fuzz

package module
v0.0.0-...-c7fbf7e Latest Latest
Warning

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: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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.

Types

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)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL