Commit 25571d87 authored by Alexandre Julliard's avatar Alexandre Julliard

oleaut32/tests: Replace some macros by functions to reduce code size and compile time.

parent 11e7b64e
...@@ -219,6 +219,134 @@ static const char *vtstr(int x) ...@@ -219,6 +219,134 @@ static const char *vtstr(int x)
} }
} }
static BOOL is_expected_variant( const VARIANT *result, const VARIANT *expected )
{
if (V_VT(result) != V_VT(expected)) return FALSE;
switch(V_VT(expected))
{
case VT_EMPTY:
case VT_NULL:
return TRUE;
#define CASE(vt) case VT_##vt: return (V_##vt(result) == V_##vt(expected))
CASE(BOOL);
CASE(I1);
CASE(UI1);
CASE(I2);
CASE(UI2);
CASE(I4);
CASE(UI4);
CASE(I8);
CASE(UI8);
CASE(INT);
CASE(UINT);
#undef CASE
case VT_DATE:
return EQ_FLOAT(V_DATE(result), V_DATE(expected));
case VT_R4:
return EQ_FLOAT(V_R4(result), V_R4(expected));
case VT_R8:
return EQ_FLOAT(V_R8(result), V_R8(expected));
case VT_CY:
return (V_CY(result).int64 == V_CY(expected).int64);
case VT_BSTR:
return !lstrcmpW( V_BSTR(result), V_BSTR(expected) );
case VT_DECIMAL:
return !memcmp( &V_DECIMAL(result), &V_DECIMAL(expected), sizeof(DECIMAL) );
default:
ok(0, "unhandled variant type %s\n",vtstr(V_VT(expected)));
return 0;
}
}
static const char *variantstr( const VARIANT *var )
{
static char buffer[16][256];
static int current;
current %= 16;
switch(V_VT(var))
{
case VT_EMPTY:
return "VT_EMPTY";
case VT_NULL:
return "VT_NULL";
case VT_VOID:
return "VT_VOID";
case VT_UNKNOWN:
return "VT_UNKNOWN";
case VT_I1:
sprintf( buffer[current], "VT_I1(%d)", V_I1(var) ); break;
case VT_I2:
sprintf( buffer[current], "VT_I2(%d)", V_I2(var) ); break;
case VT_I4:
sprintf( buffer[current], "VT_I4(%d)", V_I4(var) ); break;
case VT_INT:
sprintf( buffer[current], "VT_INT(%d)", V_INT(var) ); break;
case VT_I8:
sprintf( buffer[current], "VT_I8(%x%08x)", (UINT)(V_I8(var) >> 32), (UINT)V_I8(var) ); break;
case VT_UI8:
sprintf( buffer[current], "VT_UI8(%x%08x)", (UINT)(V_UI8(var) >> 32), (UINT)V_UI8(var) ); break;
case VT_R4:
sprintf( buffer[current], "VT_R4(%g)", V_R4(var) ); break;
case VT_R8:
sprintf( buffer[current], "VT_R8(%g)", V_R8(var) ); break;
case VT_UI1:
sprintf( buffer[current], "VT_UI1(%u)", V_UI1(var) ); break;
case VT_UI2:
sprintf( buffer[current], "VT_UI2(%u)", V_UI2(var) ); break;
case VT_UI4:
sprintf( buffer[current], "VT_UI4(%u)", V_UI4(var) ); break;
case VT_UINT:
sprintf( buffer[current], "VT_UINT(%d)", V_UINT(var) ); break;
case VT_CY:
sprintf( buffer[current], "VT_CY(%x%08x)", V_CY(var).Hi, V_CY(var).Lo ); break;
case VT_DATE:
sprintf( buffer[current], "VT_DATE(%g)", V_DATE(var) ); break;
default:
return vtstr(V_VT(var));
}
return buffer[current++];
}
static void test_var_call1( int line, HRESULT (WINAPI *func)(LPVARIANT,LPVARIANT),
VARIANT *arg, VARIANT *expected )
{
VARIANT old_arg = *arg;
VARIANT result;
HRESULT hres;
memset( &result, 0, sizeof(result) );
hres = func( arg, &result );
ok_(__FILE__,line)( hres == S_OK, "wrong result %x\n", hres );
if (hres == S_OK)
ok_(__FILE__,line)( is_expected_variant( &result, expected ),
"got %s expected %s\n", variantstr(&result), variantstr(expected) );
ok_(__FILE__,line)( is_expected_variant( arg, &old_arg ), "Modified argument %s / %s\n",
variantstr(&old_arg), variantstr(arg));
}
static void test_var_call2( int line, HRESULT (WINAPI *func)(LPVARIANT,LPVARIANT,LPVARIANT),
VARIANT *left, VARIANT *right, VARIANT *expected )
{
VARIANT old_left = *left, old_right = *right;
VARIANT result;
HRESULT hres;
memset( &result, 0, sizeof(result) );
hres = func( left, right, &result );
ok_(__FILE__,line)( hres == S_OK, "wrong result %x\n", hres );
if (hres == S_OK)
ok_(__FILE__,line)( is_expected_variant( &result, expected ),
"got %s expected %s\n", variantstr(&result), variantstr(expected) );
ok_(__FILE__,line)( is_expected_variant( left, &old_left ), "Modified left argument %s / %s\n",
variantstr(&old_left), variantstr(left));
ok_(__FILE__,line)( is_expected_variant( right, &old_right ), "Modified right argument %s / %s\n",
variantstr(&old_right), variantstr(right));
}
static void test_VariantInit(void) static void test_VariantInit(void)
{ {
VARIANTARG v1, v2; VARIANTARG v1, v2;
...@@ -758,19 +886,36 @@ static HRESULT (WINAPI *pVarParseNumFromStr)(OLECHAR*,LCID,ULONG,NUMPARSE*,BYTE* ...@@ -758,19 +886,36 @@ static HRESULT (WINAPI *pVarParseNumFromStr)(OLECHAR*,LCID,ULONG,NUMPARSE*,BYTE*
/* Macros for converting and testing the result of VarParseNumFromStr */ /* Macros for converting and testing the result of VarParseNumFromStr */
#define FAILDIG 255 #define FAILDIG 255
#define CONVERTN(str,dig,flags) MultiByteToWideChar(CP_ACP,0,str,-1,buff,sizeof(buff)/sizeof(WCHAR)); \
memset(rgb, FAILDIG, sizeof(rgb)); memset(&np,-1,sizeof(np)); np.cDig = dig; np.dwInFlags = flags; \ static HRESULT convert_str( const char *str, INT dig, ULONG flags,
hres = pVarParseNumFromStr(buff,lcid,LOCALE_NOUSEROVERRIDE,&np,rgb) NUMPARSE *np, BYTE rgb[128], LCID lcid )
{
OLECHAR buff[128];
MultiByteToWideChar( CP_ACP,0, str, -1, buff, sizeof(buff)/sizeof(WCHAR) );
memset( rgb, FAILDIG, 128 );
memset( np, 255, sizeof(*np) );
np->cDig = dig;
np->dwInFlags = flags;
return pVarParseNumFromStr( buff, lcid, LOCALE_NOUSEROVERRIDE, np, rgb);
}
static void expect_NumFromStr( int line, HRESULT hres, NUMPARSE *np, INT a, ULONG b, ULONG c,
INT d, INT e, INT f )
{
if (hres == (HRESULT)S_OK)
{
ok_(__FILE__,line)(np->cDig == a, "Expected cDig = %d, got %d\n", a, np->cDig);
ok_(__FILE__,line)(np->dwInFlags == b, "Expected dwInFlags = 0x%x, got 0x%x\n", b, np->dwInFlags);
ok_(__FILE__,line)(np->dwOutFlags == c, "Expected dwOutFlags = 0x%x, got 0x%x\n", c, np->dwOutFlags);
ok_(__FILE__,line)(np->cchUsed == d, "Expected cchUsed = %d, got %d\n", d, np->cchUsed);
ok_(__FILE__,line)(np->nBaseShift == e, "Expected nBaseShift = %d, got %d\n", e, np->nBaseShift);
ok_(__FILE__,line)(np->nPwr10 == f, "Expected nPwr10 = %d, got %d\n", f, np->nPwr10);
}
}
#define CONVERTN(str,dig,flags) hres = convert_str( str, dig, flags, &np, rgb, lcid )
#define CONVERT(str,flags) CONVERTN(str,sizeof(rgb),flags) #define CONVERT(str,flags) CONVERTN(str,sizeof(rgb),flags)
#define EXPECT(a,b,c,d,e,f) ok(hres == (HRESULT)S_OK, "Call failed, hres = %08x\n", hres); \ #define EXPECT(a,b,c,d,e,f) expect_NumFromStr( __LINE__, hres, &np, a, b, c, d, e, f )
if (hres == (HRESULT)S_OK) { \
ok(np.cDig == (a), "Expected cDig = %d, got %d\n", (a), np.cDig); \
ok(np.dwInFlags == (b), "Expected dwInFlags = 0x%x, got 0x%x\n", (ULONG)(b), np.dwInFlags); \
ok(np.dwOutFlags == (c), "Expected dwOutFlags = 0x%x, got 0x%x\n", (ULONG)(c), np.dwOutFlags); \
ok(np.cchUsed == (d), "Expected cchUsed = %d, got %d\n", (d), np.cchUsed); \
ok(np.nBaseShift == (e), "Expected nBaseShift = %d, got %d\n", (e), np.nBaseShift); \
ok(np.nPwr10 == (f), "Expected nPwr10 = %d, got %d\n", (f), np.nPwr10); \
}
#define EXPECTRGB(a,b) ok(rgb[a] == b, "Digit[%d], expected %d, got %d\n", a, b, rgb[a]) #define EXPECTRGB(a,b) ok(rgb[a] == b, "Digit[%d], expected %d, got %d\n", a, b, rgb[a])
#define EXPECTFAIL ok(hres == (HRESULT)DISP_E_TYPEMISMATCH, "Call succeeded, hres = %08x\n", hres) #define EXPECTFAIL ok(hres == (HRESULT)DISP_E_TYPEMISMATCH, "Call succeeded, hres = %08x\n", hres)
#define EXPECT2(a,b) EXPECTRGB(0,a); EXPECTRGB(1,b) #define EXPECT2(a,b) EXPECTRGB(0,a); EXPECTRGB(1,b)
...@@ -778,7 +923,6 @@ static HRESULT (WINAPI *pVarParseNumFromStr)(OLECHAR*,LCID,ULONG,NUMPARSE*,BYTE* ...@@ -778,7 +923,6 @@ static HRESULT (WINAPI *pVarParseNumFromStr)(OLECHAR*,LCID,ULONG,NUMPARSE*,BYTE*
static void test_VarParseNumFromStr(void) static void test_VarParseNumFromStr(void)
{ {
HRESULT hres; HRESULT hres;
OLECHAR buff[128];
/* Ensure all tests are using the same locale characters for '$', ',' etc */ /* Ensure all tests are using the same locale characters for '$', ',' etc */
LCID lcid = MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT); LCID lcid = MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT);
NUMPARSE np; NUMPARSE np;
...@@ -1413,23 +1557,29 @@ static void test_VarNumFromParseNum(void) ...@@ -1413,23 +1557,29 @@ static void test_VarNumFromParseNum(void)
SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_CY|VTBIT_DECIMAL); EXPECT_CY(1); SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_CY|VTBIT_DECIMAL); EXPECT_CY(1);
} }
static const char* szUdateFromDateFail = "%.16g expected %x, %d,%d,%d,%d,%d,%d,%d %d %d"
", got %x, %d,%d,%d,%d,%d,%d,%d %d %d\n";
#define DT2UD(dt,flags,r,d,m,y,h,mn,s,ms,dw,dy) \
memset(&ud, 0, sizeof(ud)); \
res = pVarUdateFromDate(dt, flags, &ud); \
ok(r == res && (FAILED(r) || (ud.st.wYear == y && ud.st.wMonth == m && ud.st.wDay == d && \
ud.st.wHour == h && ud.st.wMinute == mn && ud.st.wSecond == s && \
ud.st.wMilliseconds == ms && ud.st.wDayOfWeek == dw && ud.wDayOfYear == dy)), \
szUdateFromDateFail, dt, r, d, m, y, h, mn, s, ms, dw, dy, res, ud.st.wDay, ud.st.wMonth, \
ud.st.wYear, ud.st.wHour, ud.st.wMinute, ud.st.wSecond, \
ud.st.wMilliseconds, ud.st.wDayOfWeek, ud.wDayOfYear)
static void test_VarUdateFromDate(void) static void test_UdateFromDate( int line, DATE dt, ULONG flags, HRESULT r, WORD d, WORD m, WORD y,
WORD h, WORD mn, WORD s, WORD ms, WORD dw, WORD dy)
{ {
UDATE ud; UDATE ud;
HRESULT res; HRESULT res;
memset(&ud, 0, sizeof(ud));
res = pVarUdateFromDate(dt, flags, &ud);
ok_(__FILE__,line)(r == res, "Wrong result %x/%x\n", r, res);
if (SUCCEEDED(res))
ok_(__FILE__,line)(ud.st.wYear == y && ud.st.wMonth == m && ud.st.wDay == d &&
ud.st.wHour == h && ud.st.wMinute == mn && ud.st.wSecond == s &&
ud.st.wMilliseconds == ms && ud.st.wDayOfWeek == dw && ud.wDayOfYear == dy,
"%.16g expected %d,%d,%d,%d,%d,%d,%d %d %d, got %d,%d,%d,%d,%d,%d,%d %d %d\n",
dt, d, m, y, h, mn, s, ms, dw, dy,
ud.st.wDay, ud.st.wMonth, ud.st.wYear, ud.st.wHour, ud.st.wMinute,
ud.st.wSecond, ud.st.wMilliseconds, ud.st.wDayOfWeek, ud.wDayOfYear );
}
#define DT2UD(dt,flags,r,d,m,y,h,mn,s,ms,dw,dy) test_UdateFromDate(__LINE__,dt,flags,r,d,m,y,h,mn,s,ms,dw,dy)
static void test_VarUdateFromDate(void)
{
CHECKPTR(VarUdateFromDate); CHECKPTR(VarUdateFromDate);
DT2UD(29221.0,0,S_OK,1,1,1980,0,0,0,0,2,1); /* 1 Jan 1980 */ DT2UD(29221.0,0,S_OK,1,1,1980,0,0,0,0,2,1); /* 1 Jan 1980 */
DT2UD(29222.0,0,S_OK,2,1,1980,0,0,0,0,3,2); /* 2 Jan 1980 */ DT2UD(29222.0,0,S_OK,2,1,1980,0,0,0,0,3,2); /* 2 Jan 1980 */
...@@ -1452,20 +1602,31 @@ static void test_VarUdateFromDate(void) ...@@ -1452,20 +1602,31 @@ static void test_VarUdateFromDate(void)
DT2UD(29221.7508765432,0,S_OK,1,1,1980,18,1,16,0,2,1); /* 6:18:02 PM */ DT2UD(29221.7508765432,0,S_OK,1,1,1980,18,1,16,0,2,1); /* 6:18:02 PM */
} }
#define UD2T(d,m,y,h,mn,s,ms,dw,dy,flags,r,dt) \
ud.st.wYear = (y); ud.st.wMonth = (m); ud.st.wDay = (d); ud.st.wHour = (h); \
ud.st.wMinute = (mn); ud.st.wSecond = (s); ud.st.wMilliseconds = (ms); \
ud.st.wDayOfWeek = (dw); ud.wDayOfYear = (dy); \
res = pVarDateFromUdate(&ud, (flags), &out); \
ok((r) == res && (FAILED(r) || fabs(out-(dt)) < 1.0e-11), \
"expected %x, %.16g, got %x, %.16g\n", r, dt, res, out)
static void test_VarDateFromUdate(void) static void test_DateFromUDate( int line, WORD d, WORD m, WORD y, WORD h, WORD mn, WORD s, WORD ms,
WORD dw, WORD dy, ULONG flags, HRESULT r, DATE dt )
{ {
UDATE ud; UDATE ud;
double out; double out;
HRESULT res; HRESULT res;
ud.st.wYear = (y);
ud.st.wMonth = (m);
ud.st.wDay = (d);
ud.st.wHour = (h);
ud.st.wMinute = (mn);
ud.st.wSecond = (s);
ud.st.wMilliseconds = (ms);
ud.st.wDayOfWeek = (dw);
ud.wDayOfYear = (dy);
res = pVarDateFromUdate(&ud, flags, &out);
ok_(__FILE__,line)((r) == res && (FAILED(r) || fabs(out-(dt)) < 1.0e-11),
"expected %x, %.16g, got %x, %.16g\n", r, dt, res, out);
}
#define UD2T(d,m,y,h,mn,s,ms,dw,dy,flags,r,dt) test_DateFromUDate(__LINE__,d,m,y,h,mn,s,ms,dw,dy,flags,r,dt)
static void test_VarDateFromUdate(void)
{
CHECKPTR(VarDateFromUdate); CHECKPTR(VarDateFromUdate);
UD2T(1,1,1980,0,0,0,0,2,1,0,S_OK,29221.0); /* 1 Jan 1980 */ UD2T(1,1,1980,0,0,0,0,2,1,0,S_OK,29221.0); /* 1 Jan 1980 */
UD2T(2,1,1980,0,0,0,0,3,2,0,S_OK,29222.0); /* 2 Jan 1980 */ UD2T(2,1,1980,0,0,0,0,3,2,0,S_OK,29222.0); /* 2 Jan 1980 */
...@@ -1601,19 +1762,17 @@ static void test_VariantTimeToDosDateTime(void) ...@@ -1601,19 +1762,17 @@ static void test_VariantTimeToDosDateTime(void)
static HRESULT (WINAPI *pVarAbs)(LPVARIANT,LPVARIANT); static HRESULT (WINAPI *pVarAbs)(LPVARIANT,LPVARIANT);
static const char *szVarAbsFail = "VarAbs: expected 0x0,%d,%d, got 0x%X,%d,%d\n"; #define VARABS(vt,val,rvt,rval) \
#define VARABS(vt,val,rvt,rval) V_VT(&v) = VT_##vt; V_##vt(&v) = val; \ V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
memset(&vDst,0,sizeof(vDst)); hres = pVarAbs(&v,&vDst); \ V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
ok(hres == S_OK && V_VT(&vDst) == VT_##rvt && V_##rvt(&vDst) == (rval), \ test_var_call1( __LINE__, pVarAbs, &v, &exp );
szVarAbsFail, VT_##rvt, (int)(rval), \
hres, V_VT(&vDst), (int)V_##rvt(&vDst))
static void test_VarAbs(void) static void test_VarAbs(void)
{ {
static const WCHAR szNum[] = {'-','1','.','1','\0' }; static const WCHAR szNum[] = {'-','1','.','1','\0' };
char buff[8]; char buff[8];
HRESULT hres; HRESULT hres;
VARIANT v, vDst; VARIANT v, vDst, exp;
size_t i; size_t i;
CHECKPTR(VarAbs); CHECKPTR(VarAbs);
...@@ -1699,19 +1858,17 @@ static void test_VarAbs(void) ...@@ -1699,19 +1858,17 @@ static void test_VarAbs(void)
static HRESULT (WINAPI *pVarNot)(LPVARIANT,LPVARIANT); static HRESULT (WINAPI *pVarNot)(LPVARIANT,LPVARIANT);
static const char *szVarNotFail = "VarNot: expected 0x0,%d,%d, got 0x%X,%d,%d\n"; #define VARNOT(vt,val,rvt,rval) \
#define VARNOT(vt,val,rvt,rval) V_VT(&v) = VT_##vt; V_##vt(&v) = val; \ V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
memset(&vDst,0,sizeof(vDst)); hres = pVarNot(&v,&vDst); \ V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
ok(hres == S_OK && V_VT(&vDst) == VT_##rvt && V_##rvt(&vDst) == (rval), \ test_var_call1( __LINE__, pVarNot, &v, &exp );
szVarNotFail, VT_##rvt, (int)(rval), \
hres, V_VT(&vDst), (int)V_##rvt(&vDst))
static void test_VarNot(void) static void test_VarNot(void)
{ {
static const WCHAR szNum0[] = {'0','\0' }; static const WCHAR szNum0[] = {'0','\0' };
static const WCHAR szNum1[] = {'1','\0' }; static const WCHAR szNum1[] = {'1','\0' };
HRESULT hres; HRESULT hres;
VARIANT v, vDst; VARIANT v, exp, vDst;
DECIMAL *pdec = &V_DECIMAL(&v); DECIMAL *pdec = &V_DECIMAL(&v);
CY *pcy = &V_CY(&v); CY *pcy = &V_CY(&v);
size_t i; size_t i;
...@@ -1826,27 +1983,16 @@ static void test_VarNot(void) ...@@ -1826,27 +1983,16 @@ static void test_VarNot(void)
static HRESULT (WINAPI *pVarSub)(LPVARIANT,LPVARIANT,LPVARIANT); static HRESULT (WINAPI *pVarSub)(LPVARIANT,LPVARIANT,LPVARIANT);
static const char *szVarSubI4 = "VarSub(%d,%d): expected 0x0,%d,%d, got 0x%X,%d,%d\n"; #define VARSUB(vt1,val1,vt2,val2,rvt,rval) \
static const char *szVarSubR8 = "VarSub(%d,%d): expected 0x0,%d,%f, got 0x%X,%d,%f\n"; V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
#define VARSUB(vt1,val1,vt2,val2,rvt,rval) \
V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \ V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
memset(&result,0,sizeof(result)); hres = pVarSub(&left,&right,&result); \ V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
if (VT_##rvt == VT_R4 || VT_##rvt == VT_R8 || VT_##rvt == VT_DATE) { \ test_var_call2( __LINE__, pVarSub, &left, &right, &exp );
ok(hres == S_OK && V_VT(&result) == VT_##rvt && \
EQ_FLOAT(V_##rvt(&result), rval), \
szVarSubR8, VT_##vt1, VT_##vt2, \
VT_##rvt, (double)(rval), hres, V_VT(&result), (double)V_##rvt(&result)); \
} else { \
ok(hres == S_OK && V_VT(&result) == VT_##rvt && V_##rvt(&result) == (rval), \
szVarSubI4, VT_##vt1, VT_##vt2, \
VT_##rvt, (int)(rval), hres, V_VT(&result), (int)V_##rvt(&result)); }
static void test_VarSub(void) static void test_VarSub(void)
{ {
static const WCHAR sz12[] = {'1','2','\0'}; static const WCHAR sz12[] = {'1','2','\0'};
VARIANT left, right, result, cy, dec; VARIANT left, right, exp, result, cy, dec;
VARTYPE i; VARTYPE i;
BSTR lbstr, rbstr; BSTR lbstr, rbstr;
HRESULT hres, expectedhres; HRESULT hres, expectedhres;
...@@ -2064,27 +2210,36 @@ static void test_VarSub(void) ...@@ -2064,27 +2210,36 @@ static void test_VarSub(void)
SysFreeString(rbstr); SysFreeString(rbstr);
} }
static const char *szVarModFail = "VarMod: expected 0x%x,%d(%s),%d, got 0x%X,%d(%s),%d\n";
#define VARMOD(vt1,vt2,val1,val2,rvt,rval,hexpected) V_VT(&v1) = VT_##vt1; V_##vt1(&v1) = val1; \
V_VT(&v2) = VT_##vt2; V_##vt2(&v2) = val2; \
memset(&vDst,0,sizeof(vDst)); hres = pVarMod(&v1,&v2,&vDst); \
ok(hres == hexpected && V_VT(&vDst) == VT_##rvt && V_##rvt(&vDst) == (rval), \
szVarModFail, hexpected, VT_##rvt, vtstr(VT_##rvt), (int)(rval), \
hres, V_VT(&vDst), vtstr(V_VT(&vDst)), (int)V_##rvt(&vDst))
static const char *szVarMod2Fail = "VarMod: expected 0x%x,%d(%s),%d, got 0x%X,%d(%s),%d\n";
#define VARMOD2(vt1,vt2,val1,val2,rvt,rval,hexpected) V_VT(&v1) = VT_##vt1; V_I4(&v1) = val1; \
V_VT(&v2) = VT_##vt2; V_I4(&v2) = val2; \
memset(&vDst,0,sizeof(vDst)); hres = pVarMod(&v1,&v2,&vDst); \
ok(hres == hexpected && V_VT(&vDst) == VT_##rvt && V_I4(&vDst) == (rval), \
szVarMod2Fail, hexpected, VT_##rvt, vtstr(VT_##rvt), (int)(rval), \
hres, V_VT(&vDst), vtstr(V_VT(&vDst)), (int)V_I4(&vDst))
static HRESULT (WINAPI *pVarMod)(LPVARIANT,LPVARIANT,LPVARIANT); static HRESULT (WINAPI *pVarMod)(LPVARIANT,LPVARIANT,LPVARIANT);
static void test_Mod( int line, VARIANT *left, VARIANT *right, VARIANT *expected, HRESULT expres )
{
VARIANT result;
HRESULT hres;
memset( &result, 0, sizeof(result) );
hres = pVarMod( left, right, &result );
ok_(__FILE__,line)( hres == expres, "wrong result %x/%x\n", hres, expres );
if (hres == S_OK)
ok_(__FILE__,line)( is_expected_variant( &result, expected ),
"got %s expected %s\n", variantstr(&result), variantstr(expected) );
}
#define VARMOD(vt1,vt2,val1,val2,rvt,rval) \
V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
test_var_call2( __LINE__, pVarMod, &left, &right, &exp );
#define VARMOD2(vt1,vt2,val1,val2,rvt,rval,hexpected) \
V_VT(&left) = VT_##vt1; V_I4(&left) = val1; \
V_VT(&right) = VT_##vt2; V_I4(&right) = val2; \
V_VT(&exp) = VT_##rvt; V_I4(&exp) = rval; \
test_Mod( __LINE__, &left, &right, &exp, hexpected );
static void test_VarMod(void) static void test_VarMod(void)
{ {
VARIANT v1, v2, vDst; VARIANT v1, v2, vDst, left, right, exp;
HRESULT hres; HRESULT hres;
HRESULT hexpected = 0; HRESULT hexpected = 0;
static const WCHAR szNum0[] = {'1','2','5','\0'}; static const WCHAR szNum0[] = {'1','2','5','\0'};
...@@ -2096,132 +2251,132 @@ static void test_VarMod(void) ...@@ -2096,132 +2251,132 @@ static void test_VarMod(void)
CHECKPTR(VarMod); CHECKPTR(VarMod);
VARMOD(I1,BOOL,100,10,I4,0,S_OK); VARMOD(I1,BOOL,100,10,I4,0);
VARMOD(I1,I1,100,10,I4,0,S_OK); VARMOD(I1,I1,100,10,I4,0);
VARMOD(I1,UI1,100,10,I4,0,S_OK); VARMOD(I1,UI1,100,10,I4,0);
VARMOD(I1,I2,100,10,I4,0,S_OK); VARMOD(I1,I2,100,10,I4,0);
VARMOD(I1,UI2,100,10,I4,0,S_OK); VARMOD(I1,UI2,100,10,I4,0);
VARMOD(I1,I4,100,10,I4,0,S_OK); VARMOD(I1,I4,100,10,I4,0);
VARMOD(I1,UI4,100,10,I4,0,S_OK); VARMOD(I1,UI4,100,10,I4,0);
VARMOD(I1,R4,100,10,I4,0,S_OK); VARMOD(I1,R4,100,10,I4,0);
VARMOD(I1,R8,100,10,I4,0,S_OK); VARMOD(I1,R8,100,10,I4,0);
VARMOD(UI1,BOOL,100,10,I2,0,S_OK); VARMOD(UI1,BOOL,100,10,I2,0);
VARMOD(UI1,I1,100,10,I4,0,S_OK); VARMOD(UI1,I1,100,10,I4,0);
VARMOD(UI1,UI1,100,10,UI1,0,S_OK); VARMOD(UI1,UI1,100,10,UI1,0);
VARMOD(UI1,I2,100,10,I2,0,S_OK); VARMOD(UI1,I2,100,10,I2,0);
VARMOD(UI1,UI2,100,10,I4,0,S_OK); VARMOD(UI1,UI2,100,10,I4,0);
VARMOD(UI1,I4,100,10,I4,0,S_OK); VARMOD(UI1,I4,100,10,I4,0);
VARMOD(UI1,UI4,100,10,I4,0,S_OK); VARMOD(UI1,UI4,100,10,I4,0);
VARMOD(UI1,R4,100,10,I4,0,S_OK); VARMOD(UI1,R4,100,10,I4,0);
VARMOD(UI1,R8,100,10,I4,0,S_OK); VARMOD(UI1,R8,100,10,I4,0);
VARMOD(I2,BOOL,100,10,I2,0,S_OK); VARMOD(I2,BOOL,100,10,I2,0);
VARMOD(I2,I1,100,10,I4,0,S_OK); VARMOD(I2,I1,100,10,I4,0);
VARMOD(I2,UI1,100,10,I2,0,S_OK); VARMOD(I2,UI1,100,10,I2,0);
VARMOD(I2,I2,100,10,I2,0,S_OK); VARMOD(I2,I2,100,10,I2,0);
VARMOD(I2,UI2,100,10,I4,0,S_OK); VARMOD(I2,UI2,100,10,I4,0);
VARMOD(I2,I4,100,10,I4,0,S_OK); VARMOD(I2,I4,100,10,I4,0);
VARMOD(I2,UI4,100,10,I4,0,S_OK); VARMOD(I2,UI4,100,10,I4,0);
VARMOD(I2,R4,100,10,I4,0,S_OK); VARMOD(I2,R4,100,10,I4,0);
VARMOD(I2,R8,100,10,I4,0,S_OK); VARMOD(I2,R8,100,10,I4,0);
VARMOD(I4,BOOL,100,10,I4,0,S_OK); VARMOD(I4,BOOL,100,10,I4,0);
VARMOD(I4,I1,100,10,I4,0,S_OK); VARMOD(I4,I1,100,10,I4,0);
VARMOD(I4,UI1,100,10,I4,0,S_OK); VARMOD(I4,UI1,100,10,I4,0);
VARMOD(I4,I2,100,10,I4,0,S_OK); VARMOD(I4,I2,100,10,I4,0);
VARMOD(I4,UI2,100,10,I4,0,S_OK); VARMOD(I4,UI2,100,10,I4,0);
VARMOD(I4,I4,100,10,I4,0,S_OK); VARMOD(I4,I4,100,10,I4,0);
VARMOD(I4,UI4,100,10,I4,0,S_OK); VARMOD(I4,UI4,100,10,I4,0);
VARMOD(I4,R4,100,10,I4,0,S_OK); VARMOD(I4,R4,100,10,I4,0);
VARMOD(I4,R8,100,10,I4,0,S_OK); VARMOD(I4,R8,100,10,I4,0);
VARMOD(UI4,BOOL,100,10,I4,0,S_OK); VARMOD(UI4,BOOL,100,10,I4,0);
VARMOD(UI4,I1,100,10,I4,0,S_OK); VARMOD(UI4,I1,100,10,I4,0);
VARMOD(UI4,UI1,100,10,I4,0,S_OK); VARMOD(UI4,UI1,100,10,I4,0);
VARMOD(UI4,I2,100,10,I4,0,S_OK); VARMOD(UI4,I2,100,10,I4,0);
VARMOD(UI4,UI2,100,10,I4,0,S_OK); VARMOD(UI4,UI2,100,10,I4,0);
VARMOD(UI4,I4,100,10,I4,0,S_OK); VARMOD(UI4,I4,100,10,I4,0);
VARMOD(UI4,UI4,100,10,I4,0,S_OK); VARMOD(UI4,UI4,100,10,I4,0);
VARMOD(UI4,R4,100,10,I4,0,S_OK); VARMOD(UI4,R4,100,10,I4,0);
VARMOD(UI4,R8,100,10,I4,0,S_OK); VARMOD(UI4,R8,100,10,I4,0);
VARMOD(R4,BOOL,100,10,I4,0,S_OK); VARMOD(R4,BOOL,100,10,I4,0);
VARMOD(R4,I1,100,10,I4,0,S_OK); VARMOD(R4,I1,100,10,I4,0);
VARMOD(R4,UI1,100,10,I4,0,S_OK); VARMOD(R4,UI1,100,10,I4,0);
VARMOD(R4,I2,100,10,I4,0,S_OK); VARMOD(R4,I2,100,10,I4,0);
VARMOD(R4,UI2,100,10,I4,0,S_OK); VARMOD(R4,UI2,100,10,I4,0);
VARMOD(R4,I4,100,10,I4,0,S_OK); VARMOD(R4,I4,100,10,I4,0);
VARMOD(R4,UI4,100,10,I4,0,S_OK); VARMOD(R4,UI4,100,10,I4,0);
VARMOD(R4,R4,100,10,I4,0,S_OK); VARMOD(R4,R4,100,10,I4,0);
VARMOD(R4,R8,100,10,I4,0,S_OK); VARMOD(R4,R8,100,10,I4,0);
VARMOD(R8,BOOL,100,10,I4,0,S_OK); VARMOD(R8,BOOL,100,10,I4,0);
VARMOD(R8,I1,100,10,I4,0,S_OK); VARMOD(R8,I1,100,10,I4,0);
VARMOD(R8,UI1,100,10,I4,0,S_OK); VARMOD(R8,UI1,100,10,I4,0);
VARMOD(R8,I2,100,10,I4,0,S_OK); VARMOD(R8,I2,100,10,I4,0);
VARMOD(R8,UI2,100,10,I4,0,S_OK); VARMOD(R8,UI2,100,10,I4,0);
VARMOD(R8,I4,100,10,I4,0,S_OK); VARMOD(R8,I4,100,10,I4,0);
VARMOD(R8,UI4,100,10,I4,0,S_OK); VARMOD(R8,UI4,100,10,I4,0);
VARMOD(R8,R4,100,10,I4,0,S_OK); VARMOD(R8,R4,100,10,I4,0);
VARMOD(R8,R8,100,10,I4,0,S_OK); VARMOD(R8,R8,100,10,I4,0);
VARMOD(INT,INT,100,10,I4,0,S_OK); VARMOD(INT,INT,100,10,I4,0);
VARMOD(INT,UINT,100,10,I4,0,S_OK); VARMOD(INT,UINT,100,10,I4,0);
VARMOD(BOOL,BOOL,100,10,I2,0,S_OK); VARMOD(BOOL,BOOL,100,10,I2,0);
VARMOD(BOOL,I1,100,10,I4,0,S_OK); VARMOD(BOOL,I1,100,10,I4,0);
VARMOD(BOOL,UI1,100,10,I2,0,S_OK); VARMOD(BOOL,UI1,100,10,I2,0);
VARMOD(BOOL,I2,100,10,I2,0,S_OK); VARMOD(BOOL,I2,100,10,I2,0);
VARMOD(BOOL,UI2,100,10,I4,0,S_OK); VARMOD(BOOL,UI2,100,10,I4,0);
VARMOD(BOOL,I4,100,10,I4,0,S_OK); VARMOD(BOOL,I4,100,10,I4,0);
VARMOD(BOOL,UI4,100,10,I4,0,S_OK); VARMOD(BOOL,UI4,100,10,I4,0);
VARMOD(BOOL,R4,100,10,I4,0,S_OK); VARMOD(BOOL,R4,100,10,I4,0);
VARMOD(BOOL,R8,100,10,I4,0,S_OK); VARMOD(BOOL,R8,100,10,I4,0);
VARMOD(BOOL,DATE,100,10,I4,0,S_OK); VARMOD(BOOL,DATE,100,10,I4,0);
VARMOD(DATE,BOOL,100,10,I4,0,S_OK); VARMOD(DATE,BOOL,100,10,I4,0);
VARMOD(DATE,I1,100,10,I4,0,S_OK); VARMOD(DATE,I1,100,10,I4,0);
VARMOD(DATE,UI1,100,10,I4,0,S_OK); VARMOD(DATE,UI1,100,10,I4,0);
VARMOD(DATE,I2,100,10,I4,0,S_OK); VARMOD(DATE,I2,100,10,I4,0);
VARMOD(DATE,UI2,100,10,I4,0,S_OK); VARMOD(DATE,UI2,100,10,I4,0);
VARMOD(DATE,I4,100,10,I4,0,S_OK); VARMOD(DATE,I4,100,10,I4,0);
VARMOD(DATE,UI4,100,10,I4,0,S_OK); VARMOD(DATE,UI4,100,10,I4,0);
VARMOD(DATE,R4,100,10,I4,0,S_OK); VARMOD(DATE,R4,100,10,I4,0);
VARMOD(DATE,R8,100,10,I4,0,S_OK); VARMOD(DATE,R8,100,10,I4,0);
VARMOD(DATE,DATE,100,10,I4,0,S_OK); VARMOD(DATE,DATE,100,10,I4,0);
strNum0 = SysAllocString(szNum0); strNum0 = SysAllocString(szNum0);
strNum1 = SysAllocString(szNum1); strNum1 = SysAllocString(szNum1);
VARMOD(BSTR,BSTR,strNum0,strNum1,I4,5,S_OK); VARMOD(BSTR,BSTR,strNum0,strNum1,I4,5);
VARMOD(BSTR,I1,strNum0,10,I4,5,S_OK); VARMOD(BSTR,I1,strNum0,10,I4,5);
VARMOD(BSTR,I2,strNum0,10,I4,5,S_OK); VARMOD(BSTR,I2,strNum0,10,I4,5);
VARMOD(BSTR,I4,strNum0,10,I4,5,S_OK); VARMOD(BSTR,I4,strNum0,10,I4,5);
VARMOD(BSTR,R4,strNum0,10,I4,5,S_OK); VARMOD(BSTR,R4,strNum0,10,I4,5);
VARMOD(BSTR,R8,strNum0,10,I4,5,S_OK); VARMOD(BSTR,R8,strNum0,10,I4,5);
VARMOD(I4,BSTR,125,strNum1,I4,5,S_OK); VARMOD(I4,BSTR,125,strNum1,I4,5);
if (HAVE_OLEAUT32_I8) if (HAVE_OLEAUT32_I8)
{ {
VARMOD(BOOL,I8,100,10,I8,0,S_OK); VARMOD(BOOL,I8,100,10,I8,0);
VARMOD(I1,I8,100,10,I8,0,S_OK); VARMOD(I1,I8,100,10,I8,0);
VARMOD(UI1,I8,100,10,I8,0,S_OK); VARMOD(UI1,I8,100,10,I8,0);
VARMOD(I2,I8,100,10,I8,0,S_OK); VARMOD(I2,I8,100,10,I8,0);
VARMOD(I4,I8,100,10,I8,0,S_OK); VARMOD(I4,I8,100,10,I8,0);
VARMOD(UI4,I8,100,10,I8,0,S_OK); VARMOD(UI4,I8,100,10,I8,0);
VARMOD(R4,I8,100,10,I8,0,S_OK); VARMOD(R4,I8,100,10,I8,0);
VARMOD(R8,I8,100,10,I8,0,S_OK); VARMOD(R8,I8,100,10,I8,0);
VARMOD(DATE,I8,100,10,I8,0,S_OK); VARMOD(DATE,I8,100,10,I8,0);
VARMOD(I8,BOOL,100,10,I8,0,S_OK); VARMOD(I8,BOOL,100,10,I8,0);
VARMOD(I8,I1,100,10,I8,0,S_OK); VARMOD(I8,I1,100,10,I8,0);
VARMOD(I8,UI1,100,10,I8,0,S_OK); VARMOD(I8,UI1,100,10,I8,0);
VARMOD(I8,I2,100,10,I8,0,S_OK); VARMOD(I8,I2,100,10,I8,0);
VARMOD(I8,UI2,100,10,I8,0,S_OK); VARMOD(I8,UI2,100,10,I8,0);
VARMOD(I8,I4,100,10,I8,0,S_OK); VARMOD(I8,I4,100,10,I8,0);
VARMOD(I8,UI4,100,10,I8,0,S_OK); VARMOD(I8,UI4,100,10,I8,0);
VARMOD(I8,R4,100,10,I8,0,S_OK); VARMOD(I8,R4,100,10,I8,0);
VARMOD(I8,R8,100,10,I8,0,S_OK); VARMOD(I8,R8,100,10,I8,0);
VARMOD(I8,I8,100,10,I8,0,S_OK); VARMOD(I8,I8,100,10,I8,0);
VARMOD(BSTR,I8,strNum0,10,I8,5,S_OK); VARMOD(BSTR,I8,strNum0,10,I8,5);
} }
/* test all combinations of types */ /* test all combinations of types */
...@@ -2443,12 +2598,12 @@ static void test_VarMod(void) ...@@ -2443,12 +2598,12 @@ static void test_VarMod(void)
/****************************/ /****************************/
/* test some bad parameters */ /* test some bad parameters */
VARMOD(I4,I4,-1,-1,I4,0,S_OK); VARMOD(I4,I4,-1,-1,I4,0);
/* test modulus with zero */ /* test modulus with zero */
VARMOD2(I4,I4,100,0,EMPTY,0,DISP_E_DIVBYZERO); VARMOD2(I4,I4,100,0,EMPTY,0,DISP_E_DIVBYZERO);
VARMOD(I4,I4,0,10,I4,0,S_OK); /* test 0 mod 10 */ VARMOD(I4,I4,0,10,I4,0); /* test 0 mod 10 */
/* right parameter is type empty */ /* right parameter is type empty */
VARMOD2(I4,EMPTY,100,10,EMPTY,0,DISP_E_DIVBYZERO); VARMOD2(I4,EMPTY,100,10,EMPTY,0,DISP_E_DIVBYZERO);
...@@ -2559,24 +2714,22 @@ static void test_VarMod(void) ...@@ -2559,24 +2714,22 @@ static void test_VarMod(void)
V_I4(&v1) = 100; V_I4(&v1) = 100;
V_I4(&v2)= 10; V_I4(&v2)= 10;
hres = pVarMod(&v1,&v2,&vDst); hres = pVarMod(&v1,&v2,&vDst);
ok(hres == DISP_E_BADVARTYPE && V_VT(&vDst) == VT_EMPTY && V_I4(&vDst) == 0, ok(hres == DISP_E_BADVARTYPE && V_VT(&vDst) == VT_EMPTY,
"VarMod: expected 0x%x,%d,%d, got 0x%X,%d,%d\n", DISP_E_BADVARTYPE, VT_EMPTY, 0, hres, V_VT(&vDst), V_I4(&vDst)); "VarMod: expected 0x%x,%d, got 0x%X,%d\n", DISP_E_BADVARTYPE, VT_EMPTY, hres, V_VT(&vDst));
} }
static HRESULT (WINAPI *pVarFix)(LPVARIANT,LPVARIANT); static HRESULT (WINAPI *pVarFix)(LPVARIANT,LPVARIANT);
static const char *szVarFixFail = "VarFix: expected 0x0,%d,%d, got 0x%X,%d,%d\n"; #define VARFIX(vt,val,rvt,rval) \
#define VARFIX(vt,val,rvt,rval) V_VT(&v) = VT_##vt; V_##vt(&v) = val; \ V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
memset(&vDst,0,sizeof(vDst)); hres = pVarFix(&v,&vDst); \ V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
ok(hres == S_OK && V_VT(&vDst) == VT_##rvt && V_##rvt(&vDst) == (rval), \ test_var_call1( __LINE__, pVarFix, &v, &exp );
szVarFixFail, VT_##rvt, (int)(rval), \
hres, V_VT(&vDst), (int)V_##rvt(&vDst))
static void test_VarFix(void) static void test_VarFix(void)
{ {
static const WCHAR szNumMinus1[] = {'-','1','\0' }; static const WCHAR szNumMinus1[] = {'-','1','\0' };
HRESULT hres; HRESULT hres;
VARIANT v, vDst; VARIANT v, exp, vDst;
DECIMAL *pdec = &V_DECIMAL(&v); DECIMAL *pdec = &V_DECIMAL(&v);
CY *pcy = &V_CY(&v); CY *pcy = &V_CY(&v);
size_t i; size_t i;
...@@ -2682,18 +2835,16 @@ static void test_VarFix(void) ...@@ -2682,18 +2835,16 @@ static void test_VarFix(void)
static HRESULT (WINAPI *pVarInt)(LPVARIANT,LPVARIANT); static HRESULT (WINAPI *pVarInt)(LPVARIANT,LPVARIANT);
static const char *szVarIntFail = "VarInt: expected 0x0,%d,%d, got 0x%X,%d,%d\n"; #define VARINT(vt,val,rvt,rval) \
#define VARINT(vt,val,rvt,rval) V_VT(&v) = VT_##vt; V_##vt(&v) = val; \ V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
memset(&vDst,0,sizeof(vDst)); hres = pVarInt(&v,&vDst); \ V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
ok(hres == S_OK && V_VT(&vDst) == VT_##rvt && V_##rvt(&vDst) == (rval), \ test_var_call1( __LINE__, pVarInt, &v, &exp );
szVarIntFail, VT_##rvt, (int)(rval), \
hres, V_VT(&vDst), (int)V_##rvt(&vDst))
static void test_VarInt(void) static void test_VarInt(void)
{ {
static const WCHAR szNumMinus1[] = {'-','1','\0' }; static const WCHAR szNumMinus1[] = {'-','1','\0' };
HRESULT hres; HRESULT hres;
VARIANT v, vDst; VARIANT v, exp, vDst;
DECIMAL *pdec = &V_DECIMAL(&v); DECIMAL *pdec = &V_DECIMAL(&v);
CY *pcy = &V_CY(&v); CY *pcy = &V_CY(&v);
size_t i; size_t i;
...@@ -2800,19 +2951,17 @@ static void test_VarInt(void) ...@@ -2800,19 +2951,17 @@ static void test_VarInt(void)
static HRESULT (WINAPI *pVarNeg)(LPVARIANT,LPVARIANT); static HRESULT (WINAPI *pVarNeg)(LPVARIANT,LPVARIANT);
static const char *szVarNegFail = "VarNeg: expected 0x0,%d,%d, got 0x%X,%d,%d\n"; #define VARNEG(vt,val,rvt,rval) \
#define VARNEG(vt,val,rvt,rval) V_VT(&v) = VT_##vt; V_##vt(&v) = val; \ V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
memset(&vDst,0,sizeof(vDst)); hres = pVarNeg(&v,&vDst); \ V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
ok(hres == S_OK && V_VT(&vDst) == VT_##rvt && V_##rvt(&vDst) == (rval), \ test_var_call1( __LINE__, pVarNeg, &v, &exp );
szVarNegFail, VT_##rvt, (int)(rval), \
hres, V_VT(&vDst), (int)V_##rvt(&vDst))
static void test_VarNeg(void) static void test_VarNeg(void)
{ {
static const WCHAR szNumMinus1[] = {'-','1','\0' }; static const WCHAR szNumMinus1[] = {'-','1','\0' };
static const WCHAR szNum1[] = {'1','\0' }; static const WCHAR szNum1[] = {'1','\0' };
HRESULT hres; HRESULT hres;
VARIANT v, vDst; VARIANT v, exp, vDst;
DECIMAL *pdec = &V_DECIMAL(&v); DECIMAL *pdec = &V_DECIMAL(&v);
CY *pcy = &V_CY(&v); CY *pcy = &V_CY(&v);
size_t i; size_t i;
...@@ -2926,24 +3075,29 @@ static void test_VarNeg(void) ...@@ -2926,24 +3075,29 @@ static void test_VarNeg(void)
static HRESULT (WINAPI *pVarRound)(LPVARIANT,int,LPVARIANT); static HRESULT (WINAPI *pVarRound)(LPVARIANT,int,LPVARIANT);
#define VARROUND(vt,val,deci,rvt,rval) V_VT(&v) = VT_##vt; V_##vt(&v) = val; \ static void test_Round( int line, VARIANT *arg, int deci, VARIANT *expected )
memset(&vDst,0,sizeof(vDst)); hres = pVarRound(&v,deci,&vDst); \ {
ok(hres == S_OK && V_VT(&vDst) == VT_##rvt && V_##rvt(&vDst) == (rval), \ VARIANT result;
"VarRound: expected 0x0,%d,%d, got 0x%X,%d,%d\n", VT_##rvt, (int)(rval), \ HRESULT hres;
hres, V_VT(&vDst), (int)V_##rvt(&vDst))
#define VARROUNDF(vt,val,deci,rvt,rval) V_VT(&v) = VT_##vt; V_##vt(&v) = val; \ memset( &result, 0, sizeof(result) );
memset(&vDst,0,sizeof(vDst)); hres = pVarRound(&v,deci,&vDst); \ hres = pVarRound( arg, deci, &result );
ok(hres == S_OK && V_VT(&vDst) == VT_##rvt && V_##rvt(&vDst) == (rval), \ ok_(__FILE__,line)( hres == S_OK, "wrong result %x\n", hres );
"VarRound: expected 0x0,%d,%f, got 0x%X,%d,%f\n", VT_##rvt, rval, \ if (hres == S_OK)
hres, V_VT(&vDst), V_##rvt(&vDst)) ok_(__FILE__,line)( is_expected_variant( &result, expected ),
"got %s expected %s\n", variantstr(&result), variantstr(expected) );
}
#define VARROUND(vt,val,deci,rvt,rval) \
V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
test_Round( __LINE__, &v, deci, &exp );
static void test_VarRound(void) static void test_VarRound(void)
{ {
/* static const WCHAR szNumMin[] = {'-','1','.','4','5','\0' }; static const WCHAR szNumMin[] = {'-','1','.','4','5','\0' };
static const WCHAR szNum[] = {'1','.','4','5','\0' }; */ static const WCHAR szNum[] = {'1','.','4','5','\0' };
HRESULT hres; HRESULT hres;
VARIANT v, vDst; VARIANT v, exp, vDst;
CY *pcy = &V_CY(&v); CY *pcy = &V_CY(&v);
CHECKPTR(VarRound); CHECKPTR(VarRound);
...@@ -2967,42 +3121,39 @@ static void test_VarRound(void) ...@@ -2967,42 +3121,39 @@ static void test_VarRound(void)
* case Wine returns .2 (which is more correct) and Native returns .3 * case Wine returns .2 (which is more correct) and Native returns .3
*/ */
VARROUNDF(R4,1.0,0,R4,1.0); VARROUND(R4,1.0,0,R4,1.0);
VARROUNDF(R4,-1.0,0,R4,-1.0); VARROUND(R4,-1.0,0,R4,-1.0);
VARROUNDF(R8,1.0,0,R8,1.0); VARROUND(R8,1.0,0,R8,1.0);
VARROUNDF(R8,-1.0,0,R8,-1.0); VARROUND(R8,-1.0,0,R8,-1.0);
/* floating point numbers aren't exactly equal and we can't just /* floating point numbers aren't exactly equal and we can't just
* compare the first few digits. * compare the first few digits. */
todo_wine { VARROUND(DATE,1.451,1,DATE,1.5);
VARROUNDF(DATE,1.451,1,DATE,1.5); VARROUND(DATE,-1.45,1,DATE,-1.4);
VARROUNDF(DATE,-1.45,1,DATE,-1.4); VARROUND(BSTR,(BSTR)szNumMin,1,R8,-1.40);
VARROUNDF(BSTR,(BSTR)szNumMin,1,R8,-1.40); if (0) { VARROUND(BSTR,(BSTR)szNum,1,R8,1.50); }
VARROUNDF(BSTR,(BSTR)szNum,1,R8,1.50);
VARROUND(R4,1.23456,0,R4,1.0);
VARROUNDF(R4,1.23456,0,R4,1.0); VARROUND(R4,1.23456,1,R4,1.2);
VARROUNDF(R4,1.23456,1,R4,1.2); VARROUND(R4,1.23456,2,R4,1.23);
VARROUNDF(R4,1.23456,2,R4,1.23); VARROUND(R4,1.23456,3,R4,1.235);
VARROUNDF(R4,1.23456,3,R4,1.235); VARROUND(R4,1.23456,4,R4,1.2346);
VARROUNDF(R4,1.23456,4,R4,1.2346); VARROUND(R4,-1.23456,0,R4,-1.0);
VARROUNDF(R4,-1.23456,0,R4,-1.0); VARROUND(R4,-1.23456,1,R4,-1.2);
VARROUNDF(R4,-1.23456,1,R4,-1.2); VARROUND(R4,-1.23456,2,R4,-1.23);
VARROUNDF(R4,-1.23456,2,R4,-1.23); VARROUND(R4,-1.23456,3,R4,-1.235);
VARROUNDF(R4,-1.23456,3,R4,-1.235); VARROUND(R4,-1.23456,4,R4,-1.2346);
VARROUNDF(R4,-1.23456,4,R4,-1.2346);
VARROUND(R8,1.23456,0,R8,1.0);
VARROUNDF(R8,1.23456,0,R8,1.0); VARROUND(R8,1.23456,1,R8,1.2);
VARROUNDF(R8,1.23456,1,R8,1.2); VARROUND(R8,1.23456,2,R8,1.23);
VARROUNDF(R8,1.23456,2,R8,1.23); VARROUND(R8,1.23456,3,R8,1.235);
VARROUNDF(R8,1.23456,3,R8,1.235); VARROUND(R8,1.23456,4,R8,1.2346);
VARROUNDF(R8,1.23456,4,R8,1.2346); VARROUND(R8,-1.23456,0,R8,-1.0);
VARROUNDF(R8,-1.23456,0,R8,-1.0); VARROUND(R8,-1.23456,1,R8,-1.2);
VARROUNDF(R8,-1.23456,1,R8,-1.2); VARROUND(R8,-1.23456,2,R8,-1.23);
VARROUNDF(R8,-1.23456,2,R8,-1.23); VARROUND(R8,-1.23456,3,R8,-1.235);
VARROUNDF(R8,-1.23456,3,R8,-1.235); VARROUND(R8,-1.23456,4,R8,-1.2346);
VARROUNDF(R8,-1.23456,4,R8,-1.2346);
}
*/
V_VT(&v) = VT_EMPTY; V_VT(&v) = VT_EMPTY;
hres = pVarRound(&v,0,&vDst); hres = pVarRound(&v,0,&vDst);
...@@ -3049,33 +3200,23 @@ static void test_VarRound(void) ...@@ -3049,33 +3200,23 @@ static void test_VarRound(void)
static HRESULT (WINAPI *pVarXor)(LPVARIANT,LPVARIANT,LPVARIANT); static HRESULT (WINAPI *pVarXor)(LPVARIANT,LPVARIANT,LPVARIANT);
static const char *szVarXorFail = "VarXor(%d,%d): expected 0x0,%d,%d, got 0x%X,%d,%d\n"; #define VARXOR(vt1,val1,vt2,val2,rvt,rval) \
#define VARXOR(vt1,val1,vt2,val2,rvt,rval) \ V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \ V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
memset(&result,0,sizeof(result)); hres = pVarXor(&left,&right,&result); \ V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
ok(hres == S_OK && V_VT(&result) == VT_##rvt && V_##rvt(&result) == (rval), \ test_var_call2( __LINE__, pVarXor, &left, &right, &exp );
szVarXorFail, VT_##vt1, VT_##vt2, \
VT_##rvt, (int)(rval), hres, V_VT(&result), (int)V_##rvt(&result)); \ #define VARXORCY(vt1,val1,val2,rvt,rval) \
ok(V_VT(&left) == VT_##vt1 && V_##vt1(&left) == val1 && \ V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
V_VT(&right) == VT_##vt2 && V_##vt2(&right) == val2, \
"VarXor(%d,%d): Modified input arguments\n",VT_##vt1,VT_##vt2)
#define VARXORCY(vt1,val1,val2,rvt,rval) \
V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
V_VT(&right) = VT_CY; V_CY(&right).int64 = val2; \ V_VT(&right) = VT_CY; V_CY(&right).int64 = val2; \
memset(&result,0,sizeof(result)); hres = pVarXor(&left,&right,&result); \ V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
ok(hres == S_OK && V_VT(&result) == VT_##rvt && V_##rvt(&result) == (rval), \ test_var_call2( __LINE__, pVarXor, &left, &right, &exp );
"VarXor(%d,%d): expected 0x0,%d,%d, got 0x%X,%d,%d\n", VT_##vt1, VT_CY, \
VT_##rvt, (int)(rval), hres, V_VT(&result), (int)V_##rvt(&result)); \
ok(V_VT(&left) == VT_##vt1 && V_##vt1(&left) == val1 && \
V_VT(&right) == VT_CY && V_CY(&right).int64 == val2, \
"VarXor(%d,%d): Modified input arguments\n",VT_##vt1,VT_CY)
static void test_VarXor(void) static void test_VarXor(void)
{ {
static const WCHAR szFalse[] = { '#','F','A','L','S','E','#','\0' }; static const WCHAR szFalse[] = { '#','F','A','L','S','E','#','\0' };
static const WCHAR szTrue[] = { '#','T','R','U','E','#','\0' }; static const WCHAR szTrue[] = { '#','T','R','U','E','#','\0' };
VARIANT left, right, result; VARIANT left, right, exp, result;
BSTR lbstr, rbstr; BSTR lbstr, rbstr;
VARTYPE i; VARTYPE i;
HRESULT hres; HRESULT hres;
...@@ -3756,34 +3897,23 @@ static void test_VarXor(void) ...@@ -3756,34 +3897,23 @@ static void test_VarXor(void)
static HRESULT (WINAPI *pVarOr)(LPVARIANT,LPVARIANT,LPVARIANT); static HRESULT (WINAPI *pVarOr)(LPVARIANT,LPVARIANT,LPVARIANT);
static const char *szVarOrFail = "VarOr(%d,%d): expected 0x0,%d,%d, got 0x%X,%d,%d\n"; #define VAROR(vt1,val1,vt2,val2,rvt,rval) \
static const char *szVarOrChanged = "VarOr(%d,%d): Modified input arguments\n"; V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
#define VAROR(vt1,val1,vt2,val2,rvt,rval) \
V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \ V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
memset(&result,0,sizeof(result)); hres = pVarOr(&left,&right,&result); \ V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
ok(hres == S_OK && V_VT(&result) == VT_##rvt && V_##rvt(&result) == (rval), \ test_var_call2( __LINE__, pVarOr, &left, &right, &exp );
szVarOrFail, VT_##vt1, VT_##vt2, \
VT_##rvt, (int)(rval), hres, V_VT(&result), (int)V_##rvt(&result)); \ #define VARORCY(vt1,val1,val2,rvt,rval) \
ok(V_VT(&left) == VT_##vt1 && V_##vt1(&left) == val1 && \ V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
V_VT(&right) == VT_##vt2 && V_##vt2(&right) == val2, \
szVarOrChanged,VT_##vt1,VT_##vt2)
#define VARORCY(vt1,val1,val2,rvt,rval) \
V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
V_VT(&right) = VT_CY; V_CY(&right).int64 = val2; \ V_VT(&right) = VT_CY; V_CY(&right).int64 = val2; \
memset(&result,0,sizeof(result)); hres = pVarOr(&left,&right,&result); \ V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
ok(hres == S_OK && V_VT(&result) == VT_##rvt && V_##rvt(&result) == (rval), \ test_var_call2( __LINE__, pVarOr, &left, &right, &exp );
"VarOr(%d,%d): expected 0x0,%d,%d, got 0x%X,%d,%d\n", VT_##vt1, VT_CY, \
VT_##rvt, (int)(rval), hres, V_VT(&result), (int)V_##rvt(&result)); \
ok(V_VT(&left) == VT_##vt1 && V_##vt1(&left) == val1 && \
V_VT(&right) == VT_CY && V_CY(&right).int64 == val2, \
"VarOr(%d,%d): Modified input arguments\n",VT_##vt1,VT_CY)
static void test_VarOr(void) static void test_VarOr(void)
{ {
static const WCHAR szFalse[] = { '#','F','A','L','S','E','#','\0' }; static const WCHAR szFalse[] = { '#','F','A','L','S','E','#','\0' };
static const WCHAR szTrue[] = { '#','T','R','U','E','#','\0' }; static const WCHAR szTrue[] = { '#','T','R','U','E','#','\0' };
VARIANT left, right, result; VARIANT left, right, exp, result;
BSTR lbstr, rbstr; BSTR lbstr, rbstr;
VARTYPE i; VARTYPE i;
HRESULT hres; HRESULT hres;
...@@ -4471,18 +4601,15 @@ static void test_VarOr(void) ...@@ -4471,18 +4601,15 @@ static void test_VarOr(void)
static HRESULT (WINAPI *pVarEqv)(LPVARIANT,LPVARIANT,LPVARIANT); static HRESULT (WINAPI *pVarEqv)(LPVARIANT,LPVARIANT,LPVARIANT);
static const char *szVarEqvFail = "VarEqv(%d,%d): expected 0x0,%d,%d, got 0x%X,%d,%d\n"; #define VAREQV(vt1,val1,vt2,val2,rvt,rval) \
#define VAREQV(vt1,val1,vt2,val2,rvt,rval) \ V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \ V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \ V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
memset(&result,0,sizeof(result)); hres = pVarEqv(&left,&right,&result); \ test_var_call2( __LINE__, pVarEqv, &left, &right, &exp );
ok(hres == S_OK && V_VT(&result) == VT_##rvt && V_##rvt(&result) == (rval), \
szVarEqvFail, VT_##vt1, VT_##vt2, \
VT_##rvt, (int)(rval), hres, V_VT(&result), (int)V_##rvt(&result))
static void test_VarEqv(void) static void test_VarEqv(void)
{ {
VARIANT left, right, result; VARIANT left, right, exp, result;
VARTYPE i; VARTYPE i;
HRESULT hres; HRESULT hres;
...@@ -4613,27 +4740,16 @@ static void test_VarEqv(void) ...@@ -4613,27 +4740,16 @@ static void test_VarEqv(void)
static HRESULT (WINAPI *pVarMul)(LPVARIANT,LPVARIANT,LPVARIANT); static HRESULT (WINAPI *pVarMul)(LPVARIANT,LPVARIANT,LPVARIANT);
static const char *szVarMulI4 = "VarMul(%d,%d): expected 0x0,%d,%d, got 0x%X,%d,%d\n"; #define VARMUL(vt1,val1,vt2,val2,rvt,rval) \
static const char *szVarMulR8 = "VarMul(%d,%d): expected 0x0,%d,%f, got 0x%X,%d,%f\n"; V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
#define VARMUL(vt1,val1,vt2,val2,rvt,rval) \
V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \ V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
memset(&result,0,sizeof(result)); hres = pVarMul(&left,&right,&result); \ V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
if (VT_##rvt == VT_R4 || VT_##rvt == VT_R8) { \ test_var_call2( __LINE__, pVarMul, &left, &right, &exp );
ok(hres == S_OK && V_VT(&result) == VT_##rvt && \
EQ_FLOAT(V_##rvt(&result), rval), \
szVarMulR8, VT_##vt1, VT_##vt2, \
VT_##rvt, (double)(rval), hres, V_VT(&result), (double)V_##rvt(&result)); \
} else { \
ok(hres == S_OK && V_VT(&result) == VT_##rvt && V_##rvt(&result) == (rval), \
szVarMulI4, VT_##vt1, VT_##vt2, \
VT_##rvt, (int)(rval), hres, V_VT(&result), (int)V_##rvt(&result)); }
static void test_VarMul(void) static void test_VarMul(void)
{ {
static const WCHAR sz12[] = {'1','2','\0'}; static const WCHAR sz12[] = {'1','2','\0'};
VARIANT left, right, result, cy, dec; VARIANT left, right, exp, result, cy, dec;
VARTYPE i; VARTYPE i;
BSTR lbstr, rbstr; BSTR lbstr, rbstr;
HRESULT hres; HRESULT hres;
...@@ -4796,27 +4912,16 @@ static void test_VarMul(void) ...@@ -4796,27 +4912,16 @@ static void test_VarMul(void)
static HRESULT (WINAPI *pVarAdd)(LPVARIANT,LPVARIANT,LPVARIANT); static HRESULT (WINAPI *pVarAdd)(LPVARIANT,LPVARIANT,LPVARIANT);
static const char *szVarAddI4 = "VarAdd(%d,%d): expected 0x0,%d,%d, got 0x%X,%d,%d\n"; #define VARADD(vt1,val1,vt2,val2,rvt,rval) \
static const char *szVarAddR8 = "VarAdd(%d,%d): expected 0x0,%d,%f, got 0x%X,%d,%f\n"; V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
#define VARADD(vt1,val1,vt2,val2,rvt,rval) \
V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \ V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
memset(&result,0,sizeof(result)); hres = pVarAdd(&left,&right,&result); \ V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
if (VT_##rvt == VT_R4 || VT_##rvt == VT_R8 || VT_##rvt == VT_DATE) { \ test_var_call2( __LINE__, pVarAdd, &left, &right, &exp );
ok(hres == S_OK && V_VT(&result) == VT_##rvt && \
EQ_FLOAT(V_##rvt(&result), rval), \
szVarAddR8, VT_##vt1, VT_##vt2, \
VT_##rvt, (double)(rval), hres, V_VT(&result), (double)V_##rvt(&result)); \
} else { \
ok(hres == S_OK && V_VT(&result) == VT_##rvt && V_##rvt(&result) == (rval), \
szVarAddI4, VT_##vt1, VT_##vt2, \
VT_##rvt, (int)(rval), hres, V_VT(&result), (int)V_##rvt(&result)); }
static void test_VarAdd(void) static void test_VarAdd(void)
{ {
static const WCHAR sz12[] = {'1','2','\0'}; static const WCHAR sz12[] = {'1','2','\0'};
VARIANT left, right, result, cy, dec; VARIANT left, right, exp, result, cy, dec;
VARTYPE i; VARTYPE i;
BSTR lbstr, rbstr; BSTR lbstr, rbstr;
HRESULT hres; HRESULT hres;
...@@ -5304,22 +5409,17 @@ static void test_VarCat(void) ...@@ -5304,22 +5409,17 @@ static void test_VarCat(void)
static HRESULT (WINAPI *pVarAnd)(LPVARIANT,LPVARIANT,LPVARIANT); static HRESULT (WINAPI *pVarAnd)(LPVARIANT,LPVARIANT,LPVARIANT);
static const char *szVarAndFail = "VarAnd(%s,%s): expected 0x0,%s,%d, got 0x%X,%s,%d\n"; #define VARAND(vt1,val1,vt2,val2,rvt,rval) \
V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
#define VARAND(vt1,val1,vt2,val2,rvt,rval) \ V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \ V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \ test_var_call2( __LINE__, pVarAnd, &left, &right, &exp );
memset(&result,0,sizeof(result)); hres = pVarAnd(&left,&right,&result); \
ok(hres == S_OK && V_VT(&result) == VT_##rvt && V_##rvt(&result) == (rval), \ #define VARANDCY(vt1,val1,val2,rvt,rval) \
szVarAndFail, vtstr(VT_##vt1), vtstr(VT_##vt2), \ V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
vtstr(VT_##rvt), (int)(rval), hres, vtstr(V_VT(&result)), (int)V_##rvt(&result)); V_VT(&right) = VT_CY; V_CY(&right).int64 = val2; \
#define VARANDCY(vt1,val1,val2,rvt,rval) \ V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \ test_var_call2( __LINE__, pVarAnd, &left, &right, &exp );
V_VT(&right) = VT_CY; V_CY(&right).int64 = val2; \
memset(&result,0,sizeof(result)); hres = pVarAnd(&left,&right,&result); \
ok(hres == S_OK && V_VT(&result) == VT_##rvt && V_##rvt(&result) == (rval), \
szVarAndFail, vtstr(VT_##vt1), vtstr(VT_CY), \
vtstr(VT_##rvt), (int)(rval), hres, vtstr(V_VT(&result)), (int)V_##rvt(&result));
/* Skip any type that is not defined or produces a error for every case */ /* Skip any type that is not defined or produces a error for every case */
#define SKIPTESTAND(a) \ #define SKIPTESTAND(a) \
...@@ -5332,7 +5432,7 @@ static void test_VarAnd(void) ...@@ -5332,7 +5432,7 @@ static void test_VarAnd(void)
{ {
static const WCHAR szFalse[] = { '#','F','A','L','S','E','#','\0' }; static const WCHAR szFalse[] = { '#','F','A','L','S','E','#','\0' };
static const WCHAR szTrue[] = { '#','T','R','U','E','#','\0' }; static const WCHAR szTrue[] = { '#','T','R','U','E','#','\0' };
VARIANT left, right, result; VARIANT left, right, exp, result;
BSTR false_str, true_str; BSTR false_str, true_str;
VARTYPE i; VARTYPE i;
HRESULT hres; HRESULT hres;
...@@ -5979,18 +6079,38 @@ static void test_VarAnd(void) ...@@ -5979,18 +6079,38 @@ static void test_VarAnd(void)
static HRESULT (WINAPI *pVarCmp)(LPVARIANT,LPVARIANT,LCID,ULONG); static HRESULT (WINAPI *pVarCmp)(LPVARIANT,LPVARIANT,LCID,ULONG);
static void test_cmp( int line, LCID lcid, UINT flags, VARIANT *left, VARIANT *right, HRESULT result )
{
HRESULT hres;
hres = pVarCmp(left,right,lcid,flags);
ok_(__FILE__,line)(hres == result, "VarCmp(%s,%s): expected 0x%x, got hres=0x%x\n",
variantstr(left), variantstr(right), result, hres );
}
static void test_cmpex( int line, LCID lcid, VARIANT *left, VARIANT *right,
HRESULT res1, HRESULT res2, HRESULT res3, HRESULT res4 )
{
test_cmp( line, lcid, 0, left, right, res1 );
V_VT(left) |= VT_RESERVED;
test_cmp( line, lcid, 0, left, right, res2 );
V_VT(left) &= ~VT_RESERVED;
V_VT(right) |= VT_RESERVED;
test_cmp( line, lcid, 0, left, right, res3 );
V_VT(left) |= VT_RESERVED;
test_cmp( line, lcid, 0, left, right, res4 );
ok_(__FILE__,line)(V_VT(left) & V_VT(right) & VT_RESERVED, "VT_RESERVED filtered out\n");
}
/* ERROR from wingdi.h is interfering here */ /* ERROR from wingdi.h is interfering here */
#undef ERROR #undef ERROR
#define _VARCMP(vt1,val1,vtfl1,vt2,val2,vtfl2,lcid,flags,result) \ #define _VARCMP(vt1,val1,vtfl1,vt2,val2,vtfl2,lcid,flags,result) \
V_##vt1(&left) = val1; V_VT(&left) = VT_##vt1 | vtfl1; \ V_##vt1(&left) = val1; V_VT(&left) = VT_##vt1 | vtfl1; \
V_##vt2(&right) = val2; V_VT(&right) = VT_##vt2 | vtfl2; \ V_##vt2(&right) = val2; V_VT(&right) = VT_##vt2 | vtfl2; \
hres = pVarCmp(&left,&right,lcid,flags); \ test_cmp( __LINE__, lcid, flags, &left, &right, result );
ok(hres == result, "VarCmp(VT_" #vt1 "|" #vtfl1 ",VT_" #vt2 "|" #vtfl2 "): expected " #result ", got hres=0x%x\n", hres)
#define VARCMPEX(vt1,val1,vt2,val2,res1,res2,res3,res4) \ #define VARCMPEX(vt1,val1,vt2,val2,res1,res2,res3,res4) \
_VARCMP(vt1,val1,0,vt2,val2,0,lcid,0,res1); \ V_##vt1(&left) = val1; V_VT(&left) = VT_##vt1; \
_VARCMP(vt1,val1,VT_RESERVED,vt2,val2,0,lcid,0,res2); \ V_##vt2(&right) = val2; V_VT(&right) = VT_##vt2; \
_VARCMP(vt1,val1,0,vt2,val2,VT_RESERVED,lcid,0,res3); \ test_cmpex( __LINE__, lcid, &left, &right, res1, res2, res3, res4 );
_VARCMP(vt1,val1,VT_RESERVED,vt2,val2,VT_RESERVED,lcid,0,res4)
#define VARCMP(vt1,val1,vt2,val2,result) \ #define VARCMP(vt1,val1,vt2,val2,result) \
VARCMPEX(vt1,val1,vt2,val2,result,result,result,result) VARCMPEX(vt1,val1,vt2,val2,result,result,result,result)
/* The above macros do not work for VT_NULL as NULL gets expanded first */ /* The above macros do not work for VT_NULL as NULL gets expanded first */
...@@ -6121,7 +6241,6 @@ static void test_VarCmp(void) ...@@ -6121,7 +6241,6 @@ static void test_VarCmp(void)
input variants with (1) and without (0) VT_RESERVED set. The order input variants with (1) and without (0) VT_RESERVED set. The order
of the permutations is (0,0); (1,0); (0,1); (1,1) */ of the permutations is (0,0); (1,0); (0,1); (1,1) */
VARCMP(INT,4711,I2,4711,VARCMP_EQ); VARCMP(INT,4711,I2,4711,VARCMP_EQ);
ok(V_VT(&left) & V_VT(&right) & VT_RESERVED, "VT_RESERVED filtered out!\n");
VARCMP(INT,4711,I2,-4711,VARCMP_GT); VARCMP(INT,4711,I2,-4711,VARCMP_GT);
VARCMP(ERROR,0,ERROR,0,VARCMP_EQ); VARCMP(ERROR,0,ERROR,0,VARCMP_EQ);
VARCMP(ERROR,0,UI1,0,DISP_E_TYPEMISMATCH); VARCMP(ERROR,0,UI1,0,DISP_E_TYPEMISMATCH);
...@@ -6129,7 +6248,6 @@ static void test_VarCmp(void) ...@@ -6129,7 +6248,6 @@ static void test_VarCmp(void)
VARCMP(I4,1,R8,1.0,VARCMP_EQ); VARCMP(I4,1,R8,1.0,VARCMP_EQ);
VARCMP(EMPTY,19,I2,0,VARCMP_EQ); VARCMP(EMPTY,19,I2,0,VARCMP_EQ);
ok(V_EMPTY(&left) == 19, "VT_EMPTY modified!\n"); ok(V_EMPTY(&left) == 19, "VT_EMPTY modified!\n");
ok(V_VT(&left) & V_VT(&right) & VT_RESERVED, "VT_RESERVED filtered out!\n");
VARCMP(I4,1,UI1,1,VARCMP_EQ); VARCMP(I4,1,UI1,1,VARCMP_EQ);
VARCMP(I2,2,I2,2,VARCMP_EQ); VARCMP(I2,2,I2,2,VARCMP_EQ);
VARCMP(I2,1,I2,2,VARCMP_LT); VARCMP(I2,1,I2,2,VARCMP_LT);
...@@ -6160,7 +6278,6 @@ static void test_VarCmp(void) ...@@ -6160,7 +6278,6 @@ static void test_VarCmp(void)
_VARCMP(BSTR,(BSTR)100,0,I2,100,0,lcid,0,VARCMP_GT); _VARCMP(BSTR,(BSTR)100,0,I2,100,0,lcid,0,VARCMP_GT);
VARCMPEX(BSTR,bstr0,UI1,0,VARCMP_GT,VARCMP_EQ,VARCMP_EQ,VARCMP_GT); VARCMPEX(BSTR,bstr0,UI1,0,VARCMP_GT,VARCMP_EQ,VARCMP_EQ,VARCMP_GT);
VARCMPEX(I2,0,BSTR,bstr0,VARCMP_LT,VARCMP_EQ,VARCMP_EQ,VARCMP_LT); VARCMPEX(I2,0,BSTR,bstr0,VARCMP_LT,VARCMP_EQ,VARCMP_EQ,VARCMP_LT);
ok(V_VT(&left) & V_VT(&right) & VT_RESERVED, "VT_RESERVED filtered out!\n");
VARCMP(BSTR,bstrhuh,I4,I4_MAX,VARCMP_GT); VARCMP(BSTR,bstrhuh,I4,I4_MAX,VARCMP_GT);
VARCMP(BSTR,bstr2cents,I4,2,VARCMP_GT); VARCMP(BSTR,bstr2cents,I4,2,VARCMP_GT);
VARCMPEX(BSTR,bstr2cents,I4,42,VARCMP_GT,VARCMP_LT,VARCMP_GT,VARCMP_GT); VARCMPEX(BSTR,bstr2cents,I4,42,VARCMP_GT,VARCMP_LT,VARCMP_GT,VARCMP_GT);
...@@ -6242,18 +6359,11 @@ static void test_VarCmp(void) ...@@ -6242,18 +6359,11 @@ static void test_VarCmp(void)
static HRESULT (WINAPI *pVarPow)(LPVARIANT,LPVARIANT,LPVARIANT); static HRESULT (WINAPI *pVarPow)(LPVARIANT,LPVARIANT,LPVARIANT);
static const char *szVarPowFail = "VarPow(%s,%s): expected 0x0,%s,%d, got 0x%X,%s,%d\n"; #define VARPOW(vt1,val1,vt2,val2,rvt,rval) \
V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
#define VARPOW(vt1,val1,vt2,val2,rvt,rval) \ V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
V_VT(&left) = VT_##vt1; V_VT(&right) = VT_##vt2; \ V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
V_##vt1(&left) = val1; V_##vt2(&right) = val2; \ test_var_call2( __LINE__, pVarPow, &left, &right, &exp );
memset(&result,0,sizeof(result)); \
hres = pVarPow(&left,&right,&result); \
ok(hres == S_OK && V_VT(&result) == VT_##rvt && \
EQ_DOUBLE(V_##rvt(&result),(rval)), \
szVarPowFail, vtstr(VT_##vt1), vtstr(VT_##vt2), \
vtstr(VT_##rvt), (int)(rval), hres, vtstr(V_VT(&result)), \
(int)V_##rvt(&result));
/* Skip any type that is not defined or produces a error for every case */ /* Skip any type that is not defined or produces a error for every case */
#define SKIPTESTPOW(a) \ #define SKIPTESTPOW(a) \
...@@ -6267,7 +6377,7 @@ static void test_VarPow(void) ...@@ -6267,7 +6377,7 @@ static void test_VarPow(void)
{ {
static const WCHAR str2[] = { '2','\0' }; static const WCHAR str2[] = { '2','\0' };
static const WCHAR str3[] = { '3','\0' }; static const WCHAR str3[] = { '3','\0' };
VARIANT left, right, result, cy, dec; VARIANT left, right, exp, result, cy, dec;
BSTR num2_str, num3_str; BSTR num2_str, num3_str;
VARTYPE i; VARTYPE i;
HRESULT hres; HRESULT hres;
...@@ -6753,18 +6863,11 @@ static void test_VarPow(void) ...@@ -6753,18 +6863,11 @@ static void test_VarPow(void)
static HRESULT (WINAPI *pVarDiv)(LPVARIANT,LPVARIANT,LPVARIANT); static HRESULT (WINAPI *pVarDiv)(LPVARIANT,LPVARIANT,LPVARIANT);
static const char *szVarDivFail = "VarDiv(%s,%s): expected 0x0,%s,%d, got 0x%X,%s,%d\n"; #define VARDIV(vt1,val1,vt2,val2,rvt,rval) \
V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
#define VARDIV(vt1,val1,vt2,val2,rvt,rval) \ V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
V_VT(&left) = VT_##vt1; V_VT(&right) = VT_##vt2; \ V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
V_##vt1(&left) = val1; V_##vt2(&right) = val2; \ test_var_call2( __LINE__, pVarDiv, &left, &right, &exp );
memset(&result,0,sizeof(result)); \
hres = pVarDiv(&left,&right,&result); \
ok(hres == S_OK && V_VT(&result) == VT_##rvt && \
EQ_DOUBLE(V_##rvt(&result),(rval)), \
szVarDivFail, vtstr(VT_##vt1), vtstr(VT_##vt2), \
vtstr(VT_##rvt), (int)(rval), hres, vtstr(V_VT(&result)), \
(int)V_##rvt(&result));
/* Skip any type that is not defined or produces a error for every case */ /* Skip any type that is not defined or produces a error for every case */
#define SKIPTESTDIV(a) \ #define SKIPTESTDIV(a) \
...@@ -6781,7 +6884,7 @@ static void test_VarDiv(void) ...@@ -6781,7 +6884,7 @@ static void test_VarDiv(void)
{ {
static const WCHAR str1[] = { '1','\0' }; static const WCHAR str1[] = { '1','\0' };
static const WCHAR str2[] = { '2','\0' }; static const WCHAR str2[] = { '2','\0' };
VARIANT left, right, result, cy, dec; VARIANT left, right, exp, result, cy, dec;
BSTR num1_str, num2_str; BSTR num1_str, num2_str;
VARTYPE i; VARTYPE i;
HRESULT hres, expectedhres; HRESULT hres, expectedhres;
...@@ -7100,18 +7203,11 @@ static void test_VarDiv(void) ...@@ -7100,18 +7203,11 @@ static void test_VarDiv(void)
static HRESULT (WINAPI *pVarIdiv)(LPVARIANT,LPVARIANT,LPVARIANT); static HRESULT (WINAPI *pVarIdiv)(LPVARIANT,LPVARIANT,LPVARIANT);
static const char *szVarIdivFail = "VarIdiv(%s,%s): expected 0x0,%s,%d, got 0x%X,%s,%d\n"; #define VARIDIV(vt1,val1,vt2,val2,rvt,rval) \
V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
#define VARIDIV(vt1,val1,vt2,val2,rvt,rval) \ V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
V_VT(&left) = VT_##vt1; V_VT(&right) = VT_##vt2; \ V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
V_##vt1(&left) = val1; V_##vt2(&right) = val2; \ test_var_call2( __LINE__, pVarIdiv, &left, &right, &exp );
memset(&result,0,sizeof(result)); \
hres = pVarIdiv(&left,&right,&result); \
ok(hres == S_OK && V_VT(&result) == VT_##rvt && \
V_##rvt(&result) == (rval), \
szVarIdivFail, vtstr(VT_##vt1), vtstr(VT_##vt2), \
vtstr(VT_##rvt), (int)(rval), hres, vtstr(V_VT(&result)), \
(int)V_##rvt(&result));
/* Skip any type that is not defined or produces a error for every case */ /* Skip any type that is not defined or produces a error for every case */
#define SKIPTESTIDIV(a) \ #define SKIPTESTIDIV(a) \
...@@ -7125,7 +7221,7 @@ static void test_VarIdiv(void) ...@@ -7125,7 +7221,7 @@ static void test_VarIdiv(void)
{ {
static const WCHAR str1[] = { '1','\0' }; static const WCHAR str1[] = { '1','\0' };
static const WCHAR str2[] = { '2','\0' }; static const WCHAR str2[] = { '2','\0' };
VARIANT left, right, result, cy, dec; VARIANT left, right, exp, result, cy, dec;
BSTR num1_str, num2_str; BSTR num1_str, num2_str;
VARTYPE i; VARTYPE i;
HRESULT hres; HRESULT hres;
...@@ -7611,18 +7707,11 @@ static void test_VarIdiv(void) ...@@ -7611,18 +7707,11 @@ static void test_VarIdiv(void)
static HRESULT (WINAPI *pVarImp)(LPVARIANT,LPVARIANT,LPVARIANT); static HRESULT (WINAPI *pVarImp)(LPVARIANT,LPVARIANT,LPVARIANT);
static const char *szVarImpFail = "VarImp(%s,%s): expected 0x0,%s,%d, got 0x%X,%s,%d\n"; #define VARIMP(vt1,val1,vt2,val2,rvt,rval) \
V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
#define VARIMP(vt1,val1,vt2,val2,rvt,rval) \ V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
V_VT(&left) = VT_##vt1; V_VT(&right) = VT_##vt2; \ V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
V_##vt1(&left) = val1; V_##vt2(&right) = val2; \ test_var_call2( __LINE__, pVarImp, &left, &right, &exp );
memset(&result,0,sizeof(result)); \
hres = pVarImp(&left,&right,&result); \
ok(hres == S_OK && V_VT(&result) == VT_##rvt && \
V_##rvt(&result) == (rval), \
szVarImpFail, vtstr(VT_##vt1), vtstr(VT_##vt2), \
vtstr(VT_##rvt), (int)(rval), hres, vtstr(V_VT(&result)), \
(int)V_##rvt(&result));
/* Skip any type that is not defined or produces a error for every case */ /* Skip any type that is not defined or produces a error for every case */
#define SKIPTESTIMP(a) \ #define SKIPTESTIMP(a) \
...@@ -7636,7 +7725,7 @@ static void test_VarImp(void) ...@@ -7636,7 +7725,7 @@ static void test_VarImp(void)
{ {
static const WCHAR szFalse[] = { '#','F','A','L','S','E','#','\0' }; static const WCHAR szFalse[] = { '#','F','A','L','S','E','#','\0' };
static const WCHAR szTrue[] = { '#','T','R','U','E','#','\0' }; static const WCHAR szTrue[] = { '#','T','R','U','E','#','\0' };
VARIANT left, right, result, cy, dec; VARIANT left, right, exp, result, cy, dec;
BSTR true_str, false_str; BSTR true_str, false_str;
VARTYPE i; VARTYPE i;
HRESULT hres; HRESULT hres;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment