summaryrefslogtreecommitdiff
path: root/test/core/model/DocumentTest.cpp
diff options
context:
space:
mode:
authorAndreas Stöckel <astoecke@techfak.uni-bielefeld.de>2015-02-15 00:27:11 +0100
committerAndreas Stöckel <astoecke@techfak.uni-bielefeld.de>2015-02-15 00:27:11 +0100
commit253492406f04657fe71e6c0c6603496241280478 (patch)
tree5a9c1b785a5559025ff7d26bf9ed880ce98ff0ce /test/core/model/DocumentTest.cpp
parent551b7be64f207845cb05b8ec593f9bf2d7f0c940 (diff)
parentb708dd4cce828c1089a18fefcc22804f7cdad908 (diff)
Merge branch 'master' into astoecke_parser_stack_new
Conflicts: application/CMakeLists.txt application/src/core/parser/stack/DocumentHandler.hpp application/src/core/parser/stack/DomainHandler.hpp application/src/core/parser/stack/ImportIncludeHandler.hpp
Diffstat (limited to 'test/core/model/DocumentTest.cpp')
-rw-r--r--test/core/model/DocumentTest.cpp42
1 files changed, 23 insertions, 19 deletions
diff --git a/test/core/model/DocumentTest.cpp b/test/core/model/DocumentTest.cpp
index 3164b7e..0c6eea6 100644
--- a/test/core/model/DocumentTest.cpp
+++ b/test/core/model/DocumentTest.cpp
@@ -67,11 +67,9 @@ TEST(Document, construct)
ASSERT_EQ("text", text->getDescriptor()->getName());
ASSERT_TRUE(text->getDescriptor()->hasField());
ASSERT_EQ(1U, text->getField().size());
- ASSERT_TRUE(
- text->getField()[0]->isa(typeOf<DocumentPrimitive>()));
- Variant content = text->getField()[0]
- .cast<DocumentPrimitive>()
- ->getContent();
+ ASSERT_TRUE(text->getField()[0]->isa(typeOf<DocumentPrimitive>()));
+ Variant content =
+ text->getField()[0].cast<DocumentPrimitive>()->getContent();
ASSERT_EQ("Some introductory text", content.asString());
}
}
@@ -101,11 +99,10 @@ TEST(Document, construct)
ASSERT_EQ("text", text->getDescriptor()->getName());
ASSERT_TRUE(text->getDescriptor()->hasField());
ASSERT_EQ(1U, text->getField().size());
- ASSERT_TRUE(text->getField()[0]->isa(
- typeOf<DocumentPrimitive>()));
- Variant content = text->getField()[0]
- .cast<DocumentPrimitive>()
- ->getContent();
+ ASSERT_TRUE(
+ text->getField()[0]->isa(typeOf<DocumentPrimitive>()));
+ Variant content =
+ text->getField()[0].cast<DocumentPrimitive>()->getContent();
ASSERT_EQ("Some actual text", content.asString());
}
}
@@ -149,7 +146,8 @@ TEST(Document, validate)
}
// now let's extend the rootClass with a default field.
- Rooted<FieldDescriptor> rootField{new FieldDescriptor(mgr, rootClass)};
+ Rooted<FieldDescriptor> rootField =
+ rootClass->createFieldDescriptor(logger);
// and add a child class for it.
Rooted<StructuredClass> childClass{
new StructuredClass(mgr, "child", domain, single)};
@@ -195,7 +193,8 @@ TEST(Document, validate)
* Make it even more complicated: child gets a field for further child
* instances now.
*/
- Rooted<FieldDescriptor> childField{new FieldDescriptor(mgr, childClass)};
+ Rooted<FieldDescriptor> childField =
+ childClass->createFieldDescriptor(logger);
childField->addChild(childClass);
{
/*
@@ -211,10 +210,13 @@ TEST(Document, validate)
ASSERT_FALSE(doc->validate(logger));
}
/*
- * Override the default field in childSubClass.
+ * Override the default field in childSubClass with an optional field.
*/
- Rooted<FieldDescriptor> childSubField{
- new FieldDescriptor(mgr, childSubClass)};
+ Rooted<FieldDescriptor> childSubField =
+ childSubClass->createFieldDescriptor(
+ logger, FieldDescriptor::FieldType::TREE, "dummy", true);
+ // add a child pro forma to make it valid.
+ childSubField->addChild(childSubClass);
{
/*
* Now a document with one instance of the Child subclass should be
@@ -229,8 +231,10 @@ TEST(Document, validate)
ASSERT_TRUE(doc->validate(logger));
}
// add a primitive field to the subclass with integer content.
- Rooted<FieldDescriptor> primitive_field{new FieldDescriptor(
- mgr, childSubClass, sys->getIntType(), "int", false)};
+ Rooted<FieldDescriptor> primitive_field =
+ childSubClass->createPrimitiveFieldDescriptor(
+ sys->getIntType(), logger, FieldDescriptor::FieldType::SUBTREE,
+ "int", false);
{
/*
* Now a document with one instance of the Child subclass should be
@@ -265,12 +269,12 @@ TEST(Document, validate)
doc->referenceDomain(domain);
Rooted<StructuredEntity> root =
buildRootStructuredEntity(doc, logger, {"root"});
- Rooted<Anchor> start{new Anchor(mgr, "start", root)};
+ Rooted<Anchor> start{new Anchor(mgr, root)};
Rooted<StructuredEntity> child =
buildStructuredEntity(doc, logger, root, {"childSub"});
Rooted<DocumentPrimitive> primitive{
new DocumentPrimitive(mgr, child, {2}, "int")};
- Rooted<Anchor> end{new Anchor(mgr, "end", root)};
+ Rooted<Anchor> end{new Anchor(mgr, root)};
ASSERT_EQ(ValidationState::UNKNOWN, doc->getValidationState());
ASSERT_TRUE(doc->validate(logger));
// then add an AnnotationEntity without Anchors.