1 #include <ccan/asearch/asearch.h>
2 #include <ccan/array_size/array_size.h>
3 #include <ccan/tap/tap.h>
6 #include <ccan/asearch/asearch.c>
8 static int test_cmp(const int *key, const int *elt, void *ctx)
19 const int arr[] = { INT_MIN, 0, 1, 2, 3, 4, 5, 6, INT_MAX };
20 unsigned int start, num, i, total = 0;
25 for (start = 0; start < ARRAY_SIZE(arr); start++) {
26 for (num = 0; num < ARRAY_SIZE(arr) - start; num++) {
28 ok1(asearch(&key, &arr[start], num, test_cmp,
31 for (i = start; i < start+num; i++) {
34 ret = asearch(&key, &arr[start], num,
37 ok1(ret && *ret == key);
42 diag("Tested %u searches\n", total);