require_forward.go 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687
  1. /*
  2. * CODE GENERATED AUTOMATICALLY WITH github.com/stretchr/testify/_codegen
  3. * THIS FILE MUST NOT BE EDITED BY HAND
  4. */
  5. package require
  6. import (
  7. assert "github.com/stretchr/testify/assert"
  8. http "net/http"
  9. url "net/url"
  10. time "time"
  11. )
  12. // Condition uses a Comparison to assert a complex condition.
  13. func (a *Assertions) Condition(comp assert.Comparison, msgAndArgs ...interface{}) {
  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. Conditionf(a.t, comp, msg, args...)
  19. }
  20. // Contains asserts that the specified string, list(array, slice...) or map contains the
  21. // specified substring or element.
  22. //
  23. // a.Contains("Hello World", "World")
  24. // a.Contains(["Hello", "World"], "World")
  25. // a.Contains({"Hello": "World"}, "Hello")
  26. func (a *Assertions) Contains(s interface{}, contains interface{}, msgAndArgs ...interface{}) {
  27. Contains(a.t, s, contains, msgAndArgs...)
  28. }
  29. // Containsf asserts that the specified string, list(array, slice...) or map contains the
  30. // specified substring or element.
  31. //
  32. // a.Containsf("Hello World", "World", "error message %s", "formatted")
  33. // a.Containsf(["Hello", "World"], "World", "error message %s", "formatted")
  34. // a.Containsf({"Hello": "World"}, "Hello", "error message %s", "formatted")
  35. func (a *Assertions) Containsf(s interface{}, contains interface{}, msg string, args ...interface{}) {
  36. Containsf(a.t, s, contains, msg, args...)
  37. }
  38. // 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.
  39. func (a *Assertions) DirExists(path string, msgAndArgs ...interface{}) {
  40. DirExists(a.t, path, msgAndArgs...)
  41. }
  42. // 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.
  43. func (a *Assertions) DirExistsf(path string, msg string, args ...interface{}) {
  44. DirExistsf(a.t, path, msg, args...)
  45. }
  46. // ElementsMatch asserts that the specified listA(array, slice...) is equal to specified
  47. // listB(array, slice...) ignoring the order of the elements. If there are duplicate elements,
  48. // the number of appearances of each of them in both lists should match.
  49. //
  50. // a.ElementsMatch([1, 3, 2, 3], [1, 3, 3, 2])
  51. func (a *Assertions) ElementsMatch(listA interface{}, listB interface{}, msgAndArgs ...interface{}) {
  52. ElementsMatch(a.t, listA, listB, msgAndArgs...)
  53. }
  54. // ElementsMatchf asserts that the specified listA(array, slice...) is equal to specified
  55. // listB(array, slice...) ignoring the order of the elements. If there are duplicate elements,
  56. // the number of appearances of each of them in both lists should match.
  57. //
  58. // a.ElementsMatchf([1, 3, 2, 3], [1, 3, 3, 2], "error message %s", "formatted")
  59. func (a *Assertions) ElementsMatchf(listA interface{}, listB interface{}, msg string, args ...interface{}) {
  60. ElementsMatchf(a.t, listA, listB, msg, args...)
  61. }
  62. // Empty asserts that the specified object is empty. I.e. nil, "", false, 0 or either
  63. // a slice or a channel with len == 0.
  64. //
  65. // a.Empty(obj)
  66. func (a *Assertions) Empty(object interface{}, msgAndArgs ...interface{}) {
  67. Empty(a.t, object, msgAndArgs...)
  68. }
  69. // Emptyf asserts that the specified object is empty. I.e. nil, "", false, 0 or either
  70. // a slice or a channel with len == 0.
  71. //
  72. // a.Emptyf(obj, "error message %s", "formatted")
  73. func (a *Assertions) Emptyf(object interface{}, msg string, args ...interface{}) {
  74. Emptyf(a.t, object, msg, args...)
  75. }
  76. // Equal asserts that two objects are equal.
  77. //
  78. // a.Equal(123, 123)
  79. //
  80. // Pointer variable equality is determined based on the equality of the
  81. // referenced values (as opposed to the memory addresses). Function equality
  82. // cannot be determined and will always fail.
  83. func (a *Assertions) Equal(expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
  84. Equal(a.t, expected, actual, msgAndArgs...)
  85. }
  86. // EqualError asserts that a function returned an error (i.e. not `nil`)
  87. // and that it is equal to the provided error.
  88. //
  89. // actualObj, err := SomeFunction()
  90. // a.EqualError(err, expectedErrorString)
  91. func (a *Assertions) EqualError(theError error, errString string, msgAndArgs ...interface{}) {
  92. EqualError(a.t, theError, errString, msgAndArgs...)
  93. }
  94. // EqualErrorf asserts that a function returned an error (i.e. not `nil`)
  95. // and that it is equal to the provided error.
  96. //
  97. // actualObj, err := SomeFunction()
  98. // a.EqualErrorf(err, expectedErrorString, "error message %s", "formatted")
  99. func (a *Assertions) EqualErrorf(theError error, errString string, msg string, args ...interface{}) {
  100. EqualErrorf(a.t, theError, errString, msg, args...)
  101. }
  102. // EqualValues asserts that two objects are equal or convertable to the same types
  103. // and equal.
  104. //
  105. // a.EqualValues(uint32(123), int32(123))
  106. func (a *Assertions) EqualValues(expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
  107. EqualValues(a.t, expected, actual, msgAndArgs...)
  108. }
  109. // EqualValuesf asserts that two objects are equal or convertable to the same types
  110. // and equal.
  111. //
  112. // a.EqualValuesf(uint32(123, "error message %s", "formatted"), int32(123))
  113. func (a *Assertions) EqualValuesf(expected interface{}, actual interface{}, msg string, args ...interface{}) {
  114. EqualValuesf(a.t, expected, actual, msg, args...)
  115. }
  116. // Equalf asserts that two objects are equal.
  117. //
  118. // a.Equalf(123, 123, "error message %s", "formatted")
  119. //
  120. // Pointer variable equality is determined based on the equality of the
  121. // referenced values (as opposed to the memory addresses). Function equality
  122. // cannot be determined and will always fail.
  123. func (a *Assertions) Equalf(expected interface{}, actual interface{}, msg string, args ...interface{}) {
  124. Equalf(a.t, expected, actual, msg, args...)
  125. }
  126. // Error asserts that a function returned an error (i.e. not `nil`).
  127. //
  128. // actualObj, err := SomeFunction()
  129. // if a.Error(err) {
  130. // assert.Equal(t, expectedError, err)
  131. // }
  132. func (a *Assertions) Error(err error, msgAndArgs ...interface{}) {
  133. Error(a.t, err, msgAndArgs...)
  134. }
  135. // Errorf asserts that a function returned an error (i.e. not `nil`).
  136. //
  137. // actualObj, err := SomeFunction()
  138. // if a.Errorf(err, "error message %s", "formatted") {
  139. // assert.Equal(t, expectedErrorf, err)
  140. // }
  141. func (a *Assertions) Errorf(err error, msg string, args ...interface{}) {
  142. Errorf(a.t, err, msg, args...)
  143. }
  144. // Exactly asserts that two objects are equal in value and type.
  145. //
  146. // a.Exactly(int32(123), int64(123))
  147. func (a *Assertions) Exactly(expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
  148. Exactly(a.t, expected, actual, msgAndArgs...)
  149. }
  150. // Exactlyf asserts that two objects are equal in value and type.
  151. //
  152. // a.Exactlyf(int32(123, "error message %s", "formatted"), int64(123))
  153. func (a *Assertions) Exactlyf(expected interface{}, actual interface{}, msg string, args ...interface{}) {
  154. Exactlyf(a.t, expected, actual, msg, args...)
  155. }
  156. // Fail reports a failure through
  157. func (a *Assertions) Fail(failureMessage string, msgAndArgs ...interface{}) {
  158. Fail(a.t, failureMessage, msgAndArgs...)
  159. }
  160. // FailNow fails test
  161. func (a *Assertions) FailNow(failureMessage string, msgAndArgs ...interface{}) {
  162. FailNow(a.t, failureMessage, msgAndArgs...)
  163. }
  164. // FailNowf fails test
  165. func (a *Assertions) FailNowf(failureMessage string, msg string, args ...interface{}) {
  166. FailNowf(a.t, failureMessage, msg, args...)
  167. }
  168. // Failf reports a failure through
  169. func (a *Assertions) Failf(failureMessage string, msg string, args ...interface{}) {
  170. Failf(a.t, failureMessage, msg, args...)
  171. }
  172. // False asserts that the specified value is false.
  173. //
  174. // a.False(myBool)
  175. func (a *Assertions) False(value bool, msgAndArgs ...interface{}) {
  176. False(a.t, value, msgAndArgs...)
  177. }
  178. // Falsef asserts that the specified value is false.
  179. //
  180. // a.Falsef(myBool, "error message %s", "formatted")
  181. func (a *Assertions) Falsef(value bool, msg string, args ...interface{}) {
  182. Falsef(a.t, value, msg, args...)
  183. }
  184. // 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.
  185. func (a *Assertions) FileExists(path string, msgAndArgs ...interface{}) {
  186. FileExists(a.t, path, msgAndArgs...)
  187. }
  188. // 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.
  189. func (a *Assertions) FileExistsf(path string, msg string, args ...interface{}) {
  190. FileExistsf(a.t, path, msg, args...)
  191. }
  192. // HTTPBodyContains asserts that a specified handler returns a
  193. // body that contains a string.
  194. //
  195. // a.HTTPBodyContains(myHandler, "www.google.com", nil, "I'm Feeling Lucky")
  196. //
  197. // Returns whether the assertion was successful (true) or not (false).
  198. func (a *Assertions) HTTPBodyContains(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) {
  199. HTTPBodyContains(a.t, handler, method, url, values, str, msgAndArgs...)
  200. }
  201. // HTTPBodyContainsf asserts that a specified handler returns a
  202. // body that contains a string.
  203. //
  204. // a.HTTPBodyContainsf(myHandler, "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted")
  205. //
  206. // Returns whether the assertion was successful (true) or not (false).
  207. func (a *Assertions) HTTPBodyContainsf(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) {
  208. HTTPBodyContainsf(a.t, handler, method, url, values, str, msg, args...)
  209. }
  210. // HTTPBodyNotContains asserts that a specified handler returns a
  211. // body that does not contain a string.
  212. //
  213. // a.HTTPBodyNotContains(myHandler, "www.google.com", nil, "I'm Feeling Lucky")
  214. //
  215. // Returns whether the assertion was successful (true) or not (false).
  216. func (a *Assertions) HTTPBodyNotContains(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) {
  217. HTTPBodyNotContains(a.t, handler, method, url, values, str, msgAndArgs...)
  218. }
  219. // HTTPBodyNotContainsf asserts that a specified handler returns a
  220. // body that does not contain a string.
  221. //
  222. // a.HTTPBodyNotContainsf(myHandler, "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted")
  223. //
  224. // Returns whether the assertion was successful (true) or not (false).
  225. func (a *Assertions) HTTPBodyNotContainsf(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) {
  226. HTTPBodyNotContainsf(a.t, handler, method, url, values, str, msg, args...)
  227. }
  228. // HTTPError asserts that a specified handler returns an error status code.
  229. //
  230. // a.HTTPError(myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}}
  231. //
  232. // Returns whether the assertion was successful (true) or not (false).
  233. func (a *Assertions) HTTPError(handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) {
  234. HTTPError(a.t, handler, method, url, values, msgAndArgs...)
  235. }
  236. // HTTPErrorf asserts that a specified handler returns an error status code.
  237. //
  238. // a.HTTPErrorf(myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}}
  239. //
  240. // Returns whether the assertion was successful (true, "error message %s", "formatted") or not (false).
  241. func (a *Assertions) HTTPErrorf(handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) {
  242. HTTPErrorf(a.t, handler, method, url, values, msg, args...)
  243. }
  244. // HTTPRedirect asserts that a specified handler returns a redirect status code.
  245. //
  246. // a.HTTPRedirect(myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}}
  247. //
  248. // Returns whether the assertion was successful (true) or not (false).
  249. func (a *Assertions) HTTPRedirect(handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) {
  250. HTTPRedirect(a.t, handler, method, url, values, msgAndArgs...)
  251. }
  252. // HTTPRedirectf asserts that a specified handler returns a redirect status code.
  253. //
  254. // a.HTTPRedirectf(myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}}
  255. //
  256. // Returns whether the assertion was successful (true, "error message %s", "formatted") or not (false).
  257. func (a *Assertions) HTTPRedirectf(handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) {
  258. HTTPRedirectf(a.t, handler, method, url, values, msg, args...)
  259. }
  260. // HTTPSuccess asserts that a specified handler returns a success status code.
  261. //
  262. // a.HTTPSuccess(myHandler, "POST", "http://www.google.com", nil)
  263. //
  264. // Returns whether the assertion was successful (true) or not (false).
  265. func (a *Assertions) HTTPSuccess(handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) {
  266. HTTPSuccess(a.t, handler, method, url, values, msgAndArgs...)
  267. }
  268. // HTTPSuccessf asserts that a specified handler returns a success status code.
  269. //
  270. // a.HTTPSuccessf(myHandler, "POST", "http://www.google.com", nil, "error message %s", "formatted")
  271. //
  272. // Returns whether the assertion was successful (true) or not (false).
  273. func (a *Assertions) HTTPSuccessf(handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) {
  274. HTTPSuccessf(a.t, handler, method, url, values, msg, args...)
  275. }
  276. // Implements asserts that an object is implemented by the specified interface.
  277. //
  278. // a.Implements((*MyInterface)(nil), new(MyObject))
  279. func (a *Assertions) Implements(interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) {
  280. Implements(a.t, interfaceObject, object, msgAndArgs...)
  281. }
  282. // Implementsf asserts that an object is implemented by the specified interface.
  283. //
  284. // a.Implementsf((*MyInterface, "error message %s", "formatted")(nil), new(MyObject))
  285. func (a *Assertions) Implementsf(interfaceObject interface{}, object interface{}, msg string, args ...interface{}) {
  286. Implementsf(a.t, interfaceObject, object, msg, args...)
  287. }
  288. // InDelta asserts that the two numerals are within delta of each other.
  289. //
  290. // a.InDelta(math.Pi, (22 / 7.0), 0.01)
  291. func (a *Assertions) InDelta(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) {
  292. InDelta(a.t, expected, actual, delta, msgAndArgs...)
  293. }
  294. // InDeltaMapValues is the same as InDelta, but it compares all values between two maps. Both maps must have exactly the same keys.
  295. func (a *Assertions) InDeltaMapValues(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) {
  296. InDeltaMapValues(a.t, expected, actual, delta, msgAndArgs...)
  297. }
  298. // InDeltaMapValuesf is the same as InDelta, but it compares all values between two maps. Both maps must have exactly the same keys.
  299. func (a *Assertions) InDeltaMapValuesf(expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) {
  300. InDeltaMapValuesf(a.t, expected, actual, delta, msg, args...)
  301. }
  302. // InDeltaSlice is the same as InDelta, except it compares two slices.
  303. func (a *Assertions) InDeltaSlice(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) {
  304. InDeltaSlice(a.t, expected, actual, delta, msgAndArgs...)
  305. }
  306. // InDeltaSlicef is the same as InDelta, except it compares two slices.
  307. func (a *Assertions) InDeltaSlicef(expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) {
  308. InDeltaSlicef(a.t, expected, actual, delta, msg, args...)
  309. }
  310. // InDeltaf asserts that the two numerals are within delta of each other.
  311. //
  312. // a.InDeltaf(math.Pi, (22 / 7.0, "error message %s", "formatted"), 0.01)
  313. func (a *Assertions) InDeltaf(expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) {
  314. InDeltaf(a.t, expected, actual, delta, msg, args...)
  315. }
  316. // InEpsilon asserts that expected and actual have a relative error less than epsilon
  317. func (a *Assertions) InEpsilon(expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{}) {
  318. InEpsilon(a.t, expected, actual, epsilon, msgAndArgs...)
  319. }
  320. // InEpsilonSlice is the same as InEpsilon, except it compares each value from two slices.
  321. func (a *Assertions) InEpsilonSlice(expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{}) {
  322. InEpsilonSlice(a.t, expected, actual, epsilon, msgAndArgs...)
  323. }
  324. // InEpsilonSlicef is the same as InEpsilon, except it compares each value from two slices.
  325. func (a *Assertions) InEpsilonSlicef(expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) {
  326. InEpsilonSlicef(a.t, expected, actual, epsilon, msg, args...)
  327. }
  328. // InEpsilonf asserts that expected and actual have a relative error less than epsilon
  329. func (a *Assertions) InEpsilonf(expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) {
  330. InEpsilonf(a.t, expected, actual, epsilon, msg, args...)
  331. }
  332. // IsType asserts that the specified objects are of the same type.
  333. func (a *Assertions) IsType(expectedType interface{}, object interface{}, msgAndArgs ...interface{}) {
  334. IsType(a.t, expectedType, object, msgAndArgs...)
  335. }
  336. // IsTypef asserts that the specified objects are of the same type.
  337. func (a *Assertions) IsTypef(expectedType interface{}, object interface{}, msg string, args ...interface{}) {
  338. IsTypef(a.t, expectedType, object, msg, args...)
  339. }
  340. // JSONEq asserts that two JSON strings are equivalent.
  341. //
  342. // a.JSONEq(`{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`)
  343. func (a *Assertions) JSONEq(expected string, actual string, msgAndArgs ...interface{}) {
  344. JSONEq(a.t, expected, actual, msgAndArgs...)
  345. }
  346. // JSONEqf asserts that two JSON strings are equivalent.
  347. //
  348. // a.JSONEqf(`{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`, "error message %s", "formatted")
  349. func (a *Assertions) JSONEqf(expected string, actual string, msg string, args ...interface{}) {
  350. JSONEqf(a.t, expected, actual, msg, args...)
  351. }
  352. // Len asserts that the specified object has specific length.
  353. // Len also fails if the object has a type that len() not accept.
  354. //
  355. // a.Len(mySlice, 3)
  356. func (a *Assertions) Len(object interface{}, length int, msgAndArgs ...interface{}) {
  357. Len(a.t, object, length, msgAndArgs...)
  358. }
  359. // Lenf asserts that the specified object has specific length.
  360. // Lenf also fails if the object has a type that len() not accept.
  361. //
  362. // a.Lenf(mySlice, 3, "error message %s", "formatted")
  363. func (a *Assertions) Lenf(object interface{}, length int, msg string, args ...interface{}) {
  364. Lenf(a.t, object, length, msg, args...)
  365. }
  366. // Nil asserts that the specified object is nil.
  367. //
  368. // a.Nil(err)
  369. func (a *Assertions) Nil(object interface{}, msgAndArgs ...interface{}) {
  370. Nil(a.t, object, msgAndArgs...)
  371. }
  372. // Nilf asserts that the specified object is nil.
  373. //
  374. // a.Nilf(err, "error message %s", "formatted")
  375. func (a *Assertions) Nilf(object interface{}, msg string, args ...interface{}) {
  376. Nilf(a.t, object, msg, args...)
  377. }
  378. // NoError asserts that a function returned no error (i.e. `nil`).
  379. //
  380. // actualObj, err := SomeFunction()
  381. // if a.NoError(err) {
  382. // assert.Equal(t, expectedObj, actualObj)
  383. // }
  384. func (a *Assertions) NoError(err error, msgAndArgs ...interface{}) {
  385. NoError(a.t, err, msgAndArgs...)
  386. }
  387. // NoErrorf asserts that a function returned no error (i.e. `nil`).
  388. //
  389. // actualObj, err := SomeFunction()
  390. // if a.NoErrorf(err, "error message %s", "formatted") {
  391. // assert.Equal(t, expectedObj, actualObj)
  392. // }
  393. func (a *Assertions) NoErrorf(err error, msg string, args ...interface{}) {
  394. NoErrorf(a.t, err, msg, args...)
  395. }
  396. // NotContains asserts that the specified string, list(array, slice...) or map does NOT contain the
  397. // specified substring or element.
  398. //
  399. // a.NotContains("Hello World", "Earth")
  400. // a.NotContains(["Hello", "World"], "Earth")
  401. // a.NotContains({"Hello": "World"}, "Earth")
  402. func (a *Assertions) NotContains(s interface{}, contains interface{}, msgAndArgs ...interface{}) {
  403. NotContains(a.t, s, contains, msgAndArgs...)
  404. }
  405. // NotContainsf asserts that the specified string, list(array, slice...) or map does NOT contain the
  406. // specified substring or element.
  407. //
  408. // a.NotContainsf("Hello World", "Earth", "error message %s", "formatted")
  409. // a.NotContainsf(["Hello", "World"], "Earth", "error message %s", "formatted")
  410. // a.NotContainsf({"Hello": "World"}, "Earth", "error message %s", "formatted")
  411. func (a *Assertions) NotContainsf(s interface{}, contains interface{}, msg string, args ...interface{}) {
  412. NotContainsf(a.t, s, contains, msg, args...)
  413. }
  414. // NotEmpty asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either
  415. // a slice or a channel with len == 0.
  416. //
  417. // if a.NotEmpty(obj) {
  418. // assert.Equal(t, "two", obj[1])
  419. // }
  420. func (a *Assertions) NotEmpty(object interface{}, msgAndArgs ...interface{}) {
  421. NotEmpty(a.t, object, msgAndArgs...)
  422. }
  423. // NotEmptyf asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either
  424. // a slice or a channel with len == 0.
  425. //
  426. // if a.NotEmptyf(obj, "error message %s", "formatted") {
  427. // assert.Equal(t, "two", obj[1])
  428. // }
  429. func (a *Assertions) NotEmptyf(object interface{}, msg string, args ...interface{}) {
  430. NotEmptyf(a.t, object, msg, args...)
  431. }
  432. // NotEqual asserts that the specified values are NOT equal.
  433. //
  434. // a.NotEqual(obj1, obj2)
  435. //
  436. // Pointer variable equality is determined based on the equality of the
  437. // referenced values (as opposed to the memory addresses).
  438. func (a *Assertions) NotEqual(expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
  439. NotEqual(a.t, expected, actual, msgAndArgs...)
  440. }
  441. // NotEqualf asserts that the specified values are NOT equal.
  442. //
  443. // a.NotEqualf(obj1, obj2, "error message %s", "formatted")
  444. //
  445. // Pointer variable equality is determined based on the equality of the
  446. // referenced values (as opposed to the memory addresses).
  447. func (a *Assertions) NotEqualf(expected interface{}, actual interface{}, msg string, args ...interface{}) {
  448. NotEqualf(a.t, expected, actual, msg, args...)
  449. }
  450. // NotNil asserts that the specified object is not nil.
  451. //
  452. // a.NotNil(err)
  453. func (a *Assertions) NotNil(object interface{}, msgAndArgs ...interface{}) {
  454. NotNil(a.t, object, msgAndArgs...)
  455. }
  456. // NotNilf asserts that the specified object is not nil.
  457. //
  458. // a.NotNilf(err, "error message %s", "formatted")
  459. func (a *Assertions) NotNilf(object interface{}, msg string, args ...interface{}) {
  460. NotNilf(a.t, object, msg, args...)
  461. }
  462. // NotPanics asserts that the code inside the specified PanicTestFunc does NOT panic.
  463. //
  464. // a.NotPanics(func(){ RemainCalm() })
  465. func (a *Assertions) NotPanics(f assert.PanicTestFunc, msgAndArgs ...interface{}) {
  466. NotPanics(a.t, f, msgAndArgs...)
  467. }
  468. // NotPanicsf asserts that the code inside the specified PanicTestFunc does NOT panic.
  469. //
  470. // a.NotPanicsf(func(){ RemainCalm() }, "error message %s", "formatted")
  471. func (a *Assertions) NotPanicsf(f assert.PanicTestFunc, msg string, args ...interface{}) {
  472. NotPanicsf(a.t, f, msg, args...)
  473. }
  474. // NotRegexp asserts that a specified regexp does not match a string.
  475. //
  476. // a.NotRegexp(regexp.MustCompile("starts"), "it's starting")
  477. // a.NotRegexp("^start", "it's not starting")
  478. func (a *Assertions) NotRegexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) {
  479. NotRegexp(a.t, rx, str, msgAndArgs...)
  480. }
  481. // NotRegexpf asserts that a specified regexp does not match a string.
  482. //
  483. // a.NotRegexpf(regexp.MustCompile("starts", "error message %s", "formatted"), "it's starting")
  484. // a.NotRegexpf("^start", "it's not starting", "error message %s", "formatted")
  485. func (a *Assertions) NotRegexpf(rx interface{}, str interface{}, msg string, args ...interface{}) {
  486. NotRegexpf(a.t, rx, str, msg, args...)
  487. }
  488. // NotSubset asserts that the specified list(array, slice...) contains not all
  489. // elements given in the specified subset(array, slice...).
  490. //
  491. // a.NotSubset([1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]")
  492. func (a *Assertions) NotSubset(list interface{}, subset interface{}, msgAndArgs ...interface{}) {
  493. NotSubset(a.t, list, subset, msgAndArgs...)
  494. }
  495. // NotSubsetf asserts that the specified list(array, slice...) contains not all
  496. // elements given in the specified subset(array, slice...).
  497. //
  498. // a.NotSubsetf([1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]", "error message %s", "formatted")
  499. func (a *Assertions) NotSubsetf(list interface{}, subset interface{}, msg string, args ...interface{}) {
  500. NotSubsetf(a.t, list, subset, msg, args...)
  501. }
  502. // NotZero asserts that i is not the zero value for its type.
  503. func (a *Assertions) NotZero(i interface{}, msgAndArgs ...interface{}) {
  504. NotZero(a.t, i, msgAndArgs...)
  505. }
  506. // NotZerof asserts that i is not the zero value for its type.
  507. func (a *Assertions) NotZerof(i interface{}, msg string, args ...interface{}) {
  508. NotZerof(a.t, i, msg, args...)
  509. }
  510. // Panics asserts that the code inside the specified PanicTestFunc panics.
  511. //
  512. // a.Panics(func(){ GoCrazy() })
  513. func (a *Assertions) Panics(f assert.PanicTestFunc, msgAndArgs ...interface{}) {
  514. Panics(a.t, f, msgAndArgs...)
  515. }
  516. // PanicsWithValue asserts that the code inside the specified PanicTestFunc panics, and that
  517. // the recovered panic value equals the expected panic value.
  518. //
  519. // a.PanicsWithValue("crazy error", func(){ GoCrazy() })
  520. func (a *Assertions) PanicsWithValue(expected interface{}, f assert.PanicTestFunc, msgAndArgs ...interface{}) {
  521. PanicsWithValue(a.t, expected, f, msgAndArgs...)
  522. }
  523. // PanicsWithValuef asserts that the code inside the specified PanicTestFunc panics, and that
  524. // the recovered panic value equals the expected panic value.
  525. //
  526. // a.PanicsWithValuef("crazy error", func(){ GoCrazy() }, "error message %s", "formatted")
  527. func (a *Assertions) PanicsWithValuef(expected interface{}, f assert.PanicTestFunc, msg string, args ...interface{}) {
  528. PanicsWithValuef(a.t, expected, f, msg, args...)
  529. }
  530. // Panicsf asserts that the code inside the specified PanicTestFunc panics.
  531. //
  532. // a.Panicsf(func(){ GoCrazy() }, "error message %s", "formatted")
  533. func (a *Assertions) Panicsf(f assert.PanicTestFunc, msg string, args ...interface{}) {
  534. Panicsf(a.t, f, msg, args...)
  535. }
  536. // Regexp asserts that a specified regexp matches a string.
  537. //
  538. // a.Regexp(regexp.MustCompile("start"), "it's starting")
  539. // a.Regexp("start...$", "it's not starting")
  540. func (a *Assertions) Regexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) {
  541. Regexp(a.t, rx, str, msgAndArgs...)
  542. }
  543. // Regexpf asserts that a specified regexp matches a string.
  544. //
  545. // a.Regexpf(regexp.MustCompile("start", "error message %s", "formatted"), "it's starting")
  546. // a.Regexpf("start...$", "it's not starting", "error message %s", "formatted")
  547. func (a *Assertions) Regexpf(rx interface{}, str interface{}, msg string, args ...interface{}) {
  548. Regexpf(a.t, rx, str, msg, args...)
  549. }
  550. // Subset asserts that the specified list(array, slice...) contains all
  551. // elements given in the specified subset(array, slice...).
  552. //
  553. // a.Subset([1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]")
  554. func (a *Assertions) Subset(list interface{}, subset interface{}, msgAndArgs ...interface{}) {
  555. Subset(a.t, list, subset, msgAndArgs...)
  556. }
  557. // Subsetf asserts that the specified list(array, slice...) contains all
  558. // elements given in the specified subset(array, slice...).
  559. //
  560. // a.Subsetf([1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]", "error message %s", "formatted")
  561. func (a *Assertions) Subsetf(list interface{}, subset interface{}, msg string, args ...interface{}) {
  562. Subsetf(a.t, list, subset, msg, args...)
  563. }
  564. // True asserts that the specified value is true.
  565. //
  566. // a.True(myBool)
  567. func (a *Assertions) True(value bool, msgAndArgs ...interface{}) {
  568. True(a.t, value, msgAndArgs...)
  569. }
  570. // Truef asserts that the specified value is true.
  571. //
  572. // a.Truef(myBool, "error message %s", "formatted")
  573. func (a *Assertions) Truef(value bool, msg string, args ...interface{}) {
  574. Truef(a.t, value, msg, args...)
  575. }
  576. // WithinDuration asserts that the two times are within duration delta of each other.
  577. //
  578. // a.WithinDuration(time.Now(), time.Now(), 10*time.Second)
  579. func (a *Assertions) WithinDuration(expected time.Time, actual time.Time, delta time.Duration, msgAndArgs ...interface{}) {
  580. WithinDuration(a.t, expected, actual, delta, msgAndArgs...)
  581. }
  582. // WithinDurationf asserts that the two times are within duration delta of each other.
  583. //
  584. // a.WithinDurationf(time.Now(), time.Now(), 10*time.Second, "error message %s", "formatted")
  585. func (a *Assertions) WithinDurationf(expected time.Time, actual time.Time, delta time.Duration, msg string, args ...interface{}) {
  586. WithinDurationf(a.t, expected, actual, delta, msg, args...)
  587. }
  588. // Zero asserts that i is the zero value for its type.
  589. func (a *Assertions) Zero(i interface{}, msgAndArgs ...interface{}) {
  590. Zero(a.t, i, msgAndArgs...)
  591. }
  592. // Zerof asserts that i is the zero value for its type.
  593. func (a *Assertions) Zerof(i interface{}, msg string, args ...interface{}) {
  594. Zerof(a.t, i, msg, args...)
  595. }