-
Notifications
You must be signed in to change notification settings - Fork 0
/
number_test.go
66 lines (59 loc) · 1.15 KB
/
number_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
package gosc
import (
"testing"
)
// TestIsInt tests the IsInt function
func TestIsInt(t *testing.T) {
t.Parallel()
var tests = []struct {
data string
expected bool
}{
{"", false},
{"주", false},
{"nil", false},
{"null", false},
{"1", true},
{"0", true},
{"1111-", false},
{"-1", true},
{"5.3", false},
{"\u0031", true},
{"\x31", true},
}
for _, test := range tests {
actual := IsInt(test.data)
if actual != test.expected {
t.Errorf("Expected IsInt(%q) to be %v, got %v", test.data, test.expected, actual)
}
}
}
// TestIsFloat tests the IsFloat function
func TestIsFloat(t *testing.T) {
t.Parallel()
var tests = []struct {
data string
expected bool
}{
{"", false},
{"주", false},
{"nil", false},
{"null", false},
{"1", true},
{"0", true},
{"1111-", false},
{"-1", true},
{"-1.65", true},
{"5.3", true},
{"\u0031", true},
{"\x31", true},
{"\u0035\u002e\u0033", true},
{"\x35\x2e\x33", true},
}
for _, test := range tests {
actual := IsFloat(test.data)
if actual != test.expected {
t.Errorf("Expected IsFloat(%q) to be %v, got %v", test.data, test.expected, actual)
}
}
}