Use a slightly cleaner hack on BSD systems.
[gnulib.git] / tests / test-freading.c
index 3d69c40..1a38b9e 100644 (file)
 
 #include "freading.h"
 
+#include <stdio.h>
 #include <stdlib.h>
 
-#define ASSERT(expr) if (!(expr)) abort ();
+#define ASSERT(expr) \
+  do                                                                        \
+    {                                                                       \
+      if (!(expr))                                                          \
+        {                                                                   \
+          fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
+          abort ();                                                         \
+        }                                                                   \
+    }                                                                       \
+  while (0)
 
 #define TESTFILE "t-freading.tmp"
 
@@ -97,7 +107,9 @@ main ()
   ASSERT (!freading (fp));
   if (fseek (fp, 0, SEEK_END))
     goto skip;
-  ASSERT (!freading (fp));
+  /* freading (fp) is undefined here, because on some implementations (e.g.
+     glibc) fseek causes a buffer to be read.
+     fwriting (fp) is undefined as well.  */
   if (fclose (fp))
     goto skip;
 
@@ -135,7 +147,9 @@ main ()
   ASSERT (!freading (fp));
   if (fseek (fp, 0, SEEK_END))
     goto skip;
-  ASSERT (!freading (fp));
+  /* freading (fp) is undefined here, because on some implementations (e.g.
+     glibc) fseek causes a buffer to be read.
+     fwriting (fp) is undefined as well.  */
   if (fclose (fp))
     goto skip;