Testdriver for tmpfile().
[fw/pdclib] / platform / example / functions / stdio / tmpfile.c
index 44b975d36b13a96f2bf8d63717cd680ec230201f..b2c099b0c580d6b6d8cf552ad23349e0aceb1f85 100644 (file)
@@ -89,10 +89,23 @@ struct _PDCLIB_file_t * tmpfile( void )
 
 #ifdef TEST
 #include <_PDCLIB_test.h>
+#include <string.h>
 
 int main()
 {
-    TESTCASE( NO_TESTDRIVER );
+    FILE * fh;
+    char filename[ L_tmpnam ];
+    FILE * fhtest;
+    TESTCASE( ( fh = tmpfile() ) != NULL );
+    TESTCASE( fputc( 'x', fh ) == 'x' );
+    /* Checking that file is actually there */
+    TESTCASE_NOREG( strcpy( filename, fh->filename ) == filename );
+    TESTCASE_NOREG( ( fhtest = fopen( filename, "r" ) ) != NULL );
+    TESTCASE_NOREG( fclose( fhtest ) == 0 );
+    /* Closing tmpfile */
+    TESTCASE( fclose( fh ) == 0 );
+    /* Checking that file was deleted */
+    TESTCASE_NOREG( fopen( filename, "r" ) == NULL );
     return TEST_RESULTS;
 }