From 4fe481db95350c381f1c2545745afae52f4cefc0 Mon Sep 17 00:00:00 2001 From: Piotr Caban Date: Thu, 23 Jul 2020 15:38:42 +0200 Subject: [PATCH] msvcrt: Add __STRINGTOLD tests. Signed-off-by: Piotr Caban Signed-off-by: Alexandre Julliard --- dlls/msvcrt/tests/string.c | 60 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/dlls/msvcrt/tests/string.c b/dlls/msvcrt/tests/string.c index ad41ad4d242..8e23f9cffee 100644 --- a/dlls/msvcrt/tests/string.c +++ b/dlls/msvcrt/tests/string.c @@ -115,6 +115,8 @@ static int (__cdecl *p__memicmp)(const char*, const char*, size_t); static int (__cdecl *p__memicmp_l)(const char*, const char*, size_t, _locale_t); static size_t (__cdecl *p___strncnt)(const char*, size_t); +int CDECL __STRINGTOLD(_LDOUBLE*, char**, const char*, int); + #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) @@ -4230,6 +4232,63 @@ static void test_wcscmp(void) ok(!r, "wcscmp returned %d\n", r); } +static const char* debugstr_ldouble(_LDOUBLE *v) +{ + static char buf[2 * ARRAY_SIZE(v->ld) + 1]; + int i; + + for(i=0; ild); i++) + { + buf[2*i] = v->ld[i] / 16 + '0'; + if(buf[2*i] > '9') buf[2*i] -= 10 + '0' - 'a'; + buf[2*i+1] = v->ld[i] % 16 + '0'; + if(buf[2*i+1] > '9') buf[2*i+1] -= 10 + '0' - 'a'; + } + buf[2 * ARRAY_SIZE(v->ld)] = 0; + return buf; +} + +static void test___STRINGTOLD(void) +{ + static const struct { + const char *str; + int endptr; + int r; + _LDOUBLE v; + BOOL todo; + } tests[] = { + { "0", 1 }, + { "nan", 0, 4 }, + { "inf", 0, 4 }, + { "-0.0", 4, 0, {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80 }} }, + { "1e0", 3, 0, {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0x3f }} }, + { "1.7976931348623158e+308", 23, 0, {{ 0xaf, 0xfb, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x43 }} }, + { "1.7976931348623159e+308", 23, 0, {{ 0xb1, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x43 }} }, + { "3.65e-4951", 10, 0, {{ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }} }, + { "1.82e-4951", 10, 0, {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}, TRUE }, + { "1e-99999", 8, 1, {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }} }, + { "1.18e+4932", 10, 0, {{ 0x25, 0x75, 0x06, 0x68, 0x8a, 0xf1, 0xe7, 0xfd, 0xfe, 0x7f }} }, + { "1.19e+4932", 10, 2, {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0x7f }} }, + { "1e+99999", 8, 2, {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0x7f }} }, + }; + + char *endptr; + _LDOUBLE v; + int i, r; + + for(i=0; i