]> pd.if.org Git - pdclib/blobdiff - functions/stdio/clearerr.c
Whitespace cleanups.
[pdclib] / functions / stdio / clearerr.c
index 5664bbfcd4b272ac7c5c1217a04f43054887a1be..91cd00a6655e9d619efd5a5f6e48301a0d0f832a 100644 (file)
@@ -16,7 +16,8 @@ void clearerr( struct _PDCLIB_file_t * stream )
 #endif
 
 #ifdef TEST
-#include <_PDCLIB_test.h>
+
+#include "_PDCLIB_test.h"
 
 int main( void )
 {
@@ -25,20 +26,21 @@ int main( void )
     /* Flags should be clear */
     TESTCASE( ! ferror( fh ) );
     TESTCASE( ! feof( fh ) );
-    /* Reading from input stream - should provoke error */
-    /* FIXME: Apparently glibc disagrees on this assumption. How to provoke error on glibc? */
+    /* Reading from empty stream - should provoke EOF */
+    rewind( fh );
     TESTCASE( fgetc( fh ) == EOF );
-    TESTCASE( ferror( fh ) );
-    TESTCASE( feof( fh ) );
+    TESTCASE( ferror( fh ) );
+    TESTCASE( feof( fh ) );
     /* clearerr() should clear flags */
     clearerr( fh );
     TESTCASE( ! ferror( fh ) );
     TESTCASE( ! feof( fh ) );
-    /* Reading from empty stream - should provoke EOF */
-    rewind( fh );
+    /* reopen() the file write-only */
+    TESTCASE( ( fh = freopen( NULL, "w", fh ) ) != NULL );
+    /* Reading from write-only stream - should provoke error */
     TESTCASE( fgetc( fh ) == EOF );
-    TESTCASE( ferror( fh ) );
-    TESTCASE( feof( fh ) );
+    TESTCASE( ferror( fh ) );
+    TESTCASE( feof( fh ) );
     /* clearerr() should clear flags */
     clearerr( fh );
     TESTCASE( ! ferror( fh ) );
@@ -48,4 +50,3 @@ int main( void )
 }
 
 #endif
-