1// Code generated with github.com/stretchr/testify/_codegen; DO NOT EDIT.
11// Conditionf uses a Comparison to assert a complex condition.
12func Conditionf(t TestingT, comp Comparison, msg string, args ...interface{}) bool {
13 if h, ok := t.(tHelper); ok {
16 return Condition(t, comp, append([]interface{}{msg}, args...)...)
19// Containsf asserts that the specified string, list(array, slice...) or map contains the
20// specified substring or element.
22// assert.Containsf(t, "Hello World", "World", "error message %s", "formatted")
23// assert.Containsf(t, ["Hello", "World"], "World", "error message %s", "formatted")
24// assert.Containsf(t, {"Hello": "World"}, "Hello", "error message %s", "formatted")
25func Containsf(t TestingT, s interface{}, contains interface{}, msg string, args ...interface{}) bool {
26 if h, ok := t.(tHelper); ok {
29 return Contains(t, s, contains, append([]interface{}{msg}, args...)...)
32// DirExistsf checks whether a directory exists in the given path. It also fails
33// if the path is a file rather a directory or there is an error checking whether it exists.
34func DirExistsf(t TestingT, path string, msg string, args ...interface{}) bool {
35 if h, ok := t.(tHelper); ok {
38 return DirExists(t, path, append([]interface{}{msg}, args...)...)
41// ElementsMatchf asserts that the specified listA(array, slice...) is equal to specified
42// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements,
43// the number of appearances of each of them in both lists should match.
45// assert.ElementsMatchf(t, [1, 3, 2, 3], [1, 3, 3, 2], "error message %s", "formatted")
46func ElementsMatchf(t TestingT, listA interface{}, listB interface{}, msg string, args ...interface{}) bool {
47 if h, ok := t.(tHelper); ok {
50 return ElementsMatch(t, listA, listB, append([]interface{}{msg}, args...)...)
53// Emptyf asserts that the specified object is empty. I.e. nil, "", false, 0 or either
54// a slice or a channel with len == 0.
56// assert.Emptyf(t, obj, "error message %s", "formatted")
57func Emptyf(t TestingT, object interface{}, msg string, args ...interface{}) bool {
58 if h, ok := t.(tHelper); ok {
61 return Empty(t, object, append([]interface{}{msg}, args...)...)
64// Equalf asserts that two objects are equal.
66// assert.Equalf(t, 123, 123, "error message %s", "formatted")
68// Pointer variable equality is determined based on the equality of the
69// referenced values (as opposed to the memory addresses). Function equality
70// cannot be determined and will always fail.
71func Equalf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
72 if h, ok := t.(tHelper); ok {
75 return Equal(t, expected, actual, append([]interface{}{msg}, args...)...)
78// EqualErrorf asserts that a function returned an error (i.e. not `nil`)
79// and that it is equal to the provided error.
81// actualObj, err := SomeFunction()
82// assert.EqualErrorf(t, err, expectedErrorString, "error message %s", "formatted")
83func EqualErrorf(t TestingT, theError error, errString string, msg string, args ...interface{}) bool {
84 if h, ok := t.(tHelper); ok {
87 return EqualError(t, theError, errString, append([]interface{}{msg}, args...)...)
90// EqualExportedValuesf asserts that the types of two objects are equal and their public
91// fields are also equal. This is useful for comparing structs that have private fields
92// that could potentially differ.
98// assert.EqualExportedValuesf(t, S{1, 2}, S{1, 3}, "error message %s", "formatted") => true
99// assert.EqualExportedValuesf(t, S{1, 2}, S{2, 3}, "error message %s", "formatted") => false
100func EqualExportedValuesf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
101 if h, ok := t.(tHelper); ok {
104 return EqualExportedValues(t, expected, actual, append([]interface{}{msg}, args...)...)
107// EqualValuesf asserts that two objects are equal or convertible to the larger
110// assert.EqualValuesf(t, uint32(123), int32(123), "error message %s", "formatted")
111func EqualValuesf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
112 if h, ok := t.(tHelper); ok {
115 return EqualValues(t, expected, actual, append([]interface{}{msg}, args...)...)
118// Errorf asserts that a function returned an error (i.e. not `nil`).
120// actualObj, err := SomeFunction()
121// if assert.Errorf(t, err, "error message %s", "formatted") {
122// assert.Equal(t, expectedErrorf, err)
124func Errorf(t TestingT, err error, msg string, args ...interface{}) bool {
125 if h, ok := t.(tHelper); ok {
128 return Error(t, err, append([]interface{}{msg}, args...)...)
131// ErrorAsf asserts that at least one of the errors in err's chain matches target, and if so, sets target to that error value.
132// This is a wrapper for errors.As.
133func ErrorAsf(t TestingT, err error, target interface{}, msg string, args ...interface{}) bool {
134 if h, ok := t.(tHelper); ok {
137 return ErrorAs(t, err, target, append([]interface{}{msg}, args...)...)
140// ErrorContainsf asserts that a function returned an error (i.e. not `nil`)
141// and that the error contains the specified substring.
143// actualObj, err := SomeFunction()
144// assert.ErrorContainsf(t, err, expectedErrorSubString, "error message %s", "formatted")
145func ErrorContainsf(t TestingT, theError error, contains string, msg string, args ...interface{}) bool {
146 if h, ok := t.(tHelper); ok {
149 return ErrorContains(t, theError, contains, append([]interface{}{msg}, args...)...)
152// ErrorIsf asserts that at least one of the errors in err's chain matches target.
153// This is a wrapper for errors.Is.
154func ErrorIsf(t TestingT, err error, target error, msg string, args ...interface{}) bool {
155 if h, ok := t.(tHelper); ok {
158 return ErrorIs(t, err, target, append([]interface{}{msg}, args...)...)
161// Eventuallyf asserts that given condition will be met in waitFor time,
162// periodically checking target function each tick.
164// assert.Eventuallyf(t, func() bool { return true; }, time.Second, 10*time.Millisecond, "error message %s", "formatted")
165func Eventuallyf(t TestingT, condition func() bool, waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) bool {
166 if h, ok := t.(tHelper); ok {
169 return Eventually(t, condition, waitFor, tick, append([]interface{}{msg}, args...)...)
172// EventuallyWithTf asserts that given condition will be met in waitFor time,
173// periodically checking target function each tick. In contrast to Eventually,
174// it supplies a CollectT to the condition function, so that the condition
175// function can use the CollectT to call other assertions.
176// The condition is considered "met" if no errors are raised in a tick.
177// The supplied CollectT collects all errors from one tick (if there are any).
178// If the condition is not met before waitFor, the collected errors of
179// the last tick are copied to t.
181// externalValue := false
183// time.Sleep(8*time.Second)
184// externalValue = true
186// assert.EventuallyWithTf(t, func(c *assert.CollectT, "error message %s", "formatted") {
187// // add assertions as needed; any assertion failure will fail the current tick
188// assert.True(c, externalValue, "expected 'externalValue' to be true")
189// }, 10*time.Second, 1*time.Second, "external state has not changed to 'true'; still false")
190func EventuallyWithTf(t TestingT, condition func(collect *CollectT), waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) bool {
191 if h, ok := t.(tHelper); ok {
194 return EventuallyWithT(t, condition, waitFor, tick, append([]interface{}{msg}, args...)...)
197// Exactlyf asserts that two objects are equal in value and type.
199// assert.Exactlyf(t, int32(123), int64(123), "error message %s", "formatted")
200func Exactlyf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
201 if h, ok := t.(tHelper); ok {
204 return Exactly(t, expected, actual, append([]interface{}{msg}, args...)...)
207// Failf reports a failure through
208func Failf(t TestingT, failureMessage string, msg string, args ...interface{}) bool {
209 if h, ok := t.(tHelper); ok {
212 return Fail(t, failureMessage, append([]interface{}{msg}, args...)...)
215// FailNowf fails test
216func FailNowf(t TestingT, failureMessage string, msg string, args ...interface{}) bool {
217 if h, ok := t.(tHelper); ok {
220 return FailNow(t, failureMessage, append([]interface{}{msg}, args...)...)
223// Falsef asserts that the specified value is false.
225// assert.Falsef(t, myBool, "error message %s", "formatted")
226func Falsef(t TestingT, value bool, msg string, args ...interface{}) bool {
227 if h, ok := t.(tHelper); ok {
230 return False(t, value, append([]interface{}{msg}, args...)...)
233// FileExistsf checks whether a file exists in the given path. It also fails if
234// the path points to a directory or there is an error when trying to check the file.
235func FileExistsf(t TestingT, path string, msg string, args ...interface{}) bool {
236 if h, ok := t.(tHelper); ok {
239 return FileExists(t, path, append([]interface{}{msg}, args...)...)
242// Greaterf asserts that the first element is greater than the second
244// assert.Greaterf(t, 2, 1, "error message %s", "formatted")
245// assert.Greaterf(t, float64(2), float64(1), "error message %s", "formatted")
246// assert.Greaterf(t, "b", "a", "error message %s", "formatted")
247func Greaterf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool {
248 if h, ok := t.(tHelper); ok {
251 return Greater(t, e1, e2, append([]interface{}{msg}, args...)...)
254// GreaterOrEqualf asserts that the first element is greater than or equal to the second
256// assert.GreaterOrEqualf(t, 2, 1, "error message %s", "formatted")
257// assert.GreaterOrEqualf(t, 2, 2, "error message %s", "formatted")
258// assert.GreaterOrEqualf(t, "b", "a", "error message %s", "formatted")
259// assert.GreaterOrEqualf(t, "b", "b", "error message %s", "formatted")
260func GreaterOrEqualf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool {
261 if h, ok := t.(tHelper); ok {
264 return GreaterOrEqual(t, e1, e2, append([]interface{}{msg}, args...)...)
267// HTTPBodyContainsf asserts that a specified handler returns a
268// body that contains a string.
270// assert.HTTPBodyContainsf(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted")
272// Returns whether the assertion was successful (true) or not (false).
273func HTTPBodyContainsf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) bool {
274 if h, ok := t.(tHelper); ok {
277 return HTTPBodyContains(t, handler, method, url, values, str, append([]interface{}{msg}, args...)...)
280// HTTPBodyNotContainsf asserts that a specified handler returns a
281// body that does not contain a string.
283// assert.HTTPBodyNotContainsf(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted")
285// Returns whether the assertion was successful (true) or not (false).
286func HTTPBodyNotContainsf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) bool {
287 if h, ok := t.(tHelper); ok {
290 return HTTPBodyNotContains(t, handler, method, url, values, str, append([]interface{}{msg}, args...)...)
293// HTTPErrorf asserts that a specified handler returns an error status code.
295// assert.HTTPErrorf(t, myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}}
297// Returns whether the assertion was successful (true) or not (false).
298func HTTPErrorf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) bool {
299 if h, ok := t.(tHelper); ok {
302 return HTTPError(t, handler, method, url, values, append([]interface{}{msg}, args...)...)
305// HTTPRedirectf asserts that a specified handler returns a redirect status code.
307// assert.HTTPRedirectf(t, myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}}
309// Returns whether the assertion was successful (true) or not (false).
310func HTTPRedirectf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) bool {
311 if h, ok := t.(tHelper); ok {
314 return HTTPRedirect(t, handler, method, url, values, append([]interface{}{msg}, args...)...)
317// HTTPStatusCodef asserts that a specified handler returns a specified status code.
319// assert.HTTPStatusCodef(t, myHandler, "GET", "/notImplemented", nil, 501, "error message %s", "formatted")
321// Returns whether the assertion was successful (true) or not (false).
322func HTTPStatusCodef(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, statuscode int, msg string, args ...interface{}) bool {
323 if h, ok := t.(tHelper); ok {
326 return HTTPStatusCode(t, handler, method, url, values, statuscode, append([]interface{}{msg}, args...)...)
329// HTTPSuccessf asserts that a specified handler returns a success status code.
331// assert.HTTPSuccessf(t, myHandler, "POST", "http://www.google.com", nil, "error message %s", "formatted")
333// Returns whether the assertion was successful (true) or not (false).
334func HTTPSuccessf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) bool {
335 if h, ok := t.(tHelper); ok {
338 return HTTPSuccess(t, handler, method, url, values, append([]interface{}{msg}, args...)...)
341// Implementsf asserts that an object is implemented by the specified interface.
343// assert.Implementsf(t, (*MyInterface)(nil), new(MyObject), "error message %s", "formatted")
344func Implementsf(t TestingT, interfaceObject interface{}, object interface{}, msg string, args ...interface{}) bool {
345 if h, ok := t.(tHelper); ok {
348 return Implements(t, interfaceObject, object, append([]interface{}{msg}, args...)...)
351// InDeltaf asserts that the two numerals are within delta of each other.
353// assert.InDeltaf(t, math.Pi, 22/7.0, 0.01, "error message %s", "formatted")
354func InDeltaf(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool {
355 if h, ok := t.(tHelper); ok {
358 return InDelta(t, expected, actual, delta, append([]interface{}{msg}, args...)...)
361// InDeltaMapValuesf is the same as InDelta, but it compares all values between two maps. Both maps must have exactly the same keys.
362func InDeltaMapValuesf(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool {
363 if h, ok := t.(tHelper); ok {
366 return InDeltaMapValues(t, expected, actual, delta, append([]interface{}{msg}, args...)...)
369// InDeltaSlicef is the same as InDelta, except it compares two slices.
370func InDeltaSlicef(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool {
371 if h, ok := t.(tHelper); ok {
374 return InDeltaSlice(t, expected, actual, delta, append([]interface{}{msg}, args...)...)
377// InEpsilonf asserts that expected and actual have a relative error less than epsilon
378func InEpsilonf(t TestingT, expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) bool {
379 if h, ok := t.(tHelper); ok {
382 return InEpsilon(t, expected, actual, epsilon, append([]interface{}{msg}, args...)...)
385// InEpsilonSlicef is the same as InEpsilon, except it compares each value from two slices.
386func InEpsilonSlicef(t TestingT, expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) bool {
387 if h, ok := t.(tHelper); ok {
390 return InEpsilonSlice(t, expected, actual, epsilon, append([]interface{}{msg}, args...)...)
393// IsDecreasingf asserts that the collection is decreasing
395// assert.IsDecreasingf(t, []int{2, 1, 0}, "error message %s", "formatted")
396// assert.IsDecreasingf(t, []float{2, 1}, "error message %s", "formatted")
397// assert.IsDecreasingf(t, []string{"b", "a"}, "error message %s", "formatted")
398func IsDecreasingf(t TestingT, object interface{}, msg string, args ...interface{}) bool {
399 if h, ok := t.(tHelper); ok {
402 return IsDecreasing(t, object, append([]interface{}{msg}, args...)...)
405// IsIncreasingf asserts that the collection is increasing
407// assert.IsIncreasingf(t, []int{1, 2, 3}, "error message %s", "formatted")
408// assert.IsIncreasingf(t, []float{1, 2}, "error message %s", "formatted")
409// assert.IsIncreasingf(t, []string{"a", "b"}, "error message %s", "formatted")
410func IsIncreasingf(t TestingT, object interface{}, msg string, args ...interface{}) bool {
411 if h, ok := t.(tHelper); ok {
414 return IsIncreasing(t, object, append([]interface{}{msg}, args...)...)
417// IsNonDecreasingf asserts that the collection is not decreasing
419// assert.IsNonDecreasingf(t, []int{1, 1, 2}, "error message %s", "formatted")
420// assert.IsNonDecreasingf(t, []float{1, 2}, "error message %s", "formatted")
421// assert.IsNonDecreasingf(t, []string{"a", "b"}, "error message %s", "formatted")
422func IsNonDecreasingf(t TestingT, object interface{}, msg string, args ...interface{}) bool {
423 if h, ok := t.(tHelper); ok {
426 return IsNonDecreasing(t, object, append([]interface{}{msg}, args...)...)
429// IsNonIncreasingf asserts that the collection is not increasing
431// assert.IsNonIncreasingf(t, []int{2, 1, 1}, "error message %s", "formatted")
432// assert.IsNonIncreasingf(t, []float{2, 1}, "error message %s", "formatted")
433// assert.IsNonIncreasingf(t, []string{"b", "a"}, "error message %s", "formatted")
434func IsNonIncreasingf(t TestingT, object interface{}, msg string, args ...interface{}) bool {
435 if h, ok := t.(tHelper); ok {
438 return IsNonIncreasing(t, object, append([]interface{}{msg}, args...)...)
441// IsTypef asserts that the specified objects are of the same type.
442func IsTypef(t TestingT, expectedType interface{}, object interface{}, msg string, args ...interface{}) bool {
443 if h, ok := t.(tHelper); ok {
446 return IsType(t, expectedType, object, append([]interface{}{msg}, args...)...)
449// JSONEqf asserts that two JSON strings are equivalent.
451// assert.JSONEqf(t, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`, "error message %s", "formatted")
452func JSONEqf(t TestingT, expected string, actual string, msg string, args ...interface{}) bool {
453 if h, ok := t.(tHelper); ok {
456 return JSONEq(t, expected, actual, append([]interface{}{msg}, args...)...)
459// Lenf asserts that the specified object has specific length.
460// Lenf also fails if the object has a type that len() not accept.
462// assert.Lenf(t, mySlice, 3, "error message %s", "formatted")
463func Lenf(t TestingT, object interface{}, length int, msg string, args ...interface{}) bool {
464 if h, ok := t.(tHelper); ok {
467 return Len(t, object, length, append([]interface{}{msg}, args...)...)
470// Lessf asserts that the first element is less than the second
472// assert.Lessf(t, 1, 2, "error message %s", "formatted")
473// assert.Lessf(t, float64(1), float64(2), "error message %s", "formatted")
474// assert.Lessf(t, "a", "b", "error message %s", "formatted")
475func Lessf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool {
476 if h, ok := t.(tHelper); ok {
479 return Less(t, e1, e2, append([]interface{}{msg}, args...)...)
482// LessOrEqualf asserts that the first element is less than or equal to the second
484// assert.LessOrEqualf(t, 1, 2, "error message %s", "formatted")
485// assert.LessOrEqualf(t, 2, 2, "error message %s", "formatted")
486// assert.LessOrEqualf(t, "a", "b", "error message %s", "formatted")
487// assert.LessOrEqualf(t, "b", "b", "error message %s", "formatted")
488func LessOrEqualf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool {
489 if h, ok := t.(tHelper); ok {
492 return LessOrEqual(t, e1, e2, append([]interface{}{msg}, args...)...)
495// Negativef asserts that the specified element is negative
497// assert.Negativef(t, -1, "error message %s", "formatted")
498// assert.Negativef(t, -1.23, "error message %s", "formatted")
499func Negativef(t TestingT, e interface{}, msg string, args ...interface{}) bool {
500 if h, ok := t.(tHelper); ok {
503 return Negative(t, e, append([]interface{}{msg}, args...)...)
506// Neverf asserts that the given condition doesn't satisfy in waitFor time,
507// periodically checking the target function each tick.
509// assert.Neverf(t, func() bool { return false; }, time.Second, 10*time.Millisecond, "error message %s", "formatted")
510func Neverf(t TestingT, condition func() bool, waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) bool {
511 if h, ok := t.(tHelper); ok {
514 return Never(t, condition, waitFor, tick, append([]interface{}{msg}, args...)...)
517// Nilf asserts that the specified object is nil.
519// assert.Nilf(t, err, "error message %s", "formatted")
520func Nilf(t TestingT, object interface{}, msg string, args ...interface{}) bool {
521 if h, ok := t.(tHelper); ok {
524 return Nil(t, object, append([]interface{}{msg}, args...)...)
527// NoDirExistsf checks whether a directory does not exist in the given path.
528// It fails if the path points to an existing _directory_ only.
529func NoDirExistsf(t TestingT, path string, msg string, args ...interface{}) bool {
530 if h, ok := t.(tHelper); ok {
533 return NoDirExists(t, path, append([]interface{}{msg}, args...)...)
536// NoErrorf asserts that a function returned no error (i.e. `nil`).
538// actualObj, err := SomeFunction()
539// if assert.NoErrorf(t, err, "error message %s", "formatted") {
540// assert.Equal(t, expectedObj, actualObj)
542func NoErrorf(t TestingT, err error, msg string, args ...interface{}) bool {
543 if h, ok := t.(tHelper); ok {
546 return NoError(t, err, append([]interface{}{msg}, args...)...)
549// NoFileExistsf checks whether a file does not exist in a given path. It fails
550// if the path points to an existing _file_ only.
551func NoFileExistsf(t TestingT, path string, msg string, args ...interface{}) bool {
552 if h, ok := t.(tHelper); ok {
555 return NoFileExists(t, path, append([]interface{}{msg}, args...)...)
558// NotContainsf asserts that the specified string, list(array, slice...) or map does NOT contain the
559// specified substring or element.
561// assert.NotContainsf(t, "Hello World", "Earth", "error message %s", "formatted")
562// assert.NotContainsf(t, ["Hello", "World"], "Earth", "error message %s", "formatted")
563// assert.NotContainsf(t, {"Hello": "World"}, "Earth", "error message %s", "formatted")
564func NotContainsf(t TestingT, s interface{}, contains interface{}, msg string, args ...interface{}) bool {
565 if h, ok := t.(tHelper); ok {
568 return NotContains(t, s, contains, append([]interface{}{msg}, args...)...)
571// NotElementsMatchf asserts that the specified listA(array, slice...) is NOT equal to specified
572// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements,
573// the number of appearances of each of them in both lists should not match.
574// This is an inverse of ElementsMatch.
576// assert.NotElementsMatchf(t, [1, 1, 2, 3], [1, 1, 2, 3], "error message %s", "formatted") -> false
578// assert.NotElementsMatchf(t, [1, 1, 2, 3], [1, 2, 3], "error message %s", "formatted") -> true
580// assert.NotElementsMatchf(t, [1, 2, 3], [1, 2, 4], "error message %s", "formatted") -> true
581func NotElementsMatchf(t TestingT, listA interface{}, listB interface{}, msg string, args ...interface{}) bool {
582 if h, ok := t.(tHelper); ok {
585 return NotElementsMatch(t, listA, listB, append([]interface{}{msg}, args...)...)
588// NotEmptyf asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either
589// a slice or a channel with len == 0.
591// if assert.NotEmptyf(t, obj, "error message %s", "formatted") {
592// assert.Equal(t, "two", obj[1])
594func NotEmptyf(t TestingT, object interface{}, msg string, args ...interface{}) bool {
595 if h, ok := t.(tHelper); ok {
598 return NotEmpty(t, object, append([]interface{}{msg}, args...)...)
601// NotEqualf asserts that the specified values are NOT equal.
603// assert.NotEqualf(t, obj1, obj2, "error message %s", "formatted")
605// Pointer variable equality is determined based on the equality of the
606// referenced values (as opposed to the memory addresses).
607func NotEqualf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
608 if h, ok := t.(tHelper); ok {
611 return NotEqual(t, expected, actual, append([]interface{}{msg}, args...)...)
614// NotEqualValuesf asserts that two objects are not equal even when converted to the same type
616// assert.NotEqualValuesf(t, obj1, obj2, "error message %s", "formatted")
617func NotEqualValuesf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
618 if h, ok := t.(tHelper); ok {
621 return NotEqualValues(t, expected, actual, append([]interface{}{msg}, args...)...)
624// NotErrorAsf asserts that none of the errors in err's chain matches target,
625// but if so, sets target to that error value.
626func NotErrorAsf(t TestingT, err error, target interface{}, msg string, args ...interface{}) bool {
627 if h, ok := t.(tHelper); ok {
630 return NotErrorAs(t, err, target, append([]interface{}{msg}, args...)...)
633// NotErrorIsf asserts that none of the errors in err's chain matches target.
634// This is a wrapper for errors.Is.
635func NotErrorIsf(t TestingT, err error, target error, msg string, args ...interface{}) bool {
636 if h, ok := t.(tHelper); ok {
639 return NotErrorIs(t, err, target, append([]interface{}{msg}, args...)...)
642// NotImplementsf asserts that an object does not implement the specified interface.
644// assert.NotImplementsf(t, (*MyInterface)(nil), new(MyObject), "error message %s", "formatted")
645func NotImplementsf(t TestingT, interfaceObject interface{}, object interface{}, msg string, args ...interface{}) bool {
646 if h, ok := t.(tHelper); ok {
649 return NotImplements(t, interfaceObject, object, append([]interface{}{msg}, args...)...)
652// NotNilf asserts that the specified object is not nil.
654// assert.NotNilf(t, err, "error message %s", "formatted")
655func NotNilf(t TestingT, object interface{}, msg string, args ...interface{}) bool {
656 if h, ok := t.(tHelper); ok {
659 return NotNil(t, object, append([]interface{}{msg}, args...)...)
662// NotPanicsf asserts that the code inside the specified PanicTestFunc does NOT panic.
664// assert.NotPanicsf(t, func(){ RemainCalm() }, "error message %s", "formatted")
665func NotPanicsf(t TestingT, f PanicTestFunc, msg string, args ...interface{}) bool {
666 if h, ok := t.(tHelper); ok {
669 return NotPanics(t, f, append([]interface{}{msg}, args...)...)
672// NotRegexpf asserts that a specified regexp does not match a string.
674// assert.NotRegexpf(t, regexp.MustCompile("starts"), "it's starting", "error message %s", "formatted")
675// assert.NotRegexpf(t, "^start", "it's not starting", "error message %s", "formatted")
676func NotRegexpf(t TestingT, rx interface{}, str interface{}, msg string, args ...interface{}) bool {
677 if h, ok := t.(tHelper); ok {
680 return NotRegexp(t, rx, str, append([]interface{}{msg}, args...)...)
683// NotSamef asserts that two pointers do not reference the same object.
685// assert.NotSamef(t, ptr1, ptr2, "error message %s", "formatted")
687// Both arguments must be pointer variables. Pointer variable sameness is
688// determined based on the equality of both type and value.
689func NotSamef(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
690 if h, ok := t.(tHelper); ok {
693 return NotSame(t, expected, actual, append([]interface{}{msg}, args...)...)
696// NotSubsetf asserts that the specified list(array, slice...) or map does NOT
697// contain all elements given in the specified subset list(array, slice...) or
700// assert.NotSubsetf(t, [1, 3, 4], [1, 2], "error message %s", "formatted")
701// assert.NotSubsetf(t, {"x": 1, "y": 2}, {"z": 3}, "error message %s", "formatted")
702func NotSubsetf(t TestingT, list interface{}, subset interface{}, msg string, args ...interface{}) bool {
703 if h, ok := t.(tHelper); ok {
706 return NotSubset(t, list, subset, append([]interface{}{msg}, args...)...)
709// NotZerof asserts that i is not the zero value for its type.
710func NotZerof(t TestingT, i interface{}, msg string, args ...interface{}) bool {
711 if h, ok := t.(tHelper); ok {
714 return NotZero(t, i, append([]interface{}{msg}, args...)...)
717// Panicsf asserts that the code inside the specified PanicTestFunc panics.
719// assert.Panicsf(t, func(){ GoCrazy() }, "error message %s", "formatted")
720func Panicsf(t TestingT, f PanicTestFunc, msg string, args ...interface{}) bool {
721 if h, ok := t.(tHelper); ok {
724 return Panics(t, f, append([]interface{}{msg}, args...)...)
727// PanicsWithErrorf asserts that the code inside the specified PanicTestFunc
728// panics, and that the recovered panic value is an error that satisfies the
729// EqualError comparison.
731// assert.PanicsWithErrorf(t, "crazy error", func(){ GoCrazy() }, "error message %s", "formatted")
732func PanicsWithErrorf(t TestingT, errString string, f PanicTestFunc, msg string, args ...interface{}) bool {
733 if h, ok := t.(tHelper); ok {
736 return PanicsWithError(t, errString, f, append([]interface{}{msg}, args...)...)
739// PanicsWithValuef asserts that the code inside the specified PanicTestFunc panics, and that
740// the recovered panic value equals the expected panic value.
742// assert.PanicsWithValuef(t, "crazy error", func(){ GoCrazy() }, "error message %s", "formatted")
743func PanicsWithValuef(t TestingT, expected interface{}, f PanicTestFunc, msg string, args ...interface{}) bool {
744 if h, ok := t.(tHelper); ok {
747 return PanicsWithValue(t, expected, f, append([]interface{}{msg}, args...)...)
750// Positivef asserts that the specified element is positive
752// assert.Positivef(t, 1, "error message %s", "formatted")
753// assert.Positivef(t, 1.23, "error message %s", "formatted")
754func Positivef(t TestingT, e interface{}, msg string, args ...interface{}) bool {
755 if h, ok := t.(tHelper); ok {
758 return Positive(t, e, append([]interface{}{msg}, args...)...)
761// Regexpf asserts that a specified regexp matches a string.
763// assert.Regexpf(t, regexp.MustCompile("start"), "it's starting", "error message %s", "formatted")
764// assert.Regexpf(t, "start...$", "it's not starting", "error message %s", "formatted")
765func Regexpf(t TestingT, rx interface{}, str interface{}, msg string, args ...interface{}) bool {
766 if h, ok := t.(tHelper); ok {
769 return Regexp(t, rx, str, append([]interface{}{msg}, args...)...)
772// Samef asserts that two pointers reference the same object.
774// assert.Samef(t, ptr1, ptr2, "error message %s", "formatted")
776// Both arguments must be pointer variables. Pointer variable sameness is
777// determined based on the equality of both type and value.
778func Samef(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
779 if h, ok := t.(tHelper); ok {
782 return Same(t, expected, actual, append([]interface{}{msg}, args...)...)
785// Subsetf asserts that the specified list(array, slice...) or map contains all
786// elements given in the specified subset list(array, slice...) or map.
788// assert.Subsetf(t, [1, 2, 3], [1, 2], "error message %s", "formatted")
789// assert.Subsetf(t, {"x": 1, "y": 2}, {"x": 1}, "error message %s", "formatted")
790func Subsetf(t TestingT, list interface{}, subset interface{}, msg string, args ...interface{}) bool {
791 if h, ok := t.(tHelper); ok {
794 return Subset(t, list, subset, append([]interface{}{msg}, args...)...)
797// Truef asserts that the specified value is true.
799// assert.Truef(t, myBool, "error message %s", "formatted")
800func Truef(t TestingT, value bool, msg string, args ...interface{}) bool {
801 if h, ok := t.(tHelper); ok {
804 return True(t, value, append([]interface{}{msg}, args...)...)
807// WithinDurationf asserts that the two times are within duration delta of each other.
809// assert.WithinDurationf(t, time.Now(), time.Now(), 10*time.Second, "error message %s", "formatted")
810func WithinDurationf(t TestingT, expected time.Time, actual time.Time, delta time.Duration, msg string, args ...interface{}) bool {
811 if h, ok := t.(tHelper); ok {
814 return WithinDuration(t, expected, actual, delta, append([]interface{}{msg}, args...)...)
817// WithinRangef asserts that a time is within a time range (inclusive).
819// assert.WithinRangef(t, time.Now(), time.Now().Add(-time.Second), time.Now().Add(time.Second), "error message %s", "formatted")
820func WithinRangef(t TestingT, actual time.Time, start time.Time, end time.Time, msg string, args ...interface{}) bool {
821 if h, ok := t.(tHelper); ok {
824 return WithinRange(t, actual, start, end, append([]interface{}{msg}, args...)...)
827// YAMLEqf asserts that two YAML strings are equivalent.
828func YAMLEqf(t TestingT, expected string, actual string, msg string, args ...interface{}) bool {
829 if h, ok := t.(tHelper); ok {
832 return YAMLEq(t, expected, actual, append([]interface{}{msg}, args...)...)
835// Zerof asserts that i is the zero value for its type.
836func Zerof(t TestingT, i interface{}, msg string, args ...interface{}) bool {
837 if h, ok := t.(tHelper); ok {
840 return Zero(t, i, append([]interface{}{msg}, args...)...)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list