2019-03-27 12:33:00 +03:00
/ *
* CODE GENERATED AUTOMATICALLY WITH github . com / stretchr / testify / _codegen
* THIS FILE MUST NOT BE EDITED BY HAND
* /
package require
import (
assert "github.com/stretchr/testify/assert"
http "net/http"
url "net/url"
time "time"
)
// Condition uses a Comparison to assert a complex condition.
func Condition ( t TestingT , comp assert . Comparison , msgAndArgs ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . Condition ( t , comp , msgAndArgs ... ) {
return
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
}
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// Conditionf uses a Comparison to assert a complex condition.
func Conditionf ( t TestingT , comp assert . Comparison , msg string , args ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . Conditionf ( t , comp , msg , args ... ) {
return
}
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// Contains asserts that the specified string, list(array, slice...) or map contains the
// specified substring or element.
//
// assert.Contains(t, "Hello World", "World")
// assert.Contains(t, ["Hello", "World"], "World")
// assert.Contains(t, {"Hello": "World"}, "Hello")
func Contains ( t TestingT , s interface { } , contains interface { } , msgAndArgs ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . Contains ( t , s , contains , msgAndArgs ... ) {
return
}
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// Containsf asserts that the specified string, list(array, slice...) or map contains the
// specified substring or element.
//
// assert.Containsf(t, "Hello World", "World", "error message %s", "formatted")
// assert.Containsf(t, ["Hello", "World"], "World", "error message %s", "formatted")
// assert.Containsf(t, {"Hello": "World"}, "Hello", "error message %s", "formatted")
func Containsf ( t TestingT , s interface { } , contains interface { } , msg string , args ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . Containsf ( t , s , contains , msg , args ... ) {
return
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
}
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// 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.
func DirExists ( t TestingT , path string , msgAndArgs ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . DirExists ( t , path , msgAndArgs ... ) {
return
}
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// 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.
func DirExistsf ( t TestingT , path string , msg string , args ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . DirExistsf ( t , path , msg , args ... ) {
return
}
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// ElementsMatch asserts that the specified listA(array, slice...) is equal to specified
// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements,
// the number of appearances of each of them in both lists should match.
//
// assert.ElementsMatch(t, [1, 3, 2, 3], [1, 3, 3, 2])
func ElementsMatch ( t TestingT , listA interface { } , listB interface { } , msgAndArgs ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . ElementsMatch ( t , listA , listB , msgAndArgs ... ) {
return
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
}
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// ElementsMatchf asserts that the specified listA(array, slice...) is equal to specified
// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements,
// the number of appearances of each of them in both lists should match.
//
// assert.ElementsMatchf(t, [1, 3, 2, 3], [1, 3, 3, 2], "error message %s", "formatted")
func ElementsMatchf ( t TestingT , listA interface { } , listB interface { } , msg string , args ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . ElementsMatchf ( t , listA , listB , msg , args ... ) {
return
}
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// Empty asserts that the specified object is empty. I.e. nil, "", false, 0 or either
// a slice or a channel with len == 0.
//
// assert.Empty(t, obj)
func Empty ( t TestingT , object interface { } , msgAndArgs ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . Empty ( t , object , msgAndArgs ... ) {
return
}
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// Emptyf asserts that the specified object is empty. I.e. nil, "", false, 0 or either
// a slice or a channel with len == 0.
//
// assert.Emptyf(t, obj, "error message %s", "formatted")
func Emptyf ( t TestingT , object interface { } , msg string , args ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . Emptyf ( t , object , msg , args ... ) {
return
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
}
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// Equal asserts that two objects are equal.
//
// assert.Equal(t, 123, 123)
//
// Pointer variable equality is determined based on the equality of the
// referenced values (as opposed to the memory addresses). Function equality
// cannot be determined and will always fail.
func Equal ( t TestingT , expected interface { } , actual interface { } , msgAndArgs ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . Equal ( t , expected , actual , msgAndArgs ... ) {
return
}
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// EqualError asserts that a function returned an error (i.e. not `nil`)
// and that it is equal to the provided error.
//
// actualObj, err := SomeFunction()
// assert.EqualError(t, err, expectedErrorString)
func EqualError ( t TestingT , theError error , errString string , msgAndArgs ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . EqualError ( t , theError , errString , msgAndArgs ... ) {
return
}
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// EqualErrorf asserts that a function returned an error (i.e. not `nil`)
// and that it is equal to the provided error.
//
// actualObj, err := SomeFunction()
// assert.EqualErrorf(t, err, expectedErrorString, "error message %s", "formatted")
func EqualErrorf ( t TestingT , theError error , errString string , msg string , args ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . EqualErrorf ( t , theError , errString , msg , args ... ) {
return
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
}
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// EqualValues asserts that two objects are equal or convertable to the same types
// and equal.
//
// assert.EqualValues(t, uint32(123), int32(123))
func EqualValues ( t TestingT , expected interface { } , actual interface { } , msgAndArgs ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . EqualValues ( t , expected , actual , msgAndArgs ... ) {
return
}
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// EqualValuesf asserts that two objects are equal or convertable to the same types
// and equal.
//
// assert.EqualValuesf(t, uint32(123, "error message %s", "formatted"), int32(123))
func EqualValuesf ( t TestingT , expected interface { } , actual interface { } , msg string , args ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . EqualValuesf ( t , expected , actual , msg , args ... ) {
return
}
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// Equalf asserts that two objects are equal.
//
// assert.Equalf(t, 123, 123, "error message %s", "formatted")
//
// Pointer variable equality is determined based on the equality of the
// referenced values (as opposed to the memory addresses). Function equality
// cannot be determined and will always fail.
func Equalf ( t TestingT , expected interface { } , actual interface { } , msg string , args ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . Equalf ( t , expected , actual , msg , args ... ) {
return
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
}
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// Error asserts that a function returned an error (i.e. not `nil`).
//
// actualObj, err := SomeFunction()
// if assert.Error(t, err) {
// assert.Equal(t, expectedError, err)
// }
func Error ( t TestingT , err error , msgAndArgs ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . Error ( t , err , msgAndArgs ... ) {
return
}
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// Errorf asserts that a function returned an error (i.e. not `nil`).
//
// actualObj, err := SomeFunction()
// if assert.Errorf(t, err, "error message %s", "formatted") {
// assert.Equal(t, expectedErrorf, err)
// }
func Errorf ( t TestingT , err error , msg string , args ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . Errorf ( t , err , msg , args ... ) {
return
}
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// Exactly asserts that two objects are equal in value and type.
//
// assert.Exactly(t, int32(123), int64(123))
func Exactly ( t TestingT , expected interface { } , actual interface { } , msgAndArgs ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . Exactly ( t , expected , actual , msgAndArgs ... ) {
return
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
}
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// Exactlyf asserts that two objects are equal in value and type.
//
// assert.Exactlyf(t, int32(123, "error message %s", "formatted"), int64(123))
func Exactlyf ( t TestingT , expected interface { } , actual interface { } , msg string , args ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . Exactlyf ( t , expected , actual , msg , args ... ) {
return
}
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// Fail reports a failure through
func Fail ( t TestingT , failureMessage string , msgAndArgs ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . Fail ( t , failureMessage , msgAndArgs ... ) {
return
}
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// FailNow fails test
func FailNow ( t TestingT , failureMessage string , msgAndArgs ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . FailNow ( t , failureMessage , msgAndArgs ... ) {
return
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
}
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// FailNowf fails test
func FailNowf ( t TestingT , failureMessage string , msg string , args ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . FailNowf ( t , failureMessage , msg , args ... ) {
return
}
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// Failf reports a failure through
func Failf ( t TestingT , failureMessage string , msg string , args ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . Failf ( t , failureMessage , msg , args ... ) {
return
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
}
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// False asserts that the specified value is false.
//
// assert.False(t, myBool)
func False ( t TestingT , value bool , msgAndArgs ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . False ( t , value , msgAndArgs ... ) {
return
}
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// Falsef asserts that the specified value is false.
//
// assert.Falsef(t, myBool, "error message %s", "formatted")
func Falsef ( t TestingT , value bool , msg string , args ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . Falsef ( t , value , msg , args ... ) {
return
}
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// 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.
func FileExists ( t TestingT , path string , msgAndArgs ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . FileExists ( t , path , msgAndArgs ... ) {
return
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
}
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// 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.
func FileExistsf ( t TestingT , path string , msg string , args ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . FileExistsf ( t , path , msg , args ... ) {
return
}
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// HTTPBodyContains asserts that a specified handler returns a
// body that contains a string.
//
2019-03-27 14:15:23 +03:00
// assert.HTTPBodyContains(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky")
2019-03-27 12:33:00 +03:00
//
// Returns whether the assertion was successful (true) or not (false).
func HTTPBodyContains ( t TestingT , handler http . HandlerFunc , method string , url string , values url . Values , str interface { } , msgAndArgs ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . HTTPBodyContains ( t , handler , method , url , values , str , msgAndArgs ... ) {
return
}
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// HTTPBodyContainsf asserts that a specified handler returns a
// body that contains a string.
//
2019-03-27 14:15:23 +03:00
// assert.HTTPBodyContainsf(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted")
2019-03-27 12:33:00 +03:00
//
// Returns whether the assertion was successful (true) or not (false).
func HTTPBodyContainsf ( t TestingT , handler http . HandlerFunc , method string , url string , values url . Values , str interface { } , msg string , args ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . HTTPBodyContainsf ( t , handler , method , url , values , str , msg , args ... ) {
return
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
}
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// HTTPBodyNotContains asserts that a specified handler returns a
// body that does not contain a string.
//
2019-03-27 14:15:23 +03:00
// assert.HTTPBodyNotContains(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky")
2019-03-27 12:33:00 +03:00
//
// Returns whether the assertion was successful (true) or not (false).
func HTTPBodyNotContains ( t TestingT , handler http . HandlerFunc , method string , url string , values url . Values , str interface { } , msgAndArgs ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . HTTPBodyNotContains ( t , handler , method , url , values , str , msgAndArgs ... ) {
return
}
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// HTTPBodyNotContainsf asserts that a specified handler returns a
// body that does not contain a string.
//
2019-03-27 14:15:23 +03:00
// assert.HTTPBodyNotContainsf(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted")
2019-03-27 12:33:00 +03:00
//
// Returns whether the assertion was successful (true) or not (false).
func HTTPBodyNotContainsf ( t TestingT , handler http . HandlerFunc , method string , url string , values url . Values , str interface { } , msg string , args ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . HTTPBodyNotContainsf ( t , handler , method , url , values , str , msg , args ... ) {
return
}
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// HTTPError asserts that a specified handler returns an error status code.
//
// assert.HTTPError(t, myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}}
//
// Returns whether the assertion was successful (true) or not (false).
func HTTPError ( t TestingT , handler http . HandlerFunc , method string , url string , values url . Values , msgAndArgs ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . HTTPError ( t , handler , method , url , values , msgAndArgs ... ) {
return
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
}
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// HTTPErrorf asserts that a specified handler returns an error status code.
//
// assert.HTTPErrorf(t, myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}}
//
// Returns whether the assertion was successful (true, "error message %s", "formatted") or not (false).
func HTTPErrorf ( t TestingT , handler http . HandlerFunc , method string , url string , values url . Values , msg string , args ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . HTTPErrorf ( t , handler , method , url , values , msg , args ... ) {
return
}
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// HTTPRedirect asserts that a specified handler returns a redirect status code.
//
// assert.HTTPRedirect(t, myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}}
//
// Returns whether the assertion was successful (true) or not (false).
func HTTPRedirect ( t TestingT , handler http . HandlerFunc , method string , url string , values url . Values , msgAndArgs ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . HTTPRedirect ( t , handler , method , url , values , msgAndArgs ... ) {
return
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
}
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// HTTPRedirectf asserts that a specified handler returns a redirect status code.
//
// assert.HTTPRedirectf(t, myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}}
//
// Returns whether the assertion was successful (true, "error message %s", "formatted") or not (false).
func HTTPRedirectf ( t TestingT , handler http . HandlerFunc , method string , url string , values url . Values , msg string , args ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . HTTPRedirectf ( t , handler , method , url , values , msg , args ... ) {
return
}
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// HTTPSuccess asserts that a specified handler returns a success status code.
//
// assert.HTTPSuccess(t, myHandler, "POST", "http://www.google.com", nil)
//
// Returns whether the assertion was successful (true) or not (false).
func HTTPSuccess ( t TestingT , handler http . HandlerFunc , method string , url string , values url . Values , msgAndArgs ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . HTTPSuccess ( t , handler , method , url , values , msgAndArgs ... ) {
return
}
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// HTTPSuccessf asserts that a specified handler returns a success status code.
//
// assert.HTTPSuccessf(t, myHandler, "POST", "http://www.google.com", nil, "error message %s", "formatted")
//
// Returns whether the assertion was successful (true) or not (false).
func HTTPSuccessf ( t TestingT , handler http . HandlerFunc , method string , url string , values url . Values , msg string , args ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . HTTPSuccessf ( t , handler , method , url , values , msg , args ... ) {
return
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
}
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// Implements asserts that an object is implemented by the specified interface.
//
// assert.Implements(t, (*MyInterface)(nil), new(MyObject))
func Implements ( t TestingT , interfaceObject interface { } , object interface { } , msgAndArgs ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . Implements ( t , interfaceObject , object , msgAndArgs ... ) {
return
}
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// Implementsf asserts that an object is implemented by the specified interface.
//
// assert.Implementsf(t, (*MyInterface, "error message %s", "formatted")(nil), new(MyObject))
func Implementsf ( t TestingT , interfaceObject interface { } , object interface { } , msg string , args ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . Implementsf ( t , interfaceObject , object , msg , args ... ) {
return
}
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// InDelta asserts that the two numerals are within delta of each other.
//
// assert.InDelta(t, math.Pi, (22 / 7.0), 0.01)
func InDelta ( t TestingT , expected interface { } , actual interface { } , delta float64 , msgAndArgs ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . InDelta ( t , expected , actual , delta , msgAndArgs ... ) {
return
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
}
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// InDeltaMapValues is the same as InDelta, but it compares all values between two maps. Both maps must have exactly the same keys.
func InDeltaMapValues ( t TestingT , expected interface { } , actual interface { } , delta float64 , msgAndArgs ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . InDeltaMapValues ( t , expected , actual , delta , msgAndArgs ... ) {
return
}
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// InDeltaMapValuesf is the same as InDelta, but it compares all values between two maps. Both maps must have exactly the same keys.
func InDeltaMapValuesf ( t TestingT , expected interface { } , actual interface { } , delta float64 , msg string , args ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . InDeltaMapValuesf ( t , expected , actual , delta , msg , args ... ) {
return
}
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// InDeltaSlice is the same as InDelta, except it compares two slices.
func InDeltaSlice ( t TestingT , expected interface { } , actual interface { } , delta float64 , msgAndArgs ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . InDeltaSlice ( t , expected , actual , delta , msgAndArgs ... ) {
return
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
}
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// InDeltaSlicef is the same as InDelta, except it compares two slices.
func InDeltaSlicef ( t TestingT , expected interface { } , actual interface { } , delta float64 , msg string , args ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . InDeltaSlicef ( t , expected , actual , delta , msg , args ... ) {
return
}
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// InDeltaf asserts that the two numerals are within delta of each other.
//
// assert.InDeltaf(t, math.Pi, (22 / 7.0, "error message %s", "formatted"), 0.01)
func InDeltaf ( t TestingT , expected interface { } , actual interface { } , delta float64 , msg string , args ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . InDeltaf ( t , expected , actual , delta , msg , args ... ) {
return
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
}
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// InEpsilon asserts that expected and actual have a relative error less than epsilon
func InEpsilon ( t TestingT , expected interface { } , actual interface { } , epsilon float64 , msgAndArgs ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . InEpsilon ( t , expected , actual , epsilon , msgAndArgs ... ) {
return
}
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// InEpsilonSlice is the same as InEpsilon, except it compares each value from two slices.
func InEpsilonSlice ( t TestingT , expected interface { } , actual interface { } , epsilon float64 , msgAndArgs ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . InEpsilonSlice ( t , expected , actual , epsilon , msgAndArgs ... ) {
return
}
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// InEpsilonSlicef is the same as InEpsilon, except it compares each value from two slices.
func InEpsilonSlicef ( t TestingT , expected interface { } , actual interface { } , epsilon float64 , msg string , args ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . InEpsilonSlicef ( t , expected , actual , epsilon , msg , args ... ) {
return
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
}
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// InEpsilonf asserts that expected and actual have a relative error less than epsilon
func InEpsilonf ( t TestingT , expected interface { } , actual interface { } , epsilon float64 , msg string , args ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . InEpsilonf ( t , expected , actual , epsilon , msg , args ... ) {
return
}
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// IsType asserts that the specified objects are of the same type.
func IsType ( t TestingT , expectedType interface { } , object interface { } , msgAndArgs ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . IsType ( t , expectedType , object , msgAndArgs ... ) {
return
}
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// IsTypef asserts that the specified objects are of the same type.
func IsTypef ( t TestingT , expectedType interface { } , object interface { } , msg string , args ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . IsTypef ( t , expectedType , object , msg , args ... ) {
return
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
}
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// JSONEq asserts that two JSON strings are equivalent.
//
// assert.JSONEq(t, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`)
func JSONEq ( t TestingT , expected string , actual string , msgAndArgs ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . JSONEq ( t , expected , actual , msgAndArgs ... ) {
return
}
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// JSONEqf asserts that two JSON strings are equivalent.
//
// assert.JSONEqf(t, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`, "error message %s", "formatted")
func JSONEqf ( t TestingT , expected string , actual string , msg string , args ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . JSONEqf ( t , expected , actual , msg , args ... ) {
return
}
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// Len asserts that the specified object has specific length.
// Len also fails if the object has a type that len() not accept.
//
// assert.Len(t, mySlice, 3)
func Len ( t TestingT , object interface { } , length int , msgAndArgs ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . Len ( t , object , length , msgAndArgs ... ) {
return
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
}
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// Lenf asserts that the specified object has specific length.
// Lenf also fails if the object has a type that len() not accept.
//
// assert.Lenf(t, mySlice, 3, "error message %s", "formatted")
func Lenf ( t TestingT , object interface { } , length int , msg string , args ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . Lenf ( t , object , length , msg , args ... ) {
return
}
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// Nil asserts that the specified object is nil.
//
// assert.Nil(t, err)
func Nil ( t TestingT , object interface { } , msgAndArgs ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . Nil ( t , object , msgAndArgs ... ) {
return
}
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// Nilf asserts that the specified object is nil.
//
// assert.Nilf(t, err, "error message %s", "formatted")
func Nilf ( t TestingT , object interface { } , msg string , args ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . Nilf ( t , object , msg , args ... ) {
return
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
}
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// NoError asserts that a function returned no error (i.e. `nil`).
//
// actualObj, err := SomeFunction()
// if assert.NoError(t, err) {
// assert.Equal(t, expectedObj, actualObj)
// }
func NoError ( t TestingT , err error , msgAndArgs ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . NoError ( t , err , msgAndArgs ... ) {
return
}
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// NoErrorf asserts that a function returned no error (i.e. `nil`).
//
// actualObj, err := SomeFunction()
// if assert.NoErrorf(t, err, "error message %s", "formatted") {
// assert.Equal(t, expectedObj, actualObj)
// }
func NoErrorf ( t TestingT , err error , msg string , args ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . NoErrorf ( t , err , msg , args ... ) {
return
}
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// NotContains asserts that the specified string, list(array, slice...) or map does NOT contain the
// specified substring or element.
//
// assert.NotContains(t, "Hello World", "Earth")
// assert.NotContains(t, ["Hello", "World"], "Earth")
// assert.NotContains(t, {"Hello": "World"}, "Earth")
func NotContains ( t TestingT , s interface { } , contains interface { } , msgAndArgs ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . NotContains ( t , s , contains , msgAndArgs ... ) {
return
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
}
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// NotContainsf asserts that the specified string, list(array, slice...) or map does NOT contain the
// specified substring or element.
//
// assert.NotContainsf(t, "Hello World", "Earth", "error message %s", "formatted")
// assert.NotContainsf(t, ["Hello", "World"], "Earth", "error message %s", "formatted")
// assert.NotContainsf(t, {"Hello": "World"}, "Earth", "error message %s", "formatted")
func NotContainsf ( t TestingT , s interface { } , contains interface { } , msg string , args ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . NotContainsf ( t , s , contains , msg , args ... ) {
return
}
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// NotEmpty asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either
// a slice or a channel with len == 0.
//
// if assert.NotEmpty(t, obj) {
// assert.Equal(t, "two", obj[1])
// }
func NotEmpty ( t TestingT , object interface { } , msgAndArgs ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . NotEmpty ( t , object , msgAndArgs ... ) {
return
}
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// NotEmptyf asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either
// a slice or a channel with len == 0.
//
// if assert.NotEmptyf(t, obj, "error message %s", "formatted") {
// assert.Equal(t, "two", obj[1])
// }
func NotEmptyf ( t TestingT , object interface { } , msg string , args ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . NotEmptyf ( t , object , msg , args ... ) {
return
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
}
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// NotEqual asserts that the specified values are NOT equal.
//
// assert.NotEqual(t, obj1, obj2)
//
// Pointer variable equality is determined based on the equality of the
// referenced values (as opposed to the memory addresses).
func NotEqual ( t TestingT , expected interface { } , actual interface { } , msgAndArgs ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . NotEqual ( t , expected , actual , msgAndArgs ... ) {
return
}
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// NotEqualf asserts that the specified values are NOT equal.
//
// assert.NotEqualf(t, obj1, obj2, "error message %s", "formatted")
//
// Pointer variable equality is determined based on the equality of the
// referenced values (as opposed to the memory addresses).
func NotEqualf ( t TestingT , expected interface { } , actual interface { } , msg string , args ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . NotEqualf ( t , expected , actual , msg , args ... ) {
return
}
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// NotNil asserts that the specified object is not nil.
//
// assert.NotNil(t, err)
func NotNil ( t TestingT , object interface { } , msgAndArgs ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . NotNil ( t , object , msgAndArgs ... ) {
return
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
}
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// NotNilf asserts that the specified object is not nil.
//
// assert.NotNilf(t, err, "error message %s", "formatted")
func NotNilf ( t TestingT , object interface { } , msg string , args ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . NotNilf ( t , object , msg , args ... ) {
return
}
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// NotPanics asserts that the code inside the specified PanicTestFunc does NOT panic.
//
// assert.NotPanics(t, func(){ RemainCalm() })
func NotPanics ( t TestingT , f assert . PanicTestFunc , msgAndArgs ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . NotPanics ( t , f , msgAndArgs ... ) {
return
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
}
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// NotPanicsf asserts that the code inside the specified PanicTestFunc does NOT panic.
//
// assert.NotPanicsf(t, func(){ RemainCalm() }, "error message %s", "formatted")
func NotPanicsf ( t TestingT , f assert . PanicTestFunc , msg string , args ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . NotPanicsf ( t , f , msg , args ... ) {
return
}
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// NotRegexp asserts that a specified regexp does not match a string.
//
// assert.NotRegexp(t, regexp.MustCompile("starts"), "it's starting")
// assert.NotRegexp(t, "^start", "it's not starting")
func NotRegexp ( t TestingT , rx interface { } , str interface { } , msgAndArgs ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . NotRegexp ( t , rx , str , msgAndArgs ... ) {
return
}
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// NotRegexpf asserts that a specified regexp does not match a string.
//
// assert.NotRegexpf(t, regexp.MustCompile("starts", "error message %s", "formatted"), "it's starting")
// assert.NotRegexpf(t, "^start", "it's not starting", "error message %s", "formatted")
func NotRegexpf ( t TestingT , rx interface { } , str interface { } , msg string , args ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . NotRegexpf ( t , rx , str , msg , args ... ) {
return
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
}
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// NotSubset asserts that the specified list(array, slice...) contains not all
// elements given in the specified subset(array, slice...).
//
// assert.NotSubset(t, [1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]")
func NotSubset ( t TestingT , list interface { } , subset interface { } , msgAndArgs ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . NotSubset ( t , list , subset , msgAndArgs ... ) {
return
}
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// NotSubsetf asserts that the specified list(array, slice...) contains not all
// elements given in the specified subset(array, slice...).
//
// assert.NotSubsetf(t, [1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]", "error message %s", "formatted")
func NotSubsetf ( t TestingT , list interface { } , subset interface { } , msg string , args ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . NotSubsetf ( t , list , subset , msg , args ... ) {
return
}
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// NotZero asserts that i is not the zero value for its type.
func NotZero ( t TestingT , i interface { } , msgAndArgs ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . NotZero ( t , i , msgAndArgs ... ) {
return
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
}
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// NotZerof asserts that i is not the zero value for its type.
func NotZerof ( t TestingT , i interface { } , msg string , args ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . NotZerof ( t , i , msg , args ... ) {
return
}
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// Panics asserts that the code inside the specified PanicTestFunc panics.
//
// assert.Panics(t, func(){ GoCrazy() })
func Panics ( t TestingT , f assert . PanicTestFunc , msgAndArgs ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . Panics ( t , f , msgAndArgs ... ) {
return
}
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// PanicsWithValue asserts that the code inside the specified PanicTestFunc panics, and that
// the recovered panic value equals the expected panic value.
//
// assert.PanicsWithValue(t, "crazy error", func(){ GoCrazy() })
func PanicsWithValue ( t TestingT , expected interface { } , f assert . PanicTestFunc , msgAndArgs ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . PanicsWithValue ( t , expected , f , msgAndArgs ... ) {
return
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
}
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// PanicsWithValuef asserts that the code inside the specified PanicTestFunc panics, and that
// the recovered panic value equals the expected panic value.
//
// assert.PanicsWithValuef(t, "crazy error", func(){ GoCrazy() }, "error message %s", "formatted")
func PanicsWithValuef ( t TestingT , expected interface { } , f assert . PanicTestFunc , msg string , args ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . PanicsWithValuef ( t , expected , f , msg , args ... ) {
return
}
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// Panicsf asserts that the code inside the specified PanicTestFunc panics.
//
// assert.Panicsf(t, func(){ GoCrazy() }, "error message %s", "formatted")
func Panicsf ( t TestingT , f assert . PanicTestFunc , msg string , args ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . Panicsf ( t , f , msg , args ... ) {
return
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
}
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// Regexp asserts that a specified regexp matches a string.
//
// assert.Regexp(t, regexp.MustCompile("start"), "it's starting")
// assert.Regexp(t, "start...$", "it's not starting")
func Regexp ( t TestingT , rx interface { } , str interface { } , msgAndArgs ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . Regexp ( t , rx , str , msgAndArgs ... ) {
return
}
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// Regexpf asserts that a specified regexp matches a string.
//
// assert.Regexpf(t, regexp.MustCompile("start", "error message %s", "formatted"), "it's starting")
// assert.Regexpf(t, "start...$", "it's not starting", "error message %s", "formatted")
func Regexpf ( t TestingT , rx interface { } , str interface { } , msg string , args ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . Regexpf ( t , rx , str , msg , args ... ) {
return
}
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// Subset asserts that the specified list(array, slice...) contains all
// elements given in the specified subset(array, slice...).
//
// assert.Subset(t, [1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]")
func Subset ( t TestingT , list interface { } , subset interface { } , msgAndArgs ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . Subset ( t , list , subset , msgAndArgs ... ) {
return
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
}
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// Subsetf asserts that the specified list(array, slice...) contains all
// elements given in the specified subset(array, slice...).
//
// assert.Subsetf(t, [1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]", "error message %s", "formatted")
func Subsetf ( t TestingT , list interface { } , subset interface { } , msg string , args ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . Subsetf ( t , list , subset , msg , args ... ) {
return
}
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// True asserts that the specified value is true.
//
// assert.True(t, myBool)
func True ( t TestingT , value bool , msgAndArgs ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . True ( t , value , msgAndArgs ... ) {
return
}
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// Truef asserts that the specified value is true.
//
// assert.Truef(t, myBool, "error message %s", "formatted")
func Truef ( t TestingT , value bool , msg string , args ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . Truef ( t , value , msg , args ... ) {
return
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
}
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// WithinDuration asserts that the two times are within duration delta of each other.
//
// assert.WithinDuration(t, time.Now(), time.Now(), 10*time.Second)
func WithinDuration ( t TestingT , expected time . Time , actual time . Time , delta time . Duration , msgAndArgs ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . WithinDuration ( t , expected , actual , delta , msgAndArgs ... ) {
return
}
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// WithinDurationf asserts that the two times are within duration delta of each other.
//
// assert.WithinDurationf(t, time.Now(), time.Now(), 10*time.Second, "error message %s", "formatted")
func WithinDurationf ( t TestingT , expected time . Time , actual time . Time , delta time . Duration , msg string , args ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . WithinDurationf ( t , expected , actual , delta , msg , args ... ) {
return
}
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// Zero asserts that i is the zero value for its type.
func Zero ( t TestingT , i interface { } , msgAndArgs ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . Zero ( t , i , msgAndArgs ... ) {
return
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
}
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}
// Zerof asserts that i is the zero value for its type.
func Zerof ( t TestingT , i interface { } , msg string , args ... interface { } ) {
2019-03-27 14:15:23 +03:00
if assert . Zerof ( t , i , msg , args ... ) {
return
}
if h , ok := t . ( tHelper ) ; ok {
h . Helper ( )
2019-03-27 12:33:00 +03:00
}
2019-03-27 14:15:23 +03:00
t . FailNow ( )
2019-03-27 12:33:00 +03:00
}