2 * CODE GENERATED AUTOMATICALLY WITH github.com/stretchr/testify/_codegen
3 * THIS FILE MUST NOT BE EDITED BY HAND
14 // Conditionf uses a Comparison to assert a complex condition.
15 func Conditionf(t TestingT, comp Comparison, msg string, args ...interface{}) bool {
16 return Condition(t, comp, append([]interface{}{msg}, args...)...)
19 // Containsf asserts that the specified string, list(array, slice...) or map contains the
20 // specified substring or element.
22 // assert.Containsf(t, "Hello World", "World", "error message %s", "formatted")
23 // assert.Containsf(t, ["Hello", "World"], "World", "error message %s", "formatted")
24 // assert.Containsf(t, {"Hello": "World"}, "Hello", "error message %s", "formatted")
26 // Returns whether the assertion was successful (true) or not (false).
27 func Containsf(t TestingT, s interface{}, contains interface{}, msg string, args ...interface{}) bool {
28 return Contains(t, s, contains, append([]interface{}{msg}, args...)...)
31 // Emptyf asserts that the specified object is empty. I.e. nil, "", false, 0 or either
32 // a slice or a channel with len == 0.
34 // assert.Emptyf(t, obj, "error message %s", "formatted")
36 // Returns whether the assertion was successful (true) or not (false).
37 func Emptyf(t TestingT, object interface{}, msg string, args ...interface{}) bool {
38 return Empty(t, object, append([]interface{}{msg}, args...)...)
41 // Equalf asserts that two objects are equal.
43 // assert.Equalf(t, 123, 123, "error message %s", "formatted")
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). Function equality
49 // cannot be determined and will always fail.
50 func Equalf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
51 return Equal(t, expected, actual, append([]interface{}{msg}, args...)...)
54 // EqualErrorf asserts that a function returned an error (i.e. not `nil`)
55 // and that it is equal to the provided error.
57 // actualObj, err := SomeFunction()
58 // assert.EqualErrorf(t, err, expectedErrorString, "error message %s", "formatted")
60 // Returns whether the assertion was successful (true) or not (false).
61 func EqualErrorf(t TestingT, theError error, errString string, msg string, args ...interface{}) bool {
62 return EqualError(t, theError, errString, append([]interface{}{msg}, args...)...)
65 // EqualValuesf asserts that two objects are equal or convertable to the same types
68 // assert.EqualValuesf(t, uint32(123, "error message %s", "formatted"), int32(123))
70 // Returns whether the assertion was successful (true) or not (false).
71 func EqualValuesf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
72 return EqualValues(t, expected, actual, append([]interface{}{msg}, args...)...)
75 // Errorf asserts that a function returned an error (i.e. not `nil`).
77 // actualObj, err := SomeFunction()
78 // if assert.Errorf(t, err, "error message %s", "formatted") {
79 // assert.Equal(t, expectedErrorf, err)
82 // Returns whether the assertion was successful (true) or not (false).
83 func Errorf(t TestingT, err error, msg string, args ...interface{}) bool {
84 return Error(t, err, append([]interface{}{msg}, args...)...)
87 // Exactlyf asserts that two objects are equal is value and type.
89 // assert.Exactlyf(t, int32(123, "error message %s", "formatted"), int64(123))
91 // Returns whether the assertion was successful (true) or not (false).
92 func Exactlyf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
93 return Exactly(t, expected, actual, append([]interface{}{msg}, args...)...)
96 // Failf reports a failure through
97 func Failf(t TestingT, failureMessage string, msg string, args ...interface{}) bool {
98 return Fail(t, failureMessage, append([]interface{}{msg}, args...)...)
101 // FailNowf fails test
102 func FailNowf(t TestingT, failureMessage string, msg string, args ...interface{}) bool {
103 return FailNow(t, failureMessage, append([]interface{}{msg}, args...)...)
106 // Falsef asserts that the specified value is false.
108 // assert.Falsef(t, myBool, "error message %s", "formatted")
110 // Returns whether the assertion was successful (true) or not (false).
111 func Falsef(t TestingT, value bool, msg string, args ...interface{}) bool {
112 return False(t, value, append([]interface{}{msg}, args...)...)
115 // HTTPBodyContainsf asserts that a specified handler returns a
116 // body that contains a string.
118 // assert.HTTPBodyContainsf(t, myHandler, "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted")
120 // Returns whether the assertion was successful (true) or not (false).
121 func HTTPBodyContainsf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}) bool {
122 return HTTPBodyContains(t, handler, method, url, values, str)
125 // HTTPBodyNotContainsf asserts that a specified handler returns a
126 // body that does not contain a string.
128 // assert.HTTPBodyNotContainsf(t, myHandler, "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted")
130 // Returns whether the assertion was successful (true) or not (false).
131 func HTTPBodyNotContainsf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}) bool {
132 return HTTPBodyNotContains(t, handler, method, url, values, str)
135 // HTTPErrorf asserts that a specified handler returns an error status code.
137 // assert.HTTPErrorf(t, myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}}
139 // Returns whether the assertion was successful (true, "error message %s", "formatted") or not (false).
140 func HTTPErrorf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values) bool {
141 return HTTPError(t, handler, method, url, values)
144 // HTTPRedirectf asserts that a specified handler returns a redirect status code.
146 // assert.HTTPRedirectf(t, myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}}
148 // Returns whether the assertion was successful (true, "error message %s", "formatted") or not (false).
149 func HTTPRedirectf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values) bool {
150 return HTTPRedirect(t, handler, method, url, values)
153 // HTTPSuccessf asserts that a specified handler returns a success status code.
155 // assert.HTTPSuccessf(t, myHandler, "POST", "http://www.google.com", nil, "error message %s", "formatted")
157 // Returns whether the assertion was successful (true) or not (false).
158 func HTTPSuccessf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values) bool {
159 return HTTPSuccess(t, handler, method, url, values)
162 // Implementsf asserts that an object is implemented by the specified interface.
164 // assert.Implementsf(t, (*MyInterface, "error message %s", "formatted")(nil), new(MyObject))
165 func Implementsf(t TestingT, interfaceObject interface{}, object interface{}, msg string, args ...interface{}) bool {
166 return Implements(t, interfaceObject, object, append([]interface{}{msg}, args...)...)
169 // InDeltaf asserts that the two numerals are within delta of each other.
171 // assert.InDeltaf(t, math.Pi, (22 / 7.0, "error message %s", "formatted"), 0.01)
173 // Returns whether the assertion was successful (true) or not (false).
174 func InDeltaf(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool {
175 return InDelta(t, expected, actual, delta, append([]interface{}{msg}, args...)...)
178 // InDeltaSlicef is the same as InDelta, except it compares two slices.
179 func InDeltaSlicef(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool {
180 return InDeltaSlice(t, expected, actual, delta, append([]interface{}{msg}, args...)...)
183 // InEpsilonf asserts that expected and actual have a relative error less than epsilon
185 // Returns whether the assertion was successful (true) or not (false).
186 func InEpsilonf(t TestingT, expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) bool {
187 return InEpsilon(t, expected, actual, epsilon, append([]interface{}{msg}, args...)...)
190 // InEpsilonSlicef is the same as InEpsilon, except it compares each value from two slices.
191 func InEpsilonSlicef(t TestingT, expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) bool {
192 return InEpsilonSlice(t, expected, actual, epsilon, append([]interface{}{msg}, args...)...)
195 // IsTypef asserts that the specified objects are of the same type.
196 func IsTypef(t TestingT, expectedType interface{}, object interface{}, msg string, args ...interface{}) bool {
197 return IsType(t, expectedType, object, append([]interface{}{msg}, args...)...)
200 // JSONEqf asserts that two JSON strings are equivalent.
202 // assert.JSONEqf(t, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`, "error message %s", "formatted")
204 // Returns whether the assertion was successful (true) or not (false).
205 func JSONEqf(t TestingT, expected string, actual string, msg string, args ...interface{}) bool {
206 return JSONEq(t, expected, actual, append([]interface{}{msg}, args...)...)
209 // Lenf asserts that the specified object has specific length.
210 // Lenf also fails if the object has a type that len() not accept.
212 // assert.Lenf(t, mySlice, 3, "error message %s", "formatted")
214 // Returns whether the assertion was successful (true) or not (false).
215 func Lenf(t TestingT, object interface{}, length int, msg string, args ...interface{}) bool {
216 return Len(t, object, length, append([]interface{}{msg}, args...)...)
219 // Nilf asserts that the specified object is nil.
221 // assert.Nilf(t, err, "error message %s", "formatted")
223 // Returns whether the assertion was successful (true) or not (false).
224 func Nilf(t TestingT, object interface{}, msg string, args ...interface{}) bool {
225 return Nil(t, object, append([]interface{}{msg}, args...)...)
228 // NoErrorf asserts that a function returned no error (i.e. `nil`).
230 // actualObj, err := SomeFunction()
231 // if assert.NoErrorf(t, err, "error message %s", "formatted") {
232 // assert.Equal(t, expectedObj, actualObj)
235 // Returns whether the assertion was successful (true) or not (false).
236 func NoErrorf(t TestingT, err error, msg string, args ...interface{}) bool {
237 return NoError(t, err, append([]interface{}{msg}, args...)...)
240 // NotContainsf asserts that the specified string, list(array, slice...) or map does NOT contain the
241 // specified substring or element.
243 // assert.NotContainsf(t, "Hello World", "Earth", "error message %s", "formatted")
244 // assert.NotContainsf(t, ["Hello", "World"], "Earth", "error message %s", "formatted")
245 // assert.NotContainsf(t, {"Hello": "World"}, "Earth", "error message %s", "formatted")
247 // Returns whether the assertion was successful (true) or not (false).
248 func NotContainsf(t TestingT, s interface{}, contains interface{}, msg string, args ...interface{}) bool {
249 return NotContains(t, s, contains, append([]interface{}{msg}, args...)...)
252 // NotEmptyf asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either
253 // a slice or a channel with len == 0.
255 // if assert.NotEmptyf(t, obj, "error message %s", "formatted") {
256 // assert.Equal(t, "two", obj[1])
259 // Returns whether the assertion was successful (true) or not (false).
260 func NotEmptyf(t TestingT, object interface{}, msg string, args ...interface{}) bool {
261 return NotEmpty(t, object, append([]interface{}{msg}, args...)...)
264 // NotEqualf asserts that the specified values are NOT equal.
266 // assert.NotEqualf(t, obj1, obj2, "error message %s", "formatted")
268 // Returns whether the assertion was successful (true) or not (false).
270 // Pointer variable equality is determined based on the equality of the
271 // referenced values (as opposed to the memory addresses).
272 func NotEqualf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
273 return NotEqual(t, expected, actual, append([]interface{}{msg}, args...)...)
276 // NotNilf asserts that the specified object is not nil.
278 // assert.NotNilf(t, err, "error message %s", "formatted")
280 // Returns whether the assertion was successful (true) or not (false).
281 func NotNilf(t TestingT, object interface{}, msg string, args ...interface{}) bool {
282 return NotNil(t, object, append([]interface{}{msg}, args...)...)
285 // NotPanicsf asserts that the code inside the specified PanicTestFunc does NOT panic.
287 // assert.NotPanicsf(t, func(){ RemainCalm() }, "error message %s", "formatted")
289 // Returns whether the assertion was successful (true) or not (false).
290 func NotPanicsf(t TestingT, f PanicTestFunc, msg string, args ...interface{}) bool {
291 return NotPanics(t, f, append([]interface{}{msg}, args...)...)
294 // NotRegexpf asserts that a specified regexp does not match a string.
296 // assert.NotRegexpf(t, regexp.MustCompile("starts", "error message %s", "formatted"), "it's starting")
297 // assert.NotRegexpf(t, "^start", "it's not starting", "error message %s", "formatted")
299 // Returns whether the assertion was successful (true) or not (false).
300 func NotRegexpf(t TestingT, rx interface{}, str interface{}, msg string, args ...interface{}) bool {
301 return NotRegexp(t, rx, str, append([]interface{}{msg}, args...)...)
304 // NotSubsetf asserts that the specified list(array, slice...) contains not all
305 // elements given in the specified subset(array, slice...).
307 // assert.NotSubsetf(t, [1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]", "error message %s", "formatted")
309 // Returns whether the assertion was successful (true) or not (false).
310 func NotSubsetf(t TestingT, list interface{}, subset interface{}, msg string, args ...interface{}) bool {
311 return NotSubset(t, list, subset, append([]interface{}{msg}, args...)...)
314 // NotZerof asserts that i is not the zero value for its type and returns the truth.
315 func NotZerof(t TestingT, i interface{}, msg string, args ...interface{}) bool {
316 return NotZero(t, i, append([]interface{}{msg}, args...)...)
319 // Panicsf asserts that the code inside the specified PanicTestFunc panics.
321 // assert.Panicsf(t, func(){ GoCrazy() }, "error message %s", "formatted")
323 // Returns whether the assertion was successful (true) or not (false).
324 func Panicsf(t TestingT, f PanicTestFunc, msg string, args ...interface{}) bool {
325 return Panics(t, f, append([]interface{}{msg}, args...)...)
328 // PanicsWithValuef asserts that the code inside the specified PanicTestFunc panics, and that
329 // the recovered panic value equals the expected panic value.
331 // assert.PanicsWithValuef(t, "crazy error", func(){ GoCrazy() }, "error message %s", "formatted")
333 // Returns whether the assertion was successful (true) or not (false).
334 func PanicsWithValuef(t TestingT, expected interface{}, f PanicTestFunc, msg string, args ...interface{}) bool {
335 return PanicsWithValue(t, expected, f, append([]interface{}{msg}, args...)...)
338 // Regexpf asserts that a specified regexp matches a string.
340 // assert.Regexpf(t, regexp.MustCompile("start", "error message %s", "formatted"), "it's starting")
341 // assert.Regexpf(t, "start...$", "it's not starting", "error message %s", "formatted")
343 // Returns whether the assertion was successful (true) or not (false).
344 func Regexpf(t TestingT, rx interface{}, str interface{}, msg string, args ...interface{}) bool {
345 return Regexp(t, rx, str, append([]interface{}{msg}, args...)...)
348 // Subsetf asserts that the specified list(array, slice...) contains all
349 // elements given in the specified subset(array, slice...).
351 // assert.Subsetf(t, [1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]", "error message %s", "formatted")
353 // Returns whether the assertion was successful (true) or not (false).
354 func Subsetf(t TestingT, list interface{}, subset interface{}, msg string, args ...interface{}) bool {
355 return Subset(t, list, subset, append([]interface{}{msg}, args...)...)
358 // Truef asserts that the specified value is true.
360 // assert.Truef(t, myBool, "error message %s", "formatted")
362 // Returns whether the assertion was successful (true) or not (false).
363 func Truef(t TestingT, value bool, msg string, args ...interface{}) bool {
364 return True(t, value, append([]interface{}{msg}, args...)...)
367 // WithinDurationf asserts that the two times are within duration delta of each other.
369 // assert.WithinDurationf(t, time.Now(), time.Now(), 10*time.Second, "error message %s", "formatted")
371 // Returns whether the assertion was successful (true) or not (false).
372 func WithinDurationf(t TestingT, expected time.Time, actual time.Time, delta time.Duration, msg string, args ...interface{}) bool {
373 return WithinDuration(t, expected, actual, delta, append([]interface{}{msg}, args...)...)
376 // Zerof asserts that i is the zero value for its type and returns the truth.
377 func Zerof(t TestingT, i interface{}, msg string, args ...interface{}) bool {
378 return Zero(t, i, append([]interface{}{msg}, args...)...)