X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=functions%2Fstdio%2Ffscan_sources.incl;h=6502356878096bd424580e4178f1b057b0f72855;hb=2af8fa96cb1160d888f49d5d6d4671490ccbfca3;hp=9ee2b20660de331c9c4c12dc1fcba42162128e0c;hpb=631b18b0f447b176e6baf7e8dd88ed3709abe9be;p=fw%2Fpdclib diff --git a/functions/stdio/fscan_sources.incl b/functions/stdio/fscan_sources.incl index 9ee2b20..6502356 100644 --- a/functions/stdio/fscan_sources.incl +++ b/functions/stdio/fscan_sources.incl @@ -13,10 +13,10 @@ FILE * hexadecimal = fopen( "scanf_testdata_hexadecimal", "wb+" ); TESTCASE( hexadecimal != NULL ); - TESTCASE( fwrite( "-0x0 -0x000 -0x7f 0x80 0xff -0x7fff 0x8000\n" - "0xffff -0x7fffffff 0x80000000 0xffffffff\n" - "-0x7fffffffffffffff 0x8000000000000000\n" - "0xffffffffffffffff\n", 1, 142, hexadecimal ) == 142 ); + TESTCASE( fwrite( "-0x0 -0x000 -0x7f -0x80 0xff -0x7fff -0x8000\n" + "0xffff -0x7fffffff -0x80000000 0xffffffff\n" + "-0x7fffffffffffffff -0x8000000000000000\n" + "0xffffffffffffffff\n", 1, 146, hexadecimal ) == 146 ); rewind( hexadecimal ); FILE * octal = fopen( "scanf_testdata_octal", "wb+" ); @@ -40,12 +40,26 @@ /* fscan */ -#define TESTSCAN( result, count, source, offset, format ) \ +#define TESTSCAN( result, count, source, offset, ... ) \ do \ { \ int n = -1; \ TESTCASE( fseek( source, offset, SEEK_SET ) == 0 ); \ - TESTCASE( SCANFUNC( source, format "%n", __VA_ARGS__, &n ) == result ); \ - TESTCASE( n == count ); \ + int res = SCANFUNC( source, __VA_ARGS__ ); \ + if ( res != result ) \ + { \ + rc += 1; \ + printf( "FAILED: " __FILE__ ", line %d - expected result %d, got %d\n", __LINE__, result, res ); \ + } \ + if ( n != count ) \ + { \ + rc += 1; \ + printf( "FAILED: " __FILE__ ", line %d - expected count %d, got %d\n", __LINE__, count, n ); \ + } \ } while ( 0 ) +#define SCAN( format ) format "%n", &n +#define SCANPARMS( format, ... ) format "%n", __VA_ARGS__, &n + +#define _PDCLIB_FSCAN +