]> git.ozlabs.org Git - ccan/blob - ccan/foreach/test/run.c
foreach: new module
[ccan] / ccan / foreach / test / run.c
1 #include <ccan/foreach/foreach.h>
2 #include <ccan/tap/tap.h>
3 #include <stdio.h>
4 #include <string.h>
5 #include <ccan/foreach/foreach.c>
6
7 int main(void)
8 {
9         int i, expecti;
10         const char *p, *expectp[] = { "hello", "there", "big", "big", "world" };
11
12         plan_tests(11);
13
14         expecti = 0;
15         foreach_int(i, 0, 1, 2, 3, 4) {
16                 ok1(i == expecti);
17                 expecti++;
18         }
19
20         expecti = 0;
21         foreach_ptr(p, "hello", "there", "big", "big", "world") {
22                 ok1(strcmp(expectp[expecti], p) == 0);
23                 expecti++;
24         }
25         ok1(p == NULL);
26
27         return exit_status();
28 }
29