ferencd@0: // ferencd@0: // VMime library (http://www.vmime.org) ferencd@0: // Copyright (C) 2002-2013 Vincent Richard ferencd@0: // ferencd@0: // This program is free software; you can redistribute it and/or ferencd@0: // modify it under the terms of the GNU General Public License as ferencd@0: // published by the Free Software Foundation; either version 3 of ferencd@0: // the License, or (at your option) any later version. ferencd@0: // ferencd@0: // This program is distributed in the hope that it will be useful, ferencd@0: // but WITHOUT ANY WARRANTY; without even the implied warranty of ferencd@0: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ferencd@0: // General Public License for more details. ferencd@0: // ferencd@0: // You should have received a copy of the GNU General Public License along ferencd@0: // with this program; if not, write to the Free Software Foundation, Inc., ferencd@0: // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ferencd@0: // ferencd@0: // Linking this library statically or dynamically with other modules is making ferencd@0: // a combined work based on this library. Thus, the terms and conditions of ferencd@0: // the GNU General Public License cover the whole combination. ferencd@0: // ferencd@0: ferencd@0: #include "tests/testUtils.hpp" ferencd@0: ferencd@0: ferencd@0: VMIME_TEST_SUITE_BEGIN(bodyTest) ferencd@0: ferencd@0: VMIME_TEST_LIST_BEGIN ferencd@0: VMIME_TEST(testGenerate_Text) ferencd@0: VMIME_TEST(testGenerate_NonText) ferencd@0: VMIME_TEST_LIST_END ferencd@0: ferencd@0: ferencd@0: void testGenerate_Text() ferencd@0: { ferencd@0: // RFC-2015: [Quoted-Printable encoding] A line break in a text body, ferencd@0: // represented as a CRLF sequence in the text canonical form, must be ferencd@0: // represented by a line break which is also a CRLF sequence, in the ferencd@0: // Quoted-Printable encoding ferencd@0: ferencd@0: vmime::bodyPart p; ferencd@0: p.getBody()->setContents(vmime::make_shared ferencd@0: ("Foo éé\r\né bar\r\nbaz"), vmime::mediaType("text", "plain"), ferencd@0: vmime::charset("utf-8"), vmime::encoding("quoted-printable")); ferencd@0: ferencd@0: VASSERT_EQ("generate", ferencd@0: "Foo =C3=A9=C3=A9\r\n" ferencd@0: "=C3=A9 bar\r\n" ferencd@0: "baz", ferencd@0: p.getBody()->generate()); ferencd@0: } ferencd@0: ferencd@0: void testGenerate_NonText() ferencd@0: { ferencd@0: vmime::bodyPart p; ferencd@0: p.getBody()->setContents(vmime::make_shared ferencd@0: ("Binary\xfa\xfb\r\ndata\r\n\r\n\xfc"), vmime::mediaType("application", "octet-stream"), ferencd@0: vmime::charset("utf-8"), vmime::encoding("quoted-printable")); ferencd@0: ferencd@0: VASSERT_EQ("generate", ferencd@0: "Binary=FA=FB=0D=0Adata=0D=0A=0D=0A=FC", ferencd@0: p.getBody()->generate()); ferencd@0: } ferencd@0: ferencd@0: VMIME_TEST_SUITE_END