diff options
-rw-r--r-- | io_buffer.c | 2 | ||||
-rw-r--r-- | test/ruby/test_io_buffer.rb | 8 |
2 files changed, 10 insertions, 0 deletions
diff --git a/io_buffer.c b/io_buffer.c index 45dbfd02da..bd902ed8d4 100644 --- a/io_buffer.c +++ b/io_buffer.c @@ -259,6 +259,8 @@ rb_io_buffer_type_allocate(VALUE self) VALUE rb_io_buffer_type_for(VALUE klass, VALUE string) { + StringValue(string); + VALUE instance = rb_io_buffer_type_allocate(klass); struct rb_io_buffer *data = NULL; diff --git a/test/ruby/test_io_buffer.rb b/test/ruby/test_io_buffer.rb index 12937729f4..57d1867b25 100644 --- a/test/ruby/test_io_buffer.rb +++ b/test/ruby/test_io_buffer.rb @@ -81,6 +81,14 @@ class TestIOBuffer < Test::Unit::TestCase assert_equal "Hello World", string end + def test_non_string + not_string = Object.new + + assert_raise TypeError do + IO::Buffer.for(not_string) + end + end + def test_resize buffer = IO::Buffer.new(1024, IO::Buffer::MAPPED) buffer.resize(2048, 0) |