From b87c0c1aba1f2c4fe4c805119a48991dac128ee8 Mon Sep 17 00:00:00 2001 From: Benjamin Paassen Date: Tue, 17 Feb 2015 18:05:53 +0100 Subject: sorted test list alphabetical and added XML output test. --- test/plugins/xml/XmlOutputTest.cpp | 111 +++++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 test/plugins/xml/XmlOutputTest.cpp (limited to 'test/plugins/xml/XmlOutputTest.cpp') diff --git a/test/plugins/xml/XmlOutputTest.cpp b/test/plugins/xml/XmlOutputTest.cpp new file mode 100644 index 0000000..403078d --- /dev/null +++ b/test/plugins/xml/XmlOutputTest.cpp @@ -0,0 +1,111 @@ +/* + Ousía + Copyright (C) 2014, 2015 Benjamin Paaßen, Andreas Stöckel + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include + +#include +#include + +#include + +#include +#include +#include +#include + +#include +#include + +namespace ousia { +namespace xml { + +TEST(DemoHTMLTransformer, writeHTML) +{ + // Construct Manager + TerminalLogger logger{std::cerr, true}; + Manager mgr{1}; + Rooted sys{new SystemTypesystem(mgr)}; + // Get the domains. + Rooted bookDom = constructBookDomain(mgr, sys, logger); + Rooted headingDom = + constructHeadingDomain(mgr, sys, bookDom, logger); + Rooted listDom = constructListDomain(mgr, sys, bookDom, logger); + Rooted emDom = constructEmphasisDomain(mgr, sys, logger); + // Construct the document. + Rooted doc = constructAdvancedDocument( + mgr, logger, bookDom, headingDom, listDom, emDom); + ASSERT_TRUE(doc != nullptr); + + // we can only do a rough check here. + ResourceManager dummy; + XmlTransformer transformer; + std::stringstream out; + transformer.writeXml(doc, out, logger, dummy, true); + const std::string res = out.str(); + ASSERT_FALSE(res == ""); + ASSERT_TRUE(res.find("Was ist Aufklärung?") != std::string::npos); + ASSERT_TRUE(res.find( + "Aufklärung ist der Ausgang des Menschen aus seiner " + "selbstverschuldeten Unmündigkeit!") != std::string::npos); + ASSERT_TRUE(res.find("Sapere aude!") != std::string::npos); +} + +TEST(DemoHTMLTransformer, AnnotationProcessing) +{ + // Construct Manager + TerminalLogger logger{std::cerr, true}; + Manager mgr{1}; + Rooted sys{new SystemTypesystem(mgr)}; + // Get the domains. + Rooted bookDom = constructBookDomain(mgr, sys, logger); + Rooted emDom = constructEmphasisDomain(mgr, sys, logger); + // Construct a document only containing overlapping annotations. + // it has the form: blablubbla + Rooted doc{new Document(mgr, "annotations.oxd")}; + doc->referenceDomains({bookDom, emDom}); + Rooted book = + buildRootStructuredEntity(doc, logger, {"book"}); + ASSERT_TRUE(book != nullptr); + Rooted p = + buildStructuredEntity(doc, logger, book, {"paragraph"}); + ASSERT_TRUE(p != nullptr); + Rooted em_start{new Anchor(mgr, p)}; + ASSERT_TRUE(addText(logger, doc, p, "bla")); + Rooted strong_start{new Anchor(mgr, p)}; + ASSERT_TRUE(addText(logger, doc, p, "blub")); + Rooted em_end{new Anchor(mgr, p)}; + ASSERT_TRUE(addText(logger, doc, p, "bla")); + Rooted strong_end{new Anchor(mgr, p)}; + buildAnnotationEntity(doc, logger, {"emphasized"}, em_start, em_end); + buildAnnotationEntity(doc, logger, {"strong"}, strong_start, strong_end); + + // Check serialization. + ResourceManager dummy; + XmlTransformer transformer; + std::stringstream out; + transformer.writeXml(doc, out, logger, dummy, false); + const std::string res = out.str(); + // In HTML the overlapping structure must be serialized as follows: + ASSERT_TRUE( + res.find( + "blablubbla") != std::string::npos); +} +} +} \ No newline at end of file -- cgit v1.2.3