Changeset 9649 for code/branches/core6/test
- Timestamp:
- Aug 14, 2013, 6:42:28 PM (11 years ago)
- Location:
- code/branches/core6/test/core
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core6/test/core/class/OrxonoxClassTest.cc
r9601 r9649 1 1 #include <gtest/gtest.h> 2 2 #include "core/class/OrxonoxClass.h" 3 #include "core/object/Context.h" 3 4 4 5 namespace orxonox … … 9 10 { 10 11 }; 12 13 // Fixture 14 class OrxonoxClassTest : public ::testing::Test 15 { 16 public: 17 virtual void SetUp() 18 { 19 Context::setRootContext(new Context(NULL)); 20 } 21 22 virtual void TearDown() 23 { 24 Context::setRootContext(NULL); 25 } 26 }; 11 27 } 12 28 13 TEST (OrxonoxClassTest, CanCreate)29 TEST_F(OrxonoxClassTest, CanCreate) 14 30 { 15 31 TestClass* test = new TestClass(); -
code/branches/core6/test/core/class/OrxonoxInterfaceTest.cc
r9601 r9649 2 2 #include "core/class/OrxonoxInterface.h" 3 3 #include "core/class/OrxonoxClass.h" 4 #include "core/object/Context.h" 4 5 5 6 namespace orxonox … … 24 25 { 25 26 }; 27 28 // Fixture 29 class OrxonoxInterfaceTest : public ::testing::Test 30 { 31 public: 32 virtual void SetUp() 33 { 34 Context::setRootContext(new Context(NULL)); 35 } 36 37 virtual void TearDown() 38 { 39 Context::setRootContext(NULL); 40 } 41 }; 26 42 } 27 43 28 TEST (OrxonoxInterfaceTest, CanCreate1)44 TEST_F(OrxonoxInterfaceTest, CanCreate1) 29 45 { 30 46 TestClass1* test = new TestClass1(); … … 33 49 } 34 50 35 TEST (OrxonoxInterfaceTest, CanCreate2)51 TEST_F(OrxonoxInterfaceTest, CanCreate2) 36 52 { 37 53 TestClass2* test = new TestClass2(); -
code/branches/core6/test/core/class/SubclassIdentifierTest.cc
r9647 r9649 32 32 33 33 IdentifierManager::getInstance().createClassHierarchy(); 34 35 Context::setRootContext(new Context(NULL)); 34 36 } 35 37 36 38 virtual void TearDown() 37 39 { 40 Context::setRootContext(NULL); 41 38 42 IdentifierManager::getInstance().destroyAllIdentifiers(); 39 43 } -
code/branches/core6/test/core/class/SuperTest.cc
r9648 r9649 62 62 }; 63 63 64 64 // Fixture 65 65 class SuperTest : public ::testing::Test 66 66 { … … 76 76 77 77 IdentifierManager::getInstance().createClassHierarchy(); 78 79 Context::setRootContext(new Context(NULL)); 78 80 } 79 81 80 82 virtual void TearDown() 81 83 { 84 Context::setRootContext(NULL); 85 82 86 IdentifierManager::getInstance().destroyAllIdentifiers(); 83 87 } -
code/branches/core6/test/core/object/ClassFactoryTest.cc
r9637 r9649 2 2 #include "core/object/ClassFactory.h" 3 3 #include "core/BaseObject.h" 4 #include "core/object/Context.h" 4 5 5 6 namespace orxonox 6 7 { 7 TEST(ClassFactoryTest, CanFabricateObject) 8 namespace 9 { 10 // Fixture 11 class ClassFactoryTest : public ::testing::Test 12 { 13 public: 14 virtual void SetUp() 15 { 16 Context::setRootContext(new Context(NULL)); 17 } 18 19 virtual void TearDown() 20 { 21 Context::setRootContext(NULL); 22 } 23 }; 24 } 25 26 TEST_F(ClassFactoryTest, CanFabricateObject) 8 27 { 9 28 Factory* factory = new ClassFactoryWithContext<BaseObject>(); -
code/branches/core6/test/core/object/ContextTest.cc
r9629 r9649 13 13 SubclassContext() : Context(NULL) { RegisterRootObject(SubclassContext); } 14 14 }; 15 16 // Fixture 17 class ContextTest : public ::testing::Test 18 { 19 public: 20 virtual void SetUp() 21 { 22 Context::setRootContext(new Context(NULL)); 23 } 24 25 virtual void TearDown() 26 { 27 Context::setRootContext(NULL); 28 } 29 }; 15 30 } 16 31 17 TEST (ContextTest, CanCreateContext)32 TEST_F(ContextTest, CanCreateContext) 18 33 { 19 34 Context context(NULL); 20 35 } 21 36 22 TEST (ContextTest, CanCreateSubclassContext)37 TEST_F(ContextTest, CanCreateSubclassContext) 23 38 { 24 39 SubclassContext context; 25 40 } 26 41 27 TEST (ContextTest, ContextIsItsOwnContext)42 TEST_F(ContextTest, ContextIsItsOwnContext) 28 43 { 29 44 Context context(NULL); … … 31 46 } 32 47 33 TEST (ContextTest, SubclassContextIsItsOwnContext)48 TEST_F(ContextTest, SubclassContextIsItsOwnContext) 34 49 { 35 50 SubclassContext context; … … 37 52 } 38 53 39 TEST (ContextTest, SubclassAddsToItsOwnObjectList)54 TEST_F(ContextTest, SubclassAddsToItsOwnObjectList) 40 55 { 41 56 SubclassContext context; -
code/branches/core6/test/core/object/IteratorTest.cc
r9607 r9649 23 23 MOCK_METHOD0(test, void()); 24 24 }; 25 26 // Fixture 27 class IteratorTest : public ::testing::Test 28 { 29 public: 30 virtual void SetUp() 31 { 32 Context::setRootContext(new Context(NULL)); 33 } 34 35 virtual void TearDown() 36 { 37 Context::setRootContext(NULL); 38 } 39 }; 25 40 } 26 41 27 TEST (IteratorTest, CanCreateIterator)42 TEST_F(IteratorTest, CanCreateIterator) 28 43 { 29 44 Iterator<TestInterface> it; 30 45 } 31 46 32 TEST (IteratorTest, CanAssignIterator)47 TEST_F(IteratorTest, CanAssignIterator) 33 48 { 34 49 Iterator<TestInterface> it = ObjectList<TestInterface>::begin(); 35 50 } 36 51 37 TEST (IteratorTest, CanIterateOverEmptyList)52 TEST_F(IteratorTest, CanIterateOverEmptyList) 38 53 { 39 54 size_t i = 0; … … 43 58 } 44 59 45 TEST (IteratorTest, CanCallObjects)60 TEST_F(IteratorTest, CanCallObjects) 46 61 { 47 62 TestClass test1; -
code/branches/core6/test/core/object/ListableTest.cc
r9627 r9649 7 7 namespace 8 8 { 9 class Listable Test : public Listable9 class ListableClassTest : public Listable 10 10 { 11 11 public: 12 ListableTest() { RegisterRootObject(ListableTest); }12 ListableClassTest() { RegisterRootObject(ListableClassTest); } 13 13 }; 14 14 15 class ListableSubclassTest : public Listable Test15 class ListableSubclassTest : public ListableClassTest 16 16 { 17 17 public: … … 28 28 return false; 29 29 } 30 } 31 32 TEST(ListableTest, CanCreate) 33 { 34 ListableTest* test = new ListableTest(); 30 31 // Fixture 32 class ListableTest : public ::testing::Test 33 { 34 public: 35 virtual void SetUp() 36 { 37 Context::setRootContext(new Context(NULL)); 38 } 39 40 virtual void TearDown() 41 { 42 Context::setRootContext(NULL); 43 } 44 }; 45 } 46 47 TEST_F(ListableTest, CanCreate) 48 { 49 ListableClassTest* test = new ListableClassTest(); 35 50 ASSERT_TRUE(test != NULL); 36 51 delete test; 37 52 } 38 53 39 TEST (ListableTest, AddsToObjectList)40 { 41 Listable Test test;42 EXPECT_EQ(1u, ObjectList<Listable Test>::size());43 EXPECT_TRUE(objectListContains<Listable Test>(&test));44 } 45 46 TEST (ListableTest, AddsToAllObjectLists)47 { 48 ListableSubclassTest test; 49 EXPECT_EQ(1u, ObjectList<Listable Test>::size());50 EXPECT_TRUE(objectListContains<Listable Test>(&test));54 TEST_F(ListableTest, AddsToObjectList) 55 { 56 ListableClassTest test; 57 EXPECT_EQ(1u, ObjectList<ListableClassTest>::size()); 58 EXPECT_TRUE(objectListContains<ListableClassTest>(&test)); 59 } 60 61 TEST_F(ListableTest, AddsToAllObjectLists) 62 { 63 ListableSubclassTest test; 64 EXPECT_EQ(1u, ObjectList<ListableClassTest>::size()); 65 EXPECT_TRUE(objectListContains<ListableClassTest>(&test)); 51 66 EXPECT_EQ(1u, ObjectList<ListableSubclassTest>::size()); 52 67 EXPECT_TRUE(objectListContains<ListableSubclassTest>(&test)); 53 68 } 54 69 55 TEST (ListableTest, RemovesFromObjectList)56 { 57 EXPECT_EQ(0u, ObjectList<Listable Test>::size());58 { 59 Listable Test test;60 EXPECT_EQ(1u, ObjectList<Listable Test>::size());61 EXPECT_TRUE(objectListContains<Listable Test>(&test));70 TEST_F(ListableTest, RemovesFromObjectList) 71 { 72 EXPECT_EQ(0u, ObjectList<ListableClassTest>::size()); 73 { 74 ListableClassTest test; 75 EXPECT_EQ(1u, ObjectList<ListableClassTest>::size()); 76 EXPECT_TRUE(objectListContains<ListableClassTest>(&test)); 62 77 } 63 EXPECT_EQ(0u, ObjectList<Listable Test>::size());64 } 65 66 TEST (ListableTest, RemovesFromAllObjectLists)67 { 68 EXPECT_EQ(0u, ObjectList<Listable Test>::size());78 EXPECT_EQ(0u, ObjectList<ListableClassTest>::size()); 79 } 80 81 TEST_F(ListableTest, RemovesFromAllObjectLists) 82 { 83 EXPECT_EQ(0u, ObjectList<ListableClassTest>::size()); 69 84 EXPECT_EQ(0u, ObjectList<ListableSubclassTest>::size()); 70 85 { 71 86 ListableSubclassTest test; 72 EXPECT_EQ(1u, ObjectList<Listable Test>::size());73 EXPECT_TRUE(objectListContains<Listable Test>(&test));87 EXPECT_EQ(1u, ObjectList<ListableClassTest>::size()); 88 EXPECT_TRUE(objectListContains<ListableClassTest>(&test)); 74 89 EXPECT_EQ(1u, ObjectList<ListableSubclassTest>::size()); 75 90 EXPECT_TRUE(objectListContains<ListableSubclassTest>(&test)); 76 91 } 77 EXPECT_EQ(0u, ObjectList<Listable Test>::size());92 EXPECT_EQ(0u, ObjectList<ListableClassTest>::size()); 78 93 EXPECT_EQ(0u, ObjectList<ListableSubclassTest>::size()); 79 94 } 80 95 81 TEST (ListableTest, CanAddObjectToContext)96 TEST_F(ListableTest, CanAddObjectToContext) 82 97 { 83 98 Context context(NULL); … … 87 102 88 103 // object is in new context 89 EXPECT_EQ(1u, context.getObjectList<Listable Test>()->size());90 EXPECT_TRUE(objectListContains<Listable Test>(&test, &context));104 EXPECT_EQ(1u, context.getObjectList<ListableClassTest>()->size()); 105 EXPECT_TRUE(objectListContains<ListableClassTest>(&test, &context)); 91 106 EXPECT_EQ(1u, context.getObjectList<ListableSubclassTest>()->size()); 92 107 EXPECT_TRUE(objectListContains<ListableSubclassTest>(&test, &context)); 93 108 } 94 109 95 TEST (ListableTest, CanAddObjectToSubContext)110 TEST_F(ListableTest, CanAddObjectToSubContext) 96 111 { 97 112 Context baseContext(NULL); … … 102 117 103 118 // object is in both contexts 104 EXPECT_EQ(1u, baseContext.getObjectList<Listable Test>()->size());105 EXPECT_TRUE(objectListContains<Listable Test>(&test, &baseContext));119 EXPECT_EQ(1u, baseContext.getObjectList<ListableClassTest>()->size()); 120 EXPECT_TRUE(objectListContains<ListableClassTest>(&test, &baseContext)); 106 121 EXPECT_EQ(1u, baseContext.getObjectList<ListableSubclassTest>()->size()); 107 122 EXPECT_TRUE(objectListContains<ListableSubclassTest>(&test, &baseContext)); 108 123 109 EXPECT_EQ(1u, subContext.getObjectList<Listable Test>()->size());110 EXPECT_TRUE(objectListContains<Listable Test>(&test, &subContext));124 EXPECT_EQ(1u, subContext.getObjectList<ListableClassTest>()->size()); 125 EXPECT_TRUE(objectListContains<ListableClassTest>(&test, &subContext)); 111 126 EXPECT_EQ(1u, subContext.getObjectList<ListableSubclassTest>()->size()); 112 127 EXPECT_TRUE(objectListContains<ListableSubclassTest>(&test, &subContext)); 113 128 } 114 129 115 TEST (ListableTest, CanChangeContext)130 TEST_F(ListableTest, CanChangeContext) 116 131 { 117 132 Context* rootContext = Context::getRootContext(); … … 120 135 121 136 // object is in root context 122 EXPECT_EQ(1u, rootContext->getObjectList<Listable Test>()->size());123 EXPECT_TRUE(objectListContains<Listable Test>(&test, rootContext));137 EXPECT_EQ(1u, rootContext->getObjectList<ListableClassTest>()->size()); 138 EXPECT_TRUE(objectListContains<ListableClassTest>(&test, rootContext)); 124 139 EXPECT_EQ(1u, rootContext->getObjectList<ListableSubclassTest>()->size()); 125 140 EXPECT_TRUE(objectListContains<ListableSubclassTest>(&test, rootContext)); 126 141 127 142 // object is NOT in new context 128 EXPECT_EQ(0u, newContext.getObjectList<Listable Test>()->size());129 EXPECT_FALSE(objectListContains<Listable Test>(&test, &newContext));143 EXPECT_EQ(0u, newContext.getObjectList<ListableClassTest>()->size()); 144 EXPECT_FALSE(objectListContains<ListableClassTest>(&test, &newContext)); 130 145 EXPECT_EQ(0u, newContext.getObjectList<ListableSubclassTest>()->size()); 131 146 EXPECT_FALSE(objectListContains<ListableSubclassTest>(&test, &newContext)); … … 134 149 135 150 // object was removed from root context 136 EXPECT_EQ(0u, rootContext->getObjectList<Listable Test>()->size());137 EXPECT_FALSE(objectListContains<Listable Test>(&test, rootContext));151 EXPECT_EQ(0u, rootContext->getObjectList<ListableClassTest>()->size()); 152 EXPECT_FALSE(objectListContains<ListableClassTest>(&test, rootContext)); 138 153 EXPECT_EQ(0u, rootContext->getObjectList<ListableSubclassTest>()->size()); 139 154 EXPECT_FALSE(objectListContains<ListableSubclassTest>(&test, rootContext)); 140 155 141 156 // object is now in new context 142 EXPECT_EQ(1u, newContext.getObjectList<Listable Test>()->size());143 EXPECT_TRUE(objectListContains<Listable Test>(&test, &newContext));157 EXPECT_EQ(1u, newContext.getObjectList<ListableClassTest>()->size()); 158 EXPECT_TRUE(objectListContains<ListableClassTest>(&test, &newContext)); 144 159 EXPECT_EQ(1u, newContext.getObjectList<ListableSubclassTest>()->size()); 145 160 EXPECT_TRUE(objectListContains<ListableSubclassTest>(&test, &newContext)); 146 161 } 147 162 148 TEST (ListableTest, CanChangeToSubContext)163 TEST_F(ListableTest, CanChangeToSubContext) 149 164 { 150 165 Context* rootContext = Context::getRootContext(); … … 153 168 154 169 // object is in root context 155 EXPECT_EQ(1u, rootContext->getObjectList<Listable Test>()->size());156 EXPECT_TRUE(objectListContains<Listable Test>(&test, rootContext));170 EXPECT_EQ(1u, rootContext->getObjectList<ListableClassTest>()->size()); 171 EXPECT_TRUE(objectListContains<ListableClassTest>(&test, rootContext)); 157 172 EXPECT_EQ(1u, rootContext->getObjectList<ListableSubclassTest>()->size()); 158 173 EXPECT_TRUE(objectListContains<ListableSubclassTest>(&test, rootContext)); 159 174 160 175 // object is NOT in sub context 161 EXPECT_EQ(0u, subContext.getObjectList<Listable Test>()->size());162 EXPECT_FALSE(objectListContains<Listable Test>(&test, &subContext));176 EXPECT_EQ(0u, subContext.getObjectList<ListableClassTest>()->size()); 177 EXPECT_FALSE(objectListContains<ListableClassTest>(&test, &subContext)); 163 178 EXPECT_EQ(0u, subContext.getObjectList<ListableSubclassTest>()->size()); 164 179 EXPECT_FALSE(objectListContains<ListableSubclassTest>(&test, &subContext)); … … 167 182 168 183 // object is still in root context 169 EXPECT_EQ(1u, rootContext->getObjectList<Listable Test>()->size());170 EXPECT_TRUE(objectListContains<Listable Test>(&test, rootContext));184 EXPECT_EQ(1u, rootContext->getObjectList<ListableClassTest>()->size()); 185 EXPECT_TRUE(objectListContains<ListableClassTest>(&test, rootContext)); 171 186 EXPECT_EQ(1u, rootContext->getObjectList<ListableSubclassTest>()->size()); 172 187 EXPECT_TRUE(objectListContains<ListableSubclassTest>(&test, rootContext)); 173 188 174 189 // object is now also in sub context 175 EXPECT_EQ(1u, subContext.getObjectList<Listable Test>()->size());176 EXPECT_TRUE(objectListContains<Listable Test>(&test, &subContext));190 EXPECT_EQ(1u, subContext.getObjectList<ListableClassTest>()->size()); 191 EXPECT_TRUE(objectListContains<ListableClassTest>(&test, &subContext)); 177 192 EXPECT_EQ(1u, subContext.getObjectList<ListableSubclassTest>()->size()); 178 193 EXPECT_TRUE(objectListContains<ListableSubclassTest>(&test, &subContext)); 179 194 } 180 195 181 TEST (ListableTest, CanChangeFromSubcontextToSubContext)196 TEST_F(ListableTest, CanChangeFromSubcontextToSubContext) 182 197 { 183 198 Context* rootContext = Context::getRootContext(); … … 189 204 190 205 // object is in root context 191 EXPECT_EQ(1u, rootContext->getObjectList<Listable Test>()->size());192 EXPECT_TRUE(objectListContains<Listable Test>(&test, rootContext));206 EXPECT_EQ(1u, rootContext->getObjectList<ListableClassTest>()->size()); 207 EXPECT_TRUE(objectListContains<ListableClassTest>(&test, rootContext)); 193 208 EXPECT_EQ(1u, rootContext->getObjectList<ListableSubclassTest>()->size()); 194 209 EXPECT_TRUE(objectListContains<ListableSubclassTest>(&test, rootContext)); 195 210 196 211 // object is also in sub context 1 197 EXPECT_EQ(1u, subContext1.getObjectList<Listable Test>()->size());198 EXPECT_TRUE(objectListContains<Listable Test>(&test, &subContext1));212 EXPECT_EQ(1u, subContext1.getObjectList<ListableClassTest>()->size()); 213 EXPECT_TRUE(objectListContains<ListableClassTest>(&test, &subContext1)); 199 214 EXPECT_EQ(1u, subContext1.getObjectList<ListableSubclassTest>()->size()); 200 215 EXPECT_TRUE(objectListContains<ListableSubclassTest>(&test, &subContext1)); 201 216 202 217 // object is NOT in sub context 2 203 EXPECT_EQ(0u, subContext2.getObjectList<Listable Test>()->size());204 EXPECT_FALSE(objectListContains<Listable Test>(&test, &subContext2));218 EXPECT_EQ(0u, subContext2.getObjectList<ListableClassTest>()->size()); 219 EXPECT_FALSE(objectListContains<ListableClassTest>(&test, &subContext2)); 205 220 EXPECT_EQ(0u, subContext2.getObjectList<ListableSubclassTest>()->size()); 206 221 EXPECT_FALSE(objectListContains<ListableSubclassTest>(&test, &subContext2)); … … 209 224 210 225 // object is still in root context 211 EXPECT_EQ(1u, rootContext->getObjectList<Listable Test>()->size());212 EXPECT_TRUE(objectListContains<Listable Test>(&test, rootContext));226 EXPECT_EQ(1u, rootContext->getObjectList<ListableClassTest>()->size()); 227 EXPECT_TRUE(objectListContains<ListableClassTest>(&test, rootContext)); 213 228 EXPECT_EQ(1u, rootContext->getObjectList<ListableSubclassTest>()->size()); 214 229 EXPECT_TRUE(objectListContains<ListableSubclassTest>(&test, rootContext)); 215 230 216 231 // object was removed from sub context 1 217 EXPECT_EQ(0u, subContext1.getObjectList<Listable Test>()->size());218 EXPECT_FALSE(objectListContains<Listable Test>(&test, &subContext1));232 EXPECT_EQ(0u, subContext1.getObjectList<ListableClassTest>()->size()); 233 EXPECT_FALSE(objectListContains<ListableClassTest>(&test, &subContext1)); 219 234 EXPECT_EQ(0u, subContext1.getObjectList<ListableSubclassTest>()->size()); 220 235 EXPECT_FALSE(objectListContains<ListableSubclassTest>(&test, &subContext1)); 221 236 222 237 // object is now in sub context 2 223 EXPECT_EQ(1u, subContext2.getObjectList<Listable Test>()->size());224 EXPECT_TRUE(objectListContains<Listable Test>(&test, &subContext2));238 EXPECT_EQ(1u, subContext2.getObjectList<ListableClassTest>()->size()); 239 EXPECT_TRUE(objectListContains<ListableClassTest>(&test, &subContext2)); 225 240 EXPECT_EQ(1u, subContext2.getObjectList<ListableSubclassTest>()->size()); 226 241 EXPECT_TRUE(objectListContains<ListableSubclassTest>(&test, &subContext2)); -
code/branches/core6/test/core/object/ObjectListIteratorTest.cc
r9605 r9649 16 16 MOCK_METHOD0(test, void()); 17 17 }; 18 19 // Fixture 20 class ObjectListIteratorTest : public ::testing::Test 21 { 22 public: 23 virtual void SetUp() 24 { 25 Context::setRootContext(new Context(NULL)); 26 } 27 28 virtual void TearDown() 29 { 30 Context::setRootContext(NULL); 31 } 32 }; 18 33 } 19 34 20 TEST (ObjectListIteratorTest, CanCreateIterator)35 TEST_F(ObjectListIteratorTest, CanCreateIterator) 21 36 { 22 37 ObjectListIterator<ListableTest> it; 23 38 } 24 39 25 TEST (ObjectListIteratorTest, CanAssignIterator)40 TEST_F(ObjectListIteratorTest, CanAssignIterator) 26 41 { 27 42 ObjectListIterator<ListableTest> it = ObjectList<ListableTest>::begin(); 28 43 } 29 44 30 TEST (ObjectListIteratorTest, CanIterateOverEmptyList)45 TEST_F(ObjectListIteratorTest, CanIterateOverEmptyList) 31 46 { 32 47 size_t i = 0; … … 36 51 } 37 52 38 TEST (ObjectListIteratorTest, CanIterateOverFullList)53 TEST_F(ObjectListIteratorTest, CanIterateOverFullList) 39 54 { 40 55 ListableTest test1; … … 53 68 } 54 69 55 TEST (ObjectListIteratorTest, CanIterateReverseOverFullList)70 TEST_F(ObjectListIteratorTest, CanIterateReverseOverFullList) 56 71 { 57 72 ListableTest test1; … … 70 85 } 71 86 72 TEST (ObjectListIteratorTest, CanCallObjects)87 TEST_F(ObjectListIteratorTest, CanCallObjects) 73 88 { 74 89 ListableTest test1;
Note: See TracChangeset
for help on using the changeset viewer.