Commit 39166cca authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

oledb32: Add some conversions to DBTYPE_UI4;.

parent deb38f46
...@@ -311,6 +311,32 @@ static HRESULT WINAPI convert_DataConvert(IDataConvert* iface, ...@@ -311,6 +311,32 @@ static HRESULT WINAPI convert_DataConvert(IDataConvert* iface,
break; break;
} }
case DBTYPE_UI4:
{
DWORD *d = dst;
switch(src_type)
{
case DBTYPE_EMPTY: *d = 0; hr = S_OK; break;
case DBTYPE_I2: hr = VarUI4FromI2(*(signed short*)src, d); break;
case DBTYPE_I4: hr = VarUI4FromI4(*(signed int*)src, d); break;
case DBTYPE_R4: hr = VarUI4FromR4(*(FLOAT*)src, d); break;
case DBTYPE_R8: hr = VarUI4FromR8(*(double*)src, d); break;
case DBTYPE_CY: hr = VarUI4FromCy(*(CY*)src, d); break;
case DBTYPE_DATE: hr = VarUI4FromDate(*(DATE*)src, d); break;
case DBTYPE_BSTR: hr = VarUI4FromStr(*(WCHAR**)src, LOCALE_USER_DEFAULT, 0, d); break;
case DBTYPE_BOOL: hr = VarUI4FromBool(*(VARIANT_BOOL*)src, d); break;
case DBTYPE_DECIMAL: hr = VarUI4FromDec((DECIMAL*)src, d); break;
case DBTYPE_I1: hr = VarUI4FromI1(*(signed char*)src, d); break;
case DBTYPE_UI1: hr = VarUI4FromUI1(*(BYTE*)src, d); break;
case DBTYPE_UI2: hr = VarUI4FromUI2(*(WORD*)src, d); break;
case DBTYPE_UI4: *d = *(DWORD*)src; hr = S_OK; break;
case DBTYPE_I8: hr = VarUI4FromI8(*(LONGLONG*)src, d); break;
case DBTYPE_UI8: hr = VarUI4FromUI8(*(ULONGLONG*)src, d); break;
default: FIXME("Unimplemented conversion %04x -> UI1\n", src_type); return E_NOTIMPL;
}
break;
}
case DBTYPE_FILETIME: case DBTYPE_FILETIME:
{ {
FILETIME *d = dst; FILETIME *d = dst;
......
...@@ -1232,6 +1232,64 @@ static void test_converttoui1(void) ...@@ -1232,6 +1232,64 @@ static void test_converttoui1(void)
IDataConvert_Release(convert); IDataConvert_Release(convert);
} }
static void test_converttoui4(void)
{
IDataConvert *convert;
HRESULT hr;
DWORD 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 = 0x12345678;
hr = IDataConvert_DataConvert(convert, DBTYPE_EMPTY, DBTYPE_UI4, 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 = 0x12345678;
hr = IDataConvert_DataConvert(convert, DBTYPE_NULL, DBTYPE_UI4, 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 == 0x12345678, "got %08x\n", dst);
dst = 0x12345678;
*(DWORD*)src = 0x87654321;
hr = IDataConvert_DataConvert(convert, DBTYPE_UI4, DBTYPE_UI4, 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 == 0x87654321, "got %08x\n", dst);
dst = 0x12345678;
*(signed short *)src = 0x4321;
hr = IDataConvert_DataConvert(convert, DBTYPE_I2, DBTYPE_UI4, 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 == 0x4321, "got %08x\n", dst);
dst = 0x12345678;
*(signed short *)src = -1;
hr = IDataConvert_DataConvert(convert, DBTYPE_I2, DBTYPE_UI4, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
ok(hr == DB_E_ERRORSOCCURRED, "got %08x\n", hr);
todo_wine
ok(dst_status == DBSTATUS_E_SIGNMISMATCH, "got %08x\n", dst_status);
ok(dst_len == sizeof(dst), "got %d\n", dst_len);
ok(dst == 0x12345678, "got %08x\n", dst);
IDataConvert_Release(convert);
}
START_TEST(convert) START_TEST(convert)
{ {
OleInitialize(NULL); OleInitialize(NULL);
...@@ -1244,6 +1302,7 @@ START_TEST(convert) ...@@ -1244,6 +1302,7 @@ START_TEST(convert)
test_converttobyrefwstr(); test_converttobyrefwstr();
test_converttoguid(); test_converttoguid();
test_converttoui1(); test_converttoui1();
test_converttoui4();
test_converttofiletime(); test_converttofiletime();
OleUninitialize(); OleUninitialize();
} }
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