X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2Fstdio%2Fperror.c;h=fc6ff87a4dc4c5ec15cd260e4270874a1057698a;hb=cc5d73c2db0ed51fcdf0b3c80fd043a7e91d4602;hp=609562a8e46a783a89420808117163d6d8ce5c5e;hpb=4721cb1b6b5a90da9b70d53569a3449cbd1f8cf7;p=pdclib.old 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; }