diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_econv.rb | 7 | ||||
-rw-r--r-- | test/ruby/test_io_m17n.rb | 10 | ||||
-rw-r--r-- | test/ruby/test_transcode.rb | 8 |
3 files changed, 25 insertions, 0 deletions
diff --git a/test/ruby/test_econv.rb b/test/ruby/test_econv.rb index c898efee28..6844067526 100644 --- a/test/ruby/test_econv.rb +++ b/test/ruby/test_econv.rb @@ -654,4 +654,11 @@ class TestEncodingConverter < Test::Unit::TestCase ec.replacement = "<undef>" assert_equal("a <undef> b", ec.convert("a \u3042 b")) end + + def test_econv_new_hash + ec = Encoding::Converter.new("utf-8", "us-ascii", :undef => :replace) + assert_equal("a ? b", ec.convert("a \u3042 b")) + ec = Encoding::Converter.new("utf-8", "us-ascii", :undef => :replace, :replace => "X") + assert_equal("a X b", ec.convert("a \u3042 b")) + end end diff --git a/test/ruby/test_io_m17n.rb b/test/ruby/test_io_m17n.rb index 90dd831dd5..b8b532e94c 100644 --- a/test/ruby/test_io_m17n.rb +++ b/test/ruby/test_io_m17n.rb @@ -239,6 +239,16 @@ EOT w.close if w && !w.closed? end + def test_s_pipe_undef_replace_string + r, w = IO.pipe("utf-8:euc-jp", :undef=>:replace, :replace=>"X") + w << "\ufffd" + w.close + assert_equal("X", r.read) + ensure + r.close if r && !r.closed? + w.close if w && !w.closed? + end + def test_dup with_pipe("utf-8:euc-jp") {|r, w| w << "\u3042" diff --git a/test/ruby/test_transcode.rb b/test/ruby/test_transcode.rb index 81c58fd651..2bf8f04de4 100644 --- a/test/ruby/test_transcode.rb +++ b/test/ruby/test_transcode.rb @@ -324,10 +324,18 @@ class TestTranscode < Test::Unit::TestCase "\xA4\xA2\xFF\xFF\xA4\xA4".encode("ISO-2022-JP", "EUC-JP", invalid: :replace)) end + def test_invalid_replace_string + assert_equal("a<x>A", "a\x80A".encode("us-ascii", "euc-jp", :invalid=>:replace, :replace=>"<x>")) + end + def test_undef_replace assert_equal("?", "\u20AC".encode("EUC-JP", :undef=>:replace), "[ruby-dev:35709]") end + def test_undef_replace_string + assert_equal("a<x>A", "a\u3042A".encode("us-ascii", :undef=>:replace, :replace=>"<x>")) + end + def test_shift_jis check_both_ways("\u3000", "\x81\x40", 'shift_jis') # full-width space check_both_ways("\u00D7", "\x81\x7E", 'shift_jis') # × |