/* Test for inet_network.
- Copyright (C) 2000 Free Software Foundation, Inc.
+ Copyright (C) 2000-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Andreas Jaeger <aj@suse.de>, 2000.
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <stdio.h>
+#include <stdint.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
{"1.0", 0x100},
{"1", 0x1},
{"192.168.0.0", 0xC0A80000},
+ {"0", 0},
+ {"0x0", 0},
/* Now some invalid addresses. */
+ {"0x", INADDR_NONE},
+ {"1 bar", INADDR_NONE}, /* Bug 15277. */
{"141.30.225.2800", INADDR_NONE},
{"141.76.1.1.1", INADDR_NONE},
{"141.76.1.11.", INADDR_NONE},
};
-int
-main (void)
+static int
+do_test (void)
{
int errors = 0;
- int i;
+ size_t i;
uint32_t res;
for (i = 0; i < sizeof (tests) / sizeof (tests[0]); ++i)
if (res != tests[i].number)
{
+ ++errors;
printf ("Test failed for inet_network (\"%s\"):\n",
tests[i].network);
printf ("Expected return value %u (0x%x) but got %u (0x%x).\n",
return errors != 0;
}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"