mirror of
https://github.com/reactos/reactos.git
synced 2025-01-03 21:09:19 +00:00
[MSVCRT_WINETEST] Sync with Wine Staging 1.7.37. CORE-9246
svn path=/trunk/; revision=66659
This commit is contained in:
parent
26326ca7d5
commit
8d12ad730d
4 changed files with 115 additions and 2 deletions
|
@ -2244,6 +2244,7 @@ static void test_write_flush_size(FILE *file, int bufsize)
|
|||
char *inbuffer;
|
||||
char *outbuffer;
|
||||
int size, fd;
|
||||
fpos_t pos, pos2;
|
||||
|
||||
fd = fileno(file);
|
||||
inbuffer = calloc(bufsize + 1, 1);
|
||||
|
@ -2275,6 +2276,19 @@ static void test_write_flush_size(FILE *file, int bufsize)
|
|||
fseek(file, 0, SEEK_SET);
|
||||
ok(fread(inbuffer, 1, bufsize, file) == bufsize, "read failed\n");
|
||||
ok(memcmp(outbuffer, inbuffer, bufsize) != 0, "unexpected flush by %d/2 byte double write\n", bufsize);
|
||||
|
||||
ok(!fseek(file, -1, SEEK_END), "fseek failed\n");
|
||||
ok(!fgetpos(file, &pos), "fgetpos failed\n");
|
||||
ok(fread(inbuffer, 1, 1, file) == 1, "fread failed\n");
|
||||
ok(file->_flag & _IOREAD, "file->_flag = %x\n", file->_flag);
|
||||
ok(!file->_cnt, "file->_cnt = %d\n", file->_cnt);
|
||||
ok(file->_ptr != file->_base, "file->_ptr == file->_base\n");
|
||||
ok(fwrite(outbuffer, 1, bufsize, file), "fwrite failed\n");
|
||||
ok(file->_flag & _IOREAD, "file->_flag = %x\n", file->_flag);
|
||||
ok(!file->_cnt, "file->_cnt = %d\n", file->_cnt);
|
||||
ok(file->_ptr == file->_base, "file->_ptr == file->_base\n");
|
||||
ok(!fgetpos(file, &pos2), "fgetpos failed\n");
|
||||
ok(pos+bufsize+1 == pos2, "pos = %d (%d)\n", (int)pos, (int)pos2);
|
||||
free(inbuffer);
|
||||
free(outbuffer);
|
||||
}
|
||||
|
|
|
@ -66,11 +66,10 @@
|
|||
#define TYPEOF(type) int
|
||||
#endif
|
||||
#define MSVCRT(x) MSVCRT_##x
|
||||
#define OFFSET(T,F) ((unsigned int)((char *)&((struct T *)0L)->F - (char *)0L))
|
||||
#define CHECK_SIZE(e) ok(sizeof(e) == sizeof(MSVCRT(e)), "Element has different sizes\n")
|
||||
#define CHECK_TYPE(t) { TYPEOF(t) a = 0; TYPEOF(MSVCRT(t)) b = a; a = b; CHECK_SIZE(t); }
|
||||
#define CHECK_STRUCT(s) ok(sizeof(struct s) == sizeof(struct MSVCRT(s)), "Struct has different sizes\n")
|
||||
#define CHECK_FIELD(s,e) ok(OFFSET(s,e) == OFFSET(MSVCRT(s),e), "Bad offset\n")
|
||||
#define CHECK_FIELD(s,e) ok(offsetof(struct s,e) == offsetof(struct MSVCRT(s),e), "Bad offset\n")
|
||||
#define CHECK_DEF(d) ok(d == MSVCRT_##d, "Defines (MSVCRT_)" #d " are different: %d vs. %d\n", d, MSVCRT_##d)
|
||||
|
||||
/************* Checking types ***************/
|
||||
|
|
|
@ -1127,6 +1127,12 @@ static void test_vsnwprintf(void)
|
|||
ok( ret == 11, "got %d expected 11\n", ret );
|
||||
WideCharToMultiByte( CP_ACP, 0, str, -1, buf, sizeof(buf), NULL, NULL );
|
||||
ok( !strcmp(buf, "onetwothree"), "got %s expected 'onetwothree'\n", buf );
|
||||
|
||||
ret = _vsnwprintf_wrapper( str, 0, format, one, two, three );
|
||||
ok( ret == -1, "got %d, expected -1\n", ret );
|
||||
|
||||
ret = _vsnwprintf_wrapper( NULL, 0, format, one, two, three );
|
||||
ok( ret == 11 || broken(ret == -1 /* Win2k */), "got %d, expected 11\n", ret );
|
||||
}
|
||||
|
||||
static int __cdecl vswprintf_wrapper(wchar_t *str, const wchar_t *format, ...)
|
||||
|
|
|
@ -89,7 +89,10 @@ static int (__cdecl *p_tolower)(int);
|
|||
static size_t (__cdecl *p_mbrlen)(const char*, size_t, mbstate_t*);
|
||||
static size_t (__cdecl *p_mbrtowc)(wchar_t*, const char*, size_t, mbstate_t*);
|
||||
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__wcsset_s)(wchar_t*,size_t,wchar_t);
|
||||
|
||||
#define SETNOFAIL(x,y) x = (void*)GetProcAddress(hMsvcrt,y)
|
||||
#define SET(x,y) SETNOFAIL(x,y); ok(x != NULL, "Export '%s' not found\n", y)
|
||||
|
@ -1579,6 +1582,28 @@ static void test__strtod(void)
|
|||
ok(almost_equal(d, 0), "d = %lf\n", d);
|
||||
ok(end == white_chars, "incorrect end (%d)\n", (int)(end-white_chars));
|
||||
|
||||
if (!p__strtod_l)
|
||||
win_skip("_strtod_l not found\n");
|
||||
else
|
||||
{
|
||||
errno = EBADF;
|
||||
d = strtod(NULL, NULL);
|
||||
ok(almost_equal(d, 0.0), "d = %lf\n", d);
|
||||
ok(errno == EINVAL, "errno = %x\n", errno);
|
||||
|
||||
errno = EBADF;
|
||||
end = (char *)0xdeadbeef;
|
||||
d = strtod(NULL, &end);
|
||||
ok(almost_equal(d, 0.0), "d = %lf\n", d);
|
||||
ok(errno == EINVAL, "errno = %x\n", errno);
|
||||
ok(!end, "incorrect end ptr %p\n", end);
|
||||
|
||||
errno = EBADF;
|
||||
d = p__strtod_l(NULL, NULL, NULL);
|
||||
ok(almost_equal(d, 0.0), "d = %lf\n", d);
|
||||
ok(errno == EINVAL, "errno = %x\n", errno);
|
||||
}
|
||||
|
||||
/* Set locale with non '.' decimal point (',') */
|
||||
if(!setlocale(LC_ALL, "Polish")) {
|
||||
win_skip("system with limited locales\n");
|
||||
|
@ -2622,6 +2647,36 @@ static void test_atoi(void)
|
|||
ok(r == 0, "atoi(4294967296) = %d\n", r);
|
||||
}
|
||||
|
||||
static void test_atof(void)
|
||||
{
|
||||
double d;
|
||||
|
||||
d = atof("0.0");
|
||||
ok(almost_equal(d, 0.0), "d = %lf\n", d);
|
||||
|
||||
d = atof("1.0");
|
||||
ok(almost_equal(d, 1.0), "d = %lf\n", d);
|
||||
|
||||
d = atof("-1.0");
|
||||
ok(almost_equal(d, -1.0), "d = %lf\n", d);
|
||||
|
||||
if (!p__atof_l)
|
||||
{
|
||||
win_skip("_atof_l not found\n");
|
||||
return;
|
||||
}
|
||||
|
||||
errno = EBADF;
|
||||
d = atof(NULL);
|
||||
ok(almost_equal(d, 0.0), "d = %lf\n", d);
|
||||
ok(errno == EINVAL, "errno = %x\n", errno);
|
||||
|
||||
errno = EBADF;
|
||||
d = p__atof_l(NULL, NULL);
|
||||
ok(almost_equal(d, 0.0), "d = %lf\n", d);
|
||||
ok(errno == EINVAL, "errno = %x\n", errno);
|
||||
}
|
||||
|
||||
static void test_strncpy(void)
|
||||
{
|
||||
#define TEST_STRNCPY_LEN 10
|
||||
|
@ -2749,6 +2804,40 @@ static void test__strnset_s(void)
|
|||
ok(!buf[0] && buf[1]=='c' && buf[2]=='b', "buf = %s\n", buf);
|
||||
}
|
||||
|
||||
static void test__wcsset_s(void)
|
||||
{
|
||||
wchar_t str[10];
|
||||
int r;
|
||||
|
||||
if(!p__wcsset_s) {
|
||||
win_skip("_wcsset_s not available\n");
|
||||
return;
|
||||
}
|
||||
|
||||
r = p__wcsset_s(NULL, 0, 'a');
|
||||
ok(r == EINVAL, "r = %d\n", r);
|
||||
|
||||
str[0] = 'a';
|
||||
r = p__wcsset_s(str, 0, 'a');
|
||||
ok(r == EINVAL, "r = %d\n", r);
|
||||
ok(str[0] == 'a', "str[0] = %d\n", str[0]);
|
||||
|
||||
str[0] = 'a';
|
||||
str[1] = 'b';
|
||||
r = p__wcsset_s(str, 2, 'c');
|
||||
ok(r == EINVAL, "r = %d\n", r);
|
||||
ok(!str[0], "str[0] = %d\n", str[0]);
|
||||
ok(str[1] == 'b', "str[1] = %d\n", str[1]);
|
||||
|
||||
str[0] = 'a';
|
||||
str[1] = 0;
|
||||
str[2] = 'b';
|
||||
r = p__wcsset_s(str, 3, 'c');
|
||||
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]);
|
||||
}
|
||||
|
||||
START_TEST(string)
|
||||
{
|
||||
char mem[100];
|
||||
|
@ -2796,7 +2885,10 @@ START_TEST(string)
|
|||
p_mbrtowc = (void*)GetProcAddress(hMsvcrt, "mbrtowc");
|
||||
p_mbsrtowcs = (void*)GetProcAddress(hMsvcrt, "mbsrtowcs");
|
||||
p__atodbl_l = (void*)GetProcAddress(hMsvcrt, "_atodbl_l");
|
||||
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__wcsset_s = (void*)GetProcAddress(hMsvcrt, "_wcsset_s");
|
||||
|
||||
/* MSVCRT memcpy behaves like memmove for overlapping moves,
|
||||
MFC42 CString::Insert seems to rely on that behaviour */
|
||||
|
@ -2848,7 +2940,9 @@ START_TEST(string)
|
|||
test__stricmp();
|
||||
test__wcstoi64();
|
||||
test_atoi();
|
||||
test_atof();
|
||||
test_strncpy();
|
||||
test_strxfrm();
|
||||
test__strnset_s();
|
||||
test__wcsset_s();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue