Skip to content

Commit 22b068c

Browse files
committed
add helper function for testing xml suppressions
1 parent ab29d0b commit 22b068c

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

test/testsuppressions.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1779,6 +1779,31 @@ class TestSuppressions : public TestFixture {
17791779
}
17801780
}
17811781

1782+
#define testXmlSuppressions(...) testXmlSuppressions_(__FILE__,__LINE__,__VA_ARGS__)
1783+
void testXmlSuppressions_(const char *thisfile,
1784+
int thisline,
1785+
const std::string &xml,
1786+
const std::string &code,
1787+
const std::string expected)
1788+
{
1789+
const char *xmlpath = "testsupressions.xml";
1790+
const char *sourcepath = "test.c";
1791+
1792+
Suppressions supprs;
1793+
const ScopedFile xmlfile(xmlpath, xml);
1794+
ASSERT_EQUALS_LOC("", supprs.nomsg.parseXmlFile(xmlpath), thisfile, thisline);
1795+
1796+
Settings settings;
1797+
settings.templateFormat = templateFormat;
1798+
settings.quiet = true;
1799+
1800+
const FileWithDetails sourcefile(sourcepath, Standards::Language::C, 0);
1801+
CppCheck instance(settings, supprs, *this, nullptr, true, nullptr);
1802+
instance.checkBuffer(sourcefile, code.c_str(), code.size());
1803+
1804+
ASSERT_EQUALS_LOC(expected, errout_str(), thisfile, thisline);
1805+
}
1806+
17821807
void addSuppressionDuplicate() const {
17831808
SuppressionList supprs;
17841809

0 commit comments

Comments
 (0)