- 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_mask(&ht));
+ perfect_bit = ht_perfect_mask(&ht);
+ htable_add(&ht, 0, (void *)((uintptr_t)&val[NUM_VALS-1]
+ | perfect_bit));
+ ok1(ht_perfect_mask(&ht) == 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_mask(&ht) != 0);
+ htable_clear(&ht);
+
+ ok1(htable_init_sized(&ht, hash, NULL, 1024));
+ ok1(ht_max(&ht) >= 1024);
+ htable_clear(&ht);
+
+ ok1(htable_init_sized(&ht, hash, NULL, 1023));
+ ok1(ht_max(&ht) >= 1023);
+ htable_clear(&ht);
+
+ ok1(htable_init_sized(&ht, hash, NULL, 1025));
+ ok1(ht_max(&ht) >= 1025);
+ htable_clear(&ht);
+