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