X-Git-Url: https://pd.if.org/git/?p=pdclib;a=blobdiff_plain;f=functions%2Fstdio%2Ffreopen.c;h=2d900fd510dfeab1cc26ca1ea9d046bef2b10f78;hp=482b82025d225cf5d5cdbb2b1e9a2e0000177ba0;hb=d451ae8a715aa5fe6f2fb6f4d2494b11f4d11f2f;hpb=0326491c5ed243ea6efc5e66e3a6ea21427aad92 diff --git a/functions/stdio/freopen.c b/functions/stdio/freopen.c index 482b820..2d900fd 100644 --- a/functions/stdio/freopen.c +++ b/functions/stdio/freopen.c @@ -81,7 +81,24 @@ struct _PDCLIB_file_t * freopen( const char * _PDCLIB_restrict filename, const c int main( void ) { - TESTCASE( NO_TESTDRIVER ); + 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 ); + remove( testfile1 ); + remove( testfile2 ); + return TEST_RESULTS; }