MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / inlinesuppress

Method inlinesuppress

test/testsuppressions.cpp:1160–1213  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1158 }
1159
1160 void inlinesuppress() const {
1161 SuppressionList::Suppression s;
1162 std::string msg;
1163
1164 // Suppress without attribute
1165 ASSERT_EQUALS(false, s.parseComment("/* some text */", &msg));
1166 ASSERT_EQUALS(false, s.parseComment("/* cppcheck-suppress */", &msg));
1167 ASSERT_EQUALS(false, s.parseComment("/* cppcheck-suppress-file */", &msg));
1168 ASSERT_EQUALS(false, s.parseComment("/* cppcheck-suppress-begin */", &msg));
1169 ASSERT_EQUALS(false, s.parseComment("/* cppcheck-suppress-end */", &msg));
1170
1171 // Correct suppress
1172 msg.clear();
1173 ASSERT_EQUALS(true, s.parseComment("/* cppcheck-suppress id */", &msg));
1174 ASSERT_EQUALS("", msg);
1175 ASSERT_EQUALS("", s.extraComment);
1176
1177 msg.clear();
1178 ASSERT_EQUALS(true, s.parseComment("/* cppcheck-suppress id ; extra */", &msg));
1179 ASSERT_EQUALS("", msg);
1180 ASSERT_EQUALS("extra", s.extraComment);
1181
1182 msg.clear();
1183 ASSERT_EQUALS(true, s.parseComment("/* cppcheck-suppress id // extra */", &msg));
1184 ASSERT_EQUALS("", msg);
1185 ASSERT_EQUALS("extra", s.extraComment);
1186
1187 msg.clear();
1188 ASSERT_EQUALS(true, s.parseComment("/* cppcheck-suppress-file id */", &msg));
1189 ASSERT_EQUALS("", msg);
1190
1191 msg.clear();
1192 ASSERT_EQUALS(true, s.parseComment("/* cppcheck-suppress-begin id */", &msg));
1193 ASSERT_EQUALS("", msg);
1194
1195 msg.clear();
1196 ASSERT_EQUALS(true, s.parseComment("/* cppcheck-suppress-end id */", &msg));
1197 ASSERT_EQUALS("", msg);
1198
1199 // Bad cppcheck-suppress comment
1200 ASSERT_EQUALS(false, s.parseComment("/* cppcheck-suppress-beggin id */", &msg));
1201
1202 // Bad attribute construction
1203 const std::string badSuppressionAttribute = "Bad suppression attribute 'some'. You can write comments in the comment after a ; or //. Valid suppression attributes; symbolName=sym";
1204
1205 ASSERT_EQUALS(true, s.parseComment("/* cppcheck-suppress id some text */", &msg));
1206 ASSERT_EQUALS(badSuppressionAttribute, msg);
1207 ASSERT_EQUALS(true, s.parseComment("/* cppcheck-suppress-file id some text */", &msg));
1208 ASSERT_EQUALS(badSuppressionAttribute, msg);
1209 ASSERT_EQUALS(true, s.parseComment("/* cppcheck-suppress-begin id some text */", &msg));
1210 ASSERT_EQUALS(badSuppressionAttribute, msg);
1211 ASSERT_EQUALS(true, s.parseComment("/* cppcheck-suppress-end id some text */", &msg));
1212 ASSERT_EQUALS(badSuppressionAttribute, msg);
1213 }
1214
1215 void inlinesuppress_symbolname_Internal(unsigned int (TestSuppressions::*check)(const char[], const std::string &)) {
1216 ASSERT_EQUALS(0, (this->*check)("void f() {\n"

Callers

nothing calls this directly

Calls 2

parseCommentMethod · 0.80
clearMethod · 0.45

Tested by

no test coverage detected