Skip to content

Commit 818362f

Browse files
committed
Add TODO test case for a bug in Token::Match multicompare
The result of the %op% operator is wrong in the multicompare case for C++ templates. Detected by comparing the output of the compiled matches with the on-the-fly match parser.
1 parent 9970414 commit 818362f

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

test/testtoken.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class TestToken : public TestFixture {
4545
TEST_CASE(multiCompare);
4646
TEST_CASE(multiCompare2); // #3294 - false negative multi compare between "=" and "=="
4747
TEST_CASE(multiCompare3); // false positive for %or% on code using "|="
48+
TEST_CASE(multiCompare4);
4849
TEST_CASE(getStrLength);
4950
TEST_CASE(strValue);
5051

@@ -201,6 +202,16 @@ class TestToken : public TestFixture {
201202
ASSERT_EQUALS(true, Token::Match(numparen.tokens(), "(| 100 %bool%|%var%| )|"));
202203
}
203204

205+
void multiCompare4() {
206+
givenACodeSampleToTokenize var("std :: queue < int > foo ;");
207+
208+
ASSERT_EQUALS(Token::eBracket, var.tokens()->tokAt(3)->type());
209+
ASSERT_EQUALS(Token::eBracket, var.tokens()->tokAt(5)->type());
210+
211+
ASSERT_EQUALS(false, Token::Match(var.tokens(), "std :: queue %op%"));
212+
TODO_ASSERT_EQUALS(false, true, Token::Match(var.tokens(), "std :: queue x|%op%"));
213+
}
214+
204215
void getStrLength() {
205216
Token tok(0);
206217

0 commit comments

Comments
 (0)