From 36ccb38adf09c1b401ce77af8e42259fd95cb74b Mon Sep 17 00:00:00 2001 From: Baitinq Date: Sat, 4 Jan 2025 00:13:27 +0100 Subject: Add test --- src/main.zig | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src') 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.*); } -- cgit 1.4.1