http urls monitor.

assertion_forward.go 34KB

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