2003-12-04 21:54:48 -05:00
|
|
|
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)
|
* rubyio.h, intern.h, io.c, file.c, process.c, ext/socket/socket.c,
ext/pty/pty.c, ext/io/wait/wait.c, ext/openssl/ossl_ssl.c:
Use own buffering mechanism instead of stdio.
* io.c, ext/stringio/stringio.c, test/ruby/ut_eof.rb:
EOF flag removed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7473 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-12-06 03:40:30 -05:00
|
|
|
assert_equal("", f.read(0))
|
|
|
|
assert_equal("", f.read(0))
|
2003-12-04 21:54:48 -05:00
|
|
|
}
|
|
|
|
open_file("") {|f|
|
2003-12-10 05:29:00 -05:00
|
|
|
assert_nil(f.read(1))
|
2003-12-23 14:53:45 -05:00
|
|
|
assert_equal("", f.read)
|
2003-12-10 05:29:00 -05:00
|
|
|
assert_nil(f.read(1))
|
2003-12-04 21:54:48 -05:00
|
|
|
}
|
2003-12-24 00:23:32 -05:00
|
|
|
open_file("") {|f|
|
|
|
|
s = "x"
|
|
|
|
assert_equal("", f.read(nil, s))
|
|
|
|
assert_equal("", s)
|
|
|
|
}
|
|
|
|
open_file("") {|f|
|
|
|
|
s = "x"
|
|
|
|
assert_nil(f.read(10, s))
|
|
|
|
assert_equal("", s)
|
|
|
|
}
|
2003-12-04 21:54:48 -05:00
|
|
|
end
|
|
|
|
|
2003-12-09 00:33:32 -05:00
|
|
|
def test_eof_0_rw
|
|
|
|
return unless respond_to? :open_file_rw
|
|
|
|
open_file_rw("") {|f|
|
|
|
|
assert_equal("", f.read)
|
2003-12-23 14:53:45 -05:00
|
|
|
assert_equal("", f.read)
|
2003-12-09 00:33:32 -05:00
|
|
|
assert_equal(0, f.syswrite(""))
|
2003-12-23 14:53:45 -05:00
|
|
|
assert_equal("", f.read)
|
2003-12-09 00:33:32 -05:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2003-12-04 21:54:48 -05:00
|
|
|
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)
|
* rubyio.h, intern.h, io.c, file.c, process.c, ext/socket/socket.c,
ext/pty/pty.c, ext/io/wait/wait.c, ext/openssl/ossl_ssl.c:
Use own buffering mechanism instead of stdio.
* io.c, ext/stringio/stringio.c, test/ruby/ut_eof.rb:
EOF flag removed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7473 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-12-06 03:40:30 -05:00
|
|
|
assert_equal("", f.read(0))
|
|
|
|
assert_equal("", f.read(0))
|
2003-12-04 21:54:48 -05:00
|
|
|
}
|
|
|
|
open_file("a") {|f|
|
|
|
|
assert_equal("a", f.read(1))
|
2003-12-10 05:29:00 -05:00
|
|
|
assert_nil(f.read(1))
|
2003-12-04 21:54:48 -05:00
|
|
|
}
|
|
|
|
open_file("a") {|f|
|
|
|
|
assert_equal("a", f.read(2))
|
2003-12-10 05:29:00 -05:00
|
|
|
assert_nil(f.read(1))
|
2003-12-23 14:53:45 -05:00
|
|
|
assert_equal("", f.read)
|
2003-12-10 05:29:00 -05:00
|
|
|
assert_nil(f.read(1))
|
2003-12-04 21:54:48 -05:00
|
|
|
}
|
|
|
|
open_file("a") {|f|
|
|
|
|
assert_equal("a", f.read)
|
2003-12-10 05:29:00 -05:00
|
|
|
assert_nil(f.read(1))
|
2003-12-23 14:53:45 -05:00
|
|
|
assert_equal("", f.read)
|
2003-12-10 05:29:00 -05:00
|
|
|
assert_nil(f.read(1))
|
|
|
|
}
|
|
|
|
open_file("a") {|f|
|
|
|
|
assert_equal("a", f.read(2))
|
2003-12-23 14:53:45 -05:00
|
|
|
assert_equal("", f.read)
|
|
|
|
assert_equal("", f.read)
|
2003-12-10 05:29:00 -05:00
|
|
|
}
|
|
|
|
open_file("a") {|f|
|
|
|
|
assert_equal("a", f.read)
|
* rubyio.h, intern.h, io.c, file.c, process.c, ext/socket/socket.c,
ext/pty/pty.c, ext/io/wait/wait.c, ext/openssl/ossl_ssl.c:
Use own buffering mechanism instead of stdio.
* io.c, ext/stringio/stringio.c, test/ruby/ut_eof.rb:
EOF flag removed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7473 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-12-06 03:40:30 -05:00
|
|
|
assert_equal("", f.read(0))
|
2003-12-04 21:54:48 -05:00
|
|
|
}
|
2003-12-24 00:23:32 -05:00
|
|
|
open_file("a") {|f|
|
|
|
|
s = "x"
|
|
|
|
assert_equal("a", f.read(nil, s))
|
|
|
|
assert_equal("a", s)
|
|
|
|
}
|
|
|
|
open_file("a") {|f|
|
|
|
|
s = "x"
|
|
|
|
assert_equal("a", f.read(10, s))
|
|
|
|
assert_equal("a", s)
|
|
|
|
}
|
2003-12-04 21:54:48 -05:00
|
|
|
end
|
2003-12-10 03:16:14 -05:00
|
|
|
|
2005-03-05 16:36:11 -05:00
|
|
|
def test_eof_2
|
|
|
|
open_file("") {|f|
|
|
|
|
assert_equal("", f.read)
|
|
|
|
assert(f.eof?)
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_eof_3
|
|
|
|
open_file("") {|f|
|
|
|
|
assert(f.eof?)
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_eof_2
|
|
|
|
open_file("") {|f|
|
|
|
|
assert_equal("", f.read)
|
|
|
|
assert(f.eof?)
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_eof_3
|
|
|
|
open_file("") {|f|
|
|
|
|
assert(f.eof?)
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2003-12-10 03:16:14 -05:00
|
|
|
module Seek
|
|
|
|
def open_file_seek(content, pos)
|
|
|
|
open_file(content) do |f|
|
|
|
|
f.seek(pos)
|
|
|
|
yield f
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_eof_0_seek
|
|
|
|
open_file_seek("", 10) {|f|
|
2003-12-10 03:54:56 -05:00
|
|
|
assert_equal(10, f.pos)
|
|
|
|
assert_equal("", f.read(0))
|
2003-12-10 03:16:14 -05:00
|
|
|
assert_equal("", f.read)
|
* rubyio.h, intern.h, io.c, file.c, process.c, ext/socket/socket.c,
ext/pty/pty.c, ext/io/wait/wait.c, ext/openssl/ossl_ssl.c:
Use own buffering mechanism instead of stdio.
* io.c, ext/stringio/stringio.c, test/ruby/ut_eof.rb:
EOF flag removed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7473 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-12-06 03:40:30 -05:00
|
|
|
assert_equal("", f.read(0))
|
2003-12-23 14:53:45 -05:00
|
|
|
assert_equal("", f.read)
|
2003-12-10 03:16:14 -05:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_eof_1_seek
|
|
|
|
open_file_seek("a", 10) {|f|
|
|
|
|
assert_equal("", f.read)
|
2003-12-23 14:53:45 -05:00
|
|
|
assert_equal("", f.read)
|
2003-12-10 03:16:14 -05:00
|
|
|
}
|
|
|
|
open_file_seek("a", 1) {|f|
|
|
|
|
assert_equal("", f.read)
|
2003-12-23 14:53:45 -05:00
|
|
|
assert_equal("", f.read)
|
2003-12-10 03:16:14 -05:00
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
2003-12-04 21:54:48 -05:00
|
|
|
end
|