diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/core/LoggerTest.cpp | 10 | ||||
| -rw-r--r-- | test/plugins/mozjs/MozJsScriptEngineTest.cpp | 2 | ||||
| -rw-r--r-- | test/plugins/xml/XmlParserTest.cpp | 47 | 
3 files changed, 52 insertions, 7 deletions
diff --git a/test/core/LoggerTest.cpp b/test/core/LoggerTest.cpp index 4badc28..7031dc7 100644 --- a/test/core/LoggerTest.cpp +++ b/test/core/LoggerTest.cpp @@ -26,17 +26,23 @@ namespace ousia {  TEST(TerminalLogger, log)  { +	// Test for manual visual expection only -- no assertions  	TerminalLogger logger{std::cerr, true}; -	logger.pushFilename("/homes/mmuster/ousia/test.odp"); +	logger.pushFilename("test.odp");  	logger.debug("This is a test debug message", 10, 20); +	logger.debug("This is a test debug message with no column", 10); +	logger.debug("This is a test debug message with no line"); +	logger.debug("This is a test debug message with no file", ""); +	logger.debug("This is a test debug message with no file but a line", "", 10); +	logger.debug("This is a test debug message with no file but a line and a column", "", 10, 20);  	logger.note("This is a test note", 10, 20);  	logger.warning("This is a test warning", 10, 20);  	logger.error("This is a test error", 10, 20);  	logger.fatalError("This is a test fatal error!", 10, 20);  	try { -		throw LoggableException{"A fatal exception", true}; +		throw LoggableException{"A fatal exception"};  	} catch (const LoggableException &ex) {  		logger.log(ex);  	} 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);  }  } +} +}  | 
