From 56811617ab4b7007aad10c794366115a671e4f29 Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Sun, 19 Dec 2021 17:05:57 +1300 Subject: Improve IO::Buffer resize and introduce ownership transfer. --- test/ruby/test_io_buffer.rb | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'test/ruby/test_io_buffer.rb') diff --git a/test/ruby/test_io_buffer.rb b/test/ruby/test_io_buffer.rb index c629d2829e..afc39a8c8e 100644 --- a/test/ruby/test_io_buffer.rb +++ b/test/ruby/test_io_buffer.rb @@ -101,17 +101,21 @@ class TestIOBuffer < Test::Unit::TestCase end end - def test_resize - buffer = IO::Buffer.new(1024, IO::Buffer::MAPPED) - buffer.resize(2048, 0) + def test_resize_mapped + buffer = IO::Buffer.new + + buffer.resize(2048) assert_equal 2048, buffer.size + + buffer.resize(4096) + assert_equal 4096, buffer.size end def test_resize_preserve message = "Hello World" - buffer = IO::Buffer.new(1024, IO::Buffer::MAPPED) + buffer = IO::Buffer.new(1024) buffer.copy(message, 0) - buffer.resize(2048, 1024) + buffer.resize(2048) assert_equal message, buffer.to_str(0, message.bytesize) end @@ -159,7 +163,7 @@ class TestIOBuffer < Test::Unit::TestCase buffer = IO::Buffer.new(128, IO::Buffer::INTERNAL|IO::Buffer::LOCKED) assert_raise RuntimeError do - buffer.resize(256, 0) + buffer.resize(256) end assert_equal 128, buffer.size -- cgit v1.2.1