1 /* OLE DB Conversion library tests
3 * Copyright 2009 Huw Davies
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #define NONAMELESSUNION
24 #define NONAMELESSSTRUCT
36 #include "wine/test.h"
38 DEFINE_GUID(GUID_NULL
,0,0,0,0,0,0,0,0,0,0,0);
40 static void test_dcinfo(void)
47 hr
= CoCreateInstance(&CLSID_OLEDB_CONVERSIONLIBRARY
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDCInfo
, (void**)&info
);
50 win_skip("Unable to load oledb conversion library\n");
54 types
[0] = DCINFOTYPE_VERSION
;
55 hr
= IDCInfo_GetInfo(info
, 1, types
, &inf
);
56 ok(hr
== S_OK
, "got %08x\n", hr
);
58 ok(inf
->eInfoType
== DCINFOTYPE_VERSION
, "got %08x\n", inf
->eInfoType
);
59 ok(V_VT(&inf
->vData
) == VT_UI4
, "got %08x\n", V_VT(&inf
->vData
));
60 ok(V_UI4(&inf
->vData
) == 0x110, "got %08x\n", V_UI4(&inf
->vData
));
62 V_UI4(&inf
->vData
) = 0x200;
63 hr
= IDCInfo_SetInfo(info
, 1, inf
);
64 ok(hr
== S_OK
, "got %08x\n", hr
);
67 hr
= IDCInfo_GetInfo(info
, 1, types
, &inf
);
68 ok(hr
== S_OK
, "got %08x\n", hr
);
69 ok(inf
->eInfoType
== DCINFOTYPE_VERSION
, "got %08x\n", inf
->eInfoType
);
70 ok(V_VT(&inf
->vData
) == VT_UI4
, "got %08x\n", V_VT(&inf
->vData
));
71 ok(V_UI4(&inf
->vData
) == 0x200, "got %08x\n", V_UI4(&inf
->vData
));
73 V_UI4(&inf
->vData
) = 0x100;
74 hr
= IDCInfo_SetInfo(info
, 1, inf
);
75 ok(hr
== S_OK
, "got %08x\n", hr
);
78 hr
= IDCInfo_GetInfo(info
, 1, types
, &inf
);
79 ok(hr
== S_OK
, "got %08x\n", hr
);
80 ok(inf
->eInfoType
== DCINFOTYPE_VERSION
, "got %08x\n", inf
->eInfoType
);
81 ok(V_VT(&inf
->vData
) == VT_UI4
, "got %08x\n", V_VT(&inf
->vData
));
82 ok(V_UI4(&inf
->vData
) == 0x100, "got %08x\n", V_UI4(&inf
->vData
));
84 V_UI4(&inf
->vData
) = 0x500;
85 hr
= IDCInfo_SetInfo(info
, 1, inf
);
86 ok(hr
== S_OK
, "got %08x\n", hr
);
89 hr
= IDCInfo_GetInfo(info
, 1, types
, &inf
);
90 ok(hr
== S_OK
, "got %08x\n", hr
);
91 ok(inf
->eInfoType
== DCINFOTYPE_VERSION
, "got %08x\n", inf
->eInfoType
);
92 ok(V_VT(&inf
->vData
) == VT_UI4
, "got %08x\n", V_VT(&inf
->vData
));
93 ok(V_UI4(&inf
->vData
) == 0x500, "got %08x\n", V_UI4(&inf
->vData
));
95 V_UI4(&inf
->vData
) = 0xffff;
96 hr
= IDCInfo_SetInfo(info
, 1, inf
);
97 ok(hr
== S_OK
, "got %08x\n", hr
);
100 hr
= IDCInfo_GetInfo(info
, 1, types
, &inf
);
101 ok(hr
== S_OK
, "got %08x\n", hr
);
102 ok(inf
->eInfoType
== DCINFOTYPE_VERSION
, "got %08x\n", inf
->eInfoType
);
103 ok(V_VT(&inf
->vData
) == VT_UI4
, "got %08x\n", V_VT(&inf
->vData
));
104 ok(V_UI4(&inf
->vData
) == 0xffff, "got %08x\n", V_UI4(&inf
->vData
));
106 V_UI4(&inf
->vData
) = 0x12345678;
107 hr
= IDCInfo_SetInfo(info
, 1, inf
);
108 ok(hr
== S_OK
, "got %08x\n", hr
);
111 hr
= IDCInfo_GetInfo(info
, 1, types
, &inf
);
112 ok(hr
== S_OK
, "got %08x\n", hr
);
113 ok(inf
->eInfoType
== DCINFOTYPE_VERSION
, "got %08x\n", inf
->eInfoType
);
114 ok(V_VT(&inf
->vData
) == VT_UI4
, "got %08x\n", V_VT(&inf
->vData
));
115 ok(V_UI4(&inf
->vData
) == 0x12345678, "got %08x\n", V_UI4(&inf
->vData
));
117 /* Try setting a version variant of something other than VT_UI4 */
118 V_VT(&inf
->vData
) = VT_I4
;
119 V_I4(&inf
->vData
) = 0x200;
120 hr
= IDCInfo_SetInfo(info
, 1, inf
);
121 ok(hr
== DB_S_ERRORSOCCURRED
, "got %08x\n", hr
);
124 hr
= IDCInfo_GetInfo(info
, 1, types
, &inf
);
125 ok(hr
== S_OK
, "got %08x\n", hr
);
126 ok(inf
->eInfoType
== DCINFOTYPE_VERSION
, "got %08x\n", inf
->eInfoType
);
127 ok(V_VT(&inf
->vData
) == VT_UI4
, "got %08x\n", V_VT(&inf
->vData
));
128 ok(V_UI4(&inf
->vData
) == 0x12345678, "got %08x\n", V_UI4(&inf
->vData
));
131 /* More than one type */
133 hr
= IDCInfo_GetInfo(info
, 2, types
, &inf
);
134 ok(hr
== S_OK
, "got %08x\n", hr
);
135 ok(inf
[0].eInfoType
== DCINFOTYPE_VERSION
, "got %08x\n", inf
[0].eInfoType
);
136 ok(V_VT(&inf
[0].vData
) == VT_UI4
, "got %08x\n", V_VT(&inf
[0].vData
));
137 ok(V_UI4(&inf
[0].vData
) == 0x12345678, "got %08x\n", V_UI4(&inf
[0].vData
));
138 ok(inf
[1].eInfoType
== 2, "got %08x\n", inf
[1].eInfoType
);
139 ok(V_VT(&inf
[1].vData
) == VT_EMPTY
, "got %08x\n", V_VT(&inf
[1].vData
));
141 hr
= IDCInfo_SetInfo(info
, 2, inf
);
142 ok(hr
== S_OK
, "got %08x\n", hr
);
146 IDCInfo_Release(info
);
152 DWORD can_convert_to
;
155 {DBTYPE_EMPTY
, 0x63bfd9ff},
156 {DBTYPE_NULL
, 0x40001002},
157 {DBTYPE_I2
, 0x3b9fd9ff},
158 {DBTYPE_I4
, 0x3bdfd9ff},
160 {DBTYPE_R4
, 0x3b9fd9ff},
161 {DBTYPE_R8
, 0x3b9fd9ff},
162 {DBTYPE_CY
, 0x039fd97f},
163 {DBTYPE_DATE
, 0x799f99bf},
165 {DBTYPE_BSTR
, 0x7bffd9ff},
166 {DBTYPE_IDISPATCH
, 0x7bffffff},
167 {DBTYPE_ERROR
, 0x01001500},
168 {DBTYPE_BOOL
, 0x039fd9ff},
170 {DBTYPE_VARIANT
, 0x7bffffff},
171 {DBTYPE_IUNKNOWN
, 0x00003203},
172 {DBTYPE_DECIMAL
, 0x3b9fd97f},
173 {DBTYPE_I1
, 0x3b9fd9ff},
175 {DBTYPE_UI1
, 0x3b9fd9ff},
176 {DBTYPE_UI2
, 0x3b9fd9ff},
177 {DBTYPE_UI4
, 0x3bdfd9ff},
178 {DBTYPE_I8
, 0x43dfd97f},
180 {DBTYPE_UI8
, 0x43dfd97f},
181 {DBTYPE_GUID
, 0x01e01103},
182 {DBTYPE_BYTES
, 0x01fc110b},
183 {DBTYPE_STR
, 0x7bffd9ff},
185 {DBTYPE_WSTR
, 0x7bffd9ff},
186 {DBTYPE_NUMERIC
, 0x039fd97f},
187 {DBTYPE_UDT
, 0x00000000},
188 {DBTYPE_DBDATE
, 0x79801183},
190 {DBTYPE_DBTIME
, 0x79801183},
191 {DBTYPE_DBTIMESTAMP
, 0x79801183},
192 {DBTYPE_FILETIME
, 0x79981183}
196 static inline BOOL
array_type(DBTYPE type
)
198 return (type
>= DBTYPE_I2
&& type
<= DBTYPE_UI4
);
201 static void test_canconvert(void)
203 IDataConvert
*convert
;
205 int src_idx
, dst_idx
;
207 hr
= CoCreateInstance(&CLSID_OLEDB_CONVERSIONLIBRARY
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDataConvert
, (void**)&convert
);
210 win_skip("Unable to load oledb conversion library\n");
214 /* Some older versions of the library don't support several conversions, we'll skip
215 if we have such a library */
216 hr
= IDataConvert_CanConvert(convert
, DBTYPE_EMPTY
, DBTYPE_DBTIMESTAMP
);
219 win_skip("Doesn't handle DBTYPE_EMPTY -> DBTYPE_DBTIMESTAMP conversion so skipping\n");
220 IDataConvert_Release(convert
);
224 /* Some older versions of the library don't support several conversions, we'll skip
225 if we have such a library */
226 hr
= IDataConvert_CanConvert(convert
, DBTYPE_EMPTY
, DBTYPE_DBTIMESTAMP
);
229 win_skip("Doesn't handle DBTYPE_EMPTY -> DBTYPE_DBTIMESTAMP conversion so skipping\n");
230 IDataConvert_Release(convert
);
234 for(src_idx
= 0; src_idx
< sizeof(simple_convert
) / sizeof(simple_convert
[0]); src_idx
++)
235 for(dst_idx
= 0; dst_idx
< sizeof(simple_convert
) / sizeof(simple_convert
[0]); dst_idx
++)
237 BOOL expect
, simple_expect
;
238 simple_expect
= (simple_convert
[src_idx
].can_convert_to
>> dst_idx
) & 1;
240 hr
= IDataConvert_CanConvert(convert
, simple_convert
[src_idx
].type
, simple_convert
[dst_idx
].type
);
241 expect
= simple_expect
;
242 ok((hr
== S_OK
&& expect
== TRUE
) ||
243 (hr
== S_FALSE
&& expect
== FALSE
),
244 "%04x -> %04x: got %08x expect conversion to be %spossible\n", simple_convert
[src_idx
].type
,
245 simple_convert
[dst_idx
].type
, hr
, expect
? "" : "not ");
247 /* src DBTYPE_BYREF */
248 hr
= IDataConvert_CanConvert(convert
, simple_convert
[src_idx
].type
| DBTYPE_BYREF
, simple_convert
[dst_idx
].type
);
249 expect
= simple_expect
;
250 ok((hr
== S_OK
&& expect
== TRUE
) ||
251 (hr
== S_FALSE
&& expect
== FALSE
),
252 "%04x -> %04x: got %08x expect conversion to be %spossible\n", simple_convert
[src_idx
].type
| DBTYPE_BYREF
,
253 simple_convert
[dst_idx
].type
, hr
, expect
? "" : "not ");
255 /* dst DBTYPE_BYREF */
256 hr
= IDataConvert_CanConvert(convert
, simple_convert
[src_idx
].type
, simple_convert
[dst_idx
].type
| DBTYPE_BYREF
);
259 (simple_convert
[dst_idx
].type
== DBTYPE_BYTES
||
260 simple_convert
[dst_idx
].type
== DBTYPE_STR
||
261 simple_convert
[dst_idx
].type
== DBTYPE_WSTR
))
263 ok((hr
== S_OK
&& expect
== TRUE
) ||
264 (hr
== S_FALSE
&& expect
== FALSE
),
265 "%04x -> %04x: got %08x expect conversion to be %spossible\n", simple_convert
[src_idx
].type
,
266 simple_convert
[dst_idx
].type
| DBTYPE_BYREF
, hr
, expect
? "" : "not ");
268 /* src & dst DBTYPE_BYREF */
269 hr
= IDataConvert_CanConvert(convert
, simple_convert
[src_idx
].type
| DBTYPE_BYREF
, simple_convert
[dst_idx
].type
| DBTYPE_BYREF
);
272 (simple_convert
[dst_idx
].type
== DBTYPE_BYTES
||
273 simple_convert
[dst_idx
].type
== DBTYPE_STR
||
274 simple_convert
[dst_idx
].type
== DBTYPE_WSTR
))
276 ok((hr
== S_OK
&& expect
== TRUE
) ||
277 (hr
== S_FALSE
&& expect
== FALSE
),
278 "%04x -> %04x: got %08x expect conversion to be %spossible\n", simple_convert
[src_idx
].type
| DBTYPE_BYREF
,
279 simple_convert
[dst_idx
].type
| DBTYPE_BYREF
, hr
, expect
? "" : "not ");
281 /* src DBTYPE_ARRAY */
282 hr
= IDataConvert_CanConvert(convert
, simple_convert
[src_idx
].type
| DBTYPE_ARRAY
, simple_convert
[dst_idx
].type
);
284 if(array_type(simple_convert
[src_idx
].type
) && simple_convert
[dst_idx
].type
== DBTYPE_VARIANT
)
286 ok((hr
== S_OK
&& expect
== TRUE
) ||
287 (hr
== S_FALSE
&& expect
== FALSE
),
288 "%04x -> %04x: got %08x expect conversion to be %spossible\n", simple_convert
[src_idx
].type
| DBTYPE_ARRAY
,
289 simple_convert
[dst_idx
].type
, hr
, expect
? "" : "not ");
291 /* dst DBTYPE_ARRAY */
292 hr
= IDataConvert_CanConvert(convert
, simple_convert
[src_idx
].type
, simple_convert
[dst_idx
].type
| DBTYPE_ARRAY
);
294 if(array_type(simple_convert
[dst_idx
].type
) &&
295 (simple_convert
[src_idx
].type
== DBTYPE_IDISPATCH
||
296 simple_convert
[src_idx
].type
== DBTYPE_VARIANT
))
298 ok((hr
== S_OK
&& expect
== TRUE
) ||
299 (hr
== S_FALSE
&& expect
== FALSE
),
300 "%04x -> %04x: got %08x expect conversion to be %spossible\n", simple_convert
[src_idx
].type
,
301 simple_convert
[dst_idx
].type
| DBTYPE_ARRAY
, hr
, expect
? "" : "not ");
303 /* src & dst DBTYPE_ARRAY */
304 hr
= IDataConvert_CanConvert(convert
, simple_convert
[src_idx
].type
| DBTYPE_ARRAY
, simple_convert
[dst_idx
].type
| DBTYPE_ARRAY
);
306 if(array_type(simple_convert
[src_idx
].type
) &&
307 simple_convert
[src_idx
].type
== simple_convert
[dst_idx
].type
)
309 ok((hr
== S_OK
&& expect
== TRUE
) ||
310 (hr
== S_FALSE
&& expect
== FALSE
),
311 "%04x -> %04x: got %08x expect conversion to be %spossible\n", simple_convert
[src_idx
].type
| DBTYPE_ARRAY
,
312 simple_convert
[dst_idx
].type
| DBTYPE_ARRAY
, hr
, expect
? "" : "not ");
314 /* src DBTYPE_VECTOR */
315 hr
= IDataConvert_CanConvert(convert
, simple_convert
[src_idx
].type
| DBTYPE_VECTOR
, simple_convert
[dst_idx
].type
);
317 ok((hr
== S_OK
&& expect
== TRUE
) ||
318 (hr
== S_FALSE
&& expect
== FALSE
),
319 "%04x -> %04x: got %08x expect conversion to be %spossible\n", simple_convert
[src_idx
].type
| DBTYPE_VECTOR
,
320 simple_convert
[dst_idx
].type
, hr
, expect
? "" : "not ");
322 /* dst DBTYPE_VECTOR */
323 hr
= IDataConvert_CanConvert(convert
, simple_convert
[src_idx
].type
, simple_convert
[dst_idx
].type
| DBTYPE_VECTOR
);
325 ok((hr
== S_OK
&& expect
== TRUE
) ||
326 (hr
== S_FALSE
&& expect
== FALSE
),
327 "%04x -> %04x: got %08x expect conversion to be %spossible\n", simple_convert
[src_idx
].type
,
328 simple_convert
[dst_idx
].type
| DBTYPE_VECTOR
, hr
, expect
? "" : "not ");
330 /* src & dst DBTYPE_VECTOR */
331 hr
= IDataConvert_CanConvert(convert
, simple_convert
[src_idx
].type
| DBTYPE_VECTOR
, simple_convert
[dst_idx
].type
| DBTYPE_VECTOR
);
333 ok((hr
== S_OK
&& expect
== TRUE
) ||
334 (hr
== S_FALSE
&& expect
== FALSE
),
335 "%04x -> %04x: got %08x expect conversion to be %spossible\n", simple_convert
[src_idx
].type
| DBTYPE_VECTOR
,
336 simple_convert
[dst_idx
].type
| DBTYPE_VECTOR
, hr
, expect
? "" : "not ");
341 IDataConvert_Release(convert
);
344 static void test_converttoi2(void)
346 IDataConvert
*convert
;
352 static const WCHAR ten
[] = {'1','0',0};
355 hr
= CoCreateInstance(&CLSID_OLEDB_CONVERSIONLIBRARY
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDataConvert
, (void**)&convert
);
358 win_skip("Unable to load oledb conversion library\n");
363 hr
= IDataConvert_DataConvert(convert
, DBTYPE_EMPTY
, DBTYPE_I2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
364 ok(hr
== S_OK
, "got %08x\n", hr
);
365 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
366 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
367 ok(dst
== 0, "got %08x\n", dst
);
370 hr
= IDataConvert_DataConvert(convert
, DBTYPE_NULL
, DBTYPE_I2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
371 ok(hr
== DB_E_UNSUPPORTEDCONVERSION
, "got %08x\n", hr
);
372 ok(dst_status
== DBSTATUS_E_BADACCESSOR
, "got %08x\n", dst_status
);
373 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
374 ok(dst
== 0x1234, "got %08x\n", dst
);
377 *(short *)src
= 0x4321;
378 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I2
, DBTYPE_I2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
379 ok(hr
== S_OK
, "got %08x\n", hr
);
380 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
381 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
382 ok(dst
== 0x4321, "got %08x\n", dst
);
385 *(int *)src
= 0x4321cafe;
386 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I4
, DBTYPE_I2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
388 ok(hr
== DB_E_DATAOVERFLOW
, "got %08x\n", hr
);
389 ok(dst_status
== DBSTATUS_E_DATAOVERFLOW
, "got %08x\n", dst_status
);
390 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
391 ok(dst
== 0x1234, "got %08x\n", dst
);
394 *(int *)src
= 0x4321;
395 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I4
, DBTYPE_I2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
396 ok(hr
== S_OK
, "got %08x\n", hr
);
397 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
398 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
399 ok(dst
== 0x4321, "got %08x\n", dst
);
402 *(FLOAT
*)src
= 10.75;
403 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R4
, DBTYPE_I2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
404 ok(hr
== S_OK
, "got %08x\n", hr
);
405 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
406 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
407 ok(dst
== 11, "got %08x\n", dst
);
410 *(FLOAT
*)src
= -10.75;
411 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R4
, DBTYPE_I2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
412 ok(hr
== S_OK
, "got %08x\n", hr
);
413 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
414 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
415 ok(dst
== -11, "got %08x\n", dst
);
418 *(double *)src
= 10.75;
419 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R8
, DBTYPE_I2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
420 ok(hr
== S_OK
, "got %08x\n", hr
);
421 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
422 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
423 ok(dst
== 11, "got %08x\n", dst
);
426 ((LARGE_INTEGER
*)src
)->QuadPart
= 107500;
427 hr
= IDataConvert_DataConvert(convert
, DBTYPE_CY
, DBTYPE_I2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
428 ok(hr
== S_OK
, "got %08x\n", hr
);
429 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
430 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
431 ok(dst
== 11, "got %08x\n", dst
);
434 *(DATE
*)src
= 10.7500;
435 hr
= IDataConvert_DataConvert(convert
, DBTYPE_DATE
, DBTYPE_I2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
436 ok(hr
== S_OK
, "got %08x\n", hr
);
437 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
438 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
439 ok(dst
== 11, "got %08x\n", dst
);
442 b
= SysAllocString(ten
);
444 hr
= IDataConvert_DataConvert(convert
, DBTYPE_BSTR
, DBTYPE_I2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
445 ok(hr
== S_OK
, "got %08x\n", hr
);
446 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
447 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
448 ok(dst
== 10, "got %08x\n", dst
);
452 *(SCODE
*)src
= 0x4321cafe;
453 hr
= IDataConvert_DataConvert(convert
, DBTYPE_ERROR
, DBTYPE_I2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
454 ok(hr
== DB_E_UNSUPPORTEDCONVERSION
, "got %08x\n", hr
);
455 ok(dst_status
== DBSTATUS_E_BADACCESSOR
, "got %08x\n", dst_status
);
456 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
457 ok(dst
== 0x1234, "got %08x\n", dst
);
460 *(VARIANT_BOOL
*)src
= VARIANT_TRUE
;
461 hr
= IDataConvert_DataConvert(convert
, DBTYPE_BOOL
, DBTYPE_I2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
462 ok(hr
== S_OK
, "got %08x\n", hr
);
463 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
464 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
465 ok(dst
== -1, "got %08x\n", dst
);
468 *(VARIANT_BOOL
*)src
= VARIANT_FALSE
;
469 hr
= IDataConvert_DataConvert(convert
, DBTYPE_BOOL
, DBTYPE_I2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
470 ok(hr
== S_OK
, "got %08x\n", hr
);
471 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
472 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
473 ok(dst
== 0, "got %08x\n", dst
);
476 V_VT((VARIANT
*)src
) = VT_I2
;
477 V_I2((VARIANT
*)src
) = 0x4321;
478 hr
= IDataConvert_DataConvert(convert
, DBTYPE_VARIANT
, DBTYPE_I2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
481 ok(hr
== S_OK
, "got %08x\n", hr
);
482 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
484 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
486 ok(dst
== 0x4321, "got %08x\n", dst
);
489 memset(src
, 0, sizeof(DECIMAL
));
490 ((DECIMAL
*)src
)->u1
.Lo64
= 0x4321;
491 hr
= IDataConvert_DataConvert(convert
, DBTYPE_DECIMAL
, DBTYPE_I2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
492 ok(hr
== S_OK
, "got %08x\n", hr
);
493 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
494 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
495 ok(dst
== 0x4321, "got %08x\n", dst
);
498 *(signed char*)src
= 0xab;
499 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I1
, DBTYPE_I2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
500 ok(hr
== S_OK
, "got %08x\n", hr
);
501 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
502 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
503 ok(dst
== (signed short)0xffab, "got %08x\n", dst
);
507 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI1
, DBTYPE_I2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
508 ok(hr
== S_OK
, "got %08x\n", hr
);
509 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
510 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
511 ok(dst
== 0xab, "got %08x\n", dst
);
514 *(WORD
*)src
= 0x4321;
515 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI2
, DBTYPE_I2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
516 ok(hr
== S_OK
, "got %08x\n", hr
);
517 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
518 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
519 ok(dst
== 0x4321, "got %08x\n", dst
);
522 *(WORD
*)src
= 0xabcd;
523 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI2
, DBTYPE_I2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
524 ok(hr
== DB_E_ERRORSOCCURRED
, "got %08x\n", hr
);
525 ok(dst_status
== DBSTATUS_E_DATAOVERFLOW
, "got %08x\n", dst_status
);
526 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
527 ok(dst
== 0x1234, "got %08x\n", dst
);
530 *(DWORD
*)src
= 0xabcd1234;
531 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI4
, DBTYPE_I2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
533 ok(hr
== DB_E_DATAOVERFLOW
, "got %08x\n", hr
);
534 ok(dst_status
== DBSTATUS_E_DATAOVERFLOW
, "got %08x\n", dst_status
);
535 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
536 ok(dst
== 0x1234, "got %08x\n", dst
);
539 *(DWORD
*)src
= 0x1234abcd;
540 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI4
, DBTYPE_I2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
542 ok(hr
== DB_E_DATAOVERFLOW
, "got %08x\n", hr
);
543 ok(dst_status
== DBSTATUS_E_DATAOVERFLOW
, "got %08x\n", dst_status
);
544 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
545 ok(dst
== 0x1234, "got %08x\n", dst
);
548 *(DWORD
*)src
= 0x4321;
549 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI4
, DBTYPE_I2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
550 ok(hr
== S_OK
, "got %08x\n", hr
);
551 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
552 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
553 ok(dst
== 0x4321, "got %08x\n", dst
);
556 ((LARGE_INTEGER
*)src
)->QuadPart
= 0x1234abcd;
557 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I8
, DBTYPE_I2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
558 ok(hr
== DB_E_ERRORSOCCURRED
||
559 broken(hr
== DB_E_UNSUPPORTEDCONVERSION
), /* win98 */
561 if(hr
!= DB_E_UNSUPPORTEDCONVERSION
) /* win98 doesn't support I8/UI8 */
563 ok(dst_status
== DBSTATUS_E_DATAOVERFLOW
, "got %08x\n", dst_status
);
564 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
565 ok(dst
== 0x1234, "got %08x\n", dst
);
568 ((LARGE_INTEGER
*)src
)->QuadPart
= 0x4321;
569 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I8
, DBTYPE_I2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
570 ok(hr
== S_OK
, "got %08x\n", hr
);
571 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
572 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
573 ok(dst
== 0x4321, "got %08x\n", dst
);
576 ((ULARGE_INTEGER
*)src
)->QuadPart
= 0x4321;
577 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI8
, DBTYPE_I2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
578 ok(hr
== S_OK
, "got %08x\n", hr
);
579 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
580 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
581 ok(dst
== 0x4321, "got %08x\n", dst
);
585 strcpy((char *)src
, "10");
586 hr
= IDataConvert_DataConvert(convert
, DBTYPE_STR
, DBTYPE_I2
, 2, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
587 ok(hr
== S_OK
, "got %08x\n", hr
);
588 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
589 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
590 ok(dst
== 10, "got %08x\n", dst
);
593 strcpy((char *)src
, "10");
594 hr
= IDataConvert_DataConvert(convert
, DBTYPE_STR
, DBTYPE_I2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, DBDATACONVERT_LENGTHFROMNTS
);
595 ok(hr
== S_OK
, "got %08x\n", hr
);
596 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
597 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
598 ok(dst
== 10, "got %08x\n", dst
);
601 memcpy(src
, ten
, sizeof(ten
));
602 hr
= IDataConvert_DataConvert(convert
, DBTYPE_WSTR
, DBTYPE_I2
, 4, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
603 ok(hr
== S_OK
, "got %08x\n", hr
);
604 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
605 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
606 ok(dst
== 10, "got %08x\n", dst
);
609 memcpy(src
, ten
, sizeof(ten
));
610 hr
= IDataConvert_DataConvert(convert
, DBTYPE_WSTR
, DBTYPE_I2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, DBDATACONVERT_LENGTHFROMNTS
);
611 ok(hr
== S_OK
, "got %08x\n", hr
);
612 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
613 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
614 ok(dst
== 10, "got %08x\n", dst
);
616 IDataConvert_Release(convert
);
619 static void test_converttoi4(void)
621 IDataConvert
*convert
;
627 static const WCHAR ten
[] = {'1','0',0};
630 hr
= CoCreateInstance(&CLSID_OLEDB_CONVERSIONLIBRARY
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDataConvert
, (void**)&convert
);
633 win_skip("Unable to load oledb conversion library\n");
638 hr
= IDataConvert_DataConvert(convert
, DBTYPE_EMPTY
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
639 ok(hr
== S_OK
, "got %08x\n", hr
);
640 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
641 ok(dst_len
== sizeof(i4
), "got %d\n", dst_len
);
642 ok(i4
== 0, "got %08x\n", i4
);
645 hr
= IDataConvert_DataConvert(convert
, DBTYPE_NULL
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
646 ok(hr
== DB_E_UNSUPPORTEDCONVERSION
, "got %08x\n", hr
);
647 ok(dst_status
== DBSTATUS_E_BADACCESSOR
, "got %08x\n", dst_status
);
648 ok(dst_len
== sizeof(i4
), "got %d\n", dst_len
);
649 ok(i4
== 0x12345678, "got %08x\n", i4
);
652 *(short *)src
= 0x4321;
653 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I2
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
654 ok(hr
== S_OK
, "got %08x\n", hr
);
655 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
656 ok(dst_len
== sizeof(i4
), "got %d\n", dst_len
);
657 ok(i4
== 0x4321, "got %08x\n", i4
);
660 *(int *)src
= 0x4321cafe;
661 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I4
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
662 ok(hr
== S_OK
, "got %08x\n", hr
);
663 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
664 ok(dst_len
== sizeof(i4
), "got %d\n", dst_len
);
665 ok(i4
== 0x4321cafe, "got %08x\n", i4
);
668 *(FLOAT
*)src
= 10.75;
669 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R4
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
670 ok(hr
== S_OK
, "got %08x\n", hr
);
671 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
672 ok(dst_len
== sizeof(i4
), "got %d\n", dst_len
);
673 ok(i4
== 11, "got %08x\n", i4
);
676 *(FLOAT
*)src
= -10.75;
677 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R4
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
678 ok(hr
== S_OK
, "got %08x\n", hr
);
679 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
680 ok(dst_len
== sizeof(i4
), "got %d\n", dst_len
);
681 ok(i4
== -11, "got %08x\n", i4
);
684 *(double *)src
= 10.75;
685 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R8
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
686 ok(hr
== S_OK
, "got %08x\n", hr
);
687 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
688 ok(dst_len
== sizeof(i4
), "got %d\n", dst_len
);
689 ok(i4
== 11, "got %08x\n", i4
);
692 ((LARGE_INTEGER
*)src
)->QuadPart
= 107500;
693 hr
= IDataConvert_DataConvert(convert
, DBTYPE_CY
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
694 ok(hr
== S_OK
, "got %08x\n", hr
);
695 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
696 ok(dst_len
== sizeof(i4
), "got %d\n", dst_len
);
697 ok(i4
== 11, "got %08x\n", i4
);
700 *(DATE
*)src
= 10.7500;
701 hr
= IDataConvert_DataConvert(convert
, DBTYPE_DATE
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
702 ok(hr
== S_OK
, "got %08x\n", hr
);
703 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
704 ok(dst_len
== sizeof(i4
), "got %d\n", dst_len
);
705 ok(i4
== 11, "got %08x\n", i4
);
708 b
= SysAllocString(ten
);
710 hr
= IDataConvert_DataConvert(convert
, DBTYPE_BSTR
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
711 ok(hr
== S_OK
, "got %08x\n", hr
);
712 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
713 ok(dst_len
== sizeof(i4
), "got %d\n", dst_len
);
714 ok(i4
== 10, "got %08x\n", i4
);
718 *(SCODE
*)src
= 0x4321cafe;
719 hr
= IDataConvert_DataConvert(convert
, DBTYPE_ERROR
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
720 ok(hr
== DB_E_UNSUPPORTEDCONVERSION
, "got %08x\n", hr
);
721 ok(dst_status
== DBSTATUS_E_BADACCESSOR
, "got %08x\n", dst_status
);
722 ok(dst_len
== sizeof(i4
), "got %d\n", dst_len
);
723 ok(i4
== 0x12345678, "got %08x\n", i4
);
726 *(VARIANT_BOOL
*)src
= VARIANT_TRUE
;
727 hr
= IDataConvert_DataConvert(convert
, DBTYPE_BOOL
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
728 ok(hr
== S_OK
, "got %08x\n", hr
);
729 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
730 ok(dst_len
== sizeof(i4
), "got %d\n", dst_len
);
731 ok(i4
== 0xffffffff, "got %08x\n", i4
);
734 *(VARIANT_BOOL
*)src
= VARIANT_FALSE
;
735 hr
= IDataConvert_DataConvert(convert
, DBTYPE_BOOL
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
736 ok(hr
== S_OK
, "got %08x\n", hr
);
737 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
738 ok(dst_len
== sizeof(i4
), "got %d\n", dst_len
);
739 ok(i4
== 0, "got %08x\n", i4
);
742 V_VT((VARIANT
*)src
) = VT_I2
;
743 V_I2((VARIANT
*)src
) = 0x1234;
744 hr
= IDataConvert_DataConvert(convert
, DBTYPE_VARIANT
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
747 ok(hr
== S_OK
, "got %08x\n", hr
);
748 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
750 ok(dst_len
== sizeof(i4
), "got %d\n", dst_len
);
752 ok(i4
== 0x1234, "got %08x\n", i4
);
755 memset(src
, 0, sizeof(DECIMAL
));
756 ((DECIMAL
*)src
)->u1
.Lo64
= 0x1234;
757 hr
= IDataConvert_DataConvert(convert
, DBTYPE_DECIMAL
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
758 ok(hr
== S_OK
, "got %08x\n", hr
);
759 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
760 ok(dst_len
== sizeof(i4
), "got %d\n", dst_len
);
761 ok(i4
== 0x1234, "got %08x\n", i4
);
764 *(signed char*)src
= 0xab;
765 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I1
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
766 ok(hr
== S_OK
, "got %08x\n", hr
);
767 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
768 ok(dst_len
== sizeof(i4
), "got %d\n", dst_len
);
769 ok(i4
== 0xffffffab, "got %08x\n", i4
);
773 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI1
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
774 ok(hr
== S_OK
, "got %08x\n", hr
);
775 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
776 ok(dst_len
== sizeof(i4
), "got %d\n", dst_len
);
777 ok(i4
== 0xab, "got %08x\n", i4
);
780 *(WORD
*)src
= 0xabcd;
781 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI2
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
782 ok(hr
== S_OK
, "got %08x\n", hr
);
783 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
784 ok(dst_len
== sizeof(i4
), "got %d\n", dst_len
);
785 ok(i4
== 0xabcd, "got %08x\n", i4
);
788 *(DWORD
*)src
= 0xabcd1234;
789 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI4
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
790 ok(hr
== DB_E_ERRORSOCCURRED
, "got %08x\n", hr
);
791 ok(dst_status
== DBSTATUS_E_DATAOVERFLOW
, "got %08x\n", dst_status
);
792 ok(dst_len
== sizeof(i4
), "got %d\n", dst_len
);
793 ok(i4
== 0x12345678, "got %08x\n", i4
);
796 *(DWORD
*)src
= 0x1234abcd;
797 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI4
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
798 ok(hr
== S_OK
, "got %08x\n", hr
);
799 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
800 ok(dst_len
== sizeof(i4
), "got %d\n", dst_len
);
801 ok(i4
== 0x1234abcd, "got %08x\n", i4
);
804 ((LARGE_INTEGER
*)src
)->QuadPart
= 0x1234abcd;
805 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I8
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
807 broken(hr
== DB_E_UNSUPPORTEDCONVERSION
), /* win98 */
809 if(hr
!= DB_E_UNSUPPORTEDCONVERSION
) /* win98 doesn't support I8/UI8 */
811 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
812 ok(dst_len
== sizeof(i4
), "got %d\n", dst_len
);
813 ok(i4
== 0x1234abcd, "got %08x\n", i4
);
816 ((ULARGE_INTEGER
*)src
)->QuadPart
= 0x1234abcd;
817 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI8
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
818 ok(hr
== S_OK
, "got %08x\n", hr
);
819 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
820 ok(dst_len
== sizeof(i4
), "got %d\n", dst_len
);
821 ok(i4
== 0x1234abcd, "got %08x\n", i4
);
825 strcpy((char *)src
, "10");
826 hr
= IDataConvert_DataConvert(convert
, DBTYPE_STR
, DBTYPE_I4
, 2, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
827 ok(hr
== S_OK
, "got %08x\n", hr
);
828 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
829 ok(dst_len
== sizeof(i4
), "got %d\n", dst_len
);
830 ok(i4
== 10, "got %08x\n", i4
);
833 strcpy((char *)src
, "10");
834 hr
= IDataConvert_DataConvert(convert
, DBTYPE_STR
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, DBDATACONVERT_LENGTHFROMNTS
);
835 ok(hr
== S_OK
, "got %08x\n", hr
);
836 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
837 ok(dst_len
== sizeof(i4
), "got %d\n", dst_len
);
838 ok(i4
== 10, "got %08x\n", i4
);
841 memcpy(src
, ten
, sizeof(ten
));
842 hr
= IDataConvert_DataConvert(convert
, DBTYPE_WSTR
, DBTYPE_I4
, 4, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
843 ok(hr
== S_OK
, "got %08x\n", hr
);
844 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
845 ok(dst_len
== sizeof(i4
), "got %d\n", dst_len
);
846 ok(i4
== 10, "got %08x\n", i4
);
849 memcpy(src
, ten
, sizeof(ten
));
850 hr
= IDataConvert_DataConvert(convert
, DBTYPE_WSTR
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, DBDATACONVERT_LENGTHFROMNTS
);
851 ok(hr
== S_OK
, "got %08x\n", hr
);
852 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
853 ok(dst_len
== sizeof(i4
), "got %d\n", dst_len
);
854 ok(i4
== 10, "got %08x\n", i4
);
856 IDataConvert_Release(convert
);
859 static void test_converttobstr(void)
861 IDataConvert
*convert
;
867 static const WCHAR ten
[] = {'1','0',0};
870 hr
= CoCreateInstance(&CLSID_OLEDB_CONVERSIONLIBRARY
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDataConvert
, (void**)&convert
);
873 win_skip("Unable to load oledb conversion library\n");
877 hr
= IDataConvert_DataConvert(convert
, DBTYPE_EMPTY
, DBTYPE_BSTR
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
878 ok(hr
== S_OK
, "got %08x\n", hr
);
879 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
880 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
881 ok(dst
!= NULL
, "got %p\n", dst
);
882 ok(SysStringLen(dst
) == 0, "got %d\n", SysStringLen(dst
));
886 hr
= IDataConvert_DataConvert(convert
, DBTYPE_NULL
, DBTYPE_BSTR
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
887 ok(hr
== DB_E_UNSUPPORTEDCONVERSION
, "got %08x\n", hr
);
888 ok(dst_status
== DBSTATUS_E_BADACCESSOR
, "got %08x\n", dst_status
);
889 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
890 ok(dst
== (void*)0x1234, "got %p\n", dst
);
892 *(short *)src
= 4321;
893 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I2
, DBTYPE_BSTR
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
894 ok(hr
== S_OK
, "got %08x\n", hr
);
895 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
896 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
897 ok(dst
!= NULL
, "got %p\n", dst
);
898 ok(SysStringLen(dst
) == 4, "got %d\n", SysStringLen(dst
));
901 b
= SysAllocString(ten
);
903 hr
= IDataConvert_DataConvert(convert
, DBTYPE_BSTR
, DBTYPE_BSTR
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
904 ok(hr
== S_OK
, "got %08x\n", hr
);
905 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
906 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
907 ok(dst
!= NULL
, "got %p\n", dst
);
908 ok(dst
!= b
, "got %p src %p\n", dst
, b
);
909 ok(!lstrcmpW(b
, dst
), "got %s\n", wine_dbgstr_w(dst
));
913 IDataConvert_Release(convert
);
916 static void test_converttowstr(void)
918 IDataConvert
*convert
;
924 static const WCHAR ten
[] = {'1','0',0};
925 static const WCHAR fourthreetwoone
[] = {'4','3','2','1',0};
928 hr
= CoCreateInstance(&CLSID_OLEDB_CONVERSIONLIBRARY
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDataConvert
, (void**)&convert
);
931 win_skip("Unable to load oledb conversion library\n");
936 memset(dst
, 0xcc, sizeof(dst
));
937 hr
= IDataConvert_DataConvert(convert
, DBTYPE_EMPTY
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
938 ok(hr
== S_OK
, "got %08x\n", hr
);
939 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
940 ok(dst_len
== 0, "got %d\n", dst_len
);
941 ok(dst
[0] == 0, "got %02x\n", dst
[0]);
942 ok(dst
[1] == 0xcccc, "got %02x\n", dst
[1]);
944 memset(dst
, 0xcc, sizeof(dst
));
945 hr
= IDataConvert_DataConvert(convert
, DBTYPE_NULL
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
946 ok(hr
== DB_E_UNSUPPORTEDCONVERSION
, "got %08x\n", hr
);
947 ok(dst_status
== DBSTATUS_E_BADACCESSOR
, "got %08x\n", dst_status
);
948 ok(dst_len
== 0, "got %d\n", dst_len
);
949 ok(dst
[0] == 0xcccc, "got %02x\n", dst
[0]);
951 *(short *)src
= 4321;
952 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I2
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
953 ok(hr
== S_OK
, "got %08x\n", hr
);
954 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
955 ok(dst_len
== 8, "got %d\n", dst_len
);
956 ok(!lstrcmpW(dst
, fourthreetwoone
), "got %s\n", wine_dbgstr_w(dst
));
958 *(short *)src
= 4321;
959 memset(dst
, 0xcc, sizeof(dst
));
960 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I2
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, 0, 0, &dst_status
, 0, 0, 0);
961 ok(hr
== DB_E_ERRORSOCCURRED
, "got %08x\n", hr
);
962 ok(dst_status
== DBSTATUS_E_DATAOVERFLOW
, "got %08x\n", dst_status
);
963 ok(dst_len
== 8, "got %d\n", dst_len
);
964 ok(dst
[0] == 0xcccc, "got %02x\n", dst
[0]);
966 *(short *)src
= 4321;
967 memset(dst
, 0xcc, sizeof(dst
));
968 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I2
, DBTYPE_WSTR
, 0, &dst_len
, src
, NULL
, 0, 0, &dst_status
, 0, 0, 0);
969 ok(hr
== S_OK
, "got %08x\n", hr
);
970 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
971 ok(dst_len
== 8, "got %d\n", dst_len
);
972 ok(dst
[0] == 0xcccc, "got %02x\n", dst
[0]);
974 *(short *)src
= 4321;
975 memset(dst
, 0xcc, sizeof(dst
));
976 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I2
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, 4, 0, &dst_status
, 0, 0, 0);
977 ok(hr
== S_OK
, "got %08x\n", hr
);
978 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
979 ok(dst_len
== 8, "got %d\n", dst_len
);
980 ok(dst
[0] == '4', "got %02x\n", dst
[0]);
981 ok(dst
[1] == 0, "got %02x\n", dst
[1]);
982 ok(dst
[2] == 0xcccc, "got %02x\n", dst
[2]);
984 *(short *)src
= 4321;
985 memset(dst
, 0xcc, sizeof(dst
));
986 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I2
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, 2, 0, &dst_status
, 0, 0, 0);
987 ok(hr
== S_OK
, "got %08x\n", hr
);
988 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
989 ok(dst_len
== 8, "got %d\n", dst_len
);
990 ok(dst
[0] == 0, "got %02x\n", dst
[0]);
991 ok(dst
[1] == 0xcccc, "got %02x\n", dst
[1]);
993 *(short *)src
= 4321;
994 memset(dst
, 0xcc, sizeof(dst
));
995 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I2
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, 8, 0, &dst_status
, 0, 0, 0);
996 ok(hr
== S_OK
, "got %08x\n", hr
);
997 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
998 ok(dst_len
== 8, "got %d\n", dst_len
);
999 ok(dst
[0] == '4', "got %02x\n", dst
[0]);
1000 ok(dst
[1] == '3', "got %02x\n", dst
[1]);
1001 ok(dst
[2] == '2', "got %02x\n", dst
[2]);
1002 ok(dst
[3] == 0, "got %02x\n", dst
[3]);
1003 ok(dst
[4] == 0xcccc, "got %02x\n", dst
[4]);
1005 b
= SysAllocString(ten
);
1007 hr
= IDataConvert_DataConvert(convert
, DBTYPE_BSTR
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1008 ok(hr
== S_OK
, "got %08x\n", hr
);
1009 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1010 ok(dst_len
== 4, "got %d\n", dst_len
);
1011 ok(!lstrcmpW(b
, dst
), "got %s\n", wine_dbgstr_w(dst
));
1014 memcpy(src
, ten
, sizeof(ten
));
1015 hr
= IDataConvert_DataConvert(convert
, DBTYPE_WSTR
, DBTYPE_WSTR
, 2, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1016 ok(hr
== S_OK
, "got %08x\n", hr
);
1017 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1018 ok(dst_len
== 2, "got %d\n", dst_len
);
1019 ok(dst
[0] == '1', "got %02x\n", dst
[0]);
1020 ok(dst
[1] == 0, "got %02x\n", dst
[1]);
1022 memcpy(src
, ten
, sizeof(ten
));
1023 hr
= IDataConvert_DataConvert(convert
, DBTYPE_WSTR
, DBTYPE_WSTR
, 4, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1024 ok(hr
== S_OK
, "got %08x\n", hr
);
1025 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1026 ok(dst_len
== 4, "got %d\n", dst_len
);
1027 ok(!lstrcmpW(ten
, dst
), "got %s\n", wine_dbgstr_w(dst
));
1029 memcpy(src
, ten
, sizeof(ten
));
1030 hr
= IDataConvert_DataConvert(convert
, DBTYPE_WSTR
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, DBDATACONVERT_LENGTHFROMNTS
);
1031 ok(hr
== S_OK
, "got %08x\n", hr
);
1032 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1033 ok(dst_len
== 4, "got %d\n", dst_len
);
1034 ok(!lstrcmpW(ten
, dst
), "got %s\n", wine_dbgstr_w(dst
));
1036 IDataConvert_Release(convert
);
1039 static void test_converttobyrefwstr(void)
1041 IDataConvert
*convert
;
1045 DBSTATUS dst_status
;
1047 static const WCHAR ten
[] = {'1','0',0};
1048 static const WCHAR fourthreetwoone
[] = {'4','3','2','1',0};
1051 hr
= CoCreateInstance(&CLSID_OLEDB_CONVERSIONLIBRARY
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDataConvert
, (void**)&convert
);
1054 win_skip("Unable to load oledb conversion library\n");
1058 hr
= IDataConvert_DataConvert(convert
, DBTYPE_EMPTY
, DBTYPE_BYREF
| DBTYPE_WSTR
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1059 ok(hr
== S_OK
, "got %08x\n", hr
);
1060 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1061 ok(dst_len
== 0, "got %d\n", dst_len
);
1062 ok(dst
[0] == 0, "got %04x\n", dst
[0]);
1065 dst
= (void*)0x12345678;
1066 hr
= IDataConvert_DataConvert(convert
, DBTYPE_NULL
, DBTYPE_BYREF
| DBTYPE_WSTR
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1067 ok(hr
== DB_E_UNSUPPORTEDCONVERSION
, "got %08x\n", hr
);
1068 ok(dst_status
== DBSTATUS_E_BADACCESSOR
, "got %08x\n", dst_status
);
1069 ok(dst_len
== 0, "got %d\n", dst_len
);
1070 ok(dst
== (void*)0x12345678, "got %p\n", dst
);
1072 *(short *)src
= 4321;
1073 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I2
, DBTYPE_BYREF
| DBTYPE_WSTR
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1074 ok(hr
== S_OK
, "got %08x\n", hr
);
1075 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1076 ok(dst_len
== 8, "got %d\n", dst_len
);
1077 ok(!lstrcmpW(dst
, fourthreetwoone
), "got %s\n", wine_dbgstr_w(dst
));
1080 *(short *)src
= 4321;
1081 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I2
, DBTYPE_BYREF
| DBTYPE_WSTR
, 0, &dst_len
, src
, &dst
, 0, 0, &dst_status
, 0, 0, 0);
1082 ok(hr
== S_OK
, "got %08x\n", hr
);
1083 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1084 ok(dst_len
== 8, "got %d\n", dst_len
);
1085 ok(!lstrcmpW(dst
, fourthreetwoone
), "got %s\n", wine_dbgstr_w(dst
));
1088 b
= SysAllocString(ten
);
1090 hr
= IDataConvert_DataConvert(convert
, DBTYPE_BSTR
, DBTYPE_BYREF
| DBTYPE_WSTR
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1091 ok(hr
== S_OK
, "got %08x\n", hr
);
1092 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1093 ok(dst_len
== 4, "got %d\n", dst_len
);
1094 ok(!lstrcmpW(b
, dst
), "got %s\n", wine_dbgstr_w(dst
));
1098 memcpy(src
, ten
, sizeof(ten
));
1099 hr
= IDataConvert_DataConvert(convert
, DBTYPE_WSTR
, DBTYPE_BYREF
| DBTYPE_WSTR
, 2, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1100 ok(hr
== S_OK
, "got %08x\n", hr
);
1101 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1102 ok(dst_len
== 2, "got %d\n", dst_len
);
1103 ok(dst
[0] == '1', "got %02x\n", dst
[0]);
1104 ok(dst
[1] == 0, "got %02x\n", dst
[1]);
1107 memcpy(src
, ten
, sizeof(ten
));
1108 hr
= IDataConvert_DataConvert(convert
, DBTYPE_WSTR
, DBTYPE_BYREF
| DBTYPE_WSTR
, 4, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1109 ok(hr
== S_OK
, "got %08x\n", hr
);
1110 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1111 ok(dst_len
== 4, "got %d\n", dst_len
);
1112 ok(!lstrcmpW(ten
, dst
), "got %s\n", wine_dbgstr_w(dst
));
1115 memcpy(src
, ten
, sizeof(ten
));
1116 hr
= IDataConvert_DataConvert(convert
, DBTYPE_WSTR
, DBTYPE_BYREF
| DBTYPE_WSTR
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, DBDATACONVERT_LENGTHFROMNTS
);
1117 ok(hr
== S_OK
, "got %08x\n", hr
);
1118 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1119 ok(dst_len
== 4, "got %d\n", dst_len
);
1120 ok(!lstrcmpW(ten
, dst
), "got %s\n", wine_dbgstr_w(dst
));
1123 IDataConvert_Release(convert
);
1126 static void test_converttoguid(void)
1128 IDataConvert
*convert
;
1132 DBSTATUS dst_status
;
1135 hr
= CoCreateInstance(&CLSID_OLEDB_CONVERSIONLIBRARY
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDataConvert
, (void**)&convert
);
1138 win_skip("Unable to load oledb conversion library\n");
1143 hr
= IDataConvert_DataConvert(convert
, DBTYPE_EMPTY
, DBTYPE_GUID
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1144 ok(hr
== S_OK
, "got %08x\n", hr
);
1145 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1146 ok(dst_len
== sizeof(GUID
), "got %d\n", dst_len
);
1147 ok(IsEqualGUID(&dst
, &GUID_NULL
), "didn't get GUID_NULL\n");
1150 hr
= IDataConvert_DataConvert(convert
, DBTYPE_NULL
, DBTYPE_GUID
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1151 ok(hr
== DB_E_UNSUPPORTEDCONVERSION
, "got %08x\n", hr
);
1152 ok(dst_status
== DBSTATUS_E_BADACCESSOR
, "got %08x\n", dst_status
);
1153 ok(dst_len
== sizeof(GUID
), "got %d\n", dst_len
);
1154 ok(IsEqualGUID(&dst
, &IID_IDCInfo
), "dst has changed\n");
1157 memcpy(src
, &IID_IDataConvert
, sizeof(GUID
));
1158 hr
= IDataConvert_DataConvert(convert
, DBTYPE_GUID
, DBTYPE_GUID
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1159 ok(hr
== S_OK
, "got %08x\n", hr
);
1160 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1161 ok(dst_len
== sizeof(GUID
), "got %d\n", dst_len
);
1162 ok(IsEqualGUID(&dst
, &IID_IDataConvert
), "didn't get IID_IDataConvert\n");
1164 IDataConvert_Release(convert
);
1167 static void test_converttofiletime(void)
1169 IDataConvert
*convert
;
1173 DBSTATUS dst_status
;
1176 hr
= CoCreateInstance(&CLSID_OLEDB_CONVERSIONLIBRARY
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDataConvert
, (void**)&convert
);
1179 win_skip("Unable to load oledb conversion library\n");
1183 memset(&dst
, 0xcc, sizeof(dst
));
1184 ((FILETIME
*)src
)->dwLowDateTime
= 0x12345678;
1185 ((FILETIME
*)src
)->dwHighDateTime
= 0x9abcdef0;
1186 hr
= IDataConvert_DataConvert(convert
, DBTYPE_FILETIME
, DBTYPE_FILETIME
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1188 broken(hr
== DB_E_BADBINDINFO
), /* win98 */
1192 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1193 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
1194 ok(dst
.dwLowDateTime
== 0x12345678, "got %08x\n", dst
.dwLowDateTime
);
1195 ok(dst
.dwHighDateTime
== 0x9abcdef0, "got %08x\n", dst
.dwHighDateTime
);
1198 IDataConvert_Release(convert
);
1201 static void test_converttoui1(void)
1203 IDataConvert
*convert
;
1207 DBSTATUS dst_status
;
1210 hr
= CoCreateInstance(&CLSID_OLEDB_CONVERSIONLIBRARY
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDataConvert
, (void**)&convert
);
1213 win_skip("Unable to load oledb conversion library\n");
1218 hr
= IDataConvert_DataConvert(convert
, DBTYPE_EMPTY
, DBTYPE_UI1
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1219 ok(hr
== S_OK
, "got %08x\n", hr
);
1220 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1221 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
1222 ok(dst
== 0, "got %08x\n", dst
);
1225 hr
= IDataConvert_DataConvert(convert
, DBTYPE_NULL
, DBTYPE_UI1
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1226 ok(hr
== DB_E_UNSUPPORTEDCONVERSION
, "got %08x\n", hr
);
1227 ok(dst_status
== DBSTATUS_E_BADACCESSOR
, "got %08x\n", dst_status
);
1228 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
1229 ok(dst
== 0x12, "got %08x\n", dst
);
1233 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI1
, DBTYPE_UI1
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1234 ok(hr
== S_OK
, "got %08x\n", hr
);
1235 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1236 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
1237 ok(dst
== 0x43, "got %08x\n", dst
);
1241 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI1
, DBTYPE_UI1
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1242 ok(hr
== S_OK
, "got %08x\n", hr
);
1243 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1244 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
1245 ok(dst
== 0xfe, "got %08x\n", dst
);
1247 IDataConvert_Release(convert
);
1250 static void test_converttoui4(void)
1252 IDataConvert
*convert
;
1256 DBSTATUS dst_status
;
1259 hr
= CoCreateInstance(&CLSID_OLEDB_CONVERSIONLIBRARY
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDataConvert
, (void**)&convert
);
1262 win_skip("Unable to load oledb conversion library\n");
1267 hr
= IDataConvert_DataConvert(convert
, DBTYPE_EMPTY
, DBTYPE_UI4
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1268 ok(hr
== S_OK
, "got %08x\n", hr
);
1269 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1270 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
1271 ok(dst
== 0, "got %08x\n", dst
);
1274 hr
= IDataConvert_DataConvert(convert
, DBTYPE_NULL
, DBTYPE_UI4
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1275 ok(hr
== DB_E_UNSUPPORTEDCONVERSION
, "got %08x\n", hr
);
1276 ok(dst_status
== DBSTATUS_E_BADACCESSOR
, "got %08x\n", dst_status
);
1277 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
1278 ok(dst
== 0x12345678, "got %08x\n", dst
);
1281 *(DWORD
*)src
= 0x87654321;
1282 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI4
, DBTYPE_UI4
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1283 ok(hr
== S_OK
, "got %08x\n", hr
);
1284 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1285 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
1286 ok(dst
== 0x87654321, "got %08x\n", dst
);
1289 *(signed short *)src
= 0x4321;
1290 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I2
, DBTYPE_UI4
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1291 ok(hr
== S_OK
, "got %08x\n", hr
);
1292 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1293 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
1294 ok(dst
== 0x4321, "got %08x\n", dst
);
1297 *(signed short *)src
= -1;
1298 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I2
, DBTYPE_UI4
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1299 ok(hr
== DB_E_ERRORSOCCURRED
, "got %08x\n", hr
);
1301 ok(dst_status
== DBSTATUS_E_SIGNMISMATCH
, "got %08x\n", dst_status
);
1302 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
1303 ok(dst
== 0x12345678, "got %08x\n", dst
);
1305 IDataConvert_Release(convert
);
1308 static void test_converttor4(void)
1310 IDataConvert
*convert
;
1314 DBSTATUS dst_status
;
1317 hr
= CoCreateInstance(&CLSID_OLEDB_CONVERSIONLIBRARY
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDataConvert
, (void**)&convert
);
1320 win_skip("Unable to load oledb conversion library\n");
1325 hr
= IDataConvert_DataConvert(convert
, DBTYPE_EMPTY
, DBTYPE_R4
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1326 ok(hr
== S_OK
, "got %08x\n", hr
);
1327 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1328 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
1329 ok(dst
== 0.0, "got %f\n", dst
);
1332 hr
= IDataConvert_DataConvert(convert
, DBTYPE_NULL
, DBTYPE_R4
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1333 ok(hr
== DB_E_UNSUPPORTEDCONVERSION
, "got %08x\n", hr
);
1334 ok(dst_status
== DBSTATUS_E_BADACCESSOR
, "got %08x\n", dst_status
);
1335 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
1336 ok(dst
== 1.0, "got %f\n", dst
);
1339 *(signed int*)src
= 12345678;
1340 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I4
, DBTYPE_R4
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1341 ok(hr
== S_OK
, "got %08x\n", hr
);
1342 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1343 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
1344 ok(dst
== 12345678.0, "got %f\n", dst
);
1347 *(FLOAT
*)src
= 10.0;
1348 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R4
, DBTYPE_R4
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1349 ok(hr
== S_OK
, "got %08x\n", hr
);
1350 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1351 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
1352 ok(dst
== 10.0, "got %f\n", dst
);
1354 IDataConvert_Release(convert
);
1357 static void test_converttocy(void)
1359 IDataConvert
*convert
;
1363 DBSTATUS dst_status
;
1366 hr
= CoCreateInstance(&CLSID_OLEDB_CONVERSIONLIBRARY
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDataConvert
, (void**)&convert
);
1369 win_skip("Unable to load oledb conversion library\n");
1374 hr
= IDataConvert_DataConvert(convert
, DBTYPE_EMPTY
, DBTYPE_CY
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1375 ok(hr
== S_OK
, "got %08x\n", hr
);
1376 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1377 ok(dst_len
== sizeof(CY
), "got %d\n", dst_len
);
1378 ok(dst
.int64
== 0, "didn't get 0\n");
1381 hr
= IDataConvert_DataConvert(convert
, DBTYPE_NULL
, DBTYPE_CY
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1382 ok(hr
== DB_E_UNSUPPORTEDCONVERSION
, "got %08x\n", hr
);
1383 ok(dst_status
== DBSTATUS_E_BADACCESSOR
, "got %08x\n", dst_status
);
1384 ok(dst_len
== sizeof(CY
), "got %d\n", dst_len
);
1385 ok(dst
.int64
== 0xcc, "dst changed\n");
1389 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I4
, DBTYPE_CY
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1390 ok(hr
== S_OK
, "got %08x\n", hr
);
1391 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1392 ok(dst_len
== sizeof(CY
), "got %d\n", dst_len
);
1393 ok(dst
.int64
== 12340000, "got %d\n", dst
.s
.Lo
);
1396 ((CY
*)src
)->int64
= 1234;
1397 hr
= IDataConvert_DataConvert(convert
, DBTYPE_CY
, DBTYPE_CY
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1398 ok(hr
== S_OK
, "got %08x\n", hr
);
1399 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1400 ok(dst_len
== sizeof(CY
), "got %d\n", dst_len
);
1401 ok(dst
.int64
== 1234, "got %d\n", dst
.s
.Lo
);
1403 IDataConvert_Release(convert
);
1406 static void test_converttoui8(void)
1408 IDataConvert
*convert
;
1412 DBSTATUS dst_status
;
1415 hr
= CoCreateInstance(&CLSID_OLEDB_CONVERSIONLIBRARY
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDataConvert
, (void**)&convert
);
1418 win_skip("Unable to load oledb conversion library\n");
1422 dst
.QuadPart
= 0xcc;
1423 hr
= IDataConvert_DataConvert(convert
, DBTYPE_EMPTY
, DBTYPE_UI8
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1424 ok(hr
== S_OK
, "got %08x\n", hr
);
1425 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1426 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
1427 ok(dst
.QuadPart
== 0, "got %d\n", (int)dst
.QuadPart
);
1429 dst
.QuadPart
= 0xcc;
1430 hr
= IDataConvert_DataConvert(convert
, DBTYPE_NULL
, DBTYPE_UI8
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1431 ok(hr
== DB_E_UNSUPPORTEDCONVERSION
, "got %08x\n", hr
);
1432 ok(dst_status
== DBSTATUS_E_BADACCESSOR
, "got %08x\n", dst_status
);
1433 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
1434 ok(dst
.QuadPart
== 0xcc, "dst changed\n");
1436 dst
.QuadPart
= 0xcc;
1438 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I4
, DBTYPE_UI8
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1439 ok(hr
== S_OK
, "got %08x\n", hr
);
1440 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1441 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
1442 ok(dst
.QuadPart
== 1234, "got %d\n", (int)dst
.QuadPart
);
1444 dst
.QuadPart
= 0xcc;
1446 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I4
, DBTYPE_UI8
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1447 ok(hr
== DB_E_ERRORSOCCURRED
, "got %08x\n", hr
);
1449 ok(dst_status
== DBSTATUS_E_SIGNMISMATCH
, "got %08x\n", dst_status
);
1450 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
1451 ok(dst
.QuadPart
== 0xcc, "got %d\n", (int)dst
.QuadPart
);
1453 dst
.QuadPart
= 0xcc;
1454 ((ULARGE_INTEGER
*)src
)->QuadPart
= 1234;
1455 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI8
, DBTYPE_UI8
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1456 ok(hr
== S_OK
, "got %08x\n", hr
);
1457 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1458 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
1459 ok(dst
.QuadPart
== 1234, "got %d\n", (int)dst
.QuadPart
);
1461 IDataConvert_Release(convert
);
1466 OleInitialize(NULL
);
1471 test_converttobstr();
1472 test_converttowstr();
1473 test_converttobyrefwstr();
1474 test_converttoguid();
1475 test_converttoui1();
1476 test_converttoui4();
1478 test_converttofiletime();
1480 test_converttoui8();