bcb4e51a409d94ae670de96afb8483a4f7855294Stephan Bosch/* Copyright (c) 2014-2018 Dovecot authors, see the included COPYING file */
6b8d5b8d02bd888609f06366ffb5a5a1e6e7d251Timo Sirainen"From user@domain Fri Feb 22 17:06:23 2008\n"
6b8d5b8d02bd888609f06366ffb5a5a1e6e7d251Timo Sirainen"From: user@domain.org\n"
6b8d5b8d02bd888609f06366ffb5a5a1e6e7d251Timo Sirainen"Date: Sat, 24 Mar 2007 23:00:00 +0200\n"
6b8d5b8d02bd888609f06366ffb5a5a1e6e7d251Timo Sirainen"Mime-Version: 1.0\n"
6b8d5b8d02bd888609f06366ffb5a5a1e6e7d251Timo Sirainen"Content-Type: multipart/mixed; boundary=\"foo bar\"\n"
6b8d5b8d02bd888609f06366ffb5a5a1e6e7d251Timo Sirainen"Root MIME prologue\n"
6b8d5b8d02bd888609f06366ffb5a5a1e6e7d251Timo Sirainen"Content-Type: text/x-myown; charset=us-ascii\n"
6b8d5b8d02bd888609f06366ffb5a5a1e6e7d251Timo Sirainen"Content-Type: message/rfc822\n"
6b8d5b8d02bd888609f06366ffb5a5a1e6e7d251Timo Sirainen"From: sub@domain.org\n"
6b8d5b8d02bd888609f06366ffb5a5a1e6e7d251Timo Sirainen"Date: Sun, 12 Aug 2012 12:34:56 +0300\n"
6b8d5b8d02bd888609f06366ffb5a5a1e6e7d251Timo Sirainen"Subject: submsg\n"
6b8d5b8d02bd888609f06366ffb5a5a1e6e7d251Timo Sirainen"Content-Type: multipart/alternative; boundary=\"sub1\"\n"
6b8d5b8d02bd888609f06366ffb5a5a1e6e7d251Timo Sirainen"Sub MIME prologue\n"
6b8d5b8d02bd888609f06366ffb5a5a1e6e7d251Timo Sirainen"Content-Type: text/html\n"
6b8d5b8d02bd888609f06366ffb5a5a1e6e7d251Timo Sirainen"<p>Hello world</p>\n"
5199b576507dab5a82100e450920899ea21b3e43Timo Sirainen"Content-Type: multipart/alternative; boundary=\"sub2\"\n"
5199b576507dab5a82100e450920899ea21b3e43Timo Sirainen"Content-Type: multipart/alternative; boundary=\"sub3\"\n"
5199b576507dab5a82100e450920899ea21b3e43Timo Sirainen"sub3 text2\n"
5199b576507dab5a82100e450920899ea21b3e43Timo Sirainen"sub2 text2\n"
6b8d5b8d02bd888609f06366ffb5a5a1e6e7d251Timo Sirainen"Sub MIME epilogue\n"
5199b576507dab5a82100e450920899ea21b3e43Timo Sirainen"Content-Type: text/plain\n"
5199b576507dab5a82100e450920899ea21b3e43Timo Sirainen"Another part\n"
6b8d5b8d02bd888609f06366ffb5a5a1e6e7d251Timo Sirainen"--foo bar--\n"
6b8d5b8d02bd888609f06366ffb5a5a1e6e7d251Timo Sirainen"Root MIME epilogue\n"
6b8d5b8d02bd888609f06366ffb5a5a1e6e7d251Timo Sirainen struct message_part *parts, *part, *prev_part;
6b8d5b8d02bd888609f06366ffb5a5a1e6e7d251Timo Sirainen pool = pool_alloconly_create("message parser", 10240);
6b8d5b8d02bd888609f06366ffb5a5a1e6e7d251Timo Sirainen input = i_stream_create_from_data(test_msg, TEST_MSG_LEN);
6b8d5b8d02bd888609f06366ffb5a5a1e6e7d251Timo Sirainen parser = message_parser_init(pool, input, 0, 0);
5199b576507dab5a82100e450920899ea21b3e43Timo Sirainen while ((ret = message_parser_parse_next_block(parser, &block)) > 0) {
6b8d5b8d02bd888609f06366ffb5a5a1e6e7d251Timo Sirainen test_assert(message_part_by_idx(parts, 1) == parts->children);
d8fc51fca32881dd6d63519122eec15e185350bfTimo Sirainen test_assert(part != NULL && message_part_to_idx(part) == i);
846adf6cf365b18b899829307106db408f5954a3Timo Sirainen test_assert(part != NULL && prev_part != NULL &&
d8fc51fca32881dd6d63519122eec15e185350bfTimo Sirainen prev_part->physical_pos < part->physical_pos);
6b8d5b8d02bd888609f06366ffb5a5a1e6e7d251Timo Sirainen test_assert(message_part_by_idx(parts, i) == NULL);
baf3e87e186453fda13bd21f7cbcb2efc8492e8bTimo Sirainen static void (*const test_functions[])(void) = {