MCPcopy
hub / github.com/tidwall/sjson / TestRandomData

Function TestRandomData

sjson_test.go:138–157  ·  view source on GitHub ↗

TestRandomData is a fuzzing test that throws random data at SetRaw function looking for panics.

(t *testing.T)

Source from the content-addressed store, hash-verified

136// TestRandomData is a fuzzing test that throws random data at SetRaw
137// function looking for panics.
138func TestRandomData(t *testing.T) {
139 var lstr string
140 defer func() {
141 if v := recover(); v != nil {
142 println("'" + hex.EncodeToString([]byte(lstr)) + "'")
143 println("'" + lstr + "'")
144 panic(v)
145 }
146 }()
147 rand.Seed(time.Now().UnixNano())
148 b := make([]byte, 200)
149 for i := 0; i < 2000000; i++ {
150 n, err := rand.Read(b[:rand.Int()%len(b)])
151 if err != nil {
152 t.Fatal(err)
153 }
154 lstr = string(b[:n])
155 SetRaw(lstr, "zzzz.zzzz.zzzz", "123")
156 }
157}
158
159func TestDeleteIssue21(t *testing.T) {
160 json := `{"country_code_from":"NZ","country_code_to":"SA","date_created":"2018-09-13T02:56:11.25783Z","date_updated":"2018-09-14T03:15:16.67356Z","disabled":false,"last_edited_by":"Developers","id":"a3e...bc454","merchant_id":"f2b...b91abf","signed_date":"2018-02-01T00:00:00Z","start_date":"2018-03-01T00:00:00Z","url":"https://www.google.com"}`

Callers

nothing calls this directly

Calls 1

SetRawFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…