1/*
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 assert.Condition(t, comp, msgAndArgs...) {
18 return
19 }
20 if h, ok := t.(tHelper); ok {
21 h.Helper()
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 assert.Conditionf(t, comp, msg, args...) {
29 return
30 }
31 if h, ok := t.(tHelper); ok {
32 h.Helper()
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 assert.Contains(t, s, contains, msgAndArgs...) {
45 return
46 }
47 if h, ok := t.(tHelper); ok {
48 h.Helper()
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 assert.Containsf(t, s, contains, msg, args...) {
61 return
62 }
63 if h, ok := t.(tHelper); ok {
64 h.Helper()
65 }
66 t.FailNow()
67}
68
69// DirExists checks whether a directory exists in the given path. It also fails if the path is a file rather a directory or there is an error checking whether it exists.
70func DirExists(t TestingT, path string, msgAndArgs ...interface{}) {
71 if assert.DirExists(t, path, msgAndArgs...) {
72 return
73 }
74 if h, ok := t.(tHelper); ok {
75 h.Helper()
76 }
77 t.FailNow()
78}
79
80// DirExistsf checks whether a directory exists in the given path. It also fails if the path is a file rather a directory or there is an error checking whether it exists.
81func DirExistsf(t TestingT, path string, msg string, args ...interface{}) {
82 if assert.DirExistsf(t, path, msg, args...) {
83 return
84 }
85 if h, ok := t.(tHelper); ok {
86 h.Helper()
87 }
88 t.FailNow()
89}
90
91// ElementsMatch asserts that the specified listA(array, slice...) is equal to specified
92// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements,
93// the number of appearances of each of them in both lists should match.
94//
95// assert.ElementsMatch(t, [1, 3, 2, 3], [1, 3, 3, 2])
96func ElementsMatch(t TestingT, listA interface{}, listB interface{}, msgAndArgs ...interface{}) {
97 if assert.ElementsMatch(t, listA, listB, msgAndArgs...) {
98 return
99 }
100 if h, ok := t.(tHelper); ok {
101 h.Helper()
102 }
103 t.FailNow()
104}
105
106// ElementsMatchf asserts that the specified listA(array, slice...) is equal to specified
107// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements,
108// the number of appearances of each of them in both lists should match.
109//
110// assert.ElementsMatchf(t, [1, 3, 2, 3], [1, 3, 3, 2], "error message %s", "formatted")
111func ElementsMatchf(t TestingT, listA interface{}, listB interface{}, msg string, args ...interface{}) {
112 if assert.ElementsMatchf(t, listA, listB, msg, args...) {
113 return
114 }
115 if h, ok := t.(tHelper); ok {
116 h.Helper()
117 }
118 t.FailNow()
119}
120
121// Empty asserts that the specified object is empty. I.e. nil, "", false, 0 or either
122// a slice or a channel with len == 0.
123//
124// assert.Empty(t, obj)
125func Empty(t TestingT, object interface{}, msgAndArgs ...interface{}) {
126 if assert.Empty(t, object, msgAndArgs...) {
127 return
128 }
129 if h, ok := t.(tHelper); ok {
130 h.Helper()
131 }
132 t.FailNow()
133}
134
135// Emptyf asserts that the specified object is empty. I.e. nil, "", false, 0 or either
136// a slice or a channel with len == 0.
137//
138// assert.Emptyf(t, obj, "error message %s", "formatted")
139func Emptyf(t TestingT, object interface{}, msg string, args ...interface{}) {
140 if assert.Emptyf(t, object, msg, args...) {
141 return
142 }
143 if h, ok := t.(tHelper); ok {
144 h.Helper()
145 }
146 t.FailNow()
147}
148
149// Equal asserts that two objects are equal.
150//
151// assert.Equal(t, 123, 123)
152//
153// Pointer variable equality is determined based on the equality of the
154// referenced values (as opposed to the memory addresses). Function equality
155// cannot be determined and will always fail.
156func Equal(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
157 if assert.Equal(t, expected, actual, msgAndArgs...) {
158 return
159 }
160 if h, ok := t.(tHelper); ok {
161 h.Helper()
162 }
163 t.FailNow()
164}
165
166// EqualError asserts that a function returned an error (i.e. not `nil`)
167// and that it is equal to the provided error.
168//
169// actualObj, err := SomeFunction()
170// assert.EqualError(t, err, expectedErrorString)
171func EqualError(t TestingT, theError error, errString string, msgAndArgs ...interface{}) {
172 if assert.EqualError(t, theError, errString, msgAndArgs...) {
173 return
174 }
175 if h, ok := t.(tHelper); ok {
176 h.Helper()
177 }
178 t.FailNow()
179}
180
181// EqualErrorf asserts that a function returned an error (i.e. not `nil`)
182// and that it is equal to the provided error.
183//
184// actualObj, err := SomeFunction()
185// assert.EqualErrorf(t, err, expectedErrorString, "error message %s", "formatted")
186func EqualErrorf(t TestingT, theError error, errString string, msg string, args ...interface{}) {
187 if assert.EqualErrorf(t, theError, errString, msg, args...) {
188 return
189 }
190 if h, ok := t.(tHelper); ok {
191 h.Helper()
192 }
193 t.FailNow()
194}
195
196// EqualValues asserts that two objects are equal or convertable to the same types
197// and equal.
198//
199// assert.EqualValues(t, uint32(123), int32(123))
200func EqualValues(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
201 if assert.EqualValues(t, expected, actual, msgAndArgs...) {
202 return
203 }
204 if h, ok := t.(tHelper); ok {
205 h.Helper()
206 }
207 t.FailNow()
208}
209
210// EqualValuesf asserts that two objects are equal or convertable to the same types
211// and equal.
212//
213// assert.EqualValuesf(t, uint32(123, "error message %s", "formatted"), int32(123))
214func EqualValuesf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) {
215 if assert.EqualValuesf(t, expected, actual, msg, args...) {
216 return
217 }
218 if h, ok := t.(tHelper); ok {
219 h.Helper()
220 }
221 t.FailNow()
222}
223
224// Equalf asserts that two objects are equal.
225//
226// assert.Equalf(t, 123, 123, "error message %s", "formatted")
227//
228// Pointer variable equality is determined based on the equality of the
229// referenced values (as opposed to the memory addresses). Function equality
230// cannot be determined and will always fail.
231func Equalf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) {
232 if assert.Equalf(t, expected, actual, msg, args...) {
233 return
234 }
235 if h, ok := t.(tHelper); ok {
236 h.Helper()
237 }
238 t.FailNow()
239}
240
241// Error asserts that a function returned an error (i.e. not `nil`).
242//
243// actualObj, err := SomeFunction()
244// if assert.Error(t, err) {
245// assert.Equal(t, expectedError, err)
246// }
247func Error(t TestingT, err error, msgAndArgs ...interface{}) {
248 if assert.Error(t, err, msgAndArgs...) {
249 return
250 }
251 if h, ok := t.(tHelper); ok {
252 h.Helper()
253 }
254 t.FailNow()
255}
256
257// Errorf asserts that a function returned an error (i.e. not `nil`).
258//
259// actualObj, err := SomeFunction()
260// if assert.Errorf(t, err, "error message %s", "formatted") {
261// assert.Equal(t, expectedErrorf, err)
262// }
263func Errorf(t TestingT, err error, msg string, args ...interface{}) {
264 if assert.Errorf(t, err, msg, args...) {
265 return
266 }
267 if h, ok := t.(tHelper); ok {
268 h.Helper()
269 }
270 t.FailNow()
271}
272
273// Exactly asserts that two objects are equal in value and type.
274//
275// assert.Exactly(t, int32(123), int64(123))
276func Exactly(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
277 if assert.Exactly(t, expected, actual, msgAndArgs...) {
278 return
279 }
280 if h, ok := t.(tHelper); ok {
281 h.Helper()
282 }
283 t.FailNow()
284}
285
286// Exactlyf asserts that two objects are equal in value and type.
287//
288// assert.Exactlyf(t, int32(123, "error message %s", "formatted"), int64(123))
289func Exactlyf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) {
290 if assert.Exactlyf(t, expected, actual, msg, args...) {
291 return
292 }
293 if h, ok := t.(tHelper); ok {
294 h.Helper()
295 }
296 t.FailNow()
297}
298
299// Fail reports a failure through
300func Fail(t TestingT, failureMessage string, msgAndArgs ...interface{}) {
301 if assert.Fail(t, failureMessage, msgAndArgs...) {
302 return
303 }
304 if h, ok := t.(tHelper); ok {
305 h.Helper()
306 }
307 t.FailNow()
308}
309
310// FailNow fails test
311func FailNow(t TestingT, failureMessage string, msgAndArgs ...interface{}) {
312 if assert.FailNow(t, failureMessage, msgAndArgs...) {
313 return
314 }
315 if h, ok := t.(tHelper); ok {
316 h.Helper()
317 }
318 t.FailNow()
319}
320
321// FailNowf fails test
322func FailNowf(t TestingT, failureMessage string, msg string, args ...interface{}) {
323 if assert.FailNowf(t, failureMessage, msg, args...) {
324 return
325 }
326 if h, ok := t.(tHelper); ok {
327 h.Helper()
328 }
329 t.FailNow()
330}
331
332// Failf reports a failure through
333func Failf(t TestingT, failureMessage string, msg string, args ...interface{}) {
334 if assert.Failf(t, failureMessage, msg, args...) {
335 return
336 }
337 if h, ok := t.(tHelper); ok {
338 h.Helper()
339 }
340 t.FailNow()
341}
342
343// False asserts that the specified value is false.
344//
345// assert.False(t, myBool)
346func False(t TestingT, value bool, msgAndArgs ...interface{}) {
347 if assert.False(t, value, msgAndArgs...) {
348 return
349 }
350 if h, ok := t.(tHelper); ok {
351 h.Helper()
352 }
353 t.FailNow()
354}
355
356// Falsef asserts that the specified value is false.
357//
358// assert.Falsef(t, myBool, "error message %s", "formatted")
359func Falsef(t TestingT, value bool, msg string, args ...interface{}) {
360 if assert.Falsef(t, value, msg, args...) {
361 return
362 }
363 if h, ok := t.(tHelper); ok {
364 h.Helper()
365 }
366 t.FailNow()
367}
368
369// FileExists checks whether a file exists in the given path. It also fails if the path points to a directory or there is an error when trying to check the file.
370func FileExists(t TestingT, path string, msgAndArgs ...interface{}) {
371 if assert.FileExists(t, path, msgAndArgs...) {
372 return
373 }
374 if h, ok := t.(tHelper); ok {
375 h.Helper()
376 }
377 t.FailNow()
378}
379
380// FileExistsf checks whether a file exists in the given path. It also fails if the path points to a directory or there is an error when trying to check the file.
381func FileExistsf(t TestingT, path string, msg string, args ...interface{}) {
382 if assert.FileExistsf(t, path, msg, args...) {
383 return
384 }
385 if h, ok := t.(tHelper); ok {
386 h.Helper()
387 }
388 t.FailNow()
389}
390
391// HTTPBodyContains asserts that a specified handler returns a
392// body that contains a string.
393//
394// assert.HTTPBodyContains(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky")
395//
396// Returns whether the assertion was successful (true) or not (false).
397func HTTPBodyContains(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) {
398 if assert.HTTPBodyContains(t, handler, method, url, values, str, msgAndArgs...) {
399 return
400 }
401 if h, ok := t.(tHelper); ok {
402 h.Helper()
403 }
404 t.FailNow()
405}
406
407// HTTPBodyContainsf asserts that a specified handler returns a
408// body that contains a string.
409//
410// assert.HTTPBodyContainsf(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted")
411//
412// Returns whether the assertion was successful (true) or not (false).
413func HTTPBodyContainsf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) {
414 if assert.HTTPBodyContainsf(t, handler, method, url, values, str, msg, args...) {
415 return
416 }
417 if h, ok := t.(tHelper); ok {
418 h.Helper()
419 }
420 t.FailNow()
421}
422
423// HTTPBodyNotContains asserts that a specified handler returns a
424// body that does not contain a string.
425//
426// assert.HTTPBodyNotContains(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky")
427//
428// Returns whether the assertion was successful (true) or not (false).
429func HTTPBodyNotContains(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) {
430 if assert.HTTPBodyNotContains(t, handler, method, url, values, str, msgAndArgs...) {
431 return
432 }
433 if h, ok := t.(tHelper); ok {
434 h.Helper()
435 }
436 t.FailNow()
437}
438
439// HTTPBodyNotContainsf asserts that a specified handler returns a
440// body that does not contain a string.
441//
442// assert.HTTPBodyNotContainsf(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted")
443//
444// Returns whether the assertion was successful (true) or not (false).
445func HTTPBodyNotContainsf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) {
446 if assert.HTTPBodyNotContainsf(t, handler, method, url, values, str, msg, args...) {
447 return
448 }
449 if h, ok := t.(tHelper); ok {
450 h.Helper()
451 }
452 t.FailNow()
453}
454
455// HTTPError asserts that a specified handler returns an error status code.
456//
457// assert.HTTPError(t, myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}}
458//
459// Returns whether the assertion was successful (true) or not (false).
460func HTTPError(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) {
461 if assert.HTTPError(t, handler, method, url, values, msgAndArgs...) {
462 return
463 }
464 if h, ok := t.(tHelper); ok {
465 h.Helper()
466 }
467 t.FailNow()
468}
469
470// HTTPErrorf asserts that a specified handler returns an error status code.
471//
472// assert.HTTPErrorf(t, myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}}
473//
474// Returns whether the assertion was successful (true, "error message %s", "formatted") or not (false).
475func HTTPErrorf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) {
476 if assert.HTTPErrorf(t, handler, method, url, values, msg, args...) {
477 return
478 }
479 if h, ok := t.(tHelper); ok {
480 h.Helper()
481 }
482 t.FailNow()
483}
484
485// HTTPRedirect asserts that a specified handler returns a redirect status code.
486//
487// assert.HTTPRedirect(t, myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}}
488//
489// Returns whether the assertion was successful (true) or not (false).
490func HTTPRedirect(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) {
491 if assert.HTTPRedirect(t, handler, method, url, values, msgAndArgs...) {
492 return
493 }
494 if h, ok := t.(tHelper); ok {
495 h.Helper()
496 }
497 t.FailNow()
498}
499
500// HTTPRedirectf asserts that a specified handler returns a redirect status code.
501//
502// assert.HTTPRedirectf(t, myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}}
503//
504// Returns whether the assertion was successful (true, "error message %s", "formatted") or not (false).
505func HTTPRedirectf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) {
506 if assert.HTTPRedirectf(t, handler, method, url, values, msg, args...) {
507 return
508 }
509 if h, ok := t.(tHelper); ok {
510 h.Helper()
511 }
512 t.FailNow()
513}
514
515// HTTPSuccess asserts that a specified handler returns a success status code.
516//
517// assert.HTTPSuccess(t, myHandler, "POST", "http://www.google.com", nil)
518//
519// Returns whether the assertion was successful (true) or not (false).
520func HTTPSuccess(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) {
521 if assert.HTTPSuccess(t, handler, method, url, values, msgAndArgs...) {
522 return
523 }
524 if h, ok := t.(tHelper); ok {
525 h.Helper()
526 }
527 t.FailNow()
528}
529
530// HTTPSuccessf asserts that a specified handler returns a success status code.
531//
532// assert.HTTPSuccessf(t, myHandler, "POST", "http://www.google.com", nil, "error message %s", "formatted")
533//
534// Returns whether the assertion was successful (true) or not (false).
535func HTTPSuccessf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) {
536 if assert.HTTPSuccessf(t, handler, method, url, values, msg, args...) {
537 return
538 }
539 if h, ok := t.(tHelper); ok {
540 h.Helper()
541 }
542 t.FailNow()
543}
544
545// Implements asserts that an object is implemented by the specified interface.
546//
547// assert.Implements(t, (*MyInterface)(nil), new(MyObject))
548func Implements(t TestingT, interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) {
549 if assert.Implements(t, interfaceObject, object, msgAndArgs...) {
550 return
551 }
552 if h, ok := t.(tHelper); ok {
553 h.Helper()
554 }
555 t.FailNow()
556}
557
558// Implementsf asserts that an object is implemented by the specified interface.
559//
560// assert.Implementsf(t, (*MyInterface, "error message %s", "formatted")(nil), new(MyObject))
561func Implementsf(t TestingT, interfaceObject interface{}, object interface{}, msg string, args ...interface{}) {
562 if assert.Implementsf(t, interfaceObject, object, msg, args...) {
563 return
564 }
565 if h, ok := t.(tHelper); ok {
566 h.Helper()
567 }
568 t.FailNow()
569}
570
571// InDelta asserts that the two numerals are within delta of each other.
572//
573// assert.InDelta(t, math.Pi, (22 / 7.0), 0.01)
574func InDelta(t TestingT, expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) {
575 if assert.InDelta(t, expected, actual, delta, msgAndArgs...) {
576 return
577 }
578 if h, ok := t.(tHelper); ok {
579 h.Helper()
580 }
581 t.FailNow()
582}
583
584// InDeltaMapValues is the same as InDelta, but it compares all values between two maps. Both maps must have exactly the same keys.
585func InDeltaMapValues(t TestingT, expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) {
586 if assert.InDeltaMapValues(t, expected, actual, delta, msgAndArgs...) {
587 return
588 }
589 if h, ok := t.(tHelper); ok {
590 h.Helper()
591 }
592 t.FailNow()
593}
594
595// InDeltaMapValuesf is the same as InDelta, but it compares all values between two maps. Both maps must have exactly the same keys.
596func InDeltaMapValuesf(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) {
597 if assert.InDeltaMapValuesf(t, expected, actual, delta, msg, args...) {
598 return
599 }
600 if h, ok := t.(tHelper); ok {
601 h.Helper()
602 }
603 t.FailNow()
604}
605
606// InDeltaSlice is the same as InDelta, except it compares two slices.
607func InDeltaSlice(t TestingT, expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) {
608 if assert.InDeltaSlice(t, expected, actual, delta, msgAndArgs...) {
609 return
610 }
611 if h, ok := t.(tHelper); ok {
612 h.Helper()
613 }
614 t.FailNow()
615}
616
617// InDeltaSlicef is the same as InDelta, except it compares two slices.
618func InDeltaSlicef(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) {
619 if assert.InDeltaSlicef(t, expected, actual, delta, msg, args...) {
620 return
621 }
622 if h, ok := t.(tHelper); ok {
623 h.Helper()
624 }
625 t.FailNow()
626}
627
628// InDeltaf asserts that the two numerals are within delta of each other.
629//
630// assert.InDeltaf(t, math.Pi, (22 / 7.0, "error message %s", "formatted"), 0.01)
631func InDeltaf(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) {
632 if assert.InDeltaf(t, expected, actual, delta, msg, args...) {
633 return
634 }
635 if h, ok := t.(tHelper); ok {
636 h.Helper()
637 }
638 t.FailNow()
639}
640
641// InEpsilon asserts that expected and actual have a relative error less than epsilon
642func InEpsilon(t TestingT, expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{}) {
643 if assert.InEpsilon(t, expected, actual, epsilon, msgAndArgs...) {
644 return
645 }
646 if h, ok := t.(tHelper); ok {
647 h.Helper()
648 }
649 t.FailNow()
650}
651
652// InEpsilonSlice is the same as InEpsilon, except it compares each value from two slices.
653func InEpsilonSlice(t TestingT, expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{}) {
654 if assert.InEpsilonSlice(t, expected, actual, epsilon, msgAndArgs...) {
655 return
656 }
657 if h, ok := t.(tHelper); ok {
658 h.Helper()
659 }
660 t.FailNow()
661}
662
663// InEpsilonSlicef is the same as InEpsilon, except it compares each value from two slices.
664func InEpsilonSlicef(t TestingT, expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) {
665 if assert.InEpsilonSlicef(t, expected, actual, epsilon, msg, args...) {
666 return
667 }
668 if h, ok := t.(tHelper); ok {
669 h.Helper()
670 }
671 t.FailNow()
672}
673
674// InEpsilonf asserts that expected and actual have a relative error less than epsilon
675func InEpsilonf(t TestingT, expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) {
676 if assert.InEpsilonf(t, expected, actual, epsilon, msg, args...) {
677 return
678 }
679 if h, ok := t.(tHelper); ok {
680 h.Helper()
681 }
682 t.FailNow()
683}
684
685// IsType asserts that the specified objects are of the same type.
686func IsType(t TestingT, expectedType interface{}, object interface{}, msgAndArgs ...interface{}) {
687 if assert.IsType(t, expectedType, object, msgAndArgs...) {
688 return
689 }
690 if h, ok := t.(tHelper); ok {
691 h.Helper()
692 }
693 t.FailNow()
694}
695
696// IsTypef asserts that the specified objects are of the same type.
697func IsTypef(t TestingT, expectedType interface{}, object interface{}, msg string, args ...interface{}) {
698 if assert.IsTypef(t, expectedType, object, msg, args...) {
699 return
700 }
701 if h, ok := t.(tHelper); ok {
702 h.Helper()
703 }
704 t.FailNow()
705}
706
707// JSONEq asserts that two JSON strings are equivalent.
708//
709// assert.JSONEq(t, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`)
710func JSONEq(t TestingT, expected string, actual string, msgAndArgs ...interface{}) {
711 if assert.JSONEq(t, expected, actual, msgAndArgs...) {
712 return
713 }
714 if h, ok := t.(tHelper); ok {
715 h.Helper()
716 }
717 t.FailNow()
718}
719
720// JSONEqf asserts that two JSON strings are equivalent.
721//
722// assert.JSONEqf(t, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`, "error message %s", "formatted")
723func JSONEqf(t TestingT, expected string, actual string, msg string, args ...interface{}) {
724 if assert.JSONEqf(t, expected, actual, msg, args...) {
725 return
726 }
727 if h, ok := t.(tHelper); ok {
728 h.Helper()
729 }
730 t.FailNow()
731}
732
733// Len asserts that the specified object has specific length.
734// Len also fails if the object has a type that len() not accept.
735//
736// assert.Len(t, mySlice, 3)
737func Len(t TestingT, object interface{}, length int, msgAndArgs ...interface{}) {
738 if assert.Len(t, object, length, msgAndArgs...) {
739 return
740 }
741 if h, ok := t.(tHelper); ok {
742 h.Helper()
743 }
744 t.FailNow()
745}
746
747// Lenf asserts that the specified object has specific length.
748// Lenf also fails if the object has a type that len() not accept.
749//
750// assert.Lenf(t, mySlice, 3, "error message %s", "formatted")
751func Lenf(t TestingT, object interface{}, length int, msg string, args ...interface{}) {
752 if assert.Lenf(t, object, length, msg, args...) {
753 return
754 }
755 if h, ok := t.(tHelper); ok {
756 h.Helper()
757 }
758 t.FailNow()
759}
760
761// Nil asserts that the specified object is nil.
762//
763// assert.Nil(t, err)
764func Nil(t TestingT, object interface{}, msgAndArgs ...interface{}) {
765 if assert.Nil(t, object, msgAndArgs...) {
766 return
767 }
768 if h, ok := t.(tHelper); ok {
769 h.Helper()
770 }
771 t.FailNow()
772}
773
774// Nilf asserts that the specified object is nil.
775//
776// assert.Nilf(t, err, "error message %s", "formatted")
777func Nilf(t TestingT, object interface{}, msg string, args ...interface{}) {
778 if assert.Nilf(t, object, msg, args...) {
779 return
780 }
781 if h, ok := t.(tHelper); ok {
782 h.Helper()
783 }
784 t.FailNow()
785}
786
787// NoError asserts that a function returned no error (i.e. `nil`).
788//
789// actualObj, err := SomeFunction()
790// if assert.NoError(t, err) {
791// assert.Equal(t, expectedObj, actualObj)
792// }
793func NoError(t TestingT, err error, msgAndArgs ...interface{}) {
794 if assert.NoError(t, err, msgAndArgs...) {
795 return
796 }
797 if h, ok := t.(tHelper); ok {
798 h.Helper()
799 }
800 t.FailNow()
801}
802
803// NoErrorf asserts that a function returned no error (i.e. `nil`).
804//
805// actualObj, err := SomeFunction()
806// if assert.NoErrorf(t, err, "error message %s", "formatted") {
807// assert.Equal(t, expectedObj, actualObj)
808// }
809func NoErrorf(t TestingT, err error, msg string, args ...interface{}) {
810 if assert.NoErrorf(t, err, msg, args...) {
811 return
812 }
813 if h, ok := t.(tHelper); ok {
814 h.Helper()
815 }
816 t.FailNow()
817}
818
819// NotContains asserts that the specified string, list(array, slice...) or map does NOT contain the
820// specified substring or element.
821//
822// assert.NotContains(t, "Hello World", "Earth")
823// assert.NotContains(t, ["Hello", "World"], "Earth")
824// assert.NotContains(t, {"Hello": "World"}, "Earth")
825func NotContains(t TestingT, s interface{}, contains interface{}, msgAndArgs ...interface{}) {
826 if assert.NotContains(t, s, contains, msgAndArgs...) {
827 return
828 }
829 if h, ok := t.(tHelper); ok {
830 h.Helper()
831 }
832 t.FailNow()
833}
834
835// NotContainsf asserts that the specified string, list(array, slice...) or map does NOT contain the
836// specified substring or element.
837//
838// assert.NotContainsf(t, "Hello World", "Earth", "error message %s", "formatted")
839// assert.NotContainsf(t, ["Hello", "World"], "Earth", "error message %s", "formatted")
840// assert.NotContainsf(t, {"Hello": "World"}, "Earth", "error message %s", "formatted")
841func NotContainsf(t TestingT, s interface{}, contains interface{}, msg string, args ...interface{}) {
842 if assert.NotContainsf(t, s, contains, msg, args...) {
843 return
844 }
845 if h, ok := t.(tHelper); ok {
846 h.Helper()
847 }
848 t.FailNow()
849}
850
851// NotEmpty asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either
852// a slice or a channel with len == 0.
853//
854// if assert.NotEmpty(t, obj) {
855// assert.Equal(t, "two", obj[1])
856// }
857func NotEmpty(t TestingT, object interface{}, msgAndArgs ...interface{}) {
858 if assert.NotEmpty(t, object, msgAndArgs...) {
859 return
860 }
861 if h, ok := t.(tHelper); ok {
862 h.Helper()
863 }
864 t.FailNow()
865}
866
867// NotEmptyf asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either
868// a slice or a channel with len == 0.
869//
870// if assert.NotEmptyf(t, obj, "error message %s", "formatted") {
871// assert.Equal(t, "two", obj[1])
872// }
873func NotEmptyf(t TestingT, object interface{}, msg string, args ...interface{}) {
874 if assert.NotEmptyf(t, object, msg, args...) {
875 return
876 }
877 if h, ok := t.(tHelper); ok {
878 h.Helper()
879 }
880 t.FailNow()
881}
882
883// NotEqual asserts that the specified values are NOT equal.
884//
885// assert.NotEqual(t, obj1, obj2)
886//
887// Pointer variable equality is determined based on the equality of the
888// referenced values (as opposed to the memory addresses).
889func NotEqual(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
890 if assert.NotEqual(t, expected, actual, msgAndArgs...) {
891 return
892 }
893 if h, ok := t.(tHelper); ok {
894 h.Helper()
895 }
896 t.FailNow()
897}
898
899// NotEqualf asserts that the specified values are NOT equal.
900//
901// assert.NotEqualf(t, obj1, obj2, "error message %s", "formatted")
902//
903// Pointer variable equality is determined based on the equality of the
904// referenced values (as opposed to the memory addresses).
905func NotEqualf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) {
906 if assert.NotEqualf(t, expected, actual, msg, args...) {
907 return
908 }
909 if h, ok := t.(tHelper); ok {
910 h.Helper()
911 }
912 t.FailNow()
913}
914
915// NotNil asserts that the specified object is not nil.
916//
917// assert.NotNil(t, err)
918func NotNil(t TestingT, object interface{}, msgAndArgs ...interface{}) {
919 if assert.NotNil(t, object, msgAndArgs...) {
920 return
921 }
922 if h, ok := t.(tHelper); ok {
923 h.Helper()
924 }
925 t.FailNow()
926}
927
928// NotNilf asserts that the specified object is not nil.
929//
930// assert.NotNilf(t, err, "error message %s", "formatted")
931func NotNilf(t TestingT, object interface{}, msg string, args ...interface{}) {
932 if assert.NotNilf(t, object, msg, args...) {
933 return
934 }
935 if h, ok := t.(tHelper); ok {
936 h.Helper()
937 }
938 t.FailNow()
939}
940
941// NotPanics asserts that the code inside the specified PanicTestFunc does NOT panic.
942//
943// assert.NotPanics(t, func(){ RemainCalm() })
944func NotPanics(t TestingT, f assert.PanicTestFunc, msgAndArgs ...interface{}) {
945 if assert.NotPanics(t, f, msgAndArgs...) {
946 return
947 }
948 if h, ok := t.(tHelper); ok {
949 h.Helper()
950 }
951 t.FailNow()
952}
953
954// NotPanicsf asserts that the code inside the specified PanicTestFunc does NOT panic.
955//
956// assert.NotPanicsf(t, func(){ RemainCalm() }, "error message %s", "formatted")
957func NotPanicsf(t TestingT, f assert.PanicTestFunc, msg string, args ...interface{}) {
958 if assert.NotPanicsf(t, f, msg, args...) {
959 return
960 }
961 if h, ok := t.(tHelper); ok {
962 h.Helper()
963 }
964 t.FailNow()
965}
966
967// NotRegexp asserts that a specified regexp does not match a string.
968//
969// assert.NotRegexp(t, regexp.MustCompile("starts"), "it's starting")
970// assert.NotRegexp(t, "^start", "it's not starting")
971func NotRegexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ...interface{}) {
972 if assert.NotRegexp(t, rx, str, msgAndArgs...) {
973 return
974 }
975 if h, ok := t.(tHelper); ok {
976 h.Helper()
977 }
978 t.FailNow()
979}
980
981// NotRegexpf asserts that a specified regexp does not match a string.
982//
983// assert.NotRegexpf(t, regexp.MustCompile("starts", "error message %s", "formatted"), "it's starting")
984// assert.NotRegexpf(t, "^start", "it's not starting", "error message %s", "formatted")
985func NotRegexpf(t TestingT, rx interface{}, str interface{}, msg string, args ...interface{}) {
986 if assert.NotRegexpf(t, rx, str, msg, args...) {
987 return
988 }
989 if h, ok := t.(tHelper); ok {
990 h.Helper()
991 }
992 t.FailNow()
993}
994
995// NotSubset asserts that the specified list(array, slice...) contains not all
996// elements given in the specified subset(array, slice...).
997//
998// assert.NotSubset(t, [1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]")
999func NotSubset(t TestingT, list interface{}, subset interface{}, msgAndArgs ...interface{}) {
1000 if assert.NotSubset(t, list, subset, msgAndArgs...) {
1001 return
1002 }
1003 if h, ok := t.(tHelper); ok {
1004 h.Helper()
1005 }
1006 t.FailNow()
1007}
1008
1009// NotSubsetf asserts that the specified list(array, slice...) contains not all
1010// elements given in the specified subset(array, slice...).
1011//
1012// assert.NotSubsetf(t, [1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]", "error message %s", "formatted")
1013func NotSubsetf(t TestingT, list interface{}, subset interface{}, msg string, args ...interface{}) {
1014 if assert.NotSubsetf(t, list, subset, msg, args...) {
1015 return
1016 }
1017 if h, ok := t.(tHelper); ok {
1018 h.Helper()
1019 }
1020 t.FailNow()
1021}
1022
1023// NotZero asserts that i is not the zero value for its type.
1024func NotZero(t TestingT, i interface{}, msgAndArgs ...interface{}) {
1025 if assert.NotZero(t, i, msgAndArgs...) {
1026 return
1027 }
1028 if h, ok := t.(tHelper); ok {
1029 h.Helper()
1030 }
1031 t.FailNow()
1032}
1033
1034// NotZerof asserts that i is not the zero value for its type.
1035func NotZerof(t TestingT, i interface{}, msg string, args ...interface{}) {
1036 if assert.NotZerof(t, i, msg, args...) {
1037 return
1038 }
1039 if h, ok := t.(tHelper); ok {
1040 h.Helper()
1041 }
1042 t.FailNow()
1043}
1044
1045// Panics asserts that the code inside the specified PanicTestFunc panics.
1046//
1047// assert.Panics(t, func(){ GoCrazy() })
1048func Panics(t TestingT, f assert.PanicTestFunc, msgAndArgs ...interface{}) {
1049 if assert.Panics(t, f, msgAndArgs...) {
1050 return
1051 }
1052 if h, ok := t.(tHelper); ok {
1053 h.Helper()
1054 }
1055 t.FailNow()
1056}
1057
1058// PanicsWithValue asserts that the code inside the specified PanicTestFunc panics, and that
1059// the recovered panic value equals the expected panic value.
1060//
1061// assert.PanicsWithValue(t, "crazy error", func(){ GoCrazy() })
1062func PanicsWithValue(t TestingT, expected interface{}, f assert.PanicTestFunc, msgAndArgs ...interface{}) {
1063 if assert.PanicsWithValue(t, expected, f, msgAndArgs...) {
1064 return
1065 }
1066 if h, ok := t.(tHelper); ok {
1067 h.Helper()
1068 }
1069 t.FailNow()
1070}
1071
1072// PanicsWithValuef asserts that the code inside the specified PanicTestFunc panics, and that
1073// the recovered panic value equals the expected panic value.
1074//
1075// assert.PanicsWithValuef(t, "crazy error", func(){ GoCrazy() }, "error message %s", "formatted")
1076func PanicsWithValuef(t TestingT, expected interface{}, f assert.PanicTestFunc, msg string, args ...interface{}) {
1077 if assert.PanicsWithValuef(t, expected, f, msg, args...) {
1078 return
1079 }
1080 if h, ok := t.(tHelper); ok {
1081 h.Helper()
1082 }
1083 t.FailNow()
1084}
1085
1086// Panicsf asserts that the code inside the specified PanicTestFunc panics.
1087//
1088// assert.Panicsf(t, func(){ GoCrazy() }, "error message %s", "formatted")
1089func Panicsf(t TestingT, f assert.PanicTestFunc, msg string, args ...interface{}) {
1090 if assert.Panicsf(t, f, msg, args...) {
1091 return
1092 }
1093 if h, ok := t.(tHelper); ok {
1094 h.Helper()
1095 }
1096 t.FailNow()
1097}
1098
1099// Regexp asserts that a specified regexp matches a string.
1100//
1101// assert.Regexp(t, regexp.MustCompile("start"), "it's starting")
1102// assert.Regexp(t, "start...$", "it's not starting")
1103func Regexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ...interface{}) {
1104 if assert.Regexp(t, rx, str, msgAndArgs...) {
1105 return
1106 }
1107 if h, ok := t.(tHelper); ok {
1108 h.Helper()
1109 }
1110 t.FailNow()
1111}
1112
1113// Regexpf asserts that a specified regexp matches a string.
1114//
1115// assert.Regexpf(t, regexp.MustCompile("start", "error message %s", "formatted"), "it's starting")
1116// assert.Regexpf(t, "start...$", "it's not starting", "error message %s", "formatted")
1117func Regexpf(t TestingT, rx interface{}, str interface{}, msg string, args ...interface{}) {
1118 if assert.Regexpf(t, rx, str, msg, args...) {
1119 return
1120 }
1121 if h, ok := t.(tHelper); ok {
1122 h.Helper()
1123 }
1124 t.FailNow()
1125}
1126
1127// Subset asserts that the specified list(array, slice...) contains all
1128// elements given in the specified subset(array, slice...).
1129//
1130// assert.Subset(t, [1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]")
1131func Subset(t TestingT, list interface{}, subset interface{}, msgAndArgs ...interface{}) {
1132 if assert.Subset(t, list, subset, msgAndArgs...) {
1133 return
1134 }
1135 if h, ok := t.(tHelper); ok {
1136 h.Helper()
1137 }
1138 t.FailNow()
1139}
1140
1141// Subsetf asserts that the specified list(array, slice...) contains all
1142// elements given in the specified subset(array, slice...).
1143//
1144// assert.Subsetf(t, [1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]", "error message %s", "formatted")
1145func Subsetf(t TestingT, list interface{}, subset interface{}, msg string, args ...interface{}) {
1146 if assert.Subsetf(t, list, subset, msg, args...) {
1147 return
1148 }
1149 if h, ok := t.(tHelper); ok {
1150 h.Helper()
1151 }
1152 t.FailNow()
1153}
1154
1155// True asserts that the specified value is true.
1156//
1157// assert.True(t, myBool)
1158func True(t TestingT, value bool, msgAndArgs ...interface{}) {
1159 if assert.True(t, value, msgAndArgs...) {
1160 return
1161 }
1162 if h, ok := t.(tHelper); ok {
1163 h.Helper()
1164 }
1165 t.FailNow()
1166}
1167
1168// Truef asserts that the specified value is true.
1169//
1170// assert.Truef(t, myBool, "error message %s", "formatted")
1171func Truef(t TestingT, value bool, msg string, args ...interface{}) {
1172 if assert.Truef(t, value, msg, args...) {
1173 return
1174 }
1175 if h, ok := t.(tHelper); ok {
1176 h.Helper()
1177 }
1178 t.FailNow()
1179}
1180
1181// WithinDuration asserts that the two times are within duration delta of each other.
1182//
1183// assert.WithinDuration(t, time.Now(), time.Now(), 10*time.Second)
1184func WithinDuration(t TestingT, expected time.Time, actual time.Time, delta time.Duration, msgAndArgs ...interface{}) {
1185 if assert.WithinDuration(t, expected, actual, delta, msgAndArgs...) {
1186 return
1187 }
1188 if h, ok := t.(tHelper); ok {
1189 h.Helper()
1190 }
1191 t.FailNow()
1192}
1193
1194// WithinDurationf asserts that the two times are within duration delta of each other.
1195//
1196// assert.WithinDurationf(t, time.Now(), time.Now(), 10*time.Second, "error message %s", "formatted")
1197func WithinDurationf(t TestingT, expected time.Time, actual time.Time, delta time.Duration, msg string, args ...interface{}) {
1198 if assert.WithinDurationf(t, expected, actual, delta, msg, args...) {
1199 return
1200 }
1201 if h, ok := t.(tHelper); ok {
1202 h.Helper()
1203 }
1204 t.FailNow()
1205}
1206
1207// Zero asserts that i is the zero value for its type.
1208func Zero(t TestingT, i interface{}, msgAndArgs ...interface{}) {
1209 if assert.Zero(t, i, msgAndArgs...) {
1210 return
1211 }
1212 if h, ok := t.(tHelper); ok {
1213 h.Helper()
1214 }
1215 t.FailNow()
1216}
1217
1218// Zerof asserts that i is the zero value for its type.
1219func Zerof(t TestingT, i interface{}, msg string, args ...interface{}) {
1220 if assert.Zerof(t, i, msg, args...) {
1221 return
1222 }
1223 if h, ok := t.(tHelper); ok {
1224 h.Helper()
1225 }
1226 t.FailNow()
1227}