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.
17 // Hand-chosen tests from Unicode 5.1.0, 6.0.0 and 6.2.0 mostly to discover when new
18 // scripts and categories arise.
32 {0x156d, "Canadian_Aboriginal"},
40 {0x12420, "Cuneiform"},
44 {0x094a, "Devanagari"},
45 {0x13001, "Egyptian_Hieroglyphs"},
48 {0x2c40, "Glagolitic"},
58 {0x10841, "Imperial_Aramaic"},
59 {0x20e6, "Inherited"},
60 {0x10b70, "Inscriptional_Pahlavi"},
61 {0x10b5a, "Inscriptional_Parthian"},
67 {0x10a11, "Kharoshthi"},
73 {0x1003c, "Linear_B"},
77 {0x0d42, "Malayalam"},
79 {0xabd0, "Meetei_Mayek"},
80 {0x1099f, "Meroitic_Hieroglyphs"},
81 {0x109a0, "Meroitic_Cursive"},
83 {0x1822, "Mongolian"},
85 {0x19c3, "New_Tai_Lue"},
89 {0x10310, "Old_Italic"},
90 {0x103c9, "Old_Persian"},
91 {0x10a6f, "Old_South_Arabian"},
92 {0x10c20, "Old_Turkic"},
96 {0x10918, "Phoenician"},
99 {0x081d, "Samaritan"},
100 {0xa892, "Saurashtra"},
101 {0x111a0, "Sharada"},
102 {0x10463, "Shavian"},
104 {0x110d0, "Sora_Sompeng"},
105 {0x1ba3, "Sundanese"},
106 {0xa803, "Syloti_Nagri"},
109 {0x176f, "Tagbanwa"},
111 {0x1a62, "Tai_Tham"},
112 {0xaadc, "Tai_Viet"},
119 {0x2d55, "Tifinagh"},
120 {0x10388, "Ugaritic"},
125 var outTest
= []T
{ // not really worth being thorough
129 var inCategoryTest
= []T
{
169 var inPropTest
= []T
{
170 {0x0046, "ASCII_Hex_Digit"},
171 {0x200F, "Bidi_Control"},
173 {0xE0001, "Deprecated"},
174 {0x00B7, "Diacritic"},
175 {0x30FE, "Extender"},
176 {0xFF46, "Hex_Digit"},
178 {0x2FFB, "IDS_Binary_Operator"},
179 {0x2FF3, "IDS_Trinary_Operator"},
180 {0xFA6A, "Ideographic"},
181 {0x200D, "Join_Control"},
182 {0x0EC4, "Logical_Order_Exception"},
183 {0x2FFFF, "Noncharacter_Code_Point"},
184 {0x065E, "Other_Alphabetic"},
185 {0x2065, "Other_Default_Ignorable_Code_Point"},
186 {0x0BD7, "Other_Grapheme_Extend"},
187 {0x0387, "Other_ID_Continue"},
188 {0x212E, "Other_ID_Start"},
189 {0x2094, "Other_Lowercase"},
190 {0x2040, "Other_Math"},
191 {0x216F, "Other_Uppercase"},
192 {0x0027, "Pattern_Syntax"},
193 {0x0020, "Pattern_White_Space"},
194 {0x300D, "Quotation_Mark"},
197 {0x2071, "Soft_Dotted"},
198 {0x003A, "Terminal_Punctuation"},
199 {0x9FC3, "Unified_Ideograph"},
200 {0xFE0F, "Variation_Selector"},
201 {0x0020, "White_Space"},
204 func TestScripts(t
*testing
.T
) {
205 notTested
:= make(map[string]bool)
206 for k
:= range Scripts
{
209 for _
, test
:= range inTest
{
210 if _
, ok
:= Scripts
[test
.script
]; !ok
{
211 t
.Fatal(test
.script
, "not a known script")
213 if !Is(Scripts
[test
.script
], test
.rune
) {
214 t
.Errorf("IsScript(%U, %s) = false, want true", test
.rune
, test
.script
)
216 delete(notTested
, test
.script
)
218 for _
, test
:= range outTest
{
219 if Is(Scripts
[test
.script
], test
.rune
) {
220 t
.Errorf("IsScript(%U, %s) = true, want false", test
.rune
, test
.script
)
223 for k
:= range notTested
{
224 t
.Error("script not tested:", k
)
228 func TestCategories(t
*testing
.T
) {
229 notTested
:= make(map[string]bool)
230 for k
:= range Categories
{
233 for _
, test
:= range inCategoryTest
{
234 if _
, ok
:= Categories
[test
.script
]; !ok
{
235 t
.Fatal(test
.script
, "not a known category")
237 if !Is(Categories
[test
.script
], test
.rune
) {
238 t
.Errorf("IsCategory(%U, %s) = false, want true", test
.rune
, test
.script
)
240 delete(notTested
, test
.script
)
242 for k
:= range notTested
{
243 t
.Error("category not tested:", k
)
247 func TestProperties(t
*testing
.T
) {
248 notTested
:= make(map[string]bool)
249 for k
:= range Properties
{
252 for _
, test
:= range inPropTest
{
253 if _
, ok
:= Properties
[test
.script
]; !ok
{
254 t
.Fatal(test
.script
, "not a known prop")
256 if !Is(Properties
[test
.script
], test
.rune
) {
257 t
.Errorf("IsCategory(%U, %s) = false, want true", test
.rune
, test
.script
)
259 delete(notTested
, test
.script
)
261 for k
:= range notTested
{
262 t
.Error("property not tested:", k
)