51 h.Helper() |
51 h.Helper() |
52 } |
52 } |
53 return Containsf(a.t, s, contains, msg, args...) |
53 return Containsf(a.t, s, contains, msg, args...) |
54 } |
54 } |
55 |
55 |
56 // DirExists checks whether a directory exists in the given path. It also fails if the path is a file rather a directory or there is an error checking whether it exists. |
56 // DirExists checks whether a directory exists in the given path. It also fails |
|
57 // if the path is a file rather a directory or there is an error checking whether it exists. |
57 func (a *Assertions) DirExists(path string, msgAndArgs ...interface{}) bool { |
58 func (a *Assertions) DirExists(path string, msgAndArgs ...interface{}) bool { |
58 if h, ok := a.t.(tHelper); ok { |
59 if h, ok := a.t.(tHelper); ok { |
59 h.Helper() |
60 h.Helper() |
60 } |
61 } |
61 return DirExists(a.t, path, msgAndArgs...) |
62 return DirExists(a.t, path, msgAndArgs...) |
62 } |
63 } |
63 |
64 |
64 // DirExistsf checks whether a directory exists in the given path. It also fails if the path is a file rather a directory or there is an error checking whether it exists. |
65 // DirExistsf checks whether a directory exists in the given path. It also fails |
|
66 // if the path is a file rather a directory or there is an error checking whether it exists. |
65 func (a *Assertions) DirExistsf(path string, msg string, args ...interface{}) bool { |
67 func (a *Assertions) DirExistsf(path string, msg string, args ...interface{}) bool { |
66 if h, ok := a.t.(tHelper); ok { |
68 if h, ok := a.t.(tHelper); ok { |
67 h.Helper() |
69 h.Helper() |
68 } |
70 } |
69 return DirExistsf(a.t, path, msg, args...) |
71 return DirExistsf(a.t, path, msg, args...) |
200 h.Helper() |
202 h.Helper() |
201 } |
203 } |
202 return Error(a.t, err, msgAndArgs...) |
204 return Error(a.t, err, msgAndArgs...) |
203 } |
205 } |
204 |
206 |
|
207 // ErrorAs asserts that at least one of the errors in err's chain matches target, and if so, sets target to that error value. |
|
208 // This is a wrapper for errors.As. |
|
209 func (a *Assertions) ErrorAs(err error, target interface{}, msgAndArgs ...interface{}) bool { |
|
210 if h, ok := a.t.(tHelper); ok { |
|
211 h.Helper() |
|
212 } |
|
213 return ErrorAs(a.t, err, target, msgAndArgs...) |
|
214 } |
|
215 |
|
216 // ErrorAsf asserts that at least one of the errors in err's chain matches target, and if so, sets target to that error value. |
|
217 // This is a wrapper for errors.As. |
|
218 func (a *Assertions) ErrorAsf(err error, target interface{}, msg string, args ...interface{}) bool { |
|
219 if h, ok := a.t.(tHelper); ok { |
|
220 h.Helper() |
|
221 } |
|
222 return ErrorAsf(a.t, err, target, msg, args...) |
|
223 } |
|
224 |
|
225 // ErrorIs asserts that at least one of the errors in err's chain matches target. |
|
226 // This is a wrapper for errors.Is. |
|
227 func (a *Assertions) ErrorIs(err error, target error, msgAndArgs ...interface{}) bool { |
|
228 if h, ok := a.t.(tHelper); ok { |
|
229 h.Helper() |
|
230 } |
|
231 return ErrorIs(a.t, err, target, msgAndArgs...) |
|
232 } |
|
233 |
|
234 // ErrorIsf asserts that at least one of the errors in err's chain matches target. |
|
235 // This is a wrapper for errors.Is. |
|
236 func (a *Assertions) ErrorIsf(err error, target error, msg string, args ...interface{}) bool { |
|
237 if h, ok := a.t.(tHelper); ok { |
|
238 h.Helper() |
|
239 } |
|
240 return ErrorIsf(a.t, err, target, msg, args...) |
|
241 } |
|
242 |
205 // Errorf asserts that a function returned an error (i.e. not `nil`). |
243 // Errorf asserts that a function returned an error (i.e. not `nil`). |
206 // |
244 // |
207 // actualObj, err := SomeFunction() |
245 // actualObj, err := SomeFunction() |
208 // if a.Errorf(err, "error message %s", "formatted") { |
246 // if a.Errorf(err, "error message %s", "formatted") { |
209 // assert.Equal(t, expectedErrorf, err) |
247 // assert.Equal(t, expectedErrorf, err) |
213 h.Helper() |
251 h.Helper() |
214 } |
252 } |
215 return Errorf(a.t, err, msg, args...) |
253 return Errorf(a.t, err, msg, args...) |
216 } |
254 } |
217 |
255 |
|
256 // Eventually asserts that given condition will be met in waitFor time, |
|
257 // periodically checking target function each tick. |
|
258 // |
|
259 // a.Eventually(func() bool { return true; }, time.Second, 10*time.Millisecond) |
|
260 func (a *Assertions) Eventually(condition func() bool, waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) bool { |
|
261 if h, ok := a.t.(tHelper); ok { |
|
262 h.Helper() |
|
263 } |
|
264 return Eventually(a.t, condition, waitFor, tick, msgAndArgs...) |
|
265 } |
|
266 |
|
267 // Eventuallyf asserts that given condition will be met in waitFor time, |
|
268 // periodically checking target function each tick. |
|
269 // |
|
270 // a.Eventuallyf(func() bool { return true; }, time.Second, 10*time.Millisecond, "error message %s", "formatted") |
|
271 func (a *Assertions) Eventuallyf(condition func() bool, waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) bool { |
|
272 if h, ok := a.t.(tHelper); ok { |
|
273 h.Helper() |
|
274 } |
|
275 return Eventuallyf(a.t, condition, waitFor, tick, msg, args...) |
|
276 } |
|
277 |
218 // Exactly asserts that two objects are equal in value and type. |
278 // Exactly asserts that two objects are equal in value and type. |
219 // |
279 // |
220 // a.Exactly(int32(123), int64(123)) |
280 // a.Exactly(int32(123), int64(123)) |
221 func (a *Assertions) Exactly(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool { |
281 func (a *Assertions) Exactly(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool { |
222 if h, ok := a.t.(tHelper); ok { |
282 if h, ok := a.t.(tHelper); ok { |
225 return Exactly(a.t, expected, actual, msgAndArgs...) |
285 return Exactly(a.t, expected, actual, msgAndArgs...) |
226 } |
286 } |
227 |
287 |
228 // Exactlyf asserts that two objects are equal in value and type. |
288 // Exactlyf asserts that two objects are equal in value and type. |
229 // |
289 // |
230 // a.Exactlyf(int32(123, "error message %s", "formatted"), int64(123)) |
290 // a.Exactlyf(int32(123), int64(123), "error message %s", "formatted") |
231 func (a *Assertions) Exactlyf(expected interface{}, actual interface{}, msg string, args ...interface{}) bool { |
291 func (a *Assertions) Exactlyf(expected interface{}, actual interface{}, msg string, args ...interface{}) bool { |
232 if h, ok := a.t.(tHelper); ok { |
292 if h, ok := a.t.(tHelper); ok { |
233 h.Helper() |
293 h.Helper() |
234 } |
294 } |
235 return Exactlyf(a.t, expected, actual, msg, args...) |
295 return Exactlyf(a.t, expected, actual, msg, args...) |
285 h.Helper() |
345 h.Helper() |
286 } |
346 } |
287 return Falsef(a.t, value, msg, args...) |
347 return Falsef(a.t, value, msg, args...) |
288 } |
348 } |
289 |
349 |
290 // FileExists checks whether a file exists in the given path. It also fails if the path points to a directory or there is an error when trying to check the file. |
350 // FileExists checks whether a file exists in the given path. It also fails if |
|
351 // the path points to a directory or there is an error when trying to check the file. |
291 func (a *Assertions) FileExists(path string, msgAndArgs ...interface{}) bool { |
352 func (a *Assertions) FileExists(path string, msgAndArgs ...interface{}) bool { |
292 if h, ok := a.t.(tHelper); ok { |
353 if h, ok := a.t.(tHelper); ok { |
293 h.Helper() |
354 h.Helper() |
294 } |
355 } |
295 return FileExists(a.t, path, msgAndArgs...) |
356 return FileExists(a.t, path, msgAndArgs...) |
296 } |
357 } |
297 |
358 |
298 // FileExistsf checks whether a file exists in the given path. It also fails if the path points to a directory or there is an error when trying to check the file. |
359 // FileExistsf checks whether a file exists in the given path. It also fails if |
|
360 // the path points to a directory or there is an error when trying to check the file. |
299 func (a *Assertions) FileExistsf(path string, msg string, args ...interface{}) bool { |
361 func (a *Assertions) FileExistsf(path string, msg string, args ...interface{}) bool { |
300 if h, ok := a.t.(tHelper); ok { |
362 if h, ok := a.t.(tHelper); ok { |
301 h.Helper() |
363 h.Helper() |
302 } |
364 } |
303 return FileExistsf(a.t, path, msg, args...) |
365 return FileExistsf(a.t, path, msg, args...) |
|
366 } |
|
367 |
|
368 // Greater asserts that the first element is greater than the second |
|
369 // |
|
370 // a.Greater(2, 1) |
|
371 // a.Greater(float64(2), float64(1)) |
|
372 // a.Greater("b", "a") |
|
373 func (a *Assertions) Greater(e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool { |
|
374 if h, ok := a.t.(tHelper); ok { |
|
375 h.Helper() |
|
376 } |
|
377 return Greater(a.t, e1, e2, msgAndArgs...) |
|
378 } |
|
379 |
|
380 // GreaterOrEqual asserts that the first element is greater than or equal to the second |
|
381 // |
|
382 // a.GreaterOrEqual(2, 1) |
|
383 // a.GreaterOrEqual(2, 2) |
|
384 // a.GreaterOrEqual("b", "a") |
|
385 // a.GreaterOrEqual("b", "b") |
|
386 func (a *Assertions) GreaterOrEqual(e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool { |
|
387 if h, ok := a.t.(tHelper); ok { |
|
388 h.Helper() |
|
389 } |
|
390 return GreaterOrEqual(a.t, e1, e2, msgAndArgs...) |
|
391 } |
|
392 |
|
393 // GreaterOrEqualf asserts that the first element is greater than or equal to the second |
|
394 // |
|
395 // a.GreaterOrEqualf(2, 1, "error message %s", "formatted") |
|
396 // a.GreaterOrEqualf(2, 2, "error message %s", "formatted") |
|
397 // a.GreaterOrEqualf("b", "a", "error message %s", "formatted") |
|
398 // a.GreaterOrEqualf("b", "b", "error message %s", "formatted") |
|
399 func (a *Assertions) GreaterOrEqualf(e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool { |
|
400 if h, ok := a.t.(tHelper); ok { |
|
401 h.Helper() |
|
402 } |
|
403 return GreaterOrEqualf(a.t, e1, e2, msg, args...) |
|
404 } |
|
405 |
|
406 // Greaterf asserts that the first element is greater than the second |
|
407 // |
|
408 // a.Greaterf(2, 1, "error message %s", "formatted") |
|
409 // a.Greaterf(float64(2), float64(1), "error message %s", "formatted") |
|
410 // a.Greaterf("b", "a", "error message %s", "formatted") |
|
411 func (a *Assertions) Greaterf(e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool { |
|
412 if h, ok := a.t.(tHelper); ok { |
|
413 h.Helper() |
|
414 } |
|
415 return Greaterf(a.t, e1, e2, msg, args...) |
304 } |
416 } |
305 |
417 |
306 // HTTPBodyContains asserts that a specified handler returns a |
418 // HTTPBodyContains asserts that a specified handler returns a |
307 // body that contains a string. |
419 // body that contains a string. |
308 // |
420 // |
369 |
481 |
370 // HTTPErrorf asserts that a specified handler returns an error status code. |
482 // HTTPErrorf asserts that a specified handler returns an error status code. |
371 // |
483 // |
372 // a.HTTPErrorf(myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}} |
484 // a.HTTPErrorf(myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}} |
373 // |
485 // |
374 // Returns whether the assertion was successful (true, "error message %s", "formatted") or not (false). |
486 // Returns whether the assertion was successful (true) or not (false). |
375 func (a *Assertions) HTTPErrorf(handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) bool { |
487 func (a *Assertions) HTTPErrorf(handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) bool { |
376 if h, ok := a.t.(tHelper); ok { |
488 if h, ok := a.t.(tHelper); ok { |
377 h.Helper() |
489 h.Helper() |
378 } |
490 } |
379 return HTTPErrorf(a.t, handler, method, url, values, msg, args...) |
491 return HTTPErrorf(a.t, handler, method, url, values, msg, args...) |
393 |
505 |
394 // HTTPRedirectf asserts that a specified handler returns a redirect status code. |
506 // HTTPRedirectf asserts that a specified handler returns a redirect status code. |
395 // |
507 // |
396 // a.HTTPRedirectf(myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}} |
508 // a.HTTPRedirectf(myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}} |
397 // |
509 // |
398 // Returns whether the assertion was successful (true, "error message %s", "formatted") or not (false). |
510 // Returns whether the assertion was successful (true) or not (false). |
399 func (a *Assertions) HTTPRedirectf(handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) bool { |
511 func (a *Assertions) HTTPRedirectf(handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) bool { |
400 if h, ok := a.t.(tHelper); ok { |
512 if h, ok := a.t.(tHelper); ok { |
401 h.Helper() |
513 h.Helper() |
402 } |
514 } |
403 return HTTPRedirectf(a.t, handler, method, url, values, msg, args...) |
515 return HTTPRedirectf(a.t, handler, method, url, values, msg, args...) |
|
516 } |
|
517 |
|
518 // HTTPStatusCode asserts that a specified handler returns a specified status code. |
|
519 // |
|
520 // a.HTTPStatusCode(myHandler, "GET", "/notImplemented", nil, 501) |
|
521 // |
|
522 // Returns whether the assertion was successful (true) or not (false). |
|
523 func (a *Assertions) HTTPStatusCode(handler http.HandlerFunc, method string, url string, values url.Values, statuscode int, msgAndArgs ...interface{}) bool { |
|
524 if h, ok := a.t.(tHelper); ok { |
|
525 h.Helper() |
|
526 } |
|
527 return HTTPStatusCode(a.t, handler, method, url, values, statuscode, msgAndArgs...) |
|
528 } |
|
529 |
|
530 // HTTPStatusCodef asserts that a specified handler returns a specified status code. |
|
531 // |
|
532 // a.HTTPStatusCodef(myHandler, "GET", "/notImplemented", nil, 501, "error message %s", "formatted") |
|
533 // |
|
534 // Returns whether the assertion was successful (true) or not (false). |
|
535 func (a *Assertions) HTTPStatusCodef(handler http.HandlerFunc, method string, url string, values url.Values, statuscode int, msg string, args ...interface{}) bool { |
|
536 if h, ok := a.t.(tHelper); ok { |
|
537 h.Helper() |
|
538 } |
|
539 return HTTPStatusCodef(a.t, handler, method, url, values, statuscode, msg, args...) |
404 } |
540 } |
405 |
541 |
406 // HTTPSuccess asserts that a specified handler returns a success status code. |
542 // HTTPSuccess asserts that a specified handler returns a success status code. |
407 // |
543 // |
408 // a.HTTPSuccess(myHandler, "POST", "http://www.google.com", nil) |
544 // a.HTTPSuccess(myHandler, "POST", "http://www.google.com", nil) |
437 return Implements(a.t, interfaceObject, object, msgAndArgs...) |
573 return Implements(a.t, interfaceObject, object, msgAndArgs...) |
438 } |
574 } |
439 |
575 |
440 // Implementsf asserts that an object is implemented by the specified interface. |
576 // Implementsf asserts that an object is implemented by the specified interface. |
441 // |
577 // |
442 // a.Implementsf((*MyInterface, "error message %s", "formatted")(nil), new(MyObject)) |
578 // a.Implementsf((*MyInterface)(nil), new(MyObject), "error message %s", "formatted") |
443 func (a *Assertions) Implementsf(interfaceObject interface{}, object interface{}, msg string, args ...interface{}) bool { |
579 func (a *Assertions) Implementsf(interfaceObject interface{}, object interface{}, msg string, args ...interface{}) bool { |
444 if h, ok := a.t.(tHelper); ok { |
580 if h, ok := a.t.(tHelper); ok { |
445 h.Helper() |
581 h.Helper() |
446 } |
582 } |
447 return Implementsf(a.t, interfaceObject, object, msg, args...) |
583 return Implementsf(a.t, interfaceObject, object, msg, args...) |
448 } |
584 } |
449 |
585 |
450 // InDelta asserts that the two numerals are within delta of each other. |
586 // InDelta asserts that the two numerals are within delta of each other. |
451 // |
587 // |
452 // a.InDelta(math.Pi, (22 / 7.0), 0.01) |
588 // a.InDelta(math.Pi, 22/7.0, 0.01) |
453 func (a *Assertions) InDelta(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) bool { |
589 func (a *Assertions) InDelta(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) bool { |
454 if h, ok := a.t.(tHelper); ok { |
590 if h, ok := a.t.(tHelper); ok { |
455 h.Helper() |
591 h.Helper() |
456 } |
592 } |
457 return InDelta(a.t, expected, actual, delta, msgAndArgs...) |
593 return InDelta(a.t, expected, actual, delta, msgAndArgs...) |
489 return InDeltaSlicef(a.t, expected, actual, delta, msg, args...) |
625 return InDeltaSlicef(a.t, expected, actual, delta, msg, args...) |
490 } |
626 } |
491 |
627 |
492 // InDeltaf asserts that the two numerals are within delta of each other. |
628 // InDeltaf asserts that the two numerals are within delta of each other. |
493 // |
629 // |
494 // a.InDeltaf(math.Pi, (22 / 7.0, "error message %s", "formatted"), 0.01) |
630 // a.InDeltaf(math.Pi, 22/7.0, 0.01, "error message %s", "formatted") |
495 func (a *Assertions) InDeltaf(expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool { |
631 func (a *Assertions) InDeltaf(expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool { |
496 if h, ok := a.t.(tHelper); ok { |
632 if h, ok := a.t.(tHelper); ok { |
497 h.Helper() |
633 h.Helper() |
498 } |
634 } |
499 return InDeltaf(a.t, expected, actual, delta, msg, args...) |
635 return InDeltaf(a.t, expected, actual, delta, msg, args...) |
529 h.Helper() |
665 h.Helper() |
530 } |
666 } |
531 return InEpsilonf(a.t, expected, actual, epsilon, msg, args...) |
667 return InEpsilonf(a.t, expected, actual, epsilon, msg, args...) |
532 } |
668 } |
533 |
669 |
|
670 // IsDecreasing asserts that the collection is decreasing |
|
671 // |
|
672 // a.IsDecreasing([]int{2, 1, 0}) |
|
673 // a.IsDecreasing([]float{2, 1}) |
|
674 // a.IsDecreasing([]string{"b", "a"}) |
|
675 func (a *Assertions) IsDecreasing(object interface{}, msgAndArgs ...interface{}) bool { |
|
676 if h, ok := a.t.(tHelper); ok { |
|
677 h.Helper() |
|
678 } |
|
679 return IsDecreasing(a.t, object, msgAndArgs...) |
|
680 } |
|
681 |
|
682 // IsDecreasingf asserts that the collection is decreasing |
|
683 // |
|
684 // a.IsDecreasingf([]int{2, 1, 0}, "error message %s", "formatted") |
|
685 // a.IsDecreasingf([]float{2, 1}, "error message %s", "formatted") |
|
686 // a.IsDecreasingf([]string{"b", "a"}, "error message %s", "formatted") |
|
687 func (a *Assertions) IsDecreasingf(object interface{}, msg string, args ...interface{}) bool { |
|
688 if h, ok := a.t.(tHelper); ok { |
|
689 h.Helper() |
|
690 } |
|
691 return IsDecreasingf(a.t, object, msg, args...) |
|
692 } |
|
693 |
|
694 // IsIncreasing asserts that the collection is increasing |
|
695 // |
|
696 // a.IsIncreasing([]int{1, 2, 3}) |
|
697 // a.IsIncreasing([]float{1, 2}) |
|
698 // a.IsIncreasing([]string{"a", "b"}) |
|
699 func (a *Assertions) IsIncreasing(object interface{}, msgAndArgs ...interface{}) bool { |
|
700 if h, ok := a.t.(tHelper); ok { |
|
701 h.Helper() |
|
702 } |
|
703 return IsIncreasing(a.t, object, msgAndArgs...) |
|
704 } |
|
705 |
|
706 // IsIncreasingf asserts that the collection is increasing |
|
707 // |
|
708 // a.IsIncreasingf([]int{1, 2, 3}, "error message %s", "formatted") |
|
709 // a.IsIncreasingf([]float{1, 2}, "error message %s", "formatted") |
|
710 // a.IsIncreasingf([]string{"a", "b"}, "error message %s", "formatted") |
|
711 func (a *Assertions) IsIncreasingf(object interface{}, msg string, args ...interface{}) bool { |
|
712 if h, ok := a.t.(tHelper); ok { |
|
713 h.Helper() |
|
714 } |
|
715 return IsIncreasingf(a.t, object, msg, args...) |
|
716 } |
|
717 |
|
718 // IsNonDecreasing asserts that the collection is not decreasing |
|
719 // |
|
720 // a.IsNonDecreasing([]int{1, 1, 2}) |
|
721 // a.IsNonDecreasing([]float{1, 2}) |
|
722 // a.IsNonDecreasing([]string{"a", "b"}) |
|
723 func (a *Assertions) IsNonDecreasing(object interface{}, msgAndArgs ...interface{}) bool { |
|
724 if h, ok := a.t.(tHelper); ok { |
|
725 h.Helper() |
|
726 } |
|
727 return IsNonDecreasing(a.t, object, msgAndArgs...) |
|
728 } |
|
729 |
|
730 // IsNonDecreasingf asserts that the collection is not decreasing |
|
731 // |
|
732 // a.IsNonDecreasingf([]int{1, 1, 2}, "error message %s", "formatted") |
|
733 // a.IsNonDecreasingf([]float{1, 2}, "error message %s", "formatted") |
|
734 // a.IsNonDecreasingf([]string{"a", "b"}, "error message %s", "formatted") |
|
735 func (a *Assertions) IsNonDecreasingf(object interface{}, msg string, args ...interface{}) bool { |
|
736 if h, ok := a.t.(tHelper); ok { |
|
737 h.Helper() |
|
738 } |
|
739 return IsNonDecreasingf(a.t, object, msg, args...) |
|
740 } |
|
741 |
|
742 // IsNonIncreasing asserts that the collection is not increasing |
|
743 // |
|
744 // a.IsNonIncreasing([]int{2, 1, 1}) |
|
745 // a.IsNonIncreasing([]float{2, 1}) |
|
746 // a.IsNonIncreasing([]string{"b", "a"}) |
|
747 func (a *Assertions) IsNonIncreasing(object interface{}, msgAndArgs ...interface{}) bool { |
|
748 if h, ok := a.t.(tHelper); ok { |
|
749 h.Helper() |
|
750 } |
|
751 return IsNonIncreasing(a.t, object, msgAndArgs...) |
|
752 } |
|
753 |
|
754 // IsNonIncreasingf asserts that the collection is not increasing |
|
755 // |
|
756 // a.IsNonIncreasingf([]int{2, 1, 1}, "error message %s", "formatted") |
|
757 // a.IsNonIncreasingf([]float{2, 1}, "error message %s", "formatted") |
|
758 // a.IsNonIncreasingf([]string{"b", "a"}, "error message %s", "formatted") |
|
759 func (a *Assertions) IsNonIncreasingf(object interface{}, msg string, args ...interface{}) bool { |
|
760 if h, ok := a.t.(tHelper); ok { |
|
761 h.Helper() |
|
762 } |
|
763 return IsNonIncreasingf(a.t, object, msg, args...) |
|
764 } |
|
765 |
534 // IsType asserts that the specified objects are of the same type. |
766 // IsType asserts that the specified objects are of the same type. |
535 func (a *Assertions) IsType(expectedType interface{}, object interface{}, msgAndArgs ...interface{}) bool { |
767 func (a *Assertions) IsType(expectedType interface{}, object interface{}, msgAndArgs ...interface{}) bool { |
536 if h, ok := a.t.(tHelper); ok { |
768 if h, ok := a.t.(tHelper); ok { |
537 h.Helper() |
769 h.Helper() |
538 } |
770 } |
587 h.Helper() |
819 h.Helper() |
588 } |
820 } |
589 return Lenf(a.t, object, length, msg, args...) |
821 return Lenf(a.t, object, length, msg, args...) |
590 } |
822 } |
591 |
823 |
|
824 // Less asserts that the first element is less than the second |
|
825 // |
|
826 // a.Less(1, 2) |
|
827 // a.Less(float64(1), float64(2)) |
|
828 // a.Less("a", "b") |
|
829 func (a *Assertions) Less(e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool { |
|
830 if h, ok := a.t.(tHelper); ok { |
|
831 h.Helper() |
|
832 } |
|
833 return Less(a.t, e1, e2, msgAndArgs...) |
|
834 } |
|
835 |
|
836 // LessOrEqual asserts that the first element is less than or equal to the second |
|
837 // |
|
838 // a.LessOrEqual(1, 2) |
|
839 // a.LessOrEqual(2, 2) |
|
840 // a.LessOrEqual("a", "b") |
|
841 // a.LessOrEqual("b", "b") |
|
842 func (a *Assertions) LessOrEqual(e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool { |
|
843 if h, ok := a.t.(tHelper); ok { |
|
844 h.Helper() |
|
845 } |
|
846 return LessOrEqual(a.t, e1, e2, msgAndArgs...) |
|
847 } |
|
848 |
|
849 // LessOrEqualf asserts that the first element is less than or equal to the second |
|
850 // |
|
851 // a.LessOrEqualf(1, 2, "error message %s", "formatted") |
|
852 // a.LessOrEqualf(2, 2, "error message %s", "formatted") |
|
853 // a.LessOrEqualf("a", "b", "error message %s", "formatted") |
|
854 // a.LessOrEqualf("b", "b", "error message %s", "formatted") |
|
855 func (a *Assertions) LessOrEqualf(e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool { |
|
856 if h, ok := a.t.(tHelper); ok { |
|
857 h.Helper() |
|
858 } |
|
859 return LessOrEqualf(a.t, e1, e2, msg, args...) |
|
860 } |
|
861 |
|
862 // Lessf asserts that the first element is less than the second |
|
863 // |
|
864 // a.Lessf(1, 2, "error message %s", "formatted") |
|
865 // a.Lessf(float64(1), float64(2), "error message %s", "formatted") |
|
866 // a.Lessf("a", "b", "error message %s", "formatted") |
|
867 func (a *Assertions) Lessf(e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool { |
|
868 if h, ok := a.t.(tHelper); ok { |
|
869 h.Helper() |
|
870 } |
|
871 return Lessf(a.t, e1, e2, msg, args...) |
|
872 } |
|
873 |
|
874 // Negative asserts that the specified element is negative |
|
875 // |
|
876 // a.Negative(-1) |
|
877 // a.Negative(-1.23) |
|
878 func (a *Assertions) Negative(e interface{}, msgAndArgs ...interface{}) bool { |
|
879 if h, ok := a.t.(tHelper); ok { |
|
880 h.Helper() |
|
881 } |
|
882 return Negative(a.t, e, msgAndArgs...) |
|
883 } |
|
884 |
|
885 // Negativef asserts that the specified element is negative |
|
886 // |
|
887 // a.Negativef(-1, "error message %s", "formatted") |
|
888 // a.Negativef(-1.23, "error message %s", "formatted") |
|
889 func (a *Assertions) Negativef(e interface{}, msg string, args ...interface{}) bool { |
|
890 if h, ok := a.t.(tHelper); ok { |
|
891 h.Helper() |
|
892 } |
|
893 return Negativef(a.t, e, msg, args...) |
|
894 } |
|
895 |
|
896 // Never asserts that the given condition doesn't satisfy in waitFor time, |
|
897 // periodically checking the target function each tick. |
|
898 // |
|
899 // a.Never(func() bool { return false; }, time.Second, 10*time.Millisecond) |
|
900 func (a *Assertions) Never(condition func() bool, waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) bool { |
|
901 if h, ok := a.t.(tHelper); ok { |
|
902 h.Helper() |
|
903 } |
|
904 return Never(a.t, condition, waitFor, tick, msgAndArgs...) |
|
905 } |
|
906 |
|
907 // Neverf asserts that the given condition doesn't satisfy in waitFor time, |
|
908 // periodically checking the target function each tick. |
|
909 // |
|
910 // a.Neverf(func() bool { return false; }, time.Second, 10*time.Millisecond, "error message %s", "formatted") |
|
911 func (a *Assertions) Neverf(condition func() bool, waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) bool { |
|
912 if h, ok := a.t.(tHelper); ok { |
|
913 h.Helper() |
|
914 } |
|
915 return Neverf(a.t, condition, waitFor, tick, msg, args...) |
|
916 } |
|
917 |
592 // Nil asserts that the specified object is nil. |
918 // Nil asserts that the specified object is nil. |
593 // |
919 // |
594 // a.Nil(err) |
920 // a.Nil(err) |
595 func (a *Assertions) Nil(object interface{}, msgAndArgs ...interface{}) bool { |
921 func (a *Assertions) Nil(object interface{}, msgAndArgs ...interface{}) bool { |
596 if h, ok := a.t.(tHelper); ok { |
922 if h, ok := a.t.(tHelper); ok { |
605 func (a *Assertions) Nilf(object interface{}, msg string, args ...interface{}) bool { |
931 func (a *Assertions) Nilf(object interface{}, msg string, args ...interface{}) bool { |
606 if h, ok := a.t.(tHelper); ok { |
932 if h, ok := a.t.(tHelper); ok { |
607 h.Helper() |
933 h.Helper() |
608 } |
934 } |
609 return Nilf(a.t, object, msg, args...) |
935 return Nilf(a.t, object, msg, args...) |
|
936 } |
|
937 |
|
938 // NoDirExists checks whether a directory does not exist in the given path. |
|
939 // It fails if the path points to an existing _directory_ only. |
|
940 func (a *Assertions) NoDirExists(path string, msgAndArgs ...interface{}) bool { |
|
941 if h, ok := a.t.(tHelper); ok { |
|
942 h.Helper() |
|
943 } |
|
944 return NoDirExists(a.t, path, msgAndArgs...) |
|
945 } |
|
946 |
|
947 // NoDirExistsf checks whether a directory does not exist in the given path. |
|
948 // It fails if the path points to an existing _directory_ only. |
|
949 func (a *Assertions) NoDirExistsf(path string, msg string, args ...interface{}) bool { |
|
950 if h, ok := a.t.(tHelper); ok { |
|
951 h.Helper() |
|
952 } |
|
953 return NoDirExistsf(a.t, path, msg, args...) |
610 } |
954 } |
611 |
955 |
612 // NoError asserts that a function returned no error (i.e. `nil`). |
956 // NoError asserts that a function returned no error (i.e. `nil`). |
613 // |
957 // |
614 // actualObj, err := SomeFunction() |
958 // actualObj, err := SomeFunction() |
633 h.Helper() |
977 h.Helper() |
634 } |
978 } |
635 return NoErrorf(a.t, err, msg, args...) |
979 return NoErrorf(a.t, err, msg, args...) |
636 } |
980 } |
637 |
981 |
|
982 // NoFileExists checks whether a file does not exist in a given path. It fails |
|
983 // if the path points to an existing _file_ only. |
|
984 func (a *Assertions) NoFileExists(path string, msgAndArgs ...interface{}) bool { |
|
985 if h, ok := a.t.(tHelper); ok { |
|
986 h.Helper() |
|
987 } |
|
988 return NoFileExists(a.t, path, msgAndArgs...) |
|
989 } |
|
990 |
|
991 // NoFileExistsf checks whether a file does not exist in a given path. It fails |
|
992 // if the path points to an existing _file_ only. |
|
993 func (a *Assertions) NoFileExistsf(path string, msg string, args ...interface{}) bool { |
|
994 if h, ok := a.t.(tHelper); ok { |
|
995 h.Helper() |
|
996 } |
|
997 return NoFileExistsf(a.t, path, msg, args...) |
|
998 } |
|
999 |
638 // NotContains asserts that the specified string, list(array, slice...) or map does NOT contain the |
1000 // NotContains asserts that the specified string, list(array, slice...) or map does NOT contain the |
639 // specified substring or element. |
1001 // specified substring or element. |
640 // |
1002 // |
641 // a.NotContains("Hello World", "Earth") |
1003 // a.NotContains("Hello World", "Earth") |
642 // a.NotContains(["Hello", "World"], "Earth") |
1004 // a.NotContains(["Hello", "World"], "Earth") |
698 h.Helper() |
1060 h.Helper() |
699 } |
1061 } |
700 return NotEqual(a.t, expected, actual, msgAndArgs...) |
1062 return NotEqual(a.t, expected, actual, msgAndArgs...) |
701 } |
1063 } |
702 |
1064 |
|
1065 // NotEqualValues asserts that two objects are not equal even when converted to the same type |
|
1066 // |
|
1067 // a.NotEqualValues(obj1, obj2) |
|
1068 func (a *Assertions) NotEqualValues(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool { |
|
1069 if h, ok := a.t.(tHelper); ok { |
|
1070 h.Helper() |
|
1071 } |
|
1072 return NotEqualValues(a.t, expected, actual, msgAndArgs...) |
|
1073 } |
|
1074 |
|
1075 // NotEqualValuesf asserts that two objects are not equal even when converted to the same type |
|
1076 // |
|
1077 // a.NotEqualValuesf(obj1, obj2, "error message %s", "formatted") |
|
1078 func (a *Assertions) NotEqualValuesf(expected interface{}, actual interface{}, msg string, args ...interface{}) bool { |
|
1079 if h, ok := a.t.(tHelper); ok { |
|
1080 h.Helper() |
|
1081 } |
|
1082 return NotEqualValuesf(a.t, expected, actual, msg, args...) |
|
1083 } |
|
1084 |
703 // NotEqualf asserts that the specified values are NOT equal. |
1085 // NotEqualf asserts that the specified values are NOT equal. |
704 // |
1086 // |
705 // a.NotEqualf(obj1, obj2, "error message %s", "formatted") |
1087 // a.NotEqualf(obj1, obj2, "error message %s", "formatted") |
706 // |
1088 // |
707 // Pointer variable equality is determined based on the equality of the |
1089 // Pointer variable equality is determined based on the equality of the |
711 h.Helper() |
1093 h.Helper() |
712 } |
1094 } |
713 return NotEqualf(a.t, expected, actual, msg, args...) |
1095 return NotEqualf(a.t, expected, actual, msg, args...) |
714 } |
1096 } |
715 |
1097 |
|
1098 // NotErrorIs asserts that at none of the errors in err's chain matches target. |
|
1099 // This is a wrapper for errors.Is. |
|
1100 func (a *Assertions) NotErrorIs(err error, target error, msgAndArgs ...interface{}) bool { |
|
1101 if h, ok := a.t.(tHelper); ok { |
|
1102 h.Helper() |
|
1103 } |
|
1104 return NotErrorIs(a.t, err, target, msgAndArgs...) |
|
1105 } |
|
1106 |
|
1107 // NotErrorIsf asserts that at none of the errors in err's chain matches target. |
|
1108 // This is a wrapper for errors.Is. |
|
1109 func (a *Assertions) NotErrorIsf(err error, target error, msg string, args ...interface{}) bool { |
|
1110 if h, ok := a.t.(tHelper); ok { |
|
1111 h.Helper() |
|
1112 } |
|
1113 return NotErrorIsf(a.t, err, target, msg, args...) |
|
1114 } |
|
1115 |
716 // NotNil asserts that the specified object is not nil. |
1116 // NotNil asserts that the specified object is not nil. |
717 // |
1117 // |
718 // a.NotNil(err) |
1118 // a.NotNil(err) |
719 func (a *Assertions) NotNil(object interface{}, msgAndArgs ...interface{}) bool { |
1119 func (a *Assertions) NotNil(object interface{}, msgAndArgs ...interface{}) bool { |
720 if h, ok := a.t.(tHelper); ok { |
1120 if h, ok := a.t.(tHelper); ok { |
764 return NotRegexp(a.t, rx, str, msgAndArgs...) |
1164 return NotRegexp(a.t, rx, str, msgAndArgs...) |
765 } |
1165 } |
766 |
1166 |
767 // NotRegexpf asserts that a specified regexp does not match a string. |
1167 // NotRegexpf asserts that a specified regexp does not match a string. |
768 // |
1168 // |
769 // a.NotRegexpf(regexp.MustCompile("starts", "error message %s", "formatted"), "it's starting") |
1169 // a.NotRegexpf(regexp.MustCompile("starts"), "it's starting", "error message %s", "formatted") |
770 // a.NotRegexpf("^start", "it's not starting", "error message %s", "formatted") |
1170 // a.NotRegexpf("^start", "it's not starting", "error message %s", "formatted") |
771 func (a *Assertions) NotRegexpf(rx interface{}, str interface{}, msg string, args ...interface{}) bool { |
1171 func (a *Assertions) NotRegexpf(rx interface{}, str interface{}, msg string, args ...interface{}) bool { |
772 if h, ok := a.t.(tHelper); ok { |
1172 if h, ok := a.t.(tHelper); ok { |
773 h.Helper() |
1173 h.Helper() |
774 } |
1174 } |
775 return NotRegexpf(a.t, rx, str, msg, args...) |
1175 return NotRegexpf(a.t, rx, str, msg, args...) |
776 } |
1176 } |
777 |
1177 |
|
1178 // NotSame asserts that two pointers do not reference the same object. |
|
1179 // |
|
1180 // a.NotSame(ptr1, ptr2) |
|
1181 // |
|
1182 // Both arguments must be pointer variables. Pointer variable sameness is |
|
1183 // determined based on the equality of both type and value. |
|
1184 func (a *Assertions) NotSame(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool { |
|
1185 if h, ok := a.t.(tHelper); ok { |
|
1186 h.Helper() |
|
1187 } |
|
1188 return NotSame(a.t, expected, actual, msgAndArgs...) |
|
1189 } |
|
1190 |
|
1191 // NotSamef asserts that two pointers do not reference the same object. |
|
1192 // |
|
1193 // a.NotSamef(ptr1, ptr2, "error message %s", "formatted") |
|
1194 // |
|
1195 // Both arguments must be pointer variables. Pointer variable sameness is |
|
1196 // determined based on the equality of both type and value. |
|
1197 func (a *Assertions) NotSamef(expected interface{}, actual interface{}, msg string, args ...interface{}) bool { |
|
1198 if h, ok := a.t.(tHelper); ok { |
|
1199 h.Helper() |
|
1200 } |
|
1201 return NotSamef(a.t, expected, actual, msg, args...) |
|
1202 } |
|
1203 |
778 // NotSubset asserts that the specified list(array, slice...) contains not all |
1204 // NotSubset asserts that the specified list(array, slice...) contains not all |
779 // elements given in the specified subset(array, slice...). |
1205 // elements given in the specified subset(array, slice...). |
780 // |
1206 // |
781 // a.NotSubset([1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]") |
1207 // a.NotSubset([1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]") |
782 func (a *Assertions) NotSubset(list interface{}, subset interface{}, msgAndArgs ...interface{}) bool { |
1208 func (a *Assertions) NotSubset(list interface{}, subset interface{}, msgAndArgs ...interface{}) bool { |
821 h.Helper() |
1247 h.Helper() |
822 } |
1248 } |
823 return Panics(a.t, f, msgAndArgs...) |
1249 return Panics(a.t, f, msgAndArgs...) |
824 } |
1250 } |
825 |
1251 |
|
1252 // PanicsWithError asserts that the code inside the specified PanicTestFunc |
|
1253 // panics, and that the recovered panic value is an error that satisfies the |
|
1254 // EqualError comparison. |
|
1255 // |
|
1256 // a.PanicsWithError("crazy error", func(){ GoCrazy() }) |
|
1257 func (a *Assertions) PanicsWithError(errString string, f PanicTestFunc, msgAndArgs ...interface{}) bool { |
|
1258 if h, ok := a.t.(tHelper); ok { |
|
1259 h.Helper() |
|
1260 } |
|
1261 return PanicsWithError(a.t, errString, f, msgAndArgs...) |
|
1262 } |
|
1263 |
|
1264 // PanicsWithErrorf asserts that the code inside the specified PanicTestFunc |
|
1265 // panics, and that the recovered panic value is an error that satisfies the |
|
1266 // EqualError comparison. |
|
1267 // |
|
1268 // a.PanicsWithErrorf("crazy error", func(){ GoCrazy() }, "error message %s", "formatted") |
|
1269 func (a *Assertions) PanicsWithErrorf(errString string, f PanicTestFunc, msg string, args ...interface{}) bool { |
|
1270 if h, ok := a.t.(tHelper); ok { |
|
1271 h.Helper() |
|
1272 } |
|
1273 return PanicsWithErrorf(a.t, errString, f, msg, args...) |
|
1274 } |
|
1275 |
826 // PanicsWithValue asserts that the code inside the specified PanicTestFunc panics, and that |
1276 // PanicsWithValue asserts that the code inside the specified PanicTestFunc panics, and that |
827 // the recovered panic value equals the expected panic value. |
1277 // the recovered panic value equals the expected panic value. |
828 // |
1278 // |
829 // a.PanicsWithValue("crazy error", func(){ GoCrazy() }) |
1279 // a.PanicsWithValue("crazy error", func(){ GoCrazy() }) |
830 func (a *Assertions) PanicsWithValue(expected interface{}, f PanicTestFunc, msgAndArgs ...interface{}) bool { |
1280 func (a *Assertions) PanicsWithValue(expected interface{}, f PanicTestFunc, msgAndArgs ...interface{}) bool { |
851 func (a *Assertions) Panicsf(f PanicTestFunc, msg string, args ...interface{}) bool { |
1301 func (a *Assertions) Panicsf(f PanicTestFunc, msg string, args ...interface{}) bool { |
852 if h, ok := a.t.(tHelper); ok { |
1302 if h, ok := a.t.(tHelper); ok { |
853 h.Helper() |
1303 h.Helper() |
854 } |
1304 } |
855 return Panicsf(a.t, f, msg, args...) |
1305 return Panicsf(a.t, f, msg, args...) |
|
1306 } |
|
1307 |
|
1308 // Positive asserts that the specified element is positive |
|
1309 // |
|
1310 // a.Positive(1) |
|
1311 // a.Positive(1.23) |
|
1312 func (a *Assertions) Positive(e interface{}, msgAndArgs ...interface{}) bool { |
|
1313 if h, ok := a.t.(tHelper); ok { |
|
1314 h.Helper() |
|
1315 } |
|
1316 return Positive(a.t, e, msgAndArgs...) |
|
1317 } |
|
1318 |
|
1319 // Positivef asserts that the specified element is positive |
|
1320 // |
|
1321 // a.Positivef(1, "error message %s", "formatted") |
|
1322 // a.Positivef(1.23, "error message %s", "formatted") |
|
1323 func (a *Assertions) Positivef(e interface{}, msg string, args ...interface{}) bool { |
|
1324 if h, ok := a.t.(tHelper); ok { |
|
1325 h.Helper() |
|
1326 } |
|
1327 return Positivef(a.t, e, msg, args...) |
856 } |
1328 } |
857 |
1329 |
858 // Regexp asserts that a specified regexp matches a string. |
1330 // Regexp asserts that a specified regexp matches a string. |
859 // |
1331 // |
860 // a.Regexp(regexp.MustCompile("start"), "it's starting") |
1332 // a.Regexp(regexp.MustCompile("start"), "it's starting") |
866 return Regexp(a.t, rx, str, msgAndArgs...) |
1338 return Regexp(a.t, rx, str, msgAndArgs...) |
867 } |
1339 } |
868 |
1340 |
869 // Regexpf asserts that a specified regexp matches a string. |
1341 // Regexpf asserts that a specified regexp matches a string. |
870 // |
1342 // |
871 // a.Regexpf(regexp.MustCompile("start", "error message %s", "formatted"), "it's starting") |
1343 // a.Regexpf(regexp.MustCompile("start"), "it's starting", "error message %s", "formatted") |
872 // a.Regexpf("start...$", "it's not starting", "error message %s", "formatted") |
1344 // a.Regexpf("start...$", "it's not starting", "error message %s", "formatted") |
873 func (a *Assertions) Regexpf(rx interface{}, str interface{}, msg string, args ...interface{}) bool { |
1345 func (a *Assertions) Regexpf(rx interface{}, str interface{}, msg string, args ...interface{}) bool { |
874 if h, ok := a.t.(tHelper); ok { |
1346 if h, ok := a.t.(tHelper); ok { |
875 h.Helper() |
1347 h.Helper() |
876 } |
1348 } |
877 return Regexpf(a.t, rx, str, msg, args...) |
1349 return Regexpf(a.t, rx, str, msg, args...) |
878 } |
1350 } |
879 |
1351 |
|
1352 // Same asserts that two pointers reference the same object. |
|
1353 // |
|
1354 // a.Same(ptr1, ptr2) |
|
1355 // |
|
1356 // Both arguments must be pointer variables. Pointer variable sameness is |
|
1357 // determined based on the equality of both type and value. |
|
1358 func (a *Assertions) Same(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool { |
|
1359 if h, ok := a.t.(tHelper); ok { |
|
1360 h.Helper() |
|
1361 } |
|
1362 return Same(a.t, expected, actual, msgAndArgs...) |
|
1363 } |
|
1364 |
|
1365 // Samef asserts that two pointers reference the same object. |
|
1366 // |
|
1367 // a.Samef(ptr1, ptr2, "error message %s", "formatted") |
|
1368 // |
|
1369 // Both arguments must be pointer variables. Pointer variable sameness is |
|
1370 // determined based on the equality of both type and value. |
|
1371 func (a *Assertions) Samef(expected interface{}, actual interface{}, msg string, args ...interface{}) bool { |
|
1372 if h, ok := a.t.(tHelper); ok { |
|
1373 h.Helper() |
|
1374 } |
|
1375 return Samef(a.t, expected, actual, msg, args...) |
|
1376 } |
|
1377 |
880 // Subset asserts that the specified list(array, slice...) contains all |
1378 // Subset asserts that the specified list(array, slice...) contains all |
881 // elements given in the specified subset(array, slice...). |
1379 // elements given in the specified subset(array, slice...). |
882 // |
1380 // |
883 // a.Subset([1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]") |
1381 // a.Subset([1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]") |
884 func (a *Assertions) Subset(list interface{}, subset interface{}, msgAndArgs ...interface{}) bool { |
1382 func (a *Assertions) Subset(list interface{}, subset interface{}, msgAndArgs ...interface{}) bool { |
937 h.Helper() |
1435 h.Helper() |
938 } |
1436 } |
939 return WithinDurationf(a.t, expected, actual, delta, msg, args...) |
1437 return WithinDurationf(a.t, expected, actual, delta, msg, args...) |
940 } |
1438 } |
941 |
1439 |
|
1440 // YAMLEq asserts that two YAML strings are equivalent. |
|
1441 func (a *Assertions) YAMLEq(expected string, actual string, msgAndArgs ...interface{}) bool { |
|
1442 if h, ok := a.t.(tHelper); ok { |
|
1443 h.Helper() |
|
1444 } |
|
1445 return YAMLEq(a.t, expected, actual, msgAndArgs...) |
|
1446 } |
|
1447 |
|
1448 // YAMLEqf asserts that two YAML strings are equivalent. |
|
1449 func (a *Assertions) YAMLEqf(expected string, actual string, msg string, args ...interface{}) bool { |
|
1450 if h, ok := a.t.(tHelper); ok { |
|
1451 h.Helper() |
|
1452 } |
|
1453 return YAMLEqf(a.t, expected, actual, msg, args...) |
|
1454 } |
|
1455 |
942 // Zero asserts that i is the zero value for its type. |
1456 // Zero asserts that i is the zero value for its type. |
943 func (a *Assertions) Zero(i interface{}, msgAndArgs ...interface{}) bool { |
1457 func (a *Assertions) Zero(i interface{}, msgAndArgs ...interface{}) bool { |
944 if h, ok := a.t.(tHelper); ok { |
1458 if h, ok := a.t.(tHelper); ok { |
945 h.Helper() |
1459 h.Helper() |
946 } |
1460 } |