From ebac41111fa33790acce7be45e599f8de37e7f43 Mon Sep 17 00:00:00 2001 From: Benjamin Paassen Date: Thu, 12 Feb 2015 11:33:01 +0100 Subject: Anchors do not have a name anymore and have a unique mapping to their AnnotationEntities. This also makes serialization much easier. --- test/core/model/DocumentTest.cpp | 4 ++-- test/core/model/TestAdvanced.hpp | 6 ++---- test/plugins/html/DemoOutputTest.cpp | 23 +++++++++-------------- 3 files changed, 13 insertions(+), 20 deletions(-) (limited to 'test') diff --git a/test/core/model/DocumentTest.cpp b/test/core/model/DocumentTest.cpp index 5acf13f..0c6eea6 100644 --- a/test/core/model/DocumentTest.cpp +++ b/test/core/model/DocumentTest.cpp @@ -269,12 +269,12 @@ TEST(Document, validate) doc->referenceDomain(domain); Rooted root = buildRootStructuredEntity(doc, logger, {"root"}); - Rooted start{new Anchor(mgr, "start", root)}; + Rooted start{new Anchor(mgr, root)}; Rooted child = buildStructuredEntity(doc, logger, root, {"childSub"}); Rooted primitive{ new DocumentPrimitive(mgr, child, {2}, "int")}; - Rooted end{new Anchor(mgr, "end", root)}; + Rooted end{new Anchor(mgr, root)}; ASSERT_EQ(ValidationState::UNKNOWN, doc->getValidationState()); ASSERT_TRUE(doc->validate(logger)); // then add an AnnotationEntity without Anchors. diff --git a/test/core/model/TestAdvanced.hpp b/test/core/model/TestAdvanced.hpp index 575860b..27f33cc 100644 --- a/test/core/model/TestAdvanced.hpp +++ b/test/core/model/TestAdvanced.hpp @@ -150,19 +150,17 @@ static bool addHeading(Logger &logger, Handle doc, return true; } -static int annoIdx = 1; - // Only works for non-overlapping annotations! static bool addAnnotation(Logger &logger, Handle doc, Handle parent, const std::string &text, const std::string &annoClass) { Manager &mgr = parent->getManager(); - Rooted start{new Anchor(mgr, std::to_string(annoIdx++), parent)}; + Rooted start{new Anchor(mgr, parent)}; if (!addText(logger, doc, parent, text)) { return false; } - Rooted end{new Anchor(mgr, std::to_string(annoIdx++), parent)}; + Rooted end{new Anchor(mgr, parent)}; Rooted anno = buildAnnotationEntity(doc, logger, {annoClass}, start, end); if (anno.isNull()) { diff --git a/test/plugins/html/DemoOutputTest.cpp b/test/plugins/html/DemoOutputTest.cpp index 5006655..2f56e40 100644 --- a/test/plugins/html/DemoOutputTest.cpp +++ b/test/plugins/html/DemoOutputTest.cpp @@ -41,14 +41,11 @@ TEST(DemoHTMLTransformer, writeHTML) Manager mgr{1}; Rooted sys{new SystemTypesystem(mgr)}; // Get the domains. - Rooted bookDom = - constructBookDomain(mgr, sys, logger); + 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); + 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); @@ -79,10 +76,8 @@ TEST(DemoHTMLTransformer, AnnotationProcessing) Manager mgr{1}; Rooted sys{new SystemTypesystem(mgr)}; // Get the domains. - Rooted bookDom = - constructBookDomain(mgr, sys, logger); - Rooted emDom = - constructEmphasisDomain(mgr, sys, logger); + 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")}; @@ -93,13 +88,13 @@ TEST(DemoHTMLTransformer, AnnotationProcessing) Rooted p = buildStructuredEntity(doc, logger, book, {"paragraph"}); ASSERT_TRUE(p != nullptr); - Rooted em_start{new Anchor(mgr, "1", p)}; + Rooted em_start{new Anchor(mgr, p)}; ASSERT_TRUE(addText(logger, doc, p, "bla")); - Rooted strong_start{new Anchor(mgr, "2", p)}; + Rooted strong_start{new Anchor(mgr, p)}; ASSERT_TRUE(addText(logger, doc, p, "blub")); - Rooted em_end{new Anchor(mgr, "3", p)}; + Rooted em_end{new Anchor(mgr, p)}; ASSERT_TRUE(addText(logger, doc, p, "bla")); - Rooted strong_end{new Anchor(mgr, "4", p)}; + Rooted strong_end{new Anchor(mgr, p)}; buildAnnotationEntity(doc, logger, {"emphasized"}, em_start, em_end); buildAnnotationEntity(doc, logger, {"strong"}, strong_start, strong_end); -- cgit v1.2.3