diff options
author | David Robillard <d@drobilla.net> | 2021-06-30 01:55:23 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2021-06-30 01:55:23 -0400 |
commit | 85903d04bd8a99b5a2c749c2c2bc103f87b35281 (patch) | |
tree | 05876ec7266b66159783f2891b5a57cf9b907abe /test/hash_test.c | |
parent | 10a26115c115fa1bd88b1f431f965b348c9b5cdc (diff) | |
download | zix-85903d04bd8a99b5a2c749c2c2bc103f87b35281.tar.gz zix-85903d04bd8a99b5a2c749c2c2bc103f87b35281.tar.bz2 zix-85903d04bd8a99b5a2c749c2c2bc103f87b35281.zip |
Fix hash size after removing elements
Diffstat (limited to 'test/hash_test.c')
-rw-r--r-- | test/hash_test.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/test/hash_test.c b/test/hash_test.c index 2b9bb51..00f1bce 100644 --- a/test/hash_test.c +++ b/test/hash_test.c @@ -158,12 +158,19 @@ stress(void) // Remove strings for (size_t i = 0; i < n_strings; ++i) { + const size_t initial_size = zix_hash_size(hash); + // Remove string ZixStatus st = zix_hash_remove(hash, &strings[i]); if (st) { return test_fail("Failed to remove `%s'\n", strings[i]); } + // Ensure size is updated + if (zix_hash_size(hash) != initial_size - 1) { + return test_fail("Removing node did not decrease hash size\n"); + } + // Ensure second removal fails st = zix_hash_remove(hash, &strings[i]); if (st != ZIX_STATUS_NOT_FOUND) { |