source: web/old/remctl-2.14/tests/portable/inet_ntoa-t.c @ f6f3e91

web
Last change on this file since f6f3e91 was f6f3e91, checked in by Jessica B. Hamrick <jhamrick@…>, 15 years ago

Preserve directory hierarchy (not sure what happened to it)

  • Property mode set to 100644
File size: 1.0 KB
Line 
1/*
2 * inet_ntoa test suite.
3 *
4 * Written by Russ Allbery <rra@stanford.edu>
5 * Copyright 2009 Board of Trustees, Leland Stanford Jr. University
6 * Copyright (c) 2004, 2005, 2006, 2007
7 *     by Internet Systems Consortium, Inc. ("ISC")
8 * Copyright (c) 1991, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
9 *     2002, 2003 by The Internet Software Consortium and Rich Salz
10 *
11 * See LICENSE for licensing terms.
12 */
13
14#include <config.h>
15#include <portable/system.h>
16#include <portable/socket.h>
17
18#include <tests/tap/basic.h>
19
20const char *test_inet_ntoa(const struct in_addr);
21
22
23static void
24test_addr(const char *expected, unsigned long addr)
25{
26    struct in_addr in;
27
28    in.s_addr = htonl(addr);
29    is_string(expected, test_inet_ntoa(in), "address %s", expected);
30}
31
32
33int
34main(void)
35{
36    plan(5);
37
38    test_addr(        "0.0.0.0", 0x0);
39    test_addr(      "127.0.0.0", 0x7f000000UL);
40    test_addr("255.255.255.255", 0xffffffffUL);
41    test_addr("172.200.232.199", 0xacc8e8c7UL);
42    test_addr(        "1.2.3.4", 0x01020304UL);
43
44    return 0;
45}
Note: See TracBrowser for help on using the repository browser.