-
Notifications
You must be signed in to change notification settings - Fork 0
/
rese_test.go
92 lines (72 loc) · 1.34 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
package done_test
import (
"testing"
"github.com/stretchr/testify/require"
"github.com/yyle88/done"
)
func TestV0(t *testing.T) {
run := func() error {
return nil
}
done.V0(run())
}
func TestV1(t *testing.T) {
run := func() (string, error) {
return "a", nil
}
v1 := done.V1(run())
require.Equal(t, "a", v1)
}
func TestV2(t *testing.T) {
run := func() (string, uint64, error) {
return "a", 2, nil
}
v1, v2 := done.V2(run())
require.Equal(t, "a", v1)
require.Equal(t, uint64(2), v2)
}
func TestP0(t *testing.T) {
run := func() error {
return nil
}
done.P0(run())
}
func TestP1(t *testing.T) {
run := func() (*string, error) {
v1 := "hello"
return &v1, nil
}
p1 := done.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 := done.P2(run())
require.Equal(t, 42, *v1)
require.Equal(t, 3.14, *v2)
}
func TestC0(t *testing.T) {
run := func() error {
return nil
}
done.C0(run())
}
func TestC1(t *testing.T) {
run := func() (string, error) {
return "hello", nil
}
v1 := done.C1(run())
require.Equal(t, "hello", v1)
}
func TestC2(t *testing.T) {
run := func() (int, float64, error) {
return 42, 3.14, nil
}
v1, v2 := done.C2(run())
require.Equal(t, 42, v1)
require.Equal(t, 3.14, v2)
}