os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/tests/stringComp.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.
     1 # Commands covered:  string
     2 #
     3 # This file contains a collection of tests for one or more of the Tcl
     4 # built-in commands.  Sourcing this file into Tcl runs the tests and
     5 # generates output for errors.  No output means no errors were found.
     6 #
     7 # This differs from the original string tests in that the tests call
     8 # things in procs, which uses the compiled string code instead of
     9 # the runtime parse string code.  The tests of import should match
    10 # their equivalent number in string.test.
    11 #
    12 # Copyright (c) 2001 by ActiveState Corporation.
    13 # Copyright (c) 2001 by Kevin B. Kenny.  All rights reserved.
    14 #
    15 # See the file "license.terms" for information on usage and redistribution
    16 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
    17 #
    18 # RCS: @(#) $Id: stringComp.test,v 1.6.2.1 2004/10/28 00:01:12 dgp Exp $
    19 
    20 if {[lsearch [namespace children] ::tcltest] == -1} {
    21     package require tcltest
    22     namespace import -force ::tcltest::*
    23 }
    24 
    25 # Some tests require the testobj command
    26 
    27 set ::tcltest::testConstraints(testobj) \
    28 	[expr {[info commands testobj] != {}}]
    29 
    30 test stringComp-1.1 {error conditions} {
    31     proc foo {} {string gorp a b}
    32     list [catch {foo} msg] $msg
    33 } {1 {bad option "gorp": must be bytelength, compare, equal, first, index, is, last, length, map, match, range, repeat, replace, tolower, toupper, totitle, trim, trimleft, trimright, wordend, or wordstart}}
    34 test stringComp-1.2 {error conditions} {
    35     proc foo {} {string}
    36     list [catch {foo} msg] $msg
    37 } {1 {wrong # args: should be "string option arg ?arg ...?"}}
    38 test stringComp-1.3 {error condition - undefined method during compile} {
    39     # We don't want this to complain about 'never' because it may never
    40     # be called, or string may get redefined.  This must compile OK.
    41     proc foo {str i} {
    42         if {"yes" == "no"} { string never called but complains here }
    43         string index $str $i
    44     }
    45     foo abc 0
    46 } a
    47 
    48 test stringComp-2.1 {string compare, too few args} {
    49     proc foo {} {string compare a}
    50     list [catch {foo} msg] $msg
    51 } {1 {wrong # args: should be "string compare ?-nocase? ?-length int? string1 string2"}}
    52 test stringComp-2.2 {string compare, bad args} {
    53     proc foo {} {string compare a b c}
    54     list [catch {foo} msg] $msg
    55 } {1 {bad option "a": must be -nocase or -length}}
    56 test stringComp-2.3 {string compare, bad args} {
    57     list [catch {string compare -length -nocase str1 str2} msg] $msg
    58 } {1 {expected integer but got "-nocase"}}
    59 test stringComp-2.4 {string compare, too many args} {
    60     list [catch {string compare -length 10 -nocase str1 str2 str3} msg] $msg
    61 } {1 {wrong # args: should be "string compare ?-nocase? ?-length int? string1 string2"}}
    62 test stringComp-2.5 {string compare with length unspecified} {
    63     list [catch {string compare -length 10 10} msg] $msg
    64 } {1 {wrong # args: should be "string compare ?-nocase? ?-length int? string1 string2"}}
    65 test stringComp-2.6 {string compare} {
    66     proc foo {} {string compare abcde abdef}
    67     foo
    68 } -1
    69 test stringComp-2.7 {string compare, shortest method name} {
    70     proc foo {} {string c abcde ABCDE}
    71     foo
    72 } 1
    73 test stringComp-2.8 {string compare} {
    74     proc foo {} {string compare abcde abcde}
    75     foo
    76 } 0
    77 test stringComp-2.9 {string compare with length} {
    78     proc foo {} {string compare -length 2 abcde abxyz}
    79     foo
    80 } 0
    81 test stringComp-2.10 {string compare with special index} {
    82     proc foo {} {string compare -length end-3 abcde abxyz}
    83     list [catch {foo} msg] $msg
    84 } {1 {expected integer but got "end-3"}}
    85 test stringComp-2.11 {string compare, unicode} {
    86     proc foo {} {string compare ab\u7266 ab\u7267}
    87     foo
    88 } -1
    89 test stringComp-2.12 {string compare, high bit} {
    90     # This test will fail if the underlying comparaison
    91     # is using signed chars instead of unsigned chars.
    92     # (like SunOS's default memcmp thus the compat/memcmp.c)
    93     proc foo {} {string compare "\x80" "@"}
    94     foo
    95     # Nb this tests works also in utf8 space because \x80 is
    96     # translated into a 2 or more bytelength but whose first byte has
    97     # the high bit set.
    98 } 1
    99 test stringComp-2.13 {string compare -nocase} {
   100     proc foo {} {string compare -nocase abcde abdef}
   101     foo
   102 } -1
   103 test stringComp-2.14 {string compare -nocase} {
   104     proc foo {} {string c -nocase abcde ABCDE}
   105     foo
   106 } 0
   107 test stringComp-2.15 {string compare -nocase} {
   108     proc foo {} {string compare -nocase abcde abcde}
   109     foo
   110 } 0
   111 test stringComp-2.16 {string compare -nocase with length} {
   112     proc foo {} {string compare -length 2 -nocase abcde Abxyz}
   113     foo
   114 } 0
   115 test stringComp-2.17 {string compare -nocase with length} {
   116     proc foo {} {string compare -nocase -length 3 abcde Abxyz}
   117     foo
   118 } -1
   119 test stringComp-2.18 {string compare -nocase with length <= 0} {
   120     proc foo {} {string compare -nocase -length -1 abcde AbCdEf}
   121     foo
   122 } -1
   123 test stringComp-2.19 {string compare -nocase with excessive length} {
   124     proc foo {} {string compare -nocase -length 50 AbCdEf abcde}
   125     foo
   126 } 1
   127 test stringComp-2.20 {string compare -len unicode} {
   128     # These are strings that are 6 BYTELENGTH long, but the length
   129     # shouldn't make a different because there are actually 3 CHARS long
   130     proc foo {} {string compare -len 5 \334\334\334 \334\334\374}
   131     foo
   132 } -1
   133 test stringComp-2.21 {string compare -nocase with special index} {
   134     proc foo {} {string compare -nocase -length end-3 Abcde abxyz}
   135     list [catch {foo} msg] $msg
   136 } {1 {expected integer but got "end-3"}}
   137 test stringComp-2.22 {string compare, null strings} {
   138     proc foo {} {string compare "" ""}
   139     foo
   140 } 0
   141 test stringComp-2.23 {string compare, null strings} {
   142     proc foo {} {string compare "" foo}
   143     foo
   144 } -1
   145 test stringComp-2.24 {string compare, null strings} {
   146     proc foo {} {string compare foo ""}
   147     foo
   148 } 1
   149 test stringComp-2.25 {string compare -nocase, null strings} {
   150     proc foo {} {string compare -nocase "" ""}
   151     foo
   152 } 0
   153 test stringComp-2.26 {string compare -nocase, null strings} {
   154     proc foo {} {string compare -nocase "" foo}
   155     foo
   156 } -1
   157 test stringComp-2.27 {string compare -nocase, null strings} {
   158     proc foo {} {string compare -nocase foo ""}
   159     foo
   160 } 1
   161 test stringComp-2.28 {string compare with length, unequal strings} {
   162     proc foo {} {string compare -length 2 abc abde}
   163     foo
   164 } 0
   165 test stringComp-2.29 {string compare with length, unequal strings} {
   166     proc foo {} {string compare -length 2 ab abde}
   167     foo
   168 } 0
   169 test stringComp-2.30 {string compare with NUL character vs. other ASCII} {
   170     # Be careful here, since UTF-8 rep comparison with memcmp() of
   171     # these puts chars in the wrong order
   172     proc foo {} {string compare \x00 \x01}
   173     foo
   174 } -1
   175 test stringComp-2.31 {string compare, high bit} {
   176     proc foo {} {string compare "a\x80" "a@"}
   177     foo
   178 } 1
   179 test stringComp-2.32 {string compare, high bit} {
   180     proc foo {} {string compare "a\x00" "a\x01"}
   181     foo
   182 } -1
   183 test stringComp-2.33 {string compare, high bit} {
   184     proc foo {} {string compare "\x00\x00" "\x00\x01"}
   185     foo
   186 } -1
   187 
   188 # only need a few tests on equal, since it uses the same code as
   189 # string compare, but just modifies the return output
   190 test stringComp-3.1 {string equal} {
   191     proc foo {} {string equal abcde abdef}
   192     foo
   193 } 0
   194 test stringComp-3.2 {string equal} {
   195     proc foo {} {string eq abcde ABCDE}
   196     foo
   197 } 0
   198 test stringComp-3.3 {string equal} {
   199     proc foo {} {string equal abcde abcde}
   200     foo
   201 } 1
   202 test stringComp-3.4 {string equal -nocase} {
   203     proc foo {} {string equal -nocase \334\334\334\334\374\374\374\374 \334\334\334\334\334\334\334\334}
   204     foo
   205 } 1
   206 test stringComp-3.5 {string equal -nocase} {
   207     proc foo {} {string equal -nocase abcde abdef}
   208     foo
   209 } 0
   210 test stringComp-3.6 {string equal -nocase} {
   211     proc foo {} {string eq -nocase abcde ABCDE}
   212     foo
   213 } 1
   214 test stringComp-3.7 {string equal -nocase} {
   215     proc foo {} {string equal -nocase abcde abcde}
   216     foo
   217 } 1
   218 test stringComp-3.8 {string equal with length, unequal strings} {
   219     proc foo {} {string equal -length 2 abc abde}
   220     foo
   221 } 1
   222 
   223 test stringComp-4.1 {string first, too few args} {
   224     proc foo {} {string first a}
   225     list [catch {foo} msg] $msg
   226 } {1 {wrong # args: should be "string first subString string ?startIndex?"}}
   227 test stringComp-4.2 {string first, bad args} {
   228     proc foo {} {string first a b c}
   229     list [catch {foo} msg] $msg
   230 } {1 {bad index "c": must be integer or end?-integer?}}
   231 test stringComp-4.3 {string first, too many args} {
   232     proc foo {} {string first a b 5 d}
   233     list [catch {foo} msg] $msg
   234 } {1 {wrong # args: should be "string first subString string ?startIndex?"}}
   235 test stringComp-4.4 {string first} {
   236     proc foo {} {string first bq abcdefgbcefgbqrs}
   237     foo
   238 } 12
   239 test stringComp-4.5 {string first} {
   240     proc foo {} {string fir bcd abcdefgbcefgbqrs}
   241     foo
   242 } 1
   243 test stringComp-4.6 {string first} {
   244     proc foo {} {string f b abcdefgbcefgbqrs}
   245     foo
   246 } 1
   247 test stringComp-4.7 {string first} {
   248     proc foo {} {string first xxx x123xx345xxx789xxx012}
   249     foo
   250 } 9
   251 test stringComp-4.8 {string first} {
   252     proc foo {} {string first "" x123xx345xxx789xxx012}
   253     foo
   254 } -1
   255 test stringComp-4.9 {string first, unicode} {
   256     proc foo {} {string first x abc\u7266x}
   257     foo
   258 } 4
   259 test stringComp-4.10 {string first, unicode} {
   260     proc foo {} {string first \u7266 abc\u7266x}
   261     foo
   262 } 3
   263 test stringComp-4.11 {string first, start index} {
   264     proc foo {} {string first \u7266 abc\u7266x 3}
   265     foo
   266 } 3
   267 test stringComp-4.12 {string first, start index} {
   268     proc foo {} {string first \u7266 abc\u7266x 4}
   269     foo
   270 } -1
   271 test stringComp-4.13 {string first, start index} {
   272     proc foo {} {string first \u7266 abc\u7266x end-2}
   273     foo
   274 } 3
   275 test stringComp-4.14 {string first, negative start index} {
   276     proc foo {} {string first b abc -1}
   277     foo
   278 } 1
   279 
   280 test stringComp-5.1 {string index} {
   281     proc foo {} {string index}
   282     list [catch {foo} msg] $msg
   283 } {1 {wrong # args: should be "string index string charIndex"}}
   284 test stringComp-5.2 {string index} {
   285     proc foo {} {string index a b c}
   286     list [catch {foo} msg] $msg
   287 } {1 {wrong # args: should be "string index string charIndex"}}
   288 test stringComp-5.3 {string index} {
   289     proc foo {} {string index abcde 0}
   290     foo
   291 } a
   292 test stringComp-5.4 {string index} {
   293     proc foo {} {string in abcde 4}
   294     foo
   295 } e
   296 test stringComp-5.5 {string index} {
   297     proc foo {} {string index abcde 5}
   298     foo
   299 } {}
   300 test stringComp-5.6 {string index} {
   301     proc foo {} {string index abcde -10}
   302     list [catch {foo} msg] $msg
   303 } {0 {}}
   304 test stringComp-5.7 {string index} {
   305     proc foo {} {string index a xyz}
   306     list [catch {foo} msg] $msg
   307 } {1 {bad index "xyz": must be integer or end?-integer?}}
   308 test stringComp-5.8 {string index} {
   309     proc foo {} {string index abc end}
   310     foo
   311 } c
   312 test stringComp-5.9 {string index} {
   313     proc foo {} {string index abc end-1}
   314     foo
   315 } b
   316 test stringComp-5.10 {string index, unicode} {
   317     proc foo {} {string index abc\u7266d 4}
   318     foo
   319 } d
   320 test stringComp-5.11 {string index, unicode} {
   321     proc foo {} {string index abc\u7266d 3}
   322     foo
   323 } \u7266
   324 test stringComp-5.12 {string index, unicode over char length, under byte length} {
   325     proc foo {} {string index \334\374\334\374 6}
   326     foo
   327 } {}
   328 test stringComp-5.13 {string index, bytearray object} {
   329     proc foo {} {string index [binary format a5 fuz] 0}
   330     foo
   331 } f
   332 test stringComp-5.14 {string index, bytearray object} {
   333     proc foo {} {string index [binary format I* {0x50515253 0x52}] 3}
   334     foo
   335 } S
   336 test stringComp-5.15 {string index, bytearray object} {
   337     proc foo {} {
   338 	set b [binary format I* {0x50515253 0x52}]
   339 	set i1 [string index $b end-6]
   340 	set i2 [string index $b 1]
   341 	string compare $i1 $i2
   342     }
   343     foo
   344 } 0
   345 test stringComp-5.16 {string index, bytearray object with string obj shimmering} {
   346     proc foo {} {
   347 	set str "0123456789\x00 abcdedfghi"
   348 	binary scan $str H* dump
   349 	string compare [string index $str 10] \x00
   350     }
   351     foo
   352 } 0
   353 test stringComp-5.17 {string index, bad integer} {
   354     proc foo {} {string index "abc" 08}
   355     list [catch {foo} msg] $msg
   356 } {1 {bad index "08": must be integer or end?-integer? (looks like invalid octal number)}}
   357 test stringComp-5.18 {string index, bad integer} {
   358     proc foo {} {string index "abc" end-00289}
   359     list [catch {foo} msg] $msg
   360 } {1 {bad index "end-00289": must be integer or end?-integer? (looks like invalid octal number)}}
   361 test stringComp-5.19 {string index, bytearray object out of bounds} {
   362     proc foo {} {string index [binary format I* {0x50515253 0x52}] -1}
   363     foo
   364 } {}
   365 test stringComp-5.20 {string index, bytearray object out of bounds} {
   366     proc foo {} {string index [binary format I* {0x50515253 0x52}] 20}
   367     foo
   368 } {}
   369 
   370 
   371 proc largest_int {} {
   372     # This will give us what the largest valid int on this machine is,
   373     # so we can test for overflow properly below on >32 bit systems
   374     set int 1
   375     set exp 7; # assume we get at least 8 bits
   376     while {$int > 0} { set int [expr {1 << [incr exp]}] }
   377     return [expr {$int-1}]
   378 }
   379 
   380 ## string is
   381 ## not yet bc
   382 
   383 catch {rename largest_int {}}
   384 
   385 ## string last
   386 ## not yet bc
   387 
   388 ## string length
   389 ## not yet bc
   390 test stringComp-8.1 {string bytelength} {
   391     proc foo {} {string bytelength}
   392     list [catch {foo} msg] $msg
   393 } {1 {wrong # args: should be "string bytelength string"}}
   394 test stringComp-8.2 {string bytelength} {
   395     proc foo {} {string bytelength a b}
   396     list [catch {foo} msg] $msg
   397 } {1 {wrong # args: should be "string bytelength string"}}
   398 test stringComp-8.3 {string bytelength} {
   399     proc foo {} {string bytelength "\u00c7"}
   400     foo
   401 } 2
   402 test stringComp-8.4 {string bytelength} {
   403     proc foo {} {string b ""}
   404     foo
   405 } 0
   406 
   407 ## string length
   408 ##
   409 test stringComp-9.1 {string length} {
   410     proc foo {} {string length}
   411     list [catch {foo} msg] $msg
   412 } {1 {wrong # args: should be "string length string"}}
   413 test stringComp-9.2 {string length} {
   414     proc foo {} {string length a b}
   415     list [catch {foo} msg] $msg
   416 } {1 {wrong # args: should be "string length string"}}
   417 test stringComp-9.3 {string length} {
   418     proc foo {} {string length "a little string"}
   419     foo
   420 } 15
   421 test stringComp-9.4 {string length} {
   422     proc foo {} {string le ""}
   423     foo
   424 } 0
   425 test stringComp-9.5 {string length, unicode} {
   426     proc foo {} {string le "abcd\u7266"}
   427     foo
   428 } 5
   429 test stringComp-9.6 {string length, bytearray object} {
   430     proc foo {} {string length [binary format a5 foo]}
   431     foo
   432 } 5
   433 test stringComp-9.7 {string length, bytearray object} {
   434     proc foo {} {string length [binary format I* {0x50515253 0x52}]}
   435     foo
   436 } 8
   437 
   438 ## string map
   439 ## not yet bc
   440 
   441 ## string match
   442 ##
   443 test stringComp-11.1 {string match, too few args} {
   444     proc foo {} {string match a}
   445     list [catch {foo} msg] $msg
   446 } {1 {wrong # args: should be "string match ?-nocase? pattern string"}}
   447 test stringComp-11.2 {string match, too many args} {
   448     proc foo {} {string match a b c d}
   449     list [catch {foo} msg] $msg
   450 } {1 {wrong # args: should be "string match ?-nocase? pattern string"}}
   451 test stringComp-11.3 {string match} {
   452     proc foo {} {string match abc abc}
   453     foo
   454 } 1
   455 test stringComp-11.4 {string match} {
   456     proc foo {} {string mat abc abd}
   457     foo
   458 } 0
   459 test stringComp-11.5 {string match} {
   460     proc foo {} {string match ab*c abc}
   461     foo
   462 } 1
   463 test stringComp-11.6 {string match} {
   464     proc foo {} {string match ab**c abc}
   465     foo
   466 } 1
   467 test stringComp-11.7 {string match} {
   468     proc foo {} {string match ab* abcdef}
   469     foo
   470 } 1
   471 test stringComp-11.8 {string match} {
   472     proc foo {} {string match *c abc}
   473     foo
   474 } 1
   475 test stringComp-11.9 {string match} {
   476     proc foo {} {string match *3*6*9 0123456789}
   477     foo
   478 } 1
   479 test stringComp-11.10 {string match} {
   480     proc foo {} {string match *3*6*9 01234567890}
   481     foo
   482 } 0
   483 test stringComp-11.11 {string match} {
   484     proc foo {} {string match a?c abc}
   485     foo
   486 } 1
   487 test stringComp-11.12 {string match} {
   488     proc foo {} {string match a??c abc}
   489     foo
   490 } 0
   491 test stringComp-11.13 {string match} {
   492     proc foo {} {string match ?1??4???8? 0123456789}
   493     foo
   494 } 1
   495 test stringComp-11.14 {string match} {
   496     proc foo {} {string match {[abc]bc} abc}
   497     foo
   498 } 1
   499 test stringComp-11.15 {string match} {
   500     proc foo {} {string match {a[abc]c} abc}
   501     foo
   502 } 1
   503 test stringComp-11.16 {string match} {
   504     proc foo {} {string match {a[xyz]c} abc}
   505     foo
   506 } 0
   507 test stringComp-11.17 {string match} {
   508     proc foo {} {string match {12[2-7]45} 12345}
   509     foo
   510 } 1
   511 test stringComp-11.18 {string match} {
   512     proc foo {} {string match {12[ab2-4cd]45} 12345}
   513     foo
   514 } 1
   515 test stringComp-11.19 {string match} {
   516     proc foo {} {string match {12[ab2-4cd]45} 12b45}
   517     foo
   518 } 1
   519 test stringComp-11.20 {string match} {
   520     proc foo {} {string match {12[ab2-4cd]45} 12d45}
   521     foo
   522 } 1
   523 test stringComp-11.21 {string match} {
   524     proc foo {} {string match {12[ab2-4cd]45} 12145}
   525     foo
   526 } 0
   527 test stringComp-11.22 {string match} {
   528     proc foo {} {string match {12[ab2-4cd]45} 12545}
   529     foo
   530 } 0
   531 test stringComp-11.23 {string match} {
   532     proc foo {} {string match {a\*b} a*b}
   533     foo
   534 } 1
   535 test stringComp-11.24 {string match} {
   536     proc foo {} {string match {a\*b} ab}
   537     foo
   538 } 0
   539 test stringComp-11.25 {string match} {
   540     proc foo {} {string match {a\*\?\[\]\\\x} "a*?\[\]\\x"}
   541     foo
   542 } 1
   543 test stringComp-11.26 {string match} {
   544     proc foo {} {string match ** ""}
   545     foo
   546 } 1
   547 test stringComp-11.27 {string match} {
   548     proc foo {} {string match *. ""}
   549     foo
   550 } 0
   551 test stringComp-11.28 {string match} {
   552     proc foo {} {string match "" ""}
   553     foo
   554 } 1
   555 test stringComp-11.29 {string match} {
   556     proc foo {} {string match \[a a}
   557     foo
   558 } 1
   559 test stringComp-11.30 {string match, bad args} {
   560     proc foo {} {string match - b c}
   561     list [catch {foo} msg] $msg
   562 } {1 {bad option "-": must be -nocase}}
   563 test stringComp-11.31 {string match case} {
   564     proc foo {} {string match a A}
   565     foo
   566 } 0
   567 test stringComp-11.32 {string match nocase} {
   568     proc foo {} {string match -n a A}
   569     foo
   570 } 1
   571 test stringComp-11.33 {string match nocase} {
   572     proc foo {} {string match -nocase a\334 A\374}
   573     foo
   574 } 1
   575 test stringComp-11.34 {string match nocase} {
   576     proc foo {} {string match -nocase a*f ABCDEf}
   577     foo
   578 } 1
   579 test stringComp-11.35 {string match case, false hope} {
   580     # This is true because '_' lies between the A-Z and a-z ranges
   581     proc foo {} {string match {[A-z]} _}
   582     foo
   583 } 1
   584 test stringComp-11.36 {string match nocase range} {
   585     # This is false because although '_' lies between the A-Z and a-z ranges,
   586     # we lower case the end points before checking the ranges.
   587     proc foo {} {string match -nocase {[A-z]} _}
   588     foo
   589 } 0
   590 test stringComp-11.37 {string match nocase} {
   591     proc foo {} {string match -nocase {[A-fh-Z]} g}
   592     foo
   593 } 0
   594 test stringComp-11.38 {string match case, reverse range} {
   595     proc foo {} {string match {[A-fh-Z]} g}
   596     foo
   597 } 1
   598 test stringComp-11.39 {string match, *\ case} {
   599     proc foo {} {string match {*\abc} abc}
   600     foo
   601 } 1
   602 test stringComp-11.40 {string match, *special case} {
   603     proc foo {} {string match {*[ab]} abc}
   604     foo
   605 } 0
   606 test stringComp-11.41 {string match, *special case} {
   607     proc foo {} {string match {*[ab]*} abc}
   608     foo
   609 } 1
   610 test stringComp-11.42 {string match, *special case} {
   611     proc foo {} {string match "*\\" "\\"}
   612     foo
   613 } 0
   614 test stringComp-11.43 {string match, *special case} {
   615     proc foo {} {string match "*\\\\" "\\"}
   616     foo
   617 } 1
   618 test stringComp-11.44 {string match, *special case} {
   619     proc foo {} {string match "*???" "12345"}
   620     foo
   621 } 1
   622 test stringComp-11.45 {string match, *special case} {
   623     proc foo {} {string match "*???" "12"}
   624     foo
   625 } 0
   626 test stringComp-11.46 {string match, *special case} {
   627     proc foo {} {string match "*\\*" "abc*"}
   628     foo
   629 } 1
   630 test stringComp-11.47 {string match, *special case} {
   631     proc foo {} {string match "*\\*" "*"}
   632     foo
   633 } 1
   634 test stringComp-11.48 {string match, *special case} {
   635     proc foo {} {string match "*\\*" "*abc"}
   636     foo
   637 } 0
   638 test stringComp-11.49 {string match, *special case} {
   639     proc foo {} {string match "?\\*" "a*"}
   640     foo
   641 } 1
   642 test stringComp-11.50 {string match, *special case} {
   643     proc foo {} {string match "\\" "\\"}
   644     foo
   645 } 0
   646 test stringComp-11.51 {string match; *, -nocase and UTF-8} {
   647     proc foo {} {string match -nocase [binary format I 717316707] \
   648 	    [binary format I 2028036707]}
   649     foo
   650 } 1
   651 test stringComp-11.52 {string match, null char in string} {
   652     proc foo {} {
   653 	set ptn "*abc*"
   654 	foreach elem [list "\u0000@abc" "@abc" "\u0000@abc\u0000" "blahabcblah"] {
   655 	    lappend out [string match $ptn $elem]
   656 	}
   657 	set out
   658     }
   659     foo
   660 } {1 1 1 1}
   661 test stringComp-11.53 {string match, null char in pattern} {
   662     proc foo {} {
   663 	set out ""
   664 	foreach {ptn elem} [list \
   665 		"*\u0000abc\u0000"  "\u0000abc\u0000" \
   666 		"*\u0000abc\u0000"  "\u0000abc\u0000ef" \
   667 		"*\u0000abc\u0000*" "\u0000abc\u0000ef" \
   668 		"*\u0000abc\u0000"  "@\u0000abc\u0000ef" \
   669 		"*\u0000abc\u0000*"  "@\u0000abc\u0000ef" \
   670 		] {
   671 	    lappend out [string match $ptn $elem]
   672 	}
   673 	set out
   674     }
   675     foo
   676 } {1 0 1 0 1}
   677 test stringComp-11.54 {string match, failure} {
   678     proc foo {} {
   679 	set longString ""
   680 	for {set i 0} {$i < 10} {incr i} {
   681 	    append longString "abcdefghijklmnopqrstuvwxy\u0000z01234567890123"
   682 	}
   683 	list [string match *cba* $longString] \
   684 		[string match *a*l*\u0000* $longString] \
   685 		[string match *a*l*\u0000*123 $longString] \
   686 		[string match *a*l*\u0000*123* $longString] \
   687 		[string match *a*l*\u0000*cba* $longString] \
   688 		[string match *===* $longString]
   689     }
   690     foo
   691 } {0 1 1 1 0 0}
   692 
   693 ## string range
   694 ## not yet bc
   695 
   696 ## string repeat
   697 ## not yet bc
   698 
   699 ## string replace
   700 ## not yet bc
   701 
   702 ## string tolower
   703 ## not yet bc
   704 
   705 ## string toupper
   706 ## not yet bc
   707 
   708 ## string totitle
   709 ## not yet bc
   710 
   711 ## string trim*
   712 ## not yet bc
   713 
   714 ## string word*
   715 ## not yet bc
   716 
   717 # cleanup
   718 ::tcltest::cleanupTests
   719 return