From d38ecc58609e1da700a1be2d5ab37e13826f1fe1 Mon Sep 17 00:00:00 2001 From: mame Date: Wed, 4 Jun 2008 16:48:07 +0000 Subject: * test/ruby/test_transcode.rb: add tests for iso-2022-jp. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@16821 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_transcode.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'test/ruby/test_transcode.rb') diff --git a/test/ruby/test_transcode.rb b/test/ruby/test_transcode.rb index e4bad8e38..71045bb82 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 -- cgit