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