// Code generated with github.com/stretchr/testify/_codegen; DO NOT EDIT.package requireimport (asserthttpurltime)// Condition uses a Comparison to assert a complex condition.func ( TestingT, assert.Comparison, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.Condition(, , ...) {return } .FailNow()}// Conditionf uses a Comparison to assert a complex condition.func ( TestingT, assert.Comparison, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.Conditionf(, , , ...) {return } .FailNow()}// Contains asserts that the specified string, list(array, slice...) or map contains the// specified substring or element.//// require.Contains(t, "Hello World", "World")// require.Contains(t, ["Hello", "World"], "World")// require.Contains(t, {"Hello": "World"}, "Hello")func ( TestingT, interface{}, interface{}, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.Contains(, , , ...) {return } .FailNow()}// Containsf asserts that the specified string, list(array, slice...) or map contains the// specified substring or element.//// require.Containsf(t, "Hello World", "World", "error message %s", "formatted")// require.Containsf(t, ["Hello", "World"], "World", "error message %s", "formatted")// require.Containsf(t, {"Hello": "World"}, "Hello", "error message %s", "formatted")func ( TestingT, interface{}, interface{}, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.Containsf(, , , , ...) {return } .FailNow()}// DirExists checks whether a directory exists in the given path. It also fails// if the path is a file rather a directory or there is an error checking whether it exists.func ( TestingT, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.DirExists(, , ...) {return } .FailNow()}// DirExistsf checks whether a directory exists in the given path. It also fails// if the path is a file rather a directory or there is an error checking whether it exists.func ( TestingT, string, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.DirExistsf(, , , ...) {return } .FailNow()}// 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.//// require.ElementsMatch(t, [1, 3, 2, 3], [1, 3, 3, 2])func ( TestingT, interface{}, interface{}, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.ElementsMatch(, , , ...) {return } .FailNow()}// 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.//// require.ElementsMatchf(t, [1, 3, 2, 3], [1, 3, 3, 2], "error message %s", "formatted")func ( TestingT, interface{}, interface{}, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.ElementsMatchf(, , , , ...) {return } .FailNow()}// Empty asserts that the given value is "empty".//// [Zero values] are "empty".//// Arrays are "empty" if every element is the zero value of the type (stricter than "empty").//// Slices, maps and channels with zero length are "empty".//// Pointer values are "empty" if the pointer is nil or if the pointed value is "empty".//// require.Empty(t, obj)//// [Zero values]: https://go.dev/ref/spec#The_zero_valuefunc ( TestingT, interface{}, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.Empty(, , ...) {return } .FailNow()}// Emptyf asserts that the given value is "empty".//// [Zero values] are "empty".//// Arrays are "empty" if every element is the zero value of the type (stricter than "empty").//// Slices, maps and channels with zero length are "empty".//// Pointer values are "empty" if the pointer is nil or if the pointed value is "empty".//// require.Emptyf(t, obj, "error message %s", "formatted")//// [Zero values]: https://go.dev/ref/spec#The_zero_valuefunc ( TestingT, interface{}, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.Emptyf(, , , ...) {return } .FailNow()}// Equal asserts that two objects are equal.//// require.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 ( TestingT, interface{}, interface{}, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.Equal(, , , ...) {return } .FailNow()}// EqualError asserts that a function returned an error (i.e. not `nil`)// and that it is equal to the provided error.//// actualObj, err := SomeFunction()// require.EqualError(t, err, expectedErrorString)func ( TestingT, error, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.EqualError(, , , ...) {return } .FailNow()}// EqualErrorf asserts that a function returned an error (i.e. not `nil`)// and that it is equal to the provided error.//// actualObj, err := SomeFunction()// require.EqualErrorf(t, err, expectedErrorString, "error message %s", "formatted")func ( TestingT, error, string, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.EqualErrorf(, , , , ...) {return } .FailNow()}// EqualExportedValues asserts that the types of two objects are equal and their public// fields are also equal. This is useful for comparing structs that have private fields// that could potentially differ.//// type S struct {// Exported int// notExported int// }// require.EqualExportedValues(t, S{1, 2}, S{1, 3}) => true// require.EqualExportedValues(t, S{1, 2}, S{2, 3}) => falsefunc ( TestingT, interface{}, interface{}, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.EqualExportedValues(, , , ...) {return } .FailNow()}// EqualExportedValuesf asserts that the types of two objects are equal and their public// fields are also equal. This is useful for comparing structs that have private fields// that could potentially differ.//// type S struct {// Exported int// notExported int// }// require.EqualExportedValuesf(t, S{1, 2}, S{1, 3}, "error message %s", "formatted") => true// require.EqualExportedValuesf(t, S{1, 2}, S{2, 3}, "error message %s", "formatted") => falsefunc ( TestingT, interface{}, interface{}, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.EqualExportedValuesf(, , , , ...) {return } .FailNow()}// EqualValues asserts that two objects are equal or convertible to the larger// type and equal.//// require.EqualValues(t, uint32(123), int32(123))func ( TestingT, interface{}, interface{}, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.EqualValues(, , , ...) {return } .FailNow()}// EqualValuesf asserts that two objects are equal or convertible to the larger// type and equal.//// require.EqualValuesf(t, uint32(123), int32(123), "error message %s", "formatted")func ( TestingT, interface{}, interface{}, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.EqualValuesf(, , , , ...) {return } .FailNow()}// Equalf asserts that two objects are equal.//// require.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 ( TestingT, interface{}, interface{}, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.Equalf(, , , , ...) {return } .FailNow()}// Error asserts that a function returned an error (i.e. not `nil`).//// actualObj, err := SomeFunction()// require.Error(t, err)func ( TestingT, error, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.Error(, , ...) {return } .FailNow()}// 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 ( TestingT, error, interface{}, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.ErrorAs(, , , ...) {return } .FailNow()}// 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 ( TestingT, error, interface{}, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.ErrorAsf(, , , , ...) {return } .FailNow()}// ErrorContains asserts that a function returned an error (i.e. not `nil`)// and that the error contains the specified substring.//// actualObj, err := SomeFunction()// require.ErrorContains(t, err, expectedErrorSubString)func ( TestingT, error, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.ErrorContains(, , , ...) {return } .FailNow()}// ErrorContainsf asserts that a function returned an error (i.e. not `nil`)// and that the error contains the specified substring.//// actualObj, err := SomeFunction()// require.ErrorContainsf(t, err, expectedErrorSubString, "error message %s", "formatted")func ( TestingT, error, string, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.ErrorContainsf(, , , , ...) {return } .FailNow()}// ErrorIs asserts that at least one of the errors in err's chain matches target.// This is a wrapper for errors.Is.func ( TestingT, error, error, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.ErrorIs(, , , ...) {return } .FailNow()}// ErrorIsf asserts that at least one of the errors in err's chain matches target.// This is a wrapper for errors.Is.func ( TestingT, error, error, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.ErrorIsf(, , , , ...) {return } .FailNow()}// Errorf asserts that a function returned an error (i.e. not `nil`).//// actualObj, err := SomeFunction()// require.Errorf(t, err, "error message %s", "formatted")func ( TestingT, error, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.Errorf(, , , ...) {return } .FailNow()}// Eventually asserts that given condition will be met in waitFor time,// periodically checking target function each tick.//// require.Eventually(t, func() bool { return true; }, time.Second, 10*time.Millisecond)func ( TestingT, func() bool, time.Duration, time.Duration, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.Eventually(, , , , ...) {return } .FailNow()}// EventuallyWithT asserts that given condition will be met in waitFor time,// periodically checking target function each tick. In contrast to Eventually,// it supplies a CollectT to the condition function, so that the condition// function can use the CollectT to call other assertions.// The condition is considered "met" if no errors are raised in a tick.// The supplied CollectT collects all errors from one tick (if there are any).// If the condition is not met before waitFor, the collected errors of// the last tick are copied to t.//// externalValue := false// go func() {// time.Sleep(8*time.Second)// externalValue = true// }()// require.EventuallyWithT(t, func(c *require.CollectT) {// // add assertions as needed; any assertion failure will fail the current tick// require.True(c, externalValue, "expected 'externalValue' to be true")// }, 10*time.Second, 1*time.Second, "external state has not changed to 'true'; still false")func ( TestingT, func( *assert.CollectT), time.Duration, time.Duration, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.EventuallyWithT(, , , , ...) {return } .FailNow()}// EventuallyWithTf asserts that given condition will be met in waitFor time,// periodically checking target function each tick. In contrast to Eventually,// it supplies a CollectT to the condition function, so that the condition// function can use the CollectT to call other assertions.// The condition is considered "met" if no errors are raised in a tick.// The supplied CollectT collects all errors from one tick (if there are any).// If the condition is not met before waitFor, the collected errors of// the last tick are copied to t.//// externalValue := false// go func() {// time.Sleep(8*time.Second)// externalValue = true// }()// require.EventuallyWithTf(t, func(c *require.CollectT, "error message %s", "formatted") {// // add assertions as needed; any assertion failure will fail the current tick// require.True(c, externalValue, "expected 'externalValue' to be true")// }, 10*time.Second, 1*time.Second, "external state has not changed to 'true'; still false")func ( TestingT, func( *assert.CollectT), time.Duration, time.Duration, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.EventuallyWithTf(, , , , , ...) {return } .FailNow()}// Eventuallyf asserts that given condition will be met in waitFor time,// periodically checking target function each tick.//// require.Eventuallyf(t, func() bool { return true; }, time.Second, 10*time.Millisecond, "error message %s", "formatted")func ( TestingT, func() bool, time.Duration, time.Duration, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.Eventuallyf(, , , , , ...) {return } .FailNow()}// Exactly asserts that two objects are equal in value and type.//// require.Exactly(t, int32(123), int64(123))func ( TestingT, interface{}, interface{}, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.Exactly(, , , ...) {return } .FailNow()}// Exactlyf asserts that two objects are equal in value and type.//// require.Exactlyf(t, int32(123), int64(123), "error message %s", "formatted")func ( TestingT, interface{}, interface{}, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.Exactlyf(, , , , ...) {return } .FailNow()}// Fail reports a failure throughfunc ( TestingT, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.Fail(, , ...) {return } .FailNow()}// FailNow fails testfunc ( TestingT, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.FailNow(, , ...) {return } .FailNow()}// FailNowf fails testfunc ( TestingT, string, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.FailNowf(, , , ...) {return } .FailNow()}// Failf reports a failure throughfunc ( TestingT, string, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.Failf(, , , ...) {return } .FailNow()}// False asserts that the specified value is false.//// require.False(t, myBool)func ( TestingT, bool, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.False(, , ...) {return } .FailNow()}// Falsef asserts that the specified value is false.//// require.Falsef(t, myBool, "error message %s", "formatted")func ( TestingT, bool, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.Falsef(, , , ...) {return } .FailNow()}// FileExists checks whether a file exists in the given path. It also fails if// the path points to a directory or there is an error when trying to check the file.func ( TestingT, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.FileExists(, , ...) {return } .FailNow()}// FileExistsf checks whether a file exists in the given path. It also fails if// the path points to a directory or there is an error when trying to check the file.func ( TestingT, string, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.FileExistsf(, , , ...) {return } .FailNow()}// Greater asserts that the first element is greater than the second//// require.Greater(t, 2, 1)// require.Greater(t, float64(2), float64(1))// require.Greater(t, "b", "a")func ( TestingT, interface{}, interface{}, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.Greater(, , , ...) {return } .FailNow()}// GreaterOrEqual asserts that the first element is greater than or equal to the second//// require.GreaterOrEqual(t, 2, 1)// require.GreaterOrEqual(t, 2, 2)// require.GreaterOrEqual(t, "b", "a")// require.GreaterOrEqual(t, "b", "b")func ( TestingT, interface{}, interface{}, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.GreaterOrEqual(, , , ...) {return } .FailNow()}// GreaterOrEqualf asserts that the first element is greater than or equal to the second//// require.GreaterOrEqualf(t, 2, 1, "error message %s", "formatted")// require.GreaterOrEqualf(t, 2, 2, "error message %s", "formatted")// require.GreaterOrEqualf(t, "b", "a", "error message %s", "formatted")// require.GreaterOrEqualf(t, "b", "b", "error message %s", "formatted")func ( TestingT, interface{}, interface{}, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.GreaterOrEqualf(, , , , ...) {return } .FailNow()}// Greaterf asserts that the first element is greater than the second//// require.Greaterf(t, 2, 1, "error message %s", "formatted")// require.Greaterf(t, float64(2), float64(1), "error message %s", "formatted")// require.Greaterf(t, "b", "a", "error message %s", "formatted")func ( TestingT, interface{}, interface{}, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.Greaterf(, , , , ...) {return } .FailNow()}// HTTPBodyContains asserts that a specified handler returns a// body that contains a string.//// require.HTTPBodyContains(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky")//// Returns whether the assertion was successful (true) or not (false).func ( TestingT, http.HandlerFunc, string, string, url.Values, interface{}, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.HTTPBodyContains(, , , , , , ...) {return } .FailNow()}// HTTPBodyContainsf asserts that a specified handler returns a// body that contains a string.//// require.HTTPBodyContainsf(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted")//// Returns whether the assertion was successful (true) or not (false).func ( TestingT, http.HandlerFunc, string, string, url.Values, interface{}, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.HTTPBodyContainsf(, , , , , , , ...) {return } .FailNow()}// HTTPBodyNotContains asserts that a specified handler returns a// body that does not contain a string.//// require.HTTPBodyNotContains(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky")//// Returns whether the assertion was successful (true) or not (false).func ( TestingT, http.HandlerFunc, string, string, url.Values, interface{}, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.HTTPBodyNotContains(, , , , , , ...) {return } .FailNow()}// HTTPBodyNotContainsf asserts that a specified handler returns a// body that does not contain a string.//// require.HTTPBodyNotContainsf(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted")//// Returns whether the assertion was successful (true) or not (false).func ( TestingT, http.HandlerFunc, string, string, url.Values, interface{}, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.HTTPBodyNotContainsf(, , , , , , , ...) {return } .FailNow()}// HTTPError asserts that a specified handler returns an error status code.//// require.HTTPError(t, myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}}//// Returns whether the assertion was successful (true) or not (false).func ( TestingT, http.HandlerFunc, string, string, url.Values, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.HTTPError(, , , , , ...) {return } .FailNow()}// HTTPErrorf asserts that a specified handler returns an error status code.//// require.HTTPErrorf(t, myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}}//// Returns whether the assertion was successful (true) or not (false).func ( TestingT, http.HandlerFunc, string, string, url.Values, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.HTTPErrorf(, , , , , , ...) {return } .FailNow()}// HTTPRedirect asserts that a specified handler returns a redirect status code.//// require.HTTPRedirect(t, myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}}//// Returns whether the assertion was successful (true) or not (false).func ( TestingT, http.HandlerFunc, string, string, url.Values, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.HTTPRedirect(, , , , , ...) {return } .FailNow()}// HTTPRedirectf asserts that a specified handler returns a redirect status code.//// require.HTTPRedirectf(t, myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}}//// Returns whether the assertion was successful (true) or not (false).func ( TestingT, http.HandlerFunc, string, string, url.Values, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.HTTPRedirectf(, , , , , , ...) {return } .FailNow()}// HTTPStatusCode asserts that a specified handler returns a specified status code.//// require.HTTPStatusCode(t, myHandler, "GET", "/notImplemented", nil, 501)//// Returns whether the assertion was successful (true) or not (false).func ( TestingT, http.HandlerFunc, string, string, url.Values, int, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.HTTPStatusCode(, , , , , , ...) {return } .FailNow()}// HTTPStatusCodef asserts that a specified handler returns a specified status code.//// require.HTTPStatusCodef(t, myHandler, "GET", "/notImplemented", nil, 501, "error message %s", "formatted")//// Returns whether the assertion was successful (true) or not (false).func ( TestingT, http.HandlerFunc, string, string, url.Values, int, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.HTTPStatusCodef(, , , , , , , ...) {return } .FailNow()}// HTTPSuccess asserts that a specified handler returns a success status code.//// require.HTTPSuccess(t, myHandler, "POST", "http://www.google.com", nil)//// Returns whether the assertion was successful (true) or not (false).func ( TestingT, http.HandlerFunc, string, string, url.Values, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.HTTPSuccess(, , , , , ...) {return } .FailNow()}// HTTPSuccessf asserts that a specified handler returns a success status code.//// require.HTTPSuccessf(t, myHandler, "POST", "http://www.google.com", nil, "error message %s", "formatted")//// Returns whether the assertion was successful (true) or not (false).func ( TestingT, http.HandlerFunc, string, string, url.Values, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.HTTPSuccessf(, , , , , , ...) {return } .FailNow()}// Implements asserts that an object is implemented by the specified interface.//// require.Implements(t, (*MyInterface)(nil), new(MyObject))func ( TestingT, interface{}, interface{}, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.Implements(, , , ...) {return } .FailNow()}// Implementsf asserts that an object is implemented by the specified interface.//// require.Implementsf(t, (*MyInterface)(nil), new(MyObject), "error message %s", "formatted")func ( TestingT, interface{}, interface{}, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.Implementsf(, , , , ...) {return } .FailNow()}// InDelta asserts that the two numerals are within delta of each other.//// require.InDelta(t, math.Pi, 22/7.0, 0.01)func ( TestingT, interface{}, interface{}, float64, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.InDelta(, , , , ...) {return } .FailNow()}// InDeltaMapValues is the same as InDelta, but it compares all values between two maps. Both maps must have exactly the same keys.func ( TestingT, interface{}, interface{}, float64, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.InDeltaMapValues(, , , , ...) {return } .FailNow()}// InDeltaMapValuesf is the same as InDelta, but it compares all values between two maps. Both maps must have exactly the same keys.func ( TestingT, interface{}, interface{}, float64, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.InDeltaMapValuesf(, , , , , ...) {return } .FailNow()}// InDeltaSlice is the same as InDelta, except it compares two slices.func ( TestingT, interface{}, interface{}, float64, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.InDeltaSlice(, , , , ...) {return } .FailNow()}// InDeltaSlicef is the same as InDelta, except it compares two slices.func ( TestingT, interface{}, interface{}, float64, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.InDeltaSlicef(, , , , , ...) {return } .FailNow()}// InDeltaf asserts that the two numerals are within delta of each other.//// require.InDeltaf(t, math.Pi, 22/7.0, 0.01, "error message %s", "formatted")func ( TestingT, interface{}, interface{}, float64, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.InDeltaf(, , , , , ...) {return } .FailNow()}// InEpsilon asserts that expected and actual have a relative error less than epsilonfunc ( TestingT, interface{}, interface{}, float64, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.InEpsilon(, , , , ...) {return } .FailNow()}// InEpsilonSlice is the same as InEpsilon, except it compares each value from two slices.func ( TestingT, interface{}, interface{}, float64, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.InEpsilonSlice(, , , , ...) {return } .FailNow()}// InEpsilonSlicef is the same as InEpsilon, except it compares each value from two slices.func ( TestingT, interface{}, interface{}, float64, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.InEpsilonSlicef(, , , , , ...) {return } .FailNow()}// InEpsilonf asserts that expected and actual have a relative error less than epsilonfunc ( TestingT, interface{}, interface{}, float64, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.InEpsilonf(, , , , , ...) {return } .FailNow()}// IsDecreasing asserts that the collection is decreasing//// require.IsDecreasing(t, []int{2, 1, 0})// require.IsDecreasing(t, []float{2, 1})// require.IsDecreasing(t, []string{"b", "a"})func ( TestingT, interface{}, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.IsDecreasing(, , ...) {return } .FailNow()}// IsDecreasingf asserts that the collection is decreasing//// require.IsDecreasingf(t, []int{2, 1, 0}, "error message %s", "formatted")// require.IsDecreasingf(t, []float{2, 1}, "error message %s", "formatted")// require.IsDecreasingf(t, []string{"b", "a"}, "error message %s", "formatted")func ( TestingT, interface{}, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.IsDecreasingf(, , , ...) {return } .FailNow()}// IsIncreasing asserts that the collection is increasing//// require.IsIncreasing(t, []int{1, 2, 3})// require.IsIncreasing(t, []float{1, 2})// require.IsIncreasing(t, []string{"a", "b"})func ( TestingT, interface{}, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.IsIncreasing(, , ...) {return } .FailNow()}// IsIncreasingf asserts that the collection is increasing//// require.IsIncreasingf(t, []int{1, 2, 3}, "error message %s", "formatted")// require.IsIncreasingf(t, []float{1, 2}, "error message %s", "formatted")// require.IsIncreasingf(t, []string{"a", "b"}, "error message %s", "formatted")func ( TestingT, interface{}, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.IsIncreasingf(, , , ...) {return } .FailNow()}// IsNonDecreasing asserts that the collection is not decreasing//// require.IsNonDecreasing(t, []int{1, 1, 2})// require.IsNonDecreasing(t, []float{1, 2})// require.IsNonDecreasing(t, []string{"a", "b"})func ( TestingT, interface{}, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.IsNonDecreasing(, , ...) {return } .FailNow()}// IsNonDecreasingf asserts that the collection is not decreasing//// require.IsNonDecreasingf(t, []int{1, 1, 2}, "error message %s", "formatted")// require.IsNonDecreasingf(t, []float{1, 2}, "error message %s", "formatted")// require.IsNonDecreasingf(t, []string{"a", "b"}, "error message %s", "formatted")func ( TestingT, interface{}, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.IsNonDecreasingf(, , , ...) {return } .FailNow()}// IsNonIncreasing asserts that the collection is not increasing//// require.IsNonIncreasing(t, []int{2, 1, 1})// require.IsNonIncreasing(t, []float{2, 1})// require.IsNonIncreasing(t, []string{"b", "a"})func ( TestingT, interface{}, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.IsNonIncreasing(, , ...) {return } .FailNow()}// IsNonIncreasingf asserts that the collection is not increasing//// require.IsNonIncreasingf(t, []int{2, 1, 1}, "error message %s", "formatted")// require.IsNonIncreasingf(t, []float{2, 1}, "error message %s", "formatted")// require.IsNonIncreasingf(t, []string{"b", "a"}, "error message %s", "formatted")func ( TestingT, interface{}, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.IsNonIncreasingf(, , , ...) {return } .FailNow()}// IsNotType asserts that the specified objects are not of the same type.//// require.IsNotType(t, &NotMyStruct{}, &MyStruct{})func ( TestingT, interface{}, interface{}, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.IsNotType(, , , ...) {return } .FailNow()}// IsNotTypef asserts that the specified objects are not of the same type.//// require.IsNotTypef(t, &NotMyStruct{}, &MyStruct{}, "error message %s", "formatted")func ( TestingT, interface{}, interface{}, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.IsNotTypef(, , , , ...) {return } .FailNow()}// IsType asserts that the specified objects are of the same type.//// require.IsType(t, &MyStruct{}, &MyStruct{})func ( TestingT, interface{}, interface{}, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.IsType(, , , ...) {return } .FailNow()}// IsTypef asserts that the specified objects are of the same type.//// require.IsTypef(t, &MyStruct{}, &MyStruct{}, "error message %s", "formatted")func ( TestingT, interface{}, interface{}, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.IsTypef(, , , , ...) {return } .FailNow()}// JSONEq asserts that two JSON strings are equivalent.//// require.JSONEq(t, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`)func ( TestingT, string, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.JSONEq(, , , ...) {return } .FailNow()}// JSONEqf asserts that two JSON strings are equivalent.//// require.JSONEqf(t, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`, "error message %s", "formatted")func ( TestingT, string, string, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.JSONEqf(, , , , ...) {return } .FailNow()}// Len asserts that the specified object has specific length.// Len also fails if the object has a type that len() not accept.//// require.Len(t, mySlice, 3)func ( TestingT, interface{}, int, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.Len(, , , ...) {return } .FailNow()}// Lenf asserts that the specified object has specific length.// Lenf also fails if the object has a type that len() not accept.//// require.Lenf(t, mySlice, 3, "error message %s", "formatted")func ( TestingT, interface{}, int, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.Lenf(, , , , ...) {return } .FailNow()}// Less asserts that the first element is less than the second//// require.Less(t, 1, 2)// require.Less(t, float64(1), float64(2))// require.Less(t, "a", "b")func ( TestingT, interface{}, interface{}, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.Less(, , , ...) {return } .FailNow()}// LessOrEqual asserts that the first element is less than or equal to the second//// require.LessOrEqual(t, 1, 2)// require.LessOrEqual(t, 2, 2)// require.LessOrEqual(t, "a", "b")// require.LessOrEqual(t, "b", "b")func ( TestingT, interface{}, interface{}, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.LessOrEqual(, , , ...) {return } .FailNow()}// LessOrEqualf asserts that the first element is less than or equal to the second//// require.LessOrEqualf(t, 1, 2, "error message %s", "formatted")// require.LessOrEqualf(t, 2, 2, "error message %s", "formatted")// require.LessOrEqualf(t, "a", "b", "error message %s", "formatted")// require.LessOrEqualf(t, "b", "b", "error message %s", "formatted")func ( TestingT, interface{}, interface{}, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.LessOrEqualf(, , , , ...) {return } .FailNow()}// Lessf asserts that the first element is less than the second//// require.Lessf(t, 1, 2, "error message %s", "formatted")// require.Lessf(t, float64(1), float64(2), "error message %s", "formatted")// require.Lessf(t, "a", "b", "error message %s", "formatted")func ( TestingT, interface{}, interface{}, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.Lessf(, , , , ...) {return } .FailNow()}// Negative asserts that the specified element is negative//// require.Negative(t, -1)// require.Negative(t, -1.23)func ( TestingT, interface{}, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.Negative(, , ...) {return } .FailNow()}// Negativef asserts that the specified element is negative//// require.Negativef(t, -1, "error message %s", "formatted")// require.Negativef(t, -1.23, "error message %s", "formatted")func ( TestingT, interface{}, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.Negativef(, , , ...) {return } .FailNow()}// Never asserts that the given condition doesn't satisfy in waitFor time,// periodically checking the target function each tick.//// require.Never(t, func() bool { return false; }, time.Second, 10*time.Millisecond)func ( TestingT, func() bool, time.Duration, time.Duration, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.Never(, , , , ...) {return } .FailNow()}// Neverf asserts that the given condition doesn't satisfy in waitFor time,// periodically checking the target function each tick.//// require.Neverf(t, func() bool { return false; }, time.Second, 10*time.Millisecond, "error message %s", "formatted")func ( TestingT, func() bool, time.Duration, time.Duration, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.Neverf(, , , , , ...) {return } .FailNow()}// Nil asserts that the specified object is nil.//// require.Nil(t, err)func ( TestingT, interface{}, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.Nil(, , ...) {return } .FailNow()}// Nilf asserts that the specified object is nil.//// require.Nilf(t, err, "error message %s", "formatted")func ( TestingT, interface{}, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.Nilf(, , , ...) {return } .FailNow()}// NoDirExists checks whether a directory does not exist in the given path.// It fails if the path points to an existing _directory_ only.func ( TestingT, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.NoDirExists(, , ...) {return } .FailNow()}// NoDirExistsf checks whether a directory does not exist in the given path.// It fails if the path points to an existing _directory_ only.func ( TestingT, string, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.NoDirExistsf(, , , ...) {return } .FailNow()}// NoError asserts that a function returned no error (i.e. `nil`).//// actualObj, err := SomeFunction()// if require.NoError(t, err) {// require.Equal(t, expectedObj, actualObj)// }func ( TestingT, error, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.NoError(, , ...) {return } .FailNow()}// NoErrorf asserts that a function returned no error (i.e. `nil`).//// actualObj, err := SomeFunction()// if require.NoErrorf(t, err, "error message %s", "formatted") {// require.Equal(t, expectedObj, actualObj)// }func ( TestingT, error, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.NoErrorf(, , , ...) {return } .FailNow()}// NoFileExists checks whether a file does not exist in a given path. It fails// if the path points to an existing _file_ only.func ( TestingT, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.NoFileExists(, , ...) {return } .FailNow()}// NoFileExistsf checks whether a file does not exist in a given path. It fails// if the path points to an existing _file_ only.func ( TestingT, string, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.NoFileExistsf(, , , ...) {return } .FailNow()}// NotContains asserts that the specified string, list(array, slice...) or map does NOT contain the// specified substring or element.//// require.NotContains(t, "Hello World", "Earth")// require.NotContains(t, ["Hello", "World"], "Earth")// require.NotContains(t, {"Hello": "World"}, "Earth")func ( TestingT, interface{}, interface{}, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.NotContains(, , , ...) {return } .FailNow()}// NotContainsf asserts that the specified string, list(array, slice...) or map does NOT contain the// specified substring or element.//// require.NotContainsf(t, "Hello World", "Earth", "error message %s", "formatted")// require.NotContainsf(t, ["Hello", "World"], "Earth", "error message %s", "formatted")// require.NotContainsf(t, {"Hello": "World"}, "Earth", "error message %s", "formatted")func ( TestingT, interface{}, interface{}, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.NotContainsf(, , , , ...) {return } .FailNow()}// NotElementsMatch asserts that the specified listA(array, slice...) is NOT 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 not match.// This is an inverse of ElementsMatch.//// require.NotElementsMatch(t, [1, 1, 2, 3], [1, 1, 2, 3]) -> false//// require.NotElementsMatch(t, [1, 1, 2, 3], [1, 2, 3]) -> true//// require.NotElementsMatch(t, [1, 2, 3], [1, 2, 4]) -> truefunc ( TestingT, interface{}, interface{}, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.NotElementsMatch(, , , ...) {return } .FailNow()}// NotElementsMatchf asserts that the specified listA(array, slice...) is NOT 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 not match.// This is an inverse of ElementsMatch.//// require.NotElementsMatchf(t, [1, 1, 2, 3], [1, 1, 2, 3], "error message %s", "formatted") -> false//// require.NotElementsMatchf(t, [1, 1, 2, 3], [1, 2, 3], "error message %s", "formatted") -> true//// require.NotElementsMatchf(t, [1, 2, 3], [1, 2, 4], "error message %s", "formatted") -> truefunc ( TestingT, interface{}, interface{}, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.NotElementsMatchf(, , , , ...) {return } .FailNow()}// NotEmpty asserts that the specified object is NOT [Empty].//// if require.NotEmpty(t, obj) {// require.Equal(t, "two", obj[1])// }func ( TestingT, interface{}, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.NotEmpty(, , ...) {return } .FailNow()}// NotEmptyf asserts that the specified object is NOT [Empty].//// if require.NotEmptyf(t, obj, "error message %s", "formatted") {// require.Equal(t, "two", obj[1])// }func ( TestingT, interface{}, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.NotEmptyf(, , , ...) {return } .FailNow()}// NotEqual asserts that the specified values are NOT equal.//// require.NotEqual(t, obj1, obj2)//// Pointer variable equality is determined based on the equality of the// referenced values (as opposed to the memory addresses).func ( TestingT, interface{}, interface{}, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.NotEqual(, , , ...) {return } .FailNow()}// NotEqualValues asserts that two objects are not equal even when converted to the same type//// require.NotEqualValues(t, obj1, obj2)func ( TestingT, interface{}, interface{}, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.NotEqualValues(, , , ...) {return } .FailNow()}// NotEqualValuesf asserts that two objects are not equal even when converted to the same type//// require.NotEqualValuesf(t, obj1, obj2, "error message %s", "formatted")func ( TestingT, interface{}, interface{}, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.NotEqualValuesf(, , , , ...) {return } .FailNow()}// NotEqualf asserts that the specified values are NOT equal.//// require.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 ( TestingT, interface{}, interface{}, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.NotEqualf(, , , , ...) {return } .FailNow()}// NotErrorAs asserts that none of the errors in err's chain matches target,// but if so, sets target to that error value.func ( TestingT, error, interface{}, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.NotErrorAs(, , , ...) {return } .FailNow()}// NotErrorAsf asserts that none of the errors in err's chain matches target,// but if so, sets target to that error value.func ( TestingT, error, interface{}, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.NotErrorAsf(, , , , ...) {return } .FailNow()}// NotErrorIs asserts that none of the errors in err's chain matches target.// This is a wrapper for errors.Is.func ( TestingT, error, error, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.NotErrorIs(, , , ...) {return } .FailNow()}// NotErrorIsf asserts that none of the errors in err's chain matches target.// This is a wrapper for errors.Is.func ( TestingT, error, error, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.NotErrorIsf(, , , , ...) {return } .FailNow()}// NotImplements asserts that an object does not implement the specified interface.//// require.NotImplements(t, (*MyInterface)(nil), new(MyObject))func ( TestingT, interface{}, interface{}, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.NotImplements(, , , ...) {return } .FailNow()}// NotImplementsf asserts that an object does not implement the specified interface.//// require.NotImplementsf(t, (*MyInterface)(nil), new(MyObject), "error message %s", "formatted")func ( TestingT, interface{}, interface{}, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.NotImplementsf(, , , , ...) {return } .FailNow()}// NotNil asserts that the specified object is not nil.//// require.NotNil(t, err)func ( TestingT, interface{}, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.NotNil(, , ...) {return } .FailNow()}// NotNilf asserts that the specified object is not nil.//// require.NotNilf(t, err, "error message %s", "formatted")func ( TestingT, interface{}, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.NotNilf(, , , ...) {return } .FailNow()}// NotPanics asserts that the code inside the specified PanicTestFunc does NOT panic.//// require.NotPanics(t, func(){ RemainCalm() })func ( TestingT, assert.PanicTestFunc, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.NotPanics(, , ...) {return } .FailNow()}// NotPanicsf asserts that the code inside the specified PanicTestFunc does NOT panic.//// require.NotPanicsf(t, func(){ RemainCalm() }, "error message %s", "formatted")func ( TestingT, assert.PanicTestFunc, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.NotPanicsf(, , , ...) {return } .FailNow()}// NotRegexp asserts that a specified regexp does not match a string.//// require.NotRegexp(t, regexp.MustCompile("starts"), "it's starting")// require.NotRegexp(t, "^start", "it's not starting")func ( TestingT, interface{}, interface{}, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.NotRegexp(, , , ...) {return } .FailNow()}// NotRegexpf asserts that a specified regexp does not match a string.//// require.NotRegexpf(t, regexp.MustCompile("starts"), "it's starting", "error message %s", "formatted")// require.NotRegexpf(t, "^start", "it's not starting", "error message %s", "formatted")func ( TestingT, interface{}, interface{}, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.NotRegexpf(, , , , ...) {return } .FailNow()}// NotSame asserts that two pointers do not reference the same object.//// require.NotSame(t, ptr1, ptr2)//// Both arguments must be pointer variables. Pointer variable sameness is// determined based on the equality of both type and value.func ( TestingT, interface{}, interface{}, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.NotSame(, , , ...) {return } .FailNow()}// NotSamef asserts that two pointers do not reference the same object.//// require.NotSamef(t, ptr1, ptr2, "error message %s", "formatted")//// Both arguments must be pointer variables. Pointer variable sameness is// determined based on the equality of both type and value.func ( TestingT, interface{}, interface{}, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.NotSamef(, , , , ...) {return } .FailNow()}// NotSubset asserts that the list (array, slice, or map) does NOT contain all// elements given in the subset (array, slice, or map).// Map elements are key-value pairs unless compared with an array or slice where// only the map key is evaluated.//// require.NotSubset(t, [1, 3, 4], [1, 2])// require.NotSubset(t, {"x": 1, "y": 2}, {"z": 3})// require.NotSubset(t, [1, 3, 4], {1: "one", 2: "two"})// require.NotSubset(t, {"x": 1, "y": 2}, ["z"])func ( TestingT, interface{}, interface{}, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.NotSubset(, , , ...) {return } .FailNow()}// NotSubsetf asserts that the list (array, slice, or map) does NOT contain all// elements given in the subset (array, slice, or map).// Map elements are key-value pairs unless compared with an array or slice where// only the map key is evaluated.//// require.NotSubsetf(t, [1, 3, 4], [1, 2], "error message %s", "formatted")// require.NotSubsetf(t, {"x": 1, "y": 2}, {"z": 3}, "error message %s", "formatted")// require.NotSubsetf(t, [1, 3, 4], {1: "one", 2: "two"}, "error message %s", "formatted")// require.NotSubsetf(t, {"x": 1, "y": 2}, ["z"], "error message %s", "formatted")func ( TestingT, interface{}, interface{}, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.NotSubsetf(, , , , ...) {return } .FailNow()}// NotZero asserts that i is not the zero value for its type.func ( TestingT, interface{}, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.NotZero(, , ...) {return } .FailNow()}// NotZerof asserts that i is not the zero value for its type.func ( TestingT, interface{}, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.NotZerof(, , , ...) {return } .FailNow()}// Panics asserts that the code inside the specified PanicTestFunc panics.//// require.Panics(t, func(){ GoCrazy() })func ( TestingT, assert.PanicTestFunc, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.Panics(, , ...) {return } .FailNow()}// PanicsWithError asserts that the code inside the specified PanicTestFunc// panics, and that the recovered panic value is an error that satisfies the// EqualError comparison.//// require.PanicsWithError(t, "crazy error", func(){ GoCrazy() })func ( TestingT, string, assert.PanicTestFunc, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.PanicsWithError(, , , ...) {return } .FailNow()}// PanicsWithErrorf asserts that the code inside the specified PanicTestFunc// panics, and that the recovered panic value is an error that satisfies the// EqualError comparison.//// require.PanicsWithErrorf(t, "crazy error", func(){ GoCrazy() }, "error message %s", "formatted")func ( TestingT, string, assert.PanicTestFunc, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.PanicsWithErrorf(, , , , ...) {return } .FailNow()}// PanicsWithValue asserts that the code inside the specified PanicTestFunc panics, and that// the recovered panic value equals the expected panic value.//// require.PanicsWithValue(t, "crazy error", func(){ GoCrazy() })func ( TestingT, interface{}, assert.PanicTestFunc, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.PanicsWithValue(, , , ...) {return } .FailNow()}// PanicsWithValuef asserts that the code inside the specified PanicTestFunc panics, and that// the recovered panic value equals the expected panic value.//// require.PanicsWithValuef(t, "crazy error", func(){ GoCrazy() }, "error message %s", "formatted")func ( TestingT, interface{}, assert.PanicTestFunc, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.PanicsWithValuef(, , , , ...) {return } .FailNow()}// Panicsf asserts that the code inside the specified PanicTestFunc panics.//// require.Panicsf(t, func(){ GoCrazy() }, "error message %s", "formatted")func ( TestingT, assert.PanicTestFunc, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.Panicsf(, , , ...) {return } .FailNow()}// Positive asserts that the specified element is positive//// require.Positive(t, 1)// require.Positive(t, 1.23)func ( TestingT, interface{}, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.Positive(, , ...) {return } .FailNow()}// Positivef asserts that the specified element is positive//// require.Positivef(t, 1, "error message %s", "formatted")// require.Positivef(t, 1.23, "error message %s", "formatted")func ( TestingT, interface{}, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.Positivef(, , , ...) {return } .FailNow()}// Regexp asserts that a specified regexp matches a string.//// require.Regexp(t, regexp.MustCompile("start"), "it's starting")// require.Regexp(t, "start...$", "it's not starting")func ( TestingT, interface{}, interface{}, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.Regexp(, , , ...) {return } .FailNow()}// Regexpf asserts that a specified regexp matches a string.//// require.Regexpf(t, regexp.MustCompile("start"), "it's starting", "error message %s", "formatted")// require.Regexpf(t, "start...$", "it's not starting", "error message %s", "formatted")func ( TestingT, interface{}, interface{}, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.Regexpf(, , , , ...) {return } .FailNow()}// Same asserts that two pointers reference the same object.//// require.Same(t, ptr1, ptr2)//// Both arguments must be pointer variables. Pointer variable sameness is// determined based on the equality of both type and value.func ( TestingT, interface{}, interface{}, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.Same(, , , ...) {return } .FailNow()}// Samef asserts that two pointers reference the same object.//// require.Samef(t, ptr1, ptr2, "error message %s", "formatted")//// Both arguments must be pointer variables. Pointer variable sameness is// determined based on the equality of both type and value.func ( TestingT, interface{}, interface{}, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.Samef(, , , , ...) {return } .FailNow()}// Subset asserts that the list (array, slice, or map) contains all elements// given in the subset (array, slice, or map).// Map elements are key-value pairs unless compared with an array or slice where// only the map key is evaluated.//// require.Subset(t, [1, 2, 3], [1, 2])// require.Subset(t, {"x": 1, "y": 2}, {"x": 1})// require.Subset(t, [1, 2, 3], {1: "one", 2: "two"})// require.Subset(t, {"x": 1, "y": 2}, ["x"])func ( TestingT, interface{}, interface{}, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.Subset(, , , ...) {return } .FailNow()}// Subsetf asserts that the list (array, slice, or map) contains all elements// given in the subset (array, slice, or map).// Map elements are key-value pairs unless compared with an array or slice where// only the map key is evaluated.//// require.Subsetf(t, [1, 2, 3], [1, 2], "error message %s", "formatted")// require.Subsetf(t, {"x": 1, "y": 2}, {"x": 1}, "error message %s", "formatted")// require.Subsetf(t, [1, 2, 3], {1: "one", 2: "two"}, "error message %s", "formatted")// require.Subsetf(t, {"x": 1, "y": 2}, ["x"], "error message %s", "formatted")func ( TestingT, interface{}, interface{}, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.Subsetf(, , , , ...) {return } .FailNow()}// True asserts that the specified value is true.//// require.True(t, myBool)func ( TestingT, bool, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.True(, , ...) {return } .FailNow()}// Truef asserts that the specified value is true.//// require.Truef(t, myBool, "error message %s", "formatted")func ( TestingT, bool, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.Truef(, , , ...) {return } .FailNow()}// WithinDuration asserts that the two times are within duration delta of each other.//// require.WithinDuration(t, time.Now(), time.Now(), 10*time.Second)func ( TestingT, time.Time, time.Time, time.Duration, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.WithinDuration(, , , , ...) {return } .FailNow()}// WithinDurationf asserts that the two times are within duration delta of each other.//// require.WithinDurationf(t, time.Now(), time.Now(), 10*time.Second, "error message %s", "formatted")func ( TestingT, time.Time, time.Time, time.Duration, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.WithinDurationf(, , , , , ...) {return } .FailNow()}// WithinRange asserts that a time is within a time range (inclusive).//// require.WithinRange(t, time.Now(), time.Now().Add(-time.Second), time.Now().Add(time.Second))func ( TestingT, time.Time, time.Time, time.Time, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.WithinRange(, , , , ...) {return } .FailNow()}// WithinRangef asserts that a time is within a time range (inclusive).//// require.WithinRangef(t, time.Now(), time.Now().Add(-time.Second), time.Now().Add(time.Second), "error message %s", "formatted")func ( TestingT, time.Time, time.Time, time.Time, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.WithinRangef(, , , , , ...) {return } .FailNow()}// YAMLEq asserts that two YAML strings are equivalent.func ( TestingT, string, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.YAMLEq(, , , ...) {return } .FailNow()}// YAMLEqf asserts that two YAML strings are equivalent.func ( TestingT, string, string, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.YAMLEqf(, , , , ...) {return } .FailNow()}// Zero asserts that i is the zero value for its type.func ( TestingT, interface{}, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.Zero(, , ...) {return } .FailNow()}// Zerof asserts that i is the zero value for its type.func ( TestingT, interface{}, string, ...interface{}) {if , := .(tHelper); { .Helper() }ifassert.Zerof(, , , ...) {return } .FailNow()}
The pages are generated with Goldsv0.8.2. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.