Improve test coverage for redundant bitwise operations
This commit is contained in:
parent
95e0b0d0f9
commit
047418dda1
|
@ -2760,6 +2760,20 @@ private:
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("[test.cpp:7]: (warning) Redundant bitwise operation on 'y' in 'switch' statement. 'break;' missing?\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:7]: (warning) Redundant bitwise operation on 'y' in 'switch' statement. 'break;' missing?\n", errout.str());
|
||||||
|
|
||||||
|
check("void foo(int a)\n"
|
||||||
|
"{\n"
|
||||||
|
" int y = 1;\n"
|
||||||
|
" switch (a)\n"
|
||||||
|
" {\n"
|
||||||
|
" case 2:\n"
|
||||||
|
" y = y | 3;\n"
|
||||||
|
" case 3:\n"
|
||||||
|
" y = y | 3;\n"
|
||||||
|
" break;\n"
|
||||||
|
" }\n"
|
||||||
|
"}");
|
||||||
|
ASSERT_EQUALS("[test.cpp:7]: (warning) Redundant bitwise operation on 'y' in 'switch' statement. 'break;' missing?\n", errout.str());
|
||||||
|
|
||||||
check("void foo(int a)\n"
|
check("void foo(int a)\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" int y = 1;\n"
|
" int y = 1;\n"
|
||||||
|
@ -6983,6 +6997,14 @@ private:
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("[test.cpp:3]: (warning) Storing getchar() return value in char variable and then comparing with EOF.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:3]: (warning) Storing getchar() return value in char variable and then comparing with EOF.\n", errout.str());
|
||||||
|
|
||||||
|
check("void f() {\n"
|
||||||
|
" unsigned char c;\n"
|
||||||
|
" while( EOF != ( c = getchar() ) )\n"
|
||||||
|
" {\n"
|
||||||
|
" }\n"
|
||||||
|
"}");
|
||||||
|
ASSERT_EQUALS("[test.cpp:3]: (warning) Storing getchar() return value in char variable and then comparing with EOF.\n", errout.str());
|
||||||
|
|
||||||
check("void f() {\n"
|
check("void f() {\n"
|
||||||
" int i; i = getchar();\n"
|
" int i; i = getchar();\n"
|
||||||
" while( i != EOF)\n"
|
" while( i != EOF)\n"
|
||||||
|
|
Loading…
Reference in New Issue