diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-08-17 03:05:40 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-08-17 03:05:40 +0000 |
commit | 04bbc1df1259e70064585dc23bacc7d904063f7e (patch) | |
tree | fac5ee7ef66d13c6f12137c52334d8512a04b716 /test/ruby/test_econv.rb | |
parent | 21b00e0222d742b18f415d65a920e948e293ba45 (diff) | |
download | ruby-04bbc1df1259e70064585dc23bacc7d904063f7e.tar.gz |
* transcode.c (make_econv_exception): add several instance variables
to exception object.
(ecerr_source_encoding): new method:
Encoding::ConversionUndefined#source_encoding and
Encoding::InvalidByteSequence#source_encoding.
(ecerr_destination_encoding): new method:
Encoding::ConversionUndefined#destination_encoding and
Encoding::InvalidByteSequence#destination_encoding.
(econverr_error_char): new method:
Encoding::ConversionUndefined#error_char.
(econverr_error_bytes): new method:
Encoding::ConversionUndefined#error_bytes.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18669 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_econv.rb')
-rw-r--r-- | test/ruby/test_econv.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/ruby/test_econv.rb b/test/ruby/test_econv.rb index 356ac74c75..1f15a759a0 100644 --- a/test/ruby/test_econv.rb +++ b/test/ruby/test_econv.rb @@ -396,4 +396,23 @@ class TestEncodingConverter < Test::Unit::TestCase ec.primitive_convert("", dst, nil, 10) assert_equal("\e$B!!\e(B???\e$B!\"!!!\#$\"\e(B".force_encoding("ISO-2022-JP"), dst) end + + def test_exc_invalid + err = assert_raise(Encoding::InvalidByteSequence) { + "abc\xa4def".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) + end + + def test_exc_undef + err = assert_raise(Encoding::ConversionUndefined) { + "abc\xa4\xa2def".encode("ISO-8859-1", "EUC-JP") + } + assert_equal("UTF-8", err.source_encoding) + assert_equal("ISO-8859-1", err.destination_encoding) + assert_equal("\u{3042}", err.error_char) + end + end |