forked from ahmetb/go-linq
-
Notifications
You must be signed in to change notification settings - Fork 0
/
convert_test.go
57 lines (50 loc) · 1.04 KB
/
convert_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
package linq
import "testing"
func TestIntConverter(t *testing.T) {
tests := []struct {
input interface{}
want int64
}{
{2, 2},
{int8(-1), -1},
{int16(0), 0},
{int32(10), 10},
{int64(5), 5},
}
for _, test := range tests {
if conv := getIntConverter(test.input); conv(test.input) != test.want {
t.Errorf("IntConverter for %v failed", test.input)
}
}
}
func TestUIntConverter(t *testing.T) {
tests := []struct {
input interface{}
want uint64
}{
{uint(2), 2},
{uint8(1), 1},
{uint16(0), 0},
{uint32(10), 10},
{uint64(5), 5},
}
for _, test := range tests {
if conv := getUIntConverter(test.input); conv(test.input) != test.want {
t.Errorf("UIntConverter for %v failed", test.input)
}
}
}
func TestFloatConverter(t *testing.T) {
tests := []struct {
input interface{}
want float64
}{
{float32(-1), -1},
{float64(0), 0},
}
for _, test := range tests {
if conv := getFloatConverter(test.input); conv(test.input) != test.want {
t.Errorf("FloatConverter for %v failed", test.input)
}
}
}