[Orxonox-commit 4978] r9647 - code/branches/core6/test/core/class

landauf at orxonox.net landauf at orxonox.net
Wed Aug 14 10:39:33 CEST 2013


Author: landauf
Date: 2013-08-14 10:39:32 +0200 (Wed, 14 Aug 2013)
New Revision: 9647

Modified:
   code/branches/core6/test/core/class/SubclassIdentifierTest.cc
   code/branches/core6/test/core/class/SuperTest.cc
Log:
fixed tests (caused problem with MSVC because they were executed in a different order)

Modified: code/branches/core6/test/core/class/SubclassIdentifierTest.cc
===================================================================
--- code/branches/core6/test/core/class/SubclassIdentifierTest.cc	2013-08-13 21:35:26 UTC (rev 9646)
+++ code/branches/core6/test/core/class/SubclassIdentifierTest.cc	2013-08-14 08:39:32 UTC (rev 9647)
@@ -20,18 +20,34 @@
                 TestSubclass(Context* context = NULL) { RegisterObject(TestSubclass); }
         };
 
-        RegisterClass(TestClass);
-        RegisterClass(TestSubclass);
+        // Fixture
+        class SubclassIdentifierTest : public ::testing::Test
+        {
+            public:
+                virtual void SetUp()
+                {
+                    registerClass("OrxonoxClass", new ClassFactoryNoArgs<OrxonoxClass>());
+                    registerClass("TestClass", new ClassFactoryWithContext<TestClass>());
+                    registerClass("TestSubclass", new ClassFactoryWithContext<TestSubclass>());
+
+                    IdentifierManager::getInstance().createClassHierarchy();
+                }
+
+                virtual void TearDown()
+                {
+                    IdentifierManager::getInstance().destroyAllIdentifiers();
+                }
+        };
     }
 
-    TEST(SubclassIdentifierTest, CanCreateIdentifier)
+    TEST_F(SubclassIdentifierTest, CanCreateIdentifier)
     {
         TestSubclass test;
 
         SubclassIdentifier<TestClass> subclassIdentifier;
     }
 
-    TEST(SubclassIdentifierTest, DefaultsToNormalIdentifier)
+    TEST_F(SubclassIdentifierTest, DefaultsToNormalIdentifier)
     {
         TestSubclass test;
 
@@ -39,21 +55,17 @@
         EXPECT_EQ(Class(TestClass), subclassIdentifier.getIdentifier());
     }
 
-    TEST(SubclassIdentifierTest, CanAssignIdentifierOfSubclass)
+    TEST_F(SubclassIdentifierTest, CanAssignIdentifierOfSubclass)
     {
         TestSubclass test;
-        IdentifierManager::getInstance().createClassHierarchy();
-
         SubclassIdentifier<TestClass> subclassIdentifier;
         subclassIdentifier = Class(TestSubclass);
         EXPECT_EQ(Class(TestSubclass), subclassIdentifier.getIdentifier());
     }
 
-    TEST(SubclassIdentifierTest, CanCreateSubclass)
+    TEST_F(SubclassIdentifierTest, CanCreateSubclass)
     {
         TestSubclass test;
-        IdentifierManager::getInstance().createClassHierarchy();
-
         SubclassIdentifier<TestClass> subclassIdentifier;
         subclassIdentifier = Class(TestSubclass);
 

Modified: code/branches/core6/test/core/class/SuperTest.cc
===================================================================
--- code/branches/core6/test/core/class/SuperTest.cc	2013-08-13 21:35:26 UTC (rev 9646)
+++ code/branches/core6/test/core/class/SuperTest.cc	2013-08-14 08:39:32 UTC (rev 9647)
@@ -61,14 +61,30 @@
                 XMLPort::Mode modeSubclass_;
         };
 
-        RegisterClass(TestClass);
-        RegisterClass(TestSubclass);
+        // Fixture
+        class SuperTest : public ::testing::Test
+        {
+            public:
+                virtual void SetUp()
+                {
+                    registerClass("OrxonoxClass", new ClassFactoryNoArgs<OrxonoxClass>());
+                    registerClass("BaseObject", new ClassFactoryWithContext<BaseObject>());
+                    registerClass("TestClass", new ClassFactoryWithContext<TestClass>());
+                    registerClass("TestSubclass", new ClassFactoryWithContext<TestSubclass>());
+
+                    IdentifierManager::getInstance().createClassHierarchy();
+                }
+
+                virtual void TearDown()
+                {
+                    IdentifierManager::getInstance().destroyAllIdentifiers();
+                }
+        };
     }
 
-    TEST(SuberTest, SuperCallWithoutArguments)
+    TEST_F(SuperTest, SuperCallWithoutArguments)
     {
         TestSubclass test;
-        IdentifierManager::getInstance().createClassHierarchy();
 
         EXPECT_FALSE(test.changedNameBase_);
         EXPECT_FALSE(test.changedNameSubclass_);
@@ -79,10 +95,9 @@
         EXPECT_TRUE(test.changedNameSubclass_);
     }
 
-    TEST(SuberTest, SuperCallWithArguments)
+    TEST_F(SuperTest, SuperCallWithArguments)
     {
         TestSubclass test;
-        IdentifierManager::getInstance().createClassHierarchy();
 
         EXPECT_FALSE(test.xmlPortBase_);
         EXPECT_FALSE(test.xmlPortSubclass_);




More information about the Orxonox-commit mailing list