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);