-
Notifications
You must be signed in to change notification settings - Fork 0
/
cliutil_test.go
39 lines (33 loc) · 1003 Bytes
/
cliutil_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
package cliutil_test
import (
"testing"
"github.com/google/go-cmp/cmp"
"github.com/gostaticanalysis/cliutil"
)
func TestSplit(t *testing.T) {
t.Parallel()
cases := []struct {
name string
want []any
}{
{"int", []any{"int", "", "", false}},
{"*int", []any{"int", "", "", true}},
{"testing.T", []any{"testing", "T", "", false}},
{"*testing.T", []any{"testing", "T", "", true}},
{"(*testing.T).Fatal", []any{"testing", "T", "Fatal", true}},
{"(net/http.Handler).ServeHTTP", []any{"net/http", "Handler", "ServeHTTP", false}},
{"(example.com/pkg.Type).Method", []any{"example.com/pkg", "Type", "Method", false}},
{"(*example.com/pkg.Type).Method", []any{"example.com/pkg", "Type", "Method", true}},
}
for _, tt := range cases {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
first, second, third, ptr := cliutil.Split(tt.name)
got := []any{first, second, third, ptr}
if diff := cmp.Diff(tt.want, got); diff != "" {
t.Error(diff)
}
})
}
}