MCPcopy Create free account
hub / github.com/buger/jsonparser / checkDeterminismGate

Function checkDeterminismGate

json_fuzz_test.go:1106–1122  ·  view source on GitHub ↗

checkDeterminismGate (Gate 6: DETERMINISM) asserts that two Get calls on the same input+path return byte-identical (value, type, offset) and the same error PRESENCE. SYS-REQ-086 / SYS-REQ-080 explicitly require this. A non-determinism bug here would surface as flaky callers and is almost always a ma

(t *testing.T, data []byte, path []string)

Source from the content-addressed store, hash-verified

1104// Size-capped to avoid O(n) overhead on huge fuzz inputs (the DoS regression
1105// gate TestDoSPerformance covers scale separately).
1106func checkDeterminismGate(t *testing.T, data []byte, path []string) {
1107 t.Helper()
1108 if len(data) > fuzzGateSizeCap {
1109 return
1110 }
1111 v1, t1, o1, e1 := Get(data, path...)
1112 v2, t2, o2, e2 := Get(data, path...)
1113 if !bytes.Equal(v1, v2) || t1 != t2 || o1 != o2 {
1114 t.Errorf("Get non-deterministic (DETERMINISM violation): "+
1115 "call1=(%q,%v,%d) call2=(%q,%v,%d) data=%q path=%v",
1116 v1, t1, o1, v2, t2, o2, data, path)
1117 }
1118 if (e1 == nil) != (e2 == nil) {
1119 t.Errorf("Get error presence non-deterministic (DETERMINISM violation): "+
1120 "e1=%v e2=%v data=%q path=%v", e1, e2, data, path)
1121 }
1122}
1123
1124// checkSliceAliasingGate (Gate 7: ALIASING) asserts that the value bytes Get
1125// returns appear as a sub-slice of the input data. Per Get's documentation,

Callers 1

runStructureAwareGatesFunction · 0.85

Calls 1

GetFunction · 0.85

Tested by

no test coverage detected