]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/test/test-af-list.c
tree-wide: drop license boilerplate
[thirdparty/systemd.git] / src / test / test-af-list.c
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 /***
3 This file is part of systemd
4
5 Copyright 2015 Daniel Mack
6 ***/
7
8 #include <string.h>
9 #include <sys/socket.h>
10
11 #include "macro.h"
12 #include "string-util.h"
13 #include "util.h"
14
15 _unused_
16 static const struct af_name* lookup_af(register const char *str, register GPERF_LEN_TYPE len);
17
18 #include "af-from-name.h"
19 #include "af-list.h"
20 #include "af-to-name.h"
21
22 int main(int argc, const char *argv[]) {
23
24 unsigned int i;
25
26 for (i = 0; i < ELEMENTSOF(af_names); i++) {
27 if (af_names[i]) {
28 assert_se(streq(af_to_name(i), af_names[i]));
29 assert_se(af_from_name(af_names[i]) == (int) i);
30 }
31 }
32
33 assert_se(af_to_name(af_max()) == NULL);
34 assert_se(af_to_name(-1) == NULL);
35 assert_se(af_from_name("huddlduddl") == AF_UNSPEC);
36 assert_se(af_from_name("") == AF_UNSPEC);
37
38 return 0;
39 }