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