]> pd.if.org Git - pdclib/blobdiff - testing/_PDCLIB_iotest.h
Fixing compiler warnings.
[pdclib] / testing / _PDCLIB_iotest.h
index 134a4446809447c1acd1890834d1023cdb97c93e..155ac16d51036c3935227ec85df331186403aee7 100644 (file)
@@ -1,5 +1,3 @@
-/* $Id$ */
-
 /* PDCLib testing suite <_PDCLIB_test.h>
 
    This file is part of the Public Domain C Library (PDCLib).
 #if defined( _PDCLIB_FILEIO )
    #define GET_RESULT \
       rewind( target ); \
-      fread( result_buffer, 1, actual_rc, target );
+      if ( (int)fread( result_buffer, 1, actual_rc, target ) != actual_rc ) \
+      { \
+          fprintf( stderr, "GET_RESULT failed." ); \
+      }
    #define RESULT_MISMATCH( act, exp ) strcmp( result_buffer, exp ) != 0
    #define RESULT_STRING( tgt ) result_buffer
 #elif defined( _PDCLIB_STRINGIO )
@@ -32,6 +33,7 @@
 #define PREP_RESULT_BUFFER
 #endif
 
+#define GETFMT( fmt, ... ) (fmt)
 #define PRINTF_TEST( expected_rc, expected_string, ... ) do { \
         PREP_RESULT_BUFFER \
         int actual_rc = testprintf( target, __VA_ARGS__ ); \
              ( RESULT_MISMATCH( target, expected_string ) ) ) \
         { \
             ++TEST_RESULTS; \
-            fprintf( stderr, "FAILED: " __FILE__ " (" _PDCLIB_FILEID "), line %d\n        expected %2d, \"%s\"\n        actual   %2d, \"%s\"\n", __LINE__, expected_rc, expected_string, actual_rc, RESULT_STRING( target ) ); \
+            fprintf( stderr, \
+                "FAILED: " __FILE__ " (" _PDCLIB_FILEID "), line %d\n" \
+                "        format string \"%s\"\n" \
+                "        expected %2d, \"%s\"\n" \
+                "        actual   %2d, \"%s\"\n", \
+                 __LINE__, GETFMT(__VA_ARGS__, 0), expected_rc, \
+                 expected_string, actual_rc, RESULT_STRING( target ) ); \
         } \
     } while ( 0 )