PR target/47114
[official-gcc.git] / libgo / go / unicode / script_test.go
blobffdc40dc07d36af38d3b319b9cf1950aa0dd6218
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 int
14 script string
17 // Hand-chosen tests from Unicode 5.1.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 {0x09c2, "Bengali"},
26 {0x3115, "Bopomofo"},
27 {0x282d, "Braille"},
28 {0x1a1a, "Buginese"},
29 {0x1747, "Buhid"},
30 {0x156d, "Canadian_Aboriginal"},
31 {0x102a9, "Carian"},
32 {0xaa4d, "Cham"},
33 {0x13c2, "Cherokee"},
34 {0x0020, "Common"},
35 {0x1d4a5, "Common"},
36 {0x2cfc, "Coptic"},
37 {0x12420, "Cuneiform"},
38 {0x1080c, "Cypriot"},
39 {0xa663, "Cyrillic"},
40 {0x10430, "Deseret"},
41 {0x094a, "Devanagari"},
42 {0x13001, "Egyptian_Hieroglyphs"},
43 {0x1271, "Ethiopic"},
44 {0x10fc, "Georgian"},
45 {0x2c40, "Glagolitic"},
46 {0x10347, "Gothic"},
47 {0x03ae, "Greek"},
48 {0x0abf, "Gujarati"},
49 {0x0a24, "Gurmukhi"},
50 {0x3028, "Han"},
51 {0x11b8, "Hangul"},
52 {0x1727, "Hanunoo"},
53 {0x05a0, "Hebrew"},
54 {0x3058, "Hiragana"},
55 {0x10841, "Imperial_Aramaic"},
56 {0x20e6, "Inherited"},
57 {0x10b70, "Inscriptional_Pahlavi"},
58 {0x10b5a, "Inscriptional_Parthian"},
59 {0xa9d0, "Javanese"},
60 {0x1109f, "Kaithi"},
61 {0x0cbd, "Kannada"},
62 {0x30a6, "Katakana"},
63 {0xa928, "Kayah_Li"},
64 {0x10a11, "Kharoshthi"},
65 {0x17c6, "Khmer"},
66 {0x0eaa, "Lao"},
67 {0x1d79, "Latin"},
68 {0x1c10, "Lepcha"},
69 {0x1930, "Limbu"},
70 {0x1003c, "Linear_B"},
71 {0xa4e1, "Lisu"},
72 {0x10290, "Lycian"},
73 {0x10930, "Lydian"},
74 {0x0d42, "Malayalam"},
75 {0xabd0, "Meetei_Mayek"},
76 {0x1822, "Mongolian"},
77 {0x104c, "Myanmar"},
78 {0x19c3, "New_Tai_Lue"},
79 {0x07f8, "Nko"},
80 {0x169b, "Ogham"},
81 {0x1c6a, "Ol_Chiki"},
82 {0x10310, "Old_Italic"},
83 {0x103c9, "Old_Persian"},
84 {0x10a6f, "Old_South_Arabian"},
85 {0x10c20, "Old_Turkic"},
86 {0x0b3e, "Oriya"},
87 {0x10491, "Osmanya"},
88 {0xa860, "Phags_Pa"},
89 {0x10918, "Phoenician"},
90 {0xa949, "Rejang"},
91 {0x16c0, "Runic"},
92 {0x081d, "Samaritan"},
93 {0xa892, "Saurashtra"},
94 {0x10463, "Shavian"},
95 {0x0dbd, "Sinhala"},
96 {0x1ba3, "Sundanese"},
97 {0xa803, "Syloti_Nagri"},
98 {0x070f, "Syriac"},
99 {0x170f, "Tagalog"},
100 {0x176f, "Tagbanwa"},
101 {0x1972, "Tai_Le"},
102 {0x1a62, "Tai_Tham"},
103 {0xaadc, "Tai_Viet"},
104 {0x0bbf, "Tamil"},
105 {0x0c55, "Telugu"},
106 {0x07a7, "Thaana"},
107 {0x0e46, "Thai"},
108 {0x0f36, "Tibetan"},
109 {0x2d55, "Tifinagh"},
110 {0x10388, "Ugaritic"},
111 {0xa60e, "Vai"},
112 {0xa216, "Yi"},
115 var outTest = []T{ // not really worth being thorough
116 {0x20, "Telugu"},
119 var inCategoryTest = []T{
120 {0x0081, "Cc"},
121 {0x17b4, "Cf"},
122 {0xf0000, "Co"},
123 {0xdb80, "Cs"},
124 {0x0236, "Ll"},
125 {0x1d9d, "Lm"},
126 {0x07cf, "Lo"},
127 {0x1f8a, "Lt"},
128 {0x03ff, "Lu"},
129 {0x0bc1, "Mc"},
130 {0x20df, "Me"},
131 {0x07f0, "Mn"},
132 {0x1bb2, "Nd"},
133 {0x10147, "Nl"},
134 {0x2478, "No"},
135 {0xfe33, "Pc"},
136 {0x2011, "Pd"},
137 {0x301e, "Pe"},
138 {0x2e03, "Pf"},
139 {0x2e02, "Pi"},
140 {0x0022, "Po"},
141 {0x2770, "Ps"},
142 {0x00a4, "Sc"},
143 {0xa711, "Sk"},
144 {0x25f9, "Sm"},
145 {0x2108, "So"},
146 {0x2028, "Zl"},
147 {0x2029, "Zp"},
148 {0x202f, "Zs"},
149 {0x04aa, "letter"},
152 var inPropTest = []T{
153 {0x0046, "ASCII_Hex_Digit"},
154 {0x200F, "Bidi_Control"},
155 {0x2212, "Dash"},
156 {0xE0001, "Deprecated"},
157 {0x00B7, "Diacritic"},
158 {0x30FE, "Extender"},
159 {0xFF46, "Hex_Digit"},
160 {0x2E17, "Hyphen"},
161 {0x2FFB, "IDS_Binary_Operator"},
162 {0x2FF3, "IDS_Trinary_Operator"},
163 {0xFA6A, "Ideographic"},
164 {0x200D, "Join_Control"},
165 {0x0EC4, "Logical_Order_Exception"},
166 {0x2FFFF, "Noncharacter_Code_Point"},
167 {0x065E, "Other_Alphabetic"},
168 {0x2069, "Other_Default_Ignorable_Code_Point"},
169 {0x0BD7, "Other_Grapheme_Extend"},
170 {0x0387, "Other_ID_Continue"},
171 {0x212E, "Other_ID_Start"},
172 {0x2094, "Other_Lowercase"},
173 {0x2040, "Other_Math"},
174 {0x216F, "Other_Uppercase"},
175 {0x0027, "Pattern_Syntax"},
176 {0x0020, "Pattern_White_Space"},
177 {0x300D, "Quotation_Mark"},
178 {0x2EF3, "Radical"},
179 {0x061F, "STerm"},
180 {0x2071, "Soft_Dotted"},
181 {0x003A, "Terminal_Punctuation"},
182 {0x9FC3, "Unified_Ideograph"},
183 {0xFE0F, "Variation_Selector"},
184 {0x0020, "White_Space"},
187 func TestScripts(t *testing.T) {
188 notTested := make(map[string]bool)
189 for k := range Scripts {
190 notTested[k] = true
192 for _, test := range inTest {
193 if _, ok := Scripts[test.script]; !ok {
194 t.Fatal(test.script, "not a known script")
196 if !Is(Scripts[test.script], test.rune) {
197 t.Errorf("IsScript(%#x, %s) = false, want true", test.rune, test.script)
199 notTested[test.script] = false, false
201 for _, test := range outTest {
202 if Is(Scripts[test.script], test.rune) {
203 t.Errorf("IsScript(%#x, %s) = true, want false", test.rune, test.script)
206 for k := range notTested {
207 t.Error("not tested:", k)
211 func TestCategories(t *testing.T) {
212 notTested := make(map[string]bool)
213 for k := range Categories {
214 notTested[k] = true
216 for _, test := range inCategoryTest {
217 if _, ok := Categories[test.script]; !ok {
218 t.Fatal(test.script, "not a known category")
220 if !Is(Categories[test.script], test.rune) {
221 t.Errorf("IsCategory(%#x, %s) = false, want true", test.rune, test.script)
223 notTested[test.script] = false, false
225 for k := range notTested {
226 t.Error("not tested:", k)
230 func TestProperties(t *testing.T) {
231 notTested := make(map[string]bool)
232 for k := range Properties {
233 notTested[k] = true
235 for _, test := range inPropTest {
236 if _, ok := Properties[test.script]; !ok {
237 t.Fatal(test.script, "not a known prop")
239 if !Is(Properties[test.script], test.rune) {
240 t.Errorf("IsCategory(%#x, %s) = false, want true", test.rune, test.script)
242 notTested[test.script] = false, false
244 for k := range notTested {
245 t.Error("not tested:", k)