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