1 | #include <gtest/gtest.h> |
---|
2 | #include "core/CoreIncludes.h" |
---|
3 | #include "core/class/Identifiable.h" |
---|
4 | #include "core/module/ModuleInstance.h" |
---|
5 | |
---|
6 | namespace orxonox |
---|
7 | { |
---|
8 | namespace |
---|
9 | { |
---|
10 | class TestClass : public Identifiable |
---|
11 | { |
---|
12 | public: |
---|
13 | TestClass() { RegisterObject(TestClass); } |
---|
14 | }; |
---|
15 | |
---|
16 | class TestSubclass : public TestClass |
---|
17 | { |
---|
18 | public: |
---|
19 | TestSubclass() { RegisterObject(TestSubclass); } |
---|
20 | }; |
---|
21 | |
---|
22 | RegisterClassNoArgs(TestClass); |
---|
23 | RegisterClassNoArgs(TestSubclass); |
---|
24 | |
---|
25 | // Fixture |
---|
26 | class IdentifierTest : public ::testing::Test |
---|
27 | { |
---|
28 | public: |
---|
29 | virtual void SetUp() override |
---|
30 | { |
---|
31 | new IdentifierManager(); |
---|
32 | ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(StaticInitialization::IDENTIFIER); |
---|
33 | } |
---|
34 | |
---|
35 | virtual void TearDown() override |
---|
36 | { |
---|
37 | ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances(StaticInitialization::IDENTIFIER); |
---|
38 | delete &IdentifierManager::getInstance(); |
---|
39 | } |
---|
40 | }; |
---|
41 | } |
---|
42 | |
---|
43 | TEST_F(IdentifierTest, IdentifierExistsOfClass) |
---|
44 | { |
---|
45 | TestClass test; |
---|
46 | |
---|
47 | Identifier* identifier = Class(TestClass); |
---|
48 | EXPECT_TRUE(identifier != nullptr); |
---|
49 | } |
---|
50 | |
---|
51 | TEST_F(IdentifierTest, IdentifierExistsOfSubclass) |
---|
52 | { |
---|
53 | TestSubclass test; |
---|
54 | |
---|
55 | Identifier* identifier = Class(TestSubclass); |
---|
56 | EXPECT_TRUE(identifier != nullptr); |
---|
57 | } |
---|
58 | |
---|
59 | TEST_F(IdentifierTest, HasNameOfClass) |
---|
60 | { |
---|
61 | TestClass test; |
---|
62 | |
---|
63 | Identifier* identifier = Class(TestClass); |
---|
64 | EXPECT_EQ("TestClass", identifier->getName()); |
---|
65 | } |
---|
66 | |
---|
67 | TEST_F(IdentifierTest, HasNameOfSubClass) |
---|
68 | { |
---|
69 | TestSubclass test; |
---|
70 | |
---|
71 | Identifier* identifier = Class(TestSubclass); |
---|
72 | EXPECT_EQ("TestSubclass", identifier->getName()); |
---|
73 | } |
---|
74 | } |
---|