-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a test for boundaries terminated by semicolon
References #13
- Loading branch information
Showing
1 changed file
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -569,6 +569,71 @@ This is the second email in a test of boundaries. | |
} | ||
} | ||
|
||
func TestScanMessageWithBoundarySemicolon(t *testing.T) { | ||
mbox := `From [email protected] Tue Jun 7 05:46:46 2016 | ||
From: Sender <[email protected]> | ||
To: foo/bar <[email protected]> | ||
Message-ID: <foo/bar/1/[email protected]> | ||
Subject: Re: [foo/bar] [question] Baz? (#1) | ||
Content-Type: multipart/alternative; boundary="--==_mimepart_5755da228145a_38da3facdf97329c42987b"; | ||
MIME-Version: 1.0 | ||
----==_mimepart_5755da228145a_38da3facdf97329c42987b | ||
Content-Type: text/plain; charset="UTF-8" | ||
Content-Transfer-Encoding: 8bit | ||
Blah blah | ||
----==_mimepart_5755da228145a_38da3facdf97329c42987b | ||
Content-Type: text/html; charset="UTF-8" | ||
Content-Transfer-Encoding: 8bit | ||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | ||
<p>Blah blah</p> | ||
----==_mimepart_5755da228145a_38da3facdf97329c42987b-- | ||
From [email protected] Tue Jun 7 05:52:15 2016 | ||
From: Author <[email protected]> | ||
To: frob/blab <[email protected]> | ||
Message-ID: <frob/blab/1/[email protected]> | ||
Subject: Re: [frob/blab] [question] Bling? (#1) | ||
Content-Type: multipart/alternative; boundary="--==_mimepart_5755db739a819_79783f996b0172c04025ee"; | ||
MIME-Version: 1.0 | ||
----==_mimepart_5755db739a819_79783f996b0172c04025ee | ||
Content-Type: text/plain; charset="UTF-8" | ||
Content-Transfer-Encoding: 8bit | ||
Blah blah | ||
----==_mimepart_5755db739a819_79783f996b0172c04025ee | ||
Content-Type: text/html; charset="UTF-8" | ||
Content-Transfer-Encoding: 8bit | ||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | ||
<p>Blah blah</p> | ||
----==_mimepart_5755db739a819_79783f996b0172c04025ee-- | ||
` | ||
expected := 2 | ||
|
||
b := bytes.NewBufferString(mbox) | ||
m := NewScanner(b) | ||
|
||
parsedMessages := 0 | ||
for m.Next() { | ||
parsedMessages += 1 | ||
} | ||
|
||
if parsedMessages != expected { | ||
t.Errorf("Expected: %d; got: %d", expected, parsedMessages) | ||
} | ||
} | ||
|
||
func ExampleScanner() { | ||
r := strings.NewReader(`From herp.derp at example.com Thu Jan 1 00:00:01 2015 | ||
From: herp.derp at example.com (Herp Derp) | ||
|