package module
Version: v0.0.0-...-c7fbf7e Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Sep 16, 2014 License: Apache-2.0 Imports: 5 Imported by: 0



Package fuzz provides blackbox testing helpers for the testing/quick package or your own implementation.



This section is empty.


This section is empty.


func BindField

func BindField(name string, gen Generator) option

BindField attaches a generator to a named field.

func QuickGenerator

func QuickGenerator(g Generator) quick.Generator

QuickGenerator type is an adaptor to allow the use of Generator as testing/quick's Generator. It panics if the underlying Generator emits an error.

func QuickValues

func QuickValues(g ...Generator) func([]reflect.Value, *rand.Rand)

The QuickValues type is an adaptor to allow the use of Generator as testing/quick's Config.Values. It panics if an error occurs in the stack.

func UnbindField

func UnbindField(name string) option

UnbindField removes a generator from a named field.

func UseZeroValueFallthrough

func UseZeroValueFallthrough(on bool) option

UseZeroValueFallthrough instructs the session to use the zero-value for all unbound fields; otherwise, a random value is chosen.


type Fuzz

type Fuzz struct {
	// contains filtered or unexported fields

Fuzz describes a context in which a given struct's fields are to be annotated.

func Must

func Must(f *Fuzz, e error) *Fuzz

Must wraps New invocations to ensure that errors are caught at initialization time.

func New

func New(t reflect.Type) (*Fuzz, error)

New generates a new Fuzz session for type t, which must be a struct.

func (*Fuzz) MustOption

func (f *Fuzz) MustOption(opts ...option) option

func (*Fuzz) Option

func (f *Fuzz) Option(opts ...option) (prev option, err error)

Option applies a setting to the Fuzz session, returning an option that may be applied to revert the current operation. If an error occurs while applying the options, the operation short circuits.

func (*Fuzz) Value

func (f *Fuzz) Value(r *rand.Rand, n int) (v reflect.Value, err error)

Value emits a Value for the requested session.

type Generator

type Generator interface {
	// Generate emits a generated value for the provided random r and size hint n.
	Generate(r *rand.Rand, n int) (reflect.Value, error)

Generator creates types per a user-provided policy.

type GeneratorFunc

type GeneratorFunc func(rand *rand.Rand, n int) (reflect.Value, error)

The GeneratorFunc type is an adaptor to allow the use of ordinary functions value generators.

func (GeneratorFunc) Generate

func (g GeneratorFunc) Generate(rand *rand.Rand, size int) (reflect.Value, error)

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL