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