add() test added + init() test added
parent
f089e9c416
commit
187a1d7f2b
35
LList.zig
35
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);
|
||||
|
|
Loading…
Reference in New Issue