X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2Fstdio%2Fclearerr.c;h=ca22b0332b72b3f8f84bf3c490e2cd520e068a43;hb=3ffa88d3e16e7564ff81bf3650b5afa113caac97;hp=61461c9922431d4c2742bcf993cd7a3940f879a9;hpb=d6f1494a4f38a212b29a13ee713885058dcf0fe7;p=pdclib diff --git a/functions/stdio/clearerr.c b/functions/stdio/clearerr.c index 61461c9..ca22b03 100644 --- a/functions/stdio/clearerr.c +++ b/functions/stdio/clearerr.c @@ -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 ) );