#8860: Added regression test

This commit is contained in:
orbitcowboy 2021-08-24 14:36:13 +02:00
parent 524db1c756
commit 7d14f461f0
1 changed files with 7 additions and 1 deletions

View File

@ -1093,9 +1093,15 @@ private:
" if((x==3) && (x!=4))\n" " if((x==3) && (x!=4))\n"
" a++;\n" " a++;\n"
"}"); "}");
ASSERT_EQUALS("[test.cpp:2]: (style) Redundant condition: If 'x == 3', the comparison 'x != 4' is always true.\n", errout.str()); ASSERT_EQUALS("[test.cpp:2]: (style) Redundant condition: If 'x == 3', the comparison 'x != 4' is always true.\n", errout.str());
check("void f(const std::string &s) {\n" // #8860
" const std::size_t p = s.find(\"42\");\n"
" const std::size_t * const ptr = &p;\n"
" if(p != std::string::npos && p == 0 && *ptr != 1){;}\n"
"}");
ASSERT_EQUALS("[test.cpp:4] -> [test.cpp:4]: (style) Condition '*ptr!=1' is always true\n", errout.str());
check("void f(int x) {\n" check("void f(int x) {\n"
" if ((x!=4) && (x==3))\n" " if ((x!=4) && (x==3))\n"
" a++;\n" " a++;\n"