X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2Fstdio%2Ffreopen.c;h=3765b2b8d99c35119f31a89e6246fe5e0042fe2a;hb=5596d52a975696c29adc741ac1cdb49fb7315d73;hp=482b82025d225cf5d5cdbb2b1e9a2e0000177ba0;hpb=71712a8bb92d6a10218e3356c6d26554dc2633dd;p=pdclib diff --git a/functions/stdio/freopen.c b/functions/stdio/freopen.c index 482b820..3765b2b 100644 --- a/functions/stdio/freopen.c +++ b/functions/stdio/freopen.c @@ -1,5 +1,3 @@ -/* $Id$ */ - /* freopen( const char *, const char *, FILE * ) This file is part of the Public Domain C Library (PDCLib). @@ -81,7 +79,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; }