mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
9ae9f7c9d3
commit
5515c5642e
1 changed files with 16 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue