testmemleak: Added 'func7' test case. Not working yet

This commit is contained in:
Daniel Marjamäki 2008-11-26 07:17:50 +00:00
parent 69ba8ce7f9
commit c95fee7266
1 changed files with 20 additions and 31 deletions

View File

@ -111,6 +111,7 @@ private:
TEST_CASE( func4 ); TEST_CASE( func4 );
TEST_CASE( func5 ); TEST_CASE( func5 );
TEST_CASE( func6 ); TEST_CASE( func6 );
// TODO TEST_CASE( func7 );
TEST_CASE( class1 ); TEST_CASE( class1 );
TEST_CASE( class2 ); TEST_CASE( class2 );
@ -782,6 +783,25 @@ private:
} }
void func7()
{
check( "static void foo(char *str)\n"
"{\n"
" if (abc)\n"
" return;"
" delete [] str;\n"
"}\n"
"\n"
"static void f()\n"
"{\n"
" char *p = new char[100];\n"
" foo(p);\n"
"}\n" );
std::string err( errout.str() );
ASSERT_EQUALS( std::string("[test.cpp:4]: Memory leak: p\n"), err );
}
/* /*
void func3() void func3()
@ -813,37 +833,6 @@ private:
"}\n" ); "}\n" );
ASSERT_EQUALS( std::string("[test.cpp:9]: Mismatching allocation and deallocation: p\n"), errout.str() ); ASSERT_EQUALS( std::string("[test.cpp:9]: Mismatching allocation and deallocation: p\n"), errout.str() );
} }
void func5()
{
check( "static void foo(const char *str)\n"
"{ }\n"
"\n"
"static void f()\n"
"{\n"
" char *p = new char[100];\n"
" foo(p);\n"
"}\n" );
ASSERT_EQUALS( std::string("[test.cpp:8]: Memory leak: p\n"), errout.str() );
}
void func6()
{
check( "struct ab\n"
"{\n"
" int a;\n"
" int b;\n"
"};\n"
"\n"
"static void f()\n"
"{\n"
" struct ab *p = malloc(sizeof(struct ab));\n"
" foo(&p->b);\n"
"}\n" );
ASSERT_EQUALS( std::string("[test.cpp:11]: Memory leak: p\n"), errout.str() );
}
*/ */