msvcrt/tests: Add additional tests for atof / strtod functions.
From: Michael Müller <michael@fds-team.de>
This commit is contained in:
parent
18d72bd8ca
commit
ffcb4e0724
|
@ -89,6 +89,8 @@ static int (__cdecl *p_tolower)(int);
|
||||||
static size_t (__cdecl *p_mbrlen)(const char*, size_t, mbstate_t*);
|
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 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 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__strnset_s)(char*,size_t,int,size_t);
|
||||||
static int (__cdecl *p__wcsset_s)(wchar_t*,size_t,wchar_t);
|
static int (__cdecl *p__wcsset_s)(wchar_t*,size_t,wchar_t);
|
||||||
|
|
||||||
|
@ -1678,6 +1680,28 @@ static void test__strtod(void)
|
||||||
ok(almost_equal(d, 0), "d = %lf\n", d);
|
ok(almost_equal(d, 0), "d = %lf\n", d);
|
||||||
ok(end == white_chars, "incorrect end (%d)\n", (int)(end-white_chars));
|
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);
|
||||||
|
todo_wine 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 (',') */
|
/* Set locale with non '.' decimal point (',') */
|
||||||
if(!setlocale(LC_ALL, "Polish")) {
|
if(!setlocale(LC_ALL, "Polish")) {
|
||||||
win_skip("system with limited locales\n");
|
win_skip("system with limited locales\n");
|
||||||
|
@ -2721,6 +2745,36 @@ static void test_atoi(void)
|
||||||
ok(r == 0, "atoi(4294967296) = %d\n", r);
|
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)
|
static void test_strncpy(void)
|
||||||
{
|
{
|
||||||
#define TEST_STRNCPY_LEN 10
|
#define TEST_STRNCPY_LEN 10
|
||||||
|
@ -2959,6 +3013,8 @@ START_TEST(string)
|
||||||
p_mbrtowc = (void*)GetProcAddress(hMsvcrt, "mbrtowc");
|
p_mbrtowc = (void*)GetProcAddress(hMsvcrt, "mbrtowc");
|
||||||
p_mbsrtowcs = (void*)GetProcAddress(hMsvcrt, "mbsrtowcs");
|
p_mbsrtowcs = (void*)GetProcAddress(hMsvcrt, "mbsrtowcs");
|
||||||
p__atodbl_l = (void*)GetProcAddress(hMsvcrt, "_atodbl_l");
|
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__strnset_s = (void*)GetProcAddress(hMsvcrt, "_strnset_s");
|
||||||
p__wcsset_s = (void*)GetProcAddress(hMsvcrt, "_wcsset_s");
|
p__wcsset_s = (void*)GetProcAddress(hMsvcrt, "_wcsset_s");
|
||||||
|
|
||||||
|
@ -3015,6 +3071,7 @@ START_TEST(string)
|
||||||
test__stricmp();
|
test__stricmp();
|
||||||
test__wcstoi64();
|
test__wcstoi64();
|
||||||
test_atoi();
|
test_atoi();
|
||||||
|
test_atof();
|
||||||
test_strncpy();
|
test_strncpy();
|
||||||
test_strxfrm();
|
test_strxfrm();
|
||||||
test__strnset_s();
|
test__strnset_s();
|
||||||
|
|
Loading…
Reference in New Issue