From 5f5858d503640286c9e5d23634f9f3a8de6a2091 Mon Sep 17 00:00:00 2001 From: Benjamin Paassen Date: Mon, 19 Jan 2015 20:21:22 +0100 Subject: (re-)introduced setter methods to Document. --- test/core/model/DocumentTest.cpp | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) (limited to 'test') diff --git a/test/core/model/DocumentTest.cpp b/test/core/model/DocumentTest.cpp index fea5296..874fba7 100644 --- a/test/core/model/DocumentTest.cpp +++ b/test/core/model/DocumentTest.cpp @@ -229,10 +229,18 @@ TEST(Document, validate) doc->addDomain(domain); Rooted root = buildRootStructuredEntity(doc, logger, {"root"}); - buildStructuredEntity(doc, logger, root, {"childSub"}); + Rooted child = + buildStructuredEntity(doc, logger, root, {"childSub"}); ASSERT_FALSE(doc->validate(logger)); + // if we add a DocumentPrimitive with the wrong content it should not + // work either. + Rooted primitive{ + new DocumentPrimitive(mgr, child, {"ololol"}, "int")}; + //TODO: ASSERT_FALSE(doc->validate(logger)); + // but if we set the content right, it should work. + primitive->setContent({2}); + ASSERT_TRUE(doc->validate(logger)); } - // TODO: Check wrongly typed primitive content. // Now add an Annotation class to the domain. Rooted annoClass{new AnnotationClass(mgr, "anno", domain)}; @@ -242,23 +250,6 @@ TEST(Document, validate) */ Rooted doc{new Document(mgr, "myDoc.oxd")}; doc->addDomain(domain); - Rooted root = - buildRootStructuredEntity(doc, logger, {"root"}); - Rooted child = - buildStructuredEntity(doc, logger, root, {"childSub"}); - Rooted primitive{ - new DocumentPrimitive(mgr, child, {2}, "int")}; - ASSERT_TRUE(doc->validate(logger)); - // then add an AnnotationEntity without Anchors. - buildAnnotationEntity(doc, logger, {"anno"}, nullptr, nullptr); - ASSERT_FALSE(doc->validate(logger)); - } - { - /* - * Do the same again, but with a valid AnnotationEntity now. - */ - Rooted doc{new Document(mgr, "myDoc.oxd")}; - doc->addDomain(domain); Rooted root = buildRootStructuredEntity(doc, logger, {"root"}); Rooted start{new Anchor(mgr, "start", root)}; @@ -269,7 +260,12 @@ TEST(Document, validate) Rooted end{new Anchor(mgr, "end", root)}; ASSERT_TRUE(doc->validate(logger)); // then add an AnnotationEntity without Anchors. - buildAnnotationEntity(doc, logger, {"anno"}, start, end); + Rooted anno = + buildAnnotationEntity(doc, logger, {"anno"}, nullptr, nullptr); + ASSERT_FALSE(doc->validate(logger)); + // but it should be valid again if we set the start end and Anchor. + anno->setStart(start); + anno->setEnd(end); ASSERT_TRUE(doc->validate(logger)); } } -- cgit v1.2.3