зеркало из https://github.com/github/ruby.git
Fix mapping invalid non-file object.
This commit is contained in:
Родитель
6ad8cf7071
Коммит
9de5c4ec76
|
@ -322,6 +322,9 @@ io_buffer_map(int argc, VALUE *argv, VALUE klass)
|
|||
}
|
||||
|
||||
VALUE io = argv[0];
|
||||
if (!RB_TYPE_P(io, T_FILE)) {
|
||||
rb_raise(rb_eArgError, "Must be file/io!");
|
||||
}
|
||||
|
||||
size_t size;
|
||||
if (argc >= 2) {
|
||||
|
|
|
@ -9,10 +9,6 @@ class TestIOBuffer < Test::Unit::TestCase
|
|||
Warning[:experimental] = experimental
|
||||
end
|
||||
|
||||
def test_default_size
|
||||
assert_equal IO::Buffer::DEFAULT_SIZE, IO::Buffer.new.size
|
||||
end
|
||||
|
||||
def assert_negative(value)
|
||||
assert(value < 0, "Expected #{value} to be negative!")
|
||||
end
|
||||
|
@ -40,6 +36,10 @@ class TestIOBuffer < Test::Unit::TestCase
|
|||
assert_include [IO::Buffer::LITTLE_ENDIAN, IO::Buffer::BIG_ENDIAN], IO::Buffer::HOST_ENDIAN
|
||||
end
|
||||
|
||||
def test_default_size
|
||||
assert_equal IO::Buffer::DEFAULT_SIZE, IO::Buffer.new.size
|
||||
end
|
||||
|
||||
def test_new_internal
|
||||
buffer = IO::Buffer.new(1024, IO::Buffer::INTERNAL)
|
||||
assert_equal 1024, buffer.size
|
||||
|
@ -74,6 +74,12 @@ class TestIOBuffer < Test::Unit::TestCase
|
|||
assert_include buffer.to_str, "Hello World"
|
||||
end
|
||||
|
||||
def test_file_mapped_invalid
|
||||
assert_raise ArgumentError do
|
||||
IO::Buffer.map("foobar")
|
||||
end
|
||||
end
|
||||
|
||||
def test_string_mapped
|
||||
string = "Hello World"
|
||||
buffer = IO::Buffer.for(string)
|
||||
|
|
Загрузка…
Ссылка в новой задаче