import "github.com/leanovate/gopter/gen"
Package gen contains all commonly used generators and shrinkers.
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
AlphaChar generates arbitrary character runes (upper- and lowercase)
AlphaLowerChar generates arbitrary lowercase alpha character runes
AlphaNumChar generates arbitrary alpha-numeric character runes
AlphaString generates an arbitrary string with letters
AlphaUpperChar generates arbitrary uppercase alpha character runes
AnyString generates an arbitrary string
AnyTime generates an arbitrary time.Time struct (might be way out of bounds of any reason)
Bool generates an arbitrary bool value
Complex128 generate arbitrary complex128 numbers
func Complex128Box(min, max complex128) gopter.Gen
Complex128Box generate complex128 numbers within a rectangle/box in the complex plane
Complex128Shrinker is a shrinker for complex128 numbers
Complex64 generate arbitrary complex64 numbers
Complex64Box generate complex64 numbers within a rectangle/box in the complex plane
Complex64Shrinker is a shrinker for complex64 numbers
Const creates a generator for a constant value Not the most exciting generator, but can be helpful from time to time
Fail is a generator that always fails to generate a value Useful as fallback
Float32 generates arbitrary float32 numbers that do not contain NaN or Inf
Float32Range generates float32 numbers within a given range
Float32Shrinker is a shrinker for float32 numbers
Float64 generates arbitrary float64 numbers that do not contain NaN or Inf
Float64Range generates float64 numbers within a given range
Float64Shrinker is a shrinker for float64 numbers
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.
Identifier generates an arbitrary identifier string Identitiers are supporsed to start with a lowercase letter and contain only letters and digits
Int generate arbitrary int numbers
Int16 generate arbitrary int16 numbers
Int16Range generates int16 numbers within a given range
Int16Shrinker is a shrinker for int16 numbers
Int32 generate arbitrary int32 numbers
Int32Range generates int32 numbers within a given range
Int32Shrinker is a shrinker for int32 numbers
Int64 generates an arbitrary int64 number
Int64Range generates int64 numbers within a given range
Int64Shrinker is a shrinker for int64 numbers
Int8 generate arbitrary int8 numbers
Int8Range generates int8 numbers within a given range
Int8Shrinker is a shrinker for int8 numbers
IntRange generates int numbers within a given range
IntShrinker is a shrinker for int numbers
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
MapShrinker creates a map shrinker from shrinker for the key values. The length of the map will be shrunk as well
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.
NumChar generates arbitrary numberic character runes
NumString generates an arbitrary string with digits
OneConstOf generate one of a list of constant values
OneGenOf generate one value from a a list of generators
PtrOf generates either a pointer to a generated element or a nil pointer
PtrShrinker convert a value shrinker to a pointer to value shrinker
RegexMatch generates matches for a given regular expression regexStr is supposed to conform to the perl regular expression syntax
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.
Rune generates an arbitrary character rune
RuneNoControl generates an arbitrary character rune that is not a control character
RuneRange generates runes within a given range
Size just extracts the MaxSize field of the GenParameters. This can be helpful to generate limited integer value in a more structued manner.
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.
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
SliceOfN generates a slice of generated elements with definied length
SliceShrinker creates a slice shrinker from a shrinker for the elements of the slice. The length of the slice will be shrunk as well
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.
StringShrinker is a shrinker for strings. It is very similar to a slice shrinker just that the elements themselves will not be shrunk.
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 correspoinding field in the struct. Also note that only public fields of a struct can be generated
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 correspoinding field in the struct. Also note that only public fields of a struct can be generated
Time generates an arbitrary time.Time within year [0, 9999]
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
TimeShrinker is a shrinker for time.Time structs
UInt generate arbitrary uint numbers
UInt16 generate arbitrary uint16 numbers
UInt16Range generates uint16 numbers within a given range
UInt16Shrinker is a shrinker for uint16 numbers
UInt32 generate arbitrary int32 numbers
UInt32Range generates uint32 numbers within a given range
UInt32Shrinker is a shrinker for uint32 numbers
UInt64 generates an arbitrary Uint64 number
UInt64Range generates uint64 numbers within a given range
UInt64Shrinker is a shrinker for uint64 numbers
UInt8 generate arbitrary uint8 numbers
UInt8Range generates uint8 numbers within a given range
UInt8Shrinker is a shrinker for uint8 numbers
UIntRange generates uint numbers within a given range
UIntShrinker is a shrinker for uint numbers
func UnicodeChar(table *unicode.RangeTable) gopter.Gen
UnicodeChar generates arbitrary character runes with a given unicode table
func UnicodeString(table *unicode.RangeTable) gopter.Gen
UnicodeString generates an arbitrary string from a given unicode table.
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.
WeightedGen adds a weight number to a generator. To be used as parameter to gen.Weighted
Package gen imports 11 packages (graph) and is imported by 20 packages. Updated 2020-11-09. Refresh now. Tools for package owners.