Documentation ¶
Overview ¶
Package gen contains all commonly used generators and shrinkers.
Index ¶
- func AlphaChar() gopter.Gen
- func AlphaLowerChar() gopter.Gen
- func AlphaNumChar() gopter.Gen
- func AlphaString() gopter.Gen
- func AlphaUpperChar() gopter.Gen
- func AnyString() gopter.Gen
- func AnyTime() gopter.Gen
- func ArrayOfN(desiredlen int, elementGen gopter.Gen, typeOverrides ...reflect.Type) gopter.Gen
- func ArrayShrinkerOne(elementShrinker gopter.Shrinker) gopter.Shrinker
- func Bool() gopter.Gen
- func Complex128() gopter.Gen
- func Complex128Box(min, max complex128) gopter.Gen
- func Complex128Shrinker(v interface{}) gopter.Shrink
- func Complex64() gopter.Gen
- func Complex64Box(min, max complex64) gopter.Gen
- func Complex64Shrinker(v interface{}) gopter.Shrink
- func Const(value interface{}) gopter.Gen
- func Fail(resultType reflect.Type) gopter.Gen
- func Float32() gopter.Gen
- func Float32Range(min, max float32) gopter.Gen
- func Float32Shrinker(v interface{}) gopter.Shrink
- func Float64() gopter.Gen
- func Float64Range(min, max float64) gopter.Gen
- func Float64Shrinker(v interface{}) gopter.Shrink
- func Frequency(weightedGens map[int]gopter.Gen) gopter.Gen
- func Identifier() gopter.Gen
- func Int() gopter.Gen
- func Int16() gopter.Gen
- func Int16Range(min, max int16) gopter.Gen
- func Int16Shrinker(v interface{}) gopter.Shrink
- func Int32() gopter.Gen
- func Int32Range(min, max int32) gopter.Gen
- func Int32Shrinker(v interface{}) gopter.Shrink
- func Int64() gopter.Gen
- func Int64Range(min, max int64) gopter.Gen
- func Int64Shrinker(v interface{}) gopter.Shrink
- func Int8() gopter.Gen
- func Int8Range(min, max int8) gopter.Gen
- func Int8Shrinker(v interface{}) gopter.Shrink
- func IntRange(min, max int) gopter.Gen
- func IntShrinker(v interface{}) gopter.Shrink
- func MapOf(keyGen, elementGen gopter.Gen) gopter.Gen
- func MapShrinker(keyShrinker, elementShrinker gopter.Shrinker) gopter.Shrinker
- func MapShrinkerOne(keyShrinker, elementShrinker gopter.Shrinker) gopter.Shrinker
- func NumChar() gopter.Gen
- func NumString() gopter.Gen
- func OneConstOf(consts ...interface{}) gopter.Gen
- func OneGenOf(gens ...gopter.Gen) gopter.Gen
- func PtrOf(elementGen gopter.Gen) gopter.Gen
- func PtrShrinker(elementShrinker gopter.Shrinker) gopter.Shrinker
- func RegexMatch(regexStr string) gopter.Gen
- func RetryUntil(gen gopter.Gen, condition interface{}, maxRetries int) gopter.Gen
- func Rune() gopter.Gen
- func RuneNoControl() gopter.Gen
- func RuneRange(min, max rune) gopter.Gen
- func Size() gopter.Gen
- func Sized(f func(int) gopter.Gen) gopter.Gen
- func SliceOf(elementGen gopter.Gen, typeOverrides ...reflect.Type) gopter.Gen
- func SliceOfN(desiredlen int, elementGen gopter.Gen, typeOverrides ...reflect.Type) gopter.Gen
- func SliceShrinker(elementShrinker gopter.Shrinker) gopter.Shrinker
- func SliceShrinkerOne(elementShrinker gopter.Shrinker) gopter.Shrinker
- func StrictStruct(rt reflect.Type, gens map[string]gopter.Gen, ...) gopter.Gen
- func StrictStructPtr(rt reflect.Type, gens map[string]gopter.Gen, ...) gopter.Gen
- func StringShrinker(v interface{}) gopter.Shrink
- func Struct(rt reflect.Type, gens map[string]gopter.Gen) gopter.Gen
- func StructPtr(rt reflect.Type, gens map[string]gopter.Gen) gopter.Gen
- func Time() gopter.Gen
- func TimeRange(from time.Time, duration time.Duration) gopter.Gen
- func TimeShrinker(v interface{}) gopter.Shrink
- func UInt() gopter.Gen
- func UInt16() gopter.Gen
- func UInt16Range(min, max uint16) gopter.Gen
- func UInt16Shrinker(v interface{}) gopter.Shrink
- func UInt32() gopter.Gen
- func UInt32Range(min, max uint32) gopter.Gen
- func UInt32Shrinker(v interface{}) gopter.Shrink
- func UInt64() gopter.Gen
- func UInt64Range(min, max uint64) gopter.Gen
- func UInt64Shrinker(v interface{}) gopter.Shrink
- func UInt8() gopter.Gen
- func UInt8Range(min, max uint8) gopter.Gen
- func UInt8Shrinker(v interface{}) gopter.Shrink
- func UIntRange(min, max uint) gopter.Gen
- func UIntShrinker(v interface{}) gopter.Shrink
- func UnicodeChar(table *unicode.RangeTable) gopter.Gen
- func UnicodeString(table *unicode.RangeTable) gopter.Gen
- func Weighted(weightedGens []WeightedGen) gopter.Gen
- type WeightedGen
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AlphaLowerChar ¶
AlphaLowerChar generates arbitrary lowercase alpha character runes
func AlphaNumChar ¶
AlphaNumChar generates arbitrary alpha-numeric character runes
func AlphaString ¶
AlphaString generates an arbitrary string with letters
func AlphaUpperChar ¶
AlphaUpperChar generates arbitrary uppercase alpha character runes
func AnyTime ¶
AnyTime generates an arbitrary time.Time struct (might be way out of bounds of any reason)
func ArrayOfN ¶ added in v0.2.10
ArrayOfN generates an array of generated elements with definied length
func ArrayShrinkerOne ¶ added in v0.2.10
ArrayShrinkerOne creates an array shrinker from a shrinker for the elements of the slice. The length of the array will remains unchanged, instead each element is shrunk after the other.
func Complex128Box ¶
func Complex128Box(min, max complex128) gopter.Gen
Complex128Box generate complex128 numbers within a rectangle/box in the complex plane
func Complex128Shrinker ¶
Complex128Shrinker is a shrinker for complex128 numbers
func Complex64Box ¶
Complex64Box generate complex64 numbers within a rectangle/box in the complex plane
func Complex64Shrinker ¶
Complex64Shrinker is a shrinker for complex64 numbers
func Const ¶
Const creates a generator for a constant value Not the most exciting generator, but can be helpful from time to time
func Float32Range ¶
Float32Range generates float32 numbers within a given range
func Float32Shrinker ¶
Float32Shrinker is a shrinker for float32 numbers
func Float64Range ¶
Float64Range generates float64 numbers within a given range
func Float64Shrinker ¶
Float64Shrinker is a shrinker for float64 numbers
func Frequency ¶
Frequency combines multiple weighted generators of the the same result type The generators from weightedGens will be used accrding to the weight, i.e. generators with a hight weight will be used more often than generators with a low weight.
func Identifier ¶
Identifier generates an arbitrary identifier string Identitiers are supporsed to start with a lowercase letter and contain only letters and digits
func Int16Range ¶
Int16Range generates int16 numbers within a given range
func Int16Shrinker ¶
Int16Shrinker is a shrinker for int16 numbers
func Int32Range ¶
Int32Range generates int32 numbers within a given range
func Int32Shrinker ¶
Int32Shrinker is a shrinker for int32 numbers
func Int64Range ¶
Int64Range generates int64 numbers within a given range
func Int64Shrinker ¶
Int64Shrinker is a shrinker for int64 numbers
func Int8Shrinker ¶
Int8Shrinker is a shrinker for int8 numbers
func IntShrinker ¶
IntShrinker is a shrinker for int numbers
func MapOf ¶ added in v0.2.1
MapOf generates an arbitrary map of generated kay values. genParams.MaxSize sets an (exclusive) upper limit on the size of the map genParams.MinSize sets an (inclusive) lower limit on the size of the map
func MapShrinker ¶ added in v0.2.1
MapShrinker creates a map shrinker from shrinker for the key values. The length of the map will be shrunk as well
func MapShrinkerOne ¶ added in v0.2.1
MapShrinkerOne creates a map shrinker from a shrinker for the key values of a map. The length of the map will remain (mostly) unchanged, instead each key value pair is shrunk after the other.
func OneConstOf ¶
OneConstOf generate one of a list of constant values
func PtrShrinker ¶
PtrShrinker convert a value shrinker to a pointer to value shrinker
func RegexMatch ¶
RegexMatch generates matches for a given regular expression regexStr is supposed to conform to the perl regular expression syntax
func RetryUntil ¶
RetryUntil creates a generator that retries a given generator until a condition in met. condition: has to be a function with one parameter (matching the generated value of gen) returning a bool. Note: The new generator will only create an empty result once maxRetries is reached. Depending on the hit-ratio of the condition is may result in long running tests, use with care.
func RuneNoControl ¶
RuneNoControl generates an arbitrary character rune that is not a control character
func Size ¶
Size just extracts the MaxSize field of the GenParameters. This can be helpful to generate limited integer value in a more structued manner.
func Sized ¶ added in v0.2.5
Sized derives a generator from based on size This honors the `MinSize` and `MaxSize` of the `GenParameters` of the test suite. Keep an eye on memory consumption, by default MaxSize is 100.
func SliceOf ¶
SliceOf generates an arbitrary slice of generated elements genParams.MaxSize sets an (exclusive) upper limit on the size of the slice genParams.MinSize sets an (inclusive) lower limit on the size of the slice
func SliceShrinker ¶
SliceShrinker creates a slice shrinker from a shrinker for the elements of the slice. The length of the slice will be shrunk as well
func SliceShrinkerOne ¶
SliceShrinkerOne creates a slice shrinker from a shrinker for the elements of the slice. The length of the slice will remains unchanged, instead each element is shrunk after the other.
func StrictStruct ¶ added in v0.2.10
func StrictStruct( rt reflect.Type, gens map[string]gopter.Gen, allowFieldsWithNoGenerator ...bool, ) gopter.Gen
StrictStruct behaves the same as Struct, except it requires the keys in gens to exactly match the public fields of rt. It panics if gens contains extra keys, or has missing keys.
If given a third true argument, it only requires the keys of gens to be fields of rt. In that case, unspecified fields will remain unset.
func StrictStructPtr ¶ added in v0.2.10
func StrictStructPtr( rt reflect.Type, gens map[string]gopter.Gen, allowFieldsWithNoGenerator ...bool, ) gopter.Gen
StrictStructPtr behaves the same as StructPtr, except it requires the keys in gens to exactly match the public fields of rt. It panics if gens contains extra keys, or has missing keys.
If given a third true argument, it only requires the keys of gens to be fields of rt. In that case, unspecified fields will remain unset.
func StringShrinker ¶
StringShrinker is a shrinker for strings. It is very similar to a slice shrinker just that the elements themselves will not be shrunk.
func Struct ¶
Struct generates a given struct type. rt has to be the reflect type of the struct, gens contains a map of field generators. Note that the result types of the generators in gen have to match the type of the corresponding field in the struct. Also note that only public fields of a struct can be generated
func StructPtr ¶
StructPtr generates pointers to a given struct type. Note that StructPtr does not generate nil, if you want to include nil in your testing you should combine gen.PtrOf with gen.Struct. rt has to be the reflect type of the struct, gens contains a map of field generators. Note that the result types of the generators in gen have to match the type of the corresponding field in the struct. Also note that only public fields of a struct can be generated
func TimeRange ¶
TimeRange generates an arbitrary time.Time with a range from defines the start of the time range duration defines the overall duration of the time range
func TimeShrinker ¶
TimeShrinker is a shrinker for time.Time structs
func UInt16Range ¶
UInt16Range generates uint16 numbers within a given range
func UInt16Shrinker ¶
UInt16Shrinker is a shrinker for uint16 numbers
func UInt32Range ¶
UInt32Range generates uint32 numbers within a given range
func UInt32Shrinker ¶
UInt32Shrinker is a shrinker for uint32 numbers
func UInt64Range ¶
UInt64Range generates uint64 numbers within a given range
func UInt64Shrinker ¶
UInt64Shrinker is a shrinker for uint64 numbers
func UInt8Range ¶
UInt8Range generates uint8 numbers within a given range
func UInt8Shrinker ¶
UInt8Shrinker is a shrinker for uint8 numbers
func UIntShrinker ¶
UIntShrinker is a shrinker for uint numbers
func UnicodeChar ¶
func UnicodeChar(table *unicode.RangeTable) gopter.Gen
UnicodeChar generates arbitrary character runes with a given unicode table
func UnicodeString ¶
func UnicodeString(table *unicode.RangeTable) gopter.Gen
UnicodeString generates an arbitrary string from a given unicode table.
func Weighted ¶
func Weighted(weightedGens []WeightedGen) gopter.Gen
Weighted combines multiple generators, where each generator has a weight. The weight of a generator is proportional to the probability that the generator gets selected.
Types ¶
type WeightedGen ¶
WeightedGen adds a weight number to a generator. To be used as parameter to gen.Weighted
Source Files ¶
- array_of.go
- array_shrink.go
- bool.go
- complex.go
- complex_shrink.go
- const.go
- doc.go
- fail.go
- floats.go
- floats_shrink.go
- frequency.go
- integers.go
- integers_shrink.go
- map_of.go
- map_shrink.go
- one_of.go
- ptr_of.go
- ptr_shrink.go
- regex.go
- retry_until.go
- sized.go
- slice_of.go
- slice_shrink.go
- string_shrink.go
- strings.go
- struct.go
- time.go
- time_shrink.go
- weighted.go