summaryrefslogtreecommitdiff
path: root/test/zlib
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-01-14 09:38:56 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-01-14 09:38:56 +0000
commit3408e9e3c30115e16fb482ac29f147fb64953ebd (patch)
tree7b97b87e1c275626b256ce2850acf5825c3b0bc2 /test/zlib
parentc850c4ad37573037a6c202acbd50150b48c356c8 (diff)
revert r57323
StringIO.new makes the buffer IO.default_external, while StringIO.new("".dup) makes source encoding which is defaulted to UTF-8. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57328 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/zlib')
-rw-r--r--test/zlib/test_zlib.rb31
1 files changed, 15 insertions, 16 deletions
diff --git a/test/zlib/test_zlib.rb b/test/zlib/test_zlib.rb
index 83cb238..68acc72 100644
--- a/test/zlib/test_zlib.rb
+++ b/test/zlib/test_zlib.rb
@@ -1,5 +1,5 @@
# coding: us-ascii
-# frozen_string_literal: true
+# frozen_string_literal: false
require 'test/unit'
require 'stringio'
require 'tempfile'
@@ -42,7 +42,7 @@ if defined? Zlib
end
def test_deflate_chunked
- original = String.new
+ original = ''
chunks = []
r = Random.new 0
@@ -315,7 +315,7 @@ if defined? Zlib
z = Zlib::Inflate.new
- inflated = String.new
+ inflated = ""
deflated.each_char do |byte|
inflated << z.inflate(byte)
@@ -603,13 +603,14 @@ if defined? Zlib
assert_equal(t.path, f.path)
end
- sio = StringIO.new
+ s = ""
+ sio = StringIO.new(s)
gz = Zlib::GzipWriter.new(sio)
gz.print("foo")
assert_raise(NoMethodError) { gz.path }
gz.close
- sio = StringIO.new(sio.string)
+ sio = StringIO.new(s)
Zlib::GzipReader.new(sio) do |f|
assert_raise(NoMethodError) { f.path }
end
@@ -624,11 +625,11 @@ if defined? Zlib
end
def test_ungetc
- sio = StringIO.new
- w = Zlib::GzipWriter.new(sio)
+ s = ""
+ w = Zlib::GzipWriter.new(StringIO.new(s))
w << (1...1000).to_a.inspect
w.close
- r = Zlib::GzipReader.new(StringIO.new(sio.string))
+ r = Zlib::GzipReader.new(StringIO.new(s))
r.read(100)
r.ungetc ?a
assert_nothing_raised("[ruby-dev:24060]") {
@@ -639,11 +640,11 @@ if defined? Zlib
end
def test_ungetc_paragraph
- sio = StringIO.new
- w = Zlib::GzipWriter.new(sio)
+ s = ""
+ w = Zlib::GzipWriter.new(StringIO.new(s))
w << "abc"
w.close
- r = Zlib::GzipReader.new(StringIO.new(sio.string))
+ r = Zlib::GzipReader.new(StringIO.new(s))
r.ungetc ?\n
assert_equal("abc", r.gets(""))
assert_nothing_raised("[ruby-dev:24065]") {
@@ -777,7 +778,7 @@ if defined? Zlib
end
Zlib::GzipReader.open(t.path) do |f|
- s = String.new
+ s = ""
f.readpartial(3, s)
assert("foo".start_with?(s))
@@ -937,9 +938,7 @@ if defined? Zlib
end
def test_corrupted_header
- sio = StringIO.new
- s = sio.string
- gz = Zlib::GzipWriter.new(sio)
+ gz = Zlib::GzipWriter.new(StringIO.new(s = ""))
gz.orig_name = "X"
gz.comment = "Y"
gz.print("foo")
@@ -1121,7 +1120,7 @@ if defined? Zlib
def test_deflate_stream
r = Random.new 0
- deflated = String.new
+ deflated = ''
Zlib.deflate(r.bytes(20000)) do |chunk|
deflated << chunk