diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-08-16 05:32:42 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-08-16 05:32:42 +0000 |
commit | 7a0bea4fd327ec0f572f25a24adc7f0b2f9821e8 (patch) | |
tree | 63b4f0774952fcf345a764249c853c3415c1c793 /test/ruby/test_econv.rb | |
parent | 5f9c188d978d45cdeb81ec83dfdaddffe1b8996c (diff) | |
download | ruby-7a0bea4fd327ec0f572f25a24adc7f0b2f9821e8.tar.gz |
* include/ruby/encoding.h (rb_econv_t): add fields: in_buf_start,
in_data_start, in_data_end, in_buf_end and last_trans_index.
(rb_econv_output): removed.
(rb_econv_insert_output): declared.
(rb_econv_encoding_to_insert_output): declared.
* enc/trans/newline.trans (rb_universal_newline): stateful_type
changed.
* transcode.c (transcode_restartable0): initialize inchar_start,
tc->recognized_len and next_table at beginning of the loop.
(rb_econv_open_by_transcoder_entries): initialize new fields.
(rb_econv_open): setup last_trans_index.
(trans_sweep): last out_buf_start can be non-NULL now.
(rb_econv_convert): check last out_buf_start and in_buf_start at
first.
(rb_econv_output_with_destination_encoding): removed.
(econv_just_convert): removed.
(rb_econv_output): removed.
(econv_primitive_output): method removed.
(rb_econv_encoding_to_insert_output): new function.
(allocate_converted_string): new function.
(rb_econv_insert_output): new function.
(econv_primitive_insert_output): new method.
(output_replacement_character): use rb_econv_insert_output. unused
arguments removed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18654 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_econv.rb')
-rw-r--r-- | test/ruby/test_econv.rb | 39 |
1 files changed, 14 insertions, 25 deletions
diff --git a/test/ruby/test_econv.rb b/test/ruby/test_econv.rb index 8ac4013218..356ac74c75 100644 --- a/test/ruby/test_econv.rb +++ b/test/ruby/test_econv.rb @@ -366,45 +366,34 @@ class TestEncodingConverter < Test::Unit::TestCase assert_equal("", src) end - def test_output_region - ec = Encoding::Converter.new("EUC-JP", "UTF-8") - assert_equal(true, ec.primitive_output("abc", dst="", nil, 6)) - assert_equal("abc", dst) - assert_raise(ArgumentError) { ec.primitive_output("abc", dst, 4, 6) } - assert_equal(true, ec.primitive_output("def", dst)) - assert_equal("abcdef", dst) - assert_equal(false, ec.primitive_output("ghi", dst, nil, 1)) - assert_equal("abcdef", dst) - assert_raise(ArgumentError) { ec.primitive_output("jkl", dst, -1, 6) } - assert_raise(ArgumentError) { ec.primitive_output("hij", dst, nil, -1) } - assert_equal("abcdef", dst) - end - def test_output_iso2022jp ec = Encoding::Converter.new("EUC-JP", "ISO-2022-JP") ec.primitive_convert(src="\xa1\xa1", dst="", nil, 10, Encoding::Converter::PARTIAL_INPUT) assert_equal("\e$B!!".force_encoding("ISO-2022-JP"), dst) - assert_equal(true, ec.primitive_output("???", dst)) + assert_equal(true, ec.primitive_insert_output("???")) + ec.primitive_convert("", dst, nil, 10, Encoding::Converter::PARTIAL_INPUT) assert_equal("\e$B!!\e(B???".force_encoding("ISO-2022-JP"), dst) ec.primitive_convert(src="\xa1\xa2", dst, nil, 10, Encoding::Converter::PARTIAL_INPUT) assert_equal("\e$B!!\e(B???\e$B!\"".force_encoding("ISO-2022-JP"), dst) - # escape sequences may be reduced in future. - assert_equal(true, ec.primitive_output("\xA1\xA1".force_encoding("EUC-JP"), dst)) - assert_equal("\e$B!!\e(B???\e$B!\"\e(B\e$B!!\e(B".force_encoding("ISO-2022-JP"), dst) + assert_equal(true, ec.primitive_insert_output("\xA1\xA1".force_encoding("EUC-JP"))) + ec.primitive_convert("", dst, nil, 10, Encoding::Converter::PARTIAL_INPUT) + assert_equal("\e$B!!\e(B???\e$B!\"!!".force_encoding("ISO-2022-JP"), dst) ec.primitive_convert(src="\xa1\xa3", dst, nil, 10, Encoding::Converter::PARTIAL_INPUT) - assert_equal("\e$B!!\e(B???\e$B!\"\e(B\e$B!!\e(B\e$B!\#".force_encoding("ISO-2022-JP"), dst) + assert_equal("\e$B!!\e(B???\e$B!\"!!!\#".force_encoding("ISO-2022-JP"), dst) - assert_equal(true, ec.primitive_output("\u3042", dst)) - assert_equal("\e$B!!\e(B???\e$B!\"\e(B\e$B!!\e(B\e$B!\#\e(B\e$B$\"\e(B".force_encoding("ISO-2022-JP"), dst) + assert_equal(true, ec.primitive_insert_output("\u3042")) + ec.primitive_convert("", dst, nil, 10, Encoding::Converter::PARTIAL_INPUT) + assert_equal("\e$B!!\e(B???\e$B!\"!!!\#$\"".force_encoding("ISO-2022-JP"), dst) assert_raise(Encoding::ConversionUndefined) { - ec.primitive_output("\uFFFD", dst) + ec.primitive_insert_output("\uFFFD") } - assert_equal("\e$B!!\e(B???\e$B!\"\e(B\e$B!!\e(B\e$B!\#\e(B\e$B$\"\e(B".force_encoding("ISO-2022-JP"), dst) - end - + assert_equal("\e$B!!\e(B???\e$B!\"!!!\#$\"".force_encoding("ISO-2022-JP"), dst) + ec.primitive_convert("", dst, nil, 10) + assert_equal("\e$B!!\e(B???\e$B!\"!!!\#$\"\e(B".force_encoding("ISO-2022-JP"), dst) + end end |