From fce5cce5fdc7bd265eb023dfc0fc1accbe5a796e Mon Sep 17 00:00:00 2001 From: Benjamin Paassen Date: Wed, 4 Feb 2015 20:20:02 +0100 Subject: set non-empty default field name. --- test/core/model/DocumentTest.cpp | 25 ++++++++++++++----------- test/core/model/DomainTest.cpp | 2 +- test/core/model/TestDocumentBuilder.hpp | 19 ++++++++++--------- 3 files changed, 25 insertions(+), 21 deletions(-) (limited to 'test') 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(); 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())); - Variant content = - text->getField()[0].cast()->getContent(); + ASSERT_TRUE(text->hasField("content")); + ASSERT_EQ(1U, text->getField("content").size()); + ASSERT_TRUE( + text->getField("content")[0]->isa(typeOf())); + Variant content = text->getField("content")[0] + .cast() + ->getContent(); ASSERT_EQ("Some introductory text", content.asString()); } } @@ -97,12 +99,13 @@ TEST(Document, construct) par->getField()[0].cast(); 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())); - Variant content = - text->getField()[0].cast()->getContent(); + ASSERT_TRUE(text->hasField("content")); + ASSERT_EQ(1U, text->getField("content").size()); + ASSERT_TRUE(text->getField("content")[0]->isa( + typeOf())); + Variant content = text->getField("content")[0] + .cast() + ->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 buildRootStructuredEntity(Handle document, */ Rooted buildStructuredEntity( Handle document, Logger &logger, Handle 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 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 buildStructuredEntity( * input handle was empty or the given domains did not * contain a AnnotationClass with the given name. */ -Rooted buildAnnotationEntity( - Handle document, Logger &logger, const Path &path, - Handle start, - Handle end, Variant attributes = {}, - std::string name = "") +Rooted buildAnnotationEntity(Handle document, + Logger &logger, const Path &path, + Handle start, + Handle 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 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!"); } -- cgit v1.2.3