mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
This commit is contained in:
parent
3811bb53bd
commit
ad8cfb1b94
3 changed files with 54 additions and 8 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue