aboutsummaryrefslogtreecommitdiffstats
path: root/test/ruby/test_io_m17n.rb
blob: 43f3c3ce01f63d4de25e330c6beb2f08f04db51e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
require 'test/unit'
require 'tmpdir'

class TestIOM17N < Test::Unit::TestCase
  def with_tmpdir
    Dir.mktmpdir {|dir|
      Dir.chdir dir
      yield dir
    }
  end

  def test_conversion
    with_tmpdir {
      open("tmp", "w") {|f| f.write "before \u00FF after" }
      s = open("tmp", "r:iso-8859-1:utf-8") {|f|
        f.gets("\xFF".force_encoding("iso-8859-1"))
      }
      assert_equal("before \xFF".force_encoding("iso-8859-1"), s, '[ruby-core:14288]')
    }
  end
end