gopter: github.com/leanovate/gopter/gen Index | Files

package gen

import "github.com/leanovate/gopter/gen"

Package gen contains all commonly used generators and shrinkers.

Index

Package Files

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

func AlphaChar Uses

func AlphaChar() gopter.Gen

AlphaChar generates arbitrary character runes (upper- and lowercase)

func AlphaLowerChar Uses

func AlphaLowerChar() gopter.Gen

AlphaLowerChar generates arbitrary lowercase alpha character runes

func AlphaNumChar Uses

func AlphaNumChar() gopter.Gen

AlphaNumChar generates arbitrary alpha-numeric character runes

func AlphaString Uses

func AlphaString() gopter.Gen

AlphaString generates an arbitrary string with letters

func AlphaUpperChar Uses

func AlphaUpperChar() gopter.Gen

AlphaUpperChar generates arbitrary uppercase alpha character runes

func AnyString Uses

func AnyString() gopter.Gen

AnyString generates an arbitrary string

func AnyTime Uses

func AnyTime() gopter.Gen

AnyTime generates an arbitrary time.Time struct (might be way out of bounds of any reason)

func Bool Uses

func Bool() gopter.Gen

Bool generates an arbitrary bool value

func Complex128 Uses

func Complex128() gopter.Gen

Complex128 generate arbitrary complex128 numbers

func Complex128Box Uses

func Complex128Box(min, max complex128) gopter.Gen

Complex128Box generate complex128 numbers within a rectangle/box in the complex plane

func Complex128Shrinker Uses

func Complex128Shrinker(v interface{}) gopter.Shrink

Complex128Shrinker is a shrinker for complex128 numbers

func Complex64 Uses

func Complex64() gopter.Gen

Complex64 generate arbitrary complex64 numbers

func Complex64Box Uses

func Complex64Box(min, max complex64) gopter.Gen

Complex64Box generate complex64 numbers within a rectangle/box in the complex plane

func Complex64Shrinker Uses

func Complex64Shrinker(v interface{}) gopter.Shrink

Complex64Shrinker is a shrinker for complex64 numbers

func Const Uses

func Const(value interface{}) gopter.Gen

Const creates a generator for a constant value Not the most exciting generator, but can be helpful from time to time

func Fail Uses

func Fail(resultType reflect.Type) gopter.Gen

Fail is a generator that always fails to generate a value Useful as fallback

func Float32 Uses

func Float32() gopter.Gen

Float32 generates arbitrary float32 numbers that do not contain NaN or Inf

func Float32Range Uses

func Float32Range(min, max float32) gopter.Gen

Float32Range generates float32 numbers within a given range

func Float32Shrinker Uses

func Float32Shrinker(v interface{}) gopter.Shrink

Float32Shrinker is a shrinker for float32 numbers

func Float64 Uses

func Float64() gopter.Gen

Float64 generates arbitrary float64 numbers that do not contain NaN or Inf

func Float64Range Uses

func Float64Range(min, max float64) gopter.Gen

Float64Range generates float64 numbers within a given range

func Float64Shrinker Uses

func Float64Shrinker(v interface{}) gopter.Shrink

Float64Shrinker is a shrinker for float64 numbers

func Frequency Uses

func Frequency(weightedGens map[int]gopter.Gen) gopter.Gen

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 Uses

func Identifier() gopter.Gen

Identifier generates an arbitrary identifier string Identitiers are supporsed to start with a lowercase letter and contain only letters and digits

func Int Uses

func Int() gopter.Gen

Int generate arbitrary int numbers

func Int16 Uses

func Int16() gopter.Gen

Int16 generate arbitrary int16 numbers

func Int16Range Uses

func Int16Range(min, max int16) gopter.Gen

Int16Range generates int16 numbers within a given range

func Int16Shrinker Uses

func Int16Shrinker(v interface{}) gopter.Shrink

Int16Shrinker is a shrinker for int16 numbers

func Int32 Uses

func Int32() gopter.Gen

Int32 generate arbitrary int32 numbers

func Int32Range Uses

func Int32Range(min, max int32) gopter.Gen

Int32Range generates int32 numbers within a given range

func Int32Shrinker Uses

func Int32Shrinker(v interface{}) gopter.Shrink

Int32Shrinker is a shrinker for int32 numbers

func Int64 Uses

func Int64() gopter.Gen

Int64 generates an arbitrary int64 number

func Int64Range Uses

func Int64Range(min, max int64) gopter.Gen

Int64Range generates int64 numbers within a given range

func Int64Shrinker Uses

func Int64Shrinker(v interface{}) gopter.Shrink

Int64Shrinker is a shrinker for int64 numbers

func Int8 Uses

func Int8() gopter.Gen

Int8 generate arbitrary int8 numbers

func Int8Range Uses

func Int8Range(min, max int8) gopter.Gen

Int8Range generates int8 numbers within a given range

func Int8Shrinker Uses

func Int8Shrinker(v interface{}) gopter.Shrink

Int8Shrinker is a shrinker for int8 numbers

func IntRange Uses

func IntRange(min, max int) gopter.Gen

IntRange generates int numbers within a given range

func IntShrinker Uses

func IntShrinker(v interface{}) gopter.Shrink

IntShrinker is a shrinker for int numbers

func MapOf Uses

func MapOf(keyGen, elementGen gopter.Gen) gopter.Gen

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 Uses

func MapShrinker(keyShrinker, elementShrinker gopter.Shrinker) gopter.Shrinker

MapShrinker creates a map shrinker from shrinker for the key values. The length of the map will be shrunk as well

func MapShrinkerOne Uses

func MapShrinkerOne(keyShrinker, elementShrinker gopter.Shrinker) gopter.Shrinker

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 NumChar Uses

func NumChar() gopter.Gen

NumChar generates arbitrary numberic character runes

func NumString Uses

func NumString() gopter.Gen

NumString generates an arbitrary string with digits

func OneConstOf Uses

func OneConstOf(consts ...interface{}) gopter.Gen

OneConstOf generate one of a list of constant values

func OneGenOf Uses

func OneGenOf(gens ...gopter.Gen) gopter.Gen

OneGenOf generate one value from a a list of generators

func PtrOf Uses

func PtrOf(elementGen gopter.Gen) gopter.Gen

PtrOf generates either a pointer to a generated element or a nil pointer

func PtrShrinker Uses

func PtrShrinker(elementShrinker gopter.Shrinker) gopter.Shrinker

PtrShrinker convert a value shrinker to a pointer to value shrinker

func RegexMatch Uses

func RegexMatch(regexStr string) gopter.Gen

RegexMatch generates matches for a given regular expression regexStr is supposed to conform to the perl regular expression syntax

func RetryUntil Uses

func RetryUntil(gen gopter.Gen, condition interface{}, maxRetries int) gopter.Gen

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 Rune Uses

func Rune() gopter.Gen

Rune generates an arbitrary character rune

func RuneNoControl Uses

func RuneNoControl() gopter.Gen

RuneNoControl generates an arbitrary character rune that is not a control character

func RuneRange Uses

func RuneRange(min, max rune) gopter.Gen

RuneRange generates runes within a given range

func Size Uses

func Size() gopter.Gen

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 Uses

func Sized(f func(int) gopter.Gen) gopter.Gen

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 Uses

func SliceOf(elementGen gopter.Gen, typeOverrides ...reflect.Type) gopter.Gen

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 SliceOfN Uses

func SliceOfN(desiredlen int, elementGen gopter.Gen, typeOverrides ...reflect.Type) gopter.Gen

SliceOfN generates a slice of generated elements with definied length

func SliceShrinker Uses

func SliceShrinker(elementShrinker gopter.Shrinker) gopter.Shrinker

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 Uses

func SliceShrinkerOne(elementShrinker gopter.Shrinker) gopter.Shrinker

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 StringShrinker Uses

func StringShrinker(v interface{}) gopter.Shrink

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 Uses

func Struct(rt reflect.Type, gens map[string]gopter.Gen) gopter.Gen

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

func StructPtr Uses

func StructPtr(rt reflect.Type, gens map[string]gopter.Gen) gopter.Gen

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

func Time Uses

func Time() gopter.Gen

Time generates an arbitrary time.Time within year [0, 9999]

func TimeRange Uses

func TimeRange(from time.Time, duration time.Duration) gopter.Gen

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 Uses

func TimeShrinker(v interface{}) gopter.Shrink

TimeShrinker is a shrinker for time.Time structs

func UInt Uses

func UInt() gopter.Gen

UInt generate arbitrary uint numbers

func UInt16 Uses

func UInt16() gopter.Gen

UInt16 generate arbitrary uint16 numbers

func UInt16Range Uses

func UInt16Range(min, max uint16) gopter.Gen

UInt16Range generates uint16 numbers within a given range

func UInt16Shrinker Uses

func UInt16Shrinker(v interface{}) gopter.Shrink

UInt16Shrinker is a shrinker for uint16 numbers

func UInt32 Uses

func UInt32() gopter.Gen

UInt32 generate arbitrary int32 numbers

func UInt32Range Uses

func UInt32Range(min, max uint32) gopter.Gen

UInt32Range generates uint32 numbers within a given range

func UInt32Shrinker Uses

func UInt32Shrinker(v interface{}) gopter.Shrink

UInt32Shrinker is a shrinker for uint32 numbers

func UInt64 Uses

func UInt64() gopter.Gen

UInt64 generates an arbitrary Uint64 number

func UInt64Range Uses

func UInt64Range(min, max uint64) gopter.Gen

UInt64Range generates uint64 numbers within a given range

func UInt64Shrinker Uses

func UInt64Shrinker(v interface{}) gopter.Shrink

UInt64Shrinker is a shrinker for uint64 numbers

func UInt8 Uses

func UInt8() gopter.Gen

UInt8 generate arbitrary uint8 numbers

func UInt8Range Uses

func UInt8Range(min, max uint8) gopter.Gen

UInt8Range generates uint8 numbers within a given range

func UInt8Shrinker Uses

func UInt8Shrinker(v interface{}) gopter.Shrink

UInt8Shrinker is a shrinker for uint8 numbers

func UIntRange Uses

func UIntRange(min, max uint) gopter.Gen

UIntRange generates uint numbers within a given range

func UIntShrinker Uses

func UIntShrinker(v interface{}) gopter.Shrink

UIntShrinker is a shrinker for uint numbers

func UnicodeChar Uses

func UnicodeChar(table *unicode.RangeTable) gopter.Gen

UnicodeChar generates arbitrary character runes with a given unicode table

func UnicodeString Uses

func UnicodeString(table *unicode.RangeTable) gopter.Gen

UnicodeString generates an arbitrary string from a given unicode table.

func Weighted Uses

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.

type WeightedGen Uses

type WeightedGen struct {
    Weight int
    Gen    gopter.Gen
}

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 19 packages. Updated 2019-08-06. Refresh now. Tools for package owners.