vxorg/tree_test.cpp
Lily Tsuru af49206a16 Rewrite it in C++
rust people are going to be very mad at me now /j
2024-10-21 12:22:35 -04:00

35 lines
725 B
C++

#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");
if(data.empty()) {
std::printf("(root)\n");
} else {
std::printf("%s\n", data.c_str());
}
});
}
int main() {
test_tree();
return 0;
}