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
116
117
118
119
120
121
122
123
124
125
126
|
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package unicode_test
import (
"testing"
. "unicode"
)
var testDigit = []rune{
0x0030,
0x0039,
0x0661,
0x06F1,
0x07C9,
0x0966,
0x09EF,
0x0A66,
0x0AEF,
0x0B66,
0x0B6F,
0x0BE6,
0x0BEF,
0x0C66,
0x0CEF,
0x0D66,
0x0D6F,
0x0E50,
0x0E59,
0x0ED0,
0x0ED9,
0x0F20,
0x0F29,
0x1040,
0x1049,
0x1090,
0x1091,
0x1099,
0x17E0,
0x17E9,
0x1810,
0x1819,
0x1946,
0x194F,
0x19D0,
0x19D9,
0x1B50,
0x1B59,
0x1BB0,
0x1BB9,
0x1C40,
0x1C49,
0x1C50,
0x1C59,
0xA620,
0xA629,
0xA8D0,
0xA8D9,
0xA900,
0xA909,
0xAA50,
0xAA59,
0xFF10,
0xFF19,
0x104A1,
0x1D7CE,
}
var testLetter = []rune{
0x0041,
0x0061,
0x00AA,
0x00BA,
0x00C8,
0x00DB,
0x00F9,
0x02EC,
0x0535,
0x06E6,
0x093D,
0x0A15,
0x0B99,
0x0DC0,
0x0EDD,
0x1000,
0x1200,
0x1312,
0x1401,
0x1885,
0x2C00,
0xA800,
0xF900,
0xFA30,
0xFFDA,
0xFFDC,
0x10000,
0x10300,
0x10400,
0x20000,
0x2F800,
0x2FA1D,
}
func TestDigit(t *testing.T) {
for _, r := range testDigit {
if !IsDigit(r) {
t.Errorf("IsDigit(U+%04X) = false, want true", r)
}
}
for _, r := range testLetter {
if IsDigit(r) {
t.Errorf("IsDigit(U+%04X) = true, want false", r)
}
}
}
// Test that the special case in IsDigit agrees with the table
func TestDigitOptimization(t *testing.T) {
for i := rune(0); i <= MaxLatin1; i++ {
if Is(Digit, i) != IsDigit(i) {
t.Errorf("IsDigit(U+%04X) disagrees with Is(Digit)", i)
}
}
}
|