first commit
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
"""Tests for analysis parser and metrics."""
|
||||
|
||||
from app.analysis.parser import compare_findings, parse_output
|
||||
|
||||
|
||||
def test_parse_l1_output():
|
||||
output = "- null pointer\n- off by one"
|
||||
findings = parse_output(output, "L1")
|
||||
assert len(findings) == 2
|
||||
assert findings[0].defect_type == "null pointer"
|
||||
|
||||
|
||||
def test_parse_l2_output():
|
||||
output = """- Type: null_pointer
|
||||
Lines: 5-6
|
||||
Explanation: missing guard"""
|
||||
findings = parse_output(output, "L2")
|
||||
assert len(findings) == 1
|
||||
assert findings[0].line_start == 5
|
||||
assert findings[0].line_end == 6
|
||||
|
||||
|
||||
def test_compare_findings():
|
||||
findings = parse_output("- null_pointer", "L1")
|
||||
gt = [{"id": "1", "defect_type": "null_pointer", "line_start": 5, "line_end": 5}]
|
||||
metrics = compare_findings(findings, gt)
|
||||
assert metrics["detection_rate"] == 1.0
|
||||
assert metrics["coverage_rate"] == 1.0
|
||||
Reference in New Issue
Block a user