require_forward.go 13 KB

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