mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
7fbf13f7f2
* test/ruby/ut_eof.rb, test/ruby/test_file.rb, test/ruby/test_pipe.rb, test/stringio/test_stringio.rb: add EOF test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5115 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
46 lines
1.1 KiB
Ruby
46 lines
1.1 KiB
Ruby
require 'test/unit'
|
|
|
|
module TestEOF
|
|
def test_eof_0
|
|
open_file("") {|f|
|
|
assert_equal("", f.read(0))
|
|
assert_equal("", f.read(0))
|
|
assert_equal("", f.read)
|
|
assert_equal(nil, f.read(0))
|
|
assert_equal(nil, f.read(0))
|
|
}
|
|
open_file("") {|f|
|
|
assert_equal(nil, f.read(1))
|
|
assert_equal(nil, f.read)
|
|
assert_equal(nil, f.read(1))
|
|
}
|
|
end
|
|
|
|
def test_eof_1
|
|
open_file("a") {|f|
|
|
assert_equal("", f.read(0))
|
|
assert_equal("a", f.read(1))
|
|
assert_equal("" , f.read(0))
|
|
assert_equal("" , f.read(0))
|
|
assert_equal("", f.read)
|
|
assert_equal(nil, f.read(0))
|
|
assert_equal(nil, f.read(0))
|
|
}
|
|
open_file("a") {|f|
|
|
assert_equal("a", f.read(1))
|
|
assert_equal(nil, f.read(1))
|
|
}
|
|
open_file("a") {|f|
|
|
assert_equal("a", f.read(2))
|
|
assert_equal(nil, f.read(1))
|
|
assert_equal(nil, f.read)
|
|
assert_equal(nil, f.read(1))
|
|
}
|
|
open_file("a") {|f|
|
|
assert_equal("a", f.read)
|
|
assert_equal(nil, f.read(1))
|
|
assert_equal(nil, f.read)
|
|
assert_equal(nil, f.read(1))
|
|
}
|
|
end
|
|
end
|