diff options
| author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-08-14 06:35:33 +0000 |
|---|---|---|
| committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-08-14 06:35:33 +0000 |
| commit | 83d2bb4bf3a4e63e65b4356fa59d2ba28a8a3c60 (patch) | |
| tree | 94f84e5fb9b24f31231c4911c8939476440b3e24 /test/ruby | |
| parent | bd22699a0757a06ac0ea4c0409241d9e5fab478d (diff) | |
| download | ruby-83d2bb4bf3a4e63e65b4356fa59d2ba28a8a3c60.tar.gz ruby-83d2bb4bf3a4e63e65b4356fa59d2ba28a8a3c60.tar.xz ruby-83d2bb4bf3a4e63e65b4356fa59d2ba28a8a3c60.zip | |
* transcode.c (rb_econv_conv): new function. it don't consume input
too much, even for multilevel conversion.
(transcode_loop): use rb_econv_conv.
(econv_primitive_convert): ditto.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@18610 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
| -rw-r--r-- | test/ruby/test_econv.rb | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/test/ruby/test_econv.rb b/test/ruby/test_econv.rb index 44cc12035..860261d24 100644 --- a/test/ruby/test_econv.rb +++ b/test/ruby/test_econv.rb @@ -95,18 +95,38 @@ class TestEncodingConverter < Test::Unit::TestCase def test_invalid2 ec = Encoding::Converter.new("Shift_JIS", "EUC-JP") a = ["", "abc\xFFdef", ec, nil, 1] - check_ec("a", "def", :obuf_full, *a) - check_ec("ab", "def", :obuf_full, *a) + check_ec("a", "c\xFFdef", :obuf_full, *a) + check_ec("ab", "\xFFdef", :obuf_full, *a) check_ec("abc", "def", :invalid_input, *a) - check_ec("abcd", "", :obuf_full, *a) + check_ec("abcd", "f", :obuf_full, *a) check_ec("abcde", "", :obuf_full, *a) check_ec("abcdef", "", :finished, *a) end + def test_invalid3 + ec = Encoding::Converter.new("Shift_JIS", "EUC-JP") + a = ["", "abc\xFFdef", ec, nil, 10] + check_ec("abc", "def", :invalid_input, *a) + check_ec("abcdef", "", :finished, *a) + end + + def test_invalid4 + ec = Encoding::Converter.new("Shift_JIS", "EUC-JP") + a = ["", "abc\xFFdef", ec, nil, 10, Encoding::Converter::OUTPUT_FOLLOWED_BY_INPUT] + check_ec("a", "bc\xFFdef", :output_followed_by_input, *a) + check_ec("ab", "c\xFFdef", :output_followed_by_input, *a) + check_ec("abc", "\xFFdef", :output_followed_by_input, *a) + check_ec("abc", "def", :invalid_input, *a) + check_ec("abcd", "ef", :output_followed_by_input, *a) + check_ec("abcde", "f", :output_followed_by_input, *a) + check_ec("abcdef", "", :output_followed_by_input, *a) + check_ec("abcdef", "", :finished, *a) + end + def test_errors ec = Encoding::Converter.new("UTF-16BE", "EUC-JP") a = ["", "\xFF\xFE\x00A\xDC\x00\x00B", ec, nil, 10] - check_ec("", "\x00B", :undefined_conversion, *a) + check_ec("", "\x00A\xDC\x00\x00B", :undefined_conversion, *a) check_ec("A", "\x00B", :invalid_input, *a) # \xDC\x00 is invalid as UTF-16BE check_ec("AB", "", :finished, *a) end |
