1/* 2* CODE GENERATED AUTOMATICALLY WITH github.com/stretchr/testify/_codegen 3* THIS FILE MUST NOT BE EDITED BY HAND 4 */ 5 6package require 7 8import ( 9 assert "github.com/stretchr/testify/assert" 10 http "net/http" 11 url "net/url" 12 time "time" 13) 14 15// Condition uses a Comparison to assert a complex condition. 16func Condition(t TestingT, comp assert.Comparison, msgAndArgs ...interface{}) { 17 if h, ok := t.(tHelper); ok { 18 h.Helper() 19 } 20 if assert.Condition(t, comp, msgAndArgs...) { 21 return 22 } 23 t.FailNow() 24} 25 26// Conditionf uses a Comparison to assert a complex condition. 27func Conditionf(t TestingT, comp assert.Comparison, msg string, args ...interface{}) { 28 if h, ok := t.(tHelper); ok { 29 h.Helper() 30 } 31 if assert.Conditionf(t, comp, msg, args...) { 32 return 33 } 34 t.FailNow() 35} 36 37// Contains asserts that the specified string, list(array, slice...) or map contains the 38// specified substring or element. 39// 40// assert.Contains(t, "Hello World", "World") 41// assert.Contains(t, ["Hello", "World"], "World") 42// assert.Contains(t, {"Hello": "World"}, "Hello") 43func Contains(t TestingT, s interface{}, contains interface{}, msgAndArgs ...interface{}) { 44 if h, ok := t.(tHelper); ok { 45 h.Helper() 46 } 47 if assert.Contains(t, s, contains, msgAndArgs...) { 48 return 49 } 50 t.FailNow() 51} 52 53// Containsf asserts that the specified string, list(array, slice...) or map contains the 54// specified substring or element. 55// 56// assert.Containsf(t, "Hello World", "World", "error message %s", "formatted") 57// assert.Containsf(t, ["Hello", "World"], "World", "error message %s", "formatted") 58// assert.Containsf(t, {"Hello": "World"}, "Hello", "error message %s", "formatted") 59func Containsf(t TestingT, s interface{}, contains interface{}, msg string, args ...interface{}) { 60 if h, ok := t.(tHelper); ok { 61 h.Helper() 62 } 63 if assert.Containsf(t, s, contains, msg, args...) { 64 return 65 } 66 t.FailNow() 67} 68 69// DirExists checks whether a directory exists in the given path. It also fails 70// if the path is a file rather a directory or there is an error checking whether it exists. 71func DirExists(t TestingT, path string, msgAndArgs ...interface{}) { 72 if h, ok := t.(tHelper); ok { 73 h.Helper() 74 } 75 if assert.DirExists(t, path, msgAndArgs...) { 76 return 77 } 78 t.FailNow() 79} 80 81// DirExistsf checks whether a directory exists in the given path. It also fails 82// if the path is a file rather a directory or there is an error checking whether it exists. 83func DirExistsf(t TestingT, path string, msg string, args ...interface{}) { 84 if h, ok := t.(tHelper); ok { 85 h.Helper() 86 } 87 if assert.DirExistsf(t, path, msg, args...) { 88 return 89 } 90 t.FailNow() 91} 92 93// ElementsMatch asserts that the specified listA(array, slice...) is equal to specified 94// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements, 95// the number of appearances of each of them in both lists should match. 96// 97// assert.ElementsMatch(t, [1, 3, 2, 3], [1, 3, 3, 2]) 98func ElementsMatch(t TestingT, listA interface{}, listB interface{}, msgAndArgs ...interface{}) { 99 if h, ok := t.(tHelper); ok { 100 h.Helper() 101 } 102 if assert.ElementsMatch(t, listA, listB, msgAndArgs...) { 103 return 104 } 105 t.FailNow() 106} 107 108// ElementsMatchf asserts that the specified listA(array, slice...) is equal to specified 109// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements, 110// the number of appearances of each of them in both lists should match. 111// 112// assert.ElementsMatchf(t, [1, 3, 2, 3], [1, 3, 3, 2], "error message %s", "formatted") 113func ElementsMatchf(t TestingT, listA interface{}, listB interface{}, msg string, args ...interface{}) { 114 if h, ok := t.(tHelper); ok { 115 h.Helper() 116 } 117 if assert.ElementsMatchf(t, listA, listB, msg, args...) { 118 return 119 } 120 t.FailNow() 121} 122 123// Empty asserts that the specified object is empty. I.e. nil, "", false, 0 or either 124// a slice or a channel with len == 0. 125// 126// assert.Empty(t, obj) 127func Empty(t TestingT, object interface{}, msgAndArgs ...interface{}) { 128 if h, ok := t.(tHelper); ok { 129 h.Helper() 130 } 131 if assert.Empty(t, object, msgAndArgs...) { 132 return 133 } 134 t.FailNow() 135} 136 137// Emptyf asserts that the specified object is empty. I.e. nil, "", false, 0 or either 138// a slice or a channel with len == 0. 139// 140// assert.Emptyf(t, obj, "error message %s", "formatted") 141func Emptyf(t TestingT, object interface{}, msg string, args ...interface{}) { 142 if h, ok := t.(tHelper); ok { 143 h.Helper() 144 } 145 if assert.Emptyf(t, object, msg, args...) { 146 return 147 } 148 t.FailNow() 149} 150 151// Equal asserts that two objects are equal. 152// 153// assert.Equal(t, 123, 123) 154// 155// Pointer variable equality is determined based on the equality of the 156// referenced values (as opposed to the memory addresses). Function equality 157// cannot be determined and will always fail. 158func Equal(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) { 159 if h, ok := t.(tHelper); ok { 160 h.Helper() 161 } 162 if assert.Equal(t, expected, actual, msgAndArgs...) { 163 return 164 } 165 t.FailNow() 166} 167 168// EqualError asserts that a function returned an error (i.e. not `nil`) 169// and that it is equal to the provided error. 170// 171// actualObj, err := SomeFunction() 172// assert.EqualError(t, err, expectedErrorString) 173func EqualError(t TestingT, theError error, errString string, msgAndArgs ...interface{}) { 174 if h, ok := t.(tHelper); ok { 175 h.Helper() 176 } 177 if assert.EqualError(t, theError, errString, msgAndArgs...) { 178 return 179 } 180 t.FailNow() 181} 182 183// EqualErrorf asserts that a function returned an error (i.e. not `nil`) 184// and that it is equal to the provided error. 185// 186// actualObj, err := SomeFunction() 187// assert.EqualErrorf(t, err, expectedErrorString, "error message %s", "formatted") 188func EqualErrorf(t TestingT, theError error, errString string, msg string, args ...interface{}) { 189 if h, ok := t.(tHelper); ok { 190 h.Helper() 191 } 192 if assert.EqualErrorf(t, theError, errString, msg, args...) { 193 return 194 } 195 t.FailNow() 196} 197 198// EqualValues asserts that two objects are equal or convertable to the same types 199// and equal. 200// 201// assert.EqualValues(t, uint32(123), int32(123)) 202func EqualValues(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) { 203 if h, ok := t.(tHelper); ok { 204 h.Helper() 205 } 206 if assert.EqualValues(t, expected, actual, msgAndArgs...) { 207 return 208 } 209 t.FailNow() 210} 211 212// EqualValuesf asserts that two objects are equal or convertable to the same types 213// and equal. 214// 215// assert.EqualValuesf(t, uint32(123, "error message %s", "formatted"), int32(123)) 216func EqualValuesf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) { 217 if h, ok := t.(tHelper); ok { 218 h.Helper() 219 } 220 if assert.EqualValuesf(t, expected, actual, msg, args...) { 221 return 222 } 223 t.FailNow() 224} 225 226// Equalf asserts that two objects are equal. 227// 228// assert.Equalf(t, 123, 123, "error message %s", "formatted") 229// 230// Pointer variable equality is determined based on the equality of the 231// referenced values (as opposed to the memory addresses). Function equality 232// cannot be determined and will always fail. 233func Equalf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) { 234 if h, ok := t.(tHelper); ok { 235 h.Helper() 236 } 237 if assert.Equalf(t, expected, actual, msg, args...) { 238 return 239 } 240 t.FailNow() 241} 242 243// Error asserts that a function returned an error (i.e. not `nil`). 244// 245// actualObj, err := SomeFunction() 246// if assert.Error(t, err) { 247// assert.Equal(t, expectedError, err) 248// } 249func Error(t TestingT, err error, msgAndArgs ...interface{}) { 250 if h, ok := t.(tHelper); ok { 251 h.Helper() 252 } 253 if assert.Error(t, err, msgAndArgs...) { 254 return 255 } 256 t.FailNow() 257} 258 259// Errorf asserts that a function returned an error (i.e. not `nil`). 260// 261// actualObj, err := SomeFunction() 262// if assert.Errorf(t, err, "error message %s", "formatted") { 263// assert.Equal(t, expectedErrorf, err) 264// } 265func Errorf(t TestingT, err error, msg string, args ...interface{}) { 266 if h, ok := t.(tHelper); ok { 267 h.Helper() 268 } 269 if assert.Errorf(t, err, msg, args...) { 270 return 271 } 272 t.FailNow() 273} 274 275// Eventually asserts that given condition will be met in waitFor time, 276// periodically checking target function each tick. 277// 278// assert.Eventually(t, func() bool { return true; }, time.Second, 10*time.Millisecond) 279func Eventually(t TestingT, condition func() bool, waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) { 280 if h, ok := t.(tHelper); ok { 281 h.Helper() 282 } 283 if assert.Eventually(t, condition, waitFor, tick, msgAndArgs...) { 284 return 285 } 286 t.FailNow() 287} 288 289// Eventuallyf asserts that given condition will be met in waitFor time, 290// periodically checking target function each tick. 291// 292// assert.Eventuallyf(t, func() bool { return true; }, time.Second, 10*time.Millisecond, "error message %s", "formatted") 293func Eventuallyf(t TestingT, condition func() bool, waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) { 294 if h, ok := t.(tHelper); ok { 295 h.Helper() 296 } 297 if assert.Eventuallyf(t, condition, waitFor, tick, msg, args...) { 298 return 299 } 300 t.FailNow() 301} 302 303// Exactly asserts that two objects are equal in value and type. 304// 305// assert.Exactly(t, int32(123), int64(123)) 306func Exactly(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) { 307 if h, ok := t.(tHelper); ok { 308 h.Helper() 309 } 310 if assert.Exactly(t, expected, actual, msgAndArgs...) { 311 return 312 } 313 t.FailNow() 314} 315 316// Exactlyf asserts that two objects are equal in value and type. 317// 318// assert.Exactlyf(t, int32(123, "error message %s", "formatted"), int64(123)) 319func Exactlyf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) { 320 if h, ok := t.(tHelper); ok { 321 h.Helper() 322 } 323 if assert.Exactlyf(t, expected, actual, msg, args...) { 324 return 325 } 326 t.FailNow() 327} 328 329// Fail reports a failure through 330func Fail(t TestingT, failureMessage string, msgAndArgs ...interface{}) { 331 if h, ok := t.(tHelper); ok { 332 h.Helper() 333 } 334 if assert.Fail(t, failureMessage, msgAndArgs...) { 335 return 336 } 337 t.FailNow() 338} 339 340// FailNow fails test 341func FailNow(t TestingT, failureMessage string, msgAndArgs ...interface{}) { 342 if h, ok := t.(tHelper); ok { 343 h.Helper() 344 } 345 if assert.FailNow(t, failureMessage, msgAndArgs...) { 346 return 347 } 348 t.FailNow() 349} 350 351// FailNowf fails test 352func FailNowf(t TestingT, failureMessage string, msg string, args ...interface{}) { 353 if h, ok := t.(tHelper); ok { 354 h.Helper() 355 } 356 if assert.FailNowf(t, failureMessage, msg, args...) { 357 return 358 } 359 t.FailNow() 360} 361 362// Failf reports a failure through 363func Failf(t TestingT, failureMessage string, msg string, args ...interface{}) { 364 if h, ok := t.(tHelper); ok { 365 h.Helper() 366 } 367 if assert.Failf(t, failureMessage, msg, args...) { 368 return 369 } 370 t.FailNow() 371} 372 373// False asserts that the specified value is false. 374// 375// assert.False(t, myBool) 376func False(t TestingT, value bool, msgAndArgs ...interface{}) { 377 if h, ok := t.(tHelper); ok { 378 h.Helper() 379 } 380 if assert.False(t, value, msgAndArgs...) { 381 return 382 } 383 t.FailNow() 384} 385 386// Falsef asserts that the specified value is false. 387// 388// assert.Falsef(t, myBool, "error message %s", "formatted") 389func Falsef(t TestingT, value bool, msg string, args ...interface{}) { 390 if h, ok := t.(tHelper); ok { 391 h.Helper() 392 } 393 if assert.Falsef(t, value, msg, args...) { 394 return 395 } 396 t.FailNow() 397} 398 399// FileExists checks whether a file exists in the given path. It also fails if 400// the path points to a directory or there is an error when trying to check the file. 401func FileExists(t TestingT, path string, msgAndArgs ...interface{}) { 402 if h, ok := t.(tHelper); ok { 403 h.Helper() 404 } 405 if assert.FileExists(t, path, msgAndArgs...) { 406 return 407 } 408 t.FailNow() 409} 410 411// FileExistsf checks whether a file exists in the given path. It also fails if 412// the path points to a directory or there is an error when trying to check the file. 413func FileExistsf(t TestingT, path string, msg string, args ...interface{}) { 414 if h, ok := t.(tHelper); ok { 415 h.Helper() 416 } 417 if assert.FileExistsf(t, path, msg, args...) { 418 return 419 } 420 t.FailNow() 421} 422 423// Greater asserts that the first element is greater than the second 424// 425// assert.Greater(t, 2, 1) 426// assert.Greater(t, float64(2), float64(1)) 427// assert.Greater(t, "b", "a") 428func Greater(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) { 429 if h, ok := t.(tHelper); ok { 430 h.Helper() 431 } 432 if assert.Greater(t, e1, e2, msgAndArgs...) { 433 return 434 } 435 t.FailNow() 436} 437 438// GreaterOrEqual asserts that the first element is greater than or equal to the second 439// 440// assert.GreaterOrEqual(t, 2, 1) 441// assert.GreaterOrEqual(t, 2, 2) 442// assert.GreaterOrEqual(t, "b", "a") 443// assert.GreaterOrEqual(t, "b", "b") 444func GreaterOrEqual(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) { 445 if h, ok := t.(tHelper); ok { 446 h.Helper() 447 } 448 if assert.GreaterOrEqual(t, e1, e2, msgAndArgs...) { 449 return 450 } 451 t.FailNow() 452} 453 454// GreaterOrEqualf asserts that the first element is greater than or equal to the second 455// 456// assert.GreaterOrEqualf(t, 2, 1, "error message %s", "formatted") 457// assert.GreaterOrEqualf(t, 2, 2, "error message %s", "formatted") 458// assert.GreaterOrEqualf(t, "b", "a", "error message %s", "formatted") 459// assert.GreaterOrEqualf(t, "b", "b", "error message %s", "formatted") 460func GreaterOrEqualf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) { 461 if h, ok := t.(tHelper); ok { 462 h.Helper() 463 } 464 if assert.GreaterOrEqualf(t, e1, e2, msg, args...) { 465 return 466 } 467 t.FailNow() 468} 469 470// Greaterf asserts that the first element is greater than the second 471// 472// assert.Greaterf(t, 2, 1, "error message %s", "formatted") 473// assert.Greaterf(t, float64(2, "error message %s", "formatted"), float64(1)) 474// assert.Greaterf(t, "b", "a", "error message %s", "formatted") 475func Greaterf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) { 476 if h, ok := t.(tHelper); ok { 477 h.Helper() 478 } 479 if assert.Greaterf(t, e1, e2, msg, args...) { 480 return 481 } 482 t.FailNow() 483} 484 485// HTTPBodyContains asserts that a specified handler returns a 486// body that contains a string. 487// 488// assert.HTTPBodyContains(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky") 489// 490// Returns whether the assertion was successful (true) or not (false). 491func HTTPBodyContains(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) { 492 if h, ok := t.(tHelper); ok { 493 h.Helper() 494 } 495 if assert.HTTPBodyContains(t, handler, method, url, values, str, msgAndArgs...) { 496 return 497 } 498 t.FailNow() 499} 500 501// HTTPBodyContainsf asserts that a specified handler returns a 502// body that contains a string. 503// 504// assert.HTTPBodyContainsf(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted") 505// 506// Returns whether the assertion was successful (true) or not (false). 507func HTTPBodyContainsf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) { 508 if h, ok := t.(tHelper); ok { 509 h.Helper() 510 } 511 if assert.HTTPBodyContainsf(t, handler, method, url, values, str, msg, args...) { 512 return 513 } 514 t.FailNow() 515} 516 517// HTTPBodyNotContains asserts that a specified handler returns a 518// body that does not contain a string. 519// 520// assert.HTTPBodyNotContains(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky") 521// 522// Returns whether the assertion was successful (true) or not (false). 523func HTTPBodyNotContains(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) { 524 if h, ok := t.(tHelper); ok { 525 h.Helper() 526 } 527 if assert.HTTPBodyNotContains(t, handler, method, url, values, str, msgAndArgs...) { 528 return 529 } 530 t.FailNow() 531} 532 533// HTTPBodyNotContainsf asserts that a specified handler returns a 534// body that does not contain a string. 535// 536// assert.HTTPBodyNotContainsf(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted") 537// 538// Returns whether the assertion was successful (true) or not (false). 539func HTTPBodyNotContainsf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) { 540 if h, ok := t.(tHelper); ok { 541 h.Helper() 542 } 543 if assert.HTTPBodyNotContainsf(t, handler, method, url, values, str, msg, args...) { 544 return 545 } 546 t.FailNow() 547} 548 549// HTTPError asserts that a specified handler returns an error status code. 550// 551// assert.HTTPError(t, myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}} 552// 553// Returns whether the assertion was successful (true) or not (false). 554func HTTPError(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) { 555 if h, ok := t.(tHelper); ok { 556 h.Helper() 557 } 558 if assert.HTTPError(t, handler, method, url, values, msgAndArgs...) { 559 return 560 } 561 t.FailNow() 562} 563 564// HTTPErrorf asserts that a specified handler returns an error status code. 565// 566// assert.HTTPErrorf(t, myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}} 567// 568// Returns whether the assertion was successful (true, "error message %s", "formatted") or not (false). 569func HTTPErrorf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) { 570 if h, ok := t.(tHelper); ok { 571 h.Helper() 572 } 573 if assert.HTTPErrorf(t, handler, method, url, values, msg, args...) { 574 return 575 } 576 t.FailNow() 577} 578 579// HTTPRedirect asserts that a specified handler returns a redirect status code. 580// 581// assert.HTTPRedirect(t, myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}} 582// 583// Returns whether the assertion was successful (true) or not (false). 584func HTTPRedirect(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) { 585 if h, ok := t.(tHelper); ok { 586 h.Helper() 587 } 588 if assert.HTTPRedirect(t, handler, method, url, values, msgAndArgs...) { 589 return 590 } 591 t.FailNow() 592} 593 594// HTTPRedirectf asserts that a specified handler returns a redirect status code. 595// 596// assert.HTTPRedirectf(t, myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}} 597// 598// Returns whether the assertion was successful (true, "error message %s", "formatted") or not (false). 599func HTTPRedirectf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) { 600 if h, ok := t.(tHelper); ok { 601 h.Helper() 602 } 603 if assert.HTTPRedirectf(t, handler, method, url, values, msg, args...) { 604 return 605 } 606 t.FailNow() 607} 608 609// HTTPSuccess asserts that a specified handler returns a success status code. 610// 611// assert.HTTPSuccess(t, myHandler, "POST", "http://www.google.com", nil) 612// 613// Returns whether the assertion was successful (true) or not (false). 614func HTTPSuccess(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) { 615 if h, ok := t.(tHelper); ok { 616 h.Helper() 617 } 618 if assert.HTTPSuccess(t, handler, method, url, values, msgAndArgs...) { 619 return 620 } 621 t.FailNow() 622} 623 624// HTTPSuccessf asserts that a specified handler returns a success status code. 625// 626// assert.HTTPSuccessf(t, myHandler, "POST", "http://www.google.com", nil, "error message %s", "formatted") 627// 628// Returns whether the assertion was successful (true) or not (false). 629func HTTPSuccessf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) { 630 if h, ok := t.(tHelper); ok { 631 h.Helper() 632 } 633 if assert.HTTPSuccessf(t, handler, method, url, values, msg, args...) { 634 return 635 } 636 t.FailNow() 637} 638 639// Implements asserts that an object is implemented by the specified interface. 640// 641// assert.Implements(t, (*MyInterface)(nil), new(MyObject)) 642func Implements(t TestingT, interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) { 643 if h, ok := t.(tHelper); ok { 644 h.Helper() 645 } 646 if assert.Implements(t, interfaceObject, object, msgAndArgs...) { 647 return 648 } 649 t.FailNow() 650} 651 652// Implementsf asserts that an object is implemented by the specified interface. 653// 654// assert.Implementsf(t, (*MyInterface, "error message %s", "formatted")(nil), new(MyObject)) 655func Implementsf(t TestingT, interfaceObject interface{}, object interface{}, msg string, args ...interface{}) { 656 if h, ok := t.(tHelper); ok { 657 h.Helper() 658 } 659 if assert.Implementsf(t, interfaceObject, object, msg, args...) { 660 return 661 } 662 t.FailNow() 663} 664 665// InDelta asserts that the two numerals are within delta of each other. 666// 667// assert.InDelta(t, math.Pi, 22/7.0, 0.01) 668func InDelta(t TestingT, expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) { 669 if h, ok := t.(tHelper); ok { 670 h.Helper() 671 } 672 if assert.InDelta(t, expected, actual, delta, msgAndArgs...) { 673 return 674 } 675 t.FailNow() 676} 677 678// InDeltaMapValues is the same as InDelta, but it compares all values between two maps. Both maps must have exactly the same keys. 679func InDeltaMapValues(t TestingT, expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) { 680 if h, ok := t.(tHelper); ok { 681 h.Helper() 682 } 683 if assert.InDeltaMapValues(t, expected, actual, delta, msgAndArgs...) { 684 return 685 } 686 t.FailNow() 687} 688 689// InDeltaMapValuesf is the same as InDelta, but it compares all values between two maps. Both maps must have exactly the same keys. 690func InDeltaMapValuesf(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) { 691 if h, ok := t.(tHelper); ok { 692 h.Helper() 693 } 694 if assert.InDeltaMapValuesf(t, expected, actual, delta, msg, args...) { 695 return 696 } 697 t.FailNow() 698} 699 700// InDeltaSlice is the same as InDelta, except it compares two slices. 701func InDeltaSlice(t TestingT, expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) { 702 if h, ok := t.(tHelper); ok { 703 h.Helper() 704 } 705 if assert.InDeltaSlice(t, expected, actual, delta, msgAndArgs...) { 706 return 707 } 708 t.FailNow() 709} 710 711// InDeltaSlicef is the same as InDelta, except it compares two slices. 712func InDeltaSlicef(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) { 713 if h, ok := t.(tHelper); ok { 714 h.Helper() 715 } 716 if assert.InDeltaSlicef(t, expected, actual, delta, msg, args...) { 717 return 718 } 719 t.FailNow() 720} 721 722// InDeltaf asserts that the two numerals are within delta of each other. 723// 724// assert.InDeltaf(t, math.Pi, 22/7.0, 0.01, "error message %s", "formatted") 725func InDeltaf(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) { 726 if h, ok := t.(tHelper); ok { 727 h.Helper() 728 } 729 if assert.InDeltaf(t, expected, actual, delta, msg, args...) { 730 return 731 } 732 t.FailNow() 733} 734 735// InEpsilon asserts that expected and actual have a relative error less than epsilon 736func InEpsilon(t TestingT, expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{}) { 737 if h, ok := t.(tHelper); ok { 738 h.Helper() 739 } 740 if assert.InEpsilon(t, expected, actual, epsilon, msgAndArgs...) { 741 return 742 } 743 t.FailNow() 744} 745 746// InEpsilonSlice is the same as InEpsilon, except it compares each value from two slices. 747func InEpsilonSlice(t TestingT, expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{}) { 748 if h, ok := t.(tHelper); ok { 749 h.Helper() 750 } 751 if assert.InEpsilonSlice(t, expected, actual, epsilon, msgAndArgs...) { 752 return 753 } 754 t.FailNow() 755} 756 757// InEpsilonSlicef is the same as InEpsilon, except it compares each value from two slices. 758func InEpsilonSlicef(t TestingT, expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) { 759 if h, ok := t.(tHelper); ok { 760 h.Helper() 761 } 762 if assert.InEpsilonSlicef(t, expected, actual, epsilon, msg, args...) { 763 return 764 } 765 t.FailNow() 766} 767 768// InEpsilonf asserts that expected and actual have a relative error less than epsilon 769func InEpsilonf(t TestingT, expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) { 770 if h, ok := t.(tHelper); ok { 771 h.Helper() 772 } 773 if assert.InEpsilonf(t, expected, actual, epsilon, msg, args...) { 774 return 775 } 776 t.FailNow() 777} 778 779// IsType asserts that the specified objects are of the same type. 780func IsType(t TestingT, expectedType interface{}, object interface{}, msgAndArgs ...interface{}) { 781 if h, ok := t.(tHelper); ok { 782 h.Helper() 783 } 784 if assert.IsType(t, expectedType, object, msgAndArgs...) { 785 return 786 } 787 t.FailNow() 788} 789 790// IsTypef asserts that the specified objects are of the same type. 791func IsTypef(t TestingT, expectedType interface{}, object interface{}, msg string, args ...interface{}) { 792 if h, ok := t.(tHelper); ok { 793 h.Helper() 794 } 795 if assert.IsTypef(t, expectedType, object, msg, args...) { 796 return 797 } 798 t.FailNow() 799} 800 801// JSONEq asserts that two JSON strings are equivalent. 802// 803// assert.JSONEq(t, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`) 804func JSONEq(t TestingT, expected string, actual string, msgAndArgs ...interface{}) { 805 if h, ok := t.(tHelper); ok { 806 h.Helper() 807 } 808 if assert.JSONEq(t, expected, actual, msgAndArgs...) { 809 return 810 } 811 t.FailNow() 812} 813 814// JSONEqf asserts that two JSON strings are equivalent. 815// 816// assert.JSONEqf(t, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`, "error message %s", "formatted") 817func JSONEqf(t TestingT, expected string, actual string, msg string, args ...interface{}) { 818 if h, ok := t.(tHelper); ok { 819 h.Helper() 820 } 821 if assert.JSONEqf(t, expected, actual, msg, args...) { 822 return 823 } 824 t.FailNow() 825} 826 827// Len asserts that the specified object has specific length. 828// Len also fails if the object has a type that len() not accept. 829// 830// assert.Len(t, mySlice, 3) 831func Len(t TestingT, object interface{}, length int, msgAndArgs ...interface{}) { 832 if h, ok := t.(tHelper); ok { 833 h.Helper() 834 } 835 if assert.Len(t, object, length, msgAndArgs...) { 836 return 837 } 838 t.FailNow() 839} 840 841// Lenf asserts that the specified object has specific length. 842// Lenf also fails if the object has a type that len() not accept. 843// 844// assert.Lenf(t, mySlice, 3, "error message %s", "formatted") 845func Lenf(t TestingT, object interface{}, length int, msg string, args ...interface{}) { 846 if h, ok := t.(tHelper); ok { 847 h.Helper() 848 } 849 if assert.Lenf(t, object, length, msg, args...) { 850 return 851 } 852 t.FailNow() 853} 854 855// Less asserts that the first element is less than the second 856// 857// assert.Less(t, 1, 2) 858// assert.Less(t, float64(1), float64(2)) 859// assert.Less(t, "a", "b") 860func Less(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) { 861 if h, ok := t.(tHelper); ok { 862 h.Helper() 863 } 864 if assert.Less(t, e1, e2, msgAndArgs...) { 865 return 866 } 867 t.FailNow() 868} 869 870// LessOrEqual asserts that the first element is less than or equal to the second 871// 872// assert.LessOrEqual(t, 1, 2) 873// assert.LessOrEqual(t, 2, 2) 874// assert.LessOrEqual(t, "a", "b") 875// assert.LessOrEqual(t, "b", "b") 876func LessOrEqual(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) { 877 if h, ok := t.(tHelper); ok { 878 h.Helper() 879 } 880 if assert.LessOrEqual(t, e1, e2, msgAndArgs...) { 881 return 882 } 883 t.FailNow() 884} 885 886// LessOrEqualf asserts that the first element is less than or equal to the second 887// 888// assert.LessOrEqualf(t, 1, 2, "error message %s", "formatted") 889// assert.LessOrEqualf(t, 2, 2, "error message %s", "formatted") 890// assert.LessOrEqualf(t, "a", "b", "error message %s", "formatted") 891// assert.LessOrEqualf(t, "b", "b", "error message %s", "formatted") 892func LessOrEqualf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) { 893 if h, ok := t.(tHelper); ok { 894 h.Helper() 895 } 896 if assert.LessOrEqualf(t, e1, e2, msg, args...) { 897 return 898 } 899 t.FailNow() 900} 901 902// Lessf asserts that the first element is less than the second 903// 904// assert.Lessf(t, 1, 2, "error message %s", "formatted") 905// assert.Lessf(t, float64(1, "error message %s", "formatted"), float64(2)) 906// assert.Lessf(t, "a", "b", "error message %s", "formatted") 907func Lessf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) { 908 if h, ok := t.(tHelper); ok { 909 h.Helper() 910 } 911 if assert.Lessf(t, e1, e2, msg, args...) { 912 return 913 } 914 t.FailNow() 915} 916 917// Never asserts that the given condition doesn't satisfy in waitFor time, 918// periodically checking the target function each tick. 919// 920// assert.Never(t, func() bool { return false; }, time.Second, 10*time.Millisecond) 921func Never(t TestingT, condition func() bool, waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) { 922 if h, ok := t.(tHelper); ok { 923 h.Helper() 924 } 925 if assert.Never(t, condition, waitFor, tick, msgAndArgs...) { 926 return 927 } 928 t.FailNow() 929} 930 931// Neverf asserts that the given condition doesn't satisfy in waitFor time, 932// periodically checking the target function each tick. 933// 934// assert.Neverf(t, func() bool { return false; }, time.Second, 10*time.Millisecond, "error message %s", "formatted") 935func Neverf(t TestingT, condition func() bool, waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) { 936 if h, ok := t.(tHelper); ok { 937 h.Helper() 938 } 939 if assert.Neverf(t, condition, waitFor, tick, msg, args...) { 940 return 941 } 942 t.FailNow() 943} 944 945// Nil asserts that the specified object is nil. 946// 947// assert.Nil(t, err) 948func Nil(t TestingT, object interface{}, msgAndArgs ...interface{}) { 949 if h, ok := t.(tHelper); ok { 950 h.Helper() 951 } 952 if assert.Nil(t, object, msgAndArgs...) { 953 return 954 } 955 t.FailNow() 956} 957 958// Nilf asserts that the specified object is nil. 959// 960// assert.Nilf(t, err, "error message %s", "formatted") 961func Nilf(t TestingT, object interface{}, msg string, args ...interface{}) { 962 if h, ok := t.(tHelper); ok { 963 h.Helper() 964 } 965 if assert.Nilf(t, object, msg, args...) { 966 return 967 } 968 t.FailNow() 969} 970 971// NoDirExists checks whether a directory does not exist in the given path. 972// It fails if the path points to an existing _directory_ only. 973func NoDirExists(t TestingT, path string, msgAndArgs ...interface{}) { 974 if h, ok := t.(tHelper); ok { 975 h.Helper() 976 } 977 if assert.NoDirExists(t, path, msgAndArgs...) { 978 return 979 } 980 t.FailNow() 981} 982 983// NoDirExistsf checks whether a directory does not exist in the given path. 984// It fails if the path points to an existing _directory_ only. 985func NoDirExistsf(t TestingT, path string, msg string, args ...interface{}) { 986 if h, ok := t.(tHelper); ok { 987 h.Helper() 988 } 989 if assert.NoDirExistsf(t, path, msg, args...) { 990 return 991 } 992 t.FailNow() 993} 994 995// NoError asserts that a function returned no error (i.e. `nil`). 996// 997// actualObj, err := SomeFunction() 998// if assert.NoError(t, err) { 999// assert.Equal(t, expectedObj, actualObj) 1000// } 1001func NoError(t TestingT, err error, msgAndArgs ...interface{}) { 1002 if h, ok := t.(tHelper); ok { 1003 h.Helper() 1004 } 1005 if assert.NoError(t, err, msgAndArgs...) { 1006 return 1007 } 1008 t.FailNow() 1009} 1010 1011// NoErrorf asserts that a function returned no error (i.e. `nil`). 1012// 1013// actualObj, err := SomeFunction() 1014// if assert.NoErrorf(t, err, "error message %s", "formatted") { 1015// assert.Equal(t, expectedObj, actualObj) 1016// } 1017func NoErrorf(t TestingT, err error, msg string, args ...interface{}) { 1018 if h, ok := t.(tHelper); ok { 1019 h.Helper() 1020 } 1021 if assert.NoErrorf(t, err, msg, args...) { 1022 return 1023 } 1024 t.FailNow() 1025} 1026 1027// NoFileExists checks whether a file does not exist in a given path. It fails 1028// if the path points to an existing _file_ only. 1029func NoFileExists(t TestingT, path string, msgAndArgs ...interface{}) { 1030 if h, ok := t.(tHelper); ok { 1031 h.Helper() 1032 } 1033 if assert.NoFileExists(t, path, msgAndArgs...) { 1034 return 1035 } 1036 t.FailNow() 1037} 1038 1039// NoFileExistsf checks whether a file does not exist in a given path. It fails 1040// if the path points to an existing _file_ only. 1041func NoFileExistsf(t TestingT, path string, msg string, args ...interface{}) { 1042 if h, ok := t.(tHelper); ok { 1043 h.Helper() 1044 } 1045 if assert.NoFileExistsf(t, path, msg, args...) { 1046 return 1047 } 1048 t.FailNow() 1049} 1050 1051// NotContains asserts that the specified string, list(array, slice...) or map does NOT contain the 1052// specified substring or element. 1053// 1054// assert.NotContains(t, "Hello World", "Earth") 1055// assert.NotContains(t, ["Hello", "World"], "Earth") 1056// assert.NotContains(t, {"Hello": "World"}, "Earth") 1057func NotContains(t TestingT, s interface{}, contains interface{}, msgAndArgs ...interface{}) { 1058 if h, ok := t.(tHelper); ok { 1059 h.Helper() 1060 } 1061 if assert.NotContains(t, s, contains, msgAndArgs...) { 1062 return 1063 } 1064 t.FailNow() 1065} 1066 1067// NotContainsf asserts that the specified string, list(array, slice...) or map does NOT contain the 1068// specified substring or element. 1069// 1070// assert.NotContainsf(t, "Hello World", "Earth", "error message %s", "formatted") 1071// assert.NotContainsf(t, ["Hello", "World"], "Earth", "error message %s", "formatted") 1072// assert.NotContainsf(t, {"Hello": "World"}, "Earth", "error message %s", "formatted") 1073func NotContainsf(t TestingT, s interface{}, contains interface{}, msg string, args ...interface{}) { 1074 if h, ok := t.(tHelper); ok { 1075 h.Helper() 1076 } 1077 if assert.NotContainsf(t, s, contains, msg, args...) { 1078 return 1079 } 1080 t.FailNow() 1081} 1082 1083// NotEmpty asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either 1084// a slice or a channel with len == 0. 1085// 1086// if assert.NotEmpty(t, obj) { 1087// assert.Equal(t, "two", obj[1]) 1088// } 1089func NotEmpty(t TestingT, object interface{}, msgAndArgs ...interface{}) { 1090 if h, ok := t.(tHelper); ok { 1091 h.Helper() 1092 } 1093 if assert.NotEmpty(t, object, msgAndArgs...) { 1094 return 1095 } 1096 t.FailNow() 1097} 1098 1099// NotEmptyf asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either 1100// a slice or a channel with len == 0. 1101// 1102// if assert.NotEmptyf(t, obj, "error message %s", "formatted") { 1103// assert.Equal(t, "two", obj[1]) 1104// } 1105func NotEmptyf(t TestingT, object interface{}, msg string, args ...interface{}) { 1106 if h, ok := t.(tHelper); ok { 1107 h.Helper() 1108 } 1109 if assert.NotEmptyf(t, object, msg, args...) { 1110 return 1111 } 1112 t.FailNow() 1113} 1114 1115// NotEqual asserts that the specified values are NOT equal. 1116// 1117// assert.NotEqual(t, obj1, obj2) 1118// 1119// Pointer variable equality is determined based on the equality of the 1120// referenced values (as opposed to the memory addresses). 1121func NotEqual(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) { 1122 if h, ok := t.(tHelper); ok { 1123 h.Helper() 1124 } 1125 if assert.NotEqual(t, expected, actual, msgAndArgs...) { 1126 return 1127 } 1128 t.FailNow() 1129} 1130 1131// NotEqualf asserts that the specified values are NOT equal. 1132// 1133// assert.NotEqualf(t, obj1, obj2, "error message %s", "formatted") 1134// 1135// Pointer variable equality is determined based on the equality of the 1136// referenced values (as opposed to the memory addresses). 1137func NotEqualf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) { 1138 if h, ok := t.(tHelper); ok { 1139 h.Helper() 1140 } 1141 if assert.NotEqualf(t, expected, actual, msg, args...) { 1142 return 1143 } 1144 t.FailNow() 1145} 1146 1147// NotNil asserts that the specified object is not nil. 1148// 1149// assert.NotNil(t, err) 1150func NotNil(t TestingT, object interface{}, msgAndArgs ...interface{}) { 1151 if h, ok := t.(tHelper); ok { 1152 h.Helper() 1153 } 1154 if assert.NotNil(t, object, msgAndArgs...) { 1155 return 1156 } 1157 t.FailNow() 1158} 1159 1160// NotNilf asserts that the specified object is not nil. 1161// 1162// assert.NotNilf(t, err, "error message %s", "formatted") 1163func NotNilf(t TestingT, object interface{}, msg string, args ...interface{}) { 1164 if h, ok := t.(tHelper); ok { 1165 h.Helper() 1166 } 1167 if assert.NotNilf(t, object, msg, args...) { 1168 return 1169 } 1170 t.FailNow() 1171} 1172 1173// NotPanics asserts that the code inside the specified PanicTestFunc does NOT panic. 1174// 1175// assert.NotPanics(t, func(){ RemainCalm() }) 1176func NotPanics(t TestingT, f assert.PanicTestFunc, msgAndArgs ...interface{}) { 1177 if h, ok := t.(tHelper); ok { 1178 h.Helper() 1179 } 1180 if assert.NotPanics(t, f, msgAndArgs...) { 1181 return 1182 } 1183 t.FailNow() 1184} 1185 1186// NotPanicsf asserts that the code inside the specified PanicTestFunc does NOT panic. 1187// 1188// assert.NotPanicsf(t, func(){ RemainCalm() }, "error message %s", "formatted") 1189func NotPanicsf(t TestingT, f assert.PanicTestFunc, msg string, args ...interface{}) { 1190 if h, ok := t.(tHelper); ok { 1191 h.Helper() 1192 } 1193 if assert.NotPanicsf(t, f, msg, args...) { 1194 return 1195 } 1196 t.FailNow() 1197} 1198 1199// NotRegexp asserts that a specified regexp does not match a string. 1200// 1201// assert.NotRegexp(t, regexp.MustCompile("starts"), "it's starting") 1202// assert.NotRegexp(t, "^start", "it's not starting") 1203func NotRegexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ...interface{}) { 1204 if h, ok := t.(tHelper); ok { 1205 h.Helper() 1206 } 1207 if assert.NotRegexp(t, rx, str, msgAndArgs...) { 1208 return 1209 } 1210 t.FailNow() 1211} 1212 1213// NotRegexpf asserts that a specified regexp does not match a string. 1214// 1215// assert.NotRegexpf(t, regexp.MustCompile("starts", "error message %s", "formatted"), "it's starting") 1216// assert.NotRegexpf(t, "^start", "it's not starting", "error message %s", "formatted") 1217func NotRegexpf(t TestingT, rx interface{}, str interface{}, msg string, args ...interface{}) { 1218 if h, ok := t.(tHelper); ok { 1219 h.Helper() 1220 } 1221 if assert.NotRegexpf(t, rx, str, msg, args...) { 1222 return 1223 } 1224 t.FailNow() 1225} 1226 1227// NotSame asserts that two pointers do not reference the same object. 1228// 1229// assert.NotSame(t, ptr1, ptr2) 1230// 1231// Both arguments must be pointer variables. Pointer variable sameness is 1232// determined based on the equality of both type and value. 1233func NotSame(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) { 1234 if h, ok := t.(tHelper); ok { 1235 h.Helper() 1236 } 1237 if assert.NotSame(t, expected, actual, msgAndArgs...) { 1238 return 1239 } 1240 t.FailNow() 1241} 1242 1243// NotSamef asserts that two pointers do not reference the same object. 1244// 1245// assert.NotSamef(t, ptr1, ptr2, "error message %s", "formatted") 1246// 1247// Both arguments must be pointer variables. Pointer variable sameness is 1248// determined based on the equality of both type and value. 1249func NotSamef(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) { 1250 if h, ok := t.(tHelper); ok { 1251 h.Helper() 1252 } 1253 if assert.NotSamef(t, expected, actual, msg, args...) { 1254 return 1255 } 1256 t.FailNow() 1257} 1258 1259// NotSubset asserts that the specified list(array, slice...) contains not all 1260// elements given in the specified subset(array, slice...). 1261// 1262// assert.NotSubset(t, [1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]") 1263func NotSubset(t TestingT, list interface{}, subset interface{}, msgAndArgs ...interface{}) { 1264 if h, ok := t.(tHelper); ok { 1265 h.Helper() 1266 } 1267 if assert.NotSubset(t, list, subset, msgAndArgs...) { 1268 return 1269 } 1270 t.FailNow() 1271} 1272 1273// NotSubsetf asserts that the specified list(array, slice...) contains not all 1274// elements given in the specified subset(array, slice...). 1275// 1276// assert.NotSubsetf(t, [1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]", "error message %s", "formatted") 1277func NotSubsetf(t TestingT, list interface{}, subset interface{}, msg string, args ...interface{}) { 1278 if h, ok := t.(tHelper); ok { 1279 h.Helper() 1280 } 1281 if assert.NotSubsetf(t, list, subset, msg, args...) { 1282 return 1283 } 1284 t.FailNow() 1285} 1286 1287// NotZero asserts that i is not the zero value for its type. 1288func NotZero(t TestingT, i interface{}, msgAndArgs ...interface{}) { 1289 if h, ok := t.(tHelper); ok { 1290 h.Helper() 1291 } 1292 if assert.NotZero(t, i, msgAndArgs...) { 1293 return 1294 } 1295 t.FailNow() 1296} 1297 1298// NotZerof asserts that i is not the zero value for its type. 1299func NotZerof(t TestingT, i interface{}, msg string, args ...interface{}) { 1300 if h, ok := t.(tHelper); ok { 1301 h.Helper() 1302 } 1303 if assert.NotZerof(t, i, msg, args...) { 1304 return 1305 } 1306 t.FailNow() 1307} 1308 1309// Panics asserts that the code inside the specified PanicTestFunc panics. 1310// 1311// assert.Panics(t, func(){ GoCrazy() }) 1312func Panics(t TestingT, f assert.PanicTestFunc, msgAndArgs ...interface{}) { 1313 if h, ok := t.(tHelper); ok { 1314 h.Helper() 1315 } 1316 if assert.Panics(t, f, msgAndArgs...) { 1317 return 1318 } 1319 t.FailNow() 1320} 1321 1322// PanicsWithError asserts that the code inside the specified PanicTestFunc 1323// panics, and that the recovered panic value is an error that satisfies the 1324// EqualError comparison. 1325// 1326// assert.PanicsWithError(t, "crazy error", func(){ GoCrazy() }) 1327func PanicsWithError(t TestingT, errString string, f assert.PanicTestFunc, msgAndArgs ...interface{}) { 1328 if h, ok := t.(tHelper); ok { 1329 h.Helper() 1330 } 1331 if assert.PanicsWithError(t, errString, f, msgAndArgs...) { 1332 return 1333 } 1334 t.FailNow() 1335} 1336 1337// PanicsWithErrorf asserts that the code inside the specified PanicTestFunc 1338// panics, and that the recovered panic value is an error that satisfies the 1339// EqualError comparison. 1340// 1341// assert.PanicsWithErrorf(t, "crazy error", func(){ GoCrazy() }, "error message %s", "formatted") 1342func PanicsWithErrorf(t TestingT, errString string, f assert.PanicTestFunc, msg string, args ...interface{}) { 1343 if h, ok := t.(tHelper); ok { 1344 h.Helper() 1345 } 1346 if assert.PanicsWithErrorf(t, errString, f, msg, args...) { 1347 return 1348 } 1349 t.FailNow() 1350} 1351 1352// PanicsWithValue asserts that the code inside the specified PanicTestFunc panics, and that 1353// the recovered panic value equals the expected panic value. 1354// 1355// assert.PanicsWithValue(t, "crazy error", func(){ GoCrazy() }) 1356func PanicsWithValue(t TestingT, expected interface{}, f assert.PanicTestFunc, msgAndArgs ...interface{}) { 1357 if h, ok := t.(tHelper); ok { 1358 h.Helper() 1359 } 1360 if assert.PanicsWithValue(t, expected, f, msgAndArgs...) { 1361 return 1362 } 1363 t.FailNow() 1364} 1365 1366// PanicsWithValuef asserts that the code inside the specified PanicTestFunc panics, and that 1367// the recovered panic value equals the expected panic value. 1368// 1369// assert.PanicsWithValuef(t, "crazy error", func(){ GoCrazy() }, "error message %s", "formatted") 1370func PanicsWithValuef(t TestingT, expected interface{}, f assert.PanicTestFunc, msg string, args ...interface{}) { 1371 if h, ok := t.(tHelper); ok { 1372 h.Helper() 1373 } 1374 if assert.PanicsWithValuef(t, expected, f, msg, args...) { 1375 return 1376 } 1377 t.FailNow() 1378} 1379 1380// Panicsf asserts that the code inside the specified PanicTestFunc panics. 1381// 1382// assert.Panicsf(t, func(){ GoCrazy() }, "error message %s", "formatted") 1383func Panicsf(t TestingT, f assert.PanicTestFunc, msg string, args ...interface{}) { 1384 if h, ok := t.(tHelper); ok { 1385 h.Helper() 1386 } 1387 if assert.Panicsf(t, f, msg, args...) { 1388 return 1389 } 1390 t.FailNow() 1391} 1392 1393// Regexp asserts that a specified regexp matches a string. 1394// 1395// assert.Regexp(t, regexp.MustCompile("start"), "it's starting") 1396// assert.Regexp(t, "start...$", "it's not starting") 1397func Regexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ...interface{}) { 1398 if h, ok := t.(tHelper); ok { 1399 h.Helper() 1400 } 1401 if assert.Regexp(t, rx, str, msgAndArgs...) { 1402 return 1403 } 1404 t.FailNow() 1405} 1406 1407// Regexpf asserts that a specified regexp matches a string. 1408// 1409// assert.Regexpf(t, regexp.MustCompile("start", "error message %s", "formatted"), "it's starting") 1410// assert.Regexpf(t, "start...$", "it's not starting", "error message %s", "formatted") 1411func Regexpf(t TestingT, rx interface{}, str interface{}, msg string, args ...interface{}) { 1412 if h, ok := t.(tHelper); ok { 1413 h.Helper() 1414 } 1415 if assert.Regexpf(t, rx, str, msg, args...) { 1416 return 1417 } 1418 t.FailNow() 1419} 1420 1421// Same asserts that two pointers reference the same object. 1422// 1423// assert.Same(t, ptr1, ptr2) 1424// 1425// Both arguments must be pointer variables. Pointer variable sameness is 1426// determined based on the equality of both type and value. 1427func Same(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) { 1428 if h, ok := t.(tHelper); ok { 1429 h.Helper() 1430 } 1431 if assert.Same(t, expected, actual, msgAndArgs...) { 1432 return 1433 } 1434 t.FailNow() 1435} 1436 1437// Samef asserts that two pointers reference the same object. 1438// 1439// assert.Samef(t, ptr1, ptr2, "error message %s", "formatted") 1440// 1441// Both arguments must be pointer variables. Pointer variable sameness is 1442// determined based on the equality of both type and value. 1443func Samef(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) { 1444 if h, ok := t.(tHelper); ok { 1445 h.Helper() 1446 } 1447 if assert.Samef(t, expected, actual, msg, args...) { 1448 return 1449 } 1450 t.FailNow() 1451} 1452 1453// Subset asserts that the specified list(array, slice...) contains all 1454// elements given in the specified subset(array, slice...). 1455// 1456// assert.Subset(t, [1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]") 1457func Subset(t TestingT, list interface{}, subset interface{}, msgAndArgs ...interface{}) { 1458 if h, ok := t.(tHelper); ok { 1459 h.Helper() 1460 } 1461 if assert.Subset(t, list, subset, msgAndArgs...) { 1462 return 1463 } 1464 t.FailNow() 1465} 1466 1467// Subsetf asserts that the specified list(array, slice...) contains all 1468// elements given in the specified subset(array, slice...). 1469// 1470// assert.Subsetf(t, [1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]", "error message %s", "formatted") 1471func Subsetf(t TestingT, list interface{}, subset interface{}, msg string, args ...interface{}) { 1472 if h, ok := t.(tHelper); ok { 1473 h.Helper() 1474 } 1475 if assert.Subsetf(t, list, subset, msg, args...) { 1476 return 1477 } 1478 t.FailNow() 1479} 1480 1481// True asserts that the specified value is true. 1482// 1483// assert.True(t, myBool) 1484func True(t TestingT, value bool, msgAndArgs ...interface{}) { 1485 if h, ok := t.(tHelper); ok { 1486 h.Helper() 1487 } 1488 if assert.True(t, value, msgAndArgs...) { 1489 return 1490 } 1491 t.FailNow() 1492} 1493 1494// Truef asserts that the specified value is true. 1495// 1496// assert.Truef(t, myBool, "error message %s", "formatted") 1497func Truef(t TestingT, value bool, msg string, args ...interface{}) { 1498 if h, ok := t.(tHelper); ok { 1499 h.Helper() 1500 } 1501 if assert.Truef(t, value, msg, args...) { 1502 return 1503 } 1504 t.FailNow() 1505} 1506 1507// WithinDuration asserts that the two times are within duration delta of each other. 1508// 1509// assert.WithinDuration(t, time.Now(), time.Now(), 10*time.Second) 1510func WithinDuration(t TestingT, expected time.Time, actual time.Time, delta time.Duration, msgAndArgs ...interface{}) { 1511 if h, ok := t.(tHelper); ok { 1512 h.Helper() 1513 } 1514 if assert.WithinDuration(t, expected, actual, delta, msgAndArgs...) { 1515 return 1516 } 1517 t.FailNow() 1518} 1519 1520// WithinDurationf asserts that the two times are within duration delta of each other. 1521// 1522// assert.WithinDurationf(t, time.Now(), time.Now(), 10*time.Second, "error message %s", "formatted") 1523func WithinDurationf(t TestingT, expected time.Time, actual time.Time, delta time.Duration, msg string, args ...interface{}) { 1524 if h, ok := t.(tHelper); ok { 1525 h.Helper() 1526 } 1527 if assert.WithinDurationf(t, expected, actual, delta, msg, args...) { 1528 return 1529 } 1530 t.FailNow() 1531} 1532 1533// YAMLEq asserts that two YAML strings are equivalent. 1534func YAMLEq(t TestingT, expected string, actual string, msgAndArgs ...interface{}) { 1535 if h, ok := t.(tHelper); ok { 1536 h.Helper() 1537 } 1538 if assert.YAMLEq(t, expected, actual, msgAndArgs...) { 1539 return 1540 } 1541 t.FailNow() 1542} 1543 1544// YAMLEqf asserts that two YAML strings are equivalent. 1545func YAMLEqf(t TestingT, expected string, actual string, msg string, args ...interface{}) { 1546 if h, ok := t.(tHelper); ok { 1547 h.Helper() 1548 } 1549 if assert.YAMLEqf(t, expected, actual, msg, args...) { 1550 return 1551 } 1552 t.FailNow() 1553} 1554 1555// Zero asserts that i is the zero value for its type. 1556func Zero(t TestingT, i interface{}, msgAndArgs ...interface{}) { 1557 if h, ok := t.(tHelper); ok { 1558 h.Helper() 1559 } 1560 if assert.Zero(t, i, msgAndArgs...) { 1561 return 1562 } 1563 t.FailNow() 1564} 1565 1566// Zerof asserts that i is the zero value for its type. 1567func Zerof(t TestingT, i interface{}, msg string, args ...interface{}) { 1568 if h, ok := t.(tHelper); ok { 1569 h.Helper() 1570 } 1571 if assert.Zerof(t, i, msg, args...) { 1572 return 1573 } 1574 t.FailNow() 1575} 1576