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

Function test_sarif_location_info

test/cli/sarif_test.py:342–369  ·  view source on GitHub ↗

Test that location information is correct.

()

Source from the content-addressed store, hash-verified

340
341
342def test_sarif_location_info():
343 """Test that location information is correct."""
344 sarif = run_sarif_check(BASIC_TEST_CODE)
345
346 run = sarif["runs"][0]
347 results = run["results"]
348
349 for result in results:
350 assert "locations" in result
351 locations = result["locations"]
352 assert len(locations) > 0
353
354 for location in locations:
355 assert "physicalLocation" in location
356 phys_loc = location["physicalLocation"]
357
358 assert "artifactLocation" in phys_loc
359 assert "uri" in phys_loc["artifactLocation"]
360
361 assert "region" in phys_loc
362 region = phys_loc["region"]
363
364 # SARIF requires line and column numbers >= 1
365 assert "startLine" in region
366 assert region["startLine"] >= 1
367
368 assert "startColumn" in region
369 assert region["startColumn"] >= 1
370
371
372def test_sarif_with_multiple_files(tmp_path):

Callers

nothing calls this directly

Calls 1

run_sarif_checkFunction · 0.85

Tested by

no test coverage detected