-
Notifications
You must be signed in to change notification settings - Fork 3
/
datatypes_support_test.go
103 lines (81 loc) · 1.65 KB
/
datatypes_support_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
package fb
import (
"fmt"
"strings"
"testing"
"time"
)
func genI(i int) int32 {
return int32(i)
}
func genSi(i int) int16 {
return int16(i)
}
func genBi(i int) int64 {
return int64(i) * 1000000000
}
func genF(i int) float32 {
return float32(i) / 2
}
func genD(i int) float64 {
return float64(i) * 3333 / 2
}
func genC(i int) string {
return fmt.Sprintf("%c", 65+i%26)
}
func genC10(i int) string {
return strings.Repeat(genC(i), 5)
}
func genVc(i int) string {
return genC(i)
}
func genVc10(i int) string {
if i > 10 {
i = 10
}
return strings.Repeat(genC(i), i)
}
func genVc10000(i int) string {
return strings.Repeat(genC(i), i*1000)
}
var genLoc, _ = time.LoadLocation(TestTimezone)
func genDt(i int) time.Time {
return time.Date(2000, time.Month(i+1), i+1, 0, 0, 0, 0, genLoc)
}
func genTm(i int) time.Time {
return time.Date(1970, time.Month(1), 1, 12, i, i, 0, time.Local)
}
func genTs(i int) time.Time {
return time.Date(2006, time.Month(1), 1, i, i, i, 0, time.Local)
}
func genN92(i int) float64 {
return float64(i) * 100
}
func genD92(i int) float64 {
return float64(i) * 100
}
func TestGenI(t *testing.T) {
if genI(3) != 3 {
t.Errorf("Expected: %d, got: %d", 3, genI(3))
}
}
func TestGenSi(t *testing.T) {
if genSi(3) != 3 {
t.Errorf("Expected: %d, got: %d", 3, genSi(3))
}
}
func TestGenBi(t *testing.T) {
if genBi(3) != 3*1000000000 {
t.Errorf("Expected: %d, got: %d", int64(3)*1000000000, genBi(3))
}
}
func TestGenF(t *testing.T) {
if genF(3) != 1.5 {
t.Errorf("Expected: %f, got: %f", 1.5, genF(3))
}
}
func TestGenD(t *testing.T) {
if genD(3) != 4999.5 {
t.Errorf("Expected: %f, got: %f", 4999.5, genD(3))
}
}