Add regression test for previously fixed #6064, and TODO test for #6081

This commit is contained in:
Alexander Mai 2015-11-07 11:17:44 +01:00
parent 49f6231756
commit 2554674f4b
1 changed files with 18 additions and 0 deletions

View File

@ -951,6 +951,24 @@ private:
" if (a>b || a<b) {}\n" " if (a>b || a<b) {}\n"
"}"); "}");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
// #6064 False positive incorrectLogicOperator - invalid assumption about template type?
check("template<typename T> T icdf( const T uniform ) {\n"
" if ((0<uniform) && (uniform<1))\n"
" {}\n"
"}");
ASSERT_EQUALS("", errout.str());
// #6081 False positive: incorrectLogicOperator, with close negative comparisons
check("double neg = -1.0 - 1.0e-13;\n"
"void foo() {\n"
" if ((neg < -1.0) && (neg > -1.0 - 1.0e-12))\n"
" return;\n"
" else\n"
" return;\n"
"}");
TODO_ASSERT_EQUALS("", "[test.cpp:3]: (warning) Logical conjunction always evaluates to false: neg < -1.0 && neg > -1.0.\n", errout.str());
} }
void incorrectLogicOperator8() { // opposite expressions void incorrectLogicOperator8() { // opposite expressions