From 9579647fe18b29d946d7905f0d233bd37463a504 Mon Sep 17 00:00:00 2001 From: akr Date: Sat, 19 Apr 2008 19:47:16 +0000 Subject: * 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 --- test/ruby/test_io.rb | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'test') 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 -- cgit v1.2.3