Skip to content

Commit 483fd51

Browse files
Update testother.cpp
1 parent 6021d98 commit 483fd51

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

test/testother.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9313,6 +9313,24 @@ class TestOther : public TestFixture {
93139313
" for (unsigned p = 0; p < (sizeof(a) / sizeof((a)[0])); ++p) {}\n"
93149314
"}");
93159315
ASSERT_EQUALS("", errout_str());
9316+
9317+
check("void f(const unsigned char u) {\n"
9318+
" if (u > 0) {}\n"
9319+
" if (u < 0) {}\n"
9320+
" if (u >= 0) {}\n"
9321+
" if (u <= 0) {}\n"
9322+
" if (0 < u) {}\n"
9323+
" if (0 > u) {}\n"
9324+
" if (0 <= u) {}\n"
9325+
" if (0 >= u) {}\n"
9326+
"}");
9327+
ASSERT_EQUALS("[test.cpp:3:11]: (style) Checking if unsigned expression 'u' is less than zero. [unsignedLessThanZero]\n"
9328+
"[test.cpp:4:11]: (style) Unsigned expression 'u' can't be negative so it is unnecessary to test it. [unsignedPositive]\n"
9329+
"[test.cpp:5:11]: (style) Checking if unsigned expression 'u' is less than zero. [unsignedLessThanZero]\n"
9330+
"[test.cpp:7:13]: (style) Checking if unsigned expression 'u' is less than zero. [unsignedLessThanZero]\n"
9331+
"[test.cpp:8:13]: (style) Unsigned expression 'u' can't be negative so it is unnecessary to test it. [unsignedPositive]\n"
9332+
"[test.cpp:9:13]: (style) Checking if unsigned expression 'u' is less than zero. [unsignedLessThanZero]\n",
9333+
errout_str());
93169334
}
93179335

93189336
void checkSignOfPointer() {

0 commit comments

Comments
 (0)