oss-fuzz/projects/go-snappy/fuzz.go

28 lines
434 B
Go
Raw Normal View History

2021-03-16 13:33:58 +00:00
// +build gofuzz
package snappy
import (
"bytes"
)
func FuzzRoundTrip(data []byte) int {
encoded := Encode(nil, data)
decoded, err := Decode(nil, encoded)
if err != nil {
panic("Error decoding snappy-encoded")
}
if !bytes.Equal(data, decoded) {
panic("Different result on roundtrip encode/decode")
}
return 1
}
func FuzzDecode(data []byte) int {
_, err := Decode(nil, data)
if err != nil {
return 0
}
return 1
}