vxorg/tree_test.cpp

35 lines
728 B
C++
Raw Permalink Normal View History

#include "tree.hpp"
#include <string>
void test_tree() {
Tree<std::string> tree;
auto* virus = tree.create_leaf("Virus");
auto* worm = tree.create_leaf("Worm");
auto* test = virus->create_leaf("test");
test->create_leaf("a");
test->create_leaf("b");
test->create_leaf("c");
test->create_leaf("884");
tree.walk([](auto* node) {
auto tab_count = node->parent_count();
auto& data = node->data();
for(auto i = 0; i < tab_count; ++i)
std::printf("\t");
2024-10-21 19:56:43 -04:00
if(node->is_root()) {
std::printf("(root)\n");
} else {
std::printf("%s\n", data.c_str());
}
});
}
int main() {
test_tree();
return 0;
}