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

oledb32: Add DBTYPE_UI2 support to DataConvert.

parent 9f333b71
......@@ -533,6 +533,31 @@ static HRESULT WINAPI convert_DataConvert(IDataConvert* iface,
}
break;
}
case DBTYPE_UI2:
{
WORD *d = dst;
switch(src_type)
{
case DBTYPE_EMPTY: *d = 0; hr = S_OK; break;
case DBTYPE_I2: hr = VarUI2FromI2(*(signed short*)src, d); break;
case DBTYPE_I4: hr = VarUI2FromI4(*(signed int*)src, d); break;
case DBTYPE_R4: hr = VarUI2FromR4(*(FLOAT*)src, d); break;
case DBTYPE_R8: hr = VarUI2FromR8(*(double*)src, d); break;
case DBTYPE_CY: hr = VarUI2FromCy(*(CY*)src, d); break;
case DBTYPE_DATE: hr = VarUI2FromDate(*(DATE*)src, d); break;
case DBTYPE_BSTR: hr = VarUI2FromStr(*(WCHAR**)src, LOCALE_USER_DEFAULT, 0, d); break;
case DBTYPE_BOOL: hr = VarUI2FromBool(*(VARIANT_BOOL*)src, d); break;
case DBTYPE_DECIMAL: hr = VarUI2FromDec((DECIMAL*)src, d); break;
case DBTYPE_I1: hr = VarUI2FromI1(*(signed char*)src, d); break;
case DBTYPE_UI1: hr = VarUI2FromUI1(*(BYTE*)src, d); break;
case DBTYPE_UI2: *d = *(WORD*)src; hr = S_OK; break;
case DBTYPE_UI4: hr = VarUI2FromUI4(*(DWORD*)src, d); break;
case DBTYPE_I8: hr = VarUI2FromI8(*(LONGLONG*)src, d); break;
case DBTYPE_UI8: hr = VarUI2FromUI8(*(ULONGLONG*)src, d); break;
default: FIXME("Unimplemented conversion %04x -> UI2\n", src_type); return E_NOTIMPL;
}
break;
}
case DBTYPE_UI4:
{
......
......@@ -610,6 +610,49 @@ todo_wine
ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
ok(dst == 10, "got %08x\n", dst);
/* */
dst_len = dst = 0x1234;
*(WORD*)src = 0x4321;
hr = IDataConvert_DataConvert(convert, DBTYPE_UI2, DBTYPE_UI2, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
ok(hr == S_OK, "got %08x\n", hr);
ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
ok(dst == 0x4321, "got %08x\n", dst);
dst_len = dst = 0x1234;
*(DWORD*)src = 0xabcd1234;
hr = IDataConvert_DataConvert(convert, DBTYPE_UI4, DBTYPE_UI2, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
todo_wine
ok(hr == DB_E_DATAOVERFLOW, "got %08x\n", hr);
ok(dst_status == DBSTATUS_E_DATAOVERFLOW, "got %08x\n", dst_status);
ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
ok(dst == 0x1234, "got %08x\n", dst);
dst_len = dst = 0x1234;
*(DWORD*)src = 0x1234abcd;
hr = IDataConvert_DataConvert(convert, DBTYPE_UI4, DBTYPE_UI2, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
todo_wine
ok(hr == DB_E_DATAOVERFLOW, "got %08x\n", hr);
ok(dst_status == DBSTATUS_E_DATAOVERFLOW, "got %08x\n", dst_status);
ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
ok(dst == 0x1234, "got %08x\n", dst);
dst_len = dst = 0x1234;
*(DWORD*)src = 0x4321;
hr = IDataConvert_DataConvert(convert, DBTYPE_UI4, DBTYPE_UI2, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
ok(hr == S_OK, "got %08x\n", hr);
ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
ok(dst == 0x4321, "got %08x\n", dst);
dst_len = dst = 0x1234;
memcpy(src, ten, sizeof(ten));
hr = IDataConvert_DataConvert(convert, DBTYPE_WSTR, DBTYPE_UI2, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, DBDATACONVERT_LENGTHFROMNTS);
ok(hr == S_OK, "got %08x\n", hr);
ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
ok(dst == 10, "got %08x\n", dst);
IDataConvert_Release(convert);
}
......
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