From: solar Date: Thu, 2 Dec 2010 07:19:35 +0000 (+0000) Subject: Test driver for freopen(). X-Git-Url: https://git.gag.com/?p=fw%2Fpdclib;a=commitdiff_plain;h=b71ed9e10121ec9fb5d83ec71efb4afb408d3aee Test driver for freopen(). git-svn-id: https://srv7.svn-repos.de/dev34/pdclib/trunk@475 546481bc-9713-0410-bf18-d3337bbf4a3e --- 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; }