blob: 25337a6f07e6e05f3f29e5493cc2ba71cc474abb [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
khenaidood948f772021-08-11 17:49:24 -040056// DirExists checks whether a directory exists in the given path. It also fails
57// if the path is a file rather a directory or there is an error checking whether it exists.
khenaidooac637102019-01-14 15:44:34 -050058func (a *Assertions) DirExists(path string, msgAndArgs ...interface{}) bool {
59 if h, ok := a.t.(tHelper); ok {
60 h.Helper()
61 }
62 return DirExists(a.t, path, msgAndArgs...)
63}
64
khenaidood948f772021-08-11 17:49:24 -040065// DirExistsf checks whether a directory exists in the given path. It also fails
66// if the path is a file rather a directory or there is an error checking whether it exists.
khenaidooac637102019-01-14 15:44:34 -050067func (a *Assertions) DirExistsf(path string, msg string, args ...interface{}) bool {
68 if h, ok := a.t.(tHelper); ok {
69 h.Helper()
70 }
71 return DirExistsf(a.t, path, msg, args...)
72}
73
74// ElementsMatch asserts that the specified listA(array, slice...) is equal to specified
75// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements,
76// the number of appearances of each of them in both lists should match.
77//
78// a.ElementsMatch([1, 3, 2, 3], [1, 3, 3, 2])
79func (a *Assertions) ElementsMatch(listA interface{}, listB interface{}, msgAndArgs ...interface{}) bool {
80 if h, ok := a.t.(tHelper); ok {
81 h.Helper()
82 }
83 return ElementsMatch(a.t, listA, listB, msgAndArgs...)
84}
85
86// ElementsMatchf asserts that the specified listA(array, slice...) is equal to specified
87// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements,
88// the number of appearances of each of them in both lists should match.
89//
90// a.ElementsMatchf([1, 3, 2, 3], [1, 3, 3, 2], "error message %s", "formatted")
91func (a *Assertions) ElementsMatchf(listA interface{}, listB interface{}, msg string, args ...interface{}) bool {
92 if h, ok := a.t.(tHelper); ok {
93 h.Helper()
94 }
95 return ElementsMatchf(a.t, listA, listB, msg, args...)
96}
97
98// Empty asserts that the specified object is empty. I.e. nil, "", false, 0 or either
99// a slice or a channel with len == 0.
100//
101// a.Empty(obj)
102func (a *Assertions) Empty(object interface{}, msgAndArgs ...interface{}) bool {
103 if h, ok := a.t.(tHelper); ok {
104 h.Helper()
105 }
106 return Empty(a.t, object, msgAndArgs...)
107}
108
109// Emptyf asserts that the specified object is empty. I.e. nil, "", false, 0 or either
110// a slice or a channel with len == 0.
111//
112// a.Emptyf(obj, "error message %s", "formatted")
113func (a *Assertions) Emptyf(object interface{}, msg string, args ...interface{}) bool {
114 if h, ok := a.t.(tHelper); ok {
115 h.Helper()
116 }
117 return Emptyf(a.t, object, msg, args...)
118}
119
120// Equal asserts that two objects are equal.
121//
122// a.Equal(123, 123)
123//
124// Pointer variable equality is determined based on the equality of the
125// referenced values (as opposed to the memory addresses). Function equality
126// cannot be determined and will always fail.
127func (a *Assertions) Equal(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool {
128 if h, ok := a.t.(tHelper); ok {
129 h.Helper()
130 }
131 return Equal(a.t, expected, actual, msgAndArgs...)
132}
133
134// EqualError asserts that a function returned an error (i.e. not `nil`)
135// and that it is equal to the provided error.
136//
137// actualObj, err := SomeFunction()
138// a.EqualError(err, expectedErrorString)
139func (a *Assertions) EqualError(theError error, errString string, msgAndArgs ...interface{}) bool {
140 if h, ok := a.t.(tHelper); ok {
141 h.Helper()
142 }
143 return EqualError(a.t, theError, errString, msgAndArgs...)
144}
145
146// EqualErrorf asserts that a function returned an error (i.e. not `nil`)
147// and that it is equal to the provided error.
148//
149// actualObj, err := SomeFunction()
150// a.EqualErrorf(err, expectedErrorString, "error message %s", "formatted")
151func (a *Assertions) EqualErrorf(theError error, errString string, msg string, args ...interface{}) bool {
152 if h, ok := a.t.(tHelper); ok {
153 h.Helper()
154 }
155 return EqualErrorf(a.t, theError, errString, msg, args...)
156}
157
158// EqualValues asserts that two objects are equal or convertable to the same types
159// and equal.
160//
161// a.EqualValues(uint32(123), int32(123))
162func (a *Assertions) EqualValues(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool {
163 if h, ok := a.t.(tHelper); ok {
164 h.Helper()
165 }
166 return EqualValues(a.t, expected, actual, msgAndArgs...)
167}
168
169// EqualValuesf asserts that two objects are equal or convertable to the same types
170// and equal.
171//
khenaidood948f772021-08-11 17:49:24 -0400172// a.EqualValuesf(uint32(123), int32(123), "error message %s", "formatted")
khenaidooac637102019-01-14 15:44:34 -0500173func (a *Assertions) EqualValuesf(expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
174 if h, ok := a.t.(tHelper); ok {
175 h.Helper()
176 }
177 return EqualValuesf(a.t, expected, actual, msg, args...)
178}
179
180// Equalf asserts that two objects are equal.
181//
182// a.Equalf(123, 123, "error message %s", "formatted")
183//
184// Pointer variable equality is determined based on the equality of the
185// referenced values (as opposed to the memory addresses). Function equality
186// cannot be determined and will always fail.
187func (a *Assertions) Equalf(expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
188 if h, ok := a.t.(tHelper); ok {
189 h.Helper()
190 }
191 return Equalf(a.t, expected, actual, msg, args...)
192}
193
194// Error asserts that a function returned an error (i.e. not `nil`).
195//
196// actualObj, err := SomeFunction()
197// if a.Error(err) {
198// assert.Equal(t, expectedError, err)
199// }
200func (a *Assertions) Error(err error, msgAndArgs ...interface{}) bool {
201 if h, ok := a.t.(tHelper); ok {
202 h.Helper()
203 }
204 return Error(a.t, err, msgAndArgs...)
205}
206
khenaidood948f772021-08-11 17:49:24 -0400207// ErrorAs asserts that at least one of the errors in err's chain matches target, and if so, sets target to that error value.
208// This is a wrapper for errors.As.
209func (a *Assertions) ErrorAs(err error, target interface{}, msgAndArgs ...interface{}) bool {
210 if h, ok := a.t.(tHelper); ok {
211 h.Helper()
212 }
213 return ErrorAs(a.t, err, target, msgAndArgs...)
214}
215
216// ErrorAsf asserts that at least one of the errors in err's chain matches target, and if so, sets target to that error value.
217// This is a wrapper for errors.As.
218func (a *Assertions) ErrorAsf(err error, target interface{}, msg string, args ...interface{}) bool {
219 if h, ok := a.t.(tHelper); ok {
220 h.Helper()
221 }
222 return ErrorAsf(a.t, err, target, msg, args...)
223}
224
225// ErrorIs asserts that at least one of the errors in err's chain matches target.
226// This is a wrapper for errors.Is.
227func (a *Assertions) ErrorIs(err error, target error, msgAndArgs ...interface{}) bool {
228 if h, ok := a.t.(tHelper); ok {
229 h.Helper()
230 }
231 return ErrorIs(a.t, err, target, msgAndArgs...)
232}
233
234// ErrorIsf asserts that at least one of the errors in err's chain matches target.
235// This is a wrapper for errors.Is.
236func (a *Assertions) ErrorIsf(err error, target error, msg string, args ...interface{}) bool {
237 if h, ok := a.t.(tHelper); ok {
238 h.Helper()
239 }
240 return ErrorIsf(a.t, err, target, msg, args...)
241}
242
khenaidooac637102019-01-14 15:44:34 -0500243// Errorf asserts that a function returned an error (i.e. not `nil`).
244//
245// actualObj, err := SomeFunction()
246// if a.Errorf(err, "error message %s", "formatted") {
247// assert.Equal(t, expectedErrorf, err)
248// }
249func (a *Assertions) Errorf(err error, msg string, args ...interface{}) bool {
250 if h, ok := a.t.(tHelper); ok {
251 h.Helper()
252 }
253 return Errorf(a.t, err, msg, args...)
254}
255
Scott Baker8461e152019-10-01 14:44:30 -0700256// Eventually asserts that given condition will be met in waitFor time,
257// periodically checking target function each tick.
258//
259// a.Eventually(func() bool { return true; }, time.Second, 10*time.Millisecond)
260func (a *Assertions) Eventually(condition func() bool, waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) bool {
261 if h, ok := a.t.(tHelper); ok {
262 h.Helper()
263 }
264 return Eventually(a.t, condition, waitFor, tick, msgAndArgs...)
265}
266
267// Eventuallyf asserts that given condition will be met in waitFor time,
268// periodically checking target function each tick.
269//
270// a.Eventuallyf(func() bool { return true; }, time.Second, 10*time.Millisecond, "error message %s", "formatted")
271func (a *Assertions) Eventuallyf(condition func() bool, waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) bool {
272 if h, ok := a.t.(tHelper); ok {
273 h.Helper()
274 }
275 return Eventuallyf(a.t, condition, waitFor, tick, msg, args...)
276}
277
khenaidooac637102019-01-14 15:44:34 -0500278// Exactly asserts that two objects are equal in value and type.
279//
280// a.Exactly(int32(123), int64(123))
281func (a *Assertions) Exactly(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool {
282 if h, ok := a.t.(tHelper); ok {
283 h.Helper()
284 }
285 return Exactly(a.t, expected, actual, msgAndArgs...)
286}
287
288// Exactlyf asserts that two objects are equal in value and type.
289//
khenaidood948f772021-08-11 17:49:24 -0400290// a.Exactlyf(int32(123), int64(123), "error message %s", "formatted")
khenaidooac637102019-01-14 15:44:34 -0500291func (a *Assertions) Exactlyf(expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
292 if h, ok := a.t.(tHelper); ok {
293 h.Helper()
294 }
295 return Exactlyf(a.t, expected, actual, msg, args...)
296}
297
298// Fail reports a failure through
299func (a *Assertions) Fail(failureMessage string, msgAndArgs ...interface{}) bool {
300 if h, ok := a.t.(tHelper); ok {
301 h.Helper()
302 }
303 return Fail(a.t, failureMessage, msgAndArgs...)
304}
305
306// FailNow fails test
307func (a *Assertions) FailNow(failureMessage string, msgAndArgs ...interface{}) bool {
308 if h, ok := a.t.(tHelper); ok {
309 h.Helper()
310 }
311 return FailNow(a.t, failureMessage, msgAndArgs...)
312}
313
314// FailNowf fails test
315func (a *Assertions) FailNowf(failureMessage string, msg string, args ...interface{}) bool {
316 if h, ok := a.t.(tHelper); ok {
317 h.Helper()
318 }
319 return FailNowf(a.t, failureMessage, msg, args...)
320}
321
322// Failf reports a failure through
323func (a *Assertions) Failf(failureMessage string, msg string, args ...interface{}) bool {
324 if h, ok := a.t.(tHelper); ok {
325 h.Helper()
326 }
327 return Failf(a.t, failureMessage, msg, args...)
328}
329
330// False asserts that the specified value is false.
331//
332// a.False(myBool)
333func (a *Assertions) False(value bool, msgAndArgs ...interface{}) bool {
334 if h, ok := a.t.(tHelper); ok {
335 h.Helper()
336 }
337 return False(a.t, value, msgAndArgs...)
338}
339
340// Falsef asserts that the specified value is false.
341//
342// a.Falsef(myBool, "error message %s", "formatted")
343func (a *Assertions) Falsef(value bool, msg string, args ...interface{}) bool {
344 if h, ok := a.t.(tHelper); ok {
345 h.Helper()
346 }
347 return Falsef(a.t, value, msg, args...)
348}
349
khenaidood948f772021-08-11 17:49:24 -0400350// FileExists checks whether a file exists in the given path. It also fails if
351// the path points to a directory or there is an error when trying to check the file.
khenaidooac637102019-01-14 15:44:34 -0500352func (a *Assertions) FileExists(path string, msgAndArgs ...interface{}) bool {
353 if h, ok := a.t.(tHelper); ok {
354 h.Helper()
355 }
356 return FileExists(a.t, path, msgAndArgs...)
357}
358
khenaidood948f772021-08-11 17:49:24 -0400359// FileExistsf checks whether a file exists in the given path. It also fails if
360// the path points to a directory or there is an error when trying to check the file.
khenaidooac637102019-01-14 15:44:34 -0500361func (a *Assertions) FileExistsf(path string, msg string, args ...interface{}) bool {
362 if h, ok := a.t.(tHelper); ok {
363 h.Helper()
364 }
365 return FileExistsf(a.t, path, msg, args...)
366}
367
Scott Baker8461e152019-10-01 14:44:30 -0700368// Greater asserts that the first element is greater than the second
369//
370// a.Greater(2, 1)
371// a.Greater(float64(2), float64(1))
372// a.Greater("b", "a")
373func (a *Assertions) Greater(e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool {
374 if h, ok := a.t.(tHelper); ok {
375 h.Helper()
376 }
377 return Greater(a.t, e1, e2, msgAndArgs...)
378}
379
380// GreaterOrEqual asserts that the first element is greater than or equal to the second
381//
382// a.GreaterOrEqual(2, 1)
383// a.GreaterOrEqual(2, 2)
384// a.GreaterOrEqual("b", "a")
385// a.GreaterOrEqual("b", "b")
386func (a *Assertions) GreaterOrEqual(e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool {
387 if h, ok := a.t.(tHelper); ok {
388 h.Helper()
389 }
390 return GreaterOrEqual(a.t, e1, e2, msgAndArgs...)
391}
392
393// GreaterOrEqualf asserts that the first element is greater than or equal to the second
394//
395// a.GreaterOrEqualf(2, 1, "error message %s", "formatted")
396// a.GreaterOrEqualf(2, 2, "error message %s", "formatted")
397// a.GreaterOrEqualf("b", "a", "error message %s", "formatted")
398// a.GreaterOrEqualf("b", "b", "error message %s", "formatted")
399func (a *Assertions) GreaterOrEqualf(e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool {
400 if h, ok := a.t.(tHelper); ok {
401 h.Helper()
402 }
403 return GreaterOrEqualf(a.t, e1, e2, msg, args...)
404}
405
406// Greaterf asserts that the first element is greater than the second
407//
408// a.Greaterf(2, 1, "error message %s", "formatted")
khenaidood948f772021-08-11 17:49:24 -0400409// a.Greaterf(float64(2), float64(1), "error message %s", "formatted")
Scott Baker8461e152019-10-01 14:44:30 -0700410// a.Greaterf("b", "a", "error message %s", "formatted")
411func (a *Assertions) Greaterf(e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool {
412 if h, ok := a.t.(tHelper); ok {
413 h.Helper()
414 }
415 return Greaterf(a.t, e1, e2, msg, args...)
416}
417
khenaidooac637102019-01-14 15:44:34 -0500418// HTTPBodyContains asserts that a specified handler returns a
419// body that contains a string.
420//
421// a.HTTPBodyContains(myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky")
422//
423// Returns whether the assertion was successful (true) or not (false).
424func (a *Assertions) HTTPBodyContains(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) bool {
425 if h, ok := a.t.(tHelper); ok {
426 h.Helper()
427 }
428 return HTTPBodyContains(a.t, handler, method, url, values, str, msgAndArgs...)
429}
430
431// HTTPBodyContainsf asserts that a specified handler returns a
432// body that contains a string.
433//
434// a.HTTPBodyContainsf(myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted")
435//
436// Returns whether the assertion was successful (true) or not (false).
437func (a *Assertions) HTTPBodyContainsf(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) bool {
438 if h, ok := a.t.(tHelper); ok {
439 h.Helper()
440 }
441 return HTTPBodyContainsf(a.t, handler, method, url, values, str, msg, args...)
442}
443
444// HTTPBodyNotContains asserts that a specified handler returns a
445// body that does not contain a string.
446//
447// a.HTTPBodyNotContains(myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky")
448//
449// Returns whether the assertion was successful (true) or not (false).
450func (a *Assertions) HTTPBodyNotContains(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) bool {
451 if h, ok := a.t.(tHelper); ok {
452 h.Helper()
453 }
454 return HTTPBodyNotContains(a.t, handler, method, url, values, str, msgAndArgs...)
455}
456
457// HTTPBodyNotContainsf asserts that a specified handler returns a
458// body that does not contain a string.
459//
460// a.HTTPBodyNotContainsf(myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted")
461//
462// Returns whether the assertion was successful (true) or not (false).
463func (a *Assertions) HTTPBodyNotContainsf(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) bool {
464 if h, ok := a.t.(tHelper); ok {
465 h.Helper()
466 }
467 return HTTPBodyNotContainsf(a.t, handler, method, url, values, str, msg, args...)
468}
469
470// HTTPError asserts that a specified handler returns an error status code.
471//
472// a.HTTPError(myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}}
473//
474// Returns whether the assertion was successful (true) or not (false).
475func (a *Assertions) HTTPError(handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) bool {
476 if h, ok := a.t.(tHelper); ok {
477 h.Helper()
478 }
479 return HTTPError(a.t, handler, method, url, values, msgAndArgs...)
480}
481
482// HTTPErrorf asserts that a specified handler returns an error status code.
483//
484// a.HTTPErrorf(myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}}
485//
khenaidood948f772021-08-11 17:49:24 -0400486// Returns whether the assertion was successful (true) or not (false).
khenaidooac637102019-01-14 15:44:34 -0500487func (a *Assertions) HTTPErrorf(handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) bool {
488 if h, ok := a.t.(tHelper); ok {
489 h.Helper()
490 }
491 return HTTPErrorf(a.t, handler, method, url, values, msg, args...)
492}
493
494// HTTPRedirect asserts that a specified handler returns a redirect status code.
495//
496// a.HTTPRedirect(myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}}
497//
498// Returns whether the assertion was successful (true) or not (false).
499func (a *Assertions) HTTPRedirect(handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) bool {
500 if h, ok := a.t.(tHelper); ok {
501 h.Helper()
502 }
503 return HTTPRedirect(a.t, handler, method, url, values, msgAndArgs...)
504}
505
506// HTTPRedirectf asserts that a specified handler returns a redirect status code.
507//
508// a.HTTPRedirectf(myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}}
509//
khenaidood948f772021-08-11 17:49:24 -0400510// Returns whether the assertion was successful (true) or not (false).
khenaidooac637102019-01-14 15:44:34 -0500511func (a *Assertions) HTTPRedirectf(handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) bool {
512 if h, ok := a.t.(tHelper); ok {
513 h.Helper()
514 }
515 return HTTPRedirectf(a.t, handler, method, url, values, msg, args...)
516}
517
khenaidood948f772021-08-11 17:49:24 -0400518// HTTPStatusCode asserts that a specified handler returns a specified status code.
519//
520// a.HTTPStatusCode(myHandler, "GET", "/notImplemented", nil, 501)
521//
522// Returns whether the assertion was successful (true) or not (false).
523func (a *Assertions) HTTPStatusCode(handler http.HandlerFunc, method string, url string, values url.Values, statuscode int, msgAndArgs ...interface{}) bool {
524 if h, ok := a.t.(tHelper); ok {
525 h.Helper()
526 }
527 return HTTPStatusCode(a.t, handler, method, url, values, statuscode, msgAndArgs...)
528}
529
530// HTTPStatusCodef asserts that a specified handler returns a specified status code.
531//
532// a.HTTPStatusCodef(myHandler, "GET", "/notImplemented", nil, 501, "error message %s", "formatted")
533//
534// Returns whether the assertion was successful (true) or not (false).
535func (a *Assertions) HTTPStatusCodef(handler http.HandlerFunc, method string, url string, values url.Values, statuscode int, msg string, args ...interface{}) bool {
536 if h, ok := a.t.(tHelper); ok {
537 h.Helper()
538 }
539 return HTTPStatusCodef(a.t, handler, method, url, values, statuscode, msg, args...)
540}
541
khenaidooac637102019-01-14 15:44:34 -0500542// HTTPSuccess asserts that a specified handler returns a success status code.
543//
544// a.HTTPSuccess(myHandler, "POST", "http://www.google.com", nil)
545//
546// Returns whether the assertion was successful (true) or not (false).
547func (a *Assertions) HTTPSuccess(handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) bool {
548 if h, ok := a.t.(tHelper); ok {
549 h.Helper()
550 }
551 return HTTPSuccess(a.t, handler, method, url, values, msgAndArgs...)
552}
553
554// HTTPSuccessf asserts that a specified handler returns a success status code.
555//
556// a.HTTPSuccessf(myHandler, "POST", "http://www.google.com", nil, "error message %s", "formatted")
557//
558// Returns whether the assertion was successful (true) or not (false).
559func (a *Assertions) HTTPSuccessf(handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) bool {
560 if h, ok := a.t.(tHelper); ok {
561 h.Helper()
562 }
563 return HTTPSuccessf(a.t, handler, method, url, values, msg, args...)
564}
565
566// Implements asserts that an object is implemented by the specified interface.
567//
568// a.Implements((*MyInterface)(nil), new(MyObject))
569func (a *Assertions) Implements(interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) bool {
570 if h, ok := a.t.(tHelper); ok {
571 h.Helper()
572 }
573 return Implements(a.t, interfaceObject, object, msgAndArgs...)
574}
575
576// Implementsf asserts that an object is implemented by the specified interface.
577//
khenaidood948f772021-08-11 17:49:24 -0400578// a.Implementsf((*MyInterface)(nil), new(MyObject), "error message %s", "formatted")
khenaidooac637102019-01-14 15:44:34 -0500579func (a *Assertions) Implementsf(interfaceObject interface{}, object interface{}, msg string, args ...interface{}) bool {
580 if h, ok := a.t.(tHelper); ok {
581 h.Helper()
582 }
583 return Implementsf(a.t, interfaceObject, object, msg, args...)
584}
585
586// InDelta asserts that the two numerals are within delta of each other.
587//
khenaidood948f772021-08-11 17:49:24 -0400588// a.InDelta(math.Pi, 22/7.0, 0.01)
khenaidooac637102019-01-14 15:44:34 -0500589func (a *Assertions) InDelta(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) bool {
590 if h, ok := a.t.(tHelper); ok {
591 h.Helper()
592 }
593 return InDelta(a.t, expected, actual, delta, msgAndArgs...)
594}
595
596// InDeltaMapValues is the same as InDelta, but it compares all values between two maps. Both maps must have exactly the same keys.
597func (a *Assertions) InDeltaMapValues(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) bool {
598 if h, ok := a.t.(tHelper); ok {
599 h.Helper()
600 }
601 return InDeltaMapValues(a.t, expected, actual, delta, msgAndArgs...)
602}
603
604// InDeltaMapValuesf is the same as InDelta, but it compares all values between two maps. Both maps must have exactly the same keys.
605func (a *Assertions) InDeltaMapValuesf(expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool {
606 if h, ok := a.t.(tHelper); ok {
607 h.Helper()
608 }
609 return InDeltaMapValuesf(a.t, expected, actual, delta, msg, args...)
610}
611
612// InDeltaSlice is the same as InDelta, except it compares two slices.
613func (a *Assertions) InDeltaSlice(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) bool {
614 if h, ok := a.t.(tHelper); ok {
615 h.Helper()
616 }
617 return InDeltaSlice(a.t, expected, actual, delta, msgAndArgs...)
618}
619
620// InDeltaSlicef is the same as InDelta, except it compares two slices.
621func (a *Assertions) InDeltaSlicef(expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool {
622 if h, ok := a.t.(tHelper); ok {
623 h.Helper()
624 }
625 return InDeltaSlicef(a.t, expected, actual, delta, msg, args...)
626}
627
628// InDeltaf asserts that the two numerals are within delta of each other.
629//
khenaidood948f772021-08-11 17:49:24 -0400630// a.InDeltaf(math.Pi, 22/7.0, 0.01, "error message %s", "formatted")
khenaidooac637102019-01-14 15:44:34 -0500631func (a *Assertions) InDeltaf(expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool {
632 if h, ok := a.t.(tHelper); ok {
633 h.Helper()
634 }
635 return InDeltaf(a.t, expected, actual, delta, msg, args...)
636}
637
638// InEpsilon asserts that expected and actual have a relative error less than epsilon
639func (a *Assertions) InEpsilon(expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{}) bool {
640 if h, ok := a.t.(tHelper); ok {
641 h.Helper()
642 }
643 return InEpsilon(a.t, expected, actual, epsilon, msgAndArgs...)
644}
645
646// InEpsilonSlice is the same as InEpsilon, except it compares each value from two slices.
647func (a *Assertions) InEpsilonSlice(expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{}) bool {
648 if h, ok := a.t.(tHelper); ok {
649 h.Helper()
650 }
651 return InEpsilonSlice(a.t, expected, actual, epsilon, msgAndArgs...)
652}
653
654// InEpsilonSlicef is the same as InEpsilon, except it compares each value from two slices.
655func (a *Assertions) InEpsilonSlicef(expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) bool {
656 if h, ok := a.t.(tHelper); ok {
657 h.Helper()
658 }
659 return InEpsilonSlicef(a.t, expected, actual, epsilon, msg, args...)
660}
661
662// InEpsilonf asserts that expected and actual have a relative error less than epsilon
663func (a *Assertions) InEpsilonf(expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) bool {
664 if h, ok := a.t.(tHelper); ok {
665 h.Helper()
666 }
667 return InEpsilonf(a.t, expected, actual, epsilon, msg, args...)
668}
669
khenaidood948f772021-08-11 17:49:24 -0400670// IsDecreasing asserts that the collection is decreasing
671//
672// a.IsDecreasing([]int{2, 1, 0})
673// a.IsDecreasing([]float{2, 1})
674// a.IsDecreasing([]string{"b", "a"})
675func (a *Assertions) IsDecreasing(object interface{}, msgAndArgs ...interface{}) bool {
676 if h, ok := a.t.(tHelper); ok {
677 h.Helper()
678 }
679 return IsDecreasing(a.t, object, msgAndArgs...)
680}
681
682// IsDecreasingf asserts that the collection is decreasing
683//
684// a.IsDecreasingf([]int{2, 1, 0}, "error message %s", "formatted")
685// a.IsDecreasingf([]float{2, 1}, "error message %s", "formatted")
686// a.IsDecreasingf([]string{"b", "a"}, "error message %s", "formatted")
687func (a *Assertions) IsDecreasingf(object interface{}, msg string, args ...interface{}) bool {
688 if h, ok := a.t.(tHelper); ok {
689 h.Helper()
690 }
691 return IsDecreasingf(a.t, object, msg, args...)
692}
693
694// IsIncreasing asserts that the collection is increasing
695//
696// a.IsIncreasing([]int{1, 2, 3})
697// a.IsIncreasing([]float{1, 2})
698// a.IsIncreasing([]string{"a", "b"})
699func (a *Assertions) IsIncreasing(object interface{}, msgAndArgs ...interface{}) bool {
700 if h, ok := a.t.(tHelper); ok {
701 h.Helper()
702 }
703 return IsIncreasing(a.t, object, msgAndArgs...)
704}
705
706// IsIncreasingf asserts that the collection is increasing
707//
708// a.IsIncreasingf([]int{1, 2, 3}, "error message %s", "formatted")
709// a.IsIncreasingf([]float{1, 2}, "error message %s", "formatted")
710// a.IsIncreasingf([]string{"a", "b"}, "error message %s", "formatted")
711func (a *Assertions) IsIncreasingf(object interface{}, msg string, args ...interface{}) bool {
712 if h, ok := a.t.(tHelper); ok {
713 h.Helper()
714 }
715 return IsIncreasingf(a.t, object, msg, args...)
716}
717
718// IsNonDecreasing asserts that the collection is not decreasing
719//
720// a.IsNonDecreasing([]int{1, 1, 2})
721// a.IsNonDecreasing([]float{1, 2})
722// a.IsNonDecreasing([]string{"a", "b"})
723func (a *Assertions) IsNonDecreasing(object interface{}, msgAndArgs ...interface{}) bool {
724 if h, ok := a.t.(tHelper); ok {
725 h.Helper()
726 }
727 return IsNonDecreasing(a.t, object, msgAndArgs...)
728}
729
730// IsNonDecreasingf asserts that the collection is not decreasing
731//
732// a.IsNonDecreasingf([]int{1, 1, 2}, "error message %s", "formatted")
733// a.IsNonDecreasingf([]float{1, 2}, "error message %s", "formatted")
734// a.IsNonDecreasingf([]string{"a", "b"}, "error message %s", "formatted")
735func (a *Assertions) IsNonDecreasingf(object interface{}, msg string, args ...interface{}) bool {
736 if h, ok := a.t.(tHelper); ok {
737 h.Helper()
738 }
739 return IsNonDecreasingf(a.t, object, msg, args...)
740}
741
742// IsNonIncreasing asserts that the collection is not increasing
743//
744// a.IsNonIncreasing([]int{2, 1, 1})
745// a.IsNonIncreasing([]float{2, 1})
746// a.IsNonIncreasing([]string{"b", "a"})
747func (a *Assertions) IsNonIncreasing(object interface{}, msgAndArgs ...interface{}) bool {
748 if h, ok := a.t.(tHelper); ok {
749 h.Helper()
750 }
751 return IsNonIncreasing(a.t, object, msgAndArgs...)
752}
753
754// IsNonIncreasingf asserts that the collection is not increasing
755//
756// a.IsNonIncreasingf([]int{2, 1, 1}, "error message %s", "formatted")
757// a.IsNonIncreasingf([]float{2, 1}, "error message %s", "formatted")
758// a.IsNonIncreasingf([]string{"b", "a"}, "error message %s", "formatted")
759func (a *Assertions) IsNonIncreasingf(object interface{}, msg string, args ...interface{}) bool {
760 if h, ok := a.t.(tHelper); ok {
761 h.Helper()
762 }
763 return IsNonIncreasingf(a.t, object, msg, args...)
764}
765
khenaidooac637102019-01-14 15:44:34 -0500766// IsType asserts that the specified objects are of the same type.
767func (a *Assertions) IsType(expectedType interface{}, object interface{}, msgAndArgs ...interface{}) bool {
768 if h, ok := a.t.(tHelper); ok {
769 h.Helper()
770 }
771 return IsType(a.t, expectedType, object, msgAndArgs...)
772}
773
774// IsTypef asserts that the specified objects are of the same type.
775func (a *Assertions) IsTypef(expectedType interface{}, object interface{}, msg string, args ...interface{}) bool {
776 if h, ok := a.t.(tHelper); ok {
777 h.Helper()
778 }
779 return IsTypef(a.t, expectedType, object, msg, args...)
780}
781
782// JSONEq asserts that two JSON strings are equivalent.
783//
784// a.JSONEq(`{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`)
785func (a *Assertions) JSONEq(expected string, actual string, msgAndArgs ...interface{}) bool {
786 if h, ok := a.t.(tHelper); ok {
787 h.Helper()
788 }
789 return JSONEq(a.t, expected, actual, msgAndArgs...)
790}
791
792// JSONEqf asserts that two JSON strings are equivalent.
793//
794// a.JSONEqf(`{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`, "error message %s", "formatted")
795func (a *Assertions) JSONEqf(expected string, actual string, msg string, args ...interface{}) bool {
796 if h, ok := a.t.(tHelper); ok {
797 h.Helper()
798 }
799 return JSONEqf(a.t, expected, actual, msg, args...)
800}
801
802// Len asserts that the specified object has specific length.
803// Len also fails if the object has a type that len() not accept.
804//
805// a.Len(mySlice, 3)
806func (a *Assertions) Len(object interface{}, length int, msgAndArgs ...interface{}) bool {
807 if h, ok := a.t.(tHelper); ok {
808 h.Helper()
809 }
810 return Len(a.t, object, length, msgAndArgs...)
811}
812
813// Lenf asserts that the specified object has specific length.
814// Lenf also fails if the object has a type that len() not accept.
815//
816// a.Lenf(mySlice, 3, "error message %s", "formatted")
817func (a *Assertions) Lenf(object interface{}, length int, msg string, args ...interface{}) bool {
818 if h, ok := a.t.(tHelper); ok {
819 h.Helper()
820 }
821 return Lenf(a.t, object, length, msg, args...)
822}
823
Scott Baker8461e152019-10-01 14:44:30 -0700824// Less asserts that the first element is less than the second
825//
826// a.Less(1, 2)
827// a.Less(float64(1), float64(2))
828// a.Less("a", "b")
829func (a *Assertions) Less(e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool {
830 if h, ok := a.t.(tHelper); ok {
831 h.Helper()
832 }
833 return Less(a.t, e1, e2, msgAndArgs...)
834}
835
836// LessOrEqual asserts that the first element is less than or equal to the second
837//
838// a.LessOrEqual(1, 2)
839// a.LessOrEqual(2, 2)
840// a.LessOrEqual("a", "b")
841// a.LessOrEqual("b", "b")
842func (a *Assertions) LessOrEqual(e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool {
843 if h, ok := a.t.(tHelper); ok {
844 h.Helper()
845 }
846 return LessOrEqual(a.t, e1, e2, msgAndArgs...)
847}
848
849// LessOrEqualf asserts that the first element is less than or equal to the second
850//
851// a.LessOrEqualf(1, 2, "error message %s", "formatted")
852// a.LessOrEqualf(2, 2, "error message %s", "formatted")
853// a.LessOrEqualf("a", "b", "error message %s", "formatted")
854// a.LessOrEqualf("b", "b", "error message %s", "formatted")
855func (a *Assertions) LessOrEqualf(e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool {
856 if h, ok := a.t.(tHelper); ok {
857 h.Helper()
858 }
859 return LessOrEqualf(a.t, e1, e2, msg, args...)
860}
861
862// Lessf asserts that the first element is less than the second
863//
864// a.Lessf(1, 2, "error message %s", "formatted")
khenaidood948f772021-08-11 17:49:24 -0400865// a.Lessf(float64(1), float64(2), "error message %s", "formatted")
Scott Baker8461e152019-10-01 14:44:30 -0700866// a.Lessf("a", "b", "error message %s", "formatted")
867func (a *Assertions) Lessf(e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool {
868 if h, ok := a.t.(tHelper); ok {
869 h.Helper()
870 }
871 return Lessf(a.t, e1, e2, msg, args...)
872}
873
khenaidood948f772021-08-11 17:49:24 -0400874// Negative asserts that the specified element is negative
875//
876// a.Negative(-1)
877// a.Negative(-1.23)
878func (a *Assertions) Negative(e interface{}, msgAndArgs ...interface{}) bool {
879 if h, ok := a.t.(tHelper); ok {
880 h.Helper()
881 }
882 return Negative(a.t, e, msgAndArgs...)
883}
884
885// Negativef asserts that the specified element is negative
886//
887// a.Negativef(-1, "error message %s", "formatted")
888// a.Negativef(-1.23, "error message %s", "formatted")
889func (a *Assertions) Negativef(e interface{}, msg string, args ...interface{}) bool {
890 if h, ok := a.t.(tHelper); ok {
891 h.Helper()
892 }
893 return Negativef(a.t, e, msg, args...)
894}
895
896// Never asserts that the given condition doesn't satisfy in waitFor time,
897// periodically checking the target function each tick.
898//
899// a.Never(func() bool { return false; }, time.Second, 10*time.Millisecond)
900func (a *Assertions) Never(condition func() bool, waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) bool {
901 if h, ok := a.t.(tHelper); ok {
902 h.Helper()
903 }
904 return Never(a.t, condition, waitFor, tick, msgAndArgs...)
905}
906
907// Neverf asserts that the given condition doesn't satisfy in waitFor time,
908// periodically checking the target function each tick.
909//
910// a.Neverf(func() bool { return false; }, time.Second, 10*time.Millisecond, "error message %s", "formatted")
911func (a *Assertions) Neverf(condition func() bool, waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) bool {
912 if h, ok := a.t.(tHelper); ok {
913 h.Helper()
914 }
915 return Neverf(a.t, condition, waitFor, tick, msg, args...)
916}
917
khenaidooac637102019-01-14 15:44:34 -0500918// Nil asserts that the specified object is nil.
919//
920// a.Nil(err)
921func (a *Assertions) Nil(object interface{}, msgAndArgs ...interface{}) bool {
922 if h, ok := a.t.(tHelper); ok {
923 h.Helper()
924 }
925 return Nil(a.t, object, msgAndArgs...)
926}
927
928// Nilf asserts that the specified object is nil.
929//
930// a.Nilf(err, "error message %s", "formatted")
931func (a *Assertions) Nilf(object interface{}, msg string, args ...interface{}) bool {
932 if h, ok := a.t.(tHelper); ok {
933 h.Helper()
934 }
935 return Nilf(a.t, object, msg, args...)
936}
937
khenaidood948f772021-08-11 17:49:24 -0400938// NoDirExists checks whether a directory does not exist in the given path.
939// It fails if the path points to an existing _directory_ only.
940func (a *Assertions) NoDirExists(path string, msgAndArgs ...interface{}) bool {
941 if h, ok := a.t.(tHelper); ok {
942 h.Helper()
943 }
944 return NoDirExists(a.t, path, msgAndArgs...)
945}
946
947// NoDirExistsf checks whether a directory does not exist in the given path.
948// It fails if the path points to an existing _directory_ only.
949func (a *Assertions) NoDirExistsf(path string, msg string, args ...interface{}) bool {
950 if h, ok := a.t.(tHelper); ok {
951 h.Helper()
952 }
953 return NoDirExistsf(a.t, path, msg, args...)
954}
955
khenaidooac637102019-01-14 15:44:34 -0500956// NoError asserts that a function returned no error (i.e. `nil`).
957//
958// actualObj, err := SomeFunction()
959// if a.NoError(err) {
960// assert.Equal(t, expectedObj, actualObj)
961// }
962func (a *Assertions) NoError(err error, msgAndArgs ...interface{}) bool {
963 if h, ok := a.t.(tHelper); ok {
964 h.Helper()
965 }
966 return NoError(a.t, err, msgAndArgs...)
967}
968
969// NoErrorf asserts that a function returned no error (i.e. `nil`).
970//
971// actualObj, err := SomeFunction()
972// if a.NoErrorf(err, "error message %s", "formatted") {
973// assert.Equal(t, expectedObj, actualObj)
974// }
975func (a *Assertions) NoErrorf(err error, msg string, args ...interface{}) bool {
976 if h, ok := a.t.(tHelper); ok {
977 h.Helper()
978 }
979 return NoErrorf(a.t, err, msg, args...)
980}
981
khenaidood948f772021-08-11 17:49:24 -0400982// NoFileExists checks whether a file does not exist in a given path. It fails
983// if the path points to an existing _file_ only.
984func (a *Assertions) NoFileExists(path string, msgAndArgs ...interface{}) bool {
985 if h, ok := a.t.(tHelper); ok {
986 h.Helper()
987 }
988 return NoFileExists(a.t, path, msgAndArgs...)
989}
990
991// NoFileExistsf checks whether a file does not exist in a given path. It fails
992// if the path points to an existing _file_ only.
993func (a *Assertions) NoFileExistsf(path string, msg string, args ...interface{}) bool {
994 if h, ok := a.t.(tHelper); ok {
995 h.Helper()
996 }
997 return NoFileExistsf(a.t, path, msg, args...)
998}
999
khenaidooac637102019-01-14 15:44:34 -05001000// NotContains asserts that the specified string, list(array, slice...) or map does NOT contain the
1001// specified substring or element.
1002//
1003// a.NotContains("Hello World", "Earth")
1004// a.NotContains(["Hello", "World"], "Earth")
1005// a.NotContains({"Hello": "World"}, "Earth")
1006func (a *Assertions) NotContains(s interface{}, contains interface{}, msgAndArgs ...interface{}) bool {
1007 if h, ok := a.t.(tHelper); ok {
1008 h.Helper()
1009 }
1010 return NotContains(a.t, s, contains, msgAndArgs...)
1011}
1012
1013// NotContainsf asserts that the specified string, list(array, slice...) or map does NOT contain the
1014// specified substring or element.
1015//
1016// a.NotContainsf("Hello World", "Earth", "error message %s", "formatted")
1017// a.NotContainsf(["Hello", "World"], "Earth", "error message %s", "formatted")
1018// a.NotContainsf({"Hello": "World"}, "Earth", "error message %s", "formatted")
1019func (a *Assertions) NotContainsf(s interface{}, contains interface{}, msg string, args ...interface{}) bool {
1020 if h, ok := a.t.(tHelper); ok {
1021 h.Helper()
1022 }
1023 return NotContainsf(a.t, s, contains, msg, args...)
1024}
1025
1026// NotEmpty asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either
1027// a slice or a channel with len == 0.
1028//
1029// if a.NotEmpty(obj) {
1030// assert.Equal(t, "two", obj[1])
1031// }
1032func (a *Assertions) NotEmpty(object interface{}, msgAndArgs ...interface{}) bool {
1033 if h, ok := a.t.(tHelper); ok {
1034 h.Helper()
1035 }
1036 return NotEmpty(a.t, object, msgAndArgs...)
1037}
1038
1039// NotEmptyf asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either
1040// a slice or a channel with len == 0.
1041//
1042// if a.NotEmptyf(obj, "error message %s", "formatted") {
1043// assert.Equal(t, "two", obj[1])
1044// }
1045func (a *Assertions) NotEmptyf(object interface{}, msg string, args ...interface{}) bool {
1046 if h, ok := a.t.(tHelper); ok {
1047 h.Helper()
1048 }
1049 return NotEmptyf(a.t, object, msg, args...)
1050}
1051
1052// NotEqual asserts that the specified values are NOT equal.
1053//
1054// a.NotEqual(obj1, obj2)
1055//
1056// Pointer variable equality is determined based on the equality of the
1057// referenced values (as opposed to the memory addresses).
1058func (a *Assertions) NotEqual(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool {
1059 if h, ok := a.t.(tHelper); ok {
1060 h.Helper()
1061 }
1062 return NotEqual(a.t, expected, actual, msgAndArgs...)
1063}
1064
khenaidood948f772021-08-11 17:49:24 -04001065// NotEqualValues asserts that two objects are not equal even when converted to the same type
1066//
1067// a.NotEqualValues(obj1, obj2)
1068func (a *Assertions) NotEqualValues(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool {
1069 if h, ok := a.t.(tHelper); ok {
1070 h.Helper()
1071 }
1072 return NotEqualValues(a.t, expected, actual, msgAndArgs...)
1073}
1074
1075// NotEqualValuesf asserts that two objects are not equal even when converted to the same type
1076//
1077// a.NotEqualValuesf(obj1, obj2, "error message %s", "formatted")
1078func (a *Assertions) NotEqualValuesf(expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
1079 if h, ok := a.t.(tHelper); ok {
1080 h.Helper()
1081 }
1082 return NotEqualValuesf(a.t, expected, actual, msg, args...)
1083}
1084
khenaidooac637102019-01-14 15:44:34 -05001085// NotEqualf asserts that the specified values are NOT equal.
1086//
1087// a.NotEqualf(obj1, obj2, "error message %s", "formatted")
1088//
1089// Pointer variable equality is determined based on the equality of the
1090// referenced values (as opposed to the memory addresses).
1091func (a *Assertions) NotEqualf(expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
1092 if h, ok := a.t.(tHelper); ok {
1093 h.Helper()
1094 }
1095 return NotEqualf(a.t, expected, actual, msg, args...)
1096}
1097
khenaidood948f772021-08-11 17:49:24 -04001098// NotErrorIs asserts that at none of the errors in err's chain matches target.
1099// This is a wrapper for errors.Is.
1100func (a *Assertions) NotErrorIs(err error, target error, msgAndArgs ...interface{}) bool {
1101 if h, ok := a.t.(tHelper); ok {
1102 h.Helper()
1103 }
1104 return NotErrorIs(a.t, err, target, msgAndArgs...)
1105}
1106
1107// NotErrorIsf asserts that at none of the errors in err's chain matches target.
1108// This is a wrapper for errors.Is.
1109func (a *Assertions) NotErrorIsf(err error, target error, msg string, args ...interface{}) bool {
1110 if h, ok := a.t.(tHelper); ok {
1111 h.Helper()
1112 }
1113 return NotErrorIsf(a.t, err, target, msg, args...)
1114}
1115
khenaidooac637102019-01-14 15:44:34 -05001116// NotNil asserts that the specified object is not nil.
1117//
1118// a.NotNil(err)
1119func (a *Assertions) NotNil(object interface{}, msgAndArgs ...interface{}) bool {
1120 if h, ok := a.t.(tHelper); ok {
1121 h.Helper()
1122 }
1123 return NotNil(a.t, object, msgAndArgs...)
1124}
1125
1126// NotNilf asserts that the specified object is not nil.
1127//
1128// a.NotNilf(err, "error message %s", "formatted")
1129func (a *Assertions) NotNilf(object interface{}, msg string, args ...interface{}) bool {
1130 if h, ok := a.t.(tHelper); ok {
1131 h.Helper()
1132 }
1133 return NotNilf(a.t, object, msg, args...)
1134}
1135
1136// NotPanics asserts that the code inside the specified PanicTestFunc does NOT panic.
1137//
1138// a.NotPanics(func(){ RemainCalm() })
1139func (a *Assertions) NotPanics(f PanicTestFunc, msgAndArgs ...interface{}) bool {
1140 if h, ok := a.t.(tHelper); ok {
1141 h.Helper()
1142 }
1143 return NotPanics(a.t, f, msgAndArgs...)
1144}
1145
1146// NotPanicsf asserts that the code inside the specified PanicTestFunc does NOT panic.
1147//
1148// a.NotPanicsf(func(){ RemainCalm() }, "error message %s", "formatted")
1149func (a *Assertions) NotPanicsf(f PanicTestFunc, msg string, args ...interface{}) bool {
1150 if h, ok := a.t.(tHelper); ok {
1151 h.Helper()
1152 }
1153 return NotPanicsf(a.t, f, msg, args...)
1154}
1155
1156// NotRegexp asserts that a specified regexp does not match a string.
1157//
1158// a.NotRegexp(regexp.MustCompile("starts"), "it's starting")
1159// a.NotRegexp("^start", "it's not starting")
1160func (a *Assertions) NotRegexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) bool {
1161 if h, ok := a.t.(tHelper); ok {
1162 h.Helper()
1163 }
1164 return NotRegexp(a.t, rx, str, msgAndArgs...)
1165}
1166
1167// NotRegexpf asserts that a specified regexp does not match a string.
1168//
khenaidood948f772021-08-11 17:49:24 -04001169// a.NotRegexpf(regexp.MustCompile("starts"), "it's starting", "error message %s", "formatted")
khenaidooac637102019-01-14 15:44:34 -05001170// a.NotRegexpf("^start", "it's not starting", "error message %s", "formatted")
1171func (a *Assertions) NotRegexpf(rx interface{}, str interface{}, msg string, args ...interface{}) bool {
1172 if h, ok := a.t.(tHelper); ok {
1173 h.Helper()
1174 }
1175 return NotRegexpf(a.t, rx, str, msg, args...)
1176}
1177
khenaidood948f772021-08-11 17:49:24 -04001178// NotSame asserts that two pointers do not reference the same object.
1179//
1180// a.NotSame(ptr1, ptr2)
1181//
1182// Both arguments must be pointer variables. Pointer variable sameness is
1183// determined based on the equality of both type and value.
1184func (a *Assertions) NotSame(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool {
1185 if h, ok := a.t.(tHelper); ok {
1186 h.Helper()
1187 }
1188 return NotSame(a.t, expected, actual, msgAndArgs...)
1189}
1190
1191// NotSamef asserts that two pointers do not reference the same object.
1192//
1193// a.NotSamef(ptr1, ptr2, "error message %s", "formatted")
1194//
1195// Both arguments must be pointer variables. Pointer variable sameness is
1196// determined based on the equality of both type and value.
1197func (a *Assertions) NotSamef(expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
1198 if h, ok := a.t.(tHelper); ok {
1199 h.Helper()
1200 }
1201 return NotSamef(a.t, expected, actual, msg, args...)
1202}
1203
khenaidooac637102019-01-14 15:44:34 -05001204// NotSubset asserts that the specified list(array, slice...) contains not all
1205// elements given in the specified subset(array, slice...).
1206//
1207// a.NotSubset([1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]")
1208func (a *Assertions) NotSubset(list interface{}, subset interface{}, msgAndArgs ...interface{}) bool {
1209 if h, ok := a.t.(tHelper); ok {
1210 h.Helper()
1211 }
1212 return NotSubset(a.t, list, subset, msgAndArgs...)
1213}
1214
1215// NotSubsetf asserts that the specified list(array, slice...) contains not all
1216// elements given in the specified subset(array, slice...).
1217//
1218// a.NotSubsetf([1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]", "error message %s", "formatted")
1219func (a *Assertions) NotSubsetf(list interface{}, subset interface{}, msg string, args ...interface{}) bool {
1220 if h, ok := a.t.(tHelper); ok {
1221 h.Helper()
1222 }
1223 return NotSubsetf(a.t, list, subset, msg, args...)
1224}
1225
1226// NotZero asserts that i is not the zero value for its type.
1227func (a *Assertions) NotZero(i interface{}, msgAndArgs ...interface{}) bool {
1228 if h, ok := a.t.(tHelper); ok {
1229 h.Helper()
1230 }
1231 return NotZero(a.t, i, msgAndArgs...)
1232}
1233
1234// NotZerof asserts that i is not the zero value for its type.
1235func (a *Assertions) NotZerof(i interface{}, msg string, args ...interface{}) bool {
1236 if h, ok := a.t.(tHelper); ok {
1237 h.Helper()
1238 }
1239 return NotZerof(a.t, i, msg, args...)
1240}
1241
1242// Panics asserts that the code inside the specified PanicTestFunc panics.
1243//
1244// a.Panics(func(){ GoCrazy() })
1245func (a *Assertions) Panics(f PanicTestFunc, msgAndArgs ...interface{}) bool {
1246 if h, ok := a.t.(tHelper); ok {
1247 h.Helper()
1248 }
1249 return Panics(a.t, f, msgAndArgs...)
1250}
1251
khenaidood948f772021-08-11 17:49:24 -04001252// PanicsWithError asserts that the code inside the specified PanicTestFunc
1253// panics, and that the recovered panic value is an error that satisfies the
1254// EqualError comparison.
1255//
1256// a.PanicsWithError("crazy error", func(){ GoCrazy() })
1257func (a *Assertions) PanicsWithError(errString string, f PanicTestFunc, msgAndArgs ...interface{}) bool {
1258 if h, ok := a.t.(tHelper); ok {
1259 h.Helper()
1260 }
1261 return PanicsWithError(a.t, errString, f, msgAndArgs...)
1262}
1263
1264// PanicsWithErrorf asserts that the code inside the specified PanicTestFunc
1265// panics, and that the recovered panic value is an error that satisfies the
1266// EqualError comparison.
1267//
1268// a.PanicsWithErrorf("crazy error", func(){ GoCrazy() }, "error message %s", "formatted")
1269func (a *Assertions) PanicsWithErrorf(errString string, f PanicTestFunc, msg string, args ...interface{}) bool {
1270 if h, ok := a.t.(tHelper); ok {
1271 h.Helper()
1272 }
1273 return PanicsWithErrorf(a.t, errString, f, msg, args...)
1274}
1275
khenaidooac637102019-01-14 15:44:34 -05001276// PanicsWithValue asserts that the code inside the specified PanicTestFunc panics, and that
1277// the recovered panic value equals the expected panic value.
1278//
1279// a.PanicsWithValue("crazy error", func(){ GoCrazy() })
1280func (a *Assertions) PanicsWithValue(expected interface{}, f PanicTestFunc, msgAndArgs ...interface{}) bool {
1281 if h, ok := a.t.(tHelper); ok {
1282 h.Helper()
1283 }
1284 return PanicsWithValue(a.t, expected, f, msgAndArgs...)
1285}
1286
1287// PanicsWithValuef asserts that the code inside the specified PanicTestFunc panics, and that
1288// the recovered panic value equals the expected panic value.
1289//
1290// a.PanicsWithValuef("crazy error", func(){ GoCrazy() }, "error message %s", "formatted")
1291func (a *Assertions) PanicsWithValuef(expected interface{}, f PanicTestFunc, msg string, args ...interface{}) bool {
1292 if h, ok := a.t.(tHelper); ok {
1293 h.Helper()
1294 }
1295 return PanicsWithValuef(a.t, expected, f, msg, args...)
1296}
1297
1298// Panicsf asserts that the code inside the specified PanicTestFunc panics.
1299//
1300// a.Panicsf(func(){ GoCrazy() }, "error message %s", "formatted")
1301func (a *Assertions) Panicsf(f PanicTestFunc, msg string, args ...interface{}) bool {
1302 if h, ok := a.t.(tHelper); ok {
1303 h.Helper()
1304 }
1305 return Panicsf(a.t, f, msg, args...)
1306}
1307
khenaidood948f772021-08-11 17:49:24 -04001308// Positive asserts that the specified element is positive
1309//
1310// a.Positive(1)
1311// a.Positive(1.23)
1312func (a *Assertions) Positive(e interface{}, msgAndArgs ...interface{}) bool {
1313 if h, ok := a.t.(tHelper); ok {
1314 h.Helper()
1315 }
1316 return Positive(a.t, e, msgAndArgs...)
1317}
1318
1319// Positivef asserts that the specified element is positive
1320//
1321// a.Positivef(1, "error message %s", "formatted")
1322// a.Positivef(1.23, "error message %s", "formatted")
1323func (a *Assertions) Positivef(e interface{}, msg string, args ...interface{}) bool {
1324 if h, ok := a.t.(tHelper); ok {
1325 h.Helper()
1326 }
1327 return Positivef(a.t, e, msg, args...)
1328}
1329
khenaidooac637102019-01-14 15:44:34 -05001330// Regexp asserts that a specified regexp matches a string.
1331//
1332// a.Regexp(regexp.MustCompile("start"), "it's starting")
1333// a.Regexp("start...$", "it's not starting")
1334func (a *Assertions) Regexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) bool {
1335 if h, ok := a.t.(tHelper); ok {
1336 h.Helper()
1337 }
1338 return Regexp(a.t, rx, str, msgAndArgs...)
1339}
1340
1341// Regexpf asserts that a specified regexp matches a string.
1342//
khenaidood948f772021-08-11 17:49:24 -04001343// a.Regexpf(regexp.MustCompile("start"), "it's starting", "error message %s", "formatted")
khenaidooac637102019-01-14 15:44:34 -05001344// a.Regexpf("start...$", "it's not starting", "error message %s", "formatted")
1345func (a *Assertions) Regexpf(rx interface{}, str interface{}, msg string, args ...interface{}) bool {
1346 if h, ok := a.t.(tHelper); ok {
1347 h.Helper()
1348 }
1349 return Regexpf(a.t, rx, str, msg, args...)
1350}
1351
Scott Baker8461e152019-10-01 14:44:30 -07001352// Same asserts that two pointers reference the same object.
1353//
1354// a.Same(ptr1, ptr2)
1355//
1356// Both arguments must be pointer variables. Pointer variable sameness is
1357// determined based on the equality of both type and value.
1358func (a *Assertions) Same(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool {
1359 if h, ok := a.t.(tHelper); ok {
1360 h.Helper()
1361 }
1362 return Same(a.t, expected, actual, msgAndArgs...)
1363}
1364
1365// Samef asserts that two pointers reference the same object.
1366//
1367// a.Samef(ptr1, ptr2, "error message %s", "formatted")
1368//
1369// Both arguments must be pointer variables. Pointer variable sameness is
1370// determined based on the equality of both type and value.
1371func (a *Assertions) Samef(expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
1372 if h, ok := a.t.(tHelper); ok {
1373 h.Helper()
1374 }
1375 return Samef(a.t, expected, actual, msg, args...)
1376}
1377
khenaidooac637102019-01-14 15:44:34 -05001378// Subset asserts that the specified list(array, slice...) contains all
1379// elements given in the specified subset(array, slice...).
1380//
1381// a.Subset([1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]")
1382func (a *Assertions) Subset(list interface{}, subset interface{}, msgAndArgs ...interface{}) bool {
1383 if h, ok := a.t.(tHelper); ok {
1384 h.Helper()
1385 }
1386 return Subset(a.t, list, subset, msgAndArgs...)
1387}
1388
1389// Subsetf asserts that the specified list(array, slice...) contains all
1390// elements given in the specified subset(array, slice...).
1391//
1392// a.Subsetf([1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]", "error message %s", "formatted")
1393func (a *Assertions) Subsetf(list interface{}, subset interface{}, msg string, args ...interface{}) bool {
1394 if h, ok := a.t.(tHelper); ok {
1395 h.Helper()
1396 }
1397 return Subsetf(a.t, list, subset, msg, args...)
1398}
1399
1400// True asserts that the specified value is true.
1401//
1402// a.True(myBool)
1403func (a *Assertions) True(value bool, msgAndArgs ...interface{}) bool {
1404 if h, ok := a.t.(tHelper); ok {
1405 h.Helper()
1406 }
1407 return True(a.t, value, msgAndArgs...)
1408}
1409
1410// Truef asserts that the specified value is true.
1411//
1412// a.Truef(myBool, "error message %s", "formatted")
1413func (a *Assertions) Truef(value bool, msg string, args ...interface{}) bool {
1414 if h, ok := a.t.(tHelper); ok {
1415 h.Helper()
1416 }
1417 return Truef(a.t, value, msg, args...)
1418}
1419
1420// WithinDuration asserts that the two times are within duration delta of each other.
1421//
1422// a.WithinDuration(time.Now(), time.Now(), 10*time.Second)
1423func (a *Assertions) WithinDuration(expected time.Time, actual time.Time, delta time.Duration, msgAndArgs ...interface{}) bool {
1424 if h, ok := a.t.(tHelper); ok {
1425 h.Helper()
1426 }
1427 return WithinDuration(a.t, expected, actual, delta, msgAndArgs...)
1428}
1429
1430// WithinDurationf asserts that the two times are within duration delta of each other.
1431//
1432// a.WithinDurationf(time.Now(), time.Now(), 10*time.Second, "error message %s", "formatted")
1433func (a *Assertions) WithinDurationf(expected time.Time, actual time.Time, delta time.Duration, msg string, args ...interface{}) bool {
1434 if h, ok := a.t.(tHelper); ok {
1435 h.Helper()
1436 }
1437 return WithinDurationf(a.t, expected, actual, delta, msg, args...)
1438}
1439
khenaidood948f772021-08-11 17:49:24 -04001440// YAMLEq asserts that two YAML strings are equivalent.
1441func (a *Assertions) YAMLEq(expected string, actual string, msgAndArgs ...interface{}) bool {
1442 if h, ok := a.t.(tHelper); ok {
1443 h.Helper()
1444 }
1445 return YAMLEq(a.t, expected, actual, msgAndArgs...)
1446}
1447
1448// YAMLEqf asserts that two YAML strings are equivalent.
1449func (a *Assertions) YAMLEqf(expected string, actual string, msg string, args ...interface{}) bool {
1450 if h, ok := a.t.(tHelper); ok {
1451 h.Helper()
1452 }
1453 return YAMLEqf(a.t, expected, actual, msg, args...)
1454}
1455
khenaidooac637102019-01-14 15:44:34 -05001456// Zero asserts that i is the zero value for its type.
1457func (a *Assertions) Zero(i interface{}, msgAndArgs ...interface{}) bool {
1458 if h, ok := a.t.(tHelper); ok {
1459 h.Helper()
1460 }
1461 return Zero(a.t, i, msgAndArgs...)
1462}
1463
1464// Zerof asserts that i is the zero value for its type.
1465func (a *Assertions) Zerof(i interface{}, msg string, args ...interface{}) bool {
1466 if h, ok := a.t.(tHelper); ok {
1467 h.Helper()
1468 }
1469 return Zerof(a.t, i, msg, args...)
1470}