Documentation ¶
Index ¶
- func CallerInfo() []string
- func Empty(t TestingT, object interface{}, msgAndArgs ...interface{}) bool
- func Equal(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool
- func Error(t TestingT, err error, msgAndArgs ...interface{}) bool
- func Fail(t TestingT, failureMessage string, msgAndArgs ...interface{}) bool
- func False(t TestingT, value bool, msgAndArgs ...interface{}) bool
- func Len(t TestingT, object interface{}, length int, msgAndArgs ...interface{}) bool
- func Nil(t TestingT, object interface{}, msgAndArgs ...interface{}) bool
- func NoError(t TestingT, err error, msgAndArgs ...interface{}) bool
- func NotEmpty(t TestingT, object interface{}, msgAndArgs ...interface{}) bool
- func NotEqual(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool
- func NotNil(t TestingT, object interface{}, msgAndArgs ...interface{}) bool
- func ObjectsAreEqual(expected, actual interface{}) bool
- func True(t TestingT, value bool, msgAndArgs ...interface{}) bool
- type TestingT
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CallerInfo ¶
func CallerInfo() []string
CallerInfo returns an array of strings containing the file and line number of each stack frame leading from the current test to the assert call that failed.
func Empty ¶
Empty asserts that the specified object is empty. I.e. nil, "", false, 0 or either a slice or a channel with len == 0.
assert.Empty(t, obj)
func Equal ¶
Equal asserts that two objects are equal.
assert.Equal(t, 123, 123)
Pointer variable equality is determined based on the equality of the referenced values (as opposed to the memory addresses). Function equality cannot be determined and will always fail.
func Error ¶
Error asserts that a function returned an error (i.e. not `nil`).
actualObj, err := SomeFunction() if assert.Error(t, err) { assert.Equal(t, expectedError, err) }
func Len ¶
Len asserts that the specified object has specific length. Len also fails if the object has a type that len() not accept.
assert.Len(t, mySlice, 3)
func NoError ¶
NoError asserts that a function returned no error (i.e. `nil`).
actualObj, err := SomeFunction() if assert.NoError(t, err) { assert.Equal(t, expectedObj, actualObj) }
func NotEmpty ¶
NotEmpty asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either a slice or a channel with len == 0.
if assert.NotEmpty(t, obj) { assert.Equal(t, "two", obj[1]) }
func NotEqual ¶
NotEqual asserts that the specified values are NOT equal.
assert.NotEqual(t, obj1, obj2)
Pointer variable equality is determined based on the equality of the referenced values (as opposed to the memory addresses).
func ObjectsAreEqual ¶
func ObjectsAreEqual(expected, actual interface{}) bool
ObjectsAreEqual determines if two objects are considered equal.
This function does no assertion of any kind.