Add two tests for the new memory leak detection
This commit is contained in:
parent
f3b1c46c7d
commit
5dc4fcaa0a
|
@ -5198,6 +5198,8 @@ private:
|
||||||
void run() {
|
void run() {
|
||||||
// pass allocated memory to function..
|
// pass allocated memory to function..
|
||||||
TEST_CASE(functionParameter);
|
TEST_CASE(functionParameter);
|
||||||
|
// never use leakable resource
|
||||||
|
TEST_CASE(missingAssignement);
|
||||||
}
|
}
|
||||||
|
|
||||||
void functionParameter() {
|
void functionParameter() {
|
||||||
|
@ -5235,5 +5237,23 @@ private:
|
||||||
"}\n");
|
"}\n");
|
||||||
TODO_ASSERT_EQUALS("[test.cpp:4]: (error) Allocation with strdup, mkstemp doesn't release it.\n", "", errout.str());
|
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;
|
static TestMemleakNoVar testMemleakNoVar;
|
||||||
|
|
Loading…
Reference in New Issue