Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/suppressions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ SuppressionList::ErrorMessage SuppressionList::ErrorMessage::fromErrorMessage(co
ret.setFileName(msg.callStack.back().getfile(false));
ret.lineNumber = msg.callStack.back().line;
} else {
ret.setFileName(msg.file0);
ret.lineNumber = SuppressionList::Suppression::NO_LINE;
}
ret.certainty = msg.certainty;
Expand Down
37 changes: 37 additions & 0 deletions test/testsuppressions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ class TestSuppressions : public TestFixture {
TEST_CASE(suppressionsParseXmlFile);

TEST_CASE(toString);

TEST_CASE(suppressionFromErrorMessage);
}

void suppressionsBadId1() const {
Expand Down Expand Up @@ -1661,6 +1663,41 @@ class TestSuppressions : public TestFixture {
ASSERT_EQUALS("unitvar:sym", s.toString());
}
}

void suppressionFromErrorMessage() const {
{
const ErrorMessage msg({}, "test1.cpp", Severity::information, "msg", "id", Certainty::inconclusive);
const auto msg_s = SuppressionList::ErrorMessage::fromErrorMessage(msg, {"m1", "m2"});
ASSERT_EQUALS("test1.cpp", msg_s.getFileName());
ASSERT_EQUALS(SuppressionList::Suppression::NO_LINE, msg_s.lineNumber);
ASSERT_EQUALS("id", msg_s.errorId);
ASSERT_EQUALS_ENUM(Certainty::inconclusive, msg_s.certainty);
ASSERT_EQUALS("", msg_s.symbolNames);
ASSERT_EQUALS(2, msg_s.macroNames.size());
auto it = msg_s.macroNames.cbegin();
ASSERT_EQUALS("m1", *it);
++it;
ASSERT_EQUALS("m2", *it);
}
{
std::list<ErrorMessage::FileLocation> loc;
loc.emplace_back("test1.cpp", 1, 1);
const ErrorMessage msg(std::move(loc), "test1.cpp", Severity::information, "msg", "id", Certainty::normal);
const auto msg_s = SuppressionList::ErrorMessage::fromErrorMessage(msg, {});
ASSERT_EQUALS("test1.cpp", msg_s.getFileName());
ASSERT_EQUALS(1, msg_s.lineNumber);
}
{
std::list<ErrorMessage::FileLocation> loc;
loc.emplace_back("test1.cpp", 1, 1);
loc.emplace_back("test2.cpp", 2, 2);
loc.emplace_back("test3.cpp", 3, 3);
const ErrorMessage msg(std::move(loc), "test1.cpp", Severity::information, "msg", "id", Certainty::normal);
const auto msg_s = SuppressionList::ErrorMessage::fromErrorMessage(msg, {});
ASSERT_EQUALS("test3.cpp", msg_s.getFileName());
ASSERT_EQUALS(3, msg_s.lineNumber);
}
}
};

REGISTER_TEST(TestSuppressions)