From 5ee997a6e52146480acd9b0630a45b05cebf0414 Mon Sep 17 00:00:00 2001 From: akr Date: Tue, 26 Aug 2008 16:09:29 +0000 Subject: * include/ruby/encoding.h (rb_econv_result_t): enumeration constant: econv_incomplete_input. * io.c (finish_writeconv): check econv_incomplete_input. * transcode.c (transcode_restartable0): return econv_incomplete_input for unexpected end of source buffer. (trans_sweep): check econv_incomplete_input. (rb_trans_conv): ditto. (rb_econv_convert0): ditto. (rb_econv_convert): ditto. (transcode_loop): ditto. (make_econv_exception): change message for econv_incomplete_input. (econv_result_to_symbol): return :incomplete_input for econv_incomplete_input. (ecerr_incomplete_input): new method. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@18875 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_econv.rb | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'test/ruby') diff --git a/test/ruby/test_econv.rb b/test/ruby/test_econv.rb index a9724d5d6..5324e6dfe 100644 --- a/test/ruby/test_econv.rb +++ b/test/ruby/test_econv.rb @@ -364,7 +364,7 @@ class TestEncodingConverter < Test::Unit::TestCase def test_errinfo_invalid_partial_character ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1") ec.primitive_convert(src="\xa4", dst="", nil, 10) - assert_errinfo(:invalid_byte_sequence, "EUC-JP", "UTF-8", "\xA4", "", nil, ec) + assert_errinfo(:incomplete_input, "EUC-JP", "UTF-8", "\xA4", "", nil, ec) end def test_errinfo_valid_partial_character @@ -426,6 +426,18 @@ class TestEncodingConverter < Test::Unit::TestCase assert_equal("UTF-8", err.destination_encoding) assert_equal("\xA4".force_encoding("ASCII-8BIT"), err.error_bytes) assert_equal("d", err.readagain_bytes) + assert_equal(false, err.incomplete_input?) + end + + def test_exc_incomplete + err = assert_raise(Encoding::InvalidByteSequence) { + "abc\xa4".encode("ISO-8859-1", "EUC-JP") + } + assert_equal("EUC-JP", err.source_encoding) + assert_equal("UTF-8", err.destination_encoding) + assert_equal("\xA4".force_encoding("ASCII-8BIT"), err.error_bytes) + assert_equal(nil, err.readagain_bytes) + assert_equal(true, err.incomplete_input?) end def test_exc_undef -- cgit