ruby-changes:22741
From: nahi <ko1@a...>
Date: Fri, 24 Feb 2012 18:26:26 +0900 (JST)
Subject: [ruby-changes:22741] nahi:r34790 (trunk): * test/zlib/test_zlib.rb (TestZlibGzipReader#test_encoding): Add
nahi 2012-02-24 18:25:14 +0900 (Fri, 24 Feb 2012) New Revision: 34790 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=34790 Log: * 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 Modified files: trunk/ChangeLog trunk/test/zlib/test_zlib.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 34789) +++ ChangeLog (revision 34790) @@ -1,3 +1,10 @@ +Fri Feb 24 18:21:55 2012 Hiroshi Nakamura <nahi@r...> + + * 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 + Fri Feb 24 17:56:39 2012 URABE Shyouhei <shyouhei@r...> * test/ruby/test_literal.rb (TestRubyLiteral#test_special_const): Index: test/zlib/test_zlib.rb =================================================================== --- test/zlib/test_zlib.rb (revision 34789) +++ test/zlib/test_zlib.rb (revision 34790) @@ -749,6 +749,22 @@ 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/