Mercurial > thymian
comparison 3rdparty/vmime/tests/parser/messageTest.cpp @ 0:a4671277546c tip
created the repository for the thymian project
| author | ferencd |
|---|---|
| date | Tue, 17 Aug 2021 11:19:54 +0200 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:a4671277546c |
|---|---|
| 1 // | |
| 2 // VMime library (http://www.vmime.org) | |
| 3 // Copyright (C) 2002-2013 Vincent Richard <vincent@vmime.org> | |
| 4 // | |
| 5 // This program is free software; you can redistribute it and/or | |
| 6 // modify it under the terms of the GNU General Public License as | |
| 7 // published by the Free Software Foundation; either version 3 of | |
| 8 // the License, or (at your option) any later version. | |
| 9 // | |
| 10 // This program is distributed in the hope that it will be useful, | |
| 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 13 // General Public License for more details. | |
| 14 // | |
| 15 // You should have received a copy of the GNU General Public License along | |
| 16 // with this program; if not, write to the Free Software Foundation, Inc., | |
| 17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
| 18 // | |
| 19 // Linking this library statically or dynamically with other modules is making | |
| 20 // a combined work based on this library. Thus, the terms and conditions of | |
| 21 // the GNU General Public License cover the whole combination. | |
| 22 // | |
| 23 | |
| 24 #include "tests/testUtils.hpp" | |
| 25 | |
| 26 | |
| 27 VMIME_TEST_SUITE_BEGIN(messageTest) | |
| 28 | |
| 29 VMIME_TEST_LIST_BEGIN | |
| 30 VMIME_TEST(testGetGeneratedSize) | |
| 31 VMIME_TEST_LIST_END | |
| 32 | |
| 33 | |
| 34 void testGetGeneratedSize() | |
| 35 { | |
| 36 vmime::generationContext ctx; | |
| 37 | |
| 38 vmime::shared_ptr <vmime::message> msg = vmime::make_shared <vmime::message>(); | |
| 39 msg->getHeader()->getField("Foo")->setValue(vmime::string("bar")); | |
| 40 | |
| 41 vmime::htmlTextPart textPart; | |
| 42 textPart.setPlainText(vmime::make_shared <vmime::stringContentHandler>("Foo bar bazé foo foo foo")); | |
| 43 textPart.setText(vmime::make_shared <vmime::stringContentHandler>("Foo bar <strong>bazé</strong> foo foo foo")); | |
| 44 textPart.generateIn(msg, msg); | |
| 45 | |
| 46 // Estimated/computed generated size must be greater than the actual generated size | |
| 47 const vmime::size_t genSize = msg->getGeneratedSize(ctx); | |
| 48 const vmime::size_t actualSize = msg->generate().length(); | |
| 49 | |
| 50 std::ostringstream oss; | |
| 51 oss << "estimated size (" << genSize << ") >= actual size (" << actualSize << ")"; | |
| 52 | |
| 53 VASSERT(oss.str(), genSize >= actualSize); | |
| 54 } | |
| 55 | |
| 56 VMIME_TEST_SUITE_END | |
| 57 |
