summaryrefslogtreecommitdiff
path: root/test/stringio
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-08-12 01:47:09 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-08-12 01:47:09 +0000
commit6ee82564fac2745e45154938b5b75d9f5ab70b58 (patch)
tree0d8d1c78c9289c1860b5a27350f01ec7f5bed64d /test/stringio
parent201d0e7e3362f09529f527d2ed525013eda51513 (diff)
stringio.c: encoding at EOF
* ext/stringio/stringio.c (strio_read): should return string with the external encoding, at EOF too. [ruby-core:82349] [Bug #13806] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59578 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/stringio')
-rw-r--r--test/stringio/test_stringio.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/stringio/test_stringio.rb b/test/stringio/test_stringio.rb
index 99548d676d..89fc54e922 100644
--- a/test/stringio/test_stringio.rb
+++ b/test/stringio/test_stringio.rb
@@ -577,6 +577,13 @@ class TestStringIO < Test::Unit::TestCase
s = "0123456789"
assert_same(s, f.read(nil, s))
assert_equal("\u3042\u3044", s)
+
+ bug13806 = '[ruby-core:82349] [Bug #13806]'
+ assert_string("", Encoding::UTF_8, f.read, bug13806)
+ assert_string("", Encoding::UTF_8, f.read(nil, nil), bug13806)
+ s.force_encoding(Encoding::US_ASCII)
+ assert_same(s, f.read(nil, s))
+ assert_string("", Encoding::UTF_8, s, bug13806)
end
def test_readpartial
@@ -756,4 +763,8 @@ class TestStringIO < Test::Unit::TestCase
assert_equal(0x100000, s.pos)
end;
end
+
+ def assert_string(content, encoding, str, mesg = nil)
+ assert_equal([content, encoding], [str, str.encoding], mesg)
+ end
end