summaryrefslogtreecommitdiff
path: root/test/zlib
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-02-03 09:56:52 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-02-03 09:56:52 +0000
commitb4940b61e35d579639fd48912d03d4f731a45aef (patch)
treeca20b3ecd8ee83ed81ed10816ad3c03df0292edb /test/zlib
parentd6d24991bdd894f92681960117aaf0393866434b (diff)
e ext/zlib/zlib.c (gzfile_reader_get_unused): use rb_str_resurrect
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30773 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/zlib')
-rw-r--r--test/zlib/test_zlib.rb32
1 files changed, 30 insertions, 2 deletions
diff --git a/test/zlib/test_zlib.rb b/test/zlib/test_zlib.rb
index 68b44a1..8235223 100644
--- a/test/zlib/test_zlib.rb
+++ b/test/zlib/test_zlib.rb
@@ -491,13 +491,41 @@ if defined? Zlib
Zlib::GzipWriter.open(t.path) {|gz| gz.print("foobar") }
Zlib::GzipReader.open(t.path) do |f|
+ assert_equal(nil, f.unused)
assert_equal("foo", f.read(3))
- f.unused
+ assert_equal(nil, f.unused)
assert_equal("bar", f.read)
- f.unused
+ assert_equal(nil, f.unused)
end
end
+ def test_unused2
+ zio = StringIO.new
+
+ io = Zlib::GzipWriter.new zio
+ io.write 'aaaa'
+ io.finish
+
+ io = Zlib::GzipWriter.new zio
+ io.write 'bbbb'
+ io.finish
+
+ zio.rewind
+
+ io = Zlib::GzipReader.new zio
+ assert_equal('aaaa', io.read)
+ unused = io.unused
+ assert_equal(24, unused.bytesize)
+ io.finish
+
+ zio.pos -= unused.length
+
+ io = Zlib::GzipReader.new zio
+ assert_equal('bbbb', io.read)
+ assert_equal(nil, io.unused)
+ io.finish
+ end
+
def test_read
t = Tempfile.new("test_zlib_gzip_reader_read")
t.close