* Add regression test for #6906 Ticket #6906 was fixed inf65cf220ba
. Add a test to make sure there are no regressions. * Add regression test for #7284 Ticket #7284 was fixed in5d1fdf7958
. Add tests to avoid regressions.
This commit is contained in:
parent
ec8bc785a2
commit
8356ec6774
|
@ -496,6 +496,13 @@ private:
|
|||
" else if (bar() >1 && b) {}\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:5]: (style) Expression is always false because 'else if' condition matches previous condition at line 4.\n", errout.str());
|
||||
|
||||
// 7284
|
||||
check("void foo() {\n"
|
||||
" if (a) {}\n"
|
||||
" else if (!!a) {}\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:3]: (style) Expression is always false because 'else if' condition matches previous condition at line 2.\n", errout.str());
|
||||
}
|
||||
|
||||
void checkPureFunction(const char code[]) {
|
||||
|
|
|
@ -4082,6 +4082,19 @@ private:
|
|||
" return a && b && c;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:3]: (style) Same expression on both sides of '&&' because 'a' and 'c' represent the same value.\n", errout.str());
|
||||
|
||||
// 6906
|
||||
check("void f(const bool b) {\n"
|
||||
" const bool b1 = !b;\n"
|
||||
" if(!b && b1){}\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:3]: (style) Same expression on both sides of '&&' because '!b' and 'b1' represent the same value.\n", errout.str());
|
||||
|
||||
// 7482
|
||||
check("void f(void) {\n"
|
||||
" if (a || !!a) {}\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:2]: (style) Same expression on both sides of '||' because 'a' and '!!a' represent the same value.\n", errout.str());
|
||||
}
|
||||
|
||||
void duplicateExpression8() {
|
||||
|
|
Loading…
Reference in New Issue