u01: Add test case for very short loop

This actually worked, but it is nice to have it verified nonetheless.
filtered
Simon Bruder 2023-04-24 14:33:45 +02:00
parent 8a07422a51
commit 63431b6824
1 changed files with 24 additions and 0 deletions

View File

@ -178,6 +178,30 @@ TEST_CASE("Cycle detection (iterative)") {
delete n;
}
TEST_CASE("Very short cycle detection") {
node *n = new node("foo");
n->add_child(n);
std::stringstream output;
output << n->print_recursive();
REQUIRE(output.str() == "foo [↝ foo]\n");
delete n;
}
TEST_CASE("Very short cycle detection (iterative)") {
node *n = new node("foo");
n->add_child(n);
std::stringstream output;
output << n->print_iterative();
REQUIRE(output.str() == "foo [↝ foo]\n");
delete n;
}
TEST_CASE("Equivalence of iterative and recursive print") {
node *n = new node();
REQUIRE(n->print_recursive() == n->print_iterative());