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.

1227 lines
36 KiB

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