summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/stringObj.test162
1 files changed, 92 insertions, 70 deletions
diff --git a/tests/stringObj.test b/tests/stringObj.test
index 49af6e4..3ea2573 100644
--- a/tests/stringObj.test
+++ b/tests/stringObj.test
@@ -12,7 +12,7 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: stringObj.test,v 1.5 1999/06/15 03:22:31 hershey Exp $
+# RCS: @(#) $Id: stringObj.test,v 1.6 1999/06/15 22:06:18 hershey Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
source [file join [pwd] [file dirname [info script]] defs.tcl]
@@ -165,20 +165,30 @@ test stringObj-6.8 {Tcl_AppendStringsToObj procedure, object totally empty} {
list [teststringobj length2 1] [teststringobj get 1]
} {0 {}}
-test stringObj-7.1 {ConvertToStringType procedure} {
+test stringObj-7.1 {SetStringFromAny procedure} {
testobj freeallvars
teststringobj set2 1 [list a b]
teststringobj append 1 x -1
list [teststringobj length 1] [teststringobj length2 1] \
[teststringobj get 1]
} {4 8 {a bx}}
-test stringObj-7.2 {ConvertToStringType procedure, null object} {
+test stringObj-7.2 {SetStringFromAny procedure, null object} {
testobj freeallvars
testobj newobj 1
teststringobj appendstrings 1 {}
list [teststringobj length 1] [teststringobj length2 1] \
[teststringobj get 1]
} {0 0 {}}
+test stringObj-7.3 {SetStringFromAny called with non-string obj} {
+ set x 2345
+ list [incr x] [testobj objtype $x] [string index $x end] \
+ [testobj objtype $x]
+} {2346 int 6 string}
+test stringObj-7.4 {SetStringFromAny called with string obj} {
+ set x "abcdef"
+ list [string length $x] [testobj objtype $x] \
+ [string length $x] [testobj objtype $x]
+} {6 string 6 string}
test stringObj-8.1 {DupStringInternalRep procedure} {
testobj freeallvars
@@ -186,31 +196,32 @@ test stringObj-8.1 {DupStringInternalRep procedure} {
teststringobj append 1 abcde -1
testobj duplicate 1 2
list [teststringobj length 1] [teststringobj length2 1] \
+ [teststringobj ualloc 1] [teststringobj get 1] \
[teststringobj length 2] [teststringobj length2 2] \
- [teststringobj get 2]
-} {5 10 5 5 abcde}
-test string-8.2 {DupUnicodeInternalRep, mixed width chars} {testobj} {
+ [teststringobj ualloc 2] [teststringobj get 2]
+} {5 10 0 abcde 5 5 0 abcde}
+test stringObj-8.2 {DupUnicodeInternalRep, mixed width chars} {
set x abcï¿®ghi
string length $x
set y $x
list [testobj objtype $x] [testobj objtype $y] [append x "®¿ï"] \
[set y] [testobj objtype $x] [testobj objtype $y]
} {string string abcï¿®ghi®¿ï abcï¿®ghi string string}
-test string-8.3 {DupUnicodeInternalRep, mixed width chars} {testobj} {
+test stringObj-8.3 {DupUnicodeInternalRep, mixed width chars} {
set x abcï¿®ghi
set y $x
string length $x
list [testobj objtype $x] [testobj objtype $y] [append x "®¿ï"] \
[set y] [testobj objtype $x] [testobj objtype $y]
} {string string abcï¿®ghi®¿ï abcï¿®ghi string string}
-test string-8.4 {DupUnicodeInternalRep, all byte-size chars} {testobj} {
+test stringObj-8.4 {DupUnicodeInternalRep, all byte-size chars} {
set x abcdefghi
string length $x
set y $x
list [testobj objtype $x] [testobj objtype $y] [append x jkl] \
[set y] [testobj objtype $x] [testobj objtype $y]
} {string string abcdefghijkl abcdefghi string string}
-test string-8.5 {DupUnicodeInternalRep, all byte-size chars} {testobj} {
+test stringObj-8.5 {DupUnicodeInternalRep, all byte-size chars} {
set x abcdefghi
set y $x
string length $x
@@ -218,14 +229,14 @@ test string-8.5 {DupUnicodeInternalRep, all byte-size chars} {testobj} {
[set y] [testobj objtype $x] [testobj objtype $y]
} {string string abcdefghijkl abcdefghi string string}
-test string-9.1 {TclAppendObjToObj, mixed src & dest} {testobj} {
+test stringObj-9.1 {TclAppendObjToObj, mixed src & dest} {
set x abcï¿®ghi
set y ®¿ï
string length $x
list [testobj objtype $x] [testobj objtype $y] [append x $y] \
[set y] [testobj objtype $x] [testobj objtype $y]
-} {string none abcï¿®ghi®¿ï ®¿ï string string}
-test string-9.2 {TclAppendObjToObj, mixed src & dest} {testobj} {
+} {string none abcï¿®ghi®¿ï ®¿ï string none}
+test stringObj-9.2 {TclAppendObjToObj, mixed src & dest} {
set x abcï¿®ghi
string length $x
list [testobj objtype $x] [append x $x] [testobj objtype $x] \
@@ -233,54 +244,54 @@ test string-9.2 {TclAppendObjToObj, mixed src & dest} {testobj} {
} {string abcï¿®ghiabcï¿®ghi string\
abcï¿®ghiabcï¿®ghiabcï¿®ghiabcï¿®ghi\
string}
-test string-9.3 {TclAppendObjToObj, mixed src & 1-byte dest} {testobj} {
+test stringObj-9.3 {TclAppendObjToObj, mixed src & 1-byte dest} {
set x abcdefghi
set y ®¿ï
string length $x
list [testobj objtype $x] [testobj objtype $y] [append x $y] \
[set y] [testobj objtype $x] [testobj objtype $y]
-} {string none abcdefghi®¿ï ®¿ï string string}
-test string-9.4 {TclAppendObjToObj, 1-byte src & dest} {testobj} {
+} {string none abcdefghi®¿ï ®¿ï string none}
+test stringObj-9.4 {TclAppendObjToObj, 1-byte src & dest} {
set x abcdefghi
set y jkl
string length $x
list [testobj objtype $x] [testobj objtype $y] [append x $y] \
[set y] [testobj objtype $x] [testobj objtype $y]
-} {string none abcdefghijkl jkl string string}
-test string-9.5 {TclAppendObjToObj, 1-byte src & dest} {testobj} {
+} {string none abcdefghijkl jkl string none}
+test stringObj-9.5 {TclAppendObjToObj, 1-byte src & dest} {
set x abcdefghi
string length $x
list [testobj objtype $x] [append x $x] [testobj objtype $x] \
[append x $x] [testobj objtype $x]
} {string abcdefghiabcdefghi string abcdefghiabcdefghiabcdefghiabcdefghi\
string}
-test string-9.6 {TclAppendObjToObj, 1-byte src & mixed dest} {testobj} {
+test stringObj-9.6 {TclAppendObjToObj, 1-byte src & mixed dest} {
set x abcï¿®ghi
set y jkl
string length $x
list [testobj objtype $x] [testobj objtype $y] [append x $y] \
[set y] [testobj objtype $x] [testobj objtype $y]
-} {string none abcï¿®ghijkl jkl string string}
-test string-9.7 {TclAppendObjToObj, integer src & dest} {testobj} {
+} {string none abcï¿®ghijkl jkl string none}
+test stringObj-9.7 {TclAppendObjToObj, integer src & dest} {
set x [expr {4 * 5}]
set y [expr {4 + 5}]
list [testobj objtype $x] [testobj objtype $y] [append x $y] \
[testobj objtype $x] [append x $y] [testobj objtype $x] \
[testobj objtype $y]
} {int int 209 string 2099 string int}
-test string-9.8 {TclAppendObjToObj, integer src & dest} {testobj} {
+test stringObj-9.8 {TclAppendObjToObj, integer src & dest} {
set x [expr {4 * 5}]
list [testobj objtype $x] [append x $x] [testobj objtype $x] \
[append x $x] [testobj objtype $x]
} {int 2020 string 20202020 string}
-test string-9.9 {TclAppendObjToObj, integer src & 1-byte dest} {testobj} {
+test stringObj-9.9 {TclAppendObjToObj, integer src & 1-byte dest} {
set x abcdefghi
set y [expr {4 + 5}]
string length $x
list [testobj objtype $x] [testobj objtype $y] [append x $y] \
[set y] [testobj objtype $x] [testobj objtype $y]
} {string int abcdefghi9 9 string int}
-test string-9.10 {TclAppendObjToObj, integer src & mixed dest} {testobj} {
+test stringObj-9.10 {TclAppendObjToObj, integer src & mixed dest} {
set x abcï¿®ghi
set y [expr {4 + 5}]
string length $x
@@ -288,71 +299,82 @@ test string-9.10 {TclAppendObjToObj, integer src & mixed dest} {testobj} {
[set y] [testobj objtype $x] [testobj objtype $y]
} {string int abcï¿®ghi9 9 string int}
-test string-10.1 {SetStringFromAny called with non-string obj} {testobj} {
- set x 2345
- list [incr x] [testobj objtype $x] [string index $x end] \
- [testobj objtype $x]
-} {2346 int 6 string}
-test string-10.2 {SetStringFromAny called with string obj} {testobj} {
+test stringObj-10.1 {Tcl_GetRange with all byte-size chars} {
set x "abcdef"
- list [string length $x] [testobj objtype $x] \
- [string length $x] [testobj objtype $x]
-} {6 string 6 string}
+ list [testobj objtype $x] [set y [string range $x 1 end-1]] \
+ [testobj objtype $x] [testobj objtype $y]
+} {none bcde string string}
+test stringObj-10.2 {Tcl_GetRange with some mixed width chars} {
+ set x "abcïïdef"
+ list [testobj objtype $x] [set y [string range $x 1 end-1]] \
+ [testobj objtype $x] [testobj objtype $y]
+} {none bcïïde string string}
+test stringObj-10.3 {Tcl_GetRange with some mixed width chars} {
+ set x "abcïïdef"
+ string length $x
+ list [testobj objtype $x] [set y [string range $x 1 end-1]] \
+ [testobj objtype $x] [testobj objtype $y]
+} {string bcïïde string string}
+test stringObj-10.4 {Tcl_GetRange with some mixed width chars} {
+ set a "ïa¿b®cï¿d®"
+ set result [list]
+ while {[string length $a] > 0} {
+ set a [string range $a 1 end-1]
+ lappend result $a
+ }
+ set result
+} {a¿b®cï¿d ¿b®cï¿ b®cï ®c {}}
-test string-11.1 {UpdateStringOfString} {testobj} {
+test stringObj-11.1 {UpdateStringOfString} {
set x 2345
list [string index $x end] [testobj objtype $x] [incr x] \
[testobj objtype $x]
} {5 string 2346 int}
-test string-12.1 {TclGetUniCharFromObj with byte-size chars} {
- string index "abcdefghi" 0
-} "a"
-test string-12.2 {TclGetUniCharFromObj with byte-size chars} {
- string index "abcdefghi" 3
-} "d"
-test string-12.3 {TclGetUniCharFromObj with byte-size chars} {
- string index "abcdefghi" end
-} "i"
-test string-12.4 {TclGetUniCharFromObj with mixed width chars} {
+test stringObj-12.1 {Tcl_GetUniChar with byte-size chars} {
+ set x "abcdefghi"
+ list [string index $x 0] [string index $x 1]
+} {a b}
+test stringObj-12.2 {Tcl_GetUniChar with byte-size chars} {
+ set x "abcdefghi"
+ list [string index $x 3] [string index $x end]
+} {d i}
+test stringObj-12.3 {Tcl_GetUniChar with byte-size chars} {
+ set x "abcdefghi"
+ list [string index $x end] [string index $x end-1]
+} {i h}
+test stringObj-12.4 {Tcl_GetUniChar with mixed width chars} {
string index "ïa¿b®c®¿dï" 0
} "ï"
-test string-12.5 {TclGetUniCharFromObj} {
- string index "ïa¿b®c®¿dï" 4
-} "®"
-test string-12.6 {TclGetUniCharFromObj} {
+test stringObj-12.5 {Tcl_GetUniChar} {
+ set x "ïa¿b®c®¿dï"
+ list [string index $x 4] [string index $x 0]
+} {® ï}
+test stringObj-12.6 {Tcl_GetUniChar} {
string index "ïa¿b®cï¿d®" end
} "®"
-test string-13.1 {TclGetUnicodeLengthFromObj with byte-size chars} {
- string length ""
-} 0
-test string-13.2 {TclGetUnicodeLengthFromObj with byte-size chars} {
+test stringObj-13.1 {Tcl_GetCharLength with byte-size chars} {
+ set a ""
+ list [string length $a] [string length $a]
+} {0 0}
+test stringObj-13.2 {Tcl_GetCharLength with byte-size chars} {
string length "a"
} 1
-test string-13.3 {TclGetUnicodeLengthFromObj with byte-size chars} {
- string length "abcdef"
-} 6
-test string-13.4 {TclGetUnicodeLengthFromObj with mixed width chars} {
+test stringObj-13.3 {Tcl_GetCharLength with byte-size chars} {
+ set a "abcdef"
+ list [string length $a] [string length $a]
+} {6 6}
+test stringObj-13.4 {Tcl_GetCharLength with mixed width chars} {
string length "®"
} 1
-test string-13.5 {TclGetUnicodeLengthFromObj with mixed width chars} {
+test stringObj-13.5 {Tcl_GetCharLength with mixed width chars} {
string length "○○"
} 6
-test string-13.6 {TclGetUnicodeLengthFromObj with mixed width chars} {
- string length "ïa¿b®cï¿d®"
-} 10
-
-test string-14.1 {TclGetRangeFromObj with all byte-size chars} {testobj} {
- set x "abcdef"
- list [testobj objtype $x] [set y [string range $x 1 end-1]] \
- [testobj objtype $x] [testobj objtype $y]
-} {none bcde string none}
-test string-14.2 {TclGetRangeFromObj with some mixed width chars} {testobj} {
- set x "abcïïdef"
- list [testobj objtype $x] [set y [string range $x 1 end-1]] \
- [testobj objtype $x] [testobj objtype $y]
-} {none bcïïde string string}
+test stringObj-13.6 {Tcl_GetCharLength with mixed width chars} {
+ set a "ïa¿b®cï¿d®"
+ list [string length $a] [string length $a]
+} {10 10}
testobj freeallvars