-
Notifications
You must be signed in to change notification settings - Fork 45
/
jnigi_test2_test.go
173 lines (166 loc) · 3.4 KB
/
jnigi_test2_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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
package jnigi
import (
"github.com/stretchr/testify/assert"
"testing"
)
const (
testNum = 42
)
func PTestTypes(t *testing.T) {
obj, err := env.NewObject("local/JnigiTestBase")
if err != nil {
t.Fatal(err)
}
{
var val bool
if err := obj.CallMethod(env, "boolToboolean", &val, bool(true)); err != nil {
t.Fatal(err)
}
if !assert.Equal(t, bool(true), val) {
t.Fail()
}
}
{
var val byte
if err := obj.CallMethod(env, "byteTobyte", &val, byte(testNum)); err != nil {
t.Fatal(err)
}
if !assert.Equal(t, byte(testNum), val) {
t.Fail()
}
}
{
var val int16
if err := obj.CallMethod(env, "int16Toshort", &val, int16(testNum)); err != nil {
t.Fatal(err)
}
if !assert.Equal(t, int16(testNum), val) {
t.Fail()
}
}
{
var val uint16
if err := obj.CallMethod(env, "uint16Tochar", &val, uint16(testNum)); err != nil {
t.Fatal(err)
}
if !assert.Equal(t, uint16(testNum), val) {
t.Fail()
}
}
{
var val int
if err := obj.CallMethod(env, "intToint", &val, int(testNum)); err != nil {
t.Fatal(err)
}
if !assert.Equal(t, int(testNum), val) {
t.Fail()
}
}
{
var val int64
if err := obj.CallMethod(env, "int64Tolong", &val, int64(testNum)); err != nil {
t.Fatal(err)
}
if !assert.Equal(t, int64(testNum), val) {
t.Fail()
}
}
{
var val float32
if err := obj.CallMethod(env, "float32Tofloat", &val, float32(testNum)); err != nil {
t.Fatal(err)
}
if !assert.Equal(t, float32(testNum), val) {
t.Fail()
}
}
{
var val float64
if err := obj.CallMethod(env, "float64Todouble", &val, float64(testNum)); err != nil {
t.Fatal(err)
}
if !assert.Equal(t, float64(testNum), val) {
t.Fail()
}
}
{
wanted := []bool{true, true, true}
var got []bool
if err := obj.CallMethod(env, "s_boolToboolean", &got, wanted); err != nil {
t.Fatal(err)
}
if !assert.Equal(t, wanted, got) {
t.Fail()
}
}
{
wanted := []byte{testNum, testNum, testNum}
var got []byte
if err := obj.CallMethod(env, "s_byteTobyte", &got, wanted); err != nil {
t.Fatal(err)
}
if !assert.Equal(t, wanted, got) {
t.Fail()
}
}
{
wanted := []int16{testNum, testNum, testNum}
var got []int16
if err := obj.CallMethod(env, "s_int16Toshort", &got, wanted); err != nil {
t.Fatal(err)
}
if !assert.Equal(t, wanted, got) {
t.Fail()
}
}
{
wanted := []uint16{testNum, testNum, testNum}
var got []uint16
if err := obj.CallMethod(env, "s_uint16Tochar", &got, wanted); err != nil {
t.Fatal(err)
}
if !assert.Equal(t, wanted, got) {
t.Fail()
}
}
{
wanted := []int{testNum, testNum, testNum}
var got []int
if err := obj.CallMethod(env, "s_intToint", &got, wanted); err != nil {
t.Fatal(err)
}
if !assert.Equal(t, wanted, got) {
t.Fail()
}
}
{
wanted := []int64{testNum, testNum, testNum}
var got []int64
if err := obj.CallMethod(env, "s_int64Tolong", &got, wanted); err != nil {
t.Fatal(err)
}
if !assert.Equal(t, wanted, got) {
t.Fail()
}
}
{
wanted := []float32{testNum, testNum, testNum}
var got []float32
if err := obj.CallMethod(env, "s_float32Tofloat", &got, wanted); err != nil {
t.Fatal(err)
}
if !assert.Equal(t, wanted, got) {
t.Fail()
}
}
{
wanted := []float64{testNum, testNum, testNum}
var got []float64
if err := obj.CallMethod(env, "s_float64Todouble", &got, wanted); err != nil {
t.Fatal(err)
}
if !assert.Equal(t, wanted, got) {
t.Fail()
}
}
}