blob: 27e2420ed2e76d2766aea60566912d1428341222 [file] [log] [blame]
Elia Battistonc8d0d462022-02-22 16:30:51 +01001/*
2* CODE GENERATED AUTOMATICALLY WITH github.com/stretchr/testify/_codegen
3* THIS FILE MUST NOT BE EDITED BY HAND
4 */
5
6package assert
7
8import (
9 http "net/http"
10 url "net/url"
11 time "time"
12)
13
14// Conditionf uses a Comparison to assert a complex condition.
15func Conditionf(t TestingT, comp Comparison, msg string, args ...interface{}) bool {
16 if h, ok := t.(tHelper); ok {
17 h.Helper()
18 }
19 return Condition(t, comp, append([]interface{}{msg}, args...)...)
20}
21
22// Containsf asserts that the specified string, list(array, slice...) or map contains the
23// specified substring or element.
24//
25// assert.Containsf(t, "Hello World", "World", "error message %s", "formatted")
26// assert.Containsf(t, ["Hello", "World"], "World", "error message %s", "formatted")
27// assert.Containsf(t, {"Hello": "World"}, "Hello", "error message %s", "formatted")
28func Containsf(t TestingT, s interface{}, contains interface{}, msg string, args ...interface{}) bool {
29 if h, ok := t.(tHelper); ok {
30 h.Helper()
31 }
32 return Contains(t, s, contains, append([]interface{}{msg}, args...)...)
33}
34
35// DirExistsf checks whether a directory exists in the given path. It also fails
36// if the path is a file rather a directory or there is an error checking whether it exists.
37func DirExistsf(t TestingT, path string, msg string, args ...interface{}) bool {
38 if h, ok := t.(tHelper); ok {
39 h.Helper()
40 }
41 return DirExists(t, path, append([]interface{}{msg}, args...)...)
42}
43
44// ElementsMatchf asserts that the specified listA(array, slice...) is equal to specified
45// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements,
46// the number of appearances of each of them in both lists should match.
47//
48// assert.ElementsMatchf(t, [1, 3, 2, 3], [1, 3, 3, 2], "error message %s", "formatted")
49func ElementsMatchf(t TestingT, listA interface{}, listB interface{}, msg string, args ...interface{}) bool {
50 if h, ok := t.(tHelper); ok {
51 h.Helper()
52 }
53 return ElementsMatch(t, listA, listB, append([]interface{}{msg}, args...)...)
54}
55
56// Emptyf asserts that the specified object is empty. I.e. nil, "", false, 0 or either
57// a slice or a channel with len == 0.
58//
59// assert.Emptyf(t, obj, "error message %s", "formatted")
60func Emptyf(t TestingT, object interface{}, msg string, args ...interface{}) bool {
61 if h, ok := t.(tHelper); ok {
62 h.Helper()
63 }
64 return Empty(t, object, append([]interface{}{msg}, args...)...)
65}
66
67// Equalf asserts that two objects are equal.
68//
69// assert.Equalf(t, 123, 123, "error message %s", "formatted")
70//
71// Pointer variable equality is determined based on the equality of the
72// referenced values (as opposed to the memory addresses). Function equality
73// cannot be determined and will always fail.
74func Equalf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
75 if h, ok := t.(tHelper); ok {
76 h.Helper()
77 }
78 return Equal(t, expected, actual, append([]interface{}{msg}, args...)...)
79}
80
81// EqualErrorf asserts that a function returned an error (i.e. not `nil`)
82// and that it is equal to the provided error.
83//
84// actualObj, err := SomeFunction()
85// assert.EqualErrorf(t, err, expectedErrorString, "error message %s", "formatted")
86func EqualErrorf(t TestingT, theError error, errString string, msg string, args ...interface{}) bool {
87 if h, ok := t.(tHelper); ok {
88 h.Helper()
89 }
90 return EqualError(t, theError, errString, append([]interface{}{msg}, args...)...)
91}
92
93// EqualValuesf asserts that two objects are equal or convertable to the same types
94// and equal.
95//
96// assert.EqualValuesf(t, uint32(123), int32(123), "error message %s", "formatted")
97func EqualValuesf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
98 if h, ok := t.(tHelper); ok {
99 h.Helper()
100 }
101 return EqualValues(t, expected, actual, append([]interface{}{msg}, args...)...)
102}
103
104// Errorf asserts that a function returned an error (i.e. not `nil`).
105//
106// actualObj, err := SomeFunction()
107// if assert.Errorf(t, err, "error message %s", "formatted") {
108// assert.Equal(t, expectedErrorf, err)
109// }
110func Errorf(t TestingT, err error, msg string, args ...interface{}) bool {
111 if h, ok := t.(tHelper); ok {
112 h.Helper()
113 }
114 return Error(t, err, append([]interface{}{msg}, args...)...)
115}
116
117// ErrorAsf asserts that at least one of the errors in err's chain matches target, and if so, sets target to that error value.
118// This is a wrapper for errors.As.
119func ErrorAsf(t TestingT, err error, target interface{}, msg string, args ...interface{}) bool {
120 if h, ok := t.(tHelper); ok {
121 h.Helper()
122 }
123 return ErrorAs(t, err, target, append([]interface{}{msg}, args...)...)
124}
125
Elia Battiston4750d3c2022-07-14 13:24:56 +0000126// ErrorContainsf asserts that a function returned an error (i.e. not `nil`)
127// and that the error contains the specified substring.
128//
129// actualObj, err := SomeFunction()
130// assert.ErrorContainsf(t, err, expectedErrorSubString, "error message %s", "formatted")
131func ErrorContainsf(t TestingT, theError error, contains string, msg string, args ...interface{}) bool {
132 if h, ok := t.(tHelper); ok {
133 h.Helper()
134 }
135 return ErrorContains(t, theError, contains, append([]interface{}{msg}, args...)...)
136}
137
Elia Battistonc8d0d462022-02-22 16:30:51 +0100138// ErrorIsf asserts that at least one of the errors in err's chain matches target.
139// This is a wrapper for errors.Is.
140func ErrorIsf(t TestingT, err error, target error, msg string, args ...interface{}) bool {
141 if h, ok := t.(tHelper); ok {
142 h.Helper()
143 }
144 return ErrorIs(t, err, target, append([]interface{}{msg}, args...)...)
145}
146
147// Eventuallyf asserts that given condition will be met in waitFor time,
148// periodically checking target function each tick.
149//
150// assert.Eventuallyf(t, func() bool { return true; }, time.Second, 10*time.Millisecond, "error message %s", "formatted")
151func Eventuallyf(t TestingT, condition func() bool, waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) bool {
152 if h, ok := t.(tHelper); ok {
153 h.Helper()
154 }
155 return Eventually(t, condition, waitFor, tick, append([]interface{}{msg}, args...)...)
156}
157
158// Exactlyf asserts that two objects are equal in value and type.
159//
160// assert.Exactlyf(t, int32(123), int64(123), "error message %s", "formatted")
161func Exactlyf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
162 if h, ok := t.(tHelper); ok {
163 h.Helper()
164 }
165 return Exactly(t, expected, actual, append([]interface{}{msg}, args...)...)
166}
167
168// Failf reports a failure through
169func Failf(t TestingT, failureMessage string, msg string, args ...interface{}) bool {
170 if h, ok := t.(tHelper); ok {
171 h.Helper()
172 }
173 return Fail(t, failureMessage, append([]interface{}{msg}, args...)...)
174}
175
176// FailNowf fails test
177func FailNowf(t TestingT, failureMessage string, msg string, args ...interface{}) bool {
178 if h, ok := t.(tHelper); ok {
179 h.Helper()
180 }
181 return FailNow(t, failureMessage, append([]interface{}{msg}, args...)...)
182}
183
184// Falsef asserts that the specified value is false.
185//
186// assert.Falsef(t, myBool, "error message %s", "formatted")
187func Falsef(t TestingT, value bool, msg string, args ...interface{}) bool {
188 if h, ok := t.(tHelper); ok {
189 h.Helper()
190 }
191 return False(t, value, append([]interface{}{msg}, args...)...)
192}
193
194// FileExistsf checks whether a file exists in the given path. It also fails if
195// the path points to a directory or there is an error when trying to check the file.
196func FileExistsf(t TestingT, path string, msg string, args ...interface{}) bool {
197 if h, ok := t.(tHelper); ok {
198 h.Helper()
199 }
200 return FileExists(t, path, append([]interface{}{msg}, args...)...)
201}
202
203// Greaterf asserts that the first element is greater than the second
204//
205// assert.Greaterf(t, 2, 1, "error message %s", "formatted")
206// assert.Greaterf(t, float64(2), float64(1), "error message %s", "formatted")
207// assert.Greaterf(t, "b", "a", "error message %s", "formatted")
208func Greaterf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool {
209 if h, ok := t.(tHelper); ok {
210 h.Helper()
211 }
212 return Greater(t, e1, e2, append([]interface{}{msg}, args...)...)
213}
214
215// GreaterOrEqualf asserts that the first element is greater than or equal to the second
216//
217// assert.GreaterOrEqualf(t, 2, 1, "error message %s", "formatted")
218// assert.GreaterOrEqualf(t, 2, 2, "error message %s", "formatted")
219// assert.GreaterOrEqualf(t, "b", "a", "error message %s", "formatted")
220// assert.GreaterOrEqualf(t, "b", "b", "error message %s", "formatted")
221func GreaterOrEqualf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool {
222 if h, ok := t.(tHelper); ok {
223 h.Helper()
224 }
225 return GreaterOrEqual(t, e1, e2, append([]interface{}{msg}, args...)...)
226}
227
228// HTTPBodyContainsf asserts that a specified handler returns a
229// body that contains a string.
230//
231// assert.HTTPBodyContainsf(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted")
232//
233// Returns whether the assertion was successful (true) or not (false).
234func HTTPBodyContainsf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) bool {
235 if h, ok := t.(tHelper); ok {
236 h.Helper()
237 }
238 return HTTPBodyContains(t, handler, method, url, values, str, append([]interface{}{msg}, args...)...)
239}
240
241// HTTPBodyNotContainsf asserts that a specified handler returns a
242// body that does not contain a string.
243//
244// assert.HTTPBodyNotContainsf(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted")
245//
246// Returns whether the assertion was successful (true) or not (false).
247func HTTPBodyNotContainsf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) bool {
248 if h, ok := t.(tHelper); ok {
249 h.Helper()
250 }
251 return HTTPBodyNotContains(t, handler, method, url, values, str, append([]interface{}{msg}, args...)...)
252}
253
254// HTTPErrorf asserts that a specified handler returns an error status code.
255//
256// assert.HTTPErrorf(t, myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}}
257//
258// Returns whether the assertion was successful (true) or not (false).
259func HTTPErrorf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) bool {
260 if h, ok := t.(tHelper); ok {
261 h.Helper()
262 }
263 return HTTPError(t, handler, method, url, values, append([]interface{}{msg}, args...)...)
264}
265
266// HTTPRedirectf asserts that a specified handler returns a redirect status code.
267//
268// assert.HTTPRedirectf(t, myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}}
269//
270// Returns whether the assertion was successful (true) or not (false).
271func HTTPRedirectf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) bool {
272 if h, ok := t.(tHelper); ok {
273 h.Helper()
274 }
275 return HTTPRedirect(t, handler, method, url, values, append([]interface{}{msg}, args...)...)
276}
277
278// HTTPStatusCodef asserts that a specified handler returns a specified status code.
279//
280// assert.HTTPStatusCodef(t, myHandler, "GET", "/notImplemented", nil, 501, "error message %s", "formatted")
281//
282// Returns whether the assertion was successful (true) or not (false).
283func HTTPStatusCodef(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, statuscode int, msg string, args ...interface{}) bool {
284 if h, ok := t.(tHelper); ok {
285 h.Helper()
286 }
287 return HTTPStatusCode(t, handler, method, url, values, statuscode, append([]interface{}{msg}, args...)...)
288}
289
290// HTTPSuccessf asserts that a specified handler returns a success status code.
291//
292// assert.HTTPSuccessf(t, myHandler, "POST", "http://www.google.com", nil, "error message %s", "formatted")
293//
294// Returns whether the assertion was successful (true) or not (false).
295func HTTPSuccessf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) bool {
296 if h, ok := t.(tHelper); ok {
297 h.Helper()
298 }
299 return HTTPSuccess(t, handler, method, url, values, append([]interface{}{msg}, args...)...)
300}
301
302// Implementsf asserts that an object is implemented by the specified interface.
303//
304// assert.Implementsf(t, (*MyInterface)(nil), new(MyObject), "error message %s", "formatted")
305func Implementsf(t TestingT, interfaceObject interface{}, object interface{}, msg string, args ...interface{}) bool {
306 if h, ok := t.(tHelper); ok {
307 h.Helper()
308 }
309 return Implements(t, interfaceObject, object, append([]interface{}{msg}, args...)...)
310}
311
312// InDeltaf asserts that the two numerals are within delta of each other.
313//
314// assert.InDeltaf(t, math.Pi, 22/7.0, 0.01, "error message %s", "formatted")
315func InDeltaf(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool {
316 if h, ok := t.(tHelper); ok {
317 h.Helper()
318 }
319 return InDelta(t, expected, actual, delta, append([]interface{}{msg}, args...)...)
320}
321
322// InDeltaMapValuesf is the same as InDelta, but it compares all values between two maps. Both maps must have exactly the same keys.
323func InDeltaMapValuesf(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool {
324 if h, ok := t.(tHelper); ok {
325 h.Helper()
326 }
327 return InDeltaMapValues(t, expected, actual, delta, append([]interface{}{msg}, args...)...)
328}
329
330// InDeltaSlicef is the same as InDelta, except it compares two slices.
331func InDeltaSlicef(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool {
332 if h, ok := t.(tHelper); ok {
333 h.Helper()
334 }
335 return InDeltaSlice(t, expected, actual, delta, append([]interface{}{msg}, args...)...)
336}
337
338// InEpsilonf asserts that expected and actual have a relative error less than epsilon
339func InEpsilonf(t TestingT, expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) bool {
340 if h, ok := t.(tHelper); ok {
341 h.Helper()
342 }
343 return InEpsilon(t, expected, actual, epsilon, append([]interface{}{msg}, args...)...)
344}
345
346// InEpsilonSlicef is the same as InEpsilon, except it compares each value from two slices.
347func InEpsilonSlicef(t TestingT, expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) bool {
348 if h, ok := t.(tHelper); ok {
349 h.Helper()
350 }
351 return InEpsilonSlice(t, expected, actual, epsilon, append([]interface{}{msg}, args...)...)
352}
353
354// IsDecreasingf asserts that the collection is decreasing
355//
356// assert.IsDecreasingf(t, []int{2, 1, 0}, "error message %s", "formatted")
357// assert.IsDecreasingf(t, []float{2, 1}, "error message %s", "formatted")
358// assert.IsDecreasingf(t, []string{"b", "a"}, "error message %s", "formatted")
359func IsDecreasingf(t TestingT, object interface{}, msg string, args ...interface{}) bool {
360 if h, ok := t.(tHelper); ok {
361 h.Helper()
362 }
363 return IsDecreasing(t, object, append([]interface{}{msg}, args...)...)
364}
365
366// IsIncreasingf asserts that the collection is increasing
367//
368// assert.IsIncreasingf(t, []int{1, 2, 3}, "error message %s", "formatted")
369// assert.IsIncreasingf(t, []float{1, 2}, "error message %s", "formatted")
370// assert.IsIncreasingf(t, []string{"a", "b"}, "error message %s", "formatted")
371func IsIncreasingf(t TestingT, object interface{}, msg string, args ...interface{}) bool {
372 if h, ok := t.(tHelper); ok {
373 h.Helper()
374 }
375 return IsIncreasing(t, object, append([]interface{}{msg}, args...)...)
376}
377
378// IsNonDecreasingf asserts that the collection is not decreasing
379//
380// assert.IsNonDecreasingf(t, []int{1, 1, 2}, "error message %s", "formatted")
381// assert.IsNonDecreasingf(t, []float{1, 2}, "error message %s", "formatted")
382// assert.IsNonDecreasingf(t, []string{"a", "b"}, "error message %s", "formatted")
383func IsNonDecreasingf(t TestingT, object interface{}, msg string, args ...interface{}) bool {
384 if h, ok := t.(tHelper); ok {
385 h.Helper()
386 }
387 return IsNonDecreasing(t, object, append([]interface{}{msg}, args...)...)
388}
389
390// IsNonIncreasingf asserts that the collection is not increasing
391//
392// assert.IsNonIncreasingf(t, []int{2, 1, 1}, "error message %s", "formatted")
393// assert.IsNonIncreasingf(t, []float{2, 1}, "error message %s", "formatted")
394// assert.IsNonIncreasingf(t, []string{"b", "a"}, "error message %s", "formatted")
395func IsNonIncreasingf(t TestingT, object interface{}, msg string, args ...interface{}) bool {
396 if h, ok := t.(tHelper); ok {
397 h.Helper()
398 }
399 return IsNonIncreasing(t, object, append([]interface{}{msg}, args...)...)
400}
401
402// IsTypef asserts that the specified objects are of the same type.
403func IsTypef(t TestingT, expectedType interface{}, object interface{}, msg string, args ...interface{}) bool {
404 if h, ok := t.(tHelper); ok {
405 h.Helper()
406 }
407 return IsType(t, expectedType, object, append([]interface{}{msg}, args...)...)
408}
409
410// JSONEqf asserts that two JSON strings are equivalent.
411//
412// assert.JSONEqf(t, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`, "error message %s", "formatted")
413func JSONEqf(t TestingT, expected string, actual string, msg string, args ...interface{}) bool {
414 if h, ok := t.(tHelper); ok {
415 h.Helper()
416 }
417 return JSONEq(t, expected, actual, append([]interface{}{msg}, args...)...)
418}
419
420// Lenf asserts that the specified object has specific length.
421// Lenf also fails if the object has a type that len() not accept.
422//
423// assert.Lenf(t, mySlice, 3, "error message %s", "formatted")
424func Lenf(t TestingT, object interface{}, length int, msg string, args ...interface{}) bool {
425 if h, ok := t.(tHelper); ok {
426 h.Helper()
427 }
428 return Len(t, object, length, append([]interface{}{msg}, args...)...)
429}
430
431// Lessf asserts that the first element is less than the second
432//
433// assert.Lessf(t, 1, 2, "error message %s", "formatted")
434// assert.Lessf(t, float64(1), float64(2), "error message %s", "formatted")
435// assert.Lessf(t, "a", "b", "error message %s", "formatted")
436func Lessf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool {
437 if h, ok := t.(tHelper); ok {
438 h.Helper()
439 }
440 return Less(t, e1, e2, append([]interface{}{msg}, args...)...)
441}
442
443// LessOrEqualf asserts that the first element is less than or equal to the second
444//
445// assert.LessOrEqualf(t, 1, 2, "error message %s", "formatted")
446// assert.LessOrEqualf(t, 2, 2, "error message %s", "formatted")
447// assert.LessOrEqualf(t, "a", "b", "error message %s", "formatted")
448// assert.LessOrEqualf(t, "b", "b", "error message %s", "formatted")
449func LessOrEqualf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool {
450 if h, ok := t.(tHelper); ok {
451 h.Helper()
452 }
453 return LessOrEqual(t, e1, e2, append([]interface{}{msg}, args...)...)
454}
455
456// Negativef asserts that the specified element is negative
457//
458// assert.Negativef(t, -1, "error message %s", "formatted")
459// assert.Negativef(t, -1.23, "error message %s", "formatted")
460func Negativef(t TestingT, e interface{}, msg string, args ...interface{}) bool {
461 if h, ok := t.(tHelper); ok {
462 h.Helper()
463 }
464 return Negative(t, e, append([]interface{}{msg}, args...)...)
465}
466
467// Neverf asserts that the given condition doesn't satisfy in waitFor time,
468// periodically checking the target function each tick.
469//
470// assert.Neverf(t, func() bool { return false; }, time.Second, 10*time.Millisecond, "error message %s", "formatted")
471func Neverf(t TestingT, condition func() bool, waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) bool {
472 if h, ok := t.(tHelper); ok {
473 h.Helper()
474 }
475 return Never(t, condition, waitFor, tick, append([]interface{}{msg}, args...)...)
476}
477
478// Nilf asserts that the specified object is nil.
479//
480// assert.Nilf(t, err, "error message %s", "formatted")
481func Nilf(t TestingT, object interface{}, msg string, args ...interface{}) bool {
482 if h, ok := t.(tHelper); ok {
483 h.Helper()
484 }
485 return Nil(t, object, append([]interface{}{msg}, args...)...)
486}
487
488// NoDirExistsf checks whether a directory does not exist in the given path.
489// It fails if the path points to an existing _directory_ only.
490func NoDirExistsf(t TestingT, path string, msg string, args ...interface{}) bool {
491 if h, ok := t.(tHelper); ok {
492 h.Helper()
493 }
494 return NoDirExists(t, path, append([]interface{}{msg}, args...)...)
495}
496
497// NoErrorf asserts that a function returned no error (i.e. `nil`).
498//
499// actualObj, err := SomeFunction()
500// if assert.NoErrorf(t, err, "error message %s", "formatted") {
501// assert.Equal(t, expectedObj, actualObj)
502// }
503func NoErrorf(t TestingT, err error, msg string, args ...interface{}) bool {
504 if h, ok := t.(tHelper); ok {
505 h.Helper()
506 }
507 return NoError(t, err, append([]interface{}{msg}, args...)...)
508}
509
510// NoFileExistsf checks whether a file does not exist in a given path. It fails
511// if the path points to an existing _file_ only.
512func NoFileExistsf(t TestingT, path string, msg string, args ...interface{}) bool {
513 if h, ok := t.(tHelper); ok {
514 h.Helper()
515 }
516 return NoFileExists(t, path, append([]interface{}{msg}, args...)...)
517}
518
519// NotContainsf asserts that the specified string, list(array, slice...) or map does NOT contain the
520// specified substring or element.
521//
522// assert.NotContainsf(t, "Hello World", "Earth", "error message %s", "formatted")
523// assert.NotContainsf(t, ["Hello", "World"], "Earth", "error message %s", "formatted")
524// assert.NotContainsf(t, {"Hello": "World"}, "Earth", "error message %s", "formatted")
525func NotContainsf(t TestingT, s interface{}, contains interface{}, msg string, args ...interface{}) bool {
526 if h, ok := t.(tHelper); ok {
527 h.Helper()
528 }
529 return NotContains(t, s, contains, append([]interface{}{msg}, args...)...)
530}
531
532// NotEmptyf asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either
533// a slice or a channel with len == 0.
534//
535// if assert.NotEmptyf(t, obj, "error message %s", "formatted") {
536// assert.Equal(t, "two", obj[1])
537// }
538func NotEmptyf(t TestingT, object interface{}, msg string, args ...interface{}) bool {
539 if h, ok := t.(tHelper); ok {
540 h.Helper()
541 }
542 return NotEmpty(t, object, append([]interface{}{msg}, args...)...)
543}
544
545// NotEqualf asserts that the specified values are NOT equal.
546//
547// assert.NotEqualf(t, obj1, obj2, "error message %s", "formatted")
548//
549// Pointer variable equality is determined based on the equality of the
550// referenced values (as opposed to the memory addresses).
551func NotEqualf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
552 if h, ok := t.(tHelper); ok {
553 h.Helper()
554 }
555 return NotEqual(t, expected, actual, append([]interface{}{msg}, args...)...)
556}
557
558// NotEqualValuesf asserts that two objects are not equal even when converted to the same type
559//
560// assert.NotEqualValuesf(t, obj1, obj2, "error message %s", "formatted")
561func NotEqualValuesf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
562 if h, ok := t.(tHelper); ok {
563 h.Helper()
564 }
565 return NotEqualValues(t, expected, actual, append([]interface{}{msg}, args...)...)
566}
567
568// NotErrorIsf asserts that at none of the errors in err's chain matches target.
569// This is a wrapper for errors.Is.
570func NotErrorIsf(t TestingT, err error, target error, msg string, args ...interface{}) bool {
571 if h, ok := t.(tHelper); ok {
572 h.Helper()
573 }
574 return NotErrorIs(t, err, target, append([]interface{}{msg}, args...)...)
575}
576
577// NotNilf asserts that the specified object is not nil.
578//
579// assert.NotNilf(t, err, "error message %s", "formatted")
580func NotNilf(t TestingT, object interface{}, msg string, args ...interface{}) bool {
581 if h, ok := t.(tHelper); ok {
582 h.Helper()
583 }
584 return NotNil(t, object, append([]interface{}{msg}, args...)...)
585}
586
587// NotPanicsf asserts that the code inside the specified PanicTestFunc does NOT panic.
588//
589// assert.NotPanicsf(t, func(){ RemainCalm() }, "error message %s", "formatted")
590func NotPanicsf(t TestingT, f PanicTestFunc, msg string, args ...interface{}) bool {
591 if h, ok := t.(tHelper); ok {
592 h.Helper()
593 }
594 return NotPanics(t, f, append([]interface{}{msg}, args...)...)
595}
596
597// NotRegexpf asserts that a specified regexp does not match a string.
598//
599// assert.NotRegexpf(t, regexp.MustCompile("starts"), "it's starting", "error message %s", "formatted")
600// assert.NotRegexpf(t, "^start", "it's not starting", "error message %s", "formatted")
601func NotRegexpf(t TestingT, rx interface{}, str interface{}, msg string, args ...interface{}) bool {
602 if h, ok := t.(tHelper); ok {
603 h.Helper()
604 }
605 return NotRegexp(t, rx, str, append([]interface{}{msg}, args...)...)
606}
607
608// NotSamef asserts that two pointers do not reference the same object.
609//
610// assert.NotSamef(t, ptr1, ptr2, "error message %s", "formatted")
611//
612// Both arguments must be pointer variables. Pointer variable sameness is
613// determined based on the equality of both type and value.
614func NotSamef(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
615 if h, ok := t.(tHelper); ok {
616 h.Helper()
617 }
618 return NotSame(t, expected, actual, append([]interface{}{msg}, args...)...)
619}
620
621// NotSubsetf asserts that the specified list(array, slice...) contains not all
622// elements given in the specified subset(array, slice...).
623//
624// assert.NotSubsetf(t, [1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]", "error message %s", "formatted")
625func NotSubsetf(t TestingT, list interface{}, subset interface{}, msg string, args ...interface{}) bool {
626 if h, ok := t.(tHelper); ok {
627 h.Helper()
628 }
629 return NotSubset(t, list, subset, append([]interface{}{msg}, args...)...)
630}
631
632// NotZerof asserts that i is not the zero value for its type.
633func NotZerof(t TestingT, i interface{}, msg string, args ...interface{}) bool {
634 if h, ok := t.(tHelper); ok {
635 h.Helper()
636 }
637 return NotZero(t, i, append([]interface{}{msg}, args...)...)
638}
639
640// Panicsf asserts that the code inside the specified PanicTestFunc panics.
641//
642// assert.Panicsf(t, func(){ GoCrazy() }, "error message %s", "formatted")
643func Panicsf(t TestingT, f PanicTestFunc, msg string, args ...interface{}) bool {
644 if h, ok := t.(tHelper); ok {
645 h.Helper()
646 }
647 return Panics(t, f, append([]interface{}{msg}, args...)...)
648}
649
650// PanicsWithErrorf asserts that the code inside the specified PanicTestFunc
651// panics, and that the recovered panic value is an error that satisfies the
652// EqualError comparison.
653//
654// assert.PanicsWithErrorf(t, "crazy error", func(){ GoCrazy() }, "error message %s", "formatted")
655func PanicsWithErrorf(t TestingT, errString string, f PanicTestFunc, msg string, args ...interface{}) bool {
656 if h, ok := t.(tHelper); ok {
657 h.Helper()
658 }
659 return PanicsWithError(t, errString, f, append([]interface{}{msg}, args...)...)
660}
661
662// PanicsWithValuef asserts that the code inside the specified PanicTestFunc panics, and that
663// the recovered panic value equals the expected panic value.
664//
665// assert.PanicsWithValuef(t, "crazy error", func(){ GoCrazy() }, "error message %s", "formatted")
666func PanicsWithValuef(t TestingT, expected interface{}, f PanicTestFunc, msg string, args ...interface{}) bool {
667 if h, ok := t.(tHelper); ok {
668 h.Helper()
669 }
670 return PanicsWithValue(t, expected, f, append([]interface{}{msg}, args...)...)
671}
672
673// Positivef asserts that the specified element is positive
674//
675// assert.Positivef(t, 1, "error message %s", "formatted")
676// assert.Positivef(t, 1.23, "error message %s", "formatted")
677func Positivef(t TestingT, e interface{}, msg string, args ...interface{}) bool {
678 if h, ok := t.(tHelper); ok {
679 h.Helper()
680 }
681 return Positive(t, e, append([]interface{}{msg}, args...)...)
682}
683
684// Regexpf asserts that a specified regexp matches a string.
685//
686// assert.Regexpf(t, regexp.MustCompile("start"), "it's starting", "error message %s", "formatted")
687// assert.Regexpf(t, "start...$", "it's not starting", "error message %s", "formatted")
688func Regexpf(t TestingT, rx interface{}, str interface{}, msg string, args ...interface{}) bool {
689 if h, ok := t.(tHelper); ok {
690 h.Helper()
691 }
692 return Regexp(t, rx, str, append([]interface{}{msg}, args...)...)
693}
694
695// Samef asserts that two pointers reference the same object.
696//
697// assert.Samef(t, ptr1, ptr2, "error message %s", "formatted")
698//
699// Both arguments must be pointer variables. Pointer variable sameness is
700// determined based on the equality of both type and value.
701func Samef(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
702 if h, ok := t.(tHelper); ok {
703 h.Helper()
704 }
705 return Same(t, expected, actual, append([]interface{}{msg}, args...)...)
706}
707
708// Subsetf asserts that the specified list(array, slice...) contains all
709// elements given in the specified subset(array, slice...).
710//
711// assert.Subsetf(t, [1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]", "error message %s", "formatted")
712func Subsetf(t TestingT, list interface{}, subset interface{}, msg string, args ...interface{}) bool {
713 if h, ok := t.(tHelper); ok {
714 h.Helper()
715 }
716 return Subset(t, list, subset, append([]interface{}{msg}, args...)...)
717}
718
719// Truef asserts that the specified value is true.
720//
721// assert.Truef(t, myBool, "error message %s", "formatted")
722func Truef(t TestingT, value bool, msg string, args ...interface{}) bool {
723 if h, ok := t.(tHelper); ok {
724 h.Helper()
725 }
726 return True(t, value, append([]interface{}{msg}, args...)...)
727}
728
729// WithinDurationf asserts that the two times are within duration delta of each other.
730//
731// assert.WithinDurationf(t, time.Now(), time.Now(), 10*time.Second, "error message %s", "formatted")
732func WithinDurationf(t TestingT, expected time.Time, actual time.Time, delta time.Duration, msg string, args ...interface{}) bool {
733 if h, ok := t.(tHelper); ok {
734 h.Helper()
735 }
736 return WithinDuration(t, expected, actual, delta, append([]interface{}{msg}, args...)...)
737}
738
739// YAMLEqf asserts that two YAML strings are equivalent.
740func YAMLEqf(t TestingT, expected string, actual string, msg string, args ...interface{}) bool {
741 if h, ok := t.(tHelper); ok {
742 h.Helper()
743 }
744 return YAMLEq(t, expected, actual, append([]interface{}{msg}, args...)...)
745}
746
747// Zerof asserts that i is the zero value for its type.
748func Zerof(t TestingT, i interface{}, msg string, args ...interface{}) bool {
749 if h, ok := t.(tHelper); ok {
750 h.Helper()
751 }
752 return Zero(t, i, append([]interface{}{msg}, args...)...)
753}