-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrese_test.go
428 lines (366 loc) · 9.79 KB
/
rese_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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
package rese_test
import (
"testing"
"github.com/stretchr/testify/require"
"github.com/yyle88/rese"
)
func TestV0(t *testing.T) {
run := func() error {
return nil
}
rese.V0(run())
}
func TestV1(t *testing.T) {
run := func() (string, error) {
return "a", nil
}
v1 := rese.V1(run())
require.Equal(t, "a", v1)
}
func TestV2(t *testing.T) {
run := func() (string, uint64, error) {
return "a", 2, nil
}
v1, v2 := rese.V2(run())
require.Equal(t, "a", v1)
require.Equal(t, uint64(2), v2)
}
func TestV3(t *testing.T) {
run := func() (string, uint64, rune, error) {
return "a", 2, 'x', nil
}
v1, v2, v3 := rese.V3(run())
require.Equal(t, "a", v1)
require.Equal(t, uint64(2), v2)
require.Equal(t, 'x', v3)
}
func TestV4(t *testing.T) {
run := func() (string, uint64, rune, int32, error) {
return "a", 2, 'x', 42, nil
}
v1, v2, v3, v4 := rese.V4(run())
require.Equal(t, "a", v1)
require.Equal(t, uint64(2), v2)
require.Equal(t, 'x', v3)
require.Equal(t, int32(42), v4)
}
func TestV5(t *testing.T) {
run := func() (string, uint64, rune, int32, float64, error) {
return "a", 2, 'x', 42, 3.14, nil
}
v1, v2, v3, v4, v5 := rese.V5(run())
require.Equal(t, "a", v1)
require.Equal(t, uint64(2), v2)
require.Equal(t, 'x', v3)
require.Equal(t, int32(42), v4)
require.Equal(t, 3.14, v5)
}
func TestV6(t *testing.T) {
run := func() (string, uint64, rune, int32, float64, bool, error) {
return "a", 2, 'x', 42, 3.14, true, nil
}
v1, v2, v3, v4, v5, v6 := rese.V6(run())
require.Equal(t, "a", v1)
require.Equal(t, uint64(2), v2)
require.Equal(t, 'x', v3)
require.Equal(t, int32(42), v4)
require.Equal(t, 3.14, v5)
require.Equal(t, true, v6)
}
func TestV7(t *testing.T) {
run := func() (string, uint64, rune, int32, float64, bool, byte, error) {
return "a", 2, 'x', 42, 3.14, true, byte(255), nil
}
v1, v2, v3, v4, v5, v6, v7 := rese.V7(run())
require.Equal(t, "a", v1)
require.Equal(t, uint64(2), v2)
require.Equal(t, 'x', v3)
require.Equal(t, int32(42), v4)
require.Equal(t, 3.14, v5)
require.Equal(t, true, v6)
require.Equal(t, byte(255), v7)
}
func TestV8(t *testing.T) {
run := func() (string, uint64, rune, int32, float64, bool, byte, int64, error) {
return "a", 2, 'x', 42, 3.14, true, byte(255), int64(123456789), nil
}
v1, v2, v3, v4, v5, v6, v7, v8 := rese.V8(run())
require.Equal(t, "a", v1)
require.Equal(t, uint64(2), v2)
require.Equal(t, 'x', v3)
require.Equal(t, int32(42), v4)
require.Equal(t, 3.14, v5)
require.Equal(t, true, v6)
require.Equal(t, byte(255), v7)
require.Equal(t, int64(123456789), v8)
}
func TestV9(t *testing.T) {
run := func() (string, uint64, rune, int32, float64, bool, byte, int64, uint32, error) {
return "a", 2, 'x', 42, 3.14, true, byte(255), int64(123456789), uint32(987654321), nil
}
v1, v2, v3, v4, v5, v6, v7, v8, v9 := rese.V9(run())
require.Equal(t, "a", v1)
require.Equal(t, uint64(2), v2)
require.Equal(t, 'x', v3)
require.Equal(t, int32(42), v4)
require.Equal(t, 3.14, v5)
require.Equal(t, true, v6)
require.Equal(t, byte(255), v7)
require.Equal(t, int64(123456789), v8)
require.Equal(t, uint32(987654321), v9)
}
func TestP0(t *testing.T) {
run := func() error {
return nil
}
rese.P0(run())
}
func TestP1(t *testing.T) {
run := func() (*string, error) {
v1 := "hello"
return &v1, nil
}
p1 := rese.P1(run())
require.Equal(t, "hello", *p1)
}
func TestP2(t *testing.T) {
run := func() (*int, *float64, error) {
v1 := 42
v2 := 3.14
return &v1, &v2, nil
}
v1, v2 := rese.P2(run())
require.Equal(t, 42, *v1)
require.Equal(t, 3.14, *v2)
}
func TestP3(t *testing.T) {
run := func() (*string, *int, *bool, error) {
v1 := "test"
v2 := 100
v3 := true
return &v1, &v2, &v3, nil
}
v1, v2, v3 := rese.P3(run())
require.Equal(t, "test", *v1)
require.Equal(t, 100, *v2)
require.Equal(t, true, *v3)
}
func TestP4(t *testing.T) {
run := func() (*int, *float64, *bool, *string, error) {
v1 := 42
v2 := 3.14
v3 := false
v4 := "world"
return &v1, &v2, &v3, &v4, nil
}
v1, v2, v3, v4 := rese.P4(run())
require.Equal(t, 42, *v1)
require.Equal(t, 3.14, *v2)
require.Equal(t, false, *v3)
require.Equal(t, "world", *v4)
}
func TestP5(t *testing.T) {
run := func() (*string, *int, *bool, *float64, *rune, error) {
v1 := "test"
v2 := 123
v3 := true
v4 := 2.718
v5 := 'a'
return &v1, &v2, &v3, &v4, &v5, nil
}
v1, v2, v3, v4, v5 := rese.P5(run())
require.Equal(t, "test", *v1)
require.Equal(t, 123, *v2)
require.Equal(t, true, *v3)
require.Equal(t, 2.718, *v4)
require.Equal(t, 'a', *v5)
}
func TestP6(t *testing.T) {
run := func() (*float64, *int, *string, *bool, *rune, *int64, error) {
v1 := 3.14
v2 := 42
v3 := "hello"
v4 := true
v5 := 'x'
v6 := int64(100000)
return &v1, &v2, &v3, &v4, &v5, &v6, nil
}
v1, v2, v3, v4, v5, v6 := rese.P6(run())
require.Equal(t, 3.14, *v1)
require.Equal(t, 42, *v2)
require.Equal(t, "hello", *v3)
require.Equal(t, true, *v4)
require.Equal(t, 'x', *v5)
require.Equal(t, int64(100000), *v6)
}
func TestP7(t *testing.T) {
run := func() (*bool, *string, *int, *float64, *rune, *int64, *uint32, error) {
v1 := true
v2 := "world"
v3 := 50
v4 := 1.618
v5 := 'y'
v6 := int64(200000)
v7 := uint32(300)
return &v1, &v2, &v3, &v4, &v5, &v6, &v7, nil
}
v1, v2, v3, v4, v5, v6, v7 := rese.P7(run())
require.Equal(t, true, *v1)
require.Equal(t, "world", *v2)
require.Equal(t, 50, *v3)
require.Equal(t, 1.618, *v4)
require.Equal(t, 'y', *v5)
require.Equal(t, int64(200000), *v6)
require.Equal(t, uint32(300), *v7)
}
func TestP8(t *testing.T) {
run := func() (*string, *int, *bool, *float64, *rune, *int64, *uint32, *uint8, error) {
v1 := "abc"
v2 := 999
v3 := false
v4 := 0.577
v5 := 'z'
v6 := int64(500000)
v7 := uint32(400)
v8 := uint8(255)
return &v1, &v2, &v3, &v4, &v5, &v6, &v7, &v8, nil
}
v1, v2, v3, v4, v5, v6, v7, v8 := rese.P8(run())
require.Equal(t, "abc", *v1)
require.Equal(t, 999, *v2)
require.Equal(t, false, *v3)
require.Equal(t, 0.577, *v4)
require.Equal(t, 'z', *v5)
require.Equal(t, int64(500000), *v6)
require.Equal(t, uint32(400), *v7)
require.Equal(t, uint8(255), *v8)
}
func TestP9(t *testing.T) {
run := func() (*string, *int, *bool, *float64, *rune, *int64, *uint32, *uint8, *uint64, error) {
v1 := "final"
v2 := 888
v3 := true
v4 := 2.718
v5 := 'p'
v6 := int64(900000)
v7 := uint32(500)
v8 := uint8(100)
v9 := uint64(1000000)
return &v1, &v2, &v3, &v4, &v5, &v6, &v7, &v8, &v9, nil
}
v1, v2, v3, v4, v5, v6, v7, v8, v9 := rese.P9(run())
require.Equal(t, "final", *v1)
require.Equal(t, 888, *v2)
require.Equal(t, true, *v3)
require.Equal(t, 2.718, *v4)
require.Equal(t, 'p', *v5)
require.Equal(t, int64(900000), *v6)
require.Equal(t, uint32(500), *v7)
require.Equal(t, uint8(100), *v8)
require.Equal(t, uint64(1000000), *v9)
}
func TestC0(t *testing.T) {
run := func() error {
return nil
}
rese.C0(run())
}
func TestC1(t *testing.T) {
run := func() (string, error) {
return "hello", nil
}
v1 := rese.C1(run())
require.Equal(t, "hello", v1)
}
func TestC2(t *testing.T) {
run := func() (int, float64, error) {
return 42, 3.14, nil
}
v1, v2 := rese.C2(run())
require.Equal(t, 42, v1)
require.Equal(t, 3.14, v2)
}
func TestC3(t *testing.T) {
run := func() (bool, byte, rune, error) {
return true, 'A', '中', nil
}
v1, v2, v3 := rese.C3(run())
require.True(t, v1)
require.Equal(t, byte('A'), v2)
require.Equal(t, '中', v3)
}
func TestC4(t *testing.T) {
run := func() (string, int, uint, float32, error) {
return "world", -7, 7, 1.23, nil
}
v1, v2, v3, v4 := rese.C4(run())
require.Equal(t, "world", v1)
require.Equal(t, -7, v2)
require.Equal(t, uint(7), v3)
require.Equal(t, float32(1.23), v4)
}
func TestC5(t *testing.T) {
run := func() (uint8, uint16, uint32, uint64, string, error) {
return 8, 16, 32, 64, "test", nil
}
v1, v2, v3, v4, v5 := rese.C5(run())
require.Equal(t, uint8(8), v1)
require.Equal(t, uint16(16), v2)
require.Equal(t, uint32(32), v3)
require.Equal(t, uint64(64), v4)
require.Equal(t, "test", v5)
}
func TestC6(t *testing.T) {
run := func() (float64, complex64, complex128, bool, string, int, error) {
return 6.28, complex(1, 2), complex(3, 4), true, "check", -1, nil
}
v1, v2, v3, v4, v5, v6 := rese.C6(run())
require.Equal(t, 6.28, v1)
require.Equal(t, complex64(complex(1, 2)), v2)
require.Equal(t, complex(3, 4), v3)
require.True(t, v4)
require.Equal(t, "check", v5)
require.Equal(t, -1, v6)
}
func TestC7(t *testing.T) {
run := func() (uint, uint8, uint16, uint32, uint64, int, int8, error) {
return 1, 2, 3, 4, 5, 6, 7, nil
}
v1, v2, v3, v4, v5, v6, v7 := rese.C7(run())
require.Equal(t, uint(1), v1)
require.Equal(t, uint8(2), v2)
require.Equal(t, uint16(3), v3)
require.Equal(t, uint32(4), v4)
require.Equal(t, uint64(5), v5)
require.Equal(t, 6, v6)
require.Equal(t, int8(7), v7)
}
func TestC8(t *testing.T) {
run := func() (string, rune, byte, bool, float32, float64, int32, int64, error) {
return "go", '中', 'B', true, 2.71, 1.618, -32, -64, nil
}
v1, v2, v3, v4, v5, v6, v7, v8 := rese.C8(run())
require.Equal(t, "go", v1)
require.Equal(t, '中', v2)
require.Equal(t, byte('B'), v3)
require.True(t, v4)
require.Equal(t, float32(2.71), v5)
require.Equal(t, 1.618, v6)
require.Equal(t, int32(-32), v7)
require.Equal(t, int64(-64), v8)
}
func TestC9(t *testing.T) {
run := func() (string, uint8, int16, uint32, int64, float32, float64, complex64, complex128, error) {
return "done", 255, -16, 32, -64, 3.14, 2.71, complex(5, 6), complex(7, 8), nil
}
v1, v2, v3, v4, v5, v6, v7, v8, v9 := rese.C9(run())
require.Equal(t, "done", v1)
require.Equal(t, uint8(255), v2)
require.Equal(t, int16(-16), v3)
require.Equal(t, uint32(32), v4)
require.Equal(t, int64(-64), v5)
require.Equal(t, float32(3.14), v6)
require.Equal(t, 2.71, v7)
require.Equal(t, complex64(complex(5, 6)), v8)
require.Equal(t, complex(7, 8), v9)
}