aboutsummaryrefslogtreecommitdiff
path: root/test/common
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2022-01-08 21:17:56 +0800
committercrupest <crupest@outlook.com>2022-01-08 21:17:56 +0800
commit6b90be37d3ba7e094837bd01a19381bd59657041 (patch)
tree31bc841e7bc958e7ef31a3860321e8570bbef821 /test/common
parent45ae34c5f31eca1258f6df278c9862ff829f39db (diff)
downloadcru-6b90be37d3ba7e094837bd01a19381bd59657041.tar.gz
cru-6b90be37d3ba7e094837bd01a19381bd59657041.tar.bz2
cru-6b90be37d3ba7e094837bd01a19381bd59657041.zip
...
Diffstat (limited to 'test/common')
-rw-r--r--test/common/CMakeLists.txt1
-rw-r--r--test/common/PropertyTreeTest.cpp26
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");
+}