Skip to content
Open
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
2 changes: 2 additions & 0 deletions lib/suppressions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,8 @@ SuppressionList::Suppression SuppressionList::parseLine(std::string line)
// Strip any end of line comments
std::string::size_type endpos = std::min(line.find('#'), line.find("//"));
if (endpos != std::string::npos) {
const std::string::size_type offset = line[endpos] == '#' ? 1 : 2;
suppression.extraComment = trim(line.substr(endpos + offset));
while (endpos > 0 && std::isspace(line[endpos-1])) {
endpos--;
}
Expand Down
7 changes: 7 additions & 0 deletions test/testsuppressions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1124,38 +1124,45 @@ class TestSuppressions : public TestFixture {
SuppressionList suppressions1;
ASSERT_EQUALS("", suppressions1.parseFile(file1));
ASSERT_EQUALS(true, suppressions1.isSuppressed(errorMessage("abc", "test.cpp", 123)));
ASSERT_EQUALS("", suppressions1.getSuppressions().cbegin()->extraComment);

std::istringstream file2("// comment\n"
"abc");
SuppressionList suppressions2;
ASSERT_EQUALS("", suppressions2.parseFile(file2));
ASSERT_EQUALS(true, suppressions2.isSuppressed(errorMessage("abc", "test.cpp", 123)));
ASSERT_EQUALS("", suppressions2.getSuppressions().cbegin()->extraComment);

std::istringstream file3("abc // comment");
SuppressionList suppressions3;
ASSERT_EQUALS("", suppressions3.parseFile(file3));
ASSERT_EQUALS(true, suppressions3.isSuppressed(errorMessage("abc", "test.cpp", 123)));
ASSERT_EQUALS("comment", suppressions3.getSuppressions().cbegin()->extraComment);

std::istringstream file4("abc\t\t # comment");
SuppressionList suppressions4;
ASSERT_EQUALS("", suppressions4.parseFile(file4));
ASSERT_EQUALS(true, suppressions4.isSuppressed(errorMessage("abc", "test.cpp", 123)));
ASSERT_EQUALS("comment", suppressions4.getSuppressions().cbegin()->extraComment);

std::istringstream file5("abc:test.cpp\t\t # comment");
SuppressionList suppressions5;
ASSERT_EQUALS("", suppressions5.parseFile(file5));
ASSERT_EQUALS(true, suppressions5.isSuppressed(errorMessage("abc", "test.cpp", 123)));
ASSERT_EQUALS("comment", suppressions5.getSuppressions().cbegin()->extraComment);

std::istringstream file6("abc:test.cpp:123\t\t # comment with . inside");
SuppressionList suppressions6;
ASSERT_EQUALS("", suppressions6.parseFile(file6));
ASSERT_EQUALS(true, suppressions6.isSuppressed(errorMessage("abc", "test.cpp", 123)));
ASSERT_EQUALS("comment with . inside", suppressions6.getSuppressions().cbegin()->extraComment);

std::istringstream file7(" // comment\n" // #11450
"abc");
SuppressionList suppressions7;
ASSERT_EQUALS("", suppressions7.parseFile(file7));
ASSERT_EQUALS(true, suppressions7.isSuppressed(errorMessage("abc", "test.cpp", 123)));
ASSERT_EQUALS("", suppressions7.getSuppressions().cbegin()->extraComment);
}

void inlinesuppress() const {
Expand Down
Loading