summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/core/model/DomainTest.cpp36
-rw-r--r--test/core/model/TestAdvanced.hpp24
-rw-r--r--test/core/model/TestDocumentBuilder.hpp2
-rw-r--r--test/core/model/TestDomain.hpp17
4 files changed, 33 insertions, 46 deletions
diff --git a/test/core/model/DomainTest.cpp b/test/core/model/DomainTest.cpp
index af00151..772130c 100644
--- a/test/core/model/DomainTest.cpp
+++ b/test/core/model/DomainTest.cpp
@@ -158,55 +158,55 @@ TEST(Descriptor, pathToAdvanced)
// Let's create the classes that we need first
Rooted<StructuredClass> A{new StructuredClass(
mgr, "A", domain, any, {nullptr}, {nullptr}, false, true)};
- domain->addStructuredClass(A);
+
Rooted<StructuredClass> start{new StructuredClass(
mgr, "start", domain, any, {nullptr}, A, false, false)};
- domain->addStructuredClass(start);
+
Rooted<StructuredClass> B{new StructuredClass(
mgr, "B", domain, any, {nullptr}, {nullptr}, true, false)};
- domain->addStructuredClass(B);
+
Rooted<StructuredClass> C{
new StructuredClass(mgr, "C", domain, any, {nullptr}, B, true, false)};
- domain->addStructuredClass(C);
+
Rooted<StructuredClass> D{new StructuredClass(
mgr, "D", domain, any, {nullptr}, {nullptr}, true, false)};
- domain->addStructuredClass(D);
+
Rooted<StructuredClass> E{new StructuredClass(
mgr, "E", domain, any, {nullptr}, {nullptr}, true, false)};
- domain->addStructuredClass(E);
+
Rooted<StructuredClass> target{
new StructuredClass(mgr, "target", domain, any)};
- domain->addStructuredClass(target);
+
// We create two fields for A
Rooted<FieldDescriptor> A_field{new FieldDescriptor(mgr, A)};
- A->addFieldDescriptor(A_field);
+
A_field->addChild(target);
Rooted<FieldDescriptor> A_field2{new FieldDescriptor(
mgr, A, FieldDescriptor::FieldType::SUBTREE, "second")};
- A->addFieldDescriptor(A_field2);
+
A_field2->addChild(B);
// We create no field for B
// One for C
Rooted<FieldDescriptor> C_field{new FieldDescriptor(mgr, C)};
- C->addFieldDescriptor(C_field);
+
C_field->addChild(target);
// one for start
Rooted<FieldDescriptor> start_field{new FieldDescriptor(mgr, start)};
- start->addFieldDescriptor(start_field);
+
start_field->addChild(D);
// One for D
Rooted<FieldDescriptor> D_field{new FieldDescriptor(mgr, D)};
- D->addFieldDescriptor(D_field);
+
D_field->addChild(E);
// One for E
Rooted<FieldDescriptor> E_field{new FieldDescriptor(mgr, E)};
- E->addFieldDescriptor(E_field);
+
E_field->addChild(target);
-
- #ifdef MANAGER_GRAPHVIZ_EXPORT
- // dump the manager state
- mgr.exportGraphviz("nastyDomain.dot");
- #endif
+
+#ifdef MANAGER_GRAPHVIZ_EXPORT
+ // dump the manager state
+ mgr.exportGraphviz("nastyDomain.dot");
+#endif
// and now we should be able to find the shortest path as suggested
std::vector<Rooted<Node>> path = start->pathTo(target);
diff --git a/test/core/model/TestAdvanced.hpp b/test/core/model/TestAdvanced.hpp
index 696fbed..15a4042 100644
--- a/test/core/model/TestAdvanced.hpp
+++ b/test/core/model/TestAdvanced.hpp
@@ -58,11 +58,9 @@ static Rooted<Domain> constructHeadingDomain(Manager &mgr,
// set up heading StructuredClass.
Rooted<StructuredClass> heading{new StructuredClass(
mgr, "heading", domain, card, {nullptr}, {nullptr}, true)};
- // as field we actually want to refer to the field of paragraph.
+ // as field want to copy the field of paragraph.
Rooted<StructuredClass> p = resolveDescriptor(bookDomain, "paragraph");
- heading->addFieldDescriptor(p->getFieldDescriptors()[0]);
- // add the class to the domain.
- domain->addStructuredClass(heading);
+ heading->copyFieldDescriptor(p->getFieldDescriptors()[0]);
// create a new field for headings in each section type.
std::vector<std::string> secclasses{"book", "section", "subsection",
"paragraph"};
@@ -71,7 +69,6 @@ static Rooted<Domain> constructHeadingDomain(Manager &mgr,
Rooted<FieldDescriptor> heading_field{new FieldDescriptor(
mgr, desc, FieldDescriptor::FieldType::SUBTREE, "heading")};
heading_field->addChild(heading);
- desc->addFieldDescriptor(heading_field);
}
return domain;
}
@@ -94,9 +91,9 @@ static Rooted<Domain> constructListDomain(Manager &mgr,
// set up item StructuredClass;
Rooted<StructuredClass> item{new StructuredClass(
mgr, "item", domain, any, {nullptr}, {nullptr}, false)};
- domain->addStructuredClass(item);
- // as field we actually want to refer to the field of paragraph.
- item->addFieldDescriptor(p->getFieldDescriptors()[0]);
+
+ // as field we want to copy the field of paragraph.
+ item->copyFieldDescriptor(p->getFieldDescriptors()[0]);
// set up list StructuredClasses.
std::vector<std::string> listTypes{"ol", "ul"};
for (auto &listType : listTypes) {
@@ -104,8 +101,6 @@ static Rooted<Domain> constructListDomain(Manager &mgr,
mgr, listType, domain, any, {nullptr}, p, false)};
Rooted<FieldDescriptor> list_field{new FieldDescriptor(mgr, list)};
list_field->addChild(item);
- list->addFieldDescriptor(list_field);
- domain->addStructuredClass(list);
}
return domain;
}
@@ -121,11 +116,11 @@ static Rooted<Domain> constructEmphasisDomain(Manager &mgr,
Rooted<Domain> domain{new Domain(mgr, sys, "emphasis")};
// create AnnotationClasses
Rooted<AnnotationClass> em{
- new AnnotationClass(mgr, "emphasized", domain, {nullptr})};
- domain->addAnnotationClass(em);
+ new AnnotationClass(mgr, "emphasized", domain)};
+
Rooted<AnnotationClass> strong{
- new AnnotationClass(mgr, "strong", domain, {nullptr})};
- domain->addAnnotationClass(strong);
+ new AnnotationClass(mgr, "strong", domain)};
+
return domain;
}
@@ -338,4 +333,3 @@ static Rooted<Document> constructAdvancedDocument(Manager &mgr, Logger &logger,
}
#endif /* _TEST_DOCUMENT_HPP_ */
-
diff --git a/test/core/model/TestDocumentBuilder.hpp b/test/core/model/TestDocumentBuilder.hpp
index 081e934..5896802 100644
--- a/test/core/model/TestDocumentBuilder.hpp
+++ b/test/core/model/TestDocumentBuilder.hpp
@@ -295,8 +295,6 @@ Rooted<AnnotationEntity> buildAnnotationEntity(
Rooted<AnnotationEntity> anno{new AnnotationEntity(
document->getManager(), document, descriptor.cast<AnnotationClass>(),
start, end, attributes, name)};
- // append the new entity to the document
- document->addAnnotation(anno);
// and return it.
return anno;
}
diff --git a/test/core/model/TestDomain.hpp b/test/core/model/TestDomain.hpp
index 48db57a..f6b8805 100644
--- a/test/core/model/TestDomain.hpp
+++ b/test/core/model/TestDomain.hpp
@@ -44,40 +44,37 @@ static Rooted<Domain> constructBookDomain(Manager &mgr,
// Set up the "book" node.
Rooted<StructuredClass> book{new StructuredClass(
mgr, "book", domain, single, {nullptr}, {nullptr}, false, true)};
- domain->addStructuredClass(book);
+
// The structure field of it.
Rooted<FieldDescriptor> book_field{new FieldDescriptor(mgr, book)};
- book->addFieldDescriptor(book_field);
// From there on the "section".
Rooted<StructuredClass> section{
new StructuredClass(mgr, "section", domain, any)};
book_field->addChild(section);
- domain->addStructuredClass(section);
+
// And the field of it.
Rooted<FieldDescriptor> section_field{new FieldDescriptor(mgr, section)};
- section->addFieldDescriptor(section_field);
// We also add the "paragraph", which is transparent.
Rooted<StructuredClass> paragraph{new StructuredClass(
mgr, "paragraph", domain, any, {nullptr}, {nullptr}, true)};
section_field->addChild(paragraph);
book_field->addChild(paragraph);
- domain->addStructuredClass(paragraph);
+
// And the field of it.
Rooted<FieldDescriptor> paragraph_field{
new FieldDescriptor(mgr, paragraph)};
- paragraph->addFieldDescriptor(paragraph_field);
// We append "subsection" to section.
Rooted<StructuredClass> subsection{
new StructuredClass(mgr, "subsection", domain, any)};
section_field->addChild(subsection);
- domain->addStructuredClass(subsection);
+
// And the field of it.
Rooted<FieldDescriptor> subsection_field{
new FieldDescriptor(mgr, subsection)};
- subsection->addFieldDescriptor(subsection_field);
+
// and we add the paragraph to subsections fields
subsection_field->addChild(paragraph);
@@ -85,12 +82,11 @@ static Rooted<Domain> constructBookDomain(Manager &mgr,
Rooted<StructuredClass> text{new StructuredClass(
mgr, "text", domain, any, {nullptr}, {nullptr}, true)};
paragraph_field->addChild(text);
- domain->addStructuredClass(text);
+
// ... and has a primitive field.
Rooted<FieldDescriptor> text_field{new FieldDescriptor(
mgr, text, domain->getTypesystems()[0]->getTypes()[0], "content",
false)};
- text->addFieldDescriptor(text_field);
return domain;
}
@@ -98,4 +94,3 @@ static Rooted<Domain> constructBookDomain(Manager &mgr,
}
#endif /* _TEST_DOMAIN_HPP_ */
-