test-mail-html2text.c revision bcb4e51a409d94ae670de96afb8483a4f7855294
/* Copyright (c) 2015-2018 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "str.h"
#include "istream.h"
#include "mail-html2text.h"
#include "test-common.h"
static const struct {
const char *input;
const char *output;
} tests[] = {
{ "&&aaaaaaaaaa", "" },
{ "a&<♣>b",
"a&<\xE2\x99\xA3>b" },
{ "&", "" },
{ "&", "" },
{ "a<style>stylesheet is ignored</style>b",
"a b" },
{ "a<stylea>b</stylea>c",
"a b c" },
{ "a<!--x <p foo=\"bar\">commented tags ignored also</p> y-->b",
"ab" },
{ "a<script>javascript <p>foo</p> ignored</script>b",
"a b" },
{ "a<scripta>b</scripta>c",
"a b c" },
{ "a<blockquote><blockquote>second level</blockquote>ignored</blockquote>b",
"a b" },
{ "a<![CDATA[<style>]] >b</style>]]>c",
"a<style>]] >b</style>c" },
{ "a<foo", "a" },
{ "a<blockquote", "a" },
{ "a<blockquote>foo</blockquote", "a " },
{ "a<", "a" },
{ "a<![CDATA[b", "ab" },
{ "a<![CDATA[b]]", "ab" },
{ "aä", "a\xC3\xA4" },
{ "aä", "a\xC3\xA4" },
{ "€", "\xE2\x82\xAC" },
};
static const char *test_blockquote_input =
"a<blockquote>b<blockquote><blockquote>c</blockquote>d</blockquote>e</blockquote>f";
static const char *test_blockquote_output = "a b c d e f";
static void test_mail_html2text(void)
{
struct mail_html2text *ht;
unsigned int i, j;
test_begin("mail_html2text()");
for (i = 0; i < N_ELEMENTS(tests); i++) {
}
str_truncate(str, 0);
}
/* test without skipping quoted */
ht = mail_html2text_init(0);
test_end();
}
static void test_mail_html2text_random(void)
{
struct mail_html2text *ht;
test_begin("mail_html2text() random");
for (unsigned int i = 0; i < 1000; i++) {
unsigned char s[2];
ht = mail_html2text_init(0);
for (unsigned int i = 0; i < 100; i++) {
}
str_truncate(str, 0);
}
test_end();
}
int main(void)
{
static void (*const test_functions[])(void) = {
};
return test_run(test_functions);
}