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.

assertion_forward.go 39KB

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