2005-03-27 13:06:45 +00:00
|
|
|
//
|
|
|
|
// VMime library (http://www.vmime.org)
|
2013-01-10 16:30:31 +00:00
|
|
|
// Copyright (C) 2002-2013 Vincent Richard <vincent@vmime.org>
|
2005-03-27 13:06:45 +00:00
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU General Public License as
|
2009-09-06 12:02:10 +00:00
|
|
|
// published by the Free Software Foundation; either version 3 of
|
2005-03-27 13:06:45 +00:00
|
|
|
// the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// General Public License for more details.
|
|
|
|
//
|
2005-09-17 10:10:29 +00:00
|
|
|
// You should have received a copy of the GNU General Public License along
|
|
|
|
// with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
//
|
|
|
|
// Linking this library statically or dynamically with other modules is making
|
|
|
|
// a combined work based on this library. Thus, the terms and conditions of
|
|
|
|
// the GNU General Public License cover the whole combination.
|
2005-03-27 13:06:45 +00:00
|
|
|
//
|
|
|
|
|
2005-08-25 21:25:45 +00:00
|
|
|
#include "tests/testUtils.hpp"
|
2005-03-27 13:06:45 +00:00
|
|
|
|
|
|
|
|
2013-03-08 07:19:50 +00:00
|
|
|
VMIME_TEST_SUITE_BEGIN(messageIdTest)
|
2005-03-27 13:06:45 +00:00
|
|
|
|
2005-08-25 21:25:45 +00:00
|
|
|
VMIME_TEST_LIST_BEGIN
|
|
|
|
VMIME_TEST(testParse)
|
2006-08-09 07:18:45 +00:00
|
|
|
VMIME_TEST(testParseInvalid)
|
2005-08-25 21:25:45 +00:00
|
|
|
VMIME_TEST(testGenerate)
|
|
|
|
VMIME_TEST_LIST_END
|
2005-03-27 13:06:45 +00:00
|
|
|
|
|
|
|
|
2005-08-25 21:25:45 +00:00
|
|
|
void testParse()
|
|
|
|
{
|
|
|
|
vmime::messageId m1;
|
|
|
|
m1.parse("<a@b>");
|
2005-03-27 13:06:45 +00:00
|
|
|
|
2005-08-25 21:25:45 +00:00
|
|
|
VASSERT_EQ("1.1", "a", m1.getLeft());
|
|
|
|
VASSERT_EQ("1.2", "b", m1.getRight());
|
|
|
|
}
|
2005-03-27 13:06:45 +00:00
|
|
|
|
2006-08-09 07:18:45 +00:00
|
|
|
void testParseInvalid()
|
|
|
|
{
|
|
|
|
vmime::messageId m1;
|
|
|
|
m1.parse("foo@bar");
|
|
|
|
|
|
|
|
VASSERT_EQ("1.1", "foo", m1.getLeft());
|
|
|
|
VASSERT_EQ("1.2", "bar", m1.getRight());
|
|
|
|
}
|
|
|
|
|
2005-08-25 21:25:45 +00:00
|
|
|
void testGenerate()
|
|
|
|
{
|
|
|
|
vmime::messageId m1;
|
2005-03-27 13:06:45 +00:00
|
|
|
|
2008-07-11 21:37:38 +00:00
|
|
|
VASSERT_EQ("1", "<>", m1.generate());
|
2005-03-27 13:06:45 +00:00
|
|
|
|
2005-08-25 21:25:45 +00:00
|
|
|
vmime::messageId m2;
|
|
|
|
m2.setLeft("a");
|
2005-03-27 13:06:45 +00:00
|
|
|
|
2008-07-11 21:37:38 +00:00
|
|
|
VASSERT_EQ("2", "<a>", m2.generate());
|
2005-03-27 13:06:45 +00:00
|
|
|
|
2005-08-25 21:25:45 +00:00
|
|
|
vmime::messageId m3;
|
|
|
|
m3.setRight("b");
|
2005-03-27 13:06:45 +00:00
|
|
|
|
2005-08-25 21:25:45 +00:00
|
|
|
VASSERT_EQ("3", "<@b>", m3.generate());
|
2005-03-27 13:06:45 +00:00
|
|
|
|
2005-08-25 21:25:45 +00:00
|
|
|
vmime::messageId m4;
|
|
|
|
m4.setLeft("a");
|
|
|
|
m4.setRight("b");
|
2005-03-27 13:06:45 +00:00
|
|
|
|
2005-08-25 21:25:45 +00:00
|
|
|
VASSERT_EQ("4", "<a@b>", m4.generate());
|
|
|
|
}
|
2005-03-27 13:06:45 +00:00
|
|
|
|
2005-08-25 21:25:45 +00:00
|
|
|
VMIME_TEST_SUITE_END
|
2005-03-27 13:06:45 +00:00
|
|
|
|