Fix docs for forwarded assertions

pull/241/head
Ernesto Jiménez 2016-01-07 18:25:18 +01:00
parent 347825ef79
commit 5eeedba61e
5 changed files with 76 additions and 70 deletions

View File

@ -262,6 +262,12 @@ func (f *Func) Comment() string {
return "// " + strings.Replace(strings.TrimSpace(f.DocInfo.Doc), "\n", "\n// ", -1) return "// " + strings.Replace(strings.TrimSpace(f.DocInfo.Doc), "\n", "\n// ", -1)
} }
func (f *Func) CommentWithoutT(receiver string) string {
search := fmt.Sprintf("assert.%s(t, ", f.DocInfo.Name)
replace := fmt.Sprintf("%s.%s(", receiver, f.DocInfo.Name)
return strings.Replace(f.Comment(), search, replace, -1)
}
var headerTemplate = `/* var headerTemplate = `/*
* CODE GENERATED AUTOMATICALLY WITH github.com/stretchr/testify/_codegen * CODE GENERATED AUTOMATICALLY WITH github.com/stretchr/testify/_codegen
* THIS FILE MUST NOT BE EDITED BY HAND * THIS FILE MUST NOT BE EDITED BY HAND

View File

@ -22,9 +22,9 @@ func (a *Assertions) Condition(comp Comparison, msgAndArgs ...interface{}) bool
// Contains asserts that the specified string, list(array, slice...) or map contains the // Contains asserts that the specified string, list(array, slice...) or map contains the
// specified substring or element. // specified substring or element.
// //
// assert.Contains(t, "Hello World", "World", "But 'Hello World' does contain 'World'") // a.Contains("Hello World", "World", "But 'Hello World' does contain 'World'")
// assert.Contains(t, ["Hello", "World"], "World", "But ["Hello", "World"] does contain 'World'") // a.Contains(["Hello", "World"], "World", "But ["Hello", "World"] does contain 'World'")
// assert.Contains(t, {"Hello": "World"}, "Hello", "But {'Hello': 'World'} does contain 'Hello'") // a.Contains({"Hello": "World"}, "Hello", "But {'Hello': 'World'} does contain 'Hello'")
// //
// Returns whether the assertion was successful (true) or not (false). // Returns whether the assertion was successful (true) or not (false).
func (a *Assertions) Contains(s interface{}, contains interface{}, msgAndArgs ...interface{}) bool { func (a *Assertions) Contains(s interface{}, contains interface{}, msgAndArgs ...interface{}) bool {
@ -35,7 +35,7 @@ func (a *Assertions) Contains(s interface{}, contains interface{}, msgAndArgs ..
// Empty asserts that the specified object is empty. I.e. nil, "", false, 0 or either // Empty asserts that the specified object is empty. I.e. nil, "", false, 0 or either
// a slice or a channel with len == 0. // a slice or a channel with len == 0.
// //
// assert.Empty(t, obj) // a.Empty(obj)
// //
// Returns whether the assertion was successful (true) or not (false). // Returns whether the assertion was successful (true) or not (false).
func (a *Assertions) Empty(object interface{}, msgAndArgs ...interface{}) bool { func (a *Assertions) Empty(object interface{}, msgAndArgs ...interface{}) bool {
@ -45,7 +45,7 @@ func (a *Assertions) Empty(object interface{}, msgAndArgs ...interface{}) bool {
// Equal asserts that two objects are equal. // Equal asserts that two objects are equal.
// //
// assert.Equal(t, 123, 123, "123 and 123 should be equal") // a.Equal(123, 123, "123 and 123 should be equal")
// //
// Returns whether the assertion was successful (true) or not (false). // Returns whether the assertion was successful (true) or not (false).
func (a *Assertions) Equal(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool { func (a *Assertions) Equal(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool {
@ -70,7 +70,7 @@ func (a *Assertions) EqualError(theError error, errString string, msgAndArgs ...
// EqualValues asserts that two objects are equal or convertable to the same types // EqualValues asserts that two objects are equal or convertable to the same types
// and equal. // and equal.
// //
// assert.EqualValues(t, uint32(123), int32(123), "123 and 123 should be equal") // a.EqualValues(uint32(123), int32(123), "123 and 123 should be equal")
// //
// Returns whether the assertion was successful (true) or not (false). // Returns whether the assertion was successful (true) or not (false).
func (a *Assertions) EqualValues(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool { func (a *Assertions) EqualValues(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool {
@ -81,7 +81,7 @@ func (a *Assertions) EqualValues(expected interface{}, actual interface{}, msgAn
// Error asserts that a function returned an error (i.e. not `nil`). // Error asserts that a function returned an error (i.e. not `nil`).
// //
// actualObj, err := SomeFunction() // actualObj, err := SomeFunction()
// if assert.Error(t, err, "An error was expected") { // if a.Error(err, "An error was expected") {
// assert.Equal(t, err, expectedError) // assert.Equal(t, err, expectedError)
// } // }
// //
@ -93,7 +93,7 @@ func (a *Assertions) Error(err error, msgAndArgs ...interface{}) bool {
// Exactly asserts that two objects are equal is value and type. // Exactly asserts that two objects are equal is value and type.
// //
// assert.Exactly(t, int32(123), int64(123), "123 and 123 should NOT be equal") // a.Exactly(int32(123), int64(123), "123 and 123 should NOT be equal")
// //
// Returns whether the assertion was successful (true) or not (false). // Returns whether the assertion was successful (true) or not (false).
func (a *Assertions) Exactly(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool { func (a *Assertions) Exactly(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool {
@ -109,7 +109,7 @@ func (a *Assertions) Fail(failureMessage string, msgAndArgs ...interface{}) bool
// False asserts that the specified value is false. // False asserts that the specified value is false.
// //
// assert.False(t, myBool, "myBool should be false") // a.False(myBool, "myBool should be false")
// //
// Returns whether the assertion was successful (true) or not (false). // Returns whether the assertion was successful (true) or not (false).
func (a *Assertions) False(value bool, msgAndArgs ...interface{}) bool { func (a *Assertions) False(value bool, msgAndArgs ...interface{}) bool {
@ -120,7 +120,7 @@ func (a *Assertions) False(value bool, msgAndArgs ...interface{}) bool {
// HTTPBodyContains asserts that a specified handler returns a // HTTPBodyContains asserts that a specified handler returns a
// body that contains a string. // body that contains a string.
// //
// assert.HTTPBodyContains(t, myHandler, "www.google.com", nil, "I'm Feeling Lucky") // a.HTTPBodyContains(myHandler, "www.google.com", nil, "I'm Feeling Lucky")
// //
// Returns whether the assertion was successful (true) or not (false). // Returns whether the assertion was successful (true) or not (false).
func (a *Assertions) HTTPBodyContains(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}) bool { func (a *Assertions) HTTPBodyContains(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}) bool {
@ -131,7 +131,7 @@ func (a *Assertions) HTTPBodyContains(handler http.HandlerFunc, method string, u
// HTTPBodyNotContains asserts that a specified handler returns a // HTTPBodyNotContains asserts that a specified handler returns a
// body that does not contain a string. // body that does not contain a string.
// //
// assert.HTTPBodyNotContains(t, myHandler, "www.google.com", nil, "I'm Feeling Lucky") // a.HTTPBodyNotContains(myHandler, "www.google.com", nil, "I'm Feeling Lucky")
// //
// Returns whether the assertion was successful (true) or not (false). // Returns whether the assertion was successful (true) or not (false).
func (a *Assertions) HTTPBodyNotContains(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}) bool { func (a *Assertions) HTTPBodyNotContains(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}) bool {
@ -141,7 +141,7 @@ func (a *Assertions) HTTPBodyNotContains(handler http.HandlerFunc, method string
// HTTPError asserts that a specified handler returns an error status code. // 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"}} // a.HTTPError(myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}}
// //
// Returns whether the assertion was successful (true) or not (false). // Returns whether the assertion was successful (true) or not (false).
func (a *Assertions) HTTPError(handler http.HandlerFunc, method string, url string, values url.Values) bool { func (a *Assertions) HTTPError(handler http.HandlerFunc, method string, url string, values url.Values) bool {
@ -151,7 +151,7 @@ func (a *Assertions) HTTPError(handler http.HandlerFunc, method string, url stri
// HTTPRedirect asserts that a specified handler returns a redirect status code. // 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"}} // a.HTTPRedirect(myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}}
// //
// Returns whether the assertion was successful (true) or not (false). // Returns whether the assertion was successful (true) or not (false).
func (a *Assertions) HTTPRedirect(handler http.HandlerFunc, method string, url string, values url.Values) bool { func (a *Assertions) HTTPRedirect(handler http.HandlerFunc, method string, url string, values url.Values) bool {
@ -161,7 +161,7 @@ func (a *Assertions) HTTPRedirect(handler http.HandlerFunc, method string, url s
// HTTPSuccess asserts that a specified handler returns a success status code. // HTTPSuccess asserts that a specified handler returns a success status code.
// //
// assert.HTTPSuccess(t, myHandler, "POST", "http://www.google.com", nil) // a.HTTPSuccess(myHandler, "POST", "http://www.google.com", nil)
// //
// Returns whether the assertion was successful (true) or not (false). // Returns whether the assertion was successful (true) or not (false).
func (a *Assertions) HTTPSuccess(handler http.HandlerFunc, method string, url string, values url.Values) bool { func (a *Assertions) HTTPSuccess(handler http.HandlerFunc, method string, url string, values url.Values) bool {
@ -171,7 +171,7 @@ func (a *Assertions) HTTPSuccess(handler http.HandlerFunc, method string, url st
// Implements asserts that an object is implemented by the specified interface. // Implements asserts that an object is implemented by the specified interface.
// //
// assert.Implements(t, (*MyInterface)(nil), new(MyObject), "MyObject") // a.Implements((*MyInterface)(nil), new(MyObject), "MyObject")
func (a *Assertions) Implements(interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) bool { func (a *Assertions) Implements(interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) bool {
return Implements(a.t, interfaceObject, object, msgAndArgs...) return Implements(a.t, interfaceObject, object, msgAndArgs...)
} }
@ -179,7 +179,7 @@ func (a *Assertions) Implements(interfaceObject interface{}, object interface{},
// InDelta asserts that the two numerals are within delta of each other. // InDelta asserts that the two numerals are within delta of each other.
// //
// assert.InDelta(t, math.Pi, (22 / 7.0), 0.01) // a.InDelta(math.Pi, (22 / 7.0), 0.01)
// //
// Returns whether the assertion was successful (true) or not (false). // Returns whether the assertion was successful (true) or not (false).
func (a *Assertions) InDelta(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) bool { func (a *Assertions) InDelta(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) bool {
@ -215,7 +215,7 @@ func (a *Assertions) IsType(expectedType interface{}, object interface{}, msgAnd
// JSONEq asserts that two JSON strings are equivalent. // JSONEq asserts that two JSON strings are equivalent.
// //
// assert.JSONEq(t, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`) // a.JSONEq(`{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`)
// //
// Returns whether the assertion was successful (true) or not (false). // Returns whether the assertion was successful (true) or not (false).
func (a *Assertions) JSONEq(expected string, actual string, msgAndArgs ...interface{}) bool { func (a *Assertions) JSONEq(expected string, actual string, msgAndArgs ...interface{}) bool {
@ -226,7 +226,7 @@ func (a *Assertions) JSONEq(expected string, actual string, msgAndArgs ...interf
// Len asserts that the specified object has specific length. // Len asserts that the specified object has specific length.
// Len also fails if the object has a type that len() not accept. // Len also fails if the object has a type that len() not accept.
// //
// assert.Len(t, mySlice, 3, "The size of slice is not 3") // a.Len(mySlice, 3, "The size of slice is not 3")
// //
// Returns whether the assertion was successful (true) or not (false). // Returns whether the assertion was successful (true) or not (false).
func (a *Assertions) Len(object interface{}, length int, msgAndArgs ...interface{}) bool { func (a *Assertions) Len(object interface{}, length int, msgAndArgs ...interface{}) bool {
@ -236,7 +236,7 @@ func (a *Assertions) Len(object interface{}, length int, msgAndArgs ...interface
// Nil asserts that the specified object is nil. // Nil asserts that the specified object is nil.
// //
// assert.Nil(t, err, "err should be nothing") // a.Nil(err, "err should be nothing")
// //
// Returns whether the assertion was successful (true) or not (false). // Returns whether the assertion was successful (true) or not (false).
func (a *Assertions) Nil(object interface{}, msgAndArgs ...interface{}) bool { func (a *Assertions) Nil(object interface{}, msgAndArgs ...interface{}) bool {
@ -247,7 +247,7 @@ func (a *Assertions) Nil(object interface{}, msgAndArgs ...interface{}) bool {
// NoError asserts that a function returned no error (i.e. `nil`). // NoError asserts that a function returned no error (i.e. `nil`).
// //
// actualObj, err := SomeFunction() // actualObj, err := SomeFunction()
// if assert.NoError(t, err) { // if a.NoError(err) {
// assert.Equal(t, actualObj, expectedObj) // assert.Equal(t, actualObj, expectedObj)
// } // }
// //
@ -260,9 +260,9 @@ func (a *Assertions) NoError(err error, msgAndArgs ...interface{}) bool {
// NotContains asserts that the specified string, list(array, slice...) or map does NOT contain the // NotContains asserts that the specified string, list(array, slice...) or map does NOT contain the
// specified substring or element. // specified substring or element.
// //
// assert.NotContains(t, "Hello World", "Earth", "But 'Hello World' does NOT contain 'Earth'") // a.NotContains("Hello World", "Earth", "But 'Hello World' does NOT contain 'Earth'")
// assert.NotContains(t, ["Hello", "World"], "Earth", "But ['Hello', 'World'] does NOT contain 'Earth'") // a.NotContains(["Hello", "World"], "Earth", "But ['Hello', 'World'] does NOT contain 'Earth'")
// assert.NotContains(t, {"Hello": "World"}, "Earth", "But {'Hello': 'World'} does NOT contain 'Earth'") // a.NotContains({"Hello": "World"}, "Earth", "But {'Hello': 'World'} does NOT contain 'Earth'")
// //
// Returns whether the assertion was successful (true) or not (false). // Returns whether the assertion was successful (true) or not (false).
func (a *Assertions) NotContains(s interface{}, contains interface{}, msgAndArgs ...interface{}) bool { func (a *Assertions) NotContains(s interface{}, contains interface{}, msgAndArgs ...interface{}) bool {
@ -273,7 +273,7 @@ func (a *Assertions) NotContains(s interface{}, contains interface{}, msgAndArgs
// NotEmpty asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either // 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. // a slice or a channel with len == 0.
// //
// if assert.NotEmpty(t, obj) { // if a.NotEmpty(obj) {
// assert.Equal(t, "two", obj[1]) // assert.Equal(t, "two", obj[1])
// } // }
// //
@ -285,7 +285,7 @@ func (a *Assertions) NotEmpty(object interface{}, msgAndArgs ...interface{}) boo
// NotEqual asserts that the specified values are NOT equal. // NotEqual asserts that the specified values are NOT equal.
// //
// assert.NotEqual(t, obj1, obj2, "two objects shouldn't be equal") // a.NotEqual(obj1, obj2, "two objects shouldn't be equal")
// //
// Returns whether the assertion was successful (true) or not (false). // Returns whether the assertion was successful (true) or not (false).
func (a *Assertions) NotEqual(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool { func (a *Assertions) NotEqual(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool {
@ -295,7 +295,7 @@ func (a *Assertions) NotEqual(expected interface{}, actual interface{}, msgAndAr
// NotNil asserts that the specified object is not nil. // NotNil asserts that the specified object is not nil.
// //
// assert.NotNil(t, err, "err should be something") // a.NotNil(err, "err should be something")
// //
// Returns whether the assertion was successful (true) or not (false). // Returns whether the assertion was successful (true) or not (false).
func (a *Assertions) NotNil(object interface{}, msgAndArgs ...interface{}) bool { func (a *Assertions) NotNil(object interface{}, msgAndArgs ...interface{}) bool {
@ -305,7 +305,7 @@ func (a *Assertions) NotNil(object interface{}, msgAndArgs ...interface{}) bool
// NotPanics asserts that the code inside the specified PanicTestFunc does NOT panic. // NotPanics asserts that the code inside the specified PanicTestFunc does NOT panic.
// //
// assert.NotPanics(t, func(){ // a.NotPanics(func(){
// RemainCalm() // RemainCalm()
// }, "Calling RemainCalm() should NOT panic") // }, "Calling RemainCalm() should NOT panic")
// //
@ -317,8 +317,8 @@ func (a *Assertions) NotPanics(f PanicTestFunc, msgAndArgs ...interface{}) bool
// NotRegexp asserts that a specified regexp does not match a string. // NotRegexp asserts that a specified regexp does not match a string.
// //
// assert.NotRegexp(t, regexp.MustCompile("starts"), "it's starting") // a.NotRegexp(regexp.MustCompile("starts"), "it's starting")
// assert.NotRegexp(t, "^start", "it's not starting") // a.NotRegexp("^start", "it's not starting")
// //
// Returns whether the assertion was successful (true) or not (false). // Returns whether the assertion was successful (true) or not (false).
func (a *Assertions) NotRegexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) bool { func (a *Assertions) NotRegexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) bool {
@ -334,7 +334,7 @@ func (a *Assertions) NotZero(i interface{}, msgAndArgs ...interface{}) bool {
// Panics asserts that the code inside the specified PanicTestFunc panics. // Panics asserts that the code inside the specified PanicTestFunc panics.
// //
// assert.Panics(t, func(){ // a.Panics(func(){
// GoCrazy() // GoCrazy()
// }, "Calling GoCrazy() should panic") // }, "Calling GoCrazy() should panic")
// //
@ -346,8 +346,8 @@ func (a *Assertions) Panics(f PanicTestFunc, msgAndArgs ...interface{}) bool {
// Regexp asserts that a specified regexp matches a string. // Regexp asserts that a specified regexp matches a string.
// //
// assert.Regexp(t, regexp.MustCompile("start"), "it's starting") // a.Regexp(regexp.MustCompile("start"), "it's starting")
// assert.Regexp(t, "start...$", "it's not starting") // a.Regexp("start...$", "it's not starting")
// //
// Returns whether the assertion was successful (true) or not (false). // Returns whether the assertion was successful (true) or not (false).
func (a *Assertions) Regexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) bool { func (a *Assertions) Regexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) bool {
@ -357,7 +357,7 @@ func (a *Assertions) Regexp(rx interface{}, str interface{}, msgAndArgs ...inter
// True asserts that the specified value is true. // True asserts that the specified value is true.
// //
// assert.True(t, myBool, "myBool should be true") // a.True(myBool, "myBool should be true")
// //
// Returns whether the assertion was successful (true) or not (false). // Returns whether the assertion was successful (true) or not (false).
func (a *Assertions) True(value bool, msgAndArgs ...interface{}) bool { func (a *Assertions) True(value bool, msgAndArgs ...interface{}) bool {
@ -367,7 +367,7 @@ func (a *Assertions) True(value bool, msgAndArgs ...interface{}) bool {
// WithinDuration asserts that the two times are within duration delta of each other. // WithinDuration asserts that the two times are within duration delta of each other.
// //
// assert.WithinDuration(t, time.Now(), time.Now(), 10*time.Second, "The difference should not be more than 10s") // a.WithinDuration(time.Now(), time.Now(), 10*time.Second, "The difference should not be more than 10s")
// //
// Returns whether the assertion was successful (true) or not (false). // Returns whether the assertion was successful (true) or not (false).
func (a *Assertions) WithinDuration(expected time.Time, actual time.Time, delta time.Duration, msgAndArgs ...interface{}) bool { func (a *Assertions) WithinDuration(expected time.Time, actual time.Time, delta time.Duration, msgAndArgs ...interface{}) bool {

View File

@ -1,4 +1,4 @@
{{.Comment}} {{.CommentWithoutT "a"}}
func (a *Assertions) {{.DocInfo.Name}}({{.Params}}) bool { func (a *Assertions) {{.DocInfo.Name}}({{.Params}}) bool {
return {{.DocInfo.Name}}(a.t, {{.ForwardedParams}}) return {{.DocInfo.Name}}(a.t, {{.ForwardedParams}})
} }

View File

@ -23,9 +23,9 @@ func (a *Assertions) Condition(comp assert.Comparison, msgAndArgs ...interface{}
// Contains asserts that the specified string, list(array, slice...) or map contains the // Contains asserts that the specified string, list(array, slice...) or map contains the
// specified substring or element. // specified substring or element.
// //
// assert.Contains(t, "Hello World", "World", "But 'Hello World' does contain 'World'") // a.Contains("Hello World", "World", "But 'Hello World' does contain 'World'")
// assert.Contains(t, ["Hello", "World"], "World", "But ["Hello", "World"] does contain 'World'") // a.Contains(["Hello", "World"], "World", "But ["Hello", "World"] does contain 'World'")
// assert.Contains(t, {"Hello": "World"}, "Hello", "But {'Hello': 'World'} does contain 'Hello'") // a.Contains({"Hello": "World"}, "Hello", "But {'Hello': 'World'} does contain 'Hello'")
// //
// Returns whether the assertion was successful (true) or not (false). // Returns whether the assertion was successful (true) or not (false).
func (a *Assertions) Contains(s interface{}, contains interface{}, msgAndArgs ...interface{}) { func (a *Assertions) Contains(s interface{}, contains interface{}, msgAndArgs ...interface{}) {
@ -36,7 +36,7 @@ func (a *Assertions) Contains(s interface{}, contains interface{}, msgAndArgs ..
// Empty asserts that the specified object is empty. I.e. nil, "", false, 0 or either // Empty asserts that the specified object is empty. I.e. nil, "", false, 0 or either
// a slice or a channel with len == 0. // a slice or a channel with len == 0.
// //
// assert.Empty(t, obj) // a.Empty(obj)
// //
// Returns whether the assertion was successful (true) or not (false). // Returns whether the assertion was successful (true) or not (false).
func (a *Assertions) Empty(object interface{}, msgAndArgs ...interface{}) { func (a *Assertions) Empty(object interface{}, msgAndArgs ...interface{}) {
@ -46,7 +46,7 @@ func (a *Assertions) Empty(object interface{}, msgAndArgs ...interface{}) {
// Equal asserts that two objects are equal. // Equal asserts that two objects are equal.
// //
// assert.Equal(t, 123, 123, "123 and 123 should be equal") // a.Equal(123, 123, "123 and 123 should be equal")
// //
// Returns whether the assertion was successful (true) or not (false). // Returns whether the assertion was successful (true) or not (false).
func (a *Assertions) Equal(expected interface{}, actual interface{}, msgAndArgs ...interface{}) { func (a *Assertions) Equal(expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
@ -71,7 +71,7 @@ func (a *Assertions) EqualError(theError error, errString string, msgAndArgs ...
// EqualValues asserts that two objects are equal or convertable to the same types // EqualValues asserts that two objects are equal or convertable to the same types
// and equal. // and equal.
// //
// assert.EqualValues(t, uint32(123), int32(123), "123 and 123 should be equal") // a.EqualValues(uint32(123), int32(123), "123 and 123 should be equal")
// //
// Returns whether the assertion was successful (true) or not (false). // Returns whether the assertion was successful (true) or not (false).
func (a *Assertions) EqualValues(expected interface{}, actual interface{}, msgAndArgs ...interface{}) { func (a *Assertions) EqualValues(expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
@ -82,7 +82,7 @@ func (a *Assertions) EqualValues(expected interface{}, actual interface{}, msgAn
// Error asserts that a function returned an error (i.e. not `nil`). // Error asserts that a function returned an error (i.e. not `nil`).
// //
// actualObj, err := SomeFunction() // actualObj, err := SomeFunction()
// if assert.Error(t, err, "An error was expected") { // if a.Error(err, "An error was expected") {
// assert.Equal(t, err, expectedError) // assert.Equal(t, err, expectedError)
// } // }
// //
@ -94,7 +94,7 @@ func (a *Assertions) Error(err error, msgAndArgs ...interface{}) {
// Exactly asserts that two objects are equal is value and type. // Exactly asserts that two objects are equal is value and type.
// //
// assert.Exactly(t, int32(123), int64(123), "123 and 123 should NOT be equal") // a.Exactly(int32(123), int64(123), "123 and 123 should NOT be equal")
// //
// Returns whether the assertion was successful (true) or not (false). // Returns whether the assertion was successful (true) or not (false).
func (a *Assertions) Exactly(expected interface{}, actual interface{}, msgAndArgs ...interface{}) { func (a *Assertions) Exactly(expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
@ -110,7 +110,7 @@ func (a *Assertions) Fail(failureMessage string, msgAndArgs ...interface{}) {
// False asserts that the specified value is false. // False asserts that the specified value is false.
// //
// assert.False(t, myBool, "myBool should be false") // a.False(myBool, "myBool should be false")
// //
// Returns whether the assertion was successful (true) or not (false). // Returns whether the assertion was successful (true) or not (false).
func (a *Assertions) False(value bool, msgAndArgs ...interface{}) { func (a *Assertions) False(value bool, msgAndArgs ...interface{}) {
@ -121,7 +121,7 @@ func (a *Assertions) False(value bool, msgAndArgs ...interface{}) {
// HTTPBodyContains asserts that a specified handler returns a // HTTPBodyContains asserts that a specified handler returns a
// body that contains a string. // body that contains a string.
// //
// assert.HTTPBodyContains(t, myHandler, "www.google.com", nil, "I'm Feeling Lucky") // a.HTTPBodyContains(myHandler, "www.google.com", nil, "I'm Feeling Lucky")
// //
// Returns whether the assertion was successful (true) or not (false). // Returns whether the assertion was successful (true) or not (false).
func (a *Assertions) HTTPBodyContains(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}) { func (a *Assertions) HTTPBodyContains(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}) {
@ -132,7 +132,7 @@ func (a *Assertions) HTTPBodyContains(handler http.HandlerFunc, method string, u
// HTTPBodyNotContains asserts that a specified handler returns a // HTTPBodyNotContains asserts that a specified handler returns a
// body that does not contain a string. // body that does not contain a string.
// //
// assert.HTTPBodyNotContains(t, myHandler, "www.google.com", nil, "I'm Feeling Lucky") // a.HTTPBodyNotContains(myHandler, "www.google.com", nil, "I'm Feeling Lucky")
// //
// Returns whether the assertion was successful (true) or not (false). // Returns whether the assertion was successful (true) or not (false).
func (a *Assertions) HTTPBodyNotContains(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}) { func (a *Assertions) HTTPBodyNotContains(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}) {
@ -142,7 +142,7 @@ func (a *Assertions) HTTPBodyNotContains(handler http.HandlerFunc, method string
// HTTPError asserts that a specified handler returns an error status code. // 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"}} // a.HTTPError(myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}}
// //
// Returns whether the assertion was successful (true) or not (false). // Returns whether the assertion was successful (true) or not (false).
func (a *Assertions) HTTPError(handler http.HandlerFunc, method string, url string, values url.Values) { func (a *Assertions) HTTPError(handler http.HandlerFunc, method string, url string, values url.Values) {
@ -152,7 +152,7 @@ func (a *Assertions) HTTPError(handler http.HandlerFunc, method string, url stri
// HTTPRedirect asserts that a specified handler returns a redirect status code. // 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"}} // a.HTTPRedirect(myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}}
// //
// Returns whether the assertion was successful (true) or not (false). // Returns whether the assertion was successful (true) or not (false).
func (a *Assertions) HTTPRedirect(handler http.HandlerFunc, method string, url string, values url.Values) { func (a *Assertions) HTTPRedirect(handler http.HandlerFunc, method string, url string, values url.Values) {
@ -162,7 +162,7 @@ func (a *Assertions) HTTPRedirect(handler http.HandlerFunc, method string, url s
// HTTPSuccess asserts that a specified handler returns a success status code. // HTTPSuccess asserts that a specified handler returns a success status code.
// //
// assert.HTTPSuccess(t, myHandler, "POST", "http://www.google.com", nil) // a.HTTPSuccess(myHandler, "POST", "http://www.google.com", nil)
// //
// Returns whether the assertion was successful (true) or not (false). // Returns whether the assertion was successful (true) or not (false).
func (a *Assertions) HTTPSuccess(handler http.HandlerFunc, method string, url string, values url.Values) { func (a *Assertions) HTTPSuccess(handler http.HandlerFunc, method string, url string, values url.Values) {
@ -172,7 +172,7 @@ func (a *Assertions) HTTPSuccess(handler http.HandlerFunc, method string, url st
// Implements asserts that an object is implemented by the specified interface. // Implements asserts that an object is implemented by the specified interface.
// //
// assert.Implements(t, (*MyInterface)(nil), new(MyObject), "MyObject") // a.Implements((*MyInterface)(nil), new(MyObject), "MyObject")
func (a *Assertions) Implements(interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) { func (a *Assertions) Implements(interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) {
Implements(a.t, interfaceObject, object, msgAndArgs...) Implements(a.t, interfaceObject, object, msgAndArgs...)
} }
@ -180,7 +180,7 @@ func (a *Assertions) Implements(interfaceObject interface{}, object interface{},
// InDelta asserts that the two numerals are within delta of each other. // InDelta asserts that the two numerals are within delta of each other.
// //
// assert.InDelta(t, math.Pi, (22 / 7.0), 0.01) // a.InDelta(math.Pi, (22 / 7.0), 0.01)
// //
// Returns whether the assertion was successful (true) or not (false). // Returns whether the assertion was successful (true) or not (false).
func (a *Assertions) InDelta(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) { func (a *Assertions) InDelta(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) {
@ -216,7 +216,7 @@ func (a *Assertions) IsType(expectedType interface{}, object interface{}, msgAnd
// JSONEq asserts that two JSON strings are equivalent. // JSONEq asserts that two JSON strings are equivalent.
// //
// assert.JSONEq(t, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`) // a.JSONEq(`{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`)
// //
// Returns whether the assertion was successful (true) or not (false). // Returns whether the assertion was successful (true) or not (false).
func (a *Assertions) JSONEq(expected string, actual string, msgAndArgs ...interface{}) { func (a *Assertions) JSONEq(expected string, actual string, msgAndArgs ...interface{}) {
@ -227,7 +227,7 @@ func (a *Assertions) JSONEq(expected string, actual string, msgAndArgs ...interf
// Len asserts that the specified object has specific length. // Len asserts that the specified object has specific length.
// Len also fails if the object has a type that len() not accept. // Len also fails if the object has a type that len() not accept.
// //
// assert.Len(t, mySlice, 3, "The size of slice is not 3") // a.Len(mySlice, 3, "The size of slice is not 3")
// //
// Returns whether the assertion was successful (true) or not (false). // Returns whether the assertion was successful (true) or not (false).
func (a *Assertions) Len(object interface{}, length int, msgAndArgs ...interface{}) { func (a *Assertions) Len(object interface{}, length int, msgAndArgs ...interface{}) {
@ -237,7 +237,7 @@ func (a *Assertions) Len(object interface{}, length int, msgAndArgs ...interface
// Nil asserts that the specified object is nil. // Nil asserts that the specified object is nil.
// //
// assert.Nil(t, err, "err should be nothing") // a.Nil(err, "err should be nothing")
// //
// Returns whether the assertion was successful (true) or not (false). // Returns whether the assertion was successful (true) or not (false).
func (a *Assertions) Nil(object interface{}, msgAndArgs ...interface{}) { func (a *Assertions) Nil(object interface{}, msgAndArgs ...interface{}) {
@ -248,7 +248,7 @@ func (a *Assertions) Nil(object interface{}, msgAndArgs ...interface{}) {
// NoError asserts that a function returned no error (i.e. `nil`). // NoError asserts that a function returned no error (i.e. `nil`).
// //
// actualObj, err := SomeFunction() // actualObj, err := SomeFunction()
// if assert.NoError(t, err) { // if a.NoError(err) {
// assert.Equal(t, actualObj, expectedObj) // assert.Equal(t, actualObj, expectedObj)
// } // }
// //
@ -261,9 +261,9 @@ func (a *Assertions) NoError(err error, msgAndArgs ...interface{}) {
// NotContains asserts that the specified string, list(array, slice...) or map does NOT contain the // NotContains asserts that the specified string, list(array, slice...) or map does NOT contain the
// specified substring or element. // specified substring or element.
// //
// assert.NotContains(t, "Hello World", "Earth", "But 'Hello World' does NOT contain 'Earth'") // a.NotContains("Hello World", "Earth", "But 'Hello World' does NOT contain 'Earth'")
// assert.NotContains(t, ["Hello", "World"], "Earth", "But ['Hello', 'World'] does NOT contain 'Earth'") // a.NotContains(["Hello", "World"], "Earth", "But ['Hello', 'World'] does NOT contain 'Earth'")
// assert.NotContains(t, {"Hello": "World"}, "Earth", "But {'Hello': 'World'} does NOT contain 'Earth'") // a.NotContains({"Hello": "World"}, "Earth", "But {'Hello': 'World'} does NOT contain 'Earth'")
// //
// Returns whether the assertion was successful (true) or not (false). // Returns whether the assertion was successful (true) or not (false).
func (a *Assertions) NotContains(s interface{}, contains interface{}, msgAndArgs ...interface{}) { func (a *Assertions) NotContains(s interface{}, contains interface{}, msgAndArgs ...interface{}) {
@ -274,7 +274,7 @@ func (a *Assertions) NotContains(s interface{}, contains interface{}, msgAndArgs
// NotEmpty asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either // 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. // a slice or a channel with len == 0.
// //
// if assert.NotEmpty(t, obj) { // if a.NotEmpty(obj) {
// assert.Equal(t, "two", obj[1]) // assert.Equal(t, "two", obj[1])
// } // }
// //
@ -286,7 +286,7 @@ func (a *Assertions) NotEmpty(object interface{}, msgAndArgs ...interface{}) {
// NotEqual asserts that the specified values are NOT equal. // NotEqual asserts that the specified values are NOT equal.
// //
// assert.NotEqual(t, obj1, obj2, "two objects shouldn't be equal") // a.NotEqual(obj1, obj2, "two objects shouldn't be equal")
// //
// Returns whether the assertion was successful (true) or not (false). // Returns whether the assertion was successful (true) or not (false).
func (a *Assertions) NotEqual(expected interface{}, actual interface{}, msgAndArgs ...interface{}) { func (a *Assertions) NotEqual(expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
@ -296,7 +296,7 @@ func (a *Assertions) NotEqual(expected interface{}, actual interface{}, msgAndAr
// NotNil asserts that the specified object is not nil. // NotNil asserts that the specified object is not nil.
// //
// assert.NotNil(t, err, "err should be something") // a.NotNil(err, "err should be something")
// //
// Returns whether the assertion was successful (true) or not (false). // Returns whether the assertion was successful (true) or not (false).
func (a *Assertions) NotNil(object interface{}, msgAndArgs ...interface{}) { func (a *Assertions) NotNil(object interface{}, msgAndArgs ...interface{}) {
@ -306,7 +306,7 @@ func (a *Assertions) NotNil(object interface{}, msgAndArgs ...interface{}) {
// NotPanics asserts that the code inside the specified PanicTestFunc does NOT panic. // NotPanics asserts that the code inside the specified PanicTestFunc does NOT panic.
// //
// assert.NotPanics(t, func(){ // a.NotPanics(func(){
// RemainCalm() // RemainCalm()
// }, "Calling RemainCalm() should NOT panic") // }, "Calling RemainCalm() should NOT panic")
// //
@ -318,8 +318,8 @@ func (a *Assertions) NotPanics(f assert.PanicTestFunc, msgAndArgs ...interface{}
// NotRegexp asserts that a specified regexp does not match a string. // NotRegexp asserts that a specified regexp does not match a string.
// //
// assert.NotRegexp(t, regexp.MustCompile("starts"), "it's starting") // a.NotRegexp(regexp.MustCompile("starts"), "it's starting")
// assert.NotRegexp(t, "^start", "it's not starting") // a.NotRegexp("^start", "it's not starting")
// //
// Returns whether the assertion was successful (true) or not (false). // Returns whether the assertion was successful (true) or not (false).
func (a *Assertions) NotRegexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) { func (a *Assertions) NotRegexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) {
@ -335,7 +335,7 @@ func (a *Assertions) NotZero(i interface{}, msgAndArgs ...interface{}) {
// Panics asserts that the code inside the specified PanicTestFunc panics. // Panics asserts that the code inside the specified PanicTestFunc panics.
// //
// assert.Panics(t, func(){ // a.Panics(func(){
// GoCrazy() // GoCrazy()
// }, "Calling GoCrazy() should panic") // }, "Calling GoCrazy() should panic")
// //
@ -347,8 +347,8 @@ func (a *Assertions) Panics(f assert.PanicTestFunc, msgAndArgs ...interface{}) {
// Regexp asserts that a specified regexp matches a string. // Regexp asserts that a specified regexp matches a string.
// //
// assert.Regexp(t, regexp.MustCompile("start"), "it's starting") // a.Regexp(regexp.MustCompile("start"), "it's starting")
// assert.Regexp(t, "start...$", "it's not starting") // a.Regexp("start...$", "it's not starting")
// //
// Returns whether the assertion was successful (true) or not (false). // Returns whether the assertion was successful (true) or not (false).
func (a *Assertions) Regexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) { func (a *Assertions) Regexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) {
@ -358,7 +358,7 @@ func (a *Assertions) Regexp(rx interface{}, str interface{}, msgAndArgs ...inter
// True asserts that the specified value is true. // True asserts that the specified value is true.
// //
// assert.True(t, myBool, "myBool should be true") // a.True(myBool, "myBool should be true")
// //
// Returns whether the assertion was successful (true) or not (false). // Returns whether the assertion was successful (true) or not (false).
func (a *Assertions) True(value bool, msgAndArgs ...interface{}) { func (a *Assertions) True(value bool, msgAndArgs ...interface{}) {
@ -368,7 +368,7 @@ func (a *Assertions) True(value bool, msgAndArgs ...interface{}) {
// WithinDuration asserts that the two times are within duration delta of each other. // WithinDuration asserts that the two times are within duration delta of each other.
// //
// assert.WithinDuration(t, time.Now(), time.Now(), 10*time.Second, "The difference should not be more than 10s") // a.WithinDuration(time.Now(), time.Now(), 10*time.Second, "The difference should not be more than 10s")
// //
// Returns whether the assertion was successful (true) or not (false). // Returns whether the assertion was successful (true) or not (false).
func (a *Assertions) WithinDuration(expected time.Time, actual time.Time, delta time.Duration, msgAndArgs ...interface{}) { func (a *Assertions) WithinDuration(expected time.Time, actual time.Time, delta time.Duration, msgAndArgs ...interface{}) {

View File

@ -1,4 +1,4 @@
{{.Comment}} {{.CommentWithoutT "a"}}
func (a *Assertions) {{.DocInfo.Name}}({{.Params}}) { func (a *Assertions) {{.DocInfo.Name}}({{.Params}}) {
{{.DocInfo.Name}}(a.t, {{.ForwardedParams}}) {{.DocInfo.Name}}(a.t, {{.ForwardedParams}})
} }