1/* 2* CODE GENERATED AUTOMATICALLY WITH github.com/stretchr/testify/_codegen 3* THIS FILE MUST NOT BE EDITED BY HAND 4 */ 5 6package assert 7 8import ( 9 http "net/http" 10 url "net/url" 11 time "time" 12) 13 14// Conditionf uses a Comparison to assert a complex condition. 15func Conditionf(t TestingT, comp Comparison, msg string, args ...interface{}) bool { 16 if h, ok := t.(tHelper); ok { 17 h.Helper() 18 } 19 return Condition(t, comp, append([]interface{}{msg}, args...)...) 20} 21 22// Containsf asserts that the specified string, list(array, slice...) or map contains the 23// specified substring or element. 24// 25// assert.Containsf(t, "Hello World", "World", "error message %s", "formatted") 26// assert.Containsf(t, ["Hello", "World"], "World", "error message %s", "formatted") 27// assert.Containsf(t, {"Hello": "World"}, "Hello", "error message %s", "formatted") 28func Containsf(t TestingT, s interface{}, contains interface{}, msg string, args ...interface{}) bool { 29 if h, ok := t.(tHelper); ok { 30 h.Helper() 31 } 32 return Contains(t, s, contains, append([]interface{}{msg}, args...)...) 33} 34 35// DirExistsf checks whether a directory exists in the given path. It also fails 36// if the path is a file rather a directory or there is an error checking whether it exists. 37func DirExistsf(t TestingT, path string, msg string, args ...interface{}) bool { 38 if h, ok := t.(tHelper); ok { 39 h.Helper() 40 } 41 return DirExists(t, path, append([]interface{}{msg}, args...)...) 42} 43 44// ElementsMatchf asserts that the specified listA(array, slice...) is equal to specified 45// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements, 46// the number of appearances of each of them in both lists should match. 47// 48// assert.ElementsMatchf(t, [1, 3, 2, 3], [1, 3, 3, 2], "error message %s", "formatted") 49func ElementsMatchf(t TestingT, listA interface{}, listB interface{}, msg string, args ...interface{}) bool { 50 if h, ok := t.(tHelper); ok { 51 h.Helper() 52 } 53 return ElementsMatch(t, listA, listB, append([]interface{}{msg}, args...)...) 54} 55 56// Emptyf asserts that the specified object is empty. I.e. nil, "", false, 0 or either 57// a slice or a channel with len == 0. 58// 59// assert.Emptyf(t, obj, "error message %s", "formatted") 60func Emptyf(t TestingT, object interface{}, msg string, args ...interface{}) bool { 61 if h, ok := t.(tHelper); ok { 62 h.Helper() 63 } 64 return Empty(t, object, append([]interface{}{msg}, args...)...) 65} 66 67// Equalf asserts that two objects are equal. 68// 69// assert.Equalf(t, 123, 123, "error message %s", "formatted") 70// 71// Pointer variable equality is determined based on the equality of the 72// referenced values (as opposed to the memory addresses). Function equality 73// cannot be determined and will always fail. 74func Equalf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool { 75 if h, ok := t.(tHelper); ok { 76 h.Helper() 77 } 78 return Equal(t, expected, actual, append([]interface{}{msg}, args...)...) 79} 80 81// EqualErrorf asserts that a function returned an error (i.e. not `nil`) 82// and that it is equal to the provided error. 83// 84// actualObj, err := SomeFunction() 85// assert.EqualErrorf(t, err, expectedErrorString, "error message %s", "formatted") 86func EqualErrorf(t TestingT, theError error, errString string, msg string, args ...interface{}) bool { 87 if h, ok := t.(tHelper); ok { 88 h.Helper() 89 } 90 return EqualError(t, theError, errString, append([]interface{}{msg}, args...)...) 91} 92 93// EqualValuesf asserts that two objects are equal or convertable to the same types 94// and equal. 95// 96// assert.EqualValuesf(t, uint32(123, "error message %s", "formatted"), int32(123)) 97func EqualValuesf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool { 98 if h, ok := t.(tHelper); ok { 99 h.Helper() 100 } 101 return EqualValues(t, expected, actual, append([]interface{}{msg}, args...)...) 102} 103 104// Errorf asserts that a function returned an error (i.e. not `nil`). 105// 106// actualObj, err := SomeFunction() 107// if assert.Errorf(t, err, "error message %s", "formatted") { 108// assert.Equal(t, expectedErrorf, err) 109// } 110func Errorf(t TestingT, err error, msg string, args ...interface{}) bool { 111 if h, ok := t.(tHelper); ok { 112 h.Helper() 113 } 114 return Error(t, err, append([]interface{}{msg}, args...)...) 115} 116 117// Eventuallyf asserts that given condition will be met in waitFor time, 118// periodically checking target function each tick. 119// 120// assert.Eventuallyf(t, func() bool { return true; }, time.Second, 10*time.Millisecond, "error message %s", "formatted") 121func Eventuallyf(t TestingT, condition func() bool, waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) bool { 122 if h, ok := t.(tHelper); ok { 123 h.Helper() 124 } 125 return Eventually(t, condition, waitFor, tick, append([]interface{}{msg}, args...)...) 126} 127 128// Exactlyf asserts that two objects are equal in value and type. 129// 130// assert.Exactlyf(t, int32(123, "error message %s", "formatted"), int64(123)) 131func Exactlyf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool { 132 if h, ok := t.(tHelper); ok { 133 h.Helper() 134 } 135 return Exactly(t, expected, actual, append([]interface{}{msg}, args...)...) 136} 137 138// Failf reports a failure through 139func Failf(t TestingT, failureMessage string, msg string, args ...interface{}) bool { 140 if h, ok := t.(tHelper); ok { 141 h.Helper() 142 } 143 return Fail(t, failureMessage, append([]interface{}{msg}, args...)...) 144} 145 146// FailNowf fails test 147func FailNowf(t TestingT, failureMessage string, msg string, args ...interface{}) bool { 148 if h, ok := t.(tHelper); ok { 149 h.Helper() 150 } 151 return FailNow(t, failureMessage, append([]interface{}{msg}, args...)...) 152} 153 154// Falsef asserts that the specified value is false. 155// 156// assert.Falsef(t, myBool, "error message %s", "formatted") 157func Falsef(t TestingT, value bool, msg string, args ...interface{}) bool { 158 if h, ok := t.(tHelper); ok { 159 h.Helper() 160 } 161 return False(t, value, append([]interface{}{msg}, args...)...) 162} 163 164// FileExistsf checks whether a file exists in the given path. It also fails if 165// the path points to a directory or there is an error when trying to check the file. 166func FileExistsf(t TestingT, path string, msg string, args ...interface{}) bool { 167 if h, ok := t.(tHelper); ok { 168 h.Helper() 169 } 170 return FileExists(t, path, append([]interface{}{msg}, args...)...) 171} 172 173// Greaterf asserts that the first element is greater than the second 174// 175// assert.Greaterf(t, 2, 1, "error message %s", "formatted") 176// assert.Greaterf(t, float64(2, "error message %s", "formatted"), float64(1)) 177// assert.Greaterf(t, "b", "a", "error message %s", "formatted") 178func Greaterf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool { 179 if h, ok := t.(tHelper); ok { 180 h.Helper() 181 } 182 return Greater(t, e1, e2, append([]interface{}{msg}, args...)...) 183} 184 185// GreaterOrEqualf asserts that the first element is greater than or equal to the second 186// 187// assert.GreaterOrEqualf(t, 2, 1, "error message %s", "formatted") 188// assert.GreaterOrEqualf(t, 2, 2, "error message %s", "formatted") 189// assert.GreaterOrEqualf(t, "b", "a", "error message %s", "formatted") 190// assert.GreaterOrEqualf(t, "b", "b", "error message %s", "formatted") 191func GreaterOrEqualf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool { 192 if h, ok := t.(tHelper); ok { 193 h.Helper() 194 } 195 return GreaterOrEqual(t, e1, e2, append([]interface{}{msg}, args...)...) 196} 197 198// HTTPBodyContainsf asserts that a specified handler returns a 199// body that contains a string. 200// 201// assert.HTTPBodyContainsf(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted") 202// 203// Returns whether the assertion was successful (true) or not (false). 204func HTTPBodyContainsf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) bool { 205 if h, ok := t.(tHelper); ok { 206 h.Helper() 207 } 208 return HTTPBodyContains(t, handler, method, url, values, str, append([]interface{}{msg}, args...)...) 209} 210 211// HTTPBodyNotContainsf asserts that a specified handler returns a 212// body that does not contain a string. 213// 214// assert.HTTPBodyNotContainsf(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted") 215// 216// Returns whether the assertion was successful (true) or not (false). 217func HTTPBodyNotContainsf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) bool { 218 if h, ok := t.(tHelper); ok { 219 h.Helper() 220 } 221 return HTTPBodyNotContains(t, handler, method, url, values, str, append([]interface{}{msg}, args...)...) 222} 223 224// HTTPErrorf asserts that a specified handler returns an error status code. 225// 226// assert.HTTPErrorf(t, myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}} 227// 228// Returns whether the assertion was successful (true, "error message %s", "formatted") or not (false). 229func HTTPErrorf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) bool { 230 if h, ok := t.(tHelper); ok { 231 h.Helper() 232 } 233 return HTTPError(t, handler, method, url, values, append([]interface{}{msg}, args...)...) 234} 235 236// HTTPRedirectf asserts that a specified handler returns a redirect status code. 237// 238// assert.HTTPRedirectf(t, myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}} 239// 240// Returns whether the assertion was successful (true, "error message %s", "formatted") or not (false). 241func HTTPRedirectf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) bool { 242 if h, ok := t.(tHelper); ok { 243 h.Helper() 244 } 245 return HTTPRedirect(t, handler, method, url, values, append([]interface{}{msg}, args...)...) 246} 247 248// HTTPSuccessf asserts that a specified handler returns a success status code. 249// 250// assert.HTTPSuccessf(t, myHandler, "POST", "http://www.google.com", nil, "error message %s", "formatted") 251// 252// Returns whether the assertion was successful (true) or not (false). 253func HTTPSuccessf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) bool { 254 if h, ok := t.(tHelper); ok { 255 h.Helper() 256 } 257 return HTTPSuccess(t, handler, method, url, values, append([]interface{}{msg}, args...)...) 258} 259 260// Implementsf asserts that an object is implemented by the specified interface. 261// 262// assert.Implementsf(t, (*MyInterface, "error message %s", "formatted")(nil), new(MyObject)) 263func Implementsf(t TestingT, interfaceObject interface{}, object interface{}, msg string, args ...interface{}) bool { 264 if h, ok := t.(tHelper); ok { 265 h.Helper() 266 } 267 return Implements(t, interfaceObject, object, append([]interface{}{msg}, args...)...) 268} 269 270// InDeltaf asserts that the two numerals are within delta of each other. 271// 272// assert.InDeltaf(t, math.Pi, 22/7.0, 0.01, "error message %s", "formatted") 273func InDeltaf(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool { 274 if h, ok := t.(tHelper); ok { 275 h.Helper() 276 } 277 return InDelta(t, expected, actual, delta, append([]interface{}{msg}, args...)...) 278} 279 280// InDeltaMapValuesf is the same as InDelta, but it compares all values between two maps. Both maps must have exactly the same keys. 281func InDeltaMapValuesf(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool { 282 if h, ok := t.(tHelper); ok { 283 h.Helper() 284 } 285 return InDeltaMapValues(t, expected, actual, delta, append([]interface{}{msg}, args...)...) 286} 287 288// InDeltaSlicef is the same as InDelta, except it compares two slices. 289func InDeltaSlicef(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool { 290 if h, ok := t.(tHelper); ok { 291 h.Helper() 292 } 293 return InDeltaSlice(t, expected, actual, delta, append([]interface{}{msg}, args...)...) 294} 295 296// InEpsilonf asserts that expected and actual have a relative error less than epsilon 297func InEpsilonf(t TestingT, expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) bool { 298 if h, ok := t.(tHelper); ok { 299 h.Helper() 300 } 301 return InEpsilon(t, expected, actual, epsilon, append([]interface{}{msg}, args...)...) 302} 303 304// InEpsilonSlicef is the same as InEpsilon, except it compares each value from two slices. 305func InEpsilonSlicef(t TestingT, expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) bool { 306 if h, ok := t.(tHelper); ok { 307 h.Helper() 308 } 309 return InEpsilonSlice(t, expected, actual, epsilon, append([]interface{}{msg}, args...)...) 310} 311 312// IsTypef asserts that the specified objects are of the same type. 313func IsTypef(t TestingT, expectedType interface{}, object interface{}, msg string, args ...interface{}) bool { 314 if h, ok := t.(tHelper); ok { 315 h.Helper() 316 } 317 return IsType(t, expectedType, object, append([]interface{}{msg}, args...)...) 318} 319 320// JSONEqf asserts that two JSON strings are equivalent. 321// 322// assert.JSONEqf(t, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`, "error message %s", "formatted") 323func JSONEqf(t TestingT, expected string, actual string, msg string, args ...interface{}) bool { 324 if h, ok := t.(tHelper); ok { 325 h.Helper() 326 } 327 return JSONEq(t, expected, actual, append([]interface{}{msg}, args...)...) 328} 329 330// Lenf asserts that the specified object has specific length. 331// Lenf also fails if the object has a type that len() not accept. 332// 333// assert.Lenf(t, mySlice, 3, "error message %s", "formatted") 334func Lenf(t TestingT, object interface{}, length int, msg string, args ...interface{}) bool { 335 if h, ok := t.(tHelper); ok { 336 h.Helper() 337 } 338 return Len(t, object, length, append([]interface{}{msg}, args...)...) 339} 340 341// Lessf asserts that the first element is less than the second 342// 343// assert.Lessf(t, 1, 2, "error message %s", "formatted") 344// assert.Lessf(t, float64(1, "error message %s", "formatted"), float64(2)) 345// assert.Lessf(t, "a", "b", "error message %s", "formatted") 346func Lessf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool { 347 if h, ok := t.(tHelper); ok { 348 h.Helper() 349 } 350 return Less(t, e1, e2, append([]interface{}{msg}, args...)...) 351} 352 353// LessOrEqualf asserts that the first element is less than or equal to the second 354// 355// assert.LessOrEqualf(t, 1, 2, "error message %s", "formatted") 356// assert.LessOrEqualf(t, 2, 2, "error message %s", "formatted") 357// assert.LessOrEqualf(t, "a", "b", "error message %s", "formatted") 358// assert.LessOrEqualf(t, "b", "b", "error message %s", "formatted") 359func LessOrEqualf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool { 360 if h, ok := t.(tHelper); ok { 361 h.Helper() 362 } 363 return LessOrEqual(t, e1, e2, append([]interface{}{msg}, args...)...) 364} 365 366// Neverf asserts that the given condition doesn't satisfy in waitFor time, 367// periodically checking the target function each tick. 368// 369// assert.Neverf(t, func() bool { return false; }, time.Second, 10*time.Millisecond, "error message %s", "formatted") 370func Neverf(t TestingT, condition func() bool, waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) bool { 371 if h, ok := t.(tHelper); ok { 372 h.Helper() 373 } 374 return Never(t, condition, waitFor, tick, append([]interface{}{msg}, args...)...) 375} 376 377// Nilf asserts that the specified object is nil. 378// 379// assert.Nilf(t, err, "error message %s", "formatted") 380func Nilf(t TestingT, object interface{}, msg string, args ...interface{}) bool { 381 if h, ok := t.(tHelper); ok { 382 h.Helper() 383 } 384 return Nil(t, object, append([]interface{}{msg}, args...)...) 385} 386 387// NoDirExistsf checks whether a directory does not exist in the given path. 388// It fails if the path points to an existing _directory_ only. 389func NoDirExistsf(t TestingT, path string, msg string, args ...interface{}) bool { 390 if h, ok := t.(tHelper); ok { 391 h.Helper() 392 } 393 return NoDirExists(t, path, append([]interface{}{msg}, args...)...) 394} 395 396// NoErrorf asserts that a function returned no error (i.e. `nil`). 397// 398// actualObj, err := SomeFunction() 399// if assert.NoErrorf(t, err, "error message %s", "formatted") { 400// assert.Equal(t, expectedObj, actualObj) 401// } 402func NoErrorf(t TestingT, err error, msg string, args ...interface{}) bool { 403 if h, ok := t.(tHelper); ok { 404 h.Helper() 405 } 406 return NoError(t, err, append([]interface{}{msg}, args...)...) 407} 408 409// NoFileExistsf checks whether a file does not exist in a given path. It fails 410// if the path points to an existing _file_ only. 411func NoFileExistsf(t TestingT, path string, msg string, args ...interface{}) bool { 412 if h, ok := t.(tHelper); ok { 413 h.Helper() 414 } 415 return NoFileExists(t, path, append([]interface{}{msg}, args...)...) 416} 417 418// NotContainsf asserts that the specified string, list(array, slice...) or map does NOT contain the 419// specified substring or element. 420// 421// assert.NotContainsf(t, "Hello World", "Earth", "error message %s", "formatted") 422// assert.NotContainsf(t, ["Hello", "World"], "Earth", "error message %s", "formatted") 423// assert.NotContainsf(t, {"Hello": "World"}, "Earth", "error message %s", "formatted") 424func NotContainsf(t TestingT, s interface{}, contains interface{}, msg string, args ...interface{}) bool { 425 if h, ok := t.(tHelper); ok { 426 h.Helper() 427 } 428 return NotContains(t, s, contains, append([]interface{}{msg}, args...)...) 429} 430 431// NotEmptyf asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either 432// a slice or a channel with len == 0. 433// 434// if assert.NotEmptyf(t, obj, "error message %s", "formatted") { 435// assert.Equal(t, "two", obj[1]) 436// } 437func NotEmptyf(t TestingT, object interface{}, msg string, args ...interface{}) bool { 438 if h, ok := t.(tHelper); ok { 439 h.Helper() 440 } 441 return NotEmpty(t, object, append([]interface{}{msg}, args...)...) 442} 443 444// NotEqualf asserts that the specified values are NOT equal. 445// 446// assert.NotEqualf(t, obj1, obj2, "error message %s", "formatted") 447// 448// Pointer variable equality is determined based on the equality of the 449// referenced values (as opposed to the memory addresses). 450func NotEqualf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool { 451 if h, ok := t.(tHelper); ok { 452 h.Helper() 453 } 454 return NotEqual(t, expected, actual, append([]interface{}{msg}, args...)...) 455} 456 457// NotNilf asserts that the specified object is not nil. 458// 459// assert.NotNilf(t, err, "error message %s", "formatted") 460func NotNilf(t TestingT, object interface{}, msg string, args ...interface{}) bool { 461 if h, ok := t.(tHelper); ok { 462 h.Helper() 463 } 464 return NotNil(t, object, append([]interface{}{msg}, args...)...) 465} 466 467// NotPanicsf asserts that the code inside the specified PanicTestFunc does NOT panic. 468// 469// assert.NotPanicsf(t, func(){ RemainCalm() }, "error message %s", "formatted") 470func NotPanicsf(t TestingT, f PanicTestFunc, msg string, args ...interface{}) bool { 471 if h, ok := t.(tHelper); ok { 472 h.Helper() 473 } 474 return NotPanics(t, f, append([]interface{}{msg}, args...)...) 475} 476 477// NotRegexpf asserts that a specified regexp does not match a string. 478// 479// assert.NotRegexpf(t, regexp.MustCompile("starts", "error message %s", "formatted"), "it's starting") 480// assert.NotRegexpf(t, "^start", "it's not starting", "error message %s", "formatted") 481func NotRegexpf(t TestingT, rx interface{}, str interface{}, msg string, args ...interface{}) bool { 482 if h, ok := t.(tHelper); ok { 483 h.Helper() 484 } 485 return NotRegexp(t, rx, str, append([]interface{}{msg}, args...)...) 486} 487 488// NotSamef asserts that two pointers do not reference the same object. 489// 490// assert.NotSamef(t, ptr1, ptr2, "error message %s", "formatted") 491// 492// Both arguments must be pointer variables. Pointer variable sameness is 493// determined based on the equality of both type and value. 494func NotSamef(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool { 495 if h, ok := t.(tHelper); ok { 496 h.Helper() 497 } 498 return NotSame(t, expected, actual, append([]interface{}{msg}, args...)...) 499} 500 501// NotSubsetf asserts that the specified list(array, slice...) contains not all 502// elements given in the specified subset(array, slice...). 503// 504// assert.NotSubsetf(t, [1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]", "error message %s", "formatted") 505func NotSubsetf(t TestingT, list interface{}, subset interface{}, msg string, args ...interface{}) bool { 506 if h, ok := t.(tHelper); ok { 507 h.Helper() 508 } 509 return NotSubset(t, list, subset, append([]interface{}{msg}, args...)...) 510} 511 512// NotZerof asserts that i is not the zero value for its type. 513func NotZerof(t TestingT, i interface{}, msg string, args ...interface{}) bool { 514 if h, ok := t.(tHelper); ok { 515 h.Helper() 516 } 517 return NotZero(t, i, append([]interface{}{msg}, args...)...) 518} 519 520// Panicsf asserts that the code inside the specified PanicTestFunc panics. 521// 522// assert.Panicsf(t, func(){ GoCrazy() }, "error message %s", "formatted") 523func Panicsf(t TestingT, f PanicTestFunc, msg string, args ...interface{}) bool { 524 if h, ok := t.(tHelper); ok { 525 h.Helper() 526 } 527 return Panics(t, f, append([]interface{}{msg}, args...)...) 528} 529 530// PanicsWithErrorf asserts that the code inside the specified PanicTestFunc 531// panics, and that the recovered panic value is an error that satisfies the 532// EqualError comparison. 533// 534// assert.PanicsWithErrorf(t, "crazy error", func(){ GoCrazy() }, "error message %s", "formatted") 535func PanicsWithErrorf(t TestingT, errString string, f PanicTestFunc, msg string, args ...interface{}) bool { 536 if h, ok := t.(tHelper); ok { 537 h.Helper() 538 } 539 return PanicsWithError(t, errString, f, append([]interface{}{msg}, args...)...) 540} 541 542// PanicsWithValuef asserts that the code inside the specified PanicTestFunc panics, and that 543// the recovered panic value equals the expected panic value. 544// 545// assert.PanicsWithValuef(t, "crazy error", func(){ GoCrazy() }, "error message %s", "formatted") 546func PanicsWithValuef(t TestingT, expected interface{}, f PanicTestFunc, msg string, args ...interface{}) bool { 547 if h, ok := t.(tHelper); ok { 548 h.Helper() 549 } 550 return PanicsWithValue(t, expected, f, append([]interface{}{msg}, args...)...) 551} 552 553// Regexpf asserts that a specified regexp matches a string. 554// 555// assert.Regexpf(t, regexp.MustCompile("start", "error message %s", "formatted"), "it's starting") 556// assert.Regexpf(t, "start...$", "it's not starting", "error message %s", "formatted") 557func Regexpf(t TestingT, rx interface{}, str interface{}, msg string, args ...interface{}) bool { 558 if h, ok := t.(tHelper); ok { 559 h.Helper() 560 } 561 return Regexp(t, rx, str, append([]interface{}{msg}, args...)...) 562} 563 564// Samef asserts that two pointers reference the same object. 565// 566// assert.Samef(t, ptr1, ptr2, "error message %s", "formatted") 567// 568// Both arguments must be pointer variables. Pointer variable sameness is 569// determined based on the equality of both type and value. 570func Samef(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool { 571 if h, ok := t.(tHelper); ok { 572 h.Helper() 573 } 574 return Same(t, expected, actual, append([]interface{}{msg}, args...)...) 575} 576 577// Subsetf asserts that the specified list(array, slice...) contains all 578// elements given in the specified subset(array, slice...). 579// 580// assert.Subsetf(t, [1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]", "error message %s", "formatted") 581func Subsetf(t TestingT, list interface{}, subset interface{}, msg string, args ...interface{}) bool { 582 if h, ok := t.(tHelper); ok { 583 h.Helper() 584 } 585 return Subset(t, list, subset, append([]interface{}{msg}, args...)...) 586} 587 588// Truef asserts that the specified value is true. 589// 590// assert.Truef(t, myBool, "error message %s", "formatted") 591func Truef(t TestingT, value bool, msg string, args ...interface{}) bool { 592 if h, ok := t.(tHelper); ok { 593 h.Helper() 594 } 595 return True(t, value, append([]interface{}{msg}, args...)...) 596} 597 598// WithinDurationf asserts that the two times are within duration delta of each other. 599// 600// assert.WithinDurationf(t, time.Now(), time.Now(), 10*time.Second, "error message %s", "formatted") 601func WithinDurationf(t TestingT, expected time.Time, actual time.Time, delta time.Duration, msg string, args ...interface{}) bool { 602 if h, ok := t.(tHelper); ok { 603 h.Helper() 604 } 605 return WithinDuration(t, expected, actual, delta, append([]interface{}{msg}, args...)...) 606} 607 608// YAMLEqf asserts that two YAML strings are equivalent. 609func YAMLEqf(t TestingT, expected string, actual string, msg string, args ...interface{}) bool { 610 if h, ok := t.(tHelper); ok { 611 h.Helper() 612 } 613 return YAMLEq(t, expected, actual, append([]interface{}{msg}, args...)...) 614} 615 616// Zerof asserts that i is the zero value for its type. 617func Zerof(t TestingT, i interface{}, msg string, args ...interface{}) bool { 618 if h, ok := t.(tHelper); ok { 619 h.Helper() 620 } 621 return Zero(t, i, append([]interface{}{msg}, args...)...) 622} 623