summaryrefslogtreecommitdiffstats
path: root/tests/bigdata.test
diff options
context:
space:
mode:
Diffstat (limited to 'tests/bigdata.test')
-rw-r--r--tests/bigdata.test307
1 files changed, 266 insertions, 41 deletions
diff --git a/tests/bigdata.test b/tests/bigdata.test
index 52aa278..29ff725 100644
--- a/tests/bigdata.test
+++ b/tests/bigdata.test
@@ -193,6 +193,48 @@ bigtestRO string-first-bigdata-3 "string first - long needle" 10 -body {
} -constraints bug-a814ee5bbd
#
+# string index
+bigtestRO string-index-bigdata-1 "string index" {6 7 5 {} 5 4 {} 9 {}} -body {
+ list \
+ [string index $s 0x100000000] \
+ [string index $s 0x100000000+1] \
+ [string index $s 0x100000000-1] \
+ [string index $s 0x10000000a] \
+ [string index $s end] \
+ [string index $s end-1] \
+ [string index $s end+1] \
+ [string index $s end-0x100000000] \
+ [string index $s end-0x10000000a]
+} -setup {
+ set s [bigString 0x10000000a]
+} -cleanup {
+ unset -nocomplain s
+}
+
+#
+# string insert
+bigtestRO string-insert-bigdata-1 "string insert" 1 -body {
+ # Note insert at multiple of 10 to enable comparison against generated string
+ string equal [string insert [bigString 4294967312] 4294967310 "0123456789"] [bigString 4294967322]
+}
+bigtestRO string-insert-bigdata-2 "string insert" 1 -body {
+ string equal [string insert [bigString 4294967312] 10 "0123456789"] [bigString 4294967322]
+}
+
+#
+# string is
+bigtestRO string-is-bigdata-1 "string is" {1 0 0 4294967296} -body {
+ # TODO - add the other "is" classes
+ unset -nocomplain failat result
+ lappend result [string is alnum -failindex failat $s] [info exists failat]
+ lappend result [string is digit -failindex failat $s] $failat
+} -setup {
+ set s [bigString 0x10000000a 0x100000000]
+} -cleanup {
+ unset -nocomplain s failat
+}
+
+#
# string last
bigtestRO string-last-bigdata-1 "string last > INT_MAX" {2 -1 2147483640 11} -body {
set s [bigString 0x80000010 2]
@@ -228,36 +270,6 @@ bigtestRO string-last-bigdata-3 "string last - long needle" 0 -body {
unset -nocomplain s needle
} -constraints bug-a814ee5bbd
-bigtestRO string-index-bigdata-1 "string index" {6 7 5 {} 5 4 {} 9 {}} -body {
- list \
- [string index $s 0x100000000] \
- [string index $s 0x100000000+1] \
- [string index $s 0x100000000-1] \
- [string index $s 0x10000000a] \
- [string index $s end] \
- [string index $s end-1] \
- [string index $s end+1] \
- [string index $s end-0x100000000] \
- [string index $s end-0x10000000a]
-} -setup {
- set s [bigString 0x10000000a]
-} -cleanup {
- unset -nocomplain s
-}
-
-#
-# string is
-bigtestRO string-is-bigdata-1 "string is" {1 0 0 4294967296} -body {
- set result {}
- unset -nocomplain failat
- lappend result [string is alnum -failindex failat $s] [info exists failat]
- lappend result [string is digit -failindex failat $s] $failat
-} -setup {
- set s [bigString 0x10000000a 0x100000000]
-} -cleanup {
- unset -nocomplain s failat
-}
-
#
# string length
bigtestRO string-length-bigdata-1 {string length $s} 4294967296 -setup {
@@ -269,6 +281,9 @@ bigtestRO string-length-bigdata-1 {string length $s} 4294967296 -setup {
#
# string map
bigtestRO string-map-bigdata-1 {string map} {5 0 0 5} -body {
+ # Unset explicitly before setting to save memory as bigtestRO runs the
+ # script below twice.
+ unset -nocomplain s2
set s2 [string map {0 5 5 0} $s]
list \
[string index $s2 0] \
@@ -279,11 +294,11 @@ bigtestRO string-map-bigdata-1 {string map} {5 0 0 5} -body {
set s [bigString 0x100000000]
} -cleanup {
unset -nocomplain s s2
-}
+} -constraints takesTooLong
#
# string match
-bigtestR0 string-match-bigdata-1 {string match} {1 0 1} -body {
+bigtestRO string-match-bigdata-1 {string match} {1 0 1} -body {
list \
[string match 0*5 $s] \
[string match 0*4 $s] \
@@ -291,7 +306,7 @@ bigtestR0 string-match-bigdata-1 {string match} {1 0 1} -body {
} -setup {
set s [bigString 0x100000000]
} -cleanup {
- unset -nocomplain s pat
+ unset -nocomplain s
}
#
@@ -316,7 +331,10 @@ bigtestRO string-range-bigdata-1 "string range" {6 7 5 {} 5 4 {} 9 {}} -body {
#
# string repeat
-bigtest string-repeat-bigdata-1 "string repeat single char" {4294967296 0123456789abcdef 0123456789abcdef} -body {
+bigtest string-repeat-bigdata-1 "string repeat single char length > UINT_MAX" 4294967296 -body {
+ string length [string repeat x 0x100000000]
+}
+bigtest string-repeat-bigdata-2 "string repeat multiple char" {4294967296 0123456789abcdef 0123456789abcdef} -body {
set s [string repeat 0123456789abcdef [expr 0x100000000/16]]
list \
[string length $s] \
@@ -326,17 +344,224 @@ bigtest string-repeat-bigdata-1 "string repeat single char" {4294967296 01234567
unset -nocomplain s
}
-foreach len {0x7fffffff 0xffffffff 0x100000000} {
- set body "string length \[string repeat x $len\]"
- bigtest string-repeat-bigdata-1-$len $body $len
+#
+# string replace
+bigtestRO string-replace-bigdata-1 "string replace" {789012345 012345678 XYZ789012345 012345678XYZ} -body {
+ # Unset explicitly before setting to save memory as bigtestRO runs the
+ # script below twice.
+ unset -nocomplain result
+ lappend result [string replace $s 0 0x100000000]
+ lappend result [string replace $s end-0x100000000 end]
+ lappend result [string replace $s 0 0x100000000 XYZ]
+ lappend result [string replace $s end-0x100000000 end XYZ]
+} -setup {
+ set s [bigString 0x10000000a]
+} -cleanup {
+ unset -nocomplain s
+} -constraints bug-ad9361fd20f0
+# TODO - once above bug is fixed, add tests for large result range:
+# - replacements string is large
+# - replace in the middle - string length grows, shrinks
+# - last < first
+
+#
+# string reverse
+bigtestRO string-reverse-bigdata-1 "string reverse" {5432109876 9876543210} -body {
+ # Unset explicitly before setting to save memory as bigtestRO runs the
+ # script below twice.
+ unset -nocomplain s2 result
+ set s2 [string reverse $s]
+ list [string range $s2 0 9] [string range $s2 end-9 end]
+} -setup {
+ set s [bigString 0x10000000a]
+} -cleanup {
+ unset -nocomplain s s2
+}
+
+#
+# string tolower
+bigtestRO string-tolower-bigdata-1 "string tolower" 1 -body {
+ string equal [string tolower $s] [string repeat abcd $repts]
+} -setup {
+ set repts [expr 0x100000010/4]
+ set s [string repeat ABCD $repts]
+} -cleanup {
+ unset -nocomplain s repts
+}
+bigtestRO string-tolower-bigdata-2 "string tolower first last" {4294967312 ABCDabcdABCD 4294967312 ABCDabcdABCD 4294967312 ABCDabcdABCD} -body {
+ # Unset explicitly before setting to save memory as bigtestRO runs the
+ # script below twice.
+ unset -nocomplain s2 result
+ set s2 [string tolower $s 4 7]
+ lappend result [string length $s2] [string range $s2 0 11]
+
+ unset s2; #Explicit free to reduce total memory
+ set s2 [string tolower $s 0x100000008 0x10000000b]
+ lappend result [string length $s2] [string range $s2 0x100000004 end]
+
+ unset s2; #Explicit free to reduce total memory
+ set s2 [string tolower $s end-7 end-4]
+ lappend result [string length $s2] [string range $s2 0x100000004 end]
+} -setup {
+ set repts [expr 0x100000010/4]
+ set s [string repeat ABCD $repts]
+} -cleanup {
+ unset -nocomplain s s2 repts
}
-foreach len {0x7fffffff 0xffffffff 0x100000000} {
- break; # Skip for now
- set body "llength \[lrepeat $len x\]"
- bigtest lrepeat-bigdata-1-$len $body $len
+#
+# string totitle
+bigtestRO string-totitle-bigdata-1 "string totitle first last" {4294967312 aBcDAbcdaBcD 4294967312 aBcDAbcdaBcD 4294967312 aBcDAbcdaBcD} -body {
+ # Unset explicitly before setting to save memory as bigtestRO runs the
+ # script below twice.
+ unset -nocomplain s2 result
+ set s2 [string totitle $s 4 7]
+ lappend result [string length $s2] [string range $s2 0 11]
+ unset s2; #Explicit free to reduce total memory
+ set s2 [string totitle $s 0x100000008 0x10000000b]
+ lappend result [string length $s2] [string range $s2 0x100000004 0x10000000f]
+ unset s2; #Explicit free to reduce total memory
+ set s2 [string totitle $s end-7 end-4]
+ lappend result [string length $s2] [string range $s2 0x100000004 0x10000000f]
+} -setup {
+ set repts [expr 0x100000010/4]
+ set s [string repeat aBcD $repts]
+} -cleanup {
+ unset -nocomplain s s2 repts
}
+#
+# string toupper
+bigtestRO string-toupper-bigdata-1 "string toupper" 1 -body {
+ string equal [string toupper $s] [string repeat ABCD $repts]
+} -setup {
+ set repts [expr 0x100000010/4]
+ set s [string repeat abcd $repts]
+} -cleanup {
+ unset -nocomplain s repts
+}
+bigtestRO string-toupper-bigdata-2 "string toupper first last" {4294967312 abcdABCDabcd 4294967312 abcdABCDabcd 4294967312 abcdABCDabcd} -body {
+ # Unset explicitly before setting to save memory as bigtestRO runs the
+ # script below twice.
+ unset -nocomplain s2 result
+ set s2 [string toupper $s 4 7]
+ lappend result [string length $s2] [string range $s2 0 11]
+ unset s2; #Explicit free to reduce total memory
+ set s2 [string toupper $s 0x100000008 0x10000000b]
+ lappend result [string length $s2] [string range $s2 0x100000004 0x10000000f]
+ unset s2; #Explicit free to reduce total memory
+ set s2 [string toupper $s end-7 end-4]
+ lappend result [string length $s2] [string range $s2 0x100000004 0x10000000f]
+} -setup {
+ set repts [expr 0x100000010/4]
+ set s [string repeat abcd $repts]
+} -cleanup {
+ unset -nocomplain s s2 repts
+}
+
+#
+# string trim
+bigtestRO string-trim-bigdata-1 "string trim" {abcdyxxy yxxyabcd} -body {
+ # Unset explicitly before setting to save memory as bigtestRO runs the
+ # script below twice.
+ unset -nocomplain s2
+ set s2 [string trim $s xy]
+ list [string range $s2 0 7] [string range $s2 end-7 end]
+} -setup {
+ set repts [expr 0x100000010/8]
+ set s [string repeat xyabcdyx $repts]
+} -cleanup {
+ unset -nocomplain s s2
+}
+
+#
+# string trimleft
+bigtestRO string-trimleft-bigdata-1 "string trimleft" {abcdyxxy xyabcdyx} -body {
+ # Unset explicitly before setting to save memory as bigtestRO runs the
+ # script below twice.
+ unset -nocomplain s2
+ set s2 [string trimleft $s xy]
+ list [string range $s2 0 7] [string range $s2 end-7 end]
+} -setup {
+ set repts [expr 0x100000010/8]
+ set s [string repeat xyabcdyx $repts]
+} -cleanup {
+ unset -nocomplain s s2
+}
+
+#
+# string trimright
+bigtestRO string-trimright-bigdata-1 "string trimright" {xyabcdyx yxxyabcd} -body {
+ # Unset explicitly before setting to save memory as bigtestRO runs the
+ # script below twice.
+ unset -nocomplain s2
+ set s2 [string trimright $s xy]
+ list [string range $s2 0 7] [string range $s2 end-7 end]
+} -setup {
+ set repts [expr 0x100000010/8]
+ set s [string repeat xyabcdyx $repts]
+} -cleanup {
+ unset -nocomplain s s2
+}
+
+#
+# append
+bigtestRO append-bigdata-1 "append large to small" 1 -body {
+ set s 0123456789
+ append s [bigString 0x100000000]
+ string equal $s [bigString 0x10000000a]
+} -cleanup {
+ unset -nocomplain s
+}
+bigtest append-bigdata-2 "append small to cross UINT_MAX boundary" 1 -body {
+ append s 0123456789
+ string equal $s [bigString 4294967300]
+} -setup {
+ set s [bigString 4294967290]
+} -cleanup {
+ unset -nocomplain s
+}
+bigtest append-bigdata-3 "append small to cross UINT_MAX boundary" 1 -body {
+ set s2 ""
+ append s2 $s $s $s $s
+ string equal $s2 [bigString 4294967320]
+} -setup {
+ # Make length multiple of 4 AND 10 since the bigString pattern length is 10
+ set len [expr 4294967320/4]
+ set s [bigString $len]
+} -cleanup {
+ unset -nocomplain s
+}
+
+#
+# format
+bigtestRO format-bigdata-1 "format %s" 1 -body {
+ # Unset explicitly before setting to save memory as bigtestRO runs the
+ # script below twice.
+ unset -nocomplain s2
+ set s2 [format %s $s]
+ string equal $s $s2
+} -setup {
+ set s [bigString 0x100000000]
+} -cleanup {
+ unset -nocomplain s s2
+} -constraints bug-a550f9710b
+bigtest format-bigdata-2 "format bigstring%s" 1 -body {
+ set s [format $s X]
+ string equal $s [bigString 0x100000001 0x100000000]
+} -setup {
+ set s [bigString 0x100000000]
+ append s %s
+} -cleanup {
+ unset -nocomplain s s2
+} -constraints bug-a550f9710b
+# TODO - once above bugs fixed, add tests for width and precision
+
+# scan
+# regexp
+# regsub
+
+
# cleanup
::tcltest::cleanupTests
return