1 #include <ccan/intmap/intmap.h>
2 #include <ccan/intmap/intmap.c>
3 #include <ccan/tap/tap.h>
7 SINTMAP(const char *) map;
8 const char *first = "first", *second = "second";
11 /* This is how many tests you plan to run */
15 /* Test boundaries. */
16 ok1(!sintmap_get(&map, 0x7FFFFFFFFFFFFFFFLL));
17 ok1(!sintmap_get(&map, -0x8000000000000000LL));
18 ok1(sintmap_first(&map, &s) == NULL);
19 ok1(sintmap_last(&map, &s) == NULL);
21 s = 0x7FFFFFFFFFFFFFFFLL;
22 ok1(sintmap_after(&map, &s) == NULL);
24 s = -0x8000000000000000LL;
25 ok1(sintmap_after(&map, &s) == NULL);
27 s = 0x7FFFFFFFFFFFFFFELL;
28 ok1(sintmap_after(&map, &s) == NULL);
30 ok1(sintmap_add(&map, 0x7FFFFFFFFFFFFFFFLL, first));
31 ok1(sintmap_get(&map, 0x7FFFFFFFFFFFFFFFLL) == first);
32 ok1(sintmap_first(&map, &s) == first && s == 0x7FFFFFFFFFFFFFFFLL);
33 ok1(sintmap_last(&map, &s) == first && s == 0x7FFFFFFFFFFFFFFFLL);
35 ok1(sintmap_add(&map, -0x8000000000000000LL, second));
36 ok1(sintmap_get(&map, 0x7FFFFFFFFFFFFFFFLL) == first);
37 ok1(sintmap_get(&map, -0x8000000000000000LL) == second);
38 ok1(sintmap_first(&map, &s) == second && s == -0x8000000000000000LL);
39 ok1(sintmap_after(&map, &s) == first && s == 0x7FFFFFFFFFFFFFFFLL);
40 ok1(sintmap_last(&map, &s) == first && s == 0x7FFFFFFFFFFFFFFFLL);
42 s = 0x7FFFFFFFFFFFFFFELL;
43 ok1(sintmap_after(&map, &s) == first && s == 0x7FFFFFFFFFFFFFFFLL);
45 s = -0x7FFFFFFFFFFFFFFFLL;
46 ok1(sintmap_after(&map, &s) == first && s == 0x7FFFFFFFFFFFFFFFLL);
48 ok1(sintmap_after(&map, &s) == NULL);
50 ok1(sintmap_del(&map, 0x7FFFFFFFFFFFFFFFLL) == first);
51 s = -0x8000000000000000LL;
52 ok1(sintmap_after(&map, &s) == NULL);
54 ok1(sintmap_add(&map, 0x7FFFFFFFFFFFFFFFLL, first));
55 ok1(sintmap_del(&map, 0x8000000000000000LL) == second);
56 s = -0x8000000000000000LL;
57 ok1(sintmap_after(&map, &s) == first && s == 0x7FFFFFFFFFFFFFFFLL);
59 ok1(sintmap_del(&map, 0x7FFFFFFFFFFFFFFFLL) == first);
60 ok1(sintmap_empty(&map));
62 /* This exits depending on whether all tests passed */