Documentation
¶
Overview ¶
Package assert contains an assertion library, providing methods to e.g. assert equality of expected and actual values. This makes your unit tests much more readable.
To use it, create an Assert object and call its methods for assertion:
asrt := NewAssert(t) actual := myTestCall() asrt.Equal(actual, "expected", "Got unexpected value from myTestCall()")
Index ¶
- type Assert
- func (a *Assert) Equal(actual interface{}, expected interface{}, msg string)
- func (a *Assert) EqualSlice(actual []interface{}, expected []interface{}, msg string)
- func (a *Assert) False(val interface{}, msg string)
- func (a *Assert) Match(pattern string, target string, msg string)
- func (a *Assert) Nil(actual interface{}, msg string)
- func (a *Assert) NotNil(actual interface{}, msg string)
- func (a *Assert) True(val interface{}, msg string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Assert ¶
type Assert struct {
// contains filtered or unexported fields
}
Assert wraps a testing.T pointer for storing failures.
func (*Assert) Equal ¶
Equal asserts that actual and expected are identical. It does not assert deep equality.
func (*Assert) EqualSlice ¶
EqualSlice asserts that the two given slices are equal, i.e. they have the same size and contain the same elements, doing a shallow compare of the elements.
Click to show internal directories.
Click to hide internal directories.