/* * inet_ntoa test suite. * * Written by Russ Allbery * Copyright 2009 Board of Trustees, Leland Stanford Jr. University * Copyright (c) 2004, 2005, 2006, 2007 * by Internet Systems Consortium, Inc. ("ISC") * Copyright (c) 1991, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, * 2002, 2003 by The Internet Software Consortium and Rich Salz * * See LICENSE for licensing terms. */ #include #include #include #include const char *test_inet_ntoa(const struct in_addr); static void test_addr(const char *expected, unsigned long addr) { struct in_addr in; in.s_addr = htonl(addr); is_string(expected, test_inet_ntoa(in), "address %s", expected); } int main(void) { plan(5); test_addr( "0.0.0.0", 0x0); test_addr( "127.0.0.0", 0x7f000000UL); test_addr("255.255.255.255", 0xffffffffUL); test_addr("172.200.232.199", 0xacc8e8c7UL); test_addr( "1.2.3.4", 0x01020304UL); return 0; }