summaryrefslogtreecommitdiff
path: root/test/zlib/test_zlib.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-07-07 02:44:04 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-07-07 02:44:04 +0000
commit01e1a0ac78217f912115df046f5ae07dc146176f (patch)
tree3413d2e1caf816e2078f725a5b3adf08f0af9900 /test/zlib/test_zlib.rb
parent8ff0574198d1d32c7f80044c611d54f6e3b1aace (diff)
* 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
Diffstat (limited to 'test/zlib/test_zlib.rb')
-rw-r--r--test/zlib/test_zlib.rb18
1 files changed, 18 insertions, 0 deletions
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 }