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