Redundant condition : fixed the checking

This commit is contained in:
Daniel Marjamäki 2008-12-15 18:49:34 +00:00
parent 707a406dab
commit 0d36de4018
2 changed files with 6 additions and 6 deletions

View File

@ -214,9 +214,9 @@ void CheckOther::WarningRedundantCode()
void CheckOther::redundantCondition2()
{
const char pattern[] = "if ( %var% . find ( %any% ) != %var% . end ( ) )"
const char pattern[] = "if ( %var% . find ( %any% ) != %var% . end ( ) ) "
"{|{|"
" %var% . remove ( %any% ) ;"
" %var% . remove ( %any% ) ; "
"}|}|";
const TOKEN *tok = TOKEN::findmatch( _tokenizer->tokens(), pattern );
while ( tok )

View File

@ -54,8 +54,8 @@ private:
void run()
{
// TODO TEST_CASE( remove1 );
// TODO TEST_CASE( remove2 );
TEST_CASE( remove1 );
TEST_CASE( remove2 );
}
void remove1()
@ -65,7 +65,7 @@ private:
" if (haystack.find(needle) != haystack.end())\n"
" haystack.remove(needle);"
"}\n" );
ASSERT_EQUALS( std::string("[test.cpp:3]: Redundant condition.\n"), errout.str() );
ASSERT_EQUALS( std::string("[test.cpp:3]: Redundant condition found. The remove function in the STL will not do anything if element doesn't exist\n"), errout.str() );
}
void remove2()
@ -77,7 +77,7 @@ private:
" haystack.remove(needle);\n"
" }\n"
"}\n" );
ASSERT_EQUALS( std::string("[test.cpp:3]: Redundant condition.\n"), errout.str() );
ASSERT_EQUALS( std::string("[test.cpp:3]: Redundant condition found. The remove function in the STL will not do anything if element doesn't exist\n"), errout.str() );
}
};