diff options
author | crupest <crupest@outlook.com> | 2022-01-08 19:24:44 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2022-01-08 19:24:44 +0800 |
commit | 0c7153db084060034092c1dc24222cae384722ec (patch) | |
tree | 9de1bc4636732e3cc1e1fb7309fdf2ff60683f69 /test/toml/ParserTest.cpp | |
parent | c38f1f7c273e85c0a6d197cb27424c9ca69e234d (diff) | |
download | cru-0c7153db084060034092c1dc24222cae384722ec.tar.gz cru-0c7153db084060034092c1dc24222cae384722ec.tar.bz2 cru-0c7153db084060034092c1dc24222cae384722ec.zip |
...
Diffstat (limited to 'test/toml/ParserTest.cpp')
-rw-r--r-- | test/toml/ParserTest.cpp | 31 |
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"); +} |