oledb32: Implement DataConvert Variant->R8.
This commit is contained in:
parent
0ad8a18e3a
commit
d04d1f5230
|
@ -361,6 +361,11 @@ static HRESULT WINAPI convert_DataConvert(IDataConvert* iface,
|
|||
case DBTYPE_BSTR: hr = VarR8FromStr(*(WCHAR**)src, LOCALE_USER_DEFAULT, 0, d); break;
|
||||
case DBTYPE_BOOL: hr = VarR8FromBool(*(VARIANT_BOOL*)src, d); break;
|
||||
case DBTYPE_DECIMAL: hr = VarR8FromDec((DECIMAL*)src, d); break;
|
||||
case DBTYPE_VARIANT:
|
||||
VariantInit(&tmp);
|
||||
if ((hr = VariantChangeType(&tmp, (VARIANT*)src, 0, VT_R8)) == S_OK)
|
||||
*d = V_R8(&tmp);
|
||||
break;
|
||||
default: FIXME("Unimplemented conversion %04x -> R8\n", src_type); return E_NOTIMPL;
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -2276,6 +2276,59 @@ static void test_converttor4(void)
|
|||
ok(dst == 10.0, "got %f\n", dst);
|
||||
}
|
||||
|
||||
static void test_converttor8(void)
|
||||
{
|
||||
HRESULT hr;
|
||||
DOUBLE dst;
|
||||
BYTE src[20];
|
||||
DBSTATUS dst_status;
|
||||
DBLENGTH dst_len;
|
||||
VARIANT var;
|
||||
|
||||
dst = 1.0;
|
||||
dst_len = 0x1234;
|
||||
hr = IDataConvert_DataConvert(convert, DBTYPE_EMPTY, DBTYPE_R8, 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 %ld\n", dst_len);
|
||||
ok(dst == 0.0, "got %f\n", dst);
|
||||
|
||||
dst = 1.0;
|
||||
dst_len = 0x1234;
|
||||
hr = IDataConvert_DataConvert(convert, DBTYPE_NULL, DBTYPE_R8, 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 == 0x1234, "got %ld\n", dst_len);
|
||||
ok(dst == 1.0, "got %f\n", dst);
|
||||
|
||||
dst = 1.0;
|
||||
*(signed int*)src = 12345678;
|
||||
dst_len = 0x1234;
|
||||
hr = IDataConvert_DataConvert(convert, DBTYPE_I4, DBTYPE_R8, 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 %ld\n", dst_len);
|
||||
ok(dst == 12345678.0, "got %f\n", dst);
|
||||
|
||||
dst = 1.0;
|
||||
*(FLOAT *)src = 10.0;
|
||||
dst_len = 0x1234;
|
||||
hr = IDataConvert_DataConvert(convert, DBTYPE_R4, DBTYPE_R8, 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 %ld\n", dst_len);
|
||||
ok(dst == 10.0, "got %f\n", dst);
|
||||
|
||||
dst_len = dst = 0x1234;
|
||||
V_VT(&var) = VT_I2;
|
||||
V_I2(&var) = 0x4321;
|
||||
hr = IDataConvert_DataConvert(convert, DBTYPE_VARIANT, DBTYPE_R8, 0, &dst_len, &var, &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 %ld\n", dst_len);
|
||||
ok(dst == 0x4321, "got %f\n", dst);
|
||||
}
|
||||
|
||||
static void test_converttocy(void)
|
||||
{
|
||||
HRESULT hr;
|
||||
|
@ -2862,6 +2915,7 @@ START_TEST(convert)
|
|||
test_converttoui1();
|
||||
test_converttoui4();
|
||||
test_converttor4();
|
||||
test_converttor8();
|
||||
test_converttofiletime();
|
||||
test_converttocy();
|
||||
test_converttoui8();
|
||||
|
|
Loading…
Reference in New Issue