Permalink
Browse files

tests: add more malformation tests to mailboxTest

  • Loading branch information...
jengelh committed Jan 24, 2019
1 parent 0368ada commit cc18aa39c15ffffdd622cb61c3c147c2bc1903aa
Showing with 19 additions and 4 deletions.
  1. +19 −4 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 <e@f.g>");

mbox.parse("a@b.c <e@f.g>");
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 <h@i.j>");
VASSERT_EQ("name", vmime::text("e@f.g"), mbox.getName());
VASSERT_EQ("email", "h@i.j", mbox.getEmail());

mbox.parse("Foo <bar<baz@quux.com>");
VASSERT_EQ("name", vmime::text("Foobar"), mbox.getName());
VASSERT_EQ("email", "baz@quux.com", mbox.getEmail());

mbox.parse("Foo <foo@x.com> <bar@x.com>");
VASSERT_EQ("name", vmime::text("Foo"), mbox.getName());
VASSERT_EQ("email", "foo@x.com", mbox.getEmail());

mbox.parse("Foo <foo@x.com> Bar <bar@y.com>");
VASSERT_EQ("name", vmime::text("Foo"), mbox.getName());
VASSERT_EQ("email", "foo@x.com", mbox.getEmail());
}

VMIME_TEST_SUITE_END

0 comments on commit cc18aa3

Please sign in to comment.