hashmap quickfix

This commit is contained in:
Leonardo committed 2019-10-09 00:53:40 -03:00
1 parent b9b507bf07
commit e06e795ed8
2 files changed
+18 -1

No files matched your search

+2 -1
View File
@@ -360,7 +360,7 @@ static const size_t cmc_hashtable_primes[] = {53, 97, 191, 383, 769, 1531,
\
break; \
} \
else if (target->dist < original_pos - pos) \
else if (target->dist < pos - original_pos) \
{ \
K tmp_k = target->key; \
V tmp_v = target->value; \
@@ -527,6 +527,7 @@ static const size_t cmc_hashtable_primes[] = {53, 97, 191, 383, 769, 1531,
{ \
return _map_->capacity; \
} \
\
double PFX##_load(SNAME *_map_) \
{ \
return _map_->load; \
+16
View File
@@ -124,6 +124,22 @@ CMC_CREATE_UNIT(hashmap_test, true, {
hm_free(map, NULL);
});
CMC_CREATE_TEST(insert[distances], {
hashmap *map = hm_new(1, 0.99, cmp, hashcapminus4);
cmc_assert_not_equals(ptr, NULL, map);
cmc_assert_equals(size_t, cmc_hashtable_primes[0], hm_capacity(map));
for (size_t i = 0; i < 6; i++)
cmc_assert(hm_insert(map, i, i));
for (size_t i = 0; i < 6; i++)
cmc_assert_equals(size_t, i, hm_impl_get_entry(map, i)->dist);
hm_free(map, NULL);
});
CMC_CREATE_TEST(insert[buffer growth and item preservation], {
hashmap *map = hm_new(1, 0.99, cmp, hash);