Add two tests for the new memory leak detection

This commit is contained in:
Pierre Schweitzer 2012-03-14 23:45:20 +01:00
parent f3b1c46c7d
commit 5dc4fcaa0a
1 changed files with 20 additions and 0 deletions

View File

@ -5198,6 +5198,8 @@ private:
void run() {
// pass allocated memory to function..
TEST_CASE(functionParameter);
// never use leakable resource
TEST_CASE(missingAssignement);
}
void functionParameter() {
@ -5235,5 +5237,23 @@ private:
"}\n");
TODO_ASSERT_EQUALS("[test.cpp:4]: (error) Allocation with strdup, mkstemp doesn't release it.\n", "", errout.str());
}
void missingAssignement() {
check("void x()\n"
"{\n"
" malloc(10);\n"
"}\n");
ASSERT_EQUALS("[test.cpp:2]: (error) Allocation with malloc never assigned.\n", errout.str());
check("void *f()\n"
"{\n"
" return malloc(10);\n"
"}\n"
"void x()\n"
"{\n"
" f();\n"
"}\n");
ASSERT_EQUALS("[test.cpp:6]: (error) Allocation with f never assigned.\n", errout.str());
}
};
static TestMemleakNoVar testMemleakNoVar;