https://git.reactos.org/?p=reactos.git;a=commitdiff;h=ce2df64a06314c95713b48...
commit ce2df64a06314c95713b48b90f59f023d51b89d5 Author: Amine Khaldi amine.khaldi@reactos.org AuthorDate: Sun Nov 10 14:06:44 2019 +0100 Commit: Amine Khaldi amine.khaldi@reactos.org CommitDate: Sun Nov 10 14:06:44 2019 +0100
[MSVCRT_WINETEST] Sync with Wine Staging 4.18. CORE-16441 --- modules/rostests/winetests/msvcrt/data.c | 3 +- modules/rostests/winetests/msvcrt/environ.c | 36 +++- modules/rostests/winetests/msvcrt/heap.c | 18 +- modules/rostests/winetests/msvcrt/locale.c | 2 +- modules/rostests/winetests/msvcrt/printf.c | 320 +++++++++++++++------------- modules/rostests/winetests/msvcrt/scanf.c | 100 +++++---- modules/rostests/winetests/msvcrt/string.c | 216 +++++++++++++++++-- modules/rostests/winetests/msvcrt/time.c | 134 +++++++----- 8 files changed, 555 insertions(+), 274 deletions(-)
diff --git a/modules/rostests/winetests/msvcrt/data.c b/modules/rostests/winetests/msvcrt/data.c index 9aacac7b503..b0acc60b20b 100644 --- a/modules/rostests/winetests/msvcrt/data.c +++ b/modules/rostests/winetests/msvcrt/data.c @@ -153,9 +153,8 @@ static void test___getmainargs(void) new_argv = *p___p___argv(); ok(new_argc == 4, "*__p___argc() = %d\n", new_argc); ok(new_argv == argv, "*__p___argv() = %p, expected %p\n", new_argv, argv); - }else { - win_skip("__p___argc or __p___argv is not available\n"); } + else skip("__p___argc or __p___argv is not available\n");
mode = 0; __getmainargs(&argc, &argv, &envp, 1, &mode); diff --git a/modules/rostests/winetests/msvcrt/environ.c b/modules/rostests/winetests/msvcrt/environ.c index fdfe81f5eec..b8e0ae6251a 100644 --- a/modules/rostests/winetests/msvcrt/environ.c +++ b/modules/rostests/winetests/msvcrt/environ.c @@ -47,6 +47,8 @@ void __cdecl __wgetmainargs(int *, wchar_t ***, wchar_t ***, int, int *);
static char ***(__cdecl *p__p__environ)(void); static WCHAR ***(__cdecl *p__p__wenviron)(void); +static void (*p_get_environ)(char ***); +static void (*p_get_wenviron)(WCHAR ***);
static char ***p_environ; static WCHAR ***p_wenviron; @@ -59,6 +61,8 @@ static void init(void) p__p__wenviron = (void *)GetProcAddress(hmod, "__p__wenviron"); p_environ = (void *)GetProcAddress(hmod, "_environ"); p_wenviron = (void *)GetProcAddress(hmod, "_wenviron"); + p_get_environ = (void *)GetProcAddress(hmod, "_get_environ"); + p_get_wenviron = (void *)GetProcAddress(hmod, "_get_wenviron"); }
static void test_system(void) @@ -93,7 +97,17 @@ static void test__environ(void) "Expected _environ pointers to be identical\n" ); } else - win_skip( "__p__environ() is not available\n" ); + skip( "__p__environ() is not available\n" ); + + if (p_get_environ) + { + char **retptr; + p_get_environ(&retptr); + ok( retptr == *p_environ, + "Expected _environ pointers to be identical\n" ); + } + else + win_skip( "_get_environ() is not available\n" );
/* Note that msvcrt from Windows versions older than Vista * expects the mode pointer parameter to be valid.*/ @@ -149,7 +163,17 @@ static void test__wenviron(void) "Expected _wenviron pointers to be NULL\n" ); } else - win_skip( "__p__wenviron() is not available\n" ); + skip( "__p__wenviron() is not available\n" ); + + if (p_get_wenviron) + { + WCHAR **retptr; + p_get_wenviron(&retptr); + ok( retptr == NULL, + "Expected _wenviron pointers to be NULL\n" ); + } + else + win_skip( "_get_wenviron() is not available\n" );
/* __getmainargs doesn't initialize _wenviron. */ __getmainargs(&argc, &argv, &envp, 0, &mode); @@ -191,6 +215,14 @@ static void test__wenviron(void) "Expected _wenviron pointers to be identical\n" ); }
+ if (p_get_wenviron) + { + WCHAR **retptr; + p_get_wenviron(&retptr); + ok( retptr == *p_wenviron, + "Expected _wenviron pointers to be identical\n" ); + } + for (i = 0; ; i++) { if ((*p_wenviron)[i]) diff --git a/modules/rostests/winetests/msvcrt/heap.c b/modules/rostests/winetests/msvcrt/heap.c index a0ce2a41628..d934bf0c542 100644 --- a/modules/rostests/winetests/msvcrt/heap.c +++ b/modules/rostests/winetests/msvcrt/heap.c @@ -464,22 +464,26 @@ static void test_sbheap(void)
static void test_calloc(void) { + /* use function pointer to bypass gcc builtin */ + void *(__cdecl *p_calloc)(size_t, size_t); void *ptr;
- ptr = calloc(1, 0); + p_calloc = (void *)GetProcAddress( GetModuleHandleA("msvcrt.dll"), "calloc"); + + ptr = p_calloc(1, 0); ok(ptr != NULL, "got %p\n", ptr); free(ptr);
- ptr = calloc(0, 0); + ptr = p_calloc(0, 0); ok(ptr != NULL, "got %p\n", ptr); free(ptr);
- ptr = calloc(0, 1); + ptr = p_calloc(0, 1); ok(ptr != NULL, "got %p\n", ptr); free(ptr);
errno = 0; - ptr = calloc(~(size_t)0 / 2, ~(size_t)0 / 2); + ptr = p_calloc(~(size_t)0 / 2, ~(size_t)0 / 2); ok(ptr == NULL || broken(ptr != NULL) /* winxp sp0 */, "got %p\n", ptr); ok(errno == ENOMEM || broken(errno == 0) /* winxp, win2k3 */, "got errno %d\n", errno); free(ptr); @@ -495,13 +499,13 @@ START_TEST(heap)
mem = realloc(NULL, 10); ok(mem != NULL, "memory not allocated\n"); - + mem = realloc(mem, 20); ok(mem != NULL, "memory not reallocated\n"); - + mem = realloc(mem, 0); ok(mem == NULL, "memory not freed\n"); - + mem = realloc(NULL, 0); ok(mem != NULL, "memory not (re)allocated for size 0\n");
diff --git a/modules/rostests/winetests/msvcrt/locale.c b/modules/rostests/winetests/msvcrt/locale.c index ff777599aa2..08abac00bed 100644 --- a/modules/rostests/winetests/msvcrt/locale.c +++ b/modules/rostests/winetests/msvcrt/locale.c @@ -759,7 +759,7 @@ static void test___mb_cur_max_func(void)
/* for older Windows */ if (!p__p___mb_cur_max) - win_skip("Skipping __p___mb_cur_max tests\n"); + skip("Skipping __p___mb_cur_max tests\n"); else { mb_cur_max = *p__p___mb_cur_max(); ok(mb_cur_max == 1, "mb_cur_max = %d, expected 1\n", mb_cur_max); diff --git a/modules/rostests/winetests/msvcrt/printf.c b/modules/rostests/winetests/msvcrt/printf.c index 80180ff8b25..d8a82a0bc82 100644 --- a/modules/rostests/winetests/msvcrt/printf.c +++ b/modules/rostests/winetests/msvcrt/printf.c @@ -24,9 +24,10 @@ * the following macro is defined. */ #define _CRT_NON_CONFORMING_SWPRINTFS - + #include <stdio.h> #include <errno.h> +#include <math.h> #include <locale.h>
#include "windef.h" @@ -35,6 +36,8 @@
#include "wine/test.h"
+#ifndef __REACTOS__ + static inline float __port_infinity(void) { static const unsigned __inf_bytes = 0x7f800000; @@ -49,6 +52,8 @@ static inline float __port_nan(void) } #define NAN __port_nan()
+#endif + static inline float __port_ind(void) { static const unsigned __ind_bytes = 0xffc00000; @@ -67,6 +72,7 @@ static int (__cdecl *p__fcvt_s)(char *buffer, size_t length, double number, int ndigits, int *decpt, int *sign); static unsigned int (__cdecl *p__get_output_format)(void); static unsigned int (__cdecl *p__set_output_format)(unsigned int); +static int (WINAPIV *p_sprintf)(char*, ...); static int (__cdecl *p__vsprintf_p)(char*, size_t, const char*, __ms_va_list); static int (__cdecl *p_vswprintf)(wchar_t *str, const wchar_t *format, __ms_va_list valist); static int (__cdecl *p__vswprintf)(wchar_t *str, const wchar_t *format, __ms_va_list valist); @@ -83,6 +89,7 @@ static void init( void ) { HMODULE hmod = GetModuleHandleA("msvcrt.dll");
+ p_sprintf = (void *)GetProcAddress(hmod, "sprintf"); p__vscprintf = (void *)GetProcAddress(hmod, "_vscprintf"); p__vscwprintf = (void *)GetProcAddress(hmod, "_vscwprintf"); p__vsnwprintf_s = (void *)GetProcAddress(hmod, "_vsnwprintf_s"); @@ -106,189 +113,190 @@ static void test_sprintf( void ) double pnumber=789456123; int x, r; WCHAR wide[] = { 'w','i','d','e',0}; + WCHAR buf_w[2];
format = "%+#23.15e"; - r = sprintf(buffer,format,pnumber); + r = p_sprintf(buffer,format,pnumber); ok(!strcmp(buffer,"+7.894561230000000e+008"),"+#23.15e failed: '%s'\n", buffer); ok( r==23, "return count wrong\n");
format = "%-#23.15e"; - r = sprintf(buffer,format,pnumber); + r = p_sprintf(buffer,format,pnumber); ok(!strcmp(buffer,"7.894561230000000e+008 "),"-#23.15e failed: '%s'\n", buffer); ok( r==23, "return count wrong\n");
format = "%#23.15e"; - r = sprintf(buffer,format,pnumber); + r = p_sprintf(buffer,format,pnumber); ok(!strcmp(buffer," 7.894561230000000e+008"),"#23.15e failed: '%s'\n", buffer); ok( r==23, "return count wrong\n");
format = "%#1.1g"; - r = sprintf(buffer,format,pnumber); + r = p_sprintf(buffer,format,pnumber); ok(!strcmp(buffer,"8.e+008"),"#1.1g failed: '%s'\n", buffer); ok( r==7, "return count wrong\n");
format = "%I64d"; - r = sprintf(buffer,format,((ULONGLONG)0xffffffff)*0xffffffff); + r = p_sprintf(buffer,format,((ULONGLONG)0xffffffff)*0xffffffff); ok(!strcmp(buffer,"-8589934591"),"Problem with long long\n"); ok( r==11, "return count wrong\n");
format = "%+8I64d"; - r = sprintf(buffer,format,(LONGLONG)100); + r = p_sprintf(buffer,format,(LONGLONG)100); ok(!strcmp(buffer," +100") && r==8,"+8I64d failed: '%s'\n", buffer);
format = "%+.8I64d"; - r = sprintf(buffer,format,(LONGLONG)100); + r = p_sprintf(buffer,format,(LONGLONG)100); ok(!strcmp(buffer,"+00000100") && r==9,"+.8I64d failed: '%s'\n", buffer);
format = "%+10.8I64d"; - r = sprintf(buffer,format,(LONGLONG)100); + r = p_sprintf(buffer,format,(LONGLONG)100); ok(!strcmp(buffer," +00000100") && r==10,"+10.8I64d failed: '%s'\n", buffer); format = "%_1I64d"; - r = sprintf(buffer,format,(LONGLONG)100); + r = p_sprintf(buffer,format,(LONGLONG)100); ok(!strcmp(buffer,"_1I64d") && r==6,"_1I64d failed\n");
format = "%-1.5I64d"; - r = sprintf(buffer,format,(LONGLONG)-100); + r = p_sprintf(buffer,format,(LONGLONG)-100); ok(!strcmp(buffer,"-00100") && r==6,"-1.5I64d failed: '%s'\n", buffer);
format = "%5I64d"; - r = sprintf(buffer,format,(LONGLONG)100); + r = p_sprintf(buffer,format,(LONGLONG)100); ok(!strcmp(buffer," 100") && r==5,"5I64d failed: '%s'\n", buffer);
format = "%5I64d"; - r = sprintf(buffer,format,(LONGLONG)-100); + r = p_sprintf(buffer,format,(LONGLONG)-100); ok(!strcmp(buffer," -100") && r==5,"5I64d failed: '%s'\n", buffer);
format = "%-5I64d"; - r = sprintf(buffer,format,(LONGLONG)100); + r = p_sprintf(buffer,format,(LONGLONG)100); ok(!strcmp(buffer,"100 ") && r==5,"-5I64d failed: '%s'\n", buffer);
format = "%-5I64d"; - r = sprintf(buffer,format,(LONGLONG)-100); + r = p_sprintf(buffer,format,(LONGLONG)-100); ok(!strcmp(buffer,"-100 ") && r==5,"-5I64d failed: '%s'\n", buffer);
format = "%-.5I64d"; - r = sprintf(buffer,format,(LONGLONG)100); + r = p_sprintf(buffer,format,(LONGLONG)100); ok(!strcmp(buffer,"00100") && r==5,"-.5I64d failed: '%s'\n", buffer);
format = "%-.5I64d"; - r = sprintf(buffer,format,(LONGLONG)-100); + r = p_sprintf(buffer,format,(LONGLONG)-100); ok(!strcmp(buffer,"-00100") && r==6,"-.5I64d failed: '%s'\n", buffer);
format = "%-8.5I64d"; - r = sprintf(buffer,format,(LONGLONG)100); + r = p_sprintf(buffer,format,(LONGLONG)100); ok(!strcmp(buffer,"00100 ") && r==8,"-8.5I64d failed: '%s'\n", buffer);
format = "%-8.5I64d"; - r = sprintf(buffer,format,(LONGLONG)-100); + r = p_sprintf(buffer,format,(LONGLONG)-100); ok(!strcmp(buffer,"-00100 ") && r==8,"-8.5I64d failed: '%s'\n", buffer);
format = "%05I64d"; - r = sprintf(buffer,format,(LONGLONG)100); + r = p_sprintf(buffer,format,(LONGLONG)100); ok(!strcmp(buffer,"00100") && r==5,"05I64d failed: '%s'\n", buffer);
format = "%05I64d"; - r = sprintf(buffer,format,(LONGLONG)-100); + r = p_sprintf(buffer,format,(LONGLONG)-100); ok(!strcmp(buffer,"-0100") && r==5,"05I64d failed: '%s'\n", buffer);
format = "% I64d"; - r = sprintf(buffer,format,(LONGLONG)100); + r = p_sprintf(buffer,format,(LONGLONG)100); ok(!strcmp(buffer," 100") && r==4,"' I64d' failed: '%s'\n", buffer);
format = "% I64d"; - r = sprintf(buffer,format,(LONGLONG)-100); + r = p_sprintf(buffer,format,(LONGLONG)-100); ok(!strcmp(buffer,"-100") && r==4,"' I64d' failed: '%s'\n", buffer);
format = "% 5I64d"; - r = sprintf(buffer,format,(LONGLONG)100); + r = p_sprintf(buffer,format,(LONGLONG)100); ok(!strcmp(buffer," 100") && r==5,"' 5I64d' failed: '%s'\n", buffer);
format = "% 5I64d"; - r = sprintf(buffer,format,(LONGLONG)-100); + r = p_sprintf(buffer,format,(LONGLONG)-100); ok(!strcmp(buffer," -100") && r==5,"' 5I64d' failed: '%s'\n", buffer);
format = "% .5I64d"; - r = sprintf(buffer,format,(LONGLONG)100); + r = p_sprintf(buffer,format,(LONGLONG)100); ok(!strcmp(buffer," 00100") && r==6,"' .5I64d' failed: '%s'\n", buffer);
format = "% .5I64d"; - r = sprintf(buffer,format,(LONGLONG)-100); + r = p_sprintf(buffer,format,(LONGLONG)-100); ok(!strcmp(buffer,"-00100") && r==6,"' .5I64d' failed: '%s'\n", buffer);
format = "% 8.5I64d"; - r = sprintf(buffer,format,(LONGLONG)100); + r = p_sprintf(buffer,format,(LONGLONG)100); ok(!strcmp(buffer," 00100") && r==8,"' 8.5I64d' failed: '%s'\n", buffer);
format = "% 8.5I64d"; - r = sprintf(buffer,format,(LONGLONG)-100); + r = p_sprintf(buffer,format,(LONGLONG)-100); ok(!strcmp(buffer," -00100") && r==8,"' 8.5I64d' failed: '%s'\n", buffer);
format = "%.0I64d"; - r = sprintf(buffer,format,(LONGLONG)0); + r = p_sprintf(buffer,format,(LONGLONG)0); ok(r==0,".0I64d failed: '%s'\n", buffer);
format = "%#+21.18I64x"; - r = sprintf(buffer,format,(LONGLONG)-100); + r = p_sprintf(buffer,format,(LONGLONG)-100); ok(!strcmp(buffer," 0x00ffffffffffffff9c") && r==21,"#+21.18I64x failed: '%s'\n", buffer);
format = "%#.25I64o"; - r = sprintf(buffer,format,(LONGLONG)-100); + r = p_sprintf(buffer,format,(LONGLONG)-100); ok(!strcmp(buffer,"0001777777777777777777634") && r==25,"#.25I64o failed: '%s'\n", buffer);
format = "%#+24.20I64o"; - r = sprintf(buffer,format,(LONGLONG)-100); + r = p_sprintf(buffer,format,(LONGLONG)-100); ok(!strcmp(buffer," 01777777777777777777634") && r==24,"#+24.20I64o failed: '%s'\n", buffer);
format = "%#+18.21I64X"; - r = sprintf(buffer,format,(LONGLONG)-100); + r = p_sprintf(buffer,format,(LONGLONG)-100); ok(!strcmp(buffer,"0X00000FFFFFFFFFFFFFF9C") && r==23,"#+18.21I64X failed: '%s '\n", buffer);
format = "%#+20.24I64o"; - r = sprintf(buffer,format,(LONGLONG)-100); + r = p_sprintf(buffer,format,(LONGLONG)-100); ok(!strcmp(buffer,"001777777777777777777634") && r==24,"#+20.24I64o failed: '%s'\n", buffer);
format = "%#+25.22I64u"; - r = sprintf(buffer,format,(LONGLONG)-1); + r = p_sprintf(buffer,format,(LONGLONG)-1); ok(!strcmp(buffer," 0018446744073709551615") && r==25,"#+25.22I64u conversion failed: '%s'\n", buffer);
format = "%#+25.22I64u"; - r = sprintf(buffer,format,(LONGLONG)-1); + r = p_sprintf(buffer,format,(LONGLONG)-1); ok(!strcmp(buffer," 0018446744073709551615") && r==25,"#+25.22I64u failed: '%s'\n", buffer);
format = "%#+30.25I64u"; - r = sprintf(buffer,format,(LONGLONG)-1); + r = p_sprintf(buffer,format,(LONGLONG)-1); ok(!strcmp(buffer," 0000018446744073709551615") && r==30,"#+30.25I64u failed: '%s'\n", buffer);
format = "%+#25.22I64d"; - r = sprintf(buffer,format,(LONGLONG)-1); + r = p_sprintf(buffer,format,(LONGLONG)-1); ok(!strcmp(buffer," -0000000000000000000001") && r==25,"+#25.22I64d failed: '%s'\n", buffer);
format = "%#-8.5I64o"; - r = sprintf(buffer,format,(LONGLONG)100); + r = p_sprintf(buffer,format,(LONGLONG)100); ok(!strcmp(buffer,"00144 ") && r==8,"-8.5I64o failed: '%s'\n", buffer);
format = "%#-+ 08.5I64d"; - r = sprintf(buffer,format,(LONGLONG)100); + r = p_sprintf(buffer,format,(LONGLONG)100); ok(!strcmp(buffer,"+00100 ") && r==8,"'#-+ 08.5I64d failed: '%s'\n", buffer);
format = "%#-+ 08.5I64d"; - r = sprintf(buffer,format,(LONGLONG)100); + r = p_sprintf(buffer,format,(LONGLONG)100); ok(!strcmp(buffer,"+00100 ") && r==8,"#-+ 08.5I64d failed: '%s'\n", buffer);
format = "%.80I64d"; - r = sprintf(buffer,format,(LONGLONG)1); + r = p_sprintf(buffer,format,(LONGLONG)1); ok(r==80,"%s format failed\n", format);
format = "% .80I64d"; - r = sprintf(buffer,format,(LONGLONG)1); + r = p_sprintf(buffer,format,(LONGLONG)1); ok(r==81,"%s format failed\n", format);
format = "% .80d"; - r = sprintf(buffer,format,1); + r = p_sprintf(buffer,format,1); ok(r==81,"%s format failed\n", format);
format = "%lld"; - r = sprintf(buffer,format,((ULONGLONG)0xffffffff)*0xffffffff); + r = p_sprintf(buffer,format,((ULONGLONG)0xffffffff)*0xffffffff); ok( r == 1 || r == 11, "return count wrong %d\n", r); if (r == 11) /* %ll works on Vista */ ok(!strcmp(buffer, "-8589934591"), "Problem with "ll" interpretation '%s'\n", buffer); @@ -296,17 +304,17 @@ static void test_sprintf( void ) ok(!strcmp(buffer, "1"), "Problem with "ll" interpretation '%s'\n", buffer);
format = "%I"; - r = sprintf(buffer,format,1); + r = p_sprintf(buffer,format,1); ok(!strcmp(buffer, "I"), "Problem with "I" interpretation\n"); ok( r==1, "return count wrong\n");
format = "%I0d"; - r = sprintf(buffer,format,1); + r = p_sprintf(buffer,format,1); ok(!strcmp(buffer,"I0d"),"I0d failed\n"); ok( r==3, "return count wrong\n");
format = "%I32d"; - r = sprintf(buffer,format,1); + r = p_sprintf(buffer,format,1); if (r == 1) { ok(!strcmp(buffer,"1"),"I32d failed, got '%s'\n",buffer); @@ -318,248 +326,248 @@ static void test_sprintf( void ) }
format = "%I64D"; - r = sprintf(buffer,format,(LONGLONG)-1); + r = p_sprintf(buffer,format,(LONGLONG)-1); ok(!strcmp(buffer,"D"),"I64D failed: %s\n",buffer); ok( r==1, "return count wrong\n");
format = "%zx"; - r = sprintf(buffer,format,1); + r = p_sprintf(buffer,format,1); ok(!strcmp(buffer, "zx"), "Problem with "z" interpretation\n"); ok( r==2, "return count wrong\n");
format = "% d"; - r = sprintf(buffer,format,1); + r = p_sprintf(buffer,format,1); ok(!strcmp(buffer, " 1"),"Problem with sign place-holder: '%s'\n",buffer); ok( r==2, "return count wrong\n");
format = "%+ d"; - r = sprintf(buffer,format,1); + r = p_sprintf(buffer,format,1); ok(!strcmp(buffer, "+1"),"Problem with sign flags: '%s'\n",buffer); ok( r==2, "return count wrong\n");
format = "%S"; - r = sprintf(buffer,format,wide); + r = p_sprintf(buffer,format,wide); ok(!strcmp(buffer,"wide"),"Problem with wide string format\n"); ok( r==4, "return count wrong\n");
format = "%04c"; - r = sprintf(buffer,format,'1'); + r = p_sprintf(buffer,format,'1'); ok(!strcmp(buffer,"0001"),"Character not zero-prefixed "%s"\n",buffer); ok( r==4, "return count wrong\n");
format = "%-04c"; - r = sprintf(buffer,format,'1'); + r = p_sprintf(buffer,format,'1'); ok(!strcmp(buffer,"1 "),"Character zero-padded and/or not left-adjusted "%s"\n",buffer); ok( r==4, "return count wrong\n");
format = "%#012x"; - r = sprintf(buffer,format,1); + r = p_sprintf(buffer,format,1); ok(!strcmp(buffer,"0x0000000001"),"Hexadecimal zero-padded "%s"\n",buffer); ok( r==12, "return count wrong\n");
- r = sprintf(buffer,format,0); + r = p_sprintf(buffer,format,0); ok(!strcmp(buffer,"000000000000"),"Hexadecimal zero-padded "%s"\n",buffer); ok( r==12, "return count wrong\n");
format = "%#04.8x"; - r = sprintf(buffer,format,1); + r = p_sprintf(buffer,format,1); ok(!strcmp(buffer,"0x00000001"), "Hexadecimal zero-padded precision "%s"\n",buffer); ok( r==10, "return count wrong\n");
- r = sprintf(buffer,format,0); + r = p_sprintf(buffer,format,0); ok(!strcmp(buffer,"00000000"), "Hexadecimal zero-padded precision "%s"\n",buffer); ok( r==8, "return count wrong\n");
format = "%#-08.2x"; - r = sprintf(buffer,format,1); + r = p_sprintf(buffer,format,1); ok(!strcmp(buffer,"0x01 "), "Hexadecimal zero-padded not left-adjusted "%s"\n",buffer); ok( r==8, "return count wrong\n");
- r = sprintf(buffer,format,0); + r = p_sprintf(buffer,format,0); ok(!strcmp(buffer,"00 "), "Hexadecimal zero-padded not left-adjusted "%s"\n",buffer); ok( r==8, "return count wrong\n");
format = "%#.0x"; - r = sprintf(buffer,format,1); + r = p_sprintf(buffer,format,1); ok(!strcmp(buffer,"0x1"), "Hexadecimal zero-padded zero-precision "%s"\n",buffer); ok( r==3, "return count wrong\n");
- r = sprintf(buffer,format,0); + r = p_sprintf(buffer,format,0); ok(!strcmp(buffer,""), "Hexadecimal zero-padded zero-precision "%s"\n",buffer); ok( r==0, "return count wrong\n");
format = "%#08o"; - r = sprintf(buffer,format,1); + r = p_sprintf(buffer,format,1); ok(!strcmp(buffer,"00000001"), "Octal zero-padded "%s"\n",buffer); ok( r==8, "return count wrong\n");
format = "%#o"; - r = sprintf(buffer,format,1); + r = p_sprintf(buffer,format,1); ok(!strcmp(buffer,"01"), "Octal zero-padded "%s"\n",buffer); ok( r==2, "return count wrong\n");
- r = sprintf(buffer,format,0); + r = p_sprintf(buffer,format,0); ok(!strcmp(buffer,"0"), "Octal zero-padded "%s"\n",buffer); ok( r==1, "return count wrong\n");
if (sizeof(void *) == 8) { format = "%p"; - r = sprintf(buffer,format,(void *)57); + r = p_sprintf(buffer,format,(void *)57); ok(!strcmp(buffer,"0000000000000039"),"Pointer formatted incorrectly "%s"\n",buffer); ok( r==16, "return count wrong\n");
format = "%#020p"; - r = sprintf(buffer,format,(void *)57); + r = p_sprintf(buffer,format,(void *)57); ok(!strcmp(buffer," 0X0000000000000039"),"Pointer formatted incorrectly\n"); ok( r==20, "return count wrong\n");
format = "%Fp"; - r = sprintf(buffer,format,(void *)57); + r = p_sprintf(buffer,format,(void *)57); ok(!strcmp(buffer,"0000000000000039"),"Pointer formatted incorrectly "%s"\n",buffer); ok( r==16, "return count wrong\n");
format = "%Np"; - r = sprintf(buffer,format,(void *)57); + r = p_sprintf(buffer,format,(void *)57); ok(!strcmp(buffer,"0000000000000039"),"Pointer formatted incorrectly "%s"\n",buffer); ok( r==16, "return count wrong\n");
format = "%#-020p"; - r = sprintf(buffer,format,(void *)57); + r = p_sprintf(buffer,format,(void *)57); ok(!strcmp(buffer,"0X0000000000000039 "),"Pointer formatted incorrectly\n"); ok( r==20, "return count wrong\n");
format = "%Ix %d"; - r = sprintf(buffer,format,(size_t)0x12345678123456,1); + r = p_sprintf(buffer,format,(size_t)0x12345678123456,1); ok(!strcmp(buffer,"12345678123456 1"),"buffer = %s\n",buffer); ok( r==16, "return count wrong\n"); } else { format = "%p"; - r = sprintf(buffer,format,(void *)57); + r = p_sprintf(buffer,format,(void *)57); ok(!strcmp(buffer,"00000039"),"Pointer formatted incorrectly "%s"\n",buffer); ok( r==8, "return count wrong\n");
format = "%#012p"; - r = sprintf(buffer,format,(void *)57); + r = p_sprintf(buffer,format,(void *)57); ok(!strcmp(buffer," 0X00000039"),"Pointer formatted incorrectly\n"); ok( r==12, "return count wrong\n");
format = "%Fp"; - r = sprintf(buffer,format,(void *)57); + r = p_sprintf(buffer,format,(void *)57); ok(!strcmp(buffer,"00000039"),"Pointer formatted incorrectly "%s"\n",buffer); ok( r==8, "return count wrong\n");
format = "%Np"; - r = sprintf(buffer,format,(void *)57); + r = p_sprintf(buffer,format,(void *)57); ok(!strcmp(buffer,"00000039"),"Pointer formatted incorrectly "%s"\n",buffer); ok( r==8, "return count wrong\n");
format = "%#-012p"; - r = sprintf(buffer,format,(void *)57); + r = p_sprintf(buffer,format,(void *)57); ok(!strcmp(buffer,"0X00000039 "),"Pointer formatted incorrectly\n"); ok( r==12, "return count wrong\n");
format = "%Ix %d"; - r = sprintf(buffer,format,0x123456,1); + r = p_sprintf(buffer,format,0x123456,1); ok(!strcmp(buffer,"123456 1"),"buffer = %s\n",buffer); ok( r==8, "return count wrong\n"); }
format = "%04s"; - r = sprintf(buffer,format,"foo"); + r = p_sprintf(buffer,format,"foo"); ok(!strcmp(buffer,"0foo"),"String not zero-prefixed "%s"\n",buffer); ok( r==4, "return count wrong\n");
format = "%.1s"; - r = sprintf(buffer,format,"foo"); + r = p_sprintf(buffer,format,"foo"); ok(!strcmp(buffer,"f"),"Precision ignored "%s"\n",buffer); ok( r==1, "return count wrong\n");
format = "%.*s"; - r = sprintf(buffer,format,1,"foo"); + r = p_sprintf(buffer,format,1,"foo"); ok(!strcmp(buffer,"f"),"Precision ignored "%s"\n",buffer); ok( r==1, "return count wrong\n");
format = "%*s"; - r = sprintf(buffer,format,-5,"foo"); + r = p_sprintf(buffer,format,-5,"foo"); ok(!strcmp(buffer,"foo "),"Negative field width ignored "%s"\n",buffer); ok( r==5, "return count wrong\n");
format = "hello"; - r = sprintf(buffer, format); + r = p_sprintf(buffer, format); ok(!strcmp(buffer,"hello"), "failed\n"); ok( r==5, "return count wrong\n");
format = "%ws"; - r = sprintf(buffer, format, wide); + r = p_sprintf(buffer, format, wide); ok(!strcmp(buffer,"wide"), "failed\n"); ok( r==4, "return count wrong\n");
format = "%-10ws"; - r = sprintf(buffer, format, wide ); + r = p_sprintf(buffer, format, wide ); ok(!strcmp(buffer,"wide "), "failed\n"); ok( r==10, "return count wrong\n");
format = "%10ws"; - r = sprintf(buffer, format, wide ); + r = p_sprintf(buffer, format, wide ); ok(!strcmp(buffer," wide"), "failed\n"); ok( r==10, "return count wrong\n");
format = "%#+ -03whlls"; - r = sprintf(buffer, format, wide ); + r = p_sprintf(buffer, format, wide ); ok(!strcmp(buffer,"wide"), "failed\n"); ok( r==4, "return count wrong\n");
format = "%w0s"; - r = sprintf(buffer, format, wide ); + r = p_sprintf(buffer, format, wide ); ok(!strcmp(buffer,"0s"), "failed\n"); ok( r==2, "return count wrong\n");
format = "%w-s"; - r = sprintf(buffer, format, wide ); + r = p_sprintf(buffer, format, wide ); ok(!strcmp(buffer,"-s"), "failed\n"); ok( r==2, "return count wrong\n");
format = "%ls"; - r = sprintf(buffer, format, wide ); + r = p_sprintf(buffer, format, wide ); ok(!strcmp(buffer,"wide"), "failed\n"); ok( r==4, "return count wrong\n");
format = "%Ls"; - r = sprintf(buffer, format, "not wide" ); + r = p_sprintf(buffer, format, "not wide" ); ok(!strcmp(buffer,"not wide"), "failed\n"); ok( r==8, "return count wrong\n");
format = "%b"; - r = sprintf(buffer, format); + r = p_sprintf(buffer, format); ok(!strcmp(buffer,"b"), "failed\n"); ok( r==1, "return count wrong\n");
format = "%3c"; - r = sprintf(buffer, format,'a'); + r = p_sprintf(buffer, format,'a'); ok(!strcmp(buffer," a"), "failed\n"); ok( r==3, "return count wrong\n");
format = "%3d"; - r = sprintf(buffer, format,1234); + r = p_sprintf(buffer, format,1234); ok(!strcmp(buffer,"1234"), "failed\n"); ok( r==4, "return count wrong\n");
format = "%3h"; - r = sprintf(buffer, format); + r = p_sprintf(buffer, format); ok(!strcmp(buffer,""), "failed\n"); ok( r==0, "return count wrong\n");
format = "%j%k%m%q%r%t%v%y%z"; - r = sprintf(buffer, format); + r = p_sprintf(buffer, format); ok(!strcmp(buffer,"jkmqrtvyz"), "failed\n"); ok( r==9, "return count wrong\n");
format = "asdf%n"; x = 0; - r = sprintf(buffer, format, &x ); + r = p_sprintf(buffer, format, &x ); if (r == -1) { /* %n format is disabled by default on vista */ @@ -574,77 +582,77 @@ static void test_sprintf( void ) }
format = "%-1d"; - r = sprintf(buffer, format,2); + r = p_sprintf(buffer, format,2); ok(!strcmp(buffer,"2"), "failed\n"); ok( r==1, "return count wrong\n");
format = "%2.4f"; - r = sprintf(buffer, format,8.6); + r = p_sprintf(buffer, format,8.6); ok(!strcmp(buffer,"8.6000"), "failed\n"); ok( r==6, "return count wrong\n");
format = "%0f"; - r = sprintf(buffer, format,0.6); + r = p_sprintf(buffer, format,0.6); ok(!strcmp(buffer,"0.600000"), "failed\n"); ok( r==8, "return count wrong\n");
format = "%.0f"; - r = sprintf(buffer, format,0.6); + r = p_sprintf(buffer, format,0.6); ok(!strcmp(buffer,"1"), "failed\n"); ok( r==1, "return count wrong\n");
format = "%2.4e"; - r = sprintf(buffer, format,8.6); + r = p_sprintf(buffer, format,8.6); ok(!strcmp(buffer,"8.6000e+000"), "failed\n"); ok( r==11, "return count wrong\n");
format = "% 2.4e"; - r = sprintf(buffer, format,8.6); + r = p_sprintf(buffer, format,8.6); ok(!strcmp(buffer," 8.6000e+000"), "failed: %s\n", buffer); ok( r==12, "return count wrong\n");
format = "% 014.4e"; - r = sprintf(buffer, format,8.6); + r = p_sprintf(buffer, format,8.6); ok(!strcmp(buffer," 008.6000e+000"), "failed: %s\n", buffer); ok( r==14, "return count wrong\n");
format = "% 2.4e"; - r = sprintf(buffer, format,-8.6); + r = p_sprintf(buffer, format,-8.6); ok(!strcmp(buffer,"-8.6000e+000"), "failed: %s\n", buffer); ok( r==12, "return count wrong\n");
format = "%+2.4e"; - r = sprintf(buffer, format,8.6); + r = p_sprintf(buffer, format,8.6); ok(!strcmp(buffer,"+8.6000e+000"), "failed: %s\n", buffer); ok( r==12, "return count wrong\n");
format = "%2.4g"; - r = sprintf(buffer, format,8.6); + r = p_sprintf(buffer, format,8.6); ok(!strcmp(buffer,"8.6"), "failed\n"); ok( r==3, "return count wrong\n");
format = "%-i"; - r = sprintf(buffer, format,-1); + r = p_sprintf(buffer, format,-1); ok(!strcmp(buffer,"-1"), "failed\n"); ok( r==2, "return count wrong\n");
format = "%-i"; - r = sprintf(buffer, format,1); + r = p_sprintf(buffer, format,1); ok(!strcmp(buffer,"1"), "failed\n"); ok( r==1, "return count wrong\n");
format = "%+i"; - r = sprintf(buffer, format,1); + r = p_sprintf(buffer, format,1); ok(!strcmp(buffer,"+1"), "failed\n"); ok( r==2, "return count wrong\n");
format = "%o"; - r = sprintf(buffer, format,10); + r = p_sprintf(buffer, format,10); ok(!strcmp(buffer,"12"), "failed\n"); ok( r==2, "return count wrong\n");
format = "%p"; - r = sprintf(buffer, format,0); + r = p_sprintf(buffer, format,0); if (sizeof(void *) == 8) { ok(!strcmp(buffer,"0000000000000000"), "failed\n"); @@ -657,150 +665,166 @@ static void test_sprintf( void ) }
format = "%s"; - r = sprintf(buffer, format,0); + r = p_sprintf(buffer, format,0); ok(!strcmp(buffer,"(null)"), "failed\n"); ok( r==6, "return count wrong\n");
format = "%s"; - r = sprintf(buffer, format,"%%%%"); + r = p_sprintf(buffer, format,"%%%%"); ok(!strcmp(buffer,"%%%%"), "failed\n"); ok( r==4, "return count wrong\n");
format = "%u"; - r = sprintf(buffer, format,-1); + r = p_sprintf(buffer, format,-1); ok(!strcmp(buffer,"4294967295"), "failed\n"); ok( r==10, "return count wrong\n");
format = "%w"; - r = sprintf(buffer, format,-1); + r = p_sprintf(buffer, format,-1); ok(!strcmp(buffer,""), "failed\n"); ok( r==0, "return count wrong\n");
format = "%h"; - r = sprintf(buffer, format,-1); + r = p_sprintf(buffer, format,-1); ok(!strcmp(buffer,""), "failed\n"); ok( r==0, "return count wrong\n");
format = "%z"; - r = sprintf(buffer, format,-1); + r = p_sprintf(buffer, format,-1); ok(!strcmp(buffer,"z"), "failed\n"); ok( r==1, "return count wrong\n");
format = "%j"; - r = sprintf(buffer, format,-1); + r = p_sprintf(buffer, format,-1); ok(!strcmp(buffer,"j"), "failed\n"); ok( r==1, "return count wrong\n");
format = "%F"; - r = sprintf(buffer, format,-1); + r = p_sprintf(buffer, format,-1); ok(!strcmp(buffer,""), "failed\n"); ok( r==0, "return count wrong\n");
format = "%N"; - r = sprintf(buffer, format,-1); + r = p_sprintf(buffer, format,-1); ok(!strcmp(buffer,""), "failed\n"); ok( r==0, "return count wrong\n");
format = "%H"; - r = sprintf(buffer, format,-1); + r = p_sprintf(buffer, format,-1); ok(!strcmp(buffer,"H"), "failed\n"); ok( r==1, "return count wrong\n");
format = "x%cx"; - r = sprintf(buffer, format, 0x100+'X'); + r = p_sprintf(buffer, format, 0x100+'X'); ok(!strcmp(buffer,"xXx"), "failed\n"); ok( r==3, "return count wrong\n");
format = "%%0"; - r = sprintf(buffer, format); + r = p_sprintf(buffer, format); ok(!strcmp(buffer,"%0"), "failed: "%s"\n", buffer); ok( r==2, "return count wrong\n");
format = "%hx"; - r = sprintf(buffer, format, 0x12345); + r = p_sprintf(buffer, format, 0x12345); ok(!strcmp(buffer,"2345"), "failed "%s"\n", buffer);
format = "%hhx"; - r = sprintf(buffer, format, 0x123); + r = p_sprintf(buffer, format, 0x123); ok(!strcmp(buffer,"123"), "failed: "%s"\n", buffer); - r = sprintf(buffer, format, 0x12345); + r = p_sprintf(buffer, format, 0x12345); ok(!strcmp(buffer,"2345"), "failed "%s"\n", buffer);
format = "%lf"; - r = sprintf(buffer, format, IND); + r = p_sprintf(buffer, format, IND); ok(r==9, "r = %d\n", r); ok(!strcmp(buffer, "-1.#IND00"), "failed: "%s"\n", buffer); - r = sprintf(buffer, format, NAN); + r = p_sprintf(buffer, format, NAN); ok(r==8, "r = %d\n", r); ok(!strcmp(buffer, "1.#QNAN0"), "failed: "%s"\n", buffer); - r = sprintf(buffer, format, INFINITY); + r = p_sprintf(buffer, format, INFINITY); ok(r==8, "r = %d\n", r); ok(!strcmp(buffer, "1.#INF00"), "failed: "%s"\n", buffer);
format = "%le"; - r = sprintf(buffer, format, IND); + r = p_sprintf(buffer, format, IND); ok(r==14, "r = %d\n", r); ok(!strcmp(buffer, "-1.#IND00e+000"), "failed: "%s"\n", buffer); - r = sprintf(buffer, format, NAN); + r = p_sprintf(buffer, format, NAN); ok(r==13, "r = %d\n", r); ok(!strcmp(buffer, "1.#QNAN0e+000"), "failed: "%s"\n", buffer); - r = sprintf(buffer, format, INFINITY); + r = p_sprintf(buffer, format, INFINITY); ok(r==13, "r = %d\n", r); ok(!strcmp(buffer, "1.#INF00e+000"), "failed: "%s"\n", buffer);
format = "%lg"; - r = sprintf(buffer, format, IND); + r = p_sprintf(buffer, format, IND); ok(r==7, "r = %d\n", r); ok(!strcmp(buffer, "-1.#IND"), "failed: "%s"\n", buffer); - r = sprintf(buffer, format, NAN); + r = p_sprintf(buffer, format, NAN); ok(r==7, "r = %d\n", r); ok(!strcmp(buffer, "1.#QNAN"), "failed: "%s"\n", buffer); - r = sprintf(buffer, format, INFINITY); + r = p_sprintf(buffer, format, INFINITY); ok(r==6, "r = %d\n", r); ok(!strcmp(buffer, "1.#INF"), "failed: "%s"\n", buffer);
format = "%010.2lf"; - r = sprintf(buffer, format, IND); + r = p_sprintf(buffer, format, IND); ok(r==10, "r = %d\n", r); ok(!strcmp(buffer, "-000001.#J"), "failed: "%s"\n", buffer); - r = sprintf(buffer, format, NAN); + r = p_sprintf(buffer, format, NAN); ok(r==10, "r = %d\n", r); ok(!strcmp(buffer, "0000001.#R"), "failed: "%s"\n", buffer); - r = sprintf(buffer, format, INFINITY); + r = p_sprintf(buffer, format, INFINITY); ok(r==10, "r = %d\n", r); ok(!strcmp(buffer, "0000001.#J"), "failed: "%s"\n", buffer);
format = "%c"; - r = sprintf(buffer, format, 'a'); + r = p_sprintf(buffer, format, 'a'); ok(r==1, "r = %d\n", r); ok(!strcmp(buffer, "a"), "failed: "%s"\n", buffer); - r = sprintf(buffer, format, 0xa082); + r = p_sprintf(buffer, format, 0xa082); ok(r==1, "r = %d\n", r); ok(!strcmp(buffer, "\x82"), "failed: "%s"\n", buffer);
format = "%C"; - r = sprintf(buffer, format, 'a'); + r = p_sprintf(buffer, format, 'a'); ok(r==1, "r = %d\n", r); ok(!strcmp(buffer, "a"), "failed: "%s"\n", buffer); - r = sprintf(buffer, format, 0x3042); + r = p_sprintf(buffer, format, 0x3042); ok(r==0, "r = %d\n", r); ok(!strcmp(buffer, ""), "failed: "%s"\n", buffer);
+ format = "a%Cb"; + r = p_sprintf(buffer, format, 0x3042); + ok(r==2, "r = %d\n", r); + ok(!strcmp(buffer, "ab"), "failed: "%s"\n", buffer); + + format = "%S"; + buf_w[0] = 0x3042; + buf_w[1] = 0; + r = p_sprintf(buffer, format, buf_w); + ok(r==-1 || broken(!r), "r = %d\n", r); + if(!setlocale(LC_ALL, "Japanese_Japan.932")) { win_skip("Japanese_Japan.932 locale not available\n"); return; }
format = "%c"; - r = sprintf(buffer, format, 0xa082); + r = p_sprintf(buffer, format, 0xa082); ok(r==1, "r = %d\n", r); ok(!strcmp(buffer, "\x82"), "failed: "%s"\n", buffer);
format = "%C"; - r = sprintf(buffer, format, 0x3042); + r = p_sprintf(buffer, format, 0x3042); ok(r==2, "r = %d\n", r); ok(!strcmp(buffer, "\x82\xa0"), "failed: "%s"\n", buffer);
+ strcpy(buffer, " string to copy"); + r = p_sprintf(buffer, buffer+1); + ok(r==14, "r = %d\n", r); + ok(!strcmp(buffer, "string to copy"), "failed: "%s"\n", buffer); + setlocale(LC_ALL, "C"); }
@@ -1499,14 +1523,14 @@ static void test__get_output_format(void) ret = p__get_output_format(); ok(ret == 0, "got %d\n", ret);
- c = sprintf(buf, "%E", 1.23); + c = p_sprintf(buf, "%E", 1.23); ok(c == 13, "c = %d\n", c); ok(!strcmp(buf, "1.230000E+000"), "buf = %s\n", buf);
ret = p__set_output_format(_TWO_DIGIT_EXPONENT); ok(ret == 0, "got %d\n", ret);
- c = sprintf(buf, "%E", 1.23); + c = p_sprintf(buf, "%E", 1.23); ok(c == 12, "c = %d\n", c); ok(!strcmp(buf, "1.230000E+00"), "buf = %s\n", buf);
diff --git a/modules/rostests/winetests/msvcrt/scanf.c b/modules/rostests/winetests/msvcrt/scanf.c index b7244835aca..6d38e438c8c 100644 --- a/modules/rostests/winetests/msvcrt/scanf.c +++ b/modules/rostests/winetests/msvcrt/scanf.c @@ -24,6 +24,9 @@
static void test_sscanf( void ) { + /* use function pointers to bypass gcc builtin */ + int (WINAPIV *p_sprintf)(char *buf, const char *fmt, ...); + int (WINAPIV *p_sscanf)(const char *buf, const char *fmt, ...); char buffer[100], buffer1[100]; char format[20]; int result, ret; @@ -35,197 +38,200 @@ static void test_sscanf( void ) static const char pname[]=" St. Petersburg, Florida\n"; int hour=21,min=59,sec=20; int number,number_so_far; + HMODULE hmod = GetModuleHandleA("msvcrt.dll");
+ p_sprintf = (void *)GetProcAddress( hmod, "sprintf" ); + p_sscanf = (void *)GetProcAddress( hmod, "sscanf" );
/* check EOF */ strcpy(buffer,""); - ret = sscanf(buffer, "%d", &result); + ret = p_sscanf(buffer, "%d", &result); ok( ret == EOF,"sscanf returns %x instead of %x\n", ret, EOF );
/* check %p */ - ok( sscanf("000000000046F170", "%p", &ptr) == 1, "sscanf failed\n" ); + ok( p_sscanf("000000000046F170", "%p", &ptr) == 1, "sscanf failed\n" ); ok( ptr == (void *)0x46F170,"sscanf reads %p instead of %x\n", ptr, 0x46F170 );
- ok( sscanf("0046F171", "%p", &ptr) == 1, "sscanf failed\n" ); + ok( p_sscanf("0046F171", "%p", &ptr) == 1, "sscanf failed\n" ); ok( ptr == (void *)0x46F171,"sscanf reads %p instead of %x\n", ptr, 0x46F171 );
- ok( sscanf("46F172", "%p", &ptr) == 1, "sscanf failed\n" ); + ok( p_sscanf("46F172", "%p", &ptr) == 1, "sscanf failed\n" ); ok( ptr == (void *)0x46F172,"sscanf reads %p instead of %x\n", ptr, 0x46F172 );
- ok( sscanf("0x46F173", "%p", &ptr) == 1, "sscanf failed\n" ); + ok( p_sscanf("0x46F173", "%p", &ptr) == 1, "sscanf failed\n" ); ok( ptr == NULL,"sscanf reads %p instead of %x\n", ptr, 0 );
- ok( sscanf("-46F174", "%p", &ptr) == 1, "sscanf failed\n" ); + ok( p_sscanf("-46F174", "%p", &ptr) == 1, "sscanf failed\n" ); ok( ptr == (void *)(ULONG_PTR)-0x46f174,"sscanf reads %p instead of %p\n", ptr, (void *)(ULONG_PTR)-0x46f174 );
- ok( sscanf("+46F175", "%p", &ptr) == 1, "sscanf failed\n" ); + ok( p_sscanf("+46F175", "%p", &ptr) == 1, "sscanf failed\n" ); ok( ptr == (void *)0x46F175,"sscanf reads %p instead of %x\n", ptr, 0x46F175 );
/* check %p with no hex digits */ - ok( sscanf("1233", "%p", &ptr) == 1, "sscanf failed\n" ); + ok( p_sscanf("1233", "%p", &ptr) == 1, "sscanf failed\n" ); ok( ptr == (void *)0x1233,"sscanf reads %p instead of %x\n", ptr, 0x1233 );
- ok( sscanf("1234", "%P", &ptr) == 1, "sscanf failed\n" ); + ok( p_sscanf("1234", "%P", &ptr) == 1, "sscanf failed\n" ); ok( ptr == (void *)0x1234,"sscanf reads %p instead of %x\n", ptr, 0x1234 );
/* check %x */ strcpy(buffer,"0x519"); - ok( sscanf(buffer, "%x", &result) == 1, "sscanf failed\n" ); + ok( p_sscanf(buffer, "%x", &result) == 1, "sscanf failed\n" ); ok( result == 0x519,"sscanf reads %x instead of %x\n", result, 0x519 );
strcpy(buffer,"0x51a"); - ok( sscanf(buffer, "%x", &result) == 1, "sscanf failed\n" ); + ok( p_sscanf(buffer, "%x", &result) == 1, "sscanf failed\n" ); ok( result == 0x51a ,"sscanf reads %x instead of %x\n", result, 0x51a );
strcpy(buffer,"0x51g"); - ok( sscanf(buffer, "%x", &result) == 1, "sscanf failed\n" ); + ok( p_sscanf(buffer, "%x", &result) == 1, "sscanf failed\n" ); ok( result == 0x51, "sscanf reads %x instead of %x\n", result, 0x51 );
result = 0; - ret = sscanf("-1", "%x", &result); + ret = p_sscanf("-1", "%x", &result); ok(ret == 1, "Wrong number of arguments read: %d (expected 1)\n", ret); ok(result == -1, "Read %d, expected -1\n", result);
/* check % followed by any char */ strcpy(buffer,""%12@"); strcpy(format,"%"%%%d%@"); /* work around gcc format check */ - ok( sscanf(buffer, format, &result) == 1, "sscanf failed\n" ); + ok( p_sscanf(buffer, format, &result) == 1, "sscanf failed\n" ); ok( result == 12, "sscanf reads %x instead of %x\n", result, 12 );
/* Check float */ - ret = sprintf(buffer,"%f %f",res1, res2); + ret = p_sprintf(buffer,"%f %f",res1, res2); ok( ret == 20, "expected 20, got %u\n", ret); - ret = sscanf(buffer,"%f%f",&res11, &res12); + ret = p_sscanf(buffer,"%f%f",&res11, &res12); ok( ret == 2, "expected 2, got %u\n", ret); ok( (res11 == res1) && (res12 == res2), "Error reading floats\n");
/* Check double */ - ret = sprintf(buffer, "%lf", 32.715); + ret = p_sprintf(buffer, "%lf", 32.715); ok(ret == 9, "expected 9, got %u\n", ret); - ret = sscanf(buffer, "%lf", &double_res); + ret = p_sscanf(buffer, "%lf", &double_res); ok(ret == 1, "expected 1, got %u\n", ret); ok(double_res == 32.715, "Got %lf, expected %lf\n", double_res, 32.715); - ret = sscanf(buffer, "%Lf", &double_res); + ret = p_sscanf(buffer, "%Lf", &double_res); ok(ret == 1, "expected 1, got %u\n", ret); ok(double_res == 32.715, "Got %lf, expected %lf\n", double_res, 32.715);
strcpy(buffer, "1.1e-30"); - ret = sscanf(buffer, "%lf", &double_res); + ret = p_sscanf(buffer, "%lf", &double_res); ok(ret == 1, "expected 1, got %u\n", ret); ok(double_res >= 1.1e-30-1e-45 && double_res <= 1.1e-30+1e-45, "Got %.18le, expected %.18le\n", double_res, 1.1e-30);
/* check strings */ - ret = sprintf(buffer," %s", pname); + ret = p_sprintf(buffer," %s", pname); ok( ret == 26, "expected 26, got %u\n", ret); - ret = sscanf(buffer,"%*c%[^\n]",buffer1); + ret = p_sscanf(buffer,"%*c%[^\n]",buffer1); ok( ret == 1, "Error with format "%s"\n","%*c%[^\n]"); ok( strncmp(pname,buffer1,strlen(buffer1)) == 0, "Error with "%s" "%s"\n",pname, buffer1);
- ret = sscanf("abcefgdh","%*[a-cg-e]%c",&buffer[0]); + ret = p_sscanf("abcefgdh","%*[a-cg-e]%c",&buffer[0]); ok( ret == 1, "Error with format "%s"\n","%*[a-cg-e]%c"); ok( buffer[0] == 'd', "Error with "abcefgdh" "%c"\n", buffer[0]);
- ret = sscanf("abcefgdh","%*[a-cd-dg-e]%c",&buffer[0]); + ret = p_sscanf("abcefgdh","%*[a-cd-dg-e]%c",&buffer[0]); ok( ret == 1, "Error with format "%s"\n","%*[a-cd-dg-e]%c"); ok( buffer[0] == 'h', "Error with "abcefgdh" "%c"\n", buffer[0]);
buffer1[0] = 'b'; - ret = sscanf("a","%s%s", buffer, buffer1); + ret = p_sscanf("a","%s%s", buffer, buffer1); ok( ret == 1, "expected 1, got %u\n", ret); ok( buffer[0] == 'a', "buffer[0] = '%c'\n", buffer[0]); ok( buffer[1] == '\0', "buffer[1] = '%c'\n", buffer[1]); ok( buffer1[0] == 'b', "buffer1[0] = '%c'\n", buffer1[0]);
/* check digits */ - ret = sprintf(buffer,"%d:%d:%d",hour,min,sec); + ret = p_sprintf(buffer,"%d:%d:%d",hour,min,sec); ok( ret == 8, "expected 8, got %u\n", ret); - ret = sscanf(buffer,"%d%n",&number,&number_so_far); + ret = p_sscanf(buffer,"%d%n",&number,&number_so_far); ok(ret == 1 , "problem with format arg "%%d%%n"\n"); ok(number == hour,"Read wrong arg %d instead of %d\n",number, hour); ok(number_so_far == 2,"Read wrong arg for "%%n" %d instead of 2\n",number_so_far);
- ret = sscanf(buffer+2,"%*c%n",&number_so_far); + ret = p_sscanf(buffer+2,"%*c%n",&number_so_far); ok(ret == 0 , "problem with format arg "%%*c%%n"\n"); ok(number_so_far == 1,"Read wrong arg for "%%n" %d instead of 2\n",number_so_far);
result = 0xdeadbeef; strcpy(buffer,"12345678"); - ret = sscanf(buffer, "%hd", &result); + ret = p_sscanf(buffer, "%hd", &result); ok(ret == 1, "Wrong number of arguments read: %d\n", ret); ok(result == 0xdead614e, "Wrong number read (%x)\n", result);
result = 0xdeadbeef; - ret = sscanf(buffer, "%hhd", &result); + ret = p_sscanf(buffer, "%hhd", &result); ok(ret == 1, "Wrong number of arguments read: %d\n", ret); ok(result == 0xbc614e, "Wrong number read (%x)\n", result);
strcpy(buffer,"12345678901234"); - ret = sscanf(buffer, "%lld", &result64); + ret = p_sscanf(buffer, "%lld", &result64); ok(ret == 1, "Wrong number of arguments read: %d\n", ret); - ret = sprintf(buffer1, "%lld", result64); + ret = p_sprintf(buffer1, "%lld", result64); ok(ret==14 || broken(ret==10), "sprintf returned %d\n", ret); if(ret == 14) ok(!strcmp(buffer, buffer1), "got %s, expected %s\n", buffer1, buffer);
/* Check %i according to bug 1878 */ strcpy(buffer,"123"); - ret = sscanf(buffer, "%i", &result); + ret = p_sscanf(buffer, "%i", &result); ok(ret == 1, "Wrong number of arguments read: %d\n", ret); ok(result == 123, "Wrong number read\n"); result = 0; - ret = sscanf("-1", "%i", &result); + ret = p_sscanf("-1", "%i", &result); ok(ret == 1, "Wrong number of arguments read: %d (expected 1)\n", ret); ok(result == -1, "Read %d, expected -1\n", result); - ret = sscanf(buffer, "%d", &result); + ret = p_sscanf(buffer, "%d", &result); ok(ret == 1, "Wrong number of arguments read: %d\n", ret); ok(result == 123, "Wrong number read\n"); result = 0; - ret = sscanf("-1", "%d", &result); + ret = p_sscanf("-1", "%d", &result); ok(ret == 1, "Wrong number of arguments read: %d (expected 1)\n", ret); ok(result == -1, "Read %d, expected -1\n", result);
/* Check %i for octal and hexadecimal input */ result = 0; strcpy(buffer,"017"); - ret = sscanf(buffer, "%i", &result); + ret = p_sscanf(buffer, "%i", &result); ok(ret == 1, "Wrong number of arguments read: %d\n", ret); ok(result == 15, "Wrong number read\n"); result = 0; strcpy(buffer,"0x17"); - ret = sscanf(buffer, "%i", &result); + ret = p_sscanf(buffer, "%i", &result); ok(ret == 1, "Wrong number of arguments read: %d\n", ret); ok(result == 23, "Wrong number read\n");
/* %o */ result = 0; - ret = sscanf("-1", "%o", &result); + ret = p_sscanf("-1", "%o", &result); ok(ret == 1, "Wrong number of arguments read: %d (expected 1)\n", ret); ok(result == -1, "Read %d, expected -1\n", result);
/* %u */ result = 0; - ret = sscanf("-1", "%u", &result); + ret = p_sscanf("-1", "%u", &result); ok(ret == 1, "Wrong number of arguments read: %d (expected 1)\n", ret); ok(result == -1, "Read %d, expected -1\n", result);
/* Check %c */ strcpy(buffer,"a"); c = 0x55; - ret = sscanf(buffer, "%c", &c); + ret = p_sscanf(buffer, "%c", &c); ok(ret == 1, "Wrong number of arguments read: %d\n", ret); ok(c == 'a', "Field incorrect: '%c'\n", c);
strcpy(buffer," a"); c = 0x55; - ret = sscanf(buffer, "%c", &c); + ret = p_sscanf(buffer, "%c", &c); ok(ret == 1, "Wrong number of arguments read: %d\n", ret); ok(c == ' ', "Field incorrect: '%c'\n", c);
strcpy(buffer,"18:59"); c = 0x55; - ret = sscanf(buffer, "%d:%d%c", &hour, &min, &c); + ret = p_sscanf(buffer, "%d:%d%c", &hour, &min, &c); ok(ret == 2, "Wrong number of arguments read: %d\n", ret); ok(hour == 18, "Field 1 incorrect: %d\n", hour); ok(min == 59, "Field 2 incorrect: %d\n", min); @@ -233,7 +239,7 @@ static void test_sscanf( void )
/* Check %n (also whitespace in format strings and %s) */ buffer[0]=0; buffer1[0]=0; - ret = sscanf("abc def", "%s %n%s", buffer, &number_so_far, buffer1); + ret = p_sscanf("abc def", "%s %n%s", buffer, &number_so_far, buffer1); ok(strcmp(buffer, "abc")==0, "First %%s read incorrectly: %s\n", buffer); ok(strcmp(buffer1,"def")==0, "Second %%s read incorrectly: %s\n", buffer1); ok(number_so_far==6, "%%n yielded wrong result: %d\n", number_so_far); @@ -241,18 +247,18 @@ static void test_sscanf( void )
/* Check where %n matches to EOF in buffer */ strcpy(buffer, "3:45"); - ret = sscanf(buffer, "%d:%d%n", &hour, &min, &number_so_far); + ret = p_sscanf(buffer, "%d:%d%n", &hour, &min, &number_so_far); ok(ret == 2, "Wrong number of arguments read: %d\n", ret); ok(number_so_far == 4, "%%n yielded wrong result: %d\n", number_so_far);
buffer[0] = 0; buffer1[0] = 0; - ret = sscanf("test=value\xda", "%[^=] = %[^;]", buffer, buffer1); + ret = p_sscanf("test=value\xda", "%[^=] = %[^;]", buffer, buffer1); ok(ret == 2, "got %d\n", ret); ok(!strcmp(buffer, "test"), "buf %s\n", buffer); ok(!strcmp(buffer1, "value\xda"), "buf %s\n", buffer1);
- ret = sscanf("\x81\x82test", "\x81%\x82%s", buffer); + ret = p_sscanf("\x81\x82test", "\x81%\x82%s", buffer); ok(ret == 1, "got %d\n", ret); ok(!strcmp(buffer, "test"), "buf = %s\n", buffer); } diff --git a/modules/rostests/winetests/msvcrt/string.c b/modules/rostests/winetests/msvcrt/string.c index e80a51824ba..573289d77b5 100644 --- a/modules/rostests/winetests/msvcrt/string.c +++ b/modules/rostests/winetests/msvcrt/string.c @@ -88,6 +88,7 @@ static errno_t (__cdecl *p_mbsupr_s)(unsigned char *str, size_t numberOfElements static errno_t (__cdecl *p_mbslwr_s)(unsigned char *str, size_t numberOfElements); static int (__cdecl *p_wctob)(wint_t); static size_t (__cdecl *p_wcrtomb)(char*, wchar_t, mbstate_t*); +static int (__cdecl *p_wcrtomb_s)(size_t*, char*, size_t, wchar_t, mbstate_t*); static int (__cdecl *p_tolower)(int); static int (__cdecl *p_towlower)(wint_t); static int (__cdecl *p__towlower_l)(wint_t, _locale_t); @@ -101,6 +102,7 @@ static int (__cdecl *p__atodbl_l)(_CRT_DOUBLE*,char*,_locale_t); static double (__cdecl *p__atof_l)(const char*,_locale_t); static double (__cdecl *p__strtod_l)(const char *,char**,_locale_t); static int (__cdecl *p__strnset_s)(char*,size_t,int,size_t); +static int (__cdecl *p__wcsnset_s)(wchar_t*,size_t,wchar_t,size_t); static int (__cdecl *p__wcsset_s)(wchar_t*,size_t,wchar_t); static size_t (__cdecl *p__mbsnlen)(const unsigned char*, size_t); static int (__cdecl *p__mbccpy_s)(unsigned char*, size_t, int*, const unsigned char*); @@ -515,13 +517,32 @@ static void test_mbsspn( void) unsigned char str2[]="shiraz"; unsigned char set[]="abc"; unsigned char empty[]=""; - int ret; + unsigned char mbstr[]=" 2019\x94\x4e" "6\x8c\x8e" "29\x93\xfa"; + unsigned char mbset1[]="0123456789 \x94\x4e"; + unsigned char mbset2[]=" \x94\x4e\x8c\x8e"; + unsigned char mbset3[]="\x8e"; + int ret, cp = _getmbcp(); + ret=_mbsspn( str1, set); ok( ret==3, "_mbsspn returns %d should be 3\n", ret); ret=_mbsspn( str2, set); ok( ret==0, "_mbsspn returns %d should be 0\n", ret); ret=_mbsspn( str1, empty); ok( ret==0, "_mbsspn returns %d should be 0\n", ret); + + _setmbcp( 932); + ret=_mbsspn( mbstr, mbset1); + ok( ret==8, "_mbsspn returns %d should be 8\n", ret); + ret=_mbsspn( mbstr, mbset2); + ok( ret==1, "_mbsspn returns %d should be 1\n", ret); + ret=_mbsspn( mbstr+8, mbset1); + ok( ret==0, "_mbsspn returns %d should be 0\n", ret); + ret=_mbsspn( mbstr+8, mbset2); + ok( ret==2, "_mbsspn returns %d should be 2\n", ret); + ret=_mbsspn( mbstr, mbset3); + ok( ret==14, "_mbsspn returns %d should be 14\n", ret); + + _setmbcp( cp); }
static void test_mbsspnp( void) @@ -531,7 +552,12 @@ static void test_mbsspnp( void) unsigned char set[]="abc"; unsigned char empty[]=""; unsigned char full[]="abcenrt"; + unsigned char mbstr[]=" 2019\x94\x4e" "6\x8c\x8e" "29\x93\xfa"; + unsigned char mbset1[]="0123456789 \x94\x4e"; + unsigned char mbset2[]=" \x94\x4e\x8c\x8e"; unsigned char* ret; + int cp = _getmbcp(); + ret=_mbsspnp( str1, set); ok( ret[0]=='e', "_mbsspnp returns %c should be e\n", ret[0]); ret=_mbsspnp( str2, set); @@ -540,6 +566,18 @@ static void test_mbsspnp( void) ok( ret[0]=='c', "_mbsspnp returns %c should be c\n", ret[0]); ret=_mbsspnp( str1, full); ok( ret==NULL, "_mbsspnp returns %p should be NULL\n", ret); + + _setmbcp( 932); + ret=_mbsspnp( mbstr, mbset1); + ok( ret==mbstr+8, "_mbsspnp returns %p should be %p\n", ret, mbstr+8); + ret=_mbsspnp( mbstr, mbset2); + ok( ret==mbstr+1, "_mbsspnp returns %p should be %p\n", ret, mbstr+1); + ret=_mbsspnp( mbstr+8, mbset1); + ok( ret==mbstr+8, "_mbsspnp returns %p should be %p\n", ret, mbstr+8); + ret=_mbsspnp( mbstr+8, mbset2); + ok( ret==mbstr+10, "_mbsspnp returns %p should be %p\n", ret, mbstr+10); + + _setmbcp( cp); }
static void test_strdup(void) @@ -1019,6 +1057,11 @@ static void test_wcscpy_s(void) ok(ret == 0, "expected 0 got %d\n", ret); ok(lstrcmpW(szDest, szLongText) == 0, "szDest != szLongText\n");
+ /* dest == source */ + ret = p_wcscpy_s(szDest, 18, szDest); + ok(ret == 0, "expected 0 got %d\n", ret); + ok(lstrcmpW(szDest, szLongText) == 0, "szDest != szLongText\n"); + /* Copy smaller buffer size */ errno = EBADF; szDest[0] = 'A'; @@ -2701,7 +2744,7 @@ static void test__ultoa_s(void)
static void test_wctob(void) { - int ret; + int ret, cp = _getmbcp();
if(!p_wctob || !setlocale(LC_ALL, "chinese-traditional")) { win_skip("Skipping wctob tests\n"); @@ -2733,12 +2776,16 @@ static void test_wctob(void)
ret = p_wctob(0xe0); ok(ret == (int)(char)0xe0, "ret = %x\n", ret); + + _setmbcp(cp); } + static void test_wctomb(void) { mbstate_t state; unsigned char dst[10]; size_t ret; + int err;
if(!p_wcrtomb || !setlocale(LC_ALL, "Japanese_Japan.932")) { win_skip("wcrtomb tests\n"); @@ -2770,6 +2817,43 @@ static void test_wctomb(void) ok(ret == -1, "wcrtomb did not return -1\n"); ok(dst[0] == 0x3f, "dst[0] = %x, expected 0x3f\n", dst[0]);
+ if(!p_wcrtomb_s) { + win_skip("wcrtomb_s tests\n"); + setlocale(LC_ALL, "C"); + return; + } + + state = 1; + dst[2] = 'a'; + err = p_wcrtomb_s(&ret, (char*)dst, sizeof(dst), 0x3042, &state); + ok(!err, "err = %d\n", err); + ok(ret == 2, "ret != 2\n"); + ok(!state, "state != 0\n"); + ok(dst[0] == 0x82, "dst[0] = %x, expected 0x82\n", dst[0]); + ok(dst[1] == 0xa0, "dst[1] = %x, expected 0xa0\n", dst[1]); + ok(dst[2] == 'a', "dst[2] != 'a'\n"); + + err = p_wcrtomb_s(&ret, (char*)dst, sizeof(dst), 0x3042, NULL); + ok(!err, "err = %d\n", err); + ok(ret == 2, "ret != 2\n"); + ok(!state, "state != 0\n"); + ok(dst[0] == 0x82, "dst[0] = %x, expected 0x82\n", dst[0]); + ok(dst[1] == 0xa0, "dst[1] = %x, expected 0xa0\n", dst[1]); + + err = p_wcrtomb_s(&ret, (char*)dst, sizeof(dst), 0x20, NULL); + ok(!err, "err = %d\n", err); + ok(ret == 1, "ret != 1\n"); + ok(dst[0] == 0x20, "dst[0] = %x, expected 0x20\n", dst[0]); + + err = p_wcrtomb_s(&ret, NULL, 0, 0x20, NULL); + ok(!err, "err = %d\n", err); + ok(ret == 1, "ret != 1\n"); + + err = p_wcrtomb_s(&ret, (char*)dst, sizeof(dst), 0xffff, NULL); + ok(err == EILSEQ, "err = %d\n", err); + ok(ret == -1, "wcrtomb did not return -1\n"); + ok(dst[0] == 0x3f, "dst[0] = %x, expected 0x3f\n", dst[0]); + setlocale(LC_ALL, "C"); }
@@ -2788,13 +2872,19 @@ static void test_tolower(void)
errno = 0xdeadbeef; ret = p_tolower((char)0xF4); - todo_wine ok(ret == (char)0xF4, "ret = %x\n", ret); - todo_wine ok(errno == 0xdeadbeef, "errno = %d\n", errno); + ok(ret == (char)0xF4, "ret = %x\n", ret); + ok(errno == 0xdeadbeef, "errno = %d\n", errno);
errno = 0xdeadbeef; ret = p_tolower((char)0xD0); - todo_wine ok(ret == (char)0xD0, "ret = %x\n", ret); - todo_wine ok(errno == 0xdeadbeef, "errno = %d\n", errno); + ok(ret == (char)0xD0, "ret = %x\n", ret); + ok(errno == 0xdeadbeef, "errno = %d\n", errno); + + setlocale(LC_ALL, "C"); + errno = 0xdeadbeef; + ret = p_tolower((char)0xF4); + ok(ret == (char)0xF4, "ret = %x\n", ret); + ok(errno == 0xdeadbeef, "errno = %d\n", errno);
/* test C locale after setting locale */ if(!setlocale(LC_ALL, "us")) { @@ -3041,6 +3131,23 @@ static void test_atoi(void) ok(r == 0, "atoi(4294967296) = %d\n", r); }
+static void test_atol(void) +{ + int r; + + r = atol("0"); + ok(r == 0, "atol(0) = %d\n", r); + + r = atol("-1"); + ok(r == -1, "atol(-1) = %d\n", r); + + r = atol("1"); + ok(r == 1, "atol(1) = %d\n", r); + + r = atol("4294967296"); + ok(r == 0, "atol(4294967296) = %d\n", r); +} + static void test_atof(void) { double d; @@ -3074,29 +3181,33 @@ static void test_atof(void) static void test_strncpy(void) { #define TEST_STRNCPY_LEN 10 + /* use function pointer to bypass gcc builtin */ + char *(__cdecl *p_strncpy)(char*,const char*,size_t); char *ret; char dst[TEST_STRNCPY_LEN + 1]; char not_null_terminated[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0'};
+ p_strncpy = (void *)GetProcAddress( GetModuleHandleA("msvcrt.dll"), "strncpy"); + /* strlen(src) > TEST_STRNCPY_LEN */ - ret = strncpy(dst, "01234567890123456789", TEST_STRNCPY_LEN); + ret = p_strncpy(dst, "01234567890123456789", TEST_STRNCPY_LEN); ok(ret == dst, "ret != dst\n"); ok(!strncmp(dst, "0123456789", TEST_STRNCPY_LEN), "dst != 0123456789\n");
/* without null-terminated */ - ret = strncpy(dst, not_null_terminated, TEST_STRNCPY_LEN); + ret = p_strncpy(dst, not_null_terminated, TEST_STRNCPY_LEN); ok(ret == dst, "ret != dst\n"); ok(!strncmp(dst, "0123456789", TEST_STRNCPY_LEN), "dst != 0123456789\n");
/* strlen(src) < TEST_STRNCPY_LEN */ strcpy(dst, "0123456789"); - ret = strncpy(dst, "012345", TEST_STRNCPY_LEN); + ret = p_strncpy(dst, "012345", TEST_STRNCPY_LEN); ok(ret == dst, "ret != dst\n"); ok(!strcmp(dst, "012345"), "dst != 012345\n"); ok(dst[TEST_STRNCPY_LEN - 1] == '\0', "dst[TEST_STRNCPY_LEN - 1] != 0\n");
/* strlen(src) == TEST_STRNCPY_LEN */ - ret = strncpy(dst, "0123456789", TEST_STRNCPY_LEN); + ret = p_strncpy(dst, "0123456789", TEST_STRNCPY_LEN); ok(ret == dst, "ret != dst\n"); ok(!strncmp(dst, "0123456789", TEST_STRNCPY_LEN), "dst != 0123456789\n"); } @@ -3198,6 +3309,45 @@ static void test__strnset_s(void) ok(!buf[0] && buf[1]=='c' && buf[2]=='b', "buf = %s\n", buf); }
+static void test__wcsnset_s(void) +{ + wchar_t text[] = { 't','e','x','t',0 }; + int r; + + if(!p__wcsnset_s) { + win_skip("_wcsnset_s not available\n"); + return; + } + + r = p__wcsnset_s(NULL, 0, 'a', 0); + ok(r == 0, "r = %d\n", r); + + r = p__wcsnset_s(text, 0, 'a', 1); + ok(r == EINVAL, "r = %d\n", r); + ok(text[0] == 't', "text[0] = %d\n", text[0]); + + r = p__wcsnset_s(NULL, 2, 'a', 1); + ok(r == EINVAL, "r = %d\n", r); + + r = p__wcsnset_s(text, 2, 'a', 3); + ok(r == EINVAL, "r = %d\n", r); + ok(text[0] == 0, "text[0] = %d\n", text[0]); + ok(text[1] == 'e', "text[1] = %d\n", text[1]); + + text[0] = 't'; + r = p__wcsnset_s(text, 5, 'a', 1); + ok(r == 0, "r = %d\n", r); + ok(text[0] == 'a', "text[0] = %d\n", text[0]); + ok(text[1] == 'e', "text[1] = %d\n", text[1]); + + text[1] = 0; + r = p__wcsnset_s(text, 5, 'b', 3); + ok(r == 0, "r = %d\n", r); + ok(text[0] == 'b', "text[0] = %d\n", text[0]); + ok(text[1] == 0, "text[1] = %d\n", text[1]); + ok(text[2] == 'x', "text[2] = %d\n", text[2]); +} + static void test__wcsset_s(void) { wchar_t str[10]; @@ -3227,6 +3377,7 @@ static void test__wcsset_s(void) str[1] = 0; str[2] = 'b'; r = p__wcsset_s(str, 3, 'c'); + ok(r == 0, "r = %d\n", r); ok(str[0] == 'c', "str[0] = %d\n", str[0]); ok(str[1] == 0, "str[1] = %d\n", str[1]); ok(str[2] == 'b', "str[2] = %d\n", str[2]); @@ -3264,16 +3415,28 @@ static void test__mbscmp(void)
static void test__ismbclx(void) { - int cp, ret; + int ret, cp = _getmbcp();
ret = _ismbcl0(0); ok(!ret, "got %d\n", ret);
- cp = _setmbcp(1252); + ret = _ismbcl1(0); + ok(!ret, "got %d\n", ret); + + ret = _ismbcl2(0); + ok(!ret, "got %d\n", ret); + + _setmbcp(1252);
ret = _ismbcl0(0x8140); ok(!ret, "got %d\n", ret);
+ ret = _ismbcl1(0x889f); + ok(!ret, "got %d\n", ret); + + ret = _ismbcl2(0x989f); + ok(!ret, "got %d\n", ret); + _setmbcp(932);
ret = _ismbcl0(0); @@ -3282,6 +3445,27 @@ static void test__ismbclx(void) ret = _ismbcl0(0x8140); ok(ret, "got %d\n", ret);
+ ret = _ismbcl0(0x817f); + ok(!ret, "got %d\n", ret); + + ret = _ismbcl1(0); + ok(!ret, "got %d\n", ret); + + ret = _ismbcl1(0x889f); + ok(ret, "got %d\n", ret); + + ret = _ismbcl1(0x88fd); + ok(!ret, "got %d\n", ret); + + ret = _ismbcl2(0); + ok(!ret, "got %d\n", ret); + + ret = _ismbcl2(0x989f); + ok(ret, "got %d\n", ret); + + ret = _ismbcl2(0x993f); + ok(!ret, "got %d\n", ret); + _setmbcp(cp); }
@@ -3627,7 +3811,6 @@ static void test_C_locale(void) ok(ret == exp, "expected %x, got %x for C locale\n", exp, ret); } else - todo_wine_if(ret != i) ok(ret == i, "expected self %x, got %x for C locale\n", i, ret);
ret = p_towupper(i); @@ -3637,7 +3820,6 @@ static void test_C_locale(void) ok(ret == exp, "expected %x, got %x for C locale\n", exp, ret); } else - todo_wine_if(ret != i) ok(ret == i, "expected self %x, got %x for C locale\n", i, ret); }
@@ -3658,7 +3840,6 @@ static void test_C_locale(void) ok(ret == exp, "expected %x, got %x for C locale\n", exp, ret); } else - todo_wine_if(ret != j) ok(ret == j, "expected self %x, got %x for C locale\n", j, ret);
ret = p__towupper_l(j, locale); @@ -3668,7 +3849,6 @@ static void test_C_locale(void) ok(ret == exp, "expected %x, got %x for C locale\n", exp, ret); } else - todo_wine_if(ret != j) ok(ret == j, "expected self %x, got %x for C locale\n", j, ret); }
@@ -3720,6 +3900,7 @@ START_TEST(string) p_mbslwr_s = (void*)GetProcAddress(hMsvcrt, "_mbslwr_s"); p_wctob = (void*)GetProcAddress(hMsvcrt, "wctob"); p_wcrtomb = (void*)GetProcAddress(hMsvcrt, "wcrtomb"); + p_wcrtomb_s = (void*)GetProcAddress(hMsvcrt, "wcrtomb_s"); p_tolower = (void*)GetProcAddress(hMsvcrt, "tolower"); p_towlower = (void*)GetProcAddress(hMsvcrt, "towlower"); p__towlower_l = (void*)GetProcAddress(hMsvcrt, "_towlower_l"); @@ -3735,6 +3916,7 @@ START_TEST(string) p__atof_l = (void*)GetProcAddress(hMsvcrt, "_atof_l"); p__strtod_l = (void*)GetProcAddress(hMsvcrt, "_strtod_l"); p__strnset_s = (void*)GetProcAddress(hMsvcrt, "_strnset_s"); + p__wcsnset_s = (void*)GetProcAddress(hMsvcrt, "_wcsnset_s"); p__wcsset_s = (void*)GetProcAddress(hMsvcrt, "_wcsset_s"); p__mbsnlen = (void*)GetProcAddress(hMsvcrt, "_mbsnlen"); p__mbccpy_s = (void*)GetProcAddress(hMsvcrt, "_mbccpy_s"); @@ -3796,10 +3978,12 @@ START_TEST(string) test__stricmp(); test__wcstoi64(); test_atoi(); + test_atol(); test_atof(); test_strncpy(); test_strxfrm(); test__strnset_s(); + test__wcsnset_s(); test__wcsset_s(); test__mbscmp(); test__ismbclx(); diff --git a/modules/rostests/winetests/msvcrt/time.c b/modules/rostests/winetests/msvcrt/time.c index a5a2df18bba..cf79e5971ec 100644 --- a/modules/rostests/winetests/msvcrt/time.c +++ b/modules/rostests/winetests/msvcrt/time.c @@ -577,7 +577,7 @@ static void test_daylight(void)
if (!p___p__daylight) { - win_skip("__p__daylight not available\n"); + skip("__p__daylight not available\n"); return; }
@@ -609,47 +609,97 @@ static void test_strftime(void) ok(gmt_tm != NULL, "gmtime failed\n");
errno = 0xdeadbeef; - retA = strftime(NULL, 0, "copy", gmt_tm); + retA = p_strftime(bufA, 256, "%C", gmt_tm); ok(retA == 0, "expected 0, got %ld\n", retA); ok(errno==EINVAL || broken(errno==0xdeadbeef), "errno = %d\n", errno);
- retA = strftime(bufA, 256, "copy", NULL); + errno = 0xdeadbeef; + retA = p_strftime(bufA, 256, "%D", gmt_tm); + ok(retA == 0, "expected 0, got %ld\n", retA); + ok(errno==EINVAL || broken(errno==0xdeadbeef), "errno = %d\n", errno); + + errno = 0xdeadbeef; + retA = p_strftime(bufA, 256, "%e", gmt_tm); + ok(retA == 0, "expected 0, got %ld\n", retA); + ok(errno==EINVAL || broken(errno==0xdeadbeef), "errno = %d\n", errno); + + errno = 0xdeadbeef; + retA = p_strftime(bufA, 256, "%F", gmt_tm); + ok(retA == 0, "expected 0, got %ld\n", retA); + ok(errno==EINVAL || broken(errno==0xdeadbeef), "errno = %d\n", errno); + + errno = 0xdeadbeef; + retA = p_strftime(bufA, 256, "%h", gmt_tm); + ok(retA == 0, "expected 0, got %ld\n", retA); + ok(errno==EINVAL || broken(errno==0xdeadbeef), "errno = %d\n", errno); + + errno = 0xdeadbeef; + retA = p_strftime(bufA, 256, "%n", gmt_tm); + ok(retA == 0, "expected 0, got %ld\n", retA); + ok(errno==EINVAL || broken(errno==0xdeadbeef), "errno = %d\n", errno); + + errno = 0xdeadbeef; + retA = p_strftime(bufA, 256, "%R", gmt_tm); + ok(retA == 0, "expected 0, got %ld\n", retA); + ok(errno==EINVAL || broken(errno==0xdeadbeef), "errno = %d\n", errno); + + errno = 0xdeadbeef; + retA = p_strftime(bufA, 256, "%t", gmt_tm); + ok(retA == 0, "expected 0, got %ld\n", retA); + ok(errno==EINVAL || broken(errno==0xdeadbeef), "errno = %d\n", errno); + + errno = 0xdeadbeef; + retA = p_strftime(bufA, 256, "%T", gmt_tm); + ok(retA == 0, "expected 0, got %ld\n", retA); + ok(errno==EINVAL || broken(errno==0xdeadbeef), "errno = %d\n", errno); + + errno = 0xdeadbeef; + retA = p_strftime(bufA, 256, "%u", gmt_tm); + ok(retA == 0, "expected 0, got %ld\n", retA); + ok(errno==EINVAL || broken(errno==0xdeadbeef), "errno = %d\n", errno); + + errno = 0xdeadbeef; + retA = p_strftime(NULL, 0, "copy", gmt_tm); + ok(retA == 0, "expected 0, got %ld\n", retA); + ok(errno==EINVAL || broken(errno==0xdeadbeef), "errno = %d\n", errno); + + retA = p_strftime(bufA, 256, "copy", NULL); ok(retA == 4, "expected 4, got %ld\n", retA); ok(!strcmp(bufA, "copy"), "got %s\n", bufA);
- retA = strftime(bufA, 256, "copy it", gmt_tm); + retA = p_strftime(bufA, 256, "copy it", gmt_tm); ok(retA == 7, "expected 7, got %ld\n", retA); ok(!strcmp(bufA, "copy it"), "got %s\n", bufA);
errno = 0xdeadbeef; - retA = strftime(bufA, 2, "copy", gmt_tm); + retA = p_strftime(bufA, 2, "copy", gmt_tm); ok(retA == 0, "expected 0, got %ld\n", retA); ok(!strcmp(bufA, "") || broken(!strcmp(bufA, "copy it")), "got %s\n", bufA); ok(errno==ERANGE || errno==0xdeadbeef, "errno = %d\n", errno);
errno = 0xdeadbeef; - retA = strftime(bufA, 256, "a%e", gmt_tm); + retA = p_strftime(bufA, 256, "a%e", gmt_tm); ok(retA==0 || broken(retA==1), "expected 0, got %ld\n", retA); ok(!strcmp(bufA, "") || broken(!strcmp(bufA, "a")), "got %s\n", bufA); ok(errno==EINVAL || broken(errno==0xdeadbeef), "errno = %d\n", errno);
if(0) { /* crashes on Win2k */ errno = 0xdeadbeef; - retA = strftime(bufA, 256, "%c", NULL); + retA = p_strftime(bufA, 256, "%c", NULL); ok(retA == 0, "expected 0, got %ld\n", retA); ok(!strcmp(bufA, ""), "got %s\n", bufA); ok(errno == EINVAL, "errno = %d\n", errno); }
- retA = strftime(bufA, 256, "e%#%e", gmt_tm); + retA = p_strftime(bufA, 256, "e%#%e", gmt_tm); ok(retA == 3, "expected 3, got %ld\n", retA); ok(!strcmp(bufA, "e%e"), "got %s\n", bufA);
- retA = strftime(bufA, 256, "%c", gmt_tm); + retA = p_strftime(bufA, 256, "%c", gmt_tm); ok(retA == 17, "expected 17, got %ld\n", retA); ok(strcmp(bufA, expected) == 0, "expected %s, got %s\n", expected, bufA);
- retW = wcsftime(bufW, 256, cW, gmt_tm); + retW = p_wcsftime(bufW, 256, cW, gmt_tm); ok(retW == 17, "expected 17, got %ld\n", retW); ok(retA == retW, "expected %ld, got %ld\n", retA, retW); buf[0] = 0; @@ -657,91 +707,91 @@ static void test_strftime(void) buf[retA] = 0; ok(strcmp(bufA, buf) == 0, "expected %s, got %s\n", bufA, buf);
- retA = strftime(bufA, 256, "%x", gmt_tm); + retA = p_strftime(bufA, 256, "%x", gmt_tm); ok(retA == 8, "expected 8, got %ld\n", retA); ok(!strcmp(bufA, "01/01/70"), "got %s\n", bufA);
- retA = strftime(bufA, 256, "%X", gmt_tm); + retA = p_strftime(bufA, 256, "%X", gmt_tm); ok(retA == 8, "expected 8, got %ld\n", retA); ok(!strcmp(bufA, "00:00:00"), "got %s\n", bufA);
- retA = strftime(bufA, 256, "%a", gmt_tm); + retA = p_strftime(bufA, 256, "%a", gmt_tm); ok(retA == 3, "expected 3, got %ld\n", retA); ok(!strcmp(bufA, "Thu"), "got %s\n", bufA);
- retA = strftime(bufA, 256, "%A", gmt_tm); + retA = p_strftime(bufA, 256, "%A", gmt_tm); ok(retA == 8, "expected 8, got %ld\n", retA); ok(!strcmp(bufA, "Thursday"), "got %s\n", bufA);
- retA = strftime(bufA, 256, "%b", gmt_tm); + retA = p_strftime(bufA, 256, "%b", gmt_tm); ok(retA == 3, "expected 3, got %ld\n", retA); ok(!strcmp(bufA, "Jan"), "got %s\n", bufA);
- retA = strftime(bufA, 256, "%B", gmt_tm); + retA = p_strftime(bufA, 256, "%B", gmt_tm); ok(retA == 7, "expected 7, got %ld\n", retA); ok(!strcmp(bufA, "January"), "got %s\n", bufA);
- retA = strftime(bufA, 256, "%d", gmt_tm); + retA = p_strftime(bufA, 256, "%d", gmt_tm); ok(retA == 2, "expected 2, got %ld\n", retA); ok(!strcmp(bufA, "01"), "got %s\n", bufA);
- retA = strftime(bufA, 256, "%#d", gmt_tm); + retA = p_strftime(bufA, 256, "%#d", gmt_tm); ok(retA == 1, "expected 1, got %ld\n", retA); ok(!strcmp(bufA, "1"), "got %s\n", bufA);
- retA = strftime(bufA, 256, "%H", gmt_tm); + retA = p_strftime(bufA, 256, "%H", gmt_tm); ok(retA == 2, "expected 2, got %ld\n", retA); ok(!strcmp(bufA, "00"), "got %s\n", bufA);
- retA = strftime(bufA, 256, "%I", gmt_tm); + retA = p_strftime(bufA, 256, "%I", gmt_tm); ok(retA == 2, "expected 2, got %ld\n", retA); ok(!strcmp(bufA, "12"), "got %s\n", bufA);
- retA = strftime(bufA, 256, "%j", gmt_tm); + retA = p_strftime(bufA, 256, "%j", gmt_tm); ok(retA == 3, "expected 3, got %ld\n", retA); ok(!strcmp(bufA, "001"), "got %s\n", bufA);
- retA = strftime(bufA, 256, "%m", gmt_tm); + retA = p_strftime(bufA, 256, "%m", gmt_tm); ok(retA == 2, "expected 2, got %ld\n", retA); ok(!strcmp(bufA, "01"), "got %s\n", bufA);
- retA = strftime(bufA, 256, "%#M", gmt_tm); + retA = p_strftime(bufA, 256, "%#M", gmt_tm); ok(retA == 1, "expected 1, got %ld\n", retA); ok(!strcmp(bufA, "0"), "got %s\n", bufA);
- retA = strftime(bufA, 256, "%p", gmt_tm); + retA = p_strftime(bufA, 256, "%p", gmt_tm); ok(retA == 2, "expected 2, got %ld\n", retA); ok(!strcmp(bufA, "AM"), "got %s\n", bufA);
- retA = strftime(bufA, 256, "%U", gmt_tm); + retA = p_strftime(bufA, 256, "%U", gmt_tm); ok(retA == 2, "expected 2, got %ld\n", retA); ok(!strcmp(bufA, "00"), "got %s\n", bufA);
- retA = strftime(bufA, 256, "%W", gmt_tm); + retA = p_strftime(bufA, 256, "%W", gmt_tm); ok(retA == 2, "expected 2, got %ld\n", retA); ok(!strcmp(bufA, "00"), "got %s\n", bufA);
gmt_tm->tm_wday = 0; - retA = strftime(bufA, 256, "%U", gmt_tm); + retA = p_strftime(bufA, 256, "%U", gmt_tm); ok(retA == 2, "expected 2, got %ld\n", retA); ok(!strcmp(bufA, "01"), "got %s\n", bufA);
- retA = strftime(bufA, 256, "%W", gmt_tm); + retA = p_strftime(bufA, 256, "%W", gmt_tm); ok(retA == 2, "expected 2, got %ld\n", retA); ok(!strcmp(bufA, "00"), "got %s\n", bufA);
gmt_tm->tm_yday = 365; - retA = strftime(bufA, 256, "%U", gmt_tm); + retA = p_strftime(bufA, 256, "%U", gmt_tm); ok(retA == 2, "expected 2, got %ld\n", retA); ok(!strcmp(bufA, "53"), "got %s\n", bufA);
- retA = strftime(bufA, 256, "%W", gmt_tm); + retA = p_strftime(bufA, 256, "%W", gmt_tm); ok(retA == 2, "expected 2, got %ld\n", retA); ok(!strcmp(bufA, "52"), "got %s\n", bufA);
gmt_tm->tm_mon = 1; gmt_tm->tm_mday = 30; - retA = strftime(bufA, 256, "%c", gmt_tm); + retA = p_strftime(bufA, 256, "%c", gmt_tm); todo_wine { ok(retA == 17, "expected 17, got %ld\n", retA); ok(!strcmp(bufA, "02/30/70 00:00:00"), "got %s\n", bufA); @@ -753,7 +803,7 @@ static void test_strftime(void) }
/* test with multibyte character */ - retA = strftime(bufA, 256, "\x82%c", gmt_tm); + retA = p_strftime(bufA, 256, "\x82%c", gmt_tm); ok(retA == 3, "expected 3, got %ld\n", retA); ok(!strcmp(bufA, "\x82%c"), "got %s\n", bufA); } @@ -829,7 +879,7 @@ static void test__tzset(void) int ret;
if(!p___p__daylight || !p___p__timezone || !p___p__dstbias) { - win_skip("__p__daylight, __p__timezone or __p__dstbias is not available\n"); + skip("__p__daylight, __p__timezone or __p__dstbias is not available\n"); return; }
@@ -873,23 +923,6 @@ static void test__tzset(void) _putenv(TZ_env); }
-static void test_clock(void) -{ - static const int THRESH = 100; - FILETIME start, cur; - int c, expect; - BOOL ret; - - ret = GetProcessTimes(GetCurrentProcess(), &start, &cur, &cur, &cur); - ok(ret, "GetProcessTimes failed with error: %d\n", GetLastError()); - GetSystemTimeAsFileTime(&cur); - expect = (((LONGLONG)cur.dwHighDateTime<<32)+cur.dwLowDateTime - - ((LONGLONG)start.dwHighDateTime<<32)-start.dwLowDateTime) / 10000; - - c = clock(); - ok(abs(c-expect) < THRESH, "clock() = %d, expected %d\n", c, expect); -} - START_TEST(time) { init(); @@ -908,5 +941,4 @@ START_TEST(time) test_localtime64_s(); test_daylight(); test_asctime(); - test_clock(); }