PR target/66870
[official-gcc.git] / libgo / go / unicode / script_test.go
blob795cb4e171b85a6eb35aca2a9489d234bbd77e5b
1 // 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.
5 package unicode_test
7 import (
8 "testing"
9 . "unicode"
12 type T struct {
13 rune rune
14 script string
17 // Hand-chosen tests from Unicode 5.1.0, 6.0.0, 6.2.0, 6.3.0 and 7.0.0 mostly to
18 // discover when new scripts and categories arise.
19 var inTest = []T{
20 {0x06e2, "Arabic"},
21 {0x0567, "Armenian"},
22 {0x10b20, "Avestan"},
23 {0x1b37, "Balinese"},
24 {0xa6af, "Bamum"},
25 {0x16ada, "Bassa_Vah"},
26 {0x1be1, "Batak"},
27 {0x09c2, "Bengali"},
28 {0x3115, "Bopomofo"},
29 {0x282d, "Braille"},
30 {0x1a1a, "Buginese"},
31 {0x1747, "Buhid"},
32 {0x11011, "Brahmi"},
33 {0x156d, "Canadian_Aboriginal"},
34 {0x102a9, "Carian"},
35 {0x10563, "Caucasian_Albanian"},
36 {0x11111, "Chakma"},
37 {0xaa4d, "Cham"},
38 {0x13c2, "Cherokee"},
39 {0x0020, "Common"},
40 {0x1d4a5, "Common"},
41 {0x2cfc, "Coptic"},
42 {0x12420, "Cuneiform"},
43 {0x1080c, "Cypriot"},
44 {0xa663, "Cyrillic"},
45 {0x10430, "Deseret"},
46 {0x094a, "Devanagari"},
47 {0x1BC00, "Duployan"},
48 {0x13001, "Egyptian_Hieroglyphs"},
49 {0x10500, "Elbasan"},
50 {0x1271, "Ethiopic"},
51 {0x10fc, "Georgian"},
52 {0x2c40, "Glagolitic"},
53 {0x10347, "Gothic"},
54 {0x11303, "Grantha"},
55 {0x03ae, "Greek"},
56 {0x0abf, "Gujarati"},
57 {0x0a24, "Gurmukhi"},
58 {0x3028, "Han"},
59 {0x11b8, "Hangul"},
60 {0x1727, "Hanunoo"},
61 {0x05a0, "Hebrew"},
62 {0x3058, "Hiragana"},
63 {0x10841, "Imperial_Aramaic"},
64 {0x20e6, "Inherited"},
65 {0x10b70, "Inscriptional_Pahlavi"},
66 {0x10b5a, "Inscriptional_Parthian"},
67 {0xa9d0, "Javanese"},
68 {0x1109f, "Kaithi"},
69 {0x0cbd, "Kannada"},
70 {0x30a6, "Katakana"},
71 {0xa928, "Kayah_Li"},
72 {0x10a11, "Kharoshthi"},
73 {0x17c6, "Khmer"},
74 {0x11211, "Khojki"},
75 {0x112df, "Khudawadi"},
76 {0x0eaa, "Lao"},
77 {0x1d79, "Latin"},
78 {0x1c10, "Lepcha"},
79 {0x1930, "Limbu"},
80 {0x10755, "Linear_A"},
81 {0x1003c, "Linear_B"},
82 {0xa4e1, "Lisu"},
83 {0x10290, "Lycian"},
84 {0x10930, "Lydian"},
85 {0x11173, "Mahajani"},
86 {0x0d42, "Malayalam"},
87 {0x0843, "Mandaic"},
88 {0x10ac8, "Manichaean"},
89 {0xabd0, "Meetei_Mayek"},
90 {0x1e800, "Mende_Kikakui"},
91 {0x1099f, "Meroitic_Hieroglyphs"},
92 {0x109a0, "Meroitic_Cursive"},
93 {0x16f00, "Miao"},
94 {0x11611, "Modi"},
95 {0x1822, "Mongolian"},
96 {0x16a60, "Mro"},
97 {0x104c, "Myanmar"},
98 {0x10880, "Nabataean"},
99 {0x19c3, "New_Tai_Lue"},
100 {0x07f8, "Nko"},
101 {0x169b, "Ogham"},
102 {0x1c6a, "Ol_Chiki"},
103 {0x10310, "Old_Italic"},
104 {0x10a80, "Old_North_Arabian"},
105 {0x10350, "Old_Permic"},
106 {0x103c9, "Old_Persian"},
107 {0x10a6f, "Old_South_Arabian"},
108 {0x10c20, "Old_Turkic"},
109 {0x0b3e, "Oriya"},
110 {0x10491, "Osmanya"},
111 {0x16b2b, "Pahawh_Hmong"},
112 {0x10876, "Palmyrene"},
113 {0x11ACE, "Pau_Cin_Hau"},
114 {0xa860, "Phags_Pa"},
115 {0x10918, "Phoenician"},
116 {0x10baf, "Psalter_Pahlavi"},
117 {0xa949, "Rejang"},
118 {0x16c0, "Runic"},
119 {0x081d, "Samaritan"},
120 {0xa892, "Saurashtra"},
121 {0x111a0, "Sharada"},
122 {0x10463, "Shavian"},
123 {0x115c1, "Siddham"},
124 {0x0dbd, "Sinhala"},
125 {0x110d0, "Sora_Sompeng"},
126 {0x1ba3, "Sundanese"},
127 {0xa803, "Syloti_Nagri"},
128 {0x070f, "Syriac"},
129 {0x170f, "Tagalog"},
130 {0x176f, "Tagbanwa"},
131 {0x1972, "Tai_Le"},
132 {0x1a62, "Tai_Tham"},
133 {0xaadc, "Tai_Viet"},
134 {0x116c9, "Takri"},
135 {0x0bbf, "Tamil"},
136 {0x0c55, "Telugu"},
137 {0x07a7, "Thaana"},
138 {0x0e46, "Thai"},
139 {0x0f36, "Tibetan"},
140 {0x2d55, "Tifinagh"},
141 {0x114d9, "Tirhuta"},
142 {0x10388, "Ugaritic"},
143 {0xa60e, "Vai"},
144 {0x118ff, "Warang_Citi"},
145 {0xa216, "Yi"},
148 var outTest = []T{ // not really worth being thorough
149 {0x20, "Telugu"},
152 var inCategoryTest = []T{
153 {0x0081, "Cc"},
154 {0x200B, "Cf"},
155 {0xf0000, "Co"},
156 {0xdb80, "Cs"},
157 {0x0236, "Ll"},
158 {0x1d9d, "Lm"},
159 {0x07cf, "Lo"},
160 {0x1f8a, "Lt"},
161 {0x03ff, "Lu"},
162 {0x0bc1, "Mc"},
163 {0x20df, "Me"},
164 {0x07f0, "Mn"},
165 {0x1bb2, "Nd"},
166 {0x10147, "Nl"},
167 {0x2478, "No"},
168 {0xfe33, "Pc"},
169 {0x2011, "Pd"},
170 {0x301e, "Pe"},
171 {0x2e03, "Pf"},
172 {0x2e02, "Pi"},
173 {0x0022, "Po"},
174 {0x2770, "Ps"},
175 {0x00a4, "Sc"},
176 {0xa711, "Sk"},
177 {0x25f9, "Sm"},
178 {0x2108, "So"},
179 {0x2028, "Zl"},
180 {0x2029, "Zp"},
181 {0x202f, "Zs"},
182 // Unifieds.
183 {0x04aa, "L"},
184 {0x0009, "C"},
185 {0x1712, "M"},
186 {0x0031, "N"},
187 {0x00bb, "P"},
188 {0x00a2, "S"},
189 {0x00a0, "Z"},
192 var inPropTest = []T{
193 {0x0046, "ASCII_Hex_Digit"},
194 {0x200F, "Bidi_Control"},
195 {0x2212, "Dash"},
196 {0xE0001, "Deprecated"},
197 {0x00B7, "Diacritic"},
198 {0x30FE, "Extender"},
199 {0xFF46, "Hex_Digit"},
200 {0x2E17, "Hyphen"},
201 {0x2FFB, "IDS_Binary_Operator"},
202 {0x2FF3, "IDS_Trinary_Operator"},
203 {0xFA6A, "Ideographic"},
204 {0x200D, "Join_Control"},
205 {0x0EC4, "Logical_Order_Exception"},
206 {0x2FFFF, "Noncharacter_Code_Point"},
207 {0x065E, "Other_Alphabetic"},
208 {0x2065, "Other_Default_Ignorable_Code_Point"},
209 {0x0BD7, "Other_Grapheme_Extend"},
210 {0x0387, "Other_ID_Continue"},
211 {0x212E, "Other_ID_Start"},
212 {0x2094, "Other_Lowercase"},
213 {0x2040, "Other_Math"},
214 {0x216F, "Other_Uppercase"},
215 {0x0027, "Pattern_Syntax"},
216 {0x0020, "Pattern_White_Space"},
217 {0x300D, "Quotation_Mark"},
218 {0x2EF3, "Radical"},
219 {0x061F, "STerm"},
220 {0x2071, "Soft_Dotted"},
221 {0x003A, "Terminal_Punctuation"},
222 {0x9FC3, "Unified_Ideograph"},
223 {0xFE0F, "Variation_Selector"},
224 {0x0020, "White_Space"},
227 func TestScripts(t *testing.T) {
228 notTested := make(map[string]bool)
229 for k := range Scripts {
230 notTested[k] = true
232 for _, test := range inTest {
233 if _, ok := Scripts[test.script]; !ok {
234 t.Fatal(test.script, "not a known script")
236 if !Is(Scripts[test.script], test.rune) {
237 t.Errorf("IsScript(%U, %s) = false, want true", test.rune, test.script)
239 delete(notTested, test.script)
241 for _, test := range outTest {
242 if Is(Scripts[test.script], test.rune) {
243 t.Errorf("IsScript(%U, %s) = true, want false", test.rune, test.script)
246 for k := range notTested {
247 t.Error("script not tested:", k)
251 func TestCategories(t *testing.T) {
252 notTested := make(map[string]bool)
253 for k := range Categories {
254 notTested[k] = true
256 for _, test := range inCategoryTest {
257 if _, ok := Categories[test.script]; !ok {
258 t.Fatal(test.script, "not a known category")
260 if !Is(Categories[test.script], test.rune) {
261 t.Errorf("IsCategory(%U, %s) = false, want true", test.rune, test.script)
263 delete(notTested, test.script)
265 for k := range notTested {
266 t.Error("category not tested:", k)
270 func TestProperties(t *testing.T) {
271 notTested := make(map[string]bool)
272 for k := range Properties {
273 notTested[k] = true
275 for _, test := range inPropTest {
276 if _, ok := Properties[test.script]; !ok {
277 t.Fatal(test.script, "not a known prop")
279 if !Is(Properties[test.script], test.rune) {
280 t.Errorf("IsCategory(%U, %s) = false, want true", test.rune, test.script)
282 delete(notTested, test.script)
284 for k := range notTested {
285 t.Error("property not tested:", k)