add test for #3110 (false positve: style) Boolean result is used in bitwise operation. Clarify expression with parentheses)

This commit is contained in:
Robert Reif 2011-09-12 20:46:00 -04:00
parent f3193ef611
commit 302daeb9bd
1 changed files with 17 additions and 0 deletions

View File

@ -120,6 +120,7 @@ private:
TEST_CASE(clarifyCondition1); // if (a = b() < 0) TEST_CASE(clarifyCondition1); // if (a = b() < 0)
TEST_CASE(clarifyCondition2); // if (a & b == c) TEST_CASE(clarifyCondition2); // if (a & b == c)
TEST_CASE(clarifyCondition3); // if (! a & b) TEST_CASE(clarifyCondition3); // if (! a & b)
TEST_CASE(clarifyCondition4); // ticket #3110
TEST_CASE(bitwiseOnBoolean); // if (bool & bool) TEST_CASE(bitwiseOnBoolean); // if (bool & bool)
TEST_CASE(incorrectStringCompare); TEST_CASE(incorrectStringCompare);
@ -2837,6 +2838,22 @@ private:
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
} }
void clarifyCondition4() // ticket #3110
{
check("typedef double SomeType;\n"
"typedef std::pair<std::string,SomeType> PairType;\n"
"struct S\n"
"{\n"
" bool operator()\n"
" ( PairType const & left\n"
" , PairType const & right) const\n"
" {\n"
" return (left.first < right.first);\n"
" }\n"
"}");
ASSERT_EQUALS("", errout.str());
}
void bitwiseOnBoolean() // 3062 void bitwiseOnBoolean() // 3062
{ {
check("void f(_Bool a, _Bool b) {\n" check("void f(_Bool a, _Bool b) {\n"