1 /* OLE DB Conversion library tests
3 * Copyright 2009 Huw Davies
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #define NONAMELESSUNION
24 #define NONAMELESSSTRUCT
36 #include "wine/test.h"
38 static IDataConvert
*convert
;
40 static void test_dcinfo(void)
47 hr
= CoCreateInstance(&CLSID_OLEDB_CONVERSIONLIBRARY
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDCInfo
, (void**)&info
);
50 win_skip("Unable to load oledb conversion library\n");
54 types
[0] = DCINFOTYPE_VERSION
;
55 hr
= IDCInfo_GetInfo(info
, 1, types
, &inf
);
56 ok(hr
== S_OK
, "got %08x\n", hr
);
58 ok(inf
->eInfoType
== DCINFOTYPE_VERSION
, "got %08x\n", inf
->eInfoType
);
59 ok(V_VT(&inf
->vData
) == VT_UI4
, "got %08x\n", V_VT(&inf
->vData
));
60 ok(V_UI4(&inf
->vData
) == 0x110, "got %08x\n", V_UI4(&inf
->vData
));
62 V_UI4(&inf
->vData
) = 0x200;
63 hr
= IDCInfo_SetInfo(info
, 1, inf
);
64 ok(hr
== S_OK
, "got %08x\n", hr
);
67 hr
= IDCInfo_GetInfo(info
, 1, types
, &inf
);
68 ok(hr
== S_OK
, "got %08x\n", hr
);
69 ok(inf
->eInfoType
== DCINFOTYPE_VERSION
, "got %08x\n", inf
->eInfoType
);
70 ok(V_VT(&inf
->vData
) == VT_UI4
, "got %08x\n", V_VT(&inf
->vData
));
71 ok(V_UI4(&inf
->vData
) == 0x200, "got %08x\n", V_UI4(&inf
->vData
));
73 V_UI4(&inf
->vData
) = 0x100;
74 hr
= IDCInfo_SetInfo(info
, 1, inf
);
75 ok(hr
== S_OK
, "got %08x\n", hr
);
78 hr
= IDCInfo_GetInfo(info
, 1, types
, &inf
);
79 ok(hr
== S_OK
, "got %08x\n", hr
);
80 ok(inf
->eInfoType
== DCINFOTYPE_VERSION
, "got %08x\n", inf
->eInfoType
);
81 ok(V_VT(&inf
->vData
) == VT_UI4
, "got %08x\n", V_VT(&inf
->vData
));
82 ok(V_UI4(&inf
->vData
) == 0x100, "got %08x\n", V_UI4(&inf
->vData
));
84 V_UI4(&inf
->vData
) = 0x500;
85 hr
= IDCInfo_SetInfo(info
, 1, inf
);
86 ok(hr
== S_OK
, "got %08x\n", hr
);
89 hr
= IDCInfo_GetInfo(info
, 1, types
, &inf
);
90 ok(hr
== S_OK
, "got %08x\n", hr
);
91 ok(inf
->eInfoType
== DCINFOTYPE_VERSION
, "got %08x\n", inf
->eInfoType
);
92 ok(V_VT(&inf
->vData
) == VT_UI4
, "got %08x\n", V_VT(&inf
->vData
));
93 ok(V_UI4(&inf
->vData
) == 0x500, "got %08x\n", V_UI4(&inf
->vData
));
95 V_UI4(&inf
->vData
) = 0xffff;
96 hr
= IDCInfo_SetInfo(info
, 1, inf
);
97 ok(hr
== S_OK
, "got %08x\n", hr
);
100 hr
= IDCInfo_GetInfo(info
, 1, types
, &inf
);
101 ok(hr
== S_OK
, "got %08x\n", hr
);
102 ok(inf
->eInfoType
== DCINFOTYPE_VERSION
, "got %08x\n", inf
->eInfoType
);
103 ok(V_VT(&inf
->vData
) == VT_UI4
, "got %08x\n", V_VT(&inf
->vData
));
104 ok(V_UI4(&inf
->vData
) == 0xffff, "got %08x\n", V_UI4(&inf
->vData
));
106 V_UI4(&inf
->vData
) = 0x12345678;
107 hr
= IDCInfo_SetInfo(info
, 1, inf
);
108 ok(hr
== S_OK
, "got %08x\n", hr
);
111 hr
= IDCInfo_GetInfo(info
, 1, types
, &inf
);
112 ok(hr
== S_OK
, "got %08x\n", hr
);
113 ok(inf
->eInfoType
== DCINFOTYPE_VERSION
, "got %08x\n", inf
->eInfoType
);
114 ok(V_VT(&inf
->vData
) == VT_UI4
, "got %08x\n", V_VT(&inf
->vData
));
115 ok(V_UI4(&inf
->vData
) == 0x12345678, "got %08x\n", V_UI4(&inf
->vData
));
117 /* Try setting a version variant of something other than VT_UI4 */
118 V_VT(&inf
->vData
) = VT_I4
;
119 V_I4(&inf
->vData
) = 0x200;
120 hr
= IDCInfo_SetInfo(info
, 1, inf
);
121 ok(hr
== DB_S_ERRORSOCCURRED
, "got %08x\n", hr
);
124 hr
= IDCInfo_GetInfo(info
, 1, types
, &inf
);
125 ok(hr
== S_OK
, "got %08x\n", hr
);
126 ok(inf
->eInfoType
== DCINFOTYPE_VERSION
, "got %08x\n", inf
->eInfoType
);
127 ok(V_VT(&inf
->vData
) == VT_UI4
, "got %08x\n", V_VT(&inf
->vData
));
128 ok(V_UI4(&inf
->vData
) == 0x12345678, "got %08x\n", V_UI4(&inf
->vData
));
131 /* More than one type */
133 hr
= IDCInfo_GetInfo(info
, 2, types
, &inf
);
134 ok(hr
== S_OK
, "got %08x\n", hr
);
135 ok(inf
[0].eInfoType
== DCINFOTYPE_VERSION
, "got %08x\n", inf
[0].eInfoType
);
136 ok(V_VT(&inf
[0].vData
) == VT_UI4
, "got %08x\n", V_VT(&inf
[0].vData
));
137 ok(V_UI4(&inf
[0].vData
) == 0x12345678, "got %08x\n", V_UI4(&inf
[0].vData
));
138 ok(inf
[1].eInfoType
== 2, "got %08x\n", inf
[1].eInfoType
);
139 ok(V_VT(&inf
[1].vData
) == VT_EMPTY
, "got %08x\n", V_VT(&inf
[1].vData
));
141 hr
= IDCInfo_SetInfo(info
, 2, inf
);
142 ok(hr
== S_OK
, "got %08x\n", hr
);
146 IDCInfo_Release(info
);
149 static const struct can_convert
152 DWORD can_convert_to
;
155 {DBTYPE_EMPTY
, 0x63bfd9ff},
156 {DBTYPE_NULL
, 0x40001002},
157 {DBTYPE_I2
, 0x3b9fd9ff},
158 {DBTYPE_I4
, 0x3bdfd9ff},
160 {DBTYPE_R4
, 0x3b9fd9ff},
161 {DBTYPE_R8
, 0x3b9fd9ff},
162 {DBTYPE_CY
, 0x039fd97f},
163 {DBTYPE_DATE
, 0x799f99bf},
165 {DBTYPE_BSTR
, 0x7bffd9ff},
166 {DBTYPE_IDISPATCH
, 0x7bffffff},
167 {DBTYPE_ERROR
, 0x01001500},
168 {DBTYPE_BOOL
, 0x039fd9ff},
170 {DBTYPE_VARIANT
, 0x7bffffff},
171 {DBTYPE_IUNKNOWN
, 0x00003203},
172 {DBTYPE_DECIMAL
, 0x3b9fd97f},
173 {DBTYPE_I1
, 0x3b9fd9ff},
175 {DBTYPE_UI1
, 0x3b9fd9ff},
176 {DBTYPE_UI2
, 0x3b9fd9ff},
177 {DBTYPE_UI4
, 0x3bdfd9ff},
178 {DBTYPE_I8
, 0x43dfd97f},
180 {DBTYPE_UI8
, 0x43dfd97f},
181 {DBTYPE_GUID
, 0x01e01103},
182 {DBTYPE_BYTES
, 0x01fc110b},
183 {DBTYPE_STR
, 0x7bffd9ff},
185 {DBTYPE_WSTR
, 0x7bffd9ff},
186 {DBTYPE_NUMERIC
, 0x039fd97f},
187 {DBTYPE_UDT
, 0x00000000},
188 {DBTYPE_DBDATE
, 0x79801183},
190 {DBTYPE_DBTIME
, 0x79801183},
191 {DBTYPE_DBTIMESTAMP
, 0x79801183},
192 {DBTYPE_FILETIME
, 0x79981183}
196 static inline BOOL
array_type(DBTYPE type
)
198 return (type
>= DBTYPE_I2
&& type
<= DBTYPE_UI4
);
201 static void test_canconvert(void)
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
);
211 win_skip("Doesn't handle DBTYPE_EMPTY -> DBTYPE_DBTIMESTAMP conversion so skipping\n");
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
);
220 win_skip("Doesn't handle DBTYPE_EMPTY -> DBTYPE_DBTIMESTAMP conversion so skipping\n");
224 for(src_idx
= 0; src_idx
< sizeof(simple_convert
) / sizeof(simple_convert
[0]); src_idx
++)
225 for(dst_idx
= 0; dst_idx
< sizeof(simple_convert
) / sizeof(simple_convert
[0]); 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
);
249 (simple_convert
[dst_idx
].type
== DBTYPE_BYTES
||
250 simple_convert
[dst_idx
].type
== DBTYPE_STR
||
251 simple_convert
[dst_idx
].type
== DBTYPE_WSTR
))
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
);
262 (simple_convert
[dst_idx
].type
== DBTYPE_BYTES
||
263 simple_convert
[dst_idx
].type
== DBTYPE_STR
||
264 simple_convert
[dst_idx
].type
== DBTYPE_WSTR
))
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
);
274 if(array_type(simple_convert
[src_idx
].type
) && simple_convert
[dst_idx
].type
== DBTYPE_VARIANT
)
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
);
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
))
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
);
296 if(array_type(simple_convert
[src_idx
].type
) &&
297 simple_convert
[src_idx
].type
== simple_convert
[dst_idx
].type
)
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
);
307 ok((hr
== S_OK
&& expect
== TRUE
) ||
308 (hr
== S_FALSE
&& expect
== FALSE
),
309 "%04x -> %04x: got %08x expect conversion to be %spossible\n", simple_convert
[src_idx
].type
| DBTYPE_VECTOR
,
310 simple_convert
[dst_idx
].type
, hr
, expect
? "" : "not ");
312 /* dst DBTYPE_VECTOR */
313 hr
= IDataConvert_CanConvert(convert
, simple_convert
[src_idx
].type
, simple_convert
[dst_idx
].type
| DBTYPE_VECTOR
);
315 ok((hr
== S_OK
&& expect
== TRUE
) ||
316 (hr
== S_FALSE
&& expect
== FALSE
),
317 "%04x -> %04x: got %08x expect conversion to be %spossible\n", simple_convert
[src_idx
].type
,
318 simple_convert
[dst_idx
].type
| DBTYPE_VECTOR
, hr
, expect
? "" : "not ");
320 /* src & dst DBTYPE_VECTOR */
321 hr
= IDataConvert_CanConvert(convert
, simple_convert
[src_idx
].type
| DBTYPE_VECTOR
, simple_convert
[dst_idx
].type
| DBTYPE_VECTOR
);
323 ok((hr
== S_OK
&& expect
== TRUE
) ||
324 (hr
== S_FALSE
&& expect
== FALSE
),
325 "%04x -> %04x: got %08x expect conversion to be %spossible\n", simple_convert
[src_idx
].type
| DBTYPE_VECTOR
,
326 simple_convert
[dst_idx
].type
| DBTYPE_VECTOR
, hr
, expect
? "" : "not ");
332 static void test_converttoi2(void)
339 static const WCHAR ten
[] = {'1','0',0};
342 dst_len
= dst
= 0x1234;
343 hr
= IDataConvert_DataConvert(convert
, DBTYPE_EMPTY
, DBTYPE_I2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
344 ok(hr
== S_OK
, "got %08x\n", hr
);
345 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
346 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
347 ok(dst
== 0, "got %08x\n", dst
);
349 dst_len
= dst
= 0x1234;
350 hr
= IDataConvert_DataConvert(convert
, DBTYPE_NULL
, DBTYPE_I2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
351 ok(hr
== DB_E_UNSUPPORTEDCONVERSION
, "got %08x\n", hr
);
352 ok(dst_status
== DBSTATUS_E_BADACCESSOR
, "got %08x\n", dst_status
);
353 ok(dst_len
== 0x1234, "got %ld\n", dst_len
);
354 ok(dst
== 0x1234, "got %08x\n", dst
);
356 dst_len
= dst
= 0x1234;
357 *(short *)src
= 0x4321;
358 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I2
, DBTYPE_I2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
359 ok(hr
== S_OK
, "got %08x\n", hr
);
360 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
361 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
362 ok(dst
== 0x4321, "got %08x\n", dst
);
364 dst_len
= dst
= 0x1234;
365 *(int *)src
= 0x4321cafe;
366 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I4
, DBTYPE_I2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
368 ok(hr
== DB_E_DATAOVERFLOW
, "got %08x\n", hr
);
369 ok(dst_status
== DBSTATUS_E_DATAOVERFLOW
, "got %08x\n", dst_status
);
370 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
371 ok(dst
== 0x1234, "got %08x\n", dst
);
373 dst_len
= dst
= 0x1234;
374 *(int *)src
= 0x4321;
375 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I4
, DBTYPE_I2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
376 ok(hr
== S_OK
, "got %08x\n", hr
);
377 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
378 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
379 ok(dst
== 0x4321, "got %08x\n", dst
);
381 dst_len
= dst
= 0x1234;
382 *(FLOAT
*)src
= 10.75;
383 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R4
, DBTYPE_I2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
384 ok(hr
== S_OK
, "got %08x\n", hr
);
385 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
386 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
387 ok(dst
== 11, "got %08x\n", dst
);
389 dst_len
= dst
= 0x1234;
390 *(FLOAT
*)src
= -10.75;
391 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R4
, DBTYPE_I2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
392 ok(hr
== S_OK
, "got %08x\n", hr
);
393 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
394 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
395 ok(dst
== -11, "got %08x\n", dst
);
397 dst_len
= dst
= 0x1234;
398 *(double *)src
= 10.75;
399 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R8
, DBTYPE_I2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
400 ok(hr
== S_OK
, "got %08x\n", hr
);
401 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
402 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
403 ok(dst
== 11, "got %08x\n", dst
);
405 dst_len
= dst
= 0x1234;
406 ((LARGE_INTEGER
*)src
)->QuadPart
= 107500;
407 hr
= IDataConvert_DataConvert(convert
, DBTYPE_CY
, DBTYPE_I2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
408 ok(hr
== S_OK
, "got %08x\n", hr
);
409 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
410 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
411 ok(dst
== 11, "got %08x\n", dst
);
413 dst_len
= dst
= 0x1234;
414 *(DATE
*)src
= 10.7500;
415 hr
= IDataConvert_DataConvert(convert
, DBTYPE_DATE
, DBTYPE_I2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
416 ok(hr
== S_OK
, "got %08x\n", hr
);
417 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
418 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
419 ok(dst
== 11, "got %08x\n", dst
);
421 dst_len
= dst
= 0x1234;
422 b
= SysAllocString(ten
);
424 hr
= IDataConvert_DataConvert(convert
, DBTYPE_BSTR
, DBTYPE_I2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
425 ok(hr
== S_OK
, "got %08x\n", hr
);
426 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
427 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
428 ok(dst
== 10, "got %08x\n", dst
);
431 dst_len
= dst
= 0x1234;
432 *(SCODE
*)src
= 0x4321cafe;
433 hr
= IDataConvert_DataConvert(convert
, DBTYPE_ERROR
, DBTYPE_I2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
434 ok(hr
== DB_E_UNSUPPORTEDCONVERSION
, "got %08x\n", hr
);
435 ok(dst_status
== DBSTATUS_E_BADACCESSOR
, "got %08x\n", dst_status
);
436 ok(dst_len
== 0x1234, "got %ld\n", dst_len
);
437 ok(dst
== 0x1234, "got %08x\n", dst
);
439 dst_len
= dst
= 0x1234;
440 *(VARIANT_BOOL
*)src
= VARIANT_TRUE
;
441 hr
= IDataConvert_DataConvert(convert
, DBTYPE_BOOL
, DBTYPE_I2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
442 ok(hr
== S_OK
, "got %08x\n", hr
);
443 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
444 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
445 ok(dst
== -1, "got %08x\n", dst
);
447 dst_len
= dst
= 0x1234;
448 *(VARIANT_BOOL
*)src
= VARIANT_FALSE
;
449 hr
= IDataConvert_DataConvert(convert
, DBTYPE_BOOL
, DBTYPE_I2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
450 ok(hr
== S_OK
, "got %08x\n", hr
);
451 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
452 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
453 ok(dst
== 0, "got %08x\n", dst
);
455 dst_len
= dst
= 0x1234;
456 V_VT((VARIANT
*)src
) = VT_I2
;
457 V_I2((VARIANT
*)src
) = 0x4321;
458 hr
= IDataConvert_DataConvert(convert
, DBTYPE_VARIANT
, DBTYPE_I2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
459 ok(hr
== S_OK
, "got %08x\n", hr
);
460 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
461 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
462 ok(dst
== 0x4321, "got %08x\n", dst
);
464 dst_len
= dst
= 0x1234;
465 memset(src
, 0, sizeof(DECIMAL
));
466 ((DECIMAL
*)src
)->u1
.Lo64
= 0x4321;
467 hr
= IDataConvert_DataConvert(convert
, DBTYPE_DECIMAL
, DBTYPE_I2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
468 ok(hr
== S_OK
, "got %08x\n", hr
);
469 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
470 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
471 ok(dst
== 0x4321, "got %08x\n", dst
);
473 dst_len
= dst
= 0x1234;
474 *(signed char*)src
= 0xab;
475 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I1
, DBTYPE_I2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
476 ok(hr
== S_OK
, "got %08x\n", hr
);
477 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
478 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
479 ok(dst
== (signed short)0xffab, "got %08x\n", dst
);
481 dst_len
= dst
= 0x1234;
483 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI1
, DBTYPE_I2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
484 ok(hr
== S_OK
, "got %08x\n", hr
);
485 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
486 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
487 ok(dst
== 0xab, "got %08x\n", dst
);
489 dst_len
= dst
= 0x1234;
490 *(WORD
*)src
= 0x4321;
491 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI2
, DBTYPE_I2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
492 ok(hr
== S_OK
, "got %08x\n", hr
);
493 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
494 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
495 ok(dst
== 0x4321, "got %08x\n", dst
);
497 dst_len
= dst
= 0x1234;
498 *(WORD
*)src
= 0xabcd;
499 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI2
, DBTYPE_I2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
500 ok(hr
== DB_E_ERRORSOCCURRED
, "got %08x\n", hr
);
501 ok(dst_status
== DBSTATUS_E_DATAOVERFLOW
, "got %08x\n", dst_status
);
503 ok(broken(dst_len
== sizeof(dst
)) || dst_len
== 0x1234 /* W2K+ */, "got %ld\n", dst_len
);
504 ok(dst
== 0x1234, "got %08x\n", dst
);
506 dst_len
= dst
= 0x1234;
507 *(DWORD
*)src
= 0xabcd1234;
508 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI4
, DBTYPE_I2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
510 ok(hr
== DB_E_DATAOVERFLOW
, "got %08x\n", hr
);
511 ok(dst_status
== DBSTATUS_E_DATAOVERFLOW
, "got %08x\n", dst_status
);
512 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
513 ok(dst
== 0x1234, "got %08x\n", dst
);
515 dst_len
= dst
= 0x1234;
516 *(DWORD
*)src
= 0x1234abcd;
517 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI4
, DBTYPE_I2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
519 ok(hr
== DB_E_DATAOVERFLOW
, "got %08x\n", hr
);
520 ok(dst_status
== DBSTATUS_E_DATAOVERFLOW
, "got %08x\n", dst_status
);
521 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
522 ok(dst
== 0x1234, "got %08x\n", dst
);
524 dst_len
= dst
= 0x1234;
525 *(DWORD
*)src
= 0x4321;
526 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI4
, DBTYPE_I2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
527 ok(hr
== S_OK
, "got %08x\n", hr
);
528 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
529 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
530 ok(dst
== 0x4321, "got %08x\n", dst
);
532 dst_len
= dst
= 0x1234;
533 ((LARGE_INTEGER
*)src
)->QuadPart
= 0x1234abcd;
534 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I8
, DBTYPE_I2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
535 ok(hr
== DB_E_ERRORSOCCURRED
||
536 broken(hr
== DB_E_UNSUPPORTEDCONVERSION
), /* win98 */
538 if(hr
!= DB_E_UNSUPPORTEDCONVERSION
) /* win98 doesn't support I8/UI8 */
540 ok(dst_status
== DBSTATUS_E_DATAOVERFLOW
, "got %08x\n", dst_status
);
541 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
542 ok(dst
== 0x1234, "got %08x\n", dst
);
544 dst_len
= dst
= 0x1234;
545 ((LARGE_INTEGER
*)src
)->QuadPart
= 0x4321;
546 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I8
, DBTYPE_I2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
547 ok(hr
== S_OK
, "got %08x\n", hr
);
548 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
549 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
550 ok(dst
== 0x4321, "got %08x\n", dst
);
552 dst_len
= dst
= 0x1234;
553 ((ULARGE_INTEGER
*)src
)->QuadPart
= 0x4321;
554 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI8
, DBTYPE_I2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
555 ok(hr
== S_OK
, "got %08x\n", hr
);
556 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
557 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
558 ok(dst
== 0x4321, "got %08x\n", dst
);
561 dst_len
= dst
= 0x1234;
562 strcpy((char *)src
, "10");
563 hr
= IDataConvert_DataConvert(convert
, DBTYPE_STR
, DBTYPE_I2
, 2, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
564 ok(hr
== S_OK
, "got %08x\n", hr
);
565 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
566 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
567 ok(dst
== 10, "got %08x\n", dst
);
569 dst_len
= dst
= 0x1234;
570 strcpy((char *)src
, "10");
571 hr
= IDataConvert_DataConvert(convert
, DBTYPE_STR
, DBTYPE_I2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, DBDATACONVERT_LENGTHFROMNTS
);
572 ok(hr
== S_OK
, "got %08x\n", hr
);
573 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
574 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
575 ok(dst
== 10, "got %08x\n", dst
);
577 dst_len
= dst
= 0x1234;
578 memcpy(src
, ten
, sizeof(ten
));
579 hr
= IDataConvert_DataConvert(convert
, DBTYPE_WSTR
, DBTYPE_I2
, 4, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
580 ok(hr
== S_OK
, "got %08x\n", hr
);
581 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
582 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
583 ok(dst
== 10, "got %08x\n", dst
);
585 dst_len
= dst
= 0x1234;
586 memcpy(src
, ten
, sizeof(ten
));
587 hr
= IDataConvert_DataConvert(convert
, DBTYPE_WSTR
, DBTYPE_I2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, DBDATACONVERT_LENGTHFROMNTS
);
588 ok(hr
== S_OK
, "got %08x\n", hr
);
589 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
590 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
591 ok(dst
== 10, "got %08x\n", dst
);
594 dst_len
= dst
= 0x1234;
595 *(WORD
*)src
= 0x4321;
596 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI2
, DBTYPE_UI2
, 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
== 0x4321, "got %08x\n", dst
);
602 dst_len
= dst
= 0x1234;
603 *(DWORD
*)src
= 0xabcd1234;
604 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI4
, DBTYPE_UI2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
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
== 0x1234, "got %08x\n", dst
);
611 dst_len
= dst
= 0x1234;
612 *(DWORD
*)src
= 0x1234abcd;
613 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI4
, DBTYPE_UI2
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
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
== 0x1234, "got %08x\n", dst
);
620 dst_len
= dst
= 0x1234;
621 *(DWORD
*)src
= 0x4321;
622 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI4
, DBTYPE_UI2
, 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
== 0x4321, "got %08x\n", dst
);
628 dst_len
= dst
= 0x1234;
629 memcpy(src
, ten
, sizeof(ten
));
630 hr
= IDataConvert_DataConvert(convert
, DBTYPE_WSTR
, DBTYPE_UI2
, 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_converttoi4(void)
644 static const WCHAR ten
[] = {'1','0',0};
649 hr
= IDataConvert_DataConvert(convert
, DBTYPE_EMPTY
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
650 ok(hr
== S_OK
, "got %08x\n", hr
);
651 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
652 ok(dst_len
== sizeof(i4
), "got %ld\n", dst_len
);
653 ok(i4
== 0, "got %08x\n", i4
);
657 hr
= IDataConvert_DataConvert(convert
, DBTYPE_NULL
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
658 ok(hr
== DB_E_UNSUPPORTEDCONVERSION
, "got %08x\n", hr
);
659 ok(dst_status
== DBSTATUS_E_BADACCESSOR
, "got %08x\n", dst_status
);
660 ok(dst_len
== 0x1234, "got %ld\n", dst_len
);
661 ok(i4
== 0x12345678, "got %08x\n", i4
);
664 *(short *)src
= 0x4321;
666 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I2
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
667 ok(hr
== S_OK
, "got %08x\n", hr
);
668 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
669 ok(dst_len
== sizeof(i4
), "got %ld\n", dst_len
);
670 ok(i4
== 0x4321, "got %08x\n", i4
);
673 *(int *)src
= 0x4321cafe;
675 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I4
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
676 ok(hr
== S_OK
, "got %08x\n", hr
);
677 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
678 ok(dst_len
== sizeof(i4
), "got %ld\n", dst_len
);
679 ok(i4
== 0x4321cafe, "got %08x\n", i4
);
682 *(FLOAT
*)src
= 10.75;
683 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R4
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
684 ok(hr
== S_OK
, "got %08x\n", hr
);
685 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
686 ok(dst_len
== sizeof(i4
), "got %ld\n", dst_len
);
687 ok(i4
== 11, "got %08x\n", i4
);
690 *(FLOAT
*)src
= -10.75;
692 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R4
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
693 ok(hr
== S_OK
, "got %08x\n", hr
);
694 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
695 ok(dst_len
== sizeof(i4
), "got %ld\n", dst_len
);
696 ok(i4
== -11, "got %08x\n", i4
);
699 *(double *)src
= 10.75;
701 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R8
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
702 ok(hr
== S_OK
, "got %08x\n", hr
);
703 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
704 ok(dst_len
== sizeof(i4
), "got %ld\n", dst_len
);
705 ok(i4
== 11, "got %08x\n", i4
);
708 ((LARGE_INTEGER
*)src
)->QuadPart
= 107500;
710 hr
= IDataConvert_DataConvert(convert
, DBTYPE_CY
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
711 ok(hr
== S_OK
, "got %08x\n", hr
);
712 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
713 ok(dst_len
== sizeof(i4
), "got %ld\n", dst_len
);
714 ok(i4
== 11, "got %08x\n", i4
);
717 *(DATE
*)src
= 10.7500;
719 hr
= IDataConvert_DataConvert(convert
, DBTYPE_DATE
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
720 ok(hr
== S_OK
, "got %08x\n", hr
);
721 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
722 ok(dst_len
== sizeof(i4
), "got %ld\n", dst_len
);
723 ok(i4
== 11, "got %08x\n", i4
);
726 b
= SysAllocString(ten
);
729 hr
= IDataConvert_DataConvert(convert
, DBTYPE_BSTR
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 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(i4
), "got %ld\n", dst_len
);
733 ok(i4
== 10, "got %08x\n", i4
);
737 *(SCODE
*)src
= 0x4321cafe;
739 hr
= IDataConvert_DataConvert(convert
, DBTYPE_ERROR
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
740 ok(hr
== DB_E_UNSUPPORTEDCONVERSION
, "got %08x\n", hr
);
741 ok(dst_status
== DBSTATUS_E_BADACCESSOR
, "got %08x\n", dst_status
);
742 ok(dst_len
== 0x1234, "got %ld\n", dst_len
);
743 ok(i4
== 0x12345678, "got %08x\n", i4
);
746 *(VARIANT_BOOL
*)src
= VARIANT_TRUE
;
748 hr
= IDataConvert_DataConvert(convert
, DBTYPE_BOOL
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
749 ok(hr
== S_OK
, "got %08x\n", hr
);
750 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
751 ok(dst_len
== sizeof(i4
), "got %ld\n", dst_len
);
752 ok(i4
== 0xffffffff, "got %08x\n", i4
);
755 *(VARIANT_BOOL
*)src
= VARIANT_FALSE
;
757 hr
= IDataConvert_DataConvert(convert
, DBTYPE_BOOL
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
758 ok(hr
== S_OK
, "got %08x\n", hr
);
759 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
760 ok(dst_len
== sizeof(i4
), "got %ld\n", dst_len
);
761 ok(i4
== 0, "got %08x\n", i4
);
764 V_VT((VARIANT
*)src
) = VT_I2
;
765 V_I2((VARIANT
*)src
) = 0x1234;
767 hr
= IDataConvert_DataConvert(convert
, DBTYPE_VARIANT
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
768 ok(hr
== S_OK
, "got %08x\n", hr
);
769 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
770 ok(dst_len
== sizeof(i4
), "got %ld\n", dst_len
);
771 ok(i4
== 0x1234, "got %08x\n", i4
);
774 memset(src
, 0, sizeof(DECIMAL
));
775 ((DECIMAL
*)src
)->u1
.Lo64
= 0x1234;
777 hr
= IDataConvert_DataConvert(convert
, DBTYPE_DECIMAL
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
778 ok(hr
== S_OK
, "got %08x\n", hr
);
779 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
780 ok(dst_len
== sizeof(i4
), "got %ld\n", dst_len
);
781 ok(i4
== 0x1234, "got %08x\n", i4
);
784 *(signed char*)src
= 0xab;
786 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I1
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
787 ok(hr
== S_OK
, "got %08x\n", hr
);
788 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
789 ok(dst_len
== sizeof(i4
), "got %ld\n", dst_len
);
790 ok(i4
== 0xffffffab, "got %08x\n", i4
);
795 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI1
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 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(i4
), "got %ld\n", dst_len
);
799 ok(i4
== 0xab, "got %08x\n", i4
);
802 *(WORD
*)src
= 0xabcd;
804 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI2
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
805 ok(hr
== S_OK
, "got %08x\n", hr
);
806 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
807 ok(dst_len
== sizeof(i4
), "got %ld\n", dst_len
);
808 ok(i4
== 0xabcd, "got %08x\n", i4
);
811 *(DWORD
*)src
= 0xabcd1234;
813 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI4
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
814 ok(hr
== DB_E_ERRORSOCCURRED
, "got %08x\n", hr
);
815 ok(dst_status
== DBSTATUS_E_DATAOVERFLOW
, "got %08x\n", dst_status
);
817 ok(broken(dst_len
== sizeof(i4
)) || dst_len
== 0x1234 /* W2K+ */, "got %ld\n", dst_len
);
818 ok(i4
== 0x12345678, "got %08x\n", i4
);
821 *(DWORD
*)src
= 0x1234abcd;
823 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI4
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
824 ok(hr
== S_OK
, "got %08x\n", hr
);
825 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
826 ok(dst_len
== sizeof(i4
), "got %ld\n", dst_len
);
827 ok(i4
== 0x1234abcd, "got %08x\n", i4
);
830 ((LARGE_INTEGER
*)src
)->QuadPart
= 0x1234abcd;
832 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I8
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
834 broken(hr
== DB_E_UNSUPPORTEDCONVERSION
), /* win98 */
836 if(hr
!= DB_E_UNSUPPORTEDCONVERSION
) /* win98 doesn't support I8/UI8 */
838 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
839 ok(dst_len
== sizeof(i4
), "got %ld\n", dst_len
);
840 ok(i4
== 0x1234abcd, "got %08x\n", i4
);
843 ((ULARGE_INTEGER
*)src
)->QuadPart
= 0x1234abcd;
845 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI8
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
846 ok(hr
== S_OK
, "got %08x\n", hr
);
847 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
848 ok(dst_len
== sizeof(i4
), "got %ld\n", dst_len
);
849 ok(i4
== 0x1234abcd, "got %08x\n", i4
);
853 strcpy((char *)src
, "10");
855 hr
= IDataConvert_DataConvert(convert
, DBTYPE_STR
, DBTYPE_I4
, 2, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
856 ok(hr
== S_OK
, "got %08x\n", hr
);
857 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
858 ok(dst_len
== sizeof(i4
), "got %ld\n", dst_len
);
859 ok(i4
== 10, "got %08x\n", i4
);
862 strcpy((char *)src
, "10");
864 hr
= IDataConvert_DataConvert(convert
, DBTYPE_STR
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, DBDATACONVERT_LENGTHFROMNTS
);
865 ok(hr
== S_OK
, "got %08x\n", hr
);
866 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
867 ok(dst_len
== sizeof(i4
), "got %ld\n", dst_len
);
868 ok(i4
== 10, "got %08x\n", i4
);
871 memcpy(src
, ten
, sizeof(ten
));
873 hr
= IDataConvert_DataConvert(convert
, DBTYPE_WSTR
, DBTYPE_I4
, 4, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, 0);
874 ok(hr
== S_OK
, "got %08x\n", hr
);
875 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
876 ok(dst_len
== sizeof(i4
), "got %ld\n", dst_len
);
877 ok(i4
== 10, "got %08x\n", i4
);
880 memcpy(src
, ten
, sizeof(ten
));
882 hr
= IDataConvert_DataConvert(convert
, DBTYPE_WSTR
, DBTYPE_I4
, 0, &dst_len
, src
, &i4
, sizeof(i4
), 0, &dst_status
, 0, 0, DBDATACONVERT_LENGTHFROMNTS
);
883 ok(hr
== S_OK
, "got %08x\n", hr
);
884 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
885 ok(dst_len
== sizeof(i4
), "got %ld\n", dst_len
);
886 ok(i4
== 10, "got %08x\n", i4
);
889 static void test_converttoi8(void)
896 static const WCHAR ten
[] = {'1','0',0};
900 ((ULARGE_INTEGER
*)src
)->QuadPart
= 1234;
902 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I8
, DBTYPE_I8
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
903 ok(hr
== S_OK
, "got %08x\n", hr
);
904 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
905 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
906 ok(dst
.QuadPart
== 1234, "got %d\n", (int)dst
.QuadPart
);
909 ((ULARGE_INTEGER
*)src
)->QuadPart
= 1234;
910 b
= SysAllocString(ten
);
912 hr
= IDataConvert_DataConvert(convert
, DBTYPE_BSTR
, DBTYPE_I8
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
913 ok(hr
== S_OK
, "got %08x\n", hr
);
914 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
915 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
916 ok(dst
.QuadPart
== 10, "got %d\n", (int)dst
.QuadPart
);
920 static void test_converttobstr(void)
927 static const WCHAR ten
[] = {'1','0',0};
932 hr
= IDataConvert_DataConvert(convert
, DBTYPE_EMPTY
, DBTYPE_BSTR
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
933 ok(hr
== S_OK
, "got %08x\n", hr
);
934 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
935 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
936 ok(dst
!= NULL
, "got %p\n", dst
);
937 ok(SysStringLen(dst
) == 0, "got %d\n", SysStringLen(dst
));
941 hr
= IDataConvert_DataConvert(convert
, DBTYPE_NULL
, DBTYPE_BSTR
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
942 ok(hr
== DB_E_UNSUPPORTEDCONVERSION
, "got %08x\n", hr
);
943 ok(dst_status
== DBSTATUS_E_BADACCESSOR
, "got %08x\n", dst_status
);
944 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
945 ok(dst
== (void*)0x1234, "got %p\n", dst
);
947 *(short *)src
= 4321;
948 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I2
, DBTYPE_BSTR
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
949 ok(hr
== S_OK
, "got %08x\n", hr
);
950 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
951 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
952 ok(dst
!= NULL
, "got %p\n", dst
);
953 ok(SysStringLen(dst
) == 4, "got %d\n", SysStringLen(dst
));
956 b
= SysAllocString(ten
);
958 hr
= IDataConvert_DataConvert(convert
, DBTYPE_BSTR
, DBTYPE_BSTR
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
959 ok(hr
== S_OK
, "got %08x\n", hr
);
960 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
961 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
962 ok(dst
!= NULL
, "got %p\n", dst
);
963 ok(dst
!= b
, "got %p src %p\n", dst
, b
);
964 ok(!lstrcmpW(b
, dst
), "got %s\n", wine_dbgstr_w(dst
));
968 b
= SysAllocString(ten
);
971 hr
= IDataConvert_DataConvert(convert
, DBTYPE_VARIANT
, DBTYPE_BSTR
, 0, &dst_len
, &v
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
972 ok(hr
== S_OK
, "got %08x\n", hr
);
973 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
974 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
975 ok(dst
!= NULL
, "got %p\n", dst
);
976 ok(dst
!= b
, "got %p src %p\n", dst
, b
);
977 ok(!lstrcmpW(b
, dst
), "got %s\n", wine_dbgstr_w(dst
));
983 hr
= IDataConvert_DataConvert(convert
, DBTYPE_VARIANT
, DBTYPE_BSTR
, 0, &dst_len
, &v
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
984 ok(hr
== S_OK
, "got %08x\n", hr
);
985 ok(dst_status
== DBSTATUS_S_ISNULL
, "got %08x\n", dst_status
);
986 ok(dst_len
== sizeof(BSTR
), "got %ld\n", dst_len
);
987 ok(dst
== (void*)0x1234, "got %p\n", dst
);
990 static void test_converttowstr(void)
997 static const WCHAR ten
[] = {'1','0',0};
998 static const WCHAR fourthreetwoone
[] = {'4','3','2','1',0};
999 static const WCHAR guid_str
[] = {
1000 '{','0','C','7','3','3','A','8','D','-','2','A','1','C','-','1','1','C','E','-',
1001 'A','D','E','5','-','0','0','A','A','0','0','4','4','7','7','3','D','}',0};
1002 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 };
1003 static const WCHAR hexpacked_w
[] = {'W','i','n','e', 0 };
1006 memset(dst
, 0xcc, sizeof(dst
));
1008 hr
= IDataConvert_DataConvert(convert
, DBTYPE_EMPTY
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1009 ok(hr
== S_OK
, "got %08x\n", hr
);
1010 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1011 ok(dst_len
== 0, "got %ld\n", dst_len
);
1012 ok(dst
[0] == 0, "got %02x\n", dst
[0]);
1013 ok(dst
[1] == 0xcccc, "got %02x\n", dst
[1]);
1015 memset(dst
, 0xcc, sizeof(dst
));
1017 hr
= IDataConvert_DataConvert(convert
, DBTYPE_NULL
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1018 ok(hr
== DB_E_UNSUPPORTEDCONVERSION
, "got %08x\n", hr
);
1019 ok(dst_status
== DBSTATUS_E_BADACCESSOR
, "got %08x\n", dst_status
);
1020 ok(dst_len
== 0x1234, "got %ld\n", dst_len
);
1021 ok(dst
[0] == 0xcccc, "got %02x\n", dst
[0]);
1023 *(short *)src
= 4321;
1025 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I2
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1026 ok(hr
== S_OK
, "got %08x\n", hr
);
1027 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1028 ok(dst_len
== 8, "got %ld\n", dst_len
);
1029 ok(!lstrcmpW(dst
, fourthreetwoone
), "got %s\n", wine_dbgstr_w(dst
));
1031 *(short *)src
= 4321;
1032 memset(dst
, 0xcc, sizeof(dst
));
1034 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I2
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, 0, 0, &dst_status
, 0, 0, 0);
1035 ok(hr
== DB_E_ERRORSOCCURRED
, "got %08x\n", hr
);
1036 ok(dst_status
== DBSTATUS_E_DATAOVERFLOW
, "got %08x\n", dst_status
);
1037 ok(dst_len
== 8, "got %ld\n", dst_len
);
1038 ok(dst
[0] == 0xcccc, "got %02x\n", dst
[0]);
1040 *(short *)src
= 4321;
1041 memset(dst
, 0xcc, sizeof(dst
));
1043 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I2
, DBTYPE_WSTR
, 0, &dst_len
, src
, NULL
, 0, 0, &dst_status
, 0, 0, 0);
1044 ok(hr
== S_OK
, "got %08x\n", hr
);
1045 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1046 ok(dst_len
== 8, "got %ld\n", dst_len
);
1047 ok(dst
[0] == 0xcccc, "got %02x\n", dst
[0]);
1049 *(short *)src
= 4321;
1050 memset(dst
, 0xcc, sizeof(dst
));
1052 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I2
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, 4, 0, &dst_status
, 0, 0, 0);
1053 ok(hr
== S_OK
, "got %08x\n", hr
);
1054 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1055 ok(dst_len
== 8, "got %ld\n", dst_len
);
1056 ok(dst
[0] == '4', "got %02x\n", dst
[0]);
1057 ok(dst
[1] == 0, "got %02x\n", dst
[1]);
1058 ok(dst
[2] == 0xcccc, "got %02x\n", dst
[2]);
1060 *(short *)src
= 4321;
1061 memset(dst
, 0xcc, sizeof(dst
));
1063 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I2
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, 2, 0, &dst_status
, 0, 0, 0);
1064 ok(hr
== S_OK
, "got %08x\n", hr
);
1065 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1066 ok(dst_len
== 8, "got %ld\n", dst_len
);
1067 ok(dst
[0] == 0, "got %02x\n", dst
[0]);
1068 ok(dst
[1] == 0xcccc, "got %02x\n", dst
[1]);
1070 *(short *)src
= 4321;
1071 memset(dst
, 0xcc, sizeof(dst
));
1073 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I2
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, 8, 0, &dst_status
, 0, 0, 0);
1074 ok(hr
== S_OK
, "got %08x\n", hr
);
1075 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1076 ok(dst_len
== 8, "got %ld\n", dst_len
);
1077 ok(dst
[0] == '4', "got %02x\n", dst
[0]);
1078 ok(dst
[1] == '3', "got %02x\n", dst
[1]);
1079 ok(dst
[2] == '2', "got %02x\n", dst
[2]);
1080 ok(dst
[3] == 0, "got %02x\n", dst
[3]);
1081 ok(dst
[4] == 0xcccc, "got %02x\n", dst
[4]);
1087 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I4
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1088 ok(hr
== S_OK
, "got %08x\n", hr
);
1089 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1090 ok(dst_len
== 8, "got %ld\n", dst_len
);
1091 ok(!lstrcmpW(dst
, fourthreetwoone
), "got %s\n", wine_dbgstr_w(dst
));
1094 memset(dst
, 0xcc, sizeof(dst
));
1096 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I4
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, 0, 0, &dst_status
, 0, 0, 0);
1097 ok(hr
== DB_E_ERRORSOCCURRED
, "got %08x\n", hr
);
1098 ok(dst_status
== DBSTATUS_E_DATAOVERFLOW
, "got %08x\n", dst_status
);
1099 ok(dst_len
== 8, "got %ld\n", dst_len
);
1100 ok(dst
[0] == 0xcccc, "got %02x\n", dst
[0]);
1103 memset(dst
, 0xcc, sizeof(dst
));
1104 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I4
, DBTYPE_WSTR
, 0, &dst_len
, src
, NULL
, 0, 0, &dst_status
, 0, 0, 0);
1105 ok(hr
== S_OK
, "got %08x\n", hr
);
1106 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1107 ok(dst_len
== 8, "got %ld\n", dst_len
);
1108 ok(dst
[0] == 0xcccc, "got %02x\n", dst
[0]);
1111 memset(dst
, 0xcc, sizeof(dst
));
1113 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I4
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, 4, 0, &dst_status
, 0, 0, 0);
1114 ok(hr
== S_OK
, "got %08x\n", hr
);
1115 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1116 ok(dst_len
== 8, "got %ld\n", dst_len
);
1117 ok(dst
[0] == '4', "got %02x\n", dst
[0]);
1118 ok(dst
[1] == 0, "got %02x\n", dst
[1]);
1119 ok(dst
[2] == 0xcccc, "got %02x\n", dst
[2]);
1122 memset(dst
, 0xcc, sizeof(dst
));
1124 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I4
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, 2, 0, &dst_status
, 0, 0, 0);
1125 ok(hr
== S_OK
, "got %08x\n", hr
);
1126 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1127 ok(dst_len
== 8, "got %ld\n", dst_len
);
1128 ok(dst
[0] == 0, "got %02x\n", dst
[0]);
1129 ok(dst
[1] == 0xcccc, "got %02x\n", dst
[1]);
1132 memset(dst
, 0xcc, sizeof(dst
));
1134 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I4
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, 8, 0, &dst_status
, 0, 0, 0);
1135 ok(hr
== S_OK
, "got %08x\n", hr
);
1136 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1137 ok(dst_len
== 8, "got %ld\n", dst_len
);
1138 ok(dst
[0] == '4', "got %02x\n", dst
[0]);
1139 ok(dst
[1] == '3', "got %02x\n", dst
[1]);
1140 ok(dst
[2] == '2', "got %02x\n", dst
[2]);
1141 ok(dst
[3] == 0, "got %02x\n", dst
[3]);
1142 ok(dst
[4] == 0xcccc, "got %02x\n", dst
[4]);
1146 *(float *)src
= 4321;
1148 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R4
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1149 ok(hr
== S_OK
, "got %08x\n", hr
);
1150 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1151 ok(dst_len
== 8, "got %ld\n", dst_len
);
1152 ok(!lstrcmpW(dst
, fourthreetwoone
), "got %s\n", wine_dbgstr_w(dst
));
1154 *(float *)src
= 4321;
1155 memset(dst
, 0xcc, sizeof(dst
));
1157 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R4
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, 0, 0, &dst_status
, 0, 0, 0);
1158 ok(hr
== DB_E_ERRORSOCCURRED
, "got %08x\n", hr
);
1159 ok(dst_status
== DBSTATUS_E_DATAOVERFLOW
, "got %08x\n", dst_status
);
1160 ok(dst_len
== 8, "got %ld\n", dst_len
);
1161 ok(dst
[0] == 0xcccc, "got %02x\n", dst
[0]);
1163 *(float *)src
= 4321;
1164 memset(dst
, 0xcc, sizeof(dst
));
1165 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R4
, DBTYPE_WSTR
, 0, &dst_len
, src
, NULL
, 0, 0, &dst_status
, 0, 0, 0);
1166 ok(hr
== S_OK
, "got %08x\n", hr
);
1167 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1168 ok(dst_len
== 8, "got %ld\n", dst_len
);
1169 ok(dst
[0] == 0xcccc, "got %02x\n", dst
[0]);
1171 *(float *)src
= 4321;
1172 memset(dst
, 0xcc, sizeof(dst
));
1174 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R4
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, 4, 0, &dst_status
, 0, 0, 0);
1175 ok(hr
== S_OK
, "got %08x\n", hr
);
1176 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1177 ok(dst_len
== 8, "got %ld\n", dst_len
);
1178 ok(dst
[0] == '4', "got %02x\n", dst
[0]);
1179 ok(dst
[1] == 0, "got %02x\n", dst
[1]);
1180 ok(dst
[2] == 0xcccc, "got %02x\n", dst
[2]);
1182 *(float *)src
= 4321;
1183 memset(dst
, 0xcc, sizeof(dst
));
1185 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R4
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, 2, 0, &dst_status
, 0, 0, 0);
1186 ok(hr
== S_OK
, "got %08x\n", hr
);
1187 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1188 ok(dst_len
== 8, "got %ld\n", dst_len
);
1189 ok(dst
[0] == 0, "got %02x\n", dst
[0]);
1190 ok(dst
[1] == 0xcccc, "got %02x\n", dst
[1]);
1192 *(float *)src
= 4321;
1193 memset(dst
, 0xcc, sizeof(dst
));
1195 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R4
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, 8, 0, &dst_status
, 0, 0, 0);
1196 ok(hr
== S_OK
, "got %08x\n", hr
);
1197 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1198 ok(dst_len
== 8, "got %ld\n", dst_len
);
1199 ok(dst
[0] == '4', "got %02x\n", dst
[0]);
1200 ok(dst
[1] == '3', "got %02x\n", dst
[1]);
1201 ok(dst
[2] == '2', "got %02x\n", dst
[2]);
1202 ok(dst
[3] == 0, "got %02x\n", dst
[3]);
1203 ok(dst
[4] == 0xcccc, "got %02x\n", dst
[4]);
1207 *(double *)src
= 4321;
1209 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R8
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1210 ok(hr
== S_OK
, "got %08x\n", hr
);
1211 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1212 ok(dst_len
== 8, "got %ld\n", dst_len
);
1213 ok(!lstrcmpW(dst
, fourthreetwoone
), "got %s\n", wine_dbgstr_w(dst
));
1215 *(double *)src
= 4321;
1216 memset(dst
, 0xcc, sizeof(dst
));
1217 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R8
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, 0, 0, &dst_status
, 0, 0, 0);
1218 ok(hr
== DB_E_ERRORSOCCURRED
, "got %08x\n", hr
);
1219 ok(dst_status
== DBSTATUS_E_DATAOVERFLOW
, "got %08x\n", dst_status
);
1220 ok(dst_len
== 8, "got %ld\n", dst_len
);
1221 ok(dst
[0] == 0xcccc, "got %02x\n", dst
[0]);
1223 *(double *)src
= 4321;
1224 memset(dst
, 0xcc, sizeof(dst
));
1226 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R8
, DBTYPE_WSTR
, 0, &dst_len
, src
, NULL
, 0, 0, &dst_status
, 0, 0, 0);
1227 ok(hr
== S_OK
, "got %08x\n", hr
);
1228 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1229 ok(dst_len
== 8, "got %ld\n", dst_len
);
1230 ok(dst
[0] == 0xcccc, "got %02x\n", dst
[0]);
1232 *(double *)src
= 4321;
1233 memset(dst
, 0xcc, sizeof(dst
));
1235 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R8
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, 4, 0, &dst_status
, 0, 0, 0);
1236 ok(hr
== S_OK
, "got %08x\n", hr
);
1237 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1238 ok(dst_len
== 8, "got %ld\n", dst_len
);
1239 ok(dst
[0] == '4', "got %02x\n", dst
[0]);
1240 ok(dst
[1] == 0, "got %02x\n", dst
[1]);
1241 ok(dst
[2] == 0xcccc, "got %02x\n", dst
[2]);
1243 *(double *)src
= 4321;
1244 memset(dst
, 0xcc, sizeof(dst
));
1246 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R8
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, 2, 0, &dst_status
, 0, 0, 0);
1247 ok(hr
== S_OK
, "got %08x\n", hr
);
1248 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1249 ok(dst_len
== 8, "got %ld\n", dst_len
);
1250 ok(dst
[0] == 0, "got %02x\n", dst
[0]);
1251 ok(dst
[1] == 0xcccc, "got %02x\n", dst
[1]);
1253 *(double *)src
= 4321;
1254 memset(dst
, 0xcc, sizeof(dst
));
1256 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R8
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, 8, 0, &dst_status
, 0, 0, 0);
1257 ok(hr
== S_OK
, "got %08x\n", hr
);
1258 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1259 ok(dst_len
== 8, "got %ld\n", dst_len
);
1260 ok(dst
[0] == '4', "got %02x\n", dst
[0]);
1261 ok(dst
[1] == '3', "got %02x\n", dst
[1]);
1262 ok(dst
[2] == '2', "got %02x\n", dst
[2]);
1263 ok(dst
[3] == 0, "got %02x\n", dst
[3]);
1264 ok(dst
[4] == 0xcccc, "got %02x\n", dst
[4]);
1268 memset(src
, 0, sizeof(src
));
1269 ((CY
*)src
)->int64
= 43210000;
1270 memset(dst
, 0xcc, sizeof(dst
));
1272 hr
= IDataConvert_DataConvert(convert
, DBTYPE_CY
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1273 ok(hr
== S_OK
, "got %08x\n", hr
);
1274 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1275 ok(dst_len
== 8, "got %ld\n", dst_len
);
1276 ok(!lstrcmpW(dst
, fourthreetwoone
), "got %s\n", wine_dbgstr_w(dst
));
1280 memset(src
, 0, sizeof(src
));
1281 *(signed char *)src
= 10;
1283 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I1
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1284 ok(hr
== S_OK
, "got %08x\n", hr
);
1285 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1286 ok(dst_len
== 4, "got %ld\n", dst_len
);
1287 ok(!lstrcmpW(dst
, ten
), "got %s\n", wine_dbgstr_w(dst
));
1289 memset(src
, 0, sizeof(src
));
1290 *(unsigned char *)src
= 10;
1292 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI1
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1293 ok(hr
== S_OK
, "got %08x\n", hr
);
1294 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1295 ok(dst_len
== 4, "got %ld\n", dst_len
);
1296 ok(!lstrcmpW(dst
, ten
), "got %s\n", wine_dbgstr_w(dst
));
1298 memset(src
, 0, sizeof(src
));
1299 *(unsigned short *)src
= 4321;
1301 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI2
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1302 ok(hr
== S_OK
, "got %08x\n", hr
);
1303 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1304 ok(dst_len
== 8, "got %ld\n", dst_len
);
1305 ok(!lstrcmpW(dst
, fourthreetwoone
), "got %s\n", wine_dbgstr_w(dst
));
1307 memset(src
, 0, sizeof(src
));
1308 *(unsigned int *)src
= 4321;
1310 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI4
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1311 ok(hr
== S_OK
, "got %08x\n", hr
);
1312 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1313 ok(dst_len
== 8, "got %ld\n", dst_len
);
1314 ok(!lstrcmpW(dst
, fourthreetwoone
), "got %s\n", wine_dbgstr_w(dst
));
1316 memset(src
, 0, sizeof(src
));
1317 ((LARGE_INTEGER
*)src
)->QuadPart
= 4321;
1319 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I8
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1320 ok(broken(DB_E_UNSUPPORTEDCONVERSION
) || hr
== S_OK
/* W2K+ */, "got %08x\n", hr
);
1321 ok(broken(dst_status
== DBSTATUS_E_BADACCESSOR
) || dst_status
== DBSTATUS_S_OK
/* W2K+ */, "got %08x\n", dst_status
);
1322 ok(broken(dst_len
== 0x1234) || dst_len
== 8 /* W2K+ */, "got %ld\n", dst_len
);
1323 ok(!lstrcmpW(dst
, fourthreetwoone
), "got %s\n", wine_dbgstr_w(dst
));
1325 memset(src
, 0, sizeof(src
));
1326 ((ULARGE_INTEGER
*)src
)->QuadPart
= 4321;
1327 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI8
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1328 ok(broken(DB_E_UNSUPPORTEDCONVERSION
) || hr
== S_OK
/* W2K+ */, "got %08x\n", hr
);
1329 ok(broken(dst_status
== DBSTATUS_E_BADACCESSOR
) || dst_status
== DBSTATUS_S_OK
/* W2K+ */, "got %08x\n", dst_status
);
1330 ok(broken(dst_len
== 0x1234) || dst_len
== 8 /* W2K+ */, "got %ld\n", dst_len
);
1331 ok(!lstrcmpW(dst
, fourthreetwoone
), "got %s\n", wine_dbgstr_w(dst
));
1335 memset(src
, 0, sizeof(src
));
1336 memcpy(src
, &IID_IDataConvert
, sizeof(GUID
));
1337 memset(dst
, 0xcc, sizeof(dst
));
1339 hr
= IDataConvert_DataConvert(convert
, DBTYPE_GUID
, DBTYPE_WSTR
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1340 ok(hr
== S_OK
, "got %08x\n", hr
);
1341 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1342 ok(dst_len
== 76, "got %ld\n", dst_len
);
1343 ok(!lstrcmpW(dst
, guid_str
), "got %s\n", wine_dbgstr_w(dst
));
1347 b
= SysAllocString(ten
);
1350 hr
= IDataConvert_DataConvert(convert
, DBTYPE_BSTR
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1351 ok(hr
== S_OK
, "got %08x\n", hr
);
1352 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1353 ok(dst_len
== 4, "got %ld\n", dst_len
);
1354 ok(!lstrcmpW(b
, dst
), "got %s\n", wine_dbgstr_w(dst
));
1357 memcpy(src
, ten
, sizeof(ten
));
1359 hr
= IDataConvert_DataConvert(convert
, DBTYPE_WSTR
, DBTYPE_WSTR
, 2, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1360 ok(hr
== S_OK
, "got %08x\n", hr
);
1361 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1362 ok(dst_len
== 2, "got %ld\n", dst_len
);
1363 ok(dst
[0] == '1', "got %02x\n", dst
[0]);
1364 ok(dst
[1] == 0, "got %02x\n", dst
[1]);
1366 memcpy(src
, ten
, sizeof(ten
));
1368 hr
= IDataConvert_DataConvert(convert
, DBTYPE_WSTR
, DBTYPE_WSTR
, 4, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1369 ok(hr
== S_OK
, "got %08x\n", hr
);
1370 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1371 ok(dst_len
== 4, "got %ld\n", dst_len
);
1372 ok(!lstrcmpW(ten
, dst
), "got %s\n", wine_dbgstr_w(dst
));
1374 memcpy(src
, ten
, sizeof(ten
));
1376 hr
= IDataConvert_DataConvert(convert
, DBTYPE_WSTR
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, DBDATACONVERT_LENGTHFROMNTS
);
1377 ok(hr
== S_OK
, "got %08x\n", hr
);
1378 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1379 ok(dst_len
== 4, "got %ld\n", dst_len
);
1380 ok(!lstrcmpW(ten
, dst
), "got %s\n", wine_dbgstr_w(dst
));
1384 /* DBTYPE_BYTES to DBTYPE_*STR unpacks binary data into a hex string */
1385 memcpy(src
, hexpacked_w
, sizeof(hexpacked_w
));
1386 memset(dst
, 0xcc, sizeof(dst
));
1388 hr
= IDataConvert_DataConvert(convert
, DBTYPE_BYTES
, DBTYPE_WSTR
, sizeof(hexpacked_w
), &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1389 ok(hr
== S_OK
, "got %08x\n", hr
);
1390 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1391 ok(dst_len
== sizeof(hexpacked_w
) * 4, "got %ld\n", dst_len
);
1392 ok(!lstrcmpW(hexunpacked_w
, dst
), "got %s\n", wine_dbgstr_w(dst
));
1393 ok(dst
[sizeof(hexpacked_w
)/sizeof(WCHAR
) * 4 + 1] == 0xcccc, "clobbered buffer\n");
1395 memcpy(src
, hexpacked_w
, sizeof(hexpacked_w
));
1396 memset(dst
, 0xcc, sizeof(dst
));
1398 hr
= IDataConvert_DataConvert(convert
, DBTYPE_BYTES
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1399 ok(hr
== S_OK
, "got %08x\n", hr
);
1400 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1401 ok(dst_len
== 0, "got %ld\n", dst_len
);
1402 ok(dst
[0] == 0, "not null terminated\n");
1403 ok(dst
[1] == 0xcccc, "clobbered buffer\n");
1405 memcpy(src
, hexpacked_w
, sizeof(hexpacked_w
));
1406 memset(dst
, 0xcc, sizeof(dst
));
1408 hr
= IDataConvert_DataConvert(convert
, DBTYPE_BYTES
, DBTYPE_WSTR
, 4, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1409 ok(hr
== S_OK
, "got %08x\n", hr
);
1410 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1411 ok(dst_len
== 2 * sizeof(WCHAR
) * 4, "got %ld\n", dst_len
);
1412 ok(!memcmp(hexunpacked_w
, dst
, 2 * sizeof(WCHAR
) * 4 ), "got %s\n", wine_dbgstr_w(dst
));
1413 ok(dst
[2 * 4] == 0, "not null terminated\n");
1414 ok(dst
[2 * 4 + 1] == 0xcccc, "clobbered buffer\n");
1416 memcpy(src
, hexpacked_w
, sizeof(hexpacked_w
));
1417 memset(dst
, 0xcc, sizeof(dst
));
1419 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);
1420 ok(hr
== S_OK
, "got %08x\n", hr
);
1421 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1422 ok(dst_len
== sizeof(hexpacked_w
) * 4, "got %ld\n", dst_len
);
1423 ok(!memcmp(hexunpacked_w
, dst
, 2 * sizeof(WCHAR
) * 4 ), "got %s\n", wine_dbgstr_w(dst
));
1424 ok(dst
[2 * 4] == 0, "not null terminated\n");
1425 ok(dst
[2 * 4 + 1] == 0xcccc, "clobbered buffer\n");
1427 memcpy(src
, hexpacked_w
, sizeof(hexpacked_w
));
1428 memset(dst
, 0xcc, sizeof(dst
));
1430 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);
1431 ok(hr
== S_OK
, "got %08x\n", hr
);
1432 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1433 ok(dst_len
== sizeof(hexpacked_w
) * 4, "got %ld\n", dst_len
);
1434 ok(!memcmp(hexunpacked_w
, dst
, 2 * sizeof(WCHAR
) * 4 - 2 ), "got %s\n", wine_dbgstr_w(dst
));
1435 ok(dst
[2 * 4 - 1] == 0, "not null terminated\n");
1436 ok(dst
[2 * 4] == 0xcccc, "clobbered buffer\n");
1438 memcpy(src
, hexpacked_w
, sizeof(hexpacked_w
));
1439 memset(dst
, 0xcc, sizeof(dst
));
1441 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);
1442 ok(hr
== S_OK
, "got %08x\n", hr
);
1443 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1444 ok(dst_len
== sizeof(hexpacked_w
) * 4, "got %ld\n", dst_len
);
1445 ok(!memcmp(hexunpacked_w
, dst
, 2 * sizeof(WCHAR
) * 4 - 2 ), "got %s\n", wine_dbgstr_w(dst
));
1446 ok(dst
[2 * 4 - 1] == 0, "not null terminated\n");
1447 ok(dst
[2 * 4] == 0xcccc, "clobbered buffer\n");
1449 memcpy(src
, hexpacked_w
, sizeof(hexpacked_w
));
1450 memset(dst
, 0xcc, sizeof(dst
));
1452 hr
= IDataConvert_DataConvert(convert
, DBTYPE_BYTES
, DBTYPE_WSTR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, DBDATACONVERT_LENGTHFROMNTS
);
1453 ok(hr
== S_OK
, "got %08x\n", hr
);
1454 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1455 ok(dst_len
== 0, "got %ld\n", dst_len
);
1456 ok(dst
[0] == 0, "not null terminated\n");
1457 ok(dst
[1] == 0xcccc, "clobbered buffer\n");
1460 static void test_converttostr(void)
1465 DBSTATUS dst_status
;
1467 static const WCHAR ten
[] = {'1','0',0};
1468 static const char ten_a
[] = "10";
1469 static const char fourthreetwoone
[] = "4321";
1470 static const char guid_str
[] = "{0C733A8D-2A1C-11CE-ADE5-00AA0044773D}";
1471 static const char hexunpacked_a
[] = "57696E6500";
1472 static const char hexpacked_a
[] = "Wine";
1475 memset(dst
, 0xcc, sizeof(dst
));
1477 hr
= IDataConvert_DataConvert(convert
, DBTYPE_EMPTY
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1478 ok(hr
== S_OK
, "got %08x\n", hr
);
1479 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1480 ok(dst_len
== 0, "got %ld\n", dst_len
);
1481 ok(dst
[0] == 0, "got %02x\n", dst
[0]);
1482 ok(dst
[1] == (char)0xcc, "got %02x\n", dst
[1]);
1484 memset(dst
, 0xcc, sizeof(dst
));
1486 hr
= IDataConvert_DataConvert(convert
, DBTYPE_NULL
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1487 ok(hr
== DB_E_UNSUPPORTEDCONVERSION
, "got %08x\n", hr
);
1488 ok(dst_status
== DBSTATUS_E_BADACCESSOR
, "got %08x\n", dst_status
);
1489 ok(dst_len
== 0x1234, "got %ld\n", dst_len
);
1490 ok(dst
[0] == (char)0xcc, "got %02x\n", dst
[0]);
1492 *(short *)src
= 4321;
1494 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I2
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1495 ok(hr
== S_OK
, "got %08x\n", hr
);
1496 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1497 ok(dst_len
== 4, "got %ld\n", dst_len
);
1498 ok(!lstrcmpA(dst
, fourthreetwoone
), "got %s\n", dst
);
1500 *(short *)src
= 4321;
1501 memset(dst
, 0xcc, sizeof(dst
));
1503 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I2
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, 0, 0, &dst_status
, 0, 0, 0);
1504 ok(hr
== DB_E_ERRORSOCCURRED
, "got %08x\n", hr
);
1505 ok(dst_status
== DBSTATUS_E_DATAOVERFLOW
, "got %08x\n", dst_status
);
1506 ok(dst_len
== 4, "got %ld\n", dst_len
);
1507 ok(dst
[0] == (char)0xcc, "got %02x\n", dst
[0]);
1509 *(short *)src
= 4321;
1510 memset(dst
, 0xcc, sizeof(dst
));
1512 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I2
, DBTYPE_STR
, 0, &dst_len
, src
, NULL
, 0, 0, &dst_status
, 0, 0, 0);
1513 ok(hr
== S_OK
, "got %08x\n", hr
);
1514 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1515 ok(dst_len
== 4, "got %ld\n", dst_len
);
1516 ok(dst
[0] == (char)0xcc, "got %02x\n", dst
[0]);
1518 *(short *)src
= 4321;
1519 memset(dst
, 0xcc, sizeof(dst
));
1521 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I2
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, 2, 0, &dst_status
, 0, 0, 0);
1522 ok(hr
== S_OK
, "got %08x\n", hr
);
1523 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1524 ok(dst_len
== 4, "got %ld\n", dst_len
);
1525 ok(dst
[0] == '4', "got %02x\n", dst
[0]);
1526 ok(dst
[1] == 0, "got %02x\n", dst
[1]);
1527 ok(dst
[2] == (char)0xcc, "got %02x\n", dst
[2]);
1529 *(short *)src
= 4321;
1530 memset(dst
, 0xcc, sizeof(dst
));
1532 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I2
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, 1, 0, &dst_status
, 0, 0, 0);
1533 ok(hr
== S_OK
, "got %08x\n", hr
);
1534 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1535 ok(dst_len
== 4, "got %ld\n", dst_len
);
1536 ok(dst
[0] == 0, "got %02x\n", dst
[0]);
1537 ok(dst
[1] == (char)0xcc, "got %02x\n", dst
[1]);
1539 *(short *)src
= 4321;
1540 memset(dst
, 0xcc, sizeof(dst
));
1542 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I2
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, 4, 0, &dst_status
, 0, 0, 0);
1543 ok(hr
== S_OK
, "got %08x\n", hr
);
1544 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1545 ok(dst_len
== 4, "got %ld\n", dst_len
);
1546 ok(dst
[0] == '4', "got %02x\n", dst
[0]);
1547 ok(dst
[1] == '3', "got %02x\n", dst
[1]);
1548 ok(dst
[2] == '2', "got %02x\n", dst
[2]);
1549 ok(dst
[3] == 0, "got %02x\n", dst
[3]);
1550 ok(dst
[4] == (char)0xcc, "got %02x\n", dst
[4]);
1555 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I4
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1556 ok(hr
== S_OK
, "got %08x\n", hr
);
1557 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1558 ok(dst_len
== 4, "got %ld\n", dst_len
);
1559 ok(!lstrcmpA(dst
, fourthreetwoone
), "got %s\n", dst
);
1562 memset(dst
, 0xcc, sizeof(dst
));
1564 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I4
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, 0, 0, &dst_status
, 0, 0, 0);
1565 ok(hr
== DB_E_ERRORSOCCURRED
, "got %08x\n", hr
);
1566 ok(dst_status
== DBSTATUS_E_DATAOVERFLOW
, "got %08x\n", dst_status
);
1567 ok(dst_len
== 4, "got %ld\n", dst_len
);
1568 ok(dst
[0] == (char)0xcc, "got %02x\n", dst
[0]);
1571 memset(dst
, 0xcc, sizeof(dst
));
1573 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I4
, DBTYPE_STR
, 0, &dst_len
, src
, NULL
, 0, 0, &dst_status
, 0, 0, 0);
1574 ok(hr
== S_OK
, "got %08x\n", hr
);
1575 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1576 ok(dst_len
== 4, "got %ld\n", dst_len
);
1577 ok(dst
[0] == (char)0xcc, "got %02x\n", dst
[0]);
1580 memset(dst
, 0xcc, sizeof(dst
));
1582 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I4
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, 2, 0, &dst_status
, 0, 0, 0);
1583 ok(hr
== S_OK
, "got %08x\n", hr
);
1584 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1585 ok(dst_len
== 4, "got %ld\n", dst_len
);
1586 ok(dst
[0] == '4', "got %02x\n", dst
[0]);
1587 ok(dst
[1] == 0, "got %02x\n", dst
[1]);
1588 ok(dst
[2] == (char)0xcc, "got %02x\n", dst
[2]);
1591 memset(dst
, 0xcc, sizeof(dst
));
1593 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I4
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, 1, 0, &dst_status
, 0, 0, 0);
1594 ok(hr
== S_OK
, "got %08x\n", hr
);
1595 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1596 ok(dst_len
== 4, "got %ld\n", dst_len
);
1597 ok(dst
[0] == 0, "got %02x\n", dst
[0]);
1598 ok(dst
[1] == (char)0xcc, "got %02x\n", dst
[1]);
1601 memset(dst
, 0xcc, sizeof(dst
));
1603 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I4
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, 4, 0, &dst_status
, 0, 0, 0);
1604 ok(hr
== S_OK
, "got %08x\n", hr
);
1605 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1606 ok(dst_len
== 4, "got %ld\n", dst_len
);
1607 ok(dst
[0] == '4', "got %02x\n", dst
[0]);
1608 ok(dst
[1] == '3', "got %02x\n", dst
[1]);
1609 ok(dst
[2] == '2', "got %02x\n", dst
[2]);
1610 ok(dst
[3] == 0, "got %02x\n", dst
[3]);
1611 ok(dst
[4] == (char)0xcc, "got %02x\n", dst
[4]);
1614 *(float *)src
= 4321;
1616 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R4
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1617 ok(hr
== S_OK
, "got %08x\n", hr
);
1618 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1619 ok(dst_len
== 4, "got %ld\n", dst_len
);
1620 ok(!lstrcmpA(dst
, fourthreetwoone
), "got %s\n", dst
);
1622 *(float *)src
= 4321;
1623 memset(dst
, 0xcc, sizeof(dst
));
1625 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R4
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, 0, 0, &dst_status
, 0, 0, 0);
1626 ok(hr
== DB_E_ERRORSOCCURRED
, "got %08x\n", hr
);
1627 ok(dst_status
== DBSTATUS_E_DATAOVERFLOW
, "got %08x\n", dst_status
);
1628 ok(dst_len
== 4, "got %ld\n", dst_len
);
1629 ok(dst
[0] == (char)0xcc, "got %02x\n", dst
[0]);
1631 *(float *)src
= 4321;
1632 memset(dst
, 0xcc, sizeof(dst
));
1634 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R4
, DBTYPE_STR
, 0, &dst_len
, src
, NULL
, 0, 0, &dst_status
, 0, 0, 0);
1635 ok(hr
== S_OK
, "got %08x\n", hr
);
1636 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1637 ok(dst_len
== 4, "got %ld\n", dst_len
);
1638 ok(dst
[0] == (char)0xcc, "got %02x\n", dst
[0]);
1640 *(float *)src
= 4321;
1641 memset(dst
, 0xcc, sizeof(dst
));
1643 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R4
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, 2, 0, &dst_status
, 0, 0, 0);
1644 ok(hr
== S_OK
, "got %08x\n", hr
);
1645 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1646 ok(dst_len
== 4, "got %ld\n", dst_len
);
1647 ok(dst
[0] == '4', "got %02x\n", dst
[0]);
1648 ok(dst
[1] == 0, "got %02x\n", dst
[1]);
1649 ok(dst
[2] == (char)0xcc, "got %02x\n", dst
[2]);
1651 *(float *)src
= 4321;
1652 memset(dst
, 0xcc, sizeof(dst
));
1654 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R4
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, 1, 0, &dst_status
, 0, 0, 0);
1655 ok(hr
== S_OK
, "got %08x\n", hr
);
1656 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1657 ok(dst_len
== 4, "got %ld\n", dst_len
);
1658 ok(dst
[0] == 0, "got %02x\n", dst
[0]);
1659 ok(dst
[1] == (char)0xcc, "got %02x\n", dst
[1]);
1661 *(float *)src
= 4321;
1662 memset(dst
, 0xcc, sizeof(dst
));
1664 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R4
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, 4, 0, &dst_status
, 0, 0, 0);
1665 ok(hr
== S_OK
, "got %08x\n", hr
);
1666 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1667 ok(dst_len
== 4, "got %ld\n", dst_len
);
1668 ok(dst
[0] == '4', "got %02x\n", dst
[0]);
1669 ok(dst
[1] == '3', "got %02x\n", dst
[1]);
1670 ok(dst
[2] == '2', "got %02x\n", dst
[2]);
1671 ok(dst
[3] == 0, "got %02x\n", dst
[3]);
1672 ok(dst
[4] == (char)0xcc, "got %02x\n", dst
[4]);
1675 *(double *)src
= 4321;
1677 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R8
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1678 ok(hr
== S_OK
, "got %08x\n", hr
);
1679 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1680 ok(dst_len
== 4, "got %ld\n", dst_len
);
1681 ok(!lstrcmpA(dst
, fourthreetwoone
), "got %s\n", dst
);
1683 *(double *)src
= 4321;
1684 memset(dst
, 0xcc, sizeof(dst
));
1686 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R8
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, 0, 0, &dst_status
, 0, 0, 0);
1687 ok(hr
== DB_E_ERRORSOCCURRED
, "got %08x\n", hr
);
1688 ok(dst_status
== DBSTATUS_E_DATAOVERFLOW
, "got %08x\n", dst_status
);
1689 ok(dst_len
== 4, "got %ld\n", dst_len
);
1690 ok(dst
[0] == (char)0xcc, "got %02x\n", dst
[0]);
1692 *(double *)src
= 4321;
1693 memset(dst
, 0xcc, sizeof(dst
));
1695 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R8
, DBTYPE_STR
, 0, &dst_len
, src
, NULL
, 0, 0, &dst_status
, 0, 0, 0);
1696 ok(hr
== S_OK
, "got %08x\n", hr
);
1697 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1698 ok(dst_len
== 4, "got %ld\n", dst_len
);
1699 ok(dst
[0] == (char)0xcc, "got %02x\n", dst
[0]);
1701 *(double *)src
= 4321;
1702 memset(dst
, 0xcc, sizeof(dst
));
1704 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R8
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, 2, 0, &dst_status
, 0, 0, 0);
1705 ok(hr
== S_OK
, "got %08x\n", hr
);
1706 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1707 ok(dst_len
== 4, "got %ld\n", dst_len
);
1708 ok(dst
[0] == '4', "got %02x\n", dst
[0]);
1709 ok(dst
[1] == 0, "got %02x\n", dst
[1]);
1710 ok(dst
[2] == (char)0xcc, "got %02x\n", dst
[2]);
1712 *(double *)src
= 4321;
1713 memset(dst
, 0xcc, sizeof(dst
));
1715 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R8
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, 1, 0, &dst_status
, 0, 0, 0);
1716 ok(hr
== S_OK
, "got %08x\n", hr
);
1717 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1718 ok(dst_len
== 4, "got %ld\n", dst_len
);
1719 ok(dst
[0] == 0, "got %02x\n", dst
[0]);
1720 ok(dst
[1] == (char)0xcc, "got %02x\n", dst
[1]);
1722 *(double *)src
= 4321;
1723 memset(dst
, 0xcc, sizeof(dst
));
1725 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R8
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, 4, 0, &dst_status
, 0, 0, 0);
1726 ok(hr
== S_OK
, "got %08x\n", hr
);
1727 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1728 ok(dst_len
== 4, "got %ld\n", dst_len
);
1729 ok(dst
[0] == '4', "got %02x\n", dst
[0]);
1730 ok(dst
[1] == '3', "got %02x\n", dst
[1]);
1731 ok(dst
[2] == '2', "got %02x\n", dst
[2]);
1732 ok(dst
[3] == 0, "got %02x\n", dst
[3]);
1733 ok(dst
[4] == (char)0xcc, "got %02x\n", dst
[4]);
1737 memset(src
, 0, sizeof(src
));
1738 ((CY
*)src
)->int64
= 43210000;
1739 memset(dst
, 0xcc, sizeof(dst
));
1741 hr
= IDataConvert_DataConvert(convert
, DBTYPE_CY
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1742 ok(hr
== S_OK
, "got %08x\n", hr
);
1743 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1744 ok(dst_len
== 4, "got %ld\n", dst_len
);
1745 ok(!lstrcmpA(dst
, fourthreetwoone
), "got %s\n", dst
);
1749 memset(src
, 0, sizeof(src
));
1750 *(signed char *)src
= 10;
1752 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I1
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1753 ok(hr
== S_OK
, "got %08x\n", hr
);
1754 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1755 ok(dst_len
== 2, "got %ld\n", dst_len
);
1756 ok(!lstrcmpA(dst
, ten_a
), "got %s\n", dst
);
1758 memset(src
, 0, sizeof(src
));
1759 *(unsigned char *)src
= 10;
1761 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI1
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1762 ok(hr
== S_OK
, "got %08x\n", hr
);
1763 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1764 ok(dst_len
== 2, "got %ld\n", dst_len
);
1765 ok(!lstrcmpA(dst
, ten_a
), "got %s\n", dst
);
1767 memset(src
, 0, sizeof(src
));
1768 *(unsigned short *)src
= 4321;
1770 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI2
, DBTYPE_STR
, 0, &dst_len
, src
, 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
== 4, "got %ld\n", dst_len
);
1774 ok(!lstrcmpA(dst
, fourthreetwoone
), "got %s\n", dst
);
1776 memset(src
, 0, sizeof(src
));
1777 *(unsigned int *)src
= 4321;
1779 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI4
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1780 ok(hr
== S_OK
, "got %08x\n", hr
);
1781 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1782 ok(dst_len
== 4, "got %ld\n", dst_len
);
1783 ok(!lstrcmpA(dst
, fourthreetwoone
), "got %s\n", dst
);
1785 memset(src
, 0, sizeof(src
));
1786 ((LARGE_INTEGER
*)src
)->QuadPart
= 4321;
1788 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I8
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1789 ok(broken(DB_E_UNSUPPORTEDCONVERSION
) || hr
== S_OK
/* W2K+ */, "got %08x\n", hr
);
1790 ok(broken(dst_status
== DBSTATUS_E_BADACCESSOR
) || dst_status
== DBSTATUS_S_OK
/* W2K+ */, "got %08x\n", dst_status
);
1791 ok(broken(dst_len
== 0x1234) || dst_len
== 4 /* W2K+ */, "got %ld\n", dst_len
);
1792 ok(!lstrcmpA(dst
, fourthreetwoone
), "got %s\n", dst
);
1794 memset(src
, 0, sizeof(src
));
1795 ((ULARGE_INTEGER
*)src
)->QuadPart
= 4321;
1797 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI8
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1798 ok(broken(DB_E_UNSUPPORTEDCONVERSION
) || hr
== S_OK
/* W2K+ */, "got %08x\n", hr
);
1799 ok(broken(dst_status
== DBSTATUS_E_BADACCESSOR
) || dst_status
== DBSTATUS_S_OK
/* W2K+ */, "got %08x\n", dst_status
);
1800 ok(broken(dst_len
== 0x1234) || dst_len
== 4 /* W2K+ */, "got %ld\n", dst_len
);
1801 ok(!lstrcmpA(dst
, fourthreetwoone
), "got %s\n", dst
);
1805 memset(src
, 0, sizeof(src
));
1806 memcpy(src
, &IID_IDataConvert
, sizeof(GUID
));
1807 memset(dst
, 0xcc, sizeof(dst
));
1809 hr
= IDataConvert_DataConvert(convert
, DBTYPE_GUID
, DBTYPE_STR
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1810 ok(hr
== S_OK
, "got %08x\n", hr
);
1811 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1812 ok(dst_len
== 38, "got %ld\n", dst_len
);
1813 ok(!lstrcmpA(dst
, guid_str
), "got %s\n", dst
);
1817 b
= SysAllocString(ten
);
1819 memset(dst
, 0xcc, sizeof(dst
));
1821 hr
= IDataConvert_DataConvert(convert
, DBTYPE_BSTR
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1822 ok(hr
== S_OK
, "got %08x\n", hr
);
1823 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1824 ok(dst_len
== 2, "got %ld\n", dst_len
);
1825 ok(!lstrcmpA(ten_a
, dst
), "got %s\n", dst
);
1828 memcpy(src
, ten
, sizeof(ten
));
1829 memset(dst
, 0xcc, sizeof(dst
));
1831 hr
= IDataConvert_DataConvert(convert
, DBTYPE_WSTR
, DBTYPE_STR
, 2, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1832 ok(hr
== S_OK
, "got %08x\n", hr
);
1833 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1834 ok(dst_len
== 1, "got %ld\n", dst_len
);
1835 ok(dst
[0] == '1', "got %02x\n", dst
[0]);
1836 ok(dst
[1] == 0, "got %02x\n", dst
[1]);
1838 memcpy(src
, ten
, sizeof(ten
));
1839 memset(dst
, 0xcc, sizeof(dst
));
1841 hr
= IDataConvert_DataConvert(convert
, DBTYPE_WSTR
, DBTYPE_STR
, 4, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1842 ok(hr
== S_OK
, "got %08x\n", hr
);
1843 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1844 ok(dst_len
== 2, "got %ld\n", dst_len
);
1845 ok(!lstrcmpA(ten_a
, dst
), "got %s\n", dst
);
1847 memcpy(src
, ten
, sizeof(ten
));
1848 memset(dst
, 0xcc, sizeof(dst
));
1850 hr
= IDataConvert_DataConvert(convert
, DBTYPE_WSTR
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, DBDATACONVERT_LENGTHFROMNTS
);
1851 ok(hr
== S_OK
, "got %08x\n", hr
);
1852 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1853 ok(dst_len
== 2, "got %ld\n", dst_len
);
1854 ok(!lstrcmpA(ten_a
, dst
), "got %s\n", dst
);
1856 memcpy(src
, ten_a
, sizeof(ten_a
));
1857 memset(dst
, 0xcc, sizeof(dst
));
1859 hr
= IDataConvert_DataConvert(convert
, DBTYPE_STR
, DBTYPE_STR
, 2, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1860 ok(hr
== S_OK
, "got %08x\n", hr
);
1861 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1862 ok(dst_len
== 2, "got %ld\n", dst_len
);
1863 ok(dst
[0] == '1', "got %02x\n", dst
[0]);
1864 ok(dst
[1] == '0', "got %02x\n", dst
[1]);
1865 ok(dst
[2] == 0, "got %02x\n", dst
[2]);
1866 ok(dst
[3] == (char)0xcc, "got %02x\n", dst
[3]);
1868 memcpy(src
, ten_a
, sizeof(ten_a
));
1869 memset(dst
, 0xcc, sizeof(dst
));
1871 hr
= IDataConvert_DataConvert(convert
, DBTYPE_STR
, DBTYPE_STR
, 4, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1872 ok(hr
== S_OK
, "got %08x\n", hr
);
1873 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1874 ok(dst_len
== 4, "got %ld\n", dst_len
);
1875 ok(!lstrcmpA(ten_a
, dst
), "got %s\n", dst
);
1877 memcpy(src
, ten_a
, sizeof(ten_a
));
1878 memset(dst
, 0xcc, sizeof(dst
));
1880 hr
= IDataConvert_DataConvert(convert
, DBTYPE_STR
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, DBDATACONVERT_LENGTHFROMNTS
);
1881 ok(hr
== S_OK
, "got %08x\n", hr
);
1882 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1883 ok(dst_len
== 2, "got %ld\n", dst_len
);
1884 ok(!lstrcmpA(ten_a
, dst
), "got %s\n", dst
);
1888 /* DBTYPE_BYTES to DBTYPE_*STR unpacks binary data into a hex string */
1889 memcpy(src
, hexpacked_a
, sizeof(hexpacked_a
));
1890 memset(dst
, 0xcc, sizeof(dst
));
1892 hr
= IDataConvert_DataConvert(convert
, DBTYPE_BYTES
, DBTYPE_STR
, sizeof(hexpacked_a
), &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1893 ok(hr
== S_OK
, "got %08x\n", hr
);
1894 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1895 ok(dst_len
== sizeof(hexpacked_a
) * 2, "got %ld\n", dst_len
);
1896 ok(!lstrcmpA(hexunpacked_a
, dst
), "got %s\n", dst
);
1897 ok(dst
[sizeof(hexpacked_a
)/sizeof(char) * 4 + 1] == (char)0xcc, "clobbered buffer\n");
1899 memcpy(src
, hexpacked_a
, sizeof(hexpacked_a
));
1900 memset(dst
, 0xcc, sizeof(dst
));
1902 hr
= IDataConvert_DataConvert(convert
, DBTYPE_BYTES
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1903 ok(hr
== S_OK
, "got %08x\n", hr
);
1904 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1905 ok(dst_len
== 0, "got %ld\n", dst_len
);
1906 ok(dst
[0] == 0, "not null terminated\n");
1907 ok(dst
[1] == (char)0xcc, "clobbered buffer\n");
1909 memcpy(src
, hexpacked_a
, sizeof(hexpacked_a
));
1910 memset(dst
, 0xcc, sizeof(dst
));
1912 hr
= IDataConvert_DataConvert(convert
, DBTYPE_BYTES
, DBTYPE_STR
, 4, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1913 ok(hr
== S_OK
, "got %08x\n", hr
);
1914 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1915 ok(dst_len
== 2 * sizeof(char) * 4, "got %ld\n", dst_len
);
1916 ok(!memcmp(hexunpacked_a
, dst
, 2 * sizeof(char) * 4 ), "got %s\n", dst
);
1917 ok(dst
[2 * 4] == 0, "not null terminated\n");
1918 ok(dst
[2 * 4 + 1] == (char)0xcc, "clobbered buffer\n");
1920 memcpy(src
, hexpacked_a
, sizeof(hexpacked_a
));
1921 memset(dst
, 0xcc, sizeof(dst
));
1923 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);
1924 ok(hr
== S_OK
, "got %08x\n", hr
);
1925 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1926 ok(dst_len
== sizeof(hexpacked_a
) * 2, "got %ld\n", dst_len
);
1927 ok(!memcmp(hexunpacked_a
, dst
, 2 * sizeof(char) * 4 ), "got %s\n", dst
);
1928 ok(dst
[2 * 4] == 0, "not null terminated\n");
1929 ok(dst
[2 * 4 + 1] == (char)0xcc, "clobbered buffer\n");
1931 memcpy(src
, hexpacked_a
, sizeof(hexpacked_a
));
1932 memset(dst
, 0xcc, sizeof(dst
));
1934 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);
1935 ok(hr
== S_OK
, "got %08x\n", hr
);
1936 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
1937 ok(dst_len
== sizeof(hexpacked_a
) * 2, "got %ld\n", dst_len
);
1938 ok(!memcmp(hexunpacked_a
, dst
, 2 * sizeof(char) * 4 - 2 ), "got %s\n", dst
);
1939 ok(dst
[2 * 4 - 1] == 0, "not null terminated\n");
1940 ok(dst
[2 * 4] == (char)0xcc, "clobbered buffer\n");
1942 memcpy(src
, hexpacked_a
, sizeof(hexpacked_a
));
1943 memset(dst
, 0xcc, sizeof(dst
));
1945 hr
= IDataConvert_DataConvert(convert
, DBTYPE_BYTES
, DBTYPE_STR
, 0, &dst_len
, src
, dst
, sizeof(dst
), 0, &dst_status
, 0, 0, DBDATACONVERT_LENGTHFROMNTS
);
1946 ok(hr
== S_OK
, "got %08x\n", hr
);
1947 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1948 ok(dst_len
== 0, "got %ld\n", dst_len
);
1949 ok(dst
[0] == 0, "not null terminated\n");
1950 ok(dst
[1] == (char)0xcc, "clobbered buffer\n");
1953 static void test_converttobyrefwstr(void)
1958 DBSTATUS dst_status
;
1960 static const WCHAR ten
[] = {'1','0',0};
1961 static const WCHAR fourthreetwoone
[] = {'4','3','2','1',0};
1964 hr
= IDataConvert_DataConvert(convert
, DBTYPE_EMPTY
, DBTYPE_BYREF
| DBTYPE_WSTR
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1965 ok(hr
== S_OK
, "got %08x\n", hr
);
1966 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1967 ok(dst_len
== 0, "got %ld\n", dst_len
);
1968 ok(dst
[0] == 0, "got %04x\n", dst
[0]);
1971 dst
= (void*)0x12345678;
1973 hr
= IDataConvert_DataConvert(convert
, DBTYPE_NULL
, DBTYPE_BYREF
| DBTYPE_WSTR
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1974 ok(hr
== DB_E_UNSUPPORTEDCONVERSION
, "got %08x\n", hr
);
1975 ok(dst_status
== DBSTATUS_E_BADACCESSOR
, "got %08x\n", dst_status
);
1976 ok(dst_len
== 0x1234, "got %ld\n", dst_len
);
1977 ok(dst
== (void*)0x12345678, "got %p\n", dst
);
1979 *(short *)src
= 4321;
1981 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I2
, DBTYPE_BYREF
| DBTYPE_WSTR
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
1982 ok(hr
== S_OK
, "got %08x\n", hr
);
1983 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1984 ok(dst_len
== 8, "got %ld\n", dst_len
);
1985 ok(!lstrcmpW(dst
, fourthreetwoone
), "got %s\n", wine_dbgstr_w(dst
));
1988 *(short *)src
= 4321;
1990 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I2
, DBTYPE_BYREF
| DBTYPE_WSTR
, 0, &dst_len
, src
, &dst
, 0, 0, &dst_status
, 0, 0, 0);
1991 ok(hr
== S_OK
, "got %08x\n", hr
);
1992 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
1993 ok(dst_len
== 8, "got %ld\n", dst_len
);
1994 ok(!lstrcmpW(dst
, fourthreetwoone
), "got %s\n", wine_dbgstr_w(dst
));
1997 b
= SysAllocString(ten
);
2000 hr
= IDataConvert_DataConvert(convert
, DBTYPE_BSTR
, DBTYPE_BYREF
| DBTYPE_WSTR
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2001 ok(hr
== S_OK
, "got %08x\n", hr
);
2002 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2003 ok(dst_len
== 4, "got %ld\n", dst_len
);
2004 ok(!lstrcmpW(b
, dst
), "got %s\n", wine_dbgstr_w(dst
));
2008 memcpy(src
, ten
, sizeof(ten
));
2010 hr
= IDataConvert_DataConvert(convert
, DBTYPE_WSTR
, DBTYPE_BYREF
| DBTYPE_WSTR
, 2, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2011 ok(hr
== S_OK
, "got %08x\n", hr
);
2012 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2013 ok(dst_len
== 2, "got %ld\n", dst_len
);
2014 ok(dst
[0] == '1', "got %02x\n", dst
[0]);
2015 ok(dst
[1] == 0, "got %02x\n", dst
[1]);
2018 memcpy(src
, ten
, sizeof(ten
));
2020 hr
= IDataConvert_DataConvert(convert
, DBTYPE_WSTR
, DBTYPE_BYREF
| DBTYPE_WSTR
, 4, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2021 ok(hr
== S_OK
, "got %08x\n", hr
);
2022 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2023 ok(dst_len
== 4, "got %ld\n", dst_len
);
2024 ok(!lstrcmpW(ten
, dst
), "got %s\n", wine_dbgstr_w(dst
));
2027 memcpy(src
, ten
, sizeof(ten
));
2029 hr
= IDataConvert_DataConvert(convert
, DBTYPE_WSTR
, DBTYPE_BYREF
| DBTYPE_WSTR
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, DBDATACONVERT_LENGTHFROMNTS
);
2030 ok(hr
== S_OK
, "got %08x\n", hr
);
2031 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2032 ok(dst_len
== 4, "got %ld\n", dst_len
);
2033 ok(!lstrcmpW(ten
, dst
), "got %s\n", wine_dbgstr_w(dst
));
2037 static void test_converttoguid(void)
2042 DBSTATUS dst_status
;
2047 hr
= IDataConvert_DataConvert(convert
, DBTYPE_EMPTY
, DBTYPE_GUID
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2048 ok(hr
== S_OK
, "got %08x\n", hr
);
2049 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2050 ok(dst_len
== sizeof(GUID
), "got %ld\n", dst_len
);
2051 ok(IsEqualGUID(&dst
, &GUID_NULL
), "didn't get GUID_NULL\n");
2055 hr
= IDataConvert_DataConvert(convert
, DBTYPE_NULL
, DBTYPE_GUID
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2056 ok(hr
== DB_E_UNSUPPORTEDCONVERSION
, "got %08x\n", hr
);
2057 ok(dst_status
== DBSTATUS_E_BADACCESSOR
, "got %08x\n", dst_status
);
2058 ok(dst_len
== 0x1234, "got %ld\n", dst_len
);
2059 ok(IsEqualGUID(&dst
, &IID_IDCInfo
), "dst has changed\n");
2062 memcpy(src
, &IID_IDataConvert
, sizeof(GUID
));
2064 hr
= IDataConvert_DataConvert(convert
, DBTYPE_GUID
, DBTYPE_GUID
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2065 ok(hr
== S_OK
, "got %08x\n", hr
);
2066 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2067 ok(dst_len
== sizeof(GUID
), "got %ld\n", dst_len
);
2068 ok(IsEqualGUID(&dst
, &IID_IDataConvert
), "didn't get IID_IDataConvert\n");
2071 static void test_converttofiletime(void)
2076 DBSTATUS dst_status
;
2079 memset(&dst
, 0xcc, sizeof(dst
));
2080 ((FILETIME
*)src
)->dwLowDateTime
= 0x12345678;
2081 ((FILETIME
*)src
)->dwHighDateTime
= 0x9abcdef0;
2083 hr
= IDataConvert_DataConvert(convert
, DBTYPE_FILETIME
, DBTYPE_FILETIME
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2085 broken(hr
== DB_E_BADBINDINFO
), /* win98 */
2089 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2090 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
2091 ok(dst
.dwLowDateTime
== 0x12345678, "got %08x\n", dst
.dwLowDateTime
);
2092 ok(dst
.dwHighDateTime
== 0x9abcdef0, "got %08x\n", dst
.dwHighDateTime
);
2096 static void test_converttoui1(void)
2101 DBSTATUS dst_status
;
2106 hr
= IDataConvert_DataConvert(convert
, DBTYPE_EMPTY
, DBTYPE_UI1
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2107 ok(hr
== S_OK
, "got %08x\n", hr
);
2108 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2109 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
2110 ok(dst
== 0, "got %08x\n", dst
);
2114 hr
= IDataConvert_DataConvert(convert
, DBTYPE_NULL
, DBTYPE_UI1
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2115 ok(hr
== DB_E_UNSUPPORTEDCONVERSION
, "got %08x\n", hr
);
2116 ok(dst_status
== DBSTATUS_E_BADACCESSOR
, "got %08x\n", dst_status
);
2117 ok(dst_len
== 0x1234, "got %ld\n", dst_len
);
2118 ok(dst
== 0x12, "got %08x\n", dst
);
2123 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI1
, DBTYPE_UI1
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2124 ok(hr
== S_OK
, "got %08x\n", hr
);
2125 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2126 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
2127 ok(dst
== 0x43, "got %08x\n", dst
);
2132 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI1
, DBTYPE_UI1
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2133 ok(hr
== S_OK
, "got %08x\n", hr
);
2134 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2135 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
2136 ok(dst
== 0xfe, "got %08x\n", dst
);
2139 static void test_converttoui4(void)
2144 DBSTATUS dst_status
;
2149 hr
= IDataConvert_DataConvert(convert
, DBTYPE_EMPTY
, DBTYPE_UI4
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2150 ok(hr
== S_OK
, "got %08x\n", hr
);
2151 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2152 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
2153 ok(dst
== 0, "got %08x\n", dst
);
2157 hr
= IDataConvert_DataConvert(convert
, DBTYPE_NULL
, DBTYPE_UI4
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2158 ok(hr
== DB_E_UNSUPPORTEDCONVERSION
, "got %08x\n", hr
);
2159 ok(dst_status
== DBSTATUS_E_BADACCESSOR
, "got %08x\n", dst_status
);
2160 ok(dst_len
== 0x1234, "got %ld\n", dst_len
);
2161 ok(dst
== 0x12345678, "got %08x\n", dst
);
2164 *(DWORD
*)src
= 0x87654321;
2166 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI4
, DBTYPE_UI4
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2167 ok(hr
== S_OK
, "got %08x\n", hr
);
2168 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2169 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
2170 ok(dst
== 0x87654321, "got %08x\n", dst
);
2173 *(signed short *)src
= 0x4321;
2175 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I2
, DBTYPE_UI4
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2176 ok(hr
== S_OK
, "got %08x\n", hr
);
2177 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2178 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
2179 ok(dst
== 0x4321, "got %08x\n", dst
);
2182 *(signed short *)src
= -1;
2184 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I2
, DBTYPE_UI4
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2185 ok(hr
== DB_E_ERRORSOCCURRED
, "got %08x\n", hr
);
2187 ok(dst_status
== DBSTATUS_E_SIGNMISMATCH
, "got %08x\n", dst_status
);
2189 ok(broken(dst_len
== sizeof(dst
)) || dst_len
== 0x1234 /* W2K+ */, "got %ld\n", dst_len
);
2190 ok(dst
== 0x12345678, "got %08x\n", dst
);
2192 dst_len
= dst
= 0x1234;
2193 V_VT((VARIANT
*)src
) = VT_I2
;
2194 V_I2((VARIANT
*)src
) = 0x4321;
2195 hr
= IDataConvert_DataConvert(convert
, DBTYPE_VARIANT
, DBTYPE_UI4
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2196 ok(hr
== S_OK
, "got %08x\n", hr
);
2197 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2198 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
2199 ok(dst
== 0x4321, "got %08x\n", dst
);
2202 static void test_converttor4(void)
2207 DBSTATUS dst_status
;
2212 hr
= IDataConvert_DataConvert(convert
, DBTYPE_EMPTY
, DBTYPE_R4
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2213 ok(hr
== S_OK
, "got %08x\n", hr
);
2214 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2215 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
2216 ok(dst
== 0.0, "got %f\n", dst
);
2220 hr
= IDataConvert_DataConvert(convert
, DBTYPE_NULL
, DBTYPE_R4
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2221 ok(hr
== DB_E_UNSUPPORTEDCONVERSION
, "got %08x\n", hr
);
2222 ok(dst_status
== DBSTATUS_E_BADACCESSOR
, "got %08x\n", dst_status
);
2223 ok(dst_len
== 0x1234, "got %ld\n", dst_len
);
2224 ok(dst
== 1.0, "got %f\n", dst
);
2227 *(signed int*)src
= 12345678;
2229 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I4
, DBTYPE_R4
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2230 ok(hr
== S_OK
, "got %08x\n", hr
);
2231 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2232 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
2233 ok(dst
== 12345678.0, "got %f\n", dst
);
2236 *(FLOAT
*)src
= 10.0;
2238 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R4
, DBTYPE_R4
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2239 ok(hr
== S_OK
, "got %08x\n", hr
);
2240 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2241 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
2242 ok(dst
== 10.0, "got %f\n", dst
);
2245 static void test_converttocy(void)
2250 DBSTATUS dst_status
;
2255 hr
= IDataConvert_DataConvert(convert
, DBTYPE_EMPTY
, DBTYPE_CY
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2256 ok(hr
== S_OK
, "got %08x\n", hr
);
2257 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2258 ok(dst_len
== sizeof(CY
), "got %ld\n", dst_len
);
2259 ok(dst
.int64
== 0, "didn't get 0\n");
2263 hr
= IDataConvert_DataConvert(convert
, DBTYPE_NULL
, DBTYPE_CY
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2264 ok(hr
== DB_E_UNSUPPORTEDCONVERSION
, "got %08x\n", hr
);
2265 ok(dst_status
== DBSTATUS_E_BADACCESSOR
, "got %08x\n", dst_status
);
2266 ok(dst_len
== 0x1234, "got %ld\n", dst_len
);
2267 ok(dst
.int64
== 0xcc, "dst changed\n");
2272 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I4
, DBTYPE_CY
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2273 ok(hr
== S_OK
, "got %08x\n", hr
);
2274 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2275 ok(dst_len
== sizeof(CY
), "got %ld\n", dst_len
);
2276 ok(dst
.int64
== 12340000, "got %d\n", dst
.s
.Lo
);
2279 ((CY
*)src
)->int64
= 1234;
2281 hr
= IDataConvert_DataConvert(convert
, DBTYPE_CY
, DBTYPE_CY
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2282 ok(hr
== S_OK
, "got %08x\n", hr
);
2283 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2284 ok(dst_len
== sizeof(CY
), "got %ld\n", dst_len
);
2285 ok(dst
.int64
== 1234, "got %d\n", dst
.s
.Lo
);
2288 static void test_converttoui8(void)
2293 DBSTATUS dst_status
;
2296 dst
.QuadPart
= 0xcc;
2298 hr
= IDataConvert_DataConvert(convert
, DBTYPE_EMPTY
, DBTYPE_UI8
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2299 ok(hr
== S_OK
, "got %08x\n", hr
);
2300 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2301 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
2302 ok(dst
.QuadPart
== 0, "got %d\n", (int)dst
.QuadPart
);
2304 dst
.QuadPart
= 0xcc;
2306 hr
= IDataConvert_DataConvert(convert
, DBTYPE_NULL
, DBTYPE_UI8
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2307 ok(hr
== DB_E_UNSUPPORTEDCONVERSION
, "got %08x\n", hr
);
2308 ok(dst_status
== DBSTATUS_E_BADACCESSOR
, "got %08x\n", dst_status
);
2309 ok(dst_len
== 0x1234, "got %ld\n", dst_len
);
2310 ok(dst
.QuadPart
== 0xcc, "dst changed\n");
2312 dst
.QuadPart
= 0xcc;
2315 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I4
, DBTYPE_UI8
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2316 ok(hr
== S_OK
, "got %08x\n", hr
);
2317 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2318 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
2319 ok(dst
.QuadPart
== 1234, "got %d\n", (int)dst
.QuadPart
);
2321 dst
.QuadPart
= 0xcc;
2324 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I4
, DBTYPE_UI8
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2325 ok(hr
== DB_E_ERRORSOCCURRED
, "got %08x\n", hr
);
2327 ok(dst_status
== DBSTATUS_E_SIGNMISMATCH
, "got %08x\n", dst_status
);
2329 ok(dst_len
== 0x1234, "got %ld\n", dst_len
);
2330 ok(dst
.QuadPart
== 0xcc, "got %d\n", (int)dst
.QuadPart
);
2332 dst
.QuadPart
= 0xcc;
2333 ((ULARGE_INTEGER
*)src
)->QuadPart
= 1234;
2335 hr
= IDataConvert_DataConvert(convert
, DBTYPE_UI8
, DBTYPE_UI8
, 0, &dst_len
, src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2336 ok(hr
== S_OK
, "got %08x\n", hr
);
2337 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2338 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
2339 ok(dst
.QuadPart
== 1234, "got %d\n", (int)dst
.QuadPart
);
2342 static void test_getconversionsize(void)
2348 static WCHAR strW
[] = {'t','e','s','t',0};
2349 static char strTest
[] = "test";
2352 /* same way as CanConvert fails here */
2354 hr
= IDataConvert_GetConversionSize(convert
, DBTYPE_NULL
, DBTYPE_BSTR
, NULL
, &dst_len
, NULL
);
2355 ok(hr
== DB_E_UNSUPPORTEDCONVERSION
, "got 0x%08x\n", hr
);
2358 hr
= IDataConvert_GetConversionSize(convert
, DBTYPE_I2
, DBTYPE_I4
, NULL
, &dst_len
, NULL
);
2359 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
2360 ok(dst_len
== 4, "got %ld\n", dst_len
);
2362 hr
= IDataConvert_GetConversionSize(convert
, DBTYPE_I2
, DBTYPE_I4
, NULL
, NULL
, NULL
);
2363 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
2365 /* size doesn't include string size */
2366 str
= SysAllocStringLen(NULL
, 10);
2368 hr
= IDataConvert_GetConversionSize(convert
, DBTYPE_BSTR
, DBTYPE_VARIANT
, NULL
, &dst_len
, str
);
2369 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
2370 ok(dst_len
== sizeof(VARIANT
), "%ld\n", dst_len
);
2374 hr
= IDataConvert_GetConversionSize(convert
, DBTYPE_WSTR
, DBTYPE_WSTR
, NULL
, &dst_len
, strW
);
2375 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
2376 ok(dst_len
== 10, "%ld\n", dst_len
);
2380 hr
= IDataConvert_GetConversionSize(convert
, DBTYPE_WSTR
, DBTYPE_WSTR
, &src_len
, &dst_len
, strW
);
2381 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
2382 ok(dst_len
== 4, "%ld\n", dst_len
);
2386 hr
= IDataConvert_GetConversionSize(convert
, DBTYPE_WSTR
, DBTYPE_WSTR
, &src_len
, &dst_len
, strW
);
2387 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
2388 ok(dst_len
== 22, "%ld\n", dst_len
);
2391 hr
= IDataConvert_GetConversionSize(convert
, DBTYPE_STR
, DBTYPE_WSTR
, NULL
, &dst_len
, strTest
);
2392 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
2393 ok(dst_len
== 10 || broken(dst_len
== 12), "%ld\n", dst_len
);
2397 hr
= IDataConvert_GetConversionSize(convert
, DBTYPE_STR
, DBTYPE_WSTR
, &src_len
, &dst_len
, strTest
);
2398 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
2399 ok(dst_len
== 6, "%ld\n", dst_len
);
2403 hr
= IDataConvert_GetConversionSize(convert
, DBTYPE_STR
, DBTYPE_WSTR
, &src_len
, &dst_len
, strTest
);
2404 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
2405 ok(dst_len
== 42, "%ld\n", dst_len
);
2408 V_VT(&var
) = VT_BSTR
;
2409 V_BSTR(&var
) = SysAllocString(strW
);
2410 hr
= IDataConvert_GetConversionSize(convert
, DBTYPE_VARIANT
, DBTYPE_WSTR
, NULL
, &dst_len
, &var
);
2411 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
2412 ok(dst_len
== 10, "%ld\n", dst_len
);
2417 V_VT(&var
) = VT_BSTR
;
2418 V_BSTR(&var
) = SysAllocString(strW
);
2419 hr
= IDataConvert_GetConversionSize(convert
, DBTYPE_VARIANT
, DBTYPE_WSTR
, &src_len
, &dst_len
, &var
);
2420 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
2421 ok(dst_len
== 10, "%ld\n", dst_len
);
2428 hr
= IDataConvert_GetConversionSize(convert
, DBTYPE_VARIANT
, DBTYPE_WSTR
, &src_len
, &dst_len
, &var
);
2429 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
2430 todo_wine
ok(dst_len
== 110, "%ld\n", dst_len
);
2435 static void test_converttobytes(void)
2439 BYTE byte_src
[] = {0, 1, 2, 4, 5};
2441 DBSTATUS dst_status
;
2444 hr
= IDataConvert_DataConvert(convert
, DBTYPE_BYTES
, DBTYPE_BYTES
, sizeof(byte_src
), &dst_len
, byte_src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2445 ok(hr
== S_OK
, "got %08x\n", hr
);
2446 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2447 ok(dst_len
== sizeof(byte_src
), "got %ld\n", dst_len
);
2448 ok(!memcmp(byte_src
, dst
, dst_len
), "bytes differ\n");
2451 hr
= IDataConvert_DataConvert(convert
, DBTYPE_BYTES
, DBTYPE_BYTES
, sizeof(byte_src
), &dst_len
, byte_src
, &dst
, 2, 0, &dst_status
, 0, 0, 0);
2452 ok(hr
== S_OK
, "got %08x\n", hr
);
2453 ok(dst_status
== DBSTATUS_S_TRUNCATED
, "got %08x\n", dst_status
);
2454 ok(dst_len
== sizeof(byte_src
), "got %ld\n", dst_len
);
2455 ok(!memcmp(byte_src
, dst
, 2 ), "bytes differ\n");
2458 static void test_converttodbdate(void)
2462 DBDATE ts
= {2013, 5, 14};
2464 DBSTATUS dst_status
;
2467 hr
= IDataConvert_DataConvert(convert
, DBTYPE_DBDATE
, DBTYPE_DBDATE
, sizeof(ts
), &dst_len
, &ts
, &dst
, 2, 0, &dst_status
, 0, 0, 0);
2468 ok(hr
== S_OK
, "got %08x\n", hr
);
2469 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2470 ok(dst_len
== sizeof(DBDATE
), "got %ld\n", dst_len
);
2471 ok(!memcmp(&ts
, &dst
, sizeof(DBDATE
) ), "bytes differ\n");
2476 static void test_converttovar(void)
2478 static WCHAR strW
[] = {'t','e','s','t',0};
2479 BYTE byte_src
[5] = {1, 2, 3, 4, 5};
2480 DBTIMESTAMP ts
= {2013, 5, 14, 2, 4, 12, 0};
2481 DBDATE dbdate
= {2013, 5, 15};
2482 double dvalue
= 123.56;
2483 DBSTATUS dst_status
;
2491 VARIANT_BOOL boolean
= VARIANT_TRUE
;
2493 V_VT(&dst
) = VT_EMPTY
;
2495 dst_status
= DBSTATUS_S_DEFAULT
;
2496 hr
= IDataConvert_DataConvert(convert
, DBTYPE_WSTR
, DBTYPE_VARIANT
, sizeof(strW
), &dst_len
, strW
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2497 ok(hr
== S_OK
, "got %08x\n", hr
);
2498 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2499 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
2500 ok(V_VT(&dst
) == VT_BSTR
, "got %d\n", V_VT(&dst
));
2501 ok(!lstrcmpW(V_BSTR(&dst
), strW
), "got %s\n", wine_dbgstr_w(V_BSTR(&dst
)));
2504 /* with null dest length and status */
2505 V_VT(&dst
) = VT_EMPTY
;
2506 hr
= IDataConvert_DataConvert(convert
, DBTYPE_WSTR
, DBTYPE_VARIANT
, sizeof(strW
), NULL
, strW
, &dst
, sizeof(dst
), 0, NULL
, 0, 0, 0);
2507 ok(hr
== S_OK
, "got %08x\n", hr
);
2508 ok(V_VT(&dst
) == VT_BSTR
, "got %d\n", V_VT(&dst
));
2509 ok(!lstrcmpW(V_BSTR(&dst
), strW
), "got %s\n", wine_dbgstr_w(V_BSTR(&dst
)));
2512 V_VT(&dst
) = VT_EMPTY
;
2514 dst_status
= DBSTATUS_S_DEFAULT
;
2515 i8
.QuadPart
= 12345;
2517 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I8
, DBTYPE_VARIANT
, sizeof(i8
), &dst_len
, &i8
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2518 ok(hr
== S_OK
, "got %08x\n", hr
);
2519 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2520 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
2521 ok(V_VT(&dst
) == VT_DECIMAL
, "got %d\n", V_VT(&dst
));
2522 ok(S(U(V_DECIMAL(&dst
))).scale
== 0 && S(U(V_DECIMAL(&dst
))).sign
== 0 &&
2523 V_DECIMAL(&dst
).Hi32
== 0 && U1(V_DECIMAL(&dst
)).Lo64
== 12345, "Not Equal\n");
2525 V_VT(&dst
) = VT_EMPTY
;
2527 dst_status
= DBSTATUS_S_DEFAULT
;
2528 hr
= IDataConvert_DataConvert(convert
, DBTYPE_R8
, DBTYPE_VARIANT
, sizeof(dvalue
), &dst_len
, &dvalue
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2529 ok(hr
== S_OK
, "got %08x\n", hr
);
2530 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2531 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
2532 ok(V_VT(&dst
) == VT_R8
, "got %d\n", V_VT(&dst
));
2533 ok(V_R8(&dst
) == 123.56, "got %f\n", V_R8(&dst
));
2535 V_VT(&dst
) = VT_EMPTY
;
2537 dst_status
= DBSTATUS_S_DEFAULT
;
2538 hr
= IDataConvert_DataConvert(convert
, DBTYPE_BOOL
, DBTYPE_VARIANT
, sizeof(boolean
), &dst_len
, &boolean
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2539 ok(hr
== S_OK
, "got %08x\n", hr
);
2540 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2541 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
2542 ok(V_VT(&dst
) == VT_BOOL
, "got %d\n", V_VT(&dst
));
2543 ok(V_BOOL(&dst
) == VARIANT_TRUE
, "got %d\n", V_BOOL(&dst
));
2545 V_VT(&dst
) = VT_EMPTY
;
2547 dst_status
= DBSTATUS_S_DEFAULT
;
2549 hr
= IDataConvert_DataConvert(convert
, DBTYPE_I4
, DBTYPE_VARIANT
, sizeof(i4
), &dst_len
, &i4
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2550 ok(hr
== S_OK
, "got %08x\n", hr
);
2551 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2552 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
2553 ok(V_VT(&dst
) == VT_I4
, "got %d\n", V_VT(&dst
));
2554 ok(V_I4(&dst
) == 123, "got %d\n", V_I4(&dst
));
2556 V_VT(&dst
) = VT_EMPTY
;
2558 dst_status
= DBSTATUS_S_DEFAULT
;
2560 hr
= IDataConvert_DataConvert(convert
, DBTYPE_DATE
, DBTYPE_VARIANT
, sizeof(date
), &dst_len
, &date
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2561 ok(hr
== S_OK
, "got %08x\n", hr
);
2562 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2563 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
2564 ok(V_VT(&dst
) == VT_DATE
, "got %d\n", V_VT(&dst
));
2565 ok(V_DATE(&dst
) == 123.123, "got %f\n", V_DATE(&dst
));
2567 V_VT(&dst
) = VT_EMPTY
;
2569 dst_status
= DBSTATUS_S_DEFAULT
;
2572 hr
= IDataConvert_DataConvert(convert
, DBTYPE_CY
, DBTYPE_VARIANT
, sizeof(cy
), &dst_len
, &cy
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2573 ok(hr
== S_OK
, "got %08x\n", hr
);
2574 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2575 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
2576 ok(V_VT(&dst
) == VT_CY
, "got %d\n", V_VT(&dst
));
2579 ok(S(cy2
).Lo
== S(cy
).Lo
&& S(cy2
).Hi
== S(cy
).Hi
, "got %d,%d\n", S(cy2
).Lo
, S(cy2
).Hi
);
2582 hr
= IDataConvert_DataConvert(convert
, DBTYPE_BYTES
, DBTYPE_VARIANT
, 0, &dst_len
, &byte_src
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2583 ok(hr
== S_OK
, "got %08x\n", hr
);
2584 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2585 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
2586 ok(V_VT(&dst
) == (VT_ARRAY
|VT_UI1
), "got %d\n", V_VT(&dst
));
2590 hr
= IDataConvert_DataConvert(convert
, DBTYPE_DBTIMESTAMP
, DBTYPE_VARIANT
, 0, &dst_len
, &ts
, &dst
, sizeof(ts
), 0, &dst_status
, 0, 0, 0);
2591 ok(hr
== S_OK
, "got %08x\n", hr
);
2592 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2593 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
2594 ok(V_VT(&dst
) == VT_DATE
, "got %d\n", V_VT(&dst
));
2595 ok( (float)V_DATE(&dst
) == 41408.086250f
, "got %f\n", V_DATE(&dst
));
2598 hr
= IDataConvert_DataConvert(convert
, DBTYPE_DBDATE
, DBTYPE_VARIANT
, 0, &dst_len
, &dbdate
, &dst
, sizeof(dbdate
), 0, &dst_status
, 0, 0, 0);
2599 ok(hr
== S_OK
, "got %08x\n", hr
);
2600 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2601 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
2602 ok(V_VT(&dst
) == VT_DATE
, "got %d\n", V_VT(&dst
));
2603 ok( (float)V_DATE(&dst
) == 41409.0, "got %f\n", V_DATE(&dst
));
2606 static void test_converttotimestamp(void)
2608 DBTIMESTAMP ts
= {2013, 5, 14, 2, 4, 12, 0};
2610 DBSTATUS dst_status
;
2616 V_VT(&var
) = VT_DATE
;
2617 V_DATE(&var
) = 41408.086250;
2619 hr
= IDataConvert_DataConvert(convert
, DBTYPE_VARIANT
, DBTYPE_DBTIMESTAMP
, 0, &dst_len
, &var
, &dst
, sizeof(dst
), 0, &dst_status
, 0, 0, 0);
2620 ok(hr
== S_OK
, "got %08x\n", hr
);
2621 ok(dst_status
== DBSTATUS_S_OK
, "got %08x\n", dst_status
);
2622 ok(dst_len
== sizeof(dst
), "got %ld\n", dst_len
);
2623 ok(!memcmp(&ts
, &dst
, sizeof(ts
)), "Wrong timestamp\n");
2630 OleInitialize(NULL
);
2634 hr
= CoCreateInstance(&CLSID_OLEDB_CONVERSIONLIBRARY
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDataConvert
, (void**)&convert
);
2637 win_skip("Unable to create IDataConvert instance, 0x%08x\n", hr
);
2646 test_converttostr();
2647 test_converttobstr();
2648 test_converttowstr();
2649 test_converttobyrefwstr();
2650 test_converttoguid();
2651 test_converttoui1();
2652 test_converttoui4();
2654 test_converttofiletime();
2656 test_converttoui8();
2657 test_converttovar();
2658 test_converttobytes();
2659 test_converttodbdate();
2660 test_getconversionsize();
2661 test_converttotimestamp();
2663 IDataConvert_Release(convert
);