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
This commit is contained in:
parent
c850c4ad37
commit
3408e9e3c3
@ -6,7 +6,7 @@ require "stringio"
|
|||||||
class TestProtocol < Test::Unit::TestCase
|
class TestProtocol < Test::Unit::TestCase
|
||||||
def test_should_properly_dot_stuff_period_with_no_endline
|
def test_should_properly_dot_stuff_period_with_no_endline
|
||||||
bug9627 = '[ruby-core:61441] [Bug #9627]'
|
bug9627 = '[ruby-core:61441] [Bug #9627]'
|
||||||
sio = StringIO.new
|
sio = StringIO.new("".dup)
|
||||||
imio = Net::InternetMessageIO.new(sio)
|
imio = Net::InternetMessageIO.new(sio)
|
||||||
email = "To: bob@aol.com\nlook, a period with no endline\n."
|
email = "To: bob@aol.com\nlook, a period with no endline\n."
|
||||||
imio.write_message(email)
|
imio.write_message(email)
|
||||||
@ -15,12 +15,12 @@ class TestProtocol < Test::Unit::TestCase
|
|||||||
|
|
||||||
def test_each_crlf_line
|
def test_each_crlf_line
|
||||||
assert_output('', '') do
|
assert_output('', '') do
|
||||||
sio = StringIO.new
|
sio = StringIO.new("".dup)
|
||||||
imio = Net::InternetMessageIO.new(sio)
|
imio = Net::InternetMessageIO.new(sio)
|
||||||
assert_equal(23, imio.write_message("\u3042\r\u3044\n\u3046\r\n\u3048"))
|
assert_equal(23, imio.write_message("\u3042\r\u3044\n\u3046\r\n\u3048"))
|
||||||
assert_equal("\u3042\r\n\u3044\r\n\u3046\r\n\u3048\r\n.\r\n", sio.string)
|
assert_equal("\u3042\r\n\u3044\r\n\u3046\r\n\u3048\r\n.\r\n", sio.string)
|
||||||
|
|
||||||
sio = StringIO.new
|
sio = StringIO.new("".dup)
|
||||||
imio = Net::InternetMessageIO.new(sio)
|
imio = Net::InternetMessageIO.new(sio)
|
||||||
assert_equal(8, imio.write_message("\u3042\r"))
|
assert_equal(8, imio.write_message("\u3042\r"))
|
||||||
assert_equal("\u3042\r\n.\r\n", sio.string)
|
assert_equal("\u3042\r\n.\r\n", sio.string)
|
||||||
|
@ -246,7 +246,7 @@ class TestOpenURI < Test::Unit::TestCase
|
|||||||
|
|
||||||
def test_proxy
|
def test_proxy
|
||||||
with_http {|srv, dr, url|
|
with_http {|srv, dr, url|
|
||||||
proxy_log = StringIO.new
|
proxy_log = StringIO.new(''.dup)
|
||||||
proxy_logger = WEBrick::Log.new(proxy_log, WEBrick::BasicLog::WARN)
|
proxy_logger = WEBrick::Log.new(proxy_log, WEBrick::BasicLog::WARN)
|
||||||
proxy_auth_log = ''.dup
|
proxy_auth_log = ''.dup
|
||||||
proxy = WEBrick::HTTPProxyServer.new({
|
proxy = WEBrick::HTTPProxyServer.new({
|
||||||
@ -300,7 +300,7 @@ class TestOpenURI < Test::Unit::TestCase
|
|||||||
|
|
||||||
def test_proxy_http_basic_authentication_failure
|
def test_proxy_http_basic_authentication_failure
|
||||||
with_http {|srv, dr, url|
|
with_http {|srv, dr, url|
|
||||||
proxy_log = StringIO.new
|
proxy_log = StringIO.new(''.dup)
|
||||||
proxy_logger = WEBrick::Log.new(proxy_log, WEBrick::BasicLog::WARN)
|
proxy_logger = WEBrick::Log.new(proxy_log, WEBrick::BasicLog::WARN)
|
||||||
proxy_auth_log = ''.dup
|
proxy_auth_log = ''.dup
|
||||||
proxy = WEBrick::HTTPProxyServer.new({
|
proxy = WEBrick::HTTPProxyServer.new({
|
||||||
@ -333,7 +333,7 @@ class TestOpenURI < Test::Unit::TestCase
|
|||||||
|
|
||||||
def test_proxy_http_basic_authentication_success
|
def test_proxy_http_basic_authentication_success
|
||||||
with_http {|srv, dr, url|
|
with_http {|srv, dr, url|
|
||||||
proxy_log = StringIO.new
|
proxy_log = StringIO.new(''.dup)
|
||||||
proxy_logger = WEBrick::Log.new(proxy_log, WEBrick::BasicLog::WARN)
|
proxy_logger = WEBrick::Log.new(proxy_log, WEBrick::BasicLog::WARN)
|
||||||
proxy_auth_log = ''.dup
|
proxy_auth_log = ''.dup
|
||||||
proxy = WEBrick::HTTPProxyServer.new({
|
proxy = WEBrick::HTTPProxyServer.new({
|
||||||
@ -374,7 +374,7 @@ class TestOpenURI < Test::Unit::TestCase
|
|||||||
|
|
||||||
def test_authenticated_proxy_http_basic_authentication_success
|
def test_authenticated_proxy_http_basic_authentication_success
|
||||||
with_http {|srv, dr, url|
|
with_http {|srv, dr, url|
|
||||||
proxy_log = StringIO.new
|
proxy_log = StringIO.new(''.dup)
|
||||||
proxy_logger = WEBrick::Log.new(proxy_log, WEBrick::BasicLog::WARN)
|
proxy_logger = WEBrick::Log.new(proxy_log, WEBrick::BasicLog::WARN)
|
||||||
proxy_auth_log = ''.dup
|
proxy_auth_log = ''.dup
|
||||||
proxy = WEBrick::HTTPProxyServer.new({
|
proxy = WEBrick::HTTPProxyServer.new({
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# coding: us-ascii
|
# coding: us-ascii
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: false
|
||||||
require 'test/unit'
|
require 'test/unit'
|
||||||
require 'stringio'
|
require 'stringio'
|
||||||
require 'tempfile'
|
require 'tempfile'
|
||||||
@ -42,7 +42,7 @@ if defined? Zlib
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_deflate_chunked
|
def test_deflate_chunked
|
||||||
original = String.new
|
original = ''
|
||||||
chunks = []
|
chunks = []
|
||||||
r = Random.new 0
|
r = Random.new 0
|
||||||
|
|
||||||
@ -315,7 +315,7 @@ if defined? Zlib
|
|||||||
|
|
||||||
z = Zlib::Inflate.new
|
z = Zlib::Inflate.new
|
||||||
|
|
||||||
inflated = String.new
|
inflated = ""
|
||||||
|
|
||||||
deflated.each_char do |byte|
|
deflated.each_char do |byte|
|
||||||
inflated << z.inflate(byte)
|
inflated << z.inflate(byte)
|
||||||
@ -603,13 +603,14 @@ if defined? Zlib
|
|||||||
assert_equal(t.path, f.path)
|
assert_equal(t.path, f.path)
|
||||||
end
|
end
|
||||||
|
|
||||||
sio = StringIO.new
|
s = ""
|
||||||
|
sio = StringIO.new(s)
|
||||||
gz = Zlib::GzipWriter.new(sio)
|
gz = Zlib::GzipWriter.new(sio)
|
||||||
gz.print("foo")
|
gz.print("foo")
|
||||||
assert_raise(NoMethodError) { gz.path }
|
assert_raise(NoMethodError) { gz.path }
|
||||||
gz.close
|
gz.close
|
||||||
|
|
||||||
sio = StringIO.new(sio.string)
|
sio = StringIO.new(s)
|
||||||
Zlib::GzipReader.new(sio) do |f|
|
Zlib::GzipReader.new(sio) do |f|
|
||||||
assert_raise(NoMethodError) { f.path }
|
assert_raise(NoMethodError) { f.path }
|
||||||
end
|
end
|
||||||
@ -624,11 +625,11 @@ if defined? Zlib
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_ungetc
|
def test_ungetc
|
||||||
sio = StringIO.new
|
s = ""
|
||||||
w = Zlib::GzipWriter.new(sio)
|
w = Zlib::GzipWriter.new(StringIO.new(s))
|
||||||
w << (1...1000).to_a.inspect
|
w << (1...1000).to_a.inspect
|
||||||
w.close
|
w.close
|
||||||
r = Zlib::GzipReader.new(StringIO.new(sio.string))
|
r = Zlib::GzipReader.new(StringIO.new(s))
|
||||||
r.read(100)
|
r.read(100)
|
||||||
r.ungetc ?a
|
r.ungetc ?a
|
||||||
assert_nothing_raised("[ruby-dev:24060]") {
|
assert_nothing_raised("[ruby-dev:24060]") {
|
||||||
@ -639,11 +640,11 @@ if defined? Zlib
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_ungetc_paragraph
|
def test_ungetc_paragraph
|
||||||
sio = StringIO.new
|
s = ""
|
||||||
w = Zlib::GzipWriter.new(sio)
|
w = Zlib::GzipWriter.new(StringIO.new(s))
|
||||||
w << "abc"
|
w << "abc"
|
||||||
w.close
|
w.close
|
||||||
r = Zlib::GzipReader.new(StringIO.new(sio.string))
|
r = Zlib::GzipReader.new(StringIO.new(s))
|
||||||
r.ungetc ?\n
|
r.ungetc ?\n
|
||||||
assert_equal("abc", r.gets(""))
|
assert_equal("abc", r.gets(""))
|
||||||
assert_nothing_raised("[ruby-dev:24065]") {
|
assert_nothing_raised("[ruby-dev:24065]") {
|
||||||
@ -777,7 +778,7 @@ if defined? Zlib
|
|||||||
end
|
end
|
||||||
|
|
||||||
Zlib::GzipReader.open(t.path) do |f|
|
Zlib::GzipReader.open(t.path) do |f|
|
||||||
s = String.new
|
s = ""
|
||||||
f.readpartial(3, s)
|
f.readpartial(3, s)
|
||||||
assert("foo".start_with?(s))
|
assert("foo".start_with?(s))
|
||||||
|
|
||||||
@ -937,9 +938,7 @@ if defined? Zlib
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_corrupted_header
|
def test_corrupted_header
|
||||||
sio = StringIO.new
|
gz = Zlib::GzipWriter.new(StringIO.new(s = ""))
|
||||||
s = sio.string
|
|
||||||
gz = Zlib::GzipWriter.new(sio)
|
|
||||||
gz.orig_name = "X"
|
gz.orig_name = "X"
|
||||||
gz.comment = "Y"
|
gz.comment = "Y"
|
||||||
gz.print("foo")
|
gz.print("foo")
|
||||||
@ -1121,7 +1120,7 @@ if defined? Zlib
|
|||||||
def test_deflate_stream
|
def test_deflate_stream
|
||||||
r = Random.new 0
|
r = Random.new 0
|
||||||
|
|
||||||
deflated = String.new
|
deflated = ''
|
||||||
|
|
||||||
Zlib.deflate(r.bytes(20000)) do |chunk|
|
Zlib.deflate(r.bytes(20000)) do |chunk|
|
||||||
deflated << chunk
|
deflated << chunk
|
||||||
|
Loading…
x
Reference in New Issue
Block a user