oledb32: Add some conversions to DBTYPE_CY.
This commit is contained in:
parent
0d3e83c1c8
commit
21bbdb7157
|
@ -127,6 +127,8 @@ static int get_length(DBTYPE type)
|
|||
case DBTYPE_I8:
|
||||
case DBTYPE_UI8:
|
||||
return 8;
|
||||
case DBTYPE_CY:
|
||||
return sizeof(CY);
|
||||
case DBTYPE_BSTR:
|
||||
return sizeof(BSTR);
|
||||
case DBTYPE_FILETIME:
|
||||
|
@ -286,6 +288,32 @@ static HRESULT WINAPI convert_DataConvert(IDataConvert* iface,
|
|||
break;
|
||||
}
|
||||
|
||||
case DBTYPE_CY:
|
||||
{
|
||||
CY *d = dst;
|
||||
switch(src_type)
|
||||
{
|
||||
case DBTYPE_EMPTY: d->int64 = 0; hr = S_OK; break;
|
||||
case DBTYPE_I2: hr = VarCyFromI2(*(signed short*)src, d); break;
|
||||
case DBTYPE_I4: hr = VarCyFromI4(*(signed int*)src, d); break;
|
||||
case DBTYPE_R4: hr = VarCyFromR4(*(FLOAT*)src, d); break;
|
||||
case DBTYPE_R8: hr = VarCyFromR8(*(double*)src, d); break;
|
||||
case DBTYPE_CY: *d = *(CY*)src; hr = S_OK; break;
|
||||
case DBTYPE_DATE: hr = VarCyFromDate(*(DATE*)src, d); break;
|
||||
case DBTYPE_BSTR: hr = VarCyFromStr(*(WCHAR**)src, LOCALE_USER_DEFAULT, 0, d); break;
|
||||
case DBTYPE_BOOL: hr = VarCyFromBool(*(VARIANT_BOOL*)src, d); break;
|
||||
case DBTYPE_DECIMAL: hr = VarCyFromDec((DECIMAL*)src, d); break;
|
||||
case DBTYPE_I1: hr = VarCyFromI1(*(signed char*)src, d); break;
|
||||
case DBTYPE_UI1: hr = VarCyFromUI1(*(BYTE*)src, d); break;
|
||||
case DBTYPE_UI2: hr = VarCyFromUI2(*(WORD*)src, d); break;
|
||||
case DBTYPE_UI4: hr = VarCyFromUI4(*(DWORD*)src, d); break;
|
||||
case DBTYPE_I8: hr = VarCyFromI8(*(LONGLONG*)src, d); break;
|
||||
case DBTYPE_UI8: hr = VarCyFromUI8(*(ULONGLONG*)src, d); break;
|
||||
default: FIXME("Unimplemented conversion %04x -> CY\n", src_type); return E_NOTIMPL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case DBTYPE_BSTR:
|
||||
{
|
||||
BSTR *d = dst;
|
||||
|
|
|
@ -1339,6 +1339,55 @@ static void test_converttor4(void)
|
|||
IDataConvert_Release(convert);
|
||||
}
|
||||
|
||||
static void test_converttocy(void)
|
||||
{
|
||||
IDataConvert *convert;
|
||||
HRESULT hr;
|
||||
CY 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.int64 = 0xcc;
|
||||
hr = IDataConvert_DataConvert(convert, DBTYPE_EMPTY, DBTYPE_CY, 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(CY), "got %d\n", dst_len);
|
||||
ok(dst.int64 == 0, "didn't get 0\n");
|
||||
|
||||
dst.int64 = 0xcc;
|
||||
hr = IDataConvert_DataConvert(convert, DBTYPE_NULL, DBTYPE_CY, 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(CY), "got %d\n", dst_len);
|
||||
ok(dst.int64 == 0xcc, "dst changed\n");
|
||||
|
||||
dst.int64 = 0xcc;
|
||||
*(int*)src = 1234;
|
||||
hr = IDataConvert_DataConvert(convert, DBTYPE_I4, DBTYPE_CY, 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(CY), "got %d\n", dst_len);
|
||||
ok(dst.int64 == 12340000, "got %d\n", dst.s.Lo);
|
||||
|
||||
dst.int64 = 0xcc;
|
||||
((CY*)src)->int64 = 1234;
|
||||
hr = IDataConvert_DataConvert(convert, DBTYPE_CY, DBTYPE_CY, 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(CY), "got %d\n", dst_len);
|
||||
ok(dst.int64 == 1234, "got %d\n", dst.s.Lo);
|
||||
|
||||
IDataConvert_Release(convert);
|
||||
}
|
||||
|
||||
START_TEST(convert)
|
||||
{
|
||||
OleInitialize(NULL);
|
||||
|
@ -1354,5 +1403,6 @@ START_TEST(convert)
|
|||
test_converttoui4();
|
||||
test_converttor4();
|
||||
test_converttofiletime();
|
||||
test_converttocy();
|
||||
OleUninitialize();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue