require_forward.go 56 KB

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