From cc18aa39c15ffffdd622cb61c3c147c2bc1903aa Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Thu, 24 Jan 2019 13:14:50 +0100 Subject: tests: add more malformation tests to mailboxTest --- tests/parser/mailboxTest.cpp | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'tests/parser/mailboxTest.cpp') diff --git a/tests/parser/mailboxTest.cpp b/tests/parser/mailboxTest.cpp index 127bb422..a0d1b694 100644 --- a/tests/parser/mailboxTest.cpp +++ b/tests/parser/mailboxTest.cpp @@ -30,7 +30,7 @@ VMIME_TEST_SUITE_BEGIN(mailboxTest) VMIME_TEST(testParse) VMIME_TEST(testEmptyEmailAddress) VMIME_TEST(testSeparatorInComment) - VMIME_TEST(testAddressInName) + VMIME_TEST(testMalformations) VMIME_TEST_LIST_END @@ -146,13 +146,28 @@ VMIME_TEST_SUITE_BEGIN(mailboxTest) VASSERT_EQ("email2", "bbb@vmime.org", mbox2->getEmail()); } - void testAddressInName() { - + void testMalformations() { vmime::mailbox mbox; - mbox.parse("a@b.c "); + mbox.parse("a@b.c "); VASSERT_EQ("name", vmime::text("a@b.c"), mbox.getName()); VASSERT_EQ("email", "e@f.g", mbox.getEmail()); + + mbox.parse("a@b.c e@f.g "); + VASSERT_EQ("name", vmime::text("e@f.g"), mbox.getName()); + VASSERT_EQ("email", "h@i.j", mbox.getEmail()); + + mbox.parse("Foo "); + VASSERT_EQ("name", vmime::text("Foobar"), mbox.getName()); + VASSERT_EQ("email", "baz@quux.com", mbox.getEmail()); + + mbox.parse("Foo "); + VASSERT_EQ("name", vmime::text("Foo"), mbox.getName()); + VASSERT_EQ("email", "foo@x.com", mbox.getEmail()); + + mbox.parse("Foo Bar "); + VASSERT_EQ("name", vmime::text("Foo"), mbox.getName()); + VASSERT_EQ("email", "foo@x.com", mbox.getEmail()); } VMIME_TEST_SUITE_END -- cgit v1.2.3