oledb32: Add some conversions to DBTYPE_UI8.

This commit is contained in:
Huw Davies 2009-10-28 12:17:53 +00:00 committed by Alexandre Julliard
parent 21bbdb7157
commit b3cdc6d7c8
2 changed files with 85 additions and 0 deletions

View File

@ -392,6 +392,32 @@ static HRESULT WINAPI convert_DataConvert(IDataConvert* iface,
break; break;
} }
case DBTYPE_UI8:
{
ULONGLONG *d = dst;
switch(src_type)
{
case DBTYPE_EMPTY: *d = 0; hr = S_OK; break;
case DBTYPE_I2: hr = VarUI8FromI2(*(signed short*)src, d); break;
case DBTYPE_I4: {LONGLONG s = *(signed int*)src; hr = VarUI8FromI8(s, d); break;}
case DBTYPE_R4: hr = VarUI8FromR4(*(FLOAT*)src, d); break;
case DBTYPE_R8: hr = VarUI8FromR8(*(double*)src, d); break;
case DBTYPE_CY: hr = VarUI8FromCy(*(CY*)src, d); break;
case DBTYPE_DATE: hr = VarUI8FromDate(*(DATE*)src, d); break;
case DBTYPE_BSTR: hr = VarUI8FromStr(*(WCHAR**)src, LOCALE_USER_DEFAULT, 0, d); break;
case DBTYPE_BOOL: hr = VarUI8FromBool(*(VARIANT_BOOL*)src, d); break;
case DBTYPE_DECIMAL: hr = VarUI8FromDec((DECIMAL*)src, d); break;
case DBTYPE_I1: hr = VarUI8FromI1(*(signed char*)src, d); break;
case DBTYPE_UI1: hr = VarUI8FromUI1(*(BYTE*)src, d); break;
case DBTYPE_UI2: hr = VarUI8FromUI2(*(WORD*)src, d); break;
case DBTYPE_UI4: hr = VarUI8FromUI4(*(DWORD*)src, d); break;
case DBTYPE_I8: hr = VarUI8FromI8(*(LONGLONG*)src, d); break;
case DBTYPE_UI8: *d = *(ULONGLONG*)src; hr = S_OK; break;
default: FIXME("Unimplemented conversion %04x -> UI8\n", src_type); return E_NOTIMPL;
}
break;
}
case DBTYPE_FILETIME: case DBTYPE_FILETIME:
{ {
FILETIME *d = dst; FILETIME *d = dst;

View File

@ -1388,6 +1388,64 @@ static void test_converttocy(void)
IDataConvert_Release(convert); IDataConvert_Release(convert);
} }
static void test_converttoui8(void)
{
IDataConvert *convert;
HRESULT hr;
ULARGE_INTEGER 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.QuadPart = 0xcc;
hr = IDataConvert_DataConvert(convert, DBTYPE_EMPTY, DBTYPE_UI8, 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.QuadPart == 0, "got %d\n", (int)dst.QuadPart);
dst.QuadPart = 0xcc;
hr = IDataConvert_DataConvert(convert, DBTYPE_NULL, DBTYPE_UI8, 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.QuadPart == 0xcc, "dst changed\n");
dst.QuadPart = 0xcc;
*(int*)src = 1234;
hr = IDataConvert_DataConvert(convert, DBTYPE_I4, DBTYPE_UI8, 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.QuadPart == 1234, "got %d\n", (int)dst.QuadPart);
dst.QuadPart = 0xcc;
*(int*)src = -1234;
hr = IDataConvert_DataConvert(convert, DBTYPE_I4, DBTYPE_UI8, 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.QuadPart == 0xcc, "got %d\n", (int)dst.QuadPart);
dst.QuadPart = 0xcc;
((ULARGE_INTEGER*)src)->QuadPart = 1234;
hr = IDataConvert_DataConvert(convert, DBTYPE_UI8, DBTYPE_UI8, 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.QuadPart == 1234, "got %d\n", (int)dst.QuadPart);
IDataConvert_Release(convert);
}
START_TEST(convert) START_TEST(convert)
{ {
OleInitialize(NULL); OleInitialize(NULL);
@ -1404,5 +1462,6 @@ START_TEST(convert)
test_converttor4(); test_converttor4();
test_converttofiletime(); test_converttofiletime();
test_converttocy(); test_converttocy();
test_converttoui8();
OleUninitialize(); OleUninitialize();
} }