/* Copyright (c) 2007-2018 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "str.h"
#include "message-address.h"
#include "test-common.h"
const struct message_address *a2)
{
}
static const struct message_address *
{
/* duplicate the input (without trailing NUL) so valgrind notices
if there's any out-of-bounds access */
return addr;
}
static void test_message_address(void)
{
static const struct test {
const char *input;
const char *wanted_output;
const char *wanted_filled_output;
} tests[] = {
/* user@domain -> <user@domain> */
{ "user", "<user>", "<user@MISSING_DOMAIN>",
{ "@domain", "<\"\"@domain>", "<MISSING_MAILBOX@domain>",
/* Display Name -> Display Name */
{ "Display Name", "\"Display Name\"", "\"Display Name\" <MISSING_MAILBOX@MISSING_DOMAIN>",
{ "\"Display Name\"", "\"Display Name\"", "\"Display Name\" <MISSING_MAILBOX@MISSING_DOMAIN>",
{ "Display \"Name\"", "\"Display Name\"", "\"Display Name\" <MISSING_MAILBOX@MISSING_DOMAIN>",
{ "\"Display\" \"Name\"", "\"Display Name\"", "\"Display Name\" <MISSING_MAILBOX@MISSING_DOMAIN>",
{ "\"\"", "", "<MISSING_MAILBOX@MISSING_DOMAIN>",
/* <user@domain> -> <user@domain> */
{ "<@route>", "<@route:\"\">", "<INVALID_ROUTE:MISSING_MAILBOX@MISSING_DOMAIN>",
/* user@domain (Display Name) -> "Display Name" <user@domain> */
{ "user (Display Name)", "\"Display Name\" <user>", "\"Display Name\" <user@MISSING_DOMAIN>",
{ "@domain (Display Name)", "\"Display Name\" <\"\"@domain>", "\"Display Name\" <MISSING_MAILBOX@domain>",
/* Display Name <user@domain> -> "Display Name" <user@domain> */
{ "Display Name <user>", "\"Display Name\" <user>", "\"Display Name\" <user@MISSING_DOMAIN>",
/* <@route:user@domain> -> <@route:user@domain> */
{ "<@route@route2:user>", "<@route,@route2:user>", "<@route,@route2:user@MISSING_DOMAIN>",
/* Display Name <@route:user@domain> ->
"Display Name" <@route:user@domain> */
{ "Display Name <@route,@route2:user@domain>", "\"Display Name\" <@route,@route2:user@domain>", NULL,
{ "Display Name <@route@route2:user@domain>", "\"Display Name\" <@route,@route2:user@domain>", NULL,
{ "Display Name <@route@route2:user>", "\"Display Name\" <@route,@route2:user>", "\"Display Name\" <@route,@route2:user@MISSING_DOMAIN>",
{ "Display Name <@route@route2:\"\"@domain>", "\"Display Name\" <@route,@route2:\"\"@domain>", NULL,
/* other tests: */
{ "<>", "", "<MISSING_MAILBOX@MISSING_DOMAIN>",
{ "<@>", "", "<INVALID_ROUTE:MISSING_MAILBOX@MISSING_DOMAIN>",
};
};
};
const char *wanted_string;
unsigned int i;
test_begin("message address parsing");
/* test the address alone */
str_truncate(str, 0);
else
/* test the address as a list of itself */
str_truncate(group, 0);
for (unsigned int j = 1; j < list_length; j++) {
if ((j % 2) == 0)
else
}
for (unsigned int j = 0; j < list_length; j++) {
}
}
/* test the address as a group of itself */
str_truncate(group, 0);
for (unsigned int j = 1; j < list_length; j++) {
if ((j % 2) == 0)
else
}
for (unsigned int j = 0; j < list_length; j++) {
}
}
}
test_end();
test_begin("message address parsing with empty group");
str_truncate(group, 0);
str_truncate(str, 0);
test_end();
}
static int
{
int ret;
/* duplicate the input (without trailing NUL) so valgrind notices
if there's any out-of-bounds access */
return ret;
}
static void test_message_address_path(void)
{
static const struct test {
const char *input;
const char *wanted_output;
} tests[] = {
{ "<>", NULL,
{ " < > ", "<>",
{ "<user@domain>", NULL,
{ " <user@domain> ", "<user@domain>",
{ "<\"user\"@domain>", "<user@domain>",
{ "<\"user name\"@domain>", NULL,
{ "<\"user@na\\\\me\"@domain>", NULL,
{ "<\"user\\\"name\"@domain>", NULL,
{ "<\"\"@domain>", NULL,
};
const char *wanted_string;
unsigned int i;
test_begin("message address path parsing");
for (i = 0; i < N_ELEMENTS(tests); i++) {
int ret;
test_assert_idx(ret == 0, i);
/* test the address alone */
str_truncate(str, 0);
else
}
test_end();
}
int main(void)
{
static void (*const test_functions[])(void) = {
};
return test_run(test_functions);
}