diff options
author | Jeremy Evans <code@jeremyevans.net> | 2019-11-26 17:31:47 -0800 |
---|---|---|
committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2020-09-14 17:52:20 +0900 |
commit | d52dffd817d9285f7600138e2f69f46891fff845 (patch) | |
tree | 73a0c3b29b5dd48a499618307feead2c273f1441 /test/zlib/test_zlib.rb | |
parent | f1d32010e6e263ae94ee480a0d537727e91485ed (diff) |
[ruby/zlib] Add Zlib::GzipReader.zcat for handling multiple gzip streams in gz file
Most gzip tools support concatenated gz streams in a gz file. This
offers a way to handle such gz files in Ruby.
Fixes [Bug #9790]
Fixes [Bug #11180]
Fixes [Bug #14804]
https://github.com/ruby/zlib/commit/e2ce56de7d
Diffstat (limited to 'test/zlib/test_zlib.rb')
-rw-r--r-- | test/zlib/test_zlib.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/zlib/test_zlib.rb b/test/zlib/test_zlib.rb index 7d703d15e4..c58eafe112 100644 --- a/test/zlib/test_zlib.rb +++ b/test/zlib/test_zlib.rb @@ -446,6 +446,30 @@ if defined? Zlib end class TestZlibGzipFile < Test::Unit::TestCase + def test_gzip_reader_zcat + Tempfile.create("test_zlib_gzip_file_to_io") {|t| + gz = Zlib::GzipWriter.new(t) + gz.print("foo") + gz.close + t = File.open(t.path, 'ab') + gz = Zlib::GzipWriter.new(t) + gz.print("bar") + gz.close + + results = [] + t = File.open(t.path) + Zlib::GzipReader.zcat(t) do |str| + results << str + end + assert_equal(["foo", "bar"], results) + t.close + + t = File.open(t.path) + assert_equal("foobar", Zlib::GzipReader.zcat(t)) + t.close + } + end + def test_to_io Tempfile.create("test_zlib_gzip_file_to_io") {|t| t.close |