install-reloc: Support multi-binary installation.
[gnulib.git] / tests / test-memchr2.c
index c7ba6b9..d0f8125 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008-2009 Free Software Foundation
+ * Copyright (C) 2008-2013 Free Software Foundation, Inc.
  * Written by Eric Blake
  *
  * This program is free software: you can redistribute it and/or modify
 
 #include "memchr2.h"
 
-#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
 #include "zerosize-ptr.h"
-
-#define ASSERT(expr) \
-  do                                                                        \
-    {                                                                       \
-      if (!(expr))                                                          \
-       {                                                                    \
-         fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
-         fflush (stderr);                                                   \
-         abort ();                                                          \
-       }                                                                    \
-    }                                                                       \
-  while (0)
+#include "macros.h"
 
 /* Calculating void * + int is not portable, so this wrapper converts
    to char * to make the tests easier to write.  */
 #define MEMCHR2 (char *) memchr2
 
 int
-main ()
+main (void)
 {
   size_t n = 0x100000;
   char *input = malloc (n);
@@ -84,10 +72,10 @@ main ()
     size_t repeat = 10000;
     for (; repeat > 0; repeat--)
       {
-       ASSERT (MEMCHR2 (input, 'c', 'e', n) == input + 2);
-       ASSERT (MEMCHR2 (input, 'e', 'c', n) == input + 2);
-       ASSERT (MEMCHR2 (input, 'c', '\0', n) == input + 2);
-       ASSERT (MEMCHR2 (input, '\0', 'c', n) == input + 2);
+        ASSERT (MEMCHR2 (input, 'c', 'e', n) == input + 2);
+        ASSERT (MEMCHR2 (input, 'e', 'c', n) == input + 2);
+        ASSERT (MEMCHR2 (input, 'c', '\0', n) == input + 2);
+        ASSERT (MEMCHR2 (input, '\0', 'c', n) == input + 2);
       }
   }
 
@@ -96,13 +84,13 @@ main ()
     int i, j;
     for (i = 0; i < 32; i++)
       {
-       for (j = 0; j < 256; j++)
-         input[i + j] = j;
-       for (j = 0; j < 256; j++)
-         {
-           ASSERT (MEMCHR2 (input + i, j, 0xff, 256) == input + i + j);
-           ASSERT (MEMCHR2 (input + i, 0xff, j, 256) == input + i + j);
-         }
+        for (j = 0; j < 256; j++)
+          input[i + j] = j;
+        for (j = 0; j < 256; j++)
+          {
+            ASSERT (MEMCHR2 (input + i, j, 0xff, 256) == input + i + j);
+            ASSERT (MEMCHR2 (input + i, 0xff, j, 256) == input + i + j);
+          }
       }
   }