Commit 39fcf4ec authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

oleaut32/tests: Make it clear which vartypes are tested, skip calls on undefined vartype values.

parent acf22e83
...@@ -5900,89 +5900,147 @@ static void test_ErrorChangeTypeEx(void) ...@@ -5900,89 +5900,147 @@ static void test_ErrorChangeTypeEx(void)
/* VT_EMPTY */ /* VT_EMPTY */
static void test_EmptyChangeTypeEx(void) static void test_EmptyChangeTypeEx(void)
{ {
HRESULT hres;
VARIANTARG vSrc, vDst;
VARTYPE vt; VARTYPE vt;
LCID lcid; LCID lcid;
lcid = MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT); lcid = MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT);
for (vt = 0; vt <= VT_BSTR_BLOB; vt++) for (vt = VT_EMPTY; vt <= VT_BSTR_BLOB; vt++)
{ {
HRESULT hExpected = DISP_E_BADVARTYPE; HRESULT hExpected, hres;
VARIANTARG vSrc, vDst;
VariantInit(&vSrc); /* skip for undefined types */
memset(&vDst, 0, sizeof(vDst)); if ((vt == 15) || (vt > VT_VERSIONED_STREAM && vt < VT_BSTR_BLOB))
V_VT(&vDst) = VT_EMPTY; continue;
if (vt == VT_I8 || vt == VT_UI8) switch (vt)
{ {
case VT_I8:
case VT_UI8:
if (has_i8) if (has_i8)
hExpected = S_OK; hExpected = S_OK;
} else
else if (vt == VT_RECORD) hExpected = DISP_E_BADVARTYPE;
{ break;
hExpected = DISP_E_TYPEMISMATCH; case VT_RECORD:
} case VT_VARIANT:
else if (vt == VT_VARIANT || vt == VT_DISPATCH || case VT_DISPATCH:
vt == VT_UNKNOWN || vt == VT_ERROR) case VT_UNKNOWN:
{ case VT_ERROR:
hExpected = DISP_E_TYPEMISMATCH; hExpected = DISP_E_TYPEMISMATCH;
} break;
else if (vt <= VT_UINT && vt != (VARTYPE)15) case VT_EMPTY:
case VT_NULL:
case VT_I2:
case VT_I4:
case VT_R4:
case VT_R8:
case VT_CY:
case VT_DATE:
case VT_BSTR:
case VT_BOOL:
case VT_DECIMAL:
case VT_I1:
case VT_UI1:
case VT_UI2:
case VT_UI4:
case VT_INT:
case VT_UINT:
hExpected = S_OK; hExpected = S_OK;
break;
default:
hExpected = DISP_E_BADVARTYPE;
}
hres = VariantChangeTypeEx(&vDst, &vSrc, lcid, 0, vt); VariantInit(&vSrc);
V_VT(&vSrc) = VT_EMPTY;
memset(&vDst, 0, sizeof(vDst));
V_VT(&vDst) = VT_NULL;
ok(hres == hExpected && (hres != S_OK || V_VT(&vDst) == vt), hres = VariantChangeTypeEx(&vDst, &vSrc, lcid, 0, vt);
"change empty: vt %d expected 0x%08x, got 0x%08x, vt %d\n", ok(hres == hExpected, "change empty: vt %d expected 0x%08x, got 0x%08x, vt %d\n",
vt, hExpected, hres, V_VT(&vDst)); vt, hExpected, hres, V_VT(&vDst));
if(hres == S_OK) VariantClear(&vDst); if (hres == S_OK)
{
ok(V_VT(&vDst) == vt, "change empty: vt %d, got %d\n", vt, V_VT(&vDst));
VariantClear(&vDst);
}
} }
} }
/* VT_NULL */ /* VT_NULL */
static void test_NullChangeTypeEx(void) static void test_NullChangeTypeEx(void)
{ {
HRESULT hres;
VARIANTARG vSrc, vDst;
VARTYPE vt; VARTYPE vt;
LCID lcid; LCID lcid;
lcid = MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT); lcid = MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT);
for (vt = 0; vt <= VT_BSTR_BLOB; vt++) for (vt = VT_EMPTY; vt <= VT_BSTR_BLOB; vt++)
{ {
HRESULT hExpected = DISP_E_BADVARTYPE; VARIANTARG vSrc, vDst;
HRESULT hExpected, hres;
VariantInit(&vSrc); /* skip for undefined types */
V_VT(&vSrc) = VT_NULL; if ((vt == 15) || (vt > VT_VERSIONED_STREAM && vt < VT_BSTR_BLOB))
memset(&vDst, 0, sizeof(vDst)); continue;
V_VT(&vDst) = VT_EMPTY;
if (vt == VT_I8 || vt == VT_UI8) switch (vt)
{ {
if (has_i8) case VT_I8:
case VT_UI8:
if (has_i8)
hExpected = DISP_E_TYPEMISMATCH;
else
hExpected = DISP_E_BADVARTYPE;
break;
case VT_NULL:
hExpected = S_OK;
break;
case VT_EMPTY:
case VT_I2:
case VT_I4:
case VT_R4:
case VT_R8:
case VT_CY:
case VT_DATE:
case VT_BSTR:
case VT_DISPATCH:
case VT_ERROR:
case VT_BOOL:
case VT_VARIANT:
case VT_UNKNOWN:
case VT_DECIMAL:
case VT_I1:
case VT_UI1:
case VT_UI2:
case VT_UI4:
case VT_INT:
case VT_UINT:
case VT_RECORD:
hExpected = DISP_E_TYPEMISMATCH; hExpected = DISP_E_TYPEMISMATCH;
break;
default:
hExpected = DISP_E_BADVARTYPE;
} }
else if (vt == VT_RECORD)
{
hExpected = DISP_E_TYPEMISMATCH;
}
else if (vt == VT_NULL)
{
hExpected = S_OK;
}
else if (vt == VT_VARIANT || vt == VT_DISPATCH ||
vt == VT_UNKNOWN || vt == VT_ERROR ||
(vt <= VT_UINT && vt != (VARTYPE)15))
hExpected = DISP_E_TYPEMISMATCH;
hres = VariantChangeTypeEx(&vDst, &vSrc, lcid, 0, vt); VariantInit(&vSrc);
V_VT(&vSrc) = VT_NULL;
memset(&vDst, 0, sizeof(vDst));
V_VT(&vDst) = VT_EMPTY;
ok(hres == hExpected && (hres != S_OK || V_VT(&vDst) == vt), hres = VariantChangeTypeEx(&vDst, &vSrc, lcid, 0, vt);
"change null: vt %d expected 0x%08x, got 0x%08x, vt %d\n", ok(hres == hExpected, "change null: vt %d expected 0x%08x, got 0x%08x, vt %d\n",
vt, hExpected, hres, V_VT(&vDst)); vt, hExpected, hres, V_VT(&vDst));
/* should work only for VT_NULL -> VT_NULL case */
if (hres == S_OK)
ok(V_VT(&vDst) == VT_NULL, "change null: VT_NULL expected 0x%08x, got 0x%08x, vt %d\n",
hExpected, hres, V_VT(&vDst));
else
ok(V_VT(&vDst) == VT_EMPTY, "change null: vt %d expected 0x%08x, got 0x%08x, vt %d\n",
vt, hExpected, hres, V_VT(&vDst));
} }
} }
......
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