]> pd.if.org Git - pdclib/commitdiff
Fixed clearerr test driver.
authorMartin Baute <solar@rootdirectory.de>
Thu, 17 Mar 2016 20:10:52 +0000 (21:10 +0100)
committerMartin Baute <solar@rootdirectory.de>
Thu, 17 Mar 2016 20:10:52 +0000 (21:10 +0100)
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 ) );