mirror of
https://github.com/ruby/ruby.git
synced 2025-09-17 01:23:57 +02:00
[ruby/stringio] StringIO#initialize default to the source string encoding
[Bug #16497]4958a5ccab
(cherry picked from commite257c08f2e
)
This commit is contained in:
parent
3efbd527a8
commit
47b08728cf
3 changed files with 21 additions and 4 deletions
|
@ -797,6 +797,18 @@ class TestStringIO < Test::Unit::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
def test_binary_encoding_read_and_default_internal
|
||||
verbose, $VERBOSE = $VERBOSE, nil
|
||||
default_internal = Encoding.default_internal
|
||||
Encoding.default_internal = Encoding::UTF_8
|
||||
$VERBOSE = verbose
|
||||
assert_equal Encoding::BINARY, StringIO.new("Hello".b).read.encoding
|
||||
ensure
|
||||
$VERBOSE = nil
|
||||
Encoding.default_internal = default_internal
|
||||
$VERBOSE = verbose
|
||||
end
|
||||
|
||||
def assert_string(content, encoding, str, mesg = nil)
|
||||
assert_equal([content, encoding], [str, str.encoding], mesg)
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue