1 #include <ccan/intmap/intmap.h>
2 #include <ccan/intmap/intmap.c>
3 #include <ccan/tap/tap.h>
8 const char val[] = "there";
9 const char none[] = "";
12 /* This is how many tests you plan to run */
17 ok1(!uintmap_get(&map, 1));
19 ok1(!uintmap_get(&map, 0));
21 ok1(!uintmap_del(&map, 1));
23 ok1(!uintmap_del(&map, 0));
25 ok1(!uintmap_first(&map, &idx));
27 ok1(!uintmap_last(&map, &idx));
30 ok1(uintmap_add(&map, 1, val));
31 ok1(uintmap_get(&map, 1) == val);
32 ok1(!uintmap_get(&map, 0));
34 ok1(uintmap_first(&map, &idx) == val);
36 ok1(uintmap_last(&map, &idx) == val);
39 /* Add a duplicate should fail. */
40 ok1(!uintmap_add(&map, 1, val));
43 /* Delete should succeed. */
44 ok1(uintmap_del(&map, 1) == val);
45 ok1(!uintmap_get(&map, 1));
47 ok1(!uintmap_get(&map, 0));
51 ok1(uintmap_add(&map, 0, none));
52 ok1(uintmap_add(&map, 1, val));
53 ok1(uintmap_get(&map, 1) == val);
54 ok1(uintmap_get(&map, 0) == none);
55 ok1(uintmap_first(&map, &idx) == none);
57 ok1(uintmap_last(&map, &idx) == val);
59 ok1(!uintmap_del(&map, 2));
60 ok1(uintmap_del(&map, 0) == none);
61 ok1(uintmap_get(&map, 1) == val);
62 ok1(uintmap_del(&map, 1) == val);
64 ok1(uintmap_empty(&map));
66 /* This exits depending on whether all tests passed */