1 require File.join(File.dirname(__FILE__), "utils.rb")
3 class TestIconv::Basic < TestIconv
5 iconv = Iconv.open('SHIFT_JIS', 'EUC-JP')
6 str = iconv.iconv(EUCJ_STR)
7 str << iconv.iconv(nil)
8 assert_equal(SJIS_STR, str)
13 iconv = Iconv.new('Shift_JIS', 'EUC-JP')
16 output += iconv.iconv(EUCJ_STR)
17 output += iconv.iconv(nil)
19 assert_respond_to(iconv, :close)
20 assert_equal("", iconv.close)
21 assert_equal(SJIS_STR, output)
25 def test_open_without_block
26 assert_respond_to(Iconv, :open)
27 iconv = Iconv.open('SHIFT_JIS', 'EUC-JP')
28 str = iconv.iconv(EUCJ_STR)
29 str << iconv.iconv(nil)
30 assert_equal(SJIS_STR, str )
34 def test_open_with_block
35 input = "#{EUCJ_STR}\n"*2
37 Iconv.open("Shift_JIS", "EUC-JP") do |cd|
38 input.each_line do |s|
41 output << cd.iconv(nil)
43 assert_equal("#{SJIS_STR}\n"*2, output)
46 def test_unknown_encoding
47 assert_raise(Iconv::InvalidEncoding) { Iconv.iconv("utf-8", "X-UKNOWN", "heh") }
49 end if defined?(TestIconv)