From 5515c5642eea08452f57b1bcd90f66a3ee91836c Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 16 Dec 2013 10:25:14 +0000 Subject: [PATCH] test_io.rb: IO.write test * test/ruby/test_io.rb (test_s_write): test for IO.write. more conditions will be needed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44243 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_io.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb index 14225517bf..4dc7599b99 100644 --- a/test/ruby/test_io.rb +++ b/test/ruby/test_io.rb @@ -2968,4 +2968,20 @@ End 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