Suppressions: Handle comment in file that starts with #

This commit is contained in:
Daniel Marjamäki 2019-01-12 15:21:47 +01:00
parent c334d959ce
commit 1cd16cf94f
2 changed files with 15 additions and 0 deletions

View File

@ -74,6 +74,8 @@ std::string Suppressions::parseFile(std::istream &istr)
continue;
// Skip comments
if (line.length() > 1 && line[0] == '#')
continue;
if (line.length() >= 2 && line[0] == '/' && line[1] == '/')
continue;

View File

@ -48,6 +48,7 @@ private:
TEST_CASE(suppressionsMultiFile);
TEST_CASE(suppressionsPathSeparator);
TEST_CASE(suppressionsLine0);
TEST_CASE(suppressionsFileComment);
TEST_CASE(inlinesuppress);
TEST_CASE(inlinesuppress_symbolname);
@ -411,6 +412,18 @@ private:
ASSERT_EQUALS(true, suppressions.isSuppressed(errorMessage("syntaxError", "test.cpp", 0)));
}
void suppressionsFileComment() {
std::istringstream file1("# comment\nabc");
Suppressions suppressions1;
suppressions1.parseFile(file1);
ASSERT_EQUALS(true, suppressions1.isSuppressed(errorMessage("abc", "test.cpp", 123)));
std::istringstream file2("// comment\nabc");
Suppressions suppressions2;
suppressions2.parseFile(file2);
ASSERT_EQUALS(true, suppressions2.isSuppressed(errorMessage("abc", "test.cpp", 123)));
}
void inlinesuppress() {
Suppressions::Suppression s;
std::string msg;