[9601] | 1 | #include <gtest/gtest.h> |
---|
| 2 | #include "core/CoreIncludes.h" |
---|
| 3 | #include "core/class/Identifiable.h" |
---|
[10624] | 4 | #include "core/module/ModuleInstance.h" |
---|
[9601] | 5 | |
---|
| 6 | namespace orxonox |
---|
| 7 | { |
---|
| 8 | namespace |
---|
| 9 | { |
---|
| 10 | class TestClass : public Identifiable |
---|
| 11 | { |
---|
| 12 | public: |
---|
[9659] | 13 | TestClass() { RegisterObject(TestClass); } |
---|
[9601] | 14 | }; |
---|
| 15 | |
---|
| 16 | class TestSubclass : public TestClass |
---|
| 17 | { |
---|
| 18 | public: |
---|
| 19 | TestSubclass() { RegisterObject(TestSubclass); } |
---|
| 20 | }; |
---|
[10624] | 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 | }; |
---|
[9601] | 41 | } |
---|
| 42 | |
---|
[10624] | 43 | TEST_F(IdentifierTest, IdentifierExistsOfClass) |
---|
[9601] | 44 | { |
---|
| 45 | TestClass test; |
---|
| 46 | |
---|
| 47 | Identifier* identifier = Class(TestClass); |
---|
| 48 | EXPECT_TRUE(identifier != NULL); |
---|
| 49 | } |
---|
| 50 | |
---|
[10624] | 51 | TEST_F(IdentifierTest, IdentifierExistsOfSubclass) |
---|
[9601] | 52 | { |
---|
| 53 | TestSubclass test; |
---|
| 54 | |
---|
| 55 | Identifier* identifier = Class(TestSubclass); |
---|
| 56 | EXPECT_TRUE(identifier != NULL); |
---|
| 57 | } |
---|
| 58 | |
---|
[10624] | 59 | TEST_F(IdentifierTest, HasNameOfClass) |
---|
[9601] | 60 | { |
---|
| 61 | TestClass test; |
---|
| 62 | |
---|
| 63 | Identifier* identifier = Class(TestClass); |
---|
| 64 | EXPECT_EQ("TestClass", identifier->getName()); |
---|
| 65 | } |
---|
| 66 | |
---|
[10624] | 67 | TEST_F(IdentifierTest, HasNameOfSubClass) |
---|
[9601] | 68 | { |
---|
| 69 | TestSubclass test; |
---|
| 70 | |
---|
| 71 | Identifier* identifier = Class(TestSubclass); |
---|
| 72 | EXPECT_EQ("TestSubclass", identifier->getName()); |
---|
| 73 | } |
---|
| 74 | } |
---|