summaryrefslogtreecommitdiff
path: root/test/zlib/test_zlib.rb
diff options
context:
space:
mode:
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 }