diff options
| author | Chanin Timbal <[email protected]> | 2024-06-06 20:11:53 -0700 |
|---|---|---|
| committer | Chanin Timbal <[email protected]> | 2024-06-06 20:11:53 -0700 |
| commit | a1d340b239eeb75159640e6b3e2bdb5586251e55 (patch) | |
| tree | 5d1a00bd6d9aa56b711e18b1476dd73f1ac53dd2 /CST 126/UnitTests | |
| parent | Created node struct and singlylinkedlist struct, and append function. Also co... (diff) | |
| download | homework-1-chaninnohea-a1d340b239eeb75159640e6b3e2bdb5586251e55.tar.xz homework-1-chaninnohea-a1d340b239eeb75159640e6b3e2bdb5586251e55.zip | |
Created Prepend function for Homework 3 - Successful unit test for prepend function
Diffstat (limited to 'CST 126/UnitTests')
| -rw-r--r-- | CST 126/UnitTests/NodeUnitTests.cpp | 24 | ||||
| -rw-r--r-- | CST 126/UnitTests/UnitTests.cpp | 37 | ||||
| -rw-r--r-- | CST 126/UnitTests/UnitTests.vcxproj | 1 | ||||
| -rw-r--r-- | CST 126/UnitTests/UnitTests.vcxproj.filters | 3 |
4 files changed, 35 insertions, 30 deletions
diff --git a/CST 126/UnitTests/NodeUnitTests.cpp b/CST 126/UnitTests/NodeUnitTests.cpp deleted file mode 100644 index cd0756f..0000000 --- a/CST 126/UnitTests/NodeUnitTests.cpp +++ /dev/null @@ -1,24 +0,0 @@ -//#include "pcd.h" -//#include "CppUnitTest.h"" -// -//using namespace Microsoft::VisualStudio::CppUnitTestFramework; -// -//#include "node.hpp" -//#include "crt_check_memory.hpp" -// -//using namespace CST126; -// -//namespace LinkedListUnitTests -//{ -// TEST_CLASS(NodeUnitTests) -// { -// public: -// -// TEST_METHOD(NodeEmptyConstructor_Success) -// { -// //Arrange -// Node<int>* newNode = new Node<int>() -// -// } -// }; -//}
\ No newline at end of file diff --git a/CST 126/UnitTests/UnitTests.cpp b/CST 126/UnitTests/UnitTests.cpp index f34984e..27ad6af 100644 --- a/CST 126/UnitTests/UnitTests.cpp +++ b/CST 126/UnitTests/UnitTests.cpp @@ -11,7 +11,7 @@ namespace LinkedListUnitTests TEST_CLASS(LinkedListUnitTests) { public: - std::list<int> my_list{ 1, 5, 6, 7, 9, 10}; + //std::list<int> my_list{2, 6}; TEST_METHOD(EmptyList) { @@ -33,7 +33,40 @@ namespace LinkedListUnitTests bool success = Append(&linkedList, node); //Assert - Assert::AreEqual(5, linkedList._head->_data); + Assert::AreEqual(5,linkedList._head->_data); + Assert::AreEqual(1ull, linkedList._size); } + + TEST_METHOD(PrependingLinkedList) + { + //Arrange + SinglyLinkedList linkedList{}; + ListNode* node = new ListNode{ 2, nullptr }; + ListNode* node2 = new ListNode{ 1, nullptr }; + ListNode* node3 = new ListNode{ 3, nullptr }; + + //Act + bool success = Append(&linkedList, node); + success = Prepend(&linkedList, node2); + success = Append(&linkedList, node3); + + ListNode* travel = linkedList._head; + + //Assert + //Assert::AreEqual(2, linkedList._head->_data); + //Assert::AreEqual(6, linkedList._head->_next); + //Assert::AreEqual(2ull, linkedList._size); + + Assert::AreEqual(node2->_data, linkedList._head->_data); + + for (auto i = 1; i <= 3; i++) + { + Assert::AreEqual(i, travel->_data); + travel = travel->_next; + } + } + + + }; } diff --git a/CST 126/UnitTests/UnitTests.vcxproj b/CST 126/UnitTests/UnitTests.vcxproj index 74883d6..c6d02f3 100644 --- a/CST 126/UnitTests/UnitTests.vcxproj +++ b/CST 126/UnitTests/UnitTests.vcxproj @@ -157,7 +157,6 @@ </Link> </ItemDefinitionGroup> <ItemGroup> - <ClCompile Include="NodeUnitTests.cpp" /> <ClCompile Include="pch.cpp"> <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader> <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader> diff --git a/CST 126/UnitTests/UnitTests.vcxproj.filters b/CST 126/UnitTests/UnitTests.vcxproj.filters index 317d8de..8130616 100644 --- a/CST 126/UnitTests/UnitTests.vcxproj.filters +++ b/CST 126/UnitTests/UnitTests.vcxproj.filters @@ -21,9 +21,6 @@ <ClCompile Include="pch.cpp"> <Filter>Source Files</Filter> </ClCompile> - <ClCompile Include="NodeUnitTests.cpp"> - <Filter>Source Files</Filter> - </ClCompile> </ItemGroup> <ItemGroup> <ClInclude Include="pch.h"> |