From 02c714917d715c3c2c1e5dba155762d010733679 Mon Sep 17 00:00:00 2001 From: solar Date: Tue, 30 Nov 2010 23:56:38 +0000 Subject: [PATCH] Better error reporting on printf's. git-svn-id: https://srv7.svn-repos.de/dev34/pdclib/trunk@470 546481bc-9713-0410-bf18-d3337bbf4a3e --- functions/_PDCLIB/print.c | 4 +--- functions/stdio/snprintf.c | 4 +--- functions/stdio/sprintf.c | 4 +--- functions/stdio/vsnprintf.c | 4 +--- functions/stdio/vsprintf.c | 4 +--- testing/_PDCLIB_test.h | 3 +++ 6 files changed, 8 insertions(+), 15 deletions(-) diff --git a/functions/_PDCLIB/print.c b/functions/_PDCLIB/print.c index 8f01979..424228b 100644 --- a/functions/_PDCLIB/print.c +++ b/functions/_PDCLIB/print.c @@ -507,6 +507,7 @@ const char * _PDCLIB_print( const char * spec, struct _PDCLIB_status_t * status } #ifdef TEST +#define _PDCLIB_FILEID "_PDCLIB/print.c" #include <_PDCLIB_test.h> #include @@ -538,9 +539,6 @@ static int testprintf( char * buffer, const char * format, ... ) #define TEST_CONVERSION_ONLY -#define TESTCASE_SPRINTF( x ) if ( strcmp( target, x ) == 0 ) {} \ - else { TEST_RESULTS += 1; printf( "FAILED: " __FILE__ ", line %d - \"%s\" != %s\n", __LINE__, target, #x ); } - int main( void ) { char target[100]; diff --git a/functions/stdio/snprintf.c b/functions/stdio/snprintf.c index 851aefb..3cc30fc 100644 --- a/functions/stdio/snprintf.c +++ b/functions/stdio/snprintf.c @@ -24,6 +24,7 @@ int snprintf( char * _PDCLIB_restrict s, size_t n, const char * _PDCLIB_restrict #endif #ifdef TEST +#define _PDCLIB_FILEID "stdio/snprintf.c" #include <_PDCLIB_test.h> #include @@ -31,9 +32,6 @@ int snprintf( char * _PDCLIB_restrict s, size_t n, const char * _PDCLIB_restrict #define testprintf( s, format, ... ) snprintf( s, 100, format, __VA_ARGS__ ) -#define TESTCASE_SPRINTF( x ) if ( strcmp( target, x ) == 0 ) {} \ - else { TEST_RESULTS += 1; printf( "FAILED: " __FILE__ ", line %d - \"%s\" != %s\n", __LINE__, target, #x ); } - int main( void ) { char target[100]; diff --git a/functions/stdio/sprintf.c b/functions/stdio/sprintf.c index ca7e2d1..9c7e17a 100644 --- a/functions/stdio/sprintf.c +++ b/functions/stdio/sprintf.c @@ -25,6 +25,7 @@ int sprintf( char * _PDCLIB_restrict s, const char * _PDCLIB_restrict format, .. #endif #ifdef TEST +#define _PDCLIB_FILEID "stdio/sprintf.c" #include <_PDCLIB_test.h> #include @@ -32,9 +33,6 @@ int sprintf( char * _PDCLIB_restrict s, const char * _PDCLIB_restrict format, .. #define testprintf( s, format, ... ) sprintf( s, format, __VA_ARGS__ ) -#define TESTCASE_SPRINTF( x ) if ( strcmp( target, x ) == 0 ) {} \ - else { TEST_RESULTS += 1; printf( "FAILED: " __FILE__ ", line %d - \"%s\" != %s\n", __LINE__, target, #x ); } - int main( void ) { char target[100]; diff --git a/functions/stdio/vsnprintf.c b/functions/stdio/vsnprintf.c index 165ed54..9e54dca 100644 --- a/functions/stdio/vsnprintf.c +++ b/functions/stdio/vsnprintf.c @@ -48,6 +48,7 @@ int vsnprintf( char * _PDCLIB_restrict s, size_t n, const char * _PDCLIB_restric #endif #ifdef TEST +#define _PDCLIB_FILEID "stdio/vsnprintf.c" #include <_PDCLIB_test.h> #include @@ -64,9 +65,6 @@ static int testprintf( char * s, const char * format, ... ) return i; } -#define TESTCASE_SPRINTF( x ) if ( strcmp( target, x ) == 0 ) {} \ - else { TEST_RESULTS += 1; printf( "FAILED: " __FILE__ ", line %d - \"%s\" != %s\n", __LINE__, target, #x ); } - int main( void ) { char target[100]; diff --git a/functions/stdio/vsprintf.c b/functions/stdio/vsprintf.c index 803485e..bdb8a79 100644 --- a/functions/stdio/vsprintf.c +++ b/functions/stdio/vsprintf.c @@ -20,6 +20,7 @@ int vsprintf( char * _PDCLIB_restrict s, const char * _PDCLIB_restrict format, v #endif #ifdef TEST +#define _PDCLIB_FILEID "stdio/vsprintf.c" #include <_PDCLIB_test.h> #include @@ -36,9 +37,6 @@ static int testprintf( char * s, const char * format, ... ) return i; } -#define TESTCASE_SPRINTF( x ) if ( strcmp( target, x ) == 0 ) {} \ - else { TEST_RESULTS += 1; printf( "FAILED: " __FILE__ ", line %d - \"%s\" != %s\n", __LINE__, target, #x ); } - int main( void ) { char target[100]; diff --git a/testing/_PDCLIB_test.h b/testing/_PDCLIB_test.h index 7a7ff05..4eaa9d2 100644 --- a/testing/_PDCLIB_test.h +++ b/testing/_PDCLIB_test.h @@ -26,6 +26,9 @@ static int TEST_RESULTS = 0; #define TESTCASE( x ) if ( x ) {} \ else { TEST_RESULTS += 1; printf( "FAILED: " __FILE__ ", line %d - %s\n", __LINE__, #x ); } +#define TESTCASE_SPRINTF( x ) if ( strcmp( target, x ) == 0 ) {} \ + else { TEST_RESULTS += 1; printf( "FAILED: " __FILE__ " (" _PDCLIB_FILEID "), line %d - \"%s\" != \"%s\"\n", __LINE__, target, x ); } + #ifndef REGTEST #define TESTCASE_NOREG( x ) TESTCASE( x ) #else -- 2.30.2