4 * Copyright 1998 Jean-Claude Cote
5 * Copyright 2006 Google (Benjamin Arai)
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
30 #include "wine/test.h"
40 static HMODULE hOleaut32
;
42 static HRESULT (WINAPI
*pVarUdateFromDate
)(DATE
,ULONG
,UDATE
*);
43 static HRESULT (WINAPI
*pVarDateFromUdate
)(UDATE
*,ULONG
,DATE
*);
44 static INT (WINAPI
*pSystemTimeToVariantTime
)(LPSYSTEMTIME
,double*);
45 static INT (WINAPI
*pVariantTimeToSystemTime
)(double,LPSYSTEMTIME
);
46 static INT (WINAPI
*pDosDateTimeToVariantTime
)(USHORT
,USHORT
,double*);
47 static INT (WINAPI
*pVariantTimeToDosDateTime
)(double,USHORT
*,USHORT
*);
49 /* Get a conversion function ptr, return if function not available */
50 #define CHECKPTR(func) p##func = (void*)GetProcAddress(hOleaut32, #func); \
51 if (!p##func) { trace("function " # func " not available, not testing it\n"); return; }
53 /* Have IRecordInfo data type? */
54 static int HAVE_OLEAUT32_RECORD
= 0;
55 /* Have I8/UI8 data type? */
56 static int HAVE_OLEAUT32_I8
= 0;
57 /* Is this an ancient version with support for only I2/I4/R4/R8/DATE? */
58 static int IS_ANCIENT
= 0;
60 /* When comparing floating point values we cannot expect an exact match
61 * because the rounding errors depend on the exact algorithm.
63 #define EQ_DOUBLE(a,b) (fabs((a)-(b)) / (1.0+fabs(a)+fabs(b)) < 1e-14)
64 #define EQ_FLOAT(a,b) (fabs((a)-(b)) / (1.0+fabs(a)+fabs(b)) < 1e-7)
66 #define SKIPTESTS(a) if((a > VT_CLSID+10) && (a < VT_BSTR_BLOB-10)) continue
68 /* Allow our test macros to work for VT_NULL and VT_EMPTY too */
69 #define V_EMPTY(v) V_I4(v)
70 #define V_NULL(v) V_I4(v)
72 /* Size constraints for overflow tests */
74 #define I1_MIN ((-I1_MAX)-1)
78 #define I2_MIN ((-I2_MAX)-1)
79 #define UI2_MAX 0xffff
81 #define I4_MAX 0x7fffffff
82 #define I4_MIN ((-I4_MAX)-1)
83 #define UI4_MAX 0xffffffff
85 #define I8_MAX (((LONGLONG)I4_MAX << 32) | UI4_MAX)
86 #define I8_MIN ((-I8_MAX)-1)
87 #define UI8_MAX (((ULONGLONG)UI4_MAX << 32) | UI4_MAX)
89 #define DATE_MAX 2958465
90 #define DATE_MIN -657434
91 #define R4_MAX FLT_MAX
92 #define R4_MIN FLT_MIN
93 #define R8_MAX DBL_MAX
94 #define R8_MIN DBL_MIN
96 static void init(void)
98 hOleaut32
= GetModuleHandle("oleaut32.dll");
100 /* Is a given function exported from oleaut32? */
101 #define HAVE_FUNC(func) ((void*)GetProcAddress(hOleaut32, #func) != NULL)
103 HAVE_OLEAUT32_I8
= HAVE_FUNC(VarI8FromI1
);
104 if (!HAVE_OLEAUT32_I8
)
105 skip("No support for I8 and UI8 data types\n");
107 HAVE_OLEAUT32_RECORD
= HAVE_FUNC(SafeArraySetRecordInfo
);
108 IS_ANCIENT
= (!HAVE_FUNC(VarI1FromI2
));
113 /* Functions to set a DECIMAL */
114 static void setdec(DECIMAL
* dec
, BYTE scl
, BYTE sgn
, ULONG hi32
, ULONG64 lo64
)
116 S(U(*dec
)).scale
= scl
;
117 S(U(*dec
)).sign
= sgn
;
119 U1(*dec
).Lo64
= lo64
;
122 static void setdec64(DECIMAL
* dec
, BYTE scl
, BYTE sgn
, ULONG hi32
, ULONG mid32
, ULONG lo32
)
124 S(U(*dec
)).scale
= scl
;
125 S(U(*dec
)).sign
= sgn
;
127 S1(U1(*dec
)).Mid32
= mid32
;
128 S1(U1(*dec
)).Lo32
= lo32
;
131 static inline int strcmpW( const WCHAR
*str1
, const WCHAR
*str2
)
133 while (*str1
&& (*str1
== *str2
)) { str1
++; str2
++; }
134 return *str1
- *str2
;
137 /* return the string text of a given variant type */
138 static char vtstr_buffer
[16][256];
139 static int vtstr_current
=0;
140 static const char *vtstr(int x
)
143 #define CASE(vt) case VT_##vt: return #vt
182 CASE(STREAMED_OBJECT
);
187 CASE(VERSIONED_STREAM
);
196 return "VT_BSTR_BLOB/VT_ILLEGALMASKED/VT_TYPEMASK";
199 vtstr_current
%= sizeof(vtstr_buffer
)/sizeof(*vtstr_buffer
);
200 sprintf(vtstr_buffer
[vtstr_current
], "unknown variant type %d", x
);
201 return vtstr_buffer
[vtstr_current
++];
205 static const char *variantstr( const VARIANT
*var
)
207 vtstr_current
%= sizeof(vtstr_buffer
)/sizeof(*vtstr_buffer
);
211 sprintf( vtstr_buffer
[vtstr_current
], "VT_I1(%d)", V_I1(var
) ); break;
213 sprintf( vtstr_buffer
[vtstr_current
], "VT_I2(%d)", V_I2(var
) ); break;
215 sprintf( vtstr_buffer
[vtstr_current
], "VT_I4(%d)", V_I4(var
) ); break;
217 sprintf( vtstr_buffer
[vtstr_current
], "VT_INT(%d)", V_INT(var
) ); break;
219 sprintf( vtstr_buffer
[vtstr_current
], "VT_I8(%x%08x)", (UINT
)(V_I8(var
) >> 32), (UINT
)V_I8(var
) ); break;
221 sprintf( vtstr_buffer
[vtstr_current
], "VT_UI8(%x%08x)", (UINT
)(V_UI8(var
) >> 32), (UINT
)V_UI8(var
) ); break;
223 sprintf( vtstr_buffer
[vtstr_current
], "VT_R4(%g)", V_R4(var
) ); break;
225 sprintf( vtstr_buffer
[vtstr_current
], "VT_R8(%g)", V_R8(var
) ); break;
227 sprintf( vtstr_buffer
[vtstr_current
], "VT_UI1(%u)", V_UI1(var
) ); break;
229 sprintf( vtstr_buffer
[vtstr_current
], "VT_UI2(%u)", V_UI2(var
) ); break;
231 sprintf( vtstr_buffer
[vtstr_current
], "VT_UI4(%u)", V_UI4(var
) ); break;
233 sprintf( vtstr_buffer
[vtstr_current
], "VT_UINT(%d)", V_UINT(var
) ); break;
235 sprintf( vtstr_buffer
[vtstr_current
], "VT_CY(%x%08x)", S(V_CY(var
)).Hi
, S(V_CY(var
)).Lo
); break;
237 sprintf( vtstr_buffer
[vtstr_current
], "VT_DATE(%g)", V_DATE(var
) ); break;
239 return vtstr(V_VT(var
));
241 return vtstr_buffer
[vtstr_current
++];
244 static BOOL
is_expected_variant( const VARIANT
*result
, const VARIANT
*expected
)
246 if (V_VT(result
) != V_VT(expected
)) return FALSE
;
247 switch(V_VT(expected
))
253 #define CASE(vt) case VT_##vt: return (V_##vt(result) == V_##vt(expected))
268 return EQ_FLOAT(V_DATE(result
), V_DATE(expected
));
270 return EQ_FLOAT(V_R4(result
), V_R4(expected
));
272 return EQ_FLOAT(V_R8(result
), V_R8(expected
));
274 return (V_CY(result
).int64
== V_CY(expected
).int64
);
276 return !lstrcmpW( V_BSTR(result
), V_BSTR(expected
) );
278 return !memcmp( &V_DECIMAL(result
), &V_DECIMAL(expected
), sizeof(DECIMAL
) );
280 ok(0, "unhandled variant type %s\n",vtstr(V_VT(expected
)));
285 static void test_var_call1( int line
, HRESULT (WINAPI
*func
)(LPVARIANT
,LPVARIANT
),
286 VARIANT
*arg
, VARIANT
*expected
)
288 VARIANT old_arg
= *arg
;
292 memset( &result
, 0, sizeof(result
) );
293 hres
= func( arg
, &result
);
294 ok_(__FILE__
,line
)( hres
== S_OK
, "wrong result %x\n", hres
);
296 ok_(__FILE__
,line
)( is_expected_variant( &result
, expected
),
297 "got %s expected %s\n", variantstr(&result
), variantstr(expected
) );
298 ok_(__FILE__
,line
)( is_expected_variant( arg
, &old_arg
), "Modified argument %s / %s\n",
299 variantstr(&old_arg
), variantstr(arg
));
300 VariantClear( &result
);
303 static void test_var_call2( int line
, HRESULT (WINAPI
*func
)(LPVARIANT
,LPVARIANT
,LPVARIANT
),
304 VARIANT
*left
, VARIANT
*right
, VARIANT
*expected
)
306 VARIANT old_left
= *left
, old_right
= *right
;
310 memset( &result
, 0, sizeof(result
) );
311 hres
= func( left
, right
, &result
);
312 ok_(__FILE__
,line
)( hres
== S_OK
, "wrong result %x\n", hres
);
314 ok_(__FILE__
,line
)( is_expected_variant( &result
, expected
),
315 "got %s expected %s\n", variantstr(&result
), variantstr(expected
) );
316 ok_(__FILE__
,line
)( is_expected_variant( left
, &old_left
), "Modified left argument %s / %s\n",
317 variantstr(&old_left
), variantstr(left
));
318 ok_(__FILE__
,line
)( is_expected_variant( right
, &old_right
), "Modified right argument %s / %s\n",
319 variantstr(&old_right
), variantstr(right
));
320 VariantClear( &result
);
324 static void test_VariantInit(void)
328 /* Test that VariantInit() only sets the type */
329 memset(&v1
, -1, sizeof(v1
));
331 V_VT(&v2
) = VT_EMPTY
;
333 ok(!memcmp(&v1
, &v2
, sizeof(v1
)), "VariantInit() set extra fields\n");
336 /* All possible combinations of extra V_VT() flags */
337 static const VARTYPE ExtraFlags
[16] =
346 VT_VECTOR
|VT_RESERVED
,
347 VT_VECTOR
|VT_ARRAY
|VT_BYREF
,
348 VT_VECTOR
|VT_ARRAY
|VT_RESERVED
,
349 VT_VECTOR
|VT_BYREF
|VT_RESERVED
,
350 VT_VECTOR
|VT_ARRAY
|VT_BYREF
|VT_RESERVED
,
352 VT_ARRAY
|VT_RESERVED
,
353 VT_ARRAY
|VT_BYREF
|VT_RESERVED
,
354 VT_BYREF
|VT_RESERVED
,
357 /* Determine if a vt is valid for VariantClear() */
358 static int IsValidVariantClearVT(VARTYPE vt
, VARTYPE extraFlags
)
362 /* Only the following flags/types are valid */
363 if ((vt
<= VT_LPWSTR
|| vt
== VT_RECORD
|| vt
== VT_CLSID
) &&
365 (vt
< (VARTYPE
)24 || vt
> (VARTYPE
)31) &&
366 (!(extraFlags
& (VT_BYREF
|VT_ARRAY
)) || vt
> VT_NULL
) &&
367 (extraFlags
== 0 || extraFlags
== VT_BYREF
|| extraFlags
== VT_ARRAY
||
368 extraFlags
== (VT_ARRAY
|VT_BYREF
)))
371 if ((vt
== VT_RECORD
&& !HAVE_OLEAUT32_RECORD
) ||
372 ((vt
== VT_I8
|| vt
== VT_UI8
) && !HAVE_OLEAUT32_I8
))
373 ret
= 0; /* Old versions of oleaut32 */
379 const IUnknownVtbl
*lpVtbl
;
382 } test_VariantClearImpl
;
384 static HRESULT WINAPI
VC_QueryInterface(LPUNKNOWN iface
,REFIID riid
,LPVOID
*ppobj
)
386 test_VariantClearImpl
*This
= (test_VariantClearImpl
*)iface
;
388 return E_NOINTERFACE
;
391 static ULONG WINAPI
VC_AddRef(LPUNKNOWN iface
) {
392 test_VariantClearImpl
*This
= (test_VariantClearImpl
*)iface
;
394 return InterlockedIncrement(&This
->ref
);
397 static ULONG WINAPI
VC_Release(LPUNKNOWN iface
) {
398 test_VariantClearImpl
*This
= (test_VariantClearImpl
*)iface
;
399 /* static class, won't be freed */
401 return InterlockedDecrement(&This
->ref
);
404 static const IUnknownVtbl test_VariantClear_vtbl
= {
410 static test_VariantClearImpl test_myVariantClearImpl
= {&test_VariantClear_vtbl
, 1, 0};
412 static void test_VariantClear(void)
421 /* Crashes: Native does not test input for NULL, so neither does Wine */
422 if (0) hres
= VariantClear(NULL
);
424 /* Only the type field is set, to VT_EMPTY */
427 hres
= VariantClear(&v
);
428 ok((hres
== S_OK
&& V_VT(&v
) == VT_EMPTY
) ||
429 (IS_ANCIENT
&& hres
== DISP_E_BADVARTYPE
&& V_VT(&v
) == VT_UI4
),
430 "VariantClear: Type set to %d, res %08x\n", V_VT(&v
), hres
);
431 ok(V_UI4(&v
) == ~0u, "VariantClear: Overwrote value\n");
433 /* Test all possible V_VT values.
434 * Also demonstrates that null pointers in 'v' are not dereferenced.
435 * Individual variant tests should test VariantClear() with non-NULL values.
437 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]) && !IS_ANCIENT
; i
++)
441 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
443 HRESULT hExpected
= DISP_E_BADVARTYPE
;
447 memset(&v
, 0, sizeof(v
));
448 V_VT(&v
) = vt
| ExtraFlags
[i
];
450 hres
= VariantClear(&v
);
452 if (IsValidVariantClearVT(vt
, ExtraFlags
[i
]))
455 ok(hres
== hExpected
, "VariantClear: expected 0x%X, got 0x%X for vt %d | 0x%X\n",
456 hExpected
, hres
, vt
, ExtraFlags
[i
]);
460 /* Some BYREF tests with non-NULL ptrs */
465 V_VT(&v
) = VT_VARIANT
| VT_BYREF
;
466 V_VARIANTREF(&v
) = &v2
;
468 hres
= VariantClear(&v
);
469 ok(hres
== S_OK
, "ret %08x\n", hres
);
470 ok(V_VT(&v
) == 0, "vt %04x\n", V_VT(&v
));
471 ok(V_VARIANTREF(&v
) == &v2
, "variant ref %p\n", V_VARIANTREF(&v2
));
472 ok(V_VT(&v2
) == VT_I4
, "vt %04x\n", V_VT(&v2
));
473 ok(V_I4(&v2
) == 0x1234, "i4 %04x\n", V_I4(&v2
));
477 V_VT(&v
) = VT_I4
| VT_BYREF
;
480 hres
= VariantClear(&v
);
481 ok(hres
== S_OK
, "ret %08x\n", hres
);
482 ok(V_VT(&v
) == 0, "vt %04x\n", V_VT(&v
));
483 ok(V_I4REF(&v
) == &i4
, "i4 ref %p\n", V_I4REF(&v2
));
484 ok(i4
== 0x4321, "i4 changed %08x\n", i4
);
488 V_VT(&v
) = VT_UNKNOWN
;
489 V_UNKNOWN(&v
) = (IUnknown
*)&test_myVariantClearImpl
;
490 test_myVariantClearImpl
.events
= 0;
491 hres
= VariantClear(&v
);
492 ok(hres
== S_OK
, "ret %08x\n", hres
);
493 ok(V_VT(&v
) == 0, "vt %04x\n", V_VT(&v
));
494 ok(V_UNKNOWN(&v
) == (IUnknown
*)&test_myVariantClearImpl
, "unknown %p\n", V_UNKNOWN(&v
));
495 /* Check that Release got called, but nothing else */
496 ok(test_myVariantClearImpl
.events
== 0x4, "Unexpected call. events %08x\n", test_myVariantClearImpl
.events
);
499 punk
= (IUnknown
*)&test_myVariantClearImpl
;
500 V_VT(&v
) = VT_UNKNOWN
| VT_BYREF
;
501 V_UNKNOWNREF(&v
) = &punk
;
502 test_myVariantClearImpl
.events
= 0;
503 hres
= VariantClear(&v
);
504 ok(hres
== S_OK
, "ret %08x\n", hres
);
505 ok(V_VT(&v
) == 0, "vt %04x\n", V_VT(&v
));
506 ok(V_UNKNOWNREF(&v
) == &punk
, "unknown ref %p\n", V_UNKNOWNREF(&v
));
507 /* Check that nothing got called */
508 ok(test_myVariantClearImpl
.events
== 0, "Unexpected call. events %08x\n", test_myVariantClearImpl
.events
);
511 V_VT(&v
) = VT_DISPATCH
;
512 V_DISPATCH(&v
) = (IDispatch
*)&test_myVariantClearImpl
;
513 test_myVariantClearImpl
.events
= 0;
514 hres
= VariantClear(&v
);
515 ok(hres
== S_OK
, "ret %08x\n", hres
);
516 ok(V_VT(&v
) == 0, "vt %04x\n", V_VT(&v
));
517 ok(V_DISPATCH(&v
) == (IDispatch
*)&test_myVariantClearImpl
, "dispatch %p\n", V_DISPATCH(&v
));
518 /* Check that Release got called, but nothing else */
519 ok(test_myVariantClearImpl
.events
== 0x4, "Unexpected call. events %08x\n", test_myVariantClearImpl
.events
);
522 punk
= (IUnknown
*)&test_myVariantClearImpl
;
523 V_VT(&v
) = VT_DISPATCH
| VT_BYREF
;
524 V_DISPATCHREF(&v
) = (IDispatch
**)&punk
;
525 test_myVariantClearImpl
.events
= 0;
526 hres
= VariantClear(&v
);
527 ok(hres
== S_OK
, "ret %08x\n", hres
);
528 ok(V_VT(&v
) == 0, "vt %04x\n", V_VT(&v
));
529 ok(V_DISPATCHREF(&v
) == (IDispatch
**)&punk
, "dispatch ref %p\n", V_DISPATCHREF(&v
));
530 /* Check that nothing got called */
531 ok(test_myVariantClearImpl
.events
== 0, "Unexpected call. events %08x\n", test_myVariantClearImpl
.events
);
534 static void test_VariantCopy(void)
536 VARIANTARG vSrc
, vDst
;
539 HRESULT hres
, hExpected
;
541 /* Establish that the failure/other cases are dealt with. Individual tests
542 * for each type should verify that data is copied correctly, references
547 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]) && !IS_ANCIENT
; i
++)
549 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
553 memset(&vSrc
, 0, sizeof(vSrc
));
554 V_VT(&vSrc
) = vt
| ExtraFlags
[i
];
556 hExpected
= DISP_E_BADVARTYPE
;
557 /* src is allowed to be a VT_CLSID */
558 if (vt
!= VT_CLSID
&& IsValidVariantClearVT(vt
, ExtraFlags
[i
]))
561 hres
= VariantCopy(&vSrc
, &vSrc
);
563 ok(hres
== hExpected
,
564 "Copy(src==dst): expected 0x%X, got 0x%X for src==dest vt %d|0x%X\n",
565 hExpected
, hres
, vt
, ExtraFlags
[i
]);
569 /* Test that if VariantClear() fails on dest, the function fails. This also
570 * shows that dest is in fact cleared and not just overwritten
572 memset(&vSrc
, 0, sizeof(vSrc
));
573 V_VT(&vSrc
) = VT_UI1
;
575 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]) && !IS_ANCIENT
; i
++)
577 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
581 hExpected
= DISP_E_BADVARTYPE
;
583 memset(&vDst
, 0, sizeof(vDst
));
584 V_VT(&vDst
) = vt
| ExtraFlags
[i
];
586 if (IsValidVariantClearVT(vt
, ExtraFlags
[i
]))
589 hres
= VariantCopy(&vDst
, &vSrc
);
591 ok(hres
== hExpected
,
592 "Copy(bad dst): expected 0x%X, got 0x%X for dest vt %d|0x%X\n",
593 hExpected
, hres
, vt
, ExtraFlags
[i
]);
595 ok(V_VT(&vDst
) == VT_UI1
,
596 "Copy(bad dst): expected vt = VT_UI1, got %d\n", V_VT(&vDst
));
600 /* Test that VariantClear() checks vSrc for validity before copying */
601 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]) && !IS_ANCIENT
; i
++)
603 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
607 hExpected
= DISP_E_BADVARTYPE
;
609 memset(&vDst
, 0, sizeof(vDst
));
610 V_VT(&vDst
) = VT_EMPTY
;
612 memset(&vSrc
, 0, sizeof(vSrc
));
613 V_VT(&vSrc
) = vt
| ExtraFlags
[i
];
615 /* src is allowed to be a VT_CLSID */
616 if (vt
!= VT_CLSID
&& IsValidVariantClearVT(vt
, ExtraFlags
[i
]))
619 hres
= VariantCopy(&vDst
, &vSrc
);
621 ok(hres
== hExpected
,
622 "Copy(bad src): expected 0x%X, got 0x%X for src vt %d|0x%X\n",
623 hExpected
, hres
, vt
, ExtraFlags
[i
]);
626 ok(V_VT(&vDst
) == (vt
|ExtraFlags
[i
]),
627 "Copy(bad src): expected vt = %d, got %d\n",
628 vt
| ExtraFlags
[i
], V_VT(&vDst
));
634 /* Test that copying a NULL BSTR results in an empty BSTR */
635 memset(&vDst
, 0, sizeof(vDst
));
636 V_VT(&vDst
) = VT_EMPTY
;
637 memset(&vSrc
, 0, sizeof(vSrc
));
638 V_VT(&vSrc
) = VT_BSTR
;
639 hres
= VariantCopy(&vDst
, &vSrc
);
640 ok(hres
== S_OK
, "Copy(NULL BSTR): Failed to copy a NULL BSTR\n");
643 ok((V_VT(&vDst
) == VT_BSTR
) && V_BSTR(&vDst
),
644 "Copy(NULL BSTR): should have non-NULL result\n");
645 if ((V_VT(&vDst
) == VT_BSTR
) && V_BSTR(&vDst
))
647 ok(*V_BSTR(&vDst
) == 0, "Copy(NULL BSTR): result not empty\n");
653 /* Determine if a vt is valid for VariantCopyInd() */
654 static int IsValidVariantCopyIndVT(VARTYPE vt
, VARTYPE extraFlags
)
658 if ((extraFlags
& VT_ARRAY
) ||
659 (vt
> VT_NULL
&& vt
!= (VARTYPE
)15 && vt
< VT_VOID
&&
660 !(extraFlags
& (VT_VECTOR
|VT_RESERVED
))))
667 static void test_VariantCopyInd(void)
669 VARIANTARG vSrc
, vDst
, vRef
, vRef2
;
673 HRESULT hres
, hExpected
;
675 memset(buffer
, 0, sizeof(buffer
));
678 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]) && !IS_ANCIENT
; i
++)
680 if (ExtraFlags
[i
] & VT_ARRAY
)
681 continue; /* Native crashes on NULL safearray */
683 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
687 memset(&vSrc
, 0, sizeof(vSrc
));
688 V_VT(&vSrc
) = vt
| ExtraFlags
[i
];
690 hExpected
= DISP_E_BADVARTYPE
;
691 if (!(ExtraFlags
[i
] & VT_BYREF
))
693 /* if src is not by-reference, acts as VariantCopy() */
694 if (vt
!= VT_CLSID
&& IsValidVariantClearVT(vt
, ExtraFlags
[i
]))
699 if (vt
== VT_SAFEARRAY
|| vt
== VT_BSTR
|| vt
== VT_UNKNOWN
||
700 vt
== VT_DISPATCH
|| vt
== VT_RECORD
)
701 continue; /* Need valid ptrs for deep copies */
703 V_BYREF(&vSrc
) = &buffer
;
704 hExpected
= E_INVALIDARG
;
706 if ((vt
== VT_I8
|| vt
== VT_UI8
) &&
707 ExtraFlags
[i
] == VT_BYREF
)
709 if (HAVE_OLEAUT32_I8
)
710 hExpected
= S_OK
; /* Only valid if I8 is a known type */
712 else if (IsValidVariantCopyIndVT(vt
, ExtraFlags
[i
]))
716 hres
= VariantCopyInd(&vSrc
, &vSrc
);
718 ok(hres
== hExpected
,
719 "CopyInd(src==dst): expected 0x%X, got 0x%X for src==dst vt %d|0x%X\n",
720 hExpected
, hres
, vt
, ExtraFlags
[i
]);
725 memset(&vSrc
, 0, sizeof(vSrc
));
726 V_VT(&vSrc
) = VT_UI1
|VT_BYREF
;
727 V_BYREF(&vSrc
) = &buffer
;
729 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]) && !IS_ANCIENT
; i
++)
731 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
735 memset(&vDst
, 0, sizeof(vDst
));
736 V_VT(&vDst
) = vt
| ExtraFlags
[i
];
738 hExpected
= DISP_E_BADVARTYPE
;
740 if (IsValidVariantClearVT(vt
, ExtraFlags
[i
]))
743 hres
= VariantCopyInd(&vDst
, &vSrc
);
745 ok(hres
== hExpected
,
746 "CopyInd(bad dst): expected 0x%X, got 0x%X for dst vt %d|0x%X\n",
747 hExpected
, hres
, vt
, ExtraFlags
[i
]);
749 ok(V_VT(&vDst
) == VT_UI1
,
750 "CopyInd(bad dst): expected vt = VT_UI1, got %d\n", V_VT(&vDst
));
755 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]) && !IS_ANCIENT
; i
++)
757 if (ExtraFlags
[i
] & VT_ARRAY
)
758 continue; /* Native crashes on NULL safearray */
760 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
764 memset(&vDst
, 0, sizeof(vDst
));
765 V_VT(&vDst
) = VT_EMPTY
;
767 memset(&vSrc
, 0, sizeof(vSrc
));
768 V_VT(&vSrc
) = vt
| ExtraFlags
[i
];
770 hExpected
= DISP_E_BADVARTYPE
;
771 if (!(ExtraFlags
[i
] & VT_BYREF
))
773 /* if src is not by-reference, acts as VariantCopy() */
774 if (vt
!= VT_CLSID
&& IsValidVariantClearVT(vt
, ExtraFlags
[i
]))
779 if (vt
== VT_SAFEARRAY
|| vt
== VT_BSTR
|| vt
== VT_UNKNOWN
||
780 vt
== VT_DISPATCH
|| vt
== VT_RECORD
)
781 continue; /* Need valid ptrs for deep copies, see vartype.c */
783 V_BYREF(&vSrc
) = &buffer
;
785 hExpected
= E_INVALIDARG
;
787 if ((vt
== VT_I8
|| vt
== VT_UI8
) &&
788 ExtraFlags
[i
] == VT_BYREF
)
790 if (HAVE_OLEAUT32_I8
)
791 hExpected
= S_OK
; /* Only valid if I8 is a known type */
793 else if (IsValidVariantCopyIndVT(vt
, ExtraFlags
[i
]))
797 hres
= VariantCopyInd(&vDst
, &vSrc
);
799 ok(hres
== hExpected
,
800 "CopyInd(bad src): expected 0x%X, got 0x%X for src vt %d|0x%X\n",
801 hExpected
, hres
, vt
, ExtraFlags
[i
]);
804 if (vt
== VT_VARIANT
&& ExtraFlags
[i
] == VT_BYREF
)
806 /* Type of vDst should be the type of the referenced variant.
807 * Since we set the buffer to all zeros, its type should be
810 ok(V_VT(&vDst
) == VT_EMPTY
,
811 "CopyInd(bad src): expected dst vt = VT_EMPTY, got %d|0x%X\n",
812 V_VT(&vDst
) & VT_TYPEMASK
, V_VT(&vDst
) & ~VT_TYPEMASK
);
816 ok(V_VT(&vDst
) == (vt
|(ExtraFlags
[i
] & ~VT_BYREF
)),
817 "CopyInd(bad src): expected dst vt = %d|0x%X, got %d|0x%X\n",
818 vt
, ExtraFlags
[i
] & ~VT_BYREF
,
819 V_VT(&vDst
) & VT_TYPEMASK
, V_VT(&vDst
) & ~VT_TYPEMASK
);
826 /* By-reference variants are dereferenced */
827 V_VT(&vRef
) = VT_UI1
;
829 V_VT(&vSrc
) = VT_VARIANT
|VT_BYREF
;
830 V_VARIANTREF(&vSrc
) = &vRef
;
833 hres
= VariantCopyInd(&vDst
, &vSrc
);
834 ok(V_VT(&vDst
) == VT_UI1
&& V_UI1(&vDst
) == 0x77,
835 "CopyInd(deref): expected dst vt = VT_UI1, val 0x77, got %d|0x%X, 0x%2X\n",
836 V_VT(&vDst
) & VT_TYPEMASK
, V_VT(&vDst
) & ~VT_TYPEMASK
, V_UI1(&vDst
));
838 /* By-reference variant to a by-reference type succeeds */
839 V_VT(&vRef
) = VT_UI1
|VT_BYREF
;
840 V_UI1REF(&vRef
) = buffer
; buffer
[0] = 0x88;
841 V_VT(&vSrc
) = VT_VARIANT
|VT_BYREF
;
842 V_VARIANTREF(&vSrc
) = &vRef
;
845 hres
= VariantCopyInd(&vDst
, &vSrc
);
846 ok(V_VT(&vDst
) == VT_UI1
&& V_UI1(&vDst
) == 0x88,
847 "CopyInd(deref): expected dst vt = VT_UI1, val 0x77, got %d|0x%X, 0x%2X\n",
848 V_VT(&vDst
) & VT_TYPEMASK
, V_VT(&vDst
) & ~VT_TYPEMASK
, V_UI1(&vDst
));
850 /* But a by-reference variant to a by-reference variant fails */
851 V_VT(&vRef2
) = VT_UI1
;
852 V_UI1(&vRef2
) = 0x77;
853 V_VT(&vRef
) = VT_VARIANT
|VT_BYREF
;
854 V_VARIANTREF(&vRef
) = &vRef2
;
855 V_VT(&vSrc
) = VT_VARIANT
|VT_BYREF
;
856 V_VARIANTREF(&vSrc
) = &vRef
;
859 hres
= VariantCopyInd(&vDst
, &vSrc
);
860 ok(hres
== E_INVALIDARG
,
861 "CopyInd(ref->ref): expected E_INVALIDARG, got 0x%08x\n", hres
);
864 static HRESULT (WINAPI
*pVarParseNumFromStr
)(OLECHAR
*,LCID
,ULONG
,NUMPARSE
*,BYTE
*);
866 /* Macros for converting and testing the result of VarParseNumFromStr */
869 static HRESULT
convert_str( const char *str
, INT dig
, ULONG flags
,
870 NUMPARSE
*np
, BYTE rgb
[128], LCID lcid
)
873 MultiByteToWideChar( CP_ACP
,0, str
, -1, buff
, sizeof(buff
)/sizeof(WCHAR
) );
874 memset( rgb
, FAILDIG
, 128 );
875 memset( np
, 255, sizeof(*np
) );
877 np
->dwInFlags
= flags
;
878 return pVarParseNumFromStr( buff
, lcid
, LOCALE_NOUSEROVERRIDE
, np
, rgb
);
881 static void expect_NumFromStr( int line
, HRESULT hres
, NUMPARSE
*np
, INT a
, ULONG b
, ULONG c
,
882 INT d
, INT e
, INT f
)
884 if (hres
== (HRESULT
)S_OK
)
886 ok_(__FILE__
,line
)(np
->cDig
== a
, "Expected cDig = %d, got %d\n", a
, np
->cDig
);
887 ok_(__FILE__
,line
)(np
->dwInFlags
== b
, "Expected dwInFlags = 0x%x, got 0x%x\n", b
, np
->dwInFlags
);
888 ok_(__FILE__
,line
)(np
->dwOutFlags
== c
, "Expected dwOutFlags = 0x%x, got 0x%x\n", c
, np
->dwOutFlags
);
889 ok_(__FILE__
,line
)(np
->cchUsed
== d
, "Expected cchUsed = %d, got %d\n", d
, np
->cchUsed
);
890 ok_(__FILE__
,line
)(np
->nBaseShift
== e
, "Expected nBaseShift = %d, got %d\n", e
, np
->nBaseShift
);
891 ok_(__FILE__
,line
)(np
->nPwr10
== f
, "Expected nPwr10 = %d, got %d\n", f
, np
->nPwr10
);
895 #define CONVERTN(str,dig,flags) hres = convert_str( str, dig, flags, &np, rgb, lcid )
896 #define CONVERT(str,flags) CONVERTN(str,sizeof(rgb),flags)
897 #define EXPECT(a,b,c,d,e,f) expect_NumFromStr( __LINE__, hres, &np, a, b, c, d, e, f )
898 #define EXPECTRGB(a,b) ok(rgb[a] == b, "Digit[%d], expected %d, got %d\n", a, b, rgb[a])
899 #define EXPECTFAIL ok(hres == (HRESULT)DISP_E_TYPEMISMATCH, "Call succeeded, hres = %08x\n", hres)
900 #define EXPECT2(a,b) EXPECTRGB(0,a); EXPECTRGB(1,b)
902 static void test_VarParseNumFromStr(void)
905 /* Ensure all tests are using the same locale characters for '$', ',' etc */
906 LCID lcid
= MAKELCID(MAKELANGID(LANG_ENGLISH
,SUBLANG_ENGLISH_US
),SORT_DEFAULT
);
912 CHECKPTR(VarParseNumFromStr
);
914 /* Consume a single digit */
919 /* cDig is not literal digits - zeros are suppressed and nPwr10 is increased */
922 /* Note: Win32 writes the trailing zeros if they are within cDig's limits,
923 * but then excludes them from the returned cDig count.
924 * In our implementation we don't bother writing them at all.
928 /* if cDig is too small and numbers follow, sets INEXACT */
930 EXPECT(1,0,NUMPRS_INEXACT
,2,0,1);
933 /* Strips leading zeros */
938 /* Strips leading zeros */
944 /* Fails on non digits */
947 EXPECTRGB(0,FAILDIG
);
949 /** NUMPRS_LEADING_WHITE/NUMPRS_TRAILING_WHITE **/
951 /* Without flag, fails on whitespace */
954 EXPECTRGB(0,FAILDIG
);
957 /* With flag, consumes whitespace */
958 CONVERT(" 0", NUMPRS_LEADING_WHITE
);
959 EXPECT(1,NUMPRS_LEADING_WHITE
,NUMPRS_LEADING_WHITE
,2,0,0);
962 /* Test TAB once, then assume it acts as space for all cases */
963 CONVERT("\t0", NUMPRS_LEADING_WHITE
);
964 EXPECT(1,NUMPRS_LEADING_WHITE
,NUMPRS_LEADING_WHITE
,2,0,0);
968 /* Doesn't pick up trailing whitespace without flag */
973 /* With flag, consumes trailing whitespace */
974 CONVERT("0 ", NUMPRS_TRAILING_WHITE
);
975 EXPECT(1,NUMPRS_TRAILING_WHITE
,NUMPRS_TRAILING_WHITE
,2,0,0);
978 /* Leading flag only consumes leading */
979 CONVERT(" 0 ", NUMPRS_LEADING_WHITE
);
980 EXPECT(1,NUMPRS_LEADING_WHITE
,NUMPRS_LEADING_WHITE
,2,0,0);
983 /* Both flags consumes both */
984 CONVERT(" 0 ", NUMPRS_LEADING_WHITE
|NUMPRS_TRAILING_WHITE
);
985 EXPECT(1,NUMPRS_LEADING_WHITE
|NUMPRS_TRAILING_WHITE
,NUMPRS_LEADING_WHITE
|NUMPRS_TRAILING_WHITE
,3,0,0);
988 /** NUMPRS_LEADING_PLUS/NUMPRS_TRAILING_PLUS **/
990 /* Without flag, fails on + */
993 EXPECTRGB(0,FAILDIG
);
995 /* With flag, consumes + */
996 CONVERT("+0", NUMPRS_LEADING_PLUS
);
997 EXPECT(1,NUMPRS_LEADING_PLUS
,NUMPRS_LEADING_PLUS
,2,0,0);
1000 /* Without flag, doesn't consume trailing + */
1002 EXPECT(1,0,0,1,0,0);
1005 /* With flag, consumes trailing + */
1006 CONVERT("0+", NUMPRS_TRAILING_PLUS
);
1007 EXPECT(1,NUMPRS_TRAILING_PLUS
,NUMPRS_TRAILING_PLUS
,2,0,0);
1010 /* With leading flag, doesn't consume trailing + */
1011 CONVERT("+0+", NUMPRS_LEADING_PLUS
);
1012 EXPECT(1,NUMPRS_LEADING_PLUS
,NUMPRS_LEADING_PLUS
,2,0,0);
1015 /* Trailing + doesn't get consumed if we specify both (unlike whitespace) */
1016 CONVERT("+0+", NUMPRS_LEADING_PLUS
|NUMPRS_TRAILING_PLUS
);
1017 EXPECT(1,NUMPRS_LEADING_PLUS
|NUMPRS_TRAILING_PLUS
,NUMPRS_LEADING_PLUS
,2,0,0);
1020 /** NUMPRS_LEADING_MINUS/NUMPRS_TRAILING_MINUS **/
1022 /* Without flag, fails on - */
1025 EXPECTRGB(0,FAILDIG
);
1027 /* With flag, consumes - */
1028 CONVERT("-0", NUMPRS_LEADING_MINUS
);
1029 EXPECT(1,NUMPRS_LEADING_MINUS
,NUMPRS_NEG
|NUMPRS_LEADING_MINUS
,2,0,0);
1032 /* Without flag, doesn't consume trailing - */
1034 EXPECT(1,0,0,1,0,0);
1037 /* With flag, consumes trailing - */
1038 CONVERT("0-", NUMPRS_TRAILING_MINUS
);
1039 EXPECT(1,NUMPRS_TRAILING_MINUS
,NUMPRS_NEG
|NUMPRS_TRAILING_MINUS
,2,0,0);
1042 /* With leading flag, doesn't consume trailing - */
1043 CONVERT("-0-", NUMPRS_LEADING_MINUS
);
1044 EXPECT(1,NUMPRS_LEADING_MINUS
,NUMPRS_NEG
|NUMPRS_LEADING_MINUS
,2,0,0);
1047 /* Trailing - doesn't get consumed if we specify both (unlike whitespace) */
1048 CONVERT("-0-", NUMPRS_LEADING_MINUS
|NUMPRS_TRAILING_MINUS
);
1049 EXPECT(1,NUMPRS_LEADING_MINUS
|NUMPRS_TRAILING_MINUS
,NUMPRS_NEG
|NUMPRS_LEADING_MINUS
,2,0,0);
1052 /** NUMPRS_HEX_OCT **/
1054 /* Could be hex, octal or decimal - With flag reads as decimal */
1055 CONVERT("0", NUMPRS_HEX_OCT
);
1056 EXPECT(1,NUMPRS_HEX_OCT
,0,1,0,0);
1059 /* Doesn't recognise hex in .asm syntax */
1060 CONVERT("0h", NUMPRS_HEX_OCT
);
1061 EXPECT(1,NUMPRS_HEX_OCT
,0,1,0,0);
1064 /* Doesn't fail with valid leading string but no digits */
1065 CONVERT("0x", NUMPRS_HEX_OCT
);
1066 EXPECT(1,NUMPRS_HEX_OCT
,0,1,0,0);
1069 /* Doesn't recognise hex format numbers at all! */
1070 CONVERT("0x0", NUMPRS_HEX_OCT
);
1071 EXPECT(1,NUMPRS_HEX_OCT
,0,1,0,0);
1074 /* Doesn't recognise plain hex digits either */
1075 CONVERT("FE", NUMPRS_HEX_OCT
);
1077 EXPECTRGB(0,FAILDIG
);
1080 CONVERT("0100", NUMPRS_HEX_OCT
);
1081 EXPECT(1,NUMPRS_HEX_OCT
,0,4,0,2);
1085 EXPECTRGB(3,FAILDIG
);
1088 CONVERT("&HF800", NUMPRS_HEX_OCT
);
1089 EXPECT(4,NUMPRS_HEX_OCT
,0x40,6,4,0);
1094 EXPECTRGB(4,FAILDIG
);
1096 /* VB hex lower case and leading zero */
1097 CONVERT("&h0abcdef", NUMPRS_HEX_OCT
);
1098 EXPECT(6,NUMPRS_HEX_OCT
,0x40,9,4,0);
1105 EXPECTRGB(6,FAILDIG
);
1108 CONVERT("&O300", NUMPRS_HEX_OCT
);
1109 EXPECT(3,NUMPRS_HEX_OCT
,0x40,5,3,0);
1113 EXPECTRGB(3,FAILDIG
);
1115 /* VB oct lower case and leading zero */
1116 CONVERT("&o0777", NUMPRS_HEX_OCT
);
1117 EXPECT(3,NUMPRS_HEX_OCT
,0x40,6,3,0);
1121 EXPECTRGB(3,FAILDIG
);
1123 /* VB oct char bigger than 7 */
1124 CONVERT("&o128", NUMPRS_HEX_OCT
);
1126 Native versions 2.x of oleaut32 allow this to succeed: later versions and Wine don't
1128 EXPECTRGB(0,FAILDIG);
1130 /** NUMPRS_PARENS **/
1132 /* Empty parens = error */
1133 CONVERT("()", NUMPRS_PARENS
);
1135 EXPECTRGB(0,FAILDIG
);
1137 /* With flag, trailing parens not consumed */
1138 CONVERT("0()", NUMPRS_PARENS
);
1139 EXPECT(1,NUMPRS_PARENS
,0,1,0,0);
1142 /* With flag, Number in parens made negative and parens consumed */
1143 CONVERT("(0)", NUMPRS_PARENS
);
1144 EXPECT(1,NUMPRS_PARENS
,NUMPRS_NEG
|NUMPRS_PARENS
,3,0,0);
1147 /** NUMPRS_THOUSANDS **/
1149 /* With flag, thousands sep. not needed */
1150 CONVERT("0", NUMPRS_THOUSANDS
);
1151 EXPECT(1,NUMPRS_THOUSANDS
,0,1,0,0);
1154 /* With flag, thousands sep. and following digits consumed */
1155 CONVERT("1,000", NUMPRS_THOUSANDS
);
1156 EXPECT(1,NUMPRS_THOUSANDS
,NUMPRS_THOUSANDS
,5,0,3);
1159 /* With flag and decimal point, thousands sep. but not decimals consumed */
1160 CONVERT("1,000.0", NUMPRS_THOUSANDS
);
1161 EXPECT(1,NUMPRS_THOUSANDS
,NUMPRS_THOUSANDS
,5,0,3);
1164 /** NUMPRS_CURRENCY **/
1166 /* Without flag, chokes on currency sign */
1169 EXPECTRGB(0,FAILDIG
);
1171 /* With flag, consumes currency sign */
1172 CONVERT("$11", NUMPRS_CURRENCY
);
1173 EXPECT(2,NUMPRS_CURRENCY
,NUMPRS_CURRENCY
,3,0,0);
1175 EXPECTRGB(2,FAILDIG
);
1177 /* With flag only, doesn't consume decimal point */
1178 CONVERT("$11.1", NUMPRS_CURRENCY
);
1179 EXPECT(2,NUMPRS_CURRENCY
,NUMPRS_CURRENCY
,3,0,0);
1181 EXPECTRGB(2,FAILDIG
);
1183 /* With flag and decimal flag, consumes decimal point and following digits */
1184 CONVERT("$11.1", NUMPRS_CURRENCY
|NUMPRS_DECIMAL
);
1185 EXPECT(3,NUMPRS_CURRENCY
|NUMPRS_DECIMAL
,NUMPRS_CURRENCY
|NUMPRS_DECIMAL
,5,0,-1);
1188 EXPECTRGB(3,FAILDIG
);
1190 /* Thousands flag can only be used with currency */
1191 CONVERT("$1,234", NUMPRS_CURRENCY
|NUMPRS_THOUSANDS
);
1192 EXPECT(4,NUMPRS_CURRENCY
|NUMPRS_THOUSANDS
,NUMPRS_CURRENCY
|NUMPRS_THOUSANDS
,6,0,0);
1196 EXPECTRGB(4,FAILDIG
);
1198 /** NUMPRS_DECIMAL **/
1200 /* With flag, consumes decimal point */
1201 CONVERT("1.1", NUMPRS_DECIMAL
);
1202 EXPECT(2,NUMPRS_DECIMAL
,NUMPRS_DECIMAL
,3,0,-1);
1204 EXPECTRGB(2,FAILDIG
);
1206 /* With flag, consumes decimal point. Skipping the decimal part is not an error */
1207 CONVERT("1.", NUMPRS_DECIMAL
);
1208 EXPECT(1,NUMPRS_DECIMAL
,NUMPRS_DECIMAL
,2,0,0);
1211 /* Consumes only one decimal point */
1212 CONVERT("1.1.", NUMPRS_DECIMAL
);
1213 EXPECT(2,NUMPRS_DECIMAL
,NUMPRS_DECIMAL
,3,0,-1);
1215 EXPECTRGB(2,FAILDIG
);
1217 /** NUMPRS_EXPONENT **/
1219 /* Without flag, doesn't consume exponent */
1221 EXPECT(1,0,0,1,0,0);
1224 /* With flag, consumes exponent */
1225 CONVERT("1e1", NUMPRS_EXPONENT
);
1226 EXPECT(1,NUMPRS_EXPONENT
,NUMPRS_EXPONENT
,3,0,1);
1229 /* Negative exponents are accepted without flags */
1230 CONVERT("1e-1", NUMPRS_EXPONENT
);
1231 EXPECT(1,NUMPRS_EXPONENT
,NUMPRS_EXPONENT
,4,0,-1);
1234 /* As are positive exponents and leading exponent 0s */
1235 CONVERT("1e+01", NUMPRS_EXPONENT
);
1236 EXPECT(1,NUMPRS_EXPONENT
,NUMPRS_EXPONENT
,5,0,1);
1239 /* The same for zero exponents */
1240 CONVERT("1e0", NUMPRS_EXPONENT
);
1241 EXPECT(1,NUMPRS_EXPONENT
,NUMPRS_EXPONENT
,3,0,0);
1244 /* Sign on a zero exponent doesn't matter */
1245 CONVERT("1e+0", NUMPRS_EXPONENT
);
1246 EXPECT(1,NUMPRS_EXPONENT
,NUMPRS_EXPONENT
,4,0,0);
1249 CONVERT("1e-0", NUMPRS_EXPONENT
);
1250 EXPECT(1,NUMPRS_EXPONENT
,NUMPRS_EXPONENT
,4,0,0);
1253 /* Doesn't consume a real number exponent */
1254 CONVERT("1e1.", NUMPRS_EXPONENT
);
1255 EXPECT(1,NUMPRS_EXPONENT
,NUMPRS_EXPONENT
,3,0,1);
1258 /* Powers of 10 are calculated from the position of any decimal point */
1259 CONVERT("1.5e20", NUMPRS_EXPONENT
|NUMPRS_DECIMAL
);
1260 EXPECT(2,NUMPRS_EXPONENT
|NUMPRS_DECIMAL
,NUMPRS_EXPONENT
|NUMPRS_DECIMAL
,6,0,19);
1263 CONVERT("1.5e-20", NUMPRS_EXPONENT
|NUMPRS_DECIMAL
);
1264 EXPECT(2,NUMPRS_EXPONENT
|NUMPRS_DECIMAL
,NUMPRS_EXPONENT
|NUMPRS_DECIMAL
,7,0,-21);
1267 /** NUMPRS_USE_ALL **/
1269 /* Flag expects all digits */
1270 CONVERT("0", NUMPRS_USE_ALL
);
1271 EXPECT(1,NUMPRS_USE_ALL
,0,1,0,0);
1274 /* Rejects anything trailing */
1275 CONVERT("0 ", NUMPRS_USE_ALL
);
1279 /* Unless consumed by trailing flag */
1280 CONVERT("0 ", NUMPRS_USE_ALL
|NUMPRS_TRAILING_WHITE
);
1281 EXPECT(1,NUMPRS_USE_ALL
|NUMPRS_TRAILING_WHITE
,NUMPRS_TRAILING_WHITE
,2,0,0);
1284 /** Combinations **/
1286 /* Leading whitespace and plus, doesn't consume trailing whitespace */
1287 CONVERT("+ 0 ", NUMPRS_LEADING_PLUS
|NUMPRS_LEADING_WHITE
);
1288 EXPECT(1,NUMPRS_LEADING_PLUS
|NUMPRS_LEADING_WHITE
,NUMPRS_LEADING_PLUS
|NUMPRS_LEADING_WHITE
,3,0,0);
1291 /* Order of whitespace and plus is unimportant */
1292 CONVERT(" +0", NUMPRS_LEADING_PLUS
|NUMPRS_LEADING_WHITE
);
1293 EXPECT(1,NUMPRS_LEADING_PLUS
|NUMPRS_LEADING_WHITE
,NUMPRS_LEADING_PLUS
|NUMPRS_LEADING_WHITE
,3,0,0);
1296 /* Leading whitespace can be repeated */
1297 CONVERT(" + 0", NUMPRS_LEADING_PLUS
|NUMPRS_LEADING_WHITE
);
1298 EXPECT(1,NUMPRS_LEADING_PLUS
|NUMPRS_LEADING_WHITE
,NUMPRS_LEADING_PLUS
|NUMPRS_LEADING_WHITE
,4,0,0);
1301 /* But plus/minus etc. cannot */
1302 CONVERT("+ +0", NUMPRS_LEADING_PLUS
|NUMPRS_LEADING_WHITE
);
1304 EXPECTRGB(0,FAILDIG
);
1306 /* Inexact is not set if trailing zeros are removed */
1307 CONVERTN("10", 1, 0);
1308 EXPECT(1,0,0,2,0,1);
1311 /* Make sure a leading 0 is stripped but decimals after it get read */
1312 CONVERT("-0.51", NUMPRS_STD
);
1313 EXPECT(2,NUMPRS_STD
,NUMPRS_NEG
|NUMPRS_DECIMAL
|NUMPRS_LEADING_MINUS
,5,0,-2);
1316 /* Keep trailing zeros on whole number part of a decimal */
1317 CONVERT("10.1", NUMPRS_STD
);
1318 EXPECT(3,NUMPRS_STD
,NUMPRS_DECIMAL
,4,0,-1);
1322 /* Zeros after decimal sign */
1323 CONVERT("0.01", NUMPRS_STD
);
1324 EXPECT(1,NUMPRS_STD
,NUMPRS_DECIMAL
,4,0,-2);
1327 /* Trailing zeros after decimal part */
1328 CONVERT("0.10", NUMPRS_STD
);
1329 EXPECT(1,NUMPRS_STD
,NUMPRS_DECIMAL
,4,0,-1);
1333 static HRESULT (WINAPI
*pVarNumFromParseNum
)(NUMPARSE
*,BYTE
*,ULONG
,VARIANT
*);
1335 /* Macros for converting and testing the result of VarNumFromParseNum */
1336 #define SETRGB(indx,val) if (!indx) memset(rgb, FAILDIG, sizeof(rgb)); rgb[indx] = val
1338 #define CONVERT(a,b,c,d,e,f,bits) \
1339 np.cDig = (a); np.dwInFlags = (b); np.dwOutFlags = (c); np.cchUsed = (d); \
1340 np.nBaseShift = (e); np.nPwr10 = (f); hres = pVarNumFromParseNum(&np, rgb, bits, &vOut)
1341 static const char *szFailOverflow
= "Expected overflow, hres = %08x\n";
1342 #define EXPECT_OVERFLOW ok(hres == (HRESULT)DISP_E_OVERFLOW, szFailOverflow, hres)
1343 static const char *szFailOk
= "Call failed, hres = %08x\n";
1344 #define EXPECT_OK ok(hres == (HRESULT)S_OK, szFailOk, hres); \
1345 if (hres == (HRESULT)S_OK)
1346 #define EXPECT_TYPE(typ) ok(V_VT(&vOut) == typ,"Expected Type = " #typ ", got %d\n", V_VT(&vOut))
1347 #define EXPECT_I1(val) EXPECT_OK { EXPECT_TYPE(VT_I1); \
1348 ok(V_I1(&vOut) == val, "Expected i1 = %d, got %d\n", (signed char)val, V_I1(&vOut)); }
1349 #define EXPECT_UI1(val) EXPECT_OK { EXPECT_TYPE(VT_UI1); \
1350 ok(V_UI1(&vOut) == val, "Expected ui1 = %d, got %d\n", (BYTE)val, V_UI1(&vOut)); }
1351 #define EXPECT_I2(val) EXPECT_OK { EXPECT_TYPE(VT_I2); \
1352 ok(V_I2(&vOut) == val, "Expected i2 = %d, got %d\n", (SHORT)val, V_I2(&vOut)); }
1353 #define EXPECT_UI2(val) EXPECT_OK { EXPECT_TYPE(VT_UI2); \
1354 ok(V_UI2(&vOut) == val, "Expected ui2 = %d, got %d\n", (USHORT)val, V_UI2(&vOut)); }
1355 #define EXPECT_I4(val) EXPECT_OK { EXPECT_TYPE(VT_I4); \
1356 ok(V_I4(&vOut) == val, "Expected i4 = %d, got %d\n", (LONG)val, V_I4(&vOut)); }
1357 #define EXPECT_UI4(val) EXPECT_OK { EXPECT_TYPE(VT_UI4); \
1358 ok(V_UI4(&vOut) == val, "Expected ui4 = %d, got %d\n", (ULONG)val, V_UI4(&vOut)); }
1359 #define EXPECT_I8(high,low) EXPECT_OK { EXPECT_TYPE(VT_I8); \
1360 ok(V_I8(&vOut) == ((((LONG64)(high))<<32)|(low)), "Expected i8 = %x%08x, got %x%08x\n", \
1361 (LONG)(high), (LONG)(low), (LONG)(V_I8(&vOut)>>32), (LONG)V_I8(&vOut) ); }
1362 #define EXPECT_UI8(val) EXPECT_OK { EXPECT_TYPE(VT_UI8); \
1363 ok(V_UI8(&vOut) == val, "Expected ui8 = 0x%x%08x, got 0x%x%08x\n", \
1364 (DWORD)((ULONG64)val >> 32), (DWORD)(ULONG64)val, (DWORD)(V_UI8(&vOut) >> 32), (DWORD)V_UI8(&vOut)); }
1365 #define EXPECT_R4(val) EXPECT_OK { EXPECT_TYPE(VT_R4); \
1366 ok(V_R4(&vOut) == val, "Expected r4 = %f, got %f\n", val, V_R4(&vOut)); }
1367 #define EXPECT_R8(val) EXPECT_OK { EXPECT_TYPE(VT_R8); \
1368 ok(V_R8(&vOut) == val, "Expected r8 = %g, got %g\n", val, V_R8(&vOut)); }
1369 #define CY_MULTIPLIER 10000
1370 #define EXPECT_CY(val) EXPECT_OK { EXPECT_TYPE(VT_CY); \
1371 ok(V_CY(&vOut).int64 == (LONG64)(val * CY_MULTIPLIER), "Expected r8 = 0x%x%08x, got 0x%x%08x\n", \
1372 (DWORD)((LONG64)val >> 23), (DWORD)(LONG64)val, (DWORD)(V_CY(&vOut).int64 >>32), (DWORD)V_CY(&vOut).int64); }
1373 #define EXPECT_DECIMAL(valHi, valMid, valLo) EXPECT_OK { EXPECT_TYPE(VT_DECIMAL); \
1374 ok((V_DECIMAL(&vOut).Hi32 == valHi) && (S1(U1(V_DECIMAL(&vOut))).Mid32 == valMid) && \
1375 (S1(U1(V_DECIMAL(&vOut))).Lo32 == valLo), \
1376 "Expected decimal = %x/0x%x%08x, got %x/0x%x%08x\n", valHi, valMid, valLo, \
1377 V_DECIMAL(&vOut).Hi32, S1(U1(V_DECIMAL(&vOut))).Mid32, S1(U1(V_DECIMAL(&vOut))).Lo32); }
1379 static void test_VarNumFromParseNum(void)
1386 CHECKPTR(VarNumFromParseNum
);
1388 /* Convert the number 1 to different types */
1389 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_I1
); EXPECT_I1(1);
1390 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_UI1
); EXPECT_UI1(1);
1391 /* Prefers a signed type to unsigned of the same size */
1392 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_I1
|VTBIT_UI1
); EXPECT_I1(1);
1393 /* But takes the smaller size if possible */
1394 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_I2
|VTBIT_UI1
); EXPECT_UI1(1);
1396 /* Try different integer sizes */
1397 #define INTEGER_VTBITS (VTBIT_I1|VTBIT_UI1|VTBIT_I2|VTBIT_UI2|VTBIT_I4|VTBIT_UI4|VTBIT_I8|VTBIT_UI8)
1399 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, INTEGER_VTBITS
); EXPECT_I1(1);
1401 SETRGB(0, 1); SETRGB(1, 2); SETRGB(2, 7);
1402 CONVERT(3,0,0,3,0,0, INTEGER_VTBITS
); EXPECT_I1(127);
1404 SETRGB(0, 1); SETRGB(1, 2); SETRGB(2, 8);
1405 CONVERT(3,0,0,3,0,0, INTEGER_VTBITS
); EXPECT_UI1(128);
1407 SETRGB(0, 2); SETRGB(1, 5); SETRGB(2, 5);
1408 CONVERT(3,0,0,3,0,0, INTEGER_VTBITS
); EXPECT_UI1(255);
1410 SETRGB(0, 2); SETRGB(1, 5); SETRGB(2, 6);
1411 CONVERT(3,0,0,3,0,0, INTEGER_VTBITS
); EXPECT_I2(256);
1413 SETRGB(0, 3); SETRGB(1, 2); SETRGB(2, 7); SETRGB(3, 6); SETRGB(4, 7);
1414 CONVERT(5,0,0,5,0,0, INTEGER_VTBITS
); EXPECT_I2(32767);
1416 SETRGB(0, 3); SETRGB(1, 2); SETRGB(2, 7); SETRGB(3, 6); SETRGB(4, 8);
1417 CONVERT(5,0,0,5,0,0, INTEGER_VTBITS
); EXPECT_UI2(32768);
1419 /* Assume the above pattern holds for remaining positive integers; test negative */
1422 SETRGB(0, 1); SETRGB(1, 2); SETRGB(2, 8);
1423 CONVERT(3,0,NUMPRS_NEG
,3,0,0, INTEGER_VTBITS
); EXPECT_I1(-128);
1425 SETRGB(0, 1); SETRGB(1, 2); SETRGB(2, 9);
1426 CONVERT(3,0,NUMPRS_NEG
,3,0,0, INTEGER_VTBITS
); EXPECT_I2(-129);
1428 SETRGB(0, 3); SETRGB(1, 2); SETRGB(2, 7); SETRGB(3, 6); SETRGB(4, 8);
1429 CONVERT(5,0,NUMPRS_NEG
,5,0,0, INTEGER_VTBITS
); EXPECT_I2(-32768);
1431 SETRGB(0, 3); SETRGB(1, 2); SETRGB(2, 7); SETRGB(3, 6); SETRGB(4, 9);
1432 CONVERT(5,0,NUMPRS_NEG
,5,0,0, INTEGER_VTBITS
); EXPECT_I4(-32769);
1434 /* Assume the above pattern holds for remaining negative integers */
1436 /* Test hexadecimal conversions */
1437 SETRGB(0, 1); CONVERT(1,0,0,1,4,0, INTEGER_VTBITS
); EXPECT_I1(0x01);
1439 SETRGB(0, 7); SETRGB(1, 0xf);
1440 CONVERT(2,0,0,2,4,0, INTEGER_VTBITS
); EXPECT_I1(0x7f);
1441 SETRGB(0, 7); SETRGB(1, 0xf);
1442 CONVERT(2,0,0,2,4,0, VTBIT_DECIMAL
); EXPECT_DECIMAL(0,0,0x7f);
1444 SETRGB(0, 7); SETRGB(1, 0xf); SETRGB(2, 0xf); SETRGB(3, 0xf);
1445 CONVERT(4,0,0,4,4,0, INTEGER_VTBITS
); EXPECT_I2(0x7fff);
1447 SETRGB(0, 7); SETRGB(1, 0xf); SETRGB(2, 0xf); SETRGB(3, 0xf);
1448 SETRGB(4, 0xf); SETRGB(5, 0xf); SETRGB(6, 0xf); SETRGB(7, 0xf);
1449 CONVERT(8,0,0,8,4,0, INTEGER_VTBITS
); EXPECT_I4(0x7fffffffL
);
1450 /* 0x7fffffffffffffff (64 bits) */
1451 SETRGB(0, 7); SETRGB(1, 0xf); SETRGB(2, 0xf); SETRGB(3, 0xf);
1452 SETRGB(4, 0xf); SETRGB(5, 0xf); SETRGB(6, 0xf); SETRGB(7, 0xf);
1453 SETRGB(8, 0xf); SETRGB(9, 0xf); SETRGB(10, 0xf); SETRGB(11, 0xf);
1454 SETRGB(12, 0xf); SETRGB(13, 0xf); SETRGB(14, 0xf); SETRGB(15, 0xf);
1455 if (HAVE_OLEAUT32_I8
)
1457 /* We cannot use INTEGER_VTBITS as WinXP and Win2003 are broken(?). They
1458 truncate the number to the smallest integer size requested:
1459 CONVERT(16,0,0,16,4,0, INTEGER_VTBITS); EXPECT_I1((signed char)0xff); */
1460 CONVERT(16,0,0,16,4,0, VTBIT_I8
); EXPECT_I8(0x7fffffff,0xffffffff);
1463 /* Assume the above pattern holds for numbers without hi-bit set, test (preservation of) hi-bit */
1465 SETRGB(0, 8); SETRGB(1, 2);
1466 CONVERT(2,0,0,2,4,0, INTEGER_VTBITS
);
1467 EXPECT_I1((signed char)0x82);
1469 SETRGB(0, 8); SETRGB(1, 0); SETRGB(2, 0); SETRGB(3, 2);
1470 CONVERT(4,0,0,4,4,0, INTEGER_VTBITS
);
1471 EXPECT_I2((signed short)0x8002);
1473 SETRGB(0, 8); SETRGB(1, 0); SETRGB(2, 0); SETRGB(3, 0);
1474 SETRGB(4, 0); SETRGB(5, 0); SETRGB(6, 0); SETRGB(7, 2);
1475 CONVERT(8,0,0,8,4,0, INTEGER_VTBITS
); EXPECT_I4(0x80000002);
1476 /* 0x8000000000000002 (64 bits) */
1477 SETRGB(0, 8); SETRGB(1, 0); SETRGB(2, 0); SETRGB(3, 0);
1478 SETRGB(4, 0); SETRGB(5, 0); SETRGB(6, 0); SETRGB(7, 0);
1479 SETRGB(8, 0); SETRGB(9, 0); SETRGB(10, 0); SETRGB(11, 0);
1480 SETRGB(12, 0); SETRGB(13, 0); SETRGB(14, 0); SETRGB(15, 2);
1481 if (HAVE_OLEAUT32_I8
)
1483 /* We cannot use INTEGER_VTBITS as WinXP and Win2003 are broken(?). They
1484 truncate the number to the smallest integer size requested:
1485 CONVERT(16,0,0,16,4,0, INTEGER_VTBITS & ~VTBIT_I1);
1486 EXPECT_I2((signed short)0x0002); */
1487 CONVERT(16,0,0,16,4,0, VTBIT_I8
); EXPECT_I8(0x80000000,0x00000002);
1490 /* Test (preservation of) hi-bit with STRICT type requesting */
1492 SETRGB(0, 8); SETRGB(1, 2);
1493 CONVERT(2,0,0,2,4,0, VTBIT_I1
);
1494 EXPECT_I1((signed char)0x82);
1496 SETRGB(0, 8); SETRGB(1, 0); SETRGB(2, 0); SETRGB(3, 2);
1497 CONVERT(4,0,0,4,4,0, VTBIT_I2
);
1498 EXPECT_I2((signed short)0x8002);
1500 SETRGB(0, 8); SETRGB(1, 0); SETRGB(2, 0); SETRGB(3, 0);
1501 SETRGB(4, 0); SETRGB(5, 0); SETRGB(6, 0); SETRGB(7, 2);
1502 CONVERT(8,0,0,8,4,0, VTBIT_I4
); EXPECT_I4(0x80000002);
1503 /* 0x8000000000000002 (64 bits) */
1504 SETRGB(0, 8); SETRGB(1, 0); SETRGB(2, 0); SETRGB(3, 0);
1505 SETRGB(4, 0); SETRGB(5, 0); SETRGB(6, 0); SETRGB(7, 0);
1506 SETRGB(8, 0); SETRGB(9, 0); SETRGB(10, 0); SETRGB(11, 0);
1507 SETRGB(12, 0); SETRGB(13, 0); SETRGB(14, 0); SETRGB(15, 2);
1508 if (HAVE_OLEAUT32_I8
)
1510 CONVERT(16,0,0,16,4,0, VTBIT_I8
); EXPECT_I8(0x80000000,0x00000002);
1512 /* Assume the above pattern holds for numbers with hi-bit set */
1514 /* Negative numbers overflow if we have only unsigned outputs */
1516 SETRGB(0, 1); CONVERT(1,0,NUMPRS_NEG
,1,0,0, VTBIT_UI1
); EXPECT_OVERFLOW
;
1518 SETRGB(0, 6); CONVERT(1,0,NUMPRS_NEG
,1,0,~0u, VTBIT_UI1
); EXPECT_OVERFLOW
;
1520 /* Except that rounding is done first, so -0.5 to 0 are accepted as 0 */
1522 SETRGB(0, 5); CONVERT(1,0,NUMPRS_NEG
,1,0,~0u, VTBIT_UI1
); EXPECT_UI1(0);
1524 /* Floating point zero is OK */
1526 SETRGB(0, 0); CONVERT(1,0,NUMPRS_DECIMAL
|NUMPRS_EXPONENT
,12,0,-8, VTBIT_R8
);
1529 /* Float is acceptable for an integer input value */
1530 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_R4
); EXPECT_R4(1.0f
);
1532 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_R8
); EXPECT_R8(1.0);
1533 /* As is currency */
1534 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_CY
); EXPECT_CY(1);
1536 /* Float is preferred over double */
1537 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_R4
|VTBIT_R8
); EXPECT_R4(1.0f
);
1539 /* Double is preferred over currency */
1540 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_R8
|VTBIT_CY
); EXPECT_R8(1.0);
1542 /* Currency is preferred over decimal */
1543 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_CY
|VTBIT_DECIMAL
); EXPECT_CY(1);
1547 static void test_UdateFromDate( int line
, DATE dt
, ULONG flags
, HRESULT r
, WORD d
, WORD m
, WORD y
,
1548 WORD h
, WORD mn
, WORD s
, WORD ms
, WORD dw
, WORD dy
)
1553 memset(&ud
, 0, sizeof(ud
));
1554 res
= pVarUdateFromDate(dt
, flags
, &ud
);
1555 ok_(__FILE__
,line
)(r
== res
, "Wrong result %x/%x\n", r
, res
);
1557 ok_(__FILE__
,line
)(ud
.st
.wYear
== y
&& ud
.st
.wMonth
== m
&& ud
.st
.wDay
== d
&&
1558 ud
.st
.wHour
== h
&& ud
.st
.wMinute
== mn
&& ud
.st
.wSecond
== s
&&
1559 ud
.st
.wMilliseconds
== ms
&& ud
.st
.wDayOfWeek
== dw
&& ud
.wDayOfYear
== dy
,
1560 "%.16g expected %d,%d,%d,%d,%d,%d,%d %d %d, got %d,%d,%d,%d,%d,%d,%d %d %d\n",
1561 dt
, d
, m
, y
, h
, mn
, s
, ms
, dw
, dy
,
1562 ud
.st
.wDay
, ud
.st
.wMonth
, ud
.st
.wYear
, ud
.st
.wHour
, ud
.st
.wMinute
,
1563 ud
.st
.wSecond
, ud
.st
.wMilliseconds
, ud
.st
.wDayOfWeek
, ud
.wDayOfYear
);
1565 #define DT2UD(dt,flags,r,d,m,y,h,mn,s,ms,dw,dy) test_UdateFromDate(__LINE__,dt,flags,r,d,m,y,h,mn,s,ms,dw,dy)
1567 static void test_VarUdateFromDate(void)
1569 CHECKPTR(VarUdateFromDate
);
1570 DT2UD(29221.0,0,S_OK
,1,1,1980,0,0,0,0,2,1); /* 1 Jan 1980 */
1571 DT2UD(29222.0,0,S_OK
,2,1,1980,0,0,0,0,3,2); /* 2 Jan 1980 */
1572 DT2UD(33238.0,0,S_OK
,31,12,1990,0,0,0,0,1,365); /* 31 Dec 1990 */
1573 DT2UD(0.0,0,S_OK
,30,12,1899,0,0,0,0,6,364); /* 30 Dec 1899 - VT_DATE 0.0 */
1574 DT2UD(-657434.0,0,S_OK
,1,1,100,0,0,0,0,5,1); /* 1 Jan 100 - Min */
1575 DT2UD(-657435.0,0,E_INVALIDARG
,0,0,0,0,0,0,0,0,0); /* < 1 Jan 100 => err */
1576 DT2UD(2958465.0,0,S_OK
,31,12,9999,0,0,0,0,5,365); /* 31 Dec 9999 - Max */
1577 DT2UD(2958466.0,0,E_INVALIDARG
,0,0,0,0,0,0,0,0,0); /* > 31 Dec 9999 => err */
1579 /* VAR_VALIDDATE doesn't prevent upper and lower bounds being checked */
1580 DT2UD(-657435.0,VAR_VALIDDATE
,E_INVALIDARG
,0,0,0,0,0,0,0,0,0);
1581 DT2UD(2958466.0,VAR_VALIDDATE
,E_INVALIDARG
,0,0,0,0,0,0,0,0,0);
1584 DT2UD(29221.25,0,S_OK
,1,1,1980,6,0,0,0,2,1); /* 6 AM */
1585 DT2UD(29221.33333333,0,S_OK
,1,1,1980,8,0,0,0,2,1); /* 8 AM */
1586 DT2UD(29221.5,0,S_OK
,1,1,1980,12,0,0,0,2,1); /* 12 AM */
1587 DT2UD(29221.9888884444,0,S_OK
,1,1,1980,23,44,0,0,2,1); /* 11:44 PM */
1588 DT2UD(29221.7508765432,0,S_OK
,1,1,1980,18,1,16,0,2,1); /* 6:18:02 PM */
1592 static void test_DateFromUDate( int line
, WORD d
, WORD m
, WORD y
, WORD h
, WORD mn
, WORD s
, WORD ms
,
1593 WORD dw
, WORD dy
, ULONG flags
, HRESULT r
, DATE dt
)
1605 ud
.st
.wMilliseconds
= ms
;
1606 ud
.st
.wDayOfWeek
= dw
;
1608 res
= pVarDateFromUdate(&ud
, flags
, &out
);
1609 ok_(__FILE__
,line
)(r
== res
&& (FAILED(r
) || EQ_DOUBLE(out
, dt
)),
1610 "expected %x, %.16g, got %x, %.16g\n", r
, dt
, res
, out
);
1612 #define UD2T(d,m,y,h,mn,s,ms,dw,dy,flags,r,dt) test_DateFromUDate(__LINE__,d,m,y,h,mn,s,ms,dw,dy,flags,r,dt)
1614 static void test_VarDateFromUdate(void)
1616 CHECKPTR(VarDateFromUdate
);
1617 UD2T(1,1,1980,0,0,0,0,2,1,0,S_OK
,29221.0); /* 1 Jan 1980 */
1618 UD2T(2,1,1980,0,0,0,0,3,2,0,S_OK
,29222.0); /* 2 Jan 1980 */
1619 UD2T(31,12,1990,0,0,0,0,0,0,0,S_OK
,33238.0); /* 31 Dec 1990 */
1620 UD2T(31,12,90,0,0,0,0,0,0,0,S_OK
,33238.0); /* year < 100 is 1900+year! */
1621 UD2T(30,12,1899,0,0,0,0,6,364,0,S_OK
,0.0); /* 30 Dec 1899 - VT_DATE 0.0 */
1622 UD2T(1,1,100,0,0,0,0,0,0,0,S_OK
,-657434.0); /* 1 Jan 100 - Min */
1623 UD2T(31,12,9999,0,0,0,0,0,0,0,S_OK
,2958465.0); /* 31 Dec 9999 - Max */
1624 UD2T(1,1,10000,0,0,0,0,0,0,0,E_INVALIDARG
,0.0); /* > 31 Dec 9999 => err */
1626 UD2T(1,1,1980,18,1,16,0,2,1,0,S_OK
,29221.75087962963); /* 6:18:02 PM */
1628 UD2T(0,1,1980,0,0,0,0,2,1,0,S_OK
,29220.0); /* Rolls back to 31 Dec 1899 */
1629 UD2T(1,13,1980,0,0,0,0,2,1,0,S_OK
,29587.0); /* Rolls fwd to 1/1/1981 */
1632 static void test_st2dt(int line
, WORD d
, WORD m
, WORD y
, WORD h
, WORD mn
,
1633 WORD s
, WORD ms
, INT r
, double dt
)
1645 st
.wMilliseconds
= ms
;
1647 res
= pSystemTimeToVariantTime(&st
, &out
);
1648 ok_(__FILE__
,line
)(r
== res
&& (!r
|| EQ_DOUBLE(out
, dt
)),
1649 "expected %d, %.16g, got %d, %.16g\n", r
, dt
, res
, out
);
1651 #define ST2DT(d,m,y,h,mn,s,ms,r,dt) test_st2dt(__LINE__,d,m,y,h,mn,s,ms,r,dt)
1653 static void test_SystemTimeToVariantTime(void)
1655 CHECKPTR(SystemTimeToVariantTime
);
1656 ST2DT(1,1,1980,0,0,0,0,TRUE
,29221.0);
1657 ST2DT(2,1,1980,0,0,0,0,TRUE
,29222.0);
1658 ST2DT(0,1,1980,0,0,0,0,TRUE
,29220.0); /* Rolls back to 31 Dec 1899 */
1659 ST2DT(1,13,1980,0,0,0,0,FALSE
,29587.0); /* Fails on invalid month */
1660 ST2DT(31,12,90,0,0,0,0,TRUE
,33238.0); /* year < 100 is 1900+year! */
1663 static void test_dt2st(int line
, double dt
, INT r
, WORD d
, WORD m
, WORD y
,
1664 WORD h
, WORD mn
, WORD s
, WORD ms
)
1669 memset(&st
, 0, sizeof(st
));
1670 res
= pVariantTimeToSystemTime(dt
, &st
);
1671 ok_(__FILE__
,line
)(r
== res
&&
1672 (!r
|| (st
.wYear
== y
&& st
.wMonth
== m
&& st
.wDay
== d
&&
1673 st
.wHour
== h
&& st
.wMinute
== mn
&&
1674 st
.wSecond
== s
&& st
.wMilliseconds
== ms
)),
1675 "%.16g expected %d, %d,%d,%d,%d,%d,%d,%d, got %d, %d,%d,%d,%d,%d,%d,%d\n",
1676 dt
, r
, d
, m
, y
, h
, mn
, s
, ms
, res
, st
.wDay
, st
.wMonth
,
1677 st
.wYear
, st
.wHour
, st
.wMinute
, st
.wSecond
,
1680 #define DT2ST(dt,r,d,m,y,h,mn,s,ms) test_dt2st(__LINE__,dt,r,d,m,y,h,mn,s,ms)
1682 static void test_VariantTimeToSystemTime(void)
1684 CHECKPTR(VariantTimeToSystemTime
);
1685 DT2ST(29221.0,1,1,1,1980,0,0,0,0);
1686 DT2ST(29222.0,1,2,1,1980,0,0,0,0);
1689 #define MKDOSDATE(d,m,y) ((d & 0x1f) | ((m & 0xf) << 5) | (((y-1980) & 0x7f) << 9))
1690 #define MKDOSTIME(h,m,s) (((s>>1) & 0x1f) | ((m & 0x3f) << 5) | ((h & 0x1f) << 11))
1692 static void test_dos2dt(int line
, WORD d
, WORD m
, WORD y
, WORD h
, WORD mn
,
1693 WORD s
, INT r
, double dt
)
1695 unsigned short dosDate
, dosTime
;
1700 dosDate
= MKDOSDATE(d
, m
, y
);
1701 dosTime
= MKDOSTIME(h
, mn
, s
);
1702 res
= pDosDateTimeToVariantTime(dosDate
, dosTime
, &out
);
1703 ok_(__FILE__
,line
)(r
== res
&& (!r
|| EQ_DOUBLE(out
, dt
)),
1704 "expected %d, %.16g, got %d, %.16g\n", r
, dt
, res
, out
);
1706 #define DOS2DT(d,m,y,h,mn,s,r,dt) test_dos2dt(__LINE__,d,m,y,h,mn,s,r,dt)
1708 static void test_DosDateTimeToVariantTime(void)
1710 CHECKPTR(DosDateTimeToVariantTime
);
1713 DOS2DT(1,1,1980,0,0,0,1,29221.0); /* 1/1/1980 */
1714 DOS2DT(31,12,2099,0,0,0,1,73050.0); /* 31/12/2099 */
1715 /* Dates are limited to the dos date max of 31/12/2099 */
1716 DOS2DT(31,12,2100,0,0,0,0,0.0); /* 31/12/2100 */
1717 /* Days and months of 0 cause date to roll back 1 day or month */
1718 DOS2DT(0,1,1980,0,0,0,1,29220.0); /* 0 Day => 31/12/1979 */
1719 DOS2DT(1,0,1980,0,0,0,1,29190.0); /* 0 Mth => 1/12/1979 */
1720 DOS2DT(0,0,1980,0,0,0,1,29189.0); /* 0 D/M => 30/11/1979 */
1721 /* Days > days in the month cause date to roll forward 1 month */
1722 DOS2DT(29,2,1981,0,0,0,1,29646.0); /* 29/2/1981 -> 3/1/1980 */
1723 DOS2DT(30,2,1981,0,0,0,1,29647.0); /* 30/2/1981 -> 4/1/1980 */
1724 /* Takes leap years into account when rolling forward */
1725 DOS2DT(29,2,1980,0,0,0,1,29280.0); /* 2/29/1980 */
1726 /* Months > 12 cause an error */
1727 DOS2DT(2,13,1980,0,0,0,0,0.0);
1730 DOS2DT(1,1,1980,0,0,29,1,29221.00032407407); /* 1/1/1980 12:00:28 AM */
1731 DOS2DT(1,1,1980,0,0,31,1,29221.00034722222); /* 1/1/1980 12:00:30 AM */
1732 DOS2DT(1,1,1980,0,59,0,1,29221.04097222222); /* 1/1/1980 12:59:00 AM */
1733 DOS2DT(1,1,1980,0,60,0,0,0.0); /* Invalid seconds */
1734 DOS2DT(1,1,1980,23,0,0,1,29221.95833333333); /* 1/1/1980 11:00:00 PM */
1735 DOS2DT(1,1,1980,24,0,0,0,0.0); /* Invalid hours */
1738 static void test_dt2dos(int line
, double dt
, INT r
, WORD d
, WORD m
, WORD y
,
1739 WORD h
, WORD mn
, WORD s
)
1741 unsigned short dosDate
, dosTime
, expDosDate
, expDosTime
;
1744 dosTime
= dosDate
= 0;
1745 expDosDate
= MKDOSDATE(d
,m
,y
);
1746 expDosTime
= MKDOSTIME(h
,mn
,s
);
1747 res
= pVariantTimeToDosDateTime(dt
, &dosDate
, &dosTime
);
1748 ok_(__FILE__
,line
)(r
== res
&& (!r
|| (dosTime
== expDosTime
&& dosDate
== expDosDate
)),
1749 "%g: expected %d,%d(%d/%d/%d),%d(%d:%d:%d) got %d,%d(%d/%d/%d),%d(%d:%d:%d)\n",
1750 dt
, r
, expDosDate
, expDosDate
& 0x1f,
1751 (expDosDate
>> 5) & 0xf, 1980 + (expDosDate
>> 9),
1752 expDosTime
, expDosTime
>> 11, (expDosTime
>> 5) & 0x3f,
1753 (expDosTime
& 0x1f),
1754 res
, dosDate
, dosDate
& 0x1f, (dosDate
>> 5) & 0xf,
1755 1980 + (dosDate
>> 9), dosTime
, dosTime
>> 11,
1756 (dosTime
>> 5) & 0x3f, (dosTime
& 0x1f));
1758 #define DT2DOS(dt,r,d,m,y,h,mn,s) test_dt2dos(__LINE__,dt,r,d,m,y,h,mn,s)
1760 static void test_VariantTimeToDosDateTime(void)
1762 CHECKPTR(VariantTimeToDosDateTime
);
1765 DT2DOS(29221.0,1,1,1,1980,0,0,0); /* 1/1/1980 */
1766 DT2DOS(73050.0,1,31,12,2099,0,0,0); /* 31/12/2099 */
1767 DT2DOS(29220.0,0,0,0,0,0,0,0); /* 31/12/1979 - out of range */
1768 DT2DOS(73415.0,0,0,0,0,0,0,0); /* 31/12/2100 - out of range */
1771 DT2DOS(29221.00032407407,1,1,1,1980,0,0,29); /* 1/1/1980 12:00:28 AM */
1772 DT2DOS(29221.00034722222,1,1,1,1980,0,0,31); /* 1/1/1980 12:00:30 AM */
1773 DT2DOS(29221.04097222222,1,1,1,1980,0,59,0); /* 1/1/1980 12:59:00 AM */
1774 DT2DOS(29221.95833333333,1,1,1,1980,23,0,0); /* 1/1/1980 11:00:00 PM */
1777 static HRESULT (WINAPI
*pVarAbs
)(LPVARIANT
,LPVARIANT
);
1779 #define VARABS(vt,val,rvt,rval) \
1780 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
1781 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
1782 test_var_call1( __LINE__, pVarAbs, &v, &exp )
1784 static void test_VarAbs(void)
1786 static WCHAR szNum
[] = {'-','1','.','1','\0' };
1789 VARIANT v
, vDst
, exp
;
1794 /* Test all possible V_VT values.
1796 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
1800 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
1802 HRESULT hExpected
= DISP_E_BADVARTYPE
;
1806 memset(&v
, 0, sizeof(v
));
1807 V_VT(&v
) = vt
| ExtraFlags
[i
];
1808 V_VT(&vDst
) = VT_EMPTY
;
1810 hres
= pVarAbs(&v
,&vDst
);
1811 if (ExtraFlags
[i
] & (VT_ARRAY
|VT_ARRAY
) ||
1812 (!ExtraFlags
[i
] && (vt
== VT_UNKNOWN
|| vt
== VT_BSTR
||
1813 vt
== VT_DISPATCH
|| vt
== VT_ERROR
|| vt
== VT_RECORD
)))
1815 hExpected
= DISP_E_TYPEMISMATCH
;
1817 else if (ExtraFlags
[i
] || vt
>= VT_CLSID
|| vt
== VT_VARIANT
)
1819 hExpected
= DISP_E_BADVARTYPE
;
1821 else if (IsValidVariantClearVT(vt
, ExtraFlags
[i
]))
1824 /* Native always fails on some vartypes that should be valid. don't
1825 * check that Wine does the same; these are bugs in native.
1827 if (vt
== VT_I8
|| vt
== VT_UI8
|| vt
== VT_INT
|| vt
== VT_UINT
||
1828 vt
== VT_I1
|| vt
== VT_UI2
|| vt
== VT_UI4
)
1830 ok(hres
== hExpected
, "VarAbs: expected 0x%X, got 0x%X for vt %d | 0x%X\n",
1831 hExpected
, hres
, vt
, ExtraFlags
[i
]);
1835 /* BOOL->I2, BSTR->R8, all others remain the same */
1836 VARABS(BOOL
,VARIANT_TRUE
,I2
,-VARIANT_TRUE
);
1837 VARABS(BOOL
,VARIANT_FALSE
,I2
,VARIANT_FALSE
);
1838 VARABS(EMPTY
,0,I2
,0);
1839 VARABS(EMPTY
,1,I2
,0);
1840 VARABS(NULL
,0,NULL
,0);
1841 VARABS(NULL
,1,NULL
,0);
1846 VARABS(UI1
,1,UI1
,1);
1851 VARABS(DATE
,1,DATE
,1);
1852 VARABS(DATE
,-1,DATE
,1);
1854 V_CY(&v
).int64
= -10000;
1855 memset(&vDst
,0,sizeof(vDst
));
1856 hres
= pVarAbs(&v
,&vDst
);
1857 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_CY
&& V_CY(&vDst
).int64
== 10000,
1858 "VarAbs(CY): expected 0x0 got 0x%X\n", hres
);
1859 GetLocaleInfoA(LOCALE_USER_DEFAULT
, LOCALE_SDECIMAL
, buff
, sizeof(buff
)/sizeof(char));
1862 trace("Skipping VarAbs(BSTR) as decimal separator is '%s'\n", buff
);
1868 V_BSTR(&v
) = (BSTR
)szNum
;
1869 memset(&vDst
,0,sizeof(vDst
));
1870 hres
= pVarAbs(&v
,&vDst
);
1871 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_R8
&& V_R8(&vDst
) == 1.1,
1872 "VarAbs: expected 0x0,%d,%g, got 0x%X,%d,%g\n", VT_R8
, 1.1, hres
, V_VT(&vDst
), V_R8(&vDst
));
1875 static HRESULT (WINAPI
*pVarNot
)(LPVARIANT
,LPVARIANT
);
1877 #define VARNOT(vt,val,rvt,rval) \
1878 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
1879 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
1880 test_var_call1( __LINE__, pVarNot, &v, &exp )
1882 static void test_VarNot(void)
1884 static const WCHAR szNum0
[] = {'0','\0' };
1885 static const WCHAR szNum1
[] = {'1','\0' };
1887 VARIANT v
, exp
, vDst
;
1888 DECIMAL
*pdec
= &V_DECIMAL(&v
);
1889 CY
*pcy
= &V_CY(&v
);
1894 /* Test all possible V_VT values */
1895 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
1899 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
1901 HRESULT hExpected
= DISP_E_BADVARTYPE
;
1905 memset(&v
, 0, sizeof(v
));
1906 V_VT(&v
) = vt
| ExtraFlags
[i
];
1907 V_VT(&vDst
) = VT_EMPTY
;
1911 case VT_I1
: case VT_UI1
: case VT_I2
: case VT_UI2
:
1912 case VT_INT
: case VT_UINT
: case VT_I4
: case VT_UI4
:
1913 case VT_R4
: case VT_R8
:
1914 case VT_DECIMAL
: case VT_BOOL
: case VT_NULL
: case VT_EMPTY
:
1915 case VT_DATE
: case VT_CY
:
1918 case VT_I8
: case VT_UI8
:
1919 if (HAVE_OLEAUT32_I8
)
1923 if (HAVE_OLEAUT32_RECORD
)
1924 hExpected
= DISP_E_TYPEMISMATCH
;
1926 case VT_UNKNOWN
: case VT_BSTR
: case VT_DISPATCH
: case VT_ERROR
:
1927 hExpected
= DISP_E_TYPEMISMATCH
;
1930 if (IsValidVariantClearVT(vt
, ExtraFlags
[i
]) && vt
!= VT_CLSID
)
1931 hExpected
= DISP_E_TYPEMISMATCH
;
1935 hres
= pVarNot(&v
,&vDst
);
1936 ok(hres
== hExpected
, "VarNot: expected 0x%X, got 0x%X vt %d|0x%X\n",
1937 hExpected
, hres
, vt
, ExtraFlags
[i
]);
1940 /* Test the values returned by all cases that can succeed */
1941 VARNOT(EMPTY
,0,I2
,-1);
1942 VARNOT(EMPTY
,1,I2
,-1);
1943 VARNOT(NULL
,0,NULL
,0);
1944 VARNOT(NULL
,1,NULL
,0);
1945 VARNOT(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
);
1946 VARNOT(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
);
1954 VARNOT(UI1
,1,UI1
,254);
1955 VARNOT(UI1
,0,UI1
,255);
1956 VARNOT(UI2
,0,I4
,-1);
1957 VARNOT(UI2
,1,I4
,-2);
1958 VARNOT(UI4
,0,I4
,-1);
1959 VARNOT(UI4
,1,I4
,-2);
1960 VARNOT(INT
,0,I4
,-1);
1961 VARNOT(INT
,1,I4
,-2);
1962 VARNOT(UINT
,0,I4
,-1);
1963 VARNOT(UINT
,1,I4
,-2);
1964 if (HAVE_OLEAUT32_I8
)
1968 VARNOT(UI8
,0,I4
,-1);
1969 VARNOT(UI8
,1,I4
,-2);
1975 VARNOT(DATE
,1,I4
,-2);
1976 VARNOT(DATE
,0,I4
,-1);
1977 VARNOT(BSTR
,(BSTR
)szNum0
,I4
,-1);
1978 ok(V_VT(&v
) == VT_BSTR
&& V_BSTR(&v
) == szNum0
, "VarNot(0): changed input\n");
1979 VARNOT(BSTR
,(BSTR
)szNum1
,I4
,-2);
1980 ok(V_VT(&v
) == VT_BSTR
&& V_BSTR(&v
) == szNum1
, "VarNot(1): changed input\n");
1982 V_VT(&v
) = VT_DECIMAL
;
1983 S(U(*pdec
)).sign
= DECIMAL_NEG
;
1984 S(U(*pdec
)).scale
= 0;
1986 S1(U1(*pdec
)).Mid32
= 0;
1987 S1(U1(*pdec
)).Lo32
= 1;
1988 VARNOT(DECIMAL
,*pdec
,I4
,0);
1991 VARNOT(CY
,*pcy
,I4
,-2);
1994 VARNOT(CY
,*pcy
,I4
,-1);
1997 VARNOT(CY
,*pcy
,I4
,-1);
2000 static HRESULT (WINAPI
*pVarSub
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
2002 #define VARSUB(vt1,val1,vt2,val2,rvt,rval) \
2003 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
2004 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
2005 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
2006 test_var_call2( __LINE__, pVarSub, &left, &right, &exp )
2008 static void test_VarSub(void)
2010 static const WCHAR sz12
[] = {'1','2','\0'};
2011 VARIANT left
, right
, exp
, result
, cy
, dec
;
2014 HRESULT hres
, expectedhres
;
2019 lbstr
= SysAllocString(sz12
);
2020 rbstr
= SysAllocString(sz12
);
2023 VariantInit(&right
);
2024 VariantInit(&result
);
2026 /* Test all possible flag/vt combinations & the resulting vt type */
2027 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
2030 VARTYPE leftvt
, rightvt
, resvt
;
2032 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
2037 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
2041 expectedhres
= S_OK
;
2043 memset(&left
, 0, sizeof(left
));
2044 memset(&right
, 0, sizeof(right
));
2045 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
2046 if (leftvt
== VT_BSTR
)
2047 V_BSTR(&left
) = lbstr
;
2048 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
2049 if (rightvt
== VT_BSTR
)
2050 V_BSTR(&right
) = rbstr
;
2051 V_VT(&result
) = VT_EMPTY
;
2054 /* All extra flags produce errors */
2055 if (ExtraFlags
[i
] == (VT_VECTOR
|VT_BYREF
|VT_RESERVED
) ||
2056 ExtraFlags
[i
] == (VT_VECTOR
|VT_RESERVED
) ||
2057 ExtraFlags
[i
] == (VT_VECTOR
|VT_BYREF
) ||
2058 ExtraFlags
[i
] == (VT_BYREF
|VT_RESERVED
) ||
2059 ExtraFlags
[i
] == VT_VECTOR
||
2060 ExtraFlags
[i
] == VT_BYREF
||
2061 ExtraFlags
[i
] == VT_RESERVED
)
2063 expectedhres
= DISP_E_BADVARTYPE
;
2066 else if (ExtraFlags
[i
] >= VT_ARRAY
)
2068 expectedhres
= DISP_E_TYPEMISMATCH
;
2071 /* Native VarSub cannot handle: VT_I1, VT_UI2, VT_UI4,
2072 VT_INT, VT_UINT and VT_UI8. Tested with WinXP */
2073 else if (!IsValidVariantClearVT(leftvt
, ExtraFlags
[i
]) ||
2074 !IsValidVariantClearVT(rightvt
, ExtraFlags
[i
]) ||
2075 leftvt
== VT_CLSID
|| rightvt
== VT_CLSID
||
2076 leftvt
== VT_VARIANT
|| rightvt
== VT_VARIANT
||
2077 leftvt
== VT_I1
|| rightvt
== VT_I1
||
2078 leftvt
== VT_UI2
|| rightvt
== VT_UI2
||
2079 leftvt
== VT_UI4
|| rightvt
== VT_UI4
||
2080 leftvt
== VT_UI8
|| rightvt
== VT_UI8
||
2081 leftvt
== VT_INT
|| rightvt
== VT_INT
||
2082 leftvt
== VT_UINT
|| rightvt
== VT_UINT
||
2083 leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
||
2084 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
)
2086 if (leftvt
== VT_RECORD
&& rightvt
== VT_I8
)
2088 if (HAVE_OLEAUT32_I8
)
2089 expectedhres
= DISP_E_TYPEMISMATCH
;
2091 expectedhres
= DISP_E_BADVARTYPE
;
2093 else if (leftvt
< VT_UI1
&& rightvt
== VT_RECORD
)
2094 expectedhres
= DISP_E_TYPEMISMATCH
;
2095 else if (leftvt
>= VT_UI1
&& rightvt
== VT_RECORD
)
2096 expectedhres
= DISP_E_TYPEMISMATCH
;
2097 else if (leftvt
== VT_RECORD
&& rightvt
<= VT_UI1
)
2098 expectedhres
= DISP_E_TYPEMISMATCH
;
2099 else if (leftvt
== VT_RECORD
&& rightvt
> VT_UI1
)
2100 expectedhres
= DISP_E_BADVARTYPE
;
2102 expectedhres
= DISP_E_BADVARTYPE
;
2105 else if ((leftvt
== VT_NULL
&& rightvt
== VT_DISPATCH
) ||
2106 (leftvt
== VT_DISPATCH
&& rightvt
== VT_NULL
))
2108 else if (leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
||
2109 leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
)
2112 expectedhres
= DISP_E_TYPEMISMATCH
;
2114 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
2116 else if ((leftvt
== VT_EMPTY
&& rightvt
== VT_BSTR
) ||
2117 (leftvt
== VT_DATE
&& rightvt
== VT_DATE
) ||
2118 (leftvt
== VT_BSTR
&& rightvt
== VT_EMPTY
) ||
2119 (leftvt
== VT_BSTR
&& rightvt
== VT_BSTR
))
2121 else if (leftvt
== VT_DECIMAL
|| rightvt
== VT_DECIMAL
)
2123 else if (leftvt
== VT_DATE
|| rightvt
== VT_DATE
)
2125 else if (leftvt
== VT_CY
|| rightvt
== VT_CY
)
2127 else if (leftvt
== VT_R8
|| rightvt
== VT_R8
)
2129 else if (leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
) {
2131 } else if (leftvt
== VT_R4
|| rightvt
== VT_R4
) {
2132 if (leftvt
== VT_I4
|| rightvt
== VT_I4
||
2133 leftvt
== VT_I8
|| rightvt
== VT_I8
)
2138 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
2140 else if (leftvt
== VT_I4
|| rightvt
== VT_I4
)
2142 else if (leftvt
== VT_I2
|| rightvt
== VT_I2
||
2143 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
||
2144 (leftvt
== VT_EMPTY
&& rightvt
== VT_EMPTY
))
2146 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
2151 expectedhres
= DISP_E_TYPEMISMATCH
;
2154 hres
= pVarSub(&left
, &right
, &result
);
2156 ok(hres
== expectedhres
&& V_VT(&result
) == resvt
,
2157 "VarSub: %d|0x%X, %d|0x%X: Expected failure 0x%X, "
2158 "got 0x%X, expected vt %d got vt %d\n",
2159 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
],
2160 expectedhres
, hres
, resvt
, V_VT(&result
));
2165 /* Test returned values */
2166 VARSUB(I4
,4,I4
,2,I4
,2);
2167 VARSUB(I2
,4,I2
,2,I2
,2);
2168 VARSUB(I2
,-13,I4
,5,I4
,-18);
2169 VARSUB(I4
,-13,I4
,5,I4
,-18);
2170 VARSUB(I2
,7,R4
,0.5f
,R4
,6.5f
);
2171 VARSUB(R4
,0.5f
,I4
,5,R8
,-4.5);
2172 VARSUB(R8
,7.1,BOOL
,0,R8
,7.1);
2173 VARSUB(BSTR
,lbstr
,I2
,4,R8
,8);
2174 VARSUB(BSTR
,lbstr
,BOOL
,1,R8
,11);
2175 VARSUB(BSTR
,lbstr
,R4
,0.1f
,R8
,11.9);
2176 VARSUB(R4
,0.2f
,BSTR
,rbstr
,R8
,-11.8);
2177 VARSUB(DATE
,2.25,I4
,7,DATE
,-4.75);
2178 VARSUB(DATE
,1.25,R4
,-1.7f
,DATE
,2.95);
2180 VARSUB(UI1
, UI1_MAX
, UI1
, UI1_MAX
, UI1
, 0);
2181 VARSUB(I2
, I2_MAX
, I2
, I2_MAX
, I2
, 0);
2182 VARSUB(I2
, I2_MIN
, I2
, I2_MIN
, I2
, 0);
2183 VARSUB(I4
, I4_MAX
, I4
, I4_MAX
, I4
, 0);
2184 VARSUB(I4
, I4_MIN
, I4
, I4_MIN
, I4
, 0);
2185 VARSUB(R4
, R4_MAX
, R4
, R4_MAX
, R4
, 0.0f
);
2186 VARSUB(R4
, R4_MAX
, R4
, R4_MIN
, R4
, R4_MAX
- R4_MIN
);
2187 VARSUB(R4
, R4_MIN
, R4
, R4_MIN
, R4
, 0.0f
);
2188 VARSUB(R8
, R8_MAX
, R8
, R8_MIN
, R8
, R8_MAX
- R8_MIN
);
2189 VARSUB(R8
, R8_MIN
, R8
, R8_MIN
, R8
, 0.0);
2191 /* Manually test BSTR + BSTR */
2192 V_VT(&left
) = VT_BSTR
;
2193 V_BSTR(&left
) = lbstr
;
2194 V_VT(&right
) = VT_BSTR
;
2195 V_BSTR(&right
) = rbstr
;
2196 hres
= VarSub(&left
, &right
, &result
);
2197 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
2198 "VarSub: expected coerced type VT_R8, got %s!\n", vtstr(V_VT(&result
)));
2199 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 0),
2200 "VarSub: BSTR + BSTR, expected %f got %f\n", 0.0, V_R8(&result
));
2202 /* Manually test some VT_CY and VT_DECIMAL variants */
2204 hres
= VarCyFromI4(4711, &V_CY(&cy
));
2205 ok(hres
== S_OK
, "VarCyFromI4 failed!\n");
2206 V_VT(&dec
) = VT_DECIMAL
;
2207 hres
= VarDecFromR8(-4.2, &V_DECIMAL(&dec
));
2208 ok(hres
== S_OK
, "VarDecFromR4 failed!\n");
2209 memset(&left
, 0, sizeof(left
));
2210 memset(&right
, 0, sizeof(right
));
2211 V_VT(&left
) = VT_I4
;
2213 V_VT(&right
) = VT_UI1
;
2216 hres
= VarSub(&cy
, &right
, &result
);
2217 ok(hres
== S_OK
&& V_VT(&result
) == VT_CY
,
2218 "VarSub: expected coerced type VT_CY, got %s!\n", vtstr(V_VT(&result
)));
2219 hres
= VarR8FromCy(V_CY(&result
), &r
);
2220 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 4702),
2221 "VarSub: CY value %f, expected %f\n", r
, (double)4720);
2223 hres
= VarSub(&left
, &dec
, &result
);
2224 ok(hres
== S_OK
&& V_VT(&result
) == VT_DECIMAL
,
2225 "VarSub: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result
)));
2226 hres
= VarR8FromDec(&V_DECIMAL(&result
), &r
);
2227 ok(hres
== S_OK
&& EQ_DOUBLE(r
, -6.8),
2228 "VarSub: DECIMAL value %f, expected %f\n", r
, (double)-15.2);
2230 SysFreeString(lbstr
);
2231 SysFreeString(rbstr
);
2234 static HRESULT (WINAPI
*pVarMod
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
2236 static void test_Mod( int line
, VARIANT
*left
, VARIANT
*right
, VARIANT
*expected
, HRESULT expres
)
2241 memset( &result
, 0, sizeof(result
) );
2242 hres
= pVarMod( left
, right
, &result
);
2243 ok_(__FILE__
,line
)( hres
== expres
, "wrong result %x/%x\n", hres
, expres
);
2245 ok_(__FILE__
,line
)( is_expected_variant( &result
, expected
),
2246 "got %s expected %s\n", variantstr(&result
), variantstr(expected
) );
2249 #define VARMOD(vt1,vt2,val1,val2,rvt,rval) \
2250 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
2251 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
2252 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
2253 test_var_call2( __LINE__, pVarMod, &left, &right, &exp )
2255 #define VARMOD2(vt1,vt2,val1,val2,rvt,rval,hexpected) \
2256 V_VT(&left) = VT_##vt1; V_I4(&left) = val1; \
2257 V_VT(&right) = VT_##vt2; V_I4(&right) = val2; \
2258 V_VT(&exp) = VT_##rvt; V_I4(&exp) = rval; \
2259 test_Mod( __LINE__, &left, &right, &exp, hexpected )
2261 static void test_VarMod(void)
2263 VARIANT v1
, v2
, vDst
, left
, right
, exp
;
2265 HRESULT hexpected
= 0;
2266 static const WCHAR szNum0
[] = {'1','2','5','\0'};
2267 static const WCHAR szNum1
[] = {'1','0','\0'};
2269 BOOL lFound
, rFound
;
2270 BOOL lValid
, rValid
;
2271 BSTR strNum0
, strNum1
;
2275 VARMOD(I1
,BOOL
,100,10,I4
,0);
2276 VARMOD(I1
,I1
,100,10,I4
,0);
2277 VARMOD(I1
,UI1
,100,10,I4
,0);
2278 VARMOD(I1
,I2
,100,10,I4
,0);
2279 VARMOD(I1
,UI2
,100,10,I4
,0);
2280 VARMOD(I1
,I4
,100,10,I4
,0);
2281 VARMOD(I1
,UI4
,100,10,I4
,0);
2282 VARMOD(I1
,R4
,100,10,I4
,0);
2283 VARMOD(I1
,R8
,100,10,I4
,0);
2285 VARMOD(UI1
,BOOL
,100,10,I2
,0);
2286 VARMOD(UI1
,I1
,100,10,I4
,0);
2287 VARMOD(UI1
,UI1
,100,10,UI1
,0);
2288 VARMOD(UI1
,I2
,100,10,I2
,0);
2289 VARMOD(UI1
,UI2
,100,10,I4
,0);
2290 VARMOD(UI1
,I4
,100,10,I4
,0);
2291 VARMOD(UI1
,UI4
,100,10,I4
,0);
2292 VARMOD(UI1
,R4
,100,10,I4
,0);
2293 VARMOD(UI1
,R8
,100,10,I4
,0);
2295 VARMOD(I2
,BOOL
,100,10,I2
,0);
2296 VARMOD(I2
,I1
,100,10,I4
,0);
2297 VARMOD(I2
,UI1
,100,10,I2
,0);
2298 VARMOD(I2
,I2
,100,10,I2
,0);
2299 VARMOD(I2
,UI2
,100,10,I4
,0);
2300 VARMOD(I2
,I4
,100,10,I4
,0);
2301 VARMOD(I2
,UI4
,100,10,I4
,0);
2302 VARMOD(I2
,R4
,100,10,I4
,0);
2303 VARMOD(I2
,R8
,100,10,I4
,0);
2305 VARMOD(I4
,BOOL
,100,10,I4
,0);
2306 VARMOD(I4
,I1
,100,10,I4
,0);
2307 VARMOD(I4
,UI1
,100,10,I4
,0);
2308 VARMOD(I4
,I2
,100,10,I4
,0);
2309 VARMOD(I4
,UI2
,100,10,I4
,0);
2310 VARMOD(I4
,I4
,100,10,I4
,0);
2311 VARMOD(I4
,UI4
,100,10,I4
,0);
2312 VARMOD(I4
,R4
,100,10,I4
,0);
2313 VARMOD(I4
,R8
,100,10,I4
,0);
2314 VARMOD(UI4
,BOOL
,100,10,I4
,0);
2315 VARMOD(UI4
,I1
,100,10,I4
,0);
2316 VARMOD(UI4
,UI1
,100,10,I4
,0);
2317 VARMOD(UI4
,I2
,100,10,I4
,0);
2318 VARMOD(UI4
,UI2
,100,10,I4
,0);
2319 VARMOD(UI4
,I4
,100,10,I4
,0);
2320 VARMOD(UI4
,UI4
,100,10,I4
,0);
2321 VARMOD(UI4
,R4
,100,10,I4
,0);
2322 VARMOD(UI4
,R8
,100,10,I4
,0);
2323 VARMOD(R4
,BOOL
,100,10,I4
,0);
2324 VARMOD(R4
,I1
,100,10,I4
,0);
2325 VARMOD(R4
,UI1
,100,10,I4
,0);
2326 VARMOD(R4
,I2
,100,10,I4
,0);
2327 VARMOD(R4
,UI2
,100,10,I4
,0);
2328 VARMOD(R4
,I4
,100,10,I4
,0);
2329 VARMOD(R4
,UI4
,100,10,I4
,0);
2330 VARMOD(R4
,R4
,100,10,I4
,0);
2331 VARMOD(R4
,R8
,100,10,I4
,0);
2332 VARMOD(R8
,BOOL
,100,10,I4
,0);
2333 VARMOD(R8
,I1
,100,10,I4
,0);
2334 VARMOD(R8
,UI1
,100,10,I4
,0);
2335 VARMOD(R8
,I2
,100,10,I4
,0);
2336 VARMOD(R8
,UI2
,100,10,I4
,0);
2337 VARMOD(R8
,I4
,100,10,I4
,0);
2338 VARMOD(R8
,UI4
,100,10,I4
,0);
2339 VARMOD(R8
,R4
,100,10,I4
,0);
2340 VARMOD(R8
,R8
,100,10,I4
,0);
2342 VARMOD(INT
,INT
,100,10,I4
,0);
2343 VARMOD(INT
,UINT
,100,10,I4
,0);
2345 VARMOD(BOOL
,BOOL
,100,10,I2
,0);
2346 VARMOD(BOOL
,I1
,100,10,I4
,0);
2347 VARMOD(BOOL
,UI1
,100,10,I2
,0);
2348 VARMOD(BOOL
,I2
,100,10,I2
,0);
2349 VARMOD(BOOL
,UI2
,100,10,I4
,0);
2350 VARMOD(BOOL
,I4
,100,10,I4
,0);
2351 VARMOD(BOOL
,UI4
,100,10,I4
,0);
2352 VARMOD(BOOL
,R4
,100,10,I4
,0);
2353 VARMOD(BOOL
,R8
,100,10,I4
,0);
2354 VARMOD(BOOL
,DATE
,100,10,I4
,0);
2356 VARMOD(DATE
,BOOL
,100,10,I4
,0);
2357 VARMOD(DATE
,I1
,100,10,I4
,0);
2358 VARMOD(DATE
,UI1
,100,10,I4
,0);
2359 VARMOD(DATE
,I2
,100,10,I4
,0);
2360 VARMOD(DATE
,UI2
,100,10,I4
,0);
2361 VARMOD(DATE
,I4
,100,10,I4
,0);
2362 VARMOD(DATE
,UI4
,100,10,I4
,0);
2363 VARMOD(DATE
,R4
,100,10,I4
,0);
2364 VARMOD(DATE
,R8
,100,10,I4
,0);
2365 VARMOD(DATE
,DATE
,100,10,I4
,0);
2367 strNum0
= SysAllocString(szNum0
);
2368 strNum1
= SysAllocString(szNum1
);
2369 VARMOD(BSTR
,BSTR
,strNum0
,strNum1
,I4
,5);
2370 VARMOD(BSTR
,I1
,strNum0
,10,I4
,5);
2371 VARMOD(BSTR
,I2
,strNum0
,10,I4
,5);
2372 VARMOD(BSTR
,I4
,strNum0
,10,I4
,5);
2373 VARMOD(BSTR
,R4
,strNum0
,10,I4
,5);
2374 VARMOD(BSTR
,R8
,strNum0
,10,I4
,5);
2375 VARMOD(I4
,BSTR
,125,strNum1
,I4
,5);
2377 if (HAVE_OLEAUT32_I8
)
2379 VARMOD(BOOL
,I8
,100,10,I8
,0);
2380 VARMOD(I1
,I8
,100,10,I8
,0);
2381 VARMOD(UI1
,I8
,100,10,I8
,0);
2382 VARMOD(I2
,I8
,100,10,I8
,0);
2383 VARMOD(I4
,I8
,100,10,I8
,0);
2384 VARMOD(UI4
,I8
,100,10,I8
,0);
2385 VARMOD(R4
,I8
,100,10,I8
,0);
2386 VARMOD(R8
,I8
,100,10,I8
,0);
2387 VARMOD(DATE
,I8
,100,10,I8
,0);
2389 VARMOD(I8
,BOOL
,100,10,I8
,0);
2390 VARMOD(I8
,I1
,100,10,I8
,0);
2391 VARMOD(I8
,UI1
,100,10,I8
,0);
2392 VARMOD(I8
,I2
,100,10,I8
,0);
2393 VARMOD(I8
,UI2
,100,10,I8
,0);
2394 VARMOD(I8
,I4
,100,10,I8
,0);
2395 VARMOD(I8
,UI4
,100,10,I8
,0);
2396 VARMOD(I8
,R4
,100,10,I8
,0);
2397 VARMOD(I8
,R8
,100,10,I8
,0);
2398 VARMOD(I8
,I8
,100,10,I8
,0);
2400 VARMOD(BSTR
,I8
,strNum0
,10,I8
,5);
2403 /* test all combinations of types */
2404 for(l
= 0; l
< VT_BSTR_BLOB
; l
++)
2408 for(r
= 0; r
< VT_BSTR_BLOB
; r
++)
2412 if(l
== VT_BSTR
) continue;
2413 if(l
== VT_DISPATCH
) continue;
2414 if(r
== VT_BSTR
) continue;
2415 if(r
== VT_DISPATCH
) continue;
2449 hexpected
= DISP_E_BADVARTYPE
;
2488 if(((l
== VT_I8
) && (r
== VT_INT
)) || ((l
== VT_INT
) && (r
== VT_I8
)))
2490 hexpected
= DISP_E_TYPEMISMATCH
;
2491 } else if((l
== VT_EMPTY
) && (r
== VT_NULL
))
2494 } else if((l
== VT_NULL
) && (r
== VT_EMPTY
))
2497 } else if((l
== VT_EMPTY
) && (r
== VT_CY
))
2500 } else if((l
== VT_EMPTY
) && (r
== VT_RECORD
))
2502 hexpected
= DISP_E_TYPEMISMATCH
;
2503 } else if((r
== VT_EMPTY
) && lFound
&& lValid
)
2505 hexpected
= DISP_E_DIVBYZERO
;
2506 } else if((l
== VT_ERROR
) || ((r
== VT_ERROR
) && lFound
&& lValid
))
2508 hexpected
= DISP_E_TYPEMISMATCH
;
2509 } else if((l
== VT_NULL
) && (r
== VT_NULL
))
2512 } else if((l
== VT_VARIANT
) || ((r
== VT_VARIANT
) && lFound
&& lValid
))
2514 hexpected
= DISP_E_TYPEMISMATCH
;
2515 } else if((l
== VT_NULL
) && (r
== VT_RECORD
))
2517 hexpected
= DISP_E_TYPEMISMATCH
;
2518 } else if((l
== VT_I8
) && (r
== VT_DECIMAL
))
2521 } else if((l
== VT_DECIMAL
) && (r
== VT_I8
))
2524 } else if((l
== VT_UNKNOWN
) || ((r
== VT_UNKNOWN
) && lFound
&& lValid
))
2526 hexpected
= DISP_E_TYPEMISMATCH
;
2527 } else if((l
== VT_NULL
) && rFound
)
2530 } else if(l
== VT_RECORD
)
2532 hexpected
= DISP_E_TYPEMISMATCH
;
2533 } else if((r
== VT_RECORD
) && lValid
&& lFound
)
2535 hexpected
= DISP_E_TYPEMISMATCH
;
2536 } else if((l
== VT_EMPTY
) && (r
== VT_EMPTY
))
2538 hexpected
= DISP_E_DIVBYZERO
;
2539 } else if((l
== VT_CY
) && !rFound
)
2541 hexpected
= DISP_E_BADVARTYPE
;
2542 } else if(lFound
&& !rFound
)
2544 hexpected
= DISP_E_BADVARTYPE
;
2545 } else if(!lFound
&& rFound
)
2547 hexpected
= DISP_E_BADVARTYPE
;
2548 } else if((r
== VT_NULL
) && lFound
&& lValid
)
2551 } else if((l
== VT_NULL
) || (r
== VT_NULL
))
2553 hexpected
= DISP_E_BADVARTYPE
;
2554 } else if((l
== VT_VARIANT
) || (r
== VT_VARIANT
))
2556 hexpected
= DISP_E_BADVARTYPE
;
2557 } else if(lFound
&& !rFound
)
2559 hexpected
= DISP_E_BADVARTYPE
;
2560 } else if(!lFound
&& !rFound
)
2562 hexpected
= DISP_E_BADVARTYPE
;
2569 V_CY(&v1
).int64
= 1000000;
2574 else if(l
== VT_UI8
)
2578 else if(l
== VT_DATE
)
2580 else if (l
== VT_DECIMAL
)
2582 V_DECIMAL(&v1
).Hi32
= 0;
2583 U1(V_DECIMAL(&v1
)).Lo64
= 100;
2584 U(V_DECIMAL(&v1
)).signscale
= 0;
2590 V_CY(&v2
).int64
= 10000;
2595 else if(r
== VT_UI8
)
2599 else if(r
== VT_DATE
)
2601 else if (r
== VT_DECIMAL
)
2603 V_DECIMAL(&v2
).Hi32
= 0;
2604 U1(V_DECIMAL(&v2
)).Lo64
= 100;
2605 U(V_DECIMAL(&v2
)).signscale
= 0;
2610 if ((l
!= VT_I8
&& l
!= VT_UI8
&& r
!= VT_I8
&& r
!= VT_UI8
) || HAVE_OLEAUT32_I8
)
2612 hres
= pVarMod(&v1
,&v2
,&vDst
);
2613 ok(hres
== hexpected
,
2614 "VarMod: expected 0x%x, got 0x%X for l type of %d, r type of %d,\n", hexpected
, hres
, l
, r
);
2620 /****************************/
2621 /* test some bad parameters */
2622 VARMOD(I4
,I4
,-1,-1,I4
,0);
2624 /* test modulus with zero */
2625 VARMOD2(I4
,I4
,100,0,EMPTY
,0,DISP_E_DIVBYZERO
);
2627 VARMOD(I4
,I4
,0,10,I4
,0); /* test 0 mod 10 */
2629 /* right parameter is type empty */
2630 VARMOD2(I4
,EMPTY
,100,10,EMPTY
,0,DISP_E_DIVBYZERO
);
2632 /* left parameter is type empty */
2633 VARMOD2(EMPTY
,I4
,100,10,I4
,0,S_OK
);
2635 /* mod with a null left value */
2636 VARMOD2(NULL
,I4
,125,10,NULL
,0,S_OK
);
2638 /* mod with a null right value */
2639 VARMOD2(I4
,NULL
,100,10,NULL
,0,S_OK
);
2641 /* void left value */
2642 VARMOD2(VOID
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2644 /* void right value */
2645 VARMOD2(I4
,VOID
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2647 /* null left value, void right value */
2648 VARMOD2(NULL
,VOID
,100,10,EMPTY
, 0, DISP_E_BADVARTYPE
);
2650 /* void left value, null right value */
2651 VARMOD2(VOID
,NULL
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2653 /* some currencies */
2656 V_CY(&v1
).int64
= 100000;
2657 V_CY(&v2
).int64
= 100000;
2658 hres
= pVarMod(&v1
,&v2
,&vDst
);
2659 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I4
&& V_I4(&vDst
) == 0,
2660 "VarMod: expected 0x%x,%d,%d, got 0x%X,%d,%d\n", S_OK
, VT_I4
, 0, hres
, V_VT(&vDst
), V_I4(&vDst
));
2665 V_CY(&v2
).int64
= 100000;
2666 hres
= pVarMod(&v1
,&v2
,&vDst
);
2667 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I4
&& V_I4(&vDst
) == 0,
2668 "VarMod: expected 0x%x,%d,%d, got 0x%X,%d,%d\n", S_OK
, VT_I4
, 0, hres
, V_VT(&vDst
), V_I4(&vDst
));
2671 V_VT(&v1
) = VT_DECIMAL
;
2672 V_VT(&v2
) = VT_DECIMAL
;
2673 VarDecFromI4(100, &V_DECIMAL(&v1
));
2674 VarDecFromI4(10, &V_DECIMAL(&v2
));
2675 hres
= pVarMod(&v1
,&v2
,&vDst
);
2676 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I4
&& V_I4(&vDst
) == 0,
2677 "VarMod: expected 0x%x,%d,%d, got 0x%X,%d,%d\n", S_OK
, VT_I4
, 0, hres
, V_VT(&vDst
), V_I4(&vDst
));
2680 V_VT(&v2
) = VT_DECIMAL
;
2682 VarDecFromI4(10, &V_DECIMAL(&v2
));
2683 hres
= pVarMod(&v1
,&v2
,&vDst
);
2684 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I4
&& V_I4(&vDst
) == 0,
2685 "VarMod: expected 0x%x,%d,%d, got 0x%X,%d,%d\n", S_OK
, VT_I4
, 0, hres
, V_VT(&vDst
), V_I4(&vDst
));
2687 VARMOD2(UINT
,I4
,100,10,I4
,0,S_OK
);
2689 /* test that an error results in the type of the result changing but not its value */
2690 V_VT(&v1
) = VT_UNKNOWN
;
2691 V_VT(&v2
) = VT_EMPTY
;
2693 V_CY(&v2
).int64
= 100000;
2694 V_VT(&vDst
) = VT_I4
;
2696 hres
= pVarMod(&v1
,&v2
,&vDst
);
2697 ok(hres
== DISP_E_TYPEMISMATCH
&& V_VT(&vDst
) == VT_EMPTY
&& V_I4(&vDst
) == 1231,
2698 "VarMod: expected 0x%x,%d,%d, got 0x%X,%d,%d\n", DISP_E_TYPEMISMATCH
, VT_EMPTY
, 1231, hres
, V_VT(&vDst
), V_I4(&vDst
));
2701 /* test some invalid types */
2702 /*TODO: not testing VT_DISPATCH */
2703 if (HAVE_OLEAUT32_I8
)
2705 VARMOD2(I8
,INT
,100,10,EMPTY
,0,DISP_E_TYPEMISMATCH
);
2707 VARMOD2(ERROR
,I4
,100,10,EMPTY
,0,DISP_E_TYPEMISMATCH
);
2708 VARMOD2(VARIANT
,I4
,100,10,EMPTY
,0,DISP_E_TYPEMISMATCH
);
2709 VARMOD2(UNKNOWN
,I4
,100,10,EMPTY
,0,DISP_E_TYPEMISMATCH
);
2710 VARMOD2(VOID
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2711 VARMOD2(HRESULT
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2712 VARMOD2(PTR
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2713 VARMOD2(SAFEARRAY
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2714 VARMOD2(CARRAY
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2715 VARMOD2(USERDEFINED
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2716 VARMOD2(LPSTR
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2717 VARMOD2(LPWSTR
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2718 VARMOD2(RECORD
,I4
,100,10,EMPTY
,0,DISP_E_TYPEMISMATCH
);
2719 VARMOD2(FILETIME
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2720 VARMOD2(BLOB
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2721 VARMOD2(STREAM
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2722 VARMOD2(STORAGE
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2723 VARMOD2(STREAMED_OBJECT
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2724 VARMOD2(STORED_OBJECT
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2725 VARMOD2(BLOB_OBJECT
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2726 VARMOD2(CF
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2727 VARMOD2(CLSID
,CLSID
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2728 VARMOD2(VECTOR
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2729 VARMOD2(ARRAY
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2730 VARMOD2(BYREF
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2732 /* test some more invalid types */
2737 hres
= pVarMod(&v1
,&v2
,&vDst
);
2738 ok(hres
== DISP_E_BADVARTYPE
&& V_VT(&vDst
) == VT_EMPTY
,
2739 "VarMod: expected 0x%x,%d, got 0x%X,%d\n", DISP_E_BADVARTYPE
, VT_EMPTY
, hres
, V_VT(&vDst
));
2741 SysFreeString(strNum0
);
2742 SysFreeString(strNum1
);
2745 static HRESULT (WINAPI
*pVarFix
)(LPVARIANT
,LPVARIANT
);
2747 #define VARFIX(vt,val,rvt,rval) \
2748 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
2749 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
2750 test_var_call1( __LINE__, pVarFix, &v, &exp )
2752 static void test_VarFix(void)
2754 static const WCHAR szNumMinus1
[] = {'-','1','\0' };
2756 VARIANT v
, exp
, vDst
;
2757 DECIMAL
*pdec
= &V_DECIMAL(&v
);
2758 CY
*pcy
= &V_CY(&v
);
2763 /* Test all possible V_VT values */
2764 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
2768 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
2770 HRESULT bFail
= TRUE
;
2774 memset(&v
, 0, sizeof(v
));
2775 V_VT(&v
) = vt
| ExtraFlags
[i
];
2776 V_VT(&vDst
) = VT_EMPTY
;
2780 case VT_UI1
: case VT_I2
: case VT_I4
: case VT_R4
: case VT_R8
:
2781 case VT_DECIMAL
: case VT_BOOL
: case VT_NULL
: case VT_EMPTY
:
2782 case VT_DATE
: case VT_CY
:
2786 if (HAVE_OLEAUT32_I8
)
2791 hres
= pVarFix(&v
,&vDst
);
2793 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
2794 "VarFix: expected failure, got 0x%X vt %d|0x%X\n",
2795 hres
, vt
, ExtraFlags
[i
]);
2797 ok(hres
== S_OK
, "VarFix: expected S_OK, got 0x%X vt %d|0x%X\n",
2798 hres
, vt
, ExtraFlags
[i
]);
2802 VARFIX(BOOL
,VARIANT_TRUE
,I2
,VARIANT_TRUE
);
2803 VARFIX(BOOL
,VARIANT_FALSE
,I2
,0);
2804 VARFIX(BOOL
,1,I2
,1);
2805 VARFIX(UI1
,1,UI1
,1);
2806 VARFIX(I2
,-1,I2
,-1);
2807 VARFIX(I4
,-1,I4
,-1);
2808 if (HAVE_OLEAUT32_I8
)
2810 VARFIX(I8
,-1,I8
,-1);
2812 VARFIX(R4
,1.4f
,R4
,1);
2813 VARFIX(R4
,1.5f
,R4
,1);
2814 VARFIX(R4
,1.6f
,R4
,1);
2815 VARFIX(R4
,-1.4f
,R4
,-1);
2816 VARFIX(R4
,-1.5f
,R4
,-1);
2817 VARFIX(R4
,-1.6f
,R4
,-1);
2818 /* DATE & R8 round as for R4 */
2819 VARFIX(DATE
,-1,DATE
,-1);
2820 VARFIX(R8
,-1,R8
,-1);
2821 VARFIX(BSTR
,(BSTR
)szNumMinus1
,R8
,-1);
2823 V_VT(&v
) = VT_EMPTY
;
2824 hres
= pVarFix(&v
,&vDst
);
2825 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I2
&& V_I2(&vDst
) == 0,
2826 "VarFix: expected 0x0,%d,0 got 0x%X,%d,%d\n", VT_EMPTY
,
2827 hres
, V_VT(&vDst
), V_I2(&vDst
));
2830 hres
= pVarFix(&v
,&vDst
);
2831 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_NULL
,
2832 "VarFix: expected 0x0,%d got 0x%X,%d\n", VT_NULL
, hres
, V_VT(&vDst
));
2834 V_VT(&v
) = VT_DECIMAL
;
2835 S(U(*pdec
)).sign
= DECIMAL_NEG
;
2836 S(U(*pdec
)).scale
= 0;
2838 S1(U1(*pdec
)).Mid32
= 0;
2839 S1(U1(*pdec
)).Lo32
= 1;
2840 hres
= pVarFix(&v
,&vDst
);
2841 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_DECIMAL
&& !memcmp(&v
, &vDst
, sizeof(v
)),
2842 "VarFix: expected 0x0,%d,identical, got 0x%X,%d\n", VT_DECIMAL
,
2845 /* FIXME: Test some fractional decimals when VarDecFix is implemented */
2848 pcy
->int64
= -10000;
2849 hres
= pVarFix(&v
,&vDst
);
2850 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_CY
&& V_CY(&vDst
).int64
== -10000,
2851 "VarFix: VT_CY wrong, hres=0x%X\n", hres
);
2854 pcy
->int64
= -16000;
2855 hres
= pVarFix(&v
,&vDst
);
2856 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_CY
&& V_CY(&vDst
).int64
== -10000,
2857 "VarFix: VT_CY wrong, hres=0x%X\n", hres
);
2860 static HRESULT (WINAPI
*pVarInt
)(LPVARIANT
,LPVARIANT
);
2862 #define VARINT(vt,val,rvt,rval) \
2863 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
2864 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
2865 test_var_call1( __LINE__, pVarInt, &v, &exp )
2867 static void test_VarInt(void)
2869 static const WCHAR szNumMinus1
[] = {'-','1','\0' };
2871 VARIANT v
, exp
, vDst
;
2872 DECIMAL
*pdec
= &V_DECIMAL(&v
);
2873 CY
*pcy
= &V_CY(&v
);
2878 /* Test all possible V_VT values */
2879 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
2883 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
2885 HRESULT bFail
= TRUE
;
2889 memset(&v
, 0, sizeof(v
));
2890 V_VT(&v
) = vt
| ExtraFlags
[i
];
2891 V_VT(&vDst
) = VT_EMPTY
;
2895 case VT_UI1
: case VT_I2
: case VT_I4
: case VT_R4
: case VT_R8
:
2896 case VT_DECIMAL
: case VT_BOOL
: case VT_NULL
: case VT_EMPTY
:
2897 case VT_DATE
: case VT_CY
:
2901 if (HAVE_OLEAUT32_I8
)
2906 hres
= pVarInt(&v
,&vDst
);
2908 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
2909 "VarInt: expected failure, got 0x%X vt %d|0x%X\n",
2910 hres
, vt
, ExtraFlags
[i
]);
2912 ok(hres
== S_OK
, "VarInt: expected S_OK, got 0x%X vt %d|0x%X\n",
2913 hres
, vt
, ExtraFlags
[i
]);
2917 VARINT(BOOL
,VARIANT_TRUE
,I2
,VARIANT_TRUE
);
2918 VARINT(BOOL
,VARIANT_FALSE
,I2
,0);
2919 VARINT(BOOL
,1,I2
,1);
2920 VARINT(UI1
,1,UI1
,1);
2921 VARINT(I2
,-1,I2
,-1);
2922 VARINT(I4
,-1,I4
,-1);
2923 if (HAVE_OLEAUT32_I8
)
2925 VARINT(I8
,-1,I8
,-1);
2927 VARINT(R4
,1.4f
,R4
,1);
2928 VARINT(R4
,1.5f
,R4
,1);
2929 VARINT(R4
,1.6f
,R4
,1);
2930 VARINT(R4
,-1.4f
,R4
,-2); /* Note these 3 are different from VarFix */
2931 VARINT(R4
,-1.5f
,R4
,-2);
2932 VARINT(R4
,-1.6f
,R4
,-2);
2933 /* DATE & R8 round as for R4 */
2934 VARINT(DATE
,-1,DATE
,-1);
2935 VARINT(R8
,-1,R8
,-1);
2936 VARINT(BSTR
,(BSTR
)szNumMinus1
,R8
,-1);
2938 V_VT(&v
) = VT_EMPTY
;
2939 hres
= pVarInt(&v
,&vDst
);
2940 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I2
&& V_I2(&vDst
) == 0,
2941 "VarInt: expected 0x0,%d,0 got 0x%X,%d,%d\n", VT_EMPTY
,
2942 hres
, V_VT(&vDst
), V_I2(&vDst
));
2945 hres
= pVarInt(&v
,&vDst
);
2946 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_NULL
,
2947 "VarInt: expected 0x0,%d got 0x%X,%d\n", VT_NULL
, hres
, V_VT(&vDst
));
2949 V_VT(&v
) = VT_DECIMAL
;
2950 S(U(*pdec
)).sign
= DECIMAL_NEG
;
2951 S(U(*pdec
)).scale
= 0;
2953 S1(U1(*pdec
)).Mid32
= 0;
2954 S1(U1(*pdec
)).Lo32
= 1;
2955 hres
= pVarInt(&v
,&vDst
);
2956 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_DECIMAL
&& !memcmp(&v
, &vDst
, sizeof(v
)),
2957 "VarInt: expected 0x0,%d,identical, got 0x%X,%d\n", VT_DECIMAL
,
2960 /* FIXME: Test some fractional decimals when VarDecInt is implemented */
2963 pcy
->int64
= -10000;
2964 hres
= pVarInt(&v
,&vDst
);
2965 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_CY
&& V_CY(&vDst
).int64
== -10000,
2966 "VarInt: VT_CY wrong, hres=0x%X\n", hres
);
2969 pcy
->int64
= -11000;
2970 hres
= pVarInt(&v
,&vDst
);
2971 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_CY
&& V_CY(&vDst
).int64
== -20000,
2972 "VarInt: VT_CY wrong, hres=0x%X 0x%x%08x\n",
2973 hres
, (DWORD
)(V_CY(&vDst
).int64
>> 32), (DWORD
)V_CY(&vDst
).int64
);
2976 static HRESULT (WINAPI
*pVarNeg
)(LPVARIANT
,LPVARIANT
);
2978 #define VARNEG(vt,val,rvt,rval) \
2979 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
2980 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
2981 test_var_call1( __LINE__, pVarNeg, &v, &exp )
2983 static void test_VarNeg(void)
2985 static const WCHAR szNumMinus1
[] = {'-','1','\0' };
2986 static const WCHAR szNum1
[] = {'1','\0' };
2988 VARIANT v
, exp
, vDst
;
2989 DECIMAL
*pdec
= &V_DECIMAL(&v
);
2990 CY
*pcy
= &V_CY(&v
);
2995 /* Test all possible V_VT values. But don't test the exact return values
2996 * except for success/failure, since M$ made a hash of them in the
2997 * native version. This at least ensures (as with all tests here) that
2998 * we will notice if/when new vtypes/flags are added in native.
3000 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
3004 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
3006 HRESULT bFail
= TRUE
;
3010 memset(&v
, 0, sizeof(v
));
3011 V_VT(&v
) = vt
| ExtraFlags
[i
];
3012 V_VT(&vDst
) = VT_EMPTY
;
3016 case VT_UI1
: case VT_I2
: case VT_I4
:
3017 case VT_R4
: case VT_R8
:
3018 case VT_DECIMAL
: case VT_BOOL
: case VT_NULL
: case VT_EMPTY
:
3019 case VT_DATE
: case VT_CY
:
3023 if (HAVE_OLEAUT32_I8
)
3027 hres
= pVarNeg(&v
,&vDst
);
3029 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
3030 "VarNeg: expected failure, got 0x%X vt %d|0x%X\n",
3031 hres
, vt
, ExtraFlags
[i
]);
3033 ok(hres
== S_OK
, "VarNeg: expected S_OK, got 0x%X vt %d|0x%X\n",
3034 hres
, vt
, ExtraFlags
[i
]);
3038 VARNEG(BOOL
,VARIANT_TRUE
,I2
,1);
3039 VARNEG(BOOL
,VARIANT_FALSE
,I2
,0);
3040 VARNEG(BOOL
,1,I2
,-1);
3041 VARNEG(UI1
,1,I2
,-1);
3042 VARNEG(UI1
,254,I2
,-254);
3043 VARNEG(I2
,-32768,I4
,32768);
3046 VARNEG(I4
,-((int)(~0u >> 1)) - 1,R8
,-2147483648u);
3049 if (HAVE_OLEAUT32_I8
)
3056 VARNEG(DATE
,1,DATE
,-1);
3057 VARNEG(DATE
,-1,DATE
,1);
3060 VARNEG(BSTR
,(BSTR
)szNumMinus1
,R8
,1);
3061 VARNEG(BSTR
,(BSTR
)szNum1
,R8
,-1);
3063 V_VT(&v
) = VT_EMPTY
;
3064 hres
= pVarNeg(&v
,&vDst
);
3065 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I2
&& V_I2(&vDst
) == 0,
3066 "VarNeg: expected 0x0,%d,0 got 0x%X,%d,%d\n", VT_EMPTY
,
3067 hres
, V_VT(&vDst
), V_I2(&vDst
));
3070 hres
= pVarNeg(&v
,&vDst
);
3071 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_NULL
,
3072 "VarNeg: expected 0x0,%d got 0x%X,%d\n", VT_NULL
, hres
, V_VT(&vDst
));
3074 V_VT(&v
) = VT_DECIMAL
;
3075 S(U(*pdec
)).sign
= DECIMAL_NEG
;
3076 S(U(*pdec
)).scale
= 0;
3078 S1(U1(*pdec
)).Mid32
= 0;
3079 S1(U1(*pdec
)).Lo32
= 1;
3080 hres
= pVarNeg(&v
,&vDst
);
3081 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_DECIMAL
&&
3082 S(U(V_DECIMAL(&vDst
))).sign
== 0,
3083 "VarNeg: expected 0x0,%d,0x00, got 0x%X,%d,%02x\n", VT_DECIMAL
,
3084 hres
, V_VT(&vDst
), S(U(V_DECIMAL(&vDst
))).sign
);
3086 S(U(*pdec
)).sign
= 0;
3087 hres
= pVarNeg(&v
,&vDst
);
3088 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_DECIMAL
&&
3089 S(U(V_DECIMAL(&vDst
))).sign
== DECIMAL_NEG
,
3090 "VarNeg: expected 0x0,%d,0x7f, got 0x%X,%d,%02x\n", VT_DECIMAL
,
3091 hres
, V_VT(&vDst
), S(U(V_DECIMAL(&vDst
))).sign
);
3094 pcy
->int64
= -10000;
3095 hres
= pVarNeg(&v
,&vDst
);
3096 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_CY
&& V_CY(&vDst
).int64
== 10000,
3097 "VarNeg: VT_CY wrong, hres=0x%X\n", hres
);
3100 static HRESULT (WINAPI
*pVarRound
)(LPVARIANT
,int,LPVARIANT
);
3102 static void test_Round( int line
, VARIANT
*arg
, int deci
, VARIANT
*expected
)
3107 memset( &result
, 0, sizeof(result
) );
3108 hres
= pVarRound( arg
, deci
, &result
);
3109 ok_(__FILE__
,line
)( hres
== S_OK
, "wrong result %x\n", hres
);
3111 ok_(__FILE__
,line
)( is_expected_variant( &result
, expected
),
3112 "got %s expected %s\n", variantstr(&result
), variantstr(expected
) );
3114 #define VARROUND(vt,val,deci,rvt,rval) \
3115 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
3116 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
3117 test_Round( __LINE__, &v, deci, &exp )
3119 static void test_VarRound(void)
3121 static WCHAR szNumMin
[] = {'-','1','.','4','4','9','\0' };
3122 static WCHAR szNum
[] = {'1','.','4','5','1','\0' };
3124 VARIANT v
, exp
, vDst
;
3125 CY
*pcy
= &V_CY(&v
);
3130 /* first check valid integer types */
3131 VARROUND(BOOL
,VARIANT_TRUE
,0,I2
,-1);
3132 VARROUND(BOOL
,VARIANT_FALSE
,0,I2
,0);
3133 VARROUND(BOOL
,1,0,I2
,1);
3134 VARROUND(UI1
,1,0,UI1
,1);
3135 VARROUND(UI1
,254,0,UI1
,254);
3136 VARROUND(I2
,-32768,0,I2
,-32768);
3137 VARROUND(I2
,-1,0,I2
,-1);
3138 VARROUND(I2
,1,0,I2
,1);
3139 VARROUND(I4
,-((int)(~0u >> 1)) - 1,0,I4
,-((int)(~0u >> 1)) - 1);
3140 VARROUND(I4
,-1,0,I4
,-1);
3141 VARROUND(I4
,1,0,I4
,1);
3144 /* MSDN states that rounding of R4/R8 is dependent on the underlying
3145 * bit pattern of the number and so is architecture dependent. In this
3146 * case Wine returns .2 (which is more correct) and Native returns .3
3149 VARROUND(R4
,1.0f
,0,R4
,1.0f
);
3150 VARROUND(R4
,-1.0f
,0,R4
,-1.0f
);
3151 VARROUND(R8
,1.0,0,R8
,1.0);
3152 VARROUND(R8
,-1.0,0,R8
,-1.0);
3154 /* floating point numbers aren't exactly equal and we can't just
3155 * compare the first few digits. */
3156 VARROUND(DATE
,1.451,1,DATE
,1.5);
3157 VARROUND(DATE
,-1.449,1,DATE
,-1.4);
3159 /* replace the decimal separator */
3160 GetLocaleInfoA(LOCALE_USER_DEFAULT
, LOCALE_SDECIMAL
, buff
, sizeof(buff
)/sizeof(char));
3162 szNumMin
[2] = buff
[0];
3164 VARROUND(BSTR
,(BSTR
)szNumMin
,1,R8
,-1.40);
3165 VARROUND(BSTR
,(BSTR
)szNum
,1,R8
,1.50);
3167 skip("Skipping VarRound(BSTR) as decimal separator is '%s'\n", buff
);
3170 VARROUND(R4
,1.23456f
,0,R4
,1.0f
);
3171 VARROUND(R4
,1.23456f
,1,R4
,1.2f
);
3172 VARROUND(R4
,1.23456f
,2,R4
,1.23f
);
3173 VARROUND(R4
,1.23456f
,3,R4
,1.235f
);
3174 VARROUND(R4
,1.23456f
,4,R4
,1.2346f
);
3175 VARROUND(R4
,-1.23456f
,0,R4
,-1.0f
);
3176 VARROUND(R4
,-1.23456f
,1,R4
,-1.2f
);
3177 VARROUND(R4
,-1.23456f
,2,R4
,-1.23f
);
3178 VARROUND(R4
,-1.23456f
,3,R4
,-1.235f
);
3179 VARROUND(R4
,-1.23456f
,4,R4
,-1.2346f
);
3181 VARROUND(R8
,1.23456,0,R8
,1.0);
3182 VARROUND(R8
,1.23456,1,R8
,1.2);
3183 VARROUND(R8
,1.23456,2,R8
,1.23);
3184 VARROUND(R8
,1.23456,3,R8
,1.235);
3185 VARROUND(R8
,1.23456,4,R8
,1.2346);
3186 VARROUND(R8
,-1.23456,0,R8
,-1.0);
3187 VARROUND(R8
,-1.23456,1,R8
,-1.2);
3188 VARROUND(R8
,-1.23456,2,R8
,-1.23);
3189 VARROUND(R8
,-1.23456,3,R8
,-1.235);
3190 VARROUND(R8
,-1.23456,4,R8
,-1.2346);
3192 V_VT(&v
) = VT_EMPTY
;
3193 hres
= pVarRound(&v
,0,&vDst
);
3194 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I2
&& V_I2(&vDst
) == 0,
3195 "VarRound: expected 0x0,%d,0 got 0x%X,%d,%d\n", VT_EMPTY
,
3196 hres
, V_VT(&vDst
), V_I2(&vDst
));
3199 hres
= pVarRound(&v
,0,&vDst
);
3200 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_NULL
,
3201 "VarRound: expected 0x0,%d got 0x%X,%d\n", VT_NULL
, hres
, V_VT(&vDst
));
3203 /* not yet implemented so no use testing yet
3205 DECIMAL *pdec = &V_DECIMAL(&v);
3206 V_VT(&v) = VT_DECIMAL;
3207 S(U(*pdec)).sign = DECIMAL_NEG;
3208 S(U(*pdec)).scale = 0;
3210 S1(U1(*pdec)).Mid32 = 0;
3211 S1(U1(*pdec)).Lo32 = 1;
3212 hres = pVarRound(&v,0,&vDst);
3213 ok(hres == S_OK && V_VT(&vDst) == VT_DECIMAL &&
3214 S(U(V_DECIMAL(&vDst))).sign == 0,
3215 "VarRound: expected 0x0,%d,0x00, got 0x%X,%d,%02x\n", VT_DECIMAL,
3216 hres, V_VT(&vDst), S(U(V_DECIMAL(&vDst))).sign);
3218 S(U(*pdec)).sign = 0;
3219 hres = pVarRound(&v,0,&vDst);
3220 ok(hres == S_OK && V_VT(&vDst) == VT_DECIMAL &&
3221 S(U(V_DECIMAL(&vDst))).sign == DECIMAL_NEG,
3222 "VarRound: expected 0x0,%d,0x7f, got 0x%X,%d,%02x\n", VT_DECIMAL,
3223 hres, V_VT(&vDst), S(U(V_DECIMAL(&vDst))).sign);
3229 hres
= pVarRound(&v
,0,&vDst
);
3230 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_CY
&& V_CY(&vDst
).int64
== 10000,
3231 "VarRound: VT_CY wrong, hres=0x%X\n", hres
);
3235 static HRESULT (WINAPI
*pVarXor
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
3237 #define VARXOR(vt1,val1,vt2,val2,rvt,rval) \
3238 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
3239 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
3240 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
3241 test_var_call2( __LINE__, pVarXor, &left, &right, &exp )
3243 #define VARXORCY(vt1,val1,val2,rvt,rval) \
3244 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
3245 V_VT(&right) = VT_CY; V_CY(&right).int64 = val2; \
3246 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
3247 test_var_call2( __LINE__, pVarXor, &left, &right, &exp )
3249 static void test_VarXor(void)
3251 static const WCHAR szFalse
[] = { '#','F','A','L','S','E','#','\0' };
3252 static const WCHAR szTrue
[] = { '#','T','R','U','E','#','\0' };
3253 VARIANT left
, right
, exp
, result
;
3260 /* Test all possible flag/vt combinations & the resulting vt type */
3261 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
3263 VARTYPE leftvt
, rightvt
, resvt
;
3265 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
3270 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
3276 if (leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
||
3277 leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
||
3278 leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
)
3281 memset(&left
, 0, sizeof(left
));
3282 memset(&right
, 0, sizeof(right
));
3283 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
3284 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
3285 V_VT(&result
) = VT_EMPTY
;
3288 if (ExtraFlags
[i
] & VT_ARRAY
|| ExtraFlags
[i
] & VT_BYREF
||
3289 !IsValidVariantClearVT(leftvt
, ExtraFlags
[i
]) ||
3290 !IsValidVariantClearVT(rightvt
, ExtraFlags
[i
]) ||
3291 leftvt
== VT_CLSID
|| rightvt
== VT_CLSID
||
3292 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
||
3293 leftvt
== VT_VARIANT
|| rightvt
== VT_VARIANT
||
3294 leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
)
3298 if (leftvt
== VT_EMPTY
|| rightvt
== VT_EMPTY
)
3300 if (leftvt
== rightvt
||
3301 leftvt
== VT_I2
|| rightvt
== VT_I2
||
3302 leftvt
== VT_UI1
|| rightvt
== VT_UI1
||
3303 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
3305 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
3307 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
3310 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
3314 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
3316 if (leftvt
== rightvt
)
3318 else if (leftvt
== rightvt
||
3319 leftvt
== VT_I2
|| rightvt
== VT_I2
||
3320 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
3324 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
3327 else if (leftvt
== VT_I2
|| rightvt
== VT_I2
)
3329 if (leftvt
== rightvt
||
3330 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
3332 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
3335 else if (leftvt
== VT_BOOL
&& rightvt
== VT_BOOL
)
3339 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
3341 if (leftvt
== VT_INT
|| rightvt
== VT_INT
)
3346 hres
= pVarXor(&left
, &right
, &result
);
3348 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
3349 "VarXor: %d|0x%X, %d|0x%X: Expected failure, got 0x%X vt %d\n",
3350 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], hres
,
3353 ok(hres
== S_OK
&& V_VT(&result
) == resvt
,
3354 "VarXor: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%X vt %d\n",
3355 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], resvt
, hres
,
3361 /* Test returned values
3362 * FIXME: Test VT_DECIMAL/VT_DISPATCH
3364 VARXOR(EMPTY
,0,EMPTY
,0,I2
,0);
3365 VARXOR(EMPTY
,1,EMPTY
,0,I2
,0);
3366 VARXOR(EMPTY
,0,NULL
,0,NULL
,0);
3367 VARXOR(EMPTY
,0,I1
,0,I4
,0);
3368 VARXOR(EMPTY
,0,I1
,1,I4
,1);
3369 VARXOR(EMPTY
,0,UI1
,0,I2
,0);
3370 VARXOR(EMPTY
,0,UI1
,1,I2
,1);
3371 VARXOR(EMPTY
,0,I2
,0,I2
,0);
3372 VARXOR(EMPTY
,0,I2
,1,I2
,1);
3373 VARXOR(EMPTY
,0,UI2
,0,I4
,0);
3374 VARXOR(EMPTY
,0,UI2
,1,I4
,1);
3375 VARXOR(EMPTY
,0,I4
,0,I4
,0);
3376 VARXOR(EMPTY
,0,I4
,1,I4
,1);
3377 VARXOR(EMPTY
,0,UI4
,0,I4
,0);
3378 VARXOR(EMPTY
,0,UI4
,1,I4
,1);
3379 if (HAVE_OLEAUT32_I8
)
3381 VARXOR(EMPTY
,0,I8
,0,I8
,0);
3382 VARXOR(EMPTY
,0,I8
,1,I8
,1);
3383 VARXOR(EMPTY
,0,UI8
,0,I4
,0);
3384 VARXOR(EMPTY
,0,UI8
,1,I4
,1);
3386 VARXOR(EMPTY
,0,INT
,0,I4
,0);
3387 VARXOR(EMPTY
,0,INT
,1,I4
,1);
3388 VARXOR(EMPTY
,0,UINT
,0,I4
,0);
3389 VARXOR(EMPTY
,0,UINT
,1,I4
,1);
3390 VARXOR(EMPTY
,0,BOOL
,0,I2
,0);
3391 VARXOR(EMPTY
,0,BOOL
,1,I2
,1);
3392 VARXOR(EMPTY
,0,R4
,0,I4
,0);
3393 VARXOR(EMPTY
,0,R4
,1,I4
,1);
3394 VARXOR(EMPTY
,0,R8
,0,I4
,0);
3395 VARXOR(EMPTY
,0,R8
,1,I4
,1);
3396 rbstr
= SysAllocString(szFalse
);
3397 VARXOR(EMPTY
,0,BSTR
,rbstr
,I2
,0);
3398 SysFreeString(rbstr
);
3399 rbstr
= SysAllocString(szTrue
);
3400 VARXOR(EMPTY
,0,BSTR
,rbstr
,I2
,-1);
3401 VARXORCY(EMPTY
,0,10000,I4
,1);
3402 SysFreeString(rbstr
);
3404 /* NULL OR 0 = NULL. NULL OR n = n */
3405 VARXOR(NULL
,0,NULL
,0,NULL
,0);
3406 VARXOR(NULL
,1,NULL
,0,NULL
,0);
3407 VARXOR(NULL
,0,I1
,0,NULL
,0);
3408 VARXOR(NULL
,0,I1
,1,NULL
,0);
3409 VARXOR(NULL
,0,UI1
,0,NULL
,0);
3410 VARXOR(NULL
,0,UI1
,1,NULL
,0);
3411 VARXOR(NULL
,0,I2
,0,NULL
,0);
3412 VARXOR(NULL
,0,I2
,1,NULL
,0);
3413 VARXOR(NULL
,0,UI2
,0,NULL
,0);
3414 VARXOR(NULL
,0,UI2
,1,NULL
,0);
3415 VARXOR(NULL
,0,I4
,0,NULL
,0);
3416 VARXOR(NULL
,0,I4
,1,NULL
,0);
3417 VARXOR(NULL
,0,UI4
,0,NULL
,0);
3418 VARXOR(NULL
,0,UI4
,1,NULL
,0);
3419 if (HAVE_OLEAUT32_I8
)
3421 VARXOR(NULL
,0,I8
,0,NULL
,0);
3422 VARXOR(NULL
,0,I8
,1,NULL
,0);
3423 VARXOR(NULL
,0,UI8
,0,NULL
,0);
3424 VARXOR(NULL
,0,UI8
,1,NULL
,0);
3426 VARXOR(NULL
,0,INT
,0,NULL
,0);
3427 VARXOR(NULL
,0,INT
,1,NULL
,0);
3428 VARXOR(NULL
,0,UINT
,0,NULL
,0);
3429 VARXOR(NULL
,0,UINT
,1,NULL
,0);
3430 VARXOR(NULL
,0,BOOL
,0,NULL
,0);
3431 VARXOR(NULL
,0,BOOL
,1,NULL
,0);
3432 VARXOR(NULL
,0,R4
,0,NULL
,0);
3433 VARXOR(NULL
,0,R4
,1,NULL
,0);
3434 VARXOR(NULL
,0,R8
,0,NULL
,0);
3435 VARXOR(NULL
,0,R8
,1,NULL
,0);
3436 rbstr
= SysAllocString(szFalse
);
3437 VARXOR(NULL
,0,BSTR
,rbstr
,NULL
,0);
3438 SysFreeString(rbstr
);
3439 rbstr
= SysAllocString(szTrue
);
3440 VARXOR(NULL
,0,BSTR
,rbstr
,NULL
,0);
3441 SysFreeString(rbstr
);
3442 VARXORCY(NULL
,0,10000,NULL
,0);
3443 VARXORCY(NULL
,0,0,NULL
,0);
3445 VARXOR(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
);
3446 VARXOR(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
);
3447 VARXOR(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
);
3448 VARXOR(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_FALSE
);
3449 /* Assume x,y & y,x are the same from now on to reduce the number of tests */
3450 VARXOR(BOOL
,VARIANT_TRUE
,I1
,-1,I4
,0);
3451 VARXOR(BOOL
,VARIANT_TRUE
,I1
,0,I4
,-1);
3452 VARXOR(BOOL
,VARIANT_FALSE
,I1
,0,I4
,0);
3453 VARXOR(BOOL
,VARIANT_TRUE
,UI1
,255,I2
,-256);
3454 VARXOR(BOOL
,VARIANT_TRUE
,UI1
,0,I2
,-1);
3455 VARXOR(BOOL
,VARIANT_FALSE
,UI1
,0,I2
,0);
3456 VARXOR(BOOL
,VARIANT_TRUE
,I2
,-1,I2
,0);
3457 VARXOR(BOOL
,VARIANT_TRUE
,I2
,0,I2
,-1);
3458 VARXOR(BOOL
,VARIANT_FALSE
,I2
,0,I2
,0);
3459 VARXOR(BOOL
,VARIANT_TRUE
,UI2
,65535,I4
,-65536);
3460 VARXOR(BOOL
,VARIANT_TRUE
,UI2
,0,I4
,-1);
3461 VARXOR(BOOL
,VARIANT_FALSE
,UI2
,0,I4
,0);
3462 VARXOR(BOOL
,VARIANT_TRUE
,I4
,-1,I4
,0);
3463 VARXOR(BOOL
,VARIANT_TRUE
,I4
,0,I4
,-1);
3464 VARXOR(BOOL
,VARIANT_FALSE
,I4
,0,I4
,0);
3465 VARXOR(BOOL
,VARIANT_TRUE
,UI4
,0xffffffff,I4
,0);
3466 VARXOR(BOOL
,VARIANT_TRUE
,UI4
,0,I4
,-1);
3467 VARXOR(BOOL
,VARIANT_FALSE
,UI4
,0,I4
,0);
3468 VARXOR(BOOL
,VARIANT_TRUE
,R4
,-1,I4
,0);
3469 VARXOR(BOOL
,VARIANT_TRUE
,R4
,0,I4
,-1);
3470 VARXOR(BOOL
,VARIANT_FALSE
,R4
,0,I4
,0);
3471 VARXOR(BOOL
,VARIANT_TRUE
,R8
,-1,I4
,0);
3472 VARXOR(BOOL
,VARIANT_TRUE
,R8
,0,I4
,-1);
3473 VARXOR(BOOL
,VARIANT_FALSE
,R8
,0,I4
,0);
3474 VARXOR(BOOL
,VARIANT_TRUE
,DATE
,-1,I4
,0);
3475 VARXOR(BOOL
,VARIANT_TRUE
,DATE
,0,I4
,-1);
3476 VARXOR(BOOL
,VARIANT_FALSE
,DATE
,0,I4
,0);
3477 if (HAVE_OLEAUT32_I8
)
3479 VARXOR(BOOL
,VARIANT_TRUE
,I8
,-1,I8
,0);
3480 VARXOR(BOOL
,VARIANT_TRUE
,I8
,0,I8
,-1);
3481 VARXOR(BOOL
,VARIANT_FALSE
,I8
,0,I8
,0);
3482 /* This returns DISP_E_OVERFLOW which indicates that a conversion
3483 * to I4 is performed.
3485 /* VARXOR(BOOL,VARIANT_TRUE,UI8,-1,I4,-1); */
3486 VARXOR(BOOL
,VARIANT_TRUE
,UI8
,0,I4
,-1);
3487 VARXOR(BOOL
,VARIANT_FALSE
,UI8
,0,I4
,0);
3489 VARXOR(BOOL
,VARIANT_TRUE
,INT
,-1,I4
,0);
3490 VARXOR(BOOL
,VARIANT_TRUE
,INT
,0,I4
,-1);
3491 VARXOR(BOOL
,VARIANT_FALSE
,INT
,0,I4
,0);
3492 VARXOR(BOOL
,VARIANT_TRUE
,UINT
,0xffffffff,I4
,0);
3493 VARXOR(BOOL
,VARIANT_TRUE
,UINT
,0,I4
,-1);
3494 VARXOR(BOOL
,VARIANT_FALSE
,UINT
,0,I4
,0);
3495 rbstr
= SysAllocString(szFalse
);
3496 VARXOR(BOOL
,VARIANT_FALSE
,BSTR
,rbstr
,BOOL
,VARIANT_FALSE
);
3497 VARXOR(BOOL
,VARIANT_TRUE
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
3498 SysFreeString(rbstr
);
3499 rbstr
= SysAllocString(szTrue
);
3500 VARXOR(BOOL
,VARIANT_FALSE
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
3501 VARXOR(BOOL
,VARIANT_TRUE
,BSTR
,rbstr
,BOOL
,VARIANT_FALSE
);
3502 SysFreeString(rbstr
);
3503 VARXORCY(BOOL
,VARIANT_TRUE
,10000,I4
,-2);
3504 VARXORCY(BOOL
,VARIANT_TRUE
,0,I4
,-1);
3505 VARXORCY(BOOL
,VARIANT_FALSE
,0,I4
,0);
3507 VARXOR(I1
,-1,I1
,-1,I4
,0);
3508 VARXOR(I1
,-1,I1
,0,I4
,-1);
3509 VARXOR(I1
,0,I1
,0,I4
,0);
3510 VARXOR(I1
,-1,UI1
,255,I4
,-256);
3511 VARXOR(I1
,-1,UI1
,0,I4
,-1);
3512 VARXOR(I1
,0,UI1
,0,I4
,0);
3513 VARXOR(I1
,-1,I2
,-1,I4
,0);
3514 VARXOR(I1
,-1,I2
,0,I4
,-1);
3515 VARXOR(I1
,0,I2
,0,I4
,0);
3516 VARXOR(I1
,-1,UI2
,65535,I4
,-65536);
3517 VARXOR(I1
,-1,UI2
,0,I4
,-1);
3518 VARXOR(I1
,0,UI2
,0,I4
,0);
3519 VARXOR(I1
,-1,I4
,-1,I4
,0);
3520 VARXOR(I1
,-1,I4
,0,I4
,-1);
3521 VARXOR(I1
,0,I4
,0,I4
,0);
3522 VARXOR(I1
,-1,UI4
,0xffffffff,I4
,0);
3523 VARXOR(I1
,-1,UI4
,0,I4
,-1);
3524 VARXOR(I1
,0,UI4
,0,I4
,0);
3525 VARXOR(I1
,-1,R4
,-1,I4
,0);
3526 VARXOR(I1
,-1,R4
,0,I4
,-1);
3527 VARXOR(I1
,0,R4
,0,I4
,0);
3528 VARXOR(I1
,-1,R8
,-1,I4
,0);
3529 VARXOR(I1
,-1,R8
,0,I4
,-1);
3530 VARXOR(I1
,0,R8
,0,I4
,0);
3531 VARXOR(I1
,-1,DATE
,-1,I4
,0);
3532 VARXOR(I1
,-1,DATE
,0,I4
,-1);
3533 VARXOR(I1
,0,DATE
,0,I4
,0);
3534 if (HAVE_OLEAUT32_I8
)
3536 VARXOR(I1
,-1,I8
,-1,I8
,0);
3537 VARXOR(I1
,-1,I8
,0,I8
,-1);
3538 VARXOR(I1
,0,I8
,0,I8
,0);
3539 VARXOR(I1
,-1,UI8
,0,I4
,-1);
3540 VARXOR(I1
,0,UI8
,0,I4
,0);
3542 VARXOR(I1
,-1,INT
,-1,I4
,0);
3543 VARXOR(I1
,-1,INT
,0,I4
,-1);
3544 VARXOR(I1
,0,INT
,0,I4
,0);
3545 VARXOR(I1
,-1,UINT
,0xffffffff,I4
,0);
3546 VARXOR(I1
,-1,UINT
,0,I4
,-1);
3547 VARXOR(I1
,0,UINT
,0,I4
,0);
3548 rbstr
= SysAllocString(szFalse
);
3549 VARXOR(I1
,0,BSTR
,rbstr
,I4
,0);
3550 VARXOR(I1
,-1,BSTR
,rbstr
,I4
,-1);
3551 SysFreeString(rbstr
);
3552 rbstr
= SysAllocString(szTrue
);
3553 VARXOR(I1
,0,BSTR
,rbstr
,I4
,-1);
3554 VARXOR(I1
,-1,BSTR
,rbstr
,I4
,0);
3555 SysFreeString(rbstr
);
3556 VARXORCY(I1
,-1,10000,I4
,-2);
3557 VARXORCY(I1
,-1,0,I4
,-1);
3558 VARXORCY(I1
,0,0,I4
,0);
3560 VARXOR(UI1
,255,UI1
,255,UI1
,0);
3561 VARXOR(UI1
,255,UI1
,0,UI1
,255);
3562 VARXOR(UI1
,0,UI1
,0,UI1
,0);
3563 VARXOR(UI1
,255,I2
,-1,I2
,-256);
3564 VARXOR(UI1
,255,I2
,0,I2
,255);
3565 VARXOR(UI1
,0,I2
,0,I2
,0);
3566 VARXOR(UI1
,255,UI2
,65535,I4
,65280);
3567 VARXOR(UI1
,255,UI2
,0,I4
,255);
3568 VARXOR(UI1
,0,UI2
,0,I4
,0);
3569 VARXOR(UI1
,255,I4
,-1,I4
,-256);
3570 VARXOR(UI1
,255,I4
,0,I4
,255);
3571 VARXOR(UI1
,0,I4
,0,I4
,0);
3572 VARXOR(UI1
,255,UI4
,0xffffffff,I4
,-256);
3573 VARXOR(UI1
,255,UI4
,0,I4
,255);
3574 VARXOR(UI1
,0,UI4
,0,I4
,0);
3575 VARXOR(UI1
,255,R4
,-1,I4
,-256);
3576 VARXOR(UI1
,255,R4
,0,I4
,255);
3577 VARXOR(UI1
,0,R4
,0,I4
,0);
3578 VARXOR(UI1
,255,R8
,-1,I4
,-256);
3579 VARXOR(UI1
,255,R8
,0,I4
,255);
3580 VARXOR(UI1
,0,R8
,0,I4
,0);
3581 VARXOR(UI1
,255,DATE
,-1,I4
,-256);
3582 VARXOR(UI1
,255,DATE
,0,I4
,255);
3583 VARXOR(UI1
,0,DATE
,0,I4
,0);
3584 if (HAVE_OLEAUT32_I8
)
3586 VARXOR(UI1
,255,I8
,-1,I8
,-256);
3587 VARXOR(UI1
,255,I8
,0,I8
,255);
3588 VARXOR(UI1
,0,I8
,0,I8
,0);
3589 VARXOR(UI1
,255,UI8
,0,I4
,255);
3590 VARXOR(UI1
,0,UI8
,0,I4
,0);
3592 VARXOR(UI1
,255,INT
,-1,I4
,-256);
3593 VARXOR(UI1
,255,INT
,0,I4
,255);
3594 VARXOR(UI1
,0,INT
,0,I4
,0);
3595 VARXOR(UI1
,255,UINT
,0xffffffff,I4
,-256);
3596 VARXOR(UI1
,255,UINT
,0,I4
,255);
3597 VARXOR(UI1
,0,UINT
,0,I4
,0);
3598 rbstr
= SysAllocString(szFalse
);
3599 VARXOR(UI1
,0,BSTR
,rbstr
,I2
,0);
3600 VARXOR(UI1
,255,BSTR
,rbstr
,I2
,255);
3601 SysFreeString(rbstr
);
3602 rbstr
= SysAllocString(szTrue
);
3603 VARXOR(UI1
,0,BSTR
,rbstr
,I2
,-1);
3604 VARXOR(UI1
,255,BSTR
,rbstr
,I2
,-256);
3605 SysFreeString(rbstr
);
3606 VARXORCY(UI1
,255,10000,I4
,254);
3607 VARXORCY(UI1
,255,0,I4
,255);
3608 VARXORCY(UI1
,0,0,I4
,0);
3610 VARXOR(I2
,-1,I2
,-1,I2
,0);
3611 VARXOR(I2
,-1,I2
,0,I2
,-1);
3612 VARXOR(I2
,0,I2
,0,I2
,0);
3613 VARXOR(I2
,-1,UI2
,65535,I4
,-65536);
3614 VARXOR(I2
,-1,UI2
,0,I4
,-1);
3615 VARXOR(I2
,0,UI2
,0,I4
,0);
3616 VARXOR(I2
,-1,I4
,-1,I4
,0);
3617 VARXOR(I2
,-1,I4
,0,I4
,-1);
3618 VARXOR(I2
,0,I4
,0,I4
,0);
3619 VARXOR(I2
,-1,UI4
,0xffffffff,I4
,0);
3620 VARXOR(I2
,-1,UI4
,0,I4
,-1);
3621 VARXOR(I2
,0,UI4
,0,I4
,0);
3622 VARXOR(I2
,-1,R4
,-1,I4
,0);
3623 VARXOR(I2
,-1,R4
,0,I4
,-1);
3624 VARXOR(I2
,0,R4
,0,I4
,0);
3625 VARXOR(I2
,-1,R8
,-1,I4
,0);
3626 VARXOR(I2
,-1,R8
,0,I4
,-1);
3627 VARXOR(I2
,0,R8
,0,I4
,0);
3628 VARXOR(I2
,-1,DATE
,-1,I4
,0);
3629 VARXOR(I2
,-1,DATE
,0,I4
,-1);
3630 VARXOR(I2
,0,DATE
,0,I4
,0);
3631 if (HAVE_OLEAUT32_I8
)
3633 VARXOR(I2
,-1,I8
,-1,I8
,0);
3634 VARXOR(I2
,-1,I8
,0,I8
,-1);
3635 VARXOR(I2
,0,I8
,0,I8
,0);
3636 VARXOR(I2
,-1,UI8
,0,I4
,-1);
3637 VARXOR(I2
,0,UI8
,0,I4
,0);
3639 VARXOR(I2
,-1,INT
,-1,I4
,0);
3640 VARXOR(I2
,-1,INT
,0,I4
,-1);
3641 VARXOR(I2
,0,INT
,0,I4
,0);
3642 VARXOR(I2
,-1,UINT
,0xffffffff,I4
,0);
3643 VARXOR(I2
,-1,UINT
,0,I4
,-1);
3644 VARXOR(I2
,0,UINT
,0,I4
,0);
3645 rbstr
= SysAllocString(szFalse
);
3646 VARXOR(I2
,0,BSTR
,rbstr
,I2
,0);
3647 VARXOR(I2
,-1,BSTR
,rbstr
,I2
,-1);
3648 SysFreeString(rbstr
);
3649 rbstr
= SysAllocString(szTrue
);
3650 VARXOR(I2
,0,BSTR
,rbstr
,I2
,-1);
3651 VARXOR(I2
,-1,BSTR
,rbstr
,I2
,0);
3652 SysFreeString(rbstr
);
3653 VARXORCY(I2
,-1,10000,I4
,-2);
3654 VARXORCY(I2
,-1,0,I4
,-1);
3655 VARXORCY(I2
,0,0,I4
,0);
3657 VARXOR(UI2
,65535,UI2
,65535,I4
,0);
3658 VARXOR(UI2
,65535,UI2
,0,I4
,65535);
3659 VARXOR(UI2
,0,UI2
,0,I4
,0);
3660 VARXOR(UI2
,65535,I4
,-1,I4
,-65536);
3661 VARXOR(UI2
,65535,I4
,0,I4
,65535);
3662 VARXOR(UI2
,0,I4
,0,I4
,0);
3663 VARXOR(UI2
,65535,UI4
,0xffffffff,I4
,-65536);
3664 VARXOR(UI2
,65535,UI4
,0,I4
,65535);
3665 VARXOR(UI2
,0,UI4
,0,I4
,0);
3666 VARXOR(UI2
,65535,R4
,-1,I4
,-65536);
3667 VARXOR(UI2
,65535,R4
,0,I4
,65535);
3668 VARXOR(UI2
,0,R4
,0,I4
,0);
3669 VARXOR(UI2
,65535,R8
,-1,I4
,-65536);
3670 VARXOR(UI2
,65535,R8
,0,I4
,65535);
3671 VARXOR(UI2
,0,R8
,0,I4
,0);
3672 VARXOR(UI2
,65535,DATE
,-1,I4
,-65536);
3673 VARXOR(UI2
,65535,DATE
,0,I4
,65535);
3674 VARXOR(UI2
,0,DATE
,0,I4
,0);
3675 if (HAVE_OLEAUT32_I8
)
3677 VARXOR(UI2
,65535,I8
,-1,I8
,-65536);
3678 VARXOR(UI2
,65535,I8
,0,I8
,65535);
3679 VARXOR(UI2
,0,I8
,0,I8
,0);
3680 VARXOR(UI2
,65535,UI8
,0,I4
,65535);
3681 VARXOR(UI2
,0,UI8
,0,I4
,0);
3683 VARXOR(UI2
,65535,INT
,-1,I4
,-65536);
3684 VARXOR(UI2
,65535,INT
,0,I4
,65535);
3685 VARXOR(UI2
,0,INT
,0,I4
,0);
3686 VARXOR(UI2
,65535,UINT
,0xffffffff,I4
,-65536);
3687 VARXOR(UI2
,65535,UINT
,0,I4
,65535);
3688 VARXOR(UI2
,0,UINT
,0,I4
,0);
3689 rbstr
= SysAllocString(szFalse
);
3690 VARXOR(UI2
,0,BSTR
,rbstr
,I4
,0);
3691 VARXOR(UI2
,65535,BSTR
,rbstr
,I4
,65535);
3692 SysFreeString(rbstr
);
3693 rbstr
= SysAllocString(szTrue
);
3694 VARXOR(UI2
,0,BSTR
,rbstr
,I4
,-1);
3695 VARXOR(UI2
,65535,BSTR
,rbstr
,I4
,-65536);
3696 SysFreeString(rbstr
);
3697 VARXORCY(UI2
,65535,10000,I4
,65534);
3698 VARXORCY(UI2
,65535,0,I4
,65535);
3699 VARXORCY(UI2
,0,0,I4
,0);
3701 VARXOR(I4
,-1,I4
,-1,I4
,0);
3702 VARXOR(I4
,-1,I4
,0,I4
,-1);
3703 VARXOR(I4
,0,I4
,0,I4
,0);
3704 VARXOR(I4
,-1,UI4
,0xffffffff,I4
,0);
3705 VARXOR(I4
,-1,UI4
,0,I4
,-1);
3706 VARXOR(I4
,0,UI4
,0,I4
,0);
3707 VARXOR(I4
,-1,R4
,-1,I4
,0);
3708 VARXOR(I4
,-1,R4
,0,I4
,-1);
3709 VARXOR(I4
,0,R4
,0,I4
,0);
3710 VARXOR(I4
,-1,R8
,-1,I4
,0);
3711 VARXOR(I4
,-1,R8
,0,I4
,-1);
3712 VARXOR(I4
,0,R8
,0,I4
,0);
3713 VARXOR(I4
,-1,DATE
,-1,I4
,0);
3714 VARXOR(I4
,-1,DATE
,0,I4
,-1);
3715 VARXOR(I4
,0,DATE
,0,I4
,0);
3716 if (HAVE_OLEAUT32_I8
)
3718 VARXOR(I4
,-1,I8
,-1,I8
,0);
3719 VARXOR(I4
,-1,I8
,0,I8
,-1);
3720 VARXOR(I4
,0,I8
,0,I8
,0);
3721 VARXOR(I4
,-1,UI8
,0,I4
,-1);
3722 VARXOR(I4
,0,UI8
,0,I4
,0);
3724 VARXOR(I4
,-1,INT
,-1,I4
,0);
3725 VARXOR(I4
,-1,INT
,0,I4
,-1);
3726 VARXOR(I4
,0,INT
,0,I4
,0);
3727 VARXOR(I4
,-1,UINT
,0xffffffff,I4
,0);
3728 VARXOR(I4
,-1,UINT
,0,I4
,-1);
3729 VARXOR(I4
,0,UINT
,0,I4
,0);
3730 rbstr
= SysAllocString(szFalse
);
3731 VARXOR(I4
,0,BSTR
,rbstr
,I4
,0);
3732 VARXOR(I4
,-1,BSTR
,rbstr
,I4
,-1);
3733 SysFreeString(rbstr
);
3734 rbstr
= SysAllocString(szTrue
);
3735 VARXOR(I4
,0,BSTR
,rbstr
,I4
,-1);
3736 VARXOR(I4
,-1,BSTR
,rbstr
,I4
,0);
3737 SysFreeString(rbstr
);
3738 VARXORCY(I4
,-1,10000,I4
,-2);
3739 VARXORCY(I4
,-1,0,I4
,-1);
3740 VARXORCY(I4
,0,0,I4
,0);
3742 VARXOR(UI4
,0xffffffff,UI4
,0xffffffff,I4
,0);
3743 VARXOR(UI4
,0xffffffff,UI4
,0,I4
,-1);
3744 VARXOR(UI4
,0,UI4
,0,I4
,0);
3745 VARXOR(UI4
,0xffffffff,R4
,-1,I4
,0);
3746 VARXOR(UI4
,0xffffffff,R4
,0,I4
,-1);
3747 VARXOR(UI4
,0,R4
,0,I4
,0);
3748 VARXOR(UI4
,0xffffffff,R8
,-1,I4
,0);
3749 VARXOR(UI4
,0xffffffff,R8
,0,I4
,-1);
3750 VARXOR(UI4
,0,R8
,0,I4
,0);
3751 VARXOR(UI4
,0xffffffff,DATE
,-1,I4
,0);
3752 VARXOR(UI4
,0xffffffff,DATE
,0,I4
,-1);
3753 VARXOR(UI4
,0,DATE
,0,I4
,0);
3754 if (HAVE_OLEAUT32_I8
)
3756 VARXOR(UI4
,0xffffffff,I8
,0,I8
,0xffffffff);
3757 VARXOR(UI4
,VARIANT_FALSE
,I8
,VARIANT_FALSE
,I8
,0);
3758 VARXOR(UI4
,0,I8
,0,I8
,0);
3759 VARXOR(UI4
,0xffffffff,UI8
,0,I4
,-1);
3760 VARXOR(UI4
,0,UI8
,0,I4
,0);
3762 VARXOR(UI4
,0xffffffff,INT
,-1,I4
,0);
3763 VARXOR(UI4
,0xffffffff,INT
,0,I4
,-1);
3764 VARXOR(UI4
,0,INT
,0,I4
,0);
3765 VARXOR(UI4
,0xffffffff,UINT
,0xffffffff,I4
,0);
3766 VARXOR(UI4
,0xffffffff,UINT
,0,I4
,-1);
3767 VARXOR(UI4
,0,UINT
,0,I4
,0);
3768 rbstr
= SysAllocString(szFalse
);
3769 VARXOR(UI4
,0,BSTR
,rbstr
,I4
,0);
3770 VARXOR(UI4
,0xffffffff,BSTR
,rbstr
,I4
,-1);
3771 SysFreeString(rbstr
);
3772 rbstr
= SysAllocString(szTrue
);
3773 VARXOR(UI4
,0,BSTR
,rbstr
,I4
,-1);
3774 VARXOR(UI4
,0xffffffff,BSTR
,rbstr
,I4
,0);
3775 SysFreeString(rbstr
);
3776 VARXORCY(UI4
,0xffffffff,10000,I4
,-2);
3777 VARXORCY(UI4
,0xffffffff,0,I4
,-1);
3778 VARXORCY(UI4
,0,0,I4
,0);
3780 VARXOR(R4
,-1,R4
,-1,I4
,0);
3781 VARXOR(R4
,-1,R4
,0,I4
,-1);
3782 VARXOR(R4
,0,R4
,0,I4
,0);
3783 VARXOR(R4
,-1,R8
,-1,I4
,0);
3784 VARXOR(R4
,-1,R8
,0,I4
,-1);
3785 VARXOR(R4
,0,R8
,0,I4
,0);
3786 VARXOR(R4
,-1,DATE
,-1,I4
,0);
3787 VARXOR(R4
,-1,DATE
,0,I4
,-1);
3788 VARXOR(R4
,0,DATE
,0,I4
,0);
3789 if (HAVE_OLEAUT32_I8
)
3791 VARXOR(R4
,-1,I8
,-1,I8
,0);
3792 VARXOR(R4
,-1,I8
,0,I8
,-1);
3793 VARXOR(R4
,0,I8
,0,I8
,0);
3794 VARXOR(R4
,-1,UI8
,0,I4
,-1);
3795 VARXOR(R4
,0,UI8
,0,I4
,0);
3797 VARXOR(R4
,-1,INT
,-1,I4
,0);
3798 VARXOR(R4
,-1,INT
,0,I4
,-1);
3799 VARXOR(R4
,0,INT
,0,I4
,0);
3800 VARXOR(R4
,-1,UINT
,0xffffffff,I4
,0);
3801 VARXOR(R4
,-1,UINT
,0,I4
,-1);
3802 VARXOR(R4
,0,UINT
,0,I4
,0);
3803 rbstr
= SysAllocString(szFalse
);
3804 VARXOR(R4
,0,BSTR
,rbstr
,I4
,0);
3805 VARXOR(R4
,-1,BSTR
,rbstr
,I4
,-1);
3806 SysFreeString(rbstr
);
3807 rbstr
= SysAllocString(szTrue
);
3808 VARXOR(R4
,0,BSTR
,rbstr
,I4
,-1);
3809 VARXOR(R4
,-1,BSTR
,rbstr
,I4
,0);
3810 SysFreeString(rbstr
);
3811 VARXORCY(R4
,-1,10000,I4
,-2);
3812 VARXORCY(R4
,-1,0,I4
,-1);
3813 VARXORCY(R4
,0,0,I4
,0);
3815 VARXOR(R8
,-1,R8
,-1,I4
,0);
3816 VARXOR(R8
,-1,R8
,0,I4
,-1);
3817 VARXOR(R8
,0,R8
,0,I4
,0);
3818 VARXOR(R8
,-1,DATE
,-1,I4
,0);
3819 VARXOR(R8
,-1,DATE
,0,I4
,-1);
3820 VARXOR(R8
,0,DATE
,0,I4
,0);
3821 if (HAVE_OLEAUT32_I8
)
3823 VARXOR(R8
,-1,I8
,-1,I8
,0);
3824 VARXOR(R8
,-1,I8
,0,I8
,-1);
3825 VARXOR(R8
,0,I8
,0,I8
,0);
3826 VARXOR(R8
,-1,UI8
,0,I4
,-1);
3827 VARXOR(R8
,0,UI8
,0,I4
,0);
3829 VARXOR(R8
,-1,INT
,-1,I4
,0);
3830 VARXOR(R8
,-1,INT
,0,I4
,-1);
3831 VARXOR(R8
,0,INT
,0,I4
,0);
3832 VARXOR(R8
,-1,UINT
,0xffffffff,I4
,0);
3833 VARXOR(R8
,-1,UINT
,0,I4
,-1);
3834 VARXOR(R8
,0,UINT
,0,I4
,0);
3835 rbstr
= SysAllocString(szFalse
);
3836 VARXOR(R8
,0,BSTR
,rbstr
,I4
,0);
3837 VARXOR(R8
,-1,BSTR
,rbstr
,I4
,-1);
3838 SysFreeString(rbstr
);
3839 rbstr
= SysAllocString(szTrue
);
3840 VARXOR(R8
,0,BSTR
,rbstr
,I4
,-1);
3841 VARXOR(R8
,-1,BSTR
,rbstr
,I4
,0);
3842 SysFreeString(rbstr
);
3843 VARXORCY(R8
,-1,10000,I4
,-2);
3844 VARXORCY(R8
,-1,0,I4
,-1);
3845 VARXORCY(R8
,0,0,I4
,0);
3847 VARXOR(DATE
,-1,DATE
,-1,I4
,0);
3848 VARXOR(DATE
,-1,DATE
,0,I4
,-1);
3849 VARXOR(DATE
,0,DATE
,0,I4
,0);
3850 if (HAVE_OLEAUT32_I8
)
3852 VARXOR(DATE
,-1,I8
,-1,I8
,0);
3853 VARXOR(DATE
,-1,I8
,0,I8
,-1);
3854 VARXOR(DATE
,0,I8
,0,I8
,0);
3855 VARXOR(DATE
,-1,UI8
,0,I4
,-1);
3856 VARXOR(DATE
,0,UI8
,0,I4
,0);
3858 VARXOR(DATE
,-1,INT
,-1,I4
,0);
3859 VARXOR(DATE
,-1,INT
,0,I4
,-1);
3860 VARXOR(DATE
,0,INT
,0,I4
,0);
3861 VARXOR(DATE
,-1,UINT
,0xffffffff,I4
,0);
3862 VARXOR(DATE
,-1,UINT
,0,I4
,-1);
3863 VARXOR(DATE
,0,UINT
,0,I4
,0);
3864 rbstr
= SysAllocString(szFalse
);
3865 VARXOR(DATE
,0,BSTR
,rbstr
,I4
,0);
3866 VARXOR(DATE
,-1,BSTR
,rbstr
,I4
,-1);
3867 SysFreeString(rbstr
);
3868 rbstr
= SysAllocString(szTrue
);
3869 VARXOR(DATE
,0,BSTR
,rbstr
,I4
,-1);
3870 VARXOR(DATE
,-1,BSTR
,rbstr
,I4
,0);
3871 SysFreeString(rbstr
);
3872 VARXORCY(DATE
,-1,10000,I4
,-2);
3873 VARXORCY(DATE
,-1,0,I4
,-1);
3874 VARXORCY(DATE
,0,0,I4
,0);
3876 if (HAVE_OLEAUT32_I8
)
3878 VARXOR(I8
,-1,I8
,-1,I8
,0);
3879 VARXOR(I8
,-1,I8
,0,I8
,-1);
3880 VARXOR(I8
,0,I8
,0,I8
,0);
3881 VARXOR(I8
,-1,UI8
,0,I8
,-1);
3882 VARXOR(I8
,0,UI8
,0,I8
,0);
3883 VARXOR(I8
,-1,UINT
,0,I8
,-1);
3884 VARXOR(I8
,0,UINT
,0,I8
,0);
3885 rbstr
= SysAllocString(szFalse
);
3886 VARXOR(I8
,0,BSTR
,rbstr
,I8
,0);
3887 VARXOR(I8
,-1,BSTR
,rbstr
,I8
,-1);
3888 SysFreeString(rbstr
);
3889 rbstr
= SysAllocString(szTrue
);
3890 VARXOR(I8
,0,BSTR
,rbstr
,I8
,-1);
3891 VARXOR(I8
,-1,BSTR
,rbstr
,I8
,0);
3892 SysFreeString(rbstr
);
3893 VARXORCY(I8
,-1,10000,I8
,-2);
3894 VARXORCY(I8
,-1,0,I8
,-1);
3895 VARXORCY(I8
,0,0,I8
,0);
3897 VARXOR(UI8
,0xffff,UI8
,0xffff,I4
,0);
3898 VARXOR(UI8
,0xffff,UI8
,0,I4
,0xffff);
3899 VARXOR(UI8
,0,UI8
,0,I4
,0);
3900 VARXOR(UI8
,0xffff,INT
,-1,I4
,-65536);
3901 VARXOR(UI8
,0xffff,INT
,0,I4
,0xffff);
3902 VARXOR(UI8
,0,INT
,0,I4
,0);
3903 VARXOR(UI8
,0xffff,UINT
,0xffff,I4
,0);
3904 VARXOR(UI8
,0xffff,UINT
,0,I4
,0xffff);
3905 VARXOR(UI8
,0,UINT
,0,I4
,0);
3906 rbstr
= SysAllocString(szFalse
);
3907 VARXOR(UI8
,0,BSTR
,rbstr
,I4
,0);
3908 VARXOR(UI8
,0xffff,BSTR
,rbstr
,I4
,0xffff);
3909 SysFreeString(rbstr
);
3910 rbstr
= SysAllocString(szTrue
);
3911 VARXOR(UI8
,0,BSTR
,rbstr
,I4
,-1);
3912 VARXOR(UI8
,0xffff,BSTR
,rbstr
,I4
,-65536);
3913 SysFreeString(rbstr
);
3914 VARXORCY(UI8
,0xffff,10000,I4
,65534);
3915 VARXORCY(UI8
,0xffff,0,I4
,0xffff);
3916 VARXORCY(UI8
,0,0,I4
,0);
3919 VARXOR(INT
,-1,INT
,-1,I4
,0);
3920 VARXOR(INT
,-1,INT
,0,I4
,-1);
3921 VARXOR(INT
,0,INT
,0,I4
,0);
3922 VARXOR(INT
,-1,UINT
,0xffff,I4
,-65536);
3923 VARXOR(INT
,-1,UINT
,0,I4
,-1);
3924 VARXOR(INT
,0,UINT
,0,I4
,0);
3925 rbstr
= SysAllocString(szFalse
);
3926 VARXOR(INT
,0,BSTR
,rbstr
,I4
,0);
3927 VARXOR(INT
,-1,BSTR
,rbstr
,I4
,-1);
3928 SysFreeString(rbstr
);
3929 rbstr
= SysAllocString(szTrue
);
3930 VARXOR(INT
,0,BSTR
,rbstr
,I4
,-1);
3931 VARXOR(INT
,-1,BSTR
,rbstr
,I4
,0);
3932 SysFreeString(rbstr
);
3933 VARXORCY(INT
,-1,10000,I4
,-2);
3934 VARXORCY(INT
,-1,0,I4
,-1);
3935 VARXORCY(INT
,0,0,I4
,0);
3937 VARXOR(UINT
,0xffff,UINT
,0xffff,I4
,0);
3938 VARXOR(UINT
,0xffff,UINT
,0,I4
,0xffff);
3939 VARXOR(UINT
,0,UINT
,0,I4
,0);
3940 rbstr
= SysAllocString(szFalse
);
3941 VARXOR(UINT
,0,BSTR
,rbstr
,I4
,0);
3942 VARXOR(UINT
,0xffff,BSTR
,rbstr
,I4
,0xffff);
3943 SysFreeString(rbstr
);
3944 rbstr
= SysAllocString(szTrue
);
3945 VARXOR(UINT
,0,BSTR
,rbstr
,I4
,-1);
3946 VARXOR(UINT
,0xffff,BSTR
,rbstr
,I4
,-65536);
3947 SysFreeString(rbstr
);
3948 VARXORCY(UINT
,0xffff,10000,I4
,65534);
3949 VARXORCY(UINT
,0xffff,0,I4
,0xffff);
3950 VARXORCY(UINT
,0,0,I4
,0);
3952 lbstr
= SysAllocString(szFalse
);
3953 rbstr
= SysAllocString(szFalse
);
3954 VARXOR(BSTR
,lbstr
,BSTR
,rbstr
,BOOL
,0);
3955 SysFreeString(rbstr
);
3956 rbstr
= SysAllocString(szTrue
);
3957 VARXOR(BSTR
,lbstr
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
3958 SysFreeString(lbstr
);
3959 lbstr
= SysAllocString(szTrue
);
3960 VARXOR(BSTR
,lbstr
,BSTR
,rbstr
,BOOL
,VARIANT_FALSE
);
3961 VARXORCY(BSTR
,lbstr
,10000,I4
,-2);
3962 SysFreeString(lbstr
);
3963 lbstr
= SysAllocString(szFalse
);
3964 VARXORCY(BSTR
,lbstr
,10000,I4
,1);
3965 SysFreeString(lbstr
);
3966 SysFreeString(rbstr
);
3969 static HRESULT (WINAPI
*pVarOr
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
3971 #define VAROR(vt1,val1,vt2,val2,rvt,rval) \
3972 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
3973 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
3974 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
3975 test_var_call2( __LINE__, pVarOr, &left, &right, &exp )
3977 #define VARORCY(vt1,val1,val2,rvt,rval) \
3978 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
3979 V_VT(&right) = VT_CY; V_CY(&right).int64 = val2; \
3980 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
3981 test_var_call2( __LINE__, pVarOr, &left, &right, &exp )
3983 static void test_VarOr(void)
3985 static const WCHAR szFalse
[] = { '#','F','A','L','S','E','#','\0' };
3986 static const WCHAR szTrue
[] = { '#','T','R','U','E','#','\0' };
3987 VARIANT left
, right
, exp
, result
;
3994 /* Test all possible flag/vt combinations & the resulting vt type */
3995 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
3997 VARTYPE leftvt
, rightvt
, resvt
;
3999 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
4004 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
4010 if (leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
||
4011 leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
||
4012 leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
)
4015 memset(&left
, 0, sizeof(left
));
4016 memset(&right
, 0, sizeof(right
));
4017 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
4018 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
4019 V_VT(&result
) = VT_EMPTY
;
4022 if (ExtraFlags
[i
] & VT_ARRAY
|| ExtraFlags
[i
] & VT_BYREF
||
4023 !IsValidVariantClearVT(leftvt
, ExtraFlags
[i
]) ||
4024 !IsValidVariantClearVT(rightvt
, ExtraFlags
[i
]) ||
4025 leftvt
== VT_CLSID
|| rightvt
== VT_CLSID
||
4026 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
||
4027 leftvt
== VT_VARIANT
|| rightvt
== VT_VARIANT
||
4028 leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
)
4032 if (leftvt
== VT_EMPTY
|| rightvt
== VT_EMPTY
)
4034 if (leftvt
== rightvt
||
4035 leftvt
== VT_I2
|| rightvt
== VT_I2
||
4036 leftvt
== VT_UI1
|| rightvt
== VT_UI1
||
4037 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
4039 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
4041 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
4044 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
4048 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
4050 if (leftvt
== rightvt
)
4052 else if (leftvt
== rightvt
||
4053 leftvt
== VT_I2
|| rightvt
== VT_I2
||
4054 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
4058 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
4061 else if (leftvt
== VT_I2
|| rightvt
== VT_I2
)
4063 if (leftvt
== rightvt
||
4064 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
4066 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
4069 else if (leftvt
== VT_BOOL
&& rightvt
== VT_BOOL
)
4073 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
4075 if (leftvt
== VT_INT
|| rightvt
== VT_INT
)
4080 hres
= pVarOr(&left
, &right
, &result
);
4082 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
4083 "VarOr: %d|0x%X, %d|0x%X: Expected failure, got 0x%X vt %d\n",
4084 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], hres
,
4087 ok(hres
== S_OK
&& V_VT(&result
) == resvt
,
4088 "VarOr: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%X vt %d\n",
4089 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], resvt
, hres
,
4095 /* Test returned values. Since we know the returned type is correct
4096 * and that we handle all combinations of invalid types, just check
4097 * that good type combinations produce the desired value.
4098 * FIXME: Test VT_DECIMAL/VT_DISPATCH
4100 VAROR(EMPTY
,0,EMPTY
,0,I2
,0);
4101 VAROR(EMPTY
,1,EMPTY
,0,I2
,0);
4102 VAROR(EMPTY
,0,NULL
,0,NULL
,0);
4103 VAROR(EMPTY
,0,I1
,0,I4
,0);
4104 VAROR(EMPTY
,0,I1
,1,I4
,1);
4105 VAROR(EMPTY
,0,UI1
,0,I2
,0);
4106 VAROR(EMPTY
,0,UI1
,1,I2
,1);
4107 VAROR(EMPTY
,0,I2
,0,I2
,0);
4108 VAROR(EMPTY
,0,I2
,1,I2
,1);
4109 VAROR(EMPTY
,0,UI2
,0,I4
,0);
4110 VAROR(EMPTY
,0,UI2
,1,I4
,1);
4111 VAROR(EMPTY
,0,I4
,0,I4
,0);
4112 VAROR(EMPTY
,0,I4
,1,I4
,1);
4113 VAROR(EMPTY
,0,UI4
,0,I4
,0);
4114 VAROR(EMPTY
,0,UI4
,1,I4
,1);
4115 if (HAVE_OLEAUT32_I8
)
4117 VAROR(EMPTY
,0,I8
,0,I8
,0);
4118 VAROR(EMPTY
,0,I8
,1,I8
,1);
4119 VAROR(EMPTY
,0,UI8
,0,I4
,0);
4120 VAROR(EMPTY
,0,UI8
,1,I4
,1);
4122 VAROR(EMPTY
,0,INT
,0,I4
,0);
4123 VAROR(EMPTY
,0,INT
,1,I4
,1);
4124 VAROR(EMPTY
,0,UINT
,0,I4
,0);
4125 VAROR(EMPTY
,0,UINT
,1,I4
,1);
4126 VAROR(EMPTY
,0,BOOL
,0,I2
,0);
4127 VAROR(EMPTY
,0,BOOL
,1,I2
,1);
4128 VAROR(EMPTY
,0,R4
,0,I4
,0);
4129 VAROR(EMPTY
,0,R4
,1,I4
,1);
4130 VAROR(EMPTY
,0,R8
,0,I4
,0);
4131 VAROR(EMPTY
,0,R8
,1,I4
,1);
4132 rbstr
= SysAllocString(szFalse
);
4133 VAROR(EMPTY
,0,BSTR
,rbstr
,I2
,0);
4134 SysFreeString(rbstr
);
4135 rbstr
= SysAllocString(szTrue
);
4136 VAROR(EMPTY
,0,BSTR
,rbstr
,I2
,-1);
4137 SysFreeString(rbstr
);
4138 VARORCY(EMPTY
,0,10000,I4
,1);
4140 /* NULL OR 0 = NULL. NULL OR n = n */
4141 VAROR(NULL
,0,NULL
,0,NULL
,0);
4142 VAROR(NULL
,1,NULL
,0,NULL
,0);
4143 VAROR(NULL
,0,I1
,0,NULL
,0);
4144 VAROR(NULL
,0,I1
,1,I4
,1);
4145 VAROR(NULL
,0,UI1
,0,NULL
,0);
4146 VAROR(NULL
,0,UI1
,1,UI1
,1);
4147 VAROR(NULL
,0,I2
,0,NULL
,0);
4148 VAROR(NULL
,0,I2
,1,I2
,1);
4149 VAROR(NULL
,0,UI2
,0,NULL
,0);
4150 VAROR(NULL
,0,UI2
,1,I4
,1);
4151 VAROR(NULL
,0,I4
,0,NULL
,0);
4152 VAROR(NULL
,0,I4
,1,I4
,1);
4153 VAROR(NULL
,0,UI4
,0,NULL
,0);
4154 VAROR(NULL
,0,UI4
,1,I4
,1);
4155 if (HAVE_OLEAUT32_I8
)
4157 VAROR(NULL
,0,I8
,0,NULL
,0);
4158 VAROR(NULL
,0,I8
,1,I8
,1);
4159 VAROR(NULL
,0,UI8
,0,NULL
,0);
4160 VAROR(NULL
,0,UI8
,1,I4
,1);
4162 VAROR(NULL
,0,INT
,0,NULL
,0);
4163 VAROR(NULL
,0,INT
,1,I4
,1);
4164 VAROR(NULL
,0,UINT
,0,NULL
,0);
4165 VAROR(NULL
,0,UINT
,1,I4
,1);
4166 VAROR(NULL
,0,BOOL
,0,NULL
,0);
4167 VAROR(NULL
,0,BOOL
,1,BOOL
,1);
4168 VAROR(NULL
,0,R4
,0,NULL
,0);
4169 VAROR(NULL
,0,R4
,1,I4
,1);
4170 VAROR(NULL
,0,R8
,0,NULL
,0);
4171 VAROR(NULL
,0,R8
,1,I4
,1);
4172 rbstr
= SysAllocString(szFalse
);
4173 VAROR(NULL
,0,BSTR
,rbstr
,NULL
,0);
4174 SysFreeString(rbstr
);
4175 rbstr
= SysAllocString(szTrue
);
4176 VAROR(NULL
,0,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
4177 SysFreeString(rbstr
);
4178 VARORCY(NULL
,0,10000,I4
,1);
4179 VARORCY(NULL
,0,0,NULL
,0);
4181 VAROR(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
);
4182 VAROR(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
);
4183 VAROR(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
);
4184 VAROR(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_FALSE
);
4185 /* Assume x,y & y,x are the same from now on to reduce the number of tests */
4186 VAROR(BOOL
,VARIANT_TRUE
,I1
,-1,I4
,-1);
4187 VAROR(BOOL
,VARIANT_TRUE
,I1
,0,I4
,-1);
4188 VAROR(BOOL
,VARIANT_FALSE
,I1
,0,I4
,0);
4189 VAROR(BOOL
,VARIANT_TRUE
,UI1
,255,I2
,-1);
4190 VAROR(BOOL
,VARIANT_TRUE
,UI1
,0,I2
,-1);
4191 VAROR(BOOL
,VARIANT_FALSE
,UI1
,0,I2
,0);
4192 VAROR(BOOL
,VARIANT_TRUE
,I2
,-1,I2
,-1);
4193 VAROR(BOOL
,VARIANT_TRUE
,I2
,0,I2
,-1);
4194 VAROR(BOOL
,VARIANT_FALSE
,I2
,0,I2
,0);
4195 VAROR(BOOL
,VARIANT_TRUE
,UI2
,65535,I4
,-1);
4196 VAROR(BOOL
,VARIANT_TRUE
,UI2
,0,I4
,-1);
4197 VAROR(BOOL
,VARIANT_FALSE
,UI2
,0,I4
,0);
4198 VAROR(BOOL
,VARIANT_TRUE
,I4
,-1,I4
,-1);
4199 VAROR(BOOL
,VARIANT_TRUE
,I4
,0,I4
,-1);
4200 VAROR(BOOL
,VARIANT_FALSE
,I4
,0,I4
,0);
4201 VAROR(BOOL
,VARIANT_TRUE
,UI4
,0xffffffff,I4
,-1);
4202 VAROR(BOOL
,VARIANT_TRUE
,UI4
,0,I4
,-1);
4203 VAROR(BOOL
,VARIANT_FALSE
,UI4
,0,I4
,0);
4204 VAROR(BOOL
,VARIANT_TRUE
,R4
,-1,I4
,-1);
4205 VAROR(BOOL
,VARIANT_TRUE
,R4
,0,I4
,-1);
4206 VAROR(BOOL
,VARIANT_FALSE
,R4
,0,I4
,0);
4207 VAROR(BOOL
,VARIANT_TRUE
,R8
,-1,I4
,-1);
4208 VAROR(BOOL
,VARIANT_TRUE
,R8
,0,I4
,-1);
4209 VAROR(BOOL
,VARIANT_FALSE
,R8
,0,I4
,0);
4210 VAROR(BOOL
,VARIANT_TRUE
,DATE
,-1,I4
,-1);
4211 VAROR(BOOL
,VARIANT_TRUE
,DATE
,0,I4
,-1);
4212 VAROR(BOOL
,VARIANT_FALSE
,DATE
,0,I4
,0);
4213 if (HAVE_OLEAUT32_I8
)
4215 VAROR(BOOL
,VARIANT_TRUE
,I8
,-1,I8
,-1);
4216 VAROR(BOOL
,VARIANT_TRUE
,I8
,0,I8
,-1);
4217 VAROR(BOOL
,VARIANT_FALSE
,I8
,0,I8
,0);
4218 /* This returns DISP_E_OVERFLOW which indicates that a conversion
4219 * to I4 is performed.
4221 /* VAROR(BOOL,VARIANT_TRUE,UI8,-1,I4,-1); */
4222 VAROR(BOOL
,VARIANT_TRUE
,UI8
,0,I4
,-1);
4223 VAROR(BOOL
,VARIANT_FALSE
,UI8
,0,I4
,0);
4225 VAROR(BOOL
,VARIANT_TRUE
,INT
,-1,I4
,-1);
4226 VAROR(BOOL
,VARIANT_TRUE
,INT
,0,I4
,-1);
4227 VAROR(BOOL
,VARIANT_FALSE
,INT
,0,I4
,0);
4228 VAROR(BOOL
,VARIANT_TRUE
,UINT
,0xffffffff,I4
,-1);
4229 VAROR(BOOL
,VARIANT_TRUE
,UINT
,0,I4
,-1);
4230 VAROR(BOOL
,VARIANT_FALSE
,UINT
,0,I4
,0);
4231 rbstr
= SysAllocString(szFalse
);
4232 VAROR(BOOL
,VARIANT_FALSE
,BSTR
,rbstr
,BOOL
,VARIANT_FALSE
);
4233 VAROR(BOOL
,VARIANT_TRUE
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
4234 SysFreeString(rbstr
);
4235 rbstr
= SysAllocString(szTrue
);
4236 VAROR(BOOL
,VARIANT_FALSE
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
4237 VAROR(BOOL
,VARIANT_TRUE
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
4238 SysFreeString(rbstr
);
4239 VARORCY(BOOL
,VARIANT_TRUE
,10000,I4
,-1);
4240 VARORCY(BOOL
,VARIANT_TRUE
,0,I4
,-1);
4241 VARORCY(BOOL
,VARIANT_FALSE
,0,I4
,0);
4243 VAROR(I1
,-1,I1
,-1,I4
,-1);
4244 VAROR(I1
,-1,I1
,0,I4
,-1);
4245 VAROR(I1
,0,I1
,0,I4
,0);
4246 VAROR(I1
,-1,UI1
,255,I4
,-1);
4247 VAROR(I1
,-1,UI1
,0,I4
,-1);
4248 VAROR(I1
,0,UI1
,0,I4
,0);
4249 VAROR(I1
,-1,I2
,-1,I4
,-1);
4250 VAROR(I1
,-1,I2
,0,I4
,-1);
4251 VAROR(I1
,0,I2
,0,I4
,0);
4252 VAROR(I1
,-1,UI2
,65535,I4
,-1);
4253 VAROR(I1
,-1,UI2
,0,I4
,-1);
4254 VAROR(I1
,0,UI2
,0,I4
,0);
4255 VAROR(I1
,-1,I4
,-1,I4
,-1);
4256 VAROR(I1
,-1,I4
,0,I4
,-1);
4257 VAROR(I1
,0,I4
,0,I4
,0);
4258 VAROR(I1
,-1,UI4
,0xffffffff,I4
,-1);
4259 VAROR(I1
,-1,UI4
,0,I4
,-1);
4260 VAROR(I1
,0,UI4
,0,I4
,0);
4261 VAROR(I1
,-1,R4
,-1,I4
,-1);
4262 VAROR(I1
,-1,R4
,0,I4
,-1);
4263 VAROR(I1
,0,R4
,0,I4
,0);
4264 VAROR(I1
,-1,R8
,-1,I4
,-1);
4265 VAROR(I1
,-1,R8
,0,I4
,-1);
4266 VAROR(I1
,0,R8
,0,I4
,0);
4267 VAROR(I1
,-1,DATE
,-1,I4
,-1);
4268 VAROR(I1
,-1,DATE
,0,I4
,-1);
4269 VAROR(I1
,0,DATE
,0,I4
,0);
4270 if (HAVE_OLEAUT32_I8
)
4272 VAROR(I1
,-1,I8
,-1,I8
,-1);
4273 VAROR(I1
,-1,I8
,0,I8
,-1);
4274 VAROR(I1
,0,I8
,0,I8
,0);
4275 VAROR(I1
,-1,UI8
,0,I4
,-1);
4276 VAROR(I1
,0,UI8
,0,I4
,0);
4278 VAROR(I1
,-1,INT
,-1,I4
,-1);
4279 VAROR(I1
,-1,INT
,0,I4
,-1);
4280 VAROR(I1
,0,INT
,0,I4
,0);
4281 VAROR(I1
,-1,UINT
,0xffffffff,I4
,-1);
4282 VAROR(I1
,-1,UINT
,0,I4
,-1);
4283 VAROR(I1
,0,UINT
,0,I4
,0);
4284 rbstr
= SysAllocString(szFalse
);
4285 VAROR(I1
,0,BSTR
,rbstr
,I4
,0);
4286 VAROR(I1
,-1,BSTR
,rbstr
,I4
,-1);
4287 SysFreeString(rbstr
);
4288 rbstr
= SysAllocString(szTrue
);
4289 VAROR(I1
,0,BSTR
,rbstr
,I4
,-1);
4290 VAROR(I1
,-1,BSTR
,rbstr
,I4
,-1);
4291 SysFreeString(rbstr
);
4292 VARORCY(I1
,-1,10000,I4
,-1);
4293 VARORCY(I1
,-1,0,I4
,-1);
4294 VARORCY(I1
,0,0,I4
,0);
4296 VAROR(UI1
,255,UI1
,255,UI1
,255);
4297 VAROR(UI1
,255,UI1
,0,UI1
,255);
4298 VAROR(UI1
,0,UI1
,0,UI1
,0);
4299 VAROR(UI1
,255,I2
,-1,I2
,-1);
4300 VAROR(UI1
,255,I2
,0,I2
,255);
4301 VAROR(UI1
,0,I2
,0,I2
,0);
4302 VAROR(UI1
,255,UI2
,65535,I4
,65535);
4303 VAROR(UI1
,255,UI2
,0,I4
,255);
4304 VAROR(UI1
,0,UI2
,0,I4
,0);
4305 VAROR(UI1
,255,I4
,-1,I4
,-1);
4306 VAROR(UI1
,255,I4
,0,I4
,255);
4307 VAROR(UI1
,0,I4
,0,I4
,0);
4308 VAROR(UI1
,255,UI4
,0xffffffff,I4
,-1);
4309 VAROR(UI1
,255,UI4
,0,I4
,255);
4310 VAROR(UI1
,0,UI4
,0,I4
,0);
4311 VAROR(UI1
,255,R4
,-1,I4
,-1);
4312 VAROR(UI1
,255,R4
,0,I4
,255);
4313 VAROR(UI1
,0,R4
,0,I4
,0);
4314 VAROR(UI1
,255,R8
,-1,I4
,-1);
4315 VAROR(UI1
,255,R8
,0,I4
,255);
4316 VAROR(UI1
,0,R8
,0,I4
,0);
4317 VAROR(UI1
,255,DATE
,-1,I4
,-1);
4318 VAROR(UI1
,255,DATE
,0,I4
,255);
4319 VAROR(UI1
,0,DATE
,0,I4
,0);
4320 if (HAVE_OLEAUT32_I8
)
4322 VAROR(UI1
,255,I8
,-1,I8
,-1);
4323 VAROR(UI1
,255,I8
,0,I8
,255);
4324 VAROR(UI1
,0,I8
,0,I8
,0);
4325 VAROR(UI1
,255,UI8
,0,I4
,255);
4326 VAROR(UI1
,0,UI8
,0,I4
,0);
4328 VAROR(UI1
,255,INT
,-1,I4
,-1);
4329 VAROR(UI1
,255,INT
,0,I4
,255);
4330 VAROR(UI1
,0,INT
,0,I4
,0);
4331 VAROR(UI1
,255,UINT
,0xffffffff,I4
,-1);
4332 VAROR(UI1
,255,UINT
,0,I4
,255);
4333 VAROR(UI1
,0,UINT
,0,I4
,0);
4334 rbstr
= SysAllocString(szFalse
);
4335 VAROR(UI1
,0,BSTR
,rbstr
,I2
,0);
4336 VAROR(UI1
,255,BSTR
,rbstr
,I2
,255);
4337 SysFreeString(rbstr
);
4338 rbstr
= SysAllocString(szTrue
);
4339 VAROR(UI1
,0,BSTR
,rbstr
,I2
,-1);
4340 VAROR(UI1
,255,BSTR
,rbstr
,I2
,-1);
4341 SysFreeString(rbstr
);
4342 VARORCY(UI1
,255,10000,I4
,255);
4343 VARORCY(UI1
,255,0,I4
,255);
4344 VARORCY(UI1
,0,0,I4
,0);
4346 VAROR(I2
,-1,I2
,-1,I2
,-1);
4347 VAROR(I2
,-1,I2
,0,I2
,-1);
4348 VAROR(I2
,0,I2
,0,I2
,0);
4349 VAROR(I2
,-1,UI2
,65535,I4
,-1);
4350 VAROR(I2
,-1,UI2
,0,I4
,-1);
4351 VAROR(I2
,0,UI2
,0,I4
,0);
4352 VAROR(I2
,-1,I4
,-1,I4
,-1);
4353 VAROR(I2
,-1,I4
,0,I4
,-1);
4354 VAROR(I2
,0,I4
,0,I4
,0);
4355 VAROR(I2
,-1,UI4
,0xffffffff,I4
,-1);
4356 VAROR(I2
,-1,UI4
,0,I4
,-1);
4357 VAROR(I2
,0,UI4
,0,I4
,0);
4358 VAROR(I2
,-1,R4
,-1,I4
,-1);
4359 VAROR(I2
,-1,R4
,0,I4
,-1);
4360 VAROR(I2
,0,R4
,0,I4
,0);
4361 VAROR(I2
,-1,R8
,-1,I4
,-1);
4362 VAROR(I2
,-1,R8
,0,I4
,-1);
4363 VAROR(I2
,0,R8
,0,I4
,0);
4364 VAROR(I2
,-1,DATE
,-1,I4
,-1);
4365 VAROR(I2
,-1,DATE
,0,I4
,-1);
4366 VAROR(I2
,0,DATE
,0,I4
,0);
4367 if (HAVE_OLEAUT32_I8
)
4369 VAROR(I2
,-1,I8
,-1,I8
,-1);
4370 VAROR(I2
,-1,I8
,0,I8
,-1);
4371 VAROR(I2
,0,I8
,0,I8
,0);
4372 VAROR(I2
,-1,UI8
,0,I4
,-1);
4373 VAROR(I2
,0,UI8
,0,I4
,0);
4375 VAROR(I2
,-1,INT
,-1,I4
,-1);
4376 VAROR(I2
,-1,INT
,0,I4
,-1);
4377 VAROR(I2
,0,INT
,0,I4
,0);
4378 VAROR(I2
,-1,UINT
,0xffffffff,I4
,-1);
4379 VAROR(I2
,-1,UINT
,0,I4
,-1);
4380 VAROR(I2
,0,UINT
,0,I4
,0);
4381 rbstr
= SysAllocString(szFalse
);
4382 VAROR(I2
,0,BSTR
,rbstr
,I2
,0);
4383 VAROR(I2
,-1,BSTR
,rbstr
,I2
,-1);
4384 SysFreeString(rbstr
);
4385 rbstr
= SysAllocString(szTrue
);
4386 VAROR(I2
,0,BSTR
,rbstr
,I2
,-1);
4387 VAROR(I2
,-1,BSTR
,rbstr
,I2
,-1);
4388 SysFreeString(rbstr
);
4389 VARORCY(I2
,-1,10000,I4
,-1);
4390 VARORCY(I2
,-1,0,I4
,-1);
4391 VARORCY(I2
,0,0,I4
,0);
4393 VAROR(UI2
,65535,UI2
,65535,I4
,65535);
4394 VAROR(UI2
,65535,UI2
,0,I4
,65535);
4395 VAROR(UI2
,0,UI2
,0,I4
,0);
4396 VAROR(UI2
,65535,I4
,-1,I4
,-1);
4397 VAROR(UI2
,65535,I4
,0,I4
,65535);
4398 VAROR(UI2
,0,I4
,0,I4
,0);
4399 VAROR(UI2
,65535,UI4
,0xffffffff,I4
,-1);
4400 VAROR(UI2
,65535,UI4
,0,I4
,65535);
4401 VAROR(UI2
,0,UI4
,0,I4
,0);
4402 VAROR(UI2
,65535,R4
,-1,I4
,-1);
4403 VAROR(UI2
,65535,R4
,0,I4
,65535);
4404 VAROR(UI2
,0,R4
,0,I4
,0);
4405 VAROR(UI2
,65535,R8
,-1,I4
,-1);
4406 VAROR(UI2
,65535,R8
,0,I4
,65535);
4407 VAROR(UI2
,0,R8
,0,I4
,0);
4408 VAROR(UI2
,65535,DATE
,-1,I4
,-1);
4409 VAROR(UI2
,65535,DATE
,0,I4
,65535);
4410 VAROR(UI2
,0,DATE
,0,I4
,0);
4411 if (HAVE_OLEAUT32_I8
)
4413 VAROR(UI2
,65535,I8
,-1,I8
,-1);
4414 VAROR(UI2
,65535,I8
,0,I8
,65535);
4415 VAROR(UI2
,0,I8
,0,I8
,0);
4416 VAROR(UI2
,65535,UI8
,0,I4
,65535);
4417 VAROR(UI2
,0,UI8
,0,I4
,0);
4419 VAROR(UI2
,65535,INT
,-1,I4
,-1);
4420 VAROR(UI2
,65535,INT
,0,I4
,65535);
4421 VAROR(UI2
,0,INT
,0,I4
,0);
4422 VAROR(UI2
,65535,UINT
,0xffffffff,I4
,-1);
4423 VAROR(UI2
,65535,UINT
,0,I4
,65535);
4424 VAROR(UI2
,0,UINT
,0,I4
,0);
4425 rbstr
= SysAllocString(szFalse
);
4426 VAROR(UI2
,0,BSTR
,rbstr
,I4
,0);
4427 VAROR(UI2
,65535,BSTR
,rbstr
,I4
,65535);
4428 SysFreeString(rbstr
);
4429 rbstr
= SysAllocString(szTrue
);
4430 VAROR(UI2
,0,BSTR
,rbstr
,I4
,-1);
4431 VAROR(UI2
,65535,BSTR
,rbstr
,I4
,-1);
4432 SysFreeString(rbstr
);
4433 VARORCY(UI2
,65535,10000,I4
,65535);
4434 VARORCY(UI2
,65535,0,I4
,65535);
4435 VARORCY(UI2
,0,0,I4
,0);
4437 VAROR(I4
,-1,I4
,-1,I4
,-1);
4438 VAROR(I4
,-1,I4
,0,I4
,-1);
4439 VAROR(I4
,0,I4
,0,I4
,0);
4440 VAROR(I4
,-1,UI4
,0xffffffff,I4
,-1);
4441 VAROR(I4
,-1,UI4
,0,I4
,-1);
4442 VAROR(I4
,0,UI4
,0,I4
,0);
4443 VAROR(I4
,-1,R4
,-1,I4
,-1);
4444 VAROR(I4
,-1,R4
,0,I4
,-1);
4445 VAROR(I4
,0,R4
,0,I4
,0);
4446 VAROR(I4
,-1,R8
,-1,I4
,-1);
4447 VAROR(I4
,-1,R8
,0,I4
,-1);
4448 VAROR(I4
,0,R8
,0,I4
,0);
4449 VAROR(I4
,-1,DATE
,-1,I4
,-1);
4450 VAROR(I4
,-1,DATE
,0,I4
,-1);
4451 VAROR(I4
,0,DATE
,0,I4
,0);
4452 if (HAVE_OLEAUT32_I8
)
4454 VAROR(I4
,-1,I8
,-1,I8
,-1);
4455 VAROR(I4
,-1,I8
,0,I8
,-1);
4456 VAROR(I4
,0,I8
,0,I8
,0);
4457 VAROR(I4
,-1,UI8
,0,I4
,-1);
4458 VAROR(I4
,0,UI8
,0,I4
,0);
4460 VAROR(I4
,-1,INT
,-1,I4
,-1);
4461 VAROR(I4
,-1,INT
,0,I4
,-1);
4462 VAROR(I4
,0,INT
,0,I4
,0);
4463 VAROR(I4
,-1,UINT
,0xffffffff,I4
,-1);
4464 VAROR(I4
,-1,UINT
,0,I4
,-1);
4465 VAROR(I4
,0,UINT
,0,I4
,0);
4466 rbstr
= SysAllocString(szFalse
);
4467 VAROR(I4
,0,BSTR
,rbstr
,I4
,0);
4468 VAROR(I4
,-1,BSTR
,rbstr
,I4
,-1);
4469 SysFreeString(rbstr
);
4470 rbstr
= SysAllocString(szTrue
);
4471 VAROR(I4
,0,BSTR
,rbstr
,I4
,-1);
4472 VAROR(I4
,-1,BSTR
,rbstr
,I4
,-1);
4473 SysFreeString(rbstr
);
4474 VARORCY(I4
,-1,10000,I4
,-1);
4475 VARORCY(I4
,-1,0,I4
,-1);
4476 VARORCY(I4
,0,0,I4
,0);
4478 VAROR(UI4
,0xffffffff,UI4
,0xffffffff,I4
,-1);
4479 VAROR(UI4
,0xffffffff,UI4
,0,I4
,-1);
4480 VAROR(UI4
,0,UI4
,0,I4
,0);
4481 VAROR(UI4
,0xffffffff,R4
,-1,I4
,-1);
4482 VAROR(UI4
,0xffffffff,R4
,0,I4
,-1);
4483 VAROR(UI4
,0,R4
,0,I4
,0);
4484 VAROR(UI4
,0xffffffff,R8
,-1,I4
,-1);
4485 VAROR(UI4
,0xffffffff,R8
,0,I4
,-1);
4486 VAROR(UI4
,0,R8
,0,I4
,0);
4487 VAROR(UI4
,0xffffffff,DATE
,-1,I4
,-1);
4488 VAROR(UI4
,0xffffffff,DATE
,0,I4
,-1);
4489 VAROR(UI4
,0,DATE
,0,I4
,0);
4490 if (HAVE_OLEAUT32_I8
)
4492 VAROR(UI4
,0xffffffff,I8
,-1,I8
,-1);
4493 VAROR(UI4
,0xffffffff,I8
,0,I8
,0xffffffff);
4494 VAROR(UI4
,0,I8
,0,I8
,0);
4495 VAROR(UI4
,0xffffffff,UI8
,0,I4
,-1);
4496 VAROR(UI4
,0,UI8
,0,I4
,0);
4498 VAROR(UI4
,0xffffffff,INT
,-1,I4
,-1);
4499 VAROR(UI4
,0xffffffff,INT
,0,I4
,-1);
4500 VAROR(UI4
,0,INT
,0,I4
,0);
4501 VAROR(UI4
,0xffffffff,UINT
,0xffffffff,I4
,-1);
4502 VAROR(UI4
,0xffffffff,UINT
,0,I4
,-1);
4503 VAROR(UI4
,0,UINT
,0,I4
,0);
4504 rbstr
= SysAllocString(szFalse
);
4505 VAROR(UI4
,0,BSTR
,rbstr
,I4
,0);
4506 VAROR(UI4
,0xffffffff,BSTR
,rbstr
,I4
,-1);
4507 SysFreeString(rbstr
);
4508 rbstr
= SysAllocString(szTrue
);
4509 VAROR(UI4
,0,BSTR
,rbstr
,I4
,-1);
4510 VAROR(UI4
,0xffffffff,BSTR
,rbstr
,I4
,-1);
4511 SysFreeString(rbstr
);
4512 VARORCY(UI4
,0xffffffff,10000,I4
,-1);
4513 VARORCY(UI4
,0xffffffff,0,I4
,-1);
4514 VARORCY(UI4
,0,0,I4
,0);
4516 VAROR(R4
,-1,R4
,-1,I4
,-1);
4517 VAROR(R4
,-1,R4
,0,I4
,-1);
4518 VAROR(R4
,0,R4
,0,I4
,0);
4519 VAROR(R4
,-1,R8
,-1,I4
,-1);
4520 VAROR(R4
,-1,R8
,0,I4
,-1);
4521 VAROR(R4
,0,R8
,0,I4
,0);
4522 VAROR(R4
,-1,DATE
,-1,I4
,-1);
4523 VAROR(R4
,-1,DATE
,0,I4
,-1);
4524 VAROR(R4
,0,DATE
,0,I4
,0);
4525 if (HAVE_OLEAUT32_I8
)
4527 VAROR(R4
,-1,I8
,-1,I8
,-1);
4528 VAROR(R4
,-1,I8
,0,I8
,-1);
4529 VAROR(R4
,0,I8
,0,I8
,0);
4530 VAROR(R4
,-1,UI8
,0,I4
,-1);
4531 VAROR(R4
,0,UI8
,0,I4
,0);
4533 VAROR(R4
,-1,INT
,-1,I4
,-1);
4534 VAROR(R4
,-1,INT
,0,I4
,-1);
4535 VAROR(R4
,0,INT
,0,I4
,0);
4536 VAROR(R4
,-1,UINT
,0xffffffff,I4
,-1);
4537 VAROR(R4
,-1,UINT
,0,I4
,-1);
4538 VAROR(R4
,0,UINT
,0,I4
,0);
4539 rbstr
= SysAllocString(szFalse
);
4540 VAROR(R4
,0,BSTR
,rbstr
,I4
,0);
4541 VAROR(R4
,-1,BSTR
,rbstr
,I4
,-1);
4542 SysFreeString(rbstr
);
4543 rbstr
= SysAllocString(szTrue
);
4544 VAROR(R4
,0,BSTR
,rbstr
,I4
,-1);
4545 VAROR(R4
,-1,BSTR
,rbstr
,I4
,-1);
4546 SysFreeString(rbstr
);
4547 VARORCY(R4
,-1,10000,I4
,-1);
4548 VARORCY(R4
,-1,0,I4
,-1);
4549 VARORCY(R4
,0,0,I4
,0);
4551 VAROR(R8
,-1,R8
,-1,I4
,-1);
4552 VAROR(R8
,-1,R8
,0,I4
,-1);
4553 VAROR(R8
,0,R8
,0,I4
,0);
4554 VAROR(R8
,-1,DATE
,-1,I4
,-1);
4555 VAROR(R8
,-1,DATE
,0,I4
,-1);
4556 VAROR(R8
,0,DATE
,0,I4
,0);
4557 if (HAVE_OLEAUT32_I8
)
4559 VAROR(R8
,-1,I8
,-1,I8
,-1);
4560 VAROR(R8
,-1,I8
,0,I8
,-1);
4561 VAROR(R8
,0,I8
,0,I8
,0);
4562 VAROR(R8
,-1,UI8
,0,I4
,-1);
4563 VAROR(R8
,0,UI8
,0,I4
,0);
4565 VAROR(R8
,-1,INT
,-1,I4
,-1);
4566 VAROR(R8
,-1,INT
,0,I4
,-1);
4567 VAROR(R8
,0,INT
,0,I4
,0);
4568 VAROR(R8
,-1,UINT
,0xffffffff,I4
,-1);
4569 VAROR(R8
,-1,UINT
,0,I4
,-1);
4570 VAROR(R8
,0,UINT
,0,I4
,0);
4571 rbstr
= SysAllocString(szFalse
);
4572 VAROR(R8
,0,BSTR
,rbstr
,I4
,0);
4573 VAROR(R8
,-1,BSTR
,rbstr
,I4
,-1);
4574 SysFreeString(rbstr
);
4575 rbstr
= SysAllocString(szTrue
);
4576 VAROR(R8
,0,BSTR
,rbstr
,I4
,-1);
4577 VAROR(R8
,-1,BSTR
,rbstr
,I4
,-1);
4578 SysFreeString(rbstr
);
4579 VARORCY(R8
,-1,10000,I4
,-1);
4580 VARORCY(R8
,-1,0,I4
,-1);
4581 VARORCY(R8
,0,0,I4
,0);
4583 VAROR(DATE
,-1,DATE
,-1,I4
,-1);
4584 VAROR(DATE
,-1,DATE
,0,I4
,-1);
4585 VAROR(DATE
,0,DATE
,0,I4
,0);
4586 if (HAVE_OLEAUT32_I8
)
4588 VAROR(DATE
,-1,I8
,-1,I8
,-1);
4589 VAROR(DATE
,-1,I8
,0,I8
,-1);
4590 VAROR(DATE
,0,I8
,0,I8
,0);
4591 VAROR(DATE
,-1,UI8
,0,I4
,-1);
4592 VAROR(DATE
,0,UI8
,0,I4
,0);
4594 VAROR(DATE
,-1,INT
,-1,I4
,-1);
4595 VAROR(DATE
,-1,INT
,0,I4
,-1);
4596 VAROR(DATE
,0,INT
,0,I4
,0);
4597 VAROR(DATE
,-1,UINT
,0xffffffff,I4
,-1);
4598 VAROR(DATE
,-1,UINT
,0,I4
,-1);
4599 VAROR(DATE
,0,UINT
,0,I4
,0);
4600 rbstr
= SysAllocString(szFalse
);
4601 VAROR(DATE
,0,BSTR
,rbstr
,I4
,0);
4602 VAROR(DATE
,-1,BSTR
,rbstr
,I4
,-1);
4603 SysFreeString(rbstr
);
4604 rbstr
= SysAllocString(szTrue
);
4605 VAROR(DATE
,0,BSTR
,rbstr
,I4
,-1);
4606 VAROR(DATE
,-1,BSTR
,rbstr
,I4
,-1);
4607 SysFreeString(rbstr
);
4608 VARORCY(DATE
,-1,10000,I4
,-1);
4609 VARORCY(DATE
,-1,0,I4
,-1);
4610 VARORCY(DATE
,0,0,I4
,0);
4612 if (HAVE_OLEAUT32_I8
)
4614 VAROR(I8
,-1,I8
,-1,I8
,-1);
4615 VAROR(I8
,-1,I8
,0,I8
,-1);
4616 VAROR(I8
,0,I8
,0,I8
,0);
4617 VAROR(I8
,-1,UI8
,0,I8
,-1);
4618 VAROR(I8
,0,UI8
,0,I8
,0);
4619 /* These overflow under native and Wine
4620 VAROR(I8,-1,INT,-1,I4,-1);
4621 VAROR(I8,-1,INT,0,I4,-1);
4622 VAROR(I8,0,INT,0,I4,0); */
4623 VAROR(I8
,-1,UINT
,0xffffffff,I8
,-1);
4624 VAROR(I8
,-1,UINT
,0,I8
,-1);
4625 VAROR(I8
,0,UINT
,0,I8
,0);
4626 rbstr
= SysAllocString(szFalse
);
4627 VAROR(I8
,0,BSTR
,rbstr
,I8
,0);
4628 VAROR(I8
,-1,BSTR
,rbstr
,I8
,-1);
4629 SysFreeString(rbstr
);
4630 rbstr
= SysAllocString(szTrue
);
4631 VAROR(I8
,0,BSTR
,rbstr
,I8
,-1);
4632 VAROR(I8
,-1,BSTR
,rbstr
,I8
,-1);
4633 SysFreeString(rbstr
);
4634 VARORCY(I8
,-1,10000,I8
,-1);
4635 VARORCY(I8
,-1,0,I8
,-1);
4636 VARORCY(I8
,0,0,I8
,0);
4638 VAROR(UI8
,0xffff,UI8
,0xffff,I4
,0xffff);
4639 VAROR(UI8
,0xffff,UI8
,0,I4
,0xffff);
4640 VAROR(UI8
,0,UI8
,0,I4
,0);
4641 VAROR(UI8
,0xffff,INT
,-1,I4
,-1);
4642 VAROR(UI8
,0xffff,INT
,0,I4
,0xffff);
4643 VAROR(UI8
,0,INT
,0,I4
,0);
4644 VAROR(UI8
,0xffff,UINT
,0xffff,I4
,0xffff);
4645 VAROR(UI8
,0xffff,UINT
,0,I4
,0xffff);
4646 VAROR(UI8
,0,UINT
,0,I4
,0);
4647 rbstr
= SysAllocString(szFalse
);
4648 VAROR(UI8
,0,BSTR
,rbstr
,I4
,0);
4649 VAROR(UI8
,0xffff,BSTR
,rbstr
,I4
,0xffff);
4650 SysFreeString(rbstr
);
4651 rbstr
= SysAllocString(szTrue
);
4652 VAROR(UI8
,0,BSTR
,rbstr
,I4
,-1);
4653 VAROR(UI8
,0xffff,BSTR
,rbstr
,I4
,-1);
4654 SysFreeString(rbstr
);
4655 VARORCY(UI8
,0xffff,10000,I4
,0xffff);
4656 VARORCY(UI8
,0xffff,0,I4
,0xffff);
4657 VARORCY(UI8
,0,0,I4
,0);
4660 VAROR(INT
,-1,INT
,-1,I4
,-1);
4661 VAROR(INT
,-1,INT
,0,I4
,-1);
4662 VAROR(INT
,0,INT
,0,I4
,0);
4663 VAROR(INT
,-1,UINT
,0xffff,I4
,-1);
4664 VAROR(INT
,-1,UINT
,0,I4
,-1);
4665 VAROR(INT
,0,UINT
,0,I4
,0);
4666 rbstr
= SysAllocString(szFalse
);
4667 VAROR(INT
,0,BSTR
,rbstr
,I4
,0);
4668 VAROR(INT
,-1,BSTR
,rbstr
,I4
,-1);
4669 SysFreeString(rbstr
);
4670 rbstr
= SysAllocString(szTrue
);
4671 VAROR(INT
,0,BSTR
,rbstr
,I4
,-1);
4672 VAROR(INT
,-1,BSTR
,rbstr
,I4
,-1);
4673 SysFreeString(rbstr
);
4674 VARORCY(INT
,-1,10000,I4
,-1);
4675 VARORCY(INT
,-1,0,I4
,-1);
4676 VARORCY(INT
,0,0,I4
,0);
4678 VAROR(UINT
,0xffff,UINT
,0xffff,I4
,0xffff);
4679 VAROR(UINT
,0xffff,UINT
,0,I4
,0xffff);
4680 VAROR(UINT
,0,UINT
,0,I4
,0);
4681 rbstr
= SysAllocString(szFalse
);
4682 VAROR(UINT
,0,BSTR
,rbstr
,I4
,0);
4683 VAROR(UINT
,0xffff,BSTR
,rbstr
,I4
,0xffff);
4684 SysFreeString(rbstr
);
4685 rbstr
= SysAllocString(szTrue
);
4686 VAROR(UINT
,0,BSTR
,rbstr
,I4
,-1);
4687 VAROR(UINT
,0xffff,BSTR
,rbstr
,I4
,-1);
4688 SysFreeString(rbstr
);
4689 VARORCY(UINT
,0xffff,10000,I4
,0xffff);
4690 VARORCY(UINT
,0xffff,0,I4
,0xffff);
4691 VARORCY(UINT
,0,0,I4
,0);
4693 lbstr
= SysAllocString(szFalse
);
4694 rbstr
= SysAllocString(szFalse
);
4695 VAROR(BSTR
,lbstr
,BSTR
,rbstr
,BOOL
,0);
4696 SysFreeString(rbstr
);
4697 rbstr
= SysAllocString(szTrue
);
4698 VAROR(BSTR
,lbstr
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
4699 SysFreeString(lbstr
);
4700 lbstr
= SysAllocString(szTrue
);
4701 VAROR(BSTR
,lbstr
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
4702 VARORCY(BSTR
,lbstr
,10000,I4
,-1);
4703 SysFreeString(lbstr
);
4704 lbstr
= SysAllocString(szFalse
);
4705 VARORCY(BSTR
,lbstr
,10000,I4
,1);
4706 SysFreeString(lbstr
);
4707 SysFreeString(rbstr
);
4710 static HRESULT (WINAPI
*pVarEqv
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
4712 #define VAREQV(vt1,val1,vt2,val2,rvt,rval) \
4713 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
4714 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
4715 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
4716 test_var_call2( __LINE__, pVarEqv, &left, &right, &exp )
4718 static void test_VarEqv(void)
4720 VARIANT left
, right
, exp
, result
;
4726 /* Test all possible flag/vt combinations & the resulting vt type */
4727 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
4729 VARTYPE leftvt
, rightvt
, resvt
;
4731 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
4735 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
4741 if (leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
||
4742 leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
||
4743 leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
)
4746 memset(&left
, 0, sizeof(left
));
4747 memset(&right
, 0, sizeof(right
));
4748 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
4749 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
4750 V_VT(&result
) = VT_EMPTY
;
4753 if (ExtraFlags
[i
] & VT_ARRAY
|| ExtraFlags
[i
] & VT_BYREF
||
4754 !IsValidVariantClearVT(leftvt
, ExtraFlags
[i
]) ||
4755 !IsValidVariantClearVT(rightvt
, ExtraFlags
[i
]) ||
4756 leftvt
== VT_CLSID
|| rightvt
== VT_CLSID
||
4757 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
||
4758 leftvt
== VT_VARIANT
|| rightvt
== VT_VARIANT
||
4759 leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
)
4763 if (leftvt
== VT_EMPTY
|| rightvt
== VT_EMPTY
)
4765 if (leftvt
== rightvt
||
4766 leftvt
== VT_I2
|| rightvt
== VT_I2
||
4767 leftvt
== VT_UI1
|| rightvt
== VT_UI1
||
4768 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
4770 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
4772 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
4775 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
4779 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
4781 if (leftvt
== rightvt
)
4783 else if (leftvt
== rightvt
||
4784 leftvt
== VT_I2
|| rightvt
== VT_I2
||
4785 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
4789 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
4792 else if (leftvt
== VT_I2
|| rightvt
== VT_I2
)
4794 if (leftvt
== rightvt
||
4795 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
4797 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
4800 else if (leftvt
== VT_BOOL
&& rightvt
== VT_BOOL
)
4804 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
4806 if (leftvt
== VT_INT
|| rightvt
== VT_INT
)
4811 hres
= pVarEqv(&left
, &right
, &result
);
4813 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
4814 "VarEqv: %d|0x%X, %d|0x%X: Expected failure, got 0x%X vt %d\n",
4815 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], hres
,
4818 ok(hres
== S_OK
&& V_VT(&result
) == resvt
,
4819 "VarEqv: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%X vt %d\n",
4820 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], resvt
, hres
,
4826 /* Test returned values */
4827 VAREQV(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
);
4828 VAREQV(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
);
4829 VAREQV(BOOL
,TRUE
,BOOL
,TRUE
,BOOL
,VARIANT_TRUE
);
4830 VAREQV(BOOL
,FALSE
,BOOL
,FALSE
,BOOL
,VARIANT_TRUE
);
4831 VAREQV(BOOL
,TRUE
,BOOL
,FALSE
,BOOL
,-2);
4832 VAREQV(BOOL
,FALSE
,BOOL
,TRUE
,BOOL
,-2);
4833 VAREQV(BOOL
,6,BOOL
,7,BOOL
,-2);
4834 VAREQV(BOOL
,6,BOOL
,6,BOOL
,VARIANT_TRUE
);
4835 VAREQV(BOOL
,VARIANT_TRUE
,I2
,VARIANT_TRUE
,I2
,VARIANT_TRUE
);
4836 VAREQV(BOOL
,VARIANT_TRUE
,I2
,VARIANT_FALSE
,I2
,VARIANT_FALSE
);
4837 VAREQV(BOOL
,6,I2
,7,I2
,-2);
4838 VAREQV(UI1
,1,UI1
,1,UI1
,255);
4839 VAREQV(UI1
,1,UI1
,0,UI1
,254);
4840 VAREQV(UI1
,0,UI1
,1,UI1
,254);
4841 if (HAVE_OLEAUT32_I8
)
4843 VAREQV(UI4
,VARIANT_FALSE
,I8
,VARIANT_FALSE
,I8
,-1);
4844 VAREQV(UI4
,5,I8
,19,I8
,-23);
4845 VAREQV(UI4
,VARIANT_FALSE
,UI8
,VARIANT_FALSE
,I4
,-1);
4849 static HRESULT (WINAPI
*pVarMul
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
4851 #define VARMUL(vt1,val1,vt2,val2,rvt,rval) \
4852 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
4853 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
4854 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
4855 test_var_call2( __LINE__, pVarMul, &left, &right, &exp )
4857 static void test_VarMul(void)
4859 static const WCHAR sz12
[] = {'1','2','\0'};
4860 VARIANT left
, right
, exp
, result
, cy
, dec
;
4868 lbstr
= SysAllocString(sz12
);
4869 rbstr
= SysAllocString(sz12
);
4871 /* Test all possible flag/vt combinations & the resulting vt type */
4872 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
4874 VARTYPE leftvt
, rightvt
, resvt
;
4876 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
4881 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
4887 if (leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
||
4888 leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
)
4891 memset(&left
, 0, sizeof(left
));
4892 memset(&right
, 0, sizeof(right
));
4893 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
4894 if (leftvt
== VT_BSTR
)
4895 V_BSTR(&left
) = lbstr
;
4896 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
4897 if (rightvt
== VT_BSTR
)
4898 V_BSTR(&right
) = rbstr
;
4899 V_VT(&result
) = VT_EMPTY
;
4902 /* Don't ask me why but native VarMul cannot handle:
4903 VT_I1, VT_UI2, VT_UI4, VT_INT, VT_UINT and VT_UI8.
4904 Tested with DCOM98, Win2k, WinXP */
4905 if (ExtraFlags
[i
] & VT_ARRAY
|| ExtraFlags
[i
] & VT_BYREF
||
4906 !IsValidVariantClearVT(leftvt
, ExtraFlags
[i
]) ||
4907 !IsValidVariantClearVT(rightvt
, ExtraFlags
[i
]) ||
4908 leftvt
== VT_CLSID
|| rightvt
== VT_CLSID
||
4909 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
||
4910 leftvt
== VT_VARIANT
|| rightvt
== VT_VARIANT
||
4911 leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
||
4912 leftvt
== VT_I1
|| rightvt
== VT_I1
||
4913 leftvt
== VT_UI2
|| rightvt
== VT_UI2
||
4914 leftvt
== VT_UI4
|| rightvt
== VT_UI4
||
4915 leftvt
== VT_UI8
|| rightvt
== VT_UI8
||
4916 leftvt
== VT_INT
|| rightvt
== VT_INT
||
4917 leftvt
== VT_UINT
|| rightvt
== VT_UINT
) {
4921 if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
4923 else if (leftvt
== VT_DECIMAL
|| rightvt
== VT_DECIMAL
)
4925 else if (leftvt
== VT_R8
|| rightvt
== VT_R8
||
4926 leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
||
4927 leftvt
== VT_DATE
|| rightvt
== VT_DATE
)
4929 else if (leftvt
== VT_R4
|| rightvt
== VT_R4
) {
4930 if (leftvt
== VT_I4
|| rightvt
== VT_I4
||
4931 leftvt
== VT_I8
|| rightvt
== VT_I8
||
4932 leftvt
== VT_CY
|| rightvt
== VT_CY
)
4936 } else if (leftvt
== VT_CY
|| rightvt
== VT_CY
)
4938 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
4940 else if (leftvt
== VT_I4
|| rightvt
== VT_I4
)
4942 else if (leftvt
== VT_I2
|| rightvt
== VT_I2
||
4943 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
||
4944 (leftvt
== VT_EMPTY
&& rightvt
== VT_EMPTY
))
4946 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
4949 hres
= pVarMul(&left
, &right
, &result
);
4951 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
4952 "VarMul: %d|0x%X, %d|0x%X: Expected failure, got 0x%X vt %d\n",
4953 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], hres
,
4956 ok(hres
== S_OK
&& V_VT(&result
) == resvt
,
4957 "VarMul: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%X vt %d\n",
4958 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], resvt
, hres
,
4965 /* Test returned values */
4966 VARMUL(I4
,4,I4
,2,I4
,8);
4967 VARMUL(I2
,4,I2
,2,I2
,8);
4968 VARMUL(I2
,-13,I4
,5,I4
,-65);
4969 VARMUL(I4
,-13,I4
,5,I4
,-65);
4970 VARMUL(I2
,7,R4
,0.5f
,R4
,3.5f
);
4971 VARMUL(R4
,0.5f
,I4
,5,R8
,2.5);
4972 VARMUL(R8
,7.1,BOOL
,0,R8
,0);
4973 VARMUL(BSTR
,lbstr
,I2
,4,R8
,48);
4974 VARMUL(BSTR
,lbstr
,BOOL
,1,R8
,12);
4975 VARMUL(BSTR
,lbstr
,R4
,0.1f
,R8
,1.2);
4976 VARMUL(BSTR
,lbstr
,BSTR
,rbstr
,R8
,144);
4977 VARMUL(R4
,0.2f
,BSTR
,rbstr
,R8
,2.4);
4978 VARMUL(DATE
,2.25,I4
,7,R8
,15.75);
4980 VARMUL(UI1
, UI1_MAX
, UI1
, UI1_MAX
, I4
, UI1_MAX
* UI1_MAX
);
4981 VARMUL(I2
, I2_MAX
, I2
, I2_MAX
, I4
, I2_MAX
* I2_MAX
);
4982 VARMUL(I2
, I2_MAX
, I2
, I2_MIN
, I4
, I2_MAX
* I2_MIN
);
4983 VARMUL(I2
, I2_MIN
, I2
, I2_MIN
, I4
, I2_MIN
* I2_MIN
);
4984 VARMUL(I4
, I4_MAX
, I4
, I4_MAX
, R8
, (double)I4_MAX
* I4_MAX
);
4985 VARMUL(I4
, I4_MAX
, I4
, I4_MIN
, R8
, (double)I4_MAX
* I4_MIN
);
4986 VARMUL(I4
, I4_MIN
, I4
, I4_MIN
, R8
, (double)I4_MIN
* I4_MIN
);
4987 VARMUL(R4
, R4_MAX
, R4
, R4_MAX
, R8
, (double)R4_MAX
* R4_MAX
);
4988 VARMUL(R4
, R4_MAX
, R4
, R4_MIN
, R4
, R4_MAX
* R4_MIN
);
4989 VARMUL(R4
, R4_MIN
, R4
, R4_MIN
, R4
, R4_MIN
* R4_MIN
);
4990 VARMUL(R8
, R8_MAX
, R8
, R8_MIN
, R8
, R8_MAX
* R8_MIN
);
4991 VARMUL(R8
, R8_MIN
, R8
, R8_MIN
, R8
, R8_MIN
* R8_MIN
);
4993 /* Manuly test some VT_CY and VT_DECIMAL variants */
4995 hres
= VarCyFromI4(4711, &V_CY(&cy
));
4996 ok(hres
== S_OK
, "VarCyFromI4 failed!\n");
4997 V_VT(&dec
) = VT_DECIMAL
;
4998 hres
= VarDecFromR8(-4.2, &V_DECIMAL(&dec
));
4999 ok(hres
== S_OK
, "VarDecFromR4 failed!\n");
5000 memset(&left
, 0, sizeof(left
));
5001 memset(&right
, 0, sizeof(right
));
5002 V_VT(&left
) = VT_I4
;
5004 V_VT(&right
) = VT_UI1
;
5007 hres
= VarMul(&cy
, &right
, &result
);
5008 ok(hres
== S_OK
&& V_VT(&result
) == VT_CY
, "VarMul: expected coerced type VT_CY, got %s!\n", vtstr(V_VT(&result
)));
5009 hres
= VarR8FromCy(V_CY(&result
), &r
);
5010 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 42399), "VarMul: CY value %f, expected %f\n", r
, (double)42399);
5012 hres
= VarMul(&left
, &dec
, &result
);
5013 ok(hres
== S_OK
&& V_VT(&result
) == VT_DECIMAL
, "VarMul: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result
)));
5014 hres
= VarR8FromDec(&V_DECIMAL(&result
), &r
);
5015 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 46.2), "VarMul: DECIMAL value %f, expected %f\n", r
, (double)46.2);
5017 SysFreeString(lbstr
);
5018 SysFreeString(rbstr
);
5021 static HRESULT (WINAPI
*pVarAdd
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
5023 #define VARADD(vt1,val1,vt2,val2,rvt,rval) \
5024 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
5025 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
5026 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
5027 test_var_call2( __LINE__, pVarAdd, &left, &right, &exp )
5029 static void test_VarAdd(void)
5031 static const WCHAR sz12
[] = {'1','2','\0'};
5032 VARIANT left
, right
, exp
, result
, cy
, dec
;
5040 lbstr
= SysAllocString(sz12
);
5041 rbstr
= SysAllocString(sz12
);
5043 /* Test all possible flag/vt combinations & the resulting vt type */
5044 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
5046 VARTYPE leftvt
, rightvt
, resvt
;
5048 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
5053 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
5059 if (leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
)
5062 memset(&left
, 0, sizeof(left
));
5063 memset(&right
, 0, sizeof(right
));
5064 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
5065 if (leftvt
== VT_BSTR
)
5066 V_BSTR(&left
) = lbstr
;
5067 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
5068 if (rightvt
== VT_BSTR
)
5069 V_BSTR(&right
) = rbstr
;
5070 V_VT(&result
) = VT_EMPTY
;
5073 /* Don't ask me why but native VarAdd cannot handle:
5074 VT_I1, VT_UI2, VT_UI4, VT_INT, VT_UINT and VT_UI8.
5075 Tested with DCOM98, Win2k, WinXP */
5076 if (ExtraFlags
[i
] & VT_ARRAY
|| ExtraFlags
[i
] & VT_BYREF
||
5077 !IsValidVariantClearVT(leftvt
, ExtraFlags
[i
]) ||
5078 !IsValidVariantClearVT(rightvt
, ExtraFlags
[i
]) ||
5079 leftvt
== VT_CLSID
|| rightvt
== VT_CLSID
||
5080 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
||
5081 leftvt
== VT_VARIANT
|| rightvt
== VT_VARIANT
||
5082 leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
||
5083 leftvt
== VT_I1
|| rightvt
== VT_I1
||
5084 leftvt
== VT_UI2
|| rightvt
== VT_UI2
||
5085 leftvt
== VT_UI4
|| rightvt
== VT_UI4
||
5086 leftvt
== VT_UI8
|| rightvt
== VT_UI8
||
5087 leftvt
== VT_INT
|| rightvt
== VT_INT
||
5088 leftvt
== VT_UINT
|| rightvt
== VT_UINT
) {
5092 if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
5094 else if (leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
)
5096 else if (leftvt
== VT_DECIMAL
|| rightvt
== VT_DECIMAL
)
5098 else if (leftvt
== VT_DATE
|| rightvt
== VT_DATE
)
5100 else if (leftvt
== VT_CY
|| rightvt
== VT_CY
)
5102 else if (leftvt
== VT_R8
|| rightvt
== VT_R8
)
5104 else if (leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
) {
5105 if ((leftvt
== VT_BSTR
&& rightvt
== VT_BSTR
) ||
5106 leftvt
== VT_EMPTY
|| rightvt
== VT_EMPTY
)
5110 } else if (leftvt
== VT_R4
|| rightvt
== VT_R4
) {
5111 if (leftvt
== VT_I4
|| rightvt
== VT_I4
||
5112 leftvt
== VT_I8
|| rightvt
== VT_I8
)
5117 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
5119 else if (leftvt
== VT_I4
|| rightvt
== VT_I4
)
5121 else if (leftvt
== VT_I2
|| rightvt
== VT_I2
||
5122 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
||
5123 (leftvt
== VT_EMPTY
&& rightvt
== VT_EMPTY
))
5125 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
5128 hres
= pVarAdd(&left
, &right
, &result
);
5130 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
5131 "VarAdd: %d|0x%X, %d|0x%X: Expected failure, got 0x%X vt %d\n",
5132 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], hres
,
5135 ok(hres
== S_OK
&& V_VT(&result
) == resvt
,
5136 "VarAdd: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%X vt %d\n",
5137 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], resvt
, hres
,
5140 /* Note, we don't clear left/right deliberately here */
5141 VariantClear(&result
);
5146 /* Test returned values */
5147 VARADD(I4
,4,I4
,2,I4
,6);
5148 VARADD(I2
,4,I2
,2,I2
,6);
5149 VARADD(I2
,-13,I4
,5,I4
,-8);
5150 VARADD(I4
,-13,I4
,5,I4
,-8);
5151 VARADD(I2
,7,R4
,0.5f
,R4
,7.5f
);
5152 VARADD(R4
,0.5f
,I4
,5,R8
,5.5);
5153 VARADD(R8
,7.1,BOOL
,0,R8
,7.1);
5154 VARADD(BSTR
,lbstr
,I2
,4,R8
,16);
5155 VARADD(BSTR
,lbstr
,BOOL
,1,R8
,13);
5156 VARADD(BSTR
,lbstr
,R4
,0.1f
,R8
,12.1);
5157 VARADD(R4
,0.2f
,BSTR
,rbstr
,R8
,12.2);
5158 VARADD(DATE
,2.25,I4
,7,DATE
,9.25);
5159 VARADD(DATE
,1.25,R4
,-1.7f
,DATE
,-0.45);
5161 VARADD(UI1
, UI1_MAX
, UI1
, UI1_MAX
, I2
, UI1_MAX
+ UI1_MAX
);
5162 VARADD(I2
, I2_MAX
, I2
, I2_MAX
, I4
, I2_MAX
+ I2_MAX
);
5163 VARADD(I2
, I2_MAX
, I2
, I2_MIN
, I2
, I2_MAX
+ I2_MIN
);
5164 VARADD(I2
, I2_MIN
, I2
, I2_MIN
, I4
, I2_MIN
+ I2_MIN
);
5165 VARADD(I4
, I4_MAX
, I4
, I4_MIN
, I4
, I4_MAX
+ I4_MIN
);
5166 VARADD(I4
, I4_MAX
, I4
, I4_MAX
, R8
, (double)I4_MAX
+ I4_MAX
);
5167 VARADD(I4
, I4_MIN
, I4
, I4_MIN
, R8
, (double)I4_MIN
+ I4_MIN
);
5168 VARADD(R4
, R4_MAX
, R4
, R4_MAX
, R8
, (double)R4_MAX
+ R4_MAX
);
5169 VARADD(R4
, R4_MAX
, R4
, R4_MIN
, R4
, R4_MAX
+ R4_MIN
);
5170 VARADD(R4
, R4_MIN
, R4
, R4_MIN
, R4
, R4_MIN
+ R4_MIN
);
5171 VARADD(R8
, R8_MAX
, R8
, R8_MIN
, R8
, R8_MAX
+ R8_MIN
);
5172 VARADD(R8
, R8_MIN
, R8
, R8_MIN
, R8
, R8_MIN
+ R8_MIN
);
5174 /* Manually test BSTR + BSTR */
5175 V_VT(&left
) = VT_BSTR
;
5176 V_BSTR(&left
) = lbstr
;
5177 V_VT(&right
) = VT_BSTR
;
5178 V_BSTR(&right
) = rbstr
;
5179 hres
= VarAdd(&left
, &right
, &result
);
5180 ok(hres
== S_OK
&& V_VT(&result
) == VT_BSTR
, "VarAdd: expected coerced type VT_BSTR, got %s!\n", vtstr(V_VT(&result
)));
5181 hres
= VarR8FromStr(V_BSTR(&result
), 0, 0, &r
);
5182 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 1212), "VarAdd: BSTR value %f, expected %f\n", r
, (double)1212);
5183 VariantClear(&result
);
5185 /* Manuly test some VT_CY and VT_DECIMAL variants */
5187 hres
= VarCyFromI4(4711, &V_CY(&cy
));
5188 ok(hres
== S_OK
, "VarCyFromI4 failed!\n");
5189 V_VT(&dec
) = VT_DECIMAL
;
5190 hres
= VarDecFromR8(-4.2, &V_DECIMAL(&dec
));
5191 ok(hres
== S_OK
, "VarDecFromR4 failed!\n");
5192 memset(&left
, 0, sizeof(left
));
5193 memset(&right
, 0, sizeof(right
));
5194 V_VT(&left
) = VT_I4
;
5196 V_VT(&right
) = VT_UI1
;
5199 hres
= VarAdd(&cy
, &right
, &result
);
5200 ok(hres
== S_OK
&& V_VT(&result
) == VT_CY
, "VarAdd: expected coerced type VT_CY, got %s!\n", vtstr(V_VT(&result
)));
5201 hres
= VarR8FromCy(V_CY(&result
), &r
);
5202 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 4720), "VarAdd: CY value %f, expected %f\n", r
, (double)4720);
5204 hres
= VarAdd(&left
, &dec
, &result
);
5205 ok(hres
== S_OK
&& V_VT(&result
) == VT_DECIMAL
, "VarAdd: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result
)));
5206 hres
= VarR8FromDec(&V_DECIMAL(&result
), &r
);
5207 ok(hres
== S_OK
&& EQ_DOUBLE(r
, -15.2), "VarAdd: DECIMAL value %f, expected %f\n", r
, (double)-15.2);
5208 VariantClear(&result
);
5210 SysFreeString(lbstr
);
5211 SysFreeString(rbstr
);
5214 static void test_VarCat(void)
5217 VARIANT left
, right
, result
, expected
;
5218 static const WCHAR sz12
[] = {'1','2','\0'};
5219 static const WCHAR sz34
[] = {'3','4','\0'};
5220 static const WCHAR sz1234
[] = {'1','2','3','4','\0'};
5221 static const WCHAR date_sz12
[] = {'9','/','3','0','/','1','9','8','0','1','2','\0'};
5222 static const WCHAR sz12_date
[] = {'1','2','9','/','3','0','/','1','9','8','0','\0'};
5223 static const WCHAR sz_empty
[] = {'\0'};
5224 static const WCHAR sz12_true
[] = {'1','2','T','r','u','e','\0'};
5225 static const WCHAR sz12_false
[] = {'1','2','F','a','l','s','e','\0'};
5226 TCHAR orig_date_format
[128];
5227 VARTYPE leftvt
, rightvt
, resultvt
;
5229 HRESULT expected_error_num
;
5231 /* Set date format for testing */
5232 lcid
= LOCALE_USER_DEFAULT
;
5233 GetLocaleInfo(lcid
,LOCALE_SSHORTDATE
,orig_date_format
,128);
5234 SetLocaleInfo(lcid
,LOCALE_SSHORTDATE
,"M/d/yyyy");
5237 VariantInit(&right
);
5238 VariantInit(&result
);
5239 VariantInit(&expected
);
5241 /* Check expected types for all combinations */
5242 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
5247 /* Check if we need/have support for I8 and/or UI8 */
5248 if ((leftvt
== VT_I8
|| leftvt
== VT_UI8
) && !HAVE_OLEAUT32_I8
)
5251 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
5255 expected_error_num
= S_OK
;
5256 resultvt
= VT_EMPTY
;
5258 if (leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
||
5259 leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
||
5260 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
||
5261 leftvt
== 15 || rightvt
== 15 /* Undefined type */)
5264 /* Check if we need/have support for I8 and/or UI8 */
5265 if ((rightvt
== VT_I8
|| rightvt
== VT_UI8
) && !HAVE_OLEAUT32_I8
)
5268 if (leftvt
== VT_NULL
&& rightvt
== VT_NULL
)
5270 else if (leftvt
== VT_VARIANT
&& (rightvt
== VT_ERROR
||
5271 rightvt
== VT_DATE
|| rightvt
== VT_DECIMAL
))
5272 expected_error_num
= DISP_E_TYPEMISMATCH
;
5273 else if ((leftvt
== VT_I2
|| leftvt
== VT_I4
||
5274 leftvt
== VT_R4
|| leftvt
== VT_R8
||
5275 leftvt
== VT_CY
|| leftvt
== VT_BOOL
||
5276 leftvt
== VT_BSTR
|| leftvt
== VT_I1
||
5277 leftvt
== VT_UI1
|| leftvt
== VT_UI2
||
5278 leftvt
== VT_UI4
|| leftvt
== VT_I8
||
5279 leftvt
== VT_UI8
|| leftvt
== VT_INT
||
5280 leftvt
== VT_UINT
|| leftvt
== VT_EMPTY
||
5281 leftvt
== VT_NULL
|| leftvt
== VT_DECIMAL
||
5284 (rightvt
== VT_I2
|| rightvt
== VT_I4
||
5285 rightvt
== VT_R4
|| rightvt
== VT_R8
||
5286 rightvt
== VT_CY
|| rightvt
== VT_BOOL
||
5287 rightvt
== VT_BSTR
|| rightvt
== VT_I1
||
5288 rightvt
== VT_UI1
|| rightvt
== VT_UI2
||
5289 rightvt
== VT_UI4
|| rightvt
== VT_I8
||
5290 rightvt
== VT_UI8
|| rightvt
== VT_INT
||
5291 rightvt
== VT_UINT
|| rightvt
== VT_EMPTY
||
5292 rightvt
== VT_NULL
|| rightvt
== VT_DECIMAL
||
5293 rightvt
== VT_DATE
))
5295 else if (rightvt
== VT_ERROR
&& leftvt
< VT_VOID
)
5296 expected_error_num
= DISP_E_TYPEMISMATCH
;
5297 else if (leftvt
== VT_ERROR
&& (rightvt
== VT_DATE
||
5298 rightvt
== VT_ERROR
|| rightvt
== VT_DECIMAL
))
5299 expected_error_num
= DISP_E_TYPEMISMATCH
;
5300 else if (rightvt
== VT_DATE
|| rightvt
== VT_ERROR
||
5301 rightvt
== VT_DECIMAL
)
5302 expected_error_num
= DISP_E_BADVARTYPE
;
5303 else if (leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
)
5304 expected_error_num
= DISP_E_TYPEMISMATCH
;
5305 else if (leftvt
== VT_VARIANT
)
5306 expected_error_num
= DISP_E_TYPEMISMATCH
;
5307 else if (rightvt
== VT_VARIANT
&& (leftvt
== VT_EMPTY
||
5308 leftvt
== VT_NULL
|| leftvt
== VT_I2
||
5309 leftvt
== VT_I4
|| leftvt
== VT_R4
||
5310 leftvt
== VT_R8
|| leftvt
== VT_CY
||
5311 leftvt
== VT_DATE
|| leftvt
== VT_BSTR
||
5312 leftvt
== VT_BOOL
|| leftvt
== VT_DECIMAL
||
5313 leftvt
== VT_I1
|| leftvt
== VT_UI1
||
5314 leftvt
== VT_UI2
|| leftvt
== VT_UI4
||
5315 leftvt
== VT_I8
|| leftvt
== VT_UI8
||
5316 leftvt
== VT_INT
|| leftvt
== VT_UINT
5318 expected_error_num
= DISP_E_TYPEMISMATCH
;
5320 expected_error_num
= DISP_E_BADVARTYPE
;
5322 V_VT(&left
) = leftvt
;
5323 V_VT(&right
) = rightvt
;
5327 V_BSTR(&left
) = SysAllocString(sz_empty
); break;
5329 V_DATE(&left
) = 0.0; break;
5331 VarDecFromR8(0.0, &V_DECIMAL(&left
)); break;
5338 V_BSTR(&right
) = SysAllocString(sz_empty
); break;
5340 V_DATE(&right
) = 0.0; break;
5342 VarDecFromR8(0.0, &V_DECIMAL(&right
)); break;
5347 hres
= VarCat(&left
, &right
, &result
);
5349 /* Determine the error code for the vt combination */
5350 ok(hres
== expected_error_num
,
5351 "VarCat: %d, %d returned error, 0x%X expected 0x%X.\n",
5352 leftvt
, rightvt
, expected_error_num
, hres
);
5354 /* Check types are correct */
5355 ok(V_VT(&result
) == resultvt
,
5356 "VarCat: %d, %d: expected vt %d, got vt %d\n",
5357 leftvt
, rightvt
, resultvt
, V_VT(&result
));
5359 VariantClear(&left
);
5360 VariantClear(&right
);
5361 VariantClear(&result
);
5365 /* Running single comparison tests to compare outputs */
5367 /* Test concat strings */
5368 V_VT(&left
) = VT_BSTR
;
5369 V_VT(&right
) = VT_BSTR
;
5370 V_VT(&expected
) = VT_BSTR
;
5371 V_BSTR(&left
) = SysAllocString(sz12
);
5372 V_BSTR(&right
) = SysAllocString(sz34
);
5373 V_BSTR(&expected
) = SysAllocString(sz1234
);
5374 hres
= VarCat(&left
,&right
,&result
);
5375 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5376 ok(VarCmp(&result
,&expected
,lcid
,0) == VARCMP_EQ
,
5377 "VarCat: VT_BSTR concat with VT_BSTR failed to return correct result\n");
5379 VariantClear(&left
);
5380 VariantClear(&right
);
5381 VariantClear(&result
);
5383 /* Test if expression is VT_ERROR */
5384 V_VT(&left
) = VT_ERROR
;
5385 V_VT(&right
) = VT_BSTR
;
5386 V_BSTR(&right
) = SysAllocString(sz1234
);
5387 hres
= VarCat(&left
,&right
,&result
);
5388 ok(hres
== DISP_E_TYPEMISMATCH
, "VarCat should have returned DISP_E_TYPEMISMATCH instead of 0x%08x\n", hres
);
5389 ok(V_VT(&result
) == VT_EMPTY
,
5390 "VarCat: VT_ERROR concat with VT_BSTR should have returned VT_EMPTY\n");
5392 VariantClear(&left
);
5393 VariantClear(&right
);
5394 VariantClear(&result
);
5396 V_VT(&left
) = VT_BSTR
;
5397 V_VT(&right
) = VT_ERROR
;
5398 V_BSTR(&left
) = SysAllocString(sz1234
);
5399 hres
= VarCat(&left
,&right
,&result
);
5400 ok(hres
== DISP_E_TYPEMISMATCH
, "VarCat should have returned DISP_E_TYPEMISMATCH instead of 0x%08x\n", hres
);
5401 ok(V_VT(&result
) == VT_EMPTY
,
5402 "VarCat: VT_BSTR concat with VT_ERROR should have returned VT_EMPTY\n");
5404 VariantClear(&left
);
5405 VariantClear(&right
);
5406 VariantClear(&result
);
5407 VariantClear(&expected
);
5409 /* Test combining boolean with number */
5410 V_VT(&left
) = VT_INT
;
5411 V_VT(&right
) = VT_BOOL
;
5412 V_VT(&expected
) = VT_BSTR
;
5414 V_BOOL(&right
) = TRUE
;
5415 V_BSTR(&expected
) = SysAllocString(sz12_true
);
5416 hres
= VarCat(&left
,&right
,&result
);
5417 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5418 hres
= VarCmp(&result
,&expected
,lcid
,0);
5419 ok(hres
== VARCMP_EQ
||
5420 broken(hres
== VARCMP_GT
), "Expected VARCMP_EQ, got %08x\n", hres
);
5422 VariantClear(&left
);
5423 VariantClear(&right
);
5424 VariantClear(&result
);
5425 VariantClear(&expected
);
5427 V_VT(&left
) = VT_INT
;
5428 V_VT(&right
) = VT_BOOL
;
5429 V_VT(&expected
) = VT_BSTR
;
5431 V_BOOL(&right
) = FALSE
;
5432 V_BSTR(&expected
) = SysAllocString(sz12_false
);
5433 hres
= VarCat(&left
,&right
,&result
);
5434 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5435 hres
= VarCmp(&result
,&expected
,lcid
,0);
5436 ok(hres
== VARCMP_EQ
||
5437 broken(hres
== VARCMP_GT
), "Expected VARCMP_EQ, got %08x\n", hres
);
5439 VariantClear(&left
);
5440 VariantClear(&right
);
5441 VariantClear(&result
);
5442 VariantClear(&expected
);
5444 /* Test when both expressions are numeric */
5445 V_VT(&left
) = VT_INT
;
5446 V_VT(&right
) = VT_INT
;
5447 V_VT(&expected
) = VT_BSTR
;
5450 V_BSTR(&expected
) = SysAllocString(sz1234
);
5451 hres
= VarCat(&left
,&right
,&result
);
5452 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5453 ok(VarCmp(&result
,&expected
,lcid
,0) == VARCMP_EQ
,
5454 "VarCat: NUMBER concat with NUMBER returned inncorrect result\n");
5456 VariantClear(&left
);
5457 VariantClear(&right
);
5458 VariantClear(&result
);
5460 /* Test if one expression is numeric and the other is a string */
5461 V_VT(&left
) = VT_INT
;
5462 V_VT(&right
) = VT_BSTR
;
5464 V_BSTR(&right
) = SysAllocString(sz34
);
5465 hres
= VarCat(&left
,&right
,&result
);
5466 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5467 ok(VarCmp(&result
,&expected
,lcid
,0) == VARCMP_EQ
,
5468 "VarCat: NUMBER concat with VT_BSTR, inncorrect result\n");
5470 VariantClear(&left
);
5471 VariantClear(&right
);
5472 VariantClear(&result
);
5474 V_VT(&left
) = VT_BSTR
;
5475 V_VT(&right
) = VT_INT
;
5476 V_BSTR(&left
) = SysAllocString(sz12
);
5478 hres
= VarCat(&left
,&right
,&result
);
5479 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5480 ok(VarCmp(&result
,&expected
,lcid
,0) == VARCMP_EQ
,
5481 "VarCat: VT_BSTR concat with NUMBER, inncorrect result\n");
5483 VariantClear(&left
);
5484 VariantClear(&right
);
5485 VariantClear(&result
);
5486 VariantClear(&expected
);
5488 /* Test concat dates with strings */
5489 V_VT(&left
) = VT_BSTR
;
5490 V_VT(&right
) = VT_DATE
;
5491 V_VT(&expected
) = VT_BSTR
;
5492 V_BSTR(&left
) = SysAllocString(sz12
);
5493 V_DATE(&right
) = 29494.0;
5494 V_BSTR(&expected
)= SysAllocString(sz12_date
);
5495 hres
= VarCat(&left
,&right
,&result
);
5496 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5497 ok(VarCmp(&result
,&expected
,lcid
,0) == VARCMP_EQ
,
5498 "VarCat: VT_BSTR concat with VT_DATE returned inncorrect result\n");
5500 VariantClear(&left
);
5501 VariantClear(&right
);
5502 VariantClear(&result
);
5503 VariantClear(&expected
);
5505 V_VT(&left
) = VT_DATE
;
5506 V_VT(&right
) = VT_BSTR
;
5507 V_VT(&expected
) = VT_BSTR
;
5508 V_DATE(&left
) = 29494.0;
5509 V_BSTR(&right
) = SysAllocString(sz12
);
5510 V_BSTR(&expected
)= SysAllocString(date_sz12
);
5511 hres
= VarCat(&left
,&right
,&result
);
5512 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5513 ok(VarCmp(&result
,&expected
,lcid
,0) == VARCMP_EQ
,
5514 "VarCat: VT_DATE concat with VT_BSTR returned inncorrect result\n");
5516 VariantClear(&left
);
5517 VariantClear(&right
);
5518 VariantClear(&result
);
5519 VariantClear(&expected
);
5521 /* Test of both expressions are empty */
5522 V_VT(&left
) = VT_BSTR
;
5523 V_VT(&right
) = VT_BSTR
;
5524 V_VT(&expected
) = VT_BSTR
;
5525 V_BSTR(&left
) = SysAllocString(sz_empty
);
5526 V_BSTR(&right
) = SysAllocString(sz_empty
);
5527 V_BSTR(&expected
)= SysAllocString(sz_empty
);
5528 hres
= VarCat(&left
,&right
,&result
);
5529 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5530 ok(VarCmp(&result
,&left
,lcid
,0) == VARCMP_EQ
,
5531 "VarCat: EMPTY concat with EMPTY did not return empty VT_BSTR\n");
5533 /* Restore original date format settings */
5534 SetLocaleInfo(lcid
,LOCALE_SSHORTDATE
,orig_date_format
);
5536 VariantClear(&left
);
5537 VariantClear(&right
);
5538 VariantClear(&result
);
5539 VariantClear(&expected
);
5542 static HRESULT (WINAPI
*pVarAnd
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
5544 #define VARAND(vt1,val1,vt2,val2,rvt,rval) \
5545 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
5546 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
5547 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
5548 test_var_call2( __LINE__, pVarAnd, &left, &right, &exp )
5550 #define VARANDCY(vt1,val1,val2,rvt,rval) \
5551 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
5552 V_VT(&right) = VT_CY; V_CY(&right).int64 = val2; \
5553 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
5554 test_var_call2( __LINE__, pVarAnd, &left, &right, &exp )
5556 /* Skip any type that is not defined or produces an error for every case */
5557 #define SKIPTESTAND(a) \
5558 if (a == VT_ERROR || a == VT_VARIANT || \
5559 a == VT_DISPATCH || a == VT_UNKNOWN || \
5560 a > VT_UINT || a == 15 /*not defined*/) \
5563 static void test_VarAnd(void)
5565 static const WCHAR szFalse
[] = { '#','F','A','L','S','E','#','\0' };
5566 static const WCHAR szTrue
[] = { '#','T','R','U','E','#','\0' };
5567 VARIANT left
, right
, exp
, result
;
5568 BSTR false_str
, true_str
;
5572 true_str
= SysAllocString(szTrue
);
5573 false_str
= SysAllocString(szFalse
);
5577 /* Test all possible flag/vt combinations & the resulting vt type */
5578 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
5580 VARTYPE leftvt
, rightvt
, resvt
;
5582 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
5584 SKIPTESTAND(leftvt
);
5586 /* Check if we need/have support for I8 and/or UI8 */
5587 if ((leftvt
== VT_I8
|| leftvt
== VT_UI8
) && !HAVE_OLEAUT32_I8
)
5590 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
5593 SKIPTESTAND(rightvt
);
5595 /* Check if we need/have support for I8 and/or UI8 */
5596 if ((rightvt
== VT_I8
|| rightvt
== VT_UI8
) && !HAVE_OLEAUT32_I8
)
5599 memset(&left
, 0, sizeof(left
));
5600 memset(&right
, 0, sizeof(right
));
5601 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
5602 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
5603 V_VT(&result
) = VT_EMPTY
;
5605 if ((leftvt
| ExtraFlags
[i
]) == VT_BSTR
)
5606 V_BSTR(&left
) = true_str
;
5607 if ((rightvt
| ExtraFlags
[i
]) == VT_BSTR
)
5608 V_BSTR(&right
) = true_str
;
5610 /* Native VarAnd always returns an error when using extra
5611 * flags or if the variant combination is I8 and INT.
5613 if ((leftvt
== VT_I8
&& rightvt
== VT_INT
) ||
5614 (leftvt
== VT_INT
&& rightvt
== VT_I8
) ||
5618 /* Determine return type */
5619 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
5621 else if (leftvt
== VT_I4
|| rightvt
== VT_I4
||
5622 leftvt
== VT_UINT
|| rightvt
== VT_UINT
||
5623 leftvt
== VT_INT
|| rightvt
== VT_INT
||
5624 leftvt
== VT_UINT
|| rightvt
== VT_UINT
||
5625 leftvt
== VT_R4
|| rightvt
== VT_R4
||
5626 leftvt
== VT_R8
|| rightvt
== VT_R8
||
5627 leftvt
== VT_CY
|| rightvt
== VT_CY
||
5628 leftvt
== VT_DATE
|| rightvt
== VT_DATE
||
5629 leftvt
== VT_I1
|| rightvt
== VT_I1
||
5630 leftvt
== VT_UI2
|| rightvt
== VT_UI2
||
5631 leftvt
== VT_UI4
|| rightvt
== VT_UI4
||
5632 leftvt
== VT_UI8
|| rightvt
== VT_UI8
||
5633 leftvt
== VT_DECIMAL
|| rightvt
== VT_DECIMAL
)
5635 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
||
5636 leftvt
== VT_I2
|| rightvt
== VT_I2
||
5637 leftvt
== VT_EMPTY
|| rightvt
== VT_EMPTY
)
5638 if ((leftvt
== VT_NULL
&& rightvt
== VT_UI1
) ||
5639 (leftvt
== VT_UI1
&& rightvt
== VT_NULL
) ||
5640 (leftvt
== VT_UI1
&& rightvt
== VT_UI1
))
5644 else if (leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
||
5645 (leftvt
== VT_BSTR
&& rightvt
== VT_BSTR
))
5647 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
||
5648 leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
)
5653 hres
= pVarAnd(&left
, &right
, &result
);
5655 /* Check expected HRESULT and if result variant type is correct */
5657 ok (hres
== DISP_E_BADVARTYPE
|| hres
== DISP_E_TYPEMISMATCH
,
5658 "VarAnd: %s|0x%X, %s|0x%X: got vt %s hr 0x%X\n",
5659 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
],
5660 vtstr(V_VT(&result
)), hres
);
5662 ok (hres
== S_OK
&& resvt
== V_VT(&result
),
5663 "VarAnd: %s|0x%X, %s|0x%X: expected vt %s hr 0x%X, got vt %s hr 0x%X\n",
5664 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
], vtstr(resvt
),
5665 S_OK
, vtstr(V_VT(&result
)), hres
);
5671 * Test returned values. Since we know the returned type is correct
5672 * and that we handle all combinations of invalid types, just check
5673 * that good type combinations produce the desired value.
5674 * FIXME: Test VT_DECIMAL
5676 VARAND(EMPTY
,0,EMPTY
,0,I2
,0);
5677 VARAND(EMPTY
,1,EMPTY
,0,I2
,0);
5678 VARAND(EMPTY
,1,EMPTY
,1,I2
,0);
5679 VARAND(EMPTY
,0,NULL
,0,I2
,0);
5680 VARAND(EMPTY
,1,NULL
,0,I2
,0);
5681 VARAND(EMPTY
,1,NULL
,1,I2
,0);
5682 VARAND(EMPTY
,0,I1
,0,I4
,0);
5683 VARAND(EMPTY
,0,I1
,1,I4
,0);
5684 VARAND(EMPTY
,1,I1
,1,I4
,0);
5685 VARAND(EMPTY
,0,UI1
,0,I2
,0);
5686 VARAND(EMPTY
,0,UI1
,1,I2
,0);
5687 VARAND(EMPTY
,1,UI1
,1,I2
,0);
5688 VARAND(EMPTY
,0,I2
,0,I2
,0);
5689 VARAND(EMPTY
,0,I2
,1,I2
,0);
5690 VARAND(EMPTY
,1,I2
,1,I2
,0);
5691 VARAND(EMPTY
,0,UI2
,0,I4
,0);
5692 VARAND(EMPTY
,0,UI2
,1,I4
,0);
5693 VARAND(EMPTY
,1,UI2
,1,I4
,0);
5694 VARAND(EMPTY
,0,I4
,0,I4
,0);
5695 VARAND(EMPTY
,0,I4
,1,I4
,0);
5696 VARAND(EMPTY
,1,I4
,1,I4
,0);
5697 VARAND(EMPTY
,0,UI4
,0,I4
,0);
5698 VARAND(EMPTY
,0,UI4
,1,I4
,0);
5699 VARAND(EMPTY
,1,UI4
,1,I4
,0);
5700 if (HAVE_OLEAUT32_I8
)
5702 VARAND(EMPTY
,0,I8
,0,I8
,0);
5703 VARAND(EMPTY
,0,I8
,1,I8
,0);
5704 VARAND(EMPTY
,1,I8
,1,I8
,0);
5705 VARAND(EMPTY
,0,UI8
,0,I4
,0);
5706 VARAND(EMPTY
,0,UI8
,1,I4
,0);
5707 VARAND(EMPTY
,1,UI8
,1,I4
,0);
5709 VARAND(EMPTY
,0,INT
,0,I4
,0);
5710 VARAND(EMPTY
,0,INT
,1,I4
,0);
5711 VARAND(EMPTY
,1,INT
,1,I4
,0);
5712 VARAND(EMPTY
,0,UINT
,0,I4
,0);
5713 VARAND(EMPTY
,0,UINT
,1,I4
,0);
5714 VARAND(EMPTY
,1,UINT
,1,I4
,0);
5715 VARAND(EMPTY
,0,BOOL
,0,I2
,0);
5716 VARAND(EMPTY
,0,BOOL
,1,I2
,0);
5717 VARAND(EMPTY
,1,BOOL
,1,I2
,0);
5718 VARAND(EMPTY
,0,R4
,0,I4
,0);
5719 VARAND(EMPTY
,0,R4
,1,I4
,0);
5720 VARAND(EMPTY
,1,R4
,1,I4
,0);
5721 VARAND(EMPTY
,0,R8
,0,I4
,0);
5722 VARAND(EMPTY
,0,R8
,1,I4
,0);
5723 VARAND(EMPTY
,1,R8
,1,I4
,0);
5724 VARAND(EMPTY
,0,BSTR
,false_str
,I2
,0);
5725 VARAND(EMPTY
,0,BSTR
,true_str
,I2
,0);
5726 VARANDCY(EMPTY
,0,10000,I4
,0);
5728 /* NULL OR 0 = NULL. NULL OR n = n */
5729 VARAND(NULL
,0,NULL
,0,NULL
,0);
5730 VARAND(NULL
,1,NULL
,0,NULL
,0);
5731 VARAND(NULL
,0,I1
,0,I4
,0);
5732 VARAND(NULL
,0,I1
,1,NULL
,0);
5733 VARAND(NULL
,0,UI1
,0,UI1
,0);
5734 VARAND(NULL
,0,UI1
,1,NULL
,0);
5735 VARAND(NULL
,0,I2
,0,I2
,0);
5736 VARAND(NULL
,0,I2
,1,NULL
,0);
5737 VARAND(NULL
,0,UI2
,0,I4
,0);
5738 VARAND(NULL
,0,UI2
,1,NULL
,0);
5739 VARAND(NULL
,0,I4
,0,I4
,0);
5740 VARAND(NULL
,0,I4
,1,NULL
,0);
5741 VARAND(NULL
,0,UI4
,0,I4
,0);
5742 VARAND(NULL
,0,UI4
,1,NULL
,0);
5743 if (HAVE_OLEAUT32_I8
)
5745 VARAND(NULL
,0,I8
,0,I8
,0);
5746 VARAND(NULL
,0,I8
,1,NULL
,0);
5747 VARAND(NULL
,0,UI8
,0,I4
,0);
5748 VARAND(NULL
,0,UI8
,1,NULL
,0);
5750 VARAND(NULL
,0,INT
,0,I4
,0);
5751 VARAND(NULL
,0,INT
,1,NULL
,0);
5752 VARAND(NULL
,0,UINT
,0,I4
,0);
5753 VARAND(NULL
,0,UINT
,1,NULL
,0);
5754 VARAND(NULL
,0,BOOL
,0,BOOL
,0);
5755 VARAND(NULL
,0,BOOL
,1,NULL
,0);
5756 VARAND(NULL
,0,R4
,0,I4
,0);
5757 VARAND(NULL
,0,R4
,1,NULL
,0);
5758 VARAND(NULL
,0,R8
,0,I4
,0);
5759 VARAND(NULL
,0,R8
,1,NULL
,0);
5760 VARAND(NULL
,0,BSTR
,false_str
,BOOL
,0);
5761 VARAND(NULL
,0,BSTR
,true_str
,NULL
,VARIANT_FALSE
);
5762 VARANDCY(NULL
,0,10000,NULL
,0);
5763 VARANDCY(NULL
,0,0,I4
,0);
5764 VARAND(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
);
5765 VARAND(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_FALSE
);
5766 VARAND(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
);
5767 VARAND(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_FALSE
);
5769 /* Assume x,y & y,x are the same from now on to reduce the number of tests */
5770 VARAND(BOOL
,VARIANT_TRUE
,I1
,-1,I4
,-1);
5771 VARAND(BOOL
,VARIANT_TRUE
,I1
,0,I4
,0);
5772 VARAND(BOOL
,VARIANT_FALSE
,I1
,0,I4
,0);
5773 VARAND(BOOL
,VARIANT_TRUE
,UI1
,255,I2
,255);
5774 VARAND(BOOL
,VARIANT_TRUE
,UI1
,0,I2
,0);
5775 VARAND(BOOL
,VARIANT_FALSE
,UI1
,0,I2
,0);
5776 VARAND(BOOL
,VARIANT_TRUE
,I2
,-1,I2
,-1);
5777 VARAND(BOOL
,VARIANT_TRUE
,I2
,0,I2
,0);
5778 VARAND(BOOL
,VARIANT_FALSE
,I2
,0,I2
,0);
5779 VARAND(BOOL
,VARIANT_TRUE
,UI2
,65535,I4
,65535);
5780 VARAND(BOOL
,VARIANT_TRUE
,UI2
,0,I4
,0);
5781 VARAND(BOOL
,VARIANT_FALSE
,UI2
,0,I4
,0);
5782 VARAND(BOOL
,VARIANT_TRUE
,I4
,-1,I4
,-1);
5783 VARAND(BOOL
,VARIANT_TRUE
,I4
,0,I4
,0);
5784 VARAND(BOOL
,VARIANT_FALSE
,I4
,0,I4
,0);
5785 VARAND(BOOL
,VARIANT_TRUE
,UI4
,0xffffffff,I4
,-1);
5786 VARAND(BOOL
,VARIANT_TRUE
,UI4
,0,I4
,0);
5787 VARAND(BOOL
,VARIANT_FALSE
,UI4
,0,I4
,0);
5788 VARAND(BOOL
,VARIANT_TRUE
,R4
,-1,I4
,-1);
5789 VARAND(BOOL
,VARIANT_TRUE
,R4
,0,I4
,0);
5790 VARAND(BOOL
,VARIANT_FALSE
,R4
,0,I4
,0);
5791 VARAND(BOOL
,VARIANT_TRUE
,R8
,-1,I4
,-1);
5792 VARAND(BOOL
,VARIANT_TRUE
,R8
,0,I4
,0);
5793 VARAND(BOOL
,VARIANT_FALSE
,R8
,0,I4
,0);
5794 VARAND(BOOL
,VARIANT_TRUE
,DATE
,-1,I4
,-1);
5795 VARAND(BOOL
,VARIANT_TRUE
,DATE
,0,I4
,0);
5796 VARAND(BOOL
,VARIANT_FALSE
,DATE
,0,I4
,0);
5797 if (HAVE_OLEAUT32_I8
)
5799 VARAND(BOOL
,VARIANT_TRUE
,I8
,-1,I8
,-1);
5800 VARAND(BOOL
,VARIANT_TRUE
,I8
,0,I8
,0);
5801 VARAND(BOOL
,VARIANT_FALSE
,I8
,0,I8
,0);
5802 VARAND(BOOL
,VARIANT_TRUE
,UI8
,0,I4
,0);
5803 VARAND(BOOL
,VARIANT_FALSE
,UI8
,0,I4
,0);
5805 VARAND(BOOL
,VARIANT_TRUE
,INT
,-1,I4
,-1);
5806 VARAND(BOOL
,VARIANT_TRUE
,INT
,0,I4
,0);
5807 VARAND(BOOL
,VARIANT_FALSE
,INT
,0,I4
,0);
5808 VARAND(BOOL
,VARIANT_TRUE
,UINT
,0xffffffff,I4
,-1);
5809 VARAND(BOOL
,VARIANT_TRUE
,UINT
,0,I4
,0);
5810 VARAND(BOOL
,VARIANT_FALSE
,UINT
,0,I4
,0);
5811 VARAND(BOOL
,VARIANT_FALSE
,BSTR
,false_str
,BOOL
,VARIANT_FALSE
);
5812 VARAND(BOOL
,VARIANT_TRUE
,BSTR
,false_str
,BOOL
,VARIANT_FALSE
);
5813 VARAND(BOOL
,VARIANT_FALSE
,BSTR
,true_str
,BOOL
,VARIANT_FALSE
);
5814 VARAND(BOOL
,VARIANT_TRUE
,BSTR
,true_str
,BOOL
,VARIANT_TRUE
);
5815 VARANDCY(BOOL
,VARIANT_TRUE
,10000,I4
,1);
5816 VARANDCY(BOOL
,VARIANT_TRUE
,0,I4
,0);
5817 VARANDCY(BOOL
,VARIANT_FALSE
,0,I4
,0);
5818 VARAND(I1
,-1,I1
,-1,I4
,-1);
5819 VARAND(I1
,-1,I1
,0,I4
,0);
5820 VARAND(I1
,0,I1
,0,I4
,0);
5821 VARAND(I1
,-1,UI1
,255,I4
,255);
5822 VARAND(I1
,-1,UI1
,0,I4
,0);
5823 VARAND(I1
,0,UI1
,0,I4
,0);
5824 VARAND(I1
,-1,I2
,-1,I4
,-1);
5825 VARAND(I1
,-1,I2
,0,I4
,0);
5826 VARAND(I1
,0,I2
,0,I4
,0);
5827 VARAND(I1
,-1,UI2
,65535,I4
,65535);
5828 VARAND(I1
,-1,UI2
,0,I4
,0);
5829 VARAND(I1
,0,UI2
,0,I4
,0);
5830 VARAND(I1
,-1,I4
,-1,I4
,-1);
5831 VARAND(I1
,-1,I4
,0,I4
,0);
5832 VARAND(I1
,0,I4
,0,I4
,0);
5833 VARAND(I1
,-1,UI4
,0xffffffff,I4
,-1);
5834 VARAND(I1
,-1,UI4
,0,I4
,0);
5835 VARAND(I1
,0,UI4
,0,I4
,0);
5836 VARAND(I1
,-1,R4
,-1,I4
,-1);
5837 VARAND(I1
,-1,R4
,0,I4
,0);
5838 VARAND(I1
,0,R4
,0,I4
,0);
5839 VARAND(I1
,-1,R8
,-1,I4
,-1);
5840 VARAND(I1
,-1,R8
,0,I4
,0);
5841 VARAND(I1
,0,R8
,0,I4
,0);
5842 VARAND(I1
,-1,DATE
,-1,I4
,-1);
5843 VARAND(I1
,-1,DATE
,0,I4
,0);
5844 VARAND(I1
,0,DATE
,0,I4
,0);
5845 if (HAVE_OLEAUT32_I8
)
5847 VARAND(I1
,-1,I8
,-1,I8
,-1);
5848 VARAND(I1
,-1,I8
,0,I8
,0);
5849 VARAND(I1
,0,I8
,0,I8
,0);
5850 VARAND(I1
,-1,UI8
,0,I4
,0);
5851 VARAND(I1
,0,UI8
,0,I4
,0);
5853 VARAND(I1
,-1,INT
,-1,I4
,-1);
5854 VARAND(I1
,-1,INT
,0,I4
,0);
5855 VARAND(I1
,0,INT
,0,I4
,0);
5856 VARAND(I1
,-1,UINT
,0xffffffff,I4
,-1);
5857 VARAND(I1
,-1,UINT
,0,I4
,0);
5858 VARAND(I1
,0,UINT
,0,I4
,0);
5859 VARAND(I1
,0,BSTR
,false_str
,I4
,0);
5860 VARAND(I1
,-1,BSTR
,false_str
,I4
,0);
5861 VARAND(I1
,0,BSTR
,true_str
,I4
,0);
5862 VARAND(I1
,-1,BSTR
,true_str
,I4
,-1);
5863 VARANDCY(I1
,-1,10000,I4
,1);
5864 VARANDCY(I1
,-1,0,I4
,0);
5865 VARANDCY(I1
,0,0,I4
,0);
5867 VARAND(UI1
,255,UI1
,255,UI1
,255);
5868 VARAND(UI1
,255,UI1
,0,UI1
,0);
5869 VARAND(UI1
,0,UI1
,0,UI1
,0);
5870 VARAND(UI1
,255,I2
,-1,I2
,255);
5871 VARAND(UI1
,255,I2
,0,I2
,0);
5872 VARAND(UI1
,0,I2
,0,I2
,0);
5873 VARAND(UI1
,255,UI2
,65535,I4
,255);
5874 VARAND(UI1
,255,UI2
,0,I4
,0);
5875 VARAND(UI1
,0,UI2
,0,I4
,0);
5876 VARAND(UI1
,255,I4
,-1,I4
,255);
5877 VARAND(UI1
,255,I4
,0,I4
,0);
5878 VARAND(UI1
,0,I4
,0,I4
,0);
5879 VARAND(UI1
,255,UI4
,0xffffffff,I4
,255);
5880 VARAND(UI1
,255,UI4
,0,I4
,0);
5881 VARAND(UI1
,0,UI4
,0,I4
,0);
5882 VARAND(UI1
,255,R4
,-1,I4
,255);
5883 VARAND(UI1
,255,R4
,0,I4
,0);
5884 VARAND(UI1
,0,R4
,0,I4
,0);
5885 VARAND(UI1
,255,R8
,-1,I4
,255);
5886 VARAND(UI1
,255,R8
,0,I4
,0);
5887 VARAND(UI1
,0,R8
,0,I4
,0);
5888 VARAND(UI1
,255,DATE
,-1,I4
,255);
5889 VARAND(UI1
,255,DATE
,0,I4
,0);
5890 VARAND(UI1
,0,DATE
,0,I4
,0);
5891 if (HAVE_OLEAUT32_I8
)
5893 VARAND(UI1
,255,I8
,-1,I8
,255);
5894 VARAND(UI1
,255,I8
,0,I8
,0);
5895 VARAND(UI1
,0,I8
,0,I8
,0);
5896 VARAND(UI1
,255,UI8
,0,I4
,0);
5897 VARAND(UI1
,0,UI8
,0,I4
,0);
5899 VARAND(UI1
,255,INT
,-1,I4
,255);
5900 VARAND(UI1
,255,INT
,0,I4
,0);
5901 VARAND(UI1
,0,INT
,0,I4
,0);
5902 VARAND(UI1
,255,UINT
,0xffffffff,I4
,255);
5903 VARAND(UI1
,255,UINT
,0,I4
,0);
5904 VARAND(UI1
,0,UINT
,0,I4
,0);
5905 VARAND(UI1
,0,BSTR
,false_str
,I2
,0);
5906 VARAND(UI1
,255,BSTR
,false_str
,I2
,0);
5907 VARAND(UI1
,0,BSTR
,true_str
,I2
,0);
5908 VARAND(UI1
,255,BSTR
,true_str
,I2
,255);
5909 VARANDCY(UI1
,255,10000,I4
,1);
5910 VARANDCY(UI1
,255,0,I4
,0);
5911 VARANDCY(UI1
,0,0,I4
,0);
5913 VARAND(I2
,-1,I2
,-1,I2
,-1);
5914 VARAND(I2
,-1,I2
,0,I2
,0);
5915 VARAND(I2
,0,I2
,0,I2
,0);
5916 VARAND(I2
,-1,UI2
,65535,I4
,65535);
5917 VARAND(I2
,-1,UI2
,0,I4
,0);
5918 VARAND(I2
,0,UI2
,0,I4
,0);
5919 VARAND(I2
,-1,I4
,-1,I4
,-1);
5920 VARAND(I2
,-1,I4
,0,I4
,0);
5921 VARAND(I2
,0,I4
,0,I4
,0);
5922 VARAND(I2
,-1,UI4
,0xffffffff,I4
,-1);
5923 VARAND(I2
,-1,UI4
,0,I4
,0);
5924 VARAND(I2
,0,UI4
,0,I4
,0);
5925 VARAND(I2
,-1,R4
,-1,I4
,-1);
5926 VARAND(I2
,-1,R4
,0,I4
,0);
5927 VARAND(I2
,0,R4
,0,I4
,0);
5928 VARAND(I2
,-1,R8
,-1,I4
,-1);
5929 VARAND(I2
,-1,R8
,0,I4
,0);
5930 VARAND(I2
,0,R8
,0,I4
,0);
5931 VARAND(I2
,-1,DATE
,-1,I4
,-1);
5932 VARAND(I2
,-1,DATE
,0,I4
,0);
5933 VARAND(I2
,0,DATE
,0,I4
,0);
5934 if (HAVE_OLEAUT32_I8
)
5936 VARAND(I2
,-1,I8
,-1,I8
,-1);
5937 VARAND(I2
,-1,I8
,0,I8
,0);
5938 VARAND(I2
,0,I8
,0,I8
,0);
5939 VARAND(I2
,-1,UI8
,0,I4
,0);
5940 VARAND(I2
,0,UI8
,0,I4
,0);
5942 VARAND(I2
,-1,INT
,-1,I4
,-1);
5943 VARAND(I2
,-1,INT
,0,I4
,0);
5944 VARAND(I2
,0,INT
,0,I4
,0);
5945 VARAND(I2
,-1,UINT
,0xffffffff,I4
,-1);
5946 VARAND(I2
,-1,UINT
,0,I4
,0);
5947 VARAND(I2
,0,UINT
,0,I4
,0);
5948 VARAND(I2
,0,BSTR
,false_str
,I2
,0);
5949 VARAND(I2
,-1,BSTR
,false_str
,I2
,0);
5950 VARAND(I2
,0,BSTR
,true_str
,I2
,0);
5951 VARAND(I2
,-1,BSTR
,true_str
,I2
,-1);
5952 VARANDCY(I2
,-1,10000,I4
,1);
5953 VARANDCY(I2
,-1,0,I4
,0);
5954 VARANDCY(I2
,0,0,I4
,0);
5956 VARAND(UI2
,65535,UI2
,65535,I4
,65535);
5957 VARAND(UI2
,65535,UI2
,0,I4
,0);
5958 VARAND(UI2
,0,UI2
,0,I4
,0);
5959 VARAND(UI2
,65535,I4
,-1,I4
,65535);
5960 VARAND(UI2
,65535,I4
,0,I4
,0);
5961 VARAND(UI2
,0,I4
,0,I4
,0);
5962 VARAND(UI2
,65535,UI4
,0xffffffff,I4
,65535);
5963 VARAND(UI2
,65535,UI4
,0,I4
,0);
5964 VARAND(UI2
,0,UI4
,0,I4
,0);
5965 VARAND(UI2
,65535,R4
,-1,I4
,65535);
5966 VARAND(UI2
,65535,R4
,0,I4
,0);
5967 VARAND(UI2
,0,R4
,0,I4
,0);
5968 VARAND(UI2
,65535,R8
,-1,I4
,65535);
5969 VARAND(UI2
,65535,R8
,0,I4
,0);
5970 VARAND(UI2
,0,R8
,0,I4
,0);
5971 VARAND(UI2
,65535,DATE
,-1,I4
,65535);
5972 VARAND(UI2
,65535,DATE
,0,I4
,0);
5973 VARAND(UI2
,0,DATE
,0,I4
,0);
5974 if (HAVE_OLEAUT32_I8
)
5976 VARAND(UI2
,65535,I8
,-1,I8
,65535);
5977 VARAND(UI2
,65535,I8
,0,I8
,0);
5978 VARAND(UI2
,0,I8
,0,I8
,0);
5979 VARAND(UI2
,65535,UI8
,0,I4
,0);
5980 VARAND(UI2
,0,UI8
,0,I4
,0);
5982 VARAND(UI2
,65535,INT
,-1,I4
,65535);
5983 VARAND(UI2
,65535,INT
,0,I4
,0);
5984 VARAND(UI2
,0,INT
,0,I4
,0);
5985 VARAND(UI2
,65535,UINT
,0xffffffff,I4
,65535);
5986 VARAND(UI2
,65535,UINT
,0,I4
,0);
5987 VARAND(UI2
,0,UINT
,0,I4
,0);
5988 VARAND(UI2
,0,BSTR
,false_str
,I4
,0);
5989 VARAND(UI2
,65535,BSTR
,false_str
,I4
,0);
5990 VARAND(UI2
,0,BSTR
,true_str
,I4
,0);
5991 VARAND(UI2
,65535,BSTR
,true_str
,I4
,65535);
5992 VARANDCY(UI2
,65535,10000,I4
,1);
5993 VARANDCY(UI2
,65535,0,I4
,0);
5994 VARANDCY(UI2
,0,0,I4
,0);
5996 VARAND(I4
,-1,I4
,-1,I4
,-1);
5997 VARAND(I4
,-1,I4
,0,I4
,0);
5998 VARAND(I4
,0,I4
,0,I4
,0);
5999 VARAND(I4
,-1,UI4
,0xffffffff,I4
,-1);
6000 VARAND(I4
,-1,UI4
,0,I4
,0);
6001 VARAND(I4
,0,UI4
,0,I4
,0);
6002 VARAND(I4
,-1,R4
,-1,I4
,-1);
6003 VARAND(I4
,-1,R4
,0,I4
,0);
6004 VARAND(I4
,0,R4
,0,I4
,0);
6005 VARAND(I4
,-1,R8
,-1,I4
,-1);
6006 VARAND(I4
,-1,R8
,0,I4
,0);
6007 VARAND(I4
,0,R8
,0,I4
,0);
6008 VARAND(I4
,-1,DATE
,-1,I4
,-1);
6009 VARAND(I4
,-1,DATE
,0,I4
,0);
6010 VARAND(I4
,0,DATE
,0,I4
,0);
6011 if (HAVE_OLEAUT32_I8
)
6013 VARAND(I4
,-1,I8
,-1,I8
,-1);
6014 VARAND(I4
,-1,I8
,0,I8
,0);
6015 VARAND(I4
,0,I8
,0,I8
,0);
6016 VARAND(I4
,-1,UI8
,0,I4
,0);
6017 VARAND(I4
,0,UI8
,0,I4
,0);
6019 VARAND(I4
,-1,INT
,-1,I4
,-1);
6020 VARAND(I4
,-1,INT
,0,I4
,0);
6021 VARAND(I4
,0,INT
,0,I4
,0);
6022 VARAND(I4
,-1,UINT
,0xffffffff,I4
,-1);
6023 VARAND(I4
,-1,UINT
,0,I4
,0);
6024 VARAND(I4
,0,UINT
,0,I4
,0);
6025 VARAND(I4
,0,BSTR
,false_str
,I4
,0);
6026 VARAND(I4
,-1,BSTR
,false_str
,I4
,0);
6027 VARAND(I4
,0,BSTR
,true_str
,I4
,0);
6028 VARAND(I4
,-1,BSTR
,true_str
,I4
,-1);
6029 VARANDCY(I4
,-1,10000,I4
,1);
6030 VARANDCY(I4
,-1,0,I4
,0);
6031 VARANDCY(I4
,0,0,I4
,0);
6033 VARAND(UI4
,0xffffffff,UI4
,0xffffffff,I4
,-1);
6034 VARAND(UI4
,0xffffffff,UI4
,0,I4
,0);
6035 VARAND(UI4
,0,UI4
,0,I4
,0);
6036 VARAND(UI4
,0xffffffff,R4
,-1,I4
,-1);
6037 VARAND(UI4
,0xffffffff,R4
,0,I4
,0);
6038 VARAND(UI4
,0,R4
,0,I4
,0);
6039 VARAND(UI4
,0xffffffff,R8
,-1,I4
,-1);
6040 VARAND(UI4
,0xffffffff,R8
,0,I4
,0);
6041 VARAND(UI4
,0,R8
,0,I4
,0);
6042 VARAND(UI4
,0xffffffff,DATE
,-1,I4
,-1);
6043 VARAND(UI4
,0xffffffff,DATE
,0,I4
,0);
6044 VARAND(UI4
,0,DATE
,0,I4
,0);
6045 if (HAVE_OLEAUT32_I8
)
6047 VARAND(UI4
,0xffffffff,I8
,0,I8
,0);
6048 VARAND(UI4
,0,I8
,0,I8
,0);
6049 VARAND(UI4
,0xffffffff,UI8
,0,I4
,0);
6050 VARAND(UI4
,0,UI8
,0,I4
,0);
6052 VARAND(UI4
,0xffffffff,INT
,-1,I4
,-1);
6053 VARAND(UI4
,0xffffffff,INT
,0,I4
,0);
6054 VARAND(UI4
,0,INT
,0,I4
,0);
6055 VARAND(UI4
,0xffffffff,UINT
,0xffffffff,I4
,-1);
6056 VARAND(UI4
,0xffffffff,UINT
,0,I4
,0);
6057 VARAND(UI4
,0,UINT
,0,I4
,0);
6058 VARAND(UI4
,0,BSTR
,false_str
,I4
,0);
6059 VARAND(UI4
,0xffffffff,BSTR
,false_str
,I4
,0);
6060 VARAND(UI4
,0,BSTR
,true_str
,I4
,0);
6061 VARAND(UI4
,0xffffffff,BSTR
,true_str
,I4
,-1);
6062 VARANDCY(UI4
,0xffffffff,10000,I4
,1);
6063 VARANDCY(UI4
,0xffffffff,0,I4
,0);
6064 VARANDCY(UI4
,0,0,I4
,0);
6066 VARAND(R4
,-1,R4
,-1,I4
,-1);
6067 VARAND(R4
,-1,R4
,0,I4
,0);
6068 VARAND(R4
,0,R4
,0,I4
,0);
6069 VARAND(R4
,-1,R8
,-1,I4
,-1);
6070 VARAND(R4
,-1,R8
,0,I4
,0);
6071 VARAND(R4
,0,R8
,0,I4
,0);
6072 VARAND(R4
,-1,DATE
,-1,I4
,-1);
6073 VARAND(R4
,-1,DATE
,0,I4
,0);
6074 VARAND(R4
,0,DATE
,0,I4
,0);
6075 if (HAVE_OLEAUT32_I8
)
6077 VARAND(R4
,-1,I8
,-1,I8
,-1);
6078 VARAND(R4
,-1,I8
,0,I8
,0);
6079 VARAND(R4
,0,I8
,0,I8
,0);
6080 VARAND(R4
,-1,UI8
,0,I4
,0);
6081 VARAND(R4
,0,UI8
,0,I4
,0);
6083 VARAND(R4
,-1,INT
,-1,I4
,-1);
6084 VARAND(R4
,-1,INT
,0,I4
,0);
6085 VARAND(R4
,0,INT
,0,I4
,0);
6086 VARAND(R4
,-1,UINT
,0xffffffff,I4
,-1);
6087 VARAND(R4
,-1,UINT
,0,I4
,0);
6088 VARAND(R4
,0,UINT
,0,I4
,0);
6089 VARAND(R4
,0,BSTR
,false_str
,I4
,0);
6090 VARAND(R4
,-1,BSTR
,false_str
,I4
,0);
6091 VARAND(R4
,0,BSTR
,true_str
,I4
,0);
6092 VARAND(R4
,-1,BSTR
,true_str
,I4
,-1);
6093 VARANDCY(R4
,-1,10000,I4
,1);
6094 VARANDCY(R4
,-1,0,I4
,0);
6095 VARANDCY(R4
,0,0,I4
,0);
6097 VARAND(R8
,-1,R8
,-1,I4
,-1);
6098 VARAND(R8
,-1,R8
,0,I4
,0);
6099 VARAND(R8
,0,R8
,0,I4
,0);
6100 VARAND(R8
,-1,DATE
,-1,I4
,-1);
6101 VARAND(R8
,-1,DATE
,0,I4
,0);
6102 VARAND(R8
,0,DATE
,0,I4
,0);
6103 if (HAVE_OLEAUT32_I8
)
6105 VARAND(R8
,-1,I8
,-1,I8
,-1);
6106 VARAND(R8
,-1,I8
,0,I8
,0);
6107 VARAND(R8
,0,I8
,0,I8
,0);
6108 VARAND(R8
,-1,UI8
,0,I4
,0);
6109 VARAND(R8
,0,UI8
,0,I4
,0);
6111 VARAND(R8
,-1,INT
,-1,I4
,-1);
6112 VARAND(R8
,-1,INT
,0,I4
,0);
6113 VARAND(R8
,0,INT
,0,I4
,0);
6114 VARAND(R8
,-1,UINT
,0xffffffff,I4
,-1);
6115 VARAND(R8
,-1,UINT
,0,I4
,0);
6116 VARAND(R8
,0,UINT
,0,I4
,0);
6117 VARAND(R8
,0,BSTR
,false_str
,I4
,0);
6118 VARAND(R8
,-1,BSTR
,false_str
,I4
,0);
6119 VARAND(R8
,0,BSTR
,true_str
,I4
,0);
6120 VARAND(R8
,-1,BSTR
,true_str
,I4
,-1);
6121 VARANDCY(R8
,-1,10000,I4
,1);
6122 VARANDCY(R8
,-1,0,I4
,0);
6123 VARANDCY(R8
,0,0,I4
,0);
6125 VARAND(DATE
,-1,DATE
,-1,I4
,-1);
6126 VARAND(DATE
,-1,DATE
,0,I4
,0);
6127 VARAND(DATE
,0,DATE
,0,I4
,0);
6128 if (HAVE_OLEAUT32_I8
)
6130 VARAND(DATE
,-1,I8
,-1,I8
,-1);
6131 VARAND(DATE
,-1,I8
,0,I8
,0);
6132 VARAND(DATE
,0,I8
,0,I8
,0);
6133 VARAND(DATE
,-1,UI8
,0,I4
,0);
6134 VARAND(DATE
,0,UI8
,0,I4
,0);
6136 VARAND(DATE
,-1,INT
,-1,I4
,-1);
6137 VARAND(DATE
,-1,INT
,0,I4
,0);
6138 VARAND(DATE
,0,INT
,0,I4
,0);
6139 VARAND(DATE
,-1,UINT
,0xffffffff,I4
,-1);
6140 VARAND(DATE
,-1,UINT
,0,I4
,0);
6141 VARAND(DATE
,0,UINT
,0,I4
,0);
6142 VARAND(DATE
,0,BSTR
,false_str
,I4
,0);
6143 VARAND(DATE
,-1,BSTR
,false_str
,I4
,0);
6144 VARAND(DATE
,0,BSTR
,true_str
,I4
,0);
6145 VARAND(DATE
,-1,BSTR
,true_str
,I4
,-1);
6146 VARANDCY(DATE
,-1,10000,I4
,1);
6147 VARANDCY(DATE
,-1,0,I4
,0);
6148 VARANDCY(DATE
,0,0,I4
,0);
6150 if (HAVE_OLEAUT32_I8
)
6152 VARAND(I8
,-1,I8
,-1,I8
,-1);
6153 VARAND(I8
,-1,I8
,0,I8
,0);
6154 VARAND(I8
,0,I8
,0,I8
,0);
6155 VARAND(I8
,-1,UI8
,0,I8
,0);
6156 VARAND(I8
,0,UI8
,0,I8
,0);
6157 VARAND(I8
,-1,UINT
,0,I8
,0);
6158 VARAND(I8
,0,UINT
,0,I8
,0);
6159 VARAND(I8
,0,BSTR
,false_str
,I8
,0);
6160 VARAND(I8
,-1,BSTR
,false_str
,I8
,0);
6161 VARAND(I8
,0,BSTR
,true_str
,I8
,0);
6162 VARAND(I8
,-1,BSTR
,true_str
,I8
,-1);
6163 VARANDCY(I8
,-1,10000,I8
,1);
6164 VARANDCY(I8
,-1,0,I8
,0);
6165 VARANDCY(I8
,0,0,I8
,0);
6167 VARAND(UI8
,0xffff,UI8
,0xffff,I4
,0xffff);
6168 VARAND(UI8
,0xffff,UI8
,0,I4
,0);
6169 VARAND(UI8
,0,UI8
,0,I4
,0);
6170 VARAND(UI8
,0xffff,INT
,-1,I4
,65535);
6171 VARAND(UI8
,0xffff,INT
,0,I4
,0);
6172 VARAND(UI8
,0,INT
,0,I4
,0);
6173 VARAND(UI8
,0xffff,UINT
,0xffff,I4
,0xffff);
6174 VARAND(UI8
,0xffff,UINT
,0,I4
,0);
6175 VARAND(UI8
,0,UINT
,0,I4
,0);
6176 VARAND(UI8
,0,BSTR
,false_str
,I4
,0);
6177 VARAND(UI8
,0xffff,BSTR
,false_str
,I4
,0);
6178 VARAND(UI8
,0,BSTR
,true_str
,I4
,0);
6179 VARAND(UI8
,0xffff,BSTR
,true_str
,I4
,65535);
6180 VARANDCY(UI8
,0xffff,10000,I4
,1);
6181 VARANDCY(UI8
,0xffff,0,I4
,0);
6182 VARANDCY(UI8
,0,0,I4
,0);
6185 VARAND(INT
,-1,INT
,-1,I4
,-1);
6186 VARAND(INT
,-1,INT
,0,I4
,0);
6187 VARAND(INT
,0,INT
,0,I4
,0);
6188 VARAND(INT
,-1,UINT
,0xffff,I4
,65535);
6189 VARAND(INT
,-1,UINT
,0,I4
,0);
6190 VARAND(INT
,0,UINT
,0,I4
,0);
6191 VARAND(INT
,0,BSTR
,false_str
,I4
,0);
6192 VARAND(INT
,-1,BSTR
,false_str
,I4
,0);
6193 VARAND(INT
,0,BSTR
,true_str
,I4
,0);
6194 VARAND(INT
,-1,BSTR
,true_str
,I4
,-1);
6195 VARANDCY(INT
,-1,10000,I4
,1);
6196 VARANDCY(INT
,-1,0,I4
,0);
6197 VARANDCY(INT
,0,0,I4
,0);
6199 VARAND(UINT
,0xffff,UINT
,0xffff,I4
,0xffff);
6200 VARAND(UINT
,0xffff,UINT
,0,I4
,0);
6201 VARAND(UINT
,0,UINT
,0,I4
,0);
6202 VARAND(UINT
,0,BSTR
,false_str
,I4
,0);
6203 VARAND(UINT
,0xffff,BSTR
, false_str
,I4
,0);
6204 VARAND(UINT
,0,BSTR
,true_str
,I4
,0);
6205 VARAND(UINT
,0xffff,BSTR
,true_str
,I4
,65535);
6206 VARANDCY(UINT
,0xffff,10000,I4
,1);
6207 VARANDCY(UINT
,0xffff,0,I4
,0);
6208 VARANDCY(UINT
,0,0,I4
,0);
6210 VARAND(BSTR
,false_str
,BSTR
,false_str
,BOOL
,0);
6211 VARAND(BSTR
,true_str
,BSTR
,false_str
,BOOL
,VARIANT_FALSE
);
6212 VARAND(BSTR
,true_str
,BSTR
,true_str
,BOOL
,VARIANT_TRUE
);
6213 VARANDCY(BSTR
,true_str
,10000,I4
,1);
6214 VARANDCY(BSTR
,false_str
,10000,I4
,0);
6216 SysFreeString(true_str
);
6217 SysFreeString(false_str
);
6220 static HRESULT (WINAPI
*pVarCmp
)(LPVARIANT
,LPVARIANT
,LCID
,ULONG
);
6222 static void test_cmp( int line
, LCID lcid
, UINT flags
, VARIANT
*left
, VARIANT
*right
, HRESULT result
)
6226 hres
= pVarCmp(left
,right
,lcid
,flags
);
6227 ok_(__FILE__
,line
)(hres
== result
, "VarCmp(%s,%s): expected 0x%x, got hres=0x%x\n",
6228 variantstr(left
), variantstr(right
), result
, hres
);
6230 static void test_cmpex( int line
, LCID lcid
, VARIANT
*left
, VARIANT
*right
,
6231 HRESULT res1
, HRESULT res2
, HRESULT res3
, HRESULT res4
)
6233 test_cmp( line
, lcid
, 0, left
, right
, res1
);
6234 V_VT(left
) |= VT_RESERVED
;
6235 test_cmp( line
, lcid
, 0, left
, right
, res2
);
6236 V_VT(left
) &= ~VT_RESERVED
;
6237 V_VT(right
) |= VT_RESERVED
;
6238 test_cmp( line
, lcid
, 0, left
, right
, res3
);
6239 V_VT(left
) |= VT_RESERVED
;
6240 test_cmp( line
, lcid
, 0, left
, right
, res4
);
6241 ok_(__FILE__
,line
)(V_VT(left
) & V_VT(right
) & VT_RESERVED
, "VT_RESERVED filtered out\n");
6244 /* ERROR from wingdi.h is interfering here */
6246 #define _VARCMP(vt1,val1,vtfl1,vt2,val2,vtfl2,lcid,flags,result) \
6247 V_##vt1(&left) = val1; V_VT(&left) = VT_##vt1 | vtfl1; \
6248 V_##vt2(&right) = val2; V_VT(&right) = VT_##vt2 | vtfl2; \
6249 test_cmp( __LINE__, lcid, flags, &left, &right, result )
6250 #define VARCMPEX(vt1,val1,vt2,val2,res1,res2,res3,res4) \
6251 V_##vt1(&left) = val1; V_VT(&left) = VT_##vt1; \
6252 V_##vt2(&right) = val2; V_VT(&right) = VT_##vt2; \
6253 test_cmpex( __LINE__, lcid, &left, &right, res1, res2, res3, res4 )
6254 #define VARCMP(vt1,val1,vt2,val2,result) \
6255 VARCMPEX(vt1,val1,vt2,val2,result,result,result,result)
6256 /* The above macros do not work for VT_NULL as NULL gets expanded first */
6257 #define V_NULL_ V_NULL
6258 #define VT_NULL_ VT_NULL
6260 static void test_VarCmp(void)
6262 VARIANT left
, right
;
6267 static const WCHAR szhuh
[] = {'h','u','h','?','\0'};
6268 static const WCHAR sz2cents
[] = {'2','c','e','n','t','s','\0'};
6269 static const WCHAR szempty
[] = {'\0'};
6270 static const WCHAR sz0
[] = {'0','\0'};
6271 static const WCHAR sz1
[] = {'1','\0'};
6272 static const WCHAR sz7
[] = {'7','\0'};
6273 static const WCHAR sz42
[] = {'4','2','\0'};
6274 static const WCHAR sz1neg
[] = {'-','1','\0'};
6275 static const WCHAR sz666neg
[] = {'-','6','6','6','\0'};
6276 static const WCHAR sz1few
[] = {'1','.','0','0','0','0','0','0','0','1','\0'};
6277 BSTR bstrhuh
, bstrempty
, bstr0
, bstr1
, bstr7
, bstr42
, bstr1neg
, bstr666neg
;
6278 BSTR bstr2cents
, bstr1few
;
6282 lcid
= MAKELCID(MAKELANGID(LANG_ENGLISH
,SUBLANG_ENGLISH_US
),SORT_DEFAULT
);
6283 bstrempty
= SysAllocString(szempty
);
6284 bstrhuh
= SysAllocString(szhuh
);
6285 bstr2cents
= SysAllocString(sz2cents
);
6286 bstr0
= SysAllocString(sz0
);
6287 bstr1
= SysAllocString(sz1
);
6288 bstr7
= SysAllocString(sz7
);
6289 bstr42
= SysAllocString(sz42
);
6290 bstr1neg
= SysAllocString(sz1neg
);
6291 bstr666neg
= SysAllocString(sz666neg
);
6292 bstr1few
= SysAllocString(sz1few
);
6294 /* Test all possible flag/vt combinations & the resulting vt type */
6295 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
6297 VARTYPE leftvt
, rightvt
;
6299 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
6304 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
6307 HRESULT expect
= VARCMP_EQ
;
6311 memset(&left
, 0, sizeof(left
));
6312 memset(&right
, 0, sizeof(right
));
6313 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
6314 if (leftvt
== VT_BSTR
) {
6315 V_BSTR(&left
) = bstr1neg
;
6316 if (ExtraFlags
[i
] & VT_RESERVED
)
6321 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
6322 if (rightvt
== VT_BSTR
) {
6323 V_BSTR(&right
) = bstr1neg
;
6324 if (ExtraFlags
[i
] & VT_RESERVED
)
6330 /* Don't ask me why but native VarCmp cannot handle:
6331 VT_I1, VT_UI2, VT_UI4, VT_UINT and VT_UI8.
6332 VT_INT is only supported as left variant. Go figure.
6333 Tested with DCOM98, Win2k, WinXP */
6334 if (ExtraFlags
[i
] & VT_ARRAY
|| ExtraFlags
[i
] & VT_BYREF
||
6335 !IsValidVariantClearVT(leftvt
, ExtraFlags
[i
] & ~VT_RESERVED
) ||
6336 !IsValidVariantClearVT(rightvt
, ExtraFlags
[i
] & ~VT_RESERVED
) ||
6337 leftvt
== VT_CLSID
|| rightvt
== VT_CLSID
||
6338 leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
||
6339 leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
||
6340 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
||
6341 leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
||
6342 leftvt
== VT_VARIANT
|| rightvt
== VT_VARIANT
||
6343 leftvt
== VT_I1
|| rightvt
== VT_I1
||
6344 leftvt
== VT_UI2
|| rightvt
== VT_UI2
||
6345 leftvt
== VT_UI4
|| rightvt
== VT_UI4
||
6346 leftvt
== VT_UI8
|| rightvt
== VT_UI8
||
6347 rightvt
== VT_INT
||
6348 leftvt
== VT_UINT
|| rightvt
== VT_UINT
) {
6352 if (leftvt
== VT_ERROR
&& rightvt
== VT_ERROR
&&
6353 !(ExtraFlags
[i
] & ~VT_RESERVED
)) {
6356 } else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
6357 expect
= VARCMP_NULL
;
6358 else if (leftvt
== VT_BSTR
&& rightvt
== VT_BSTR
)
6360 else if (leftvt
== VT_BSTR
&& rightvt
== VT_EMPTY
)
6362 else if (leftvt
== VT_EMPTY
&& rightvt
== VT_BSTR
)
6365 hres
= pVarCmp(&left
, &right
, LOCALE_USER_DEFAULT
, 0);
6367 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
6368 "VarCmp: %d|0x%X, %d|0x%X: Expected failure, got 0x%X\n",
6369 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], hres
);
6372 "VarCmp: %d|0x%X, %d|0x%X: Expected 0x%X, got 0x%X\n",
6373 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], expect
,
6380 /* VARCMP{,EX} run each 4 tests with a permutation of all possible
6381 input variants with (1) and without (0) VT_RESERVED set. The order
6382 of the permutations is (0,0); (1,0); (0,1); (1,1) */
6383 VARCMP(INT
,4711,I2
,4711,VARCMP_EQ
);
6384 VARCMP(INT
,4711,I2
,-4711,VARCMP_GT
);
6385 VARCMP(ERROR
,0,ERROR
,0,VARCMP_EQ
);
6386 VARCMP(ERROR
,0,UI1
,0,DISP_E_TYPEMISMATCH
);
6387 VARCMP(EMPTY
,0,EMPTY
,0,VARCMP_EQ
);
6388 VARCMP(I4
,1,R8
,1.0,VARCMP_EQ
);
6389 VARCMP(EMPTY
,19,I2
,0,VARCMP_EQ
);
6390 ok(V_EMPTY(&left
) == 19, "VT_EMPTY modified!\n");
6391 VARCMP(I4
,1,UI1
,1,VARCMP_EQ
);
6392 VARCMP(I2
,2,I2
,2,VARCMP_EQ
);
6393 VARCMP(I2
,1,I2
,2,VARCMP_LT
);
6394 VARCMP(I2
,2,I2
,1,VARCMP_GT
);
6395 VARCMP(I2
,2,EMPTY
,1,VARCMP_GT
);
6396 VARCMP(I2
,2,NULL_
,1,VARCMP_NULL
);
6398 /* BSTR handling, especially in conjunction with VT_RESERVED */
6399 VARCMP(BSTR
,bstr0
,NULL_
,0,VARCMP_NULL
);
6400 VARCMP(BSTR
,bstr0
,BSTR
,bstr0
,VARCMP_EQ
);
6401 VARCMP(BSTR
,bstrempty
,BSTR
,bstr0
,VARCMP_LT
);
6402 VARCMP(BSTR
,bstr7
,BSTR
,bstr0
,VARCMP_GT
);
6403 VARCMP(BSTR
,bstr7
,BSTR
,bstr1neg
,VARCMP_GT
);
6404 VARCMP(BSTR
,bstr0
,BSTR
,NULL
,VARCMP_GT
);
6405 VARCMP(BSTR
,NULL
,BSTR
,NULL
,VARCMP_EQ
);
6406 VARCMP(BSTR
,bstrempty
,BSTR
,NULL
,VARCMP_EQ
);
6407 VARCMP(BSTR
,NULL
,EMPTY
,0,VARCMP_EQ
);
6408 VARCMP(EMPTY
,0,BSTR
,NULL
,VARCMP_EQ
);
6409 VARCMP(EMPTY
,0,BSTR
,bstrempty
,VARCMP_EQ
);
6410 VARCMP(EMPTY
,1,BSTR
,bstrempty
,VARCMP_EQ
);
6411 VARCMP(BSTR
,bstr0
,EMPTY
,0,VARCMP_GT
);
6412 VARCMP(BSTR
,bstr42
,EMPTY
,0,VARCMP_GT
);
6413 VARCMPEX(BSTR
,bstrempty
,UI1
,0,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
6414 VARCMPEX(BSTR
,bstrempty
,I2
,-1,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
6415 VARCMPEX(I4
,0,BSTR
,bstrempty
,VARCMP_LT
,VARCMP_LT
,VARCMP_GT
,VARCMP_LT
);
6416 VARCMPEX(BSTR
,NULL
,UI1
,0,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
6417 VARCMPEX(I4
,7,BSTR
,NULL
,VARCMP_LT
,VARCMP_LT
,VARCMP_GT
,VARCMP_LT
);
6418 _VARCMP(BSTR
,(BSTR
)100,0,I2
,100,0,lcid
,0,VARCMP_GT
);
6419 VARCMPEX(BSTR
,bstr0
,UI1
,0,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_GT
);
6420 VARCMPEX(I2
,0,BSTR
,bstr0
,VARCMP_LT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_LT
);
6421 VARCMP(BSTR
,bstrhuh
,I4
,I4_MAX
,VARCMP_GT
);
6422 VARCMP(BSTR
,bstr2cents
,I4
,2,VARCMP_GT
);
6423 VARCMPEX(BSTR
,bstr2cents
,I4
,42,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
6424 VARCMP(BSTR
,bstr2cents
,I4
,-1,VARCMP_GT
);
6425 VARCMPEX(BSTR
,bstr2cents
,I4
,-666,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
6426 VARCMPEX(BSTR
,bstr0
,I2
,0,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_GT
);
6427 VARCMPEX(BSTR
,bstr0
,I4
,0,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_GT
);
6428 VARCMPEX(BSTR
,bstr0
,I4
,-666,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
6429 VARCMP(BSTR
,bstr1
,I4
,0,VARCMP_GT
);
6430 VARCMPEX(BSTR
,bstr1
,I4
,1,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_GT
);
6431 VARCMPEX(BSTR
,bstr1
,I4
,I4_MAX
,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
,VARCMP_GT
);
6432 VARCMPEX(BSTR
,bstr1
,I4
,-1,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
6433 VARCMP(BSTR
,bstr7
,I4
,1,VARCMP_GT
);
6434 VARCMPEX(BSTR
,bstr7
,I4
,7,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_GT
);
6435 VARCMPEX(BSTR
,bstr7
,I4
,42,VARCMP_GT
,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
);
6436 VARCMPEX(BSTR
,bstr42
,I4
,7,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
6437 VARCMPEX(BSTR
,bstr42
,I4
,42,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_GT
);
6438 VARCMPEX(BSTR
,bstr42
,I4
,I4_MAX
,VARCMP_GT
,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
);
6439 VARCMPEX(BSTR
,bstr1neg
,I4
,1,VARCMP_GT
,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
);
6440 VARCMPEX(BSTR
,bstr1neg
,I4
,42,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
,VARCMP_LT
);
6441 VARCMPEX(BSTR
,bstr1neg
,I4
,-1,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_LT
);
6442 VARCMPEX(BSTR
,bstr1neg
,I4
,-666,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_LT
);
6443 VARCMPEX(BSTR
,bstr666neg
,I4
,1,VARCMP_GT
,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
);
6444 VARCMPEX(BSTR
,bstr666neg
,I4
,7,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
,VARCMP_LT
);
6445 VARCMPEX(BSTR
,bstr666neg
,I4
,42,VARCMP_GT
,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
);
6446 VARCMPEX(BSTR
,bstr666neg
,I4
,I4_MAX
,VARCMP_GT
,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
);
6447 VARCMPEX(BSTR
,bstr666neg
,I4
,-1,VARCMP_GT
,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
);
6448 VARCMPEX(BSTR
,bstr666neg
,I4
,-666,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_LT
);
6449 VARCMPEX(BSTR
,bstr7
,R8
,7.0,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_GT
);
6450 VARCMPEX(R8
,3.141592,BSTR
,NULL
,VARCMP_LT
,VARCMP_LT
,VARCMP_GT
,VARCMP_LT
);
6451 VARCMP(BSTR
,bstr7
,BSTR
,bstr7
,VARCMP_EQ
);
6452 VARCMP(BSTR
,bstr7
,BSTR
,bstr42
,VARCMP_GT
);
6453 VARCMP(BSTR
,bstr42
,BSTR
,bstr7
,VARCMP_LT
);
6455 /* DECIMAL handling */
6456 setdec(&dec
,0,0,0,0);
6457 VARCMPEX(DECIMAL
,dec
,BSTR
,bstr0
,VARCMP_LT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_LT
);
6458 setdec64(&dec
,0,0,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF); /* max DECIMAL */
6459 VARCMP(DECIMAL
,dec
,R8
,R8_MAX
,VARCMP_LT
); /* R8 has bigger range */
6460 VARCMP(DECIMAL
,dec
,DATE
,R8_MAX
,VARCMP_LT
); /* DATE has bigger range */
6461 setdec64(&dec
,0,0x80,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF);
6462 VARCMP(DECIMAL
,dec
,R8
,-R8_MAX
,VARCMP_GT
);
6463 setdec64(&dec
,20,0,0x5,0x6BC75E2D,0x63100001); /* 1+1e-20 */
6464 VARCMP(DECIMAL
,dec
,R8
,1,VARCMP_GT
); /* DECIMAL has higher precision */
6466 /* Show that DATE is handled just as a R8 */
6467 VARCMP(DATE
,DATE_MAX
,DATE
,DATE_MAX
+1,VARCMP_LT
);
6468 VARCMP(DATE
,DATE_MIN
,DATE
,DATE_MIN
-1,VARCMP_GT
);
6469 VARCMP(DATE
,R8_MIN
,R8
,R8_MIN
,VARCMP_EQ
);
6470 VARCMP(DATE
,1,DATE
,1+1e-15,VARCMP_LT
); /* 1e-15 == 8.64e-11 seconds */
6471 VARCMP(DATE
,25570.0,DATE
,25570.0,VARCMP_EQ
);
6472 VARCMP(DATE
,25570.0,DATE
,25571.0,VARCMP_LT
);
6473 VARCMP(DATE
,25571.0,DATE
,25570.0,VARCMP_GT
);
6474 VARCMP(DATE
,25570.0,EMPTY
,0,VARCMP_GT
);
6475 VARCMP(DATE
,25570.0,NULL_
,0,VARCMP_NULL
);
6477 /* R4 precision handling */
6478 VARCMP(R4
,1,R8
,1+1e-8,VARCMP_EQ
);
6479 VARCMP(R8
,1+1e-8,R4
,1,VARCMP_EQ
);
6480 VARCMP(R8
,1+1e-8,R8
,1,VARCMP_GT
);
6481 VARCMP(R8
,R4_MAX
*1.1,R4
,R4_MAX
,VARCMP_GT
);
6482 VARCMP(R4
,R4_MAX
,R8
,R8_MAX
,VARCMP_LT
);
6483 VARCMP(R4
,1,DATE
,1+1e-8,VARCMP_EQ
);
6484 VARCMP(R4
,1,BSTR
,bstr1few
,VARCMP_LT
); /* bstr1few == 1+1e-8 */
6485 setdec(&dec
,8,0,0,0x5F5E101); /* 1+1e-8 */
6486 VARCMP(R4
,1,DECIMAL
,dec
,VARCMP_LT
);
6488 SysFreeString(bstrhuh
);
6489 SysFreeString(bstrempty
);
6490 SysFreeString(bstr0
);
6491 SysFreeString(bstr1
);
6492 SysFreeString(bstr7
);
6493 SysFreeString(bstr42
);
6494 SysFreeString(bstr1neg
);
6495 SysFreeString(bstr666neg
);
6496 SysFreeString(bstr2cents
);
6497 SysFreeString(bstr1few
);
6500 static HRESULT (WINAPI
*pVarPow
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
6502 #define VARPOW(vt1,val1,vt2,val2,rvt,rval) \
6503 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
6504 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
6505 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
6506 test_var_call2( __LINE__, pVarPow, &left, &right, &exp )
6508 /* Skip any type that is not defined or produces an error for every case */
6509 #define SKIPTESTPOW(a) \
6510 if (a == VT_ERROR || a == VT_VARIANT || \
6511 a == VT_DISPATCH || a == VT_UNKNOWN || \
6512 a == VT_RECORD || a > VT_UINT || \
6513 a == 15 /*not defined*/) \
6516 static void test_VarPow(void)
6518 static const WCHAR str2
[] = { '2','\0' };
6519 static const WCHAR str3
[] = { '3','\0' };
6520 VARIANT left
, right
, exp
, result
, cy
, dec
;
6521 BSTR num2_str
, num3_str
;
6527 num2_str
= SysAllocString(str2
);
6528 num3_str
= SysAllocString(str3
);
6530 /* Test all possible flag/vt combinations & the resulting vt type */
6531 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
6533 VARTYPE leftvt
, rightvt
, resvt
;
6535 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
6537 SKIPTESTPOW(leftvt
);
6539 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
6542 SKIPTESTPOW(rightvt
);
6544 /* Native crashes with VT_BYREF */
6545 if (ExtraFlags
[i
] == VT_BYREF
)
6548 memset(&left
, 0, sizeof(left
));
6549 memset(&right
, 0, sizeof(right
));
6550 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
6551 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
6552 V_VT(&result
) = VT_EMPTY
;
6555 if (leftvt
== VT_BSTR
)
6556 V_BSTR(&left
) = num2_str
;
6557 if (rightvt
== VT_BSTR
)
6558 V_BSTR(&right
) = num2_str
;
6560 /* Native VarPow always returns an error when using extra flags */
6561 if (ExtraFlags
[i
] != 0)
6564 /* Determine return type */
6565 else if ((leftvt
== VT_NULL
|| rightvt
== VT_NULL
) &&
6566 ((leftvt
!= VT_I8
&& leftvt
!= VT_UI8
&&
6567 rightvt
!= VT_I8
&& rightvt
!= VT_UI8
) || HAVE_OLEAUT32_I8
))
6569 else if ((leftvt
== VT_EMPTY
|| leftvt
== VT_I2
||
6570 leftvt
== VT_I4
|| leftvt
== VT_R4
||
6571 leftvt
== VT_R8
|| leftvt
== VT_CY
||
6572 leftvt
== VT_DATE
|| leftvt
== VT_BSTR
||
6573 leftvt
== VT_BOOL
|| leftvt
== VT_DECIMAL
||
6574 (leftvt
>= VT_I1
&& leftvt
<= VT_UI4
) ||
6575 (HAVE_OLEAUT32_I8
&& (leftvt
== VT_I8
|| leftvt
== VT_UI8
)) ||
6576 leftvt
== VT_INT
|| leftvt
== VT_UINT
) &&
6577 (rightvt
== VT_EMPTY
|| rightvt
== VT_I2
||
6578 rightvt
== VT_I4
|| rightvt
== VT_R4
||
6579 rightvt
== VT_R8
|| rightvt
== VT_CY
||
6580 rightvt
== VT_DATE
|| rightvt
== VT_BSTR
||
6581 rightvt
== VT_BOOL
|| rightvt
== VT_DECIMAL
||
6582 (rightvt
>= VT_I1
&& rightvt
<= VT_UI4
) ||
6583 (HAVE_OLEAUT32_I8
&& (rightvt
== VT_I8
|| rightvt
== VT_UI8
)) ||
6584 rightvt
== VT_INT
|| rightvt
== VT_UINT
))
6589 hres
= pVarPow(&left
, &right
, &result
);
6591 /* Check expected HRESULT and if result variant type is correct */
6593 ok (hres
== DISP_E_BADVARTYPE
|| hres
== DISP_E_TYPEMISMATCH
,
6594 "VarPow: %s|0x%X, %s|0x%X: got vt %s hr 0x%X\n",
6595 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
],
6596 vtstr(V_VT(&result
)), hres
);
6598 ok (hres
== S_OK
&& resvt
== V_VT(&result
),
6599 "VarPow: %s|0x%X, %s|0x%X: expected vt %s hr 0x%X, got vt %s hr 0x%X\n",
6600 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
], vtstr(resvt
),
6601 S_OK
, vtstr(V_VT(&result
)), hres
);
6606 /* Check return values for valid variant type combinations */
6607 VARPOW(EMPTY
,0,EMPTY
,0,R8
,1.0);
6608 VARPOW(EMPTY
,0,NULL
,0,NULL
,0);
6609 VARPOW(EMPTY
,0,I2
,3,R8
,0.0);
6610 VARPOW(EMPTY
,0,I4
,3,R8
,0.0);
6611 VARPOW(EMPTY
,0,R4
,3.0f
,R8
,0.0);
6612 VARPOW(EMPTY
,0,R8
,3.0,R8
,0.0);
6613 VARPOW(EMPTY
,0,DATE
,3,R8
,0.0);
6614 VARPOW(EMPTY
,0,BSTR
,num3_str
,R8
,0.0);
6615 VARPOW(EMPTY
,0,BOOL
,VARIANT_FALSE
,R8
,1.0);
6616 VARPOW(EMPTY
,0,I1
,3,R8
,0.0);
6617 VARPOW(EMPTY
,0,UI1
,3,R8
,0.0);
6618 VARPOW(EMPTY
,0,UI2
,3,R8
,0.0);
6619 VARPOW(EMPTY
,0,UI4
,3,R8
,0.0);
6620 if (HAVE_OLEAUT32_I8
)
6622 VARPOW(EMPTY
,0,I8
,3,R8
,0.0);
6623 VARPOW(EMPTY
,0,UI8
,3,R8
,0.0);
6625 VARPOW(EMPTY
,0,INT
,3,R8
,0.0);
6626 VARPOW(EMPTY
,0,UINT
,3,R8
,0.0);
6627 VARPOW(NULL
,0,EMPTY
,0,NULL
,0);
6628 VARPOW(NULL
,0,NULL
,0,NULL
,0);
6629 VARPOW(NULL
,0,I2
,3,NULL
,0);
6630 VARPOW(NULL
,0,I4
,3,NULL
,0);
6631 VARPOW(NULL
,0,R4
,3.0f
,NULL
,0);
6632 VARPOW(NULL
,0,R8
,3.0,NULL
,0);
6633 VARPOW(NULL
,0,DATE
,3,NULL
,0);
6634 VARPOW(NULL
,0,BSTR
,num3_str
,NULL
,0);
6635 VARPOW(NULL
,0,BOOL
,VARIANT_TRUE
,NULL
,0);
6636 VARPOW(NULL
,0,I1
,3,NULL
,0);
6637 VARPOW(NULL
,0,UI1
,3,NULL
,0);
6638 VARPOW(NULL
,0,UI2
,3,NULL
,0);
6639 VARPOW(NULL
,0,UI4
,3,NULL
,0);
6640 if (HAVE_OLEAUT32_I8
)
6642 VARPOW(NULL
,0,I8
,3,NULL
,0);
6643 VARPOW(NULL
,0,UI8
,3,NULL
,0);
6645 VARPOW(NULL
,0,INT
,3,NULL
,0);
6646 VARPOW(NULL
,0,UINT
,3,NULL
,0);
6647 VARPOW(I2
,2,EMPTY
,0,R8
,1.0);
6648 VARPOW(I2
,2,NULL
,0,NULL
,0);
6649 VARPOW(I2
,2,I2
,3,R8
,8.0);
6650 VARPOW(I2
,2,I4
,3,R8
,8.0);
6651 VARPOW(I2
,2,R4
,3.0f
,R8
,8.0);
6652 VARPOW(I2
,2,R8
,3.0,R8
,8.0);
6653 VARPOW(I2
,2,DATE
,3,R8
,8.0);
6654 VARPOW(I2
,2,BSTR
,num3_str
,R8
,8.0);
6655 VARPOW(I2
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6656 VARPOW(I2
,2,I1
,3,R8
,8.0);
6657 VARPOW(I2
,2,UI1
,3,R8
,8.0);
6658 VARPOW(I2
,2,UI2
,3,R8
,8.0);
6659 VARPOW(I2
,2,UI4
,3,R8
,8.0);
6660 if (HAVE_OLEAUT32_I8
)
6662 VARPOW(I2
,2,I8
,3,R8
,8.0);
6663 VARPOW(I2
,2,UI8
,3,R8
,8.0);
6665 VARPOW(I2
,2,INT
,3,R8
,8.0);
6666 VARPOW(I2
,2,UINT
,3,R8
,8.0);
6667 VARPOW(I4
,2,EMPTY
,0,R8
,1.0);
6668 VARPOW(I4
,2,NULL
,0,NULL
,0);
6669 VARPOW(I4
,2,I2
,3,R8
,8.0);
6670 VARPOW(I4
,2,I4
,3,R8
,8.0);
6671 VARPOW(I4
,2,R4
,3.0f
,R8
,8.0);
6672 VARPOW(I4
,2,R8
,3.0,R8
,8.0);
6673 VARPOW(I4
,2,DATE
,3,R8
,8.0);
6674 VARPOW(I4
,2,BSTR
,num3_str
,R8
,8.0);
6675 VARPOW(I4
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6676 VARPOW(I4
,2,I1
,3,R8
,8.0);
6677 VARPOW(I4
,2,UI1
,3,R8
,8.0);
6678 VARPOW(I4
,2,UI2
,3,R8
,8.0);
6679 VARPOW(I4
,2,UI4
,3,R8
,8.0);
6680 if (HAVE_OLEAUT32_I8
)
6682 VARPOW(I4
,2,I8
,3,R8
,8.0);
6683 VARPOW(I4
,2,UI8
,3,R8
,8.0);
6685 VARPOW(I4
,2,INT
,3,R8
,8.0);
6686 VARPOW(I4
,2,UINT
,3,R8
,8.0);
6687 VARPOW(R4
,2,EMPTY
,0,R8
,1.0);
6688 VARPOW(R4
,2,NULL
,0,NULL
,0);
6689 VARPOW(R4
,2,I2
,3,R8
,8.0);
6690 VARPOW(R4
,2,I4
,3,R8
,8.0);
6691 VARPOW(R4
,2,R4
,3.0f
,R8
,8.0);
6692 VARPOW(R4
,2,R8
,3.0,R8
,8.0);
6693 VARPOW(R4
,2,DATE
,3,R8
,8.0);
6694 VARPOW(R4
,2,BSTR
,num3_str
,R8
,8.0);
6695 VARPOW(R4
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6696 VARPOW(R4
,2,I1
,3,R8
,8.0);
6697 VARPOW(R4
,2,UI1
,3,R8
,8.0);
6698 VARPOW(R4
,2,UI2
,3,R8
,8.0);
6699 VARPOW(R4
,2,UI4
,3,R8
,8.0);
6700 if (HAVE_OLEAUT32_I8
)
6702 VARPOW(R4
,2,I8
,3,R8
,8.0);
6703 VARPOW(R4
,2,UI8
,3,R8
,8.0);
6705 VARPOW(R4
,2,INT
,3,R8
,8.0);
6706 VARPOW(R4
,2,UINT
,3,R8
,8.0);
6707 VARPOW(R8
,2,EMPTY
,0,R8
,1.0);
6708 VARPOW(R8
,2,NULL
,0,NULL
,0);
6709 VARPOW(R8
,2,I2
,3,R8
,8.0);
6710 VARPOW(R8
,2,I4
,3,R8
,8.0);
6711 VARPOW(R8
,2,R4
,3.0f
,R8
,8.0);
6712 VARPOW(R8
,2,R8
,3.0,R8
,8.0);
6713 VARPOW(R8
,2,DATE
,3,R8
,8.0);
6714 VARPOW(R8
,2,BSTR
,num3_str
,R8
,8.0);
6715 VARPOW(R8
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6716 VARPOW(R8
,2,I1
,3,R8
,8.0);
6717 VARPOW(R8
,2,UI1
,3,R8
,8.0);
6718 VARPOW(R8
,2,UI2
,3,R8
,8.0);
6719 VARPOW(R8
,2,UI4
,3,R8
,8.0);
6720 if (HAVE_OLEAUT32_I8
)
6722 VARPOW(R8
,2,I8
,3,R8
,8.0);
6723 VARPOW(R8
,2,UI8
,3,R8
,8.0);
6725 VARPOW(R8
,2,INT
,3,R8
,8.0);
6726 VARPOW(R8
,2,UINT
,3,R8
,8.0);
6727 VARPOW(DATE
,2,EMPTY
,0,R8
,1.0);
6728 VARPOW(DATE
,2,NULL
,0,NULL
,0);
6729 VARPOW(DATE
,2,I2
,3,R8
,8.0);
6730 VARPOW(DATE
,2,I4
,3,R8
,8.0);
6731 VARPOW(DATE
,2,R4
,3.0f
,R8
,8.0);
6732 VARPOW(DATE
,2,R8
,3.0,R8
,8.0);
6733 VARPOW(DATE
,2,DATE
,3,R8
,8.0);
6734 VARPOW(DATE
,2,BSTR
,num3_str
,R8
,8.0);
6735 VARPOW(DATE
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6736 VARPOW(DATE
,2,I1
,3,R8
,8.0);
6737 VARPOW(DATE
,2,UI1
,3,R8
,8.0);
6738 VARPOW(DATE
,2,UI2
,3,R8
,8.0);
6739 VARPOW(DATE
,2,UI4
,3,R8
,8.0);
6740 if (HAVE_OLEAUT32_I8
)
6742 VARPOW(DATE
,2,I8
,3,R8
,8.0);
6743 VARPOW(DATE
,2,UI8
,3,R8
,8.0);
6745 VARPOW(DATE
,2,INT
,3,R8
,8.0);
6746 VARPOW(DATE
,2,UINT
,3,R8
,8.0);
6747 VARPOW(BSTR
,num2_str
,EMPTY
,0,R8
,1.0);
6748 VARPOW(BSTR
,num2_str
,NULL
,0,NULL
,0);
6749 VARPOW(BSTR
,num2_str
,I2
,3,R8
,8.0);
6750 VARPOW(BSTR
,num2_str
,I4
,3,R8
,8.0);
6751 VARPOW(BSTR
,num2_str
,R4
,3.0f
,R8
,8.0);
6752 VARPOW(BSTR
,num2_str
,R8
,3.0,R8
,8.0);
6753 VARPOW(BSTR
,num2_str
,DATE
,3,R8
,8.0);
6754 VARPOW(BSTR
,num2_str
,BSTR
,num3_str
,R8
,8.0);
6755 VARPOW(BSTR
,num2_str
,BOOL
,VARIANT_FALSE
,R8
,1.0);
6756 VARPOW(BSTR
,num2_str
,I1
,3,R8
,8.0);
6757 VARPOW(BSTR
,num2_str
,UI1
,3,R8
,8.0);
6758 VARPOW(BSTR
,num2_str
,UI2
,3,R8
,8.0);
6759 VARPOW(BSTR
,num2_str
,UI4
,3,R8
,8.0);
6760 if (HAVE_OLEAUT32_I8
)
6762 VARPOW(BSTR
,num2_str
,I8
,3,R8
,8.0);
6763 VARPOW(BSTR
,num2_str
,UI8
,3,R8
,8.0);
6765 VARPOW(BSTR
,num2_str
,INT
,3,R8
,8.0);
6766 VARPOW(BSTR
,num2_str
,UINT
,3,R8
,8.0);
6767 VARPOW(BOOL
,VARIANT_TRUE
,EMPTY
,0,R8
,1.0);
6768 VARPOW(BOOL
,VARIANT_TRUE
,NULL
,0,NULL
,0);
6769 VARPOW(BOOL
,VARIANT_TRUE
,I2
,3,R8
,-1.0);
6770 VARPOW(BOOL
,VARIANT_TRUE
,I4
,3,R8
,-1.0);
6771 VARPOW(BOOL
,VARIANT_TRUE
,R4
,3.0f
,R8
,-1.0);
6772 VARPOW(BOOL
,VARIANT_TRUE
,R8
,3.0,R8
,-1.0);
6773 VARPOW(BOOL
,VARIANT_TRUE
,DATE
,3,R8
,-1.0);
6774 VARPOW(BOOL
,VARIANT_TRUE
,BSTR
,num3_str
,R8
,-1.0);
6775 VARPOW(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
,R8
,-1.0);
6776 VARPOW(BOOL
,VARIANT_TRUE
,I1
,3,R8
,-1.0);
6777 VARPOW(BOOL
,VARIANT_TRUE
,UI1
,3,R8
,-1.0);
6778 VARPOW(BOOL
,VARIANT_TRUE
,UI2
,3,R8
,-1.0);
6779 VARPOW(BOOL
,VARIANT_TRUE
,UI4
,3,R8
,-1.0);
6780 if (HAVE_OLEAUT32_I8
)
6782 VARPOW(BOOL
,VARIANT_TRUE
,I8
,3,R8
,-1.0);
6783 VARPOW(BOOL
,VARIANT_TRUE
,UI8
,3,R8
,-1.0);
6785 VARPOW(BOOL
,VARIANT_TRUE
,INT
,3,R8
,-1.0);
6786 VARPOW(BOOL
,VARIANT_TRUE
,UINT
,3,R8
,-1.0);
6787 VARPOW(I1
,2,EMPTY
,0,R8
,1.0);
6788 VARPOW(I1
,2,NULL
,0,NULL
,0);
6789 VARPOW(I1
,2,I2
,3,R8
,8.0);
6790 VARPOW(I1
,2,I4
,3,R8
,8.0);
6791 VARPOW(I1
,2,R4
,3.0f
,R8
,8.0);
6792 VARPOW(I1
,2,R8
,3.0,R8
,8.0);
6793 VARPOW(I1
,2,DATE
,3,R8
,8.0);
6794 VARPOW(I1
,2,BSTR
,num3_str
,R8
,8.0);
6795 VARPOW(I1
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6796 VARPOW(I1
,2,I1
,3,R8
,8.0);
6797 VARPOW(I1
,2,UI1
,3,R8
,8.0);
6798 VARPOW(I1
,2,UI2
,3,R8
,8.0);
6799 VARPOW(I1
,2,UI4
,3,R8
,8.0);
6800 if (HAVE_OLEAUT32_I8
)
6802 VARPOW(I1
,2,I8
,3,R8
,8.0);
6803 VARPOW(I1
,2,UI8
,3,R8
,8.0);
6805 VARPOW(I1
,2,INT
,3,R8
,8.0);
6806 VARPOW(I1
,2,UINT
,3,R8
,8.0);
6807 VARPOW(UI1
,2,EMPTY
,0,R8
,1.0);
6808 VARPOW(UI1
,2,NULL
,0,NULL
,0);
6809 VARPOW(UI1
,2,I2
,3,R8
,8.0);
6810 VARPOW(UI1
,2,I4
,3,R8
,8.0);
6811 VARPOW(UI1
,2,R4
,3.0f
,R8
,8.0);
6812 VARPOW(UI1
,2,R8
,3.0,R8
,8.0);
6813 VARPOW(UI1
,2,DATE
,3,R8
,8.0);
6814 VARPOW(UI1
,2,BSTR
,num3_str
,R8
,8.0);
6815 VARPOW(UI1
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6816 VARPOW(UI1
,2,I1
,3,R8
,8.0);
6817 VARPOW(UI1
,2,UI1
,3,R8
,8.0);
6818 VARPOW(UI1
,2,UI2
,3,R8
,8.0);
6819 VARPOW(UI1
,2,UI4
,3,R8
,8.0);
6820 if (HAVE_OLEAUT32_I8
)
6822 VARPOW(UI1
,2,I8
,3,R8
,8.0);
6823 VARPOW(UI1
,2,UI8
,3,R8
,8.0);
6825 VARPOW(UI1
,2,INT
,3,R8
,8.0);
6826 VARPOW(UI1
,2,UINT
,3,R8
,8.0);
6827 VARPOW(UI2
,2,EMPTY
,0,R8
,1.0);
6828 VARPOW(UI2
,2,NULL
,0,NULL
,0);
6829 VARPOW(UI2
,2,I2
,3,R8
,8.0);
6830 VARPOW(UI2
,2,I4
,3,R8
,8.0);
6831 VARPOW(UI2
,2,R4
,3.0f
,R8
,8.0);
6832 VARPOW(UI2
,2,R8
,3.0,R8
,8.0);
6833 VARPOW(UI2
,2,DATE
,3,R8
,8.0);
6834 VARPOW(UI2
,2,BSTR
,num3_str
,R8
,8.0);
6835 VARPOW(UI2
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6836 VARPOW(UI2
,2,I1
,3,R8
,8.0);
6837 VARPOW(UI2
,2,UI1
,3,R8
,8.0);
6838 VARPOW(UI2
,2,UI2
,3,R8
,8.0);
6839 VARPOW(UI2
,2,UI4
,3,R8
,8.0);
6840 if (HAVE_OLEAUT32_I8
)
6842 VARPOW(UI2
,2,I8
,3,R8
,8.0);
6843 VARPOW(UI2
,2,UI8
,3,R8
,8.0);
6845 VARPOW(UI2
,2,INT
,3,R8
,8.0);
6846 VARPOW(UI2
,2,UINT
,3,R8
,8.0);
6847 VARPOW(UI4
,2,EMPTY
,0,R8
,1.0);
6848 VARPOW(UI4
,2,NULL
,0,NULL
,0);
6849 VARPOW(UI4
,2,I2
,3,R8
,8.0);
6850 VARPOW(UI4
,2,I4
,3,R8
,8.0);
6851 VARPOW(UI4
,2,R4
,3.0f
,R8
,8.0);
6852 VARPOW(UI4
,2,R8
,3.0,R8
,8.0);
6853 VARPOW(UI4
,2,DATE
,3,R8
,8.0);
6854 VARPOW(UI4
,2,BSTR
,num3_str
,R8
,8.0);
6855 VARPOW(UI4
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6856 VARPOW(UI4
,2,I1
,3,R8
,8.0);
6857 VARPOW(UI4
,2,UI1
,3,R8
,8.0);
6858 VARPOW(UI4
,2,UI2
,3,R8
,8.0);
6859 VARPOW(UI4
,2,UI4
,3,R8
,8.0);
6860 if (HAVE_OLEAUT32_I8
)
6862 VARPOW(UI4
,2,I8
,3,R8
,8.0);
6863 VARPOW(UI4
,2,UI8
,3,R8
,8.0);
6865 VARPOW(UI4
,2,INT
,3,R8
,8.0);
6866 VARPOW(UI4
,2,UINT
,3,R8
,8.0);
6867 if (HAVE_OLEAUT32_I8
)
6869 VARPOW(I8
,2,EMPTY
,0,R8
,1.0);
6870 VARPOW(I8
,2,NULL
,0,NULL
,0);
6871 VARPOW(I8
,2,I2
,3,R8
,8.0);
6872 VARPOW(I8
,2,I4
,3,R8
,8.0);
6873 VARPOW(I8
,2,R4
,3.0f
,R8
,8.0);
6874 VARPOW(I8
,2,R8
,3.0,R8
,8.0);
6875 VARPOW(I8
,2,DATE
,3,R8
,8.0);
6876 VARPOW(I8
,2,BSTR
,num3_str
,R8
,8.0);
6877 VARPOW(I8
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6878 VARPOW(I8
,2,I1
,3,R8
,8.0);
6879 VARPOW(I8
,2,UI1
,3,R8
,8.0);
6880 VARPOW(I8
,2,UI2
,3,R8
,8.0);
6881 VARPOW(I8
,2,UI4
,3,R8
,8.0);
6882 VARPOW(I8
,2,I8
,3,R8
,8.0);
6883 VARPOW(I8
,2,UI8
,3,R8
,8.0);
6884 VARPOW(I8
,2,INT
,3,R8
,8.0);
6885 VARPOW(I8
,2,UINT
,3,R8
,8.0);
6886 VARPOW(UI8
,2,EMPTY
,0,R8
,1.0);
6887 VARPOW(UI8
,2,NULL
,0,NULL
,0);
6888 VARPOW(UI8
,2,I2
,3,R8
,8.0);
6889 VARPOW(UI8
,2,I4
,3,R8
,8.0);
6890 VARPOW(UI8
,2,R4
,3.0f
,R8
,8.0);
6891 VARPOW(UI8
,2,R8
,3.0,R8
,8.0);
6892 VARPOW(UI8
,2,DATE
,3,R8
,8.0);
6893 VARPOW(UI8
,2,BSTR
,num3_str
,R8
,8.0);
6894 VARPOW(UI8
,2,I1
,3,R8
,8.0);
6895 VARPOW(UI8
,2,UI1
,3,R8
,8.0);
6896 VARPOW(UI8
,2,UI2
,3,R8
,8.0);
6897 VARPOW(UI8
,2,UI4
,3,R8
,8.0);
6898 VARPOW(UI8
,2,I8
,3,R8
,8.0);
6899 VARPOW(UI8
,2,UI8
,3,R8
,8.0);
6900 VARPOW(UI8
,2,INT
,3,R8
,8.0);
6901 VARPOW(UI8
,2,UINT
,3,R8
,8.0);
6903 VARPOW(INT
,2,EMPTY
,0,R8
,1.0);
6904 VARPOW(INT
,2,NULL
,0,NULL
,0);
6905 VARPOW(INT
,2,I2
,3,R8
,8.0);
6906 VARPOW(INT
,2,I4
,3,R8
,8.0);
6907 VARPOW(INT
,2,R4
,3.0f
,R8
,8.0);
6908 VARPOW(INT
,2,R8
,3.0,R8
,8.0);
6909 VARPOW(INT
,2,DATE
,3,R8
,8.0);
6910 VARPOW(INT
,2,BSTR
,num3_str
,R8
,8.0);
6911 VARPOW(INT
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6912 VARPOW(INT
,2,I1
,3,R8
,8.0);
6913 VARPOW(INT
,2,UI1
,3,R8
,8.0);
6914 VARPOW(INT
,2,UI2
,3,R8
,8.0);
6915 VARPOW(INT
,2,UI4
,3,R8
,8.0);
6916 if (HAVE_OLEAUT32_I8
)
6918 VARPOW(INT
,2,I8
,3,R8
,8.0);
6919 VARPOW(INT
,2,UI8
,3,R8
,8.0);
6921 VARPOW(INT
,2,INT
,3,R8
,8.0);
6922 VARPOW(INT
,2,UINT
,3,R8
,8.0);
6923 VARPOW(UINT
,2,EMPTY
,0,R8
,1.0);
6924 VARPOW(UINT
,2,NULL
,0,NULL
,0);
6925 VARPOW(UINT
,2,I2
,3,R8
,8.0);
6926 VARPOW(UINT
,2,I4
,3,R8
,8.0);
6927 VARPOW(UINT
,2,R4
,3.0f
,R8
,8.0);
6928 VARPOW(UINT
,2,R8
,3.0,R8
,8.0);
6929 VARPOW(UINT
,2,DATE
,3,R8
,8.0);
6930 VARPOW(UINT
,2,BSTR
,num3_str
,R8
,8.0);
6931 VARPOW(UINT
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6932 VARPOW(UINT
,2,I1
,3,R8
,8.0);
6933 VARPOW(UINT
,2,UI1
,3,R8
,8.0);
6934 VARPOW(UINT
,2,UI2
,3,R8
,8.0);
6935 VARPOW(UINT
,2,UI4
,3,R8
,8.0);
6936 if (HAVE_OLEAUT32_I8
)
6938 VARPOW(UINT
,2,I8
,3,R8
,8.0);
6939 VARPOW(UINT
,2,UI8
,3,R8
,8.0);
6941 VARPOW(UINT
,2,INT
,3,R8
,8.0);
6942 VARPOW(UINT
,2,UINT
,3,R8
,8.0);
6944 /* Manually test some VT_CY, VT_DECIMAL variants */
6946 hres
= VarCyFromI4(2, &V_CY(&cy
));
6947 ok(hres
== S_OK
, "VarCyFromI4 failed!\n");
6948 V_VT(&dec
) = VT_DECIMAL
;
6949 hres
= VarDecFromR8(2.0, &V_DECIMAL(&dec
));
6950 ok(hres
== S_OK
, "VarDecFromR4 failed!\n");
6951 memset(&left
, 0, sizeof(left
));
6952 memset(&right
, 0, sizeof(right
));
6953 V_VT(&left
) = VT_I4
;
6955 V_VT(&right
) = VT_I8
;
6958 hres
= pVarPow(&cy
, &cy
, &result
);
6959 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
6960 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
6961 S_OK
, hres
, vtstr(V_VT(&result
)));
6962 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 4.0),
6963 "VARPOW: CY value %f, expected %f\n", V_R8(&result
), 4.0);
6965 hres
= pVarPow(&cy
, &right
, &result
);
6968 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
6969 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
6970 S_OK
, hres
, vtstr(V_VT(&result
)));
6971 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 4.0),
6972 "VARPOW: CY value %f, expected %f\n", V_R8(&result
), 4.0);
6976 ok(hres
== DISP_E_BADVARTYPE
&& V_VT(&result
) == VT_EMPTY
,
6977 "VARPOW: expected coerced hres 0x%X type VT_EMPTY, got hres 0x%X type %s!\n",
6978 DISP_E_BADVARTYPE
, hres
, vtstr(V_VT(&result
)));
6981 hres
= pVarPow(&left
, &cy
, &result
);
6982 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
6983 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
6984 S_OK
, hres
, vtstr(V_VT(&result
)));
6985 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 10000.0),
6986 "VARPOW: CY value %f, expected %f\n", V_R8(&result
), 10000.0);
6988 hres
= pVarPow(&left
, &dec
, &result
);
6989 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
6990 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
6991 S_OK
, hres
, vtstr(V_VT(&result
)));
6992 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
),10000.0),
6993 "VARPOW: DECIMAL value %f, expected %f\n", V_R8(&result
), 10000.0);
6995 hres
= pVarPow(&dec
, &dec
, &result
);
6996 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
6997 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
6998 S_OK
, hres
, vtstr(V_VT(&result
)));
6999 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 4.0),
7000 "VARPOW: DECIMAL value %f, expected %f\n", V_R8(&result
), 4.0);
7002 hres
= pVarPow(&dec
, &right
, &result
);
7005 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
7006 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
7007 S_OK
, hres
, vtstr(V_VT(&result
)));
7008 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 4.0),
7009 "VARPOW: DECIMAL value %f, expected %f\n", V_R8(&result
), 4.0);
7013 ok(hres
== DISP_E_BADVARTYPE
&& V_VT(&result
) == VT_EMPTY
,
7014 "VARPOW: expected coerced hres 0x%X type VT_EMPTY, got hres 0x%X type %s!\n",
7015 DISP_E_BADVARTYPE
, hres
, vtstr(V_VT(&result
)));
7018 SysFreeString(num2_str
);
7019 SysFreeString(num3_str
);
7022 static HRESULT (WINAPI
*pVarDiv
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
7024 #define VARDIV(vt1,val1,vt2,val2,rvt,rval) \
7025 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
7026 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
7027 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
7028 test_var_call2( __LINE__, pVarDiv, &left, &right, &exp )
7030 /* Skip any type that is not defined or produces an error for every case */
7031 #define SKIPTESTDIV(a) \
7032 if (a == VT_ERROR || a == VT_VARIANT || \
7033 a == VT_DISPATCH || a == VT_UNKNOWN || \
7034 a == VT_RECORD || a > VT_UINT || \
7035 a == VT_I1 || a == VT_UI8 || \
7036 a == VT_INT || a == VT_UINT || \
7037 a == VT_UI2 || a == VT_UI4 || \
7038 a == 15 /*not defined*/) \
7041 static void test_VarDiv(void)
7043 static const WCHAR str1
[] = { '1','\0' };
7044 static const WCHAR str2
[] = { '2','\0' };
7045 VARIANT left
, right
, exp
, result
, cy
, dec
;
7046 BSTR num1_str
, num2_str
;
7048 HRESULT hres
, expectedhres
;
7051 num1_str
= SysAllocString(str1
);
7052 num2_str
= SysAllocString(str2
);
7056 /* Test all possible flag/vt combinations & the resulting vt type */
7057 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
7059 VARTYPE leftvt
, rightvt
, resvt
;
7061 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
7063 SKIPTESTDIV(leftvt
);
7065 /* Check if we need/have support for I8 */
7066 if (leftvt
== VT_I8
&& !HAVE_OLEAUT32_I8
)
7069 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
7072 SKIPTESTDIV(rightvt
);
7074 /* Check if we need/have support for I8 */
7075 if (rightvt
== VT_I8
&& !HAVE_OLEAUT32_I8
)
7078 /* Native crashes with VT_BYREF */
7079 if (ExtraFlags
[i
] == VT_BYREF
)
7082 memset(&left
, 0, sizeof(left
));
7083 memset(&right
, 0, sizeof(right
));
7084 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
7085 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
7086 V_VT(&result
) = VT_EMPTY
;
7088 expectedhres
= S_OK
;
7090 if (leftvt
== VT_BSTR
)
7091 V_BSTR(&left
) = num2_str
;
7092 else if (leftvt
== VT_DECIMAL
)
7094 VarDecFromR8(2.0, &V_DECIMAL(&left
));
7095 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
7098 /* Division by 0 is undefined */
7102 V_BSTR(&right
) = num2_str
;
7105 VarDecFromR8(2.0, &V_DECIMAL(&right
));
7106 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
7109 V_BOOL(&right
) = VARIANT_TRUE
;
7111 case VT_I2
: V_I2(&right
) = 2; break;
7112 case VT_I4
: V_I4(&right
) = 2; break;
7113 case VT_R4
: V_R4(&right
) = 2.0f
; break;
7114 case VT_R8
: V_R8(&right
) = 2.0; break;
7115 case VT_CY
: V_CY(&right
).int64
= 2; break;
7116 case VT_DATE
: V_DATE(&right
) = 2; break;
7117 case VT_UI1
: V_UI1(&right
) = 2; break;
7118 case VT_I8
: V_I8(&right
) = 2; break;
7122 /* Determine return type */
7123 if (!(rightvt
== VT_EMPTY
))
7125 if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
7127 else if (leftvt
== VT_DECIMAL
|| rightvt
== VT_DECIMAL
)
7129 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
||
7130 leftvt
== VT_CY
|| rightvt
== VT_CY
||
7131 leftvt
== VT_DATE
|| rightvt
== VT_DATE
||
7132 leftvt
== VT_I4
|| rightvt
== VT_I4
||
7133 leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
||
7134 leftvt
== VT_I2
|| rightvt
== VT_I2
||
7135 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
||
7136 leftvt
== VT_R8
|| rightvt
== VT_R8
||
7137 leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
7139 if ((leftvt
== VT_UI1
&& rightvt
== VT_R4
) ||
7140 (leftvt
== VT_R4
&& rightvt
== VT_UI1
))
7142 else if ((leftvt
== VT_R4
&& (rightvt
== VT_BOOL
||
7143 rightvt
== VT_I2
)) || (rightvt
== VT_R4
&&
7144 (leftvt
== VT_BOOL
|| leftvt
== VT_I2
)))
7149 else if (leftvt
== VT_R4
|| rightvt
== VT_R4
)
7152 else if (leftvt
== VT_NULL
&& rightvt
== VT_EMPTY
)
7157 /* Native VarDiv always returns an error when using extra flags */
7158 if (ExtraFlags
[i
] != 0)
7161 hres
= pVarDiv(&left
, &right
, &result
);
7163 /* Check expected HRESULT and if result variant type is correct */
7165 ok (hres
== DISP_E_BADVARTYPE
|| hres
== DISP_E_TYPEMISMATCH
||
7166 hres
== DISP_E_OVERFLOW
|| hres
== DISP_E_DIVBYZERO
,
7167 "VarDiv: %s|0x%X, %s|0x%X: got vt %s hr 0x%X\n",
7168 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
],
7169 vtstr(V_VT(&result
)), hres
);
7171 ok (hres
== S_OK
&& resvt
== V_VT(&result
),
7172 "VarDiv: %s|0x%X, %s|0x%X: expected vt %s hr 0x%X, got vt %s hr 0x%X\n",
7173 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
], vtstr(resvt
),
7174 S_OK
, vtstr(V_VT(&result
)), hres
);
7179 /* Test return values for all the good cases */
7180 VARDIV(EMPTY
,0,NULL
,0,NULL
,0);
7181 VARDIV(EMPTY
,0,I2
,2,R8
,0.0);
7182 VARDIV(EMPTY
,0,I4
,2,R8
,0.0);
7183 VARDIV(EMPTY
,0,R4
,2.0f
,R4
,0.0f
);
7184 VARDIV(EMPTY
,0,R8
,2.0,R8
,0.0);
7185 VARDIV(EMPTY
,0,DATE
,2.0,R8
,0.0);
7186 VARDIV(EMPTY
,0,BSTR
,num2_str
,R8
,0.0);
7187 VARDIV(EMPTY
,0,BOOL
,VARIANT_TRUE
,R8
,0.0);
7188 VARDIV(EMPTY
,0,UI1
,2,R8
,0.0);
7189 if (HAVE_OLEAUT32_I8
)
7191 VARDIV(EMPTY
,0,I8
,2,R8
,0.0);
7193 VARDIV(NULL
,0,EMPTY
,0,NULL
,0);
7194 VARDIV(NULL
,0,NULL
,0,NULL
,0);
7195 VARDIV(NULL
,0,I2
,2,NULL
,0);
7196 VARDIV(NULL
,0,I4
,2,NULL
,0);
7197 VARDIV(NULL
,0,R4
,2.0f
,NULL
,0);
7198 VARDIV(NULL
,0,R8
,2.0,NULL
,0);
7199 VARDIV(NULL
,0,DATE
,2,NULL
,0);
7200 VARDIV(NULL
,0,BSTR
,num2_str
,NULL
,0);
7201 VARDIV(NULL
,0,BOOL
,VARIANT_TRUE
,NULL
,0);
7202 VARDIV(NULL
,0,UI1
,2,NULL
,0);
7203 if (HAVE_OLEAUT32_I8
)
7205 VARDIV(NULL
,0,I8
,2,NULL
,0);
7207 VARDIV(I2
,2,NULL
,0,NULL
,0);
7208 VARDIV(I2
,1,I2
,2,R8
,0.5);
7209 VARDIV(I2
,1,I4
,2,R8
,0.5);
7210 VARDIV(I2
,1,R4
,2,R4
,0.5f
);
7211 VARDIV(I2
,1,R8
,2.0,R8
,0.5);
7212 VARDIV(I2
,1,DATE
,2,R8
,0.5);
7213 VARDIV(I2
,1,BOOL
,VARIANT_TRUE
,R8
,-1.0);
7214 VARDIV(I2
,1,UI1
,2,R8
,0.5);
7215 if (HAVE_OLEAUT32_I8
)
7217 VARDIV(I2
,1,I8
,2,R8
,0.5);
7219 VARDIV(I4
,1,NULL
,0,NULL
,0);
7220 VARDIV(I4
,1,I2
,2,R8
,0.5);
7221 VARDIV(I4
,1,I4
,2,R8
,0.5);
7222 VARDIV(I4
,1,R4
,2.0f
,R8
,0.5);
7223 VARDIV(I4
,1,R8
,2.0,R8
,0.5);
7224 VARDIV(I4
,1,DATE
,2,R8
,0.5);
7225 VARDIV(I4
,1,BSTR
,num2_str
,R8
,0.5);
7226 VARDIV(I4
,1,BOOL
,VARIANT_TRUE
,R8
,-1.0);
7227 VARDIV(I4
,1,UI1
,2,R8
,0.5);
7228 if (HAVE_OLEAUT32_I8
)
7230 VARDIV(I4
,1,I8
,2,R8
,0.5);
7232 VARDIV(R4
,1.0f
,NULL
,0,NULL
,0);
7233 VARDIV(R4
,1.0f
,I2
,2,R4
,0.5f
);
7234 VARDIV(R4
,1.0f
,I4
,2,R8
,0.5);
7235 VARDIV(R4
,1.0f
,R4
,2.0f
,R4
,0.5f
);
7236 VARDIV(R4
,1.0f
,R8
,2.0,R8
,0.5);
7237 VARDIV(R4
,1.0f
,DATE
,2,R8
,0.5);
7238 VARDIV(R4
,1.0f
,BSTR
,num2_str
,R8
,0.5);
7239 VARDIV(R4
,1.0f
,BOOL
,VARIANT_TRUE
,R4
,-1);
7240 VARDIV(R4
,1.0f
,UI1
,2,R4
,0.5f
);
7241 if (HAVE_OLEAUT32_I8
)
7243 VARDIV(R4
,1.0f
,I8
,2,R8
,0.5);
7245 VARDIV(R8
,1.0,NULL
,0,NULL
,0);
7246 VARDIV(R8
,1.0,I2
,2,R8
,0.5);
7247 VARDIV(R8
,1.0,I4
,2,R8
,0.5);
7248 VARDIV(R8
,1.0,R4
,2.0f
,R8
,0.5);
7249 VARDIV(R8
,1.0,R8
,2.0,R8
,0.5);
7250 VARDIV(R8
,1.0,DATE
,2,R8
,0.5);
7251 VARDIV(R8
,1.0,BSTR
,num2_str
,R8
,0.5);
7252 VARDIV(R8
,1.0,BOOL
,VARIANT_TRUE
,R8
,-1.0);
7253 VARDIV(R8
,1.0,UI1
,2,R8
,0.5);
7254 if (HAVE_OLEAUT32_I8
)
7256 VARDIV(R8
,1.0,I8
,2,R8
,0.5);
7258 VARDIV(DATE
,1,NULL
,0,NULL
,0);
7259 VARDIV(DATE
,1,I2
,2,R8
,0.5);
7260 VARDIV(DATE
,1,I4
,2,R8
,0.5);
7261 VARDIV(DATE
,1,R4
,2.0f
,R8
,0.5);
7262 VARDIV(DATE
,1,R8
,2.0,R8
,0.5);
7263 VARDIV(DATE
,1,DATE
,2,R8
,0.5);
7264 VARDIV(DATE
,1,BSTR
,num2_str
,R8
,0.5);
7265 VARDIV(DATE
,1,BOOL
,VARIANT_TRUE
,R8
,-1.0);
7266 VARDIV(DATE
,1,UI1
,2,R8
,0.5);
7267 if (HAVE_OLEAUT32_I8
)
7269 VARDIV(DATE
,1,I8
,2,R8
,0.5);
7271 VARDIV(BSTR
,num1_str
,NULL
,0,NULL
,0);
7272 VARDIV(BSTR
,num1_str
,I2
,2,R8
,0.5);
7273 VARDIV(BSTR
,num1_str
,I4
,2,R8
,0.5);
7274 VARDIV(BSTR
,num1_str
,R4
,2.0f
,R8
,0.5);
7275 VARDIV(BSTR
,num1_str
,R8
,2.0,R8
,0.5);
7276 VARDIV(BSTR
,num1_str
,DATE
,2,R8
,0.5);
7277 VARDIV(BSTR
,num1_str
,BSTR
,num2_str
,R8
,0.5);
7278 VARDIV(BSTR
,num1_str
,BOOL
,VARIANT_TRUE
,R8
,-1);
7279 VARDIV(BSTR
,num1_str
,UI1
,2,R8
,0.5);
7280 if (HAVE_OLEAUT32_I8
)
7282 VARDIV(BSTR
,num1_str
,I8
,2,R8
,0.5);
7284 VARDIV(BOOL
,VARIANT_TRUE
,NULL
,0,NULL
,0);
7285 VARDIV(BOOL
,VARIANT_TRUE
,I2
,1,R8
,-1.0);
7286 VARDIV(BOOL
,VARIANT_FALSE
,I2
,1,R8
,0.0);
7287 VARDIV(BOOL
,VARIANT_TRUE
,I4
,1,R8
,-1.0);
7288 VARDIV(BOOL
,VARIANT_FALSE
,I4
,1,R8
,0.0);
7289 VARDIV(BOOL
,VARIANT_TRUE
,R4
,1,R4
,-1.0f
);
7290 VARDIV(BOOL
,VARIANT_FALSE
,R4
,1,R4
,0.0f
);
7291 VARDIV(BOOL
,VARIANT_TRUE
,R8
,1.0,R8
,-1.0);
7292 VARDIV(BOOL
,VARIANT_FALSE
,R8
,1.0,R8
,0.0);
7293 VARDIV(BOOL
,VARIANT_FALSE
,DATE
,2,R8
,0.0);
7294 VARDIV(BOOL
,VARIANT_FALSE
,BSTR
,num2_str
,R8
,0.0);
7295 VARDIV(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
,R8
,1.0);
7296 VARDIV(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
,R8
,0.0);
7297 VARDIV(BOOL
,VARIANT_TRUE
,UI1
,1,R8
,-1.0);
7298 if (HAVE_OLEAUT32_I8
)
7300 VARDIV(BOOL
,VARIANT_TRUE
,I8
,1,R8
,-1.0);
7302 VARDIV(UI1
,1,NULL
,0,NULL
,0);
7303 VARDIV(UI1
,1,I2
,2,R8
,0.5);
7304 VARDIV(UI1
,1,I4
,2,R8
,0.5);
7305 VARDIV(UI1
,1,R4
,2.0f
,R4
,0.5f
);
7306 VARDIV(UI1
,1,R8
,2.0,R8
,0.5);
7307 VARDIV(UI1
,1,DATE
,2,R8
,0.5);
7308 VARDIV(UI1
,1,BSTR
,num2_str
,R8
,0.5);
7309 VARDIV(UI1
,1,BOOL
,VARIANT_TRUE
,R8
,-1);
7310 VARDIV(UI1
,1,UI1
,2,R8
,0.5);
7311 if (HAVE_OLEAUT32_I8
)
7313 VARDIV(UI1
,1,I8
,2,R8
,0.5);
7314 VARDIV(I8
,1,NULL
,0,NULL
,0);
7315 VARDIV(I8
,1,I2
,2,R8
,0.5);
7316 VARDIV(I8
,1,I4
,2,R8
,0.5);
7317 VARDIV(I8
,1,R4
,2.0f
,R8
,0.5);
7318 VARDIV(I8
,1,R8
,2.0,R8
,0.5);
7319 VARDIV(I8
,1,DATE
,2,R8
,0.5);
7320 VARDIV(I8
,1,BSTR
,num2_str
,R8
,0.5);
7321 VARDIV(I8
,1,BOOL
,VARIANT_TRUE
,R8
,-1);
7322 VARDIV(I8
,1,UI1
,2,R8
,0.5);
7323 VARDIV(I8
,1,I8
,2,R8
,0.5);
7326 /* Manually test some VT_CY, VT_DECIMAL variants */
7328 hres
= VarCyFromI4(10000, &V_CY(&cy
));
7329 ok(hres
== S_OK
, "VarCyFromI4 failed!\n");
7330 V_VT(&dec
) = VT_DECIMAL
;
7331 hres
= VarDecFromR8(2.0, &V_DECIMAL(&dec
));
7332 ok(hres
== S_OK
, "VarDecFromR4 failed!\n");
7333 memset(&left
, 0, sizeof(left
));
7334 memset(&right
, 0, sizeof(right
));
7335 V_VT(&left
) = VT_I4
;
7337 V_VT(&right
) = VT_UI1
;
7340 hres
= pVarDiv(&cy
, &cy
, &result
);
7341 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
7342 "VARDIV: expected coerced type VT_R8, got %s!\n", vtstr(V_VT(&result
)));
7343 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 1.0),
7344 "VARDIV: CY value %f, expected %f\n", V_R8(&result
), (double)1.0);
7346 hres
= pVarDiv(&cy
, &right
, &result
);
7347 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
7348 "VARDIV: expected coerced type VT_R8, got %s!\n", vtstr(V_VT(&result
)));
7349 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 5000.0),
7350 "VARDIV: CY value %f, expected %f\n", V_R8(&result
), (double)5000.0);
7352 hres
= pVarDiv(&left
, &cy
, &result
);
7353 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
7354 "VARDIV: expected coerced type VT_R8, got %s!\n", vtstr(V_VT(&result
)));
7355 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 0.01),
7356 "VARDIV: CY value %f, expected %f\n", V_R8(&result
), (double)0.01);
7358 hres
= pVarDiv(&left
, &dec
, &result
);
7359 ok(hres
== S_OK
&& V_VT(&result
) == VT_DECIMAL
,
7360 "VARDIV: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result
)));
7361 hres
= VarR8FromDec(&V_DECIMAL(&result
), &r
);
7362 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 50.0),
7363 "VARDIV: DECIMAL value %f, expected %f\n", r
, (double)50.0);
7365 hres
= pVarDiv(&dec
, &dec
, &result
);
7366 ok(hres
== S_OK
&& V_VT(&result
) == VT_DECIMAL
,
7367 "VARDIV: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result
)));
7368 hres
= VarR8FromDec(&V_DECIMAL(&result
), &r
);
7369 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 1.0),
7370 "VARDIV: DECIMAL value %f, expected %f\n", r
, (double)1.0);
7372 hres
= pVarDiv(&dec
, &right
, &result
);
7373 ok(hres
== S_OK
&& V_VT(&result
) == VT_DECIMAL
,
7374 "VARDIV: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result
)));
7375 hres
= VarR8FromDec(&V_DECIMAL(&result
), &r
);
7376 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 1.0),
7377 "VARDIV: DECIMAL value %f, expected %f\n", r
, (double)1.0);
7379 /* Check for division by zero and overflow */
7380 V_VT(&left
) = VT_R8
;
7382 V_VT(&right
) = VT_R8
;
7384 hres
= pVarDiv(&left
, &right
, &result
);
7385 ok(hres
== DISP_E_DIVBYZERO
&& V_VT(&result
) == VT_EMPTY
,
7386 "VARDIV: Division by (1.0/0.0) should result in DISP_E_DIVBYZERO but got 0x%X\n", hres
);
7388 V_VT(&left
) = VT_R8
;
7390 V_VT(&right
) = VT_R8
;
7392 hres
= pVarDiv(&left
, &right
, &result
);
7393 ok(hres
== DISP_E_OVERFLOW
&& V_VT(&result
) == VT_EMPTY
,
7394 "VARDIV: Division by (0.0/0.0) should result in DISP_E_OVERFLOW but got 0x%X\n", hres
);
7396 SysFreeString(num1_str
);
7397 SysFreeString(num2_str
);
7400 static HRESULT (WINAPI
*pVarIdiv
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
7402 #define VARIDIV(vt1,val1,vt2,val2,rvt,rval) \
7403 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
7404 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
7405 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
7406 test_var_call2( __LINE__, pVarIdiv, &left, &right, &exp )
7408 /* Skip any type that is not defined or produces an error for every case */
7409 #define SKIPTESTIDIV(a) \
7410 if (a == VT_ERROR || a == VT_VARIANT || \
7411 a == VT_DISPATCH || a == VT_UNKNOWN || \
7412 a == VT_RECORD || a > VT_UINT || \
7413 a == 15 /*not defined*/) \
7416 static void test_VarIdiv(void)
7418 static const WCHAR str1
[] = { '1','\0' };
7419 static const WCHAR str2
[] = { '2','\0' };
7420 VARIANT left
, right
, exp
, result
, cy
, dec
;
7421 BSTR num1_str
, num2_str
;
7427 num1_str
= SysAllocString(str1
);
7428 num2_str
= SysAllocString(str2
);
7430 /* Test all possible flag/vt combinations & the resulting vt type */
7431 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
7433 VARTYPE leftvt
, rightvt
, resvt
;
7435 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
7437 SKIPTESTIDIV(leftvt
);
7439 /* Check if we need/have support for I8 and/or UI8 */
7440 if ((leftvt
== VT_I8
|| leftvt
== VT_UI8
) && !HAVE_OLEAUT32_I8
)
7443 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
7446 SKIPTESTIDIV(rightvt
);
7448 /* Native crashes with extra flag VT_BYREF */
7449 if (ExtraFlags
[i
] == VT_BYREF
)
7452 /* Check if we need/have support for I8 and/or UI8 */
7453 if ((rightvt
== VT_I8
|| rightvt
== VT_UI8
) && !HAVE_OLEAUT32_I8
)
7456 memset(&left
, 0, sizeof(left
));
7457 memset(&right
, 0, sizeof(right
));
7458 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
7459 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
7460 V_VT(&result
) = VT_EMPTY
;
7463 if (leftvt
== VT_BSTR
)
7464 V_BSTR(&left
) = num2_str
;
7465 else if (leftvt
== VT_DECIMAL
)
7467 VarDecFromR8(2.0, &V_DECIMAL(&left
));
7468 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
7471 /* Division by 0 is undefined */
7475 V_BSTR(&right
) = num2_str
;
7478 VarDecFromR8(2.0, &V_DECIMAL(&right
));
7479 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
7482 V_BOOL(&right
) = VARIANT_TRUE
;
7485 VarCyFromI4(10000, &V_CY(&right
));
7486 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
7488 case VT_I2
: V_I2(&right
) = 2; break;
7489 case VT_I4
: V_I4(&right
) = 2; break;
7490 case VT_R4
: V_R4(&right
) = 2.0f
; break;
7491 case VT_R8
: V_R8(&right
) = 2.0; break;
7492 case VT_DATE
: V_DATE(&right
) = 2; break;
7493 case VT_I1
: V_I1(&right
) = 2; break;
7494 case VT_UI1
: V_UI1(&right
) = 2; break;
7495 case VT_UI2
: V_UI2(&right
) = 2; break;
7496 case VT_UI4
: V_UI4(&right
) = 2; break;
7497 case VT_I8
: V_I8(&right
) = 2; break;
7498 case VT_UI8
: V_UI8(&right
) = 2; break;
7499 case VT_INT
: V_INT(&right
) = 2; break;
7500 case VT_UINT
: V_UINT(&right
) = 2; break;
7504 /* Native VarIdiv always returns an error when using extra
7505 * flags or if the variant combination is I8 and INT.
7507 if ((leftvt
== VT_I8
&& rightvt
== VT_INT
) ||
7508 (leftvt
== VT_INT
&& rightvt
== VT_I8
) ||
7509 (rightvt
== VT_EMPTY
&& leftvt
!= VT_NULL
) ||
7513 /* Determine variant type */
7514 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
7516 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
7518 else if (leftvt
== VT_I4
|| rightvt
== VT_I4
||
7519 leftvt
== VT_INT
|| rightvt
== VT_INT
||
7520 leftvt
== VT_UINT
|| rightvt
== VT_UINT
||
7521 leftvt
== VT_UI8
|| rightvt
== VT_UI8
||
7522 leftvt
== VT_UI4
|| rightvt
== VT_UI4
||
7523 leftvt
== VT_UI2
|| rightvt
== VT_UI2
||
7524 leftvt
== VT_I1
|| rightvt
== VT_I1
||
7525 leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
||
7526 leftvt
== VT_DATE
|| rightvt
== VT_DATE
||
7527 leftvt
== VT_CY
|| rightvt
== VT_CY
||
7528 leftvt
== VT_DECIMAL
|| rightvt
== VT_DECIMAL
||
7529 leftvt
== VT_R8
|| rightvt
== VT_R8
||
7530 leftvt
== VT_R4
|| rightvt
== VT_R4
)
7532 else if (leftvt
== VT_I2
|| rightvt
== VT_I2
||
7533 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
||
7536 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
7541 hres
= pVarIdiv(&left
, &right
, &result
);
7543 /* Check expected HRESULT and if result variant type is correct */
7545 ok (hres
== DISP_E_BADVARTYPE
|| hres
== DISP_E_TYPEMISMATCH
||
7546 hres
== DISP_E_DIVBYZERO
,
7547 "VarIdiv: %s|0x%X, %s|0x%X: got vt %s hr 0x%X\n",
7548 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
],
7549 vtstr(V_VT(&result
)), hres
);
7551 ok (hres
== S_OK
&& resvt
== V_VT(&result
),
7552 "VarIdiv: %s|0x%X, %s|0x%X: expected vt %s hr 0x%X, got vt %s hr 0x%X\n",
7553 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
], vtstr(resvt
),
7554 S_OK
, vtstr(V_VT(&result
)), hres
);
7559 /* Test return values for all the good cases */
7560 VARIDIV(EMPTY
,0,NULL
,0,NULL
,0);
7561 VARIDIV(EMPTY
,0,I2
,1,I2
,0);
7562 VARIDIV(EMPTY
,0,I4
,1,I4
,0);
7563 VARIDIV(EMPTY
,0,R4
,1.0f
,I4
,0);
7564 VARIDIV(EMPTY
,0,R8
,1.0,I4
,0);
7565 VARIDIV(EMPTY
,0,DATE
,1.0,I4
,0);
7566 VARIDIV(EMPTY
,0,BSTR
,num1_str
,I4
,0);
7567 VARIDIV(EMPTY
,0,BOOL
,VARIANT_TRUE
,I2
,0);
7568 VARIDIV(EMPTY
,0,I1
,1,I4
,0);
7569 VARIDIV(EMPTY
,0,UI1
,1,I2
,0);
7570 VARIDIV(EMPTY
,0,UI2
,1,I4
,0);
7571 VARIDIV(EMPTY
,0,UI4
,1,I4
,0);
7572 if (HAVE_OLEAUT32_I8
)
7574 VARIDIV(EMPTY
,0,I8
,1,I8
,0);
7575 VARIDIV(EMPTY
,0,UI8
,1,I4
,0);
7577 VARIDIV(EMPTY
,0,INT
,1,I4
,0);
7578 VARIDIV(EMPTY
,0,UINT
,1,I4
,0);
7579 VARIDIV(NULL
,0,EMPTY
,0,NULL
,0);
7580 VARIDIV(NULL
,0,NULL
,0,NULL
,0);
7581 VARIDIV(NULL
,0,I2
,1,NULL
,0);
7582 VARIDIV(NULL
,0,I4
,1,NULL
,0);
7583 VARIDIV(NULL
,0,R4
,1,NULL
,0);
7584 VARIDIV(NULL
,0,R8
,1,NULL
,0);
7585 VARIDIV(NULL
,0,DATE
,1,NULL
,0);
7586 VARIDIV(NULL
,0,BSTR
,num1_str
,NULL
,0);
7587 VARIDIV(NULL
,0,BOOL
,VARIANT_TRUE
,NULL
,0);
7588 VARIDIV(NULL
,0,I1
,1,NULL
,0);
7589 VARIDIV(NULL
,0,UI1
,1,NULL
,0);
7590 VARIDIV(NULL
,0,UI2
,1,NULL
,0);
7591 VARIDIV(NULL
,0,UI4
,1,NULL
,0);
7592 if (HAVE_OLEAUT32_I8
)
7594 VARIDIV(NULL
,0,I8
,1,NULL
,0);
7595 VARIDIV(NULL
,0,UI8
,1,NULL
,0);
7597 VARIDIV(NULL
,0,INT
,1,NULL
,0);
7598 VARIDIV(NULL
,0,UINT
,1,NULL
,0);
7599 VARIDIV(I2
,2,NULL
,0,NULL
,0);
7600 VARIDIV(I2
,2,I2
,1,I2
,2);
7601 VARIDIV(I2
,2,I4
,1,I4
,2);
7602 VARIDIV(I2
,2,R4
,1,I4
,2);
7603 VARIDIV(I2
,2,R8
,1,I4
,2);
7604 VARIDIV(I2
,2,DATE
,1,I4
,2);
7605 VARIDIV(I2
,2,BSTR
,num1_str
,I4
,2);
7606 VARIDIV(I2
,2,BOOL
,VARIANT_TRUE
,I2
,-2);
7607 VARIDIV(I2
,2,I1
,1,I4
,2);
7608 VARIDIV(I2
,2,UI1
,1,I2
,2);
7609 VARIDIV(I2
,2,UI2
,1,I4
,2);
7610 VARIDIV(I2
,2,UI4
,1,I4
,2);
7611 if (HAVE_OLEAUT32_I8
)
7613 VARIDIV(I2
,2,I8
,1,I8
,2);
7614 VARIDIV(I2
,2,UI8
,1,I4
,2);
7616 VARIDIV(I2
,2,INT
,1,I4
,2);
7617 VARIDIV(I2
,2,UINT
,1,I4
,2);
7618 VARIDIV(I4
,2,NULL
,0,NULL
,0);
7619 VARIDIV(I4
,2,I2
,1,I4
,2);
7620 VARIDIV(I4
,2,I4
,1,I4
,2);
7621 VARIDIV(I4
,2,R4
,1,I4
,2);
7622 VARIDIV(I4
,2,R8
,1,I4
,2);
7623 VARIDIV(I4
,2,DATE
,1,I4
,2);
7624 VARIDIV(I4
,2,BSTR
,num1_str
,I4
,2);
7625 VARIDIV(I4
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
7626 VARIDIV(I4
,2,I1
,1,I4
,2);
7627 VARIDIV(I4
,2,UI1
,1,I4
,2);
7628 VARIDIV(I4
,2,UI2
,1,I4
,2);
7629 VARIDIV(I4
,2,UI4
,1,I4
,2);
7630 if (HAVE_OLEAUT32_I8
)
7632 VARIDIV(I4
,2,I8
,1,I8
,2);
7633 VARIDIV(I4
,2,UI8
,1,I4
,2);
7635 VARIDIV(I4
,2,INT
,1,I4
,2);
7636 VARIDIV(I4
,2,UINT
,1,I4
,2);
7637 VARIDIV(R4
,2.0f
,NULL
,0,NULL
,0);
7638 VARIDIV(R4
,2.0f
,I2
,1,I4
,2);
7639 VARIDIV(R4
,2.0f
,I4
,1,I4
,2);
7640 VARIDIV(R4
,2.0f
,R4
,1.0f
,I4
,2);
7641 VARIDIV(R4
,2.0f
,R8
,1.0,I4
,2);
7642 VARIDIV(R4
,2.0f
,DATE
,1,I4
,2);
7643 VARIDIV(R4
,2.0f
,BSTR
,num1_str
,I4
,2);
7644 VARIDIV(R4
,2.0f
,BOOL
,VARIANT_TRUE
,I4
,-2);
7645 VARIDIV(R4
,2.0f
,I1
,1,I4
,2);
7646 VARIDIV(R4
,2.0f
,UI1
,1,I4
,2);
7647 VARIDIV(R4
,2.0f
,UI2
,1,I4
,2);
7648 VARIDIV(R4
,2.0f
,UI4
,1,I4
,2);
7649 if (HAVE_OLEAUT32_I8
)
7651 VARIDIV(R4
,2.0f
,I8
,1,I8
,2);
7652 VARIDIV(R4
,2.0f
,UI8
,1,I4
,2);
7654 VARIDIV(R4
,2.0f
,INT
,1,I4
,2);
7655 VARIDIV(R4
,2.0f
,UINT
,1,I4
,2);
7656 VARIDIV(R8
,2.0,NULL
,0,NULL
,0);
7657 VARIDIV(R8
,2.0,I2
,1,I4
,2);
7658 VARIDIV(R8
,2.0,I4
,1,I4
,2);
7659 VARIDIV(R8
,2.0,R4
,1,I4
,2);
7660 VARIDIV(R8
,2.0,R8
,1,I4
,2);
7661 VARIDIV(R8
,2.0,DATE
,1,I4
,2);
7662 VARIDIV(R8
,2.0,BSTR
,num1_str
,I4
,2);
7663 VARIDIV(R8
,2.0,BOOL
,VARIANT_TRUE
,I4
,-2);
7664 VARIDIV(R8
,2.0,I1
,1,I4
,2);
7665 VARIDIV(R8
,2.0,UI1
,1,I4
,2);
7666 VARIDIV(R8
,2.0,UI2
,1,I4
,2);
7667 VARIDIV(R8
,2.0,UI4
,1,I4
,2);
7668 if (HAVE_OLEAUT32_I8
)
7670 VARIDIV(R8
,2.0,I8
,1,I8
,2);
7671 VARIDIV(R8
,2.0,UI8
,1,I4
,2);
7673 VARIDIV(R8
,2.0,INT
,1,I4
,2);
7674 VARIDIV(R8
,2.0,UINT
,1,I4
,2);
7675 VARIDIV(DATE
,2,NULL
,0,NULL
,0);
7676 VARIDIV(DATE
,2,I2
,1,I4
,2);
7677 VARIDIV(DATE
,2,I4
,1,I4
,2);
7678 VARIDIV(DATE
,2,R4
,1,I4
,2);
7679 VARIDIV(DATE
,2,R8
,1,I4
,2);
7680 VARIDIV(DATE
,2,DATE
,1,I4
,2);
7681 VARIDIV(DATE
,2,BSTR
,num1_str
,I4
,2);
7682 VARIDIV(DATE
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
7683 VARIDIV(DATE
,2,I1
,1,I4
,2);
7684 VARIDIV(DATE
,2,UI1
,1,I4
,2);
7685 VARIDIV(DATE
,2,UI2
,1,I4
,2);
7686 VARIDIV(DATE
,2,UI4
,1,I4
,2);
7687 if (HAVE_OLEAUT32_I8
)
7689 VARIDIV(DATE
,2,I8
,1,I8
,2);
7690 VARIDIV(DATE
,2,UI8
,1,I4
,2);
7692 VARIDIV(DATE
,2,INT
,1,I4
,2);
7693 VARIDIV(DATE
,2,UINT
,1,I4
,2);
7694 VARIDIV(BSTR
,num2_str
,NULL
,0,NULL
,0);
7695 VARIDIV(BSTR
,num2_str
,I2
,1,I4
,2);
7696 VARIDIV(BSTR
,num2_str
,I4
,1,I4
,2);
7697 VARIDIV(BSTR
,num2_str
,R4
,1.0f
,I4
,2);
7698 VARIDIV(BSTR
,num2_str
,R8
,1.0,I4
,2);
7699 VARIDIV(BSTR
,num2_str
,DATE
,1,I4
,2);
7700 VARIDIV(BSTR
,num2_str
,BSTR
,num1_str
,I4
,2);
7701 VARIDIV(BSTR
,num2_str
,BOOL
,VARIANT_TRUE
,I4
,-2);
7702 VARIDIV(BSTR
,num2_str
,I1
,1,I4
,2);
7703 VARIDIV(BSTR
,num2_str
,UI1
,1,I4
,2);
7704 VARIDIV(BSTR
,num2_str
,UI2
,1,I4
,2);
7705 VARIDIV(BSTR
,num2_str
,UI4
,1,I4
,2);
7706 if (HAVE_OLEAUT32_I8
)
7708 VARIDIV(BSTR
,num2_str
,I8
,1,I8
,2);
7709 VARIDIV(BSTR
,num2_str
,UI8
,1,I4
,2);
7711 VARIDIV(BSTR
,num2_str
,INT
,1,I4
,2);
7712 VARIDIV(BSTR
,num2_str
,UINT
,1,I4
,2);
7713 VARIDIV(BOOL
,VARIANT_TRUE
,NULL
,0,NULL
,0);
7714 VARIDIV(BOOL
,VARIANT_TRUE
,I2
,1,I2
,-1);
7715 VARIDIV(BOOL
,VARIANT_TRUE
,I4
,1,I4
,-1);
7716 VARIDIV(BOOL
,VARIANT_TRUE
,R4
,1.0f
,I4
,-1);
7717 VARIDIV(BOOL
,VARIANT_TRUE
,R8
,1.0,I4
,-1);
7718 VARIDIV(BOOL
,VARIANT_TRUE
,DATE
,1,I4
,-1);
7719 VARIDIV(BOOL
,VARIANT_TRUE
,BSTR
,num1_str
,I4
,-1);
7720 VARIDIV(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
,I2
,1);
7721 VARIDIV(BOOL
,VARIANT_TRUE
,I1
,1,I4
,-1);
7722 VARIDIV(BOOL
,VARIANT_TRUE
,UI1
,1,I2
,-1);
7723 VARIDIV(BOOL
,VARIANT_TRUE
,UI2
,1,I4
,-1);
7724 VARIDIV(BOOL
,VARIANT_TRUE
,UI4
,1,I4
,-1);
7725 if (HAVE_OLEAUT32_I8
)
7727 VARIDIV(BOOL
,VARIANT_TRUE
,I8
,1,I8
,-1);
7728 VARIDIV(BOOL
,VARIANT_TRUE
,UI8
,1,I4
,-1);
7730 VARIDIV(BOOL
,VARIANT_TRUE
,INT
,1,I4
,-1);
7731 VARIDIV(BOOL
,VARIANT_TRUE
,UINT
,1,I4
,-1);
7732 VARIDIV(I1
,2,NULL
,0,NULL
,0);
7733 VARIDIV(I1
,2,I2
,1,I4
,2);
7734 VARIDIV(I1
,2,I4
,1,I4
,2);
7735 VARIDIV(I1
,2,R4
,1.0f
,I4
,2);
7736 VARIDIV(I1
,2,R8
,1.0,I4
,2);
7737 VARIDIV(I1
,2,DATE
,1,I4
,2);
7738 VARIDIV(I1
,2,BSTR
,num1_str
,I4
,2);
7739 VARIDIV(I1
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
7740 VARIDIV(I1
,2,I1
,1,I4
,2);
7741 VARIDIV(I1
,2,UI1
,1,I4
,2);
7742 VARIDIV(I1
,2,UI2
,1,I4
,2);
7743 VARIDIV(I1
,2,UI4
,1,I4
,2);
7744 if (HAVE_OLEAUT32_I8
)
7746 VARIDIV(I1
,2,I8
,1,I8
,2);
7747 VARIDIV(I1
,2,UI8
,1,I4
,2);
7749 VARIDIV(I1
,2,INT
,1,I4
,2);
7750 VARIDIV(I1
,2,UINT
,1,I4
,2);
7751 VARIDIV(UI1
,2,NULL
,0,NULL
,0);
7752 VARIDIV(UI1
,2,I2
,1,I2
,2);
7753 VARIDIV(UI1
,2,I4
,1,I4
,2);
7754 VARIDIV(UI1
,2,R4
,1.0f
,I4
,2);
7755 VARIDIV(UI1
,2,R8
,1.0,I4
,2);
7756 VARIDIV(UI1
,2,DATE
,1,I4
,2);
7757 VARIDIV(UI1
,2,BSTR
,num1_str
,I4
,2);
7758 VARIDIV(UI1
,2,BOOL
,VARIANT_TRUE
,I2
,-2);
7759 VARIDIV(UI1
,2,I1
,1,I4
,2);
7760 VARIDIV(UI1
,2,UI1
,1,UI1
,2);
7761 VARIDIV(UI1
,2,UI2
,1,I4
,2);
7762 VARIDIV(UI1
,2,UI4
,1,I4
,2);
7763 if (HAVE_OLEAUT32_I8
)
7765 VARIDIV(UI1
,2,I8
,1,I8
,2);
7766 VARIDIV(UI1
,2,UI8
,1,I4
,2);
7768 VARIDIV(UI1
,2,INT
,1,I4
,2);
7769 VARIDIV(UI1
,2,UINT
,1,I4
,2);
7770 VARIDIV(UI2
,2,NULL
,0,NULL
,0);
7771 VARIDIV(UI2
,2,I2
,1,I4
,2);
7772 VARIDIV(UI2
,2,I4
,1,I4
,2);
7773 VARIDIV(UI2
,2,R4
,1.0f
,I4
,2);
7774 VARIDIV(UI2
,2,R8
,1.0,I4
,2);
7775 VARIDIV(UI2
,2,DATE
,1,I4
,2);
7776 VARIDIV(UI2
,2,BSTR
,num1_str
,I4
,2);
7777 VARIDIV(UI2
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
7778 VARIDIV(UI2
,2,I1
,1,I4
,2);
7779 VARIDIV(UI2
,2,UI1
,1,I4
,2);
7780 VARIDIV(UI2
,2,UI2
,1,I4
,2);
7781 VARIDIV(UI2
,2,UI4
,1,I4
,2);
7782 if (HAVE_OLEAUT32_I8
)
7784 VARIDIV(UI2
,2,I8
,1,I8
,2);
7785 VARIDIV(UI2
,2,UI8
,1,I4
,2);
7787 VARIDIV(UI2
,2,INT
,1,I4
,2);
7788 VARIDIV(UI2
,2,UINT
,1,I4
,2);
7789 VARIDIV(UI4
,2,NULL
,0,NULL
,0);
7790 VARIDIV(UI4
,2,I2
,1,I4
,2);
7791 VARIDIV(UI4
,2,I4
,1,I4
,2);
7792 VARIDIV(UI4
,2,R4
,1.0f
,I4
,2);
7793 VARIDIV(UI4
,2,R8
,1.0,I4
,2);
7794 VARIDIV(UI4
,2,DATE
,1,I4
,2);
7795 VARIDIV(UI4
,2,BSTR
,num1_str
,I4
,2);
7796 VARIDIV(UI4
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
7797 VARIDIV(UI4
,2,I1
,1,I4
,2);
7798 VARIDIV(UI4
,2,UI1
,1,I4
,2);
7799 VARIDIV(UI4
,2,UI2
,1,I4
,2);
7800 VARIDIV(UI4
,2,UI4
,1,I4
,2);
7801 if (HAVE_OLEAUT32_I8
)
7803 VARIDIV(UI4
,2,I8
,1,I8
,2);
7804 VARIDIV(UI4
,2,UI8
,1,I4
,2);
7806 VARIDIV(UI4
,2,INT
,1,I4
,2);
7807 VARIDIV(UI4
,2,UINT
,1,I4
,2);
7808 if (HAVE_OLEAUT32_I8
)
7810 VARIDIV(I8
,2,NULL
,0,NULL
,0);
7811 VARIDIV(I8
,2,I2
,1,I8
,2);
7812 VARIDIV(I8
,2,I4
,1,I8
,2);
7813 VARIDIV(I8
,2,R4
,1.0f
,I8
,2);
7814 VARIDIV(I8
,2,R8
,1.0,I8
,2);
7815 VARIDIV(I8
,2,DATE
,1,I8
,2);
7816 VARIDIV(I8
,2,BSTR
,num1_str
,I8
,2);
7817 VARIDIV(I8
,2,BOOL
,1,I8
,2);
7818 VARIDIV(I8
,2,I1
,1,I8
,2);
7819 VARIDIV(I8
,2,UI1
,1,I8
,2);
7820 VARIDIV(I8
,2,UI2
,1,I8
,2);
7821 VARIDIV(I8
,2,UI4
,1,I8
,2);
7822 VARIDIV(I8
,2,I8
,1,I8
,2);
7823 VARIDIV(I8
,2,UI8
,1,I8
,2);
7824 VARIDIV(I8
,2,UINT
,1,I8
,2);
7825 VARIDIV(UI8
,2,NULL
,0,NULL
,0);
7826 VARIDIV(UI8
,2,I2
,1,I4
,2);
7827 VARIDIV(UI8
,2,I4
,1,I4
,2);
7828 VARIDIV(UI8
,2,R4
,1.0f
,I4
,2);
7829 VARIDIV(UI8
,2,R8
,1.0,I4
,2);
7830 VARIDIV(UI8
,2,DATE
,1,I4
,2);
7831 VARIDIV(UI8
,2,BSTR
,num1_str
,I4
,2);
7832 VARIDIV(UI8
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
7833 VARIDIV(UI8
,2,I1
,1,I4
,2);
7834 VARIDIV(UI8
,2,UI1
,1,I4
,2);
7835 VARIDIV(UI8
,2,UI2
,1,I4
,2);
7836 VARIDIV(UI8
,2,UI4
,1,I4
,2);
7837 VARIDIV(UI8
,2,I8
,1,I8
,2);
7838 VARIDIV(UI8
,2,UI8
,1,I4
,2);
7839 VARIDIV(UI8
,2,INT
,1,I4
,2);
7840 VARIDIV(UI8
,2,UINT
,1,I4
,2);
7842 VARIDIV(INT
,2,NULL
,0,NULL
,0);
7843 VARIDIV(INT
,2,I2
,1,I4
,2);
7844 VARIDIV(INT
,2,I4
,1,I4
,2);
7845 VARIDIV(INT
,2,R4
,1.0f
,I4
,2);
7846 VARIDIV(INT
,2,R8
,1.0,I4
,2);
7847 VARIDIV(INT
,2,DATE
,1,I4
,2);
7848 VARIDIV(INT
,2,BSTR
,num1_str
,I4
,2);
7849 VARIDIV(INT
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
7850 VARIDIV(INT
,2,I1
,1,I4
,2);
7851 VARIDIV(INT
,2,UI1
,1,I4
,2);
7852 VARIDIV(INT
,2,UI2
,1,I4
,2);
7853 VARIDIV(INT
,2,UI4
,1,I4
,2);
7854 if (HAVE_OLEAUT32_I8
)
7856 VARIDIV(INT
,2,UI8
,1,I4
,2);
7858 VARIDIV(INT
,2,INT
,1,I4
,2);
7859 VARIDIV(INT
,2,UINT
,1,I4
,2);
7860 VARIDIV(UINT
,2,NULL
,0,NULL
,0);
7861 VARIDIV(UINT
,2,I2
,1,I4
,2);
7862 VARIDIV(UINT
,2,I4
,1,I4
,2);
7863 VARIDIV(UINT
,2,R4
,1.0f
,I4
,2);
7864 VARIDIV(UINT
,2,R8
,1.0,I4
,2);
7865 VARIDIV(UINT
,2,DATE
,1,I4
,2);
7866 VARIDIV(UINT
,2,BSTR
,num1_str
,I4
,2);
7867 VARIDIV(UINT
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
7868 VARIDIV(UINT
,2,I1
,1,I4
,2);
7869 VARIDIV(UINT
,2,UI1
,1,I4
,2);
7870 VARIDIV(UINT
,2,UI2
,1,I4
,2);
7871 VARIDIV(UINT
,2,UI4
,1,I4
,2);
7872 if (HAVE_OLEAUT32_I8
)
7874 VARIDIV(UINT
,2,I8
,1,I8
,2);
7875 VARIDIV(UINT
,2,UI8
,1,I4
,2);
7877 VARIDIV(UINT
,2,INT
,1,I4
,2);
7878 VARIDIV(UINT
,2,UINT
,1,I4
,2);
7880 /* Manually test some VT_CY, VT_DECIMAL variants */
7882 hres
= VarCyFromI4(10000, &V_CY(&cy
));
7883 ok(hres
== S_OK
, "VarCyFromI4 failed!\n");
7884 V_VT(&dec
) = VT_DECIMAL
;
7885 hres
= VarDecFromR8(2.0, &V_DECIMAL(&dec
));
7886 ok(hres
== S_OK
, "VarDecFromR4 failed!\n");
7887 memset(&left
, 0, sizeof(left
));
7888 memset(&right
, 0, sizeof(right
));
7889 V_VT(&left
) = VT_I4
;
7891 V_VT(&right
) = VT_I8
;
7894 hres
= VarIdiv(&cy
, &cy
, &result
);
7895 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
7896 "VARIDIV: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
7897 S_OK
, hres
, vtstr(V_VT(&result
)));
7898 ok(hres
== S_OK
&& V_I4(&result
) == 1,
7899 "VARIDIV: CY value %d, expected %d\n", V_I4(&result
), 1);
7901 if (HAVE_OLEAUT32_I8
)
7903 hres
= VarIdiv(&cy
, &right
, &result
);
7904 ok(hres
== S_OK
&& V_VT(&result
) == VT_I8
,
7905 "VARIDIV: expected coerced hres 0x%X type VT_I8, got hres 0x%X type %s!\n",
7906 S_OK
, hres
, vtstr(V_VT(&result
)));
7907 ok(hres
== S_OK
&& V_I8(&result
) == 5000,
7908 "VARIDIV: CY value 0x%x%08x, expected 0x%x\n",
7909 (DWORD
)(V_I8(&result
) >>32), (DWORD
)V_I8(&result
), 5000);
7912 hres
= VarIdiv(&left
, &cy
, &result
);
7913 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
7914 "VARIDIV: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
7915 S_OK
, hres
, vtstr(V_VT(&result
)));
7916 ok(hres
== S_OK
&& V_I4(&result
) == 0,
7917 "VARIDIV: CY value %d, expected %d\n", V_I4(&result
), 0);
7919 hres
= VarIdiv(&left
, &dec
, &result
);
7920 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
7921 "VARIDIV: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
7922 S_OK
, hres
, vtstr(V_VT(&result
)));
7923 ok(hres
== S_OK
&& V_I4(&result
) == 50,
7924 "VARIDIV: DECIMAL value %d, expected %d\n", V_I4(&result
), 50);
7926 hres
= VarIdiv(&dec
, &dec
, &result
);
7927 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
7928 "VARIDIV: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
7929 S_OK
, hres
, vtstr(V_VT(&result
)));
7930 ok(hres
== S_OK
&& V_I4(&result
) == 1,
7931 "VARIDIV: DECIMAL value %d, expected %d\n", V_I4(&result
), 1);
7933 if (HAVE_OLEAUT32_I8
)
7935 hres
= VarIdiv(&dec
, &right
, &result
);
7936 ok(hres
== S_OK
&& V_VT(&result
) == VT_I8
,
7937 "VARIDIV: expected coerced hres 0x%X type VT_I8, got hres 0x%X type %s!\n",
7938 S_OK
, hres
, vtstr(V_VT(&result
)));
7939 ok(hres
== S_OK
&& V_I8(&result
) == 1,
7940 "VARIDIV: DECIMAL value 0x%x%08x, expected %d\n",
7941 (DWORD
)(V_I8(&result
) >> 32), (DWORD
)V_I8(&result
), 1);
7944 /* Check for division by zero */
7945 V_VT(&left
) = VT_INT
;
7947 V_VT(&right
) = VT_INT
;
7949 hres
= pVarIdiv(&left
, &right
, &result
);
7950 ok(hres
== DISP_E_DIVBYZERO
&& V_VT(&result
) == VT_EMPTY
,
7951 "VARIDIV: Division by 0 should result in DISP_E_DIVBYZERO but got 0x%X\n", hres
);
7953 V_VT(&left
) = VT_INT
;
7955 V_VT(&right
) = VT_INT
;
7957 hres
= pVarIdiv(&left
, &right
, &result
);
7958 ok(hres
== DISP_E_DIVBYZERO
&& V_VT(&result
) == VT_EMPTY
,
7959 "VARIDIV: Division by 0 should result in DISP_E_DIVBYZERO but got 0x%X\n", hres
);
7961 SysFreeString(num1_str
);
7962 SysFreeString(num2_str
);
7966 static HRESULT (WINAPI
*pVarImp
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
7968 #define VARIMP(vt1,val1,vt2,val2,rvt,rval) \
7969 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
7970 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
7971 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
7972 test_var_call2( __LINE__, pVarImp, &left, &right, &exp )
7974 /* Skip any type that is not defined or produces an error for every case */
7975 #define SKIPTESTIMP(a) \
7976 if (a == VT_ERROR || a == VT_VARIANT || \
7977 a == VT_DISPATCH || a == VT_UNKNOWN || \
7978 a == VT_RECORD || a > VT_UINT || \
7979 a == 15 /*not defined*/) \
7982 static void test_VarImp(void)
7984 static const WCHAR szFalse
[] = { '#','F','A','L','S','E','#','\0' };
7985 static const WCHAR szTrue
[] = { '#','T','R','U','E','#','\0' };
7986 VARIANT left
, right
, exp
, result
, cy
, dec
;
7987 BSTR true_str
, false_str
;
7993 true_str
= SysAllocString(szTrue
);
7994 false_str
= SysAllocString(szFalse
);
7996 /* Test all possible flag/vt combinations & the resulting vt type */
7997 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
7999 VARTYPE leftvt
, rightvt
, resvt
;
8001 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
8003 SKIPTESTIMP(leftvt
);
8005 /* Check if we need/have support for I8 and/or UI8 */
8006 if ((leftvt
== VT_I8
|| leftvt
== VT_UI8
) && !HAVE_OLEAUT32_I8
)
8009 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
8012 SKIPTESTIMP(rightvt
);
8014 /* Native crashes when using the extra flag VT_BYREF
8015 * or with the following VT combinations
8017 if ((leftvt
== VT_UI4
&& rightvt
== VT_BSTR
) ||
8018 (leftvt
== VT_UI8
&& rightvt
== VT_BSTR
) ||
8019 ExtraFlags
[i
] == VT_BYREF
)
8022 /* Check if we need/have support for I8 and/or UI8 */
8023 if ((rightvt
== VT_I8
|| rightvt
== VT_UI8
) && !HAVE_OLEAUT32_I8
)
8026 memset(&left
, 0, sizeof(left
));
8027 memset(&right
, 0, sizeof(right
));
8028 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
8029 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
8030 V_VT(&result
) = VT_EMPTY
;
8033 if (leftvt
== VT_BSTR
)
8034 V_BSTR(&left
) = true_str
;
8036 /* This allows us to test return types that are not NULL
8037 * (NULL Imp value = n, NULL Imp 0 = NULL)
8042 V_BSTR(&right
) = true_str
;
8045 VarDecFromR8(2.0, &V_DECIMAL(&right
));
8046 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
8049 V_BOOL(&right
) = VARIANT_TRUE
;
8051 case VT_I1
: V_I1(&right
) = 2; break;
8052 case VT_I2
: V_I2(&right
) = 2; break;
8053 case VT_I4
: V_I4(&right
) = 2; break;
8054 case VT_R4
: V_R4(&right
) = 2.0f
; break;
8055 case VT_R8
: V_R8(&right
) = 2.0; break;
8056 case VT_CY
: V_CY(&right
).int64
= 10000; break;
8057 case VT_DATE
: V_DATE(&right
) = 2; break;
8058 case VT_I8
: V_I8(&right
) = 2; break;
8059 case VT_INT
: V_INT(&right
) = 2; break;
8060 case VT_UINT
: V_UINT(&right
) = 2; break;
8061 case VT_UI1
: V_UI1(&right
) = 2; break;
8062 case VT_UI2
: V_UI2(&right
) = 2; break;
8063 case VT_UI4
: V_UI4(&right
) = 2; break;
8064 case VT_UI8
: V_UI8(&right
) = 2; break;
8068 /* Native VarImp always returns an error when using extra
8069 * flags or if the variants are I8 and INT.
8071 if ((leftvt
== VT_I8
&& rightvt
== VT_INT
) ||
8075 /* Determine result type */
8076 else if ((leftvt
== VT_BSTR
&& rightvt
== VT_NULL
) ||
8077 (leftvt
== VT_NULL
&& rightvt
== VT_NULL
) ||
8078 (leftvt
== VT_NULL
&& rightvt
== VT_EMPTY
))
8080 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
8082 else if (leftvt
== VT_I4
|| rightvt
== VT_I4
||
8083 leftvt
== VT_INT
|| rightvt
== VT_INT
||
8084 leftvt
== VT_UINT
|| rightvt
== VT_UINT
||
8085 leftvt
== VT_UI4
|| rightvt
== VT_UI4
||
8086 leftvt
== VT_UI8
|| rightvt
== VT_UI8
||
8087 leftvt
== VT_UI2
|| rightvt
== VT_UI2
||
8088 leftvt
== VT_DECIMAL
|| rightvt
== VT_DECIMAL
||
8089 leftvt
== VT_DATE
|| rightvt
== VT_DATE
||
8090 leftvt
== VT_CY
|| rightvt
== VT_CY
||
8091 leftvt
== VT_R8
|| rightvt
== VT_R8
||
8092 leftvt
== VT_R4
|| rightvt
== VT_R4
||
8093 leftvt
== VT_I1
|| rightvt
== VT_I1
)
8095 else if ((leftvt
== VT_UI1
&& rightvt
== VT_UI1
) ||
8096 (leftvt
== VT_UI1
&& rightvt
== VT_NULL
) ||
8097 (leftvt
== VT_NULL
&& rightvt
== VT_UI1
))
8099 else if (leftvt
== VT_EMPTY
|| rightvt
== VT_EMPTY
||
8100 leftvt
== VT_I2
|| rightvt
== VT_I2
||
8101 leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
8103 else if (leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
||
8104 leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
)
8107 hres
= pVarImp(&left
, &right
, &result
);
8109 /* Check expected HRESULT and if result variant type is correct */
8111 ok (hres
== DISP_E_BADVARTYPE
|| hres
== DISP_E_TYPEMISMATCH
,
8112 "VarImp: %s|0x%X, %s|0x%X: got vt %s hr 0x%X\n",
8113 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
],
8114 vtstr(V_VT(&result
)), hres
);
8116 ok (hres
== S_OK
&& resvt
== V_VT(&result
),
8117 "VarImp: %s|0x%X, %s|0x%X: expected vt %s hr 0x%X, got vt %s hr 0x%X\n",
8118 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
], vtstr(resvt
),
8119 S_OK
, vtstr(V_VT(&result
)), hres
);
8124 VARIMP(EMPTY
,0,EMPTY
,0,I2
,-1);
8125 VARIMP(EMPTY
,0,NULL
,0,I2
,-1);
8126 VARIMP(EMPTY
,0,I2
,-1,I2
,-1);
8127 VARIMP(EMPTY
,0,I4
,-1,I4
,-1);
8128 VARIMP(EMPTY
,0,R4
,0.0f
,I4
,-1);
8129 VARIMP(EMPTY
,0,R8
,-1.0,I4
,-1);
8130 VARIMP(EMPTY
,0,DATE
,0,I4
,-1);
8131 VARIMP(EMPTY
,0,BSTR
,true_str
,I2
,-1);
8132 VARIMP(EMPTY
,0,BOOL
,VARIANT_FALSE
,I2
,-1);
8133 VARIMP(EMPTY
,0,I1
,0,I4
,-1);
8134 VARIMP(EMPTY
,0,UI1
,1,I2
,-1);
8135 VARIMP(EMPTY
,0,UI2
,1,I4
,-1);
8136 VARIMP(EMPTY
,0,UI4
,1,I4
,-1);
8137 if (HAVE_OLEAUT32_I8
)
8139 VARIMP(EMPTY
,0,I8
,1,I8
,-1);
8140 VARIMP(EMPTY
,0,UI8
,1,I4
,-1);
8142 VARIMP(EMPTY
,0,INT
,-1,I4
,-1);
8143 VARIMP(EMPTY
,0,UINT
,1,I4
,-1);
8144 VARIMP(NULL
,0,EMPTY
,0,NULL
,0);
8145 VARIMP(NULL
,0,NULL
,0,NULL
,0);
8146 VARIMP(NULL
,0,I2
,-1,I2
,-1);
8147 VARIMP(NULL
,0,I4
,-1,I4
,-1);
8148 VARIMP(NULL
,0,R4
,0.0f
,NULL
,0);
8149 VARIMP(NULL
,0,R8
,-1.0,I4
,-1);
8150 VARIMP(NULL
,0,DATE
,0,NULL
,0);
8151 VARIMP(NULL
,0,BSTR
,true_str
,BOOL
,-1);
8152 VARIMP(NULL
,0,BOOL
,VARIANT_FALSE
,NULL
,0);
8153 VARIMP(NULL
,0,I1
,0,NULL
,0);
8154 VARIMP(NULL
,0,UI1
,1,UI1
,1);
8155 VARIMP(NULL
,0,UI2
,1,I4
,1);
8156 VARIMP(NULL
,0,UI4
,1,I4
,1);
8157 if (HAVE_OLEAUT32_I8
)
8159 VARIMP(NULL
,0,I8
,1,I8
,1);
8160 VARIMP(NULL
,0,UI8
,1,I4
,1);
8162 VARIMP(NULL
,0,INT
,-1,I4
,-1);
8163 VARIMP(NULL
,0,UINT
,1,I4
,1);
8164 VARIMP(I2
,-1,EMPTY
,0,I2
,0);
8165 VARIMP(I2
,-1,I2
,-1,I2
,-1);
8166 VARIMP(I2
,-1,I4
,-1,I4
,-1);
8167 VARIMP(I2
,-1,R4
,0.0f
,I4
,0);
8168 VARIMP(I2
,-1,R8
,-1.0,I4
,-1);
8169 VARIMP(I2
,-1,DATE
,0,I4
,0);
8170 VARIMP(I2
,-1,BSTR
,true_str
,I2
,-1);
8171 VARIMP(I2
,-1,BOOL
,VARIANT_FALSE
,I2
,0);
8172 VARIMP(I2
,-1,I1
,0,I4
,0);
8173 VARIMP(I2
,-1,UI1
,1,I2
,1);
8174 VARIMP(I2
,-1,UI2
,1,I4
,1);
8175 VARIMP(I2
,-1,UI4
,1,I4
,1);
8176 if (HAVE_OLEAUT32_I8
)
8178 VARIMP(I2
,-1,I8
,1,I8
,1);
8179 VARIMP(I2
,-1,UI8
,1,I4
,1);
8181 VARIMP(I2
,-1,INT
,-1,I4
,-1);
8182 VARIMP(I2
,-1,UINT
,1,I4
,1);
8183 VARIMP(I4
,2,EMPTY
,0,I4
,-3);
8184 VARIMP(I4
,2,NULL
,0,I4
,-3);
8185 VARIMP(I4
,2,I2
,-1,I4
,-1);
8186 VARIMP(I4
,2,I4
,-1,I4
,-1);
8187 VARIMP(I4
,2,R4
,0.0f
,I4
,-3);
8188 VARIMP(I4
,2,R8
,-1.0,I4
,-1);
8189 VARIMP(I4
,2,DATE
,0,I4
,-3);
8190 VARIMP(I4
,2,BSTR
,true_str
,I4
,-1);
8191 VARIMP(I4
,2,BOOL
,VARIANT_FALSE
,I4
,-3);
8192 VARIMP(I4
,2,I1
,0,I4
,-3);
8193 VARIMP(I4
,2,UI1
,1,I4
,-3);
8194 VARIMP(I4
,2,UI2
,1,I4
,-3);
8195 VARIMP(I4
,2,UI4
,1,I4
,-3);
8196 if (HAVE_OLEAUT32_I8
)
8198 VARIMP(I4
,2,I8
,1,I8
,-3);
8199 VARIMP(I4
,2,UI8
,1,I4
,-3);
8201 VARIMP(I4
,2,INT
,-1,I4
,-1);
8202 VARIMP(I4
,2,UINT
,1,I4
,-3);
8203 VARIMP(R4
,-1.0f
,EMPTY
,0,I4
,0);
8204 VARIMP(R4
,-1.0f
,NULL
,0,NULL
,0);
8205 VARIMP(R4
,-1.0f
,I2
,-1,I4
,-1);
8206 VARIMP(R4
,-1.0f
,I4
,-1,I4
,-1);
8207 VARIMP(R4
,-1.0f
,R4
,0.0f
,I4
,0);
8208 VARIMP(R4
,-1.0f
,R8
,-1.0,I4
,-1);
8209 VARIMP(R4
,-1.0f
,DATE
,1,I4
,1);
8210 VARIMP(R4
,-1.0f
,BSTR
,true_str
,I4
,-1);
8211 VARIMP(R4
,-1.0f
,BOOL
,VARIANT_FALSE
,I4
,0);
8212 VARIMP(R4
,-1.0f
,I1
,0,I4
,0);
8213 VARIMP(R4
,-1.0f
,UI1
,1,I4
,1);
8214 VARIMP(R4
,-1.0f
,UI2
,1,I4
,1);
8215 VARIMP(R4
,-1.0f
,UI4
,1,I4
,1);
8216 if (HAVE_OLEAUT32_I8
)
8218 VARIMP(R4
,-1.0f
,I8
,1,I8
,1);
8219 VARIMP(R4
,-1.0f
,UI8
,1,I4
,1);
8221 VARIMP(R4
,-1.0f
,INT
,-1,I4
,-1);
8222 VARIMP(R4
,-1.0f
,UINT
,1,I4
,1);
8223 VARIMP(R8
,1.0,EMPTY
,0,I4
,-2);
8224 VARIMP(R8
,1.0,NULL
,0,I4
,-2);
8225 VARIMP(R8
,1.0,I2
,-1,I4
,-1);
8226 VARIMP(R8
,1.0,I4
,-1,I4
,-1);
8227 VARIMP(R8
,1.0,R4
,0.0f
,I4
,-2);
8228 VARIMP(R8
,1.0,R8
,-1.0,I4
,-1);
8229 VARIMP(R8
,1.0,DATE
,0,I4
,-2);
8230 VARIMP(R8
,1.0,BSTR
,true_str
,I4
,-1);
8231 VARIMP(R8
,1.0,BOOL
,VARIANT_FALSE
,I4
,-2);
8232 VARIMP(R8
,1.0,I1
,0,I4
,-2);
8233 VARIMP(R8
,1.0,UI1
,1,I4
,-1);
8234 VARIMP(R8
,1.0,UI2
,1,I4
,-1);
8235 VARIMP(R8
,1.0,UI4
,1,I4
,-1);
8236 if (HAVE_OLEAUT32_I8
)
8238 VARIMP(R8
,1.0,I8
,1,I8
,-1);
8239 VARIMP(R8
,1.0,UI8
,1,I4
,-1);
8241 VARIMP(R8
,1.0,INT
,-1,I4
,-1);
8242 VARIMP(R8
,1.0,UINT
,1,I4
,-1);
8243 VARIMP(DATE
,0,EMPTY
,0,I4
,-1);
8244 VARIMP(DATE
,0,NULL
,0,I4
,-1);
8245 VARIMP(DATE
,0,I2
,-1,I4
,-1);
8246 VARIMP(DATE
,0,I4
,-1,I4
,-1);
8247 VARIMP(DATE
,0,R4
,0.0f
,I4
,-1);
8248 VARIMP(DATE
,0,R8
,-1.0,I4
,-1);
8249 VARIMP(DATE
,0,DATE
,0,I4
,-1);
8250 VARIMP(DATE
,0,BSTR
,true_str
,I4
,-1);
8251 VARIMP(DATE
,0,BOOL
,VARIANT_FALSE
,I4
,-1);
8252 VARIMP(DATE
,0,I1
,0,I4
,-1);
8253 VARIMP(DATE
,0,UI1
,1,I4
,-1);
8254 VARIMP(DATE
,0,UI2
,1,I4
,-1);
8255 VARIMP(DATE
,0,UI4
,1,I4
,-1);
8256 if (HAVE_OLEAUT32_I8
)
8258 VARIMP(DATE
,0,I8
,1,I8
,-1);
8259 VARIMP(DATE
,0,UI8
,1,I4
,-1);
8261 VARIMP(DATE
,0,INT
,-1,I4
,-1);
8262 VARIMP(DATE
,0,UINT
,1,I4
,-1);
8263 VARIMP(BSTR
,false_str
,EMPTY
,0,I2
,-1);
8264 VARIMP(BSTR
,false_str
,NULL
,0,BOOL
,-1);
8265 VARIMP(BSTR
,false_str
,I2
,-1,I2
,-1);
8266 VARIMP(BSTR
,false_str
,I4
,-1,I4
,-1);
8267 VARIMP(BSTR
,false_str
,R4
,0.0f
,I4
,-1);
8268 VARIMP(BSTR
,false_str
,R8
,-1.0,I4
,-1);
8269 VARIMP(BSTR
,false_str
,DATE
,0,I4
,-1);
8270 VARIMP(BSTR
,false_str
,BSTR
,true_str
,BOOL
,-1);
8271 VARIMP(BSTR
,false_str
,BOOL
,VARIANT_FALSE
,BOOL
,-1);
8272 VARIMP(BSTR
,false_str
,I1
,0,I4
,-1);
8273 VARIMP(BSTR
,false_str
,UI1
,1,I2
,-1);
8274 VARIMP(BSTR
,false_str
,UI2
,1,I4
,-1);
8275 VARIMP(BSTR
,false_str
,UI4
,1,I4
,-1);
8276 if (HAVE_OLEAUT32_I8
)
8278 VARIMP(BSTR
,false_str
,I8
,1,I8
,-1);
8279 VARIMP(BSTR
,false_str
,UI8
,1,I4
,-1);
8281 VARIMP(BSTR
,false_str
,INT
,-1,I4
,-1);
8282 VARIMP(BSTR
,false_str
,UINT
,1,I4
,-1);
8283 VARIMP(BOOL
,VARIANT_TRUE
,EMPTY
,0,I2
,0);
8284 VARIMP(BOOL
,VARIANT_TRUE
,NULL
,0,NULL
,0);
8285 VARIMP(BOOL
,VARIANT_TRUE
,I2
,-1,I2
,-1);
8286 VARIMP(BOOL
,VARIANT_TRUE
,I4
,-1,I4
,-1);
8287 VARIMP(BOOL
,VARIANT_TRUE
,R4
,0.0f
,I4
,0);
8288 VARIMP(BOOL
,VARIANT_TRUE
,R8
,-1.0,I4
,-1);
8289 VARIMP(BOOL
,VARIANT_TRUE
,DATE
,0,I4
,0);
8290 VARIMP(BOOL
,VARIANT_TRUE
,BSTR
,true_str
,BOOL
,-1);
8291 VARIMP(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
,BOOL
,0);
8292 VARIMP(BOOL
,VARIANT_TRUE
,I1
,0,I4
,0);
8293 VARIMP(BOOL
,VARIANT_TRUE
,UI1
,1,I2
,1);
8294 VARIMP(BOOL
,VARIANT_TRUE
,UI2
,1,I4
,1);
8295 VARIMP(BOOL
,VARIANT_TRUE
,UI4
,1,I4
,1);
8296 if (HAVE_OLEAUT32_I8
)
8298 VARIMP(BOOL
,VARIANT_TRUE
,I8
,1,I8
,1);
8299 VARIMP(BOOL
,VARIANT_TRUE
,UI8
,1,I4
,1);
8301 VARIMP(BOOL
,VARIANT_TRUE
,INT
,-1,I4
,-1);
8302 VARIMP(BOOL
,VARIANT_TRUE
,UINT
,1,I4
,1);
8303 VARIMP(I1
,-1,EMPTY
,0,I4
,0);
8304 VARIMP(I1
,-1,NULL
,0,NULL
,0);
8305 VARIMP(I1
,-1,I2
,-1,I4
,-1);
8306 VARIMP(I1
,-1,I4
,-1,I4
,-1);
8307 VARIMP(I1
,-1,R4
,0.0f
,I4
,0);
8308 VARIMP(I1
,-1,R8
,-1.0,I4
,-1);
8309 VARIMP(I1
,-1,DATE
,0,I4
,0);
8310 VARIMP(I1
,-1,BSTR
,true_str
,I4
,-1);
8311 VARIMP(I1
,-1,BOOL
,VARIANT_FALSE
,I4
,0);
8312 VARIMP(I1
,-1,I1
,0,I4
,0);
8313 VARIMP(I1
,-1,UI1
,1,I4
,1);
8314 VARIMP(I1
,-1,UI2
,1,I4
,1);
8315 VARIMP(I1
,-1,UI4
,1,I4
,1);
8316 if (HAVE_OLEAUT32_I8
)
8318 VARIMP(I1
,-1,I8
,1,I8
,1);
8319 VARIMP(I1
,-1,UI8
,1,I4
,1);
8321 VARIMP(I1
,-1,INT
,-1,I4
,-1);
8322 VARIMP(I1
,-1,UINT
,1,I4
,1);
8323 VARIMP(UI1
,0,EMPTY
,0,I2
,-1);
8324 VARIMP(UI1
,0,NULL
,0,UI1
,255);
8325 VARIMP(UI1
,0,I2
,-1,I2
,-1);
8326 VARIMP(UI1
,0,I4
,-1,I4
,-1);
8327 VARIMP(UI1
,0,R4
,0.0f
,I4
,-1);
8328 VARIMP(UI1
,0,R8
,-1.0,I4
,-1);
8329 VARIMP(UI1
,0,DATE
,0,I4
,-1);
8330 VARIMP(UI1
,0,BSTR
,true_str
,I2
,-1);
8331 VARIMP(UI1
,0,BOOL
,VARIANT_FALSE
,I2
,-1);
8332 VARIMP(UI1
,0,I1
,0,I4
,-1);
8333 VARIMP(UI1
,0,UI1
,1,UI1
,255);
8334 VARIMP(UI1
,0,UI2
,1,I4
,-1);
8335 VARIMP(UI1
,0,UI4
,1,I4
,-1);
8336 if (HAVE_OLEAUT32_I8
)
8338 VARIMP(UI1
,0,I8
,1,I8
,-1);
8339 VARIMP(UI1
,0,UI8
,1,I4
,-1);
8341 VARIMP(UI1
,0,INT
,-1,I4
,-1);
8342 VARIMP(UI1
,0,UINT
,1,I4
,-1);
8343 VARIMP(UI2
,0,EMPTY
,0,I4
,-1);
8344 VARIMP(UI2
,0,NULL
,0,I4
,-1);
8345 VARIMP(UI2
,0,I2
,-1,I4
,-1);
8346 VARIMP(UI2
,0,I4
,-1,I4
,-1);
8347 VARIMP(UI2
,0,R4
,0.0f
,I4
,-1);
8348 VARIMP(UI2
,0,R8
,-1.0,I4
,-1);
8349 VARIMP(UI2
,0,DATE
,0,I4
,-1);
8350 VARIMP(UI2
,0,BSTR
,true_str
,I4
,-1);
8351 VARIMP(UI2
,0,BOOL
,VARIANT_FALSE
,I4
,-1);
8352 VARIMP(UI2
,0,I1
,0,I4
,-1);
8353 VARIMP(UI2
,0,UI1
,1,I4
,-1);
8354 VARIMP(UI2
,0,UI2
,1,I4
,-1);
8355 VARIMP(UI2
,0,UI4
,1,I4
,-1);
8356 if (HAVE_OLEAUT32_I8
)
8358 VARIMP(UI2
,0,I8
,1,I8
,-1);
8359 VARIMP(UI2
,0,UI8
,1,I4
,-1);
8361 VARIMP(UI2
,0,INT
,-1,I4
,-1);
8362 VARIMP(UI2
,0,UINT
,1,I4
,-1);
8363 VARIMP(UI4
,0,EMPTY
,0,I4
,-1);
8364 VARIMP(UI4
,0,NULL
,0,I4
,-1);
8365 VARIMP(UI4
,0,I2
,-1,I4
,-1);
8366 VARIMP(UI4
,0,I4
,-1,I4
,-1);
8367 VARIMP(UI4
,0,R4
,0.0f
,I4
,-1);
8368 VARIMP(UI4
,0,R8
,-1.0,I4
,-1);
8369 VARIMP(UI4
,0,DATE
,0,I4
,-1);
8370 VARIMP(UI4
,0,BSTR
,true_str
,I4
,-1);
8371 VARIMP(UI4
,0,BOOL
,VARIANT_FALSE
,I4
,-1);
8372 VARIMP(UI4
,0,I1
,0,I4
,-1);
8373 VARIMP(UI4
,0,UI1
,1,I4
,-1);
8374 VARIMP(UI4
,0,UI2
,1,I4
,-1);
8375 VARIMP(UI4
,0,UI4
,1,I4
,-1);
8376 if (HAVE_OLEAUT32_I8
)
8378 VARIMP(UI4
,0,I8
,1,I8
,-1);
8379 VARIMP(UI4
,0,UI8
,1,I4
,-1);
8381 VARIMP(UI4
,0,INT
,-1,I4
,-1);
8382 VARIMP(UI4
,0,UINT
,1,I4
,-1);
8383 if (HAVE_OLEAUT32_I8
)
8385 VARIMP(I8
,-1,EMPTY
,0,I8
,0);
8386 VARIMP(I8
,-1,NULL
,0,NULL
,0);
8387 VARIMP(I8
,-1,I2
,-1,I8
,-1);
8388 VARIMP(I8
,-1,I4
,-1,I8
,-1);
8389 VARIMP(I8
,-1,R4
,0.0f
,I8
,0);
8390 VARIMP(I8
,-1,R8
,-1.0,I8
,-1);
8391 VARIMP(I8
,-1,DATE
,0,I8
,0);
8392 VARIMP(I8
,-1,BSTR
,true_str
,I8
,-1);
8393 VARIMP(I8
,-1,BOOL
,VARIANT_FALSE
,I8
,0);
8394 VARIMP(I8
,-1,I1
,0,I8
,0);
8395 VARIMP(I8
,-1,UI1
,1,I8
,1);
8396 VARIMP(I8
,-1,UI2
,1,I8
,1);
8397 VARIMP(I8
,-1,UI4
,1,I8
,1);
8398 VARIMP(I8
,-1,I8
,1,I8
,1);
8399 VARIMP(I8
,-1,UI8
,1,I8
,1);
8400 VARIMP(I8
,-1,UINT
,1,I8
,1);
8401 VARIMP(UI8
,0,EMPTY
,0,I4
,-1);
8402 VARIMP(UI8
,0,NULL
,0,I4
,-1);
8403 VARIMP(UI8
,0,I2
,-1,I4
,-1);
8404 VARIMP(UI8
,0,I4
,-1,I4
,-1);
8405 VARIMP(UI8
,0,R4
,0.0f
,I4
,-1);
8406 VARIMP(UI8
,0,R8
,-1.0,I4
,-1);
8407 VARIMP(UI8
,0,DATE
,0,I4
,-1);
8408 VARIMP(UI8
,0,BSTR
,true_str
,I4
,-1);
8409 VARIMP(UI8
,0,BOOL
,VARIANT_FALSE
,I4
,-1);
8410 VARIMP(UI8
,0,I1
,0,I4
,-1);
8411 VARIMP(UI8
,0,UI1
,1,I4
,-1);
8412 VARIMP(UI8
,0,UI2
,1,I4
,-1);
8413 VARIMP(UI8
,0,UI4
,1,I4
,-1);
8414 VARIMP(UI8
,0,I8
,1,I8
,-1);
8415 VARIMP(UI8
,0,UI8
,1,I4
,-1);
8416 VARIMP(UI8
,0,INT
,-1,I4
,-1);
8417 VARIMP(UI8
,0,UINT
,1,I4
,-1);
8419 VARIMP(INT
,-1,EMPTY
,0,I4
,0);
8420 VARIMP(INT
,-1,NULL
,0,NULL
,0);
8421 VARIMP(INT
,-1,I2
,-1,I4
,-1);
8422 VARIMP(INT
,-1,I4
,-1,I4
,-1);
8423 VARIMP(INT
,-1,R4
,0.0f
,I4
,0);
8424 VARIMP(INT
,-1,R8
,-1.0,I4
,-1);
8425 VARIMP(INT
,-1,DATE
,0,I4
,0);
8426 VARIMP(INT
,-1,BSTR
,true_str
,I4
,-1);
8427 VARIMP(INT
,-1,BOOL
,VARIANT_FALSE
,I4
,0);
8428 VARIMP(INT
,-1,I1
,0,I4
,0);
8429 VARIMP(INT
,-1,UI1
,1,I4
,1);
8430 VARIMP(INT
,-1,UI2
,1,I4
,1);
8431 VARIMP(INT
,-1,UI4
,1,I4
,1);
8432 if (HAVE_OLEAUT32_I8
)
8434 VARIMP(INT
,-1,I8
,1,I8
,1);
8435 VARIMP(INT
,-1,UI8
,1,I4
,1);
8437 VARIMP(INT
,-1,INT
,-1,I4
,-1);
8438 VARIMP(INT
,-1,UINT
,1,I4
,1);
8439 VARIMP(UINT
,1,EMPTY
,0,I4
,-2);
8440 VARIMP(UINT
,1,NULL
,0,I4
,-2);
8441 VARIMP(UINT
,1,I2
,-1,I4
,-1);
8442 VARIMP(UINT
,1,I4
,-1,I4
,-1);
8443 VARIMP(UINT
,1,R4
,0.0f
,I4
,-2);
8444 VARIMP(UINT
,1,R8
,-1.0,I4
,-1);
8445 VARIMP(UINT
,1,DATE
,0,I4
,-2);
8446 VARIMP(UINT
,1,BSTR
,true_str
,I4
,-1);
8447 VARIMP(UINT
,1,BOOL
,VARIANT_FALSE
,I4
,-2);
8448 VARIMP(UINT
,1,I1
,0,I4
,-2);
8449 VARIMP(UINT
,1,UI1
,1,I4
,-1);
8450 VARIMP(UINT
,1,UI2
,1,I4
,-1);
8451 VARIMP(UINT
,1,UI4
,1,I4
,-1);
8452 if (HAVE_OLEAUT32_I8
)
8454 VARIMP(UINT
,1,I8
,1,I8
,-1);
8455 VARIMP(UINT
,1,UI8
,1,I4
,-1);
8457 VARIMP(UINT
,1,INT
,-1,I4
,-1);
8458 VARIMP(UINT
,1,UINT
,1,I4
,-1);
8460 /* Manually test some VT_CY, VT_DECIMAL variants */
8462 hres
= VarCyFromI4(1, &V_CY(&cy
));
8463 ok(hres
== S_OK
, "VarCyFromI4 failed!\n");
8464 V_VT(&dec
) = VT_DECIMAL
;
8465 hres
= VarDecFromR8(2.0, &V_DECIMAL(&dec
));
8466 ok(hres
== S_OK
, "VarDecFromR4 failed!\n");
8467 memset(&left
, 0, sizeof(left
));
8468 memset(&right
, 0, sizeof(right
));
8469 V_VT(&left
) = VT_I4
;
8471 V_VT(&right
) = VT_I8
;
8474 hres
= pVarImp(&cy
, &cy
, &result
);
8475 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
8476 "VARIMP: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8477 S_OK
, hres
, vtstr(V_VT(&result
)));
8478 ok(hres
== S_OK
&& V_I4(&result
) == -1,
8479 "VARIMP: CY value %d, expected %d\n", V_I4(&result
), -1);
8481 if (HAVE_OLEAUT32_I8
)
8483 hres
= pVarImp(&cy
, &right
, &result
);
8484 ok(hres
== S_OK
&& V_VT(&result
) == VT_I8
,
8485 "VARIMP: expected coerced hres 0x%X type VT_I8, got hres 0x%X type %s!\n",
8486 S_OK
, hres
, vtstr(V_VT(&result
)));
8487 ok(hres
== S_OK
&& V_I8(&result
) == -2,
8488 "VARIMP: CY value %x%08x, expected %d\n",
8489 (DWORD
)((V_I8(&result
)) >> 32), (DWORD
)(V_I8(&result
)), -2);
8492 hres
= pVarImp(&left
, &cy
, &result
);
8493 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
8494 "VARIMP: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8495 S_OK
, hres
, vtstr(V_VT(&result
)));
8496 ok(hres
== S_OK
&& V_I4(&result
) == -1,
8497 "VARIMP: CY value %d, expected %d\n", V_I4(&result
), -1);
8499 hres
= pVarImp(&left
, &dec
, &result
);
8500 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
8501 "VARIMP: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8502 S_OK
, hres
, vtstr(V_VT(&result
)));
8503 ok(hres
== S_OK
&& V_I4(&result
) == -1,
8504 "VARIMP: DECIMAL value %d, expected %d\n", V_I4(&result
), -1);
8506 hres
= pVarImp(&dec
, &dec
, &result
);
8507 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
8508 "VARIMP: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8509 S_OK
, hres
, vtstr(V_VT(&result
)));
8510 ok(hres
== S_OK
&& V_I4(&result
) == -1,
8511 "VARIMP: DECIMAL value %d, expected %d\n", V_I4(&result
), -1);
8513 if (HAVE_OLEAUT32_I8
)
8515 hres
= pVarImp(&dec
, &right
, &result
);
8516 ok(hres
== S_OK
&& V_VT(&result
) == VT_I8
,
8517 "VARIMP: expected coerced hres 0x%X type VT_I8, got hres 0x%X type %s!\n",
8518 S_OK
, hres
, vtstr(V_VT(&result
)));
8519 ok(hres
== S_OK
&& V_I8(&result
) == -3,
8520 "VARIMP: DECIMAL value 0x%x%08x, expected %d\n",
8521 (DWORD
)(V_I8(&result
) >>32), (DWORD
)V_I8(&result
), -3);
8524 SysFreeString(false_str
);
8525 SysFreeString(true_str
);
8533 test_VariantClear();
8535 test_VariantCopyInd();
8536 test_VarParseNumFromStr();
8537 test_VarNumFromParseNum();
8538 test_VarUdateFromDate();
8539 test_VarDateFromUdate();
8540 test_SystemTimeToVariantTime();
8541 test_VariantTimeToSystemTime();
8542 test_DosDateTimeToVariantTime();
8543 test_VariantTimeToDosDateTime();