bcb4e51a409d94ae670de96afb8483a4f7855294Stephan Bosch/* Copyright (c) 2015-2018 Dovecot authors, see the included COPYING file */
b7324e421e2132cbbf753e6fdbe675bbaecdf929Timo Sirainenstatic const struct {
7f7be2cbf68f8a202a688d5bc50f82483d461643Timo Sirainen { "Content-Type: text/plain\n"
7f7be2cbf68f8a202a688d5bc50f82483d461643Timo Sirainen "1234567890 234567890",
7f7be2cbf68f8a202a688d5bc50f82483d461643Timo Sirainen "1234567890 2" },
7f7be2cbf68f8a202a688d5bc50f82483d461643Timo Sirainen { "Content-Type: text/plain\n"
7f7be2cbf68f8a202a688d5bc50f82483d461643Timo Sirainen "line1\n>quote2\nline2\n",
7f7be2cbf68f8a202a688d5bc50f82483d461643Timo Sirainen "line1 line2" },
7f7be2cbf68f8a202a688d5bc50f82483d461643Timo Sirainen { "Content-Type: text/plain\n"
7f7be2cbf68f8a202a688d5bc50f82483d461643Timo Sirainen "line1\n>quote2\n> quote3\n > line4\n\n \t\t \nline5\n \t ",
7f7be2cbf68f8a202a688d5bc50f82483d461643Timo Sirainen "line1 > line4 line5" },
7f7be2cbf68f8a202a688d5bc50f82483d461643Timo Sirainen { "Content-Type: text/plain; charset=utf-8\n"
7f7be2cbf68f8a202a688d5bc50f82483d461643Timo Sirainen "hyv\xC3\xA4\xC3\xA4 p\xC3\xA4iv\xC3\xA4\xC3\xA4",
7f7be2cbf68f8a202a688d5bc50f82483d461643Timo Sirainen "hyv\xC3\xA4\xC3\xA4 p\xC3\xA4iv\xC3\xA4" },
7f7be2cbf68f8a202a688d5bc50f82483d461643Timo Sirainen { "Content-Type: text/plain; charset=utf-8\n"
7f7be2cbf68f8a202a688d5bc50f82483d461643Timo Sirainen "Content-Transfer-Encoding: quoted-printable\n"
7f7be2cbf68f8a202a688d5bc50f82483d461643Timo Sirainen "hyv=C3=A4=C3=A4 p=C3=A4iv=C3=A4=C3=A4",
7f7be2cbf68f8a202a688d5bc50f82483d461643Timo Sirainen "hyv\xC3\xA4\xC3\xA4 p\xC3\xA4iv\xC3\xA4" },
7f7be2cbf68f8a202a688d5bc50f82483d461643Timo Sirainen { "Content-Transfer-Encoding: quoted-printable\n"
7f7be2cbf68f8a202a688d5bc50f82483d461643Timo Sirainen "Content-Type: text/html;\n"
7f7be2cbf68f8a202a688d5bc50f82483d461643Timo Sirainen " charset=utf-8\n"
7f7be2cbf68f8a202a688d5bc50f82483d461643Timo Sirainen "<html><head><meta http-equiv=3D\"Content-Type\" content=3D\"text/html =\n"
7f7be2cbf68f8a202a688d5bc50f82483d461643Timo Sirainen "charset=3Dutf-8\"></head><body style=3D\"word-wrap: break-word; =\n"
00a50d6dc74e15b5b83afcb8c12c2109a2ca376dTimo Sirainen "-webkit-nbsp-mode: space; -webkit-line-break: after-white-space;\" =\n"
00a50d6dc74e15b5b83afcb8c12c2109a2ca376dTimo Sirainen "class=3D\"\">Hi,<div class=3D\"\"><br class=3D\"\"></div><div class=3D\"\">How =\n"
00a50d6dc74e15b5b83afcb8c12c2109a2ca376dTimo Sirainen "is it going? <blockquote>quoted text is ignored</blockquote>\n"
00a50d6dc74e15b5b83afcb8c12c2109a2ca376dTimo Sirainen "> -foo\n"
00a50d6dc74e15b5b83afcb8c12c2109a2ca376dTimo Sirainen "</div><br =class=3D\"\"></body></html>=\n",
00a50d6dc74e15b5b83afcb8c12c2109a2ca376dTimo Sirainen "Hi, How is it going? > -foo" },
00a50d6dc74e15b5b83afcb8c12c2109a2ca376dTimo Sirainen { "Content-Transfer-Encoding: quoted-printable\n"
00a50d6dc74e15b5b83afcb8c12c2109a2ca376dTimo Sirainen "Content-Type: application/xhtml+xml;\n"
00a50d6dc74e15b5b83afcb8c12c2109a2ca376dTimo Sirainen " charset=utf-8\n"
00a50d6dc74e15b5b83afcb8c12c2109a2ca376dTimo Sirainen "<html><head><meta http-equiv=3D\"Content-Type\" content=3D\"text/html =\n"
00a50d6dc74e15b5b83afcb8c12c2109a2ca376dTimo Sirainen "charset=3Dutf-8\"></head><body style=3D\"word-wrap: break-word; =\n"
7f7be2cbf68f8a202a688d5bc50f82483d461643Timo Sirainen "-webkit-nbsp-mode: space; -webkit-line-break: after-white-space;\" =\n"
7f7be2cbf68f8a202a688d5bc50f82483d461643Timo Sirainen "class=3D\"\">Hi,<div class=3D\"\"><br class=3D\"\"></div><div class=3D\"\">How =\n"
7f7be2cbf68f8a202a688d5bc50f82483d461643Timo Sirainen "is it going? <blockquote>quoted text is ignored</blockquote>\n"
7f7be2cbf68f8a202a688d5bc50f82483d461643Timo Sirainen "> -foo\n"
7f7be2cbf68f8a202a688d5bc50f82483d461643Timo Sirainen "</div><br =class=3D\"\"></body></html>=\n",
7f7be2cbf68f8a202a688d5bc50f82483d461643Timo Sirainen "Hi, How is it going? > -foo" },
7f7be2cbf68f8a202a688d5bc50f82483d461643Timo Sirainen unsigned int i;
7f7be2cbf68f8a202a688d5bc50f82483d461643Timo Sirainen input = i_stream_create_from_data(tests[i].input, strlen(tests[i].input));
7f7be2cbf68f8a202a688d5bc50f82483d461643Timo Sirainen test_assert_idx(message_snippet_generate(input, tests[i].max_snippet_chars, str) == 0, i);
7f7be2cbf68f8a202a688d5bc50f82483d461643Timo Sirainen test_assert_idx(strcmp(tests[i].output, str_c(str)) == 0, i);
baf3e87e186453fda13bd21f7cbcb2efc8492e8bTimo Sirainen static void (*const test_functions[])(void) = {