diff options
author | Alan Wu <XrXr@users.noreply.github.com> | 2019-10-25 19:15:24 -0400 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2019-10-31 22:23:58 +0900 |
commit | 0aaa15f6362e307c9ef636e9625027b96e577dfb (patch) | |
tree | 79aaa8a72d1077b3621210810bc3a60ffe769bbb /test | |
parent | d6ed7a984c8fd991ce2614d2f228239f8eb490b5 (diff) | |
download | ruby-0aaa15f6362e307c9ef636e9625027b96e577dfb.tar.gz |
[ruby/zlib] Fix setting mtime to zero in GzipWriter
Before this change, it was not possible to write out zero for the
timestamp part of a Gzip file's header, as calling GzipWriter#mtime with
zero was ignored.
Judging from the docs for `GzipWriter#mtime=`, it should be possible to
indicate that no timestamp is available by calling the method with zero.
https://github.com/ruby/zlib/commit/310be39cac
Diffstat (limited to 'test')
-rw-r--r-- | test/zlib/test_zlib.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/test/zlib/test_zlib.rb b/test/zlib/test_zlib.rb index 7df53bd538..7d703d15e4 100644 --- a/test/zlib/test_zlib.rb +++ b/test/zlib/test_zlib.rb @@ -488,6 +488,17 @@ if defined? Zlib } end + def test_zero_mtime + sio = StringIO.new + gz = Zlib::GzipWriter.new(sio) + gz.mtime = 0 + gz.write("Hi") + gz.close + reading_io = StringIO.new(sio.string) + reader = Zlib::GzipReader.new(reading_io) + assert_equal(0, reader.mtime.to_i) + end + def test_level Tempfile.create("test_zlib_gzip_file_level") {|t| t.close |