]> pd.if.org Git - pdclib/blobdiff - functions/stdio/snprintf.c
Fixing #47 (*snprint() crash).
[pdclib] / functions / stdio / snprintf.c
index a34558992e5b84a717282dc5da67a976cdaeec8b..db6778cc780fa6c635b1893763f846a03252923d 100644 (file)
@@ -24,19 +24,19 @@ int snprintf( char * _PDCLIB_restrict s, size_t n, const char * _PDCLIB_restrict
 #endif
 
 #ifdef TEST
-#include <_PDCLIB_test.h>
-
-#include <string.h>
-#include <limits.h>
+#define _PDCLIB_FILEID "stdio/snprintf.c"
+#define _PDCLIB_STRINGIO
 
-#define testprintf( s, n, format, ... ) snprintf( s, n, format, __VA_ARGS__ )
+#include <_PDCLIB_test.h>
 
-#define TESTCASE_SPRINTF( x ) TESTCASE( x )
+#define testprintf( s, format, ... ) snprintf( s, 100, format, __VA_ARGS__ )
 
 int main( void )
 {
-    char buffer[100];
-#include "printf_testcases.incl"
+    char target[100];
+#include "printf_testcases.h"
+    TESTCASE( snprintf( NULL, 0, "foo" ) == 3 );
+    TESTCASE( snprintf( NULL, 0, "%d", 100 ) == 3 );
     return TEST_RESULTS;
 }