]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/test/test-af-list.c
test: Use TEST macro
[thirdparty/systemd.git] / src / test / test-af-list.c
CommitLineData
db9ecf05 1/* SPDX-License-Identifier: LGPL-2.1-or-later */
da8ba721 2
07630cea 3#include <sys/socket.h>
da8ba721
DM
4
5#include "macro.h"
07630cea 6#include "string-util.h"
4f7452a8 7#include "tests.h"
da8ba721
DM
8#include "util.h"
9
96315188 10_unused_
c9f7b4d3 11static const struct af_name* lookup_af(register const char *str, register GPERF_LEN_TYPE len);
da8ba721 12
07630cea 13#include "af-from-name.h"
da8ba721
DM
14#include "af-list.h"
15#include "af-to-name.h"
da8ba721 16
4f7452a8
JJ
17TEST(af_list) {
18 for (unsigned i = 0; i < ELEMENTSOF(af_names); i++) {
da8ba721
DM
19 if (af_names[i]) {
20 assert_se(streq(af_to_name(i), af_names[i]));
21 assert_se(af_from_name(af_names[i]) == (int) i);
22 }
23 }
24
25 assert_se(af_to_name(af_max()) == NULL);
26 assert_se(af_to_name(-1) == NULL);
acf4d158
YW
27 assert_se(af_from_name("huddlduddl") == -EINVAL);
28 assert_se(af_from_name("") == -EINVAL);
07630cea 29}
4f7452a8
JJ
30
31DEFINE_TEST_MAIN(LOG_INFO);