X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Fintmap%2Ftest%2Frun-after-fail.c;fp=ccan%2Fintmap%2Ftest%2Frun-after-fail.c;h=4105b12f1ae7565e21321be33209114f6788cefb;hb=4d9c7e1c2f899930a0bef5f05391615875ff668c;hp=0000000000000000000000000000000000000000;hpb=e59acd521d11c1f392264762d79195fd6cc2b992;p=ccan diff --git a/ccan/intmap/test/run-after-fail.c b/ccan/intmap/test/run-after-fail.c new file mode 100644 index 00000000..4105b12f --- /dev/null +++ b/ccan/intmap/test/run-after-fail.c @@ -0,0 +1,26 @@ +#include +#include +#include + +int main(void) +{ + UINTMAP(const char *) map; + u64 idx; + + /* This is how many tests you plan to run */ + plan_tests(2); + + uintmap_init(&map); + assert(uintmap_add(&map, 0x103, "103")); + assert(uintmap_add(&map, 0x10b, "10b")); + + uintmap_first(&map, &idx); + ok1(idx > 0xF); + idx = 0xF; + ok1(strcmp(uintmap_after(&map, &idx), "103") == 0); + + uintmap_clear(&map); + + /* This exits depending on whether all tests passed */ + return exit_status(); +}