u01/tests: Simplify create complete tree
This commit is contained in:
parent
89d1f5f6e0
commit
6a7c1c4546
|
@ -66,43 +66,40 @@ TEST_CASE("Create complete tree") {
|
|||
const unsigned int tree_depth = 4;
|
||||
node *t = create_complete_tree(nr_child_nodes, tree_depth);
|
||||
|
||||
const int node_id_start = get_node_id(t);
|
||||
int count = 0;
|
||||
int count = get_node_id(t);
|
||||
|
||||
REQUIRE(t->get_name() == "node_" + std::to_string(node_id_start + count++));
|
||||
REQUIRE(t->get_name() == "node_" + std::to_string(count++));
|
||||
|
||||
// this is very verbose,
|
||||
// but without a serialisation,
|
||||
// there is no other good way I could find (that does not also implement the
|
||||
// logic to test).
|
||||
REQUIRE(t->get_child(0)->get_name() ==
|
||||
"node_" + std::to_string(node_id_start + count++));
|
||||
REQUIRE(t->get_child(0)->get_name() == "node_" + std::to_string(count++));
|
||||
REQUIRE(t->get_child(0)->get_child(0)->get_name() ==
|
||||
"node_" + std::to_string(node_id_start + count++));
|
||||
"node_" + std::to_string(count++));
|
||||
REQUIRE(t->get_child(0)->get_child(0)->get_child(0)->get_name() ==
|
||||
"node_" + std::to_string(node_id_start + count++));
|
||||
"node_" + std::to_string(count++));
|
||||
REQUIRE(t->get_child(0)->get_child(0)->get_child(1)->get_name() ==
|
||||
"node_" + std::to_string(node_id_start + count++));
|
||||
"node_" + std::to_string(count++));
|
||||
REQUIRE(t->get_child(0)->get_child(1)->get_name() ==
|
||||
"node_" + std::to_string(node_id_start + count++));
|
||||
"node_" + std::to_string(count++));
|
||||
REQUIRE(t->get_child(0)->get_child(1)->get_child(0)->get_name() ==
|
||||
"node_" + std::to_string(node_id_start + count++));
|
||||
"node_" + std::to_string(count++));
|
||||
REQUIRE(t->get_child(0)->get_child(1)->get_child(1)->get_name() ==
|
||||
"node_" + std::to_string(node_id_start + count++));
|
||||
REQUIRE(t->get_child(1)->get_name() ==
|
||||
"node_" + std::to_string(node_id_start + count++));
|
||||
"node_" + std::to_string(count++));
|
||||
REQUIRE(t->get_child(1)->get_name() == "node_" + std::to_string(count++));
|
||||
REQUIRE(t->get_child(1)->get_child(0)->get_name() ==
|
||||
"node_" + std::to_string(node_id_start + count++));
|
||||
"node_" + std::to_string(count++));
|
||||
REQUIRE(t->get_child(1)->get_child(0)->get_child(0)->get_name() ==
|
||||
"node_" + std::to_string(node_id_start + count++));
|
||||
"node_" + std::to_string(count++));
|
||||
REQUIRE(t->get_child(1)->get_child(0)->get_child(1)->get_name() ==
|
||||
"node_" + std::to_string(node_id_start + count++));
|
||||
"node_" + std::to_string(count++));
|
||||
REQUIRE(t->get_child(1)->get_child(1)->get_name() ==
|
||||
"node_" + std::to_string(node_id_start + count++));
|
||||
"node_" + std::to_string(count++));
|
||||
REQUIRE(t->get_child(1)->get_child(1)->get_child(0)->get_name() ==
|
||||
"node_" + std::to_string(node_id_start + count++));
|
||||
"node_" + std::to_string(count++));
|
||||
REQUIRE(t->get_child(1)->get_child(1)->get_child(1)->get_name() ==
|
||||
"node_" + std::to_string(node_id_start + count++));
|
||||
"node_" + std::to_string(count++));
|
||||
|
||||
REQUIRE(t->get_nr_children() == nr_child_nodes);
|
||||
REQUIRE(t->get_child(0)->get_nr_children() == nr_child_nodes);
|
||||
|
|
Reference in a new issue