diff options
Diffstat (limited to 'tests/io.test')
-rw-r--r-- | tests/io.test | 80 |
1 files changed, 79 insertions, 1 deletions
diff --git a/tests/io.test b/tests/io.test index e3ac4a1..c193793 100644 --- a/tests/io.test +++ b/tests/io.test @@ -12,7 +12,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: io.test,v 1.16 2001/04/04 17:35:25 andreas_kupries Exp $ +# RCS: @(#) $Id: io.test,v 1.17 2001/05/19 16:59:04 andreas_kupries Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest @@ -6369,6 +6369,84 @@ test io-52.8 {TclCopyChannel} {stdio} { list $s0 [file size test1] } {40 40} +# Empty files, to register them with the test facility +makeFile {} kyrillic.txt +makeFile {} utf8-fcopy.txt +makeFile {} utf8-rp.txt + +# Create kyrillic file +set out [open kyrillic.txt w] +fconfigure $out -encoding koi8-r +puts $out "\u0410\u0410" +close $out + +test io-52.9 {TclCopyChannel & encodings} { + # Copy kyrillic to UTF-8, using fcopy. + + set in [open kyrillic.txt r] + set out [open utf8-fcopy.txt w] + + fconfigure $in -encoding koi8-r + fconfigure $out -encoding utf-8 + + fcopy $in $out + close $in + close $out + + # Do the same again, but differently (read/puts). + + set in [open kyrillic.txt r] + set out [open utf8-rp.txt w] + + fconfigure $in -encoding koi8-r + fconfigure $out -encoding utf-8 + + puts -nonewline $out [read $in] + + close $in + close $out + + list \ + [file size kyrillic.txt] \ + [file size utf8-fcopy.txt] \ + [file size utf8-rp.txt] +} {3 5 5} + +test io-52.10 {TclCopyChannel & encodings} { + # encoding to binary (=> implies that the + # internal utf-8 is written) + + set in [open kyrillic.txt r] + set out [open utf8-fcopy.txt w] + + fconfigure $in -encoding koi8-r + fconfigure $out -encoding binary + + fcopy $in $out + close $in + close $out + + file size utf8-fcopy.txt +} 5 + +test io-52.11 {TclCopyChannel & encodings} { + # binary to encoding => the input has to be + # in utf-8 to make sense to the encoder + + set in [open utf8-fcopy.txt r] + set out [open kyrillic.txt w] + + fconfigure $in -encoding binary + fconfigure $out -encoding koi8-r + + fcopy $in $out + close $in + close $out + + file size kyrillic.txt +} 3 + + test io-53.1 {CopyData} { removeFile test1 set f1 [open $thisScript] |