-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbytemaps_test.go
55 lines (51 loc) · 1012 Bytes
/
bytemaps_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
package njson
import (
"testing"
)
func TestIsDigit(t *testing.T) {
for i := 0; i < 255; i++ {
want := '0' <= i && i <= '9'
if isDigit(byte(i)) != want {
t.Fatalf("IsDigit(%c) != %t", i, want)
}
}
}
func TestIsNumberEnd(t *testing.T) {
type args struct {
c byte
}
tests := []struct {
name string
args args
want bool
}{
{",", args{','}, true},
{" ", args{' '}, true},
{"\n", args{'\n'}, true},
{"\r", args{'\r'}, true},
{"\t", args{'\t'}, true},
{"}", args{'}'}, true},
{"]", args{']'}, true},
{"a", args{'a'}, false},
{"0", args{'0'}, false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := isNumberEnd(tt.args.c); got != tt.want {
t.Errorf("IsNumberEnd() = %v, want %v", got, tt.want)
}
})
}
}
func TestIsSpaceASCII(t *testing.T) {
for i := 0; i < 255; i++ {
want := false
switch i {
case '\r', '\n', ' ', '\t':
want = true
}
if isSpace(byte(i)) != want {
t.Fatalf("isSpave(%c) != %t", i, want)
}
}
}