Improve cid_fuzz.go tests

This commit is contained in:
Jakub Sztandera
2016-11-17 18:27:01 +01:00
parent 8aeb1a44a8
commit 5ec5bbcb48
2 changed files with 19 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
cid-fuzz.zip

View File

@@ -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
} }