aboutsummaryrefslogtreecommitdiff
path: root/test/toml/ParserTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/toml/ParserTest.cpp')
-rw-r--r--test/toml/ParserTest.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/toml/ParserTest.cpp b/test/toml/ParserTest.cpp
new file mode 100644
index 00000000..5bbb5fe7
--- /dev/null
+++ b/test/toml/ParserTest.cpp
@@ -0,0 +1,31 @@
+#include "cru/toml/TomlDocument.hpp"
+#include "cru/toml/TomlParser.hpp"
+
+#include <gtest/gtest.h>
+
+using namespace cru::toml;
+
+TEST(CruTomlParserTest, Simple) {
+ TomlParser parser(
+ uR"(
+a1 = v1
+"a2" = "v2"
+# comment
+
+[s1]
+# comment
+a3 = v3
+"a4" = "v4"
+
+[s2]
+a5 = v5
+"a6" = "v6"
+ )");
+ auto document = parser.Parse();
+ ASSERT_EQ(document.GetSection(u"")->GetValue(u"a1"), u"v1");
+ ASSERT_EQ(document.GetSection(u"")->GetValue(u"a2"), u"v2");
+ ASSERT_EQ(document.GetSection(u"s1")->GetValue(u"a3"), u"v3");
+ ASSERT_EQ(document.GetSection(u"s1")->GetValue(u"a4"), u"v4");
+ ASSERT_EQ(document.GetSection(u"s2")->GetValue(u"a5"), u"v5");
+ ASSERT_EQ(document.GetSection(u"s2")->GetValue(u"a6"), u"v6");
+}