Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/test/core/class/IdentifierTest.cc @ 12207

Last change on this file since 12207 was 11071, checked in by landauf, 9 years ago

merged branch cpp11_v3 back to trunk

  • Property svn:eol-style set to native
File size: 1.9 KB
RevLine 
[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
6namespace 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:
[11071]29                virtual void SetUp() override
[10624]30                {
31                    new IdentifierManager();
32                    ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(StaticInitialization::IDENTIFIER);
33                }
34
[11071]35                virtual void TearDown() override
[10624]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);
[11071]48        EXPECT_TRUE(identifier != nullptr);
[9601]49    }
50
[10624]51    TEST_F(IdentifierTest, IdentifierExistsOfSubclass)
[9601]52    {
53        TestSubclass test;
54
55        Identifier* identifier = Class(TestSubclass);
[11071]56        EXPECT_TRUE(identifier != nullptr);
[9601]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}
Note: See TracBrowser for help on using the repository browser.