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 | 9e1ad7f73af73c98f566a5c61b8c5ccedcd4cb94 (patch) | |
| tree | fac5ee7ef66d13c6f12137c52334d8512a04b716 /test/ruby | |
| parent | 00b7ade35cfc9040796b3e0042350c2cc2cfee0f (diff) | |
| download | ruby-9e1ad7f73af73c98f566a5c61b8c5ccedcd4cb94.tar.gz ruby-9e1ad7f73af73c98f566a5c61b8c5ccedcd4cb94.tar.xz ruby-9e1ad7f73af73c98f566a5c61b8c5ccedcd4cb94.zip | |
* 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: http://svn.ruby-lang.org/repos/ruby/trunk@18669 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
| -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 356ac74c7..1f15a759a 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 |
