5 This file is part of the Public Domain C Library (PDCLib).
6 Permission is granted to use, modify, and / or redistribute at will.
13 void clearerr( struct _PDCLIB_file_t * stream )
15 stream->status &= ~( _PDCLIB_ERRORFLAG | _PDCLIB_EOFFLAG );
21 #include <_PDCLIB_test.h>
26 TESTCASE( ( fh = tmpfile() ) != NULL );
27 /* Flags should be clear */
28 TESTCASE( ! ferror( fh ) );
29 TESTCASE( ! feof( fh ) );
30 /* Reading from input stream - should provoke error */
31 /* FIXME: Apparently glibc disagrees on this assumption. How to provoke error on glibc? */
32 TESTCASE( fgetc( fh ) == EOF );
33 TESTCASE( ferror( fh ) );
34 TESTCASE( ! feof( fh ) );
35 /* clearerr() should clear flags */
37 TESTCASE( ! ferror( fh ) );
38 TESTCASE( ! feof( fh ) );
39 /* Reading from empty stream - should provoke EOF */
41 TESTCASE( fgetc( fh ) == EOF );
42 TESTCASE( ! ferror( fh ) );
43 TESTCASE( feof( fh ) );
44 /* clearerr() should clear flags */
46 TESTCASE( ! ferror( fh ) );
47 TESTCASE( ! feof( fh ) );
48 TESTCASE( fclose( fh ) == 0 );