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

Function genArray

json_fuzz_test.go:220–230  ·  view source on GitHub ↗

genArray emits an array with 0–5 elements (including the empty array []).

(r *rand.Rand, depth int, buf *[]byte)

Source from the content-addressed store, hash-verified

218
219// genArray emits an array with 0–5 elements (including the empty array []).
220func genArray(r *rand.Rand, depth int, buf *[]byte) {
221 *buf = append(*buf, '[')
222 n := r.Intn(6) // 0..5 elements
223 for i := 0; i < n; i++ {
224 if i > 0 {
225 *buf = append(*buf, ',')
226 }
227 genValue(r, depth+1, buf)
228 }
229 *buf = append(*buf, ']')
230}
231
232// genKey emits a JSON object key (a double-quoted string). The key content
233// is drawn from a weighted distribution that includes the cases most likely

Callers 1

genValueFunction · 0.85

Calls 1

genValueFunction · 0.85

Tested by

no test coverage detected