diff options
author | Nobuyoshi Nakada <[email protected]> | 2021-12-22 15:33:12 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <[email protected]> | 2021-12-22 15:45:59 +0900 |
commit | fdf39963490cf2cf95b30d91bb9b35964c2c2350 (patch) | |
tree | 42794b7b89e46b0a035fda9ebbbe5ea22336bcc8 /test/ruby/test_io.rb | |
parent | 9902398d8613ac4eaf9b90c3d2c1a103a32d61e2 (diff) |
Empty and return the buffer if zero size is given [Bug #18421]
In `IO#readpartial` and `IO#read_nonblock`, as well as `IO#read`.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/5323
Diffstat (limited to 'test/ruby/test_io.rb')
-rw-r--r-- | test/ruby/test_io.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb index b46777df5f..4f54052d3b 100644 --- a/test/ruby/test_io.rb +++ b/test/ruby/test_io.rb @@ -1494,6 +1494,13 @@ class TestIO < Test::Unit::TestCase end) end + def test_readpartial_zero_size + File.open(IO::NULL) do |r| + assert_empty(r.readpartial(0, s = "01234567")) + assert_empty(s) + end + end + def test_readpartial_buffer_error with_pipe do |r, w| s = "" @@ -1539,6 +1546,13 @@ class TestIO < Test::Unit::TestCase end) end + def test_read_zero_size + File.open(IO::NULL) do |r| + assert_empty(r.read(0, s = "01234567")) + assert_empty(s) + end + end + def test_read_buffer_error with_pipe do |r, w| s = "" @@ -1576,6 +1590,13 @@ class TestIO < Test::Unit::TestCase } end + def test_read_nonblock_zero_size + File.open(IO::NULL) do |r| + assert_empty(r.read_nonblock(0, s = "01234567")) + assert_empty(s) + end + end + def test_write_nonblock_simple_no_exceptions pipe(proc do |w| w.write_nonblock('1', exception: false) |