Commit 8375c8e0 authored by Francois Gouget's avatar Francois Gouget Committed by Alexandre Julliard

oleaut32/tests: Dynamically load some functions that are missing on early NT4 releases.

parent af3114a5
...@@ -29,6 +29,9 @@ ...@@ -29,6 +29,9 @@
#include "tmarshal.h" #include "tmarshal.h"
#include "tmarshal_dispids.h" #include "tmarshal_dispids.h"
static HRESULT (WINAPI *pVarAdd)(LPVARIANT,LPVARIANT,LPVARIANT);
#define ok_ole_success(hr, func) ok(hr == S_OK, #func " failed with error 0x%08lx\n", (unsigned long int)hr) #define ok_ole_success(hr, func) ok(hr == S_OK, #func " failed with error 0x%08lx\n", (unsigned long int)hr)
/* ULL suffix is not portable */ /* ULL suffix is not portable */
...@@ -481,8 +484,6 @@ static HRESULT WINAPI Widget_VariantCArray( ...@@ -481,8 +484,6 @@ static HRESULT WINAPI Widget_VariantCArray(
VARIANT values[]) VARIANT values[])
{ {
ULONG i; ULONG i;
VARIANT inc, res;
HRESULT hr;
trace("VariantCArray(%u,%p)\n", count, values); trace("VariantCArray(%u,%p)\n", count, values);
...@@ -490,11 +491,16 @@ static HRESULT WINAPI Widget_VariantCArray( ...@@ -490,11 +491,16 @@ static HRESULT WINAPI Widget_VariantCArray(
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
ok(V_VT(&values[i]) == VT_I4, "values[%d] is not VT_I4\n", i); ok(V_VT(&values[i]) == VT_I4, "values[%d] is not VT_I4\n", i);
if (pVarAdd)
{
VARIANT inc, res;
HRESULT hr;
V_VT(&inc) = VT_I4; V_VT(&inc) = VT_I4;
V_I4(&inc) = 1; V_I4(&inc) = 1;
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
VariantInit(&res); VariantInit(&res);
hr = VarAdd(&values[i], &inc, &res); hr = pVarAdd(&values[i], &inc, &res);
if (FAILED(hr)) { if (FAILED(hr)) {
ok(0, "VarAdd failed at %u with error 0x%x\n", i, hr); ok(0, "VarAdd failed at %u with error 0x%x\n", i, hr);
return hr; return hr;
...@@ -505,6 +511,9 @@ static HRESULT WINAPI Widget_VariantCArray( ...@@ -505,6 +511,9 @@ static HRESULT WINAPI Widget_VariantCArray(
return hr; return hr;
} }
} }
}
else
win_skip("VarAdd is not available\n");
return S_OK; return S_OK;
} }
...@@ -1593,6 +1602,8 @@ static void test_libattr(void) ...@@ -1593,6 +1602,8 @@ static void test_libattr(void)
START_TEST(tmarshal) START_TEST(tmarshal)
{ {
HRESULT hr; HRESULT hr;
HANDLE hOleaut32 = GetModuleHandleA("oleaut32.dll");
pVarAdd = (void*)GetProcAddress(hOleaut32, "VarAdd");
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
......
...@@ -36,12 +36,16 @@ ...@@ -36,12 +36,16 @@
# define V_U2(A) (*(A)) # define V_U2(A) (*(A))
#endif #endif
static HRESULT (WINAPI *pSafeArrayGetIID)(SAFEARRAY*,GUID*);
static HRESULT (WINAPI *pSafeArrayGetVartype)(SAFEARRAY*,VARTYPE*);
static HRESULT (WINAPI *pVarBstrCmp)(BSTR,BSTR,LCID,ULONG);
static inline SF_TYPE get_union_type(SAFEARRAY *psa) static inline SF_TYPE get_union_type(SAFEARRAY *psa)
{ {
VARTYPE vt; VARTYPE vt;
HRESULT hr; HRESULT hr;
hr = SafeArrayGetVartype(psa, &vt); hr = pSafeArrayGetVartype(psa, &vt);
if (FAILED(hr)) if (FAILED(hr))
{ {
if(psa->fFeatures & FADF_VARIANT) return SF_VARIANT; if(psa->fFeatures & FADF_VARIANT) return SF_VARIANT;
...@@ -129,7 +133,10 @@ static void check_safearray(void *buffer, LPSAFEARRAY lpsa) ...@@ -129,7 +133,10 @@ static void check_safearray(void *buffer, LPSAFEARRAY lpsa)
return; return;
} }
if(FAILED(SafeArrayGetVartype(lpsa, &vt))) if (!pSafeArrayGetVartype || !pSafeArrayGetIID)
return;
if(FAILED(pSafeArrayGetVartype(lpsa, &vt)))
vt = 0; vt = 0;
sftype = get_union_type(lpsa); sftype = get_union_type(lpsa);
...@@ -158,7 +165,7 @@ static void check_safearray(void *buffer, LPSAFEARRAY lpsa) ...@@ -158,7 +165,7 @@ static void check_safearray(void *buffer, LPSAFEARRAY lpsa)
if(sftype == SF_HAVEIID) if(sftype == SF_HAVEIID)
{ {
GUID guid; GUID guid;
SafeArrayGetIID(lpsa, &guid); pSafeArrayGetIID(lpsa, &guid);
ok(IsEqualGUID(&guid, wiresa), "guid mismatch\n"); ok(IsEqualGUID(&guid, wiresa), "guid mismatch\n");
wiresa += sizeof(GUID); wiresa += sizeof(GUID);
} }
...@@ -259,9 +266,12 @@ static void test_marshal_LPSAFEARRAY(void) ...@@ -259,9 +266,12 @@ static void test_marshal_LPSAFEARRAY(void)
init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, buffer, size, MSHCTX_DIFFERENTMACHINE); init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, buffer, size, MSHCTX_DIFFERENTMACHINE);
LPSAFEARRAY_UserUnmarshal(&umcb.Flags, buffer, &lpsa2); LPSAFEARRAY_UserUnmarshal(&umcb.Flags, buffer, &lpsa2);
ok(lpsa2 != NULL, "LPSAFEARRAY didn't unmarshal\n"); ok(lpsa2 != NULL, "LPSAFEARRAY didn't unmarshal\n");
SafeArrayGetVartype(lpsa, &vt); if (pSafeArrayGetVartype)
SafeArrayGetVartype(lpsa2, &vt2); {
pSafeArrayGetVartype(lpsa, &vt);
pSafeArrayGetVartype(lpsa2, &vt2);
ok(vt == vt2, "vts differ %x %x\n", vt, vt2); ok(vt == vt2, "vts differ %x %x\n", vt, vt2);
}
ok(lpsa2->cLocks == 0, "got lock count %u, expected 0\n", lpsa2->cLocks); ok(lpsa2->cLocks == 0, "got lock count %u, expected 0\n", lpsa2->cLocks);
init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, NULL, 0, MSHCTX_DIFFERENTMACHINE); init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, NULL, 0, MSHCTX_DIFFERENTMACHINE);
LPSAFEARRAY_UserFree(&umcb.Flags, &lpsa2); LPSAFEARRAY_UserFree(&umcb.Flags, &lpsa2);
...@@ -302,9 +312,12 @@ static void test_marshal_LPSAFEARRAY(void) ...@@ -302,9 +312,12 @@ static void test_marshal_LPSAFEARRAY(void)
init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, buffer, size, MSHCTX_DIFFERENTMACHINE); init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, buffer, size, MSHCTX_DIFFERENTMACHINE);
LPSAFEARRAY_UserUnmarshal(&umcb.Flags, buffer, &lpsa2); LPSAFEARRAY_UserUnmarshal(&umcb.Flags, buffer, &lpsa2);
ok(lpsa2 != NULL, "LPSAFEARRAY didn't unmarshal\n"); ok(lpsa2 != NULL, "LPSAFEARRAY didn't unmarshal\n");
SafeArrayGetVartype(lpsa, &vt); if (pSafeArrayGetVartype)
SafeArrayGetVartype(lpsa2, &vt2); {
pSafeArrayGetVartype(lpsa, &vt);
pSafeArrayGetVartype(lpsa2, &vt2);
ok(vt == vt2, "vts differ %x %x\n", vt, vt2); ok(vt == vt2, "vts differ %x %x\n", vt, vt2);
}
ok(lpsa2->cLocks == 0, "got lock count %u, expected 0\n", lpsa2->cLocks); ok(lpsa2->cLocks == 0, "got lock count %u, expected 0\n", lpsa2->cLocks);
init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, NULL, 0, MSHCTX_DIFFERENTMACHINE); init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, NULL, 0, MSHCTX_DIFFERENTMACHINE);
LPSAFEARRAY_UserFree(&umcb.Flags, &lpsa2); LPSAFEARRAY_UserFree(&umcb.Flags, &lpsa2);
...@@ -374,8 +387,11 @@ static void test_marshal_LPSAFEARRAY(void) ...@@ -374,8 +387,11 @@ static void test_marshal_LPSAFEARRAY(void)
hr = SafeArrayAllocData(lpsa); hr = SafeArrayAllocData(lpsa);
ok(hr == S_OK, "saad failed %08x\n", hr); ok(hr == S_OK, "saad failed %08x\n", hr);
hr = SafeArrayGetVartype(lpsa, &vt); if (pSafeArrayGetVartype)
{
hr = pSafeArrayGetVartype(lpsa, &vt);
ok(hr == E_INVALIDARG, "ret %08x\n", hr); ok(hr == E_INVALIDARG, "ret %08x\n", hr);
}
init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, NULL, 0, MSHCTX_DIFFERENTMACHINE); init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, NULL, 0, MSHCTX_DIFFERENTMACHINE);
size = LPSAFEARRAY_UserSize(&umcb.Flags, 0, &lpsa); size = LPSAFEARRAY_UserSize(&umcb.Flags, 0, &lpsa);
...@@ -455,7 +471,8 @@ static void test_marshal_LPSAFEARRAY(void) ...@@ -455,7 +471,8 @@ static void test_marshal_LPSAFEARRAY(void)
ok(hr == S_OK, "Failed to get bstr element at hres 0x%x\n", hr); ok(hr == S_OK, "Failed to get bstr element at hres 0x%x\n", hr);
if (hr == S_OK) if (hr == S_OK)
{ {
ok(VarBstrCmp(values[i], gotvalue, 0, 0) == VARCMP_EQ, "String %d does not match\n", i); if (pVarBstrCmp)
ok(pVarBstrCmp(values[i], gotvalue, 0, 0) == VARCMP_EQ, "String %d does not match\n", i);
SysFreeString(gotvalue); SysFreeString(gotvalue);
} }
} }
...@@ -480,8 +497,11 @@ static void test_marshal_LPSAFEARRAY(void) ...@@ -480,8 +497,11 @@ static void test_marshal_LPSAFEARRAY(void)
hr = SafeArrayAllocData(lpsa); hr = SafeArrayAllocData(lpsa);
ok(hr == S_OK, "saad failed %08x\n", hr); ok(hr == S_OK, "saad failed %08x\n", hr);
hr = SafeArrayGetVartype(lpsa, &vt); if (pSafeArrayGetVartype)
{
hr = pSafeArrayGetVartype(lpsa, &vt);
ok(hr == E_INVALIDARG, "ret %08x\n", hr); ok(hr == E_INVALIDARG, "ret %08x\n", hr);
}
init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, NULL, 0, MSHCTX_DIFFERENTMACHINE); init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, NULL, 0, MSHCTX_DIFFERENTMACHINE);
size = LPSAFEARRAY_UserSize(&umcb.Flags, 0, &lpsa); size = LPSAFEARRAY_UserSize(&umcb.Flags, 0, &lpsa);
...@@ -1273,9 +1293,12 @@ static void test_marshal_VARIANT(void) ...@@ -1273,9 +1293,12 @@ static void test_marshal_VARIANT(void)
SafeArrayGetUBound(V_ARRAY(&v), 1, &bound); SafeArrayGetUBound(V_ARRAY(&v), 1, &bound);
SafeArrayGetUBound(V_ARRAY(&v2), 1, &bound2); SafeArrayGetUBound(V_ARRAY(&v2), 1, &bound2);
ok(bound == bound2, "array ubounds differ\n"); ok(bound == bound2, "array ubounds differ\n");
SafeArrayGetVartype(V_ARRAY(&v), &vt); if (pSafeArrayGetVartype)
SafeArrayGetVartype(V_ARRAY(&v2), &vt2); {
pSafeArrayGetVartype(V_ARRAY(&v), &vt);
pSafeArrayGetVartype(V_ARRAY(&v2), &vt2);
ok(vt == vt2, "array vts differ %x %x\n", vt, vt2); ok(vt == vt2, "array vts differ %x %x\n", vt, vt2);
}
VARIANT_UserFree(&umcb.Flags, &v2); VARIANT_UserFree(&umcb.Flags, &v2);
HeapFree(GetProcessHeap(), 0, oldbuffer); HeapFree(GetProcessHeap(), 0, oldbuffer);
...@@ -1313,9 +1336,12 @@ static void test_marshal_VARIANT(void) ...@@ -1313,9 +1336,12 @@ static void test_marshal_VARIANT(void)
SafeArrayGetUBound(*V_ARRAYREF(&v), 1, &bound); SafeArrayGetUBound(*V_ARRAYREF(&v), 1, &bound);
SafeArrayGetUBound(*V_ARRAYREF(&v2), 1, &bound2); SafeArrayGetUBound(*V_ARRAYREF(&v2), 1, &bound2);
ok(bound == bound2, "array ubounds differ\n"); ok(bound == bound2, "array ubounds differ\n");
SafeArrayGetVartype(*V_ARRAYREF(&v), &vt); if (pSafeArrayGetVartype)
SafeArrayGetVartype(*V_ARRAYREF(&v2), &vt2); {
pSafeArrayGetVartype(*V_ARRAYREF(&v), &vt);
pSafeArrayGetVartype(*V_ARRAYREF(&v2), &vt2);
ok(vt == vt2, "array vts differ %x %x\n", vt, vt2); ok(vt == vt2, "array vts differ %x %x\n", vt, vt2);
}
VARIANT_UserFree(&umcb.Flags, &v2); VARIANT_UserFree(&umcb.Flags, &v2);
HeapFree(GetProcessHeap(), 0, oldbuffer); HeapFree(GetProcessHeap(), 0, oldbuffer);
hr = SafeArrayDestroy(lpsa); hr = SafeArrayDestroy(lpsa);
...@@ -1481,6 +1507,16 @@ static void test_marshal_VARIANT(void) ...@@ -1481,6 +1507,16 @@ static void test_marshal_VARIANT(void)
START_TEST(usrmarshal) START_TEST(usrmarshal)
{ {
HANDLE hOleaut32 = GetModuleHandleA("oleaut32.dll");
#define GETPTR(func) p##func = (void*)GetProcAddress(hOleaut32, #func)
GETPTR(SafeArrayGetIID);
GETPTR(SafeArrayGetVartype);
GETPTR(VarBstrCmp);
#undef GETPTR
if (!pSafeArrayGetIID || !pSafeArrayGetVartype)
win_skip("SafeArrayGetIID and/or SafeArrayGetVartype is not available, some tests will be skipped\n");
CoInitialize(NULL); CoInitialize(NULL);
test_marshal_LPSAFEARRAY(); test_marshal_LPSAFEARRAY();
......
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
static HMODULE hOleaut32; static HMODULE hOleaut32;
static HRESULT (WINAPI *pVarBstrCmp)(BSTR,BSTR,LCID,ULONG);
static HRESULT (WINAPI *pVarFormatNumber)(LPVARIANT,int,int,int,int,ULONG,BSTR*); static HRESULT (WINAPI *pVarFormatNumber)(LPVARIANT,int,int,int,int,ULONG,BSTR*);
static HRESULT (WINAPI *pVarFormat)(LPVARIANT,LPOLESTR,int,int,ULONG,BSTR*); static HRESULT (WINAPI *pVarFormat)(LPVARIANT,LPOLESTR,int,int,ULONG,BSTR*);
static HRESULT (WINAPI *pVarWeekdayName)(int,int,int,ULONG,BSTR*); static HRESULT (WINAPI *pVarWeekdayName)(int,int,int,ULONG,BSTR*);
...@@ -525,6 +526,8 @@ static void test_VarWeekdayName(void) ...@@ -525,6 +526,8 @@ static void test_VarWeekdayName(void)
"Null pointer: expected E_INVALIDARG, got 0x%08x\n", hres); "Null pointer: expected E_INVALIDARG, got 0x%08x\n", hres);
/* Check all combinations */ /* Check all combinations */
pVarBstrCmp = (void*)GetProcAddress(hOleaut32, "VarBstrCmp");
if (pVarBstrCmp)
for (iWeekday = 1; iWeekday <= 7; ++iWeekday) for (iWeekday = 1; iWeekday <= 7; ++iWeekday)
{ {
for (fAbbrev = 0; fAbbrev <= 1; ++fAbbrev) for (fAbbrev = 0; fAbbrev <= 1; ++fAbbrev)
...@@ -539,7 +542,7 @@ static void test_VarWeekdayName(void) ...@@ -539,7 +542,7 @@ static void test_VarWeekdayName(void)
/* Translate from 0=Sunday to 0=Monday in the modulo 7 space */ /* Translate from 0=Sunday to 0=Monday in the modulo 7 space */
firstDay = iFirstDay - 2; firstDay = iFirstDay - 2;
day = (7 + iWeekday - 1 + firstDay) % 7; day = (7 + iWeekday - 1 + firstDay) % 7;
ok(VARCMP_EQ == VarBstrCmp(out, dayNames[day][fAbbrev], ok(VARCMP_EQ == pVarBstrCmp(out, dayNames[day][fAbbrev],
LOCALE_USER_DEFAULT, 0), LOCALE_USER_DEFAULT, 0),
"VarWeekdayName(%d,%d,%d): got wrong dayname: '%s'\n", "VarWeekdayName(%d,%d,%d): got wrong dayname: '%s'\n",
iWeekday, fAbbrev, iFirstDay, buff); iWeekday, fAbbrev, iFirstDay, buff);
......
...@@ -5326,6 +5326,9 @@ static void test_VarAdd(void) ...@@ -5326,6 +5326,9 @@ static void test_VarAdd(void)
SysFreeString(rbstr); SysFreeString(rbstr);
} }
static HRESULT (WINAPI *pVarCmp)(LPVARIANT,LPVARIANT,LCID,ULONG);
static HRESULT (WINAPI *pVarCat)(LPVARIANT,LPVARIANT,LPVARIANT);
static void test_VarCat(void) static void test_VarCat(void)
{ {
LCID lcid; LCID lcid;
...@@ -5342,6 +5345,8 @@ static void test_VarCat(void) ...@@ -5342,6 +5345,8 @@ static void test_VarCat(void)
HRESULT hres; HRESULT hres;
HRESULT expected_error_num; HRESULT expected_error_num;
CHECKPTR(VarCat);
/* Set date format for testing */ /* Set date format for testing */
lcid = LOCALE_USER_DEFAULT; lcid = LOCALE_USER_DEFAULT;
GetLocaleInfo(lcid,LOCALE_SSHORTDATE,orig_date_format,128); GetLocaleInfo(lcid,LOCALE_SSHORTDATE,orig_date_format,128);
...@@ -5458,7 +5463,7 @@ static void test_VarCat(void) ...@@ -5458,7 +5463,7 @@ static void test_VarCat(void)
V_I8(&right) = 0; V_I8(&right) = 0;
} }
hres = VarCat(&left, &right, &result); hres = pVarCat(&left, &right, &result);
/* Determine the error code for the vt combination */ /* Determine the error code for the vt combination */
ok(hres == expected_error_num, ok(hres == expected_error_num,
...@@ -5485,9 +5490,10 @@ static void test_VarCat(void) ...@@ -5485,9 +5490,10 @@ static void test_VarCat(void)
V_BSTR(&left) = SysAllocString(sz12); V_BSTR(&left) = SysAllocString(sz12);
V_BSTR(&right) = SysAllocString(sz34); V_BSTR(&right) = SysAllocString(sz34);
V_BSTR(&expected) = SysAllocString(sz1234); V_BSTR(&expected) = SysAllocString(sz1234);
hres = VarCat(&left,&right,&result); hres = pVarCat(&left,&right,&result);
ok(hres == S_OK, "VarCat failed with error 0x%08x\n", hres); ok(hres == S_OK, "VarCat failed with error 0x%08x\n", hres);
ok(VarCmp(&result,&expected,lcid,0) == VARCMP_EQ, if (pVarCmp)
ok(pVarCmp(&result,&expected,lcid,0) == VARCMP_EQ,
"VarCat: VT_BSTR concat with VT_BSTR failed to return correct result\n"); "VarCat: VT_BSTR concat with VT_BSTR failed to return correct result\n");
VariantClear(&left); VariantClear(&left);
...@@ -5498,7 +5504,7 @@ static void test_VarCat(void) ...@@ -5498,7 +5504,7 @@ static void test_VarCat(void)
V_VT(&left) = VT_ERROR; V_VT(&left) = VT_ERROR;
V_VT(&right) = VT_BSTR; V_VT(&right) = VT_BSTR;
V_BSTR(&right) = SysAllocString(sz1234); V_BSTR(&right) = SysAllocString(sz1234);
hres = VarCat(&left,&right,&result); hres = pVarCat(&left,&right,&result);
ok(hres == DISP_E_TYPEMISMATCH, "VarCat should have returned DISP_E_TYPEMISMATCH instead of 0x%08x\n", hres); ok(hres == DISP_E_TYPEMISMATCH, "VarCat should have returned DISP_E_TYPEMISMATCH instead of 0x%08x\n", hres);
ok(V_VT(&result) == VT_EMPTY, ok(V_VT(&result) == VT_EMPTY,
"VarCat: VT_ERROR concat with VT_BSTR should have returned VT_EMPTY\n"); "VarCat: VT_ERROR concat with VT_BSTR should have returned VT_EMPTY\n");
...@@ -5510,7 +5516,7 @@ static void test_VarCat(void) ...@@ -5510,7 +5516,7 @@ static void test_VarCat(void)
V_VT(&left) = VT_BSTR; V_VT(&left) = VT_BSTR;
V_VT(&right) = VT_ERROR; V_VT(&right) = VT_ERROR;
V_BSTR(&left) = SysAllocString(sz1234); V_BSTR(&left) = SysAllocString(sz1234);
hres = VarCat(&left,&right,&result); hres = pVarCat(&left,&right,&result);
ok(hres == DISP_E_TYPEMISMATCH, "VarCat should have returned DISP_E_TYPEMISMATCH instead of 0x%08x\n", hres); ok(hres == DISP_E_TYPEMISMATCH, "VarCat should have returned DISP_E_TYPEMISMATCH instead of 0x%08x\n", hres);
ok(V_VT(&result) == VT_EMPTY, ok(V_VT(&result) == VT_EMPTY,
"VarCat: VT_BSTR concat with VT_ERROR should have returned VT_EMPTY\n"); "VarCat: VT_BSTR concat with VT_ERROR should have returned VT_EMPTY\n");
...@@ -5527,11 +5533,14 @@ static void test_VarCat(void) ...@@ -5527,11 +5533,14 @@ static void test_VarCat(void)
V_INT(&left) = 12; V_INT(&left) = 12;
V_BOOL(&right) = TRUE; V_BOOL(&right) = TRUE;
V_BSTR(&expected) = SysAllocString(sz12_true); V_BSTR(&expected) = SysAllocString(sz12_true);
hres = VarCat(&left,&right,&result); hres = pVarCat(&left,&right,&result);
ok(hres == S_OK, "VarCat failed with error 0x%08x\n", hres); ok(hres == S_OK, "VarCat failed with error 0x%08x\n", hres);
hres = VarCmp(&result,&expected,lcid,0); if (pVarCmp)
{
hres = pVarCmp(&result,&expected,lcid,0);
ok(hres == VARCMP_EQ, "Expected VARCMP_EQ, got %08x for %s, %s\n", ok(hres == VARCMP_EQ, "Expected VARCMP_EQ, got %08x for %s, %s\n",
hres, variantstr(&result), variantstr(&expected)); hres, variantstr(&result), variantstr(&expected));
}
VariantClear(&left); VariantClear(&left);
VariantClear(&right); VariantClear(&right);
...@@ -5544,11 +5553,14 @@ static void test_VarCat(void) ...@@ -5544,11 +5553,14 @@ static void test_VarCat(void)
V_INT(&left) = 12; V_INT(&left) = 12;
V_BOOL(&right) = FALSE; V_BOOL(&right) = FALSE;
V_BSTR(&expected) = SysAllocString(sz12_false); V_BSTR(&expected) = SysAllocString(sz12_false);
hres = VarCat(&left,&right,&result); hres = pVarCat(&left,&right,&result);
ok(hres == S_OK, "VarCat failed with error 0x%08x\n", hres); ok(hres == S_OK, "VarCat failed with error 0x%08x\n", hres);
hres = VarCmp(&result,&expected,lcid,0); if (pVarCmp)
{
hres = pVarCmp(&result,&expected,lcid,0);
ok(hres == VARCMP_EQ, "Expected VARCMP_EQ, got %08x for %s, %s\n", ok(hres == VARCMP_EQ, "Expected VARCMP_EQ, got %08x for %s, %s\n",
hres, variantstr(&result), variantstr(&expected)); hres, variantstr(&result), variantstr(&expected));
}
VariantClear(&left); VariantClear(&left);
VariantClear(&right); VariantClear(&right);
...@@ -5562,9 +5574,10 @@ static void test_VarCat(void) ...@@ -5562,9 +5574,10 @@ static void test_VarCat(void)
V_INT(&left) = 12; V_INT(&left) = 12;
V_INT(&right) = 34; V_INT(&right) = 34;
V_BSTR(&expected) = SysAllocString(sz1234); V_BSTR(&expected) = SysAllocString(sz1234);
hres = VarCat(&left,&right,&result); hres = pVarCat(&left,&right,&result);
ok(hres == S_OK, "VarCat failed with error 0x%08x\n", hres); ok(hres == S_OK, "VarCat failed with error 0x%08x\n", hres);
ok(VarCmp(&result,&expected,lcid,0) == VARCMP_EQ, if (pVarCmp)
ok(pVarCmp(&result,&expected,lcid,0) == VARCMP_EQ,
"VarCat: NUMBER concat with NUMBER returned incorrect result\n"); "VarCat: NUMBER concat with NUMBER returned incorrect result\n");
VariantClear(&left); VariantClear(&left);
...@@ -5576,9 +5589,10 @@ static void test_VarCat(void) ...@@ -5576,9 +5589,10 @@ static void test_VarCat(void)
V_VT(&right) = VT_BSTR; V_VT(&right) = VT_BSTR;
V_INT(&left) = 12; V_INT(&left) = 12;
V_BSTR(&right) = SysAllocString(sz34); V_BSTR(&right) = SysAllocString(sz34);
hres = VarCat(&left,&right,&result); hres = pVarCat(&left,&right,&result);
ok(hres == S_OK, "VarCat failed with error 0x%08x\n", hres); ok(hres == S_OK, "VarCat failed with error 0x%08x\n", hres);
ok(VarCmp(&result,&expected,lcid,0) == VARCMP_EQ, if (pVarCmp)
ok(pVarCmp(&result,&expected,lcid,0) == VARCMP_EQ,
"VarCat: NUMBER concat with VT_BSTR, incorrect result\n"); "VarCat: NUMBER concat with VT_BSTR, incorrect result\n");
VariantClear(&left); VariantClear(&left);
...@@ -5589,9 +5603,10 @@ static void test_VarCat(void) ...@@ -5589,9 +5603,10 @@ static void test_VarCat(void)
V_VT(&right) = VT_INT; V_VT(&right) = VT_INT;
V_BSTR(&left) = SysAllocString(sz12); V_BSTR(&left) = SysAllocString(sz12);
V_INT(&right) = 34; V_INT(&right) = 34;
hres = VarCat(&left,&right,&result); hres = pVarCat(&left,&right,&result);
ok(hres == S_OK, "VarCat failed with error 0x%08x\n", hres); ok(hres == S_OK, "VarCat failed with error 0x%08x\n", hres);
ok(VarCmp(&result,&expected,lcid,0) == VARCMP_EQ, if (pVarCmp)
ok(pVarCmp(&result,&expected,lcid,0) == VARCMP_EQ,
"VarCat: VT_BSTR concat with NUMBER, incorrect result\n"); "VarCat: VT_BSTR concat with NUMBER, incorrect result\n");
VariantClear(&left); VariantClear(&left);
...@@ -5608,10 +5623,11 @@ static void test_VarCat(void) ...@@ -5608,10 +5623,11 @@ static void test_VarCat(void)
V_DATE(&right) = 29494.0; V_DATE(&right) = 29494.0;
V_BSTR(&expected)= SysAllocString(sz12_date); V_BSTR(&expected)= SysAllocString(sz12_date);
V_BSTR(&expected_broken)= SysAllocString(sz12_date_broken); V_BSTR(&expected_broken)= SysAllocString(sz12_date_broken);
hres = VarCat(&left,&right,&result); hres = pVarCat(&left,&right,&result);
ok(hres == S_OK, "VarCat failed with error 0x%08x\n", hres); ok(hres == S_OK, "VarCat failed with error 0x%08x\n", hres);
ok(VarCmp(&result,&expected,lcid,0) == VARCMP_EQ || if (pVarCmp)
broken(VarCmp(&result,&expected_broken,lcid,0) == VARCMP_EQ), /* Some W98 and NT4 (intermittent) */ ok(pVarCmp(&result,&expected,lcid,0) == VARCMP_EQ ||
broken(pVarCmp(&result,&expected_broken,lcid,0) == VARCMP_EQ), /* Some W98 and NT4 (intermittent) */
"VarCat: VT_BSTR concat with VT_DATE returned incorrect result\n"); "VarCat: VT_BSTR concat with VT_DATE returned incorrect result\n");
VariantClear(&left); VariantClear(&left);
...@@ -5628,10 +5644,11 @@ static void test_VarCat(void) ...@@ -5628,10 +5644,11 @@ static void test_VarCat(void)
V_BSTR(&right) = SysAllocString(sz12); V_BSTR(&right) = SysAllocString(sz12);
V_BSTR(&expected)= SysAllocString(date_sz12); V_BSTR(&expected)= SysAllocString(date_sz12);
V_BSTR(&expected_broken)= SysAllocString(date_sz12_broken); V_BSTR(&expected_broken)= SysAllocString(date_sz12_broken);
hres = VarCat(&left,&right,&result); hres = pVarCat(&left,&right,&result);
ok(hres == S_OK, "VarCat failed with error 0x%08x\n", hres); ok(hres == S_OK, "VarCat failed with error 0x%08x\n", hres);
ok(VarCmp(&result,&expected,lcid,0) == VARCMP_EQ || if (pVarCmp)
broken(VarCmp(&result,&expected_broken,lcid,0) == VARCMP_EQ), /* Some W98 and NT4 (intermittent) */ ok(pVarCmp(&result,&expected,lcid,0) == VARCMP_EQ ||
broken(pVarCmp(&result,&expected_broken,lcid,0) == VARCMP_EQ), /* Some W98 and NT4 (intermittent) */
"VarCat: VT_DATE concat with VT_BSTR returned incorrect result\n"); "VarCat: VT_DATE concat with VT_BSTR returned incorrect result\n");
VariantClear(&left); VariantClear(&left);
...@@ -5647,9 +5664,10 @@ static void test_VarCat(void) ...@@ -5647,9 +5664,10 @@ static void test_VarCat(void)
V_BSTR(&left) = SysAllocString(sz_empty); V_BSTR(&left) = SysAllocString(sz_empty);
V_BSTR(&right) = SysAllocString(sz_empty); V_BSTR(&right) = SysAllocString(sz_empty);
V_BSTR(&expected)= SysAllocString(sz_empty); V_BSTR(&expected)= SysAllocString(sz_empty);
hres = VarCat(&left,&right,&result); hres = pVarCat(&left,&right,&result);
ok(hres == S_OK, "VarCat failed with error 0x%08x\n", hres); ok(hres == S_OK, "VarCat failed with error 0x%08x\n", hres);
ok(VarCmp(&result,&left,lcid,0) == VARCMP_EQ, if (pVarCmp)
ok(pVarCmp(&result,&left,lcid,0) == VARCMP_EQ,
"VarCat: EMPTY concat with EMPTY did not return empty VT_BSTR\n"); "VarCat: EMPTY concat with EMPTY did not return empty VT_BSTR\n");
/* Restore original date format settings */ /* Restore original date format settings */
...@@ -5665,18 +5683,18 @@ static void test_VarCat(void) ...@@ -5665,18 +5683,18 @@ static void test_VarCat(void)
V_BOOL(&left) = VARIANT_TRUE; V_BOOL(&left) = VARIANT_TRUE;
V_VT(&right) = VT_BSTR; V_VT(&right) = VT_BSTR;
V_BSTR(&right) = SysAllocStringLen(NULL,0); V_BSTR(&right) = SysAllocStringLen(NULL,0);
hres = VarCat(&left, &right, &result); hres = pVarCat(&left, &right, &result);
ok(hres == S_OK, "VarCat failed: %08x\n", hres); ok(hres == S_OK, "VarCat failed: %08x\n", hres);
if(!strcmp_wa(V_BSTR(&result), "True")) { if(!strcmp_wa(V_BSTR(&result), "True")) {
V_VT(&right) = VT_BOOL; V_VT(&right) = VT_BOOL;
V_BOOL(&right) = 100; V_BOOL(&right) = 100;
hres = VarCat(&left, &right, &result); hres = pVarCat(&left, &right, &result);
ok(hres == S_OK, "VarCat failed: %08x\n", hres); ok(hres == S_OK, "VarCat failed: %08x\n", hres);
test_bstr_var(&result, "TrueTrue"); test_bstr_var(&result, "TrueTrue");
VariantClear(&result); VariantClear(&result);
V_BOOL(&right) = VARIANT_FALSE; V_BOOL(&right) = VARIANT_FALSE;
hres = VarCat(&left, &right, &result); hres = pVarCat(&left, &right, &result);
ok(hres == S_OK, "VarCat failed: %08x\n", hres); ok(hres == S_OK, "VarCat failed: %08x\n", hres);
test_bstr_var(&result, "TrueFalse"); test_bstr_var(&result, "TrueFalse");
VariantClear(&result); VariantClear(&result);
...@@ -6363,12 +6381,12 @@ static void test_VarAnd(void) ...@@ -6363,12 +6381,12 @@ static void test_VarAnd(void)
SysFreeString(false_str); SysFreeString(false_str);
} }
static HRESULT (WINAPI *pVarCmp)(LPVARIANT,LPVARIANT,LCID,ULONG);
static void test_cmp( int line, LCID lcid, UINT flags, VARIANT *left, VARIANT *right, HRESULT result ) static void test_cmp( int line, LCID lcid, UINT flags, VARIANT *left, VARIANT *right, HRESULT result )
{ {
HRESULT hres; HRESULT hres;
CHECKPTR(VarCmp);
hres = pVarCmp(left,right,lcid,flags); hres = pVarCmp(left,right,lcid,flags);
ok_(__FILE__,line)(hres == result, "VarCmp(%s,%s): expected 0x%x, got hres=0x%x\n", ok_(__FILE__,line)(hres == result, "VarCmp(%s,%s): expected 0x%x, got hres=0x%x\n",
variantstr(left), variantstr(right), result, hres ); variantstr(left), variantstr(right), result, hres );
...@@ -8700,8 +8718,8 @@ START_TEST(vartest) ...@@ -8700,8 +8718,8 @@ START_TEST(vartest)
test_VarEqv(); test_VarEqv();
test_VarMul(); test_VarMul();
test_VarAdd(); test_VarAdd();
test_VarCmp(); /* Before test_VarCat() which needs VarCmp() */
test_VarCat(); test_VarCat();
test_VarCmp();
test_VarAnd(); test_VarAnd();
test_VarDiv(); test_VarDiv();
test_VarIdiv(); test_VarIdiv();
......
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