Documentation
¶
Index ¶
- Variables
- func NewLenMismatch(expected, actual int) (min, max int, err error)
- func NewNotEqual(areEqual bool, expected, actual interface{}) error
- func NewSliceErrs(lnExpected, lnActual int, fn func(int) error) error
- func NewTypeMismatch(expected, actual interface{}) error
- type ErrLenMismatch
- type ErrNotEqual
- type ErrTypeMismatch
- type SliceErrRecord
- type SliceErrs
Constants ¶
This section is empty.
Variables ¶
var MaxSliceErrs = 10
MaxSliceErrs limits the number of errors that will be reported by SliceErrs.Error
Functions ¶
func NewLenMismatch ¶
NewLenMismatch will return a nil error if expected and actual are equal and an instance of LenMismatch if they are different. The min and max will be set to the smaller and larger of the values passed in respectivly.
func NewNotEqual ¶
NewNotEqual will return nil if areEqual is true and will create an instance of ErrNotEqual if it is false.
func NewSliceErrs ¶
NewSliceErrs creates an instance of SliceErrs by calling the provided func for every value up to Min(lnExpected, lnActual). If lnExpected and lnActual are not equal and instance of LenMismatch will be added to the start of the SliceErrs with an index of -1. If lnActual == -1 the length check is ignored.
func NewTypeMismatch ¶
func NewTypeMismatch(expected, actual interface{}) error
NewTypeMismatch will return nil if the given types are the same and returns ErrTypeMismatch if they do not.
Types ¶
type ErrLenMismatch ¶
type ErrLenMismatch struct {
Expected, Actual int
}
ErrLenMismatch represents a mis-matched length.
func LenMismatch ¶
func LenMismatch(expected, actual int) ErrLenMismatch
LenMismatch returns an ErrLenMismatch.
func (ErrLenMismatch) Error ¶
func (e ErrLenMismatch) Error() string
Error fulfills the error interface.
type ErrNotEqual ¶
type ErrNotEqual struct {
Expected, Actual interface{}
}
ErrNotEqual is used to indicate two values that were expected to be equal. were not.
func NotEqual ¶
func NotEqual(expected, actual interface{}) ErrNotEqual
NotEqual creates an instance of ErrNotEqual.
type ErrTypeMismatch ¶
ErrTypeMismatch indicates that two types that were expected to be equal were not.
func TypeMismatch ¶
func TypeMismatch(expected, actual interface{}) ErrTypeMismatch
TypeMismatch creates an instance of ErrTypeMismatch.
func (ErrTypeMismatch) Error ¶
func (e ErrTypeMismatch) Error() string
Error fulfills the error interface.
type SliceErrRecord ¶
SliceErrRecord represents an error comparing two slices. An index less than 0 is treated as an error on the underlying comparison and will be printed without the index. For instance, if the lengths of the slices are not the same.
type SliceErrs ¶
type SliceErrs []SliceErrRecord
SliceErrs collects SliceErrRecord and treats them as a single error.
func (SliceErrs) Append ¶
Append a SliceErrRecord to SliceErrs. If err is nil it will not be appended.