(#8262) Added TODO test for "False positive: memory leak with shared_ptr stored in container" (#1228)

This commit is contained in:
umanamente 2018-05-14 04:08:33 -07:00 committed by Daniel Marjamäki
parent 3d860e6f36
commit d2d1bf900b
1 changed files with 15 additions and 0 deletions

View File

@ -141,6 +141,8 @@ private:
TEST_CASE(testKeywords); // #6767
TEST_CASE(inlineFunction); // #3989
TEST_CASE(smartPtrInContainer); // #8262
}
void check(const char code[], bool cpp = false) {
@ -1520,6 +1522,19 @@ private:
"}");
ASSERT_EQUALS("", errout.str());
}
// #8262
void smartPtrInContainer() {
check( "std::list< std::shared_ptr<int> > mList;\n"
"void test(){\n"
" int *pt = new int(1);\n"
" mList.push_back(std::shared_ptr<int>(pt));\n"
"}\n",
true
);
TODO_ASSERT_EQUALS("", "[test.cpp:5]: (error) Memory leak: pt\n", errout.str());
}
};
REGISTER_TEST(TestLeakAutoVar)