Changeset 10624 for code/trunk/test
- Timestamp:
- Oct 4, 2015, 9:12:21 PM (9 years ago)
- Location:
- code/trunk
- Files:
-
- 2 deleted
- 23 edited
- 3 copied
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
-
code/trunk/test/core/CMakeLists.txt
r10188 r10624 12 12 class/IdentifierClassHierarchyTest.cc 13 13 class/IdentifierSimpleClassHierarchyTest.cc 14 class/IdentifierNestedClassHierarchyTest.cc 14 15 class/IdentifierExternalClassHierarchyTest.cc 15 16 class/OrxonoxClassTest.cc … … 25 26 object/ObjectListBaseTest.cc 26 27 object/ObjectListIteratorTest.cc 27 object/S martPtrTest.cc28 object/StrongPtrTest.cc 28 29 object/WeakPtrTest.cc 30 singleton/ScopeTest.cc 29 31 ) 30 32 ADD_DEPENDENCIES(all_tests core_test) -
code/trunk/test/core/class/IdentifiableTest.cc
r9659 r10624 2 2 #include "core/CoreIncludes.h" 3 3 #include "core/class/Identifiable.h" 4 #include "core/module/ModuleInstance.h" 4 5 5 6 namespace orxonox … … 7 8 namespace 8 9 { 9 class Identifiable Test: public Identifiable10 class IdentifiableClass : public Identifiable 10 11 { 11 12 public: 12 IdentifiableTest() { RegisterObject(IdentifiableTest); } 13 IdentifiableClass() { RegisterObject(IdentifiableClass); } 14 }; 15 16 RegisterClassNoArgs(IdentifiableClass); 17 18 // Fixture 19 class IdentifiableTest : public ::testing::Test 20 { 21 public: 22 virtual void SetUp() 23 { 24 new IdentifierManager(); 25 ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(StaticInitialization::IDENTIFIER); 26 } 27 28 virtual void TearDown() 29 { 30 ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances(StaticInitialization::IDENTIFIER); 31 delete &IdentifierManager::getInstance(); 32 } 13 33 }; 14 34 } 15 35 16 TEST (IdentifiableTest, CanCreate)36 TEST_F(IdentifiableTest, CanCreate) 17 37 { 18 Identifiable Test* test = new IdentifiableTest();38 IdentifiableClass* test = new IdentifiableClass(); 19 39 ASSERT_TRUE(test != NULL); 20 40 delete test; 21 41 } 22 42 23 TEST (IdentifiableTest, HasIdentifierAssigned)43 TEST_F(IdentifiableTest, HasIdentifierAssigned) 24 44 { 25 Identifiable Testtest;45 IdentifiableClass test; 26 46 EXPECT_TRUE(test.getIdentifier()); 27 47 } 28 48 29 TEST (IdentifiableTest, CanBeIdentified)49 TEST_F(IdentifiableTest, CanBeIdentified) 30 50 { 31 Identifiable Testtest;32 EXPECT_TRUE(test.isA(Class(Identifiable Test)));51 IdentifiableClass test; 52 EXPECT_TRUE(test.isA(Class(IdentifiableClass))); 33 53 } 34 54 } -
code/trunk/test/core/class/IdentifierClassHierarchyTest.cc
r9659 r10624 4 4 #include "core/class/OrxonoxClass.h" 5 5 #include "core/class/OrxonoxInterface.h" 6 #include "core/module/ModuleInstance.h" 6 7 7 8 namespace orxonox … … 19 20 namespace 20 21 { 21 class BaseInterface1 : public OrxonoxInterface22 class BaseInterface1 : virtual public OrxonoxInterface 22 23 { 23 24 public: … … 30 31 }; 31 32 32 class BaseInterface2 : public OrxonoxInterface33 class BaseInterface2 : virtual public OrxonoxInterface 33 34 { 34 35 public: … … 124 125 }; 125 126 127 RegisterAbstractClass(BaseInterface1).inheritsFrom<OrxonoxInterface>(); 128 RegisterAbstractClass(BaseInterface2).inheritsFrom<OrxonoxInterface>(); 129 RegisterAbstractClass(Interface1).inheritsFrom<BaseInterface1>(); 130 RegisterAbstractClass(Interface2).inheritsFrom<BaseInterface2>(); 131 RegisterClassNoArgs(BaseClass); 132 RegisterClassNoArgs(Class0); 133 RegisterClassNoArgs(Class1); 134 RegisterClassNoArgs(Class2a); 135 RegisterClassNoArgs(Class2b); 136 RegisterClassNoArgs(Class3); 137 126 138 // Fixture 127 139 class IdentifierClassHierarchyTest : public ::testing::Test … … 130 142 virtual void SetUp() 131 143 { 132 registerClass("Context", new ClassFactoryWithContext<Context>()); 133 registerClass("Listable", new ClassFactoryWithContext<Listable>()); 134 registerClass("Configurable", new ClassFactoryNoArgs<Configurable>()); 135 registerClass("OrxonoxInterface", new ClassFactoryNoArgs<OrxonoxInterface>()); 136 registerClass("OrxonoxClass", new ClassFactoryNoArgs<OrxonoxClass>()); 137 registerClass("BaseInterface1", static_cast<ClassFactory<BaseInterface1>*>(NULL), false).inheritsFrom(Class(OrxonoxInterface)); 138 registerClass("BaseInterface2", static_cast<ClassFactory<BaseInterface2>*>(NULL), false).inheritsFrom(Class(OrxonoxInterface)); 139 registerClass("Interface1", static_cast<ClassFactory<Interface1>*>(NULL), false).inheritsFrom(Class(BaseInterface1)); 140 registerClass("Interface2", static_cast<ClassFactory<Interface2>*>(NULL), false).inheritsFrom(Class(BaseInterface2)); 141 registerClass("BaseClass", new ClassFactoryNoArgs<BaseClass>()); 142 registerClass("Class0", new ClassFactoryNoArgs<Class0>()); 143 registerClass("Class1", new ClassFactoryNoArgs<Class1>()); 144 registerClass("Class2a", new ClassFactoryNoArgs<Class2a>()); 145 registerClass("Class2b", new ClassFactoryNoArgs<Class2b>()); 146 registerClass("Class3", new ClassFactoryNoArgs<Class3>()); 147 144 new IdentifierManager(); 145 ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(StaticInitialization::IDENTIFIER); 146 Context::setRootContext(new Context(NULL)); 147 Identifier::initConfigValues_s = false; // TODO: hack! 148 148 IdentifierManager::getInstance().createClassHierarchy(); 149 149 } … … 151 151 virtual void TearDown() 152 152 { 153 IdentifierManager::getInstance().destroyAllIdentifiers(); 154 } 155 }; 153 IdentifierManager::getInstance().destroyClassHierarchy(); 154 Context::destroyRootContext(); 155 ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances(StaticInitialization::IDENTIFIER); 156 delete &IdentifierManager::getInstance(); 157 } 158 }; 159 160 bool contains(const std::list<const Identifier*> identifiers, Identifier* identifier) 161 { 162 return std::find(identifiers.begin(), identifiers.end(), identifier) != identifiers.end(); 163 } 156 164 157 165 bool contains(const std::set<const Identifier*> identifiers, Identifier* identifier) 158 166 { 159 167 return identifiers.find(identifier) != identifiers.end(); 160 }161 }162 163 TEST(IdentifierClassHierarchyTest_NoFixture, NoInitialization)164 {165 {166 Identifier* identifier = Class(BaseInterface1);167 EXPECT_EQ(0u, identifier->getChildren().size());168 EXPECT_EQ(0u, identifier->getParents().size());169 }170 {171 Identifier* identifier = Class(BaseInterface2);172 EXPECT_EQ(0u, identifier->getChildren().size());173 EXPECT_EQ(0u, identifier->getParents().size());174 }175 {176 Identifier* identifier = Class(Interface1);177 EXPECT_EQ(0u, identifier->getChildren().size());178 EXPECT_EQ(0u, identifier->getParents().size());179 }180 {181 Identifier* identifier = Class(Interface2);182 EXPECT_EQ(0u, identifier->getChildren().size());183 EXPECT_EQ(0u, identifier->getParents().size());184 }185 {186 Identifier* identifier = Class(BaseClass);187 EXPECT_EQ(0u, identifier->getChildren().size());188 EXPECT_EQ(0u, identifier->getParents().size());189 }190 {191 Identifier* identifier = Class(Class0);192 EXPECT_EQ(0u, identifier->getChildren().size());193 EXPECT_EQ(0u, identifier->getParents().size());194 }195 {196 Identifier* identifier = Class(Class1);197 EXPECT_EQ(0u, identifier->getChildren().size());198 EXPECT_EQ(0u, identifier->getParents().size());199 }200 {201 Identifier* identifier = Class(Class2a);202 EXPECT_EQ(0u, identifier->getChildren().size());203 EXPECT_EQ(0u, identifier->getParents().size());204 }205 {206 Identifier* identifier = Class(Class2b);207 EXPECT_EQ(0u, identifier->getChildren().size());208 EXPECT_EQ(0u, identifier->getParents().size());209 }210 {211 Identifier* identifier = Class(Class3);212 EXPECT_EQ(0u, identifier->getChildren().size());213 EXPECT_EQ(0u, identifier->getParents().size());214 168 } 215 169 } -
code/trunk/test/core/class/IdentifierExternalClassHierarchyTest.cc
r9659 r10624 2 2 #include "core/CoreIncludes.h" 3 3 #include "core/class/Identifiable.h" 4 #include "core/module/ModuleInstance.h" 4 5 5 6 namespace orxonox … … 38 39 }; 39 40 41 RegisterAbstractClass(Interface).inheritsFrom<Identifiable>(); 42 RegisterClassNoArgs(BaseClass); 43 RegisterClassNoArgs(RealClass); 44 40 45 // Fixture 41 46 class IdentifierExternalClassHierarchyTest : public ::testing::Test … … 44 49 virtual void SetUp() 45 50 { 46 registerClass("Context", new ClassFactoryWithContext<Context>()); 47 registerClass("Listable", new ClassFactoryWithContext<Listable>()); 48 registerClass("Interface", static_cast<ClassFactory<Interface>*>(NULL), false).inheritsFrom(Class(Identifiable)); 49 registerClass("BaseClass", new ClassFactoryNoArgs<BaseClass>()); 50 registerClass("RealClass", new ClassFactoryNoArgs<RealClass>()); 51 51 new IdentifierManager(); 52 ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(StaticInitialization::IDENTIFIER); 53 Context::setRootContext(new Context(NULL)); 54 Identifier::initConfigValues_s = false; // TODO: hack! 52 55 IdentifierManager::getInstance().createClassHierarchy(); 53 56 } … … 55 58 virtual void TearDown() 56 59 { 57 IdentifierManager::getInstance().destroyAllIdentifiers(); 60 IdentifierManager::getInstance().destroyClassHierarchy(); 61 Context::destroyRootContext(); 62 ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances(StaticInitialization::IDENTIFIER); 63 delete &IdentifierManager::getInstance(); 58 64 } 59 65 }; 66 67 bool contains(const std::list<const Identifier*> identifiers, Identifier* identifier) 68 { 69 return std::find(identifiers.begin(), identifiers.end(), identifier) != identifiers.end(); 70 } 60 71 61 72 bool contains(const std::set<const Identifier*> identifiers, Identifier* identifier) 62 73 { 63 74 return identifiers.find(identifier) != identifiers.end(); 64 }65 }66 67 TEST(IdentifierExternalClassHierarchyTest_NoFixture, NoInitialization)68 {69 {70 Identifier* identifier = Class(Interface);71 EXPECT_EQ(0u, identifier->getChildren().size());72 EXPECT_EQ(0u, identifier->getParents().size());73 }74 {75 Identifier* identifier = Class(BaseClass);76 EXPECT_EQ(0u, identifier->getChildren().size());77 EXPECT_EQ(0u, identifier->getParents().size());78 }79 {80 Identifier* identifier = Class(RealClass);81 EXPECT_EQ(0u, identifier->getChildren().size());82 EXPECT_EQ(0u, identifier->getParents().size());83 75 } 84 76 } -
code/trunk/test/core/class/IdentifierSimpleClassHierarchyTest.cc
r9659 r10624 4 4 #include "core/class/OrxonoxClass.h" 5 5 #include "core/class/OrxonoxInterface.h" 6 #include "core/module/ModuleInstance.h" 6 7 7 8 namespace orxonox … … 9 10 namespace 10 11 { 11 class Interface : public OrxonoxInterface12 class Interface : virtual public OrxonoxInterface 12 13 { 13 14 public: … … 40 41 }; 41 42 43 RegisterAbstractClass(Interface).inheritsFrom<OrxonoxInterface>(); 44 RegisterClassNoArgs(BaseClass); 45 RegisterClassNoArgs(RealClass); 46 42 47 // Fixture 43 48 class IdentifierSimpleClassHierarchyTest : public ::testing::Test … … 46 51 virtual void SetUp() 47 52 { 48 registerClass("Context", new ClassFactoryWithContext<Context>()); 49 registerClass("Listable", new ClassFactoryWithContext<Listable>()); 50 registerClass("Configurable", new ClassFactoryNoArgs<Configurable>()); 51 registerClass("OrxonoxInterface", new ClassFactoryNoArgs<OrxonoxInterface>()); 52 registerClass("OrxonoxClass", new ClassFactoryNoArgs<OrxonoxClass>()); 53 registerClass("Interface", static_cast<ClassFactory<Interface>*>(NULL), false).inheritsFrom(Class(OrxonoxInterface)); 54 registerClass("BaseClass", new ClassFactoryNoArgs<BaseClass>()); 55 registerClass("RealClass", new ClassFactoryNoArgs<RealClass>()); 56 53 new IdentifierManager(); 54 ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(StaticInitialization::IDENTIFIER); 55 Context::setRootContext(new Context(NULL)); 56 Identifier::initConfigValues_s = false; // TODO: hack! 57 57 IdentifierManager::getInstance().createClassHierarchy(); 58 58 } … … 60 60 virtual void TearDown() 61 61 { 62 IdentifierManager::getInstance().destroyAllIdentifiers(); 62 IdentifierManager::getInstance().destroyClassHierarchy(); 63 Context::destroyRootContext(); 64 ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances(StaticInitialization::IDENTIFIER); 65 delete &IdentifierManager::getInstance(); 63 66 } 64 67 }; 68 69 bool contains(const std::list<const Identifier*> identifiers, Identifier* identifier) 70 { 71 return std::find(identifiers.begin(), identifiers.end(), identifier) != identifiers.end(); 72 } 65 73 66 74 bool contains(const std::set<const Identifier*> identifiers, Identifier* identifier) 67 75 { 68 76 return identifiers.find(identifier) != identifiers.end(); 69 }70 }71 72 TEST(IdentifierSimpleClassHierarchyTest_NoFixture, NoInitialization)73 {74 {75 Identifier* identifier = Class(Interface);76 EXPECT_EQ(0u, identifier->getChildren().size());77 EXPECT_EQ(0u, identifier->getParents().size());78 }79 {80 Identifier* identifier = Class(BaseClass);81 EXPECT_EQ(0u, identifier->getChildren().size());82 EXPECT_EQ(0u, identifier->getParents().size());83 }84 {85 Identifier* identifier = Class(RealClass);86 EXPECT_EQ(0u, identifier->getChildren().size());87 EXPECT_EQ(0u, identifier->getParents().size());88 77 } 89 78 } -
code/trunk/test/core/class/IdentifierTest.cc
r9659 r10624 2 2 #include "core/CoreIncludes.h" 3 3 #include "core/class/Identifiable.h" 4 #include "core/module/ModuleInstance.h" 4 5 5 6 namespace orxonox … … 18 19 TestSubclass() { RegisterObject(TestSubclass); } 19 20 }; 21 22 RegisterClassNoArgs(TestClass); 23 RegisterClassNoArgs(TestSubclass); 24 25 // Fixture 26 class IdentifierTest : public ::testing::Test 27 { 28 public: 29 virtual void SetUp() 30 { 31 new IdentifierManager(); 32 ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(StaticInitialization::IDENTIFIER); 33 } 34 35 virtual void TearDown() 36 { 37 ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances(StaticInitialization::IDENTIFIER); 38 delete &IdentifierManager::getInstance(); 39 } 40 }; 20 41 } 21 42 22 TEST (IdentifierTest, IdentifierExistsOfClass)43 TEST_F(IdentifierTest, IdentifierExistsOfClass) 23 44 { 24 45 TestClass test; … … 28 49 } 29 50 30 TEST (IdentifierTest, IdentifierExistsOfSubclass)51 TEST_F(IdentifierTest, IdentifierExistsOfSubclass) 31 52 { 32 53 TestSubclass test; … … 36 57 } 37 58 38 TEST (IdentifierTest, HasNameOfClass)59 TEST_F(IdentifierTest, HasNameOfClass) 39 60 { 40 61 TestClass test; … … 44 65 } 45 66 46 TEST (IdentifierTest, HasNameOfSubClass)67 TEST_F(IdentifierTest, HasNameOfSubClass) 47 68 { 48 69 TestSubclass test; -
code/trunk/test/core/class/OrxonoxClassTest.cc
r9649 r10624 1 1 #include <gtest/gtest.h> 2 2 #include "core/class/OrxonoxClass.h" 3 #include "core/class/IdentifierManager.h" 3 4 #include "core/object/Context.h" 4 5 … … 17 18 virtual void SetUp() 18 19 { 20 new IdentifierManager(); 19 21 Context::setRootContext(new Context(NULL)); 20 22 } … … 22 24 virtual void TearDown() 23 25 { 24 Context::setRootContext(NULL); 26 Context::destroyRootContext(); 27 delete &IdentifierManager::getInstance(); 25 28 } 26 29 }; -
code/trunk/test/core/class/OrxonoxInterfaceTest.cc
r9649 r10624 2 2 #include "core/class/OrxonoxInterface.h" 3 3 #include "core/class/OrxonoxClass.h" 4 #include "core/class/IdentifierManager.h" 4 5 #include "core/object/Context.h" 5 6 … … 32 33 virtual void SetUp() 33 34 { 35 new IdentifierManager(); 34 36 Context::setRootContext(new Context(NULL)); 35 37 } … … 37 39 virtual void TearDown() 38 40 { 39 Context::setRootContext(NULL); 41 Context::destroyRootContext(); 42 delete &IdentifierManager::getInstance(); 40 43 } 41 44 }; -
code/trunk/test/core/class/SubclassIdentifierTest.cc
r9659 r10624 4 4 #include "core/class/SubclassIdentifier.h" 5 5 #include "core/class/OrxonoxClass.h" 6 #include "core/module/ModuleInstance.h" 6 7 7 8 namespace orxonox … … 21 22 }; 22 23 24 RegisterClass(TestClass); 25 RegisterClass(TestSubclass); 26 23 27 // Fixture 24 28 class SubclassIdentifierTest : public ::testing::Test … … 27 31 virtual void SetUp() 28 32 { 29 registerClass("OrxonoxClass", new ClassFactoryNoArgs<OrxonoxClass>());30 registerClass("TestClass", new ClassFactoryWithContext<TestClass>());31 registerClass("TestSubclass", new ClassFactoryWithContext<TestSubclass>());32 33 new IdentifierManager(); 34 ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(StaticInitialization::IDENTIFIER); 35 Context::setRootContext(new Context(NULL)); 36 Identifier::initConfigValues_s = false; // TODO: hack! 33 37 IdentifierManager::getInstance().createClassHierarchy(); 34 35 Context::setRootContext(new Context(NULL));36 38 } 37 39 38 40 virtual void TearDown() 39 41 { 40 Context::setRootContext(NULL); 41 42 IdentifierManager::getInstance().destroyAllIdentifiers(); 42 IdentifierManager::getInstance().destroyClassHierarchy(); 43 Context::destroyRootContext(); 44 ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances(StaticInitialization::IDENTIFIER); 45 delete &IdentifierManager::getInstance(); 43 46 } 44 47 }; -
code/trunk/test/core/class/SuperTest.cc
r9659 r10624 5 5 #include "core/BaseObject.h" 6 6 #include "core/class/Super.h" 7 #include "core/module/ModuleInstance.h" 7 8 8 9 namespace orxonox … … 62 63 }; 63 64 64 // Fixture 65 RegisterClass(TestClass); 66 RegisterClass(TestSubclass); 67 68 // Fixture 65 69 class SuperTest : public ::testing::Test 66 70 { … … 68 72 virtual void SetUp() 69 73 { 70 IdentifierManager::getInstance().destroyAllIdentifiers(); 71 72 registerClass("OrxonoxClass", new ClassFactoryNoArgs<OrxonoxClass>()); 73 registerClass("BaseObject", new ClassFactoryWithContext<BaseObject>()); 74 registerClass("TestClass", new ClassFactoryWithContext<TestClass>()); 75 registerClass("TestSubclass", new ClassFactoryWithContext<TestSubclass>()); 76 74 new IdentifierManager(); 75 ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(StaticInitialization::IDENTIFIER); 76 Context::setRootContext(new Context(NULL)); 77 Identifier::initConfigValues_s = false; // TODO: hack! 77 78 IdentifierManager::getInstance().createClassHierarchy(); 78 79 Context::setRootContext(new Context(NULL));80 79 } 81 80 82 81 virtual void TearDown() 83 82 { 84 Context::setRootContext(NULL); 85 86 IdentifierManager::getInstance().destroyAllIdentifiers(); 83 IdentifierManager::getInstance().destroyClassHierarchy(); 84 Context::destroyRootContext(); 85 ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances(StaticInitialization::IDENTIFIER); 86 delete &IdentifierManager::getInstance(); 87 87 } 88 88 }; … … 97 97 98 98 EXPECT_EQ(1u, identifier->getDirectParents().size()); 99 EXPECT_TRUE( identifier->getDirectParents().find(Class(TestClass)) != identifier->getDirectParents().end());99 EXPECT_TRUE(std::find(identifier->getDirectParents().begin(), identifier->getDirectParents().end(), Class(TestClass)) != identifier->getDirectParents().end()); 100 100 } 101 101 { … … 106 106 107 107 EXPECT_EQ(1u, identifier->getDirectParents().size()); 108 EXPECT_TRUE( identifier->getDirectParents().find(Class(BaseObject)) != identifier->getDirectParents().end());108 EXPECT_TRUE(std::find(identifier->getDirectParents().begin(), identifier->getDirectParents().end(), Class(BaseObject)) != identifier->getDirectParents().end()); 109 109 } 110 110 } -
code/trunk/test/core/command/CommandTest.cc
r9603 r10624 1 1 #include <gtest/gtest.h> 2 #include "core/command/ConsoleCommand.h" 2 #include "core/class/Identifier.h" 3 #include "core/class/IdentifierManager.h" 4 #include "core/command/ConsoleCommandIncludes.h" 3 5 #include "core/command/CommandExecutor.h" 4 6 #include "core/object/Destroyable.h" 7 #include "core/module/ModuleInstance.h" 5 8 6 9 namespace orxonox … … 130 133 ModifyConsoleCommand("test").popFunction(); 131 134 } 135 136 // Fixture 137 class CommandTest : public ::testing::Test 138 { 139 public: 140 virtual void SetUp() 141 { 142 new IdentifierManager(); 143 new ConsoleCommandManager(); 144 ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(StaticInitialization::CONSOLE_COMMAND); 145 Context::setRootContext(new Context(NULL)); 146 Identifier::initConfigValues_s = false; // TODO: hack! 147 IdentifierManager::getInstance().createClassHierarchy(); 148 } 149 150 virtual void TearDown() 151 { 152 IdentifierManager::getInstance().destroyClassHierarchy(); 153 Context::destroyRootContext(); 154 ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances(StaticInitialization::CONSOLE_COMMAND); 155 delete &ConsoleCommandManager::getInstance(); 156 delete &IdentifierManager::getInstance(); 157 } 158 }; 132 159 } 133 160 … … 139 166 } 140 167 141 TEST (CommandTest, ModuleTest)168 TEST_F(CommandTest, ModuleTest) 142 169 { 143 170 test(0, 0, 0); -
code/trunk/test/core/object/ClassFactoryTest.cc
r9649 r10624 3 3 #include "core/BaseObject.h" 4 4 #include "core/object/Context.h" 5 #include "core/module/ModuleInstance.h" 6 #include "core/CoreIncludes.h" 5 7 6 8 namespace orxonox … … 14 16 virtual void SetUp() 15 17 { 18 new IdentifierManager(); 19 ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(StaticInitialization::IDENTIFIER); 16 20 Context::setRootContext(new Context(NULL)); 17 21 } … … 19 23 virtual void TearDown() 20 24 { 21 Context::setRootContext(NULL); 25 Context::destroyRootContext(); 26 ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances(StaticInitialization::IDENTIFIER); 27 delete &IdentifierManager::getInstance(); 22 28 } 23 29 }; -
code/trunk/test/core/object/ContextTest.cc
r9659 r10624 3 3 #include "core/class/OrxonoxClass.h" 4 4 #include "core/CoreIncludes.h" 5 #include "core/module/ModuleInstance.h" 5 6 6 7 namespace orxonox … … 14 15 }; 15 16 17 RegisterClassNoArgs(SubclassContext); 18 16 19 // Fixture 17 20 class ContextTest : public ::testing::Test … … 20 23 virtual void SetUp() 21 24 { 25 new IdentifierManager(); 26 ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(StaticInitialization::IDENTIFIER); 22 27 Context::setRootContext(new Context(NULL)); 23 28 } … … 25 30 virtual void TearDown() 26 31 { 27 Context::setRootContext(NULL); 32 Context::destroyRootContext(); 33 ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances(StaticInitialization::IDENTIFIER); 34 delete &IdentifierManager::getInstance(); 28 35 } 29 36 }; -
code/trunk/test/core/object/IteratorTest.cc
r9659 r10624 6 6 #include "core/class/OrxonoxInterface.h" 7 7 #include "core/CoreIncludes.h" 8 #include "core/module/ModuleInstance.h" 8 9 9 10 namespace orxonox … … 24 25 }; 25 26 27 RegisterClassNoArgs(TestInterface); 28 RegisterClassNoArgs(TestClass); 29 26 30 // Fixture 27 31 class IteratorTest : public ::testing::Test … … 30 34 virtual void SetUp() 31 35 { 36 new IdentifierManager(); 37 ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(StaticInitialization::IDENTIFIER); 32 38 Context::setRootContext(new Context(NULL)); 33 39 } … … 35 41 virtual void TearDown() 36 42 { 37 Context::setRootContext(NULL); 43 Context::destroyRootContext(); 44 ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances(StaticInitialization::IDENTIFIER); 45 delete &IdentifierManager::getInstance(); 38 46 } 39 47 }; -
code/trunk/test/core/object/ListableTest.cc
r9659 r10624 2 2 #include "core/object/Listable.h" 3 3 #include "core/CoreIncludes.h" 4 #include "core/module/ModuleInstance.h" 4 5 5 6 namespace orxonox … … 10 11 { 11 12 public: 12 ListableClassTest() { RegisterObject(ListableClassTest); }13 ListableClassTest() { RegisterObject(ListableClassTest); } 13 14 }; 14 15 … … 18 19 ListableSubclassTest() { RegisterObject(ListableSubclassTest); } 19 20 }; 21 22 RegisterClassNoArgs(ListableClassTest); 23 RegisterClassNoArgs(ListableSubclassTest); 20 24 21 25 template <class T> … … 35 39 virtual void SetUp() 36 40 { 41 new IdentifierManager(); 42 ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(StaticInitialization::IDENTIFIER); 37 43 Context::setRootContext(new Context(NULL)); 38 44 } … … 40 46 virtual void TearDown() 41 47 { 42 Context::setRootContext(NULL); 48 Context::destroyRootContext(); 49 ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances(StaticInitialization::IDENTIFIER); 50 delete &IdentifierManager::getInstance(); 43 51 } 44 52 }; -
code/trunk/test/core/object/ObjectListIteratorTest.cc
r9659 r10624 5 5 #include "core/object/Listable.h" 6 6 #include "core/CoreIncludes.h" 7 #include "core/module/ModuleInstance.h" 7 8 8 9 namespace orxonox … … 17 18 }; 18 19 20 RegisterClassNoArgs(ListableTest); 21 19 22 // Fixture 20 23 class ObjectListIteratorTest : public ::testing::Test … … 23 26 virtual void SetUp() 24 27 { 28 new IdentifierManager(); 29 ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(StaticInitialization::IDENTIFIER); 25 30 Context::setRootContext(new Context(NULL)); 26 31 } … … 28 33 virtual void TearDown() 29 34 { 30 Context::setRootContext(NULL); 35 Context::destroyRootContext(); 36 ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances(StaticInitialization::IDENTIFIER); 37 delete &IdentifierManager::getInstance(); 31 38 } 32 39 }; -
code/trunk/test/core/object/WeakPtrTest.cc
r9603 r10624 45 45 test->destroy(); 46 46 } 47 48 void isNull(const WeakPtr<DestroyableTest> weakPtr) 49 { 50 EXPECT_TRUE(weakPtr == NULL); 51 EXPECT_TRUE(weakPtr == 0); 52 EXPECT_TRUE(!weakPtr); 53 EXPECT_FALSE(weakPtr != NULL); 54 EXPECT_FALSE(weakPtr != 0); 55 EXPECT_FALSE(weakPtr); 56 } 57 58 TEST(WeakPtrTest, IsNull) 59 { 60 { 61 WeakPtr<DestroyableTest> weakPtr; 62 isNull(weakPtr); 63 } 64 { 65 WeakPtr<DestroyableTest> weakPtr = NULL; 66 isNull(weakPtr); 67 } 68 { 69 WeakPtr<DestroyableTest> weakPtr; 70 weakPtr = NULL; 71 isNull(weakPtr); 72 } 73 { 74 WeakPtr<DestroyableTest> weakPtr = 0; 75 isNull(weakPtr); 76 } 77 { 78 WeakPtr<DestroyableTest> weakPtr; 79 weakPtr = 0; 80 isNull(weakPtr); 81 } 82 } 83 84 TEST(WeakPtrTest, IsNotNull) 85 { 86 DestroyableTest* test = new DestroyableTest(); 87 WeakPtr<DestroyableTest> weakPtr = test; 88 EXPECT_FALSE(weakPtr == NULL); 89 EXPECT_FALSE(weakPtr == 0); 90 EXPECT_FALSE(!weakPtr); 91 EXPECT_TRUE(weakPtr != NULL); 92 EXPECT_TRUE(weakPtr != 0); 93 EXPECT_TRUE(weakPtr); 94 test->destroy(); 95 } 47 96 } -
code/trunk/test/util/CMakeLists.txt
r10188 r10624 13 13 MultiTypeTest.cc 14 14 OutputTest.cc 15 ScopeTest.cc16 15 SharedPtrTest.cc 17 16 SingletonTest.cc -
code/trunk/test/util/output/ConsoleWriterTest.cc
r9547 r10624 7 7 namespace orxonox 8 8 { 9 TEST(ConsoleWriterTest, Disable)9 namespace 10 10 { 11 // reset output manager 12 OutputManager::Testing::getInstancePointer() = new OutputManager(); 11 // Fixture 12 class ConsoleWriterTest : public ::testing::Test 13 { 14 public: 15 virtual void SetUp() 16 { 17 // reset output manager 18 OutputManager::Testing::getInstancePointer() = new OutputManager(); 19 } 13 20 21 virtual void TearDown() 22 { 23 } 24 }; 25 } 26 27 TEST_F(ConsoleWriterTest, Disable) 28 { 14 29 std::ostream stream(NULL); 15 30 EXPECT_EQ(0U, OutputManager::getInstance().getListeners().size()); … … 20 35 } 21 36 22 TEST (ConsoleWriterTest, Enable)37 TEST_F(ConsoleWriterTest, Enable) 23 38 { 24 // reset output manager25 OutputManager::Testing::getInstancePointer() = new OutputManager();26 27 39 std::ostream stream(NULL); 28 40 ConsoleWriter writer(stream); … … 33 45 } 34 46 35 TEST (ConsoleWriterTest, WritesNoOutputToOutputStream)47 TEST_F(ConsoleWriterTest, WritesNoOutputToOutputStream) 36 48 { 37 49 std::stringbuf buffer; … … 44 56 } 45 57 46 TEST (ConsoleWriterTest, WritesOutputToOutputStream)58 TEST_F(ConsoleWriterTest, WritesOutputToOutputStream) 47 59 { 48 60 std::stringbuf buffer; … … 63 75 } 64 76 65 TEST (ConsoleWriterTest, DefaultConsoleWriterUsesCout)77 TEST_F(ConsoleWriterTest, DefaultConsoleWriterUsesCout) 66 78 { 67 79 OutputManager::getInstanceAndCreateListeners(); -
code/trunk/test/util/output/LogWriterTest.cc
r9549 r10624 3 3 #include "util/output/LogWriter.h" 4 4 #include "util/Convert.h" 5 #include "util/output/OutputManager.h" 6 #include "util/SharedPtr.h" 5 7 6 8 namespace orxonox … … 14 16 { this->LogWriter::printLine(line, level); } 15 17 }; 18 19 // Fixture 20 class LogWriterTest : public ::testing::Test 21 { 22 public: 23 virtual void SetUp() 24 { 25 // reset output manager 26 OutputManager::Testing::getInstancePointer() = new OutputManager(); 27 } 28 29 virtual void TearDown() 30 { 31 } 32 }; 16 33 } 17 34 18 35 // test constructor opens file 19 TEST (LogWriterTest, ConstructorOpensFile)36 TEST_F(LogWriterTest, ConstructorOpensFile) 20 37 { 21 38 LogWriter logWriter; … … 64 81 } 65 82 66 TEST (LogWriterTest, SetLogDirectoryOpensNewFile)83 TEST_F(LogWriterTest, SetLogDirectoryOpensNewFile) 67 84 { 68 85 std::string path = "./orxonox.log"; … … 83 100 84 101 // prints output to logfile 85 TEST (LogWriterTest, PrintsOutputToLogfile)102 TEST_F(LogWriterTest, PrintsOutputToLogfile) 86 103 { 87 104 std::string path; … … 103 120 104 121 // prints time to logfile 105 TEST (LogWriterTest, PrintsTimestampToLogfile)122 TEST_F(LogWriterTest, PrintsTimestampToLogfile) 106 123 { 107 124 std::string path; … … 152 169 } 153 170 154 TEST (LogWriterTest, ArchivesOldLogFile)171 TEST_F(LogWriterTest, ArchivesOldLogFile) 155 172 { 156 173 deleteAllLogFiles(); … … 196 213 } 197 214 198 TEST (LogWriterTest, ArchivesNineLogFiles)215 TEST_F(LogWriterTest, ArchivesNineLogFiles) 199 216 { 200 217 deleteAllLogFiles(); -
code/trunk/test/util/output/MemoryWriterTest.cc
r9545 r10624 4 4 #include "util/output/MemoryWriter.h" 5 5 #include "util/output/OutputManager.h" 6 #include "util/SharedPtr.h" 6 7 7 8 namespace orxonox … … 14 15 MOCK_METHOD3(output, void(OutputLevel, const OutputContextContainer&, const std::vector<std::string>&)); 15 16 }; 17 18 // Fixture 19 class MemoryWriterTest : public ::testing::Test 20 { 21 public: 22 virtual void SetUp() 23 { 24 // reset output manager 25 OutputManager::Testing::getInstancePointer() = new OutputManager(); 26 } 27 28 virtual void TearDown() 29 { 30 } 31 }; 16 32 } 17 33 18 TEST (MemoryWriterTest, Disable)34 TEST_F(MemoryWriterTest, Disable) 19 35 { 20 36 EXPECT_EQ(0U, OutputManager::getInstance().getListeners().size()); … … 25 41 } 26 42 27 TEST (MemoryWriterTest, ResendOutput)43 TEST_F(MemoryWriterTest, ResendOutput) 28 44 { 29 45 MemoryWriter writer; -
code/trunk/test/util/output/OutputManagerTest.cc
r9547 r10624 98 98 99 99 EXPECT_FALSE(manager.getListeners().empty()); 100 101 manager.unregisterListener(&listener); 100 102 } 101 103 … … 123 125 124 126 EXPECT_FALSE(listener.getListeners().empty()); 127 128 manager.unregisterListener(&listener); 125 129 } 126 130 … … 156 160 EXPECT_EQ(level::verbose_more, manager.getCombinedAdditionalContextsLevelMask()); 157 161 EXPECT_EQ(context::unittest2().mask, manager.getCombinedAdditionalContextsMask()); 162 163 manager.unregisterListener(&listener); 158 164 } 159 165 … … 193 199 194 200 EXPECT_EQ(level::internal_warning, manager.getCombinedLevelMask()); 201 202 manager.unregisterListener(&listener); 195 203 } 196 204 … … 208 216 209 217 EXPECT_EQ(level::internal_warning, manager.getCombinedAdditionalContextsLevelMask()); 218 219 manager.unregisterListener(&listener); 210 220 } 211 221 … … 223 233 224 234 EXPECT_EQ(context::unittest2().mask, manager.getCombinedAdditionalContextsMask()); 235 236 manager.unregisterListener(&listener); 225 237 } 226 238 … … 254 266 EXPECT_EQ(level::verbose | level::verbose_more | level::verbose_ultra, manager.getCombinedAdditionalContextsLevelMask()); 255 267 EXPECT_EQ(context::unittest1().mask | context::unittest2().mask | context::unittest3().mask, manager.getCombinedAdditionalContextsMask()); 268 269 manager.unregisterListener(&listener1); 270 manager.unregisterListener(&listener2); 271 manager.unregisterListener(&listener3); 256 272 } 257 273 … … 287 303 EXPECT_TRUE(manager.acceptsOutput(level::verbose_more, context::unittest2())); 288 304 EXPECT_FALSE(manager.acceptsOutput(level::verbose_ultra, context::unittest2())); 305 306 manager.unregisterListener(&listener); 289 307 } 290 308 … … 302 320 303 321 manager.pushMessage(level::user_status, context::unittest1(), "some output"); 322 323 manager.unregisterListener(&listener); 304 324 } 305 325 … … 319 339 320 340 manager.pushMessage(level::user_status, context::unittest1(), "some output\nand some more output\n!!!"); 341 342 manager.unregisterListener(&listener); 321 343 } 322 344
Note: See TracChangeset
for help on using the changeset viewer.