Fix fuzz comparison of big.Int

This commit is contained in:
Matt Joiner 2021-09-29 12:11:17 +10:00
parent 2daad6e564
commit 03f8ec7090
2 changed files with 9 additions and 1 deletions

View File

@ -3,11 +3,17 @@
package bencode
import (
"math/big"
"testing"
qt "github.com/frankban/quicktest"
"github.com/google/go-cmp/cmp"
)
var bencodeInterfaceChecker = qt.CmpEquals(cmp.Comparer(func(a, b *big.Int) bool {
return a.Cmp(b) == 0
}))
func Fuzz(f *testing.F) {
f.Fuzz(func(t *testing.T, b []byte) {
c := qt.New(t)
@ -21,6 +27,6 @@ func Fuzz(f *testing.F) {
var d0 interface{}
err = Unmarshal(b0, &d0)
c.Assert(err, qt.IsNil)
c.Assert(d0, qt.DeepEquals, d)
c.Assert(d0, bencodeInterfaceChecker, d)
})
}

View File

@ -0,0 +1,2 @@
go test fuzz v1
[]byte("i62208002200000000:00{݃y\u007f m.\x16\t\fZL\x18'\xad\xe7\xc4e")