diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-12-23 23:57:14 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-12-23 23:57:14 +0000 |
commit | 57482b2a42b977a9ba3e9385a49ab22829979935 (patch) | |
tree | 9cc70ec2c10bd7ddebfbdb486dc0c01de4a9499e /test | |
parent | 08349f2ec96225f5d91f2a4d0d8ca5e19d9e2ccc (diff) | |
download | ruby-57482b2a42b977a9ba3e9385a49ab22829979935.tar.gz ruby-57482b2a42b977a9ba3e9385a49ab22829979935.tar.xz ruby-57482b2a42b977a9ba3e9385a49ab22829979935.zip |
add some tests on conversion for pipe.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@14560 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_io_m17n.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/test/ruby/test_io_m17n.rb b/test/ruby/test_io_m17n.rb index 4b8273b40..16dc9f232 100644 --- a/test/ruby/test_io_m17n.rb +++ b/test/ruby/test_io_m17n.rb @@ -1,5 +1,6 @@ require 'test/unit' require 'tmpdir' +require 'timeout' class TestIO_M17N < Test::Unit::TestCase ENCS = [ @@ -65,6 +66,39 @@ EOT } end + def test_pipe_terminator_conversion + with_pipe("euc-jp:utf-8") {|r, w| + w.write "before \xa2\xa2 after" + rs = "\xA2\xA2".encode("utf-8", "euc-jp") + timeout(1) { + assert_equal("before \xa2\xa2".encode("utf-8", "euc-jp"), + r.gets(rs)) + } + } + end + + def test_pipe_conversion + with_pipe("euc-jp:utf-8") {|r, w| + w.write "\xa1\xa1" + assert_equal("\xa1\xa1".encode("utf-8", "euc-jp"), r.getc) + } + end + + def test_pipe_convert_partial_read + with_pipe("euc-jp:utf-8") {|r, w| + begin + t = Thread.new { + w.write "\xa1" + sleep 0.1 + w.write "\xa1" + } + assert_equal("\xa1\xa1".encode("utf-8", "euc-jp"), r.getc) + ensure + t.join if t + end + } + end + def test_open_ascii with_tmpdir { src = "abc\n" |