Memory leaks: Added ASSERT_EQUALS near the TODO_ASSERT_EQUALS

This commit is contained in:
Daniel Marjamäki 2010-08-05 13:30:07 +02:00
parent 1b2f16f443
commit e5a2c6426b
1 changed files with 10 additions and 1 deletions

View File

@ -91,6 +91,7 @@ private:
" delete [] p;\n" " delete [] p;\n"
"}\n"); "}\n");
TODO_ASSERT_EQUALS("[test.cpp:8]: (error) Memory leak: p\n", errout.str()); TODO_ASSERT_EQUALS("[test.cpp:8]: (error) Memory leak: p\n", errout.str());
ASSERT_EQUALS("", errout.str());
} }
void test4() void test4()
@ -232,7 +233,8 @@ private:
settings.inconclusive = showAll; settings.inconclusive = showAll;
tokenizer.fillFunctionList(); tokenizer.fillFunctionList();
CheckMemoryLeakInFunction checkMemoryLeak(&tokenizer, &settings, this); CheckMemoryLeakInFunction checkMemoryLeak(&tokenizer, &settings, this);
checkMemoryLeak.runSimplifiedChecks(&tokenizer, &settings, this); checkMemoryLeak.checkReallocUsage();
checkMemoryLeak.check();
} }
@ -1132,6 +1134,7 @@ private:
" delete [] x;\n" " delete [] x;\n"
"}\n", true); "}\n", true);
TODO_ASSERT_EQUALS("[test.cpp:6]: (error) Memory leak: x\n", errout.str()); TODO_ASSERT_EQUALS("[test.cpp:6]: (error) Memory leak: x\n", errout.str());
ASSERT_EQUALS("", errout.str());
} }
@ -1186,6 +1189,7 @@ private:
" return a;\n" " return a;\n"
"}\n"); "}\n");
TODO_ASSERT_EQUALS("[test.cpp:10]: (error) Memory leak: a\n", errout.str()); TODO_ASSERT_EQUALS("[test.cpp:10]: (error) Memory leak: a\n", errout.str());
ASSERT_EQUALS("[test.cpp:8]: (error) Common realloc mistake: \"a\" nulled but not freed upon failure\n", errout.str());
} }
@ -1467,6 +1471,7 @@ private:
" foo(p);\n" " foo(p);\n"
"}\n"); "}\n");
TODO_ASSERT_EQUALS("[test.cpp:11]: (error) Memory leak: p\n", errout.str()); TODO_ASSERT_EQUALS("[test.cpp:11]: (error) Memory leak: p\n", errout.str());
ASSERT_EQUALS("", errout.str());
} }
@ -1816,6 +1821,7 @@ private:
" foo(&p);\n" " foo(&p);\n"
"}\n"); "}\n");
TODO_ASSERT_EQUALS(std::string("[test.cpp:11]: (error) Memory leak: p\n"), errout.str()); TODO_ASSERT_EQUALS(std::string("[test.cpp:11]: (error) Memory leak: p\n"), errout.str());
ASSERT_EQUALS("", errout.str());
check("void foo(char **str)\n" check("void foo(char **str)\n"
"{\n" "{\n"
@ -2000,6 +2006,7 @@ private:
"}\n"); "}\n");
TODO_ASSERT_EQUALS("[test.cpp:5]: (error) Memory leak: a\n", errout.str()); TODO_ASSERT_EQUALS("[test.cpp:5]: (error) Memory leak: a\n", errout.str());
ASSERT_EQUALS("[test.cpp:4]: (error) Common realloc mistake: \"a\" nulled but not freed upon failure\n", errout.str());
} }
void realloc5() void realloc5()
@ -2180,6 +2187,7 @@ private:
" char c = *str;\n" " char c = *str;\n"
"}\n"); "}\n");
TODO_ASSERT_EQUALS("[test.cpp:5]: (error) Dereferencing 'str' after it is deallocated / released\n", errout.str()); TODO_ASSERT_EQUALS("[test.cpp:5]: (error) Dereferencing 'str' after it is deallocated / released\n", errout.str());
ASSERT_EQUALS("", errout.str());
check("void foo()\n" check("void foo()\n"
"{\n" "{\n"
@ -2676,6 +2684,7 @@ private:
" close(handle);\n" " close(handle);\n"
"}\n"); "}\n");
TODO_ASSERT_EQUALS("[test.cpp:11]: (error) Resource leak: handle\n", errout.str()); TODO_ASSERT_EQUALS("[test.cpp:11]: (error) Resource leak: handle\n", errout.str());
ASSERT_EQUALS("", errout.str());
} }
void fd_functions() void fd_functions()