Mercurial > thymian
comparison 3rdparty/vmime/tests/parser/bodyTest.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(bodyTest) | |
| 28 | |
| 29 VMIME_TEST_LIST_BEGIN | |
| 30 VMIME_TEST(testGenerate_Text) | |
| 31 VMIME_TEST(testGenerate_NonText) | |
| 32 VMIME_TEST_LIST_END | |
| 33 | |
| 34 | |
| 35 void testGenerate_Text() | |
| 36 { | |
| 37 // RFC-2015: [Quoted-Printable encoding] A line break in a text body, | |
| 38 // represented as a CRLF sequence in the text canonical form, must be | |
| 39 // represented by a line break which is also a CRLF sequence, in the | |
| 40 // Quoted-Printable encoding | |
| 41 | |
| 42 vmime::bodyPart p; | |
| 43 p.getBody()->setContents(vmime::make_shared <vmime::stringContentHandler> | |
| 44 ("Foo éé\r\né bar\r\nbaz"), vmime::mediaType("text", "plain"), | |
| 45 vmime::charset("utf-8"), vmime::encoding("quoted-printable")); | |
| 46 | |
| 47 VASSERT_EQ("generate", | |
| 48 "Foo =C3=A9=C3=A9\r\n" | |
| 49 "=C3=A9 bar\r\n" | |
| 50 "baz", | |
| 51 p.getBody()->generate()); | |
| 52 } | |
| 53 | |
| 54 void testGenerate_NonText() | |
| 55 { | |
| 56 vmime::bodyPart p; | |
| 57 p.getBody()->setContents(vmime::make_shared <vmime::stringContentHandler> | |
| 58 ("Binary\xfa\xfb\r\ndata\r\n\r\n\xfc"), vmime::mediaType("application", "octet-stream"), | |
| 59 vmime::charset("utf-8"), vmime::encoding("quoted-printable")); | |
| 60 | |
| 61 VASSERT_EQ("generate", | |
| 62 "Binary=FA=FB=0D=0Adata=0D=0A=0D=0A=FC", | |
| 63 p.getBody()->generate()); | |
| 64 } | |
| 65 | |
| 66 VMIME_TEST_SUITE_END |
