Skip to content

Commit a80d0a5

Browse files
committed
splits expression_tree_op_node unit tests into AND and OR test cases
1 parent 01bc017 commit a80d0a5

File tree

1 file changed

+79
-4
lines changed

1 file changed

+79
-4
lines changed

tests/expression_tree_op_node.cpp

Lines changed: 79 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,17 @@
66

77
using namespace attwoodn::expression_tree;
88

9-
void test_one_layer_op_node_evaluation();
9+
void test_AND_op_node_evaluation();
10+
void test_OR_op_node_evaluation();
1011

1112
int main(int argc, char** argv) {
12-
test_one_layer_op_node_evaluation();
13+
test_AND_op_node_evaluation();
14+
test_OR_op_node_evaluation();
1315

1416
return EXIT_SUCCESS;
1517
}
1618

17-
void test_one_layer_op_node_evaluation() {
19+
void test_AND_op_node_evaluation() {
1820
auto child_expr1 = make_expr(&test_fixture::some_string, op::equals, std::string("hello, world!"));
1921
auto child_expr2 = make_expr(&test_fixture::some_uint, op::less_than, (uint16_t) 500);
2022

@@ -63,4 +65,77 @@ void test_one_layer_op_node_evaluation() {
6365

6466
fixture.some_string = "hello, world!";
6567
assert(expr->evaluate(fixture));
66-
}
68+
}
69+
70+
void test_OR_op_node_evaluation() {
71+
auto child_expr1 = make_expr(&test_fixture::some_string, op::equals, std::string("hello, world!"));
72+
auto child_expr2 = make_expr(&test_fixture::some_uint, op::less_than, (uint16_t) 500);
73+
74+
auto expr = make_op_node<test_fixture>(child_expr1, boolean_op::OR, child_expr2);
75+
76+
test_fixture fixture;
77+
fixture.some_string = "hello, world!";
78+
fixture.some_uint = 499;
79+
assert(expr->evaluate(fixture));
80+
81+
fixture.some_uint = 0;
82+
assert(expr->evaluate(fixture));
83+
84+
fixture.some_uint = 1;
85+
assert(expr->evaluate(fixture));
86+
87+
fixture.some_uint = 250;
88+
assert(expr->evaluate(fixture));
89+
90+
fixture.some_uint = 435;
91+
assert(expr->evaluate(fixture));
92+
93+
fixture.some_uint = 500;
94+
assert(expr->evaluate(fixture));
95+
96+
fixture.some_uint = 501;
97+
assert(expr->evaluate(fixture));
98+
99+
fixture.some_uint = 9999;
100+
assert(expr->evaluate(fixture));
101+
102+
fixture.some_uint = std::numeric_limits<uint16_t>::max();
103+
assert(expr->evaluate(fixture));
104+
105+
fixture.some_uint = 499;
106+
assert(expr->evaluate(fixture));
107+
108+
fixture.some_string = "hello!";
109+
assert(expr->evaluate(fixture));
110+
111+
fixture.some_string = "hello world!";
112+
assert(expr->evaluate(fixture));
113+
114+
fixture.some_string = "hello,world!";
115+
assert(expr->evaluate(fixture));
116+
117+
fixture.some_string = "some test string";
118+
fixture.some_uint = 501;
119+
assert(!expr->evaluate(fixture));
120+
121+
fixture.some_string = "hello!";
122+
fixture.some_uint = 5876;
123+
assert(!expr->evaluate(fixture));
124+
125+
fixture.some_string = "hello hello HELLO";
126+
fixture.some_uint = 12345;
127+
assert(!expr->evaluate(fixture));
128+
129+
fixture.some_string = "";
130+
fixture.some_uint = -1;
131+
assert(!expr->evaluate(fixture));
132+
133+
fixture.some_string = "";
134+
fixture.some_uint = 0;
135+
assert(expr->evaluate(fixture));
136+
137+
fixture.some_string = "hello, world!";
138+
fixture.some_uint = 350;
139+
assert(expr->evaluate(fixture));
140+
}
141+

0 commit comments

Comments
 (0)