Ok, corrected insert, should have copied directly from my c implementation, all tests good, just need to test insert middle

This commit is contained in:
2026-03-21 23:25:57 -06:00
parent cf4871e201
commit 06091a1b7d
2 changed files with 31 additions and 8 deletions

View File

@@ -279,3 +279,25 @@ TEST_CASE("Insert at start of list", "[linkedlist]") {
REQUIRE(list.len() == 4);
REQUIRE(list.get(0) == 90);
}
TEST_CASE("Insert at end of list", "[linkedlist]") {
LinkedList<int> list = {};
REQUIRE(list.len() == 0);
list.append(8);
REQUIRE(list.len() == 1);
REQUIRE(list.get(0) == 8);
list.append(9);
REQUIRE(list.len() == 2);
REQUIRE(list.get(1) == 9);
list.append(10);
REQUIRE(list.len() == 3);
REQUIRE(list.get(2) == 10);
list.insert(2, 90);
REQUIRE(list.len() == 4);
REQUIRE(list.get(2) == 90);
}