From 3883e6df939ad1ecb9a788153e087fefd9f0e838 Mon Sep 17 00:00:00 2001 From: Benjamin Paassen Date: Fri, 6 Feb 2015 16:47:49 +0100 Subject: corrected attributes descriptor handling. --- test/core/model/DocumentTest.cpp | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) (limited to 'test/core/model/DocumentTest.cpp') diff --git a/test/core/model/DocumentTest.cpp b/test/core/model/DocumentTest.cpp index 5a2bcec..177f69b 100644 --- a/test/core/model/DocumentTest.cpp +++ b/test/core/model/DocumentTest.cpp @@ -123,7 +123,7 @@ TEST(Document, validate) single.merge({1}); // Set up the "root" StructuredClass. Rooted rootClass{new StructuredClass( - mgr, "root", domain, single, {nullptr}, {nullptr}, false, true)}; + mgr, "root", domain, single, {nullptr}, false, true)}; // set up a document for it. { @@ -177,8 +177,8 @@ TEST(Document, validate) /* * Add a further extension to the domain: We add a subclass to child. */ - Rooted childSubClass{new StructuredClass( - mgr, "childSub", domain, single, {nullptr}, childClass)}; + Rooted childSubClass{ + new StructuredClass(mgr, "childSub", domain, single, childClass)}; { /* * A document with one instance of the Child subclass should be valid. @@ -284,23 +284,19 @@ TEST(Document, validate) ASSERT_EQ(ValidationState::UNKNOWN, doc->getValidationState()); ASSERT_TRUE(doc->validate(logger)); // add an attribute to the root, which should make it invalid. - root->setAttributes({2}); + root->setAttributes(Variant::mapType{{"bla", 2}}); ASSERT_EQ(ValidationState::UNKNOWN, doc->getValidationState()); ASSERT_FALSE(doc->validate(logger)); - // if we reset it to null it should be valid again - root->setAttributes({}); + // if we reset it to an empty map it should be valid again + root->setAttributes(Variant::mapType{}); ASSERT_EQ(ValidationState::UNKNOWN, doc->getValidationState()); ASSERT_TRUE(doc->validate(logger)); // let's set an attribute descriptor. - Rooted structType{StructType::createValidated( - mgr, "attributes", nullptr, nullptr, - NodeVector{ - new Attribute{mgr, "myAttr", sys->getStringType(), "default"}}, - logger)}; - childSubClass->setAttributesDescriptor(structType); + childSubClass->getAttributesDescriptor()->addAttribute( + new Attribute{mgr, "myAttr", sys->getStringType(), "default"}, + logger); // the right map content should be valid now. - child->setAttributes( - std::map{{"myAttr", "content"}}); + child->setAttributes(Variant::mapType{{"myAttr", "content"}}); ASSERT_EQ(ValidationState::UNKNOWN, doc->getValidationState()); ASSERT_TRUE(doc->validate(logger)); // but an empty map as well -- cgit v1.2.3