Commit d7278752 authored by Alistair Leslie-Hughes's avatar Alistair Leslie-Hughes Committed by Alexandre Julliard

oledb32: Implement GetConversionSize DBTYPE_VARIANT->DBTYPE_WSTR.

parent 489707f9
......@@ -1113,6 +1113,20 @@ static HRESULT WINAPI convert_GetConversionSize(IDataConvert* iface,
{
switch (src_type)
{
case DBTYPE_VARIANT:
{
VARIANT v;
VariantInit(&v);
if ((hr = VariantChangeType(&v, (VARIANT*)src, 0, VT_BSTR)) == S_OK)
{
*dst_len = (SysStringLen(V_BSTR(&v)) + 1) * sizeof(WCHAR);
VariantClear(&v);
}
else
return hr;
}
break;
case DBTYPE_STR:
if(src_len)
*dst_len = (*src_len + 1) * sizeof(WCHAR);
......
......@@ -2339,6 +2339,7 @@ static void test_getconversionsize(void)
BSTR str;
static WCHAR strW[] = {'t','e','s','t',0};
static char strTest[] = "test";
VARIANT var;
/* same way as CanConvert fails here */
dst_len = 0;
......@@ -2394,6 +2395,33 @@ static void test_getconversionsize(void)
hr = IDataConvert_GetConversionSize(convert, DBTYPE_STR, DBTYPE_WSTR, &src_len, &dst_len, strTest);
ok(hr == S_OK, "got 0x%08x\n", hr);
ok(dst_len == 42, "%ld\n", dst_len);
dst_len = 0;
V_VT(&var) = VT_BSTR;
V_BSTR(&var) = SysAllocString(strW);
hr = IDataConvert_GetConversionSize(convert, DBTYPE_VARIANT, DBTYPE_WSTR, NULL, &dst_len, &var);
ok(hr == S_OK, "got 0x%08x\n", hr);
ok(dst_len == 10, "%ld\n", dst_len);
VariantClear(&var);
dst_len = 0;
src_len = 20;
V_VT(&var) = VT_BSTR;
V_BSTR(&var) = SysAllocString(strW);
hr = IDataConvert_GetConversionSize(convert, DBTYPE_VARIANT, DBTYPE_WSTR, &src_len, &dst_len, &var);
ok(hr == S_OK, "got 0x%08x\n", hr);
ok(dst_len == 10, "%ld\n", dst_len);
VariantClear(&var);
dst_len = 0;
src_len = 20;
V_VT(&var) = VT_I4;
V_I4(&var) = 4;
hr = IDataConvert_GetConversionSize(convert, DBTYPE_VARIANT, DBTYPE_WSTR, &src_len, &dst_len, &var);
ok(hr == S_OK, "got 0x%08x\n", hr);
todo_wine ok(dst_len == 110, "%ld\n", dst_len);
VariantClear(&var);
}
static void test_converttovar(void)
......
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