require_forward.go 11 KB

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