You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

686 lines
29 KiB

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