setup project for assignment 3

This commit is contained in:
2021-01-08 16:01:54 +01:00
parent 51b54f68fb
commit 2f9f32e50e
13 changed files with 268 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
include(FetchContent)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG release-1.10.0
)
FetchContent_MakeAvailable(googletest)
add_executable(node_unit_test Node_test.cpp)
target_link_libraries(node_unit_test PUBLIC gtest gtest_main)
target_link_libraries(node_unit_test PUBLIC sets)
add_test(NodeTest node_unit_test)

View File

@@ -0,0 +1,32 @@
#include <gtest/gtest.h>
#include <lib/Node.h>
TEST(NodeTest, DummyNode_smaller_int) {
Node * n = Node::Dummy();
ASSERT_FALSE(n->is_smaller_than(std::numeric_limits<int>::max()));
ASSERT_FALSE(n->is_smaller_than(std::numeric_limits<int>::min()));
}
TEST(NodeTest, DummyNode_smaller_node) {
Node * n = Node::Dummy();
Node * max = new Node(std::numeric_limits<int>::max());
Node * min = new Node(std::numeric_limits<int>::min());
ASSERT_FALSE(n->is_smaller_than(max));
ASSERT_FALSE(n->is_smaller_than(min));
}
TEST(NodeTest, LockingUnlockingNode) {
Node * n = new Node(1);
n->lock();
n->unlock();
}
TEST(NodeTest, ChainingNode) {
Node* first = Node::Dummy();
Node* last = Node::Dummy();
first->next = last;
ASSERT_TRUE(first->next == last);
}