- Conversions between variants types of the same size should ignore
overflows. - Tests for this behaviour.
This commit is contained in:
parent
fb42af123b
commit
cbc3af8ca5
|
@ -144,8 +144,8 @@ static HMODULE hOleaut32;
|
|||
|
||||
#define TYPETEST(typ,res,fs) CHANGETYPEEX(typ); \
|
||||
ok(hres == S_OK && V_VT(&vDst) == typ && (CONV_TYPE)res == in, \
|
||||
"hres=0x%lX, type=%d (should be %d(" #typ ")), value=" fs " (should be 1)\n", \
|
||||
hres, V_VT(&vDst), typ, (CONV_TYPE)res);
|
||||
"hres=0x%lX, type=%d (should be %d(" #typ ")), value=" fs " (should be " fs ")\n", \
|
||||
hres, V_VT(&vDst), typ, (CONV_TYPE)res, in);
|
||||
#define TYPETESTI8(typ,res) CHANGETYPEEX(typ); \
|
||||
ok(hres == S_OK && V_VT(&vDst) == typ && (CONV_TYPE)res == in, \
|
||||
"hres=0x%lX, type=%d (should be %d(" #typ ")), value=%d (should be 1)\n", \
|
||||
|
@ -179,6 +179,15 @@ static HMODULE hOleaut32;
|
|||
TYPETEST(VT_I8, V_I8(&vDst), fs); \
|
||||
TYPETEST(VT_UI8, V_UI8(&vDst), fs); \
|
||||
}
|
||||
#define NEGATIVE_TYPETEST(vt, val, fs, vtneg, valneg) \
|
||||
in = -in; \
|
||||
VariantInit(&vSrc); \
|
||||
VariantInit(&vDst); \
|
||||
V_VT(&vSrc) = vt; \
|
||||
(val(&vSrc)) = in; \
|
||||
if (!IS_ANCIENT) { \
|
||||
TYPETEST(vtneg, valneg(&vDst), fs); \
|
||||
}
|
||||
|
||||
#define INITIAL_TYPETESTI8(vt, val) \
|
||||
VariantInit(&vSrc); \
|
||||
|
@ -832,6 +841,7 @@ static void test_VarI1ChangeTypeEx(void)
|
|||
{
|
||||
INITIAL_TYPETEST(VT_I1, V_I1, "%d");
|
||||
COMMON_TYPETEST;
|
||||
NEGATIVE_TYPETEST(VT_I1, V_I1, "%d", VT_UI1, V_UI1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1113,6 +1123,7 @@ static void test_VarUI1ChangeTypeEx(void)
|
|||
|
||||
INITIAL_TYPETEST(VT_UI1, V_UI1, "%d");
|
||||
COMMON_TYPETEST;
|
||||
NEGATIVE_TYPETEST(VT_UI1, V_UI1, "%d", VT_I1, V_I1);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1361,6 +1372,7 @@ static void test_VarI2ChangeTypeEx(void)
|
|||
|
||||
INITIAL_TYPETEST(VT_I2, V_I2, "%d");
|
||||
COMMON_TYPETEST;
|
||||
NEGATIVE_TYPETEST(VT_I2, V_I2, "%d", VT_UI2, V_UI2);
|
||||
}
|
||||
|
||||
#undef CONV_TYPE
|
||||
|
@ -1601,6 +1613,7 @@ static void test_VarUI2ChangeTypeEx(void)
|
|||
{
|
||||
INITIAL_TYPETEST(VT_UI2, V_UI2, "%d");
|
||||
COMMON_TYPETEST;
|
||||
NEGATIVE_TYPETEST(VT_UI2, V_UI2, "%d", VT_I2, V_I2);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1853,6 +1866,7 @@ static void test_VarI4ChangeTypeEx(void)
|
|||
|
||||
INITIAL_TYPETEST(VT_I4, V_I4, "%ld");
|
||||
COMMON_TYPETEST;
|
||||
NEGATIVE_TYPETEST(VT_I4, V_I4, "%ld", VT_UI4, V_UI4);
|
||||
}
|
||||
|
||||
#undef CONV_TYPE
|
||||
|
@ -2088,6 +2102,7 @@ static void test_VarUI4ChangeTypeEx(void)
|
|||
{
|
||||
INITIAL_TYPETEST(VT_UI4, V_UI4, "%lu");
|
||||
COMMON_TYPETEST;
|
||||
NEGATIVE_TYPETEST(VT_UI4, V_UI4, "%lu", VT_I4, V_I4);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -82,7 +82,6 @@ static inline HRESULT VARIANT_Coerce(VARIANTARG* pd, LCID lcid, USHORT wFlags,
|
|||
{
|
||||
HRESULT res = DISP_E_TYPEMISMATCH;
|
||||
VARTYPE vtFrom = V_TYPE(ps);
|
||||
BOOL bIgnoreOverflow = FALSE;
|
||||
DWORD dwFlags = 0;
|
||||
|
||||
TRACE("(%p->(%s%s),0x%08lx,0x%04x,%p->(%s%s),%s%s)\n", pd, debugstr_VT(pd),
|
||||
|
@ -117,11 +116,7 @@ static inline HRESULT VARIANT_Coerce(VARIANTARG* pd, LCID lcid, USHORT wFlags,
|
|||
if (vtFrom == VT_INT)
|
||||
vtFrom = VT_I4;
|
||||
else if (vtFrom == VT_UINT)
|
||||
{
|
||||
vtFrom = VT_UI4;
|
||||
if (vt == VT_I4)
|
||||
bIgnoreOverflow = TRUE;
|
||||
}
|
||||
|
||||
if (vt == vtFrom)
|
||||
return VariantCopy(pd, ps);
|
||||
|
@ -155,7 +150,7 @@ static inline HRESULT VARIANT_Coerce(VARIANTARG* pd, LCID lcid, USHORT wFlags,
|
|||
case VT_EMPTY: V_I1(pd) = 0; return S_OK;
|
||||
case VT_I2: return VarI1FromI2(V_I2(ps), &V_I1(pd));
|
||||
case VT_I4: return VarI1FromI4(V_I4(ps), &V_I1(pd));
|
||||
case VT_UI1: return VarI1FromUI1(V_UI1(ps), &V_I1(pd));
|
||||
case VT_UI1: V_I1(pd) = V_UI1(ps); return S_OK;
|
||||
case VT_UI2: return VarI1FromUI2(V_UI2(ps), &V_I1(pd));
|
||||
case VT_UI4: return VarI1FromUI4(V_UI4(ps), &V_I1(pd));
|
||||
case VT_I8: return VarI1FromI8(V_I8(ps), &V_I1(pd));
|
||||
|
@ -178,7 +173,7 @@ static inline HRESULT VARIANT_Coerce(VARIANTARG* pd, LCID lcid, USHORT wFlags,
|
|||
case VT_I1: return VarI2FromI1(V_I1(ps), &V_I2(pd));
|
||||
case VT_I4: return VarI2FromI4(V_I4(ps), &V_I2(pd));
|
||||
case VT_UI1: return VarI2FromUI1(V_UI1(ps), &V_I2(pd));
|
||||
case VT_UI2: return VarI2FromUI2(V_UI2(ps), &V_I2(pd));
|
||||
case VT_UI2: V_I2(pd) = V_UI2(ps); return S_OK;
|
||||
case VT_UI4: return VarI2FromUI4(V_UI4(ps), &V_I2(pd));
|
||||
case VT_I8: return VarI2FromI8(V_I8(ps), &V_I2(pd));
|
||||
case VT_UI8: return VarI2FromUI8(V_UI8(ps), &V_I2(pd));
|
||||
|
@ -201,14 +196,7 @@ static inline HRESULT VARIANT_Coerce(VARIANTARG* pd, LCID lcid, USHORT wFlags,
|
|||
case VT_I2: return VarI4FromI2(V_I2(ps), &V_I4(pd));
|
||||
case VT_UI1: return VarI4FromUI1(V_UI1(ps), &V_I4(pd));
|
||||
case VT_UI2: return VarI4FromUI2(V_UI2(ps), &V_I4(pd));
|
||||
case VT_UI4:
|
||||
if (bIgnoreOverflow)
|
||||
{
|
||||
V_VT(pd) = VT_I4;
|
||||
V_I4(pd) = V_I4(ps);
|
||||
return S_OK;
|
||||
}
|
||||
return VarI4FromUI4(V_UI4(ps), &V_I4(pd));
|
||||
case VT_UI4: V_I4(pd) = V_UI4(ps); return S_OK;
|
||||
case VT_I8: return VarI4FromI8(V_I8(ps), &V_I4(pd));
|
||||
case VT_UI8: return VarI4FromUI8(V_UI8(ps), &V_I4(pd));
|
||||
case VT_R4: return VarI4FromR4(V_R4(ps), &V_I4(pd));
|
||||
|
@ -226,7 +214,7 @@ static inline HRESULT VARIANT_Coerce(VARIANTARG* pd, LCID lcid, USHORT wFlags,
|
|||
switch (vtFrom)
|
||||
{
|
||||
case VT_EMPTY: V_UI1(pd) = 0; return S_OK;
|
||||
case VT_I1: return VarUI1FromI1(V_I1(ps), &V_UI1(pd));
|
||||
case VT_I1: V_UI1(pd) = V_I1(ps); return S_OK;
|
||||
case VT_I2: return VarUI1FromI2(V_I2(ps), &V_UI1(pd));
|
||||
case VT_I4: return VarUI1FromI4(V_I4(ps), &V_UI1(pd));
|
||||
case VT_UI2: return VarUI1FromUI2(V_UI2(ps), &V_UI1(pd));
|
||||
|
@ -249,7 +237,7 @@ static inline HRESULT VARIANT_Coerce(VARIANTARG* pd, LCID lcid, USHORT wFlags,
|
|||
{
|
||||
case VT_EMPTY: V_UI2(pd) = 0; return S_OK;
|
||||
case VT_I1: return VarUI2FromI1(V_I1(ps), &V_UI2(pd));
|
||||
case VT_I2: return VarUI2FromI2(V_I2(ps), &V_UI2(pd));
|
||||
case VT_I2: V_UI2(pd) = V_I2(ps); return S_OK;
|
||||
case VT_I4: return VarUI2FromI4(V_I4(ps), &V_UI2(pd));
|
||||
case VT_UI1: return VarUI2FromUI1(V_UI1(ps), &V_UI2(pd));
|
||||
case VT_UI4: return VarUI2FromUI4(V_UI4(ps), &V_UI2(pd));
|
||||
|
@ -272,7 +260,7 @@ static inline HRESULT VARIANT_Coerce(VARIANTARG* pd, LCID lcid, USHORT wFlags,
|
|||
case VT_EMPTY: V_UI4(pd) = 0; return S_OK;
|
||||
case VT_I1: return VarUI4FromI1(V_I1(ps), &V_UI4(pd));
|
||||
case VT_I2: return VarUI4FromI2(V_I2(ps), &V_UI4(pd));
|
||||
case VT_I4: return VarUI4FromI4(V_I4(ps), &V_UI4(pd));
|
||||
case VT_I4: V_UI4(pd) = V_I4(ps); return S_OK;
|
||||
case VT_UI1: return VarUI4FromUI1(V_UI1(ps), &V_UI4(pd));
|
||||
case VT_UI2: return VarUI4FromUI2(V_UI2(ps), &V_UI4(pd));
|
||||
case VT_I8: return VarUI4FromI8(V_I8(ps), &V_UI4(pd));
|
||||
|
@ -298,7 +286,7 @@ static inline HRESULT VARIANT_Coerce(VARIANTARG* pd, LCID lcid, USHORT wFlags,
|
|||
case VT_UI1: return VarUI8FromUI1(V_UI1(ps), &V_UI8(pd));
|
||||
case VT_UI2: return VarUI8FromUI2(V_UI2(ps), &V_UI8(pd));
|
||||
case VT_UI4: return VarUI8FromUI4(V_UI4(ps), &V_UI8(pd));
|
||||
case VT_I8: return VarUI8FromI8(V_I8(ps), &V_UI8(pd));
|
||||
case VT_I8: V_UI8(pd) = V_I8(ps); return S_OK;
|
||||
case VT_R4: return VarUI8FromR4(V_R4(ps), &V_UI8(pd));
|
||||
case VT_R8: return VarUI8FromR8(V_R8(ps), &V_UI8(pd));
|
||||
case VT_DATE: return VarUI8FromDate(V_DATE(ps), &V_UI8(pd));
|
||||
|
@ -320,7 +308,7 @@ static inline HRESULT VARIANT_Coerce(VARIANTARG* pd, LCID lcid, USHORT wFlags,
|
|||
case VT_UI1: return VarI8FromUI1(V_UI1(ps), &V_I8(pd));
|
||||
case VT_UI2: return VarI8FromUI2(V_UI2(ps), &V_I8(pd));
|
||||
case VT_UI4: return VarI8FromUI4(V_UI4(ps), &V_I8(pd));
|
||||
case VT_UI8: return VarI8FromUI8(V_I8(ps), &V_I8(pd));
|
||||
case VT_UI8: V_I8(pd) = V_UI8(ps); return S_OK;
|
||||
case VT_R4: return VarI8FromR4(V_R4(ps), &V_I8(pd));
|
||||
case VT_R8: return VarI8FromR8(V_R8(ps), &V_I8(pd));
|
||||
case VT_DATE: return VarI8FromDate(V_DATE(ps), &V_I8(pd));
|
||||
|
|
Loading…
Reference in New Issue