Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/core7/test/core/class/IdentifierTest.cc @ 10508

Last change on this file since 10508 was 10400, checked in by landauf, 10 years ago

fixed tests. however there are some open issues:

  • the class-hierarchy must be built exactly 1 times in core_test. this is currently done in CommandTest.cc because that's the first test to run in core_test which actually needs the class hierarchy. the order of tests is not guaranteed though, so this should be solved more generic
  • during creation of class hierarchy, config values are used. this fails in the tests, so it had to be disabled with a static flag in Identifier. this should be solved in a cleaner way.
  • because the class hierarchy is now statically generated for all tests in core_test in CommandTest.cc, there is no way to test identifiers in an uninitialized state. because of this, three tests had to be disabled (*_NoFixture tests)

⇒ make the creation of the class hierarchy more modular and fix these issues

  • Property svn:eol-style set to native
File size: 1.2 KB
Line 
1#include <gtest/gtest.h>
2#include "core/CoreIncludes.h"
3#include "core/class/Identifiable.h"
4
5namespace orxonox
6{
7    namespace
8    {
9        class TestClass : public Identifiable
10        {
11            public:
12                TestClass() { RegisterObject(TestClass); }
13        };
14
15        class TestSubclass : public TestClass
16        {
17            public:
18                TestSubclass() { RegisterObject(TestSubclass); }
19        };
20
21        RegisterClassNoArgs(TestClass);
22        RegisterClassNoArgs(TestSubclass);
23    }
24
25    TEST(IdentifierTest, IdentifierExistsOfClass)
26    {
27        TestClass test;
28
29        Identifier* identifier = Class(TestClass);
30        EXPECT_TRUE(identifier != NULL);
31    }
32
33    TEST(IdentifierTest, IdentifierExistsOfSubclass)
34    {
35        TestSubclass test;
36
37        Identifier* identifier = Class(TestSubclass);
38        EXPECT_TRUE(identifier != NULL);
39    }
40
41    TEST(IdentifierTest, HasNameOfClass)
42    {
43        TestClass test;
44
45        Identifier* identifier = Class(TestClass);
46        EXPECT_EQ("TestClass", identifier->getName());
47    }
48
49    TEST(IdentifierTest, HasNameOfSubClass)
50    {
51        TestSubclass test;
52
53        Identifier* identifier = Class(TestSubclass);
54        EXPECT_EQ("TestSubclass", identifier->getName());
55    }
56}
Note: See TracBrowser for help on using the repository browser.