From 187a1d7f2bee01ea1d00ac32c1b0e2ed4b6ab7df Mon Sep 17 00:00:00 2001 From: 3011357 <3011357@stud.hs-mannheim.de> Date: Sun, 10 Nov 2024 20:24:27 +0100 Subject: [PATCH] add() test added + init() test added --- LList.zig | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/LList.zig b/LList.zig index 82c27df..64456a4 100644 --- a/LList.zig +++ b/LList.zig @@ -98,7 +98,19 @@ pub fn Node(comptime T: type) type { }; } -test "leaks" { +test "init()" { + + var testList: LList(u64) = undefined; + try testList.init(testingAllocator); + + try expect(testList.first == null); + try expect(testList.counter == 0); + + try testList.deinit(); + +} + +test "deinit()" { var testList: LList(u64) = undefined; try testList.init(testingAllocator); @@ -111,8 +123,27 @@ test "leaks" { } +test "add()" { -test "size" { + var testList: LList(u64) = undefined; + try testList.init(testingAllocator); + + const firstNode = try testList.add(1); + const secondNode = try testList.add(2); + const thirdNode = try testList.add(3); + const fourtNode = try testList.add(4); + + try expect(firstNode.value.* == 1); + try expect(secondNode.value.* == 2); + try expect(thirdNode.value.* == 3); + try expect(fourtNode.value.* == 4); + + try testList.deinit(); + +} + + +test "size()" { var testList: LList(u64) = undefined; try testList.init(testingAllocator);