|
|
|
@ -10,6 +10,7 @@
|
|
|
|
|
//#include <pEp/slurp.hh>
|
|
|
|
|
#include <iostream>
|
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
|
#include <boost/algorithm/string/replace.hpp>
|
|
|
|
|
|
|
|
|
|
using namespace std::string_literals;
|
|
|
|
|
|
|
|
|
@ -311,6 +312,20 @@ namespace
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// to test the MIME parser whether it handles non-standard line endings
|
|
|
|
|
struct TestEntryLineEnding
|
|
|
|
|
{
|
|
|
|
|
const char* const name;
|
|
|
|
|
std::string (*converter)(const char* mime_text);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const TestEntryLineEnding lineendings[] =
|
|
|
|
|
{
|
|
|
|
|
{ "CRLF", [](const char* mime_text){ return std::string(mime_text); } },
|
|
|
|
|
{ "CR" , [](const char* mime_text){ return boost::algorithm::replace_all_copy(std::string(mime_text), "\r\n", "\r"); } },
|
|
|
|
|
{ "LF" , [](const char* mime_text){ return boost::algorithm::replace_all_copy(std::string(mime_text), "\r\n", "\n"); } },
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // end of anonymous namespace
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -367,19 +382,28 @@ TEST_P( MimeTestP, MimeTypes )
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TEST(PepMimeTest, Nested)
|
|
|
|
|
class MimeTestLineEndingP : public ::testing::TestWithParam<TestEntryLineEnding>
|
|
|
|
|
{
|
|
|
|
|
// intentionally left blank for now.
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
INSTANTIATE_TEST_CASE_P(MimeTestLineEndingPInstance, MimeTestLineEndingP, testing::ValuesIn(lineendings) );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TEST_P(MimeTestLineEndingP, Nested)
|
|
|
|
|
{
|
|
|
|
|
const std::string f = mail1_eml;
|
|
|
|
|
const auto& p = GetParam();
|
|
|
|
|
const std::string f = p.converter(mail1_eml);
|
|
|
|
|
|
|
|
|
|
message* m = pEpMIME::parse_message(f.data(), f.size());
|
|
|
|
|
ASSERT_NE( m, nullptr );
|
|
|
|
|
|
|
|
|
|
std::cerr << "\n§§§§§§§§§§§<BEGIN>§§§§§§§§§\n";
|
|
|
|
|
std::cerr << "\n§§§§§§§§§§§<BEGIN: " << p.name << ">§§§§§§§§§\n";
|
|
|
|
|
pEpMIME::print_message(m);
|
|
|
|
|
std::cerr << "§§§§§§§§§§§<END>§§§§§§§§§\n\n";
|
|
|
|
|
std::cerr << "§§§§§§§§§§§<END: " << p.name << ">§§§§§§§§§\n\n";
|
|
|
|
|
EXPECT_STREQ( m->from->username, "Alice");
|
|
|
|
|
EXPECT_STREQ( m->shortmsg, "Rødgrød med fløde" );
|
|
|
|
|
EXPECT_STREQ( m->longmsg , "Rødgrød med fløde?\r\n" );
|
|
|
|
|
EXPECT_EQ( std::string(m->longmsg) , p.converter("Rødgrød med fløde?\r\n") );
|
|
|
|
|
EXPECT_EQ( identity_list_length(m->to), 1 );
|
|
|
|
|
EXPECT_EQ( identity_list_length(m->cc), 4 );
|
|
|
|
|
EXPECT_EQ( identity_list_length(m->bcc), 0 );
|
|
|
|
|