Move SliceOfNZero to test/generator package
This commit is contained in:
@ -6,6 +6,15 @@ import (
|
||||
"pgregory.net/rapid"
|
||||
)
|
||||
|
||||
// Error returns a new error created by calling [errors.New] with a random string.
|
||||
func Error() *rapid.Generator[error] {
|
||||
return rapid.Map(rapid.String(), errors.New)
|
||||
}
|
||||
|
||||
// SliceOfNZero returns a generator that makes slices of the zero value of T.
|
||||
// The range of slice lengths are determined as in [rapid.SliceOfN].
|
||||
func SliceOfNZero[T any](minLen, maxLen int) *rapid.Generator[[]T] {
|
||||
return rapid.Map(rapid.IntRange(minLen, maxLen), func(n int) []T {
|
||||
return make([]T, n)
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user