pter

package module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2021 License: MIT 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.

README

pter

Go Property Tester base on testing/quick.

usage

$ go get github.com/a3d21/pter

example

goto example_test.go.

func TestAddSpec(t *testing.T) {
	add := func(a, b int) int {
		return a + b
	}

	assertion := func(a, b int) bool {
		return add(a, b) == a+b
	}

	QuickCheck(t, assertion, &Config{
		MaxCount: 10000,
	})
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func QuickCheck

func QuickCheck(t *testing.T, assertion interface{}, c *Config)

Types

type ArgsFn added in v0.0.2

type ArgsFn func() []interface{}

ArgsFn generate test args

func FuzzArgs

func FuzzArgs(fuzzer *fuzz.Fuzzer, assertion interface{}) ArgsFn

FuzzArgs fuzz non-nil args generator for testing/quick

func (ArgsFn) ToQuickValueFn added in v0.0.2

func (f ArgsFn) ToQuickValueFn() func(values []reflect.Value, rand *rand.Rand)

ToQuickValueFn transform to testing/quick value fn

type Config added in v0.0.2

type Config struct {
	// MaxCount sets the maximum test count
	MaxCount int
	// Args generator
	Args ArgsFn
	// Fuzzer generate args, use `defaultFuzzer` when Fuzzer==nil
	Fuzzer *fuzz.Fuzzer
}

Jump to

Keyboard shortcuts

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