diff options
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' |