blob: 47be36c862b565471d51b51d8a10188b86f97879 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
#include "pch.h"
#include "CppUnitTest.h"
#include "SinglyLinkedList.hpp"
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
namespace LinkedListUnitTests
{
TEST_CLASS(LinkedListUnitTests)
{
public:
TEST_METHOD(EmptyListHasZeroSize)
{
SinglyLinkedList<int> LinkedList{};
Assert::AreEqual(0ull, LinkedList._size);
}
TEST_METHOD(AppendingLinkedListWith1Item)
{
SinglyLinkedList<int> LinkedList{};
ListNode<int>* node = new ListNode<int>{ 5, nullptr };
bool Success = Append(&LinkedList, node);
Assert::AreEqual(5, LinkedList._head->_data);
delete node;
}
TEST_METHOD(AppendingLinkedListWith5Items)
{
SinglyLinkedList<int> LinkedList{};
ListNode<int>* node = new ListNode<int>{ 5, nullptr };
Append(&LinkedList, node);
Append(&LinkedList, node);
Append(&LinkedList, node);
Append(&LinkedList, node);
Append(&LinkedList, node);
Assert::AreEqual(5, LinkedList._head->_next->_next->_next->_next->_data);
delete node;
}
TEST_METHOD(DeleteFirstLinkWith0)
{
SinglyLinkedList<int> LinkedList{};
ListNode<int>* node = new ListNode<int>{};
bool Success = RemoveFirst(&LinkedList, node);
Assert::AreEqual(1, static_cast<int>(Success));
delete node;
}
};
}
|