summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-10-12 06:37:27 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-10-12 06:37:27 +0000
commit7587eb706a593f1728fcc0f3c4480856159e5d2a (patch)
tree9317224b226db60a0341ac0b70b970b8ca6690e6 /test/ruby
parent0a8f047a983deaf853e8ddc9f70da78f3a83f9ef (diff)
downloadruby-7587eb706a593f1728fcc0f3c4480856159e5d2a.tar.gz
* io.c (rb_io_ungetc): use unsigned int for GB18030.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29448 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_io_m17n.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/ruby/test_io_m17n.rb b/test/ruby/test_io_m17n.rb
index 5f35c227ea..10714b3e44 100644
--- a/test/ruby/test_io_m17n.rb
+++ b/test/ruby/test_io_m17n.rb
@@ -418,6 +418,30 @@ EOT
}
end
+ def test_ungetc_int
+ with_tmpdir {
+ generate_file('tmp', "A")
+ s = open("tmp", "r:GB18030") {|f|
+ f.ungetc(0x8431A439)
+ f.read
+ }
+ assert_equal(Encoding::GB18030, s.encoding)
+ assert_str_equal(0x8431A439.chr("GB18030")+"A", s)
+ }
+ end
+
+ def test_ungetc_str
+ with_tmpdir {
+ generate_file('tmp', "A")
+ s = open("tmp", "r:GB18030") {|f|
+ f.ungetc(0x8431A439.chr("GB18030"))
+ f.read
+ }
+ assert_equal(Encoding::GB18030, s.encoding)
+ assert_str_equal(0x8431A439.chr("GB18030")+"A", s)
+ }
+ end
+
def test_ungetc_stateful_conversion
with_tmpdir {
src = "before \e$B\x23\x30\x23\x31\e(B after".force_encoding("iso-2022-jp")