diff --git a/test/testbool.cpp b/test/testbool.cpp index eb4443313..5a23165f1 100644 --- a/test/testbool.cpp +++ b/test/testbool.cpp @@ -64,6 +64,7 @@ private: TEST_CASE(checkComparisonOfFuncReturningBool5); TEST_CASE(checkComparisonOfFuncReturningBool6); TEST_CASE(checkComparisonOfFuncReturningBool7); // #7197 + TEST_CASE(checkComparisonOfFuncReturningBool8); // #4103 // Integration tests.. TEST_CASE(checkComparisonOfFuncReturningBoolIntegrationTest1); // #7798 overloaded functions @@ -729,6 +730,45 @@ private: errout.str()); } + void checkComparisonOfFuncReturningBool8() { // #4103 + // op: > + check("int main(void){\n" + " bool a = true;\n" + " bool b = false;\n" + " if(b > a){ \n" // here warning should be displayed + " ;\n" + " }\n" + "}"); + ASSERT_EQUALS("[test.cpp:4]: (style) Comparison of a variable having boolean value using relational (<, >, <= or >=) operator.\n", errout.str()); + // op: < + check("int main(void){\n" + " bool a = true;\n" + " bool b = false;\n" + " if(b < a){ \n" // here warning should be displayed + " ;\n" + " }\n" + "}"); + ASSERT_EQUALS("[test.cpp:4]: (style) Comparison of a variable having boolean value using relational (<, >, <= or >=) operator.\n", errout.str()); + // op: >= + check("int main(void){\n" + " bool a = true;\n" + " bool b = false;\n" + " if(b >= a){ \n" // here warning should be displayed + " ;\n" + " }\n" + "}"); + ASSERT_EQUALS("[test.cpp:4]: (style) Comparison of a variable having boolean value using relational (<, >, <= or >=) operator.\n", errout.str()); + // op: <= + check("int main(void){\n" + " bool a = true;\n" + " bool b = false;\n" + " if(b <= a){ \n" // here warning should be displayed + " ;\n" + " }\n" + "}"); + ASSERT_EQUALS("[test.cpp:4]: (style) Comparison of a variable having boolean value using relational (<, >, <= or >=) operator.\n", errout.str()); + } + void checkComparisonOfFuncReturningBoolIntegrationTest1() { // #7798 check("bool eval(double *) { return false; }\n" "double eval(char *) { return 1.0; }\n"