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