summaryrefslogtreecommitdiff
path: root/src/02/04
diff options
context:
space:
mode:
authormo khan <mo.khan@gmail.com>2020-08-03 15:36:23 -0600
committermo khan <mo.khan@gmail.com>2020-08-03 15:36:23 -0600
commit3bf3ca9b3aede625fdc818e01ad0128db7cce9f6 (patch)
tree31aab1af1038493fbcbda204390476e275dda797 /src/02/04
parent3a79c28d7bb9294ddd9c519657850f2043340439 (diff)
Add a spec to insert each value in question
Diffstat (limited to 'src/02/04')
-rw-r--r--src/02/04/hash_test.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/02/04/hash_test.c b/src/02/04/hash_test.c
index 88ad925..5f7b2ad 100644
--- a/src/02/04/hash_test.c
+++ b/src/02/04/hash_test.c
@@ -36,6 +36,22 @@ Ensure(HashTable, when_a_hash_collision_occurs) {
assert_that(hash_get(hash, 21), is_equal_to(210));
}
+Ensure(HashTable, when_inserting_multiple_items_into_the_hash_table) {
+ Hash *hash = hash_init(13);
+
+ int items[] = {1, 5, 21, 26, 39, 14, 15, 16, 17, 18, 19, 20, 111, 145, 146};
+
+ for (int i = 0; i < sizeof(items); i++) {
+ int value = i * 10;
+ hash_set(hash, items[i], &value);
+ }
+
+ for (int i = 0; i < sizeof(items); i++) {
+ int key = items[i];
+ assert_that(hash_get(hash, key), is_equal_to(key * 10));
+ }
+}
+
TestSuite *hash_table_tests() {
TestSuite *suite = create_test_suite();