crt: Add snwprintf test

Signed-off-by: Martin Storsjö <martin@martin.st>
This commit is contained in:
Pali Rohár 2024-11-15 17:59:59 +01:00 committed by Martin Storsjö
parent 53a9374004
commit 1e2529bf12
5 changed files with 26 additions and 0 deletions

View File

@ -4196,6 +4196,9 @@ testcase_progs = \
testcases/t_swprintf \
testcases/t_swprintf0 \
testcases/t_swprintf1 \
testcases/t_snwprintf \
testcases/t_snwprintf0 \
testcases/t_snwprintf1 \
testcases/t_setjmp \
testcases/t_sigv \
testcases/t_speed_powl \

View File

@ -0,0 +1 @@
#include "t_snwprintf_tmpl.h"

View File

@ -0,0 +1,2 @@
#define __USE_MINGW_ANSI_STDIO 0
#include "t_snwprintf_tmpl.h"

View File

@ -0,0 +1,2 @@
#define __USE_MINGW_ANSI_STDIO 1
#include "t_snwprintf_tmpl.h"

View File

@ -0,0 +1,18 @@
#include <stdio.h>
#include <wchar.h>
int main() {
int i;
wchar_t buffer[10] = L"XXXXXXXXXX";
int ret = snwprintf(buffer, 3, L"%ls", L"AAA");
if (ret != 3 || wmemcmp(buffer, L"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)(wint_t)buffer[i]);
}
fprintf(stderr, "\n");
return 1;
}
return 0;
}