2 * CODE GENERATED AUTOMATICALLY WITH github.com/stretchr/testify/_codegen
3 * THIS FILE MUST NOT BE EDITED BY HAND
14 // Condition uses a Comparison to assert a complex condition.
15 func (a *Assertions) Condition(comp Comparison, msgAndArgs ...interface{}) bool {
16 return Condition(a.t, comp, msgAndArgs...)
19 // Contains asserts that the specified string, list(array, slice...) or map contains the
20 // specified substring or element.
22 // a.Contains("Hello World", "World", "But 'Hello World' does contain 'World'")
23 // a.Contains(["Hello", "World"], "World", "But ["Hello", "World"] does contain 'World'")
24 // a.Contains({"Hello": "World"}, "Hello", "But {'Hello': 'World'} does contain 'Hello'")
26 // Returns whether the assertion was successful (true) or not (false).
27 func (a *Assertions) Contains(s interface{}, contains interface{}, msgAndArgs ...interface{}) bool {
28 return Contains(a.t, s, contains, msgAndArgs...)
31 // Empty asserts that the specified object is empty. I.e. nil, "", false, 0 or either
32 // a slice or a channel with len == 0.
36 // Returns whether the assertion was successful (true) or not (false).
37 func (a *Assertions) Empty(object interface{}, msgAndArgs ...interface{}) bool {
38 return Empty(a.t, object, msgAndArgs...)
41 // Equal asserts that two objects are equal.
43 // a.Equal(123, 123, "123 and 123 should be equal")
45 // Returns whether the assertion was successful (true) or not (false).
47 // Pointer variable equality is determined based on the equality of the
48 // referenced values (as opposed to the memory addresses).
49 func (a *Assertions) Equal(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool {
50 return Equal(a.t, expected, actual, msgAndArgs...)
53 // EqualError asserts that a function returned an error (i.e. not `nil`)
54 // and that it is equal to the provided error.
56 // actualObj, err := SomeFunction()
57 // a.EqualError(err, expectedErrorString, "An error was expected")
59 // Returns whether the assertion was successful (true) or not (false).
60 func (a *Assertions) EqualError(theError error, errString string, msgAndArgs ...interface{}) bool {
61 return EqualError(a.t, theError, errString, msgAndArgs...)
64 // EqualValues asserts that two objects are equal or convertable to the same types
67 // a.EqualValues(uint32(123), int32(123), "123 and 123 should be equal")
69 // Returns whether the assertion was successful (true) or not (false).
70 func (a *Assertions) EqualValues(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool {
71 return EqualValues(a.t, expected, actual, msgAndArgs...)
74 // Error asserts that a function returned an error (i.e. not `nil`).
76 // actualObj, err := SomeFunction()
77 // if a.Error(err, "An error was expected") {
78 // assert.Equal(t, err, expectedError)
81 // Returns whether the assertion was successful (true) or not (false).
82 func (a *Assertions) Error(err error, msgAndArgs ...interface{}) bool {
83 return Error(a.t, err, msgAndArgs...)
86 // Exactly asserts that two objects are equal is value and type.
88 // a.Exactly(int32(123), int64(123), "123 and 123 should NOT be equal")
90 // Returns whether the assertion was successful (true) or not (false).
91 func (a *Assertions) Exactly(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool {
92 return Exactly(a.t, expected, actual, msgAndArgs...)
95 // Fail reports a failure through
96 func (a *Assertions) Fail(failureMessage string, msgAndArgs ...interface{}) bool {
97 return Fail(a.t, failureMessage, msgAndArgs...)
100 // FailNow fails test
101 func (a *Assertions) FailNow(failureMessage string, msgAndArgs ...interface{}) bool {
102 return FailNow(a.t, failureMessage, msgAndArgs...)
105 // False asserts that the specified value is false.
107 // a.False(myBool, "myBool should be false")
109 // Returns whether the assertion was successful (true) or not (false).
110 func (a *Assertions) False(value bool, msgAndArgs ...interface{}) bool {
111 return False(a.t, value, msgAndArgs...)
114 // HTTPBodyContains asserts that a specified handler returns a
115 // body that contains a string.
117 // a.HTTPBodyContains(myHandler, "www.google.com", nil, "I'm Feeling Lucky")
119 // Returns whether the assertion was successful (true) or not (false).
120 func (a *Assertions) HTTPBodyContains(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}) bool {
121 return HTTPBodyContains(a.t, handler, method, url, values, str)
124 // HTTPBodyNotContains asserts that a specified handler returns a
125 // body that does not contain a string.
127 // a.HTTPBodyNotContains(myHandler, "www.google.com", nil, "I'm Feeling Lucky")
129 // Returns whether the assertion was successful (true) or not (false).
130 func (a *Assertions) HTTPBodyNotContains(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}) bool {
131 return HTTPBodyNotContains(a.t, handler, method, url, values, str)
134 // HTTPError asserts that a specified handler returns an error status code.
136 // a.HTTPError(myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}}
138 // Returns whether the assertion was successful (true) or not (false).
139 func (a *Assertions) HTTPError(handler http.HandlerFunc, method string, url string, values url.Values) bool {
140 return HTTPError(a.t, handler, method, url, values)
143 // HTTPRedirect asserts that a specified handler returns a redirect status code.
145 // a.HTTPRedirect(myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}}
147 // Returns whether the assertion was successful (true) or not (false).
148 func (a *Assertions) HTTPRedirect(handler http.HandlerFunc, method string, url string, values url.Values) bool {
149 return HTTPRedirect(a.t, handler, method, url, values)
152 // HTTPSuccess asserts that a specified handler returns a success status code.
154 // a.HTTPSuccess(myHandler, "POST", "http://www.google.com", nil)
156 // Returns whether the assertion was successful (true) or not (false).
157 func (a *Assertions) HTTPSuccess(handler http.HandlerFunc, method string, url string, values url.Values) bool {
158 return HTTPSuccess(a.t, handler, method, url, values)
161 // Implements asserts that an object is implemented by the specified interface.
163 // a.Implements((*MyInterface)(nil), new(MyObject), "MyObject")
164 func (a *Assertions) Implements(interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) bool {
165 return Implements(a.t, interfaceObject, object, msgAndArgs...)
168 // InDelta asserts that the two numerals are within delta of each other.
170 // a.InDelta(math.Pi, (22 / 7.0), 0.01)
172 // Returns whether the assertion was successful (true) or not (false).
173 func (a *Assertions) InDelta(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) bool {
174 return InDelta(a.t, expected, actual, delta, msgAndArgs...)
177 // InDeltaSlice is the same as InDelta, except it compares two slices.
178 func (a *Assertions) InDeltaSlice(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) bool {
179 return InDeltaSlice(a.t, expected, actual, delta, msgAndArgs...)
182 // InEpsilon asserts that expected and actual have a relative error less than epsilon
184 // Returns whether the assertion was successful (true) or not (false).
185 func (a *Assertions) InEpsilon(expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{}) bool {
186 return InEpsilon(a.t, expected, actual, epsilon, msgAndArgs...)
189 // InEpsilonSlice is the same as InEpsilon, except it compares each value from two slices.
190 func (a *Assertions) InEpsilonSlice(expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{}) bool {
191 return InEpsilonSlice(a.t, expected, actual, epsilon, msgAndArgs...)
194 // IsType asserts that the specified objects are of the same type.
195 func (a *Assertions) IsType(expectedType interface{}, object interface{}, msgAndArgs ...interface{}) bool {
196 return IsType(a.t, expectedType, object, msgAndArgs...)
199 // JSONEq asserts that two JSON strings are equivalent.
201 // a.JSONEq(`{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`)
203 // Returns whether the assertion was successful (true) or not (false).
204 func (a *Assertions) JSONEq(expected string, actual string, msgAndArgs ...interface{}) bool {
205 return JSONEq(a.t, expected, actual, msgAndArgs...)
208 // Len asserts that the specified object has specific length.
209 // Len also fails if the object has a type that len() not accept.
211 // a.Len(mySlice, 3, "The size of slice is not 3")
213 // Returns whether the assertion was successful (true) or not (false).
214 func (a *Assertions) Len(object interface{}, length int, msgAndArgs ...interface{}) bool {
215 return Len(a.t, object, length, msgAndArgs...)
218 // Nil asserts that the specified object is nil.
220 // a.Nil(err, "err should be nothing")
222 // Returns whether the assertion was successful (true) or not (false).
223 func (a *Assertions) Nil(object interface{}, msgAndArgs ...interface{}) bool {
224 return Nil(a.t, object, msgAndArgs...)
227 // NoError asserts that a function returned no error (i.e. `nil`).
229 // actualObj, err := SomeFunction()
230 // if a.NoError(err) {
231 // assert.Equal(t, actualObj, expectedObj)
234 // Returns whether the assertion was successful (true) or not (false).
235 func (a *Assertions) NoError(err error, msgAndArgs ...interface{}) bool {
236 return NoError(a.t, err, msgAndArgs...)
239 // NotContains asserts that the specified string, list(array, slice...) or map does NOT contain the
240 // specified substring or element.
242 // a.NotContains("Hello World", "Earth", "But 'Hello World' does NOT contain 'Earth'")
243 // a.NotContains(["Hello", "World"], "Earth", "But ['Hello', 'World'] does NOT contain 'Earth'")
244 // a.NotContains({"Hello": "World"}, "Earth", "But {'Hello': 'World'} does NOT contain 'Earth'")
246 // Returns whether the assertion was successful (true) or not (false).
247 func (a *Assertions) NotContains(s interface{}, contains interface{}, msgAndArgs ...interface{}) bool {
248 return NotContains(a.t, s, contains, msgAndArgs...)
251 // NotEmpty asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either
252 // a slice or a channel with len == 0.
254 // if a.NotEmpty(obj) {
255 // assert.Equal(t, "two", obj[1])
258 // Returns whether the assertion was successful (true) or not (false).
259 func (a *Assertions) NotEmpty(object interface{}, msgAndArgs ...interface{}) bool {
260 return NotEmpty(a.t, object, msgAndArgs...)
263 // NotEqual asserts that the specified values are NOT equal.
265 // a.NotEqual(obj1, obj2, "two objects shouldn't be equal")
267 // Returns whether the assertion was successful (true) or not (false).
269 // Pointer variable equality is determined based on the equality of the
270 // referenced values (as opposed to the memory addresses).
271 func (a *Assertions) NotEqual(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool {
272 return NotEqual(a.t, expected, actual, msgAndArgs...)
275 // NotNil asserts that the specified object is not nil.
277 // a.NotNil(err, "err should be something")
279 // Returns whether the assertion was successful (true) or not (false).
280 func (a *Assertions) NotNil(object interface{}, msgAndArgs ...interface{}) bool {
281 return NotNil(a.t, object, msgAndArgs...)
284 // NotPanics asserts that the code inside the specified PanicTestFunc does NOT panic.
286 // a.NotPanics(func(){
288 // }, "Calling RemainCalm() should NOT panic")
290 // Returns whether the assertion was successful (true) or not (false).
291 func (a *Assertions) NotPanics(f PanicTestFunc, msgAndArgs ...interface{}) bool {
292 return NotPanics(a.t, f, msgAndArgs...)
295 // NotRegexp asserts that a specified regexp does not match a string.
297 // a.NotRegexp(regexp.MustCompile("starts"), "it's starting")
298 // a.NotRegexp("^start", "it's not starting")
300 // Returns whether the assertion was successful (true) or not (false).
301 func (a *Assertions) NotRegexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) bool {
302 return NotRegexp(a.t, rx, str, msgAndArgs...)
305 // NotZero asserts that i is not the zero value for its type and returns the truth.
306 func (a *Assertions) NotZero(i interface{}, msgAndArgs ...interface{}) bool {
307 return NotZero(a.t, i, msgAndArgs...)
310 // Panics asserts that the code inside the specified PanicTestFunc panics.
314 // }, "Calling GoCrazy() should panic")
316 // Returns whether the assertion was successful (true) or not (false).
317 func (a *Assertions) Panics(f PanicTestFunc, msgAndArgs ...interface{}) bool {
318 return Panics(a.t, f, msgAndArgs...)
321 // Regexp asserts that a specified regexp matches a string.
323 // a.Regexp(regexp.MustCompile("start"), "it's starting")
324 // a.Regexp("start...$", "it's not starting")
326 // Returns whether the assertion was successful (true) or not (false).
327 func (a *Assertions) Regexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) bool {
328 return Regexp(a.t, rx, str, msgAndArgs...)
331 // True asserts that the specified value is true.
333 // a.True(myBool, "myBool should be true")
335 // Returns whether the assertion was successful (true) or not (false).
336 func (a *Assertions) True(value bool, msgAndArgs ...interface{}) bool {
337 return True(a.t, value, msgAndArgs...)
340 // WithinDuration asserts that the two times are within duration delta of each other.
342 // a.WithinDuration(time.Now(), time.Now(), 10*time.Second, "The difference should not be more than 10s")
344 // Returns whether the assertion was successful (true) or not (false).
345 func (a *Assertions) WithinDuration(expected time.Time, actual time.Time, delta time.Duration, msgAndArgs ...interface{}) bool {
346 return WithinDuration(a.t, expected, actual, delta, msgAndArgs...)
349 // Zero asserts that i is the zero value for its type and returns the truth.
350 func (a *Assertions) Zero(i interface{}, msgAndArgs ...interface{}) bool {
351 return Zero(a.t, i, msgAndArgs...)