msvcrt: Added _atodbl tests.

This commit is contained in:
Piotr Caban 2012-12-17 15:19:19 +01:00 committed by Alexandre Julliard
parent 3b5ab1b48f
commit 78553db096
2 changed files with 65 additions and 0 deletions

View file

@ -30,6 +30,7 @@
#include <locale.h>
#include <errno.h>
#include <limits.h>
#include <math.h>
static char *buf_to_string(const unsigned char *bin, int len, int nr)
{
@ -89,6 +90,7 @@ static size_t (__cdecl *p_wcrtomb)(char*, wchar_t, mbstate_t*);
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);
#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)
@ -2376,6 +2378,66 @@ static void test_tolower(void)
setlocale(LC_ALL, "C");
}
static void test__atodbl(void)
{
_CRT_DOUBLE d;
char num[32];
int ret;
if(!p__atodbl_l) {
/* Old versions of msvcrt use different values for _OVERFLOW and _UNDERFLOW
* Because of this lets skip _atodbl tests when _atodbl_l is not available */
win_skip("_atodbl_l is not available\n");
return;
}
num[0] = 0;
ret = p__atodbl_l(&d, num, NULL);
ok(ret == 0, "_atodbl_l(&d, \"\", NULL) returned %d, expected 0\n", ret);
ok(d.x == 0, "d.x = %lf, expected 0\n", d.x);
ret = _atodbl(&d, num);
ok(ret == 0, "_atodbl(&d, \"\") returned %d, expected 0\n", ret);
ok(d.x == 0, "d.x = %lf, expected 0\n", d.x);
strcpy(num, "t");
ret = p__atodbl_l(&d, num, NULL);
ok(ret == 0, "_atodbl_l(&d, \"t\", NULL) returned %d, expected 0\n", ret);
ok(d.x == 0, "d.x = %lf, expected 0\n", d.x);
ret = _atodbl(&d, num);
ok(ret == 0, "_atodbl(&d, \"t\") returned %d, expected 0\n", ret);
ok(d.x == 0, "d.x = %lf, expected 0\n", d.x);
strcpy(num, "0");
ret = p__atodbl_l(&d, num, NULL);
ok(ret == 0, "_atodbl_l(&d, \"0\", NULL) returned %d, expected 0\n", ret);
ok(d.x == 0, "d.x = %lf, expected 0\n", d.x);
ret = _atodbl(&d, num);
ok(ret == 0, "_atodbl(&d, \"0\") returned %d, expected 0\n", ret);
ok(d.x == 0, "d.x = %lf, expected 0\n", d.x);
strcpy(num, "123");
ret = p__atodbl_l(&d, num, NULL);
ok(ret == 0, "_atodbl_l(&d, \"123\", NULL) returned %d, expected 0\n", ret);
ok(d.x == 123, "d.x = %lf, expected 123\n", d.x);
ret = _atodbl(&d, num);
ok(ret == 0, "_atodbl(&d, \"123\") returned %d, expected 0\n", ret);
ok(d.x == 123, "d.x = %lf, expected 123\n", d.x);
strcpy(num, "1e-309");
ret = p__atodbl_l(&d, num, NULL);
ok(ret == _UNDERFLOW, "_atodbl_l(&d, \"1e-309\", NULL) returned %d, expected _UNDERFLOW\n", ret);
ok(d.x!=0 && almost_equal(d.x, 0), "d.x = %le, expected 0\n", d.x);
ret = _atodbl(&d, num);
ok(ret == _UNDERFLOW, "_atodbl(&d, \"1e-309\") returned %d, expected _UNDERFLOW\n", ret);
ok(d.x!=0 && almost_equal(d.x, 0), "d.x = %le, expected 0\n", d.x);
strcpy(num, "1e309");
ret = p__atodbl_l(&d, num, NULL);
ok(ret == _OVERFLOW, "_atodbl_l(&d, \"1e309\", NULL) returned %d, expected _OVERFLOW\n", ret);
ret = _atodbl(&d, num);
ok(ret == _OVERFLOW, "_atodbl(&d, \"1e309\") returned %d, expected _OVERFLOW\n", ret);
}
START_TEST(string)
{
char mem[100];
@ -2420,6 +2482,7 @@ START_TEST(string)
p_mbrlen = (void*)GetProcAddress(hMsvcrt, "mbrlen");
p_mbrtowc = (void*)GetProcAddress(hMsvcrt, "mbrtowc");
p_mbsrtowcs = (void*)GetProcAddress(hMsvcrt, "mbsrtowcs");
p__atodbl_l = (void*)GetProcAddress(hMsvcrt, "_atodbl_l");
/* MSVCRT memcpy behaves like memmove for overlapping moves,
MFC42 CString::Insert seems to rely on that behaviour */
@ -2469,4 +2532,5 @@ START_TEST(string)
test_wctob();
test_wctomb();
test_tolower();
test__atodbl();
}

View file

@ -140,6 +140,7 @@ typedef int (__cdecl *_onexit_t)(void);
int __cdecl _atodbl(_CRT_DOUBLE*,char*);
int __cdecl _atodbl_l(_CRT_DOUBLE*,char*,_locale_t);
int __cdecl _atoflt(_CRT_FLOAT*,char*);
int __cdecl _atoflt_l(_CRT_FLOAT*,char*,_locale_t);
__int64 __cdecl _atoi64(const char*);