1
2
3 package assert
4
5 import (
6 http "net/http"
7 url "net/url"
8 time "time"
9 )
10
11
12 func Conditionf(t TestingT, comp Comparison, msg string, args ...interface{}) bool {
13 if h, ok := t.(tHelper); ok {
14 h.Helper()
15 }
16 return Condition(t, comp, append([]interface{}{msg}, args...)...)
17 }
18
19
20
21
22
23
24
25 func Containsf(t TestingT, s interface{}, contains interface{}, msg string, args ...interface{}) bool {
26 if h, ok := t.(tHelper); ok {
27 h.Helper()
28 }
29 return Contains(t, s, contains, append([]interface{}{msg}, args...)...)
30 }
31
32
33
34 func DirExistsf(t TestingT, path string, msg string, args ...interface{}) bool {
35 if h, ok := t.(tHelper); ok {
36 h.Helper()
37 }
38 return DirExists(t, path, append([]interface{}{msg}, args...)...)
39 }
40
41
42
43
44
45
46 func ElementsMatchf(t TestingT, listA interface{}, listB interface{}, msg string, args ...interface{}) bool {
47 if h, ok := t.(tHelper); ok {
48 h.Helper()
49 }
50 return ElementsMatch(t, listA, listB, append([]interface{}{msg}, args...)...)
51 }
52
53
54
55
56
57 func Emptyf(t TestingT, object interface{}, msg string, args ...interface{}) bool {
58 if h, ok := t.(tHelper); ok {
59 h.Helper()
60 }
61 return Empty(t, object, append([]interface{}{msg}, args...)...)
62 }
63
64
65
66
67
68
69
70
71 func Equalf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
72 if h, ok := t.(tHelper); ok {
73 h.Helper()
74 }
75 return Equal(t, expected, actual, append([]interface{}{msg}, args...)...)
76 }
77
78
79
80
81
82
83 func EqualErrorf(t TestingT, theError error, errString string, msg string, args ...interface{}) bool {
84 if h, ok := t.(tHelper); ok {
85 h.Helper()
86 }
87 return EqualError(t, theError, errString, append([]interface{}{msg}, args...)...)
88 }
89
90
91
92
93
94
95
96
97
98
99
100 func EqualExportedValuesf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
101 if h, ok := t.(tHelper); ok {
102 h.Helper()
103 }
104 return EqualExportedValues(t, expected, actual, append([]interface{}{msg}, args...)...)
105 }
106
107
108
109
110
111 func EqualValuesf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
112 if h, ok := t.(tHelper); ok {
113 h.Helper()
114 }
115 return EqualValues(t, expected, actual, append([]interface{}{msg}, args...)...)
116 }
117
118
119
120
121
122
123
124 func Errorf(t TestingT, err error, msg string, args ...interface{}) bool {
125 if h, ok := t.(tHelper); ok {
126 h.Helper()
127 }
128 return Error(t, err, append([]interface{}{msg}, args...)...)
129 }
130
131
132
133 func ErrorAsf(t TestingT, err error, target interface{}, msg string, args ...interface{}) bool {
134 if h, ok := t.(tHelper); ok {
135 h.Helper()
136 }
137 return ErrorAs(t, err, target, append([]interface{}{msg}, args...)...)
138 }
139
140
141
142
143
144
145 func ErrorContainsf(t TestingT, theError error, contains string, msg string, args ...interface{}) bool {
146 if h, ok := t.(tHelper); ok {
147 h.Helper()
148 }
149 return ErrorContains(t, theError, contains, append([]interface{}{msg}, args...)...)
150 }
151
152
153
154 func ErrorIsf(t TestingT, err error, target error, msg string, args ...interface{}) bool {
155 if h, ok := t.(tHelper); ok {
156 h.Helper()
157 }
158 return ErrorIs(t, err, target, append([]interface{}{msg}, args...)...)
159 }
160
161
162
163
164
165 func Eventuallyf(t TestingT, condition func() bool, waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) bool {
166 if h, ok := t.(tHelper); ok {
167 h.Helper()
168 }
169 return Eventually(t, condition, waitFor, tick, append([]interface{}{msg}, args...)...)
170 }
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190 func EventuallyWithTf(t TestingT, condition func(collect *CollectT), waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) bool {
191 if h, ok := t.(tHelper); ok {
192 h.Helper()
193 }
194 return EventuallyWithT(t, condition, waitFor, tick, append([]interface{}{msg}, args...)...)
195 }
196
197
198
199
200 func Exactlyf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
201 if h, ok := t.(tHelper); ok {
202 h.Helper()
203 }
204 return Exactly(t, expected, actual, append([]interface{}{msg}, args...)...)
205 }
206
207
208 func Failf(t TestingT, failureMessage string, msg string, args ...interface{}) bool {
209 if h, ok := t.(tHelper); ok {
210 h.Helper()
211 }
212 return Fail(t, failureMessage, append([]interface{}{msg}, args...)...)
213 }
214
215
216 func FailNowf(t TestingT, failureMessage string, msg string, args ...interface{}) bool {
217 if h, ok := t.(tHelper); ok {
218 h.Helper()
219 }
220 return FailNow(t, failureMessage, append([]interface{}{msg}, args...)...)
221 }
222
223
224
225
226 func Falsef(t TestingT, value bool, msg string, args ...interface{}) bool {
227 if h, ok := t.(tHelper); ok {
228 h.Helper()
229 }
230 return False(t, value, append([]interface{}{msg}, args...)...)
231 }
232
233
234
235 func FileExistsf(t TestingT, path string, msg string, args ...interface{}) bool {
236 if h, ok := t.(tHelper); ok {
237 h.Helper()
238 }
239 return FileExists(t, path, append([]interface{}{msg}, args...)...)
240 }
241
242
243
244
245
246
247 func Greaterf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool {
248 if h, ok := t.(tHelper); ok {
249 h.Helper()
250 }
251 return Greater(t, e1, e2, append([]interface{}{msg}, args...)...)
252 }
253
254
255
256
257
258
259
260 func GreaterOrEqualf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool {
261 if h, ok := t.(tHelper); ok {
262 h.Helper()
263 }
264 return GreaterOrEqual(t, e1, e2, append([]interface{}{msg}, args...)...)
265 }
266
267
268
269
270
271
272
273 func HTTPBodyContainsf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) bool {
274 if h, ok := t.(tHelper); ok {
275 h.Helper()
276 }
277 return HTTPBodyContains(t, handler, method, url, values, str, append([]interface{}{msg}, args...)...)
278 }
279
280
281
282
283
284
285
286 func HTTPBodyNotContainsf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) bool {
287 if h, ok := t.(tHelper); ok {
288 h.Helper()
289 }
290 return HTTPBodyNotContains(t, handler, method, url, values, str, append([]interface{}{msg}, args...)...)
291 }
292
293
294
295
296
297
298 func HTTPErrorf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) bool {
299 if h, ok := t.(tHelper); ok {
300 h.Helper()
301 }
302 return HTTPError(t, handler, method, url, values, append([]interface{}{msg}, args...)...)
303 }
304
305
306
307
308
309
310 func HTTPRedirectf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) bool {
311 if h, ok := t.(tHelper); ok {
312 h.Helper()
313 }
314 return HTTPRedirect(t, handler, method, url, values, append([]interface{}{msg}, args...)...)
315 }
316
317
318
319
320
321
322 func HTTPStatusCodef(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, statuscode int, msg string, args ...interface{}) bool {
323 if h, ok := t.(tHelper); ok {
324 h.Helper()
325 }
326 return HTTPStatusCode(t, handler, method, url, values, statuscode, append([]interface{}{msg}, args...)...)
327 }
328
329
330
331
332
333
334 func HTTPSuccessf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) bool {
335 if h, ok := t.(tHelper); ok {
336 h.Helper()
337 }
338 return HTTPSuccess(t, handler, method, url, values, append([]interface{}{msg}, args...)...)
339 }
340
341
342
343
344 func Implementsf(t TestingT, interfaceObject interface{}, object interface{}, msg string, args ...interface{}) bool {
345 if h, ok := t.(tHelper); ok {
346 h.Helper()
347 }
348 return Implements(t, interfaceObject, object, append([]interface{}{msg}, args...)...)
349 }
350
351
352
353
354 func InDeltaf(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool {
355 if h, ok := t.(tHelper); ok {
356 h.Helper()
357 }
358 return InDelta(t, expected, actual, delta, append([]interface{}{msg}, args...)...)
359 }
360
361
362 func InDeltaMapValuesf(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool {
363 if h, ok := t.(tHelper); ok {
364 h.Helper()
365 }
366 return InDeltaMapValues(t, expected, actual, delta, append([]interface{}{msg}, args...)...)
367 }
368
369
370 func InDeltaSlicef(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool {
371 if h, ok := t.(tHelper); ok {
372 h.Helper()
373 }
374 return InDeltaSlice(t, expected, actual, delta, append([]interface{}{msg}, args...)...)
375 }
376
377
378 func InEpsilonf(t TestingT, expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) bool {
379 if h, ok := t.(tHelper); ok {
380 h.Helper()
381 }
382 return InEpsilon(t, expected, actual, epsilon, append([]interface{}{msg}, args...)...)
383 }
384
385
386 func InEpsilonSlicef(t TestingT, expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) bool {
387 if h, ok := t.(tHelper); ok {
388 h.Helper()
389 }
390 return InEpsilonSlice(t, expected, actual, epsilon, append([]interface{}{msg}, args...)...)
391 }
392
393
394
395
396
397
398 func IsDecreasingf(t TestingT, object interface{}, msg string, args ...interface{}) bool {
399 if h, ok := t.(tHelper); ok {
400 h.Helper()
401 }
402 return IsDecreasing(t, object, append([]interface{}{msg}, args...)...)
403 }
404
405
406
407
408
409
410 func IsIncreasingf(t TestingT, object interface{}, msg string, args ...interface{}) bool {
411 if h, ok := t.(tHelper); ok {
412 h.Helper()
413 }
414 return IsIncreasing(t, object, append([]interface{}{msg}, args...)...)
415 }
416
417
418
419
420
421
422 func IsNonDecreasingf(t TestingT, object interface{}, msg string, args ...interface{}) bool {
423 if h, ok := t.(tHelper); ok {
424 h.Helper()
425 }
426 return IsNonDecreasing(t, object, append([]interface{}{msg}, args...)...)
427 }
428
429
430
431
432
433
434 func IsNonIncreasingf(t TestingT, object interface{}, msg string, args ...interface{}) bool {
435 if h, ok := t.(tHelper); ok {
436 h.Helper()
437 }
438 return IsNonIncreasing(t, object, append([]interface{}{msg}, args...)...)
439 }
440
441
442 func IsTypef(t TestingT, expectedType interface{}, object interface{}, msg string, args ...interface{}) bool {
443 if h, ok := t.(tHelper); ok {
444 h.Helper()
445 }
446 return IsType(t, expectedType, object, append([]interface{}{msg}, args...)...)
447 }
448
449
450
451
452 func JSONEqf(t TestingT, expected string, actual string, msg string, args ...interface{}) bool {
453 if h, ok := t.(tHelper); ok {
454 h.Helper()
455 }
456 return JSONEq(t, expected, actual, append([]interface{}{msg}, args...)...)
457 }
458
459
460
461
462
463 func Lenf(t TestingT, object interface{}, length int, msg string, args ...interface{}) bool {
464 if h, ok := t.(tHelper); ok {
465 h.Helper()
466 }
467 return Len(t, object, length, append([]interface{}{msg}, args...)...)
468 }
469
470
471
472
473
474
475 func Lessf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool {
476 if h, ok := t.(tHelper); ok {
477 h.Helper()
478 }
479 return Less(t, e1, e2, append([]interface{}{msg}, args...)...)
480 }
481
482
483
484
485
486
487
488 func LessOrEqualf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool {
489 if h, ok := t.(tHelper); ok {
490 h.Helper()
491 }
492 return LessOrEqual(t, e1, e2, append([]interface{}{msg}, args...)...)
493 }
494
495
496
497
498
499 func Negativef(t TestingT, e interface{}, msg string, args ...interface{}) bool {
500 if h, ok := t.(tHelper); ok {
501 h.Helper()
502 }
503 return Negative(t, e, append([]interface{}{msg}, args...)...)
504 }
505
506
507
508
509
510 func Neverf(t TestingT, condition func() bool, waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) bool {
511 if h, ok := t.(tHelper); ok {
512 h.Helper()
513 }
514 return Never(t, condition, waitFor, tick, append([]interface{}{msg}, args...)...)
515 }
516
517
518
519
520 func Nilf(t TestingT, object interface{}, msg string, args ...interface{}) bool {
521 if h, ok := t.(tHelper); ok {
522 h.Helper()
523 }
524 return Nil(t, object, append([]interface{}{msg}, args...)...)
525 }
526
527
528
529 func NoDirExistsf(t TestingT, path string, msg string, args ...interface{}) bool {
530 if h, ok := t.(tHelper); ok {
531 h.Helper()
532 }
533 return NoDirExists(t, path, append([]interface{}{msg}, args...)...)
534 }
535
536
537
538
539
540
541
542 func NoErrorf(t TestingT, err error, msg string, args ...interface{}) bool {
543 if h, ok := t.(tHelper); ok {
544 h.Helper()
545 }
546 return NoError(t, err, append([]interface{}{msg}, args...)...)
547 }
548
549
550
551 func NoFileExistsf(t TestingT, path string, msg string, args ...interface{}) bool {
552 if h, ok := t.(tHelper); ok {
553 h.Helper()
554 }
555 return NoFileExists(t, path, append([]interface{}{msg}, args...)...)
556 }
557
558
559
560
561
562
563
564 func NotContainsf(t TestingT, s interface{}, contains interface{}, msg string, args ...interface{}) bool {
565 if h, ok := t.(tHelper); ok {
566 h.Helper()
567 }
568 return NotContains(t, s, contains, append([]interface{}{msg}, args...)...)
569 }
570
571
572
573
574
575
576
577 func NotEmptyf(t TestingT, object interface{}, msg string, args ...interface{}) bool {
578 if h, ok := t.(tHelper); ok {
579 h.Helper()
580 }
581 return NotEmpty(t, object, append([]interface{}{msg}, args...)...)
582 }
583
584
585
586
587
588
589
590 func NotEqualf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
591 if h, ok := t.(tHelper); ok {
592 h.Helper()
593 }
594 return NotEqual(t, expected, actual, append([]interface{}{msg}, args...)...)
595 }
596
597
598
599
600 func NotEqualValuesf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
601 if h, ok := t.(tHelper); ok {
602 h.Helper()
603 }
604 return NotEqualValues(t, expected, actual, append([]interface{}{msg}, args...)...)
605 }
606
607
608
609 func NotErrorIsf(t TestingT, err error, target error, msg string, args ...interface{}) bool {
610 if h, ok := t.(tHelper); ok {
611 h.Helper()
612 }
613 return NotErrorIs(t, err, target, append([]interface{}{msg}, args...)...)
614 }
615
616
617
618
619 func NotImplementsf(t TestingT, interfaceObject interface{}, object interface{}, msg string, args ...interface{}) bool {
620 if h, ok := t.(tHelper); ok {
621 h.Helper()
622 }
623 return NotImplements(t, interfaceObject, object, append([]interface{}{msg}, args...)...)
624 }
625
626
627
628
629 func NotNilf(t TestingT, object interface{}, msg string, args ...interface{}) bool {
630 if h, ok := t.(tHelper); ok {
631 h.Helper()
632 }
633 return NotNil(t, object, append([]interface{}{msg}, args...)...)
634 }
635
636
637
638
639 func NotPanicsf(t TestingT, f PanicTestFunc, msg string, args ...interface{}) bool {
640 if h, ok := t.(tHelper); ok {
641 h.Helper()
642 }
643 return NotPanics(t, f, append([]interface{}{msg}, args...)...)
644 }
645
646
647
648
649
650 func NotRegexpf(t TestingT, rx interface{}, str interface{}, msg string, args ...interface{}) bool {
651 if h, ok := t.(tHelper); ok {
652 h.Helper()
653 }
654 return NotRegexp(t, rx, str, append([]interface{}{msg}, args...)...)
655 }
656
657
658
659
660
661
662
663 func NotSamef(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
664 if h, ok := t.(tHelper); ok {
665 h.Helper()
666 }
667 return NotSame(t, expected, actual, append([]interface{}{msg}, args...)...)
668 }
669
670
671
672
673
674
675
676 func NotSubsetf(t TestingT, list interface{}, subset interface{}, msg string, args ...interface{}) bool {
677 if h, ok := t.(tHelper); ok {
678 h.Helper()
679 }
680 return NotSubset(t, list, subset, append([]interface{}{msg}, args...)...)
681 }
682
683
684 func NotZerof(t TestingT, i interface{}, msg string, args ...interface{}) bool {
685 if h, ok := t.(tHelper); ok {
686 h.Helper()
687 }
688 return NotZero(t, i, append([]interface{}{msg}, args...)...)
689 }
690
691
692
693
694 func Panicsf(t TestingT, f PanicTestFunc, msg string, args ...interface{}) bool {
695 if h, ok := t.(tHelper); ok {
696 h.Helper()
697 }
698 return Panics(t, f, append([]interface{}{msg}, args...)...)
699 }
700
701
702
703
704
705
706 func PanicsWithErrorf(t TestingT, errString string, f PanicTestFunc, msg string, args ...interface{}) bool {
707 if h, ok := t.(tHelper); ok {
708 h.Helper()
709 }
710 return PanicsWithError(t, errString, f, append([]interface{}{msg}, args...)...)
711 }
712
713
714
715
716
717 func PanicsWithValuef(t TestingT, expected interface{}, f PanicTestFunc, msg string, args ...interface{}) bool {
718 if h, ok := t.(tHelper); ok {
719 h.Helper()
720 }
721 return PanicsWithValue(t, expected, f, append([]interface{}{msg}, args...)...)
722 }
723
724
725
726
727
728 func Positivef(t TestingT, e interface{}, msg string, args ...interface{}) bool {
729 if h, ok := t.(tHelper); ok {
730 h.Helper()
731 }
732 return Positive(t, e, append([]interface{}{msg}, args...)...)
733 }
734
735
736
737
738
739 func Regexpf(t TestingT, rx interface{}, str interface{}, msg string, args ...interface{}) bool {
740 if h, ok := t.(tHelper); ok {
741 h.Helper()
742 }
743 return Regexp(t, rx, str, append([]interface{}{msg}, args...)...)
744 }
745
746
747
748
749
750
751
752 func Samef(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
753 if h, ok := t.(tHelper); ok {
754 h.Helper()
755 }
756 return Same(t, expected, actual, append([]interface{}{msg}, args...)...)
757 }
758
759
760
761
762
763
764 func Subsetf(t TestingT, list interface{}, subset interface{}, msg string, args ...interface{}) bool {
765 if h, ok := t.(tHelper); ok {
766 h.Helper()
767 }
768 return Subset(t, list, subset, append([]interface{}{msg}, args...)...)
769 }
770
771
772
773
774 func Truef(t TestingT, value bool, msg string, args ...interface{}) bool {
775 if h, ok := t.(tHelper); ok {
776 h.Helper()
777 }
778 return True(t, value, append([]interface{}{msg}, args...)...)
779 }
780
781
782
783
784 func WithinDurationf(t TestingT, expected time.Time, actual time.Time, delta time.Duration, msg string, args ...interface{}) bool {
785 if h, ok := t.(tHelper); ok {
786 h.Helper()
787 }
788 return WithinDuration(t, expected, actual, delta, append([]interface{}{msg}, args...)...)
789 }
790
791
792
793
794 func WithinRangef(t TestingT, actual time.Time, start time.Time, end time.Time, msg string, args ...interface{}) bool {
795 if h, ok := t.(tHelper); ok {
796 h.Helper()
797 }
798 return WithinRange(t, actual, start, end, append([]interface{}{msg}, args...)...)
799 }
800
801
802 func YAMLEqf(t TestingT, expected string, actual string, msg string, args ...interface{}) bool {
803 if h, ok := t.(tHelper); ok {
804 h.Helper()
805 }
806 return YAMLEq(t, expected, actual, append([]interface{}{msg}, args...)...)
807 }
808
809
810 func Zerof(t TestingT, i interface{}, msg string, args ...interface{}) bool {
811 if h, ok := t.(tHelper); ok {
812 h.Helper()
813 }
814 return Zero(t, i, append([]interface{}{msg}, args...)...)
815 }
816
View as plain text