annotate 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
rev   line source
ferencd@0 1 //
ferencd@0 2 // VMime library (http://www.vmime.org)
ferencd@0 3 // Copyright (C) 2002-2013 Vincent Richard <vincent@vmime.org>
ferencd@0 4 //
ferencd@0 5 // This program is free software; you can redistribute it and/or
ferencd@0 6 // modify it under the terms of the GNU General Public License as
ferencd@0 7 // published by the Free Software Foundation; either version 3 of
ferencd@0 8 // the License, or (at your option) any later version.
ferencd@0 9 //
ferencd@0 10 // This program is distributed in the hope that it will be useful,
ferencd@0 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
ferencd@0 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
ferencd@0 13 // General Public License for more details.
ferencd@0 14 //
ferencd@0 15 // You should have received a copy of the GNU General Public License along
ferencd@0 16 // with this program; if not, write to the Free Software Foundation, Inc.,
ferencd@0 17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
ferencd@0 18 //
ferencd@0 19 // Linking this library statically or dynamically with other modules is making
ferencd@0 20 // a combined work based on this library. Thus, the terms and conditions of
ferencd@0 21 // the GNU General Public License cover the whole combination.
ferencd@0 22 //
ferencd@0 23
ferencd@0 24 #include "tests/testUtils.hpp"
ferencd@0 25
ferencd@0 26
ferencd@0 27 VMIME_TEST_SUITE_BEGIN(bodyTest)
ferencd@0 28
ferencd@0 29 VMIME_TEST_LIST_BEGIN
ferencd@0 30 VMIME_TEST(testGenerate_Text)
ferencd@0 31 VMIME_TEST(testGenerate_NonText)
ferencd@0 32 VMIME_TEST_LIST_END
ferencd@0 33
ferencd@0 34
ferencd@0 35 void testGenerate_Text()
ferencd@0 36 {
ferencd@0 37 // RFC-2015: [Quoted-Printable encoding] A line break in a text body,
ferencd@0 38 // represented as a CRLF sequence in the text canonical form, must be
ferencd@0 39 // represented by a line break which is also a CRLF sequence, in the
ferencd@0 40 // Quoted-Printable encoding
ferencd@0 41
ferencd@0 42 vmime::bodyPart p;
ferencd@0 43 p.getBody()->setContents(vmime::make_shared <vmime::stringContentHandler>
ferencd@0 44 ("Foo éé\r\né bar\r\nbaz"), vmime::mediaType("text", "plain"),
ferencd@0 45 vmime::charset("utf-8"), vmime::encoding("quoted-printable"));
ferencd@0 46
ferencd@0 47 VASSERT_EQ("generate",
ferencd@0 48 "Foo =C3=A9=C3=A9\r\n"
ferencd@0 49 "=C3=A9 bar\r\n"
ferencd@0 50 "baz",
ferencd@0 51 p.getBody()->generate());
ferencd@0 52 }
ferencd@0 53
ferencd@0 54 void testGenerate_NonText()
ferencd@0 55 {
ferencd@0 56 vmime::bodyPart p;
ferencd@0 57 p.getBody()->setContents(vmime::make_shared <vmime::stringContentHandler>
ferencd@0 58 ("Binary\xfa\xfb\r\ndata\r\n\r\n\xfc"), vmime::mediaType("application", "octet-stream"),
ferencd@0 59 vmime::charset("utf-8"), vmime::encoding("quoted-printable"));
ferencd@0 60
ferencd@0 61 VASSERT_EQ("generate",
ferencd@0 62 "Binary=FA=FB=0D=0Adata=0D=0A=0D=0A=FC",
ferencd@0 63 p.getBody()->generate());
ferencd@0 64 }
ferencd@0 65
ferencd@0 66 VMIME_TEST_SUITE_END