-/* $Id$ */
-
/* freopen( const char *, const char *, FILE * )
This file is part of the Public Domain C Library (PDCLib).
*/
#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
#ifndef REGTEST
-#include <_PDCLIB_glue.h>
-#include <stdlib.h>
-#include <string.h>
+#include "_PDCLIB_glue.h"
struct _PDCLIB_file_t * freopen( const char * _PDCLIB_restrict filename, const char * _PDCLIB_restrict mode, struct _PDCLIB_file_t * _PDCLIB_restrict stream )
{
#endif
#ifdef TEST
-#include <_PDCLIB_test.h>
+
+#include "_PDCLIB_test.h"
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;
}