MCPcopy
hub / github.com/buger/jsonparser / TestFuzzEachKeyHarnessCoverage

Function TestFuzzEachKeyHarnessCoverage

coverage_closure_test.go:18–47  ·  view source on GitHub ↗

============================================================================= Coverage closure tests for fuzz harness functions ============================================================================= The proof coverage tool maps requirement annotations in fuzz.go to coverage data. Fuzz functi

(t *testing.T)

Source from the content-addressed store, hash-verified

16// Verifies: SYS-REQ-008 [fuzz]
17// MCDC SYS-REQ-008: N/A
18func TestFuzzEachKeyHarnessCoverage(t *testing.T) {
19 // FuzzEachKey exercises EachKey with 12 hard-coded paths against
20 // arbitrary data. The function always returns 1 regardless of whether
21 // paths are found. Exercise it with data that matches some paths and
22 // data that matches none.
23
24 // Case 1: well-formed JSON matching several of the hard-coded paths
25 data := []byte(`{
26 "name": "test",
27 "order": 1,
28 "nested": {"a": 1, "b": 2, "nested3": {"b": 3}},
29 "nested2": {"a": 4},
30 "arr": [{"b": 5}, {"b": 6}],
31 "arrInt": [0, 1, 2, 3, 4, 5]
32 }`)
33 if got := FuzzEachKey(data); got != 1 {
34 t.Fatalf("FuzzEachKey with matching paths = %d, want 1", got)
35 }
36
37 // Case 2: empty JSON object, no paths match
38 if got := FuzzEachKey([]byte(`{}`)); got != 1 {
39 t.Fatalf("FuzzEachKey with empty object = %d, want 1", got)
40 }
41
42 // Case 3: malformed JSON -- EachKey returns -1 internally but the
43 // fuzz harness still returns 1 (it ignores the return value)
44 if got := FuzzEachKey([]byte(`{`)); got != 1 {
45 t.Fatalf("FuzzEachKey with malformed JSON = %d, want 1", got)
46 }
47}
48
49// Verifies: SYS-REQ-010 [fuzz]
50// MCDC SYS-REQ-010: delete_path_is_provided=T, delete_returns_empty_document_without_path=F => TRUE

Callers

nothing calls this directly

Calls 1

FuzzEachKeyFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…