summaryrefslogtreecommitdiff
path: root/test/plugins/xml
diff options
context:
space:
mode:
authorAndreas Stöckel <astoecke@techfak.uni-bielefeld.de>2014-11-30 23:42:05 +0100
committerAndreas Stöckel <astoecke@techfak.uni-bielefeld.de>2014-11-30 23:42:05 +0100
commit58ac684725b4c5c75c94516a2068d8d55e8c348c (patch)
treef455832ac77707947d655f4c4389b45b3b363f38 /test/plugins/xml
parent235b98e0d1a2e9e60c440076b5a11c8bf64ba071 (diff)
backup
Diffstat (limited to 'test/plugins/xml')
-rw-r--r--test/plugins/xml/XmlParserTest.cpp47
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);
}
}
+}
+}