1 /**
2 * @file
3 * Test code for mutt_date_make_imap()
4 *
5 * @authors
6 * Copyright (C) 2019 Richard Russon <rich@flatcap.org>
7 *
8 * @copyright
9 * This program is free software: you can redistribute it and/or modify it under
10 * the terms of the GNU General Public License as published by the Free Software
11 * Foundation, either version 2 of the License, or (at your option) any later
12 * version.
13 *
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
17 * details.
18 *
19 * You should have received a copy of the GNU General Public License along with
20 * this program. If not, see <http://www.gnu.org/licenses/>.
21 */
22
23 #define TEST_NO_MAIN
24 #include "config.h"
25 #include "acutest.h"
26 #include <stdlib.h>
27 #include "mutt/lib.h"
28
test_mutt_date_make_imap(void)29 void test_mutt_date_make_imap(void)
30 {
31 // int mutt_date_make_imap(char *buf, size_t buflen, time_t timestamp);
32
33 setenv("TZ", "UTC", 1);
34
35 {
36 TEST_CHECK(mutt_date_make_imap(NULL, 10, 0) != 0);
37 }
38
39 {
40 char buf[64] = { 0 };
41 time_t t = 961930800;
42 TEST_CHECK(mutt_date_make_imap(buf, sizeof(buf), t) > 0);
43 TEST_MSG(buf);
44 bool result = (strcmp(buf, "25-Jun-2000 12:00:00 +0100") == 0) || // Expected result...
45 (strcmp(buf, "25-Jun-2000 11:00:00 +0000") == 0); // but Travis seems to have locale problems
46 TEST_CHECK(result == true);
47 }
48 }
49