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

Function checkParseBooleanGate

json_fuzz_test.go:1211–1228  ·  view source on GitHub ↗

checkParseBooleanGate (Gate 9: PARSEBOOLEAN) cross-checks ParseBoolean against strconv.ParseBool on Boolean-typed values. Closes the API-coverage blind spot: the structure-aware fuzzer cross-checks ParseInt/ParseFloat (via checkNumericOracle) but NEVER reaches ParseBoolean.

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

Source from the content-addressed store, hash-verified

1209// blind spot: the structure-aware fuzzer cross-checks ParseInt/ParseFloat
1210// (via checkNumericOracle) but NEVER reaches ParseBoolean.
1211func checkParseBooleanGate(t *testing.T, data []byte, path []string) {
1212 t.Helper()
1213 val, dt, _, err := Get(data, path...)
1214 if err != nil || dt != Boolean || len(val) == 0 {
1215 return
1216 }
1217 jpVal, jpErr := ParseBoolean(val)
1218 sVal, sErr := strconv.ParseBool(string(val))
1219 if (jpErr == nil) != (sErr == nil) {
1220 t.Errorf("ParseBoolean disagreement on %q (PARSEBOOLEAN differential): "+
1221 "jsonparser=(%v,%v) strconv=(%v,%v) data=%q path=%v",
1222 val, jpVal, jpErr, sVal, sErr, data, path)
1223 } else if jpErr == nil && jpVal != sVal {
1224 t.Errorf("ParseBoolean value mismatch on %q: "+
1225 "jsonparser=%v strconv=%v data=%q path=%v",
1226 val, jpVal, sVal, data, path)
1227 }
1228}
1229
1230// =============================================================================
1231// Gate runner (the assertions that catch each bug class)

Callers 1

runStructureAwareGatesFunction · 0.85

Calls 2

GetFunction · 0.85
ParseBooleanFunction · 0.85

Tested by

no test coverage detected