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
|
@ -31,7 +31,7 @@ class CGICoreTest < Test::Unit::TestCase
|
|||
}
|
||||
ENV.update(@environ)
|
||||
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"])
|
||||
end
|
||||
|
||||
|
@ -48,27 +48,6 @@ class CGICoreTest < Test::Unit::TestCase
|
|||
## cgi[]
|
||||
assert_equal('123', cgi['id'])
|
||||
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
|
||||
assert_equal(['123', '456', ''], cgi.params['id'])
|
||||
assert_equal(['@h =~ /^$/'], cgi.params['str'])
|
||||
|
@ -199,48 +178,8 @@ class CGICoreTest < Test::Unit::TestCase
|
|||
}
|
||||
ENV.update(@environ)
|
||||
cgi = CGI.new
|
||||
## jis, euc, sjis string
|
||||
jis_str = "\e$B8+$m!\"?M$,%4%_$N$h$&$@\e(B"
|
||||
## euc string
|
||||
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)
|
||||
options = { 'charset'=>'utf8' }
|
||||
$stdout = StringIO.new
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue