9 func TestImplementsWrapper(t *testing.T) {
12 require.Implements((*AssertionTesterInterface)(nil), new(AssertionTesterConformingObject))
15 mockRequire := New(mockT)
16 mockRequire.Implements((*AssertionTesterInterface)(nil), new(AssertionTesterNonConformingObject))
18 t.Error("Check should fail")
22 func TestIsTypeWrapper(t *testing.T) {
24 require.IsType(new(AssertionTesterConformingObject), new(AssertionTesterConformingObject))
27 mockRequire := New(mockT)
28 mockRequire.IsType(new(AssertionTesterConformingObject), new(AssertionTesterNonConformingObject))
30 t.Error("Check should fail")
34 func TestEqualWrapper(t *testing.T) {
39 mockRequire := New(mockT)
40 mockRequire.Equal(1, 2)
42 t.Error("Check should fail")
46 func TestNotEqualWrapper(t *testing.T) {
48 require.NotEqual(1, 2)
51 mockRequire := New(mockT)
52 mockRequire.NotEqual(2, 2)
54 t.Error("Check should fail")
58 func TestExactlyWrapper(t *testing.T) {
68 mockRequire := New(mockT)
69 mockRequire.Exactly(a, c)
71 t.Error("Check should fail")
75 func TestNotNilWrapper(t *testing.T) {
77 require.NotNil(t, new(AssertionTesterConformingObject))
80 mockRequire := New(mockT)
81 mockRequire.NotNil(nil)
83 t.Error("Check should fail")
87 func TestNilWrapper(t *testing.T) {
92 mockRequire := New(mockT)
93 mockRequire.Nil(new(AssertionTesterConformingObject))
95 t.Error("Check should fail")
99 func TestTrueWrapper(t *testing.T) {
104 mockRequire := New(mockT)
105 mockRequire.True(false)
107 t.Error("Check should fail")
111 func TestFalseWrapper(t *testing.T) {
116 mockRequire := New(mockT)
117 mockRequire.False(true)
119 t.Error("Check should fail")
123 func TestContainsWrapper(t *testing.T) {
125 require.Contains("Hello World", "Hello")
128 mockRequire := New(mockT)
129 mockRequire.Contains("Hello World", "Salut")
131 t.Error("Check should fail")
135 func TestNotContainsWrapper(t *testing.T) {
137 require.NotContains("Hello World", "Hello!")
140 mockRequire := New(mockT)
141 mockRequire.NotContains("Hello World", "Hello")
143 t.Error("Check should fail")
147 func TestPanicsWrapper(t *testing.T) {
149 require.Panics(func() {
154 mockRequire := New(mockT)
155 mockRequire.Panics(func() {})
157 t.Error("Check should fail")
161 func TestNotPanicsWrapper(t *testing.T) {
163 require.NotPanics(func() {})
166 mockRequire := New(mockT)
167 mockRequire.NotPanics(func() {
171 t.Error("Check should fail")
175 func TestNoErrorWrapper(t *testing.T) {
180 mockRequire := New(mockT)
181 mockRequire.NoError(errors.New("some error"))
183 t.Error("Check should fail")
187 func TestErrorWrapper(t *testing.T) {
189 require.Error(errors.New("some error"))
192 mockRequire := New(mockT)
193 mockRequire.Error(nil)
195 t.Error("Check should fail")
199 func TestEqualErrorWrapper(t *testing.T) {
201 require.EqualError(errors.New("some error"), "some error")
204 mockRequire := New(mockT)
205 mockRequire.EqualError(errors.New("some error"), "Not some error")
207 t.Error("Check should fail")
211 func TestEmptyWrapper(t *testing.T) {
216 mockRequire := New(mockT)
217 mockRequire.Empty("x")
219 t.Error("Check should fail")
223 func TestNotEmptyWrapper(t *testing.T) {
225 require.NotEmpty("x")
228 mockRequire := New(mockT)
229 mockRequire.NotEmpty("")
231 t.Error("Check should fail")
235 func TestWithinDurationWrapper(t *testing.T) {
238 b := a.Add(10 * time.Second)
240 require.WithinDuration(a, b, 15*time.Second)
243 mockRequire := New(mockT)
244 mockRequire.WithinDuration(a, b, 5*time.Second)
246 t.Error("Check should fail")
250 func TestInDeltaWrapper(t *testing.T) {
252 require.InDelta(1.001, 1, 0.01)
255 mockRequire := New(mockT)
256 mockRequire.InDelta(1, 2, 0.5)
258 t.Error("Check should fail")
262 func TestZeroWrapper(t *testing.T) {
267 mockRequire := New(mockT)
270 t.Error("Check should fail")
274 func TestNotZeroWrapper(t *testing.T) {
279 mockRequire := New(mockT)
280 mockRequire.NotZero(0)
282 t.Error("Check should fail")
286 func TestJSONEqWrapper_EqualSONString(t *testing.T) {
288 mockRequire := New(mockT)
290 mockRequire.JSONEq(`{"hello": "world", "foo": "bar"}`, `{"hello": "world", "foo": "bar"}`)
292 t.Error("Check should pass")
296 func TestJSONEqWrapper_EquivalentButNotEqual(t *testing.T) {
298 mockRequire := New(mockT)
300 mockRequire.JSONEq(`{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`)
302 t.Error("Check should pass")
306 func TestJSONEqWrapper_HashOfArraysAndHashes(t *testing.T) {
308 mockRequire := New(mockT)
310 mockRequire.JSONEq("{\r\n\t\"numeric\": 1.5,\r\n\t\"array\": [{\"foo\": \"bar\"}, 1, \"string\", [\"nested\", \"array\", 5.5]],\r\n\t\"hash\": {\"nested\": \"hash\", \"nested_slice\": [\"this\", \"is\", \"nested\"]},\r\n\t\"string\": \"foo\"\r\n}",
311 "{\r\n\t\"numeric\": 1.5,\r\n\t\"hash\": {\"nested\": \"hash\", \"nested_slice\": [\"this\", \"is\", \"nested\"]},\r\n\t\"string\": \"foo\",\r\n\t\"array\": [{\"foo\": \"bar\"}, 1, \"string\", [\"nested\", \"array\", 5.5]]\r\n}")
313 t.Error("Check should pass")
317 func TestJSONEqWrapper_Array(t *testing.T) {
319 mockRequire := New(mockT)
321 mockRequire.JSONEq(`["foo", {"hello": "world", "nested": "hash"}]`, `["foo", {"nested": "hash", "hello": "world"}]`)
323 t.Error("Check should pass")
327 func TestJSONEqWrapper_HashAndArrayNotEquivalent(t *testing.T) {
329 mockRequire := New(mockT)
331 mockRequire.JSONEq(`["foo", {"hello": "world", "nested": "hash"}]`, `{"foo": "bar", {"nested": "hash", "hello": "world"}}`)
333 t.Error("Check should fail")
337 func TestJSONEqWrapper_HashesNotEquivalent(t *testing.T) {
339 mockRequire := New(mockT)
341 mockRequire.JSONEq(`{"foo": "bar"}`, `{"foo": "bar", "hello": "world"}`)
343 t.Error("Check should fail")
347 func TestJSONEqWrapper_ActualIsNotJSON(t *testing.T) {
349 mockRequire := New(mockT)
351 mockRequire.JSONEq(`{"foo": "bar"}`, "Not JSON")
353 t.Error("Check should fail")
357 func TestJSONEqWrapper_ExpectedIsNotJSON(t *testing.T) {
359 mockRequire := New(mockT)
361 mockRequire.JSONEq("Not JSON", `{"foo": "bar", "hello": "world"}`)
363 t.Error("Check should fail")
367 func TestJSONEqWrapper_ExpectedAndActualNotJSON(t *testing.T) {
369 mockRequire := New(mockT)
371 mockRequire.JSONEq("Not JSON", "Not JSON")
373 t.Error("Check should fail")
377 func TestJSONEqWrapper_ArraysOfDifferentOrder(t *testing.T) {
379 mockRequire := New(mockT)
381 mockRequire.JSONEq(`["foo", {"hello": "world", "nested": "hash"}]`, `[{ "hello": "world", "nested": "hash"}, "foo"]`)
383 t.Error("Check should fail")