]> pd.if.org Git - pdclib/blobdiff - functions/stdio/perror.c
Test drivers for fgetpos, fsetpos, and perror. Cannot really test closeall().
[pdclib] / functions / stdio / perror.c
index 609562a8e46a783a89420808117163d6d8ce5c5e..fc6ff87a4dc4c5ec15cd260e4270874a1057698a 100644 (file)
@@ -27,10 +27,24 @@ void perror( const char * s )
 
 #ifdef TEST
 #include <_PDCLIB_test.h>
+#include <stdlib.h>
+#include <string.h>
+#include <limits.h>
 
 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;
 }