diff options
| author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-08-25 13:04:16 +0000 |
|---|---|---|
| committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-08-25 13:04:16 +0000 |
| commit | a491a8f7c7d6a9c4163c424ac26fde3d06c54ca5 (patch) | |
| tree | afa9851cf5aba5f4687ab65279a75e24c59018b9 /test/ruby | |
| parent | a4be1acb7868ed71e8200413e378de957a7f96f4 (diff) | |
| download | ruby-a491a8f7c7d6a9c4163c424ac26fde3d06c54ca5.tar.gz ruby-a491a8f7c7d6a9c4163c424ac26fde3d06c54ca5.tar.xz ruby-a491a8f7c7d6a9c4163c424ac26fde3d06c54ca5.zip | |
* transcode.c (rb_econv_open_by_transcoder_entries): initialize
last_error. num_trans may be zero.
(rb_econv_convert0): num_trans may be zero.
(rb_econv_putbackable): ditto.
(rb_econv_putback): ditto.
(rb_econv_convert): input_ptr and output_ptr may be NULL.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@18835 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
| -rw-r--r-- | test/ruby/test_econv.rb | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/test/ruby/test_econv.rb b/test/ruby/test_econv.rb index 5ba6b7c44..32ac4ca93 100644 --- a/test/ruby/test_econv.rb +++ b/test/ruby/test_econv.rb @@ -480,5 +480,45 @@ class TestEncodingConverter < Test::Unit::TestCase assert_equal("abcdef", dst) end - + def test_noconv + ec = Encoding::Converter.new("", "") + assert_equal(nil, ec.source_encoding) + assert_equal(nil, ec.destination_encoding) + assert_equal([:source_buffer_empty, nil, nil, nil, nil, nil], ec.primitive_errinfo) + a = ["", "abcdefg", ec, nil, 2] + check_ec("ab", "cdefg", :destination_buffer_full, *a) + check_ec("abcd", "efg", :destination_buffer_full, *a) + check_ec("abcdef", "g", :destination_buffer_full, *a) + check_ec("abcdefg", "", :finished, *a) + end + + def test_noconv_partial + ec = Encoding::Converter.new("", "") + a = ["", "abcdefg", ec, nil, 2, Encoding::Converter::PARTIAL_INPUT] + check_ec("ab", "cdefg", :destination_buffer_full, *a) + check_ec("abcd", "efg", :destination_buffer_full, *a) + check_ec("abcdef", "g", :destination_buffer_full, *a) + check_ec("abcdefg", "", :source_buffer_empty, *a) + end + + def test_noconv_output_followed_by_input + ec = Encoding::Converter.new("", "") + a = ["", "abcdefg", ec, nil, 2, Encoding::Converter::OUTPUT_FOLLOWED_BY_INPUT] + check_ec("a", "bcdefg", :output_followed_by_input, *a) + check_ec("ab", "cdefg", :output_followed_by_input, *a) + check_ec("abc", "defg", :output_followed_by_input, *a) + check_ec("abcd", "efg", :output_followed_by_input, *a) + check_ec("abcde", "fg", :output_followed_by_input, *a) + check_ec("abcdef", "g", :output_followed_by_input, *a) + check_ec("abcdefg", "", :output_followed_by_input, *a) + check_ec("abcdefg", "", :finished, *a) + end + + def test_noconv_insert_output + ec = Encoding::Converter.new("", "") + ec.primitive_insert_output("xyz") + ret = ec.primitive_convert(src="abc", dst="", nil, 20) + assert_equal(:finished, ret) + assert_equal(["xyzabc", ""], [dst, src]) + end end |
