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