oledb32: Add some conversions to DBTYPE_R4.
This commit is contained in:
parent
39166ccab0
commit
0d3e83c1c8
|
@ -122,6 +122,7 @@ static int get_length(DBTYPE type)
|
|||
return 2;
|
||||
case DBTYPE_I4:
|
||||
case DBTYPE_UI4:
|
||||
case DBTYPE_R4:
|
||||
return 4;
|
||||
case DBTYPE_I8:
|
||||
case DBTYPE_UI8:
|
||||
|
@ -259,6 +260,32 @@ static HRESULT WINAPI convert_DataConvert(IDataConvert* iface,
|
|||
break;
|
||||
}
|
||||
|
||||
case DBTYPE_R4:
|
||||
{
|
||||
FLOAT *d = dst;
|
||||
switch(src_type)
|
||||
{
|
||||
case DBTYPE_EMPTY: *d = 0; hr = S_OK; break;
|
||||
case DBTYPE_I2: hr = VarR4FromI2(*(signed short*)src, d); break;
|
||||
case DBTYPE_I4: hr = VarR4FromI4(*(signed int*)src, d); break;
|
||||
case DBTYPE_R4: *d = *(FLOAT*)src; hr = S_OK; break;
|
||||
case DBTYPE_R8: hr = VarR4FromR8(*(double*)src, d); break;
|
||||
case DBTYPE_CY: hr = VarR4FromCy(*(CY*)src, d); break;
|
||||
case DBTYPE_DATE: hr = VarR4FromDate(*(DATE*)src, d); break;
|
||||
case DBTYPE_BSTR: hr = VarR4FromStr(*(WCHAR**)src, LOCALE_USER_DEFAULT, 0, d); break;
|
||||
case DBTYPE_BOOL: hr = VarR4FromBool(*(VARIANT_BOOL*)src, d); break;
|
||||
case DBTYPE_DECIMAL: hr = VarR4FromDec((DECIMAL*)src, d); break;
|
||||
case DBTYPE_I1: hr = VarR4FromI1(*(signed char*)src, d); break;
|
||||
case DBTYPE_UI1: hr = VarR4FromUI1(*(BYTE*)src, d); break;
|
||||
case DBTYPE_UI2: hr = VarR4FromUI2(*(WORD*)src, d); break;
|
||||
case DBTYPE_UI4: hr = VarR4FromUI4(*(DWORD*)src, d); break;
|
||||
case DBTYPE_I8: hr = VarR4FromI8(*(LONGLONG*)src, d); break;
|
||||
case DBTYPE_UI8: hr = VarR4FromUI8(*(ULONGLONG*)src, d); break;
|
||||
default: FIXME("Unimplemented conversion %04x -> R4\n", src_type); return E_NOTIMPL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case DBTYPE_BSTR:
|
||||
{
|
||||
BSTR *d = dst;
|
||||
|
@ -332,7 +359,7 @@ static HRESULT WINAPI convert_DataConvert(IDataConvert* iface,
|
|||
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;
|
||||
default: FIXME("Unimplemented conversion %04x -> UI4\n", src_type); return E_NOTIMPL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1290,6 +1290,55 @@ todo_wine
|
|||
IDataConvert_Release(convert);
|
||||
}
|
||||
|
||||
static void test_converttor4(void)
|
||||
{
|
||||
IDataConvert *convert;
|
||||
HRESULT hr;
|
||||
FLOAT 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 = 1.0;
|
||||
hr = IDataConvert_DataConvert(convert, DBTYPE_EMPTY, DBTYPE_R4, 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.0, "got %f\n", dst);
|
||||
|
||||
dst = 1.0;
|
||||
hr = IDataConvert_DataConvert(convert, DBTYPE_NULL, DBTYPE_R4, 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 == 1.0, "got %f\n", dst);
|
||||
|
||||
dst = 1.0;
|
||||
*(signed int*)src = 12345678;
|
||||
hr = IDataConvert_DataConvert(convert, DBTYPE_I4, DBTYPE_R4, 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 == 12345678.0, "got %f\n", dst);
|
||||
|
||||
dst = 1.0;
|
||||
*(FLOAT *)src = 10.0;
|
||||
hr = IDataConvert_DataConvert(convert, DBTYPE_R4, DBTYPE_R4, 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 == 10.0, "got %f\n", dst);
|
||||
|
||||
IDataConvert_Release(convert);
|
||||
}
|
||||
|
||||
START_TEST(convert)
|
||||
{
|
||||
OleInitialize(NULL);
|
||||
|
@ -1303,6 +1352,7 @@ START_TEST(convert)
|
|||
test_converttoguid();
|
||||
test_converttoui1();
|
||||
test_converttoui4();
|
||||
test_converttor4();
|
||||
test_converttofiletime();
|
||||
OleUninitialize();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue