Check for double nots in isSameExpression
Closed this issue · 0 comments
pfultz2 commented
void sameExpressionDoubleNot() {
check("void f(bool a) { if( a == !(!a) ) {}}");
ASSERT_EQUALS("[test.cpp:1] -> [test.cpp:1]: (style) Same expression on both sides of '=='.\n", errout.str());
check("void f(bool a) { if( a != !(!a) ) {}}");
ASSERT_EQUALS("[test.cpp:1] -> [test.cpp:1]: (style) Same expression on both sides of '!='.\n", errout.str());
check("void f(bool a) { if( !(!a) == a ) {}}");
ASSERT_EQUALS("[test.cpp:1] -> [test.cpp:1]: (style) Same expression on both sides of '!='.\n", errout.str());
}
void oppositeExpressionDoubleNot() {
check("void f(bool a) { if( !(a) == !(!a) ) {}}");
ASSERT_EQUALS("[test.cpp:1] -> [test.cpp:1]: (style) Opposite expression on both sides of '!='.\n", errout.str());
check("void f(bool a) { if( !(a) != !(!a) ) {}}");
ASSERT_EQUALS("[test.cpp:1] -> [test.cpp:1]: (style) Opposite expression on both sides of '!='.\n", errout.str());
check("void f(bool a) { if( !(!a) != a ) {}}");
ASSERT_EQUALS("[test.cpp:1] -> [test.cpp:1]: (style) Opposite expression on both sides of '!='.\n", errout.str());
}