Debian Codegraph @

tests/utf.test

raw
1 # This file contains a collection of tests for tclUtf.c
2 # Sourcing this file into Tcl runs the tests and generates output for
3 # errors. No output means no errors were found.
4 #
5 # Copyright (c) 1997 Sun Microsystems, Inc.
6 # Copyright (c) 1998-1999 Scriptics Corporation.
7 #
8 # See the file "license.terms" for information on usage and redistribution
9 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
10
11 if {"::tcltest" ni [namespace children]} {
12 package require tcltest 2.5
13 namespace import -force ::tcltest::*
14 }
15
16 ::tcltest::loadTestedCommands
17 catch [list package require -exact Tcltest [info patchlevel]]
18
19 testConstraint ucs2 [expr {[format %c 0x010000] eq "\uFFFD"}]
20 testConstraint fullutf [expr {[format %c 0x010000] ne "\uFFFD"}]
21 testConstraint utf16 [expr {[string length [format %c 0x10000]] == 2}]
22 testConstraint utf32 [expr {[testConstraint fullutf]
23 && [string length [format %c 0x10000]] == 1}]
24
25 testConstraint Uesc [expr {"\U0041" eq "A"}]
26 testConstraint pre388 [expr {"\x741" eq "A"}]
27 testConstraint pairsTo4bytes [expr {[llength [info commands teststringbytes]]
28 && [string length [teststringbytes \uD83D\uDCA9]] == 4}]
29
30 testConstraint testbytestring [llength [info commands testbytestring]]
31 testConstraint testfindfirst [llength [info commands testfindfirst]]
32 testConstraint testfindlast [llength [info commands testfindlast]]
33 testConstraint testnumutfchars [llength [info commands testnumutfchars]]
34 testConstraint teststringobj [llength [info commands teststringobj]]
35 testConstraint testutfnext [llength [info commands testutfnext]]
36 testConstraint testutfprev [llength [info commands testutfprev]]
37 testConstraint testgetunichar [llength [info commands testgetunichar]]
38
39 testConstraint tip413 [expr {[string trim \x00] eq {}}]
40
41 catch {unset x}
42
43 test utf-1.1 {Tcl_UniCharToUtf: 1 byte sequences} testbytestring {
44 expr {"\x01" eq [testbytestring \x01]}
45 } 1
46 test utf-1.2 {Tcl_UniCharToUtf: 2 byte sequences} testbytestring {
47 expr {"\x00" eq [testbytestring \xC0\x80]}
48 } 1
49 test utf-1.3 {Tcl_UniCharToUtf: 2 byte sequences} testbytestring {
50 expr {"\xE0" eq [testbytestring \xC3\xA0]}
51 } 1
52 test utf-1.4 {Tcl_UniCharToUtf: 3 byte sequences} testbytestring {
53 expr {"\u4E4E" eq [testbytestring \xE4\xB9\x8E]}
54 } 1
55 test utf-1.5 {Tcl_UniCharToUtf: overflowed Tcl_UniChar} testbytestring {
56 expr {[format %c 0x110000] eq [testbytestring \xEF\xBF\xBD]}
57 } 1
58 test utf-1.6 {Tcl_UniCharToUtf: negative Tcl_UniChar} testbytestring {
59 expr {[format %c -1] eq [testbytestring \xEF\xBF\xBD]}
60 } 1
61 test utf-1.7.0 {Tcl_UniCharToUtf: 4 byte sequences} {fullutf testbytestring} {
62 expr {"\U014E4E" eq [testbytestring \xF0\x94\xB9\x8E]}
63 } 1
64 test utf-1.7.1 {Tcl_UniCharToUtf: 4 byte sequences} {Uesc ucs2 testbytestring} {
65 expr {"\U014E4E" eq [testbytestring \xF0\x94\xB9\x8E]}
66 } 0
67 test utf-1.8 {Tcl_UniCharToUtf: 3 byte sequence, high surrogate} testbytestring {
68 expr {"\uD842" eq [testbytestring \xED\xA1\x82]}
69 } 1
70 test utf-1.9 {Tcl_UniCharToUtf: 3 byte sequence, low surrogate} testbytestring {
71 expr {"\uDC42" eq [testbytestring \xED\xB1\x82]}
72 } 1
73 test utf-1.10 {Tcl_UniCharToUtf: 3 byte sequence, high surrogate} testbytestring {
74 expr {[format %c 0xD842] eq [testbytestring \xED\xA1\x82]}
75 } 1
76 test utf-1.11 {Tcl_UniCharToUtf: 3 byte sequence, low surrogate} testbytestring {
77 expr {[format %c 0xDC42] eq [testbytestring \xED\xB1\x82]}
78 } 1
79 test utf-1.12 {Tcl_UniCharToUtf: 4 byte sequence, high/low surrogate} {pairsTo4bytes testbytestring} {
80 expr {"\uD842\uDC42" eq [testbytestring \xF0\xA0\xA1\x82]}
81 } 1
82 test utf-1.13.0 {Tcl_UniCharToUtf: Invalid surrogate} {Uesc ucs2} {
83 expr {"\UD842" eq "\uD842"}
84 } 1
85 test utf-1.13.1 {Tcl_UniCharToUtf: Invalid surrogate} {fullutf testbytestring} {
86 expr {"\UD842" eq [testbytestring \xEF\xBF\xBD]}
87 } 1
88
89 test utf-2.1 {Tcl_UtfToUniChar: low ascii} {
90 string length "abc"
91 } 3
92 test utf-2.2 {Tcl_UtfToUniChar: naked trail bytes} testbytestring {
93 string length [testbytestring \x82\x83\x84]
94 } 3
95 test utf-2.3 {Tcl_UtfToUniChar: lead (2-byte) followed by non-trail} testbytestring {
96 string length [testbytestring \xC2]
97 } 1
98 test utf-2.4 {Tcl_UtfToUniChar: lead (2-byte) followed by trail} {
99 string length \xA2
100 } 1
101 test utf-2.5 {Tcl_UtfToUniChar: lead (3-byte) followed by non-trail} testbytestring {
102 string length [testbytestring \xE2]
103 } 1
104 test utf-2.6 {Tcl_UtfToUniChar: lead (3-byte) followed by 1 trail} testbytestring {
105 string length [testbytestring \xE2\xA2]
106 } 2
107 test utf-2.7 {Tcl_UtfToUniChar: lead (3-byte) followed by 2 trail} testbytestring {
108 string length [testbytestring \xE4\xB9\x8E]
109 } 1
110 test utf-2.8.0 {Tcl_UtfToUniChar: lead (4-byte) followed by 3 trail} {ucs2 testbytestring} {
111 string length [testbytestring \xF0\x90\x80\x80]
112 } 2
113 test utf-2.8.1 {Tcl_UtfToUniChar: lead (4-byte) followed by 3 trail} utf16 {
114 string length \U010000
115 } 2
116 test utf-2.8.2 {Tcl_UtfToUniChar: lead (4-byte) followed by 3 trail} utf32 {
117 string length \U010000
118 } 1
119 test utf-2.9.0 {Tcl_UtfToUniChar: lead (4-byte) followed by 3 trail} {ucs2 testbytestring} {
120 string length [testbytestring \xF4\x8F\xBF\xBF]
121 } 2
122 test utf-2.9.1 {Tcl_UtfToUniChar: lead (4-byte) followed by 3 trail} utf16 {
123 string length \U10FFFF
124 } 2
125 test utf-2.9.2 {Tcl_UtfToUniChar: lead (4-byte) followed by 3 trail} utf32 {
126 string length \U10FFFF
127 } 1
128 test utf-2.10 {Tcl_UtfToUniChar: lead (4-byte) followed by 3 trail, underflow} testbytestring {
129 string length [testbytestring \xF0\x8F\xBF\xBF]
130 } 4
131 test utf-2.11 {Tcl_UtfToUniChar: lead (4-byte) followed by 3 trail, overflow} testbytestring {
132 # Would decode to U+110000 but that is outside the Unicode range.
133 string length [testbytestring \xF4\x90\x80\x80]
134 } 4
135 test utf-2.12 {Tcl_UtfToUniChar: longer UTF sequences not supported} testbytestring {
136 string length [testbytestring \xF8\xA2\xA2\xA2\xA2]
137 } 5
138
139 test utf-3.1 {Tcl_UtfCharComplete} {
140 } {}
141
142 test utf-4.1 {Tcl_NumUtfChars: zero length} testnumutfchars {
143 testnumutfchars ""
144 } 0
145 test utf-4.2 {Tcl_NumUtfChars: length 1} testnumutfchars {
146 testnumutfchars \xA2
147 } 1
148 test utf-4.3 {Tcl_NumUtfChars: long string} {testnumutfchars testbytestring} {
149 testnumutfchars abc\xA2[testbytestring \xE4\xB9\x8E\xA2\x4E]
150 } 7
151 test utf-4.4 {Tcl_NumUtfChars: #x00} testnumutfchars {
152 testnumutfchars \x00
153 } 1
154 test utf-4.5 {Tcl_NumUtfChars: zero length, calc len} testnumutfchars {
155 testnumutfchars "" 0
156 } 0
157 test utf-4.6 {Tcl_NumUtfChars: length 1, calc len} {testnumutfchars testbytestring} {
158 testnumutfchars \xA2 end
159 } 1
160 test utf-4.7 {Tcl_NumUtfChars: long string, calc len} {testnumutfchars testbytestring} {
161 testnumutfchars abc\xA2[testbytestring \xE4\xB9\x8E\xA2\x4E] end
162 } 7
163 test utf-4.8 {Tcl_NumUtfChars: #x00, calc len} testnumutfchars {
164 testnumutfchars \x00 end
165 } 1
166 # Bug [2738427]: Tcl_NumUtfChars(...) no overflow check
167 test utf-4.9 {Tcl_NumUtfChars: #u20AC, calc len, incomplete} {testnumutfchars testbytestring} {
168 testnumutfchars [testbytestring \xE2\x82\xAC] end-1
169 } 2
170 test utf-4.10 {Tcl_NumUtfChars: #x00, calc len, overcomplete} {testnumutfchars testbytestring} {
171 testnumutfchars [testbytestring \x00] end+1
172 } 2
173 test utf-4.11 {Tcl_NumUtfChars: 3 bytes of 4-byte UTF-8 characater} {testnumutfchars testbytestring} {
174 testnumutfchars [testbytestring \xF0\x9F\x92\xA9] end-1
175 } 3
176 test utf-4.12.0 {Tcl_NumUtfChars: #4-byte UTF-8 character} {testnumutfchars testbytestring ucs2} {
177 testnumutfchars [testbytestring \xF0\x9F\x92\xA9] end
178 } 2
179 test utf-4.12.1 {Tcl_NumUtfChars: #4-byte UTF-8 character} {testnumutfchars testbytestring utf32} {
180 testnumutfchars [testbytestring \xF0\x9F\x92\xA9] end
181 } 1
182 test utf-4.13 {Tcl_NumUtfChars: end of string} {testnumutfchars testbytestring} {
183 testnumutfchars foobar[testbytestring \xF2\xC2\xA0] end
184 } 8
185 test utf-4.14 {Tcl_NumUtfChars: 3 bytes of 4-byte UTF-8 characater} {testnumutfchars testbytestring} {
186 testnumutfchars [testbytestring \xF4\x90\x80\x80] end-1
187 } 3
188
189 test utf-5.1 {Tcl_UtfFindFirst} {testfindfirst testbytestring} {
190 testfindfirst [testbytestring abcbc] 98
191 } bcbc
192 test utf-5.2 {Tcl_UtfFindLast} {testfindlast testbytestring} {
193 testfindlast [testbytestring abcbc] 98
194 } bc
195
196 test utf-6.1 {Tcl_UtfNext} {testutfnext testbytestring} {
197 # This takes the pointer one past the terminating NUL.
198 # This is really an invalid call.
199 testutfnext [testbytestring \x00]
200 } 1
201 test utf-6.2 {Tcl_UtfNext} testutfnext {
202 testutfnext A
203 } 1
204 test utf-6.3 {Tcl_UtfNext} testutfnext {
205 testutfnext AA
206 } 1
207 test utf-6.4 {Tcl_UtfNext} {testutfnext testbytestring} {
208 testutfnext [testbytestring A\xA0]
209 } 1
210 test utf-6.5 {Tcl_UtfNext} {testutfnext testbytestring} {
211 testutfnext A[testbytestring \xD0]
212 } 1
213 test utf-6.6 {Tcl_UtfNext} {testutfnext testbytestring} {
214 testutfnext A[testbytestring \xE8]
215 } 1
216 test utf-6.7 {Tcl_UtfNext} {testutfnext testbytestring} {
217 testutfnext A[testbytestring \xF2]
218 } 1
219 test utf-6.8 {Tcl_UtfNext} {testutfnext testbytestring} {
220 testutfnext A[testbytestring \xF8]
221 } 1
222 test utf-6.9 {Tcl_UtfNext} {testutfnext testbytestring} {
223 testutfnext [testbytestring \xA0\x00]
224 } 1
225 test utf-6.10 {Tcl_UtfNext} {testutfnext testbytestring} {
226 testutfnext [testbytestring \xA0]G
227 } 1
228 test utf-6.11.0 {Tcl_UtfNext} {testutfnext testbytestring ucs2} {
229 testutfnext [testbytestring \xA0\xA0\x00]
230 } 1
231 test utf-6.11.1 {Tcl_UtfNext} {testutfnext testbytestring fullutf} {
232 testutfnext [testbytestring \xA0\xA0\x00]
233 } 2
234 test utf-6.12 {Tcl_UtfNext} {testutfnext testbytestring} {
235 testutfnext [testbytestring \xA0\xD0]
236 } 1
237 test utf-6.13 {Tcl_UtfNext} {testutfnext testbytestring} {
238 testutfnext [testbytestring \xA0\xE8]
239 } 1
240 test utf-6.14 {Tcl_UtfNext} {testutfnext testbytestring} {
241 testutfnext [testbytestring \xA0\xF2]
242 } 1
243 test utf-6.15 {Tcl_UtfNext} {testutfnext testbytestring} {
244 testutfnext [testbytestring \xA0\xF8]
245 } 1
246 test utf-6.16 {Tcl_UtfNext} {testutfnext testbytestring} {
247 testutfnext [testbytestring \xD0\x00]
248 } 1
249 test utf-6.17 {Tcl_UtfNext} {testutfnext testbytestring} {
250 testutfnext [testbytestring \xD0]G
251 } 1
252 test utf-6.18 {Tcl_UtfNext} {testutfnext testbytestring} {
253 testutfnext [testbytestring \xD0\xA0]
254 } 2
255 test utf-6.19 {Tcl_UtfNext} {testutfnext testbytestring} {
256 testutfnext [testbytestring \xD0\xD0]
257 } 1
258 test utf-6.20 {Tcl_UtfNext} {testutfnext testbytestring} {
259 testutfnext [testbytestring \xD0\xE8]
260 } 1
261 test utf-6.21 {Tcl_UtfNext} {testutfnext testbytestring} {
262 testutfnext [testbytestring \xD0\xF2]
263 } 1
264 test utf-6.22 {Tcl_UtfNext} {testutfnext testbytestring} {
265 testutfnext [testbytestring \xD0\xF8]
266 } 1
267 test utf-6.23 {Tcl_UtfNext} {testutfnext testbytestring} {
268 testutfnext [testbytestring \xE8\x00]
269 } 1
270 test utf-6.24 {Tcl_UtfNext} {testutfnext testbytestring} {
271 testutfnext [testbytestring \xE8]G
272 } 1
273 test utf-6.25 {Tcl_UtfNext} {testutfnext testbytestring} {
274 testutfnext [testbytestring \xE8\xA0\x00]
275 } 1
276 test utf-6.26 {Tcl_UtfNext} {testutfnext testbytestring} {
277 testutfnext [testbytestring \xE8\xD0]
278 } 1
279 test utf-6.27 {Tcl_UtfNext} {testutfnext testbytestring} {
280 testutfnext [testbytestring \xE8\xE8]
281 } 1
282 test utf-6.28 {Tcl_UtfNext} {testutfnext testbytestring} {
283 testutfnext [testbytestring \xE8\xF2]
284 } 1
285 test utf-6.29 {Tcl_UtfNext} {testutfnext testbytestring} {
286 testutfnext [testbytestring \xE8\xF8]
287 } 1
288 test utf-6.30.0 {Tcl_UtfNext} {testutfnext testbytestring ucs2} {
289 testutfnext [testbytestring \xF2]
290 } 1
291 test utf-6.30.1 {Tcl_UtfNext} {testutfnext testbytestring fullutf} {
292 testutfnext [testbytestring \xF2\x00]
293 } 1
294 test utf-6.31 {Tcl_UtfNext} {testutfnext testbytestring} {
295 testutfnext [testbytestring \xF2]G
296 } 1
297 test utf-6.32.0 {Tcl_UtfNext} {testutfnext testbytestring ucs2} {
298 testutfnext [testbytestring \xF2\xA0]
299 } 1
300 test utf-6.32.1 {Tcl_UtfNext} {testutfnext testbytestring fullutf} {
301 testutfnext [testbytestring \xF2\xA0\x00]
302 } 1
303 test utf-6.33 {Tcl_UtfNext} {testutfnext testbytestring} {
304 testutfnext [testbytestring \xF2\xD0]
305 } 1
306 test utf-6.34 {Tcl_UtfNext} {testutfnext testbytestring} {
307 testutfnext [testbytestring \xF2\xE8]
308 } 1
309 test utf-6.35 {Tcl_UtfNext} {testutfnext testbytestring} {
310 testutfnext [testbytestring \xF2\xF2]
311 } 1
312 test utf-6.36 {Tcl_UtfNext} {testutfnext testbytestring} {
313 testutfnext [testbytestring \xF2\xF8]
314 } 1
315 test utf-6.37 {Tcl_UtfNext} {testutfnext testbytestring} {
316 testutfnext [testbytestring \xF8]
317 } 1
318 test utf-6.38 {Tcl_UtfNext} {testutfnext testbytestring} {
319 testutfnext [testbytestring \xF8]G
320 } 1
321 test utf-6.39 {Tcl_UtfNext} {testutfnext testbytestring} {
322 testutfnext [testbytestring \xF8\xA0]
323 } 1
324 test utf-6.40 {Tcl_UtfNext} {testutfnext testbytestring} {
325 testutfnext [testbytestring \xF8\xD0]
326 } 1
327 test utf-6.41 {Tcl_UtfNext} {testutfnext testbytestring} {
328 testutfnext [testbytestring \xF8\xE8]
329 } 1
330 test utf-6.42 {Tcl_UtfNext} {testutfnext testbytestring} {
331 testutfnext [testbytestring \xF8\xF2]
332 } 1
333 test utf-6.43 {Tcl_UtfNext} {testutfnext testbytestring} {
334 testutfnext [testbytestring \xF8\xF8]
335 } 1
336 test utf-6.44 {Tcl_UtfNext} {testutfnext testbytestring} {
337 testutfnext [testbytestring \xD0\xA0]G
338 } 2
339 test utf-6.45 {Tcl_UtfNext} {testutfnext testbytestring} {
340 testutfnext [testbytestring \xD0\xA0\xA0]
341 } 2
342 test utf-6.46 {Tcl_UtfNext} {testutfnext testbytestring} {
343 testutfnext [testbytestring \xD0\xA0\xD0]
344 } 2
345 test utf-6.47 {Tcl_UtfNext} {testutfnext testbytestring} {
346 testutfnext [testbytestring \xD0\xA0\xE8]
347 } 2
348 test utf-6.48 {Tcl_UtfNext} {testutfnext testbytestring} {
349 testutfnext [testbytestring \xD0\xA0\xF2]
350 } 2
351 test utf-6.49 {Tcl_UtfNext} {testutfnext testbytestring} {
352 testutfnext [testbytestring \xD0\xA0\xF8]
353 } 2
354 test utf-6.50 {Tcl_UtfNext} {testutfnext testbytestring} {
355 testutfnext [testbytestring \xE8\xA0]G
356 } 1
357 test utf-6.51 {Tcl_UtfNext} testutfnext {
358 testutfnext \u8820
359 } 3
360 test utf-6.52 {Tcl_UtfNext} {testutfnext testbytestring} {
361 testutfnext [testbytestring \xE8\xA0\xD0]
362 } 1
363 test utf-6.53 {Tcl_UtfNext} {testutfnext testbytestring} {
364 testutfnext [testbytestring \xE8\xA0\xE8]
365 } 1
366 test utf-6.54 {Tcl_UtfNext} {testutfnext testbytestring} {
367 testutfnext [testbytestring \xE8\xA0\xF2]
368 } 1
369 test utf-6.55 {Tcl_UtfNext} {testutfnext testbytestring} {
370 testutfnext [testbytestring \xE8\xA0\xF8]
371 } 1
372 test utf-6.56 {Tcl_UtfNext} {testutfnext testbytestring} {
373 testutfnext [testbytestring \xF2\xA0]G
374 } 1
375 test utf-6.57 {Tcl_UtfNext} {testutfnext testbytestring} {
376 testutfnext [testbytestring \xF2\xA0\xA0\x00]
377 } 1
378 test utf-6.58 {Tcl_UtfNext} {testutfnext testbytestring} {
379 testutfnext [testbytestring \xF2\xA0\xD0]
380 } 1
381 test utf-6.59 {Tcl_UtfNext} {testutfnext testbytestring} {
382 testutfnext [testbytestring \xF2\xA0\xE8]
383 } 1
384 test utf-6.60 {Tcl_UtfNext} {testutfnext testbytestring} {
385 testutfnext [testbytestring \xF2\xA0\xF2]
386 } 1
387 test utf-6.61 {Tcl_UtfNext} {testutfnext testbytestring} {
388 testutfnext [testbytestring \xF2\xA0\xF8]
389 } 1
390 test utf-6.62 {Tcl_UtfNext} testutfnext {
391 testutfnext \u8820G
392 } 3
393 test utf-6.63 {Tcl_UtfNext} {testutfnext testbytestring} {
394 testutfnext [testbytestring \xE8\xA0\xA0\xA0]
395 } 3
396 test utf-6.64 {Tcl_UtfNext} {testutfnext testbytestring} {
397 testutfnext \u8820[testbytestring \xD0]
398 } 3
399 test utf-6.65 {Tcl_UtfNext} {testutfnext testbytestring} {
400 testutfnext \u8820[testbytestring \xE8]
401 } 3
402 test utf-6.66 {Tcl_UtfNext} {testutfnext testbytestring} {
403 testutfnext \u8820[testbytestring \xF2]
404 } 3
405 test utf-6.67 {Tcl_UtfNext} {testutfnext testbytestring} {
406 testutfnext \u8820[testbytestring \xF8]
407 } 3
408 test utf-6.68 {Tcl_UtfNext} {testutfnext testbytestring} {
409 testutfnext [testbytestring \xF2\xA0\xA0]G
410 } 1
411 test utf-6.69.0 {Tcl_UtfNext} {testutfnext testbytestring ucs2} {
412 testutfnext [testbytestring \xF2\xA0\xA0\xA0]
413 } 1
414 test utf-6.69.1 {Tcl_UtfNext} {testutfnext testbytestring fullutf} {
415 testutfnext [testbytestring \xF2\xA0\xA0\xA0]
416 } 4
417 test utf-6.70 {Tcl_UtfNext} {testutfnext testbytestring} {
418 testutfnext [testbytestring \xF2\xA0\xA0\xD0]
419 } 1
420 test utf-6.71 {Tcl_UtfNext} {testutfnext testbytestring} {
421 testutfnext [testbytestring \xF2\xA0\xA0\xE8]
422 } 1
423 test utf-6.72 {Tcl_UtfNext} {testutfnext testbytestring} {
424 testutfnext [testbytestring \xF2\xA0\xA0\xF2]
425 } 1
426 test utf-6.73 {Tcl_UtfNext} {testutfnext testbytestring} {
427 testutfnext [testbytestring \xF2\xA0\xA0\xF8]
428 } 1
429 test utf-6.74.0 {Tcl_UtfNext} {testutfnext testbytestring ucs2} {
430 testutfnext [testbytestring \xF2\xA0\xA0\xA0]G
431 } 1
432 test utf-6.74.1 {Tcl_UtfNext} {testutfnext testbytestring fullutf} {
433 testutfnext [testbytestring \xF2\xA0\xA0\xA0]G
434 } 4
435 test utf-6.75.0 {Tcl_UtfNext} {testutfnext testbytestring ucs2} {
436 testutfnext [testbytestring \xF2\xA0\xA0\xA0\xA0]
437 } 1
438 test utf-6.75.1 {Tcl_UtfNext} {testutfnext testbytestring fullutf} {
439 testutfnext [testbytestring \xF2\xA0\xA0\xA0\xA0]
440 } 4
441 test utf-6.76.0 {Tcl_UtfNext} {testutfnext testbytestring ucs2} {
442 testutfnext [testbytestring \xF2\xA0\xA0\xA0\xD0]
443 } 1
444 test utf-6.76.1 {Tcl_UtfNext} {testutfnext testbytestring fullutf} {
445 testutfnext [testbytestring \xF2\xA0\xA0\xA0\xD0]
446 } 4
447 test utf-6.77.0 {Tcl_UtfNext} {testutfnext testbytestring ucs2} {
448 testutfnext [testbytestring \xF2\xA0\xA0\xA0\xE8]
449 } 1
450 test utf-6.77.1 {Tcl_UtfNext} {testutfnext testbytestring fullutf} {
451 testutfnext [testbytestring \xF2\xA0\xA0\xA0\xE8]
452 } 4
453 test utf-6.78.0 {Tcl_UtfNext} {testutfnext testbytestring ucs2} {
454 testutfnext [testbytestring \xF2\xA0\xA0\xA0\xF2]
455 } 1
456 test utf-6.78.1 {Tcl_UtfNext} {testutfnext testbytestring fullutf} {
457 testutfnext [testbytestring \xF2\xA0\xA0\xA0\xF2]
458 } 4
459 test utf-6.79.0 {Tcl_UtfNext} {testutfnext testbytestring ucs2} {
460 testutfnext [testbytestring \xF2\xA0\xA0\xA0G\xF8]
461 } 1
462 test utf-6.79.1 {Tcl_UtfNext} {testutfnext testbytestring fullutf} {
463 testutfnext [testbytestring \xF2\xA0\xA0\xA0G\xF8]
464 } 4
465 test utf-6.80 {Tcl_UtfNext - overlong sequences} testutfnext {
466 testutfnext \x00
467 } 2
468 test utf-6.81 {Tcl_UtfNext - overlong sequences} {testutfnext testbytestring} {
469 testutfnext [testbytestring \xC0\x81]
470 } 1
471 test utf-6.82 {Tcl_UtfNext - overlong sequences} {testutfnext testbytestring} {
472 testutfnext [testbytestring \xC1\x80]
473 } 1
474 test utf-6.83 {Tcl_UtfNext - overlong sequences} {testutfnext testbytestring} {
475 testutfnext [testbytestring \xC2\x80]
476 } 2
477 test utf-6.84 {Tcl_UtfNext - overlong sequences} {testutfnext testbytestring} {
478 testutfnext [testbytestring \xE0\x80\x80]
479 } 1
480 test utf-6.85 {Tcl_UtfNext - overlong sequences} {testutfnext testbytestring} {
481 testutfnext [testbytestring \xE0\xA0\x80]
482 } 3
483 test utf-6.86 {Tcl_UtfNext - overlong sequences} {testutfnext testbytestring} {
484 testutfnext [testbytestring \xF0\x80\x80\x80]
485 } 1
486 test utf-6.87.0 {Tcl_UtfNext - overlong sequences} {testutfnext testbytestring ucs2} {
487 testutfnext [testbytestring \xF0\x90\x80\x80]
488 } 1
489 test utf-6.87.1 {Tcl_UtfNext - overlong sequences} {testutfnext testbytestring fullutf} {
490 testutfnext [testbytestring \xF0\x90\x80\x80]
491 } 4
492 test utf-6.88.0 {Tcl_UtfNext, pointing to 2th byte of 3-byte valid sequence} {testutfnext testbytestring ucs2} {
493 testutfnext [testbytestring \xA0\xA0\x00]
494 } 1
495 test utf-6.88.1 {Tcl_UtfNext, pointing to 2th byte of 3-byte valid sequence} {testutfnext testbytestring fullutf} {
496 testutfnext [testbytestring \xA0\xA0\x00]
497 } 2
498 test utf-6.89.0 {Tcl_UtfNext, pointing to 2th byte of 3-byte invalid sequence} {testutfnext testbytestring ucs2} {
499 testutfnext [testbytestring \x80\x80\x00]
500 } 1
501 test utf-6.89.1 {Tcl_UtfNext, pointing to 2th byte of 3-byte invalid sequence} {testutfnext testbytestring fullutf} {
502 testutfnext [testbytestring \x80\x80\x00]
503 } 2
504 test utf-6.90.0 {Tcl_UtfNext, validity check [493dccc2de]} {testutfnext testbytestring ucs2} {
505 testutfnext [testbytestring \xF4\x8F\xBF\xBF]
506 } 1
507 test utf-6.90.1 {Tcl_UtfNext, validity check [493dccc2de]} {testutfnext testbytestring fullutf} {
508 testutfnext [testbytestring \xF4\x8F\xBF\xBF]
509 } 4
510 test utf-6.91 {Tcl_UtfNext, validity check [493dccc2de]} {testutfnext testbytestring} {
511 testutfnext [testbytestring \xF4\x90\x80\x80]
512 } 1
513 test utf-6.92.0 {Tcl_UtfNext, pointing to 2th byte of 4-byte valid sequence} {testutfnext testbytestring ucs2} {
514 testutfnext [testbytestring \xA0\xA0\xA0]
515 } 1
516 test utf-6.92.1 {Tcl_UtfNext, pointing to 2th byte of 4-byte valid sequence} {testutfnext testbytestring fullutf} {
517 testutfnext [testbytestring \xA0\xA0\xA0]
518 } 3
519 test utf-6.93.0 {Tcl_UtfNext, pointing to 2th byte of 4-byte invalid sequence} {testutfnext testbytestring ucs2} {
520 testutfnext [testbytestring \x80\x80\x80]
521 } 1
522 test utf-6.93.1 {Tcl_UtfNext, pointing to 2th byte of 4-byte invalid sequence} {testutfnext testbytestring fullutf} {
523 testutfnext [testbytestring \x80\x80\x80]
524 } 3
525 test utf-6.94.0 {Tcl_UtfNext, pointing to 2th byte of 5-byte invalid sequence} {testutfnext testbytestring ucs2} {
526 testutfnext [testbytestring \xA0\xA0\xA0\xA0]
527 } 1
528 test utf-6.94.1 {Tcl_UtfNext, pointing to 2th byte of 5-byte invalid sequence} {testutfnext testbytestring fullutf} {
529 testutfnext [testbytestring \xA0\xA0\xA0\xA0]
530 } 3
531 test utf-6.95.0 {Tcl_UtfNext, pointing to 2th byte of 5-byte invalid sequence} {testutfnext testbytestring ucs2} {
532 testutfnext [testbytestring \x80\x80\x80\x80]
533 } 1
534 test utf-6.95.1 {Tcl_UtfNext, pointing to 2th byte of 5-byte invalid sequence} {testutfnext testbytestring fullutf} {
535 testutfnext [testbytestring \x80\x80\x80\x80]
536 } 3
537 test utf-6.96 {Tcl_UtfNext, read limits} testutfnext {
538 testutfnext G 0
539 } 0
540 test utf-6.97 {Tcl_UtfNext, read limits} {testutfnext testbytestring} {
541 testutfnext [testbytestring \xA0] 0
542 } 0
543 test utf-6.98 {Tcl_UtfNext, read limits} testutfnext {
544 testutfnext AG 1
545 } 1
546 test utf-6.99 {Tcl_UtfNext, read limits} {testutfnext testbytestring} {
547 testutfnext A[testbytestring \xA0] 1
548 } 1
549 test utf-6.100 {Tcl_UtfNext, read limits} {testutfnext testbytestring} {
550 testutfnext [testbytestring \xD0\xA0]G 1
551 } 0
552 test utf-6.101 {Tcl_UtfNext, read limits} {testutfnext testbytestring} {
553 testutfnext [testbytestring \xD0\xA0]G 2
554 } 2
555 test utf-6.102 {Tcl_UtfNext, read limits} {testutfnext testbytestring} {
556 testutfnext [testbytestring \xD0\xA0\xA0] 1
557 } 0
558 test utf-6.103 {Tcl_UtfNext, read limits} {testutfnext testbytestring} {
559 testutfnext [testbytestring \xD0\xA0\xA0] 2
560 } 2
561 test utf-6.104 {Tcl_UtfNext, read limits} testutfnext {
562 testutfnext \u8820G 1
563 } 0
564 test utf-6.105 {Tcl_UtfNext, read limits} testutfnext {
565 testutfnext \u8820G 2
566 } 0
567 test utf-6.106 {Tcl_UtfNext, read limits} testutfnext {
568 testutfnext \u8820G 3
569 } 3
570 test utf-6.107 {Tcl_UtfNext, read limits} {testutfnext testbytestring} {
571 testutfnext \u8820[testbytestring \xA0] 1
572 } 0
573 test utf-6.108 {Tcl_UtfNext, read limits} {testutfnext testbytestring} {
574 testutfnext \u8820[testbytestring \xA0] 2
575 } 0
576 test utf-6.109 {Tcl_UtfNext, read limits} {testutfnext testbytestring} {
577 testutfnext \u8820[testbytestring \xA0] 3
578 } 3
579 # This testcase actually tests Tcl_UtfCharComplete, not Tcl_UtfNext
580 test utf-6.110 {Tcl_UtfNext, read limits} {testutfnext testbytestring} {
581 testutfnext [testbytestring \xF2\xA0\xA0\xA0]G 1
582 } 0
583 # This testcase actually tests Tcl_UtfCharComplete, not Tcl_UtfNext
584 test utf-6.111 {Tcl_UtfNext, read limits} {testutfnext testbytestring} {
585 testutfnext [testbytestring \xF2\xA0\xA0\xA0]G 2
586 } 0
587 test utf-6.112.0 {Tcl_UtfNext, read limits} {testutfnext testbytestring ucs2} {
588 testutfnext [testbytestring \xF2\xA0\xA0\xA0]G 3
589 } 1
590 test utf-6.112.1 {Tcl_UtfNext, read limits} {testutfnext testbytestring fullutf} {
591 testutfnext [testbytestring \xF2\xA0\xA0\xA0]G 3
592 } 0
593 test utf-6.113.0 {Tcl_UtfNext, read limits} {testutfnext testbytestring ucs2} {
594 testutfnext [testbytestring \xF2\xA0\xA0\xA0]G 4
595 } 1
596 test utf-6.113.1 {Tcl_UtfNext, read limits} {testutfnext testbytestring fullutf} {
597 testutfnext [testbytestring \xF2\xA0\xA0\xA0]G 4
598 } 4
599 # This testcase actually tests Tcl_UtfCharComplete, not Tcl_UtfNext
600 test utf-6.114 {Tcl_UtfNext, read limits} {testutfnext testbytestring} {
601 testutfnext [testbytestring \xF2\xA0\xA0\xA0\xA0] 1
602 } 0
603 # This testcase actually tests Tcl_UtfCharComplete, not Tcl_UtfNext
604 test utf-6.115 {Tcl_UtfNext, read limits} {testutfnext testbytestring} {
605 testutfnext [testbytestring \xF2\xA0\xA0\xA0\xA0] 2
606 } 0
607 test utf-6.116.0 {Tcl_UtfNext, read limits} {testutfnext testbytestring ucs2} {
608 testutfnext [testbytestring \xF2\xA0\xA0\xA0\xA0] 3
609 } 1
610 test utf-6.116.1 {Tcl_UtfNext, read limits} {testutfnext testbytestring fullutf} {
611 testutfnext [testbytestring \xF2\xA0\xA0\xA0\xA0] 3
612 } 0
613 test utf-6.117.0 {Tcl_UtfNext, read limits} {testutfnext testbytestring ucs2} {
614 testutfnext [testbytestring \xF2\xA0\xA0\xA0\xA0] 4
615 } 1
616 test utf-6.117.1 {Tcl_UtfNext, read limits} {testutfnext testbytestring fullutf} {
617 testutfnext [testbytestring \xF2\xA0\xA0\xA0\xA0] 4
618 } 4
619 test utf-6.118 {Tcl_UtfNext, read limits} {testutfnext testbytestring} {
620 testutfnext [testbytestring \xA0]G 0
621 } 0
622 test utf-6.119 {Tcl_UtfNext, read limits} {testutfnext testbytestring} {
623 testutfnext [testbytestring \xA0]G 1
624 } 0
625 test utf-6.120 {Tcl_UtfNext, read limits} {testutfnext testbytestring} {
626 testutfnext [testbytestring \xA0\xA0] 1
627 } 0
628 test utf-6.121 {Tcl_UtfNext, read limits} {testutfnext testbytestring} {
629 testutfnext [testbytestring \xA0\xA0]G 2
630 } 0
631 test utf-6.122 {Tcl_UtfNext, read limits} {testutfnext testbytestring} {
632 testutfnext [testbytestring \xA0\xA0\xA0] 2
633 } 0
634 test utf-6.123.0 {Tcl_UtfNext, read limits} {testutfnext testbytestring ucs2} {
635 testutfnext [testbytestring \xA0\xA0\xA0]G 3
636 } 1
637 test utf-6.123.1 {Tcl_UtfNext, read limits} {testutfnext testbytestring fullutf} {
638 testutfnext [testbytestring \xA0\xA0\xA0]G 3
639 } 3
640 test utf-6.124.0 {Tcl_UtfNext, read limits} {testutfnext testbytestring ucs2} {
641 testutfnext [testbytestring \xA0\xA0\xA0\xA0] 3
642 } 1
643 test utf-6.124.1 {Tcl_UtfNext, read limits} {testutfnext testbytestring fullutf} {
644 testutfnext [testbytestring \xA0\xA0\xA0\xA0] 3
645 } 3
646 test utf-6.125.0 {Tcl_UtfNext, read limits} {testutfnext testbytestring ucs2} {
647 testutfnext [testbytestring \xA0\xA0\xA0\xA0]G 4
648 } 1
649 test utf-6.125.1 {Tcl_UtfNext, read limits} {testutfnext testbytestring fullutf} {
650 testutfnext [testbytestring \xA0\xA0\xA0\xA0]G 4
651 } 3
652 test utf-6.126.0 {Tcl_UtfNext, read limits} {testutfnext testbytestring ucs2} {
653 testutfnext [testbytestring \xA0\xA0\xA0\xA0\xA0] 4
654 } 1
655 test utf-6.126.1 {Tcl_UtfNext, read limits} {testutfnext testbytestring fullutf} {
656 testutfnext [testbytestring \xA0\xA0\xA0\xA0\xA0] 4
657 } 3
658
659 test utf-7.1 {Tcl_UtfPrev} testutfprev {
660 testutfprev {}
661 } 0
662 test utf-7.2 {Tcl_UtfPrev} testutfprev {
663 testutfprev A
664 } 0
665 test utf-7.3 {Tcl_UtfPrev} testutfprev {
666 testutfprev AA
667 } 1
668 test utf-7.4 {Tcl_UtfPrev} {testutfprev testbytestring} {
669 testutfprev A[testbytestring \xF8]
670 } 1
671 test utf-7.4.1 {Tcl_UtfPrev} {testutfprev testbytestring} {
672 testutfprev A[testbytestring \xF8\xA0\xA0\xA0] 2
673 } 1
674 test utf-7.4.2 {Tcl_UtfPrev} {testutfprev testbytestring} {
675 testutfprev A[testbytestring \xF8\xF8\xA0\xA0] 2
676 } 1
677 test utf-7.5 {Tcl_UtfPrev} {testutfprev testbytestring} {
678 testutfprev A[testbytestring \xF2]
679 } 1
680 test utf-7.5.1 {Tcl_UtfPrev} {testutfprev testbytestring} {
681 testutfprev A[testbytestring \xF2\xA0\xA0\xA0] 2
682 } 1
683 test utf-7.5.2 {Tcl_UtfPrev} {testutfprev testbytestring} {
684 testutfprev A[testbytestring \xF2\xF8\xA0\xA0] 2
685 } 1
686 test utf-7.6 {Tcl_UtfPrev} {testutfprev testbytestring} {
687 testutfprev A[testbytestring \xE8]
688 } 1
689 test utf-7.6.1 {Tcl_UtfPrev} {testutfprev testbytestring} {
690 testutfprev A[testbytestring \xE8\xA0\xA0\xA0] 2
691 } 1
692 test utf-7.6.2 {Tcl_UtfPrev} {testutfprev testbytestring} {
693 testutfprev A[testbytestring \xE8\xF8\xA0\xA0] 2
694 } 1
695 test utf-7.7 {Tcl_UtfPrev} {testutfprev testbytestring} {
696 testutfprev A[testbytestring \xD0]
697 } 1
698 test utf-7.7.1 {Tcl_UtfPrev} {testutfprev testbytestring} {
699 testutfprev A[testbytestring \xD0\xA0\xA0\xA0] 2
700 } 1
701 test utf-7.7.2 {Tcl_UtfPrev} {testutfprev testbytestring} {
702 testutfprev A[testbytestring \xD0\xF8\xA0\xA0] 2
703 } 1
704 test utf-7.8 {Tcl_UtfPrev} {testutfprev testbytestring} {
705 testutfprev [testbytestring A\xA0]
706 } 1
707 test utf-7.8.1 {Tcl_UtfPrev} {testutfprev testbytestring} {
708 testutfprev [testbytestring A\xA0\xA0\xA0\xA0] 2
709 } 1
710 test utf-7.8.2 {Tcl_UtfPrev} {testutfprev testbytestring} {
711 testutfprev [testbytestring A\xA0\xF8\xA0\xA0] 2
712 } 1
713 test utf-7.9 {Tcl_UtfPrev} {testutfprev testbytestring} {
714 testutfprev A[testbytestring \xF8\xA0]
715 } 2
716 test utf-7.9.1 {Tcl_UtfPrev} {testutfprev testbytestring} {
717 testutfprev A[testbytestring \xF8\xA0\xA0\xA0] 3
718 } 2
719 test utf-7.9.2 {Tcl_UtfPrev} {testutfprev testbytestring} {
720 testutfprev A[testbytestring \xF8\xA0\xF8\xA0] 3
721 } 2
722 test utf-7.10.0 {Tcl_UtfPrev} {testutfprev testbytestring ucs2} {
723 testutfprev A[testbytestring \xF2\xA0]
724 } 2
725 test utf-7.10.1 {Tcl_UtfPrev} {testutfprev testbytestring fullutf} {
726 testutfprev A[testbytestring \xF2\xA0]
727 } 1
728 test utf-7.10.2 {Tcl_UtfPrev} {testutfprev testbytestring ucs2} {
729 testutfprev A[testbytestring \xF2\xA0\xA0\xA0] 3
730 } 2
731 test utf-7.10.3 {Tcl_UtfPrev} {testutfprev testbytestring fullutf} {
732 testutfprev A[testbytestring \xF2\xA0\xA0\xA0] 3
733 } 1
734 test utf-7.10.4 {Tcl_UtfPrev} {testutfprev testbytestring ucs2} {
735 testutfprev A[testbytestring \xF2\xA0\xF8\xA0] 3
736 } 2
737 test utf-7.10.5 {Tcl_UtfPrev} {testutfprev testbytestring fullutf} {
738 testutfprev A[testbytestring \xF2\xA0\xF8\xA0] 3
739 } 1
740 test utf-7.11 {Tcl_UtfPrev} {testutfprev testbytestring} {
741 testutfprev A[testbytestring \xE8\xA0]
742 } 1
743 test utf-7.11.1 {Tcl_UtfPrev} {testutfprev testbytestring} {
744 testutfprev A[testbytestring \xE8\xA0\xA0\xA0] 3
745 } 1
746 test utf-7.11.2 {Tcl_UtfPrev} {testutfprev testbytestring} {
747 testutfprev A[testbytestring \xE8\xA0\xF8\xA0] 3
748 } 1
749 test utf-7.11.3 {Tcl_UtfPrev} {testutfprev testbytestring} {
750 testutfprev A[testbytestring \xE8\xA0\xF8] 3
751 } 1
752 test utf-7.12 {Tcl_UtfPrev} {testutfprev testbytestring} {
753 testutfprev A[testbytestring \xD0\xA0]
754 } 1
755 test utf-7.12.1 {Tcl_UtfPrev} {testutfprev testbytestring} {
756 testutfprev A[testbytestring \xD0\xA0\xA0\xA0] 3
757 } 1
758 test utf-7.12.2 {Tcl_UtfPrev} {testutfprev testbytestring} {
759 testutfprev A[testbytestring \xD0\xA0\xF8\xA0] 3
760 } 1
761 test utf-7.13 {Tcl_UtfPrev} {testutfprev testbytestring} {
762 testutfprev [testbytestring A\xA0\xA0]
763 } 2
764 test utf-7.13.1 {Tcl_UtfPrev} {testutfprev testbytestring} {
765 testutfprev [testbytestring A\xA0\xA0\xA0\xA0] 3
766 } 2
767 test utf-7.13.2 {Tcl_UtfPrev} {testutfprev testbytestring} {
768 testutfprev [testbytestring A\xA0\xA0\xF8\xA0] 3
769 } 2
770 test utf-7.14 {Tcl_UtfPrev} {testutfprev testbytestring} {
771 testutfprev A[testbytestring \xF8\xA0\xA0]
772 } 3
773 test utf-7.14.1 {Tcl_UtfPrev} {testutfprev testbytestring} {
774 testutfprev A[testbytestring \xF8\xA0\xA0\xA0] 4
775 } 3
776 test utf-7.14.2 {Tcl_UtfPrev} {testutfprev testbytestring} {
777 testutfprev A[testbytestring \xF8\xA0\xA0\xF8] 4
778 } 3
779 test utf-7.15.0 {Tcl_UtfPrev} {testutfprev testbytestring ucs2} {
780 testutfprev A[testbytestring \xF2\xA0\xA0]
781 } 3
782 test utf-7.15.1 {Tcl_UtfPrev} {testutfprev testbytestring fullutf} {
783 testutfprev A[testbytestring \xF2\xA0\xA0]
784 } 1
785 test utf-7.15.2 {Tcl_UtfPrev} {testutfprev testbytestring ucs2} {
786 testutfprev A[testbytestring \xF2\xA0\xA0\xA0] 4
787 } 3
788 test utf-7.15.3 {Tcl_UtfPrev} {testutfprev testbytestring fullutf} {
789 testutfprev A[testbytestring \xF2\xA0\xA0\xA0] 4
790 } 1
791 test utf-7.15.4 {Tcl_UtfPrev} {testutfprev testbytestring ucs2} {
792 testutfprev A[testbytestring \xF2\xA0\xA0\xF8] 4
793 } 3
794 test utf-7.15.5 {Tcl_UtfPrev} {testutfprev testbytestring fullutf} {
795 testutfprev A[testbytestring \xF2\xA0\xA0\xF8] 4
796 } 1
797 test utf-7.16 {Tcl_UtfPrev} testutfprev {
798 testutfprev A\u8820
799 } 1
800 test utf-7.16.1 {Tcl_UtfPrev} {testutfprev testbytestring} {
801 testutfprev A[testbytestring \xE8\xA0\xA0\xA0] 4
802 } 1
803 test utf-7.16.2 {Tcl_UtfPrev} {testutfprev testbytestring} {
804 testutfprev A\u8820[testbytestring \xF8] 4
805 } 1
806 test utf-7.17 {Tcl_UtfPrev} {testutfprev testbytestring} {
807 testutfprev A[testbytestring \xD0\xA0\xA0]
808 } 3
809 test utf-7.17.1 {Tcl_UtfPrev} {testutfprev testbytestring} {
810 testutfprev A[testbytestring \xD0\xA0\xA0\xA0] 4
811 } 3
812 test utf-7.17.2 {Tcl_UtfPrev} {testutfprev testbytestring} {
813 testutfprev A[testbytestring \xD0\xA0\xA0\xF8] 4
814 } 3
815 test utf-7.18.0 {Tcl_UtfPrev} {testutfprev testbytestring} {
816 testutfprev [testbytestring A\xA0\xA0\xA0]
817 } 3
818 test utf-7.18.1 {Tcl_UtfPrev} {testutfprev testbytestring} {
819 testutfprev [testbytestring A\xA0\xA0\xA0\xA0] 4
820 } 3
821 test utf-7.18.2 {Tcl_UtfPrev} {testutfprev testbytestring} {
822 testutfprev [testbytestring A\xA0\xA0\xA0\xF8] 4
823 } 3
824 test utf-7.19 {Tcl_UtfPrev} {testutfprev testbytestring} {
825 testutfprev [testbytestring A\xF8\xA0\xA0\xA0]
826 } 4
827 test utf-7.20.0 {Tcl_UtfPrev} {testutfprev testbytestring ucs2} {
828 testutfprev [testbytestring A\xF2\xA0\xA0\xA0]
829 } 4
830 test utf-7.20.1 {Tcl_UtfPrev} {testutfprev testbytestring fullutf} {
831 testutfprev [testbytestring A\xF2\xA0\xA0\xA0]
832 } 1
833 test utf-7.21 {Tcl_UtfPrev} {testutfprev testbytestring} {
834 testutfprev A[testbytestring \xE8\xA0\xA0\xA0]
835 } 4
836 test utf-7.22 {Tcl_UtfPrev} {testutfprev testbytestring} {
837 testutfprev A[testbytestring \xD0\xA0\xA0\xA0]
838 } 4
839 test utf-7.23 {Tcl_UtfPrev} {testutfprev testbytestring} {
840 testutfprev [testbytestring A\xA0\xA0\xA0\xA0]
841 } 4
842 test utf-7.24 {Tcl_UtfPrev -- overlong sequence} {testutfprev testbytestring} {
843 testutfprev A[testbytestring \xC0\x81]
844 } 2
845 test utf-7.25 {Tcl_UtfPrev -- overlong sequence} {testutfprev testbytestring} {
846 testutfprev A[testbytestring \xC0\x81] 2
847 } 1
848 test utf-7.26 {Tcl_UtfPrev -- overlong sequence} {testutfprev testbytestring} {
849 testutfprev A[testbytestring \xE0\x80\x80]
850 } 3
851 test utf-7.27 {Tcl_UtfPrev -- overlong sequence} {testutfprev testbytestring} {
852 testutfprev A[testbytestring \xE0\x80]
853 } 2
854 test utf-7.27.1 {Tcl_UtfPrev -- overlong sequence} {testutfprev testbytestring} {
855 testutfprev A[testbytestring \xE0\x80\x80] 3
856 } 2
857 test utf-7.28 {Tcl_UtfPrev -- overlong sequence} {testutfprev testbytestring} {
858 testutfprev A[testbytestring \xE0]
859 } 1
860 test utf-7.28.1 {Tcl_UtfPrev -- overlong sequence} {testutfprev testbytestring} {
861 testutfprev A[testbytestring \xE0\x80\x80] 2
862 } 1
863 test utf-7.29 {Tcl_UtfPrev -- overlong sequence} {testutfprev testbytestring} {
864 testutfprev A[testbytestring \xF0\x80\x80\x80]
865 } 4
866 test utf-7.30 {Tcl_UtfPrev -- overlong sequence} {testutfprev testbytestring} {
867 testutfprev A[testbytestring \xF0\x80\x80\x80] 4
868 } 3
869 test utf-7.31 {Tcl_UtfPrev -- overlong sequence} {testutfprev testbytestring} {
870 testutfprev A[testbytestring \xF0\x80\x80\x80] 3
871 } 2
872 test utf-7.32 {Tcl_UtfPrev -- overlong sequence} {testutfprev testbytestring} {
873 testutfprev A[testbytestring \xF0\x80\x80\x80] 2
874 } 1
875 test utf-7.33 {Tcl_UtfPrev -- overlong sequence} testutfprev {
876 testutfprev A\x00
877 } 1
878 test utf-7.34 {Tcl_UtfPrev -- overlong sequence} {testutfprev testbytestring} {
879 testutfprev A[testbytestring \xC1\x80]
880 } 2
881 test utf-7.35 {Tcl_UtfPrev -- overlong sequence} {testutfprev testbytestring} {
882 testutfprev A[testbytestring \xC2\x80]
883 } 1
884 test utf-7.36 {Tcl_UtfPrev -- overlong sequence} {testutfprev testbytestring} {
885 testutfprev A[testbytestring \xE0\xA0\x80]
886 } 1
887 test utf-7.37 {Tcl_UtfPrev -- overlong sequence} {testutfprev testbytestring} {
888 testutfprev A[testbytestring \xE0\xA0\x80] 3
889 } 1
890 test utf-7.38 {Tcl_UtfPrev -- overlong sequence} {testutfprev testbytestring} {
891 testutfprev A[testbytestring \xE0\xA0\x80] 2
892 } 1
893 test utf-7.39.0 {Tcl_UtfPrev -- overlong sequence} {testutfprev testbytestring ucs2} {
894 testutfprev A[testbytestring \xF0\x90\x80\x80]
895 } 4
896 test utf-7.39.1 {Tcl_UtfPrev -- overlong sequence} {testutfprev testbytestring fullutf} {
897 testutfprev A[testbytestring \xF0\x90\x80\x80]
898 } 1
899 test utf-7.40.0 {Tcl_UtfPrev -- overlong sequence} {testutfprev testbytestring ucs2} {
900 testutfprev A[testbytestring \xF0\x90\x80\x80] 4
901 } 3
902 test utf-7.40.1 {Tcl_UtfPrev -- overlong sequence} {testutfprev testbytestring fullutf} {
903 testutfprev A[testbytestring \xF0\x90\x80\x80] 4
904 } 1
905 test utf-7.41.0 {Tcl_UtfPrev -- overlong sequence} {testutfprev testbytestring ucs2} {
906 testutfprev A[testbytestring \xF0\x90\x80\x80] 3
907 } 2
908 test utf-7.41.1 {Tcl_UtfPrev -- overlong sequence} {testutfprev testbytestring fullutf} {
909 testutfprev A[testbytestring \xF0\x90\x80\x80] 3
910 } 1
911 test utf-7.42 {Tcl_UtfPrev -- overlong sequence} {testutfprev testbytestring} {
912 testutfprev A[testbytestring \xF0\x90\x80\x80] 2
913 } 1
914 test utf-7.43 {Tcl_UtfPrev -- no lead byte at start} {testutfprev testbytestring} {
915 testutfprev [testbytestring \xA0]
916 } 0
917 test utf-7.44 {Tcl_UtfPrev -- no lead byte at start} {testutfprev testbytestring} {
918 testutfprev [testbytestring \xA0\xA0]
919 } 1
920 test utf-7.45 {Tcl_UtfPrev -- no lead byte at start} {testutfprev testbytestring} {
921 testutfprev [testbytestring \xA0\xA0\xA0]
922 } 2
923 test utf-7.46 {Tcl_UtfPrev -- no lead byte at start} {testutfprev testbytestring} {
924 testutfprev [testbytestring \xA0\xA0\xA0\xA0]
925 } 3
926 test utf-7.47 {Tcl_UtfPrev, pointing to 3th byte of 3-byte valid sequence} {testutfprev testbytestring} {
927 testutfprev [testbytestring \xE8\xA0]
928 } 0
929 test utf-7.47.1 {Tcl_UtfPrev, pointing to 3th byte of 3-byte valid sequence} testutfprev {
930 testutfprev \u8820 2
931 } 0
932 test utf-7.47.2 {Tcl_UtfPrev, pointing to 3th byte of 3-byte invalid sequence} {testutfprev testbytestring} {
933 testutfprev [testbytestring \xE8\xA0\x00] 2
934 } 0
935 test utf-7.48.0 {Tcl_UtfPrev, validity check [493dccc2de]} {testutfprev testbytestring ucs2} {
936 testutfprev A[testbytestring \xF4\x8F\xBF\xBF]
937 } 4
938 test utf-7.48.1 {Tcl_UtfPrev, validity check [493dccc2de]} {testutfprev testbytestring fullutf} {
939 testutfprev A[testbytestring \xF4\x8F\xBF\xBF]
940 } 1
941 test utf-7.48.2 {Tcl_UtfPrev, validity check [493dccc2de]} {testutfprev testbytestring ucs2} {
942 testutfprev A[testbytestring \xF4\x8F\xBF\xBF] 4
943 } 3
944 test utf-7.48.3 {Tcl_UtfPrev, validity check [493dccc2de]} {testutfprev testbytestring fullutf} {
945 testutfprev A[testbytestring \xF4\x8F\xBF\xBF] 4
946 } 1
947 test utf-7.48.4 {Tcl_UtfPrev, validity check [493dccc2de]} {testutfprev testbytestring ucs2} {
948 testutfprev A[testbytestring \xF4\x8F\xBF\xBF] 3
949 } 2
950 test utf-7.48.5 {Tcl_UtfPrev, validity check [493dccc2de]} {testutfprev testbytestring fullutf} {
951 testutfprev A[testbytestring \xF4\x8F\xBF\xBF] 3
952 } 1
953 test utf-7.48.6 {Tcl_UtfPrev, validity check [493dccc2de]} {testutfprev testbytestring} {
954 testutfprev A[testbytestring \xF4\x8F\xBF\xBF] 2
955 } 1
956 test utf-7.49.0 {Tcl_UtfPrev, validity check [493dccc2de]} {testutfprev testbytestring} {
957 testutfprev A[testbytestring \xF4\x90\x80\x80]
958 } 4
959 test utf-7.49.1 {Tcl_UtfPrev, validity check [493dccc2de]} {testutfprev testbytestring} {
960 testutfprev A[testbytestring \xF4\x90\x80\x80] 4
961 } 3
962 test utf-7.49.2 {Tcl_UtfPrev, validity check [493dccc2de]} {testutfprev testbytestring} {
963 testutfprev A[testbytestring \xF4\x90\x80\x80] 3
964 } 2
965 test utf-7.49.3 {Tcl_UtfPrev, validity check [493dccc2de]} {testutfprev testbytestring} {
966 testutfprev A[testbytestring \xF4\x90\x80\x80] 2
967 } 1
968
969 test utf-8.1 {Tcl_UniCharAtIndex: index = 0} {
970 string index abcd 0
971 } a
972 test utf-8.2 {Tcl_UniCharAtIndex: index = 0} {
973 string index \u4E4E\u25A 0
974 } \u4E4E
975 test utf-8.3 {Tcl_UniCharAtIndex: index > 0} {
976 string index abcd 2
977 } c
978 test utf-8.4 {Tcl_UniCharAtIndex: index > 0} {
979 string index \u4E4E\u25A\xFF\u543 2
980 } \xFF
981 test utf-8.5.0 {Tcl_UniCharAtIndex: high surrogate} ucs2 {
982 string index \uD842 0
983 } \uD842
984 test utf-8.5.1 {Tcl_UniCharAtIndex: high surrogate} utf32 {
985 string index \uD842 0
986 } \uD842
987 test utf-8.5.2 {Tcl_UniCharAtIndex: high surrogate} utf16 {
988 string index \uD842 0
989 } \uD842
990 test utf-8.6 {Tcl_UniCharAtIndex: low surrogate} {
991 string index \uDC42 0
992 } \uDC42
993 test utf-8.7.0 {Tcl_UniCharAtIndex: Emoji} ucs2 {
994 string index \uD83D\uDE00G 0
995 } \uD83D
996 test utf-8.7.1 {Tcl_UniCharAtIndex: Emoji} utf32 {
997 string index \U1F600G 0
998 } \U1F600
999 test utf-8.7.2 {Tcl_UniCharAtIndex: Emoji} utf16 {
1000 string index \U1F600G 0
1001 } \U1F600
1002 test utf-8.8.0 {Tcl_UniCharAtIndex: Emoji} ucs2 {
1003 string index \uD83D\uDE00G 1
1004 } \uDE00
1005 test utf-8.8.1 {Tcl_UniCharAtIndex: Emoji} utf32 {
1006 string index \U1F600G 1
1007 } G
1008 test utf-8.8.2 {Tcl_UniCharAtIndex: Emoji} utf16 {
1009 string index \U1F600G 1
1010 } {}
1011 test utf-8.9.0 {Tcl_UniCharAtIndex: Emoji} ucs2 {
1012 string index \uD83D\uDE00G 2
1013 } G
1014 test utf-8.9.1 {Tcl_UniCharAtIndex: Emoji} utf32 {
1015 string index \U1F600G 2
1016 } {}
1017 test utf-8.9.2 {Tcl_UniCharAtIndex: Emoji} utf16 {
1018 string index \U1F600G 2
1019 } G
1020 test utf-8.10.0 {Tcl_UniCharAtIndex: Emoji} {Uesc ucs2} {
1021 string index \U1F600G 0
1022 } \uFFFD
1023 test utf-8.10.1 {Tcl_UniCharAtIndex: Emoji} utf32 {
1024 string index \U1F600G 0
1025 } \U1F600
1026 test utf-8.10.2 {Tcl_UniCharAtIndex: Emoji} utf16 {
1027 string index \U1F600G 0
1028 } \U1F600
1029 test utf-8.11.0 {Tcl_UniCharAtIndex: Emoji} {Uesc ucs2} {
1030 string index \U1F600G 1
1031 } G
1032 test utf-8.11.1 {Tcl_UniCharAtIndex: Emoji} utf32 {
1033 string index \U1F600G 1
1034 } G
1035 test utf-8.11.2 {Tcl_UniCharAtIndex: Emoji} utf16 {
1036 string index \U1F600G 1
1037 } {}
1038 test utf-8.12.0 {Tcl_UniCharAtIndex: Emoji} {Uesc ucs2} {
1039 string index \U1F600G 2
1040 } {}
1041 test utf-8.12.1 {Tcl_UniCharAtIndex: Emoji} utf32 {
1042 string index \U1F600G 2
1043 } {}
1044 test utf-8.12.2 {Tcl_UniCharAtIndex: Emoji} utf16 {
1045 string index \U1F600G 2
1046 } G
1047
1048 test utf-9.1 {Tcl_UtfAtIndex: index = 0} {
1049 string range abcd 0 2
1050 } abc
1051 test utf-9.2 {Tcl_UtfAtIndex: index > 0} {
1052 string range \u4E4E\u25A\xFF\u543klmnop 1 5
1053 } \u25A\xFF\u543kl
1054 test utf-9.3.0 {Tcl_UtfAtIndex: index = 0, Emoji} ucs2 {
1055 string range \uD83D\uDE00G 0 0
1056 } \uD83D
1057 test utf-9.3.1 {Tcl_UtfAtIndex: index = 0, Emoji} utf32 {
1058 string range \U1F600G 0 0
1059 } \U1F600
1060 test utf-9.3.2 {Tcl_UtfAtIndex: index = 0, Emoji} utf16 {
1061 string range \U1F600G 0 0
1062 } \U1F600
1063 test utf-9.4.0 {Tcl_UtfAtIndex: index > 0, Emoji} ucs2 {
1064 string range \uD83D\uDE00G 1 1
1065 } \uDE00
1066 test utf-9.4.1 {Tcl_UtfAtIndex: index > 0, Emoji} utf32 {
1067 string range \U1F600G 1 1
1068 } G
1069 test utf-9.4.2 {Tcl_UtfAtIndex: index > 0, Emoji} utf16 {
1070 string range \U1F600G 1 1
1071 } {}
1072 test utf-9.5.0 {Tcl_UtfAtIndex: index > 0, Emoji} ucs2 {
1073 string range \uD83D\uDE00G 2 2
1074 } G
1075 test utf-9.5.1 {Tcl_UtfAtIndex: index > 0, Emoji} utf32 {
1076 string range \U1F600G 2 2
1077 } {}
1078 test utf-9.5.2 {Tcl_UtfAtIndex: index > 0, Emoji} utf16 {
1079 string range \U1F600G 2 2
1080 } G
1081 test utf-9.6.0 {Tcl_UtfAtIndex: index = 0, Emoji} {Uesc ucs2} {
1082 string range \U1F600G 0 0
1083 } \uFFFD
1084 test utf-9.6.1 {Tcl_UtfAtIndex: index = 0, Emoji} utf32 {
1085 string range \U1F600G 0 0
1086 } \U1F600
1087 test utf-9.6.2 {Tcl_UtfAtIndex: index = 0, Emoji} utf16 {
1088 string range \U1F600G 0 0
1089 } \U1F600
1090 test utf-9.7.0 {Tcl_UtfAtIndex: index > 0, Emoji} {Uesc ucs2} {
1091 string range \U1F600G 1 1
1092 } G
1093 test utf-9.7.1 {Tcl_UtfAtIndex: index > 0, Emoji} utf32 {
1094 string range \U1F600G 1 1
1095 } G
1096 test utf-9.7.2 {Tcl_UtfAtIndex: index > 0, Emoji} utf16 {
1097 string range \U1F600G 1 1
1098 } {}
1099 test utf-9.8.0 {Tcl_UtfAtIndex: index > 0, Emoji} {Uesc ucs2} {
1100 string range \U1F600G 2 2
1101 } {}
1102 test utf-9.8.1 {Tcl_UtfAtIndex: index > 0, Emoji} utf32 {
1103 string range \U1F600G 2 2
1104 } {}
1105 test utf-9.8.2 {Tcl_UtfAtIndex: index > 0, Emoji} utf16 {
1106 string range \U1F600G 2 2
1107 } G
1108
1109 test utf-10.1 {Tcl_UtfBackslash: dst == NULL} {
1110 set x \n
1111 } {
1112 }
1113 test utf-10.2 {Tcl_UtfBackslash: \u subst} testbytestring {
1114 expr {"\uA2" eq [testbytestring \xC2\xA2]}
1115 } 1
1116 test utf-10.3 {Tcl_UtfBackslash: longer \u subst} testbytestring {
1117 expr {"\u4E21" eq [testbytestring \xE4\xB8\xA1]}
1118 } 1
1119 test utf-10.4 {Tcl_UtfBackslash: stops at first non-hex} testbytestring {
1120 expr {"\u4E2k" eq "[testbytestring \xD3\xA2]k"}
1121 } 1
1122 test utf-10.5 {Tcl_UtfBackslash: stops after 4 hex chars} testbytestring {
1123 expr {"\u4E216" eq "[testbytestring \xE4\xB8\xA1]6"}
1124 } 1
1125 test utf-10.6 {Tcl_UtfBackslash: stops after 5 hex chars} {fullutf testbytestring} {
1126 expr {"\U1E2165" eq "[testbytestring \xF0\x9E\x88\x96]5"}
1127 } 1
1128 test utf-10.7 {Tcl_UtfBackslash: stops after 6 hex chars} {fullutf testbytestring} {
1129 expr {"\U10E2165" eq "[testbytestring \xF4\x8E\x88\x96]5"}
1130 } 1
1131
1132 proc bsCheck {char num {constraints {}}} {
1133 global errNum
1134 test utf-10.$errNum {backslash substitution} $constraints {
1135 scan $char %c value
1136 set value
1137 } $num
1138 incr errNum
1139 }
1140 set errNum 8
1141 bsCheck \b 8
1142 bsCheck \e 101
1143 bsCheck \f 12
1144 bsCheck \n 10
1145 bsCheck \r 13
1146 bsCheck \t 9
1147 bsCheck \v 11
1148 bsCheck \{ 123
1149 bsCheck \} 125
1150 bsCheck \[ 91
1151 bsCheck \] 93
1152 bsCheck \$ 36
1153 bsCheck \ 32
1154 bsCheck \; 59
1155 bsCheck \\ 92
1156 bsCheck \Ca 67
1157 bsCheck \Ma 77
1158 bsCheck \CMa 67
1159 # prior to 8.3, this returned 8, as \8 as accepted as an
1160 # octal value - but it isn't! [Bug: 3975]
1161 bsCheck \8a 56
1162 bsCheck \14 12
1163 bsCheck \141 97
1164 bsCheck b\0 98
1165 bsCheck \x 120
1166 bsCheck \xa 10
1167 bsCheck \xA 10
1168 bsCheck \x41 65
1169 bsCheck \x541 65 pre388 ;# == \x41
1170 bsCheck \x541 84 !pre388 ;# == \x54 1
1171 bsCheck \u 117
1172 bsCheck \uk 117
1173 bsCheck \u41 65
1174 bsCheck \ua 10
1175 bsCheck \uA 10
1176 bsCheck \340 224
1177 bsCheck \uA1 161
1178 bsCheck \u4E21 20001
1179 bsCheck \741 225 pre388 ;# == \341
1180 bsCheck \741 60 !pre388 ;# == \74 1
1181 bsCheck \U 85
1182 bsCheck \Uk 85
1183 bsCheck \U41 65 Uesc
1184 bsCheck \Ua 10 Uesc
1185 bsCheck \UA 10 Uesc
1186 bsCheck \UA1 161 Uesc
1187 bsCheck \U4E21 20001 Uesc
1188 bsCheck \U004E21 20001 Uesc
1189 bsCheck \U00004E21 20001 Uesc
1190 bsCheck \U0000004E21 78 Uesc
1191 bsCheck \U00110000 69632 fullutf
1192 bsCheck \U01100000 69632 fullutf
1193 bsCheck \U11000000 69632 fullutf
1194 bsCheck \U0010FFFF 1114111 fullutf
1195 bsCheck \U010FFFF0 1114111 fullutf
1196 bsCheck \U10FFFF00 1114111 fullutf
1197 bsCheck \UFFFFFFFF 1048575 fullutf
1198
1199 test utf-11.1 {Tcl_UtfToUpper} {
1200 string toupper {}
1201 } {}
1202 test utf-11.2 {Tcl_UtfToUpper} {
1203 string toupper abc
1204 } ABC
1205 test utf-11.3 {Tcl_UtfToUpper} {
1206 string toupper \xE3gh
1207 } \xC3GH
1208 test utf-11.4 {Tcl_UtfToUpper} {
1209 string toupper \u01E3gh
1210 } \u01E2GH
1211 test utf-11.5 {Tcl_UtfToUpper Georgian (new in Unicode 11)} {
1212 string toupper \u10D0\u1C90
1213 } \u1C90\u1C90
1214 test utf-11.6 {Tcl_UtfToUpper beyond U+FFFF} fullutf {
1215 string toupper \U10428
1216 } \U10400
1217 test utf-11.7 {Tcl_UtfToUpper beyond U+FFFF} fullutf {
1218 string toupper \uD801\uDC28
1219 } \uD801\uDC00
1220 test utf-11.8 {Tcl_UtfToUpper low/high surrogate)} {
1221 string toupper \uDC24\uD824
1222 } \uDC24\uD824
1223
1224 test utf-12.1 {Tcl_UtfToLower} {
1225 string tolower {}
1226 } {}
1227 test utf-12.2 {Tcl_UtfToLower} {
1228 string tolower ABC
1229 } abc
1230 test utf-12.3 {Tcl_UtfToLower} {
1231 string tolower \xC3GH
1232 } \xE3gh
1233 test utf-12.4 {Tcl_UtfToLower} {
1234 string tolower \u01E2GH
1235 } \u01E3gh
1236 test utf-12.5 {Tcl_UtfToLower Georgian (new in Unicode 11)} {
1237 string tolower \u10D0\u1C90
1238 } \u10D0\u10D0
1239 test utf-12.6 {Tcl_UtfToLower low/high surrogate)} {
1240 string tolower \uDC24\uD824
1241 } \uDC24\uD824
1242 test utf-12.7 {Tcl_UtfToLower beyond U+FFFF} fullutf {
1243 string tolower \U10400
1244 } \U10428
1245 test utf-12.8 {Tcl_UtfToLower beyond U+FFFF} fullutf {
1246 string tolower \uD801\uDC00
1247 } \uD801\uDC28
1248
1249 test utf-13.1 {Tcl_UtfToTitle} {
1250 string totitle {}
1251 } {}
1252 test utf-13.2 {Tcl_UtfToTitle} {
1253 string totitle abc
1254 } Abc
1255 test utf-13.3 {Tcl_UtfToTitle} {
1256 string totitle \xE3GH
1257 } \xC3gh
1258 test utf-13.4 {Tcl_UtfToTitle} {
1259 string totitle \u01F3AB
1260 } \u01F2ab
1261 test utf-13.5 {Tcl_UtfToTitle Georgian (new in Unicode 11)} {
1262 string totitle \u10D0\u1C90
1263 } \u10D0\u1C90
1264 test utf-13.6 {Tcl_UtfToTitle Georgian (new in Unicode 11)} {
1265 string totitle \u1C90\u10D0
1266 } \u1C90\u10D0
1267 test utf-13.7 {Tcl_UtfToTitle low/high surrogate)} {
1268 string totitle \uDC24\uD824
1269 } \uDC24\uD824
1270 test utf-13.8 {Tcl_UtfToTitle beyond U+FFFF} fullutf {
1271 string totitle \U10428\U10400
1272 } \U10400\U10428
1273 test utf-13.9 {Tcl_UtfToTitle beyond U+FFFF} fullutf {
1274 string totitle \uD801\uDC28\uD801\uDC00
1275 } \uD801\uDC00\uD801\uDC28
1276
1277 test utf-14.1 {Tcl_UtfNcasecmp} {
1278 string compare -nocase a b
1279 } -1
1280 test utf-14.2 {Tcl_UtfNcasecmp} {
1281 string compare -nocase b a
1282 } 1
1283 test utf-14.3 {Tcl_UtfNcasecmp} {
1284 string compare -nocase B a
1285 } 1
1286 test utf-14.4 {Tcl_UtfNcasecmp} {
1287 string compare -nocase aBcB abca
1288 } 1
1289
1290 test utf-15.1 {Tcl_UniCharToUpper, negative delta} {
1291 string toupper aA
1292 } AA
1293 test utf-15.2 {Tcl_UniCharToUpper, positive delta} {
1294 string toupper \u0178\xFF
1295 } \u0178\u0178
1296 test utf-15.3 {Tcl_UniCharToUpper, no delta} {
1297 string toupper !
1298 } !
1299
1300 test utf-16.1 {Tcl_UniCharToLower, negative delta} {
1301 string tolower aA
1302 } aa
1303 test utf-16.2 {Tcl_UniCharToLower, positive delta} {
1304 string tolower \u0178\xFF\uA78D\u01C5
1305 } \xFF\xFF\u0265\u01C6
1306
1307 test utf-17.1 {Tcl_UniCharToLower, no delta} {
1308 string tolower !
1309 } !
1310
1311 test utf-18.1 {Tcl_UniCharToTitle, add one for title} {
1312 string totitle \u01C4
1313 } \u01C5
1314 test utf-18.2 {Tcl_UniCharToTitle, subtract one for title} {
1315 string totitle \u01C6
1316 } \u01C5
1317 test utf-18.3 {Tcl_UniCharToTitle, subtract delta for title (positive)} {
1318 string totitle \u017F
1319 } \x53
1320 test utf-18.4 {Tcl_UniCharToTitle, subtract delta for title (negative)} {
1321 string totitle \xFF
1322 } \u0178
1323 test utf-18.5 {Tcl_UniCharToTitle, no delta} {
1324 string totitle !
1325 } !
1326
1327 test utf-19.1 {TclUniCharLen} -body {
1328 list [regexp \\d abc456def foo] $foo
1329 } -cleanup {
1330 unset -nocomplain foo
1331 } -result {1 4}
1332
1333 test utf-20.1 {TclUniCharNcmp} utf32 {
1334 string compare [string range [format %c 0xFFFF] 0 0] [string range [format %c 0x10000] 0 0]
1335 } -1
1336 test utf-20.2 {[4c591fa487] TclUniCharNcmp/TclUtfNcmp} {
1337 set one [format %c 0xFFFF]
1338 set two [format %c 0x10000]
1339 set first [string compare $one $two]
1340 string range $one 0 0
1341 string range $two 0 0
1342 set second [string compare $one $two]
1343 expr {($first == $second) ? "agree" : "disagree"}
1344 } agree
1345
1346 test utf-21.1 {Tcl_UniCharIsAlnum} {
1347 # this returns 1 with Unicode 7 compliance
1348 string is alnum \u1040\u021F\u0220
1349 } 1
1350 test utf-21.2 {unicode alnum char in regc_locale.c} {
1351 # this returns 1 with Unicode 7 compliance
1352 list [regexp {^[[:alnum:]]+$} \u1040\u021F\u0220] [regexp {^\w+$} \u1040\u021F\u0220_\u203F\u2040\u2054\uFE33\uFE34\uFE4D\uFE4E\uFE4F\uFF3F]
1353 } {1 1}
1354 test utf-21.3 {unicode print char in regc_locale.c} {
1355 # this returns 1 with Unicode 7 compliance
1356 regexp {^[[:print:]]+$} \uFBC1
1357 } 1
1358 test utf-21.4 {Tcl_UniCharIsGraph} {
1359 # [Bug 3464428]
1360 string is graph \u0120
1361 } 1
1362 test utf-21.5 {unicode graph char in regc_locale.c} {
1363 # [Bug 3464428]
1364 regexp {^[[:graph:]]+$} \u0120
1365 } 1
1366 test utf-21.6 {Tcl_UniCharIsGraph} {
1367 # [Bug 3464428]
1368 string is graph \xA0
1369 } 0
1370 test utf-21.7 {unicode graph char in regc_locale.c} {
1371 # [Bug 3464428]
1372 regexp {[[:graph:]]} \x20\xA0\u2028\u2029
1373 } 0
1374 test utf-21.8 {Tcl_UniCharIsPrint} {
1375 # [Bug 3464428]
1376 string is print \x09
1377 } 0
1378 test utf-21.9 {unicode print char in regc_locale.c} {
1379 # [Bug 3464428]
1380 regexp {[[:print:]]} \x09
1381 } 0
1382 test utf-21.10 {unicode print char in regc_locale.c} {
1383 # [Bug 3464428]
1384 regexp {[[:print:]]} \x09
1385 } 0
1386 test utf-21.11 {Tcl_UniCharIsControl} {
1387 # [Bug 3464428]
1388 string is control \x00\x1F\xAD\u0605\u061C\u180E\u2066\uFEFF
1389 } 1
1390 test utf-21.12 {unicode control char in regc_locale.c} {
1391 # [Bug 3464428], [Bug a876646efe]
1392 regexp {^[[:cntrl:]]*$} \x00\x1F\xAD\u0605\u061C\u180E\u2066\uFEFF
1393 } 1
1394
1395 test utf-22.1 {Tcl_UniCharIsWordChar} {
1396 string wordend "xyz123_bar fg" 0
1397 } 10
1398 test utf-22.2 {Tcl_UniCharIsWordChar} {
1399 string wordend "x\u5080z123_bar\u203C fg" 0
1400 } 10
1401
1402 test utf-23.1 {Tcl_UniCharIsAlpha} {
1403 # this returns 1 with Unicode 7 compliance
1404 string is alpha \u021F\u0220\u037F\u052F
1405 } 1
1406 test utf-23.2 {unicode alpha char in regc_locale.c} {
1407 # this returns 1 with Unicode 7 compliance
1408 regexp {^[[:alpha:]]+$} \u021F\u0220\u037F\u052F
1409 } 1
1410
1411 test utf-24.1 {Tcl_UniCharIsDigit} {
1412 # this returns 1 with Unicode 7 compliance
1413 string is digit \u1040\uABF0
1414 } 1
1415 test utf-24.2 {unicode digit char in regc_locale.c} {
1416 # this returns 1 with Unicode 7 compliance
1417 list [regexp {^[[:digit:]]+$} \u1040\uABF0] [regexp {^\d+$} \u1040\uABF0]
1418 } {1 1}
1419
1420 test utf-24.3 {Tcl_UniCharIsSpace} {
1421 # this returns 1 with Unicode 7 compliance
1422 string is space \u1680\u180E\u202F
1423 } 1
1424 test utf-24.4 {unicode space char in regc_locale.c} {
1425 # this returns 1 with Unicode 7 compliance
1426 list [regexp {^[[:space:]]+$} \u1680\u180E\u202F] [regexp {^\s+$} \u1680\u180E\u202F]
1427 } {1 1}
1428 test utf-24.5 {Tcl_UniCharIsSpace} tip413 {
1429 # this returns 1 with Unicode 7/TIP 413 compliance
1430 string is space \x85\u1680\u180E\u200B\u202F\u2060
1431 } 1
1432 test utf-24.6 {unicode space char in regc_locale.c} tip413 {
1433 # this returns 1 with Unicode 7/TIP 413 compliance
1434 list [regexp {^[[:space:]]+$} \x85\u1680\u180E\u200B\u202F\u2060] [regexp {^\s+$} \x85\u1680\u180E\u200B\u202F\u2060]
1435 } {1 1}
1436
1437 proc UniCharCaseCmpTest {order one two {constraints {}}} {
1438 variable count
1439 test utf-25.$count {Tcl_UniCharNcasecmp} -setup {
1440 testobj freeallvars
1441 } -constraints [linsert $constraints 0 teststringobj] -cleanup {
1442 testobj freeallvars
1443 } -body {
1444 teststringobj set 1 $one
1445 teststringobj set 2 $two
1446 teststringobj getunicode 1
1447 teststringobj getunicode 2
1448 set result [string compare -nocase [teststringobj get 1] [teststringobj get 2]]
1449 if {$result eq [string map {< -1 = 0 > 1} $order]} {
1450 set result ok
1451 } else {
1452 set result "'$one' should be $order '$two' (no case)"
1453 }
1454 set result
1455 } -result ok
1456 incr count
1457 }
1458 variable count 1
1459 UniCharCaseCmpTest < a b
1460 UniCharCaseCmpTest > b a
1461 UniCharCaseCmpTest > B a
1462 UniCharCaseCmpTest > aBcB abca
1463 UniCharCaseCmpTest < \uFFFF [format %c 0x10000] utf32
1464 UniCharCaseCmpTest < \uFFFF \U10000 utf32
1465 UniCharCaseCmpTest > [format %c 0x10000] \uFFFF utf32
1466 UniCharCaseCmpTest > \U10000 \uFFFF utf32
1467
1468
1469 test utf-26.1 {Tcl_UniCharDString} -setup {
1470 testobj freeallvars
1471 } -constraints {teststringobj testbytestring} -cleanup {
1472 testobj freeallvars
1473 } -body {
1474 teststringobj set 1 foo
1475 teststringobj getunicode 1
1476 teststringobj append 1 [testbytestring barsoom\xF2\xC2\x80] 10
1477 scan [string index [teststringobj get 1] 11] %c
1478 } -result 128
1479
1480 unset count
1481 rename UniCharCaseCmpTest {}
1482
1483 proc GetUniCharTest {s index result} {
1484 variable count
1485 # Use quotes, not {} so test output shows exact string on error
1486 test getunichar-1.$count "Tcl_GetUniChar $s $index" \
1487 -constraints testgetunichar \
1488 -body "testgetunichar $s $index" \
1489 -result $result
1490 incr count
1491 }
1492 variable count 1
1493 set errorIndicator [expr 0xFFFD]; # Decimalize U+FFFD
1494 GetUniCharTest abcd -2 $errorIndicator
1495 GetUniCharTest abcd -1 $errorIndicator
1496 GetUniCharTest abcd 0 97 ;# a -> ASCII 97
1497 GetUniCharTest abcd 3 100
1498 GetUniCharTest abcd 4 $errorIndicator
1499 GetUniCharTest abcd 1000 $errorIndicator
1500
1501 GetUniCharTest \xe0bc\xe1 -2 $errorIndicator
1502 GetUniCharTest \xe0bc\xe1 -1 $errorIndicator
1503 GetUniCharTest \xe0bc\xe1 0 224 ;# \xe0 == 224
1504 GetUniCharTest \xe0bc\xe1 3 225
1505 GetUniCharTest \xe0bc\xe1 4 $errorIndicator
1506 GetUniCharTest \xe0bc\xe1 1000 $errorIndicator
1507
1508 unset count
1509 rename GetUniCharTest ""
1510
1511 # cleanup
1512 ::tcltest::cleanupTests
1513 return
1514
1515 # Local Variables:
1516 # mode: tcl
1517 # End: