-
Notifications
You must be signed in to change notification settings - Fork 0
/
func_test.go
80 lines (66 loc) · 1.57 KB
/
func_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
package lo
import (
"strconv"
"testing"
"github.com/stretchr/testify/assert"
)
func TestPartial(t *testing.T) {
t.Parallel()
is := assert.New(t)
add := func(x float64, y int) string {
return strconv.Itoa(int(x) + y)
}
f := Partial(add, 5)
is.Equal("15", f(10))
is.Equal("0", f(-5))
}
func TestPartial1(t *testing.T) {
t.Parallel()
is := assert.New(t)
add := func(x float64, y int) string {
return strconv.Itoa(int(x) + y)
}
f := Partial1(add, 5)
is.Equal("15", f(10))
is.Equal("0", f(-5))
}
func TestPartial2(t *testing.T) {
t.Parallel()
is := assert.New(t)
add := func(x float64, y int, z int) string {
return strconv.Itoa(int(x) + y + z)
}
f := Partial2(add, 5)
is.Equal("24", f(10, 9))
is.Equal("8", f(-5, 8))
}
func TestPartial3(t *testing.T) {
t.Parallel()
is := assert.New(t)
add := func(x float64, y int, z int, a float32) string {
return strconv.Itoa(int(x) + y + z + int(a))
}
f := Partial3(add, 5)
is.Equal("21", f(10, 9, -3))
is.Equal("15", f(-5, 8, 7))
}
func TestPartial4(t *testing.T) {
t.Parallel()
is := assert.New(t)
add := func(x float64, y int, z int, a float32, b int32) string {
return strconv.Itoa(int(x) + y + z + int(a) + int(b))
}
f := Partial4(add, 5)
is.Equal("21", f(10, 9, -3, 0))
is.Equal("14", f(-5, 8, 7, -1))
}
func TestPartial5(t *testing.T) {
t.Parallel()
is := assert.New(t)
add := func(x float64, y int, z int, a float32, b int32, c int) string {
return strconv.Itoa(int(x) + y + z + int(a) + int(b) + c)
}
f := Partial5(add, 5)
is.Equal("26", f(10, 9, -3, 0, 5))
is.Equal("21", f(-5, 8, 7, -1, 7))
}