X-Git-Url: https://git.gag.com/?a=blobdiff_plain;ds=sidebyside;f=functions%2Fstdio%2Ffreopen.c;h=682e3c6c1e8f4eee7e1839cf6e60ba2fb7f724dd;hb=2612fba05258dfde899375db0aa88e65c337395d;hp=482b82025d225cf5d5cdbb2b1e9a2e0000177ba0;hpb=1e4088e0a8ad680a929d6d9f27d1ef5447f43996;p=fw%2Fpdclib diff --git a/functions/stdio/freopen.c b/functions/stdio/freopen.c index 482b820..682e3c6 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 ); + TESTCASE( remove( testfile1 ) == 0 ); + TESTCASE( remove( testfile2 ) == 0 ); + return TEST_RESULTS; }