Debian Codegraph @

src/test/test-arphrd-util.c

raw
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2
3 #include <linux/if_arp.h>
4
5 #include "arphrd-util.h"
6 #include "tests.h"
7
8 TEST(arphrd) {
9 for (int i = 0; i <= ARPHRD_VOID + 1; i++) {
10 const char *name;
11
12 name = arphrd_to_name(i);
13 if (name) {
14 log_info("%i: %s", i, name);
15
16 ASSERT_EQ(arphrd_from_name(name), i);
17 }
18 }
19
20 ASSERT_NULL(arphrd_to_name(ARPHRD_VOID + 1));
21 assert_se(arphrd_from_name("huddlduddl") == -EINVAL);
22 assert_se(arphrd_from_name("") == -EINVAL);
23 }
24
25 DEFINE_TEST_MAIN(LOG_INFO);