Bug Summary

File:core/class/OrxonoxClassTest.cc
Location:line 21, column 49
Description:Potential memory leak

Annotated Source Code

1#include <gtest/gtest.h>
2#include "core/class/OrxonoxClass.h"
3#include "core/class/IdentifierManager.h"
4#include "core/object/Context.h"
5
6namespace orxonox
7{
8 namespace
9 {
10 class TestClass : public OrxonoxClass
11 {
12 };
13
14 // Fixture
15 class OrxonoxClassTest : public ::testing::Test
16 {
17 public:
18 virtual void SetUp() override
19 {
20 new IdentifierManager();
1
Memory is allocated
21 Context::setRootContext(new Context(nullptr));
2
Potential memory leak
22 }
23
24 virtual void TearDown() override
25 {
26 Context::destroyRootContext();
27 delete &IdentifierManager::getInstance();
28 }
29 };
30 }
31
32 TEST_F(OrxonoxClassTest, CanCreate)class OrxonoxClassTest_CanCreate_Test : public OrxonoxClassTest
{ public: OrxonoxClassTest_CanCreate_Test() {} private: virtual
void TestBody(); static ::testing::TestInfo* const test_info_
__attribute__ ((unused)); OrxonoxClassTest_CanCreate_Test(OrxonoxClassTest_CanCreate_Test
const &); void operator=(OrxonoxClassTest_CanCreate_Test
const &);};::testing::TestInfo* const OrxonoxClassTest_CanCreate_Test
::test_info_ = ::testing::internal::MakeAndRegisterTestInfo(
"OrxonoxClassTest", "CanCreate", __null, __null, (::testing::
internal::GetTypeId<OrxonoxClassTest>()), OrxonoxClassTest
::SetUpTestCase, OrxonoxClassTest::TearDownTestCase, new ::testing
::internal::TestFactoryImpl< OrxonoxClassTest_CanCreate_Test
>);void OrxonoxClassTest_CanCreate_Test::TestBody()
33 {
34 TestClass* test = new TestClass();
35 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/OrxonoxClassTest.cc"
, 35, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "test != nullptr", "false", "true").c_str()) = ::testing::Message
()
;
36 delete test;
37 }
38}