github.com/anacrolix/torrent@v1.61.0/webtorrent/fuzz_test.go (about) 1 //go:build go1.18 2 // +build go1.18 3 4 package webtorrent 5 6 import ( 7 "encoding/json" 8 "testing" 9 10 qt "github.com/go-quicktest/qt" 11 ) 12 13 func FuzzJsonBinaryStrings(f *testing.F) { 14 f.Fuzz(func(t *testing.T, in []byte) { 15 jsonBytes, err := json.Marshal(binaryToJsonString(in)) 16 if err != nil { 17 t.Fatal(err) 18 } 19 // t.Logf("%q", jsonBytes) 20 var jsonStr string 21 err = json.Unmarshal(jsonBytes, &jsonStr) 22 if err != nil { 23 t.Fatal(err) 24 } 25 // t.Logf("%q", jsonStr) 26 out, err := decodeJsonByteString(jsonStr, []byte{}) 27 qt.Assert(t, qt.IsNil(err)) 28 qt.Assert(t, qt.DeepEquals(out, in)) 29 }) 30 }