1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
/**
* @file
* Test code for mutt_str_sysexit()
*
* @authors
* Copyright (C) 2019 Richard Russon <rich@flatcap.org>
*
* @copyright
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 2 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define TEST_NO_MAIN
#include "config.h"
#include "acutest.h"
#include <stddef.h>
#include "mutt/lib.h"
#include "test_common.h"
#ifdef HAVE_SYSEXITS_H
#include <sysexits.h>
#endif
struct TestValue
{
int err_num; ///< Error number to lookup
const char *result; ///< Expected result string
};
// clang-format off
static const struct TestValue tests[] = {
#ifdef EX_NOUSER
{ 0xff & EX_NOUSER, "User unknown." },
#endif
#ifdef EX_NOHOST
{ 0xff & EX_NOHOST, "Host unknown." },
#endif
#ifdef EX_UNAVAILABLE
{ 0xff & EX_UNAVAILABLE, "Service unavailable." },
#endif
#ifdef EX_IOERR
{ 0xff & EX_IOERR, "I/O error." },
#endif
#ifdef EX_NOPERM
{ 0xff & EX_NOPERM, "Insufficient permission." },
#endif
{ 255, NULL },
{ -1, NULL },
};
// clang-format on
void test_mutt_str_sysexit(void)
{
// const char *mutt_str_sysexit(int e);
const char *result = NULL;
for (size_t i = 0; i < mutt_array_size(tests); i++)
{
TEST_MSG("Testing %d, expecting '%s'\n", tests[i].err_num, NONULL(tests[i].result));
result = mutt_str_sysexit(tests[i].err_num);
TEST_CHECK_STR_EQ(result, tests[i].result);
}
}
|