]> pd.if.org Git - pdclib/blobdiff - platform/example/functions/stdio/tmpfile.c
Fixed prototype warnings.
[pdclib] / platform / example / functions / stdio / tmpfile.c
index 44b975d36b13a96f2bf8d63717cd680ec230201f..29750d46b2a7757cf785c10fa9756dfc98503622 100644 (file)
@@ -89,10 +89,25 @@ struct _PDCLIB_file_t * tmpfile( void )
 
 #ifdef TEST
 #include <_PDCLIB_test.h>
+#include <string.h>
 
-int main()
+int main( void )
 {
-    TESTCASE( NO_TESTDRIVER );
+    FILE * fh;
+#ifndef REGTEST
+    char filename[ L_tmpnam ];
+    FILE * fhtest;
+#endif
+    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;
 }