-
Notifications
You must be signed in to change notification settings - Fork 0
/
method_test.go
38 lines (30 loc) · 861 Bytes
/
method_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
package parser
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestReadMethodName(t *testing.T) {
t.Parallel()
cf, err := parseFile("./testdata/classes/main/Test.class")
assert.NoError(t, err)
for _, e := range cf.Methods {
_, err = e.Name(cf.ConstantPool)
assert.NoError(t, err)
_, err = e.Descriptor(cf.ConstantPool)
assert.NoError(t, err)
}
}
func TestAnnotationDefault(t *testing.T) {
t.Parallel()
cf, err := parseFile("./testdata/classes/main/Annot.class")
assert.NoError(t, err)
m := cf.Methods[0]
name, _ := m.Name(cf.ConstantPool)
assert.Equal(t, "value", name)
attr := m.AnnotationDefault()
assert.NotNil(t, attr)
index := attr.DefaultValue.(*ElementValueConstValue).ConstValueIndex
utf8, err := cf.ConstantPool.GetConstantUtf8(index)
assert.NoError(t, err)
assert.Equal(t, "default", utf8.String())
}