Skip to content

Commit c0ebf70

Browse files
committed
fix windows build issue
1 parent 68cc214 commit c0ebf70

1 file changed

Lines changed: 30 additions & 28 deletions

File tree

test/testsarifreport.cpp

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "fixture.h"
2323
#include "helpers.h"
2424

25+
#include <cmath>
2526
#include <string>
2627
#include <vector>
2728

@@ -61,21 +62,21 @@ class TestSarifReport : public TestFixture
6162

6263
// Helper to create an ErrorMessage
6364
static ErrorMessage createErrorMessage(const std::string& id,
64-
Severity severity,
65-
const std::string& msg,
66-
const std::string& file = "test.cpp",
67-
int line = 10,
68-
int column = 5,
69-
int cweId = 0,
70-
Certainty certainty = Certainty::normal)
65+
Severity severity,
66+
const std::string& msg,
67+
const std::string& file = "test.cpp",
68+
int line = 10,
69+
int column = 5,
70+
int cweId = 0,
71+
Certainty certainty = Certainty::normal)
7172
{
7273
ErrorMessage::FileLocation loc(file, line, column);
73-
ErrorMessage errmsg({loc}, file, severity, msg, id, certainty);
74+
ErrorMessage errorMessage({loc}, file, severity, msg, id, certainty);
7475
if (cweId > 0)
7576
{
76-
errmsg.cwe = CWE(cweId);
77+
errorMessage.cwe = CWE(cweId);
7778
}
78-
return errmsg;
79+
return errorMessage;
7980
}
8081

8182
// Helper to parse JSON and validate structure
@@ -173,8 +174,9 @@ class TestSarifReport : public TestFixture
173174
SarifReport report;
174175

175176
// Create error without location (empty callStack)
176-
ErrorMessage errmsg({}, "test.cpp", Severity::error, "Error without location", "testError", Certainty::normal);
177-
report.addFinding(errmsg);
177+
ErrorMessage errorMessage(
178+
{}, "test.cpp", Severity::error, "Error without location", "testError", Certainty::normal);
179+
report.addFinding(errorMessage);
178180

179181
std::string sarif = report.serialize("Cppcheck");
180182
picojson::value json;
@@ -202,13 +204,13 @@ class TestSarifReport : public TestFixture
202204
ErrorMessage::FileLocation loc2("test2.cpp", 20, 10);
203205
ErrorMessage::FileLocation loc3("test3.cpp", 30, 15);
204206

205-
ErrorMessage errmsg({loc1, loc2, loc3},
206-
"test1.cpp",
207-
Severity::error,
208-
"Error with multiple locations",
209-
"multiLocError",
210-
Certainty::normal);
211-
report.addFinding(errmsg);
207+
ErrorMessage errorMessage({loc1, loc2, loc3},
208+
"test1.cpp",
209+
Severity::error,
210+
"Error with multiple locations",
211+
"multiLocError",
212+
Certainty::normal);
213+
report.addFinding(errorMessage);
212214

213215
std::string sarif = report.serialize("Cppcheck");
214216
picojson::value json;
@@ -390,7 +392,7 @@ class TestSarifReport : public TestFixture
390392
report.addFinding(
391393
createErrorMessage("test1", Severity::error, "Conclusive", "test.cpp", 10, 5, 0, Certainty::normal));
392394
report.addFinding(createErrorMessage(
393-
"test2", Severity::error, "Inconclusive", "test.cpp", 20, 5, 0, Certainty::inconclusive));
395+
"test2", Severity::error, "Inconclusive", "test.cpp", 20, 5, 0, Certainty::inconclusive));
394396

395397
std::string sarif = report.serialize("Cppcheck");
396398
picojson::value json;
@@ -475,11 +477,11 @@ class TestSarifReport : public TestFixture
475477
ErrorMessage::FileLocation loc1("test.cpp", 0, 0);
476478
ErrorMessage::FileLocation loc2("test.cpp", 1, 1);
477479

478-
ErrorMessage errmsg1({loc1}, "test.cpp", Severity::error, "Error at 0,0", "error1", Certainty::normal);
479-
ErrorMessage errmsg2({loc2}, "test.cpp", Severity::error, "Error at 1,1", "error2", Certainty::normal);
480+
ErrorMessage errorMessage1({loc1}, "test.cpp", Severity::error, "Error at 0,0", "error1", Certainty::normal);
481+
ErrorMessage errorMessage2({loc2}, "test.cpp", Severity::error, "Error at 1,1", "error2", Certainty::normal);
480482

481-
report.addFinding(errmsg1);
482-
report.addFinding(errmsg2);
483+
report.addFinding(errorMessage1);
484+
report.addFinding(errorMessage2);
483485

484486
std::string sarif = report.serialize("Cppcheck");
485487
picojson::value json;
@@ -713,14 +715,14 @@ class TestSarifReport : public TestFixture
713715

714716
// Test with 0 values
715717
ErrorMessage::FileLocation loc0("test.cpp", 0, 0);
716-
ErrorMessage errmsg0({loc0}, "test.cpp", Severity::error, "Error at 0", "error0", Certainty::normal);
717-
report.addFinding(errmsg0);
718+
ErrorMessage errorMessage0({loc0}, "test.cpp", Severity::error, "Error at 0", "error0", Certainty::normal);
719+
report.addFinding(errorMessage0);
718720

719721
// Test with positive values
720722
ErrorMessage::FileLocation locPos("test.cpp", 10, 5);
721-
ErrorMessage errmsgPos(
723+
ErrorMessage errorMessagePos(
722724
{locPos}, "test.cpp", Severity::error, "Error at positive", "errorPos", Certainty::normal);
723-
report.addFinding(errmsgPos);
725+
report.addFinding(errorMessagePos);
724726

725727
std::string sarif = report.serialize("Cppcheck");
726728
picojson::value json;

0 commit comments

Comments
 (0)