OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library unicode_tests; | 5 library unicode_tests; |
6 | 6 |
7 // Google favorite: "Îñţérñåţîöñåļîžåţîờñ". | 7 // Google favorite: "Îñţérñåţîöñåļîžåţîờñ". |
8 const INTER_BYTES = const [0xc3, 0x8e, 0xc3, 0xb1, 0xc5, 0xa3, 0xc3, 0xa9, 0x72, | 8 const INTER_BYTES = const [ |
9 0xc3, 0xb1, 0xc3, 0xa5, 0xc5, 0xa3, 0xc3, 0xae, 0xc3, | 9 0xc3, |
10 0xb6, 0xc3, 0xb1, 0xc3, 0xa5, 0xc4, 0xbc, 0xc3, 0xae, | 10 0x8e, |
11 0xc5, 0xbe, 0xc3, 0xa5, 0xc5, 0xa3, 0xc3, 0xae, 0xe1, | 11 0xc3, |
12 0xbb, 0x9d, 0xc3, 0xb1]; | 12 0xb1, |
| 13 0xc5, |
| 14 0xa3, |
| 15 0xc3, |
| 16 0xa9, |
| 17 0x72, |
| 18 0xc3, |
| 19 0xb1, |
| 20 0xc3, |
| 21 0xa5, |
| 22 0xc5, |
| 23 0xa3, |
| 24 0xc3, |
| 25 0xae, |
| 26 0xc3, |
| 27 0xb6, |
| 28 0xc3, |
| 29 0xb1, |
| 30 0xc3, |
| 31 0xa5, |
| 32 0xc4, |
| 33 0xbc, |
| 34 0xc3, |
| 35 0xae, |
| 36 0xc5, |
| 37 0xbe, |
| 38 0xc3, |
| 39 0xa5, |
| 40 0xc5, |
| 41 0xa3, |
| 42 0xc3, |
| 43 0xae, |
| 44 0xe1, |
| 45 0xbb, |
| 46 0x9d, |
| 47 0xc3, |
| 48 0xb1 |
| 49 ]; |
13 const INTER_STRING = "Îñţérñåţîöñåļîžåţîờñ"; | 50 const INTER_STRING = "Îñţérñåţîöñåļîžåţîờñ"; |
14 | 51 |
15 // Blueberry porridge in Danish: "blåbærgrød". | 52 // Blueberry porridge in Danish: "blåbærgrød". |
16 const BLUEBERRY_BYTES = const [0x62, 0x6c, 0xc3, 0xa5, 0x62, 0xc3, 0xa6, 0x72, | 53 const BLUEBERRY_BYTES = const [ |
17 0x67, 0x72, 0xc3, 0xb8, 0x64]; | 54 0x62, |
| 55 0x6c, |
| 56 0xc3, |
| 57 0xa5, |
| 58 0x62, |
| 59 0xc3, |
| 60 0xa6, |
| 61 0x72, |
| 62 0x67, |
| 63 0x72, |
| 64 0xc3, |
| 65 0xb8, |
| 66 0x64 |
| 67 ]; |
18 const BLUEBERRY_STRING = "blåbærgrød"; | 68 const BLUEBERRY_STRING = "blåbærgrød"; |
19 | 69 |
20 // "சிவா அணாமாைல", that is "Siva Annamalai" in Tamil. | 70 // "சிவா அணாமாைல", that is "Siva Annamalai" in Tamil. |
21 const SIVA_BYTES1 = const [0xe0, 0xae, 0x9a, 0xe0, 0xae, 0xbf, 0xe0, 0xae, 0xb5, | 71 const SIVA_BYTES1 = const [ |
22 0xe0, 0xae, 0xbe, 0x20, 0xe0, 0xae, 0x85, 0xe0, 0xae, | 72 0xe0, |
23 0xa3, 0xe0, 0xae, 0xbe, 0xe0, 0xae, 0xae, 0xe0, 0xae, | 73 0xae, |
24 0xbe, 0xe0, 0xaf, 0x88, 0xe0, 0xae, 0xb2]; | 74 0x9a, |
| 75 0xe0, |
| 76 0xae, |
| 77 0xbf, |
| 78 0xe0, |
| 79 0xae, |
| 80 0xb5, |
| 81 0xe0, |
| 82 0xae, |
| 83 0xbe, |
| 84 0x20, |
| 85 0xe0, |
| 86 0xae, |
| 87 0x85, |
| 88 0xe0, |
| 89 0xae, |
| 90 0xa3, |
| 91 0xe0, |
| 92 0xae, |
| 93 0xbe, |
| 94 0xe0, |
| 95 0xae, |
| 96 0xae, |
| 97 0xe0, |
| 98 0xae, |
| 99 0xbe, |
| 100 0xe0, |
| 101 0xaf, |
| 102 0x88, |
| 103 0xe0, |
| 104 0xae, |
| 105 0xb2 |
| 106 ]; |
25 const SIVA_STRING1 = "சிவா அணாமாைல"; | 107 const SIVA_STRING1 = "சிவா அணாமாைல"; |
26 | 108 |
27 // "िसवा अणामालै", that is "Siva Annamalai" in Devanagari. | 109 // "िसवा अणामालै", that is "Siva Annamalai" in Devanagari. |
28 const SIVA_BYTES2 = const [0xe0, 0xa4, 0xbf, 0xe0, 0xa4, 0xb8, 0xe0, 0xa4, 0xb5, | 110 const SIVA_BYTES2 = const [ |
29 0xe0, 0xa4, 0xbe, 0x20, 0xe0, 0xa4, 0x85, 0xe0, 0xa4, | 111 0xe0, |
30 0xa3, 0xe0, 0xa4, 0xbe, 0xe0, 0xa4, 0xae, 0xe0, 0xa4, | 112 0xa4, |
31 0xbe, 0xe0, 0xa4, 0xb2, 0xe0, 0xa5, 0x88]; | 113 0xbf, |
| 114 0xe0, |
| 115 0xa4, |
| 116 0xb8, |
| 117 0xe0, |
| 118 0xa4, |
| 119 0xb5, |
| 120 0xe0, |
| 121 0xa4, |
| 122 0xbe, |
| 123 0x20, |
| 124 0xe0, |
| 125 0xa4, |
| 126 0x85, |
| 127 0xe0, |
| 128 0xa4, |
| 129 0xa3, |
| 130 0xe0, |
| 131 0xa4, |
| 132 0xbe, |
| 133 0xe0, |
| 134 0xa4, |
| 135 0xae, |
| 136 0xe0, |
| 137 0xa4, |
| 138 0xbe, |
| 139 0xe0, |
| 140 0xa4, |
| 141 0xb2, |
| 142 0xe0, |
| 143 0xa5, |
| 144 0x88 |
| 145 ]; |
32 const SIVA_STRING2 = "िसवा अणामालै"; | 146 const SIVA_STRING2 = "िसवा अणामालै"; |
33 | 147 |
34 // DESERET CAPITAL LETTER BEE, unicode 0x10412(0xD801+0xDC12) | 148 // DESERET CAPITAL LETTER BEE, unicode 0x10412(0xD801+0xDC12) |
35 // UTF-8: F0 90 90 92 | 149 // UTF-8: F0 90 90 92 |
36 const BEE_BYTES = const [0xf0, 0x90, 0x90, 0x92]; | 150 const BEE_BYTES = const [0xf0, 0x90, 0x90, 0x92]; |
37 const BEE_STRING = "𐐒"; | 151 const BEE_STRING = "𐐒"; |
38 | 152 |
39 const DIGIT_BYTES = const [ 0x35 ]; | 153 const DIGIT_BYTES = const [0x35]; |
40 const DIGIT_STRING = "5"; | 154 const DIGIT_STRING = "5"; |
41 | 155 |
42 const ASCII_BYTES = const [ 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, | 156 const ASCII_BYTES = const [ |
43 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, | 157 0x61, |
44 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, | 158 0x62, |
45 0x79, 0x7A ]; | 159 0x63, |
| 160 0x64, |
| 161 0x65, |
| 162 0x66, |
| 163 0x67, |
| 164 0x68, |
| 165 0x69, |
| 166 0x6A, |
| 167 0x6B, |
| 168 0x6C, |
| 169 0x6D, |
| 170 0x6E, |
| 171 0x6F, |
| 172 0x70, |
| 173 0x71, |
| 174 0x72, |
| 175 0x73, |
| 176 0x74, |
| 177 0x75, |
| 178 0x76, |
| 179 0x77, |
| 180 0x78, |
| 181 0x79, |
| 182 0x7A |
| 183 ]; |
46 const ASCII_STRING = "abcdefghijklmnopqrstuvwxyz"; | 184 const ASCII_STRING = "abcdefghijklmnopqrstuvwxyz"; |
47 | 185 |
48 const BIGGEST_ASCII_BYTES = const [ 0x7F ]; | 186 const BIGGEST_ASCII_BYTES = const [0x7F]; |
49 const BIGGEST_ASCII_STRING = "\x7F"; | 187 const BIGGEST_ASCII_STRING = "\x7F"; |
50 | 188 |
51 const SMALLEST_2_UTF8_UNIT_BYTES = const [ 0xC2, 0x80 ]; | 189 const SMALLEST_2_UTF8_UNIT_BYTES = const [0xC2, 0x80]; |
52 const SMALLEST_2_UTF8_UNIT_STRING = "\u{80}"; | 190 const SMALLEST_2_UTF8_UNIT_STRING = "\u{80}"; |
53 | 191 |
54 const BIGGEST_2_UTF8_UNIT_BYTES = const [ 0xDF, 0xBF ]; | 192 const BIGGEST_2_UTF8_UNIT_BYTES = const [0xDF, 0xBF]; |
55 const BIGGEST_2_UTF8_UNIT_STRING = "\u{7FF}"; | 193 const BIGGEST_2_UTF8_UNIT_STRING = "\u{7FF}"; |
56 | 194 |
57 const SMALLEST_3_UTF8_UNIT_BYTES = const [ 0xE0, 0xA0, 0x80 ]; | 195 const SMALLEST_3_UTF8_UNIT_BYTES = const [0xE0, 0xA0, 0x80]; |
58 const SMALLEST_3_UTF8_UNIT_STRING = "\u{800}"; | 196 const SMALLEST_3_UTF8_UNIT_STRING = "\u{800}"; |
59 | 197 |
60 const BIGGEST_3_UTF8_UNIT_BYTES = const [ 0xEF, 0xBF, 0xBF ]; | 198 const BIGGEST_3_UTF8_UNIT_BYTES = const [0xEF, 0xBF, 0xBF]; |
61 const BIGGEST_3_UTF8_UNIT_STRING = "\u{FFFF}"; | 199 const BIGGEST_3_UTF8_UNIT_STRING = "\u{FFFF}"; |
62 | 200 |
63 const SMALLEST_4_UTF8_UNIT_BYTES = const [ 0xF0, 0x90, 0x80, 0x80 ]; | 201 const SMALLEST_4_UTF8_UNIT_BYTES = const [0xF0, 0x90, 0x80, 0x80]; |
64 const SMALLEST_4_UTF8_UNIT_STRING = "\u{10000}"; | 202 const SMALLEST_4_UTF8_UNIT_STRING = "\u{10000}"; |
65 | 203 |
66 const BIGGEST_4_UTF8_UNIT_BYTES = const [ 0xF4, 0x8F, 0xBF, 0xBF ]; | 204 const BIGGEST_4_UTF8_UNIT_BYTES = const [0xF4, 0x8F, 0xBF, 0xBF]; |
67 const BIGGEST_4_UTF8_UNIT_STRING = "\u{10FFFF}"; | 205 const BIGGEST_4_UTF8_UNIT_STRING = "\u{10FFFF}"; |
68 | 206 |
69 const _TEST_PAIRS = const [ | 207 const _TEST_PAIRS = const [ |
70 const [ const [], "" ], | 208 const [const [], ""], |
71 const [ INTER_BYTES, INTER_STRING ], | 209 const [INTER_BYTES, INTER_STRING], |
72 const [ BLUEBERRY_BYTES, BLUEBERRY_STRING ], | 210 const [BLUEBERRY_BYTES, BLUEBERRY_STRING], |
73 const [ SIVA_BYTES1, SIVA_STRING1 ], | 211 const [SIVA_BYTES1, SIVA_STRING1], |
74 const [ SIVA_BYTES2, SIVA_STRING2 ], | 212 const [SIVA_BYTES2, SIVA_STRING2], |
75 const [ BEE_BYTES, BEE_STRING ], | 213 const [BEE_BYTES, BEE_STRING], |
76 const [ DIGIT_BYTES, DIGIT_STRING ], | 214 const [DIGIT_BYTES, DIGIT_STRING], |
77 const [ ASCII_BYTES, ASCII_STRING ], | 215 const [ASCII_BYTES, ASCII_STRING], |
78 const [ BIGGEST_ASCII_BYTES, BIGGEST_ASCII_STRING ], | 216 const [BIGGEST_ASCII_BYTES, BIGGEST_ASCII_STRING], |
79 const [ SMALLEST_2_UTF8_UNIT_BYTES, SMALLEST_2_UTF8_UNIT_STRING ], | 217 const [SMALLEST_2_UTF8_UNIT_BYTES, SMALLEST_2_UTF8_UNIT_STRING], |
80 const [ BIGGEST_2_UTF8_UNIT_BYTES, BIGGEST_2_UTF8_UNIT_STRING ], | 218 const [BIGGEST_2_UTF8_UNIT_BYTES, BIGGEST_2_UTF8_UNIT_STRING], |
81 const [ SMALLEST_3_UTF8_UNIT_BYTES, SMALLEST_3_UTF8_UNIT_STRING ], | 219 const [SMALLEST_3_UTF8_UNIT_BYTES, SMALLEST_3_UTF8_UNIT_STRING], |
82 const [ BIGGEST_3_UTF8_UNIT_BYTES, BIGGEST_3_UTF8_UNIT_STRING ], | 220 const [BIGGEST_3_UTF8_UNIT_BYTES, BIGGEST_3_UTF8_UNIT_STRING], |
83 const [ SMALLEST_4_UTF8_UNIT_BYTES, SMALLEST_4_UTF8_UNIT_STRING ], | 221 const [SMALLEST_4_UTF8_UNIT_BYTES, SMALLEST_4_UTF8_UNIT_STRING], |
84 const [ BIGGEST_4_UTF8_UNIT_BYTES, BIGGEST_4_UTF8_UNIT_STRING ], | 222 const [BIGGEST_4_UTF8_UNIT_BYTES, BIGGEST_4_UTF8_UNIT_STRING], |
85 ]; | 223 ]; |
86 | 224 |
87 List<List> _expandTestPairs() { | 225 List<List> _expandTestPairs() { |
88 assert(2 == BEE_STRING.length); | 226 assert(2 == BEE_STRING.length); |
89 var tests = []; | 227 var tests = []; |
90 tests.addAll(_TEST_PAIRS); | 228 tests.addAll(_TEST_PAIRS); |
91 tests.addAll(_TEST_PAIRS.map((test) { | 229 tests.addAll(_TEST_PAIRS.map((test) { |
92 var bytes = test[0]; | 230 var bytes = test[0]; |
93 var string = test[1]; | 231 var string = test[1]; |
94 var longBytes = []; | 232 var longBytes = []; |
95 var longString = ""; | 233 var longString = ""; |
96 for (int i = 0; i < 100; i++) { | 234 for (int i = 0; i < 100; i++) { |
97 longBytes.addAll(bytes); | 235 longBytes.addAll(bytes); |
98 longString += string; | 236 longString += string; |
99 } | 237 } |
100 return [longBytes, longString]; | 238 return [longBytes, longString]; |
101 })); | 239 })); |
102 return tests; | 240 return tests; |
103 } | 241 } |
104 | 242 |
105 final List UNICODE_TESTS = _expandTestPairs(); | 243 final List UNICODE_TESTS = _expandTestPairs(); |
OLD | NEW |