diff options
author | hershey <hershey@noemail.net> | 1999-06-08 02:59:22 (GMT) |
---|---|---|
committer | hershey <hershey@noemail.net> | 1999-06-08 02:59:22 (GMT) |
commit | b526f0248a7fbb746f214d0bc34619b037f9d9f9 (patch) | |
tree | 87cee8e23f1c9f621f583c5d97e3e62979935fa9 /tests/string.test | |
parent | 98cc1fb3340965e34cc3a3f7453ffc02a344eeeb (diff) | |
download | tcl-b526f0248a7fbb746f214d0bc34619b037f9d9f9.zip tcl-b526f0248a7fbb746f214d0bc34619b037f9d9f9.tar.gz tcl-b526f0248a7fbb746f214d0bc34619b037f9d9f9.tar.bz2 |
* tests/string.test:
* generic/tclVar.c (Tcl_SetVar2Ex):
* generic/tclStringObj.c (Tcl_AppendObjToObj):
* generic/tclCmdMZ.c (Tcl_StringObjCmd): optimized the string
index, string length, string range, and append command in cases
where the object's internal rep is a bytearray. Objects with
other internal reps are converted to have the new unicode internal
rep.
* unix/Makefile.in:
* win/Makefile.in:
* win/Makefile.vc:
* tests/unicode.test:
* generic/tclInt.h:
* generic/tclObj.c:
* generic/tclUnicodeObj.c: added a new object type to store the
unicode representation of a string.
* generic/tclTestObj.c: added the objtype option to the testobj
command. This option returns the name of the type of internal rep
an object has.
FossilOrigin-Name: 8fcb19ead37123b20e22ef888f8c6c310abde293
Diffstat (limited to 'tests/string.test')
-rw-r--r-- | tests/string.test | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/tests/string.test b/tests/string.test index 01ad4bf..235dba8 100644 --- a/tests/string.test +++ b/tests/string.test @@ -11,12 +11,17 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: string.test,v 1.11 1999/06/03 18:43:30 stanton Exp $ +# RCS: @(#) $Id: string.test,v 1.12 1999/06/08 02:59:28 hershey Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { source [file join [pwd] [file dirname [info script]] defs.tcl] } +# Some tests require the testobj command + +set ::tcltest::testConfig(testobj) \ + [expr {[info commands testobj] != {}}] + test string-1.1 {error conditions} { list [catch {string gorp a b} msg] $msg } {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}} @@ -226,6 +231,18 @@ test string-5.11 {string index, unicode} { test string-5.12 {string index, unicode over char length, under byte length} { string index \334\374\334\374 6 } {} +test string-5.13 {string index, bytearray object} { + string index [binary format a5 fuz] 0 +} f +test string-5.14 {string index, bytearray object} { + string index [binary format I* {0x50515253 0x52}] 3 +} S +test string-5.15 {string index, bytearray object} { + set b [binary format I* {0x50515253 0x52}] + set i1 [string index $b end-6] + set i2 [string index $b 1] + string compare $i1 $i2 +} 0 test string-6.1 {string is, too few args} { list [catch {string is} msg] $msg @@ -585,6 +602,12 @@ test string-9.4 {string length} { test string-9.5 {string length, unicode} { string le "abcd\u7266" } 5 +test string-9.6 {string length, bytearray object} { + string length [binary format a5 foo] +} 5 +test string-9.7 {string length, bytearray object} { + string length [binary format I* {0x50515253 0x52}] +} 8 test string-10.1 {string map, too few args} { list [catch {string map} msg] $msg @@ -798,6 +821,12 @@ test string-12.17 {string range, unicode} { test string-12.18 {string range, unicode} { string range ab\u7266cdefghijklmnop 2 3 } \u7266c +test string-12.19 {string range, bytearray object} { + set b [binary format I* {0x50515253 0x52}] + set r1 [string range $b 1 end-1] + set r2 [string range $b 1 6] + string compare $r1 $r2 +} 0 test string-13.1 {string repeat} { list [catch {string repeat} msg] $msg |