@@ -26,29 +26,32 @@ import (
26
26
27
27
func TestMatchers (t * testing.T ) {
28
28
type e interface {}
29
- type testCase struct {
29
+ tests := []struct {
30
+ name string
30
31
matcher gomock.Matcher
31
32
yes , no []e
32
- }
33
- tests := []testCase {
34
- {gomock .Any (), []e {3 , nil , "foo" }, nil },
35
- {gomock .Eq (4 ), []e {4 }, []e {3 , "blah" , nil , int64 (4 )}},
36
- {gomock .Nil (),
33
+ }{
34
+ {"test Any" , gomock .Any (), []e {3 , nil , "foo" }, nil },
35
+ {"test All" , gomock .Eq (4 ), []e {4 }, []e {3 , "blah" , nil , int64 (4 )}},
36
+ {"test Nil" , gomock .Nil (),
37
37
[]e {nil , (error )(nil ), (chan bool )(nil ), (* int )(nil )},
38
38
[]e {"" , 0 , make (chan bool ), errors .New ("err" ), new (int )}},
39
- {gomock .Not (gomock .Eq (4 )), []e {3 , "blah" , nil , int64 (4 )}, []e {4 }},
40
- }
41
- for i , test := range tests {
42
- for _ , x := range test .yes {
43
- if ! test .matcher .Matches (x ) {
44
- t .Errorf (`test %d: "%v %s" should be true.` , i , x , test .matcher )
39
+ {"test Not" , gomock .Not (gomock .Eq (4 )), []e {3 , "blah" , nil , int64 (4 )}, []e {4 }},
40
+ {"test All" , gomock .All (gomock .Any (), gomock .Eq (4 )), []e {4 }, []e {3 , "blah" , nil , int64 (4 )}},
41
+ }
42
+ for _ , tt := range tests {
43
+ t .Run (tt .name , func (t * testing.T ) {
44
+ for _ , x := range tt .yes {
45
+ if ! tt .matcher .Matches (x ) {
46
+ t .Errorf (`"%v %s": got false, want true.` , x , tt .matcher )
47
+ }
45
48
}
46
- }
47
- for _ , x := range test . no {
48
- if test . matcher . Matches ( x ) {
49
- t . Errorf ( `test %d: "%v %s" should be false.` , i , x , test . matcher )
49
+ for _ , x := range tt . no {
50
+ if tt . matcher . Matches ( x ) {
51
+ t . Errorf ( `"%v %s": got true, want false.` , x , tt . matcher )
52
+ }
50
53
}
51
- }
54
+ })
52
55
}
53
56
}
54
57
0 commit comments