Debian Codegraph @

src/test/test-net-naming-scheme.c

raw
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2
3 #include "netif-naming-scheme.h"
4 #include "tests.h"
5
6 #ifdef _DEFAULT_NET_NAMING_SCHEME
7 /* The primary purpose of this check is to verify that _DEFAULT_NET_NAMING_SCHEME_TEST
8 * is a valid identifier. If an invalid name is given during configuration, this will
9 * fail with a name error. */
10 assert_cc(_DEFAULT_NET_NAMING_SCHEME >= 0);
11 #endif
12
13 TEST(default_net_naming_scheme) {
14 const NamingScheme *n;
15 assert_se(n = naming_scheme_from_name(DEFAULT_NET_NAMING_SCHEME));
16 log_info("default → %s", n->name);
17
18 assert_se(naming_scheme_from_name(n->name) == n);
19 }
20
21 TEST(naming_scheme_conversions) {
22 const NamingScheme *n;
23 assert_se(n = naming_scheme_from_name("latest"));
24 log_info("latest → %s", n->name);
25
26 assert_se(n = naming_scheme_from_name("v238"));
27 ASSERT_STREQ(n->name, "v238");
28 }
29
30 DEFINE_TEST_MAIN(LOG_INFO);