Documentation ¶
Overview ¶
Package ez provides an easy, powerful way to define tests & benchmarks that are compatible with package `testing`.
Index ¶
- Variables
- func In(xs ...interface{}) *in
- func Out(xs ...interface{}) out
- func Panic() out
- func PanicWith(x interface{}) out
- type Case
- type CaseMap
- type Step
- type Unit
- func (u *Unit) Call(fn interface{}) *Unit
- func (u *Unit) Case(in in, out out) *Unit
- func (u *Unit) Cases(cs CaseMap) *Unit
- func (u *Unit) Do(fn func()) *Unit
- func (u *Unit) Equal(x interface{}, y interface{}) *Unit
- func (u *Unit) Func(fn interface{}) *Unit
- func (u *Unit) In(xs ...interface{}) *half
- func (u *Unit) Run()
- func (u *Unit) RunBenchmark(b *testing.B)
- func (u *Unit) RunTest(t *testing.T)
- func (u *Unit) Step(fn func()) *Unit
- func (u *Unit) Thru(fn func(*Unit)) *Unit
Constants ¶
This section is empty.
Variables ¶
var Any struct{}
Any is a placeholder that can be used with Out and Panic, and it means any value is acceptable.
var Colorize = true
Colorize determines whether to attempt to use terminal colors.
var Diff = gitDiff
Diff is a function that should produce a string representing the difference between two strings. By default it attempts to use the git command to produce an inline diff, which can be colorized.
var Error struct{}
Error is a placeholder that can be used with Out and Panic, and it means any error is acceptable.
var Zero struct{}
Zero is a placeholder that can be used with Out and Panic, and it means only the zero value is acceptable.
Functions ¶
func In ¶
func In(xs ...interface{}) *in
In returns xs as inputs that can be used in a Case or CaseMap.
func Out ¶
func Out(xs ...interface{}) out
Out returns xs as outputs that can be used in a Case or CaseMap.
Types ¶
type Case ¶
type Case struct {
// contains filtered or unexported fields
}
A Case represents a function and its required input and output values.
type Step ¶
type Step struct {
// contains filtered or unexported fields
}
A Step holds arbitrary code to execute during a specific part of a test.
type Unit ¶
A Unit is a specification that can be used for testing and/or benchmarking.
func Seq ¶
func Seq() *Unit
Seq is a synonym for New until Sequential is split out from Parallel test types.
func (*Unit) Call ¶
Call is a synonym for Func until Sequential is split out from Parallel test types.
func (*Unit) Cases ¶
Cases adds every in/out pair in the CaseMap (plus the current function) as a Case to the Unit.
func (*Unit) Run ¶
func (u *Unit) Run()
Run runs the Unit as a test and/or benchmark, depending on whether T and/or B are set.
func (*Unit) RunBenchmark ¶
RunBenchmark runs the Unit as a benchmark using b.