diff options
author | Steve Bennett <steveb@workware.net.au> | 2013-02-15 12:26:19 +1000 |
---|---|---|
committer | Steve Bennett <steveb@workware.net.au> | 2013-02-15 12:26:19 +1000 |
commit | 9d4f23daa022c9ca012fb65606960b64b22febe5 (patch) | |
tree | 7061e0cb77c1dc72d834f8be9c216a0a5a37cba8 /tests/string.test | |
parent | c75d1adc81d7fd1b9427aec8823859b881c34468 (diff) | |
download | jimtcl-9d4f23daa022c9ca012fb65606960b64b22febe5.zip jimtcl-9d4f23daa022c9ca012fb65606960b64b22febe5.tar.gz jimtcl-9d4f23daa022c9ca012fb65606960b64b22febe5.tar.bz2 |
Fix [string replace] replacing single char
Also added some additional tests
Signed-off-by: Steve Bennett <steveb@workware.net.au>
Diffstat (limited to 'tests/string.test')
-rw-r--r-- | tests/string.test | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/string.test b/tests/string.test index 0371f74..e4d5dc5 100644 --- a/tests/string.test +++ b/tests/string.test @@ -727,6 +727,56 @@ test string-13.13 {string repeat} { string repeat \x00 3 } \x00\x00\x00 +test string-14.1 {string replace} { + list [catch {string replace} msg] $msg +} {1 {wrong # args: should be "string replace string first last ?string?"}} +test string-14.2 {string replace} { + list [catch {string replace a 1} msg] $msg +} {1 {wrong # args: should be "string replace string first last ?string?"}} +test string-14.3 {string replace} { + list [catch {string replace a 1 2 3 4} msg] $msg +} {1 {wrong # args: should be "string replace string first last ?string?"}} +test string-14.4 {string replace} { +} {} +test string-14.5 {string replace} { + string replace abcdefghijklmnop 2 14 +} {abp} +test string-14.6 {string replace} { + string replace abcdefghijklmnop 7 1000 +} {abcdefg} +test string-14.7 {string replace} { + string replace abcdefghijklmnop 10 end +} {abcdefghij} +test string-14.8 {string replace} { + string replace abcdefghijklmnop 10 9 +} {abcdefghijklmnop} +test string-14.9 {string replace} { + string replace abcdefghijklmnop -3 2 +} {defghijklmnop} +test string-14.10 {string replace} { + string replace abcdefghijklmnop -3 -2 +} {abcdefghijklmnop} +test string-14.11 {string replace} { + string replace abcdefghijklmnop 1000 1010 +} {abcdefghijklmnop} +test string-14.12 {string replace} { + string replace abcdefghijklmnop -100 end +} {} +test string-14.13 {string replace} { + list [catch {string replace abc abc 1} msg] $msg +} {1 {bad index "abc": must be integer?[+-]integer? or end?[+-]integer?}} +test string-14.14 {string replace} { + list [catch {string replace abc 1 eof} msg] $msg +} {1 {bad index "eof": must be integer?[+-]integer? or end?[+-]integer?}} +test string-14.15 {string replace} { + string replace abcdefghijklmnop end-10 end-2 NEW +} {abcdeNEWop} +test string-14.16 {string replace} { + string replace abcdefghijklmnop 0 end foo +} {foo} +test string-14.17 {string replace} { + string replace abcdefghijklmnop end end-1 +} {abcdefghijklmnop} test string-15.1 {string tolower too few args} { list [catch {string tolower} msg] |