-
Notifications
You must be signed in to change notification settings - Fork 0
/
parse_internal_test.go
95 lines (89 loc) · 1.5 KB
/
parse_internal_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
package budoux
import "testing"
func TestUnicodeBlockAndFeature(t *testing.T) {
tbl := []struct {
in string
idx int
char string
size int
feature string
}{
{
in: "abc",
idx: 0,
char: "a",
size: 1,
feature: "001",
},
{
in: "xyz",
idx: 2,
char: "z",
size: 1,
feature: "001",
},
{
in: "out of index",
idx: 12,
char: "",
size: 0,
feature: invalidFeature,
},
{
in: "あいうえお",
idx: 0,
char: "あ",
size: 3,
feature: "108",
},
{
in: "わをん",
idx: 6,
char: "ん",
size: 3,
feature: "108",
},
{
in: "安",
idx: 0,
char: "安",
size: 3,
feature: "120",
},
{
in: "範囲外アクセス",
idx: 21,
char: "",
size: 0,
feature: invalidFeature,
},
{
in: "≠",
idx: 0,
char: "≠",
size: 3,
feature: "079",
},
{
in: "不正",
idx: 1,
char: "",
size: 1,
feature: invalidFeature,
},
}
for _, v := range tbl {
t.Run(v.in, func(t *testing.T) {
char, size, feature := getUnicodeBlockAndFeature(v.in, v.idx)
if char != v.char {
t.Errorf("unmatch char, want %q, got %q", v.char, char)
}
if size != v.size {
t.Errorf("unmatch size, want %d, got %d", v.size, size)
}
if feature != v.feature {
t.Errorf("unmatch feature, want %q, got %q", v.feature, feature)
}
})
}
}