require_forward.go 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  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. // Contains asserts that the specified string, list(array, slice...) or map contains the
  17. // specified substring or element.
  18. //
  19. // a.Contains("Hello World", "World", "But 'Hello World' does contain 'World'")
  20. // a.Contains(["Hello", "World"], "World", "But ["Hello", "World"] does contain 'World'")
  21. // a.Contains({"Hello": "World"}, "Hello", "But {'Hello': 'World'} does contain 'Hello'")
  22. //
  23. // Returns whether the assertion was successful (true) or not (false).
  24. func (a *Assertions) Contains(s interface{}, contains interface{}, msgAndArgs ...interface{}) {
  25. Contains(a.t, s, contains, msgAndArgs...)
  26. }
  27. // Empty asserts that the specified object is empty. I.e. nil, "", false, 0 or either
  28. // a slice or a channel with len == 0.
  29. //
  30. // a.Empty(obj)
  31. //
  32. // Returns whether the assertion was successful (true) or not (false).
  33. func (a *Assertions) Empty(object interface{}, msgAndArgs ...interface{}) {
  34. Empty(a.t, object, msgAndArgs...)
  35. }
  36. // Equal asserts that two objects are equal.
  37. //
  38. // a.Equal(123, 123, "123 and 123 should be equal")
  39. //
  40. // Returns whether the assertion was successful (true) or not (false).
  41. func (a *Assertions) Equal(expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
  42. Equal(a.t, expected, actual, msgAndArgs...)
  43. }
  44. // EqualError asserts that a function returned an error (i.e. not `nil`)
  45. // and that it is equal to the provided error.
  46. //
  47. // actualObj, err := SomeFunction()
  48. // if assert.Error(t, err, "An error was expected") {
  49. // assert.Equal(t, err, expectedError)
  50. // }
  51. //
  52. // Returns whether the assertion was successful (true) or not (false).
  53. func (a *Assertions) EqualError(theError error, errString string, msgAndArgs ...interface{}) {
  54. EqualError(a.t, theError, errString, msgAndArgs...)
  55. }
  56. // EqualValues asserts that two objects are equal or convertable to the same types
  57. // and equal.
  58. //
  59. // a.EqualValues(uint32(123), int32(123), "123 and 123 should be equal")
  60. //
  61. // Returns whether the assertion was successful (true) or not (false).
  62. func (a *Assertions) EqualValues(expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
  63. EqualValues(a.t, expected, actual, msgAndArgs...)
  64. }
  65. // Error asserts that a function returned an error (i.e. not `nil`).
  66. //
  67. // actualObj, err := SomeFunction()
  68. // if a.Error(err, "An error was expected") {
  69. // assert.Equal(t, err, expectedError)
  70. // }
  71. //
  72. // Returns whether the assertion was successful (true) or not (false).
  73. func (a *Assertions) Error(err error, msgAndArgs ...interface{}) {
  74. Error(a.t, err, msgAndArgs...)
  75. }
  76. // Exactly asserts that two objects are equal is value and type.
  77. //
  78. // a.Exactly(int32(123), int64(123), "123 and 123 should NOT be equal")
  79. //
  80. // Returns whether the assertion was successful (true) or not (false).
  81. func (a *Assertions) Exactly(expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
  82. Exactly(a.t, expected, actual, msgAndArgs...)
  83. }
  84. // Fail reports a failure through
  85. func (a *Assertions) Fail(failureMessage string, msgAndArgs ...interface{}) {
  86. Fail(a.t, failureMessage, msgAndArgs...)
  87. }
  88. // FailNow fails test
  89. func (a *Assertions) FailNow(failureMessage string, msgAndArgs ...interface{}) {
  90. FailNow(a.t, failureMessage, msgAndArgs...)
  91. }
  92. // False asserts that the specified value is false.
  93. //
  94. // a.False(myBool, "myBool should be false")
  95. //
  96. // Returns whether the assertion was successful (true) or not (false).
  97. func (a *Assertions) False(value bool, msgAndArgs ...interface{}) {
  98. False(a.t, value, msgAndArgs...)
  99. }
  100. // HTTPBodyContains asserts that a specified handler returns a
  101. // body that contains a string.
  102. //
  103. // a.HTTPBodyContains(myHandler, "www.google.com", nil, "I'm Feeling Lucky")
  104. //
  105. // Returns whether the assertion was successful (true) or not (false).
  106. func (a *Assertions) HTTPBodyContains(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}) {
  107. HTTPBodyContains(a.t, handler, method, url, values, str)
  108. }
  109. // HTTPBodyNotContains asserts that a specified handler returns a
  110. // body that does not contain a string.
  111. //
  112. // a.HTTPBodyNotContains(myHandler, "www.google.com", nil, "I'm Feeling Lucky")
  113. //
  114. // Returns whether the assertion was successful (true) or not (false).
  115. func (a *Assertions) HTTPBodyNotContains(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}) {
  116. HTTPBodyNotContains(a.t, handler, method, url, values, str)
  117. }
  118. // HTTPError asserts that a specified handler returns an error status code.
  119. //
  120. // a.HTTPError(myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}}
  121. //
  122. // Returns whether the assertion was successful (true) or not (false).
  123. func (a *Assertions) HTTPError(handler http.HandlerFunc, method string, url string, values url.Values) {
  124. HTTPError(a.t, handler, method, url, values)
  125. }
  126. // HTTPRedirect asserts that a specified handler returns a redirect status code.
  127. //
  128. // a.HTTPRedirect(myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}}
  129. //
  130. // Returns whether the assertion was successful (true) or not (false).
  131. func (a *Assertions) HTTPRedirect(handler http.HandlerFunc, method string, url string, values url.Values) {
  132. HTTPRedirect(a.t, handler, method, url, values)
  133. }
  134. // HTTPSuccess asserts that a specified handler returns a success status code.
  135. //
  136. // a.HTTPSuccess(myHandler, "POST", "http://www.google.com", nil)
  137. //
  138. // Returns whether the assertion was successful (true) or not (false).
  139. func (a *Assertions) HTTPSuccess(handler http.HandlerFunc, method string, url string, values url.Values) {
  140. HTTPSuccess(a.t, handler, method, url, values)
  141. }
  142. // Implements asserts that an object is implemented by the specified interface.
  143. //
  144. // a.Implements((*MyInterface)(nil), new(MyObject), "MyObject")
  145. func (a *Assertions) Implements(interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) {
  146. Implements(a.t, interfaceObject, object, msgAndArgs...)
  147. }
  148. // InDelta asserts that the two numerals are within delta of each other.
  149. //
  150. // a.InDelta(math.Pi, (22 / 7.0), 0.01)
  151. //
  152. // Returns whether the assertion was successful (true) or not (false).
  153. func (a *Assertions) InDelta(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) {
  154. InDelta(a.t, expected, actual, delta, msgAndArgs...)
  155. }
  156. // InDeltaSlice is the same as InDelta, except it compares two slices.
  157. func (a *Assertions) InDeltaSlice(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) {
  158. InDeltaSlice(a.t, expected, actual, delta, msgAndArgs...)
  159. }
  160. // InEpsilon asserts that expected and actual have a relative error less than epsilon
  161. //
  162. // Returns whether the assertion was successful (true) or not (false).
  163. func (a *Assertions) InEpsilon(expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{}) {
  164. InEpsilon(a.t, expected, actual, epsilon, msgAndArgs...)
  165. }
  166. // InEpsilonSlice is the same as InEpsilon, except it compares two slices.
  167. func (a *Assertions) InEpsilonSlice(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) {
  168. InEpsilonSlice(a.t, expected, actual, delta, msgAndArgs...)
  169. }
  170. // IsType asserts that the specified objects are of the same type.
  171. func (a *Assertions) IsType(expectedType interface{}, object interface{}, msgAndArgs ...interface{}) {
  172. IsType(a.t, expectedType, object, msgAndArgs...)
  173. }
  174. // JSONEq asserts that two JSON strings are equivalent.
  175. //
  176. // a.JSONEq(`{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`)
  177. //
  178. // Returns whether the assertion was successful (true) or not (false).
  179. func (a *Assertions) JSONEq(expected string, actual string, msgAndArgs ...interface{}) {
  180. JSONEq(a.t, expected, actual, msgAndArgs...)
  181. }
  182. // Len asserts that the specified object has specific length.
  183. // Len also fails if the object has a type that len() not accept.
  184. //
  185. // a.Len(mySlice, 3, "The size of slice is not 3")
  186. //
  187. // Returns whether the assertion was successful (true) or not (false).
  188. func (a *Assertions) Len(object interface{}, length int, msgAndArgs ...interface{}) {
  189. Len(a.t, object, length, msgAndArgs...)
  190. }
  191. // Nil asserts that the specified object is nil.
  192. //
  193. // a.Nil(err, "err should be nothing")
  194. //
  195. // Returns whether the assertion was successful (true) or not (false).
  196. func (a *Assertions) Nil(object interface{}, msgAndArgs ...interface{}) {
  197. Nil(a.t, object, msgAndArgs...)
  198. }
  199. // NoError asserts that a function returned no error (i.e. `nil`).
  200. //
  201. // actualObj, err := SomeFunction()
  202. // if a.NoError(err) {
  203. // assert.Equal(t, actualObj, expectedObj)
  204. // }
  205. //
  206. // Returns whether the assertion was successful (true) or not (false).
  207. func (a *Assertions) NoError(err error, msgAndArgs ...interface{}) {
  208. NoError(a.t, err, msgAndArgs...)
  209. }
  210. // NotContains asserts that the specified string, list(array, slice...) or map does NOT contain the
  211. // specified substring or element.
  212. //
  213. // a.NotContains("Hello World", "Earth", "But 'Hello World' does NOT contain 'Earth'")
  214. // a.NotContains(["Hello", "World"], "Earth", "But ['Hello', 'World'] does NOT contain 'Earth'")
  215. // a.NotContains({"Hello": "World"}, "Earth", "But {'Hello': 'World'} does NOT contain 'Earth'")
  216. //
  217. // Returns whether the assertion was successful (true) or not (false).
  218. func (a *Assertions) NotContains(s interface{}, contains interface{}, msgAndArgs ...interface{}) {
  219. NotContains(a.t, s, contains, msgAndArgs...)
  220. }
  221. // NotEmpty asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either
  222. // a slice or a channel with len == 0.
  223. //
  224. // if a.NotEmpty(obj) {
  225. // assert.Equal(t, "two", obj[1])
  226. // }
  227. //
  228. // Returns whether the assertion was successful (true) or not (false).
  229. func (a *Assertions) NotEmpty(object interface{}, msgAndArgs ...interface{}) {
  230. NotEmpty(a.t, object, msgAndArgs...)
  231. }
  232. // NotEqual asserts that the specified values are NOT equal.
  233. //
  234. // a.NotEqual(obj1, obj2, "two objects shouldn't be equal")
  235. //
  236. // Returns whether the assertion was successful (true) or not (false).
  237. func (a *Assertions) NotEqual(expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
  238. NotEqual(a.t, expected, actual, msgAndArgs...)
  239. }
  240. // NotNil asserts that the specified object is not nil.
  241. //
  242. // a.NotNil(err, "err should be something")
  243. //
  244. // Returns whether the assertion was successful (true) or not (false).
  245. func (a *Assertions) NotNil(object interface{}, msgAndArgs ...interface{}) {
  246. NotNil(a.t, object, msgAndArgs...)
  247. }
  248. // NotPanics asserts that the code inside the specified PanicTestFunc does NOT panic.
  249. //
  250. // a.NotPanics(func(){
  251. // RemainCalm()
  252. // }, "Calling RemainCalm() should NOT panic")
  253. //
  254. // Returns whether the assertion was successful (true) or not (false).
  255. func (a *Assertions) NotPanics(f assert.PanicTestFunc, msgAndArgs ...interface{}) {
  256. NotPanics(a.t, f, msgAndArgs...)
  257. }
  258. // NotRegexp asserts that a specified regexp does not match a string.
  259. //
  260. // a.NotRegexp(regexp.MustCompile("starts"), "it's starting")
  261. // a.NotRegexp("^start", "it's not starting")
  262. //
  263. // Returns whether the assertion was successful (true) or not (false).
  264. func (a *Assertions) NotRegexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) {
  265. NotRegexp(a.t, rx, str, msgAndArgs...)
  266. }
  267. // NotZero asserts that i is not the zero value for its type and returns the truth.
  268. func (a *Assertions) NotZero(i interface{}, msgAndArgs ...interface{}) {
  269. NotZero(a.t, i, msgAndArgs...)
  270. }
  271. // Panics asserts that the code inside the specified PanicTestFunc panics.
  272. //
  273. // a.Panics(func(){
  274. // GoCrazy()
  275. // }, "Calling GoCrazy() should panic")
  276. //
  277. // Returns whether the assertion was successful (true) or not (false).
  278. func (a *Assertions) Panics(f assert.PanicTestFunc, msgAndArgs ...interface{}) {
  279. Panics(a.t, f, msgAndArgs...)
  280. }
  281. // Regexp asserts that a specified regexp matches a string.
  282. //
  283. // a.Regexp(regexp.MustCompile("start"), "it's starting")
  284. // a.Regexp("start...$", "it's not starting")
  285. //
  286. // Returns whether the assertion was successful (true) or not (false).
  287. func (a *Assertions) Regexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) {
  288. Regexp(a.t, rx, str, msgAndArgs...)
  289. }
  290. // True asserts that the specified value is true.
  291. //
  292. // a.True(myBool, "myBool should be true")
  293. //
  294. // Returns whether the assertion was successful (true) or not (false).
  295. func (a *Assertions) True(value bool, msgAndArgs ...interface{}) {
  296. True(a.t, value, msgAndArgs...)
  297. }
  298. // WithinDuration asserts that the two times are within duration delta of each other.
  299. //
  300. // a.WithinDuration(time.Now(), time.Now(), 10*time.Second, "The difference should not be more than 10s")
  301. //
  302. // Returns whether the assertion was successful (true) or not (false).
  303. func (a *Assertions) WithinDuration(expected time.Time, actual time.Time, delta time.Duration, msgAndArgs ...interface{}) {
  304. WithinDuration(a.t, expected, actual, delta, msgAndArgs...)
  305. }
  306. // Zero asserts that i is the zero value for its type and returns the truth.
  307. func (a *Assertions) Zero(i interface{}, msgAndArgs ...interface{}) {
  308. Zero(a.t, i, msgAndArgs...)
  309. }