本站源代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

567 lines
22KB

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