- find_vals(ht, val, NUM_VALS);
- ok1(!htable_get(ht, hash(&dne, NULL), objcmp, &dne));
-
+ find_vals(&ht, val, NUM_VALS);
+ ok1(!htable_get(&ht, hash(&dne, NULL), objcmp, &dne));
+
+ /* Corner cases: wipe out the perfect bit using bogus pointer. */
+ htable_clear(&ht);
+ htable_add(&ht, 0, (void *)((uintptr_t)&val[NUM_VALS-1]));
+ ok1(ht.perfect_bit);
+ perfect_bit = ht.perfect_bit;
+ htable_add(&ht, 0, (void *)((uintptr_t)&val[NUM_VALS-1]
+ | perfect_bit));
+ ok1(ht.perfect_bit == 0);
+ htable_del(&ht, 0, (void *)((uintptr_t)&val[NUM_VALS-1] | perfect_bit));
+
+ /* Enlarging should restore it... */
+ add_vals(&ht, val, 0, NUM_VALS-1);
+
+ 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);
+