aboutsummaryrefslogtreecommitdiffstats
path: root/test/zlib
diff options
context:
space:
mode:
authornahi <nahi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-02-24 09:25:14 +0000
committernahi <nahi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-02-24 09:25:14 +0000
commitd77f31b6352799c7df440b81af4a91ad76734089 (patch)
treebcc113d791f24b9230d5e261320c06d0c0d6578d /test/zlib
parent79bd9c3e4da4418b8282fe1cd2a9709aa318ce94 (diff)
downloadruby-d77f31b6352799c7df440b81af4a91ad76734089.tar.gz
* test/zlib/test_zlib.rb (TestZlibGzipReader#test_encoding): Add
encoding testcases for GzipReader#read. read() emits Encoding.default_external in contrast to read(size) emits BINARY. See also: http://bugs.jruby.org/6208 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34790 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/zlib')
-rw-r--r--test/zlib/test_zlib.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/zlib/test_zlib.rb b/test/zlib/test_zlib.rb
index b526d24df9..1e3d77160c 100644
--- a/test/zlib/test_zlib.rb
+++ b/test/zlib/test_zlib.rb
@@ -749,6 +749,22 @@ if defined? Zlib
end
end
end
+
+ def test_encoding
+ t = Tempfile.new("test_zlib_gzip_reader_encoding")
+ t.binmode
+ content = (0..255).to_a.pack('c*')
+ Zlib::GzipWriter.wrap(t) {|gz| gz.print(content) }
+ t.close
+
+ read_all = Zlib::GzipReader.open(t.path) {|gz| gz.read }
+ assert_equal(Encoding.default_external, read_all.encoding)
+
+ # chunks are in BINARY regardless of encoding settings
+ read_size = Zlib::GzipReader.open(t.path) {|gz| gz.read(1024) }
+ assert_equal(Encoding::ASCII_8BIT, read_size.encoding)
+ assert_equal(content, read_size)
+ end
end
class TestZlibGzipWriter < Test::Unit::TestCase