test-message-snippet.c revision 7f7be2cbf68f8a202a688d5bc50f82483d461643
2454dfa32c93c20a8522c6ed42fe057baaac9f9aStephan Bosch/* Copyright (c) 2015 Dovecot authors, see the included COPYING file */
fdc557286bc9f92c5f3bb49096ff6e2bcec0ea79Timo Sirainenstatic struct {
5da1aa5197a43d83f0fb3eeb83125c7cd73d1b62Timo Sirainen { "Content-Type: text/plain\n"
c04f9a724a7b3cc649485a61b0a540868d25d71bTimo Sirainen "1234567890 234567890",
e2d268e9531227ead6a98466ecf3c046c857ef70Timo Sirainen "1234567890 2" },
c04f9a724a7b3cc649485a61b0a540868d25d71bTimo Sirainen { "Content-Type: text/plain\n"
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen "line1\n>quote2\nline2\n",
eb0816090cf5a549280ad783b9aa6fec199d36baTimo Sirainen "line1 line2" },
eb0816090cf5a549280ad783b9aa6fec199d36baTimo Sirainen { "Content-Type: text/plain\n"
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen "line1\n>quote2\n> quote3\n > line4\n\n \t\t \nline5\n \t ",
eb0816090cf5a549280ad783b9aa6fec199d36baTimo Sirainen "line1 > line4 line5" },
e2d268e9531227ead6a98466ecf3c046c857ef70Timo Sirainen { "Content-Type: text/plain; charset=utf-8\n"
eb0816090cf5a549280ad783b9aa6fec199d36baTimo Sirainen "hyv\xC3\xA4\xC3\xA4 p\xC3\xA4iv\xC3\xA4\xC3\xA4",
2b9dbb270ad82e58d5f3581436e6f143176d5819Timo Sirainen "hyv\xC3\xA4\xC3\xA4 p\xC3\xA4iv\xC3\xA4" },
900bb5e316d030cdebff7ee128ce65881dfb27f7Timo Sirainen { "Content-Type: text/plain; charset=utf-8\n"
900bb5e316d030cdebff7ee128ce65881dfb27f7Timo Sirainen "Content-Transfer-Encoding: quoted-printable\n"
50c617761ee9653bd44646a95178773a3686d62eTimo Sirainen "hyv=C3=A4=C3=A4 p=C3=A4iv=C3=A4=C3=A4",
661998e2ccd772ad92a9d4a75cb712692a8c94b3Timo Sirainen "hyv\xC3\xA4\xC3\xA4 p\xC3\xA4iv\xC3\xA4" },
50c617761ee9653bd44646a95178773a3686d62eTimo Sirainen { "Content-Transfer-Encoding: quoted-printable\n"
50c617761ee9653bd44646a95178773a3686d62eTimo Sirainen "Content-Type: text/html;\n"
50c617761ee9653bd44646a95178773a3686d62eTimo Sirainen " charset=utf-8\n"
661998e2ccd772ad92a9d4a75cb712692a8c94b3Timo Sirainen "<html><head><meta http-equiv=3D\"Content-Type\" content=3D\"text/html =\n"
661998e2ccd772ad92a9d4a75cb712692a8c94b3Timo Sirainen "charset=3Dutf-8\"></head><body style=3D\"word-wrap: break-word; =\n"
661998e2ccd772ad92a9d4a75cb712692a8c94b3Timo Sirainen "-webkit-nbsp-mode: space; -webkit-line-break: after-white-space;\" =\n"
50c617761ee9653bd44646a95178773a3686d62eTimo Sirainen "class=3D\"\">Hi,<div class=3D\"\"><br class=3D\"\"></div><div class=3D\"\">How =\n"
50c617761ee9653bd44646a95178773a3686d62eTimo Sirainen "is it going? <blockquote>quoted text is ignored</blockquote>\n"
50c617761ee9653bd44646a95178773a3686d62eTimo Sirainen "> -foo\n"
50c617761ee9653bd44646a95178773a3686d62eTimo Sirainen "</div><br =class=3D\"\"></body></html>=\n",
897368f75a68f97e172ba76540759a10c557f1c3Timo Sirainen "Hi, How is it going? > -foo" },
900bb5e316d030cdebff7ee128ce65881dfb27f7Timo Sirainen unsigned int i;
e2d268e9531227ead6a98466ecf3c046c857ef70Timo Sirainen input = i_stream_create_from_data(tests[i].input, strlen(tests[i].input));
e2d268e9531227ead6a98466ecf3c046c857ef70Timo Sirainen test_assert_idx(message_snippet_generate(input, tests[i].max_snippet_chars, str) == 0, i);
e2d268e9531227ead6a98466ecf3c046c857ef70Timo Sirainen test_assert_idx(strcmp(tests[i].output, str_c(str)) == 0, i);
1f1ee8db68d9ae1604350801cd8dc33ebe29fe8aTimo Sirainen static void (*test_functions[])(void) = {