summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorBenjamin Paassen <bpaassen@techfak.uni-bielefeld.de>2015-02-04 20:20:02 +0100
committerBenjamin Paassen <bpaassen@techfak.uni-bielefeld.de>2015-02-04 20:20:02 +0100
commitfce5cce5fdc7bd265eb023dfc0fc1accbe5a796e (patch)
treec745b76fc01ff7fa8c38c5810682c8878ade1fc1 /test
parente76f58e912bd6661ba755d27da97bebf711f06ad (diff)
set non-empty default field name.
Diffstat (limited to 'test')
-rw-r--r--test/core/model/DocumentTest.cpp25
-rw-r--r--test/core/model/DomainTest.cpp2
-rw-r--r--test/core/model/TestDocumentBuilder.hpp19
3 files changed, 25 insertions, 21 deletions
diff --git a/test/core/model/DocumentTest.cpp b/test/core/model/DocumentTest.cpp
index 7190437..5a2bcec 100644
--- a/test/core/model/DocumentTest.cpp
+++ b/test/core/model/DocumentTest.cpp
@@ -65,11 +65,13 @@ TEST(Document, construct)
foreword->getField()[0].cast<StructuredEntity>();
ASSERT_FALSE(text.isNull());
ASSERT_EQ("text", text->getDescriptor()->getName());
- ASSERT_TRUE(text->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->hasField("content"));
+ ASSERT_EQ(1U, text->getField("content").size());
+ ASSERT_TRUE(
+ text->getField("content")[0]->isa(typeOf<DocumentPrimitive>()));
+ Variant content = text->getField("content")[0]
+ .cast<DocumentPrimitive>()
+ ->getContent();
ASSERT_EQ("Some introductory text", content.asString());
}
}
@@ -97,12 +99,13 @@ TEST(Document, construct)
par->getField()[0].cast<StructuredEntity>();
ASSERT_FALSE(text.isNull());
ASSERT_EQ("text", text->getDescriptor()->getName());
- ASSERT_TRUE(text->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->hasField("content"));
+ ASSERT_EQ(1U, text->getField("content").size());
+ ASSERT_TRUE(text->getField("content")[0]->isa(
+ typeOf<DocumentPrimitive>()));
+ Variant content = text->getField("content")[0]
+ .cast<DocumentPrimitive>()
+ ->getContent();
ASSERT_EQ("Some actual text", content.asString());
}
}
diff --git a/test/core/model/DomainTest.cpp b/test/core/model/DomainTest.cpp
index 32cdd24..69c6694 100644
--- a/test/core/model/DomainTest.cpp
+++ b/test/core/model/DomainTest.cpp
@@ -213,7 +213,7 @@ TEST(Descriptor, pathToAdvanced)
ASSERT_TRUE(path[1]->isa(RttiTypes::StructuredClass));
ASSERT_EQ("B", path[1]->getName());
ASSERT_TRUE(path[2]->isa(RttiTypes::FieldDescriptor));
- ASSERT_EQ("", path[2]->getName());
+ ASSERT_EQ("$default", path[2]->getName());
}
TEST(StructuredClass, isSubclassOf)
diff --git a/test/core/model/TestDocumentBuilder.hpp b/test/core/model/TestDocumentBuilder.hpp
index 71b353d..05b27b7 100644
--- a/test/core/model/TestDocumentBuilder.hpp
+++ b/test/core/model/TestDocumentBuilder.hpp
@@ -133,8 +133,8 @@ Rooted<StructuredEntity> buildRootStructuredEntity(Handle<Document> document,
*/
Rooted<StructuredEntity> buildStructuredEntity(
Handle<Document> document, Logger &logger, Handle<StructuredEntity> parent,
- Path path, const std::string &fieldName = "", Variant attributes = {},
- std::string name = "")
+ Path path, const std::string &fieldName = DEFAULT_FIELD_NAME,
+ Variant attributes = {}, std::string name = "")
{
// If the input handles are not set, we can not build the entity.
if (parent == nullptr) {
@@ -152,7 +152,7 @@ Rooted<StructuredEntity> buildStructuredEntity(
if (descriptor == nullptr) {
return {nullptr};
}
- if(!descriptor->isa(RttiTypes::StructuredClass)){
+ if (!descriptor->isa(RttiTypes::StructuredClass)) {
return {nullptr};
logger.error("The descriptor was not an AnnotationClass!");
}
@@ -184,11 +184,12 @@ Rooted<StructuredEntity> buildStructuredEntity(
* input handle was empty or the given domains did not
* contain a AnnotationClass with the given name.
*/
-Rooted<AnnotationEntity> buildAnnotationEntity(
- Handle<Document> document, Logger &logger, const Path &path,
- Handle<Anchor> start,
- Handle<Anchor> end, Variant attributes = {},
- std::string name = "")
+Rooted<AnnotationEntity> buildAnnotationEntity(Handle<Document> document,
+ Logger &logger, const Path &path,
+ Handle<Anchor> start,
+ Handle<Anchor> end,
+ Variant attributes = {},
+ std::string name = "")
{
// If the input handles are not set, we can not build the entity.
if (document == nullptr) {
@@ -202,7 +203,7 @@ Rooted<AnnotationEntity> buildAnnotationEntity(
if (descriptor == nullptr) {
return {nullptr};
}
- if(!descriptor->isa(RttiTypes::AnnotationClass)){
+ if (!descriptor->isa(RttiTypes::AnnotationClass)) {
return {nullptr};
logger.error("The descriptor was not an AnnotationClass!");
}