Skip to content

Commit bac66db

Browse files
committed
add/update tests
1 parent 01b94e7 commit bac66db

File tree

3 files changed

+27
-5
lines changed

3 files changed

+27
-5
lines changed

gui/test/resultstree/testresultstree.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ void TestResultsTree::testReportType() const
157157
QCOMPARE(report.output, "id1,,\nunusedVariable,,");
158158

159159
// switch to Misra C report and check that "id1" is not shown
160-
tree.setReportType(ReportType::misraC);
160+
tree.setReportType(ReportType::misraC2012);
161161
tree.saveResults(&report);
162162
QCOMPARE(report.output, "unusedVariable,Advisory,2.8");
163163

@@ -187,7 +187,7 @@ void TestResultsTree::testGetGuidelineError() const
187187

188188
// normal report with 2 errors
189189
ResultsTree tree(nullptr);
190-
tree.setReportType(ReportType::misraC);
190+
tree.setReportType(ReportType::misraC2012);
191191
tree.addErrorItem(createErrorItem(Severity::error, "id1")); // error severity => guideline 1.3
192192
tree.saveResults(&report);
193193
QCOMPARE(report.output, "id1,Required,1.3");

test/testcmdlineparser.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,7 @@ class TestCmdlineParser : public TestFixture {
502502
TEST_CASE(reportTypeCertC);
503503
TEST_CASE(reportTypeMisraC2012);
504504
TEST_CASE(reportTypeMisraC2023);
505+
TEST_CASE(reportTypeMisraC2025);
505506
TEST_CASE(reportTypeMisraCpp2008);
506507
TEST_CASE(reportTypeMisraCpp2023);
507508
TEST_CASE(invalidReportType);
@@ -3453,14 +3454,21 @@ class TestCmdlineParser : public TestFixture {
34533454
REDIRECT;
34543455
const char *const argv[] = { "cppcheck", "--report-type=misra-c-2012", "file.cpp" };
34553456
ASSERT_EQUALS_ENUM(CmdLineParser::Result::Success, parseFromArgs(argv));
3456-
ASSERT_EQUALS_ENUM(ReportType::misraC, settings->reportType);
3457+
ASSERT_EQUALS_ENUM(ReportType::misraC2012, settings->reportType);
34573458
}
34583459

34593460
void reportTypeMisraC2023() {
34603461
REDIRECT;
34613462
const char *const argv[] = { "cppcheck", "--report-type=misra-c-2023", "file.cpp" };
34623463
ASSERT_EQUALS_ENUM(CmdLineParser::Result::Success, parseFromArgs(argv));
3463-
ASSERT_EQUALS_ENUM(ReportType::misraC, settings->reportType);
3464+
ASSERT_EQUALS_ENUM(ReportType::misraC2023, settings->reportType);
3465+
}
3466+
3467+
void reportTypeMisraC2025() {
3468+
REDIRECT;
3469+
const char *const argv[] = { "cppcheck", "--report-type=misra-c-2025", "file.cpp" };
3470+
ASSERT_EQUALS_ENUM(CmdLineParser::Result::Success, parseFromArgs(argv));
3471+
ASSERT_EQUALS_ENUM(ReportType::misraC2025, settings->reportType);
34643472
}
34653473

34663474
void reportTypeMisraCpp2008() {

test/testerrorlogger.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ class TestErrorLogger : public TestFixture {
7878
TEST_CASE(isCriticalErrorId);
7979

8080
TEST_CASE(ErrorMessageReportTypeMisraC);
81+
TEST_CASE(ErrorMessageReportTypeMisraCDirective);
8182
TEST_CASE(ErrorMessageReportTypeCertC);
8283
}
8384

@@ -317,7 +318,7 @@ class TestErrorLogger : public TestFixture {
317318

318319
void ErrorMessageReportTypeMisraC() const {
319320
std::list<ErrorMessage::FileLocation> locs = { fooCpp5 };
320-
const auto reportType = ReportType::misraC;
321+
const auto reportType = ReportType::misraC2012;
321322
const auto mapping = createGuidelineMapping(reportType);
322323
const std::string format = "{severity} {id}";
323324
ErrorMessage msg(std::move(locs), emptyString, Severity::error, "", "unusedVariable", Certainty::normal);
@@ -328,6 +329,19 @@ class TestErrorLogger : public TestFixture {
328329
ASSERT_EQUALS("Advisory 2.8", msg.toString(true, format, ""));
329330
}
330331

332+
void ErrorMessageReportTypeMisraCDirective() const {
333+
std::list<ErrorMessage::FileLocation> locs = { fooCpp5 };
334+
const auto reportType = ReportType::misraC2012;
335+
const auto mapping = createGuidelineMapping(reportType);
336+
const std::string format = "{severity} {id}";
337+
ErrorMessage msg(std::move(locs), emptyString, Severity::style, "", "premium-misra-c-2012-dir-4.6", Certainty::normal);
338+
msg.guideline = getGuideline(msg.id, reportType, mapping, msg.severity);
339+
msg.classification = getClassification(msg.guideline, reportType);
340+
ASSERT_EQUALS("Advisory", msg.classification);
341+
ASSERT_EQUALS("Dir 4.6", msg.guideline);
342+
ASSERT_EQUALS("Advisory Dir 4.6", msg.toString(true, format, ""));
343+
}
344+
331345
void ErrorMessageReportTypeCertC() const {
332346
std::list<ErrorMessage::FileLocation> locs = { fooCpp5 };
333347
const auto reportType = ReportType::certC;

0 commit comments

Comments
 (0)