Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
olabetskyi committed Jan 29, 2024
1 parent a88e251 commit 4d8f380
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions test/testsuppressions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1203,9 +1203,14 @@ class TestSuppressions : public TestFixture {
ASSERT_EQUALS("", settings.nomsg.addSuppressionLine("uninitvar"));
settings.exitCode = 1;

const char code[] = "int f() { int a; return a; }";
ASSERT_EQUALS(0, cppCheck.check("test.c", code)); // <- no unsuppressed error is seen
ASSERT_EQUALS("[test.c:1]: (error) Uninitialized variable: a\n", errout.str()); // <- report error so ThreadExecutor can suppress it and make sure the global suppression is matched.
ScopedFile file("test.cpp",
"int f()\n"
"{\n"
" int a;\n"
" return a;\n"
"}");
ASSERT_EQUALS(0, cppCheck.check(file.path())); // <- no unsuppressed error is seen
ASSERT_EQUALS("[test.cpp:4]: (error) Uninitialized variable: a\n", errout.str()); // <- report error so ThreadExecutor can suppress it and make sure the global suppression is matched.
}

void inlinesuppress_unusedFunction() const { // #4210, #4946 - wrong report of "unmatchedSuppression" for "unusedFunction"
Expand Down Expand Up @@ -1239,15 +1244,15 @@ class TestSuppressions : public TestFixture {
settings.inlineSuppressions = true;
settings.relativePaths = true;
settings.basePaths.emplace_back("/somewhere");
const char code[] =
"struct Point\n"
"{\n"
" // cppcheck-suppress unusedStructMember\n"
" int x;\n"
" // cppcheck-suppress unusedStructMember\n"
" int y;\n"
"};";
ASSERT_EQUALS(0, cppCheck.check("/somewhere/test.cpp", code));
ScopedFile file("test.cpp",
"struct Point\n"
"{\n"
" // cppcheck-suppress unusedStructMember\n"
" int x;\n"
" // cppcheck-suppress unusedStructMember\n"
" int y;\n"
"};");
ASSERT_EQUALS(0, cppCheck.check(file.path()));
ASSERT_EQUALS("",errout.str());
}

Expand Down

0 comments on commit 4d8f380

Please sign in to comment.