summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-12-16 10:25:14 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-12-16 10:25:14 +0000
commit5515c5642eea08452f57b1bcd90f66a3ee91836c (patch)
tree179e6f59c34d03c2de5780f5a3c5064897d616d1 /test
parent9ae9f7c9d3057f45afce56e6f696895b71c84489 (diff)
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
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_io.rb16
1 files changed, 16 insertions, 0 deletions
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