本站源代码
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.

1122 lines
38KB

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