Lolly
1.4.28
Loading...
Searching...
No Matches
tests
Kernel
Containers
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
6
TEST_CASE
(
"Test the add_child function"
) {
7
hashtree<int, string>
t
;
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
28
TEST_CASE
(
"Test the contains function"
) {
29
hashtree<int, string>
t
;
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
43
TEST_CASE
(
"add_new_child function"
) {
44
hashtree<int, string>
t
;
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
58
TEST_CASE
(
"set_label and get_label function"
) {
59
hashtree<int, string>
t
;
60
t
->set_label (
"root"
);
61
CHECK_EQ
(
t
->get_label () ==
"root"
,
true
);
62
}
63
64
TEST_CASE
(
"Test the N and is_nil functions"
) {
65
hashtree<int, std::string>
nil_tree
;
66
CHECK_EQ
(
is_nil
(
nil_tree
),
false
);
67
}
a_lolly_test.hpp
N
int N(array< T > a)
Get the length of the array.
Definition
array.hpp:170
is_nil
bool is_nil(blackbox x)
Definition
blackbox.hpp:29
b
blackbox b[13]
Definition
blackbox_test.cpp:41
t
blackbox t[13]
Definition
blackbox_test.cpp:40
list
The list class represents a linked list.
Definition
list.hpp:48
hashtree.hpp
TEST_CASE
TEST_CASE("test for operator+= and advance()")
Definition
parse_string_test.cpp:85
string.hpp
Generated by
1.10.0