diff options
author | stanton <stanton> | 1998-11-10 02:40:58 (GMT) |
---|---|---|
committer | stanton <stanton> | 1998-11-10 02:40:58 (GMT) |
commit | a9095128af52a34f6ad1a62dc2b2f34f92ad9387 (patch) | |
tree | dd33674560c55e9883fab312a986abf17ef84ccd /tests/format.test | |
parent | 0b4519300089676213a88b349f37d77d6d707d34 (diff) | |
download | tcl-a9095128af52a34f6ad1a62dc2b2f34f92ad9387.zip tcl-a9095128af52a34f6ad1a62dc2b2f34f92ad9387.tar.gz tcl-a9095128af52a34f6ad1a62dc2b2f34f92ad9387.tar.bz2 |
fixed "format" so it handles multibyte characters in %s with field
width and precision specifiers
Diffstat (limited to 'tests/format.test')
-rw-r--r-- | tests/format.test | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/tests/format.test b/tests/format.test index e6261c1..1a3e9b8 100644 --- a/tests/format.test +++ b/tests/format.test @@ -10,7 +10,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: format.test,v 1.1.2.2 1998/09/24 23:59:25 stanton Exp $ +# RCS: @(#) $Id: format.test,v 1.1.2.3 1998/11/10 02:40:59 stanton Exp $ if {[info commands test] != "test"} { source defs @@ -80,6 +80,45 @@ test format-2.3 {string formatting} { test format-2.4 {string formatting} { format "%s %s %% %c %s" abcd {This is a very long test string.} 120 x } {abcd This is a very long test string. % x x} +test format-2.5 {string formatting, embedded nulls} { + format "%10s" abc\0def +} " abc\0def" +test format-2.6 {string formatting, international chars} { + format "%10s" abc\ufeffdef +} " abc\ufeffdef" +test format-2.6 {string formatting, international chars} { + format "%.5s" abc\ufeffdef +} "abc\ufeffd" +test format-2.7 {string formatting, international chars} { + format "foo\ufeffbar%s" baz +} "foo\ufeffbarbaz" +test format-2.8 {string formatting, width} { + format "a%5sa" f +} "a fa" +test format-2.8 {string formatting, width} { + format "a%-5sa" f +} "af a" +test format-2.8 {string formatting, width} { + format "a%2sa" foo +} "afooa" +test format-2.8 {string formatting, width} { + format "a%0sa" foo +} "afooa" +test format-2.8 {string formatting, precision} { + format "a%.2sa" foobarbaz +} "afoa" +test format-2.8 {string formatting, precision} { + format "a%.sa" foobarbaz +} "aa" +test format-2.8 {string formatting, precision} { + list [catch {format "a%.-2sa" foobarbaz} msg] $msg +} {1 {bad field specifier "-"}} +test format-2.8 {string formatting, width and precision} { + format "a%5.2sa" foobarbaz +} "a foa" +test format-2.8 {string formatting, width and precision} { + format "a%5.7sa" foobarbaz +} "afoobarba" test format-3.1 {Tcl_FormatObjCmd: character formatting} { format "|%c|%0c|%-1c|%1c|%-6c|%6c|%*c|%*c|" 65 65 65 65 65 65 3 65 -4 65 |