diff options
author | oehhar <harald.oehlmann@elmicron.de> | 2023-11-13 17:38:29 (GMT) |
---|---|---|
committer | oehhar <harald.oehlmann@elmicron.de> | 2023-11-13 17:38:29 (GMT) |
commit | a71edde2eaa93e4663f869fc1301d702a6eaef61 (patch) | |
tree | a63390d7f694c42a2277ca1d43cf7a4f09334b5e | |
parent | d0863453ccc9e881f12f9015c72a94533dec5267 (diff) | |
download | tcl-a71edde2eaa93e4663f869fc1301d702a6eaef61.zip tcl-a71edde2eaa93e4663f869fc1301d702a6eaef61.tar.gz tcl-a71edde2eaa93e4663f869fc1301d702a6eaef61.tar.bz2 |
Bug [a173f922]: fcopy encoding error file position issues: read error test (failing currently)
-rw-r--r-- | tests/io.test | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/io.test b/tests/io.test index 7e62e6b..f3402f3 100644 --- a/tests/io.test +++ b/tests/io.test @@ -7654,6 +7654,37 @@ test io-52.20 {TclCopyChannel & encodings} -setup { close $in close $out } -returnCodes 1 -match glob -result {error reading "file*": invalid or incomplete multibyte or wide character} + +test io-52.20.1 {TclCopyChannel & read encoding error & tell position} -setup { + set out [open $path(utf8-fcopy.txt) w] + fconfigure $out -encoding utf-8 -translation lf + puts $out "AÁ" + close $out +} -constraints {fcopy} -body { + # binary to encoding => the input has to be + # in utf-8 to make sense to the encoder + + set in [open $path(utf8-fcopy.txt) r] + set out [open $path(kyrillic.txt) w] + + # Using "-encoding ascii" means reading the "Á" gives an error + fconfigure $in -encoding ascii -profile strict + fconfigure $out -encoding koi8-r -translation lf + + set l {} + # should fail, so 1 is added + lappend l [catch {fcopy $in $out}] + # should be at position 1, after the first correct byte, so 1 is read. + lappend l [tell $in] + # not sure, if flush required, but anyway + flush $out + # should be at position 1, after the first correct byte, so 1 is written. + lappend l [tell $out] +} -cleanup { + close $in + close $out +} -returnCodes 0 -result {1 1 1} + test io-52.21 {TclCopyChannel & encodings} -setup { set out [open $path(utf8-fcopy.txt) w] fconfigure $out -encoding utf-8 -translation lf |