test-imap-bodystructure.c revision 3693d00aeb46f1fe4afcc67782487a281262fa63
/* Copyright (c) 2013-2017 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "istream.h"
#include "str.h"
#include "message-parser.h"
#include "imap-bodystructure.h"
#include "test-common.h"
struct parse_test {
const char *message;
const char *body;
const char *bodystructure;
};
struct parse_test parse_tests[] = {
{
.message =
"From: user@domain.org\n"
"Date: Sat, 24 Mar 2007 23:00:00 +0200\n"
"Mime-Version: 1.0\n"
" bar\"\n"
"\n"
"Root MIME prologue\n"
"\n"
"--foo bar\n"
"Content-ID: <foo@example.com>\n"
"Content-MD5: Q2hlY2sgSW50ZWdyaXR5IQ==\n"
"Content-Disposition: inline; foo=bar\n"
"Content-Description: hellodescription\n"
"Content-Language: en, fi, se\n"
"Content-Location: http://example.com/test.txt\n"
"\n"
"hello\n"
"\n"
"--foo bar\n"
"\n"
"From: sub@domain.org\n"
"To: sub-to1@domain.org, sub-to2@domain.org\n"
"Date: Sun, 12 Aug 2012 12:34:56 +0300\n"
"Subject: submsg\n"
"Content-Type: multipart/alternative; boundary=\"sub1\"\n"
"\n"
"Sub MIME prologue\n"
"--sub1\n"
"Content-Transfer-Encoding: 8bit\n"
"\n"
"<p>Hello world</p>\n"
"\n"
"--sub1\n"
"Content-Transfer-Encoding: ?invalid\n"
"\n"
"Hello another world\n"
"\n"
"--sub1--\n"
"Sub MIME epilogue\n"
"\n"
"--foo bar--\n"
"Root MIME epilogue\n",
"(\"text\" \"x-myown\" (\"charset\" \"us-ascii\" \"foo\" \"quoted\\\"string\") \"<foo@example.com>\" \"hellodescription\" \"7bit\" 7 1 \"Q2hlY2sgSW50ZWdyaXR5IQ==\" (\"inline\" (\"foo\" \"bar\")) (\"en\" \"fi\" \"se\") \"http://example.com/test.txt\")(\"message\" \"rfc822\" NIL NIL NIL \"7bit\" 412 (\"Sun, 12 Aug 2012 12:34:56 +0300\" \"submsg\" ((NIL NIL \"sub\" \"domain.org\")) ((NIL NIL \"sub\" \"domain.org\")) ((NIL NIL \"sub\" \"domain.org\")) ((NIL NIL \"sub-to1\" \"domain.org\")(NIL NIL \"sub-to2\" \"domain.org\")) NIL NIL NIL NIL) ((\"text\" \"html\" (\"charset\" \"us-ascii\") NIL NIL \"8bit\" 20 1 NIL NIL NIL NIL)(\"text\" \"plain\" (\"charset\" \"us-ascii\") NIL NIL \"7bit\" 21 1 NIL NIL NIL NIL) \"alternative\" (\"boundary\" \"sub1\") NIL NIL NIL) 21 NIL NIL NIL NIL) \"mixed\" (\"boundary\" \"foo bar\") NIL NIL NIL",
.body =
"(\"text\" \"x-myown\" (\"charset\" \"us-ascii\" \"foo\" \"quoted\\\"string\") \"<foo@example.com>\" \"hellodescription\" \"7bit\" 7 1)(\"message\" \"rfc822\" NIL NIL NIL \"7bit\" 412 (\"Sun, 12 Aug 2012 12:34:56 +0300\" \"submsg\" ((NIL NIL \"sub\" \"domain.org\")) ((NIL NIL \"sub\" \"domain.org\")) ((NIL NIL \"sub\" \"domain.org\")) ((NIL NIL \"sub-to1\" \"domain.org\")(NIL NIL \"sub-to2\" \"domain.org\")) NIL NIL NIL NIL) ((\"text\" \"html\" (\"charset\" \"us-ascii\") NIL NIL \"8bit\" 20 1)(\"text\" \"plain\" (\"charset\" \"us-ascii\") NIL NIL \"7bit\" 21 1) \"alternative\") 21) \"mixed\""
}
};
static struct message_part *
{
struct message_parser_ctx *parser;
struct message_block block;
struct message_part *parts;
int ret;
if (parse_bodystructure) {
}
}
test_assert(ret < 0);
return parts;
}
static void test_imap_bodystructure_write(void)
{
struct message_part *parts;
unsigned int i;
for (i = 0; i < parse_tests_count; i++) T_BEGIN {
str_truncate(str, 0);
pool_unref(&pool);
test_end();
} T_END;
}
static void test_imap_bodystructure_parse(void)
{
struct message_part *parts;
const char *error;
unsigned int i;
int ret;
for (i = 0; i < parse_tests_count; i++) T_BEGIN {
test_assert(ret == 0);
if (ret == 0) {
str_truncate(str, 0);
} else {
}
pool_unref(&pool);
test_end();
} T_END;
}
int main(void)
{
static void (*const test_functions[])(void) = {
};
return test_run(test_functions);
}