diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-08-31 08:21:46 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-08-31 08:21:46 +0000 |
commit | 9f1994ed5ce9e5f3a0964058b4753a021a92e40d (patch) | |
tree | b8530dbd622619640e94ab40e230b415894fb120 /test | |
parent | bb03f02805d1cd112c5fc7a3a8027ed2797c0074 (diff) | |
download | ruby-9f1994ed5ce9e5f3a0964058b4753a021a92e40d.tar.gz |
io.c: shrink read buffer
* io.c (io_setstrbuf): return true if the buffer is newly created.
* io.c (io_set_read_length): shrink the read buffer if it is a new
object and is too large. [ruby-core:81370] [Bug #13597]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59701 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/-ext-/string/test_capacity.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/test/-ext-/string/test_capacity.rb b/test/-ext-/string/test_capacity.rb index 48d2deadee..6ef5a8c4da 100644 --- a/test/-ext-/string/test_capacity.rb +++ b/test/-ext-/string/test_capacity.rb @@ -29,4 +29,12 @@ class Test_StringCapacity < Test::Unit::TestCase assert_equal("", String.new(capacity: -1000)) assert_equal(capa(String.new(capacity: -10000)), capa(String.new(capacity: -1000))) end + + def test_io_read + s = String.new(capacity: 1000) + open(__FILE__) {|f|f.read(1024*1024, s)} + assert_equal(1024*1024, capa(s)) + open(__FILE__) {|f|s = f.read(1024*1024)} + assert_operator(capa(s), :<=, s.bytesize+4096) + end end |