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[] = "";
11 /* This is how many tests you plan to run */
16 ok1(!uintmap_get(&map, 1));
18 ok1(!uintmap_get(&map, 0));
20 ok1(!uintmap_del(&map, 1));
22 ok1(!uintmap_del(&map, 0));
25 ok1(uintmap_add(&map, 1, val));
26 ok1(uintmap_get(&map, 1) == val);
27 ok1(!uintmap_get(&map, 0));
30 /* Add a duplicate should fail. */
31 ok1(!uintmap_add(&map, 1, val));
34 /* Delete should succeed. */
35 ok1(uintmap_del(&map, 1) == val);
36 ok1(!uintmap_get(&map, 1));
38 ok1(!uintmap_get(&map, 0));
42 ok1(uintmap_add(&map, 0, none));
43 ok1(uintmap_add(&map, 1, val));
44 ok1(uintmap_get(&map, 1) == val);
45 ok1(uintmap_get(&map, 0) == none);
46 ok1(!uintmap_del(&map, 2));
47 ok1(uintmap_del(&map, 0) == none);
48 ok1(uintmap_get(&map, 1) == val);
49 ok1(uintmap_del(&map, 1) == val);
51 ok1(uintmap_empty(&map));
53 /* This exits depending on whether all tests passed */