summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAndreas Stöckel <astoecke@techfak.uni-bielefeld.de>2014-12-29 00:20:54 +0100
committerAndreas Stöckel <andreas@somweyr.de>2014-12-29 00:20:54 +0100
commit0af66457f7739df4c1b151b2adb7479d87275c9a (patch)
tree82d0599d80b1f10bc613c2e1728cb6c9d0372fbc /test
parentcb3189b43290cb5bdf3b699f0cda1b6b6a5b871b (diff)
more unit tests
Diffstat (limited to 'test')
-rw-r--r--test/core/model/TypesystemTest.cpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/test/core/model/TypesystemTest.cpp b/test/core/model/TypesystemTest.cpp
index f995222..fd6e38f 100644
--- a/test/core/model/TypesystemTest.cpp
+++ b/test/core/model/TypesystemTest.cpp
@@ -472,6 +472,57 @@ TEST(StructType, creationWithParent)
ASSERT_EQ(42, arr[5].asInt());
}
+TEST(StructType, derivedFrom)
+{
+ Logger logger;
+ Manager mgr;
+ Rooted<StructType> structType = createStructType(mgr, logger);
+ Rooted<StructType> structWithParentType =
+ createStructTypeWithParent(structType, mgr, logger);
+
+ ASSERT_TRUE(structType->derivedFrom(structType));
+ ASSERT_TRUE(structWithParentType->derivedFrom(structType));
+ ASSERT_TRUE(structWithParentType->derivedFrom(structWithParentType));
+ ASSERT_FALSE(structType->derivedFrom(structWithParentType));
+}
+
+TEST(StructType, cast)
+{
+ Logger logger;
+ Manager mgr;
+ Rooted<StructType> structType = createStructType(mgr, logger);
+ Rooted<StructType> structWithParentType =
+ createStructTypeWithParent(structType, mgr, logger);
+
+ Variant val = structWithParentType->create();
+
+ Variant casted = structType->cast(val, logger);
+ 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());
+}
+
+TEST(StructType, indexOf)
+{
+ Logger logger;
+ Manager mgr;
+ Rooted<StructType> structType = createStructType(mgr, logger);
+ ASSERT_EQ(0, structType->indexOf("d"));
+ ASSERT_EQ(1, structType->indexOf("b"));
+ ASSERT_EQ(2, structType->indexOf("c"));
+ ASSERT_EQ(3, structType->indexOf("a"));
+ ASSERT_EQ(-1, structType->indexOf("#0"));
+}
+
/* Class ArrayType */
TEST(ArrayType, rtti)