Documentation ¶
Index ¶
- func Empty(t TestingT, object interface{}, msgAndArgs ...interface{}) bool
- func Emptyf(t TestingT, object interface{}, msg string, args ...interface{}) bool
- func Equal(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool
- func EqualError(t TestingT, theError error, errString string, msgAndArgs ...interface{}) bool
- func EqualErrorf(t TestingT, theError error, errString string, msg string, args ...interface{}) bool
- func Equalf(t TestingT, expected interface{}, actual interface{}, msg string, ...) bool
- func Error(t TestingT, err error, msgAndArgs ...interface{}) bool
- func ErrorAs(t TestingT, err error, target interface{}, msgAndArgs ...interface{}) bool
- func ErrorAsf(t TestingT, err error, target interface{}, msg string, args ...interface{}) bool
- func ErrorIs(t TestingT, err, target error, msgAndArgs ...interface{}) bool
- func ErrorIsf(t TestingT, err error, target error, msg string, args ...interface{}) bool
- func Errorf(t TestingT, err error, msg string, args ...interface{}) bool
- func Fail(t TestingT, failureMessage string, msgAndArgs ...interface{}) bool
- func Failf(t TestingT, failureMessage string, msg string, args ...interface{}) bool
- func False(t TestingT, value bool, msgAndArgs ...interface{}) bool
- func Falsef(t TestingT, value bool, msg string, args ...interface{}) bool
- func Greater(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool
- func GreaterOrEqual(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool
- func GreaterOrEqualf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool
- func Greaterf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool
- func InDelta(t TestingT, expected, actual interface{}, delta float64, ...) bool
- func InDeltaMapValues(t TestingT, expected, actual interface{}, delta float64, ...) bool
- func InDeltaSlice(t TestingT, expected, actual interface{}, delta float64, ...) bool
- func InEpsilon(t TestingT, expected, actual interface{}, epsilon float64, ...) bool
- func InEpsilonSlice(t TestingT, expected, actual interface{}, epsilon float64, ...) bool
- func JSONEq(t TestingT, expected string, actual string, msgAndArgs ...interface{}) bool
- func JSONEqf(t TestingT, expected string, actual string, msg string, args ...interface{}) bool
- func Less(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool
- func LessOrEqual(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool
- func LessOrEqualf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool
- func Lessf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool
- func Negative(t TestingT, e interface{}, msgAndArgs ...interface{}) bool
- func Negativef(t TestingT, e interface{}, msg string, args ...interface{}) bool
- func Nil(t TestingT, object interface{}, msgAndArgs ...interface{}) bool
- func Nilf(t TestingT, object interface{}, msg string, args ...interface{}) bool
- func NoError(t TestingT, err error, msgAndArgs ...interface{}) bool
- func NoErrorf(t TestingT, err error, msg string, args ...interface{}) bool
- func NotEmpty(t TestingT, object interface{}, msgAndArgs ...interface{}) bool
- func NotEmptyf(t TestingT, object interface{}, msg string, args ...interface{}) bool
- func NotEqual(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool
- func NotEqualf(t TestingT, expected interface{}, actual interface{}, msg string, ...) bool
- func NotErrorIs(t TestingT, err, target error, msgAndArgs ...interface{}) bool
- func NotErrorIsf(t TestingT, err error, target error, msg string, args ...interface{}) bool
- func NotNil(t TestingT, object interface{}, msgAndArgs ...interface{}) bool
- func NotNilf(t TestingT, object interface{}, msg string, args ...interface{}) bool
- func NotZero(t TestingT, i interface{}, msgAndArgs ...interface{}) bool
- func ObjectsAreEqual(expected, actual interface{}) bool
- func ObjectsAreEqualValues(expected, actual interface{}) bool
- func Panics(t TestingT, f func(), msgAndArgs ...interface{}) bool
- func Panicsf(t TestingT, f func(), msg string, args ...interface{}) bool
- func Positive(t TestingT, e interface{}, msgAndArgs ...interface{}) bool
- func True(t TestingT, value bool, msgAndArgs ...interface{}) bool
- func Truef(t TestingT, value bool, msg string, args ...interface{}) bool
- func Zero(t TestingT, i interface{}, msgAndArgs ...interface{}) bool
- type TestingT
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 Emptyf ¶
Emptyf asserts that the specified object is empty. I.e. nil, "", false, 0 or either a slice or a channel with len == 0.
assert.Emptyf(t, obj, "error message %s", "formatted")
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 EqualError ¶
EqualError asserts that a function returned an error (i.e. not `nil`) and that it is equal to the provided error.
actualObj, err := SomeFunction() assert.EqualError(t, err, expectedErrorString)
func EqualErrorf ¶
func EqualErrorf(t TestingT, theError error, errString string, msg string, args ...interface{}) bool
EqualErrorf asserts that a function returned an error (i.e. not `nil`) and that it is equal to the provided error.
actualObj, err := SomeFunction() assert.EqualErrorf(t, err, expectedErrorString, "error message %s", "formatted")
func Equalf ¶
func Equalf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool
Equalf asserts that two objects are equal.
assert.Equalf(t, 123, 123, "error message %s", "formatted")
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 ErrorAs ¶
ErrorAs asserts that at least one of the errors in err's chain matches target, and if so, sets target to that error value. This is a wrapper for errors.As.
func ErrorAsf ¶
ErrorAsf asserts that at least one of the errors in err's chain matches target, and if so, sets target to that error value. This is a wrapper for errors.As.
func ErrorIs ¶
ErrorIs asserts that at least one of the errors in err's chain matches target. This is a wrapper for errors.Is.
func ErrorIsf ¶
ErrorIsf asserts that at least one of the errors in err's chain matches target. This is a wrapper for errors.Is.
func Errorf ¶
Errorf asserts that a function returned an error (i.e. not `nil`).
actualObj, err := SomeFunction() if assert.Errorf(t, err, "error message %s", "formatted") { assert.Equal(t, expectedErrorf, err) }
func Falsef ¶
Falsef asserts that the specified value is false.
assert.Falsef(t, myBool, "error message %s", "formatted")
func Greater ¶
Greater asserts that the first element is greater than the second
assert.Greater(t, 2, 1) assert.Greater(t, float64(2), float64(1)) assert.Greater(t, "b", "a")
func GreaterOrEqual ¶
GreaterOrEqual asserts that the first element is greater than or equal to the second
assert.GreaterOrEqual(t, 2, 1) assert.GreaterOrEqual(t, 2, 2) assert.GreaterOrEqual(t, "b", "a") assert.GreaterOrEqual(t, "b", "b")
func GreaterOrEqualf ¶
func GreaterOrEqualf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool
GreaterOrEqualf asserts that the first element is greater than or equal to the second
assert.GreaterOrEqualf(t, 2, 1, "error message %s", "formatted") assert.GreaterOrEqualf(t, 2, 2, "error message %s", "formatted") assert.GreaterOrEqualf(t, "b", "a", "error message %s", "formatted") assert.GreaterOrEqualf(t, "b", "b", "error message %s", "formatted")
func Greaterf ¶
Greaterf asserts that the first element is greater than the second
assert.Greaterf(t, 2, 1, "error message %s", "formatted") assert.Greaterf(t, float64(2), float64(1), "error message %s", "formatted") assert.Greaterf(t, "b", "a", "error message %s", "formatted")
func InDelta ¶
func InDelta(t TestingT, expected, actual interface{}, delta float64, msgAndArgs ...interface{}) bool
InDelta asserts that the two numerals are within delta of each other.
assert.InDelta(t, math.Pi, 22/7.0, 0.01)
func InDeltaMapValues ¶
func InDeltaMapValues(t TestingT, expected, actual interface{}, delta float64, msgAndArgs ...interface{}) bool
InDeltaMapValues is the same as InDelta, but it compares all values between two maps. Both maps must have exactly the same keys.
func InDeltaSlice ¶
func InDeltaSlice(t TestingT, expected, actual interface{}, delta float64, msgAndArgs ...interface{}) bool
InDeltaSlice is the same as InDelta, except it compares two slices.
func InEpsilon ¶
func InEpsilon(t TestingT, expected, actual interface{}, epsilon float64, msgAndArgs ...interface{}) bool
InEpsilon asserts that expected and actual have a relative error less than epsilon
func InEpsilonSlice ¶
func InEpsilonSlice(t TestingT, expected, actual interface{}, epsilon float64, msgAndArgs ...interface{}) bool
InEpsilonSlice is the same as InEpsilon, except it compares each value from two slices.
func JSONEq ¶
JSONEq asserts that two JSON strings are equivalent.
assert.JSONEq(t, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`)
func JSONEqf ¶
JSONEqf asserts that two JSON strings are equivalent.
assert.JSONEqf(t, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`, "error message %s", "formatted")
func Less ¶
Less asserts that the first element is less than the second
assert.Less(t, 1, 2) assert.Less(t, float64(1), float64(2)) assert.Less(t, "a", "b")
func LessOrEqual ¶
LessOrEqual asserts that the first element is less than or equal to the second
assert.LessOrEqual(t, 1, 2) assert.LessOrEqual(t, 2, 2) assert.LessOrEqual(t, "a", "b") assert.LessOrEqual(t, "b", "b")
func LessOrEqualf ¶
LessOrEqualf asserts that the first element is less than or equal to the second
assert.LessOrEqualf(t, 1, 2, "error message %s", "formatted") assert.LessOrEqualf(t, 2, 2, "error message %s", "formatted") assert.LessOrEqualf(t, "a", "b", "error message %s", "formatted") assert.LessOrEqualf(t, "b", "b", "error message %s", "formatted")
func Lessf ¶
Lessf asserts that the first element is less than the second
assert.Lessf(t, 1, 2, "error message %s", "formatted") assert.Lessf(t, float64(1), float64(2), "error message %s", "formatted") assert.Lessf(t, "a", "b", "error message %s", "formatted")
func Negative ¶
Negative asserts that the specified element is negative
assert.Negative(t, -1) assert.Negative(t, -1.23)
func Negativef ¶
Negativef asserts that the specified element is negative
assert.Negativef(t, -1, "error message %s", "formatted") assert.Negativef(t, -1.23, "error message %s", "formatted")
func Nilf ¶
Nilf asserts that the specified object is nil.
assert.Nilf(t, err, "error message %s", "formatted")
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 NoErrorf ¶
NoErrorf asserts that a function returned no error (i.e. `nil`).
actualObj, err := SomeFunction() if assert.NoErrorf(t, err, "error message %s", "formatted") { 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 NotEmptyf ¶
NotEmptyf 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.NotEmptyf(t, obj, "error message %s", "formatted") { 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 NotEqualf ¶
func NotEqualf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool
NotEqualf asserts that the specified values are NOT equal.
assert.NotEqualf(t, obj1, obj2, "error message %s", "formatted")
Pointer variable equality is determined based on the equality of the referenced values (as opposed to the memory addresses).
func NotErrorIs ¶
NotErrorIs asserts that at none of the errors in err's chain matches target. This is a wrapper for errors.Is.
func NotErrorIsf ¶
NotErrorIsf asserts that at none of the errors in err's chain matches target. This is a wrapper for errors.Is.
func NotNilf ¶
NotNilf asserts that the specified object is not nil.
assert.NotNilf(t, err, "error message %s", "formatted")
func ObjectsAreEqual ¶
func ObjectsAreEqual(expected, actual interface{}) bool
ObjectsAreEqual determines if two objects are considered equal.
This function does no assertion of any kind.
func ObjectsAreEqualValues ¶
func ObjectsAreEqualValues(expected, actual interface{}) bool
ObjectsAreEqualValues gets whether two objects are equal, or if their values are equal.
func Panics ¶
Panics asserts that the code inside the specified f panics.
assert.Panics(t, func(){ GoCrazy() })
func Panicsf ¶
Panicsf asserts that the code inside the specified f panics.
assert.Panicsf(t, func(){ GoCrazy() }, "error message %s", "formatted")
func Positive ¶
Positive asserts that the specified element is positive
assert.Positive(t, 1) assert.Positive(t, 1.23)