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