X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Fasearch%2Ftest%2Frun-strings.c;fp=ccan%2Fasearch%2Ftest%2Frun-strings.c;h=3ec453842f8df6e3e6a6d8f69f2d2edea49c83b6;hb=93d1e1063c6b5599ab334398234d2de05c1236e8;hp=0000000000000000000000000000000000000000;hpb=c10aab24894083ac7ed2c5e349a2767457314982;p=ccan diff --git a/ccan/asearch/test/run-strings.c b/ccan/asearch/test/run-strings.c new file mode 100644 index 00000000..3ec45384 --- /dev/null +++ b/ccan/asearch/test/run-strings.c @@ -0,0 +1,22 @@ +#include +#include +#include +#include + +static int cmp(const int *key, const char *const *elem) +{ + return *key - atoi(*elem); +} + +int main(void) +{ + const char *args[] = { "1", "4", "7", "9" }; + int key = 7; + const char **p; + + plan_tests(1); + p = asearch(&key, args, ARRAY_SIZE(args), cmp); + ok1(p == &args[2]); + + return exit_status(); +}