Sha256: e75f76221b1bf1f668d33fffd55d9861f414afe60aa7719ad35b05836211a465

Contents?: true

Size: 1.19 KB

Versions: 16

Compression:

Stored size: 1.19 KB

Contents

$:.unshift File.dirname(__FILE__)
require 'test_helper'
require 'tmail'
require 'kcode'
require 'time'

class TestMail < Test::Unit::TestCase
  include TMail::TextUtils

  def setup
    @mail = TMail::Mail.new
  end

  def lf( str )
    str.gsub(/\n|\r\n|\r/) { "\n" }
  end

  def crlf( str )
    str.gsub(/\n|\r\n|\r/) { "\r\n" }
  end

  def test_MIME
    # FIXME: test more.
    
    kcode('EUC') {
      mail = TMail::Mail.parse('From: hoge@example.jp (=?iso-2022-jp?B?GyRCJUYlOSVIGyhC?=)')
      assert_not_nil mail['From']
      
      expected = "\245\306\245\271\245\310"
      if expected.respond_to? :force_encoding
        expected.force_encoding(mail['From'].comments.first.encoding)
      end
      assert_equal [expected], mail['From'].comments

      expected = "From: hoge@example.jp (\245\306\245\271\245\310)\n\n"
      expected.force_encoding 'EUC-JP' if expected.respond_to? :force_encoding
      assert_equal expected, mail.to_s
      assert_equal expected, mail.decoded

      expected = "From: hoge@example.jp (=?iso-2022-jp?B?GyRCJUYlOSVIGyhC?=)\r\n\r\n"
      expected.force_encoding 'EUC-JP' if expected.respond_to? :force_encoding
      assert_equal expected, mail.encoded
    }
  end

end

Version data entries

16 entries across 16 versions & 8 rubygems

Version Path
tmail_es-1.2.7.3 test/temp_test_one.rb
tmail_es-1.2.7.2 test/temp_test_one.rb
bjornblomqvist-tmail-0.0.1 test/temp_test_one.rb
bjornblomqvist-tmail-0.0.2 test/temp_test_one.rb
japetheape-tmail-1.2.3.4 test/temp_test_one.rb
ledermann-tmail-1.2.5 test/temp_test_one.rb
valodzka-tmail-1.2.3.2 test/temp_test_one.rb
valodzka-tmail-1.2.3.3 test/temp_test_one.rb
valodzka-valodzka-tmail-1.2.3.2 test/temp_test_one.rb
tmail-1.2.7.1 test/temp_test_one.rb
tmail-1.2.7 test/temp_test_one.rb
tmail-1.2.6 test/temp_test_one.rb
sa-tmail-1.2.5.1 test/temp_test_one.rb
tmail-1.2.2 test/temp_test_one.rb
tmail-1.2.3.1 test/temp_test_one.rb
tmail-1.2.3 test/temp_test_one.rb