-
Notifications
You must be signed in to change notification settings - Fork 0
/
parse_test.go
50 lines (45 loc) · 913 Bytes
/
parse_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
package zc
import "testing"
func TestPreParseNumber(t *testing.T) {
tests := []struct {
in string
out string
}{
{"1234", "1234"},
{"1,234", "1234"},
{"1_234", "1234"},
{"1 234", "1234"},
{"$1234", "1234"},
{"0x10ab", "0x10ab"},
}
for _, test := range tests {
t.Run(test.in, func(t *testing.T) {
out := PreParseInt(test.in)
if out != test.out {
t.Fatalf("\n have: %v \n want: %v", out, test.out)
}
})
}
}
func TestPreParseFloat(t *testing.T) {
tests := []struct {
in string
out string
}{
{"1234", "1234"},
{"1,234", "1234"},
{"1_234", "1234"},
{"1 234", "1234"},
{"$1234", "1234"},
{"1234x1056", "1234e56"},
{"3.041409320×1064", "3.041409320e64"},
}
for _, test := range tests {
t.Run(test.in, func(t *testing.T) {
out := PreParseDecimal(test.in)
if out != test.out {
t.Fatalf("\n have: %v \n want: %v", out, test.out)
}
})
}
}