diff options
author | Baitinq <manuelpalenzuelamerino@gmail.com> | 2025-01-04 00:13:27 +0100 |
---|---|---|
committer | Baitinq <manuelpalenzuelamerino@gmail.com> | 2025-01-04 00:13:27 +0100 |
commit | 36ccb38adf09c1b401ce77af8e42259fd95cb74b (patch) | |
tree | 5a21341f2d397d6b2a89ce823a62d3d1e72a130a | |
parent | Call c from zig (diff) | |
download | c-hashtable-36ccb38adf09c1b401ce77af8e42259fd95cb74b.tar.gz c-hashtable-36ccb38adf09c1b401ce77af8e42259fd95cb74b.tar.bz2 c-hashtable-36ccb38adf09c1b401ce77af8e42259fd95cb74b.zip |
Add test
-rw-r--r-- | src/main.zig | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/main.zig b/src/main.zig index 926f26b..40dc44e 100644 --- a/src/main.zig +++ b/src/main.zig @@ -24,8 +24,10 @@ pub fn main() !void { } test "simple test" { - var list = std.ArrayList(i32).init(std.testing.allocator); - defer list.deinit(); // try commenting this out and see if zig detects the memory leak! - try list.append(42); - try std.testing.expectEqual(@as(i32, 42), list.pop()); + var ht = hashtable.hashtable_init(); + defer _ = hashtable.hashtable_deinit(&ht); + const data: i32 = 4; + _ = hashtable.hashtable_put(ht, @constCast("key"), @constCast(&data)); + const res: *align(1) i32 = @ptrCast(hashtable.hashtable_get(ht, @constCast("key"))); + try std.testing.expectEqual(@as(i32, 4), res.*); } |