From 58ac684725b4c5c75c94516a2068d8d55e8c348c Mon Sep 17 00:00:00 2001 From: Andreas Stöckel Date: Sun, 30 Nov 2014 23:42:05 +0100 Subject: backup --- test/plugins/xml/XmlParserTest.cpp | 47 ++++++++++++++++++++++++++++++++++---- 1 file changed, 42 insertions(+), 5 deletions(-) (limited to 'test/plugins/xml') diff --git a/test/plugins/xml/XmlParserTest.cpp b/test/plugins/xml/XmlParserTest.cpp index d2c4410..98a5a34 100644 --- a/test/plugins/xml/XmlParserTest.cpp +++ b/test/plugins/xml/XmlParserTest.cpp @@ -20,18 +20,55 @@ #include -#include +#include namespace ousia { +namespace parser { +namespace xml { -TEST(XmlParser, logging) +struct TestParserContext : public ParserContext { + +private: + Logger log; + Registry r; + Scope s; + +public: + TestParserContext() : ParserContext(s, r, log), r(log), s(nullptr) {}; + +}; + +TEST(XmlParser, mismatchedTagException) +{ + TestParserContext ctx; + XmlParser p; + + bool hadException = false; + try { + p.parse("data\n", ctx); + } + catch (ParserException ex) { + ASSERT_EQ(2, ex.line); + ASSERT_FALSE(ex.fatal); + hadException = true; + } + ASSERT_TRUE(hadException); +} + +const char* TEST_DATA = "\n" + "\n" + " \n" + "\n"; + +TEST(XmlParser, namespaces) { - TerminalLogger log(std::cerr, true); + TestParserContext ctx; XmlParser p; - log.pushFilename("test.xml"); - p.parse("", nullptr, log); + p.parse(TEST_DATA, ctx); } } +} +} -- cgit v1.2.3