summary refs log tree commit diff
diff options
context:
space:
mode:
authorBaitinq <manuelpalenzuelamerino@gmail.com>2025-01-05 12:27:11 +0100
committerBaitinq <manuelpalenzuelamerino@gmail.com>2025-01-05 12:27:11 +0100
commit81a27b6905ea9a67ba070648a158a66015a77de0 (patch)
treef14af94a0112f758418617a5597b42f6ce9d1310
parentfix memory bug in hashmap implementation (diff)
downloadc-hashtable-81a27b6905ea9a67ba070648a158a66015a77de0.tar.gz
c-hashtable-81a27b6905ea9a67ba070648a158a66015a77de0.tar.bz2
c-hashtable-81a27b6905ea9a67ba070648a158a66015a77de0.zip
also fuzz deletions
-rw-r--r--src/main.zig6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/main.zig b/src/main.zig
index 5ad6dd3..3f6bcc8 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -60,7 +60,7 @@ test "fuzzing" {
                 const key: [*c]u8 = @constCast(@as([2]u8, .{ source[i + 1], 0 })[0..]);
                 const value: [*c]u8 = @constCast(@as([2]u8, .{ source[i + 2], 0 })[0..]);
 
-                switch (operation % 2) {
+                switch (operation % 3) {
                     0 => {
                         const ret: ?[*]u8 = @ptrCast(hashtable.hashtable_get(ht, key));
                         const reference_ret: ?[]const u8 = reference_hashmap.get(key[0..2]);
@@ -74,6 +74,10 @@ test "fuzzing" {
                         _ = hashtable.hashtable_put(ht, key, @constCast(value), @sizeOf(u8) * 2);
                         try reference_hashmap.put(key[0..2], @as([*]u8, value)[0..2]);
                     },
+                    2 => {
+                        _ = hashtable.hashtable_remove(ht, key);
+                        reference_hashmap.remove(key[0..2]);
+                    },
                     else => unreachable,
                 }
             }