diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2018-07-25 19:54:32 +0200 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2018-08-12 11:13:54 +0200 |
commit | d88329fe7b27ccf6a1cdae97d020a12f51d253ad (patch) | |
tree | 5acce236a9a0ab1c55914de8cb57437bbbbb3aba /test/configparsertest.cc | |
parent | 753cb561f3f72662430c89414f971c8137beb43c (diff) |
Rewrite ConfigParser to use pugixml.
Diffstat (limited to 'test/configparsertest.cc')
-rw-r--r-- | test/configparsertest.cc | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/test/configparsertest.cc b/test/configparsertest.cc index de2f37e..0b00d0c 100644 --- a/test/configparsertest.cc +++ b/test/configparsertest.cc @@ -35,6 +35,7 @@ public: ConfigParserTest() { DGUNIT_TEST(ConfigParserTest::test); + DGUNIT_TEST(ConfigParserTest::invalid); } void test() @@ -44,20 +45,36 @@ public: "<config>\n" \ " <value name=\"foo\">42</value>\n" \ " <value name=\"bar\">true</value>\n" \ - " <value name=\"bas\">\"</value>\n" \ + " <value name=\"bas\">"<</value>\n" \ "</config>"; ConfigParser parser; - DGUNIT_ASSERT(!parser.parseString(xml)); + DGUNIT_ASSERT(parser.parseString(xml)); DGUNIT_ASSERT_EQUAL(std::string("42"), parser.value("foo", "-")); DGUNIT_ASSERT_EQUAL(std::string("true"), parser.value("bar", "-")); - DGUNIT_ASSERT_EQUAL(std::string("\""), parser.value("bas", "-")); + DGUNIT_ASSERT_EQUAL(std::string("\"<"), parser.value("bas", "-")); // Non-existing value DGUNIT_ASSERT_EQUAL(std::string("-"), parser.value("bas2", "-")); } + + void invalid() + { + std::string xml = + "<?xml version='1.0' encoding='UTF-8'?>\n" \ + "<config\n" \ + " <value name=\"foo\">42</value>\n" \ + " <value name=\"bar\">true</value>\n" \ + " <value name=\"bas\">"<</value>\n" \ + "</config>"; + + + ConfigParser parser; + // Epxect parser error (missing '>' in line 2) + DGUNIT_ASSERT(!parser.parseString(xml)); + } }; // Registers the fixture into the 'registry' |