testmemleak: preparing to add checks of function calls

This commit is contained in:
Daniel Marjamäki 2008-10-08 07:01:25 +00:00
parent b2b3e48ebc
commit f01ab43eed
1 changed files with 39 additions and 30 deletions

View File

@ -416,40 +416,49 @@ public:
/* /*
code = "static char *dmalloc()\n" void func3()
"{\n" {
" char *p = new char[100];\n" check( "static char *dmalloc()\n"
" return p;\n" "{\n"
"}\n" " char *p = new char[100];\n"
"static void f()\n" " return p;\n"
"{\n" "}\n"
" char *p = dmalloc();\n" "static void f()\n"
"}\n"; "{\n"
check( CheckMemoryLeak, __LINE__, code, "[test.cpp:9]: Memory leak: p\n" ); " char *p = dmalloc();\n"
"}\n" );
ASSERT_EQUALS( std::string("[test.cpp:9]: Memory leak: p\n"), errout.str() );
}
code = "static char *dmalloc()\n" void func4()
"{\n" {
" char *p = new char[100];\n" check( "static char *dmalloc()\n"
" return p;\n" "{\n"
"}\n" " char *p = new char[100];\n"
"static void f()\n" " return p;\n"
"{\n" "}\n"
" char *p = dmalloc();\n" "static void f()\n"
" delete p;\n" "{\n"
"}\n"; " char *p = dmalloc();\n"
check( CheckMemoryLeak, __LINE__, code, "[test.cpp:9]: Mismatching allocation and deallocation: p\n" ); " delete p;\n"
"}\n" );
ASSERT_EQUALS( std::string("[test.cpp:9]: Mismatching allocation and deallocation: p\n"), errout.str() );
}
code = "static void foo(const char *str)\n" void func5()
"{ }\n" {
"\n" check( "static void foo(const char *str)\n"
"static void f()\n" "{ }\n"
"{\n" "\n"
" char *p = new char[100];\n" "static void f()\n"
" foo(p);\n" "{\n"
"}\n"; " char *p = new char[100];\n"
check( CheckMemoryLeak, __LINE__, code, "[test.cpp:8]: Memory leak: p\n" ); " foo(p);\n"
"}\n" );
ASSERT_EQUALS( std::string("[test.cpp:8]: Memory leak: p\n"), errout.str() );
}
*/ */