X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Fintmap%2Ftest%2Frun.c;h=86f09af47e0f4f2ced43d782b79c185d174bbb4d;hp=41efc442d88aaade56eb3996bc8a85ea60fe9235;hb=09bb99b92546f3e8be6bb0f9218924b8491be461;hpb=8502a66a5ba8916758c67ea5b0b404386c34da24 diff --git a/ccan/intmap/test/run.c b/ccan/intmap/test/run.c index 41efc442..86f09af4 100644 --- a/ccan/intmap/test/run.c +++ b/ccan/intmap/test/run.c @@ -7,9 +7,10 @@ int main(void) UINTMAP(char *) map; const char val[] = "there"; const char none[] = ""; + uint64_t idx; /* This is how many tests you plan to run */ - plan_tests(28); + plan_tests(40); uintmap_init(&map); @@ -21,11 +22,19 @@ int main(void) ok1(errno == ENOENT); ok1(!uintmap_del(&map, 0)); ok1(errno == ENOENT); + ok1(!uintmap_first(&map, &idx)); + ok1(errno == ENOENT); + ok1(!uintmap_last(&map, &idx)); + ok1(errno == ENOENT); ok1(uintmap_add(&map, 1, val)); ok1(uintmap_get(&map, 1) == val); ok1(!uintmap_get(&map, 0)); ok1(errno == ENOENT); + ok1(uintmap_first(&map, &idx) == val); + ok1(idx == 1); + ok1(uintmap_last(&map, &idx) == val); + ok1(idx == 1); /* Add a duplicate should fail. */ ok1(!uintmap_add(&map, 1, val)); @@ -43,6 +52,10 @@ int main(void) ok1(uintmap_add(&map, 1, val)); ok1(uintmap_get(&map, 1) == val); ok1(uintmap_get(&map, 0) == none); + ok1(uintmap_first(&map, &idx) == none); + ok1(idx == 0); + ok1(uintmap_last(&map, &idx) == val); + ok1(idx == 1); ok1(!uintmap_del(&map, 2)); ok1(uintmap_del(&map, 0) == none); ok1(uintmap_get(&map, 1) == val);