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