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

Function oracleRandKey

reference_oracle_test.go:239–252  ·  view source on GitHub ↗

oracleRandKey generates a short object key. Includes "" (empty) to exercise the 8th-panic-site hazard. Bracket-style strings like "[0]" are NOT emitted as object keys: they are syntactically ambiguous with array indices in Delete (which uses `keys[last][0] == '['` as the array-mode signal), producin

(r *mathrand.Rand)

Source from the content-addressed store, hash-verified

237// signal), producing structural corruption. The dedicated
238// TestOracleDeleteBracketKeyAmbiguity test below documents that divergence.
239func oracleRandKey(r *mathrand.Rand) string {
240 switch r.Intn(10) {
241 case 0:
242 return "" // empty key — the 8th-panic-site hazard
243 default:
244 letters := "abcdefghijklmnopqr"
245 n := r.Intn(5) + 1
246 var b strings.Builder
247 for i := 0; i < n; i++ {
248 b.WriteByte(letters[r.Intn(len(letters))])
249 }
250 return b.String()
251 }
252}
253
254// oracleRandomJSONBytes returns marshaled JSON for a random value, plus the
255// Go value itself (so callers can walk the tree to predict sub-values).

Callers 1

oracleRandomJSONValueFunction · 0.85

Calls 1

StringMethod · 0.45

Tested by

no test coverage detected