diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-08-28 17:39:02 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-08-28 17:39:02 +0000 |
commit | ad8cfb1b945d2ec6b28be8a1bc60ed458a19075c (patch) | |
tree | 48a7cdef57ab343827ab49b450d7bc4674d993c6 /test | |
parent | 3811bb53bdc604ec6abe1252787c3fb381a711d6 (diff) | |
download | ruby-ad8cfb1b945d2ec6b28be8a1bc60ed458a19075c.tar.gz |
* transcode.c (econv_primitive_convert): accept nil as
destination_bytesize for unlimited destination size.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18911 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_econv.rb | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/test/ruby/test_econv.rb b/test/ruby/test_econv.rb index bc22da567d..7d6e78227b 100644 --- a/test/ruby/test_econv.rb +++ b/test/ruby/test_econv.rb @@ -79,12 +79,31 @@ class TestEncodingConverter < Test::Unit::TestCase } end - def test_nil_input + def test_nil_source_buffer ec = Encoding::Converter.new("UTF-8", "EUC-JP") ret = ec.primitive_convert(nil, dst="", nil, 10) assert_equal(:finished, ret) end + def test_nil_destination_bytesize + ec = Encoding::Converter.new("Shift_JIS", "UTF-8") + n = 10000 + src = "\xa1".force_encoding("Shift_JIS") * n + ret = ec.primitive_convert(src, dst="", nil, nil) + assert_equal(:finished, ret) + assert_equal("\xEF\xBD\xA1".force_encoding("UTF-8") * n, dst) + end + + def test_nil_destination_bytesize_with_nonnli_byteoffset + ec = Encoding::Converter.new("Shift_JIS", "UTF-8") + n = 2000 + src = "\xa1".force_encoding("Shift_JIS") * n + dst = "abcd" * 2000 + ret = ec.primitive_convert(src, dst, 3, nil) + assert_equal(:finished, ret) + assert_equal("abc" + "\xEF\xBD\xA1".force_encoding("UTF-8") * n, dst) + end + def test_partial_input ec = Encoding::Converter.new("UTF-8", "EUC-JP") ret = ec.primitive_convert(src="", dst="", nil, 10, Encoding::Converter::PARTIAL_INPUT) |