aboutsummaryrefslogtreecommitdiff
path: root/test/toml/ParserTest.cpp
blob: 5e9b84b988df7bd196ab50c567ec12abe230a3c9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "cru/toml/TomlDocument.h"
#include "cru/toml/TomlParser.h"

#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");
}