Source file
src/unicode/script_test.go
1
2
3
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 var inCategoryTest = []T{
18 {0x0081, "Cc"},
19 {0x200B, "Cf"},
20 {0xf0000, "Co"},
21 {0xdb80, "Cs"},
22 {0x0236, "Ll"},
23 {0x1d9d, "Lm"},
24 {0x07cf, "Lo"},
25 {0x1f8a, "Lt"},
26 {0x03ff, "Lu"},
27 {0x0bc1, "Mc"},
28 {0x20df, "Me"},
29 {0x07f0, "Mn"},
30 {0x1bb2, "Nd"},
31 {0x10147, "Nl"},
32 {0x2478, "No"},
33 {0xfe33, "Pc"},
34 {0x2011, "Pd"},
35 {0x301e, "Pe"},
36 {0x2e03, "Pf"},
37 {0x2e02, "Pi"},
38 {0x0022, "Po"},
39 {0x2770, "Ps"},
40 {0x00a4, "Sc"},
41 {0xa711, "Sk"},
42 {0x25f9, "Sm"},
43 {0x2108, "So"},
44 {0x2028, "Zl"},
45 {0x2029, "Zp"},
46 {0x202f, "Zs"},
47
48 {0x04aa, "L"},
49 {0x0009, "C"},
50 {0x1712, "M"},
51 {0x0031, "N"},
52 {0x00bb, "P"},
53 {0x00a2, "S"},
54 {0x00a0, "Z"},
55 {0x0065, "LC"},
56
57 {0x0378, "Cn"},
58 {0x0378, "C"},
59 }
60
61 var inPropTest = []T{
62 {0x0046, "ASCII_Hex_Digit"},
63 {0x200F, "Bidi_Control"},
64 {0x2212, "Dash"},
65 {0xE0001, "Deprecated"},
66 {0x00B7, "Diacritic"},
67 {0x30FE, "Extender"},
68 {0xFF46, "Hex_Digit"},
69 {0x2E17, "Hyphen"},
70 {0x2FFB, "IDS_Binary_Operator"},
71 {0x2FF3, "IDS_Trinary_Operator"},
72 {0xFA6A, "Ideographic"},
73 {0x200D, "Join_Control"},
74 {0x0EC4, "Logical_Order_Exception"},
75 {0x2FFFF, "Noncharacter_Code_Point"},
76 {0x065E, "Other_Alphabetic"},
77 {0x2065, "Other_Default_Ignorable_Code_Point"},
78 {0x0BD7, "Other_Grapheme_Extend"},
79 {0x0387, "Other_ID_Continue"},
80 {0x212E, "Other_ID_Start"},
81 {0x2094, "Other_Lowercase"},
82 {0x2040, "Other_Math"},
83 {0x216F, "Other_Uppercase"},
84 {0x0027, "Pattern_Syntax"},
85 {0x0020, "Pattern_White_Space"},
86 {0x06DD, "Prepended_Concatenation_Mark"},
87 {0x300D, "Quotation_Mark"},
88 {0x2EF3, "Radical"},
89 {0x1f1ff, "Regional_Indicator"},
90 {0x061F, "STerm"},
91 {0x061F, "Sentence_Terminal"},
92 {0x2071, "Soft_Dotted"},
93 {0x003A, "Terminal_Punctuation"},
94 {0x9FC3, "Unified_Ideograph"},
95 {0xFE0F, "Variation_Selector"},
96 {0x0020, "White_Space"},
97 {0x221e, "ID_Compat_Math_Start"},
98 {0x06e3, "Modifier_Combining_Mark"},
99 {0x2080, "ID_Compat_Math_Continue"},
100 {0x2ffe, "IDS_Unary_Operator"},
101 }
102
103 func TestCategories(t *testing.T) {
104 notTested := make(map[string]bool)
105 for k := range Categories {
106 notTested[k] = true
107 }
108 for _, test := range inCategoryTest {
109 if _, ok := Categories[test.script]; !ok {
110 t.Fatal(test.script, "not a known category")
111 }
112 if !Is(Categories[test.script], test.rune) {
113 t.Errorf("IsCategory(%U, %s) = false, want true", test.rune, test.script)
114 }
115 delete(notTested, test.script)
116 }
117 for k := range notTested {
118 t.Error("category not tested:", k)
119 }
120 }
121
122 func TestProperties(t *testing.T) {
123 notTested := make(map[string]bool)
124 for k := range Properties {
125 notTested[k] = true
126 }
127 for _, test := range inPropTest {
128 if _, ok := Properties[test.script]; !ok {
129 t.Fatal(test.script, "not a known prop")
130 }
131 if !Is(Properties[test.script], test.rune) {
132 t.Errorf("IsCategory(%U, %s) = false, want true", test.rune, test.script)
133 }
134 delete(notTested, test.script)
135 }
136 for k := range notTested {
137 t.Error("property not tested:", k)
138 }
139 }
140
View as plain text