X-Git-Url: https://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Fintmap%2Ftest%2Frun-order-smallsize.c;h=8121f27697fcda19ad617112070758169ce7643e;hp=63c5b9c9f63514f7c58e857c2c992af11cf7c669;hb=7aac849abf06ef469c2aad9a0dd6e3bb82ef1f96;hpb=f7ead5da96bfb5ce3ebffe11256bbcb5f4b4f750 diff --git a/ccan/intmap/test/run-order-smallsize.c b/ccan/intmap/test/run-order-smallsize.c index 63c5b9c9..8121f276 100644 --- a/ccan/intmap/test/run-order-smallsize.c +++ b/ccan/intmap/test/run-order-smallsize.c @@ -19,6 +19,15 @@ static bool check_umap(const umap *map) bool last = true; /* Must be in order, must contain value. */ + prev = 256; + for (v = uintmap_last(map, &i); v; v = uintmap_before(map, &i)) { + if (i >= prev) + return false; + if (*v != i) + return false; + prev = i; + } + prev = -1; for (v = uintmap_first(map, &i); v; v = uintmap_after(map, &i)) { if (i <= prev) @@ -40,6 +49,15 @@ static bool check_smap(const smap *map) bool last = true; /* Must be in order, must contain value. */ + prev = 0x80000000ULL; + for (v = sintmap_last(map, &i); v; v = sintmap_before(map, &i)) { + if (i >= prev) + return false; + if (*v != i) + return false; + prev = i; + } + prev = -0x80000001ULL; for (v = sintmap_first(map, &i); v; v = sintmap_after(map, &i)) { if (i <= prev) @@ -52,7 +70,7 @@ static bool check_smap(const smap *map) return last; } -int main(void) +int main(int argc, char *argv[]) { umap umap; smap smap; @@ -64,6 +82,9 @@ int main(void) uintmap_init(&umap); sintmap_init(&smap); + if (argc > 1) + srandom(atoi(argv[1])); + for (i = 0; i < NUM; i++) { urandoms[i] = random(); srandoms[i] = random();