diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-04-22 02:27:17 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-04-22 02:27:17 +0000 |
commit | c37ac198fccdd896deefca469f800adf3341d1c3 (patch) | |
tree | 5fb1a717e5059ea3439f3a6e43e19ba4673b3639 | |
parent | 28747c6720c95fc6474bdda36b1df7a9b6b8b9dd (diff) | |
download | ruby-c37ac198fccdd896deefca469f800adf3341d1c3.tar.gz |
test_io.rb: test with holes
* test/ruby/test_io.rb (test_seek, test_seek_symwhence): add tests
of SEEK_DATA and SEEK_HOLE with holes.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45659 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | test/ruby/test_io.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb index b375754878..5f62fe11bc 100644 --- a/test/ruby/test_io.rb +++ b/test/ruby/test_io.rb @@ -1696,12 +1696,22 @@ class TestIO < Test::Unit::TestCase f.seek(0, IO::SEEK_DATA) assert_equal("foo\nbar\nbaz\n", f.read) } + open(t.path, 'r+') { |f| + pos = f.pos + f.seek(100*1024, IO::SEEK_SET) + f.print("zot\n") + f.seek(50*1024, IO::SEEK_DATA) + assert_operator(f.pos, :>=, 50*1024) + assert_match(/\A\0*zot\n\z/, f.read) + } end if defined?(IO::SEEK_HOLE) open(t.path) { |f| assert_equal("foo\n", f.gets) f.seek(0, IO::SEEK_HOLE) + assert_operator(f.pos, :>, 20) + f.seek(100*1024, IO::SEEK_HOLE) assert_equal("", f.read) } end @@ -1732,12 +1742,22 @@ class TestIO < Test::Unit::TestCase f.seek(0, :DATA) assert_equal("foo\nbar\nbaz\n", f.read) } + open(t.path, 'r+') { |f| + pos = f.pos + f.seek(100*1024, :SET) + f.print("zot\n") + f.seek(50*1024, :DATA) + assert_operator(f.pos, :>=, 50*1024) + assert_match(/\A\0*zot\n\z/, f.read) + } end if defined?(IO::SEEK_HOLE) open(t.path) { |f| assert_equal("foo\n", f.gets) f.seek(0, :HOLE) + assert_operator(f.pos, :>, 20) + f.seek(100*1024, :HOLE) assert_equal("", f.read) } end |