summaryrefslogtreecommitdiff
path: root/test/cgi/test_cgi_util.rb
diff options
context:
space:
mode:
authormrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-01-23 01:09:06 +0000
committermrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-01-23 01:09:06 +0000
commit4c9968c9d9775a442346b0bd6d53e4bd95f69c15 (patch)
tree9a859f3d709883c1da09f640f3b71739478f0071 /test/cgi/test_cgi_util.rb
parentca516aad53c79bc9c92df98f2760c187d97072af (diff)
* test/cgi/test_cgi_util.rb (test_cgi_escape_preserve_encoding):
add a test for CGI::escape to preserve encoding. * test/cgi/test_cgi_util.rb (test_cgi_unescape_preserve_encoding): add a test for CGI::unescape to preserve encoding. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34357 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/cgi/test_cgi_util.rb')
-rw-r--r--test/cgi/test_cgi_util.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/cgi/test_cgi_util.rb b/test/cgi/test_cgi_util.rb
index f34703e..a291d47 100644
--- a/test/cgi/test_cgi_util.rb
+++ b/test/cgi/test_cgi_util.rb
@@ -30,12 +30,24 @@ class CGIUtilTest < Test::Unit::TestCase
end
end
+ def test_cgi_escape_preserve_encoding
+ assert_equal(Encoding::US_ASCII, CGI::escape("\xC0<<".force_encoding("US-ASCII")).encoding)
+ assert_equal(Encoding::ASCII_8BIT, CGI::escape("\xC0<<".force_encoding("ASCII-8BIT")).encoding)
+ assert_equal(Encoding::UTF_8, CGI::escape("\xC0<<".force_encoding("UTF-8")).encoding)
+ end
+
def test_cgi_unescape
assert_equal(@str1, CGI::unescape('%26%3C%3E%22+%E3%82%86%E3%82%93%E3%82%86%E3%82%93'))
assert_equal(@str1.encoding, CGI::unescape('%26%3C%3E%22+%E3%82%86%E3%82%93%E3%82%86%E3%82%93').encoding) if defined?(::Encoding)
assert_equal("\u{30E1 30E2 30EA 691C 7D22}", CGI.unescape("\u{30E1 30E2 30EA}%E6%A4%9C%E7%B4%A2"))
end
+ def test_cgi_unescape_preserve_encoding
+ assert_equal(Encoding::US_ASCII, CGI::unescape("%C0%3C%3C".force_encoding("US-ASCII")).encoding)
+ assert_equal(Encoding::ASCII_8BIT, CGI::unescape("%C0%3C%3C".force_encoding("ASCII-8BIT")).encoding)
+ assert_equal(Encoding::UTF_8, CGI::unescape("%C0%3C%3C".force_encoding("UTF-8")).encoding)
+ end
+
def test_cgi_pretty
assert_equal("<HTML>\n <BODY>\n </BODY>\n</HTML>\n",CGI::pretty("<HTML><BODY></BODY></HTML>"))
assert_equal("<HTML>\n\t<BODY>\n\t</BODY>\n</HTML>\n",CGI::pretty("<HTML><BODY></BODY></HTML>","\t"))