summaryrefslogtreecommitdiff
path: root/test/core/model/DocumentTest.cpp
diff options
context:
space:
mode:
authorAndreas Stöckel <astoecke@techfak.uni-bielefeld.de>2015-03-03 19:16:30 +0100
committerAndreas Stöckel <andreas@somweyr.de>2015-03-03 19:16:30 +0100
commitb730f4d9cc092f8ab2d7c71853431042d75d5d08 (patch)
tree9922b245fbd33ca5a60b901003e8e9b606bd5699 /test/core/model/DocumentTest.cpp
parent2a5e714d1d222cc5e27fc442c56c1a880df573d2 (diff)
parent68c66558cd7c8e64dd0d3b934ccb58603f8b9836 (diff)
Merge branch 'master' of ssh://somweyr.de/var/local/git/ousia
Diffstat (limited to 'test/core/model/DocumentTest.cpp')
-rw-r--r--test/core/model/DocumentTest.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/test/core/model/DocumentTest.cpp b/test/core/model/DocumentTest.cpp
index 9362af8..8ae9475 100644
--- a/test/core/model/DocumentTest.cpp
+++ b/test/core/model/DocumentTest.cpp
@@ -75,6 +75,41 @@ TEST(DocumentEntity, searchStartAnchor)
ASSERT_EQ(b, root->searchStartAnchor(0, Alpha, "myAnno"));
}
+
+TEST(DocumentEntity, searchStartAnchorCycles)
+{
+ // create a trivial ontology.
+ Logger logger;
+ Manager mgr{1};
+ Rooted<SystemTypesystem> sys{new SystemTypesystem(mgr)};
+ Rooted<Ontology> ontology{new Ontology(mgr, sys, "trivial")};
+ // we only have one StructuredClass that may have itself as a child.
+ Rooted<StructuredClass> A = ontology->createStructuredClass(
+ "A", Cardinality::any(), nullptr, false, true);
+ Rooted<FieldDescriptor> A_field = A->createFieldDescriptor(logger).first;
+ A_field->addChild(A);
+ // create an AnnotationClass.
+ Rooted<AnnotationClass> Alpha = ontology->createAnnotationClass("Alpha");
+ // validate this ontology.
+ ASSERT_TRUE(ontology->validate(logger));
+
+ // create a trivial but cyclic document.
+ Rooted<Document> doc{new Document(mgr, "myDoc")};
+ Rooted<StructuredEntity> root = doc->createRootStructuredEntity(A);
+ // add an Anchor.
+ Rooted<Anchor> a = root->createChildAnchor();
+ // create an AnnotationEntity with the Anchor as start.
+ doc->createChildAnnotation(Alpha, a, nullptr, Variant::mapType{}, "myAnno");
+ // add the cyclic reference.
+ root->addStructureNode(root, 0);
+ // We should be able to find the Anchor now if we look for it. There should
+ // be no loops.
+ ASSERT_EQ(a, root->searchStartAnchor(0));
+ ASSERT_EQ(a, root->searchStartAnchor(0, Alpha));
+ ASSERT_EQ(a, root->searchStartAnchor(0, nullptr, "myAnno"));
+ ASSERT_EQ(a, root->searchStartAnchor(0, Alpha, "myAnno"));
+}
+
TEST(DocumentEntity, searchStartAnchorUpwards)
{
// create a trivial ontology.