-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathider_test.go
49 lines (44 loc) · 1006 Bytes
/
ider_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
package splitfile
import (
"go/token"
"go/types"
"testing"
)
type mockObject struct {
pkgFn func() *types.Package
nameFn func() string
posFn func() token.Pos
}
func (mo mockObject) Pkg() *types.Package { return mo.pkgFn() }
func (mo mockObject) Name() string { return mo.nameFn() }
func (mo mockObject) Pos() token.Pos { return mo.posFn() }
func TestId(t *testing.T) {
var tests = []struct {
name string
want string
pkgFn func() *types.Package
nameFn func() string
posFn func() token.Pos
}{
{
name: "no package",
want: "name 1",
pkgFn: func() *types.Package { return nil },
nameFn: func() string { return "name" },
posFn: func() token.Pos { return token.Pos(1) },
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
o := mockObject{
pkgFn: tt.pkgFn,
nameFn: tt.nameFn,
posFn: tt.posFn,
}
got := Id(o)
if got != tt.want {
t.Errorf("Id(): want '%s', got '%s'", tt.want, got)
}
})
}
}