wined3d: Pass a wined3d_device_context to wined3d_cs_emit_blt_sub_resource().
[wine/zf.git] / dlls / oledb32 / tests / convert.c
blob8ec64d40ae514a28c6e465a5dce7745abd1391d6
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
20 #include <stdarg.h>
22 #define COBJMACROS
23 #define NONAMELESSUNION
24 #define NONAMELESSSTRUCT
26 #include "windef.h"
27 #include "winbase.h"
28 #include "ole2.h"
29 #include "msdadc.h"
31 #include "oledberr.h"
33 #include "initguid.h"
34 #include "msdaguid.h"
36 #include "wine/test.h"
38 static IDataConvert *convert;
40 static void test_dcinfo(void)
42 IDCInfo *info;
43 HRESULT hr;
44 DCINFOTYPE types[2];
45 DCINFO *inf;
47 hr = CoCreateInstance(&CLSID_OLEDB_CONVERSIONLIBRARY, NULL, CLSCTX_INPROC_SERVER, &IID_IDCInfo, (void**)&info);
48 if(FAILED(hr))
50 win_skip("Unable to load oledb conversion library\n");
51 return;
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);
65 CoTaskMemFree(inf);
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);
76 CoTaskMemFree(inf);
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);
87 CoTaskMemFree(inf);
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);
98 CoTaskMemFree(inf);
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);
109 CoTaskMemFree(inf);
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);
122 CoTaskMemFree(inf);
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));
129 CoTaskMemFree(inf);
131 /* More than one type */
132 types[1] = 2;
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);
143 CoTaskMemFree(inf);
146 IDCInfo_Release(info);
149 static const struct can_convert
151 DBTYPE type;
152 DWORD can_convert_to;
153 } simple_convert[] =
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 HRESULT hr;
204 int src_idx, dst_idx;
206 /* Some older versions of the library don't support several conversions, we'll skip
207 if we have such a library */
208 hr = IDataConvert_CanConvert(convert, DBTYPE_EMPTY, DBTYPE_DBTIMESTAMP);
209 if(hr == S_FALSE)
211 win_skip("Doesn't handle DBTYPE_EMPTY -> DBTYPE_DBTIMESTAMP conversion so skipping\n");
212 return;
215 /* Some older versions of the library don't support several conversions, we'll skip
216 if we have such a library */
217 hr = IDataConvert_CanConvert(convert, DBTYPE_EMPTY, DBTYPE_DBTIMESTAMP);
218 if(hr == S_FALSE)
220 win_skip("Doesn't handle DBTYPE_EMPTY -> DBTYPE_DBTIMESTAMP conversion so skipping\n");
221 return;
224 for(src_idx = 0; src_idx < ARRAY_SIZE(simple_convert); src_idx++)
225 for(dst_idx = 0; dst_idx < ARRAY_SIZE(simple_convert); dst_idx++)
227 BOOL expect, simple_expect;
228 simple_expect = (simple_convert[src_idx].can_convert_to >> dst_idx) & 1;
230 hr = IDataConvert_CanConvert(convert, simple_convert[src_idx].type, simple_convert[dst_idx].type);
231 expect = simple_expect;
232 ok((hr == S_OK && expect == TRUE) ||
233 (hr == S_FALSE && expect == FALSE),
234 "%04x -> %04x: got %08x expect conversion to be %spossible\n", simple_convert[src_idx].type,
235 simple_convert[dst_idx].type, hr, expect ? "" : "not ");
237 /* src DBTYPE_BYREF */
238 hr = IDataConvert_CanConvert(convert, simple_convert[src_idx].type | DBTYPE_BYREF, simple_convert[dst_idx].type);
239 expect = simple_expect;
240 ok((hr == S_OK && expect == TRUE) ||
241 (hr == S_FALSE && expect == FALSE),
242 "%04x -> %04x: got %08x expect conversion to be %spossible\n", simple_convert[src_idx].type | DBTYPE_BYREF,
243 simple_convert[dst_idx].type, hr, expect ? "" : "not ");
245 /* dst DBTYPE_BYREF */
246 hr = IDataConvert_CanConvert(convert, simple_convert[src_idx].type, simple_convert[dst_idx].type | DBTYPE_BYREF);
247 expect = FALSE;
248 if(simple_expect &&
249 (simple_convert[dst_idx].type == DBTYPE_BYTES ||
250 simple_convert[dst_idx].type == DBTYPE_STR ||
251 simple_convert[dst_idx].type == DBTYPE_WSTR))
252 expect = TRUE;
253 ok((hr == S_OK && expect == TRUE) ||
254 (hr == S_FALSE && expect == FALSE),
255 "%04x -> %04x: got %08x expect conversion to be %spossible\n", simple_convert[src_idx].type,
256 simple_convert[dst_idx].type | DBTYPE_BYREF, hr, expect ? "" : "not ");
258 /* src & dst DBTYPE_BYREF */
259 hr = IDataConvert_CanConvert(convert, simple_convert[src_idx].type | DBTYPE_BYREF, simple_convert[dst_idx].type | DBTYPE_BYREF);
260 expect = FALSE;
261 if(simple_expect &&
262 (simple_convert[dst_idx].type == DBTYPE_BYTES ||
263 simple_convert[dst_idx].type == DBTYPE_STR ||
264 simple_convert[dst_idx].type == DBTYPE_WSTR))
265 expect = TRUE;
266 ok((hr == S_OK && expect == TRUE) ||
267 (hr == S_FALSE && expect == FALSE),
268 "%04x -> %04x: got %08x expect conversion to be %spossible\n", simple_convert[src_idx].type | DBTYPE_BYREF,
269 simple_convert[dst_idx].type | DBTYPE_BYREF, hr, expect ? "" : "not ");
271 /* src DBTYPE_ARRAY */
272 hr = IDataConvert_CanConvert(convert, simple_convert[src_idx].type | DBTYPE_ARRAY, simple_convert[dst_idx].type);
273 expect = FALSE;
274 if(array_type(simple_convert[src_idx].type) && simple_convert[dst_idx].type == DBTYPE_VARIANT)
275 expect = TRUE;
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_ARRAY,
279 simple_convert[dst_idx].type, hr, expect ? "" : "not ");
281 /* dst DBTYPE_ARRAY */
282 hr = IDataConvert_CanConvert(convert, simple_convert[src_idx].type, simple_convert[dst_idx].type | DBTYPE_ARRAY);
283 expect = FALSE;
284 if(array_type(simple_convert[dst_idx].type) &&
285 (simple_convert[src_idx].type == DBTYPE_IDISPATCH ||
286 simple_convert[src_idx].type == DBTYPE_VARIANT))
287 expect = TRUE;
288 ok((hr == S_OK && expect == TRUE) ||
289 (hr == S_FALSE && expect == FALSE),
290 "%04x -> %04x: got %08x expect conversion to be %spossible\n", simple_convert[src_idx].type,
291 simple_convert[dst_idx].type | DBTYPE_ARRAY, hr, expect ? "" : "not ");
293 /* src & dst DBTYPE_ARRAY */
294 hr = IDataConvert_CanConvert(convert, simple_convert[src_idx].type | DBTYPE_ARRAY, simple_convert[dst_idx].type | DBTYPE_ARRAY);
295 expect = FALSE;
296 if(array_type(simple_convert[src_idx].type) &&
297 simple_convert[src_idx].type == simple_convert[dst_idx].type)
298 expect = TRUE;
299 ok((hr == S_OK && expect == TRUE) ||
300 (hr == S_FALSE && expect == FALSE),
301 "%04x -> %04x: got %08x expect conversion to be %spossible\n", simple_convert[src_idx].type | DBTYPE_ARRAY,
302 simple_convert[dst_idx].type | DBTYPE_ARRAY, hr, expect ? "" : "not ");
304 /* src DBTYPE_VECTOR */
305 hr = IDataConvert_CanConvert(convert, simple_convert[src_idx].type | DBTYPE_VECTOR, simple_convert[dst_idx].type);
306 ok(hr == S_FALSE,
307 "%04x -> %04x: got %08x expect conversion to not be possible\n", simple_convert[src_idx].type | DBTYPE_VECTOR,
308 simple_convert[dst_idx].type, hr);
310 /* dst DBTYPE_VECTOR */
311 hr = IDataConvert_CanConvert(convert, simple_convert[src_idx].type, simple_convert[dst_idx].type | DBTYPE_VECTOR);
312 ok(hr == S_FALSE,
313 "%04x -> %04x: got %08x expect conversion to not be possible\n", simple_convert[src_idx].type,
314 simple_convert[dst_idx].type | DBTYPE_VECTOR, hr);
316 /* src & dst DBTYPE_VECTOR */
317 hr = IDataConvert_CanConvert(convert, simple_convert[src_idx].type | DBTYPE_VECTOR, simple_convert[dst_idx].type | DBTYPE_VECTOR);
318 ok(hr == S_FALSE,
319 "%04x -> %04x: got %08x expect conversion to not be possible\n", simple_convert[src_idx].type | DBTYPE_VECTOR,
320 simple_convert[dst_idx].type | DBTYPE_VECTOR, hr);
326 static void test_converttoi1(void)
328 HRESULT hr;
329 signed char dst;
330 BYTE src[20];
331 DBSTATUS dst_status;
332 DBLENGTH dst_len;
333 static const WCHAR ten[] = {'1','0',0};
334 BSTR b;
336 dst_len = dst = 0x12;
337 hr = IDataConvert_DataConvert(convert, DBTYPE_EMPTY, DBTYPE_I1, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
338 ok(hr == S_OK, "got %08x\n", hr);
339 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
340 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
341 ok(dst == 0, "got %08x\n", dst);
343 dst_len = dst = 0x12;
344 hr = IDataConvert_DataConvert(convert, DBTYPE_NULL, DBTYPE_I1, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
345 ok(hr == DB_E_UNSUPPORTEDCONVERSION, "got %08x\n", hr);
346 ok(dst_status == DBSTATUS_E_BADACCESSOR, "got %08x\n", dst_status);
347 ok(dst_len == 0x12, "got %ld\n", dst_len);
348 ok(dst == 0x12, "got %08x\n", dst);
350 dst_len = dst = 0x12;
351 *(short *)src = 0x43;
352 hr = IDataConvert_DataConvert(convert, DBTYPE_I2, DBTYPE_I1, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
353 ok(hr == S_OK, "got %08x\n", hr);
354 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
355 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
356 ok(dst == 0x43, "got %08x\n", dst);
358 dst_len = dst = 0x12;
359 *(int *)src = 0x4321cafe;
360 hr = IDataConvert_DataConvert(convert, DBTYPE_I4, DBTYPE_I1, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
361 todo_wine
362 ok(hr == DB_E_DATAOVERFLOW, "got %08x\n", hr);
363 ok(dst_status == DBSTATUS_E_DATAOVERFLOW, "got %08x\n", dst_status);
364 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
365 ok(dst == 0x12, "got %08x\n", dst);
367 dst_len = dst = 0x12;
368 *(int *)src = 0x43;
369 hr = IDataConvert_DataConvert(convert, DBTYPE_I4, DBTYPE_I1, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
370 ok(hr == S_OK, "got %08x\n", hr);
371 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
372 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
373 ok(dst == 0x43, "got %08x\n", dst);
375 dst_len = dst = 0x12;
376 *(FLOAT *)src = 10.75;
377 hr = IDataConvert_DataConvert(convert, DBTYPE_R4, DBTYPE_I1, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
378 ok(hr == S_OK, "got %08x\n", hr);
379 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
380 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
381 ok(dst == 11, "got %08x\n", dst);
383 dst_len = dst = 0x12;
384 *(FLOAT *)src = -10.75;
385 hr = IDataConvert_DataConvert(convert, DBTYPE_R4, DBTYPE_I1, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
386 ok(hr == S_OK, "got %08x\n", hr);
387 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
388 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
389 ok(dst == -11, "got %08x\n", dst);
391 dst_len = dst = 0x12;
392 *(double *)src = 10.75;
393 hr = IDataConvert_DataConvert(convert, DBTYPE_R8, DBTYPE_I1, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
394 ok(hr == S_OK, "got %08x\n", hr);
395 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
396 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
397 ok(dst == 11, "got %08x\n", dst);
399 dst_len = dst = 0x12;
400 ((LARGE_INTEGER *)src)->QuadPart = 107500;
401 hr = IDataConvert_DataConvert(convert, DBTYPE_CY, DBTYPE_I1, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
402 ok(hr == S_OK, "got %08x\n", hr);
403 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
404 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
405 ok(dst == 11, "got %08x\n", dst);
407 dst_len = dst = 0x12;
408 *(DATE *)src = 10.7500;
409 hr = IDataConvert_DataConvert(convert, DBTYPE_DATE, DBTYPE_I1, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
410 ok(hr == S_OK, "got %08x\n", hr);
411 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
412 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
413 ok(dst == 11, "got %08x\n", dst);
415 dst_len = dst = 0x12;
416 b = SysAllocString(ten);
417 *(BSTR *)src = b;
418 hr = IDataConvert_DataConvert(convert, DBTYPE_BSTR, DBTYPE_I1, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
419 ok(hr == S_OK, "got %08x\n", hr);
420 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
421 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
422 ok(dst == 10, "got %08x\n", dst);
423 SysFreeString(b);
425 dst_len = dst = 0x12;
426 *(SCODE *)src = 0x4321cafe;
427 hr = IDataConvert_DataConvert(convert, DBTYPE_ERROR, DBTYPE_I1, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
428 ok(hr == DB_E_UNSUPPORTEDCONVERSION, "got %08x\n", hr);
429 ok(dst_status == DBSTATUS_E_BADACCESSOR, "got %08x\n", dst_status);
430 ok(dst_len == 0x12, "got %ld\n", dst_len);
431 ok(dst == 0x12, "got %08x\n", dst);
433 dst_len = dst = 0x12;
434 *(VARIANT_BOOL *)src = VARIANT_TRUE;
435 hr = IDataConvert_DataConvert(convert, DBTYPE_BOOL, DBTYPE_I1, 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 == -1, "got %08x\n", dst);
441 dst_len = dst = 0x12;
442 *(VARIANT_BOOL *)src = VARIANT_FALSE;
443 hr = IDataConvert_DataConvert(convert, DBTYPE_BOOL, DBTYPE_I1, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
444 ok(hr == S_OK, "got %08x\n", hr);
445 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
446 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
447 ok(dst == 0, "got %08x\n", dst);
449 dst_len = dst = 0x12;
450 V_VT((VARIANT*)src) = VT_I2;
451 V_I2((VARIANT*)src) = 0x43;
452 hr = IDataConvert_DataConvert(convert, DBTYPE_VARIANT, DBTYPE_I1, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
453 ok(hr == S_OK, "got %08x\n", hr);
454 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
455 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
456 ok(dst == 0x43, "got %08x\n", dst);
458 V_VT((VARIANT*)src) = VT_NULL;
459 dst_len = 0x12;
460 hr = IDataConvert_DataConvert(convert, DBTYPE_VARIANT, DBTYPE_I1, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
461 ok(hr == S_OK, "got %08x\n", hr);
462 ok(dst_status == DBSTATUS_S_ISNULL, "got %08x\n", dst_status);
463 ok(dst_len == 0x12, "got %ld\n", dst_len);
465 dst_len = dst = 0x12;
466 memset(src, 0, sizeof(DECIMAL));
467 ((DECIMAL*)src)->u1.Lo64 = 0x43;
468 hr = IDataConvert_DataConvert(convert, DBTYPE_DECIMAL, DBTYPE_I1, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
469 ok(hr == S_OK, "got %08x\n", hr);
470 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
471 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
472 ok(dst == 0x43, "got %08x\n", dst);
474 dst_len = dst = 0x12;
475 *(signed char*)src = 0x70;
476 hr = IDataConvert_DataConvert(convert, DBTYPE_I1, DBTYPE_I1, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
477 ok(hr == S_OK, "got %08x\n", hr);
478 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
479 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
480 ok(dst == 0x70, "got %08x\n", dst);
482 dst_len = dst = 0x12;
483 *(BYTE*)src = 0x70;
484 hr = IDataConvert_DataConvert(convert, DBTYPE_UI1, DBTYPE_I1, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
485 ok(hr == S_OK, "got %08x\n", hr);
486 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
487 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
488 ok(dst == 0x70, "got %08x\n", dst);
490 dst_len = dst = 0x12;
491 *(WORD*)src = 0xC8;
492 hr = IDataConvert_DataConvert(convert, DBTYPE_UI1, DBTYPE_I1, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
493 ok(hr == DB_E_ERRORSOCCURRED, "got %08x\n", hr);
494 ok(dst_status == DBSTATUS_E_DATAOVERFLOW, "got %08x\n", dst_status);
495 todo_wine
496 ok(broken(dst_len == sizeof(dst)) || dst_len == 0x12 /* W2K+ */, "got %ld\n", dst_len);
497 ok(dst == 0x12, "got %08x\n", dst);
499 dst_len = dst = 0x12;
500 *(WORD*)src = 0x43;
501 hr = IDataConvert_DataConvert(convert, DBTYPE_UI2, DBTYPE_I1, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
502 ok(hr == S_OK, "got %08x\n", hr);
503 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
504 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
505 ok(dst == 0x43, "got %08x\n", dst);
507 dst_len = dst = 0x12;
508 *(DWORD*)src = 0xabcd1234;
509 hr = IDataConvert_DataConvert(convert, DBTYPE_UI4, DBTYPE_I1, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
510 todo_wine
511 ok(hr == DB_E_DATAOVERFLOW, "got %08x\n", hr);
512 ok(dst_status == DBSTATUS_E_DATAOVERFLOW, "got %08x\n", dst_status);
513 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
514 ok(dst == 0x12, "got %08x\n", dst);
516 dst_len = dst = 0x12;
517 *(DWORD*)src = 0x12abcd;
518 hr = IDataConvert_DataConvert(convert, DBTYPE_UI4, DBTYPE_I1, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
519 todo_wine
520 ok(hr == DB_E_DATAOVERFLOW, "got %08x\n", hr);
521 ok(dst_status == DBSTATUS_E_DATAOVERFLOW, "got %08x\n", dst_status);
522 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
523 ok(dst == 0x12, "got %08x\n", dst);
525 dst_len = dst = 0x12;
526 *(DWORD*)src = 0x43;
527 hr = IDataConvert_DataConvert(convert, DBTYPE_UI4, DBTYPE_I1, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
528 ok(hr == S_OK, "got %08x\n", hr);
529 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
530 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
531 ok(dst == 0x43, "got %08x\n", dst);
533 dst_len = dst = 0x12;
534 ((LARGE_INTEGER*)src)->QuadPart = 0x12abcd;
535 hr = IDataConvert_DataConvert(convert, DBTYPE_I8, DBTYPE_I1, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
536 ok(hr == DB_E_ERRORSOCCURRED ||
537 broken(hr == DB_E_UNSUPPORTEDCONVERSION), /* win98 */
538 "got %08x\n", hr);
539 if(hr != DB_E_UNSUPPORTEDCONVERSION) /* win98 doesn't support I8/UI8 */
541 ok(dst_status == DBSTATUS_E_DATAOVERFLOW, "got %08x\n", dst_status);
542 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
543 ok(dst == 0x12, "got %08x\n", dst);
545 dst_len = dst = 0x12;
546 ((LARGE_INTEGER*)src)->QuadPart = 0x43;
547 hr = IDataConvert_DataConvert(convert, DBTYPE_I8, DBTYPE_I1, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
548 ok(hr == S_OK, "got %08x\n", hr);
549 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
550 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
551 ok(dst == 0x43, "got %08x\n", dst);
553 dst_len = dst = 0x12;
554 ((ULARGE_INTEGER*)src)->QuadPart = 0x43;
555 hr = IDataConvert_DataConvert(convert, DBTYPE_UI8, DBTYPE_I1, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
556 ok(hr == S_OK, "got %08x\n", hr);
557 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
558 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
559 ok(dst == 0x43, "got %08x\n", dst);
562 dst_len = dst = 0x12;
563 strcpy((char *)src, "10");
564 hr = IDataConvert_DataConvert(convert, DBTYPE_STR, DBTYPE_I1, 2, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
565 ok(hr == S_OK, "got %08x\n", hr);
566 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
567 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
568 ok(dst == 10, "got %08x\n", dst);
570 dst_len = dst = 0x12;
571 strcpy((char *)src, "10");
572 hr = IDataConvert_DataConvert(convert, DBTYPE_STR, DBTYPE_I1, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, DBDATACONVERT_LENGTHFROMNTS);
573 ok(hr == S_OK, "got %08x\n", hr);
574 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
575 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
576 ok(dst == 10, "got %08x\n", dst);
578 dst_len = dst = 0x12;
579 memcpy(src, ten, sizeof(ten));
580 hr = IDataConvert_DataConvert(convert, DBTYPE_WSTR, DBTYPE_I1, 4, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
581 ok(hr == S_OK, "got %08x\n", hr);
582 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
583 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
584 ok(dst == 10, "got %08x\n", dst);
586 dst_len = dst = 0x12;
587 memcpy(src, ten, sizeof(ten));
588 hr = IDataConvert_DataConvert(convert, DBTYPE_WSTR, DBTYPE_I1, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, DBDATACONVERT_LENGTHFROMNTS);
589 ok(hr == S_OK, "got %08x\n", hr);
590 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
591 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
592 ok(dst == 10, "got %08x\n", dst);
594 dst_len = dst = 0x12;
595 *(WORD*)src = 0x43;
596 hr = IDataConvert_DataConvert(convert, DBTYPE_UI2, DBTYPE_UI1, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
597 ok(hr == S_OK, "got %08x\n", hr);
598 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
599 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
600 ok(dst == 0x43, "got %08x\n", dst);
602 dst_len = dst = 0x12;
603 *(DWORD*)src = 0xabcd1234;
604 hr = IDataConvert_DataConvert(convert, DBTYPE_UI4, DBTYPE_UI1, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
605 todo_wine
606 ok(hr == DB_E_DATAOVERFLOW, "got %08x\n", hr);
607 ok(dst_status == DBSTATUS_E_DATAOVERFLOW, "got %08x\n", dst_status);
608 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
609 ok(dst == 0x12, "got %08x\n", dst);
611 dst_len = dst = 0x12;
612 *(DWORD*)src = 0x12abcd;
613 hr = IDataConvert_DataConvert(convert, DBTYPE_UI4, DBTYPE_UI1, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
614 todo_wine
615 ok(hr == DB_E_DATAOVERFLOW, "got %08x\n", hr);
616 ok(dst_status == DBSTATUS_E_DATAOVERFLOW, "got %08x\n", dst_status);
617 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
618 ok(dst == 0x12, "got %08x\n", dst);
620 dst_len = dst = 0x12;
621 *(DWORD*)src = 0x43;
622 hr = IDataConvert_DataConvert(convert, DBTYPE_UI4, DBTYPE_UI1, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
623 ok(hr == S_OK, "got %08x\n", hr);
624 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
625 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
626 ok(dst == 0x43, "got %08x\n", dst);
628 dst_len = dst = 0x12;
629 memcpy(src, ten, sizeof(ten));
630 hr = IDataConvert_DataConvert(convert, DBTYPE_WSTR, DBTYPE_UI1, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, DBDATACONVERT_LENGTHFROMNTS);
631 ok(hr == S_OK, "got %08x\n", hr);
632 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
633 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
634 ok(dst == 10, "got %08x\n", dst);
637 static void test_converttoi2(void)
639 HRESULT hr;
640 signed short dst;
641 BYTE src[20];
642 DBSTATUS dst_status;
643 DBLENGTH dst_len;
644 static const WCHAR ten[] = {'1','0',0};
645 BSTR b;
647 dst_len = dst = 0x1234;
648 hr = IDataConvert_DataConvert(convert, DBTYPE_EMPTY, DBTYPE_I2, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
649 ok(hr == S_OK, "got %08x\n", hr);
650 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
651 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
652 ok(dst == 0, "got %08x\n", dst);
654 dst_len = dst = 0x1234;
655 hr = IDataConvert_DataConvert(convert, DBTYPE_NULL, DBTYPE_I2, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
656 ok(hr == DB_E_UNSUPPORTEDCONVERSION, "got %08x\n", hr);
657 ok(dst_status == DBSTATUS_E_BADACCESSOR, "got %08x\n", dst_status);
658 ok(dst_len == 0x1234, "got %ld\n", dst_len);
659 ok(dst == 0x1234, "got %08x\n", dst);
661 dst_len = dst = 0x1234;
662 *(short *)src = 0x4321;
663 hr = IDataConvert_DataConvert(convert, DBTYPE_I2, DBTYPE_I2, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
664 ok(hr == S_OK, "got %08x\n", hr);
665 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
666 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
667 ok(dst == 0x4321, "got %08x\n", dst);
669 dst_len = dst = 0x1234;
670 *(int *)src = 0x4321cafe;
671 hr = IDataConvert_DataConvert(convert, DBTYPE_I4, DBTYPE_I2, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
672 todo_wine
673 ok(hr == DB_E_DATAOVERFLOW, "got %08x\n", hr);
674 ok(dst_status == DBSTATUS_E_DATAOVERFLOW, "got %08x\n", dst_status);
675 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
676 ok(dst == 0x1234, "got %08x\n", dst);
678 dst_len = dst = 0x1234;
679 *(int *)src = 0x4321;
680 hr = IDataConvert_DataConvert(convert, DBTYPE_I4, DBTYPE_I2, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
681 ok(hr == S_OK, "got %08x\n", hr);
682 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
683 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
684 ok(dst == 0x4321, "got %08x\n", dst);
686 dst_len = dst = 0x1234;
687 *(FLOAT *)src = 10.75;
688 hr = IDataConvert_DataConvert(convert, DBTYPE_R4, DBTYPE_I2, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
689 ok(hr == S_OK, "got %08x\n", hr);
690 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
691 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
692 ok(dst == 11, "got %08x\n", dst);
694 dst_len = dst = 0x1234;
695 *(FLOAT *)src = -10.75;
696 hr = IDataConvert_DataConvert(convert, DBTYPE_R4, DBTYPE_I2, 0, &dst_len, src, &dst, sizeof(dst), 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(dst), "got %ld\n", dst_len);
700 ok(dst == -11, "got %08x\n", dst);
702 dst_len = dst = 0x1234;
703 *(double *)src = 10.75;
704 hr = IDataConvert_DataConvert(convert, DBTYPE_R8, DBTYPE_I2, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
705 ok(hr == S_OK, "got %08x\n", hr);
706 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
707 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
708 ok(dst == 11, "got %08x\n", dst);
710 dst_len = dst = 0x1234;
711 ((LARGE_INTEGER *)src)->QuadPart = 107500;
712 hr = IDataConvert_DataConvert(convert, DBTYPE_CY, DBTYPE_I2, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
713 ok(hr == S_OK, "got %08x\n", hr);
714 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
715 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
716 ok(dst == 11, "got %08x\n", dst);
718 dst_len = dst = 0x1234;
719 *(DATE *)src = 10.7500;
720 hr = IDataConvert_DataConvert(convert, DBTYPE_DATE, DBTYPE_I2, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
721 ok(hr == S_OK, "got %08x\n", hr);
722 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
723 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
724 ok(dst == 11, "got %08x\n", dst);
726 dst_len = dst = 0x1234;
727 b = SysAllocString(ten);
728 *(BSTR *)src = b;
729 hr = IDataConvert_DataConvert(convert, DBTYPE_BSTR, DBTYPE_I2, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
730 ok(hr == S_OK, "got %08x\n", hr);
731 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
732 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
733 ok(dst == 10, "got %08x\n", dst);
734 SysFreeString(b);
736 dst_len = dst = 0x1234;
737 *(SCODE *)src = 0x4321cafe;
738 hr = IDataConvert_DataConvert(convert, DBTYPE_ERROR, DBTYPE_I2, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
739 ok(hr == DB_E_UNSUPPORTEDCONVERSION, "got %08x\n", hr);
740 ok(dst_status == DBSTATUS_E_BADACCESSOR, "got %08x\n", dst_status);
741 ok(dst_len == 0x1234, "got %ld\n", dst_len);
742 ok(dst == 0x1234, "got %08x\n", dst);
744 dst_len = dst = 0x1234;
745 *(VARIANT_BOOL *)src = VARIANT_TRUE;
746 hr = IDataConvert_DataConvert(convert, DBTYPE_BOOL, DBTYPE_I2, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
747 ok(hr == S_OK, "got %08x\n", hr);
748 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
749 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
750 ok(dst == -1, "got %08x\n", dst);
752 dst_len = dst = 0x1234;
753 *(VARIANT_BOOL *)src = VARIANT_FALSE;
754 hr = IDataConvert_DataConvert(convert, DBTYPE_BOOL, DBTYPE_I2, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
755 ok(hr == S_OK, "got %08x\n", hr);
756 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
757 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
758 ok(dst == 0, "got %08x\n", dst);
760 dst_len = dst = 0x1234;
761 V_VT((VARIANT*)src) = VT_I2;
762 V_I2((VARIANT*)src) = 0x4321;
763 hr = IDataConvert_DataConvert(convert, DBTYPE_VARIANT, DBTYPE_I2, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
764 ok(hr == S_OK, "got %08x\n", hr);
765 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
766 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
767 ok(dst == 0x4321, "got %08x\n", dst);
769 V_VT((VARIANT*)src) = VT_NULL;
770 dst_len = 0x1234;
771 hr = IDataConvert_DataConvert(convert, DBTYPE_VARIANT, DBTYPE_I2, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
772 ok(hr == S_OK, "got %08x\n", hr);
773 ok(dst_status == DBSTATUS_S_ISNULL, "got %08x\n", dst_status);
774 ok(dst_len == 0x1234, "got %ld\n", dst_len);
776 dst_len = dst = 0x1234;
777 memset(src, 0, sizeof(DECIMAL));
778 ((DECIMAL*)src)->u1.Lo64 = 0x4321;
779 hr = IDataConvert_DataConvert(convert, DBTYPE_DECIMAL, DBTYPE_I2, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
780 ok(hr == S_OK, "got %08x\n", hr);
781 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
782 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
783 ok(dst == 0x4321, "got %08x\n", dst);
785 dst_len = dst = 0x1234;
786 *(signed char*)src = 0xab;
787 hr = IDataConvert_DataConvert(convert, DBTYPE_I1, DBTYPE_I2, 0, &dst_len, src, &dst, sizeof(dst), 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(dst), "got %ld\n", dst_len);
791 ok(dst == (signed short)0xffab, "got %08x\n", dst);
793 dst_len = dst = 0x1234;
794 *(BYTE*)src = 0xab;
795 hr = IDataConvert_DataConvert(convert, DBTYPE_UI1, DBTYPE_I2, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
796 ok(hr == S_OK, "got %08x\n", hr);
797 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
798 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
799 ok(dst == 0xab, "got %08x\n", dst);
801 dst_len = dst = 0x1234;
802 *(WORD*)src = 0x4321;
803 hr = IDataConvert_DataConvert(convert, DBTYPE_UI2, DBTYPE_I2, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
804 ok(hr == S_OK, "got %08x\n", hr);
805 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
806 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
807 ok(dst == 0x4321, "got %08x\n", dst);
809 dst_len = dst = 0x1234;
810 *(WORD*)src = 0xabcd;
811 hr = IDataConvert_DataConvert(convert, DBTYPE_UI2, DBTYPE_I2, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
812 ok(hr == DB_E_ERRORSOCCURRED, "got %08x\n", hr);
813 ok(dst_status == DBSTATUS_E_DATAOVERFLOW, "got %08x\n", dst_status);
814 todo_wine
815 ok(broken(dst_len == sizeof(dst)) || dst_len == 0x1234 /* W2K+ */, "got %ld\n", dst_len);
816 ok(dst == 0x1234, "got %08x\n", dst);
818 dst_len = dst = 0x1234;
819 *(DWORD*)src = 0xabcd1234;
820 hr = IDataConvert_DataConvert(convert, DBTYPE_UI4, DBTYPE_I2, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
821 todo_wine
822 ok(hr == DB_E_DATAOVERFLOW, "got %08x\n", hr);
823 ok(dst_status == DBSTATUS_E_DATAOVERFLOW, "got %08x\n", dst_status);
824 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
825 ok(dst == 0x1234, "got %08x\n", dst);
827 dst_len = dst = 0x1234;
828 *(DWORD*)src = 0x1234abcd;
829 hr = IDataConvert_DataConvert(convert, DBTYPE_UI4, DBTYPE_I2, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
830 todo_wine
831 ok(hr == DB_E_DATAOVERFLOW, "got %08x\n", hr);
832 ok(dst_status == DBSTATUS_E_DATAOVERFLOW, "got %08x\n", dst_status);
833 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
834 ok(dst == 0x1234, "got %08x\n", dst);
836 dst_len = dst = 0x1234;
837 *(DWORD*)src = 0x4321;
838 hr = IDataConvert_DataConvert(convert, DBTYPE_UI4, DBTYPE_I2, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
839 ok(hr == S_OK, "got %08x\n", hr);
840 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
841 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
842 ok(dst == 0x4321, "got %08x\n", dst);
844 dst_len = dst = 0x1234;
845 ((LARGE_INTEGER*)src)->QuadPart = 0x1234abcd;
846 hr = IDataConvert_DataConvert(convert, DBTYPE_I8, DBTYPE_I2, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
847 ok(hr == DB_E_ERRORSOCCURRED ||
848 broken(hr == DB_E_UNSUPPORTEDCONVERSION), /* win98 */
849 "got %08x\n", hr);
850 if(hr != DB_E_UNSUPPORTEDCONVERSION) /* win98 doesn't support I8/UI8 */
852 ok(dst_status == DBSTATUS_E_DATAOVERFLOW, "got %08x\n", dst_status);
853 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
854 ok(dst == 0x1234, "got %08x\n", dst);
856 dst_len = dst = 0x1234;
857 ((LARGE_INTEGER*)src)->QuadPart = 0x4321;
858 hr = IDataConvert_DataConvert(convert, DBTYPE_I8, DBTYPE_I2, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
859 ok(hr == S_OK, "got %08x\n", hr);
860 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
861 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
862 ok(dst == 0x4321, "got %08x\n", dst);
864 dst_len = dst = 0x1234;
865 ((ULARGE_INTEGER*)src)->QuadPart = 0x4321;
866 hr = IDataConvert_DataConvert(convert, DBTYPE_UI8, DBTYPE_I2, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
867 ok(hr == S_OK, "got %08x\n", hr);
868 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
869 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
870 ok(dst == 0x4321, "got %08x\n", dst);
873 dst_len = dst = 0x1234;
874 strcpy((char *)src, "10");
875 hr = IDataConvert_DataConvert(convert, DBTYPE_STR, DBTYPE_I2, 2, &dst_len, src, &dst, sizeof(dst), 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(dst), "got %ld\n", dst_len);
879 ok(dst == 10, "got %08x\n", dst);
881 dst_len = dst = 0x1234;
882 strcpy((char *)src, "10");
883 hr = IDataConvert_DataConvert(convert, DBTYPE_STR, DBTYPE_I2, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, DBDATACONVERT_LENGTHFROMNTS);
884 ok(hr == S_OK, "got %08x\n", hr);
885 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
886 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
887 ok(dst == 10, "got %08x\n", dst);
889 dst_len = dst = 0x1234;
890 memcpy(src, ten, sizeof(ten));
891 hr = IDataConvert_DataConvert(convert, DBTYPE_WSTR, DBTYPE_I2, 4, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
892 ok(hr == S_OK, "got %08x\n", hr);
893 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
894 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
895 ok(dst == 10, "got %08x\n", dst);
897 dst_len = dst = 0x1234;
898 memcpy(src, ten, sizeof(ten));
899 hr = IDataConvert_DataConvert(convert, DBTYPE_WSTR, DBTYPE_I2, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, DBDATACONVERT_LENGTHFROMNTS);
900 ok(hr == S_OK, "got %08x\n", hr);
901 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
902 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
903 ok(dst == 10, "got %08x\n", dst);
905 /* */
906 dst_len = dst = 0x1234;
907 *(WORD*)src = 0x4321;
908 hr = IDataConvert_DataConvert(convert, DBTYPE_UI2, DBTYPE_UI2, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
909 ok(hr == S_OK, "got %08x\n", hr);
910 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
911 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
912 ok(dst == 0x4321, "got %08x\n", dst);
914 dst_len = dst = 0x1234;
915 *(DWORD*)src = 0xabcd1234;
916 hr = IDataConvert_DataConvert(convert, DBTYPE_UI4, DBTYPE_UI2, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
917 todo_wine
918 ok(hr == DB_E_DATAOVERFLOW, "got %08x\n", hr);
919 ok(dst_status == DBSTATUS_E_DATAOVERFLOW, "got %08x\n", dst_status);
920 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
921 ok(dst == 0x1234, "got %08x\n", dst);
923 dst_len = dst = 0x1234;
924 *(DWORD*)src = 0x1234abcd;
925 hr = IDataConvert_DataConvert(convert, DBTYPE_UI4, DBTYPE_UI2, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
926 todo_wine
927 ok(hr == DB_E_DATAOVERFLOW, "got %08x\n", hr);
928 ok(dst_status == DBSTATUS_E_DATAOVERFLOW, "got %08x\n", dst_status);
929 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
930 ok(dst == 0x1234, "got %08x\n", dst);
932 dst_len = dst = 0x1234;
933 *(DWORD*)src = 0x4321;
934 hr = IDataConvert_DataConvert(convert, DBTYPE_UI4, DBTYPE_UI2, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
935 ok(hr == S_OK, "got %08x\n", hr);
936 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
937 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
938 ok(dst == 0x4321, "got %08x\n", dst);
940 dst_len = dst = 0x1234;
941 memcpy(src, ten, sizeof(ten));
942 hr = IDataConvert_DataConvert(convert, DBTYPE_WSTR, DBTYPE_UI2, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, DBDATACONVERT_LENGTHFROMNTS);
943 ok(hr == S_OK, "got %08x\n", hr);
944 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
945 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
946 ok(dst == 10, "got %08x\n", dst);
949 static void test_converttoi4(void)
951 HRESULT hr;
952 INT i4;
953 BYTE src[20];
954 DBSTATUS dst_status;
955 DBLENGTH dst_len;
956 static const WCHAR ten[] = {'1','0',0};
957 BSTR b;
959 i4 = 0x12345678;
960 dst_len = 0x1234;
961 hr = IDataConvert_DataConvert(convert, DBTYPE_EMPTY, DBTYPE_I4, 0, &dst_len, src, &i4, sizeof(i4), 0, &dst_status, 0, 0, 0);
962 ok(hr == S_OK, "got %08x\n", hr);
963 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
964 ok(dst_len == sizeof(i4), "got %ld\n", dst_len);
965 ok(i4 == 0, "got %08x\n", i4);
967 i4 = 0x12345678;
968 dst_len = 0x1234;
969 hr = IDataConvert_DataConvert(convert, DBTYPE_NULL, DBTYPE_I4, 0, &dst_len, src, &i4, sizeof(i4), 0, &dst_status, 0, 0, 0);
970 ok(hr == DB_E_UNSUPPORTEDCONVERSION, "got %08x\n", hr);
971 ok(dst_status == DBSTATUS_E_BADACCESSOR, "got %08x\n", dst_status);
972 ok(dst_len == 0x1234, "got %ld\n", dst_len);
973 ok(i4 == 0x12345678, "got %08x\n", i4);
975 i4 = 0x12345678;
976 *(short *)src = 0x4321;
977 dst_len = 0x1234;
978 hr = IDataConvert_DataConvert(convert, DBTYPE_I2, DBTYPE_I4, 0, &dst_len, src, &i4, sizeof(i4), 0, &dst_status, 0, 0, 0);
979 ok(hr == S_OK, "got %08x\n", hr);
980 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
981 ok(dst_len == sizeof(i4), "got %ld\n", dst_len);
982 ok(i4 == 0x4321, "got %08x\n", i4);
984 i4 = 0x12345678;
985 *(int *)src = 0x4321cafe;
986 dst_len = 0x1234;
987 hr = IDataConvert_DataConvert(convert, DBTYPE_I4, DBTYPE_I4, 0, &dst_len, src, &i4, sizeof(i4), 0, &dst_status, 0, 0, 0);
988 ok(hr == S_OK, "got %08x\n", hr);
989 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
990 ok(dst_len == sizeof(i4), "got %ld\n", dst_len);
991 ok(i4 == 0x4321cafe, "got %08x\n", i4);
993 i4 = 0x12345678;
994 *(FLOAT *)src = 10.75;
995 hr = IDataConvert_DataConvert(convert, DBTYPE_R4, DBTYPE_I4, 0, &dst_len, src, &i4, sizeof(i4), 0, &dst_status, 0, 0, 0);
996 ok(hr == S_OK, "got %08x\n", hr);
997 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
998 ok(dst_len == sizeof(i4), "got %ld\n", dst_len);
999 ok(i4 == 11, "got %08x\n", i4);
1001 i4 = 0x12345678;
1002 *(FLOAT *)src = -10.75;
1003 dst_len = 0x1234;
1004 hr = IDataConvert_DataConvert(convert, DBTYPE_R4, DBTYPE_I4, 0, &dst_len, src, &i4, sizeof(i4), 0, &dst_status, 0, 0, 0);
1005 ok(hr == S_OK, "got %08x\n", hr);
1006 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
1007 ok(dst_len == sizeof(i4), "got %ld\n", dst_len);
1008 ok(i4 == -11, "got %08x\n", i4);
1010 i4 = 0x12345678;
1011 *(double *)src = 10.75;
1012 dst_len = 0x1234;
1013 hr = IDataConvert_DataConvert(convert, DBTYPE_R8, DBTYPE_I4, 0, &dst_len, src, &i4, sizeof(i4), 0, &dst_status, 0, 0, 0);
1014 ok(hr == S_OK, "got %08x\n", hr);
1015 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
1016 ok(dst_len == sizeof(i4), "got %ld\n", dst_len);
1017 ok(i4 == 11, "got %08x\n", i4);
1019 i4 = 0x12345678;
1020 ((LARGE_INTEGER *)src)->QuadPart = 107500;
1021 dst_len = 0x1234;
1022 hr = IDataConvert_DataConvert(convert, DBTYPE_CY, DBTYPE_I4, 0, &dst_len, src, &i4, sizeof(i4), 0, &dst_status, 0, 0, 0);
1023 ok(hr == S_OK, "got %08x\n", hr);
1024 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
1025 ok(dst_len == sizeof(i4), "got %ld\n", dst_len);
1026 ok(i4 == 11, "got %08x\n", i4);
1028 i4 = 0x12345678;
1029 *(DATE *)src = 10.7500;
1030 dst_len = 0x1234;
1031 hr = IDataConvert_DataConvert(convert, DBTYPE_DATE, DBTYPE_I4, 0, &dst_len, src, &i4, sizeof(i4), 0, &dst_status, 0, 0, 0);
1032 ok(hr == S_OK, "got %08x\n", hr);
1033 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
1034 ok(dst_len == sizeof(i4), "got %ld\n", dst_len);
1035 ok(i4 == 11, "got %08x\n", i4);
1037 i4 = 0x12345678;
1038 b = SysAllocString(ten);
1039 *(BSTR *)src = b;
1040 dst_len = 0x1234;
1041 hr = IDataConvert_DataConvert(convert, DBTYPE_BSTR, DBTYPE_I4, 0, &dst_len, src, &i4, sizeof(i4), 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 == sizeof(i4), "got %ld\n", dst_len);
1045 ok(i4 == 10, "got %08x\n", i4);
1046 SysFreeString(b);
1048 i4 = 0x12345678;
1049 *(SCODE *)src = 0x4321cafe;
1050 dst_len = 0x1234;
1051 hr = IDataConvert_DataConvert(convert, DBTYPE_ERROR, DBTYPE_I4, 0, &dst_len, src, &i4, sizeof(i4), 0, &dst_status, 0, 0, 0);
1052 ok(hr == DB_E_UNSUPPORTEDCONVERSION, "got %08x\n", hr);
1053 ok(dst_status == DBSTATUS_E_BADACCESSOR, "got %08x\n", dst_status);
1054 ok(dst_len == 0x1234, "got %ld\n", dst_len);
1055 ok(i4 == 0x12345678, "got %08x\n", i4);
1057 i4 = 0x12345678;
1058 *(VARIANT_BOOL *)src = VARIANT_TRUE;
1059 dst_len = 0x1234;
1060 hr = IDataConvert_DataConvert(convert, DBTYPE_BOOL, DBTYPE_I4, 0, &dst_len, src, &i4, sizeof(i4), 0, &dst_status, 0, 0, 0);
1061 ok(hr == S_OK, "got %08x\n", hr);
1062 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
1063 ok(dst_len == sizeof(i4), "got %ld\n", dst_len);
1064 ok(i4 == 0xffffffff, "got %08x\n", i4);
1066 i4 = 0x12345678;
1067 *(VARIANT_BOOL *)src = VARIANT_FALSE;
1068 dst_len = 0x1234;
1069 hr = IDataConvert_DataConvert(convert, DBTYPE_BOOL, DBTYPE_I4, 0, &dst_len, src, &i4, sizeof(i4), 0, &dst_status, 0, 0, 0);
1070 ok(hr == S_OK, "got %08x\n", hr);
1071 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
1072 ok(dst_len == sizeof(i4), "got %ld\n", dst_len);
1073 ok(i4 == 0, "got %08x\n", i4);
1075 i4 = 0x12345678;
1076 V_VT((VARIANT*)src) = VT_I2;
1077 V_I2((VARIANT*)src) = 0x1234;
1078 dst_len = 0x1234;
1079 hr = IDataConvert_DataConvert(convert, DBTYPE_VARIANT, DBTYPE_I4, 0, &dst_len, src, &i4, sizeof(i4), 0, &dst_status, 0, 0, 0);
1080 ok(hr == S_OK, "got %08x\n", hr);
1081 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
1082 ok(dst_len == sizeof(i4), "got %ld\n", dst_len);
1083 ok(i4 == 0x1234, "got %08x\n", i4);
1085 V_VT((VARIANT*)src) = VT_NULL;
1086 dst_len = 0x1234;
1087 hr = IDataConvert_DataConvert(convert, DBTYPE_VARIANT, DBTYPE_I4, 0, &dst_len, src, &i4, sizeof(i4), 0, &dst_status, 0, 0, 0);
1088 ok(hr == S_OK, "got %08x\n", hr);
1089 ok(dst_status == DBSTATUS_S_ISNULL, "got %08x\n", dst_status);
1090 ok(dst_len == 0x1234, "got %ld\n", dst_len);
1092 i4 = 0x12345678;
1093 memset(src, 0, sizeof(DECIMAL));
1094 ((DECIMAL*)src)->u1.Lo64 = 0x1234;
1095 dst_len = 0x1234;
1096 hr = IDataConvert_DataConvert(convert, DBTYPE_DECIMAL, DBTYPE_I4, 0, &dst_len, src, &i4, sizeof(i4), 0, &dst_status, 0, 0, 0);
1097 ok(hr == S_OK, "got %08x\n", hr);
1098 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
1099 ok(dst_len == sizeof(i4), "got %ld\n", dst_len);
1100 ok(i4 == 0x1234, "got %08x\n", i4);
1102 i4 = 0x12345678;
1103 *(signed char*)src = 0xab;
1104 dst_len = 0x1234;
1105 hr = IDataConvert_DataConvert(convert, DBTYPE_I1, DBTYPE_I4, 0, &dst_len, src, &i4, sizeof(i4), 0, &dst_status, 0, 0, 0);
1106 ok(hr == S_OK, "got %08x\n", hr);
1107 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
1108 ok(dst_len == sizeof(i4), "got %ld\n", dst_len);
1109 ok(i4 == 0xffffffab, "got %08x\n", i4);
1111 i4 = 0x12345678;
1112 *(BYTE*)src = 0xab;
1113 dst_len = 0x1234;
1114 hr = IDataConvert_DataConvert(convert, DBTYPE_UI1, DBTYPE_I4, 0, &dst_len, src, &i4, sizeof(i4), 0, &dst_status, 0, 0, 0);
1115 ok(hr == S_OK, "got %08x\n", hr);
1116 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
1117 ok(dst_len == sizeof(i4), "got %ld\n", dst_len);
1118 ok(i4 == 0xab, "got %08x\n", i4);
1120 i4 = 0x12345678;
1121 *(WORD*)src = 0xabcd;
1122 dst_len = 0x1234;
1123 hr = IDataConvert_DataConvert(convert, DBTYPE_UI2, DBTYPE_I4, 0, &dst_len, src, &i4, sizeof(i4), 0, &dst_status, 0, 0, 0);
1124 ok(hr == S_OK, "got %08x\n", hr);
1125 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
1126 ok(dst_len == sizeof(i4), "got %ld\n", dst_len);
1127 ok(i4 == 0xabcd, "got %08x\n", i4);
1129 i4 = 0x12345678;
1130 *(DWORD*)src = 0xabcd1234;
1131 dst_len = 0x1234;
1132 hr = IDataConvert_DataConvert(convert, DBTYPE_UI4, DBTYPE_I4, 0, &dst_len, src, &i4, sizeof(i4), 0, &dst_status, 0, 0, 0);
1133 ok(hr == DB_E_ERRORSOCCURRED, "got %08x\n", hr);
1134 ok(dst_status == DBSTATUS_E_DATAOVERFLOW, "got %08x\n", dst_status);
1135 todo_wine
1136 ok(broken(dst_len == sizeof(i4)) || dst_len == 0x1234 /* W2K+ */, "got %ld\n", dst_len);
1137 ok(i4 == 0x12345678, "got %08x\n", i4);
1139 i4 = 0x12345678;
1140 *(DWORD*)src = 0x1234abcd;
1141 dst_len = 0x1234;
1142 hr = IDataConvert_DataConvert(convert, DBTYPE_UI4, DBTYPE_I4, 0, &dst_len, src, &i4, sizeof(i4), 0, &dst_status, 0, 0, 0);
1143 ok(hr == S_OK, "got %08x\n", hr);
1144 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
1145 ok(dst_len == sizeof(i4), "got %ld\n", dst_len);
1146 ok(i4 == 0x1234abcd, "got %08x\n", i4);
1148 i4 = 0x12345678;
1149 ((LARGE_INTEGER*)src)->QuadPart = 0x1234abcd;
1150 dst_len = 0x1234;
1151 hr = IDataConvert_DataConvert(convert, DBTYPE_I8, DBTYPE_I4, 0, &dst_len, src, &i4, sizeof(i4), 0, &dst_status, 0, 0, 0);
1152 ok(hr == S_OK ||
1153 broken(hr == DB_E_UNSUPPORTEDCONVERSION), /* win98 */
1154 "got %08x\n", hr);
1155 if(hr != DB_E_UNSUPPORTEDCONVERSION) /* win98 doesn't support I8/UI8 */
1157 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
1158 ok(dst_len == sizeof(i4), "got %ld\n", dst_len);
1159 ok(i4 == 0x1234abcd, "got %08x\n", i4);
1161 i4 = 0x12345678;
1162 ((ULARGE_INTEGER*)src)->QuadPart = 0x1234abcd;
1163 dst_len = 0x1234;
1164 hr = IDataConvert_DataConvert(convert, DBTYPE_UI8, DBTYPE_I4, 0, &dst_len, src, &i4, sizeof(i4), 0, &dst_status, 0, 0, 0);
1165 ok(hr == S_OK, "got %08x\n", hr);
1166 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
1167 ok(dst_len == sizeof(i4), "got %ld\n", dst_len);
1168 ok(i4 == 0x1234abcd, "got %08x\n", i4);
1171 i4 = 0x12345678;
1172 strcpy((char *)src, "10");
1173 dst_len = 0x1234;
1174 hr = IDataConvert_DataConvert(convert, DBTYPE_STR, DBTYPE_I4, 2, &dst_len, src, &i4, sizeof(i4), 0, &dst_status, 0, 0, 0);
1175 ok(hr == S_OK, "got %08x\n", hr);
1176 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
1177 ok(dst_len == sizeof(i4), "got %ld\n", dst_len);
1178 ok(i4 == 10, "got %08x\n", i4);
1180 i4 = 0x12345678;
1181 strcpy((char *)src, "10");
1182 dst_len = 0x1234;
1183 hr = IDataConvert_DataConvert(convert, DBTYPE_STR, DBTYPE_I4, 0, &dst_len, src, &i4, sizeof(i4), 0, &dst_status, 0, 0, DBDATACONVERT_LENGTHFROMNTS);
1184 ok(hr == S_OK, "got %08x\n", hr);
1185 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
1186 ok(dst_len == sizeof(i4), "got %ld\n", dst_len);
1187 ok(i4 == 10, "got %08x\n", i4);
1189 i4 = 0x12345678;
1190 memcpy(src, ten, sizeof(ten));
1191 dst_len = 0x1234;
1192 hr = IDataConvert_DataConvert(convert, DBTYPE_WSTR, DBTYPE_I4, 4, &dst_len, src, &i4, sizeof(i4), 0, &dst_status, 0, 0, 0);
1193 ok(hr == S_OK, "got %08x\n", hr);
1194 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
1195 ok(dst_len == sizeof(i4), "got %ld\n", dst_len);
1196 ok(i4 == 10, "got %08x\n", i4);
1198 i4 = 0x12345678;
1199 memcpy(src, ten, sizeof(ten));
1200 dst_len = 0x1234;
1201 hr = IDataConvert_DataConvert(convert, DBTYPE_WSTR, DBTYPE_I4, 0, &dst_len, src, &i4, sizeof(i4), 0, &dst_status, 0, 0, DBDATACONVERT_LENGTHFROMNTS);
1202 ok(hr == S_OK, "got %08x\n", hr);
1203 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
1204 ok(dst_len == sizeof(i4), "got %ld\n", dst_len);
1205 ok(i4 == 10, "got %08x\n", i4);
1207 /* src_status = DBSTATUS_S_ISNULL */
1208 i4 = 0x12345678;
1209 hr = IDataConvert_DataConvert(convert, DBTYPE_I4, DBTYPE_I4, 0, &dst_len, src, &i4, sizeof(i4), DBSTATUS_S_ISNULL, &dst_status, 0, 0, 0);
1210 ok(hr == S_OK, "got %08x\n", hr);
1211 ok(dst_status == DBSTATUS_S_ISNULL, "got %08x\n", dst_status);
1212 ok(dst_len == 0, "got %ld\n", dst_len);
1214 /* dst = NULL */
1215 *(int *)src = 0x4321cafe;
1216 dst_len = 0x1234;
1217 hr = IDataConvert_DataConvert(convert, DBTYPE_I4, DBTYPE_I4, 0, &dst_len, src, NULL, 0, 0, NULL, 0, 0, 0);
1218 ok(hr == S_OK, "got %08x\n", hr);
1219 ok(dst_len == sizeof(i4), "got %ld\n", dst_len);
1223 static void test_converttoi8(void)
1225 HRESULT hr;
1226 LARGE_INTEGER dst;
1227 BYTE src[20];
1228 DBSTATUS dst_status;
1229 DBLENGTH dst_len;
1230 static const WCHAR ten[] = {'1','0',0};
1231 BSTR b;
1233 dst.QuadPart = 0xcc;
1234 ((ULARGE_INTEGER*)src)->QuadPart = 1234;
1235 dst_len = 0x1234;
1236 hr = IDataConvert_DataConvert(convert, DBTYPE_I8, DBTYPE_I8, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
1237 ok(hr == S_OK, "got %08x\n", hr);
1238 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
1239 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
1240 ok(dst.QuadPart == 1234, "got %d\n", (int)dst.QuadPart);
1242 dst.QuadPart = 0xcc;
1243 ((ULARGE_INTEGER*)src)->QuadPart = 1234;
1244 b = SysAllocString(ten);
1245 *(BSTR *)src = b;
1246 hr = IDataConvert_DataConvert(convert, DBTYPE_BSTR, DBTYPE_I8, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
1247 ok(hr == S_OK, "got %08x\n", hr);
1248 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
1249 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
1250 ok(dst.QuadPart == 10, "got %d\n", (int)dst.QuadPart);
1251 SysFreeString(b);
1253 V_VT((VARIANT*)src) = VT_NULL;
1254 dst_len = 0x1234;
1255 hr = IDataConvert_DataConvert(convert, DBTYPE_VARIANT, DBTYPE_I8, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
1256 ok(hr == S_OK, "got %08x\n", hr);
1257 ok(dst_status == DBSTATUS_S_ISNULL, "got %08x\n", dst_status);
1258 ok(dst_len == 0x1234, "got %ld\n", dst_len);
1261 static void test_converttobstr(void)
1263 HRESULT hr;
1264 BSTR dst;
1265 BYTE src[20];
1266 DBSTATUS dst_status;
1267 DBLENGTH dst_len;
1268 static const WCHAR ten[] = {'1','0',0};
1269 static const WCHAR tsW[] = {'2','0','1','3','-','0','5','-','1','4',' ','0','2',':','0','4',':','1','2',0};
1270 static const WCHAR ts1W[] = {'2','0','1','3','-','0','5','-','1','4',' ','0','2',':','0','4',':','1','2','.','0','0','0','0','0','0','0','0','3',0};
1271 static const WCHAR ts2W[] = {'2','0','1','3','-','0','5','-','1','4',' ','0','2',':','0','4',':','1','2','.','0','0','0','0','0','0','2','0','0',0};
1272 DBTIMESTAMP ts = {2013, 5, 14, 2, 4, 12, 0};
1273 VARIANT v;
1274 BSTR b;
1276 dst_len = 0x1234;
1277 hr = IDataConvert_DataConvert(convert, DBTYPE_EMPTY, DBTYPE_BSTR, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
1278 ok(hr == S_OK, "got %08x\n", hr);
1279 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
1280 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
1281 ok(dst != NULL, "got %p\n", dst);
1282 ok(SysStringLen(dst) == 0, "got %d\n", SysStringLen(dst));
1283 SysFreeString(dst);
1285 dst = (void*)0x1234;
1286 hr = IDataConvert_DataConvert(convert, DBTYPE_NULL, DBTYPE_BSTR, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
1287 ok(hr == DB_E_UNSUPPORTEDCONVERSION, "got %08x\n", hr);
1288 ok(dst_status == DBSTATUS_E_BADACCESSOR, "got %08x\n", dst_status);
1289 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
1290 ok(dst == (void*)0x1234, "got %p\n", dst);
1292 *(short *)src = 4321;
1293 hr = IDataConvert_DataConvert(convert, DBTYPE_I2, DBTYPE_BSTR, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
1294 ok(hr == S_OK, "got %08x\n", hr);
1295 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
1296 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
1297 ok(dst != NULL, "got %p\n", dst);
1298 ok(SysStringLen(dst) == 4, "got %d\n", SysStringLen(dst));
1299 SysFreeString(dst);
1301 b = SysAllocString(ten);
1302 *(BSTR *)src = b;
1303 hr = IDataConvert_DataConvert(convert, DBTYPE_BSTR, DBTYPE_BSTR, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
1304 ok(hr == S_OK, "got %08x\n", hr);
1305 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
1306 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
1307 ok(dst != NULL, "got %p\n", dst);
1308 ok(dst != b, "got %p src %p\n", dst, b);
1309 ok(!lstrcmpW(b, dst), "got %s\n", wine_dbgstr_w(dst));
1310 SysFreeString(dst);
1311 SysFreeString(b);
1313 b = SysAllocString(ten);
1314 V_VT(&v) = VT_BSTR;
1315 V_BSTR(&v) = b;
1316 hr = IDataConvert_DataConvert(convert, DBTYPE_VARIANT, DBTYPE_BSTR, 0, &dst_len, &v, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
1317 ok(hr == S_OK, "got %08x\n", hr);
1318 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
1319 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
1320 ok(dst != NULL, "got %p\n", dst);
1321 ok(dst != b, "got %p src %p\n", dst, b);
1322 ok(!lstrcmpW(b, dst), "got %s\n", wine_dbgstr_w(dst));
1323 SysFreeString(dst);
1324 SysFreeString(b);
1326 V_VT(&v) = VT_NULL;
1327 dst = (void*)0x1234;
1328 dst_len = 33;
1329 hr = IDataConvert_DataConvert(convert, DBTYPE_VARIANT, DBTYPE_BSTR, 0, &dst_len, &v, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
1330 ok(hr == S_OK, "got %08x\n", hr);
1331 ok(dst_status == DBSTATUS_S_ISNULL, "got %08x\n", dst_status);
1332 ok(dst_len == 33, "got %ld\n", dst_len);
1333 ok(dst == (void*)0x1234, "got %p\n", dst);
1335 dst_len = 0x1234;
1336 hr = IDataConvert_DataConvert(convert, DBTYPE_DBTIMESTAMP, DBTYPE_BSTR, 0, &dst_len, &ts, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
1337 ok(hr == S_OK, "got %08x\n", hr);
1338 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
1339 ok(dst_len == sizeof(BSTR), "got %ld\n", dst_len);
1340 ok(!lstrcmpW(tsW, dst), "got %s\n", wine_dbgstr_w(dst));
1341 SysFreeString(dst);
1343 dst_len = 0x1234;
1344 ts.fraction = 3;
1345 hr = IDataConvert_DataConvert(convert, DBTYPE_DBTIMESTAMP, DBTYPE_BSTR, 0, &dst_len, &ts, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
1346 ok(hr == S_OK, "got %08x\n", hr);
1347 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
1348 ok(dst_len == sizeof(BSTR), "got %ld\n", dst_len);
1349 ok(!lstrcmpW(ts1W, dst), "got %s\n", wine_dbgstr_w(dst));
1350 SysFreeString(dst);
1352 dst_len = 0x1234;
1353 ts.fraction = 200;
1354 hr = IDataConvert_DataConvert(convert, DBTYPE_DBTIMESTAMP, DBTYPE_BSTR, 0, &dst_len, &ts, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
1355 ok(hr == S_OK, "got %08x\n", hr);
1356 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
1357 ok(dst_len == sizeof(BSTR), "got %ld\n", dst_len);
1358 ok(!lstrcmpW(ts2W, dst), "got %s\n", wine_dbgstr_w(dst));
1359 SysFreeString(dst);
1362 static void test_converttowstr(void)
1364 HRESULT hr;
1365 WCHAR dst[100];
1366 BYTE src[20];
1367 DBSTATUS dst_status;
1368 DBLENGTH dst_len;
1369 static const WCHAR ten[] = {'1','0',0};
1370 static const WCHAR fourthreetwoone[] = {'4','3','2','1',0};
1371 static const WCHAR guid_str[] = {
1372 '{','0','C','7','3','3','A','8','D','-','2','A','1','C','-','1','1','C','E','-',
1373 'A','D','E','5','-','0','0','A','A','0','0','4','4','7','7','3','D','}',0};
1374 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 };
1375 static const WCHAR hexpacked_w[] = {'W','i','n','e', 0 };
1376 static const WCHAR tsW[] = {'2','0','1','3','-','0','5','-','1','4',' ','0','2',':','0','4',':','1','2',0};
1377 static const WCHAR ts1W[] = {'2','0','1','3','-','0','5','-','1','4',' ','0','2',':','0','4',':','1','2','.','0','0','0','0','0','0','0','0','3',0};
1378 static const WCHAR ts2W[] = {'2','0','1','3','-','0','5','-','1','4',' ','0','2',':','0','4',':','1','2','.','0','0','0','0','0','0','2','0','0',0};
1379 DBTIMESTAMP ts = {2013, 5, 14, 2, 4, 12, 0};
1380 BSTR b;
1381 VARIANT v;
1383 VariantInit(&v);
1385 memset(dst, 0xcc, sizeof(dst));
1386 dst_len = 0x1234;
1387 hr = IDataConvert_DataConvert(convert, DBTYPE_EMPTY, DBTYPE_WSTR, 0, &dst_len, src, dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
1388 ok(hr == S_OK, "got %08x\n", hr);
1389 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
1390 ok(dst_len == 0, "got %ld\n", dst_len);
1391 ok(dst[0] == 0, "got %02x\n", dst[0]);
1392 ok(dst[1] == 0xcccc, "got %02x\n", dst[1]);
1394 memset(dst, 0xcc, sizeof(dst));
1395 dst_len = 0x1234;
1396 hr = IDataConvert_DataConvert(convert, DBTYPE_NULL, DBTYPE_WSTR, 0, &dst_len, src, dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
1397 ok(hr == DB_E_UNSUPPORTEDCONVERSION, "got %08x\n", hr);
1398 ok(dst_status == DBSTATUS_E_BADACCESSOR, "got %08x\n", dst_status);
1399 ok(dst_len == 0x1234, "got %ld\n", dst_len);
1400 ok(dst[0] == 0xcccc, "got %02x\n", dst[0]);
1402 *(short *)src = 4321;
1403 dst_len = 0x1234;
1404 hr = IDataConvert_DataConvert(convert, DBTYPE_I2, DBTYPE_WSTR, 0, &dst_len, src, dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
1405 ok(hr == S_OK, "got %08x\n", hr);
1406 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
1407 ok(dst_len == 8, "got %ld\n", dst_len);
1408 ok(!lstrcmpW(dst, fourthreetwoone), "got %s\n", wine_dbgstr_w(dst));
1410 *(short *)src = 4321;
1411 memset(dst, 0xcc, sizeof(dst));
1412 dst_len = 0x1234;
1413 hr = IDataConvert_DataConvert(convert, DBTYPE_I2, DBTYPE_WSTR, 0, &dst_len, src, dst, 0, 0, &dst_status, 0, 0, 0);
1414 ok(hr == DB_E_ERRORSOCCURRED, "got %08x\n", hr);
1415 ok(dst_status == DBSTATUS_E_DATAOVERFLOW, "got %08x\n", dst_status);
1416 ok(dst_len == 8, "got %ld\n", dst_len);
1417 ok(dst[0] == 0xcccc, "got %02x\n", dst[0]);
1419 *(short *)src = 4321;
1420 memset(dst, 0xcc, sizeof(dst));
1421 dst_len = 0x1234;
1422 hr = IDataConvert_DataConvert(convert, DBTYPE_I2, DBTYPE_WSTR, 0, &dst_len, src, NULL, 0, 0, &dst_status, 0, 0, 0);
1423 ok(hr == S_OK, "got %08x\n", hr);
1424 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
1425 ok(dst_len == 8, "got %ld\n", dst_len);
1426 ok(dst[0] == 0xcccc, "got %02x\n", dst[0]);
1428 *(short *)src = 4321;
1429 memset(dst, 0xcc, sizeof(dst));
1430 dst_len = 0x1234;
1431 hr = IDataConvert_DataConvert(convert, DBTYPE_I2, DBTYPE_WSTR, 0, &dst_len, src, dst, 4, 0, &dst_status, 0, 0, 0);
1432 ok(hr == S_OK, "got %08x\n", hr);
1433 ok(dst_status == DBSTATUS_S_TRUNCATED, "got %08x\n", dst_status);
1434 ok(dst_len == 8, "got %ld\n", dst_len);
1435 ok(dst[0] == '4', "got %02x\n", dst[0]);
1436 ok(dst[1] == 0, "got %02x\n", dst[1]);
1437 ok(dst[2] == 0xcccc, "got %02x\n", dst[2]);
1439 *(short *)src = 4321;
1440 memset(dst, 0xcc, sizeof(dst));
1441 dst_len = 0x1234;
1442 hr = IDataConvert_DataConvert(convert, DBTYPE_I2, DBTYPE_WSTR, 0, &dst_len, src, dst, 2, 0, &dst_status, 0, 0, 0);
1443 ok(hr == S_OK, "got %08x\n", hr);
1444 ok(dst_status == DBSTATUS_S_TRUNCATED, "got %08x\n", dst_status);
1445 ok(dst_len == 8, "got %ld\n", dst_len);
1446 ok(dst[0] == 0, "got %02x\n", dst[0]);
1447 ok(dst[1] == 0xcccc, "got %02x\n", dst[1]);
1449 *(short *)src = 4321;
1450 memset(dst, 0xcc, sizeof(dst));
1451 dst_len = 0x1234;
1452 hr = IDataConvert_DataConvert(convert, DBTYPE_I2, DBTYPE_WSTR, 0, &dst_len, src, dst, 8, 0, &dst_status, 0, 0, 0);
1453 ok(hr == S_OK, "got %08x\n", hr);
1454 ok(dst_status == DBSTATUS_S_TRUNCATED, "got %08x\n", dst_status);
1455 ok(dst_len == 8, "got %ld\n", dst_len);
1456 ok(dst[0] == '4', "got %02x\n", dst[0]);
1457 ok(dst[1] == '3', "got %02x\n", dst[1]);
1458 ok(dst[2] == '2', "got %02x\n", dst[2]);
1459 ok(dst[3] == 0, "got %02x\n", dst[3]);
1460 ok(dst[4] == 0xcccc, "got %02x\n", dst[4]);
1464 *(int *)src = 4321;
1465 dst_len = 0x1234;
1466 hr = IDataConvert_DataConvert(convert, DBTYPE_I4, DBTYPE_WSTR, 0, &dst_len, src, dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
1467 ok(hr == S_OK, "got %08x\n", hr);
1468 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
1469 ok(dst_len == 8, "got %ld\n", dst_len);
1470 ok(!lstrcmpW(dst, fourthreetwoone), "got %s\n", wine_dbgstr_w(dst));
1472 *(int *)src = 4321;
1473 memset(dst, 0xcc, sizeof(dst));
1474 dst_len = 0x1234;
1475 hr = IDataConvert_DataConvert(convert, DBTYPE_I4, DBTYPE_WSTR, 0, &dst_len, src, dst, 0, 0, &dst_status, 0, 0, 0);
1476 ok(hr == DB_E_ERRORSOCCURRED, "got %08x\n", hr);
1477 ok(dst_status == DBSTATUS_E_DATAOVERFLOW, "got %08x\n", dst_status);
1478 ok(dst_len == 8, "got %ld\n", dst_len);
1479 ok(dst[0] == 0xcccc, "got %02x\n", dst[0]);
1481 *(int *)src = 4321;
1482 memset(dst, 0xcc, sizeof(dst));
1483 hr = IDataConvert_DataConvert(convert, DBTYPE_I4, DBTYPE_WSTR, 0, &dst_len, src, NULL, 0, 0, &dst_status, 0, 0, 0);
1484 ok(hr == S_OK, "got %08x\n", hr);
1485 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
1486 ok(dst_len == 8, "got %ld\n", dst_len);
1487 ok(dst[0] == 0xcccc, "got %02x\n", dst[0]);
1489 *(int *)src = 4321;
1490 memset(dst, 0xcc, sizeof(dst));
1491 dst_len = 0x1234;
1492 hr = IDataConvert_DataConvert(convert, DBTYPE_I4, DBTYPE_WSTR, 0, &dst_len, src, dst, 4, 0, &dst_status, 0, 0, 0);
1493 ok(hr == S_OK, "got %08x\n", hr);
1494 ok(dst_status == DBSTATUS_S_TRUNCATED, "got %08x\n", dst_status);
1495 ok(dst_len == 8, "got %ld\n", dst_len);
1496 ok(dst[0] == '4', "got %02x\n", dst[0]);
1497 ok(dst[1] == 0, "got %02x\n", dst[1]);
1498 ok(dst[2] == 0xcccc, "got %02x\n", dst[2]);
1500 *(int *)src = 4321;
1501 memset(dst, 0xcc, sizeof(dst));
1502 dst_len = 0x1234;
1503 hr = IDataConvert_DataConvert(convert, DBTYPE_I4, DBTYPE_WSTR, 0, &dst_len, src, dst, 2, 0, &dst_status, 0, 0, 0);
1504 ok(hr == S_OK, "got %08x\n", hr);
1505 ok(dst_status == DBSTATUS_S_TRUNCATED, "got %08x\n", dst_status);
1506 ok(dst_len == 8, "got %ld\n", dst_len);
1507 ok(dst[0] == 0, "got %02x\n", dst[0]);
1508 ok(dst[1] == 0xcccc, "got %02x\n", dst[1]);
1510 *(int *)src = 4321;
1511 memset(dst, 0xcc, sizeof(dst));
1512 dst_len = 0x1234;
1513 hr = IDataConvert_DataConvert(convert, DBTYPE_I4, DBTYPE_WSTR, 0, &dst_len, src, dst, 8, 0, &dst_status, 0, 0, 0);
1514 ok(hr == S_OK, "got %08x\n", hr);
1515 ok(dst_status == DBSTATUS_S_TRUNCATED, "got %08x\n", dst_status);
1516 ok(dst_len == 8, "got %ld\n", dst_len);
1517 ok(dst[0] == '4', "got %02x\n", dst[0]);
1518 ok(dst[1] == '3', "got %02x\n", dst[1]);
1519 ok(dst[2] == '2', "got %02x\n", dst[2]);
1520 ok(dst[3] == 0, "got %02x\n", dst[3]);
1521 ok(dst[4] == 0xcccc, "got %02x\n", dst[4]);
1525 *(float *)src = 4321;
1526 dst_len = 0x1234;
1527 hr = IDataConvert_DataConvert(convert, DBTYPE_R4, DBTYPE_WSTR, 0, &dst_len, src, dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
1528 ok(hr == S_OK, "got %08x\n", hr);
1529 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
1530 ok(dst_len == 8, "got %ld\n", dst_len);
1531 ok(!lstrcmpW(dst, fourthreetwoone), "got %s\n", wine_dbgstr_w(dst));
1533 *(float *)src = 4321;
1534 memset(dst, 0xcc, sizeof(dst));
1535 dst_len = 0x1234;
1536 hr = IDataConvert_DataConvert(convert, DBTYPE_R4, DBTYPE_WSTR, 0, &dst_len, src, dst, 0, 0, &dst_status, 0, 0, 0);
1537 ok(hr == DB_E_ERRORSOCCURRED, "got %08x\n", hr);
1538 ok(dst_status == DBSTATUS_E_DATAOVERFLOW, "got %08x\n", dst_status);
1539 ok(dst_len == 8, "got %ld\n", dst_len);
1540 ok(dst[0] == 0xcccc, "got %02x\n", dst[0]);
1542 *(float *)src = 4321;
1543 memset(dst, 0xcc, sizeof(dst));
1544 hr = IDataConvert_DataConvert(convert, DBTYPE_R4, DBTYPE_WSTR, 0, &dst_len, src, NULL, 0, 0, &dst_status, 0, 0, 0);
1545 ok(hr == S_OK, "got %08x\n", hr);
1546 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
1547 ok(dst_len == 8, "got %ld\n", dst_len);
1548 ok(dst[0] == 0xcccc, "got %02x\n", dst[0]);
1550 *(float *)src = 4321;
1551 memset(dst, 0xcc, sizeof(dst));
1552 dst_len = 0x1234;
1553 hr = IDataConvert_DataConvert(convert, DBTYPE_R4, DBTYPE_WSTR, 0, &dst_len, src, dst, 4, 0, &dst_status, 0, 0, 0);
1554 ok(hr == S_OK, "got %08x\n", hr);
1555 ok(dst_status == DBSTATUS_S_TRUNCATED, "got %08x\n", dst_status);
1556 ok(dst_len == 8, "got %ld\n", dst_len);
1557 ok(dst[0] == '4', "got %02x\n", dst[0]);
1558 ok(dst[1] == 0, "got %02x\n", dst[1]);
1559 ok(dst[2] == 0xcccc, "got %02x\n", dst[2]);
1561 *(float *)src = 4321;
1562 memset(dst, 0xcc, sizeof(dst));
1563 dst_len = 0x1234;
1564 hr = IDataConvert_DataConvert(convert, DBTYPE_R4, DBTYPE_WSTR, 0, &dst_len, src, dst, 2, 0, &dst_status, 0, 0, 0);
1565 ok(hr == S_OK, "got %08x\n", hr);
1566 ok(dst_status == DBSTATUS_S_TRUNCATED, "got %08x\n", dst_status);
1567 ok(dst_len == 8, "got %ld\n", dst_len);
1568 ok(dst[0] == 0, "got %02x\n", dst[0]);
1569 ok(dst[1] == 0xcccc, "got %02x\n", dst[1]);
1571 *(float *)src = 4321;
1572 memset(dst, 0xcc, sizeof(dst));
1573 dst_len = 0x1234;
1574 hr = IDataConvert_DataConvert(convert, DBTYPE_R4, DBTYPE_WSTR, 0, &dst_len, src, dst, 8, 0, &dst_status, 0, 0, 0);
1575 ok(hr == S_OK, "got %08x\n", hr);
1576 ok(dst_status == DBSTATUS_S_TRUNCATED, "got %08x\n", dst_status);
1577 ok(dst_len == 8, "got %ld\n", dst_len);
1578 ok(dst[0] == '4', "got %02x\n", dst[0]);
1579 ok(dst[1] == '3', "got %02x\n", dst[1]);
1580 ok(dst[2] == '2', "got %02x\n", dst[2]);
1581 ok(dst[3] == 0, "got %02x\n", dst[3]);
1582 ok(dst[4] == 0xcccc, "got %02x\n", dst[4]);
1586 *(double *)src = 4321;
1587 dst_len = 0x1234;
1588 hr = IDataConvert_DataConvert(convert, DBTYPE_R8, DBTYPE_WSTR, 0, &dst_len, src, dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
1589 ok(hr == S_OK, "got %08x\n", hr);
1590 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
1591 ok(dst_len == 8, "got %ld\n", dst_len);
1592 ok(!lstrcmpW(dst, fourthreetwoone), "got %s\n", wine_dbgstr_w(dst));
1594 *(double *)src = 4321;
1595 memset(dst, 0xcc, sizeof(dst));
1596 hr = IDataConvert_DataConvert(convert, DBTYPE_R8, DBTYPE_WSTR, 0, &dst_len, src, dst, 0, 0, &dst_status, 0, 0, 0);
1597 ok(hr == DB_E_ERRORSOCCURRED, "got %08x\n", hr);
1598 ok(dst_status == DBSTATUS_E_DATAOVERFLOW, "got %08x\n", dst_status);
1599 ok(dst_len == 8, "got %ld\n", dst_len);
1600 ok(dst[0] == 0xcccc, "got %02x\n", dst[0]);
1602 *(double *)src = 4321;
1603 memset(dst, 0xcc, sizeof(dst));
1604 dst_len = 0x1234;
1605 hr = IDataConvert_DataConvert(convert, DBTYPE_R8, DBTYPE_WSTR, 0, &dst_len, src, NULL, 0, 0, &dst_status, 0, 0, 0);
1606 ok(hr == S_OK, "got %08x\n", hr);
1607 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
1608 ok(dst_len == 8, "got %ld\n", dst_len);
1609 ok(dst[0] == 0xcccc, "got %02x\n", dst[0]);
1611 *(double *)src = 4321;
1612 memset(dst, 0xcc, sizeof(dst));
1613 dst_len = 0x1234;
1614 hr = IDataConvert_DataConvert(convert, DBTYPE_R8, DBTYPE_WSTR, 0, &dst_len, src, dst, 4, 0, &dst_status, 0, 0, 0);
1615 ok(hr == S_OK, "got %08x\n", hr);
1616 ok(dst_status == DBSTATUS_S_TRUNCATED, "got %08x\n", dst_status);
1617 ok(dst_len == 8, "got %ld\n", dst_len);
1618 ok(dst[0] == '4', "got %02x\n", dst[0]);
1619 ok(dst[1] == 0, "got %02x\n", dst[1]);
1620 ok(dst[2] == 0xcccc, "got %02x\n", dst[2]);
1622 *(double *)src = 4321;
1623 memset(dst, 0xcc, sizeof(dst));
1624 dst_len = 0x1234;
1625 hr = IDataConvert_DataConvert(convert, DBTYPE_R8, DBTYPE_WSTR, 0, &dst_len, src, dst, 2, 0, &dst_status, 0, 0, 0);
1626 ok(hr == S_OK, "got %08x\n", hr);
1627 ok(dst_status == DBSTATUS_S_TRUNCATED, "got %08x\n", dst_status);
1628 ok(dst_len == 8, "got %ld\n", dst_len);
1629 ok(dst[0] == 0, "got %02x\n", dst[0]);
1630 ok(dst[1] == 0xcccc, "got %02x\n", dst[1]);
1632 *(double *)src = 4321;
1633 memset(dst, 0xcc, sizeof(dst));
1634 dst_len = 0x1234;
1635 hr = IDataConvert_DataConvert(convert, DBTYPE_R8, DBTYPE_WSTR, 0, &dst_len, src, dst, 8, 0, &dst_status, 0, 0, 0);
1636 ok(hr == S_OK, "got %08x\n", hr);
1637 ok(dst_status == DBSTATUS_S_TRUNCATED, "got %08x\n", dst_status);
1638 ok(dst_len == 8, "got %ld\n", dst_len);
1639 ok(dst[0] == '4', "got %02x\n", dst[0]);
1640 ok(dst[1] == '3', "got %02x\n", dst[1]);
1641 ok(dst[2] == '2', "got %02x\n", dst[2]);
1642 ok(dst[3] == 0, "got %02x\n", dst[3]);
1643 ok(dst[4] == 0xcccc, "got %02x\n", dst[4]);
1647 memset(src, 0, sizeof(src));
1648 ((CY*)src)->int64 = 43210000;
1649 memset(dst, 0xcc, sizeof(dst));
1650 dst_len = 0x1234;
1651 hr = IDataConvert_DataConvert(convert, DBTYPE_CY, DBTYPE_WSTR, 0, &dst_len, src, dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
1652 ok(hr == S_OK, "got %08x\n", hr);
1653 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
1654 ok(dst_len == 8, "got %ld\n", dst_len);
1655 ok(!lstrcmpW(dst, fourthreetwoone), "got %s\n", wine_dbgstr_w(dst));
1659 memset(src, 0, sizeof(src));
1660 *(signed char *)src = 10;
1661 dst_len = 0x1234;
1662 hr = IDataConvert_DataConvert(convert, DBTYPE_I1, DBTYPE_WSTR, 0, &dst_len, src, dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
1663 ok(hr == S_OK, "got %08x\n", hr);
1664 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
1665 ok(dst_len == 4, "got %ld\n", dst_len);
1666 ok(!lstrcmpW(dst, ten), "got %s\n", wine_dbgstr_w(dst));
1668 memset(src, 0, sizeof(src));
1669 *(unsigned char *)src = 10;
1670 dst_len = 0x1234;
1671 hr = IDataConvert_DataConvert(convert, DBTYPE_UI1, DBTYPE_WSTR, 0, &dst_len, src, dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
1672 ok(hr == S_OK, "got %08x\n", hr);
1673 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
1674 ok(dst_len == 4, "got %ld\n", dst_len);
1675 ok(!lstrcmpW(dst, ten), "got %s\n", wine_dbgstr_w(dst));
1677 memset(src, 0, sizeof(src));
1678 *(unsigned short *)src = 4321;
1679 dst_len = 0x1234;
1680 hr = IDataConvert_DataConvert(convert, DBTYPE_UI2, DBTYPE_WSTR, 0, &dst_len, src, dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
1681 ok(hr == S_OK, "got %08x\n", hr);
1682 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
1683 ok(dst_len == 8, "got %ld\n", dst_len);
1684 ok(!lstrcmpW(dst, fourthreetwoone), "got %s\n", wine_dbgstr_w(dst));
1686 memset(src, 0, sizeof(src));
1687 *(unsigned int *)src = 4321;
1688 dst_len = 0x1234;
1689 hr = IDataConvert_DataConvert(convert, DBTYPE_UI4, DBTYPE_WSTR, 0, &dst_len, src, dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
1690 ok(hr == S_OK, "got %08x\n", hr);
1691 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
1692 ok(dst_len == 8, "got %ld\n", dst_len);
1693 ok(!lstrcmpW(dst, fourthreetwoone), "got %s\n", wine_dbgstr_w(dst));
1695 memset(src, 0, sizeof(src));
1696 ((LARGE_INTEGER*)src)->QuadPart = 4321;
1697 dst_len = 0x1234;
1698 hr = IDataConvert_DataConvert(convert, DBTYPE_I8, DBTYPE_WSTR, 0, &dst_len, src, dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
1699 ok(broken(hr == DB_E_UNSUPPORTEDCONVERSION) || hr == S_OK /* W2K+ */, "got %08x\n", hr);
1700 ok(broken(dst_status == DBSTATUS_E_BADACCESSOR) || dst_status == DBSTATUS_S_OK /* W2K+ */, "got %08x\n", dst_status);
1701 ok(broken(dst_len == 0x1234) || dst_len == 8 /* W2K+ */, "got %ld\n", dst_len);
1702 ok(!lstrcmpW(dst, fourthreetwoone), "got %s\n", wine_dbgstr_w(dst));
1704 memset(src, 0, sizeof(src));
1705 ((ULARGE_INTEGER*)src)->QuadPart = 4321;
1706 hr = IDataConvert_DataConvert(convert, DBTYPE_UI8, DBTYPE_WSTR, 0, &dst_len, src, dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
1707 ok(broken(hr == DB_E_UNSUPPORTEDCONVERSION) || hr == S_OK /* W2K+ */, "got %08x\n", hr);
1708 ok(broken(dst_status == DBSTATUS_E_BADACCESSOR) || dst_status == DBSTATUS_S_OK /* W2K+ */, "got %08x\n", dst_status);
1709 ok(broken(dst_len == 0x1234) || dst_len == 8 /* W2K+ */, "got %ld\n", dst_len);
1710 ok(!lstrcmpW(dst, fourthreetwoone), "got %s\n", wine_dbgstr_w(dst));
1714 memset(src, 0, sizeof(src));
1715 memcpy(src, &IID_IDataConvert, sizeof(GUID));
1716 memset(dst, 0xcc, sizeof(dst));
1717 dst_len = 0x1234;
1718 hr = IDataConvert_DataConvert(convert, DBTYPE_GUID, DBTYPE_WSTR, 0, &dst_len, src, dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
1719 ok(hr == S_OK, "got %08x\n", hr);
1720 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
1721 ok(dst_len == 76, "got %ld\n", dst_len);
1722 ok(!lstrcmpW(dst, guid_str), "got %s\n", wine_dbgstr_w(dst));
1726 b = SysAllocString(ten);
1727 *(BSTR *)src = b;
1728 dst_len = 0x1234;
1729 hr = IDataConvert_DataConvert(convert, DBTYPE_BSTR, DBTYPE_WSTR, 0, &dst_len, src, dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
1730 ok(hr == S_OK, "got %08x\n", hr);
1731 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
1732 ok(dst_len == 4, "got %ld\n", dst_len);
1733 ok(!lstrcmpW(b, dst), "got %s\n", wine_dbgstr_w(dst));
1734 SysFreeString(b);
1736 memcpy(src, ten, sizeof(ten));
1737 dst_len = 0x1234;
1738 hr = IDataConvert_DataConvert(convert, DBTYPE_WSTR, DBTYPE_WSTR, 2, &dst_len, src, dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
1739 ok(hr == S_OK, "got %08x\n", hr);
1740 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
1741 ok(dst_len == 2, "got %ld\n", dst_len);
1742 ok(dst[0] == '1', "got %02x\n", dst[0]);
1743 ok(dst[1] == 0, "got %02x\n", dst[1]);
1745 memcpy(src, ten, sizeof(ten));
1746 dst_len = 0x1234;
1747 hr = IDataConvert_DataConvert(convert, DBTYPE_WSTR, DBTYPE_WSTR, 4, &dst_len, src, dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
1748 ok(hr == S_OK, "got %08x\n", hr);
1749 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
1750 ok(dst_len == 4, "got %ld\n", dst_len);
1751 ok(!lstrcmpW(ten, dst), "got %s\n", wine_dbgstr_w(dst));
1753 memcpy(src, ten, sizeof(ten));
1754 dst_len = 0x1234;
1755 hr = IDataConvert_DataConvert(convert, DBTYPE_WSTR, DBTYPE_WSTR, 0, &dst_len, src, dst, sizeof(dst), 0, &dst_status, 0, 0, DBDATACONVERT_LENGTHFROMNTS);
1756 ok(hr == S_OK, "got %08x\n", hr);
1757 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
1758 ok(dst_len == 4, "got %ld\n", dst_len);
1759 ok(!lstrcmpW(ten, dst), "got %s\n", wine_dbgstr_w(dst));
1761 dst_len = 0x1234;
1762 hr = IDataConvert_DataConvert(convert, DBTYPE_DBTIMESTAMP, DBTYPE_WSTR, 0, &dst_len, &ts, 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 == 38, "got %ld\n", dst_len);
1766 ok(!lstrcmpW(tsW, dst), "got %s\n", wine_dbgstr_w(dst));
1768 dst_len = 0x1234;
1769 ts.fraction = 3;
1770 hr = IDataConvert_DataConvert(convert, DBTYPE_DBTIMESTAMP, DBTYPE_WSTR, 0, &dst_len, &ts, dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
1771 ok(hr == S_OK, "got %08x\n", hr);
1772 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
1773 ok(dst_len == 58, "got %ld\n", dst_len);
1774 ok(!lstrcmpW(ts1W, dst), "got %s\n", wine_dbgstr_w(dst));
1776 dst_len = 0x1234;
1777 ts.fraction = 200;
1778 hr = IDataConvert_DataConvert(convert, DBTYPE_DBTIMESTAMP, DBTYPE_WSTR, 0, &dst_len, &ts, dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
1779 ok(hr == S_OK, "got %08x\n", hr);
1780 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
1781 ok(dst_len == 58, "got %ld\n", dst_len);
1782 ok(!lstrcmpW(ts2W, dst), "got %s\n", wine_dbgstr_w(dst));
1784 /* DBTYPE_BYTES to DBTYPE_*STR unpacks binary data into a hex string */
1785 memcpy(src, hexpacked_w, sizeof(hexpacked_w));
1786 memset(dst, 0xcc, sizeof(dst));
1787 dst_len = 0x1234;
1788 hr = IDataConvert_DataConvert(convert, DBTYPE_BYTES, DBTYPE_WSTR, sizeof(hexpacked_w), &dst_len, src, dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
1789 ok(hr == S_OK, "got %08x\n", hr);
1790 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
1791 ok(dst_len == sizeof(hexpacked_w) * 4, "got %ld\n", dst_len);
1792 ok(!lstrcmpW(hexunpacked_w, dst), "got %s\n", wine_dbgstr_w(dst));
1793 ok(dst[ARRAY_SIZE(hexpacked_w) * 4 + 1] == 0xcccc, "clobbered buffer\n");
1795 memcpy(src, hexpacked_w, sizeof(hexpacked_w));
1796 memset(dst, 0xcc, sizeof(dst));
1797 dst_len = 0x1234;
1798 hr = IDataConvert_DataConvert(convert, DBTYPE_BYTES, DBTYPE_WSTR, 0, &dst_len, src, dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
1799 ok(hr == S_OK, "got %08x\n", hr);
1800 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
1801 ok(dst_len == 0, "got %ld\n", dst_len);
1802 ok(dst[0] == 0, "not null terminated\n");
1803 ok(dst[1] == 0xcccc, "clobbered buffer\n");
1805 memcpy(src, hexpacked_w, sizeof(hexpacked_w));
1806 memset(dst, 0xcc, sizeof(dst));
1807 dst_len = 0x1234;
1808 hr = IDataConvert_DataConvert(convert, DBTYPE_BYTES, DBTYPE_WSTR, 4, &dst_len, src, dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
1809 ok(hr == S_OK, "got %08x\n", hr);
1810 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
1811 ok(dst_len == 2 * sizeof(WCHAR) * 4, "got %ld\n", dst_len);
1812 ok(!memcmp(hexunpacked_w, dst, 2 * sizeof(WCHAR) * 4 ), "got %s\n", wine_dbgstr_w(dst));
1813 ok(dst[2 * 4] == 0, "not null terminated\n");
1814 ok(dst[2 * 4 + 1] == 0xcccc, "clobbered buffer\n");
1816 memcpy(src, hexpacked_w, sizeof(hexpacked_w));
1817 memset(dst, 0xcc, sizeof(dst));
1818 dst_len = 0x1234;
1819 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);
1820 ok(hr == S_OK, "got %08x\n", hr);
1821 ok(dst_status == DBSTATUS_S_TRUNCATED, "got %08x\n", dst_status);
1822 ok(dst_len == sizeof(hexpacked_w) * 4, "got %ld\n", dst_len);
1823 ok(!memcmp(hexunpacked_w, dst, 2 * sizeof(WCHAR) * 4 ), "got %s\n", wine_dbgstr_w(dst));
1824 ok(dst[2 * 4] == 0, "not null terminated\n");
1825 ok(dst[2 * 4 + 1] == 0xcccc, "clobbered buffer\n");
1827 memcpy(src, hexpacked_w, sizeof(hexpacked_w));
1828 memset(dst, 0xcc, sizeof(dst));
1829 dst_len = 0x1234;
1830 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);
1831 ok(hr == S_OK, "got %08x\n", hr);
1832 ok(dst_status == DBSTATUS_S_TRUNCATED, "got %08x\n", dst_status);
1833 ok(dst_len == sizeof(hexpacked_w) * 4, "got %ld\n", dst_len);
1834 ok(!memcmp(hexunpacked_w, dst, 2 * sizeof(WCHAR) * 4 - 2 ), "got %s\n", wine_dbgstr_w(dst));
1835 ok(dst[2 * 4 - 1] == 0, "not null terminated\n");
1836 ok(dst[2 * 4] == 0xcccc, "clobbered buffer\n");
1838 memcpy(src, hexpacked_w, sizeof(hexpacked_w));
1839 memset(dst, 0xcc, sizeof(dst));
1840 dst_len = 0x1234;
1841 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);
1842 ok(hr == S_OK, "got %08x\n", hr);
1843 ok(dst_status == DBSTATUS_S_TRUNCATED, "got %08x\n", dst_status);
1844 ok(dst_len == sizeof(hexpacked_w) * 4, "got %ld\n", dst_len);
1845 ok(!memcmp(hexunpacked_w, dst, 2 * sizeof(WCHAR) * 4 - 2 ), "got %s\n", wine_dbgstr_w(dst));
1846 ok(dst[2 * 4 - 1] == 0, "not null terminated\n");
1847 ok(dst[2 * 4] == 0xcccc, "clobbered buffer\n");
1849 memcpy(src, hexpacked_w, sizeof(hexpacked_w));
1850 memset(dst, 0xcc, sizeof(dst));
1851 dst_len = 0x1234;
1852 hr = IDataConvert_DataConvert(convert, DBTYPE_BYTES, DBTYPE_WSTR, 0, &dst_len, src, dst, sizeof(dst), 0, &dst_status, 0, 0, DBDATACONVERT_LENGTHFROMNTS);
1853 ok(hr == S_OK, "got %08x\n", hr);
1854 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
1855 ok(dst_len == 0, "got %ld\n", dst_len);
1856 ok(dst[0] == 0, "not null terminated\n");
1857 ok(dst[1] == 0xcccc, "clobbered buffer\n");
1859 b = SysAllocStringLen(NULL, 0);
1860 V_VT(&v) = VT_BSTR;
1861 V_BSTR(&v) = b;
1862 hr = IDataConvert_DataConvert(convert, DBTYPE_VARIANT, DBTYPE_WSTR, 0, &dst_len, &v, dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
1863 ok(hr == S_OK, "got %08x\n", hr);
1864 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
1865 ok(dst_len == 0, "got %ld\n", dst_len);
1866 ok(!lstrcmpW(b, dst), "got %s\n", wine_dbgstr_w(dst));
1867 VariantClear(&v);
1869 dst_len = 44;
1870 V_VT(&v) = VT_NULL;
1871 hr = IDataConvert_DataConvert(convert, DBTYPE_VARIANT, DBTYPE_WSTR, 0, &dst_len, &v, dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
1872 ok(hr == S_OK, "got %08x\n", hr);
1873 ok(dst_status == DBSTATUS_S_ISNULL, "got %08x\n", dst_status);
1874 ok(dst_len == 44, "got %ld\n", dst_len);
1877 static void test_converttostr(void)
1879 HRESULT hr;
1880 char dst[100];
1881 BYTE src[64];
1882 DBSTATUS dst_status;
1883 DBLENGTH dst_len;
1884 static const WCHAR ten[] = {'1','0',0};
1885 static const WCHAR idW[] = {'0','C','7','3','3','A','8','D','-','2','A','1','C',0 };
1886 static const char idA[] = "0C733A8D";
1887 static const char withnull[] = "test\0ed";
1888 static const char ten_a[] = "10";
1889 static const char fourthreetwoone[] = "4321";
1890 static const char guid_str[] = "{0C733A8D-2A1C-11CE-ADE5-00AA0044773D}";
1891 static const char hexunpacked_a[] = "57696E6500";
1892 static const char hexpacked_a[] = "Wine";
1893 BSTR b;
1894 VARIANT v;
1896 memset(dst, 0xcc, sizeof(dst));
1897 dst_len = 0x1234;
1898 hr = IDataConvert_DataConvert(convert, DBTYPE_EMPTY, DBTYPE_STR, 0, &dst_len, src, dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
1899 ok(hr == S_OK, "got %08x\n", hr);
1900 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
1901 ok(dst_len == 0, "got %ld\n", dst_len);
1902 ok(dst[0] == 0, "got %02x\n", dst[0]);
1903 ok(dst[1] == (char)0xcc, "got %02x\n", dst[1]);
1905 memset(dst, 0xcc, sizeof(dst));
1906 dst_len = 0x1234;
1907 hr = IDataConvert_DataConvert(convert, DBTYPE_NULL, DBTYPE_STR, 0, &dst_len, src, dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
1908 ok(hr == DB_E_UNSUPPORTEDCONVERSION, "got %08x\n", hr);
1909 ok(dst_status == DBSTATUS_E_BADACCESSOR, "got %08x\n", dst_status);
1910 ok(dst_len == 0x1234, "got %ld\n", dst_len);
1911 ok(dst[0] == (char)0xcc, "got %02x\n", dst[0]);
1913 *(short *)src = 4321;
1914 dst_len = 0x1234;
1915 hr = IDataConvert_DataConvert(convert, DBTYPE_I2, DBTYPE_STR, 0, &dst_len, src, dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
1916 ok(hr == S_OK, "got %08x\n", hr);
1917 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
1918 ok(dst_len == 4, "got %ld\n", dst_len);
1919 ok(!lstrcmpA(dst, fourthreetwoone), "got %s\n", dst);
1921 *(short *)src = 4321;
1922 memset(dst, 0xcc, sizeof(dst));
1923 dst_len = 0x1234;
1924 hr = IDataConvert_DataConvert(convert, DBTYPE_I2, DBTYPE_STR, 0, &dst_len, src, dst, 0, 0, &dst_status, 0, 0, 0);
1925 ok(hr == DB_E_ERRORSOCCURRED, "got %08x\n", hr);
1926 ok(dst_status == DBSTATUS_E_DATAOVERFLOW, "got %08x\n", dst_status);
1927 ok(dst_len == 4, "got %ld\n", dst_len);
1928 ok(dst[0] == (char)0xcc, "got %02x\n", dst[0]);
1930 *(short *)src = 4321;
1931 memset(dst, 0xcc, sizeof(dst));
1932 dst_len = 0x1234;
1933 hr = IDataConvert_DataConvert(convert, DBTYPE_I2, DBTYPE_STR, 0, &dst_len, src, NULL, 0, 0, &dst_status, 0, 0, 0);
1934 ok(hr == S_OK, "got %08x\n", hr);
1935 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
1936 ok(dst_len == 4, "got %ld\n", dst_len);
1937 ok(dst[0] == (char)0xcc, "got %02x\n", dst[0]);
1939 *(short *)src = 4321;
1940 memset(dst, 0xcc, sizeof(dst));
1941 dst_len = 0x1234;
1942 hr = IDataConvert_DataConvert(convert, DBTYPE_I2, DBTYPE_STR, 0, &dst_len, src, dst, 2, 0, &dst_status, 0, 0, 0);
1943 ok(hr == S_OK, "got %08x\n", hr);
1944 ok(dst_status == DBSTATUS_S_TRUNCATED, "got %08x\n", dst_status);
1945 ok(dst_len == 4, "got %ld\n", dst_len);
1946 ok(dst[0] == '4', "got %02x\n", dst[0]);
1947 ok(dst[1] == 0, "got %02x\n", dst[1]);
1948 ok(dst[2] == (char)0xcc, "got %02x\n", dst[2]);
1950 *(short *)src = 4321;
1951 memset(dst, 0xcc, sizeof(dst));
1952 dst_len = 0x1234;
1953 hr = IDataConvert_DataConvert(convert, DBTYPE_I2, DBTYPE_STR, 0, &dst_len, src, dst, 1, 0, &dst_status, 0, 0, 0);
1954 ok(hr == S_OK, "got %08x\n", hr);
1955 ok(dst_status == DBSTATUS_S_TRUNCATED, "got %08x\n", dst_status);
1956 ok(dst_len == 4, "got %ld\n", dst_len);
1957 ok(dst[0] == 0, "got %02x\n", dst[0]);
1958 ok(dst[1] == (char)0xcc, "got %02x\n", dst[1]);
1960 *(short *)src = 4321;
1961 memset(dst, 0xcc, sizeof(dst));
1962 dst_len = 0x1234;
1963 hr = IDataConvert_DataConvert(convert, DBTYPE_I2, DBTYPE_STR, 0, &dst_len, src, dst, 4, 0, &dst_status, 0, 0, 0);
1964 ok(hr == S_OK, "got %08x\n", hr);
1965 ok(dst_status == DBSTATUS_S_TRUNCATED, "got %08x\n", dst_status);
1966 ok(dst_len == 4, "got %ld\n", dst_len);
1967 ok(dst[0] == '4', "got %02x\n", dst[0]);
1968 ok(dst[1] == '3', "got %02x\n", dst[1]);
1969 ok(dst[2] == '2', "got %02x\n", dst[2]);
1970 ok(dst[3] == 0, "got %02x\n", dst[3]);
1971 ok(dst[4] == (char)0xcc, "got %02x\n", dst[4]);
1974 *(int *)src = 4321;
1975 dst_len = 0x1234;
1976 hr = IDataConvert_DataConvert(convert, DBTYPE_I4, DBTYPE_STR, 0, &dst_len, src, dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
1977 ok(hr == S_OK, "got %08x\n", hr);
1978 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
1979 ok(dst_len == 4, "got %ld\n", dst_len);
1980 ok(!lstrcmpA(dst, fourthreetwoone), "got %s\n", dst);
1982 *(int *)src = 4321;
1983 memset(dst, 0xcc, sizeof(dst));
1984 dst_len = 0x1234;
1985 hr = IDataConvert_DataConvert(convert, DBTYPE_I4, DBTYPE_STR, 0, &dst_len, src, dst, 0, 0, &dst_status, 0, 0, 0);
1986 ok(hr == DB_E_ERRORSOCCURRED, "got %08x\n", hr);
1987 ok(dst_status == DBSTATUS_E_DATAOVERFLOW, "got %08x\n", dst_status);
1988 ok(dst_len == 4, "got %ld\n", dst_len);
1989 ok(dst[0] == (char)0xcc, "got %02x\n", dst[0]);
1991 *(int *)src = 4321;
1992 memset(dst, 0xcc, sizeof(dst));
1993 dst_len = 0x1234;
1994 hr = IDataConvert_DataConvert(convert, DBTYPE_I4, DBTYPE_STR, 0, &dst_len, src, NULL, 0, 0, &dst_status, 0, 0, 0);
1995 ok(hr == S_OK, "got %08x\n", hr);
1996 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
1997 ok(dst_len == 4, "got %ld\n", dst_len);
1998 ok(dst[0] == (char)0xcc, "got %02x\n", dst[0]);
2000 *(int *)src = 4321;
2001 memset(dst, 0xcc, sizeof(dst));
2002 dst_len = 0x1234;
2003 hr = IDataConvert_DataConvert(convert, DBTYPE_I4, DBTYPE_STR, 0, &dst_len, src, dst, 2, 0, &dst_status, 0, 0, 0);
2004 ok(hr == S_OK, "got %08x\n", hr);
2005 ok(dst_status == DBSTATUS_S_TRUNCATED, "got %08x\n", dst_status);
2006 ok(dst_len == 4, "got %ld\n", dst_len);
2007 ok(dst[0] == '4', "got %02x\n", dst[0]);
2008 ok(dst[1] == 0, "got %02x\n", dst[1]);
2009 ok(dst[2] == (char)0xcc, "got %02x\n", dst[2]);
2011 *(int *)src = 4321;
2012 memset(dst, 0xcc, sizeof(dst));
2013 dst_len = 0x1234;
2014 hr = IDataConvert_DataConvert(convert, DBTYPE_I4, DBTYPE_STR, 0, &dst_len, src, dst, 1, 0, &dst_status, 0, 0, 0);
2015 ok(hr == S_OK, "got %08x\n", hr);
2016 ok(dst_status == DBSTATUS_S_TRUNCATED, "got %08x\n", dst_status);
2017 ok(dst_len == 4, "got %ld\n", dst_len);
2018 ok(dst[0] == 0, "got %02x\n", dst[0]);
2019 ok(dst[1] == (char)0xcc, "got %02x\n", dst[1]);
2021 *(int *)src = 4321;
2022 memset(dst, 0xcc, sizeof(dst));
2023 dst_len = 0x1234;
2024 hr = IDataConvert_DataConvert(convert, DBTYPE_I4, DBTYPE_STR, 0, &dst_len, src, dst, 4, 0, &dst_status, 0, 0, 0);
2025 ok(hr == S_OK, "got %08x\n", hr);
2026 ok(dst_status == DBSTATUS_S_TRUNCATED, "got %08x\n", dst_status);
2027 ok(dst_len == 4, "got %ld\n", dst_len);
2028 ok(dst[0] == '4', "got %02x\n", dst[0]);
2029 ok(dst[1] == '3', "got %02x\n", dst[1]);
2030 ok(dst[2] == '2', "got %02x\n", dst[2]);
2031 ok(dst[3] == 0, "got %02x\n", dst[3]);
2032 ok(dst[4] == (char)0xcc, "got %02x\n", dst[4]);
2035 *(float *)src = 4321;
2036 dst_len = 0x1234;
2037 hr = IDataConvert_DataConvert(convert, DBTYPE_R4, DBTYPE_STR, 0, &dst_len, src, dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
2038 ok(hr == S_OK, "got %08x\n", hr);
2039 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
2040 ok(dst_len == 4, "got %ld\n", dst_len);
2041 ok(!lstrcmpA(dst, fourthreetwoone), "got %s\n", dst);
2043 *(float *)src = 4321;
2044 memset(dst, 0xcc, sizeof(dst));
2045 dst_len = 0x1234;
2046 hr = IDataConvert_DataConvert(convert, DBTYPE_R4, DBTYPE_STR, 0, &dst_len, src, dst, 0, 0, &dst_status, 0, 0, 0);
2047 ok(hr == DB_E_ERRORSOCCURRED, "got %08x\n", hr);
2048 ok(dst_status == DBSTATUS_E_DATAOVERFLOW, "got %08x\n", dst_status);
2049 ok(dst_len == 4, "got %ld\n", dst_len);
2050 ok(dst[0] == (char)0xcc, "got %02x\n", dst[0]);
2052 *(float *)src = 4321;
2053 memset(dst, 0xcc, sizeof(dst));
2054 dst_len = 0x1234;
2055 hr = IDataConvert_DataConvert(convert, DBTYPE_R4, DBTYPE_STR, 0, &dst_len, src, NULL, 0, 0, &dst_status, 0, 0, 0);
2056 ok(hr == S_OK, "got %08x\n", hr);
2057 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
2058 ok(dst_len == 4, "got %ld\n", dst_len);
2059 ok(dst[0] == (char)0xcc, "got %02x\n", dst[0]);
2061 *(float *)src = 4321;
2062 memset(dst, 0xcc, sizeof(dst));
2063 dst_len = 0x1234;
2064 hr = IDataConvert_DataConvert(convert, DBTYPE_R4, DBTYPE_STR, 0, &dst_len, src, dst, 2, 0, &dst_status, 0, 0, 0);
2065 ok(hr == S_OK, "got %08x\n", hr);
2066 ok(dst_status == DBSTATUS_S_TRUNCATED, "got %08x\n", dst_status);
2067 ok(dst_len == 4, "got %ld\n", dst_len);
2068 ok(dst[0] == '4', "got %02x\n", dst[0]);
2069 ok(dst[1] == 0, "got %02x\n", dst[1]);
2070 ok(dst[2] == (char)0xcc, "got %02x\n", dst[2]);
2072 *(float *)src = 4321;
2073 memset(dst, 0xcc, sizeof(dst));
2074 dst_len = 0x1234;
2075 hr = IDataConvert_DataConvert(convert, DBTYPE_R4, DBTYPE_STR, 0, &dst_len, src, dst, 1, 0, &dst_status, 0, 0, 0);
2076 ok(hr == S_OK, "got %08x\n", hr);
2077 ok(dst_status == DBSTATUS_S_TRUNCATED, "got %08x\n", dst_status);
2078 ok(dst_len == 4, "got %ld\n", dst_len);
2079 ok(dst[0] == 0, "got %02x\n", dst[0]);
2080 ok(dst[1] == (char)0xcc, "got %02x\n", dst[1]);
2082 *(float *)src = 4321;
2083 memset(dst, 0xcc, sizeof(dst));
2084 dst_len = 0x1234;
2085 hr = IDataConvert_DataConvert(convert, DBTYPE_R4, DBTYPE_STR, 0, &dst_len, src, dst, 4, 0, &dst_status, 0, 0, 0);
2086 ok(hr == S_OK, "got %08x\n", hr);
2087 ok(dst_status == DBSTATUS_S_TRUNCATED, "got %08x\n", dst_status);
2088 ok(dst_len == 4, "got %ld\n", dst_len);
2089 ok(dst[0] == '4', "got %02x\n", dst[0]);
2090 ok(dst[1] == '3', "got %02x\n", dst[1]);
2091 ok(dst[2] == '2', "got %02x\n", dst[2]);
2092 ok(dst[3] == 0, "got %02x\n", dst[3]);
2093 ok(dst[4] == (char)0xcc, "got %02x\n", dst[4]);
2096 *(double *)src = 4321;
2097 dst_len = 0x1234;
2098 hr = IDataConvert_DataConvert(convert, DBTYPE_R8, DBTYPE_STR, 0, &dst_len, src, dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
2099 ok(hr == S_OK, "got %08x\n", hr);
2100 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
2101 ok(dst_len == 4, "got %ld\n", dst_len);
2102 ok(!lstrcmpA(dst, fourthreetwoone), "got %s\n", dst);
2104 *(double *)src = 4321;
2105 memset(dst, 0xcc, sizeof(dst));
2106 dst_len = 0x1234;
2107 hr = IDataConvert_DataConvert(convert, DBTYPE_R8, DBTYPE_STR, 0, &dst_len, src, dst, 0, 0, &dst_status, 0, 0, 0);
2108 ok(hr == DB_E_ERRORSOCCURRED, "got %08x\n", hr);
2109 ok(dst_status == DBSTATUS_E_DATAOVERFLOW, "got %08x\n", dst_status);
2110 ok(dst_len == 4, "got %ld\n", dst_len);
2111 ok(dst[0] == (char)0xcc, "got %02x\n", dst[0]);
2113 *(double *)src = 4321;
2114 memset(dst, 0xcc, sizeof(dst));
2115 dst_len = 0x1234;
2116 hr = IDataConvert_DataConvert(convert, DBTYPE_R8, DBTYPE_STR, 0, &dst_len, src, NULL, 0, 0, &dst_status, 0, 0, 0);
2117 ok(hr == S_OK, "got %08x\n", hr);
2118 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
2119 ok(dst_len == 4, "got %ld\n", dst_len);
2120 ok(dst[0] == (char)0xcc, "got %02x\n", dst[0]);
2122 *(double *)src = 4321;
2123 memset(dst, 0xcc, sizeof(dst));
2124 dst_len = 0x1234;
2125 hr = IDataConvert_DataConvert(convert, DBTYPE_R8, DBTYPE_STR, 0, &dst_len, src, dst, 2, 0, &dst_status, 0, 0, 0);
2126 ok(hr == S_OK, "got %08x\n", hr);
2127 ok(dst_status == DBSTATUS_S_TRUNCATED, "got %08x\n", dst_status);
2128 ok(dst_len == 4, "got %ld\n", dst_len);
2129 ok(dst[0] == '4', "got %02x\n", dst[0]);
2130 ok(dst[1] == 0, "got %02x\n", dst[1]);
2131 ok(dst[2] == (char)0xcc, "got %02x\n", dst[2]);
2133 *(double *)src = 4321;
2134 memset(dst, 0xcc, sizeof(dst));
2135 dst_len = 0x1234;
2136 hr = IDataConvert_DataConvert(convert, DBTYPE_R8, DBTYPE_STR, 0, &dst_len, src, dst, 1, 0, &dst_status, 0, 0, 0);
2137 ok(hr == S_OK, "got %08x\n", hr);
2138 ok(dst_status == DBSTATUS_S_TRUNCATED, "got %08x\n", dst_status);
2139 ok(dst_len == 4, "got %ld\n", dst_len);
2140 ok(dst[0] == 0, "got %02x\n", dst[0]);
2141 ok(dst[1] == (char)0xcc, "got %02x\n", dst[1]);
2143 *(double *)src = 4321;
2144 memset(dst, 0xcc, sizeof(dst));
2145 dst_len = 0x1234;
2146 hr = IDataConvert_DataConvert(convert, DBTYPE_R8, DBTYPE_STR, 0, &dst_len, src, dst, 4, 0, &dst_status, 0, 0, 0);
2147 ok(hr == S_OK, "got %08x\n", hr);
2148 ok(dst_status == DBSTATUS_S_TRUNCATED, "got %08x\n", dst_status);
2149 ok(dst_len == 4, "got %ld\n", dst_len);
2150 ok(dst[0] == '4', "got %02x\n", dst[0]);
2151 ok(dst[1] == '3', "got %02x\n", dst[1]);
2152 ok(dst[2] == '2', "got %02x\n", dst[2]);
2153 ok(dst[3] == 0, "got %02x\n", dst[3]);
2154 ok(dst[4] == (char)0xcc, "got %02x\n", dst[4]);
2158 memset(src, 0, sizeof(src));
2159 ((CY*)src)->int64 = 43210000;
2160 memset(dst, 0xcc, sizeof(dst));
2161 dst_len = 0x1234;
2162 hr = IDataConvert_DataConvert(convert, DBTYPE_CY, DBTYPE_STR, 0, &dst_len, src, dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
2163 ok(hr == S_OK, "got %08x\n", hr);
2164 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
2165 ok(dst_len == 4, "got %ld\n", dst_len);
2166 ok(!lstrcmpA(dst, fourthreetwoone), "got %s\n", dst);
2170 memset(src, 0, sizeof(src));
2171 *(signed char *)src = 10;
2172 dst_len = 0x1234;
2173 hr = IDataConvert_DataConvert(convert, DBTYPE_I1, DBTYPE_STR, 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 == 2, "got %ld\n", dst_len);
2177 ok(!lstrcmpA(dst, ten_a), "got %s\n", dst);
2179 memset(src, 0, sizeof(src));
2180 *(unsigned char *)src = 10;
2181 dst_len = 0x1234;
2182 hr = IDataConvert_DataConvert(convert, DBTYPE_UI1, DBTYPE_STR, 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 == 2, "got %ld\n", dst_len);
2186 ok(!lstrcmpA(dst, ten_a), "got %s\n", dst);
2188 memset(src, 0, sizeof(src));
2189 *(unsigned short *)src = 4321;
2190 dst_len = 0x1234;
2191 hr = IDataConvert_DataConvert(convert, DBTYPE_UI2, DBTYPE_STR, 0, &dst_len, src, dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
2192 ok(hr == S_OK, "got %08x\n", hr);
2193 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
2194 ok(dst_len == 4, "got %ld\n", dst_len);
2195 ok(!lstrcmpA(dst, fourthreetwoone), "got %s\n", dst);
2197 memset(src, 0, sizeof(src));
2198 *(unsigned int *)src = 4321;
2199 dst_len = 0x1234;
2200 hr = IDataConvert_DataConvert(convert, DBTYPE_UI4, DBTYPE_STR, 0, &dst_len, src, dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
2201 ok(hr == S_OK, "got %08x\n", hr);
2202 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
2203 ok(dst_len == 4, "got %ld\n", dst_len);
2204 ok(!lstrcmpA(dst, fourthreetwoone), "got %s\n", dst);
2206 memset(src, 0, sizeof(src));
2207 ((LARGE_INTEGER*)src)->QuadPart = 4321;
2208 dst_len = 0x1234;
2209 hr = IDataConvert_DataConvert(convert, DBTYPE_I8, DBTYPE_STR, 0, &dst_len, src, dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
2210 ok(broken(hr == DB_E_UNSUPPORTEDCONVERSION) || hr == S_OK /* W2K+ */, "got %08x\n", hr);
2211 ok(broken(dst_status == DBSTATUS_E_BADACCESSOR) || dst_status == DBSTATUS_S_OK /* W2K+ */, "got %08x\n", dst_status);
2212 ok(broken(dst_len == 0x1234) || dst_len == 4 /* W2K+ */, "got %ld\n", dst_len);
2213 ok(!lstrcmpA(dst, fourthreetwoone), "got %s\n", dst);
2215 memset(src, 0, sizeof(src));
2216 ((ULARGE_INTEGER*)src)->QuadPart = 4321;
2217 dst_len = 0x1234;
2218 hr = IDataConvert_DataConvert(convert, DBTYPE_UI8, DBTYPE_STR, 0, &dst_len, src, dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
2219 ok(broken(hr == DB_E_UNSUPPORTEDCONVERSION) || hr == S_OK /* W2K+ */, "got %08x\n", hr);
2220 ok(broken(dst_status == DBSTATUS_E_BADACCESSOR) || dst_status == DBSTATUS_S_OK /* W2K+ */, "got %08x\n", dst_status);
2221 ok(broken(dst_len == 0x1234) || dst_len == 4 /* W2K+ */, "got %ld\n", dst_len);
2222 ok(!lstrcmpA(dst, fourthreetwoone), "got %s\n", dst);
2226 memset(src, 0, sizeof(src));
2227 memcpy(src, &IID_IDataConvert, sizeof(GUID));
2228 memset(dst, 0xcc, sizeof(dst));
2229 dst_len = 0x1234;
2230 hr = IDataConvert_DataConvert(convert, DBTYPE_GUID, DBTYPE_STR, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
2231 ok(hr == S_OK, "got %08x\n", hr);
2232 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
2233 ok(dst_len == 38, "got %ld\n", dst_len);
2234 ok(!lstrcmpA(dst, guid_str), "got %s\n", dst);
2238 b = SysAllocString(ten);
2239 *(BSTR *)src = b;
2240 memset(dst, 0xcc, sizeof(dst));
2241 dst_len = 0x1234;
2242 hr = IDataConvert_DataConvert(convert, DBTYPE_BSTR, DBTYPE_STR, 0, &dst_len, src, dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
2243 ok(hr == S_OK, "got %08x\n", hr);
2244 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
2245 ok(dst_len == 2, "got %ld\n", dst_len);
2246 ok(!lstrcmpA(ten_a, dst), "got %s\n", dst);
2247 SysFreeString(b);
2249 b = SysAllocString(idW);
2250 *(BSTR *)src = b;
2251 memset(dst, 0xcc, sizeof(dst));
2252 dst_len = 0x1234;
2253 hr = IDataConvert_DataConvert(convert, DBTYPE_BSTR, DBTYPE_STR, 0, &dst_len, src, dst, 9, 0, &dst_status, 0, 0, 0);
2254 ok(hr == S_OK, "got %08x\n", hr);
2255 ok(dst_status == DBSTATUS_S_TRUNCATED, "got %08x\n", dst_status);
2256 ok(dst_len == 13, "got %ld\n", dst_len);
2257 ok(!lstrcmpA(idA, dst), "got %s\n", dst);
2258 SysFreeString(b);
2260 memcpy(src, withnull, sizeof(withnull));
2261 memset(dst, 0xcc, sizeof(dst));
2262 dst_len = 0x1234;
2263 hr = IDataConvert_DataConvert(convert, DBTYPE_STR, DBTYPE_STR, sizeof(withnull), &dst_len, src, dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
2264 ok(hr == S_OK, "got %08x\n", hr);
2265 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
2266 ok(dst_len == 8, "got %ld\n", dst_len);
2267 ok(!memcmp(withnull, dst, 8), "got %s\n", dst);
2268 ok(dst[8] == 0, "got %02x\n", dst[8]);
2270 memcpy(src, withnull, sizeof(withnull));
2271 memset(dst, 0xcc, sizeof(dst));
2272 dst_len = 0x1234;
2273 hr = IDataConvert_DataConvert(convert, DBTYPE_STR, DBTYPE_STR, 7, &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 == 7, "got %ld\n", dst_len);
2277 ok(!memcmp(withnull, dst, 7), "got %s\n", dst);
2278 ok(dst[7] == 0, "got %02x\n", dst[7]);
2280 memcpy(src, withnull, sizeof(withnull));
2281 memset(dst, 0xcc, sizeof(dst));
2282 dst_len = 0x1234;
2283 hr = IDataConvert_DataConvert(convert, DBTYPE_STR, DBTYPE_STR, 6, &dst_len, src, dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
2284 ok(hr == S_OK, "got %08x\n", hr);
2285 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
2286 ok(dst_len == 6, "got %ld\n", dst_len);
2287 ok(!memcmp(withnull, dst, 6), "got %s\n", dst);
2288 ok(dst[6] == 0, "got %02x\n", dst[6]);
2290 memcpy(src, ten, sizeof(ten));
2291 memset(dst, 0xcc, sizeof(dst));
2292 dst_len = 0x1234;
2293 hr = IDataConvert_DataConvert(convert, DBTYPE_WSTR, DBTYPE_STR, 2, &dst_len, src, dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
2294 ok(hr == S_OK, "got %08x\n", hr);
2295 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
2296 ok(dst_len == 1, "got %ld\n", dst_len);
2297 ok(dst[0] == '1', "got %02x\n", dst[0]);
2298 ok(dst[1] == 0, "got %02x\n", dst[1]);
2300 memcpy(src, ten, sizeof(ten));
2301 memset(dst, 0xcc, sizeof(dst));
2302 dst_len = 0x1234;
2303 hr = IDataConvert_DataConvert(convert, DBTYPE_WSTR, DBTYPE_STR, 4, &dst_len, src, dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
2304 ok(hr == S_OK, "got %08x\n", hr);
2305 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
2306 ok(dst_len == 2, "got %ld\n", dst_len);
2307 ok(!lstrcmpA(ten_a, dst), "got %s\n", dst);
2309 memcpy(src, ten, sizeof(ten));
2310 memset(dst, 0xcc, sizeof(dst));
2311 dst_len = 0x1234;
2312 hr = IDataConvert_DataConvert(convert, DBTYPE_WSTR, DBTYPE_STR, 0, &dst_len, src, dst, sizeof(dst), 0, &dst_status, 0, 0, DBDATACONVERT_LENGTHFROMNTS);
2313 ok(hr == S_OK, "got %08x\n", hr);
2314 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
2315 ok(dst_len == 2, "got %ld\n", dst_len);
2316 ok(!lstrcmpA(ten_a, dst), "got %s\n", dst);
2318 memcpy(src, ten_a, sizeof(ten_a));
2319 memset(dst, 0xcc, sizeof(dst));
2320 dst_len = 0x1234;
2321 hr = IDataConvert_DataConvert(convert, DBTYPE_STR, DBTYPE_STR, 2, &dst_len, src, dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
2322 ok(hr == S_OK, "got %08x\n", hr);
2323 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
2324 ok(dst_len == 2, "got %ld\n", dst_len);
2325 ok(dst[0] == '1', "got %02x\n", dst[0]);
2326 ok(dst[1] == '0', "got %02x\n", dst[1]);
2327 ok(dst[2] == 0, "got %02x\n", dst[2]);
2328 ok(dst[3] == (char)0xcc, "got %02x\n", dst[3]);
2330 memcpy(src, ten_a, sizeof(ten_a));
2331 memset(dst, 0xcc, sizeof(dst));
2332 dst_len = 0x1234;
2333 hr = IDataConvert_DataConvert(convert, DBTYPE_STR, DBTYPE_STR, 4, &dst_len, src, dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
2334 ok(hr == S_OK, "got %08x\n", hr);
2335 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
2336 ok(dst_len == 4, "got %ld\n", dst_len);
2337 ok(!lstrcmpA(ten_a, dst), "got %s\n", dst);
2339 memcpy(src, ten_a, sizeof(ten_a));
2340 memset(dst, 0xcc, sizeof(dst));
2341 dst_len = 0x1234;
2342 hr = IDataConvert_DataConvert(convert, DBTYPE_STR, DBTYPE_STR, 0, &dst_len, src, dst, sizeof(dst), 0, &dst_status, 0, 0, DBDATACONVERT_LENGTHFROMNTS);
2343 ok(hr == S_OK, "got %08x\n", hr);
2344 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
2345 ok(dst_len == 2, "got %ld\n", dst_len);
2346 ok(!lstrcmpA(ten_a, dst), "got %s\n", dst);
2350 /* DBTYPE_BYTES to DBTYPE_*STR unpacks binary data into a hex string */
2351 memcpy(src, hexpacked_a, sizeof(hexpacked_a));
2352 memset(dst, 0xcc, sizeof(dst));
2353 dst_len = 0x1234;
2354 hr = IDataConvert_DataConvert(convert, DBTYPE_BYTES, DBTYPE_STR, sizeof(hexpacked_a), &dst_len, src, dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
2355 ok(hr == S_OK, "got %08x\n", hr);
2356 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
2357 ok(dst_len == sizeof(hexpacked_a) * 2, "got %ld\n", dst_len);
2358 ok(!lstrcmpA(hexunpacked_a, dst), "got %s\n", dst);
2359 ok(dst[ARRAY_SIZE(hexpacked_a) * 4 + 1] == (char)0xcc, "clobbered buffer\n");
2361 memcpy(src, hexpacked_a, sizeof(hexpacked_a));
2362 memset(dst, 0xcc, sizeof(dst));
2363 dst_len = 0x1234;
2364 hr = IDataConvert_DataConvert(convert, DBTYPE_BYTES, DBTYPE_STR, 0, &dst_len, src, dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
2365 ok(hr == S_OK, "got %08x\n", hr);
2366 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
2367 ok(dst_len == 0, "got %ld\n", dst_len);
2368 ok(dst[0] == 0, "not null terminated\n");
2369 ok(dst[1] == (char)0xcc, "clobbered buffer\n");
2371 memcpy(src, hexpacked_a, sizeof(hexpacked_a));
2372 memset(dst, 0xcc, sizeof(dst));
2373 dst_len = 0x1234;
2374 hr = IDataConvert_DataConvert(convert, DBTYPE_BYTES, DBTYPE_STR, 4, &dst_len, src, dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
2375 ok(hr == S_OK, "got %08x\n", hr);
2376 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
2377 ok(dst_len == 2 * sizeof(char) * 4, "got %ld\n", dst_len);
2378 ok(!memcmp(hexunpacked_a, dst, 2 * sizeof(char) * 4 ), "got %s\n", dst);
2379 ok(dst[2 * 4] == 0, "not null terminated\n");
2380 ok(dst[2 * 4 + 1] == (char)0xcc, "clobbered buffer\n");
2382 memcpy(src, hexpacked_a, sizeof(hexpacked_a));
2383 memset(dst, 0xcc, sizeof(dst));
2384 dst_len = 0x1234;
2385 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);
2386 ok(hr == S_OK, "got %08x\n", hr);
2387 ok(dst_status == DBSTATUS_S_TRUNCATED, "got %08x\n", dst_status);
2388 ok(dst_len == sizeof(hexpacked_a) * 2, "got %ld\n", dst_len);
2389 ok(!memcmp(hexunpacked_a, dst, 2 * sizeof(char) * 4 ), "got %s\n", dst);
2390 ok(dst[2 * 4] == 0, "not null terminated\n");
2391 ok(dst[2 * 4 + 1] == (char)0xcc, "clobbered buffer\n");
2393 memcpy(src, hexpacked_a, sizeof(hexpacked_a));
2394 memset(dst, 0xcc, sizeof(dst));
2395 dst_len = 0x1234;
2396 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);
2397 ok(hr == S_OK, "got %08x\n", hr);
2398 ok(dst_status == DBSTATUS_S_TRUNCATED, "got %08x\n", dst_status);
2399 ok(dst_len == sizeof(hexpacked_a) * 2, "got %ld\n", dst_len);
2400 ok(!memcmp(hexunpacked_a, dst, 2 * sizeof(char) * 4 - 2 ), "got %s\n", dst);
2401 ok(dst[2 * 4 - 1] == 0, "not null terminated\n");
2402 ok(dst[2 * 4] == (char)0xcc, "clobbered buffer\n");
2404 memcpy(src, hexpacked_a, sizeof(hexpacked_a));
2405 memset(dst, 0xcc, sizeof(dst));
2406 dst_len = 0x1234;
2407 hr = IDataConvert_DataConvert(convert, DBTYPE_BYTES, DBTYPE_STR, 0, &dst_len, src, dst, sizeof(dst), 0, &dst_status, 0, 0, DBDATACONVERT_LENGTHFROMNTS);
2408 ok(hr == S_OK, "got %08x\n", hr);
2409 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
2410 ok(dst_len == 0, "got %ld\n", dst_len);
2411 ok(dst[0] == 0, "not null terminated\n");
2412 ok(dst[1] == (char)0xcc, "clobbered buffer\n");
2414 dst_len = 44;
2415 V_VT(&v) = VT_NULL;
2416 hr = IDataConvert_DataConvert(convert, DBTYPE_VARIANT, DBTYPE_STR, 0, &dst_len, &v, dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
2417 ok(hr == S_OK, "got %08x\n", hr);
2418 ok(dst_status == DBSTATUS_S_ISNULL, "got %08x\n", dst_status);
2419 ok(dst_len == 44, "got %ld\n", dst_len);
2422 static void test_converttobyrefwstr(void)
2424 HRESULT hr;
2425 WCHAR *dst;
2426 BYTE src[20];
2427 DBSTATUS dst_status;
2428 DBLENGTH dst_len;
2429 static const WCHAR ten[] = {'1','0',0};
2430 static const WCHAR fourthreetwoone[] = {'4','3','2','1',0};
2431 BSTR b;
2432 VARIANT v;
2434 VariantInit(&v);
2436 hr = IDataConvert_DataConvert(convert, DBTYPE_EMPTY, DBTYPE_BYREF | DBTYPE_WSTR, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
2437 ok(hr == S_OK, "got %08x\n", hr);
2438 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
2439 ok(dst_len == 0, "got %ld\n", dst_len);
2440 ok(dst[0] == 0, "got %04x\n", dst[0]);
2441 CoTaskMemFree(dst);
2443 dst = (void*)0x12345678;
2444 dst_len = 0x1234;
2445 hr = IDataConvert_DataConvert(convert, DBTYPE_NULL, DBTYPE_BYREF | DBTYPE_WSTR, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
2446 ok(hr == DB_E_UNSUPPORTEDCONVERSION, "got %08x\n", hr);
2447 ok(dst_status == DBSTATUS_E_BADACCESSOR, "got %08x\n", dst_status);
2448 ok(dst_len == 0x1234, "got %ld\n", dst_len);
2449 ok(dst == (void*)0x12345678, "got %p\n", dst);
2451 *(short *)src = 4321;
2452 dst_len = 0x1234;
2453 hr = IDataConvert_DataConvert(convert, DBTYPE_I2, DBTYPE_BYREF | DBTYPE_WSTR, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
2454 ok(hr == S_OK, "got %08x\n", hr);
2455 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
2456 ok(dst_len == 8, "got %ld\n", dst_len);
2457 ok(!lstrcmpW(dst, fourthreetwoone), "got %s\n", wine_dbgstr_w(dst));
2458 CoTaskMemFree(dst);
2460 *(short *)src = 4321;
2461 dst_len = 0x1234;
2462 hr = IDataConvert_DataConvert(convert, DBTYPE_I2, DBTYPE_BYREF | DBTYPE_WSTR, 0, &dst_len, src, &dst, 0, 0, &dst_status, 0, 0, 0);
2463 ok(hr == S_OK, "got %08x\n", hr);
2464 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
2465 ok(dst_len == 8, "got %ld\n", dst_len);
2466 ok(!lstrcmpW(dst, fourthreetwoone), "got %s\n", wine_dbgstr_w(dst));
2467 CoTaskMemFree(dst);
2469 b = SysAllocString(ten);
2470 *(BSTR *)src = b;
2471 dst_len = 0x1234;
2472 hr = IDataConvert_DataConvert(convert, DBTYPE_BSTR, DBTYPE_BYREF | DBTYPE_WSTR, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
2473 ok(hr == S_OK, "got %08x\n", hr);
2474 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
2475 ok(dst_len == 4, "got %ld\n", dst_len);
2476 ok(!lstrcmpW(b, dst), "got %s\n", wine_dbgstr_w(dst));
2477 CoTaskMemFree(dst);
2478 SysFreeString(b);
2480 memcpy(src, ten, sizeof(ten));
2481 dst_len = 0x1234;
2482 hr = IDataConvert_DataConvert(convert, DBTYPE_WSTR, DBTYPE_BYREF | DBTYPE_WSTR, 2, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
2483 ok(hr == S_OK, "got %08x\n", hr);
2484 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
2485 ok(dst_len == 2, "got %ld\n", dst_len);
2486 ok(dst[0] == '1', "got %02x\n", dst[0]);
2487 ok(dst[1] == 0, "got %02x\n", dst[1]);
2488 CoTaskMemFree(dst);
2490 memcpy(src, ten, sizeof(ten));
2491 dst_len = 0x1234;
2492 hr = IDataConvert_DataConvert(convert, DBTYPE_WSTR, DBTYPE_BYREF | DBTYPE_WSTR, 4, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
2493 ok(hr == S_OK, "got %08x\n", hr);
2494 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
2495 ok(dst_len == 4, "got %ld\n", dst_len);
2496 ok(!lstrcmpW(ten, dst), "got %s\n", wine_dbgstr_w(dst));
2497 CoTaskMemFree(dst);
2499 memcpy(src, ten, sizeof(ten));
2500 dst_len = 0x1234;
2501 hr = IDataConvert_DataConvert(convert, DBTYPE_WSTR, DBTYPE_BYREF | DBTYPE_WSTR, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, DBDATACONVERT_LENGTHFROMNTS);
2502 ok(hr == S_OK, "got %08x\n", hr);
2503 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
2504 ok(dst_len == 4, "got %ld\n", dst_len);
2505 ok(!lstrcmpW(ten, dst), "got %s\n", wine_dbgstr_w(dst));
2506 CoTaskMemFree(dst);
2508 dst_len = 44;
2509 V_VT(&v) = VT_NULL;
2510 hr = IDataConvert_DataConvert(convert, DBTYPE_VARIANT, DBTYPE_BYREF | DBTYPE_WSTR, 0, &dst_len, &v, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
2511 ok(hr == S_OK, "got %08x\n", hr);
2512 ok(dst_status == DBSTATUS_S_ISNULL, "got %08x\n", dst_status);
2513 ok(dst_len == 44, "got %ld\n", dst_len);
2516 static void test_converttobyrefstr(void)
2518 HRESULT hr;
2519 char *dst;
2520 BYTE src[20];
2521 DBSTATUS dst_status;
2522 DBLENGTH dst_len;
2523 static const WCHAR ten[] = {'1','0',0};
2524 static const char withnull[] = "test\0ed";
2525 BSTR b;
2526 VARIANT v;
2528 VariantInit(&v);
2530 hr = IDataConvert_DataConvert(convert, DBTYPE_EMPTY, DBTYPE_STR | DBTYPE_BYREF, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
2531 ok(hr == S_OK, "got %08x\n", hr);
2532 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
2533 ok(dst_len == 0, "got %ld\n", dst_len);
2534 ok(dst[0] == 0, "got %04x\n", dst[0]);
2535 CoTaskMemFree(dst);
2537 dst = (void*)0x12345678;
2538 dst_len = 0x1234;
2539 hr = IDataConvert_DataConvert(convert, DBTYPE_NULL, DBTYPE_STR | DBTYPE_BYREF, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
2540 ok(hr == DB_E_UNSUPPORTEDCONVERSION, "got %08x\n", hr);
2541 ok(dst_status == DBSTATUS_E_BADACCESSOR, "got %08x\n", dst_status);
2542 ok(dst_len == 0x1234, "got %ld\n", dst_len);
2543 ok(dst == (void*)0x12345678, "got %p\n", dst);
2545 *(short *)src = 4321;
2546 dst_len = 0x1234;
2547 hr = IDataConvert_DataConvert(convert, DBTYPE_I2, DBTYPE_STR | DBTYPE_BYREF, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
2548 ok(hr == S_OK, "got %08x\n", hr);
2549 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
2550 ok(dst_len == 4, "got %ld\n", dst_len);
2551 ok(!lstrcmpA(dst, "4321"), "got %s\n", dst);
2552 CoTaskMemFree(dst);
2554 *(short *)src = 4321;
2555 dst_len = 0x1234;
2556 hr = IDataConvert_DataConvert(convert, DBTYPE_I2, DBTYPE_STR | DBTYPE_BYREF, 0, &dst_len, src, &dst, 0, 0, &dst_status, 0, 0, 0);
2557 ok(hr == S_OK, "got %08x\n", hr);
2558 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
2559 ok(dst_len == 4, "got %ld\n", dst_len);
2560 ok(!lstrcmpA(dst, "4321"), "got %s\n", dst);
2561 CoTaskMemFree(dst);
2563 b = SysAllocString(ten);
2564 *(BSTR *)src = b;
2565 dst_len = 0x1234;
2566 hr = IDataConvert_DataConvert(convert, DBTYPE_BSTR, DBTYPE_STR | DBTYPE_BYREF, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
2567 ok(hr == S_OK, "got %08x\n", hr);
2568 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
2569 ok(dst_len == 2, "got %ld\n", dst_len);
2570 ok(!lstrcmpA("10", dst), "got %s\n", dst);
2571 CoTaskMemFree(dst);
2572 SysFreeString(b);
2574 memcpy(src, ten, sizeof(ten));
2575 dst_len = 0x1234;
2576 hr = IDataConvert_DataConvert(convert, DBTYPE_WSTR, DBTYPE_STR | DBTYPE_BYREF, 2, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
2577 ok(hr == S_OK, "got %08x\n", hr);
2578 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
2579 ok(dst_len == 1, "got %ld\n", dst_len);
2580 ok(dst[0] == '1', "got %02x\n", dst[0]);
2581 ok(dst[1] == 0, "got %02x\n", dst[1]);
2582 CoTaskMemFree(dst);
2584 memcpy(src, ten, sizeof(ten));
2585 dst_len = 0x1234;
2586 hr = IDataConvert_DataConvert(convert, DBTYPE_WSTR, DBTYPE_STR | DBTYPE_BYREF, 4, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
2587 ok(hr == S_OK, "got %08x\n", hr);
2588 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
2589 ok(dst_len == 2, "got %ld\n", dst_len);
2590 ok(!lstrcmpA("10", dst), "got %s\n", dst);
2591 CoTaskMemFree(dst);
2593 memcpy(src, ten, sizeof(ten));
2594 dst_len = 0x1234;
2595 hr = IDataConvert_DataConvert(convert, DBTYPE_WSTR, DBTYPE_STR | DBTYPE_BYREF, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, DBDATACONVERT_LENGTHFROMNTS);
2596 ok(hr == S_OK, "got %08x\n", hr);
2597 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
2598 ok(dst_len == 2, "got %ld\n", dst_len);
2599 ok(!lstrcmpA("10", dst), "got %s\n", dst);
2600 CoTaskMemFree(dst);
2602 memcpy(src, withnull, sizeof(withnull));
2603 dst_len = 0x1234;
2604 hr = IDataConvert_DataConvert(convert, DBTYPE_STR, DBTYPE_STR | DBTYPE_BYREF, sizeof(withnull), &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
2605 ok(hr == S_OK, "got %08x\n", hr);
2606 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
2607 ok(dst_len == 8, "got %ld\n", dst_len);
2608 ok(!memcmp(withnull, dst, 8), "got %s\n", dst);
2609 ok(dst[8] == 0, "got %02x\n", dst[8]);
2610 CoTaskMemFree(dst);
2612 memcpy(src, withnull, sizeof(withnull));
2613 dst_len = 0x1234;
2614 hr = IDataConvert_DataConvert(convert, DBTYPE_STR, DBTYPE_STR | DBTYPE_BYREF, 7, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
2615 ok(hr == S_OK, "got %08x\n", hr);
2616 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
2617 ok(dst_len == 7, "got %ld\n", dst_len);
2618 ok(!memcmp(withnull, dst, 7), "got %s\n", dst);
2619 ok(dst[7] == 0, "got %02x\n", dst[7]);
2620 CoTaskMemFree(dst);
2622 memcpy(src, withnull, sizeof(withnull));
2623 dst_len = 0x1234;
2624 hr = IDataConvert_DataConvert(convert, DBTYPE_STR, DBTYPE_STR | DBTYPE_BYREF, 6, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
2625 ok(hr == S_OK, "got %08x\n", hr);
2626 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
2627 ok(dst_len == 6, "got %ld\n", dst_len);
2628 ok(!memcmp(withnull, dst, 6), "got %s\n", dst);
2629 ok(dst[6] == 0, "got %02x\n", dst[6]);
2630 CoTaskMemFree(dst);
2633 dst_len = 44;
2634 V_VT(&v) = VT_NULL;
2635 hr = IDataConvert_DataConvert(convert, DBTYPE_VARIANT, DBTYPE_STR | DBTYPE_BYREF, 0, &dst_len, &v, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
2636 ok(hr == S_OK, "got %08x\n", hr);
2637 ok(dst_status == DBSTATUS_S_ISNULL, "got %08x\n", dst_status);
2638 ok(dst_len == 44, "got %ld\n", dst_len);
2641 static void test_converttoguid(void)
2643 HRESULT hr;
2644 GUID dst;
2645 BYTE src[20];
2646 DBSTATUS dst_status;
2647 DBLENGTH dst_len;
2648 VARIANT v;
2650 VariantInit(&v);
2652 dst = IID_IDCInfo;
2653 dst_len = 0x1234;
2654 hr = IDataConvert_DataConvert(convert, DBTYPE_EMPTY, DBTYPE_GUID, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
2655 ok(hr == S_OK, "got %08x\n", hr);
2656 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
2657 ok(dst_len == sizeof(GUID), "got %ld\n", dst_len);
2658 ok(IsEqualGUID(&dst, &GUID_NULL), "didn't get GUID_NULL\n");
2660 dst = IID_IDCInfo;
2661 dst_len = 0x1234;
2662 hr = IDataConvert_DataConvert(convert, DBTYPE_NULL, DBTYPE_GUID, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
2663 ok(hr == DB_E_UNSUPPORTEDCONVERSION, "got %08x\n", hr);
2664 ok(dst_status == DBSTATUS_E_BADACCESSOR, "got %08x\n", dst_status);
2665 ok(dst_len == 0x1234, "got %ld\n", dst_len);
2666 ok(IsEqualGUID(&dst, &IID_IDCInfo), "dst has changed\n");
2668 dst = IID_IDCInfo;
2669 memcpy(src, &IID_IDataConvert, sizeof(GUID));
2670 dst_len = 0x1234;
2671 hr = IDataConvert_DataConvert(convert, DBTYPE_GUID, DBTYPE_GUID, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
2672 ok(hr == S_OK, "got %08x\n", hr);
2673 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
2674 ok(dst_len == sizeof(GUID), "got %ld\n", dst_len);
2675 ok(IsEqualGUID(&dst, &IID_IDataConvert), "didn't get IID_IDataConvert\n");
2677 dst_len = 44;
2678 V_VT(&v) = VT_NULL;
2679 hr = IDataConvert_DataConvert(convert, DBTYPE_VARIANT, DBTYPE_GUID, 0, &dst_len, &v, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
2680 ok(hr == S_OK, "got %08x\n", hr);
2681 ok(dst_status == DBSTATUS_S_ISNULL, "got %08x\n", dst_status);
2682 ok(dst_len == 44, "got %ld\n", dst_len);
2685 static void test_converttofiletime(void)
2687 HRESULT hr;
2688 FILETIME dst;
2689 BYTE src[20];
2690 DBSTATUS dst_status;
2691 DBLENGTH dst_len;
2692 VARIANT v;
2694 VariantInit(&v);
2696 memset(&dst, 0xcc, sizeof(dst));
2697 ((FILETIME *)src)->dwLowDateTime = 0x12345678;
2698 ((FILETIME *)src)->dwHighDateTime = 0x9abcdef0;
2699 dst_len = 0x1234;
2700 hr = IDataConvert_DataConvert(convert, DBTYPE_FILETIME, DBTYPE_FILETIME, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
2701 ok(hr == S_OK ||
2702 broken(hr == DB_E_BADBINDINFO), /* win98 */
2703 "got %08x\n", hr);
2704 if(SUCCEEDED(hr))
2706 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
2707 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
2708 ok(dst.dwLowDateTime == 0x12345678, "got %08x\n", dst.dwLowDateTime);
2709 ok(dst.dwHighDateTime == 0x9abcdef0, "got %08x\n", dst.dwHighDateTime);
2712 dst_len = 44;
2713 V_VT(&v) = VT_NULL;
2714 hr = IDataConvert_DataConvert(convert, DBTYPE_VARIANT, DBTYPE_FILETIME, 0, &dst_len, &v, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
2715 ok(hr == S_OK, "got %08x\n", hr);
2716 ok(dst_status == DBSTATUS_S_ISNULL, "got %08x\n", dst_status);
2717 ok(dst_len == 44, "got %ld\n", dst_len);
2720 static void test_converttoui1(void)
2722 HRESULT hr;
2723 BYTE dst;
2724 BYTE src[20];
2725 DBSTATUS dst_status;
2726 DBLENGTH dst_len;
2727 VARIANT v;
2729 VariantInit(&v);
2731 dst = 0x12;
2732 dst_len = 0x1234;
2733 hr = IDataConvert_DataConvert(convert, DBTYPE_EMPTY, DBTYPE_UI1, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
2734 ok(hr == S_OK, "got %08x\n", hr);
2735 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
2736 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
2737 ok(dst == 0, "got %08x\n", dst);
2739 dst = 0x12;
2740 dst_len = 0x1234;
2741 hr = IDataConvert_DataConvert(convert, DBTYPE_NULL, DBTYPE_UI1, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
2742 ok(hr == DB_E_UNSUPPORTEDCONVERSION, "got %08x\n", hr);
2743 ok(dst_status == DBSTATUS_E_BADACCESSOR, "got %08x\n", dst_status);
2744 ok(dst_len == 0x1234, "got %ld\n", dst_len);
2745 ok(dst == 0x12, "got %08x\n", dst);
2747 dst = 0x12;
2748 src[0] = 0x43;
2749 dst_len = 0x1234;
2750 hr = IDataConvert_DataConvert(convert, DBTYPE_UI1, DBTYPE_UI1, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
2751 ok(hr == S_OK, "got %08x\n", hr);
2752 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
2753 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
2754 ok(dst == 0x43, "got %08x\n", dst);
2756 dst = 0x12;
2757 src[0] = 0xfe;
2758 dst_len = 0x1234;
2759 hr = IDataConvert_DataConvert(convert, DBTYPE_UI1, DBTYPE_UI1, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
2760 ok(hr == S_OK, "got %08x\n", hr);
2761 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
2762 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
2763 ok(dst == 0xfe, "got %08x\n", dst);
2765 dst_len = 44;
2766 V_VT(&v) = VT_NULL;
2767 hr = IDataConvert_DataConvert(convert, DBTYPE_VARIANT, DBTYPE_UI1, 0, &dst_len, &v, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
2768 ok(hr == S_OK, "got %08x\n", hr);
2769 ok(dst_status == DBSTATUS_S_ISNULL, "got %08x\n", dst_status);
2770 ok(dst_len == 44, "got %ld\n", dst_len);
2773 static void test_converttoui4(void)
2775 HRESULT hr;
2776 DWORD dst;
2777 BYTE src[20];
2778 DBSTATUS dst_status;
2779 DBLENGTH dst_len;
2781 dst = 0x12345678;
2782 dst_len = 0x1234;
2783 hr = IDataConvert_DataConvert(convert, DBTYPE_EMPTY, DBTYPE_UI4, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
2784 ok(hr == S_OK, "got %08x\n", hr);
2785 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
2786 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
2787 ok(dst == 0, "got %08x\n", dst);
2789 dst = 0x12345678;
2790 dst_len = 0x1234;
2791 hr = IDataConvert_DataConvert(convert, DBTYPE_NULL, DBTYPE_UI4, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
2792 ok(hr == DB_E_UNSUPPORTEDCONVERSION, "got %08x\n", hr);
2793 ok(dst_status == DBSTATUS_E_BADACCESSOR, "got %08x\n", dst_status);
2794 ok(dst_len == 0x1234, "got %ld\n", dst_len);
2795 ok(dst == 0x12345678, "got %08x\n", dst);
2797 dst = 0x12345678;
2798 *(DWORD*)src = 0x87654321;
2799 dst_len = 0x1234;
2800 hr = IDataConvert_DataConvert(convert, DBTYPE_UI4, DBTYPE_UI4, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
2801 ok(hr == S_OK, "got %08x\n", hr);
2802 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
2803 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
2804 ok(dst == 0x87654321, "got %08x\n", dst);
2806 dst = 0x12345678;
2807 *(signed short *)src = 0x4321;
2808 dst_len = 0x1234;
2809 hr = IDataConvert_DataConvert(convert, DBTYPE_I2, DBTYPE_UI4, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
2810 ok(hr == S_OK, "got %08x\n", hr);
2811 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
2812 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
2813 ok(dst == 0x4321, "got %08x\n", dst);
2815 dst = 0x12345678;
2816 *(signed short *)src = -1;
2817 dst_len = 0x1234;
2818 hr = IDataConvert_DataConvert(convert, DBTYPE_I2, DBTYPE_UI4, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
2819 ok(hr == DB_E_ERRORSOCCURRED, "got %08x\n", hr);
2820 todo_wine
2821 ok(dst_status == DBSTATUS_E_SIGNMISMATCH, "got %08x\n", dst_status);
2822 todo_wine
2823 ok(broken(dst_len == sizeof(dst)) || dst_len == 0x1234 /* W2K+ */, "got %ld\n", dst_len);
2824 ok(dst == 0x12345678, "got %08x\n", dst);
2826 dst_len = dst = 0x1234;
2827 V_VT((VARIANT*)src) = VT_I2;
2828 V_I2((VARIANT*)src) = 0x4321;
2829 hr = IDataConvert_DataConvert(convert, DBTYPE_VARIANT, DBTYPE_UI4, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
2830 ok(hr == S_OK, "got %08x\n", hr);
2831 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
2832 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
2833 ok(dst == 0x4321, "got %08x\n", dst);
2835 dst_len = 44;
2836 V_VT((VARIANT*)src) = VT_NULL;
2837 hr = IDataConvert_DataConvert(convert, DBTYPE_VARIANT, DBTYPE_UI4, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
2838 ok(hr == S_OK, "got %08x\n", hr);
2839 ok(dst_status == DBSTATUS_S_ISNULL, "got %08x\n", dst_status);
2840 ok(dst_len == 44, "got %ld\n", dst_len);
2843 static void test_converttor4(void)
2845 HRESULT hr;
2846 FLOAT dst;
2847 BYTE src[20];
2848 DBSTATUS dst_status;
2849 DBLENGTH dst_len;
2850 VARIANT v;
2852 VariantInit(&v);
2854 dst = 1.0;
2855 dst_len = 0x1234;
2856 hr = IDataConvert_DataConvert(convert, DBTYPE_EMPTY, DBTYPE_R4, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
2857 ok(hr == S_OK, "got %08x\n", hr);
2858 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
2859 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
2860 ok(dst == 0.0, "got %f\n", dst);
2862 dst = 1.0;
2863 dst_len = 0x1234;
2864 hr = IDataConvert_DataConvert(convert, DBTYPE_NULL, DBTYPE_R4, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
2865 ok(hr == DB_E_UNSUPPORTEDCONVERSION, "got %08x\n", hr);
2866 ok(dst_status == DBSTATUS_E_BADACCESSOR, "got %08x\n", dst_status);
2867 ok(dst_len == 0x1234, "got %ld\n", dst_len);
2868 ok(dst == 1.0, "got %f\n", dst);
2870 dst = 1.0;
2871 *(signed int*)src = 12345678;
2872 dst_len = 0x1234;
2873 hr = IDataConvert_DataConvert(convert, DBTYPE_I4, DBTYPE_R4, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
2874 ok(hr == S_OK, "got %08x\n", hr);
2875 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
2876 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
2877 ok(dst == 12345678.0, "got %f\n", dst);
2879 dst = 1.0;
2880 *(FLOAT *)src = 10.0;
2881 dst_len = 0x1234;
2882 hr = IDataConvert_DataConvert(convert, DBTYPE_R4, DBTYPE_R4, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
2883 ok(hr == S_OK, "got %08x\n", hr);
2884 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
2885 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
2886 ok(dst == 10.0, "got %f\n", dst);
2888 dst_len = 44;
2889 V_VT(&v) = VT_NULL;
2890 hr = IDataConvert_DataConvert(convert, DBTYPE_VARIANT, DBTYPE_R4, 0, &dst_len, &v, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
2891 ok(hr == S_OK, "got %08x\n", hr);
2892 ok(dst_status == DBSTATUS_S_ISNULL, "got %08x\n", dst_status);
2893 ok(dst_len == 44, "got %ld\n", dst_len);
2895 dst_len = dst = 0x1234;
2896 V_VT(&v) = VT_I2;
2897 V_I2(&v) = 0x4321;
2898 hr = IDataConvert_DataConvert(convert, DBTYPE_VARIANT, DBTYPE_R4, 0, &dst_len, &v, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
2899 ok(hr == S_OK, "got %08x\n", hr);
2900 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
2901 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
2902 ok(dst == 0x4321, "got %f\n", dst);
2905 static void test_converttor8(void)
2907 HRESULT hr;
2908 DOUBLE dst;
2909 BYTE src[20];
2910 DBSTATUS dst_status;
2911 DBLENGTH dst_len;
2912 VARIANT var;
2914 dst = 1.0;
2915 dst_len = 0x1234;
2916 hr = IDataConvert_DataConvert(convert, DBTYPE_EMPTY, DBTYPE_R8, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
2917 ok(hr == S_OK, "got %08x\n", hr);
2918 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
2919 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
2920 ok(dst == 0.0, "got %f\n", dst);
2922 dst = 1.0;
2923 dst_len = 0x1234;
2924 hr = IDataConvert_DataConvert(convert, DBTYPE_NULL, DBTYPE_R8, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
2925 ok(hr == DB_E_UNSUPPORTEDCONVERSION, "got %08x\n", hr);
2926 ok(dst_status == DBSTATUS_E_BADACCESSOR, "got %08x\n", dst_status);
2927 ok(dst_len == 0x1234, "got %ld\n", dst_len);
2928 ok(dst == 1.0, "got %f\n", dst);
2930 dst = 1.0;
2931 *(signed int*)src = 12345678;
2932 dst_len = 0x1234;
2933 hr = IDataConvert_DataConvert(convert, DBTYPE_I4, DBTYPE_R8, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
2934 ok(hr == S_OK, "got %08x\n", hr);
2935 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
2936 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
2937 ok(dst == 12345678.0, "got %f\n", dst);
2939 dst = 1.0;
2940 *(FLOAT *)src = 10.0;
2941 dst_len = 0x1234;
2942 hr = IDataConvert_DataConvert(convert, DBTYPE_R4, DBTYPE_R8, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
2943 ok(hr == S_OK, "got %08x\n", hr);
2944 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
2945 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
2946 ok(dst == 10.0, "got %f\n", dst);
2948 dst_len = dst = 0x1234;
2949 V_VT(&var) = VT_I2;
2950 V_I2(&var) = 0x4321;
2951 hr = IDataConvert_DataConvert(convert, DBTYPE_VARIANT, DBTYPE_R8, 0, &dst_len, &var, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
2952 ok(hr == S_OK, "got %08x\n", hr);
2953 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
2954 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
2955 ok(dst == 0x4321, "got %f\n", dst);
2957 dst_len = 44;
2958 V_VT(&var) = VT_NULL;
2959 hr = IDataConvert_DataConvert(convert, DBTYPE_VARIANT, DBTYPE_R8, 0, &dst_len, &var, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
2960 ok(hr == S_OK, "got %08x\n", hr);
2961 ok(dst_status == DBSTATUS_S_ISNULL, "got %08x\n", dst_status);
2962 ok(dst_len == 44, "got %ld\n", dst_len);
2965 static void test_converttocy(void)
2967 HRESULT hr;
2968 CY dst;
2969 BYTE src[20];
2970 DBSTATUS dst_status;
2971 DBLENGTH dst_len;
2972 VARIANT v;
2974 VariantInit(&v);
2976 dst.int64 = 0xcc;
2977 dst_len = 0x1234;
2978 hr = IDataConvert_DataConvert(convert, DBTYPE_EMPTY, DBTYPE_CY, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
2979 ok(hr == S_OK, "got %08x\n", hr);
2980 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
2981 ok(dst_len == sizeof(CY), "got %ld\n", dst_len);
2982 ok(dst.int64 == 0, "didn't get 0\n");
2984 dst.int64 = 0xcc;
2985 dst_len = 0x1234;
2986 hr = IDataConvert_DataConvert(convert, DBTYPE_NULL, DBTYPE_CY, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
2987 ok(hr == DB_E_UNSUPPORTEDCONVERSION, "got %08x\n", hr);
2988 ok(dst_status == DBSTATUS_E_BADACCESSOR, "got %08x\n", dst_status);
2989 ok(dst_len == 0x1234, "got %ld\n", dst_len);
2990 ok(dst.int64 == 0xcc, "dst changed\n");
2992 dst.int64 = 0xcc;
2993 *(int*)src = 1234;
2994 dst_len = 0x1234;
2995 hr = IDataConvert_DataConvert(convert, DBTYPE_I4, DBTYPE_CY, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
2996 ok(hr == S_OK, "got %08x\n", hr);
2997 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
2998 ok(dst_len == sizeof(CY), "got %ld\n", dst_len);
2999 ok(dst.int64 == 12340000, "got %d\n", dst.s.Lo);
3001 dst.int64 = 0xcc;
3002 ((CY*)src)->int64 = 1234;
3003 dst_len = 0x1234;
3004 hr = IDataConvert_DataConvert(convert, DBTYPE_CY, DBTYPE_CY, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
3005 ok(hr == S_OK, "got %08x\n", hr);
3006 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
3007 ok(dst_len == sizeof(CY), "got %ld\n", dst_len);
3008 ok(dst.int64 == 1234, "got %d\n", dst.s.Lo);
3010 dst_len = 44;
3011 V_VT(&v) = VT_NULL;
3012 hr = IDataConvert_DataConvert(convert, DBTYPE_VARIANT, DBTYPE_CY, 0, &dst_len, &v, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
3013 ok(hr == S_OK, "got %08x\n", hr);
3014 ok(dst_status == DBSTATUS_S_ISNULL, "got %08x\n", dst_status);
3015 ok(dst_len == 44, "got %ld\n", dst_len);
3018 static void test_converttoui8(void)
3020 HRESULT hr;
3021 ULARGE_INTEGER dst;
3022 BYTE src[20];
3023 DBSTATUS dst_status;
3024 DBLENGTH dst_len;
3025 VARIANT v;
3027 VariantInit(&v);
3029 dst.QuadPart = 0xcc;
3030 dst_len = 0x1234;
3031 hr = IDataConvert_DataConvert(convert, DBTYPE_EMPTY, DBTYPE_UI8, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
3032 ok(hr == S_OK, "got %08x\n", hr);
3033 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
3034 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
3035 ok(dst.QuadPart == 0, "got %d\n", (int)dst.QuadPart);
3037 dst.QuadPart = 0xcc;
3038 dst_len = 0x1234;
3039 hr = IDataConvert_DataConvert(convert, DBTYPE_NULL, DBTYPE_UI8, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
3040 ok(hr == DB_E_UNSUPPORTEDCONVERSION, "got %08x\n", hr);
3041 ok(dst_status == DBSTATUS_E_BADACCESSOR, "got %08x\n", dst_status);
3042 ok(dst_len == 0x1234, "got %ld\n", dst_len);
3043 ok(dst.QuadPart == 0xcc, "dst changed\n");
3045 dst.QuadPart = 0xcc;
3046 *(int*)src = 1234;
3047 dst_len = 0x1234;
3048 hr = IDataConvert_DataConvert(convert, DBTYPE_I4, DBTYPE_UI8, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
3049 ok(hr == S_OK, "got %08x\n", hr);
3050 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
3051 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
3052 ok(dst.QuadPart == 1234, "got %d\n", (int)dst.QuadPart);
3054 dst.QuadPart = 0xcc;
3055 *(int*)src = -1234;
3056 dst_len = 0x1234;
3057 hr = IDataConvert_DataConvert(convert, DBTYPE_I4, DBTYPE_UI8, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
3058 ok(hr == DB_E_ERRORSOCCURRED, "got %08x\n", hr);
3059 todo_wine
3060 ok(dst_status == DBSTATUS_E_SIGNMISMATCH, "got %08x\n", dst_status);
3061 todo_wine
3062 ok(dst_len == 0x1234, "got %ld\n", dst_len);
3063 ok(dst.QuadPart == 0xcc, "got %d\n", (int)dst.QuadPart);
3065 dst.QuadPart = 0xcc;
3066 ((ULARGE_INTEGER*)src)->QuadPart = 1234;
3067 dst_len = 0x1234;
3068 hr = IDataConvert_DataConvert(convert, DBTYPE_UI8, DBTYPE_UI8, 0, &dst_len, src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
3069 ok(hr == S_OK, "got %08x\n", hr);
3070 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
3071 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
3072 ok(dst.QuadPart == 1234, "got %d\n", (int)dst.QuadPart);
3074 dst_len = 44;
3075 V_VT(&v) = VT_NULL;
3076 hr = IDataConvert_DataConvert(convert, DBTYPE_VARIANT, DBTYPE_UI8, 0, &dst_len, &v, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
3077 ok(hr == S_OK, "got %08x\n", hr);
3078 ok(dst_status == DBSTATUS_S_ISNULL, "got %08x\n", dst_status);
3079 ok(dst_len == 44, "got %ld\n", dst_len);
3082 static void test_getconversionsize(void)
3084 DBLENGTH dst_len;
3085 DBLENGTH src_len;
3086 HRESULT hr;
3087 BSTR str;
3088 static WCHAR strW[] = {'t','e','s','t',0};
3089 static char strTest[] = "test";
3090 VARIANT var;
3091 SAFEARRAY *psa = NULL;
3092 SAFEARRAYBOUND rgsabound[1];
3093 int i4 = 200;
3094 WORD i2 = 201;
3095 char i1 = (char)203;
3096 FLOAT f4 = 1.0;
3097 LONGLONG i8 = 202;
3098 DATE dbdate;
3099 DECIMAL dec;
3100 DBTIMESTAMP ts = {2013, 5, 14, 2, 4, 12, 0};
3101 DBTIME dbtime;
3102 DBDATE dbdate1;
3104 /* same way as CanConvert fails here */
3105 dst_len = 0;
3106 hr = IDataConvert_GetConversionSize(convert, DBTYPE_NULL, DBTYPE_BSTR, NULL, &dst_len, NULL);
3107 ok(hr == DB_E_UNSUPPORTEDCONVERSION, "got 0x%08x\n", hr);
3109 dst_len = 0;
3110 hr = IDataConvert_GetConversionSize(convert, DBTYPE_I2, DBTYPE_I4, NULL, &dst_len, NULL);
3111 ok(hr == S_OK, "got 0x%08x\n", hr);
3112 ok(dst_len == 4, "got %ld\n", dst_len);
3114 hr = IDataConvert_GetConversionSize(convert, DBTYPE_I2, DBTYPE_I4, NULL, NULL, NULL);
3115 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
3117 /* size doesn't include string size */
3118 str = SysAllocStringLen(NULL, 10);
3119 dst_len = 0;
3120 hr = IDataConvert_GetConversionSize(convert, DBTYPE_BSTR, DBTYPE_VARIANT, NULL, &dst_len, str);
3121 ok(hr == S_OK, "got 0x%08x\n", hr);
3122 ok(dst_len == sizeof(VARIANT), "%ld\n", dst_len);
3123 SysFreeString(str);
3125 dst_len = 0;
3126 hr = IDataConvert_GetConversionSize(convert, DBTYPE_WSTR, DBTYPE_WSTR, NULL, &dst_len, strW);
3127 ok(hr == S_OK, "got 0x%08x\n", hr);
3128 ok(dst_len == 10, "%ld\n", dst_len);
3130 dst_len = 0;
3131 src_len = 2;
3132 hr = IDataConvert_GetConversionSize(convert, DBTYPE_WSTR, DBTYPE_WSTR, &src_len, &dst_len, strW);
3133 ok(hr == S_OK, "got 0x%08x\n", hr);
3134 ok(dst_len == 4, "%ld\n", dst_len);
3136 dst_len = 0;
3137 src_len = 20;
3138 hr = IDataConvert_GetConversionSize(convert, DBTYPE_WSTR, DBTYPE_WSTR, &src_len, &dst_len, strW);
3139 ok(hr == S_OK, "got 0x%08x\n", hr);
3140 ok(dst_len == 22, "%ld\n", dst_len);
3142 dst_len = 0;
3143 hr = IDataConvert_GetConversionSize(convert, DBTYPE_STR, DBTYPE_WSTR, NULL, &dst_len, strTest);
3144 ok(hr == S_OK, "got 0x%08x\n", hr);
3145 ok(dst_len == 10 || broken(dst_len == 12), "%ld\n", dst_len);
3147 dst_len = 0;
3148 src_len = 2;
3149 hr = IDataConvert_GetConversionSize(convert, DBTYPE_STR, DBTYPE_WSTR, &src_len, &dst_len, strTest);
3150 ok(hr == S_OK, "got 0x%08x\n", hr);
3151 ok(dst_len == 6, "%ld\n", dst_len);
3153 dst_len = 0;
3154 src_len = 20;
3155 hr = IDataConvert_GetConversionSize(convert, DBTYPE_STR, DBTYPE_WSTR, &src_len, &dst_len, strTest);
3156 ok(hr == S_OK, "got 0x%08x\n", hr);
3157 ok(dst_len == 42, "%ld\n", dst_len);
3159 dst_len = 0;
3160 V_VT(&var) = VT_BSTR;
3161 V_BSTR(&var) = SysAllocString(strW);
3162 hr = IDataConvert_GetConversionSize(convert, DBTYPE_VARIANT, DBTYPE_WSTR, NULL, &dst_len, &var);
3163 ok(hr == S_OK, "got 0x%08x\n", hr);
3164 ok(dst_len == 10, "%ld\n", dst_len);
3165 VariantClear(&var);
3167 dst_len = 0;
3168 src_len = 20;
3169 V_VT(&var) = VT_BSTR;
3170 V_BSTR(&var) = SysAllocString(strW);
3171 hr = IDataConvert_GetConversionSize(convert, DBTYPE_VARIANT, DBTYPE_WSTR, &src_len, &dst_len, &var);
3172 ok(hr == S_OK, "got 0x%08x\n", hr);
3173 ok(dst_len == 10, "%ld\n", dst_len);
3174 VariantClear(&var);
3176 dst_len = 0;
3177 src_len = 20;
3178 V_VT(&var) = VT_I4;
3179 V_I4(&var) = 4;
3180 hr = IDataConvert_GetConversionSize(convert, DBTYPE_VARIANT, DBTYPE_WSTR, &src_len, &dst_len, &var);
3181 ok(hr == S_OK, "got 0x%08x\n", hr);
3182 VariantClear(&var);
3184 dst_len = 0;
3185 src_len = 20;
3186 V_VT(&var) = VT_BSTR;
3187 V_BSTR(&var) = SysAllocString(strW);
3188 hr = IDataConvert_GetConversionSize(convert, DBTYPE_VARIANT, DBTYPE_STR, &src_len, &dst_len, &var);
3189 ok(hr == S_OK, "got 0x%08x\n", hr);
3190 ok(dst_len == 5, "%ld\n", dst_len);
3191 VariantClear(&var);
3193 src_len = 20;
3194 V_VT(&var) = VT_I4;
3195 V_I4(&var) = 4;
3196 hr = IDataConvert_GetConversionSize(convert, DBTYPE_VARIANT, DBTYPE_STR, &src_len, &dst_len, &var);
3197 ok(hr == S_OK, "got 0x%08x\n", hr);
3198 VariantClear(&var);
3200 dst_len = 0;
3201 src_len = 20;
3202 V_VT(&var) = VT_BSTR;
3203 V_BSTR(&var) = SysAllocString(strW);
3204 hr = IDataConvert_GetConversionSize(convert, DBTYPE_VARIANT, DBTYPE_BYTES, &src_len, &dst_len, &var);
3205 ok(hr == S_OK, "got 0x%08x\n", hr);
3206 ok(dst_len == 2, "%ld\n", dst_len);
3207 VariantClear(&var);
3209 dst_len = 0;
3210 src_len = 20;
3211 rgsabound[0].lLbound = 0;
3212 rgsabound[0].cElements = 1802;
3213 psa = SafeArrayCreate(VT_UI1,1,rgsabound);
3215 V_VT(&var) = VT_ARRAY|VT_UI1;
3216 V_ARRAY(&var) = psa;
3217 hr = IDataConvert_GetConversionSize(convert, DBTYPE_VARIANT, DBTYPE_BYTES, &src_len, &dst_len, &var);
3218 ok(hr == S_OK, "got 0x%08x\n", hr);
3219 ok(dst_len == 1802, "%ld\n", dst_len);
3220 VariantClear(&var);
3222 /* On Windows, NULL variants being convert to a non-fixed sized type will return a dst_len of
3223 * 110 but we aren't testing for this value.
3225 dst_len = 32;
3226 V_VT(&var) = VT_NULL;
3227 hr = IDataConvert_GetConversionSize(convert, DBTYPE_VARIANT, DBTYPE_I4, NULL, &dst_len, &var);
3228 ok(dst_len == 4, "%ld\n", dst_len);
3229 ok(hr == S_OK, "got 0x%08x\n", hr);
3231 V_VT(&var) = VT_NULL;
3232 hr = IDataConvert_GetConversionSize(convert, DBTYPE_VARIANT, DBTYPE_STR, NULL, &dst_len, &var);
3233 ok(hr == S_OK, "got 0x%08x\n", hr);
3234 ok(dst_len == 110, "%ld\n", dst_len);
3236 V_VT(&var) = VT_NULL;
3237 hr = IDataConvert_GetConversionSize(convert, DBTYPE_VARIANT, DBTYPE_WSTR, NULL, &dst_len, &var);
3238 ok(hr == S_OK, "got 0x%08x\n", hr);
3239 ok(dst_len == 110, "%ld\n", dst_len);
3241 src_len = 20;
3242 V_VT(&var) = VT_NULL;
3243 hr = IDataConvert_GetConversionSize(convert, DBTYPE_VARIANT, DBTYPE_BYTES, &src_len, &dst_len, &var);
3244 ok(hr == S_OK, "got 0x%08x\n", hr);
3245 ok(dst_len == 110, "%ld\n", dst_len);
3246 VariantClear(&var);
3248 hr = IDataConvert_GetConversionSize(convert, DBTYPE_NUMERIC, DBTYPE_NUMERIC, NULL, &dst_len, NULL);
3249 ok(hr == S_OK, "got 0x%08x\n", hr);
3250 ok(dst_len == sizeof(DB_NUMERIC), "%ld\n", dst_len);
3252 dst_len = 0;
3253 src_len = sizeof(i4);
3254 hr = IDataConvert_GetConversionSize(convert, DBTYPE_I4, DBTYPE_WSTR, &src_len, &dst_len, &i4);
3255 ok(hr == S_OK, "got 0x%08x\n", hr);
3256 ok(dst_len == 110, "%ld\n", dst_len);
3258 dst_len = 0;
3259 hr = IDataConvert_GetConversionSize(convert, DBTYPE_I4, DBTYPE_WSTR, NULL, &dst_len, NULL);
3260 ok(hr == S_OK, "got 0x%08x\n", hr);
3261 ok(dst_len == 110, "%ld\n", dst_len);
3263 dst_len = 0;
3264 src_len = sizeof(i4);
3265 hr = IDataConvert_GetConversionSize(convert, DBTYPE_UI4, DBTYPE_WSTR, &src_len, &dst_len, &i4);
3266 ok(hr == S_OK, "got 0x%08x\n", hr);
3267 ok(dst_len == 110, "%ld\n", dst_len);
3269 dst_len = 0;
3270 hr = IDataConvert_GetConversionSize(convert, DBTYPE_UI4, DBTYPE_WSTR, NULL, &dst_len, NULL);
3271 ok(hr == S_OK, "got 0x%08x\n", hr);
3272 ok(dst_len == 110, "%ld\n", dst_len);
3274 dst_len = 0;
3275 src_len = sizeof(i2);
3276 hr = IDataConvert_GetConversionSize(convert, DBTYPE_I2, DBTYPE_WSTR, &src_len, &dst_len, &i2);
3277 ok(hr == S_OK, "got 0x%08x\n", hr);
3278 ok(dst_len == 110, "%ld\n", dst_len);
3280 dst_len = 0;
3281 hr = IDataConvert_GetConversionSize(convert, DBTYPE_I2, DBTYPE_WSTR, NULL, &dst_len, NULL);
3282 ok(hr == S_OK, "got 0x%08x\n", hr);
3283 ok(dst_len == 110, "%ld\n", dst_len);
3285 dst_len = 0;
3286 src_len = sizeof(i2);
3287 hr = IDataConvert_GetConversionSize(convert, DBTYPE_UI2, DBTYPE_WSTR, &src_len, &dst_len, &i2);
3288 ok(hr == S_OK, "got 0x%08x\n", hr);
3289 ok(dst_len == 110, "%ld\n", dst_len);
3291 dst_len = 0;
3292 src_len = sizeof(i1);
3293 hr = IDataConvert_GetConversionSize(convert, DBTYPE_I1, DBTYPE_WSTR, &src_len, &dst_len, &i1);
3294 ok(hr == S_OK, "got 0x%08x\n", hr);
3295 ok(dst_len == 110, "%ld\n", dst_len);
3297 dst_len = 0;
3298 hr = IDataConvert_GetConversionSize(convert, DBTYPE_I1, DBTYPE_WSTR, NULL, &dst_len, NULL);
3299 ok(hr == S_OK, "got 0x%08x\n", hr);
3300 ok(dst_len == 110, "%ld\n", dst_len);
3302 dst_len = 0;
3303 src_len = sizeof(i2);
3304 hr = IDataConvert_GetConversionSize(convert, DBTYPE_UI2, DBTYPE_WSTR, &src_len, &dst_len, &i2);
3305 ok(hr == S_OK, "got 0x%08x\n", hr);
3306 ok(dst_len == 110, "%ld\n", dst_len);
3308 dst_len = 0;
3309 hr = IDataConvert_GetConversionSize(convert, DBTYPE_UI2, DBTYPE_WSTR, NULL, &dst_len, NULL);
3310 ok(hr == S_OK, "got 0x%08x\n", hr);
3311 ok(dst_len == 110, "%ld\n", dst_len);
3313 dst_len = 0;
3314 src_len = sizeof(f4);
3315 hr = IDataConvert_GetConversionSize(convert, DBTYPE_R4, DBTYPE_WSTR, &src_len, &dst_len, &f4);
3316 ok(hr == S_OK, "got 0x%08x\n", hr);
3317 ok(dst_len == 110, "%ld\n", dst_len);
3319 dst_len = 0;
3320 hr = IDataConvert_GetConversionSize(convert, DBTYPE_R4, DBTYPE_WSTR, NULL, &dst_len, NULL);
3321 ok(hr == S_OK, "got 0x%08x\n", hr);
3322 ok(dst_len == 110, "%ld\n", dst_len);
3324 dst_len = 0;
3325 src_len = sizeof(i8);
3326 hr = IDataConvert_GetConversionSize(convert, DBTYPE_UI8, DBTYPE_WSTR, &src_len, &dst_len, &i8);
3327 ok(hr == S_OK, "got 0x%08x\n", hr);
3328 ok(dst_len == 110, "%ld\n", dst_len);
3330 dst_len = 0;
3331 hr = IDataConvert_GetConversionSize(convert, DBTYPE_UI8, DBTYPE_WSTR, NULL, &dst_len, NULL);
3332 ok(hr == S_OK, "got 0x%08x\n", hr);
3333 ok(dst_len == 110, "%ld\n", dst_len);
3335 dst_len = 0;
3336 src_len = sizeof(i8);
3337 hr = IDataConvert_GetConversionSize(convert, DBTYPE_I8, DBTYPE_WSTR, &src_len, &dst_len, &i8);
3338 ok(hr == S_OK, "got 0x%08x\n", hr);
3339 ok(dst_len == 110, "%ld\n", dst_len);
3341 dst_len = 0;
3342 hr = IDataConvert_GetConversionSize(convert, DBTYPE_I8, DBTYPE_WSTR, NULL, &dst_len, NULL);
3343 ok(hr == S_OK, "got 0x%08x\n", hr);
3344 ok(dst_len == 110, "%ld\n", dst_len);
3346 dst_len = 0;
3347 src_len = sizeof(dbdate);
3348 hr = IDataConvert_GetConversionSize(convert, DBTYPE_DATE, DBTYPE_WSTR, &src_len, &dst_len, &dbdate);
3349 ok(hr == S_OK, "got 0x%08x\n", hr);
3350 ok(dst_len == 110, "%ld\n", dst_len);
3352 dst_len = 0;
3353 hr = IDataConvert_GetConversionSize(convert, DBTYPE_DATE, DBTYPE_WSTR, NULL, &dst_len, NULL);
3354 ok(hr == S_OK, "got 0x%08x\n", hr);
3355 ok(dst_len == 110, "%ld\n", dst_len);
3357 dst_len = 0;
3358 src_len = sizeof(dec);
3359 hr = IDataConvert_GetConversionSize(convert, DBTYPE_DECIMAL, DBTYPE_WSTR, &src_len, &dst_len, &dec);
3360 ok(hr == S_OK, "got 0x%08x\n", hr);
3361 ok(dst_len == 110, "%ld\n", dst_len);
3363 dst_len = 0;
3364 hr = IDataConvert_GetConversionSize(convert, DBTYPE_DECIMAL, DBTYPE_WSTR, NULL, &dst_len, NULL);
3365 ok(hr == S_OK, "got 0x%08x\n", hr);
3366 ok(dst_len == 110, "%ld\n", dst_len);
3368 dst_len = 0;
3369 hr = IDataConvert_GetConversionSize(convert, DBTYPE_EMPTY, DBTYPE_WSTR, NULL, &dst_len, NULL);
3370 ok(hr == S_OK, "got 0x%08x\n", hr);
3371 ok(dst_len == 110, "%ld\n", dst_len);
3373 dst_len = 0;
3374 src_len = sizeof(ts);
3375 hr = IDataConvert_GetConversionSize(convert, DBTYPE_DBTIMESTAMP, DBTYPE_WSTR, &src_len, &dst_len, &ts);
3376 ok(hr == S_OK, "got 0x%08x\n", hr);
3377 ok(dst_len == 110, "%ld\n", dst_len);
3379 dst_len = 0;
3380 hr = IDataConvert_GetConversionSize(convert, DBTYPE_DBTIMESTAMP, DBTYPE_WSTR, NULL, &dst_len, NULL);
3381 ok(hr == S_OK, "got 0x%08x\n", hr);
3382 ok(dst_len == 110, "%ld\n", dst_len);
3384 dst_len = 0;
3385 src_len = sizeof(dbtime);
3386 hr = IDataConvert_GetConversionSize(convert, DBTYPE_DBTIME, DBTYPE_WSTR, &src_len, &dst_len, &dbtime);
3387 ok(hr == S_OK, "got 0x%08x\n", hr);
3388 ok(dst_len == 110, "%ld\n", dst_len);
3390 dst_len = 0;
3391 hr = IDataConvert_GetConversionSize(convert, DBTYPE_DBTIME, DBTYPE_WSTR, NULL, &dst_len, NULL);
3392 ok(hr == S_OK, "got 0x%08x\n", hr);
3393 ok(dst_len == 110, "%ld\n", dst_len);
3395 dst_len = 0;
3396 src_len = sizeof(dbdate1);
3397 hr = IDataConvert_GetConversionSize(convert, DBTYPE_DBDATE, DBTYPE_WSTR, &src_len, &dst_len, &dbdate1);
3398 ok(hr == S_OK, "got 0x%08x\n", hr);
3399 ok(dst_len == 110, "%ld\n", dst_len);
3401 dst_len = 0;
3402 hr = IDataConvert_GetConversionSize(convert, DBTYPE_DBDATE, DBTYPE_WSTR, NULL, &dst_len, NULL);
3403 ok(hr == S_OK, "got 0x%08x\n", hr);
3404 ok(dst_len == 110, "%ld\n", dst_len);
3406 dst_len = 0;
3407 src_len = sizeof(i4);
3408 hr = IDataConvert_GetConversionSize(convert, DBTYPE_I4, DBTYPE_STR, &src_len, &dst_len, &i4);
3409 ok(hr == S_OK, "got 0x%08x\n", hr);
3410 ok(dst_len == 110, "%ld\n", dst_len);
3412 dst_len = 0;
3413 hr = IDataConvert_GetConversionSize(convert, DBTYPE_I4, DBTYPE_STR, NULL, &dst_len, NULL);
3414 ok(hr == S_OK, "got 0x%08x\n", hr);
3415 ok(dst_len == 110, "%ld\n", dst_len);
3417 dst_len = 0;
3418 src_len = sizeof(i4);
3419 hr = IDataConvert_GetConversionSize(convert, DBTYPE_UI4, DBTYPE_STR, &src_len, &dst_len, &i4);
3420 ok(hr == S_OK, "got 0x%08x\n", hr);
3421 ok(dst_len == 110, "%ld\n", dst_len);
3423 dst_len = 0;
3424 hr = IDataConvert_GetConversionSize(convert, DBTYPE_UI4, DBTYPE_STR, NULL, &dst_len, NULL);
3425 ok(hr == S_OK, "got 0x%08x\n", hr);
3426 ok(dst_len == 110, "%ld\n", dst_len);
3428 dst_len = 0;
3429 src_len = sizeof(i2);
3430 hr = IDataConvert_GetConversionSize(convert, DBTYPE_I2, DBTYPE_STR, &src_len, &dst_len, &i2);
3431 ok(hr == S_OK, "got 0x%08x\n", hr);
3432 ok(dst_len == 110, "%ld\n", dst_len);
3434 dst_len = 0;
3435 hr = IDataConvert_GetConversionSize(convert, DBTYPE_I2, DBTYPE_STR, NULL, &dst_len, NULL);
3436 ok(hr == S_OK, "got 0x%08x\n", hr);
3437 ok(dst_len == 110, "%ld\n", dst_len);
3439 dst_len = 0;
3440 src_len = sizeof(i2);
3441 hr = IDataConvert_GetConversionSize(convert, DBTYPE_UI2, DBTYPE_STR, &src_len, &dst_len, &i2);
3442 ok(hr == S_OK, "got 0x%08x\n", hr);
3443 ok(dst_len == 110, "%ld\n", dst_len);
3445 dst_len = 0;
3446 src_len = sizeof(i1);
3447 hr = IDataConvert_GetConversionSize(convert, DBTYPE_I1, DBTYPE_STR, &src_len, &dst_len, &i1);
3448 ok(hr == S_OK, "got 0x%08x\n", hr);
3449 ok(dst_len == 110, "%ld\n", dst_len);
3451 dst_len = 0;
3452 hr = IDataConvert_GetConversionSize(convert, DBTYPE_I1, DBTYPE_STR, NULL, &dst_len, NULL);
3453 ok(hr == S_OK, "got 0x%08x\n", hr);
3454 ok(dst_len == 110, "%ld\n", dst_len);
3456 dst_len = 0;
3457 src_len = sizeof(i2);
3458 hr = IDataConvert_GetConversionSize(convert, DBTYPE_UI2, DBTYPE_STR, &src_len, &dst_len, &i2);
3459 ok(hr == S_OK, "got 0x%08x\n", hr);
3460 ok(dst_len == 110, "%ld\n", dst_len);
3462 dst_len = 0;
3463 hr = IDataConvert_GetConversionSize(convert, DBTYPE_UI2, DBTYPE_STR, NULL, &dst_len, NULL);
3464 ok(hr == S_OK, "got 0x%08x\n", hr);
3465 ok(dst_len == 110, "%ld\n", dst_len);
3467 dst_len = 0;
3468 src_len = sizeof(f4);
3469 hr = IDataConvert_GetConversionSize(convert, DBTYPE_R4, DBTYPE_STR, &src_len, &dst_len, &f4);
3470 ok(hr == S_OK, "got 0x%08x\n", hr);
3471 ok(dst_len == 110, "%ld\n", dst_len);
3473 dst_len = 0;
3474 hr = IDataConvert_GetConversionSize(convert, DBTYPE_R4, DBTYPE_STR, NULL, &dst_len, NULL);
3475 ok(hr == S_OK, "got 0x%08x\n", hr);
3476 ok(dst_len == 110, "%ld\n", dst_len);
3478 dst_len = 0;
3479 src_len = sizeof(i8);
3480 hr = IDataConvert_GetConversionSize(convert, DBTYPE_UI8, DBTYPE_STR, &src_len, &dst_len, &i8);
3481 ok(hr == S_OK, "got 0x%08x\n", hr);
3482 ok(dst_len == 110, "%ld\n", dst_len);
3484 dst_len = 0;
3485 hr = IDataConvert_GetConversionSize(convert, DBTYPE_UI8, DBTYPE_STR, NULL, &dst_len, NULL);
3486 ok(hr == S_OK, "got 0x%08x\n", hr);
3487 ok(dst_len == 110, "%ld\n", dst_len);
3489 dst_len = 0;
3490 src_len = sizeof(i8);
3491 hr = IDataConvert_GetConversionSize(convert, DBTYPE_I8, DBTYPE_STR, &src_len, &dst_len, &i8);
3492 ok(hr == S_OK, "got 0x%08x\n", hr);
3493 ok(dst_len == 110, "%ld\n", dst_len);
3495 dst_len = 0;
3496 hr = IDataConvert_GetConversionSize(convert, DBTYPE_I8, DBTYPE_STR, NULL, &dst_len, NULL);
3497 ok(hr == S_OK, "got 0x%08x\n", hr);
3498 ok(dst_len == 110, "%ld\n", dst_len);
3500 dst_len = 0;
3501 src_len = sizeof(dbdate);
3502 hr = IDataConvert_GetConversionSize(convert, DBTYPE_DATE, DBTYPE_STR, &src_len, &dst_len, &dbdate);
3503 ok(hr == S_OK, "got 0x%08x\n", hr);
3504 ok(dst_len == 110, "%ld\n", dst_len);
3506 dst_len = 0;
3507 hr = IDataConvert_GetConversionSize(convert, DBTYPE_DATE, DBTYPE_STR, NULL, &dst_len, NULL);
3508 ok(hr == S_OK, "got 0x%08x\n", hr);
3509 ok(dst_len == 110, "%ld\n", dst_len);
3511 dst_len = 0;
3512 src_len = sizeof(dec);
3513 hr = IDataConvert_GetConversionSize(convert, DBTYPE_DECIMAL, DBTYPE_STR, &src_len, &dst_len, &dec);
3514 ok(hr == S_OK, "got 0x%08x\n", hr);
3515 ok(dst_len == 110, "%ld\n", dst_len);
3517 dst_len = 0;
3518 hr = IDataConvert_GetConversionSize(convert, DBTYPE_DECIMAL, DBTYPE_STR, NULL, &dst_len, NULL);
3519 ok(hr == S_OK, "got 0x%08x\n", hr);
3520 ok(dst_len == 110, "%ld\n", dst_len);
3522 dst_len = 0;
3523 hr = IDataConvert_GetConversionSize(convert, DBTYPE_EMPTY, DBTYPE_STR, NULL, &dst_len, NULL);
3524 ok(hr == S_OK, "got 0x%08x\n", hr);
3525 ok(dst_len == 110, "%ld\n", dst_len);
3527 dst_len = 0;
3528 src_len = sizeof(ts);
3529 hr = IDataConvert_GetConversionSize(convert, DBTYPE_DBTIMESTAMP, DBTYPE_STR, &src_len, &dst_len, &ts);
3530 ok(hr == S_OK, "got 0x%08x\n", hr);
3531 ok(dst_len == 110, "%ld\n", dst_len);
3533 dst_len = 0;
3534 hr = IDataConvert_GetConversionSize(convert, DBTYPE_DBTIMESTAMP, DBTYPE_STR, NULL, &dst_len, NULL);
3535 ok(hr == S_OK, "got 0x%08x\n", hr);
3536 ok(dst_len == 110, "%ld\n", dst_len);
3538 dst_len = 0;
3539 src_len = sizeof(dbtime);
3540 hr = IDataConvert_GetConversionSize(convert, DBTYPE_DBTIME, DBTYPE_STR, &src_len, &dst_len, &dbtime);
3541 ok(hr == S_OK, "got 0x%08x\n", hr);
3542 ok(dst_len == 110, "%ld\n", dst_len);
3544 dst_len = 0;
3545 hr = IDataConvert_GetConversionSize(convert, DBTYPE_DBTIME, DBTYPE_STR, NULL, &dst_len, NULL);
3546 ok(hr == S_OK, "got 0x%08x\n", hr);
3547 ok(dst_len == 110, "%ld\n", dst_len);
3549 dst_len = 0;
3550 src_len = sizeof(dbdate1);
3551 hr = IDataConvert_GetConversionSize(convert, DBTYPE_DBDATE, DBTYPE_STR, &src_len, &dst_len, &dbdate1);
3552 ok(hr == S_OK, "got 0x%08x\n", hr);
3553 ok(dst_len == 110, "%ld\n", dst_len);
3555 dst_len = 0;
3556 hr = IDataConvert_GetConversionSize(convert, DBTYPE_DBDATE, DBTYPE_STR, NULL, &dst_len, NULL);
3557 ok(hr == S_OK, "got 0x%08x\n", hr);
3558 ok(dst_len == 110, "%ld\n", dst_len);
3561 static void test_converttobytes(void)
3563 DBLENGTH dst_len;
3564 HRESULT hr;
3565 BYTE byte_src[] = {0, 1, 2, 4, 5};
3566 BYTE byte_dst[] = {0, 0, 0, 0, 0};
3567 BYTE dst[10] = {0};
3568 DBSTATUS dst_status;
3569 VARIANT v;
3570 SAFEARRAY *psa = NULL;
3571 SAFEARRAYBOUND rgsabound[1];
3573 dst_len = 0;
3574 hr = IDataConvert_DataConvert(convert, DBTYPE_BYTES, DBTYPE_BYTES, sizeof(byte_src), &dst_len, byte_src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
3575 ok(hr == S_OK, "got %08x\n", hr);
3576 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
3577 ok(dst_len == sizeof(byte_src), "got %ld\n", dst_len);
3578 ok(!memcmp(byte_src, dst, dst_len ), "bytes differ\n");
3580 dst_len = 0;
3581 hr = IDataConvert_DataConvert(convert, DBTYPE_BYTES, DBTYPE_BYTES, sizeof(byte_src), &dst_len, byte_src, &dst, 2, 0, &dst_status, 0, 0, 0);
3582 ok(hr == S_OK, "got %08x\n", hr);
3583 ok(dst_status == DBSTATUS_S_TRUNCATED, "got %08x\n", dst_status);
3584 ok(dst_len == sizeof(byte_src), "got %ld\n", dst_len);
3585 ok(!memcmp(byte_src, dst, 2 ), "bytes differ\n");
3587 V_VT(&v) = VT_NULL;
3588 dst_len = 77;
3589 hr = IDataConvert_DataConvert(convert, DBTYPE_VARIANT, DBTYPE_BYTES, sizeof(v), &dst_len, &v, &dst, 2, 0, &dst_status, 0, 0, 0);
3590 ok(hr == S_OK, "got %08x\n", hr);
3591 ok(dst_status == DBSTATUS_S_ISNULL, "got %08x\n", dst_status);
3592 ok(dst_len == 77, "got %ld\n", dst_len);
3594 dst_len = 0;
3595 rgsabound[0].lLbound = 0;
3596 rgsabound[0].cElements = 4;
3597 psa = SafeArrayCreate(VT_UI1,1,rgsabound);
3599 V_VT(&v) = VT_ARRAY|VT_UI1;
3600 V_ARRAY(&v) = psa;
3601 hr = IDataConvert_DataConvert(convert, DBTYPE_VARIANT, DBTYPE_BYTES, sizeof(v), &dst_len, &v, &dst, 10, 0, &dst_status, 0, 0, 0);
3602 ok(hr == S_OK, "got 0x%08x\n", hr);
3603 ok(dst_len == 4, "%ld\n", dst_len);
3604 ok(!memcmp(byte_dst, dst, dst_len), "bytes differ\n");
3605 VariantClear(&v);
3607 dst_len = 44;
3608 V_VT(&v) = VT_NULL;
3609 hr = IDataConvert_DataConvert(convert, DBTYPE_VARIANT, DBTYPE_BYTES, 0, &dst_len, &v, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
3610 ok(hr == S_OK, "got %08x\n", hr);
3611 ok(dst_status == DBSTATUS_S_ISNULL, "got %08x\n", dst_status);
3612 ok(dst_len == 44, "got %ld\n", dst_len);
3616 static void test_converttobytesbyref(void)
3618 DBLENGTH dst_len;
3619 HRESULT hr;
3620 BYTE byte_src[] = {0, 1, 2, 4, 5};
3621 BYTE *dst;
3622 DBSTATUS dst_status;
3623 VARIANT v;
3625 VariantInit(&v);
3627 dst_len = 0;
3628 hr = IDataConvert_DataConvert(convert, DBTYPE_BYTES, DBTYPE_BYTES | DBTYPE_BYREF, sizeof(byte_src), &dst_len, byte_src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
3629 ok(hr == S_OK, "got %08x\n", hr);
3630 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
3631 ok(dst_len == sizeof(byte_src), "got %ld\n", dst_len);
3632 ok(!memcmp(byte_src, dst, dst_len ), "bytes differ\n");
3633 CoTaskMemFree(dst);
3635 dst_len = 44;
3636 V_VT(&v) = VT_NULL;
3637 hr = IDataConvert_DataConvert(convert, DBTYPE_VARIANT, DBTYPE_BYTES | DBTYPE_BYREF, 0, &dst_len, &v, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
3638 ok(hr == S_OK, "got %08x\n", hr);
3639 ok(dst_status == DBSTATUS_S_ISNULL, "got %08x\n", dst_status);
3640 ok(dst_len == 44, "got %ld\n", dst_len);
3643 static void test_converttodbdate(void)
3645 DBLENGTH dst_len;
3646 HRESULT hr;
3647 static const WCHAR strW[] = {'2','0','1','3','-','0','5','-','1','4',0};
3648 DBDATE ts = {2013, 5, 14};
3649 DBDATE dst;
3650 DBSTATUS dst_status;
3651 VARIANT var;
3652 BSTR bstr;
3654 dst_len = 0;
3655 hr = IDataConvert_DataConvert(convert, DBTYPE_DBDATE, DBTYPE_DBDATE, sizeof(ts), &dst_len, &ts, &dst, 2, 0, &dst_status, 0, 0, 0);
3656 ok(hr == S_OK, "got %08x\n", hr);
3657 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
3658 ok(dst_len == sizeof(DBDATE), "got %ld\n", dst_len);
3659 ok(!memcmp(&ts, &dst, sizeof(DBDATE) ), "bytes differ\n");
3661 VariantInit(&var);
3662 V_VT(&var) = VT_DATE;
3663 V_DATE(&var) = 41408.086250;
3664 dst_len = 0;
3665 hr = IDataConvert_DataConvert(convert, DBTYPE_VARIANT, DBTYPE_DBDATE, sizeof(var), &dst_len, &var, &dst, 2, 0, &dst_status, 0, 0, 0);
3666 ok(hr == S_OK, "got %08x\n", hr);
3667 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
3668 ok(dst_len == sizeof(DBDATE), "got %ld\n", dst_len);
3669 ok(!memcmp(&ts, &dst, sizeof(DBDATE) ), "bytes differ\n");
3671 V_VT(&var) = VT_R8;
3672 V_R8(&var) = 41408.086250;
3673 dst_len = 0;
3674 hr = IDataConvert_DataConvert(convert, DBTYPE_VARIANT, DBTYPE_DBDATE, sizeof(var), &dst_len, &var, &dst, 2, 0, &dst_status, 0, 0, 0);
3675 ok(hr == S_OK, "got %08x\n", hr);
3676 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
3677 ok(dst_len == sizeof(DBDATE), "got %ld\n", dst_len);
3678 ok(!memcmp(&ts, &dst, sizeof(DBDATE) ), "bytes differ\n");
3680 V_VT(&var) = VT_BSTR;
3681 V_BSTR(&var) = SysAllocString(strW);
3682 dst_len = 0;
3683 hr = IDataConvert_DataConvert(convert, DBTYPE_VARIANT, DBTYPE_DBDATE, sizeof(var), &dst_len, &var, &dst, 2, 0, &dst_status, 0, 0, 0);
3684 ok(hr == S_OK, "got %08x\n", hr);
3685 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
3686 ok(dst_len == sizeof(DBDATE), "got %ld\n", dst_len);
3687 ok(!memcmp(&ts, &dst, sizeof(DBDATE) ), "bytes differ\n");
3688 VariantClear(&var);
3690 dst_len = 0;
3691 bstr = SysAllocString(strW);
3692 hr = IDataConvert_DataConvert(convert, DBTYPE_BSTR, DBTYPE_DBDATE, 0, &dst_len, &bstr, &dst, 2, 0, &dst_status, 0, 0, 0);
3693 ok(hr == S_OK, "got %08x\n", hr);
3694 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
3695 ok(dst_len == sizeof(DBDATE), "got %ld\n", dst_len);
3696 ok(!memcmp(&ts, &dst, sizeof(DBDATE) ), "bytes differ\n");
3697 SysFreeString(bstr);
3699 V_VT(&var) = VT_NULL;
3700 dst_len = 88;
3701 hr = IDataConvert_DataConvert(convert, DBTYPE_VARIANT, DBTYPE_DBDATE, sizeof(var), &dst_len, &var, &dst, 2, 0, &dst_status, 0, 0, 0);
3702 ok(hr == S_OK, "got %08x\n", hr);
3703 ok(dst_status == DBSTATUS_S_ISNULL, "got %08x\n", dst_status);
3704 ok(dst_len == 88, "got %ld\n", dst_len);
3708 static void test_converttovar(void)
3710 static WCHAR strW[] = {'t','e','s','t',0};
3711 BYTE byte_src[5] = {1, 2, 3, 4, 5};
3712 DBTIMESTAMP ts = {2013, 5, 14, 2, 4, 12, 0};
3713 DBDATE dbdate = {2013, 5, 15};
3714 double dvalue = 123.56;
3715 DBSTATUS dst_status;
3716 DBLENGTH dst_len;
3717 VARIANT dst;
3718 HRESULT hr;
3719 CY cy, cy2;
3720 DATE date;
3721 INT i4;
3722 signed short i2;
3723 LARGE_INTEGER i8;
3724 VARIANT_BOOL boolean = VARIANT_TRUE;
3725 FLOAT fvalue = 543.21f;
3726 VARIANT var;
3728 VariantInit(&var);
3730 V_VT(&dst) = VT_EMPTY;
3731 dst_len = 0;
3732 dst_status = DBSTATUS_S_DEFAULT;
3733 hr = IDataConvert_DataConvert(convert, DBTYPE_WSTR, DBTYPE_VARIANT, sizeof(strW), &dst_len, strW, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
3734 ok(hr == S_OK, "got %08x\n", hr);
3735 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
3736 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
3737 ok(V_VT(&dst) == VT_BSTR, "got %d\n", V_VT(&dst));
3738 ok(!lstrcmpW(V_BSTR(&dst), strW), "got %s\n", wine_dbgstr_w(V_BSTR(&dst)));
3739 VariantClear(&dst);
3741 /* with null dest length and status */
3742 V_VT(&dst) = VT_EMPTY;
3743 hr = IDataConvert_DataConvert(convert, DBTYPE_WSTR, DBTYPE_VARIANT, sizeof(strW), NULL, strW, &dst, sizeof(dst), 0, NULL, 0, 0, 0);
3744 ok(hr == S_OK, "got %08x\n", hr);
3745 ok(V_VT(&dst) == VT_BSTR, "got %d\n", V_VT(&dst));
3746 ok(!lstrcmpW(V_BSTR(&dst), strW), "got %s\n", wine_dbgstr_w(V_BSTR(&dst)));
3747 VariantClear(&dst);
3749 V_VT(&dst) = VT_EMPTY;
3750 dst_status = DBSTATUS_S_DEFAULT;
3751 i8.QuadPart = 12345;
3752 dst_len = 0x1234;
3753 hr = IDataConvert_DataConvert(convert, DBTYPE_I8, DBTYPE_VARIANT, sizeof(i8), &dst_len, &i8, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
3754 ok(hr == S_OK, "got %08x\n", hr);
3755 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
3756 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
3757 ok(V_VT(&dst) == VT_DECIMAL, "got %d\n", V_VT(&dst));
3758 ok(S(U(V_DECIMAL(&dst))).scale == 0 && S(U(V_DECIMAL(&dst))).sign == 0 &&
3759 V_DECIMAL(&dst).Hi32 == 0 && U1(V_DECIMAL(&dst)).Lo64 == 12345, "Not Equal\n");
3761 V_VT(&dst) = VT_EMPTY;
3762 dst_len = 0;
3763 dst_status = DBSTATUS_S_DEFAULT;
3764 hr = IDataConvert_DataConvert(convert, DBTYPE_R4, DBTYPE_VARIANT, sizeof(fvalue), &dst_len, &fvalue, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
3765 ok(hr == S_OK, "got %08x\n", hr);
3766 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
3767 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
3768 ok(V_VT(&dst) == VT_R4, "got %d\n", V_VT(&dst));
3769 ok(V_R4(&dst) == 543.21f, "got %f\n", V_R4(&dst));
3771 V_VT(&dst) = VT_EMPTY;
3772 dst_len = 0;
3773 dst_status = DBSTATUS_S_DEFAULT;
3774 hr = IDataConvert_DataConvert(convert, DBTYPE_R8, DBTYPE_VARIANT, sizeof(dvalue), &dst_len, &dvalue, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
3775 ok(hr == S_OK, "got %08x\n", hr);
3776 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
3777 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
3778 ok(V_VT(&dst) == VT_R8, "got %d\n", V_VT(&dst));
3779 ok(V_R8(&dst) == 123.56, "got %f\n", V_R8(&dst));
3781 V_VT(&dst) = VT_EMPTY;
3782 dst_len = 0;
3783 dst_status = DBSTATUS_S_DEFAULT;
3784 hr = IDataConvert_DataConvert(convert, DBTYPE_BOOL, DBTYPE_VARIANT, sizeof(boolean), &dst_len, &boolean, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
3785 ok(hr == S_OK, "got %08x\n", hr);
3786 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
3787 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
3788 ok(V_VT(&dst) == VT_BOOL, "got %d\n", V_VT(&dst));
3789 ok(V_BOOL(&dst) == VARIANT_TRUE, "got %d\n", V_BOOL(&dst));
3791 V_VT(&dst) = VT_EMPTY;
3792 dst_len = 0;
3793 dst_status = DBSTATUS_S_DEFAULT;
3794 i4 = 123;
3795 hr = IDataConvert_DataConvert(convert, DBTYPE_I4, DBTYPE_VARIANT, sizeof(i4), &dst_len, &i4, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
3796 ok(hr == S_OK, "got %08x\n", hr);
3797 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
3798 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
3799 ok(V_VT(&dst) == VT_I4, "got %d\n", V_VT(&dst));
3800 ok(V_I4(&dst) == 123, "got %d\n", V_I4(&dst));
3802 V_VT(&dst) = VT_EMPTY;
3803 dst_len = 0;
3804 dst_status = DBSTATUS_S_DEFAULT;
3805 i2 = 123;
3806 hr = IDataConvert_DataConvert(convert, DBTYPE_I2, DBTYPE_VARIANT, sizeof(i2), &dst_len, &i2, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
3807 ok(hr == S_OK, "got %08x\n", hr);
3808 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
3809 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
3810 ok(V_VT(&dst) == VT_I2, "got %d\n", V_VT(&dst));
3811 ok(V_I2(&dst) == 123, "got %d\n", V_I2(&dst));
3813 V_VT(&dst) = VT_EMPTY;
3814 dst_len = 0;
3815 dst_status = DBSTATUS_S_DEFAULT;
3816 date = 123.123;
3817 hr = IDataConvert_DataConvert(convert, DBTYPE_DATE, DBTYPE_VARIANT, sizeof(date), &dst_len, &date, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
3818 ok(hr == S_OK, "got %08x\n", hr);
3819 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
3820 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
3821 ok(V_VT(&dst) == VT_DATE, "got %d\n", V_VT(&dst));
3822 ok(V_DATE(&dst) == 123.123, "got %f\n", V_DATE(&dst));
3824 V_VT(&dst) = VT_EMPTY;
3825 dst_len = 0;
3826 dst_status = DBSTATUS_S_DEFAULT;
3827 S(cy).Lo = 1;
3828 S(cy).Hi = 2;
3829 hr = IDataConvert_DataConvert(convert, DBTYPE_CY, DBTYPE_VARIANT, sizeof(cy), &dst_len, &cy, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
3830 ok(hr == S_OK, "got %08x\n", hr);
3831 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
3832 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
3833 ok(V_VT(&dst) == VT_CY, "got %d\n", V_VT(&dst));
3835 cy2 = V_CY(&dst);
3836 ok(S(cy2).Lo == S(cy).Lo && S(cy2).Hi == S(cy).Hi, "got %d,%d\n", S(cy2).Lo, S(cy2).Hi);
3838 dst_len = 0x1234;
3839 hr = IDataConvert_DataConvert(convert, DBTYPE_BYTES, DBTYPE_VARIANT, sizeof(byte_src), &dst_len, &byte_src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
3840 ok(hr == S_OK, "got %08x\n", hr);
3841 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
3842 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
3843 ok(V_VT(&dst) == (VT_ARRAY|VT_UI1), "got %d\n", V_VT(&dst));
3844 if(V_VT(&dst) == (VT_ARRAY|VT_UI1))
3846 LONG l;
3848 hr = SafeArrayGetUBound(V_ARRAY(&dst), 1, &l);
3849 ok(hr == S_OK, "got %08x\n", hr);
3850 ok(l == 4, "got %d\n", l); /* 5 elements */
3852 VariantClear(&dst);
3854 dst_len = 0x1234;
3855 hr = IDataConvert_DataConvert(convert, DBTYPE_BYTES, DBTYPE_VARIANT, 0, &dst_len, &byte_src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
3856 ok(hr == S_OK, "got %08x\n", hr);
3857 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
3858 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
3859 ok(V_VT(&dst) == (VT_ARRAY|VT_UI1), "got %d\n", V_VT(&dst));
3860 if(V_VT(&dst) == (VT_ARRAY|VT_UI1))
3862 LONG l;
3864 hr = SafeArrayGetUBound(V_ARRAY(&dst), 1, &l);
3865 ok(hr == S_OK, "got %08x\n", hr);
3866 ok(l == -1, "got %d\n", l); /* 0 elements */
3868 VariantClear(&dst);
3870 dst_len = 0x1234;
3871 hr = IDataConvert_DataConvert(convert, DBTYPE_BYTES, DBTYPE_VARIANT, 2, &dst_len, &byte_src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
3872 ok(hr == S_OK, "got %08x\n", hr);
3873 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
3874 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
3875 ok(V_VT(&dst) == (VT_ARRAY|VT_UI1), "got %d\n", V_VT(&dst));
3876 if(V_VT(&dst) == (VT_ARRAY|VT_UI1))
3878 LONG l;
3880 hr = SafeArrayGetUBound(V_ARRAY(&dst), 1, &l);
3881 ok(hr == S_OK, "got %08x\n", hr);
3882 ok(l == 1, "got %d\n", l); /* 2 elements */
3884 VariantClear(&dst);
3886 dst_len = 0x1234;
3887 hr = IDataConvert_DataConvert(convert, DBTYPE_DBTIMESTAMP, DBTYPE_VARIANT, 0, &dst_len, &ts, &dst, sizeof(ts), 0, &dst_status, 0, 0, 0);
3888 ok(hr == S_OK, "got %08x\n", hr);
3889 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
3890 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
3891 ok(V_VT(&dst) == VT_DATE, "got %d\n", V_VT(&dst));
3892 ok( (float)V_DATE(&dst) == 41408.086250f, "got %f\n", V_DATE(&dst));
3894 dst_len = 0x1234;
3895 hr = IDataConvert_DataConvert(convert, DBTYPE_DBDATE, DBTYPE_VARIANT, 0, &dst_len, &dbdate, &dst, sizeof(dbdate), 0, &dst_status, 0, 0, 0);
3896 ok(hr == S_OK, "got %08x\n", hr);
3897 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
3898 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
3899 ok(V_VT(&dst) == VT_DATE, "got %d\n", V_VT(&dst));
3900 ok( (float)V_DATE(&dst) == 41409.0, "got %f\n", V_DATE(&dst));
3902 /* src_status = DBSTATUS_S_ISNULL */
3903 i4 = 123;
3904 dst_len = 99;
3905 hr = IDataConvert_DataConvert(convert, DBTYPE_I4, DBTYPE_VARIANT, sizeof(i4), &dst_len, &i4, &dst, sizeof(dst), DBSTATUS_S_ISNULL, &dst_status, 0, 0, 0);
3906 ok(hr == S_OK, "got %08x\n", hr);
3907 ok(dst_status == DBSTATUS_S_ISNULL, "got %08x\n", dst_status);
3908 ok(dst_len == 0, "got %ld\n", dst_len);
3910 dst_len = 44;
3911 V_VT(&var) = VT_NULL;
3912 hr = IDataConvert_DataConvert(convert, DBTYPE_VARIANT, DBTYPE_VARIANT, 0, &dst_len, &var, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
3913 ok(hr == S_OK, "got %08x\n", hr);
3914 ok(dst_status == DBSTATUS_S_ISNULL, "got %08x\n", dst_status);
3915 ok(dst_len == sizeof(VARIANT), "got %ld\n", dst_len);
3919 static void test_converttotimestamp(void)
3921 static const WCHAR strW[] = {'2','0','1','3','-','0','5','-','1','4',' ','0','2',':','0','4',':','1','2',0};
3922 static const WCHAR strFullW[] = {'2','0','1','3','-','0','5','-','1','4',' ','0','2',':','0','4',':','1','2',
3923 '.','0','1','7','0','0','0','0','0','0',0};
3924 DBTIMESTAMP ts = {2013, 5, 14, 2, 4, 12, 0};
3925 DBTIMESTAMP ts1 = {2013, 5, 14, 2, 4, 12, 17000000};
3926 DATE date;
3927 DBTIMESTAMP dst;
3928 DBSTATUS dst_status;
3929 DBLENGTH dst_len;
3930 VARIANT var;
3931 HRESULT hr;
3932 BSTR bstr;
3934 VariantInit(&var);
3935 V_VT(&var) = VT_DATE;
3936 V_DATE(&var) = 41408.086250;
3937 dst_len = 0x1234;
3938 hr = IDataConvert_DataConvert(convert, DBTYPE_VARIANT, DBTYPE_DBTIMESTAMP, 0, &dst_len, &var, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
3939 ok(hr == S_OK, "got %08x\n", hr);
3940 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
3941 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
3942 ok(!memcmp(&ts, &dst, sizeof(ts)), "Wrong timestamp\n");
3944 bstr = SysAllocString(strW);
3945 dst_len = 0x1234;
3946 hr = IDataConvert_DataConvert(convert, DBTYPE_BSTR, DBTYPE_DBTIMESTAMP, 0, &dst_len, &bstr, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
3947 ok(hr == S_OK, "got %08x\n", hr);
3948 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
3949 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
3950 ok(!memcmp(&ts, &dst, sizeof(ts)), "Wrong timestamp\n");
3951 SysFreeString(bstr);
3953 bstr = SysAllocString(strFullW);
3954 dst_len = 0x1234;
3955 hr = IDataConvert_DataConvert(convert, DBTYPE_BSTR, DBTYPE_DBTIMESTAMP, 0, &dst_len, &bstr, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
3956 ok(hr == S_OK, "got %08x\n", hr);
3957 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
3958 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
3959 ok(!memcmp(&ts1, &dst, sizeof(ts1)), "Wrong timestamp\n");
3960 SysFreeString(bstr);
3962 bstr = SysAllocString(L"2013-05-14 02:04:12.017000000");
3963 dst_len = 0x1234;
3964 hr = IDataConvert_DataConvert(convert, DBTYPE_BSTR, DBTYPE_DBTIMESTAMP, 0, &dst_len, &bstr, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
3965 ok(hr == S_OK, "got %08x\n", hr);
3966 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
3967 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
3968 ok(!memcmp(&ts1, &dst, sizeof(ts1)), "Wrong timestamp\n");
3969 SysFreeString(bstr);
3971 bstr = SysAllocString(L"2013/05/14 02:04:12.01700");
3972 dst_len = 0x1234;
3973 hr = IDataConvert_DataConvert(convert, DBTYPE_BSTR, DBTYPE_DBTIMESTAMP, 0, &dst_len, &bstr, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
3974 ok(hr == DISP_E_TYPEMISMATCH, "got %08x\n", hr);
3975 ok(dst_status == DBSTATUS_E_CANTCONVERTVALUE, "got %08x\n", dst_status);
3976 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
3977 SysFreeString(bstr);
3979 V_VT(&var) = VT_NULL;
3980 dst_len = 77;
3981 hr = IDataConvert_DataConvert(convert, DBTYPE_VARIANT, DBTYPE_DBTIMESTAMP, sizeof(var), &dst_len, &var, &dst, 2, 0, &dst_status, 0, 0, 0);
3982 ok(hr == S_OK, "got %08x\n", hr);
3983 ok(dst_status == DBSTATUS_S_ISNULL, "got %08x\n", dst_status);
3984 ok(dst_len == 77, "got %ld\n", dst_len);
3986 dst_len = 0x1234;
3987 date = 41408.086250;
3988 hr = IDataConvert_DataConvert(convert, DBTYPE_DATE, DBTYPE_DBTIMESTAMP, 0, &dst_len, &date, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
3989 ok(hr == S_OK, "got %08x\n", hr);
3990 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
3991 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
3992 ok(!memcmp(&ts, &dst, sizeof(ts)), "Wrong timestamp\n");
3995 static void test_converttoiunknown(void)
3997 HRESULT hr;
3998 DBSTATUS dst_status;
3999 DBLENGTH dst_len;
4000 IUnknown *dst = NULL;
4001 static WCHAR strW[] = {'t','e','s','t',0};
4002 VARIANT var;
4004 VariantInit(&var);
4006 dst_len = 0x1234;
4007 hr = IDataConvert_DataConvert(convert, DBTYPE_WSTR, DBTYPE_IUNKNOWN, sizeof(strW), &dst_len, strW, dst, sizeof(dst), DBSTATUS_S_ISNULL, &dst_status, 0, 0, 0);
4008 ok(hr == S_OK, "got %08x\n", hr);
4009 ok(dst_status == DBSTATUS_S_ISNULL, "got %08x\n", dst_status);
4010 ok(dst_len == 0, "got %ld\n", dst_len);
4012 dst_len = 44;
4013 V_VT(&var) = VT_NULL;
4014 hr = IDataConvert_DataConvert(convert, DBTYPE_VARIANT, DBTYPE_IUNKNOWN, 0, &dst_len, &var, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
4015 ok(hr == S_OK, "got %08x\n", hr);
4016 ok(dst_status == DBSTATUS_S_ISNULL, "got %08x\n", dst_status);
4017 ok(dst_len == 44, "got %ld\n", dst_len);
4020 #define test_numeric_val(current, expected) _test_numeric_val(__LINE__, current, expected);
4021 static inline void _test_numeric_val(unsigned line, DB_NUMERIC *current, DB_NUMERIC *expected)
4023 int same = !memcmp(current, expected, sizeof(DB_NUMERIC));
4024 ok_(__FILE__,line) (same, "Invalid byte array\n");
4025 if(!same)
4027 int i;
4028 for(i=0; i < sizeof(current->val); i++)
4029 ok_(__FILE__,line) (current->val[i] == expected->val[i], " byte %d got 0x%02x expected 0x%02x\n", i, current->val[i], expected->val[i]);
4033 static void test_converttonumeric(void)
4035 HRESULT hr;
4036 DBSTATUS dst_status;
4037 DBLENGTH dst_len;
4038 DB_NUMERIC dst;
4039 static WCHAR strW[] = {'1','2','3','.','4','5',0};
4040 static WCHAR largeW[] = {'1','2','3','4','5','6','7','8','9','0',0};
4041 INT i;
4042 BSTR bstr;
4043 FLOAT fvalue = 543.21f;
4044 VARIANT_BOOL boolean = VARIANT_TRUE;
4045 VARIANT var;
4046 LARGE_INTEGER i8;
4047 DB_NUMERIC result1 = { 10, 0, 1, {0x02, 0x10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }; /* 4098 */
4048 DB_NUMERIC result2 = { 10, 0, 1, {0x39, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }; /* 12345 */
4049 DB_NUMERIC result3 = { 10, 0, 0, {0x01, 0x00, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }; /* -1 */
4050 DB_NUMERIC result4 = { 10, 0, 1, {0x1f, 0x02, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }; /* 543.21 */
4051 DB_NUMERIC result5 = { 10, 0, 1, {0x7b, 0x00, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }; /* 123.45 */
4052 DB_NUMERIC result6 = { 10, 0, 1, {0xd2, 0x02, 0x96, 0x49, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }; /* 123456789 */
4054 VariantInit(&var);
4056 i = 4098;
4057 dst_len = 0x1234;
4058 dst.scale = 30;
4059 memset(dst.val, 0xfe, sizeof(dst.val));
4060 hr = IDataConvert_DataConvert(convert, DBTYPE_I4, DBTYPE_NUMERIC, 0, &dst_len, &i, &dst, sizeof(dst), 0, &dst_status, 10, 0, 0);
4061 todo_wine ok(hr == S_OK, "got %08x\n", hr);
4062 todo_wine ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
4063 todo_wine ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
4064 todo_wine test_numeric_val(&dst, &result1);
4066 i8.QuadPart = 12345;
4067 dst_len = 0x1234;
4068 dst.scale = 30;
4069 memset(dst.val, 0xfe, sizeof(dst.val));
4070 hr = IDataConvert_DataConvert(convert, DBTYPE_I8, DBTYPE_NUMERIC, sizeof(i8), &dst_len, &i8, &dst, sizeof(dst), 0, &dst_status, 10, 0, 0);
4071 todo_wine ok(hr == S_OK, "got %08x\n", hr);
4072 todo_wine ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
4073 todo_wine ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
4074 todo_wine test_numeric_val(&dst, &result2);
4076 dst_len = 0x1234;
4077 dst.scale = 30;
4078 dst.sign = 1;
4079 memset(dst.val, 0xfe, sizeof(dst.val));
4080 hr = IDataConvert_DataConvert(convert, DBTYPE_BOOL, DBTYPE_NUMERIC, sizeof(boolean), &dst_len, &boolean, &dst, sizeof(dst), 0, &dst_status, 10, 0, 0);
4081 todo_wine ok(hr == S_OK, "got %08x\n", hr);
4082 todo_wine ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
4083 todo_wine ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
4084 todo_wine test_numeric_val(&dst, &result3);
4086 dst_len = 0x1234;
4087 dst.scale = 30;
4088 dst.sign = 0;
4089 memset(dst.val, 0xfe, sizeof(dst.val));
4090 hr = IDataConvert_DataConvert(convert, DBTYPE_R4, DBTYPE_NUMERIC, sizeof(fvalue), &dst_len, &fvalue, &dst, sizeof(dst), 0, &dst_status, 10, 0, 0);
4091 todo_wine ok(hr == S_OK, "got %08x\n", hr);
4092 todo_wine ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
4093 todo_wine ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
4094 todo_wine test_numeric_val(&dst, &result4);
4096 dst_len = 0x1234;
4097 dst.scale = 30;
4098 dst.sign = 0;
4099 memset(dst.val, 0xfe, sizeof(dst.val));
4100 V_VT(&var) = VT_NULL;
4101 hr = IDataConvert_DataConvert(convert, DBTYPE_VARIANT, DBTYPE_NUMERIC, sizeof(var), &dst_len, &var, &dst, sizeof(dst), 0, &dst_status, 10, 0, 0);
4102 ok(hr == S_OK, "got %08x\n", hr);
4103 ok(dst_status == DBSTATUS_S_ISNULL, "got %08x\n", dst_status);
4105 dst_len = 0x1234;
4106 dst.scale = 30;
4107 dst.sign = 0;
4108 memset(dst.val, 0xfe, sizeof(dst.val));
4109 hr = IDataConvert_DataConvert(convert, DBTYPE_WSTR, DBTYPE_NUMERIC, sizeof(strW), &dst_len, strW, &dst, sizeof(dst), 0, &dst_status, 10, 0, 0);
4110 todo_wine ok(hr == S_OK, "got %08x\n", hr);
4111 todo_wine ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
4112 todo_wine ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
4113 todo_wine test_numeric_val(&dst, &result5);
4115 bstr = SysAllocString(strW);
4116 dst_status = 0;
4117 dst.scale = 30;
4118 dst.sign = 0;
4119 dst_len = sizeof(strW);
4120 memset(dst.val, 0xfe, sizeof(dst.val));
4121 hr = IDataConvert_DataConvert(convert, DBTYPE_BSTR, DBTYPE_NUMERIC, 0, &dst_len, &bstr, &dst, sizeof(dst), 0, &dst_status, 10, 0, 0);
4122 todo_wine ok(hr == S_OK, "got %08x\n", hr);
4123 todo_wine ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
4124 todo_wine ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
4125 todo_wine test_numeric_val(&dst, &result5);
4126 SysFreeString(bstr);
4128 bstr = SysAllocString(largeW);
4129 dst_status = 0;
4130 dst.scale = 30;
4131 dst.sign = 0;
4132 dst_len = sizeof(largeW);
4133 memset(dst.val, 0xfe, sizeof(dst.val));
4134 hr = IDataConvert_DataConvert(convert, DBTYPE_BSTR, DBTYPE_NUMERIC, 0, &dst_len, &bstr, &dst, sizeof(dst), 0, &dst_status, 10, 0, 0);
4135 todo_wine ok(hr == S_OK, "got %08x\n", hr);
4136 todo_wine ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
4137 todo_wine ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
4138 todo_wine test_numeric_val(&dst, &result6);
4139 SysFreeString(bstr);
4142 static void test_converttodate(void)
4144 static const WCHAR strW[] = {'2','0','1','3','-','0','5','-','1','4',0};
4145 DBLENGTH dst_len;
4146 HRESULT hr;
4147 DATE dst, date = 41408.086250;
4148 DBSTATUS dst_status;
4149 VARIANT var;
4150 BSTR bstr;
4152 dst = 0.0;
4153 dst_len = 0;
4154 hr = IDataConvert_DataConvert(convert, DBTYPE_DATE, DBTYPE_DATE, sizeof(date), &dst_len, &date, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
4155 ok(hr == S_OK, "got %08x\n", hr);
4156 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
4157 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
4158 ok(dst == 41408.086250, "got %f\n", dst);
4160 VariantInit(&var);
4161 V_VT(&var) = VT_DATE;
4162 V_DATE(&var) = 41408.086250;
4163 dst = 0.0;
4164 dst_len = 0;
4165 hr = IDataConvert_DataConvert(convert, DBTYPE_VARIANT, DBTYPE_DATE, sizeof(var), &dst_len, &var, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
4166 ok(hr == S_OK, "got %08x\n", hr);
4167 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
4168 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
4169 ok(dst == 41408.086250, "got %f\n", dst);
4171 VariantInit(&var);
4172 V_VT(&var) = VT_R8;
4173 V_R8(&var) = 41408.086250;
4174 dst = 0.0;
4175 dst_len = 0;
4176 hr = IDataConvert_DataConvert(convert, DBTYPE_VARIANT, DBTYPE_DATE, sizeof(var), &dst_len, &var, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
4177 ok(hr == S_OK, "got %08x\n", hr);
4178 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
4179 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
4180 ok(dst == 41408.086250, "got %f\n", dst);
4182 VariantInit(&var);
4183 V_VT(&var) = VT_I4;
4184 V_I4(&var) = 41408;
4185 dst = 0.0;
4186 dst_len = 0;
4187 hr = IDataConvert_DataConvert(convert, DBTYPE_VARIANT, DBTYPE_DATE, sizeof(var), &dst_len, &var, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
4188 ok(hr == S_OK, "got %08x\n", hr);
4189 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
4190 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
4191 ok(dst == 41408.000000, "got %f\n", dst);
4193 V_VT(&var) = VT_BSTR;
4194 V_BSTR(&var) = SysAllocString(strW);
4195 dst = 0.0;
4196 dst_len = 0;
4197 hr = IDataConvert_DataConvert(convert, DBTYPE_VARIANT, DBTYPE_DATE, sizeof(var), &dst_len, &var, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
4198 ok(hr == S_OK, "got %08x\n", hr);
4199 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
4200 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
4201 ok(dst == 41408.000000, "got %f\n", dst);
4202 VariantClear(&var);
4204 dst = 0.0;
4205 dst_len = 0;
4206 bstr = SysAllocString(strW);
4207 hr = IDataConvert_DataConvert(convert, DBTYPE_BSTR, DBTYPE_DATE, 0, &dst_len, &bstr, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
4208 ok(hr == S_OK, "got %08x\n", hr);
4209 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
4210 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
4211 ok(dst == 41408.000000, "got %f\n", dst);
4212 SysFreeString(bstr);
4214 V_VT(&var) = VT_EMPTY;
4215 dst = 1.0;
4216 dst_len = 0;
4217 hr = IDataConvert_DataConvert(convert, DBTYPE_VARIANT, DBTYPE_DATE, sizeof(var), &dst_len, &var, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
4218 ok(hr == S_OK, "got %08x\n", hr);
4219 ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
4220 ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
4221 ok(dst == 0.0, "got %f\n", dst);
4223 V_VT(&var) = VT_NULL;
4224 dst = 1.0;
4225 dst_len = 0xdeadbeef;
4226 hr = IDataConvert_DataConvert(convert, DBTYPE_VARIANT, DBTYPE_DATE, sizeof(var), &dst_len, &var, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
4227 ok(hr == S_OK, "got %08x\n", hr);
4228 ok(dst_status == DBSTATUS_S_ISNULL, "got %08x\n", dst_status);
4229 ok(dst_len == 0xdeadbeef, "got %ld\n", dst_len);
4230 ok(dst == 1.0, "got %f\n", dst);
4233 START_TEST(convert)
4235 HRESULT hr;
4237 OleInitialize(NULL);
4239 test_dcinfo();
4241 hr = CoCreateInstance(&CLSID_OLEDB_CONVERSIONLIBRARY, NULL, CLSCTX_INPROC_SERVER, &IID_IDataConvert, (void**)&convert);
4242 if(FAILED(hr))
4244 win_skip("Unable to create IDataConvert instance, 0x%08x\n", hr);
4245 OleUninitialize();
4246 return;
4249 test_canconvert();
4250 test_converttoi1();
4251 test_converttoi2();
4252 test_converttoi4();
4253 test_converttoi8();
4254 test_converttostr();
4255 test_converttobstr();
4256 test_converttowstr();
4257 test_converttobyrefwstr();
4258 test_converttobyrefstr();
4259 test_converttoguid();
4260 test_converttoui1();
4261 test_converttoui4();
4262 test_converttor4();
4263 test_converttor8();
4264 test_converttofiletime();
4265 test_converttocy();
4266 test_converttoui8();
4267 test_converttovar();
4268 test_converttobytes();
4269 test_converttobytesbyref();
4270 test_converttodbdate();
4271 test_getconversionsize();
4272 test_converttotimestamp();
4273 test_converttoiunknown();
4274 test_converttonumeric();
4275 test_converttodate();
4277 IDataConvert_Release(convert);
4279 OleUninitialize();