summaryrefslogtreecommitdiff
path: root/test/stringio
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-01-04 20:45:14 +0000
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-01-04 20:45:14 +0000
commitdc59c76898a6b6c3f87ec176660cb30fb2935370 (patch)
treeb9bc561d416c83d61b08a7e0088a408632dd44dc /test/stringio
parent812c5798e22fad779849561d14a8956434234114 (diff)
stringio: binmode sets encoding to ASCII-8BIT
This should match the behavior of IO#binmode as far as treating content as ASCII-8BIT (binary). * ext/stringio/stringio.c (strio_binmode): implement to set encoding * test/stringio/test_stringio.rb (test_binmode): new test [ruby-core:72699] [Bug #11945] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53435 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/stringio')
-rw-r--r--test/stringio/test_stringio.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/test/stringio/test_stringio.rb b/test/stringio/test_stringio.rb
index 77a9872..e443fa6 100644
--- a/test/stringio/test_stringio.rb
+++ b/test/stringio/test_stringio.rb
@@ -665,4 +665,13 @@ class TestStringIO < Test::Unit::TestCase
assert_raise(ArgumentError, "[ruby-dev:43392]") { StringIO.new.each_line(0){} }
assert_raise(ArgumentError, "[ruby-dev:43392]") { StringIO.new.each_line("a",0){} }
end
+
+ def test_binmode
+ s = StringIO.new
+ s.set_encoding('utf-8')
+ assert_same s, s.binmode
+
+ bug_11945 = '[ruby-core:72699] [Bug #11945]'
+ assert_equal Encoding::ASCII_8BIT, s.external_encoding, bug_11945
+ end
end