intmap: clean up iterators.
[ccan] / ccan / intmap / test / run-signed-int.c
index 8e95e8f4f29f1ff78ee31c2a0409b98bc4450af6..7c86a940c8538ef9a28e66099ed4e1fe57c473cb 100644 (file)
@@ -6,6 +6,7 @@ int main(void)
 {
        SINTMAP(const char *) map;
        const char *first = "first", *second = "second";
+       int64_t s;
 
        /* This is how many tests you plan to run */
        plan_tests(35);
@@ -14,36 +15,43 @@ int main(void)
        /* Test boundaries. */
        ok1(!sintmap_get(&map, 0x7FFFFFFFFFFFFFFFLL));
        ok1(!sintmap_get(&map, -0x8000000000000000LL));
-       ok1(sintmap_first(&map) == 0x7FFFFFFFFFFFFFFFLL);
+       ok1(sintmap_first(&map, &s) == NULL);
        ok1(errno == ENOENT);
-       ok1(sintmap_after(&map, 0x7FFFFFFFFFFFFFFFLL) == 0x7FFFFFFFFFFFFFFFLL);
+       s = 0x7FFFFFFFFFFFFFFFLL;
+       ok1(sintmap_after(&map, &s) == NULL);
        ok1(errno == ENOENT);
-       ok1(sintmap_after(&map, -0x8000000000000000LL) == 0x7FFFFFFFFFFFFFFFLL);
+       s = -0x8000000000000000LL;
+       ok1(sintmap_after(&map, &s) == NULL);
        ok1(errno == ENOENT);
-       ok1(sintmap_after(&map, 0x7FFFFFFFFFFFFFFELL) == 0x7FFFFFFFFFFFFFFFLL);
+       s = 0x7FFFFFFFFFFFFFFELL;
+       ok1(sintmap_after(&map, &s) == NULL);
        ok1(errno == ENOENT);
        ok1(sintmap_add(&map, 0x7FFFFFFFFFFFFFFFLL, first));
        ok1(sintmap_get(&map, 0x7FFFFFFFFFFFFFFFLL) == first);
-       ok1(sintmap_first(&map) == 0x7FFFFFFFFFFFFFFFLL);
+       ok1(sintmap_first(&map, &s) == first && s == 0x7FFFFFFFFFFFFFFFLL);
        ok1(errno == 0);
        ok1(sintmap_add(&map, -0x8000000000000000LL, second));
        ok1(sintmap_get(&map, 0x7FFFFFFFFFFFFFFFLL) == first);
        ok1(sintmap_get(&map, -0x8000000000000000LL) == second);
-       ok1(sintmap_first(&map) == -0x8000000000000000LL);
-       ok1(sintmap_after(&map, -0x8000000000000000LL) == 0x7FFFFFFFFFFFFFFFLL);
+       ok1(sintmap_first(&map, &s) == second && s == -0x8000000000000000LL);
+       ok1(sintmap_after(&map, &s) == first && s == 0x7FFFFFFFFFFFFFFFLL);
        ok1(errno == 0);
-       ok1(sintmap_after(&map, 0x7FFFFFFFFFFFFFFELL) == 0x7FFFFFFFFFFFFFFFLL);
+       s = 0x7FFFFFFFFFFFFFFELL;
+       ok1(sintmap_after(&map, &s) == first && s == 0x7FFFFFFFFFFFFFFFLL);
        ok1(errno == 0);
-       ok1(sintmap_after(&map, -0x7FFFFFFFFFFFFFFFLL) == 0x7FFFFFFFFFFFFFFFLL);
+       s = -0x7FFFFFFFFFFFFFFFLL;
+       ok1(sintmap_after(&map, &s) == first && s == 0x7FFFFFFFFFFFFFFFLL);
        ok1(errno == 0);
-       ok1(sintmap_after(&map, 0x7FFFFFFFFFFFFFFFLL) == 0x7FFFFFFFFFFFFFFFLL);
+       ok1(sintmap_after(&map, &s) == NULL);
        ok1(errno == ENOENT);
        ok1(sintmap_del(&map, 0x7FFFFFFFFFFFFFFFLL) == first);
-       ok1(sintmap_after(&map, -0x8000000000000000LL) == 0x7FFFFFFFFFFFFFFFLL);
+       s = -0x8000000000000000LL;
+       ok1(sintmap_after(&map, &s) == NULL);
        ok1(errno == ENOENT);
        ok1(sintmap_add(&map, 0x7FFFFFFFFFFFFFFFLL, first));
        ok1(sintmap_del(&map, 0x8000000000000000LL) == second);
-       ok1(sintmap_after(&map, -0x8000000000000000LL) == 0x7FFFFFFFFFFFFFFFLL);
+       s = -0x8000000000000000LL;
+       ok1(sintmap_after(&map, &s) == first && s == 0x7FFFFFFFFFFFFFFFLL);
        ok1(errno == 0);
        ok1(sintmap_del(&map, 0x7FFFFFFFFFFFFFFFLL) == first);
        ok1(sintmap_empty(&map));