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, mostly to discover when new
18 // scripts and categories arise.
30 {0x156d, "Canadian_Aboriginal"},
37 {0x12420, "Cuneiform"},
41 {0x094a, "Devanagari"},
42 {0x13001, "Egyptian_Hieroglyphs"},
45 {0x2c40, "Glagolitic"},
55 {0x10841, "Imperial_Aramaic"},
56 {0x20e6, "Inherited"},
57 {0x10b70, "Inscriptional_Pahlavi"},
58 {0x10b5a, "Inscriptional_Parthian"},
64 {0x10a11, "Kharoshthi"},
70 {0x1003c, "Linear_B"},
74 {0x0d42, "Malayalam"},
75 {0xabd0, "Meetei_Mayek"},
76 {0x1822, "Mongolian"},
78 {0x19c3, "New_Tai_Lue"},
82 {0x10310, "Old_Italic"},
83 {0x103c9, "Old_Persian"},
84 {0x10a6f, "Old_South_Arabian"},
85 {0x10c20, "Old_Turkic"},
89 {0x10918, "Phoenician"},
92 {0x081d, "Samaritan"},
93 {0xa892, "Saurashtra"},
96 {0x1ba3, "Sundanese"},
97 {0xa803, "Syloti_Nagri"},
100 {0x176f, "Tagbanwa"},
102 {0x1a62, "Tai_Tham"},
103 {0xaadc, "Tai_Viet"},
109 {0x2d55, "Tifinagh"},
110 {0x10388, "Ugaritic"},
115 var outTest
= []T
{ // not really worth being thorough
119 var inCategoryTest
= []T
{
152 var inPropTest
= []T
{
153 {0x0046, "ASCII_Hex_Digit"},
154 {0x200F, "Bidi_Control"},
156 {0xE0001, "Deprecated"},
157 {0x00B7, "Diacritic"},
158 {0x30FE, "Extender"},
159 {0xFF46, "Hex_Digit"},
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"},
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
{
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
{
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
{
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
)