summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAndreas Stöckel <astoecke@techfak.uni-bielefeld.de>2014-12-20 15:51:00 +0100
committerAndreas Stöckel <andreas@somweyr.de>2014-12-20 15:51:00 +0100
commita7567d08e4d5869833069ec7211785af350aea88 (patch)
tree120971129563f9e5f054ea5bb740fcbf8f473936 /test
parent87233da76c01ebead18a26f01ffb4e20dffe3214 (diff)
Renamed ManagedType class to Rtti to make naming less confusing, implemented easier to use Rtti clas
Diffstat (limited to 'test')
-rw-r--r--test/core/managed/ManagedTest.cpp35
-rw-r--r--test/core/managed/RttiTest.cpp63
2 files changed, 68 insertions, 30 deletions
diff --git a/test/core/managed/ManagedTest.cpp b/test/core/managed/ManagedTest.cpp
index e286166..c88cf7a 100644
--- a/test/core/managed/ManagedTest.cpp
+++ b/test/core/managed/ManagedTest.cpp
@@ -75,33 +75,10 @@ class TypeTestManaged5 : public Managed {
using Managed::Managed;
};
-ManagedType Type1("Type1", typeid(TypeTestManaged1));
-ManagedType Type2("Type2", typeid(TypeTestManaged2));
-ManagedType Type3("Type3", typeid(TypeTestManaged3), {&Type1});
-ManagedType Type4("Type2", typeid(TypeTestManaged4), {&Type3, &Type2});
-
-TEST(ManagedType, isa)
-{
- ASSERT_TRUE(Type1.isa(Type1));
- ASSERT_FALSE(Type1.isa(Type2));
- ASSERT_FALSE(Type1.isa(Type3));
- ASSERT_FALSE(Type1.isa(Type4));
-
- ASSERT_FALSE(Type2.isa(Type1));
- ASSERT_TRUE(Type2.isa(Type2));
- ASSERT_FALSE(Type2.isa(Type3));
- ASSERT_FALSE(Type2.isa(Type4));
-
- ASSERT_TRUE(Type3.isa(Type1));
- ASSERT_FALSE(Type3.isa(Type2));
- ASSERT_TRUE(Type3.isa(Type3));
- ASSERT_FALSE(Type3.isa(Type4));
-
- ASSERT_TRUE(Type4.isa(Type1));
- ASSERT_TRUE(Type4.isa(Type2));
- ASSERT_TRUE(Type4.isa(Type3));
- ASSERT_TRUE(Type4.isa(Type4));
-}
+static const Rtti<TypeTestManaged1> Type1("Type1");
+static const Rtti<TypeTestManaged2> Type2("Type2");
+static const Rtti<TypeTestManaged3> Type3("Type3", {&Type1});
+static const Rtti<TypeTestManaged4> Type4("Type4", {&Type3, &Type2});
TEST(Managed, type)
{
@@ -117,10 +94,8 @@ TEST(Managed, type)
ASSERT_EQ(&Type2, &m2->type());
ASSERT_EQ(&Type3, &m3->type());
ASSERT_EQ(&Type4, &m4->type());
- ASSERT_EQ(&ManagedType::None, &m5->type());
+ ASSERT_EQ(&RttiBase::None, &m5->type());
- ASSERT_EQ(&Type1, &ManagedType::typeOf(*m1));
- ASSERT_EQ(&Type1, &ManagedType::typeOf<TypeTestManaged1>());
ASSERT_EQ(&Type1, &typeOf<TypeTestManaged1>());
ASSERT_EQ(&Type1, &typeOf(*m1));
}
diff --git a/test/core/managed/RttiTest.cpp b/test/core/managed/RttiTest.cpp
new file mode 100644
index 0000000..091bdea
--- /dev/null
+++ b/test/core/managed/RttiTest.cpp
@@ -0,0 +1,63 @@
+/*
+ Ousía
+ Copyright (C) 2014, 2015 Benjamin Paaßen, Andreas Stöckel
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include <array>
+#include <string>
+#include <iostream>
+
+#include <gtest/gtest.h>
+
+#include <core/managed/Rtti.hpp>
+
+namespace ousia {
+
+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});
+
+TEST(Rtti, isa)
+{
+ ASSERT_TRUE(Type1.isa(Type1));
+ ASSERT_FALSE(Type1.isa(Type2));
+ ASSERT_FALSE(Type1.isa(Type3));
+ ASSERT_FALSE(Type1.isa(Type4));
+
+ ASSERT_FALSE(Type2.isa(Type1));
+ ASSERT_TRUE(Type2.isa(Type2));
+ ASSERT_FALSE(Type2.isa(Type3));
+ ASSERT_FALSE(Type2.isa(Type4));
+
+ ASSERT_TRUE(Type3.isa(Type1));
+ ASSERT_FALSE(Type3.isa(Type2));
+ ASSERT_TRUE(Type3.isa(Type3));
+ ASSERT_FALSE(Type3.isa(Type4));
+
+ ASSERT_TRUE(Type4.isa(Type1));
+ ASSERT_TRUE(Type4.isa(Type2));
+ ASSERT_TRUE(Type4.isa(Type3));
+ ASSERT_TRUE(Type4.isa(Type4));
+}
+
+}
+