]> pd.if.org Git - pdclib/blobdiff - functions/stdio/clearerr.c
Fixed clearerr test driver.
[pdclib] / functions / stdio / clearerr.c
index 61461c9922431d4c2742bcf993cd7a3940f879a9..ca22b0332b72b3f8f84bf3c490e2cd520e068a43 100644 (file)
@@ -25,20 +25,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 ) );