1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* test/ruby/test_file.rb (test_*_extended_file): test in default/text/binary

mode.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19985 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
usa 2008-10-28 05:20:24 +00:00
parent 6714f687e3
commit 993a9404cb

View file

@ -65,56 +65,70 @@ class TestFile < Test::Unit::TestCase
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)
[nil, {:textmode=>true}, {:binmode=>true}].each do |mode|
f = Tempfile.new("test-extended-file", mode)
assert_nil(f.getc)
open(f.path, "w") {|g| g.print "a" }
assert_equal("a", f.read)
end
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"))
[nil, {:textmode=>true}, {:binmode=>true}].each do |mode|
f = Tempfile.new("test-extended-file", mode)
assert_nil(f.getc)
open(f.path, "w") {|g| g.print "a" }
assert_equal("a", f.gets("a"))
end
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(""))
[nil, {:textmode=>true}, {:binmode=>true}].each do |mode|
f = Tempfile.new("test-extended-file")
assert_nil(f.getc)
open(f.path, "w") {|g| g.print "\na" }
assert_equal("a", f.gets(""))
end
end
def test_each_char_extended_file
f = Tempfile.new("test-extended-file")
assert_nil(f.getc)
open(f.path, "w") {|g| g.print "a" }
result = []
f.each_char {|b| result << b }
assert_equal([?a], result)
[nil, {:textmode=>true}, {:binmode=>true}].each do |mode|
f = Tempfile.new("test-extended-file")
assert_nil(f.getc)
open(f.path, "w") {|g| g.print "a" }
result = []
f.each_char {|b| result << b }
assert_equal([?a], result)
end
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.chr }
assert_equal([?a], result)
[nil, {:textmode=>true}, {:binmode=>true}].each do |mode|
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.chr }
assert_equal([?a], result)
end
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)
[nil, {:textmode=>true}, {:binmode=>true}].each do |mode|
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
def test_getbyte_extended_file
f = Tempfile.new("test-extended-file")
assert_nil(f.getc)
open(f.path, "w") {|g| g.print "a" }
assert_equal(?a, f.getbyte.chr)
[nil, {:textmode=>true}, {:binmode=>true}].each do |mode|
f = Tempfile.new("test-extended-file")
assert_nil(f.getc)
open(f.path, "w") {|g| g.print "a" }
assert_equal(?a, f.getbyte.chr)
end
end
def test_s_chown