blob: 51820df2e6726fe50df902ff53c6a2a08bc344e8 [file] [log] [blame]
amit.ghosh6ab2a982022-09-15 21:04:53 +02001/*
2* CODE GENERATED AUTOMATICALLY WITH github.com/stretchr/testify/_codegen
3* THIS FILE MUST NOT BE EDITED BY HAND
4 */
5
6package require
7
8import (
9 assert "github.com/stretchr/testify/assert"
10 http "net/http"
11 url "net/url"
12 time "time"
13)
14
15// Condition uses a Comparison to assert a complex condition.
16func Condition(t TestingT, comp assert.Comparison, msgAndArgs ...interface{}) {
17 if h, ok := t.(tHelper); ok {
18 h.Helper()
19 }
20 if assert.Condition(t, comp, msgAndArgs...) {
21 return
22 }
23 t.FailNow()
24}
25
26// Conditionf uses a Comparison to assert a complex condition.
27func Conditionf(t TestingT, comp assert.Comparison, msg string, args ...interface{}) {
28 if h, ok := t.(tHelper); ok {
29 h.Helper()
30 }
31 if assert.Conditionf(t, comp, msg, args...) {
32 return
33 }
34 t.FailNow()
35}
36
37// Contains asserts that the specified string, list(array, slice...) or map contains the
38// specified substring or element.
39//
40// assert.Contains(t, "Hello World", "World")
41// assert.Contains(t, ["Hello", "World"], "World")
42// assert.Contains(t, {"Hello": "World"}, "Hello")
43func Contains(t TestingT, s interface{}, contains interface{}, msgAndArgs ...interface{}) {
44 if h, ok := t.(tHelper); ok {
45 h.Helper()
46 }
47 if assert.Contains(t, s, contains, msgAndArgs...) {
48 return
49 }
50 t.FailNow()
51}
52
53// Containsf asserts that the specified string, list(array, slice...) or map contains the
54// specified substring or element.
55//
56// assert.Containsf(t, "Hello World", "World", "error message %s", "formatted")
57// assert.Containsf(t, ["Hello", "World"], "World", "error message %s", "formatted")
58// assert.Containsf(t, {"Hello": "World"}, "Hello", "error message %s", "formatted")
59func Containsf(t TestingT, s interface{}, contains interface{}, msg string, args ...interface{}) {
60 if h, ok := t.(tHelper); ok {
61 h.Helper()
62 }
63 if assert.Containsf(t, s, contains, msg, args...) {
64 return
65 }
66 t.FailNow()
67}
68
69// DirExists checks whether a directory exists in the given path. It also fails
70// if the path is a file rather a directory or there is an error checking whether it exists.
71func DirExists(t TestingT, path string, msgAndArgs ...interface{}) {
72 if h, ok := t.(tHelper); ok {
73 h.Helper()
74 }
75 if assert.DirExists(t, path, msgAndArgs...) {
76 return
77 }
78 t.FailNow()
79}
80
81// DirExistsf checks whether a directory exists in the given path. It also fails
82// if the path is a file rather a directory or there is an error checking whether it exists.
83func DirExistsf(t TestingT, path string, msg string, args ...interface{}) {
84 if h, ok := t.(tHelper); ok {
85 h.Helper()
86 }
87 if assert.DirExistsf(t, path, msg, args...) {
88 return
89 }
90 t.FailNow()
91}
92
93// ElementsMatch asserts that the specified listA(array, slice...) is equal to specified
94// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements,
95// the number of appearances of each of them in both lists should match.
96//
97// assert.ElementsMatch(t, [1, 3, 2, 3], [1, 3, 3, 2])
98func ElementsMatch(t TestingT, listA interface{}, listB interface{}, msgAndArgs ...interface{}) {
99 if h, ok := t.(tHelper); ok {
100 h.Helper()
101 }
102 if assert.ElementsMatch(t, listA, listB, msgAndArgs...) {
103 return
104 }
105 t.FailNow()
106}
107
108// ElementsMatchf asserts that the specified listA(array, slice...) is equal to specified
109// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements,
110// the number of appearances of each of them in both lists should match.
111//
112// assert.ElementsMatchf(t, [1, 3, 2, 3], [1, 3, 3, 2], "error message %s", "formatted")
113func ElementsMatchf(t TestingT, listA interface{}, listB interface{}, msg string, args ...interface{}) {
114 if h, ok := t.(tHelper); ok {
115 h.Helper()
116 }
117 if assert.ElementsMatchf(t, listA, listB, msg, args...) {
118 return
119 }
120 t.FailNow()
121}
122
123// Empty asserts that the specified object is empty. I.e. nil, "", false, 0 or either
124// a slice or a channel with len == 0.
125//
126// assert.Empty(t, obj)
127func Empty(t TestingT, object interface{}, msgAndArgs ...interface{}) {
128 if h, ok := t.(tHelper); ok {
129 h.Helper()
130 }
131 if assert.Empty(t, object, msgAndArgs...) {
132 return
133 }
134 t.FailNow()
135}
136
137// Emptyf asserts that the specified object is empty. I.e. nil, "", false, 0 or either
138// a slice or a channel with len == 0.
139//
140// assert.Emptyf(t, obj, "error message %s", "formatted")
141func Emptyf(t TestingT, object interface{}, msg string, args ...interface{}) {
142 if h, ok := t.(tHelper); ok {
143 h.Helper()
144 }
145 if assert.Emptyf(t, object, msg, args...) {
146 return
147 }
148 t.FailNow()
149}
150
151// Equal asserts that two objects are equal.
152//
153// assert.Equal(t, 123, 123)
154//
155// Pointer variable equality is determined based on the equality of the
156// referenced values (as opposed to the memory addresses). Function equality
157// cannot be determined and will always fail.
158func Equal(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
159 if h, ok := t.(tHelper); ok {
160 h.Helper()
161 }
162 if assert.Equal(t, expected, actual, msgAndArgs...) {
163 return
164 }
165 t.FailNow()
166}
167
168// EqualError asserts that a function returned an error (i.e. not `nil`)
169// and that it is equal to the provided error.
170//
171// actualObj, err := SomeFunction()
172// assert.EqualError(t, err, expectedErrorString)
173func EqualError(t TestingT, theError error, errString string, msgAndArgs ...interface{}) {
174 if h, ok := t.(tHelper); ok {
175 h.Helper()
176 }
177 if assert.EqualError(t, theError, errString, msgAndArgs...) {
178 return
179 }
180 t.FailNow()
181}
182
183// EqualErrorf asserts that a function returned an error (i.e. not `nil`)
184// and that it is equal to the provided error.
185//
186// actualObj, err := SomeFunction()
187// assert.EqualErrorf(t, err, expectedErrorString, "error message %s", "formatted")
188func EqualErrorf(t TestingT, theError error, errString string, msg string, args ...interface{}) {
189 if h, ok := t.(tHelper); ok {
190 h.Helper()
191 }
192 if assert.EqualErrorf(t, theError, errString, msg, args...) {
193 return
194 }
195 t.FailNow()
196}
197
198// EqualValues asserts that two objects are equal or convertable to the same types
199// and equal.
200//
201// assert.EqualValues(t, uint32(123), int32(123))
202func EqualValues(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
203 if h, ok := t.(tHelper); ok {
204 h.Helper()
205 }
206 if assert.EqualValues(t, expected, actual, msgAndArgs...) {
207 return
208 }
209 t.FailNow()
210}
211
212// EqualValuesf asserts that two objects are equal or convertable to the same types
213// and equal.
214//
215// assert.EqualValuesf(t, uint32(123), int32(123), "error message %s", "formatted")
216func EqualValuesf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) {
217 if h, ok := t.(tHelper); ok {
218 h.Helper()
219 }
220 if assert.EqualValuesf(t, expected, actual, msg, args...) {
221 return
222 }
223 t.FailNow()
224}
225
226// Equalf asserts that two objects are equal.
227//
228// assert.Equalf(t, 123, 123, "error message %s", "formatted")
229//
230// Pointer variable equality is determined based on the equality of the
231// referenced values (as opposed to the memory addresses). Function equality
232// cannot be determined and will always fail.
233func Equalf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) {
234 if h, ok := t.(tHelper); ok {
235 h.Helper()
236 }
237 if assert.Equalf(t, expected, actual, msg, args...) {
238 return
239 }
240 t.FailNow()
241}
242
243// Error asserts that a function returned an error (i.e. not `nil`).
244//
245// actualObj, err := SomeFunction()
246// if assert.Error(t, err) {
247// assert.Equal(t, expectedError, err)
248// }
249func Error(t TestingT, err error, msgAndArgs ...interface{}) {
250 if h, ok := t.(tHelper); ok {
251 h.Helper()
252 }
253 if assert.Error(t, err, msgAndArgs...) {
254 return
255 }
256 t.FailNow()
257}
258
259// ErrorAs asserts that at least one of the errors in err's chain matches target, and if so, sets target to that error value.
260// This is a wrapper for errors.As.
261func ErrorAs(t TestingT, err error, target interface{}, msgAndArgs ...interface{}) {
262 if h, ok := t.(tHelper); ok {
263 h.Helper()
264 }
265 if assert.ErrorAs(t, err, target, msgAndArgs...) {
266 return
267 }
268 t.FailNow()
269}
270
271// ErrorAsf asserts that at least one of the errors in err's chain matches target, and if so, sets target to that error value.
272// This is a wrapper for errors.As.
273func ErrorAsf(t TestingT, err error, target interface{}, msg string, args ...interface{}) {
274 if h, ok := t.(tHelper); ok {
275 h.Helper()
276 }
277 if assert.ErrorAsf(t, err, target, msg, args...) {
278 return
279 }
280 t.FailNow()
281}
282
283// ErrorIs asserts that at least one of the errors in err's chain matches target.
284// This is a wrapper for errors.Is.
285func ErrorIs(t TestingT, err error, target error, msgAndArgs ...interface{}) {
286 if h, ok := t.(tHelper); ok {
287 h.Helper()
288 }
289 if assert.ErrorIs(t, err, target, msgAndArgs...) {
290 return
291 }
292 t.FailNow()
293}
294
295// ErrorIsf asserts that at least one of the errors in err's chain matches target.
296// This is a wrapper for errors.Is.
297func ErrorIsf(t TestingT, err error, target error, msg string, args ...interface{}) {
298 if h, ok := t.(tHelper); ok {
299 h.Helper()
300 }
301 if assert.ErrorIsf(t, err, target, msg, args...) {
302 return
303 }
304 t.FailNow()
305}
306
307// Errorf asserts that a function returned an error (i.e. not `nil`).
308//
309// actualObj, err := SomeFunction()
310// if assert.Errorf(t, err, "error message %s", "formatted") {
311// assert.Equal(t, expectedErrorf, err)
312// }
313func Errorf(t TestingT, err error, msg string, args ...interface{}) {
314 if h, ok := t.(tHelper); ok {
315 h.Helper()
316 }
317 if assert.Errorf(t, err, msg, args...) {
318 return
319 }
320 t.FailNow()
321}
322
323// Eventually asserts that given condition will be met in waitFor time,
324// periodically checking target function each tick.
325//
326// assert.Eventually(t, func() bool { return true; }, time.Second, 10*time.Millisecond)
327func Eventually(t TestingT, condition func() bool, waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) {
328 if h, ok := t.(tHelper); ok {
329 h.Helper()
330 }
331 if assert.Eventually(t, condition, waitFor, tick, msgAndArgs...) {
332 return
333 }
334 t.FailNow()
335}
336
337// Eventuallyf asserts that given condition will be met in waitFor time,
338// periodically checking target function each tick.
339//
340// assert.Eventuallyf(t, func() bool { return true; }, time.Second, 10*time.Millisecond, "error message %s", "formatted")
341func Eventuallyf(t TestingT, condition func() bool, waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) {
342 if h, ok := t.(tHelper); ok {
343 h.Helper()
344 }
345 if assert.Eventuallyf(t, condition, waitFor, tick, msg, args...) {
346 return
347 }
348 t.FailNow()
349}
350
351// Exactly asserts that two objects are equal in value and type.
352//
353// assert.Exactly(t, int32(123), int64(123))
354func Exactly(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
355 if h, ok := t.(tHelper); ok {
356 h.Helper()
357 }
358 if assert.Exactly(t, expected, actual, msgAndArgs...) {
359 return
360 }
361 t.FailNow()
362}
363
364// Exactlyf asserts that two objects are equal in value and type.
365//
366// assert.Exactlyf(t, int32(123), int64(123), "error message %s", "formatted")
367func Exactlyf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) {
368 if h, ok := t.(tHelper); ok {
369 h.Helper()
370 }
371 if assert.Exactlyf(t, expected, actual, msg, args...) {
372 return
373 }
374 t.FailNow()
375}
376
377// Fail reports a failure through
378func Fail(t TestingT, failureMessage string, msgAndArgs ...interface{}) {
379 if h, ok := t.(tHelper); ok {
380 h.Helper()
381 }
382 if assert.Fail(t, failureMessage, msgAndArgs...) {
383 return
384 }
385 t.FailNow()
386}
387
388// FailNow fails test
389func FailNow(t TestingT, failureMessage string, msgAndArgs ...interface{}) {
390 if h, ok := t.(tHelper); ok {
391 h.Helper()
392 }
393 if assert.FailNow(t, failureMessage, msgAndArgs...) {
394 return
395 }
396 t.FailNow()
397}
398
399// FailNowf fails test
400func FailNowf(t TestingT, failureMessage string, msg string, args ...interface{}) {
401 if h, ok := t.(tHelper); ok {
402 h.Helper()
403 }
404 if assert.FailNowf(t, failureMessage, msg, args...) {
405 return
406 }
407 t.FailNow()
408}
409
410// Failf reports a failure through
411func Failf(t TestingT, failureMessage string, msg string, args ...interface{}) {
412 if h, ok := t.(tHelper); ok {
413 h.Helper()
414 }
415 if assert.Failf(t, failureMessage, msg, args...) {
416 return
417 }
418 t.FailNow()
419}
420
421// False asserts that the specified value is false.
422//
423// assert.False(t, myBool)
424func False(t TestingT, value bool, msgAndArgs ...interface{}) {
425 if h, ok := t.(tHelper); ok {
426 h.Helper()
427 }
428 if assert.False(t, value, msgAndArgs...) {
429 return
430 }
431 t.FailNow()
432}
433
434// Falsef asserts that the specified value is false.
435//
436// assert.Falsef(t, myBool, "error message %s", "formatted")
437func Falsef(t TestingT, value bool, msg string, args ...interface{}) {
438 if h, ok := t.(tHelper); ok {
439 h.Helper()
440 }
441 if assert.Falsef(t, value, msg, args...) {
442 return
443 }
444 t.FailNow()
445}
446
447// FileExists checks whether a file exists in the given path. It also fails if
448// the path points to a directory or there is an error when trying to check the file.
449func FileExists(t TestingT, path string, msgAndArgs ...interface{}) {
450 if h, ok := t.(tHelper); ok {
451 h.Helper()
452 }
453 if assert.FileExists(t, path, msgAndArgs...) {
454 return
455 }
456 t.FailNow()
457}
458
459// FileExistsf checks whether a file exists in the given path. It also fails if
460// the path points to a directory or there is an error when trying to check the file.
461func FileExistsf(t TestingT, path string, msg string, args ...interface{}) {
462 if h, ok := t.(tHelper); ok {
463 h.Helper()
464 }
465 if assert.FileExistsf(t, path, msg, args...) {
466 return
467 }
468 t.FailNow()
469}
470
471// Greater asserts that the first element is greater than the second
472//
473// assert.Greater(t, 2, 1)
474// assert.Greater(t, float64(2), float64(1))
475// assert.Greater(t, "b", "a")
476func Greater(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) {
477 if h, ok := t.(tHelper); ok {
478 h.Helper()
479 }
480 if assert.Greater(t, e1, e2, msgAndArgs...) {
481 return
482 }
483 t.FailNow()
484}
485
486// GreaterOrEqual asserts that the first element is greater than or equal to the second
487//
488// assert.GreaterOrEqual(t, 2, 1)
489// assert.GreaterOrEqual(t, 2, 2)
490// assert.GreaterOrEqual(t, "b", "a")
491// assert.GreaterOrEqual(t, "b", "b")
492func GreaterOrEqual(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) {
493 if h, ok := t.(tHelper); ok {
494 h.Helper()
495 }
496 if assert.GreaterOrEqual(t, e1, e2, msgAndArgs...) {
497 return
498 }
499 t.FailNow()
500}
501
502// GreaterOrEqualf asserts that the first element is greater than or equal to the second
503//
504// assert.GreaterOrEqualf(t, 2, 1, "error message %s", "formatted")
505// assert.GreaterOrEqualf(t, 2, 2, "error message %s", "formatted")
506// assert.GreaterOrEqualf(t, "b", "a", "error message %s", "formatted")
507// assert.GreaterOrEqualf(t, "b", "b", "error message %s", "formatted")
508func GreaterOrEqualf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) {
509 if h, ok := t.(tHelper); ok {
510 h.Helper()
511 }
512 if assert.GreaterOrEqualf(t, e1, e2, msg, args...) {
513 return
514 }
515 t.FailNow()
516}
517
518// Greaterf asserts that the first element is greater than the second
519//
520// assert.Greaterf(t, 2, 1, "error message %s", "formatted")
521// assert.Greaterf(t, float64(2), float64(1), "error message %s", "formatted")
522// assert.Greaterf(t, "b", "a", "error message %s", "formatted")
523func Greaterf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) {
524 if h, ok := t.(tHelper); ok {
525 h.Helper()
526 }
527 if assert.Greaterf(t, e1, e2, msg, args...) {
528 return
529 }
530 t.FailNow()
531}
532
533// HTTPBodyContains asserts that a specified handler returns a
534// body that contains a string.
535//
536// assert.HTTPBodyContains(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky")
537//
538// Returns whether the assertion was successful (true) or not (false).
539func HTTPBodyContains(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) {
540 if h, ok := t.(tHelper); ok {
541 h.Helper()
542 }
543 if assert.HTTPBodyContains(t, handler, method, url, values, str, msgAndArgs...) {
544 return
545 }
546 t.FailNow()
547}
548
549// HTTPBodyContainsf asserts that a specified handler returns a
550// body that contains a string.
551//
552// assert.HTTPBodyContainsf(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted")
553//
554// Returns whether the assertion was successful (true) or not (false).
555func HTTPBodyContainsf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) {
556 if h, ok := t.(tHelper); ok {
557 h.Helper()
558 }
559 if assert.HTTPBodyContainsf(t, handler, method, url, values, str, msg, args...) {
560 return
561 }
562 t.FailNow()
563}
564
565// HTTPBodyNotContains asserts that a specified handler returns a
566// body that does not contain a string.
567//
568// assert.HTTPBodyNotContains(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky")
569//
570// Returns whether the assertion was successful (true) or not (false).
571func HTTPBodyNotContains(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) {
572 if h, ok := t.(tHelper); ok {
573 h.Helper()
574 }
575 if assert.HTTPBodyNotContains(t, handler, method, url, values, str, msgAndArgs...) {
576 return
577 }
578 t.FailNow()
579}
580
581// HTTPBodyNotContainsf asserts that a specified handler returns a
582// body that does not contain a string.
583//
584// assert.HTTPBodyNotContainsf(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted")
585//
586// Returns whether the assertion was successful (true) or not (false).
587func HTTPBodyNotContainsf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) {
588 if h, ok := t.(tHelper); ok {
589 h.Helper()
590 }
591 if assert.HTTPBodyNotContainsf(t, handler, method, url, values, str, msg, args...) {
592 return
593 }
594 t.FailNow()
595}
596
597// HTTPError asserts that a specified handler returns an error status code.
598//
599// assert.HTTPError(t, myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}}
600//
601// Returns whether the assertion was successful (true) or not (false).
602func HTTPError(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) {
603 if h, ok := t.(tHelper); ok {
604 h.Helper()
605 }
606 if assert.HTTPError(t, handler, method, url, values, msgAndArgs...) {
607 return
608 }
609 t.FailNow()
610}
611
612// HTTPErrorf asserts that a specified handler returns an error status code.
613//
614// assert.HTTPErrorf(t, myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}}
615//
616// Returns whether the assertion was successful (true) or not (false).
617func HTTPErrorf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) {
618 if h, ok := t.(tHelper); ok {
619 h.Helper()
620 }
621 if assert.HTTPErrorf(t, handler, method, url, values, msg, args...) {
622 return
623 }
624 t.FailNow()
625}
626
627// HTTPRedirect asserts that a specified handler returns a redirect status code.
628//
629// assert.HTTPRedirect(t, myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}}
630//
631// Returns whether the assertion was successful (true) or not (false).
632func HTTPRedirect(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) {
633 if h, ok := t.(tHelper); ok {
634 h.Helper()
635 }
636 if assert.HTTPRedirect(t, handler, method, url, values, msgAndArgs...) {
637 return
638 }
639 t.FailNow()
640}
641
642// HTTPRedirectf asserts that a specified handler returns a redirect status code.
643//
644// assert.HTTPRedirectf(t, myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}}
645//
646// Returns whether the assertion was successful (true) or not (false).
647func HTTPRedirectf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) {
648 if h, ok := t.(tHelper); ok {
649 h.Helper()
650 }
651 if assert.HTTPRedirectf(t, handler, method, url, values, msg, args...) {
652 return
653 }
654 t.FailNow()
655}
656
657// HTTPStatusCode asserts that a specified handler returns a specified status code.
658//
659// assert.HTTPStatusCode(t, myHandler, "GET", "/notImplemented", nil, 501)
660//
661// Returns whether the assertion was successful (true) or not (false).
662func HTTPStatusCode(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, statuscode int, msgAndArgs ...interface{}) {
663 if h, ok := t.(tHelper); ok {
664 h.Helper()
665 }
666 if assert.HTTPStatusCode(t, handler, method, url, values, statuscode, msgAndArgs...) {
667 return
668 }
669 t.FailNow()
670}
671
672// HTTPStatusCodef asserts that a specified handler returns a specified status code.
673//
674// assert.HTTPStatusCodef(t, myHandler, "GET", "/notImplemented", nil, 501, "error message %s", "formatted")
675//
676// Returns whether the assertion was successful (true) or not (false).
677func HTTPStatusCodef(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, statuscode int, msg string, args ...interface{}) {
678 if h, ok := t.(tHelper); ok {
679 h.Helper()
680 }
681 if assert.HTTPStatusCodef(t, handler, method, url, values, statuscode, msg, args...) {
682 return
683 }
684 t.FailNow()
685}
686
687// HTTPSuccess asserts that a specified handler returns a success status code.
688//
689// assert.HTTPSuccess(t, myHandler, "POST", "http://www.google.com", nil)
690//
691// Returns whether the assertion was successful (true) or not (false).
692func HTTPSuccess(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) {
693 if h, ok := t.(tHelper); ok {
694 h.Helper()
695 }
696 if assert.HTTPSuccess(t, handler, method, url, values, msgAndArgs...) {
697 return
698 }
699 t.FailNow()
700}
701
702// HTTPSuccessf asserts that a specified handler returns a success status code.
703//
704// assert.HTTPSuccessf(t, myHandler, "POST", "http://www.google.com", nil, "error message %s", "formatted")
705//
706// Returns whether the assertion was successful (true) or not (false).
707func HTTPSuccessf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) {
708 if h, ok := t.(tHelper); ok {
709 h.Helper()
710 }
711 if assert.HTTPSuccessf(t, handler, method, url, values, msg, args...) {
712 return
713 }
714 t.FailNow()
715}
716
717// Implements asserts that an object is implemented by the specified interface.
718//
719// assert.Implements(t, (*MyInterface)(nil), new(MyObject))
720func Implements(t TestingT, interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) {
721 if h, ok := t.(tHelper); ok {
722 h.Helper()
723 }
724 if assert.Implements(t, interfaceObject, object, msgAndArgs...) {
725 return
726 }
727 t.FailNow()
728}
729
730// Implementsf asserts that an object is implemented by the specified interface.
731//
732// assert.Implementsf(t, (*MyInterface)(nil), new(MyObject), "error message %s", "formatted")
733func Implementsf(t TestingT, interfaceObject interface{}, object interface{}, msg string, args ...interface{}) {
734 if h, ok := t.(tHelper); ok {
735 h.Helper()
736 }
737 if assert.Implementsf(t, interfaceObject, object, msg, args...) {
738 return
739 }
740 t.FailNow()
741}
742
743// InDelta asserts that the two numerals are within delta of each other.
744//
745// assert.InDelta(t, math.Pi, 22/7.0, 0.01)
746func InDelta(t TestingT, expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) {
747 if h, ok := t.(tHelper); ok {
748 h.Helper()
749 }
750 if assert.InDelta(t, expected, actual, delta, msgAndArgs...) {
751 return
752 }
753 t.FailNow()
754}
755
756// InDeltaMapValues is the same as InDelta, but it compares all values between two maps. Both maps must have exactly the same keys.
757func InDeltaMapValues(t TestingT, expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) {
758 if h, ok := t.(tHelper); ok {
759 h.Helper()
760 }
761 if assert.InDeltaMapValues(t, expected, actual, delta, msgAndArgs...) {
762 return
763 }
764 t.FailNow()
765}
766
767// InDeltaMapValuesf is the same as InDelta, but it compares all values between two maps. Both maps must have exactly the same keys.
768func InDeltaMapValuesf(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) {
769 if h, ok := t.(tHelper); ok {
770 h.Helper()
771 }
772 if assert.InDeltaMapValuesf(t, expected, actual, delta, msg, args...) {
773 return
774 }
775 t.FailNow()
776}
777
778// InDeltaSlice is the same as InDelta, except it compares two slices.
779func InDeltaSlice(t TestingT, expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) {
780 if h, ok := t.(tHelper); ok {
781 h.Helper()
782 }
783 if assert.InDeltaSlice(t, expected, actual, delta, msgAndArgs...) {
784 return
785 }
786 t.FailNow()
787}
788
789// InDeltaSlicef is the same as InDelta, except it compares two slices.
790func InDeltaSlicef(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) {
791 if h, ok := t.(tHelper); ok {
792 h.Helper()
793 }
794 if assert.InDeltaSlicef(t, expected, actual, delta, msg, args...) {
795 return
796 }
797 t.FailNow()
798}
799
800// InDeltaf asserts that the two numerals are within delta of each other.
801//
802// assert.InDeltaf(t, math.Pi, 22/7.0, 0.01, "error message %s", "formatted")
803func InDeltaf(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) {
804 if h, ok := t.(tHelper); ok {
805 h.Helper()
806 }
807 if assert.InDeltaf(t, expected, actual, delta, msg, args...) {
808 return
809 }
810 t.FailNow()
811}
812
813// InEpsilon asserts that expected and actual have a relative error less than epsilon
814func InEpsilon(t TestingT, expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{}) {
815 if h, ok := t.(tHelper); ok {
816 h.Helper()
817 }
818 if assert.InEpsilon(t, expected, actual, epsilon, msgAndArgs...) {
819 return
820 }
821 t.FailNow()
822}
823
824// InEpsilonSlice is the same as InEpsilon, except it compares each value from two slices.
825func InEpsilonSlice(t TestingT, expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{}) {
826 if h, ok := t.(tHelper); ok {
827 h.Helper()
828 }
829 if assert.InEpsilonSlice(t, expected, actual, epsilon, msgAndArgs...) {
830 return
831 }
832 t.FailNow()
833}
834
835// InEpsilonSlicef is the same as InEpsilon, except it compares each value from two slices.
836func InEpsilonSlicef(t TestingT, expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) {
837 if h, ok := t.(tHelper); ok {
838 h.Helper()
839 }
840 if assert.InEpsilonSlicef(t, expected, actual, epsilon, msg, args...) {
841 return
842 }
843 t.FailNow()
844}
845
846// InEpsilonf asserts that expected and actual have a relative error less than epsilon
847func InEpsilonf(t TestingT, expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) {
848 if h, ok := t.(tHelper); ok {
849 h.Helper()
850 }
851 if assert.InEpsilonf(t, expected, actual, epsilon, msg, args...) {
852 return
853 }
854 t.FailNow()
855}
856
857// IsDecreasing asserts that the collection is decreasing
858//
859// assert.IsDecreasing(t, []int{2, 1, 0})
860// assert.IsDecreasing(t, []float{2, 1})
861// assert.IsDecreasing(t, []string{"b", "a"})
862func IsDecreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) {
863 if h, ok := t.(tHelper); ok {
864 h.Helper()
865 }
866 if assert.IsDecreasing(t, object, msgAndArgs...) {
867 return
868 }
869 t.FailNow()
870}
871
872// IsDecreasingf asserts that the collection is decreasing
873//
874// assert.IsDecreasingf(t, []int{2, 1, 0}, "error message %s", "formatted")
875// assert.IsDecreasingf(t, []float{2, 1}, "error message %s", "formatted")
876// assert.IsDecreasingf(t, []string{"b", "a"}, "error message %s", "formatted")
877func IsDecreasingf(t TestingT, object interface{}, msg string, args ...interface{}) {
878 if h, ok := t.(tHelper); ok {
879 h.Helper()
880 }
881 if assert.IsDecreasingf(t, object, msg, args...) {
882 return
883 }
884 t.FailNow()
885}
886
887// IsIncreasing asserts that the collection is increasing
888//
889// assert.IsIncreasing(t, []int{1, 2, 3})
890// assert.IsIncreasing(t, []float{1, 2})
891// assert.IsIncreasing(t, []string{"a", "b"})
892func IsIncreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) {
893 if h, ok := t.(tHelper); ok {
894 h.Helper()
895 }
896 if assert.IsIncreasing(t, object, msgAndArgs...) {
897 return
898 }
899 t.FailNow()
900}
901
902// IsIncreasingf asserts that the collection is increasing
903//
904// assert.IsIncreasingf(t, []int{1, 2, 3}, "error message %s", "formatted")
905// assert.IsIncreasingf(t, []float{1, 2}, "error message %s", "formatted")
906// assert.IsIncreasingf(t, []string{"a", "b"}, "error message %s", "formatted")
907func IsIncreasingf(t TestingT, object interface{}, msg string, args ...interface{}) {
908 if h, ok := t.(tHelper); ok {
909 h.Helper()
910 }
911 if assert.IsIncreasingf(t, object, msg, args...) {
912 return
913 }
914 t.FailNow()
915}
916
917// IsNonDecreasing asserts that the collection is not decreasing
918//
919// assert.IsNonDecreasing(t, []int{1, 1, 2})
920// assert.IsNonDecreasing(t, []float{1, 2})
921// assert.IsNonDecreasing(t, []string{"a", "b"})
922func IsNonDecreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) {
923 if h, ok := t.(tHelper); ok {
924 h.Helper()
925 }
926 if assert.IsNonDecreasing(t, object, msgAndArgs...) {
927 return
928 }
929 t.FailNow()
930}
931
932// IsNonDecreasingf asserts that the collection is not decreasing
933//
934// assert.IsNonDecreasingf(t, []int{1, 1, 2}, "error message %s", "formatted")
935// assert.IsNonDecreasingf(t, []float{1, 2}, "error message %s", "formatted")
936// assert.IsNonDecreasingf(t, []string{"a", "b"}, "error message %s", "formatted")
937func IsNonDecreasingf(t TestingT, object interface{}, msg string, args ...interface{}) {
938 if h, ok := t.(tHelper); ok {
939 h.Helper()
940 }
941 if assert.IsNonDecreasingf(t, object, msg, args...) {
942 return
943 }
944 t.FailNow()
945}
946
947// IsNonIncreasing asserts that the collection is not increasing
948//
949// assert.IsNonIncreasing(t, []int{2, 1, 1})
950// assert.IsNonIncreasing(t, []float{2, 1})
951// assert.IsNonIncreasing(t, []string{"b", "a"})
952func IsNonIncreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) {
953 if h, ok := t.(tHelper); ok {
954 h.Helper()
955 }
956 if assert.IsNonIncreasing(t, object, msgAndArgs...) {
957 return
958 }
959 t.FailNow()
960}
961
962// IsNonIncreasingf asserts that the collection is not increasing
963//
964// assert.IsNonIncreasingf(t, []int{2, 1, 1}, "error message %s", "formatted")
965// assert.IsNonIncreasingf(t, []float{2, 1}, "error message %s", "formatted")
966// assert.IsNonIncreasingf(t, []string{"b", "a"}, "error message %s", "formatted")
967func IsNonIncreasingf(t TestingT, object interface{}, msg string, args ...interface{}) {
968 if h, ok := t.(tHelper); ok {
969 h.Helper()
970 }
971 if assert.IsNonIncreasingf(t, object, msg, args...) {
972 return
973 }
974 t.FailNow()
975}
976
977// IsType asserts that the specified objects are of the same type.
978func IsType(t TestingT, expectedType interface{}, object interface{}, msgAndArgs ...interface{}) {
979 if h, ok := t.(tHelper); ok {
980 h.Helper()
981 }
982 if assert.IsType(t, expectedType, object, msgAndArgs...) {
983 return
984 }
985 t.FailNow()
986}
987
988// IsTypef asserts that the specified objects are of the same type.
989func IsTypef(t TestingT, expectedType interface{}, object interface{}, msg string, args ...interface{}) {
990 if h, ok := t.(tHelper); ok {
991 h.Helper()
992 }
993 if assert.IsTypef(t, expectedType, object, msg, args...) {
994 return
995 }
996 t.FailNow()
997}
998
999// JSONEq asserts that two JSON strings are equivalent.
1000//
1001// assert.JSONEq(t, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`)
1002func JSONEq(t TestingT, expected string, actual string, msgAndArgs ...interface{}) {
1003 if h, ok := t.(tHelper); ok {
1004 h.Helper()
1005 }
1006 if assert.JSONEq(t, expected, actual, msgAndArgs...) {
1007 return
1008 }
1009 t.FailNow()
1010}
1011
1012// JSONEqf asserts that two JSON strings are equivalent.
1013//
1014// assert.JSONEqf(t, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`, "error message %s", "formatted")
1015func JSONEqf(t TestingT, expected string, actual string, msg string, args ...interface{}) {
1016 if h, ok := t.(tHelper); ok {
1017 h.Helper()
1018 }
1019 if assert.JSONEqf(t, expected, actual, msg, args...) {
1020 return
1021 }
1022 t.FailNow()
1023}
1024
1025// Len asserts that the specified object has specific length.
1026// Len also fails if the object has a type that len() not accept.
1027//
1028// assert.Len(t, mySlice, 3)
1029func Len(t TestingT, object interface{}, length int, msgAndArgs ...interface{}) {
1030 if h, ok := t.(tHelper); ok {
1031 h.Helper()
1032 }
1033 if assert.Len(t, object, length, msgAndArgs...) {
1034 return
1035 }
1036 t.FailNow()
1037}
1038
1039// Lenf asserts that the specified object has specific length.
1040// Lenf also fails if the object has a type that len() not accept.
1041//
1042// assert.Lenf(t, mySlice, 3, "error message %s", "formatted")
1043func Lenf(t TestingT, object interface{}, length int, msg string, args ...interface{}) {
1044 if h, ok := t.(tHelper); ok {
1045 h.Helper()
1046 }
1047 if assert.Lenf(t, object, length, msg, args...) {
1048 return
1049 }
1050 t.FailNow()
1051}
1052
1053// Less asserts that the first element is less than the second
1054//
1055// assert.Less(t, 1, 2)
1056// assert.Less(t, float64(1), float64(2))
1057// assert.Less(t, "a", "b")
1058func Less(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) {
1059 if h, ok := t.(tHelper); ok {
1060 h.Helper()
1061 }
1062 if assert.Less(t, e1, e2, msgAndArgs...) {
1063 return
1064 }
1065 t.FailNow()
1066}
1067
1068// LessOrEqual asserts that the first element is less than or equal to the second
1069//
1070// assert.LessOrEqual(t, 1, 2)
1071// assert.LessOrEqual(t, 2, 2)
1072// assert.LessOrEqual(t, "a", "b")
1073// assert.LessOrEqual(t, "b", "b")
1074func LessOrEqual(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) {
1075 if h, ok := t.(tHelper); ok {
1076 h.Helper()
1077 }
1078 if assert.LessOrEqual(t, e1, e2, msgAndArgs...) {
1079 return
1080 }
1081 t.FailNow()
1082}
1083
1084// LessOrEqualf asserts that the first element is less than or equal to the second
1085//
1086// assert.LessOrEqualf(t, 1, 2, "error message %s", "formatted")
1087// assert.LessOrEqualf(t, 2, 2, "error message %s", "formatted")
1088// assert.LessOrEqualf(t, "a", "b", "error message %s", "formatted")
1089// assert.LessOrEqualf(t, "b", "b", "error message %s", "formatted")
1090func LessOrEqualf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) {
1091 if h, ok := t.(tHelper); ok {
1092 h.Helper()
1093 }
1094 if assert.LessOrEqualf(t, e1, e2, msg, args...) {
1095 return
1096 }
1097 t.FailNow()
1098}
1099
1100// Lessf asserts that the first element is less than the second
1101//
1102// assert.Lessf(t, 1, 2, "error message %s", "formatted")
1103// assert.Lessf(t, float64(1), float64(2), "error message %s", "formatted")
1104// assert.Lessf(t, "a", "b", "error message %s", "formatted")
1105func Lessf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) {
1106 if h, ok := t.(tHelper); ok {
1107 h.Helper()
1108 }
1109 if assert.Lessf(t, e1, e2, msg, args...) {
1110 return
1111 }
1112 t.FailNow()
1113}
1114
1115// Negative asserts that the specified element is negative
1116//
1117// assert.Negative(t, -1)
1118// assert.Negative(t, -1.23)
1119func Negative(t TestingT, e interface{}, msgAndArgs ...interface{}) {
1120 if h, ok := t.(tHelper); ok {
1121 h.Helper()
1122 }
1123 if assert.Negative(t, e, msgAndArgs...) {
1124 return
1125 }
1126 t.FailNow()
1127}
1128
1129// Negativef asserts that the specified element is negative
1130//
1131// assert.Negativef(t, -1, "error message %s", "formatted")
1132// assert.Negativef(t, -1.23, "error message %s", "formatted")
1133func Negativef(t TestingT, e interface{}, msg string, args ...interface{}) {
1134 if h, ok := t.(tHelper); ok {
1135 h.Helper()
1136 }
1137 if assert.Negativef(t, e, msg, args...) {
1138 return
1139 }
1140 t.FailNow()
1141}
1142
1143// Never asserts that the given condition doesn't satisfy in waitFor time,
1144// periodically checking the target function each tick.
1145//
1146// assert.Never(t, func() bool { return false; }, time.Second, 10*time.Millisecond)
1147func Never(t TestingT, condition func() bool, waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) {
1148 if h, ok := t.(tHelper); ok {
1149 h.Helper()
1150 }
1151 if assert.Never(t, condition, waitFor, tick, msgAndArgs...) {
1152 return
1153 }
1154 t.FailNow()
1155}
1156
1157// Neverf asserts that the given condition doesn't satisfy in waitFor time,
1158// periodically checking the target function each tick.
1159//
1160// assert.Neverf(t, func() bool { return false; }, time.Second, 10*time.Millisecond, "error message %s", "formatted")
1161func Neverf(t TestingT, condition func() bool, waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) {
1162 if h, ok := t.(tHelper); ok {
1163 h.Helper()
1164 }
1165 if assert.Neverf(t, condition, waitFor, tick, msg, args...) {
1166 return
1167 }
1168 t.FailNow()
1169}
1170
1171// Nil asserts that the specified object is nil.
1172//
1173// assert.Nil(t, err)
1174func Nil(t TestingT, object interface{}, msgAndArgs ...interface{}) {
1175 if h, ok := t.(tHelper); ok {
1176 h.Helper()
1177 }
1178 if assert.Nil(t, object, msgAndArgs...) {
1179 return
1180 }
1181 t.FailNow()
1182}
1183
1184// Nilf asserts that the specified object is nil.
1185//
1186// assert.Nilf(t, err, "error message %s", "formatted")
1187func Nilf(t TestingT, object interface{}, msg string, args ...interface{}) {
1188 if h, ok := t.(tHelper); ok {
1189 h.Helper()
1190 }
1191 if assert.Nilf(t, object, msg, args...) {
1192 return
1193 }
1194 t.FailNow()
1195}
1196
1197// NoDirExists checks whether a directory does not exist in the given path.
1198// It fails if the path points to an existing _directory_ only.
1199func NoDirExists(t TestingT, path string, msgAndArgs ...interface{}) {
1200 if h, ok := t.(tHelper); ok {
1201 h.Helper()
1202 }
1203 if assert.NoDirExists(t, path, msgAndArgs...) {
1204 return
1205 }
1206 t.FailNow()
1207}
1208
1209// NoDirExistsf checks whether a directory does not exist in the given path.
1210// It fails if the path points to an existing _directory_ only.
1211func NoDirExistsf(t TestingT, path string, msg string, args ...interface{}) {
1212 if h, ok := t.(tHelper); ok {
1213 h.Helper()
1214 }
1215 if assert.NoDirExistsf(t, path, msg, args...) {
1216 return
1217 }
1218 t.FailNow()
1219}
1220
1221// NoError asserts that a function returned no error (i.e. `nil`).
1222//
1223// actualObj, err := SomeFunction()
1224// if assert.NoError(t, err) {
1225// assert.Equal(t, expectedObj, actualObj)
1226// }
1227func NoError(t TestingT, err error, msgAndArgs ...interface{}) {
1228 if h, ok := t.(tHelper); ok {
1229 h.Helper()
1230 }
1231 if assert.NoError(t, err, msgAndArgs...) {
1232 return
1233 }
1234 t.FailNow()
1235}
1236
1237// NoErrorf asserts that a function returned no error (i.e. `nil`).
1238//
1239// actualObj, err := SomeFunction()
1240// if assert.NoErrorf(t, err, "error message %s", "formatted") {
1241// assert.Equal(t, expectedObj, actualObj)
1242// }
1243func NoErrorf(t TestingT, err error, msg string, args ...interface{}) {
1244 if h, ok := t.(tHelper); ok {
1245 h.Helper()
1246 }
1247 if assert.NoErrorf(t, err, msg, args...) {
1248 return
1249 }
1250 t.FailNow()
1251}
1252
1253// NoFileExists checks whether a file does not exist in a given path. It fails
1254// if the path points to an existing _file_ only.
1255func NoFileExists(t TestingT, path string, msgAndArgs ...interface{}) {
1256 if h, ok := t.(tHelper); ok {
1257 h.Helper()
1258 }
1259 if assert.NoFileExists(t, path, msgAndArgs...) {
1260 return
1261 }
1262 t.FailNow()
1263}
1264
1265// NoFileExistsf checks whether a file does not exist in a given path. It fails
1266// if the path points to an existing _file_ only.
1267func NoFileExistsf(t TestingT, path string, msg string, args ...interface{}) {
1268 if h, ok := t.(tHelper); ok {
1269 h.Helper()
1270 }
1271 if assert.NoFileExistsf(t, path, msg, args...) {
1272 return
1273 }
1274 t.FailNow()
1275}
1276
1277// NotContains asserts that the specified string, list(array, slice...) or map does NOT contain the
1278// specified substring or element.
1279//
1280// assert.NotContains(t, "Hello World", "Earth")
1281// assert.NotContains(t, ["Hello", "World"], "Earth")
1282// assert.NotContains(t, {"Hello": "World"}, "Earth")
1283func NotContains(t TestingT, s interface{}, contains interface{}, msgAndArgs ...interface{}) {
1284 if h, ok := t.(tHelper); ok {
1285 h.Helper()
1286 }
1287 if assert.NotContains(t, s, contains, msgAndArgs...) {
1288 return
1289 }
1290 t.FailNow()
1291}
1292
1293// NotContainsf asserts that the specified string, list(array, slice...) or map does NOT contain the
1294// specified substring or element.
1295//
1296// assert.NotContainsf(t, "Hello World", "Earth", "error message %s", "formatted")
1297// assert.NotContainsf(t, ["Hello", "World"], "Earth", "error message %s", "formatted")
1298// assert.NotContainsf(t, {"Hello": "World"}, "Earth", "error message %s", "formatted")
1299func NotContainsf(t TestingT, s interface{}, contains interface{}, msg string, args ...interface{}) {
1300 if h, ok := t.(tHelper); ok {
1301 h.Helper()
1302 }
1303 if assert.NotContainsf(t, s, contains, msg, args...) {
1304 return
1305 }
1306 t.FailNow()
1307}
1308
1309// NotEmpty asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either
1310// a slice or a channel with len == 0.
1311//
1312// if assert.NotEmpty(t, obj) {
1313// assert.Equal(t, "two", obj[1])
1314// }
1315func NotEmpty(t TestingT, object interface{}, msgAndArgs ...interface{}) {
1316 if h, ok := t.(tHelper); ok {
1317 h.Helper()
1318 }
1319 if assert.NotEmpty(t, object, msgAndArgs...) {
1320 return
1321 }
1322 t.FailNow()
1323}
1324
1325// NotEmptyf asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either
1326// a slice or a channel with len == 0.
1327//
1328// if assert.NotEmptyf(t, obj, "error message %s", "formatted") {
1329// assert.Equal(t, "two", obj[1])
1330// }
1331func NotEmptyf(t TestingT, object interface{}, msg string, args ...interface{}) {
1332 if h, ok := t.(tHelper); ok {
1333 h.Helper()
1334 }
1335 if assert.NotEmptyf(t, object, msg, args...) {
1336 return
1337 }
1338 t.FailNow()
1339}
1340
1341// NotEqual asserts that the specified values are NOT equal.
1342//
1343// assert.NotEqual(t, obj1, obj2)
1344//
1345// Pointer variable equality is determined based on the equality of the
1346// referenced values (as opposed to the memory addresses).
1347func NotEqual(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
1348 if h, ok := t.(tHelper); ok {
1349 h.Helper()
1350 }
1351 if assert.NotEqual(t, expected, actual, msgAndArgs...) {
1352 return
1353 }
1354 t.FailNow()
1355}
1356
1357// NotEqualValues asserts that two objects are not equal even when converted to the same type
1358//
1359// assert.NotEqualValues(t, obj1, obj2)
1360func NotEqualValues(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
1361 if h, ok := t.(tHelper); ok {
1362 h.Helper()
1363 }
1364 if assert.NotEqualValues(t, expected, actual, msgAndArgs...) {
1365 return
1366 }
1367 t.FailNow()
1368}
1369
1370// NotEqualValuesf asserts that two objects are not equal even when converted to the same type
1371//
1372// assert.NotEqualValuesf(t, obj1, obj2, "error message %s", "formatted")
1373func NotEqualValuesf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) {
1374 if h, ok := t.(tHelper); ok {
1375 h.Helper()
1376 }
1377 if assert.NotEqualValuesf(t, expected, actual, msg, args...) {
1378 return
1379 }
1380 t.FailNow()
1381}
1382
1383// NotEqualf asserts that the specified values are NOT equal.
1384//
1385// assert.NotEqualf(t, obj1, obj2, "error message %s", "formatted")
1386//
1387// Pointer variable equality is determined based on the equality of the
1388// referenced values (as opposed to the memory addresses).
1389func NotEqualf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) {
1390 if h, ok := t.(tHelper); ok {
1391 h.Helper()
1392 }
1393 if assert.NotEqualf(t, expected, actual, msg, args...) {
1394 return
1395 }
1396 t.FailNow()
1397}
1398
1399// NotErrorIs asserts that at none of the errors in err's chain matches target.
1400// This is a wrapper for errors.Is.
1401func NotErrorIs(t TestingT, err error, target error, msgAndArgs ...interface{}) {
1402 if h, ok := t.(tHelper); ok {
1403 h.Helper()
1404 }
1405 if assert.NotErrorIs(t, err, target, msgAndArgs...) {
1406 return
1407 }
1408 t.FailNow()
1409}
1410
1411// NotErrorIsf asserts that at none of the errors in err's chain matches target.
1412// This is a wrapper for errors.Is.
1413func NotErrorIsf(t TestingT, err error, target error, msg string, args ...interface{}) {
1414 if h, ok := t.(tHelper); ok {
1415 h.Helper()
1416 }
1417 if assert.NotErrorIsf(t, err, target, msg, args...) {
1418 return
1419 }
1420 t.FailNow()
1421}
1422
1423// NotNil asserts that the specified object is not nil.
1424//
1425// assert.NotNil(t, err)
1426func NotNil(t TestingT, object interface{}, msgAndArgs ...interface{}) {
1427 if h, ok := t.(tHelper); ok {
1428 h.Helper()
1429 }
1430 if assert.NotNil(t, object, msgAndArgs...) {
1431 return
1432 }
1433 t.FailNow()
1434}
1435
1436// NotNilf asserts that the specified object is not nil.
1437//
1438// assert.NotNilf(t, err, "error message %s", "formatted")
1439func NotNilf(t TestingT, object interface{}, msg string, args ...interface{}) {
1440 if h, ok := t.(tHelper); ok {
1441 h.Helper()
1442 }
1443 if assert.NotNilf(t, object, msg, args...) {
1444 return
1445 }
1446 t.FailNow()
1447}
1448
1449// NotPanics asserts that the code inside the specified PanicTestFunc does NOT panic.
1450//
1451// assert.NotPanics(t, func(){ RemainCalm() })
1452func NotPanics(t TestingT, f assert.PanicTestFunc, msgAndArgs ...interface{}) {
1453 if h, ok := t.(tHelper); ok {
1454 h.Helper()
1455 }
1456 if assert.NotPanics(t, f, msgAndArgs...) {
1457 return
1458 }
1459 t.FailNow()
1460}
1461
1462// NotPanicsf asserts that the code inside the specified PanicTestFunc does NOT panic.
1463//
1464// assert.NotPanicsf(t, func(){ RemainCalm() }, "error message %s", "formatted")
1465func NotPanicsf(t TestingT, f assert.PanicTestFunc, msg string, args ...interface{}) {
1466 if h, ok := t.(tHelper); ok {
1467 h.Helper()
1468 }
1469 if assert.NotPanicsf(t, f, msg, args...) {
1470 return
1471 }
1472 t.FailNow()
1473}
1474
1475// NotRegexp asserts that a specified regexp does not match a string.
1476//
1477// assert.NotRegexp(t, regexp.MustCompile("starts"), "it's starting")
1478// assert.NotRegexp(t, "^start", "it's not starting")
1479func NotRegexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ...interface{}) {
1480 if h, ok := t.(tHelper); ok {
1481 h.Helper()
1482 }
1483 if assert.NotRegexp(t, rx, str, msgAndArgs...) {
1484 return
1485 }
1486 t.FailNow()
1487}
1488
1489// NotRegexpf asserts that a specified regexp does not match a string.
1490//
1491// assert.NotRegexpf(t, regexp.MustCompile("starts"), "it's starting", "error message %s", "formatted")
1492// assert.NotRegexpf(t, "^start", "it's not starting", "error message %s", "formatted")
1493func NotRegexpf(t TestingT, rx interface{}, str interface{}, msg string, args ...interface{}) {
1494 if h, ok := t.(tHelper); ok {
1495 h.Helper()
1496 }
1497 if assert.NotRegexpf(t, rx, str, msg, args...) {
1498 return
1499 }
1500 t.FailNow()
1501}
1502
1503// NotSame asserts that two pointers do not reference the same object.
1504//
1505// assert.NotSame(t, ptr1, ptr2)
1506//
1507// Both arguments must be pointer variables. Pointer variable sameness is
1508// determined based on the equality of both type and value.
1509func NotSame(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
1510 if h, ok := t.(tHelper); ok {
1511 h.Helper()
1512 }
1513 if assert.NotSame(t, expected, actual, msgAndArgs...) {
1514 return
1515 }
1516 t.FailNow()
1517}
1518
1519// NotSamef asserts that two pointers do not reference the same object.
1520//
1521// assert.NotSamef(t, ptr1, ptr2, "error message %s", "formatted")
1522//
1523// Both arguments must be pointer variables. Pointer variable sameness is
1524// determined based on the equality of both type and value.
1525func NotSamef(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) {
1526 if h, ok := t.(tHelper); ok {
1527 h.Helper()
1528 }
1529 if assert.NotSamef(t, expected, actual, msg, args...) {
1530 return
1531 }
1532 t.FailNow()
1533}
1534
1535// NotSubset asserts that the specified list(array, slice...) contains not all
1536// elements given in the specified subset(array, slice...).
1537//
1538// assert.NotSubset(t, [1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]")
1539func NotSubset(t TestingT, list interface{}, subset interface{}, msgAndArgs ...interface{}) {
1540 if h, ok := t.(tHelper); ok {
1541 h.Helper()
1542 }
1543 if assert.NotSubset(t, list, subset, msgAndArgs...) {
1544 return
1545 }
1546 t.FailNow()
1547}
1548
1549// NotSubsetf asserts that the specified list(array, slice...) contains not all
1550// elements given in the specified subset(array, slice...).
1551//
1552// assert.NotSubsetf(t, [1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]", "error message %s", "formatted")
1553func NotSubsetf(t TestingT, list interface{}, subset interface{}, msg string, args ...interface{}) {
1554 if h, ok := t.(tHelper); ok {
1555 h.Helper()
1556 }
1557 if assert.NotSubsetf(t, list, subset, msg, args...) {
1558 return
1559 }
1560 t.FailNow()
1561}
1562
1563// NotZero asserts that i is not the zero value for its type.
1564func NotZero(t TestingT, i interface{}, msgAndArgs ...interface{}) {
1565 if h, ok := t.(tHelper); ok {
1566 h.Helper()
1567 }
1568 if assert.NotZero(t, i, msgAndArgs...) {
1569 return
1570 }
1571 t.FailNow()
1572}
1573
1574// NotZerof asserts that i is not the zero value for its type.
1575func NotZerof(t TestingT, i interface{}, msg string, args ...interface{}) {
1576 if h, ok := t.(tHelper); ok {
1577 h.Helper()
1578 }
1579 if assert.NotZerof(t, i, msg, args...) {
1580 return
1581 }
1582 t.FailNow()
1583}
1584
1585// Panics asserts that the code inside the specified PanicTestFunc panics.
1586//
1587// assert.Panics(t, func(){ GoCrazy() })
1588func Panics(t TestingT, f assert.PanicTestFunc, msgAndArgs ...interface{}) {
1589 if h, ok := t.(tHelper); ok {
1590 h.Helper()
1591 }
1592 if assert.Panics(t, f, msgAndArgs...) {
1593 return
1594 }
1595 t.FailNow()
1596}
1597
1598// PanicsWithError asserts that the code inside the specified PanicTestFunc
1599// panics, and that the recovered panic value is an error that satisfies the
1600// EqualError comparison.
1601//
1602// assert.PanicsWithError(t, "crazy error", func(){ GoCrazy() })
1603func PanicsWithError(t TestingT, errString string, f assert.PanicTestFunc, msgAndArgs ...interface{}) {
1604 if h, ok := t.(tHelper); ok {
1605 h.Helper()
1606 }
1607 if assert.PanicsWithError(t, errString, f, msgAndArgs...) {
1608 return
1609 }
1610 t.FailNow()
1611}
1612
1613// PanicsWithErrorf asserts that the code inside the specified PanicTestFunc
1614// panics, and that the recovered panic value is an error that satisfies the
1615// EqualError comparison.
1616//
1617// assert.PanicsWithErrorf(t, "crazy error", func(){ GoCrazy() }, "error message %s", "formatted")
1618func PanicsWithErrorf(t TestingT, errString string, f assert.PanicTestFunc, msg string, args ...interface{}) {
1619 if h, ok := t.(tHelper); ok {
1620 h.Helper()
1621 }
1622 if assert.PanicsWithErrorf(t, errString, f, msg, args...) {
1623 return
1624 }
1625 t.FailNow()
1626}
1627
1628// PanicsWithValue asserts that the code inside the specified PanicTestFunc panics, and that
1629// the recovered panic value equals the expected panic value.
1630//
1631// assert.PanicsWithValue(t, "crazy error", func(){ GoCrazy() })
1632func PanicsWithValue(t TestingT, expected interface{}, f assert.PanicTestFunc, msgAndArgs ...interface{}) {
1633 if h, ok := t.(tHelper); ok {
1634 h.Helper()
1635 }
1636 if assert.PanicsWithValue(t, expected, f, msgAndArgs...) {
1637 return
1638 }
1639 t.FailNow()
1640}
1641
1642// PanicsWithValuef asserts that the code inside the specified PanicTestFunc panics, and that
1643// the recovered panic value equals the expected panic value.
1644//
1645// assert.PanicsWithValuef(t, "crazy error", func(){ GoCrazy() }, "error message %s", "formatted")
1646func PanicsWithValuef(t TestingT, expected interface{}, f assert.PanicTestFunc, msg string, args ...interface{}) {
1647 if h, ok := t.(tHelper); ok {
1648 h.Helper()
1649 }
1650 if assert.PanicsWithValuef(t, expected, f, msg, args...) {
1651 return
1652 }
1653 t.FailNow()
1654}
1655
1656// Panicsf asserts that the code inside the specified PanicTestFunc panics.
1657//
1658// assert.Panicsf(t, func(){ GoCrazy() }, "error message %s", "formatted")
1659func Panicsf(t TestingT, f assert.PanicTestFunc, msg string, args ...interface{}) {
1660 if h, ok := t.(tHelper); ok {
1661 h.Helper()
1662 }
1663 if assert.Panicsf(t, f, msg, args...) {
1664 return
1665 }
1666 t.FailNow()
1667}
1668
1669// Positive asserts that the specified element is positive
1670//
1671// assert.Positive(t, 1)
1672// assert.Positive(t, 1.23)
1673func Positive(t TestingT, e interface{}, msgAndArgs ...interface{}) {
1674 if h, ok := t.(tHelper); ok {
1675 h.Helper()
1676 }
1677 if assert.Positive(t, e, msgAndArgs...) {
1678 return
1679 }
1680 t.FailNow()
1681}
1682
1683// Positivef asserts that the specified element is positive
1684//
1685// assert.Positivef(t, 1, "error message %s", "formatted")
1686// assert.Positivef(t, 1.23, "error message %s", "formatted")
1687func Positivef(t TestingT, e interface{}, msg string, args ...interface{}) {
1688 if h, ok := t.(tHelper); ok {
1689 h.Helper()
1690 }
1691 if assert.Positivef(t, e, msg, args...) {
1692 return
1693 }
1694 t.FailNow()
1695}
1696
1697// Regexp asserts that a specified regexp matches a string.
1698//
1699// assert.Regexp(t, regexp.MustCompile("start"), "it's starting")
1700// assert.Regexp(t, "start...$", "it's not starting")
1701func Regexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ...interface{}) {
1702 if h, ok := t.(tHelper); ok {
1703 h.Helper()
1704 }
1705 if assert.Regexp(t, rx, str, msgAndArgs...) {
1706 return
1707 }
1708 t.FailNow()
1709}
1710
1711// Regexpf asserts that a specified regexp matches a string.
1712//
1713// assert.Regexpf(t, regexp.MustCompile("start"), "it's starting", "error message %s", "formatted")
1714// assert.Regexpf(t, "start...$", "it's not starting", "error message %s", "formatted")
1715func Regexpf(t TestingT, rx interface{}, str interface{}, msg string, args ...interface{}) {
1716 if h, ok := t.(tHelper); ok {
1717 h.Helper()
1718 }
1719 if assert.Regexpf(t, rx, str, msg, args...) {
1720 return
1721 }
1722 t.FailNow()
1723}
1724
1725// Same asserts that two pointers reference the same object.
1726//
1727// assert.Same(t, ptr1, ptr2)
1728//
1729// Both arguments must be pointer variables. Pointer variable sameness is
1730// determined based on the equality of both type and value.
1731func Same(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
1732 if h, ok := t.(tHelper); ok {
1733 h.Helper()
1734 }
1735 if assert.Same(t, expected, actual, msgAndArgs...) {
1736 return
1737 }
1738 t.FailNow()
1739}
1740
1741// Samef asserts that two pointers reference the same object.
1742//
1743// assert.Samef(t, ptr1, ptr2, "error message %s", "formatted")
1744//
1745// Both arguments must be pointer variables. Pointer variable sameness is
1746// determined based on the equality of both type and value.
1747func Samef(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) {
1748 if h, ok := t.(tHelper); ok {
1749 h.Helper()
1750 }
1751 if assert.Samef(t, expected, actual, msg, args...) {
1752 return
1753 }
1754 t.FailNow()
1755}
1756
1757// Subset asserts that the specified list(array, slice...) contains all
1758// elements given in the specified subset(array, slice...).
1759//
1760// assert.Subset(t, [1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]")
1761func Subset(t TestingT, list interface{}, subset interface{}, msgAndArgs ...interface{}) {
1762 if h, ok := t.(tHelper); ok {
1763 h.Helper()
1764 }
1765 if assert.Subset(t, list, subset, msgAndArgs...) {
1766 return
1767 }
1768 t.FailNow()
1769}
1770
1771// Subsetf asserts that the specified list(array, slice...) contains all
1772// elements given in the specified subset(array, slice...).
1773//
1774// assert.Subsetf(t, [1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]", "error message %s", "formatted")
1775func Subsetf(t TestingT, list interface{}, subset interface{}, msg string, args ...interface{}) {
1776 if h, ok := t.(tHelper); ok {
1777 h.Helper()
1778 }
1779 if assert.Subsetf(t, list, subset, msg, args...) {
1780 return
1781 }
1782 t.FailNow()
1783}
1784
1785// True asserts that the specified value is true.
1786//
1787// assert.True(t, myBool)
1788func True(t TestingT, value bool, msgAndArgs ...interface{}) {
1789 if h, ok := t.(tHelper); ok {
1790 h.Helper()
1791 }
1792 if assert.True(t, value, msgAndArgs...) {
1793 return
1794 }
1795 t.FailNow()
1796}
1797
1798// Truef asserts that the specified value is true.
1799//
1800// assert.Truef(t, myBool, "error message %s", "formatted")
1801func Truef(t TestingT, value bool, msg string, args ...interface{}) {
1802 if h, ok := t.(tHelper); ok {
1803 h.Helper()
1804 }
1805 if assert.Truef(t, value, msg, args...) {
1806 return
1807 }
1808 t.FailNow()
1809}
1810
1811// WithinDuration asserts that the two times are within duration delta of each other.
1812//
1813// assert.WithinDuration(t, time.Now(), time.Now(), 10*time.Second)
1814func WithinDuration(t TestingT, expected time.Time, actual time.Time, delta time.Duration, msgAndArgs ...interface{}) {
1815 if h, ok := t.(tHelper); ok {
1816 h.Helper()
1817 }
1818 if assert.WithinDuration(t, expected, actual, delta, msgAndArgs...) {
1819 return
1820 }
1821 t.FailNow()
1822}
1823
1824// WithinDurationf asserts that the two times are within duration delta of each other.
1825//
1826// assert.WithinDurationf(t, time.Now(), time.Now(), 10*time.Second, "error message %s", "formatted")
1827func WithinDurationf(t TestingT, expected time.Time, actual time.Time, delta time.Duration, msg string, args ...interface{}) {
1828 if h, ok := t.(tHelper); ok {
1829 h.Helper()
1830 }
1831 if assert.WithinDurationf(t, expected, actual, delta, msg, args...) {
1832 return
1833 }
1834 t.FailNow()
1835}
1836
1837// YAMLEq asserts that two YAML strings are equivalent.
1838func YAMLEq(t TestingT, expected string, actual string, msgAndArgs ...interface{}) {
1839 if h, ok := t.(tHelper); ok {
1840 h.Helper()
1841 }
1842 if assert.YAMLEq(t, expected, actual, msgAndArgs...) {
1843 return
1844 }
1845 t.FailNow()
1846}
1847
1848// YAMLEqf asserts that two YAML strings are equivalent.
1849func YAMLEqf(t TestingT, expected string, actual string, msg string, args ...interface{}) {
1850 if h, ok := t.(tHelper); ok {
1851 h.Helper()
1852 }
1853 if assert.YAMLEqf(t, expected, actual, msg, args...) {
1854 return
1855 }
1856 t.FailNow()
1857}
1858
1859// Zero asserts that i is the zero value for its type.
1860func Zero(t TestingT, i interface{}, msgAndArgs ...interface{}) {
1861 if h, ok := t.(tHelper); ok {
1862 h.Helper()
1863 }
1864 if assert.Zero(t, i, msgAndArgs...) {
1865 return
1866 }
1867 t.FailNow()
1868}
1869
1870// Zerof asserts that i is the zero value for its type.
1871func Zerof(t TestingT, i interface{}, msg string, args ...interface{}) {
1872 if h, ok := t.(tHelper); ok {
1873 h.Helper()
1874 }
1875 if assert.Zerof(t, i, msg, args...) {
1876 return
1877 }
1878 t.FailNow()
1879}