]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/test/test-arphrd-list.c
tree-wide: beautify remaining copyright statements
[thirdparty/systemd.git] / src / test / test-arphrd-list.c
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 /***
3 Copyright © 2015 Daniel Mack
4 ***/
5
6 #include <net/if_arp.h>
7 #include <string.h>
8
9 #include "macro.h"
10 #include "string-util.h"
11 #include "util.h"
12
13 _unused_ \
14 static const struct arphrd_name* lookup_arphrd(register const char *str, register GPERF_LEN_TYPE len);
15
16 #include "arphrd-from-name.h"
17 #include "arphrd-list.h"
18 #include "arphrd-to-name.h"
19
20 int main(int argc, const char *argv[]) {
21
22 unsigned int i;
23
24 for (i = 1; i < ELEMENTSOF(arphrd_names); i++) {
25 if (arphrd_names[i]) {
26 assert_se(streq(arphrd_to_name(i), arphrd_names[i]));
27 assert_se(arphrd_from_name(arphrd_names[i]) == (int) i);
28 }
29 }
30
31 assert_se(arphrd_to_name(arphrd_max()) == NULL);
32 assert_se(arphrd_to_name(0) == NULL);
33 assert_se(arphrd_from_name("huddlduddl") == 0);
34 assert_se(arphrd_from_name("") == 0);
35
36 return 0;
37 }