quick
packagestandard libraryThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
Links
Documentation¶
Overview¶
Package quick implements utility functions to help with black box testing.
The testing/quick package is frozen and is not accepting new features.
Index¶
Constants¶
This section is empty.
Variables¶
This section is empty.
Functions¶
funcCheck¶
Check looks for an input to f, any function that returns bool,such that f returns false. It calls f repeatedly, with arbitraryvalues for each argument. If f returns false on a given input,Check returns that input as a *CheckError.For example:
func TestOddMultipleOfThree(t *testing.T) {f := func(x int) bool {y := OddMultipleOfThree(x)return y%2 == 1 && y%3 == 0}if err := quick.Check(f, nil); err != nil {t.Error(err)}}
funcCheckEqual¶
CheckEqual looks for an input on which f and g return different results.It calls f and g repeatedly with arbitrary values for each argument.If f and g return different answers, CheckEqual returns a *CheckEqualErrordescribing the input and the outputs.
Types¶
typeCheckEqualError¶
type CheckEqualError struct {CheckErrorOut1 []anyOut2 []any}
A CheckEqualError is the resultCheckEqual finding an error.
func (*CheckEqualError)Error¶
func (s *CheckEqualError) Error()string
typeCheckError¶
A CheckError is the result of Check finding an error.
func (*CheckError)Error¶
func (s *CheckError) Error()string
typeConfig¶
type Config struct {// MaxCount sets the maximum number of iterations.// If zero, MaxCountScale is used.MaxCountint// MaxCountScale is a non-negative scale factor applied to the// default maximum.// A count of zero implies the default, which is usually 100// but can be set by the -quickchecks flag.MaxCountScalefloat64// Rand specifies a source of random numbers.// If nil, a default pseudo-random source will be used.Rand *rand.Rand// Values specifies a function to generate a slice of// arbitrary reflect.Values that are congruent with the// arguments to the function being tested.// If nil, the top-level Value function is used to generate them.Values func([]reflect.Value, *rand.Rand)}
A Config structure contains options for running a test.
typeGenerator¶
type Generator interface {// Generate returns a random instance of the type on which it is a// method using the size as a size hint.Generate(rand *rand.Rand, sizeint)reflect.Value}
A Generator can generate random values of its own type.
typeSetupError¶
type SetupErrorstring
A SetupError is the result of an error in the way that check is beingused, independent of the functions being tested.
func (SetupError)Error¶
func (sSetupError) Error()string