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