Lolly 1.4.27
Loading...
Searching...
No Matches
hashtree_test.cpp
Go to the documentation of this file.
1#include "a_lolly_test.hpp"
2#include "hashtree.hpp"
3#include "string.hpp"
4#include <string>
5
6TEST_CASE ("Test the add_child function") {
8 string a ("one");
9 string b ("two");
10 hashtree<int, string> child1 (string ("one"));
11 hashtree<int, string> child2 (string ("two"));
12 hashtree<int, string> child3 (string ("three"));
13 t->add_child (1, child1);
14 t->add_child (2, child2);
15
16 CHECK (N (child1) == 0);
17 CHECK (N (child2) == 0);
18 CHECK (N (t) == 2);
19
20 child1->add_child (3, child3);
21
22 CHECK (N (child1) == 1);
23 CHECK (N (child2) == 0);
24 CHECK_EQ (N (t) == 3, false);
25 CHECK_EQ (N (t) == 2, true);
26}
27
28TEST_CASE ("Test the contains function") {
30
31 string a ("one");
32 string b ("two");
33
34 hashtree<int, string> child1 (string ("one"));
35 hashtree<int, string> child2 (string ("two"));
36 t->add_child (1, child1);
37 t->add_child (2, child2);
38 CHECK (t->contains (1));
39 CHECK (t->contains (2));
40 CHECK (!t->contains (3));
41}
42
43TEST_CASE ("add_new_child function") {
45
46 string a ("one");
47 string b ("two");
48
49 hashtree<int, string> child1 (string ("one"));
50 hashtree<int, string> child2 (string ("two"));
51 t->add_child (1, child1);
52 t->add_child (2, child2);
53 t->add_new_child (3);
54 CHECK_EQ (N (child2) == 3, false);
55 CHECK (t->contains (3));
56}
57
58TEST_CASE ("set_label and get_label function") {
60 t->set_label ("root");
61 CHECK_EQ (t->get_label () == "root", true);
62}
63
64TEST_CASE ("Test the N and is_nil functions") {
66 CHECK_EQ (is_nil (nil_tree), false);
67}
int N(array< T > a)
Get the length of the array.
Definition array.hpp:170
bool is_nil(blackbox x)
Definition blackbox.hpp:29
blackbox b[13]
blackbox t[13]
The list class represents a linked list.
Definition list.hpp:48
TEST_CASE("test for operator+= and advance()")