Skip to content

Commit df6b0bc

Browse files
committed
#10026: Added a regression test for 'false negative: duplicateExpression'
1 parent ab50a75 commit df6b0bc

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

test/testother.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ class TestOther : public TestFixture {
146146
TEST_CASE(duplicateExpression9); // #9320
147147
TEST_CASE(duplicateExpression10); // #9485
148148
TEST_CASE(duplicateExpression11); // #8916 (function call)
149+
TEST_CASE(duplicateExpression12); // #10026
149150
TEST_CASE(duplicateExpressionLoop);
150151
TEST_CASE(duplicateValueTernary);
151152
TEST_CASE(duplicateExpressionTernary); // #6391
@@ -5240,6 +5241,15 @@ class TestOther : public TestFixture {
52405241
ASSERT_EQUALS("", errout.str());
52415242
}
52425243

5244+
void duplicateExpression12() { //#10026
5245+
check("int f(const std::vector<int> &buffer, const uint8_t index)\n"
5246+
"{\n"
5247+
" int var = buffer[index - 1];\n"
5248+
" return buffer[index - 1] - var;\n" // <<
5249+
"}");
5250+
ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:4]: (style) Same expression on both sides of '-'.\n", errout.str());
5251+
}
5252+
52435253
void duplicateExpressionLoop() {
52445254
check("void f() {\n"
52455255
" int a = 1;\n"

0 commit comments

Comments
 (0)