mirror of
https://git.code.sf.net/p/mingw-w64/mingw-w64
synced 2024-11-23 01:44:43 +08:00
crt: Add snprintf test
Signed-off-by: Martin Storsjö <martin@martin.st>
This commit is contained in:
parent
581532b8e4
commit
20bc9fa6f8
@ -4190,6 +4190,9 @@ testcase_progs = \
|
||||
testcases/t_matherr \
|
||||
testcases/t_nullptrexception \
|
||||
testcases/t_readdir \
|
||||
testcases/t_snprintf \
|
||||
testcases/t_snprintf0 \
|
||||
testcases/t_snprintf1 \
|
||||
testcases/t_setjmp \
|
||||
testcases/t_sigv \
|
||||
testcases/t_speed_powl \
|
||||
|
1
mingw-w64-crt/testcases/t_snprintf.c
Normal file
1
mingw-w64-crt/testcases/t_snprintf.c
Normal file
@ -0,0 +1 @@
|
||||
#include "t_snprintf_tmpl.h"
|
2
mingw-w64-crt/testcases/t_snprintf0.c
Normal file
2
mingw-w64-crt/testcases/t_snprintf0.c
Normal file
@ -0,0 +1,2 @@
|
||||
#define __USE_MINGW_ANSI_STDIO 0
|
||||
#include "t_snprintf_tmpl.h"
|
2
mingw-w64-crt/testcases/t_snprintf1.c
Normal file
2
mingw-w64-crt/testcases/t_snprintf1.c
Normal file
@ -0,0 +1,2 @@
|
||||
#define __USE_MINGW_ANSI_STDIO 1
|
||||
#include "t_snprintf_tmpl.h"
|
18
mingw-w64-crt/testcases/t_snprintf_tmpl.h
Normal file
18
mingw-w64-crt/testcases/t_snprintf_tmpl.h
Normal file
@ -0,0 +1,18 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int main() {
|
||||
int i;
|
||||
char buffer[10] = "XXXXXXXXXX";
|
||||
int ret = snprintf(buffer, 3, "%s", "AAA");
|
||||
if (ret != 3 || memcmp(buffer, "AA\0XXXXXXX", 10) != 0) {
|
||||
fprintf(stderr, "ret: expected=3 got=%d\n", ret);
|
||||
fprintf(stderr, "buffer:");
|
||||
for (i = 0; i < 10; i++) {
|
||||
fprintf(stderr, " 0x%02x", (int)buffer[i]);
|
||||
}
|
||||
fprintf(stderr, "\n");
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user