-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathassert_cmp_test.go
99 lines (84 loc) · 1.78 KB
/
assert_cmp_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
package actually
import (
"testing"
pb "github.com/bayashi/actually/testpb"
)
func TestCmp(t *testing.T) {
Got(123).Expect(123).Cmp(t)
}
func TestCmp_Fail(t *testing.T) {
stubConfirm(t, func() {
Got(123).Expect(456).Cmp(t)
}, "Not same value")
}
func TestCmpProto(t *testing.T) {
Got(&pb.Foo{Id: 123}).Expect(&pb.Foo{Id: 123}).CmpProto(t)
}
func TestCmpProto_Fail(t *testing.T) {
stubConfirm(t, func() {
Got(&pb.Foo{Id: 123}).Expect(&pb.Foo{Id: 456}).CmpProto(t)
}, "Not same value")
}
func TestCmpAllowUnexported(t *testing.T) {
x := struct {
id int
Name string
}{
id: 1,
Name: "aiko",
}
Got(x).Expect(x).CmpAllowUnexported(t)
}
func TestCmpAllowUnexported_Fail(t *testing.T) {
x := struct {
id int
Name string
}{
id: 1,
Name: "aiko",
}
y := x
y.id = 2
stubConfirm(t, func() {
Got(x).Expect(y).CmpAllowUnexported(t)
}, "Not same value")
stubConfirm(t, func() {
Got(nil).Expect(y).CmpAllowUnexported(t)
}, "`Got` value should be type of struct")
stubConfirm(t, func() {
Got(x).Expect(nil).CmpAllowUnexported(t)
}, "`Expect` value should be type of struct")
}
func TestCmpIgnoreUnexported(t *testing.T) {
x := struct {
id int
Name string
}{
id: 1,
Name: "aiko",
}
Got(x).Expect(x).CmpIgnoreUnexported(t)
y := x
y.id = 2
Got(x).Expect(y).CmpIgnoreUnexported(t)
}
func TestCmpIgnoreUnexported_Fail(t *testing.T) {
x := struct {
id int
Name string
}{
id: 1,
Name: "aiko",
}
y := x
y.Name = "eiko"
stubConfirm(t, func() {
Got(x).Expect(y).CmpIgnoreUnexported(t)
}, "Not same value")
stubConfirm(t, func() {
Got(nil).Expect(y).CmpIgnoreUnexported(t)
}, "`Got` value should be type of struct")
stubConfirm(t, func() {
Got(x).Expect(nil).CmpIgnoreUnexported(t)
}, "`Expect` value should be type of struct")
}