Bug Summary

File:core/class/OrxonoxInterfaceTest.cc
Location:line 50, column 9
Description:Potential leak of memory pointed to by 'test'

Annotated Source Code

1#include <gtest/gtest.h>
2#include "core/class/OrxonoxInterface.h"
3#include "core/class/OrxonoxClass.h"
4#include "core/class/IdentifierManager.h"
5#include "core/object/Context.h"
6
7namespace orxonox
8{
9 namespace
10 {
11 class Interface1 : virtual public OrxonoxInterface
12 {
13 };
14 class Interface2 : virtual public OrxonoxInterface
15 {
16 };
17 class Interface3 : virtual public OrxonoxInterface
18 {
19 };
20
21 class TestClass1 : public Interface1, public Interface2, public Interface3
22 {
23 };
24
25 class TestClass2 : public OrxonoxClass, public Interface1, public Interface2, public Interface3
26 {
27 };
28
29 // Fixture
30 class OrxonoxInterfaceTest : public ::testing::Test
31 {
32 public:
33 virtual void SetUp() override
34 {
35 new IdentifierManager();
36 Context::setRootContext(new Context(nullptr));
37 }
38
39 virtual void TearDown() override
40 {
41 Context::destroyRootContext();
42 delete &IdentifierManager::getInstance();
43 }
44 };
45 }
46
47 TEST_F(OrxonoxInterfaceTest, CanCreate1)class OrxonoxInterfaceTest_CanCreate1_Test : public OrxonoxInterfaceTest
{ public: OrxonoxInterfaceTest_CanCreate1_Test() {} private:
virtual void TestBody(); static ::testing::TestInfo* const test_info_
__attribute__ ((unused)); OrxonoxInterfaceTest_CanCreate1_Test
(OrxonoxInterfaceTest_CanCreate1_Test const &); void operator
=(OrxonoxInterfaceTest_CanCreate1_Test const &);};::testing
::TestInfo* const OrxonoxInterfaceTest_CanCreate1_Test ::test_info_
= ::testing::internal::MakeAndRegisterTestInfo( "OrxonoxInterfaceTest"
, "CanCreate1", __null, __null, (::testing::internal::GetTypeId
<OrxonoxInterfaceTest>()), OrxonoxInterfaceTest::SetUpTestCase
, OrxonoxInterfaceTest::TearDownTestCase, new ::testing::internal
::TestFactoryImpl< OrxonoxInterfaceTest_CanCreate1_Test>
);void OrxonoxInterfaceTest_CanCreate1_Test::TestBody()
48 {
49 TestClass1* test = new TestClass1();
1
Memory is allocated
50 ASSERT_TRUE(test != nullptr)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(test != nullptr)) ; else
return ::testing::internal::AssertHelper(::testing::TestPartResult
::kFatalFailure, "/home/jenkins/workspace/orxonox_qc_trunk_checks/test/core/class/OrxonoxInterfaceTest.cc"
, 50, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "test != nullptr", "false", "true").c_str()) = ::testing::Message
()
;
2
Within the expansion of the macro 'ASSERT_TRUE':
a
Potential leak of memory pointed to by 'test'
51 delete test;
52 }
53
54 TEST_F(OrxonoxInterfaceTest, CanCreate2)class OrxonoxInterfaceTest_CanCreate2_Test : public OrxonoxInterfaceTest
{ public: OrxonoxInterfaceTest_CanCreate2_Test() {} private:
virtual void TestBody(); static ::testing::TestInfo* const test_info_
__attribute__ ((unused)); OrxonoxInterfaceTest_CanCreate2_Test
(OrxonoxInterfaceTest_CanCreate2_Test const &); void operator
=(OrxonoxInterfaceTest_CanCreate2_Test const &);};::testing
::TestInfo* const OrxonoxInterfaceTest_CanCreate2_Test ::test_info_
= ::testing::internal::MakeAndRegisterTestInfo( "OrxonoxInterfaceTest"
, "CanCreate2", __null, __null, (::testing::internal::GetTypeId
<OrxonoxInterfaceTest>()), OrxonoxInterfaceTest::SetUpTestCase
, OrxonoxInterfaceTest::TearDownTestCase, new ::testing::internal
::TestFactoryImpl< OrxonoxInterfaceTest_CanCreate2_Test>
);void OrxonoxInterfaceTest_CanCreate2_Test::TestBody()
55 {
56 TestClass2* test = new TestClass2();
57 ASSERT_TRUE(test != nullptr)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(test != nullptr)) ; else
return ::testing::internal::AssertHelper(::testing::TestPartResult
::kFatalFailure, "/home/jenkins/workspace/orxonox_qc_trunk_checks/test/core/class/OrxonoxInterfaceTest.cc"
, 57, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "test != nullptr", "false", "true").c_str()) = ::testing::Message
()
;
58 delete test;
59 }
60}