diff options
Diffstat (limited to 'test/plugins/xml/XmlParserTest.cpp')
-rw-r--r-- | test/plugins/xml/XmlParserTest.cpp | 47 |
1 files changed, 42 insertions, 5 deletions
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 <gtest/gtest.h> -#include <core/parser/XmlParser.hpp> +#include <plugins/xml/XmlParser.hpp> 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("<test foo=\"bar\">data<![CDATA[bla]]>\n</btest>", ctx); + } + catch (ParserException ex) { + ASSERT_EQ(2, ex.line); + ASSERT_FALSE(ex.fatal); + hadException = true; + } + ASSERT_TRUE(hadException); +} + +const char* TEST_DATA = "<?xml version=\"1.0\" standalone=\"yes\"?>\n" + "<document a:bc=\"b\">\n" + " <bla:test xmlAttr=\"blub\" />\n" + "</document>\n"; + +TEST(XmlParser, namespaces) { - TerminalLogger log(std::cerr, true); + TestParserContext ctx; XmlParser p; - log.pushFilename("test.xml"); - p.parse("<test></btest>", nullptr, log); + p.parse(TEST_DATA, ctx); } } +} +} |