Documentation ¶
Index ¶
- Constants
- func AllowAllUnexported(i interface{}) cmp.Option
- func ApproxTime(d time.Duration) func(interface{}) cmp.Option
- func BoolP(b bool) *bool
- func CaptureLog() *capture
- func CaptureStdErr() *capture
- func CaptureStdOut() *capture
- func CmpFuncs(x, y interface{}) (b bool, s string)
- func Contains(x, y interface{}) (bool, string)
- func Equal(actual, expected interface{}) (bool, string)
- func EqualOpt(optFns ...func(i interface{}) cmp.Option) func(actual, expected interface{}) (bool, string)
- func EquateEmpty(i interface{}) cmp.Option
- func ErrType(err error) error
- func Float32P(f float32) *float32
- func Float64P(f float64) *float64
- func IgnoreAllUnexported(i interface{}) cmp.Option
- func IgnoreFields(f ...string) func(interface{}) cmp.Option
- func IgnoreTypes(types ...interface{}) func(interface{}) cmp.Option
- func Int16P(i int16) *int16
- func Int32P(i int32) *int32
- func Int64P(i int64) *int64
- func Int8P(i int8) *int8
- func IntP(i int) *int
- func StringP(s string) *string
- func Time(layout, value string) time.Time
- func TimeDay(value string) time.Time
- func TimeHour(value string) time.Time
- func TimeP(layout, value string) *time.Time
- func Times(layout string, values ...string) []time.Time
- func Uint16P(i uint16) *uint16
- func Uint32P(i uint32) *uint32
- func Uint64P(i uint64) *uint64
- func Uint8P(i uint8) *uint8
- func UintP(i uint) *uint
- type Case
- type Cases
- type CompareFunc
- type Comparer
- type Input
- type TestFunc
- type Trial
Constants ¶
const ( SubStrings = iota SubSlices SubMaps )
Variables ¶
This section is empty.
Functions ¶
func AllowAllUnexported ¶ added in v0.6.0
AllowAllUnexported sets cmp.Diff to allow all unexported (private) variables
func ApproxTime ¶ added in v0.6.0
ApproxTime is a wrapper around the cmpopts.EquateApproxTime it will consider time.Time values equal if there difference is less than the defined duration
func CaptureLog ¶ added in v0.4.0
func CaptureLog() *capture
CaptureLog overrides the log output for reading
func CaptureStdErr ¶ added in v0.4.0
func CaptureStdErr() *capture
CaptureStdErr redirects stderr for reading note this does not redirect log output
func CaptureStdOut ¶ added in v0.4.0
func CaptureStdOut() *capture
CaptureStdOut redirects stdout for reading
func Contains ¶ added in v0.4.0
Contains determines if y is a subset of x. x is a string -> y is a string that is equal to or a subset of x (string.Contains) x is a slice or array -> y is contained in x x is a map -> y is a map and is contained in x
func Equal ¶
Equal use the cmp.Diff method to check equality and display differences. This method checks all unexpected values
func EqualOpt ¶ added in v0.6.0
func EqualOpt(optFns ...func(i interface{}) cmp.Option) func(actual, expected interface{}) (bool, string)
EqualOpt allow easy customization of the cmp.Equal method. see below for a list of supported options
func EquateEmpty ¶ added in v0.6.0
EquateEmpty is a wrapper around cmpopts.EquateEmpty it determines all maps and slices with a length of zero to be equal, regardless of whether they are nil
func ErrType ¶
ErrType can be used with ExpectedErr to check that the expected err is of a certain type
func IgnoreAllUnexported ¶ added in v0.6.0
IgnoreAllUnexported sets cmp.Diff to ignore all unexported (private) variables
func IgnoreFields ¶ added in v0.6.0
IgnoreFields is a wrapper around the cmpopts.IgnoreFields syntax: IgnoreFields(package.struct.Field)
func IgnoreTypes ¶ added in v0.6.0
IgnoreTypes is a wrapper around the cmpopts.IgnoreTypes it allows ignore the type of the values passed in int32(0), int(0), string(0), time.Duration(0), etc
func Time ¶
Time is a panic wrapper for the time.Parse method it returns a time.Time for the given layout and value
func TimeHour ¶
TimeHour is a helper method for parsing times with hour precision. format 2006-01-02T15
func TimeP ¶
TimeP return a pointers to a time.Time for the given layout and value. it panics on error
func Times ¶
Times is a panic wrapper for the time.Parse method it returns a time.Time slice for the given layout and values
Types ¶
type Case ¶
type Case[In any, Out any] struct { Input In Expected Out // testing conditions ShouldErr bool // is an error expected ExpectedErr error // the error that was expected (nil is no error expected) ShouldPanic bool // is a panic expected }
Case made during the trial of your code
type CompareFunc ¶ added in v0.4.0
CompareFunc compares actual and expected to determine equality. It should return a human readable string representing the differences between actual and expected. Symbols with meaning: "-" elements missing from actual "+" elements missing from expected
type Comparer ¶ added in v0.4.0
Comparer interface is implemented by an object to check for equality and show any differences found
type Input ¶ added in v0.4.0
type Input struct {
// contains filtered or unexported fields
}
Input the input value given to the trial test function
func Args ¶
func Args(args ...interface{}) Input
Args converts any number of parameters to an interface. generally used with Case's Input for multiple params
func (Input) Interface ¶ added in v0.4.0
func (in Input) Interface() interface{}
Interface returns the current value of input
func (Input) Map ¶ added in v0.4.0
Map returns the value for the provided key, panics on non map value
func (Input) Slice ¶ added in v0.4.0
Slice returns the input value of the index of a slice/array. panics if non slice value
type Trial ¶
Trial framework used to test different logical states
func (*Trial[In, Out]) Comparer ¶ added in v0.4.0
func (t *Trial[In, Out]) Comparer(fn CompareFunc) *Trial[In, Out]
Comparer override the default comparison function. see Contains(x, y interface{}) (bool, string) see Equals(x, y interface{}) (bool, string)
func (*Trial[In, Out]) EqualFn ¶
func (t *Trial[In, Out]) EqualFn(fn CompareFunc) *Trial[In, Out]
EqualFn override the default comparison method used. see ContainsFn(x, y interface{}) (bool, string) deprecated