summaryrefslogtreecommitdiff
path: root/test/net/imap
diff options
context:
space:
mode:
authorshugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-05-09 07:03:19 +0000
committershugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-05-09 07:03:19 +0000
commit2e63cd97c1a1acf7cd93976c7e7531c46901e1d2 (patch)
tree262f229733c0cb00e9152968cea8c0deebb1924d /test/net/imap
parente62c35fb8f7bc9fd9bc7e99a603da492fc89d21c (diff)
* lib/net/imap.rb (decode_utf7, encode_utf7): refactored by
Nobuyoshi Nakada, to use String#encode. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35604 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/net/imap')
-rw-r--r--test/net/imap/test_imap.rb14
1 files changed, 12 insertions, 2 deletions
diff --git a/test/net/imap/test_imap.rb b/test/net/imap/test_imap.rb
index 0feabb91084..9484ab8f6c4 100644
--- a/test/net/imap/test_imap.rb
+++ b/test/net/imap/test_imap.rb
@@ -18,16 +18,26 @@ class IMAPTest < Test::Unit::TestCase
end
def test_encode_utf7
+ assert_equal("foo", Net::IMAP.encode_utf7("foo"))
+ assert_equal("&-", Net::IMAP.encode_utf7("&"))
+
utf8 = "\357\274\241\357\274\242\357\274\243".force_encoding("UTF-8")
s = Net::IMAP.encode_utf7(utf8)
- assert_equal("&,yH,Iv8j-".force_encoding("UTF-8"), s)
+ assert_equal("&,yH,Iv8j-", s)
+ s = Net::IMAP.encode_utf7("foo&#{utf8}-bar".encode("EUC-JP"))
+ assert_equal("foo&-&,yH,Iv8j--bar", s)
utf8 = "\343\201\202&".force_encoding("UTF-8")
s = Net::IMAP.encode_utf7(utf8)
- assert_equal("&MEI-&-".force_encoding("UTF-8"), s)
+ assert_equal("&MEI-&-", s)
+ s = Net::IMAP.encode_utf7(utf8.encode("EUC-JP"))
+ assert_equal("&MEI-&-", s)
end
def test_decode_utf7
+ assert_equal("&", Net::IMAP.decode_utf7("&-"))
+ assert_equal("&-", Net::IMAP.decode_utf7("&--"))
+
s = Net::IMAP.decode_utf7("&,yH,Iv8j-")
utf8 = "\357\274\241\357\274\242\357\274\243".force_encoding("UTF-8")
assert_equal(utf8, s)