mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* test/cgi/test_cgi_core.rb: removed obsoleted condition for Ruby 1.8.
* test/cgi/test_cgi_header.rb: ditto. * test/cgi/test_cgi_multipart.rb: ditto. * test/cgi/test_cgi_tag_helper.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47110 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
8a1463beba
commit
556f805493
5 changed files with 28 additions and 92 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
Sat Aug 9 10:18:00 2014 SHIBATA Hiroshi <shibata.hiroshi@gmail.com>
|
||||||
|
|
||||||
|
* test/cgi/test_cgi_core.rb: removed obsoleted condition for Ruby 1.8.
|
||||||
|
* test/cgi/test_cgi_header.rb: ditto.
|
||||||
|
* test/cgi/test_cgi_multipart.rb: ditto.
|
||||||
|
* test/cgi/test_cgi_tag_helper.rb: ditto.
|
||||||
|
|
||||||
Sat Aug 9 00:34:37 2014 Masaki Suketa <masaki.suketa@nifty.ne.jp>
|
Sat Aug 9 00:34:37 2014 Masaki Suketa <masaki.suketa@nifty.ne.jp>
|
||||||
|
|
||||||
* ext/win32ole/win32ole.c: separate WIN32OLE_TYPE src from win32ole.c.
|
* ext/win32ole/win32ole.c: separate WIN32OLE_TYPE src from win32ole.c.
|
||||||
|
|
|
@ -31,7 +31,7 @@ class CGICoreTest < Test::Unit::TestCase
|
||||||
}
|
}
|
||||||
ENV.update(@environ)
|
ENV.update(@environ)
|
||||||
cgi = CGI.new
|
cgi = CGI.new
|
||||||
assert_equal(["a","b","c","d"],cgi.keys.sort) if RUBY_VERSION>="1.9"
|
assert_equal(["a","b","c","d"],cgi.keys.sort)
|
||||||
assert_equal("",cgi["d"])
|
assert_equal("",cgi["d"])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -48,27 +48,6 @@ class CGICoreTest < Test::Unit::TestCase
|
||||||
## cgi[]
|
## cgi[]
|
||||||
assert_equal('123', cgi['id'])
|
assert_equal('123', cgi['id'])
|
||||||
assert_equal('@h =~ /^$/', cgi['str'])
|
assert_equal('@h =~ /^$/', cgi['str'])
|
||||||
## cgi[][], cgi[].first, cgi[].to_ary (obsolete 1.9)
|
|
||||||
if RUBY_VERSION<"1.9"
|
|
||||||
$stderr = StringIO.new
|
|
||||||
begin
|
|
||||||
assert_equal('123', cgi['id'][0])
|
|
||||||
assert_equal('456', cgi['id'][1])
|
|
||||||
assert_equal('', cgi['id'][2])
|
|
||||||
assert_nil(cgi['id'][3])
|
|
||||||
assert_equal('@h =~ /^$/', cgi['str'][0])
|
|
||||||
assert_nil(cgi['str'][1])
|
|
||||||
assert_equal('123', cgi['id'].first)
|
|
||||||
assert_equal('123', cgi['id'].last) # should be '' ?
|
|
||||||
id1, id2, id3 = cgi['id']
|
|
||||||
assert_equal(['123', '456', ''], [id1, id2, id3])
|
|
||||||
str1, = cgi['str']
|
|
||||||
assert_equal('@h =~ /^$/', str1)
|
|
||||||
assert_not_same(str1, cgi['str']) # necessary?
|
|
||||||
ensure
|
|
||||||
$stderr = STDERR
|
|
||||||
end
|
|
||||||
end
|
|
||||||
## cgi.params
|
## cgi.params
|
||||||
assert_equal(['123', '456', ''], cgi.params['id'])
|
assert_equal(['123', '456', ''], cgi.params['id'])
|
||||||
assert_equal(['@h =~ /^$/'], cgi.params['str'])
|
assert_equal(['@h =~ /^$/'], cgi.params['str'])
|
||||||
|
@ -199,48 +178,8 @@ class CGICoreTest < Test::Unit::TestCase
|
||||||
}
|
}
|
||||||
ENV.update(@environ)
|
ENV.update(@environ)
|
||||||
cgi = CGI.new
|
cgi = CGI.new
|
||||||
## jis, euc, sjis string
|
## euc string
|
||||||
jis_str = "\e$B8+$m!\"?M$,%4%_$N$h$&$@\e(B"
|
|
||||||
euc_str = "\270\253\244\355\241\242\277\315\244\254\245\264\245\337\244\316\244\350\244\246\244\300"
|
euc_str = "\270\253\244\355\241\242\277\315\244\254\245\264\245\337\244\316\244\350\244\246\244\300"
|
||||||
sjis_str = "\214\251\202\353\201A\220l\202\252\203S\203~\202\314\202\346\202\244\202\276"
|
|
||||||
if RUBY_VERSION<"1.9"
|
|
||||||
## iso-2022-jp
|
|
||||||
options = { 'charset'=>'iso-2022-jp' }
|
|
||||||
$stdout = StringIO.new
|
|
||||||
cgi.out(options) { euc_str }
|
|
||||||
assert_equal('ja', options['language'])
|
|
||||||
actual = $stdout.string
|
|
||||||
expected = "Content-Type: text/html; charset=iso-2022-jp\r\n" +
|
|
||||||
"Content-Length: 28\r\n" +
|
|
||||||
"Content-Language: ja\r\n" +
|
|
||||||
"\r\n" +
|
|
||||||
jis_str
|
|
||||||
assert_equal(expected,actual)
|
|
||||||
## euc-jp
|
|
||||||
options = { 'charset'=>'EUC-JP' }
|
|
||||||
$stdout = StringIO.new
|
|
||||||
cgi.out(options) { euc_str }
|
|
||||||
assert_equal('ja', options['language'])
|
|
||||||
actual = $stdout.string
|
|
||||||
expected = "Content-Type: text/html; charset=EUC-JP\r\n" +
|
|
||||||
"Content-Length: 22\r\n" +
|
|
||||||
"Content-Language: ja\r\n" +
|
|
||||||
"\r\n" +
|
|
||||||
euc_str
|
|
||||||
assert_equal(expected, actual)
|
|
||||||
## shift_jis
|
|
||||||
options = { 'charset'=>'Shift_JIS' }
|
|
||||||
$stdout = StringIO.new
|
|
||||||
cgi.out(options) { euc_str }
|
|
||||||
assert_equal('ja', options['language'])
|
|
||||||
actual = $stdout.string
|
|
||||||
expected = "Content-Type: text/html; charset=Shift_JIS\r\n" +
|
|
||||||
"Content-Length: 22\r\n" +
|
|
||||||
"Content-Language: ja\r\n" +
|
|
||||||
"\r\n" +
|
|
||||||
sjis_str
|
|
||||||
assert_equal(expected, actual)
|
|
||||||
end
|
|
||||||
## utf8 (not converted)
|
## utf8 (not converted)
|
||||||
options = { 'charset'=>'utf8' }
|
options = { 'charset'=>'utf8' }
|
||||||
$stdout = StringIO.new
|
$stdout = StringIO.new
|
||||||
|
|
|
@ -71,12 +71,8 @@ class CGIHeaderTest < Test::Unit::TestCase
|
||||||
|
|
||||||
def test_cgi_http_header_argerr
|
def test_cgi_http_header_argerr
|
||||||
cgi = CGI.new
|
cgi = CGI.new
|
||||||
#expected = NoMethodError # must be ArgumentError
|
expected = ArgumentError
|
||||||
if RUBY_VERSION>="1.9.0"
|
|
||||||
expected = ArgumentError # for CGIAlt
|
|
||||||
else
|
|
||||||
expected = NoMethodError # for Ruby1.8
|
|
||||||
end
|
|
||||||
assert_raise(expected) do
|
assert_raise(expected) do
|
||||||
cgi.http_header(nil)
|
cgi.http_header(nil)
|
||||||
end
|
end
|
||||||
|
|
|
@ -152,14 +152,13 @@ class CGIMultipartTest < Test::Unit::TestCase
|
||||||
_prepare(@data)
|
_prepare(@data)
|
||||||
options = {:accept_charset=>"UTF-8"}
|
options = {:accept_charset=>"UTF-8"}
|
||||||
options.merge! cgi_options
|
options.merge! cgi_options
|
||||||
cgi = RUBY_VERSION>="1.9" ? CGI.new(options) : CGI.new
|
cgi = CGI.new(options)
|
||||||
expected_names = @data.collect{|hash| hash[:name] }.sort
|
expected_names = @data.collect{|hash| hash[:name] }.sort
|
||||||
assert_equal(expected_names, cgi.params.keys.sort)
|
assert_equal(expected_names, cgi.params.keys.sort)
|
||||||
threshold = 1024*10
|
threshold = 1024*10
|
||||||
@data.each do |hash|
|
@data.each do |hash|
|
||||||
name = hash[:name]
|
name = hash[:name]
|
||||||
expected = hash[:value]
|
expected = hash[:value]
|
||||||
if RUBY_VERSION>="1.9"
|
|
||||||
if hash[:filename] #if file
|
if hash[:filename] #if file
|
||||||
expected_class = @expected_class || (hash[:value].length < threshold ? StringIO : Tempfile)
|
expected_class = @expected_class || (hash[:value].length < threshold ? StringIO : Tempfile)
|
||||||
assert(cgi.files.keys.member?(hash[:name]))
|
assert(cgi.files.keys.member?(hash[:name]))
|
||||||
|
@ -168,9 +167,6 @@ class CGIMultipartTest < Test::Unit::TestCase
|
||||||
assert_equal(expected, cgi[name])
|
assert_equal(expected, cgi[name])
|
||||||
assert_equal(false,cgi.files.keys.member?(hash[:name]))
|
assert_equal(false,cgi.files.keys.member?(hash[:name]))
|
||||||
end
|
end
|
||||||
else
|
|
||||||
expected_class = @expected_class || (hash[:value].length < threshold ? StringIO : Tempfile)
|
|
||||||
end
|
|
||||||
assert_kind_of(expected_class, cgi[name])
|
assert_kind_of(expected_class, cgi[name])
|
||||||
assert_equal(expected, cgi[name].read())
|
assert_equal(expected, cgi[name].read())
|
||||||
assert_equal(hash[:filename] || '', cgi[name].original_filename) #if hash[:filename]
|
assert_equal(hash[:filename] || '', cgi[name].original_filename) #if hash[:filename]
|
||||||
|
@ -301,7 +297,7 @@ class CGIMultipartTest < Test::Unit::TestCase
|
||||||
input2
|
input2
|
||||||
end
|
end
|
||||||
ex = assert_raise(EOFError) do
|
ex = assert_raise(EOFError) do
|
||||||
RUBY_VERSION>="1.9" ? CGI.new(:accept_charset=>"UTF-8") : CGI.new
|
CGI.new(:accept_charset=>"UTF-8")
|
||||||
end
|
end
|
||||||
assert_equal("bad content body", ex.message)
|
assert_equal("bad content body", ex.message)
|
||||||
#
|
#
|
||||||
|
@ -312,7 +308,7 @@ class CGIMultipartTest < Test::Unit::TestCase
|
||||||
input2
|
input2
|
||||||
end
|
end
|
||||||
ex = assert_raise(EOFError) do
|
ex = assert_raise(EOFError) do
|
||||||
RUBY_VERSION>="1.9" ? CGI.new(:accept_charset=>"UTF-8") : CGI.new
|
CGI.new(:accept_charset=>"UTF-8")
|
||||||
end
|
end
|
||||||
assert_equal("bad content body", ex.message)
|
assert_equal("bad content body", ex.message)
|
||||||
end
|
end
|
||||||
|
@ -328,9 +324,9 @@ class CGIMultipartTest < Test::Unit::TestCase
|
||||||
{:name=>'image1', :value=>_read('small.png'),
|
{:name=>'image1', :value=>_read('small.png'),
|
||||||
:filename=>'small.png', :content_type=>'image/png'}, # small image
|
:filename=>'small.png', :content_type=>'image/png'}, # small image
|
||||||
]
|
]
|
||||||
@data[1][:value].force_encoding("UTF-8") if RUBY_VERSION>="1.9"
|
@data[1][:value].force_encoding("UTF-8")
|
||||||
_prepare(@data)
|
_prepare(@data)
|
||||||
cgi = RUBY_VERSION>="1.9" ? CGI.new(:accept_charset=>"UTF-8") : CGI.new
|
cgi = CGI.new(:accept_charset=>"UTF-8")
|
||||||
assert_equal('file1.html', cgi['file1'].original_filename)
|
assert_equal('file1.html', cgi['file1'].original_filename)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -342,7 +338,7 @@ class CGIMultipartTest < Test::Unit::TestCase
|
||||||
{:name=>'foo', :value=>"bar"},
|
{:name=>'foo', :value=>"bar"},
|
||||||
]
|
]
|
||||||
_prepare(@data)
|
_prepare(@data)
|
||||||
cgi = RUBY_VERSION>="1.9" ? CGI.new(:accept_charset=>"UTF-8") : CGI.new
|
cgi = CGI.new(:accept_charset=>"UTF-8")
|
||||||
assert_equal(cgi['foo'], 'bar')
|
assert_equal(cgi['foo'], 'bar')
|
||||||
assert_equal(cgi['file'].read, 'b'*10134)
|
assert_equal(cgi['file'].read, 'b'*10134)
|
||||||
cgi['file'].close! if cgi['file'].kind_of? Tempfile
|
cgi['file'].close! if cgi['file'].kind_of? Tempfile
|
||||||
|
|
|
@ -318,14 +318,12 @@ class CGITagHelperTest < Test::Unit::TestCase
|
||||||
assert_match(/^<INPUT .*TYPE="checkbox".*>bb<INPUT .*TYPE="checkbox".*>dd$/,str)
|
assert_match(/^<INPUT .*TYPE="checkbox".*>bb<INPUT .*TYPE="checkbox".*>dd$/,str)
|
||||||
assert_match(/^<INPUT .*NAME="foo".*>bb<INPUT .*NAME="foo".*>dd$/,str)
|
assert_match(/^<INPUT .*NAME="foo".*>bb<INPUT .*NAME="foo".*>dd$/,str)
|
||||||
assert_match(/^<INPUT .*>bb<INPUT .*CHECKED.*>dd$/,str)
|
assert_match(/^<INPUT .*>bb<INPUT .*CHECKED.*>dd$/,str)
|
||||||
assert_match(/<INPUT .*TYPE="text".*>/,cgi.text_field(:name=>"name",:value=>"value")) if RUBY_VERSION>="1.9"
|
assert_match(/<INPUT .*TYPE="text".*>/,cgi.text_field(:name=>"name",:value=>"value"))
|
||||||
if RUBY_VERSION>="1.9"
|
|
||||||
str=cgi.radio_group("foo",["aa","bb"],["cc","dd",false])
|
str=cgi.radio_group("foo",["aa","bb"],["cc","dd",false])
|
||||||
assert_match(/^<INPUT .*VALUE="aa".*>bb<INPUT .*VALUE="cc".*>dd$/,str)
|
assert_match(/^<INPUT .*VALUE="aa".*>bb<INPUT .*VALUE="cc".*>dd$/,str)
|
||||||
assert_match(/^<INPUT .*TYPE="radio".*>bb<INPUT .*TYPE="radio".*>dd$/,str)
|
assert_match(/^<INPUT .*TYPE="radio".*>bb<INPUT .*TYPE="radio".*>dd$/,str)
|
||||||
assert_match(/^<INPUT .*NAME="foo".*>bb<INPUT .*NAME="foo".*>dd$/,str)
|
assert_match(/^<INPUT .*NAME="foo".*>bb<INPUT .*NAME="foo".*>dd$/,str)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
=begin
|
=begin
|
||||||
def test_cgi_tag_helper_html4
|
def test_cgi_tag_helper_html4
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue