diff options
-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 |