diff options
Diffstat (limited to 'test/common')
-rw-r--r-- | test/common/CMakeLists.txt | 1 | ||||
-rw-r--r-- | test/common/PropertyTreeTest.cpp | 26 |
2 files changed, 27 insertions, 0 deletions
diff --git a/test/common/CMakeLists.txt b/test/common/CMakeLists.txt index 730607d2..810c68d5 100644 --- a/test/common/CMakeLists.txt +++ b/test/common/CMakeLists.txt @@ -1,5 +1,6 @@ add_executable(cru_base_test HandlerRegistryTest.cpp + PropertyTreeTest.cpp StringTest.cpp StringUtilTest.cpp ) diff --git a/test/common/PropertyTreeTest.cpp b/test/common/PropertyTreeTest.cpp new file mode 100644 index 00000000..03b8971a --- /dev/null +++ b/test/common/PropertyTreeTest.cpp @@ -0,0 +1,26 @@ +#include "cru/common/PropertyTree.hpp" + +#include <gtest/gtest.h> + +TEST(PropertyTree, Test) { + using cru::PropertySubTreeRef; + using cru::PropertyTree; + + PropertyTree tree({ + {u"k1", u"v1"}, + {u"k2", u"v2"}, + {u"k3.sub", u"v3"}, + }); + + ASSERT_EQ(tree.GetValue(u"k1"), u"v1"); + ASSERT_EQ(tree.GetValue(u"k2"), u"v2"); + ASSERT_EQ(tree.GetValue(u"k3.sub"), u"v3"); + + PropertySubTreeRef sub_tree = tree.GetSubTreeRef(u"k3"); + ASSERT_EQ(sub_tree.GetValue(u"sub"), u"v3"); + + PropertySubTreeRef root_tree = sub_tree.GetParent(); + ASSERT_EQ(root_tree.GetValue(u"k1"), u"v1"); + ASSERT_EQ(root_tree.GetValue(u"k2"), u"v2"); + ASSERT_EQ(root_tree.GetValue(u"k3.sub"), u"v3"); +} |