[前][次][番号順一覧][スレッド一覧]

ruby-changes:33578

From: nobu <ko1@a...>
Date: Tue, 22 Apr 2014 11:27:23 +0900 (JST)
Subject: [ruby-changes:33578] nobu:r45659 (trunk): test_io.rb: test with holes

nobu	2014-04-22 11:27:17 +0900 (Tue, 22 Apr 2014)

  New Revision: 45659

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=45659

  Log:
    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.

  Modified files:
    trunk/test/ruby/test_io.rb
Index: test/ruby/test_io.rb
===================================================================
--- test/ruby/test_io.rb	(revision 45658)
+++ test/ruby/test_io.rb	(revision 45659)
@@ -1696,12 +1696,22 @@ class TestIO < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_io.rb#L1696
           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 https://github.com/ruby/ruby/blob/trunk/test/ruby/test_io.rb#L1742
           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

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]