From 171d6b233690f7b0ed01450e1d993b246fe42ed3 Mon Sep 17 00:00:00 2001 From: Andreas Stöckel Date: Sun, 28 Dec 2014 12:16:23 +0100 Subject: fixed insertion of attribute default values in the StructType.insert function --- test/core/model/TypesystemTest.cpp | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'test/core') diff --git a/test/core/model/TypesystemTest.cpp b/test/core/model/TypesystemTest.cpp index 5757213..4a37707 100644 --- a/test/core/model/TypesystemTest.cpp +++ b/test/core/model/TypesystemTest.cpp @@ -389,10 +389,10 @@ static Rooted createStructType(Manager &mgr, Logger &logger) Rooted structType{StructType::createValidated( mgr, "struct", nullptr, nullptr, NodeVector{ - new Attribute{mgr, "attr1", stringType, "attr1default"}, - new Attribute{mgr, "attr2", stringType}, - new Attribute{mgr, "attr3", intType, 3}, - new Attribute{mgr, "attr4", intType}}, + new Attribute{mgr, "d", stringType, "attr1default"}, + new Attribute{mgr, "b", stringType}, + new Attribute{mgr, "c", intType, 3}, + new Attribute{mgr, "a", intType}}, logger)}; return structType; } @@ -407,6 +407,27 @@ TEST(StructType, rtti) ASSERT_TRUE(structType->isa(typeOf())); } +TEST(StructType, creation) +{ + Logger logger; + Manager mgr; + Rooted structType = createStructType(mgr, logger); + Variant val = structType->create(); + ASSERT_TRUE(val.isArray()); + ASSERT_EQ(4U, val.asArray().size()); + + const auto &arr = val.asArray(); + ASSERT_TRUE(arr[0].isString()); + ASSERT_TRUE(arr[1].isString()); + ASSERT_TRUE(arr[2].isInt()); + ASSERT_TRUE(arr[3].isInt()); + + ASSERT_EQ("attr1default", arr[0].asString()); + ASSERT_EQ("", arr[1].asString()); + ASSERT_EQ(3, arr[2].asInt()); + ASSERT_EQ(0, arr[3].asInt()); +} + /* Class ArrayType */ TEST(ArrayType, rtti) -- cgit v1.2.3