X-Git-Url: https://pd.if.org/git/?p=pdclib;a=blobdiff_plain;f=functions%2Fstdio%2Fperror.c;h=fc6ff87a4dc4c5ec15cd260e4270874a1057698a;hp=609562a8e46a783a89420808117163d6d8ce5c5e;hb=afde3daa4992d49e190a6e8677e7317e0d367c59;hpb=dc0120b7aacb31723bdfe3a385b2247ce7fee145 diff --git a/functions/stdio/perror.c b/functions/stdio/perror.c index 609562a..fc6ff87 100644 --- a/functions/stdio/perror.c +++ b/functions/stdio/perror.c @@ -27,10 +27,24 @@ void perror( const char * s ) #ifdef TEST #include <_PDCLIB_test.h> +#include +#include +#include int main( void ) { - TESTCASE( NO_TESTDRIVER ); + FILE * fh; + unsigned long long max = ULLONG_MAX; + char buffer[100]; + sprintf( buffer, "%llu", max ); + TESTCASE( ( fh = freopen( testfile, "wb+", stderr ) ) != NULL ); + TESTCASE( strtol( buffer, NULL, 10 ) == LONG_MAX ); + perror( "Test" ); + rewind( fh ); + TESTCASE( fread( buffer, 1, 7, fh ) == 7 ); + TESTCASE( memcmp( buffer, "Test: ", 6 ) == 0 ); + TESTCASE( fclose( fh ) == 0 ); + remove( testfile ); return TEST_RESULTS; }