diff options
author | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-06-04 16:48:07 +0000 |
---|---|---|
committer | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-06-04 16:48:07 +0000 |
commit | d6ada9f14b4726b61f292a1f6d104bf297db1f74 (patch) | |
tree | e1868e82175234a8edaa07828bebf4afa9271922 | |
parent | 4a14d3c04b61851abffbf020bcdc82f5276a3d12 (diff) | |
download | ruby-d6ada9f14b4726b61f292a1f6d104bf297db1f74.tar.gz |
* test/ruby/test_transcode.rb: add tests for iso-2022-jp.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16821 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | test/ruby/test_transcode.rb | 15 |
2 files changed, 19 insertions, 0 deletions
@@ -1,3 +1,7 @@ +Thu Jun 5 01:47:18 2008 Yusuke Endoh <mame@tsg.ne.jp> + + * test/ruby/test_transcode.rb: add tests for iso-2022-jp. + Thu Jun 5 01:27:42 2008 Yusuke Endoh <mame@tsg.ne.jp> * test/ruby/test_process.rb: add tests. diff --git a/test/ruby/test_transcode.rb b/test/ruby/test_transcode.rb index e4bad8e38a..71045bb82d 100644 --- a/test/ruby/test_transcode.rb +++ b/test/ruby/test_transcode.rb @@ -253,4 +253,19 @@ class TestTranscode < Test::Unit::TestCase assert_equal(''.force_encoding('UTF-16BE'), "\x82\xAB".encode('UTF-16BE', 'UTF-8', invalid: :ignore)) end + + def test_iso_2022_jp + assert_raise(RuntimeError) { "\x1b(A".encode("utf-8", "iso-2022-jp") } + assert_raise(RuntimeError) { "\x1b$(A".encode("utf-8", "iso-2022-jp") } + assert_equal("\uff71\uff72\uff73\uff74\uff75", + "\x1b(I12345\x1b(B".force_encoding("iso-2022-jp").encode("utf-8")) + assert_equal("\u9299", "\x1b$(Dd!\x1b(B".encode("utf-8", "iso-2022-jp")) + assert_raise(RuntimeError) { "\x1b$C".encode("utf-8", "iso-2022-jp") } + assert_raise(RuntimeError) { "\x1e".encode("utf-8", "iso-2022-jp") } + assert_raise(RuntimeError) { "\x80".encode("utf-8", "iso-2022-jp") } + + assert_equal("\x1b(I12345\x1b(B".force_encoding("iso-2022-jp"), + "\uff71\uff72\uff73\uff74\uff75".encode("iso-2022-jp")) + assert_equal("\x1b$(Dd!\x1b(B".force_encoding("iso-2022-jp"), "\u9299".encode("iso-2022-jp")) + end end |