Author: akhaldi
Date: Tue May 26 17:15:48 2015
New Revision: 67923
URL:
http://svn.reactos.org/svn/reactos?rev=67923&view=rev
Log:
[MSVCRT_WINETEST] Sync with Wine Staging 1.7.43.
Modified:
trunk/rostests/winetests/msvcrt/misc.c
trunk/rostests/winetests/msvcrt/printf.c
trunk/rostests/winetests/msvcrt/string.c
Modified: trunk/rostests/winetests/msvcrt/misc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/msvcrt/misc.c?r…
==============================================================================
--- trunk/rostests/winetests/msvcrt/misc.c [iso-8859-1] (original)
+++ trunk/rostests/winetests/msvcrt/misc.c [iso-8859-1] Tue May 26 17:15:48 2015
@@ -23,6 +23,26 @@
#include <stdio.h>
#include "msvcrt.h"
+static inline float __port_infinity(void)
+{
+ static const unsigned __inf_bytes = 0x7f800000;
+ return *(const float *)&__inf_bytes;
+}
+#define INFINITY __port_infinity()
+
+static inline float __port_nan(void)
+{
+ static const unsigned __nan_bytes = 0x7fc00000;
+ return *(const float *)&__nan_bytes;
+}
+#define NAN __port_nan()
+
+static inline BOOL almost_equal(double d1, double d2) {
+ if(d1-d2>-1e-30 && d1-d2<1e-30)
+ return TRUE;
+ return FALSE;
+}
+
static int (__cdecl *prand_s)(unsigned int *);
static int (__cdecl *pI10_OUTPUT)(long double, int, int, void*);
static int (__cdecl *pstrerror_s)(char *, MSVCRT_size_t, int);
@@ -34,6 +54,9 @@
const wchar_t*, const wchar_t*, unsigned int, uintptr_t);
static void (__cdecl *p_qsort_s)(void*, MSVCRT_size_t, MSVCRT_size_t,
int (__cdecl*)(void*, const void*, const void*), void*);
+static double (__cdecl *p_atan)(double);
+static double (__cdecl *p_exp)(double);
+static double (__cdecl *p_tanh)(double);
static void init(void)
{
@@ -48,6 +71,9 @@
p_set_errno = (void *)GetProcAddress(hmod, "_set_errno");
p__invalid_parameter = (void *)GetProcAddress(hmod, "_invalid_parameter");
p_qsort_s = (void *)GetProcAddress(hmod, "qsort_s");
+ p_atan = (void *)GetProcAddress(hmod, "atan");
+ p_exp = (void *)GetProcAddress(hmod, "exp");
+ p_tanh = (void *)GetProcAddress(hmod, "tanh");
}
static void test_rand_s(void)
@@ -477,6 +503,42 @@
ok(tab[i] == i, "data sorted incorrectly on position %d: %d\n", i,
tab[i]);
}
+static void test_math_functions(void)
+{
+ double ret;
+
+ errno = 0xdeadbeef;
+ p_atan(NAN);
+ ok(errno == EDOM, "errno = %d\n", errno);
+
+ errno = 0xdeadbeef;
+ ret = p_atan(INFINITY);
+ ok(almost_equal(ret, 1.57079632679489661923), "ret = %lf\n", ret);
+ ok(errno == 0xdeadbeef, "errno = %d\n", errno);
+
+ errno = 0xdeadbeef;
+ ret = p_atan(-INFINITY);
+ ok(almost_equal(ret, -1.57079632679489661923), "ret = %lf\n", ret);
+ ok(errno == 0xdeadbeef, "errno = %d\n", errno);
+
+ errno = 0xdeadbeef;
+ p_tanh(NAN);
+ ok(errno == EDOM, "errno = %d\n", errno);
+
+ errno = 0xdeadbeef;
+ ret = p_tanh(INFINITY);
+ ok(almost_equal(ret, 1.0), "ret = %lf\n", ret);
+ ok(errno == 0xdeadbeef, "errno = %d\n", errno);
+
+ errno = 0xdeadbeef;
+ p_exp(NAN);
+ ok(errno == EDOM, "errno = %d\n", errno);
+
+ errno = 0xdeadbeef;
+ p_exp(INFINITY);
+ ok(errno == 0xdeadbeef, "errno = %d\n", errno);
+}
+
START_TEST(misc)
{
int arg_c;
@@ -504,4 +566,5 @@
test__popen(arg_v[0]);
test__invalid_parameter();
test_qsort_s();
-}
+ test_math_functions();
+}
Modified: trunk/rostests/winetests/msvcrt/printf.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/msvcrt/printf.c…
==============================================================================
--- trunk/rostests/winetests/msvcrt/printf.c [iso-8859-1] (original)
+++ trunk/rostests/winetests/msvcrt/printf.c [iso-8859-1] Tue May 26 17:15:48 2015
@@ -27,13 +27,33 @@
#include <stdio.h>
#include <errno.h>
-#include <math.h>
#include "windef.h"
#include "winbase.h"
#include "winnls.h"
#include "wine/test.h"
+
+static inline float __port_infinity(void)
+{
+ static const unsigned __inf_bytes = 0x7f800000;
+ return *(const float *)&__inf_bytes;
+}
+#define INFINITY __port_infinity()
+
+static inline float __port_nan(void)
+{
+ static const unsigned __nan_bytes = 0x7fc00000;
+ return *(const float *)&__nan_bytes;
+}
+#define NAN __port_nan()
+
+static inline float __port_ind(void)
+{
+ static const unsigned __ind_bytes = 0xffc00000;
+ return *(const float *)&__ind_bytes;
+}
+#define IND __port_ind()
static int (__cdecl *p__vscprintf)(const char *format, __ms_va_list valist);
static int (__cdecl *p__vscwprintf)(const wchar_t *format, __ms_va_list valist);
@@ -82,7 +102,7 @@
{
char buffer[100];
const char *format;
- double pnumber=789456123, inf, nan;
+ double pnumber=789456123;
int x, r;
WCHAR wide[] = { 'w','i','d','e',0};
@@ -675,38 +695,47 @@
r = sprintf(buffer, format, 0x12345);
ok(!strcmp(buffer,"2345"), "failed \"%s\"\n", buffer);
- nan = 0.0;
- inf = 1.0/nan;
- nan = sqrt(-1);
format = "%lf";
- r = sprintf(buffer, format, nan);
+ r = sprintf(buffer, format, IND);
ok(r==9, "r = %d\n", r);
ok(!strcmp(buffer, "-1.#IND00"), "failed: \"%s\"\n",
buffer);
- r = sprintf(buffer, format, inf);
+ r = 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);
ok(r==8, "r = %d\n", r);
ok(!strcmp(buffer, "1.#INF00"), "failed: \"%s\"\n",
buffer);
format = "%le";
- r = sprintf(buffer, format, nan);
+ r = 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, inf);
+ r = 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);
ok(r==13, "r = %d\n", r);
ok(!strcmp(buffer, "1.#INF00e+000"), "failed:
\"%s\"\n", buffer);
format = "%lg";
- r = sprintf(buffer, format, nan);
+ r = sprintf(buffer, format, IND);
ok(r==7, "r = %d\n", r);
ok(!strcmp(buffer, "-1.#IND"), "failed: \"%s\"\n",
buffer);
- r = sprintf(buffer, format, inf);
+ r = 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);
ok(r==6, "r = %d\n", r);
ok(!strcmp(buffer, "1.#INF"), "failed: \"%s\"\n",
buffer);
format = "%010.2lf";
- r = sprintf(buffer, format, nan);
+ r = sprintf(buffer, format, IND);
ok(r==10, "r = %d\n", r);
ok(!strcmp(buffer, "-000001.#J"), "failed: \"%s\"\n",
buffer);
- r = sprintf(buffer, format, inf);
+ r = 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);
ok(r==10, "r = %d\n", r);
ok(!strcmp(buffer, "0000001.#J"), "failed: \"%s\"\n",
buffer);
}
Modified: trunk/rostests/winetests/msvcrt/string.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/msvcrt/string.c…
==============================================================================
--- trunk/rostests/winetests/msvcrt/string.c [iso-8859-1] (original)
+++ trunk/rostests/winetests/msvcrt/string.c [iso-8859-1] Tue May 26 17:15:48 2015
@@ -1144,6 +1144,65 @@
_setmbcp(prev_cp);
}
+static void test_mbctohira(void)
+{
+ static const unsigned int mbchira_932[][2] = {
+ {0x8152, 0x8152}, {0x8153, 0x8153}, {0x8154, 0x8154}, {0x8155, 0x8155},
+ {0x82a0, 0x82a0}, {0x833f, 0x833f}, {0x8340, 0x829f}, {0x837e, 0x82dd},
+ {0x837f, 0x837f}, {0x8380, 0x82de}, {0x8393, 0x82f1}, {0x8394, 0x8394},
+ {0x8396, 0x8396}, {0x8397, 0x8397},
+ {0xa5, 0xa5}, {0xb0, 0xb0}, {0xdd, 0xdd} };
+ unsigned int i;
+ unsigned int prev_cp = _getmbcp();
+
+ _setmbcp(_MB_CP_SBCS);
+ for (i = 0; i < sizeof(mbchira_932)/sizeof(mbchira_932[0]); i++)
+ {
+ int ret, exp = mbchira_932[i][0];
+ ret = _mbctohira(mbchira_932[i][0]);
+ ok(ret == exp, "Expected 0x%x, got 0x%x\n", exp, ret);
+ }
+
+ _setmbcp(932);
+ for (i = 0; i < sizeof(mbchira_932)/sizeof(mbchira_932[0]); i++)
+ {
+ unsigned int ret, exp;
+ ret = _mbctohira(mbchira_932[i][0]);
+ exp = mbchira_932[i][1];
+ ok(ret == exp, "Expected 0x%x, got 0x%x\n", exp, ret);
+ }
+ _setmbcp(prev_cp);
+}
+
+static void test_mbctokata(void)
+{
+ static const unsigned int mbckata_932[][2] = {
+ {0x8152, 0x8152}, {0x8153, 0x8153}, {0x8154, 0x8154}, {0x8155, 0x8155},
+ {0x833f, 0x833f}, {0x829f, 0x8340}, {0x82dd, 0x837e}, {0x837f, 0x837f},
+ {0x82de, 0x8380}, {0x8394, 0x8394}, {0x8397, 0x8397},
+ {0xa5, 0xa5}, {0xb0, 0xb0}, {0xdd, 0xdd} };
+ unsigned int i;
+ unsigned int prev_cp = _getmbcp();
+
+ _setmbcp(_MB_CP_SBCS);
+ for (i = 0; i < sizeof(mbckata_932)/sizeof(mbckata_932[0]); i++)
+ {
+ int ret, exp = mbckata_932[i][0];
+ ret = _mbctokata(mbckata_932[i][0]);
+ ok(ret == exp, "Expected 0x%x, got 0x%x\n", exp, ret);
+ }
+
+ _setmbcp(932);
+ for (i = 0; i < sizeof(mbckata_932)/sizeof(mbckata_932[0]); i++)
+ {
+ unsigned int ret, exp;
+ ret = _mbctokata(mbckata_932[i][0]);
+ exp = mbckata_932[i][1];
+ ok(ret == exp, "Expected 0x%x, got 0x%x\n", exp, ret);
+ }
+ _setmbcp(prev_cp);
+}
+
static void test_mbbtombc(void)
{
static const unsigned int mbbmbc[][2] = {
@@ -1189,6 +1248,37 @@
exp = mbcmbb_932[i][1];
ok(ret == exp, "Expected 0x%x, got 0x%x\n", exp, ret);
}
+ _setmbcp(prev_cp);
+}
+
+static void test_ismbckata(void) {
+ struct katakana_pair {
+ UINT c;
+ BOOL exp;
+ };
+ static const struct katakana_pair tests[] = {
+ {0x8152, FALSE}, {0x8153, FALSE}, {0x8154, FALSE}, {0x8155, FALSE},
+ {0x82a0, FALSE}, {0x833f, FALSE}, {0x8340, TRUE }, {0x837e, TRUE },
+ {0x837f, FALSE}, {0x8380, TRUE }, {0x8396, TRUE }, {0x8397, FALSE},
+ {0xa5, FALSE}, {0xb0, FALSE}, {0xdd, FALSE}
+ };
+ unsigned int prev_cp = _getmbcp();
+ int ret;
+ unsigned int i;
+
+ _setmbcp(_MB_CP_SBCS);
+ for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++) {
+ ret = _ismbckata(tests[i].c);
+ ok(!ret, "expected 0, got %d for %04x\n", ret, tests[i].c);
+ }
+
+ _setmbcp(932);
+ for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++) {
+ ret = _ismbckata(tests[i].c);
+ ok(!!ret == tests[i].exp, "expected %d, got %d for %04x\n",
+ tests[i].exp, !!ret, tests[i].c);
+ }
+
_setmbcp(prev_cp);
}
@@ -2836,6 +2926,36 @@
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]);
+}
+
+static void test__mbscmp(void)
+{
+ static const unsigned char a[] = {'a',0}, b[] = {'b',0};
+ int ret;
+
+ if (!p_mbrlen)
+ {
+ win_skip("_mbscmp tests\n");
+ return;
+ }
+
+ ret = _mbscmp(NULL, NULL);
+ ok(ret == INT_MAX, "got %d\n", ret);
+
+ ret = _mbscmp(a, NULL);
+ ok(ret == INT_MAX, "got %d\n", ret);
+
+ ret = _mbscmp(NULL, a);
+ ok(ret == INT_MAX, "got %d\n", ret);
+
+ ret = _mbscmp(a, a);
+ ok(!ret, "got %d\n", ret);
+
+ ret = _mbscmp(a, b);
+ ok(ret == -1, "got %d\n", ret);
+
+ ret = _mbscmp(b, a);
+ ok(ret == 1, "got %d\n", ret);
}
START_TEST(string)
@@ -2913,8 +3033,11 @@
test__mbscpy_s();
test_mbcjisjms();
test_mbcjmsjis();
+ test_mbctohira();
+ test_mbctokata();
test_mbbtombc();
test_mbctombb();
+ test_ismbckata();
test_ismbclegal();
test_strtok();
test__mbstok();
@@ -2945,4 +3068,5 @@
test_strxfrm();
test__strnset_s();
test__wcsset_s();
-}
+ test__mbscmp();
+}