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 | 62ecf80478cb6c5162d1445be6c2d1d1aac86171 (patch) | |
| tree | 4c557e6cc9d549bdb4b8287dd9e50db3269c23f6 /test/ruby | |
| parent | c19c6063bc37dcff113f35dbb422ae61f162d03b (diff) | |
| download | ruby-62ecf80478cb6c5162d1445be6c2d1d1aac86171.tar.gz ruby-62ecf80478cb6c5162d1445be6c2d1d1aac86171.tar.xz ruby-62ecf80478cb6c5162d1445be6c2d1d1aac86171.zip | |
* io.c (copy_stream_body): use readpartial and write method for
non-IOs such as StringIO and ARGF.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@16087 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
| -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 0cb8a775e..d2292446f 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 |
