Documentation
¶
Index ¶
- Variables
- type Info
- func (i *Info) AddCmpHooks(fns []interface{}) error
- func (i *Info) AddIgnoreUnexported(ts []interface{}) error
- func (i *Info) AddSmuggleHooks(fns []interface{}) error
- func (i *Info) AddUseEqual(ts []interface{}) error
- func (i *Info) Cmp(got, expected reflect.Value) (bool, error)
- func (i *Info) Copy() *Info
- func (i *Info) IgnoreUnexported(t reflect.Type) bool
- func (i *Info) Smuggle(got *reflect.Value) (bool, error)
- func (i *Info) UseEqual(t reflect.Type) bool
Constants ¶
This section is empty.
Variables ¶
var ErrBoolean = errors.New("CmpHook(got, expected) failed")
Functions ¶
This section is empty.
Types ¶
type Info ¶
Info gathers all hooks information.
func (*Info) AddCmpHooks ¶
AddCmpHooks records new Cmp hooks using functions contained in "fns".
Each function in "fns" has to be a function with the following possible signatures:
func (A, A) bool func (A, A) error
First arg is always "got", and second is always "expected".
A cannot be an interface. This retriction can be removed in the future, if really needed.
It returns an error if an item of "fns" is not a function or if its signature does not match the expected ones.
func (*Info) AddIgnoreUnexported ¶ added in v1.10.0
AddIgnoreUnexported records types of values contained in "ts" as ignoring unexported struct fields. "ts" can also contain reflect.Type instances.
func (*Info) AddSmuggleHooks ¶
AddSmuggleHooks records new Smuggle hooks using functions contained in "fns".
Each function in "fns" has to be a function with the following possible signatures:
func (A) B func (A) (B, error)
A cannot be an interface. This retriction can be removed in the future, if really needed.
B can be an interface.
It returns an error if an item of "fns" is not a function or if its signature does not match the expected ones.
func (*Info) AddUseEqual ¶ added in v1.10.0
AddUseEqual records types of values contained in "ts" as using Equal method. "ts" can also contain reflect.Type instances.
func (*Info) Cmp ¶
Cmp checks if a Cmp hook exists matching "got" and "expected" types.
If no, it returns (false, nil)
If yes, it calls it and returns (true, nil) if it succeeds, (true, <an error>) if it fails. If the hook returns a false bool, the error returned is ErrBoolean.
func (*Info) Copy ¶
Copy returns a new instance of *Info with the same hooks as i. As a special case, if i is nil, returned instance is non-nil.
func (*Info) IgnoreUnexported ¶ added in v1.10.0
IgnoreUnexported returns true if the unexported fields of the type "t" have to be ignored.