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 | |
parent | 753cb561f3f72662430c89414f971c8137beb43c (diff) |
Rewrite ConfigParser to use pugixml.
Diffstat (limited to 'test')
-rw-r--r-- | test/Makefile.am | 5 | ||||
-rw-r--r-- | test/configparsertest.cc | 23 |
2 files changed, 22 insertions, 6 deletions
diff --git a/test/Makefile.am b/test/Makefile.am index c26b017..2a34275 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -219,12 +219,11 @@ domloadertest_SOURCES = \ configparsertest_CXXFLAGS = -DOUTPUT=\"configparsertest\" \ -I$(top_srcdir)/src -I$(top_srcdir)/include -I$(top_srcdir)/hugin \ - -I$(top_srcdir)/pugixml/src $(EXPAT_CFLAGS) -configparsertest_LDFLAGS = $(EXPAT_LIBS) + -I$(top_srcdir)/pugixml/src +configparsertest_LDFLAGS = configparsertest_SOURCES = \ $(top_srcdir)/hugin/hugin.c \ $(top_srcdir)/src/configparser.cc \ - $(top_srcdir)/src/saxparser.cc \ $(top_srcdir)/pugixml/src/pugixml.cpp \ configparsertest.cc \ dgtest.cc 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' |