Skip to content

Commit 109ea08

Browse files
committed
Format, add tests
1 parent 11a7c8e commit 109ea08

2 files changed

Lines changed: 30 additions & 12 deletions

File tree

test/testtoken.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ class TestToken : public TestFixture {
6464
TEST_CASE(multiCompare3); // false positive for %or% on code using "|="
6565
TEST_CASE(multiCompare4);
6666
TEST_CASE(multiCompare5);
67+
TEST_CASE(multiCompare6);
6768
TEST_CASE(charTypes);
6869
TEST_CASE(stringTypes);
6970
TEST_CASE(getStrLength);
@@ -322,6 +323,17 @@ class TestToken : public TestFixture {
322323
ASSERT_EQUALS(true, TokenTest::multiCompare(&tok, "+|%or%|%oror%", 0) >= 0);
323324
}
324325

326+
void multiCompare6() const {
327+
{
328+
const SimpleTokenList stl("x %= y;");
329+
ASSERT_EQUALS(true, Token::Match(stl.front(), "%name% %= %name%"));
330+
}
331+
{
332+
const SimpleTokenList stl("x += y;");
333+
ASSERT_EQUALS(false, Token::Match(stl.front(), "%name% %= %name%"));
334+
}
335+
}
336+
325337
void charTypes() const {
326338
auto tokensFrontBack = std::make_shared<TokensFrontBack>();
327339
Token tok(list, std::move(tokensFrontBack));

test/testvalueflow.cpp

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5807,27 +5807,33 @@ class TestValueFlow : public TestFixture {
58075807
ASSERT_EQUALS(false, testValueOfX(code, 3U, 1));
58085808

58095809
code = "int f(int a) {\n"
5810-
" int x = a ^ a;\n"
5811-
" return x;\n"
5812-
"}\n";
5810+
" int x = a ^ a;\n"
5811+
" return x;\n"
5812+
"}\n";
58135813
ASSERT_EQUALS(true, testValueOfX(code, 3U, 0));
58145814

58155815
code = "int f(int a) {\n"
5816-
" int x = a /= a;\n"
5817-
" return x;\n"
5818-
"}\n";
5816+
" int x = a /= a;\n"
5817+
" return x;\n"
5818+
"}\n";
58195819
ASSERT_EQUALS(true, testValueOfX(code, 3U, 1));
58205820

58215821
code = "int f(int a) {\n"
5822-
" int x = a -= a;\n"
5823-
" return x;\n"
5824-
"}\n";
5822+
" int x = a -= a;\n"
5823+
" return x;\n"
5824+
"}\n";
58255825
ASSERT_EQUALS(true, testValueOfX(code, 3U, 0));
58265826

58275827
code = "int f(int a) {\n"
5828-
" int x = a %= a;\n"
5829-
" return x;\n"
5830-
"}\n";
5828+
" int x = a %= a;\n"
5829+
" return x;\n"
5830+
"}\n";
5831+
ASSERT_EQUALS(true, testValueOfX(code, 3U, 0));
5832+
5833+
code = "int f(int a) {\n"
5834+
" int x = a ^= a;\n"
5835+
" return x;\n"
5836+
"}\n";
58315837
ASSERT_EQUALS(true, testValueOfX(code, 3U, 0));
58325838
}
58335839

0 commit comments

Comments
 (0)