1package assert
2
3import (
4	"errors"
5	"regexp"
6	"testing"
7	"time"
8)
9
10func TestImplementsWrapper(t *testing.T) {
11	assert := New(new(testing.T))
12
13	if !assert.Implements((*AssertionTesterInterface)(nil), new(AssertionTesterConformingObject)) {
14		t.Error("Implements method should return true: AssertionTesterConformingObject implements AssertionTesterInterface")
15	}
16	if assert.Implements((*AssertionTesterInterface)(nil), new(AssertionTesterNonConformingObject)) {
17		t.Error("Implements method should return false: AssertionTesterNonConformingObject does not implements AssertionTesterInterface")
18	}
19}
20
21func TestIsTypeWrapper(t *testing.T) {
22	assert := New(new(testing.T))
23
24	if !assert.IsType(new(AssertionTesterConformingObject), new(AssertionTesterConformingObject)) {
25		t.Error("IsType should return true: AssertionTesterConformingObject is the same type as AssertionTesterConformingObject")
26	}
27	if assert.IsType(new(AssertionTesterConformingObject), new(AssertionTesterNonConformingObject)) {
28		t.Error("IsType should return false: AssertionTesterConformingObject is not the same type as AssertionTesterNonConformingObject")
29	}
30
31}
32
33func TestEqualWrapper(t *testing.T) {
34	assert := New(new(testing.T))
35
36	if !assert.Equal("Hello World", "Hello World") {
37		t.Error("Equal should return true")
38	}
39	if !assert.Equal(123, 123) {
40		t.Error("Equal should return true")
41	}
42	if !assert.Equal(123.5, 123.5) {
43		t.Error("Equal should return true")
44	}
45	if !assert.Equal([]byte("Hello World"), []byte("Hello World")) {
46		t.Error("Equal should return true")
47	}
48	if !assert.Equal(nil, nil) {
49		t.Error("Equal should return true")
50	}
51}
52
53func TestEqualValuesWrapper(t *testing.T) {
54	assert := New(new(testing.T))
55
56	if !assert.EqualValues(uint32(10), int32(10)) {
57		t.Error("EqualValues should return true")
58	}
59}
60
61func TestNotNilWrapper(t *testing.T) {
62	assert := New(new(testing.T))
63
64	if !assert.NotNil(new(AssertionTesterConformingObject)) {
65		t.Error("NotNil should return true: object is not nil")
66	}
67	if assert.NotNil(nil) {
68		t.Error("NotNil should return false: object is nil")
69	}
70
71}
72
73func TestNilWrapper(t *testing.T) {
74	assert := New(new(testing.T))
75
76	if !assert.Nil(nil) {
77		t.Error("Nil should return true: object is nil")
78	}
79	if assert.Nil(new(AssertionTesterConformingObject)) {
80		t.Error("Nil should return false: object is not nil")
81	}
82
83}
84
85func TestTrueWrapper(t *testing.T) {
86	assert := New(new(testing.T))
87
88	if !assert.True(true) {
89		t.Error("True should return true")
90	}
91	if assert.True(false) {
92		t.Error("True should return false")
93	}
94
95}
96
97func TestFalseWrapper(t *testing.T) {
98	assert := New(new(testing.T))
99
100	if !assert.False(false) {
101		t.Error("False should return true")
102	}
103	if assert.False(true) {
104		t.Error("False should return false")
105	}
106
107}
108
109func TestExactlyWrapper(t *testing.T) {
110	assert := New(new(testing.T))
111
112	a := float32(1)
113	b := float64(1)
114	c := float32(1)
115	d := float32(2)
116
117	if assert.Exactly(a, b) {
118		t.Error("Exactly should return false")
119	}
120	if assert.Exactly(a, d) {
121		t.Error("Exactly should return false")
122	}
123	if !assert.Exactly(a, c) {
124		t.Error("Exactly should return true")
125	}
126
127	if assert.Exactly(nil, a) {
128		t.Error("Exactly should return false")
129	}
130	if assert.Exactly(a, nil) {
131		t.Error("Exactly should return false")
132	}
133
134}
135
136func TestNotEqualWrapper(t *testing.T) {
137
138	assert := New(new(testing.T))
139
140	if !assert.NotEqual("Hello World", "Hello World!") {
141		t.Error("NotEqual should return true")
142	}
143	if !assert.NotEqual(123, 1234) {
144		t.Error("NotEqual should return true")
145	}
146	if !assert.NotEqual(123.5, 123.55) {
147		t.Error("NotEqual should return true")
148	}
149	if !assert.NotEqual([]byte("Hello World"), []byte("Hello World!")) {
150		t.Error("NotEqual should return true")
151	}
152	if !assert.NotEqual(nil, new(AssertionTesterConformingObject)) {
153		t.Error("NotEqual should return true")
154	}
155}
156
157func TestContainsWrapper(t *testing.T) {
158
159	assert := New(new(testing.T))
160	list := []string{"Foo", "Bar"}
161
162	if !assert.Contains("Hello World", "Hello") {
163		t.Error("Contains should return true: \"Hello World\" contains \"Hello\"")
164	}
165	if assert.Contains("Hello World", "Salut") {
166		t.Error("Contains should return false: \"Hello World\" does not contain \"Salut\"")
167	}
168
169	if !assert.Contains(list, "Foo") {
170		t.Error("Contains should return true: \"[\"Foo\", \"Bar\"]\" contains \"Foo\"")
171	}
172	if assert.Contains(list, "Salut") {
173		t.Error("Contains should return false: \"[\"Foo\", \"Bar\"]\" does not contain \"Salut\"")
174	}
175
176}
177
178func TestNotContainsWrapper(t *testing.T) {
179
180	assert := New(new(testing.T))
181	list := []string{"Foo", "Bar"}
182
183	if !assert.NotContains("Hello World", "Hello!") {
184		t.Error("NotContains should return true: \"Hello World\" does not contain \"Hello!\"")
185	}
186	if assert.NotContains("Hello World", "Hello") {
187		t.Error("NotContains should return false: \"Hello World\" contains \"Hello\"")
188	}
189
190	if !assert.NotContains(list, "Foo!") {
191		t.Error("NotContains should return true: \"[\"Foo\", \"Bar\"]\" does not contain \"Foo!\"")
192	}
193	if assert.NotContains(list, "Foo") {
194		t.Error("NotContains should return false: \"[\"Foo\", \"Bar\"]\" contains \"Foo\"")
195	}
196
197}
198
199func TestConditionWrapper(t *testing.T) {
200
201	assert := New(new(testing.T))
202
203	if !assert.Condition(func() bool { return true }, "Truth") {
204		t.Error("Condition should return true")
205	}
206
207	if assert.Condition(func() bool { return false }, "Lie") {
208		t.Error("Condition should return false")
209	}
210
211}
212
213func TestDidPanicWrapper(t *testing.T) {
214
215	if funcDidPanic, _ := didPanic(func() {
216		panic("Panic!")
217	}); !funcDidPanic {
218		t.Error("didPanic should return true")
219	}
220
221	if funcDidPanic, _ := didPanic(func() {
222	}); funcDidPanic {
223		t.Error("didPanic should return false")
224	}
225
226}
227
228func TestPanicsWrapper(t *testing.T) {
229
230	assert := New(new(testing.T))
231
232	if !assert.Panics(func() {
233		panic("Panic!")
234	}) {
235		t.Error("Panics should return true")
236	}
237
238	if assert.Panics(func() {
239	}) {
240		t.Error("Panics should return false")
241	}
242
243}
244
245func TestNotPanicsWrapper(t *testing.T) {
246
247	assert := New(new(testing.T))
248
249	if !assert.NotPanics(func() {
250	}) {
251		t.Error("NotPanics should return true")
252	}
253
254	if assert.NotPanics(func() {
255		panic("Panic!")
256	}) {
257		t.Error("NotPanics should return false")
258	}
259
260}
261
262func TestNoErrorWrapper(t *testing.T) {
263	assert := New(t)
264	mockAssert := New(new(testing.T))
265
266	// start with a nil error
267	var err error
268
269	assert.True(mockAssert.NoError(err), "NoError should return True for nil arg")
270
271	// now set an error
272	err = errors.New("Some error")
273
274	assert.False(mockAssert.NoError(err), "NoError with error should return False")
275
276}
277
278func TestErrorWrapper(t *testing.T) {
279	assert := New(t)
280	mockAssert := New(new(testing.T))
281
282	// start with a nil error
283	var err error
284
285	assert.False(mockAssert.Error(err), "Error should return False for nil arg")
286
287	// now set an error
288	err = errors.New("Some error")
289
290	assert.True(mockAssert.Error(err), "Error with error should return True")
291
292}
293
294func TestEqualErrorWrapper(t *testing.T) {
295	assert := New(t)
296	mockAssert := New(new(testing.T))
297
298	// start with a nil error
299	var err error
300	assert.False(mockAssert.EqualError(err, ""),
301		"EqualError should return false for nil arg")
302
303	// now set an error
304	err = errors.New("some error")
305	assert.False(mockAssert.EqualError(err, "Not some error"),
306		"EqualError should return false for different error string")
307	assert.True(mockAssert.EqualError(err, "some error"),
308		"EqualError should return true")
309}
310
311func TestEmptyWrapper(t *testing.T) {
312	assert := New(t)
313	mockAssert := New(new(testing.T))
314
315	assert.True(mockAssert.Empty(""), "Empty string is empty")
316	assert.True(mockAssert.Empty(nil), "Nil is empty")
317	assert.True(mockAssert.Empty([]string{}), "Empty string array is empty")
318	assert.True(mockAssert.Empty(0), "Zero int value is empty")
319	assert.True(mockAssert.Empty(false), "False value is empty")
320
321	assert.False(mockAssert.Empty("something"), "Non Empty string is not empty")
322	assert.False(mockAssert.Empty(errors.New("something")), "Non nil object is not empty")
323	assert.False(mockAssert.Empty([]string{"something"}), "Non empty string array is not empty")
324	assert.False(mockAssert.Empty(1), "Non-zero int value is not empty")
325	assert.False(mockAssert.Empty(true), "True value is not empty")
326
327}
328
329func TestNotEmptyWrapper(t *testing.T) {
330	assert := New(t)
331	mockAssert := New(new(testing.T))
332
333	assert.False(mockAssert.NotEmpty(""), "Empty string is empty")
334	assert.False(mockAssert.NotEmpty(nil), "Nil is empty")
335	assert.False(mockAssert.NotEmpty([]string{}), "Empty string array is empty")
336	assert.False(mockAssert.NotEmpty(0), "Zero int value is empty")
337	assert.False(mockAssert.NotEmpty(false), "False value is empty")
338
339	assert.True(mockAssert.NotEmpty("something"), "Non Empty string is not empty")
340	assert.True(mockAssert.NotEmpty(errors.New("something")), "Non nil object is not empty")
341	assert.True(mockAssert.NotEmpty([]string{"something"}), "Non empty string array is not empty")
342	assert.True(mockAssert.NotEmpty(1), "Non-zero int value is not empty")
343	assert.True(mockAssert.NotEmpty(true), "True value is not empty")
344
345}
346
347func TestLenWrapper(t *testing.T) {
348	assert := New(t)
349	mockAssert := New(new(testing.T))
350
351	assert.False(mockAssert.Len(nil, 0), "nil does not have length")
352	assert.False(mockAssert.Len(0, 0), "int does not have length")
353	assert.False(mockAssert.Len(true, 0), "true does not have length")
354	assert.False(mockAssert.Len(false, 0), "false does not have length")
355	assert.False(mockAssert.Len('A', 0), "Rune does not have length")
356	assert.False(mockAssert.Len(struct{}{}, 0), "Struct does not have length")
357
358	ch := make(chan int, 5)
359	ch <- 1
360	ch <- 2
361	ch <- 3
362
363	cases := []struct {
364		v interface{}
365		l int
366	}{
367		{[]int{1, 2, 3}, 3},
368		{[...]int{1, 2, 3}, 3},
369		{"ABC", 3},
370		{map[int]int{1: 2, 2: 4, 3: 6}, 3},
371		{ch, 3},
372
373		{[]int{}, 0},
374		{map[int]int{}, 0},
375		{make(chan int), 0},
376
377		{[]int(nil), 0},
378		{map[int]int(nil), 0},
379		{(chan int)(nil), 0},
380	}
381
382	for _, c := range cases {
383		assert.True(mockAssert.Len(c.v, c.l), "%#v have %d items", c.v, c.l)
384	}
385}
386
387func TestWithinDurationWrapper(t *testing.T) {
388	assert := New(t)
389	mockAssert := New(new(testing.T))
390	a := time.Now()
391	b := a.Add(10 * time.Second)
392
393	assert.True(mockAssert.WithinDuration(a, b, 10*time.Second), "A 10s difference is within a 10s time difference")
394	assert.True(mockAssert.WithinDuration(b, a, 10*time.Second), "A 10s difference is within a 10s time difference")
395
396	assert.False(mockAssert.WithinDuration(a, b, 9*time.Second), "A 10s difference is not within a 9s time difference")
397	assert.False(mockAssert.WithinDuration(b, a, 9*time.Second), "A 10s difference is not within a 9s time difference")
398
399	assert.False(mockAssert.WithinDuration(a, b, -9*time.Second), "A 10s difference is not within a 9s time difference")
400	assert.False(mockAssert.WithinDuration(b, a, -9*time.Second), "A 10s difference is not within a 9s time difference")
401
402	assert.False(mockAssert.WithinDuration(a, b, -11*time.Second), "A 10s difference is not within a 9s time difference")
403	assert.False(mockAssert.WithinDuration(b, a, -11*time.Second), "A 10s difference is not within a 9s time difference")
404}
405
406func TestInDeltaWrapper(t *testing.T) {
407	assert := New(new(testing.T))
408
409	True(t, assert.InDelta(1.001, 1, 0.01), "|1.001 - 1| <= 0.01")
410	True(t, assert.InDelta(1, 1.001, 0.01), "|1 - 1.001| <= 0.01")
411	True(t, assert.InDelta(1, 2, 1), "|1 - 2| <= 1")
412	False(t, assert.InDelta(1, 2, 0.5), "Expected |1 - 2| <= 0.5 to fail")
413	False(t, assert.InDelta(2, 1, 0.5), "Expected |2 - 1| <= 0.5 to fail")
414	False(t, assert.InDelta("", nil, 1), "Expected non numerals to fail")
415
416	cases := []struct {
417		a, b  interface{}
418		delta float64
419	}{
420		{uint8(2), uint8(1), 1},
421		{uint16(2), uint16(1), 1},
422		{uint32(2), uint32(1), 1},
423		{uint64(2), uint64(1), 1},
424
425		{int(2), int(1), 1},
426		{int8(2), int8(1), 1},
427		{int16(2), int16(1), 1},
428		{int32(2), int32(1), 1},
429		{int64(2), int64(1), 1},
430
431		{float32(2), float32(1), 1},
432		{float64(2), float64(1), 1},
433	}
434
435	for _, tc := range cases {
436		True(t, assert.InDelta(tc.a, tc.b, tc.delta), "Expected |%V - %V| <= %v", tc.a, tc.b, tc.delta)
437	}
438}
439
440func TestInEpsilonWrapper(t *testing.T) {
441	assert := New(new(testing.T))
442
443	cases := []struct {
444		a, b    interface{}
445		epsilon float64
446	}{
447		{uint8(2), uint16(2), .001},
448		{2.1, 2.2, 0.1},
449		{2.2, 2.1, 0.1},
450		{-2.1, -2.2, 0.1},
451		{-2.2, -2.1, 0.1},
452		{uint64(100), uint8(101), 0.01},
453		{0.1, -0.1, 2},
454	}
455
456	for _, tc := range cases {
457		True(t, assert.InEpsilon(tc.a, tc.b, tc.epsilon, "Expected %V and %V to have a relative difference of %v", tc.a, tc.b, tc.epsilon))
458	}
459
460	cases = []struct {
461		a, b    interface{}
462		epsilon float64
463	}{
464		{uint8(2), int16(-2), .001},
465		{uint64(100), uint8(102), 0.01},
466		{2.1, 2.2, 0.001},
467		{2.2, 2.1, 0.001},
468		{2.1, -2.2, 1},
469		{2.1, "bla-bla", 0},
470		{0.1, -0.1, 1.99},
471	}
472
473	for _, tc := range cases {
474		False(t, assert.InEpsilon(tc.a, tc.b, tc.epsilon, "Expected %V and %V to have a relative difference of %v", tc.a, tc.b, tc.epsilon))
475	}
476}
477
478func TestRegexpWrapper(t *testing.T) {
479
480	assert := New(new(testing.T))
481
482	cases := []struct {
483		rx, str string
484	}{
485		{"^start", "start of the line"},
486		{"end$", "in the end"},
487		{"[0-9]{3}[.-]?[0-9]{2}[.-]?[0-9]{2}", "My phone number is 650.12.34"},
488	}
489
490	for _, tc := range cases {
491		True(t, assert.Regexp(tc.rx, tc.str))
492		True(t, assert.Regexp(regexp.MustCompile(tc.rx), tc.str))
493		False(t, assert.NotRegexp(tc.rx, tc.str))
494		False(t, assert.NotRegexp(regexp.MustCompile(tc.rx), tc.str))
495	}
496
497	cases = []struct {
498		rx, str string
499	}{
500		{"^asdfastart", "Not the start of the line"},
501		{"end$", "in the end."},
502		{"[0-9]{3}[.-]?[0-9]{2}[.-]?[0-9]{2}", "My phone number is 650.12a.34"},
503	}
504
505	for _, tc := range cases {
506		False(t, assert.Regexp(tc.rx, tc.str), "Expected \"%s\" to not match \"%s\"", tc.rx, tc.str)
507		False(t, assert.Regexp(regexp.MustCompile(tc.rx), tc.str))
508		True(t, assert.NotRegexp(tc.rx, tc.str))
509		True(t, assert.NotRegexp(regexp.MustCompile(tc.rx), tc.str))
510	}
511}
512
513func TestZeroWrapper(t *testing.T) {
514	assert := New(t)
515	mockAssert := New(new(testing.T))
516
517	for _, test := range zeros {
518		assert.True(mockAssert.Zero(test), "Zero should return true for %v", test)
519	}
520
521	for _, test := range nonZeros {
522		assert.False(mockAssert.Zero(test), "Zero should return false for %v", test)
523	}
524}
525
526func TestNotZeroWrapper(t *testing.T) {
527	assert := New(t)
528	mockAssert := New(new(testing.T))
529
530	for _, test := range zeros {
531		assert.False(mockAssert.NotZero(test), "Zero should return true for %v", test)
532	}
533
534	for _, test := range nonZeros {
535		assert.True(mockAssert.NotZero(test), "Zero should return false for %v", test)
536	}
537}
538
539func TestJSONEqWrapper_EqualSONString(t *testing.T) {
540	assert := New(new(testing.T))
541	if !assert.JSONEq(`{"hello": "world", "foo": "bar"}`, `{"hello": "world", "foo": "bar"}`) {
542		t.Error("JSONEq should return true")
543	}
544
545}
546
547func TestJSONEqWrapper_EquivalentButNotEqual(t *testing.T) {
548	assert := New(new(testing.T))
549	if !assert.JSONEq(`{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`) {
550		t.Error("JSONEq should return true")
551	}
552
553}
554
555func TestJSONEqWrapper_HashOfArraysAndHashes(t *testing.T) {
556	assert := New(new(testing.T))
557	if !assert.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}",
558		"{\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}") {
559		t.Error("JSONEq should return true")
560	}
561}
562
563func TestJSONEqWrapper_Array(t *testing.T) {
564	assert := New(new(testing.T))
565	if !assert.JSONEq(`["foo", {"hello": "world", "nested": "hash"}]`, `["foo", {"nested": "hash", "hello": "world"}]`) {
566		t.Error("JSONEq should return true")
567	}
568
569}
570
571func TestJSONEqWrapper_HashAndArrayNotEquivalent(t *testing.T) {
572	assert := New(new(testing.T))
573	if assert.JSONEq(`["foo", {"hello": "world", "nested": "hash"}]`, `{"foo": "bar", {"nested": "hash", "hello": "world"}}`) {
574		t.Error("JSONEq should return false")
575	}
576}
577
578func TestJSONEqWrapper_HashesNotEquivalent(t *testing.T) {
579	assert := New(new(testing.T))
580	if assert.JSONEq(`{"foo": "bar"}`, `{"foo": "bar", "hello": "world"}`) {
581		t.Error("JSONEq should return false")
582	}
583}
584
585func TestJSONEqWrapper_ActualIsNotJSON(t *testing.T) {
586	assert := New(new(testing.T))
587	if assert.JSONEq(`{"foo": "bar"}`, "Not JSON") {
588		t.Error("JSONEq should return false")
589	}
590}
591
592func TestJSONEqWrapper_ExpectedIsNotJSON(t *testing.T) {
593	assert := New(new(testing.T))
594	if assert.JSONEq("Not JSON", `{"foo": "bar", "hello": "world"}`) {
595		t.Error("JSONEq should return false")
596	}
597}
598
599func TestJSONEqWrapper_ExpectedAndActualNotJSON(t *testing.T) {
600	assert := New(new(testing.T))
601	if assert.JSONEq("Not JSON", "Not JSON") {
602		t.Error("JSONEq should return false")
603	}
604}
605
606func TestJSONEqWrapper_ArraysOfDifferentOrder(t *testing.T) {
607	assert := New(new(testing.T))
608	if assert.JSONEq(`["foo", {"hello": "world", "nested": "hash"}]`, `[{ "hello": "world", "nested": "hash"}, "foo"]`) {
609		t.Error("JSONEq should return false")
610	}
611}
612
613func TestYAMLEqWrapper_EqualYAMLString(t *testing.T) {
614	assert := New(new(testing.T))
615	if !assert.YAMLEq(`{"hello": "world", "foo": "bar"}`, `{"hello": "world", "foo": "bar"}`) {
616		t.Error("YAMLEq should return true")
617	}
618
619}
620
621func TestYAMLEqWrapper_EquivalentButNotEqual(t *testing.T) {
622	assert := New(new(testing.T))
623	if !assert.YAMLEq(`{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`) {
624		t.Error("YAMLEq should return true")
625	}
626
627}
628
629func TestYAMLEqWrapper_HashOfArraysAndHashes(t *testing.T) {
630	assert := New(new(testing.T))
631	expected := `
632numeric: 1.5
633array:
634  - foo: bar
635  - 1
636  - "string"
637  - ["nested", "array", 5.5]
638hash:
639  nested: hash
640  nested_slice: [this, is, nested]
641string: "foo"
642`
643
644	actual := `
645numeric: 1.5
646hash:
647  nested: hash
648  nested_slice: [this, is, nested]
649string: "foo"
650array:
651  - foo: bar
652  - 1
653  - "string"
654  - ["nested", "array", 5.5]
655`
656	if !assert.YAMLEq(expected, actual) {
657		t.Error("YAMLEq should return true")
658	}
659}
660
661func TestYAMLEqWrapper_Array(t *testing.T) {
662	assert := New(new(testing.T))
663	if !assert.YAMLEq(`["foo", {"hello": "world", "nested": "hash"}]`, `["foo", {"nested": "hash", "hello": "world"}]`) {
664		t.Error("YAMLEq should return true")
665	}
666
667}
668
669func TestYAMLEqWrapper_HashAndArrayNotEquivalent(t *testing.T) {
670	assert := New(new(testing.T))
671	if assert.YAMLEq(`["foo", {"hello": "world", "nested": "hash"}]`, `{"foo": "bar", {"nested": "hash", "hello": "world"}}`) {
672		t.Error("YAMLEq should return false")
673	}
674}
675
676func TestYAMLEqWrapper_HashesNotEquivalent(t *testing.T) {
677	assert := New(new(testing.T))
678	if assert.YAMLEq(`{"foo": "bar"}`, `{"foo": "bar", "hello": "world"}`) {
679		t.Error("YAMLEq should return false")
680	}
681}
682
683func TestYAMLEqWrapper_ActualIsSimpleString(t *testing.T) {
684	assert := New(new(testing.T))
685	if assert.YAMLEq(`{"foo": "bar"}`, "Simple String") {
686		t.Error("YAMLEq should return false")
687	}
688}
689
690func TestYAMLEqWrapper_ExpectedIsSimpleString(t *testing.T) {
691	assert := New(new(testing.T))
692	if assert.YAMLEq("Simple String", `{"foo": "bar", "hello": "world"}`) {
693		t.Error("YAMLEq should return false")
694	}
695}
696
697func TestYAMLEqWrapper_ExpectedAndActualSimpleString(t *testing.T) {
698	assert := New(new(testing.T))
699	if !assert.YAMLEq("Simple String", "Simple String") {
700		t.Error("YAMLEq should return true")
701	}
702}
703
704func TestYAMLEqWrapper_ArraysOfDifferentOrder(t *testing.T) {
705	assert := New(new(testing.T))
706	if assert.YAMLEq(`["foo", {"hello": "world", "nested": "hash"}]`, `[{ "hello": "world", "nested": "hash"}, "foo"]`) {
707		t.Error("YAMLEq should return false")
708	}
709}
710