diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-04-23 13:56:11 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-04-23 13:56:11 +0000 |
commit | ce2dc60216934e01910d2a3424c2aa0fe3ce4736 (patch) | |
tree | 2fd7e329cf9f391b2fa8201e359e529c19a3c228 /test | |
parent | 82801b9113222c21b088e173521eda99277d1b1b (diff) | |
download | ruby-ce2dc60216934e01910d2a3424c2aa0fe3ce4736.tar.gz |
* ext/iconv: deprecated. [Feature #6322]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35444 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/iconv/test_basic.rb | 59 | ||||
-rw-r--r-- | test/iconv/test_option.rb | 43 | ||||
-rw-r--r-- | test/iconv/test_partial.rb | 41 | ||||
-rw-r--r-- | test/iconv/utils.rb | 29 |
4 files changed, 0 insertions, 172 deletions
diff --git a/test/iconv/test_basic.rb b/test/iconv/test_basic.rb deleted file mode 100644 index 2575b22eb9..0000000000 --- a/test/iconv/test_basic.rb +++ /dev/null @@ -1,59 +0,0 @@ -require File.expand_path("../utils.rb", __FILE__) - -class TestIconv::Basic < TestIconv - def test_euc2sjis - iconv = Iconv.open('SHIFT_JIS', 'EUC-JP') - str = iconv.iconv(EUCJ_STR) - str << iconv.iconv(nil) - assert_equal(SJIS_STR, str) - iconv.close - end - - def test_close - iconv = Iconv.new('Shift_JIS', 'EUC-JP') - output = "" - begin - output += iconv.iconv(EUCJ_STR) - output += iconv.iconv(nil) - ensure - assert_respond_to(iconv, :close) - assert_equal("", iconv.close) - assert_equal(SJIS_STR, output) - end - end - - def test_open_without_block - assert_respond_to(Iconv, :open) - iconv = Iconv.open('SHIFT_JIS', 'EUC-JP') - str = iconv.iconv(EUCJ_STR) - str << iconv.iconv(nil) - assert_equal(SJIS_STR, str ) - iconv.close - end - - def test_open_with_block - input = "#{EUCJ_STR}\n"*2 - output = "" - Iconv.open("Shift_JIS", "EUC-JP") do |cd| - input.each_line do |s| - output << cd.iconv(s) - end - output << cd.iconv(nil) - end - assert_equal("#{SJIS_STR}\n"*2, output) - end - - def test_invalid_arguments - assert_raise(TypeError) { Iconv.new(nil, 'Shift_JIS') } - assert_raise(TypeError) { Iconv.new('Shift_JIS', nil) } - assert_raise(TypeError) { Iconv.open(nil, 'Shift_JIS') } - assert_raise(TypeError) { Iconv.open('Shift_JIS', nil) } - end - - def test_unknown_encoding - assert_raise(Iconv::InvalidEncoding) { Iconv.iconv("utf-8", "X-UKNOWN", "heh") } - assert_raise(Iconv::InvalidEncoding, '[ruby-dev:39487]') { - Iconv.iconv("X-UNKNOWN-1", "X-UNKNOWN-2") {break} - } - end -end if defined?(TestIconv) diff --git a/test/iconv/test_option.rb b/test/iconv/test_option.rb deleted file mode 100644 index e81df9d850..0000000000 --- a/test/iconv/test_option.rb +++ /dev/null @@ -1,43 +0,0 @@ -require File.expand_path("../utils.rb", __FILE__) - -class TestIconv::Option < TestIconv - def test_ignore_option - begin - iconv = Iconv.new('SHIFT_JIS', 'EUC-JP') - iconv.transliterate? - rescue NotImplementedError - return - end - iconv = Iconv.new('SHIFT_JIS', 'EUC-JP//ignore') - str = iconv.iconv(EUCJ_STR) - str << iconv.iconv(nil) - assert_equal(SJIS_STR, str) - iconv.close - - iconv = Iconv.new('SHIFT_JIS//IGNORE', 'EUC-JP//ignore') - str = iconv.iconv(EUCJ_STR) - str << iconv.iconv(nil) - assert_equal(SJIS_STR, str) - iconv.close - end - - def test_translit_option - begin - iconv = Iconv.new('SHIFT_JIS', 'EUC-JP') - iconv.transliterate? - rescue NotImplementedError - return - end - iconv = Iconv.new('SHIFT_JIS', 'EUC-JP//ignore') - str = iconv.iconv(EUCJ_STR) - str << iconv.iconv(nil) - assert_equal(SJIS_STR, str) - iconv.close - - iconv = Iconv.new('SHIFT_JIS//TRANSLIT', 'EUC-JP//translit//ignore') - str = iconv.iconv(EUCJ_STR) - str << iconv.iconv(nil) - assert_equal(SJIS_STR, str) - iconv.close - end -end if defined?(TestIconv) diff --git a/test/iconv/test_partial.rb b/test/iconv/test_partial.rb deleted file mode 100644 index a98960b070..0000000000 --- a/test/iconv/test_partial.rb +++ /dev/null @@ -1,41 +0,0 @@ -require File.expand_path("../utils.rb", __FILE__) - -class TestIconv::Partial < TestIconv - def test_partial_ascii - c = Iconv.open(ASCII, ASCII) - ref = '[ruby-core:17092]' - rescue - return - else - assert_equal("abc", c.iconv("abc")) - assert_equal("c", c.iconv("abc", 2), "#{ref}: with start") - assert_equal("c", c.iconv("abc", 2, 1), "#{ref}: with start, length") - assert_equal("c", c.iconv("abc", 2, 5), "#{ref}: with start, longer length") - assert_equal("bc", c.iconv("abc", -2), "#{ref}: with nagative start") - assert_equal("b", c.iconv("abc", -2, 1), "#{ref}: with nagative start, length") - assert_equal("bc", c.iconv("abc", -2, 5), "#{ref}: with nagative start, longer length") - assert_equal("", c.iconv("abc", 5), "#{ref}: with OOB") - assert_equal("", c.iconv("abc", 5, 2), "#{ref}: with OOB, length") - ensure - c.close if c - end - - def test_partial_euc2sjis - c = Iconv.open('SHIFT_JIS', 'EUC-JP') - rescue - return - else - assert_equal(SJIS_STR[0, 2], c.iconv(EUCJ_STR, 0, 2)) - assert_equal(SJIS_STR, c.iconv(EUCJ_STR, 0, 20)) - assert_equal(SJIS_STR[2..-1], c.iconv(EUCJ_STR, 2)) - assert_equal(SJIS_STR[2, 2], c.iconv(EUCJ_STR, 2, 2)) - assert_equal(SJIS_STR[2..-1], c.iconv(EUCJ_STR, 2, 20)) - assert_equal(SJIS_STR[-4..-1], c.iconv(EUCJ_STR, -4)) - assert_equal(SJIS_STR[-4, 2], c.iconv(EUCJ_STR, -4, 2)) - assert_equal(SJIS_STR[-4..-1], c.iconv(EUCJ_STR, -4, 20)) - assert_equal("", c.iconv(EUCJ_STR, 20)) - assert_equal("", c.iconv(EUCJ_STR, 20, 2)) - ensure - c.close - end -end if defined?(TestIconv) diff --git a/test/iconv/utils.rb b/test/iconv/utils.rb deleted file mode 100644 index 5f72dd3aea..0000000000 --- a/test/iconv/utils.rb +++ /dev/null @@ -1,29 +0,0 @@ -begin - verbose, $VERBOSE = $VERBOSE, nil - require 'iconv' -rescue LoadError -else - require 'test/unit' -ensure - $VERBOSE = verbose -end - -class TestIconv < ::Test::Unit::TestCase - if defined?(::Encoding) and String.method_defined?(:force_encoding) - def self.encode(str, enc) - str.force_encoding(enc) - end - else - def self.encode(str, enc) - str - end - end - - def default_test - self.class == TestIconv or super - end - - ASCII = "ascii" - EUCJ_STR = encode("\xa4\xa2\xa4\xa4\xa4\xa6\xa4\xa8\xa4\xaa", "EUC-JP").freeze - SJIS_STR = encode("\x82\xa0\x82\xa2\x82\xa4\x82\xa6\x82\xa8", "Shift_JIS").freeze -end if defined?(::Iconv) |