oleaut32: Conformance test for function variant:VarIdiv.

This commit is contained in:
Benjamin Arai 2006-09-11 16:58:36 -07:00 committed by Alexandre Julliard
parent ed64999180
commit 7e1f392a27
1 changed files with 509 additions and 0 deletions

View File

@ -7029,6 +7029,514 @@ static void test_VarDiv(void)
SysFreeString(num2_str);
}
static HRESULT (WINAPI *pVarIdiv)(LPVARIANT,LPVARIANT,LPVARIANT);
static const char *szVarIdivFail = "VarIdiv(%s,%s): expected 0x0,%s,%d, got 0x%lX,%s,%d\n";
#define VARIDIV(vt1,val1,vt2,val2,rvt,rval) \
V_VT(&left) = VT_##vt1; V_VT(&right) = VT_##vt2; \
V_##vt1(&left) = val1; V_##vt2(&right) = val2; \
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 */
#define SKIPTESTIDIV(a) \
if (a == VT_ERROR || a == VT_VARIANT || \
a == VT_DISPATCH || a == VT_UNKNOWN || \
a == VT_RECORD || a > VT_UINT || \
a == 15 /*not defined*/) \
continue;
static void test_VarIdiv(void)
{
static const WCHAR str1[] = { '1','\0' };
static const WCHAR str2[] = { '2','\0' };
VARIANT left, right, result, cy, dec;
BSTR num1_str, num2_str;
VARTYPE i;
HRESULT hres;
CHECKPTR(VarIdiv);
num1_str = SysAllocString(str1);
num2_str = SysAllocString(str2);
/* Test all possible flag/vt combinations & the resulting vt type */
for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
{
VARTYPE leftvt, rightvt, resvt;
for (leftvt = 0; leftvt <= VT_BSTR_BLOB; leftvt++)
{
SKIPTESTIDIV(leftvt);
for (rightvt = 0; rightvt <= VT_BSTR_BLOB; rightvt++)
{
BOOL bFail = FALSE;
SKIPTESTIDIV(rightvt);
/* Native crashes with extra flag VT_BYREF */
if (ExtraFlags[i] == VT_BYREF)
continue;
memset(&left, 0, sizeof(left));
memset(&right, 0, sizeof(right));
V_VT(&left) = leftvt | ExtraFlags[i];
V_VT(&right) = rightvt | ExtraFlags[i];
V_VT(&result) = VT_EMPTY;
resvt = VT_EMPTY;
if (leftvt == VT_BSTR)
V_BSTR(&left) = num2_str;
else if (leftvt == VT_DECIMAL)
{
VarDecFromR8(2.0, &V_DECIMAL(&left));
V_VT(&left) = leftvt | ExtraFlags[i];
}
/* Division by 0 is undefined */
switch(rightvt)
{
case VT_BSTR:
V_BSTR(&right) = num2_str;
break;
case VT_DECIMAL:
VarDecFromR8(2.0, &V_DECIMAL(&right));
V_VT(&right) = rightvt | ExtraFlags[i];
break;
case VT_BOOL:
V_BOOL(&right) = VARIANT_TRUE;
break;
case VT_CY:
VarCyFromI4(10000, &V_CY(&right));
V_VT(&right) = rightvt | ExtraFlags[i];
break;
case VT_I2: V_I2(&right) = 2; break;
case VT_I4: V_I4(&right) = 2; break;
case VT_R4: V_R4(&right) = 2.0; break;
case VT_R8: V_R8(&right) = 2.0; break;
case VT_DATE: V_DATE(&right) = 2; break;
case VT_I1: V_I1(&right) = 2; break;
case VT_UI1: V_UI1(&right) = 2; break;
case VT_UI2: V_UI2(&right) = 2; break;
case VT_UI4: V_UI4(&right) = 2; break;
case VT_I8: V_I8(&right) = 2; break;
case VT_UI8: V_UI8(&right) = 2; break;
case VT_INT: V_INT(&right) = 2; break;
case VT_UINT: V_UINT(&right) = 2; break;
default: break;
}
/* Native VarIdiv always returns a error when using any extra
* flags or if the variant combination is I8 and INT.
*/
if ((leftvt == VT_I8 && rightvt == VT_INT) ||
(leftvt == VT_INT && rightvt == VT_I8) ||
(rightvt == VT_EMPTY && leftvt != VT_NULL) ||
ExtraFlags[i] != 0)
bFail = TRUE;
/* Determine variant type */
else if (leftvt == VT_NULL || rightvt == VT_NULL)
resvt = VT_NULL;
else if (leftvt == VT_I8 || rightvt == VT_I8)
resvt = VT_I8;
else if (leftvt == VT_I4 || rightvt == VT_I4 ||
leftvt == VT_INT || rightvt == VT_INT ||
leftvt == VT_UINT || rightvt == VT_UINT ||
leftvt == VT_UI8 || rightvt == VT_UI8 ||
leftvt == VT_UI4 || rightvt == VT_UI4 ||
leftvt == VT_UI2 || rightvt == VT_UI2 ||
leftvt == VT_I1 || rightvt == VT_I1 ||
leftvt == VT_BSTR || rightvt == VT_BSTR ||
leftvt == VT_DATE || rightvt == VT_DATE ||
leftvt == VT_CY || rightvt == VT_CY ||
leftvt == VT_DECIMAL || rightvt == VT_DECIMAL ||
leftvt == VT_R8 || rightvt == VT_R8 ||
leftvt == VT_R4 || rightvt == VT_R4)
resvt = VT_I4;
else if (leftvt == VT_I2 || rightvt == VT_I2 ||
leftvt == VT_BOOL || rightvt == VT_BOOL ||
leftvt == VT_EMPTY)
resvt = VT_I2;
else if (leftvt == VT_UI1 || rightvt == VT_UI1)
resvt = VT_UI1;
else
bFail = TRUE;
hres = pVarIdiv(&left, &right, &result);
/* Check expected HRESULT and if result variant type is correct */
if (bFail)
ok (hres == DISP_E_BADVARTYPE || hres == DISP_E_TYPEMISMATCH ||
hres == DISP_E_DIVBYZERO,
"VarIdiv: %s|0x%X, %s|0x%X: got vt %s hr 0x%lX\n",
vtstr(leftvt), ExtraFlags[i], vtstr(rightvt), ExtraFlags[i],
vtstr(V_VT(&result)), hres);
else
ok (hres == S_OK && resvt == V_VT(&result),
"VarIdiv: %s|0x%X, %s|0x%X: expected vt %s hr 0x%lX, got vt %s hr 0x%lX\n",
vtstr(leftvt), ExtraFlags[i], vtstr(rightvt), ExtraFlags[i], vtstr(resvt),
S_OK, vtstr(V_VT(&result)), hres);
}
}
}
/* Test return values for all the good cases */
VARIDIV(EMPTY,0,NULL,0,NULL,0);
VARIDIV(EMPTY,0,I2,1,I2,0);
VARIDIV(EMPTY,0,I4,1,I4,0);
VARIDIV(EMPTY,0,R4,1.0,I4,0);
VARIDIV(EMPTY,0,R8,1.0,I4,0);
VARIDIV(EMPTY,0,DATE,1.0,I4,0);
VARIDIV(EMPTY,0,BSTR,num1_str,I4,0);
VARIDIV(EMPTY,0,BOOL,VARIANT_TRUE,I2,0);
VARIDIV(EMPTY,0,I1,1,I4,0);
VARIDIV(EMPTY,0,UI1,1,I2,0);
VARIDIV(EMPTY,0,UI2,1,I4,0);
VARIDIV(EMPTY,0,UI4,1,I4,0);
VARIDIV(EMPTY,0,I8,1,I8,0);
VARIDIV(EMPTY,0,UI8,1,I4,0);
VARIDIV(EMPTY,0,INT,1,I4,0);
VARIDIV(EMPTY,0,UINT,1,I4,0);
VARIDIV(NULL,0,EMPTY,0,NULL,0);
VARIDIV(NULL,0,NULL,0,NULL,0);
VARIDIV(NULL,0,I2,1,NULL,0);
VARIDIV(NULL,0,I4,1,NULL,0);
VARIDIV(NULL,0,R4,1,NULL,0);
VARIDIV(NULL,0,R8,1,NULL,0);
VARIDIV(NULL,0,DATE,1,NULL,0);
VARIDIV(NULL,0,BSTR,num1_str,NULL,0);
VARIDIV(NULL,0,BOOL,VARIANT_TRUE,NULL,0);
VARIDIV(NULL,0,I1,1,NULL,0);
VARIDIV(NULL,0,UI1,1,NULL,0);
VARIDIV(NULL,0,UI2,1,NULL,0);
VARIDIV(NULL,0,UI4,1,NULL,0);
VARIDIV(NULL,0,I8,1,NULL,0);
VARIDIV(NULL,0,UI8,1,NULL,0);
VARIDIV(NULL,0,INT,1,NULL,0);
VARIDIV(NULL,0,UINT,1,NULL,0);
VARIDIV(I2,2,NULL,0,NULL,0);
VARIDIV(I2,2,I2,1,I2,2);
VARIDIV(I2,2,I4,1,I4,2);
VARIDIV(I2,2,R4,1,I4,2);
VARIDIV(I2,2,R8,1,I4,2);
VARIDIV(I2,2,DATE,1,I4,2);
VARIDIV(I2,2,BSTR,num1_str,I4,2);
VARIDIV(I2,2,BOOL,VARIANT_TRUE,I2,-2);
VARIDIV(I2,2,I1,1,I4,2);
VARIDIV(I2,2,UI1,1,I2,2);
VARIDIV(I2,2,UI2,1,I4,2);
VARIDIV(I2,2,UI4,1,I4,2);
VARIDIV(I2,2,I8,1,I8,2);
VARIDIV(I2,2,UI8,1,I4,2);
VARIDIV(I2,2,INT,1,I4,2);
VARIDIV(I2,2,UINT,1,I4,2);
VARIDIV(I4,2,NULL,0,NULL,0);
VARIDIV(I4,2,I2,1,I4,2);
VARIDIV(I4,2,I4,1,I4,2);
VARIDIV(I4,2,R4,1,I4,2);
VARIDIV(I4,2,R8,1,I4,2);
VARIDIV(I4,2,DATE,1,I4,2);
VARIDIV(I4,2,BSTR,num1_str,I4,2);
VARIDIV(I4,2,BOOL,VARIANT_TRUE,I4,-2);
VARIDIV(I4,2,I1,1,I4,2);
VARIDIV(I4,2,UI1,1,I4,2);
VARIDIV(I4,2,UI2,1,I4,2);
VARIDIV(I4,2,UI4,1,I4,2);
VARIDIV(I4,2,I8,1,I8,2);
VARIDIV(I4,2,UI8,1,I4,2);
VARIDIV(I4,2,INT,1,I4,2);
VARIDIV(I4,2,UINT,1,I4,2);
VARIDIV(R4,2.0,NULL,0,NULL,0);
VARIDIV(R4,2.0,I2,1,I4,2);
VARIDIV(R4,2.0,I4,1,I4,2);
VARIDIV(R4,2.0,R4,1.0,I4,2);
VARIDIV(R4,2.0,R8,1.0,I4,2);
VARIDIV(R4,2.0,DATE,1,I4,2);
VARIDIV(R4,2.0,BSTR,num1_str,I4,2);
VARIDIV(R4,2.0,BOOL,VARIANT_TRUE,I4,-2);
VARIDIV(R4,2.0,I1,1,I4,2);
VARIDIV(R4,2.0,UI1,1,I4,2);
VARIDIV(R4,2.0,UI2,1,I4,2);
VARIDIV(R4,2.0,UI4,1,I4,2);
VARIDIV(R4,2.0,I8,1,I8,2);
VARIDIV(R4,2.0,UI8,1,I4,2);
VARIDIV(R4,2.0,INT,1,I4,2);
VARIDIV(R4,2.0,UINT,1,I4,2);
VARIDIV(R8,2.0,NULL,0,NULL,0);
VARIDIV(R8,2.0,I2,1,I4,2);
VARIDIV(R8,2.0,I4,1,I4,2);
VARIDIV(R8,2.0,R4,1,I4,2);
VARIDIV(R8,2.0,R8,1,I4,2);
VARIDIV(R8,2.0,DATE,1,I4,2);
VARIDIV(R8,2.0,BSTR,num1_str,I4,2);
VARIDIV(R8,2.0,BOOL,VARIANT_TRUE,I4,-2);
VARIDIV(R8,2.0,I1,1,I4,2);
VARIDIV(R8,2.0,UI1,1,I4,2);
VARIDIV(R8,2.0,UI2,1,I4,2);
VARIDIV(R8,2.0,UI4,1,I4,2);
VARIDIV(R8,2.0,I8,1,I8,2);
VARIDIV(R8,2.0,UI8,1,I4,2);
VARIDIV(R8,2.0,INT,1,I4,2);
VARIDIV(R8,2.0,UINT,1,I4,2);
VARIDIV(DATE,2,NULL,0,NULL,0);
VARIDIV(DATE,2,I2,1,I4,2);
VARIDIV(DATE,2,I4,1,I4,2);
VARIDIV(DATE,2,R4,1,I4,2);
VARIDIV(DATE,2,R8,1,I4,2);
VARIDIV(DATE,2,DATE,1,I4,2);
VARIDIV(DATE,2,BSTR,num1_str,I4,2);
VARIDIV(DATE,2,BOOL,VARIANT_TRUE,I4,-2);
VARIDIV(DATE,2,I1,1,I4,2);
VARIDIV(DATE,2,UI1,1,I4,2);
VARIDIV(DATE,2,UI2,1,I4,2);
VARIDIV(DATE,2,UI4,1,I4,2);
VARIDIV(DATE,2,I8,1,I8,2);
VARIDIV(DATE,2,UI8,1,I4,2);
VARIDIV(DATE,2,INT,1,I4,2);
VARIDIV(DATE,2,UINT,1,I4,2);
VARIDIV(BSTR,num2_str,NULL,0,NULL,0);
VARIDIV(BSTR,num2_str,I2,1,I4,2);
VARIDIV(BSTR,num2_str,I4,1,I4,2);
VARIDIV(BSTR,num2_str,R4,1.0,I4,2);
VARIDIV(BSTR,num2_str,R8,1.0,I4,2);
VARIDIV(BSTR,num2_str,DATE,1,I4,2);
VARIDIV(BSTR,num2_str,BSTR,num1_str,I4,2);
VARIDIV(BSTR,num2_str,BOOL,VARIANT_TRUE,I4,-2);
VARIDIV(BSTR,num2_str,I1,1,I4,2);
VARIDIV(BSTR,num2_str,UI1,1,I4,2);
VARIDIV(BSTR,num2_str,UI2,1,I4,2);
VARIDIV(BSTR,num2_str,UI4,1,I4,2);
VARIDIV(BSTR,num2_str,I8,1,I8,2);
VARIDIV(BSTR,num2_str,UI8,1,I4,2);
VARIDIV(BSTR,num2_str,INT,1,I4,2);
VARIDIV(BSTR,num2_str,UINT,1,I4,2);
VARIDIV(BOOL,VARIANT_TRUE,NULL,0,NULL,0);
VARIDIV(BOOL,VARIANT_TRUE,I2,1,I2,-1);
VARIDIV(BOOL,VARIANT_TRUE,I4,1,I4,-1);
VARIDIV(BOOL,VARIANT_TRUE,R4,1.0,I4,-1);
VARIDIV(BOOL,VARIANT_TRUE,R8,1.0,I4,-1);
VARIDIV(BOOL,VARIANT_TRUE,DATE,1,I4,-1);
VARIDIV(BOOL,VARIANT_TRUE,BSTR,num1_str,I4,-1);
VARIDIV(BOOL,VARIANT_TRUE,BOOL,VARIANT_TRUE,I2,1);
VARIDIV(BOOL,VARIANT_TRUE,I1,1,I4,-1);
VARIDIV(BOOL,VARIANT_TRUE,UI1,1,I2,-1);
VARIDIV(BOOL,VARIANT_TRUE,UI2,1,I4,-1);
VARIDIV(BOOL,VARIANT_TRUE,UI4,1,I4,-1);
VARIDIV(BOOL,VARIANT_TRUE,I8,1,I8,-1);
VARIDIV(BOOL,VARIANT_TRUE,UI8,1,I4,-1);
VARIDIV(BOOL,VARIANT_TRUE,INT,1,I4,-1);
VARIDIV(BOOL,VARIANT_TRUE,UINT,1,I4,-1);
VARIDIV(I1,2,NULL,0,NULL,0);
VARIDIV(I1,2,I2,1,I4,2);
VARIDIV(I1,2,I4,1,I4,2);
VARIDIV(I1,2,R4,1.0,I4,2);
VARIDIV(I1,2,R8,1.0,I4,2);
VARIDIV(I1,2,DATE,1,I4,2);
VARIDIV(I1,2,BSTR,num1_str,I4,2);
VARIDIV(I1,2,BOOL,VARIANT_TRUE,I4,-2);
VARIDIV(I1,2,I1,1,I4,2);
VARIDIV(I1,2,UI1,1,I4,2);
VARIDIV(I1,2,UI2,1,I4,2);
VARIDIV(I1,2,UI4,1,I4,2);
VARIDIV(I1,2,I8,1,I8,2);
VARIDIV(I1,2,UI8,1,I4,2);
VARIDIV(I1,2,INT,1,I4,2);
VARIDIV(I1,2,UINT,1,I4,2);
VARIDIV(UI1,2,NULL,0,NULL,0);
VARIDIV(UI1,2,I2,1,I2,2);
VARIDIV(UI1,2,I4,1,I4,2);
VARIDIV(UI1,2,R4,1.0,I4,2);
VARIDIV(UI1,2,R8,1.0,I4,2);
VARIDIV(UI1,2,DATE,1,I4,2);
VARIDIV(UI1,2,BSTR,num1_str,I4,2);
VARIDIV(UI1,2,BOOL,VARIANT_TRUE,I2,-2);
VARIDIV(UI1,2,I1,1,I4,2);
VARIDIV(UI1,2,UI1,1,UI1,2);
VARIDIV(UI1,2,UI2,1,I4,2);
VARIDIV(UI1,2,UI4,1,I4,2);
VARIDIV(UI1,2,I8,1,I8,2);
VARIDIV(UI1,2,UI8,1,I4,2);
VARIDIV(UI1,2,INT,1,I4,2);
VARIDIV(UI1,2,UINT,1,I4,2);
VARIDIV(UI2,2,NULL,0,NULL,0);
VARIDIV(UI2,2,I2,1,I4,2);
VARIDIV(UI2,2,I4,1,I4,2);
VARIDIV(UI2,2,R4,1.0,I4,2);
VARIDIV(UI2,2,R8,1.0,I4,2);
VARIDIV(UI2,2,DATE,1,I4,2);
VARIDIV(UI2,2,BSTR,num1_str,I4,2);
VARIDIV(UI2,2,BOOL,VARIANT_TRUE,I4,-2);
VARIDIV(UI2,2,I1,1,I4,2);
VARIDIV(UI2,2,UI1,1,I4,2);
VARIDIV(UI2,2,UI2,1,I4,2);
VARIDIV(UI2,2,UI4,1,I4,2);
VARIDIV(UI2,2,I8,1,I8,2);
VARIDIV(UI2,2,UI8,1,I4,2);
VARIDIV(UI2,2,INT,1,I4,2);
VARIDIV(UI2,2,UINT,1,I4,2);
VARIDIV(UI4,2,NULL,0,NULL,0);
VARIDIV(UI4,2,I2,1,I4,2);
VARIDIV(UI4,2,I4,1,I4,2);
VARIDIV(UI4,2,R4,1.0,I4,2);
VARIDIV(UI4,2,R8,1.0,I4,2);
VARIDIV(UI4,2,DATE,1,I4,2);
VARIDIV(UI4,2,BSTR,num1_str,I4,2);
VARIDIV(UI4,2,BOOL,VARIANT_TRUE,I4,-2);
VARIDIV(UI4,2,I1,1,I4,2);
VARIDIV(UI4,2,UI1,1,I4,2);
VARIDIV(UI4,2,UI2,1,I4,2);
VARIDIV(UI4,2,UI4,1,I4,2);
VARIDIV(UI4,2,I8,1,I8,2);
VARIDIV(UI4,2,UI8,1,I4,2);
VARIDIV(UI4,2,INT,1,I4,2);
VARIDIV(UI4,2,UINT,1,I4,2);
VARIDIV(I8,2,NULL,0,NULL,0);
VARIDIV(I8,2,I2,1,I8,2);
VARIDIV(I8,2,I4,1,I8,2);
VARIDIV(I8,2,R4,1.0,I8,2);
VARIDIV(I8,2,R8,1.0,I8,2);
VARIDIV(I8,2,DATE,1,I8,2);
VARIDIV(I8,2,BSTR,num1_str,I8,2);
VARIDIV(I8,2,BOOL,1,I8,2);
VARIDIV(I8,2,I1,1,I8,2);
VARIDIV(I8,2,UI1,1,I8,2);
VARIDIV(I8,2,UI2,1,I8,2);
VARIDIV(I8,2,UI4,1,I8,2);
VARIDIV(I8,2,I8,1,I8,2);
VARIDIV(I8,2,UI8,1,I8,2);
VARIDIV(I8,2,UINT,1,I8,2);
VARIDIV(UI8,2,NULL,0,NULL,0);
VARIDIV(UI8,2,I2,1,I4,2);
VARIDIV(UI8,2,I4,1,I4,2);
VARIDIV(UI8,2,R4,1.0,I4,2);
VARIDIV(UI8,2,R8,1.0,I4,2);
VARIDIV(UI8,2,DATE,1,I4,2);
VARIDIV(UI8,2,BSTR,num1_str,I4,2);
VARIDIV(UI8,2,BOOL,VARIANT_TRUE,I4,-2);
VARIDIV(UI8,2,I1,1,I4,2);
VARIDIV(UI8,2,UI1,1,I4,2);
VARIDIV(UI8,2,UI2,1,I4,2);
VARIDIV(UI8,2,UI4,1,I4,2);
VARIDIV(UI8,2,I8,1,I8,2);
VARIDIV(UI8,2,UI8,1,I4,2);
VARIDIV(UI8,2,INT,1,I4,2);
VARIDIV(UI8,2,UINT,1,I4,2);
VARIDIV(INT,2,NULL,0,NULL,0);
VARIDIV(INT,2,I2,1,I4,2);
VARIDIV(INT,2,I4,1,I4,2);
VARIDIV(INT,2,R4,1.0,I4,2);
VARIDIV(INT,2,R8,1.0,I4,2);
VARIDIV(INT,2,DATE,1,I4,2);
VARIDIV(INT,2,BSTR,num1_str,I4,2);
VARIDIV(INT,2,BOOL,VARIANT_TRUE,I4,-2);
VARIDIV(INT,2,I1,1,I4,2);
VARIDIV(INT,2,UI1,1,I4,2);
VARIDIV(INT,2,UI2,1,I4,2);
VARIDIV(INT,2,UI4,1,I4,2);
VARIDIV(INT,2,UI8,1,I4,2);
VARIDIV(INT,2,INT,1,I4,2);
VARIDIV(INT,2,UINT,1,I4,2);
VARIDIV(UINT,2,NULL,0,NULL,0);
VARIDIV(UINT,2,I2,1,I4,2);
VARIDIV(UINT,2,I4,1,I4,2);
VARIDIV(UINT,2,R4,1.0,I4,2);
VARIDIV(UINT,2,R8,1.0,I4,2);
VARIDIV(UINT,2,DATE,1,I4,2);
VARIDIV(UINT,2,BSTR,num1_str,I4,2);
VARIDIV(UINT,2,BOOL,VARIANT_TRUE,I4,-2);
VARIDIV(UINT,2,I1,1,I4,2);
VARIDIV(UINT,2,UI1,1,I4,2);
VARIDIV(UINT,2,UI2,1,I4,2);
VARIDIV(UINT,2,UI4,1,I4,2);
VARIDIV(UINT,2,I8,1,I8,2);
VARIDIV(UINT,2,UI8,1,I4,2);
VARIDIV(UINT,2,INT,1,I4,2);
VARIDIV(UINT,2,UINT,1,I4,2);
/* Manually test some VT_CY, VT_DECIMAL variants */
V_VT(&cy) = VT_CY;
hres = VarCyFromI4(10000, &V_CY(&cy));
ok(hres == S_OK, "VarCyFromI4 failed!\n");
V_VT(&dec) = VT_DECIMAL;
hres = VarDecFromR8(2.0, &V_DECIMAL(&dec));
ok(hres == S_OK, "VarDecFromR4 failed!\n");
memset(&left, 0, sizeof(left));
memset(&right, 0, sizeof(right));
V_VT(&left) = VT_I4;
V_I4(&left) = 100;
V_VT(&right) = VT_I8;
V_UI1(&right) = 2;
hres = VarIdiv(&cy, &cy, &result);
ok(hres == S_OK && V_VT(&result) == VT_I4,
"VARIDIV: expected coerced hres 0x%lX type VT_I4, got hres 0x%lX type %s!\n",
S_OK, hres, vtstr(V_VT(&result)));
ok(hres == S_OK && V_I4(&result) == 1,
"VARIDIV: CY value %ld, expected %d\n", V_I4(&result), 1);
hres = VarIdiv(&cy, &right, &result);
ok(hres == S_OK && V_VT(&result) == VT_I8,
"VARIDIV: expected coerced hres 0x%lX type VT_I8, got hres 0x%lX type %s!\n",
S_OK, hres, vtstr(V_VT(&result)));
ok(hres == S_OK && V_I8(&result) == 5000,
"VARIDIV: CY value %lld, expected %d\n", V_I8(&result), 5000);
hres = VarIdiv(&left, &cy, &result);
ok(hres == S_OK && V_VT(&result) == VT_I4,
"VARIDIV: expected coerced hres 0x%lX type VT_I4, got hres 0x%lX type %s!\n",
S_OK, hres, vtstr(V_VT(&result)));
ok(hres == S_OK && V_I4(&result) == 0,
"VARIDIV: CY value %ld, expected %d\n", V_I4(&result), 0);
hres = VarIdiv(&left, &dec, &result);
ok(hres == S_OK && V_VT(&result) == VT_I4,
"VARIDIV: expected coerced hres 0x%lX type VT_I4, got hres 0x%lX type %s!\n",
S_OK, hres, vtstr(V_VT(&result)));
ok(hres == S_OK && V_I4(&result) == 50,
"VARIDIV: DECIMAL value %ld, expected %d\n", V_I4(&result), 50);
hres = VarIdiv(&dec, &dec, &result);
ok(hres == S_OK && V_VT(&result) == VT_I4,
"VARIDIV: expected coerced hres 0x%lX type VT_I4, got hres 0x%lX type %s!\n",
S_OK, hres, vtstr(V_VT(&result)));
ok(hres == S_OK && V_I4(&result) == 1,
"VARIDIV: DECIMAL value %ld, expected %d\n", V_I4(&result), 1);
hres = VarIdiv(&dec, &right, &result);
ok(hres == S_OK && V_VT(&result) == VT_I8,
"VARIDIV: expected coerced hres 0x%lX type VT_I8, got hres 0x%lX type%s!\n",
S_OK, hres, vtstr(V_VT(&result)));
ok(hres == S_OK && V_I8(&result) == 1,
"VARIDIV: DECIMAL value %lld, expected %d\n", V_I8(&result), 1);
/* Check for division by zero */
V_VT(&left) = VT_INT;
V_I4(&left) = 1;
V_VT(&right) = VT_INT;
V_I4(&right) = 0;
hres = pVarIdiv(&left, &right, &result);
ok(hres == DISP_E_DIVBYZERO && V_VT(&result) == VT_EMPTY,
"VARIDIV: Division by 0 should result in DISP_E_DIVBYZERO but got 0x%lX\n", hres);
V_VT(&left) = VT_INT;
V_I4(&left) = 0;
V_VT(&right) = VT_INT;
V_I4(&right) = 0;
hres = pVarIdiv(&left, &right, &result);
ok(hres == DISP_E_DIVBYZERO && V_VT(&result) == VT_EMPTY,
"VARIDIV: Division by 0 should result in DISP_E_DIVBYZERO but got 0x%lX\n", hres);
SysFreeString(num1_str);
SysFreeString(num2_str);
}
START_TEST(vartest)
{
hOleaut32 = LoadLibraryA("oleaut32.dll");
@ -7063,4 +7571,5 @@ START_TEST(vartest)
test_VarCmp();
test_VarAnd();
test_VarDiv();
test_VarIdiv();
}