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

Function truncateForMsg

encoding_json_fuzz_test.go:127–133  ·  view source on GitHub ↗

truncateForMsg renders a byte slice for inclusion in an error message, truncating very large inputs (e.g. the 100 KB deep-nesting seed) so test output remains readable.

(b []byte)

Source from the content-addressed store, hash-verified

125// truncating very large inputs (e.g. the 100 KB deep-nesting seed) so test
126// output remains readable.
127func truncateForMsg(b []byte) string {
128 const max = 200
129 if len(b) <= max {
130 return fmt.Sprintf("%q", b)
131 }
132 return fmt.Sprintf("%q...(truncated, %d bytes total)", b[:max], len(b))
133}
134
135// genDeepNesting returns deeply-nested JSON array bytes. When closed is true
136// the structure is complete ([[[...1...]]]); when false it is left unclosed

Callers 6

encodingJSONNoPanicFunction · 0.85
runValidConsistencyGateFunction · 0.85
runRoundTripGateFunction · 0.85
compareNumberParsingFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected