52 int_duplicate(
const int *i)
54 int *j = cpl_malloc(
sizeof *j);
63 cpl_free(*i); *i = NULL;
69 int_less_than(
const int *i,
const int *j,
void *data)
76 int_evaluate(
const int *i,
void *data)
85 int_list *l = int_list_new();
89 test( int_list_size(l) == 0 );
91 int_list_insert(l, int_duplicate(&x));
92 int_list_insert(l, int_duplicate(&x));
94 int_list_insert(l, int_duplicate(&x));
96 test( int_list_size(l) == 3 );
100 test_eq( *int_list_min (l, int_less_than, NULL), 0 );
101 test_eq( *int_list_max (l, int_less_than, NULL), 8 );
102 test_eq( *int_list_min_val(l, int_evaluate, NULL), 0 );
103 test_eq( *int_list_max_val(l, int_evaluate, NULL), 8 );
106 const int_list *l2 = int_list_duplicate(l, int_duplicate);
108 test( *int_list_kth_const(l2, 1, int_less_than, NULL) == 0 );
109 test( *int_list_kth_const(l2, 3, int_less_than, NULL) == 8 );
110 test( *int_list_kth_const(l2, 3, int_less_than, NULL) == 8 );
111 test( *int_list_kth_const(l2, 2, int_less_than, NULL) == 8 );
113 test( *int_list_max_const(l2, int_less_than, NULL) == 8 );
118 for (int_list_first_pair_const(l2, &p1, &p2);
120 int_list_next_pair_const(l2, &p1, &p2)) {
126 test_eq( num_pairs, (3*2/2));
129 int_list_delete_const(&l2, int_delete);
135 ip = int_list_remove(l, int_list_first(l));
138 test( int_list_size(l) == 2 );
141 ip = int_list_remove(l, int_list_next(l));
143 test( int_list_size(l) == 1 );
145 ip = int_list_remove(l, int_list_first(l));
147 test( int_list_size(l) == 0 );
150 int_list_delete(&l, int_delete);