You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: test/testother.cpp
+18-2Lines changed: 18 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -175,6 +175,7 @@ class TestOther : public TestFixture {
175
175
TEST_CASE(duplicateExpression14); // #9871
176
176
TEST_CASE(duplicateExpression15); // #10650
177
177
TEST_CASE(duplicateExpression16); // #10569
178
+
TEST_CASE(duplicateExpression17); // #12036
178
179
TEST_CASE(duplicateExpressionLoop);
179
180
TEST_CASE(duplicateValueTernary);
180
181
TEST_CASE(duplicateExpressionTernary); // #6391
@@ -6291,7 +6292,8 @@ class TestOther : public TestFixture {
6291
6292
" enum { Four = 4 };\n"
6292
6293
" if (Four == 4) {}"
6293
6294
"}", nullptr, true, false);
6294
-
ASSERT_EQUALS("", errout.str());
6295
+
ASSERT_EQUALS("[test.cpp:3]: (style) The comparison 'Four == 4' is always true.\n",
6296
+
errout.str());
6295
6297
6296
6298
check("void f() {\n"
6297
6299
" enum { Four = 4 };\n"
@@ -6310,7 +6312,8 @@ class TestOther : public TestFixture {
6310
6312
" enum { FourInEnumTwo = 4 };\n"
6311
6313
" if (FourInEnumOne == FourInEnumTwo) {}\n"
6312
6314
"}", nullptr, true, false);
6313
-
ASSERT_EQUALS("", errout.str());
6315
+
ASSERT_EQUALS("[test.cpp:4]: (style) The comparison 'FourInEnumOne == FourInEnumTwo' is always true because 'FourInEnumOne' and 'FourInEnumTwo' represent the same value.\n",
6316
+
errout.str());
6314
6317
6315
6318
check("void f() {\n"
6316
6319
" enum { FourInEnumOne = 4 };\n"
@@ -6853,6 +6856,19 @@ class TestOther : public TestFixture {
6853
6856
ASSERT_EQUALS("[test.cpp:3]: (style) Same expression '!s[1]' found multiple times in chain of '||' operators.\n", errout.str());
6854
6857
}
6855
6858
6859
+
voidduplicateExpression17() {
6860
+
check("enum { E0 };\n"// #12036
6861
+
"void f() {\n"
6862
+
" if (0 > E0) {}\n"
6863
+
" if (E0 > 0) {}\n"
6864
+
" if (E0 == 0) {}\n"
6865
+
"}\n");
6866
+
ASSERT_EQUALS("[test.cpp:3]: (style) The comparison '0 > E0' is always false.\n"
6867
+
"[test.cpp:4]: (style) The comparison 'E0 > 0' is always false.\n"
6868
+
"[test.cpp:5]: (style) The comparison 'E0 == 0' is always true.\n",
0 commit comments