From c5607d106449cc3c8680e95ec8595370996d5fb1 Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Sun, 5 Nov 2023 19:24:20 +0100 Subject: core,tests: Fixed include file and implemented tree container --- tests/tree.cpp | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 tests/tree.cpp (limited to 'tests/tree.cpp') diff --git a/tests/tree.cpp b/tests/tree.cpp new file mode 100644 index 0000000..de6bda6 --- /dev/null +++ b/tests/tree.cpp @@ -0,0 +1,38 @@ +#include +#include + +namespace { +SAW_TEST("Tree insert"){ + using namespace saw; + + tree_or troi; + { + // Replace with value + auto eor = troi.replace_tree(5); + + SAW_EXPECT(eor.is_value(), "Didn't manage to replace with value"); + } + { + // Replace with tree again + auto eor = troi.replace_value(tree{}); + + SAW_EXPECT(eor.is_value(), "Not a value"); + } +} + +SAW_TEST("Tree add child"){ + using namespace saw; + + tree tr; + { + auto eov = tr.add(10); + SAW_EXPECT(eov.is_value(), "Didn't manage to add value"); + } + { + auto eov = tr.add(); + SAW_EXPECT(eov.is_value(), "Didn't manage to add tree"); + std::size_t index = eov.get_value(); + + } +} +} -- cgit v1.2.3