Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
StringIO#read(length) returns binary string when passed length
Test Script ---- require 'stringio' require 'test/unit/assertions.rb' include Test::Unit::Assertions str = "abcdefg" * 100 str.force_encoding('UTF-8') io = StringIO.new(str) s = io.read(0) assert_equal("", s) assert_equal(Encoding::ASCII_8BIT, s.encoding) s = io.read(10) assert_equal("abcdefgabc", s) assert_equal(Encoding::ASCII_8BIT, s.encoding) s = io.read() assert_equal(Encoding::UTF_8, s.encoding) length = Object.new def length.to_int 0 end io = StringIO.new("") s = io.read(length) assert_equal("", s) assert_equal(Encoding::ASCII_8BIT, s.encoding)
- Loading branch information