require.go 56 KB

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