Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/test/core/command/ExecutorPtrTest.cc @ 11436

Last change on this file since 11436 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: 2.4 KB
Line 
1#include <gtest/gtest.h>
2#include "core/command/Executor.h"
3
4namespace orxonox
5{
6    namespace
7    {
8        class Testclass : public Destroyable
9        {
10            public:
11                void testMember() {}
12                static void testStatic() {}
13        };
14
15        class Subclass : public Testclass
16        {
17        };
18
19        // Fixture
20        class ExecutorPtrTest : public ::testing::Test
21        {
22            public:
23                virtual void SetUp() override
24                {
25                }
26
27                virtual void TearDown() override
28                {
29                }
30        };
31    }
32
33    TEST_F(ExecutorPtrTest, emptyPtr)
34    {
35        ExecutorMemberPtr<Testclass> ptr1;
36        ExecutorStaticPtr ptr2;
37        ExecutorPtr ptr3;
38
39        ASSERT_FALSE(static_cast<bool>(ptr1));
40        ASSERT_FALSE(static_cast<bool>(ptr2));
41        ASSERT_FALSE(static_cast<bool>(ptr3));
42    }
43
44    TEST_F(ExecutorPtrTest, canAssignToExecutorMemberPtr)
45    {
46        ExecutorMemberPtr<Testclass> ptr = createExecutor(createFunctor(&Testclass::testMember));
47        ASSERT_TRUE(static_cast<bool>(ptr));
48    }
49
50    TEST_F(ExecutorPtrTest, canAssignToExecutorStaticPtr)
51    {
52        ExecutorStaticPtr ptr = createExecutor(createFunctor(&Testclass::testStatic));
53        ASSERT_TRUE(static_cast<bool>(ptr));
54    }
55
56    TEST_F(ExecutorPtrTest, canAssignToExecutorPtr)
57    {
58        ExecutorPtr ptr1 = createExecutor(createFunctor(&Testclass::testMember));
59        ASSERT_TRUE(static_cast<bool>(ptr1));
60        ExecutorPtr ptr2 = createExecutor(createFunctor(&Testclass::testStatic));
61        ASSERT_TRUE(static_cast<bool>(ptr2));
62    }
63
64    TEST_F(ExecutorPtrTest, canCastFromExecutorMemberPtr)
65    {
66        ExecutorMemberPtr<Testclass> ptr1 = createExecutor(createFunctor(&Testclass::testMember));
67        ExecutorPtr ptr2 = ptr1;
68        ASSERT_TRUE(static_cast<bool>(ptr2));
69    }
70
71    TEST_F(ExecutorPtrTest, canCastFromExecutorStaticPtr)
72    {
73        ExecutorStaticPtr ptr1 = createExecutor(createFunctor(&Testclass::testStatic));
74        ExecutorPtr ptr2 = ptr1;
75        ASSERT_TRUE(static_cast<bool>(ptr2));
76    }
77
78    TEST_F(ExecutorPtrTest, canCastToExecutorMemberOfSubclass)
79    {
80        ExecutorPtr ptr1 = createExecutor(createFunctor(&Subclass::testMember));
81        ExecutorMemberPtr<Subclass> ptr2 = std::static_pointer_cast<ExecutorMember<Subclass>>(ptr1);
82        ASSERT_TRUE(static_cast<bool>(ptr2));
83    }
84}
Note: See TracBrowser for help on using the repository browser.