/* Copyright (c) 2009-2018 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "buffer.h"
#include "str.h"
#include "charset-utf8.h"
#include "message-header-encode.h"
#include "message-header-decode.h"
#include "test-common.h"
enum charset_result
{
return CHARSET_RET_OK;
}
static void test_message_header_decode(void)
{
static const char *data[] = {
" \t=?utf-8?q?=c3=a4?= =?utf-8?q?=c3=a4?= b \t\r\n ", "\xC3\xA4\xC3\xA4 b \t\r\n ",
"a =?utf-8?q?=c3=a4?= b", "a \xC3\xA4 b",
"a =?utf-8?q?=c3=a4?= b", "a \xC3\xA4 b",
"a =?utf-8?q?=c3=a4?=\t\t\r\n =?utf-8?q?=c3=a4?= b", "a \xC3\xA4\xC3\xA4 b",
"a =?utf-8?q?=c3=a4?= x =?utf-8?q?=c3=a4?= b", "a \xC3\xA4 x \xC3\xA4 b",
"a =?utf-8?b?w6TDpCDDpA==?= b", "a \xC3\xA4\xC3\xA4 \xC3\xA4 b",
"=?utf-8?b?w6Qgw6Q=?=", "\xC3\xA4 \xC3\xA4",
};
unsigned int i;
test_begin("message header decode");
str_truncate(dest, 0);
message_header_decode_utf8((const unsigned char *)data[i],
}
test_end();
}
static void test_message_header_decode_read_overflow(void)
{
test_begin("message header decode read overflow");
test_end();
}
static void test_message_header_decode_encode_random(void)
{
unsigned int i, j, buflen;
test_begin("message header encode & decode randomly");
for (i = 0; i < 1000; i++) {
/* fill only with 7bit data so we don't have to worry about
the data being valid UTF-8 */
for (j = 0; j < sizeof(buf); j++)
str_truncate(encoded, 0);
str_truncate(decoded, 0);
/* test Q */
/* test B */
str_truncate(encoded, 0);
str_truncate(decoded, 0);
}
test_end();
}
int main(void)
{
static void (*const test_functions[])(void) = {
};
return test_run(test_functions);
}