Fix fuzz comparison of big.Int
This commit is contained in:
parent
2daad6e564
commit
03f8ec7090
|
@ -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)
|
||||
})
|
||||
}
|
||||
|
|
2
bencode/testdata/fuzz/Fuzz/65cfcaf31066e15825ace0f8e03701b8729a159063a9ca0884df18a5c9499715
vendored
Normal file
2
bencode/testdata/fuzz/Fuzz/65cfcaf31066e15825ace0f8e03701b8729a159063a9ca0884df18a5c9499715
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
go test fuzz v1
|
||||
[]byte("i62208002200000000:00{݃y\u007f m.\x16\t\fZL\x18'\xad\xe7\xc4e")
|
Loading…
Reference in New Issue