Files
gf/third/github.com/DataDog/zstd/errors_test.go
John 40b5162fdf up
2019-01-04 15:32:16 +08:00

30 lines
790 B
Go

package zstd
import (
"testing"
)
const (
// ErrorUpperBound is the upper bound to error number, currently only used in test
// If this needs to be updated, check in zstd_errors.h what the max is
ErrorUpperBound = 1000
)
// TestFindIsDstSizeTooSmallError tests that there is at least one error code that
// corresponds to dst size too small
func TestFindIsDstSizeTooSmallError(t *testing.T) {
found := 0
for i := -1; i > -ErrorUpperBound; i-- {
e := ErrorCode(i)
if IsDstSizeTooSmallError(e) {
found++
}
}
if found == 0 {
t.Fatal("Couldn't find an error code for DstSizeTooSmall error, please make sure we didn't change the error string")
} else if found > 1 {
t.Fatal("IsDstSizeTooSmallError found multiple error codes matching, this shouldn't be the case")
}
}