| 176 | } |
| 177 | |
| 178 | void errorWithoutLocation() |
| 179 | { |
| 180 | SarifReport report; |
| 181 | |
| 182 | // Create error without location (empty callStack) |
| 183 | ErrorMessage errorMessage( |
| 184 | {}, "test.cpp", Severity::error, "Error without location", "testError", Certainty::normal); |
| 185 | report.addFinding(errorMessage); |
| 186 | |
| 187 | std::string sarif = report.serialize("Cppcheck"); |
| 188 | picojson::value json; |
| 189 | ASSERT(parseAndValidateJson(sarif, json)); |
| 190 | |
| 191 | const picojson::object& root = json.get<picojson::object>(); |
| 192 | const picojson::array& runs = root.at("runs").get<picojson::array>(); |
| 193 | const picojson::object& cur_run = runs[0].get<picojson::object>(); |
| 194 | |
| 195 | // Should have no results (GitHub doesn't support findings without locations) |
| 196 | const picojson::array& results = cur_run.at("results").get<picojson::array>(); |
| 197 | ASSERT_EQUALS(0U, results.size()); |
| 198 | |
| 199 | const picojson::object& tool = cur_run.at("tool").get<picojson::object>(); |
| 200 | const picojson::object& driver = tool.at("driver").get<picojson::object>(); |
| 201 | const picojson::array& rules = driver.at("rules").get<picojson::array>(); |
| 202 | ASSERT_EQUALS(0U, rules.size()); |
| 203 | } |
| 204 | |
| 205 | void errorWithMultipleLocations() |
| 206 | { |
nothing calls this directly
no test coverage detected