Documentation ¶
Index ¶
- func Contains(t TestingT, s interface{}, contains interface{}, msgAndArgs ...interface{})
- func Containsf(t TestingT, s interface{}, contains interface{}, msg string, ...)
- func ElementsMatch(t TestingT, listA interface{}, listB interface{}, msgAndArgs ...interface{})
- func ElementsMatchf(t TestingT, listA interface{}, listB interface{}, msg string, ...)
- func Equal(t TestingT, expected interface{}, actual interface{}, ...)
- func EqualError(t TestingT, theError error, errString string, msgAndArgs ...interface{})
- func EqualErrorf(t TestingT, theError error, errString string, msg string, args ...interface{})
- func EqualValues(t TestingT, expected interface{}, actual interface{}, ...)
- func EqualValuesf(t TestingT, expected interface{}, actual interface{}, msg string, ...)
- func Equalf(t TestingT, expected interface{}, actual interface{}, msg string, ...)
- func Error(t TestingT, err error, msgAndArgs ...interface{})
- func ErrorContains(t TestingT, theError error, contains string, msgAndArgs ...interface{})
- func ErrorContainsf(t TestingT, theError error, contains string, msg string, args ...interface{})
- func Errorf(t TestingT, err error, msg string, args ...interface{})
- func Eventually(t TestingT, condition func() bool, waitFor time.Duration, tick time.Duration, ...)
- func Eventuallyf(t TestingT, condition func() bool, waitFor time.Duration, tick time.Duration, ...)
- func Fail(t TestingT, failureMessage string, msgAndArgs ...interface{})
- func FailNow(t TestingT, failureMessage string, msgAndArgs ...interface{})
- func FailNowf(t TestingT, failureMessage string, msg string, args ...interface{})
- func Failf(t TestingT, failureMessage string, msg string, args ...interface{})
- func False(t TestingT, value bool, msgAndArgs ...interface{})
- func Falsef(t TestingT, value bool, msg string, args ...interface{})
- func Greater(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{})
- func GreaterOrEqual(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{})
- func GreaterOrEqualf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{})
- func Greaterf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{})
- func InDelta(t TestingT, expected interface{}, actual interface{}, delta float64, ...)
- func InDeltaf(t TestingT, expected interface{}, actual interface{}, delta float64, ...)
- func IsType(t TestingT, expectedType interface{}, object interface{}, ...)
- func IsTypef(t TestingT, expectedType interface{}, object interface{}, msg string, ...)
- func Len(t TestingT, object interface{}, length int, msgAndArgs ...interface{})
- func Lenf(t TestingT, object interface{}, length int, msg string, args ...interface{})
- func Less(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{})
- func LessOrEqual(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{})
- func LessOrEqualf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{})
- func Lessf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{})
- func Negative(t TestingT, e interface{}, msgAndArgs ...interface{})
- func Negativef(t TestingT, e interface{}, msg string, args ...interface{})
- func Nil(t TestingT, object interface{}, msgAndArgs ...interface{})
- func Nilf(t TestingT, object interface{}, msg string, args ...interface{})
- func NoError(t TestingT, err error, msgAndArgs ...interface{})
- func NoErrorf(t TestingT, err error, msg string, args ...interface{})
- func NotContains(t TestingT, s interface{}, contains interface{}, msgAndArgs ...interface{})
- func NotContainsf(t TestingT, s interface{}, contains interface{}, msg string, ...)
- func NotEqual(t TestingT, expected interface{}, actual interface{}, ...)
- func NotEqualValues(t TestingT, expected interface{}, actual interface{}, ...)
- func NotEqualValuesf(t TestingT, expected interface{}, actual interface{}, msg string, ...)
- func NotEqualf(t TestingT, expected interface{}, actual interface{}, msg string, ...)
- func NotNil(t TestingT, object interface{}, msgAndArgs ...interface{})
- func NotNilf(t TestingT, object interface{}, msg string, args ...interface{})
- func Positive(t TestingT, e interface{}, msgAndArgs ...interface{})
- func Positivef(t TestingT, e interface{}, msg string, args ...interface{})
- func True(t TestingT, value bool, msgAndArgs ...interface{})
- func Truef(t TestingT, value bool, msg string, args ...interface{})
- func WithinDuration(t TestingT, expected time.Time, actual time.Time, delta time.Duration, ...)
- func WithinDurationf(t TestingT, expected time.Time, actual time.Time, delta time.Duration, ...)
- type TestingT
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Contains ¶
func Contains(t TestingT, s interface{}, contains interface{}, msgAndArgs ...interface{})
Contains asserts that the specified string, list(array, slice...) or map contains the specified substring or element.
assert.Contains(t, "Hello World", "World") assert.Contains(t, ["Hello", "World"], "World") assert.Contains(t, {"Hello": "World"}, "Hello")
func Containsf ¶
Containsf asserts that the specified string, list(array, slice...) or map contains the specified substring or element.
assert.Containsf(t, "Hello World", "World", "error message %s", "formatted") assert.Containsf(t, ["Hello", "World"], "World", "error message %s", "formatted") assert.Containsf(t, {"Hello": "World"}, "Hello", "error message %s", "formatted")
func ElementsMatch ¶
func ElementsMatch(t TestingT, listA interface{}, listB interface{}, msgAndArgs ...interface{})
ElementsMatch asserts that the specified listA(array, slice...) is equal to specified listB(array, slice...) ignoring the order of the elements. If there are duplicate elements, the number of appearances of each of them in both lists should match.
assert.ElementsMatch(t, [1, 3, 2, 3], [1, 3, 3, 2])
func ElementsMatchf ¶
func ElementsMatchf(t TestingT, listA interface{}, listB interface{}, msg string, args ...interface{})
ElementsMatchf asserts that the specified listA(array, slice...) is equal to specified listB(array, slice...) ignoring the order of the elements. If there are duplicate elements, the number of appearances of each of them in both lists should match.
assert.ElementsMatchf(t, [1, 3, 2, 3], [1, 3, 3, 2], "error message %s", "formatted")
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 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 ¶
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 EqualValues ¶
func EqualValues(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{})
EqualValues asserts that two objects are equal or convertable to the same types and equal.
assert.EqualValues(t, uint32(123), int32(123))
func EqualValuesf ¶
func EqualValuesf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{})
EqualValuesf asserts that two objects are equal or convertable to the same types and equal.
assert.EqualValuesf(t, uint32(123), int32(123), "error message %s", "formatted")
func Equalf ¶
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 ErrorContains ¶
ErrorContains asserts that a function returned an error (i.e. not `nil`) and that the error contains the specified substring.
actualObj, err := SomeFunction() assert.ErrorContains(t, err, expectedErrorSubString)
func ErrorContainsf ¶
ErrorContainsf asserts that a function returned an error (i.e. not `nil`) and that the error contains the specified substring.
actualObj, err := SomeFunction() assert.ErrorContainsf(t, err, expectedErrorSubString, "error message %s", "formatted")
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 Eventually ¶
func Eventually(t TestingT, condition func() bool, waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{})
Eventually asserts that given condition will be met in waitFor time, periodically checking target function each tick.
assert.Eventually(t, func() bool { return true; }, time.Second, 10*time.Millisecond)
func Eventuallyf ¶
func Eventuallyf(t TestingT, condition func() bool, waitFor time.Duration, tick time.Duration, msg string, args ...interface{})
Eventuallyf asserts that given condition will be met in waitFor time, periodically checking target function each tick.
assert.Eventuallyf(t, func() bool { return true; }, time.Second, 10*time.Millisecond, "error message %s", "formatted")
func Falsef ¶
Falsef asserts that the specified value is false.
assert.Falsef(t, myBool, "error message %s", "formatted")
func Greater ¶
func Greater(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{})
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 ¶
func GreaterOrEqual(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{})
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 ¶
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 interface{}, actual interface{}, delta float64, msgAndArgs ...interface{})
InDelta asserts that the two numerals are within delta of each other.
assert.InDelta(t, math.Pi, 22/7.0, 0.01)
func InDeltaf ¶
func InDeltaf(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{})
InDeltaf asserts that the two numerals are within delta of each other.
assert.InDeltaf(t, math.Pi, 22/7.0, 0.01, "error message %s", "formatted")
func IsType ¶
func IsType(t TestingT, expectedType interface{}, object interface{}, msgAndArgs ...interface{})
IsType asserts that the specified objects are of the same type.
func IsTypef ¶
func IsTypef(t TestingT, expectedType interface{}, object interface{}, msg string, args ...interface{})
IsTypef asserts that the specified objects are of the same type.
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 Lenf ¶
Lenf asserts that the specified object has specific length. Lenf also fails if the object has a type that len() not accept.
assert.Lenf(t, mySlice, 3, "error message %s", "formatted")
func Less ¶
func Less(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{})
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 ¶
func LessOrEqual(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{})
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 ¶
func Negative(t TestingT, e interface{}, msgAndArgs ...interface{})
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 Nil ¶
func Nil(t TestingT, object interface{}, msgAndArgs ...interface{})
Nil asserts that the specified object is nil.
assert.Nil(t, err)
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 NotContains ¶
func NotContains(t TestingT, s interface{}, contains interface{}, msgAndArgs ...interface{})
NotContains asserts that the specified string, list(array, slice...) or map does NOT contain the specified substring or element.
assert.NotContains(t, "Hello World", "Earth") assert.NotContains(t, ["Hello", "World"], "Earth") assert.NotContains(t, {"Hello": "World"}, "Earth")
func NotContainsf ¶
NotContainsf asserts that the specified string, list(array, slice...) or map does NOT contain the specified substring or element.
assert.NotContainsf(t, "Hello World", "Earth", "error message %s", "formatted") assert.NotContainsf(t, ["Hello", "World"], "Earth", "error message %s", "formatted") assert.NotContainsf(t, {"Hello": "World"}, "Earth", "error message %s", "formatted")
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).
func NotEqualValues ¶
func NotEqualValues(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{})
NotEqualValues asserts that two objects are not equal even when converted to the same type
assert.NotEqualValues(t, obj1, obj2)
func NotEqualValuesf ¶
func NotEqualValuesf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{})
NotEqualValuesf asserts that two objects are not equal even when converted to the same type
assert.NotEqualValuesf(t, obj1, obj2, "error message %s", "formatted")
func NotEqualf ¶
func NotEqualf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{})
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 NotNil ¶
func NotNil(t TestingT, object interface{}, msgAndArgs ...interface{})
NotNil asserts that the specified object is not nil.
assert.NotNil(t, err)
func NotNilf ¶
NotNilf asserts that the specified object is not nil.
assert.NotNilf(t, err, "error message %s", "formatted")
func Positive ¶
func Positive(t TestingT, e interface{}, msgAndArgs ...interface{})
Positive asserts that the specified element is positive
assert.Positive(t, 1) assert.Positive(t, 1.23)
func Positivef ¶
Positivef asserts that the specified element is positive
assert.Positivef(t, 1, "error message %s", "formatted") assert.Positivef(t, 1.23, "error message %s", "formatted")
func Truef ¶
Truef asserts that the specified value is true.
assert.Truef(t, myBool, "error message %s", "formatted")
func WithinDuration ¶
func WithinDuration(t TestingT, expected time.Time, actual time.Time, delta time.Duration, msgAndArgs ...interface{})
WithinDuration asserts that the two times are within duration delta of each other.
assert.WithinDuration(t, time.Now(), time.Now(), 10*time.Second)
func WithinDurationf ¶
func WithinDurationf(t TestingT, expected time.Time, actual time.Time, delta time.Duration, msg string, args ...interface{})
WithinDurationf asserts that the two times are within duration delta of each other.
assert.WithinDurationf(t, time.Now(), time.Now(), 10*time.Second, "error message %s", "formatted")