]> git.ozlabs.org Git - ccan/blob - ccan/strset/test/run-iterate-const.c
setset: fix API to match strmap and common sense.
[ccan] / ccan / strset / test / run-iterate-const.c
1 #include <ccan/strset/strset.h>
2 #include <ccan/strset/strset.c>
3 #include <ccan/tap/tap.h>
4
5 static bool found = false;
6
7 /* Make sure const args work. */
8 static bool find_string(const char *str, const char *cmp)
9 {
10         if (strcmp(str, cmp) == 0)
11                 found = true;
12         return false;
13 }
14
15 int main(void)
16 {
17         struct strset set;
18
19         plan_tests(3);
20
21         strset_init(&set);
22         ok1(strset_add(&set, "hello"));
23         ok1(strset_add(&set, "world"));
24         strset_iterate(&set, find_string, (const char *)"hello");
25         ok1(found);
26         strset_clear(&set);
27
28         /* This exits depending on whether all tests passed */
29         return exit_status();
30 }