blob: 26830403a9b356e2206e4c0c7e4e22ff00d14aa4 [file] [log] [blame]
Jonathan Hart4b110f62020-03-13 17:36:19 -07001/*
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// Eventually asserts that given condition will be met in waitFor time,
219// periodically checking target function each tick.
220//
221// a.Eventually(func() bool { return true; }, time.Second, 10*time.Millisecond)
222func (a *Assertions) Eventually(condition func() bool, waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) bool {
223 if h, ok := a.t.(tHelper); ok {
224 h.Helper()
225 }
226 return Eventually(a.t, condition, waitFor, tick, msgAndArgs...)
227}
228
229// Eventuallyf asserts that given condition will be met in waitFor time,
230// periodically checking target function each tick.
231//
232// a.Eventuallyf(func() bool { return true; }, time.Second, 10*time.Millisecond, "error message %s", "formatted")
233func (a *Assertions) Eventuallyf(condition func() bool, waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) bool {
234 if h, ok := a.t.(tHelper); ok {
235 h.Helper()
236 }
237 return Eventuallyf(a.t, condition, waitFor, tick, msg, args...)
238}
239
240// Exactly asserts that two objects are equal in value and type.
241//
242// a.Exactly(int32(123), int64(123))
243func (a *Assertions) Exactly(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool {
244 if h, ok := a.t.(tHelper); ok {
245 h.Helper()
246 }
247 return Exactly(a.t, expected, actual, msgAndArgs...)
248}
249
250// Exactlyf asserts that two objects are equal in value and type.
251//
252// a.Exactlyf(int32(123, "error message %s", "formatted"), int64(123))
253func (a *Assertions) Exactlyf(expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
254 if h, ok := a.t.(tHelper); ok {
255 h.Helper()
256 }
257 return Exactlyf(a.t, expected, actual, msg, args...)
258}
259
260// Fail reports a failure through
261func (a *Assertions) Fail(failureMessage string, msgAndArgs ...interface{}) bool {
262 if h, ok := a.t.(tHelper); ok {
263 h.Helper()
264 }
265 return Fail(a.t, failureMessage, msgAndArgs...)
266}
267
268// FailNow fails test
269func (a *Assertions) FailNow(failureMessage string, msgAndArgs ...interface{}) bool {
270 if h, ok := a.t.(tHelper); ok {
271 h.Helper()
272 }
273 return FailNow(a.t, failureMessage, msgAndArgs...)
274}
275
276// FailNowf fails test
277func (a *Assertions) FailNowf(failureMessage string, msg string, args ...interface{}) bool {
278 if h, ok := a.t.(tHelper); ok {
279 h.Helper()
280 }
281 return FailNowf(a.t, failureMessage, msg, args...)
282}
283
284// Failf reports a failure through
285func (a *Assertions) Failf(failureMessage string, msg string, args ...interface{}) bool {
286 if h, ok := a.t.(tHelper); ok {
287 h.Helper()
288 }
289 return Failf(a.t, failureMessage, msg, args...)
290}
291
292// False asserts that the specified value is false.
293//
294// a.False(myBool)
295func (a *Assertions) False(value bool, msgAndArgs ...interface{}) bool {
296 if h, ok := a.t.(tHelper); ok {
297 h.Helper()
298 }
299 return False(a.t, value, msgAndArgs...)
300}
301
302// Falsef asserts that the specified value is false.
303//
304// a.Falsef(myBool, "error message %s", "formatted")
305func (a *Assertions) Falsef(value bool, msg string, args ...interface{}) bool {
306 if h, ok := a.t.(tHelper); ok {
307 h.Helper()
308 }
309 return Falsef(a.t, value, msg, args...)
310}
311
312// 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.
313func (a *Assertions) FileExists(path string, msgAndArgs ...interface{}) bool {
314 if h, ok := a.t.(tHelper); ok {
315 h.Helper()
316 }
317 return FileExists(a.t, path, msgAndArgs...)
318}
319
320// 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.
321func (a *Assertions) FileExistsf(path string, msg string, args ...interface{}) bool {
322 if h, ok := a.t.(tHelper); ok {
323 h.Helper()
324 }
325 return FileExistsf(a.t, path, msg, args...)
326}
327
328// Greater asserts that the first element is greater than the second
329//
330// a.Greater(2, 1)
331// a.Greater(float64(2), float64(1))
332// a.Greater("b", "a")
333func (a *Assertions) Greater(e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool {
334 if h, ok := a.t.(tHelper); ok {
335 h.Helper()
336 }
337 return Greater(a.t, e1, e2, msgAndArgs...)
338}
339
340// GreaterOrEqual asserts that the first element is greater than or equal to the second
341//
342// a.GreaterOrEqual(2, 1)
343// a.GreaterOrEqual(2, 2)
344// a.GreaterOrEqual("b", "a")
345// a.GreaterOrEqual("b", "b")
346func (a *Assertions) GreaterOrEqual(e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool {
347 if h, ok := a.t.(tHelper); ok {
348 h.Helper()
349 }
350 return GreaterOrEqual(a.t, e1, e2, msgAndArgs...)
351}
352
353// GreaterOrEqualf asserts that the first element is greater than or equal to the second
354//
355// a.GreaterOrEqualf(2, 1, "error message %s", "formatted")
356// a.GreaterOrEqualf(2, 2, "error message %s", "formatted")
357// a.GreaterOrEqualf("b", "a", "error message %s", "formatted")
358// a.GreaterOrEqualf("b", "b", "error message %s", "formatted")
359func (a *Assertions) GreaterOrEqualf(e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool {
360 if h, ok := a.t.(tHelper); ok {
361 h.Helper()
362 }
363 return GreaterOrEqualf(a.t, e1, e2, msg, args...)
364}
365
366// Greaterf asserts that the first element is greater than the second
367//
368// a.Greaterf(2, 1, "error message %s", "formatted")
369// a.Greaterf(float64(2, "error message %s", "formatted"), float64(1))
370// a.Greaterf("b", "a", "error message %s", "formatted")
371func (a *Assertions) Greaterf(e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool {
372 if h, ok := a.t.(tHelper); ok {
373 h.Helper()
374 }
375 return Greaterf(a.t, e1, e2, msg, args...)
376}
377
378// HTTPBodyContains asserts that a specified handler returns a
379// body that contains a string.
380//
381// a.HTTPBodyContains(myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky")
382//
383// Returns whether the assertion was successful (true) or not (false).
384func (a *Assertions) HTTPBodyContains(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) bool {
385 if h, ok := a.t.(tHelper); ok {
386 h.Helper()
387 }
388 return HTTPBodyContains(a.t, handler, method, url, values, str, msgAndArgs...)
389}
390
391// HTTPBodyContainsf asserts that a specified handler returns a
392// body that contains a string.
393//
394// a.HTTPBodyContainsf(myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted")
395//
396// Returns whether the assertion was successful (true) or not (false).
397func (a *Assertions) HTTPBodyContainsf(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) bool {
398 if h, ok := a.t.(tHelper); ok {
399 h.Helper()
400 }
401 return HTTPBodyContainsf(a.t, handler, method, url, values, str, msg, args...)
402}
403
404// HTTPBodyNotContains asserts that a specified handler returns a
405// body that does not contain a string.
406//
407// a.HTTPBodyNotContains(myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky")
408//
409// Returns whether the assertion was successful (true) or not (false).
410func (a *Assertions) HTTPBodyNotContains(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) bool {
411 if h, ok := a.t.(tHelper); ok {
412 h.Helper()
413 }
414 return HTTPBodyNotContains(a.t, handler, method, url, values, str, msgAndArgs...)
415}
416
417// HTTPBodyNotContainsf asserts that a specified handler returns a
418// body that does not contain a string.
419//
420// a.HTTPBodyNotContainsf(myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted")
421//
422// Returns whether the assertion was successful (true) or not (false).
423func (a *Assertions) HTTPBodyNotContainsf(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) bool {
424 if h, ok := a.t.(tHelper); ok {
425 h.Helper()
426 }
427 return HTTPBodyNotContainsf(a.t, handler, method, url, values, str, msg, args...)
428}
429
430// HTTPError asserts that a specified handler returns an error status code.
431//
432// a.HTTPError(myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}}
433//
434// Returns whether the assertion was successful (true) or not (false).
435func (a *Assertions) HTTPError(handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) bool {
436 if h, ok := a.t.(tHelper); ok {
437 h.Helper()
438 }
439 return HTTPError(a.t, handler, method, url, values, msgAndArgs...)
440}
441
442// HTTPErrorf asserts that a specified handler returns an error status code.
443//
444// a.HTTPErrorf(myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}}
445//
446// Returns whether the assertion was successful (true, "error message %s", "formatted") or not (false).
447func (a *Assertions) HTTPErrorf(handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) bool {
448 if h, ok := a.t.(tHelper); ok {
449 h.Helper()
450 }
451 return HTTPErrorf(a.t, handler, method, url, values, msg, args...)
452}
453
454// HTTPRedirect asserts that a specified handler returns a redirect status code.
455//
456// a.HTTPRedirect(myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}}
457//
458// Returns whether the assertion was successful (true) or not (false).
459func (a *Assertions) HTTPRedirect(handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) bool {
460 if h, ok := a.t.(tHelper); ok {
461 h.Helper()
462 }
463 return HTTPRedirect(a.t, handler, method, url, values, msgAndArgs...)
464}
465
466// HTTPRedirectf asserts that a specified handler returns a redirect status code.
467//
468// a.HTTPRedirectf(myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}}
469//
470// Returns whether the assertion was successful (true, "error message %s", "formatted") or not (false).
471func (a *Assertions) HTTPRedirectf(handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) bool {
472 if h, ok := a.t.(tHelper); ok {
473 h.Helper()
474 }
475 return HTTPRedirectf(a.t, handler, method, url, values, msg, args...)
476}
477
478// HTTPSuccess asserts that a specified handler returns a success status code.
479//
480// a.HTTPSuccess(myHandler, "POST", "http://www.google.com", nil)
481//
482// Returns whether the assertion was successful (true) or not (false).
483func (a *Assertions) HTTPSuccess(handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) bool {
484 if h, ok := a.t.(tHelper); ok {
485 h.Helper()
486 }
487 return HTTPSuccess(a.t, handler, method, url, values, msgAndArgs...)
488}
489
490// HTTPSuccessf asserts that a specified handler returns a success status code.
491//
492// a.HTTPSuccessf(myHandler, "POST", "http://www.google.com", nil, "error message %s", "formatted")
493//
494// Returns whether the assertion was successful (true) or not (false).
495func (a *Assertions) HTTPSuccessf(handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) bool {
496 if h, ok := a.t.(tHelper); ok {
497 h.Helper()
498 }
499 return HTTPSuccessf(a.t, handler, method, url, values, msg, args...)
500}
501
502// Implements asserts that an object is implemented by the specified interface.
503//
504// a.Implements((*MyInterface)(nil), new(MyObject))
505func (a *Assertions) Implements(interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) bool {
506 if h, ok := a.t.(tHelper); ok {
507 h.Helper()
508 }
509 return Implements(a.t, interfaceObject, object, msgAndArgs...)
510}
511
512// Implementsf asserts that an object is implemented by the specified interface.
513//
514// a.Implementsf((*MyInterface, "error message %s", "formatted")(nil), new(MyObject))
515func (a *Assertions) Implementsf(interfaceObject interface{}, object interface{}, msg string, args ...interface{}) bool {
516 if h, ok := a.t.(tHelper); ok {
517 h.Helper()
518 }
519 return Implementsf(a.t, interfaceObject, object, msg, args...)
520}
521
522// InDelta asserts that the two numerals are within delta of each other.
523//
524// a.InDelta(math.Pi, (22 / 7.0), 0.01)
525func (a *Assertions) InDelta(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) bool {
526 if h, ok := a.t.(tHelper); ok {
527 h.Helper()
528 }
529 return InDelta(a.t, expected, actual, delta, msgAndArgs...)
530}
531
532// InDeltaMapValues is the same as InDelta, but it compares all values between two maps. Both maps must have exactly the same keys.
533func (a *Assertions) InDeltaMapValues(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) bool {
534 if h, ok := a.t.(tHelper); ok {
535 h.Helper()
536 }
537 return InDeltaMapValues(a.t, expected, actual, delta, msgAndArgs...)
538}
539
540// InDeltaMapValuesf is the same as InDelta, but it compares all values between two maps. Both maps must have exactly the same keys.
541func (a *Assertions) InDeltaMapValuesf(expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool {
542 if h, ok := a.t.(tHelper); ok {
543 h.Helper()
544 }
545 return InDeltaMapValuesf(a.t, expected, actual, delta, msg, args...)
546}
547
548// InDeltaSlice is the same as InDelta, except it compares two slices.
549func (a *Assertions) InDeltaSlice(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) bool {
550 if h, ok := a.t.(tHelper); ok {
551 h.Helper()
552 }
553 return InDeltaSlice(a.t, expected, actual, delta, msgAndArgs...)
554}
555
556// InDeltaSlicef is the same as InDelta, except it compares two slices.
557func (a *Assertions) InDeltaSlicef(expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool {
558 if h, ok := a.t.(tHelper); ok {
559 h.Helper()
560 }
561 return InDeltaSlicef(a.t, expected, actual, delta, msg, args...)
562}
563
564// InDeltaf asserts that the two numerals are within delta of each other.
565//
566// a.InDeltaf(math.Pi, (22 / 7.0, "error message %s", "formatted"), 0.01)
567func (a *Assertions) InDeltaf(expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool {
568 if h, ok := a.t.(tHelper); ok {
569 h.Helper()
570 }
571 return InDeltaf(a.t, expected, actual, delta, msg, args...)
572}
573
574// InEpsilon asserts that expected and actual have a relative error less than epsilon
575func (a *Assertions) InEpsilon(expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{}) bool {
576 if h, ok := a.t.(tHelper); ok {
577 h.Helper()
578 }
579 return InEpsilon(a.t, expected, actual, epsilon, msgAndArgs...)
580}
581
582// InEpsilonSlice is the same as InEpsilon, except it compares each value from two slices.
583func (a *Assertions) InEpsilonSlice(expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{}) bool {
584 if h, ok := a.t.(tHelper); ok {
585 h.Helper()
586 }
587 return InEpsilonSlice(a.t, expected, actual, epsilon, msgAndArgs...)
588}
589
590// InEpsilonSlicef is the same as InEpsilon, except it compares each value from two slices.
591func (a *Assertions) InEpsilonSlicef(expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) bool {
592 if h, ok := a.t.(tHelper); ok {
593 h.Helper()
594 }
595 return InEpsilonSlicef(a.t, expected, actual, epsilon, msg, args...)
596}
597
598// InEpsilonf asserts that expected and actual have a relative error less than epsilon
599func (a *Assertions) InEpsilonf(expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) bool {
600 if h, ok := a.t.(tHelper); ok {
601 h.Helper()
602 }
603 return InEpsilonf(a.t, expected, actual, epsilon, msg, args...)
604}
605
606// IsType asserts that the specified objects are of the same type.
607func (a *Assertions) IsType(expectedType interface{}, object interface{}, msgAndArgs ...interface{}) bool {
608 if h, ok := a.t.(tHelper); ok {
609 h.Helper()
610 }
611 return IsType(a.t, expectedType, object, msgAndArgs...)
612}
613
614// IsTypef asserts that the specified objects are of the same type.
615func (a *Assertions) IsTypef(expectedType interface{}, object interface{}, msg string, args ...interface{}) bool {
616 if h, ok := a.t.(tHelper); ok {
617 h.Helper()
618 }
619 return IsTypef(a.t, expectedType, object, msg, args...)
620}
621
622// JSONEq asserts that two JSON strings are equivalent.
623//
624// a.JSONEq(`{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`)
625func (a *Assertions) JSONEq(expected string, actual string, msgAndArgs ...interface{}) bool {
626 if h, ok := a.t.(tHelper); ok {
627 h.Helper()
628 }
629 return JSONEq(a.t, expected, actual, msgAndArgs...)
630}
631
632// JSONEqf asserts that two JSON strings are equivalent.
633//
634// a.JSONEqf(`{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`, "error message %s", "formatted")
635func (a *Assertions) JSONEqf(expected string, actual string, msg string, args ...interface{}) bool {
636 if h, ok := a.t.(tHelper); ok {
637 h.Helper()
638 }
639 return JSONEqf(a.t, expected, actual, msg, args...)
640}
641
642// YAMLEq asserts that two YAML strings are equivalent.
643func (a *Assertions) YAMLEq(expected string, actual string, msgAndArgs ...interface{}) bool {
644 if h, ok := a.t.(tHelper); ok {
645 h.Helper()
646 }
647 return YAMLEq(a.t, expected, actual, msgAndArgs...)
648}
649
650// YAMLEqf asserts that two YAML strings are equivalent.
651func (a *Assertions) YAMLEqf(expected string, actual string, msg string, args ...interface{}) bool {
652 if h, ok := a.t.(tHelper); ok {
653 h.Helper()
654 }
655 return YAMLEqf(a.t, expected, actual, msg, args...)
656}
657
658// Len asserts that the specified object has specific length.
659// Len also fails if the object has a type that len() not accept.
660//
661// a.Len(mySlice, 3)
662func (a *Assertions) Len(object interface{}, length int, msgAndArgs ...interface{}) bool {
663 if h, ok := a.t.(tHelper); ok {
664 h.Helper()
665 }
666 return Len(a.t, object, length, msgAndArgs...)
667}
668
669// Lenf asserts that the specified object has specific length.
670// Lenf also fails if the object has a type that len() not accept.
671//
672// a.Lenf(mySlice, 3, "error message %s", "formatted")
673func (a *Assertions) Lenf(object interface{}, length int, msg string, args ...interface{}) bool {
674 if h, ok := a.t.(tHelper); ok {
675 h.Helper()
676 }
677 return Lenf(a.t, object, length, msg, args...)
678}
679
680// Less asserts that the first element is less than the second
681//
682// a.Less(1, 2)
683// a.Less(float64(1), float64(2))
684// a.Less("a", "b")
685func (a *Assertions) Less(e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool {
686 if h, ok := a.t.(tHelper); ok {
687 h.Helper()
688 }
689 return Less(a.t, e1, e2, msgAndArgs...)
690}
691
692// LessOrEqual asserts that the first element is less than or equal to the second
693//
694// a.LessOrEqual(1, 2)
695// a.LessOrEqual(2, 2)
696// a.LessOrEqual("a", "b")
697// a.LessOrEqual("b", "b")
698func (a *Assertions) LessOrEqual(e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool {
699 if h, ok := a.t.(tHelper); ok {
700 h.Helper()
701 }
702 return LessOrEqual(a.t, e1, e2, msgAndArgs...)
703}
704
705// LessOrEqualf asserts that the first element is less than or equal to the second
706//
707// a.LessOrEqualf(1, 2, "error message %s", "formatted")
708// a.LessOrEqualf(2, 2, "error message %s", "formatted")
709// a.LessOrEqualf("a", "b", "error message %s", "formatted")
710// a.LessOrEqualf("b", "b", "error message %s", "formatted")
711func (a *Assertions) LessOrEqualf(e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool {
712 if h, ok := a.t.(tHelper); ok {
713 h.Helper()
714 }
715 return LessOrEqualf(a.t, e1, e2, msg, args...)
716}
717
718// Lessf asserts that the first element is less than the second
719//
720// a.Lessf(1, 2, "error message %s", "formatted")
721// a.Lessf(float64(1, "error message %s", "formatted"), float64(2))
722// a.Lessf("a", "b", "error message %s", "formatted")
723func (a *Assertions) Lessf(e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool {
724 if h, ok := a.t.(tHelper); ok {
725 h.Helper()
726 }
727 return Lessf(a.t, e1, e2, msg, args...)
728}
729
730// Nil asserts that the specified object is nil.
731//
732// a.Nil(err)
733func (a *Assertions) Nil(object interface{}, msgAndArgs ...interface{}) bool {
734 if h, ok := a.t.(tHelper); ok {
735 h.Helper()
736 }
737 return Nil(a.t, object, msgAndArgs...)
738}
739
740// Nilf asserts that the specified object is nil.
741//
742// a.Nilf(err, "error message %s", "formatted")
743func (a *Assertions) Nilf(object interface{}, msg string, args ...interface{}) bool {
744 if h, ok := a.t.(tHelper); ok {
745 h.Helper()
746 }
747 return Nilf(a.t, object, msg, args...)
748}
749
750// NoError asserts that a function returned no error (i.e. `nil`).
751//
752// actualObj, err := SomeFunction()
753// if a.NoError(err) {
754// assert.Equal(t, expectedObj, actualObj)
755// }
756func (a *Assertions) NoError(err error, msgAndArgs ...interface{}) bool {
757 if h, ok := a.t.(tHelper); ok {
758 h.Helper()
759 }
760 return NoError(a.t, err, msgAndArgs...)
761}
762
763// NoErrorf asserts that a function returned no error (i.e. `nil`).
764//
765// actualObj, err := SomeFunction()
766// if a.NoErrorf(err, "error message %s", "formatted") {
767// assert.Equal(t, expectedObj, actualObj)
768// }
769func (a *Assertions) NoErrorf(err error, msg string, args ...interface{}) bool {
770 if h, ok := a.t.(tHelper); ok {
771 h.Helper()
772 }
773 return NoErrorf(a.t, err, msg, args...)
774}
775
776// NotContains asserts that the specified string, list(array, slice...) or map does NOT contain the
777// specified substring or element.
778//
779// a.NotContains("Hello World", "Earth")
780// a.NotContains(["Hello", "World"], "Earth")
781// a.NotContains({"Hello": "World"}, "Earth")
782func (a *Assertions) NotContains(s interface{}, contains interface{}, msgAndArgs ...interface{}) bool {
783 if h, ok := a.t.(tHelper); ok {
784 h.Helper()
785 }
786 return NotContains(a.t, s, contains, msgAndArgs...)
787}
788
789// NotContainsf asserts that the specified string, list(array, slice...) or map does NOT contain the
790// specified substring or element.
791//
792// a.NotContainsf("Hello World", "Earth", "error message %s", "formatted")
793// a.NotContainsf(["Hello", "World"], "Earth", "error message %s", "formatted")
794// a.NotContainsf({"Hello": "World"}, "Earth", "error message %s", "formatted")
795func (a *Assertions) NotContainsf(s interface{}, contains interface{}, msg string, args ...interface{}) bool {
796 if h, ok := a.t.(tHelper); ok {
797 h.Helper()
798 }
799 return NotContainsf(a.t, s, contains, msg, args...)
800}
801
802// NotEmpty asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either
803// a slice or a channel with len == 0.
804//
805// if a.NotEmpty(obj) {
806// assert.Equal(t, "two", obj[1])
807// }
808func (a *Assertions) NotEmpty(object interface{}, msgAndArgs ...interface{}) bool {
809 if h, ok := a.t.(tHelper); ok {
810 h.Helper()
811 }
812 return NotEmpty(a.t, object, msgAndArgs...)
813}
814
815// NotEmptyf asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either
816// a slice or a channel with len == 0.
817//
818// if a.NotEmptyf(obj, "error message %s", "formatted") {
819// assert.Equal(t, "two", obj[1])
820// }
821func (a *Assertions) NotEmptyf(object interface{}, msg string, args ...interface{}) bool {
822 if h, ok := a.t.(tHelper); ok {
823 h.Helper()
824 }
825 return NotEmptyf(a.t, object, msg, args...)
826}
827
828// NotEqual asserts that the specified values are NOT equal.
829//
830// a.NotEqual(obj1, obj2)
831//
832// Pointer variable equality is determined based on the equality of the
833// referenced values (as opposed to the memory addresses).
834func (a *Assertions) NotEqual(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool {
835 if h, ok := a.t.(tHelper); ok {
836 h.Helper()
837 }
838 return NotEqual(a.t, expected, actual, msgAndArgs...)
839}
840
841// NotEqualf asserts that the specified values are NOT equal.
842//
843// a.NotEqualf(obj1, obj2, "error message %s", "formatted")
844//
845// Pointer variable equality is determined based on the equality of the
846// referenced values (as opposed to the memory addresses).
847func (a *Assertions) NotEqualf(expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
848 if h, ok := a.t.(tHelper); ok {
849 h.Helper()
850 }
851 return NotEqualf(a.t, expected, actual, msg, args...)
852}
853
854// NotNil asserts that the specified object is not nil.
855//
856// a.NotNil(err)
857func (a *Assertions) NotNil(object interface{}, msgAndArgs ...interface{}) bool {
858 if h, ok := a.t.(tHelper); ok {
859 h.Helper()
860 }
861 return NotNil(a.t, object, msgAndArgs...)
862}
863
864// NotNilf asserts that the specified object is not nil.
865//
866// a.NotNilf(err, "error message %s", "formatted")
867func (a *Assertions) NotNilf(object interface{}, msg string, args ...interface{}) bool {
868 if h, ok := a.t.(tHelper); ok {
869 h.Helper()
870 }
871 return NotNilf(a.t, object, msg, args...)
872}
873
874// NotPanics asserts that the code inside the specified PanicTestFunc does NOT panic.
875//
876// a.NotPanics(func(){ RemainCalm() })
877func (a *Assertions) NotPanics(f PanicTestFunc, msgAndArgs ...interface{}) bool {
878 if h, ok := a.t.(tHelper); ok {
879 h.Helper()
880 }
881 return NotPanics(a.t, f, msgAndArgs...)
882}
883
884// NotPanicsf asserts that the code inside the specified PanicTestFunc does NOT panic.
885//
886// a.NotPanicsf(func(){ RemainCalm() }, "error message %s", "formatted")
887func (a *Assertions) NotPanicsf(f PanicTestFunc, msg string, args ...interface{}) bool {
888 if h, ok := a.t.(tHelper); ok {
889 h.Helper()
890 }
891 return NotPanicsf(a.t, f, msg, args...)
892}
893
894// NotRegexp asserts that a specified regexp does not match a string.
895//
896// a.NotRegexp(regexp.MustCompile("starts"), "it's starting")
897// a.NotRegexp("^start", "it's not starting")
898func (a *Assertions) NotRegexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) bool {
899 if h, ok := a.t.(tHelper); ok {
900 h.Helper()
901 }
902 return NotRegexp(a.t, rx, str, msgAndArgs...)
903}
904
905// NotRegexpf asserts that a specified regexp does not match a string.
906//
907// a.NotRegexpf(regexp.MustCompile("starts", "error message %s", "formatted"), "it's starting")
908// a.NotRegexpf("^start", "it's not starting", "error message %s", "formatted")
909func (a *Assertions) NotRegexpf(rx interface{}, str interface{}, msg string, args ...interface{}) bool {
910 if h, ok := a.t.(tHelper); ok {
911 h.Helper()
912 }
913 return NotRegexpf(a.t, rx, str, msg, args...)
914}
915
916// NotSubset asserts that the specified list(array, slice...) contains not all
917// elements given in the specified subset(array, slice...).
918//
919// a.NotSubset([1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]")
920func (a *Assertions) NotSubset(list interface{}, subset interface{}, msgAndArgs ...interface{}) bool {
921 if h, ok := a.t.(tHelper); ok {
922 h.Helper()
923 }
924 return NotSubset(a.t, list, subset, msgAndArgs...)
925}
926
927// NotSubsetf asserts that the specified list(array, slice...) contains not all
928// elements given in the specified subset(array, slice...).
929//
930// a.NotSubsetf([1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]", "error message %s", "formatted")
931func (a *Assertions) NotSubsetf(list interface{}, subset interface{}, msg string, args ...interface{}) bool {
932 if h, ok := a.t.(tHelper); ok {
933 h.Helper()
934 }
935 return NotSubsetf(a.t, list, subset, msg, args...)
936}
937
938// NotZero asserts that i is not the zero value for its type.
939func (a *Assertions) NotZero(i interface{}, msgAndArgs ...interface{}) bool {
940 if h, ok := a.t.(tHelper); ok {
941 h.Helper()
942 }
943 return NotZero(a.t, i, msgAndArgs...)
944}
945
946// NotZerof asserts that i is not the zero value for its type.
947func (a *Assertions) NotZerof(i interface{}, msg string, args ...interface{}) bool {
948 if h, ok := a.t.(tHelper); ok {
949 h.Helper()
950 }
951 return NotZerof(a.t, i, msg, args...)
952}
953
954// Panics asserts that the code inside the specified PanicTestFunc panics.
955//
956// a.Panics(func(){ GoCrazy() })
957func (a *Assertions) Panics(f PanicTestFunc, msgAndArgs ...interface{}) bool {
958 if h, ok := a.t.(tHelper); ok {
959 h.Helper()
960 }
961 return Panics(a.t, f, msgAndArgs...)
962}
963
964// PanicsWithValue asserts that the code inside the specified PanicTestFunc panics, and that
965// the recovered panic value equals the expected panic value.
966//
967// a.PanicsWithValue("crazy error", func(){ GoCrazy() })
968func (a *Assertions) PanicsWithValue(expected interface{}, f PanicTestFunc, msgAndArgs ...interface{}) bool {
969 if h, ok := a.t.(tHelper); ok {
970 h.Helper()
971 }
972 return PanicsWithValue(a.t, expected, f, msgAndArgs...)
973}
974
975// PanicsWithValuef asserts that the code inside the specified PanicTestFunc panics, and that
976// the recovered panic value equals the expected panic value.
977//
978// a.PanicsWithValuef("crazy error", func(){ GoCrazy() }, "error message %s", "formatted")
979func (a *Assertions) PanicsWithValuef(expected interface{}, f PanicTestFunc, msg string, args ...interface{}) bool {
980 if h, ok := a.t.(tHelper); ok {
981 h.Helper()
982 }
983 return PanicsWithValuef(a.t, expected, f, msg, args...)
984}
985
986// Panicsf asserts that the code inside the specified PanicTestFunc panics.
987//
988// a.Panicsf(func(){ GoCrazy() }, "error message %s", "formatted")
989func (a *Assertions) Panicsf(f PanicTestFunc, msg string, args ...interface{}) bool {
990 if h, ok := a.t.(tHelper); ok {
991 h.Helper()
992 }
993 return Panicsf(a.t, f, msg, args...)
994}
995
996// Regexp asserts that a specified regexp matches a string.
997//
998// a.Regexp(regexp.MustCompile("start"), "it's starting")
999// a.Regexp("start...$", "it's not starting")
1000func (a *Assertions) Regexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) bool {
1001 if h, ok := a.t.(tHelper); ok {
1002 h.Helper()
1003 }
1004 return Regexp(a.t, rx, str, msgAndArgs...)
1005}
1006
1007// Regexpf asserts that a specified regexp matches a string.
1008//
1009// a.Regexpf(regexp.MustCompile("start", "error message %s", "formatted"), "it's starting")
1010// a.Regexpf("start...$", "it's not starting", "error message %s", "formatted")
1011func (a *Assertions) Regexpf(rx interface{}, str interface{}, msg string, args ...interface{}) bool {
1012 if h, ok := a.t.(tHelper); ok {
1013 h.Helper()
1014 }
1015 return Regexpf(a.t, rx, str, msg, args...)
1016}
1017
1018// Same asserts that two pointers reference the same object.
1019//
1020// a.Same(ptr1, ptr2)
1021//
1022// Both arguments must be pointer variables. Pointer variable sameness is
1023// determined based on the equality of both type and value.
1024func (a *Assertions) Same(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool {
1025 if h, ok := a.t.(tHelper); ok {
1026 h.Helper()
1027 }
1028 return Same(a.t, expected, actual, msgAndArgs...)
1029}
1030
1031// Samef asserts that two pointers reference the same object.
1032//
1033// a.Samef(ptr1, ptr2, "error message %s", "formatted")
1034//
1035// Both arguments must be pointer variables. Pointer variable sameness is
1036// determined based on the equality of both type and value.
1037func (a *Assertions) Samef(expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
1038 if h, ok := a.t.(tHelper); ok {
1039 h.Helper()
1040 }
1041 return Samef(a.t, expected, actual, msg, args...)
1042}
1043
1044// Subset asserts that the specified list(array, slice...) contains all
1045// elements given in the specified subset(array, slice...).
1046//
1047// a.Subset([1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]")
1048func (a *Assertions) Subset(list interface{}, subset interface{}, msgAndArgs ...interface{}) bool {
1049 if h, ok := a.t.(tHelper); ok {
1050 h.Helper()
1051 }
1052 return Subset(a.t, list, subset, msgAndArgs...)
1053}
1054
1055// Subsetf asserts that the specified list(array, slice...) contains all
1056// elements given in the specified subset(array, slice...).
1057//
1058// a.Subsetf([1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]", "error message %s", "formatted")
1059func (a *Assertions) Subsetf(list interface{}, subset interface{}, msg string, args ...interface{}) bool {
1060 if h, ok := a.t.(tHelper); ok {
1061 h.Helper()
1062 }
1063 return Subsetf(a.t, list, subset, msg, args...)
1064}
1065
1066// True asserts that the specified value is true.
1067//
1068// a.True(myBool)
1069func (a *Assertions) True(value bool, msgAndArgs ...interface{}) bool {
1070 if h, ok := a.t.(tHelper); ok {
1071 h.Helper()
1072 }
1073 return True(a.t, value, msgAndArgs...)
1074}
1075
1076// Truef asserts that the specified value is true.
1077//
1078// a.Truef(myBool, "error message %s", "formatted")
1079func (a *Assertions) Truef(value bool, msg string, args ...interface{}) bool {
1080 if h, ok := a.t.(tHelper); ok {
1081 h.Helper()
1082 }
1083 return Truef(a.t, value, msg, args...)
1084}
1085
1086// WithinDuration asserts that the two times are within duration delta of each other.
1087//
1088// a.WithinDuration(time.Now(), time.Now(), 10*time.Second)
1089func (a *Assertions) WithinDuration(expected time.Time, actual time.Time, delta time.Duration, msgAndArgs ...interface{}) bool {
1090 if h, ok := a.t.(tHelper); ok {
1091 h.Helper()
1092 }
1093 return WithinDuration(a.t, expected, actual, delta, msgAndArgs...)
1094}
1095
1096// WithinDurationf asserts that the two times are within duration delta of each other.
1097//
1098// a.WithinDurationf(time.Now(), time.Now(), 10*time.Second, "error message %s", "formatted")
1099func (a *Assertions) WithinDurationf(expected time.Time, actual time.Time, delta time.Duration, msg string, args ...interface{}) bool {
1100 if h, ok := a.t.(tHelper); ok {
1101 h.Helper()
1102 }
1103 return WithinDurationf(a.t, expected, actual, delta, msg, args...)
1104}
1105
1106// Zero asserts that i is the zero value for its type.
1107func (a *Assertions) Zero(i interface{}, msgAndArgs ...interface{}) bool {
1108 if h, ok := a.t.(tHelper); ok {
1109 h.Helper()
1110 }
1111 return Zero(a.t, i, msgAndArgs...)
1112}
1113
1114// Zerof asserts that i is the zero value for its type.
1115func (a *Assertions) Zerof(i interface{}, msg string, args ...interface{}) bool {
1116 if h, ok := a.t.(tHelper); ok {
1117 h.Helper()
1118 }
1119 return Zerof(a.t, i, msg, args...)
1120}