summaryrefslogtreecommitdiff
path: root/test/core
diff options
context:
space:
mode:
authorAndreas Stöckel <astoecke@techfak.uni-bielefeld.de>2014-12-22 18:45:44 +0100
committerAndreas Stöckel <andreas@somweyr.de>2014-12-22 18:45:44 +0100
commit9ebe4f0b90a7217e479c656209e87ab6292662d5 (patch)
tree56c56be1a26392438b82b34a7bdaeb450aa9e747 /test/core
parent9c8d6b461246bbee6e3d8ac411c7f10da481acf2 (diff)
added unit tests and documentation for the IntType class
Diffstat (limited to 'test/core')
-rw-r--r--test/core/model/TypesystemTest.cpp44
1 files changed, 43 insertions, 1 deletions
diff --git a/test/core/model/TypesystemTest.cpp b/test/core/model/TypesystemTest.cpp
index 4c57431..b388fe0 100644
--- a/test/core/model/TypesystemTest.cpp
+++ b/test/core/model/TypesystemTest.cpp
@@ -103,6 +103,47 @@ TEST(StringType, conversion)
}
}
+/* Class IntType */
+
+TEST(IntType, rtti)
+{
+ Manager mgr;
+ Rooted<IntType> intType{new IntType(mgr, nullptr)};
+ ASSERT_TRUE(intType->isa(RttiTypes::IntType));
+ ASSERT_TRUE(intType->isa(typeOf<Type>()));
+ ASSERT_TRUE(intType->isa(typeOf<Node>()));
+}
+
+TEST(IntType, creation)
+{
+ Manager mgr;
+ Rooted<IntType> intType{new IntType(mgr, nullptr)};
+ Variant val = intType->create();
+ ASSERT_TRUE(val.isInt());
+ ASSERT_EQ(0, val.asInt());
+}
+
+TEST(IntType, conversion)
+{
+ Logger logger;
+ Manager mgr;
+ Rooted<IntType> intType{new IntType(mgr, nullptr)};
+
+ {
+ Variant val{314};
+ ASSERT_TRUE(intType->build(val, logger));
+ ASSERT_TRUE(val.isInt());
+ ASSERT_EQ(314, val.asInt());
+ }
+
+ {
+ Variant val{"1"};
+ ASSERT_FALSE(intType->build(val, logger));
+ ASSERT_TRUE(val.isInt());
+ ASSERT_EQ(0, val.asInt());
+ }
+}
+
/* Class ArrayType */
TEST(ArrayType, rtti)
@@ -123,6 +164,7 @@ TEST(ArrayType, creation)
Variant val = arrayType->create();
ASSERT_TRUE(val.isArray());
+ ASSERT_TRUE(val.asArray().empty());
}
TEST(ArrayType, conversion)
@@ -152,7 +194,7 @@ TEST(ArrayType, conversion)
Variant val{1};
ASSERT_FALSE(arrayType->build(val, logger));
ASSERT_TRUE(val.isArray());
- ASSERT_EQ(0U, val.asArray().size());
+ ASSERT_TRUE(val.asArray().empty());
}
}