Documentation
¶
Index ¶
- func Equal(t TestingT, expected interface{}, actual interface{}, ...)
- func False(t TestingT, value bool, msgAndArgs ...interface{})
- func Len(t TestingT, object interface{}, length int, msgAndArgs ...interface{})
- func Nil(t TestingT, object interface{}, msgAndArgs ...interface{})
- func NoError(t TestingT, err error, msgAndArgs ...interface{})
- func NotEmpty(t TestingT, object interface{}, msgAndArgs ...interface{})
- func NotEqual(t TestingT, expected interface{}, actual interface{}, ...)
- func NotNil(t TestingT, object interface{}, msgAndArgs ...interface{})
- func True(t TestingT, value bool, msgAndArgs ...interface{})
- type TestingT
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Equal ¶
func Equal(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{})
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 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 Nil ¶
func Nil(t TestingT, object interface{}, msgAndArgs ...interface{})
Nil asserts that the specified object is nil.
assert.Nil(t, err)
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 ¶
func NotEmpty(t TestingT, object interface{}, msgAndArgs ...interface{})
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 ¶
func NotEqual(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{})
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).