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
);
149 static const struct can_convert
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 %ld\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 %ld\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 %ld\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 %ld\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 %ld\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 %ld\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 %ld\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 %ld\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 %ld\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 %ld\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 %ld\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 %ld\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 %ld\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 %ld\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 %ld\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 %ld\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 %ld\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 %ld\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 %ld\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 %ld\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 %ld\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 %ld\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 %ld\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 %ld\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 %ld\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 %ld\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 %ld\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 %ld\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 %ld\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 %ld\n", dst_len
);
611 ok(dst
== 10, "got %08x\n", dst
);
614 dst_len
= dst
= 0x1234;
615 *(WORD
*)src
= 0x4321;
616 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI2
, DBTYPE_UI2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
617 ok(hr
== S_OK
, "got %08x\n", hr
);
618 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
619 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
620 ok(dst
== 0x4321, "got %08x\n", dst
);
622 dst_len
= dst
= 0x1234;
623 *(DWORD
*)src
= 0xabcd1234;
624 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI4
, DBTYPE_UI2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
626 ok(hr
== DB_E_DATAOVERFLOW
, "got %08x\n", hr
);
627 ok(dst_status
== DBSTATUS_E_DATAOVERFLOW
, "got %08x\n", dst_status
);
628 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
629 ok(dst
== 0x1234, "got %08x\n", dst
);
631 dst_len
= dst
= 0x1234;
632 *(DWORD
*)src
= 0x1234abcd;
633 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI4
, DBTYPE_UI2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
635 ok(hr
== DB_E_DATAOVERFLOW
, "got %08x\n", hr
);
636 ok(dst_status
== DBSTATUS_E_DATAOVERFLOW
, "got %08x\n", dst_status
);
637 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
638 ok(dst
== 0x1234, "got %08x\n", dst
);
640 dst_len
= dst
= 0x1234;
641 *(DWORD
*)src
= 0x4321;
642 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI4
, DBTYPE_UI2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
643 ok(hr
== S_OK
, "got %08x\n", hr
);
644 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
645 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
646 ok(dst
== 0x4321, "got %08x\n", dst
);
648 dst_len
= dst
= 0x1234;
649 memcpy(src
, ten
, sizeof(ten
));
650 hr
= IDataConvert_DataConvert(convert
, DBTYPE_WSTR
, DBTYPE_UI2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, DBDATACONVERT_LENGTHFROMNTS
);
651 ok(hr
== S_OK
, "got %08x\n", hr
);
652 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
653 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
654 ok(dst
== 10, "got %08x\n", dst
);
656 IDataConvert_Release(convert
);
659 static void test_converttoi4(void)
661 IDataConvert
*convert
;
667 static const WCHAR ten
[] = {'1','0',0};
670 hr
= CoCreateInstance(&CLSID_OLEDB_CONVERSIONLIBRARY
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDataConvert
, (void**)&convert
);
673 win_skip("Unable to load oledb conversion library\n");
679 hr
= IDataConvert_DataConvert(convert
, DBTYPE_EMPTY
, 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 %ld\n", dst_len
);
683 ok(i4
== 0, "got %08x\n", i4
);
687 hr
= IDataConvert_DataConvert(convert
, DBTYPE_NULL
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
688 ok(hr
== DB_E_UNSUPPORTEDCONVERSION
, "got %08x\n", hr
);
689 ok(dst_status
== DBSTATUS_E_BADACCESSOR
, "got %08x\n", dst_status
);
690 ok(dst_len
== 0x1234, "got %ld\n", dst_len
);
691 ok(i4
== 0x12345678, "got %08x\n", i4
);
694 *(short *)src
= 0x4321;
696 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I2
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
697 ok(hr
== S_OK
, "got %08x\n", hr
);
698 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
699 ok(dst_len
== sizeof(i4
), "got %ld\n", dst_len
);
700 ok(i4
== 0x4321, "got %08x\n", i4
);
703 *(int *)src
= 0x4321cafe;
705 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I4
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
706 ok(hr
== S_OK
, "got %08x\n", hr
);
707 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
708 ok(dst_len
== sizeof(i4
), "got %ld\n", dst_len
);
709 ok(i4
== 0x4321cafe, "got %08x\n", i4
);
712 *(FLOAT
*)src
= 10.75;
713 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R4
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
714 ok(hr
== S_OK
, "got %08x\n", hr
);
715 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
716 ok(dst_len
== sizeof(i4
), "got %ld\n", dst_len
);
717 ok(i4
== 11, "got %08x\n", i4
);
720 *(FLOAT
*)src
= -10.75;
722 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R4
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
723 ok(hr
== S_OK
, "got %08x\n", hr
);
724 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
725 ok(dst_len
== sizeof(i4
), "got %ld\n", dst_len
);
726 ok(i4
== -11, "got %08x\n", i4
);
729 *(double *)src
= 10.75;
731 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R8
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
732 ok(hr
== S_OK
, "got %08x\n", hr
);
733 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
734 ok(dst_len
== sizeof(i4
), "got %ld\n", dst_len
);
735 ok(i4
== 11, "got %08x\n", i4
);
738 ((LARGE_INTEGER
*)src
)->QuadPart
= 107500;
740 hr
= IDataConvert_DataConvert(convert
, DBTYPE_CY
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
741 ok(hr
== S_OK
, "got %08x\n", hr
);
742 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
743 ok(dst_len
== sizeof(i4
), "got %ld\n", dst_len
);
744 ok(i4
== 11, "got %08x\n", i4
);
747 *(DATE
*)src
= 10.7500;
749 hr
= IDataConvert_DataConvert(convert
, DBTYPE_DATE
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
750 ok(hr
== S_OK
, "got %08x\n", hr
);
751 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
752 ok(dst_len
== sizeof(i4
), "got %ld\n", dst_len
);
753 ok(i4
== 11, "got %08x\n", i4
);
756 b
= SysAllocString(ten
);
759 hr
= IDataConvert_DataConvert(convert
, DBTYPE_BSTR
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
760 ok(hr
== S_OK
, "got %08x\n", hr
);
761 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
762 ok(dst_len
== sizeof(i4
), "got %ld\n", dst_len
);
763 ok(i4
== 10, "got %08x\n", i4
);
767 *(SCODE
*)src
= 0x4321cafe;
769 hr
= IDataConvert_DataConvert(convert
, DBTYPE_ERROR
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
770 ok(hr
== DB_E_UNSUPPORTEDCONVERSION
, "got %08x\n", hr
);
771 ok(dst_status
== DBSTATUS_E_BADACCESSOR
, "got %08x\n", dst_status
);
772 ok(dst_len
== 0x1234, "got %ld\n", dst_len
);
773 ok(i4
== 0x12345678, "got %08x\n", i4
);
776 *(VARIANT_BOOL
*)src
= VARIANT_TRUE
;
778 hr
= IDataConvert_DataConvert(convert
, DBTYPE_BOOL
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
779 ok(hr
== S_OK
, "got %08x\n", hr
);
780 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
781 ok(dst_len
== sizeof(i4
), "got %ld\n", dst_len
);
782 ok(i4
== 0xffffffff, "got %08x\n", i4
);
785 *(VARIANT_BOOL
*)src
= VARIANT_FALSE
;
787 hr
= IDataConvert_DataConvert(convert
, DBTYPE_BOOL
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
788 ok(hr
== S_OK
, "got %08x\n", hr
);
789 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
790 ok(dst_len
== sizeof(i4
), "got %ld\n", dst_len
);
791 ok(i4
== 0, "got %08x\n", i4
);
794 V_VT((VARIANT
*)src
) = VT_I2
;
795 V_I2((VARIANT
*)src
) = 0x1234;
797 hr
= IDataConvert_DataConvert(convert
, DBTYPE_VARIANT
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
798 ok(hr
== S_OK
, "got %08x\n", hr
);
799 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
800 ok(dst_len
== sizeof(i4
), "got %ld\n", dst_len
);
801 ok(i4
== 0x1234, "got %08x\n", i4
);
804 memset(src
, 0, sizeof(DECIMAL
));
805 ((DECIMAL
*)src
)->u1
.Lo64
= 0x1234;
807 hr
= IDataConvert_DataConvert(convert
, DBTYPE_DECIMAL
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
808 ok(hr
== S_OK
, "got %08x\n", hr
);
809 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
810 ok(dst_len
== sizeof(i4
), "got %ld\n", dst_len
);
811 ok(i4
== 0x1234, "got %08x\n", i4
);
814 *(signed char*)src
= 0xab;
816 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I1
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
817 ok(hr
== S_OK
, "got %08x\n", hr
);
818 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
819 ok(dst_len
== sizeof(i4
), "got %ld\n", dst_len
);
820 ok(i4
== 0xffffffab, "got %08x\n", i4
);
825 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI1
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
826 ok(hr
== S_OK
, "got %08x\n", hr
);
827 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
828 ok(dst_len
== sizeof(i4
), "got %ld\n", dst_len
);
829 ok(i4
== 0xab, "got %08x\n", i4
);
832 *(WORD
*)src
= 0xabcd;
834 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI2
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
835 ok(hr
== S_OK
, "got %08x\n", hr
);
836 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
837 ok(dst_len
== sizeof(i4
), "got %ld\n", dst_len
);
838 ok(i4
== 0xabcd, "got %08x\n", i4
);
841 *(DWORD
*)src
= 0xabcd1234;
843 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI4
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
844 ok(hr
== DB_E_ERRORSOCCURRED
, "got %08x\n", hr
);
845 ok(dst_status
== DBSTATUS_E_DATAOVERFLOW
, "got %08x\n", dst_status
);
847 ok(broken(dst_len
== sizeof(i4
)) || dst_len
== 0x1234 /* W2K+ */, "got %ld\n", dst_len
);
848 ok(i4
== 0x12345678, "got %08x\n", i4
);
851 *(DWORD
*)src
= 0x1234abcd;
853 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI4
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
854 ok(hr
== S_OK
, "got %08x\n", hr
);
855 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
856 ok(dst_len
== sizeof(i4
), "got %ld\n", dst_len
);
857 ok(i4
== 0x1234abcd, "got %08x\n", i4
);
860 ((LARGE_INTEGER
*)src
)->QuadPart
= 0x1234abcd;
862 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I8
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
864 broken(hr
== DB_E_UNSUPPORTEDCONVERSION
), /* win98 */
866 if(hr
!= DB_E_UNSUPPORTEDCONVERSION
) /* win98 doesn't support I8/UI8 */
868 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
869 ok(dst_len
== sizeof(i4
), "got %ld\n", dst_len
);
870 ok(i4
== 0x1234abcd, "got %08x\n", i4
);
873 ((ULARGE_INTEGER
*)src
)->QuadPart
= 0x1234abcd;
875 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI8
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
876 ok(hr
== S_OK
, "got %08x\n", hr
);
877 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
878 ok(dst_len
== sizeof(i4
), "got %ld\n", dst_len
);
879 ok(i4
== 0x1234abcd, "got %08x\n", i4
);
883 strcpy((char *)src
, "10");
885 hr
= IDataConvert_DataConvert(convert
, DBTYPE_STR
, DBTYPE_I4
, 2, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
886 ok(hr
== S_OK
, "got %08x\n", hr
);
887 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
888 ok(dst_len
== sizeof(i4
), "got %ld\n", dst_len
);
889 ok(i4
== 10, "got %08x\n", i4
);
892 strcpy((char *)src
, "10");
894 hr
= IDataConvert_DataConvert(convert
, DBTYPE_STR
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, DBDATACONVERT_LENGTHFROMNTS
);
895 ok(hr
== S_OK
, "got %08x\n", hr
);
896 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
897 ok(dst_len
== sizeof(i4
), "got %ld\n", dst_len
);
898 ok(i4
== 10, "got %08x\n", i4
);
901 memcpy(src
, ten
, sizeof(ten
));
903 hr
= IDataConvert_DataConvert(convert
, DBTYPE_WSTR
, DBTYPE_I4
, 4, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
904 ok(hr
== S_OK
, "got %08x\n", hr
);
905 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
906 ok(dst_len
== sizeof(i4
), "got %ld\n", dst_len
);
907 ok(i4
== 10, "got %08x\n", i4
);
910 memcpy(src
, ten
, sizeof(ten
));
912 hr
= IDataConvert_DataConvert(convert
, DBTYPE_WSTR
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, DBDATACONVERT_LENGTHFROMNTS
);
913 ok(hr
== S_OK
, "got %08x\n", hr
);
914 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
915 ok(dst_len
== sizeof(i4
), "got %ld\n", dst_len
);
916 ok(i4
== 10, "got %08x\n", i4
);
918 IDataConvert_Release(convert
);
921 static void test_converttobstr(void)
923 IDataConvert
*convert
;
929 static const WCHAR ten
[] = {'1','0',0};
932 hr
= CoCreateInstance(&CLSID_OLEDB_CONVERSIONLIBRARY
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDataConvert
, (void**)&convert
);
935 win_skip("Unable to load oledb conversion library\n");
940 hr
= IDataConvert_DataConvert(convert
, DBTYPE_EMPTY
, DBTYPE_BSTR
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
941 ok(hr
== S_OK
, "got %08x\n", hr
);
942 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
943 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
944 ok(dst
!= NULL
, "got %p\n", dst
);
945 ok(SysStringLen(dst
) == 0, "got %d\n", SysStringLen(dst
));
949 hr
= IDataConvert_DataConvert(convert
, DBTYPE_NULL
, DBTYPE_BSTR
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
950 ok(hr
== DB_E_UNSUPPORTEDCONVERSION
, "got %08x\n", hr
);
951 ok(dst_status
== DBSTATUS_E_BADACCESSOR
, "got %08x\n", dst_status
);
952 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
953 ok(dst
== (void*)0x1234, "got %p\n", dst
);
955 *(short *)src
= 4321;
956 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I2
, DBTYPE_BSTR
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
957 ok(hr
== S_OK
, "got %08x\n", hr
);
958 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
959 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
960 ok(dst
!= NULL
, "got %p\n", dst
);
961 ok(SysStringLen(dst
) == 4, "got %d\n", SysStringLen(dst
));
964 b
= SysAllocString(ten
);
966 hr
= IDataConvert_DataConvert(convert
, DBTYPE_BSTR
, DBTYPE_BSTR
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
967 ok(hr
== S_OK
, "got %08x\n", hr
);
968 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
969 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
970 ok(dst
!= NULL
, "got %p\n", dst
);
971 ok(dst
!= b
, "got %p src %p\n", dst
, b
);
972 ok(!lstrcmpW(b
, dst
), "got %s\n", wine_dbgstr_w(dst
));
976 IDataConvert_Release(convert
);
979 static void test_converttowstr(void)
981 IDataConvert
*convert
;
987 static const WCHAR ten
[] = {'1','0',0};
988 static const WCHAR fourthreetwoone
[] = {'4','3','2','1',0};
989 static const WCHAR guid_str
[] = {
990 '{','0','C','7','3','3','A','8','D','-','2','A','1','C','-','1','1','C','E','-',
991 'A','D','E','5','-','0','0','A','A','0','0','4','4','7','7','3','D','}',0};
992 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 };
993 static const WCHAR hexpacked_w
[] = {'W','i','n','e', 0 };
996 hr
= CoCreateInstance(&CLSID_OLEDB_CONVERSIONLIBRARY
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDataConvert
, (void**)&convert
);
999 win_skip("Unable to load oledb conversion library\n");
1004 memset(dst
, 0xcc, sizeof(dst
));
1006 hr
= IDataConvert_DataConvert(convert
, DBTYPE_EMPTY
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1007 ok(hr
== S_OK
, "got %08x\n", hr
);
1008 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1009 ok(dst_len
== 0, "got %ld\n", dst_len
);
1010 ok(dst
[0] == 0, "got %02x\n", dst
[0]);
1011 ok(dst
[1] == 0xcccc, "got %02x\n", dst
[1]);
1013 memset(dst
, 0xcc, sizeof(dst
));
1015 hr
= IDataConvert_DataConvert(convert
, DBTYPE_NULL
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1016 ok(hr
== DB_E_UNSUPPORTEDCONVERSION
, "got %08x\n", hr
);
1017 ok(dst_status
== DBSTATUS_E_BADACCESSOR
, "got %08x\n", dst_status
);
1018 ok(dst_len
== 0x1234, "got %ld\n", dst_len
);
1019 ok(dst
[0] == 0xcccc, "got %02x\n", dst
[0]);
1021 *(short *)src
= 4321;
1023 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I2
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1024 ok(hr
== S_OK
, "got %08x\n", hr
);
1025 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1026 ok(dst_len
== 8, "got %ld\n", dst_len
);
1027 ok(!lstrcmpW(dst
, fourthreetwoone
), "got %s\n", wine_dbgstr_w(dst
));
1029 *(short *)src
= 4321;
1030 memset(dst
, 0xcc, sizeof(dst
));
1032 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I2
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, 0, 0, &dst_status
, 0, 0, 0);
1033 ok(hr
== DB_E_ERRORSOCCURRED
, "got %08x\n", hr
);
1034 ok(dst_status
== DBSTATUS_E_DATAOVERFLOW
, "got %08x\n", dst_status
);
1035 ok(dst_len
== 8, "got %ld\n", dst_len
);
1036 ok(dst
[0] == 0xcccc, "got %02x\n", dst
[0]);
1038 *(short *)src
= 4321;
1039 memset(dst
, 0xcc, sizeof(dst
));
1041 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I2
, DBTYPE_WSTR
, 0, &dst_len
, src
, NULL
, 0, 0, &dst_status
, 0, 0, 0);
1042 ok(hr
== S_OK
, "got %08x\n", hr
);
1043 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1044 ok(dst_len
== 8, "got %ld\n", dst_len
);
1045 ok(dst
[0] == 0xcccc, "got %02x\n", dst
[0]);
1047 *(short *)src
= 4321;
1048 memset(dst
, 0xcc, sizeof(dst
));
1050 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I2
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, 4, 0, &dst_status
, 0, 0, 0);
1051 ok(hr
== S_OK
, "got %08x\n", hr
);
1052 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1053 ok(dst_len
== 8, "got %ld\n", dst_len
);
1054 ok(dst
[0] == '4', "got %02x\n", dst
[0]);
1055 ok(dst
[1] == 0, "got %02x\n", dst
[1]);
1056 ok(dst
[2] == 0xcccc, "got %02x\n", dst
[2]);
1058 *(short *)src
= 4321;
1059 memset(dst
, 0xcc, sizeof(dst
));
1061 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I2
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, 2, 0, &dst_status
, 0, 0, 0);
1062 ok(hr
== S_OK
, "got %08x\n", hr
);
1063 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1064 ok(dst_len
== 8, "got %ld\n", dst_len
);
1065 ok(dst
[0] == 0, "got %02x\n", dst
[0]);
1066 ok(dst
[1] == 0xcccc, "got %02x\n", dst
[1]);
1068 *(short *)src
= 4321;
1069 memset(dst
, 0xcc, sizeof(dst
));
1071 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I2
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, 8, 0, &dst_status
, 0, 0, 0);
1072 ok(hr
== S_OK
, "got %08x\n", hr
);
1073 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1074 ok(dst_len
== 8, "got %ld\n", dst_len
);
1075 ok(dst
[0] == '4', "got %02x\n", dst
[0]);
1076 ok(dst
[1] == '3', "got %02x\n", dst
[1]);
1077 ok(dst
[2] == '2', "got %02x\n", dst
[2]);
1078 ok(dst
[3] == 0, "got %02x\n", dst
[3]);
1079 ok(dst
[4] == 0xcccc, "got %02x\n", dst
[4]);
1085 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I4
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1086 ok(hr
== S_OK
, "got %08x\n", hr
);
1087 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1088 ok(dst_len
== 8, "got %ld\n", dst_len
);
1089 ok(!lstrcmpW(dst
, fourthreetwoone
), "got %s\n", wine_dbgstr_w(dst
));
1092 memset(dst
, 0xcc, sizeof(dst
));
1094 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I4
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, 0, 0, &dst_status
, 0, 0, 0);
1095 ok(hr
== DB_E_ERRORSOCCURRED
, "got %08x\n", hr
);
1096 ok(dst_status
== DBSTATUS_E_DATAOVERFLOW
, "got %08x\n", dst_status
);
1097 ok(dst_len
== 8, "got %ld\n", dst_len
);
1098 ok(dst
[0] == 0xcccc, "got %02x\n", dst
[0]);
1101 memset(dst
, 0xcc, sizeof(dst
));
1102 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I4
, DBTYPE_WSTR
, 0, &dst_len
, src
, NULL
, 0, 0, &dst_status
, 0, 0, 0);
1103 ok(hr
== S_OK
, "got %08x\n", hr
);
1104 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1105 ok(dst_len
== 8, "got %ld\n", dst_len
);
1106 ok(dst
[0] == 0xcccc, "got %02x\n", dst
[0]);
1109 memset(dst
, 0xcc, sizeof(dst
));
1111 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I4
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, 4, 0, &dst_status
, 0, 0, 0);
1112 ok(hr
== S_OK
, "got %08x\n", hr
);
1113 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1114 ok(dst_len
== 8, "got %ld\n", dst_len
);
1115 ok(dst
[0] == '4', "got %02x\n", dst
[0]);
1116 ok(dst
[1] == 0, "got %02x\n", dst
[1]);
1117 ok(dst
[2] == 0xcccc, "got %02x\n", dst
[2]);
1120 memset(dst
, 0xcc, sizeof(dst
));
1122 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I4
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, 2, 0, &dst_status
, 0, 0, 0);
1123 ok(hr
== S_OK
, "got %08x\n", hr
);
1124 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1125 ok(dst_len
== 8, "got %ld\n", dst_len
);
1126 ok(dst
[0] == 0, "got %02x\n", dst
[0]);
1127 ok(dst
[1] == 0xcccc, "got %02x\n", dst
[1]);
1130 memset(dst
, 0xcc, sizeof(dst
));
1132 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I4
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, 8, 0, &dst_status
, 0, 0, 0);
1133 ok(hr
== S_OK
, "got %08x\n", hr
);
1134 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1135 ok(dst_len
== 8, "got %ld\n", dst_len
);
1136 ok(dst
[0] == '4', "got %02x\n", dst
[0]);
1137 ok(dst
[1] == '3', "got %02x\n", dst
[1]);
1138 ok(dst
[2] == '2', "got %02x\n", dst
[2]);
1139 ok(dst
[3] == 0, "got %02x\n", dst
[3]);
1140 ok(dst
[4] == 0xcccc, "got %02x\n", dst
[4]);
1144 *(float *)src
= 4321;
1146 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R4
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1147 ok(hr
== S_OK
, "got %08x\n", hr
);
1148 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1149 ok(dst_len
== 8, "got %ld\n", dst_len
);
1150 ok(!lstrcmpW(dst
, fourthreetwoone
), "got %s\n", wine_dbgstr_w(dst
));
1152 *(float *)src
= 4321;
1153 memset(dst
, 0xcc, sizeof(dst
));
1155 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R4
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, 0, 0, &dst_status
, 0, 0, 0);
1156 ok(hr
== DB_E_ERRORSOCCURRED
, "got %08x\n", hr
);
1157 ok(dst_status
== DBSTATUS_E_DATAOVERFLOW
, "got %08x\n", dst_status
);
1158 ok(dst_len
== 8, "got %ld\n", dst_len
);
1159 ok(dst
[0] == 0xcccc, "got %02x\n", dst
[0]);
1161 *(float *)src
= 4321;
1162 memset(dst
, 0xcc, sizeof(dst
));
1163 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R4
, DBTYPE_WSTR
, 0, &dst_len
, src
, NULL
, 0, 0, &dst_status
, 0, 0, 0);
1164 ok(hr
== S_OK
, "got %08x\n", hr
);
1165 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1166 ok(dst_len
== 8, "got %ld\n", dst_len
);
1167 ok(dst
[0] == 0xcccc, "got %02x\n", dst
[0]);
1169 *(float *)src
= 4321;
1170 memset(dst
, 0xcc, sizeof(dst
));
1172 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R4
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, 4, 0, &dst_status
, 0, 0, 0);
1173 ok(hr
== S_OK
, "got %08x\n", hr
);
1174 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1175 ok(dst_len
== 8, "got %ld\n", dst_len
);
1176 ok(dst
[0] == '4', "got %02x\n", dst
[0]);
1177 ok(dst
[1] == 0, "got %02x\n", dst
[1]);
1178 ok(dst
[2] == 0xcccc, "got %02x\n", dst
[2]);
1180 *(float *)src
= 4321;
1181 memset(dst
, 0xcc, sizeof(dst
));
1183 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R4
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, 2, 0, &dst_status
, 0, 0, 0);
1184 ok(hr
== S_OK
, "got %08x\n", hr
);
1185 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1186 ok(dst_len
== 8, "got %ld\n", dst_len
);
1187 ok(dst
[0] == 0, "got %02x\n", dst
[0]);
1188 ok(dst
[1] == 0xcccc, "got %02x\n", dst
[1]);
1190 *(float *)src
= 4321;
1191 memset(dst
, 0xcc, sizeof(dst
));
1193 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R4
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, 8, 0, &dst_status
, 0, 0, 0);
1194 ok(hr
== S_OK
, "got %08x\n", hr
);
1195 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1196 ok(dst_len
== 8, "got %ld\n", dst_len
);
1197 ok(dst
[0] == '4', "got %02x\n", dst
[0]);
1198 ok(dst
[1] == '3', "got %02x\n", dst
[1]);
1199 ok(dst
[2] == '2', "got %02x\n", dst
[2]);
1200 ok(dst
[3] == 0, "got %02x\n", dst
[3]);
1201 ok(dst
[4] == 0xcccc, "got %02x\n", dst
[4]);
1205 *(double *)src
= 4321;
1207 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R8
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1208 ok(hr
== S_OK
, "got %08x\n", hr
);
1209 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1210 ok(dst_len
== 8, "got %ld\n", dst_len
);
1211 ok(!lstrcmpW(dst
, fourthreetwoone
), "got %s\n", wine_dbgstr_w(dst
));
1213 *(double *)src
= 4321;
1214 memset(dst
, 0xcc, sizeof(dst
));
1215 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R8
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, 0, 0, &dst_status
, 0, 0, 0);
1216 ok(hr
== DB_E_ERRORSOCCURRED
, "got %08x\n", hr
);
1217 ok(dst_status
== DBSTATUS_E_DATAOVERFLOW
, "got %08x\n", dst_status
);
1218 ok(dst_len
== 8, "got %ld\n", dst_len
);
1219 ok(dst
[0] == 0xcccc, "got %02x\n", dst
[0]);
1221 *(double *)src
= 4321;
1222 memset(dst
, 0xcc, sizeof(dst
));
1224 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R8
, DBTYPE_WSTR
, 0, &dst_len
, src
, NULL
, 0, 0, &dst_status
, 0, 0, 0);
1225 ok(hr
== S_OK
, "got %08x\n", hr
);
1226 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1227 ok(dst_len
== 8, "got %ld\n", dst_len
);
1228 ok(dst
[0] == 0xcccc, "got %02x\n", dst
[0]);
1230 *(double *)src
= 4321;
1231 memset(dst
, 0xcc, sizeof(dst
));
1233 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R8
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, 4, 0, &dst_status
, 0, 0, 0);
1234 ok(hr
== S_OK
, "got %08x\n", hr
);
1235 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1236 ok(dst_len
== 8, "got %ld\n", dst_len
);
1237 ok(dst
[0] == '4', "got %02x\n", dst
[0]);
1238 ok(dst
[1] == 0, "got %02x\n", dst
[1]);
1239 ok(dst
[2] == 0xcccc, "got %02x\n", dst
[2]);
1241 *(double *)src
= 4321;
1242 memset(dst
, 0xcc, sizeof(dst
));
1244 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R8
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, 2, 0, &dst_status
, 0, 0, 0);
1245 ok(hr
== S_OK
, "got %08x\n", hr
);
1246 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1247 ok(dst_len
== 8, "got %ld\n", dst_len
);
1248 ok(dst
[0] == 0, "got %02x\n", dst
[0]);
1249 ok(dst
[1] == 0xcccc, "got %02x\n", dst
[1]);
1251 *(double *)src
= 4321;
1252 memset(dst
, 0xcc, sizeof(dst
));
1254 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R8
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, 8, 0, &dst_status
, 0, 0, 0);
1255 ok(hr
== S_OK
, "got %08x\n", hr
);
1256 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1257 ok(dst_len
== 8, "got %ld\n", dst_len
);
1258 ok(dst
[0] == '4', "got %02x\n", dst
[0]);
1259 ok(dst
[1] == '3', "got %02x\n", dst
[1]);
1260 ok(dst
[2] == '2', "got %02x\n", dst
[2]);
1261 ok(dst
[3] == 0, "got %02x\n", dst
[3]);
1262 ok(dst
[4] == 0xcccc, "got %02x\n", dst
[4]);
1266 memset(src
, 0, sizeof(src
));
1267 ((CY
*)src
)->int64
= 43210000;
1268 memset(dst
, 0xcc, sizeof(dst
));
1270 hr
= IDataConvert_DataConvert(convert
, DBTYPE_CY
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1271 ok(hr
== S_OK
, "got %08x\n", hr
);
1272 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1273 ok(dst_len
== 8, "got %ld\n", dst_len
);
1274 ok(!lstrcmpW(dst
, fourthreetwoone
), "got %s\n", wine_dbgstr_w(dst
));
1278 memset(src
, 0, sizeof(src
));
1279 *(signed char *)src
= 10;
1281 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I1
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1282 ok(hr
== S_OK
, "got %08x\n", hr
);
1283 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1284 ok(dst_len
== 4, "got %ld\n", dst_len
);
1285 ok(!lstrcmpW(dst
, ten
), "got %s\n", wine_dbgstr_w(dst
));
1287 memset(src
, 0, sizeof(src
));
1288 *(unsigned char *)src
= 10;
1290 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI1
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1291 ok(hr
== S_OK
, "got %08x\n", hr
);
1292 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1293 ok(dst_len
== 4, "got %ld\n", dst_len
);
1294 ok(!lstrcmpW(dst
, ten
), "got %s\n", wine_dbgstr_w(dst
));
1296 memset(src
, 0, sizeof(src
));
1297 *(unsigned short *)src
= 4321;
1299 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI2
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1300 ok(hr
== S_OK
, "got %08x\n", hr
);
1301 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1302 ok(dst_len
== 8, "got %ld\n", dst_len
);
1303 ok(!lstrcmpW(dst
, fourthreetwoone
), "got %s\n", wine_dbgstr_w(dst
));
1305 memset(src
, 0, sizeof(src
));
1306 *(unsigned int *)src
= 4321;
1308 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI4
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1309 ok(hr
== S_OK
, "got %08x\n", hr
);
1310 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1311 ok(dst_len
== 8, "got %ld\n", dst_len
);
1312 ok(!lstrcmpW(dst
, fourthreetwoone
), "got %s\n", wine_dbgstr_w(dst
));
1314 memset(src
, 0, sizeof(src
));
1315 ((LARGE_INTEGER
*)src
)->QuadPart
= 4321;
1317 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I8
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1318 ok(broken(DB_E_UNSUPPORTEDCONVERSION
) || hr
== S_OK
/* W2K+ */, "got %08x\n", hr
);
1319 ok(broken(dst_status
== DBSTATUS_E_BADACCESSOR
) || dst_status
== DBSTATUS_S_OK
/* W2K+ */, "got %08x\n", dst_status
);
1320 ok(broken(dst_len
== 0x1234) || dst_len
== 8 /* W2K+ */, "got %ld\n", dst_len
);
1321 ok(!lstrcmpW(dst
, fourthreetwoone
), "got %s\n", wine_dbgstr_w(dst
));
1323 memset(src
, 0, sizeof(src
));
1324 ((ULARGE_INTEGER
*)src
)->QuadPart
= 4321;
1325 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI8
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1326 ok(broken(DB_E_UNSUPPORTEDCONVERSION
) || hr
== S_OK
/* W2K+ */, "got %08x\n", hr
);
1327 ok(broken(dst_status
== DBSTATUS_E_BADACCESSOR
) || dst_status
== DBSTATUS_S_OK
/* W2K+ */, "got %08x\n", dst_status
);
1328 ok(broken(dst_len
== 0x1234) || dst_len
== 8 /* W2K+ */, "got %ld\n", dst_len
);
1329 ok(!lstrcmpW(dst
, fourthreetwoone
), "got %s\n", wine_dbgstr_w(dst
));
1333 memset(src
, 0, sizeof(src
));
1334 memcpy(src
, &IID_IDataConvert
, sizeof(GUID
));
1335 memset(dst
, 0xcc, sizeof(dst
));
1337 hr
= IDataConvert_DataConvert(convert
, DBTYPE_GUID
, DBTYPE_WSTR
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1338 ok(hr
== S_OK
, "got %08x\n", hr
);
1339 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1340 ok(dst_len
== 76, "got %ld\n", dst_len
);
1341 ok(!lstrcmpW(dst
, guid_str
), "got %s\n", wine_dbgstr_w(dst
));
1345 b
= SysAllocString(ten
);
1348 hr
= IDataConvert_DataConvert(convert
, DBTYPE_BSTR
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1349 ok(hr
== S_OK
, "got %08x\n", hr
);
1350 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1351 ok(dst_len
== 4, "got %ld\n", dst_len
);
1352 ok(!lstrcmpW(b
, dst
), "got %s\n", wine_dbgstr_w(dst
));
1355 memcpy(src
, ten
, sizeof(ten
));
1357 hr
= IDataConvert_DataConvert(convert
, DBTYPE_WSTR
, DBTYPE_WSTR
, 2, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1358 ok(hr
== S_OK
, "got %08x\n", hr
);
1359 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1360 ok(dst_len
== 2, "got %ld\n", dst_len
);
1361 ok(dst
[0] == '1', "got %02x\n", dst
[0]);
1362 ok(dst
[1] == 0, "got %02x\n", dst
[1]);
1364 memcpy(src
, ten
, sizeof(ten
));
1366 hr
= IDataConvert_DataConvert(convert
, DBTYPE_WSTR
, DBTYPE_WSTR
, 4, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1367 ok(hr
== S_OK
, "got %08x\n", hr
);
1368 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1369 ok(dst_len
== 4, "got %ld\n", dst_len
);
1370 ok(!lstrcmpW(ten
, dst
), "got %s\n", wine_dbgstr_w(dst
));
1372 memcpy(src
, ten
, sizeof(ten
));
1374 hr
= IDataConvert_DataConvert(convert
, DBTYPE_WSTR
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, DBDATACONVERT_LENGTHFROMNTS
);
1375 ok(hr
== S_OK
, "got %08x\n", hr
);
1376 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1377 ok(dst_len
== 4, "got %ld\n", dst_len
);
1378 ok(!lstrcmpW(ten
, dst
), "got %s\n", wine_dbgstr_w(dst
));
1382 /* DBTYPE_BYTES to DBTYPE_*STR unpacks binary data into a hex string */
1383 memcpy(src
, hexpacked_w
, sizeof(hexpacked_w
));
1384 memset(dst
, 0xcc, sizeof(dst
));
1386 hr
= IDataConvert_DataConvert(convert
, DBTYPE_BYTES
, DBTYPE_WSTR
, sizeof(hexpacked_w
), &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1387 ok(hr
== S_OK
, "got %08x\n", hr
);
1388 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1389 ok(dst_len
== sizeof(hexpacked_w
) * 4, "got %ld\n", dst_len
);
1390 ok(!lstrcmpW(hexunpacked_w
, dst
), "got %s\n", wine_dbgstr_w(dst
));
1391 ok(dst
[sizeof(hexpacked_w
)/sizeof(WCHAR
) * 4 + 1] == 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
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1397 ok(hr
== S_OK
, "got %08x\n", hr
);
1398 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1399 ok(dst_len
== 0, "got %ld\n", dst_len
);
1400 ok(dst
[0] == 0, "not null terminated\n");
1401 ok(dst
[1] == 0xcccc, "clobbered buffer\n");
1403 memcpy(src
, hexpacked_w
, sizeof(hexpacked_w
));
1404 memset(dst
, 0xcc, sizeof(dst
));
1406 hr
= IDataConvert_DataConvert(convert
, DBTYPE_BYTES
, DBTYPE_WSTR
, 4, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1407 ok(hr
== S_OK
, "got %08x\n", hr
);
1408 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1409 ok(dst_len
== 2 * sizeof(WCHAR
) * 4, "got %ld\n", dst_len
);
1410 ok(!memcmp(hexunpacked_w
, dst
, 2 * sizeof(WCHAR
) * 4 ), "got %s\n", wine_dbgstr_w(dst
));
1411 ok(dst
[2 * 4] == 0, "not null terminated\n");
1412 ok(dst
[2 * 4 + 1] == 0xcccc, "clobbered buffer\n");
1414 memcpy(src
, hexpacked_w
, sizeof(hexpacked_w
));
1415 memset(dst
, 0xcc, sizeof(dst
));
1417 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);
1418 ok(hr
== S_OK
, "got %08x\n", hr
);
1419 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1420 ok(dst_len
== sizeof(hexpacked_w
) * 4, "got %ld\n", dst_len
);
1421 ok(!memcmp(hexunpacked_w
, dst
, 2 * sizeof(WCHAR
) * 4 ), "got %s\n", wine_dbgstr_w(dst
));
1422 ok(dst
[2 * 4] == 0, "not null terminated\n");
1423 ok(dst
[2 * 4 + 1] == 0xcccc, "clobbered buffer\n");
1425 memcpy(src
, hexpacked_w
, sizeof(hexpacked_w
));
1426 memset(dst
, 0xcc, sizeof(dst
));
1428 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);
1429 ok(hr
== S_OK
, "got %08x\n", hr
);
1430 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1431 ok(dst_len
== sizeof(hexpacked_w
) * 4, "got %ld\n", dst_len
);
1432 ok(!memcmp(hexunpacked_w
, dst
, 2 * sizeof(WCHAR
) * 4 - 2 ), "got %s\n", wine_dbgstr_w(dst
));
1433 ok(dst
[2 * 4 - 1] == 0, "not null terminated\n");
1434 ok(dst
[2 * 4] == 0xcccc, "clobbered buffer\n");
1436 memcpy(src
, hexpacked_w
, sizeof(hexpacked_w
));
1437 memset(dst
, 0xcc, sizeof(dst
));
1439 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);
1440 ok(hr
== S_OK
, "got %08x\n", hr
);
1441 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1442 ok(dst_len
== sizeof(hexpacked_w
) * 4, "got %ld\n", dst_len
);
1443 ok(!memcmp(hexunpacked_w
, dst
, 2 * sizeof(WCHAR
) * 4 - 2 ), "got %s\n", wine_dbgstr_w(dst
));
1444 ok(dst
[2 * 4 - 1] == 0, "not null terminated\n");
1445 ok(dst
[2 * 4] == 0xcccc, "clobbered buffer\n");
1447 memcpy(src
, hexpacked_w
, sizeof(hexpacked_w
));
1448 memset(dst
, 0xcc, sizeof(dst
));
1450 hr
= IDataConvert_DataConvert(convert
, DBTYPE_BYTES
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, DBDATACONVERT_LENGTHFROMNTS
);
1451 ok(hr
== S_OK
, "got %08x\n", hr
);
1452 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1453 ok(dst_len
== 0, "got %ld\n", dst_len
);
1454 ok(dst
[0] == 0, "not null terminated\n");
1455 ok(dst
[1] == 0xcccc, "clobbered buffer\n");
1458 IDataConvert_Release(convert
);
1461 static void test_converttostr(void)
1463 IDataConvert
*convert
;
1467 DBSTATUS dst_status
;
1469 static const WCHAR ten
[] = {'1','0',0};
1470 static const char ten_a
[] = "10";
1471 static const char fourthreetwoone
[] = "4321";
1472 static const char guid_str
[] = "{0C733A8D-2A1C-11CE-ADE5-00AA0044773D}";
1473 static const char hexunpacked_a
[] = "57696E6500";
1474 static const char hexpacked_a
[] = "Wine";
1477 hr
= CoCreateInstance(&CLSID_OLEDB_CONVERSIONLIBRARY
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDataConvert
, (void**)&convert
);
1480 win_skip("Unable to load oledb conversion library\n");
1485 memset(dst
, 0xcc, sizeof(dst
));
1487 hr
= IDataConvert_DataConvert(convert
, DBTYPE_EMPTY
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1488 ok(hr
== S_OK
, "got %08x\n", hr
);
1489 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1490 ok(dst_len
== 0, "got %ld\n", dst_len
);
1491 ok(dst
[0] == 0, "got %02x\n", dst
[0]);
1492 ok(dst
[1] == (char)0xcc, "got %02x\n", dst
[1]);
1494 memset(dst
, 0xcc, sizeof(dst
));
1496 hr
= IDataConvert_DataConvert(convert
, DBTYPE_NULL
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1497 ok(hr
== DB_E_UNSUPPORTEDCONVERSION
, "got %08x\n", hr
);
1498 ok(dst_status
== DBSTATUS_E_BADACCESSOR
, "got %08x\n", dst_status
);
1499 ok(dst_len
== 0x1234, "got %ld\n", dst_len
);
1500 ok(dst
[0] == (char)0xcc, "got %02x\n", dst
[0]);
1502 *(short *)src
= 4321;
1504 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I2
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1505 ok(hr
== S_OK
, "got %08x\n", hr
);
1506 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1507 ok(dst_len
== 4, "got %ld\n", dst_len
);
1508 ok(!lstrcmpA(dst
, fourthreetwoone
), "got %s\n", dst
);
1510 *(short *)src
= 4321;
1511 memset(dst
, 0xcc, sizeof(dst
));
1513 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I2
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, 0, 0, &dst_status
, 0, 0, 0);
1514 ok(hr
== DB_E_ERRORSOCCURRED
, "got %08x\n", hr
);
1515 ok(dst_status
== DBSTATUS_E_DATAOVERFLOW
, "got %08x\n", dst_status
);
1516 ok(dst_len
== 4, "got %ld\n", dst_len
);
1517 ok(dst
[0] == (char)0xcc, "got %02x\n", dst
[0]);
1519 *(short *)src
= 4321;
1520 memset(dst
, 0xcc, sizeof(dst
));
1522 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I2
, DBTYPE_STR
, 0, &dst_len
, src
, NULL
, 0, 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 %ld\n", dst_len
);
1526 ok(dst
[0] == (char)0xcc, "got %02x\n", dst
[0]);
1528 *(short *)src
= 4321;
1529 memset(dst
, 0xcc, sizeof(dst
));
1531 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I2
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, 2, 0, &dst_status
, 0, 0, 0);
1532 ok(hr
== S_OK
, "got %08x\n", hr
);
1533 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1534 ok(dst_len
== 4, "got %ld\n", dst_len
);
1535 ok(dst
[0] == '4', "got %02x\n", dst
[0]);
1536 ok(dst
[1] == 0, "got %02x\n", dst
[1]);
1537 ok(dst
[2] == (char)0xcc, "got %02x\n", dst
[2]);
1539 *(short *)src
= 4321;
1540 memset(dst
, 0xcc, sizeof(dst
));
1542 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I2
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, 1, 0, &dst_status
, 0, 0, 0);
1543 ok(hr
== S_OK
, "got %08x\n", hr
);
1544 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1545 ok(dst_len
== 4, "got %ld\n", dst_len
);
1546 ok(dst
[0] == 0, "got %02x\n", dst
[0]);
1547 ok(dst
[1] == (char)0xcc, "got %02x\n", dst
[1]);
1549 *(short *)src
= 4321;
1550 memset(dst
, 0xcc, sizeof(dst
));
1552 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I2
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, 4, 0, &dst_status
, 0, 0, 0);
1553 ok(hr
== S_OK
, "got %08x\n", hr
);
1554 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1555 ok(dst_len
== 4, "got %ld\n", dst_len
);
1556 ok(dst
[0] == '4', "got %02x\n", dst
[0]);
1557 ok(dst
[1] == '3', "got %02x\n", dst
[1]);
1558 ok(dst
[2] == '2', "got %02x\n", dst
[2]);
1559 ok(dst
[3] == 0, "got %02x\n", dst
[3]);
1560 ok(dst
[4] == (char)0xcc, "got %02x\n", dst
[4]);
1565 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I4
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1566 ok(hr
== S_OK
, "got %08x\n", hr
);
1567 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1568 ok(dst_len
== 4, "got %ld\n", dst_len
);
1569 ok(!lstrcmpA(dst
, fourthreetwoone
), "got %s\n", dst
);
1572 memset(dst
, 0xcc, sizeof(dst
));
1574 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I4
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, 0, 0, &dst_status
, 0, 0, 0);
1575 ok(hr
== DB_E_ERRORSOCCURRED
, "got %08x\n", hr
);
1576 ok(dst_status
== DBSTATUS_E_DATAOVERFLOW
, "got %08x\n", dst_status
);
1577 ok(dst_len
== 4, "got %ld\n", dst_len
);
1578 ok(dst
[0] == (char)0xcc, "got %02x\n", dst
[0]);
1581 memset(dst
, 0xcc, sizeof(dst
));
1583 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I4
, DBTYPE_STR
, 0, &dst_len
, src
, NULL
, 0, 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 %ld\n", dst_len
);
1587 ok(dst
[0] == (char)0xcc, "got %02x\n", dst
[0]);
1590 memset(dst
, 0xcc, sizeof(dst
));
1592 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I4
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, 2, 0, &dst_status
, 0, 0, 0);
1593 ok(hr
== S_OK
, "got %08x\n", hr
);
1594 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1595 ok(dst_len
== 4, "got %ld\n", dst_len
);
1596 ok(dst
[0] == '4', "got %02x\n", dst
[0]);
1597 ok(dst
[1] == 0, "got %02x\n", dst
[1]);
1598 ok(dst
[2] == (char)0xcc, "got %02x\n", dst
[2]);
1601 memset(dst
, 0xcc, sizeof(dst
));
1603 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I4
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, 1, 0, &dst_status
, 0, 0, 0);
1604 ok(hr
== S_OK
, "got %08x\n", hr
);
1605 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1606 ok(dst_len
== 4, "got %ld\n", dst_len
);
1607 ok(dst
[0] == 0, "got %02x\n", dst
[0]);
1608 ok(dst
[1] == (char)0xcc, "got %02x\n", dst
[1]);
1611 memset(dst
, 0xcc, sizeof(dst
));
1613 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I4
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, 4, 0, &dst_status
, 0, 0, 0);
1614 ok(hr
== S_OK
, "got %08x\n", hr
);
1615 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1616 ok(dst_len
== 4, "got %ld\n", dst_len
);
1617 ok(dst
[0] == '4', "got %02x\n", dst
[0]);
1618 ok(dst
[1] == '3', "got %02x\n", dst
[1]);
1619 ok(dst
[2] == '2', "got %02x\n", dst
[2]);
1620 ok(dst
[3] == 0, "got %02x\n", dst
[3]);
1621 ok(dst
[4] == (char)0xcc, "got %02x\n", dst
[4]);
1624 *(float *)src
= 4321;
1626 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R4
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1627 ok(hr
== S_OK
, "got %08x\n", hr
);
1628 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1629 ok(dst_len
== 4, "got %ld\n", dst_len
);
1630 ok(!lstrcmpA(dst
, fourthreetwoone
), "got %s\n", dst
);
1632 *(float *)src
= 4321;
1633 memset(dst
, 0xcc, sizeof(dst
));
1635 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R4
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, 0, 0, &dst_status
, 0, 0, 0);
1636 ok(hr
== DB_E_ERRORSOCCURRED
, "got %08x\n", hr
);
1637 ok(dst_status
== DBSTATUS_E_DATAOVERFLOW
, "got %08x\n", dst_status
);
1638 ok(dst_len
== 4, "got %ld\n", dst_len
);
1639 ok(dst
[0] == (char)0xcc, "got %02x\n", dst
[0]);
1641 *(float *)src
= 4321;
1642 memset(dst
, 0xcc, sizeof(dst
));
1644 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R4
, DBTYPE_STR
, 0, &dst_len
, src
, NULL
, 0, 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 %ld\n", dst_len
);
1648 ok(dst
[0] == (char)0xcc, "got %02x\n", dst
[0]);
1650 *(float *)src
= 4321;
1651 memset(dst
, 0xcc, sizeof(dst
));
1653 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R4
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, 2, 0, &dst_status
, 0, 0, 0);
1654 ok(hr
== S_OK
, "got %08x\n", hr
);
1655 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1656 ok(dst_len
== 4, "got %ld\n", dst_len
);
1657 ok(dst
[0] == '4', "got %02x\n", dst
[0]);
1658 ok(dst
[1] == 0, "got %02x\n", dst
[1]);
1659 ok(dst
[2] == (char)0xcc, "got %02x\n", dst
[2]);
1661 *(float *)src
= 4321;
1662 memset(dst
, 0xcc, sizeof(dst
));
1664 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R4
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, 1, 0, &dst_status
, 0, 0, 0);
1665 ok(hr
== S_OK
, "got %08x\n", hr
);
1666 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1667 ok(dst_len
== 4, "got %ld\n", dst_len
);
1668 ok(dst
[0] == 0, "got %02x\n", dst
[0]);
1669 ok(dst
[1] == (char)0xcc, "got %02x\n", dst
[1]);
1671 *(float *)src
= 4321;
1672 memset(dst
, 0xcc, sizeof(dst
));
1674 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R4
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, 4, 0, &dst_status
, 0, 0, 0);
1675 ok(hr
== S_OK
, "got %08x\n", hr
);
1676 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1677 ok(dst_len
== 4, "got %ld\n", dst_len
);
1678 ok(dst
[0] == '4', "got %02x\n", dst
[0]);
1679 ok(dst
[1] == '3', "got %02x\n", dst
[1]);
1680 ok(dst
[2] == '2', "got %02x\n", dst
[2]);
1681 ok(dst
[3] == 0, "got %02x\n", dst
[3]);
1682 ok(dst
[4] == (char)0xcc, "got %02x\n", dst
[4]);
1685 *(double *)src
= 4321;
1687 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R8
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1688 ok(hr
== S_OK
, "got %08x\n", hr
);
1689 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1690 ok(dst_len
== 4, "got %ld\n", dst_len
);
1691 ok(!lstrcmpA(dst
, fourthreetwoone
), "got %s\n", dst
);
1693 *(double *)src
= 4321;
1694 memset(dst
, 0xcc, sizeof(dst
));
1696 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R8
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, 0, 0, &dst_status
, 0, 0, 0);
1697 ok(hr
== DB_E_ERRORSOCCURRED
, "got %08x\n", hr
);
1698 ok(dst_status
== DBSTATUS_E_DATAOVERFLOW
, "got %08x\n", dst_status
);
1699 ok(dst_len
== 4, "got %ld\n", dst_len
);
1700 ok(dst
[0] == (char)0xcc, "got %02x\n", dst
[0]);
1702 *(double *)src
= 4321;
1703 memset(dst
, 0xcc, sizeof(dst
));
1705 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R8
, DBTYPE_STR
, 0, &dst_len
, src
, NULL
, 0, 0, &dst_status
, 0, 0, 0);
1706 ok(hr
== S_OK
, "got %08x\n", hr
);
1707 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1708 ok(dst_len
== 4, "got %ld\n", dst_len
);
1709 ok(dst
[0] == (char)0xcc, "got %02x\n", dst
[0]);
1711 *(double *)src
= 4321;
1712 memset(dst
, 0xcc, sizeof(dst
));
1714 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R8
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, 2, 0, &dst_status
, 0, 0, 0);
1715 ok(hr
== S_OK
, "got %08x\n", hr
);
1716 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1717 ok(dst_len
== 4, "got %ld\n", dst_len
);
1718 ok(dst
[0] == '4', "got %02x\n", dst
[0]);
1719 ok(dst
[1] == 0, "got %02x\n", dst
[1]);
1720 ok(dst
[2] == (char)0xcc, "got %02x\n", dst
[2]);
1722 *(double *)src
= 4321;
1723 memset(dst
, 0xcc, sizeof(dst
));
1725 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R8
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, 1, 0, &dst_status
, 0, 0, 0);
1726 ok(hr
== S_OK
, "got %08x\n", hr
);
1727 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1728 ok(dst_len
== 4, "got %ld\n", dst_len
);
1729 ok(dst
[0] == 0, "got %02x\n", dst
[0]);
1730 ok(dst
[1] == (char)0xcc, "got %02x\n", dst
[1]);
1732 *(double *)src
= 4321;
1733 memset(dst
, 0xcc, sizeof(dst
));
1735 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R8
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, 4, 0, &dst_status
, 0, 0, 0);
1736 ok(hr
== S_OK
, "got %08x\n", hr
);
1737 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1738 ok(dst_len
== 4, "got %ld\n", dst_len
);
1739 ok(dst
[0] == '4', "got %02x\n", dst
[0]);
1740 ok(dst
[1] == '3', "got %02x\n", dst
[1]);
1741 ok(dst
[2] == '2', "got %02x\n", dst
[2]);
1742 ok(dst
[3] == 0, "got %02x\n", dst
[3]);
1743 ok(dst
[4] == (char)0xcc, "got %02x\n", dst
[4]);
1747 memset(src
, 0, sizeof(src
));
1748 ((CY
*)src
)->int64
= 43210000;
1749 memset(dst
, 0xcc, sizeof(dst
));
1751 hr
= IDataConvert_DataConvert(convert
, DBTYPE_CY
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1752 ok(hr
== S_OK
, "got %08x\n", hr
);
1753 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1754 ok(dst_len
== 4, "got %ld\n", dst_len
);
1755 ok(!lstrcmpA(dst
, fourthreetwoone
), "got %s\n", dst
);
1759 memset(src
, 0, sizeof(src
));
1760 *(signed char *)src
= 10;
1762 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I1
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1763 ok(hr
== S_OK
, "got %08x\n", hr
);
1764 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1765 ok(dst_len
== 2, "got %ld\n", dst_len
);
1766 ok(!lstrcmpA(dst
, ten_a
), "got %s\n", dst
);
1768 memset(src
, 0, sizeof(src
));
1769 *(unsigned char *)src
= 10;
1771 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI1
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1772 ok(hr
== S_OK
, "got %08x\n", hr
);
1773 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1774 ok(dst_len
== 2, "got %ld\n", dst_len
);
1775 ok(!lstrcmpA(dst
, ten_a
), "got %s\n", dst
);
1777 memset(src
, 0, sizeof(src
));
1778 *(unsigned short *)src
= 4321;
1780 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI2
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1781 ok(hr
== S_OK
, "got %08x\n", hr
);
1782 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1783 ok(dst_len
== 4, "got %ld\n", dst_len
);
1784 ok(!lstrcmpA(dst
, fourthreetwoone
), "got %s\n", dst
);
1786 memset(src
, 0, sizeof(src
));
1787 *(unsigned int *)src
= 4321;
1789 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI4
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1790 ok(hr
== S_OK
, "got %08x\n", hr
);
1791 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1792 ok(dst_len
== 4, "got %ld\n", dst_len
);
1793 ok(!lstrcmpA(dst
, fourthreetwoone
), "got %s\n", dst
);
1795 memset(src
, 0, sizeof(src
));
1796 ((LARGE_INTEGER
*)src
)->QuadPart
= 4321;
1798 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I8
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1799 ok(broken(DB_E_UNSUPPORTEDCONVERSION
) || hr
== S_OK
/* W2K+ */, "got %08x\n", hr
);
1800 ok(broken(dst_status
== DBSTATUS_E_BADACCESSOR
) || dst_status
== DBSTATUS_S_OK
/* W2K+ */, "got %08x\n", dst_status
);
1801 ok(broken(dst_len
== 0x1234) || dst_len
== 4 /* W2K+ */, "got %ld\n", dst_len
);
1802 ok(!lstrcmpA(dst
, fourthreetwoone
), "got %s\n", dst
);
1804 memset(src
, 0, sizeof(src
));
1805 ((ULARGE_INTEGER
*)src
)->QuadPart
= 4321;
1807 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI8
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1808 ok(broken(DB_E_UNSUPPORTEDCONVERSION
) || hr
== S_OK
/* W2K+ */, "got %08x\n", hr
);
1809 ok(broken(dst_status
== DBSTATUS_E_BADACCESSOR
) || dst_status
== DBSTATUS_S_OK
/* W2K+ */, "got %08x\n", dst_status
);
1810 ok(broken(dst_len
== 0x1234) || dst_len
== 4 /* W2K+ */, "got %ld\n", dst_len
);
1811 ok(!lstrcmpA(dst
, fourthreetwoone
), "got %s\n", dst
);
1815 memset(src
, 0, sizeof(src
));
1816 memcpy(src
, &IID_IDataConvert
, sizeof(GUID
));
1817 memset(dst
, 0xcc, sizeof(dst
));
1819 hr
= IDataConvert_DataConvert(convert
, DBTYPE_GUID
, DBTYPE_STR
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1820 ok(hr
== S_OK
, "got %08x\n", hr
);
1821 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1822 ok(dst_len
== 38, "got %ld\n", dst_len
);
1823 ok(!lstrcmpA(dst
, guid_str
), "got %s\n", dst
);
1827 b
= SysAllocString(ten
);
1829 memset(dst
, 0xcc, sizeof(dst
));
1831 hr
= IDataConvert_DataConvert(convert
, DBTYPE_BSTR
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1832 ok(hr
== S_OK
, "got %08x\n", hr
);
1833 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1834 ok(dst_len
== 2, "got %ld\n", dst_len
);
1835 ok(!lstrcmpA(ten_a
, dst
), "got %s\n", dst
);
1838 memcpy(src
, ten
, sizeof(ten
));
1839 memset(dst
, 0xcc, sizeof(dst
));
1841 hr
= IDataConvert_DataConvert(convert
, DBTYPE_WSTR
, DBTYPE_STR
, 2, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1842 ok(hr
== S_OK
, "got %08x\n", hr
);
1843 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1844 ok(dst_len
== 1, "got %ld\n", dst_len
);
1845 ok(dst
[0] == '1', "got %02x\n", dst
[0]);
1846 ok(dst
[1] == 0, "got %02x\n", dst
[1]);
1848 memcpy(src
, ten
, sizeof(ten
));
1849 memset(dst
, 0xcc, sizeof(dst
));
1851 hr
= IDataConvert_DataConvert(convert
, DBTYPE_WSTR
, DBTYPE_STR
, 4, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1852 ok(hr
== S_OK
, "got %08x\n", hr
);
1853 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1854 ok(dst_len
== 2, "got %ld\n", dst_len
);
1855 ok(!lstrcmpA(ten_a
, dst
), "got %s\n", dst
);
1857 memcpy(src
, ten
, sizeof(ten
));
1858 memset(dst
, 0xcc, sizeof(dst
));
1860 hr
= IDataConvert_DataConvert(convert
, DBTYPE_WSTR
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, DBDATACONVERT_LENGTHFROMNTS
);
1861 ok(hr
== S_OK
, "got %08x\n", hr
);
1862 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1863 ok(dst_len
== 2, "got %ld\n", dst_len
);
1864 ok(!lstrcmpA(ten_a
, dst
), "got %s\n", dst
);
1866 memcpy(src
, ten_a
, sizeof(ten_a
));
1867 memset(dst
, 0xcc, sizeof(dst
));
1869 hr
= IDataConvert_DataConvert(convert
, DBTYPE_STR
, DBTYPE_STR
, 2, &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
== 2, "got %ld\n", dst_len
);
1873 ok(dst
[0] == '1', "got %02x\n", dst
[0]);
1874 ok(dst
[1] == '0', "got %02x\n", dst
[1]);
1875 ok(dst
[2] == 0, "got %02x\n", dst
[2]);
1876 ok(dst
[3] == (char)0xcc, "got %02x\n", dst
[3]);
1878 memcpy(src
, ten_a
, sizeof(ten_a
));
1879 memset(dst
, 0xcc, sizeof(dst
));
1881 hr
= IDataConvert_DataConvert(convert
, DBTYPE_STR
, DBTYPE_STR
, 4, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1882 ok(hr
== S_OK
, "got %08x\n", hr
);
1883 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1884 ok(dst_len
== 4, "got %ld\n", dst_len
);
1885 ok(!lstrcmpA(ten_a
, dst
), "got %s\n", dst
);
1887 memcpy(src
, ten_a
, sizeof(ten_a
));
1888 memset(dst
, 0xcc, sizeof(dst
));
1890 hr
= IDataConvert_DataConvert(convert
, DBTYPE_STR
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, DBDATACONVERT_LENGTHFROMNTS
);
1891 ok(hr
== S_OK
, "got %08x\n", hr
);
1892 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1893 ok(dst_len
== 2, "got %ld\n", dst_len
);
1894 ok(!lstrcmpA(ten_a
, dst
), "got %s\n", dst
);
1898 /* DBTYPE_BYTES to DBTYPE_*STR unpacks binary data into a hex string */
1899 memcpy(src
, hexpacked_a
, sizeof(hexpacked_a
));
1900 memset(dst
, 0xcc, sizeof(dst
));
1902 hr
= IDataConvert_DataConvert(convert
, DBTYPE_BYTES
, DBTYPE_STR
, sizeof(hexpacked_a
), &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1903 ok(hr
== S_OK
, "got %08x\n", hr
);
1904 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1905 ok(dst_len
== sizeof(hexpacked_a
) * 2, "got %ld\n", dst_len
);
1906 ok(!lstrcmpA(hexunpacked_a
, dst
), "got %s\n", dst
);
1907 ok(dst
[sizeof(hexpacked_a
)/sizeof(char) * 4 + 1] == (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, 0);
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 %ld\n", dst_len
);
1916 ok(dst
[0] == 0, "not null terminated\n");
1917 ok(dst
[1] == (char)0xcc, "clobbered buffer\n");
1919 memcpy(src
, hexpacked_a
, sizeof(hexpacked_a
));
1920 memset(dst
, 0xcc, sizeof(dst
));
1922 hr
= IDataConvert_DataConvert(convert
, DBTYPE_BYTES
, DBTYPE_STR
, 4, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1923 ok(hr
== S_OK
, "got %08x\n", hr
);
1924 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1925 ok(dst_len
== 2 * sizeof(char) * 4, "got %ld\n", dst_len
);
1926 ok(!memcmp(hexunpacked_a
, dst
, 2 * sizeof(char) * 4 ), "got %s\n", dst
);
1927 ok(dst
[2 * 4] == 0, "not null terminated\n");
1928 ok(dst
[2 * 4 + 1] == (char)0xcc, "clobbered buffer\n");
1930 memcpy(src
, hexpacked_a
, sizeof(hexpacked_a
));
1931 memset(dst
, 0xcc, sizeof(dst
));
1933 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);
1934 ok(hr
== S_OK
, "got %08x\n", hr
);
1935 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1936 ok(dst_len
== sizeof(hexpacked_a
) * 2, "got %ld\n", dst_len
);
1937 ok(!memcmp(hexunpacked_a
, dst
, 2 * sizeof(char) * 4 ), "got %s\n", dst
);
1938 ok(dst
[2 * 4] == 0, "not null terminated\n");
1939 ok(dst
[2 * 4 + 1] == (char)0xcc, "clobbered buffer\n");
1941 memcpy(src
, hexpacked_a
, sizeof(hexpacked_a
));
1942 memset(dst
, 0xcc, sizeof(dst
));
1944 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);
1945 ok(hr
== S_OK
, "got %08x\n", hr
);
1946 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1947 ok(dst_len
== sizeof(hexpacked_a
) * 2, "got %ld\n", dst_len
);
1948 ok(!memcmp(hexunpacked_a
, dst
, 2 * sizeof(char) * 4 - 2 ), "got %s\n", dst
);
1949 ok(dst
[2 * 4 - 1] == 0, "not null terminated\n");
1950 ok(dst
[2 * 4] == (char)0xcc, "clobbered buffer\n");
1952 memcpy(src
, hexpacked_a
, sizeof(hexpacked_a
));
1953 memset(dst
, 0xcc, sizeof(dst
));
1955 hr
= IDataConvert_DataConvert(convert
, DBTYPE_BYTES
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, DBDATACONVERT_LENGTHFROMNTS
);
1956 ok(hr
== S_OK
, "got %08x\n", hr
);
1957 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1958 ok(dst_len
== 0, "got %ld\n", dst_len
);
1959 ok(dst
[0] == 0, "not null terminated\n");
1960 ok(dst
[1] == (char)0xcc, "clobbered buffer\n");
1962 IDataConvert_Release(convert
);
1965 static void test_converttobyrefwstr(void)
1967 IDataConvert
*convert
;
1971 DBSTATUS dst_status
;
1973 static const WCHAR ten
[] = {'1','0',0};
1974 static const WCHAR fourthreetwoone
[] = {'4','3','2','1',0};
1977 hr
= CoCreateInstance(&CLSID_OLEDB_CONVERSIONLIBRARY
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDataConvert
, (void**)&convert
);
1980 win_skip("Unable to load oledb conversion library\n");
1984 hr
= IDataConvert_DataConvert(convert
, DBTYPE_EMPTY
, DBTYPE_BYREF
| DBTYPE_WSTR
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1985 ok(hr
== S_OK
, "got %08x\n", hr
);
1986 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1987 ok(dst_len
== 0, "got %ld\n", dst_len
);
1988 ok(dst
[0] == 0, "got %04x\n", dst
[0]);
1991 dst
= (void*)0x12345678;
1993 hr
= IDataConvert_DataConvert(convert
, DBTYPE_NULL
, DBTYPE_BYREF
| DBTYPE_WSTR
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1994 ok(hr
== DB_E_UNSUPPORTEDCONVERSION
, "got %08x\n", hr
);
1995 ok(dst_status
== DBSTATUS_E_BADACCESSOR
, "got %08x\n", dst_status
);
1996 ok(dst_len
== 0x1234, "got %ld\n", dst_len
);
1997 ok(dst
== (void*)0x12345678, "got %p\n", dst
);
1999 *(short *)src
= 4321;
2001 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I2
, DBTYPE_BYREF
| DBTYPE_WSTR
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2002 ok(hr
== S_OK
, "got %08x\n", hr
);
2003 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2004 ok(dst_len
== 8, "got %ld\n", dst_len
);
2005 ok(!lstrcmpW(dst
, fourthreetwoone
), "got %s\n", wine_dbgstr_w(dst
));
2008 *(short *)src
= 4321;
2010 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I2
, DBTYPE_BYREF
| DBTYPE_WSTR
, 0, &dst_len
, src
, &dst
, 0, 0, &dst_status
, 0, 0, 0);
2011 ok(hr
== S_OK
, "got %08x\n", hr
);
2012 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2013 ok(dst_len
== 8, "got %ld\n", dst_len
);
2014 ok(!lstrcmpW(dst
, fourthreetwoone
), "got %s\n", wine_dbgstr_w(dst
));
2017 b
= SysAllocString(ten
);
2020 hr
= IDataConvert_DataConvert(convert
, DBTYPE_BSTR
, DBTYPE_BYREF
| DBTYPE_WSTR
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2021 ok(hr
== S_OK
, "got %08x\n", hr
);
2022 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2023 ok(dst_len
== 4, "got %ld\n", dst_len
);
2024 ok(!lstrcmpW(b
, dst
), "got %s\n", wine_dbgstr_w(dst
));
2028 memcpy(src
, ten
, sizeof(ten
));
2030 hr
= IDataConvert_DataConvert(convert
, DBTYPE_WSTR
, DBTYPE_BYREF
| DBTYPE_WSTR
, 2, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2031 ok(hr
== S_OK
, "got %08x\n", hr
);
2032 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2033 ok(dst_len
== 2, "got %ld\n", dst_len
);
2034 ok(dst
[0] == '1', "got %02x\n", dst
[0]);
2035 ok(dst
[1] == 0, "got %02x\n", dst
[1]);
2038 memcpy(src
, ten
, sizeof(ten
));
2040 hr
= IDataConvert_DataConvert(convert
, DBTYPE_WSTR
, DBTYPE_BYREF
| DBTYPE_WSTR
, 4, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2041 ok(hr
== S_OK
, "got %08x\n", hr
);
2042 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2043 ok(dst_len
== 4, "got %ld\n", dst_len
);
2044 ok(!lstrcmpW(ten
, dst
), "got %s\n", wine_dbgstr_w(dst
));
2047 memcpy(src
, ten
, sizeof(ten
));
2049 hr
= IDataConvert_DataConvert(convert
, DBTYPE_WSTR
, DBTYPE_BYREF
| DBTYPE_WSTR
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, DBDATACONVERT_LENGTHFROMNTS
);
2050 ok(hr
== S_OK
, "got %08x\n", hr
);
2051 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2052 ok(dst_len
== 4, "got %ld\n", dst_len
);
2053 ok(!lstrcmpW(ten
, dst
), "got %s\n", wine_dbgstr_w(dst
));
2056 IDataConvert_Release(convert
);
2059 static void test_converttoguid(void)
2061 IDataConvert
*convert
;
2065 DBSTATUS dst_status
;
2068 hr
= CoCreateInstance(&CLSID_OLEDB_CONVERSIONLIBRARY
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDataConvert
, (void**)&convert
);
2071 win_skip("Unable to load oledb conversion library\n");
2077 hr
= IDataConvert_DataConvert(convert
, DBTYPE_EMPTY
, DBTYPE_GUID
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2078 ok(hr
== S_OK
, "got %08x\n", hr
);
2079 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2080 ok(dst_len
== sizeof(GUID
), "got %ld\n", dst_len
);
2081 ok(IsEqualGUID(&dst
, &GUID_NULL
), "didn't get GUID_NULL\n");
2085 hr
= IDataConvert_DataConvert(convert
, DBTYPE_NULL
, DBTYPE_GUID
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2086 ok(hr
== DB_E_UNSUPPORTEDCONVERSION
, "got %08x\n", hr
);
2087 ok(dst_status
== DBSTATUS_E_BADACCESSOR
, "got %08x\n", dst_status
);
2088 ok(dst_len
== 0x1234, "got %ld\n", dst_len
);
2089 ok(IsEqualGUID(&dst
, &IID_IDCInfo
), "dst has changed\n");
2092 memcpy(src
, &IID_IDataConvert
, sizeof(GUID
));
2094 hr
= IDataConvert_DataConvert(convert
, DBTYPE_GUID
, DBTYPE_GUID
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2095 ok(hr
== S_OK
, "got %08x\n", hr
);
2096 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2097 ok(dst_len
== sizeof(GUID
), "got %ld\n", dst_len
);
2098 ok(IsEqualGUID(&dst
, &IID_IDataConvert
), "didn't get IID_IDataConvert\n");
2100 IDataConvert_Release(convert
);
2103 static void test_converttofiletime(void)
2105 IDataConvert
*convert
;
2109 DBSTATUS dst_status
;
2112 hr
= CoCreateInstance(&CLSID_OLEDB_CONVERSIONLIBRARY
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDataConvert
, (void**)&convert
);
2115 win_skip("Unable to load oledb conversion library\n");
2119 memset(&dst
, 0xcc, sizeof(dst
));
2120 ((FILETIME
*)src
)->dwLowDateTime
= 0x12345678;
2121 ((FILETIME
*)src
)->dwHighDateTime
= 0x9abcdef0;
2123 hr
= IDataConvert_DataConvert(convert
, DBTYPE_FILETIME
, DBTYPE_FILETIME
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2125 broken(hr
== DB_E_BADBINDINFO
), /* win98 */
2129 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2130 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
2131 ok(dst
.dwLowDateTime
== 0x12345678, "got %08x\n", dst
.dwLowDateTime
);
2132 ok(dst
.dwHighDateTime
== 0x9abcdef0, "got %08x\n", dst
.dwHighDateTime
);
2135 IDataConvert_Release(convert
);
2138 static void test_converttoui1(void)
2140 IDataConvert
*convert
;
2144 DBSTATUS dst_status
;
2147 hr
= CoCreateInstance(&CLSID_OLEDB_CONVERSIONLIBRARY
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDataConvert
, (void**)&convert
);
2150 win_skip("Unable to load oledb conversion library\n");
2156 hr
= IDataConvert_DataConvert(convert
, DBTYPE_EMPTY
, DBTYPE_UI1
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2157 ok(hr
== S_OK
, "got %08x\n", hr
);
2158 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2159 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
2160 ok(dst
== 0, "got %08x\n", dst
);
2164 hr
= IDataConvert_DataConvert(convert
, DBTYPE_NULL
, DBTYPE_UI1
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2165 ok(hr
== DB_E_UNSUPPORTEDCONVERSION
, "got %08x\n", hr
);
2166 ok(dst_status
== DBSTATUS_E_BADACCESSOR
, "got %08x\n", dst_status
);
2167 ok(dst_len
== 0x1234, "got %ld\n", dst_len
);
2168 ok(dst
== 0x12, "got %08x\n", dst
);
2173 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI1
, DBTYPE_UI1
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2174 ok(hr
== S_OK
, "got %08x\n", hr
);
2175 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2176 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
2177 ok(dst
== 0x43, "got %08x\n", dst
);
2182 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI1
, DBTYPE_UI1
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2183 ok(hr
== S_OK
, "got %08x\n", hr
);
2184 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2185 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
2186 ok(dst
== 0xfe, "got %08x\n", dst
);
2188 IDataConvert_Release(convert
);
2191 static void test_converttoui4(void)
2193 IDataConvert
*convert
;
2197 DBSTATUS dst_status
;
2200 hr
= CoCreateInstance(&CLSID_OLEDB_CONVERSIONLIBRARY
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDataConvert
, (void**)&convert
);
2203 win_skip("Unable to load oledb conversion library\n");
2209 hr
= IDataConvert_DataConvert(convert
, DBTYPE_EMPTY
, DBTYPE_UI4
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2210 ok(hr
== S_OK
, "got %08x\n", hr
);
2211 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2212 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
2213 ok(dst
== 0, "got %08x\n", dst
);
2217 hr
= IDataConvert_DataConvert(convert
, DBTYPE_NULL
, DBTYPE_UI4
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2218 ok(hr
== DB_E_UNSUPPORTEDCONVERSION
, "got %08x\n", hr
);
2219 ok(dst_status
== DBSTATUS_E_BADACCESSOR
, "got %08x\n", dst_status
);
2220 ok(dst_len
== 0x1234, "got %ld\n", dst_len
);
2221 ok(dst
== 0x12345678, "got %08x\n", dst
);
2224 *(DWORD
*)src
= 0x87654321;
2226 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI4
, DBTYPE_UI4
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2227 ok(hr
== S_OK
, "got %08x\n", hr
);
2228 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2229 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
2230 ok(dst
== 0x87654321, "got %08x\n", dst
);
2233 *(signed short *)src
= 0x4321;
2235 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I2
, DBTYPE_UI4
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2236 ok(hr
== S_OK
, "got %08x\n", hr
);
2237 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2238 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
2239 ok(dst
== 0x4321, "got %08x\n", dst
);
2242 *(signed short *)src
= -1;
2244 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I2
, DBTYPE_UI4
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2245 ok(hr
== DB_E_ERRORSOCCURRED
, "got %08x\n", hr
);
2247 ok(dst_status
== DBSTATUS_E_SIGNMISMATCH
, "got %08x\n", dst_status
);
2249 ok(broken(dst_len
== sizeof(dst
)) || dst_len
== 0x1234 /* W2K+ */, "got %ld\n", dst_len
);
2250 ok(dst
== 0x12345678, "got %08x\n", dst
);
2252 IDataConvert_Release(convert
);
2255 static void test_converttor4(void)
2257 IDataConvert
*convert
;
2261 DBSTATUS dst_status
;
2264 hr
= CoCreateInstance(&CLSID_OLEDB_CONVERSIONLIBRARY
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDataConvert
, (void**)&convert
);
2267 win_skip("Unable to load oledb conversion library\n");
2273 hr
= IDataConvert_DataConvert(convert
, DBTYPE_EMPTY
, DBTYPE_R4
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2274 ok(hr
== S_OK
, "got %08x\n", hr
);
2275 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2276 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
2277 ok(dst
== 0.0, "got %f\n", dst
);
2281 hr
= IDataConvert_DataConvert(convert
, DBTYPE_NULL
, DBTYPE_R4
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2282 ok(hr
== DB_E_UNSUPPORTEDCONVERSION
, "got %08x\n", hr
);
2283 ok(dst_status
== DBSTATUS_E_BADACCESSOR
, "got %08x\n", dst_status
);
2284 ok(dst_len
== 0x1234, "got %ld\n", dst_len
);
2285 ok(dst
== 1.0, "got %f\n", dst
);
2288 *(signed int*)src
= 12345678;
2290 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I4
, DBTYPE_R4
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2291 ok(hr
== S_OK
, "got %08x\n", hr
);
2292 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2293 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
2294 ok(dst
== 12345678.0, "got %f\n", dst
);
2297 *(FLOAT
*)src
= 10.0;
2299 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R4
, DBTYPE_R4
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2300 ok(hr
== S_OK
, "got %08x\n", hr
);
2301 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2302 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
2303 ok(dst
== 10.0, "got %f\n", dst
);
2305 IDataConvert_Release(convert
);
2308 static void test_converttocy(void)
2310 IDataConvert
*convert
;
2314 DBSTATUS dst_status
;
2317 hr
= CoCreateInstance(&CLSID_OLEDB_CONVERSIONLIBRARY
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDataConvert
, (void**)&convert
);
2320 win_skip("Unable to load oledb conversion library\n");
2326 hr
= IDataConvert_DataConvert(convert
, DBTYPE_EMPTY
, DBTYPE_CY
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2327 ok(hr
== S_OK
, "got %08x\n", hr
);
2328 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2329 ok(dst_len
== sizeof(CY
), "got %ld\n", dst_len
);
2330 ok(dst
.int64
== 0, "didn't get 0\n");
2334 hr
= IDataConvert_DataConvert(convert
, DBTYPE_NULL
, DBTYPE_CY
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2335 ok(hr
== DB_E_UNSUPPORTEDCONVERSION
, "got %08x\n", hr
);
2336 ok(dst_status
== DBSTATUS_E_BADACCESSOR
, "got %08x\n", dst_status
);
2337 ok(dst_len
== 0x1234, "got %ld\n", dst_len
);
2338 ok(dst
.int64
== 0xcc, "dst changed\n");
2343 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I4
, DBTYPE_CY
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2344 ok(hr
== S_OK
, "got %08x\n", hr
);
2345 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2346 ok(dst_len
== sizeof(CY
), "got %ld\n", dst_len
);
2347 ok(dst
.int64
== 12340000, "got %d\n", dst
.s
.Lo
);
2350 ((CY
*)src
)->int64
= 1234;
2352 hr
= IDataConvert_DataConvert(convert
, DBTYPE_CY
, DBTYPE_CY
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2353 ok(hr
== S_OK
, "got %08x\n", hr
);
2354 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2355 ok(dst_len
== sizeof(CY
), "got %ld\n", dst_len
);
2356 ok(dst
.int64
== 1234, "got %d\n", dst
.s
.Lo
);
2358 IDataConvert_Release(convert
);
2361 static void test_converttoui8(void)
2363 IDataConvert
*convert
;
2367 DBSTATUS dst_status
;
2370 hr
= CoCreateInstance(&CLSID_OLEDB_CONVERSIONLIBRARY
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDataConvert
, (void**)&convert
);
2373 win_skip("Unable to load oledb conversion library\n");
2377 dst
.QuadPart
= 0xcc;
2379 hr
= IDataConvert_DataConvert(convert
, DBTYPE_EMPTY
, DBTYPE_UI8
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2380 ok(hr
== S_OK
, "got %08x\n", hr
);
2381 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2382 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
2383 ok(dst
.QuadPart
== 0, "got %d\n", (int)dst
.QuadPart
);
2385 dst
.QuadPart
= 0xcc;
2387 hr
= IDataConvert_DataConvert(convert
, DBTYPE_NULL
, DBTYPE_UI8
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2388 ok(hr
== DB_E_UNSUPPORTEDCONVERSION
, "got %08x\n", hr
);
2389 ok(dst_status
== DBSTATUS_E_BADACCESSOR
, "got %08x\n", dst_status
);
2390 ok(dst_len
== 0x1234, "got %ld\n", dst_len
);
2391 ok(dst
.QuadPart
== 0xcc, "dst changed\n");
2393 dst
.QuadPart
= 0xcc;
2396 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I4
, DBTYPE_UI8
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2397 ok(hr
== S_OK
, "got %08x\n", hr
);
2398 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2399 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
2400 ok(dst
.QuadPart
== 1234, "got %d\n", (int)dst
.QuadPart
);
2402 dst
.QuadPart
= 0xcc;
2405 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I4
, DBTYPE_UI8
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2406 ok(hr
== DB_E_ERRORSOCCURRED
, "got %08x\n", hr
);
2408 ok(dst_status
== DBSTATUS_E_SIGNMISMATCH
, "got %08x\n", dst_status
);
2410 ok(dst_len
== 0x1234, "got %ld\n", dst_len
);
2411 ok(dst
.QuadPart
== 0xcc, "got %d\n", (int)dst
.QuadPart
);
2413 dst
.QuadPart
= 0xcc;
2414 ((ULARGE_INTEGER
*)src
)->QuadPart
= 1234;
2416 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI8
, DBTYPE_UI8
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2417 ok(hr
== S_OK
, "got %08x\n", hr
);
2418 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2419 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
2420 ok(dst
.QuadPart
== 1234, "got %d\n", (int)dst
.QuadPart
);
2422 IDataConvert_Release(convert
);
2427 OleInitialize(NULL
);
2432 test_converttostr();
2433 test_converttobstr();
2434 test_converttowstr();
2435 test_converttobyrefwstr();
2436 test_converttoguid();
2437 test_converttoui1();
2438 test_converttoui4();
2440 test_converttofiletime();
2442 test_converttoui8();