]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - inet/tst-network.c
Update copyright dates with scripts/update-copyrights.
[thirdparty/glibc.git] / inet / tst-network.c
index 71ef031c781bbaf9f081441521ab0c46e6a4908c..e0befd79538bc3674b583e64ba2810b7dd3aade9 100644 (file)
@@ -1,5 +1,5 @@
 /* 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>
@@ -34,7 +34,11 @@ struct
   {"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},
@@ -47,11 +51,11 @@ struct
 };
 
 
-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)
@@ -61,6 +65,7 @@ main (void)
 
       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",
@@ -71,3 +76,6 @@ main (void)
 
   return errors != 0;
 }
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"