1 /**
2 * @file
3 * Test code for mutt_addr_for_display()
4 *
5 * @authors
6 * Copyright (C) 2019 Richard Russon <rich@flatcap.org>
7 * Copyright (C) 2019 Pietro Cerutti <gahr@gahr.ch>
8 *
9 * @copyright
10 * This program is free software: you can redistribute it and/or modify it under
11 * the terms of the GNU General Public License as published by the Free Software
12 * Foundation, either version 2 of the License, or (at your option) any later
13 * version.
14 *
15 * This program is distributed in the hope that it will be useful, but WITHOUT
16 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
18 * details.
19 *
20 * You should have received a copy of the GNU General Public License along with
21 * this program. If not, see <http://www.gnu.org/licenses/>.
22 */
23
24 #define TEST_NO_MAIN
25 #include "config.h"
26 #include "acutest.h"
27 #include "mutt/lib.h"
28 #include "address/lib.h"
29 #include "config/lib.h"
30 #include "core/lib.h"
31 #include "test_common.h"
32
33 static struct ConfigDef Vars[] = {
34 // clang-format off
35 { "charset", DT_STRING|DT_NOT_EMPTY|DT_CHARSET_SINGLE, IP "utf-8", 0, NULL, },
36 { "idn_decode", DT_BOOL, true, 0, NULL, },
37 { NULL },
38 // clang-format on
39 };
40
test_mutt_addr_for_display(void)41 void test_mutt_addr_for_display(void)
42 {
43 // const char *mutt_addr_for_display(const struct Address *a);
44
45 {
46 TEST_CHECK(!mutt_addr_for_display(NULL));
47 }
48
49 { /* integration */
50 char per[64] = "bobby bob";
51 char mbx[64] = "bob@bobsdomain";
52
53 struct Address addr = {
54 .personal = per,
55 .mailbox = mbx,
56 .group = 0,
57 .is_intl = 0,
58 .intl_checked = 0,
59 };
60
61 NeoMutt = test_neomutt_create();
62 TEST_CHECK(cs_register_variables(NeoMutt->sub->cs, Vars, 0));
63
64 const char *expected = "bob@bobsdomain";
65 const char *actual = mutt_addr_for_display(&addr);
66
67 TEST_CHECK_STR_EQ(expected, actual);
68
69 test_neomutt_destroy(&NeoMutt);
70 }
71 }
72