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 | aeffc67dbbb8a06297afd13a2e68edf40294b460 (patch) | |
tree | afa9851cf5aba5f4687ab65279a75e24c59018b9 /test | |
parent | cc3cbd2965ce1c75bd0eace89eeb3c3fe8c90735 (diff) | |
download | ruby-aeffc67dbbb8a06297afd13a2e68edf40294b460.tar.gz |
* 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: svn+ssh://ci.ruby-lang.org/ruby/trunk@18835 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-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 5ba6b7c447..32ac4ca935 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 |