1 /* t-mbox-util.c - Module test for mbox-util.c
2 * Copyright (C) 2015 Werner Koch
4 * This file is part of GnuPG.
6 * GnuPG is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
11 * GnuPG is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <https://www.gnu.org/licenses/>.
26 #include "mbox-util.h"
28 #define pass() do { ; } while(0)
29 #define fail(a) do { fprintf (stderr, "%s:%d: test %d failed\n",\
30 __FILE__,__LINE__, (a)); \
44 { "Werner Koch <wk@gnupg.org>", "wk@gnupg.org" },
45 { "<wk@gnupg.org>", "wk@gnupg.org" },
46 { "wk@gnupg.org", "wk@gnupg.org" },
47 { "wk@gnupg.org ", NULL },
48 { " wk@gnupg.org", NULL },
49 { "Werner Koch (test) <wk@gnupg.org>", "wk@gnupg.org" },
50 { "Werner Koch <wk@gnupg.org> (test)", "wk@gnupg.org" },
51 { "Werner Koch <wk@gnupg.org (test)", NULL },
52 { "Werner Koch <wk@gnupg.org >", NULL },
53 { "Werner Koch <wk@gnupg.org", NULL },
57 { "<foo@example.org>", "foo@example.org" },
58 { "<foo.@example.org>", "foo.@example.org" },
59 { "<.foo.@example.org>", ".foo.@example.org" },
60 { "<foo..@example.org>", "foo..@example.org" },
61 { "<foo..bar@example.org>", "foo..bar@example.org" },
62 { "<foo@example.org.>", NULL },
63 { "<foo@example..org>", NULL },
65 { "<@example.org>", NULL },
66 { "<foo@@example.org>", NULL },
67 { "<@foo@example.org>", NULL },
68 { "<foo@example.org> ()", "foo@example.org" },
69 { "<fo()o@example.org> ()", "fo()o@example.org" },
70 { "<fo()o@example.org> ()", "fo()o@example.org" },
71 { "fo()o@example.org", NULL},
72 { "Mr. Foo <foo@example.org><bar@example.net>", "foo@example.org"},
77 for (idx=0; testtbl[idx].userid; idx++)
79 char *mbox = mailbox_from_userid (testtbl[idx].userid);
81 if (!testtbl[idx].mbox)
88 else if (strcmp (mbox, testtbl[idx].mbox))
97 main (int argc, char **argv)