]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/test/test-af-list.c
Merge pull request #16271 from yuwata/network-cleanups-around-link-get
[thirdparty/systemd.git] / src / test / test-af-list.c
CommitLineData
53e1b683 1/* SPDX-License-Identifier: LGPL-2.1+ */
da8ba721 2
07630cea 3#include <sys/socket.h>
da8ba721
DM
4
5#include "macro.h"
07630cea 6#include "string-util.h"
da8ba721
DM
7#include "util.h"
8
96315188 9_unused_
c9f7b4d3 10static const struct af_name* lookup_af(register const char *str, register GPERF_LEN_TYPE len);
da8ba721 11
07630cea 12#include "af-from-name.h"
da8ba721
DM
13#include "af-list.h"
14#include "af-to-name.h"
da8ba721
DM
15
16int main(int argc, const char *argv[]) {
17
14cb109d 18 unsigned i;
da8ba721
DM
19
20 for (i = 0; i < ELEMENTSOF(af_names); i++) {
21 if (af_names[i]) {
22 assert_se(streq(af_to_name(i), af_names[i]));
23 assert_se(af_from_name(af_names[i]) == (int) i);
24 }
25 }
26
27 assert_se(af_to_name(af_max()) == NULL);
28 assert_se(af_to_name(-1) == NULL);
acf4d158
YW
29 assert_se(af_from_name("huddlduddl") == -EINVAL);
30 assert_se(af_from_name("") == -EINVAL);
da8ba721
DM
31
32 return 0;
07630cea 33}