X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2Fstdio%2Fsnprintf.c;h=db6778cc780fa6c635b1893763f846a03252923d;hb=f6b6a83981cda2a6f20a945631be2d9a7a257192;hp=3a6e706f8ebeb1e1b8e59009f243347acd82c357;hpb=b08f4b52b1cd1f7a9553c0f357a7c90859fa3e73;p=pdclib diff --git a/functions/stdio/snprintf.c b/functions/stdio/snprintf.c index 3a6e706..db6778c 100644 --- a/functions/stdio/snprintf.c +++ b/functions/stdio/snprintf.c @@ -13,19 +13,30 @@ int snprintf( char * _PDCLIB_restrict s, size_t n, const char * _PDCLIB_restrict format, ...) { + int rc; va_list ap; va_start( ap, format ); - return vsnprintf( s, n, format, ap ); + rc = vsnprintf( s, n, format, ap ); + va_end( ap ); + return rc; } #endif #ifdef TEST +#define _PDCLIB_FILEID "stdio/snprintf.c" +#define _PDCLIB_STRINGIO + #include <_PDCLIB_test.h> +#define testprintf( s, format, ... ) snprintf( s, 100, format, __VA_ARGS__ ) + int main( void ) { - TESTCASE( NO_TESTDRIVER ); + char target[100]; +#include "printf_testcases.h" + TESTCASE( snprintf( NULL, 0, "foo" ) == 3 ); + TESTCASE( snprintf( NULL, 0, "%d", 100 ) == 3 ); return TEST_RESULTS; }