From 6a7c1c4546c1a964097483774796ab50a1858496 Mon Sep 17 00:00:00 2001 From: Simon Bruder Date: Sat, 22 Apr 2023 10:43:32 +0200 Subject: [PATCH] u01/tests: Simplify create complete tree --- u01/tests.cpp | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/u01/tests.cpp b/u01/tests.cpp index c0bbecc..f9cb13e 100644 --- a/u01/tests.cpp +++ b/u01/tests.cpp @@ -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);