/* Copyright (c) 2008-2018 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "str.h"
#include "unichar.h"
#include "imap-utf7.h"
#include "test-common.h"
static void test_imap_utf7_by_example(void)
{
static const struct test {
const char *utf8;
const char *mutf7;
} tests[] = {
{ "&&x&&", "&-&-x&-&-" },
{ "tiet\xc3\xa4j\xc3\xa4", "tiet&AOQ-j&AOQ-" },
{ "p\xe4\xe4", NULL },
{ NULL, "&" },
{ NULL, "&Jjo" },
{ NULL, "&Jjo!" },
{ NULL, "&U,BTFw-&ZeVnLIqe-" }
};
unsigned int i;
test_begin("imap mutf7 examples");
for (i = 0; i < N_ELEMENTS(tests); i++) {
str_truncate(dest, 0);
else
}
str_truncate(dest, 0);
else
}
}
test_end();
}
static void test_imap_utf7_ucs4_cases(void)
{
const char *orig_src;
unsigned int i, j;
test_begin("imap mutf7 ucs4 cases");
for (i = 1; i <= 10; i++) {
str_truncate(src, 0);
str_truncate(dest, 0);
for (j = 0; j < i; j++) {
if (j % 3 == 0)
if (j % 5 == 0)
}
str_truncate(src, 0);
}
} T_END;
test_end();
}
static void test_imap_utf7_non_utf16(void)
{
unsigned int i;
test_begin("imap mutf7 non-utf16");
for (i = 0; i <= 255; ++i) {
/* Invalid, code a single 8-bit octet */
}
for (i = 0; i <= 255; ++i) {
/* Invalid, U+00E4 followed by a single octet */
csrc[0] = '&';
}
test_end();
}
static void test_imap_utf7_bad_ascii(void)
{
unsigned int i;
test_begin("imap mutf7 bad ascii");
for (i = 1; i <= 0x7f; ++i) {
if (i == ' ')
i = 0x7f;
csrc[0] = i;
str_truncate(dest, 0);
}
test_end();
}
static void test_imap_utf7_unnecessary(void)
{
unsigned int i;
test_begin("imap mutf7 unnecessary");
for (i = 0x20; i < 0x7f; ++i) {
/* Create an invalid escaped encoding of a simple char or '&' */
csrc[0] = '&';
str_truncate(dest, 0);
/* All self-coding characters must self-code */
if (i == '&')
continue;
csrc[0] = i;
str_truncate(dest, 0);
}
test_end();
}
int main(void)
{
static void (*const test_functions[])(void) = {
};
return test_run(test_functions);
}