From 754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sun, 7 Apr 2024 13:41:34 -0500 Subject: new repository --- devdocs/go/testing%2Fquick%2Findex.html | 74 +++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 devdocs/go/testing%2Fquick%2Findex.html (limited to 'devdocs/go/testing%2Fquick%2Findex.html') diff --git a/devdocs/go/testing%2Fquick%2Findex.html b/devdocs/go/testing%2Fquick%2Findex.html new file mode 100644 index 00000000..d7c9f316 --- /dev/null +++ b/devdocs/go/testing%2Fquick%2Findex.html @@ -0,0 +1,74 @@ +

Package quick

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

Package files

quick.go

func Check

func Check(f any, config *Config) error

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 CheckEqual

func CheckEqual(f, g 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 Value

func Value(t reflect.Type, rand *rand.Rand) (value reflect.Value, ok bool)

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.

+

type CheckEqualError

A CheckEqualError is the result CheckEqual finding an error.

+
type CheckEqualError struct {
+    CheckError
+    Out1 []any
+    Out2 []any
+}
+

func (*CheckEqualError) Error

func (s *CheckEqualError) Error() string

type CheckError

A CheckError is the result of Check finding an error.

+
type CheckError struct {
+    Count int
+    In    []any
+}
+

func (*CheckError) Error

func (s *CheckError) Error() string

type Config

A Config structure contains options for running a test.

+
type Config struct {
+    // MaxCount sets the maximum number of iterations.
+    // If zero, MaxCountScale is used.
+    MaxCount int
+    // 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.
+    MaxCountScale float64
+    // 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)
+}
+

type Generator

A Generator can generate random values of its own type.

+
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, size int) reflect.Value
+}

type SetupError

A SetupError is the result of an error in the way that check is being used, independent of the functions being tested.

+
type SetupError string

func (SetupError) Error

func (s SetupError) Error() string
+

+ © Google, Inc.
Licensed under the Creative Commons Attribution License 3.0.
+ http://golang.org/pkg/testing/quick/ +

+
-- cgit v1.2.3