From 76c0ad1b829cf9366ab71daf03fb2c88e5f9f4c9 Mon Sep 17 00:00:00 2001 From: fallenoak Date: Mon, 21 Sep 2020 22:53:46 -0500 Subject: [PATCH] chore(test): clean up and add more list tests --- test/List.cpp | 88 +++++++++++++++++++++++++++++++++++---------------- 1 file changed, 61 insertions(+), 27 deletions(-) diff --git a/test/List.cpp b/test/List.cpp index c86a8d0..ca611a8 100644 --- a/test/List.cpp +++ b/test/List.cpp @@ -24,33 +24,6 @@ TEST_CASE("TSList::LinkToHead", "[list]") { delete node; } - SECTION("links node to tail correctly") { - STORM_LIST(TestListNode) list; - - auto node = new TestListNode(); - list.LinkToTail(node); - - REQUIRE(list.Tail() == node); - - delete node; - } - - SECTION("links nodes to head and tail correctly") { - STORM_LIST(TestListNode) list; - - auto node1 = new TestListNode(); - list.LinkToHead(node1); - - auto node2 = new TestListNode(); - list.LinkToTail(node2); - - REQUIRE(list.Head() == node1); - REQUIRE(list.Tail() == node2); - - delete node1; - delete node2; - } - SECTION("links multiple nodes to head correctly") { STORM_LIST(TestListNode) list; @@ -66,4 +39,65 @@ TEST_CASE("TSList::LinkToHead", "[list]") { delete node1; delete node2; } + + SECTION("links node to head after linking node to tail correctly") { + STORM_LIST(TestListNode) list; + + auto node1 = new TestListNode(); + list.LinkToTail(node1); + + auto node2 = new TestListNode(); + list.LinkToHead(node2); + + REQUIRE(list.Head() == node2); + REQUIRE(list.Tail() == node1); + + delete node1; + delete node2; + } +} + +TEST_CASE("TSList::LinkToTail", "[list]") { + SECTION("links node to tail correctly") { + STORM_LIST(TestListNode) list; + + auto node = new TestListNode(); + list.LinkToTail(node); + + REQUIRE(list.Tail() == node); + + delete node; + } + + SECTION("links multiple nodes to tail correctly") { + STORM_LIST(TestListNode) list; + + auto node1 = new TestListNode(); + list.LinkToTail(node1); + + auto node2 = new TestListNode(); + list.LinkToTail(node2); + + REQUIRE(list.Head() == node1); + REQUIRE(list.Tail() == node2); + + delete node1; + delete node2; + } + + SECTION("links node to tail after linking node to head correctly") { + STORM_LIST(TestListNode) list; + + auto node1 = new TestListNode(); + list.LinkToHead(node1); + + auto node2 = new TestListNode(); + list.LinkToTail(node2); + + REQUIRE(list.Head() == node1); + REQUIRE(list.Tail() == node2); + + delete node1; + delete node2; + } }