Documentation
¶
Index ¶
- func CallerInfo() []string
- func Empty(t TestingT, object any, msgAndArgs ...any) bool
- func Equal(t TestingT, expected, actual any, msgAndArgs ...any) bool
- func Error(t TestingT, err error, msgAndArgs ...any) bool
- func Fail(t TestingT, failureMessage string, msgAndArgs ...any) bool
- func False(t TestingT, value bool, msgAndArgs ...any) bool
- func Len(t TestingT, object any, length int, msgAndArgs ...any) bool
- func Nil(t TestingT, object any, msgAndArgs ...any) bool
- func NoError(t TestingT, err error, msgAndArgs ...any) bool
- func NotEmpty(t TestingT, object any, msgAndArgs ...any) bool
- func NotEqual(t TestingT, expected, actual any, msgAndArgs ...any) bool
- func NotNil(t TestingT, object any, msgAndArgs ...any) bool
- func ObjectsAreEqual(expected, actual any) bool
- func True(t TestingT, value bool, msgAndArgs ...any) 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 ¶
ObjectsAreEqual determines if two objects are considered equal.
This function does no assertion of any kind.