X-Git-Url: https://git.gag.com/?p=fw%2Fpdclib;a=blobdiff_plain;f=platform%2Fexample%2Ffunctions%2Fstdio%2Ftmpfile.c;h=b2c099b0c580d6b6d8cf552ad23349e0aceb1f85;hp=44b975d36b13a96f2bf8d63717cd680ec230201f;hb=98263bcb0de07459069c5a39867a4fd3d6a08da7;hpb=b71ed9e10121ec9fb5d83ec71efb4afb408d3aee diff --git a/platform/example/functions/stdio/tmpfile.c b/platform/example/functions/stdio/tmpfile.c index 44b975d..b2c099b 100644 --- a/platform/example/functions/stdio/tmpfile.c +++ b/platform/example/functions/stdio/tmpfile.c @@ -89,10 +89,23 @@ struct _PDCLIB_file_t * tmpfile( void ) #ifdef TEST #include <_PDCLIB_test.h> +#include 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; }