diff --git a/tests/tree/avl.cc b/tests/tree/avl.cc index 1752d9fa..8ead82d6 100644 --- a/tests/tree/avl.cc +++ b/tests/tree/avl.cc @@ -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 t({1, 10, 2, 8, 6, 5}); + REQUIRE_NOTHROW(cout << t); + + avl_tree tt({'a', 'g', 'd', 'z', 'w', 'f'}); + REQUIRE_NOTHROW(cout << tt); +} + #define TREE_VISUALIZATION_H #ifdef TREE_VISUALIZATION_H diff --git a/tests/tree/bst.cc b/tests/tree/bst.cc index 9a260aa2..830b3e50 100644 --- a/tests/tree/bst.cc +++ b/tests/tree/bst.cc @@ -151,6 +151,14 @@ TEST_CASE("testing level order in bst"){ REQUIRE(produced == sol); } +TEST_CASE("Testing opearator << for bst") { + bst t({1, 10, 5, 3, 9, 25}); + REQUIRE_NOTHROW(cout << t); + + bst tt({'a', 'g', 'q', 'v', 'w'}); + REQUIRE_NOTHROW(cout << tt); +} + #define TREE_VISUALIZATION_H #ifdef TREE_VISUALIZATION_H diff --git a/tests/tree/splay_tree.cc b/tests/tree/splay_tree.cc index 04e2926e..01b8a754 100644 --- a/tests/tree/splay_tree.cc +++ b/tests/tree/splay_tree.cc @@ -128,6 +128,14 @@ TEST_CASE("testing level order for splay tree"){ REQUIRE(produced==sol); } +TEST_CASE("Testing operator << for splay tree") { + splay_tree t({1, 5, 3, 2, 9, 11}); + REQUIRE_NOTHROW(cout << t); + + splay_tree tt({'a', 'b', 'w', 'z', 'f', 'd'}); + REQUIRE_NOTHROW(cout << tt); +} + #define TREE_VISUALIZATION_H #ifdef TREE_VISUALIZATION_H diff --git a/tests/tree/tree.cc b/tests/tree/tree.cc index d0de6f33..138888f4 100644 --- a/tests/tree/tree.cc +++ b/tests/tree/tree.cc @@ -53,6 +53,27 @@ TEST_CASE("testing level order traversal in tree class [TREECLASS]"){ REQUIRE(produced == sol); } +TEST_CASE("Testing operator << for tree") { + tree 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 tt; + tt.insert("", "hello"); + tt.insert("r", "world"); + tt.insert("l", "universe"); + REQUIRE_NOTHROW(cout << tt); +} + #define TREE_VISUALIZATION_H #ifdef TREE_VISUALIZATION_H