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