summaryrefslogtreecommitdiff
path: root/test/core
diff options
context:
space:
mode:
authorAndreas Stöckel <astoecke@techfak.uni-bielefeld.de>2015-01-03 15:52:40 +0100
committerAndreas Stöckel <andreas@somweyr.de>2015-01-03 15:52:40 +0100
commit17e79d4535ef4dba7346dedb2a8341fc4421fa23 (patch)
treee206ddfd9d4880dcf9012b1c9c756f61adaf69f3 /test/core
parentd5c76d849026d79ee25587e099602aa6b9c648d9 (diff)
added test for the RttiBase::contains function
Diffstat (limited to 'test/core')
-rw-r--r--test/core/common/RttiTest.cpp52
1 files changed, 44 insertions, 8 deletions
diff --git a/test/core/common/RttiTest.cpp b/test/core/common/RttiTest.cpp
index 64b4bb0..7990593 100644
--- a/test/core/common/RttiTest.cpp
+++ b/test/core/common/RttiTest.cpp
@@ -25,16 +25,25 @@
#include <core/common/Rtti.hpp>
namespace ousia {
+namespace {
-class RttiTestClass1 {};
-class RttiTestClass2 {};
-class RttiTestClass3 {};
-class RttiTestClass4 {};
+class RttiTestClass1 {
+};
+class RttiTestClass2 {
+};
+class RttiTestClass3 {
+};
+class RttiTestClass4 {
+};
-static const Rtti<RttiTestClass1> Type1("Type1");
-static const Rtti<RttiTestClass2> Type2("Type2");
-static const Rtti<RttiTestClass3> Type3("Type3", {&Type1});
-static const Rtti<RttiTestClass4> Type4("Type4", {&Type3, &Type2});
+extern const Rtti<RttiTestClass2> Type6;
+
+const Rtti<RttiTestClass1> Type1("Type1");
+const Rtti<RttiTestClass2> Type2("Type2");
+const Rtti<RttiTestClass3> Type3("Type3", {&Type1});
+const Rtti<RttiTestClass4> Type4("Type4", {&Type3, &Type2});
+const Rtti<RttiTestClass1> Type5("Type5", {}, {&Type6});
+const Rtti<RttiTestClass2> Type6("Type6", {}, {&Type5, &Type1});
TEST(Rtti, isa)
{
@@ -59,5 +68,32 @@ TEST(Rtti, isa)
ASSERT_TRUE(Type4.isa(Type4));
}
+TEST(Rtti, contains)
+{
+ std::vector<const RttiBase *> types{&Type1, &Type2, &Type3, &Type4};
+ for (auto t : types) {
+ ASSERT_FALSE(t->contains(Type1));
+ ASSERT_FALSE(t->contains(Type2));
+ ASSERT_FALSE(t->contains(Type3));
+ ASSERT_FALSE(t->contains(Type4));
+ ASSERT_FALSE(t->contains(Type5));
+ ASSERT_FALSE(t->contains(Type6));
+ }
+
+ ASSERT_TRUE(Type5.contains(Type1));
+ ASSERT_FALSE(Type5.contains(Type2));
+ ASSERT_FALSE(Type5.contains(Type3));
+ ASSERT_FALSE(Type5.contains(Type4));
+ ASSERT_TRUE(Type5.contains(Type5));
+ ASSERT_TRUE(Type5.contains(Type6));
+
+ ASSERT_TRUE(Type6.contains(Type1));
+ ASSERT_FALSE(Type6.contains(Type2));
+ ASSERT_FALSE(Type6.contains(Type3));
+ ASSERT_FALSE(Type6.contains(Type4));
+ ASSERT_TRUE(Type6.contains(Type5));
+ ASSERT_TRUE(Type6.contains(Type6));
+}
+}
}