]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/test/test-af-list.c
Add SPDX license identifiers to source files under the LGPL
[thirdparty/systemd.git] / src / test / test-af-list.c
CommitLineData
53e1b683 1/* SPDX-License-Identifier: LGPL-2.1+ */
da8ba721
DM
2/***
3 This file is part of systemd
4
5 Copyright 2015 Daniel Mack
6
7 systemd is free software; you can redistribute it and/or modify it
8 under the terms of the GNU Lesser General Public License as published by
9 the Free Software Foundation; either version 2.1 of the License, or
10 (at your option) any later version.
11
12 systemd is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public License
18 along with systemd; If not, see <http://www.gnu.org/licenses/>.
19***/
20
da8ba721 21#include <string.h>
07630cea 22#include <sys/socket.h>
da8ba721
DM
23
24#include "macro.h"
07630cea 25#include "string-util.h"
da8ba721
DM
26#include "util.h"
27
96315188 28_unused_
c9f7b4d3 29static const struct af_name* lookup_af(register const char *str, register GPERF_LEN_TYPE len);
da8ba721 30
07630cea 31#include "af-from-name.h"
da8ba721
DM
32#include "af-list.h"
33#include "af-to-name.h"
da8ba721
DM
34
35int main(int argc, const char *argv[]) {
36
37 unsigned int i;
38
39 for (i = 0; i < ELEMENTSOF(af_names); i++) {
40 if (af_names[i]) {
41 assert_se(streq(af_to_name(i), af_names[i]));
42 assert_se(af_from_name(af_names[i]) == (int) i);
43 }
44 }
45
46 assert_se(af_to_name(af_max()) == NULL);
47 assert_se(af_to_name(-1) == NULL);
48 assert_se(af_from_name("huddlduddl") == AF_UNSPEC);
49
50 return 0;
07630cea 51}