Unit testing: Added test case for memset. Ticket: #1538

This commit is contained in:
Robert Reif 2010-03-31 19:53:53 +02:00 committed by Daniel Marjamäki
parent ef57d01f7a
commit 78e54e17f2
2 changed files with 13 additions and 15 deletions

View File

@ -1475,21 +1475,6 @@ void CheckClass::thisSubtraction()
}
//---------------------------------------------------------------------------
const Token * findParameter(const Token *var, const Token *start, const Token * end)
{
const Token * param = start->next();
for (; param && param != end; param = param->next())
{
if (param->varId()) // a function parameter
{
// check if the variable and the parameter name are the same
if (var->str() == param->str())
return param;
}
}
return 0;
}
struct NestInfo
{
std::string className;

View File

@ -50,6 +50,7 @@ private:
TEST_CASE(uninitVarEnum);
TEST_CASE(uninitVarStream);
TEST_CASE(uninitVarTypedef);
TEST_CASE(uninitVarMemset);
TEST_CASE(uninitVarArray1);
TEST_CASE(uninitVarArray2);
TEST_CASE(uninitVarArray3);
@ -1357,6 +1358,18 @@ private:
ASSERT_EQUALS("", errout.str());
}
void uninitVarMemset()
{
checkUninitVar("class Foo\n"
"{\n"
"public:\n"
" int * pointer;\n"
" Foo() { memset(this, 0, sizeof(*this)); }\n"
"};\n");
ASSERT_EQUALS("", errout.str());
}
void privateCtor1()
{
checkUninitVar("class Foo {\n"