Skip to content

Commit

Permalink
Added test cases on tree classes for operators <<. Thanks @Fr1eran
Browse files Browse the repository at this point in the history
  • Loading branch information
spirosmaggioros committed Nov 19, 2024
1 parent a5a2ac6 commit c4238d9
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tests/tree/avl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,14 @@ TEST_CASE("Testing get_root function in avl tree"){
REQUIRE(t.get_root() == 36);
}

TEST_CASE("Testing operator << for avl tree") {
avl_tree<int> t({1, 10, 2, 8, 6, 5});
REQUIRE_NOTHROW(cout << t);

avl_tree<char> tt({'a', 'g', 'd', 'z', 'w', 'f'});
REQUIRE_NOTHROW(cout << tt);
}

#define TREE_VISUALIZATION_H
#ifdef TREE_VISUALIZATION_H

Expand Down
8 changes: 8 additions & 0 deletions tests/tree/bst.cc
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,14 @@ TEST_CASE("testing level order in bst"){
REQUIRE(produced == sol);
}

TEST_CASE("Testing opearator << for bst") {
bst<int> t({1, 10, 5, 3, 9, 25});
REQUIRE_NOTHROW(cout << t);

bst<char> tt({'a', 'g', 'q', 'v', 'w'});
REQUIRE_NOTHROW(cout << tt);
}

#define TREE_VISUALIZATION_H
#ifdef TREE_VISUALIZATION_H

Expand Down
8 changes: 8 additions & 0 deletions tests/tree/splay_tree.cc
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,14 @@ TEST_CASE("testing level order for splay tree"){
REQUIRE(produced==sol);
}

TEST_CASE("Testing operator << for splay tree") {
splay_tree<int> t({1, 5, 3, 2, 9, 11});
REQUIRE_NOTHROW(cout << t);

splay_tree<char> tt({'a', 'b', 'w', 'z', 'f', 'd'});
REQUIRE_NOTHROW(cout << tt);
}

#define TREE_VISUALIZATION_H
#ifdef TREE_VISUALIZATION_H

Expand Down
21 changes: 21 additions & 0 deletions tests/tree/tree.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,27 @@ TEST_CASE("testing level order traversal in tree class [TREECLASS]"){
REQUIRE(produced == sol);
}

TEST_CASE("Testing operator << for tree") {
tree<int> t;
t.insert("", 1);
t.insert("l", 2);
t.insert("r", 3);
t.insert("ll", 4);
t.insert("lr", 5);
t.insert("rl", 6);
t.insert("rr", 7);
t.insert("lll", 8);
t.insert("llr", 9);
t.insert("lrl", 10);
REQUIRE_NOTHROW(cout << t);

tree<std::string> tt;
tt.insert("", "hello");
tt.insert("r", "world");
tt.insert("l", "universe");
REQUIRE_NOTHROW(cout << tt);
}

#define TREE_VISUALIZATION_H
#ifdef TREE_VISUALIZATION_H

Expand Down

0 comments on commit c4238d9

Please sign in to comment.