os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/tests/dstring.test
First public contribution.
1 # Commands covered: none
3 # This file contains a collection of tests for Tcl's dynamic string
4 # library procedures. Sourcing this file into Tcl runs the tests and
5 # generates output for errors. No output means no errors were found.
7 # Copyright (c) 1993 The Regents of the University of California.
8 # Copyright (c) 1994 Sun Microsystems, Inc.
9 # Copyright (c) 1998-1999 by Scriptics Corporation.
11 # See the file "license.terms" for information on usage and redistribution
12 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
14 # RCS: @(#) $Id: dstring.test,v 1.5 2000/04/10 17:18:58 ericm Exp $
16 if {[lsearch [namespace children] ::tcltest] == -1} {
17 package require tcltest
18 namespace import -force ::tcltest::*
21 if {[info commands testdstring] == {}} {
22 puts "This application hasn't been compiled with the \"testdstring\""
23 puts "command, so I can't test Tcl_DStringAppend et al."
24 ::tcltest::cleanupTests
28 test dstring-1.1 {appending and retrieving} {
30 testdstring append "abc" -1
31 list [testdstring get] [testdstring length]
33 test dstring-1.2 {appending and retrieving} {
35 testdstring append "abc" -1
36 testdstring append " xyzzy" 3
37 testdstring append " 12345" -1
38 list [testdstring get] [testdstring length]
40 test dstring-1.3 {appending and retrieving} {
42 foreach l {a b c d e f g h i j k l m n o p} {
43 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
45 list [testdstring get] [testdstring length]
46 } {{aaaaaaaaaaaaaaaaaaaaa
64 test dstring-2.1 {appending list elements} {
66 testdstring element "abc"
67 testdstring element "d e f"
68 list [testdstring get] [testdstring length]
70 test dstring-2.2 {appending list elements} {
72 testdstring element "x"
73 testdstring element "\{"
74 testdstring element "ab\}"
77 test dstring-2.3 {appending list elements} {
79 foreach l {a b c d e f g h i j k l m n o p} {
80 testdstring element $l$l$l$l$l$l$l$l$l$l$l$l$l$l$l$l$l$l$l$l$l
83 } {aaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbb ccccccccccccccccccccc ddddddddddddddddddddd eeeeeeeeeeeeeeeeeeeee fffffffffffffffffffff ggggggggggggggggggggg hhhhhhhhhhhhhhhhhhhhh iiiiiiiiiiiiiiiiiiiii jjjjjjjjjjjjjjjjjjjjj kkkkkkkkkkkkkkkkkkkkk lllllllllllllllllllll mmmmmmmmmmmmmmmmmmmmm nnnnnnnnnnnnnnnnnnnnn ooooooooooooooooooooo ppppppppppppppppppppp}
84 test dstring-2.4 {appending list elements} {
86 testdstring append "a\{" -1
87 testdstring element abc
88 testdstring append " \{" -1
89 testdstring element xyzzy
92 test dstring-2.5 {appending list elements} {
94 testdstring append " \{" -1
95 testdstring element abc
98 test dstring-2.6 {appending list elements} {
100 testdstring append " " -1
101 testdstring element abc
104 test dstring-2.7 {appending list elements} {
106 testdstring append "\\ " -1
107 testdstring element abc
110 test dstring-2.8 {appending list elements} {
112 testdstring append "x " -1
113 testdstring element abc
117 test dstring-3.1 {nested sublists} {
120 testdstring element foo
121 testdstring element bar
123 testdstring element another
125 } {{foo bar} another}
126 test dstring-3.2 {nested sublists} {
130 testdstring element abc
131 testdstring element def
134 testdstring element ghi
137 test dstring-3.3 {nested sublists} {
142 testdstring element foo
143 testdstring element foo2
146 testdstring element foo3
148 testdstring element foo4
150 } {{{{foo foo2}} foo3} foo4}
151 test dstring-3.4 {nested sublists} {
153 testdstring element before
155 testdstring element during
156 testdstring element more
158 testdstring element last
160 } {before {during more} last}
161 test dstring-3.5 {nested sublists} {
163 testdstring element "\{"
165 testdstring element first
166 testdstring element second
169 } {\{ {first second}}
171 test dstring-4.1 {truncation} {
173 testdstring append "abcdefg" -1
175 list [testdstring get] [testdstring length]
177 test dstring-4.2 {truncation} {
179 testdstring append "xyzzy" -1
181 list [testdstring get] [testdstring length]
184 test dstring-5.1 {copying to result} {
186 testdstring append xyz -1
189 test dstring-5.2 {copying to result} {
192 foreach l {a b c d e f g h i j k l m n o p} {
193 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
195 set a [testdstring result]
196 testdstring append abc -1
197 list $a [testdstring get]
198 } {{aaaaaaaaaaaaaaaaaaaaa
199 bbbbbbbbbbbbbbbbbbbbb
200 ccccccccccccccccccccc
201 ddddddddddddddddddddd
202 eeeeeeeeeeeeeeeeeeeee
203 fffffffffffffffffffff
204 ggggggggggggggggggggg
205 hhhhhhhhhhhhhhhhhhhhh
206 iiiiiiiiiiiiiiiiiiiii
207 jjjjjjjjjjjjjjjjjjjjj
208 kkkkkkkkkkkkkkkkkkkkk
209 lllllllllllllllllllll
210 mmmmmmmmmmmmmmmmmmmmm
211 nnnnnnnnnnnnnnnnnnnnn
212 ooooooooooooooooooooo
213 ppppppppppppppppppppp
216 test dstring-6.1 {Tcl_DStringGetResult} {
218 list [testdstring gresult staticsmall] [testdstring get]
220 test dstring-6.2 {Tcl_DStringGetResult} {
222 foreach l {a b c d e f g h i j k l m n o p} {
223 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
225 list [testdstring gresult staticsmall] [testdstring get]
227 test dstring-6.3 {Tcl_DStringGetResult} {
229 lappend result [testdstring gresult staticlarge]
230 testdstring append x 1
231 lappend result [testdstring get]
232 } {{} {first0 first1 first2 first3 first4 first5 first6 first7 first8 first9
233 second0 second1 second2 second3 second4 second5 second6 second7 second8 second9
234 third0 third1 third2 third3 third4 third5 third6 third7 third8 third9
235 fourth0 fourth1 fourth2 fourth3 fourth4 fourth5 fourth6 fourth7 fourth8 fourth9
236 fifth0 fifth1 fifth2 fifth3 fifth4 fifth5 fifth6 fifth7 fifth8 fifth9
237 sixth0 sixth1 sixth2 sixth3 sixth4 sixth5 sixth6 sixth7 sixth8 sixth9
238 seventh0 seventh1 seventh2 seventh3 seventh4 seventh5 seventh6 seventh7 seventh8 seventh9
240 test dstring-6.4 {Tcl_DStringGetResult} {
242 lappend result [testdstring gresult free]
243 testdstring append y 1
244 lappend result [testdstring get]
245 } {{} {This is a malloc-ed stringy}}
246 test dstring-6.5 {Tcl_DStringGetResult} {
248 lappend result [testdstring gresult special]
249 testdstring append z 1
250 lappend result [testdstring get]
251 } {{} {This is a specially-allocated stringz}}
255 ::tcltest::cleanupTests