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