TestMemleak: added two testcases for checking for leaks in classes

This commit is contained in:
Daniel Marjamäki 2009-03-13 19:52:01 +01:00
parent 3c4704a00c
commit 0a6a0ae46e
1 changed files with 26 additions and 0 deletions

View File

@ -152,6 +152,8 @@ private:
TEST_CASE(class7); TEST_CASE(class7);
TEST_CASE(class8); TEST_CASE(class8);
TEST_CASE(class9); TEST_CASE(class9);
// TODO TEST_CASE(class10);
// TODO TEST_CASE(class11);
TEST_CASE(throw1); TEST_CASE(throw1);
TEST_CASE(throw2); TEST_CASE(throw2);
@ -1515,6 +1517,30 @@ private:
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
} }
void class10()
{
check("class A\n"
"{\n"
"public:\n"
" int * p;\n"
" A() { p = new int; }\n"
"};\n", true);
ASSERT_EQUALS("memory leak", errout.str());
}
void class11()
{
check("class A\n"
"{\n"
"public:\n"
" int * p;\n"
" A();\n"
"};\n"
"A::A() : p(new int[10])\n"
"{ }", true);
ASSERT_EQUALS("memory leak", errout.str());
}