diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-04-19 19:47:16 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-04-19 19:47:16 +0000 |
commit | 9579647fe18b29d946d7905f0d233bd37463a504 (patch) | |
tree | 4c557e6cc9d549bdb4b8287dd9e50db3269c23f6 /test | |
parent | 24197c48d27625233b4141fa99aa67191eeeb2bc (diff) | |
download | ruby-9579647fe18b29d946d7905f0d233bd37463a504.tar.gz |
* io.c (copy_stream_body): use readpartial and write method for
non-IOs such as StringIO and ARGF.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16087 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_io.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb index 0cb8a775e2..d2292446fd 100644 --- a/test/ruby/test_io.rb +++ b/test/ruby/test_io.rb @@ -2,6 +2,7 @@ require 'test/unit' require 'tmpdir' require 'io/nonblock' require 'socket' +require 'stringio' class TestIO < Test::Unit::TestCase def test_gets_rs @@ -393,8 +394,33 @@ class TestIO < Test::Unit::TestCase result = t.value assert_equal(megacontent, result) } + } + end + + def test_copy_stream_strio + src = StringIO.new("abcd") + dst = StringIO.new + ret = IO.copy_stream(src, dst) + assert_equal(4, ret) + assert_equal("abcd", dst.string) + assert_equal(4, src.pos) + end + def test_copy_stream_strio_len + src = StringIO.new("abcd") + dst = StringIO.new + ret = IO.copy_stream(src, dst, 3) + assert_equal(3, ret) + assert_equal("abc", dst.string) + assert_equal(3, src.pos) + end + def test_copy_stream_strio_off + src = StringIO.new("abcd") + dst = StringIO.new + assert_raise(ArgumentError) { + IO.copy_stream(src, dst, 3, 1) } end + end |