X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2Fstdio%2Fperror.c;h=bf3b3afee1c1bf0028218f657263853c0ffcc7a6;hb=a7a8d2f1c85c2d7760d4d3479e90466cc3a81b04;hp=609562a8e46a783a89420808117163d6d8ce5c5e;hpb=4116251e9bb6c386580d71d8c4afd2d0d08c6096;p=pdclib diff --git a/functions/stdio/perror.c b/functions/stdio/perror.c index 609562a..bf3b3af 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 ); + TESTCASE( remove( testfile ) == 0 ); return TEST_RESULTS; }