From 0d36de4018cb659ccfefeb36397621d2c19e3c3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Mon, 15 Dec 2008 18:49:34 +0000 Subject: [PATCH] Redundant condition : fixed the checking --- checkother.cpp | 4 ++-- testredundantif.cpp | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/checkother.cpp b/checkother.cpp index 1b4e93c37..1d417b06e 100644 --- a/checkother.cpp +++ b/checkother.cpp @@ -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 ) diff --git a/testredundantif.cpp b/testredundantif.cpp index cfe7809bc..83b7e86c8 100644 --- a/testredundantif.cpp +++ b/testredundantif.cpp @@ -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() ); } };