add() test added + init() test added

main
Anastasia Kisner 2024-11-10 20:24:27 +01:00
parent f089e9c416
commit 187a1d7f2b
1 changed files with 33 additions and 2 deletions

View File

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