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