-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_tree.cpp
More file actions
28 lines (15 loc) · 748 Bytes
/
Copy pathtest_tree.cpp
File metadata and controls
28 lines (15 loc) · 748 Bytes
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
#include "catch.hpp"
#include "Tree.hpp" // Include your Tree header file
TEST_CASE("Tree functionality tests", "[Tree]") {
Tree<std::string, int> tree;
// Testing normal insertion
REQUIRE(tree.insert("Root") == true);
REQUIRE(tree.insert("Child1", "Root", 1) == true);
REQUIRE(tree.insert("Child2", "Root", 2) == true);
// Testing insertion of a node with non-existent parent
REQUIRE_THROWS_AS(tree.insert("Child3", "NonExistent", 3), std::runtime_error);
// Testing insertion of a duplicate node
REQUIRE_THROWS_AS(tree.insert("Child1", "Root", 1), std::runtime_error);
REQUIRE(tree.getcount() == 3);
tree.printWholeTree();
}