1 #include <ccan/asearch/asearch.h>
2 #include <ccan/array_size/array_size.h>
3 #include <ccan/tap/tap.h>
6 static int test_cmp(const int *key
, const int *elt
)
17 const int arr
[] = { INT_MIN
, 0, 1, 2, 3, 4, 5, 6, INT_MAX
};
18 unsigned int start
, num
, i
, total
= 0;
23 for (start
= 0; start
< ARRAY_SIZE(arr
); start
++) {
24 for (num
= 0; num
< ARRAY_SIZE(arr
) - start
; num
++) {
26 ok1(asearch(&key
, &arr
[start
], num
, test_cmp
) == NULL
);
28 for (i
= start
; i
< start
+num
; i
++) {
31 ret
= asearch(&key
, &arr
[start
], num
, test_cmp
);
33 ok1(ret
&& *ret
== key
);
38 diag("Tested %u searches\n", total
);