1 | # Commands covered: none |
---|
2 | # |
---|
3 | # This file contains tests for the procedures in tclStringObj.c |
---|
4 | # that implement the Tcl type manager for the string type. |
---|
5 | # |
---|
6 | # Sourcing this file into Tcl runs the tests and generates output for |
---|
7 | # errors. No output means no errors were found. |
---|
8 | # |
---|
9 | # Copyright (c) 1995-1997 Sun Microsystems, Inc. |
---|
10 | # Copyright (c) 1998-1999 by Scriptics Corporation. |
---|
11 | # |
---|
12 | # See the file "license.terms" for information on usage and redistribution |
---|
13 | # of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
---|
14 | # |
---|
15 | # RCS: @(#) $Id: stringObj.test,v 1.16 2004/05/19 20:15:32 dkf Exp $ |
---|
16 | |
---|
17 | if {[lsearch [namespace children] ::tcltest] == -1} { |
---|
18 | package require tcltest |
---|
19 | namespace import -force ::tcltest::* |
---|
20 | } |
---|
21 | |
---|
22 | testConstraint testobj [llength [info commands testobj]] |
---|
23 | |
---|
24 | test stringObj-1.1 {string type registration} testobj { |
---|
25 | set t [testobj types] |
---|
26 | set first [string first "string" $t] |
---|
27 | set result [expr {$first != -1}] |
---|
28 | } {1} |
---|
29 | |
---|
30 | test stringObj-2.1 {Tcl_NewStringObj} testobj { |
---|
31 | set result "" |
---|
32 | lappend result [testobj freeallvars] |
---|
33 | lappend result [teststringobj set 1 abcd] |
---|
34 | lappend result [testobj type 1] |
---|
35 | lappend result [testobj refcount 1] |
---|
36 | } {{} abcd string 2} |
---|
37 | |
---|
38 | test stringObj-3.1 {Tcl_SetStringObj, existing "empty string" object} testobj { |
---|
39 | set result "" |
---|
40 | lappend result [testobj freeallvars] |
---|
41 | lappend result [testobj newobj 1] |
---|
42 | lappend result [teststringobj set 1 xyz] ;# makes existing obj a string |
---|
43 | lappend result [testobj type 1] |
---|
44 | lappend result [testobj refcount 1] |
---|
45 | } {{} {} xyz string 2} |
---|
46 | test stringObj-3.2 {Tcl_SetStringObj, existing non-"empty string" object} testobj { |
---|
47 | set result "" |
---|
48 | lappend result [testobj freeallvars] |
---|
49 | lappend result [testintobj set 1 512] |
---|
50 | lappend result [teststringobj set 1 foo] ;# makes existing obj a string |
---|
51 | lappend result [testobj type 1] |
---|
52 | lappend result [testobj refcount 1] |
---|
53 | } {{} 512 foo string 2} |
---|
54 | |
---|
55 | test stringObj-4.1 {Tcl_SetObjLength procedure, string gets shorter} testobj { |
---|
56 | testobj freeallvars |
---|
57 | teststringobj set 1 test |
---|
58 | teststringobj setlength 1 3 |
---|
59 | list [teststringobj length 1] [teststringobj length2 1] \ |
---|
60 | [teststringobj get 1] |
---|
61 | } {3 4 tes} |
---|
62 | test stringObj-4.2 {Tcl_SetObjLength procedure, string gets longer} testobj { |
---|
63 | testobj freeallvars |
---|
64 | teststringobj set 1 abcdef |
---|
65 | teststringobj setlength 1 10 |
---|
66 | list [teststringobj length 1] [teststringobj length2 1] |
---|
67 | } {10 10} |
---|
68 | test stringObj-4.3 {Tcl_SetObjLength procedure, string gets longer} testobj { |
---|
69 | testobj freeallvars |
---|
70 | teststringobj set 1 abcdef |
---|
71 | teststringobj append 1 xyzq -1 |
---|
72 | list [teststringobj length 1] [teststringobj length2 1] \ |
---|
73 | [teststringobj get 1] |
---|
74 | } {10 20 abcdefxyzq} |
---|
75 | test stringObj-4.4 {Tcl_SetObjLength procedure, "expty string", length 0} testobj { |
---|
76 | testobj freeallvars |
---|
77 | testobj newobj 1 |
---|
78 | teststringobj setlength 1 0 |
---|
79 | list [teststringobj length2 1] [teststringobj get 1] |
---|
80 | } {0 {}} |
---|
81 | |
---|
82 | test stringObj-5.1 {Tcl_AppendToObj procedure, type conversion} testobj { |
---|
83 | testobj freeallvars |
---|
84 | testintobj set2 1 43 |
---|
85 | teststringobj append 1 xyz -1 |
---|
86 | teststringobj get 1 |
---|
87 | } {43xyz} |
---|
88 | test stringObj-5.2 {Tcl_AppendToObj procedure, length calculation} testobj { |
---|
89 | testobj freeallvars |
---|
90 | teststringobj set 1 {x y } |
---|
91 | teststringobj append 1 bbCCddEE 4 |
---|
92 | teststringobj append 1 123 -1 |
---|
93 | teststringobj get 1 |
---|
94 | } {x y bbCC123} |
---|
95 | test stringObj-5.3 {Tcl_AppendToObj procedure, reallocating space} testobj { |
---|
96 | testobj freeallvars |
---|
97 | teststringobj set 1 xyz |
---|
98 | teststringobj setlength 1 15 |
---|
99 | teststringobj setlength 1 2 |
---|
100 | set result {} |
---|
101 | teststringobj append 1 1234567890123 -1 |
---|
102 | lappend result [teststringobj length 1] [teststringobj length2 1] |
---|
103 | teststringobj setlength 1 10 |
---|
104 | teststringobj append 1 abcdef -1 |
---|
105 | lappend result [teststringobj length 1] [teststringobj length2 1] \ |
---|
106 | [teststringobj get 1] |
---|
107 | } {15 15 16 32 xy12345678abcdef} |
---|
108 | |
---|
109 | test stringObj-6.1 {Tcl_AppendStringsToObj procedure, type conversion} testobj { |
---|
110 | testobj freeallvars |
---|
111 | teststringobj set2 1 [list a b] |
---|
112 | teststringobj appendstrings 1 xyz { 1234 } foo |
---|
113 | teststringobj get 1 |
---|
114 | } {a bxyz 1234 foo} |
---|
115 | test stringObj-6.2 {Tcl_AppendStringsToObj procedure, counting space} testobj { |
---|
116 | testobj freeallvars |
---|
117 | teststringobj set 1 abc |
---|
118 | teststringobj appendstrings 1 |
---|
119 | list [teststringobj length 1] [teststringobj get 1] |
---|
120 | } {3 abc} |
---|
121 | test stringObj-6.3 {Tcl_AppendStringsToObj procedure, counting space} testobj { |
---|
122 | testobj freeallvars |
---|
123 | teststringobj set 1 abc |
---|
124 | teststringobj appendstrings 1 {} {} {} {} |
---|
125 | list [teststringobj length 1] [teststringobj get 1] |
---|
126 | } {3 abc} |
---|
127 | test stringObj-6.4 {Tcl_AppendStringsToObj procedure, counting space} testobj { |
---|
128 | testobj freeallvars |
---|
129 | teststringobj set 1 abc |
---|
130 | teststringobj appendstrings 1 { 123 } abcdefg |
---|
131 | list [teststringobj length 1] [teststringobj get 1] |
---|
132 | } {15 {abc 123 abcdefg}} |
---|
133 | test stringObj-6.5 {Tcl_AppendStringsToObj procedure, don't double space if initial string empty} testobj { |
---|
134 | testobj freeallvars |
---|
135 | testobj newobj 1 |
---|
136 | teststringobj appendstrings 1 123 abcdefg |
---|
137 | list [teststringobj length 1] [teststringobj length2 1] [teststringobj get 1] |
---|
138 | } {10 10 123abcdefg} |
---|
139 | test stringObj-6.6 {Tcl_AppendStringsToObj procedure, space reallocation} testobj { |
---|
140 | testobj freeallvars |
---|
141 | teststringobj set 1 abc |
---|
142 | teststringobj setlength 1 10 |
---|
143 | teststringobj setlength 1 2 |
---|
144 | teststringobj appendstrings 1 34567890 |
---|
145 | list [teststringobj length 1] [teststringobj length2 1] \ |
---|
146 | [teststringobj get 1] |
---|
147 | } {10 10 ab34567890} |
---|
148 | test stringObj-6.7 {Tcl_AppendStringsToObj procedure, space reallocation} testobj { |
---|
149 | testobj freeallvars |
---|
150 | teststringobj set 1 abc |
---|
151 | teststringobj setlength 1 10 |
---|
152 | teststringobj setlength 1 2 |
---|
153 | teststringobj appendstrings 1 34567890x |
---|
154 | list [teststringobj length 1] [teststringobj length2 1] \ |
---|
155 | [teststringobj get 1] |
---|
156 | } {11 22 ab34567890x} |
---|
157 | test stringObj-6.8 {Tcl_AppendStringsToObj procedure, object totally empty} testobj { |
---|
158 | testobj freeallvars |
---|
159 | testobj newobj 1 |
---|
160 | teststringobj appendstrings 1 {} |
---|
161 | list [teststringobj length2 1] [teststringobj get 1] |
---|
162 | } {0 {}} |
---|
163 | |
---|
164 | test stringObj-7.1 {SetStringFromAny procedure} testobj { |
---|
165 | testobj freeallvars |
---|
166 | teststringobj set2 1 [list a b] |
---|
167 | teststringobj append 1 x -1 |
---|
168 | list [teststringobj length 1] [teststringobj length2 1] \ |
---|
169 | [teststringobj get 1] |
---|
170 | } {4 8 {a bx}} |
---|
171 | test stringObj-7.2 {SetStringFromAny procedure, null object} testobj { |
---|
172 | testobj freeallvars |
---|
173 | testobj newobj 1 |
---|
174 | teststringobj appendstrings 1 {} |
---|
175 | list [teststringobj length 1] [teststringobj length2 1] \ |
---|
176 | [teststringobj get 1] |
---|
177 | } {0 0 {}} |
---|
178 | test stringObj-7.3 {SetStringFromAny called with non-string obj} testobj { |
---|
179 | set x 2345 |
---|
180 | list [incr x] [testobj objtype $x] [string index $x end] \ |
---|
181 | [testobj objtype $x] |
---|
182 | } {2346 int 6 string} |
---|
183 | test stringObj-7.4 {SetStringFromAny called with string obj} testobj { |
---|
184 | set x "abcdef" |
---|
185 | list [string length $x] [testobj objtype $x] \ |
---|
186 | [string length $x] [testobj objtype $x] |
---|
187 | } {6 string 6 string} |
---|
188 | |
---|
189 | test stringObj-8.1 {DupStringInternalRep procedure} testobj { |
---|
190 | testobj freeallvars |
---|
191 | teststringobj set 1 {} |
---|
192 | teststringobj append 1 abcde -1 |
---|
193 | testobj duplicate 1 2 |
---|
194 | list [teststringobj length 1] [teststringobj length2 1] \ |
---|
195 | [teststringobj ualloc 1] [teststringobj get 1] \ |
---|
196 | [teststringobj length 2] [teststringobj length2 2] \ |
---|
197 | [teststringobj ualloc 2] [teststringobj get 2] |
---|
198 | } {5 10 0 abcde 5 5 0 abcde} |
---|
199 | test stringObj-8.2 {DupUnicodeInternalRep, mixed width chars} testobj { |
---|
200 | set x abcï¿®ghi |
---|
201 | string length $x |
---|
202 | set y $x |
---|
203 | list [testobj objtype $x] [testobj objtype $y] [append x "®¿ï"] \ |
---|
204 | [set y] [testobj objtype $x] [testobj objtype $y] |
---|
205 | } {string string abcï¿®ghi®¿ï abcï¿®ghi string string} |
---|
206 | test stringObj-8.3 {DupUnicodeInternalRep, mixed width chars} testobj { |
---|
207 | set x abcï¿®ghi |
---|
208 | set y $x |
---|
209 | string length $x |
---|
210 | list [testobj objtype $x] [testobj objtype $y] [append x "®¿ï"] \ |
---|
211 | [set y] [testobj objtype $x] [testobj objtype $y] |
---|
212 | } {string string abcï¿®ghi®¿ï abcï¿®ghi string string} |
---|
213 | test stringObj-8.4 {DupUnicodeInternalRep, all byte-size chars} testobj { |
---|
214 | set x abcdefghi |
---|
215 | string length $x |
---|
216 | set y $x |
---|
217 | list [testobj objtype $x] [testobj objtype $y] [append x jkl] \ |
---|
218 | [set y] [testobj objtype $x] [testobj objtype $y] |
---|
219 | } {string string abcdefghijkl abcdefghi string string} |
---|
220 | test stringObj-8.5 {DupUnicodeInternalRep, all byte-size chars} testobj { |
---|
221 | set x abcdefghi |
---|
222 | set y $x |
---|
223 | string length $x |
---|
224 | list [testobj objtype $x] [testobj objtype $y] [append x jkl] \ |
---|
225 | [set y] [testobj objtype $x] [testobj objtype $y] |
---|
226 | } {string string abcdefghijkl abcdefghi string string} |
---|
227 | |
---|
228 | test stringObj-9.1 {TclAppendObjToObj, mixed src & dest} testobj { |
---|
229 | set x abcï¿®ghi |
---|
230 | set y ®¿ï |
---|
231 | string length $x |
---|
232 | list [testobj objtype $x] [testobj objtype $y] [append x $y] \ |
---|
233 | [set y] [testobj objtype $x] [testobj objtype $y] |
---|
234 | } {string none abcï¿®ghi®¿ï ®¿ï string none} |
---|
235 | test stringObj-9.2 {TclAppendObjToObj, mixed src & dest} testobj { |
---|
236 | set x abcï¿®ghi |
---|
237 | string length $x |
---|
238 | list [testobj objtype $x] [append x $x] [testobj objtype $x] \ |
---|
239 | [append x $x] [testobj objtype $x] |
---|
240 | } {string abcï¿®ghiabcï¿®ghi string\ |
---|
241 | abcï¿®ghiabcï¿®ghiabcï¿®ghiabcï¿®ghi\ |
---|
242 | string} |
---|
243 | test stringObj-9.3 {TclAppendObjToObj, mixed src & 1-byte dest} testobj { |
---|
244 | set x abcdefghi |
---|
245 | set y ®¿ï |
---|
246 | string length $x |
---|
247 | list [testobj objtype $x] [testobj objtype $y] [append x $y] \ |
---|
248 | [set y] [testobj objtype $x] [testobj objtype $y] |
---|
249 | } {string none abcdefghi®¿ï ®¿ï string none} |
---|
250 | test stringObj-9.4 {TclAppendObjToObj, 1-byte src & dest} testobj { |
---|
251 | set x abcdefghi |
---|
252 | set y jkl |
---|
253 | string length $x |
---|
254 | list [testobj objtype $x] [testobj objtype $y] [append x $y] \ |
---|
255 | [set y] [testobj objtype $x] [testobj objtype $y] |
---|
256 | } {string none abcdefghijkl jkl string none} |
---|
257 | test stringObj-9.5 {TclAppendObjToObj, 1-byte src & dest} testobj { |
---|
258 | set x abcdefghi |
---|
259 | string length $x |
---|
260 | list [testobj objtype $x] [append x $x] [testobj objtype $x] \ |
---|
261 | [append x $x] [testobj objtype $x] |
---|
262 | } {string abcdefghiabcdefghi string abcdefghiabcdefghiabcdefghiabcdefghi\ |
---|
263 | string} |
---|
264 | test stringObj-9.6 {TclAppendObjToObj, 1-byte src & mixed dest} testobj { |
---|
265 | set x abcï¿®ghi |
---|
266 | set y jkl |
---|
267 | string length $x |
---|
268 | list [testobj objtype $x] [testobj objtype $y] [append x $y] \ |
---|
269 | [set y] [testobj objtype $x] [testobj objtype $y] |
---|
270 | } {string none abcï¿®ghijkl jkl string none} |
---|
271 | test stringObj-9.7 {TclAppendObjToObj, integer src & dest} testobj { |
---|
272 | set x [expr {4 * 5}] |
---|
273 | set y [expr {4 + 5}] |
---|
274 | list [testobj objtype $x] [testobj objtype $y] [append x $y] \ |
---|
275 | [testobj objtype $x] [append x $y] [testobj objtype $x] \ |
---|
276 | [testobj objtype $y] |
---|
277 | } {int int 209 string 2099 string int} |
---|
278 | test stringObj-9.8 {TclAppendObjToObj, integer src & dest} testobj { |
---|
279 | set x [expr {4 * 5}] |
---|
280 | list [testobj objtype $x] [append x $x] [testobj objtype $x] \ |
---|
281 | [append x $x] [testobj objtype $x] |
---|
282 | } {int 2020 string 20202020 string} |
---|
283 | test stringObj-9.9 {TclAppendObjToObj, integer src & 1-byte dest} testobj { |
---|
284 | set x abcdefghi |
---|
285 | set y [expr {4 + 5}] |
---|
286 | string length $x |
---|
287 | list [testobj objtype $x] [testobj objtype $y] [append x $y] \ |
---|
288 | [set y] [testobj objtype $x] [testobj objtype $y] |
---|
289 | } {string int abcdefghi9 9 string int} |
---|
290 | test stringObj-9.10 {TclAppendObjToObj, integer src & mixed dest} testobj { |
---|
291 | set x abcï¿®ghi |
---|
292 | set y [expr {4 + 5}] |
---|
293 | string length $x |
---|
294 | list [testobj objtype $x] [testobj objtype $y] [append x $y] \ |
---|
295 | [set y] [testobj objtype $x] [testobj objtype $y] |
---|
296 | } {string int abcï¿®ghi9 9 string int} |
---|
297 | test stringObj-9.11 {TclAppendObjToObj, mixed src & 1-byte dest index check} testobj { |
---|
298 | # bug 2678, in <=8.2.0, the second obj (the one to append) in |
---|
299 | # Tcl_AppendObjToObj was not correctly checked to see if it was |
---|
300 | # all one byte chars, so a unicode string would be added as one |
---|
301 | # byte chars. |
---|
302 | set x abcdef |
---|
303 | set len [string length $x] |
---|
304 | set y aübåcï |
---|
305 | set len [string length $y] |
---|
306 | append x $y |
---|
307 | string length $x |
---|
308 | set q {} |
---|
309 | for {set i 0} {$i < 12} {incr i} { |
---|
310 | lappend q [string index $x $i] |
---|
311 | } |
---|
312 | set q |
---|
313 | } {a b c d e f a ü b å c ï} |
---|
314 | |
---|
315 | test stringObj-10.1 {Tcl_GetRange with all byte-size chars} testobj { |
---|
316 | set x "abcdef" |
---|
317 | list [testobj objtype $x] [set y [string range $x 1 end-1]] \ |
---|
318 | [testobj objtype $x] [testobj objtype $y] |
---|
319 | } [list none bcde string string] |
---|
320 | test stringObj-10.2 {Tcl_GetRange with some mixed width chars} testobj { |
---|
321 | # Because this test does not use \uXXXX notation below instead of |
---|
322 | # hardcoding the values, it may fail in multibyte locales. However, |
---|
323 | # we need to test that the parser produces untyped objects even when there |
---|
324 | # are high-ASCII characters in the input (like "ï"). I don't know what |
---|
325 | # else to do but inline those characters here. |
---|
326 | set x "abcïïdef" |
---|
327 | list [testobj objtype $x] [set y [string range $x 1 end-1]] \ |
---|
328 | [testobj objtype $x] [testobj objtype $y] |
---|
329 | } [list none "bc\u00EF\u00EFde" string string] |
---|
330 | test stringObj-10.3 {Tcl_GetRange with some mixed width chars} testobj { |
---|
331 | # set x "abcïïdef" |
---|
332 | # Use \uXXXX notation below instead of hardcoding the values, otherwise |
---|
333 | # the test will fail in multibyte locales. |
---|
334 | set x "abc\u00EF\u00EFdef" |
---|
335 | string length $x |
---|
336 | list [testobj objtype $x] [set y [string range $x 1 end-1]] \ |
---|
337 | [testobj objtype $x] [testobj objtype $y] |
---|
338 | } [list string "bc\u00EF\u00EFde" string string] |
---|
339 | test stringObj-10.4 {Tcl_GetRange with some mixed width chars} testobj { |
---|
340 | # set a "ïa¿b®cï¿d®" |
---|
341 | # Use \uXXXX notation below instead of hardcoding the values, otherwise |
---|
342 | # the test will fail in multibyte locales. |
---|
343 | set a "\u00EFa\u00BFb\u00AEc\u00EF\u00BFd\u00AE" |
---|
344 | set result [list] |
---|
345 | while {[string length $a] > 0} { |
---|
346 | set a [string range $a 1 end-1] |
---|
347 | lappend result $a |
---|
348 | } |
---|
349 | set result |
---|
350 | } [list a\u00BFb\u00AEc\u00EF\u00BFd \ |
---|
351 | \u00BFb\u00AEc\u00EF\u00BF \ |
---|
352 | b\u00AEc\u00EF \ |
---|
353 | \u00AEc \ |
---|
354 | {}] |
---|
355 | |
---|
356 | test stringObj-11.1 {UpdateStringOfString} testobj { |
---|
357 | set x 2345 |
---|
358 | list [string index $x end] [testobj objtype $x] [incr x] \ |
---|
359 | [testobj objtype $x] |
---|
360 | } {5 string 2346 int} |
---|
361 | |
---|
362 | test stringObj-12.1 {Tcl_GetUniChar with byte-size chars} testobj { |
---|
363 | set x "abcdefghi" |
---|
364 | list [string index $x 0] [string index $x 1] |
---|
365 | } {a b} |
---|
366 | test stringObj-12.2 {Tcl_GetUniChar with byte-size chars} testobj { |
---|
367 | set x "abcdefghi" |
---|
368 | list [string index $x 3] [string index $x end] |
---|
369 | } {d i} |
---|
370 | test stringObj-12.3 {Tcl_GetUniChar with byte-size chars} testobj { |
---|
371 | set x "abcdefghi" |
---|
372 | list [string index $x end] [string index $x end-1] |
---|
373 | } {i h} |
---|
374 | test stringObj-12.4 {Tcl_GetUniChar with mixed width chars} testobj { |
---|
375 | string index "ïa¿b®c®¿dï" 0 |
---|
376 | } "ï" |
---|
377 | test stringObj-12.5 {Tcl_GetUniChar} testobj { |
---|
378 | set x "ïa¿b®c®¿dï" |
---|
379 | list [string index $x 4] [string index $x 0] |
---|
380 | } {® ï} |
---|
381 | test stringObj-12.6 {Tcl_GetUniChar} testobj { |
---|
382 | string index "ïa¿b®cï¿d®" end |
---|
383 | } "®" |
---|
384 | |
---|
385 | test stringObj-13.1 {Tcl_GetCharLength with byte-size chars} testobj { |
---|
386 | set a "" |
---|
387 | list [string length $a] [string length $a] |
---|
388 | } {0 0} |
---|
389 | test stringObj-13.2 {Tcl_GetCharLength with byte-size chars} testobj { |
---|
390 | string length "a" |
---|
391 | } 1 |
---|
392 | test stringObj-13.3 {Tcl_GetCharLength with byte-size chars} testobj { |
---|
393 | set a "abcdef" |
---|
394 | list [string length $a] [string length $a] |
---|
395 | } {6 6} |
---|
396 | test stringObj-13.4 {Tcl_GetCharLength with mixed width chars} testobj { |
---|
397 | string length "®" |
---|
398 | } 1 |
---|
399 | test stringObj-13.5 {Tcl_GetCharLength with mixed width chars} testobj { |
---|
400 | # string length "○○" |
---|
401 | # Use \uXXXX notation below instead of hardcoding the values, otherwise |
---|
402 | # the test will fail in multibyte locales. |
---|
403 | string length "\u00EF\u00BF\u00AE\u00EF\u00BF\u00AE" |
---|
404 | } 6 |
---|
405 | test stringObj-13.6 {Tcl_GetCharLength with mixed width chars} testobj { |
---|
406 | # set a "ïa¿b®cï¿d®" |
---|
407 | # Use \uXXXX notation below instead of hardcoding the values, otherwise |
---|
408 | # the test will fail in multibyte locales. |
---|
409 | set a "\u00EFa\u00BFb\u00AEc\u00EF\u00BFd\u00AE" |
---|
410 | list [string length $a] [string length $a] |
---|
411 | } {10 10} |
---|
412 | test stringObj-13.7 {Tcl_GetCharLength with identity nulls} testobj { |
---|
413 | # SF bug #684699 |
---|
414 | string length [encoding convertfrom identity \x00] |
---|
415 | } 1 |
---|
416 | test stringObj-13.8 {Tcl_GetCharLength with identity nulls} testobj { |
---|
417 | string length [encoding convertfrom identity \x01\x00\x02] |
---|
418 | } 3 |
---|
419 | |
---|
420 | test stringObj-14.1 {Tcl_SetObjLength on pure unicode object} testobj { |
---|
421 | teststringobj set 1 foo |
---|
422 | teststringobj getunicode 1 |
---|
423 | teststringobj append 1 bar -1 |
---|
424 | teststringobj getunicode 1 |
---|
425 | teststringobj append 1 bar -1 |
---|
426 | teststringobj setlength 1 0 |
---|
427 | teststringobj append 1 bar -1 |
---|
428 | teststringobj get 1 |
---|
429 | } {bar} |
---|
430 | |
---|
431 | if {[testConstraint testobj]} { |
---|
432 | testobj freeallvars |
---|
433 | } |
---|
434 | |
---|
435 | # cleanup |
---|
436 | ::tcltest::cleanupTests |
---|
437 | return |
---|