Changeset 9184
- Timestamp:
- 04/01/08 05:32:11 (3 months ago)
- Files:
-
- trunk/actionmailer/test/quoting_test.rb (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/actionmailer/test/quoting_test.rb
r8666 r9184 5 5 6 6 class QuotingTest < Test::Unit::TestCase 7 8 7 # Move some tests from TMAIL here 9 8 def test_unquote_quoted_printable 10 a ="=?ISO-8859-1?Q?[166417]_Bekr=E6ftelse_fra_Rejsefeber?=" 9 a ="=?ISO-8859-1?Q?[166417]_Bekr=E6ftelse_fra_Rejsefeber?=" 11 10 b = TMail::Unquoter.unquote_and_convert_to(a, 'utf-8') 12 11 assert_equal "[166417] Bekr\303\246ftelse fra Rejsefeber", b … … 20 19 21 20 def test_unquote_without_charset 22 a ="[166417]_Bekr=E6ftelse_fra_Rejsefeber" 21 a ="[166417]_Bekr=E6ftelse_fra_Rejsefeber" 23 22 b = TMail::Unquoter.unquote_and_convert_to(a, 'utf-8') 24 23 assert_equal "[166417]_Bekr=E6ftelse_fra_Rejsefeber", b 25 end 26 24 end 25 27 26 def test_unqoute_multiple 28 a ="=?utf-8?q?Re=3A_=5B12=5D_=23137=3A_Inkonsistente_verwendung_von_=22Hin?==?utf-8?b?enVmw7xnZW4i?=" 27 a ="=?utf-8?q?Re=3A_=5B12=5D_=23137=3A_Inkonsistente_verwendung_von_=22Hin?==?utf-8?b?enVmw7xnZW4i?=" 29 28 b = TMail::Unquoter.unquote_and_convert_to(a, 'utf-8') 30 29 assert_equal "Re: [12] #137: Inkonsistente verwendung von \"Hinzuf\303\274gen\"", b 31 30 end 32 31 33 32 def test_unqoute_in_the_middle 34 a ="Re: Photos =?ISO-8859-1?Q?Brosch=FCre_Rand?=" 33 a ="Re: Photos =?ISO-8859-1?Q?Brosch=FCre_Rand?=" 35 34 b = TMail::Unquoter.unquote_and_convert_to(a, 'utf-8') 36 35 assert_equal "Re: Photos Brosch\303\274re Rand", b 37 36 end 38 37 39 38 def test_unqoute_iso 40 a ="=?ISO-8859-1?Q?Brosch=FCre_Rand?=" 39 a ="=?ISO-8859-1?Q?Brosch=FCre_Rand?=" 41 40 b = TMail::Unquoter.unquote_and_convert_to(a, 'iso-8859-1') 42 41 expected = "Brosch\374re Rand" … … 44 43 assert_equal expected, b 45 44 end 46 45 47 46 def test_quote_multibyte_chars 48 47 original = "\303\246 \303\270 and \303\245" 49 original.force_encoding nilif original.respond_to?(:force_encoding)48 original.force_encoding('ASCII-8BIT') if original.respond_to?(:force_encoding) 50 49 51 50 result = execute_in_sandbox(<<-CODE) … … 61 60 assert_equal unquoted, original 62 61 end 63 64 62 63 65 64 # test an email that has been created using \r\n newlines, instead of 66 65 # \n newlines. … … 74 73 assert_equal "Re: Test: \"\346\274\242\345\255\227\" mid \"\346\274\242\345\255\227\" tail", mail.subject 75 74 end 76 75 77 76 def test_decode 78 77 encoded, decoded = expected_base64_strings 79 78 assert_equal decoded, TMail::Base64.decode(encoded) 80 79 end 81 80 82 81 def test_encode 83 82 encoded, decoded = expected_base64_strings 84 83 assert_equal encoded.length, TMail::Base64.encode(decoded).length 85 84 end 86 85 87 86 private 88 87 89 88 # This whole thing *could* be much simpler, but I don't think Tempfile, 90 89 # popen and others exist on all platforms (like Windows). … … 108 107 File.delete(res_name) rescue nil 109 108 end 110 109 111 110 def expected_base64_strings 112 111 [ File.read("#{File.dirname(__FILE__)}/fixtures/raw_base64_encoded_string"), File.read("#{File.dirname(__FILE__)}/fixtures/raw_base64_decoded_string") ] 113 112 end 114 113 end 115