ruby-changes:32164
From: nobu <ko1@a...>
Date: Mon, 16 Dec 2013 19:25:18 +0900 (JST)
Subject: [ruby-changes:32164] nobu:r44243 (trunk): test_io.rb: IO.write test
nobu 2013-12-16 19:25:14 +0900 (Mon, 16 Dec 2013) New Revision: 44243 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=44243 Log: test_io.rb: IO.write test * test/ruby/test_io.rb (test_s_write): test for IO.write. more conditions will be needed. Modified files: trunk/test/ruby/test_io.rb Index: test/ruby/test_io.rb =================================================================== --- test/ruby/test_io.rb (revision 44242) +++ test/ruby/test_io.rb (revision 44243) @@ -2968,4 +2968,20 @@ End https://github.com/ruby/ruby/blob/trunk/test/ruby/test_io.rb#L2968 ensure t.kill end + + def test_s_write + t = Tempfile.new("test_io") + t.close + path = t.path + File.unlink(path) + IO.write(path, "foo") + assert_equal("foo", IO.read(path)) + IO.write(path, "bar", 2) + assert_equal("fobar", IO.read(path)) + File.unlink(path) + IO.write(path, "foo", encoding: Encoding::UTF_32BE) + assert_equal("\0\0\0f\0\0\0o\0\0\0o", File.binread(path)) + ensure + t.close! + end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/