var defaultMaxCount … type Generator … // randFloat32 generates a random float taking the full range of a float32. func randFloat32(rand *rand.Rand) float32 { … } // randFloat64 generates a random float taking the full range of a float64. func randFloat64(rand *rand.Rand) float64 { … } // randInt64 returns a random int64. func randInt64(rand *rand.Rand) int64 { … } const complexSize … // Value returns an arbitrary value of the given type. // If the type implements the [Generator] interface, that will be used. // Note: To create arbitrary values for structs, all the fields must be exported. func Value(t reflect.Type, rand *rand.Rand) (value reflect.Value, ok bool) { … } // sizedValue returns an arbitrary value of the given type. The size // hint is used for shrinking as a function of indirection level so // that recursive data structures will terminate. func sizedValue(t reflect.Type, rand *rand.Rand, size int) (value reflect.Value, ok bool) { … } type Config … var defaultConfig … // getRand returns the *rand.Rand to use for a given Config. func (c *Config) getRand() *rand.Rand { … } // getMaxCount returns the maximum number of iterations to run for a given // Config. func (c *Config) getMaxCount() (maxCount int) { … } type SetupError … func (s SetupError) Error() string { … } type CheckError … func (s *CheckError) Error() string { … } type CheckEqualError … func (s *CheckEqualError) Error() string { … } // Check looks for an input to f, any function that returns bool, // such that f returns false. It calls f repeatedly, with arbitrary // values 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) // } // } func Check(f any, config *Config) error { … } // 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 *[CheckEqualError] // describing the input and the outputs. func CheckEqual(f, g any, config *Config) error { … } // arbitraryValues writes Values to args such that args contains Values // suitable for calling f. func arbitraryValues(args []reflect.Value, f reflect.Type, config *Config, rand *rand.Rand) (err error) { … } func functionAndType(f any) (v reflect.Value, t reflect.Type, ok bool) { … } func toInterfaces(values []reflect.Value) []any { … } func toString(interfaces []any) string { … }