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");
362 dst_len
= dst
= 0x1234;
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
);
369 dst_len
= dst
= 0x1234;
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
== 0x1234, "got %d\n", dst_len
);
374 ok(dst
== 0x1234, "got %08x\n", dst
);
376 dst_len
= dst
= 0x1234;
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
);
384 dst_len
= dst
= 0x1234;
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
);
393 dst_len
= dst
= 0x1234;
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
);
401 dst_len
= dst
= 0x1234;
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
);
409 dst_len
= dst
= 0x1234;
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
);
417 dst_len
= dst
= 0x1234;
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
);
425 dst_len
= dst
= 0x1234;
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
);
433 dst_len
= dst
= 0x1234;
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
);
441 dst_len
= dst
= 0x1234;
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
);
451 dst_len
= dst
= 0x1234;
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
== 0x1234, "got %d\n", dst_len
);
457 ok(dst
== 0x1234, "got %08x\n", dst
);
459 dst_len
= dst
= 0x1234;
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
);
467 dst_len
= dst
= 0x1234;
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
);
475 dst_len
= dst
= 0x1234;
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);
479 ok(hr
== S_OK
, "got %08x\n", hr
);
480 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
481 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
482 ok(dst
== 0x4321, "got %08x\n", dst
);
484 dst_len
= dst
= 0x1234;
485 memset(src
, 0, sizeof(DECIMAL
));
486 ((DECIMAL
*)src
)->u1
.Lo64
= 0x4321;
487 hr
= IDataConvert_DataConvert(convert
, DBTYPE_DECIMAL
, DBTYPE_I2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
488 ok(hr
== S_OK
, "got %08x\n", hr
);
489 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
490 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
491 ok(dst
== 0x4321, "got %08x\n", dst
);
493 dst_len
= dst
= 0x1234;
494 *(signed char*)src
= 0xab;
495 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I1
, DBTYPE_I2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
496 ok(hr
== S_OK
, "got %08x\n", hr
);
497 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
498 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
499 ok(dst
== (signed short)0xffab, "got %08x\n", dst
);
501 dst_len
= dst
= 0x1234;
503 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI1
, DBTYPE_I2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
504 ok(hr
== S_OK
, "got %08x\n", hr
);
505 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
506 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
507 ok(dst
== 0xab, "got %08x\n", dst
);
509 dst_len
= dst
= 0x1234;
510 *(WORD
*)src
= 0x4321;
511 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI2
, DBTYPE_I2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
512 ok(hr
== S_OK
, "got %08x\n", hr
);
513 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
514 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
515 ok(dst
== 0x4321, "got %08x\n", dst
);
517 dst_len
= dst
= 0x1234;
518 *(WORD
*)src
= 0xabcd;
519 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI2
, DBTYPE_I2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
520 ok(hr
== DB_E_ERRORSOCCURRED
, "got %08x\n", hr
);
521 ok(dst_status
== DBSTATUS_E_DATAOVERFLOW
, "got %08x\n", dst_status
);
523 ok(broken(dst_len
== sizeof(dst
)) || dst_len
== 0x1234 /* W2K+ */, "got %d\n", dst_len
);
524 ok(dst
== 0x1234, "got %08x\n", dst
);
526 dst_len
= dst
= 0x1234;
527 *(DWORD
*)src
= 0xabcd1234;
528 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI4
, DBTYPE_I2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
530 ok(hr
== DB_E_DATAOVERFLOW
, "got %08x\n", hr
);
531 ok(dst_status
== DBSTATUS_E_DATAOVERFLOW
, "got %08x\n", dst_status
);
532 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
533 ok(dst
== 0x1234, "got %08x\n", dst
);
535 dst_len
= dst
= 0x1234;
536 *(DWORD
*)src
= 0x1234abcd;
537 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI4
, DBTYPE_I2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
539 ok(hr
== DB_E_DATAOVERFLOW
, "got %08x\n", hr
);
540 ok(dst_status
== DBSTATUS_E_DATAOVERFLOW
, "got %08x\n", dst_status
);
541 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
542 ok(dst
== 0x1234, "got %08x\n", dst
);
544 dst_len
= dst
= 0x1234;
545 *(DWORD
*)src
= 0x4321;
546 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI4
, DBTYPE_I2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
547 ok(hr
== S_OK
, "got %08x\n", hr
);
548 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
549 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
550 ok(dst
== 0x4321, "got %08x\n", dst
);
552 dst_len
= dst
= 0x1234;
553 ((LARGE_INTEGER
*)src
)->QuadPart
= 0x1234abcd;
554 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I8
, DBTYPE_I2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
555 ok(hr
== DB_E_ERRORSOCCURRED
||
556 broken(hr
== DB_E_UNSUPPORTEDCONVERSION
), /* win98 */
558 if(hr
!= DB_E_UNSUPPORTEDCONVERSION
) /* win98 doesn't support I8/UI8 */
560 ok(dst_status
== DBSTATUS_E_DATAOVERFLOW
, "got %08x\n", dst_status
);
561 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
562 ok(dst
== 0x1234, "got %08x\n", dst
);
564 dst_len
= dst
= 0x1234;
565 ((LARGE_INTEGER
*)src
)->QuadPart
= 0x4321;
566 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I8
, DBTYPE_I2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
567 ok(hr
== S_OK
, "got %08x\n", hr
);
568 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
569 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
570 ok(dst
== 0x4321, "got %08x\n", dst
);
572 dst_len
= dst
= 0x1234;
573 ((ULARGE_INTEGER
*)src
)->QuadPart
= 0x4321;
574 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI8
, DBTYPE_I2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
575 ok(hr
== S_OK
, "got %08x\n", hr
);
576 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
577 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
578 ok(dst
== 0x4321, "got %08x\n", dst
);
581 dst_len
= dst
= 0x1234;
582 strcpy((char *)src
, "10");
583 hr
= IDataConvert_DataConvert(convert
, DBTYPE_STR
, DBTYPE_I2
, 2, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
584 ok(hr
== S_OK
, "got %08x\n", hr
);
585 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
586 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
587 ok(dst
== 10, "got %08x\n", dst
);
589 dst_len
= dst
= 0x1234;
590 strcpy((char *)src
, "10");
591 hr
= IDataConvert_DataConvert(convert
, DBTYPE_STR
, DBTYPE_I2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, DBDATACONVERT_LENGTHFROMNTS
);
592 ok(hr
== S_OK
, "got %08x\n", hr
);
593 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
594 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
595 ok(dst
== 10, "got %08x\n", dst
);
597 dst_len
= dst
= 0x1234;
598 memcpy(src
, ten
, sizeof(ten
));
599 hr
= IDataConvert_DataConvert(convert
, DBTYPE_WSTR
, DBTYPE_I2
, 4, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
600 ok(hr
== S_OK
, "got %08x\n", hr
);
601 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
602 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
603 ok(dst
== 10, "got %08x\n", dst
);
605 dst_len
= dst
= 0x1234;
606 memcpy(src
, ten
, sizeof(ten
));
607 hr
= IDataConvert_DataConvert(convert
, DBTYPE_WSTR
, DBTYPE_I2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, DBDATACONVERT_LENGTHFROMNTS
);
608 ok(hr
== S_OK
, "got %08x\n", hr
);
609 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
610 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
611 ok(dst
== 10, "got %08x\n", dst
);
613 IDataConvert_Release(convert
);
616 static void test_converttoi4(void)
618 IDataConvert
*convert
;
624 static const WCHAR ten
[] = {'1','0',0};
627 hr
= CoCreateInstance(&CLSID_OLEDB_CONVERSIONLIBRARY
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDataConvert
, (void**)&convert
);
630 win_skip("Unable to load oledb conversion library\n");
636 hr
= IDataConvert_DataConvert(convert
, DBTYPE_EMPTY
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
637 ok(hr
== S_OK
, "got %08x\n", hr
);
638 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
639 ok(dst_len
== sizeof(i4
), "got %d\n", dst_len
);
640 ok(i4
== 0, "got %08x\n", i4
);
644 hr
= IDataConvert_DataConvert(convert
, DBTYPE_NULL
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
645 ok(hr
== DB_E_UNSUPPORTEDCONVERSION
, "got %08x\n", hr
);
646 ok(dst_status
== DBSTATUS_E_BADACCESSOR
, "got %08x\n", dst_status
);
647 ok(dst_len
== 0x1234, "got %d\n", dst_len
);
648 ok(i4
== 0x12345678, "got %08x\n", i4
);
651 *(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;
662 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I4
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
663 ok(hr
== S_OK
, "got %08x\n", hr
);
664 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
665 ok(dst_len
== sizeof(i4
), "got %d\n", dst_len
);
666 ok(i4
== 0x4321cafe, "got %08x\n", i4
);
669 *(FLOAT
*)src
= 10.75;
670 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R4
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
671 ok(hr
== S_OK
, "got %08x\n", hr
);
672 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
673 ok(dst_len
== sizeof(i4
), "got %d\n", dst_len
);
674 ok(i4
== 11, "got %08x\n", i4
);
677 *(FLOAT
*)src
= -10.75;
679 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R4
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
680 ok(hr
== S_OK
, "got %08x\n", hr
);
681 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
682 ok(dst_len
== sizeof(i4
), "got %d\n", dst_len
);
683 ok(i4
== -11, "got %08x\n", i4
);
686 *(double *)src
= 10.75;
688 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R8
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
689 ok(hr
== S_OK
, "got %08x\n", hr
);
690 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
691 ok(dst_len
== sizeof(i4
), "got %d\n", dst_len
);
692 ok(i4
== 11, "got %08x\n", i4
);
695 ((LARGE_INTEGER
*)src
)->QuadPart
= 107500;
697 hr
= IDataConvert_DataConvert(convert
, DBTYPE_CY
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
698 ok(hr
== S_OK
, "got %08x\n", hr
);
699 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
700 ok(dst_len
== sizeof(i4
), "got %d\n", dst_len
);
701 ok(i4
== 11, "got %08x\n", i4
);
704 *(DATE
*)src
= 10.7500;
706 hr
= IDataConvert_DataConvert(convert
, DBTYPE_DATE
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
707 ok(hr
== S_OK
, "got %08x\n", hr
);
708 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
709 ok(dst_len
== sizeof(i4
), "got %d\n", dst_len
);
710 ok(i4
== 11, "got %08x\n", i4
);
713 b
= SysAllocString(ten
);
716 hr
= IDataConvert_DataConvert(convert
, DBTYPE_BSTR
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
717 ok(hr
== S_OK
, "got %08x\n", hr
);
718 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
719 ok(dst_len
== sizeof(i4
), "got %d\n", dst_len
);
720 ok(i4
== 10, "got %08x\n", i4
);
724 *(SCODE
*)src
= 0x4321cafe;
726 hr
= IDataConvert_DataConvert(convert
, DBTYPE_ERROR
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
727 ok(hr
== DB_E_UNSUPPORTEDCONVERSION
, "got %08x\n", hr
);
728 ok(dst_status
== DBSTATUS_E_BADACCESSOR
, "got %08x\n", dst_status
);
729 ok(dst_len
== 0x1234, "got %d\n", dst_len
);
730 ok(i4
== 0x12345678, "got %08x\n", i4
);
733 *(VARIANT_BOOL
*)src
= VARIANT_TRUE
;
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
== 0xffffffff, "got %08x\n", i4
);
742 *(VARIANT_BOOL
*)src
= VARIANT_FALSE
;
744 hr
= IDataConvert_DataConvert(convert
, DBTYPE_BOOL
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
745 ok(hr
== S_OK
, "got %08x\n", hr
);
746 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
747 ok(dst_len
== sizeof(i4
), "got %d\n", dst_len
);
748 ok(i4
== 0, "got %08x\n", i4
);
751 V_VT((VARIANT
*)src
) = VT_I2
;
752 V_I2((VARIANT
*)src
) = 0x1234;
754 hr
= IDataConvert_DataConvert(convert
, DBTYPE_VARIANT
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
755 ok(hr
== S_OK
, "got %08x\n", hr
);
756 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
757 ok(dst_len
== sizeof(i4
), "got %d\n", dst_len
);
758 ok(i4
== 0x1234, "got %08x\n", i4
);
761 memset(src
, 0, sizeof(DECIMAL
));
762 ((DECIMAL
*)src
)->u1
.Lo64
= 0x1234;
764 hr
= IDataConvert_DataConvert(convert
, DBTYPE_DECIMAL
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
765 ok(hr
== S_OK
, "got %08x\n", hr
);
766 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
767 ok(dst_len
== sizeof(i4
), "got %d\n", dst_len
);
768 ok(i4
== 0x1234, "got %08x\n", i4
);
771 *(signed char*)src
= 0xab;
773 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I1
, 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
== 0xffffffab, "got %08x\n", i4
);
782 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI1
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
783 ok(hr
== S_OK
, "got %08x\n", hr
);
784 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
785 ok(dst_len
== sizeof(i4
), "got %d\n", dst_len
);
786 ok(i4
== 0xab, "got %08x\n", i4
);
789 *(WORD
*)src
= 0xabcd;
791 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI2
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
792 ok(hr
== S_OK
, "got %08x\n", hr
);
793 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
794 ok(dst_len
== sizeof(i4
), "got %d\n", dst_len
);
795 ok(i4
== 0xabcd, "got %08x\n", i4
);
798 *(DWORD
*)src
= 0xabcd1234;
800 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI4
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
801 ok(hr
== DB_E_ERRORSOCCURRED
, "got %08x\n", hr
);
802 ok(dst_status
== DBSTATUS_E_DATAOVERFLOW
, "got %08x\n", dst_status
);
804 ok(broken(dst_len
== sizeof(i4
)) || dst_len
== 0x1234 /* W2K+ */, "got %d\n", dst_len
);
805 ok(i4
== 0x12345678, "got %08x\n", i4
);
808 *(DWORD
*)src
= 0x1234abcd;
810 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI4
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
811 ok(hr
== S_OK
, "got %08x\n", hr
);
812 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
813 ok(dst_len
== sizeof(i4
), "got %d\n", dst_len
);
814 ok(i4
== 0x1234abcd, "got %08x\n", i4
);
817 ((LARGE_INTEGER
*)src
)->QuadPart
= 0x1234abcd;
819 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I8
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
821 broken(hr
== DB_E_UNSUPPORTEDCONVERSION
), /* win98 */
823 if(hr
!= DB_E_UNSUPPORTEDCONVERSION
) /* win98 doesn't support I8/UI8 */
825 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
826 ok(dst_len
== sizeof(i4
), "got %d\n", dst_len
);
827 ok(i4
== 0x1234abcd, "got %08x\n", i4
);
830 ((ULARGE_INTEGER
*)src
)->QuadPart
= 0x1234abcd;
832 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI8
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
833 ok(hr
== S_OK
, "got %08x\n", hr
);
834 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
835 ok(dst_len
== sizeof(i4
), "got %d\n", dst_len
);
836 ok(i4
== 0x1234abcd, "got %08x\n", i4
);
840 strcpy((char *)src
, "10");
842 hr
= IDataConvert_DataConvert(convert
, DBTYPE_STR
, DBTYPE_I4
, 2, &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 strcpy((char *)src
, "10");
851 hr
= IDataConvert_DataConvert(convert
, DBTYPE_STR
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, DBDATACONVERT_LENGTHFROMNTS
);
852 ok(hr
== S_OK
, "got %08x\n", hr
);
853 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
854 ok(dst_len
== sizeof(i4
), "got %d\n", dst_len
);
855 ok(i4
== 10, "got %08x\n", i4
);
858 memcpy(src
, ten
, sizeof(ten
));
860 hr
= IDataConvert_DataConvert(convert
, DBTYPE_WSTR
, DBTYPE_I4
, 4, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
861 ok(hr
== S_OK
, "got %08x\n", hr
);
862 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
863 ok(dst_len
== sizeof(i4
), "got %d\n", dst_len
);
864 ok(i4
== 10, "got %08x\n", i4
);
867 memcpy(src
, ten
, sizeof(ten
));
869 hr
= IDataConvert_DataConvert(convert
, DBTYPE_WSTR
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, DBDATACONVERT_LENGTHFROMNTS
);
870 ok(hr
== S_OK
, "got %08x\n", hr
);
871 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
872 ok(dst_len
== sizeof(i4
), "got %d\n", dst_len
);
873 ok(i4
== 10, "got %08x\n", i4
);
875 IDataConvert_Release(convert
);
878 static void test_converttobstr(void)
880 IDataConvert
*convert
;
886 static const WCHAR ten
[] = {'1','0',0};
889 hr
= CoCreateInstance(&CLSID_OLEDB_CONVERSIONLIBRARY
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDataConvert
, (void**)&convert
);
892 win_skip("Unable to load oledb conversion library\n");
897 hr
= IDataConvert_DataConvert(convert
, DBTYPE_EMPTY
, DBTYPE_BSTR
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
898 ok(hr
== S_OK
, "got %08x\n", hr
);
899 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
900 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
901 ok(dst
!= NULL
, "got %p\n", dst
);
902 ok(SysStringLen(dst
) == 0, "got %d\n", SysStringLen(dst
));
906 hr
= IDataConvert_DataConvert(convert
, DBTYPE_NULL
, DBTYPE_BSTR
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
907 ok(hr
== DB_E_UNSUPPORTEDCONVERSION
, "got %08x\n", hr
);
908 ok(dst_status
== DBSTATUS_E_BADACCESSOR
, "got %08x\n", dst_status
);
909 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
910 ok(dst
== (void*)0x1234, "got %p\n", dst
);
912 *(short *)src
= 4321;
913 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I2
, DBTYPE_BSTR
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
914 ok(hr
== S_OK
, "got %08x\n", hr
);
915 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
916 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
917 ok(dst
!= NULL
, "got %p\n", dst
);
918 ok(SysStringLen(dst
) == 4, "got %d\n", SysStringLen(dst
));
921 b
= SysAllocString(ten
);
923 hr
= IDataConvert_DataConvert(convert
, DBTYPE_BSTR
, DBTYPE_BSTR
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
924 ok(hr
== S_OK
, "got %08x\n", hr
);
925 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
926 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
927 ok(dst
!= NULL
, "got %p\n", dst
);
928 ok(dst
!= b
, "got %p src %p\n", dst
, b
);
929 ok(!lstrcmpW(b
, dst
), "got %s\n", wine_dbgstr_w(dst
));
933 IDataConvert_Release(convert
);
936 static void test_converttowstr(void)
938 IDataConvert
*convert
;
944 static const WCHAR ten
[] = {'1','0',0};
945 static const WCHAR fourthreetwoone
[] = {'4','3','2','1',0};
946 static const WCHAR guid_str
[] = {
947 '{','0','C','7','3','3','A','8','D','-','2','A','1','C','-','1','1','C','E','-',
948 'A','D','E','5','-','0','0','A','A','0','0','4','4','7','7','3','D','}',0};
949 static const WCHAR hexunpacked_w
[] = {'5','7','0','0','6','9','0','0','6','E','0','0','6','5','0','0','0','0','0','0', 0 };
950 static const WCHAR hexpacked_w
[] = {'W','i','n','e', 0 };
953 hr
= CoCreateInstance(&CLSID_OLEDB_CONVERSIONLIBRARY
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDataConvert
, (void**)&convert
);
956 win_skip("Unable to load oledb conversion library\n");
961 memset(dst
, 0xcc, sizeof(dst
));
963 hr
= IDataConvert_DataConvert(convert
, DBTYPE_EMPTY
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
964 ok(hr
== S_OK
, "got %08x\n", hr
);
965 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
966 ok(dst_len
== 0, "got %d\n", dst_len
);
967 ok(dst
[0] == 0, "got %02x\n", dst
[0]);
968 ok(dst
[1] == 0xcccc, "got %02x\n", dst
[1]);
970 memset(dst
, 0xcc, sizeof(dst
));
972 hr
= IDataConvert_DataConvert(convert
, DBTYPE_NULL
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
973 ok(hr
== DB_E_UNSUPPORTEDCONVERSION
, "got %08x\n", hr
);
974 ok(dst_status
== DBSTATUS_E_BADACCESSOR
, "got %08x\n", dst_status
);
975 ok(dst_len
== 0x1234, "got %d\n", dst_len
);
976 ok(dst
[0] == 0xcccc, "got %02x\n", dst
[0]);
978 *(short *)src
= 4321;
980 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I2
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
981 ok(hr
== S_OK
, "got %08x\n", hr
);
982 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
983 ok(dst_len
== 8, "got %d\n", dst_len
);
984 ok(!lstrcmpW(dst
, fourthreetwoone
), "got %s\n", wine_dbgstr_w(dst
));
986 *(short *)src
= 4321;
987 memset(dst
, 0xcc, sizeof(dst
));
989 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I2
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, 0, 0, &dst_status
, 0, 0, 0);
990 ok(hr
== DB_E_ERRORSOCCURRED
, "got %08x\n", hr
);
991 ok(dst_status
== DBSTATUS_E_DATAOVERFLOW
, "got %08x\n", dst_status
);
992 ok(dst_len
== 8, "got %d\n", dst_len
);
993 ok(dst
[0] == 0xcccc, "got %02x\n", dst
[0]);
995 *(short *)src
= 4321;
996 memset(dst
, 0xcc, sizeof(dst
));
998 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I2
, DBTYPE_WSTR
, 0, &dst_len
, src
, NULL
, 0, 0, &dst_status
, 0, 0, 0);
999 ok(hr
== S_OK
, "got %08x\n", hr
);
1000 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1001 ok(dst_len
== 8, "got %d\n", dst_len
);
1002 ok(dst
[0] == 0xcccc, "got %02x\n", dst
[0]);
1004 *(short *)src
= 4321;
1005 memset(dst
, 0xcc, sizeof(dst
));
1007 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I2
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, 4, 0, &dst_status
, 0, 0, 0);
1008 ok(hr
== S_OK
, "got %08x\n", hr
);
1009 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1010 ok(dst_len
== 8, "got %d\n", dst_len
);
1011 ok(dst
[0] == '4', "got %02x\n", dst
[0]);
1012 ok(dst
[1] == 0, "got %02x\n", dst
[1]);
1013 ok(dst
[2] == 0xcccc, "got %02x\n", dst
[2]);
1015 *(short *)src
= 4321;
1016 memset(dst
, 0xcc, sizeof(dst
));
1018 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I2
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, 2, 0, &dst_status
, 0, 0, 0);
1019 ok(hr
== S_OK
, "got %08x\n", hr
);
1020 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1021 ok(dst_len
== 8, "got %d\n", dst_len
);
1022 ok(dst
[0] == 0, "got %02x\n", dst
[0]);
1023 ok(dst
[1] == 0xcccc, "got %02x\n", dst
[1]);
1025 *(short *)src
= 4321;
1026 memset(dst
, 0xcc, sizeof(dst
));
1028 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I2
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, 8, 0, &dst_status
, 0, 0, 0);
1029 ok(hr
== S_OK
, "got %08x\n", hr
);
1030 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1031 ok(dst_len
== 8, "got %d\n", dst_len
);
1032 ok(dst
[0] == '4', "got %02x\n", dst
[0]);
1033 ok(dst
[1] == '3', "got %02x\n", dst
[1]);
1034 ok(dst
[2] == '2', "got %02x\n", dst
[2]);
1035 ok(dst
[3] == 0, "got %02x\n", dst
[3]);
1036 ok(dst
[4] == 0xcccc, "got %02x\n", dst
[4]);
1042 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I4
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1043 ok(hr
== S_OK
, "got %08x\n", hr
);
1044 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1045 ok(dst_len
== 8, "got %d\n", dst_len
);
1046 ok(!lstrcmpW(dst
, fourthreetwoone
), "got %s\n", wine_dbgstr_w(dst
));
1049 memset(dst
, 0xcc, sizeof(dst
));
1051 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I4
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, 0, 0, &dst_status
, 0, 0, 0);
1052 ok(hr
== DB_E_ERRORSOCCURRED
, "got %08x\n", hr
);
1053 ok(dst_status
== DBSTATUS_E_DATAOVERFLOW
, "got %08x\n", dst_status
);
1054 ok(dst_len
== 8, "got %d\n", dst_len
);
1055 ok(dst
[0] == 0xcccc, "got %02x\n", dst
[0]);
1058 memset(dst
, 0xcc, sizeof(dst
));
1059 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I4
, DBTYPE_WSTR
, 0, &dst_len
, src
, NULL
, 0, 0, &dst_status
, 0, 0, 0);
1060 ok(hr
== S_OK
, "got %08x\n", hr
);
1061 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1062 ok(dst_len
== 8, "got %d\n", dst_len
);
1063 ok(dst
[0] == 0xcccc, "got %02x\n", dst
[0]);
1066 memset(dst
, 0xcc, sizeof(dst
));
1068 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I4
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, 4, 0, &dst_status
, 0, 0, 0);
1069 ok(hr
== S_OK
, "got %08x\n", hr
);
1070 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1071 ok(dst_len
== 8, "got %d\n", dst_len
);
1072 ok(dst
[0] == '4', "got %02x\n", dst
[0]);
1073 ok(dst
[1] == 0, "got %02x\n", dst
[1]);
1074 ok(dst
[2] == 0xcccc, "got %02x\n", dst
[2]);
1077 memset(dst
, 0xcc, sizeof(dst
));
1079 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I4
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, 2, 0, &dst_status
, 0, 0, 0);
1080 ok(hr
== S_OK
, "got %08x\n", hr
);
1081 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1082 ok(dst_len
== 8, "got %d\n", dst_len
);
1083 ok(dst
[0] == 0, "got %02x\n", dst
[0]);
1084 ok(dst
[1] == 0xcccc, "got %02x\n", dst
[1]);
1087 memset(dst
, 0xcc, sizeof(dst
));
1089 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I4
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, 8, 0, &dst_status
, 0, 0, 0);
1090 ok(hr
== S_OK
, "got %08x\n", hr
);
1091 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1092 ok(dst_len
== 8, "got %d\n", dst_len
);
1093 ok(dst
[0] == '4', "got %02x\n", dst
[0]);
1094 ok(dst
[1] == '3', "got %02x\n", dst
[1]);
1095 ok(dst
[2] == '2', "got %02x\n", dst
[2]);
1096 ok(dst
[3] == 0, "got %02x\n", dst
[3]);
1097 ok(dst
[4] == 0xcccc, "got %02x\n", dst
[4]);
1101 *(float *)src
= 4321;
1103 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R4
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1104 ok(hr
== S_OK
, "got %08x\n", hr
);
1105 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1106 ok(dst_len
== 8, "got %d\n", dst_len
);
1107 ok(!lstrcmpW(dst
, fourthreetwoone
), "got %s\n", wine_dbgstr_w(dst
));
1109 *(float *)src
= 4321;
1110 memset(dst
, 0xcc, sizeof(dst
));
1112 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R4
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, 0, 0, &dst_status
, 0, 0, 0);
1113 ok(hr
== DB_E_ERRORSOCCURRED
, "got %08x\n", hr
);
1114 ok(dst_status
== DBSTATUS_E_DATAOVERFLOW
, "got %08x\n", dst_status
);
1115 ok(dst_len
== 8, "got %d\n", dst_len
);
1116 ok(dst
[0] == 0xcccc, "got %02x\n", dst
[0]);
1118 *(float *)src
= 4321;
1119 memset(dst
, 0xcc, sizeof(dst
));
1120 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R4
, DBTYPE_WSTR
, 0, &dst_len
, src
, NULL
, 0, 0, &dst_status
, 0, 0, 0);
1121 ok(hr
== S_OK
, "got %08x\n", hr
);
1122 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1123 ok(dst_len
== 8, "got %d\n", dst_len
);
1124 ok(dst
[0] == 0xcccc, "got %02x\n", dst
[0]);
1126 *(float *)src
= 4321;
1127 memset(dst
, 0xcc, sizeof(dst
));
1129 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R4
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, 4, 0, &dst_status
, 0, 0, 0);
1130 ok(hr
== S_OK
, "got %08x\n", hr
);
1131 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1132 ok(dst_len
== 8, "got %d\n", dst_len
);
1133 ok(dst
[0] == '4', "got %02x\n", dst
[0]);
1134 ok(dst
[1] == 0, "got %02x\n", dst
[1]);
1135 ok(dst
[2] == 0xcccc, "got %02x\n", dst
[2]);
1137 *(float *)src
= 4321;
1138 memset(dst
, 0xcc, sizeof(dst
));
1140 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R4
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, 2, 0, &dst_status
, 0, 0, 0);
1141 ok(hr
== S_OK
, "got %08x\n", hr
);
1142 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1143 ok(dst_len
== 8, "got %d\n", dst_len
);
1144 ok(dst
[0] == 0, "got %02x\n", dst
[0]);
1145 ok(dst
[1] == 0xcccc, "got %02x\n", dst
[1]);
1147 *(float *)src
= 4321;
1148 memset(dst
, 0xcc, sizeof(dst
));
1150 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R4
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, 8, 0, &dst_status
, 0, 0, 0);
1151 ok(hr
== S_OK
, "got %08x\n", hr
);
1152 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1153 ok(dst_len
== 8, "got %d\n", dst_len
);
1154 ok(dst
[0] == '4', "got %02x\n", dst
[0]);
1155 ok(dst
[1] == '3', "got %02x\n", dst
[1]);
1156 ok(dst
[2] == '2', "got %02x\n", dst
[2]);
1157 ok(dst
[3] == 0, "got %02x\n", dst
[3]);
1158 ok(dst
[4] == 0xcccc, "got %02x\n", dst
[4]);
1162 *(double *)src
= 4321;
1164 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R8
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1165 ok(hr
== S_OK
, "got %08x\n", hr
);
1166 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1167 ok(dst_len
== 8, "got %d\n", dst_len
);
1168 ok(!lstrcmpW(dst
, fourthreetwoone
), "got %s\n", wine_dbgstr_w(dst
));
1170 *(double *)src
= 4321;
1171 memset(dst
, 0xcc, sizeof(dst
));
1172 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R8
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, 0, 0, &dst_status
, 0, 0, 0);
1173 ok(hr
== DB_E_ERRORSOCCURRED
, "got %08x\n", hr
);
1174 ok(dst_status
== DBSTATUS_E_DATAOVERFLOW
, "got %08x\n", dst_status
);
1175 ok(dst_len
== 8, "got %d\n", dst_len
);
1176 ok(dst
[0] == 0xcccc, "got %02x\n", dst
[0]);
1178 *(double *)src
= 4321;
1179 memset(dst
, 0xcc, sizeof(dst
));
1181 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R8
, DBTYPE_WSTR
, 0, &dst_len
, src
, NULL
, 0, 0, &dst_status
, 0, 0, 0);
1182 ok(hr
== S_OK
, "got %08x\n", hr
);
1183 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1184 ok(dst_len
== 8, "got %d\n", dst_len
);
1185 ok(dst
[0] == 0xcccc, "got %02x\n", dst
[0]);
1187 *(double *)src
= 4321;
1188 memset(dst
, 0xcc, sizeof(dst
));
1190 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R8
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, 4, 0, &dst_status
, 0, 0, 0);
1191 ok(hr
== S_OK
, "got %08x\n", hr
);
1192 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1193 ok(dst_len
== 8, "got %d\n", dst_len
);
1194 ok(dst
[0] == '4', "got %02x\n", dst
[0]);
1195 ok(dst
[1] == 0, "got %02x\n", dst
[1]);
1196 ok(dst
[2] == 0xcccc, "got %02x\n", dst
[2]);
1198 *(double *)src
= 4321;
1199 memset(dst
, 0xcc, sizeof(dst
));
1201 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R8
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, 2, 0, &dst_status
, 0, 0, 0);
1202 ok(hr
== S_OK
, "got %08x\n", hr
);
1203 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1204 ok(dst_len
== 8, "got %d\n", dst_len
);
1205 ok(dst
[0] == 0, "got %02x\n", dst
[0]);
1206 ok(dst
[1] == 0xcccc, "got %02x\n", dst
[1]);
1208 *(double *)src
= 4321;
1209 memset(dst
, 0xcc, sizeof(dst
));
1211 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R8
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, 8, 0, &dst_status
, 0, 0, 0);
1212 ok(hr
== S_OK
, "got %08x\n", hr
);
1213 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1214 ok(dst_len
== 8, "got %d\n", dst_len
);
1215 ok(dst
[0] == '4', "got %02x\n", dst
[0]);
1216 ok(dst
[1] == '3', "got %02x\n", dst
[1]);
1217 ok(dst
[2] == '2', "got %02x\n", dst
[2]);
1218 ok(dst
[3] == 0, "got %02x\n", dst
[3]);
1219 ok(dst
[4] == 0xcccc, "got %02x\n", dst
[4]);
1223 memset(src
, 0, sizeof(src
));
1224 ((CY
*)src
)->int64
= 43210000;
1225 memset(dst
, 0xcc, sizeof(dst
));
1227 hr
= IDataConvert_DataConvert(convert
, DBTYPE_CY
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1228 ok(hr
== S_OK
, "got %08x\n", hr
);
1229 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1230 ok(dst_len
== 8, "got %d\n", dst_len
);
1231 ok(!lstrcmpW(dst
, fourthreetwoone
), "got %s\n", wine_dbgstr_w(dst
));
1235 memset(src
, 0, sizeof(src
));
1236 *(signed char *)src
= 10;
1238 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I1
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1239 ok(hr
== S_OK
, "got %08x\n", hr
);
1240 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1241 ok(dst_len
== 4, "got %d\n", dst_len
);
1242 ok(!lstrcmpW(dst
, ten
), "got %s\n", wine_dbgstr_w(dst
));
1244 memset(src
, 0, sizeof(src
));
1245 *(unsigned char *)src
= 10;
1247 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI1
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1248 ok(hr
== S_OK
, "got %08x\n", hr
);
1249 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1250 ok(dst_len
== 4, "got %d\n", dst_len
);
1251 ok(!lstrcmpW(dst
, ten
), "got %s\n", wine_dbgstr_w(dst
));
1253 memset(src
, 0, sizeof(src
));
1254 *(unsigned short *)src
= 4321;
1256 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI2
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1257 ok(hr
== S_OK
, "got %08x\n", hr
);
1258 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1259 ok(dst_len
== 8, "got %d\n", dst_len
);
1260 ok(!lstrcmpW(dst
, fourthreetwoone
), "got %s\n", wine_dbgstr_w(dst
));
1262 memset(src
, 0, sizeof(src
));
1263 *(unsigned int *)src
= 4321;
1265 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI4
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1266 ok(hr
== S_OK
, "got %08x\n", hr
);
1267 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1268 ok(dst_len
== 8, "got %d\n", dst_len
);
1269 ok(!lstrcmpW(dst
, fourthreetwoone
), "got %s\n", wine_dbgstr_w(dst
));
1271 memset(src
, 0, sizeof(src
));
1272 ((LARGE_INTEGER
*)src
)->QuadPart
= 4321;
1274 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I8
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1275 ok(broken(DB_E_UNSUPPORTEDCONVERSION
) || hr
== S_OK
/* W2K+ */, "got %08x\n", hr
);
1276 ok(broken(dst_status
== DBSTATUS_E_BADACCESSOR
) || dst_status
== DBSTATUS_S_OK
/* W2K+ */, "got %08x\n", dst_status
);
1277 ok(broken(dst_len
== 0x1234) || dst_len
== 8 /* W2K+ */, "got %d\n", dst_len
);
1278 ok(!lstrcmpW(dst
, fourthreetwoone
), "got %s\n", wine_dbgstr_w(dst
));
1280 memset(src
, 0, sizeof(src
));
1281 ((ULARGE_INTEGER
*)src
)->QuadPart
= 4321;
1282 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI8
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1283 ok(broken(DB_E_UNSUPPORTEDCONVERSION
) || hr
== S_OK
/* W2K+ */, "got %08x\n", hr
);
1284 ok(broken(dst_status
== DBSTATUS_E_BADACCESSOR
) || dst_status
== DBSTATUS_S_OK
/* W2K+ */, "got %08x\n", dst_status
);
1285 ok(broken(dst_len
== 0x1234) || dst_len
== 8 /* W2K+ */, "got %d\n", dst_len
);
1286 ok(!lstrcmpW(dst
, fourthreetwoone
), "got %s\n", wine_dbgstr_w(dst
));
1290 memset(src
, 0, sizeof(src
));
1291 memcpy(src
, &IID_IDataConvert
, sizeof(GUID
));
1292 memset(dst
, 0xcc, sizeof(dst
));
1294 hr
= IDataConvert_DataConvert(convert
, DBTYPE_GUID
, DBTYPE_WSTR
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1295 ok(hr
== S_OK
, "got %08x\n", hr
);
1296 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1297 ok(dst_len
== 76, "got %d\n", dst_len
);
1298 ok(!lstrcmpW(dst
, guid_str
), "got %s\n", wine_dbgstr_w(dst
));
1302 b
= SysAllocString(ten
);
1305 hr
= IDataConvert_DataConvert(convert
, DBTYPE_BSTR
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1306 ok(hr
== S_OK
, "got %08x\n", hr
);
1307 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1308 ok(dst_len
== 4, "got %d\n", dst_len
);
1309 ok(!lstrcmpW(b
, dst
), "got %s\n", wine_dbgstr_w(dst
));
1312 memcpy(src
, ten
, sizeof(ten
));
1314 hr
= IDataConvert_DataConvert(convert
, DBTYPE_WSTR
, DBTYPE_WSTR
, 2, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1315 ok(hr
== S_OK
, "got %08x\n", hr
);
1316 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1317 ok(dst_len
== 2, "got %d\n", dst_len
);
1318 ok(dst
[0] == '1', "got %02x\n", dst
[0]);
1319 ok(dst
[1] == 0, "got %02x\n", dst
[1]);
1321 memcpy(src
, ten
, sizeof(ten
));
1323 hr
= IDataConvert_DataConvert(convert
, DBTYPE_WSTR
, DBTYPE_WSTR
, 4, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1324 ok(hr
== S_OK
, "got %08x\n", hr
);
1325 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1326 ok(dst_len
== 4, "got %d\n", dst_len
);
1327 ok(!lstrcmpW(ten
, dst
), "got %s\n", wine_dbgstr_w(dst
));
1329 memcpy(src
, ten
, sizeof(ten
));
1331 hr
= IDataConvert_DataConvert(convert
, DBTYPE_WSTR
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, DBDATACONVERT_LENGTHFROMNTS
);
1332 ok(hr
== S_OK
, "got %08x\n", hr
);
1333 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1334 ok(dst_len
== 4, "got %d\n", dst_len
);
1335 ok(!lstrcmpW(ten
, dst
), "got %s\n", wine_dbgstr_w(dst
));
1339 /* DBTYPE_BYTES to DBTYPE_*STR unpacks binary data into a hex string */
1340 memcpy(src
, hexpacked_w
, sizeof(hexpacked_w
));
1341 memset(dst
, 0xcc, sizeof(dst
));
1343 hr
= IDataConvert_DataConvert(convert
, DBTYPE_BYTES
, DBTYPE_WSTR
, sizeof(hexpacked_w
), &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1344 ok(hr
== S_OK
, "got %08x\n", hr
);
1345 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1346 ok(dst_len
== sizeof(hexpacked_w
) * 4, "got %d\n", dst_len
);
1347 ok(!lstrcmpW(hexunpacked_w
, dst
), "got %s\n", wine_dbgstr_w(dst
));
1348 ok(dst
[sizeof(hexpacked_w
)/sizeof(WCHAR
) * 4 + 1] == 0xcccc, "clobbered buffer\n");
1350 memcpy(src
, hexpacked_w
, sizeof(hexpacked_w
));
1351 memset(dst
, 0xcc, sizeof(dst
));
1353 hr
= IDataConvert_DataConvert(convert
, DBTYPE_BYTES
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1354 ok(hr
== S_OK
, "got %08x\n", hr
);
1355 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1356 ok(dst_len
== 0, "got %d\n", dst_len
);
1357 ok(dst
[0] == 0, "not null terminated\n");
1358 ok(dst
[1] == 0xcccc, "clobbered buffer\n");
1360 memcpy(src
, hexpacked_w
, sizeof(hexpacked_w
));
1361 memset(dst
, 0xcc, sizeof(dst
));
1363 hr
= IDataConvert_DataConvert(convert
, DBTYPE_BYTES
, DBTYPE_WSTR
, 4, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1364 ok(hr
== S_OK
, "got %08x\n", hr
);
1365 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1366 ok(dst_len
== 2 * sizeof(WCHAR
) * 4, "got %d\n", dst_len
);
1367 ok(!memcmp(hexunpacked_w
, dst
, 2 * sizeof(WCHAR
) * 4 ), "got %s\n", wine_dbgstr_w(dst
));
1368 ok(dst
[2 * 4] == 0, "not null terminated\n");
1369 ok(dst
[2 * 4 + 1] == 0xcccc, "clobbered buffer\n");
1371 memcpy(src
, hexpacked_w
, sizeof(hexpacked_w
));
1372 memset(dst
, 0xcc, sizeof(dst
));
1374 hr
= IDataConvert_DataConvert(convert
, DBTYPE_BYTES
, DBTYPE_WSTR
, sizeof(hexpacked_w
), &dst_len
, src
, dst
, 2 * sizeof(WCHAR
) * 4 + sizeof(WCHAR
), 0, &dst_status
, 0, 0, 0);
1375 ok(hr
== S_OK
, "got %08x\n", hr
);
1376 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1377 ok(dst_len
== sizeof(hexpacked_w
) * 4, "got %d\n", dst_len
);
1378 ok(!memcmp(hexunpacked_w
, dst
, 2 * sizeof(WCHAR
) * 4 ), "got %s\n", wine_dbgstr_w(dst
));
1379 ok(dst
[2 * 4] == 0, "not null terminated\n");
1380 ok(dst
[2 * 4 + 1] == 0xcccc, "clobbered buffer\n");
1382 memcpy(src
, hexpacked_w
, sizeof(hexpacked_w
));
1383 memset(dst
, 0xcc, sizeof(dst
));
1385 hr
= IDataConvert_DataConvert(convert
, DBTYPE_BYTES
, DBTYPE_WSTR
, sizeof(hexpacked_w
), &dst_len
, src
, dst
, 2 * sizeof(WCHAR
) * 4 +1, 0, &dst_status
, 0, 0, 0);
1386 ok(hr
== S_OK
, "got %08x\n", hr
);
1387 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1388 ok(dst_len
== sizeof(hexpacked_w
) * 4, "got %d\n", dst_len
);
1389 ok(!memcmp(hexunpacked_w
, dst
, 2 * sizeof(WCHAR
) * 4 - 2 ), "got %s\n", wine_dbgstr_w(dst
));
1390 ok(dst
[2 * 4 - 1] == 0, "not null terminated\n");
1391 ok(dst
[2 * 4] == 0xcccc, "clobbered buffer\n");
1393 memcpy(src
, hexpacked_w
, sizeof(hexpacked_w
));
1394 memset(dst
, 0xcc, sizeof(dst
));
1396 hr
= IDataConvert_DataConvert(convert
, DBTYPE_BYTES
, DBTYPE_WSTR
, sizeof(hexpacked_w
), &dst_len
, src
, dst
, 2 * sizeof(WCHAR
) * 4, 0, &dst_status
, 0, 0, 0);
1397 ok(hr
== S_OK
, "got %08x\n", hr
);
1398 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1399 ok(dst_len
== sizeof(hexpacked_w
) * 4, "got %d\n", dst_len
);
1400 ok(!memcmp(hexunpacked_w
, dst
, 2 * sizeof(WCHAR
) * 4 - 2 ), "got %s\n", wine_dbgstr_w(dst
));
1401 ok(dst
[2 * 4 - 1] == 0, "not null terminated\n");
1402 ok(dst
[2 * 4] == 0xcccc, "clobbered buffer\n");
1404 memcpy(src
, hexpacked_w
, sizeof(hexpacked_w
));
1405 memset(dst
, 0xcc, sizeof(dst
));
1407 hr
= IDataConvert_DataConvert(convert
, DBTYPE_BYTES
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, DBDATACONVERT_LENGTHFROMNTS
);
1408 ok(hr
== S_OK
, "got %08x\n", hr
);
1409 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1410 ok(dst_len
== 0, "got %d\n", dst_len
);
1411 ok(dst
[0] == 0, "not null terminated\n");
1412 ok(dst
[1] == 0xcccc, "clobbered buffer\n");
1415 IDataConvert_Release(convert
);
1418 static void test_converttostr(void)
1420 IDataConvert
*convert
;
1424 DBSTATUS dst_status
;
1426 static const WCHAR ten
[] = {'1','0',0};
1427 static const char ten_a
[] = "10";
1428 static const char fourthreetwoone
[] = "4321";
1429 static const char guid_str
[] = "{0C733A8D-2A1C-11CE-ADE5-00AA0044773D}";
1430 static const char hexunpacked_a
[] = "57696E6500";
1431 static const char hexpacked_a
[] = "Wine";
1434 hr
= CoCreateInstance(&CLSID_OLEDB_CONVERSIONLIBRARY
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDataConvert
, (void**)&convert
);
1437 win_skip("Unable to load oledb conversion library\n");
1442 memset(dst
, 0xcc, sizeof(dst
));
1444 hr
= IDataConvert_DataConvert(convert
, DBTYPE_EMPTY
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1445 ok(hr
== S_OK
, "got %08x\n", hr
);
1446 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1447 ok(dst_len
== 0, "got %d\n", dst_len
);
1448 ok(dst
[0] == 0, "got %02x\n", dst
[0]);
1449 ok(dst
[1] == (char)0xcc, "got %02x\n", dst
[1]);
1451 memset(dst
, 0xcc, sizeof(dst
));
1453 hr
= IDataConvert_DataConvert(convert
, DBTYPE_NULL
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1454 ok(hr
== DB_E_UNSUPPORTEDCONVERSION
, "got %08x\n", hr
);
1455 ok(dst_status
== DBSTATUS_E_BADACCESSOR
, "got %08x\n", dst_status
);
1456 ok(dst_len
== 0x1234, "got %d\n", dst_len
);
1457 ok(dst
[0] == (char)0xcc, "got %02x\n", dst
[0]);
1459 *(short *)src
= 4321;
1461 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I2
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1462 ok(hr
== S_OK
, "got %08x\n", hr
);
1463 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1464 ok(dst_len
== 4, "got %d\n", dst_len
);
1465 ok(!lstrcmpA(dst
, fourthreetwoone
), "got %s\n", dst
);
1467 *(short *)src
= 4321;
1468 memset(dst
, 0xcc, sizeof(dst
));
1470 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I2
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, 0, 0, &dst_status
, 0, 0, 0);
1471 ok(hr
== DB_E_ERRORSOCCURRED
, "got %08x\n", hr
);
1472 ok(dst_status
== DBSTATUS_E_DATAOVERFLOW
, "got %08x\n", dst_status
);
1473 ok(dst_len
== 4, "got %d\n", dst_len
);
1474 ok(dst
[0] == (char)0xcc, "got %02x\n", dst
[0]);
1476 *(short *)src
= 4321;
1477 memset(dst
, 0xcc, sizeof(dst
));
1479 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I2
, DBTYPE_STR
, 0, &dst_len
, src
, NULL
, 0, 0, &dst_status
, 0, 0, 0);
1480 ok(hr
== S_OK
, "got %08x\n", hr
);
1481 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1482 ok(dst_len
== 4, "got %d\n", dst_len
);
1483 ok(dst
[0] == (char)0xcc, "got %02x\n", dst
[0]);
1485 *(short *)src
= 4321;
1486 memset(dst
, 0xcc, sizeof(dst
));
1488 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I2
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, 2, 0, &dst_status
, 0, 0, 0);
1489 ok(hr
== S_OK
, "got %08x\n", hr
);
1490 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1491 ok(dst_len
== 4, "got %d\n", dst_len
);
1492 ok(dst
[0] == '4', "got %02x\n", dst
[0]);
1493 ok(dst
[1] == 0, "got %02x\n", dst
[1]);
1494 ok(dst
[2] == (char)0xcc, "got %02x\n", dst
[2]);
1496 *(short *)src
= 4321;
1497 memset(dst
, 0xcc, sizeof(dst
));
1499 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I2
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, 1, 0, &dst_status
, 0, 0, 0);
1500 ok(hr
== S_OK
, "got %08x\n", hr
);
1501 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1502 ok(dst_len
== 4, "got %d\n", dst_len
);
1503 ok(dst
[0] == 0, "got %02x\n", dst
[0]);
1504 ok(dst
[1] == (char)0xcc, "got %02x\n", dst
[1]);
1506 *(short *)src
= 4321;
1507 memset(dst
, 0xcc, sizeof(dst
));
1509 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I2
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, 4, 0, &dst_status
, 0, 0, 0);
1510 ok(hr
== S_OK
, "got %08x\n", hr
);
1511 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1512 ok(dst_len
== 4, "got %d\n", dst_len
);
1513 ok(dst
[0] == '4', "got %02x\n", dst
[0]);
1514 ok(dst
[1] == '3', "got %02x\n", dst
[1]);
1515 ok(dst
[2] == '2', "got %02x\n", dst
[2]);
1516 ok(dst
[3] == 0, "got %02x\n", dst
[3]);
1517 ok(dst
[4] == (char)0xcc, "got %02x\n", dst
[4]);
1522 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I4
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1523 ok(hr
== S_OK
, "got %08x\n", hr
);
1524 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1525 ok(dst_len
== 4, "got %d\n", dst_len
);
1526 ok(!lstrcmpA(dst
, fourthreetwoone
), "got %s\n", dst
);
1529 memset(dst
, 0xcc, sizeof(dst
));
1531 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I4
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, 0, 0, &dst_status
, 0, 0, 0);
1532 ok(hr
== DB_E_ERRORSOCCURRED
, "got %08x\n", hr
);
1533 ok(dst_status
== DBSTATUS_E_DATAOVERFLOW
, "got %08x\n", dst_status
);
1534 ok(dst_len
== 4, "got %d\n", dst_len
);
1535 ok(dst
[0] == (char)0xcc, "got %02x\n", dst
[0]);
1538 memset(dst
, 0xcc, sizeof(dst
));
1540 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I4
, DBTYPE_STR
, 0, &dst_len
, src
, NULL
, 0, 0, &dst_status
, 0, 0, 0);
1541 ok(hr
== S_OK
, "got %08x\n", hr
);
1542 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1543 ok(dst_len
== 4, "got %d\n", dst_len
);
1544 ok(dst
[0] == (char)0xcc, "got %02x\n", dst
[0]);
1547 memset(dst
, 0xcc, sizeof(dst
));
1549 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I4
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, 2, 0, &dst_status
, 0, 0, 0);
1550 ok(hr
== S_OK
, "got %08x\n", hr
);
1551 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1552 ok(dst_len
== 4, "got %d\n", dst_len
);
1553 ok(dst
[0] == '4', "got %02x\n", dst
[0]);
1554 ok(dst
[1] == 0, "got %02x\n", dst
[1]);
1555 ok(dst
[2] == (char)0xcc, "got %02x\n", dst
[2]);
1558 memset(dst
, 0xcc, sizeof(dst
));
1560 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I4
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, 1, 0, &dst_status
, 0, 0, 0);
1561 ok(hr
== S_OK
, "got %08x\n", hr
);
1562 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1563 ok(dst_len
== 4, "got %d\n", dst_len
);
1564 ok(dst
[0] == 0, "got %02x\n", dst
[0]);
1565 ok(dst
[1] == (char)0xcc, "got %02x\n", dst
[1]);
1568 memset(dst
, 0xcc, sizeof(dst
));
1570 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I4
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, 4, 0, &dst_status
, 0, 0, 0);
1571 ok(hr
== S_OK
, "got %08x\n", hr
);
1572 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1573 ok(dst_len
== 4, "got %d\n", dst_len
);
1574 ok(dst
[0] == '4', "got %02x\n", dst
[0]);
1575 ok(dst
[1] == '3', "got %02x\n", dst
[1]);
1576 ok(dst
[2] == '2', "got %02x\n", dst
[2]);
1577 ok(dst
[3] == 0, "got %02x\n", dst
[3]);
1578 ok(dst
[4] == (char)0xcc, "got %02x\n", dst
[4]);
1581 *(float *)src
= 4321;
1583 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R4
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1584 ok(hr
== S_OK
, "got %08x\n", hr
);
1585 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1586 ok(dst_len
== 4, "got %d\n", dst_len
);
1587 ok(!lstrcmpA(dst
, fourthreetwoone
), "got %s\n", dst
);
1589 *(float *)src
= 4321;
1590 memset(dst
, 0xcc, sizeof(dst
));
1592 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R4
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, 0, 0, &dst_status
, 0, 0, 0);
1593 ok(hr
== DB_E_ERRORSOCCURRED
, "got %08x\n", hr
);
1594 ok(dst_status
== DBSTATUS_E_DATAOVERFLOW
, "got %08x\n", dst_status
);
1595 ok(dst_len
== 4, "got %d\n", dst_len
);
1596 ok(dst
[0] == (char)0xcc, "got %02x\n", dst
[0]);
1598 *(float *)src
= 4321;
1599 memset(dst
, 0xcc, sizeof(dst
));
1601 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R4
, DBTYPE_STR
, 0, &dst_len
, src
, NULL
, 0, 0, &dst_status
, 0, 0, 0);
1602 ok(hr
== S_OK
, "got %08x\n", hr
);
1603 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1604 ok(dst_len
== 4, "got %d\n", dst_len
);
1605 ok(dst
[0] == (char)0xcc, "got %02x\n", dst
[0]);
1607 *(float *)src
= 4321;
1608 memset(dst
, 0xcc, sizeof(dst
));
1610 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R4
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, 2, 0, &dst_status
, 0, 0, 0);
1611 ok(hr
== S_OK
, "got %08x\n", hr
);
1612 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1613 ok(dst_len
== 4, "got %d\n", dst_len
);
1614 ok(dst
[0] == '4', "got %02x\n", dst
[0]);
1615 ok(dst
[1] == 0, "got %02x\n", dst
[1]);
1616 ok(dst
[2] == (char)0xcc, "got %02x\n", dst
[2]);
1618 *(float *)src
= 4321;
1619 memset(dst
, 0xcc, sizeof(dst
));
1621 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R4
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, 1, 0, &dst_status
, 0, 0, 0);
1622 ok(hr
== S_OK
, "got %08x\n", hr
);
1623 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1624 ok(dst_len
== 4, "got %d\n", dst_len
);
1625 ok(dst
[0] == 0, "got %02x\n", dst
[0]);
1626 ok(dst
[1] == (char)0xcc, "got %02x\n", dst
[1]);
1628 *(float *)src
= 4321;
1629 memset(dst
, 0xcc, sizeof(dst
));
1631 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R4
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, 4, 0, &dst_status
, 0, 0, 0);
1632 ok(hr
== S_OK
, "got %08x\n", hr
);
1633 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1634 ok(dst_len
== 4, "got %d\n", dst_len
);
1635 ok(dst
[0] == '4', "got %02x\n", dst
[0]);
1636 ok(dst
[1] == '3', "got %02x\n", dst
[1]);
1637 ok(dst
[2] == '2', "got %02x\n", dst
[2]);
1638 ok(dst
[3] == 0, "got %02x\n", dst
[3]);
1639 ok(dst
[4] == (char)0xcc, "got %02x\n", dst
[4]);
1642 *(double *)src
= 4321;
1644 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R8
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1645 ok(hr
== S_OK
, "got %08x\n", hr
);
1646 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1647 ok(dst_len
== 4, "got %d\n", dst_len
);
1648 ok(!lstrcmpA(dst
, fourthreetwoone
), "got %s\n", dst
);
1650 *(double *)src
= 4321;
1651 memset(dst
, 0xcc, sizeof(dst
));
1653 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R8
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, 0, 0, &dst_status
, 0, 0, 0);
1654 ok(hr
== DB_E_ERRORSOCCURRED
, "got %08x\n", hr
);
1655 ok(dst_status
== DBSTATUS_E_DATAOVERFLOW
, "got %08x\n", dst_status
);
1656 ok(dst_len
== 4, "got %d\n", dst_len
);
1657 ok(dst
[0] == (char)0xcc, "got %02x\n", dst
[0]);
1659 *(double *)src
= 4321;
1660 memset(dst
, 0xcc, sizeof(dst
));
1662 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R8
, DBTYPE_STR
, 0, &dst_len
, src
, NULL
, 0, 0, &dst_status
, 0, 0, 0);
1663 ok(hr
== S_OK
, "got %08x\n", hr
);
1664 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1665 ok(dst_len
== 4, "got %d\n", dst_len
);
1666 ok(dst
[0] == (char)0xcc, "got %02x\n", dst
[0]);
1668 *(double *)src
= 4321;
1669 memset(dst
, 0xcc, sizeof(dst
));
1671 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R8
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, 2, 0, &dst_status
, 0, 0, 0);
1672 ok(hr
== S_OK
, "got %08x\n", hr
);
1673 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1674 ok(dst_len
== 4, "got %d\n", dst_len
);
1675 ok(dst
[0] == '4', "got %02x\n", dst
[0]);
1676 ok(dst
[1] == 0, "got %02x\n", dst
[1]);
1677 ok(dst
[2] == (char)0xcc, "got %02x\n", dst
[2]);
1679 *(double *)src
= 4321;
1680 memset(dst
, 0xcc, sizeof(dst
));
1682 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R8
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, 1, 0, &dst_status
, 0, 0, 0);
1683 ok(hr
== S_OK
, "got %08x\n", hr
);
1684 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1685 ok(dst_len
== 4, "got %d\n", dst_len
);
1686 ok(dst
[0] == 0, "got %02x\n", dst
[0]);
1687 ok(dst
[1] == (char)0xcc, "got %02x\n", dst
[1]);
1689 *(double *)src
= 4321;
1690 memset(dst
, 0xcc, sizeof(dst
));
1692 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R8
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, 4, 0, &dst_status
, 0, 0, 0);
1693 ok(hr
== S_OK
, "got %08x\n", hr
);
1694 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1695 ok(dst_len
== 4, "got %d\n", dst_len
);
1696 ok(dst
[0] == '4', "got %02x\n", dst
[0]);
1697 ok(dst
[1] == '3', "got %02x\n", dst
[1]);
1698 ok(dst
[2] == '2', "got %02x\n", dst
[2]);
1699 ok(dst
[3] == 0, "got %02x\n", dst
[3]);
1700 ok(dst
[4] == (char)0xcc, "got %02x\n", dst
[4]);
1704 memset(src
, 0, sizeof(src
));
1705 ((CY
*)src
)->int64
= 43210000;
1706 memset(dst
, 0xcc, sizeof(dst
));
1708 hr
= IDataConvert_DataConvert(convert
, DBTYPE_CY
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1709 ok(hr
== S_OK
, "got %08x\n", hr
);
1710 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1711 ok(dst_len
== 4, "got %d\n", dst_len
);
1712 ok(!lstrcmpA(dst
, fourthreetwoone
), "got %s\n", dst
);
1716 memset(src
, 0, sizeof(src
));
1717 *(signed char *)src
= 10;
1719 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I1
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1720 ok(hr
== S_OK
, "got %08x\n", hr
);
1721 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1722 ok(dst_len
== 2, "got %d\n", dst_len
);
1723 ok(!lstrcmpA(dst
, ten_a
), "got %s\n", dst
);
1725 memset(src
, 0, sizeof(src
));
1726 *(unsigned char *)src
= 10;
1728 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI1
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1729 ok(hr
== S_OK
, "got %08x\n", hr
);
1730 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1731 ok(dst_len
== 2, "got %d\n", dst_len
);
1732 ok(!lstrcmpA(dst
, ten_a
), "got %s\n", dst
);
1734 memset(src
, 0, sizeof(src
));
1735 *(unsigned short *)src
= 4321;
1737 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI2
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1738 ok(hr
== S_OK
, "got %08x\n", hr
);
1739 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1740 ok(dst_len
== 4, "got %d\n", dst_len
);
1741 ok(!lstrcmpA(dst
, fourthreetwoone
), "got %s\n", dst
);
1743 memset(src
, 0, sizeof(src
));
1744 *(unsigned int *)src
= 4321;
1746 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI4
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1747 ok(hr
== S_OK
, "got %08x\n", hr
);
1748 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1749 ok(dst_len
== 4, "got %d\n", dst_len
);
1750 ok(!lstrcmpA(dst
, fourthreetwoone
), "got %s\n", dst
);
1752 memset(src
, 0, sizeof(src
));
1753 ((LARGE_INTEGER
*)src
)->QuadPart
= 4321;
1755 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I8
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1756 ok(broken(DB_E_UNSUPPORTEDCONVERSION
) || hr
== S_OK
/* W2K+ */, "got %08x\n", hr
);
1757 ok(broken(dst_status
== DBSTATUS_E_BADACCESSOR
) || dst_status
== DBSTATUS_S_OK
/* W2K+ */, "got %08x\n", dst_status
);
1758 ok(broken(dst_len
== 0x1234) || dst_len
== 4 /* W2K+ */, "got %d\n", dst_len
);
1759 ok(!lstrcmpA(dst
, fourthreetwoone
), "got %s\n", dst
);
1761 memset(src
, 0, sizeof(src
));
1762 ((ULARGE_INTEGER
*)src
)->QuadPart
= 4321;
1764 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI8
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1765 ok(broken(DB_E_UNSUPPORTEDCONVERSION
) || hr
== S_OK
/* W2K+ */, "got %08x\n", hr
);
1766 ok(broken(dst_status
== DBSTATUS_E_BADACCESSOR
) || dst_status
== DBSTATUS_S_OK
/* W2K+ */, "got %08x\n", dst_status
);
1767 ok(broken(dst_len
== 0x1234) || dst_len
== 4 /* W2K+ */, "got %d\n", dst_len
);
1768 ok(!lstrcmpA(dst
, fourthreetwoone
), "got %s\n", dst
);
1772 memset(src
, 0, sizeof(src
));
1773 memcpy(src
, &IID_IDataConvert
, sizeof(GUID
));
1774 memset(dst
, 0xcc, sizeof(dst
));
1776 hr
= IDataConvert_DataConvert(convert
, DBTYPE_GUID
, DBTYPE_STR
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1777 ok(hr
== S_OK
, "got %08x\n", hr
);
1778 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1779 ok(dst_len
== 38, "got %d\n", dst_len
);
1780 ok(!lstrcmpA(dst
, guid_str
), "got %s\n", dst
);
1784 b
= SysAllocString(ten
);
1786 memset(dst
, 0xcc, sizeof(dst
));
1788 hr
= IDataConvert_DataConvert(convert
, DBTYPE_BSTR
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1789 ok(hr
== S_OK
, "got %08x\n", hr
);
1790 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1791 ok(dst_len
== 2, "got %d\n", dst_len
);
1792 ok(!lstrcmpA(ten_a
, dst
), "got %s\n", dst
);
1795 memcpy(src
, ten
, sizeof(ten
));
1796 memset(dst
, 0xcc, sizeof(dst
));
1798 hr
= IDataConvert_DataConvert(convert
, DBTYPE_WSTR
, DBTYPE_STR
, 2, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1799 ok(hr
== S_OK
, "got %08x\n", hr
);
1800 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1801 ok(dst_len
== 1, "got %d\n", dst_len
);
1802 ok(dst
[0] == '1', "got %02x\n", dst
[0]);
1803 ok(dst
[1] == 0, "got %02x\n", dst
[1]);
1805 memcpy(src
, ten
, sizeof(ten
));
1806 memset(dst
, 0xcc, sizeof(dst
));
1808 hr
= IDataConvert_DataConvert(convert
, DBTYPE_WSTR
, DBTYPE_STR
, 4, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1809 ok(hr
== S_OK
, "got %08x\n", hr
);
1810 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1811 ok(dst_len
== 2, "got %d\n", dst_len
);
1812 ok(!lstrcmpA(ten_a
, dst
), "got %s\n", dst
);
1814 memcpy(src
, ten
, sizeof(ten
));
1815 memset(dst
, 0xcc, sizeof(dst
));
1817 hr
= IDataConvert_DataConvert(convert
, DBTYPE_WSTR
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, DBDATACONVERT_LENGTHFROMNTS
);
1818 ok(hr
== S_OK
, "got %08x\n", hr
);
1819 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1820 ok(dst_len
== 2, "got %d\n", dst_len
);
1821 ok(!lstrcmpA(ten_a
, dst
), "got %s\n", dst
);
1823 memcpy(src
, ten_a
, sizeof(ten_a
));
1824 memset(dst
, 0xcc, sizeof(dst
));
1826 hr
= IDataConvert_DataConvert(convert
, DBTYPE_STR
, DBTYPE_STR
, 2, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1827 ok(hr
== S_OK
, "got %08x\n", hr
);
1828 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1829 ok(dst_len
== 2, "got %d\n", dst_len
);
1830 ok(dst
[0] == '1', "got %02x\n", dst
[0]);
1831 ok(dst
[1] == '0', "got %02x\n", dst
[1]);
1832 ok(dst
[2] == 0, "got %02x\n", dst
[2]);
1833 ok(dst
[3] == (char)0xcc, "got %02x\n", dst
[3]);
1835 memcpy(src
, ten_a
, sizeof(ten_a
));
1836 memset(dst
, 0xcc, sizeof(dst
));
1838 hr
= IDataConvert_DataConvert(convert
, DBTYPE_STR
, DBTYPE_STR
, 4, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1839 ok(hr
== S_OK
, "got %08x\n", hr
);
1840 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1841 ok(dst_len
== 4, "got %d\n", dst_len
);
1842 ok(!lstrcmpA(ten_a
, dst
), "got %s\n", dst
);
1844 memcpy(src
, ten_a
, sizeof(ten_a
));
1845 memset(dst
, 0xcc, sizeof(dst
));
1847 hr
= IDataConvert_DataConvert(convert
, DBTYPE_STR
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, DBDATACONVERT_LENGTHFROMNTS
);
1848 ok(hr
== S_OK
, "got %08x\n", hr
);
1849 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1850 ok(dst_len
== 2, "got %d\n", dst_len
);
1851 ok(!lstrcmpA(ten_a
, dst
), "got %s\n", dst
);
1855 /* DBTYPE_BYTES to DBTYPE_*STR unpacks binary data into a hex string */
1856 memcpy(src
, hexpacked_a
, sizeof(hexpacked_a
));
1857 memset(dst
, 0xcc, sizeof(dst
));
1859 hr
= IDataConvert_DataConvert(convert
, DBTYPE_BYTES
, DBTYPE_STR
, sizeof(hexpacked_a
), &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1860 ok(hr
== S_OK
, "got %08x\n", hr
);
1861 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1862 ok(dst_len
== sizeof(hexpacked_a
) * 2, "got %d\n", dst_len
);
1863 ok(!lstrcmpA(hexunpacked_a
, dst
), "got %s\n", dst
);
1864 ok(dst
[sizeof(hexpacked_a
)/sizeof(char) * 4 + 1] == (char)0xcc, "clobbered buffer\n");
1866 memcpy(src
, hexpacked_a
, sizeof(hexpacked_a
));
1867 memset(dst
, 0xcc, sizeof(dst
));
1869 hr
= IDataConvert_DataConvert(convert
, DBTYPE_BYTES
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1870 ok(hr
== S_OK
, "got %08x\n", hr
);
1871 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1872 ok(dst_len
== 0, "got %d\n", dst_len
);
1873 ok(dst
[0] == 0, "not null terminated\n");
1874 ok(dst
[1] == (char)0xcc, "clobbered buffer\n");
1876 memcpy(src
, hexpacked_a
, sizeof(hexpacked_a
));
1877 memset(dst
, 0xcc, sizeof(dst
));
1879 hr
= IDataConvert_DataConvert(convert
, DBTYPE_BYTES
, DBTYPE_STR
, 4, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1880 ok(hr
== S_OK
, "got %08x\n", hr
);
1881 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1882 ok(dst_len
== 2 * sizeof(char) * 4, "got %d\n", dst_len
);
1883 ok(!memcmp(hexunpacked_a
, dst
, 2 * sizeof(char) * 4 ), "got %s\n", dst
);
1884 ok(dst
[2 * 4] == 0, "not null terminated\n");
1885 ok(dst
[2 * 4 + 1] == (char)0xcc, "clobbered buffer\n");
1887 memcpy(src
, hexpacked_a
, sizeof(hexpacked_a
));
1888 memset(dst
, 0xcc, sizeof(dst
));
1890 hr
= IDataConvert_DataConvert(convert
, DBTYPE_BYTES
, DBTYPE_STR
, sizeof(hexpacked_a
), &dst_len
, src
, dst
, 2 * sizeof(char) * 4 + sizeof(char), 0, &dst_status
, 0, 0, 0);
1891 ok(hr
== S_OK
, "got %08x\n", hr
);
1892 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1893 ok(dst_len
== sizeof(hexpacked_a
) * 2, "got %d\n", dst_len
);
1894 ok(!memcmp(hexunpacked_a
, dst
, 2 * sizeof(char) * 4 ), "got %s\n", dst
);
1895 ok(dst
[2 * 4] == 0, "not null terminated\n");
1896 ok(dst
[2 * 4 + 1] == (char)0xcc, "clobbered buffer\n");
1898 memcpy(src
, hexpacked_a
, sizeof(hexpacked_a
));
1899 memset(dst
, 0xcc, sizeof(dst
));
1901 hr
= IDataConvert_DataConvert(convert
, DBTYPE_BYTES
, DBTYPE_STR
, sizeof(hexpacked_a
), &dst_len
, src
, dst
, 2 * sizeof(char) * 4, 0, &dst_status
, 0, 0, 0);
1902 ok(hr
== S_OK
, "got %08x\n", hr
);
1903 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1904 ok(dst_len
== sizeof(hexpacked_a
) * 2, "got %d\n", dst_len
);
1905 ok(!memcmp(hexunpacked_a
, dst
, 2 * sizeof(char) * 4 - 2 ), "got %s\n", dst
);
1906 ok(dst
[2 * 4 - 1] == 0, "not null terminated\n");
1907 ok(dst
[2 * 4] == (char)0xcc, "clobbered buffer\n");
1909 memcpy(src
, hexpacked_a
, sizeof(hexpacked_a
));
1910 memset(dst
, 0xcc, sizeof(dst
));
1912 hr
= IDataConvert_DataConvert(convert
, DBTYPE_BYTES
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, DBDATACONVERT_LENGTHFROMNTS
);
1913 ok(hr
== S_OK
, "got %08x\n", hr
);
1914 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1915 ok(dst_len
== 0, "got %d\n", dst_len
);
1916 ok(dst
[0] == 0, "not null terminated\n");
1917 ok(dst
[1] == (char)0xcc, "clobbered buffer\n");
1919 IDataConvert_Release(convert
);
1922 static void test_converttobyrefwstr(void)
1924 IDataConvert
*convert
;
1928 DBSTATUS dst_status
;
1930 static const WCHAR ten
[] = {'1','0',0};
1931 static const WCHAR fourthreetwoone
[] = {'4','3','2','1',0};
1934 hr
= CoCreateInstance(&CLSID_OLEDB_CONVERSIONLIBRARY
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDataConvert
, (void**)&convert
);
1937 win_skip("Unable to load oledb conversion library\n");
1941 hr
= IDataConvert_DataConvert(convert
, DBTYPE_EMPTY
, DBTYPE_BYREF
| DBTYPE_WSTR
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1942 ok(hr
== S_OK
, "got %08x\n", hr
);
1943 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1944 ok(dst_len
== 0, "got %d\n", dst_len
);
1945 ok(dst
[0] == 0, "got %04x\n", dst
[0]);
1948 dst
= (void*)0x12345678;
1950 hr
= IDataConvert_DataConvert(convert
, DBTYPE_NULL
, DBTYPE_BYREF
| DBTYPE_WSTR
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1951 ok(hr
== DB_E_UNSUPPORTEDCONVERSION
, "got %08x\n", hr
);
1952 ok(dst_status
== DBSTATUS_E_BADACCESSOR
, "got %08x\n", dst_status
);
1953 ok(dst_len
== 0x1234, "got %d\n", dst_len
);
1954 ok(dst
== (void*)0x12345678, "got %p\n", dst
);
1956 *(short *)src
= 4321;
1958 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I2
, DBTYPE_BYREF
| DBTYPE_WSTR
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1959 ok(hr
== S_OK
, "got %08x\n", hr
);
1960 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1961 ok(dst_len
== 8, "got %d\n", dst_len
);
1962 ok(!lstrcmpW(dst
, fourthreetwoone
), "got %s\n", wine_dbgstr_w(dst
));
1965 *(short *)src
= 4321;
1967 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I2
, DBTYPE_BYREF
| DBTYPE_WSTR
, 0, &dst_len
, src
, &dst
, 0, 0, &dst_status
, 0, 0, 0);
1968 ok(hr
== S_OK
, "got %08x\n", hr
);
1969 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1970 ok(dst_len
== 8, "got %d\n", dst_len
);
1971 ok(!lstrcmpW(dst
, fourthreetwoone
), "got %s\n", wine_dbgstr_w(dst
));
1974 b
= SysAllocString(ten
);
1977 hr
= IDataConvert_DataConvert(convert
, DBTYPE_BSTR
, DBTYPE_BYREF
| DBTYPE_WSTR
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1978 ok(hr
== S_OK
, "got %08x\n", hr
);
1979 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1980 ok(dst_len
== 4, "got %d\n", dst_len
);
1981 ok(!lstrcmpW(b
, dst
), "got %s\n", wine_dbgstr_w(dst
));
1985 memcpy(src
, ten
, sizeof(ten
));
1987 hr
= IDataConvert_DataConvert(convert
, DBTYPE_WSTR
, DBTYPE_BYREF
| DBTYPE_WSTR
, 2, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1988 ok(hr
== S_OK
, "got %08x\n", hr
);
1989 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1990 ok(dst_len
== 2, "got %d\n", dst_len
);
1991 ok(dst
[0] == '1', "got %02x\n", dst
[0]);
1992 ok(dst
[1] == 0, "got %02x\n", dst
[1]);
1995 memcpy(src
, ten
, sizeof(ten
));
1997 hr
= IDataConvert_DataConvert(convert
, DBTYPE_WSTR
, DBTYPE_BYREF
| DBTYPE_WSTR
, 4, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1998 ok(hr
== S_OK
, "got %08x\n", hr
);
1999 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2000 ok(dst_len
== 4, "got %d\n", dst_len
);
2001 ok(!lstrcmpW(ten
, dst
), "got %s\n", wine_dbgstr_w(dst
));
2004 memcpy(src
, ten
, sizeof(ten
));
2006 hr
= IDataConvert_DataConvert(convert
, DBTYPE_WSTR
, DBTYPE_BYREF
| DBTYPE_WSTR
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, DBDATACONVERT_LENGTHFROMNTS
);
2007 ok(hr
== S_OK
, "got %08x\n", hr
);
2008 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2009 ok(dst_len
== 4, "got %d\n", dst_len
);
2010 ok(!lstrcmpW(ten
, dst
), "got %s\n", wine_dbgstr_w(dst
));
2013 IDataConvert_Release(convert
);
2016 static void test_converttoguid(void)
2018 IDataConvert
*convert
;
2022 DBSTATUS dst_status
;
2025 hr
= CoCreateInstance(&CLSID_OLEDB_CONVERSIONLIBRARY
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDataConvert
, (void**)&convert
);
2028 win_skip("Unable to load oledb conversion library\n");
2034 hr
= IDataConvert_DataConvert(convert
, DBTYPE_EMPTY
, DBTYPE_GUID
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2035 ok(hr
== S_OK
, "got %08x\n", hr
);
2036 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2037 ok(dst_len
== sizeof(GUID
), "got %d\n", dst_len
);
2038 ok(IsEqualGUID(&dst
, &GUID_NULL
), "didn't get GUID_NULL\n");
2042 hr
= IDataConvert_DataConvert(convert
, DBTYPE_NULL
, DBTYPE_GUID
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2043 ok(hr
== DB_E_UNSUPPORTEDCONVERSION
, "got %08x\n", hr
);
2044 ok(dst_status
== DBSTATUS_E_BADACCESSOR
, "got %08x\n", dst_status
);
2045 ok(dst_len
== 0x1234, "got %d\n", dst_len
);
2046 ok(IsEqualGUID(&dst
, &IID_IDCInfo
), "dst has changed\n");
2049 memcpy(src
, &IID_IDataConvert
, sizeof(GUID
));
2051 hr
= IDataConvert_DataConvert(convert
, DBTYPE_GUID
, DBTYPE_GUID
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2052 ok(hr
== S_OK
, "got %08x\n", hr
);
2053 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2054 ok(dst_len
== sizeof(GUID
), "got %d\n", dst_len
);
2055 ok(IsEqualGUID(&dst
, &IID_IDataConvert
), "didn't get IID_IDataConvert\n");
2057 IDataConvert_Release(convert
);
2060 static void test_converttofiletime(void)
2062 IDataConvert
*convert
;
2066 DBSTATUS dst_status
;
2069 hr
= CoCreateInstance(&CLSID_OLEDB_CONVERSIONLIBRARY
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDataConvert
, (void**)&convert
);
2072 win_skip("Unable to load oledb conversion library\n");
2076 memset(&dst
, 0xcc, sizeof(dst
));
2077 ((FILETIME
*)src
)->dwLowDateTime
= 0x12345678;
2078 ((FILETIME
*)src
)->dwHighDateTime
= 0x9abcdef0;
2080 hr
= IDataConvert_DataConvert(convert
, DBTYPE_FILETIME
, DBTYPE_FILETIME
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2082 broken(hr
== DB_E_BADBINDINFO
), /* win98 */
2086 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2087 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
2088 ok(dst
.dwLowDateTime
== 0x12345678, "got %08x\n", dst
.dwLowDateTime
);
2089 ok(dst
.dwHighDateTime
== 0x9abcdef0, "got %08x\n", dst
.dwHighDateTime
);
2092 IDataConvert_Release(convert
);
2095 static void test_converttoui1(void)
2097 IDataConvert
*convert
;
2101 DBSTATUS dst_status
;
2104 hr
= CoCreateInstance(&CLSID_OLEDB_CONVERSIONLIBRARY
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDataConvert
, (void**)&convert
);
2107 win_skip("Unable to load oledb conversion library\n");
2113 hr
= IDataConvert_DataConvert(convert
, DBTYPE_EMPTY
, DBTYPE_UI1
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2114 ok(hr
== S_OK
, "got %08x\n", hr
);
2115 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2116 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
2117 ok(dst
== 0, "got %08x\n", dst
);
2121 hr
= IDataConvert_DataConvert(convert
, DBTYPE_NULL
, DBTYPE_UI1
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2122 ok(hr
== DB_E_UNSUPPORTEDCONVERSION
, "got %08x\n", hr
);
2123 ok(dst_status
== DBSTATUS_E_BADACCESSOR
, "got %08x\n", dst_status
);
2124 ok(dst_len
== 0x1234, "got %d\n", dst_len
);
2125 ok(dst
== 0x12, "got %08x\n", dst
);
2130 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI1
, DBTYPE_UI1
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2131 ok(hr
== S_OK
, "got %08x\n", hr
);
2132 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2133 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
2134 ok(dst
== 0x43, "got %08x\n", dst
);
2139 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI1
, DBTYPE_UI1
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2140 ok(hr
== S_OK
, "got %08x\n", hr
);
2141 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2142 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
2143 ok(dst
== 0xfe, "got %08x\n", dst
);
2145 IDataConvert_Release(convert
);
2148 static void test_converttoui4(void)
2150 IDataConvert
*convert
;
2154 DBSTATUS dst_status
;
2157 hr
= CoCreateInstance(&CLSID_OLEDB_CONVERSIONLIBRARY
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDataConvert
, (void**)&convert
);
2160 win_skip("Unable to load oledb conversion library\n");
2166 hr
= IDataConvert_DataConvert(convert
, DBTYPE_EMPTY
, DBTYPE_UI4
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2167 ok(hr
== S_OK
, "got %08x\n", hr
);
2168 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2169 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
2170 ok(dst
== 0, "got %08x\n", dst
);
2174 hr
= IDataConvert_DataConvert(convert
, DBTYPE_NULL
, DBTYPE_UI4
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2175 ok(hr
== DB_E_UNSUPPORTEDCONVERSION
, "got %08x\n", hr
);
2176 ok(dst_status
== DBSTATUS_E_BADACCESSOR
, "got %08x\n", dst_status
);
2177 ok(dst_len
== 0x1234, "got %d\n", dst_len
);
2178 ok(dst
== 0x12345678, "got %08x\n", dst
);
2181 *(DWORD
*)src
= 0x87654321;
2183 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI4
, DBTYPE_UI4
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2184 ok(hr
== S_OK
, "got %08x\n", hr
);
2185 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2186 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
2187 ok(dst
== 0x87654321, "got %08x\n", dst
);
2190 *(signed short *)src
= 0x4321;
2192 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I2
, DBTYPE_UI4
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2193 ok(hr
== S_OK
, "got %08x\n", hr
);
2194 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2195 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
2196 ok(dst
== 0x4321, "got %08x\n", dst
);
2199 *(signed short *)src
= -1;
2201 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I2
, DBTYPE_UI4
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2202 ok(hr
== DB_E_ERRORSOCCURRED
, "got %08x\n", hr
);
2204 ok(dst_status
== DBSTATUS_E_SIGNMISMATCH
, "got %08x\n", dst_status
);
2206 ok(broken(dst_len
== sizeof(dst
)) || dst_len
== 0x1234 /* W2K+ */, "got %d\n", dst_len
);
2207 ok(dst
== 0x12345678, "got %08x\n", dst
);
2209 IDataConvert_Release(convert
);
2212 static void test_converttor4(void)
2214 IDataConvert
*convert
;
2218 DBSTATUS dst_status
;
2221 hr
= CoCreateInstance(&CLSID_OLEDB_CONVERSIONLIBRARY
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDataConvert
, (void**)&convert
);
2224 win_skip("Unable to load oledb conversion library\n");
2230 hr
= IDataConvert_DataConvert(convert
, DBTYPE_EMPTY
, DBTYPE_R4
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2231 ok(hr
== S_OK
, "got %08x\n", hr
);
2232 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2233 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
2234 ok(dst
== 0.0, "got %f\n", dst
);
2238 hr
= IDataConvert_DataConvert(convert
, DBTYPE_NULL
, DBTYPE_R4
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2239 ok(hr
== DB_E_UNSUPPORTEDCONVERSION
, "got %08x\n", hr
);
2240 ok(dst_status
== DBSTATUS_E_BADACCESSOR
, "got %08x\n", dst_status
);
2241 ok(dst_len
== 0x1234, "got %d\n", dst_len
);
2242 ok(dst
== 1.0, "got %f\n", dst
);
2245 *(signed int*)src
= 12345678;
2247 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I4
, DBTYPE_R4
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2248 ok(hr
== S_OK
, "got %08x\n", hr
);
2249 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2250 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
2251 ok(dst
== 12345678.0, "got %f\n", dst
);
2254 *(FLOAT
*)src
= 10.0;
2256 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R4
, DBTYPE_R4
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2257 ok(hr
== S_OK
, "got %08x\n", hr
);
2258 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2259 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
2260 ok(dst
== 10.0, "got %f\n", dst
);
2262 IDataConvert_Release(convert
);
2265 static void test_converttocy(void)
2267 IDataConvert
*convert
;
2271 DBSTATUS dst_status
;
2274 hr
= CoCreateInstance(&CLSID_OLEDB_CONVERSIONLIBRARY
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDataConvert
, (void**)&convert
);
2277 win_skip("Unable to load oledb conversion library\n");
2283 hr
= IDataConvert_DataConvert(convert
, DBTYPE_EMPTY
, DBTYPE_CY
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2284 ok(hr
== S_OK
, "got %08x\n", hr
);
2285 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2286 ok(dst_len
== sizeof(CY
), "got %d\n", dst_len
);
2287 ok(dst
.int64
== 0, "didn't get 0\n");
2291 hr
= IDataConvert_DataConvert(convert
, DBTYPE_NULL
, DBTYPE_CY
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2292 ok(hr
== DB_E_UNSUPPORTEDCONVERSION
, "got %08x\n", hr
);
2293 ok(dst_status
== DBSTATUS_E_BADACCESSOR
, "got %08x\n", dst_status
);
2294 ok(dst_len
== 0x1234, "got %d\n", dst_len
);
2295 ok(dst
.int64
== 0xcc, "dst changed\n");
2300 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I4
, DBTYPE_CY
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2301 ok(hr
== S_OK
, "got %08x\n", hr
);
2302 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2303 ok(dst_len
== sizeof(CY
), "got %d\n", dst_len
);
2304 ok(dst
.int64
== 12340000, "got %d\n", dst
.s
.Lo
);
2307 ((CY
*)src
)->int64
= 1234;
2309 hr
= IDataConvert_DataConvert(convert
, DBTYPE_CY
, DBTYPE_CY
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2310 ok(hr
== S_OK
, "got %08x\n", hr
);
2311 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2312 ok(dst_len
== sizeof(CY
), "got %d\n", dst_len
);
2313 ok(dst
.int64
== 1234, "got %d\n", dst
.s
.Lo
);
2315 IDataConvert_Release(convert
);
2318 static void test_converttoui8(void)
2320 IDataConvert
*convert
;
2324 DBSTATUS dst_status
;
2327 hr
= CoCreateInstance(&CLSID_OLEDB_CONVERSIONLIBRARY
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDataConvert
, (void**)&convert
);
2330 win_skip("Unable to load oledb conversion library\n");
2334 dst
.QuadPart
= 0xcc;
2336 hr
= IDataConvert_DataConvert(convert
, DBTYPE_EMPTY
, DBTYPE_UI8
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2337 ok(hr
== S_OK
, "got %08x\n", hr
);
2338 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2339 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
2340 ok(dst
.QuadPart
== 0, "got %d\n", (int)dst
.QuadPart
);
2342 dst
.QuadPart
= 0xcc;
2344 hr
= IDataConvert_DataConvert(convert
, DBTYPE_NULL
, DBTYPE_UI8
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2345 ok(hr
== DB_E_UNSUPPORTEDCONVERSION
, "got %08x\n", hr
);
2346 ok(dst_status
== DBSTATUS_E_BADACCESSOR
, "got %08x\n", dst_status
);
2347 ok(dst_len
== 0x1234, "got %d\n", dst_len
);
2348 ok(dst
.QuadPart
== 0xcc, "dst changed\n");
2350 dst
.QuadPart
= 0xcc;
2353 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I4
, DBTYPE_UI8
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2354 ok(hr
== S_OK
, "got %08x\n", hr
);
2355 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2356 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
2357 ok(dst
.QuadPart
== 1234, "got %d\n", (int)dst
.QuadPart
);
2359 dst
.QuadPart
= 0xcc;
2362 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I4
, DBTYPE_UI8
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2363 ok(hr
== DB_E_ERRORSOCCURRED
, "got %08x\n", hr
);
2365 ok(dst_status
== DBSTATUS_E_SIGNMISMATCH
, "got %08x\n", dst_status
);
2367 ok(dst_len
== 0x1234, "got %d\n", dst_len
);
2368 ok(dst
.QuadPart
== 0xcc, "got %d\n", (int)dst
.QuadPart
);
2370 dst
.QuadPart
= 0xcc;
2371 ((ULARGE_INTEGER
*)src
)->QuadPart
= 1234;
2373 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI8
, DBTYPE_UI8
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2374 ok(hr
== S_OK
, "got %08x\n", hr
);
2375 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2376 ok(dst_len
== sizeof(dst
), "got %d\n", dst_len
);
2377 ok(dst
.QuadPart
== 1234, "got %d\n", (int)dst
.QuadPart
);
2379 IDataConvert_Release(convert
);
2384 OleInitialize(NULL
);
2389 test_converttostr();
2390 test_converttobstr();
2391 test_converttowstr();
2392 test_converttobyrefwstr();
2393 test_converttoguid();
2394 test_converttoui1();
2395 test_converttoui4();
2397 test_converttofiletime();
2399 test_converttoui8();