// S : tags stdio libc c // S : expect --result valid // S : cc -o test.bc -D_PDCLIB_BUILD -DTEST $file // S : verify -o nofail:malloc test.bc #include #include "_PDCLIB_test.h" int main( void ) { FILE * fin; FILE * fout; TESTCASE( ( fin = fopen( testfile1, "wb+" ) ) != NULL ); TESTCASE( fputc( 'x', fin ) == 'x' ); TESTCASE( fclose( fin ) == 0 ); TESTCASE( ( fin = freopen( testfile1, "rb", stdin ) ) != NULL ); TESTCASE( getchar() == 'x' ); TESTCASE( ( fout = freopen( testfile2, "wb+", stdout ) ) != NULL ); TESTCASE( putchar( 'x' ) == 'x' ); rewind( fout ); TESTCASE( fgetc( fout ) == 'x' ); TESTCASE( fclose( fin ) == 0 ); TESTCASE( fclose( fout ) == 0 ); TESTCASE( remove( testfile1 ) == 0 ); TESTCASE( remove( testfile2 ) == 0 ); return TEST_RESULTS; }