OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libgo/] [go/] [unicode/] [script_test.go] - Blame information for rev 747

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 747 jeremybenn
// Copyright 2009 The Go Authors. All rights reserved.
2
// Use of this source code is governed by a BSD-style
3
// license that can be found in the LICENSE file.
4
 
5
package unicode_test
6
 
7
import (
8
        "testing"
9
        . "unicode"
10
)
11
 
12
type T struct {
13
        rune   rune
14
        script string
15
}
16
 
17
// Hand-chosen tests from Unicode 5.1.0 & 6.0..0, mostly to discover when new
18
// scripts and categories arise.
19
var inTest = []T{
20
        {0x06e2, "Arabic"},
21
        {0x0567, "Armenian"},
22
        {0x10b20, "Avestan"},
23
        {0x1b37, "Balinese"},
24
        {0xa6af, "Bamum"},
25
        {0x1be1, "Batak"},
26
        {0x09c2, "Bengali"},
27
        {0x3115, "Bopomofo"},
28
        {0x282d, "Braille"},
29
        {0x1a1a, "Buginese"},
30
        {0x1747, "Buhid"},
31
        {0x11011, "Brahmi"},
32
        {0x156d, "Canadian_Aboriginal"},
33
        {0x102a9, "Carian"},
34
        {0xaa4d, "Cham"},
35
        {0x13c2, "Cherokee"},
36
        {0x0020, "Common"},
37
        {0x1d4a5, "Common"},
38
        {0x2cfc, "Coptic"},
39
        {0x12420, "Cuneiform"},
40
        {0x1080c, "Cypriot"},
41
        {0xa663, "Cyrillic"},
42
        {0x10430, "Deseret"},
43
        {0x094a, "Devanagari"},
44
        {0x13001, "Egyptian_Hieroglyphs"},
45
        {0x1271, "Ethiopic"},
46
        {0x10fc, "Georgian"},
47
        {0x2c40, "Glagolitic"},
48
        {0x10347, "Gothic"},
49
        {0x03ae, "Greek"},
50
        {0x0abf, "Gujarati"},
51
        {0x0a24, "Gurmukhi"},
52
        {0x3028, "Han"},
53
        {0x11b8, "Hangul"},
54
        {0x1727, "Hanunoo"},
55
        {0x05a0, "Hebrew"},
56
        {0x3058, "Hiragana"},
57
        {0x10841, "Imperial_Aramaic"},
58
        {0x20e6, "Inherited"},
59
        {0x10b70, "Inscriptional_Pahlavi"},
60
        {0x10b5a, "Inscriptional_Parthian"},
61
        {0xa9d0, "Javanese"},
62
        {0x1109f, "Kaithi"},
63
        {0x0cbd, "Kannada"},
64
        {0x30a6, "Katakana"},
65
        {0xa928, "Kayah_Li"},
66
        {0x10a11, "Kharoshthi"},
67
        {0x17c6, "Khmer"},
68
        {0x0eaa, "Lao"},
69
        {0x1d79, "Latin"},
70
        {0x1c10, "Lepcha"},
71
        {0x1930, "Limbu"},
72
        {0x1003c, "Linear_B"},
73
        {0xa4e1, "Lisu"},
74
        {0x10290, "Lycian"},
75
        {0x10930, "Lydian"},
76
        {0x0d42, "Malayalam"},
77
        {0x0843, "Mandaic"},
78
        {0xabd0, "Meetei_Mayek"},
79
        {0x1822, "Mongolian"},
80
        {0x104c, "Myanmar"},
81
        {0x19c3, "New_Tai_Lue"},
82
        {0x07f8, "Nko"},
83
        {0x169b, "Ogham"},
84
        {0x1c6a, "Ol_Chiki"},
85
        {0x10310, "Old_Italic"},
86
        {0x103c9, "Old_Persian"},
87
        {0x10a6f, "Old_South_Arabian"},
88
        {0x10c20, "Old_Turkic"},
89
        {0x0b3e, "Oriya"},
90
        {0x10491, "Osmanya"},
91
        {0xa860, "Phags_Pa"},
92
        {0x10918, "Phoenician"},
93
        {0xa949, "Rejang"},
94
        {0x16c0, "Runic"},
95
        {0x081d, "Samaritan"},
96
        {0xa892, "Saurashtra"},
97
        {0x10463, "Shavian"},
98
        {0x0dbd, "Sinhala"},
99
        {0x1ba3, "Sundanese"},
100
        {0xa803, "Syloti_Nagri"},
101
        {0x070f, "Syriac"},
102
        {0x170f, "Tagalog"},
103
        {0x176f, "Tagbanwa"},
104
        {0x1972, "Tai_Le"},
105
        {0x1a62, "Tai_Tham"},
106
        {0xaadc, "Tai_Viet"},
107
        {0x0bbf, "Tamil"},
108
        {0x0c55, "Telugu"},
109
        {0x07a7, "Thaana"},
110
        {0x0e46, "Thai"},
111
        {0x0f36, "Tibetan"},
112
        {0x2d55, "Tifinagh"},
113
        {0x10388, "Ugaritic"},
114
        {0xa60e, "Vai"},
115
        {0xa216, "Yi"},
116
}
117
 
118
var outTest = []T{ // not really worth being thorough
119
        {0x20, "Telugu"},
120
}
121
 
122
var inCategoryTest = []T{
123
        {0x0081, "Cc"},
124
        {0x17b4, "Cf"},
125
        {0xf0000, "Co"},
126
        {0xdb80, "Cs"},
127
        {0x0236, "Ll"},
128
        {0x1d9d, "Lm"},
129
        {0x07cf, "Lo"},
130
        {0x1f8a, "Lt"},
131
        {0x03ff, "Lu"},
132
        {0x0bc1, "Mc"},
133
        {0x20df, "Me"},
134
        {0x07f0, "Mn"},
135
        {0x1bb2, "Nd"},
136
        {0x10147, "Nl"},
137
        {0x2478, "No"},
138
        {0xfe33, "Pc"},
139
        {0x2011, "Pd"},
140
        {0x301e, "Pe"},
141
        {0x2e03, "Pf"},
142
        {0x2e02, "Pi"},
143
        {0x0022, "Po"},
144
        {0x2770, "Ps"},
145
        {0x00a4, "Sc"},
146
        {0xa711, "Sk"},
147
        {0x25f9, "Sm"},
148
        {0x2108, "So"},
149
        {0x2028, "Zl"},
150
        {0x2029, "Zp"},
151
        {0x202f, "Zs"},
152
        // Unifieds.
153
        {0x04aa, "L"},
154
        {0x0009, "C"},
155
        {0x1712, "M"},
156
        {0x0031, "N"},
157
        {0x00bb, "P"},
158
        {0x00a2, "S"},
159
        {0x00a0, "Z"},
160
}
161
 
162
var inPropTest = []T{
163
        {0x0046, "ASCII_Hex_Digit"},
164
        {0x200F, "Bidi_Control"},
165
        {0x2212, "Dash"},
166
        {0xE0001, "Deprecated"},
167
        {0x00B7, "Diacritic"},
168
        {0x30FE, "Extender"},
169
        {0xFF46, "Hex_Digit"},
170
        {0x2E17, "Hyphen"},
171
        {0x2FFB, "IDS_Binary_Operator"},
172
        {0x2FF3, "IDS_Trinary_Operator"},
173
        {0xFA6A, "Ideographic"},
174
        {0x200D, "Join_Control"},
175
        {0x0EC4, "Logical_Order_Exception"},
176
        {0x2FFFF, "Noncharacter_Code_Point"},
177
        {0x065E, "Other_Alphabetic"},
178
        {0x2069, "Other_Default_Ignorable_Code_Point"},
179
        {0x0BD7, "Other_Grapheme_Extend"},
180
        {0x0387, "Other_ID_Continue"},
181
        {0x212E, "Other_ID_Start"},
182
        {0x2094, "Other_Lowercase"},
183
        {0x2040, "Other_Math"},
184
        {0x216F, "Other_Uppercase"},
185
        {0x0027, "Pattern_Syntax"},
186
        {0x0020, "Pattern_White_Space"},
187
        {0x300D, "Quotation_Mark"},
188
        {0x2EF3, "Radical"},
189
        {0x061F, "STerm"},
190
        {0x2071, "Soft_Dotted"},
191
        {0x003A, "Terminal_Punctuation"},
192
        {0x9FC3, "Unified_Ideograph"},
193
        {0xFE0F, "Variation_Selector"},
194
        {0x0020, "White_Space"},
195
}
196
 
197
func TestScripts(t *testing.T) {
198
        notTested := make(map[string]bool)
199
        for k := range Scripts {
200
                notTested[k] = true
201
        }
202
        for _, test := range inTest {
203
                if _, ok := Scripts[test.script]; !ok {
204
                        t.Fatal(test.script, "not a known script")
205
                }
206
                if !Is(Scripts[test.script], test.rune) {
207
                        t.Errorf("IsScript(%U, %s) = false, want true", test.rune, test.script)
208
                }
209
                delete(notTested, test.script)
210
        }
211
        for _, test := range outTest {
212
                if Is(Scripts[test.script], test.rune) {
213
                        t.Errorf("IsScript(%U, %s) = true, want false", test.rune, test.script)
214
                }
215
        }
216
        for k := range notTested {
217
                t.Error("script not tested:", k)
218
        }
219
}
220
 
221
func TestCategories(t *testing.T) {
222
        notTested := make(map[string]bool)
223
        for k := range Categories {
224
                notTested[k] = true
225
        }
226
        for _, test := range inCategoryTest {
227
                if _, ok := Categories[test.script]; !ok {
228
                        t.Fatal(test.script, "not a known category")
229
                }
230
                if !Is(Categories[test.script], test.rune) {
231
                        t.Errorf("IsCategory(%U, %s) = false, want true", test.rune, test.script)
232
                }
233
                delete(notTested, test.script)
234
        }
235
        for k := range notTested {
236
                t.Error("category not tested:", k)
237
        }
238
}
239
 
240
func TestProperties(t *testing.T) {
241
        notTested := make(map[string]bool)
242
        for k := range Properties {
243
                notTested[k] = true
244
        }
245
        for _, test := range inPropTest {
246
                if _, ok := Properties[test.script]; !ok {
247
                        t.Fatal(test.script, "not a known prop")
248
                }
249
                if !Is(Properties[test.script], test.rune) {
250
                        t.Errorf("IsCategory(%U, %s) = false, want true", test.rune, test.script)
251
                }
252
                delete(notTested, test.script)
253
        }
254
        for k := range notTested {
255
                t.Error("property not tested:", k)
256
        }
257
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.