Improve cid_fuzz.go tests
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
cid-fuzz.zip
|
||||||
18
cid_fuzz.go
18
cid_fuzz.go
@@ -10,8 +10,26 @@ func Fuzz(data []byte) int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_ = cid.Bytes()
|
_ = cid.Bytes()
|
||||||
|
_ = cid.String()
|
||||||
|
_ = cid.Prefix()
|
||||||
|
|
||||||
if !cid.Equals(cid) {
|
if !cid.Equals(cid) {
|
||||||
panic("inequality")
|
panic("inequality")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// json loop
|
||||||
|
json, err := cid.MarshalJSON()
|
||||||
|
if err != nil {
|
||||||
|
panic(err.Error())
|
||||||
|
}
|
||||||
|
cid2 := &Cid{}
|
||||||
|
err = cid2.UnmarshalJSON(json)
|
||||||
|
if err != nil {
|
||||||
|
panic(err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
if !cid.Equals(cid2) {
|
||||||
|
panic("json loop not equal")
|
||||||
|
}
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user