oledb32: Add DBTYPE_UI2 support to DataConvert.

This commit is contained in:
Alistair Leslie-Hughes 2011-06-28 20:41:04 +10:00 committed by Alexandre Julliard
parent 9f333b71b6
commit d911374b9c
2 changed files with 68 additions and 0 deletions

View file

@ -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:
{

View file

@ -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);
}