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
31 #include "wine/test.h"
41 static HMODULE hOleaut32
;
43 static HRESULT (WINAPI
*pVarUdateFromDate
)(DATE
,ULONG
,UDATE
*);
44 static HRESULT (WINAPI
*pVarDateFromUdate
)(UDATE
*,ULONG
,DATE
*);
45 static INT (WINAPI
*pSystemTimeToVariantTime
)(LPSYSTEMTIME
,double*);
46 static INT (WINAPI
*pVariantTimeToSystemTime
)(double,LPSYSTEMTIME
);
47 static INT (WINAPI
*pDosDateTimeToVariantTime
)(USHORT
,USHORT
,double*);
48 static INT (WINAPI
*pVariantTimeToDosDateTime
)(double,USHORT
*,USHORT
*);
50 /* Get a conversion function ptr, return if function not available */
51 #define CHECKPTR(func) p##func = (void*)GetProcAddress(hOleaut32, #func); \
52 if (!p##func) { trace("function " # func " not available, not testing it\n"); return; }
54 /* Is a given function exported from oleaut32? */
55 #define HAVE_FUNC(func) ((void*)GetProcAddress(hOleaut32, #func) != NULL)
57 /* Have IRecordInfo data type? */
58 #define HAVE_OLEAUT32_RECORD HAVE_FUNC(SafeArraySetRecordInfo)
59 /* Have CY data type? */
60 #define HAVE_OLEAUT32_CY HAVE_FUNC(VarCyAdd)
61 /* Have I8/UI8 data type? */
62 #define HAVE_OLEAUT32_I8 HAVE_FUNC(VarI8FromI1)
63 /* Is this an ancient version with support for only I2/I4/R4/R8/DATE? */
64 #define IS_ANCIENT (!HAVE_FUNC(VarI1FromI2))
66 /* When comparing floating point values we cannot expect an exact match
67 * because the rounding errors depend on the exact algorithm.
69 #define EQ_DOUBLE(a,b) (fabs((a)-(b)) / (1.0+fabs(a)+fabs(b)) < 1e-14)
70 #define EQ_FLOAT(a,b) (fabs((a)-(b)) / (1.0+fabs(a)+fabs(b)) < 1e-7)
72 #define SKIPTESTS(a) if((a > VT_CLSID+10) && (a < VT_BSTR_BLOB-10)) continue
74 /* Allow our test macros to work for VT_NULL and VT_EMPTY too */
75 #define V_EMPTY(v) V_I4(v)
76 #define V_NULL(v) V_I4(v)
78 /* Size constraints for overflow tests */
80 #define I1_MIN ((-I1_MAX)-1)
84 #define I2_MIN ((-I2_MAX)-1)
85 #define UI2_MAX 0xffff
87 #define I4_MAX 0x7fffffff
88 #define I4_MIN ((-I4_MAX)-1)
89 #define UI4_MAX 0xffffffff
91 #define I8_MAX (((LONGLONG)I4_MAX << 32) | UI4_MAX)
92 #define I8_MIN ((-I8_MAX)-1)
93 #define UI8_MAX (((ULONGLONG)UI4_MAX << 32) | UI4_MAX)
95 #define DATE_MAX 2958465
96 #define DATE_MIN -657434
97 #define R4_MAX FLT_MAX
98 #define R4_MIN FLT_MIN
99 #define R8_MAX DBL_MAX
100 #define R8_MIN DBL_MIN
102 /* Functions to set a DECIMAL */
103 static void setdec(DECIMAL
* dec
, BYTE scl
, BYTE sgn
, ULONG hi32
, ULONG64 lo64
)
105 S(U(*dec
)).scale
= scl
;
106 S(U(*dec
)).sign
= sgn
;
108 U1(*dec
).Lo64
= lo64
;
111 static void setdec64(DECIMAL
* dec
, BYTE scl
, BYTE sgn
, ULONG hi32
, ULONG mid32
, ULONG lo32
)
113 S(U(*dec
)).scale
= scl
;
114 S(U(*dec
)).sign
= sgn
;
116 S1(U1(*dec
)).Mid32
= mid32
;
117 S1(U1(*dec
)).Lo32
= lo32
;
120 static inline int strcmpW( const WCHAR
*str1
, const WCHAR
*str2
)
122 while (*str1
&& (*str1
== *str2
)) { str1
++; str2
++; }
123 return *str1
- *str2
;
126 /* return the string text of a given variant type */
127 static char vtstr_buffer
[16][256];
128 static int vtstr_current
=0;
129 static const char *vtstr(int x
)
132 #define CASE(vt) case VT_##vt: return #vt
171 CASE(STREAMED_OBJECT
);
176 CASE(VERSIONED_STREAM
);
185 return "VT_BSTR_BLOB/VT_ILLEGALMASKED/VT_TYPEMASK";
188 vtstr_current
%= sizeof(vtstr_buffer
)/sizeof(*vtstr_buffer
);
189 sprintf(vtstr_buffer
[vtstr_current
], "unknown variant type %d", x
);
190 return vtstr_buffer
[vtstr_current
++];
194 static const char *variantstr( const VARIANT
*var
)
196 vtstr_current
%= sizeof(vtstr_buffer
)/sizeof(*vtstr_buffer
);
200 sprintf( vtstr_buffer
[vtstr_current
], "VT_I1(%d)", V_I1(var
) ); break;
202 sprintf( vtstr_buffer
[vtstr_current
], "VT_I2(%d)", V_I2(var
) ); break;
204 sprintf( vtstr_buffer
[vtstr_current
], "VT_I4(%d)", V_I4(var
) ); break;
206 sprintf( vtstr_buffer
[vtstr_current
], "VT_INT(%d)", V_INT(var
) ); break;
208 sprintf( vtstr_buffer
[vtstr_current
], "VT_I8(%x%08x)", (UINT
)(V_I8(var
) >> 32), (UINT
)V_I8(var
) ); break;
210 sprintf( vtstr_buffer
[vtstr_current
], "VT_UI8(%x%08x)", (UINT
)(V_UI8(var
) >> 32), (UINT
)V_UI8(var
) ); break;
212 sprintf( vtstr_buffer
[vtstr_current
], "VT_R4(%g)", V_R4(var
) ); break;
214 sprintf( vtstr_buffer
[vtstr_current
], "VT_R8(%g)", V_R8(var
) ); break;
216 sprintf( vtstr_buffer
[vtstr_current
], "VT_UI1(%u)", V_UI1(var
) ); break;
218 sprintf( vtstr_buffer
[vtstr_current
], "VT_UI2(%u)", V_UI2(var
) ); break;
220 sprintf( vtstr_buffer
[vtstr_current
], "VT_UI4(%u)", V_UI4(var
) ); break;
222 sprintf( vtstr_buffer
[vtstr_current
], "VT_UINT(%d)", V_UINT(var
) ); break;
224 sprintf( vtstr_buffer
[vtstr_current
], "VT_CY(%x%08x)", S(V_CY(var
)).Hi
, S(V_CY(var
)).Lo
); break;
226 sprintf( vtstr_buffer
[vtstr_current
], "VT_DATE(%g)", V_DATE(var
) ); break;
228 return vtstr(V_VT(var
));
230 return vtstr_buffer
[vtstr_current
++];
233 static BOOL
is_expected_variant( const VARIANT
*result
, const VARIANT
*expected
)
235 if (V_VT(result
) != V_VT(expected
)) return FALSE
;
236 switch(V_VT(expected
))
242 #define CASE(vt) case VT_##vt: return (V_##vt(result) == V_##vt(expected))
257 return EQ_FLOAT(V_DATE(result
), V_DATE(expected
));
259 return EQ_FLOAT(V_R4(result
), V_R4(expected
));
261 return EQ_FLOAT(V_R8(result
), V_R8(expected
));
263 return (V_CY(result
).int64
== V_CY(expected
).int64
);
265 return !lstrcmpW( V_BSTR(result
), V_BSTR(expected
) );
267 return !memcmp( &V_DECIMAL(result
), &V_DECIMAL(expected
), sizeof(DECIMAL
) );
269 ok(0, "unhandled variant type %s\n",vtstr(V_VT(expected
)));
274 static void test_var_call1( int line
, HRESULT (WINAPI
*func
)(LPVARIANT
,LPVARIANT
),
275 VARIANT
*arg
, VARIANT
*expected
)
277 VARIANT old_arg
= *arg
;
281 memset( &result
, 0, sizeof(result
) );
282 hres
= func( arg
, &result
);
283 ok_(__FILE__
,line
)( hres
== S_OK
, "wrong result %x\n", hres
);
285 ok_(__FILE__
,line
)( is_expected_variant( &result
, expected
),
286 "got %s expected %s\n", variantstr(&result
), variantstr(expected
) );
287 ok_(__FILE__
,line
)( is_expected_variant( arg
, &old_arg
), "Modified argument %s / %s\n",
288 variantstr(&old_arg
), variantstr(arg
));
291 static void test_var_call2( int line
, HRESULT (WINAPI
*func
)(LPVARIANT
,LPVARIANT
,LPVARIANT
),
292 VARIANT
*left
, VARIANT
*right
, VARIANT
*expected
)
294 VARIANT old_left
= *left
, old_right
= *right
;
298 memset( &result
, 0, sizeof(result
) );
299 hres
= func( left
, right
, &result
);
300 ok_(__FILE__
,line
)( hres
== S_OK
, "wrong result %x\n", hres
);
302 ok_(__FILE__
,line
)( is_expected_variant( &result
, expected
),
303 "got %s expected %s\n", variantstr(&result
), variantstr(expected
) );
304 ok_(__FILE__
,line
)( is_expected_variant( left
, &old_left
), "Modified left argument %s / %s\n",
305 variantstr(&old_left
), variantstr(left
));
306 ok_(__FILE__
,line
)( is_expected_variant( right
, &old_right
), "Modified right argument %s / %s\n",
307 variantstr(&old_right
), variantstr(right
));
311 static void test_VariantInit(void)
315 /* Test that VariantInit() only sets the type */
316 memset(&v1
, -1, sizeof(v1
));
318 V_VT(&v2
) = VT_EMPTY
;
320 ok(!memcmp(&v1
, &v2
, sizeof(v1
)), "VariantInit() set extra fields\n");
323 /* All possible combinations of extra V_VT() flags */
324 static const VARTYPE ExtraFlags
[16] =
333 VT_VECTOR
|VT_RESERVED
,
334 VT_VECTOR
|VT_ARRAY
|VT_BYREF
,
335 VT_VECTOR
|VT_ARRAY
|VT_RESERVED
,
336 VT_VECTOR
|VT_BYREF
|VT_RESERVED
,
337 VT_VECTOR
|VT_ARRAY
|VT_BYREF
|VT_RESERVED
,
339 VT_ARRAY
|VT_RESERVED
,
340 VT_ARRAY
|VT_BYREF
|VT_RESERVED
,
341 VT_BYREF
|VT_RESERVED
,
344 /* Determine if a vt is valid for VariantClear() */
345 static int IsValidVariantClearVT(VARTYPE vt
, VARTYPE extraFlags
)
349 /* Only the following flags/types are valid */
350 if ((vt
<= VT_LPWSTR
|| vt
== VT_RECORD
|| vt
== VT_CLSID
) &&
352 (vt
< (VARTYPE
)24 || vt
> (VARTYPE
)31) &&
353 (!(extraFlags
& (VT_BYREF
|VT_ARRAY
)) || vt
> VT_NULL
) &&
354 (extraFlags
== 0 || extraFlags
== VT_BYREF
|| extraFlags
== VT_ARRAY
||
355 extraFlags
== (VT_ARRAY
|VT_BYREF
)))
358 if ((vt
== VT_RECORD
&& !HAVE_OLEAUT32_RECORD
) ||
359 ((vt
== VT_I8
|| vt
== VT_UI8
) && !HAVE_OLEAUT32_I8
))
360 ret
= 0; /* Old versions of oleaut32 */
366 const IUnknownVtbl
*lpVtbl
;
369 } test_VariantClearImpl
;
371 static HRESULT WINAPI
VC_QueryInterface(LPUNKNOWN iface
,REFIID riid
,LPVOID
*ppobj
)
373 test_VariantClearImpl
*This
= (test_VariantClearImpl
*)iface
;
375 return E_NOINTERFACE
;
378 static ULONG WINAPI
VC_AddRef(LPUNKNOWN iface
) {
379 test_VariantClearImpl
*This
= (test_VariantClearImpl
*)iface
;
381 return InterlockedIncrement(&This
->ref
);
384 static ULONG WINAPI
VC_Release(LPUNKNOWN iface
) {
385 test_VariantClearImpl
*This
= (test_VariantClearImpl
*)iface
;
386 /* static class, won't be freed */
388 return InterlockedDecrement(&This
->ref
);
391 static const IUnknownVtbl test_VariantClear_vtbl
= {
397 static test_VariantClearImpl test_myVariantClearImpl
= {&test_VariantClear_vtbl
, 1, 0};
399 static void test_VariantClear(void)
408 /* Crashes: Native does not test input for NULL, so neither does Wine */
409 if (0) hres
= VariantClear(NULL
);
411 /* Only the type field is set, to VT_EMPTY */
414 hres
= VariantClear(&v
);
415 ok((hres
== S_OK
&& V_VT(&v
) == VT_EMPTY
) ||
416 (IS_ANCIENT
&& hres
== DISP_E_BADVARTYPE
&& V_VT(&v
) == VT_UI4
),
417 "VariantClear: Type set to %d, res %08x\n", V_VT(&v
), hres
);
418 ok(V_UI4(&v
) == ~0u, "VariantClear: Overwrote value\n");
420 /* Test all possible V_VT values.
421 * Also demonstrates that null pointers in 'v' are not dereferenced.
422 * Individual variant tests should test VariantClear() with non-NULL values.
424 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]) && !IS_ANCIENT
; i
++)
428 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
430 HRESULT hExpected
= DISP_E_BADVARTYPE
;
434 memset(&v
, 0, sizeof(v
));
435 V_VT(&v
) = vt
| ExtraFlags
[i
];
437 hres
= VariantClear(&v
);
439 if (IsValidVariantClearVT(vt
, ExtraFlags
[i
]))
442 ok(hres
== hExpected
, "VariantClear: expected 0x%X, got 0x%X for vt %d | 0x%X\n",
443 hExpected
, hres
, vt
, ExtraFlags
[i
]);
447 /* Some BYREF tests with non-NULL ptrs */
452 V_VT(&v
) = VT_VARIANT
| VT_BYREF
;
453 V_VARIANTREF(&v
) = &v2
;
455 hres
= VariantClear(&v
);
456 ok(hres
== S_OK
, "ret %08x\n", hres
);
457 ok(V_VT(&v
) == 0, "vt %04x\n", V_VT(&v
));
458 ok(V_VARIANTREF(&v
) == &v2
, "variant ref %p\n", V_VARIANTREF(&v2
));
459 ok(V_VT(&v2
) == VT_I4
, "vt %04x\n", V_VT(&v2
));
460 ok(V_I4(&v2
) == 0x1234, "i4 %04x\n", V_I4(&v2
));
464 V_VT(&v
) = VT_I4
| VT_BYREF
;
467 hres
= VariantClear(&v
);
468 ok(hres
== S_OK
, "ret %08x\n", hres
);
469 ok(V_VT(&v
) == 0, "vt %04x\n", V_VT(&v
));
470 ok(V_I4REF(&v
) == &i4
, "i4 ref %p\n", V_I4REF(&v2
));
471 ok(i4
== 0x4321, "i4 changed %08x\n", i4
);
475 V_VT(&v
) = VT_UNKNOWN
;
476 V_UNKNOWN(&v
) = (IUnknown
*)&test_myVariantClearImpl
;
477 test_myVariantClearImpl
.events
= 0;
478 hres
= VariantClear(&v
);
479 ok(hres
== S_OK
, "ret %08x\n", hres
);
480 ok(V_VT(&v
) == 0, "vt %04x\n", V_VT(&v
));
481 ok(V_UNKNOWN(&v
) == (IUnknown
*)&test_myVariantClearImpl
, "unknown %p\n", V_UNKNOWN(&v
));
482 /* Check that Release got called, but nothing else */
483 ok(test_myVariantClearImpl
.events
== 0x4, "Unexpected call. events %08x\n", test_myVariantClearImpl
.events
);
486 punk
= (IUnknown
*)&test_myVariantClearImpl
;
487 V_VT(&v
) = VT_UNKNOWN
| VT_BYREF
;
488 V_UNKNOWNREF(&v
) = &punk
;
489 test_myVariantClearImpl
.events
= 0;
490 hres
= VariantClear(&v
);
491 ok(hres
== S_OK
, "ret %08x\n", hres
);
492 ok(V_VT(&v
) == 0, "vt %04x\n", V_VT(&v
));
493 ok(V_UNKNOWNREF(&v
) == &punk
, "unknown ref %p\n", V_UNKNOWNREF(&v
));
494 /* Check that nothing got called */
495 ok(test_myVariantClearImpl
.events
== 0, "Unexpected call. events %08x\n", test_myVariantClearImpl
.events
);
498 V_VT(&v
) = VT_DISPATCH
;
499 V_DISPATCH(&v
) = (IDispatch
*)&test_myVariantClearImpl
;
500 test_myVariantClearImpl
.events
= 0;
501 hres
= VariantClear(&v
);
502 ok(hres
== S_OK
, "ret %08x\n", hres
);
503 ok(V_VT(&v
) == 0, "vt %04x\n", V_VT(&v
));
504 ok(V_DISPATCH(&v
) == (IDispatch
*)&test_myVariantClearImpl
, "dispatch %p\n", V_DISPATCH(&v
));
505 /* Check that Release got called, but nothing else */
506 ok(test_myVariantClearImpl
.events
== 0x4, "Unexpected call. events %08x\n", test_myVariantClearImpl
.events
);
509 punk
= (IUnknown
*)&test_myVariantClearImpl
;
510 V_VT(&v
) = VT_DISPATCH
| VT_BYREF
;
511 V_DISPATCHREF(&v
) = (IDispatch
**)&punk
;
512 test_myVariantClearImpl
.events
= 0;
513 hres
= VariantClear(&v
);
514 ok(hres
== S_OK
, "ret %08x\n", hres
);
515 ok(V_VT(&v
) == 0, "vt %04x\n", V_VT(&v
));
516 ok(V_DISPATCHREF(&v
) == (IDispatch
**)&punk
, "dispatch ref %p\n", V_DISPATCHREF(&v
));
517 /* Check that nothing got called */
518 ok(test_myVariantClearImpl
.events
== 0, "Unexpected call. events %08x\n", test_myVariantClearImpl
.events
);
521 static void test_VariantCopy(void)
523 VARIANTARG vSrc
, vDst
;
526 HRESULT hres
, hExpected
;
528 /* Establish that the failure/other cases are dealt with. Individual tests
529 * for each type should verify that data is copied correctly, references
534 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]) && !IS_ANCIENT
; i
++)
536 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
540 memset(&vSrc
, 0, sizeof(vSrc
));
541 V_VT(&vSrc
) = vt
| ExtraFlags
[i
];
543 hExpected
= DISP_E_BADVARTYPE
;
544 /* src is allowed to be a VT_CLSID */
545 if (vt
!= VT_CLSID
&& IsValidVariantClearVT(vt
, ExtraFlags
[i
]))
548 hres
= VariantCopy(&vSrc
, &vSrc
);
550 ok(hres
== hExpected
,
551 "Copy(src==dst): expected 0x%X, got 0x%X for src==dest vt %d|0x%X\n",
552 hExpected
, hres
, vt
, ExtraFlags
[i
]);
556 /* Test that if VariantClear() fails on dest, the function fails. This also
557 * shows that dest is in fact cleared and not just overwritten
559 memset(&vSrc
, 0, sizeof(vSrc
));
560 V_VT(&vSrc
) = VT_UI1
;
562 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]) && !IS_ANCIENT
; i
++)
564 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
568 hExpected
= DISP_E_BADVARTYPE
;
570 memset(&vDst
, 0, sizeof(vDst
));
571 V_VT(&vDst
) = vt
| ExtraFlags
[i
];
573 if (IsValidVariantClearVT(vt
, ExtraFlags
[i
]))
576 hres
= VariantCopy(&vDst
, &vSrc
);
578 ok(hres
== hExpected
,
579 "Copy(bad dst): expected 0x%X, got 0x%X for dest vt %d|0x%X\n",
580 hExpected
, hres
, vt
, ExtraFlags
[i
]);
582 ok(V_VT(&vDst
) == VT_UI1
,
583 "Copy(bad dst): expected vt = VT_UI1, got %d\n", V_VT(&vDst
));
587 /* Test that VariantClear() checks vSrc for validity before copying */
588 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]) && !IS_ANCIENT
; i
++)
590 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
594 hExpected
= DISP_E_BADVARTYPE
;
596 memset(&vDst
, 0, sizeof(vDst
));
597 V_VT(&vDst
) = VT_EMPTY
;
599 memset(&vSrc
, 0, sizeof(vSrc
));
600 V_VT(&vSrc
) = vt
| ExtraFlags
[i
];
602 /* src is allowed to be a VT_CLSID */
603 if (vt
!= VT_CLSID
&& IsValidVariantClearVT(vt
, ExtraFlags
[i
]))
606 hres
= VariantCopy(&vDst
, &vSrc
);
608 ok(hres
== hExpected
,
609 "Copy(bad src): expected 0x%X, got 0x%X for src vt %d|0x%X\n",
610 hExpected
, hres
, vt
, ExtraFlags
[i
]);
612 ok(V_VT(&vDst
) == (vt
|ExtraFlags
[i
]),
613 "Copy(bad src): expected vt = %d, got %d\n",
614 vt
| ExtraFlags
[i
], V_VT(&vDst
));
618 /* Test that copying a NULL BSTR results in an empty BSTR */
619 memset(&vDst
, 0, sizeof(vDst
));
620 V_VT(&vDst
) = VT_EMPTY
;
621 memset(&vSrc
, 0, sizeof(vSrc
));
622 V_VT(&vSrc
) = VT_BSTR
;
623 hres
= VariantCopy(&vDst
, &vSrc
);
624 ok(hres
== S_OK
, "Copy(NULL BSTR): Failed to copy a NULL BSTR\n");
627 ok((V_VT(&vDst
) == VT_BSTR
) && V_BSTR(&vDst
),
628 "Copy(NULL BSTR): should have non-NULL result\n");
629 if ((V_VT(&vDst
) == VT_BSTR
) && V_BSTR(&vDst
))
631 ok(*V_BSTR(&vDst
) == 0, "Copy(NULL BSTR): result not empty\n");
636 /* Determine if a vt is valid for VariantCopyInd() */
637 static int IsValidVariantCopyIndVT(VARTYPE vt
, VARTYPE extraFlags
)
641 if ((extraFlags
& VT_ARRAY
) ||
642 (vt
> VT_NULL
&& vt
!= (VARTYPE
)15 && vt
< VT_VOID
&&
643 !(extraFlags
& (VT_VECTOR
|VT_RESERVED
))))
650 static void test_VariantCopyInd(void)
652 VARIANTARG vSrc
, vDst
, vRef
, vRef2
;
656 HRESULT hres
, hExpected
;
658 memset(buffer
, 0, sizeof(buffer
));
661 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]) && !IS_ANCIENT
; i
++)
663 if (ExtraFlags
[i
] & VT_ARRAY
)
664 continue; /* Native crashes on NULL safearray */
666 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
670 memset(&vSrc
, 0, sizeof(vSrc
));
671 V_VT(&vSrc
) = vt
| ExtraFlags
[i
];
673 hExpected
= DISP_E_BADVARTYPE
;
674 if (!(ExtraFlags
[i
] & VT_BYREF
))
676 /* if src is not by-reference, acts as VariantCopy() */
677 if (vt
!= VT_CLSID
&& IsValidVariantClearVT(vt
, ExtraFlags
[i
]))
682 if (vt
== VT_SAFEARRAY
|| vt
== VT_BSTR
|| vt
== VT_UNKNOWN
||
683 vt
== VT_DISPATCH
|| vt
== VT_RECORD
)
684 continue; /* Need valid ptrs for deep copies */
686 V_BYREF(&vSrc
) = &buffer
;
687 hExpected
= E_INVALIDARG
;
689 if ((vt
== VT_I8
|| vt
== VT_UI8
) &&
690 ExtraFlags
[i
] == VT_BYREF
)
692 if (HAVE_OLEAUT32_I8
)
693 hExpected
= S_OK
; /* Only valid if I8 is a known type */
695 else if (IsValidVariantCopyIndVT(vt
, ExtraFlags
[i
]))
699 hres
= VariantCopyInd(&vSrc
, &vSrc
);
701 ok(hres
== hExpected
,
702 "CopyInd(src==dst): expected 0x%X, got 0x%X for src==dst vt %d|0x%X\n",
703 hExpected
, hres
, vt
, ExtraFlags
[i
]);
708 memset(&vSrc
, 0, sizeof(vSrc
));
709 V_VT(&vSrc
) = VT_UI1
|VT_BYREF
;
710 V_BYREF(&vSrc
) = &buffer
;
712 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]) && !IS_ANCIENT
; i
++)
714 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
718 memset(&vDst
, 0, sizeof(vDst
));
719 V_VT(&vDst
) = vt
| ExtraFlags
[i
];
721 hExpected
= DISP_E_BADVARTYPE
;
723 if (IsValidVariantClearVT(vt
, ExtraFlags
[i
]))
726 hres
= VariantCopyInd(&vDst
, &vSrc
);
728 ok(hres
== hExpected
,
729 "CopyInd(bad dst): expected 0x%X, got 0x%X for dst vt %d|0x%X\n",
730 hExpected
, hres
, vt
, ExtraFlags
[i
]);
732 ok(V_VT(&vDst
) == VT_UI1
,
733 "CopyInd(bad dst): expected vt = VT_UI1, got %d\n", V_VT(&vDst
));
738 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]) && !IS_ANCIENT
; i
++)
740 if (ExtraFlags
[i
] & VT_ARRAY
)
741 continue; /* Native crashes on NULL safearray */
743 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
747 memset(&vDst
, 0, sizeof(vDst
));
748 V_VT(&vDst
) = VT_EMPTY
;
750 memset(&vSrc
, 0, sizeof(vSrc
));
751 V_VT(&vSrc
) = vt
| ExtraFlags
[i
];
753 hExpected
= DISP_E_BADVARTYPE
;
754 if (!(ExtraFlags
[i
] & VT_BYREF
))
756 /* if src is not by-reference, acts as VariantCopy() */
757 if (vt
!= VT_CLSID
&& IsValidVariantClearVT(vt
, ExtraFlags
[i
]))
762 if (vt
== VT_SAFEARRAY
|| vt
== VT_BSTR
|| vt
== VT_UNKNOWN
||
763 vt
== VT_DISPATCH
|| vt
== VT_RECORD
)
764 continue; /* Need valid ptrs for deep copies, see vartype.c */
766 V_BYREF(&vSrc
) = &buffer
;
768 hExpected
= E_INVALIDARG
;
770 if ((vt
== VT_I8
|| vt
== VT_UI8
) &&
771 ExtraFlags
[i
] == VT_BYREF
)
773 if (HAVE_OLEAUT32_I8
)
774 hExpected
= S_OK
; /* Only valid if I8 is a known type */
776 else if (IsValidVariantCopyIndVT(vt
, ExtraFlags
[i
]))
780 hres
= VariantCopyInd(&vDst
, &vSrc
);
782 ok(hres
== hExpected
,
783 "CopyInd(bad src): expected 0x%X, got 0x%X for src vt %d|0x%X\n",
784 hExpected
, hres
, vt
, ExtraFlags
[i
]);
787 if (vt
== VT_VARIANT
&& ExtraFlags
[i
] == VT_BYREF
)
789 /* Type of vDst should be the type of the referenced variant.
790 * Since we set the buffer to all zeros, its type should be
793 ok(V_VT(&vDst
) == VT_EMPTY
,
794 "CopyInd(bad src): expected dst vt = VT_EMPTY, got %d|0x%X\n",
795 V_VT(&vDst
) & VT_TYPEMASK
, V_VT(&vDst
) & ~VT_TYPEMASK
);
799 ok(V_VT(&vDst
) == (vt
|(ExtraFlags
[i
] & ~VT_BYREF
)),
800 "CopyInd(bad src): expected dst vt = %d|0x%X, got %d|0x%X\n",
801 vt
, ExtraFlags
[i
] & ~VT_BYREF
,
802 V_VT(&vDst
) & VT_TYPEMASK
, V_VT(&vDst
) & ~VT_TYPEMASK
);
808 /* By-reference variants are dereferenced */
809 V_VT(&vRef
) = VT_UI1
;
811 V_VT(&vSrc
) = VT_VARIANT
|VT_BYREF
;
812 V_VARIANTREF(&vSrc
) = &vRef
;
815 hres
= VariantCopyInd(&vDst
, &vSrc
);
816 ok(V_VT(&vDst
) == VT_UI1
&& V_UI1(&vDst
) == 0x77,
817 "CopyInd(deref): expected dst vt = VT_UI1, val 0x77, got %d|0x%X, 0x%2X\n",
818 V_VT(&vDst
) & VT_TYPEMASK
, V_VT(&vDst
) & ~VT_TYPEMASK
, V_UI1(&vDst
));
820 /* By-reference variant to a by-reference type succeeds */
821 V_VT(&vRef
) = VT_UI1
|VT_BYREF
;
822 V_UI1REF(&vRef
) = buffer
; buffer
[0] = 0x88;
823 V_VT(&vSrc
) = VT_VARIANT
|VT_BYREF
;
824 V_VARIANTREF(&vSrc
) = &vRef
;
827 hres
= VariantCopyInd(&vDst
, &vSrc
);
828 ok(V_VT(&vDst
) == VT_UI1
&& V_UI1(&vDst
) == 0x88,
829 "CopyInd(deref): expected dst vt = VT_UI1, val 0x77, got %d|0x%X, 0x%2X\n",
830 V_VT(&vDst
) & VT_TYPEMASK
, V_VT(&vDst
) & ~VT_TYPEMASK
, V_UI1(&vDst
));
832 /* But a by-reference variant to a by-reference variant fails */
833 V_VT(&vRef2
) = VT_UI1
;
834 V_UI1(&vRef2
) = 0x77;
835 V_VT(&vRef
) = VT_VARIANT
|VT_BYREF
;
836 V_VARIANTREF(&vRef
) = &vRef2
;
837 V_VT(&vSrc
) = VT_VARIANT
|VT_BYREF
;
838 V_VARIANTREF(&vSrc
) = &vRef
;
841 hres
= VariantCopyInd(&vDst
, &vSrc
);
842 ok(hres
== E_INVALIDARG
,
843 "CopyInd(ref->ref): expected E_INVALIDARG, got 0x%08x\n", hres
);
846 static HRESULT (WINAPI
*pVarParseNumFromStr
)(OLECHAR
*,LCID
,ULONG
,NUMPARSE
*,BYTE
*);
848 /* Macros for converting and testing the result of VarParseNumFromStr */
851 static HRESULT
convert_str( const char *str
, INT dig
, ULONG flags
,
852 NUMPARSE
*np
, BYTE rgb
[128], LCID lcid
)
855 MultiByteToWideChar( CP_ACP
,0, str
, -1, buff
, sizeof(buff
)/sizeof(WCHAR
) );
856 memset( rgb
, FAILDIG
, 128 );
857 memset( np
, 255, sizeof(*np
) );
859 np
->dwInFlags
= flags
;
860 return pVarParseNumFromStr( buff
, lcid
, LOCALE_NOUSEROVERRIDE
, np
, rgb
);
863 static void expect_NumFromStr( int line
, HRESULT hres
, NUMPARSE
*np
, INT a
, ULONG b
, ULONG c
,
864 INT d
, INT e
, INT f
)
866 if (hres
== (HRESULT
)S_OK
)
868 ok_(__FILE__
,line
)(np
->cDig
== a
, "Expected cDig = %d, got %d\n", a
, np
->cDig
);
869 ok_(__FILE__
,line
)(np
->dwInFlags
== b
, "Expected dwInFlags = 0x%x, got 0x%x\n", b
, np
->dwInFlags
);
870 ok_(__FILE__
,line
)(np
->dwOutFlags
== c
, "Expected dwOutFlags = 0x%x, got 0x%x\n", c
, np
->dwOutFlags
);
871 ok_(__FILE__
,line
)(np
->cchUsed
== d
, "Expected cchUsed = %d, got %d\n", d
, np
->cchUsed
);
872 ok_(__FILE__
,line
)(np
->nBaseShift
== e
, "Expected nBaseShift = %d, got %d\n", e
, np
->nBaseShift
);
873 ok_(__FILE__
,line
)(np
->nPwr10
== f
, "Expected nPwr10 = %d, got %d\n", f
, np
->nPwr10
);
877 #define CONVERTN(str,dig,flags) hres = convert_str( str, dig, flags, &np, rgb, lcid )
878 #define CONVERT(str,flags) CONVERTN(str,sizeof(rgb),flags)
879 #define EXPECT(a,b,c,d,e,f) expect_NumFromStr( __LINE__, hres, &np, a, b, c, d, e, f )
880 #define EXPECTRGB(a,b) ok(rgb[a] == b, "Digit[%d], expected %d, got %d\n", a, b, rgb[a])
881 #define EXPECTFAIL ok(hres == (HRESULT)DISP_E_TYPEMISMATCH, "Call succeeded, hres = %08x\n", hres)
882 #define EXPECT2(a,b) EXPECTRGB(0,a); EXPECTRGB(1,b)
884 static void test_VarParseNumFromStr(void)
887 /* Ensure all tests are using the same locale characters for '$', ',' etc */
888 LCID lcid
= MAKELCID(MAKELANGID(LANG_ENGLISH
,SUBLANG_ENGLISH_US
),SORT_DEFAULT
);
894 CHECKPTR(VarParseNumFromStr
);
896 /* Consume a single digit */
901 /* cDig is not literal digits - zeros are suppressed and nPwr10 is increased */
904 /* Note: Win32 writes the trailing zeros if they are within cDig's limits,
905 * but then excludes them from the returned cDig count.
906 * In our implementation we don't bother writing them at all.
910 /* if cDig is too small and numbers follow, sets INEXACT */
912 EXPECT(1,0,NUMPRS_INEXACT
,2,0,1);
915 /* Strips leading zeros */
920 /* Strips leading zeros */
926 /* Fails on non digits */
929 EXPECTRGB(0,FAILDIG
);
931 /** NUMPRS_LEADING_WHITE/NUMPRS_TRAILING_WHITE **/
933 /* Without flag, fails on whitespace */
936 EXPECTRGB(0,FAILDIG
);
939 /* With flag, consumes whitespace */
940 CONVERT(" 0", NUMPRS_LEADING_WHITE
);
941 EXPECT(1,NUMPRS_LEADING_WHITE
,NUMPRS_LEADING_WHITE
,2,0,0);
944 /* Test TAB once, then assume it acts as space for all cases */
945 CONVERT("\t0", NUMPRS_LEADING_WHITE
);
946 EXPECT(1,NUMPRS_LEADING_WHITE
,NUMPRS_LEADING_WHITE
,2,0,0);
950 /* Doesn't pick up trailing whitespace without flag */
955 /* With flag, consumes trailing whitespace */
956 CONVERT("0 ", NUMPRS_TRAILING_WHITE
);
957 EXPECT(1,NUMPRS_TRAILING_WHITE
,NUMPRS_TRAILING_WHITE
,2,0,0);
960 /* Leading flag only consumes leading */
961 CONVERT(" 0 ", NUMPRS_LEADING_WHITE
);
962 EXPECT(1,NUMPRS_LEADING_WHITE
,NUMPRS_LEADING_WHITE
,2,0,0);
965 /* Both flags consumes both */
966 CONVERT(" 0 ", NUMPRS_LEADING_WHITE
|NUMPRS_TRAILING_WHITE
);
967 EXPECT(1,NUMPRS_LEADING_WHITE
|NUMPRS_TRAILING_WHITE
,NUMPRS_LEADING_WHITE
|NUMPRS_TRAILING_WHITE
,3,0,0);
970 /** NUMPRS_LEADING_PLUS/NUMPRS_TRAILING_PLUS **/
972 /* Without flag, fails on + */
975 EXPECTRGB(0,FAILDIG
);
977 /* With flag, consumes + */
978 CONVERT("+0", NUMPRS_LEADING_PLUS
);
979 EXPECT(1,NUMPRS_LEADING_PLUS
,NUMPRS_LEADING_PLUS
,2,0,0);
982 /* Without flag, doesn't consume trailing + */
987 /* With flag, consumes trailing + */
988 CONVERT("0+", NUMPRS_TRAILING_PLUS
);
989 EXPECT(1,NUMPRS_TRAILING_PLUS
,NUMPRS_TRAILING_PLUS
,2,0,0);
992 /* With leading flag, doesn't consume trailing + */
993 CONVERT("+0+", NUMPRS_LEADING_PLUS
);
994 EXPECT(1,NUMPRS_LEADING_PLUS
,NUMPRS_LEADING_PLUS
,2,0,0);
997 /* Trailing + doesn't get consumed if we specify both (unlike whitespace) */
998 CONVERT("+0+", NUMPRS_LEADING_PLUS
|NUMPRS_TRAILING_PLUS
);
999 EXPECT(1,NUMPRS_LEADING_PLUS
|NUMPRS_TRAILING_PLUS
,NUMPRS_LEADING_PLUS
,2,0,0);
1002 /** NUMPRS_LEADING_MINUS/NUMPRS_TRAILING_MINUS **/
1004 /* Without flag, fails on - */
1007 EXPECTRGB(0,FAILDIG
);
1009 /* With flag, consumes - */
1010 CONVERT("-0", NUMPRS_LEADING_MINUS
);
1011 EXPECT(1,NUMPRS_LEADING_MINUS
,NUMPRS_NEG
|NUMPRS_LEADING_MINUS
,2,0,0);
1014 /* Without flag, doesn't consume trailing - */
1016 EXPECT(1,0,0,1,0,0);
1019 /* With flag, consumes trailing - */
1020 CONVERT("0-", NUMPRS_TRAILING_MINUS
);
1021 EXPECT(1,NUMPRS_TRAILING_MINUS
,NUMPRS_NEG
|NUMPRS_TRAILING_MINUS
,2,0,0);
1024 /* With leading flag, doesn't consume trailing - */
1025 CONVERT("-0-", NUMPRS_LEADING_MINUS
);
1026 EXPECT(1,NUMPRS_LEADING_MINUS
,NUMPRS_NEG
|NUMPRS_LEADING_MINUS
,2,0,0);
1029 /* Trailing - doesn't get consumed if we specify both (unlike whitespace) */
1030 CONVERT("-0-", NUMPRS_LEADING_MINUS
|NUMPRS_TRAILING_MINUS
);
1031 EXPECT(1,NUMPRS_LEADING_MINUS
|NUMPRS_TRAILING_MINUS
,NUMPRS_NEG
|NUMPRS_LEADING_MINUS
,2,0,0);
1034 /** NUMPRS_HEX_OCT **/
1036 /* Could be hex, octal or decimal - With flag reads as decimal */
1037 CONVERT("0", NUMPRS_HEX_OCT
);
1038 EXPECT(1,NUMPRS_HEX_OCT
,0,1,0,0);
1041 /* Doesn't recognise hex in .asm sytax */
1042 CONVERT("0h", NUMPRS_HEX_OCT
);
1043 EXPECT(1,NUMPRS_HEX_OCT
,0,1,0,0);
1046 /* Doesn't fail with valid leading string but no digits */
1047 CONVERT("0x", NUMPRS_HEX_OCT
);
1048 EXPECT(1,NUMPRS_HEX_OCT
,0,1,0,0);
1051 /* Doesn't recognise hex format humbers at all! */
1052 CONVERT("0x0", NUMPRS_HEX_OCT
);
1053 EXPECT(1,NUMPRS_HEX_OCT
,0,1,0,0);
1056 /* Doesn't recognise plain hex digits either */
1057 CONVERT("FE", NUMPRS_HEX_OCT
);
1059 EXPECTRGB(0,FAILDIG
);
1062 CONVERT("0100", NUMPRS_HEX_OCT
);
1063 EXPECT(1,NUMPRS_HEX_OCT
,0,4,0,2);
1067 EXPECTRGB(3,FAILDIG
);
1070 CONVERT("&HF800", NUMPRS_HEX_OCT
);
1071 EXPECT(4,NUMPRS_HEX_OCT
,0x40,6,4,0);
1076 EXPECTRGB(4,FAILDIG
);
1078 /* VB hex lower case and leading zero */
1079 CONVERT("&h0abcdef", NUMPRS_HEX_OCT
);
1080 EXPECT(6,NUMPRS_HEX_OCT
,0x40,9,4,0);
1087 EXPECTRGB(6,FAILDIG
);
1090 CONVERT("&O300", NUMPRS_HEX_OCT
);
1091 EXPECT(3,NUMPRS_HEX_OCT
,0x40,5,3,0);
1095 EXPECTRGB(3,FAILDIG
);
1097 /* VB oct lower case and leading zero */
1098 CONVERT("&o0777", NUMPRS_HEX_OCT
);
1099 EXPECT(3,NUMPRS_HEX_OCT
,0x40,6,3,0);
1103 EXPECTRGB(3,FAILDIG
);
1105 /* VB oct char bigger than 7 */
1106 CONVERT("&o128", NUMPRS_HEX_OCT
);
1108 Native versions 2.x of oleaut32 allow this to succeed: later versions and Wine don't
1110 EXPECTRGB(0,FAILDIG);
1112 /** NUMPRS_PARENS **/
1114 /* Empty parens = error */
1115 CONVERT("()", NUMPRS_PARENS
);
1117 EXPECTRGB(0,FAILDIG
);
1119 /* With flag, trailing parens not consumed */
1120 CONVERT("0()", NUMPRS_PARENS
);
1121 EXPECT(1,NUMPRS_PARENS
,0,1,0,0);
1124 /* With flag, Number in parens made negative and parens consumed */
1125 CONVERT("(0)", NUMPRS_PARENS
);
1126 EXPECT(1,NUMPRS_PARENS
,NUMPRS_NEG
|NUMPRS_PARENS
,3,0,0);
1129 /** NUMPRS_THOUSANDS **/
1131 /* With flag, thousands sep. not needed */
1132 CONVERT("0", NUMPRS_THOUSANDS
);
1133 EXPECT(1,NUMPRS_THOUSANDS
,0,1,0,0);
1136 /* With flag, thousands sep. and following digits consumed */
1137 CONVERT("1,000", NUMPRS_THOUSANDS
);
1138 EXPECT(1,NUMPRS_THOUSANDS
,NUMPRS_THOUSANDS
,5,0,3);
1141 /* With flag and decimal point, thousands sep. but not decimals consumed */
1142 CONVERT("1,000.0", NUMPRS_THOUSANDS
);
1143 EXPECT(1,NUMPRS_THOUSANDS
,NUMPRS_THOUSANDS
,5,0,3);
1146 /** NUMPRS_CURRENCY **/
1148 /* Without flag, chokes on currency sign */
1151 EXPECTRGB(0,FAILDIG
);
1153 /* With flag, consumes currency sign */
1154 CONVERT("$11", NUMPRS_CURRENCY
);
1155 EXPECT(2,NUMPRS_CURRENCY
,NUMPRS_CURRENCY
,3,0,0);
1157 EXPECTRGB(2,FAILDIG
);
1159 /* With flag only, doesn't consume decimal point */
1160 CONVERT("$11.1", NUMPRS_CURRENCY
);
1161 EXPECT(2,NUMPRS_CURRENCY
,NUMPRS_CURRENCY
,3,0,0);
1163 EXPECTRGB(2,FAILDIG
);
1165 /* With flag and decimal flag, consumes decimal point and following digits */
1166 CONVERT("$11.1", NUMPRS_CURRENCY
|NUMPRS_DECIMAL
);
1167 EXPECT(3,NUMPRS_CURRENCY
|NUMPRS_DECIMAL
,NUMPRS_CURRENCY
|NUMPRS_DECIMAL
,5,0,-1);
1170 EXPECTRGB(3,FAILDIG
);
1172 /* Thousands flag can only be used with currency */
1173 CONVERT("$1,234", NUMPRS_CURRENCY
|NUMPRS_THOUSANDS
);
1174 EXPECT(4,NUMPRS_CURRENCY
|NUMPRS_THOUSANDS
,NUMPRS_CURRENCY
|NUMPRS_THOUSANDS
,6,0,0);
1178 EXPECTRGB(4,FAILDIG
);
1180 /** NUMPRS_DECIMAL **/
1182 /* With flag, consumes decimal point */
1183 CONVERT("1.1", NUMPRS_DECIMAL
);
1184 EXPECT(2,NUMPRS_DECIMAL
,NUMPRS_DECIMAL
,3,0,-1);
1186 EXPECTRGB(2,FAILDIG
);
1188 /* With flag, consumes decimal point. Skipping the decimal part is not an error */
1189 CONVERT("1.", NUMPRS_DECIMAL
);
1190 EXPECT(1,NUMPRS_DECIMAL
,NUMPRS_DECIMAL
,2,0,0);
1193 /* Consumes only one decimal point */
1194 CONVERT("1.1.", NUMPRS_DECIMAL
);
1195 EXPECT(2,NUMPRS_DECIMAL
,NUMPRS_DECIMAL
,3,0,-1);
1197 EXPECTRGB(2,FAILDIG
);
1199 /** NUMPRS_EXPONENT **/
1201 /* Without flag, doesn't consume exponent */
1203 EXPECT(1,0,0,1,0,0);
1206 /* With flag, consumes exponent */
1207 CONVERT("1e1", NUMPRS_EXPONENT
);
1208 EXPECT(1,NUMPRS_EXPONENT
,NUMPRS_EXPONENT
,3,0,1);
1211 /* Negative exponents are accepted without flags */
1212 CONVERT("1e-1", NUMPRS_EXPONENT
);
1213 EXPECT(1,NUMPRS_EXPONENT
,NUMPRS_EXPONENT
,4,0,-1);
1216 /* As are positive exponents and leading exponent 0s */
1217 CONVERT("1e+01", NUMPRS_EXPONENT
);
1218 EXPECT(1,NUMPRS_EXPONENT
,NUMPRS_EXPONENT
,5,0,1);
1221 /* The same for zero exponents */
1222 CONVERT("1e0", NUMPRS_EXPONENT
);
1223 EXPECT(1,NUMPRS_EXPONENT
,NUMPRS_EXPONENT
,3,0,0);
1226 /* Sign on a zero exponent doesn't matter */
1227 CONVERT("1e+0", NUMPRS_EXPONENT
);
1228 EXPECT(1,NUMPRS_EXPONENT
,NUMPRS_EXPONENT
,4,0,0);
1231 CONVERT("1e-0", NUMPRS_EXPONENT
);
1232 EXPECT(1,NUMPRS_EXPONENT
,NUMPRS_EXPONENT
,4,0,0);
1235 /* Doesn't consume a real number exponent */
1236 CONVERT("1e1.", NUMPRS_EXPONENT
);
1237 EXPECT(1,NUMPRS_EXPONENT
,NUMPRS_EXPONENT
,3,0,1);
1240 /* Powers of 10 are calculated from the position of any decimal point */
1241 CONVERT("1.5e20", NUMPRS_EXPONENT
|NUMPRS_DECIMAL
);
1242 EXPECT(2,NUMPRS_EXPONENT
|NUMPRS_DECIMAL
,NUMPRS_EXPONENT
|NUMPRS_DECIMAL
,6,0,19);
1245 CONVERT("1.5e-20", NUMPRS_EXPONENT
|NUMPRS_DECIMAL
);
1246 EXPECT(2,NUMPRS_EXPONENT
|NUMPRS_DECIMAL
,NUMPRS_EXPONENT
|NUMPRS_DECIMAL
,7,0,-21);
1249 /** NUMPRS_USE_ALL **/
1251 /* Flag expects all digits */
1252 CONVERT("0", NUMPRS_USE_ALL
);
1253 EXPECT(1,NUMPRS_USE_ALL
,0,1,0,0);
1256 /* Rejects anything trailing */
1257 CONVERT("0 ", NUMPRS_USE_ALL
);
1261 /* Unless consumed by trailing flag */
1262 CONVERT("0 ", NUMPRS_USE_ALL
|NUMPRS_TRAILING_WHITE
);
1263 EXPECT(1,NUMPRS_USE_ALL
|NUMPRS_TRAILING_WHITE
,NUMPRS_TRAILING_WHITE
,2,0,0);
1266 /** Combinations **/
1268 /* Leading whitespace and plus, doesn't consume trailing whitespace */
1269 CONVERT("+ 0 ", NUMPRS_LEADING_PLUS
|NUMPRS_LEADING_WHITE
);
1270 EXPECT(1,NUMPRS_LEADING_PLUS
|NUMPRS_LEADING_WHITE
,NUMPRS_LEADING_PLUS
|NUMPRS_LEADING_WHITE
,3,0,0);
1273 /* Order of whitespace and plus is unimportant */
1274 CONVERT(" +0", NUMPRS_LEADING_PLUS
|NUMPRS_LEADING_WHITE
);
1275 EXPECT(1,NUMPRS_LEADING_PLUS
|NUMPRS_LEADING_WHITE
,NUMPRS_LEADING_PLUS
|NUMPRS_LEADING_WHITE
,3,0,0);
1278 /* Leading whitespace can be repeated */
1279 CONVERT(" + 0", NUMPRS_LEADING_PLUS
|NUMPRS_LEADING_WHITE
);
1280 EXPECT(1,NUMPRS_LEADING_PLUS
|NUMPRS_LEADING_WHITE
,NUMPRS_LEADING_PLUS
|NUMPRS_LEADING_WHITE
,4,0,0);
1283 /* But plus/minus etc. cannot */
1284 CONVERT("+ +0", NUMPRS_LEADING_PLUS
|NUMPRS_LEADING_WHITE
);
1286 EXPECTRGB(0,FAILDIG
);
1288 /* Inexact is not set if trailing zeros are removed */
1289 CONVERTN("10", 1, 0);
1290 EXPECT(1,0,0,2,0,1);
1293 /* Make sure a leading 0 is stripped but decimals after it get read */
1294 CONVERT("-0.51", NUMPRS_STD
);
1295 EXPECT(2,NUMPRS_STD
,NUMPRS_NEG
|NUMPRS_DECIMAL
|NUMPRS_LEADING_MINUS
,5,0,-2);
1298 /* Keep trailing zeros on whole number part of a decimal */
1299 CONVERT("10.1", NUMPRS_STD
);
1300 EXPECT(3,NUMPRS_STD
,NUMPRS_DECIMAL
,4,0,-1);
1304 /* Zeros after decimal sign */
1305 CONVERT("0.01", NUMPRS_STD
);
1306 EXPECT(1,NUMPRS_STD
,NUMPRS_DECIMAL
,4,0,-2);
1309 /* Trailing zeros after decimal part */
1310 CONVERT("0.10", NUMPRS_STD
);
1311 EXPECT(1,NUMPRS_STD
,NUMPRS_DECIMAL
,4,0,-1);
1315 static HRESULT (WINAPI
*pVarNumFromParseNum
)(NUMPARSE
*,BYTE
*,ULONG
,VARIANT
*);
1317 /* Macros for converting and testing the result of VarNumFromParseNum */
1318 #define SETRGB(indx,val) if (!indx) memset(rgb, FAILDIG, sizeof(rgb)); rgb[indx] = val
1320 #define CONVERT(a,b,c,d,e,f,bits) \
1321 np.cDig = (a); np.dwInFlags = (b); np.dwOutFlags = (c); np.cchUsed = (d); \
1322 np.nBaseShift = (e); np.nPwr10 = (f); hres = pVarNumFromParseNum(&np, rgb, bits, &vOut)
1323 static const char *szFailOverflow
= "Expected overflow, hres = %08x\n";
1324 #define EXPECT_OVERFLOW ok(hres == (HRESULT)DISP_E_OVERFLOW, szFailOverflow, hres)
1325 static const char *szFailOk
= "Call failed, hres = %08x\n";
1326 #define EXPECT_OK ok(hres == (HRESULT)S_OK, szFailOk, hres); \
1327 if (hres == (HRESULT)S_OK)
1328 #define EXPECT_TYPE(typ) ok(V_VT(&vOut) == typ,"Expected Type = " #typ ", got %d\n", V_VT(&vOut))
1329 #define EXPECT_I1(val) EXPECT_OK { EXPECT_TYPE(VT_I1); \
1330 ok(V_I1(&vOut) == val, "Expected i1 = %d, got %d\n", (signed char)val, V_I1(&vOut)); }
1331 #define EXPECT_UI1(val) EXPECT_OK { EXPECT_TYPE(VT_UI1); \
1332 ok(V_UI1(&vOut) == val, "Expected ui1 = %d, got %d\n", (BYTE)val, V_UI1(&vOut)); }
1333 #define EXPECT_I2(val) EXPECT_OK { EXPECT_TYPE(VT_I2); \
1334 ok(V_I2(&vOut) == val, "Expected i2 = %d, got %d\n", (SHORT)val, V_I2(&vOut)); }
1335 #define EXPECT_UI2(val) EXPECT_OK { EXPECT_TYPE(VT_UI2); \
1336 ok(V_UI2(&vOut) == val, "Expected ui2 = %d, got %d\n", (USHORT)val, V_UI2(&vOut)); }
1337 #define EXPECT_I4(val) EXPECT_OK { EXPECT_TYPE(VT_I4); \
1338 ok(V_I4(&vOut) == val, "Expected i4 = %d, got %d\n", (LONG)val, V_I4(&vOut)); }
1339 #define EXPECT_UI4(val) EXPECT_OK { EXPECT_TYPE(VT_UI4); \
1340 ok(V_UI4(&vOut) == val, "Expected ui4 = %d, got %d\n", (ULONG)val, V_UI4(&vOut)); }
1341 #define EXPECT_I8(high,low) EXPECT_OK { EXPECT_TYPE(VT_I8); \
1342 ok(V_I8(&vOut) == ((((LONG64)(high))<<32)|(low)), "Expected i8 = %x%08x, got %x%08x\n", \
1343 (LONG)(high), (LONG)(low), (LONG)(V_I8(&vOut)>>32), (LONG)V_I8(&vOut) ); }
1344 #define EXPECT_UI8(val) EXPECT_OK { EXPECT_TYPE(VT_UI8); \
1345 ok(V_UI8(&vOut) == val, "Expected ui8 = 0x%x%08x, got 0x%x%08x\n", \
1346 (DWORD)((ULONG64)val >> 32), (DWORD)(ULONG64)val, (DWORD)(V_UI8(&vOut) >> 32), (DWORD)V_UI8(&vOut)); }
1347 #define EXPECT_R4(val) EXPECT_OK { EXPECT_TYPE(VT_R4); \
1348 ok(V_R4(&vOut) == val, "Expected r4 = %f, got %f\n", val, V_R4(&vOut)); }
1349 #define EXPECT_R8(val) EXPECT_OK { EXPECT_TYPE(VT_R8); \
1350 ok(V_R8(&vOut) == val, "Expected r8 = %g, got %g\n", val, V_R8(&vOut)); }
1351 #define CY_MULTIPLIER 10000
1352 #define EXPECT_CY(val) EXPECT_OK { EXPECT_TYPE(VT_CY); \
1353 ok(V_CY(&vOut).int64 == (LONG64)(val * CY_MULTIPLIER), "Expected r8 = 0x%x%08x, got 0x%x%08x\n", \
1354 (DWORD)((LONG64)val >> 23), (DWORD)(LONG64)val, (DWORD)(V_CY(&vOut).int64 >>32), (DWORD)V_CY(&vOut).int64); }
1355 #define EXPECT_DECIMAL(valHi, valMid, valLo) EXPECT_OK { EXPECT_TYPE(VT_DECIMAL); \
1356 ok((V_DECIMAL(&vOut).Hi32 == valHi) && (S1(U1(V_DECIMAL(&vOut))).Mid32 == valMid) && \
1357 (S1(U1(V_DECIMAL(&vOut))).Lo32 == valLo), \
1358 "Expected decimal = %x/0x%x%08x, got %x/0x%x%08x\n", valHi, valMid, valLo, \
1359 V_DECIMAL(&vOut).Hi32, S1(U1(V_DECIMAL(&vOut))).Mid32, S1(U1(V_DECIMAL(&vOut))).Lo32); }
1361 static void test_VarNumFromParseNum(void)
1368 CHECKPTR(VarNumFromParseNum
);
1370 /* Convert the number 1 to different types */
1371 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_I1
); EXPECT_I1(1);
1372 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_UI1
); EXPECT_UI1(1);
1373 /* Prefers a signed type to unsigned of the same size */
1374 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_I1
|VTBIT_UI1
); EXPECT_I1(1);
1375 /* But takes the smaller size if possible */
1376 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_I2
|VTBIT_UI1
); EXPECT_UI1(1);
1378 /* Try different integer sizes */
1379 #define INTEGER_VTBITS (VTBIT_I1|VTBIT_UI1|VTBIT_I2|VTBIT_UI2|VTBIT_I4|VTBIT_UI4|VTBIT_I8|VTBIT_UI8)
1381 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, INTEGER_VTBITS
); EXPECT_I1(1);
1383 SETRGB(0, 1); SETRGB(1, 2); SETRGB(2, 7);
1384 CONVERT(3,0,0,3,0,0, INTEGER_VTBITS
); EXPECT_I1(127);
1386 SETRGB(0, 1); SETRGB(1, 2); SETRGB(2, 8);
1387 CONVERT(3,0,0,3,0,0, INTEGER_VTBITS
); EXPECT_UI1(128);
1389 SETRGB(0, 2); SETRGB(1, 5); SETRGB(2, 5);
1390 CONVERT(3,0,0,3,0,0, INTEGER_VTBITS
); EXPECT_UI1(255);
1392 SETRGB(0, 2); SETRGB(1, 5); SETRGB(2, 6);
1393 CONVERT(3,0,0,3,0,0, INTEGER_VTBITS
); EXPECT_I2(256);
1395 SETRGB(0, 3); SETRGB(1, 2); SETRGB(2, 7); SETRGB(3, 6); SETRGB(4, 7);
1396 CONVERT(5,0,0,5,0,0, INTEGER_VTBITS
); EXPECT_I2(32767);
1398 SETRGB(0, 3); SETRGB(1, 2); SETRGB(2, 7); SETRGB(3, 6); SETRGB(4, 8);
1399 CONVERT(5,0,0,5,0,0, INTEGER_VTBITS
); EXPECT_UI2(32768);
1401 /* Assume the above pattern holds for remaining positive integers; test negative */
1404 SETRGB(0, 1); SETRGB(1, 2); SETRGB(2, 8);
1405 CONVERT(3,0,NUMPRS_NEG
,3,0,0, INTEGER_VTBITS
); EXPECT_I1(-128);
1407 SETRGB(0, 1); SETRGB(1, 2); SETRGB(2, 9);
1408 CONVERT(3,0,NUMPRS_NEG
,3,0,0, INTEGER_VTBITS
); EXPECT_I2(-129);
1410 SETRGB(0, 3); SETRGB(1, 2); SETRGB(2, 7); SETRGB(3, 6); SETRGB(4, 8);
1411 CONVERT(5,0,NUMPRS_NEG
,5,0,0, INTEGER_VTBITS
); EXPECT_I2(-32768);
1413 SETRGB(0, 3); SETRGB(1, 2); SETRGB(2, 7); SETRGB(3, 6); SETRGB(4, 9);
1414 CONVERT(5,0,NUMPRS_NEG
,5,0,0, INTEGER_VTBITS
); EXPECT_I4(-32769);
1416 /* Assume the above pattern holds for remaining negative integers */
1418 /* Test hexadecimal conversions */
1419 SETRGB(0, 1); CONVERT(1,0,0,1,4,0, INTEGER_VTBITS
); EXPECT_I1(0x01);
1421 SETRGB(0, 7); SETRGB(1, 0xf);
1422 CONVERT(2,0,0,2,4,0, INTEGER_VTBITS
); EXPECT_I1(0x7f);
1423 SETRGB(0, 7); SETRGB(1, 0xf);
1424 CONVERT(2,0,0,2,4,0, VTBIT_DECIMAL
); EXPECT_DECIMAL(0,0,0x7f);
1426 SETRGB(0, 7); SETRGB(1, 0xf); SETRGB(2, 0xf); SETRGB(3, 0xf);
1427 CONVERT(4,0,0,4,4,0, INTEGER_VTBITS
); EXPECT_I2(0x7fff);
1429 SETRGB(0, 7); SETRGB(1, 0xf); SETRGB(2, 0xf); SETRGB(3, 0xf);
1430 SETRGB(4, 0xf); SETRGB(5, 0xf); SETRGB(6, 0xf); SETRGB(7, 0xf);
1431 CONVERT(8,0,0,8,4,0, INTEGER_VTBITS
); EXPECT_I4(0x7fffffffL
);
1432 /* 0x7fffffffffffffff (64 bits) */
1433 SETRGB(0, 7); SETRGB(1, 0xf); SETRGB(2, 0xf); SETRGB(3, 0xf);
1434 SETRGB(4, 0xf); SETRGB(5, 0xf); SETRGB(6, 0xf); SETRGB(7, 0xf);
1435 SETRGB(8, 0xf); SETRGB(9, 0xf); SETRGB(10, 0xf); SETRGB(11, 0xf);
1436 SETRGB(12, 0xf); SETRGB(13, 0xf); SETRGB(14, 0xf); SETRGB(15, 0xf);
1437 if (HAVE_OLEAUT32_I8
)
1439 /* We cannot use INTEGER_VTBITS as WinXP and Win2003 are broken(?). They
1440 truncate the number to the smallest integer size requested:
1441 CONVERT(16,0,0,16,4,0, INTEGER_VTBITS); EXPECT_I1((signed char)0xff); */
1442 CONVERT(16,0,0,16,4,0, VTBIT_I8
); EXPECT_I8(0x7fffffff,0xffffffff);
1445 /* Assume the above pattern holds for numbers without hi-bit set, test (preservation of) hi-bit */
1447 SETRGB(0, 8); SETRGB(1, 2);
1448 CONVERT(2,0,0,2,4,0, INTEGER_VTBITS
);
1449 EXPECT_I1((signed char)0x82);
1451 SETRGB(0, 8); SETRGB(1, 0); SETRGB(2, 0); SETRGB(3, 2);
1452 CONVERT(4,0,0,4,4,0, INTEGER_VTBITS
);
1453 EXPECT_I2((signed short)0x8002);
1455 SETRGB(0, 8); SETRGB(1, 0); SETRGB(2, 0); SETRGB(3, 0);
1456 SETRGB(4, 0); SETRGB(5, 0); SETRGB(6, 0); SETRGB(7, 2);
1457 CONVERT(8,0,0,8,4,0, INTEGER_VTBITS
); EXPECT_I4(0x80000002);
1458 /* 0x8000000000000002 (64 bits) */
1459 SETRGB(0, 8); SETRGB(1, 0); SETRGB(2, 0); SETRGB(3, 0);
1460 SETRGB(4, 0); SETRGB(5, 0); SETRGB(6, 0); SETRGB(7, 0);
1461 SETRGB(8, 0); SETRGB(9, 0); SETRGB(10, 0); SETRGB(11, 0);
1462 SETRGB(12, 0); SETRGB(13, 0); SETRGB(14, 0); SETRGB(15, 2);
1463 if (HAVE_OLEAUT32_I8
)
1465 /* We cannot use INTEGER_VTBITS as WinXP and Win2003 are broken(?). They
1466 truncate the number to the smallest integer size requested:
1467 CONVERT(16,0,0,16,4,0, INTEGER_VTBITS & ~VTBIT_I1);
1468 EXPECT_I2((signed short)0x0002); */
1469 CONVERT(16,0,0,16,4,0, VTBIT_I8
); EXPECT_I8(0x80000000,0x00000002);
1472 /* Test (preservation of) hi-bit with STRICT type requesting */
1474 SETRGB(0, 8); SETRGB(1, 2);
1475 CONVERT(2,0,0,2,4,0, VTBIT_I1
);
1476 EXPECT_I1((signed char)0x82);
1478 SETRGB(0, 8); SETRGB(1, 0); SETRGB(2, 0); SETRGB(3, 2);
1479 CONVERT(4,0,0,4,4,0, VTBIT_I2
);
1480 EXPECT_I2((signed short)0x8002);
1482 SETRGB(0, 8); SETRGB(1, 0); SETRGB(2, 0); SETRGB(3, 0);
1483 SETRGB(4, 0); SETRGB(5, 0); SETRGB(6, 0); SETRGB(7, 2);
1484 CONVERT(8,0,0,8,4,0, VTBIT_I4
); EXPECT_I4(0x80000002);
1485 /* 0x8000000000000002 (64 bits) */
1486 SETRGB(0, 8); SETRGB(1, 0); SETRGB(2, 0); SETRGB(3, 0);
1487 SETRGB(4, 0); SETRGB(5, 0); SETRGB(6, 0); SETRGB(7, 0);
1488 SETRGB(8, 0); SETRGB(9, 0); SETRGB(10, 0); SETRGB(11, 0);
1489 SETRGB(12, 0); SETRGB(13, 0); SETRGB(14, 0); SETRGB(15, 2);
1490 if (HAVE_OLEAUT32_I8
)
1492 CONVERT(16,0,0,16,4,0, VTBIT_I8
); EXPECT_I8(0x80000000,0x00000002);
1494 /* Assume the above pattern holds for numbers with hi-bit set */
1496 /* Negative numbers overflow if we have only unsigned outputs */
1498 SETRGB(0, 1); CONVERT(1,0,NUMPRS_NEG
,1,0,0, VTBIT_UI1
); EXPECT_OVERFLOW
;
1500 SETRGB(0, 6); CONVERT(1,0,NUMPRS_NEG
,1,0,~0u, VTBIT_UI1
); EXPECT_OVERFLOW
;
1502 /* Except that rounding is done first, so -0.5 to 0 are accepted as 0 */
1504 SETRGB(0, 5); CONVERT(1,0,NUMPRS_NEG
,1,0,~0u, VTBIT_UI1
); EXPECT_UI1(0);
1506 /* Floating point zero is OK */
1508 SETRGB(0, 0); CONVERT(1,0,NUMPRS_DECIMAL
|NUMPRS_EXPONENT
,12,0,-8, VTBIT_R8
);
1511 /* Float is acceptable for an integer input value */
1512 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_R4
); EXPECT_R4(1.0f
);
1514 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_R8
); EXPECT_R8(1.0);
1515 /* As is currency */
1516 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_CY
); EXPECT_CY(1);
1518 /* Float is preferred over double */
1519 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_R4
|VTBIT_R8
); EXPECT_R4(1.0f
);
1521 /* Double is preferred over currency */
1522 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_R8
|VTBIT_CY
); EXPECT_R8(1.0);
1524 /* Currency is preferred over decimal */
1525 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_CY
|VTBIT_DECIMAL
); EXPECT_CY(1);
1529 static void test_UdateFromDate( int line
, DATE dt
, ULONG flags
, HRESULT r
, WORD d
, WORD m
, WORD y
,
1530 WORD h
, WORD mn
, WORD s
, WORD ms
, WORD dw
, WORD dy
)
1535 memset(&ud
, 0, sizeof(ud
));
1536 res
= pVarUdateFromDate(dt
, flags
, &ud
);
1537 ok_(__FILE__
,line
)(r
== res
, "Wrong result %x/%x\n", r
, res
);
1539 ok_(__FILE__
,line
)(ud
.st
.wYear
== y
&& ud
.st
.wMonth
== m
&& ud
.st
.wDay
== d
&&
1540 ud
.st
.wHour
== h
&& ud
.st
.wMinute
== mn
&& ud
.st
.wSecond
== s
&&
1541 ud
.st
.wMilliseconds
== ms
&& ud
.st
.wDayOfWeek
== dw
&& ud
.wDayOfYear
== dy
,
1542 "%.16g expected %d,%d,%d,%d,%d,%d,%d %d %d, got %d,%d,%d,%d,%d,%d,%d %d %d\n",
1543 dt
, d
, m
, y
, h
, mn
, s
, ms
, dw
, dy
,
1544 ud
.st
.wDay
, ud
.st
.wMonth
, ud
.st
.wYear
, ud
.st
.wHour
, ud
.st
.wMinute
,
1545 ud
.st
.wSecond
, ud
.st
.wMilliseconds
, ud
.st
.wDayOfWeek
, ud
.wDayOfYear
);
1547 #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)
1549 static void test_VarUdateFromDate(void)
1551 CHECKPTR(VarUdateFromDate
);
1552 DT2UD(29221.0,0,S_OK
,1,1,1980,0,0,0,0,2,1); /* 1 Jan 1980 */
1553 DT2UD(29222.0,0,S_OK
,2,1,1980,0,0,0,0,3,2); /* 2 Jan 1980 */
1554 DT2UD(33238.0,0,S_OK
,31,12,1990,0,0,0,0,1,365); /* 31 Dec 1990 */
1555 DT2UD(0.0,0,S_OK
,30,12,1899,0,0,0,0,6,364); /* 30 Dec 1899 - VT_DATE 0.0 */
1556 DT2UD(-657434.0,0,S_OK
,1,1,100,0,0,0,0,5,1); /* 1 Jan 100 - Min */
1557 DT2UD(-657435.0,0,E_INVALIDARG
,0,0,0,0,0,0,0,0,0); /* < 1 Jan 100 => err */
1558 DT2UD(2958465.0,0,S_OK
,31,12,9999,0,0,0,0,5,365); /* 31 Dec 9999 - Max */
1559 DT2UD(2958466.0,0,E_INVALIDARG
,0,0,0,0,0,0,0,0,0); /* > 31 Dec 9999 => err */
1561 /* VAR_VALIDDATE doesn't prevent upper and lower bounds being checked */
1562 DT2UD(-657435.0,VAR_VALIDDATE
,E_INVALIDARG
,0,0,0,0,0,0,0,0,0);
1563 DT2UD(2958466.0,VAR_VALIDDATE
,E_INVALIDARG
,0,0,0,0,0,0,0,0,0);
1566 DT2UD(29221.25,0,S_OK
,1,1,1980,6,0,0,0,2,1); /* 6 AM */
1567 DT2UD(29221.33333333,0,S_OK
,1,1,1980,8,0,0,0,2,1); /* 8 AM */
1568 DT2UD(29221.5,0,S_OK
,1,1,1980,12,0,0,0,2,1); /* 12 AM */
1569 DT2UD(29221.9888884444,0,S_OK
,1,1,1980,23,44,0,0,2,1); /* 11:44 PM */
1570 DT2UD(29221.7508765432,0,S_OK
,1,1,1980,18,1,16,0,2,1); /* 6:18:02 PM */
1574 static void test_DateFromUDate( int line
, WORD d
, WORD m
, WORD y
, WORD h
, WORD mn
, WORD s
, WORD ms
,
1575 WORD dw
, WORD dy
, ULONG flags
, HRESULT r
, DATE dt
)
1587 ud
.st
.wMilliseconds
= ms
;
1588 ud
.st
.wDayOfWeek
= dw
;
1590 res
= pVarDateFromUdate(&ud
, flags
, &out
);
1591 ok_(__FILE__
,line
)(r
== res
&& (FAILED(r
) || EQ_DOUBLE(out
, dt
)),
1592 "expected %x, %.16g, got %x, %.16g\n", r
, dt
, res
, out
);
1594 #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)
1596 static void test_VarDateFromUdate(void)
1598 CHECKPTR(VarDateFromUdate
);
1599 UD2T(1,1,1980,0,0,0,0,2,1,0,S_OK
,29221.0); /* 1 Jan 1980 */
1600 UD2T(2,1,1980,0,0,0,0,3,2,0,S_OK
,29222.0); /* 2 Jan 1980 */
1601 UD2T(31,12,1990,0,0,0,0,0,0,0,S_OK
,33238.0); /* 31 Dec 1990 */
1602 UD2T(31,12,90,0,0,0,0,0,0,0,S_OK
,33238.0); /* year < 100 is 1900+year! */
1603 UD2T(30,12,1899,0,0,0,0,6,364,0,S_OK
,0.0); /* 30 Dec 1899 - VT_DATE 0.0 */
1604 UD2T(1,1,100,0,0,0,0,0,0,0,S_OK
,-657434.0); /* 1 Jan 100 - Min */
1605 UD2T(31,12,9999,0,0,0,0,0,0,0,S_OK
,2958465.0); /* 31 Dec 9999 - Max */
1606 UD2T(1,1,10000,0,0,0,0,0,0,0,E_INVALIDARG
,0.0); /* > 31 Dec 9999 => err */
1608 UD2T(1,1,1980,18,1,16,0,2,1,0,S_OK
,29221.75087962963); /* 6:18:02 PM */
1610 UD2T(0,1,1980,0,0,0,0,2,1,0,S_OK
,29220.0); /* Rolls back to 31 Dec 1899 */
1611 UD2T(1,13,1980,0,0,0,0,2,1,0,S_OK
,29587.0); /* Rolls fwd to 1/1/1981 */
1614 static void test_st2dt(int line
, WORD d
, WORD m
, WORD y
, WORD h
, WORD mn
,
1615 WORD s
, WORD ms
, INT r
, double dt
)
1627 st
.wMilliseconds
= ms
;
1629 res
= pSystemTimeToVariantTime(&st
, &out
);
1630 ok_(__FILE__
,line
)(r
== res
&& (!r
|| EQ_DOUBLE(out
, dt
)),
1631 "expected %d, %.16g, got %d, %.16g\n", r
, dt
, res
, out
);
1633 #define ST2DT(d,m,y,h,mn,s,ms,r,dt) test_st2dt(__LINE__,d,m,y,h,mn,s,ms,r,dt)
1635 static void test_SystemTimeToVariantTime(void)
1637 CHECKPTR(SystemTimeToVariantTime
);
1638 ST2DT(1,1,1980,0,0,0,0,TRUE
,29221.0);
1639 ST2DT(2,1,1980,0,0,0,0,TRUE
,29222.0);
1640 ST2DT(0,1,1980,0,0,0,0,TRUE
,29220.0); /* Rolls back to 31 Dec 1899 */
1641 ST2DT(1,13,1980,0,0,0,0,FALSE
,29587.0); /* Fails on invalid month */
1642 ST2DT(31,12,90,0,0,0,0,TRUE
,33238.0); /* year < 100 is 1900+year! */
1645 static void test_dt2st(int line
, double dt
, INT r
, WORD d
, WORD m
, WORD y
,
1646 WORD h
, WORD mn
, WORD s
, WORD ms
)
1651 memset(&st
, 0, sizeof(st
));
1652 res
= pVariantTimeToSystemTime(dt
, &st
);
1653 ok_(__FILE__
,line
)(r
== res
&&
1654 (!r
|| (st
.wYear
== y
&& st
.wMonth
== m
&& st
.wDay
== d
&&
1655 st
.wHour
== h
&& st
.wMinute
== mn
&&
1656 st
.wSecond
== s
&& st
.wMilliseconds
== ms
)),
1657 "%.16g expected %d, %d,%d,%d,%d,%d,%d,%d, got %d, %d,%d,%d,%d,%d,%d,%d\n",
1658 dt
, r
, d
, m
, y
, h
, mn
, s
, ms
, res
, st
.wDay
, st
.wMonth
,
1659 st
.wYear
, st
.wHour
, st
.wMinute
, st
.wSecond
,
1662 #define DT2ST(dt,r,d,m,y,h,mn,s,ms) test_dt2st(__LINE__,dt,r,d,m,y,h,mn,s,ms)
1664 static void test_VariantTimeToSystemTime(void)
1666 CHECKPTR(VariantTimeToSystemTime
);
1667 DT2ST(29221.0,1,1,1,1980,0,0,0,0);
1668 DT2ST(29222.0,1,2,1,1980,0,0,0,0);
1671 #define MKDOSDATE(d,m,y) ((d & 0x1f) | ((m & 0xf) << 5) | (((y-1980) & 0x7f) << 9))
1672 #define MKDOSTIME(h,m,s) (((s>>1) & 0x1f) | ((m & 0x3f) << 5) | ((h & 0x1f) << 11))
1674 static void test_dos2dt(int line
, WORD d
, WORD m
, WORD y
, WORD h
, WORD mn
,
1675 WORD s
, INT r
, double dt
)
1677 unsigned short dosDate
, dosTime
;
1682 dosDate
= MKDOSDATE(d
, m
, y
);
1683 dosTime
= MKDOSTIME(h
, mn
, s
);
1684 res
= pDosDateTimeToVariantTime(dosDate
, dosTime
, &out
);
1685 ok_(__FILE__
,line
)(r
== res
&& (!r
|| EQ_DOUBLE(out
, dt
)),
1686 "expected %d, %.16g, got %d, %.16g\n", r
, dt
, res
, out
);
1688 #define DOS2DT(d,m,y,h,mn,s,r,dt) test_dos2dt(__LINE__,d,m,y,h,mn,s,r,dt)
1690 static void test_DosDateTimeToVariantTime(void)
1692 CHECKPTR(DosDateTimeToVariantTime
);
1695 DOS2DT(1,1,1980,0,0,0,1,29221.0); /* 1/1/1980 */
1696 DOS2DT(31,12,2099,0,0,0,1,73050.0); /* 31/12/2099 */
1697 /* Dates are limited to the dos date max of 31/12/2099 */
1698 DOS2DT(31,12,2100,0,0,0,0,0.0); /* 31/12/2100 */
1699 /* Days and months of 0 cause date to roll back 1 day or month */
1700 DOS2DT(0,1,1980,0,0,0,1,29220.0); /* 0 Day => 31/12/1979 */
1701 DOS2DT(1,0,1980,0,0,0,1,29190.0); /* 0 Mth => 1/12/1979 */
1702 DOS2DT(0,0,1980,0,0,0,1,29189.0); /* 0 D/M => 30/11/1979 */
1703 /* Days > days in the month cause date to roll forward 1 month */
1704 DOS2DT(29,2,1981,0,0,0,1,29646.0); /* 29/2/1981 -> 3/1/1980 */
1705 DOS2DT(30,2,1981,0,0,0,1,29647.0); /* 30/2/1981 -> 4/1/1980 */
1706 /* Takes leap years into account when rolling forward */
1707 DOS2DT(29,2,1980,0,0,0,1,29280.0); /* 2/29/1980 */
1708 /* Months > 12 cause an error */
1709 DOS2DT(2,13,1980,0,0,0,0,0.0);
1712 DOS2DT(1,1,1980,0,0,29,1,29221.00032407407); /* 1/1/1980 12:00:28 AM */
1713 DOS2DT(1,1,1980,0,0,31,1,29221.00034722222); /* 1/1/1980 12:00:30 AM */
1714 DOS2DT(1,1,1980,0,59,0,1,29221.04097222222); /* 1/1/1980 12:59:00 AM */
1715 DOS2DT(1,1,1980,0,60,0,0,0.0); /* Invalid seconds */
1716 DOS2DT(1,1,1980,23,0,0,1,29221.95833333333); /* 1/1/1980 11:00:00 PM */
1717 DOS2DT(1,1,1980,24,0,0,0,0.0); /* Invalid hours */
1720 static void test_dt2dos(int line
, double dt
, INT r
, WORD d
, WORD m
, WORD y
,
1721 WORD h
, WORD mn
, WORD s
)
1723 unsigned short dosDate
, dosTime
, expDosDate
, expDosTime
;
1726 dosTime
= dosDate
= 0;
1727 expDosDate
= MKDOSDATE(d
,m
,y
);
1728 expDosTime
= MKDOSTIME(h
,mn
,s
);
1729 res
= pVariantTimeToDosDateTime(dt
, &dosDate
, &dosTime
);
1730 ok_(__FILE__
,line
)(r
== res
&& (!r
|| (dosTime
== expDosTime
&& dosDate
== expDosDate
)),
1731 "%g: expected %d,%d(%d/%d/%d),%d(%d:%d:%d) got %d,%d(%d/%d/%d),%d(%d:%d:%d)\n",
1732 dt
, r
, expDosDate
, expDosDate
& 0x1f,
1733 (expDosDate
>> 5) & 0xf, 1980 + (expDosDate
>> 9),
1734 expDosTime
, expDosTime
>> 11, (expDosTime
>> 5) & 0x3f,
1735 (expDosTime
& 0x1f),
1736 res
, dosDate
, dosDate
& 0x1f, (dosDate
>> 5) & 0xf,
1737 1980 + (dosDate
>> 9), dosTime
, dosTime
>> 11,
1738 (dosTime
>> 5) & 0x3f, (dosTime
& 0x1f));
1740 #define DT2DOS(dt,r,d,m,y,h,mn,s) test_dt2dos(__LINE__,dt,r,d,m,y,h,mn,s)
1742 static void test_VariantTimeToDosDateTime(void)
1744 CHECKPTR(VariantTimeToDosDateTime
);
1747 DT2DOS(29221.0,1,1,1,1980,0,0,0); /* 1/1/1980 */
1748 DT2DOS(73050.0,1,31,12,2099,0,0,0); /* 31/12/2099 */
1749 DT2DOS(29220.0,0,0,0,0,0,0,0); /* 31/12/1979 - out of range */
1750 DT2DOS(73415.0,0,0,0,0,0,0,0); /* 31/12/2100 - out of range */
1753 DT2DOS(29221.00032407407,1,1,1,1980,0,0,29); /* 1/1/1980 12:00:28 AM */
1754 DT2DOS(29221.00034722222,1,1,1,1980,0,0,31); /* 1/1/1980 12:00:30 AM */
1755 DT2DOS(29221.04097222222,1,1,1,1980,0,59,0); /* 1/1/1980 12:59:00 AM */
1756 DT2DOS(29221.95833333333,1,1,1,1980,23,0,0); /* 1/1/1980 11:00:00 PM */
1759 static HRESULT (WINAPI
*pVarAbs
)(LPVARIANT
,LPVARIANT
);
1761 #define VARABS(vt,val,rvt,rval) \
1762 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
1763 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
1764 test_var_call1( __LINE__, pVarAbs, &v, &exp )
1766 static void test_VarAbs(void)
1768 static const WCHAR szNum
[] = {'-','1','.','1','\0' };
1771 VARIANT v
, vDst
, exp
;
1776 /* Test all possible V_VT values.
1778 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
1782 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
1784 HRESULT hExpected
= DISP_E_BADVARTYPE
;
1788 memset(&v
, 0, sizeof(v
));
1789 V_VT(&v
) = vt
| ExtraFlags
[i
];
1790 V_VT(&vDst
) = VT_EMPTY
;
1792 hres
= pVarAbs(&v
,&vDst
);
1793 if (ExtraFlags
[i
] & (VT_ARRAY
|VT_ARRAY
) ||
1794 (!ExtraFlags
[i
] && (vt
== VT_UNKNOWN
|| vt
== VT_BSTR
||
1795 vt
== VT_DISPATCH
|| vt
== VT_ERROR
|| vt
== VT_RECORD
)))
1797 hExpected
= DISP_E_TYPEMISMATCH
;
1799 else if (ExtraFlags
[i
] || vt
>= VT_CLSID
|| vt
== VT_VARIANT
)
1801 hExpected
= DISP_E_BADVARTYPE
;
1803 else if (IsValidVariantClearVT(vt
, ExtraFlags
[i
]))
1806 /* Native always fails on some vartypes that should be valid. don't
1807 * check that Wine does the same; these are bugs in native.
1809 if (vt
== VT_I8
|| vt
== VT_UI8
|| vt
== VT_INT
|| vt
== VT_UINT
||
1810 vt
== VT_I1
|| vt
== VT_UI2
|| vt
== VT_UI4
)
1812 ok(hres
== hExpected
, "VarAbs: expected 0x%X, got 0x%X for vt %d | 0x%X\n",
1813 hExpected
, hres
, vt
, ExtraFlags
[i
]);
1817 /* BOOL->I2, BSTR->R8, all others remain the same */
1818 VARABS(BOOL
,VARIANT_TRUE
,I2
,-VARIANT_TRUE
);
1819 VARABS(BOOL
,VARIANT_FALSE
,I2
,VARIANT_FALSE
);
1820 VARABS(EMPTY
,0,I2
,0);
1821 VARABS(EMPTY
,1,I2
,0);
1822 VARABS(NULL
,0,NULL
,0);
1823 VARABS(NULL
,1,NULL
,0);
1828 VARABS(UI1
,1,UI1
,1);
1833 VARABS(DATE
,1,DATE
,1);
1834 VARABS(DATE
,-1,DATE
,1);
1836 V_CY(&v
).int64
= -10000;
1837 memset(&vDst
,0,sizeof(vDst
));
1838 hres
= pVarAbs(&v
,&vDst
);
1839 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_CY
&& V_CY(&vDst
).int64
== 10000,
1840 "VarAbs(CY): expected 0x0 got 0x%X\n", hres
);
1841 GetLocaleInfoA(LOCALE_USER_DEFAULT
, LOCALE_SDECIMAL
, buff
, sizeof(buff
)/sizeof(char));
1842 if (buff
[0] != '.' || buff
[1])
1844 trace("Skipping VarAbs(BSTR) as decimal separator is '%s'\n", buff
);
1848 V_BSTR(&v
) = (BSTR
)szNum
;
1849 memset(&vDst
,0,sizeof(vDst
));
1850 hres
= pVarAbs(&v
,&vDst
);
1851 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_R8
&& V_R8(&vDst
) == 1.1,
1852 "VarAbs: expected 0x0,%d,%g, got 0x%X,%d,%g\n", VT_R8
, 1.1, hres
, V_VT(&vDst
), V_R8(&vDst
));
1855 static HRESULT (WINAPI
*pVarNot
)(LPVARIANT
,LPVARIANT
);
1857 #define VARNOT(vt,val,rvt,rval) \
1858 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
1859 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
1860 test_var_call1( __LINE__, pVarNot, &v, &exp )
1862 static void test_VarNot(void)
1864 static const WCHAR szNum0
[] = {'0','\0' };
1865 static const WCHAR szNum1
[] = {'1','\0' };
1867 VARIANT v
, exp
, vDst
;
1868 DECIMAL
*pdec
= &V_DECIMAL(&v
);
1869 CY
*pcy
= &V_CY(&v
);
1874 /* Test all possible V_VT values */
1875 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
1879 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
1881 HRESULT hExpected
= DISP_E_BADVARTYPE
;
1885 memset(&v
, 0, sizeof(v
));
1886 V_VT(&v
) = vt
| ExtraFlags
[i
];
1887 V_VT(&vDst
) = VT_EMPTY
;
1891 case VT_I1
: case VT_UI1
: case VT_I2
: case VT_UI2
:
1892 case VT_INT
: case VT_UINT
: case VT_I4
: case VT_UI4
:
1893 case VT_R4
: case VT_R8
:
1894 case VT_DECIMAL
: case VT_BOOL
: case VT_NULL
: case VT_EMPTY
:
1895 case VT_DATE
: case VT_CY
:
1898 case VT_I8
: case VT_UI8
:
1899 if (HAVE_OLEAUT32_I8
)
1903 if (HAVE_OLEAUT32_RECORD
)
1904 hExpected
= DISP_E_TYPEMISMATCH
;
1906 case VT_UNKNOWN
: case VT_BSTR
: case VT_DISPATCH
: case VT_ERROR
:
1907 hExpected
= DISP_E_TYPEMISMATCH
;
1910 if (IsValidVariantClearVT(vt
, ExtraFlags
[i
]) && vt
!= VT_CLSID
)
1911 hExpected
= DISP_E_TYPEMISMATCH
;
1915 hres
= pVarNot(&v
,&vDst
);
1916 ok(hres
== hExpected
, "VarNot: expected 0x%X, got 0x%X vt %d|0x%X\n",
1917 hExpected
, hres
, vt
, ExtraFlags
[i
]);
1920 /* Test the values returned by all cases that can succeed */
1921 VARNOT(EMPTY
,0,I2
,-1);
1922 VARNOT(EMPTY
,1,I2
,-1);
1923 VARNOT(NULL
,0,NULL
,0);
1924 VARNOT(NULL
,1,NULL
,0);
1925 VARNOT(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
);
1926 VARNOT(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
);
1934 VARNOT(UI1
,1,UI1
,254);
1935 VARNOT(UI1
,0,UI1
,255);
1936 VARNOT(UI2
,0,I4
,-1);
1937 VARNOT(UI2
,1,I4
,-2);
1938 VARNOT(UI4
,0,I4
,-1);
1939 VARNOT(UI4
,1,I4
,-2);
1940 VARNOT(INT
,0,I4
,-1);
1941 VARNOT(INT
,1,I4
,-2);
1942 VARNOT(UINT
,0,I4
,-1);
1943 VARNOT(UINT
,1,I4
,-2);
1944 if (HAVE_OLEAUT32_I8
)
1948 VARNOT(UI8
,0,I4
,-1);
1949 VARNOT(UI8
,1,I4
,-2);
1955 VARNOT(DATE
,1,I4
,-2);
1956 VARNOT(DATE
,0,I4
,-1);
1957 VARNOT(BSTR
,(BSTR
)szNum0
,I4
,-1);
1958 ok(V_VT(&v
) == VT_BSTR
&& V_BSTR(&v
) == szNum0
, "VarNot(0): changed input\n");
1959 VARNOT(BSTR
,(BSTR
)szNum1
,I4
,-2);
1960 ok(V_VT(&v
) == VT_BSTR
&& V_BSTR(&v
) == szNum1
, "VarNot(1): changed input\n");
1962 V_VT(&v
) = VT_DECIMAL
;
1963 S(U(*pdec
)).sign
= DECIMAL_NEG
;
1964 S(U(*pdec
)).scale
= 0;
1966 S1(U1(*pdec
)).Mid32
= 0;
1967 S1(U1(*pdec
)).Lo32
= 1;
1968 VARNOT(DECIMAL
,*pdec
,I4
,0);
1971 VARNOT(CY
,*pcy
,I4
,-2);
1974 VARNOT(CY
,*pcy
,I4
,-1);
1977 VARNOT(CY
,*pcy
,I4
,-1);
1980 static HRESULT (WINAPI
*pVarSub
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
1982 #define VARSUB(vt1,val1,vt2,val2,rvt,rval) \
1983 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
1984 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
1985 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
1986 test_var_call2( __LINE__, pVarSub, &left, &right, &exp )
1988 static void test_VarSub(void)
1990 static const WCHAR sz12
[] = {'1','2','\0'};
1991 VARIANT left
, right
, exp
, result
, cy
, dec
;
1994 HRESULT hres
, expectedhres
;
1999 lbstr
= SysAllocString(sz12
);
2000 rbstr
= SysAllocString(sz12
);
2003 VariantInit(&right
);
2004 VariantInit(&result
);
2006 /* Test all possible flag/vt combinations & the resulting vt type */
2007 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
2010 VARTYPE leftvt
, rightvt
, resvt
;
2012 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
2017 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
2021 expectedhres
= S_OK
;
2023 memset(&left
, 0, sizeof(left
));
2024 memset(&right
, 0, sizeof(right
));
2025 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
2026 if (leftvt
== VT_BSTR
)
2027 V_BSTR(&left
) = lbstr
;
2028 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
2029 if (rightvt
== VT_BSTR
)
2030 V_BSTR(&right
) = rbstr
;
2031 V_VT(&result
) = VT_EMPTY
;
2034 /* All extra flags produce errors */
2035 if (ExtraFlags
[i
] == (VT_VECTOR
|VT_BYREF
|VT_RESERVED
) ||
2036 ExtraFlags
[i
] == (VT_VECTOR
|VT_RESERVED
) ||
2037 ExtraFlags
[i
] == (VT_VECTOR
|VT_BYREF
) ||
2038 ExtraFlags
[i
] == (VT_BYREF
|VT_RESERVED
) ||
2039 ExtraFlags
[i
] == VT_VECTOR
||
2040 ExtraFlags
[i
] == VT_BYREF
||
2041 ExtraFlags
[i
] == VT_RESERVED
)
2043 expectedhres
= DISP_E_BADVARTYPE
;
2046 else if (ExtraFlags
[i
] >= VT_ARRAY
)
2048 expectedhres
= DISP_E_TYPEMISMATCH
;
2051 /* Native VarSub cannot handle: VT_I1, VT_UI2, VT_UI4,
2052 VT_INT, VT_UINT and VT_UI8. Tested with WinXP */
2053 else if (!IsValidVariantClearVT(leftvt
, ExtraFlags
[i
]) ||
2054 !IsValidVariantClearVT(rightvt
, ExtraFlags
[i
]) ||
2055 leftvt
== VT_CLSID
|| rightvt
== VT_CLSID
||
2056 leftvt
== VT_VARIANT
|| rightvt
== VT_VARIANT
||
2057 leftvt
== VT_I1
|| rightvt
== VT_I1
||
2058 leftvt
== VT_UI2
|| rightvt
== VT_UI2
||
2059 leftvt
== VT_UI4
|| rightvt
== VT_UI4
||
2060 leftvt
== VT_UI8
|| rightvt
== VT_UI8
||
2061 leftvt
== VT_INT
|| rightvt
== VT_INT
||
2062 leftvt
== VT_UINT
|| rightvt
== VT_UINT
||
2063 leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
||
2064 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
)
2066 if (leftvt
== VT_RECORD
&& rightvt
== VT_I8
)
2067 expectedhres
= DISP_E_TYPEMISMATCH
;
2068 else if (leftvt
< VT_UI1
&& rightvt
== VT_RECORD
)
2069 expectedhres
= DISP_E_TYPEMISMATCH
;
2070 else if (leftvt
>= VT_UI1
&& rightvt
== VT_RECORD
)
2071 expectedhres
= DISP_E_TYPEMISMATCH
;
2072 else if (leftvt
== VT_RECORD
&& rightvt
<= VT_UI1
)
2073 expectedhres
= DISP_E_TYPEMISMATCH
;
2074 else if (leftvt
== VT_RECORD
&& rightvt
> VT_UI1
)
2075 expectedhres
= DISP_E_BADVARTYPE
;
2077 expectedhres
= DISP_E_BADVARTYPE
;
2080 else if ((leftvt
== VT_NULL
&& rightvt
== VT_DISPATCH
) ||
2081 (leftvt
== VT_DISPATCH
&& rightvt
== VT_NULL
))
2083 else if (leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
||
2084 leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
)
2087 expectedhres
= DISP_E_TYPEMISMATCH
;
2089 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
2091 else if ((leftvt
== VT_EMPTY
&& rightvt
== VT_BSTR
) ||
2092 (leftvt
== VT_DATE
&& rightvt
== VT_DATE
) ||
2093 (leftvt
== VT_BSTR
&& rightvt
== VT_EMPTY
) ||
2094 (leftvt
== VT_BSTR
&& rightvt
== VT_BSTR
))
2096 else if (leftvt
== VT_DECIMAL
|| rightvt
== VT_DECIMAL
)
2098 else if (leftvt
== VT_DATE
|| rightvt
== VT_DATE
)
2100 else if (leftvt
== VT_CY
|| rightvt
== VT_CY
)
2102 else if (leftvt
== VT_R8
|| rightvt
== VT_R8
)
2104 else if (leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
) {
2106 } else if (leftvt
== VT_R4
|| rightvt
== VT_R4
) {
2107 if (leftvt
== VT_I4
|| rightvt
== VT_I4
||
2108 leftvt
== VT_I8
|| rightvt
== VT_I8
)
2113 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
2115 else if (leftvt
== VT_I4
|| rightvt
== VT_I4
)
2117 else if (leftvt
== VT_I2
|| rightvt
== VT_I2
||
2118 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
||
2119 (leftvt
== VT_EMPTY
&& rightvt
== VT_EMPTY
))
2121 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
2126 expectedhres
= DISP_E_TYPEMISMATCH
;
2129 hres
= pVarSub(&left
, &right
, &result
);
2131 ok(hres
== expectedhres
&& V_VT(&result
) == resvt
,
2132 "VarSub: %d|0x%X, %d|0x%X: Expected failure 0x%X, "
2133 "got 0x%X, expected vt %d got vt %d\n",
2134 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
],
2135 expectedhres
, hres
, resvt
, V_VT(&result
));
2140 /* Test returned values */
2141 VARSUB(I4
,4,I4
,2,I4
,2);
2142 VARSUB(I2
,4,I2
,2,I2
,2);
2143 VARSUB(I2
,-13,I4
,5,I4
,-18);
2144 VARSUB(I4
,-13,I4
,5,I4
,-18);
2145 VARSUB(I2
,7,R4
,0.5f
,R4
,6.5f
);
2146 VARSUB(R4
,0.5f
,I4
,5,R8
,-4.5);
2147 VARSUB(R8
,7.1,BOOL
,0,R8
,7.1);
2148 VARSUB(BSTR
,lbstr
,I2
,4,R8
,8);
2149 VARSUB(BSTR
,lbstr
,BOOL
,1,R8
,11);
2150 VARSUB(BSTR
,lbstr
,R4
,0.1f
,R8
,11.9);
2151 VARSUB(R4
,0.2f
,BSTR
,rbstr
,R8
,-11.8);
2152 VARSUB(DATE
,2.25,I4
,7,DATE
,-4.75);
2153 VARSUB(DATE
,1.25,R4
,-1.7f
,DATE
,2.95);
2155 VARSUB(UI1
, UI1_MAX
, UI1
, UI1_MAX
, UI1
, 0);
2156 VARSUB(I2
, I2_MAX
, I2
, I2_MAX
, I2
, 0);
2157 VARSUB(I2
, I2_MIN
, I2
, I2_MIN
, I2
, 0);
2158 VARSUB(I4
, I4_MAX
, I4
, I4_MAX
, I4
, 0);
2159 VARSUB(I4
, I4_MIN
, I4
, I4_MIN
, I4
, 0);
2160 VARSUB(R4
, R4_MAX
, R4
, R4_MAX
, R4
, 0.0f
);
2161 VARSUB(R4
, R4_MAX
, R4
, R4_MIN
, R4
, R4_MAX
- R4_MIN
);
2162 VARSUB(R4
, R4_MIN
, R4
, R4_MIN
, R4
, 0.0f
);
2163 VARSUB(R8
, R8_MAX
, R8
, R8_MIN
, R8
, R8_MAX
- R8_MIN
);
2164 VARSUB(R8
, R8_MIN
, R8
, R8_MIN
, R8
, 0.0);
2166 /* Manually test BSTR + BSTR */
2167 V_VT(&left
) = VT_BSTR
;
2168 V_BSTR(&left
) = lbstr
;
2169 V_VT(&right
) = VT_BSTR
;
2170 V_BSTR(&right
) = rbstr
;
2171 hres
= VarSub(&left
, &right
, &result
);
2172 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
2173 "VarSub: expected coerced type VT_R8, got %s!\n", vtstr(V_VT(&result
)));
2174 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 0),
2175 "VarSub: BSTR + BSTR, expected %f got %f\n", 0.0, V_R8(&result
));
2177 /* Manually test some VT_CY and VT_DECIMAL variants */
2179 hres
= VarCyFromI4(4711, &V_CY(&cy
));
2180 ok(hres
== S_OK
, "VarCyFromI4 failed!\n");
2181 V_VT(&dec
) = VT_DECIMAL
;
2182 hres
= VarDecFromR8(-4.2, &V_DECIMAL(&dec
));
2183 ok(hres
== S_OK
, "VarDecFromR4 failed!\n");
2184 memset(&left
, 0, sizeof(left
));
2185 memset(&right
, 0, sizeof(right
));
2186 V_VT(&left
) = VT_I4
;
2188 V_VT(&right
) = VT_UI1
;
2191 hres
= VarSub(&cy
, &right
, &result
);
2192 ok(hres
== S_OK
&& V_VT(&result
) == VT_CY
,
2193 "VarSub: expected coerced type VT_CY, got %s!\n", vtstr(V_VT(&result
)));
2194 hres
= VarR8FromCy(V_CY(&result
), &r
);
2195 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 4702),
2196 "VarSub: CY value %f, expected %f\n", r
, (double)4720);
2198 hres
= VarSub(&left
, &dec
, &result
);
2199 ok(hres
== S_OK
&& V_VT(&result
) == VT_DECIMAL
,
2200 "VarSub: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result
)));
2201 hres
= VarR8FromDec(&V_DECIMAL(&result
), &r
);
2202 ok(hres
== S_OK
&& EQ_DOUBLE(r
, -6.8),
2203 "VarSub: DECIMAL value %f, expected %f\n", r
, (double)-15.2);
2205 SysFreeString(lbstr
);
2206 SysFreeString(rbstr
);
2209 static HRESULT (WINAPI
*pVarMod
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
2211 static void test_Mod( int line
, VARIANT
*left
, VARIANT
*right
, VARIANT
*expected
, HRESULT expres
)
2216 memset( &result
, 0, sizeof(result
) );
2217 hres
= pVarMod( left
, right
, &result
);
2218 ok_(__FILE__
,line
)( hres
== expres
, "wrong result %x/%x\n", hres
, expres
);
2220 ok_(__FILE__
,line
)( is_expected_variant( &result
, expected
),
2221 "got %s expected %s\n", variantstr(&result
), variantstr(expected
) );
2224 #define VARMOD(vt1,vt2,val1,val2,rvt,rval) \
2225 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
2226 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
2227 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
2228 test_var_call2( __LINE__, pVarMod, &left, &right, &exp )
2230 #define VARMOD2(vt1,vt2,val1,val2,rvt,rval,hexpected) \
2231 V_VT(&left) = VT_##vt1; V_I4(&left) = val1; \
2232 V_VT(&right) = VT_##vt2; V_I4(&right) = val2; \
2233 V_VT(&exp) = VT_##rvt; V_I4(&exp) = rval; \
2234 test_Mod( __LINE__, &left, &right, &exp, hexpected )
2236 static void test_VarMod(void)
2238 VARIANT v1
, v2
, vDst
, left
, right
, exp
;
2240 HRESULT hexpected
= 0;
2241 static const WCHAR szNum0
[] = {'1','2','5','\0'};
2242 static const WCHAR szNum1
[] = {'1','0','\0'};
2244 BOOL lFound
, rFound
;
2245 BOOL lValid
, rValid
;
2246 BSTR strNum0
, strNum1
;
2250 VARMOD(I1
,BOOL
,100,10,I4
,0);
2251 VARMOD(I1
,I1
,100,10,I4
,0);
2252 VARMOD(I1
,UI1
,100,10,I4
,0);
2253 VARMOD(I1
,I2
,100,10,I4
,0);
2254 VARMOD(I1
,UI2
,100,10,I4
,0);
2255 VARMOD(I1
,I4
,100,10,I4
,0);
2256 VARMOD(I1
,UI4
,100,10,I4
,0);
2257 VARMOD(I1
,R4
,100,10,I4
,0);
2258 VARMOD(I1
,R8
,100,10,I4
,0);
2260 VARMOD(UI1
,BOOL
,100,10,I2
,0);
2261 VARMOD(UI1
,I1
,100,10,I4
,0);
2262 VARMOD(UI1
,UI1
,100,10,UI1
,0);
2263 VARMOD(UI1
,I2
,100,10,I2
,0);
2264 VARMOD(UI1
,UI2
,100,10,I4
,0);
2265 VARMOD(UI1
,I4
,100,10,I4
,0);
2266 VARMOD(UI1
,UI4
,100,10,I4
,0);
2267 VARMOD(UI1
,R4
,100,10,I4
,0);
2268 VARMOD(UI1
,R8
,100,10,I4
,0);
2270 VARMOD(I2
,BOOL
,100,10,I2
,0);
2271 VARMOD(I2
,I1
,100,10,I4
,0);
2272 VARMOD(I2
,UI1
,100,10,I2
,0);
2273 VARMOD(I2
,I2
,100,10,I2
,0);
2274 VARMOD(I2
,UI2
,100,10,I4
,0);
2275 VARMOD(I2
,I4
,100,10,I4
,0);
2276 VARMOD(I2
,UI4
,100,10,I4
,0);
2277 VARMOD(I2
,R4
,100,10,I4
,0);
2278 VARMOD(I2
,R8
,100,10,I4
,0);
2280 VARMOD(I4
,BOOL
,100,10,I4
,0);
2281 VARMOD(I4
,I1
,100,10,I4
,0);
2282 VARMOD(I4
,UI1
,100,10,I4
,0);
2283 VARMOD(I4
,I2
,100,10,I4
,0);
2284 VARMOD(I4
,UI2
,100,10,I4
,0);
2285 VARMOD(I4
,I4
,100,10,I4
,0);
2286 VARMOD(I4
,UI4
,100,10,I4
,0);
2287 VARMOD(I4
,R4
,100,10,I4
,0);
2288 VARMOD(I4
,R8
,100,10,I4
,0);
2289 VARMOD(UI4
,BOOL
,100,10,I4
,0);
2290 VARMOD(UI4
,I1
,100,10,I4
,0);
2291 VARMOD(UI4
,UI1
,100,10,I4
,0);
2292 VARMOD(UI4
,I2
,100,10,I4
,0);
2293 VARMOD(UI4
,UI2
,100,10,I4
,0);
2294 VARMOD(UI4
,I4
,100,10,I4
,0);
2295 VARMOD(UI4
,UI4
,100,10,I4
,0);
2296 VARMOD(UI4
,R4
,100,10,I4
,0);
2297 VARMOD(UI4
,R8
,100,10,I4
,0);
2298 VARMOD(R4
,BOOL
,100,10,I4
,0);
2299 VARMOD(R4
,I1
,100,10,I4
,0);
2300 VARMOD(R4
,UI1
,100,10,I4
,0);
2301 VARMOD(R4
,I2
,100,10,I4
,0);
2302 VARMOD(R4
,UI2
,100,10,I4
,0);
2303 VARMOD(R4
,I4
,100,10,I4
,0);
2304 VARMOD(R4
,UI4
,100,10,I4
,0);
2305 VARMOD(R4
,R4
,100,10,I4
,0);
2306 VARMOD(R4
,R8
,100,10,I4
,0);
2307 VARMOD(R8
,BOOL
,100,10,I4
,0);
2308 VARMOD(R8
,I1
,100,10,I4
,0);
2309 VARMOD(R8
,UI1
,100,10,I4
,0);
2310 VARMOD(R8
,I2
,100,10,I4
,0);
2311 VARMOD(R8
,UI2
,100,10,I4
,0);
2312 VARMOD(R8
,I4
,100,10,I4
,0);
2313 VARMOD(R8
,UI4
,100,10,I4
,0);
2314 VARMOD(R8
,R4
,100,10,I4
,0);
2315 VARMOD(R8
,R8
,100,10,I4
,0);
2317 VARMOD(INT
,INT
,100,10,I4
,0);
2318 VARMOD(INT
,UINT
,100,10,I4
,0);
2320 VARMOD(BOOL
,BOOL
,100,10,I2
,0);
2321 VARMOD(BOOL
,I1
,100,10,I4
,0);
2322 VARMOD(BOOL
,UI1
,100,10,I2
,0);
2323 VARMOD(BOOL
,I2
,100,10,I2
,0);
2324 VARMOD(BOOL
,UI2
,100,10,I4
,0);
2325 VARMOD(BOOL
,I4
,100,10,I4
,0);
2326 VARMOD(BOOL
,UI4
,100,10,I4
,0);
2327 VARMOD(BOOL
,R4
,100,10,I4
,0);
2328 VARMOD(BOOL
,R8
,100,10,I4
,0);
2329 VARMOD(BOOL
,DATE
,100,10,I4
,0);
2331 VARMOD(DATE
,BOOL
,100,10,I4
,0);
2332 VARMOD(DATE
,I1
,100,10,I4
,0);
2333 VARMOD(DATE
,UI1
,100,10,I4
,0);
2334 VARMOD(DATE
,I2
,100,10,I4
,0);
2335 VARMOD(DATE
,UI2
,100,10,I4
,0);
2336 VARMOD(DATE
,I4
,100,10,I4
,0);
2337 VARMOD(DATE
,UI4
,100,10,I4
,0);
2338 VARMOD(DATE
,R4
,100,10,I4
,0);
2339 VARMOD(DATE
,R8
,100,10,I4
,0);
2340 VARMOD(DATE
,DATE
,100,10,I4
,0);
2342 strNum0
= SysAllocString(szNum0
);
2343 strNum1
= SysAllocString(szNum1
);
2344 VARMOD(BSTR
,BSTR
,strNum0
,strNum1
,I4
,5);
2345 VARMOD(BSTR
,I1
,strNum0
,10,I4
,5);
2346 VARMOD(BSTR
,I2
,strNum0
,10,I4
,5);
2347 VARMOD(BSTR
,I4
,strNum0
,10,I4
,5);
2348 VARMOD(BSTR
,R4
,strNum0
,10,I4
,5);
2349 VARMOD(BSTR
,R8
,strNum0
,10,I4
,5);
2350 VARMOD(I4
,BSTR
,125,strNum1
,I4
,5);
2352 if (HAVE_OLEAUT32_I8
)
2354 VARMOD(BOOL
,I8
,100,10,I8
,0);
2355 VARMOD(I1
,I8
,100,10,I8
,0);
2356 VARMOD(UI1
,I8
,100,10,I8
,0);
2357 VARMOD(I2
,I8
,100,10,I8
,0);
2358 VARMOD(I4
,I8
,100,10,I8
,0);
2359 VARMOD(UI4
,I8
,100,10,I8
,0);
2360 VARMOD(R4
,I8
,100,10,I8
,0);
2361 VARMOD(R8
,I8
,100,10,I8
,0);
2362 VARMOD(DATE
,I8
,100,10,I8
,0);
2364 VARMOD(I8
,BOOL
,100,10,I8
,0);
2365 VARMOD(I8
,I1
,100,10,I8
,0);
2366 VARMOD(I8
,UI1
,100,10,I8
,0);
2367 VARMOD(I8
,I2
,100,10,I8
,0);
2368 VARMOD(I8
,UI2
,100,10,I8
,0);
2369 VARMOD(I8
,I4
,100,10,I8
,0);
2370 VARMOD(I8
,UI4
,100,10,I8
,0);
2371 VARMOD(I8
,R4
,100,10,I8
,0);
2372 VARMOD(I8
,R8
,100,10,I8
,0);
2373 VARMOD(I8
,I8
,100,10,I8
,0);
2375 VARMOD(BSTR
,I8
,strNum0
,10,I8
,5);
2378 /* test all combinations of types */
2379 for(l
= 0; l
< VT_BSTR_BLOB
; l
++)
2383 for(r
= 0; r
< VT_BSTR_BLOB
; r
++)
2387 if(l
== VT_BSTR
) continue;
2388 if(l
== VT_DISPATCH
) continue;
2389 if(r
== VT_BSTR
) continue;
2390 if(r
== VT_DISPATCH
) continue;
2424 hexpected
= DISP_E_BADVARTYPE
;
2463 if(((l
== VT_I8
) && (r
== VT_INT
)) || ((l
== VT_INT
) && (r
== VT_I8
)))
2465 hexpected
= DISP_E_TYPEMISMATCH
;
2466 } else if((l
== VT_EMPTY
) && (r
== VT_NULL
))
2469 } else if((l
== VT_NULL
) && (r
== VT_EMPTY
))
2472 } else if((l
== VT_EMPTY
) && (r
== VT_CY
))
2475 } else if((l
== VT_EMPTY
) && (r
== VT_RECORD
))
2477 hexpected
= DISP_E_TYPEMISMATCH
;
2478 } else if((r
== VT_EMPTY
) && lFound
&& lValid
)
2480 hexpected
= DISP_E_DIVBYZERO
;
2481 } else if((l
== VT_ERROR
) || ((r
== VT_ERROR
) && lFound
&& lValid
))
2483 hexpected
= DISP_E_TYPEMISMATCH
;
2484 } else if((l
== VT_NULL
) && (r
== VT_NULL
))
2487 } else if((l
== VT_VARIANT
) || ((r
== VT_VARIANT
) && lFound
&& lValid
))
2489 hexpected
= DISP_E_TYPEMISMATCH
;
2490 } else if((l
== VT_NULL
) && (r
== VT_RECORD
))
2492 hexpected
= DISP_E_TYPEMISMATCH
;
2493 } else if((l
== VT_I8
) && (r
== VT_DECIMAL
))
2496 } else if((l
== VT_DECIMAL
) && (r
== VT_I8
))
2499 } else if((l
== VT_UNKNOWN
) || ((r
== VT_UNKNOWN
) && lFound
&& lValid
))
2501 hexpected
= DISP_E_TYPEMISMATCH
;
2502 } else if((l
== VT_NULL
) && rFound
)
2505 } else if(l
== VT_RECORD
)
2507 hexpected
= DISP_E_TYPEMISMATCH
;
2508 } else if((r
== VT_RECORD
) && lValid
&& lFound
)
2510 hexpected
= DISP_E_TYPEMISMATCH
;
2511 } else if((l
== VT_EMPTY
) && (r
== VT_EMPTY
))
2513 hexpected
= DISP_E_DIVBYZERO
;
2514 } else if((l
== VT_CY
) && !rFound
)
2516 hexpected
= DISP_E_BADVARTYPE
;
2517 } else if(lFound
&& !rFound
)
2519 hexpected
= DISP_E_BADVARTYPE
;
2520 } else if(!lFound
&& rFound
)
2522 hexpected
= DISP_E_BADVARTYPE
;
2523 } else if((r
== VT_NULL
) && lFound
&& lValid
)
2526 } else if((l
== VT_NULL
) || (r
== VT_NULL
))
2528 hexpected
= DISP_E_BADVARTYPE
;
2529 } else if((l
== VT_VARIANT
) || (r
== VT_VARIANT
))
2531 hexpected
= DISP_E_BADVARTYPE
;
2532 } else if(lFound
&& !rFound
)
2534 hexpected
= DISP_E_BADVARTYPE
;
2535 } else if(!lFound
&& !rFound
)
2537 hexpected
= DISP_E_BADVARTYPE
;
2544 V_CY(&v1
).int64
= 1000000;
2549 else if(l
== VT_UI8
)
2553 else if(l
== VT_DATE
)
2555 else if (l
== VT_DECIMAL
)
2557 V_DECIMAL(&v1
).Hi32
= 0;
2558 U1(V_DECIMAL(&v1
)).Lo64
= 100;
2559 U(V_DECIMAL(&v1
)).signscale
= 0;
2565 V_CY(&v2
).int64
= 10000;
2570 else if(r
== VT_UI8
)
2574 else if(r
== VT_DATE
)
2576 else if (r
== VT_DECIMAL
)
2578 V_DECIMAL(&v2
).Hi32
= 0;
2579 U1(V_DECIMAL(&v2
)).Lo64
= 100;
2580 U(V_DECIMAL(&v2
)).signscale
= 0;
2585 if ((l
!= VT_I8
&& l
!= VT_UI8
&& r
!= VT_I8
&& r
!= VT_UI8
) || HAVE_OLEAUT32_I8
)
2587 hres
= pVarMod(&v1
,&v2
,&vDst
);
2588 ok(hres
== hexpected
,
2589 "VarMod: expected 0x%x, got 0x%X for l type of %d, r type of %d,\n", hexpected
, hres
, l
, r
);
2595 /****************************/
2596 /* test some bad parameters */
2597 VARMOD(I4
,I4
,-1,-1,I4
,0);
2599 /* test modulus with zero */
2600 VARMOD2(I4
,I4
,100,0,EMPTY
,0,DISP_E_DIVBYZERO
);
2602 VARMOD(I4
,I4
,0,10,I4
,0); /* test 0 mod 10 */
2604 /* right parameter is type empty */
2605 VARMOD2(I4
,EMPTY
,100,10,EMPTY
,0,DISP_E_DIVBYZERO
);
2607 /* left parameter is type empty */
2608 VARMOD2(EMPTY
,I4
,100,10,I4
,0,S_OK
);
2610 /* mod with a null left value */
2611 VARMOD2(NULL
,I4
,125,10,NULL
,0,S_OK
);
2613 /* mod with a null right value */
2614 VARMOD2(I4
,NULL
,100,10,NULL
,0,S_OK
);
2616 /* void left value */
2617 VARMOD2(VOID
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2619 /* void right value */
2620 VARMOD2(I4
,VOID
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2622 /* null left value, void right value */
2623 VARMOD2(NULL
,VOID
,100,10,EMPTY
, 0, DISP_E_BADVARTYPE
);
2625 /* void left value, null right value */
2626 VARMOD2(VOID
,NULL
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2628 /* some currencies */
2631 V_CY(&v1
).int64
= 100000;
2632 V_CY(&v2
).int64
= 100000;
2633 hres
= pVarMod(&v1
,&v2
,&vDst
);
2634 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I4
&& V_I4(&vDst
) == 0,
2635 "VarMod: expected 0x%x,%d,%d, got 0x%X,%d,%d\n", S_OK
, VT_I4
, 0, hres
, V_VT(&vDst
), V_I4(&vDst
));
2640 V_CY(&v2
).int64
= 100000;
2641 hres
= pVarMod(&v1
,&v2
,&vDst
);
2642 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I4
&& V_I4(&vDst
) == 0,
2643 "VarMod: expected 0x%x,%d,%d, got 0x%X,%d,%d\n", S_OK
, VT_I4
, 0, hres
, V_VT(&vDst
), V_I4(&vDst
));
2646 V_VT(&v1
) = VT_DECIMAL
;
2647 V_VT(&v2
) = VT_DECIMAL
;
2648 VarDecFromI4(100, &V_DECIMAL(&v1
));
2649 VarDecFromI4(10, &V_DECIMAL(&v2
));
2650 hres
= pVarMod(&v1
,&v2
,&vDst
);
2651 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I4
&& V_I4(&vDst
) == 0,
2652 "VarMod: expected 0x%x,%d,%d, got 0x%X,%d,%d\n", S_OK
, VT_I4
, 0, hres
, V_VT(&vDst
), V_I4(&vDst
));
2655 V_VT(&v2
) = VT_DECIMAL
;
2657 VarDecFromI4(10, &V_DECIMAL(&v2
));
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
));
2662 VARMOD2(UINT
,I4
,100,10,I4
,0,S_OK
);
2664 /* test that an error results in the type of the result changing but not its value */
2665 V_VT(&v1
) = VT_UNKNOWN
;
2666 V_VT(&v2
) = VT_EMPTY
;
2668 V_CY(&v2
).int64
= 100000;
2669 V_VT(&vDst
) = VT_I4
;
2671 hres
= pVarMod(&v1
,&v2
,&vDst
);
2672 ok(hres
== DISP_E_TYPEMISMATCH
&& V_VT(&vDst
) == VT_EMPTY
&& V_I4(&vDst
) == 1231,
2673 "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
));
2676 /* test some invalid types */
2677 /*TODO: not testing VT_DISPATCH */
2678 if (HAVE_OLEAUT32_I8
)
2680 VARMOD2(I8
,INT
,100,10,EMPTY
,0,DISP_E_TYPEMISMATCH
);
2682 VARMOD2(ERROR
,I4
,100,10,EMPTY
,0,DISP_E_TYPEMISMATCH
);
2683 VARMOD2(VARIANT
,I4
,100,10,EMPTY
,0,DISP_E_TYPEMISMATCH
);
2684 VARMOD2(UNKNOWN
,I4
,100,10,EMPTY
,0,DISP_E_TYPEMISMATCH
);
2685 VARMOD2(VOID
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2686 VARMOD2(HRESULT
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2687 VARMOD2(PTR
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2688 VARMOD2(SAFEARRAY
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2689 VARMOD2(CARRAY
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2690 VARMOD2(USERDEFINED
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2691 VARMOD2(LPSTR
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2692 VARMOD2(LPWSTR
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2693 VARMOD2(RECORD
,I4
,100,10,EMPTY
,0,DISP_E_TYPEMISMATCH
);
2694 VARMOD2(FILETIME
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2695 VARMOD2(BLOB
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2696 VARMOD2(STREAM
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2697 VARMOD2(STORAGE
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2698 VARMOD2(STREAMED_OBJECT
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2699 VARMOD2(STORED_OBJECT
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2700 VARMOD2(BLOB_OBJECT
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2701 VARMOD2(CF
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2702 VARMOD2(CLSID
,CLSID
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2703 VARMOD2(VECTOR
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2704 VARMOD2(ARRAY
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2705 VARMOD2(BYREF
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2707 /* test some more invalid types */
2712 hres
= pVarMod(&v1
,&v2
,&vDst
);
2713 ok(hres
== DISP_E_BADVARTYPE
&& V_VT(&vDst
) == VT_EMPTY
,
2714 "VarMod: expected 0x%x,%d, got 0x%X,%d\n", DISP_E_BADVARTYPE
, VT_EMPTY
, hres
, V_VT(&vDst
));
2717 static HRESULT (WINAPI
*pVarFix
)(LPVARIANT
,LPVARIANT
);
2719 #define VARFIX(vt,val,rvt,rval) \
2720 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
2721 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
2722 test_var_call1( __LINE__, pVarFix, &v, &exp )
2724 static void test_VarFix(void)
2726 static const WCHAR szNumMinus1
[] = {'-','1','\0' };
2728 VARIANT v
, exp
, vDst
;
2729 DECIMAL
*pdec
= &V_DECIMAL(&v
);
2730 CY
*pcy
= &V_CY(&v
);
2735 /* Test all possible V_VT values */
2736 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
2740 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
2742 HRESULT bFail
= TRUE
;
2746 memset(&v
, 0, sizeof(v
));
2747 V_VT(&v
) = vt
| ExtraFlags
[i
];
2748 V_VT(&vDst
) = VT_EMPTY
;
2752 case VT_UI1
: case VT_I2
: case VT_I4
: case VT_R4
: case VT_R8
:
2753 case VT_DECIMAL
: case VT_BOOL
: case VT_NULL
: case VT_EMPTY
:
2754 case VT_DATE
: case VT_CY
:
2758 if (HAVE_OLEAUT32_I8
)
2763 hres
= pVarFix(&v
,&vDst
);
2765 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
2766 "VarFix: expected failure, got 0x%X vt %d|0x%X\n",
2767 hres
, vt
, ExtraFlags
[i
]);
2769 ok(hres
== S_OK
, "VarFix: expected S_OK, got 0x%X vt %d|0x%X\n",
2770 hres
, vt
, ExtraFlags
[i
]);
2774 VARFIX(BOOL
,VARIANT_TRUE
,I2
,VARIANT_TRUE
);
2775 VARFIX(BOOL
,VARIANT_FALSE
,I2
,0);
2776 VARFIX(BOOL
,1,I2
,1);
2777 VARFIX(UI1
,1,UI1
,1);
2778 VARFIX(I2
,-1,I2
,-1);
2779 VARFIX(I4
,-1,I4
,-1);
2780 if (HAVE_OLEAUT32_I8
)
2782 VARFIX(I8
,-1,I8
,-1);
2784 VARFIX(R4
,1.4f
,R4
,1);
2785 VARFIX(R4
,1.5f
,R4
,1);
2786 VARFIX(R4
,1.6f
,R4
,1);
2787 VARFIX(R4
,-1.4f
,R4
,-1);
2788 VARFIX(R4
,-1.5f
,R4
,-1);
2789 VARFIX(R4
,-1.6f
,R4
,-1);
2790 /* DATE & R8 round as for R4 */
2791 VARFIX(DATE
,-1,DATE
,-1);
2792 VARFIX(R8
,-1,R8
,-1);
2793 VARFIX(BSTR
,(BSTR
)szNumMinus1
,R8
,-1);
2795 V_VT(&v
) = VT_EMPTY
;
2796 hres
= pVarFix(&v
,&vDst
);
2797 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I2
&& V_I2(&vDst
) == 0,
2798 "VarFix: expected 0x0,%d,0 got 0x%X,%d,%d\n", VT_EMPTY
,
2799 hres
, V_VT(&vDst
), V_I2(&vDst
));
2802 hres
= pVarFix(&v
,&vDst
);
2803 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_NULL
,
2804 "VarFix: expected 0x0,%d got 0x%X,%d\n", VT_NULL
, hres
, V_VT(&vDst
));
2806 V_VT(&v
) = VT_DECIMAL
;
2807 S(U(*pdec
)).sign
= DECIMAL_NEG
;
2808 S(U(*pdec
)).scale
= 0;
2810 S1(U1(*pdec
)).Mid32
= 0;
2811 S1(U1(*pdec
)).Lo32
= 1;
2812 hres
= pVarFix(&v
,&vDst
);
2813 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_DECIMAL
&& !memcmp(&v
, &vDst
, sizeof(v
)),
2814 "VarFix: expected 0x0,%d,identical, got 0x%X,%d\n", VT_DECIMAL
,
2817 /* FIXME: Test some fractional decimals when VarDecFix is implemented */
2820 pcy
->int64
= -10000;
2821 hres
= pVarFix(&v
,&vDst
);
2822 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_CY
&& V_CY(&vDst
).int64
== -10000,
2823 "VarFix: VT_CY wrong, hres=0x%X\n", hres
);
2826 pcy
->int64
= -16000;
2827 hres
= pVarFix(&v
,&vDst
);
2828 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_CY
&& V_CY(&vDst
).int64
== -10000,
2829 "VarFix: VT_CY wrong, hres=0x%X\n", hres
);
2832 static HRESULT (WINAPI
*pVarInt
)(LPVARIANT
,LPVARIANT
);
2834 #define VARINT(vt,val,rvt,rval) \
2835 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
2836 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
2837 test_var_call1( __LINE__, pVarInt, &v, &exp )
2839 static void test_VarInt(void)
2841 static const WCHAR szNumMinus1
[] = {'-','1','\0' };
2843 VARIANT v
, exp
, vDst
;
2844 DECIMAL
*pdec
= &V_DECIMAL(&v
);
2845 CY
*pcy
= &V_CY(&v
);
2850 /* Test all possible V_VT values */
2851 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
2855 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
2857 HRESULT bFail
= TRUE
;
2861 memset(&v
, 0, sizeof(v
));
2862 V_VT(&v
) = vt
| ExtraFlags
[i
];
2863 V_VT(&vDst
) = VT_EMPTY
;
2867 case VT_UI1
: case VT_I2
: case VT_I4
: case VT_R4
: case VT_R8
:
2868 case VT_DECIMAL
: case VT_BOOL
: case VT_NULL
: case VT_EMPTY
:
2869 case VT_DATE
: case VT_CY
:
2873 if (HAVE_OLEAUT32_I8
)
2878 hres
= pVarInt(&v
,&vDst
);
2880 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
2881 "VarInt: expected failure, got 0x%X vt %d|0x%X\n",
2882 hres
, vt
, ExtraFlags
[i
]);
2884 ok(hres
== S_OK
, "VarInt: expected S_OK, got 0x%X vt %d|0x%X\n",
2885 hres
, vt
, ExtraFlags
[i
]);
2889 VARINT(BOOL
,VARIANT_TRUE
,I2
,VARIANT_TRUE
);
2890 VARINT(BOOL
,VARIANT_FALSE
,I2
,0);
2891 VARINT(BOOL
,1,I2
,1);
2892 VARINT(UI1
,1,UI1
,1);
2893 VARINT(I2
,-1,I2
,-1);
2894 VARINT(I4
,-1,I4
,-1);
2895 if (HAVE_OLEAUT32_I8
)
2897 VARINT(I8
,-1,I8
,-1);
2899 VARINT(R4
,1.4f
,R4
,1);
2900 VARINT(R4
,1.5f
,R4
,1);
2901 VARINT(R4
,1.6f
,R4
,1);
2902 VARINT(R4
,-1.4f
,R4
,-2); /* Note these 3 are different from VarFix */
2903 VARINT(R4
,-1.5f
,R4
,-2);
2904 VARINT(R4
,-1.6f
,R4
,-2);
2905 /* DATE & R8 round as for R4 */
2906 VARINT(DATE
,-1,DATE
,-1);
2907 VARINT(R8
,-1,R8
,-1);
2908 VARINT(BSTR
,(BSTR
)szNumMinus1
,R8
,-1);
2910 V_VT(&v
) = VT_EMPTY
;
2911 hres
= pVarInt(&v
,&vDst
);
2912 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I2
&& V_I2(&vDst
) == 0,
2913 "VarInt: expected 0x0,%d,0 got 0x%X,%d,%d\n", VT_EMPTY
,
2914 hres
, V_VT(&vDst
), V_I2(&vDst
));
2917 hres
= pVarInt(&v
,&vDst
);
2918 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_NULL
,
2919 "VarInt: expected 0x0,%d got 0x%X,%d\n", VT_NULL
, hres
, V_VT(&vDst
));
2921 V_VT(&v
) = VT_DECIMAL
;
2922 S(U(*pdec
)).sign
= DECIMAL_NEG
;
2923 S(U(*pdec
)).scale
= 0;
2925 S1(U1(*pdec
)).Mid32
= 0;
2926 S1(U1(*pdec
)).Lo32
= 1;
2927 hres
= pVarInt(&v
,&vDst
);
2928 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_DECIMAL
&& !memcmp(&v
, &vDst
, sizeof(v
)),
2929 "VarInt: expected 0x0,%d,identical, got 0x%X,%d\n", VT_DECIMAL
,
2932 /* FIXME: Test some fractional decimals when VarDecInt is implemented */
2935 pcy
->int64
= -10000;
2936 hres
= pVarInt(&v
,&vDst
);
2937 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_CY
&& V_CY(&vDst
).int64
== -10000,
2938 "VarInt: VT_CY wrong, hres=0x%X\n", hres
);
2941 pcy
->int64
= -11000;
2942 hres
= pVarInt(&v
,&vDst
);
2943 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_CY
&& V_CY(&vDst
).int64
== -20000,
2944 "VarInt: VT_CY wrong, hres=0x%X 0x%x%08x\n",
2945 hres
, (DWORD
)(V_CY(&vDst
).int64
>> 32), (DWORD
)V_CY(&vDst
).int64
);
2948 static HRESULT (WINAPI
*pVarNeg
)(LPVARIANT
,LPVARIANT
);
2950 #define VARNEG(vt,val,rvt,rval) \
2951 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
2952 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
2953 test_var_call1( __LINE__, pVarNeg, &v, &exp )
2955 static void test_VarNeg(void)
2957 static const WCHAR szNumMinus1
[] = {'-','1','\0' };
2958 static const WCHAR szNum1
[] = {'1','\0' };
2960 VARIANT v
, exp
, vDst
;
2961 DECIMAL
*pdec
= &V_DECIMAL(&v
);
2962 CY
*pcy
= &V_CY(&v
);
2967 /* Test all possible V_VT values. But don't test the exact return values
2968 * except for success/failure, since M$ made a hash of them in the
2969 * native version. This at least ensures (as with all tests here) that
2970 * we will notice if/when new vtypes/flags are added in native.
2972 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
2976 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
2978 HRESULT bFail
= TRUE
;
2982 memset(&v
, 0, sizeof(v
));
2983 V_VT(&v
) = vt
| ExtraFlags
[i
];
2984 V_VT(&vDst
) = VT_EMPTY
;
2988 case VT_UI1
: case VT_I2
: case VT_I4
:
2989 case VT_R4
: case VT_R8
:
2990 case VT_DECIMAL
: case VT_BOOL
: case VT_NULL
: case VT_EMPTY
:
2991 case VT_DATE
: case VT_CY
:
2995 if (HAVE_OLEAUT32_I8
)
2999 hres
= pVarNeg(&v
,&vDst
);
3001 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
3002 "VarNeg: expected failure, got 0x%X vt %d|0x%X\n",
3003 hres
, vt
, ExtraFlags
[i
]);
3005 ok(hres
== S_OK
, "VarNeg: expected S_OK, got 0x%X vt %d|0x%X\n",
3006 hres
, vt
, ExtraFlags
[i
]);
3010 VARNEG(BOOL
,VARIANT_TRUE
,I2
,1);
3011 VARNEG(BOOL
,VARIANT_FALSE
,I2
,0);
3012 VARNEG(BOOL
,1,I2
,-1);
3013 VARNEG(UI1
,1,I2
,-1);
3014 VARNEG(UI1
,254,I2
,-254);
3015 VARNEG(I2
,-32768,I4
,32768);
3018 VARNEG(I4
,-((int)(~0u >> 1)) - 1,R8
,-2147483648u);
3021 if (HAVE_OLEAUT32_I8
)
3028 VARNEG(DATE
,1,DATE
,-1);
3029 VARNEG(DATE
,-1,DATE
,1);
3032 VARNEG(BSTR
,(BSTR
)szNumMinus1
,R8
,1);
3033 VARNEG(BSTR
,(BSTR
)szNum1
,R8
,-1);
3035 V_VT(&v
) = VT_EMPTY
;
3036 hres
= pVarNeg(&v
,&vDst
);
3037 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I2
&& V_I2(&vDst
) == 0,
3038 "VarNeg: expected 0x0,%d,0 got 0x%X,%d,%d\n", VT_EMPTY
,
3039 hres
, V_VT(&vDst
), V_I2(&vDst
));
3042 hres
= pVarNeg(&v
,&vDst
);
3043 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_NULL
,
3044 "VarNeg: expected 0x0,%d got 0x%X,%d\n", VT_NULL
, hres
, V_VT(&vDst
));
3046 V_VT(&v
) = VT_DECIMAL
;
3047 S(U(*pdec
)).sign
= DECIMAL_NEG
;
3048 S(U(*pdec
)).scale
= 0;
3050 S1(U1(*pdec
)).Mid32
= 0;
3051 S1(U1(*pdec
)).Lo32
= 1;
3052 hres
= pVarNeg(&v
,&vDst
);
3053 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_DECIMAL
&&
3054 S(U(V_DECIMAL(&vDst
))).sign
== 0,
3055 "VarNeg: expected 0x0,%d,0x00, got 0x%X,%d,%02x\n", VT_DECIMAL
,
3056 hres
, V_VT(&vDst
), S(U(V_DECIMAL(&vDst
))).sign
);
3058 S(U(*pdec
)).sign
= 0;
3059 hres
= pVarNeg(&v
,&vDst
);
3060 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_DECIMAL
&&
3061 S(U(V_DECIMAL(&vDst
))).sign
== DECIMAL_NEG
,
3062 "VarNeg: expected 0x0,%d,0x7f, got 0x%X,%d,%02x\n", VT_DECIMAL
,
3063 hres
, V_VT(&vDst
), S(U(V_DECIMAL(&vDst
))).sign
);
3066 pcy
->int64
= -10000;
3067 hres
= pVarNeg(&v
,&vDst
);
3068 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_CY
&& V_CY(&vDst
).int64
== 10000,
3069 "VarNeg: VT_CY wrong, hres=0x%X\n", hres
);
3072 static HRESULT (WINAPI
*pVarRound
)(LPVARIANT
,int,LPVARIANT
);
3074 static void test_Round( int line
, VARIANT
*arg
, int deci
, VARIANT
*expected
)
3079 memset( &result
, 0, sizeof(result
) );
3080 hres
= pVarRound( arg
, deci
, &result
);
3081 ok_(__FILE__
,line
)( hres
== S_OK
, "wrong result %x\n", hres
);
3083 ok_(__FILE__
,line
)( is_expected_variant( &result
, expected
),
3084 "got %s expected %s\n", variantstr(&result
), variantstr(expected
) );
3086 #define VARROUND(vt,val,deci,rvt,rval) \
3087 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
3088 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
3089 test_Round( __LINE__, &v, deci, &exp )
3091 static void test_VarRound(void)
3093 static const WCHAR szNumMin
[] = {'-','1','.','4','5','\0' };
3094 static const WCHAR szNum
[] = {'1','.','4','5','\0' };
3096 VARIANT v
, exp
, vDst
;
3097 CY
*pcy
= &V_CY(&v
);
3101 /* first check valid integer types */
3102 VARROUND(BOOL
,VARIANT_TRUE
,0,I2
,-1);
3103 VARROUND(BOOL
,VARIANT_FALSE
,0,I2
,0);
3104 VARROUND(BOOL
,1,0,I2
,1);
3105 VARROUND(UI1
,1,0,UI1
,1);
3106 VARROUND(UI1
,254,0,UI1
,254);
3107 VARROUND(I2
,-32768,0,I2
,-32768);
3108 VARROUND(I2
,-1,0,I2
,-1);
3109 VARROUND(I2
,1,0,I2
,1);
3110 VARROUND(I4
,-((int)(~0u >> 1)) - 1,0,I4
,-((int)(~0u >> 1)) - 1);
3111 VARROUND(I4
,-1,0,I4
,-1);
3112 VARROUND(I4
,1,0,I4
,1);
3115 /* MSDN states that rounding of R4/R8 is dependent on the underlying
3116 * bit pattern of the number and so is architecture dependent. In this
3117 * case Wine returns .2 (which is more correct) and Native returns .3
3120 VARROUND(R4
,1.0f
,0,R4
,1.0f
);
3121 VARROUND(R4
,-1.0f
,0,R4
,-1.0f
);
3122 VARROUND(R8
,1.0,0,R8
,1.0);
3123 VARROUND(R8
,-1.0,0,R8
,-1.0);
3125 /* floating point numbers aren't exactly equal and we can't just
3126 * compare the first few digits. */
3127 VARROUND(DATE
,1.451,1,DATE
,1.5);
3128 VARROUND(DATE
,-1.45,1,DATE
,-1.4);
3129 VARROUND(BSTR
,(BSTR
)szNumMin
,1,R8
,-1.40);
3130 if (0) { VARROUND(BSTR
,(BSTR
)szNum
,1,R8
,1.50); }
3132 VARROUND(R4
,1.23456f
,0,R4
,1.0f
);
3133 VARROUND(R4
,1.23456f
,1,R4
,1.2f
);
3134 VARROUND(R4
,1.23456f
,2,R4
,1.23f
);
3135 VARROUND(R4
,1.23456f
,3,R4
,1.235f
);
3136 VARROUND(R4
,1.23456f
,4,R4
,1.2346f
);
3137 VARROUND(R4
,-1.23456f
,0,R4
,-1.0f
);
3138 VARROUND(R4
,-1.23456f
,1,R4
,-1.2f
);
3139 VARROUND(R4
,-1.23456f
,2,R4
,-1.23f
);
3140 VARROUND(R4
,-1.23456f
,3,R4
,-1.235f
);
3141 VARROUND(R4
,-1.23456f
,4,R4
,-1.2346f
);
3143 VARROUND(R8
,1.23456,0,R8
,1.0);
3144 VARROUND(R8
,1.23456,1,R8
,1.2);
3145 VARROUND(R8
,1.23456,2,R8
,1.23);
3146 VARROUND(R8
,1.23456,3,R8
,1.235);
3147 VARROUND(R8
,1.23456,4,R8
,1.2346);
3148 VARROUND(R8
,-1.23456,0,R8
,-1.0);
3149 VARROUND(R8
,-1.23456,1,R8
,-1.2);
3150 VARROUND(R8
,-1.23456,2,R8
,-1.23);
3151 VARROUND(R8
,-1.23456,3,R8
,-1.235);
3152 VARROUND(R8
,-1.23456,4,R8
,-1.2346);
3154 V_VT(&v
) = VT_EMPTY
;
3155 hres
= pVarRound(&v
,0,&vDst
);
3156 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I2
&& V_I2(&vDst
) == 0,
3157 "VarRound: expected 0x0,%d,0 got 0x%X,%d,%d\n", VT_EMPTY
,
3158 hres
, V_VT(&vDst
), V_I2(&vDst
));
3161 hres
= pVarRound(&v
,0,&vDst
);
3162 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_NULL
,
3163 "VarRound: expected 0x0,%d got 0x%X,%d\n", VT_NULL
, hres
, V_VT(&vDst
));
3165 /* not yet implemented so no use testing yet
3167 DECIMAL *pdec = &V_DECIMAL(&v);
3168 V_VT(&v) = VT_DECIMAL;
3169 S(U(*pdec)).sign = DECIMAL_NEG;
3170 S(U(*pdec)).scale = 0;
3172 S1(U1(*pdec)).Mid32 = 0;
3173 S1(U1(*pdec)).Lo32 = 1;
3174 hres = pVarRound(&v,0,&vDst);
3175 ok(hres == S_OK && V_VT(&vDst) == VT_DECIMAL &&
3176 S(U(V_DECIMAL(&vDst))).sign == 0,
3177 "VarRound: expected 0x0,%d,0x00, got 0x%X,%d,%02x\n", VT_DECIMAL,
3178 hres, V_VT(&vDst), S(U(V_DECIMAL(&vDst))).sign);
3180 S(U(*pdec)).sign = 0;
3181 hres = pVarRound(&v,0,&vDst);
3182 ok(hres == S_OK && V_VT(&vDst) == VT_DECIMAL &&
3183 S(U(V_DECIMAL(&vDst))).sign == DECIMAL_NEG,
3184 "VarRound: expected 0x0,%d,0x7f, got 0x%X,%d,%02x\n", VT_DECIMAL,
3185 hres, V_VT(&vDst), S(U(V_DECIMAL(&vDst))).sign);
3191 hres
= pVarRound(&v
,0,&vDst
);
3192 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_CY
&& V_CY(&vDst
).int64
== 10000,
3193 "VarRound: VT_CY wrong, hres=0x%X\n", hres
);
3197 static HRESULT (WINAPI
*pVarXor
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
3199 #define VARXOR(vt1,val1,vt2,val2,rvt,rval) \
3200 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
3201 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
3202 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
3203 test_var_call2( __LINE__, pVarXor, &left, &right, &exp )
3205 #define VARXORCY(vt1,val1,val2,rvt,rval) \
3206 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
3207 V_VT(&right) = VT_CY; V_CY(&right).int64 = val2; \
3208 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
3209 test_var_call2( __LINE__, pVarXor, &left, &right, &exp )
3211 static void test_VarXor(void)
3213 static const WCHAR szFalse
[] = { '#','F','A','L','S','E','#','\0' };
3214 static const WCHAR szTrue
[] = { '#','T','R','U','E','#','\0' };
3215 VARIANT left
, right
, exp
, result
;
3222 /* Test all possible flag/vt combinations & the resulting vt type */
3223 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
3225 VARTYPE leftvt
, rightvt
, resvt
;
3227 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
3232 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
3238 if (leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
||
3239 leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
||
3240 leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
)
3243 memset(&left
, 0, sizeof(left
));
3244 memset(&right
, 0, sizeof(right
));
3245 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
3246 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
3247 V_VT(&result
) = VT_EMPTY
;
3250 if (ExtraFlags
[i
] & VT_ARRAY
|| ExtraFlags
[i
] & VT_BYREF
||
3251 !IsValidVariantClearVT(leftvt
, ExtraFlags
[i
]) ||
3252 !IsValidVariantClearVT(rightvt
, ExtraFlags
[i
]) ||
3253 leftvt
== VT_CLSID
|| rightvt
== VT_CLSID
||
3254 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
||
3255 leftvt
== VT_VARIANT
|| rightvt
== VT_VARIANT
||
3256 leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
)
3260 if (leftvt
== VT_EMPTY
|| rightvt
== VT_EMPTY
)
3262 if (leftvt
== rightvt
||
3263 leftvt
== VT_I2
|| rightvt
== VT_I2
||
3264 leftvt
== VT_UI1
|| rightvt
== VT_UI1
||
3265 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
3267 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
3269 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
3272 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
3276 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
3278 if (leftvt
== rightvt
)
3280 else if (leftvt
== rightvt
||
3281 leftvt
== VT_I2
|| rightvt
== VT_I2
||
3282 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
3286 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
3289 else if (leftvt
== VT_I2
|| rightvt
== VT_I2
)
3291 if (leftvt
== rightvt
||
3292 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
3294 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
3297 else if (leftvt
== VT_BOOL
&& rightvt
== VT_BOOL
)
3301 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
3303 if (leftvt
== VT_INT
|| rightvt
== VT_INT
)
3308 hres
= pVarXor(&left
, &right
, &result
);
3310 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
3311 "VarXor: %d|0x%X, %d|0x%X: Expected failure, got 0x%X vt %d\n",
3312 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], hres
,
3315 ok(hres
== S_OK
&& V_VT(&result
) == resvt
,
3316 "VarXor: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%X vt %d\n",
3317 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], resvt
, hres
,
3323 /* Test returned values
3324 * FIXME: Test VT_DECIMAL/VT_DISPATCH
3326 VARXOR(EMPTY
,0,EMPTY
,0,I2
,0);
3327 VARXOR(EMPTY
,1,EMPTY
,0,I2
,0);
3328 VARXOR(EMPTY
,0,NULL
,0,NULL
,0);
3329 VARXOR(EMPTY
,0,I1
,0,I4
,0);
3330 VARXOR(EMPTY
,0,I1
,1,I4
,1);
3331 VARXOR(EMPTY
,0,UI1
,0,I2
,0);
3332 VARXOR(EMPTY
,0,UI1
,1,I2
,1);
3333 VARXOR(EMPTY
,0,I2
,0,I2
,0);
3334 VARXOR(EMPTY
,0,I2
,1,I2
,1);
3335 VARXOR(EMPTY
,0,UI2
,0,I4
,0);
3336 VARXOR(EMPTY
,0,UI2
,1,I4
,1);
3337 VARXOR(EMPTY
,0,I4
,0,I4
,0);
3338 VARXOR(EMPTY
,0,I4
,1,I4
,1);
3339 VARXOR(EMPTY
,0,UI4
,0,I4
,0);
3340 VARXOR(EMPTY
,0,UI4
,1,I4
,1);
3341 if (HAVE_OLEAUT32_I8
)
3343 VARXOR(EMPTY
,0,I8
,0,I8
,0);
3344 VARXOR(EMPTY
,0,I8
,1,I8
,1);
3345 VARXOR(EMPTY
,0,UI8
,0,I4
,0);
3346 VARXOR(EMPTY
,0,UI8
,1,I4
,1);
3348 VARXOR(EMPTY
,0,INT
,0,I4
,0);
3349 VARXOR(EMPTY
,0,INT
,1,I4
,1);
3350 VARXOR(EMPTY
,0,UINT
,0,I4
,0);
3351 VARXOR(EMPTY
,0,UINT
,1,I4
,1);
3352 VARXOR(EMPTY
,0,BOOL
,0,I2
,0);
3353 VARXOR(EMPTY
,0,BOOL
,1,I2
,1);
3354 VARXOR(EMPTY
,0,R4
,0,I4
,0);
3355 VARXOR(EMPTY
,0,R4
,1,I4
,1);
3356 VARXOR(EMPTY
,0,R8
,0,I4
,0);
3357 VARXOR(EMPTY
,0,R8
,1,I4
,1);
3358 rbstr
= SysAllocString(szFalse
);
3359 VARXOR(EMPTY
,0,BSTR
,rbstr
,I2
,0);
3360 rbstr
= SysAllocString(szTrue
);
3361 VARXOR(EMPTY
,0,BSTR
,rbstr
,I2
,-1);
3362 VARXORCY(EMPTY
,0,10000,I4
,1);
3364 /* NULL OR 0 = NULL. NULL OR n = n */
3365 VARXOR(NULL
,0,NULL
,0,NULL
,0);
3366 VARXOR(NULL
,1,NULL
,0,NULL
,0);
3367 VARXOR(NULL
,0,I1
,0,NULL
,0);
3368 VARXOR(NULL
,0,I1
,1,NULL
,0);
3369 VARXOR(NULL
,0,UI1
,0,NULL
,0);
3370 VARXOR(NULL
,0,UI1
,1,NULL
,0);
3371 VARXOR(NULL
,0,I2
,0,NULL
,0);
3372 VARXOR(NULL
,0,I2
,1,NULL
,0);
3373 VARXOR(NULL
,0,UI2
,0,NULL
,0);
3374 VARXOR(NULL
,0,UI2
,1,NULL
,0);
3375 VARXOR(NULL
,0,I4
,0,NULL
,0);
3376 VARXOR(NULL
,0,I4
,1,NULL
,0);
3377 VARXOR(NULL
,0,UI4
,0,NULL
,0);
3378 VARXOR(NULL
,0,UI4
,1,NULL
,0);
3379 if (HAVE_OLEAUT32_I8
)
3381 VARXOR(NULL
,0,I8
,0,NULL
,0);
3382 VARXOR(NULL
,0,I8
,1,NULL
,0);
3383 VARXOR(NULL
,0,UI8
,0,NULL
,0);
3384 VARXOR(NULL
,0,UI8
,1,NULL
,0);
3386 VARXOR(NULL
,0,INT
,0,NULL
,0);
3387 VARXOR(NULL
,0,INT
,1,NULL
,0);
3388 VARXOR(NULL
,0,UINT
,0,NULL
,0);
3389 VARXOR(NULL
,0,UINT
,1,NULL
,0);
3390 VARXOR(NULL
,0,BOOL
,0,NULL
,0);
3391 VARXOR(NULL
,0,BOOL
,1,NULL
,0);
3392 VARXOR(NULL
,0,R4
,0,NULL
,0);
3393 VARXOR(NULL
,0,R4
,1,NULL
,0);
3394 VARXOR(NULL
,0,R8
,0,NULL
,0);
3395 VARXOR(NULL
,0,R8
,1,NULL
,0);
3396 rbstr
= SysAllocString(szFalse
);
3397 VARXOR(NULL
,0,BSTR
,rbstr
,NULL
,0);
3398 rbstr
= SysAllocString(szTrue
);
3399 VARXOR(NULL
,0,BSTR
,rbstr
,NULL
,0);
3400 VARXORCY(NULL
,0,10000,NULL
,0);
3401 VARXORCY(NULL
,0,0,NULL
,0);
3403 VARXOR(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
);
3404 VARXOR(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
);
3405 VARXOR(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
);
3406 VARXOR(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_FALSE
);
3407 /* Assume x,y & y,x are the same from now on to reduce the number of tests */
3408 VARXOR(BOOL
,VARIANT_TRUE
,I1
,-1,I4
,0);
3409 VARXOR(BOOL
,VARIANT_TRUE
,I1
,0,I4
,-1);
3410 VARXOR(BOOL
,VARIANT_FALSE
,I1
,0,I4
,0);
3411 VARXOR(BOOL
,VARIANT_TRUE
,UI1
,255,I2
,-256);
3412 VARXOR(BOOL
,VARIANT_TRUE
,UI1
,0,I2
,-1);
3413 VARXOR(BOOL
,VARIANT_FALSE
,UI1
,0,I2
,0);
3414 VARXOR(BOOL
,VARIANT_TRUE
,I2
,-1,I2
,0);
3415 VARXOR(BOOL
,VARIANT_TRUE
,I2
,0,I2
,-1);
3416 VARXOR(BOOL
,VARIANT_FALSE
,I2
,0,I2
,0);
3417 VARXOR(BOOL
,VARIANT_TRUE
,UI2
,65535,I4
,-65536);
3418 VARXOR(BOOL
,VARIANT_TRUE
,UI2
,0,I4
,-1);
3419 VARXOR(BOOL
,VARIANT_FALSE
,UI2
,0,I4
,0);
3420 VARXOR(BOOL
,VARIANT_TRUE
,I4
,-1,I4
,0);
3421 VARXOR(BOOL
,VARIANT_TRUE
,I4
,0,I4
,-1);
3422 VARXOR(BOOL
,VARIANT_FALSE
,I4
,0,I4
,0);
3423 VARXOR(BOOL
,VARIANT_TRUE
,UI4
,0xffffffff,I4
,0);
3424 VARXOR(BOOL
,VARIANT_TRUE
,UI4
,0,I4
,-1);
3425 VARXOR(BOOL
,VARIANT_FALSE
,UI4
,0,I4
,0);
3426 VARXOR(BOOL
,VARIANT_TRUE
,R4
,-1,I4
,0);
3427 VARXOR(BOOL
,VARIANT_TRUE
,R4
,0,I4
,-1);
3428 VARXOR(BOOL
,VARIANT_FALSE
,R4
,0,I4
,0);
3429 VARXOR(BOOL
,VARIANT_TRUE
,R8
,-1,I4
,0);
3430 VARXOR(BOOL
,VARIANT_TRUE
,R8
,0,I4
,-1);
3431 VARXOR(BOOL
,VARIANT_FALSE
,R8
,0,I4
,0);
3432 VARXOR(BOOL
,VARIANT_TRUE
,DATE
,-1,I4
,0);
3433 VARXOR(BOOL
,VARIANT_TRUE
,DATE
,0,I4
,-1);
3434 VARXOR(BOOL
,VARIANT_FALSE
,DATE
,0,I4
,0);
3435 if (HAVE_OLEAUT32_I8
)
3437 VARXOR(BOOL
,VARIANT_TRUE
,I8
,-1,I8
,0);
3438 VARXOR(BOOL
,VARIANT_TRUE
,I8
,0,I8
,-1);
3439 VARXOR(BOOL
,VARIANT_FALSE
,I8
,0,I8
,0);
3440 /* This returns DISP_E_OVERFLOW which indicates that a conversion
3441 * to I4 is performed.
3443 /* VARXOR(BOOL,VARIANT_TRUE,UI8,-1,I4,-1); */
3444 VARXOR(BOOL
,VARIANT_TRUE
,UI8
,0,I4
,-1);
3445 VARXOR(BOOL
,VARIANT_FALSE
,UI8
,0,I4
,0);
3447 VARXOR(BOOL
,VARIANT_TRUE
,INT
,-1,I4
,0);
3448 VARXOR(BOOL
,VARIANT_TRUE
,INT
,0,I4
,-1);
3449 VARXOR(BOOL
,VARIANT_FALSE
,INT
,0,I4
,0);
3450 VARXOR(BOOL
,VARIANT_TRUE
,UINT
,0xffffffff,I4
,0);
3451 VARXOR(BOOL
,VARIANT_TRUE
,UINT
,0,I4
,-1);
3452 VARXOR(BOOL
,VARIANT_FALSE
,UINT
,0,I4
,0);
3453 rbstr
= SysAllocString(szFalse
);
3454 VARXOR(BOOL
,VARIANT_FALSE
,BSTR
,rbstr
,BOOL
,VARIANT_FALSE
);
3455 VARXOR(BOOL
,VARIANT_TRUE
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
3456 rbstr
= SysAllocString(szTrue
);
3457 VARXOR(BOOL
,VARIANT_FALSE
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
3458 VARXOR(BOOL
,VARIANT_TRUE
,BSTR
,rbstr
,BOOL
,VARIANT_FALSE
);
3459 VARXORCY(BOOL
,VARIANT_TRUE
,10000,I4
,-2);
3460 VARXORCY(BOOL
,VARIANT_TRUE
,0,I4
,-1);
3461 VARXORCY(BOOL
,VARIANT_FALSE
,0,I4
,0);
3463 VARXOR(I1
,-1,I1
,-1,I4
,0);
3464 VARXOR(I1
,-1,I1
,0,I4
,-1);
3465 VARXOR(I1
,0,I1
,0,I4
,0);
3466 VARXOR(I1
,-1,UI1
,255,I4
,-256);
3467 VARXOR(I1
,-1,UI1
,0,I4
,-1);
3468 VARXOR(I1
,0,UI1
,0,I4
,0);
3469 VARXOR(I1
,-1,I2
,-1,I4
,0);
3470 VARXOR(I1
,-1,I2
,0,I4
,-1);
3471 VARXOR(I1
,0,I2
,0,I4
,0);
3472 VARXOR(I1
,-1,UI2
,65535,I4
,-65536);
3473 VARXOR(I1
,-1,UI2
,0,I4
,-1);
3474 VARXOR(I1
,0,UI2
,0,I4
,0);
3475 VARXOR(I1
,-1,I4
,-1,I4
,0);
3476 VARXOR(I1
,-1,I4
,0,I4
,-1);
3477 VARXOR(I1
,0,I4
,0,I4
,0);
3478 VARXOR(I1
,-1,UI4
,0xffffffff,I4
,0);
3479 VARXOR(I1
,-1,UI4
,0,I4
,-1);
3480 VARXOR(I1
,0,UI4
,0,I4
,0);
3481 VARXOR(I1
,-1,R4
,-1,I4
,0);
3482 VARXOR(I1
,-1,R4
,0,I4
,-1);
3483 VARXOR(I1
,0,R4
,0,I4
,0);
3484 VARXOR(I1
,-1,R8
,-1,I4
,0);
3485 VARXOR(I1
,-1,R8
,0,I4
,-1);
3486 VARXOR(I1
,0,R8
,0,I4
,0);
3487 VARXOR(I1
,-1,DATE
,-1,I4
,0);
3488 VARXOR(I1
,-1,DATE
,0,I4
,-1);
3489 VARXOR(I1
,0,DATE
,0,I4
,0);
3490 if (HAVE_OLEAUT32_I8
)
3492 VARXOR(I1
,-1,I8
,-1,I8
,0);
3493 VARXOR(I1
,-1,I8
,0,I8
,-1);
3494 VARXOR(I1
,0,I8
,0,I8
,0);
3495 VARXOR(I1
,-1,UI8
,0,I4
,-1);
3496 VARXOR(I1
,0,UI8
,0,I4
,0);
3498 VARXOR(I1
,-1,INT
,-1,I4
,0);
3499 VARXOR(I1
,-1,INT
,0,I4
,-1);
3500 VARXOR(I1
,0,INT
,0,I4
,0);
3501 VARXOR(I1
,-1,UINT
,0xffffffff,I4
,0);
3502 VARXOR(I1
,-1,UINT
,0,I4
,-1);
3503 VARXOR(I1
,0,UINT
,0,I4
,0);
3504 rbstr
= SysAllocString(szFalse
);
3505 VARXOR(I1
,0,BSTR
,rbstr
,I4
,0);
3506 VARXOR(I1
,-1,BSTR
,rbstr
,I4
,-1);
3507 rbstr
= SysAllocString(szTrue
);
3508 VARXOR(I1
,0,BSTR
,rbstr
,I4
,-1);
3509 VARXOR(I1
,-1,BSTR
,rbstr
,I4
,0);
3510 VARXORCY(I1
,-1,10000,I4
,-2);
3511 VARXORCY(I1
,-1,0,I4
,-1);
3512 VARXORCY(I1
,0,0,I4
,0);
3514 VARXOR(UI1
,255,UI1
,255,UI1
,0);
3515 VARXOR(UI1
,255,UI1
,0,UI1
,255);
3516 VARXOR(UI1
,0,UI1
,0,UI1
,0);
3517 VARXOR(UI1
,255,I2
,-1,I2
,-256);
3518 VARXOR(UI1
,255,I2
,0,I2
,255);
3519 VARXOR(UI1
,0,I2
,0,I2
,0);
3520 VARXOR(UI1
,255,UI2
,65535,I4
,65280);
3521 VARXOR(UI1
,255,UI2
,0,I4
,255);
3522 VARXOR(UI1
,0,UI2
,0,I4
,0);
3523 VARXOR(UI1
,255,I4
,-1,I4
,-256);
3524 VARXOR(UI1
,255,I4
,0,I4
,255);
3525 VARXOR(UI1
,0,I4
,0,I4
,0);
3526 VARXOR(UI1
,255,UI4
,0xffffffff,I4
,-256);
3527 VARXOR(UI1
,255,UI4
,0,I4
,255);
3528 VARXOR(UI1
,0,UI4
,0,I4
,0);
3529 VARXOR(UI1
,255,R4
,-1,I4
,-256);
3530 VARXOR(UI1
,255,R4
,0,I4
,255);
3531 VARXOR(UI1
,0,R4
,0,I4
,0);
3532 VARXOR(UI1
,255,R8
,-1,I4
,-256);
3533 VARXOR(UI1
,255,R8
,0,I4
,255);
3534 VARXOR(UI1
,0,R8
,0,I4
,0);
3535 VARXOR(UI1
,255,DATE
,-1,I4
,-256);
3536 VARXOR(UI1
,255,DATE
,0,I4
,255);
3537 VARXOR(UI1
,0,DATE
,0,I4
,0);
3538 if (HAVE_OLEAUT32_I8
)
3540 VARXOR(UI1
,255,I8
,-1,I8
,-256);
3541 VARXOR(UI1
,255,I8
,0,I8
,255);
3542 VARXOR(UI1
,0,I8
,0,I8
,0);
3543 VARXOR(UI1
,255,UI8
,0,I4
,255);
3544 VARXOR(UI1
,0,UI8
,0,I4
,0);
3546 VARXOR(UI1
,255,INT
,-1,I4
,-256);
3547 VARXOR(UI1
,255,INT
,0,I4
,255);
3548 VARXOR(UI1
,0,INT
,0,I4
,0);
3549 VARXOR(UI1
,255,UINT
,0xffffffff,I4
,-256);
3550 VARXOR(UI1
,255,UINT
,0,I4
,255);
3551 VARXOR(UI1
,0,UINT
,0,I4
,0);
3552 rbstr
= SysAllocString(szFalse
);
3553 VARXOR(UI1
,0,BSTR
,rbstr
,I2
,0);
3554 VARXOR(UI1
,255,BSTR
,rbstr
,I2
,255);
3555 rbstr
= SysAllocString(szTrue
);
3556 VARXOR(UI1
,0,BSTR
,rbstr
,I2
,-1);
3557 VARXOR(UI1
,255,BSTR
,rbstr
,I2
,-256);
3558 VARXORCY(UI1
,255,10000,I4
,254);
3559 VARXORCY(UI1
,255,0,I4
,255);
3560 VARXORCY(UI1
,0,0,I4
,0);
3562 VARXOR(I2
,-1,I2
,-1,I2
,0);
3563 VARXOR(I2
,-1,I2
,0,I2
,-1);
3564 VARXOR(I2
,0,I2
,0,I2
,0);
3565 VARXOR(I2
,-1,UI2
,65535,I4
,-65536);
3566 VARXOR(I2
,-1,UI2
,0,I4
,-1);
3567 VARXOR(I2
,0,UI2
,0,I4
,0);
3568 VARXOR(I2
,-1,I4
,-1,I4
,0);
3569 VARXOR(I2
,-1,I4
,0,I4
,-1);
3570 VARXOR(I2
,0,I4
,0,I4
,0);
3571 VARXOR(I2
,-1,UI4
,0xffffffff,I4
,0);
3572 VARXOR(I2
,-1,UI4
,0,I4
,-1);
3573 VARXOR(I2
,0,UI4
,0,I4
,0);
3574 VARXOR(I2
,-1,R4
,-1,I4
,0);
3575 VARXOR(I2
,-1,R4
,0,I4
,-1);
3576 VARXOR(I2
,0,R4
,0,I4
,0);
3577 VARXOR(I2
,-1,R8
,-1,I4
,0);
3578 VARXOR(I2
,-1,R8
,0,I4
,-1);
3579 VARXOR(I2
,0,R8
,0,I4
,0);
3580 VARXOR(I2
,-1,DATE
,-1,I4
,0);
3581 VARXOR(I2
,-1,DATE
,0,I4
,-1);
3582 VARXOR(I2
,0,DATE
,0,I4
,0);
3583 if (HAVE_OLEAUT32_I8
)
3585 VARXOR(I2
,-1,I8
,-1,I8
,0);
3586 VARXOR(I2
,-1,I8
,0,I8
,-1);
3587 VARXOR(I2
,0,I8
,0,I8
,0);
3588 VARXOR(I2
,-1,UI8
,0,I4
,-1);
3589 VARXOR(I2
,0,UI8
,0,I4
,0);
3591 VARXOR(I2
,-1,INT
,-1,I4
,0);
3592 VARXOR(I2
,-1,INT
,0,I4
,-1);
3593 VARXOR(I2
,0,INT
,0,I4
,0);
3594 VARXOR(I2
,-1,UINT
,0xffffffff,I4
,0);
3595 VARXOR(I2
,-1,UINT
,0,I4
,-1);
3596 VARXOR(I2
,0,UINT
,0,I4
,0);
3597 rbstr
= SysAllocString(szFalse
);
3598 VARXOR(I2
,0,BSTR
,rbstr
,I2
,0);
3599 VARXOR(I2
,-1,BSTR
,rbstr
,I2
,-1);
3600 rbstr
= SysAllocString(szTrue
);
3601 VARXOR(I2
,0,BSTR
,rbstr
,I2
,-1);
3602 VARXOR(I2
,-1,BSTR
,rbstr
,I2
,0);
3603 VARXORCY(I2
,-1,10000,I4
,-2);
3604 VARXORCY(I2
,-1,0,I4
,-1);
3605 VARXORCY(I2
,0,0,I4
,0);
3607 VARXOR(UI2
,65535,UI2
,65535,I4
,0);
3608 VARXOR(UI2
,65535,UI2
,0,I4
,65535);
3609 VARXOR(UI2
,0,UI2
,0,I4
,0);
3610 VARXOR(UI2
,65535,I4
,-1,I4
,-65536);
3611 VARXOR(UI2
,65535,I4
,0,I4
,65535);
3612 VARXOR(UI2
,0,I4
,0,I4
,0);
3613 VARXOR(UI2
,65535,UI4
,0xffffffff,I4
,-65536);
3614 VARXOR(UI2
,65535,UI4
,0,I4
,65535);
3615 VARXOR(UI2
,0,UI4
,0,I4
,0);
3616 VARXOR(UI2
,65535,R4
,-1,I4
,-65536);
3617 VARXOR(UI2
,65535,R4
,0,I4
,65535);
3618 VARXOR(UI2
,0,R4
,0,I4
,0);
3619 VARXOR(UI2
,65535,R8
,-1,I4
,-65536);
3620 VARXOR(UI2
,65535,R8
,0,I4
,65535);
3621 VARXOR(UI2
,0,R8
,0,I4
,0);
3622 VARXOR(UI2
,65535,DATE
,-1,I4
,-65536);
3623 VARXOR(UI2
,65535,DATE
,0,I4
,65535);
3624 VARXOR(UI2
,0,DATE
,0,I4
,0);
3625 if (HAVE_OLEAUT32_I8
)
3627 VARXOR(UI2
,65535,I8
,-1,I8
,-65536);
3628 VARXOR(UI2
,65535,I8
,0,I8
,65535);
3629 VARXOR(UI2
,0,I8
,0,I8
,0);
3630 VARXOR(UI2
,65535,UI8
,0,I4
,65535);
3631 VARXOR(UI2
,0,UI8
,0,I4
,0);
3633 VARXOR(UI2
,65535,INT
,-1,I4
,-65536);
3634 VARXOR(UI2
,65535,INT
,0,I4
,65535);
3635 VARXOR(UI2
,0,INT
,0,I4
,0);
3636 VARXOR(UI2
,65535,UINT
,0xffffffff,I4
,-65536);
3637 VARXOR(UI2
,65535,UINT
,0,I4
,65535);
3638 VARXOR(UI2
,0,UINT
,0,I4
,0);
3639 rbstr
= SysAllocString(szFalse
);
3640 VARXOR(UI2
,0,BSTR
,rbstr
,I4
,0);
3641 VARXOR(UI2
,65535,BSTR
,rbstr
,I4
,65535);
3642 rbstr
= SysAllocString(szTrue
);
3643 VARXOR(UI2
,0,BSTR
,rbstr
,I4
,-1);
3644 VARXOR(UI2
,65535,BSTR
,rbstr
,I4
,-65536);
3645 VARXORCY(UI2
,65535,10000,I4
,65534);
3646 VARXORCY(UI2
,65535,0,I4
,65535);
3647 VARXORCY(UI2
,0,0,I4
,0);
3649 VARXOR(I4
,-1,I4
,-1,I4
,0);
3650 VARXOR(I4
,-1,I4
,0,I4
,-1);
3651 VARXOR(I4
,0,I4
,0,I4
,0);
3652 VARXOR(I4
,-1,UI4
,0xffffffff,I4
,0);
3653 VARXOR(I4
,-1,UI4
,0,I4
,-1);
3654 VARXOR(I4
,0,UI4
,0,I4
,0);
3655 VARXOR(I4
,-1,R4
,-1,I4
,0);
3656 VARXOR(I4
,-1,R4
,0,I4
,-1);
3657 VARXOR(I4
,0,R4
,0,I4
,0);
3658 VARXOR(I4
,-1,R8
,-1,I4
,0);
3659 VARXOR(I4
,-1,R8
,0,I4
,-1);
3660 VARXOR(I4
,0,R8
,0,I4
,0);
3661 VARXOR(I4
,-1,DATE
,-1,I4
,0);
3662 VARXOR(I4
,-1,DATE
,0,I4
,-1);
3663 VARXOR(I4
,0,DATE
,0,I4
,0);
3664 if (HAVE_OLEAUT32_I8
)
3666 VARXOR(I4
,-1,I8
,-1,I8
,0);
3667 VARXOR(I4
,-1,I8
,0,I8
,-1);
3668 VARXOR(I4
,0,I8
,0,I8
,0);
3669 VARXOR(I4
,-1,UI8
,0,I4
,-1);
3670 VARXOR(I4
,0,UI8
,0,I4
,0);
3672 VARXOR(I4
,-1,INT
,-1,I4
,0);
3673 VARXOR(I4
,-1,INT
,0,I4
,-1);
3674 VARXOR(I4
,0,INT
,0,I4
,0);
3675 VARXOR(I4
,-1,UINT
,0xffffffff,I4
,0);
3676 VARXOR(I4
,-1,UINT
,0,I4
,-1);
3677 VARXOR(I4
,0,UINT
,0,I4
,0);
3678 rbstr
= SysAllocString(szFalse
);
3679 VARXOR(I4
,0,BSTR
,rbstr
,I4
,0);
3680 VARXOR(I4
,-1,BSTR
,rbstr
,I4
,-1);
3681 rbstr
= SysAllocString(szTrue
);
3682 VARXOR(I4
,0,BSTR
,rbstr
,I4
,-1);
3683 VARXOR(I4
,-1,BSTR
,rbstr
,I4
,0);
3684 VARXORCY(I4
,-1,10000,I4
,-2);
3685 VARXORCY(I4
,-1,0,I4
,-1);
3686 VARXORCY(I4
,0,0,I4
,0);
3688 VARXOR(UI4
,0xffffffff,UI4
,0xffffffff,I4
,0);
3689 VARXOR(UI4
,0xffffffff,UI4
,0,I4
,-1);
3690 VARXOR(UI4
,0,UI4
,0,I4
,0);
3691 VARXOR(UI4
,0xffffffff,R4
,-1,I4
,0);
3692 VARXOR(UI4
,0xffffffff,R4
,0,I4
,-1);
3693 VARXOR(UI4
,0,R4
,0,I4
,0);
3694 VARXOR(UI4
,0xffffffff,R8
,-1,I4
,0);
3695 VARXOR(UI4
,0xffffffff,R8
,0,I4
,-1);
3696 VARXOR(UI4
,0,R8
,0,I4
,0);
3697 VARXOR(UI4
,0xffffffff,DATE
,-1,I4
,0);
3698 VARXOR(UI4
,0xffffffff,DATE
,0,I4
,-1);
3699 VARXOR(UI4
,0,DATE
,0,I4
,0);
3700 if (HAVE_OLEAUT32_I8
)
3702 VARXOR(UI4
,0xffffffff,I8
,0,I8
,0xffffffff);
3703 VARXOR(UI4
,VARIANT_FALSE
,I8
,VARIANT_FALSE
,I8
,0);
3704 VARXOR(UI4
,0,I8
,0,I8
,0);
3705 VARXOR(UI4
,0xffffffff,UI8
,0,I4
,-1);
3706 VARXOR(UI4
,0,UI8
,0,I4
,0);
3708 VARXOR(UI4
,0xffffffff,INT
,-1,I4
,0);
3709 VARXOR(UI4
,0xffffffff,INT
,0,I4
,-1);
3710 VARXOR(UI4
,0,INT
,0,I4
,0);
3711 VARXOR(UI4
,0xffffffff,UINT
,0xffffffff,I4
,0);
3712 VARXOR(UI4
,0xffffffff,UINT
,0,I4
,-1);
3713 VARXOR(UI4
,0,UINT
,0,I4
,0);
3714 rbstr
= SysAllocString(szFalse
);
3715 VARXOR(UI4
,0,BSTR
,rbstr
,I4
,0);
3716 VARXOR(UI4
,0xffffffff,BSTR
,rbstr
,I4
,-1);
3717 rbstr
= SysAllocString(szTrue
);
3718 VARXOR(UI4
,0,BSTR
,rbstr
,I4
,-1);
3719 VARXOR(UI4
,0xffffffff,BSTR
,rbstr
,I4
,0);
3720 VARXORCY(UI4
,0xffffffff,10000,I4
,-2);
3721 VARXORCY(UI4
,0xffffffff,0,I4
,-1);
3722 VARXORCY(UI4
,0,0,I4
,0);
3724 VARXOR(R4
,-1,R4
,-1,I4
,0);
3725 VARXOR(R4
,-1,R4
,0,I4
,-1);
3726 VARXOR(R4
,0,R4
,0,I4
,0);
3727 VARXOR(R4
,-1,R8
,-1,I4
,0);
3728 VARXOR(R4
,-1,R8
,0,I4
,-1);
3729 VARXOR(R4
,0,R8
,0,I4
,0);
3730 VARXOR(R4
,-1,DATE
,-1,I4
,0);
3731 VARXOR(R4
,-1,DATE
,0,I4
,-1);
3732 VARXOR(R4
,0,DATE
,0,I4
,0);
3733 if (HAVE_OLEAUT32_I8
)
3735 VARXOR(R4
,-1,I8
,-1,I8
,0);
3736 VARXOR(R4
,-1,I8
,0,I8
,-1);
3737 VARXOR(R4
,0,I8
,0,I8
,0);
3738 VARXOR(R4
,-1,UI8
,0,I4
,-1);
3739 VARXOR(R4
,0,UI8
,0,I4
,0);
3741 VARXOR(R4
,-1,INT
,-1,I4
,0);
3742 VARXOR(R4
,-1,INT
,0,I4
,-1);
3743 VARXOR(R4
,0,INT
,0,I4
,0);
3744 VARXOR(R4
,-1,UINT
,0xffffffff,I4
,0);
3745 VARXOR(R4
,-1,UINT
,0,I4
,-1);
3746 VARXOR(R4
,0,UINT
,0,I4
,0);
3747 rbstr
= SysAllocString(szFalse
);
3748 VARXOR(R4
,0,BSTR
,rbstr
,I4
,0);
3749 VARXOR(R4
,-1,BSTR
,rbstr
,I4
,-1);
3750 rbstr
= SysAllocString(szTrue
);
3751 VARXOR(R4
,0,BSTR
,rbstr
,I4
,-1);
3752 VARXOR(R4
,-1,BSTR
,rbstr
,I4
,0);
3753 VARXORCY(R4
,-1,10000,I4
,-2);
3754 VARXORCY(R4
,-1,0,I4
,-1);
3755 VARXORCY(R4
,0,0,I4
,0);
3757 VARXOR(R8
,-1,R8
,-1,I4
,0);
3758 VARXOR(R8
,-1,R8
,0,I4
,-1);
3759 VARXOR(R8
,0,R8
,0,I4
,0);
3760 VARXOR(R8
,-1,DATE
,-1,I4
,0);
3761 VARXOR(R8
,-1,DATE
,0,I4
,-1);
3762 VARXOR(R8
,0,DATE
,0,I4
,0);
3763 if (HAVE_OLEAUT32_I8
)
3765 VARXOR(R8
,-1,I8
,-1,I8
,0);
3766 VARXOR(R8
,-1,I8
,0,I8
,-1);
3767 VARXOR(R8
,0,I8
,0,I8
,0);
3768 VARXOR(R8
,-1,UI8
,0,I4
,-1);
3769 VARXOR(R8
,0,UI8
,0,I4
,0);
3771 VARXOR(R8
,-1,INT
,-1,I4
,0);
3772 VARXOR(R8
,-1,INT
,0,I4
,-1);
3773 VARXOR(R8
,0,INT
,0,I4
,0);
3774 VARXOR(R8
,-1,UINT
,0xffffffff,I4
,0);
3775 VARXOR(R8
,-1,UINT
,0,I4
,-1);
3776 VARXOR(R8
,0,UINT
,0,I4
,0);
3777 rbstr
= SysAllocString(szFalse
);
3778 VARXOR(R8
,0,BSTR
,rbstr
,I4
,0);
3779 VARXOR(R8
,-1,BSTR
,rbstr
,I4
,-1);
3780 rbstr
= SysAllocString(szTrue
);
3781 VARXOR(R8
,0,BSTR
,rbstr
,I4
,-1);
3782 VARXOR(R8
,-1,BSTR
,rbstr
,I4
,0);
3783 VARXORCY(R8
,-1,10000,I4
,-2);
3784 VARXORCY(R8
,-1,0,I4
,-1);
3785 VARXORCY(R8
,0,0,I4
,0);
3787 VARXOR(DATE
,-1,DATE
,-1,I4
,0);
3788 VARXOR(DATE
,-1,DATE
,0,I4
,-1);
3789 VARXOR(DATE
,0,DATE
,0,I4
,0);
3790 if (HAVE_OLEAUT32_I8
)
3792 VARXOR(DATE
,-1,I8
,-1,I8
,0);
3793 VARXOR(DATE
,-1,I8
,0,I8
,-1);
3794 VARXOR(DATE
,0,I8
,0,I8
,0);
3795 VARXOR(DATE
,-1,UI8
,0,I4
,-1);
3796 VARXOR(DATE
,0,UI8
,0,I4
,0);
3798 VARXOR(DATE
,-1,INT
,-1,I4
,0);
3799 VARXOR(DATE
,-1,INT
,0,I4
,-1);
3800 VARXOR(DATE
,0,INT
,0,I4
,0);
3801 VARXOR(DATE
,-1,UINT
,0xffffffff,I4
,0);
3802 VARXOR(DATE
,-1,UINT
,0,I4
,-1);
3803 VARXOR(DATE
,0,UINT
,0,I4
,0);
3804 rbstr
= SysAllocString(szFalse
);
3805 VARXOR(DATE
,0,BSTR
,rbstr
,I4
,0);
3806 VARXOR(DATE
,-1,BSTR
,rbstr
,I4
,-1);
3807 rbstr
= SysAllocString(szTrue
);
3808 VARXOR(DATE
,0,BSTR
,rbstr
,I4
,-1);
3809 VARXOR(DATE
,-1,BSTR
,rbstr
,I4
,0);
3810 VARXORCY(DATE
,-1,10000,I4
,-2);
3811 VARXORCY(DATE
,-1,0,I4
,-1);
3812 VARXORCY(DATE
,0,0,I4
,0);
3814 if (HAVE_OLEAUT32_I8
)
3816 VARXOR(I8
,-1,I8
,-1,I8
,0);
3817 VARXOR(I8
,-1,I8
,0,I8
,-1);
3818 VARXOR(I8
,0,I8
,0,I8
,0);
3819 VARXOR(I8
,-1,UI8
,0,I8
,-1);
3820 VARXOR(I8
,0,UI8
,0,I8
,0);
3821 VARXOR(I8
,-1,UINT
,0,I8
,-1);
3822 VARXOR(I8
,0,UINT
,0,I8
,0);
3823 rbstr
= SysAllocString(szFalse
);
3824 VARXOR(I8
,0,BSTR
,rbstr
,I8
,0);
3825 VARXOR(I8
,-1,BSTR
,rbstr
,I8
,-1);
3826 rbstr
= SysAllocString(szTrue
);
3827 VARXOR(I8
,0,BSTR
,rbstr
,I8
,-1);
3828 VARXOR(I8
,-1,BSTR
,rbstr
,I8
,0);
3829 VARXORCY(I8
,-1,10000,I8
,-2);
3830 VARXORCY(I8
,-1,0,I8
,-1);
3831 VARXORCY(I8
,0,0,I8
,0);
3833 VARXOR(UI8
,0xffff,UI8
,0xffff,I4
,0);
3834 VARXOR(UI8
,0xffff,UI8
,0,I4
,0xffff);
3835 VARXOR(UI8
,0,UI8
,0,I4
,0);
3836 VARXOR(UI8
,0xffff,INT
,-1,I4
,-65536);
3837 VARXOR(UI8
,0xffff,INT
,0,I4
,0xffff);
3838 VARXOR(UI8
,0,INT
,0,I4
,0);
3839 VARXOR(UI8
,0xffff,UINT
,0xffff,I4
,0);
3840 VARXOR(UI8
,0xffff,UINT
,0,I4
,0xffff);
3841 VARXOR(UI8
,0,UINT
,0,I4
,0);
3842 rbstr
= SysAllocString(szFalse
);
3843 VARXOR(UI8
,0,BSTR
,rbstr
,I4
,0);
3844 VARXOR(UI8
,0xffff,BSTR
,rbstr
,I4
,0xffff);
3845 rbstr
= SysAllocString(szTrue
);
3846 VARXOR(UI8
,0,BSTR
,rbstr
,I4
,-1);
3847 VARXOR(UI8
,0xffff,BSTR
,rbstr
,I4
,-65536);
3848 VARXORCY(UI8
,0xffff,10000,I4
,65534);
3849 VARXORCY(UI8
,0xffff,0,I4
,0xffff);
3850 VARXORCY(UI8
,0,0,I4
,0);
3853 VARXOR(INT
,-1,INT
,-1,I4
,0);
3854 VARXOR(INT
,-1,INT
,0,I4
,-1);
3855 VARXOR(INT
,0,INT
,0,I4
,0);
3856 VARXOR(INT
,-1,UINT
,0xffff,I4
,-65536);
3857 VARXOR(INT
,-1,UINT
,0,I4
,-1);
3858 VARXOR(INT
,0,UINT
,0,I4
,0);
3859 rbstr
= SysAllocString(szFalse
);
3860 VARXOR(INT
,0,BSTR
,rbstr
,I4
,0);
3861 VARXOR(INT
,-1,BSTR
,rbstr
,I4
,-1);
3862 rbstr
= SysAllocString(szTrue
);
3863 VARXOR(INT
,0,BSTR
,rbstr
,I4
,-1);
3864 VARXOR(INT
,-1,BSTR
,rbstr
,I4
,0);
3865 VARXORCY(INT
,-1,10000,I4
,-2);
3866 VARXORCY(INT
,-1,0,I4
,-1);
3867 VARXORCY(INT
,0,0,I4
,0);
3869 VARXOR(UINT
,0xffff,UINT
,0xffff,I4
,0);
3870 VARXOR(UINT
,0xffff,UINT
,0,I4
,0xffff);
3871 VARXOR(UINT
,0,UINT
,0,I4
,0);
3872 rbstr
= SysAllocString(szFalse
);
3873 VARXOR(UINT
,0,BSTR
,rbstr
,I4
,0);
3874 VARXOR(UINT
,0xffff,BSTR
,rbstr
,I4
,0xffff);
3875 rbstr
= SysAllocString(szTrue
);
3876 VARXOR(UINT
,0,BSTR
,rbstr
,I4
,-1);
3877 VARXOR(UINT
,0xffff,BSTR
,rbstr
,I4
,-65536);
3878 VARXORCY(UINT
,0xffff,10000,I4
,65534);
3879 VARXORCY(UINT
,0xffff,0,I4
,0xffff);
3880 VARXORCY(UINT
,0,0,I4
,0);
3882 lbstr
= SysAllocString(szFalse
);
3883 rbstr
= SysAllocString(szFalse
);
3884 VARXOR(BSTR
,lbstr
,BSTR
,rbstr
,BOOL
,0);
3885 rbstr
= SysAllocString(szTrue
);
3886 VARXOR(BSTR
,lbstr
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
3887 lbstr
= SysAllocString(szTrue
);
3888 VARXOR(BSTR
,lbstr
,BSTR
,rbstr
,BOOL
,VARIANT_FALSE
);
3889 VARXORCY(BSTR
,lbstr
,10000,I4
,-2);
3890 lbstr
= SysAllocString(szFalse
);
3891 VARXORCY(BSTR
,lbstr
,10000,I4
,1);
3894 static HRESULT (WINAPI
*pVarOr
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
3896 #define VAROR(vt1,val1,vt2,val2,rvt,rval) \
3897 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
3898 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
3899 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
3900 test_var_call2( __LINE__, pVarOr, &left, &right, &exp )
3902 #define VARORCY(vt1,val1,val2,rvt,rval) \
3903 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
3904 V_VT(&right) = VT_CY; V_CY(&right).int64 = val2; \
3905 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
3906 test_var_call2( __LINE__, pVarOr, &left, &right, &exp )
3908 static void test_VarOr(void)
3910 static const WCHAR szFalse
[] = { '#','F','A','L','S','E','#','\0' };
3911 static const WCHAR szTrue
[] = { '#','T','R','U','E','#','\0' };
3912 VARIANT left
, right
, exp
, result
;
3919 /* Test all possible flag/vt combinations & the resulting vt type */
3920 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
3922 VARTYPE leftvt
, rightvt
, resvt
;
3924 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
3929 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
3935 if (leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
||
3936 leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
||
3937 leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
)
3940 memset(&left
, 0, sizeof(left
));
3941 memset(&right
, 0, sizeof(right
));
3942 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
3943 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
3944 V_VT(&result
) = VT_EMPTY
;
3947 if (ExtraFlags
[i
] & VT_ARRAY
|| ExtraFlags
[i
] & VT_BYREF
||
3948 !IsValidVariantClearVT(leftvt
, ExtraFlags
[i
]) ||
3949 !IsValidVariantClearVT(rightvt
, ExtraFlags
[i
]) ||
3950 leftvt
== VT_CLSID
|| rightvt
== VT_CLSID
||
3951 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
||
3952 leftvt
== VT_VARIANT
|| rightvt
== VT_VARIANT
||
3953 leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
)
3957 if (leftvt
== VT_EMPTY
|| rightvt
== VT_EMPTY
)
3959 if (leftvt
== rightvt
||
3960 leftvt
== VT_I2
|| rightvt
== VT_I2
||
3961 leftvt
== VT_UI1
|| rightvt
== VT_UI1
||
3962 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
3964 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
3966 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
3969 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
3973 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
3975 if (leftvt
== rightvt
)
3977 else if (leftvt
== rightvt
||
3978 leftvt
== VT_I2
|| rightvt
== VT_I2
||
3979 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
3983 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
3986 else if (leftvt
== VT_I2
|| rightvt
== VT_I2
)
3988 if (leftvt
== rightvt
||
3989 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
3991 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
3994 else if (leftvt
== VT_BOOL
&& rightvt
== VT_BOOL
)
3998 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
4000 if (leftvt
== VT_INT
|| rightvt
== VT_INT
)
4005 hres
= pVarOr(&left
, &right
, &result
);
4007 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
4008 "VarOr: %d|0x%X, %d|0x%X: Expected failure, got 0x%X vt %d\n",
4009 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], hres
,
4012 ok(hres
== S_OK
&& V_VT(&result
) == resvt
,
4013 "VarOr: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%X vt %d\n",
4014 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], resvt
, hres
,
4020 /* Test returned values. Since we know the returned type is correct
4021 * and that we handle all combinations of invalid types, just check
4022 * that good type combinations produce the desired value.
4023 * FIXME: Test VT_DECIMAL/VT_DISPATCH
4025 VAROR(EMPTY
,0,EMPTY
,0,I2
,0);
4026 VAROR(EMPTY
,1,EMPTY
,0,I2
,0);
4027 VAROR(EMPTY
,0,NULL
,0,NULL
,0);
4028 VAROR(EMPTY
,0,I1
,0,I4
,0);
4029 VAROR(EMPTY
,0,I1
,1,I4
,1);
4030 VAROR(EMPTY
,0,UI1
,0,I2
,0);
4031 VAROR(EMPTY
,0,UI1
,1,I2
,1);
4032 VAROR(EMPTY
,0,I2
,0,I2
,0);
4033 VAROR(EMPTY
,0,I2
,1,I2
,1);
4034 VAROR(EMPTY
,0,UI2
,0,I4
,0);
4035 VAROR(EMPTY
,0,UI2
,1,I4
,1);
4036 VAROR(EMPTY
,0,I4
,0,I4
,0);
4037 VAROR(EMPTY
,0,I4
,1,I4
,1);
4038 VAROR(EMPTY
,0,UI4
,0,I4
,0);
4039 VAROR(EMPTY
,0,UI4
,1,I4
,1);
4040 if (HAVE_OLEAUT32_I8
)
4042 VAROR(EMPTY
,0,I8
,0,I8
,0);
4043 VAROR(EMPTY
,0,I8
,1,I8
,1);
4044 VAROR(EMPTY
,0,UI8
,0,I4
,0);
4045 VAROR(EMPTY
,0,UI8
,1,I4
,1);
4047 VAROR(EMPTY
,0,INT
,0,I4
,0);
4048 VAROR(EMPTY
,0,INT
,1,I4
,1);
4049 VAROR(EMPTY
,0,UINT
,0,I4
,0);
4050 VAROR(EMPTY
,0,UINT
,1,I4
,1);
4051 VAROR(EMPTY
,0,BOOL
,0,I2
,0);
4052 VAROR(EMPTY
,0,BOOL
,1,I2
,1);
4053 VAROR(EMPTY
,0,R4
,0,I4
,0);
4054 VAROR(EMPTY
,0,R4
,1,I4
,1);
4055 VAROR(EMPTY
,0,R8
,0,I4
,0);
4056 VAROR(EMPTY
,0,R8
,1,I4
,1);
4057 rbstr
= SysAllocString(szFalse
);
4058 VAROR(EMPTY
,0,BSTR
,rbstr
,I2
,0);
4059 rbstr
= SysAllocString(szTrue
);
4060 VAROR(EMPTY
,0,BSTR
,rbstr
,I2
,-1);
4061 VARORCY(EMPTY
,0,10000,I4
,1);
4063 /* NULL OR 0 = NULL. NULL OR n = n */
4064 VAROR(NULL
,0,NULL
,0,NULL
,0);
4065 VAROR(NULL
,1,NULL
,0,NULL
,0);
4066 VAROR(NULL
,0,I1
,0,NULL
,0);
4067 VAROR(NULL
,0,I1
,1,I4
,1);
4068 VAROR(NULL
,0,UI1
,0,NULL
,0);
4069 VAROR(NULL
,0,UI1
,1,UI1
,1);
4070 VAROR(NULL
,0,I2
,0,NULL
,0);
4071 VAROR(NULL
,0,I2
,1,I2
,1);
4072 VAROR(NULL
,0,UI2
,0,NULL
,0);
4073 VAROR(NULL
,0,UI2
,1,I4
,1);
4074 VAROR(NULL
,0,I4
,0,NULL
,0);
4075 VAROR(NULL
,0,I4
,1,I4
,1);
4076 VAROR(NULL
,0,UI4
,0,NULL
,0);
4077 VAROR(NULL
,0,UI4
,1,I4
,1);
4078 if (HAVE_OLEAUT32_I8
)
4080 VAROR(NULL
,0,I8
,0,NULL
,0);
4081 VAROR(NULL
,0,I8
,1,I8
,1);
4082 VAROR(NULL
,0,UI8
,0,NULL
,0);
4083 VAROR(NULL
,0,UI8
,1,I4
,1);
4085 VAROR(NULL
,0,INT
,0,NULL
,0);
4086 VAROR(NULL
,0,INT
,1,I4
,1);
4087 VAROR(NULL
,0,UINT
,0,NULL
,0);
4088 VAROR(NULL
,0,UINT
,1,I4
,1);
4089 VAROR(NULL
,0,BOOL
,0,NULL
,0);
4090 VAROR(NULL
,0,BOOL
,1,BOOL
,1);
4091 VAROR(NULL
,0,R4
,0,NULL
,0);
4092 VAROR(NULL
,0,R4
,1,I4
,1);
4093 VAROR(NULL
,0,R8
,0,NULL
,0);
4094 VAROR(NULL
,0,R8
,1,I4
,1);
4095 rbstr
= SysAllocString(szFalse
);
4096 VAROR(NULL
,0,BSTR
,rbstr
,NULL
,0);
4097 rbstr
= SysAllocString(szTrue
);
4098 VAROR(NULL
,0,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
4099 VARORCY(NULL
,0,10000,I4
,1);
4100 VARORCY(NULL
,0,0,NULL
,0);
4102 VAROR(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
);
4103 VAROR(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
);
4104 VAROR(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
);
4105 VAROR(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_FALSE
);
4106 /* Assume x,y & y,x are the same from now on to reduce the number of tests */
4107 VAROR(BOOL
,VARIANT_TRUE
,I1
,-1,I4
,-1);
4108 VAROR(BOOL
,VARIANT_TRUE
,I1
,0,I4
,-1);
4109 VAROR(BOOL
,VARIANT_FALSE
,I1
,0,I4
,0);
4110 VAROR(BOOL
,VARIANT_TRUE
,UI1
,255,I2
,-1);
4111 VAROR(BOOL
,VARIANT_TRUE
,UI1
,0,I2
,-1);
4112 VAROR(BOOL
,VARIANT_FALSE
,UI1
,0,I2
,0);
4113 VAROR(BOOL
,VARIANT_TRUE
,I2
,-1,I2
,-1);
4114 VAROR(BOOL
,VARIANT_TRUE
,I2
,0,I2
,-1);
4115 VAROR(BOOL
,VARIANT_FALSE
,I2
,0,I2
,0);
4116 VAROR(BOOL
,VARIANT_TRUE
,UI2
,65535,I4
,-1);
4117 VAROR(BOOL
,VARIANT_TRUE
,UI2
,0,I4
,-1);
4118 VAROR(BOOL
,VARIANT_FALSE
,UI2
,0,I4
,0);
4119 VAROR(BOOL
,VARIANT_TRUE
,I4
,-1,I4
,-1);
4120 VAROR(BOOL
,VARIANT_TRUE
,I4
,0,I4
,-1);
4121 VAROR(BOOL
,VARIANT_FALSE
,I4
,0,I4
,0);
4122 VAROR(BOOL
,VARIANT_TRUE
,UI4
,0xffffffff,I4
,-1);
4123 VAROR(BOOL
,VARIANT_TRUE
,UI4
,0,I4
,-1);
4124 VAROR(BOOL
,VARIANT_FALSE
,UI4
,0,I4
,0);
4125 VAROR(BOOL
,VARIANT_TRUE
,R4
,-1,I4
,-1);
4126 VAROR(BOOL
,VARIANT_TRUE
,R4
,0,I4
,-1);
4127 VAROR(BOOL
,VARIANT_FALSE
,R4
,0,I4
,0);
4128 VAROR(BOOL
,VARIANT_TRUE
,R8
,-1,I4
,-1);
4129 VAROR(BOOL
,VARIANT_TRUE
,R8
,0,I4
,-1);
4130 VAROR(BOOL
,VARIANT_FALSE
,R8
,0,I4
,0);
4131 VAROR(BOOL
,VARIANT_TRUE
,DATE
,-1,I4
,-1);
4132 VAROR(BOOL
,VARIANT_TRUE
,DATE
,0,I4
,-1);
4133 VAROR(BOOL
,VARIANT_FALSE
,DATE
,0,I4
,0);
4134 if (HAVE_OLEAUT32_I8
)
4136 VAROR(BOOL
,VARIANT_TRUE
,I8
,-1,I8
,-1);
4137 VAROR(BOOL
,VARIANT_TRUE
,I8
,0,I8
,-1);
4138 VAROR(BOOL
,VARIANT_FALSE
,I8
,0,I8
,0);
4139 /* This returns DISP_E_OVERFLOW which indicates that a conversion
4140 * to I4 is performed.
4142 /* VAROR(BOOL,VARIANT_TRUE,UI8,-1,I4,-1); */
4143 VAROR(BOOL
,VARIANT_TRUE
,UI8
,0,I4
,-1);
4144 VAROR(BOOL
,VARIANT_FALSE
,UI8
,0,I4
,0);
4146 VAROR(BOOL
,VARIANT_TRUE
,INT
,-1,I4
,-1);
4147 VAROR(BOOL
,VARIANT_TRUE
,INT
,0,I4
,-1);
4148 VAROR(BOOL
,VARIANT_FALSE
,INT
,0,I4
,0);
4149 VAROR(BOOL
,VARIANT_TRUE
,UINT
,0xffffffff,I4
,-1);
4150 VAROR(BOOL
,VARIANT_TRUE
,UINT
,0,I4
,-1);
4151 VAROR(BOOL
,VARIANT_FALSE
,UINT
,0,I4
,0);
4152 rbstr
= SysAllocString(szFalse
);
4153 VAROR(BOOL
,VARIANT_FALSE
,BSTR
,rbstr
,BOOL
,VARIANT_FALSE
);
4154 VAROR(BOOL
,VARIANT_TRUE
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
4155 rbstr
= SysAllocString(szTrue
);
4156 VAROR(BOOL
,VARIANT_FALSE
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
4157 VAROR(BOOL
,VARIANT_TRUE
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
4158 VARORCY(BOOL
,VARIANT_TRUE
,10000,I4
,-1);
4159 VARORCY(BOOL
,VARIANT_TRUE
,0,I4
,-1);
4160 VARORCY(BOOL
,VARIANT_FALSE
,0,I4
,0);
4162 VAROR(I1
,-1,I1
,-1,I4
,-1);
4163 VAROR(I1
,-1,I1
,0,I4
,-1);
4164 VAROR(I1
,0,I1
,0,I4
,0);
4165 VAROR(I1
,-1,UI1
,255,I4
,-1);
4166 VAROR(I1
,-1,UI1
,0,I4
,-1);
4167 VAROR(I1
,0,UI1
,0,I4
,0);
4168 VAROR(I1
,-1,I2
,-1,I4
,-1);
4169 VAROR(I1
,-1,I2
,0,I4
,-1);
4170 VAROR(I1
,0,I2
,0,I4
,0);
4171 VAROR(I1
,-1,UI2
,65535,I4
,-1);
4172 VAROR(I1
,-1,UI2
,0,I4
,-1);
4173 VAROR(I1
,0,UI2
,0,I4
,0);
4174 VAROR(I1
,-1,I4
,-1,I4
,-1);
4175 VAROR(I1
,-1,I4
,0,I4
,-1);
4176 VAROR(I1
,0,I4
,0,I4
,0);
4177 VAROR(I1
,-1,UI4
,0xffffffff,I4
,-1);
4178 VAROR(I1
,-1,UI4
,0,I4
,-1);
4179 VAROR(I1
,0,UI4
,0,I4
,0);
4180 VAROR(I1
,-1,R4
,-1,I4
,-1);
4181 VAROR(I1
,-1,R4
,0,I4
,-1);
4182 VAROR(I1
,0,R4
,0,I4
,0);
4183 VAROR(I1
,-1,R8
,-1,I4
,-1);
4184 VAROR(I1
,-1,R8
,0,I4
,-1);
4185 VAROR(I1
,0,R8
,0,I4
,0);
4186 VAROR(I1
,-1,DATE
,-1,I4
,-1);
4187 VAROR(I1
,-1,DATE
,0,I4
,-1);
4188 VAROR(I1
,0,DATE
,0,I4
,0);
4189 if (HAVE_OLEAUT32_I8
)
4191 VAROR(I1
,-1,I8
,-1,I8
,-1);
4192 VAROR(I1
,-1,I8
,0,I8
,-1);
4193 VAROR(I1
,0,I8
,0,I8
,0);
4194 VAROR(I1
,-1,UI8
,0,I4
,-1);
4195 VAROR(I1
,0,UI8
,0,I4
,0);
4197 VAROR(I1
,-1,INT
,-1,I4
,-1);
4198 VAROR(I1
,-1,INT
,0,I4
,-1);
4199 VAROR(I1
,0,INT
,0,I4
,0);
4200 VAROR(I1
,-1,UINT
,0xffffffff,I4
,-1);
4201 VAROR(I1
,-1,UINT
,0,I4
,-1);
4202 VAROR(I1
,0,UINT
,0,I4
,0);
4203 rbstr
= SysAllocString(szFalse
);
4204 VAROR(I1
,0,BSTR
,rbstr
,I4
,0);
4205 VAROR(I1
,-1,BSTR
,rbstr
,I4
,-1);
4206 rbstr
= SysAllocString(szTrue
);
4207 VAROR(I1
,0,BSTR
,rbstr
,I4
,-1);
4208 VAROR(I1
,-1,BSTR
,rbstr
,I4
,-1);
4209 VARORCY(I1
,-1,10000,I4
,-1);
4210 VARORCY(I1
,-1,0,I4
,-1);
4211 VARORCY(I1
,0,0,I4
,0);
4213 VAROR(UI1
,255,UI1
,255,UI1
,255);
4214 VAROR(UI1
,255,UI1
,0,UI1
,255);
4215 VAROR(UI1
,0,UI1
,0,UI1
,0);
4216 VAROR(UI1
,255,I2
,-1,I2
,-1);
4217 VAROR(UI1
,255,I2
,0,I2
,255);
4218 VAROR(UI1
,0,I2
,0,I2
,0);
4219 VAROR(UI1
,255,UI2
,65535,I4
,65535);
4220 VAROR(UI1
,255,UI2
,0,I4
,255);
4221 VAROR(UI1
,0,UI2
,0,I4
,0);
4222 VAROR(UI1
,255,I4
,-1,I4
,-1);
4223 VAROR(UI1
,255,I4
,0,I4
,255);
4224 VAROR(UI1
,0,I4
,0,I4
,0);
4225 VAROR(UI1
,255,UI4
,0xffffffff,I4
,-1);
4226 VAROR(UI1
,255,UI4
,0,I4
,255);
4227 VAROR(UI1
,0,UI4
,0,I4
,0);
4228 VAROR(UI1
,255,R4
,-1,I4
,-1);
4229 VAROR(UI1
,255,R4
,0,I4
,255);
4230 VAROR(UI1
,0,R4
,0,I4
,0);
4231 VAROR(UI1
,255,R8
,-1,I4
,-1);
4232 VAROR(UI1
,255,R8
,0,I4
,255);
4233 VAROR(UI1
,0,R8
,0,I4
,0);
4234 VAROR(UI1
,255,DATE
,-1,I4
,-1);
4235 VAROR(UI1
,255,DATE
,0,I4
,255);
4236 VAROR(UI1
,0,DATE
,0,I4
,0);
4237 if (HAVE_OLEAUT32_I8
)
4239 VAROR(UI1
,255,I8
,-1,I8
,-1);
4240 VAROR(UI1
,255,I8
,0,I8
,255);
4241 VAROR(UI1
,0,I8
,0,I8
,0);
4242 VAROR(UI1
,255,UI8
,0,I4
,255);
4243 VAROR(UI1
,0,UI8
,0,I4
,0);
4245 VAROR(UI1
,255,INT
,-1,I4
,-1);
4246 VAROR(UI1
,255,INT
,0,I4
,255);
4247 VAROR(UI1
,0,INT
,0,I4
,0);
4248 VAROR(UI1
,255,UINT
,0xffffffff,I4
,-1);
4249 VAROR(UI1
,255,UINT
,0,I4
,255);
4250 VAROR(UI1
,0,UINT
,0,I4
,0);
4251 rbstr
= SysAllocString(szFalse
);
4252 VAROR(UI1
,0,BSTR
,rbstr
,I2
,0);
4253 VAROR(UI1
,255,BSTR
,rbstr
,I2
,255);
4254 rbstr
= SysAllocString(szTrue
);
4255 VAROR(UI1
,0,BSTR
,rbstr
,I2
,-1);
4256 VAROR(UI1
,255,BSTR
,rbstr
,I2
,-1);
4257 VARORCY(UI1
,255,10000,I4
,255);
4258 VARORCY(UI1
,255,0,I4
,255);
4259 VARORCY(UI1
,0,0,I4
,0);
4261 VAROR(I2
,-1,I2
,-1,I2
,-1);
4262 VAROR(I2
,-1,I2
,0,I2
,-1);
4263 VAROR(I2
,0,I2
,0,I2
,0);
4264 VAROR(I2
,-1,UI2
,65535,I4
,-1);
4265 VAROR(I2
,-1,UI2
,0,I4
,-1);
4266 VAROR(I2
,0,UI2
,0,I4
,0);
4267 VAROR(I2
,-1,I4
,-1,I4
,-1);
4268 VAROR(I2
,-1,I4
,0,I4
,-1);
4269 VAROR(I2
,0,I4
,0,I4
,0);
4270 VAROR(I2
,-1,UI4
,0xffffffff,I4
,-1);
4271 VAROR(I2
,-1,UI4
,0,I4
,-1);
4272 VAROR(I2
,0,UI4
,0,I4
,0);
4273 VAROR(I2
,-1,R4
,-1,I4
,-1);
4274 VAROR(I2
,-1,R4
,0,I4
,-1);
4275 VAROR(I2
,0,R4
,0,I4
,0);
4276 VAROR(I2
,-1,R8
,-1,I4
,-1);
4277 VAROR(I2
,-1,R8
,0,I4
,-1);
4278 VAROR(I2
,0,R8
,0,I4
,0);
4279 VAROR(I2
,-1,DATE
,-1,I4
,-1);
4280 VAROR(I2
,-1,DATE
,0,I4
,-1);
4281 VAROR(I2
,0,DATE
,0,I4
,0);
4282 if (HAVE_OLEAUT32_I8
)
4284 VAROR(I2
,-1,I8
,-1,I8
,-1);
4285 VAROR(I2
,-1,I8
,0,I8
,-1);
4286 VAROR(I2
,0,I8
,0,I8
,0);
4287 VAROR(I2
,-1,UI8
,0,I4
,-1);
4288 VAROR(I2
,0,UI8
,0,I4
,0);
4290 VAROR(I2
,-1,INT
,-1,I4
,-1);
4291 VAROR(I2
,-1,INT
,0,I4
,-1);
4292 VAROR(I2
,0,INT
,0,I4
,0);
4293 VAROR(I2
,-1,UINT
,0xffffffff,I4
,-1);
4294 VAROR(I2
,-1,UINT
,0,I4
,-1);
4295 VAROR(I2
,0,UINT
,0,I4
,0);
4296 rbstr
= SysAllocString(szFalse
);
4297 VAROR(I2
,0,BSTR
,rbstr
,I2
,0);
4298 VAROR(I2
,-1,BSTR
,rbstr
,I2
,-1);
4299 rbstr
= SysAllocString(szTrue
);
4300 VAROR(I2
,0,BSTR
,rbstr
,I2
,-1);
4301 VAROR(I2
,-1,BSTR
,rbstr
,I2
,-1);
4302 VARORCY(I2
,-1,10000,I4
,-1);
4303 VARORCY(I2
,-1,0,I4
,-1);
4304 VARORCY(I2
,0,0,I4
,0);
4306 VAROR(UI2
,65535,UI2
,65535,I4
,65535);
4307 VAROR(UI2
,65535,UI2
,0,I4
,65535);
4308 VAROR(UI2
,0,UI2
,0,I4
,0);
4309 VAROR(UI2
,65535,I4
,-1,I4
,-1);
4310 VAROR(UI2
,65535,I4
,0,I4
,65535);
4311 VAROR(UI2
,0,I4
,0,I4
,0);
4312 VAROR(UI2
,65535,UI4
,0xffffffff,I4
,-1);
4313 VAROR(UI2
,65535,UI4
,0,I4
,65535);
4314 VAROR(UI2
,0,UI4
,0,I4
,0);
4315 VAROR(UI2
,65535,R4
,-1,I4
,-1);
4316 VAROR(UI2
,65535,R4
,0,I4
,65535);
4317 VAROR(UI2
,0,R4
,0,I4
,0);
4318 VAROR(UI2
,65535,R8
,-1,I4
,-1);
4319 VAROR(UI2
,65535,R8
,0,I4
,65535);
4320 VAROR(UI2
,0,R8
,0,I4
,0);
4321 VAROR(UI2
,65535,DATE
,-1,I4
,-1);
4322 VAROR(UI2
,65535,DATE
,0,I4
,65535);
4323 VAROR(UI2
,0,DATE
,0,I4
,0);
4324 if (HAVE_OLEAUT32_I8
)
4326 VAROR(UI2
,65535,I8
,-1,I8
,-1);
4327 VAROR(UI2
,65535,I8
,0,I8
,65535);
4328 VAROR(UI2
,0,I8
,0,I8
,0);
4329 VAROR(UI2
,65535,UI8
,0,I4
,65535);
4330 VAROR(UI2
,0,UI8
,0,I4
,0);
4332 VAROR(UI2
,65535,INT
,-1,I4
,-1);
4333 VAROR(UI2
,65535,INT
,0,I4
,65535);
4334 VAROR(UI2
,0,INT
,0,I4
,0);
4335 VAROR(UI2
,65535,UINT
,0xffffffff,I4
,-1);
4336 VAROR(UI2
,65535,UINT
,0,I4
,65535);
4337 VAROR(UI2
,0,UINT
,0,I4
,0);
4338 rbstr
= SysAllocString(szFalse
);
4339 VAROR(UI2
,0,BSTR
,rbstr
,I4
,0);
4340 VAROR(UI2
,65535,BSTR
,rbstr
,I4
,65535);
4341 rbstr
= SysAllocString(szTrue
);
4342 VAROR(UI2
,0,BSTR
,rbstr
,I4
,-1);
4343 VAROR(UI2
,65535,BSTR
,rbstr
,I4
,-1);
4344 VARORCY(UI2
,65535,10000,I4
,65535);
4345 VARORCY(UI2
,65535,0,I4
,65535);
4346 VARORCY(UI2
,0,0,I4
,0);
4348 VAROR(I4
,-1,I4
,-1,I4
,-1);
4349 VAROR(I4
,-1,I4
,0,I4
,-1);
4350 VAROR(I4
,0,I4
,0,I4
,0);
4351 VAROR(I4
,-1,UI4
,0xffffffff,I4
,-1);
4352 VAROR(I4
,-1,UI4
,0,I4
,-1);
4353 VAROR(I4
,0,UI4
,0,I4
,0);
4354 VAROR(I4
,-1,R4
,-1,I4
,-1);
4355 VAROR(I4
,-1,R4
,0,I4
,-1);
4356 VAROR(I4
,0,R4
,0,I4
,0);
4357 VAROR(I4
,-1,R8
,-1,I4
,-1);
4358 VAROR(I4
,-1,R8
,0,I4
,-1);
4359 VAROR(I4
,0,R8
,0,I4
,0);
4360 VAROR(I4
,-1,DATE
,-1,I4
,-1);
4361 VAROR(I4
,-1,DATE
,0,I4
,-1);
4362 VAROR(I4
,0,DATE
,0,I4
,0);
4363 if (HAVE_OLEAUT32_I8
)
4365 VAROR(I4
,-1,I8
,-1,I8
,-1);
4366 VAROR(I4
,-1,I8
,0,I8
,-1);
4367 VAROR(I4
,0,I8
,0,I8
,0);
4368 VAROR(I4
,-1,UI8
,0,I4
,-1);
4369 VAROR(I4
,0,UI8
,0,I4
,0);
4371 VAROR(I4
,-1,INT
,-1,I4
,-1);
4372 VAROR(I4
,-1,INT
,0,I4
,-1);
4373 VAROR(I4
,0,INT
,0,I4
,0);
4374 VAROR(I4
,-1,UINT
,0xffffffff,I4
,-1);
4375 VAROR(I4
,-1,UINT
,0,I4
,-1);
4376 VAROR(I4
,0,UINT
,0,I4
,0);
4377 rbstr
= SysAllocString(szFalse
);
4378 VAROR(I4
,0,BSTR
,rbstr
,I4
,0);
4379 VAROR(I4
,-1,BSTR
,rbstr
,I4
,-1);
4380 rbstr
= SysAllocString(szTrue
);
4381 VAROR(I4
,0,BSTR
,rbstr
,I4
,-1);
4382 VAROR(I4
,-1,BSTR
,rbstr
,I4
,-1);
4383 VARORCY(I4
,-1,10000,I4
,-1);
4384 VARORCY(I4
,-1,0,I4
,-1);
4385 VARORCY(I4
,0,0,I4
,0);
4387 VAROR(UI4
,0xffffffff,UI4
,0xffffffff,I4
,-1);
4388 VAROR(UI4
,0xffffffff,UI4
,0,I4
,-1);
4389 VAROR(UI4
,0,UI4
,0,I4
,0);
4390 VAROR(UI4
,0xffffffff,R4
,-1,I4
,-1);
4391 VAROR(UI4
,0xffffffff,R4
,0,I4
,-1);
4392 VAROR(UI4
,0,R4
,0,I4
,0);
4393 VAROR(UI4
,0xffffffff,R8
,-1,I4
,-1);
4394 VAROR(UI4
,0xffffffff,R8
,0,I4
,-1);
4395 VAROR(UI4
,0,R8
,0,I4
,0);
4396 VAROR(UI4
,0xffffffff,DATE
,-1,I4
,-1);
4397 VAROR(UI4
,0xffffffff,DATE
,0,I4
,-1);
4398 VAROR(UI4
,0,DATE
,0,I4
,0);
4399 if (HAVE_OLEAUT32_I8
)
4401 VAROR(UI4
,0xffffffff,I8
,-1,I8
,-1);
4402 VAROR(UI4
,0xffffffff,I8
,0,I8
,0xffffffff);
4403 VAROR(UI4
,0,I8
,0,I8
,0);
4404 VAROR(UI4
,0xffffffff,UI8
,0,I4
,-1);
4405 VAROR(UI4
,0,UI8
,0,I4
,0);
4407 VAROR(UI4
,0xffffffff,INT
,-1,I4
,-1);
4408 VAROR(UI4
,0xffffffff,INT
,0,I4
,-1);
4409 VAROR(UI4
,0,INT
,0,I4
,0);
4410 VAROR(UI4
,0xffffffff,UINT
,0xffffffff,I4
,-1);
4411 VAROR(UI4
,0xffffffff,UINT
,0,I4
,-1);
4412 VAROR(UI4
,0,UINT
,0,I4
,0);
4413 rbstr
= SysAllocString(szFalse
);
4414 VAROR(UI4
,0,BSTR
,rbstr
,I4
,0);
4415 VAROR(UI4
,0xffffffff,BSTR
,rbstr
,I4
,-1);
4416 rbstr
= SysAllocString(szTrue
);
4417 VAROR(UI4
,0,BSTR
,rbstr
,I4
,-1);
4418 VAROR(UI4
,0xffffffff,BSTR
,rbstr
,I4
,-1);
4419 VARORCY(UI4
,0xffffffff,10000,I4
,-1);
4420 VARORCY(UI4
,0xffffffff,0,I4
,-1);
4421 VARORCY(UI4
,0,0,I4
,0);
4423 VAROR(R4
,-1,R4
,-1,I4
,-1);
4424 VAROR(R4
,-1,R4
,0,I4
,-1);
4425 VAROR(R4
,0,R4
,0,I4
,0);
4426 VAROR(R4
,-1,R8
,-1,I4
,-1);
4427 VAROR(R4
,-1,R8
,0,I4
,-1);
4428 VAROR(R4
,0,R8
,0,I4
,0);
4429 VAROR(R4
,-1,DATE
,-1,I4
,-1);
4430 VAROR(R4
,-1,DATE
,0,I4
,-1);
4431 VAROR(R4
,0,DATE
,0,I4
,0);
4432 if (HAVE_OLEAUT32_I8
)
4434 VAROR(R4
,-1,I8
,-1,I8
,-1);
4435 VAROR(R4
,-1,I8
,0,I8
,-1);
4436 VAROR(R4
,0,I8
,0,I8
,0);
4437 VAROR(R4
,-1,UI8
,0,I4
,-1);
4438 VAROR(R4
,0,UI8
,0,I4
,0);
4440 VAROR(R4
,-1,INT
,-1,I4
,-1);
4441 VAROR(R4
,-1,INT
,0,I4
,-1);
4442 VAROR(R4
,0,INT
,0,I4
,0);
4443 VAROR(R4
,-1,UINT
,0xffffffff,I4
,-1);
4444 VAROR(R4
,-1,UINT
,0,I4
,-1);
4445 VAROR(R4
,0,UINT
,0,I4
,0);
4446 rbstr
= SysAllocString(szFalse
);
4447 VAROR(R4
,0,BSTR
,rbstr
,I4
,0);
4448 VAROR(R4
,-1,BSTR
,rbstr
,I4
,-1);
4449 rbstr
= SysAllocString(szTrue
);
4450 VAROR(R4
,0,BSTR
,rbstr
,I4
,-1);
4451 VAROR(R4
,-1,BSTR
,rbstr
,I4
,-1);
4452 VARORCY(R4
,-1,10000,I4
,-1);
4453 VARORCY(R4
,-1,0,I4
,-1);
4454 VARORCY(R4
,0,0,I4
,0);
4456 VAROR(R8
,-1,R8
,-1,I4
,-1);
4457 VAROR(R8
,-1,R8
,0,I4
,-1);
4458 VAROR(R8
,0,R8
,0,I4
,0);
4459 VAROR(R8
,-1,DATE
,-1,I4
,-1);
4460 VAROR(R8
,-1,DATE
,0,I4
,-1);
4461 VAROR(R8
,0,DATE
,0,I4
,0);
4462 if (HAVE_OLEAUT32_I8
)
4464 VAROR(R8
,-1,I8
,-1,I8
,-1);
4465 VAROR(R8
,-1,I8
,0,I8
,-1);
4466 VAROR(R8
,0,I8
,0,I8
,0);
4467 VAROR(R8
,-1,UI8
,0,I4
,-1);
4468 VAROR(R8
,0,UI8
,0,I4
,0);
4470 VAROR(R8
,-1,INT
,-1,I4
,-1);
4471 VAROR(R8
,-1,INT
,0,I4
,-1);
4472 VAROR(R8
,0,INT
,0,I4
,0);
4473 VAROR(R8
,-1,UINT
,0xffffffff,I4
,-1);
4474 VAROR(R8
,-1,UINT
,0,I4
,-1);
4475 VAROR(R8
,0,UINT
,0,I4
,0);
4476 rbstr
= SysAllocString(szFalse
);
4477 VAROR(R8
,0,BSTR
,rbstr
,I4
,0);
4478 VAROR(R8
,-1,BSTR
,rbstr
,I4
,-1);
4479 rbstr
= SysAllocString(szTrue
);
4480 VAROR(R8
,0,BSTR
,rbstr
,I4
,-1);
4481 VAROR(R8
,-1,BSTR
,rbstr
,I4
,-1);
4482 VARORCY(R8
,-1,10000,I4
,-1);
4483 VARORCY(R8
,-1,0,I4
,-1);
4484 VARORCY(R8
,0,0,I4
,0);
4486 VAROR(DATE
,-1,DATE
,-1,I4
,-1);
4487 VAROR(DATE
,-1,DATE
,0,I4
,-1);
4488 VAROR(DATE
,0,DATE
,0,I4
,0);
4489 if (HAVE_OLEAUT32_I8
)
4491 VAROR(DATE
,-1,I8
,-1,I8
,-1);
4492 VAROR(DATE
,-1,I8
,0,I8
,-1);
4493 VAROR(DATE
,0,I8
,0,I8
,0);
4494 VAROR(DATE
,-1,UI8
,0,I4
,-1);
4495 VAROR(DATE
,0,UI8
,0,I4
,0);
4497 VAROR(DATE
,-1,INT
,-1,I4
,-1);
4498 VAROR(DATE
,-1,INT
,0,I4
,-1);
4499 VAROR(DATE
,0,INT
,0,I4
,0);
4500 VAROR(DATE
,-1,UINT
,0xffffffff,I4
,-1);
4501 VAROR(DATE
,-1,UINT
,0,I4
,-1);
4502 VAROR(DATE
,0,UINT
,0,I4
,0);
4503 rbstr
= SysAllocString(szFalse
);
4504 VAROR(DATE
,0,BSTR
,rbstr
,I4
,0);
4505 VAROR(DATE
,-1,BSTR
,rbstr
,I4
,-1);
4506 rbstr
= SysAllocString(szTrue
);
4507 VAROR(DATE
,0,BSTR
,rbstr
,I4
,-1);
4508 VAROR(DATE
,-1,BSTR
,rbstr
,I4
,-1);
4509 VARORCY(DATE
,-1,10000,I4
,-1);
4510 VARORCY(DATE
,-1,0,I4
,-1);
4511 VARORCY(DATE
,0,0,I4
,0);
4513 if (HAVE_OLEAUT32_I8
)
4515 VAROR(I8
,-1,I8
,-1,I8
,-1);
4516 VAROR(I8
,-1,I8
,0,I8
,-1);
4517 VAROR(I8
,0,I8
,0,I8
,0);
4518 VAROR(I8
,-1,UI8
,0,I8
,-1);
4519 VAROR(I8
,0,UI8
,0,I8
,0);
4520 /* These overflow under native and Wine
4521 VAROR(I8,-1,INT,-1,I4,-1);
4522 VAROR(I8,-1,INT,0,I4,-1);
4523 VAROR(I8,0,INT,0,I4,0); */
4524 VAROR(I8
,-1,UINT
,0xffffffff,I8
,-1);
4525 VAROR(I8
,-1,UINT
,0,I8
,-1);
4526 VAROR(I8
,0,UINT
,0,I8
,0);
4527 rbstr
= SysAllocString(szFalse
);
4528 VAROR(I8
,0,BSTR
,rbstr
,I8
,0);
4529 VAROR(I8
,-1,BSTR
,rbstr
,I8
,-1);
4530 rbstr
= SysAllocString(szTrue
);
4531 VAROR(I8
,0,BSTR
,rbstr
,I8
,-1);
4532 VAROR(I8
,-1,BSTR
,rbstr
,I8
,-1);
4533 VARORCY(I8
,-1,10000,I8
,-1);
4534 VARORCY(I8
,-1,0,I8
,-1);
4535 VARORCY(I8
,0,0,I8
,0);
4537 VAROR(UI8
,0xffff,UI8
,0xffff,I4
,0xffff);
4538 VAROR(UI8
,0xffff,UI8
,0,I4
,0xffff);
4539 VAROR(UI8
,0,UI8
,0,I4
,0);
4540 VAROR(UI8
,0xffff,INT
,-1,I4
,-1);
4541 VAROR(UI8
,0xffff,INT
,0,I4
,0xffff);
4542 VAROR(UI8
,0,INT
,0,I4
,0);
4543 VAROR(UI8
,0xffff,UINT
,0xffff,I4
,0xffff);
4544 VAROR(UI8
,0xffff,UINT
,0,I4
,0xffff);
4545 VAROR(UI8
,0,UINT
,0,I4
,0);
4546 rbstr
= SysAllocString(szFalse
);
4547 VAROR(UI8
,0,BSTR
,rbstr
,I4
,0);
4548 VAROR(UI8
,0xffff,BSTR
,rbstr
,I4
,0xffff);
4549 rbstr
= SysAllocString(szTrue
);
4550 VAROR(UI8
,0,BSTR
,rbstr
,I4
,-1);
4551 VAROR(UI8
,0xffff,BSTR
,rbstr
,I4
,-1);
4552 VARORCY(UI8
,0xffff,10000,I4
,0xffff);
4553 VARORCY(UI8
,0xffff,0,I4
,0xffff);
4554 VARORCY(UI8
,0,0,I4
,0);
4557 VAROR(INT
,-1,INT
,-1,I4
,-1);
4558 VAROR(INT
,-1,INT
,0,I4
,-1);
4559 VAROR(INT
,0,INT
,0,I4
,0);
4560 VAROR(INT
,-1,UINT
,0xffff,I4
,-1);
4561 VAROR(INT
,-1,UINT
,0,I4
,-1);
4562 VAROR(INT
,0,UINT
,0,I4
,0);
4563 rbstr
= SysAllocString(szFalse
);
4564 VAROR(INT
,0,BSTR
,rbstr
,I4
,0);
4565 VAROR(INT
,-1,BSTR
,rbstr
,I4
,-1);
4566 rbstr
= SysAllocString(szTrue
);
4567 VAROR(INT
,0,BSTR
,rbstr
,I4
,-1);
4568 VAROR(INT
,-1,BSTR
,rbstr
,I4
,-1);
4569 VARORCY(INT
,-1,10000,I4
,-1);
4570 VARORCY(INT
,-1,0,I4
,-1);
4571 VARORCY(INT
,0,0,I4
,0);
4573 VAROR(UINT
,0xffff,UINT
,0xffff,I4
,0xffff);
4574 VAROR(UINT
,0xffff,UINT
,0,I4
,0xffff);
4575 VAROR(UINT
,0,UINT
,0,I4
,0);
4576 rbstr
= SysAllocString(szFalse
);
4577 VAROR(UINT
,0,BSTR
,rbstr
,I4
,0);
4578 VAROR(UINT
,0xffff,BSTR
,rbstr
,I4
,0xffff);
4579 rbstr
= SysAllocString(szTrue
);
4580 VAROR(UINT
,0,BSTR
,rbstr
,I4
,-1);
4581 VAROR(UINT
,0xffff,BSTR
,rbstr
,I4
,-1);
4582 VARORCY(UINT
,0xffff,10000,I4
,0xffff);
4583 VARORCY(UINT
,0xffff,0,I4
,0xffff);
4584 VARORCY(UINT
,0,0,I4
,0);
4586 lbstr
= SysAllocString(szFalse
);
4587 rbstr
= SysAllocString(szFalse
);
4588 VAROR(BSTR
,lbstr
,BSTR
,rbstr
,BOOL
,0);
4589 rbstr
= SysAllocString(szTrue
);
4590 VAROR(BSTR
,lbstr
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
4591 lbstr
= SysAllocString(szTrue
);
4592 VAROR(BSTR
,lbstr
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
4593 VARORCY(BSTR
,lbstr
,10000,I4
,-1);
4594 lbstr
= SysAllocString(szFalse
);
4595 VARORCY(BSTR
,lbstr
,10000,I4
,1);
4598 static HRESULT (WINAPI
*pVarEqv
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
4600 #define VAREQV(vt1,val1,vt2,val2,rvt,rval) \
4601 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
4602 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
4603 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
4604 test_var_call2( __LINE__, pVarEqv, &left, &right, &exp )
4606 static void test_VarEqv(void)
4608 VARIANT left
, right
, exp
, result
;
4614 /* Test all possible flag/vt combinations & the resulting vt type */
4615 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
4617 VARTYPE leftvt
, rightvt
, resvt
;
4619 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
4623 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
4629 if (leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
||
4630 leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
||
4631 leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
)
4634 memset(&left
, 0, sizeof(left
));
4635 memset(&right
, 0, sizeof(right
));
4636 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
4637 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
4638 V_VT(&result
) = VT_EMPTY
;
4641 if (ExtraFlags
[i
] & VT_ARRAY
|| ExtraFlags
[i
] & VT_BYREF
||
4642 !IsValidVariantClearVT(leftvt
, ExtraFlags
[i
]) ||
4643 !IsValidVariantClearVT(rightvt
, ExtraFlags
[i
]) ||
4644 leftvt
== VT_CLSID
|| rightvt
== VT_CLSID
||
4645 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
||
4646 leftvt
== VT_VARIANT
|| rightvt
== VT_VARIANT
||
4647 leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
)
4651 if (leftvt
== VT_EMPTY
|| rightvt
== VT_EMPTY
)
4653 if (leftvt
== rightvt
||
4654 leftvt
== VT_I2
|| rightvt
== VT_I2
||
4655 leftvt
== VT_UI1
|| rightvt
== VT_UI1
||
4656 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
4658 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
4660 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
4663 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
4667 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
4669 if (leftvt
== rightvt
)
4671 else if (leftvt
== rightvt
||
4672 leftvt
== VT_I2
|| rightvt
== VT_I2
||
4673 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
4677 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
4680 else if (leftvt
== VT_I2
|| rightvt
== VT_I2
)
4682 if (leftvt
== rightvt
||
4683 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
4685 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
4688 else if (leftvt
== VT_BOOL
&& rightvt
== VT_BOOL
)
4692 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
4694 if (leftvt
== VT_INT
|| rightvt
== VT_INT
)
4699 hres
= pVarEqv(&left
, &right
, &result
);
4701 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
4702 "VarEqv: %d|0x%X, %d|0x%X: Expected failure, got 0x%X vt %d\n",
4703 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], hres
,
4706 ok(hres
== S_OK
&& V_VT(&result
) == resvt
,
4707 "VarEqv: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%X vt %d\n",
4708 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], resvt
, hres
,
4714 /* Test returned values */
4715 VAREQV(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
);
4716 VAREQV(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
);
4717 VAREQV(BOOL
,TRUE
,BOOL
,TRUE
,BOOL
,VARIANT_TRUE
);
4718 VAREQV(BOOL
,FALSE
,BOOL
,FALSE
,BOOL
,VARIANT_TRUE
);
4719 VAREQV(BOOL
,TRUE
,BOOL
,FALSE
,BOOL
,-2);
4720 VAREQV(BOOL
,FALSE
,BOOL
,TRUE
,BOOL
,-2);
4721 VAREQV(BOOL
,6,BOOL
,7,BOOL
,-2);
4722 VAREQV(BOOL
,6,BOOL
,6,BOOL
,VARIANT_TRUE
);
4723 VAREQV(BOOL
,VARIANT_TRUE
,I2
,VARIANT_TRUE
,I2
,VARIANT_TRUE
);
4724 VAREQV(BOOL
,VARIANT_TRUE
,I2
,VARIANT_FALSE
,I2
,VARIANT_FALSE
);
4725 VAREQV(BOOL
,6,I2
,7,I2
,-2);
4726 VAREQV(UI1
,1,UI1
,1,UI1
,255);
4727 VAREQV(UI1
,1,UI1
,0,UI1
,254);
4728 VAREQV(UI1
,0,UI1
,1,UI1
,254);
4729 if (HAVE_OLEAUT32_I8
)
4731 VAREQV(UI4
,VARIANT_FALSE
,I8
,VARIANT_FALSE
,I8
,-1);
4732 VAREQV(UI4
,5,I8
,19,I8
,-23);
4733 VAREQV(UI4
,VARIANT_FALSE
,UI8
,VARIANT_FALSE
,I4
,-1);
4737 static HRESULT (WINAPI
*pVarMul
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
4739 #define VARMUL(vt1,val1,vt2,val2,rvt,rval) \
4740 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
4741 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
4742 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
4743 test_var_call2( __LINE__, pVarMul, &left, &right, &exp )
4745 static void test_VarMul(void)
4747 static const WCHAR sz12
[] = {'1','2','\0'};
4748 VARIANT left
, right
, exp
, result
, cy
, dec
;
4756 lbstr
= SysAllocString(sz12
);
4757 rbstr
= SysAllocString(sz12
);
4759 /* Test all possible flag/vt combinations & the resulting vt type */
4760 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
4762 VARTYPE leftvt
, rightvt
, resvt
;
4764 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
4769 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
4775 if (leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
||
4776 leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
)
4779 memset(&left
, 0, sizeof(left
));
4780 memset(&right
, 0, sizeof(right
));
4781 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
4782 if (leftvt
== VT_BSTR
)
4783 V_BSTR(&left
) = lbstr
;
4784 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
4785 if (rightvt
== VT_BSTR
)
4786 V_BSTR(&right
) = rbstr
;
4787 V_VT(&result
) = VT_EMPTY
;
4790 /* Don't ask me why but native VarMul cannot handle:
4791 VT_I1, VT_UI2, VT_UI4, VT_INT, VT_UINT and VT_UI8.
4792 Tested with DCOM98, Win2k, WinXP */
4793 if (ExtraFlags
[i
] & VT_ARRAY
|| ExtraFlags
[i
] & VT_BYREF
||
4794 !IsValidVariantClearVT(leftvt
, ExtraFlags
[i
]) ||
4795 !IsValidVariantClearVT(rightvt
, ExtraFlags
[i
]) ||
4796 leftvt
== VT_CLSID
|| rightvt
== VT_CLSID
||
4797 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
||
4798 leftvt
== VT_VARIANT
|| rightvt
== VT_VARIANT
||
4799 leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
||
4800 leftvt
== VT_I1
|| rightvt
== VT_I1
||
4801 leftvt
== VT_UI2
|| rightvt
== VT_UI2
||
4802 leftvt
== VT_UI4
|| rightvt
== VT_UI4
||
4803 leftvt
== VT_UI8
|| rightvt
== VT_UI8
||
4804 leftvt
== VT_INT
|| rightvt
== VT_INT
||
4805 leftvt
== VT_UINT
|| rightvt
== VT_UINT
) {
4809 if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
4811 else if (leftvt
== VT_DECIMAL
|| rightvt
== VT_DECIMAL
)
4813 else if (leftvt
== VT_R8
|| rightvt
== VT_R8
||
4814 leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
||
4815 leftvt
== VT_DATE
|| rightvt
== VT_DATE
)
4817 else if (leftvt
== VT_R4
|| rightvt
== VT_R4
) {
4818 if (leftvt
== VT_I4
|| rightvt
== VT_I4
||
4819 leftvt
== VT_I8
|| rightvt
== VT_I8
||
4820 leftvt
== VT_CY
|| rightvt
== VT_CY
)
4824 } else if (leftvt
== VT_CY
|| rightvt
== VT_CY
)
4826 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
4828 else if (leftvt
== VT_I4
|| rightvt
== VT_I4
)
4830 else if (leftvt
== VT_I2
|| rightvt
== VT_I2
||
4831 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
||
4832 (leftvt
== VT_EMPTY
&& rightvt
== VT_EMPTY
))
4834 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
4837 hres
= pVarMul(&left
, &right
, &result
);
4839 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
4840 "VarMul: %d|0x%X, %d|0x%X: Expected failure, got 0x%X vt %d\n",
4841 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], hres
,
4844 ok(hres
== S_OK
&& V_VT(&result
) == resvt
,
4845 "VarMul: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%X vt %d\n",
4846 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], resvt
, hres
,
4853 /* Test returned values */
4854 VARMUL(I4
,4,I4
,2,I4
,8);
4855 VARMUL(I2
,4,I2
,2,I2
,8);
4856 VARMUL(I2
,-13,I4
,5,I4
,-65);
4857 VARMUL(I4
,-13,I4
,5,I4
,-65);
4858 VARMUL(I2
,7,R4
,0.5f
,R4
,3.5f
);
4859 VARMUL(R4
,0.5f
,I4
,5,R8
,2.5);
4860 VARMUL(R8
,7.1,BOOL
,0,R8
,0);
4861 VARMUL(BSTR
,lbstr
,I2
,4,R8
,48);
4862 VARMUL(BSTR
,lbstr
,BOOL
,1,R8
,12);
4863 VARMUL(BSTR
,lbstr
,R4
,0.1f
,R8
,1.2);
4864 VARMUL(BSTR
,lbstr
,BSTR
,rbstr
,R8
,144);
4865 VARMUL(R4
,0.2f
,BSTR
,rbstr
,R8
,2.4);
4866 VARMUL(DATE
,2.25,I4
,7,R8
,15.75);
4868 VARMUL(UI1
, UI1_MAX
, UI1
, UI1_MAX
, I4
, UI1_MAX
* UI1_MAX
);
4869 VARMUL(I2
, I2_MAX
, I2
, I2_MAX
, I4
, I2_MAX
* I2_MAX
);
4870 VARMUL(I2
, I2_MAX
, I2
, I2_MIN
, I4
, I2_MAX
* I2_MIN
);
4871 VARMUL(I2
, I2_MIN
, I2
, I2_MIN
, I4
, I2_MIN
* I2_MIN
);
4872 VARMUL(I4
, I4_MAX
, I4
, I4_MAX
, R8
, (double)I4_MAX
* I4_MAX
);
4873 VARMUL(I4
, I4_MAX
, I4
, I4_MIN
, R8
, (double)I4_MAX
* I4_MIN
);
4874 VARMUL(I4
, I4_MIN
, I4
, I4_MIN
, R8
, (double)I4_MIN
* I4_MIN
);
4875 VARMUL(R4
, R4_MAX
, R4
, R4_MAX
, R8
, (double)R4_MAX
* R4_MAX
);
4876 VARMUL(R4
, R4_MAX
, R4
, R4_MIN
, R4
, R4_MAX
* R4_MIN
);
4877 VARMUL(R4
, R4_MIN
, R4
, R4_MIN
, R4
, R4_MIN
* R4_MIN
);
4878 VARMUL(R8
, R8_MAX
, R8
, R8_MIN
, R8
, R8_MAX
* R8_MIN
);
4879 VARMUL(R8
, R8_MIN
, R8
, R8_MIN
, R8
, R8_MIN
* R8_MIN
);
4881 /* Manuly test some VT_CY and VT_DECIMAL variants */
4883 hres
= VarCyFromI4(4711, &V_CY(&cy
));
4884 ok(hres
== S_OK
, "VarCyFromI4 failed!\n");
4885 V_VT(&dec
) = VT_DECIMAL
;
4886 hres
= VarDecFromR8(-4.2, &V_DECIMAL(&dec
));
4887 ok(hres
== S_OK
, "VarDecFromR4 failed!\n");
4888 memset(&left
, 0, sizeof(left
));
4889 memset(&right
, 0, sizeof(right
));
4890 V_VT(&left
) = VT_I4
;
4892 V_VT(&right
) = VT_UI1
;
4895 hres
= VarMul(&cy
, &right
, &result
);
4896 ok(hres
== S_OK
&& V_VT(&result
) == VT_CY
, "VarMul: expected coerced type VT_CY, got %s!\n", vtstr(V_VT(&result
)));
4897 hres
= VarR8FromCy(V_CY(&result
), &r
);
4898 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 42399), "VarMul: CY value %f, expected %f\n", r
, (double)42399);
4900 hres
= VarMul(&left
, &dec
, &result
);
4901 ok(hres
== S_OK
&& V_VT(&result
) == VT_DECIMAL
, "VarMul: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result
)));
4902 hres
= VarR8FromDec(&V_DECIMAL(&result
), &r
);
4903 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 46.2), "VarMul: DECIMAL value %f, expected %f\n", r
, (double)46.2);
4905 SysFreeString(lbstr
);
4906 SysFreeString(rbstr
);
4909 static HRESULT (WINAPI
*pVarAdd
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
4911 #define VARADD(vt1,val1,vt2,val2,rvt,rval) \
4912 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
4913 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
4914 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
4915 test_var_call2( __LINE__, pVarAdd, &left, &right, &exp )
4917 static void test_VarAdd(void)
4919 static const WCHAR sz12
[] = {'1','2','\0'};
4920 VARIANT left
, right
, exp
, result
, cy
, dec
;
4928 lbstr
= SysAllocString(sz12
);
4929 rbstr
= SysAllocString(sz12
);
4931 /* Test all possible flag/vt combinations & the resulting vt type */
4932 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
4934 VARTYPE leftvt
, rightvt
, resvt
;
4936 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
4941 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
4947 if (leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
)
4950 memset(&left
, 0, sizeof(left
));
4951 memset(&right
, 0, sizeof(right
));
4952 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
4953 if (leftvt
== VT_BSTR
)
4954 V_BSTR(&left
) = lbstr
;
4955 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
4956 if (rightvt
== VT_BSTR
)
4957 V_BSTR(&right
) = rbstr
;
4958 V_VT(&result
) = VT_EMPTY
;
4961 /* Don't ask me why but native VarAdd cannot handle:
4962 VT_I1, VT_UI2, VT_UI4, VT_INT, VT_UINT and VT_UI8.
4963 Tested with DCOM98, Win2k, WinXP */
4964 if (ExtraFlags
[i
] & VT_ARRAY
|| ExtraFlags
[i
] & VT_BYREF
||
4965 !IsValidVariantClearVT(leftvt
, ExtraFlags
[i
]) ||
4966 !IsValidVariantClearVT(rightvt
, ExtraFlags
[i
]) ||
4967 leftvt
== VT_CLSID
|| rightvt
== VT_CLSID
||
4968 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
||
4969 leftvt
== VT_VARIANT
|| rightvt
== VT_VARIANT
||
4970 leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
||
4971 leftvt
== VT_I1
|| rightvt
== VT_I1
||
4972 leftvt
== VT_UI2
|| rightvt
== VT_UI2
||
4973 leftvt
== VT_UI4
|| rightvt
== VT_UI4
||
4974 leftvt
== VT_UI8
|| rightvt
== VT_UI8
||
4975 leftvt
== VT_INT
|| rightvt
== VT_INT
||
4976 leftvt
== VT_UINT
|| rightvt
== VT_UINT
) {
4980 if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
4982 else if (leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
)
4984 else if (leftvt
== VT_DECIMAL
|| rightvt
== VT_DECIMAL
)
4986 else if (leftvt
== VT_DATE
|| rightvt
== VT_DATE
)
4988 else if (leftvt
== VT_CY
|| rightvt
== VT_CY
)
4990 else if (leftvt
== VT_R8
|| rightvt
== VT_R8
)
4992 else if (leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
) {
4993 if ((leftvt
== VT_BSTR
&& rightvt
== VT_BSTR
) ||
4994 leftvt
== VT_EMPTY
|| rightvt
== VT_EMPTY
)
4998 } else if (leftvt
== VT_R4
|| rightvt
== VT_R4
) {
4999 if (leftvt
== VT_I4
|| rightvt
== VT_I4
||
5000 leftvt
== VT_I8
|| rightvt
== VT_I8
)
5005 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
5007 else if (leftvt
== VT_I4
|| rightvt
== VT_I4
)
5009 else if (leftvt
== VT_I2
|| rightvt
== VT_I2
||
5010 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
||
5011 (leftvt
== VT_EMPTY
&& rightvt
== VT_EMPTY
))
5013 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
5016 hres
= pVarAdd(&left
, &right
, &result
);
5018 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
5019 "VarAdd: %d|0x%X, %d|0x%X: Expected failure, got 0x%X vt %d\n",
5020 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], hres
,
5023 ok(hres
== S_OK
&& V_VT(&result
) == resvt
,
5024 "VarAdd: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%X vt %d\n",
5025 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], resvt
, hres
,
5032 /* Test returned values */
5033 VARADD(I4
,4,I4
,2,I4
,6);
5034 VARADD(I2
,4,I2
,2,I2
,6);
5035 VARADD(I2
,-13,I4
,5,I4
,-8);
5036 VARADD(I4
,-13,I4
,5,I4
,-8);
5037 VARADD(I2
,7,R4
,0.5f
,R4
,7.5f
);
5038 VARADD(R4
,0.5f
,I4
,5,R8
,5.5);
5039 VARADD(R8
,7.1,BOOL
,0,R8
,7.1);
5040 VARADD(BSTR
,lbstr
,I2
,4,R8
,16);
5041 VARADD(BSTR
,lbstr
,BOOL
,1,R8
,13);
5042 VARADD(BSTR
,lbstr
,R4
,0.1f
,R8
,12.1);
5043 VARADD(R4
,0.2f
,BSTR
,rbstr
,R8
,12.2);
5044 VARADD(DATE
,2.25,I4
,7,DATE
,9.25);
5045 VARADD(DATE
,1.25,R4
,-1.7f
,DATE
,-0.45);
5047 VARADD(UI1
, UI1_MAX
, UI1
, UI1_MAX
, I2
, UI1_MAX
+ UI1_MAX
);
5048 VARADD(I2
, I2_MAX
, I2
, I2_MAX
, I4
, I2_MAX
+ I2_MAX
);
5049 VARADD(I2
, I2_MAX
, I2
, I2_MIN
, I2
, I2_MAX
+ I2_MIN
);
5050 VARADD(I2
, I2_MIN
, I2
, I2_MIN
, I4
, I2_MIN
+ I2_MIN
);
5051 VARADD(I4
, I4_MAX
, I4
, I4_MIN
, I4
, I4_MAX
+ I4_MIN
);
5052 VARADD(I4
, I4_MAX
, I4
, I4_MAX
, R8
, (double)I4_MAX
+ I4_MAX
);
5053 VARADD(I4
, I4_MIN
, I4
, I4_MIN
, R8
, (double)I4_MIN
+ I4_MIN
);
5054 VARADD(R4
, R4_MAX
, R4
, R4_MAX
, R8
, (double)R4_MAX
+ R4_MAX
);
5055 VARADD(R4
, R4_MAX
, R4
, R4_MIN
, R4
, R4_MAX
+ R4_MIN
);
5056 VARADD(R4
, R4_MIN
, R4
, R4_MIN
, R4
, R4_MIN
+ R4_MIN
);
5057 VARADD(R8
, R8_MAX
, R8
, R8_MIN
, R8
, R8_MAX
+ R8_MIN
);
5058 VARADD(R8
, R8_MIN
, R8
, R8_MIN
, R8
, R8_MIN
+ R8_MIN
);
5060 /* Manualy test BSTR + BSTR */
5061 V_VT(&left
) = VT_BSTR
;
5062 V_BSTR(&left
) = lbstr
;
5063 V_VT(&right
) = VT_BSTR
;
5064 V_BSTR(&right
) = rbstr
;
5065 hres
= VarAdd(&left
, &right
, &result
);
5066 ok(hres
== S_OK
&& V_VT(&result
) == VT_BSTR
, "VarAdd: expected coerced type VT_BSTR, got %s!\n", vtstr(V_VT(&result
)));
5067 hres
= VarR8FromStr(V_BSTR(&result
), 0, 0, &r
);
5068 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 1212), "VarAdd: BSTR value %f, expected %f\n", r
, (double)1212);
5070 /* Manuly test some VT_CY and VT_DECIMAL variants */
5072 hres
= VarCyFromI4(4711, &V_CY(&cy
));
5073 ok(hres
== S_OK
, "VarCyFromI4 failed!\n");
5074 V_VT(&dec
) = VT_DECIMAL
;
5075 hres
= VarDecFromR8(-4.2, &V_DECIMAL(&dec
));
5076 ok(hres
== S_OK
, "VarDecFromR4 failed!\n");
5077 memset(&left
, 0, sizeof(left
));
5078 memset(&right
, 0, sizeof(right
));
5079 V_VT(&left
) = VT_I4
;
5081 V_VT(&right
) = VT_UI1
;
5084 hres
= VarAdd(&cy
, &right
, &result
);
5085 ok(hres
== S_OK
&& V_VT(&result
) == VT_CY
, "VarAdd: expected coerced type VT_CY, got %s!\n", vtstr(V_VT(&result
)));
5086 hres
= VarR8FromCy(V_CY(&result
), &r
);
5087 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 4720), "VarAdd: CY value %f, expected %f\n", r
, (double)4720);
5089 hres
= VarAdd(&left
, &dec
, &result
);
5090 ok(hres
== S_OK
&& V_VT(&result
) == VT_DECIMAL
, "VarAdd: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result
)));
5091 hres
= VarR8FromDec(&V_DECIMAL(&result
), &r
);
5092 ok(hres
== S_OK
&& EQ_DOUBLE(r
, -15.2), "VarAdd: DECIMAL value %f, expected %f\n", r
, (double)-15.2);
5094 SysFreeString(lbstr
);
5095 SysFreeString(rbstr
);
5098 static void test_VarCat(void)
5101 VARIANT left
, right
, result
, expected
;
5102 static const WCHAR sz12
[] = {'1','2','\0'};
5103 static const WCHAR sz34
[] = {'3','4','\0'};
5104 static const WCHAR sz1234
[] = {'1','2','3','4','\0'};
5105 static const WCHAR date_sz12
[] = {'9','/','3','0','/','1','9','8','0','1','2','\0'};
5106 static const WCHAR sz12_date
[] = {'1','2','9','/','3','0','/','1','9','8','0','\0'};
5107 static const WCHAR sz_empty
[] = {'\0'};
5108 static const WCHAR sz12_true
[] = {'1','2','T','r','u','e','\0'};
5109 static const WCHAR sz12_false
[] = {'1','2','F','a','l','s','e','\0'};
5110 TCHAR orig_date_format
[128];
5111 VARTYPE leftvt
, rightvt
, resultvt
;
5113 HRESULT expected_error_num
;
5115 /* Set date format for testing */
5116 lcid
= LOCALE_USER_DEFAULT
;
5117 GetLocaleInfo(lcid
,LOCALE_SSHORTDATE
,orig_date_format
,128);
5118 SetLocaleInfo(lcid
,LOCALE_SSHORTDATE
,"M/d/yyyy");
5121 VariantInit(&right
);
5122 VariantInit(&result
);
5123 VariantInit(&expected
);
5125 /* Check expected types for all combinations */
5126 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
5131 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
5135 expected_error_num
= S_OK
;
5136 resultvt
= VT_EMPTY
;
5138 if (leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
||
5139 leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
||
5140 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
||
5141 leftvt
== 15 || rightvt
== 15 /* Undefined type */)
5144 if (leftvt
== VT_NULL
&& rightvt
== VT_NULL
)
5146 else if (leftvt
== VT_VARIANT
&& (rightvt
== VT_ERROR
||
5147 rightvt
== VT_DATE
|| rightvt
== VT_DECIMAL
))
5148 expected_error_num
= DISP_E_TYPEMISMATCH
;
5149 else if ((leftvt
== VT_I2
|| leftvt
== VT_I4
||
5150 leftvt
== VT_R4
|| leftvt
== VT_R8
||
5151 leftvt
== VT_CY
|| leftvt
== VT_BOOL
||
5152 leftvt
== VT_BSTR
|| leftvt
== VT_I1
||
5153 leftvt
== VT_UI1
|| leftvt
== VT_UI2
||
5154 leftvt
== VT_UI4
|| leftvt
== VT_I8
||
5155 leftvt
== VT_UI8
|| leftvt
== VT_INT
||
5156 leftvt
== VT_UINT
|| leftvt
== VT_EMPTY
||
5157 leftvt
== VT_NULL
|| leftvt
== VT_DECIMAL
||
5160 (rightvt
== VT_I2
|| rightvt
== VT_I4
||
5161 rightvt
== VT_R4
|| rightvt
== VT_R8
||
5162 rightvt
== VT_CY
|| rightvt
== VT_BOOL
||
5163 rightvt
== VT_BSTR
|| rightvt
== VT_I1
||
5164 rightvt
== VT_UI1
|| rightvt
== VT_UI2
||
5165 rightvt
== VT_UI4
|| rightvt
== VT_I8
||
5166 rightvt
== VT_UI8
|| rightvt
== VT_INT
||
5167 rightvt
== VT_UINT
|| rightvt
== VT_EMPTY
||
5168 rightvt
== VT_NULL
|| rightvt
== VT_DECIMAL
||
5169 rightvt
== VT_DATE
))
5171 else if (rightvt
== VT_ERROR
&& leftvt
< VT_VOID
)
5172 expected_error_num
= DISP_E_TYPEMISMATCH
;
5173 else if (leftvt
== VT_ERROR
&& (rightvt
== VT_DATE
||
5174 rightvt
== VT_ERROR
|| rightvt
== VT_DECIMAL
))
5175 expected_error_num
= DISP_E_TYPEMISMATCH
;
5176 else if (rightvt
== VT_DATE
|| rightvt
== VT_ERROR
||
5177 rightvt
== VT_DECIMAL
)
5178 expected_error_num
= DISP_E_BADVARTYPE
;
5179 else if (leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
)
5180 expected_error_num
= DISP_E_TYPEMISMATCH
;
5181 else if (leftvt
== VT_VARIANT
)
5182 expected_error_num
= DISP_E_TYPEMISMATCH
;
5183 else if (rightvt
== VT_VARIANT
&& (leftvt
== VT_EMPTY
||
5184 leftvt
== VT_NULL
|| leftvt
== VT_I2
||
5185 leftvt
== VT_I4
|| leftvt
== VT_R4
||
5186 leftvt
== VT_R8
|| leftvt
== VT_CY
||
5187 leftvt
== VT_DATE
|| leftvt
== VT_BSTR
||
5188 leftvt
== VT_BOOL
|| leftvt
== VT_DECIMAL
||
5189 leftvt
== VT_I1
|| leftvt
== VT_UI1
||
5190 leftvt
== VT_UI2
|| leftvt
== VT_UI4
||
5191 leftvt
== VT_I8
|| leftvt
== VT_UI8
||
5192 leftvt
== VT_INT
|| leftvt
== VT_UINT
5194 expected_error_num
= DISP_E_TYPEMISMATCH
;
5196 expected_error_num
= DISP_E_BADVARTYPE
;
5198 V_VT(&left
) = leftvt
;
5199 V_VT(&right
) = rightvt
;
5201 if (leftvt
== VT_BSTR
)
5202 V_BSTR(&left
) = SysAllocString(sz_empty
);
5203 if (rightvt
== VT_BSTR
)
5204 V_BSTR(&right
) = SysAllocString(sz_empty
);
5205 if (leftvt
== VT_DATE
)
5206 V_DATE(&left
) = 0.0;
5207 if (rightvt
== VT_DATE
)
5208 V_DATE(&right
) = 0.0;
5209 if (leftvt
== VT_DECIMAL
)
5210 VarDecFromR8(0.0, &V_DECIMAL(&left
));
5211 if (rightvt
== VT_DECIMAL
)
5212 VarDecFromR8(0.0, &V_DECIMAL(&right
));
5214 hres
= VarCat(&left
, &right
, &result
);
5216 /* Determine the error code for the vt combination */
5217 ok(hres
== expected_error_num
,
5218 "VarCat: %d, %d returned error, 0x%X expected 0x%X.\n",
5219 leftvt
, rightvt
, expected_error_num
, hres
);
5221 /* Check types are correct */
5222 ok(V_VT(&result
) == resultvt
,
5223 "VarCat: %d, %d: expected vt %d, got vt %d\n",
5224 leftvt
, rightvt
, resultvt
, V_VT(&result
));
5226 VariantClear(&left
);
5227 VariantClear(&right
);
5228 VariantClear(&result
);
5232 /* Runnning single comparison tests to compare outputs */
5234 /* Test concat strings */
5235 V_VT(&left
) = VT_BSTR
;
5236 V_VT(&right
) = VT_BSTR
;
5237 V_VT(&expected
) = VT_BSTR
;
5238 V_BSTR(&left
) = SysAllocString(sz12
);
5239 V_BSTR(&right
) = SysAllocString(sz34
);
5240 V_BSTR(&expected
) = SysAllocString(sz1234
);
5241 hres
= VarCat(&left
,&right
,&result
);
5242 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5243 ok(VarCmp(&result
,&expected
,lcid
,0) == VARCMP_EQ
,
5244 "VarCat: VT_BSTR concat with VT_BSTR failed to return correct result\n");
5246 VariantClear(&left
);
5247 VariantClear(&right
);
5248 VariantClear(&result
);
5250 /* Test if expression is VT_ERROR */
5251 V_VT(&left
) = VT_ERROR
;
5252 V_VT(&right
) = VT_BSTR
;
5253 V_BSTR(&right
) = SysAllocString(sz1234
);
5254 hres
= VarCat(&left
,&right
,&result
);
5255 ok(hres
== DISP_E_TYPEMISMATCH
, "VarCat should have returned DISP_E_TYPEMISMATCH instead of 0x%08x\n", hres
);
5256 ok(V_VT(&result
) == VT_EMPTY
,
5257 "VarCat: VT_ERROR concat with VT_BSTR should have returned VT_EMPTY\n");
5259 VariantClear(&left
);
5260 VariantClear(&right
);
5261 VariantClear(&result
);
5263 V_VT(&left
) = VT_BSTR
;
5264 V_VT(&right
) = VT_ERROR
;
5265 V_BSTR(&left
) = SysAllocString(sz1234
);
5266 hres
= VarCat(&left
,&right
,&result
);
5267 ok(hres
== DISP_E_TYPEMISMATCH
, "VarCat should have returned DISP_E_TYPEMISMATCH instead of 0x%08x\n", hres
);
5268 ok(V_VT(&result
) == VT_EMPTY
,
5269 "VarCat: VT_BSTR concat with VT_ERROR should have returned VT_EMPTY\n");
5271 VariantClear(&left
);
5272 VariantClear(&right
);
5273 VariantClear(&result
);
5274 VariantClear(&expected
);
5276 /* Test combining boolean with number */
5277 V_VT(&left
) = VT_INT
;
5278 V_VT(&right
) = VT_BOOL
;
5279 V_VT(&expected
) = VT_BSTR
;
5281 V_BOOL(&right
) = TRUE
;
5282 V_BSTR(&expected
) = SysAllocString(sz12_true
);
5283 hres
= VarCat(&left
,&right
,&result
);
5284 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5285 ok(VarCmp(&result
,&expected
,lcid
,0) == VARCMP_EQ
,
5286 "VarCat: VT_INT concat with VT_BOOL (TRUE) returned incorrect result\n");
5288 VariantClear(&left
);
5289 VariantClear(&right
);
5290 VariantClear(&result
);
5291 VariantClear(&expected
);
5293 V_VT(&left
) = VT_INT
;
5294 V_VT(&right
) = VT_BOOL
;
5295 V_VT(&expected
) = VT_BSTR
;
5297 V_BOOL(&right
) = FALSE
;
5298 V_BSTR(&expected
) = SysAllocString(sz12_false
);
5299 hres
= VarCat(&left
,&right
,&result
);
5300 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5301 ok(VarCmp(&result
,&expected
,lcid
,0) == VARCMP_EQ
,
5302 "VarCat: VT_INT concat with VT_BOOL (FALSE) returned inncorrect result\n");
5304 VariantClear(&left
);
5305 VariantClear(&right
);
5306 VariantClear(&result
);
5307 VariantClear(&expected
);
5309 /* Test when both expressions are numeric */
5310 V_VT(&left
) = VT_INT
;
5311 V_VT(&right
) = VT_INT
;
5312 V_VT(&expected
) = VT_BSTR
;
5315 V_BSTR(&expected
) = SysAllocString(sz1234
);
5316 hres
= VarCat(&left
,&right
,&result
);
5317 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5318 ok(VarCmp(&result
,&expected
,lcid
,0) == VARCMP_EQ
,
5319 "VarCat: NUMBER concat with NUMBER returned inncorrect result\n");
5321 VariantClear(&left
);
5322 VariantClear(&right
);
5323 VariantClear(&result
);
5325 /* Test if one expression is numeric and the other is a string */
5326 V_VT(&left
) = VT_INT
;
5327 V_VT(&right
) = VT_BSTR
;
5329 V_BSTR(&right
) = SysAllocString(sz34
);
5330 hres
= VarCat(&left
,&right
,&result
);
5331 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5332 ok(VarCmp(&result
,&expected
,lcid
,0) == VARCMP_EQ
,
5333 "VarCat: NUMBER concat with VT_BSTR, inncorrect result\n");
5335 VariantClear(&left
);
5336 VariantClear(&right
);
5337 VariantClear(&result
);
5339 V_VT(&left
) = VT_BSTR
;
5340 V_VT(&right
) = VT_INT
;
5341 V_BSTR(&left
) = SysAllocString(sz12
);
5343 hres
= VarCat(&left
,&right
,&result
);
5344 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5345 ok(VarCmp(&result
,&expected
,lcid
,0) == VARCMP_EQ
,
5346 "VarCat: VT_BSTR concat with NUMBER, inncorrect result\n");
5348 VariantClear(&left
);
5349 VariantClear(&right
);
5350 VariantClear(&result
);
5352 /* Test concat dates with strings */
5353 V_VT(&left
) = VT_BSTR
;
5354 V_VT(&right
) = VT_DATE
;
5355 V_VT(&expected
) = VT_BSTR
;
5356 V_BSTR(&left
) = SysAllocString(sz12
);
5357 V_DATE(&right
) = 29494.0;
5358 V_BSTR(&expected
)= SysAllocString(sz12_date
);
5359 hres
= VarCat(&left
,&right
,&result
);
5360 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5361 ok(VarCmp(&result
,&expected
,lcid
,0) == VARCMP_EQ
,
5362 "VarCat: VT_BSTR concat with VT_DATE returned inncorrect result\n");
5364 VariantClear(&left
);
5365 VariantClear(&right
);
5366 VariantClear(&result
);
5367 VariantClear(&expected
);
5369 V_VT(&left
) = VT_DATE
;
5370 V_VT(&right
) = VT_BSTR
;
5371 V_VT(&expected
) = VT_BSTR
;
5372 V_DATE(&left
) = 29494.0;
5373 V_BSTR(&right
) = SysAllocString(sz12
);
5374 V_BSTR(&expected
)= SysAllocString(date_sz12
);
5375 hres
= VarCat(&left
,&right
,&result
);
5376 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5377 ok(VarCmp(&result
,&expected
,lcid
,0) == VARCMP_EQ
,
5378 "VarCat: VT_DATE concat with VT_BSTR returned inncorrect result\n");
5380 VariantClear(&left
);
5381 VariantClear(&right
);
5382 VariantClear(&result
);
5383 VariantClear(&expected
);
5385 /* Test of both expressions are empty */
5386 V_VT(&left
) = VT_BSTR
;
5387 V_VT(&right
) = VT_BSTR
;
5388 V_VT(&expected
) = VT_BSTR
;
5389 V_BSTR(&left
) = SysAllocString(sz_empty
);
5390 V_BSTR(&right
) = SysAllocString(sz_empty
);
5391 V_BSTR(&expected
)= SysAllocString(sz_empty
);
5392 hres
= VarCat(&left
,&right
,&result
);
5393 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5394 ok(VarCmp(&result
,&left
,lcid
,0) == VARCMP_EQ
,
5395 "VarCat: EMPTY concat with EMPTY did not return empty VT_BSTR\n");
5397 /* Restore original date format settings */
5398 SetLocaleInfo(lcid
,LOCALE_SSHORTDATE
,orig_date_format
);
5400 VariantClear(&left
);
5401 VariantClear(&right
);
5402 VariantClear(&result
);
5403 VariantClear(&expected
);
5406 static HRESULT (WINAPI
*pVarAnd
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
5408 #define VARAND(vt1,val1,vt2,val2,rvt,rval) \
5409 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
5410 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
5411 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
5412 test_var_call2( __LINE__, pVarAnd, &left, &right, &exp )
5414 #define VARANDCY(vt1,val1,val2,rvt,rval) \
5415 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
5416 V_VT(&right) = VT_CY; V_CY(&right).int64 = val2; \
5417 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
5418 test_var_call2( __LINE__, pVarAnd, &left, &right, &exp )
5420 /* Skip any type that is not defined or produces an error for every case */
5421 #define SKIPTESTAND(a) \
5422 if (a == VT_ERROR || a == VT_VARIANT || \
5423 a == VT_DISPATCH || a == VT_UNKNOWN || \
5424 a > VT_UINT || a == 15 /*not defined*/) \
5427 static void test_VarAnd(void)
5429 static const WCHAR szFalse
[] = { '#','F','A','L','S','E','#','\0' };
5430 static const WCHAR szTrue
[] = { '#','T','R','U','E','#','\0' };
5431 VARIANT left
, right
, exp
, result
;
5432 BSTR false_str
, true_str
;
5436 true_str
= SysAllocString(szTrue
);
5437 false_str
= SysAllocString(szFalse
);
5441 /* Test all possible flag/vt combinations & the resulting vt type */
5442 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
5444 VARTYPE leftvt
, rightvt
, resvt
;
5446 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
5448 SKIPTESTAND(leftvt
);
5450 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
5453 SKIPTESTAND(rightvt
);
5455 memset(&left
, 0, sizeof(left
));
5456 memset(&right
, 0, sizeof(right
));
5457 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
5458 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
5459 V_VT(&result
) = VT_EMPTY
;
5461 if ((leftvt
| ExtraFlags
[i
]) == VT_BSTR
)
5462 V_BSTR(&left
) = true_str
;
5463 if ((rightvt
| ExtraFlags
[i
]) == VT_BSTR
)
5464 V_BSTR(&right
) = true_str
;
5466 /* Native VarAnd always returns an error when using extra
5467 * flags or if the variant combination is I8 and INT.
5469 if ((leftvt
== VT_I8
&& rightvt
== VT_INT
) ||
5470 (leftvt
== VT_INT
&& rightvt
== VT_I8
) ||
5474 /* Determine return type */
5475 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
5477 else if (leftvt
== VT_I4
|| rightvt
== VT_I4
||
5478 leftvt
== VT_UINT
|| rightvt
== VT_UINT
||
5479 leftvt
== VT_INT
|| rightvt
== VT_INT
||
5480 leftvt
== VT_UINT
|| rightvt
== VT_UINT
||
5481 leftvt
== VT_R4
|| rightvt
== VT_R4
||
5482 leftvt
== VT_R8
|| rightvt
== VT_R8
||
5483 leftvt
== VT_CY
|| rightvt
== VT_CY
||
5484 leftvt
== VT_DATE
|| rightvt
== VT_DATE
||
5485 leftvt
== VT_I1
|| rightvt
== VT_I1
||
5486 leftvt
== VT_UI2
|| rightvt
== VT_UI2
||
5487 leftvt
== VT_UI4
|| rightvt
== VT_UI4
||
5488 leftvt
== VT_UI8
|| rightvt
== VT_UI8
||
5489 leftvt
== VT_DECIMAL
|| rightvt
== VT_DECIMAL
)
5491 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
||
5492 leftvt
== VT_I2
|| rightvt
== VT_I2
||
5493 leftvt
== VT_EMPTY
|| rightvt
== VT_EMPTY
)
5494 if ((leftvt
== VT_NULL
&& rightvt
== VT_UI1
) ||
5495 (leftvt
== VT_UI1
&& rightvt
== VT_NULL
) ||
5496 (leftvt
== VT_UI1
&& rightvt
== VT_UI1
))
5500 else if (leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
||
5501 (leftvt
== VT_BSTR
&& rightvt
== VT_BSTR
))
5503 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
||
5504 leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
)
5509 hres
= pVarAnd(&left
, &right
, &result
);
5511 /* Check expected HRESULT and if result variant type is correct */
5513 ok (hres
== DISP_E_BADVARTYPE
|| hres
== DISP_E_TYPEMISMATCH
,
5514 "VarAnd: %s|0x%X, %s|0x%X: got vt %s hr 0x%X\n",
5515 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
],
5516 vtstr(V_VT(&result
)), hres
);
5518 ok (hres
== S_OK
&& resvt
== V_VT(&result
),
5519 "VarAnd: %s|0x%X, %s|0x%X: expected vt %s hr 0x%X, got vt %s hr 0x%X\n",
5520 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
], vtstr(resvt
),
5521 S_OK
, vtstr(V_VT(&result
)), hres
);
5527 * Test returned values. Since we know the returned type is correct
5528 * and that we handle all combinations of invalid types, just check
5529 * that good type combinations produce the desired value.
5530 * FIXME: Test VT_DECIMAL
5532 VARAND(EMPTY
,0,EMPTY
,0,I2
,0);
5533 VARAND(EMPTY
,1,EMPTY
,0,I2
,0);
5534 VARAND(EMPTY
,1,EMPTY
,1,I2
,0);
5535 VARAND(EMPTY
,0,NULL
,0,I2
,0);
5536 VARAND(EMPTY
,1,NULL
,0,I2
,0);
5537 VARAND(EMPTY
,1,NULL
,1,I2
,0);
5538 VARAND(EMPTY
,0,I1
,0,I4
,0);
5539 VARAND(EMPTY
,0,I1
,1,I4
,0);
5540 VARAND(EMPTY
,1,I1
,1,I4
,0);
5541 VARAND(EMPTY
,0,UI1
,0,I2
,0);
5542 VARAND(EMPTY
,0,UI1
,1,I2
,0);
5543 VARAND(EMPTY
,1,UI1
,1,I2
,0);
5544 VARAND(EMPTY
,0,I2
,0,I2
,0);
5545 VARAND(EMPTY
,0,I2
,1,I2
,0);
5546 VARAND(EMPTY
,1,I2
,1,I2
,0);
5547 VARAND(EMPTY
,0,UI2
,0,I4
,0);
5548 VARAND(EMPTY
,0,UI2
,1,I4
,0);
5549 VARAND(EMPTY
,1,UI2
,1,I4
,0);
5550 VARAND(EMPTY
,0,I4
,0,I4
,0);
5551 VARAND(EMPTY
,0,I4
,1,I4
,0);
5552 VARAND(EMPTY
,1,I4
,1,I4
,0);
5553 VARAND(EMPTY
,0,UI4
,0,I4
,0);
5554 VARAND(EMPTY
,0,UI4
,1,I4
,0);
5555 VARAND(EMPTY
,1,UI4
,1,I4
,0);
5556 if (HAVE_OLEAUT32_I8
)
5558 VARAND(EMPTY
,0,I8
,0,I8
,0);
5559 VARAND(EMPTY
,0,I8
,1,I8
,0);
5560 VARAND(EMPTY
,1,I8
,1,I8
,0);
5561 VARAND(EMPTY
,0,UI8
,0,I4
,0);
5562 VARAND(EMPTY
,0,UI8
,1,I4
,0);
5563 VARAND(EMPTY
,1,UI8
,1,I4
,0);
5565 VARAND(EMPTY
,0,INT
,0,I4
,0);
5566 VARAND(EMPTY
,0,INT
,1,I4
,0);
5567 VARAND(EMPTY
,1,INT
,1,I4
,0);
5568 VARAND(EMPTY
,0,UINT
,0,I4
,0);
5569 VARAND(EMPTY
,0,UINT
,1,I4
,0);
5570 VARAND(EMPTY
,1,UINT
,1,I4
,0);
5571 VARAND(EMPTY
,0,BOOL
,0,I2
,0);
5572 VARAND(EMPTY
,0,BOOL
,1,I2
,0);
5573 VARAND(EMPTY
,1,BOOL
,1,I2
,0);
5574 VARAND(EMPTY
,0,R4
,0,I4
,0);
5575 VARAND(EMPTY
,0,R4
,1,I4
,0);
5576 VARAND(EMPTY
,1,R4
,1,I4
,0);
5577 VARAND(EMPTY
,0,R8
,0,I4
,0);
5578 VARAND(EMPTY
,0,R8
,1,I4
,0);
5579 VARAND(EMPTY
,1,R8
,1,I4
,0);
5580 VARAND(EMPTY
,0,BSTR
,false_str
,I2
,0);
5581 VARAND(EMPTY
,0,BSTR
,true_str
,I2
,0);
5582 VARANDCY(EMPTY
,0,10000,I4
,0);
5584 /* NULL OR 0 = NULL. NULL OR n = n */
5585 VARAND(NULL
,0,NULL
,0,NULL
,0);
5586 VARAND(NULL
,1,NULL
,0,NULL
,0);
5587 VARAND(NULL
,0,I1
,0,I4
,0);
5588 VARAND(NULL
,0,I1
,1,NULL
,0);
5589 VARAND(NULL
,0,UI1
,0,UI1
,0);
5590 VARAND(NULL
,0,UI1
,1,NULL
,0);
5591 VARAND(NULL
,0,I2
,0,I2
,0);
5592 VARAND(NULL
,0,I2
,1,NULL
,0);
5593 VARAND(NULL
,0,UI2
,0,I4
,0);
5594 VARAND(NULL
,0,UI2
,1,NULL
,0);
5595 VARAND(NULL
,0,I4
,0,I4
,0);
5596 VARAND(NULL
,0,I4
,1,NULL
,0);
5597 VARAND(NULL
,0,UI4
,0,I4
,0);
5598 VARAND(NULL
,0,UI4
,1,NULL
,0);
5599 if (HAVE_OLEAUT32_I8
)
5601 VARAND(NULL
,0,I8
,0,I8
,0);
5602 VARAND(NULL
,0,I8
,1,NULL
,0);
5603 VARAND(NULL
,0,UI8
,0,I4
,0);
5604 VARAND(NULL
,0,UI8
,1,NULL
,0);
5606 VARAND(NULL
,0,INT
,0,I4
,0);
5607 VARAND(NULL
,0,INT
,1,NULL
,0);
5608 VARAND(NULL
,0,UINT
,0,I4
,0);
5609 VARAND(NULL
,0,UINT
,1,NULL
,0);
5610 VARAND(NULL
,0,BOOL
,0,BOOL
,0);
5611 VARAND(NULL
,0,BOOL
,1,NULL
,0);
5612 VARAND(NULL
,0,R4
,0,I4
,0);
5613 VARAND(NULL
,0,R4
,1,NULL
,0);
5614 VARAND(NULL
,0,R8
,0,I4
,0);
5615 VARAND(NULL
,0,R8
,1,NULL
,0);
5616 VARAND(NULL
,0,BSTR
,false_str
,BOOL
,0);
5617 VARAND(NULL
,0,BSTR
,true_str
,NULL
,VARIANT_FALSE
);
5618 VARANDCY(NULL
,0,10000,NULL
,0);
5619 VARANDCY(NULL
,0,0,I4
,0);
5620 VARAND(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
);
5621 VARAND(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_FALSE
);
5622 VARAND(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
);
5623 VARAND(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_FALSE
);
5625 /* Assume x,y & y,x are the same from now on to reduce the number of tests */
5626 VARAND(BOOL
,VARIANT_TRUE
,I1
,-1,I4
,-1);
5627 VARAND(BOOL
,VARIANT_TRUE
,I1
,0,I4
,0);
5628 VARAND(BOOL
,VARIANT_FALSE
,I1
,0,I4
,0);
5629 VARAND(BOOL
,VARIANT_TRUE
,UI1
,255,I2
,255);
5630 VARAND(BOOL
,VARIANT_TRUE
,UI1
,0,I2
,0);
5631 VARAND(BOOL
,VARIANT_FALSE
,UI1
,0,I2
,0);
5632 VARAND(BOOL
,VARIANT_TRUE
,I2
,-1,I2
,-1);
5633 VARAND(BOOL
,VARIANT_TRUE
,I2
,0,I2
,0);
5634 VARAND(BOOL
,VARIANT_FALSE
,I2
,0,I2
,0);
5635 VARAND(BOOL
,VARIANT_TRUE
,UI2
,65535,I4
,65535);
5636 VARAND(BOOL
,VARIANT_TRUE
,UI2
,0,I4
,0);
5637 VARAND(BOOL
,VARIANT_FALSE
,UI2
,0,I4
,0);
5638 VARAND(BOOL
,VARIANT_TRUE
,I4
,-1,I4
,-1);
5639 VARAND(BOOL
,VARIANT_TRUE
,I4
,0,I4
,0);
5640 VARAND(BOOL
,VARIANT_FALSE
,I4
,0,I4
,0);
5641 VARAND(BOOL
,VARIANT_TRUE
,UI4
,0xffffffff,I4
,-1);
5642 VARAND(BOOL
,VARIANT_TRUE
,UI4
,0,I4
,0);
5643 VARAND(BOOL
,VARIANT_FALSE
,UI4
,0,I4
,0);
5644 VARAND(BOOL
,VARIANT_TRUE
,R4
,-1,I4
,-1);
5645 VARAND(BOOL
,VARIANT_TRUE
,R4
,0,I4
,0);
5646 VARAND(BOOL
,VARIANT_FALSE
,R4
,0,I4
,0);
5647 VARAND(BOOL
,VARIANT_TRUE
,R8
,-1,I4
,-1);
5648 VARAND(BOOL
,VARIANT_TRUE
,R8
,0,I4
,0);
5649 VARAND(BOOL
,VARIANT_FALSE
,R8
,0,I4
,0);
5650 VARAND(BOOL
,VARIANT_TRUE
,DATE
,-1,I4
,-1);
5651 VARAND(BOOL
,VARIANT_TRUE
,DATE
,0,I4
,0);
5652 VARAND(BOOL
,VARIANT_FALSE
,DATE
,0,I4
,0);
5653 if (HAVE_OLEAUT32_I8
)
5655 VARAND(BOOL
,VARIANT_TRUE
,I8
,-1,I8
,-1);
5656 VARAND(BOOL
,VARIANT_TRUE
,I8
,0,I8
,0);
5657 VARAND(BOOL
,VARIANT_FALSE
,I8
,0,I8
,0);
5658 VARAND(BOOL
,VARIANT_TRUE
,UI8
,0,I4
,0);
5659 VARAND(BOOL
,VARIANT_FALSE
,UI8
,0,I4
,0);
5661 VARAND(BOOL
,VARIANT_TRUE
,INT
,-1,I4
,-1);
5662 VARAND(BOOL
,VARIANT_TRUE
,INT
,0,I4
,0);
5663 VARAND(BOOL
,VARIANT_FALSE
,INT
,0,I4
,0);
5664 VARAND(BOOL
,VARIANT_TRUE
,UINT
,0xffffffff,I4
,-1);
5665 VARAND(BOOL
,VARIANT_TRUE
,UINT
,0,I4
,0);
5666 VARAND(BOOL
,VARIANT_FALSE
,UINT
,0,I4
,0);
5667 VARAND(BOOL
,VARIANT_FALSE
,BSTR
,false_str
,BOOL
,VARIANT_FALSE
);
5668 VARAND(BOOL
,VARIANT_TRUE
,BSTR
,false_str
,BOOL
,VARIANT_FALSE
);
5669 VARAND(BOOL
,VARIANT_FALSE
,BSTR
,true_str
,BOOL
,VARIANT_FALSE
);
5670 VARAND(BOOL
,VARIANT_TRUE
,BSTR
,true_str
,BOOL
,VARIANT_TRUE
);
5671 VARANDCY(BOOL
,VARIANT_TRUE
,10000,I4
,1);
5672 VARANDCY(BOOL
,VARIANT_TRUE
,0,I4
,0);
5673 VARANDCY(BOOL
,VARIANT_FALSE
,0,I4
,0);
5674 VARAND(I1
,-1,I1
,-1,I4
,-1);
5675 VARAND(I1
,-1,I1
,0,I4
,0);
5676 VARAND(I1
,0,I1
,0,I4
,0);
5677 VARAND(I1
,-1,UI1
,255,I4
,255);
5678 VARAND(I1
,-1,UI1
,0,I4
,0);
5679 VARAND(I1
,0,UI1
,0,I4
,0);
5680 VARAND(I1
,-1,I2
,-1,I4
,-1);
5681 VARAND(I1
,-1,I2
,0,I4
,0);
5682 VARAND(I1
,0,I2
,0,I4
,0);
5683 VARAND(I1
,-1,UI2
,65535,I4
,65535);
5684 VARAND(I1
,-1,UI2
,0,I4
,0);
5685 VARAND(I1
,0,UI2
,0,I4
,0);
5686 VARAND(I1
,-1,I4
,-1,I4
,-1);
5687 VARAND(I1
,-1,I4
,0,I4
,0);
5688 VARAND(I1
,0,I4
,0,I4
,0);
5689 VARAND(I1
,-1,UI4
,0xffffffff,I4
,-1);
5690 VARAND(I1
,-1,UI4
,0,I4
,0);
5691 VARAND(I1
,0,UI4
,0,I4
,0);
5692 VARAND(I1
,-1,R4
,-1,I4
,-1);
5693 VARAND(I1
,-1,R4
,0,I4
,0);
5694 VARAND(I1
,0,R4
,0,I4
,0);
5695 VARAND(I1
,-1,R8
,-1,I4
,-1);
5696 VARAND(I1
,-1,R8
,0,I4
,0);
5697 VARAND(I1
,0,R8
,0,I4
,0);
5698 VARAND(I1
,-1,DATE
,-1,I4
,-1);
5699 VARAND(I1
,-1,DATE
,0,I4
,0);
5700 VARAND(I1
,0,DATE
,0,I4
,0);
5701 if (HAVE_OLEAUT32_I8
)
5703 VARAND(I1
,-1,I8
,-1,I8
,-1);
5704 VARAND(I1
,-1,I8
,0,I8
,0);
5705 VARAND(I1
,0,I8
,0,I8
,0);
5706 VARAND(I1
,-1,UI8
,0,I4
,0);
5707 VARAND(I1
,0,UI8
,0,I4
,0);
5709 VARAND(I1
,-1,INT
,-1,I4
,-1);
5710 VARAND(I1
,-1,INT
,0,I4
,0);
5711 VARAND(I1
,0,INT
,0,I4
,0);
5712 VARAND(I1
,-1,UINT
,0xffffffff,I4
,-1);
5713 VARAND(I1
,-1,UINT
,0,I4
,0);
5714 VARAND(I1
,0,UINT
,0,I4
,0);
5715 VARAND(I1
,0,BSTR
,false_str
,I4
,0);
5716 VARAND(I1
,-1,BSTR
,false_str
,I4
,0);
5717 VARAND(I1
,0,BSTR
,true_str
,I4
,0);
5718 VARAND(I1
,-1,BSTR
,true_str
,I4
,-1);
5719 VARANDCY(I1
,-1,10000,I4
,1);
5720 VARANDCY(I1
,-1,0,I4
,0);
5721 VARANDCY(I1
,0,0,I4
,0);
5723 VARAND(UI1
,255,UI1
,255,UI1
,255);
5724 VARAND(UI1
,255,UI1
,0,UI1
,0);
5725 VARAND(UI1
,0,UI1
,0,UI1
,0);
5726 VARAND(UI1
,255,I2
,-1,I2
,255);
5727 VARAND(UI1
,255,I2
,0,I2
,0);
5728 VARAND(UI1
,0,I2
,0,I2
,0);
5729 VARAND(UI1
,255,UI2
,65535,I4
,255);
5730 VARAND(UI1
,255,UI2
,0,I4
,0);
5731 VARAND(UI1
,0,UI2
,0,I4
,0);
5732 VARAND(UI1
,255,I4
,-1,I4
,255);
5733 VARAND(UI1
,255,I4
,0,I4
,0);
5734 VARAND(UI1
,0,I4
,0,I4
,0);
5735 VARAND(UI1
,255,UI4
,0xffffffff,I4
,255);
5736 VARAND(UI1
,255,UI4
,0,I4
,0);
5737 VARAND(UI1
,0,UI4
,0,I4
,0);
5738 VARAND(UI1
,255,R4
,-1,I4
,255);
5739 VARAND(UI1
,255,R4
,0,I4
,0);
5740 VARAND(UI1
,0,R4
,0,I4
,0);
5741 VARAND(UI1
,255,R8
,-1,I4
,255);
5742 VARAND(UI1
,255,R8
,0,I4
,0);
5743 VARAND(UI1
,0,R8
,0,I4
,0);
5744 VARAND(UI1
,255,DATE
,-1,I4
,255);
5745 VARAND(UI1
,255,DATE
,0,I4
,0);
5746 VARAND(UI1
,0,DATE
,0,I4
,0);
5747 if (HAVE_OLEAUT32_I8
)
5749 VARAND(UI1
,255,I8
,-1,I8
,255);
5750 VARAND(UI1
,255,I8
,0,I8
,0);
5751 VARAND(UI1
,0,I8
,0,I8
,0);
5752 VARAND(UI1
,255,UI8
,0,I4
,0);
5753 VARAND(UI1
,0,UI8
,0,I4
,0);
5755 VARAND(UI1
,255,INT
,-1,I4
,255);
5756 VARAND(UI1
,255,INT
,0,I4
,0);
5757 VARAND(UI1
,0,INT
,0,I4
,0);
5758 VARAND(UI1
,255,UINT
,0xffffffff,I4
,255);
5759 VARAND(UI1
,255,UINT
,0,I4
,0);
5760 VARAND(UI1
,0,UINT
,0,I4
,0);
5761 VARAND(UI1
,0,BSTR
,false_str
,I2
,0);
5762 VARAND(UI1
,255,BSTR
,false_str
,I2
,0);
5763 VARAND(UI1
,0,BSTR
,true_str
,I2
,0);
5764 VARAND(UI1
,255,BSTR
,true_str
,I2
,255);
5765 VARANDCY(UI1
,255,10000,I4
,1);
5766 VARANDCY(UI1
,255,0,I4
,0);
5767 VARANDCY(UI1
,0,0,I4
,0);
5769 VARAND(I2
,-1,I2
,-1,I2
,-1);
5770 VARAND(I2
,-1,I2
,0,I2
,0);
5771 VARAND(I2
,0,I2
,0,I2
,0);
5772 VARAND(I2
,-1,UI2
,65535,I4
,65535);
5773 VARAND(I2
,-1,UI2
,0,I4
,0);
5774 VARAND(I2
,0,UI2
,0,I4
,0);
5775 VARAND(I2
,-1,I4
,-1,I4
,-1);
5776 VARAND(I2
,-1,I4
,0,I4
,0);
5777 VARAND(I2
,0,I4
,0,I4
,0);
5778 VARAND(I2
,-1,UI4
,0xffffffff,I4
,-1);
5779 VARAND(I2
,-1,UI4
,0,I4
,0);
5780 VARAND(I2
,0,UI4
,0,I4
,0);
5781 VARAND(I2
,-1,R4
,-1,I4
,-1);
5782 VARAND(I2
,-1,R4
,0,I4
,0);
5783 VARAND(I2
,0,R4
,0,I4
,0);
5784 VARAND(I2
,-1,R8
,-1,I4
,-1);
5785 VARAND(I2
,-1,R8
,0,I4
,0);
5786 VARAND(I2
,0,R8
,0,I4
,0);
5787 VARAND(I2
,-1,DATE
,-1,I4
,-1);
5788 VARAND(I2
,-1,DATE
,0,I4
,0);
5789 VARAND(I2
,0,DATE
,0,I4
,0);
5790 if (HAVE_OLEAUT32_I8
)
5792 VARAND(I2
,-1,I8
,-1,I8
,-1);
5793 VARAND(I2
,-1,I8
,0,I8
,0);
5794 VARAND(I2
,0,I8
,0,I8
,0);
5795 VARAND(I2
,-1,UI8
,0,I4
,0);
5796 VARAND(I2
,0,UI8
,0,I4
,0);
5798 VARAND(I2
,-1,INT
,-1,I4
,-1);
5799 VARAND(I2
,-1,INT
,0,I4
,0);
5800 VARAND(I2
,0,INT
,0,I4
,0);
5801 VARAND(I2
,-1,UINT
,0xffffffff,I4
,-1);
5802 VARAND(I2
,-1,UINT
,0,I4
,0);
5803 VARAND(I2
,0,UINT
,0,I4
,0);
5804 VARAND(I2
,0,BSTR
,false_str
,I2
,0);
5805 VARAND(I2
,-1,BSTR
,false_str
,I2
,0);
5806 VARAND(I2
,0,BSTR
,true_str
,I2
,0);
5807 VARAND(I2
,-1,BSTR
,true_str
,I2
,-1);
5808 VARANDCY(I2
,-1,10000,I4
,1);
5809 VARANDCY(I2
,-1,0,I4
,0);
5810 VARANDCY(I2
,0,0,I4
,0);
5812 VARAND(UI2
,65535,UI2
,65535,I4
,65535);
5813 VARAND(UI2
,65535,UI2
,0,I4
,0);
5814 VARAND(UI2
,0,UI2
,0,I4
,0);
5815 VARAND(UI2
,65535,I4
,-1,I4
,65535);
5816 VARAND(UI2
,65535,I4
,0,I4
,0);
5817 VARAND(UI2
,0,I4
,0,I4
,0);
5818 VARAND(UI2
,65535,UI4
,0xffffffff,I4
,65535);
5819 VARAND(UI2
,65535,UI4
,0,I4
,0);
5820 VARAND(UI2
,0,UI4
,0,I4
,0);
5821 VARAND(UI2
,65535,R4
,-1,I4
,65535);
5822 VARAND(UI2
,65535,R4
,0,I4
,0);
5823 VARAND(UI2
,0,R4
,0,I4
,0);
5824 VARAND(UI2
,65535,R8
,-1,I4
,65535);
5825 VARAND(UI2
,65535,R8
,0,I4
,0);
5826 VARAND(UI2
,0,R8
,0,I4
,0);
5827 VARAND(UI2
,65535,DATE
,-1,I4
,65535);
5828 VARAND(UI2
,65535,DATE
,0,I4
,0);
5829 VARAND(UI2
,0,DATE
,0,I4
,0);
5830 if (HAVE_OLEAUT32_I8
)
5832 VARAND(UI2
,65535,I8
,-1,I8
,65535);
5833 VARAND(UI2
,65535,I8
,0,I8
,0);
5834 VARAND(UI2
,0,I8
,0,I8
,0);
5835 VARAND(UI2
,65535,UI8
,0,I4
,0);
5836 VARAND(UI2
,0,UI8
,0,I4
,0);
5838 VARAND(UI2
,65535,INT
,-1,I4
,65535);
5839 VARAND(UI2
,65535,INT
,0,I4
,0);
5840 VARAND(UI2
,0,INT
,0,I4
,0);
5841 VARAND(UI2
,65535,UINT
,0xffffffff,I4
,65535);
5842 VARAND(UI2
,65535,UINT
,0,I4
,0);
5843 VARAND(UI2
,0,UINT
,0,I4
,0);
5844 VARAND(UI2
,0,BSTR
,false_str
,I4
,0);
5845 VARAND(UI2
,65535,BSTR
,false_str
,I4
,0);
5846 VARAND(UI2
,0,BSTR
,true_str
,I4
,0);
5847 VARAND(UI2
,65535,BSTR
,true_str
,I4
,65535);
5848 VARANDCY(UI2
,65535,10000,I4
,1);
5849 VARANDCY(UI2
,65535,0,I4
,0);
5850 VARANDCY(UI2
,0,0,I4
,0);
5852 VARAND(I4
,-1,I4
,-1,I4
,-1);
5853 VARAND(I4
,-1,I4
,0,I4
,0);
5854 VARAND(I4
,0,I4
,0,I4
,0);
5855 VARAND(I4
,-1,UI4
,0xffffffff,I4
,-1);
5856 VARAND(I4
,-1,UI4
,0,I4
,0);
5857 VARAND(I4
,0,UI4
,0,I4
,0);
5858 VARAND(I4
,-1,R4
,-1,I4
,-1);
5859 VARAND(I4
,-1,R4
,0,I4
,0);
5860 VARAND(I4
,0,R4
,0,I4
,0);
5861 VARAND(I4
,-1,R8
,-1,I4
,-1);
5862 VARAND(I4
,-1,R8
,0,I4
,0);
5863 VARAND(I4
,0,R8
,0,I4
,0);
5864 VARAND(I4
,-1,DATE
,-1,I4
,-1);
5865 VARAND(I4
,-1,DATE
,0,I4
,0);
5866 VARAND(I4
,0,DATE
,0,I4
,0);
5867 if (HAVE_OLEAUT32_I8
)
5869 VARAND(I4
,-1,I8
,-1,I8
,-1);
5870 VARAND(I4
,-1,I8
,0,I8
,0);
5871 VARAND(I4
,0,I8
,0,I8
,0);
5872 VARAND(I4
,-1,UI8
,0,I4
,0);
5873 VARAND(I4
,0,UI8
,0,I4
,0);
5875 VARAND(I4
,-1,INT
,-1,I4
,-1);
5876 VARAND(I4
,-1,INT
,0,I4
,0);
5877 VARAND(I4
,0,INT
,0,I4
,0);
5878 VARAND(I4
,-1,UINT
,0xffffffff,I4
,-1);
5879 VARAND(I4
,-1,UINT
,0,I4
,0);
5880 VARAND(I4
,0,UINT
,0,I4
,0);
5881 VARAND(I4
,0,BSTR
,false_str
,I4
,0);
5882 VARAND(I4
,-1,BSTR
,false_str
,I4
,0);
5883 VARAND(I4
,0,BSTR
,true_str
,I4
,0);
5884 VARAND(I4
,-1,BSTR
,true_str
,I4
,-1);
5885 VARANDCY(I4
,-1,10000,I4
,1);
5886 VARANDCY(I4
,-1,0,I4
,0);
5887 VARANDCY(I4
,0,0,I4
,0);
5889 VARAND(UI4
,0xffffffff,UI4
,0xffffffff,I4
,-1);
5890 VARAND(UI4
,0xffffffff,UI4
,0,I4
,0);
5891 VARAND(UI4
,0,UI4
,0,I4
,0);
5892 VARAND(UI4
,0xffffffff,R4
,-1,I4
,-1);
5893 VARAND(UI4
,0xffffffff,R4
,0,I4
,0);
5894 VARAND(UI4
,0,R4
,0,I4
,0);
5895 VARAND(UI4
,0xffffffff,R8
,-1,I4
,-1);
5896 VARAND(UI4
,0xffffffff,R8
,0,I4
,0);
5897 VARAND(UI4
,0,R8
,0,I4
,0);
5898 VARAND(UI4
,0xffffffff,DATE
,-1,I4
,-1);
5899 VARAND(UI4
,0xffffffff,DATE
,0,I4
,0);
5900 VARAND(UI4
,0,DATE
,0,I4
,0);
5901 if (HAVE_OLEAUT32_I8
)
5903 VARAND(UI4
,0xffffffff,I8
,0,I8
,0);
5904 VARAND(UI4
,0,I8
,0,I8
,0);
5905 VARAND(UI4
,0xffffffff,UI8
,0,I4
,0);
5906 VARAND(UI4
,0,UI8
,0,I4
,0);
5908 VARAND(UI4
,0xffffffff,INT
,-1,I4
,-1);
5909 VARAND(UI4
,0xffffffff,INT
,0,I4
,0);
5910 VARAND(UI4
,0,INT
,0,I4
,0);
5911 VARAND(UI4
,0xffffffff,UINT
,0xffffffff,I4
,-1);
5912 VARAND(UI4
,0xffffffff,UINT
,0,I4
,0);
5913 VARAND(UI4
,0,UINT
,0,I4
,0);
5914 VARAND(UI4
,0,BSTR
,false_str
,I4
,0);
5915 VARAND(UI4
,0xffffffff,BSTR
,false_str
,I4
,0);
5916 VARAND(UI4
,0,BSTR
,true_str
,I4
,0);
5917 VARAND(UI4
,0xffffffff,BSTR
,true_str
,I4
,-1);
5918 VARANDCY(UI4
,0xffffffff,10000,I4
,1);
5919 VARANDCY(UI4
,0xffffffff,0,I4
,0);
5920 VARANDCY(UI4
,0,0,I4
,0);
5922 VARAND(R4
,-1,R4
,-1,I4
,-1);
5923 VARAND(R4
,-1,R4
,0,I4
,0);
5924 VARAND(R4
,0,R4
,0,I4
,0);
5925 VARAND(R4
,-1,R8
,-1,I4
,-1);
5926 VARAND(R4
,-1,R8
,0,I4
,0);
5927 VARAND(R4
,0,R8
,0,I4
,0);
5928 VARAND(R4
,-1,DATE
,-1,I4
,-1);
5929 VARAND(R4
,-1,DATE
,0,I4
,0);
5930 VARAND(R4
,0,DATE
,0,I4
,0);
5931 if (HAVE_OLEAUT32_I8
)
5933 VARAND(R4
,-1,I8
,-1,I8
,-1);
5934 VARAND(R4
,-1,I8
,0,I8
,0);
5935 VARAND(R4
,0,I8
,0,I8
,0);
5936 VARAND(R4
,-1,UI8
,0,I4
,0);
5937 VARAND(R4
,0,UI8
,0,I4
,0);
5939 VARAND(R4
,-1,INT
,-1,I4
,-1);
5940 VARAND(R4
,-1,INT
,0,I4
,0);
5941 VARAND(R4
,0,INT
,0,I4
,0);
5942 VARAND(R4
,-1,UINT
,0xffffffff,I4
,-1);
5943 VARAND(R4
,-1,UINT
,0,I4
,0);
5944 VARAND(R4
,0,UINT
,0,I4
,0);
5945 VARAND(R4
,0,BSTR
,false_str
,I4
,0);
5946 VARAND(R4
,-1,BSTR
,false_str
,I4
,0);
5947 VARAND(R4
,0,BSTR
,true_str
,I4
,0);
5948 VARAND(R4
,-1,BSTR
,true_str
,I4
,-1);
5949 VARANDCY(R4
,-1,10000,I4
,1);
5950 VARANDCY(R4
,-1,0,I4
,0);
5951 VARANDCY(R4
,0,0,I4
,0);
5953 VARAND(R8
,-1,R8
,-1,I4
,-1);
5954 VARAND(R8
,-1,R8
,0,I4
,0);
5955 VARAND(R8
,0,R8
,0,I4
,0);
5956 VARAND(R8
,-1,DATE
,-1,I4
,-1);
5957 VARAND(R8
,-1,DATE
,0,I4
,0);
5958 VARAND(R8
,0,DATE
,0,I4
,0);
5959 if (HAVE_OLEAUT32_I8
)
5961 VARAND(R8
,-1,I8
,-1,I8
,-1);
5962 VARAND(R8
,-1,I8
,0,I8
,0);
5963 VARAND(R8
,0,I8
,0,I8
,0);
5964 VARAND(R8
,-1,UI8
,0,I4
,0);
5965 VARAND(R8
,0,UI8
,0,I4
,0);
5967 VARAND(R8
,-1,INT
,-1,I4
,-1);
5968 VARAND(R8
,-1,INT
,0,I4
,0);
5969 VARAND(R8
,0,INT
,0,I4
,0);
5970 VARAND(R8
,-1,UINT
,0xffffffff,I4
,-1);
5971 VARAND(R8
,-1,UINT
,0,I4
,0);
5972 VARAND(R8
,0,UINT
,0,I4
,0);
5973 VARAND(R8
,0,BSTR
,false_str
,I4
,0);
5974 VARAND(R8
,-1,BSTR
,false_str
,I4
,0);
5975 VARAND(R8
,0,BSTR
,true_str
,I4
,0);
5976 VARAND(R8
,-1,BSTR
,true_str
,I4
,-1);
5977 VARANDCY(R8
,-1,10000,I4
,1);
5978 VARANDCY(R8
,-1,0,I4
,0);
5979 VARANDCY(R8
,0,0,I4
,0);
5981 VARAND(DATE
,-1,DATE
,-1,I4
,-1);
5982 VARAND(DATE
,-1,DATE
,0,I4
,0);
5983 VARAND(DATE
,0,DATE
,0,I4
,0);
5984 if (HAVE_OLEAUT32_I8
)
5986 VARAND(DATE
,-1,I8
,-1,I8
,-1);
5987 VARAND(DATE
,-1,I8
,0,I8
,0);
5988 VARAND(DATE
,0,I8
,0,I8
,0);
5989 VARAND(DATE
,-1,UI8
,0,I4
,0);
5990 VARAND(DATE
,0,UI8
,0,I4
,0);
5992 VARAND(DATE
,-1,INT
,-1,I4
,-1);
5993 VARAND(DATE
,-1,INT
,0,I4
,0);
5994 VARAND(DATE
,0,INT
,0,I4
,0);
5995 VARAND(DATE
,-1,UINT
,0xffffffff,I4
,-1);
5996 VARAND(DATE
,-1,UINT
,0,I4
,0);
5997 VARAND(DATE
,0,UINT
,0,I4
,0);
5998 VARAND(DATE
,0,BSTR
,false_str
,I4
,0);
5999 VARAND(DATE
,-1,BSTR
,false_str
,I4
,0);
6000 VARAND(DATE
,0,BSTR
,true_str
,I4
,0);
6001 VARAND(DATE
,-1,BSTR
,true_str
,I4
,-1);
6002 VARANDCY(DATE
,-1,10000,I4
,1);
6003 VARANDCY(DATE
,-1,0,I4
,0);
6004 VARANDCY(DATE
,0,0,I4
,0);
6006 if (HAVE_OLEAUT32_I8
)
6008 VARAND(I8
,-1,I8
,-1,I8
,-1);
6009 VARAND(I8
,-1,I8
,0,I8
,0);
6010 VARAND(I8
,0,I8
,0,I8
,0);
6011 VARAND(I8
,-1,UI8
,0,I8
,0);
6012 VARAND(I8
,0,UI8
,0,I8
,0);
6013 VARAND(I8
,-1,UINT
,0,I8
,0);
6014 VARAND(I8
,0,UINT
,0,I8
,0);
6015 VARAND(I8
,0,BSTR
,false_str
,I8
,0);
6016 VARAND(I8
,-1,BSTR
,false_str
,I8
,0);
6017 VARAND(I8
,0,BSTR
,true_str
,I8
,0);
6018 VARAND(I8
,-1,BSTR
,true_str
,I8
,-1);
6019 VARANDCY(I8
,-1,10000,I8
,1);
6020 VARANDCY(I8
,-1,0,I8
,0);
6021 VARANDCY(I8
,0,0,I8
,0);
6023 VARAND(UI8
,0xffff,UI8
,0xffff,I4
,0xffff);
6024 VARAND(UI8
,0xffff,UI8
,0,I4
,0);
6025 VARAND(UI8
,0,UI8
,0,I4
,0);
6026 VARAND(UI8
,0xffff,INT
,-1,I4
,65535);
6027 VARAND(UI8
,0xffff,INT
,0,I4
,0);
6028 VARAND(UI8
,0,INT
,0,I4
,0);
6029 VARAND(UI8
,0xffff,UINT
,0xffff,I4
,0xffff);
6030 VARAND(UI8
,0xffff,UINT
,0,I4
,0);
6031 VARAND(UI8
,0,UINT
,0,I4
,0);
6032 VARAND(UI8
,0,BSTR
,false_str
,I4
,0);
6033 VARAND(UI8
,0xffff,BSTR
,false_str
,I4
,0);
6034 VARAND(UI8
,0,BSTR
,true_str
,I4
,0);
6035 VARAND(UI8
,0xffff,BSTR
,true_str
,I4
,65535);
6036 VARANDCY(UI8
,0xffff,10000,I4
,1);
6037 VARANDCY(UI8
,0xffff,0,I4
,0);
6038 VARANDCY(UI8
,0,0,I4
,0);
6041 VARAND(INT
,-1,INT
,-1,I4
,-1);
6042 VARAND(INT
,-1,INT
,0,I4
,0);
6043 VARAND(INT
,0,INT
,0,I4
,0);
6044 VARAND(INT
,-1,UINT
,0xffff,I4
,65535);
6045 VARAND(INT
,-1,UINT
,0,I4
,0);
6046 VARAND(INT
,0,UINT
,0,I4
,0);
6047 VARAND(INT
,0,BSTR
,false_str
,I4
,0);
6048 VARAND(INT
,-1,BSTR
,false_str
,I4
,0);
6049 VARAND(INT
,0,BSTR
,true_str
,I4
,0);
6050 VARAND(INT
,-1,BSTR
,true_str
,I4
,-1);
6051 VARANDCY(INT
,-1,10000,I4
,1);
6052 VARANDCY(INT
,-1,0,I4
,0);
6053 VARANDCY(INT
,0,0,I4
,0);
6055 VARAND(UINT
,0xffff,UINT
,0xffff,I4
,0xffff);
6056 VARAND(UINT
,0xffff,UINT
,0,I4
,0);
6057 VARAND(UINT
,0,UINT
,0,I4
,0);
6058 VARAND(UINT
,0,BSTR
,false_str
,I4
,0);
6059 VARAND(UINT
,0xffff,BSTR
, false_str
,I4
,0);
6060 VARAND(UINT
,0,BSTR
,true_str
,I4
,0);
6061 VARAND(UINT
,0xffff,BSTR
,true_str
,I4
,65535);
6062 VARANDCY(UINT
,0xffff,10000,I4
,1);
6063 VARANDCY(UINT
,0xffff,0,I4
,0);
6064 VARANDCY(UINT
,0,0,I4
,0);
6066 VARAND(BSTR
,false_str
,BSTR
,false_str
,BOOL
,0);
6067 VARAND(BSTR
,true_str
,BSTR
,false_str
,BOOL
,VARIANT_FALSE
);
6068 VARAND(BSTR
,true_str
,BSTR
,true_str
,BOOL
,VARIANT_TRUE
);
6069 VARANDCY(BSTR
,true_str
,10000,I4
,1);
6070 VARANDCY(BSTR
,false_str
,10000,I4
,0);
6072 SysFreeString(true_str
);
6073 SysFreeString(false_str
);
6076 static HRESULT (WINAPI
*pVarCmp
)(LPVARIANT
,LPVARIANT
,LCID
,ULONG
);
6078 static void test_cmp( int line
, LCID lcid
, UINT flags
, VARIANT
*left
, VARIANT
*right
, HRESULT result
)
6082 hres
= pVarCmp(left
,right
,lcid
,flags
);
6083 ok_(__FILE__
,line
)(hres
== result
, "VarCmp(%s,%s): expected 0x%x, got hres=0x%x\n",
6084 variantstr(left
), variantstr(right
), result
, hres
);
6086 static void test_cmpex( int line
, LCID lcid
, VARIANT
*left
, VARIANT
*right
,
6087 HRESULT res1
, HRESULT res2
, HRESULT res3
, HRESULT res4
)
6089 test_cmp( line
, lcid
, 0, left
, right
, res1
);
6090 V_VT(left
) |= VT_RESERVED
;
6091 test_cmp( line
, lcid
, 0, left
, right
, res2
);
6092 V_VT(left
) &= ~VT_RESERVED
;
6093 V_VT(right
) |= VT_RESERVED
;
6094 test_cmp( line
, lcid
, 0, left
, right
, res3
);
6095 V_VT(left
) |= VT_RESERVED
;
6096 test_cmp( line
, lcid
, 0, left
, right
, res4
);
6097 ok_(__FILE__
,line
)(V_VT(left
) & V_VT(right
) & VT_RESERVED
, "VT_RESERVED filtered out\n");
6100 /* ERROR from wingdi.h is interfering here */
6102 #define _VARCMP(vt1,val1,vtfl1,vt2,val2,vtfl2,lcid,flags,result) \
6103 V_##vt1(&left) = val1; V_VT(&left) = VT_##vt1 | vtfl1; \
6104 V_##vt2(&right) = val2; V_VT(&right) = VT_##vt2 | vtfl2; \
6105 test_cmp( __LINE__, lcid, flags, &left, &right, result )
6106 #define VARCMPEX(vt1,val1,vt2,val2,res1,res2,res3,res4) \
6107 V_##vt1(&left) = val1; V_VT(&left) = VT_##vt1; \
6108 V_##vt2(&right) = val2; V_VT(&right) = VT_##vt2; \
6109 test_cmpex( __LINE__, lcid, &left, &right, res1, res2, res3, res4 )
6110 #define VARCMP(vt1,val1,vt2,val2,result) \
6111 VARCMPEX(vt1,val1,vt2,val2,result,result,result,result)
6112 /* The above macros do not work for VT_NULL as NULL gets expanded first */
6113 #define V_NULL_ V_NULL
6114 #define VT_NULL_ VT_NULL
6116 static void test_VarCmp(void)
6118 VARIANT left
, right
;
6123 static const WCHAR szhuh
[] = {'h','u','h','?','\0'};
6124 static const WCHAR sz2cents
[] = {'2','c','e','n','t','s','\0'};
6125 static const WCHAR szempty
[] = {'\0'};
6126 static const WCHAR sz0
[] = {'0','\0'};
6127 static const WCHAR sz1
[] = {'1','\0'};
6128 static const WCHAR sz7
[] = {'7','\0'};
6129 static const WCHAR sz42
[] = {'4','2','\0'};
6130 static const WCHAR sz1neg
[] = {'-','1','\0'};
6131 static const WCHAR sz666neg
[] = {'-','6','6','6','\0'};
6132 static const WCHAR sz1few
[] = {'1','.','0','0','0','0','0','0','0','1','\0'};
6133 BSTR bstrhuh
, bstrempty
, bstr0
, bstr1
, bstr7
, bstr42
, bstr1neg
, bstr666neg
;
6134 BSTR bstr2cents
, bstr1few
;
6138 lcid
= MAKELCID(MAKELANGID(LANG_ENGLISH
,SUBLANG_ENGLISH_US
),SORT_DEFAULT
);
6139 bstrempty
= SysAllocString(szempty
);
6140 bstrhuh
= SysAllocString(szhuh
);
6141 bstr2cents
= SysAllocString(sz2cents
);
6142 bstr0
= SysAllocString(sz0
);
6143 bstr1
= SysAllocString(sz1
);
6144 bstr7
= SysAllocString(sz7
);
6145 bstr42
= SysAllocString(sz42
);
6146 bstr1neg
= SysAllocString(sz1neg
);
6147 bstr666neg
= SysAllocString(sz666neg
);
6148 bstr1few
= SysAllocString(sz1few
);
6150 /* Test all possible flag/vt combinations & the resulting vt type */
6151 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
6153 VARTYPE leftvt
, rightvt
;
6155 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
6160 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
6163 HRESULT expect
= VARCMP_EQ
;
6167 memset(&left
, 0, sizeof(left
));
6168 memset(&right
, 0, sizeof(right
));
6169 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
6170 if (leftvt
== VT_BSTR
) {
6171 V_BSTR(&left
) = bstr1neg
;
6172 if (ExtraFlags
[i
] & VT_RESERVED
)
6177 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
6178 if (rightvt
== VT_BSTR
) {
6179 V_BSTR(&right
) = bstr1neg
;
6180 if (ExtraFlags
[i
] & VT_RESERVED
)
6186 /* Don't ask me why but native VarCmp cannot handle:
6187 VT_I1, VT_UI2, VT_UI4, VT_UINT and VT_UI8.
6188 VT_INT is only supported as left variant. Go figure.
6189 Tested with DCOM98, Win2k, WinXP */
6190 if (ExtraFlags
[i
] & VT_ARRAY
|| ExtraFlags
[i
] & VT_BYREF
||
6191 !IsValidVariantClearVT(leftvt
, ExtraFlags
[i
] & ~VT_RESERVED
) ||
6192 !IsValidVariantClearVT(rightvt
, ExtraFlags
[i
] & ~VT_RESERVED
) ||
6193 leftvt
== VT_CLSID
|| rightvt
== VT_CLSID
||
6194 leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
||
6195 leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
||
6196 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
||
6197 leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
||
6198 leftvt
== VT_VARIANT
|| rightvt
== VT_VARIANT
||
6199 leftvt
== VT_I1
|| rightvt
== VT_I1
||
6200 leftvt
== VT_UI2
|| rightvt
== VT_UI2
||
6201 leftvt
== VT_UI4
|| rightvt
== VT_UI4
||
6202 leftvt
== VT_UI8
|| rightvt
== VT_UI8
||
6203 rightvt
== VT_INT
||
6204 leftvt
== VT_UINT
|| rightvt
== VT_UINT
) {
6208 if (leftvt
== VT_ERROR
&& rightvt
== VT_ERROR
&&
6209 !(ExtraFlags
[i
] & ~VT_RESERVED
)) {
6212 } else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
6213 expect
= VARCMP_NULL
;
6214 else if (leftvt
== VT_BSTR
&& rightvt
== VT_BSTR
)
6216 else if (leftvt
== VT_BSTR
&& rightvt
== VT_EMPTY
)
6218 else if (leftvt
== VT_EMPTY
&& rightvt
== VT_BSTR
)
6221 hres
= pVarCmp(&left
, &right
, LOCALE_USER_DEFAULT
, 0);
6223 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
6224 "VarCmp: %d|0x%X, %d|0x%X: Expected failure, got 0x%X\n",
6225 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], hres
);
6228 "VarCmp: %d|0x%X, %d|0x%X: Expected 0x%X, got 0x%X\n",
6229 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], expect
,
6236 /* VARCMP{,EX} run each 4 tests with a permutation of all posible
6237 input variants with (1) and without (0) VT_RESERVED set. The order
6238 of the permutations is (0,0); (1,0); (0,1); (1,1) */
6239 VARCMP(INT
,4711,I2
,4711,VARCMP_EQ
);
6240 VARCMP(INT
,4711,I2
,-4711,VARCMP_GT
);
6241 VARCMP(ERROR
,0,ERROR
,0,VARCMP_EQ
);
6242 VARCMP(ERROR
,0,UI1
,0,DISP_E_TYPEMISMATCH
);
6243 VARCMP(EMPTY
,0,EMPTY
,0,VARCMP_EQ
);
6244 VARCMP(I4
,1,R8
,1.0,VARCMP_EQ
);
6245 VARCMP(EMPTY
,19,I2
,0,VARCMP_EQ
);
6246 ok(V_EMPTY(&left
) == 19, "VT_EMPTY modified!\n");
6247 VARCMP(I4
,1,UI1
,1,VARCMP_EQ
);
6248 VARCMP(I2
,2,I2
,2,VARCMP_EQ
);
6249 VARCMP(I2
,1,I2
,2,VARCMP_LT
);
6250 VARCMP(I2
,2,I2
,1,VARCMP_GT
);
6251 VARCMP(I2
,2,EMPTY
,1,VARCMP_GT
);
6252 VARCMP(I2
,2,NULL_
,1,VARCMP_NULL
);
6254 /* BSTR handling, especially in conjunction with VT_RESERVED */
6255 VARCMP(BSTR
,bstr0
,NULL_
,0,VARCMP_NULL
);
6256 VARCMP(BSTR
,bstr0
,BSTR
,bstr0
,VARCMP_EQ
);
6257 VARCMP(BSTR
,bstrempty
,BSTR
,bstr0
,VARCMP_LT
);
6258 VARCMP(BSTR
,bstr7
,BSTR
,bstr0
,VARCMP_GT
);
6259 VARCMP(BSTR
,bstr7
,BSTR
,bstr1neg
,VARCMP_GT
);
6260 VARCMP(BSTR
,bstr0
,BSTR
,NULL
,VARCMP_GT
);
6261 VARCMP(BSTR
,NULL
,BSTR
,NULL
,VARCMP_EQ
);
6262 VARCMP(BSTR
,bstrempty
,BSTR
,NULL
,VARCMP_EQ
);
6263 VARCMP(BSTR
,NULL
,EMPTY
,0,VARCMP_EQ
);
6264 VARCMP(EMPTY
,0,BSTR
,NULL
,VARCMP_EQ
);
6265 VARCMP(EMPTY
,0,BSTR
,bstrempty
,VARCMP_EQ
);
6266 VARCMP(EMPTY
,1,BSTR
,bstrempty
,VARCMP_EQ
);
6267 VARCMP(BSTR
,bstr0
,EMPTY
,0,VARCMP_GT
);
6268 VARCMP(BSTR
,bstr42
,EMPTY
,0,VARCMP_GT
);
6269 VARCMPEX(BSTR
,bstrempty
,UI1
,0,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
6270 VARCMPEX(BSTR
,bstrempty
,I2
,-1,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
6271 VARCMPEX(I4
,0,BSTR
,bstrempty
,VARCMP_LT
,VARCMP_LT
,VARCMP_GT
,VARCMP_LT
);
6272 VARCMPEX(BSTR
,NULL
,UI1
,0,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
6273 VARCMPEX(I4
,7,BSTR
,NULL
,VARCMP_LT
,VARCMP_LT
,VARCMP_GT
,VARCMP_LT
);
6274 _VARCMP(BSTR
,(BSTR
)100,0,I2
,100,0,lcid
,0,VARCMP_GT
);
6275 VARCMPEX(BSTR
,bstr0
,UI1
,0,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_GT
);
6276 VARCMPEX(I2
,0,BSTR
,bstr0
,VARCMP_LT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_LT
);
6277 VARCMP(BSTR
,bstrhuh
,I4
,I4_MAX
,VARCMP_GT
);
6278 VARCMP(BSTR
,bstr2cents
,I4
,2,VARCMP_GT
);
6279 VARCMPEX(BSTR
,bstr2cents
,I4
,42,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
6280 VARCMP(BSTR
,bstr2cents
,I4
,-1,VARCMP_GT
);
6281 VARCMPEX(BSTR
,bstr2cents
,I4
,-666,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
6282 VARCMPEX(BSTR
,bstr0
,I2
,0,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_GT
);
6283 VARCMPEX(BSTR
,bstr0
,I4
,0,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_GT
);
6284 VARCMPEX(BSTR
,bstr0
,I4
,-666,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
6285 VARCMP(BSTR
,bstr1
,I4
,0,VARCMP_GT
);
6286 VARCMPEX(BSTR
,bstr1
,I4
,1,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_GT
);
6287 VARCMPEX(BSTR
,bstr1
,I4
,I4_MAX
,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
,VARCMP_GT
);
6288 VARCMPEX(BSTR
,bstr1
,I4
,-1,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
6289 VARCMP(BSTR
,bstr7
,I4
,1,VARCMP_GT
);
6290 VARCMPEX(BSTR
,bstr7
,I4
,7,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_GT
);
6291 VARCMPEX(BSTR
,bstr7
,I4
,42,VARCMP_GT
,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
);
6292 VARCMPEX(BSTR
,bstr42
,I4
,7,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
6293 VARCMPEX(BSTR
,bstr42
,I4
,42,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_GT
);
6294 VARCMPEX(BSTR
,bstr42
,I4
,I4_MAX
,VARCMP_GT
,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
);
6295 VARCMPEX(BSTR
,bstr1neg
,I4
,1,VARCMP_GT
,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
);
6296 VARCMPEX(BSTR
,bstr1neg
,I4
,42,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
,VARCMP_LT
);
6297 VARCMPEX(BSTR
,bstr1neg
,I4
,-1,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_LT
);
6298 VARCMPEX(BSTR
,bstr1neg
,I4
,-666,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_LT
);
6299 VARCMPEX(BSTR
,bstr666neg
,I4
,1,VARCMP_GT
,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
);
6300 VARCMPEX(BSTR
,bstr666neg
,I4
,7,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
,VARCMP_LT
);
6301 VARCMPEX(BSTR
,bstr666neg
,I4
,42,VARCMP_GT
,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
);
6302 VARCMPEX(BSTR
,bstr666neg
,I4
,I4_MAX
,VARCMP_GT
,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
);
6303 VARCMPEX(BSTR
,bstr666neg
,I4
,-1,VARCMP_GT
,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
);
6304 VARCMPEX(BSTR
,bstr666neg
,I4
,-666,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_LT
);
6305 VARCMPEX(BSTR
,bstr7
,R8
,7.0,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_GT
);
6306 VARCMPEX(R8
,3.141592,BSTR
,NULL
,VARCMP_LT
,VARCMP_LT
,VARCMP_GT
,VARCMP_LT
);
6307 VARCMP(BSTR
,bstr7
,BSTR
,bstr7
,VARCMP_EQ
);
6308 VARCMP(BSTR
,bstr7
,BSTR
,bstr42
,VARCMP_GT
);
6309 VARCMP(BSTR
,bstr42
,BSTR
,bstr7
,VARCMP_LT
);
6311 /* DECIMAL handling */
6312 setdec(&dec
,0,0,0,0);
6313 VARCMPEX(DECIMAL
,dec
,BSTR
,bstr0
,VARCMP_LT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_LT
);
6314 setdec64(&dec
,0,0,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF); /* max DECIMAL */
6315 VARCMP(DECIMAL
,dec
,R8
,R8_MAX
,VARCMP_LT
); /* R8 has bigger range */
6316 VARCMP(DECIMAL
,dec
,DATE
,R8_MAX
,VARCMP_LT
); /* DATE has bigger range */
6317 setdec64(&dec
,0,0x80,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF);
6318 VARCMP(DECIMAL
,dec
,R8
,-R8_MAX
,VARCMP_GT
);
6319 setdec64(&dec
,20,0,0x5,0x6BC75E2D,0x63100001); /* 1+1e-20 */
6320 VARCMP(DECIMAL
,dec
,R8
,1,VARCMP_GT
); /* DECIMAL has higher precision */
6322 /* Show that DATE is handled just as a R8 */
6323 VARCMP(DATE
,DATE_MAX
,DATE
,DATE_MAX
+1,VARCMP_LT
);
6324 VARCMP(DATE
,DATE_MIN
,DATE
,DATE_MIN
-1,VARCMP_GT
);
6325 VARCMP(DATE
,R8_MIN
,R8
,R8_MIN
,VARCMP_EQ
);
6326 VARCMP(DATE
,1,DATE
,1+1e-15,VARCMP_LT
); /* 1e-15 == 8.64e-11 seconds */
6327 VARCMP(DATE
,25570.0,DATE
,25570.0,VARCMP_EQ
);
6328 VARCMP(DATE
,25570.0,DATE
,25571.0,VARCMP_LT
);
6329 VARCMP(DATE
,25571.0,DATE
,25570.0,VARCMP_GT
);
6330 VARCMP(DATE
,25570.0,EMPTY
,0,VARCMP_GT
);
6331 VARCMP(DATE
,25570.0,NULL_
,0,VARCMP_NULL
);
6333 /* R4 precision handling */
6334 VARCMP(R4
,1,R8
,1+1e-8,VARCMP_EQ
);
6335 VARCMP(R8
,1+1e-8,R4
,1,VARCMP_EQ
);
6336 VARCMP(R8
,1+1e-8,R8
,1,VARCMP_GT
);
6337 VARCMP(R8
,R4_MAX
*1.1,R4
,R4_MAX
,VARCMP_GT
);
6338 VARCMP(R4
,R4_MAX
,R8
,R8_MAX
,VARCMP_LT
);
6339 VARCMP(R4
,1,DATE
,1+1e-8,VARCMP_EQ
);
6340 VARCMP(R4
,1,BSTR
,bstr1few
,VARCMP_LT
); /* bstr1few == 1+1e-8 */
6341 setdec(&dec
,8,0,0,0x5F5E101); /* 1+1e-8 */
6342 VARCMP(R4
,1,DECIMAL
,dec
,VARCMP_LT
);
6344 SysFreeString(bstrhuh
);
6345 SysFreeString(bstrempty
);
6346 SysFreeString(bstr0
);
6347 SysFreeString(bstr1
);
6348 SysFreeString(bstr7
);
6349 SysFreeString(bstr42
);
6350 SysFreeString(bstr1neg
);
6351 SysFreeString(bstr666neg
);
6352 SysFreeString(bstr2cents
);
6353 SysFreeString(bstr1few
);
6356 static HRESULT (WINAPI
*pVarPow
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
6358 #define VARPOW(vt1,val1,vt2,val2,rvt,rval) \
6359 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
6360 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
6361 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
6362 test_var_call2( __LINE__, pVarPow, &left, &right, &exp )
6364 /* Skip any type that is not defined or produces an error for every case */
6365 #define SKIPTESTPOW(a) \
6366 if (a == VT_ERROR || a == VT_VARIANT || \
6367 a == VT_DISPATCH || a == VT_UNKNOWN || \
6368 a == VT_RECORD || a > VT_UINT || \
6369 a == 15 /*not defined*/) \
6372 static void test_VarPow(void)
6374 static const WCHAR str2
[] = { '2','\0' };
6375 static const WCHAR str3
[] = { '3','\0' };
6376 VARIANT left
, right
, exp
, result
, cy
, dec
;
6377 BSTR num2_str
, num3_str
;
6383 num2_str
= SysAllocString(str2
);
6384 num3_str
= SysAllocString(str3
);
6386 /* Test all possible flag/vt combinations & the resulting vt type */
6387 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
6389 VARTYPE leftvt
, rightvt
, resvt
;
6391 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
6393 SKIPTESTPOW(leftvt
);
6395 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
6398 SKIPTESTPOW(rightvt
);
6400 /* Native crashes with VT_BYREF */
6401 if (ExtraFlags
[i
] == VT_BYREF
)
6404 memset(&left
, 0, sizeof(left
));
6405 memset(&right
, 0, sizeof(right
));
6406 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
6407 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
6408 V_VT(&result
) = VT_EMPTY
;
6411 if (leftvt
== VT_BSTR
)
6412 V_BSTR(&left
) = num2_str
;
6413 if (rightvt
== VT_BSTR
)
6414 V_BSTR(&right
) = num2_str
;
6416 /* Native VarPow always returns an error when using extra flags */
6417 if (ExtraFlags
[i
] != 0)
6420 /* Determine return type */
6421 else if ((leftvt
== VT_NULL
|| rightvt
== VT_NULL
) &&
6422 ((leftvt
!= VT_I8
&& leftvt
!= VT_UI8
&&
6423 rightvt
!= VT_I8
&& rightvt
!= VT_UI8
) || HAVE_OLEAUT32_I8
))
6425 else if ((leftvt
== VT_EMPTY
|| leftvt
== VT_I2
||
6426 leftvt
== VT_I4
|| leftvt
== VT_R4
||
6427 leftvt
== VT_R8
|| leftvt
== VT_CY
||
6428 leftvt
== VT_DATE
|| leftvt
== VT_BSTR
||
6429 leftvt
== VT_BOOL
|| leftvt
== VT_DECIMAL
||
6430 (leftvt
>= VT_I1
&& leftvt
<= VT_UI4
) ||
6431 (HAVE_OLEAUT32_I8
&& (leftvt
== VT_I8
|| leftvt
== VT_UI8
)) ||
6432 leftvt
== VT_INT
|| leftvt
== VT_UINT
) &&
6433 (rightvt
== VT_EMPTY
|| rightvt
== VT_I2
||
6434 rightvt
== VT_I4
|| rightvt
== VT_R4
||
6435 rightvt
== VT_R8
|| rightvt
== VT_CY
||
6436 rightvt
== VT_DATE
|| rightvt
== VT_BSTR
||
6437 rightvt
== VT_BOOL
|| rightvt
== VT_DECIMAL
||
6438 (rightvt
>= VT_I1
&& rightvt
<= VT_UI4
) ||
6439 (HAVE_OLEAUT32_I8
&& (rightvt
== VT_I8
|| rightvt
== VT_UI8
)) ||
6440 rightvt
== VT_INT
|| rightvt
== VT_UINT
))
6445 hres
= pVarPow(&left
, &right
, &result
);
6447 /* Check expected HRESULT and if result variant type is correct */
6449 ok (hres
== DISP_E_BADVARTYPE
|| hres
== DISP_E_TYPEMISMATCH
,
6450 "VarPow: %s|0x%X, %s|0x%X: got vt %s hr 0x%X\n",
6451 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
],
6452 vtstr(V_VT(&result
)), hres
);
6454 ok (hres
== S_OK
&& resvt
== V_VT(&result
),
6455 "VarPow: %s|0x%X, %s|0x%X: expected vt %s hr 0x%X, got vt %s hr 0x%X\n",
6456 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
], vtstr(resvt
),
6457 S_OK
, vtstr(V_VT(&result
)), hres
);
6462 /* Check return values for valid variant type combinations */
6463 VARPOW(EMPTY
,0,EMPTY
,0,R8
,1.0);
6464 VARPOW(EMPTY
,0,NULL
,0,NULL
,0);
6465 VARPOW(EMPTY
,0,I2
,3,R8
,0.0);
6466 VARPOW(EMPTY
,0,I4
,3,R8
,0.0);
6467 VARPOW(EMPTY
,0,R4
,3.0f
,R8
,0.0);
6468 VARPOW(EMPTY
,0,R8
,3.0,R8
,0.0);
6469 VARPOW(EMPTY
,0,DATE
,3,R8
,0.0);
6470 VARPOW(EMPTY
,0,BSTR
,num3_str
,R8
,0.0);
6471 VARPOW(EMPTY
,0,BOOL
,VARIANT_FALSE
,R8
,1.0);
6472 VARPOW(EMPTY
,0,I1
,3,R8
,0.0);
6473 VARPOW(EMPTY
,0,UI1
,3,R8
,0.0);
6474 VARPOW(EMPTY
,0,UI2
,3,R8
,0.0);
6475 VARPOW(EMPTY
,0,UI4
,3,R8
,0.0);
6476 if (HAVE_OLEAUT32_I8
)
6478 VARPOW(EMPTY
,0,I8
,3,R8
,0.0);
6479 VARPOW(EMPTY
,0,UI8
,3,R8
,0.0);
6481 VARPOW(EMPTY
,0,INT
,3,R8
,0.0);
6482 VARPOW(EMPTY
,0,UINT
,3,R8
,0.0);
6483 VARPOW(NULL
,0,EMPTY
,0,NULL
,0);
6484 VARPOW(NULL
,0,NULL
,0,NULL
,0);
6485 VARPOW(NULL
,0,I2
,3,NULL
,0);
6486 VARPOW(NULL
,0,I4
,3,NULL
,0);
6487 VARPOW(NULL
,0,R4
,3.0f
,NULL
,0);
6488 VARPOW(NULL
,0,R8
,3.0,NULL
,0);
6489 VARPOW(NULL
,0,DATE
,3,NULL
,0);
6490 VARPOW(NULL
,0,BSTR
,num3_str
,NULL
,0);
6491 VARPOW(NULL
,0,BOOL
,VARIANT_TRUE
,NULL
,0);
6492 VARPOW(NULL
,0,I1
,3,NULL
,0);
6493 VARPOW(NULL
,0,UI1
,3,NULL
,0);
6494 VARPOW(NULL
,0,UI2
,3,NULL
,0);
6495 VARPOW(NULL
,0,UI4
,3,NULL
,0);
6496 if (HAVE_OLEAUT32_I8
)
6498 VARPOW(NULL
,0,I8
,3,NULL
,0);
6499 VARPOW(NULL
,0,UI8
,3,NULL
,0);
6501 VARPOW(NULL
,0,INT
,3,NULL
,0);
6502 VARPOW(NULL
,0,UINT
,3,NULL
,0);
6503 VARPOW(I2
,2,EMPTY
,0,R8
,1.0);
6504 VARPOW(I2
,2,NULL
,0,NULL
,0);
6505 VARPOW(I2
,2,I2
,3,R8
,8.0);
6506 VARPOW(I2
,2,I4
,3,R8
,8.0);
6507 VARPOW(I2
,2,R4
,3.0f
,R8
,8.0);
6508 VARPOW(I2
,2,R8
,3.0,R8
,8.0);
6509 VARPOW(I2
,2,DATE
,3,R8
,8.0);
6510 VARPOW(I2
,2,BSTR
,num3_str
,R8
,8.0);
6511 VARPOW(I2
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6512 VARPOW(I2
,2,I1
,3,R8
,8.0);
6513 VARPOW(I2
,2,UI1
,3,R8
,8.0);
6514 VARPOW(I2
,2,UI2
,3,R8
,8.0);
6515 VARPOW(I2
,2,UI4
,3,R8
,8.0);
6516 if (HAVE_OLEAUT32_I8
)
6518 VARPOW(I2
,2,I8
,3,R8
,8.0);
6519 VARPOW(I2
,2,UI8
,3,R8
,8.0);
6521 VARPOW(I2
,2,INT
,3,R8
,8.0);
6522 VARPOW(I2
,2,UINT
,3,R8
,8.0);
6523 VARPOW(I4
,2,EMPTY
,0,R8
,1.0);
6524 VARPOW(I4
,2,NULL
,0,NULL
,0);
6525 VARPOW(I4
,2,I2
,3,R8
,8.0);
6526 VARPOW(I4
,2,I4
,3,R8
,8.0);
6527 VARPOW(I4
,2,R4
,3.0f
,R8
,8.0);
6528 VARPOW(I4
,2,R8
,3.0,R8
,8.0);
6529 VARPOW(I4
,2,DATE
,3,R8
,8.0);
6530 VARPOW(I4
,2,BSTR
,num3_str
,R8
,8.0);
6531 VARPOW(I4
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6532 VARPOW(I4
,2,I1
,3,R8
,8.0);
6533 VARPOW(I4
,2,UI1
,3,R8
,8.0);
6534 VARPOW(I4
,2,UI2
,3,R8
,8.0);
6535 VARPOW(I4
,2,UI4
,3,R8
,8.0);
6536 if (HAVE_OLEAUT32_I8
)
6538 VARPOW(I4
,2,I8
,3,R8
,8.0);
6539 VARPOW(I4
,2,UI8
,3,R8
,8.0);
6541 VARPOW(I4
,2,INT
,3,R8
,8.0);
6542 VARPOW(I4
,2,UINT
,3,R8
,8.0);
6543 VARPOW(R4
,2,EMPTY
,0,R8
,1.0);
6544 VARPOW(R4
,2,NULL
,0,NULL
,0);
6545 VARPOW(R4
,2,I2
,3,R8
,8.0);
6546 VARPOW(R4
,2,I4
,3,R8
,8.0);
6547 VARPOW(R4
,2,R4
,3.0f
,R8
,8.0);
6548 VARPOW(R4
,2,R8
,3.0,R8
,8.0);
6549 VARPOW(R4
,2,DATE
,3,R8
,8.0);
6550 VARPOW(R4
,2,BSTR
,num3_str
,R8
,8.0);
6551 VARPOW(R4
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6552 VARPOW(R4
,2,I1
,3,R8
,8.0);
6553 VARPOW(R4
,2,UI1
,3,R8
,8.0);
6554 VARPOW(R4
,2,UI2
,3,R8
,8.0);
6555 VARPOW(R4
,2,UI4
,3,R8
,8.0);
6556 if (HAVE_OLEAUT32_I8
)
6558 VARPOW(R4
,2,I8
,3,R8
,8.0);
6559 VARPOW(R4
,2,UI8
,3,R8
,8.0);
6561 VARPOW(R4
,2,INT
,3,R8
,8.0);
6562 VARPOW(R4
,2,UINT
,3,R8
,8.0);
6563 VARPOW(R8
,2,EMPTY
,0,R8
,1.0);
6564 VARPOW(R8
,2,NULL
,0,NULL
,0);
6565 VARPOW(R8
,2,I2
,3,R8
,8.0);
6566 VARPOW(R8
,2,I4
,3,R8
,8.0);
6567 VARPOW(R8
,2,R4
,3.0f
,R8
,8.0);
6568 VARPOW(R8
,2,R8
,3.0,R8
,8.0);
6569 VARPOW(R8
,2,DATE
,3,R8
,8.0);
6570 VARPOW(R8
,2,BSTR
,num3_str
,R8
,8.0);
6571 VARPOW(R8
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6572 VARPOW(R8
,2,I1
,3,R8
,8.0);
6573 VARPOW(R8
,2,UI1
,3,R8
,8.0);
6574 VARPOW(R8
,2,UI2
,3,R8
,8.0);
6575 VARPOW(R8
,2,UI4
,3,R8
,8.0);
6576 if (HAVE_OLEAUT32_I8
)
6578 VARPOW(R8
,2,I8
,3,R8
,8.0);
6579 VARPOW(R8
,2,UI8
,3,R8
,8.0);
6581 VARPOW(R8
,2,INT
,3,R8
,8.0);
6582 VARPOW(R8
,2,UINT
,3,R8
,8.0);
6583 VARPOW(DATE
,2,EMPTY
,0,R8
,1.0);
6584 VARPOW(DATE
,2,NULL
,0,NULL
,0);
6585 VARPOW(DATE
,2,I2
,3,R8
,8.0);
6586 VARPOW(DATE
,2,I4
,3,R8
,8.0);
6587 VARPOW(DATE
,2,R4
,3.0f
,R8
,8.0);
6588 VARPOW(DATE
,2,R8
,3.0,R8
,8.0);
6589 VARPOW(DATE
,2,DATE
,3,R8
,8.0);
6590 VARPOW(DATE
,2,BSTR
,num3_str
,R8
,8.0);
6591 VARPOW(DATE
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6592 VARPOW(DATE
,2,I1
,3,R8
,8.0);
6593 VARPOW(DATE
,2,UI1
,3,R8
,8.0);
6594 VARPOW(DATE
,2,UI2
,3,R8
,8.0);
6595 VARPOW(DATE
,2,UI4
,3,R8
,8.0);
6596 if (HAVE_OLEAUT32_I8
)
6598 VARPOW(DATE
,2,I8
,3,R8
,8.0);
6599 VARPOW(DATE
,2,UI8
,3,R8
,8.0);
6601 VARPOW(DATE
,2,INT
,3,R8
,8.0);
6602 VARPOW(DATE
,2,UINT
,3,R8
,8.0);
6603 VARPOW(BSTR
,num2_str
,EMPTY
,0,R8
,1.0);
6604 VARPOW(BSTR
,num2_str
,NULL
,0,NULL
,0);
6605 VARPOW(BSTR
,num2_str
,I2
,3,R8
,8.0);
6606 VARPOW(BSTR
,num2_str
,I4
,3,R8
,8.0);
6607 VARPOW(BSTR
,num2_str
,R4
,3.0f
,R8
,8.0);
6608 VARPOW(BSTR
,num2_str
,R8
,3.0,R8
,8.0);
6609 VARPOW(BSTR
,num2_str
,DATE
,3,R8
,8.0);
6610 VARPOW(BSTR
,num2_str
,BSTR
,num3_str
,R8
,8.0);
6611 VARPOW(BSTR
,num2_str
,BOOL
,VARIANT_FALSE
,R8
,1.0);
6612 VARPOW(BSTR
,num2_str
,I1
,3,R8
,8.0);
6613 VARPOW(BSTR
,num2_str
,UI1
,3,R8
,8.0);
6614 VARPOW(BSTR
,num2_str
,UI2
,3,R8
,8.0);
6615 VARPOW(BSTR
,num2_str
,UI4
,3,R8
,8.0);
6616 if (HAVE_OLEAUT32_I8
)
6618 VARPOW(BSTR
,num2_str
,I8
,3,R8
,8.0);
6619 VARPOW(BSTR
,num2_str
,UI8
,3,R8
,8.0);
6621 VARPOW(BSTR
,num2_str
,INT
,3,R8
,8.0);
6622 VARPOW(BSTR
,num2_str
,UINT
,3,R8
,8.0);
6623 VARPOW(BOOL
,VARIANT_TRUE
,EMPTY
,0,R8
,1.0);
6624 VARPOW(BOOL
,VARIANT_TRUE
,NULL
,0,NULL
,0);
6625 VARPOW(BOOL
,VARIANT_TRUE
,I2
,3,R8
,-1.0);
6626 VARPOW(BOOL
,VARIANT_TRUE
,I4
,3,R8
,-1.0);
6627 VARPOW(BOOL
,VARIANT_TRUE
,R4
,3.0f
,R8
,-1.0);
6628 VARPOW(BOOL
,VARIANT_TRUE
,R8
,3.0,R8
,-1.0);
6629 VARPOW(BOOL
,VARIANT_TRUE
,DATE
,3,R8
,-1.0);
6630 VARPOW(BOOL
,VARIANT_TRUE
,BSTR
,num3_str
,R8
,-1.0);
6631 VARPOW(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
,R8
,-1.0);
6632 VARPOW(BOOL
,VARIANT_TRUE
,I1
,3,R8
,-1.0);
6633 VARPOW(BOOL
,VARIANT_TRUE
,UI1
,3,R8
,-1.0);
6634 VARPOW(BOOL
,VARIANT_TRUE
,UI2
,3,R8
,-1.0);
6635 VARPOW(BOOL
,VARIANT_TRUE
,UI4
,3,R8
,-1.0);
6636 if (HAVE_OLEAUT32_I8
)
6638 VARPOW(BOOL
,VARIANT_TRUE
,I8
,3,R8
,-1.0);
6639 VARPOW(BOOL
,VARIANT_TRUE
,UI8
,3,R8
,-1.0);
6641 VARPOW(BOOL
,VARIANT_TRUE
,INT
,3,R8
,-1.0);
6642 VARPOW(BOOL
,VARIANT_TRUE
,UINT
,3,R8
,-1.0);
6643 VARPOW(I1
,2,EMPTY
,0,R8
,1.0);
6644 VARPOW(I1
,2,NULL
,0,NULL
,0);
6645 VARPOW(I1
,2,I2
,3,R8
,8.0);
6646 VARPOW(I1
,2,I4
,3,R8
,8.0);
6647 VARPOW(I1
,2,R4
,3.0f
,R8
,8.0);
6648 VARPOW(I1
,2,R8
,3.0,R8
,8.0);
6649 VARPOW(I1
,2,DATE
,3,R8
,8.0);
6650 VARPOW(I1
,2,BSTR
,num3_str
,R8
,8.0);
6651 VARPOW(I1
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6652 VARPOW(I1
,2,I1
,3,R8
,8.0);
6653 VARPOW(I1
,2,UI1
,3,R8
,8.0);
6654 VARPOW(I1
,2,UI2
,3,R8
,8.0);
6655 VARPOW(I1
,2,UI4
,3,R8
,8.0);
6656 if (HAVE_OLEAUT32_I8
)
6658 VARPOW(I1
,2,I8
,3,R8
,8.0);
6659 VARPOW(I1
,2,UI8
,3,R8
,8.0);
6661 VARPOW(I1
,2,INT
,3,R8
,8.0);
6662 VARPOW(I1
,2,UINT
,3,R8
,8.0);
6663 VARPOW(UI1
,2,EMPTY
,0,R8
,1.0);
6664 VARPOW(UI1
,2,NULL
,0,NULL
,0);
6665 VARPOW(UI1
,2,I2
,3,R8
,8.0);
6666 VARPOW(UI1
,2,I4
,3,R8
,8.0);
6667 VARPOW(UI1
,2,R4
,3.0f
,R8
,8.0);
6668 VARPOW(UI1
,2,R8
,3.0,R8
,8.0);
6669 VARPOW(UI1
,2,DATE
,3,R8
,8.0);
6670 VARPOW(UI1
,2,BSTR
,num3_str
,R8
,8.0);
6671 VARPOW(UI1
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6672 VARPOW(UI1
,2,I1
,3,R8
,8.0);
6673 VARPOW(UI1
,2,UI1
,3,R8
,8.0);
6674 VARPOW(UI1
,2,UI2
,3,R8
,8.0);
6675 VARPOW(UI1
,2,UI4
,3,R8
,8.0);
6676 if (HAVE_OLEAUT32_I8
)
6678 VARPOW(UI1
,2,I8
,3,R8
,8.0);
6679 VARPOW(UI1
,2,UI8
,3,R8
,8.0);
6681 VARPOW(UI1
,2,INT
,3,R8
,8.0);
6682 VARPOW(UI1
,2,UINT
,3,R8
,8.0);
6683 VARPOW(UI2
,2,EMPTY
,0,R8
,1.0);
6684 VARPOW(UI2
,2,NULL
,0,NULL
,0);
6685 VARPOW(UI2
,2,I2
,3,R8
,8.0);
6686 VARPOW(UI2
,2,I4
,3,R8
,8.0);
6687 VARPOW(UI2
,2,R4
,3.0f
,R8
,8.0);
6688 VARPOW(UI2
,2,R8
,3.0,R8
,8.0);
6689 VARPOW(UI2
,2,DATE
,3,R8
,8.0);
6690 VARPOW(UI2
,2,BSTR
,num3_str
,R8
,8.0);
6691 VARPOW(UI2
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6692 VARPOW(UI2
,2,I1
,3,R8
,8.0);
6693 VARPOW(UI2
,2,UI1
,3,R8
,8.0);
6694 VARPOW(UI2
,2,UI2
,3,R8
,8.0);
6695 VARPOW(UI2
,2,UI4
,3,R8
,8.0);
6696 if (HAVE_OLEAUT32_I8
)
6698 VARPOW(UI2
,2,I8
,3,R8
,8.0);
6699 VARPOW(UI2
,2,UI8
,3,R8
,8.0);
6701 VARPOW(UI2
,2,INT
,3,R8
,8.0);
6702 VARPOW(UI2
,2,UINT
,3,R8
,8.0);
6703 VARPOW(UI4
,2,EMPTY
,0,R8
,1.0);
6704 VARPOW(UI4
,2,NULL
,0,NULL
,0);
6705 VARPOW(UI4
,2,I2
,3,R8
,8.0);
6706 VARPOW(UI4
,2,I4
,3,R8
,8.0);
6707 VARPOW(UI4
,2,R4
,3.0f
,R8
,8.0);
6708 VARPOW(UI4
,2,R8
,3.0,R8
,8.0);
6709 VARPOW(UI4
,2,DATE
,3,R8
,8.0);
6710 VARPOW(UI4
,2,BSTR
,num3_str
,R8
,8.0);
6711 VARPOW(UI4
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6712 VARPOW(UI4
,2,I1
,3,R8
,8.0);
6713 VARPOW(UI4
,2,UI1
,3,R8
,8.0);
6714 VARPOW(UI4
,2,UI2
,3,R8
,8.0);
6715 VARPOW(UI4
,2,UI4
,3,R8
,8.0);
6716 if (HAVE_OLEAUT32_I8
)
6718 VARPOW(UI4
,2,I8
,3,R8
,8.0);
6719 VARPOW(UI4
,2,UI8
,3,R8
,8.0);
6721 VARPOW(UI4
,2,INT
,3,R8
,8.0);
6722 VARPOW(UI4
,2,UINT
,3,R8
,8.0);
6723 if (HAVE_OLEAUT32_I8
)
6725 VARPOW(I8
,2,EMPTY
,0,R8
,1.0);
6726 VARPOW(I8
,2,NULL
,0,NULL
,0);
6727 VARPOW(I8
,2,I2
,3,R8
,8.0);
6728 VARPOW(I8
,2,I4
,3,R8
,8.0);
6729 VARPOW(I8
,2,R4
,3.0f
,R8
,8.0);
6730 VARPOW(I8
,2,R8
,3.0,R8
,8.0);
6731 VARPOW(I8
,2,DATE
,3,R8
,8.0);
6732 VARPOW(I8
,2,BSTR
,num3_str
,R8
,8.0);
6733 VARPOW(I8
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6734 VARPOW(I8
,2,I1
,3,R8
,8.0);
6735 VARPOW(I8
,2,UI1
,3,R8
,8.0);
6736 VARPOW(I8
,2,UI2
,3,R8
,8.0);
6737 VARPOW(I8
,2,UI4
,3,R8
,8.0);
6738 VARPOW(I8
,2,I8
,3,R8
,8.0);
6739 VARPOW(I8
,2,UI8
,3,R8
,8.0);
6740 VARPOW(I8
,2,INT
,3,R8
,8.0);
6741 VARPOW(I8
,2,UINT
,3,R8
,8.0);
6742 VARPOW(UI8
,2,EMPTY
,0,R8
,1.0);
6743 VARPOW(UI8
,2,NULL
,0,NULL
,0);
6744 VARPOW(UI8
,2,I2
,3,R8
,8.0);
6745 VARPOW(UI8
,2,I4
,3,R8
,8.0);
6746 VARPOW(UI8
,2,R4
,3.0f
,R8
,8.0);
6747 VARPOW(UI8
,2,R8
,3.0,R8
,8.0);
6748 VARPOW(UI8
,2,DATE
,3,R8
,8.0);
6749 VARPOW(UI8
,2,BSTR
,num3_str
,R8
,8.0);
6750 VARPOW(UI8
,2,I1
,3,R8
,8.0);
6751 VARPOW(UI8
,2,UI1
,3,R8
,8.0);
6752 VARPOW(UI8
,2,UI2
,3,R8
,8.0);
6753 VARPOW(UI8
,2,UI4
,3,R8
,8.0);
6754 VARPOW(UI8
,2,I8
,3,R8
,8.0);
6755 VARPOW(UI8
,2,UI8
,3,R8
,8.0);
6756 VARPOW(UI8
,2,INT
,3,R8
,8.0);
6757 VARPOW(UI8
,2,UINT
,3,R8
,8.0);
6759 VARPOW(INT
,2,EMPTY
,0,R8
,1.0);
6760 VARPOW(INT
,2,NULL
,0,NULL
,0);
6761 VARPOW(INT
,2,I2
,3,R8
,8.0);
6762 VARPOW(INT
,2,I4
,3,R8
,8.0);
6763 VARPOW(INT
,2,R4
,3.0f
,R8
,8.0);
6764 VARPOW(INT
,2,R8
,3.0,R8
,8.0);
6765 VARPOW(INT
,2,DATE
,3,R8
,8.0);
6766 VARPOW(INT
,2,BSTR
,num3_str
,R8
,8.0);
6767 VARPOW(INT
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6768 VARPOW(INT
,2,I1
,3,R8
,8.0);
6769 VARPOW(INT
,2,UI1
,3,R8
,8.0);
6770 VARPOW(INT
,2,UI2
,3,R8
,8.0);
6771 VARPOW(INT
,2,UI4
,3,R8
,8.0);
6772 if (HAVE_OLEAUT32_I8
)
6774 VARPOW(INT
,2,I8
,3,R8
,8.0);
6775 VARPOW(INT
,2,UI8
,3,R8
,8.0);
6777 VARPOW(INT
,2,INT
,3,R8
,8.0);
6778 VARPOW(INT
,2,UINT
,3,R8
,8.0);
6779 VARPOW(UINT
,2,EMPTY
,0,R8
,1.0);
6780 VARPOW(UINT
,2,NULL
,0,NULL
,0);
6781 VARPOW(UINT
,2,I2
,3,R8
,8.0);
6782 VARPOW(UINT
,2,I4
,3,R8
,8.0);
6783 VARPOW(UINT
,2,R4
,3.0f
,R8
,8.0);
6784 VARPOW(UINT
,2,R8
,3.0,R8
,8.0);
6785 VARPOW(UINT
,2,DATE
,3,R8
,8.0);
6786 VARPOW(UINT
,2,BSTR
,num3_str
,R8
,8.0);
6787 VARPOW(UINT
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6788 VARPOW(UINT
,2,I1
,3,R8
,8.0);
6789 VARPOW(UINT
,2,UI1
,3,R8
,8.0);
6790 VARPOW(UINT
,2,UI2
,3,R8
,8.0);
6791 VARPOW(UINT
,2,UI4
,3,R8
,8.0);
6792 if (HAVE_OLEAUT32_I8
)
6794 VARPOW(UINT
,2,I8
,3,R8
,8.0);
6795 VARPOW(UINT
,2,UI8
,3,R8
,8.0);
6797 VARPOW(UINT
,2,INT
,3,R8
,8.0);
6798 VARPOW(UINT
,2,UINT
,3,R8
,8.0);
6800 /* Manually test some VT_CY, VT_DECIMAL variants */
6802 hres
= VarCyFromI4(2, &V_CY(&cy
));
6803 ok(hres
== S_OK
, "VarCyFromI4 failed!\n");
6804 V_VT(&dec
) = VT_DECIMAL
;
6805 hres
= VarDecFromR8(2.0, &V_DECIMAL(&dec
));
6806 ok(hres
== S_OK
, "VarDecFromR4 failed!\n");
6807 memset(&left
, 0, sizeof(left
));
6808 memset(&right
, 0, sizeof(right
));
6809 V_VT(&left
) = VT_I4
;
6811 V_VT(&right
) = VT_I8
;
6814 hres
= pVarPow(&cy
, &cy
, &result
);
6815 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
6816 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
6817 S_OK
, hres
, vtstr(V_VT(&result
)));
6818 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 4.0),
6819 "VARPOW: CY value %f, expected %f\n", V_R8(&result
), 4.0);
6821 hres
= pVarPow(&cy
, &right
, &result
);
6822 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
6823 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
6824 S_OK
, hres
, vtstr(V_VT(&result
)));
6825 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 4.0),
6826 "VARPOW: CY value %f, expected %f\n", V_R8(&result
), 4.0);
6828 hres
= pVarPow(&left
, &cy
, &result
);
6829 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
6830 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
6831 S_OK
, hres
, vtstr(V_VT(&result
)));
6832 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 10000.0),
6833 "VARPOW: CY value %f, expected %f\n", V_R8(&result
), 10000.0);
6835 hres
= pVarPow(&left
, &dec
, &result
);
6836 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
6837 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
6838 S_OK
, hres
, vtstr(V_VT(&result
)));
6839 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
),10000.0),
6840 "VARPOW: DECIMAL value %f, expected %f\n", V_R8(&result
), 10000.0);
6842 hres
= pVarPow(&dec
, &dec
, &result
);
6843 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
6844 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
6845 S_OK
, hres
, vtstr(V_VT(&result
)));
6846 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 4.0),
6847 "VARPOW: DECIMAL value %f, expected %f\n", V_R8(&result
), 4.0);
6849 hres
= pVarPow(&dec
, &right
, &result
);
6850 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
6851 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type%s!\n",
6852 S_OK
, hres
, vtstr(V_VT(&result
)));
6853 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 4.0),
6854 "VARPOW: DECIMAL value %f, expected %f\n", V_R8(&result
), 4.0);
6856 SysFreeString(num2_str
);
6857 SysFreeString(num3_str
);
6860 static HRESULT (WINAPI
*pVarDiv
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
6862 #define VARDIV(vt1,val1,vt2,val2,rvt,rval) \
6863 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
6864 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
6865 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
6866 test_var_call2( __LINE__, pVarDiv, &left, &right, &exp )
6868 /* Skip any type that is not defined or produces an error for every case */
6869 #define SKIPTESTDIV(a) \
6870 if (a == VT_ERROR || a == VT_VARIANT || \
6871 a == VT_DISPATCH || a == VT_UNKNOWN || \
6872 a == VT_RECORD || a > VT_UINT || \
6873 a == VT_I1 || a == VT_UI8 || \
6874 a == VT_INT || a == VT_UINT || \
6875 a == VT_UI2 || a == VT_UI4 || \
6876 a == 15 /*not defined*/) \
6879 static void test_VarDiv(void)
6881 static const WCHAR str1
[] = { '1','\0' };
6882 static const WCHAR str2
[] = { '2','\0' };
6883 VARIANT left
, right
, exp
, result
, cy
, dec
;
6884 BSTR num1_str
, num2_str
;
6886 HRESULT hres
, expectedhres
;
6889 num1_str
= SysAllocString(str1
);
6890 num2_str
= SysAllocString(str2
);
6894 /* Test all possible flag/vt combinations & the resulting vt type */
6895 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
6897 VARTYPE leftvt
, rightvt
, resvt
;
6899 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
6901 SKIPTESTDIV(leftvt
);
6903 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
6906 SKIPTESTDIV(rightvt
);
6908 /* Native crashes with VT_BYREF */
6909 if (ExtraFlags
[i
] == VT_BYREF
)
6912 memset(&left
, 0, sizeof(left
));
6913 memset(&right
, 0, sizeof(right
));
6914 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
6915 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
6916 V_VT(&result
) = VT_EMPTY
;
6918 expectedhres
= S_OK
;
6920 if (leftvt
== VT_BSTR
)
6921 V_BSTR(&left
) = num2_str
;
6922 else if (leftvt
== VT_DECIMAL
)
6924 VarDecFromR8(2.0, &V_DECIMAL(&left
));
6925 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
6928 /* Division by 0 is undefined */
6932 V_BSTR(&right
) = num2_str
;
6935 VarDecFromR8(2.0, &V_DECIMAL(&right
));
6936 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
6939 V_BOOL(&right
) = VARIANT_TRUE
;
6941 case VT_I2
: V_I2(&right
) = 2; break;
6942 case VT_I4
: V_I4(&right
) = 2; break;
6943 case VT_R4
: V_R4(&right
) = 2.0f
; break;
6944 case VT_R8
: V_R8(&right
) = 2.0; break;
6945 case VT_CY
: V_CY(&right
).int64
= 2; break;
6946 case VT_DATE
: V_DATE(&right
) = 2; break;
6947 case VT_UI1
: V_UI1(&right
) = 2; break;
6948 case VT_I8
: V_I8(&right
) = 2; break;
6952 /* Determine return type */
6953 if (!(rightvt
== VT_EMPTY
))
6955 if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
6957 else if (leftvt
== VT_DECIMAL
|| rightvt
== VT_DECIMAL
)
6959 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
||
6960 leftvt
== VT_CY
|| rightvt
== VT_CY
||
6961 leftvt
== VT_DATE
|| rightvt
== VT_DATE
||
6962 leftvt
== VT_I4
|| rightvt
== VT_I4
||
6963 leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
||
6964 leftvt
== VT_I2
|| rightvt
== VT_I2
||
6965 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
||
6966 leftvt
== VT_R8
|| rightvt
== VT_R8
||
6967 leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
6969 if ((leftvt
== VT_UI1
&& rightvt
== VT_R4
) ||
6970 (leftvt
== VT_R4
&& rightvt
== VT_UI1
))
6972 else if ((leftvt
== VT_R4
&& (rightvt
== VT_BOOL
||
6973 rightvt
== VT_I2
)) || (rightvt
== VT_R4
&&
6974 (leftvt
== VT_BOOL
|| leftvt
== VT_I2
)))
6979 else if (leftvt
== VT_R4
|| rightvt
== VT_R4
)
6982 else if (leftvt
== VT_NULL
&& rightvt
== VT_EMPTY
)
6987 /* Native VarDiv always returns an error when using extra flags */
6988 if (ExtraFlags
[i
] != 0)
6991 hres
= pVarDiv(&left
, &right
, &result
);
6993 /* Check expected HRESULT and if result variant type is correct */
6995 ok (hres
== DISP_E_BADVARTYPE
|| hres
== DISP_E_TYPEMISMATCH
||
6996 hres
== DISP_E_OVERFLOW
|| hres
== DISP_E_DIVBYZERO
,
6997 "VarDiv: %s|0x%X, %s|0x%X: got vt %s hr 0x%X\n",
6998 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
],
6999 vtstr(V_VT(&result
)), hres
);
7001 ok (hres
== S_OK
&& resvt
== V_VT(&result
),
7002 "VarDiv: %s|0x%X, %s|0x%X: expected vt %s hr 0x%X, got vt %s hr 0x%X\n",
7003 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
], vtstr(resvt
),
7004 S_OK
, vtstr(V_VT(&result
)), hres
);
7009 /* Test return values for all the good cases */
7010 VARDIV(EMPTY
,0,NULL
,0,NULL
,0);
7011 VARDIV(EMPTY
,0,I2
,2,R8
,0.0);
7012 VARDIV(EMPTY
,0,I4
,2,R8
,0.0);
7013 VARDIV(EMPTY
,0,R4
,2.0f
,R4
,0.0f
);
7014 VARDIV(EMPTY
,0,R8
,2.0,R8
,0.0);
7015 VARDIV(EMPTY
,0,DATE
,2.0,R8
,0.0);
7016 VARDIV(EMPTY
,0,BSTR
,num2_str
,R8
,0.0);
7017 VARDIV(EMPTY
,0,BOOL
,VARIANT_TRUE
,R8
,0.0);
7018 VARDIV(EMPTY
,0,UI1
,2,R8
,0.0);
7019 VARDIV(EMPTY
,0,I8
,2,R8
,0.0);
7020 VARDIV(NULL
,0,EMPTY
,0,NULL
,0);
7021 VARDIV(NULL
,0,NULL
,0,NULL
,0);
7022 VARDIV(NULL
,0,I2
,2,NULL
,0);
7023 VARDIV(NULL
,0,I4
,2,NULL
,0);
7024 VARDIV(NULL
,0,R4
,2.0f
,NULL
,0);
7025 VARDIV(NULL
,0,R8
,2.0,NULL
,0);
7026 VARDIV(NULL
,0,DATE
,2,NULL
,0);
7027 VARDIV(NULL
,0,BSTR
,num2_str
,NULL
,0);
7028 VARDIV(NULL
,0,BOOL
,VARIANT_TRUE
,NULL
,0);
7029 VARDIV(NULL
,0,UI1
,2,NULL
,0);
7030 VARDIV(NULL
,0,I8
,2,NULL
,0);
7031 VARDIV(I2
,2,NULL
,0,NULL
,0);
7032 VARDIV(I2
,1,I2
,2,R8
,0.5);
7033 VARDIV(I2
,1,I4
,2,R8
,0.5);
7034 VARDIV(I2
,1,R4
,2,R4
,0.5f
);
7035 VARDIV(I2
,1,R8
,2.0,R8
,0.5);
7036 VARDIV(I2
,1,DATE
,2,R8
,0.5);
7037 VARDIV(I2
,1,BOOL
,VARIANT_TRUE
,R8
,-1.0);
7038 VARDIV(I2
,1,UI1
,2,R8
,0.5);
7039 VARDIV(I2
,1,I8
,2,R8
,0.5);
7040 VARDIV(I4
,1,NULL
,0,NULL
,0);
7041 VARDIV(I4
,1,I2
,2,R8
,0.5);
7042 VARDIV(I4
,1,I4
,2,R8
,0.5);
7043 VARDIV(I4
,1,R4
,2.0f
,R8
,0.5);
7044 VARDIV(I4
,1,R8
,2.0,R8
,0.5);
7045 VARDIV(I4
,1,DATE
,2,R8
,0.5);
7046 VARDIV(I4
,1,BSTR
,num2_str
,R8
,0.5);
7047 VARDIV(I4
,1,BOOL
,VARIANT_TRUE
,R8
,-1.0);
7048 VARDIV(I4
,1,UI1
,2,R8
,0.5);
7049 VARDIV(I4
,1,I8
,2,R8
,0.5);
7050 VARDIV(R4
,1.0f
,NULL
,0,NULL
,0);
7051 VARDIV(R4
,1.0f
,I2
,2,R4
,0.5f
);
7052 VARDIV(R4
,1.0f
,I4
,2,R8
,0.5);
7053 VARDIV(R4
,1.0f
,R4
,2.0f
,R4
,0.5f
);
7054 VARDIV(R4
,1.0f
,R8
,2.0,R8
,0.5);
7055 VARDIV(R4
,1.0f
,DATE
,2,R8
,0.5);
7056 VARDIV(R4
,1.0f
,BSTR
,num2_str
,R8
,0.5);
7057 VARDIV(R4
,1.0f
,BOOL
,VARIANT_TRUE
,R4
,-1);
7058 VARDIV(R4
,1.0f
,UI1
,2,R4
,0.5f
);
7059 VARDIV(R4
,1.0f
,I8
,2,R8
,0.5);
7060 VARDIV(R8
,1.0,NULL
,0,NULL
,0);
7061 VARDIV(R8
,1.0,I2
,2,R8
,0.5);
7062 VARDIV(R8
,1.0,I4
,2,R8
,0.5);
7063 VARDIV(R8
,1.0,R4
,2.0f
,R8
,0.5);
7064 VARDIV(R8
,1.0,R8
,2.0,R8
,0.5);
7065 VARDIV(R8
,1.0,DATE
,2,R8
,0.5);
7066 VARDIV(R8
,1.0,BSTR
,num2_str
,R8
,0.5);
7067 VARDIV(R8
,1.0,BOOL
,VARIANT_TRUE
,R8
,-1.0);
7068 VARDIV(R8
,1.0,UI1
,2,R8
,0.5);
7069 VARDIV(R8
,1.0,I8
,2,R8
,0.5);
7070 VARDIV(DATE
,1,NULL
,0,NULL
,0);
7071 VARDIV(DATE
,1,I2
,2,R8
,0.5);
7072 VARDIV(DATE
,1,I4
,2,R8
,0.5);
7073 VARDIV(DATE
,1,R4
,2.0f
,R8
,0.5);
7074 VARDIV(DATE
,1,R8
,2.0,R8
,0.5);
7075 VARDIV(DATE
,1,DATE
,2,R8
,0.5);
7076 VARDIV(DATE
,1,BSTR
,num2_str
,R8
,0.5);
7077 VARDIV(DATE
,1,BOOL
,VARIANT_TRUE
,R8
,-1.0);
7078 VARDIV(DATE
,1,UI1
,2,R8
,0.5);
7079 VARDIV(DATE
,1,I8
,2,R8
,0.5);
7080 VARDIV(BSTR
,num1_str
,NULL
,0,NULL
,0);
7081 VARDIV(BSTR
,num1_str
,I2
,2,R8
,0.5);
7082 VARDIV(BSTR
,num1_str
,I4
,2,R8
,0.5);
7083 VARDIV(BSTR
,num1_str
,R4
,2.0f
,R8
,0.5);
7084 VARDIV(BSTR
,num1_str
,R8
,2.0,R8
,0.5);
7085 VARDIV(BSTR
,num1_str
,DATE
,2,R8
,0.5);
7086 VARDIV(BSTR
,num1_str
,BSTR
,num2_str
,R8
,0.5);
7087 VARDIV(BSTR
,num1_str
,BOOL
,VARIANT_TRUE
,R8
,-1);
7088 VARDIV(BSTR
,num1_str
,UI1
,2,R8
,0.5);
7089 VARDIV(BSTR
,num1_str
,I8
,2,R8
,0.5);
7090 VARDIV(BOOL
,VARIANT_TRUE
,NULL
,0,NULL
,0);
7091 VARDIV(BOOL
,VARIANT_TRUE
,I2
,1,R8
,-1.0);
7092 VARDIV(BOOL
,VARIANT_FALSE
,I2
,1,R8
,0.0);
7093 VARDIV(BOOL
,VARIANT_TRUE
,I4
,1,R8
,-1.0);
7094 VARDIV(BOOL
,VARIANT_FALSE
,I4
,1,R8
,0.0);
7095 VARDIV(BOOL
,VARIANT_TRUE
,R4
,1,R4
,-1.0f
);
7096 VARDIV(BOOL
,VARIANT_FALSE
,R4
,1,R4
,0.0f
);
7097 VARDIV(BOOL
,VARIANT_TRUE
,R8
,1.0,R8
,-1.0);
7098 VARDIV(BOOL
,VARIANT_FALSE
,R8
,1.0,R8
,0.0);
7099 VARDIV(BOOL
,VARIANT_FALSE
,DATE
,2,R8
,0.0);
7100 VARDIV(BOOL
,VARIANT_FALSE
,BSTR
,num2_str
,R8
,0.0);
7101 VARDIV(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
,R8
,1.0);
7102 VARDIV(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
,R8
,0.0);
7103 VARDIV(BOOL
,VARIANT_TRUE
,UI1
,1,R8
,-1.0);
7104 VARDIV(BOOL
,VARIANT_TRUE
,I8
,1,R8
,-1.0);
7105 VARDIV(UI1
,1,NULL
,0,NULL
,0);
7106 VARDIV(UI1
,1,I2
,2,R8
,0.5);
7107 VARDIV(UI1
,1,I4
,2,R8
,0.5);
7108 VARDIV(UI1
,1,R4
,2.0f
,R4
,0.5f
);
7109 VARDIV(UI1
,1,R8
,2.0,R8
,0.5);
7110 VARDIV(UI1
,1,DATE
,2,R8
,0.5);
7111 VARDIV(UI1
,1,BSTR
,num2_str
,R8
,0.5);
7112 VARDIV(UI1
,1,BOOL
,VARIANT_TRUE
,R8
,-1);
7113 VARDIV(UI1
,1,UI1
,2,R8
,0.5);
7114 VARDIV(UI1
,1,I8
,2,R8
,0.5);
7115 VARDIV(I8
,1,NULL
,0,NULL
,0);
7116 VARDIV(I8
,1,I2
,2,R8
,0.5);
7117 VARDIV(I8
,1,I4
,2,R8
,0.5);
7118 VARDIV(I8
,1,R4
,2.0f
,R8
,0.5);
7119 VARDIV(I8
,1,R8
,2.0,R8
,0.5);
7120 VARDIV(I8
,1,DATE
,2,R8
,0.5);
7121 VARDIV(I8
,1,BSTR
,num2_str
,R8
,0.5);
7122 VARDIV(I8
,1,BOOL
,VARIANT_TRUE
,R8
,-1);
7123 VARDIV(I8
,1,UI1
,2,R8
,0.5);
7124 VARDIV(I8
,1,I8
,2,R8
,0.5);
7126 /* Manually test some VT_CY, VT_DECIMAL variants */
7128 hres
= VarCyFromI4(10000, &V_CY(&cy
));
7129 ok(hres
== S_OK
, "VarCyFromI4 failed!\n");
7130 V_VT(&dec
) = VT_DECIMAL
;
7131 hres
= VarDecFromR8(2.0, &V_DECIMAL(&dec
));
7132 ok(hres
== S_OK
, "VarDecFromR4 failed!\n");
7133 memset(&left
, 0, sizeof(left
));
7134 memset(&right
, 0, sizeof(right
));
7135 V_VT(&left
) = VT_I4
;
7137 V_VT(&right
) = VT_UI1
;
7140 hres
= pVarDiv(&cy
, &cy
, &result
);
7141 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
7142 "VARDIV: expected coerced type VT_R8, got %s!\n", vtstr(V_VT(&result
)));
7143 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 1.0),
7144 "VARDIV: CY value %f, expected %f\n", V_R8(&result
), (double)1.0);
7146 hres
= pVarDiv(&cy
, &right
, &result
);
7147 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
7148 "VARDIV: expected coerced type VT_R8, got %s!\n", vtstr(V_VT(&result
)));
7149 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 5000.0),
7150 "VARDIV: CY value %f, expected %f\n", V_R8(&result
), (double)5000.0);
7152 hres
= pVarDiv(&left
, &cy
, &result
);
7153 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
7154 "VARDIV: expected coerced type VT_R8, got %s!\n", vtstr(V_VT(&result
)));
7155 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 0.01),
7156 "VARDIV: CY value %f, expected %f\n", V_R8(&result
), (double)0.01);
7158 hres
= pVarDiv(&left
, &dec
, &result
);
7159 ok(hres
== S_OK
&& V_VT(&result
) == VT_DECIMAL
,
7160 "VARDIV: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result
)));
7161 hres
= VarR8FromDec(&V_DECIMAL(&result
), &r
);
7162 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 50.0),
7163 "VARDIV: DECIMAL value %f, expected %f\n", r
, (double)50.0);
7165 hres
= pVarDiv(&dec
, &dec
, &result
);
7166 ok(hres
== S_OK
&& V_VT(&result
) == VT_DECIMAL
,
7167 "VARDIV: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result
)));
7168 hres
= VarR8FromDec(&V_DECIMAL(&result
), &r
);
7169 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 1.0),
7170 "VARDIV: DECIMAL value %f, expected %f\n", r
, (double)1.0);
7172 hres
= pVarDiv(&dec
, &right
, &result
);
7173 ok(hres
== S_OK
&& V_VT(&result
) == VT_DECIMAL
,
7174 "VARDIV: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result
)));
7175 hres
= VarR8FromDec(&V_DECIMAL(&result
), &r
);
7176 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 1.0),
7177 "VARDIV: DECIMAL value %f, expected %f\n", r
, (double)1.0);
7179 /* Check for division by zero and overflow */
7180 V_VT(&left
) = VT_R8
;
7182 V_VT(&right
) = VT_R8
;
7184 hres
= pVarDiv(&left
, &right
, &result
);
7185 ok(hres
== DISP_E_DIVBYZERO
&& V_VT(&result
) == VT_EMPTY
,
7186 "VARDIV: Division by (1.0/0.0) should result in DISP_E_DIVBYZERO but got 0x%X\n", hres
);
7188 V_VT(&left
) = VT_R8
;
7190 V_VT(&right
) = VT_R8
;
7192 hres
= pVarDiv(&left
, &right
, &result
);
7193 ok(hres
== DISP_E_OVERFLOW
&& V_VT(&result
) == VT_EMPTY
,
7194 "VARDIV: Division by (0.0/0.0) should result in DISP_E_OVERFLOW but got 0x%X\n", hres
);
7196 SysFreeString(num1_str
);
7197 SysFreeString(num2_str
);
7200 static HRESULT (WINAPI
*pVarIdiv
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
7202 #define VARIDIV(vt1,val1,vt2,val2,rvt,rval) \
7203 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
7204 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
7205 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
7206 test_var_call2( __LINE__, pVarIdiv, &left, &right, &exp )
7208 /* Skip any type that is not defined or produces an error for every case */
7209 #define SKIPTESTIDIV(a) \
7210 if (a == VT_ERROR || a == VT_VARIANT || \
7211 a == VT_DISPATCH || a == VT_UNKNOWN || \
7212 a == VT_RECORD || a > VT_UINT || \
7213 a == 15 /*not defined*/) \
7216 static void test_VarIdiv(void)
7218 static const WCHAR str1
[] = { '1','\0' };
7219 static const WCHAR str2
[] = { '2','\0' };
7220 VARIANT left
, right
, exp
, result
, cy
, dec
;
7221 BSTR num1_str
, num2_str
;
7227 num1_str
= SysAllocString(str1
);
7228 num2_str
= SysAllocString(str2
);
7230 /* Test all possible flag/vt combinations & the resulting vt type */
7231 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
7233 VARTYPE leftvt
, rightvt
, resvt
;
7235 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
7237 SKIPTESTIDIV(leftvt
);
7239 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
7242 SKIPTESTIDIV(rightvt
);
7244 /* Native crashes with extra flag VT_BYREF */
7245 if (ExtraFlags
[i
] == VT_BYREF
)
7248 memset(&left
, 0, sizeof(left
));
7249 memset(&right
, 0, sizeof(right
));
7250 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
7251 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
7252 V_VT(&result
) = VT_EMPTY
;
7255 if (leftvt
== VT_BSTR
)
7256 V_BSTR(&left
) = num2_str
;
7257 else if (leftvt
== VT_DECIMAL
)
7259 VarDecFromR8(2.0, &V_DECIMAL(&left
));
7260 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
7263 /* Division by 0 is undefined */
7267 V_BSTR(&right
) = num2_str
;
7270 VarDecFromR8(2.0, &V_DECIMAL(&right
));
7271 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
7274 V_BOOL(&right
) = VARIANT_TRUE
;
7277 VarCyFromI4(10000, &V_CY(&right
));
7278 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
7280 case VT_I2
: V_I2(&right
) = 2; break;
7281 case VT_I4
: V_I4(&right
) = 2; break;
7282 case VT_R4
: V_R4(&right
) = 2.0f
; break;
7283 case VT_R8
: V_R8(&right
) = 2.0; break;
7284 case VT_DATE
: V_DATE(&right
) = 2; break;
7285 case VT_I1
: V_I1(&right
) = 2; break;
7286 case VT_UI1
: V_UI1(&right
) = 2; break;
7287 case VT_UI2
: V_UI2(&right
) = 2; break;
7288 case VT_UI4
: V_UI4(&right
) = 2; break;
7289 case VT_I8
: V_I8(&right
) = 2; break;
7290 case VT_UI8
: V_UI8(&right
) = 2; break;
7291 case VT_INT
: V_INT(&right
) = 2; break;
7292 case VT_UINT
: V_UINT(&right
) = 2; break;
7296 /* Native VarIdiv always returns an error when using extra
7297 * flags or if the variant combination is I8 and INT.
7299 if ((leftvt
== VT_I8
&& rightvt
== VT_INT
) ||
7300 (leftvt
== VT_INT
&& rightvt
== VT_I8
) ||
7301 (rightvt
== VT_EMPTY
&& leftvt
!= VT_NULL
) ||
7305 /* Determine variant type */
7306 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
7308 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
7310 else if (leftvt
== VT_I4
|| rightvt
== VT_I4
||
7311 leftvt
== VT_INT
|| rightvt
== VT_INT
||
7312 leftvt
== VT_UINT
|| rightvt
== VT_UINT
||
7313 leftvt
== VT_UI8
|| rightvt
== VT_UI8
||
7314 leftvt
== VT_UI4
|| rightvt
== VT_UI4
||
7315 leftvt
== VT_UI2
|| rightvt
== VT_UI2
||
7316 leftvt
== VT_I1
|| rightvt
== VT_I1
||
7317 leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
||
7318 leftvt
== VT_DATE
|| rightvt
== VT_DATE
||
7319 leftvt
== VT_CY
|| rightvt
== VT_CY
||
7320 leftvt
== VT_DECIMAL
|| rightvt
== VT_DECIMAL
||
7321 leftvt
== VT_R8
|| rightvt
== VT_R8
||
7322 leftvt
== VT_R4
|| rightvt
== VT_R4
)
7324 else if (leftvt
== VT_I2
|| rightvt
== VT_I2
||
7325 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
||
7328 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
7333 hres
= pVarIdiv(&left
, &right
, &result
);
7335 /* Check expected HRESULT and if result variant type is correct */
7337 ok (hres
== DISP_E_BADVARTYPE
|| hres
== DISP_E_TYPEMISMATCH
||
7338 hres
== DISP_E_DIVBYZERO
,
7339 "VarIdiv: %s|0x%X, %s|0x%X: got vt %s hr 0x%X\n",
7340 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
],
7341 vtstr(V_VT(&result
)), hres
);
7343 ok (hres
== S_OK
&& resvt
== V_VT(&result
),
7344 "VarIdiv: %s|0x%X, %s|0x%X: expected vt %s hr 0x%X, got vt %s hr 0x%X\n",
7345 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
], vtstr(resvt
),
7346 S_OK
, vtstr(V_VT(&result
)), hres
);
7351 /* Test return values for all the good cases */
7352 VARIDIV(EMPTY
,0,NULL
,0,NULL
,0);
7353 VARIDIV(EMPTY
,0,I2
,1,I2
,0);
7354 VARIDIV(EMPTY
,0,I4
,1,I4
,0);
7355 VARIDIV(EMPTY
,0,R4
,1.0f
,I4
,0);
7356 VARIDIV(EMPTY
,0,R8
,1.0,I4
,0);
7357 VARIDIV(EMPTY
,0,DATE
,1.0,I4
,0);
7358 VARIDIV(EMPTY
,0,BSTR
,num1_str
,I4
,0);
7359 VARIDIV(EMPTY
,0,BOOL
,VARIANT_TRUE
,I2
,0);
7360 VARIDIV(EMPTY
,0,I1
,1,I4
,0);
7361 VARIDIV(EMPTY
,0,UI1
,1,I2
,0);
7362 VARIDIV(EMPTY
,0,UI2
,1,I4
,0);
7363 VARIDIV(EMPTY
,0,UI4
,1,I4
,0);
7364 VARIDIV(EMPTY
,0,I8
,1,I8
,0);
7365 VARIDIV(EMPTY
,0,UI8
,1,I4
,0);
7366 VARIDIV(EMPTY
,0,INT
,1,I4
,0);
7367 VARIDIV(EMPTY
,0,UINT
,1,I4
,0);
7368 VARIDIV(NULL
,0,EMPTY
,0,NULL
,0);
7369 VARIDIV(NULL
,0,NULL
,0,NULL
,0);
7370 VARIDIV(NULL
,0,I2
,1,NULL
,0);
7371 VARIDIV(NULL
,0,I4
,1,NULL
,0);
7372 VARIDIV(NULL
,0,R4
,1,NULL
,0);
7373 VARIDIV(NULL
,0,R8
,1,NULL
,0);
7374 VARIDIV(NULL
,0,DATE
,1,NULL
,0);
7375 VARIDIV(NULL
,0,BSTR
,num1_str
,NULL
,0);
7376 VARIDIV(NULL
,0,BOOL
,VARIANT_TRUE
,NULL
,0);
7377 VARIDIV(NULL
,0,I1
,1,NULL
,0);
7378 VARIDIV(NULL
,0,UI1
,1,NULL
,0);
7379 VARIDIV(NULL
,0,UI2
,1,NULL
,0);
7380 VARIDIV(NULL
,0,UI4
,1,NULL
,0);
7381 VARIDIV(NULL
,0,I8
,1,NULL
,0);
7382 VARIDIV(NULL
,0,UI8
,1,NULL
,0);
7383 VARIDIV(NULL
,0,INT
,1,NULL
,0);
7384 VARIDIV(NULL
,0,UINT
,1,NULL
,0);
7385 VARIDIV(I2
,2,NULL
,0,NULL
,0);
7386 VARIDIV(I2
,2,I2
,1,I2
,2);
7387 VARIDIV(I2
,2,I4
,1,I4
,2);
7388 VARIDIV(I2
,2,R4
,1,I4
,2);
7389 VARIDIV(I2
,2,R8
,1,I4
,2);
7390 VARIDIV(I2
,2,DATE
,1,I4
,2);
7391 VARIDIV(I2
,2,BSTR
,num1_str
,I4
,2);
7392 VARIDIV(I2
,2,BOOL
,VARIANT_TRUE
,I2
,-2);
7393 VARIDIV(I2
,2,I1
,1,I4
,2);
7394 VARIDIV(I2
,2,UI1
,1,I2
,2);
7395 VARIDIV(I2
,2,UI2
,1,I4
,2);
7396 VARIDIV(I2
,2,UI4
,1,I4
,2);
7397 VARIDIV(I2
,2,I8
,1,I8
,2);
7398 VARIDIV(I2
,2,UI8
,1,I4
,2);
7399 VARIDIV(I2
,2,INT
,1,I4
,2);
7400 VARIDIV(I2
,2,UINT
,1,I4
,2);
7401 VARIDIV(I4
,2,NULL
,0,NULL
,0);
7402 VARIDIV(I4
,2,I2
,1,I4
,2);
7403 VARIDIV(I4
,2,I4
,1,I4
,2);
7404 VARIDIV(I4
,2,R4
,1,I4
,2);
7405 VARIDIV(I4
,2,R8
,1,I4
,2);
7406 VARIDIV(I4
,2,DATE
,1,I4
,2);
7407 VARIDIV(I4
,2,BSTR
,num1_str
,I4
,2);
7408 VARIDIV(I4
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
7409 VARIDIV(I4
,2,I1
,1,I4
,2);
7410 VARIDIV(I4
,2,UI1
,1,I4
,2);
7411 VARIDIV(I4
,2,UI2
,1,I4
,2);
7412 VARIDIV(I4
,2,UI4
,1,I4
,2);
7413 VARIDIV(I4
,2,I8
,1,I8
,2);
7414 VARIDIV(I4
,2,UI8
,1,I4
,2);
7415 VARIDIV(I4
,2,INT
,1,I4
,2);
7416 VARIDIV(I4
,2,UINT
,1,I4
,2);
7417 VARIDIV(R4
,2.0f
,NULL
,0,NULL
,0);
7418 VARIDIV(R4
,2.0f
,I2
,1,I4
,2);
7419 VARIDIV(R4
,2.0f
,I4
,1,I4
,2);
7420 VARIDIV(R4
,2.0f
,R4
,1.0f
,I4
,2);
7421 VARIDIV(R4
,2.0f
,R8
,1.0,I4
,2);
7422 VARIDIV(R4
,2.0f
,DATE
,1,I4
,2);
7423 VARIDIV(R4
,2.0f
,BSTR
,num1_str
,I4
,2);
7424 VARIDIV(R4
,2.0f
,BOOL
,VARIANT_TRUE
,I4
,-2);
7425 VARIDIV(R4
,2.0f
,I1
,1,I4
,2);
7426 VARIDIV(R4
,2.0f
,UI1
,1,I4
,2);
7427 VARIDIV(R4
,2.0f
,UI2
,1,I4
,2);
7428 VARIDIV(R4
,2.0f
,UI4
,1,I4
,2);
7429 VARIDIV(R4
,2.0f
,I8
,1,I8
,2);
7430 VARIDIV(R4
,2.0f
,UI8
,1,I4
,2);
7431 VARIDIV(R4
,2.0f
,INT
,1,I4
,2);
7432 VARIDIV(R4
,2.0f
,UINT
,1,I4
,2);
7433 VARIDIV(R8
,2.0,NULL
,0,NULL
,0);
7434 VARIDIV(R8
,2.0,I2
,1,I4
,2);
7435 VARIDIV(R8
,2.0,I4
,1,I4
,2);
7436 VARIDIV(R8
,2.0,R4
,1,I4
,2);
7437 VARIDIV(R8
,2.0,R8
,1,I4
,2);
7438 VARIDIV(R8
,2.0,DATE
,1,I4
,2);
7439 VARIDIV(R8
,2.0,BSTR
,num1_str
,I4
,2);
7440 VARIDIV(R8
,2.0,BOOL
,VARIANT_TRUE
,I4
,-2);
7441 VARIDIV(R8
,2.0,I1
,1,I4
,2);
7442 VARIDIV(R8
,2.0,UI1
,1,I4
,2);
7443 VARIDIV(R8
,2.0,UI2
,1,I4
,2);
7444 VARIDIV(R8
,2.0,UI4
,1,I4
,2);
7445 VARIDIV(R8
,2.0,I8
,1,I8
,2);
7446 VARIDIV(R8
,2.0,UI8
,1,I4
,2);
7447 VARIDIV(R8
,2.0,INT
,1,I4
,2);
7448 VARIDIV(R8
,2.0,UINT
,1,I4
,2);
7449 VARIDIV(DATE
,2,NULL
,0,NULL
,0);
7450 VARIDIV(DATE
,2,I2
,1,I4
,2);
7451 VARIDIV(DATE
,2,I4
,1,I4
,2);
7452 VARIDIV(DATE
,2,R4
,1,I4
,2);
7453 VARIDIV(DATE
,2,R8
,1,I4
,2);
7454 VARIDIV(DATE
,2,DATE
,1,I4
,2);
7455 VARIDIV(DATE
,2,BSTR
,num1_str
,I4
,2);
7456 VARIDIV(DATE
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
7457 VARIDIV(DATE
,2,I1
,1,I4
,2);
7458 VARIDIV(DATE
,2,UI1
,1,I4
,2);
7459 VARIDIV(DATE
,2,UI2
,1,I4
,2);
7460 VARIDIV(DATE
,2,UI4
,1,I4
,2);
7461 VARIDIV(DATE
,2,I8
,1,I8
,2);
7462 VARIDIV(DATE
,2,UI8
,1,I4
,2);
7463 VARIDIV(DATE
,2,INT
,1,I4
,2);
7464 VARIDIV(DATE
,2,UINT
,1,I4
,2);
7465 VARIDIV(BSTR
,num2_str
,NULL
,0,NULL
,0);
7466 VARIDIV(BSTR
,num2_str
,I2
,1,I4
,2);
7467 VARIDIV(BSTR
,num2_str
,I4
,1,I4
,2);
7468 VARIDIV(BSTR
,num2_str
,R4
,1.0f
,I4
,2);
7469 VARIDIV(BSTR
,num2_str
,R8
,1.0,I4
,2);
7470 VARIDIV(BSTR
,num2_str
,DATE
,1,I4
,2);
7471 VARIDIV(BSTR
,num2_str
,BSTR
,num1_str
,I4
,2);
7472 VARIDIV(BSTR
,num2_str
,BOOL
,VARIANT_TRUE
,I4
,-2);
7473 VARIDIV(BSTR
,num2_str
,I1
,1,I4
,2);
7474 VARIDIV(BSTR
,num2_str
,UI1
,1,I4
,2);
7475 VARIDIV(BSTR
,num2_str
,UI2
,1,I4
,2);
7476 VARIDIV(BSTR
,num2_str
,UI4
,1,I4
,2);
7477 VARIDIV(BSTR
,num2_str
,I8
,1,I8
,2);
7478 VARIDIV(BSTR
,num2_str
,UI8
,1,I4
,2);
7479 VARIDIV(BSTR
,num2_str
,INT
,1,I4
,2);
7480 VARIDIV(BSTR
,num2_str
,UINT
,1,I4
,2);
7481 VARIDIV(BOOL
,VARIANT_TRUE
,NULL
,0,NULL
,0);
7482 VARIDIV(BOOL
,VARIANT_TRUE
,I2
,1,I2
,-1);
7483 VARIDIV(BOOL
,VARIANT_TRUE
,I4
,1,I4
,-1);
7484 VARIDIV(BOOL
,VARIANT_TRUE
,R4
,1.0f
,I4
,-1);
7485 VARIDIV(BOOL
,VARIANT_TRUE
,R8
,1.0,I4
,-1);
7486 VARIDIV(BOOL
,VARIANT_TRUE
,DATE
,1,I4
,-1);
7487 VARIDIV(BOOL
,VARIANT_TRUE
,BSTR
,num1_str
,I4
,-1);
7488 VARIDIV(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
,I2
,1);
7489 VARIDIV(BOOL
,VARIANT_TRUE
,I1
,1,I4
,-1);
7490 VARIDIV(BOOL
,VARIANT_TRUE
,UI1
,1,I2
,-1);
7491 VARIDIV(BOOL
,VARIANT_TRUE
,UI2
,1,I4
,-1);
7492 VARIDIV(BOOL
,VARIANT_TRUE
,UI4
,1,I4
,-1);
7493 VARIDIV(BOOL
,VARIANT_TRUE
,I8
,1,I8
,-1);
7494 VARIDIV(BOOL
,VARIANT_TRUE
,UI8
,1,I4
,-1);
7495 VARIDIV(BOOL
,VARIANT_TRUE
,INT
,1,I4
,-1);
7496 VARIDIV(BOOL
,VARIANT_TRUE
,UINT
,1,I4
,-1);
7497 VARIDIV(I1
,2,NULL
,0,NULL
,0);
7498 VARIDIV(I1
,2,I2
,1,I4
,2);
7499 VARIDIV(I1
,2,I4
,1,I4
,2);
7500 VARIDIV(I1
,2,R4
,1.0f
,I4
,2);
7501 VARIDIV(I1
,2,R8
,1.0,I4
,2);
7502 VARIDIV(I1
,2,DATE
,1,I4
,2);
7503 VARIDIV(I1
,2,BSTR
,num1_str
,I4
,2);
7504 VARIDIV(I1
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
7505 VARIDIV(I1
,2,I1
,1,I4
,2);
7506 VARIDIV(I1
,2,UI1
,1,I4
,2);
7507 VARIDIV(I1
,2,UI2
,1,I4
,2);
7508 VARIDIV(I1
,2,UI4
,1,I4
,2);
7509 VARIDIV(I1
,2,I8
,1,I8
,2);
7510 VARIDIV(I1
,2,UI8
,1,I4
,2);
7511 VARIDIV(I1
,2,INT
,1,I4
,2);
7512 VARIDIV(I1
,2,UINT
,1,I4
,2);
7513 VARIDIV(UI1
,2,NULL
,0,NULL
,0);
7514 VARIDIV(UI1
,2,I2
,1,I2
,2);
7515 VARIDIV(UI1
,2,I4
,1,I4
,2);
7516 VARIDIV(UI1
,2,R4
,1.0f
,I4
,2);
7517 VARIDIV(UI1
,2,R8
,1.0,I4
,2);
7518 VARIDIV(UI1
,2,DATE
,1,I4
,2);
7519 VARIDIV(UI1
,2,BSTR
,num1_str
,I4
,2);
7520 VARIDIV(UI1
,2,BOOL
,VARIANT_TRUE
,I2
,-2);
7521 VARIDIV(UI1
,2,I1
,1,I4
,2);
7522 VARIDIV(UI1
,2,UI1
,1,UI1
,2);
7523 VARIDIV(UI1
,2,UI2
,1,I4
,2);
7524 VARIDIV(UI1
,2,UI4
,1,I4
,2);
7525 VARIDIV(UI1
,2,I8
,1,I8
,2);
7526 VARIDIV(UI1
,2,UI8
,1,I4
,2);
7527 VARIDIV(UI1
,2,INT
,1,I4
,2);
7528 VARIDIV(UI1
,2,UINT
,1,I4
,2);
7529 VARIDIV(UI2
,2,NULL
,0,NULL
,0);
7530 VARIDIV(UI2
,2,I2
,1,I4
,2);
7531 VARIDIV(UI2
,2,I4
,1,I4
,2);
7532 VARIDIV(UI2
,2,R4
,1.0f
,I4
,2);
7533 VARIDIV(UI2
,2,R8
,1.0,I4
,2);
7534 VARIDIV(UI2
,2,DATE
,1,I4
,2);
7535 VARIDIV(UI2
,2,BSTR
,num1_str
,I4
,2);
7536 VARIDIV(UI2
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
7537 VARIDIV(UI2
,2,I1
,1,I4
,2);
7538 VARIDIV(UI2
,2,UI1
,1,I4
,2);
7539 VARIDIV(UI2
,2,UI2
,1,I4
,2);
7540 VARIDIV(UI2
,2,UI4
,1,I4
,2);
7541 VARIDIV(UI2
,2,I8
,1,I8
,2);
7542 VARIDIV(UI2
,2,UI8
,1,I4
,2);
7543 VARIDIV(UI2
,2,INT
,1,I4
,2);
7544 VARIDIV(UI2
,2,UINT
,1,I4
,2);
7545 VARIDIV(UI4
,2,NULL
,0,NULL
,0);
7546 VARIDIV(UI4
,2,I2
,1,I4
,2);
7547 VARIDIV(UI4
,2,I4
,1,I4
,2);
7548 VARIDIV(UI4
,2,R4
,1.0f
,I4
,2);
7549 VARIDIV(UI4
,2,R8
,1.0,I4
,2);
7550 VARIDIV(UI4
,2,DATE
,1,I4
,2);
7551 VARIDIV(UI4
,2,BSTR
,num1_str
,I4
,2);
7552 VARIDIV(UI4
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
7553 VARIDIV(UI4
,2,I1
,1,I4
,2);
7554 VARIDIV(UI4
,2,UI1
,1,I4
,2);
7555 VARIDIV(UI4
,2,UI2
,1,I4
,2);
7556 VARIDIV(UI4
,2,UI4
,1,I4
,2);
7557 VARIDIV(UI4
,2,I8
,1,I8
,2);
7558 VARIDIV(UI4
,2,UI8
,1,I4
,2);
7559 VARIDIV(UI4
,2,INT
,1,I4
,2);
7560 VARIDIV(UI4
,2,UINT
,1,I4
,2);
7561 VARIDIV(I8
,2,NULL
,0,NULL
,0);
7562 VARIDIV(I8
,2,I2
,1,I8
,2);
7563 VARIDIV(I8
,2,I4
,1,I8
,2);
7564 VARIDIV(I8
,2,R4
,1.0f
,I8
,2);
7565 VARIDIV(I8
,2,R8
,1.0,I8
,2);
7566 VARIDIV(I8
,2,DATE
,1,I8
,2);
7567 VARIDIV(I8
,2,BSTR
,num1_str
,I8
,2);
7568 VARIDIV(I8
,2,BOOL
,1,I8
,2);
7569 VARIDIV(I8
,2,I1
,1,I8
,2);
7570 VARIDIV(I8
,2,UI1
,1,I8
,2);
7571 VARIDIV(I8
,2,UI2
,1,I8
,2);
7572 VARIDIV(I8
,2,UI4
,1,I8
,2);
7573 VARIDIV(I8
,2,I8
,1,I8
,2);
7574 VARIDIV(I8
,2,UI8
,1,I8
,2);
7575 VARIDIV(I8
,2,UINT
,1,I8
,2);
7576 VARIDIV(UI8
,2,NULL
,0,NULL
,0);
7577 VARIDIV(UI8
,2,I2
,1,I4
,2);
7578 VARIDIV(UI8
,2,I4
,1,I4
,2);
7579 VARIDIV(UI8
,2,R4
,1.0f
,I4
,2);
7580 VARIDIV(UI8
,2,R8
,1.0,I4
,2);
7581 VARIDIV(UI8
,2,DATE
,1,I4
,2);
7582 VARIDIV(UI8
,2,BSTR
,num1_str
,I4
,2);
7583 VARIDIV(UI8
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
7584 VARIDIV(UI8
,2,I1
,1,I4
,2);
7585 VARIDIV(UI8
,2,UI1
,1,I4
,2);
7586 VARIDIV(UI8
,2,UI2
,1,I4
,2);
7587 VARIDIV(UI8
,2,UI4
,1,I4
,2);
7588 VARIDIV(UI8
,2,I8
,1,I8
,2);
7589 VARIDIV(UI8
,2,UI8
,1,I4
,2);
7590 VARIDIV(UI8
,2,INT
,1,I4
,2);
7591 VARIDIV(UI8
,2,UINT
,1,I4
,2);
7592 VARIDIV(INT
,2,NULL
,0,NULL
,0);
7593 VARIDIV(INT
,2,I2
,1,I4
,2);
7594 VARIDIV(INT
,2,I4
,1,I4
,2);
7595 VARIDIV(INT
,2,R4
,1.0f
,I4
,2);
7596 VARIDIV(INT
,2,R8
,1.0,I4
,2);
7597 VARIDIV(INT
,2,DATE
,1,I4
,2);
7598 VARIDIV(INT
,2,BSTR
,num1_str
,I4
,2);
7599 VARIDIV(INT
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
7600 VARIDIV(INT
,2,I1
,1,I4
,2);
7601 VARIDIV(INT
,2,UI1
,1,I4
,2);
7602 VARIDIV(INT
,2,UI2
,1,I4
,2);
7603 VARIDIV(INT
,2,UI4
,1,I4
,2);
7604 VARIDIV(INT
,2,UI8
,1,I4
,2);
7605 VARIDIV(INT
,2,INT
,1,I4
,2);
7606 VARIDIV(INT
,2,UINT
,1,I4
,2);
7607 VARIDIV(UINT
,2,NULL
,0,NULL
,0);
7608 VARIDIV(UINT
,2,I2
,1,I4
,2);
7609 VARIDIV(UINT
,2,I4
,1,I4
,2);
7610 VARIDIV(UINT
,2,R4
,1.0f
,I4
,2);
7611 VARIDIV(UINT
,2,R8
,1.0,I4
,2);
7612 VARIDIV(UINT
,2,DATE
,1,I4
,2);
7613 VARIDIV(UINT
,2,BSTR
,num1_str
,I4
,2);
7614 VARIDIV(UINT
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
7615 VARIDIV(UINT
,2,I1
,1,I4
,2);
7616 VARIDIV(UINT
,2,UI1
,1,I4
,2);
7617 VARIDIV(UINT
,2,UI2
,1,I4
,2);
7618 VARIDIV(UINT
,2,UI4
,1,I4
,2);
7619 VARIDIV(UINT
,2,I8
,1,I8
,2);
7620 VARIDIV(UINT
,2,UI8
,1,I4
,2);
7621 VARIDIV(UINT
,2,INT
,1,I4
,2);
7622 VARIDIV(UINT
,2,UINT
,1,I4
,2);
7624 /* Manually test some VT_CY, VT_DECIMAL variants */
7626 hres
= VarCyFromI4(10000, &V_CY(&cy
));
7627 ok(hres
== S_OK
, "VarCyFromI4 failed!\n");
7628 V_VT(&dec
) = VT_DECIMAL
;
7629 hres
= VarDecFromR8(2.0, &V_DECIMAL(&dec
));
7630 ok(hres
== S_OK
, "VarDecFromR4 failed!\n");
7631 memset(&left
, 0, sizeof(left
));
7632 memset(&right
, 0, sizeof(right
));
7633 V_VT(&left
) = VT_I4
;
7635 V_VT(&right
) = VT_I8
;
7638 hres
= VarIdiv(&cy
, &cy
, &result
);
7639 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
7640 "VARIDIV: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
7641 S_OK
, hres
, vtstr(V_VT(&result
)));
7642 ok(hres
== S_OK
&& V_I4(&result
) == 1,
7643 "VARIDIV: CY value %d, expected %d\n", V_I4(&result
), 1);
7645 hres
= VarIdiv(&cy
, &right
, &result
);
7646 ok(hres
== S_OK
&& V_VT(&result
) == VT_I8
,
7647 "VARIDIV: expected coerced hres 0x%X type VT_I8, got hres 0x%X type %s!\n",
7648 S_OK
, hres
, vtstr(V_VT(&result
)));
7649 ok(hres
== S_OK
&& V_I8(&result
) == 5000,
7650 "VARIDIV: CY value 0x%x%08x, expected 0x%x\n",
7651 (DWORD
)(V_I8(&result
) >>32), (DWORD
)V_I8(&result
), 5000);
7653 hres
= VarIdiv(&left
, &cy
, &result
);
7654 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
7655 "VARIDIV: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
7656 S_OK
, hres
, vtstr(V_VT(&result
)));
7657 ok(hres
== S_OK
&& V_I4(&result
) == 0,
7658 "VARIDIV: CY value %d, expected %d\n", V_I4(&result
), 0);
7660 hres
= VarIdiv(&left
, &dec
, &result
);
7661 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
7662 "VARIDIV: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
7663 S_OK
, hres
, vtstr(V_VT(&result
)));
7664 ok(hres
== S_OK
&& V_I4(&result
) == 50,
7665 "VARIDIV: DECIMAL value %d, expected %d\n", V_I4(&result
), 50);
7667 hres
= VarIdiv(&dec
, &dec
, &result
);
7668 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
7669 "VARIDIV: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
7670 S_OK
, hres
, vtstr(V_VT(&result
)));
7671 ok(hres
== S_OK
&& V_I4(&result
) == 1,
7672 "VARIDIV: DECIMAL value %d, expected %d\n", V_I4(&result
), 1);
7674 hres
= VarIdiv(&dec
, &right
, &result
);
7675 ok(hres
== S_OK
&& V_VT(&result
) == VT_I8
,
7676 "VARIDIV: expected coerced hres 0x%X type VT_I8, got hres 0x%X type%s!\n",
7677 S_OK
, hres
, vtstr(V_VT(&result
)));
7678 ok(hres
== S_OK
&& V_I8(&result
) == 1,
7679 "VARIDIV: DECIMAL value 0x%x%08x, expected %d\n",
7680 (DWORD
)(V_I8(&result
) >> 32), (DWORD
)V_I8(&result
), 1);
7682 /* Check for division by zero */
7683 V_VT(&left
) = VT_INT
;
7685 V_VT(&right
) = VT_INT
;
7687 hres
= pVarIdiv(&left
, &right
, &result
);
7688 ok(hres
== DISP_E_DIVBYZERO
&& V_VT(&result
) == VT_EMPTY
,
7689 "VARIDIV: Division by 0 should result in DISP_E_DIVBYZERO but got 0x%X\n", hres
);
7691 V_VT(&left
) = VT_INT
;
7693 V_VT(&right
) = VT_INT
;
7695 hres
= pVarIdiv(&left
, &right
, &result
);
7696 ok(hres
== DISP_E_DIVBYZERO
&& V_VT(&result
) == VT_EMPTY
,
7697 "VARIDIV: Division by 0 should result in DISP_E_DIVBYZERO but got 0x%X\n", hres
);
7699 SysFreeString(num1_str
);
7700 SysFreeString(num2_str
);
7704 static HRESULT (WINAPI
*pVarImp
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
7706 #define VARIMP(vt1,val1,vt2,val2,rvt,rval) \
7707 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
7708 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
7709 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
7710 test_var_call2( __LINE__, pVarImp, &left, &right, &exp )
7712 /* Skip any type that is not defined or produces an error for every case */
7713 #define SKIPTESTIMP(a) \
7714 if (a == VT_ERROR || a == VT_VARIANT || \
7715 a == VT_DISPATCH || a == VT_UNKNOWN || \
7716 a == VT_RECORD || a > VT_UINT || \
7717 a == 15 /*not defined*/) \
7720 static void test_VarImp(void)
7722 static const WCHAR szFalse
[] = { '#','F','A','L','S','E','#','\0' };
7723 static const WCHAR szTrue
[] = { '#','T','R','U','E','#','\0' };
7724 VARIANT left
, right
, exp
, result
, cy
, dec
;
7725 BSTR true_str
, false_str
;
7731 true_str
= SysAllocString(szTrue
);
7732 false_str
= SysAllocString(szFalse
);
7734 /* Test all possible flag/vt combinations & the resulting vt type */
7735 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
7737 VARTYPE leftvt
, rightvt
, resvt
;
7739 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
7741 SKIPTESTIMP(leftvt
);
7743 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
7746 SKIPTESTIMP(rightvt
);
7748 /* Native crashes using the the extra flag VT_BYREF
7749 * or with the following VT combinations
7751 if ((leftvt
== VT_UI4
&& rightvt
== VT_BSTR
) ||
7752 (leftvt
== VT_UI8
&& rightvt
== VT_BSTR
) ||
7753 ExtraFlags
[i
] == VT_BYREF
)
7756 memset(&left
, 0, sizeof(left
));
7757 memset(&right
, 0, sizeof(right
));
7758 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
7759 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
7760 V_VT(&result
) = VT_EMPTY
;
7763 if (leftvt
== VT_BSTR
)
7764 V_BSTR(&left
) = true_str
;
7766 /* This allows us to test return types that are not NULL
7767 * (NULL Imp value = n, NULL Imp 0 = NULL)
7772 V_BSTR(&right
) = true_str
;
7775 VarDecFromR8(2.0, &V_DECIMAL(&right
));
7776 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
7779 V_BOOL(&right
) = VARIANT_TRUE
;
7781 case VT_I1
: V_I1(&right
) = 2; break;
7782 case VT_I2
: V_I2(&right
) = 2; break;
7783 case VT_I4
: V_I4(&right
) = 2; break;
7784 case VT_R4
: V_R4(&right
) = 2.0f
; break;
7785 case VT_R8
: V_R8(&right
) = 2.0; break;
7786 case VT_CY
: V_CY(&right
).int64
= 10000; break;
7787 case VT_DATE
: V_DATE(&right
) = 2; break;
7788 case VT_I8
: V_I8(&right
) = 2; break;
7789 case VT_INT
: V_INT(&right
) = 2; break;
7790 case VT_UINT
: V_UINT(&right
) = 2; break;
7791 case VT_UI1
: V_UI1(&right
) = 2; break;
7792 case VT_UI2
: V_UI2(&right
) = 2; break;
7793 case VT_UI4
: V_UI4(&right
) = 2; break;
7794 case VT_UI8
: V_UI8(&right
) = 2; break;
7798 /* Native VarImp always returns an error when using extra
7799 * flags or if the variants are I8 and INT.
7801 if ((leftvt
== VT_I8
&& rightvt
== VT_INT
) ||
7805 /* Determine result type */
7806 else if ((leftvt
== VT_BSTR
&& rightvt
== VT_NULL
) ||
7807 (leftvt
== VT_NULL
&& rightvt
== VT_NULL
) ||
7808 (leftvt
== VT_NULL
&& rightvt
== VT_EMPTY
))
7810 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
7812 else if (leftvt
== VT_I4
|| rightvt
== VT_I4
||
7813 leftvt
== VT_INT
|| rightvt
== VT_INT
||
7814 leftvt
== VT_UINT
|| rightvt
== VT_UINT
||
7815 leftvt
== VT_UI4
|| rightvt
== VT_UI4
||
7816 leftvt
== VT_UI8
|| rightvt
== VT_UI8
||
7817 leftvt
== VT_UI2
|| rightvt
== VT_UI2
||
7818 leftvt
== VT_DECIMAL
|| rightvt
== VT_DECIMAL
||
7819 leftvt
== VT_DATE
|| rightvt
== VT_DATE
||
7820 leftvt
== VT_CY
|| rightvt
== VT_CY
||
7821 leftvt
== VT_R8
|| rightvt
== VT_R8
||
7822 leftvt
== VT_R4
|| rightvt
== VT_R4
||
7823 leftvt
== VT_I1
|| rightvt
== VT_I1
)
7825 else if ((leftvt
== VT_UI1
&& rightvt
== VT_UI1
) ||
7826 (leftvt
== VT_UI1
&& rightvt
== VT_NULL
) ||
7827 (leftvt
== VT_NULL
&& rightvt
== VT_UI1
))
7829 else if (leftvt
== VT_EMPTY
|| rightvt
== VT_EMPTY
||
7830 leftvt
== VT_I2
|| rightvt
== VT_I2
||
7831 leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
7833 else if (leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
||
7834 leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
)
7837 hres
= pVarImp(&left
, &right
, &result
);
7839 /* Check expected HRESULT and if result variant type is correct */
7841 ok (hres
== DISP_E_BADVARTYPE
|| hres
== DISP_E_TYPEMISMATCH
,
7842 "VarImp: %s|0x%X, %s|0x%X: got vt %s hr 0x%X\n",
7843 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
],
7844 vtstr(V_VT(&result
)), hres
);
7846 ok (hres
== S_OK
&& resvt
== V_VT(&result
),
7847 "VarImp: %s|0x%X, %s|0x%X: expected vt %s hr 0x%X, got vt %s hr 0x%X\n",
7848 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
], vtstr(resvt
),
7849 S_OK
, vtstr(V_VT(&result
)), hres
);
7854 VARIMP(EMPTY
,0,EMPTY
,0,I2
,-1);
7855 VARIMP(EMPTY
,0,NULL
,0,I2
,-1);
7856 VARIMP(EMPTY
,0,I2
,-1,I2
,-1);
7857 VARIMP(EMPTY
,0,I4
,-1,I4
,-1);
7858 VARIMP(EMPTY
,0,R4
,0.0f
,I4
,-1);
7859 VARIMP(EMPTY
,0,R8
,-1.0,I4
,-1);
7860 VARIMP(EMPTY
,0,DATE
,0,I4
,-1);
7861 VARIMP(EMPTY
,0,BSTR
,true_str
,I2
,-1);
7862 VARIMP(EMPTY
,0,BOOL
,VARIANT_FALSE
,I2
,-1);
7863 VARIMP(EMPTY
,0,I1
,0,I4
,-1);
7864 VARIMP(EMPTY
,0,UI1
,1,I2
,-1);
7865 VARIMP(EMPTY
,0,UI2
,1,I4
,-1);
7866 VARIMP(EMPTY
,0,UI4
,1,I4
,-1);
7867 VARIMP(EMPTY
,0,I8
,1,I8
,-1);
7868 VARIMP(EMPTY
,0,UI8
,1,I4
,-1);
7869 VARIMP(EMPTY
,0,INT
,-1,I4
,-1);
7870 VARIMP(EMPTY
,0,UINT
,1,I4
,-1);
7871 VARIMP(NULL
,0,EMPTY
,0,NULL
,0);
7872 VARIMP(NULL
,0,NULL
,0,NULL
,0);
7873 VARIMP(NULL
,0,I2
,-1,I2
,-1);
7874 VARIMP(NULL
,0,I4
,-1,I4
,-1);
7875 VARIMP(NULL
,0,R4
,0.0f
,NULL
,0);
7876 VARIMP(NULL
,0,R8
,-1.0,I4
,-1);
7877 VARIMP(NULL
,0,DATE
,0,NULL
,0);
7878 VARIMP(NULL
,0,BSTR
,true_str
,BOOL
,-1);
7879 VARIMP(NULL
,0,BOOL
,VARIANT_FALSE
,NULL
,0);
7880 VARIMP(NULL
,0,I1
,0,NULL
,0);
7881 VARIMP(NULL
,0,UI1
,1,UI1
,1);
7882 VARIMP(NULL
,0,UI2
,1,I4
,1);
7883 VARIMP(NULL
,0,UI4
,1,I4
,1);
7884 VARIMP(NULL
,0,I8
,1,I8
,1);
7885 VARIMP(NULL
,0,UI8
,1,I4
,1);
7886 VARIMP(NULL
,0,INT
,-1,I4
,-1);
7887 VARIMP(NULL
,0,UINT
,1,I4
,1);
7888 VARIMP(I2
,-1,EMPTY
,0,I2
,0);
7889 VARIMP(I2
,-1,I2
,-1,I2
,-1);
7890 VARIMP(I2
,-1,I4
,-1,I4
,-1);
7891 VARIMP(I2
,-1,R4
,0.0f
,I4
,0);
7892 VARIMP(I2
,-1,R8
,-1.0,I4
,-1);
7893 VARIMP(I2
,-1,DATE
,0,I4
,0);
7894 VARIMP(I2
,-1,BSTR
,true_str
,I2
,-1);
7895 VARIMP(I2
,-1,BOOL
,VARIANT_FALSE
,I2
,0);
7896 VARIMP(I2
,-1,I1
,0,I4
,0);
7897 VARIMP(I2
,-1,UI1
,1,I2
,1);
7898 VARIMP(I2
,-1,UI2
,1,I4
,1);
7899 VARIMP(I2
,-1,UI4
,1,I4
,1);
7900 VARIMP(I2
,-1,I8
,1,I8
,1);
7901 VARIMP(I2
,-1,UI8
,1,I4
,1);
7902 VARIMP(I2
,-1,INT
,-1,I4
,-1);
7903 VARIMP(I2
,-1,UINT
,1,I4
,1);
7904 VARIMP(I4
,2,EMPTY
,0,I4
,-3);
7905 VARIMP(I4
,2,NULL
,0,I4
,-3);
7906 VARIMP(I4
,2,I2
,-1,I4
,-1);
7907 VARIMP(I4
,2,I4
,-1,I4
,-1);
7908 VARIMP(I4
,2,R4
,0.0f
,I4
,-3);
7909 VARIMP(I4
,2,R8
,-1.0,I4
,-1);
7910 VARIMP(I4
,2,DATE
,0,I4
,-3);
7911 VARIMP(I4
,2,BSTR
,true_str
,I4
,-1);
7912 VARIMP(I4
,2,BOOL
,VARIANT_FALSE
,I4
,-3);
7913 VARIMP(I4
,2,I1
,0,I4
,-3);
7914 VARIMP(I4
,2,UI1
,1,I4
,-3);
7915 VARIMP(I4
,2,UI2
,1,I4
,-3);
7916 VARIMP(I4
,2,UI4
,1,I4
,-3);
7917 VARIMP(I4
,2,I8
,1,I8
,-3);
7918 VARIMP(I4
,2,UI8
,1,I4
,-3);
7919 VARIMP(I4
,2,INT
,-1,I4
,-1);
7920 VARIMP(I4
,2,UINT
,1,I4
,-3);
7921 VARIMP(R4
,-1.0f
,EMPTY
,0,I4
,0);
7922 VARIMP(R4
,-1.0f
,NULL
,0,NULL
,0);
7923 VARIMP(R4
,-1.0f
,I2
,-1,I4
,-1);
7924 VARIMP(R4
,-1.0f
,I4
,-1,I4
,-1);
7925 VARIMP(R4
,-1.0f
,R4
,0.0f
,I4
,0);
7926 VARIMP(R4
,-1.0f
,R8
,-1.0,I4
,-1);
7927 VARIMP(R4
,-1.0f
,DATE
,1,I4
,1);
7928 VARIMP(R4
,-1.0f
,BSTR
,true_str
,I4
,-1);
7929 VARIMP(R4
,-1.0f
,BOOL
,VARIANT_FALSE
,I4
,0);
7930 VARIMP(R4
,-1.0f
,I1
,0,I4
,0);
7931 VARIMP(R4
,-1.0f
,UI1
,1,I4
,1);
7932 VARIMP(R4
,-1.0f
,UI2
,1,I4
,1);
7933 VARIMP(R4
,-1.0f
,UI4
,1,I4
,1);
7934 VARIMP(R4
,-1.0f
,I8
,1,I8
,1);
7935 VARIMP(R4
,-1.0f
,UI8
,1,I4
,1);
7936 VARIMP(R4
,-1.0f
,INT
,-1,I4
,-1);
7937 VARIMP(R4
,-1.0f
,UINT
,1,I4
,1);
7938 VARIMP(R8
,1.0,EMPTY
,0,I4
,-2);
7939 VARIMP(R8
,1.0,NULL
,0,I4
,-2);
7940 VARIMP(R8
,1.0,I2
,-1,I4
,-1);
7941 VARIMP(R8
,1.0,I4
,-1,I4
,-1);
7942 VARIMP(R8
,1.0,R4
,0.0f
,I4
,-2);
7943 VARIMP(R8
,1.0,R8
,-1.0,I4
,-1);
7944 VARIMP(R8
,1.0,DATE
,0,I4
,-2);
7945 VARIMP(R8
,1.0,BSTR
,true_str
,I4
,-1);
7946 VARIMP(R8
,1.0,BOOL
,VARIANT_FALSE
,I4
,-2);
7947 VARIMP(R8
,1.0,I1
,0,I4
,-2);
7948 VARIMP(R8
,1.0,UI1
,1,I4
,-1);
7949 VARIMP(R8
,1.0,UI2
,1,I4
,-1);
7950 VARIMP(R8
,1.0,UI4
,1,I4
,-1);
7951 VARIMP(R8
,1.0,I8
,1,I8
,-1);
7952 VARIMP(R8
,1.0,UI8
,1,I4
,-1);
7953 VARIMP(R8
,1.0,INT
,-1,I4
,-1);
7954 VARIMP(R8
,1.0,UINT
,1,I4
,-1);
7955 VARIMP(DATE
,0,EMPTY
,0,I4
,-1);
7956 VARIMP(DATE
,0,NULL
,0,I4
,-1);
7957 VARIMP(DATE
,0,I2
,-1,I4
,-1);
7958 VARIMP(DATE
,0,I4
,-1,I4
,-1);
7959 VARIMP(DATE
,0,R4
,0.0f
,I4
,-1);
7960 VARIMP(DATE
,0,R8
,-1.0,I4
,-1);
7961 VARIMP(DATE
,0,DATE
,0,I4
,-1);
7962 VARIMP(DATE
,0,BSTR
,true_str
,I4
,-1);
7963 VARIMP(DATE
,0,BOOL
,VARIANT_FALSE
,I4
,-1);
7964 VARIMP(DATE
,0,I1
,0,I4
,-1);
7965 VARIMP(DATE
,0,UI1
,1,I4
,-1);
7966 VARIMP(DATE
,0,UI2
,1,I4
,-1);
7967 VARIMP(DATE
,0,UI4
,1,I4
,-1);
7968 VARIMP(DATE
,0,I8
,1,I8
,-1);
7969 VARIMP(DATE
,0,UI8
,1,I4
,-1);
7970 VARIMP(DATE
,0,INT
,-1,I4
,-1);
7971 VARIMP(DATE
,0,UINT
,1,I4
,-1);
7972 VARIMP(BSTR
,false_str
,EMPTY
,0,I2
,-1);
7973 VARIMP(BSTR
,false_str
,NULL
,0,BOOL
,-1);
7974 VARIMP(BSTR
,false_str
,I2
,-1,I2
,-1);
7975 VARIMP(BSTR
,false_str
,I4
,-1,I4
,-1);
7976 VARIMP(BSTR
,false_str
,R4
,0.0f
,I4
,-1);
7977 VARIMP(BSTR
,false_str
,R8
,-1.0,I4
,-1);
7978 VARIMP(BSTR
,false_str
,DATE
,0,I4
,-1);
7979 VARIMP(BSTR
,false_str
,BSTR
,true_str
,BOOL
,-1);
7980 VARIMP(BSTR
,false_str
,BOOL
,VARIANT_FALSE
,BOOL
,-1);
7981 VARIMP(BSTR
,false_str
,I1
,0,I4
,-1);
7982 VARIMP(BSTR
,false_str
,UI1
,1,I2
,-1);
7983 VARIMP(BSTR
,false_str
,UI2
,1,I4
,-1);
7984 VARIMP(BSTR
,false_str
,UI4
,1,I4
,-1);
7985 VARIMP(BSTR
,false_str
,I8
,1,I8
,-1);
7986 VARIMP(BSTR
,false_str
,UI8
,1,I4
,-1);
7987 VARIMP(BSTR
,false_str
,INT
,-1,I4
,-1);
7988 VARIMP(BSTR
,false_str
,UINT
,1,I4
,-1);
7989 VARIMP(BOOL
,VARIANT_TRUE
,EMPTY
,0,I2
,0);
7990 VARIMP(BOOL
,VARIANT_TRUE
,NULL
,0,NULL
,0);
7991 VARIMP(BOOL
,VARIANT_TRUE
,I2
,-1,I2
,-1);
7992 VARIMP(BOOL
,VARIANT_TRUE
,I4
,-1,I4
,-1);
7993 VARIMP(BOOL
,VARIANT_TRUE
,R4
,0.0f
,I4
,0);
7994 VARIMP(BOOL
,VARIANT_TRUE
,R8
,-1.0,I4
,-1);
7995 VARIMP(BOOL
,VARIANT_TRUE
,DATE
,0,I4
,0);
7996 VARIMP(BOOL
,VARIANT_TRUE
,BSTR
,true_str
,BOOL
,-1);
7997 VARIMP(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
,BOOL
,0);
7998 VARIMP(BOOL
,VARIANT_TRUE
,I1
,0,I4
,0);
7999 VARIMP(BOOL
,VARIANT_TRUE
,UI1
,1,I2
,1);
8000 VARIMP(BOOL
,VARIANT_TRUE
,UI2
,1,I4
,1);
8001 VARIMP(BOOL
,VARIANT_TRUE
,UI4
,1,I4
,1);
8002 VARIMP(BOOL
,VARIANT_TRUE
,I8
,1,I8
,1);
8003 VARIMP(BOOL
,VARIANT_TRUE
,UI8
,1,I4
,1);
8004 VARIMP(BOOL
,VARIANT_TRUE
,INT
,-1,I4
,-1);
8005 VARIMP(BOOL
,VARIANT_TRUE
,UINT
,1,I4
,1);
8006 VARIMP(I1
,-1,EMPTY
,0,I4
,0);
8007 VARIMP(I1
,-1,NULL
,0,NULL
,0);
8008 VARIMP(I1
,-1,I2
,-1,I4
,-1);
8009 VARIMP(I1
,-1,I4
,-1,I4
,-1);
8010 VARIMP(I1
,-1,R4
,0.0f
,I4
,0);
8011 VARIMP(I1
,-1,R8
,-1.0,I4
,-1);
8012 VARIMP(I1
,-1,DATE
,0,I4
,0);
8013 VARIMP(I1
,-1,BSTR
,true_str
,I4
,-1);
8014 VARIMP(I1
,-1,BOOL
,VARIANT_FALSE
,I4
,0);
8015 VARIMP(I1
,-1,I1
,0,I4
,0);
8016 VARIMP(I1
,-1,UI1
,1,I4
,1);
8017 VARIMP(I1
,-1,UI2
,1,I4
,1);
8018 VARIMP(I1
,-1,UI4
,1,I4
,1);
8019 VARIMP(I1
,-1,I8
,1,I8
,1);
8020 VARIMP(I1
,-1,UI8
,1,I4
,1);
8021 VARIMP(I1
,-1,INT
,-1,I4
,-1);
8022 VARIMP(I1
,-1,UINT
,1,I4
,1);
8023 VARIMP(UI1
,0,EMPTY
,0,I2
,-1);
8024 VARIMP(UI1
,0,NULL
,0,UI1
,255);
8025 VARIMP(UI1
,0,I2
,-1,I2
,-1);
8026 VARIMP(UI1
,0,I4
,-1,I4
,-1);
8027 VARIMP(UI1
,0,R4
,0.0f
,I4
,-1);
8028 VARIMP(UI1
,0,R8
,-1.0,I4
,-1);
8029 VARIMP(UI1
,0,DATE
,0,I4
,-1);
8030 VARIMP(UI1
,0,BSTR
,true_str
,I2
,-1);
8031 VARIMP(UI1
,0,BOOL
,VARIANT_FALSE
,I2
,-1);
8032 VARIMP(UI1
,0,I1
,0,I4
,-1);
8033 VARIMP(UI1
,0,UI1
,1,UI1
,255);
8034 VARIMP(UI1
,0,UI2
,1,I4
,-1);
8035 VARIMP(UI1
,0,UI4
,1,I4
,-1);
8036 VARIMP(UI1
,0,I8
,1,I8
,-1);
8037 VARIMP(UI1
,0,UI8
,1,I4
,-1);
8038 VARIMP(UI1
,0,INT
,-1,I4
,-1);
8039 VARIMP(UI1
,0,UINT
,1,I4
,-1);
8040 VARIMP(UI2
,0,EMPTY
,0,I4
,-1);
8041 VARIMP(UI2
,0,NULL
,0,I4
,-1);
8042 VARIMP(UI2
,0,I2
,-1,I4
,-1);
8043 VARIMP(UI2
,0,I4
,-1,I4
,-1);
8044 VARIMP(UI2
,0,R4
,0.0f
,I4
,-1);
8045 VARIMP(UI2
,0,R8
,-1.0,I4
,-1);
8046 VARIMP(UI2
,0,DATE
,0,I4
,-1);
8047 VARIMP(UI2
,0,BSTR
,true_str
,I4
,-1);
8048 VARIMP(UI2
,0,BOOL
,VARIANT_FALSE
,I4
,-1);
8049 VARIMP(UI2
,0,I1
,0,I4
,-1);
8050 VARIMP(UI2
,0,UI1
,1,I4
,-1);
8051 VARIMP(UI2
,0,UI2
,1,I4
,-1);
8052 VARIMP(UI2
,0,UI4
,1,I4
,-1);
8053 VARIMP(UI2
,0,I8
,1,I8
,-1);
8054 VARIMP(UI2
,0,UI8
,1,I4
,-1);
8055 VARIMP(UI2
,0,INT
,-1,I4
,-1);
8056 VARIMP(UI2
,0,UINT
,1,I4
,-1);
8057 VARIMP(UI4
,0,EMPTY
,0,I4
,-1);
8058 VARIMP(UI4
,0,NULL
,0,I4
,-1);
8059 VARIMP(UI4
,0,I2
,-1,I4
,-1);
8060 VARIMP(UI4
,0,I4
,-1,I4
,-1);
8061 VARIMP(UI4
,0,R4
,0.0f
,I4
,-1);
8062 VARIMP(UI4
,0,R8
,-1.0,I4
,-1);
8063 VARIMP(UI4
,0,DATE
,0,I4
,-1);
8064 VARIMP(UI4
,0,BSTR
,true_str
,I4
,-1);
8065 VARIMP(UI4
,0,BOOL
,VARIANT_FALSE
,I4
,-1);
8066 VARIMP(UI4
,0,I1
,0,I4
,-1);
8067 VARIMP(UI4
,0,UI1
,1,I4
,-1);
8068 VARIMP(UI4
,0,UI2
,1,I4
,-1);
8069 VARIMP(UI4
,0,UI4
,1,I4
,-1);
8070 VARIMP(UI4
,0,I8
,1,I8
,-1);
8071 VARIMP(UI4
,0,UI8
,1,I4
,-1);
8072 VARIMP(UI4
,0,INT
,-1,I4
,-1);
8073 VARIMP(UI4
,0,UINT
,1,I4
,-1);
8074 VARIMP(I8
,-1,EMPTY
,0,I8
,0);
8075 VARIMP(I8
,-1,NULL
,0,NULL
,0);
8076 VARIMP(I8
,-1,I2
,-1,I8
,-1);
8077 VARIMP(I8
,-1,I4
,-1,I8
,-1);
8078 VARIMP(I8
,-1,R4
,0.0f
,I8
,0);
8079 VARIMP(I8
,-1,R8
,-1.0,I8
,-1);
8080 VARIMP(I8
,-1,DATE
,0,I8
,0);
8081 VARIMP(I8
,-1,BSTR
,true_str
,I8
,-1);
8082 VARIMP(I8
,-1,BOOL
,VARIANT_FALSE
,I8
,0);
8083 VARIMP(I8
,-1,I1
,0,I8
,0);
8084 VARIMP(I8
,-1,UI1
,1,I8
,1);
8085 VARIMP(I8
,-1,UI2
,1,I8
,1);
8086 VARIMP(I8
,-1,UI4
,1,I8
,1);
8087 VARIMP(I8
,-1,I8
,1,I8
,1);
8088 VARIMP(I8
,-1,UI8
,1,I8
,1);
8089 VARIMP(I8
,-1,UINT
,1,I8
,1);
8090 VARIMP(UI8
,0,EMPTY
,0,I4
,-1);
8091 VARIMP(UI8
,0,NULL
,0,I4
,-1);
8092 VARIMP(UI8
,0,I2
,-1,I4
,-1);
8093 VARIMP(UI8
,0,I4
,-1,I4
,-1);
8094 VARIMP(UI8
,0,R4
,0.0f
,I4
,-1);
8095 VARIMP(UI8
,0,R8
,-1.0,I4
,-1);
8096 VARIMP(UI8
,0,DATE
,0,I4
,-1);
8097 VARIMP(UI8
,0,BSTR
,true_str
,I4
,-1);
8098 VARIMP(UI8
,0,BOOL
,VARIANT_FALSE
,I4
,-1);
8099 VARIMP(UI8
,0,I1
,0,I4
,-1);
8100 VARIMP(UI8
,0,UI1
,1,I4
,-1);
8101 VARIMP(UI8
,0,UI2
,1,I4
,-1);
8102 VARIMP(UI8
,0,UI4
,1,I4
,-1);
8103 VARIMP(UI8
,0,I8
,1,I8
,-1);
8104 VARIMP(UI8
,0,UI8
,1,I4
,-1);
8105 VARIMP(UI8
,0,INT
,-1,I4
,-1);
8106 VARIMP(UI8
,0,UINT
,1,I4
,-1);
8107 VARIMP(INT
,-1,EMPTY
,0,I4
,0);
8108 VARIMP(INT
,-1,NULL
,0,NULL
,0);
8109 VARIMP(INT
,-1,I2
,-1,I4
,-1);
8110 VARIMP(INT
,-1,I4
,-1,I4
,-1);
8111 VARIMP(INT
,-1,R4
,0.0f
,I4
,0);
8112 VARIMP(INT
,-1,R8
,-1.0,I4
,-1);
8113 VARIMP(INT
,-1,DATE
,0,I4
,0);
8114 VARIMP(INT
,-1,BSTR
,true_str
,I4
,-1);
8115 VARIMP(INT
,-1,BOOL
,VARIANT_FALSE
,I4
,0);
8116 VARIMP(INT
,-1,I1
,0,I4
,0);
8117 VARIMP(INT
,-1,UI1
,1,I4
,1);
8118 VARIMP(INT
,-1,UI2
,1,I4
,1);
8119 VARIMP(INT
,-1,UI4
,1,I4
,1);
8120 VARIMP(INT
,-1,I8
,1,I8
,1);
8121 VARIMP(INT
,-1,UI8
,1,I4
,1);
8122 VARIMP(INT
,-1,INT
,-1,I4
,-1);
8123 VARIMP(INT
,-1,UINT
,1,I4
,1);
8124 VARIMP(UINT
,1,EMPTY
,0,I4
,-2);
8125 VARIMP(UINT
,1,NULL
,0,I4
,-2);
8126 VARIMP(UINT
,1,I2
,-1,I4
,-1);
8127 VARIMP(UINT
,1,I4
,-1,I4
,-1);
8128 VARIMP(UINT
,1,R4
,0.0f
,I4
,-2);
8129 VARIMP(UINT
,1,R8
,-1.0,I4
,-1);
8130 VARIMP(UINT
,1,DATE
,0,I4
,-2);
8131 VARIMP(UINT
,1,BSTR
,true_str
,I4
,-1);
8132 VARIMP(UINT
,1,BOOL
,VARIANT_FALSE
,I4
,-2);
8133 VARIMP(UINT
,1,I1
,0,I4
,-2);
8134 VARIMP(UINT
,1,UI1
,1,I4
,-1);
8135 VARIMP(UINT
,1,UI2
,1,I4
,-1);
8136 VARIMP(UINT
,1,UI4
,1,I4
,-1);
8137 VARIMP(UINT
,1,I8
,1,I8
,-1);
8138 VARIMP(UINT
,1,UI8
,1,I4
,-1);
8139 VARIMP(UINT
,1,INT
,-1,I4
,-1);
8140 VARIMP(UINT
,1,UINT
,1,I4
,-1);
8142 /* Manually test some VT_CY, VT_DECIMAL variants */
8144 hres
= VarCyFromI4(1, &V_CY(&cy
));
8145 ok(hres
== S_OK
, "VarCyFromI4 failed!\n");
8146 V_VT(&dec
) = VT_DECIMAL
;
8147 hres
= VarDecFromR8(2.0, &V_DECIMAL(&dec
));
8148 ok(hres
== S_OK
, "VarDecFromR4 failed!\n");
8149 memset(&left
, 0, sizeof(left
));
8150 memset(&right
, 0, sizeof(right
));
8151 V_VT(&left
) = VT_I4
;
8153 V_VT(&right
) = VT_I8
;
8156 hres
= pVarImp(&cy
, &cy
, &result
);
8157 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
8158 "VARIMP: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8159 S_OK
, hres
, vtstr(V_VT(&result
)));
8160 ok(hres
== S_OK
&& V_I4(&result
) == -1,
8161 "VARIMP: CY value %d, expected %d\n", V_I4(&result
), -1);
8163 hres
= pVarImp(&cy
, &right
, &result
);
8164 ok(hres
== S_OK
&& V_VT(&result
) == VT_I8
,
8165 "VARIMP: expected coerced hres 0x%X type VT_I8, got hres 0x%X type %s!\n",
8166 S_OK
, hres
, vtstr(V_VT(&result
)));
8167 ok(hres
== S_OK
&& V_I8(&result
) == -2,
8168 "VARIMP: CY value %x%08x, expected %d\n",
8169 (DWORD
)((V_I8(&result
)) >> 32), (DWORD
)(V_I8(&result
)), -2);
8171 hres
= pVarImp(&left
, &cy
, &result
);
8172 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
8173 "VARIMP: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8174 S_OK
, hres
, vtstr(V_VT(&result
)));
8175 ok(hres
== S_OK
&& V_I4(&result
) == -1,
8176 "VARIMP: CY value %d, expected %d\n", V_I4(&result
), -1);
8178 hres
= pVarImp(&left
, &dec
, &result
);
8179 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
8180 "VARIMP: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8181 S_OK
, hres
, vtstr(V_VT(&result
)));
8182 ok(hres
== S_OK
&& V_I4(&result
) == -1,
8183 "VARIMP: DECIMAL value %d, expected %d\n", V_I4(&result
), -1);
8185 hres
= pVarImp(&dec
, &dec
, &result
);
8186 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
8187 "VARIMP: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8188 S_OK
, hres
, vtstr(V_VT(&result
)));
8189 ok(hres
== S_OK
&& V_I4(&result
) == -1,
8190 "VARIMP: DECIMAL value %d, expected %d\n", V_I4(&result
), -1);
8192 hres
= pVarImp(&dec
, &right
, &result
);
8193 ok(hres
== S_OK
&& V_VT(&result
) == VT_I8
,
8194 "VARIMP: expected coerced hres 0x%X type VT_I8, got hres 0x%X type%s!\n",
8195 S_OK
, hres
, vtstr(V_VT(&result
)));
8196 ok(hres
== S_OK
&& V_I8(&result
) == -3,
8197 "VARIMP: DECIMAL value 0x%x%08x, expected %d\n",
8198 (DWORD
)(V_I8(&result
) >>32), (DWORD
)V_I8(&result
), -3);
8200 SysFreeString(false_str
);
8201 SysFreeString(true_str
);
8206 hOleaut32
= LoadLibraryA("oleaut32.dll");
8209 test_VariantClear();
8211 test_VariantCopyInd();
8212 test_VarParseNumFromStr();
8213 test_VarNumFromParseNum();
8214 test_VarUdateFromDate();
8215 test_VarDateFromUdate();
8216 test_SystemTimeToVariantTime();
8217 test_VariantTimeToSystemTime();
8218 test_DosDateTimeToVariantTime();
8219 test_VariantTimeToDosDateTime();