ruby-changes:3107
From: ko1@a...
Date: 24 Dec 2007 19:22:44 +0900
Subject: [ruby-changes:3107] akr - Ruby:r14599 (trunk): add tests.
akr 2007-12-24 19:22:34 +0900 (Mon, 24 Dec 2007) New Revision: 14599 Modified files: trunk/test/ruby/test_io_m17n.rb Log: add tests. http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/test/ruby/test_io_m17n.rb?r1=14599&r2=14598 Index: test/ruby/test_io_m17n.rb =================================================================== --- test/ruby/test_io_m17n.rb (revision 14598) +++ test/ruby/test_io_m17n.rb (revision 14599) @@ -44,6 +44,87 @@ assert_block(full_message) { expected == actual } end + def test_open_r + with_tmpdir { + generate_file('tmp', "") + open("tmp", "r") {|f| + assert_equal(nil, f.external_encoding) + assert_equal(nil, f.internal_encoding) + } + } + end + + def test_open_r_enc + with_tmpdir { + generate_file('tmp', "") + open("tmp", "r:euc-jp") {|f| + assert_equal(Encoding::EUC_JP, f.external_encoding) + assert_equal(nil, f.internal_encoding) + } + } + end + + def test_open_r_enc_enc + with_tmpdir { + generate_file('tmp', "") + open("tmp", "r:euc-jp:utf-8") {|f| + assert_equal(Encoding::EUC_JP, f.external_encoding) + assert_equal(Encoding::UTF_8, f.internal_encoding) + } + } + end + + def test_open_w + with_tmpdir { + open("tmp", "w") {|f| + assert_equal(nil, f.external_encoding) + assert_equal(nil, f.internal_encoding) + } + } + end + + def test_open_w_enc + with_tmpdir { + open("tmp", "w:euc-jp") {|f| + assert_equal(Encoding::EUC_JP, f.external_encoding) + assert_equal(nil, f.internal_encoding) + } + } + end + + def test_open_w_enc_enc + with_tmpdir { + open("tmp", "w:euc-jp:utf-8") {|f| + assert_equal(Encoding::EUC_JP, f.external_encoding) + assert_equal(Encoding::UTF_8, f.internal_encoding) + } + } + end + + def test_open_w_enc + with_tmpdir { + open("tmp", "w:euc-jp") {|f| + assert_equal(Encoding::EUC_JP, f.external_encoding) + assert_equal(nil, f.internal_encoding) + } + } + end + + def test_stdin + assert_equal(Encoding.default_external, STDIN.external_encoding) + assert_equal(nil, STDIN.internal_encoding) + end + + def test_stdout + assert_equal(nil, STDOUT.external_encoding) + assert_equal(nil, STDOUT.internal_encoding) + end + + def test_stderr + assert_equal(nil, STDERR.external_encoding) + assert_equal(nil, STDERR.internal_encoding) + end + def test_terminator_conversion with_tmpdir { generate_file('tmp', "before \u00FF after") -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml