X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=platform%2Fexample_cygwin%2Ffunctions%2Fstdio%2Ftmpfile.c;h=3049260a5d332dfcc29681030b2685731ba52c0f;hb=babe116007c414671ede1a315f16f7936fa3bb0b;hp=255a35eb75721d58d352cd1279a1dd7f3fdda622;hpb=0c316ee3b4dc0712797877f5dc0f4a789646154d;p=pdclib diff --git a/platform/example_cygwin/functions/stdio/tmpfile.c b/platform/example_cygwin/functions/stdio/tmpfile.c index 255a35e..3049260 100644 --- a/platform/example_cygwin/functions/stdio/tmpfile.c +++ b/platform/example_cygwin/functions/stdio/tmpfile.c @@ -21,9 +21,21 @@ struct _PDCLIB_file_t * tmpfile( void ) #ifdef TEST #include <_PDCLIB_test.h> -int main() +int main( void ) { - 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; }