4 #include <netinet/in.h>
8 test (unsigned int inaddr
, const char *expected
)
14 addr
.s_addr
= htonl (inaddr
);
15 res
= inet_ntoa (addr
);
16 fail
= strcmp (res
, expected
);
18 printf ("%#010x -> \"%s\" -> %s%s\n", inaddr
, res
,
19 fail
? "fail, expected" : "ok", fail
? expected
: "");
30 result
|= test (INADDR_LOOPBACK
, "127.0.0.1");
31 result
|= test (INADDR_BROADCAST
, "255.255.255.255");
32 result
|= test (INADDR_ANY
, "0.0.0.0");
33 result
|= test (0xc0060746, "192.6.7.70");
38 #define TEST_FUNCTION do_test ()
39 #include "../test-skeleton.c"