diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_io.rb | 16 |
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 |