require.go 57 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935
  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. // WithinRange asserts that a time is within a time range (inclusive).
  1731. //
  1732. // assert.WithinRange(t, time.Now(), time.Now().Add(-time.Second), time.Now().Add(time.Second))
  1733. func WithinRange(t TestingT, actual time.Time, start time.Time, end time.Time, msgAndArgs ...interface{}) {
  1734. if h, ok := t.(tHelper); ok {
  1735. h.Helper()
  1736. }
  1737. if assert.WithinRange(t, actual, start, end, msgAndArgs...) {
  1738. return
  1739. }
  1740. t.FailNow()
  1741. }
  1742. // WithinRangef asserts that a time is within a time range (inclusive).
  1743. //
  1744. // assert.WithinRangef(t, time.Now(), time.Now().Add(-time.Second), time.Now().Add(time.Second), "error message %s", "formatted")
  1745. func WithinRangef(t TestingT, actual time.Time, start time.Time, end time.Time, msg string, args ...interface{}) {
  1746. if h, ok := t.(tHelper); ok {
  1747. h.Helper()
  1748. }
  1749. if assert.WithinRangef(t, actual, start, end, msg, args...) {
  1750. return
  1751. }
  1752. t.FailNow()
  1753. }
  1754. // YAMLEq asserts that two YAML strings are equivalent.
  1755. func YAMLEq(t TestingT, expected string, actual string, msgAndArgs ...interface{}) {
  1756. if h, ok := t.(tHelper); ok {
  1757. h.Helper()
  1758. }
  1759. if assert.YAMLEq(t, expected, actual, msgAndArgs...) {
  1760. return
  1761. }
  1762. t.FailNow()
  1763. }
  1764. // YAMLEqf asserts that two YAML strings are equivalent.
  1765. func YAMLEqf(t TestingT, expected string, actual string, msg string, args ...interface{}) {
  1766. if h, ok := t.(tHelper); ok {
  1767. h.Helper()
  1768. }
  1769. if assert.YAMLEqf(t, expected, actual, msg, args...) {
  1770. return
  1771. }
  1772. t.FailNow()
  1773. }
  1774. // Zero asserts that i is the zero value for its type.
  1775. func Zero(t TestingT, i interface{}, msgAndArgs ...interface{}) {
  1776. if h, ok := t.(tHelper); ok {
  1777. h.Helper()
  1778. }
  1779. if assert.Zero(t, i, msgAndArgs...) {
  1780. return
  1781. }
  1782. t.FailNow()
  1783. }
  1784. // Zerof asserts that i is the zero value for its type.
  1785. func Zerof(t TestingT, i interface{}, msg string, args ...interface{}) {
  1786. if h, ok := t.(tHelper); ok {
  1787. h.Helper()
  1788. }
  1789. if assert.Zerof(t, i, msg, args...) {
  1790. return
  1791. }
  1792. t.FailNow()
  1793. }