From 01e1a0ac78217f912115df046f5ae07dc146176f Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 7 Jul 2010 02:44:04 +0000 Subject: * ext/zlib/zlib.c (gzfile_raise): add invalid header to exceptions. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28562 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/zlib/test_zlib.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'test/zlib/test_zlib.rb') diff --git a/test/zlib/test_zlib.rb b/test/zlib/test_zlib.rb index 6b13cf6026..e8fa2f63f9 100644 --- a/test/zlib/test_zlib.rb +++ b/test/zlib/test_zlib.rb @@ -431,6 +431,24 @@ if defined? Zlib def test_open t = Tempfile.new("test_zlib_gzip_reader") t.close + e = assert_raise(Zlib::GzipFile::Error) { + Zlib::GzipReader.open(t.path) + } + assert_equal("not in gzip format", e.message) + assert_nil(e.input) + open(t.path, "wb") {|f| f.write("foo")} + e = assert_raise(Zlib::GzipFile::Error) { + Zlib::GzipReader.open(t.path) + } + assert_equal("not in gzip format", e.message) + assert_equal("foo", e.input) + open(t.path, "wb") {|f| f.write("foobarzothoge")} + e = assert_raise(Zlib::GzipFile::Error) { + Zlib::GzipReader.open(t.path) + } + assert_equal("not in gzip format", e.message) + assert_equal("foobarzothoge", e.input) + Zlib::GzipWriter.open(t.path) {|gz| gz.print("foo") } assert_raise(ArgumentError) { Zlib::GzipReader.open } -- cgit v1.2.3