mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/stringio/stringio.c (strio_ungetbyte): encoding should not
be effective. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23424 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
760f2c2917
commit
af634f8455
4 changed files with 67 additions and 2 deletions
|
@ -289,6 +289,21 @@ class TestStringIO < Test::Unit::TestCase
|
|||
f.close unless f.closed?
|
||||
end
|
||||
|
||||
def test_ungetbyte
|
||||
s = "foo\nbar\n"
|
||||
t = StringIO.new(s, "r")
|
||||
t.ungetbyte(0x41)
|
||||
assert_equal(0x41, t.getbyte)
|
||||
t.ungetbyte("qux")
|
||||
assert_equal("quxfoo\n", t.gets)
|
||||
t.set_encoding("utf-8")
|
||||
t.ungetbyte(0x89)
|
||||
t.ungetbyte(0x8e)
|
||||
t.ungetbyte("\xe7")
|
||||
t.ungetbyte("\xe7\xb4\x85")
|
||||
assert_equal("\u7d05\u7389bar\n", t.gets)
|
||||
end
|
||||
|
||||
def test_ungetc
|
||||
s = "1234"
|
||||
f = StringIO.new(s, "r")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue