Bug Summary

File:_plugin/PluginTest.cc
Location:line 185, column 9
Description:Called C++ object pointer is null

Annotated Source Code

1#include <gtest/gtest.h>
2#include <vector>
3
4#include "util/Exception.h"
5#include "core/Core.h"
6#include "core/CoreIncludes.h"
7#include "core/module/PluginReference.h"
8#include "core/commandline/CommandLineParser.h"
9#include "core/command/ConsoleCommand.h"
10#include "core/command/ConsoleCommandManager.h"
11
12#include "Testclass.h"
13#include "Testsingleton.h"
14
15namespace orxonox
16{
17 namespace
18 {
19 // Fixture
20 class PluginTest : public ::testing::Test
21 {
22 public:
23 PluginTest()
24 {
25 this->plugin_ = nullptr;
26 }
27
28 static void SetUpTestCase()
29 {
30 new Core("--noIOConsole");
31 }
32
33 static void TearDownTestCase()
34 {
35 delete &Core::getInstance();
36 }
37
38 void loadPlugin()
39 {
40 this->plugin_ = new PluginReference("testplugin");
41 }
42
43 void unloadPlugin()
44 {
45 delete this->plugin_;
46 this->plugin_ = nullptr;
47 }
48
49 virtual void TearDown() override
50 {
51 // make sure the plugin is unloaded
52 this->unloadPlugin();
53 }
54
55 private:
56 PluginReference* plugin_;
57 };
58 }
59
60
61 TEST_F(PluginTest, CanLoadPlugin)class PluginTest_CanLoadPlugin_Test : public PluginTest { public
: PluginTest_CanLoadPlugin_Test() {} private: virtual void TestBody
(); static ::testing::TestInfo* const test_info_ __attribute__
((unused)); PluginTest_CanLoadPlugin_Test(PluginTest_CanLoadPlugin_Test
const &); void operator=(PluginTest_CanLoadPlugin_Test const
&);};::testing::TestInfo* const PluginTest_CanLoadPlugin_Test
::test_info_ = ::testing::internal::MakeAndRegisterTestInfo(
"PluginTest", "CanLoadPlugin", __null, __null, (::testing::internal
::GetTypeId<PluginTest>()), PluginTest::SetUpTestCase, PluginTest
::TearDownTestCase, new ::testing::internal::TestFactoryImpl<
PluginTest_CanLoadPlugin_Test>);void PluginTest_CanLoadPlugin_Test
::TestBody()
62 {
63 this->loadPlugin();
64 this->unloadPlugin();
65 }
66
67
68 ///////////////////////////////////////////
69 /////////////// Identifier ////////////////
70 ///////////////////////////////////////////
71
72 Identifier* getIdentifier()
73 {
74 return ClassByString("Testclass");
75 }
76
77 TEST_F(PluginTest, LoadsIdentifier)class PluginTest_LoadsIdentifier_Test : public PluginTest { public
: PluginTest_LoadsIdentifier_Test() {} private: virtual void TestBody
(); static ::testing::TestInfo* const test_info_ __attribute__
((unused)); PluginTest_LoadsIdentifier_Test(PluginTest_LoadsIdentifier_Test
const &); void operator=(PluginTest_LoadsIdentifier_Test
const &);};::testing::TestInfo* const PluginTest_LoadsIdentifier_Test
::test_info_ = ::testing::internal::MakeAndRegisterTestInfo(
"PluginTest", "LoadsIdentifier", __null, __null, (::testing::
internal::GetTypeId<PluginTest>()), PluginTest::SetUpTestCase
, PluginTest::TearDownTestCase, new ::testing::internal::TestFactoryImpl
< PluginTest_LoadsIdentifier_Test>);void PluginTest_LoadsIdentifier_Test
::TestBody()
78 {
79 EXPECT_TRUE(getIdentifier() == nullptr)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(getIdentifier() == nullptr
)) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "/home/jenkins/workspace/orxonox_qc_trunk_checks/test/core_plugin/PluginTest.cc"
, 79, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "getIdentifier() == nullptr", "false", "true").c_str()) = ::
testing::Message()
;
80 this->loadPlugin();
81 EXPECT_TRUE(getIdentifier() != nullptr)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(getIdentifier() != nullptr
)) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "/home/jenkins/workspace/orxonox_qc_trunk_checks/test/core_plugin/PluginTest.cc"
, 81, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "getIdentifier() != nullptr", "false", "true").c_str()) = ::
testing::Message()
;
82 this->unloadPlugin();
83 }
84
85 TEST_F(PluginTest, UnloadsIdentifier)class PluginTest_UnloadsIdentifier_Test : public PluginTest {
public: PluginTest_UnloadsIdentifier_Test() {} private: virtual
void TestBody(); static ::testing::TestInfo* const test_info_
__attribute__ ((unused)); PluginTest_UnloadsIdentifier_Test(
PluginTest_UnloadsIdentifier_Test const &); void operator
=(PluginTest_UnloadsIdentifier_Test const &);};::testing::
TestInfo* const PluginTest_UnloadsIdentifier_Test ::test_info_
= ::testing::internal::MakeAndRegisterTestInfo( "PluginTest"
, "UnloadsIdentifier", __null, __null, (::testing::internal::
GetTypeId<PluginTest>()), PluginTest::SetUpTestCase, PluginTest
::TearDownTestCase, new ::testing::internal::TestFactoryImpl<
PluginTest_UnloadsIdentifier_Test>);void PluginTest_UnloadsIdentifier_Test
::TestBody()
86 {
87 this->loadPlugin();
88 EXPECT_TRUE(getIdentifier() != nullptr)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(getIdentifier() != nullptr
)) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "/home/jenkins/workspace/orxonox_qc_trunk_checks/test/core_plugin/PluginTest.cc"
, 88, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "getIdentifier() != nullptr", "false", "true").c_str()) = ::
testing::Message()
;
89 this->unloadPlugin();
90 EXPECT_TRUE(getIdentifier() == nullptr)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(getIdentifier() == nullptr
)) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "/home/jenkins/workspace/orxonox_qc_trunk_checks/test/core_plugin/PluginTest.cc"
, 90, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "getIdentifier() == nullptr", "false", "true").c_str()) = ::
testing::Message()
;
91 }
92
93 TEST_F(PluginTest, ReloadsIdentifier)class PluginTest_ReloadsIdentifier_Test : public PluginTest {
public: PluginTest_ReloadsIdentifier_Test() {} private: virtual
void TestBody(); static ::testing::TestInfo* const test_info_
__attribute__ ((unused)); PluginTest_ReloadsIdentifier_Test(
PluginTest_ReloadsIdentifier_Test const &); void operator
=(PluginTest_ReloadsIdentifier_Test const &);};::testing::
TestInfo* const PluginTest_ReloadsIdentifier_Test ::test_info_
= ::testing::internal::MakeAndRegisterTestInfo( "PluginTest"
, "ReloadsIdentifier", __null, __null, (::testing::internal::
GetTypeId<PluginTest>()), PluginTest::SetUpTestCase, PluginTest
::TearDownTestCase, new ::testing::internal::TestFactoryImpl<
PluginTest_ReloadsIdentifier_Test>);void PluginTest_ReloadsIdentifier_Test
::TestBody()
94 {
95 this->loadPlugin();
96 EXPECT_TRUE(getIdentifier() != nullptr)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(getIdentifier() != nullptr
)) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "/home/jenkins/workspace/orxonox_qc_trunk_checks/test/core_plugin/PluginTest.cc"
, 96, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "getIdentifier() != nullptr", "false", "true").c_str()) = ::
testing::Message()
;
97 this->unloadPlugin();
98 EXPECT_TRUE(getIdentifier() == nullptr)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(getIdentifier() == nullptr
)) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "/home/jenkins/workspace/orxonox_qc_trunk_checks/test/core_plugin/PluginTest.cc"
, 98, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "getIdentifier() == nullptr", "false", "true").c_str()) = ::
testing::Message()
;
99 this->loadPlugin();
100 EXPECT_TRUE(getIdentifier() != nullptr)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(getIdentifier() != nullptr
)) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "/home/jenkins/workspace/orxonox_qc_trunk_checks/test/core_plugin/PluginTest.cc"
, 100, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "getIdentifier() != nullptr", "false", "true").c_str()) = ::
testing::Message()
;
101 this->unloadPlugin();
102 }
103
104 TEST_F(PluginTest, CanCreateObjectFromIdentifier)class PluginTest_CanCreateObjectFromIdentifier_Test : public PluginTest
{ public: PluginTest_CanCreateObjectFromIdentifier_Test() {}
private: virtual void TestBody(); static ::testing::TestInfo
* const test_info_ __attribute__ ((unused)); PluginTest_CanCreateObjectFromIdentifier_Test
(PluginTest_CanCreateObjectFromIdentifier_Test const &); void
operator=(PluginTest_CanCreateObjectFromIdentifier_Test const
&);};::testing::TestInfo* const PluginTest_CanCreateObjectFromIdentifier_Test
::test_info_ = ::testing::internal::MakeAndRegisterTestInfo(
"PluginTest", "CanCreateObjectFromIdentifier", __null, __null
, (::testing::internal::GetTypeId<PluginTest>()), PluginTest
::SetUpTestCase, PluginTest::TearDownTestCase, new ::testing::
internal::TestFactoryImpl< PluginTest_CanCreateObjectFromIdentifier_Test
>);void PluginTest_CanCreateObjectFromIdentifier_Test::TestBody
()
105 {
106 this->loadPlugin();
107
108 Identifier* identifier = getIdentifier();
109 ASSERT_TRUE(identifier != nullptr)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(identifier != nullptr
)) ; else return ::testing::internal::AssertHelper(::testing::
TestPartResult::kFatalFailure, "/home/jenkins/workspace/orxonox_qc_trunk_checks/test/core_plugin/PluginTest.cc"
, 109, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "identifier != nullptr", "false", "true").c_str()) = ::testing
::Message()
;
110
111 Identifiable* object = identifier->fabricate(nullptr);
112 ASSERT_TRUE(object != nullptr)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(object != nullptr)) ;
else return ::testing::internal::AssertHelper(::testing::TestPartResult
::kFatalFailure, "/home/jenkins/workspace/orxonox_qc_trunk_checks/test/core_plugin/PluginTest.cc"
, 112, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "object != nullptr", "false", "true").c_str()) = ::testing::
Message()
;
113
114 Testclass* testclass = orxonox_cast<Testclass*>(object);
115 ASSERT_TRUE(testclass != nullptr)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(testclass != nullptr)
) ; else return ::testing::internal::AssertHelper(::testing::
TestPartResult::kFatalFailure, "/home/jenkins/workspace/orxonox_qc_trunk_checks/test/core_plugin/PluginTest.cc"
, 115, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "testclass != nullptr", "false", "true").c_str()) = ::testing
::Message()
;
116
117 EXPECT_EQ(666, testclass->getValue())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper(666)) == 1)>::Compare("666"
, "testclass->getValue()", 666, testclass->getValue()))
) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "/home/jenkins/workspace/orxonox_qc_trunk_checks/test/core_plugin/PluginTest.cc"
, 117, gtest_ar.failure_message()) = ::testing::Message()
;
118
119 this->unloadPlugin();
120 }
121
122
123 ///////////////////////////////////////////
124 //////////////// Singleton ////////////////
125 ///////////////////////////////////////////
126
127 // Cannot directly use Testsingleton::getInstance() because we don't link the test to the plugin.
128 // Also cannot directly use ObjectList<Testsingleton> because the Identifier is not known before the plugin is loaded.
129 Testsingleton* getSingleton()
130 {
131 std::vector<Testsingleton*> singletons;
132
133 for (Listable* listable : ObjectList<Listable>())
134 {
135 Testsingleton* singleton = dynamic_cast<Testsingleton*>(listable);
136 if (singleton)
137 singletons.push_back(singleton);
138 }
139
140 switch (singletons.size())
141 {
142 case 0:
143 return nullptr;
144 case 1:
145 return singletons[0];
146 default:
147 throw std::exception(); // unexpected number of singletons found
148 }
149 }
150
151 TEST_F(PluginTest, LoadsSingleton)class PluginTest_LoadsSingleton_Test : public PluginTest { public
: PluginTest_LoadsSingleton_Test() {} private: virtual void TestBody
(); static ::testing::TestInfo* const test_info_ __attribute__
((unused)); PluginTest_LoadsSingleton_Test(PluginTest_LoadsSingleton_Test
const &); void operator=(PluginTest_LoadsSingleton_Test const
&);};::testing::TestInfo* const PluginTest_LoadsSingleton_Test
::test_info_ = ::testing::internal::MakeAndRegisterTestInfo(
"PluginTest", "LoadsSingleton", __null, __null, (::testing::
internal::GetTypeId<PluginTest>()), PluginTest::SetUpTestCase
, PluginTest::TearDownTestCase, new ::testing::internal::TestFactoryImpl
< PluginTest_LoadsSingleton_Test>);void PluginTest_LoadsSingleton_Test
::TestBody()
152 {
153 EXPECT_TRUE(getSingleton() == nullptr)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(getSingleton() == nullptr
)) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "/home/jenkins/workspace/orxonox_qc_trunk_checks/test/core_plugin/PluginTest.cc"
, 153, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "getSingleton() == nullptr", "false", "true").c_str()) = ::
testing::Message()
;
154 this->loadPlugin();
155 EXPECT_TRUE(getSingleton() != nullptr)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(getSingleton() != nullptr
)) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "/home/jenkins/workspace/orxonox_qc_trunk_checks/test/core_plugin/PluginTest.cc"
, 155, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "getSingleton() != nullptr", "false", "true").c_str()) = ::
testing::Message()
;
156 this->unloadPlugin();
157 }
158
159 TEST_F(PluginTest, UnloadsSingleton)class PluginTest_UnloadsSingleton_Test : public PluginTest { public
: PluginTest_UnloadsSingleton_Test() {} private: virtual void
TestBody(); static ::testing::TestInfo* const test_info_ __attribute__
((unused)); PluginTest_UnloadsSingleton_Test(PluginTest_UnloadsSingleton_Test
const &); void operator=(PluginTest_UnloadsSingleton_Test
const &);};::testing::TestInfo* const PluginTest_UnloadsSingleton_Test
::test_info_ = ::testing::internal::MakeAndRegisterTestInfo(
"PluginTest", "UnloadsSingleton", __null, __null, (::testing
::internal::GetTypeId<PluginTest>()), PluginTest::SetUpTestCase
, PluginTest::TearDownTestCase, new ::testing::internal::TestFactoryImpl
< PluginTest_UnloadsSingleton_Test>);void PluginTest_UnloadsSingleton_Test
::TestBody()
160 {
161 this->loadPlugin();
162 EXPECT_TRUE(getSingleton() != nullptr)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(getSingleton() != nullptr
)) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "/home/jenkins/workspace/orxonox_qc_trunk_checks/test/core_plugin/PluginTest.cc"
, 162, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "getSingleton() != nullptr", "false", "true").c_str()) = ::
testing::Message()
;
163 this->unloadPlugin();
164 EXPECT_TRUE(getSingleton() == nullptr)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(getSingleton() == nullptr
)) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "/home/jenkins/workspace/orxonox_qc_trunk_checks/test/core_plugin/PluginTest.cc"
, 164, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "getSingleton() == nullptr", "false", "true").c_str()) = ::
testing::Message()
;
165 }
166
167 TEST_F(PluginTest, ReloadsSingleton)class PluginTest_ReloadsSingleton_Test : public PluginTest { public
: PluginTest_ReloadsSingleton_Test() {} private: virtual void
TestBody(); static ::testing::TestInfo* const test_info_ __attribute__
((unused)); PluginTest_ReloadsSingleton_Test(PluginTest_ReloadsSingleton_Test
const &); void operator=(PluginTest_ReloadsSingleton_Test
const &);};::testing::TestInfo* const PluginTest_ReloadsSingleton_Test
::test_info_ = ::testing::internal::MakeAndRegisterTestInfo(
"PluginTest", "ReloadsSingleton", __null, __null, (::testing
::internal::GetTypeId<PluginTest>()), PluginTest::SetUpTestCase
, PluginTest::TearDownTestCase, new ::testing::internal::TestFactoryImpl
< PluginTest_ReloadsSingleton_Test>);void PluginTest_ReloadsSingleton_Test
::TestBody()
168 {
169 this->loadPlugin();
170 EXPECT_TRUE(getSingleton() != nullptr)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(getSingleton() != nullptr
)) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "/home/jenkins/workspace/orxonox_qc_trunk_checks/test/core_plugin/PluginTest.cc"
, 170, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "getSingleton() != nullptr", "false", "true").c_str()) = ::
testing::Message()
;
171 this->unloadPlugin();
172 EXPECT_TRUE(getSingleton() == nullptr)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(getSingleton() == nullptr
)) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "/home/jenkins/workspace/orxonox_qc_trunk_checks/test/core_plugin/PluginTest.cc"
, 172, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "getSingleton() == nullptr", "false", "true").c_str()) = ::
testing::Message()
;
173 this->loadPlugin();
174 EXPECT_TRUE(getSingleton() != nullptr)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(getSingleton() != nullptr
)) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "/home/jenkins/workspace/orxonox_qc_trunk_checks/test/core_plugin/PluginTest.cc"
, 174, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "getSingleton() != nullptr", "false", "true").c_str()) = ::
testing::Message()
;
175 this->unloadPlugin();
176 }
177
178 TEST_F(PluginTest, CanCallFunctionOnSingleton)class PluginTest_CanCallFunctionOnSingleton_Test : public PluginTest
{ public: PluginTest_CanCallFunctionOnSingleton_Test() {} private
: virtual void TestBody(); static ::testing::TestInfo* const test_info_
__attribute__ ((unused)); PluginTest_CanCallFunctionOnSingleton_Test
(PluginTest_CanCallFunctionOnSingleton_Test const &); void
operator=(PluginTest_CanCallFunctionOnSingleton_Test const &
);};::testing::TestInfo* const PluginTest_CanCallFunctionOnSingleton_Test
::test_info_ = ::testing::internal::MakeAndRegisterTestInfo(
"PluginTest", "CanCallFunctionOnSingleton", __null, __null, (
::testing::internal::GetTypeId<PluginTest>()), PluginTest
::SetUpTestCase, PluginTest::TearDownTestCase, new ::testing::
internal::TestFactoryImpl< PluginTest_CanCallFunctionOnSingleton_Test
>);void PluginTest_CanCallFunctionOnSingleton_Test::TestBody
()
179 {
180 this->loadPlugin();
181
182 Testsingleton* singleton = getSingleton();
1
'singleton' initialized here
183 ASSERT_TRUE(singleton != nullptr)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(singleton != nullptr)
) ; else return ::testing::internal::AssertHelper(::testing::
TestPartResult::kFatalFailure, "/home/jenkins/workspace/orxonox_qc_trunk_checks/test/core_plugin/PluginTest.cc"
, 183, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "singleton != nullptr", "false", "true").c_str()) = ::testing
::Message()
;
2
Within the expansion of the macro 'ASSERT_TRUE':
a
Assuming pointer value is null
184
185 EXPECT_EQ(999, singleton->getValue())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper(999)) == 1)>::Compare("999"
, "singleton->getValue()", 999, singleton->getValue()))
) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "/home/jenkins/workspace/orxonox_qc_trunk_checks/test/core_plugin/PluginTest.cc"
, 185, gtest_ar.failure_message()) = ::testing::Message()
;
3
Within the expansion of the macro 'EXPECT_EQ':
a
Called C++ object pointer is null
186
187 this->unloadPlugin();
188 }
189
190
191 ///////////////////////////////////////////
192 ////////// Command Line Argument //////////
193 ///////////////////////////////////////////
194
195 bool hasCommandLineArgument()
196 {
197 try
198 {
199 CommandLineParser::getValue("testvalue");
200 return true;
201 }
202 catch (const ArgumentException&)
203 {
204 return false;
205 }
206 }
207
208 TEST_F(PluginTest, LoadsCommandLineArgument)class PluginTest_LoadsCommandLineArgument_Test : public PluginTest
{ public: PluginTest_LoadsCommandLineArgument_Test() {} private
: virtual void TestBody(); static ::testing::TestInfo* const test_info_
__attribute__ ((unused)); PluginTest_LoadsCommandLineArgument_Test
(PluginTest_LoadsCommandLineArgument_Test const &); void operator
=(PluginTest_LoadsCommandLineArgument_Test const &);};::testing
::TestInfo* const PluginTest_LoadsCommandLineArgument_Test ::
test_info_ = ::testing::internal::MakeAndRegisterTestInfo( "PluginTest"
, "LoadsCommandLineArgument", __null, __null, (::testing::internal
::GetTypeId<PluginTest>()), PluginTest::SetUpTestCase, PluginTest
::TearDownTestCase, new ::testing::internal::TestFactoryImpl<
PluginTest_LoadsCommandLineArgument_Test>);void PluginTest_LoadsCommandLineArgument_Test
::TestBody()
209 {
210 EXPECT_FALSE(hasCommandLineArgument())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(!(hasCommandLineArgument
()))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "/home/jenkins/workspace/orxonox_qc_trunk_checks/test/core_plugin/PluginTest.cc"
, 210, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "hasCommandLineArgument()", "true", "false").c_str()) = ::testing
::Message()
;
211 this->loadPlugin();
212 EXPECT_TRUE(hasCommandLineArgument())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(hasCommandLineArgument
())) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "/home/jenkins/workspace/orxonox_qc_trunk_checks/test/core_plugin/PluginTest.cc"
, 212, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "hasCommandLineArgument()", "false", "true").c_str()) = ::testing
::Message()
;
213 this->unloadPlugin();
214 }
215
216 TEST_F(PluginTest, UnloadsCommandLineArgument)class PluginTest_UnloadsCommandLineArgument_Test : public PluginTest
{ public: PluginTest_UnloadsCommandLineArgument_Test() {} private
: virtual void TestBody(); static ::testing::TestInfo* const test_info_
__attribute__ ((unused)); PluginTest_UnloadsCommandLineArgument_Test
(PluginTest_UnloadsCommandLineArgument_Test const &); void
operator=(PluginTest_UnloadsCommandLineArgument_Test const &
);};::testing::TestInfo* const PluginTest_UnloadsCommandLineArgument_Test
::test_info_ = ::testing::internal::MakeAndRegisterTestInfo(
"PluginTest", "UnloadsCommandLineArgument", __null, __null, (
::testing::internal::GetTypeId<PluginTest>()), PluginTest
::SetUpTestCase, PluginTest::TearDownTestCase, new ::testing::
internal::TestFactoryImpl< PluginTest_UnloadsCommandLineArgument_Test
>);void PluginTest_UnloadsCommandLineArgument_Test::TestBody
()
217 {
218 this->loadPlugin();
219 EXPECT_TRUE(hasCommandLineArgument())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(hasCommandLineArgument
())) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "/home/jenkins/workspace/orxonox_qc_trunk_checks/test/core_plugin/PluginTest.cc"
, 219, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "hasCommandLineArgument()", "false", "true").c_str()) = ::testing
::Message()
;
220 this->unloadPlugin();
221 EXPECT_FALSE(hasCommandLineArgument())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(!(hasCommandLineArgument
()))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "/home/jenkins/workspace/orxonox_qc_trunk_checks/test/core_plugin/PluginTest.cc"
, 221, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "hasCommandLineArgument()", "true", "false").c_str()) = ::testing
::Message()
;
222 }
223
224 TEST_F(PluginTest, ReloadsCommandLineArgument)class PluginTest_ReloadsCommandLineArgument_Test : public PluginTest
{ public: PluginTest_ReloadsCommandLineArgument_Test() {} private
: virtual void TestBody(); static ::testing::TestInfo* const test_info_
__attribute__ ((unused)); PluginTest_ReloadsCommandLineArgument_Test
(PluginTest_ReloadsCommandLineArgument_Test const &); void
operator=(PluginTest_ReloadsCommandLineArgument_Test const &
);};::testing::TestInfo* const PluginTest_ReloadsCommandLineArgument_Test
::test_info_ = ::testing::internal::MakeAndRegisterTestInfo(
"PluginTest", "ReloadsCommandLineArgument", __null, __null, (
::testing::internal::GetTypeId<PluginTest>()), PluginTest
::SetUpTestCase, PluginTest::TearDownTestCase, new ::testing::
internal::TestFactoryImpl< PluginTest_ReloadsCommandLineArgument_Test
>);void PluginTest_ReloadsCommandLineArgument_Test::TestBody
()
225 {
226 this->loadPlugin();
227 EXPECT_TRUE(hasCommandLineArgument())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(hasCommandLineArgument
())) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "/home/jenkins/workspace/orxonox_qc_trunk_checks/test/core_plugin/PluginTest.cc"
, 227, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "hasCommandLineArgument()", "false", "true").c_str()) = ::testing
::Message()
;
228 this->unloadPlugin();
229 EXPECT_FALSE(hasCommandLineArgument())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(!(hasCommandLineArgument
()))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "/home/jenkins/workspace/orxonox_qc_trunk_checks/test/core_plugin/PluginTest.cc"
, 229, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "hasCommandLineArgument()", "true", "false").c_str()) = ::testing
::Message()
;
230 this->loadPlugin();
231 EXPECT_TRUE(hasCommandLineArgument())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(hasCommandLineArgument
())) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "/home/jenkins/workspace/orxonox_qc_trunk_checks/test/core_plugin/PluginTest.cc"
, 231, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "hasCommandLineArgument()", "false", "true").c_str()) = ::testing
::Message()
;
232 this->unloadPlugin();
233 }
234
235 TEST_F(PluginTest, CommandLineArgumentHasCorrectValue)class PluginTest_CommandLineArgumentHasCorrectValue_Test : public
PluginTest { public: PluginTest_CommandLineArgumentHasCorrectValue_Test
() {} private: virtual void TestBody(); static ::testing::TestInfo
* const test_info_ __attribute__ ((unused)); PluginTest_CommandLineArgumentHasCorrectValue_Test
(PluginTest_CommandLineArgumentHasCorrectValue_Test const &
); void operator=(PluginTest_CommandLineArgumentHasCorrectValue_Test
const &);};::testing::TestInfo* const PluginTest_CommandLineArgumentHasCorrectValue_Test
::test_info_ = ::testing::internal::MakeAndRegisterTestInfo(
"PluginTest", "CommandLineArgumentHasCorrectValue", __null, __null
, (::testing::internal::GetTypeId<PluginTest>()), PluginTest
::SetUpTestCase, PluginTest::TearDownTestCase, new ::testing::
internal::TestFactoryImpl< PluginTest_CommandLineArgumentHasCorrectValue_Test
>);void PluginTest_CommandLineArgumentHasCorrectValue_Test
::TestBody()
236 {
237 this->loadPlugin();
238
239 ASSERT_TRUE(hasCommandLineArgument())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(hasCommandLineArgument
())) ; else return ::testing::internal::AssertHelper(::testing
::TestPartResult::kFatalFailure, "/home/jenkins/workspace/orxonox_qc_trunk_checks/test/core_plugin/PluginTest.cc"
, 239, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "hasCommandLineArgument()", "false", "true").c_str()) = ::testing
::Message()
;
240 EXPECT_EQ(333, CommandLineParser::getValue("testvalue").get<int>())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper(333)) == 1)>::Compare("333"
, "CommandLineParser::getValue(\"testvalue\").get<int>()"
, 333, CommandLineParser::getValue("testvalue").get<int>
()))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "/home/jenkins/workspace/orxonox_qc_trunk_checks/test/core_plugin/PluginTest.cc"
, 240, gtest_ar.failure_message()) = ::testing::Message()
;
241
242 this->unloadPlugin();
243 }
244
245
246 ///////////////////////////////////////////
247 ///////////// Console Command /////////////
248 ///////////////////////////////////////////
249
250 ConsoleCommand* getConsoleCommand()
251 {
252 return ConsoleCommandManager::getInstance().getCommand("testcommand");
253 }
254
255 TEST_F(PluginTest, LoadsConsoleCommand)class PluginTest_LoadsConsoleCommand_Test : public PluginTest
{ public: PluginTest_LoadsConsoleCommand_Test() {} private: virtual
void TestBody(); static ::testing::TestInfo* const test_info_
__attribute__ ((unused)); PluginTest_LoadsConsoleCommand_Test
(PluginTest_LoadsConsoleCommand_Test const &); void operator
=(PluginTest_LoadsConsoleCommand_Test const &);};::testing
::TestInfo* const PluginTest_LoadsConsoleCommand_Test ::test_info_
= ::testing::internal::MakeAndRegisterTestInfo( "PluginTest"
, "LoadsConsoleCommand", __null, __null, (::testing::internal
::GetTypeId<PluginTest>()), PluginTest::SetUpTestCase, PluginTest
::TearDownTestCase, new ::testing::internal::TestFactoryImpl<
PluginTest_LoadsConsoleCommand_Test>);void PluginTest_LoadsConsoleCommand_Test
::TestBody()
256 {
257 EXPECT_TRUE(getConsoleCommand() == nullptr)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(getConsoleCommand() ==
nullptr)) ; else ::testing::internal::AssertHelper(::testing
::TestPartResult::kNonFatalFailure, "/home/jenkins/workspace/orxonox_qc_trunk_checks/test/core_plugin/PluginTest.cc"
, 257, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "getConsoleCommand() == nullptr", "false", "true").c_str())
= ::testing::Message()
;
258 this->loadPlugin();
259 EXPECT_TRUE(getConsoleCommand() != nullptr)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(getConsoleCommand() !=
nullptr)) ; else ::testing::internal::AssertHelper(::testing
::TestPartResult::kNonFatalFailure, "/home/jenkins/workspace/orxonox_qc_trunk_checks/test/core_plugin/PluginTest.cc"
, 259, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "getConsoleCommand() != nullptr", "false", "true").c_str())
= ::testing::Message()
;
260 this->unloadPlugin();
261 }
262
263 TEST_F(PluginTest, UnloadsConsoleCommand)class PluginTest_UnloadsConsoleCommand_Test : public PluginTest
{ public: PluginTest_UnloadsConsoleCommand_Test() {} private
: virtual void TestBody(); static ::testing::TestInfo* const test_info_
__attribute__ ((unused)); PluginTest_UnloadsConsoleCommand_Test
(PluginTest_UnloadsConsoleCommand_Test const &); void operator
=(PluginTest_UnloadsConsoleCommand_Test const &);};::testing
::TestInfo* const PluginTest_UnloadsConsoleCommand_Test ::test_info_
= ::testing::internal::MakeAndRegisterTestInfo( "PluginTest"
, "UnloadsConsoleCommand", __null, __null, (::testing::internal
::GetTypeId<PluginTest>()), PluginTest::SetUpTestCase, PluginTest
::TearDownTestCase, new ::testing::internal::TestFactoryImpl<
PluginTest_UnloadsConsoleCommand_Test>);void PluginTest_UnloadsConsoleCommand_Test
::TestBody()
264 {
265 this->loadPlugin();
266 EXPECT_TRUE(getConsoleCommand() != nullptr)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(getConsoleCommand() !=
nullptr)) ; else ::testing::internal::AssertHelper(::testing
::TestPartResult::kNonFatalFailure, "/home/jenkins/workspace/orxonox_qc_trunk_checks/test/core_plugin/PluginTest.cc"
, 266, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "getConsoleCommand() != nullptr", "false", "true").c_str())
= ::testing::Message()
;
267 this->unloadPlugin();
268 EXPECT_TRUE(getConsoleCommand() == nullptr)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(getConsoleCommand() ==
nullptr)) ; else ::testing::internal::AssertHelper(::testing
::TestPartResult::kNonFatalFailure, "/home/jenkins/workspace/orxonox_qc_trunk_checks/test/core_plugin/PluginTest.cc"
, 268, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "getConsoleCommand() == nullptr", "false", "true").c_str())
= ::testing::Message()
;
269 }
270
271 TEST_F(PluginTest, ReloadsConsoleCommand)class PluginTest_ReloadsConsoleCommand_Test : public PluginTest
{ public: PluginTest_ReloadsConsoleCommand_Test() {} private
: virtual void TestBody(); static ::testing::TestInfo* const test_info_
__attribute__ ((unused)); PluginTest_ReloadsConsoleCommand_Test
(PluginTest_ReloadsConsoleCommand_Test const &); void operator
=(PluginTest_ReloadsConsoleCommand_Test const &);};::testing
::TestInfo* const PluginTest_ReloadsConsoleCommand_Test ::test_info_
= ::testing::internal::MakeAndRegisterTestInfo( "PluginTest"
, "ReloadsConsoleCommand", __null, __null, (::testing::internal
::GetTypeId<PluginTest>()), PluginTest::SetUpTestCase, PluginTest
::TearDownTestCase, new ::testing::internal::TestFactoryImpl<
PluginTest_ReloadsConsoleCommand_Test>);void PluginTest_ReloadsConsoleCommand_Test
::TestBody()
272 {
273 this->loadPlugin();
274 EXPECT_TRUE(getConsoleCommand() != nullptr)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(getConsoleCommand() !=
nullptr)) ; else ::testing::internal::AssertHelper(::testing
::TestPartResult::kNonFatalFailure, "/home/jenkins/workspace/orxonox_qc_trunk_checks/test/core_plugin/PluginTest.cc"
, 274, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "getConsoleCommand() != nullptr", "false", "true").c_str())
= ::testing::Message()
;
275 this->unloadPlugin();
276 EXPECT_TRUE(getConsoleCommand() == nullptr)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(getConsoleCommand() ==
nullptr)) ; else ::testing::internal::AssertHelper(::testing
::TestPartResult::kNonFatalFailure, "/home/jenkins/workspace/orxonox_qc_trunk_checks/test/core_plugin/PluginTest.cc"
, 276, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "getConsoleCommand() == nullptr", "false", "true").c_str())
= ::testing::Message()
;
277 this->loadPlugin();
278 EXPECT_TRUE(getConsoleCommand() != nullptr)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(getConsoleCommand() !=
nullptr)) ; else ::testing::internal::AssertHelper(::testing
::TestPartResult::kNonFatalFailure, "/home/jenkins/workspace/orxonox_qc_trunk_checks/test/core_plugin/PluginTest.cc"
, 278, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "getConsoleCommand() != nullptr", "false", "true").c_str())
= ::testing::Message()
;
279 this->unloadPlugin();
280 }
281
282 TEST_F(PluginTest, CanCallConsoleCommand)class PluginTest_CanCallConsoleCommand_Test : public PluginTest
{ public: PluginTest_CanCallConsoleCommand_Test() {} private
: virtual void TestBody(); static ::testing::TestInfo* const test_info_
__attribute__ ((unused)); PluginTest_CanCallConsoleCommand_Test
(PluginTest_CanCallConsoleCommand_Test const &); void operator
=(PluginTest_CanCallConsoleCommand_Test const &);};::testing
::TestInfo* const PluginTest_CanCallConsoleCommand_Test ::test_info_
= ::testing::internal::MakeAndRegisterTestInfo( "PluginTest"
, "CanCallConsoleCommand", __null, __null, (::testing::internal
::GetTypeId<PluginTest>()), PluginTest::SetUpTestCase, PluginTest
::TearDownTestCase, new ::testing::internal::TestFactoryImpl<
PluginTest_CanCallConsoleCommand_Test>);void PluginTest_CanCallConsoleCommand_Test
::TestBody()
283 {
284 this->loadPlugin();
285
286 ConsoleCommand* command = getConsoleCommand();
287 ASSERT_TRUE(command != nullptr)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(command != nullptr)) ;
else return ::testing::internal::AssertHelper(::testing::TestPartResult
::kFatalFailure, "/home/jenkins/workspace/orxonox_qc_trunk_checks/test/core_plugin/PluginTest.cc"
, 287, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "command != nullptr", "false", "true").c_str()) = ::testing
::Message()
;
288
289 EXPECT_EQ(999, (*command->getExecutor())(333, 666).get<int>())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper(999)) == 1)>::Compare("999"
, "(*command->getExecutor())(333, 666).get<int>()", 999
, (*command->getExecutor())(333, 666).get<int>()))) ;
else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "/home/jenkins/workspace/orxonox_qc_trunk_checks/test/core_plugin/PluginTest.cc"
, 289, gtest_ar.failure_message()) = ::testing::Message()
;
290
291 this->unloadPlugin();
292 }
293}