os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/tests/dstring.test
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/tests/dstring.test	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,268 @@
     1.4 +# Commands covered:  none
     1.5 +#
     1.6 +# This file contains a collection of tests for Tcl's dynamic string
     1.7 +# library procedures.  Sourcing this file into Tcl runs the tests and
     1.8 +# generates output for errors.  No output means no errors were found.
     1.9 +#
    1.10 +# Copyright (c) 1993 The Regents of the University of California.
    1.11 +# Copyright (c) 1994 Sun Microsystems, Inc.
    1.12 +# Copyright (c) 1998-1999 by Scriptics Corporation.
    1.13 +#
    1.14 +# See the file "license.terms" for information on usage and redistribution
    1.15 +# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
    1.16 +#
    1.17 +# RCS: @(#) $Id: dstring.test,v 1.5 2000/04/10 17:18:58 ericm Exp $
    1.18 +
    1.19 +if {[lsearch [namespace children] ::tcltest] == -1} {
    1.20 +    package require tcltest
    1.21 +    namespace import -force ::tcltest::*
    1.22 +}
    1.23 +
    1.24 +if {[info commands testdstring] == {}} {
    1.25 +    puts "This application hasn't been compiled with the \"testdstring\""
    1.26 +    puts "command, so I can't test Tcl_DStringAppend et al."
    1.27 +    ::tcltest::cleanupTests
    1.28 +    return
    1.29 +}
    1.30 +
    1.31 +test dstring-1.1 {appending and retrieving} {
    1.32 +    testdstring free
    1.33 +    testdstring append "abc" -1
    1.34 +    list [testdstring get] [testdstring length]
    1.35 +} {abc 3}
    1.36 +test dstring-1.2 {appending and retrieving} {
    1.37 +    testdstring free
    1.38 +    testdstring append "abc" -1
    1.39 +    testdstring append " xyzzy" 3
    1.40 +    testdstring append " 12345" -1
    1.41 +    list [testdstring get] [testdstring length]
    1.42 +} {{abc xy 12345} 12}
    1.43 +test dstring-1.3 {appending and retrieving} {
    1.44 +    testdstring free
    1.45 +    foreach l {a b c d e f g h i j k l m n o p} {
    1.46 +	testdstring append $l$l$l$l$l$l$l$l$l$l$l$l$l$l$l$l$l$l$l$l$l\n -1
    1.47 +    }
    1.48 +    list [testdstring get] [testdstring length]
    1.49 +} {{aaaaaaaaaaaaaaaaaaaaa
    1.50 +bbbbbbbbbbbbbbbbbbbbb
    1.51 +ccccccccccccccccccccc
    1.52 +ddddddddddddddddddddd
    1.53 +eeeeeeeeeeeeeeeeeeeee
    1.54 +fffffffffffffffffffff
    1.55 +ggggggggggggggggggggg
    1.56 +hhhhhhhhhhhhhhhhhhhhh
    1.57 +iiiiiiiiiiiiiiiiiiiii
    1.58 +jjjjjjjjjjjjjjjjjjjjj
    1.59 +kkkkkkkkkkkkkkkkkkkkk
    1.60 +lllllllllllllllllllll
    1.61 +mmmmmmmmmmmmmmmmmmmmm
    1.62 +nnnnnnnnnnnnnnnnnnnnn
    1.63 +ooooooooooooooooooooo
    1.64 +ppppppppppppppppppppp
    1.65 +} 352}
    1.66 +
    1.67 +test dstring-2.1 {appending list elements} {
    1.68 +    testdstring free
    1.69 +    testdstring element "abc"
    1.70 +    testdstring element "d e f"
    1.71 +    list [testdstring get] [testdstring length]
    1.72 +} {{abc {d e f}} 11}
    1.73 +test dstring-2.2 {appending list elements} {
    1.74 +    testdstring free
    1.75 +    testdstring element "x"
    1.76 +    testdstring element "\{"
    1.77 +    testdstring element "ab\}"
    1.78 +    testdstring get
    1.79 +} {x \{ ab\}}
    1.80 +test dstring-2.3 {appending list elements} {
    1.81 +    testdstring free
    1.82 +    foreach l {a b c d e f g h i j k l m n o p} {
    1.83 +	testdstring element $l$l$l$l$l$l$l$l$l$l$l$l$l$l$l$l$l$l$l$l$l
    1.84 +    }
    1.85 +    testdstring get
    1.86 +} {aaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbb ccccccccccccccccccccc ddddddddddddddddddddd eeeeeeeeeeeeeeeeeeeee fffffffffffffffffffff ggggggggggggggggggggg hhhhhhhhhhhhhhhhhhhhh iiiiiiiiiiiiiiiiiiiii jjjjjjjjjjjjjjjjjjjjj kkkkkkkkkkkkkkkkkkkkk lllllllllllllllllllll mmmmmmmmmmmmmmmmmmmmm nnnnnnnnnnnnnnnnnnnnn ooooooooooooooooooooo ppppppppppppppppppppp}
    1.87 +test dstring-2.4 {appending list elements} {
    1.88 +    testdstring free
    1.89 +    testdstring append "a\{" -1
    1.90 +    testdstring element abc
    1.91 +    testdstring append "	\{" -1
    1.92 +    testdstring element xyzzy
    1.93 +    testdstring get
    1.94 +} "a{ abc	{xyzzy"
    1.95 +test dstring-2.5 {appending list elements} {
    1.96 +    testdstring free
    1.97 +    testdstring append " \{" -1
    1.98 +    testdstring element abc
    1.99 +    testdstring get
   1.100 +} " {abc"
   1.101 +test dstring-2.6 {appending list elements} {
   1.102 +    testdstring free
   1.103 +    testdstring append " " -1
   1.104 +    testdstring element abc
   1.105 +    testdstring get
   1.106 +} { abc}
   1.107 +test dstring-2.7 {appending list elements} {
   1.108 +    testdstring free
   1.109 +    testdstring append "\\ " -1
   1.110 +    testdstring element abc
   1.111 +    testdstring get
   1.112 +} "\\  abc"
   1.113 +test dstring-2.8 {appending list elements} {
   1.114 +    testdstring free
   1.115 +    testdstring append "x " -1
   1.116 +    testdstring element abc
   1.117 +    testdstring get
   1.118 +} {x abc}
   1.119 +
   1.120 +test dstring-3.1 {nested sublists} {
   1.121 +    testdstring free
   1.122 +    testdstring start
   1.123 +    testdstring element foo
   1.124 +    testdstring element bar
   1.125 +    testdstring end
   1.126 +    testdstring element another
   1.127 +    testdstring get
   1.128 +} {{foo bar} another}
   1.129 +test dstring-3.2 {nested sublists} {
   1.130 +    testdstring free
   1.131 +    testdstring start
   1.132 +    testdstring start
   1.133 +    testdstring element abc
   1.134 +    testdstring element def
   1.135 +    testdstring end
   1.136 +    testdstring end
   1.137 +    testdstring element ghi
   1.138 +    testdstring get
   1.139 +} {{{abc def}} ghi}
   1.140 +test dstring-3.3 {nested sublists} {
   1.141 +    testdstring free
   1.142 +    testdstring start
   1.143 +    testdstring start
   1.144 +    testdstring start
   1.145 +    testdstring element foo
   1.146 +    testdstring element foo2
   1.147 +    testdstring end
   1.148 +    testdstring end
   1.149 +    testdstring element foo3
   1.150 +    testdstring end
   1.151 +    testdstring element foo4
   1.152 +    testdstring get
   1.153 +} {{{{foo foo2}} foo3} foo4}
   1.154 +test dstring-3.4 {nested sublists} {
   1.155 +    testdstring free
   1.156 +    testdstring element before
   1.157 +    testdstring start
   1.158 +    testdstring element during
   1.159 +    testdstring element more
   1.160 +    testdstring end
   1.161 +    testdstring element last
   1.162 +    testdstring get
   1.163 +} {before {during more} last}
   1.164 +test dstring-3.5 {nested sublists} {
   1.165 +    testdstring free
   1.166 +    testdstring element "\{"
   1.167 +    testdstring start
   1.168 +    testdstring element first
   1.169 +    testdstring element second
   1.170 +    testdstring end
   1.171 +    testdstring get
   1.172 +} {\{ {first second}}
   1.173 +
   1.174 +test dstring-4.1 {truncation} {
   1.175 +    testdstring free
   1.176 +    testdstring append "abcdefg" -1
   1.177 +    testdstring trunc 3
   1.178 +    list [testdstring get] [testdstring length]
   1.179 +} {abc 3}
   1.180 +test dstring-4.2 {truncation} {
   1.181 +    testdstring free
   1.182 +    testdstring append "xyzzy" -1
   1.183 +    testdstring trunc 0
   1.184 +    list [testdstring get] [testdstring length]
   1.185 +} {{} 0}
   1.186 +
   1.187 +test dstring-5.1 {copying to result} {
   1.188 +    testdstring free
   1.189 +    testdstring append xyz -1
   1.190 +    testdstring result
   1.191 +} xyz
   1.192 +test dstring-5.2 {copying to result} {
   1.193 +    testdstring free
   1.194 +    catch {unset a}
   1.195 +    foreach l {a b c d e f g h i j k l m n o p} {
   1.196 +	testdstring append $l$l$l$l$l$l$l$l$l$l$l$l$l$l$l$l$l$l$l$l$l\n -1
   1.197 +    }
   1.198 +    set a [testdstring result]
   1.199 +    testdstring append abc -1
   1.200 +    list $a [testdstring get]
   1.201 +} {{aaaaaaaaaaaaaaaaaaaaa
   1.202 +bbbbbbbbbbbbbbbbbbbbb
   1.203 +ccccccccccccccccccccc
   1.204 +ddddddddddddddddddddd
   1.205 +eeeeeeeeeeeeeeeeeeeee
   1.206 +fffffffffffffffffffff
   1.207 +ggggggggggggggggggggg
   1.208 +hhhhhhhhhhhhhhhhhhhhh
   1.209 +iiiiiiiiiiiiiiiiiiiii
   1.210 +jjjjjjjjjjjjjjjjjjjjj
   1.211 +kkkkkkkkkkkkkkkkkkkkk
   1.212 +lllllllllllllllllllll
   1.213 +mmmmmmmmmmmmmmmmmmmmm
   1.214 +nnnnnnnnnnnnnnnnnnnnn
   1.215 +ooooooooooooooooooooo
   1.216 +ppppppppppppppppppppp
   1.217 +} abc}
   1.218 +
   1.219 +test dstring-6.1 {Tcl_DStringGetResult} {
   1.220 +    testdstring free
   1.221 +    list [testdstring gresult staticsmall] [testdstring get]
   1.222 +} {{} short}
   1.223 +test dstring-6.2 {Tcl_DStringGetResult} {
   1.224 +    testdstring free
   1.225 +    foreach l {a b c d e f g h i j k l m n o p} {
   1.226 +	testdstring append $l$l$l$l$l$l$l$l$l$l$l$l$l$l$l$l$l$l$l$l$l\n -1
   1.227 +    }
   1.228 +    list [testdstring gresult staticsmall] [testdstring get]
   1.229 +} {{} short}
   1.230 +test dstring-6.3 {Tcl_DStringGetResult} {
   1.231 +    set result {}
   1.232 +    lappend result [testdstring gresult staticlarge]
   1.233 +    testdstring append x 1
   1.234 +    lappend result [testdstring get]
   1.235 +} {{} {first0 first1 first2 first3 first4 first5 first6 first7 first8 first9
   1.236 +second0 second1 second2 second3 second4 second5 second6 second7 second8 second9
   1.237 +third0 third1 third2 third3 third4 third5 third6 third7 third8 third9
   1.238 +fourth0 fourth1 fourth2 fourth3 fourth4 fourth5 fourth6 fourth7 fourth8 fourth9
   1.239 +fifth0 fifth1 fifth2 fifth3 fifth4 fifth5 fifth6 fifth7 fifth8 fifth9
   1.240 +sixth0 sixth1 sixth2 sixth3 sixth4 sixth5 sixth6 sixth7 sixth8 sixth9
   1.241 +seventh0 seventh1 seventh2 seventh3 seventh4 seventh5 seventh6 seventh7 seventh8 seventh9
   1.242 +x}}
   1.243 +test dstring-6.4 {Tcl_DStringGetResult} {
   1.244 +    set result {}
   1.245 +    lappend result [testdstring gresult free]
   1.246 +    testdstring append y 1
   1.247 +    lappend result [testdstring get]
   1.248 +} {{} {This is a malloc-ed stringy}}
   1.249 +test dstring-6.5 {Tcl_DStringGetResult} {
   1.250 +    set result {}
   1.251 +    lappend result [testdstring gresult special]
   1.252 +    testdstring append z 1
   1.253 +    lappend result [testdstring get]
   1.254 +} {{} {This is a specially-allocated stringz}}
   1.255 +
   1.256 +# cleanup
   1.257 +testdstring free
   1.258 +::tcltest::cleanupTests
   1.259 +return
   1.260 +
   1.261 +
   1.262 +
   1.263 +
   1.264 +
   1.265 +
   1.266 +
   1.267 +
   1.268 +
   1.269 +
   1.270 +
   1.271 +