diff options
author | Andreas Stöckel <astoecke@techfak.uni-bielefeld.de> | 2014-12-28 12:16:23 +0100 |
---|---|---|
committer | Andreas Stöckel <andreas@somweyr.de> | 2014-12-28 12:16:23 +0100 |
commit | 171d6b233690f7b0ed01450e1d993b246fe42ed3 (patch) | |
tree | 25b6e56df4c51f04cac4d08314e5c6c2c7c047be /test/core | |
parent | 3f22fdbf6aa5d4543c122a91cf244046697a1ec9 (diff) |
fixed insertion of attribute default values in the StructType.insert function
Diffstat (limited to 'test/core')
-rw-r--r-- | test/core/model/TypesystemTest.cpp | 29 |
1 files changed, 25 insertions, 4 deletions
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<StructType> createStructType(Manager &mgr, Logger &logger) Rooted<StructType> structType{StructType::createValidated( mgr, "struct", nullptr, nullptr, NodeVector<Attribute>{ - 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<Node>())); } +TEST(StructType, creation) +{ + Logger logger; + Manager mgr; + Rooted<StructType> 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) |