-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtarget_test.go
More file actions
26 lines (24 loc) · 841 Bytes
/
target_test.go
File metadata and controls
26 lines (24 loc) · 841 Bytes
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
package markers
import (
"github.com/stretchr/testify/assert"
"go/ast"
"testing"
)
func TestFindTargetLevelFromNode(t *testing.T) {
assert.Equal(t, StructTypeLevel, FindTargetLevelFromNode(&ast.TypeSpec{
Type: &ast.StructType{},
}))
assert.Equal(t, InterfaceTypeLevel, FindTargetLevelFromNode(&ast.TypeSpec{
Type: &ast.InterfaceType{},
}))
assert.Equal(t, FieldLevel, FindTargetLevelFromNode(&ast.Field{}))
assert.Equal(t, InterfaceMethodLevel, FindTargetLevelFromNode(&ast.Field{
Type: &ast.FuncType{},
}))
assert.Equal(t, StructMethodLevel, FindTargetLevelFromNode(&ast.FuncDecl{
Recv: &ast.FieldList{},
}))
assert.Equal(t, FunctionLevel, FindTargetLevelFromNode(&ast.FuncDecl{}))
assert.Equal(t, PackageLevel, FindTargetLevelFromNode(&ast.Package{}))
assert.Equal(t, InvalidLevel, FindTargetLevelFromNode(nil))
}