assertion_forward.go 58 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621
  1. // Code generated with github.com/stretchr/testify/_codegen; DO NOT EDIT.
  2. package assert
  3. import (
  4. http "net/http"
  5. url "net/url"
  6. time "time"
  7. )
  8. // Condition uses a Comparison to assert a complex condition.
  9. func (a *Assertions) Condition(comp Comparison, msgAndArgs ...interface{}) bool {
  10. if h, ok := a.t.(tHelper); ok {
  11. h.Helper()
  12. }
  13. return Condition(a.t, comp, msgAndArgs...)
  14. }
  15. // Conditionf uses a Comparison to assert a complex condition.
  16. func (a *Assertions) Conditionf(comp Comparison, msg string, args ...interface{}) bool {
  17. if h, ok := a.t.(tHelper); ok {
  18. h.Helper()
  19. }
  20. return Conditionf(a.t, comp, msg, args...)
  21. }
  22. // Contains asserts that the specified string, list(array, slice...) or map contains the
  23. // specified substring or element.
  24. //
  25. // a.Contains("Hello World", "World")
  26. // a.Contains(["Hello", "World"], "World")
  27. // a.Contains({"Hello": "World"}, "Hello")
  28. func (a *Assertions) Contains(s interface{}, contains interface{}, msgAndArgs ...interface{}) bool {
  29. if h, ok := a.t.(tHelper); ok {
  30. h.Helper()
  31. }
  32. return Contains(a.t, s, contains, msgAndArgs...)
  33. }
  34. // Containsf asserts that the specified string, list(array, slice...) or map contains the
  35. // specified substring or element.
  36. //
  37. // a.Containsf("Hello World", "World", "error message %s", "formatted")
  38. // a.Containsf(["Hello", "World"], "World", "error message %s", "formatted")
  39. // a.Containsf({"Hello": "World"}, "Hello", "error message %s", "formatted")
  40. func (a *Assertions) Containsf(s interface{}, contains interface{}, msg string, args ...interface{}) bool {
  41. if h, ok := a.t.(tHelper); ok {
  42. h.Helper()
  43. }
  44. return Containsf(a.t, s, contains, msg, args...)
  45. }
  46. // DirExists checks whether a directory exists in the given path. It also fails
  47. // if the path is a file rather a directory or there is an error checking whether it exists.
  48. func (a *Assertions) DirExists(path string, msgAndArgs ...interface{}) bool {
  49. if h, ok := a.t.(tHelper); ok {
  50. h.Helper()
  51. }
  52. return DirExists(a.t, path, msgAndArgs...)
  53. }
  54. // DirExistsf checks whether a directory exists in the given path. It also fails
  55. // if the path is a file rather a directory or there is an error checking whether it exists.
  56. func (a *Assertions) DirExistsf(path string, msg string, args ...interface{}) bool {
  57. if h, ok := a.t.(tHelper); ok {
  58. h.Helper()
  59. }
  60. return DirExistsf(a.t, path, msg, args...)
  61. }
  62. // ElementsMatch asserts that the specified listA(array, slice...) is equal to specified
  63. // listB(array, slice...) ignoring the order of the elements. If there are duplicate elements,
  64. // the number of appearances of each of them in both lists should match.
  65. //
  66. // a.ElementsMatch([1, 3, 2, 3], [1, 3, 3, 2])
  67. func (a *Assertions) ElementsMatch(listA interface{}, listB interface{}, msgAndArgs ...interface{}) bool {
  68. if h, ok := a.t.(tHelper); ok {
  69. h.Helper()
  70. }
  71. return ElementsMatch(a.t, listA, listB, msgAndArgs...)
  72. }
  73. // ElementsMatchf asserts that the specified listA(array, slice...) is equal to specified
  74. // listB(array, slice...) ignoring the order of the elements. If there are duplicate elements,
  75. // the number of appearances of each of them in both lists should match.
  76. //
  77. // a.ElementsMatchf([1, 3, 2, 3], [1, 3, 3, 2], "error message %s", "formatted")
  78. func (a *Assertions) ElementsMatchf(listA interface{}, listB interface{}, msg string, args ...interface{}) bool {
  79. if h, ok := a.t.(tHelper); ok {
  80. h.Helper()
  81. }
  82. return ElementsMatchf(a.t, listA, listB, msg, args...)
  83. }
  84. // Empty asserts that the specified object is empty. I.e. nil, "", false, 0 or either
  85. // a slice or a channel with len == 0.
  86. //
  87. // a.Empty(obj)
  88. func (a *Assertions) Empty(object interface{}, msgAndArgs ...interface{}) bool {
  89. if h, ok := a.t.(tHelper); ok {
  90. h.Helper()
  91. }
  92. return Empty(a.t, object, msgAndArgs...)
  93. }
  94. // Emptyf asserts that the specified object is empty. I.e. nil, "", false, 0 or either
  95. // a slice or a channel with len == 0.
  96. //
  97. // a.Emptyf(obj, "error message %s", "formatted")
  98. func (a *Assertions) Emptyf(object interface{}, msg string, args ...interface{}) bool {
  99. if h, ok := a.t.(tHelper); ok {
  100. h.Helper()
  101. }
  102. return Emptyf(a.t, object, msg, args...)
  103. }
  104. // Equal asserts that two objects are equal.
  105. //
  106. // a.Equal(123, 123)
  107. //
  108. // Pointer variable equality is determined based on the equality of the
  109. // referenced values (as opposed to the memory addresses). Function equality
  110. // cannot be determined and will always fail.
  111. func (a *Assertions) Equal(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool {
  112. if h, ok := a.t.(tHelper); ok {
  113. h.Helper()
  114. }
  115. return Equal(a.t, expected, actual, msgAndArgs...)
  116. }
  117. // EqualError asserts that a function returned an error (i.e. not `nil`)
  118. // and that it is equal to the provided error.
  119. //
  120. // actualObj, err := SomeFunction()
  121. // a.EqualError(err, expectedErrorString)
  122. func (a *Assertions) EqualError(theError error, errString string, msgAndArgs ...interface{}) bool {
  123. if h, ok := a.t.(tHelper); ok {
  124. h.Helper()
  125. }
  126. return EqualError(a.t, theError, errString, msgAndArgs...)
  127. }
  128. // EqualErrorf asserts that a function returned an error (i.e. not `nil`)
  129. // and that it is equal to the provided error.
  130. //
  131. // actualObj, err := SomeFunction()
  132. // a.EqualErrorf(err, expectedErrorString, "error message %s", "formatted")
  133. func (a *Assertions) EqualErrorf(theError error, errString string, msg string, args ...interface{}) bool {
  134. if h, ok := a.t.(tHelper); ok {
  135. h.Helper()
  136. }
  137. return EqualErrorf(a.t, theError, errString, msg, args...)
  138. }
  139. // EqualExportedValues asserts that the types of two objects are equal and their public
  140. // fields are also equal. This is useful for comparing structs that have private fields
  141. // that could potentially differ.
  142. //
  143. // type S struct {
  144. // Exported int
  145. // notExported int
  146. // }
  147. // a.EqualExportedValues(S{1, 2}, S{1, 3}) => true
  148. // a.EqualExportedValues(S{1, 2}, S{2, 3}) => false
  149. func (a *Assertions) EqualExportedValues(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool {
  150. if h, ok := a.t.(tHelper); ok {
  151. h.Helper()
  152. }
  153. return EqualExportedValues(a.t, expected, actual, msgAndArgs...)
  154. }
  155. // EqualExportedValuesf asserts that the types of two objects are equal and their public
  156. // fields are also equal. This is useful for comparing structs that have private fields
  157. // that could potentially differ.
  158. //
  159. // type S struct {
  160. // Exported int
  161. // notExported int
  162. // }
  163. // a.EqualExportedValuesf(S{1, 2}, S{1, 3}, "error message %s", "formatted") => true
  164. // a.EqualExportedValuesf(S{1, 2}, S{2, 3}, "error message %s", "formatted") => false
  165. func (a *Assertions) EqualExportedValuesf(expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
  166. if h, ok := a.t.(tHelper); ok {
  167. h.Helper()
  168. }
  169. return EqualExportedValuesf(a.t, expected, actual, msg, args...)
  170. }
  171. // EqualValues asserts that two objects are equal or convertible to the same types
  172. // and equal.
  173. //
  174. // a.EqualValues(uint32(123), int32(123))
  175. func (a *Assertions) EqualValues(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool {
  176. if h, ok := a.t.(tHelper); ok {
  177. h.Helper()
  178. }
  179. return EqualValues(a.t, expected, actual, msgAndArgs...)
  180. }
  181. // EqualValuesf asserts that two objects are equal or convertible to the same types
  182. // and equal.
  183. //
  184. // a.EqualValuesf(uint32(123), int32(123), "error message %s", "formatted")
  185. func (a *Assertions) EqualValuesf(expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
  186. if h, ok := a.t.(tHelper); ok {
  187. h.Helper()
  188. }
  189. return EqualValuesf(a.t, expected, actual, msg, args...)
  190. }
  191. // Equalf asserts that two objects are equal.
  192. //
  193. // a.Equalf(123, 123, "error message %s", "formatted")
  194. //
  195. // Pointer variable equality is determined based on the equality of the
  196. // referenced values (as opposed to the memory addresses). Function equality
  197. // cannot be determined and will always fail.
  198. func (a *Assertions) Equalf(expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
  199. if h, ok := a.t.(tHelper); ok {
  200. h.Helper()
  201. }
  202. return Equalf(a.t, expected, actual, msg, args...)
  203. }
  204. // Error asserts that a function returned an error (i.e. not `nil`).
  205. //
  206. // actualObj, err := SomeFunction()
  207. // if a.Error(err) {
  208. // assert.Equal(t, expectedError, err)
  209. // }
  210. func (a *Assertions) Error(err error, msgAndArgs ...interface{}) bool {
  211. if h, ok := a.t.(tHelper); ok {
  212. h.Helper()
  213. }
  214. return Error(a.t, err, msgAndArgs...)
  215. }
  216. // ErrorAs asserts that at least one of the errors in err's chain matches target, and if so, sets target to that error value.
  217. // This is a wrapper for errors.As.
  218. func (a *Assertions) ErrorAs(err error, target interface{}, msgAndArgs ...interface{}) bool {
  219. if h, ok := a.t.(tHelper); ok {
  220. h.Helper()
  221. }
  222. return ErrorAs(a.t, err, target, msgAndArgs...)
  223. }
  224. // ErrorAsf asserts that at least one of the errors in err's chain matches target, and if so, sets target to that error value.
  225. // This is a wrapper for errors.As.
  226. func (a *Assertions) ErrorAsf(err error, target interface{}, msg string, args ...interface{}) bool {
  227. if h, ok := a.t.(tHelper); ok {
  228. h.Helper()
  229. }
  230. return ErrorAsf(a.t, err, target, msg, args...)
  231. }
  232. // ErrorContains asserts that a function returned an error (i.e. not `nil`)
  233. // and that the error contains the specified substring.
  234. //
  235. // actualObj, err := SomeFunction()
  236. // a.ErrorContains(err, expectedErrorSubString)
  237. func (a *Assertions) ErrorContains(theError error, contains string, msgAndArgs ...interface{}) bool {
  238. if h, ok := a.t.(tHelper); ok {
  239. h.Helper()
  240. }
  241. return ErrorContains(a.t, theError, contains, msgAndArgs...)
  242. }
  243. // ErrorContainsf asserts that a function returned an error (i.e. not `nil`)
  244. // and that the error contains the specified substring.
  245. //
  246. // actualObj, err := SomeFunction()
  247. // a.ErrorContainsf(err, expectedErrorSubString, "error message %s", "formatted")
  248. func (a *Assertions) ErrorContainsf(theError error, contains string, msg string, args ...interface{}) bool {
  249. if h, ok := a.t.(tHelper); ok {
  250. h.Helper()
  251. }
  252. return ErrorContainsf(a.t, theError, contains, msg, args...)
  253. }
  254. // ErrorIs asserts that at least one of the errors in err's chain matches target.
  255. // This is a wrapper for errors.Is.
  256. func (a *Assertions) ErrorIs(err error, target error, msgAndArgs ...interface{}) bool {
  257. if h, ok := a.t.(tHelper); ok {
  258. h.Helper()
  259. }
  260. return ErrorIs(a.t, err, target, msgAndArgs...)
  261. }
  262. // ErrorIsf asserts that at least one of the errors in err's chain matches target.
  263. // This is a wrapper for errors.Is.
  264. func (a *Assertions) ErrorIsf(err error, target error, msg string, args ...interface{}) bool {
  265. if h, ok := a.t.(tHelper); ok {
  266. h.Helper()
  267. }
  268. return ErrorIsf(a.t, err, target, msg, args...)
  269. }
  270. // Errorf asserts that a function returned an error (i.e. not `nil`).
  271. //
  272. // actualObj, err := SomeFunction()
  273. // if a.Errorf(err, "error message %s", "formatted") {
  274. // assert.Equal(t, expectedErrorf, err)
  275. // }
  276. func (a *Assertions) Errorf(err error, msg string, args ...interface{}) bool {
  277. if h, ok := a.t.(tHelper); ok {
  278. h.Helper()
  279. }
  280. return Errorf(a.t, err, msg, args...)
  281. }
  282. // Eventually asserts that given condition will be met in waitFor time,
  283. // periodically checking target function each tick.
  284. //
  285. // a.Eventually(func() bool { return true; }, time.Second, 10*time.Millisecond)
  286. func (a *Assertions) Eventually(condition func() bool, waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) bool {
  287. if h, ok := a.t.(tHelper); ok {
  288. h.Helper()
  289. }
  290. return Eventually(a.t, condition, waitFor, tick, msgAndArgs...)
  291. }
  292. // EventuallyWithT asserts that given condition will be met in waitFor time,
  293. // periodically checking target function each tick. In contrast to Eventually,
  294. // it supplies a CollectT to the condition function, so that the condition
  295. // function can use the CollectT to call other assertions.
  296. // The condition is considered "met" if no errors are raised in a tick.
  297. // The supplied CollectT collects all errors from one tick (if there are any).
  298. // If the condition is not met before waitFor, the collected errors of
  299. // the last tick are copied to t.
  300. //
  301. // externalValue := false
  302. // go func() {
  303. // time.Sleep(8*time.Second)
  304. // externalValue = true
  305. // }()
  306. // a.EventuallyWithT(func(c *assert.CollectT) {
  307. // // add assertions as needed; any assertion failure will fail the current tick
  308. // assert.True(c, externalValue, "expected 'externalValue' to be true")
  309. // }, 1*time.Second, 10*time.Second, "external state has not changed to 'true'; still false")
  310. func (a *Assertions) EventuallyWithT(condition func(collect *CollectT), waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) bool {
  311. if h, ok := a.t.(tHelper); ok {
  312. h.Helper()
  313. }
  314. return EventuallyWithT(a.t, condition, waitFor, tick, msgAndArgs...)
  315. }
  316. // EventuallyWithTf asserts that given condition will be met in waitFor time,
  317. // periodically checking target function each tick. In contrast to Eventually,
  318. // it supplies a CollectT to the condition function, so that the condition
  319. // function can use the CollectT to call other assertions.
  320. // The condition is considered "met" if no errors are raised in a tick.
  321. // The supplied CollectT collects all errors from one tick (if there are any).
  322. // If the condition is not met before waitFor, the collected errors of
  323. // the last tick are copied to t.
  324. //
  325. // externalValue := false
  326. // go func() {
  327. // time.Sleep(8*time.Second)
  328. // externalValue = true
  329. // }()
  330. // a.EventuallyWithTf(func(c *assert.CollectT, "error message %s", "formatted") {
  331. // // add assertions as needed; any assertion failure will fail the current tick
  332. // assert.True(c, externalValue, "expected 'externalValue' to be true")
  333. // }, 1*time.Second, 10*time.Second, "external state has not changed to 'true'; still false")
  334. func (a *Assertions) EventuallyWithTf(condition func(collect *CollectT), waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) bool {
  335. if h, ok := a.t.(tHelper); ok {
  336. h.Helper()
  337. }
  338. return EventuallyWithTf(a.t, condition, waitFor, tick, msg, args...)
  339. }
  340. // Eventuallyf asserts that given condition will be met in waitFor time,
  341. // periodically checking target function each tick.
  342. //
  343. // a.Eventuallyf(func() bool { return true; }, time.Second, 10*time.Millisecond, "error message %s", "formatted")
  344. func (a *Assertions) Eventuallyf(condition func() bool, waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) bool {
  345. if h, ok := a.t.(tHelper); ok {
  346. h.Helper()
  347. }
  348. return Eventuallyf(a.t, condition, waitFor, tick, msg, args...)
  349. }
  350. // Exactly asserts that two objects are equal in value and type.
  351. //
  352. // a.Exactly(int32(123), int64(123))
  353. func (a *Assertions) Exactly(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool {
  354. if h, ok := a.t.(tHelper); ok {
  355. h.Helper()
  356. }
  357. return Exactly(a.t, expected, actual, msgAndArgs...)
  358. }
  359. // Exactlyf asserts that two objects are equal in value and type.
  360. //
  361. // a.Exactlyf(int32(123), int64(123), "error message %s", "formatted")
  362. func (a *Assertions) Exactlyf(expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
  363. if h, ok := a.t.(tHelper); ok {
  364. h.Helper()
  365. }
  366. return Exactlyf(a.t, expected, actual, msg, args...)
  367. }
  368. // Fail reports a failure through
  369. func (a *Assertions) Fail(failureMessage string, msgAndArgs ...interface{}) bool {
  370. if h, ok := a.t.(tHelper); ok {
  371. h.Helper()
  372. }
  373. return Fail(a.t, failureMessage, msgAndArgs...)
  374. }
  375. // FailNow fails test
  376. func (a *Assertions) FailNow(failureMessage string, msgAndArgs ...interface{}) bool {
  377. if h, ok := a.t.(tHelper); ok {
  378. h.Helper()
  379. }
  380. return FailNow(a.t, failureMessage, msgAndArgs...)
  381. }
  382. // FailNowf fails test
  383. func (a *Assertions) FailNowf(failureMessage string, msg string, args ...interface{}) bool {
  384. if h, ok := a.t.(tHelper); ok {
  385. h.Helper()
  386. }
  387. return FailNowf(a.t, failureMessage, msg, args...)
  388. }
  389. // Failf reports a failure through
  390. func (a *Assertions) Failf(failureMessage string, msg string, args ...interface{}) bool {
  391. if h, ok := a.t.(tHelper); ok {
  392. h.Helper()
  393. }
  394. return Failf(a.t, failureMessage, msg, args...)
  395. }
  396. // False asserts that the specified value is false.
  397. //
  398. // a.False(myBool)
  399. func (a *Assertions) False(value bool, msgAndArgs ...interface{}) bool {
  400. if h, ok := a.t.(tHelper); ok {
  401. h.Helper()
  402. }
  403. return False(a.t, value, msgAndArgs...)
  404. }
  405. // Falsef asserts that the specified value is false.
  406. //
  407. // a.Falsef(myBool, "error message %s", "formatted")
  408. func (a *Assertions) Falsef(value bool, msg string, args ...interface{}) bool {
  409. if h, ok := a.t.(tHelper); ok {
  410. h.Helper()
  411. }
  412. return Falsef(a.t, value, msg, args...)
  413. }
  414. // FileExists checks whether a file exists in the given path. It also fails if
  415. // the path points to a directory or there is an error when trying to check the file.
  416. func (a *Assertions) FileExists(path string, msgAndArgs ...interface{}) bool {
  417. if h, ok := a.t.(tHelper); ok {
  418. h.Helper()
  419. }
  420. return FileExists(a.t, path, msgAndArgs...)
  421. }
  422. // FileExistsf checks whether a file exists in the given path. It also fails if
  423. // the path points to a directory or there is an error when trying to check the file.
  424. func (a *Assertions) FileExistsf(path string, msg string, args ...interface{}) bool {
  425. if h, ok := a.t.(tHelper); ok {
  426. h.Helper()
  427. }
  428. return FileExistsf(a.t, path, msg, args...)
  429. }
  430. // Greater asserts that the first element is greater than the second
  431. //
  432. // a.Greater(2, 1)
  433. // a.Greater(float64(2), float64(1))
  434. // a.Greater("b", "a")
  435. func (a *Assertions) Greater(e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool {
  436. if h, ok := a.t.(tHelper); ok {
  437. h.Helper()
  438. }
  439. return Greater(a.t, e1, e2, msgAndArgs...)
  440. }
  441. // GreaterOrEqual asserts that the first element is greater than or equal to the second
  442. //
  443. // a.GreaterOrEqual(2, 1)
  444. // a.GreaterOrEqual(2, 2)
  445. // a.GreaterOrEqual("b", "a")
  446. // a.GreaterOrEqual("b", "b")
  447. func (a *Assertions) GreaterOrEqual(e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool {
  448. if h, ok := a.t.(tHelper); ok {
  449. h.Helper()
  450. }
  451. return GreaterOrEqual(a.t, e1, e2, msgAndArgs...)
  452. }
  453. // GreaterOrEqualf asserts that the first element is greater than or equal to the second
  454. //
  455. // a.GreaterOrEqualf(2, 1, "error message %s", "formatted")
  456. // a.GreaterOrEqualf(2, 2, "error message %s", "formatted")
  457. // a.GreaterOrEqualf("b", "a", "error message %s", "formatted")
  458. // a.GreaterOrEqualf("b", "b", "error message %s", "formatted")
  459. func (a *Assertions) GreaterOrEqualf(e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool {
  460. if h, ok := a.t.(tHelper); ok {
  461. h.Helper()
  462. }
  463. return GreaterOrEqualf(a.t, e1, e2, msg, args...)
  464. }
  465. // Greaterf asserts that the first element is greater than the second
  466. //
  467. // a.Greaterf(2, 1, "error message %s", "formatted")
  468. // a.Greaterf(float64(2), float64(1), "error message %s", "formatted")
  469. // a.Greaterf("b", "a", "error message %s", "formatted")
  470. func (a *Assertions) Greaterf(e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool {
  471. if h, ok := a.t.(tHelper); ok {
  472. h.Helper()
  473. }
  474. return Greaterf(a.t, e1, e2, msg, args...)
  475. }
  476. // HTTPBodyContains asserts that a specified handler returns a
  477. // body that contains a string.
  478. //
  479. // a.HTTPBodyContains(myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky")
  480. //
  481. // Returns whether the assertion was successful (true) or not (false).
  482. func (a *Assertions) HTTPBodyContains(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) bool {
  483. if h, ok := a.t.(tHelper); ok {
  484. h.Helper()
  485. }
  486. return HTTPBodyContains(a.t, handler, method, url, values, str, msgAndArgs...)
  487. }
  488. // HTTPBodyContainsf asserts that a specified handler returns a
  489. // body that contains a string.
  490. //
  491. // a.HTTPBodyContainsf(myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted")
  492. //
  493. // Returns whether the assertion was successful (true) or not (false).
  494. func (a *Assertions) HTTPBodyContainsf(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) bool {
  495. if h, ok := a.t.(tHelper); ok {
  496. h.Helper()
  497. }
  498. return HTTPBodyContainsf(a.t, handler, method, url, values, str, msg, args...)
  499. }
  500. // HTTPBodyNotContains asserts that a specified handler returns a
  501. // body that does not contain a string.
  502. //
  503. // a.HTTPBodyNotContains(myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky")
  504. //
  505. // Returns whether the assertion was successful (true) or not (false).
  506. func (a *Assertions) HTTPBodyNotContains(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) bool {
  507. if h, ok := a.t.(tHelper); ok {
  508. h.Helper()
  509. }
  510. return HTTPBodyNotContains(a.t, handler, method, url, values, str, msgAndArgs...)
  511. }
  512. // HTTPBodyNotContainsf asserts that a specified handler returns a
  513. // body that does not contain a string.
  514. //
  515. // a.HTTPBodyNotContainsf(myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted")
  516. //
  517. // Returns whether the assertion was successful (true) or not (false).
  518. func (a *Assertions) HTTPBodyNotContainsf(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) bool {
  519. if h, ok := a.t.(tHelper); ok {
  520. h.Helper()
  521. }
  522. return HTTPBodyNotContainsf(a.t, handler, method, url, values, str, msg, args...)
  523. }
  524. // HTTPError asserts that a specified handler returns an error status code.
  525. //
  526. // a.HTTPError(myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}}
  527. //
  528. // Returns whether the assertion was successful (true) or not (false).
  529. func (a *Assertions) HTTPError(handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) bool {
  530. if h, ok := a.t.(tHelper); ok {
  531. h.Helper()
  532. }
  533. return HTTPError(a.t, handler, method, url, values, msgAndArgs...)
  534. }
  535. // HTTPErrorf asserts that a specified handler returns an error status code.
  536. //
  537. // a.HTTPErrorf(myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}}
  538. //
  539. // Returns whether the assertion was successful (true) or not (false).
  540. func (a *Assertions) HTTPErrorf(handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) bool {
  541. if h, ok := a.t.(tHelper); ok {
  542. h.Helper()
  543. }
  544. return HTTPErrorf(a.t, handler, method, url, values, msg, args...)
  545. }
  546. // HTTPRedirect asserts that a specified handler returns a redirect status code.
  547. //
  548. // a.HTTPRedirect(myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}}
  549. //
  550. // Returns whether the assertion was successful (true) or not (false).
  551. func (a *Assertions) HTTPRedirect(handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) bool {
  552. if h, ok := a.t.(tHelper); ok {
  553. h.Helper()
  554. }
  555. return HTTPRedirect(a.t, handler, method, url, values, msgAndArgs...)
  556. }
  557. // HTTPRedirectf asserts that a specified handler returns a redirect status code.
  558. //
  559. // a.HTTPRedirectf(myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}}
  560. //
  561. // Returns whether the assertion was successful (true) or not (false).
  562. func (a *Assertions) HTTPRedirectf(handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) bool {
  563. if h, ok := a.t.(tHelper); ok {
  564. h.Helper()
  565. }
  566. return HTTPRedirectf(a.t, handler, method, url, values, msg, args...)
  567. }
  568. // HTTPStatusCode asserts that a specified handler returns a specified status code.
  569. //
  570. // a.HTTPStatusCode(myHandler, "GET", "/notImplemented", nil, 501)
  571. //
  572. // Returns whether the assertion was successful (true) or not (false).
  573. func (a *Assertions) HTTPStatusCode(handler http.HandlerFunc, method string, url string, values url.Values, statuscode int, msgAndArgs ...interface{}) bool {
  574. if h, ok := a.t.(tHelper); ok {
  575. h.Helper()
  576. }
  577. return HTTPStatusCode(a.t, handler, method, url, values, statuscode, msgAndArgs...)
  578. }
  579. // HTTPStatusCodef asserts that a specified handler returns a specified status code.
  580. //
  581. // a.HTTPStatusCodef(myHandler, "GET", "/notImplemented", nil, 501, "error message %s", "formatted")
  582. //
  583. // Returns whether the assertion was successful (true) or not (false).
  584. func (a *Assertions) HTTPStatusCodef(handler http.HandlerFunc, method string, url string, values url.Values, statuscode int, msg string, args ...interface{}) bool {
  585. if h, ok := a.t.(tHelper); ok {
  586. h.Helper()
  587. }
  588. return HTTPStatusCodef(a.t, handler, method, url, values, statuscode, msg, args...)
  589. }
  590. // HTTPSuccess asserts that a specified handler returns a success status code.
  591. //
  592. // a.HTTPSuccess(myHandler, "POST", "http://www.google.com", nil)
  593. //
  594. // Returns whether the assertion was successful (true) or not (false).
  595. func (a *Assertions) HTTPSuccess(handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) bool {
  596. if h, ok := a.t.(tHelper); ok {
  597. h.Helper()
  598. }
  599. return HTTPSuccess(a.t, handler, method, url, values, msgAndArgs...)
  600. }
  601. // HTTPSuccessf asserts that a specified handler returns a success status code.
  602. //
  603. // a.HTTPSuccessf(myHandler, "POST", "http://www.google.com", nil, "error message %s", "formatted")
  604. //
  605. // Returns whether the assertion was successful (true) or not (false).
  606. func (a *Assertions) HTTPSuccessf(handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) bool {
  607. if h, ok := a.t.(tHelper); ok {
  608. h.Helper()
  609. }
  610. return HTTPSuccessf(a.t, handler, method, url, values, msg, args...)
  611. }
  612. // Implements asserts that an object is implemented by the specified interface.
  613. //
  614. // a.Implements((*MyInterface)(nil), new(MyObject))
  615. func (a *Assertions) Implements(interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) bool {
  616. if h, ok := a.t.(tHelper); ok {
  617. h.Helper()
  618. }
  619. return Implements(a.t, interfaceObject, object, msgAndArgs...)
  620. }
  621. // Implementsf asserts that an object is implemented by the specified interface.
  622. //
  623. // a.Implementsf((*MyInterface)(nil), new(MyObject), "error message %s", "formatted")
  624. func (a *Assertions) Implementsf(interfaceObject interface{}, object interface{}, msg string, args ...interface{}) bool {
  625. if h, ok := a.t.(tHelper); ok {
  626. h.Helper()
  627. }
  628. return Implementsf(a.t, interfaceObject, object, msg, args...)
  629. }
  630. // InDelta asserts that the two numerals are within delta of each other.
  631. //
  632. // a.InDelta(math.Pi, 22/7.0, 0.01)
  633. func (a *Assertions) InDelta(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) bool {
  634. if h, ok := a.t.(tHelper); ok {
  635. h.Helper()
  636. }
  637. return InDelta(a.t, expected, actual, delta, msgAndArgs...)
  638. }
  639. // InDeltaMapValues is the same as InDelta, but it compares all values between two maps. Both maps must have exactly the same keys.
  640. func (a *Assertions) InDeltaMapValues(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) bool {
  641. if h, ok := a.t.(tHelper); ok {
  642. h.Helper()
  643. }
  644. return InDeltaMapValues(a.t, expected, actual, delta, msgAndArgs...)
  645. }
  646. // InDeltaMapValuesf is the same as InDelta, but it compares all values between two maps. Both maps must have exactly the same keys.
  647. func (a *Assertions) InDeltaMapValuesf(expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool {
  648. if h, ok := a.t.(tHelper); ok {
  649. h.Helper()
  650. }
  651. return InDeltaMapValuesf(a.t, expected, actual, delta, msg, args...)
  652. }
  653. // InDeltaSlice is the same as InDelta, except it compares two slices.
  654. func (a *Assertions) InDeltaSlice(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) bool {
  655. if h, ok := a.t.(tHelper); ok {
  656. h.Helper()
  657. }
  658. return InDeltaSlice(a.t, expected, actual, delta, msgAndArgs...)
  659. }
  660. // InDeltaSlicef is the same as InDelta, except it compares two slices.
  661. func (a *Assertions) InDeltaSlicef(expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool {
  662. if h, ok := a.t.(tHelper); ok {
  663. h.Helper()
  664. }
  665. return InDeltaSlicef(a.t, expected, actual, delta, msg, args...)
  666. }
  667. // InDeltaf asserts that the two numerals are within delta of each other.
  668. //
  669. // a.InDeltaf(math.Pi, 22/7.0, 0.01, "error message %s", "formatted")
  670. func (a *Assertions) InDeltaf(expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool {
  671. if h, ok := a.t.(tHelper); ok {
  672. h.Helper()
  673. }
  674. return InDeltaf(a.t, expected, actual, delta, msg, args...)
  675. }
  676. // InEpsilon asserts that expected and actual have a relative error less than epsilon
  677. func (a *Assertions) InEpsilon(expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{}) bool {
  678. if h, ok := a.t.(tHelper); ok {
  679. h.Helper()
  680. }
  681. return InEpsilon(a.t, expected, actual, epsilon, msgAndArgs...)
  682. }
  683. // InEpsilonSlice is the same as InEpsilon, except it compares each value from two slices.
  684. func (a *Assertions) InEpsilonSlice(expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{}) bool {
  685. if h, ok := a.t.(tHelper); ok {
  686. h.Helper()
  687. }
  688. return InEpsilonSlice(a.t, expected, actual, epsilon, msgAndArgs...)
  689. }
  690. // InEpsilonSlicef is the same as InEpsilon, except it compares each value from two slices.
  691. func (a *Assertions) InEpsilonSlicef(expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) bool {
  692. if h, ok := a.t.(tHelper); ok {
  693. h.Helper()
  694. }
  695. return InEpsilonSlicef(a.t, expected, actual, epsilon, msg, args...)
  696. }
  697. // InEpsilonf asserts that expected and actual have a relative error less than epsilon
  698. func (a *Assertions) InEpsilonf(expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) bool {
  699. if h, ok := a.t.(tHelper); ok {
  700. h.Helper()
  701. }
  702. return InEpsilonf(a.t, expected, actual, epsilon, msg, args...)
  703. }
  704. // IsDecreasing asserts that the collection is decreasing
  705. //
  706. // a.IsDecreasing([]int{2, 1, 0})
  707. // a.IsDecreasing([]float{2, 1})
  708. // a.IsDecreasing([]string{"b", "a"})
  709. func (a *Assertions) IsDecreasing(object interface{}, msgAndArgs ...interface{}) bool {
  710. if h, ok := a.t.(tHelper); ok {
  711. h.Helper()
  712. }
  713. return IsDecreasing(a.t, object, msgAndArgs...)
  714. }
  715. // IsDecreasingf asserts that the collection is decreasing
  716. //
  717. // a.IsDecreasingf([]int{2, 1, 0}, "error message %s", "formatted")
  718. // a.IsDecreasingf([]float{2, 1}, "error message %s", "formatted")
  719. // a.IsDecreasingf([]string{"b", "a"}, "error message %s", "formatted")
  720. func (a *Assertions) IsDecreasingf(object interface{}, msg string, args ...interface{}) bool {
  721. if h, ok := a.t.(tHelper); ok {
  722. h.Helper()
  723. }
  724. return IsDecreasingf(a.t, object, msg, args...)
  725. }
  726. // IsIncreasing asserts that the collection is increasing
  727. //
  728. // a.IsIncreasing([]int{1, 2, 3})
  729. // a.IsIncreasing([]float{1, 2})
  730. // a.IsIncreasing([]string{"a", "b"})
  731. func (a *Assertions) IsIncreasing(object interface{}, msgAndArgs ...interface{}) bool {
  732. if h, ok := a.t.(tHelper); ok {
  733. h.Helper()
  734. }
  735. return IsIncreasing(a.t, object, msgAndArgs...)
  736. }
  737. // IsIncreasingf asserts that the collection is increasing
  738. //
  739. // a.IsIncreasingf([]int{1, 2, 3}, "error message %s", "formatted")
  740. // a.IsIncreasingf([]float{1, 2}, "error message %s", "formatted")
  741. // a.IsIncreasingf([]string{"a", "b"}, "error message %s", "formatted")
  742. func (a *Assertions) IsIncreasingf(object interface{}, msg string, args ...interface{}) bool {
  743. if h, ok := a.t.(tHelper); ok {
  744. h.Helper()
  745. }
  746. return IsIncreasingf(a.t, object, msg, args...)
  747. }
  748. // IsNonDecreasing asserts that the collection is not decreasing
  749. //
  750. // a.IsNonDecreasing([]int{1, 1, 2})
  751. // a.IsNonDecreasing([]float{1, 2})
  752. // a.IsNonDecreasing([]string{"a", "b"})
  753. func (a *Assertions) IsNonDecreasing(object interface{}, msgAndArgs ...interface{}) bool {
  754. if h, ok := a.t.(tHelper); ok {
  755. h.Helper()
  756. }
  757. return IsNonDecreasing(a.t, object, msgAndArgs...)
  758. }
  759. // IsNonDecreasingf asserts that the collection is not decreasing
  760. //
  761. // a.IsNonDecreasingf([]int{1, 1, 2}, "error message %s", "formatted")
  762. // a.IsNonDecreasingf([]float{1, 2}, "error message %s", "formatted")
  763. // a.IsNonDecreasingf([]string{"a", "b"}, "error message %s", "formatted")
  764. func (a *Assertions) IsNonDecreasingf(object interface{}, msg string, args ...interface{}) bool {
  765. if h, ok := a.t.(tHelper); ok {
  766. h.Helper()
  767. }
  768. return IsNonDecreasingf(a.t, object, msg, args...)
  769. }
  770. // IsNonIncreasing asserts that the collection is not increasing
  771. //
  772. // a.IsNonIncreasing([]int{2, 1, 1})
  773. // a.IsNonIncreasing([]float{2, 1})
  774. // a.IsNonIncreasing([]string{"b", "a"})
  775. func (a *Assertions) IsNonIncreasing(object interface{}, msgAndArgs ...interface{}) bool {
  776. if h, ok := a.t.(tHelper); ok {
  777. h.Helper()
  778. }
  779. return IsNonIncreasing(a.t, object, msgAndArgs...)
  780. }
  781. // IsNonIncreasingf asserts that the collection is not increasing
  782. //
  783. // a.IsNonIncreasingf([]int{2, 1, 1}, "error message %s", "formatted")
  784. // a.IsNonIncreasingf([]float{2, 1}, "error message %s", "formatted")
  785. // a.IsNonIncreasingf([]string{"b", "a"}, "error message %s", "formatted")
  786. func (a *Assertions) IsNonIncreasingf(object interface{}, msg string, args ...interface{}) bool {
  787. if h, ok := a.t.(tHelper); ok {
  788. h.Helper()
  789. }
  790. return IsNonIncreasingf(a.t, object, msg, args...)
  791. }
  792. // IsType asserts that the specified objects are of the same type.
  793. func (a *Assertions) IsType(expectedType interface{}, object interface{}, msgAndArgs ...interface{}) bool {
  794. if h, ok := a.t.(tHelper); ok {
  795. h.Helper()
  796. }
  797. return IsType(a.t, expectedType, object, msgAndArgs...)
  798. }
  799. // IsTypef asserts that the specified objects are of the same type.
  800. func (a *Assertions) IsTypef(expectedType interface{}, object interface{}, msg string, args ...interface{}) bool {
  801. if h, ok := a.t.(tHelper); ok {
  802. h.Helper()
  803. }
  804. return IsTypef(a.t, expectedType, object, msg, args...)
  805. }
  806. // JSONEq asserts that two JSON strings are equivalent.
  807. //
  808. // a.JSONEq(`{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`)
  809. func (a *Assertions) JSONEq(expected string, actual string, msgAndArgs ...interface{}) bool {
  810. if h, ok := a.t.(tHelper); ok {
  811. h.Helper()
  812. }
  813. return JSONEq(a.t, expected, actual, msgAndArgs...)
  814. }
  815. // JSONEqf asserts that two JSON strings are equivalent.
  816. //
  817. // a.JSONEqf(`{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`, "error message %s", "formatted")
  818. func (a *Assertions) JSONEqf(expected string, actual string, msg string, args ...interface{}) bool {
  819. if h, ok := a.t.(tHelper); ok {
  820. h.Helper()
  821. }
  822. return JSONEqf(a.t, expected, actual, msg, args...)
  823. }
  824. // Len asserts that the specified object has specific length.
  825. // Len also fails if the object has a type that len() not accept.
  826. //
  827. // a.Len(mySlice, 3)
  828. func (a *Assertions) Len(object interface{}, length int, msgAndArgs ...interface{}) bool {
  829. if h, ok := a.t.(tHelper); ok {
  830. h.Helper()
  831. }
  832. return Len(a.t, object, length, msgAndArgs...)
  833. }
  834. // Lenf asserts that the specified object has specific length.
  835. // Lenf also fails if the object has a type that len() not accept.
  836. //
  837. // a.Lenf(mySlice, 3, "error message %s", "formatted")
  838. func (a *Assertions) Lenf(object interface{}, length int, msg string, args ...interface{}) bool {
  839. if h, ok := a.t.(tHelper); ok {
  840. h.Helper()
  841. }
  842. return Lenf(a.t, object, length, msg, args...)
  843. }
  844. // Less asserts that the first element is less than the second
  845. //
  846. // a.Less(1, 2)
  847. // a.Less(float64(1), float64(2))
  848. // a.Less("a", "b")
  849. func (a *Assertions) Less(e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool {
  850. if h, ok := a.t.(tHelper); ok {
  851. h.Helper()
  852. }
  853. return Less(a.t, e1, e2, msgAndArgs...)
  854. }
  855. // LessOrEqual asserts that the first element is less than or equal to the second
  856. //
  857. // a.LessOrEqual(1, 2)
  858. // a.LessOrEqual(2, 2)
  859. // a.LessOrEqual("a", "b")
  860. // a.LessOrEqual("b", "b")
  861. func (a *Assertions) LessOrEqual(e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool {
  862. if h, ok := a.t.(tHelper); ok {
  863. h.Helper()
  864. }
  865. return LessOrEqual(a.t, e1, e2, msgAndArgs...)
  866. }
  867. // LessOrEqualf asserts that the first element is less than or equal to the second
  868. //
  869. // a.LessOrEqualf(1, 2, "error message %s", "formatted")
  870. // a.LessOrEqualf(2, 2, "error message %s", "formatted")
  871. // a.LessOrEqualf("a", "b", "error message %s", "formatted")
  872. // a.LessOrEqualf("b", "b", "error message %s", "formatted")
  873. func (a *Assertions) LessOrEqualf(e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool {
  874. if h, ok := a.t.(tHelper); ok {
  875. h.Helper()
  876. }
  877. return LessOrEqualf(a.t, e1, e2, msg, args...)
  878. }
  879. // Lessf asserts that the first element is less than the second
  880. //
  881. // a.Lessf(1, 2, "error message %s", "formatted")
  882. // a.Lessf(float64(1), float64(2), "error message %s", "formatted")
  883. // a.Lessf("a", "b", "error message %s", "formatted")
  884. func (a *Assertions) Lessf(e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool {
  885. if h, ok := a.t.(tHelper); ok {
  886. h.Helper()
  887. }
  888. return Lessf(a.t, e1, e2, msg, args...)
  889. }
  890. // Negative asserts that the specified element is negative
  891. //
  892. // a.Negative(-1)
  893. // a.Negative(-1.23)
  894. func (a *Assertions) Negative(e interface{}, msgAndArgs ...interface{}) bool {
  895. if h, ok := a.t.(tHelper); ok {
  896. h.Helper()
  897. }
  898. return Negative(a.t, e, msgAndArgs...)
  899. }
  900. // Negativef asserts that the specified element is negative
  901. //
  902. // a.Negativef(-1, "error message %s", "formatted")
  903. // a.Negativef(-1.23, "error message %s", "formatted")
  904. func (a *Assertions) Negativef(e interface{}, msg string, args ...interface{}) bool {
  905. if h, ok := a.t.(tHelper); ok {
  906. h.Helper()
  907. }
  908. return Negativef(a.t, e, msg, args...)
  909. }
  910. // Never asserts that the given condition doesn't satisfy in waitFor time,
  911. // periodically checking the target function each tick.
  912. //
  913. // a.Never(func() bool { return false; }, time.Second, 10*time.Millisecond)
  914. func (a *Assertions) Never(condition func() bool, waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) bool {
  915. if h, ok := a.t.(tHelper); ok {
  916. h.Helper()
  917. }
  918. return Never(a.t, condition, waitFor, tick, msgAndArgs...)
  919. }
  920. // Neverf asserts that the given condition doesn't satisfy in waitFor time,
  921. // periodically checking the target function each tick.
  922. //
  923. // a.Neverf(func() bool { return false; }, time.Second, 10*time.Millisecond, "error message %s", "formatted")
  924. func (a *Assertions) Neverf(condition func() bool, waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) bool {
  925. if h, ok := a.t.(tHelper); ok {
  926. h.Helper()
  927. }
  928. return Neverf(a.t, condition, waitFor, tick, msg, args...)
  929. }
  930. // Nil asserts that the specified object is nil.
  931. //
  932. // a.Nil(err)
  933. func (a *Assertions) Nil(object interface{}, msgAndArgs ...interface{}) bool {
  934. if h, ok := a.t.(tHelper); ok {
  935. h.Helper()
  936. }
  937. return Nil(a.t, object, msgAndArgs...)
  938. }
  939. // Nilf asserts that the specified object is nil.
  940. //
  941. // a.Nilf(err, "error message %s", "formatted")
  942. func (a *Assertions) Nilf(object interface{}, msg string, args ...interface{}) bool {
  943. if h, ok := a.t.(tHelper); ok {
  944. h.Helper()
  945. }
  946. return Nilf(a.t, object, msg, args...)
  947. }
  948. // NoDirExists checks whether a directory does not exist in the given path.
  949. // It fails if the path points to an existing _directory_ only.
  950. func (a *Assertions) NoDirExists(path string, msgAndArgs ...interface{}) bool {
  951. if h, ok := a.t.(tHelper); ok {
  952. h.Helper()
  953. }
  954. return NoDirExists(a.t, path, msgAndArgs...)
  955. }
  956. // NoDirExistsf checks whether a directory does not exist in the given path.
  957. // It fails if the path points to an existing _directory_ only.
  958. func (a *Assertions) NoDirExistsf(path string, msg string, args ...interface{}) bool {
  959. if h, ok := a.t.(tHelper); ok {
  960. h.Helper()
  961. }
  962. return NoDirExistsf(a.t, path, msg, args...)
  963. }
  964. // NoError asserts that a function returned no error (i.e. `nil`).
  965. //
  966. // actualObj, err := SomeFunction()
  967. // if a.NoError(err) {
  968. // assert.Equal(t, expectedObj, actualObj)
  969. // }
  970. func (a *Assertions) NoError(err error, msgAndArgs ...interface{}) bool {
  971. if h, ok := a.t.(tHelper); ok {
  972. h.Helper()
  973. }
  974. return NoError(a.t, err, msgAndArgs...)
  975. }
  976. // NoErrorf asserts that a function returned no error (i.e. `nil`).
  977. //
  978. // actualObj, err := SomeFunction()
  979. // if a.NoErrorf(err, "error message %s", "formatted") {
  980. // assert.Equal(t, expectedObj, actualObj)
  981. // }
  982. func (a *Assertions) NoErrorf(err error, msg string, args ...interface{}) bool {
  983. if h, ok := a.t.(tHelper); ok {
  984. h.Helper()
  985. }
  986. return NoErrorf(a.t, err, msg, args...)
  987. }
  988. // NoFileExists checks whether a file does not exist in a given path. It fails
  989. // if the path points to an existing _file_ only.
  990. func (a *Assertions) NoFileExists(path string, msgAndArgs ...interface{}) bool {
  991. if h, ok := a.t.(tHelper); ok {
  992. h.Helper()
  993. }
  994. return NoFileExists(a.t, path, msgAndArgs...)
  995. }
  996. // NoFileExistsf checks whether a file does not exist in a given path. It fails
  997. // if the path points to an existing _file_ only.
  998. func (a *Assertions) NoFileExistsf(path string, msg string, args ...interface{}) bool {
  999. if h, ok := a.t.(tHelper); ok {
  1000. h.Helper()
  1001. }
  1002. return NoFileExistsf(a.t, path, msg, args...)
  1003. }
  1004. // NotContains asserts that the specified string, list(array, slice...) or map does NOT contain the
  1005. // specified substring or element.
  1006. //
  1007. // a.NotContains("Hello World", "Earth")
  1008. // a.NotContains(["Hello", "World"], "Earth")
  1009. // a.NotContains({"Hello": "World"}, "Earth")
  1010. func (a *Assertions) NotContains(s interface{}, contains interface{}, msgAndArgs ...interface{}) bool {
  1011. if h, ok := a.t.(tHelper); ok {
  1012. h.Helper()
  1013. }
  1014. return NotContains(a.t, s, contains, msgAndArgs...)
  1015. }
  1016. // NotContainsf asserts that the specified string, list(array, slice...) or map does NOT contain the
  1017. // specified substring or element.
  1018. //
  1019. // a.NotContainsf("Hello World", "Earth", "error message %s", "formatted")
  1020. // a.NotContainsf(["Hello", "World"], "Earth", "error message %s", "formatted")
  1021. // a.NotContainsf({"Hello": "World"}, "Earth", "error message %s", "formatted")
  1022. func (a *Assertions) NotContainsf(s interface{}, contains interface{}, msg string, args ...interface{}) bool {
  1023. if h, ok := a.t.(tHelper); ok {
  1024. h.Helper()
  1025. }
  1026. return NotContainsf(a.t, s, contains, msg, args...)
  1027. }
  1028. // NotEmpty asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either
  1029. // a slice or a channel with len == 0.
  1030. //
  1031. // if a.NotEmpty(obj) {
  1032. // assert.Equal(t, "two", obj[1])
  1033. // }
  1034. func (a *Assertions) NotEmpty(object interface{}, msgAndArgs ...interface{}) bool {
  1035. if h, ok := a.t.(tHelper); ok {
  1036. h.Helper()
  1037. }
  1038. return NotEmpty(a.t, object, msgAndArgs...)
  1039. }
  1040. // NotEmptyf asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either
  1041. // a slice or a channel with len == 0.
  1042. //
  1043. // if a.NotEmptyf(obj, "error message %s", "formatted") {
  1044. // assert.Equal(t, "two", obj[1])
  1045. // }
  1046. func (a *Assertions) NotEmptyf(object interface{}, msg string, args ...interface{}) bool {
  1047. if h, ok := a.t.(tHelper); ok {
  1048. h.Helper()
  1049. }
  1050. return NotEmptyf(a.t, object, msg, args...)
  1051. }
  1052. // NotEqual asserts that the specified values are NOT equal.
  1053. //
  1054. // a.NotEqual(obj1, obj2)
  1055. //
  1056. // Pointer variable equality is determined based on the equality of the
  1057. // referenced values (as opposed to the memory addresses).
  1058. func (a *Assertions) NotEqual(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool {
  1059. if h, ok := a.t.(tHelper); ok {
  1060. h.Helper()
  1061. }
  1062. return NotEqual(a.t, expected, actual, msgAndArgs...)
  1063. }
  1064. // NotEqualValues asserts that two objects are not equal even when converted to the same type
  1065. //
  1066. // a.NotEqualValues(obj1, obj2)
  1067. func (a *Assertions) NotEqualValues(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool {
  1068. if h, ok := a.t.(tHelper); ok {
  1069. h.Helper()
  1070. }
  1071. return NotEqualValues(a.t, expected, actual, msgAndArgs...)
  1072. }
  1073. // NotEqualValuesf asserts that two objects are not equal even when converted to the same type
  1074. //
  1075. // a.NotEqualValuesf(obj1, obj2, "error message %s", "formatted")
  1076. func (a *Assertions) NotEqualValuesf(expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
  1077. if h, ok := a.t.(tHelper); ok {
  1078. h.Helper()
  1079. }
  1080. return NotEqualValuesf(a.t, expected, actual, msg, args...)
  1081. }
  1082. // NotEqualf asserts that the specified values are NOT equal.
  1083. //
  1084. // a.NotEqualf(obj1, obj2, "error message %s", "formatted")
  1085. //
  1086. // Pointer variable equality is determined based on the equality of the
  1087. // referenced values (as opposed to the memory addresses).
  1088. func (a *Assertions) NotEqualf(expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
  1089. if h, ok := a.t.(tHelper); ok {
  1090. h.Helper()
  1091. }
  1092. return NotEqualf(a.t, expected, actual, msg, args...)
  1093. }
  1094. // NotErrorIs asserts that at none of the errors in err's chain matches target.
  1095. // This is a wrapper for errors.Is.
  1096. func (a *Assertions) NotErrorIs(err error, target error, msgAndArgs ...interface{}) bool {
  1097. if h, ok := a.t.(tHelper); ok {
  1098. h.Helper()
  1099. }
  1100. return NotErrorIs(a.t, err, target, msgAndArgs...)
  1101. }
  1102. // NotErrorIsf asserts that at none of the errors in err's chain matches target.
  1103. // This is a wrapper for errors.Is.
  1104. func (a *Assertions) NotErrorIsf(err error, target error, msg string, args ...interface{}) bool {
  1105. if h, ok := a.t.(tHelper); ok {
  1106. h.Helper()
  1107. }
  1108. return NotErrorIsf(a.t, err, target, msg, args...)
  1109. }
  1110. // NotImplements asserts that an object does not implement the specified interface.
  1111. //
  1112. // a.NotImplements((*MyInterface)(nil), new(MyObject))
  1113. func (a *Assertions) NotImplements(interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) bool {
  1114. if h, ok := a.t.(tHelper); ok {
  1115. h.Helper()
  1116. }
  1117. return NotImplements(a.t, interfaceObject, object, msgAndArgs...)
  1118. }
  1119. // NotImplementsf asserts that an object does not implement the specified interface.
  1120. //
  1121. // a.NotImplementsf((*MyInterface)(nil), new(MyObject), "error message %s", "formatted")
  1122. func (a *Assertions) NotImplementsf(interfaceObject interface{}, object interface{}, msg string, args ...interface{}) bool {
  1123. if h, ok := a.t.(tHelper); ok {
  1124. h.Helper()
  1125. }
  1126. return NotImplementsf(a.t, interfaceObject, object, msg, args...)
  1127. }
  1128. // NotNil asserts that the specified object is not nil.
  1129. //
  1130. // a.NotNil(err)
  1131. func (a *Assertions) NotNil(object interface{}, msgAndArgs ...interface{}) bool {
  1132. if h, ok := a.t.(tHelper); ok {
  1133. h.Helper()
  1134. }
  1135. return NotNil(a.t, object, msgAndArgs...)
  1136. }
  1137. // NotNilf asserts that the specified object is not nil.
  1138. //
  1139. // a.NotNilf(err, "error message %s", "formatted")
  1140. func (a *Assertions) NotNilf(object interface{}, msg string, args ...interface{}) bool {
  1141. if h, ok := a.t.(tHelper); ok {
  1142. h.Helper()
  1143. }
  1144. return NotNilf(a.t, object, msg, args...)
  1145. }
  1146. // NotPanics asserts that the code inside the specified PanicTestFunc does NOT panic.
  1147. //
  1148. // a.NotPanics(func(){ RemainCalm() })
  1149. func (a *Assertions) NotPanics(f PanicTestFunc, msgAndArgs ...interface{}) bool {
  1150. if h, ok := a.t.(tHelper); ok {
  1151. h.Helper()
  1152. }
  1153. return NotPanics(a.t, f, msgAndArgs...)
  1154. }
  1155. // NotPanicsf asserts that the code inside the specified PanicTestFunc does NOT panic.
  1156. //
  1157. // a.NotPanicsf(func(){ RemainCalm() }, "error message %s", "formatted")
  1158. func (a *Assertions) NotPanicsf(f PanicTestFunc, msg string, args ...interface{}) bool {
  1159. if h, ok := a.t.(tHelper); ok {
  1160. h.Helper()
  1161. }
  1162. return NotPanicsf(a.t, f, msg, args...)
  1163. }
  1164. // NotRegexp asserts that a specified regexp does not match a string.
  1165. //
  1166. // a.NotRegexp(regexp.MustCompile("starts"), "it's starting")
  1167. // a.NotRegexp("^start", "it's not starting")
  1168. func (a *Assertions) NotRegexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) bool {
  1169. if h, ok := a.t.(tHelper); ok {
  1170. h.Helper()
  1171. }
  1172. return NotRegexp(a.t, rx, str, msgAndArgs...)
  1173. }
  1174. // NotRegexpf asserts that a specified regexp does not match a string.
  1175. //
  1176. // a.NotRegexpf(regexp.MustCompile("starts"), "it's starting", "error message %s", "formatted")
  1177. // a.NotRegexpf("^start", "it's not starting", "error message %s", "formatted")
  1178. func (a *Assertions) NotRegexpf(rx interface{}, str interface{}, msg string, args ...interface{}) bool {
  1179. if h, ok := a.t.(tHelper); ok {
  1180. h.Helper()
  1181. }
  1182. return NotRegexpf(a.t, rx, str, msg, args...)
  1183. }
  1184. // NotSame asserts that two pointers do not reference the same object.
  1185. //
  1186. // a.NotSame(ptr1, ptr2)
  1187. //
  1188. // Both arguments must be pointer variables. Pointer variable sameness is
  1189. // determined based on the equality of both type and value.
  1190. func (a *Assertions) NotSame(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool {
  1191. if h, ok := a.t.(tHelper); ok {
  1192. h.Helper()
  1193. }
  1194. return NotSame(a.t, expected, actual, msgAndArgs...)
  1195. }
  1196. // NotSamef asserts that two pointers do not reference the same object.
  1197. //
  1198. // a.NotSamef(ptr1, ptr2, "error message %s", "formatted")
  1199. //
  1200. // Both arguments must be pointer variables. Pointer variable sameness is
  1201. // determined based on the equality of both type and value.
  1202. func (a *Assertions) NotSamef(expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
  1203. if h, ok := a.t.(tHelper); ok {
  1204. h.Helper()
  1205. }
  1206. return NotSamef(a.t, expected, actual, msg, args...)
  1207. }
  1208. // NotSubset asserts that the specified list(array, slice...) or map does NOT
  1209. // contain all elements given in the specified subset list(array, slice...) or
  1210. // map.
  1211. //
  1212. // a.NotSubset([1, 3, 4], [1, 2])
  1213. // a.NotSubset({"x": 1, "y": 2}, {"z": 3})
  1214. func (a *Assertions) NotSubset(list interface{}, subset interface{}, msgAndArgs ...interface{}) bool {
  1215. if h, ok := a.t.(tHelper); ok {
  1216. h.Helper()
  1217. }
  1218. return NotSubset(a.t, list, subset, msgAndArgs...)
  1219. }
  1220. // NotSubsetf asserts that the specified list(array, slice...) or map does NOT
  1221. // contain all elements given in the specified subset list(array, slice...) or
  1222. // map.
  1223. //
  1224. // a.NotSubsetf([1, 3, 4], [1, 2], "error message %s", "formatted")
  1225. // a.NotSubsetf({"x": 1, "y": 2}, {"z": 3}, "error message %s", "formatted")
  1226. func (a *Assertions) NotSubsetf(list interface{}, subset interface{}, msg string, args ...interface{}) bool {
  1227. if h, ok := a.t.(tHelper); ok {
  1228. h.Helper()
  1229. }
  1230. return NotSubsetf(a.t, list, subset, msg, args...)
  1231. }
  1232. // NotZero asserts that i is not the zero value for its type.
  1233. func (a *Assertions) NotZero(i interface{}, msgAndArgs ...interface{}) bool {
  1234. if h, ok := a.t.(tHelper); ok {
  1235. h.Helper()
  1236. }
  1237. return NotZero(a.t, i, msgAndArgs...)
  1238. }
  1239. // NotZerof asserts that i is not the zero value for its type.
  1240. func (a *Assertions) NotZerof(i interface{}, msg string, args ...interface{}) bool {
  1241. if h, ok := a.t.(tHelper); ok {
  1242. h.Helper()
  1243. }
  1244. return NotZerof(a.t, i, msg, args...)
  1245. }
  1246. // Panics asserts that the code inside the specified PanicTestFunc panics.
  1247. //
  1248. // a.Panics(func(){ GoCrazy() })
  1249. func (a *Assertions) Panics(f PanicTestFunc, msgAndArgs ...interface{}) bool {
  1250. if h, ok := a.t.(tHelper); ok {
  1251. h.Helper()
  1252. }
  1253. return Panics(a.t, f, msgAndArgs...)
  1254. }
  1255. // PanicsWithError asserts that the code inside the specified PanicTestFunc
  1256. // panics, and that the recovered panic value is an error that satisfies the
  1257. // EqualError comparison.
  1258. //
  1259. // a.PanicsWithError("crazy error", func(){ GoCrazy() })
  1260. func (a *Assertions) PanicsWithError(errString string, f PanicTestFunc, msgAndArgs ...interface{}) bool {
  1261. if h, ok := a.t.(tHelper); ok {
  1262. h.Helper()
  1263. }
  1264. return PanicsWithError(a.t, errString, f, msgAndArgs...)
  1265. }
  1266. // PanicsWithErrorf asserts that the code inside the specified PanicTestFunc
  1267. // panics, and that the recovered panic value is an error that satisfies the
  1268. // EqualError comparison.
  1269. //
  1270. // a.PanicsWithErrorf("crazy error", func(){ GoCrazy() }, "error message %s", "formatted")
  1271. func (a *Assertions) PanicsWithErrorf(errString string, f PanicTestFunc, msg string, args ...interface{}) bool {
  1272. if h, ok := a.t.(tHelper); ok {
  1273. h.Helper()
  1274. }
  1275. return PanicsWithErrorf(a.t, errString, f, msg, args...)
  1276. }
  1277. // PanicsWithValue asserts that the code inside the specified PanicTestFunc panics, and that
  1278. // the recovered panic value equals the expected panic value.
  1279. //
  1280. // a.PanicsWithValue("crazy error", func(){ GoCrazy() })
  1281. func (a *Assertions) PanicsWithValue(expected interface{}, f PanicTestFunc, msgAndArgs ...interface{}) bool {
  1282. if h, ok := a.t.(tHelper); ok {
  1283. h.Helper()
  1284. }
  1285. return PanicsWithValue(a.t, expected, f, msgAndArgs...)
  1286. }
  1287. // PanicsWithValuef asserts that the code inside the specified PanicTestFunc panics, and that
  1288. // the recovered panic value equals the expected panic value.
  1289. //
  1290. // a.PanicsWithValuef("crazy error", func(){ GoCrazy() }, "error message %s", "formatted")
  1291. func (a *Assertions) PanicsWithValuef(expected interface{}, f PanicTestFunc, msg string, args ...interface{}) bool {
  1292. if h, ok := a.t.(tHelper); ok {
  1293. h.Helper()
  1294. }
  1295. return PanicsWithValuef(a.t, expected, f, msg, args...)
  1296. }
  1297. // Panicsf asserts that the code inside the specified PanicTestFunc panics.
  1298. //
  1299. // a.Panicsf(func(){ GoCrazy() }, "error message %s", "formatted")
  1300. func (a *Assertions) Panicsf(f PanicTestFunc, msg string, args ...interface{}) bool {
  1301. if h, ok := a.t.(tHelper); ok {
  1302. h.Helper()
  1303. }
  1304. return Panicsf(a.t, f, msg, args...)
  1305. }
  1306. // Positive asserts that the specified element is positive
  1307. //
  1308. // a.Positive(1)
  1309. // a.Positive(1.23)
  1310. func (a *Assertions) Positive(e interface{}, msgAndArgs ...interface{}) bool {
  1311. if h, ok := a.t.(tHelper); ok {
  1312. h.Helper()
  1313. }
  1314. return Positive(a.t, e, msgAndArgs...)
  1315. }
  1316. // Positivef asserts that the specified element is positive
  1317. //
  1318. // a.Positivef(1, "error message %s", "formatted")
  1319. // a.Positivef(1.23, "error message %s", "formatted")
  1320. func (a *Assertions) Positivef(e interface{}, msg string, args ...interface{}) bool {
  1321. if h, ok := a.t.(tHelper); ok {
  1322. h.Helper()
  1323. }
  1324. return Positivef(a.t, e, msg, args...)
  1325. }
  1326. // Regexp asserts that a specified regexp matches a string.
  1327. //
  1328. // a.Regexp(regexp.MustCompile("start"), "it's starting")
  1329. // a.Regexp("start...$", "it's not starting")
  1330. func (a *Assertions) Regexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) bool {
  1331. if h, ok := a.t.(tHelper); ok {
  1332. h.Helper()
  1333. }
  1334. return Regexp(a.t, rx, str, msgAndArgs...)
  1335. }
  1336. // Regexpf asserts that a specified regexp matches a string.
  1337. //
  1338. // a.Regexpf(regexp.MustCompile("start"), "it's starting", "error message %s", "formatted")
  1339. // a.Regexpf("start...$", "it's not starting", "error message %s", "formatted")
  1340. func (a *Assertions) Regexpf(rx interface{}, str interface{}, msg string, args ...interface{}) bool {
  1341. if h, ok := a.t.(tHelper); ok {
  1342. h.Helper()
  1343. }
  1344. return Regexpf(a.t, rx, str, msg, args...)
  1345. }
  1346. // Same asserts that two pointers reference the same object.
  1347. //
  1348. // a.Same(ptr1, ptr2)
  1349. //
  1350. // Both arguments must be pointer variables. Pointer variable sameness is
  1351. // determined based on the equality of both type and value.
  1352. func (a *Assertions) Same(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool {
  1353. if h, ok := a.t.(tHelper); ok {
  1354. h.Helper()
  1355. }
  1356. return Same(a.t, expected, actual, msgAndArgs...)
  1357. }
  1358. // Samef asserts that two pointers reference the same object.
  1359. //
  1360. // a.Samef(ptr1, ptr2, "error message %s", "formatted")
  1361. //
  1362. // Both arguments must be pointer variables. Pointer variable sameness is
  1363. // determined based on the equality of both type and value.
  1364. func (a *Assertions) Samef(expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
  1365. if h, ok := a.t.(tHelper); ok {
  1366. h.Helper()
  1367. }
  1368. return Samef(a.t, expected, actual, msg, args...)
  1369. }
  1370. // Subset asserts that the specified list(array, slice...) or map contains all
  1371. // elements given in the specified subset list(array, slice...) or map.
  1372. //
  1373. // a.Subset([1, 2, 3], [1, 2])
  1374. // a.Subset({"x": 1, "y": 2}, {"x": 1})
  1375. func (a *Assertions) Subset(list interface{}, subset interface{}, msgAndArgs ...interface{}) bool {
  1376. if h, ok := a.t.(tHelper); ok {
  1377. h.Helper()
  1378. }
  1379. return Subset(a.t, list, subset, msgAndArgs...)
  1380. }
  1381. // Subsetf asserts that the specified list(array, slice...) or map contains all
  1382. // elements given in the specified subset list(array, slice...) or map.
  1383. //
  1384. // a.Subsetf([1, 2, 3], [1, 2], "error message %s", "formatted")
  1385. // a.Subsetf({"x": 1, "y": 2}, {"x": 1}, "error message %s", "formatted")
  1386. func (a *Assertions) Subsetf(list interface{}, subset interface{}, msg string, args ...interface{}) bool {
  1387. if h, ok := a.t.(tHelper); ok {
  1388. h.Helper()
  1389. }
  1390. return Subsetf(a.t, list, subset, msg, args...)
  1391. }
  1392. // True asserts that the specified value is true.
  1393. //
  1394. // a.True(myBool)
  1395. func (a *Assertions) True(value bool, msgAndArgs ...interface{}) bool {
  1396. if h, ok := a.t.(tHelper); ok {
  1397. h.Helper()
  1398. }
  1399. return True(a.t, value, msgAndArgs...)
  1400. }
  1401. // Truef asserts that the specified value is true.
  1402. //
  1403. // a.Truef(myBool, "error message %s", "formatted")
  1404. func (a *Assertions) Truef(value bool, msg string, args ...interface{}) bool {
  1405. if h, ok := a.t.(tHelper); ok {
  1406. h.Helper()
  1407. }
  1408. return Truef(a.t, value, msg, args...)
  1409. }
  1410. // WithinDuration asserts that the two times are within duration delta of each other.
  1411. //
  1412. // a.WithinDuration(time.Now(), time.Now(), 10*time.Second)
  1413. func (a *Assertions) WithinDuration(expected time.Time, actual time.Time, delta time.Duration, msgAndArgs ...interface{}) bool {
  1414. if h, ok := a.t.(tHelper); ok {
  1415. h.Helper()
  1416. }
  1417. return WithinDuration(a.t, expected, actual, delta, msgAndArgs...)
  1418. }
  1419. // WithinDurationf asserts that the two times are within duration delta of each other.
  1420. //
  1421. // a.WithinDurationf(time.Now(), time.Now(), 10*time.Second, "error message %s", "formatted")
  1422. func (a *Assertions) WithinDurationf(expected time.Time, actual time.Time, delta time.Duration, msg string, args ...interface{}) bool {
  1423. if h, ok := a.t.(tHelper); ok {
  1424. h.Helper()
  1425. }
  1426. return WithinDurationf(a.t, expected, actual, delta, msg, args...)
  1427. }
  1428. // WithinRange asserts that a time is within a time range (inclusive).
  1429. //
  1430. // a.WithinRange(time.Now(), time.Now().Add(-time.Second), time.Now().Add(time.Second))
  1431. func (a *Assertions) WithinRange(actual time.Time, start time.Time, end time.Time, msgAndArgs ...interface{}) bool {
  1432. if h, ok := a.t.(tHelper); ok {
  1433. h.Helper()
  1434. }
  1435. return WithinRange(a.t, actual, start, end, msgAndArgs...)
  1436. }
  1437. // WithinRangef asserts that a time is within a time range (inclusive).
  1438. //
  1439. // a.WithinRangef(time.Now(), time.Now().Add(-time.Second), time.Now().Add(time.Second), "error message %s", "formatted")
  1440. func (a *Assertions) WithinRangef(actual time.Time, start time.Time, end time.Time, msg string, args ...interface{}) bool {
  1441. if h, ok := a.t.(tHelper); ok {
  1442. h.Helper()
  1443. }
  1444. return WithinRangef(a.t, actual, start, end, msg, args...)
  1445. }
  1446. // YAMLEq asserts that two YAML strings are equivalent.
  1447. func (a *Assertions) YAMLEq(expected string, actual string, msgAndArgs ...interface{}) bool {
  1448. if h, ok := a.t.(tHelper); ok {
  1449. h.Helper()
  1450. }
  1451. return YAMLEq(a.t, expected, actual, msgAndArgs...)
  1452. }
  1453. // YAMLEqf asserts that two YAML strings are equivalent.
  1454. func (a *Assertions) YAMLEqf(expected string, actual string, msg string, args ...interface{}) bool {
  1455. if h, ok := a.t.(tHelper); ok {
  1456. h.Helper()
  1457. }
  1458. return YAMLEqf(a.t, expected, actual, msg, args...)
  1459. }
  1460. // Zero asserts that i is the zero value for its type.
  1461. func (a *Assertions) Zero(i interface{}, msgAndArgs ...interface{}) bool {
  1462. if h, ok := a.t.(tHelper); ok {
  1463. h.Helper()
  1464. }
  1465. return Zero(a.t, i, msgAndArgs...)
  1466. }
  1467. // Zerof asserts that i is the zero value for its type.
  1468. func (a *Assertions) Zerof(i interface{}, msg string, args ...interface{}) bool {
  1469. if h, ok := a.t.(tHelper); ok {
  1470. h.Helper()
  1471. }
  1472. return Zerof(a.t, i, msg, args...)
  1473. }