Test driver for freopen().
authorsolar <solar@546481bc-9713-0410-bf18-d3337bbf4a3e>
Thu, 2 Dec 2010 07:19:35 +0000 (07:19 +0000)
committersolar <solar@546481bc-9713-0410-bf18-d3337bbf4a3e>
Thu, 2 Dec 2010 07:19:35 +0000 (07:19 +0000)
git-svn-id: https://srv7.svn-repos.de/dev34/pdclib/trunk@475 546481bc-9713-0410-bf18-d3337bbf4a3e

functions/stdio/freopen.c

index 482b82025d225cf5d5cdbb2b1e9a2e0000177ba0..2d900fd510dfeab1cc26ca1ea9d046bef2b10f78 100644 (file)
@@ -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;
 }