-
Notifications
You must be signed in to change notification settings - Fork 3
/
utils_test.go
115 lines (109 loc) · 2.22 KB
/
utils_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
package bdstockexchange
import (
"testing"
)
func Test_isValidCategoryName(t *testing.T) {
type args struct {
categoryName string
}
tests := []struct {
name string
args args
want bool
}{
// TODO: Add test cases.
{"", args{categoryName: "A"}, true},
{"", args{categoryName: "Abaa"}, false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := isValidCategoryName(tt.args.categoryName); got != tt.want {
t.Errorf("isValidCategoryName() = %v, want %v", got, tt.want)
}
})
}
}
func Test_normalizeAmerican(t *testing.T) {
type args struct {
old string
}
tests := []struct {
name string
args args
want string
}{
// TODO: Add test cases.
{"", args{old: "20,000.000"}, "20000.000"},
{"", args{old: "20,120"}, "20120"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := normalizeAmerican(tt.args.old); got != tt.want {
t.Errorf("normalizeAmerican() = %v, want %v", got, tt.want)
}
})
}
}
func Test_toFloat64(t *testing.T) {
type args struct {
text string
}
tests := []struct {
name string
args args
want float64
}{
// TODO: Add test cases.
{"", args{text: "20,000.78"}, 20000.78},
{"", args{text: "50.07"}, 50.07},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := toFloat64(tt.args.text); got != tt.want {
t.Errorf("toFloat64() = %v, want %v", got, tt.want)
}
})
}
}
func Test_toInt64(t *testing.T) {
type args struct {
text string
}
tests := []struct {
name string
args args
want int64
}{
// TODO: Add test cases.
{"", args{text: "50,000"}, 50000},
{"", args{text: "40,000"}, 40000},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := toInt64(tt.args.text); got != tt.want {
t.Errorf("toInt64() = %v, want %v", got, tt.want)
}
})
}
}
func Test_toInt(t *testing.T) {
type args struct {
text string
}
tests := []struct {
name string
args args
want int
}{
// TODO: Add test cases.
{"", args{text: "1"}, 1},
{"", args{text: "2"}, 2},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := toInt(tt.args.text); got != tt.want {
t.Errorf("toInt() = %v, want %v", got, tt.want)
}
})
}
}