unit testing: Added TODO test case for unused variables when using pointer aliasing. Related with ticket #1622
This commit is contained in:
parent
2bdcf3b5b2
commit
e6f640d816
|
@ -73,6 +73,7 @@ private:
|
|||
TEST_CASE(localvar8);
|
||||
TEST_CASE(localvar9); // ticket #1605
|
||||
TEST_CASE(localvar10);
|
||||
TEST_CASE(localvaralias);
|
||||
TEST_CASE(localvarasm);
|
||||
|
||||
// Don't give false positives for variables in structs/unions
|
||||
|
@ -640,6 +641,26 @@ private:
|
|||
"[test.cpp:7]: (style) Unused variable: i\n", errout.str());
|
||||
}
|
||||
|
||||
void localvaralias()
|
||||
{
|
||||
functionVariableUsage("void foo()\n"
|
||||
"{\n"
|
||||
" int a;\n"
|
||||
" int *b = &a;\n"
|
||||
" *b = 0;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
|
||||
functionVariableUsage("void foo()\n"
|
||||
"{\n"
|
||||
" int a[10];\n"
|
||||
" int *b = a;\n"
|
||||
" *b = 0;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS(std::string("[test.cpp:3]: (style) Variable 'a' is not assigned a value\n"), errout.str());
|
||||
TODO_ASSERT_EQUALS(std::string(""), errout.str());
|
||||
}
|
||||
|
||||
void localvarasm()
|
||||
{
|
||||
functionVariableUsage("void foo(int &b)\n"
|
||||
|
|
Loading…
Reference in New Issue