merge revision(s) r45646: [Backport #9765]

* ext/stringio/stringio.c (strio_putc): fix for non-ascii
	  encoding, like as IO#putc.  [ruby-dev:48114] [Bug #9765]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46213 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nagachika 2014-05-28 14:38:54 +00:00
parent 7ebed66e59
commit fc9677332a
4 changed files with 30 additions and 9 deletions

View file

@ -419,6 +419,22 @@ class TestStringIO < Test::Unit::TestCase
assert_equal("foo123", s)
end
def test_putc_nonascii
s = ""
f = StringIO.new(s, "w")
f.putc("\u{3042}")
f.putc(0x3044)
f.close
assert_equal("\u{3042}D", s)
s = "foo"
f = StringIO.new(s, "a")
f.putc("\u{3042}")
f.putc(0x3044)
f.close
assert_equal("foo\u{3042}D", s)
end
def test_read
f = StringIO.new("\u3042\u3044")
assert_raise(ArgumentError) { f.read(-1) }