strtod: next round of AIX fixes
[gnulib.git] / tests / test-getdate.c
index 5866886..5f7095c 100644 (file)
@@ -1,5 +1,5 @@
 /* Test of getdate() function.
-   Copyright (C) 2008, 2009 Free Software Foundation, Inc.
+   Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
 
 #include <config.h>
 
+#include "getdate.h"
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
 #include "progname.h"
-
-#include "getdate.h"
-
-#define ASSERT(expr)                                                   \
-  do                                                                   \
-    {                                                                  \
-      if (!(expr))                                                     \
-       {                                                               \
-         fprintf (stderr, "%s:%d: assertion failed\n",                 \
-                  __FILE__, __LINE__);                                 \
-         fflush (stderr);                                              \
-         abort ();                                                     \
-       }                                                               \
-    }                                                                  \
-  while (0)
+#include "macros.h"
 
 #ifdef DEBUG
-#define LOG(str, now, res)                                             \
-  printf ("string `%s' diff %d %d\n",                  \
-         str, res.tv_sec - now.tv_sec, res.tv_nsec - now.tv_nsec);
+#define LOG(str, now, res)                                              \
+  printf ("string `%s' diff %d %d\n",                   \
+          str, res.tv_sec - now.tv_sec, res.tv_nsec - now.tv_nsec);
 #else
 #define LOG(str, now, res) (void) 0
 #endif
@@ -61,7 +49,7 @@ static const char* const day_table[] =
 };
 
 int
-main (int argc _UNUSED_PARAMETER_, char **argv)
+main (int argc _GL_UNUSED, char **argv)
 {
   struct timespec result;
   struct timespec result2;
@@ -84,7 +72,7 @@ main (int argc _UNUSED_PARAMETER_, char **argv)
   ASSERT (get_date (&result, p, &now));
   LOG (p, now, result);
   ASSERT (now.tv_sec + 24 * 60 * 60 == result.tv_sec
-         && now.tv_nsec == result.tv_nsec);
+          && now.tv_nsec == result.tv_nsec);
 
   now.tv_sec = 4711;
   now.tv_nsec = 1267;
@@ -92,7 +80,7 @@ main (int argc _UNUSED_PARAMETER_, char **argv)
   ASSERT (get_date (&result, p, &now));
   LOG (p, now, result);
   ASSERT (now.tv_sec - 24 * 60 * 60 == result.tv_sec
-         && now.tv_nsec == result.tv_nsec);
+          && now.tv_nsec == result.tv_nsec);
 
   now.tv_sec = 4711;
   now.tv_nsec = 1267;
@@ -100,7 +88,7 @@ main (int argc _UNUSED_PARAMETER_, char **argv)
   ASSERT (get_date (&result, p, &now));
   LOG (p, now, result);
   ASSERT (now.tv_sec + 4 * 60 * 60 == result.tv_sec
-         && now.tv_nsec == result.tv_nsec);
+          && now.tv_nsec == result.tv_nsec);
 
   /* test if timezone is not being ignored for day offset */
   now.tv_sec = 4711;
@@ -112,7 +100,7 @@ main (int argc _UNUSED_PARAMETER_, char **argv)
   ASSERT (get_date (&result2, p, &now));
   LOG (p, now, result2);
   ASSERT (result.tv_sec == result2.tv_sec
-         && result.tv_nsec == result2.tv_nsec);
+          && result.tv_nsec == result2.tv_nsec);
 
   /* test if several time zones formats are handled same way */
   now.tv_sec = 4711;
@@ -124,12 +112,12 @@ main (int argc _UNUSED_PARAMETER_, char **argv)
   ASSERT (get_date (&result2, p, &now));
   LOG (p, now, result2);
   ASSERT (result.tv_sec == result2.tv_sec
-         && result.tv_nsec == result2.tv_nsec);
+          && result.tv_nsec == result2.tv_nsec);
   p = "UTC+1400";
   ASSERT (get_date (&result2, p, &now));
   LOG (p, now, result2);
   ASSERT (result.tv_sec == result2.tv_sec
-         && result.tv_nsec == result2.tv_nsec);
+          && result.tv_nsec == result2.tv_nsec);
 
   now.tv_sec = 4711;
   now.tv_nsec = 1267;
@@ -140,12 +128,12 @@ main (int argc _UNUSED_PARAMETER_, char **argv)
   ASSERT (get_date (&result2, p, &now));
   LOG (p, now, result2);
   ASSERT (result.tv_sec == result2.tv_sec
-         && result.tv_nsec == result2.tv_nsec);
+          && result.tv_nsec == result2.tv_nsec);
   p = "UTC-1400";
   ASSERT (get_date (&result2, p, &now));
   LOG (p, now, result2);
   ASSERT (result.tv_sec == result2.tv_sec
-         && result.tv_nsec == result2.tv_nsec);
+          && result.tv_nsec == result2.tv_nsec);
 
   now.tv_sec = 4711;
   now.tv_nsec = 1267;
@@ -156,7 +144,7 @@ main (int argc _UNUSED_PARAMETER_, char **argv)
   ASSERT (get_date (&result2, p, &now));
   LOG (p, now, result2);
   ASSERT (result.tv_sec == result2.tv_sec
-         && result.tv_nsec == result2.tv_nsec);
+          && result.tv_nsec == result2.tv_nsec);
 
   now.tv_sec = 4711;
   now.tv_nsec = 1267;
@@ -167,7 +155,7 @@ main (int argc _UNUSED_PARAMETER_, char **argv)
   ASSERT (get_date (&result2, p, &now));
   LOG (p, now, result2);
   ASSERT (result.tv_sec == result2.tv_sec
-         && result.tv_nsec == result2.tv_nsec);
+          && result.tv_nsec == result2.tv_nsec);
 
 
   /* TZ out of range should cause get_date failure */
@@ -176,7 +164,7 @@ main (int argc _UNUSED_PARAMETER_, char **argv)
   p = "UTC+25:00";
   ASSERT (!get_date (&result, p, &now));
 
-       /* Check for several invalid countable dayshifts */
+        /* Check for several invalid countable dayshifts */
   now.tv_sec = 4711;
   now.tv_nsec = 1267;
   p = "UTC+4:00 +40 yesterday";
@@ -202,7 +190,7 @@ main (int argc _UNUSED_PARAMETER_, char **argv)
   ASSERT (get_date (&result2, p, &now));
   LOG (p, now, result2);
   ASSERT (result.tv_sec == result2.tv_sec
-         && result.tv_nsec == result2.tv_nsec);
+          && result.tv_nsec == result2.tv_nsec);
   now.tv_sec = 4711;
   now.tv_nsec = 1267;
   p = "UTC+400 yesterday";
@@ -212,7 +200,7 @@ main (int argc _UNUSED_PARAMETER_, char **argv)
   ASSERT (get_date (&result2, p, &now));
   LOG (p, now, result2);
   ASSERT (result.tv_sec == result2.tv_sec
-         && result.tv_nsec == result2.tv_nsec);
+          && result.tv_nsec == result2.tv_nsec);
   now.tv_sec = 4711;
   now.tv_nsec = 1267;
   p = "UTC+400 now";
@@ -222,7 +210,7 @@ main (int argc _UNUSED_PARAMETER_, char **argv)
   ASSERT (get_date (&result2, p, &now));
   LOG (p, now, result2);
   ASSERT (result.tv_sec == result2.tv_sec
-         && result.tv_nsec == result2.tv_nsec);
+          && result.tv_nsec == result2.tv_nsec);
 
   /* Check that some "next Monday", "last Wednesday", etc. are correct.  */
   setenv ("TZ", "UTC0", 1);
@@ -253,7 +241,7 @@ main (int argc _UNUSED_PARAMETER_, char **argv)
   ASSERT (get_date (&result, p, &now));
   LOG (p, now, result);
   ASSERT (result.tv_sec == now.tv_sec
-         && result.tv_nsec == now.tv_nsec);
+          && result.tv_nsec == now.tv_nsec);
 
   p = "FRIDAY UTC+00";
   now.tv_sec = 0;
@@ -261,7 +249,7 @@ main (int argc _UNUSED_PARAMETER_, char **argv)
   ASSERT (get_date (&result, p, &now));
   LOG (p, now, result);
   ASSERT (result.tv_sec == 24 * 3600
-         && result.tv_nsec == now.tv_nsec);
+          && result.tv_nsec == now.tv_nsec);
 
   return 0;
 }