diff options
author | Andreas Stöckel <astoecke@techfak.uni-bielefeld.de> | 2014-11-30 23:42:05 +0100 |
---|---|---|
committer | Andreas Stöckel <astoecke@techfak.uni-bielefeld.de> | 2014-11-30 23:42:05 +0100 |
commit | 58ac684725b4c5c75c94516a2068d8d55e8c348c (patch) | |
tree | f455832ac77707947d655f4c4389b45b3b363f38 /test/plugins | |
parent | 235b98e0d1a2e9e60c440076b5a11c8bf64ba071 (diff) |
backup
Diffstat (limited to 'test/plugins')
-rw-r--r-- | test/plugins/mozjs/MozJsScriptEngineTest.cpp | 2 | ||||
-rw-r--r-- | test/plugins/xml/XmlParserTest.cpp | 47 |
2 files changed, 44 insertions, 5 deletions
diff --git a/test/plugins/mozjs/MozJsScriptEngineTest.cpp b/test/plugins/mozjs/MozJsScriptEngineTest.cpp index 96e6cf6..da88acb 100644 --- a/test/plugins/mozjs/MozJsScriptEngineTest.cpp +++ b/test/plugins/mozjs/MozJsScriptEngineTest.cpp @@ -25,6 +25,7 @@ namespace ousia { namespace script { +namespace mozjs { /* Global engine object */ MozJsScriptEngine engine; @@ -37,4 +38,5 @@ auto scope = std::unique_ptr<MozJsScriptEngineScope>{engine.createScope()}; } } +} 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); } } +} +} |