Improve test coverage for functions returning bool values

This commit is contained in:
Dmitry-Me 2019-12-04 18:12:10 +03:00
parent e712df7cb4
commit 571de5844f
1 changed files with 10 additions and 2 deletions

View File

@ -597,13 +597,20 @@ private:
}
void checkComparisonOfFuncReturningBool2() {
check("void f(){\n"
check("void leftOfComparison(){\n"
" int temp = 4;\n"
" bool a = true;\n"
" if(compare(temp) > a){\n"
" printf(\"foo\");\n"
" }\n"
"}\n"
"void rightOfComparison(){\n"
" int temp = 4;\n"
" bool a = true;\n"
" if(a < compare(temp)){\n"
" printf(\"foo\");\n"
" }\n"
"}\n"
"bool compare(int temp){\n"
" if(temp==4){\n"
" return true;\n"
@ -611,7 +618,8 @@ private:
" else\n"
" return false;\n"
"}");
ASSERT_EQUALS("[test.cpp:4]: (style) Comparison of a function returning boolean value using relational (<, >, <= or >=) operator.\n", errout.str());
ASSERT_EQUALS("[test.cpp:4]: (style) Comparison of a function returning boolean value using relational (<, >, <= or >=) operator.\n"
"[test.cpp:11]: (style) Comparison of a function returning boolean value using relational (<, >, <= or >=) operator.\n", errout.str());
}
void checkComparisonOfFuncReturningBool3() {