X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=platform%2Fexample%2Ffunctions%2Fstdio%2Ftmpfile.c;h=b778f3f9dabe374c63a54b551b4e2bbf38d61669;hb=8cfc7f73e7baec32630b9cf55582febd41b8a684;hp=44b975d36b13a96f2bf8d63717cd680ec230201f;hpb=eac150f3e3dc119ad89e6d089d28a8c4b6c79223;p=pdclib.old diff --git a/platform/example/functions/stdio/tmpfile.c b/platform/example/functions/stdio/tmpfile.c index 44b975d..b778f3f 100644 --- a/platform/example/functions/stdio/tmpfile.c +++ b/platform/example/functions/stdio/tmpfile.c @@ -89,10 +89,25 @@ struct _PDCLIB_file_t * tmpfile( void ) #ifdef TEST #include <_PDCLIB_test.h> +#include int main() { - 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; }