X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Fhtable%2Ftest%2Frun.c;h=46514c7202f2438b54b15aca2f9c0800ca5f5dd4;hb=5ff76d983c62c8fc489672a1f89927ee3ba58e5d;hp=7fc05e24f6bfac4b38748491911c6741d0b841a8;hpb=0b93bd102aad6b61f1e569fb12aabc6352a1d7cd;p=ccan diff --git a/ccan/htable/test/run.c b/ccan/htable/test/run.c index 7fc05e24..46514c72 100644 --- a/ccan/htable/test/run.c +++ b/ccan/htable/test/run.c @@ -10,7 +10,7 @@ /* We use the number divided by two as the hash (for lots of collisions), plus set all the higher bits so we can detect if they don't get masked out. */ -static size_t hash(const void *elem, void *unused) +static size_t hash(const void *elem, void *unused UNNEEDED) { size_t h = *(uint64_t *)elem / 2; h |= -1UL << NUM_BITS; @@ -95,7 +95,7 @@ static bool check_mask(struct htable *ht, uint64_t val[], unsigned num) return true; } -int main(int argc, char *argv[]) +int main(void) { unsigned int i, weight; uintptr_t perfect_bit; @@ -105,7 +105,7 @@ int main(int argc, char *argv[]) void *p; struct htable_iter iter; - plan_tests(29); + plan_tests(36); for (i = 0; i < NUM_VALS; i++) val[i] = i; dne = i; @@ -156,6 +156,11 @@ int main(int argc, char *argv[]) i++; ok1(i == NUM_VALS); + i = 0; + for (p = htable_prev(&ht, &iter); p; p = htable_prev(&ht, &iter)) + i++; + ok1(i == NUM_VALS); + /* Delete all. */ del_vals(&ht, val, NUM_VALS); ok1(!htable_get(&ht, hash(&val[0], NULL), objcmp, &val[0])); @@ -191,5 +196,17 @@ int main(int argc, char *argv[]) ok1(ht.perfect_bit != 0); htable_clear(&ht); + ok1(htable_init_sized(&ht, hash, NULL, 1024)); + ok1(ht.max >= 1024); + htable_clear(&ht); + + ok1(htable_init_sized(&ht, hash, NULL, 1023)); + ok1(ht.max >= 1023); + htable_clear(&ht); + + ok1(htable_init_sized(&ht, hash, NULL, 1025)); + ok1(ht.max >= 1025); + htable_clear(&ht); + return exit_status(); }