]> git.ozlabs.org Git - ccan/blob - ccan/intmap/test/run-after-fail.c
intmap: add test case which failed, extracted from real world usage.
[ccan] / ccan / intmap / test / run-after-fail.c
1 #include <ccan/intmap/intmap.h>
2 #include <ccan/intmap/intmap.c>
3 #include <ccan/tap/tap.h>
4
5 int main(void)
6 {
7         UINTMAP(const char *) map;
8         u64 idx;
9
10         /* This is how many tests you plan to run */
11         plan_tests(2);
12
13         uintmap_init(&map);
14         assert(uintmap_add(&map, 0x103, "103"));
15         assert(uintmap_add(&map, 0x10b, "10b"));
16
17         uintmap_first(&map, &idx);
18         ok1(idx > 0xF);
19         idx = 0xF;
20         ok1(strcmp(uintmap_after(&map, &idx), "103") == 0);
21
22         uintmap_clear(&map);
23
24         /* This exits depending on whether all tests passed */
25         return exit_status();
26 }