test-message-address.c revision 6b8f4863bb2b0938d40f774122baf6528a833ea0
e59faf65ce864fe95dc00f5d52b8323cdbd0608aTimo Sirainen/* Copyright (c) 2007-2017 Dovecot authors, see the included COPYING file */
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainenstatic bool cmp_addr(const struct message_address *a1,
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen return null_strcmp(a1->name, a2->name) == 0 &&
b30584ea5916834e73dcb3672e870291968a9054Timo Sirainen static const struct test {
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen /* user@domain -> <user@domain> */
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen { NULL, NULL, NULL, "user", "domain", FALSE } },
d665e2948cb6fe8016706752a9e4940d64f4a61dTimo Sirainen { NULL, NULL, NULL, "user", "domain", FALSE } },
d665e2948cb6fe8016706752a9e4940d64f4a61dTimo Sirainen { "\"user name\"@domain", "<\"user name\"@domain>",
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen { NULL, NULL, NULL, "user name", "domain", FALSE } },
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen { "\"user@na\\\\me\"@domain", "<\"user@na\\\\me\"@domain>",
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen { NULL, NULL, NULL, "user@na\\me", "domain", FALSE } },
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen { "\"user\\\"name\"@domain", "<\"user\\\"name\"@domain>",
fc40a9a002458e372ff4b9f6f4e15239520c0bcdTimo Sirainen { NULL, NULL, NULL, "user\"name", "domain", FALSE } },
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen /* <user@domain> -> <user@domain> */
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen { NULL, NULL, NULL, "user", "domain", FALSE } },
d665e2948cb6fe8016706752a9e4940d64f4a61dTimo Sirainen { NULL, NULL, NULL, "user", "domain", FALSE } },
d665e2948cb6fe8016706752a9e4940d64f4a61dTimo Sirainen { NULL, NULL, NULL, "user name", "domain", FALSE } },
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen { NULL, NULL, NULL, "user@na\\me", "domain", FALSE } },
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen { NULL, NULL, NULL, "user\"name", "domain", FALSE } },
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen /* user@domain (Display Name) -> "Display Name" <user@domain> */
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen { "user@domain (DisplayName)", "DisplayName <user@domain>",
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen { NULL, "DisplayName", NULL, "user", "domain", FALSE } },
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen { "user@domain (Display Name)", "\"Display Name\" <user@domain>",
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen { NULL, "Display Name", NULL, "user", "domain", FALSE } },
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen { "user@domain (Display\"Name)", "\"Display\\\"Name\" <user@domain>",
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen { NULL, "Display\"Name", NULL, "user", "domain", FALSE } },
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen { "user (Display Name)", "\"Display Name\" <user>",
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen { NULL, "Display Name", NULL, "user", "", TRUE } },
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen { "@domain (Display Name)", "\"Display Name\" <\"\"@domain>",
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen { NULL, "Display Name", NULL, "", "domain", TRUE } },
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen /* Display Name <user@domain> -> "Display Name" <user@domain> */
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen { NULL, "DisplayName", NULL, "user", "domain", FALSE } },
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen { "Display Name <user@domain>", "\"Display Name\" <user@domain>",
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen { NULL, "Display Name", NULL, "user", "domain", FALSE } },
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen { NULL, "Display Name", NULL, "user", "domain", FALSE } },
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen { NULL, "Display\"Name", NULL, "user", "domain", FALSE } },
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen { "Display Name <user>", "\"Display Name\" <user>",
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen { NULL, "Display Name", NULL, "user", "", TRUE } },
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen /* <@route:user@domain> -> <@route:user@domain> */
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen { NULL, NULL, "@route", "user", "domain", FALSE } },
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen { NULL, NULL, "@route,@route2", "user", "domain", FALSE } },
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen { "<@route@route2:user@domain>", "<@route,@route2:user@domain>",
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen { NULL, NULL, "@route,@route2", "user", "domain", FALSE } },
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen { "<@route@route2:user>", "<@route,@route2:user>",
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen { NULL, NULL, "@route,@route2", "user", "", TRUE } },
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen { "<@route@route2:\"\"@domain>", "<@route,@route2:\"\"@domain>",
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen { NULL, NULL, "@route,@route2", "", "domain", FALSE } },
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen /* Display Name <@route:user@domain> ->
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen "Display Name" <@route:user@domain> */
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen { "Display Name <@route:user@domain>", "\"Display Name\" <@route:user@domain>",
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen { NULL, "Display Name", "@route", "user", "domain", FALSE } },
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen { "Display Name <@route,@route2:user@domain>", "\"Display Name\" <@route,@route2:user@domain>",
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen { NULL, "Display Name", "@route,@route2", "user", "domain", FALSE } },
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen { "Display Name <@route@route2:user@domain>", "\"Display Name\" <@route,@route2:user@domain>",
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen { NULL, "Display Name", "@route,@route2", "user", "domain", FALSE } },
9af6cc9ebc9986c1275ebdfa29c39e152af1557eTimo Sirainen { "Display Name <@route@route2:user>", "\"Display Name\" <@route,@route2:user>",
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen { NULL, "Display Name", "@route,@route2", "user", "", TRUE } },
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen { "Display Name <@route@route2:\"\"@domain>", "\"Display Name\" <@route,@route2:\"\"@domain>",
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen { NULL, "Display Name", "@route,@route2", "", "domain", FALSE } },
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen /* other tests: */
6564208826b0f46a00f010d1b5711d85944c3c88Timo Sirainen { NULL, "foo: <a@b>;,", NULL, "user", "domain", FALSE } },
const char *wanted_string;
test_end();
test_end();
test_end();
int main(void)
static void (*const test_functions[])(void) = {