summaryrefslogtreecommitdiff
path: root/test/ruby/test_io_buffer.rb
diff options
context:
space:
mode:
authorSamuel Williams <[email protected]>2023-02-25 18:40:26 +1300
committerGitHub <[email protected]>2023-02-25 18:40:26 +1300
commit57bc3f2f462df8e945ddfa5f9a8de45c1b0f0a86 (patch)
treef43f4c6651e645f07834ec591146185c6897716c /test/ruby/test_io_buffer.rb
parent132934b82baad97107fe754d60f9a68a1db7ecda (diff)
Add `IO::Buffer.string` for efficient string creation. (#7364)
Notes
Notes: Merged-By: ioquatix <[email protected]>
Diffstat (limited to 'test/ruby/test_io_buffer.rb')
-rw-r--r--test/ruby/test_io_buffer.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/ruby/test_io_buffer.rb b/test/ruby/test_io_buffer.rb
index d9fa22fd2a..55e347471d 100644
--- a/test/ruby/test_io_buffer.rb
+++ b/test/ruby/test_io_buffer.rb
@@ -124,6 +124,20 @@ class TestIOBuffer < Test::Unit::TestCase
end
end
+ def test_string
+ result = IO::Buffer.string(12) do |buffer|
+ buffer.set_string("Hello World!")
+ end
+
+ assert_equal "Hello World!", result
+ end
+
+ def test_string_negative
+ assert_raise ArgumentError do
+ IO::Buffer.string(-1)
+ end
+ end
+
def test_resize_mapped
buffer = IO::Buffer.new