193 lines
5.9 KiB
Plaintext
193 lines
5.9 KiB
Plaintext
# Commands covered: none
|
|
#
|
|
# This file contains a collection of tests for Tcl's dynamic string
|
|
# library procedures. Sourcing this file into Tcl runs the tests and
|
|
# generates output for errors. No output means no errors were found.
|
|
#
|
|
# Copyright (c) 1993 The Regents of the University of California.
|
|
# All rights reserved.
|
|
#
|
|
# Permission is hereby granted, without written agreement and without
|
|
# license or royalty fees, to use, copy, modify, and distribute this
|
|
# software and its documentation for any purpose, provided that the
|
|
# above copyright notice and the following two paragraphs appear in
|
|
# all copies of this software.
|
|
#
|
|
# IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
|
|
# DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
|
|
# OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
|
|
# CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
#
|
|
# THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
|
|
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
# AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
|
|
# ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
|
|
# PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
|
|
#
|
|
# $Header: /user6/ouster/tcl/tests/RCS/dstring.test,v 1.3 93/10/11 09:06:01 ouster Exp $ (Berkeley)
|
|
|
|
if {[info commands testdstring] == {}} {
|
|
puts "This application hasn't been compiled with the \"testdstring\""
|
|
puts "command, so I can't test Tcl_DStringAppend et al."
|
|
return
|
|
}
|
|
|
|
if {[string compare test [info procs test]] == 1} then {source defs}
|
|
|
|
test dstring-1.1 {appending and retrieving} {
|
|
testdstring free
|
|
testdstring append "abc" -1
|
|
list [testdstring get] [testdstring length]
|
|
} {abc 3}
|
|
test dstring-1.2 {appending and retrieving} {
|
|
testdstring free
|
|
testdstring append "abc" -1
|
|
testdstring append " xyzzy" 3
|
|
testdstring append " 12345" -1
|
|
list [testdstring get] [testdstring length]
|
|
} {{abc xy 12345} 12}
|
|
test dstring-1.3 {appending and retrieving} {
|
|
testdstring free
|
|
foreach l {a b c d e f g h i j k l m n o p} {
|
|
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
|
|
}
|
|
list [testdstring get] [testdstring length]
|
|
} {{aaaaaaaaaaaaaaaaaaaaa
|
|
bbbbbbbbbbbbbbbbbbbbb
|
|
ccccccccccccccccccccc
|
|
ddddddddddddddddddddd
|
|
eeeeeeeeeeeeeeeeeeeee
|
|
fffffffffffffffffffff
|
|
ggggggggggggggggggggg
|
|
hhhhhhhhhhhhhhhhhhhhh
|
|
iiiiiiiiiiiiiiiiiiiii
|
|
jjjjjjjjjjjjjjjjjjjjj
|
|
kkkkkkkkkkkkkkkkkkkkk
|
|
lllllllllllllllllllll
|
|
mmmmmmmmmmmmmmmmmmmmm
|
|
nnnnnnnnnnnnnnnnnnnnn
|
|
ooooooooooooooooooooo
|
|
ppppppppppppppppppppp
|
|
} 352}
|
|
|
|
test dstring-2.1 {appending list elements} {
|
|
testdstring free
|
|
testdstring element "abc"
|
|
testdstring element "d e f"
|
|
list [testdstring get] [testdstring length]
|
|
} {{abc {d e f}} 11}
|
|
test dstring-2.2 {appending list elements} {
|
|
testdstring free
|
|
testdstring element "x"
|
|
testdstring element "\{"
|
|
testdstring element "ab\}"
|
|
testdstring get
|
|
} {x \{ ab\}}
|
|
test dstring-2.3 {appending list elements} {
|
|
testdstring free
|
|
foreach l {a b c d e f g h i j k l m n o p} {
|
|
testdstring element $l$l$l$l$l$l$l$l$l$l$l$l$l$l$l$l$l$l$l$l$l
|
|
}
|
|
testdstring get
|
|
} {aaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbb ccccccccccccccccccccc ddddddddddddddddddddd eeeeeeeeeeeeeeeeeeeee fffffffffffffffffffff ggggggggggggggggggggg hhhhhhhhhhhhhhhhhhhhh iiiiiiiiiiiiiiiiiiiii jjjjjjjjjjjjjjjjjjjjj kkkkkkkkkkkkkkkkkkkkk lllllllllllllllllllll mmmmmmmmmmmmmmmmmmmmm nnnnnnnnnnnnnnnnnnnnn ooooooooooooooooooooo ppppppppppppppppppppp}
|
|
|
|
test dstring-3.1 {nested sublists} {
|
|
testdstring free
|
|
testdstring start
|
|
testdstring element foo
|
|
testdstring element bar
|
|
testdstring end
|
|
testdstring element another
|
|
testdstring get
|
|
} {{foo bar} another}
|
|
test dstring-3.2 {nested sublists} {
|
|
testdstring free
|
|
testdstring start
|
|
testdstring start
|
|
testdstring element abc
|
|
testdstring element def
|
|
testdstring end
|
|
testdstring end
|
|
testdstring element ghi
|
|
testdstring get
|
|
} {{{abc def}} ghi}
|
|
test dstring-3.3 {nested sublists} {
|
|
testdstring free
|
|
testdstring start
|
|
testdstring start
|
|
testdstring start
|
|
testdstring element foo
|
|
testdstring element foo2
|
|
testdstring end
|
|
testdstring end
|
|
testdstring element foo3
|
|
testdstring end
|
|
testdstring element foo4
|
|
testdstring get
|
|
} {{{{foo foo2}} foo3} foo4}
|
|
test dstring-3.4 {nested sublists} {
|
|
testdstring free
|
|
testdstring element before
|
|
testdstring start
|
|
testdstring element during
|
|
testdstring element more
|
|
testdstring end
|
|
testdstring element last
|
|
testdstring get
|
|
} {before {during more} last}
|
|
test dstring-3.4 {nested sublists} {
|
|
testdstring free
|
|
testdstring element "\{"
|
|
testdstring start
|
|
testdstring element first
|
|
testdstring element second
|
|
testdstring end
|
|
testdstring get
|
|
} {\{ {first second}}
|
|
|
|
test dstring-4.1 {truncation} {
|
|
testdstring free
|
|
testdstring append "abcdefg" -1
|
|
testdstring trunc 3
|
|
list [testdstring get] [testdstring length]
|
|
} {abc 3}
|
|
test dstring-4.2 {truncation} {
|
|
testdstring free
|
|
testdstring append "xyzzy" -1
|
|
testdstring trunc 0
|
|
list [testdstring get] [testdstring length]
|
|
} {{} 0}
|
|
|
|
test dstring-5.1 {copying to result} {
|
|
testdstring free
|
|
testdstring append xyz -1
|
|
testdstring result
|
|
} xyz
|
|
test dstring-5.2 {copying to result} {
|
|
testdstring free
|
|
foreach l {a b c d e f g h i j k l m n o p} {
|
|
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
|
|
}
|
|
set a [testdstring result]
|
|
testdstring append abc -1
|
|
list $a [testdstring get]
|
|
} {{aaaaaaaaaaaaaaaaaaaaa
|
|
bbbbbbbbbbbbbbbbbbbbb
|
|
ccccccccccccccccccccc
|
|
ddddddddddddddddddddd
|
|
eeeeeeeeeeeeeeeeeeeee
|
|
fffffffffffffffffffff
|
|
ggggggggggggggggggggg
|
|
hhhhhhhhhhhhhhhhhhhhh
|
|
iiiiiiiiiiiiiiiiiiiii
|
|
jjjjjjjjjjjjjjjjjjjjj
|
|
kkkkkkkkkkkkkkkkkkkkk
|
|
lllllllllllllllllllll
|
|
mmmmmmmmmmmmmmmmmmmmm
|
|
nnnnnnnnnnnnnnnnnnnnn
|
|
ooooooooooooooooooooo
|
|
ppppppppppppppppppppp
|
|
} abc}
|
|
|
|
testdstring free
|