oledb32: Add some conversions to DBTYPE_UI1.
This commit is contained in:
parent
64a8eb601e
commit
deb38f467d
|
@ -285,6 +285,32 @@ static HRESULT WINAPI convert_DataConvert(IDataConvert* iface,
|
|||
break;
|
||||
}
|
||||
|
||||
case DBTYPE_UI1:
|
||||
{
|
||||
BYTE *d = dst;
|
||||
switch(src_type)
|
||||
{
|
||||
case DBTYPE_EMPTY: *d = 0; hr = S_OK; break;
|
||||
case DBTYPE_I2: hr = VarUI1FromI2(*(signed short*)src, d); break;
|
||||
case DBTYPE_I4: hr = VarUI1FromI4(*(signed int*)src, d); break;
|
||||
case DBTYPE_R4: hr = VarUI1FromR4(*(FLOAT*)src, d); break;
|
||||
case DBTYPE_R8: hr = VarUI1FromR8(*(double*)src, d); break;
|
||||
case DBTYPE_CY: hr = VarUI1FromCy(*(CY*)src, d); break;
|
||||
case DBTYPE_DATE: hr = VarUI1FromDate(*(DATE*)src, d); break;
|
||||
case DBTYPE_BSTR: hr = VarUI1FromStr(*(WCHAR**)src, LOCALE_USER_DEFAULT, 0, d); break;
|
||||
case DBTYPE_BOOL: hr = VarUI1FromBool(*(VARIANT_BOOL*)src, d); break;
|
||||
case DBTYPE_DECIMAL: hr = VarUI1FromDec((DECIMAL*)src, d); break;
|
||||
case DBTYPE_I1: hr = VarUI1FromI1(*(signed char*)src, d); break;
|
||||
case DBTYPE_UI1: *d = *(BYTE*)src; hr = S_OK; break;
|
||||
case DBTYPE_UI2: hr = VarUI1FromUI2(*(WORD*)src, d); break;
|
||||
case DBTYPE_UI4: hr = VarUI1FromUI4(*(DWORD*)src, d); break;
|
||||
case DBTYPE_I8: hr = VarUI1FromI8(*(LONGLONG*)src, d); break;
|
||||
case DBTYPE_UI8: hr = VarUI1FromUI8(*(ULONGLONG*)src, d); break;
|
||||
default: FIXME("Unimplemented conversion %04x -> UI1\n", src_type); return E_NOTIMPL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case DBTYPE_FILETIME:
|
||||
{
|
||||
FILETIME *d = dst;
|
||||
|
|
|
@ -1183,6 +1183,55 @@ static void test_converttofiletime(void)
|
|||
IDataConvert_Release(convert);
|
||||
}
|
||||
|
||||
static void test_converttoui1(void)
|
||||
{
|
||||
IDataConvert *convert;
|
||||
HRESULT hr;
|
||||
BYTE dst;
|
||||
BYTE src[20];
|
||||
DBSTATUS dst_status;
|
||||
DBLENGTH dst_len;
|
||||
|
||||
hr = CoCreateInstance(&CLSID_OLEDB_CONVERSIONLIBRARY, NULL, CLSCTX_INPROC_SERVER, &IID_IDataConvert, (void**)&convert);
|
||||
if(FAILED(hr))
|
||||
{
|
||||
win_skip("Unable to load oledb conversion library\n");
|
||||
return;
|
||||
}
|
||||
|
||||
dst = 0x12;
|
||||
hr = IDataConvert_DataConvert(convert, DBTYPE_EMPTY, DBTYPE_UI1, 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 %d\n", dst_len);
|
||||
ok(dst == 0, "got %08x\n", dst);
|
||||
|
||||
dst = 0x12;
|
||||
hr = IDataConvert_DataConvert(convert, DBTYPE_NULL, DBTYPE_UI1, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
|
||||
ok(hr == DB_E_UNSUPPORTEDCONVERSION, "got %08x\n", hr);
|
||||
ok(dst_status == DBSTATUS_E_BADACCESSOR, "got %08x\n", dst_status);
|
||||
ok(dst_len == sizeof(dst), "got %d\n", dst_len);
|
||||
ok(dst == 0x12, "got %08x\n", dst);
|
||||
|
||||
dst = 0x12;
|
||||
src[0] = 0x43;
|
||||
hr = IDataConvert_DataConvert(convert, DBTYPE_UI1, DBTYPE_UI1, 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 %d\n", dst_len);
|
||||
ok(dst == 0x43, "got %08x\n", dst);
|
||||
|
||||
dst = 0x12;
|
||||
src[0] = 0xfe;
|
||||
hr = IDataConvert_DataConvert(convert, DBTYPE_UI1, DBTYPE_UI1, 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 %d\n", dst_len);
|
||||
ok(dst == 0xfe, "got %08x\n", dst);
|
||||
|
||||
IDataConvert_Release(convert);
|
||||
}
|
||||
|
||||
START_TEST(convert)
|
||||
{
|
||||
OleInitialize(NULL);
|
||||
|
@ -1194,6 +1243,7 @@ START_TEST(convert)
|
|||
test_converttowstr();
|
||||
test_converttobyrefwstr();
|
||||
test_converttoguid();
|
||||
test_converttoui1();
|
||||
test_converttofiletime();
|
||||
OleUninitialize();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue