mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
add tests for reading an extended file
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8441 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
cddaecb1ae
commit
40fd465e82
1 changed files with 45 additions and 0 deletions
|
@ -245,4 +245,49 @@ class TestFile < Test::Unit::TestCase
|
|||
f.truncate(3)
|
||||
assert_equal(nil, f.gets)
|
||||
end
|
||||
|
||||
def test_truncate_beyond_eof
|
||||
f = Tempfile.new("test-truncate")
|
||||
f.print "abc"
|
||||
f.truncate 10
|
||||
assert_equal("\0" * 7, f.read(100), "[ruby-dev:24532]")
|
||||
end
|
||||
|
||||
def test_read_all_extended_file
|
||||
f = Tempfile.new("test-extended-file")
|
||||
assert_nil(f.getc)
|
||||
open(f.path, "w") {|g| g.print "a" }
|
||||
assert_equal("a", f.read)
|
||||
end
|
||||
|
||||
def test_gets_extended_file
|
||||
f = Tempfile.new("test-extended-file")
|
||||
assert_nil(f.getc)
|
||||
open(f.path, "w") {|g| g.print "a" }
|
||||
assert_equal("a", f.gets("a"))
|
||||
end
|
||||
|
||||
def test_gets_para_extended_file
|
||||
f = Tempfile.new("test-extended-file")
|
||||
assert_nil(f.getc)
|
||||
open(f.path, "w") {|g| g.print "\na" }
|
||||
assert_equal("a", f.gets(""))
|
||||
end
|
||||
|
||||
def test_each_byte_extended_file
|
||||
f = Tempfile.new("test-extended-file")
|
||||
assert_nil(f.getc)
|
||||
open(f.path, "w") {|g| g.print "a" }
|
||||
result = []
|
||||
f.each_byte {|b| result << b }
|
||||
assert_equal([?a], result)
|
||||
end
|
||||
|
||||
def test_getc_extended_file
|
||||
f = Tempfile.new("test-extended-file")
|
||||
assert_nil(f.getc)
|
||||
open(f.path, "w") {|g| g.print "a" }
|
||||
assert_equal(?a, f.getc)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue