36 lines
831 B
C++
36 lines
831 B
C++
#include <catch2/catch_test_macros.hpp>
|
|
#include <iostream>
|
|
|
|
#include "node.h"
|
|
|
|
TEST_CASE("Name") {
|
|
node *n = new node("test");
|
|
REQUIRE(n->get_name() == "test");
|
|
n->set_name("foo");
|
|
REQUIRE(n->get_name() == "foo");
|
|
delete n;
|
|
}
|
|
|
|
TEST_CASE("Number of children") {
|
|
node *n = new node("test");
|
|
REQUIRE(n->get_nr_children() == 0);
|
|
for (std::size_t i = 0; i < 20; i++) {
|
|
node *child = new node("child");
|
|
n->add_child(child);
|
|
}
|
|
REQUIRE(n->get_nr_children() == 20);
|
|
delete n;
|
|
}
|
|
|
|
TEST_CASE("Get children") {
|
|
node *n = new node("test");
|
|
REQUIRE(n->get_nr_children() == 0);
|
|
for (std::size_t i = 0; i < 5; i++) {
|
|
n->add_child(new node("child " + std::to_string(i)));
|
|
}
|
|
for (std::size_t i = 0; i < 5; i++) {
|
|
REQUIRE(n->get_child(i)->get_name() == "child " + std::to_string(i));
|
|
}
|
|
delete n;
|
|
}
|