@@ -70,6 +70,9 @@ class TestErrorLogger : public TestFixture {
70
70
TEST_CASE (substituteTemplateLocationStatic);
71
71
72
72
TEST_CASE (isCriticalErrorId);
73
+
74
+ TEST_CASE (ErrorMessageReportTypeMisraC);
75
+ TEST_CASE (ErrorMessageReportTypeCertC);
73
76
}
74
77
75
78
void TestPatternSearchReplace (const std::string& idPlaceholder, const std::string& id) const {
@@ -194,6 +197,32 @@ class TestErrorLogger : public TestFixture {
194
197
}
195
198
}
196
199
200
+ void ErrorMessageReportTypeMisraC () const {
201
+ std::list<ErrorMessage::FileLocation> locs = { fooCpp5 };
202
+ const auto reportType = checkers::ReportType::misraC;
203
+ const auto mapping = checkers::createGuidelineMapping (reportType);
204
+ const std::string format = " {severity} {id}" ;
205
+ ErrorMessage msg (std::move (locs), emptyString, Severity::error, " " , " unusedVariable" , Certainty::normal );
206
+ msg.guideline = checkers::getGuideline (msg.id , reportType, mapping, msg.severity );
207
+ msg.classification = checkers::getClassification (msg.guideline , reportType);
208
+ ASSERT_EQUALS (" Advisory" , msg.classification );
209
+ ASSERT_EQUALS (" 2.8" , msg.guideline );
210
+ ASSERT_EQUALS (" Advisory 2.8" , msg.toString (true , format));
211
+ }
212
+
213
+ void ErrorMessageReportTypeCertC () const {
214
+ std::list<ErrorMessage::FileLocation> locs = { fooCpp5 };
215
+ const auto reportType = checkers::ReportType::certC;
216
+ const auto mapping = checkers::createGuidelineMapping (reportType);
217
+ const std::string format = " {severity} {id}" ;
218
+ ErrorMessage msg (std::move (locs), emptyString, Severity::error, " " , " resourceLeak" , Certainty::normal );
219
+ msg.guideline = checkers::getGuideline (msg.id , reportType, mapping, msg.severity );
220
+ msg.classification = checkers::getClassification (msg.guideline , reportType);
221
+ ASSERT_EQUALS (" L3" , msg.classification );
222
+ ASSERT_EQUALS (" FIO42-C" , msg.guideline );
223
+ ASSERT_EQUALS (" L3 FIO42-C" , msg.toString (true , format));
224
+ }
225
+
197
226
void CustomFormat () const {
198
227
std::list<ErrorMessage::FileLocation> locs (1 , fooCpp5);
199
228
ErrorMessage msg (std::move (locs), emptyString, Severity::error, " Programming error.\n Verbose error" , " errorId" , Certainty::normal );
0 commit comments