diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_econv.rb | 4 | ||||
-rw-r--r-- | test/ruby/test_io_m17n.rb | 20 | ||||
-rw-r--r-- | test/ruby/test_transcode.rb | 16 |
3 files changed, 20 insertions, 20 deletions
diff --git a/test/ruby/test_econv.rb b/test/ruby/test_econv.rb index 684406752..12f652d85 100644 --- a/test/ruby/test_econv.rb +++ b/test/ruby/test_econv.rb @@ -524,7 +524,7 @@ class TestEncodingConverter < Test::Unit::TestCase end def test_invalid_ignore - ec = Encoding::Converter.new("UTF-8", "EUC-JP", Encoding::Converter::INVALID_IGNORE) + ec = Encoding::Converter.new("UTF-8", "EUC-JP", :invalid => :replace, :replace => "") ret = ec.primitive_convert(src="abc\x80def", dst="", nil, 100) assert_equal(:finished, ret) assert_equal("", src) @@ -540,7 +540,7 @@ class TestEncodingConverter < Test::Unit::TestCase end def test_undef_ignore - ec = Encoding::Converter.new("UTF-8", "EUC-JP", Encoding::Converter::UNDEF_IGNORE) + ec = Encoding::Converter.new("UTF-8", "EUC-JP", :undef => :replace, :replace => "") ret = ec.primitive_convert(src="abc\u{fffd}def", dst="", nil, 100) assert_equal(:finished, ret) assert_equal("", src) diff --git a/test/ruby/test_io_m17n.rb b/test/ruby/test_io_m17n.rb index 67f48527b..550d163bc 100644 --- a/test/ruby/test_io_m17n.rb +++ b/test/ruby/test_io_m17n.rb @@ -1312,14 +1312,14 @@ EOT open("t.txt", "r:utf-8:euc-jp", :invalid => :replace) {|f| assert_equal("a?b", f.read) } - open("t.txt", "r:utf-8:euc-jp", :invalid => :ignore) {|f| + open("t.txt", "r:utf-8:euc-jp", :invalid => :replace, :replace => "") {|f| assert_equal("ab", f.read) } open("t.txt", "r:utf-8:euc-jp", :undef => :replace) {|f| assert_raise(Encoding::InvalidByteSequence) { f.read } assert_equal("b", f.read) } - open("t.txt", "r:utf-8:euc-jp", :undef => :ignore) {|f| + open("t.txt", "r:utf-8:euc-jp", :undef => :replace, :replace => "") {|f| assert_raise(Encoding::InvalidByteSequence) { f.read } assert_equal("b", f.read) } @@ -1332,14 +1332,14 @@ EOT open("t.txt", "r:utf-8:euc-jp", :undef => :replace) {|f| assert_equal("a?b", f.read) } - open("t.txt", "r:utf-8:euc-jp", :undef => :ignore) {|f| + open("t.txt", "r:utf-8:euc-jp", :undef => :replace, :replace => "") {|f| assert_equal("ab", f.read) } open("t.txt", "r:utf-8:euc-jp", :invalid => :replace) {|f| assert_raise(Encoding::ConversionUndefined) { f.read } assert_equal("b", f.read) } - open("t.txt", "r:utf-8:euc-jp", :invalid => :ignore) {|f| + open("t.txt", "r:utf-8:euc-jp", :invalid => :replace, :replace => "") {|f| assert_raise(Encoding::ConversionUndefined) { f.read } assert_equal("b", f.read) } @@ -1354,7 +1354,7 @@ EOT } assert_equal("a?b", File.read("t.txt")) - open("t.txt", "w:euc-jp", :invalid => :ignore) {|f| + open("t.txt", "w:euc-jp", :invalid => :replace, :replace => "") {|f| assert_nothing_raised { f.write invalid_utf8 } } assert_equal("ab", File.read("t.txt")) @@ -1362,7 +1362,7 @@ EOT open("t.txt", "w:euc-jp", :undef => :replace) {|f| assert_raise(Encoding::InvalidByteSequence) { f.write invalid_utf8 } } - open("t.txt", "w:euc-jp", :undef => :ignore) {|f| + open("t.txt", "w:euc-jp", :undef => :replace, :replace => "") {|f| assert_raise(Encoding::InvalidByteSequence) { f.write invalid_utf8 } } } @@ -1375,14 +1375,14 @@ EOT assert_nothing_raised { f.write "a\uFFFDb" } } assert_equal("a?b", File.read("t.txt")) - open("t.txt", "w:euc-jp:utf-8", :undef => :ignore) {|f| + open("t.txt", "w:euc-jp:utf-8", :undef => :replace, :replace => "") {|f| assert_nothing_raised { f.write "a\uFFFDb" } } assert_equal("ab", File.read("t.txt")) open("t.txt", "w:euc-jp:utf-8", :invalid => :replace) {|f| assert_raise(Encoding::ConversionUndefined) { f.write "a\uFFFDb" } } - open("t.txt", "w:euc-jp:utf-8", :invalid => :ignore) {|f| + open("t.txt", "w:euc-jp:utf-8", :invalid => :replace, :replace => "") {|f| assert_raise(Encoding::ConversionUndefined) { f.write "a\uFFFDb" } } } @@ -1395,14 +1395,14 @@ EOT assert_nothing_raised { f.write "a\uFFFDb" } } assert_equal("a?b", File.read("t.txt")) - open("t.txt", "w:iso-2022-jp:utf-8", :undef => :ignore) {|f| + open("t.txt", "w:iso-2022-jp:utf-8", :undef => :replace, :replace => "") {|f| assert_nothing_raised { f.write "a\uFFFDb" } } assert_equal("ab", File.read("t.txt")) open("t.txt", "w:iso-2022-jp:utf-8", :invalid => :replace) {|f| assert_raise(Encoding::ConversionUndefined) { f.write "a\uFFFDb" } } - open("t.txt", "w:iso-2022-jp:utf-8", :invalid => :ignore) {|f| + open("t.txt", "w:iso-2022-jp:utf-8", :invalid => :replace, :replace => "") {|f| assert_raise(Encoding::ConversionUndefined) { f.write "a\uFFFDb" } } } diff --git a/test/ruby/test_transcode.rb b/test/ruby/test_transcode.rb index 2bf8f04de..614d4ceb0 100644 --- a/test/ruby/test_transcode.rb +++ b/test/ruby/test_transcode.rb @@ -247,23 +247,23 @@ class TestTranscode < Test::Unit::TestCase def test_invalid_ignore # arguments only - assert_nothing_raised { 'abc'.encode('utf-8', invalid: :ignore) } + assert_nothing_raised { 'abc'.encode('utf-8', invalid: :replace, replace: "") } # check handling of UTF-8 ill-formed subsequences assert_equal("\x00\x41\x00\x3E\x00\x42".force_encoding('UTF-16BE'), - "\x41\xC2\x3E\x42".encode('UTF-16BE', 'UTF-8', invalid: :ignore)) + "\x41\xC2\x3E\x42".encode('UTF-16BE', 'UTF-8', invalid: :replace, replace: "")) assert_equal("\x00\x41\x00\xF1\x00\x42".force_encoding('UTF-16BE'), - "\x41\xC2\xC3\xB1\x42".encode('UTF-16BE', 'UTF-8', invalid: :ignore)) + "\x41\xC2\xC3\xB1\x42".encode('UTF-16BE', 'UTF-8', invalid: :replace, replace: "")) assert_equal("\x00\x42".force_encoding('UTF-16BE'), - "\xF0\x80\x80\x42".encode('UTF-16BE', 'UTF-8', invalid: :ignore)) + "\xF0\x80\x80\x42".encode('UTF-16BE', 'UTF-8', invalid: :replace, replace: "")) assert_equal(''.force_encoding('UTF-16BE'), - "\x82\xAB".encode('UTF-16BE', 'UTF-8', invalid: :ignore)) + "\x82\xAB".encode('UTF-16BE', 'UTF-8', invalid: :replace, replace: "")) assert_equal("\e$B!!\e(B".force_encoding("ISO-2022-JP"), - "\xA1\xA1\xFF".encode("ISO-2022-JP", "EUC-JP", invalid: :ignore)) + "\xA1\xA1\xFF".encode("ISO-2022-JP", "EUC-JP", invalid: :replace, replace: "")) assert_equal("\e$B\x24\x22\x24\x24\e(B".force_encoding("ISO-2022-JP"), - "\xA4\xA2\xFF\xA4\xA4".encode("ISO-2022-JP", "EUC-JP", invalid: :ignore)) + "\xA4\xA2\xFF\xA4\xA4".encode("ISO-2022-JP", "EUC-JP", invalid: :replace, replace: "")) assert_equal("\e$B\x24\x22\x24\x24\e(B".force_encoding("ISO-2022-JP"), - "\xA4\xA2\xFF\xFF\xA4\xA4".encode("ISO-2022-JP", "EUC-JP", invalid: :ignore)) + "\xA4\xA2\xFF\xFF\xA4\xA4".encode("ISO-2022-JP", "EUC-JP", invalid: :replace, replace: "")) end def test_invalid_replace |