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());
|
||||
|
||||
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"
|
||||
"{\n"
|
||||
" int y = 1;\n"
|
||||
|
@ -6975,6 +6989,14 @@ private:
|
|||
"}");
|
||||
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"
|
||||
" unsigned char c;\n"
|
||||
" while( EOF != ( c = getchar() ) )\n"
|
||||
|
|
Loading…
Reference in New Issue