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), int32(123), "error message %s", "formatted") 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), int64(123), "error message %s", "formatted") 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), float64(1), "error message %s", "formatted") 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) 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) 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// HTTPStatusCode asserts that a specified handler returns a specified status code. 610// 611// assert.HTTPStatusCode(t, myHandler, "GET", "/notImplemented", nil, 501) 612// 613// Returns whether the assertion was successful (true) or not (false). 614func HTTPStatusCode(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, statuscode int, msgAndArgs ...interface{}) { 615 if h, ok := t.(tHelper); ok { 616 h.Helper() 617 } 618 if assert.HTTPStatusCode(t, handler, method, url, values, statuscode, msgAndArgs...) { 619 return 620 } 621 t.FailNow() 622} 623 624// HTTPStatusCodef asserts that a specified handler returns a specified status code. 625// 626// assert.HTTPStatusCodef(t, myHandler, "GET", "/notImplemented", nil, 501, "error message %s", "formatted") 627// 628// Returns whether the assertion was successful (true) or not (false). 629func HTTPStatusCodef(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, statuscode int, msg string, args ...interface{}) { 630 if h, ok := t.(tHelper); ok { 631 h.Helper() 632 } 633 if assert.HTTPStatusCodef(t, handler, method, url, values, statuscode, msg, args...) { 634 return 635 } 636 t.FailNow() 637} 638 639// HTTPSuccess asserts that a specified handler returns a success status code. 640// 641// assert.HTTPSuccess(t, myHandler, "POST", "http://www.google.com", nil) 642// 643// Returns whether the assertion was successful (true) or not (false). 644func HTTPSuccess(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) { 645 if h, ok := t.(tHelper); ok { 646 h.Helper() 647 } 648 if assert.HTTPSuccess(t, handler, method, url, values, msgAndArgs...) { 649 return 650 } 651 t.FailNow() 652} 653 654// HTTPSuccessf asserts that a specified handler returns a success status code. 655// 656// assert.HTTPSuccessf(t, myHandler, "POST", "http://www.google.com", nil, "error message %s", "formatted") 657// 658// Returns whether the assertion was successful (true) or not (false). 659func HTTPSuccessf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) { 660 if h, ok := t.(tHelper); ok { 661 h.Helper() 662 } 663 if assert.HTTPSuccessf(t, handler, method, url, values, msg, args...) { 664 return 665 } 666 t.FailNow() 667} 668 669// Implements asserts that an object is implemented by the specified interface. 670// 671// assert.Implements(t, (*MyInterface)(nil), new(MyObject)) 672func Implements(t TestingT, interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) { 673 if h, ok := t.(tHelper); ok { 674 h.Helper() 675 } 676 if assert.Implements(t, interfaceObject, object, msgAndArgs...) { 677 return 678 } 679 t.FailNow() 680} 681 682// Implementsf asserts that an object is implemented by the specified interface. 683// 684// assert.Implementsf(t, (*MyInterface)(nil), new(MyObject), "error message %s", "formatted") 685func Implementsf(t TestingT, interfaceObject interface{}, object interface{}, msg string, args ...interface{}) { 686 if h, ok := t.(tHelper); ok { 687 h.Helper() 688 } 689 if assert.Implementsf(t, interfaceObject, object, msg, args...) { 690 return 691 } 692 t.FailNow() 693} 694 695// InDelta asserts that the two numerals are within delta of each other. 696// 697// assert.InDelta(t, math.Pi, 22/7.0, 0.01) 698func InDelta(t TestingT, expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) { 699 if h, ok := t.(tHelper); ok { 700 h.Helper() 701 } 702 if assert.InDelta(t, expected, actual, delta, msgAndArgs...) { 703 return 704 } 705 t.FailNow() 706} 707 708// InDeltaMapValues is the same as InDelta, but it compares all values between two maps. Both maps must have exactly the same keys. 709func InDeltaMapValues(t TestingT, expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) { 710 if h, ok := t.(tHelper); ok { 711 h.Helper() 712 } 713 if assert.InDeltaMapValues(t, expected, actual, delta, msgAndArgs...) { 714 return 715 } 716 t.FailNow() 717} 718 719// InDeltaMapValuesf is the same as InDelta, but it compares all values between two maps. Both maps must have exactly the same keys. 720func InDeltaMapValuesf(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) { 721 if h, ok := t.(tHelper); ok { 722 h.Helper() 723 } 724 if assert.InDeltaMapValuesf(t, expected, actual, delta, msg, args...) { 725 return 726 } 727 t.FailNow() 728} 729 730// InDeltaSlice is the same as InDelta, except it compares two slices. 731func InDeltaSlice(t TestingT, expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) { 732 if h, ok := t.(tHelper); ok { 733 h.Helper() 734 } 735 if assert.InDeltaSlice(t, expected, actual, delta, msgAndArgs...) { 736 return 737 } 738 t.FailNow() 739} 740 741// InDeltaSlicef is the same as InDelta, except it compares two slices. 742func InDeltaSlicef(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) { 743 if h, ok := t.(tHelper); ok { 744 h.Helper() 745 } 746 if assert.InDeltaSlicef(t, expected, actual, delta, msg, args...) { 747 return 748 } 749 t.FailNow() 750} 751 752// InDeltaf asserts that the two numerals are within delta of each other. 753// 754// assert.InDeltaf(t, math.Pi, 22/7.0, 0.01, "error message %s", "formatted") 755func InDeltaf(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) { 756 if h, ok := t.(tHelper); ok { 757 h.Helper() 758 } 759 if assert.InDeltaf(t, expected, actual, delta, msg, args...) { 760 return 761 } 762 t.FailNow() 763} 764 765// InEpsilon asserts that expected and actual have a relative error less than epsilon 766func InEpsilon(t TestingT, expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{}) { 767 if h, ok := t.(tHelper); ok { 768 h.Helper() 769 } 770 if assert.InEpsilon(t, expected, actual, epsilon, msgAndArgs...) { 771 return 772 } 773 t.FailNow() 774} 775 776// InEpsilonSlice is the same as InEpsilon, except it compares each value from two slices. 777func InEpsilonSlice(t TestingT, expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{}) { 778 if h, ok := t.(tHelper); ok { 779 h.Helper() 780 } 781 if assert.InEpsilonSlice(t, expected, actual, epsilon, msgAndArgs...) { 782 return 783 } 784 t.FailNow() 785} 786 787// InEpsilonSlicef is the same as InEpsilon, except it compares each value from two slices. 788func InEpsilonSlicef(t TestingT, expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) { 789 if h, ok := t.(tHelper); ok { 790 h.Helper() 791 } 792 if assert.InEpsilonSlicef(t, expected, actual, epsilon, msg, args...) { 793 return 794 } 795 t.FailNow() 796} 797 798// InEpsilonf asserts that expected and actual have a relative error less than epsilon 799func InEpsilonf(t TestingT, expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) { 800 if h, ok := t.(tHelper); ok { 801 h.Helper() 802 } 803 if assert.InEpsilonf(t, expected, actual, epsilon, msg, args...) { 804 return 805 } 806 t.FailNow() 807} 808 809// IsType asserts that the specified objects are of the same type. 810func IsType(t TestingT, expectedType interface{}, object interface{}, msgAndArgs ...interface{}) { 811 if h, ok := t.(tHelper); ok { 812 h.Helper() 813 } 814 if assert.IsType(t, expectedType, object, msgAndArgs...) { 815 return 816 } 817 t.FailNow() 818} 819 820// IsTypef asserts that the specified objects are of the same type. 821func IsTypef(t TestingT, expectedType interface{}, object interface{}, msg string, args ...interface{}) { 822 if h, ok := t.(tHelper); ok { 823 h.Helper() 824 } 825 if assert.IsTypef(t, expectedType, object, msg, args...) { 826 return 827 } 828 t.FailNow() 829} 830 831// JSONEq asserts that two JSON strings are equivalent. 832// 833// assert.JSONEq(t, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`) 834func JSONEq(t TestingT, expected string, actual string, msgAndArgs ...interface{}) { 835 if h, ok := t.(tHelper); ok { 836 h.Helper() 837 } 838 if assert.JSONEq(t, expected, actual, msgAndArgs...) { 839 return 840 } 841 t.FailNow() 842} 843 844// JSONEqf asserts that two JSON strings are equivalent. 845// 846// assert.JSONEqf(t, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`, "error message %s", "formatted") 847func JSONEqf(t TestingT, expected string, actual string, msg string, args ...interface{}) { 848 if h, ok := t.(tHelper); ok { 849 h.Helper() 850 } 851 if assert.JSONEqf(t, expected, actual, msg, args...) { 852 return 853 } 854 t.FailNow() 855} 856 857// Len asserts that the specified object has specific length. 858// Len also fails if the object has a type that len() not accept. 859// 860// assert.Len(t, mySlice, 3) 861func Len(t TestingT, object interface{}, length int, msgAndArgs ...interface{}) { 862 if h, ok := t.(tHelper); ok { 863 h.Helper() 864 } 865 if assert.Len(t, object, length, msgAndArgs...) { 866 return 867 } 868 t.FailNow() 869} 870 871// Lenf asserts that the specified object has specific length. 872// Lenf also fails if the object has a type that len() not accept. 873// 874// assert.Lenf(t, mySlice, 3, "error message %s", "formatted") 875func Lenf(t TestingT, object interface{}, length int, msg string, args ...interface{}) { 876 if h, ok := t.(tHelper); ok { 877 h.Helper() 878 } 879 if assert.Lenf(t, object, length, msg, args...) { 880 return 881 } 882 t.FailNow() 883} 884 885// Less asserts that the first element is less than the second 886// 887// assert.Less(t, 1, 2) 888// assert.Less(t, float64(1), float64(2)) 889// assert.Less(t, "a", "b") 890func Less(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) { 891 if h, ok := t.(tHelper); ok { 892 h.Helper() 893 } 894 if assert.Less(t, e1, e2, msgAndArgs...) { 895 return 896 } 897 t.FailNow() 898} 899 900// LessOrEqual asserts that the first element is less than or equal to the second 901// 902// assert.LessOrEqual(t, 1, 2) 903// assert.LessOrEqual(t, 2, 2) 904// assert.LessOrEqual(t, "a", "b") 905// assert.LessOrEqual(t, "b", "b") 906func LessOrEqual(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) { 907 if h, ok := t.(tHelper); ok { 908 h.Helper() 909 } 910 if assert.LessOrEqual(t, e1, e2, msgAndArgs...) { 911 return 912 } 913 t.FailNow() 914} 915 916// LessOrEqualf asserts that the first element is less than or equal to the second 917// 918// assert.LessOrEqualf(t, 1, 2, "error message %s", "formatted") 919// assert.LessOrEqualf(t, 2, 2, "error message %s", "formatted") 920// assert.LessOrEqualf(t, "a", "b", "error message %s", "formatted") 921// assert.LessOrEqualf(t, "b", "b", "error message %s", "formatted") 922func LessOrEqualf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) { 923 if h, ok := t.(tHelper); ok { 924 h.Helper() 925 } 926 if assert.LessOrEqualf(t, e1, e2, msg, args...) { 927 return 928 } 929 t.FailNow() 930} 931 932// Lessf asserts that the first element is less than the second 933// 934// assert.Lessf(t, 1, 2, "error message %s", "formatted") 935// assert.Lessf(t, float64(1), float64(2), "error message %s", "formatted") 936// assert.Lessf(t, "a", "b", "error message %s", "formatted") 937func Lessf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) { 938 if h, ok := t.(tHelper); ok { 939 h.Helper() 940 } 941 if assert.Lessf(t, e1, e2, msg, args...) { 942 return 943 } 944 t.FailNow() 945} 946 947// Never asserts that the given condition doesn't satisfy in waitFor time, 948// periodically checking the target function each tick. 949// 950// assert.Never(t, func() bool { return false; }, time.Second, 10*time.Millisecond) 951func Never(t TestingT, condition func() bool, waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) { 952 if h, ok := t.(tHelper); ok { 953 h.Helper() 954 } 955 if assert.Never(t, condition, waitFor, tick, msgAndArgs...) { 956 return 957 } 958 t.FailNow() 959} 960 961// Neverf asserts that the given condition doesn't satisfy in waitFor time, 962// periodically checking the target function each tick. 963// 964// assert.Neverf(t, func() bool { return false; }, time.Second, 10*time.Millisecond, "error message %s", "formatted") 965func Neverf(t TestingT, condition func() bool, waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) { 966 if h, ok := t.(tHelper); ok { 967 h.Helper() 968 } 969 if assert.Neverf(t, condition, waitFor, tick, msg, args...) { 970 return 971 } 972 t.FailNow() 973} 974 975// Nil asserts that the specified object is nil. 976// 977// assert.Nil(t, err) 978func Nil(t TestingT, object interface{}, msgAndArgs ...interface{}) { 979 if h, ok := t.(tHelper); ok { 980 h.Helper() 981 } 982 if assert.Nil(t, object, msgAndArgs...) { 983 return 984 } 985 t.FailNow() 986} 987 988// Nilf asserts that the specified object is nil. 989// 990// assert.Nilf(t, err, "error message %s", "formatted") 991func Nilf(t TestingT, object interface{}, msg string, args ...interface{}) { 992 if h, ok := t.(tHelper); ok { 993 h.Helper() 994 } 995 if assert.Nilf(t, object, msg, args...) { 996 return 997 } 998 t.FailNow() 999} 1000 1001// NoDirExists checks whether a directory does not exist in the given path. 1002// It fails if the path points to an existing _directory_ only. 1003func NoDirExists(t TestingT, path string, msgAndArgs ...interface{}) { 1004 if h, ok := t.(tHelper); ok { 1005 h.Helper() 1006 } 1007 if assert.NoDirExists(t, path, msgAndArgs...) { 1008 return 1009 } 1010 t.FailNow() 1011} 1012 1013// NoDirExistsf checks whether a directory does not exist in the given path. 1014// It fails if the path points to an existing _directory_ only. 1015func NoDirExistsf(t TestingT, path string, msg string, args ...interface{}) { 1016 if h, ok := t.(tHelper); ok { 1017 h.Helper() 1018 } 1019 if assert.NoDirExistsf(t, path, msg, args...) { 1020 return 1021 } 1022 t.FailNow() 1023} 1024 1025// NoError asserts that a function returned no error (i.e. `nil`). 1026// 1027// actualObj, err := SomeFunction() 1028// if assert.NoError(t, err) { 1029// assert.Equal(t, expectedObj, actualObj) 1030// } 1031func NoError(t TestingT, err error, msgAndArgs ...interface{}) { 1032 if h, ok := t.(tHelper); ok { 1033 h.Helper() 1034 } 1035 if assert.NoError(t, err, msgAndArgs...) { 1036 return 1037 } 1038 t.FailNow() 1039} 1040 1041// NoErrorf asserts that a function returned no error (i.e. `nil`). 1042// 1043// actualObj, err := SomeFunction() 1044// if assert.NoErrorf(t, err, "error message %s", "formatted") { 1045// assert.Equal(t, expectedObj, actualObj) 1046// } 1047func NoErrorf(t TestingT, err error, msg string, args ...interface{}) { 1048 if h, ok := t.(tHelper); ok { 1049 h.Helper() 1050 } 1051 if assert.NoErrorf(t, err, msg, args...) { 1052 return 1053 } 1054 t.FailNow() 1055} 1056 1057// NoFileExists checks whether a file does not exist in a given path. It fails 1058// if the path points to an existing _file_ only. 1059func NoFileExists(t TestingT, path string, msgAndArgs ...interface{}) { 1060 if h, ok := t.(tHelper); ok { 1061 h.Helper() 1062 } 1063 if assert.NoFileExists(t, path, msgAndArgs...) { 1064 return 1065 } 1066 t.FailNow() 1067} 1068 1069// NoFileExistsf checks whether a file does not exist in a given path. It fails 1070// if the path points to an existing _file_ only. 1071func NoFileExistsf(t TestingT, path string, msg string, args ...interface{}) { 1072 if h, ok := t.(tHelper); ok { 1073 h.Helper() 1074 } 1075 if assert.NoFileExistsf(t, path, msg, args...) { 1076 return 1077 } 1078 t.FailNow() 1079} 1080 1081// NotContains asserts that the specified string, list(array, slice...) or map does NOT contain the 1082// specified substring or element. 1083// 1084// assert.NotContains(t, "Hello World", "Earth") 1085// assert.NotContains(t, ["Hello", "World"], "Earth") 1086// assert.NotContains(t, {"Hello": "World"}, "Earth") 1087func NotContains(t TestingT, s interface{}, contains interface{}, msgAndArgs ...interface{}) { 1088 if h, ok := t.(tHelper); ok { 1089 h.Helper() 1090 } 1091 if assert.NotContains(t, s, contains, msgAndArgs...) { 1092 return 1093 } 1094 t.FailNow() 1095} 1096 1097// NotContainsf asserts that the specified string, list(array, slice...) or map does NOT contain the 1098// specified substring or element. 1099// 1100// assert.NotContainsf(t, "Hello World", "Earth", "error message %s", "formatted") 1101// assert.NotContainsf(t, ["Hello", "World"], "Earth", "error message %s", "formatted") 1102// assert.NotContainsf(t, {"Hello": "World"}, "Earth", "error message %s", "formatted") 1103func NotContainsf(t TestingT, s interface{}, contains interface{}, msg string, args ...interface{}) { 1104 if h, ok := t.(tHelper); ok { 1105 h.Helper() 1106 } 1107 if assert.NotContainsf(t, s, contains, msg, args...) { 1108 return 1109 } 1110 t.FailNow() 1111} 1112 1113// NotEmpty asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either 1114// a slice or a channel with len == 0. 1115// 1116// if assert.NotEmpty(t, obj) { 1117// assert.Equal(t, "two", obj[1]) 1118// } 1119func NotEmpty(t TestingT, object interface{}, msgAndArgs ...interface{}) { 1120 if h, ok := t.(tHelper); ok { 1121 h.Helper() 1122 } 1123 if assert.NotEmpty(t, object, msgAndArgs...) { 1124 return 1125 } 1126 t.FailNow() 1127} 1128 1129// NotEmptyf asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either 1130// a slice or a channel with len == 0. 1131// 1132// if assert.NotEmptyf(t, obj, "error message %s", "formatted") { 1133// assert.Equal(t, "two", obj[1]) 1134// } 1135func NotEmptyf(t TestingT, object interface{}, msg string, args ...interface{}) { 1136 if h, ok := t.(tHelper); ok { 1137 h.Helper() 1138 } 1139 if assert.NotEmptyf(t, object, msg, args...) { 1140 return 1141 } 1142 t.FailNow() 1143} 1144 1145// NotEqual asserts that the specified values are NOT equal. 1146// 1147// assert.NotEqual(t, obj1, obj2) 1148// 1149// Pointer variable equality is determined based on the equality of the 1150// referenced values (as opposed to the memory addresses). 1151func NotEqual(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) { 1152 if h, ok := t.(tHelper); ok { 1153 h.Helper() 1154 } 1155 if assert.NotEqual(t, expected, actual, msgAndArgs...) { 1156 return 1157 } 1158 t.FailNow() 1159} 1160 1161// NotEqualValues asserts that two objects are not equal even when converted to the same type 1162// 1163// assert.NotEqualValues(t, obj1, obj2) 1164func NotEqualValues(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) { 1165 if h, ok := t.(tHelper); ok { 1166 h.Helper() 1167 } 1168 if assert.NotEqualValues(t, expected, actual, msgAndArgs...) { 1169 return 1170 } 1171 t.FailNow() 1172} 1173 1174// NotEqualValuesf asserts that two objects are not equal even when converted to the same type 1175// 1176// assert.NotEqualValuesf(t, obj1, obj2, "error message %s", "formatted") 1177func NotEqualValuesf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) { 1178 if h, ok := t.(tHelper); ok { 1179 h.Helper() 1180 } 1181 if assert.NotEqualValuesf(t, expected, actual, msg, args...) { 1182 return 1183 } 1184 t.FailNow() 1185} 1186 1187// NotEqualf asserts that the specified values are NOT equal. 1188// 1189// assert.NotEqualf(t, obj1, obj2, "error message %s", "formatted") 1190// 1191// Pointer variable equality is determined based on the equality of the 1192// referenced values (as opposed to the memory addresses). 1193func NotEqualf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) { 1194 if h, ok := t.(tHelper); ok { 1195 h.Helper() 1196 } 1197 if assert.NotEqualf(t, expected, actual, msg, args...) { 1198 return 1199 } 1200 t.FailNow() 1201} 1202 1203// NotNil asserts that the specified object is not nil. 1204// 1205// assert.NotNil(t, err) 1206func NotNil(t TestingT, object interface{}, msgAndArgs ...interface{}) { 1207 if h, ok := t.(tHelper); ok { 1208 h.Helper() 1209 } 1210 if assert.NotNil(t, object, msgAndArgs...) { 1211 return 1212 } 1213 t.FailNow() 1214} 1215 1216// NotNilf asserts that the specified object is not nil. 1217// 1218// assert.NotNilf(t, err, "error message %s", "formatted") 1219func NotNilf(t TestingT, object interface{}, msg string, args ...interface{}) { 1220 if h, ok := t.(tHelper); ok { 1221 h.Helper() 1222 } 1223 if assert.NotNilf(t, object, msg, args...) { 1224 return 1225 } 1226 t.FailNow() 1227} 1228 1229// NotPanics asserts that the code inside the specified PanicTestFunc does NOT panic. 1230// 1231// assert.NotPanics(t, func(){ RemainCalm() }) 1232func NotPanics(t TestingT, f assert.PanicTestFunc, msgAndArgs ...interface{}) { 1233 if h, ok := t.(tHelper); ok { 1234 h.Helper() 1235 } 1236 if assert.NotPanics(t, f, msgAndArgs...) { 1237 return 1238 } 1239 t.FailNow() 1240} 1241 1242// NotPanicsf asserts that the code inside the specified PanicTestFunc does NOT panic. 1243// 1244// assert.NotPanicsf(t, func(){ RemainCalm() }, "error message %s", "formatted") 1245func NotPanicsf(t TestingT, f assert.PanicTestFunc, msg string, args ...interface{}) { 1246 if h, ok := t.(tHelper); ok { 1247 h.Helper() 1248 } 1249 if assert.NotPanicsf(t, f, msg, args...) { 1250 return 1251 } 1252 t.FailNow() 1253} 1254 1255// NotRegexp asserts that a specified regexp does not match a string. 1256// 1257// assert.NotRegexp(t, regexp.MustCompile("starts"), "it's starting") 1258// assert.NotRegexp(t, "^start", "it's not starting") 1259func NotRegexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ...interface{}) { 1260 if h, ok := t.(tHelper); ok { 1261 h.Helper() 1262 } 1263 if assert.NotRegexp(t, rx, str, msgAndArgs...) { 1264 return 1265 } 1266 t.FailNow() 1267} 1268 1269// NotRegexpf asserts that a specified regexp does not match a string. 1270// 1271// assert.NotRegexpf(t, regexp.MustCompile("starts"), "it's starting", "error message %s", "formatted") 1272// assert.NotRegexpf(t, "^start", "it's not starting", "error message %s", "formatted") 1273func NotRegexpf(t TestingT, rx interface{}, str interface{}, msg string, args ...interface{}) { 1274 if h, ok := t.(tHelper); ok { 1275 h.Helper() 1276 } 1277 if assert.NotRegexpf(t, rx, str, msg, args...) { 1278 return 1279 } 1280 t.FailNow() 1281} 1282 1283// NotSame asserts that two pointers do not reference the same object. 1284// 1285// assert.NotSame(t, ptr1, ptr2) 1286// 1287// Both arguments must be pointer variables. Pointer variable sameness is 1288// determined based on the equality of both type and value. 1289func NotSame(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) { 1290 if h, ok := t.(tHelper); ok { 1291 h.Helper() 1292 } 1293 if assert.NotSame(t, expected, actual, msgAndArgs...) { 1294 return 1295 } 1296 t.FailNow() 1297} 1298 1299// NotSamef asserts that two pointers do not reference the same object. 1300// 1301// assert.NotSamef(t, ptr1, ptr2, "error message %s", "formatted") 1302// 1303// Both arguments must be pointer variables. Pointer variable sameness is 1304// determined based on the equality of both type and value. 1305func NotSamef(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) { 1306 if h, ok := t.(tHelper); ok { 1307 h.Helper() 1308 } 1309 if assert.NotSamef(t, expected, actual, msg, args...) { 1310 return 1311 } 1312 t.FailNow() 1313} 1314 1315// NotSubset asserts that the specified list(array, slice...) contains not all 1316// elements given in the specified subset(array, slice...). 1317// 1318// assert.NotSubset(t, [1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]") 1319func NotSubset(t TestingT, list interface{}, subset interface{}, msgAndArgs ...interface{}) { 1320 if h, ok := t.(tHelper); ok { 1321 h.Helper() 1322 } 1323 if assert.NotSubset(t, list, subset, msgAndArgs...) { 1324 return 1325 } 1326 t.FailNow() 1327} 1328 1329// NotSubsetf asserts that the specified list(array, slice...) contains not all 1330// elements given in the specified subset(array, slice...). 1331// 1332// assert.NotSubsetf(t, [1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]", "error message %s", "formatted") 1333func NotSubsetf(t TestingT, list interface{}, subset interface{}, msg string, args ...interface{}) { 1334 if h, ok := t.(tHelper); ok { 1335 h.Helper() 1336 } 1337 if assert.NotSubsetf(t, list, subset, msg, args...) { 1338 return 1339 } 1340 t.FailNow() 1341} 1342 1343// NotZero asserts that i is not the zero value for its type. 1344func NotZero(t TestingT, i interface{}, msgAndArgs ...interface{}) { 1345 if h, ok := t.(tHelper); ok { 1346 h.Helper() 1347 } 1348 if assert.NotZero(t, i, msgAndArgs...) { 1349 return 1350 } 1351 t.FailNow() 1352} 1353 1354// NotZerof asserts that i is not the zero value for its type. 1355func NotZerof(t TestingT, i interface{}, msg string, args ...interface{}) { 1356 if h, ok := t.(tHelper); ok { 1357 h.Helper() 1358 } 1359 if assert.NotZerof(t, i, msg, args...) { 1360 return 1361 } 1362 t.FailNow() 1363} 1364 1365// Panics asserts that the code inside the specified PanicTestFunc panics. 1366// 1367// assert.Panics(t, func(){ GoCrazy() }) 1368func Panics(t TestingT, f assert.PanicTestFunc, msgAndArgs ...interface{}) { 1369 if h, ok := t.(tHelper); ok { 1370 h.Helper() 1371 } 1372 if assert.Panics(t, f, msgAndArgs...) { 1373 return 1374 } 1375 t.FailNow() 1376} 1377 1378// PanicsWithError asserts that the code inside the specified PanicTestFunc 1379// panics, and that the recovered panic value is an error that satisfies the 1380// EqualError comparison. 1381// 1382// assert.PanicsWithError(t, "crazy error", func(){ GoCrazy() }) 1383func PanicsWithError(t TestingT, errString string, f assert.PanicTestFunc, msgAndArgs ...interface{}) { 1384 if h, ok := t.(tHelper); ok { 1385 h.Helper() 1386 } 1387 if assert.PanicsWithError(t, errString, f, msgAndArgs...) { 1388 return 1389 } 1390 t.FailNow() 1391} 1392 1393// PanicsWithErrorf asserts that the code inside the specified PanicTestFunc 1394// panics, and that the recovered panic value is an error that satisfies the 1395// EqualError comparison. 1396// 1397// assert.PanicsWithErrorf(t, "crazy error", func(){ GoCrazy() }, "error message %s", "formatted") 1398func PanicsWithErrorf(t TestingT, errString string, f assert.PanicTestFunc, msg string, args ...interface{}) { 1399 if h, ok := t.(tHelper); ok { 1400 h.Helper() 1401 } 1402 if assert.PanicsWithErrorf(t, errString, f, msg, args...) { 1403 return 1404 } 1405 t.FailNow() 1406} 1407 1408// PanicsWithValue asserts that the code inside the specified PanicTestFunc panics, and that 1409// the recovered panic value equals the expected panic value. 1410// 1411// assert.PanicsWithValue(t, "crazy error", func(){ GoCrazy() }) 1412func PanicsWithValue(t TestingT, expected interface{}, f assert.PanicTestFunc, msgAndArgs ...interface{}) { 1413 if h, ok := t.(tHelper); ok { 1414 h.Helper() 1415 } 1416 if assert.PanicsWithValue(t, expected, f, msgAndArgs...) { 1417 return 1418 } 1419 t.FailNow() 1420} 1421 1422// PanicsWithValuef asserts that the code inside the specified PanicTestFunc panics, and that 1423// the recovered panic value equals the expected panic value. 1424// 1425// assert.PanicsWithValuef(t, "crazy error", func(){ GoCrazy() }, "error message %s", "formatted") 1426func PanicsWithValuef(t TestingT, expected interface{}, f assert.PanicTestFunc, msg string, args ...interface{}) { 1427 if h, ok := t.(tHelper); ok { 1428 h.Helper() 1429 } 1430 if assert.PanicsWithValuef(t, expected, f, msg, args...) { 1431 return 1432 } 1433 t.FailNow() 1434} 1435 1436// Panicsf asserts that the code inside the specified PanicTestFunc panics. 1437// 1438// assert.Panicsf(t, func(){ GoCrazy() }, "error message %s", "formatted") 1439func Panicsf(t TestingT, f assert.PanicTestFunc, msg string, args ...interface{}) { 1440 if h, ok := t.(tHelper); ok { 1441 h.Helper() 1442 } 1443 if assert.Panicsf(t, f, msg, args...) { 1444 return 1445 } 1446 t.FailNow() 1447} 1448 1449// Regexp asserts that a specified regexp matches a string. 1450// 1451// assert.Regexp(t, regexp.MustCompile("start"), "it's starting") 1452// assert.Regexp(t, "start...$", "it's not starting") 1453func Regexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ...interface{}) { 1454 if h, ok := t.(tHelper); ok { 1455 h.Helper() 1456 } 1457 if assert.Regexp(t, rx, str, msgAndArgs...) { 1458 return 1459 } 1460 t.FailNow() 1461} 1462 1463// Regexpf asserts that a specified regexp matches a string. 1464// 1465// assert.Regexpf(t, regexp.MustCompile("start"), "it's starting", "error message %s", "formatted") 1466// assert.Regexpf(t, "start...$", "it's not starting", "error message %s", "formatted") 1467func Regexpf(t TestingT, rx interface{}, str interface{}, msg string, args ...interface{}) { 1468 if h, ok := t.(tHelper); ok { 1469 h.Helper() 1470 } 1471 if assert.Regexpf(t, rx, str, msg, args...) { 1472 return 1473 } 1474 t.FailNow() 1475} 1476 1477// Same asserts that two pointers reference the same object. 1478// 1479// assert.Same(t, ptr1, ptr2) 1480// 1481// Both arguments must be pointer variables. Pointer variable sameness is 1482// determined based on the equality of both type and value. 1483func Same(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) { 1484 if h, ok := t.(tHelper); ok { 1485 h.Helper() 1486 } 1487 if assert.Same(t, expected, actual, msgAndArgs...) { 1488 return 1489 } 1490 t.FailNow() 1491} 1492 1493// Samef asserts that two pointers reference the same object. 1494// 1495// assert.Samef(t, ptr1, ptr2, "error message %s", "formatted") 1496// 1497// Both arguments must be pointer variables. Pointer variable sameness is 1498// determined based on the equality of both type and value. 1499func Samef(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) { 1500 if h, ok := t.(tHelper); ok { 1501 h.Helper() 1502 } 1503 if assert.Samef(t, expected, actual, msg, args...) { 1504 return 1505 } 1506 t.FailNow() 1507} 1508 1509// Subset asserts that the specified list(array, slice...) contains all 1510// elements given in the specified subset(array, slice...). 1511// 1512// assert.Subset(t, [1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]") 1513func Subset(t TestingT, list interface{}, subset interface{}, msgAndArgs ...interface{}) { 1514 if h, ok := t.(tHelper); ok { 1515 h.Helper() 1516 } 1517 if assert.Subset(t, list, subset, msgAndArgs...) { 1518 return 1519 } 1520 t.FailNow() 1521} 1522 1523// Subsetf asserts that the specified list(array, slice...) contains all 1524// elements given in the specified subset(array, slice...). 1525// 1526// assert.Subsetf(t, [1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]", "error message %s", "formatted") 1527func Subsetf(t TestingT, list interface{}, subset interface{}, msg string, args ...interface{}) { 1528 if h, ok := t.(tHelper); ok { 1529 h.Helper() 1530 } 1531 if assert.Subsetf(t, list, subset, msg, args...) { 1532 return 1533 } 1534 t.FailNow() 1535} 1536 1537// True asserts that the specified value is true. 1538// 1539// assert.True(t, myBool) 1540func True(t TestingT, value bool, msgAndArgs ...interface{}) { 1541 if h, ok := t.(tHelper); ok { 1542 h.Helper() 1543 } 1544 if assert.True(t, value, msgAndArgs...) { 1545 return 1546 } 1547 t.FailNow() 1548} 1549 1550// Truef asserts that the specified value is true. 1551// 1552// assert.Truef(t, myBool, "error message %s", "formatted") 1553func Truef(t TestingT, value bool, msg string, args ...interface{}) { 1554 if h, ok := t.(tHelper); ok { 1555 h.Helper() 1556 } 1557 if assert.Truef(t, value, msg, args...) { 1558 return 1559 } 1560 t.FailNow() 1561} 1562 1563// WithinDuration asserts that the two times are within duration delta of each other. 1564// 1565// assert.WithinDuration(t, time.Now(), time.Now(), 10*time.Second) 1566func WithinDuration(t TestingT, expected time.Time, actual time.Time, delta time.Duration, msgAndArgs ...interface{}) { 1567 if h, ok := t.(tHelper); ok { 1568 h.Helper() 1569 } 1570 if assert.WithinDuration(t, expected, actual, delta, msgAndArgs...) { 1571 return 1572 } 1573 t.FailNow() 1574} 1575 1576// WithinDurationf asserts that the two times are within duration delta of each other. 1577// 1578// assert.WithinDurationf(t, time.Now(), time.Now(), 10*time.Second, "error message %s", "formatted") 1579func WithinDurationf(t TestingT, expected time.Time, actual time.Time, delta time.Duration, msg string, args ...interface{}) { 1580 if h, ok := t.(tHelper); ok { 1581 h.Helper() 1582 } 1583 if assert.WithinDurationf(t, expected, actual, delta, msg, args...) { 1584 return 1585 } 1586 t.FailNow() 1587} 1588 1589// YAMLEq asserts that two YAML strings are equivalent. 1590func YAMLEq(t TestingT, expected string, actual string, msgAndArgs ...interface{}) { 1591 if h, ok := t.(tHelper); ok { 1592 h.Helper() 1593 } 1594 if assert.YAMLEq(t, expected, actual, msgAndArgs...) { 1595 return 1596 } 1597 t.FailNow() 1598} 1599 1600// YAMLEqf asserts that two YAML strings are equivalent. 1601func YAMLEqf(t TestingT, expected string, actual string, msg string, args ...interface{}) { 1602 if h, ok := t.(tHelper); ok { 1603 h.Helper() 1604 } 1605 if assert.YAMLEqf(t, expected, actual, msg, args...) { 1606 return 1607 } 1608 t.FailNow() 1609} 1610 1611// Zero asserts that i is the zero value for its type. 1612func Zero(t TestingT, i interface{}, msgAndArgs ...interface{}) { 1613 if h, ok := t.(tHelper); ok { 1614 h.Helper() 1615 } 1616 if assert.Zero(t, i, msgAndArgs...) { 1617 return 1618 } 1619 t.FailNow() 1620} 1621 1622// Zerof asserts that i is the zero value for its type. 1623func Zerof(t TestingT, i interface{}, msg string, args ...interface{}) { 1624 if h, ok := t.(tHelper); ok { 1625 h.Helper() 1626 } 1627 if assert.Zerof(t, i, msg, args...) { 1628 return 1629 } 1630 t.FailNow() 1631} 1632