testmemleak: Added 2 tests, fopen() and popen() should return resource leak, instead of memory leak
This commit is contained in:
parent
90bc72a413
commit
a44c21da08
|
@ -104,6 +104,8 @@ private:
|
|||
|
||||
TEST_CASE( ret1 );
|
||||
TEST_CASE( ret2 );
|
||||
TEST_CASE( ret3 );
|
||||
TEST_CASE( ret4 );
|
||||
|
||||
TEST_CASE( mismatch1 );
|
||||
|
||||
|
@ -685,8 +687,25 @@ private:
|
|||
ASSERT_EQUALS( std::string("[test.cpp:6]: Memory leak: abc\n"), errout.str() );
|
||||
}
|
||||
|
||||
void ret3()
|
||||
{
|
||||
check( "void foo()\n"
|
||||
"{\n"
|
||||
" FILE *filep = fopen(\"myfile.txt\",\"w\");\n"
|
||||
"}\n" );
|
||||
|
||||
ASSERT_EQUALS( std::string("[test.cpp:4]: Resource leak: filep\n"), errout.str() );
|
||||
}
|
||||
|
||||
void ret4()
|
||||
{
|
||||
check( "void foo()\n"
|
||||
"{\n"
|
||||
" FILE *p = popen( \"ls -l\", \"r\");\n"
|
||||
"}\n" );
|
||||
|
||||
ASSERT_EQUALS( std::string("[test.cpp:4]: Resource leak: p\n"), errout.str() );
|
||||
}
|
||||
|
||||
void mismatch1()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue