ticket 1253 added testcases and one todo

This commit is contained in:
Martin Ettl 2010-04-09 23:36:32 +02:00
parent 6dc3860ae9
commit 3388daadc3
1 changed files with 27 additions and 0 deletions

View File

@ -67,6 +67,7 @@ private:
TEST_CASE(localvar4);
TEST_CASE(localvar5);
TEST_CASE(localvar6);
TEST_CASE(localvar7);
TEST_CASE(localvarasm);
// Don't give false positives for variables in structs/unions
@ -331,6 +332,32 @@ private:
ASSERT_EQUALS(std::string(""), errout.str());
}
void localvar7()// ticket 1253
{
functionVariableUsage("void foo()\n"
"{\n"
" int i;\n"
" i--;\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:2]: (style) Unused variable: i\n"), errout.str());
functionVariableUsage("void foo()\n"
"{\n"
" int i;\n"
" int &ii(i);"
" ii--;\n"
"}\n");
TODO_ASSERT_EQUALS(std::string("[test.cpp:2]: (style) Variable 'i' is not assigned a value\n"), errout.str());
functionVariableUsage("void foo()\n"
"{\n"
" int i;\n"
" int &ii=i;"
" ii--;\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:2]: (style) Variable 'i' is not assigned a value\n"), errout.str());
}
void localvarasm()
{
functionVariableUsage("void foo(int &b)\n"