9 class TestMBoxParsing < Test::Unit::TestCase
16 def test_normal_headers
17 h = Source.parse_raw_email_header StringIO.new(<<EOS)
18 From: Bob <bob@bob.com>
19 To: Sally <sally@sally.com>
22 assert_equal "Bob <bob@bob.com>", h["from"]
23 assert_equal "Sally <sally@sally.com>", h["to"]
24 assert_nil h["message-id"]
28 h = Source.parse_raw_email_header StringIO.new(<<EOS)
29 From: Bob <bob@bob.com>
30 Subject: one two three
32 To: Sally <sally@sally.com>
38 assert_equal "one two three four five six", h["subject"]
39 assert_equal "Sally <sally@sally.com>", h["to"]
40 assert_equal "<seven> <eight>", h["references"]
43 def test_ignore_spacing
45 "Subject:one two three end\n",
46 "Subject: one two three end\n",
47 "Subject: one two three end \n",
50 h = Source.parse_raw_email_header StringIO.new(s)
51 assert_equal "one two three end", h["subject"]
55 def test_message_id_ignore_spacing
57 "Message-Id: <one@bob.com> \n",
58 "Message-Id:<one@bob.com> \n",
61 h = Source.parse_raw_email_header StringIO.new(s)
62 assert_equal "<one@bob.com>", h["message-id"]
67 h = Source.parse_raw_email_header StringIO.new("")
68 assert_equal nil, h["message-id"]
71 def test_empty_headers
77 h = Source.parse_raw_email_header StringIO.new(s)
78 assert_equal "", h["message-id"]
82 def test_detect_end_of_headers
83 h = Source.parse_raw_email_header StringIO.new(<<EOS)
84 From: Bob <bob@bob.com>
88 assert_equal "Bob <bob@bob.com>", h["from"]
91 h = Source.parse_raw_email_header StringIO.new(<<EOS)
92 From: Bob <bob@bob.com>
96 assert_equal "Bob <bob@bob.com>", h["from"]
99 h = Source.parse_raw_email_header StringIO.new(<<EOS)
100 From: Bob <bob@bob.com>
104 assert_equal "Bob <bob@bob.com>", h["from"]