Bug Summary

File:/class/SuperTest.cc
Location:line 135, column 9
Description:Forming reference to null pointer

Annotated Source Code

1#include <gtest/gtest.h>
2#include <tinyxml/tinyxml.h>
3
4#include "core/CoreIncludes.h"
5#include "core/BaseObject.h"
6#include "core/class/Super.h"
7#include "core/module/ModuleInstance.h"
8
9namespace orxonox
10{
11 namespace
12 {
13 class TestClass : public BaseObject
14 {
15 public:
16 TestClass(Context* context = nullptr) : BaseObject(context), changedNameBase_(false), xmlPortBase_(false), modeBase_(XMLPort::NOP)
17 {
18 RegisterObject(TestClass)if (ClassIdentifier<TestClass>::getIdentifier()->initializeObject
(this)) return; else ((void)0)
;
19 }
20
21 virtual void changedName() override
22 {
23 this->changedNameBase_ = true;
24 }
25
26 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override
27 {
28 this->xmlPortBase_ = true;
29 this->modeBase_ = mode;
30 }
31
32 bool changedNameBase_;
33 bool xmlPortBase_;
34 XMLPort::Mode modeBase_;
35 };
36
37 class TestSubclass : public TestClass
38 {
39 public:
40 TestSubclass(Context* context = nullptr) : TestClass(context), changedNameSubclass_(false), xmlPortSubclass_(false), modeSubclass_(XMLPort::NOP)
41 {
42 RegisterObject(TestSubclass)if (ClassIdentifier<TestSubclass>::getIdentifier()->
initializeObject(this)) return; else ((void)0)
;
43 }
44
45 virtual void changedName() override
46 {
47 this->changedNameSubclass_ = true;
48
49 SUPER(TestSubclass, changedName)(*ClassIdentifier<TestSubclass>::getIdentifier()->superFunctionCaller_changedName_
)(this)
;
50 }
51
52 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override
53 {
54 this->xmlPortSubclass_ = true;
55 this->modeSubclass_ = mode;
56
57 SUPER(TestSubclass, XMLPort, xmlelement, mode)(*ClassIdentifier<TestSubclass>::getIdentifier()->superFunctionCaller_XMLPort_
)(this, xmlelement, mode)
;
58 }
59
60 bool changedNameSubclass_;
61 bool xmlPortSubclass_;
62 XMLPort::Mode modeSubclass_;
63 };
64
65 RegisterClass(TestClass)orxonox::SI_I& _TestClassIdentifier = (*new orxonox::SI_I
(orxonox::registerClass<TestClass>("TestClass", new orxonox
::ClassFactoryWithContext<TestClass>(), true)))
;
66 RegisterClass(TestSubclass)orxonox::SI_I& _TestSubclassIdentifier = (*new orxonox::SI_I
(orxonox::registerClass<TestSubclass>("TestSubclass", new
orxonox::ClassFactoryWithContext<TestSubclass>(), true
)))
;
67
68 // Fixture
69 class SuperTest : public ::testing::Test
70 {
71 public:
72 virtual void SetUp() override
73 {
74 new IdentifierManager();
75 ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(StaticInitialization::IDENTIFIER);
76 Context::setRootContext(new Context(nullptr));
77 Identifier::initConfigValues_s = false; // TODO: hack!
78 IdentifierManager::getInstance().createClassHierarchy();
79 }
80
81 virtual void TearDown() override
82 {
83 IdentifierManager::getInstance().destroyClassHierarchy();
84 Context::destroyRootContext();
85 ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances(StaticInitialization::IDENTIFIER);
86 delete &IdentifierManager::getInstance();
87 }
88 };
89 }
90
91 TEST_F(SuperTest, ClassHierarchyIsCorrect)class SuperTest_ClassHierarchyIsCorrect_Test : public SuperTest
{ public: SuperTest_ClassHierarchyIsCorrect_Test() {} private
: virtual void TestBody(); static ::testing::TestInfo* const test_info_
__attribute__ ((unused)); SuperTest_ClassHierarchyIsCorrect_Test
(SuperTest_ClassHierarchyIsCorrect_Test const &); void operator
=(SuperTest_ClassHierarchyIsCorrect_Test const &);};::testing
::TestInfo* const SuperTest_ClassHierarchyIsCorrect_Test ::test_info_
= ::testing::internal::MakeAndRegisterTestInfo( "SuperTest",
"ClassHierarchyIsCorrect", __null, __null, (::testing::internal
::GetTypeId<SuperTest>()), SuperTest::SetUpTestCase, SuperTest
::TearDownTestCase, new ::testing::internal::TestFactoryImpl<
SuperTest_ClassHierarchyIsCorrect_Test>);void SuperTest_ClassHierarchyIsCorrect_Test
::TestBody()
92 {
93 {
94 Identifier* identifier = Class(TestSubclass)orxonox::ClassIdentifier<TestSubclass>::getIdentifier();
95
96 EXPECT_EQ(0u, identifier->getDirectChildren().size())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper(0u)) == 1)>::Compare("0u",
"identifier->getDirectChildren().size()", 0u, identifier->
getDirectChildren().size()))) ; else ::testing::internal::AssertHelper
(::testing::TestPartResult::kNonFatalFailure, "/home/jenkins/workspace/orxonox_qc_trunk_checks/test/core/class/SuperTest.cc"
, 96, gtest_ar.failure_message()) = ::testing::Message()
;
97
98 EXPECT_EQ(1u, identifier->getDirectParents().size())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper(1u)) == 1)>::Compare("1u",
"identifier->getDirectParents().size()", 1u, identifier->
getDirectParents().size()))) ; else ::testing::internal::AssertHelper
(::testing::TestPartResult::kNonFatalFailure, "/home/jenkins/workspace/orxonox_qc_trunk_checks/test/core/class/SuperTest.cc"
, 98, gtest_ar.failure_message()) = ::testing::Message()
;
99 EXPECT_TRUE(std::find(identifier->getDirectParents().begin(), identifier->getDirectParents().end(), Class(TestClass)) != identifier->getDirectParents().end())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(std::find(identifier->
getDirectParents().begin(), identifier->getDirectParents()
.end(), orxonox::ClassIdentifier<TestClass>::getIdentifier
()) != identifier->getDirectParents().end())) ; else ::testing
::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure
, "/home/jenkins/workspace/orxonox_qc_trunk_checks/test/core/class/SuperTest.cc"
, 99, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "std::find(identifier->getDirectParents().begin(), identifier->getDirectParents().end(), Class(TestClass)) != identifier->getDirectParents().end()"
, "false", "true").c_str()) = ::testing::Message()
;
100 }
101 {
102 Identifier* identifier = Class(TestClass)orxonox::ClassIdentifier<TestClass>::getIdentifier();
103
104 EXPECT_EQ(1u, identifier->getDirectChildren().size())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper(1u)) == 1)>::Compare("1u",
"identifier->getDirectChildren().size()", 1u, identifier->
getDirectChildren().size()))) ; else ::testing::internal::AssertHelper
(::testing::TestPartResult::kNonFatalFailure, "/home/jenkins/workspace/orxonox_qc_trunk_checks/test/core/class/SuperTest.cc"
, 104, gtest_ar.failure_message()) = ::testing::Message()
;
105 EXPECT_TRUE(identifier->getDirectChildren().find(Class(TestSubclass)) != identifier->getDirectChildren().end())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(identifier->getDirectChildren
().find(orxonox::ClassIdentifier<TestSubclass>::getIdentifier
()) != identifier->getDirectChildren().end())) ; else ::testing
::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure
, "/home/jenkins/workspace/orxonox_qc_trunk_checks/test/core/class/SuperTest.cc"
, 105, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "identifier->getDirectChildren().find(Class(TestSubclass)) != identifier->getDirectChildren().end()"
, "false", "true").c_str()) = ::testing::Message()
;
106
107 EXPECT_EQ(1u, identifier->getDirectParents().size())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper(1u)) == 1)>::Compare("1u",
"identifier->getDirectParents().size()", 1u, identifier->
getDirectParents().size()))) ; else ::testing::internal::AssertHelper
(::testing::TestPartResult::kNonFatalFailure, "/home/jenkins/workspace/orxonox_qc_trunk_checks/test/core/class/SuperTest.cc"
, 107, gtest_ar.failure_message()) = ::testing::Message()
;
108 EXPECT_TRUE(std::find(identifier->getDirectParents().begin(), identifier->getDirectParents().end(), Class(BaseObject)) != identifier->getDirectParents().end())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(std::find(identifier->
getDirectParents().begin(), identifier->getDirectParents()
.end(), orxonox::ClassIdentifier<BaseObject>::getIdentifier
()) != identifier->getDirectParents().end())) ; else ::testing
::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure
, "/home/jenkins/workspace/orxonox_qc_trunk_checks/test/core/class/SuperTest.cc"
, 108, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "std::find(identifier->getDirectParents().begin(), identifier->getDirectParents().end(), Class(BaseObject)) != identifier->getDirectParents().end()"
, "false", "true").c_str()) = ::testing::Message()
;
109 }
110 }
111
112 TEST_F(SuperTest, SuperCallWithoutArguments)class SuperTest_SuperCallWithoutArguments_Test : public SuperTest
{ public: SuperTest_SuperCallWithoutArguments_Test() {} private
: virtual void TestBody(); static ::testing::TestInfo* const test_info_
__attribute__ ((unused)); SuperTest_SuperCallWithoutArguments_Test
(SuperTest_SuperCallWithoutArguments_Test const &); void operator
=(SuperTest_SuperCallWithoutArguments_Test const &);};::testing
::TestInfo* const SuperTest_SuperCallWithoutArguments_Test ::
test_info_ = ::testing::internal::MakeAndRegisterTestInfo( "SuperTest"
, "SuperCallWithoutArguments", __null, __null, (::testing::internal
::GetTypeId<SuperTest>()), SuperTest::SetUpTestCase, SuperTest
::TearDownTestCase, new ::testing::internal::TestFactoryImpl<
SuperTest_SuperCallWithoutArguments_Test>);void SuperTest_SuperCallWithoutArguments_Test
::TestBody()
113 {
114 TestSubclass test;
115
116 EXPECT_FALSE(test.changedNameBase_)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(!(test.changedNameBase_
))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "/home/jenkins/workspace/orxonox_qc_trunk_checks/test/core/class/SuperTest.cc"
, 116, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "test.changedNameBase_", "true", "false").c_str()) = ::testing
::Message()
;
117 EXPECT_FALSE(test.changedNameSubclass_)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(!(test.changedNameSubclass_
))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "/home/jenkins/workspace/orxonox_qc_trunk_checks/test/core/class/SuperTest.cc"
, 117, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "test.changedNameSubclass_", "true", "false").c_str()) = ::
testing::Message()
;
118
119 test.changedName();
120
121 EXPECT_TRUE(test.changedNameBase_)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(test.changedNameBase_
)) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "/home/jenkins/workspace/orxonox_qc_trunk_checks/test/core/class/SuperTest.cc"
, 121, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "test.changedNameBase_", "false", "true").c_str()) = ::testing
::Message()
;
122 EXPECT_TRUE(test.changedNameSubclass_)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(test.changedNameSubclass_
)) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "/home/jenkins/workspace/orxonox_qc_trunk_checks/test/core/class/SuperTest.cc"
, 122, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "test.changedNameSubclass_", "false", "true").c_str()) = ::
testing::Message()
;
123 }
124
125 TEST_F(SuperTest, SuperCallWithArguments)class SuperTest_SuperCallWithArguments_Test : public SuperTest
{ public: SuperTest_SuperCallWithArguments_Test() {} private
: virtual void TestBody(); static ::testing::TestInfo* const test_info_
__attribute__ ((unused)); SuperTest_SuperCallWithArguments_Test
(SuperTest_SuperCallWithArguments_Test const &); void operator
=(SuperTest_SuperCallWithArguments_Test const &);};::testing
::TestInfo* const SuperTest_SuperCallWithArguments_Test ::test_info_
= ::testing::internal::MakeAndRegisterTestInfo( "SuperTest",
"SuperCallWithArguments", __null, __null, (::testing::internal
::GetTypeId<SuperTest>()), SuperTest::SetUpTestCase, SuperTest
::TearDownTestCase, new ::testing::internal::TestFactoryImpl<
SuperTest_SuperCallWithArguments_Test>);void SuperTest_SuperCallWithArguments_Test
::TestBody()
126 {
127 TestSubclass test;
128
129 EXPECT_FALSE(test.xmlPortBase_)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(!(test.xmlPortBase_))
) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "/home/jenkins/workspace/orxonox_qc_trunk_checks/test/core/class/SuperTest.cc"
, 129, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "test.xmlPortBase_", "true", "false").c_str()) = ::testing::
Message()
;
130 EXPECT_FALSE(test.xmlPortSubclass_)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(!(test.xmlPortSubclass_
))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "/home/jenkins/workspace/orxonox_qc_trunk_checks/test/core/class/SuperTest.cc"
, 130, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "test.xmlPortSubclass_", "true", "false").c_str()) = ::testing
::Message()
;
131 EXPECT_EQ(XMLPort::NOP, test.modeBase_)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper(XMLPort::NOP)) == 1)>::Compare
("XMLPort::NOP", "test.modeBase_", XMLPort::NOP, test.modeBase_
))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "/home/jenkins/workspace/orxonox_qc_trunk_checks/test/core/class/SuperTest.cc"
, 131, gtest_ar.failure_message()) = ::testing::Message()
;
132 EXPECT_EQ(XMLPort::NOP, test.modeSubclass_)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper(XMLPort::NOP)) == 1)>::Compare
("XMLPort::NOP", "test.modeSubclass_", XMLPort::NOP, test.modeSubclass_
))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "/home/jenkins/workspace/orxonox_qc_trunk_checks/test/core/class/SuperTest.cc"
, 132, gtest_ar.failure_message()) = ::testing::Message()
;
133
134 Element* element = nullptr;
1
'element' initialized to a null pointer value
135 test.XMLPort(*element, XMLPort::SaveObject);
2
Forming reference to null pointer
136
137 EXPECT_TRUE(test.xmlPortBase_)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(test.xmlPortBase_)) ;
else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "/home/jenkins/workspace/orxonox_qc_trunk_checks/test/core/class/SuperTest.cc"
, 137, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "test.xmlPortBase_", "false", "true").c_str()) = ::testing::
Message()
;
138 EXPECT_TRUE(test.xmlPortSubclass_)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(test.xmlPortSubclass_
)) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "/home/jenkins/workspace/orxonox_qc_trunk_checks/test/core/class/SuperTest.cc"
, 138, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "test.xmlPortSubclass_", "false", "true").c_str()) = ::testing
::Message()
;
139 EXPECT_EQ(XMLPort::SaveObject, test.modeBase_)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper(XMLPort::SaveObject)) == 1)>
::Compare("XMLPort::SaveObject", "test.modeBase_", XMLPort::SaveObject
, test.modeBase_))) ; else ::testing::internal::AssertHelper(
::testing::TestPartResult::kNonFatalFailure, "/home/jenkins/workspace/orxonox_qc_trunk_checks/test/core/class/SuperTest.cc"
, 139, gtest_ar.failure_message()) = ::testing::Message()
;
140 EXPECT_EQ(XMLPort::SaveObject, test.modeSubclass_)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper(XMLPort::SaveObject)) == 1)>
::Compare("XMLPort::SaveObject", "test.modeSubclass_", XMLPort
::SaveObject, test.modeSubclass_))) ; else ::testing::internal
::AssertHelper(::testing::TestPartResult::kNonFatalFailure, "/home/jenkins/workspace/orxonox_qc_trunk_checks/test/core/class/SuperTest.cc"
, 140, gtest_ar.failure_message()) = ::testing::Message()
;
141 }
142}