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))<1e-14)
70 #define EQ_FLOAT(a,b) (fabs((a)-(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 /* Macros to set a DECIMAL */
103 #define SETDEC(dec, scl, sgn, hi, lo) S(U(dec)).scale = (BYTE)scl; \
104 S(U(dec)).sign = (BYTE)sgn; dec.Hi32 = (ULONG)hi; \
105 U1(dec).Lo64 = (ULONG64)lo
106 #define SETDEC64(dec, scl, sgn, hi, mid, lo) S(U(dec)).scale = (BYTE)scl; \
107 S(U(dec)).sign = (BYTE)sgn; dec.Hi32 = (ULONG)hi; \
108 S1(U1(dec)).Mid32 = mid; S1(U1(dec)).Lo32 = lo;
110 static inline int strcmpW( const WCHAR
*str1
, const WCHAR
*str2
)
112 while (*str1
&& (*str1
== *str2
)) { str1
++; str2
++; }
113 return *str1
- *str2
;
116 /* return the string text of a given variant type */
117 static const char *vtstr(int x
)
139 return "VT_DISPATCH";
175 return "VT_SAFEARRAY";
179 return "VT_USERDEFINED";
187 return "VT_FILETIME";
195 return "VT_STREAMED_OBJECT";
197 return "VT_STORED_OBJECT";
199 return "VT_BLOB_OBJECT";
205 return "VT_BSTR_BLOB/VT_ILLEGALMASKED/VT_TYPEMASK";
213 return "VT_RESERVED";
222 static BOOL
is_expected_variant( const VARIANT
*result
, const VARIANT
*expected
)
224 if (V_VT(result
) != V_VT(expected
)) return FALSE
;
225 switch(V_VT(expected
))
231 #define CASE(vt) case VT_##vt: return (V_##vt(result) == V_##vt(expected))
246 return EQ_FLOAT(V_DATE(result
), V_DATE(expected
));
248 return EQ_FLOAT(V_R4(result
), V_R4(expected
));
250 return EQ_FLOAT(V_R8(result
), V_R8(expected
));
252 return (V_CY(result
).int64
== V_CY(expected
).int64
);
254 return !lstrcmpW( V_BSTR(result
), V_BSTR(expected
) );
256 return !memcmp( &V_DECIMAL(result
), &V_DECIMAL(expected
), sizeof(DECIMAL
) );
258 ok(0, "unhandled variant type %s\n",vtstr(V_VT(expected
)));
263 static const char *variantstr( const VARIANT
*var
)
265 static char buffer
[16][256];
280 sprintf( buffer
[current
], "VT_I1(%d)", V_I1(var
) ); break;
282 sprintf( buffer
[current
], "VT_I2(%d)", V_I2(var
) ); break;
284 sprintf( buffer
[current
], "VT_I4(%d)", V_I4(var
) ); break;
286 sprintf( buffer
[current
], "VT_INT(%d)", V_INT(var
) ); break;
288 sprintf( buffer
[current
], "VT_I8(%x%08x)", (UINT
)(V_I8(var
) >> 32), (UINT
)V_I8(var
) ); break;
290 sprintf( buffer
[current
], "VT_UI8(%x%08x)", (UINT
)(V_UI8(var
) >> 32), (UINT
)V_UI8(var
) ); break;
292 sprintf( buffer
[current
], "VT_R4(%g)", V_R4(var
) ); break;
294 sprintf( buffer
[current
], "VT_R8(%g)", V_R8(var
) ); break;
296 sprintf( buffer
[current
], "VT_UI1(%u)", V_UI1(var
) ); break;
298 sprintf( buffer
[current
], "VT_UI2(%u)", V_UI2(var
) ); break;
300 sprintf( buffer
[current
], "VT_UI4(%u)", V_UI4(var
) ); break;
302 sprintf( buffer
[current
], "VT_UINT(%d)", V_UINT(var
) ); break;
304 sprintf( buffer
[current
], "VT_CY(%x%08x)", S(V_CY(var
)).Hi
, S(V_CY(var
)).Lo
); break;
306 sprintf( buffer
[current
], "VT_DATE(%g)", V_DATE(var
) ); break;
308 return vtstr(V_VT(var
));
310 return buffer
[current
++];
313 static void test_var_call1( int line
, HRESULT (WINAPI
*func
)(LPVARIANT
,LPVARIANT
),
314 VARIANT
*arg
, VARIANT
*expected
)
316 VARIANT old_arg
= *arg
;
320 memset( &result
, 0, sizeof(result
) );
321 hres
= func( arg
, &result
);
322 ok_(__FILE__
,line
)( hres
== S_OK
, "wrong result %x\n", hres
);
324 ok_(__FILE__
,line
)( is_expected_variant( &result
, expected
),
325 "got %s expected %s\n", variantstr(&result
), variantstr(expected
) );
326 ok_(__FILE__
,line
)( is_expected_variant( arg
, &old_arg
), "Modified argument %s / %s\n",
327 variantstr(&old_arg
), variantstr(arg
));
330 static void test_var_call2( int line
, HRESULT (WINAPI
*func
)(LPVARIANT
,LPVARIANT
,LPVARIANT
),
331 VARIANT
*left
, VARIANT
*right
, VARIANT
*expected
)
333 VARIANT old_left
= *left
, old_right
= *right
;
337 memset( &result
, 0, sizeof(result
) );
338 hres
= func( left
, right
, &result
);
339 ok_(__FILE__
,line
)( hres
== S_OK
, "wrong result %x\n", hres
);
341 ok_(__FILE__
,line
)( is_expected_variant( &result
, expected
),
342 "got %s expected %s\n", variantstr(&result
), variantstr(expected
) );
343 ok_(__FILE__
,line
)( is_expected_variant( left
, &old_left
), "Modified left argument %s / %s\n",
344 variantstr(&old_left
), variantstr(left
));
345 ok_(__FILE__
,line
)( is_expected_variant( right
, &old_right
), "Modified right argument %s / %s\n",
346 variantstr(&old_right
), variantstr(right
));
350 static void test_VariantInit(void)
354 /* Test that VariantInit() only sets the type */
355 memset(&v1
, -1, sizeof(v1
));
357 V_VT(&v2
) = VT_EMPTY
;
359 ok(!memcmp(&v1
, &v2
, sizeof(v1
)), "VariantInit() set extra fields\n");
362 /* All possible combinations of extra V_VT() flags */
363 static const VARTYPE ExtraFlags
[16] =
372 VT_VECTOR
|VT_RESERVED
,
373 VT_VECTOR
|VT_ARRAY
|VT_BYREF
,
374 VT_VECTOR
|VT_ARRAY
|VT_RESERVED
,
375 VT_VECTOR
|VT_BYREF
|VT_RESERVED
,
376 VT_VECTOR
|VT_ARRAY
|VT_BYREF
|VT_RESERVED
,
378 VT_ARRAY
|VT_RESERVED
,
379 VT_ARRAY
|VT_BYREF
|VT_RESERVED
,
380 VT_BYREF
|VT_RESERVED
,
383 /* Determine if a vt is valid for VariantClear() */
384 static int IsValidVariantClearVT(VARTYPE vt
, VARTYPE extraFlags
)
388 /* Only the following flags/types are valid */
389 if ((vt
<= VT_LPWSTR
|| vt
== VT_RECORD
|| vt
== VT_CLSID
) &&
391 (vt
< (VARTYPE
)24 || vt
> (VARTYPE
)31) &&
392 (!(extraFlags
& (VT_BYREF
|VT_ARRAY
)) || vt
> VT_NULL
) &&
393 (extraFlags
== 0 || extraFlags
== VT_BYREF
|| extraFlags
== VT_ARRAY
||
394 extraFlags
== (VT_ARRAY
|VT_BYREF
)))
397 if ((vt
== VT_RECORD
&& !HAVE_OLEAUT32_RECORD
) ||
398 ((vt
== VT_I8
|| vt
== VT_UI8
) && !HAVE_OLEAUT32_I8
))
399 ret
= 0; /* Old versions of oleaut32 */
405 const IUnknownVtbl
*lpVtbl
;
408 } test_VariantClearImpl
;
410 static HRESULT WINAPI
VC_QueryInterface(LPUNKNOWN iface
,REFIID riid
,LPVOID
*ppobj
)
412 test_VariantClearImpl
*This
= (test_VariantClearImpl
*)iface
;
414 return E_NOINTERFACE
;
417 static ULONG WINAPI
VC_AddRef(LPUNKNOWN iface
) {
418 test_VariantClearImpl
*This
= (test_VariantClearImpl
*)iface
;
420 return InterlockedIncrement(&This
->ref
);
423 static ULONG WINAPI
VC_Release(LPUNKNOWN iface
) {
424 test_VariantClearImpl
*This
= (test_VariantClearImpl
*)iface
;
425 /* static class, won't be freed */
427 return InterlockedDecrement(&This
->ref
);
430 static const IUnknownVtbl test_VariantClear_vtbl
= {
436 static test_VariantClearImpl test_myVariantClearImpl
= {&test_VariantClear_vtbl
, 1, 0};
438 static void test_VariantClear(void)
447 /* Crashes: Native does not test input for NULL, so neither does Wine */
448 if (0) hres
= VariantClear(NULL
);
450 /* Only the type field is set, to VT_EMPTY */
453 hres
= VariantClear(&v
);
454 ok((hres
== S_OK
&& V_VT(&v
) == VT_EMPTY
) ||
455 (IS_ANCIENT
&& hres
== DISP_E_BADVARTYPE
&& V_VT(&v
) == VT_UI4
),
456 "VariantClear: Type set to %d, res %08x\n", V_VT(&v
), hres
);
457 ok(V_UI4(&v
) == ~0u, "VariantClear: Overwrote value\n");
459 /* Test all possible V_VT values.
460 * Also demonstrates that null pointers in 'v' are not dereferenced.
461 * Individual variant tests should test VariantClear() with non-NULL values.
463 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]) && !IS_ANCIENT
; i
++)
467 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
469 HRESULT hExpected
= DISP_E_BADVARTYPE
;
473 memset(&v
, 0, sizeof(v
));
474 V_VT(&v
) = vt
| ExtraFlags
[i
];
476 hres
= VariantClear(&v
);
478 if (IsValidVariantClearVT(vt
, ExtraFlags
[i
]))
481 ok(hres
== hExpected
, "VariantClear: expected 0x%X, got 0x%X for vt %d | 0x%X\n",
482 hExpected
, hres
, vt
, ExtraFlags
[i
]);
486 /* Some BYREF tests with non-NULL ptrs */
491 V_VT(&v
) = VT_VARIANT
| VT_BYREF
;
492 V_VARIANTREF(&v
) = &v2
;
494 hres
= VariantClear(&v
);
495 ok(hres
== S_OK
, "ret %08x\n", hres
);
496 ok(V_VT(&v
) == 0, "vt %04x\n", V_VT(&v
));
497 ok(V_VARIANTREF(&v
) == &v2
, "variant ref %p\n", V_VARIANTREF(&v2
));
498 ok(V_VT(&v2
) == VT_I4
, "vt %04x\n", V_VT(&v2
));
499 ok(V_I4(&v2
) == 0x1234, "i4 %04x\n", V_I4(&v2
));
503 V_VT(&v
) = VT_I4
| VT_BYREF
;
506 hres
= VariantClear(&v
);
507 ok(hres
== S_OK
, "ret %08x\n", hres
);
508 ok(V_VT(&v
) == 0, "vt %04x\n", V_VT(&v
));
509 ok(V_I4REF(&v
) == &i4
, "i4 ref %p\n", V_I4REF(&v2
));
510 ok(i4
== 0x4321, "i4 changed %08x\n", i4
);
514 V_VT(&v
) = VT_UNKNOWN
;
515 V_UNKNOWN(&v
) = (IUnknown
*)&test_myVariantClearImpl
;
516 test_myVariantClearImpl
.events
= 0;
517 hres
= VariantClear(&v
);
518 ok(hres
== S_OK
, "ret %08x\n", hres
);
519 ok(V_VT(&v
) == 0, "vt %04x\n", V_VT(&v
));
520 ok(V_UNKNOWN(&v
) == (IUnknown
*)&test_myVariantClearImpl
, "unknown %p\n", V_UNKNOWN(&v
));
521 /* Check that Release got called, but nothing else */
522 ok(test_myVariantClearImpl
.events
== 0x4, "Unexpected call. events %08x\n", test_myVariantClearImpl
.events
);
525 punk
= (IUnknown
*)&test_myVariantClearImpl
;
526 V_VT(&v
) = VT_UNKNOWN
| VT_BYREF
;
527 V_UNKNOWNREF(&v
) = &punk
;
528 test_myVariantClearImpl
.events
= 0;
529 hres
= VariantClear(&v
);
530 ok(hres
== S_OK
, "ret %08x\n", hres
);
531 ok(V_VT(&v
) == 0, "vt %04x\n", V_VT(&v
));
532 ok(V_UNKNOWNREF(&v
) == &punk
, "unknown ref %p\n", V_UNKNOWNREF(&v
));
533 /* Check that nothing got called */
534 ok(test_myVariantClearImpl
.events
== 0, "Unexpected call. events %08x\n", test_myVariantClearImpl
.events
);
537 V_VT(&v
) = VT_DISPATCH
;
538 V_DISPATCH(&v
) = (IDispatch
*)&test_myVariantClearImpl
;
539 test_myVariantClearImpl
.events
= 0;
540 hres
= VariantClear(&v
);
541 ok(hres
== S_OK
, "ret %08x\n", hres
);
542 ok(V_VT(&v
) == 0, "vt %04x\n", V_VT(&v
));
543 ok(V_DISPATCH(&v
) == (IDispatch
*)&test_myVariantClearImpl
, "dispatch %p\n", V_DISPATCH(&v
));
544 /* Check that Release got called, but nothing else */
545 ok(test_myVariantClearImpl
.events
== 0x4, "Unexpected call. events %08x\n", test_myVariantClearImpl
.events
);
548 punk
= (IUnknown
*)&test_myVariantClearImpl
;
549 V_VT(&v
) = VT_DISPATCH
| VT_BYREF
;
550 V_DISPATCHREF(&v
) = (IDispatch
**)&punk
;
551 test_myVariantClearImpl
.events
= 0;
552 hres
= VariantClear(&v
);
553 ok(hres
== S_OK
, "ret %08x\n", hres
);
554 ok(V_VT(&v
) == 0, "vt %04x\n", V_VT(&v
));
555 ok(V_DISPATCHREF(&v
) == (IDispatch
**)&punk
, "dispatch ref %p\n", V_DISPATCHREF(&v
));
556 /* Check that nothing got called */
557 ok(test_myVariantClearImpl
.events
== 0, "Unexpected call. events %08x\n", test_myVariantClearImpl
.events
);
560 static void test_VariantCopy(void)
562 VARIANTARG vSrc
, vDst
;
565 HRESULT hres
, hExpected
;
567 /* Establish that the failure/other cases are dealt with. Individual tests
568 * for each type should verify that data is copied correctly, references
573 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]) && !IS_ANCIENT
; i
++)
575 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
579 memset(&vSrc
, 0, sizeof(vSrc
));
580 V_VT(&vSrc
) = vt
| ExtraFlags
[i
];
582 hExpected
= DISP_E_BADVARTYPE
;
583 /* src is allowed to be a VT_CLSID */
584 if (vt
!= VT_CLSID
&& IsValidVariantClearVT(vt
, ExtraFlags
[i
]))
587 hres
= VariantCopy(&vSrc
, &vSrc
);
589 ok(hres
== hExpected
,
590 "Copy(src==dst): expected 0x%X, got 0x%X for src==dest vt %d|0x%X\n",
591 hExpected
, hres
, vt
, ExtraFlags
[i
]);
595 /* Test that if VariantClear() fails on dest, the function fails. This also
596 * shows that dest is in fact cleared and not just overwritten
598 memset(&vSrc
, 0, sizeof(vSrc
));
599 V_VT(&vSrc
) = VT_UI1
;
601 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]) && !IS_ANCIENT
; i
++)
603 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
607 hExpected
= DISP_E_BADVARTYPE
;
609 memset(&vDst
, 0, sizeof(vDst
));
610 V_VT(&vDst
) = vt
| ExtraFlags
[i
];
612 if (IsValidVariantClearVT(vt
, ExtraFlags
[i
]))
615 hres
= VariantCopy(&vDst
, &vSrc
);
617 ok(hres
== hExpected
,
618 "Copy(bad dst): expected 0x%X, got 0x%X for dest vt %d|0x%X\n",
619 hExpected
, hres
, vt
, ExtraFlags
[i
]);
621 ok(V_VT(&vDst
) == VT_UI1
,
622 "Copy(bad dst): expected vt = VT_UI1, got %d\n", V_VT(&vDst
));
626 /* Test that VariantClear() checks vSrc for validity before copying */
627 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]) && !IS_ANCIENT
; i
++)
629 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
633 hExpected
= DISP_E_BADVARTYPE
;
635 memset(&vDst
, 0, sizeof(vDst
));
636 V_VT(&vDst
) = VT_EMPTY
;
638 memset(&vSrc
, 0, sizeof(vSrc
));
639 V_VT(&vSrc
) = vt
| ExtraFlags
[i
];
641 /* src is allowed to be a VT_CLSID */
642 if (vt
!= VT_CLSID
&& IsValidVariantClearVT(vt
, ExtraFlags
[i
]))
645 hres
= VariantCopy(&vDst
, &vSrc
);
647 ok(hres
== hExpected
,
648 "Copy(bad src): expected 0x%X, got 0x%X for src vt %d|0x%X\n",
649 hExpected
, hres
, vt
, ExtraFlags
[i
]);
651 ok(V_VT(&vDst
) == (vt
|ExtraFlags
[i
]),
652 "Copy(bad src): expected vt = %d, got %d\n",
653 vt
| ExtraFlags
[i
], V_VT(&vDst
));
657 /* Test that copying a NULL BSTR results in an empty BSTR */
658 memset(&vDst
, 0, sizeof(vDst
));
659 V_VT(&vDst
) = VT_EMPTY
;
660 memset(&vSrc
, 0, sizeof(vSrc
));
661 V_VT(&vSrc
) = VT_BSTR
;
662 hres
= VariantCopy(&vDst
, &vSrc
);
663 ok(hres
== S_OK
, "Copy(NULL BSTR): Failed to copy a NULL BSTR\n");
666 ok((V_VT(&vDst
) == VT_BSTR
) && V_BSTR(&vDst
),
667 "Copy(NULL BSTR): should have non-NULL result\n");
668 if ((V_VT(&vDst
) == VT_BSTR
) && V_BSTR(&vDst
))
670 ok(*V_BSTR(&vDst
) == 0, "Copy(NULL BSTR): result not empty\n");
675 /* Determine if a vt is valid for VariantCopyInd() */
676 static int IsValidVariantCopyIndVT(VARTYPE vt
, VARTYPE extraFlags
)
680 if ((extraFlags
& VT_ARRAY
) ||
681 (vt
> VT_NULL
&& vt
!= (VARTYPE
)15 && vt
< VT_VOID
&&
682 !(extraFlags
& (VT_VECTOR
|VT_RESERVED
))))
689 static void test_VariantCopyInd(void)
691 VARIANTARG vSrc
, vDst
, vRef
, vRef2
;
695 HRESULT hres
, hExpected
;
697 memset(buffer
, 0, sizeof(buffer
));
700 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]) && !IS_ANCIENT
; i
++)
702 if (ExtraFlags
[i
] & VT_ARRAY
)
703 continue; /* Native crashes on NULL safearray */
705 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
709 memset(&vSrc
, 0, sizeof(vSrc
));
710 V_VT(&vSrc
) = vt
| ExtraFlags
[i
];
712 hExpected
= DISP_E_BADVARTYPE
;
713 if (!(ExtraFlags
[i
] & VT_BYREF
))
715 /* if src is not by-reference, acts as VariantCopy() */
716 if (vt
!= VT_CLSID
&& IsValidVariantClearVT(vt
, ExtraFlags
[i
]))
721 if (vt
== VT_SAFEARRAY
|| vt
== VT_BSTR
|| vt
== VT_UNKNOWN
||
722 vt
== VT_DISPATCH
|| vt
== VT_RECORD
)
723 continue; /* Need valid ptrs for deep copies */
725 V_BYREF(&vSrc
) = &buffer
;
726 hExpected
= E_INVALIDARG
;
728 if ((vt
== VT_I8
|| vt
== VT_UI8
) &&
729 ExtraFlags
[i
] == VT_BYREF
)
731 if (HAVE_OLEAUT32_I8
)
732 hExpected
= S_OK
; /* Only valid if I8 is a known type */
734 else if (IsValidVariantCopyIndVT(vt
, ExtraFlags
[i
]))
738 hres
= VariantCopyInd(&vSrc
, &vSrc
);
740 ok(hres
== hExpected
,
741 "CopyInd(src==dst): expected 0x%X, got 0x%X for src==dst vt %d|0x%X\n",
742 hExpected
, hres
, vt
, ExtraFlags
[i
]);
747 memset(&vSrc
, 0, sizeof(vSrc
));
748 V_VT(&vSrc
) = VT_UI1
|VT_BYREF
;
749 V_BYREF(&vSrc
) = &buffer
;
751 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]) && !IS_ANCIENT
; i
++)
753 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
757 memset(&vDst
, 0, sizeof(vDst
));
758 V_VT(&vDst
) = vt
| ExtraFlags
[i
];
760 hExpected
= DISP_E_BADVARTYPE
;
762 if (IsValidVariantClearVT(vt
, ExtraFlags
[i
]))
765 hres
= VariantCopyInd(&vDst
, &vSrc
);
767 ok(hres
== hExpected
,
768 "CopyInd(bad dst): expected 0x%X, got 0x%X for dst vt %d|0x%X\n",
769 hExpected
, hres
, vt
, ExtraFlags
[i
]);
771 ok(V_VT(&vDst
) == VT_UI1
,
772 "CopyInd(bad dst): expected vt = VT_UI1, got %d\n", V_VT(&vDst
));
777 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]) && !IS_ANCIENT
; i
++)
779 if (ExtraFlags
[i
] & VT_ARRAY
)
780 continue; /* Native crashes on NULL safearray */
782 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
786 memset(&vDst
, 0, sizeof(vDst
));
787 V_VT(&vDst
) = VT_EMPTY
;
789 memset(&vSrc
, 0, sizeof(vSrc
));
790 V_VT(&vSrc
) = vt
| ExtraFlags
[i
];
792 hExpected
= DISP_E_BADVARTYPE
;
793 if (!(ExtraFlags
[i
] & VT_BYREF
))
795 /* if src is not by-reference, acts as VariantCopy() */
796 if (vt
!= VT_CLSID
&& IsValidVariantClearVT(vt
, ExtraFlags
[i
]))
801 if (vt
== VT_SAFEARRAY
|| vt
== VT_BSTR
|| vt
== VT_UNKNOWN
||
802 vt
== VT_DISPATCH
|| vt
== VT_RECORD
)
803 continue; /* Need valid ptrs for deep copies, see vartype.c */
805 V_BYREF(&vSrc
) = &buffer
;
807 hExpected
= E_INVALIDARG
;
809 if ((vt
== VT_I8
|| vt
== VT_UI8
) &&
810 ExtraFlags
[i
] == VT_BYREF
)
812 if (HAVE_OLEAUT32_I8
)
813 hExpected
= S_OK
; /* Only valid if I8 is a known type */
815 else if (IsValidVariantCopyIndVT(vt
, ExtraFlags
[i
]))
819 hres
= VariantCopyInd(&vDst
, &vSrc
);
821 ok(hres
== hExpected
,
822 "CopyInd(bad src): expected 0x%X, got 0x%X for src vt %d|0x%X\n",
823 hExpected
, hres
, vt
, ExtraFlags
[i
]);
826 if (vt
== VT_VARIANT
&& ExtraFlags
[i
] == VT_BYREF
)
828 /* Type of vDst should be the type of the referenced variant.
829 * Since we set the buffer to all zeros, its type should be
832 ok(V_VT(&vDst
) == VT_EMPTY
,
833 "CopyInd(bad src): expected dst vt = VT_EMPTY, got %d|0x%X\n",
834 V_VT(&vDst
) & VT_TYPEMASK
, V_VT(&vDst
) & ~VT_TYPEMASK
);
838 ok(V_VT(&vDst
) == (vt
|(ExtraFlags
[i
] & ~VT_BYREF
)),
839 "CopyInd(bad src): expected dst vt = %d|0x%X, got %d|0x%X\n",
840 vt
, ExtraFlags
[i
] & ~VT_BYREF
,
841 V_VT(&vDst
) & VT_TYPEMASK
, V_VT(&vDst
) & ~VT_TYPEMASK
);
847 /* By-reference variants are dereferenced */
848 V_VT(&vRef
) = VT_UI1
;
850 V_VT(&vSrc
) = VT_VARIANT
|VT_BYREF
;
851 V_VARIANTREF(&vSrc
) = &vRef
;
854 hres
= VariantCopyInd(&vDst
, &vSrc
);
855 ok(V_VT(&vDst
) == VT_UI1
&& V_UI1(&vDst
) == 0x77,
856 "CopyInd(deref): expected dst vt = VT_UI1, val 0x77, got %d|0x%X, 0x%2X\n",
857 V_VT(&vDst
) & VT_TYPEMASK
, V_VT(&vDst
) & ~VT_TYPEMASK
, V_UI1(&vDst
));
859 /* By-reference variant to a by-reference type succeeds */
860 V_VT(&vRef
) = VT_UI1
|VT_BYREF
;
861 V_UI1REF(&vRef
) = buffer
; buffer
[0] = 0x88;
862 V_VT(&vSrc
) = VT_VARIANT
|VT_BYREF
;
863 V_VARIANTREF(&vSrc
) = &vRef
;
866 hres
= VariantCopyInd(&vDst
, &vSrc
);
867 ok(V_VT(&vDst
) == VT_UI1
&& V_UI1(&vDst
) == 0x88,
868 "CopyInd(deref): expected dst vt = VT_UI1, val 0x77, got %d|0x%X, 0x%2X\n",
869 V_VT(&vDst
) & VT_TYPEMASK
, V_VT(&vDst
) & ~VT_TYPEMASK
, V_UI1(&vDst
));
871 /* But a by-reference variant to a by-reference variant fails */
872 V_VT(&vRef2
) = VT_UI1
;
873 V_UI1(&vRef2
) = 0x77;
874 V_VT(&vRef
) = VT_VARIANT
|VT_BYREF
;
875 V_VARIANTREF(&vRef
) = &vRef2
;
876 V_VT(&vSrc
) = VT_VARIANT
|VT_BYREF
;
877 V_VARIANTREF(&vSrc
) = &vRef
;
880 hres
= VariantCopyInd(&vDst
, &vSrc
);
881 ok(hres
== E_INVALIDARG
,
882 "CopyInd(ref->ref): expected E_INVALIDARG, got 0x%08x\n", hres
);
885 static HRESULT (WINAPI
*pVarParseNumFromStr
)(OLECHAR
*,LCID
,ULONG
,NUMPARSE
*,BYTE
*);
887 /* Macros for converting and testing the result of VarParseNumFromStr */
890 static HRESULT
convert_str( const char *str
, INT dig
, ULONG flags
,
891 NUMPARSE
*np
, BYTE rgb
[128], LCID lcid
)
894 MultiByteToWideChar( CP_ACP
,0, str
, -1, buff
, sizeof(buff
)/sizeof(WCHAR
) );
895 memset( rgb
, FAILDIG
, 128 );
896 memset( np
, 255, sizeof(*np
) );
898 np
->dwInFlags
= flags
;
899 return pVarParseNumFromStr( buff
, lcid
, LOCALE_NOUSEROVERRIDE
, np
, rgb
);
902 static void expect_NumFromStr( int line
, HRESULT hres
, NUMPARSE
*np
, INT a
, ULONG b
, ULONG c
,
903 INT d
, INT e
, INT f
)
905 if (hres
== (HRESULT
)S_OK
)
907 ok_(__FILE__
,line
)(np
->cDig
== a
, "Expected cDig = %d, got %d\n", a
, np
->cDig
);
908 ok_(__FILE__
,line
)(np
->dwInFlags
== b
, "Expected dwInFlags = 0x%x, got 0x%x\n", b
, np
->dwInFlags
);
909 ok_(__FILE__
,line
)(np
->dwOutFlags
== c
, "Expected dwOutFlags = 0x%x, got 0x%x\n", c
, np
->dwOutFlags
);
910 ok_(__FILE__
,line
)(np
->cchUsed
== d
, "Expected cchUsed = %d, got %d\n", d
, np
->cchUsed
);
911 ok_(__FILE__
,line
)(np
->nBaseShift
== e
, "Expected nBaseShift = %d, got %d\n", e
, np
->nBaseShift
);
912 ok_(__FILE__
,line
)(np
->nPwr10
== f
, "Expected nPwr10 = %d, got %d\n", f
, np
->nPwr10
);
916 #define CONVERTN(str,dig,flags) hres = convert_str( str, dig, flags, &np, rgb, lcid )
917 #define CONVERT(str,flags) CONVERTN(str,sizeof(rgb),flags)
918 #define EXPECT(a,b,c,d,e,f) expect_NumFromStr( __LINE__, hres, &np, a, b, c, d, e, f )
919 #define EXPECTRGB(a,b) ok(rgb[a] == b, "Digit[%d], expected %d, got %d\n", a, b, rgb[a])
920 #define EXPECTFAIL ok(hres == (HRESULT)DISP_E_TYPEMISMATCH, "Call succeeded, hres = %08x\n", hres)
921 #define EXPECT2(a,b) EXPECTRGB(0,a); EXPECTRGB(1,b)
923 static void test_VarParseNumFromStr(void)
926 /* Ensure all tests are using the same locale characters for '$', ',' etc */
927 LCID lcid
= MAKELCID(MAKELANGID(LANG_ENGLISH
,SUBLANG_ENGLISH_US
),SORT_DEFAULT
);
933 CHECKPTR(VarParseNumFromStr
);
935 /* Consume a single digit */
940 /* cDig is not literal digits - zeros are suppressed and nPwr10 is increased */
943 /* Note: Win32 writes the trailing zeros if they are within cDig's limits,
944 * but then excludes them from the returned cDig count.
945 * In our implementation we don't bother writing them at all.
949 /* if cDig is too small and numbers follow, sets INEXACT */
951 EXPECT(1,0,NUMPRS_INEXACT
,2,0,1);
954 /* Strips leading zeros */
959 /* Strips leading zeros */
965 /* Fails on non digits */
968 EXPECTRGB(0,FAILDIG
);
970 /** NUMPRS_LEADING_WHITE/NUMPRS_TRAILING_WHITE **/
972 /* Without flag, fails on whitespace */
975 EXPECTRGB(0,FAILDIG
);
978 /* With flag, consumes whitespace */
979 CONVERT(" 0", NUMPRS_LEADING_WHITE
);
980 EXPECT(1,NUMPRS_LEADING_WHITE
,NUMPRS_LEADING_WHITE
,2,0,0);
983 /* Test TAB once, then assume it acts as space for all cases */
984 CONVERT("\t0", NUMPRS_LEADING_WHITE
);
985 EXPECT(1,NUMPRS_LEADING_WHITE
,NUMPRS_LEADING_WHITE
,2,0,0);
989 /* Doesn't pick up trailing whitespace without flag */
994 /* With flag, consumes trailing whitespace */
995 CONVERT("0 ", NUMPRS_TRAILING_WHITE
);
996 EXPECT(1,NUMPRS_TRAILING_WHITE
,NUMPRS_TRAILING_WHITE
,2,0,0);
999 /* Leading flag only consumes leading */
1000 CONVERT(" 0 ", NUMPRS_LEADING_WHITE
);
1001 EXPECT(1,NUMPRS_LEADING_WHITE
,NUMPRS_LEADING_WHITE
,2,0,0);
1004 /* Both flags consumes both */
1005 CONVERT(" 0 ", NUMPRS_LEADING_WHITE
|NUMPRS_TRAILING_WHITE
);
1006 EXPECT(1,NUMPRS_LEADING_WHITE
|NUMPRS_TRAILING_WHITE
,NUMPRS_LEADING_WHITE
|NUMPRS_TRAILING_WHITE
,3,0,0);
1009 /** NUMPRS_LEADING_PLUS/NUMPRS_TRAILING_PLUS **/
1011 /* Without flag, fails on + */
1014 EXPECTRGB(0,FAILDIG
);
1016 /* With flag, consumes + */
1017 CONVERT("+0", NUMPRS_LEADING_PLUS
);
1018 EXPECT(1,NUMPRS_LEADING_PLUS
,NUMPRS_LEADING_PLUS
,2,0,0);
1021 /* Without flag, doesn't consume trailing + */
1023 EXPECT(1,0,0,1,0,0);
1026 /* With flag, consumes trailing + */
1027 CONVERT("0+", NUMPRS_TRAILING_PLUS
);
1028 EXPECT(1,NUMPRS_TRAILING_PLUS
,NUMPRS_TRAILING_PLUS
,2,0,0);
1031 /* With leading flag, doesn't consume trailing + */
1032 CONVERT("+0+", NUMPRS_LEADING_PLUS
);
1033 EXPECT(1,NUMPRS_LEADING_PLUS
,NUMPRS_LEADING_PLUS
,2,0,0);
1036 /* Trailing + doesn't get consumed if we specify both (unlike whitespace) */
1037 CONVERT("+0+", NUMPRS_LEADING_PLUS
|NUMPRS_TRAILING_PLUS
);
1038 EXPECT(1,NUMPRS_LEADING_PLUS
|NUMPRS_TRAILING_PLUS
,NUMPRS_LEADING_PLUS
,2,0,0);
1041 /** NUMPRS_LEADING_MINUS/NUMPRS_TRAILING_MINUS **/
1043 /* Without flag, fails on - */
1046 EXPECTRGB(0,FAILDIG
);
1048 /* With flag, consumes - */
1049 CONVERT("-0", NUMPRS_LEADING_MINUS
);
1050 EXPECT(1,NUMPRS_LEADING_MINUS
,NUMPRS_NEG
|NUMPRS_LEADING_MINUS
,2,0,0);
1053 /* Without flag, doesn't consume trailing - */
1055 EXPECT(1,0,0,1,0,0);
1058 /* With flag, consumes trailing - */
1059 CONVERT("0-", NUMPRS_TRAILING_MINUS
);
1060 EXPECT(1,NUMPRS_TRAILING_MINUS
,NUMPRS_NEG
|NUMPRS_TRAILING_MINUS
,2,0,0);
1063 /* With leading flag, doesn't consume trailing - */
1064 CONVERT("-0-", NUMPRS_LEADING_MINUS
);
1065 EXPECT(1,NUMPRS_LEADING_MINUS
,NUMPRS_NEG
|NUMPRS_LEADING_MINUS
,2,0,0);
1068 /* Trailing - doesn't get consumed if we specify both (unlike whitespace) */
1069 CONVERT("-0-", NUMPRS_LEADING_MINUS
|NUMPRS_TRAILING_MINUS
);
1070 EXPECT(1,NUMPRS_LEADING_MINUS
|NUMPRS_TRAILING_MINUS
,NUMPRS_NEG
|NUMPRS_LEADING_MINUS
,2,0,0);
1073 /** NUMPRS_HEX_OCT **/
1075 /* Could be hex, octal or decimal - With flag reads as decimal */
1076 CONVERT("0", NUMPRS_HEX_OCT
);
1077 EXPECT(1,NUMPRS_HEX_OCT
,0,1,0,0);
1080 /* Doesn't recognise hex in .asm sytax */
1081 CONVERT("0h", NUMPRS_HEX_OCT
);
1082 EXPECT(1,NUMPRS_HEX_OCT
,0,1,0,0);
1085 /* Doesn't fail with valid leading string but no digits */
1086 CONVERT("0x", NUMPRS_HEX_OCT
);
1087 EXPECT(1,NUMPRS_HEX_OCT
,0,1,0,0);
1090 /* Doesn't recognise hex format humbers at all! */
1091 CONVERT("0x0", NUMPRS_HEX_OCT
);
1092 EXPECT(1,NUMPRS_HEX_OCT
,0,1,0,0);
1095 /* Doesn't recognise plain hex digits either */
1096 CONVERT("FE", NUMPRS_HEX_OCT
);
1098 EXPECTRGB(0,FAILDIG
);
1101 CONVERT("0100", NUMPRS_HEX_OCT
);
1102 EXPECT(1,NUMPRS_HEX_OCT
,0,4,0,2);
1106 EXPECTRGB(3,FAILDIG
);
1109 CONVERT("&HF800", NUMPRS_HEX_OCT
);
1110 EXPECT(4,NUMPRS_HEX_OCT
,0x40,6,4,0);
1115 EXPECTRGB(4,FAILDIG
);
1117 /* VB hex lower case and leading zero */
1118 CONVERT("&h0abcdef", NUMPRS_HEX_OCT
);
1119 EXPECT(6,NUMPRS_HEX_OCT
,0x40,9,4,0);
1126 EXPECTRGB(6,FAILDIG
);
1129 CONVERT("&O300", NUMPRS_HEX_OCT
);
1130 EXPECT(3,NUMPRS_HEX_OCT
,0x40,5,3,0);
1134 EXPECTRGB(3,FAILDIG
);
1136 /* VB oct lower case and leading zero */
1137 CONVERT("&o0777", NUMPRS_HEX_OCT
);
1138 EXPECT(3,NUMPRS_HEX_OCT
,0x40,6,3,0);
1142 EXPECTRGB(3,FAILDIG
);
1144 /* VB oct char bigger than 7 */
1145 CONVERT("&o128", NUMPRS_HEX_OCT
);
1147 Native versions 2.x of oleaut32 allow this to succeed: later versions and Wine don't
1149 EXPECTRGB(0,FAILDIG);
1151 /** NUMPRS_PARENS **/
1153 /* Empty parens = error */
1154 CONVERT("()", NUMPRS_PARENS
);
1156 EXPECTRGB(0,FAILDIG
);
1158 /* With flag, trailing parens not consumed */
1159 CONVERT("0()", NUMPRS_PARENS
);
1160 EXPECT(1,NUMPRS_PARENS
,0,1,0,0);
1163 /* With flag, Number in parens made negative and parens consumed */
1164 CONVERT("(0)", NUMPRS_PARENS
);
1165 EXPECT(1,NUMPRS_PARENS
,NUMPRS_NEG
|NUMPRS_PARENS
,3,0,0);
1168 /** NUMPRS_THOUSANDS **/
1170 /* With flag, thousands sep. not needed */
1171 CONVERT("0", NUMPRS_THOUSANDS
);
1172 EXPECT(1,NUMPRS_THOUSANDS
,0,1,0,0);
1175 /* With flag, thousands sep. and following digits consumed */
1176 CONVERT("1,000", NUMPRS_THOUSANDS
);
1177 EXPECT(1,NUMPRS_THOUSANDS
,NUMPRS_THOUSANDS
,5,0,3);
1180 /* With flag and decimal point, thousands sep. but not decimals consumed */
1181 CONVERT("1,000.0", NUMPRS_THOUSANDS
);
1182 EXPECT(1,NUMPRS_THOUSANDS
,NUMPRS_THOUSANDS
,5,0,3);
1185 /** NUMPRS_CURRENCY **/
1187 /* Without flag, chokes on currency sign */
1190 EXPECTRGB(0,FAILDIG
);
1192 /* With flag, consumes currency sign */
1193 CONVERT("$11", NUMPRS_CURRENCY
);
1194 EXPECT(2,NUMPRS_CURRENCY
,NUMPRS_CURRENCY
,3,0,0);
1196 EXPECTRGB(2,FAILDIG
);
1198 /* With flag only, doesn't consume decimal point */
1199 CONVERT("$11.1", NUMPRS_CURRENCY
);
1200 EXPECT(2,NUMPRS_CURRENCY
,NUMPRS_CURRENCY
,3,0,0);
1202 EXPECTRGB(2,FAILDIG
);
1204 /* With flag and decimal flag, consumes decimal point and following digits */
1205 CONVERT("$11.1", NUMPRS_CURRENCY
|NUMPRS_DECIMAL
);
1206 EXPECT(3,NUMPRS_CURRENCY
|NUMPRS_DECIMAL
,NUMPRS_CURRENCY
|NUMPRS_DECIMAL
,5,0,-1);
1209 EXPECTRGB(3,FAILDIG
);
1211 /* Thousands flag can only be used with currency */
1212 CONVERT("$1,234", NUMPRS_CURRENCY
|NUMPRS_THOUSANDS
);
1213 EXPECT(4,NUMPRS_CURRENCY
|NUMPRS_THOUSANDS
,NUMPRS_CURRENCY
|NUMPRS_THOUSANDS
,6,0,0);
1217 EXPECTRGB(4,FAILDIG
);
1219 /** NUMPRS_DECIMAL **/
1221 /* With flag, consumes decimal point */
1222 CONVERT("1.1", NUMPRS_DECIMAL
);
1223 EXPECT(2,NUMPRS_DECIMAL
,NUMPRS_DECIMAL
,3,0,-1);
1225 EXPECTRGB(2,FAILDIG
);
1227 /* With flag, consumes decimal point. Skipping the decimal part is not an error */
1228 CONVERT("1.", NUMPRS_DECIMAL
);
1229 EXPECT(1,NUMPRS_DECIMAL
,NUMPRS_DECIMAL
,2,0,0);
1232 /* Consumes only one decimal point */
1233 CONVERT("1.1.", NUMPRS_DECIMAL
);
1234 EXPECT(2,NUMPRS_DECIMAL
,NUMPRS_DECIMAL
,3,0,-1);
1236 EXPECTRGB(2,FAILDIG
);
1238 /** NUMPRS_EXPONENT **/
1240 /* Without flag, doesn't consume exponent */
1242 EXPECT(1,0,0,1,0,0);
1245 /* With flag, consumes exponent */
1246 CONVERT("1e1", NUMPRS_EXPONENT
);
1247 EXPECT(1,NUMPRS_EXPONENT
,NUMPRS_EXPONENT
,3,0,1);
1250 /* Negative exponents are accepted without flags */
1251 CONVERT("1e-1", NUMPRS_EXPONENT
);
1252 EXPECT(1,NUMPRS_EXPONENT
,NUMPRS_EXPONENT
,4,0,-1);
1255 /* As are positive exponents and leading exponent 0's */
1256 CONVERT("1e+01", NUMPRS_EXPONENT
);
1257 EXPECT(1,NUMPRS_EXPONENT
,NUMPRS_EXPONENT
,5,0,1);
1260 /* The same for zero exponents */
1261 CONVERT("1e0", NUMPRS_EXPONENT
);
1262 EXPECT(1,NUMPRS_EXPONENT
,NUMPRS_EXPONENT
,3,0,0);
1265 /* Sign on a zero exponent doesn't matter */
1266 CONVERT("1e+0", NUMPRS_EXPONENT
);
1267 EXPECT(1,NUMPRS_EXPONENT
,NUMPRS_EXPONENT
,4,0,0);
1270 CONVERT("1e-0", NUMPRS_EXPONENT
);
1271 EXPECT(1,NUMPRS_EXPONENT
,NUMPRS_EXPONENT
,4,0,0);
1274 /* Doesn't consume a real number exponent */
1275 CONVERT("1e1.", NUMPRS_EXPONENT
);
1276 EXPECT(1,NUMPRS_EXPONENT
,NUMPRS_EXPONENT
,3,0,1);
1279 /* Powers of 10 are calculated from the position of any decimal point */
1280 CONVERT("1.5e20", NUMPRS_EXPONENT
|NUMPRS_DECIMAL
);
1281 EXPECT(2,NUMPRS_EXPONENT
|NUMPRS_DECIMAL
,NUMPRS_EXPONENT
|NUMPRS_DECIMAL
,6,0,19);
1284 CONVERT("1.5e-20", NUMPRS_EXPONENT
|NUMPRS_DECIMAL
);
1285 EXPECT(2,NUMPRS_EXPONENT
|NUMPRS_DECIMAL
,NUMPRS_EXPONENT
|NUMPRS_DECIMAL
,7,0,-21);
1288 /** NUMPRS_USE_ALL **/
1290 /* Flag expects all digits */
1291 CONVERT("0", NUMPRS_USE_ALL
);
1292 EXPECT(1,NUMPRS_USE_ALL
,0,1,0,0);
1295 /* Rejects anything trailing */
1296 CONVERT("0 ", NUMPRS_USE_ALL
);
1300 /* Unless consumed by trailing flag */
1301 CONVERT("0 ", NUMPRS_USE_ALL
|NUMPRS_TRAILING_WHITE
);
1302 EXPECT(1,NUMPRS_USE_ALL
|NUMPRS_TRAILING_WHITE
,NUMPRS_TRAILING_WHITE
,2,0,0);
1305 /** Combinations **/
1307 /* Leading whitepace and plus, doesn't consume trailing whitespace */
1308 CONVERT("+ 0 ", NUMPRS_LEADING_PLUS
|NUMPRS_LEADING_WHITE
);
1309 EXPECT(1,NUMPRS_LEADING_PLUS
|NUMPRS_LEADING_WHITE
,NUMPRS_LEADING_PLUS
|NUMPRS_LEADING_WHITE
,3,0,0);
1312 /* Order of whitepace and plus is unimportant */
1313 CONVERT(" +0", NUMPRS_LEADING_PLUS
|NUMPRS_LEADING_WHITE
);
1314 EXPECT(1,NUMPRS_LEADING_PLUS
|NUMPRS_LEADING_WHITE
,NUMPRS_LEADING_PLUS
|NUMPRS_LEADING_WHITE
,3,0,0);
1317 /* Leading whitespace can be repeated */
1318 CONVERT(" + 0", NUMPRS_LEADING_PLUS
|NUMPRS_LEADING_WHITE
);
1319 EXPECT(1,NUMPRS_LEADING_PLUS
|NUMPRS_LEADING_WHITE
,NUMPRS_LEADING_PLUS
|NUMPRS_LEADING_WHITE
,4,0,0);
1322 /* But plus/minus etc. cannot */
1323 CONVERT("+ +0", NUMPRS_LEADING_PLUS
|NUMPRS_LEADING_WHITE
);
1325 EXPECTRGB(0,FAILDIG
);
1327 /* Inexact is not set if trailing zeros are removed */
1328 CONVERTN("10", 1, 0);
1329 EXPECT(1,0,0,2,0,1);
1332 /* Make sure a leading 0 is stripped but decimals after it get read */
1333 CONVERT("-0.51", NUMPRS_STD
);
1334 EXPECT(2,NUMPRS_STD
,NUMPRS_NEG
|NUMPRS_DECIMAL
|NUMPRS_LEADING_MINUS
,5,0,-2);
1337 /* Keep trailing zeros on whole number part of a decimal */
1338 CONVERT("10.1", NUMPRS_STD
);
1339 EXPECT(3,NUMPRS_STD
,NUMPRS_DECIMAL
,4,0,-1);
1343 /* Zeros after decimal sign */
1344 CONVERT("0.01", NUMPRS_STD
);
1345 EXPECT(1,NUMPRS_STD
,NUMPRS_DECIMAL
,4,0,-2);
1348 /* Trailing zeros after decimal part */
1349 CONVERT("0.10", NUMPRS_STD
);
1350 EXPECT(1,NUMPRS_STD
,NUMPRS_DECIMAL
,4,0,-1);
1354 static HRESULT (WINAPI
*pVarNumFromParseNum
)(NUMPARSE
*,BYTE
*,ULONG
,VARIANT
*);
1356 /* Macros for converting and testing the result of VarNumFromParseNum */
1357 #define SETRGB(indx,val) if (!indx) memset(rgb, FAILDIG, sizeof(rgb)); rgb[indx] = val
1359 #define CONVERT(a,b,c,d,e,f,bits) \
1360 np.cDig = (a); np.dwInFlags = (b); np.dwOutFlags = (c); np.cchUsed = (d); \
1361 np.nBaseShift = (e); np.nPwr10 = (f); hres = pVarNumFromParseNum(&np, rgb, bits, &vOut)
1362 static const char *szFailOverflow
= "Expected overflow, hres = %08x\n";
1363 #define EXPECT_OVERFLOW ok(hres == (HRESULT)DISP_E_OVERFLOW, szFailOverflow, hres)
1364 static const char *szFailOk
= "Call failed, hres = %08x\n";
1365 #define EXPECT_OK ok(hres == (HRESULT)S_OK, szFailOk, hres); \
1366 if (hres == (HRESULT)S_OK)
1367 #define EXPECT_TYPE(typ) ok(V_VT(&vOut) == typ,"Expected Type = " #typ ", got %d\n", V_VT(&vOut))
1368 #define EXPECT_I1(val) EXPECT_OK { EXPECT_TYPE(VT_I1); \
1369 ok(V_I1(&vOut) == val, "Expected i1 = %d, got %d\n", (signed char)val, V_I1(&vOut)); }
1370 #define EXPECT_UI1(val) EXPECT_OK { EXPECT_TYPE(VT_UI1); \
1371 ok(V_UI1(&vOut) == val, "Expected ui1 = %d, got %d\n", (BYTE)val, V_UI1(&vOut)); }
1372 #define EXPECT_I2(val) EXPECT_OK { EXPECT_TYPE(VT_I2); \
1373 ok(V_I2(&vOut) == val, "Expected i2 = %d, got %d\n", (SHORT)val, V_I2(&vOut)); }
1374 #define EXPECT_UI2(val) EXPECT_OK { EXPECT_TYPE(VT_UI2); \
1375 ok(V_UI2(&vOut) == val, "Expected ui2 = %d, got %d\n", (USHORT)val, V_UI2(&vOut)); }
1376 #define EXPECT_I4(val) EXPECT_OK { EXPECT_TYPE(VT_I4); \
1377 ok(V_I4(&vOut) == val, "Expected i4 = %d, got %d\n", (LONG)val, V_I4(&vOut)); }
1378 #define EXPECT_UI4(val) EXPECT_OK { EXPECT_TYPE(VT_UI4); \
1379 ok(V_UI4(&vOut) == val, "Expected ui4 = %d, got %d\n", (ULONG)val, V_UI4(&vOut)); }
1380 #define EXPECT_I8(high,low) EXPECT_OK { EXPECT_TYPE(VT_I8); \
1381 ok(V_I8(&vOut) == ((((LONG64)(high))<<32)|(low)), "Expected i8 = %x%08x, got %x%08x\n", \
1382 (LONG)(high), (LONG)(low), (LONG)(V_I8(&vOut)>>32), (LONG)V_I8(&vOut) ); }
1383 #define EXPECT_UI8(val) EXPECT_OK { EXPECT_TYPE(VT_UI8); \
1384 ok(V_UI8(&vOut) == val, "Expected ui8 = 0x%x%08x, got 0x%x%08x\n", \
1385 (DWORD)((ULONG64)val >> 32), (DWORD)(ULONG64)val, (DWORD)(V_UI8(&vOut) >> 32), (DWORD)V_UI8(&vOut)); }
1386 #define EXPECT_R4(val) EXPECT_OK { EXPECT_TYPE(VT_R4); \
1387 ok(V_R4(&vOut) == val, "Expected r4 = %f, got %f\n", val, V_R4(&vOut)); }
1388 #define EXPECT_R8(val) EXPECT_OK { EXPECT_TYPE(VT_R8); \
1389 ok(V_R8(&vOut) == val, "Expected r8 = %g, got %g\n", val, V_R8(&vOut)); }
1390 #define CY_MULTIPLIER 10000
1391 #define EXPECT_CY(val) EXPECT_OK { EXPECT_TYPE(VT_CY); \
1392 ok(V_CY(&vOut).int64 == (LONG64)(val * CY_MULTIPLIER), "Expected r8 = 0x%x%08x, got 0x%x%08x\n", \
1393 (DWORD)((LONG64)val >> 23), (DWORD)(LONG64)val, (DWORD)(V_CY(&vOut).int64 >>32), (DWORD)V_CY(&vOut).int64); }
1394 #define EXPECT_DECIMAL(valHi, valMid, valLo) EXPECT_OK { EXPECT_TYPE(VT_DECIMAL); \
1395 ok((V_DECIMAL(&vOut).Hi32 == valHi) && (S1(U1(V_DECIMAL(&vOut))).Mid32 == valMid) && \
1396 (S1(U1(V_DECIMAL(&vOut))).Lo32 == valLo), \
1397 "Expected decimal = %x/0x%x%08x, got %x/0x%x%08x\n", valHi, valMid, valLo, \
1398 V_DECIMAL(&vOut).Hi32, S1(U1(V_DECIMAL(&vOut))).Mid32, S1(U1(V_DECIMAL(&vOut))).Lo32); }
1400 static void test_VarNumFromParseNum(void)
1407 CHECKPTR(VarNumFromParseNum
);
1409 /* Convert the number 1 to different types */
1410 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_I1
); EXPECT_I1(1);
1411 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_UI1
); EXPECT_UI1(1);
1412 /* Prefers a signed type to unsigned of the same size */
1413 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_I1
|VTBIT_UI1
); EXPECT_I1(1);
1414 /* But takes the smaller size if possible */
1415 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_I2
|VTBIT_UI1
); EXPECT_UI1(1);
1417 /* Try different integer sizes */
1418 #define INTEGER_VTBITS (VTBIT_I1|VTBIT_UI1|VTBIT_I2|VTBIT_UI2|VTBIT_I4|VTBIT_UI4|VTBIT_I8|VTBIT_UI8)
1420 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, INTEGER_VTBITS
); EXPECT_I1(1);
1422 SETRGB(0, 1); SETRGB(1, 2); SETRGB(2, 7);
1423 CONVERT(3,0,0,3,0,0, INTEGER_VTBITS
); EXPECT_I1(127);
1425 SETRGB(0, 1); SETRGB(1, 2); SETRGB(2, 8);
1426 CONVERT(3,0,0,3,0,0, INTEGER_VTBITS
); EXPECT_UI1(128);
1428 SETRGB(0, 2); SETRGB(1, 5); SETRGB(2, 5);
1429 CONVERT(3,0,0,3,0,0, INTEGER_VTBITS
); EXPECT_UI1(255);
1431 SETRGB(0, 2); SETRGB(1, 5); SETRGB(2, 6);
1432 CONVERT(3,0,0,3,0,0, INTEGER_VTBITS
); EXPECT_I2(256);
1434 SETRGB(0, 3); SETRGB(1, 2); SETRGB(2, 7); SETRGB(3, 6); SETRGB(4, 7);
1435 CONVERT(5,0,0,5,0,0, INTEGER_VTBITS
); EXPECT_I2(32767);
1437 SETRGB(0, 3); SETRGB(1, 2); SETRGB(2, 7); SETRGB(3, 6); SETRGB(4, 8);
1438 CONVERT(5,0,0,5,0,0, INTEGER_VTBITS
); EXPECT_UI2(32768);
1440 /* Assume the above pattern holds for remaining positive integers; test negative */
1443 SETRGB(0, 1); SETRGB(1, 2); SETRGB(2, 8);
1444 CONVERT(3,0,NUMPRS_NEG
,3,0,0, INTEGER_VTBITS
); EXPECT_I1(-128);
1446 SETRGB(0, 1); SETRGB(1, 2); SETRGB(2, 9);
1447 CONVERT(3,0,NUMPRS_NEG
,3,0,0, INTEGER_VTBITS
); EXPECT_I2(-129);
1449 SETRGB(0, 3); SETRGB(1, 2); SETRGB(2, 7); SETRGB(3, 6); SETRGB(4, 8);
1450 CONVERT(5,0,NUMPRS_NEG
,5,0,0, INTEGER_VTBITS
); EXPECT_I2(-32768);
1452 SETRGB(0, 3); SETRGB(1, 2); SETRGB(2, 7); SETRGB(3, 6); SETRGB(4, 9);
1453 CONVERT(5,0,NUMPRS_NEG
,5,0,0, INTEGER_VTBITS
); EXPECT_I4(-32769);
1455 /* Assume the above pattern holds for remaining negative integers */
1457 /* Test hexadecimal conversions */
1458 SETRGB(0, 1); CONVERT(1,0,0,1,4,0, INTEGER_VTBITS
); EXPECT_I1(0x01);
1460 SETRGB(0, 7); SETRGB(1, 0xf);
1461 CONVERT(2,0,0,2,4,0, INTEGER_VTBITS
); EXPECT_I1(0x7f);
1462 SETRGB(0, 7); SETRGB(1, 0xf);
1463 CONVERT(2,0,0,2,4,0, VTBIT_DECIMAL
); EXPECT_DECIMAL(0,0,0x7f);
1465 SETRGB(0, 7); SETRGB(1, 0xf); SETRGB(2, 0xf); SETRGB(3, 0xf);
1466 CONVERT(4,0,0,4,4,0, INTEGER_VTBITS
); EXPECT_I2(0x7fff);
1468 SETRGB(0, 7); SETRGB(1, 0xf); SETRGB(2, 0xf); SETRGB(3, 0xf);
1469 SETRGB(4, 0xf); SETRGB(5, 0xf); SETRGB(6, 0xf); SETRGB(7, 0xf);
1470 CONVERT(8,0,0,8,4,0, INTEGER_VTBITS
); EXPECT_I4(0x7fffffffL
);
1471 /* 0x7fffffffffffffff (64 bits) */
1472 SETRGB(0, 7); SETRGB(1, 0xf); SETRGB(2, 0xf); SETRGB(3, 0xf);
1473 SETRGB(4, 0xf); SETRGB(5, 0xf); SETRGB(6, 0xf); SETRGB(7, 0xf);
1474 SETRGB(8, 0xf); SETRGB(9, 0xf); SETRGB(10, 0xf); SETRGB(11, 0xf);
1475 SETRGB(12, 0xf); SETRGB(13, 0xf); SETRGB(14, 0xf); SETRGB(15, 0xf);
1476 if (HAVE_OLEAUT32_I8
)
1478 /* We cannot use INTEGER_VTBITS as WinXP and Win2003 are broken(?). They
1479 truncate the number to the smallest integer size requested:
1480 CONVERT(16,0,0,16,4,0, INTEGER_VTBITS); EXPECT_I1((signed char)0xff); */
1481 CONVERT(16,0,0,16,4,0, VTBIT_I8
); EXPECT_I8(0x7fffffff,0xffffffff);
1484 /* Assume the above pattern holds for numbers without hi-bit set, test (preservation of) hi-bit */
1486 SETRGB(0, 8); SETRGB(1, 2);
1487 CONVERT(2,0,0,2,4,0, INTEGER_VTBITS
);
1488 EXPECT_I1((signed char)0x82);
1490 SETRGB(0, 8); SETRGB(1, 0); SETRGB(2, 0); SETRGB(3, 2);
1491 CONVERT(4,0,0,4,4,0, INTEGER_VTBITS
);
1492 EXPECT_I2((signed short)0x8002);
1494 SETRGB(0, 8); SETRGB(1, 0); SETRGB(2, 0); SETRGB(3, 0);
1495 SETRGB(4, 0); SETRGB(5, 0); SETRGB(6, 0); SETRGB(7, 2);
1496 CONVERT(8,0,0,8,4,0, INTEGER_VTBITS
); EXPECT_I4(0x80000002);
1497 /* 0x8000000000000002 (64 bits) */
1498 SETRGB(0, 8); SETRGB(1, 0); SETRGB(2, 0); SETRGB(3, 0);
1499 SETRGB(4, 0); SETRGB(5, 0); SETRGB(6, 0); SETRGB(7, 0);
1500 SETRGB(8, 0); SETRGB(9, 0); SETRGB(10, 0); SETRGB(11, 0);
1501 SETRGB(12, 0); SETRGB(13, 0); SETRGB(14, 0); SETRGB(15, 2);
1502 if (HAVE_OLEAUT32_I8
)
1504 /* We cannot use INTEGER_VTBITS as WinXP and Win2003 are broken(?). They
1505 truncate the number to the smallest integer size requested:
1506 CONVERT(16,0,0,16,4,0, INTEGER_VTBITS & ~VTBIT_I1);
1507 EXPECT_I2((signed short)0x0002); */
1508 CONVERT(16,0,0,16,4,0, VTBIT_I8
); EXPECT_I8(0x80000000,0x00000002);
1511 /* Test (preservation of) hi-bit with STRICT type requesting */
1513 SETRGB(0, 8); SETRGB(1, 2);
1514 CONVERT(2,0,0,2,4,0, VTBIT_I1
);
1515 EXPECT_I1((signed char)0x82);
1517 SETRGB(0, 8); SETRGB(1, 0); SETRGB(2, 0); SETRGB(3, 2);
1518 CONVERT(4,0,0,4,4,0, VTBIT_I2
);
1519 EXPECT_I2((signed short)0x8002);
1521 SETRGB(0, 8); SETRGB(1, 0); SETRGB(2, 0); SETRGB(3, 0);
1522 SETRGB(4, 0); SETRGB(5, 0); SETRGB(6, 0); SETRGB(7, 2);
1523 CONVERT(8,0,0,8,4,0, VTBIT_I4
); EXPECT_I4(0x80000002);
1524 /* 0x8000000000000002 (64 bits) */
1525 SETRGB(0, 8); SETRGB(1, 0); SETRGB(2, 0); SETRGB(3, 0);
1526 SETRGB(4, 0); SETRGB(5, 0); SETRGB(6, 0); SETRGB(7, 0);
1527 SETRGB(8, 0); SETRGB(9, 0); SETRGB(10, 0); SETRGB(11, 0);
1528 SETRGB(12, 0); SETRGB(13, 0); SETRGB(14, 0); SETRGB(15, 2);
1529 if (HAVE_OLEAUT32_I8
)
1531 CONVERT(16,0,0,16,4,0, VTBIT_I8
); EXPECT_I8(0x80000000,0x00000002);
1533 /* Assume the above pattern holds for numbers with hi-bit set */
1535 /* Negative numbers overflow if we have only unsigned outputs */
1537 SETRGB(0, 1); CONVERT(1,0,NUMPRS_NEG
,1,0,0, VTBIT_UI1
); EXPECT_OVERFLOW
;
1539 SETRGB(0, 6); CONVERT(1,0,NUMPRS_NEG
,1,0,~0u, VTBIT_UI1
); EXPECT_OVERFLOW
;
1541 /* Except that rounding is done first, so -0.5 to 0 are accepted as 0 */
1543 SETRGB(0, 5); CONVERT(1,0,NUMPRS_NEG
,1,0,~0u, VTBIT_UI1
); EXPECT_UI1(0);
1545 /* Floating point zero is OK */
1547 SETRGB(0, 0); CONVERT(1,0,NUMPRS_DECIMAL
|NUMPRS_EXPONENT
,12,0,-8, VTBIT_R8
);
1550 /* Float is acceptable for an integer input value */
1551 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_R4
); EXPECT_R4(1.0f
);
1553 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_R8
); EXPECT_R8(1.0);
1554 /* As is currency */
1555 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_CY
); EXPECT_CY(1);
1557 /* Float is preferred over double */
1558 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_R4
|VTBIT_R8
); EXPECT_R4(1.0f
);
1560 /* Double is preferred over currency */
1561 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_R8
|VTBIT_CY
); EXPECT_R8(1.0);
1563 /* Currency is preferred over decimal */
1564 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_CY
|VTBIT_DECIMAL
); EXPECT_CY(1);
1568 static void test_UdateFromDate( int line
, DATE dt
, ULONG flags
, HRESULT r
, WORD d
, WORD m
, WORD y
,
1569 WORD h
, WORD mn
, WORD s
, WORD ms
, WORD dw
, WORD dy
)
1574 memset(&ud
, 0, sizeof(ud
));
1575 res
= pVarUdateFromDate(dt
, flags
, &ud
);
1576 ok_(__FILE__
,line
)(r
== res
, "Wrong result %x/%x\n", r
, res
);
1578 ok_(__FILE__
,line
)(ud
.st
.wYear
== y
&& ud
.st
.wMonth
== m
&& ud
.st
.wDay
== d
&&
1579 ud
.st
.wHour
== h
&& ud
.st
.wMinute
== mn
&& ud
.st
.wSecond
== s
&&
1580 ud
.st
.wMilliseconds
== ms
&& ud
.st
.wDayOfWeek
== dw
&& ud
.wDayOfYear
== dy
,
1581 "%.16g expected %d,%d,%d,%d,%d,%d,%d %d %d, got %d,%d,%d,%d,%d,%d,%d %d %d\n",
1582 dt
, d
, m
, y
, h
, mn
, s
, ms
, dw
, dy
,
1583 ud
.st
.wDay
, ud
.st
.wMonth
, ud
.st
.wYear
, ud
.st
.wHour
, ud
.st
.wMinute
,
1584 ud
.st
.wSecond
, ud
.st
.wMilliseconds
, ud
.st
.wDayOfWeek
, ud
.wDayOfYear
);
1586 #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)
1588 static void test_VarUdateFromDate(void)
1590 CHECKPTR(VarUdateFromDate
);
1591 DT2UD(29221.0,0,S_OK
,1,1,1980,0,0,0,0,2,1); /* 1 Jan 1980 */
1592 DT2UD(29222.0,0,S_OK
,2,1,1980,0,0,0,0,3,2); /* 2 Jan 1980 */
1593 DT2UD(33238.0,0,S_OK
,31,12,1990,0,0,0,0,1,365); /* 31 Dec 1990 */
1594 DT2UD(0.0,0,S_OK
,30,12,1899,0,0,0,0,6,364); /* 30 Dec 1899 - VT_DATE 0.0 */
1595 DT2UD(-657434.0,0,S_OK
,1,1,100,0,0,0,0,5,1); /* 1 Jan 100 - Min */
1596 DT2UD(-657435.0,0,E_INVALIDARG
,0,0,0,0,0,0,0,0,0); /* < 1 Jan 100 => err */
1597 DT2UD(2958465.0,0,S_OK
,31,12,9999,0,0,0,0,5,365); /* 31 Dec 9999 - Max */
1598 DT2UD(2958466.0,0,E_INVALIDARG
,0,0,0,0,0,0,0,0,0); /* > 31 Dec 9999 => err */
1600 /* VAR_VALIDDATE doesn't prevent upper and lower bounds being checked */
1601 DT2UD(-657435.0,VAR_VALIDDATE
,E_INVALIDARG
,0,0,0,0,0,0,0,0,0);
1602 DT2UD(2958466.0,VAR_VALIDDATE
,E_INVALIDARG
,0,0,0,0,0,0,0,0,0);
1605 DT2UD(29221.25,0,S_OK
,1,1,1980,6,0,0,0,2,1); /* 6 AM */
1606 DT2UD(29221.33333333,0,S_OK
,1,1,1980,8,0,0,0,2,1); /* 8 AM */
1607 DT2UD(29221.5,0,S_OK
,1,1,1980,12,0,0,0,2,1); /* 12 AM */
1608 DT2UD(29221.9888884444,0,S_OK
,1,1,1980,23,44,0,0,2,1); /* 11:44 PM */
1609 DT2UD(29221.7508765432,0,S_OK
,1,1,1980,18,1,16,0,2,1); /* 6:18:02 PM */
1613 static void test_DateFromUDate( int line
, WORD d
, WORD m
, WORD y
, WORD h
, WORD mn
, WORD s
, WORD ms
,
1614 WORD dw
, WORD dy
, ULONG flags
, HRESULT r
, DATE dt
)
1624 ud
.st
.wMinute
= (mn
);
1625 ud
.st
.wSecond
= (s
);
1626 ud
.st
.wMilliseconds
= (ms
);
1627 ud
.st
.wDayOfWeek
= (dw
);
1628 ud
.wDayOfYear
= (dy
);
1629 res
= pVarDateFromUdate(&ud
, flags
, &out
);
1630 ok_(__FILE__
,line
)((r
) == res
&& (FAILED(r
) || fabs(out
-(dt
)) < 1.0e-11),
1631 "expected %x, %.16g, got %x, %.16g\n", r
, dt
, res
, out
);
1633 #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)
1635 static void test_VarDateFromUdate(void)
1637 CHECKPTR(VarDateFromUdate
);
1638 UD2T(1,1,1980,0,0,0,0,2,1,0,S_OK
,29221.0); /* 1 Jan 1980 */
1639 UD2T(2,1,1980,0,0,0,0,3,2,0,S_OK
,29222.0); /* 2 Jan 1980 */
1640 UD2T(31,12,1990,0,0,0,0,0,0,0,S_OK
,33238.0); /* 31 Dec 1990 */
1641 UD2T(31,12,90,0,0,0,0,0,0,0,S_OK
,33238.0); /* year < 100 is 1900+year! */
1642 UD2T(30,12,1899,0,0,0,0,6,364,0,S_OK
,0.0); /* 30 Dec 1899 - VT_DATE 0.0 */
1643 UD2T(1,1,100,0,0,0,0,0,0,0,S_OK
,-657434.0); /* 1 Jan 100 - Min */
1644 UD2T(31,12,9999,0,0,0,0,0,0,0,S_OK
,2958465.0); /* 31 Dec 9999 - Max */
1645 UD2T(1,1,10000,0,0,0,0,0,0,0,E_INVALIDARG
,0.0); /* > 31 Dec 9999 => err */
1647 UD2T(1,1,1980,18,1,16,0,2,1,0,S_OK
,29221.75087962963); /* 6:18:02 PM */
1649 UD2T(0,1,1980,0,0,0,0,2,1,0,S_OK
,29220.0); /* Rolls back to 31 Dec 1899 */
1650 UD2T(1,13,1980,0,0,0,0,2,1,0,S_OK
,29587.0); /* Rolls fwd to 1/1/1981 */
1653 #define ST2DT(d,m,y,h,mn,s,ms,r,dt) \
1654 st.wYear = y; st.wMonth = m; st.wDay = d; st.wHour = h; st.wMinute = mn; \
1655 st.wSecond = s; st.wMilliseconds = ms; st.wDayOfWeek = 0; \
1656 res = pSystemTimeToVariantTime(&st, &out); \
1657 ok(r == res && (!r || fabs(out-dt) < 1.0e-11), \
1658 "expected %d, %.16g, got %d, %.16g\n", r, dt, res, out)
1660 static void test_SystemTimeToVariantTime(void)
1666 CHECKPTR(SystemTimeToVariantTime
);
1667 ST2DT(1,1,1980,0,0,0,0,TRUE
,29221.0);
1668 ST2DT(2,1,1980,0,0,0,0,TRUE
,29222.0);
1669 ST2DT(0,1,1980,0,0,0,0,TRUE
,29220.0); /* Rolls back to 31 Dec 1899 */
1670 ST2DT(1,13,1980,0,0,0,0,FALSE
,29587.0); /* Fails on invalid month */
1671 ST2DT(31,12,90,0,0,0,0,TRUE
,33238.0); /* year < 100 is 1900+year! */
1674 #define DT2ST(dt,r,d,m,y,h,mn,s,ms) \
1675 memset(&st, 0, sizeof(st)); \
1676 res = pVariantTimeToSystemTime(dt, &st); \
1677 ok(r == res && (!r || (st.wYear == y && st.wMonth == m && st.wDay == d && \
1678 st.wHour == h && st.wMinute == mn && st.wSecond == s && \
1679 st.wMilliseconds == ms)), \
1680 "%.16g expected %d, %d,%d,%d,%d,%d,%d,%d, got %d, %d,%d,%d,%d,%d,%d,%d\n", \
1681 dt, r, d, m, y, h, mn, s, ms, res, st.wDay, st.wMonth, st.wYear, \
1682 st.wHour, st.wMinute, st.wSecond, st.wMilliseconds)
1684 static void test_VariantTimeToSystemTime(void)
1689 CHECKPTR(VariantTimeToSystemTime
);
1690 DT2ST(29221.0,1,1,1,1980,0,0,0,0);
1691 DT2ST(29222.0,1,2,1,1980,0,0,0,0);
1694 #define MKDOSDATE(d,m,y) ((d & 0x1f) | ((m & 0xf) << 5) | (((y-1980) & 0x7f) << 9))
1695 #define MKDOSTIME(h,m,s) (((s>>1) & 0x1f) | ((m & 0x3f) << 5) | ((h & 0x1f) << 11))
1697 static const char *szDosDateToVarTimeFail
= "expected %d, %.16g, got %d, %.16g\n";
1698 #define DOS2DT(d,m,y,h,mn,s,r,dt) out = 0.0; \
1699 dosDate = MKDOSDATE(d,m,y); \
1700 dosTime = MKDOSTIME(h,mn,s); \
1701 res = pDosDateTimeToVariantTime(dosDate, dosTime, &out); \
1702 ok(r == res && (!r || fabs(out-dt) < 1.0e-11), \
1703 szDosDateToVarTimeFail, r, dt, res, out)
1705 static void test_DosDateTimeToVariantTime(void)
1707 USHORT dosDate
, dosTime
;
1711 CHECKPTR(DosDateTimeToVariantTime
);
1714 DOS2DT(1,1,1980,0,0,0,1,29221.0); /* 1/1/1980 */
1715 DOS2DT(31,12,2099,0,0,0,1,73050.0); /* 31/12/2099 */
1716 /* Dates are limited to the dos date max of 31/12/2099 */
1717 DOS2DT(31,12,2100,0,0,0,0,0.0); /* 31/12/2100 */
1718 /* Days and months of 0 cause date to roll back 1 day or month */
1719 DOS2DT(0,1,1980,0,0,0,1,29220.0); /* 0 Day => 31/12/1979 */
1720 DOS2DT(1,0,1980,0,0,0,1,29190.0); /* 0 Mth => 1/12/1979 */
1721 DOS2DT(0,0,1980,0,0,0,1,29189.0); /* 0 D/M => 30/11/1979 */
1722 /* Days > days in the month cause date to roll forward 1 month */
1723 DOS2DT(29,2,1981,0,0,0,1,29646.0); /* 29/2/1981 -> 3/1/1980 */
1724 DOS2DT(30,2,1981,0,0,0,1,29647.0); /* 30/2/1981 -> 4/1/1980 */
1725 /* Takes leap years into account when rolling forward */
1726 DOS2DT(29,2,1980,0,0,0,1,29280.0); /* 2/29/1980 */
1727 /* Months > 12 cause an error */
1728 DOS2DT(2,13,1980,0,0,0,0,0.0);
1731 DOS2DT(1,1,1980,0,0,29,1,29221.00032407407); /* 1/1/1980 12:00:28 AM */
1732 DOS2DT(1,1,1980,0,0,31,1,29221.00034722222); /* 1/1/1980 12:00:30 AM */
1733 DOS2DT(1,1,1980,0,59,0,1,29221.04097222222); /* 1/1/1980 12:59:00 AM */
1734 DOS2DT(1,1,1980,0,60,0,0,0.0); /* Invalid seconds */
1735 DOS2DT(1,1,1980,23,0,0,1,29221.95833333333); /* 1/1/1980 11:00:00 PM */
1736 DOS2DT(1,1,1980,24,0,0,0,0.0); /* Invalid hours */
1739 #define DT2DOS(dt,r,d,m,y,h,mn,s) dosTime = dosDate = 0; \
1740 expDosDate = MKDOSDATE(d,m,y); \
1741 expDosTime = MKDOSTIME(h,mn,s); \
1742 res = pVariantTimeToDosDateTime(dt, &dosDate, &dosTime); \
1743 ok(r == res && (!r || (dosTime == expDosTime && dosDate == expDosDate)), \
1744 "%g: expected %d,%d(%d/%d/%d),%d(%d:%d:%d) got %d,%d(%d/%d/%d),%d(%d:%d:%d)\n", \
1745 dt, r, expDosDate, expDosDate & 0x1f, (expDosDate >> 5) & 0xf, 1980 + (expDosDate >> 9), \
1746 expDosTime, expDosTime >> 11, (expDosTime >> 5) & 0x3f, (expDosTime & 0x1f), \
1747 res, dosDate, dosDate & 0x1f, (dosDate >> 5) & 0xf, 1980 + (dosDate >> 9), \
1748 dosTime, dosTime >> 11, (dosTime >> 5) & 0x3f, (dosTime & 0x1f))
1750 static void test_VariantTimeToDosDateTime(void)
1752 USHORT dosDate
, dosTime
, expDosDate
, expDosTime
;
1755 CHECKPTR(VariantTimeToDosDateTime
);
1758 DT2DOS(29221.0,1,1,1,1980,0,0,0); /* 1/1/1980 */
1759 DT2DOS(73050.0,1,31,12,2099,0,0,0); /* 31/12/2099 */
1760 DT2DOS(29220.0,0,0,0,0,0,0,0); /* 31/12/1979 - out of range */
1761 DT2DOS(73415.0,0,0,0,0,0,0,0); /* 31/12/2100 - out of range */
1764 DT2DOS(29221.00032407407,1,1,1,1980,0,0,29); /* 1/1/1980 12:00:28 AM */
1765 DT2DOS(29221.00034722222,1,1,1,1980,0,0,31); /* 1/1/1980 12:00:30 AM */
1766 DT2DOS(29221.04097222222,1,1,1,1980,0,59,0); /* 1/1/1980 12:59:00 AM */
1767 DT2DOS(29221.95833333333,1,1,1,1980,23,0,0); /* 1/1/1980 11:00:00 PM */
1770 static HRESULT (WINAPI
*pVarAbs
)(LPVARIANT
,LPVARIANT
);
1772 #define VARABS(vt,val,rvt,rval) \
1773 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
1774 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
1775 test_var_call1( __LINE__, pVarAbs, &v, &exp );
1777 static void test_VarAbs(void)
1779 static const WCHAR szNum
[] = {'-','1','.','1','\0' };
1782 VARIANT v
, vDst
, exp
;
1787 /* Test all possible V_VT values.
1789 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
1793 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
1795 HRESULT hExpected
= DISP_E_BADVARTYPE
;
1799 memset(&v
, 0, sizeof(v
));
1800 V_VT(&v
) = vt
| ExtraFlags
[i
];
1801 V_VT(&vDst
) = VT_EMPTY
;
1803 hres
= pVarAbs(&v
,&vDst
);
1804 if (ExtraFlags
[i
] & (VT_ARRAY
|VT_ARRAY
) ||
1805 (!ExtraFlags
[i
] && (vt
== VT_UNKNOWN
|| vt
== VT_BSTR
||
1806 vt
== VT_DISPATCH
|| vt
== VT_ERROR
|| vt
== VT_RECORD
)))
1808 hExpected
= DISP_E_TYPEMISMATCH
;
1810 else if (ExtraFlags
[i
] || vt
>= VT_CLSID
|| vt
== VT_VARIANT
)
1812 hExpected
= DISP_E_BADVARTYPE
;
1814 else if (IsValidVariantClearVT(vt
, ExtraFlags
[i
]))
1817 /* Native always fails on some vartypes that should be valid. don't
1818 * check that Wine does the same; these are bugs in native.
1820 if (vt
== VT_I8
|| vt
== VT_UI8
|| vt
== VT_INT
|| vt
== VT_UINT
||
1821 vt
== VT_I1
|| vt
== VT_UI2
|| vt
== VT_UI4
)
1823 ok(hres
== hExpected
, "VarAbs: expected 0x%X, got 0x%X for vt %d | 0x%X\n",
1824 hExpected
, hres
, vt
, ExtraFlags
[i
]);
1828 /* BOOL->I2, BSTR->R8, all others remain the same */
1829 VARABS(BOOL
,VARIANT_TRUE
,I2
,-VARIANT_TRUE
);
1830 VARABS(BOOL
,VARIANT_FALSE
,I2
,VARIANT_FALSE
);
1831 VARABS(EMPTY
,0,I2
,0);
1832 VARABS(EMPTY
,1,I2
,0);
1833 VARABS(NULL
,0,NULL
,0);
1834 VARABS(NULL
,1,NULL
,0);
1839 VARABS(UI1
,1,UI1
,1);
1844 VARABS(DATE
,1,DATE
,1);
1845 VARABS(DATE
,-1,DATE
,1);
1847 V_CY(&v
).int64
= -10000;
1848 memset(&vDst
,0,sizeof(vDst
));
1849 hres
= pVarAbs(&v
,&vDst
);
1850 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_CY
&& V_CY(&vDst
).int64
== 10000,
1851 "VarAbs(CY): expected 0x0 got 0x%X\n", hres
);
1852 GetLocaleInfoA(LOCALE_USER_DEFAULT
, LOCALE_SDECIMAL
, buff
, sizeof(buff
)/sizeof(char));
1853 if (buff
[0] != '.' || buff
[1])
1855 trace("Skipping VarAbs(BSTR) as decimal separator is '%s'\n", buff
);
1859 V_BSTR(&v
) = (BSTR
)szNum
;
1860 memset(&vDst
,0,sizeof(vDst
));
1861 hres
= pVarAbs(&v
,&vDst
);
1862 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_R8
&& V_R8(&vDst
) == 1.1,
1863 "VarAbs: expected 0x0,%d,%g, got 0x%X,%d,%g\n", VT_R8
, 1.1, hres
, V_VT(&vDst
), V_R8(&vDst
));
1866 static HRESULT (WINAPI
*pVarNot
)(LPVARIANT
,LPVARIANT
);
1868 #define VARNOT(vt,val,rvt,rval) \
1869 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
1870 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
1871 test_var_call1( __LINE__, pVarNot, &v, &exp );
1873 static void test_VarNot(void)
1875 static const WCHAR szNum0
[] = {'0','\0' };
1876 static const WCHAR szNum1
[] = {'1','\0' };
1878 VARIANT v
, exp
, vDst
;
1879 DECIMAL
*pdec
= &V_DECIMAL(&v
);
1880 CY
*pcy
= &V_CY(&v
);
1885 /* Test all possible V_VT values */
1886 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
1890 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
1892 HRESULT hExpected
= DISP_E_BADVARTYPE
;
1896 memset(&v
, 0, sizeof(v
));
1897 V_VT(&v
) = vt
| ExtraFlags
[i
];
1898 V_VT(&vDst
) = VT_EMPTY
;
1902 case VT_I1
: case VT_UI1
: case VT_I2
: case VT_UI2
:
1903 case VT_INT
: case VT_UINT
: case VT_I4
: case VT_UI4
:
1904 case VT_R4
: case VT_R8
:
1905 case VT_DECIMAL
: case VT_BOOL
: case VT_NULL
: case VT_EMPTY
:
1906 case VT_DATE
: case VT_CY
:
1909 case VT_I8
: case VT_UI8
:
1910 if (HAVE_OLEAUT32_I8
)
1914 if (HAVE_OLEAUT32_RECORD
)
1915 hExpected
= DISP_E_TYPEMISMATCH
;
1917 case VT_UNKNOWN
: case VT_BSTR
: case VT_DISPATCH
: case VT_ERROR
:
1918 hExpected
= DISP_E_TYPEMISMATCH
;
1921 if (IsValidVariantClearVT(vt
, ExtraFlags
[i
]) && vt
!= VT_CLSID
)
1922 hExpected
= DISP_E_TYPEMISMATCH
;
1926 hres
= pVarNot(&v
,&vDst
);
1927 ok(hres
== hExpected
, "VarNot: expected 0x%X, got 0x%X vt %d|0x%X\n",
1928 hExpected
, hres
, vt
, ExtraFlags
[i
]);
1931 /* Test the values returned by all cases that can succeed */
1932 VARNOT(EMPTY
,0,I2
,-1);
1933 VARNOT(EMPTY
,1,I2
,-1);
1934 VARNOT(NULL
,0,NULL
,0);
1935 VARNOT(NULL
,1,NULL
,0);
1936 VARNOT(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
);
1937 VARNOT(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
);
1945 VARNOT(UI1
,1,UI1
,254);
1946 VARNOT(UI1
,0,UI1
,255);
1947 VARNOT(UI2
,0,I4
,-1);
1948 VARNOT(UI2
,1,I4
,-2);
1949 VARNOT(UI4
,0,I4
,-1);
1950 VARNOT(UI4
,1,I4
,-2);
1951 VARNOT(INT
,0,I4
,-1);
1952 VARNOT(INT
,1,I4
,-2);
1953 VARNOT(UINT
,0,I4
,-1);
1954 VARNOT(UINT
,1,I4
,-2);
1955 if (HAVE_OLEAUT32_I8
)
1959 VARNOT(UI8
,0,I4
,-1);
1960 VARNOT(UI8
,1,I4
,-2);
1966 VARNOT(DATE
,1,I4
,-2);
1967 VARNOT(DATE
,0,I4
,-1);
1968 VARNOT(BSTR
,(BSTR
)szNum0
,I4
,-1);
1969 ok(V_VT(&v
) == VT_BSTR
&& V_BSTR(&v
) == szNum0
, "VarNot(0): changed input\n");
1970 VARNOT(BSTR
,(BSTR
)szNum1
,I4
,-2);
1971 ok(V_VT(&v
) == VT_BSTR
&& V_BSTR(&v
) == szNum1
, "VarNot(1): changed input\n");
1973 V_VT(&v
) = VT_DECIMAL
;
1974 S(U(*pdec
)).sign
= DECIMAL_NEG
;
1975 S(U(*pdec
)).scale
= 0;
1977 S1(U1(*pdec
)).Mid32
= 0;
1978 S1(U1(*pdec
)).Lo32
= 1;
1979 VARNOT(DECIMAL
,*pdec
,I4
,0);
1982 VARNOT(CY
,*pcy
,I4
,-2);
1985 VARNOT(CY
,*pcy
,I4
,-1);
1988 VARNOT(CY
,*pcy
,I4
,-1);
1991 static HRESULT (WINAPI
*pVarSub
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
1993 #define VARSUB(vt1,val1,vt2,val2,rvt,rval) \
1994 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
1995 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
1996 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
1997 test_var_call2( __LINE__, pVarSub, &left, &right, &exp );
1999 static void test_VarSub(void)
2001 static const WCHAR sz12
[] = {'1','2','\0'};
2002 VARIANT left
, right
, exp
, result
, cy
, dec
;
2005 HRESULT hres
, expectedhres
;
2010 lbstr
= SysAllocString(sz12
);
2011 rbstr
= SysAllocString(sz12
);
2014 VariantInit(&right
);
2015 VariantInit(&result
);
2017 /* Test all possible flag/vt combinations & the resulting vt type */
2018 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
2021 VARTYPE leftvt
, rightvt
, resvt
;
2023 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
2028 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
2032 expectedhres
= S_OK
;
2034 memset(&left
, 0, sizeof(left
));
2035 memset(&right
, 0, sizeof(right
));
2036 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
2037 if (leftvt
== VT_BSTR
)
2038 V_BSTR(&left
) = lbstr
;
2039 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
2040 if (rightvt
== VT_BSTR
)
2041 V_BSTR(&right
) = rbstr
;
2042 V_VT(&result
) = VT_EMPTY
;
2045 /* All extra flags produce errors */
2046 if (ExtraFlags
[i
] == (VT_VECTOR
|VT_BYREF
|VT_RESERVED
) ||
2047 ExtraFlags
[i
] == (VT_VECTOR
|VT_RESERVED
) ||
2048 ExtraFlags
[i
] == (VT_VECTOR
|VT_BYREF
) ||
2049 ExtraFlags
[i
] == (VT_BYREF
|VT_RESERVED
) ||
2050 ExtraFlags
[i
] == VT_VECTOR
||
2051 ExtraFlags
[i
] == VT_BYREF
||
2052 ExtraFlags
[i
] == VT_RESERVED
)
2054 expectedhres
= DISP_E_BADVARTYPE
;
2057 else if (ExtraFlags
[i
] >= VT_ARRAY
)
2059 expectedhres
= DISP_E_TYPEMISMATCH
;
2062 /* Native VarSub cannot handle: VT_I1, VT_UI2, VT_UI4,
2063 VT_INT, VT_UINT and VT_UI8. Tested with WinXP */
2064 else if (!IsValidVariantClearVT(leftvt
, ExtraFlags
[i
]) ||
2065 !IsValidVariantClearVT(rightvt
, ExtraFlags
[i
]) ||
2066 leftvt
== VT_CLSID
|| rightvt
== VT_CLSID
||
2067 leftvt
== VT_VARIANT
|| rightvt
== VT_VARIANT
||
2068 leftvt
== VT_I1
|| rightvt
== VT_I1
||
2069 leftvt
== VT_UI2
|| rightvt
== VT_UI2
||
2070 leftvt
== VT_UI4
|| rightvt
== VT_UI4
||
2071 leftvt
== VT_UI8
|| rightvt
== VT_UI8
||
2072 leftvt
== VT_INT
|| rightvt
== VT_INT
||
2073 leftvt
== VT_UINT
|| rightvt
== VT_UINT
||
2074 leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
||
2075 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
)
2077 if (leftvt
== VT_RECORD
&& rightvt
== VT_I8
)
2078 expectedhres
= DISP_E_TYPEMISMATCH
;
2079 else if (leftvt
< VT_UI1
&& rightvt
== VT_RECORD
)
2080 expectedhres
= DISP_E_TYPEMISMATCH
;
2081 else if (leftvt
>= VT_UI1
&& rightvt
== VT_RECORD
)
2082 expectedhres
= DISP_E_TYPEMISMATCH
;
2083 else if (leftvt
== VT_RECORD
&& rightvt
<= VT_UI1
)
2084 expectedhres
= DISP_E_TYPEMISMATCH
;
2085 else if (leftvt
== VT_RECORD
&& rightvt
> VT_UI1
)
2086 expectedhres
= DISP_E_BADVARTYPE
;
2088 expectedhres
= DISP_E_BADVARTYPE
;
2091 else if ((leftvt
== VT_NULL
&& rightvt
== VT_DISPATCH
) ||
2092 (leftvt
== VT_DISPATCH
&& rightvt
== VT_NULL
))
2094 else if (leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
||
2095 leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
)
2098 expectedhres
= DISP_E_TYPEMISMATCH
;
2100 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
2102 else if ((leftvt
== VT_EMPTY
&& rightvt
== VT_BSTR
) ||
2103 (leftvt
== VT_DATE
&& rightvt
== VT_DATE
) ||
2104 (leftvt
== VT_BSTR
&& rightvt
== VT_EMPTY
) ||
2105 (leftvt
== VT_BSTR
&& rightvt
== VT_BSTR
))
2107 else if (leftvt
== VT_DECIMAL
|| rightvt
== VT_DECIMAL
)
2109 else if (leftvt
== VT_DATE
|| rightvt
== VT_DATE
)
2111 else if (leftvt
== VT_CY
|| rightvt
== VT_CY
)
2113 else if (leftvt
== VT_R8
|| rightvt
== VT_R8
)
2115 else if (leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
) {
2117 } else if (leftvt
== VT_R4
|| rightvt
== VT_R4
) {
2118 if (leftvt
== VT_I4
|| rightvt
== VT_I4
||
2119 leftvt
== VT_I8
|| rightvt
== VT_I8
)
2124 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
2126 else if (leftvt
== VT_I4
|| rightvt
== VT_I4
)
2128 else if (leftvt
== VT_I2
|| rightvt
== VT_I2
||
2129 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
||
2130 (leftvt
== VT_EMPTY
&& rightvt
== VT_EMPTY
))
2132 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
2137 expectedhres
= DISP_E_TYPEMISMATCH
;
2140 hres
= pVarSub(&left
, &right
, &result
);
2142 ok(hres
== expectedhres
&& V_VT(&result
) == resvt
,
2143 "VarSub: %d|0x%X, %d|0x%X: Expected failure 0x%X, "
2144 "got 0x%X, expected vt %d got vt %d\n",
2145 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
],
2146 expectedhres
, hres
, resvt
, V_VT(&result
));
2151 /* Test returned values */
2152 VARSUB(I4
,4,I4
,2,I4
,2);
2153 VARSUB(I2
,4,I2
,2,I2
,2);
2154 VARSUB(I2
,-13,I4
,5,I4
,-18);
2155 VARSUB(I4
,-13,I4
,5,I4
,-18);
2156 VARSUB(I2
,7,R4
,0.5,R4
,6.5);
2157 VARSUB(R4
,0.5,I4
,5,R8
,-4.5);
2158 VARSUB(R8
,7.1,BOOL
,0,R8
,7.1);
2159 VARSUB(BSTR
,lbstr
,I2
,4,R8
,8);
2160 VARSUB(BSTR
,lbstr
,BOOL
,1,R8
,11);
2161 VARSUB(BSTR
,lbstr
,R4
,0.1,R8
,11.9);
2162 VARSUB(R4
,0.2,BSTR
,rbstr
,R8
,-11.8);
2163 VARSUB(DATE
,2.25,I4
,7,DATE
,-4.75);
2164 VARSUB(DATE
,1.25,R4
,-1.7,DATE
,2.95);
2166 VARSUB(UI1
, UI1_MAX
, UI1
, UI1_MAX
, UI1
, 0);
2167 VARSUB(I2
, I2_MAX
, I2
, I2_MAX
, I2
, 0);
2168 VARSUB(I2
, I2_MIN
, I2
, I2_MIN
, I2
, 0);
2169 VARSUB(I4
, I4_MAX
, I4
, I4_MAX
, I4
, 0.0);
2170 VARSUB(I4
, I4_MIN
, I4
, I4_MIN
, I4
, 0.0);
2171 VARSUB(R4
, R4_MAX
, R4
, R4_MAX
, R4
, 0.0);
2172 VARSUB(R4
, R4_MAX
, R4
, R4_MIN
, R4
, R4_MAX
- R4_MIN
);
2173 VARSUB(R4
, R4_MIN
, R4
, R4_MIN
, R4
, 0.0);
2174 VARSUB(R8
, R8_MAX
, R8
, R8_MIN
, R8
, R8_MAX
- R8_MIN
);
2175 VARSUB(R8
, R8_MIN
, R8
, R8_MIN
, R8
, 0.0);
2177 /* Manually test BSTR + BSTR */
2178 V_VT(&left
) = VT_BSTR
;
2179 V_BSTR(&left
) = lbstr
;
2180 V_VT(&right
) = VT_BSTR
;
2181 V_BSTR(&right
) = rbstr
;
2182 hres
= VarSub(&left
, &right
, &result
);
2183 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
2184 "VarSub: expected coerced type VT_R8, got %s!\n", vtstr(V_VT(&result
)));
2185 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 0),
2186 "VarSub: BSTR + BSTR, expected %f got %f\n", 0.0, V_R8(&result
));
2188 /* Manually test some VT_CY and VT_DECIMAL variants */
2190 hres
= VarCyFromI4(4711, &V_CY(&cy
));
2191 ok(hres
== S_OK
, "VarCyFromI4 failed!\n");
2192 V_VT(&dec
) = VT_DECIMAL
;
2193 hres
= VarDecFromR8(-4.2, &V_DECIMAL(&dec
));
2194 ok(hres
== S_OK
, "VarDecFromR4 failed!\n");
2195 memset(&left
, 0, sizeof(left
));
2196 memset(&right
, 0, sizeof(right
));
2197 V_VT(&left
) = VT_I4
;
2199 V_VT(&right
) = VT_UI1
;
2202 hres
= VarSub(&cy
, &right
, &result
);
2203 ok(hres
== S_OK
&& V_VT(&result
) == VT_CY
,
2204 "VarSub: expected coerced type VT_CY, got %s!\n", vtstr(V_VT(&result
)));
2205 hres
= VarR8FromCy(V_CY(&result
), &r
);
2206 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 4702),
2207 "VarSub: CY value %f, expected %f\n", r
, (double)4720);
2209 hres
= VarSub(&left
, &dec
, &result
);
2210 ok(hres
== S_OK
&& V_VT(&result
) == VT_DECIMAL
,
2211 "VarSub: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result
)));
2212 hres
= VarR8FromDec(&V_DECIMAL(&result
), &r
);
2213 ok(hres
== S_OK
&& EQ_DOUBLE(r
, -6.8),
2214 "VarSub: DECIMAL value %f, expected %f\n", r
, (double)-15.2);
2216 SysFreeString(lbstr
);
2217 SysFreeString(rbstr
);
2220 static HRESULT (WINAPI
*pVarMod
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
2222 static void test_Mod( int line
, VARIANT
*left
, VARIANT
*right
, VARIANT
*expected
, HRESULT expres
)
2227 memset( &result
, 0, sizeof(result
) );
2228 hres
= pVarMod( left
, right
, &result
);
2229 ok_(__FILE__
,line
)( hres
== expres
, "wrong result %x/%x\n", hres
, expres
);
2231 ok_(__FILE__
,line
)( is_expected_variant( &result
, expected
),
2232 "got %s expected %s\n", variantstr(&result
), variantstr(expected
) );
2235 #define VARMOD(vt1,vt2,val1,val2,rvt,rval) \
2236 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
2237 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
2238 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
2239 test_var_call2( __LINE__, pVarMod, &left, &right, &exp );
2241 #define VARMOD2(vt1,vt2,val1,val2,rvt,rval,hexpected) \
2242 V_VT(&left) = VT_##vt1; V_I4(&left) = val1; \
2243 V_VT(&right) = VT_##vt2; V_I4(&right) = val2; \
2244 V_VT(&exp) = VT_##rvt; V_I4(&exp) = rval; \
2245 test_Mod( __LINE__, &left, &right, &exp, hexpected );
2247 static void test_VarMod(void)
2249 VARIANT v1
, v2
, vDst
, left
, right
, exp
;
2251 HRESULT hexpected
= 0;
2252 static const WCHAR szNum0
[] = {'1','2','5','\0'};
2253 static const WCHAR szNum1
[] = {'1','0','\0'};
2255 BOOL lFound
, rFound
;
2256 BOOL lValid
, rValid
;
2257 BSTR strNum0
, strNum1
;
2261 VARMOD(I1
,BOOL
,100,10,I4
,0);
2262 VARMOD(I1
,I1
,100,10,I4
,0);
2263 VARMOD(I1
,UI1
,100,10,I4
,0);
2264 VARMOD(I1
,I2
,100,10,I4
,0);
2265 VARMOD(I1
,UI2
,100,10,I4
,0);
2266 VARMOD(I1
,I4
,100,10,I4
,0);
2267 VARMOD(I1
,UI4
,100,10,I4
,0);
2268 VARMOD(I1
,R4
,100,10,I4
,0);
2269 VARMOD(I1
,R8
,100,10,I4
,0);
2271 VARMOD(UI1
,BOOL
,100,10,I2
,0);
2272 VARMOD(UI1
,I1
,100,10,I4
,0);
2273 VARMOD(UI1
,UI1
,100,10,UI1
,0);
2274 VARMOD(UI1
,I2
,100,10,I2
,0);
2275 VARMOD(UI1
,UI2
,100,10,I4
,0);
2276 VARMOD(UI1
,I4
,100,10,I4
,0);
2277 VARMOD(UI1
,UI4
,100,10,I4
,0);
2278 VARMOD(UI1
,R4
,100,10,I4
,0);
2279 VARMOD(UI1
,R8
,100,10,I4
,0);
2281 VARMOD(I2
,BOOL
,100,10,I2
,0);
2282 VARMOD(I2
,I1
,100,10,I4
,0);
2283 VARMOD(I2
,UI1
,100,10,I2
,0);
2284 VARMOD(I2
,I2
,100,10,I2
,0);
2285 VARMOD(I2
,UI2
,100,10,I4
,0);
2286 VARMOD(I2
,I4
,100,10,I4
,0);
2287 VARMOD(I2
,UI4
,100,10,I4
,0);
2288 VARMOD(I2
,R4
,100,10,I4
,0);
2289 VARMOD(I2
,R8
,100,10,I4
,0);
2291 VARMOD(I4
,BOOL
,100,10,I4
,0);
2292 VARMOD(I4
,I1
,100,10,I4
,0);
2293 VARMOD(I4
,UI1
,100,10,I4
,0);
2294 VARMOD(I4
,I2
,100,10,I4
,0);
2295 VARMOD(I4
,UI2
,100,10,I4
,0);
2296 VARMOD(I4
,I4
,100,10,I4
,0);
2297 VARMOD(I4
,UI4
,100,10,I4
,0);
2298 VARMOD(I4
,R4
,100,10,I4
,0);
2299 VARMOD(I4
,R8
,100,10,I4
,0);
2300 VARMOD(UI4
,BOOL
,100,10,I4
,0);
2301 VARMOD(UI4
,I1
,100,10,I4
,0);
2302 VARMOD(UI4
,UI1
,100,10,I4
,0);
2303 VARMOD(UI4
,I2
,100,10,I4
,0);
2304 VARMOD(UI4
,UI2
,100,10,I4
,0);
2305 VARMOD(UI4
,I4
,100,10,I4
,0);
2306 VARMOD(UI4
,UI4
,100,10,I4
,0);
2307 VARMOD(UI4
,R4
,100,10,I4
,0);
2308 VARMOD(UI4
,R8
,100,10,I4
,0);
2309 VARMOD(R4
,BOOL
,100,10,I4
,0);
2310 VARMOD(R4
,I1
,100,10,I4
,0);
2311 VARMOD(R4
,UI1
,100,10,I4
,0);
2312 VARMOD(R4
,I2
,100,10,I4
,0);
2313 VARMOD(R4
,UI2
,100,10,I4
,0);
2314 VARMOD(R4
,I4
,100,10,I4
,0);
2315 VARMOD(R4
,UI4
,100,10,I4
,0);
2316 VARMOD(R4
,R4
,100,10,I4
,0);
2317 VARMOD(R4
,R8
,100,10,I4
,0);
2318 VARMOD(R8
,BOOL
,100,10,I4
,0);
2319 VARMOD(R8
,I1
,100,10,I4
,0);
2320 VARMOD(R8
,UI1
,100,10,I4
,0);
2321 VARMOD(R8
,I2
,100,10,I4
,0);
2322 VARMOD(R8
,UI2
,100,10,I4
,0);
2323 VARMOD(R8
,I4
,100,10,I4
,0);
2324 VARMOD(R8
,UI4
,100,10,I4
,0);
2325 VARMOD(R8
,R4
,100,10,I4
,0);
2326 VARMOD(R8
,R8
,100,10,I4
,0);
2328 VARMOD(INT
,INT
,100,10,I4
,0);
2329 VARMOD(INT
,UINT
,100,10,I4
,0);
2331 VARMOD(BOOL
,BOOL
,100,10,I2
,0);
2332 VARMOD(BOOL
,I1
,100,10,I4
,0);
2333 VARMOD(BOOL
,UI1
,100,10,I2
,0);
2334 VARMOD(BOOL
,I2
,100,10,I2
,0);
2335 VARMOD(BOOL
,UI2
,100,10,I4
,0);
2336 VARMOD(BOOL
,I4
,100,10,I4
,0);
2337 VARMOD(BOOL
,UI4
,100,10,I4
,0);
2338 VARMOD(BOOL
,R4
,100,10,I4
,0);
2339 VARMOD(BOOL
,R8
,100,10,I4
,0);
2340 VARMOD(BOOL
,DATE
,100,10,I4
,0);
2342 VARMOD(DATE
,BOOL
,100,10,I4
,0);
2343 VARMOD(DATE
,I1
,100,10,I4
,0);
2344 VARMOD(DATE
,UI1
,100,10,I4
,0);
2345 VARMOD(DATE
,I2
,100,10,I4
,0);
2346 VARMOD(DATE
,UI2
,100,10,I4
,0);
2347 VARMOD(DATE
,I4
,100,10,I4
,0);
2348 VARMOD(DATE
,UI4
,100,10,I4
,0);
2349 VARMOD(DATE
,R4
,100,10,I4
,0);
2350 VARMOD(DATE
,R8
,100,10,I4
,0);
2351 VARMOD(DATE
,DATE
,100,10,I4
,0);
2353 strNum0
= SysAllocString(szNum0
);
2354 strNum1
= SysAllocString(szNum1
);
2355 VARMOD(BSTR
,BSTR
,strNum0
,strNum1
,I4
,5);
2356 VARMOD(BSTR
,I1
,strNum0
,10,I4
,5);
2357 VARMOD(BSTR
,I2
,strNum0
,10,I4
,5);
2358 VARMOD(BSTR
,I4
,strNum0
,10,I4
,5);
2359 VARMOD(BSTR
,R4
,strNum0
,10,I4
,5);
2360 VARMOD(BSTR
,R8
,strNum0
,10,I4
,5);
2361 VARMOD(I4
,BSTR
,125,strNum1
,I4
,5);
2363 if (HAVE_OLEAUT32_I8
)
2365 VARMOD(BOOL
,I8
,100,10,I8
,0);
2366 VARMOD(I1
,I8
,100,10,I8
,0);
2367 VARMOD(UI1
,I8
,100,10,I8
,0);
2368 VARMOD(I2
,I8
,100,10,I8
,0);
2369 VARMOD(I4
,I8
,100,10,I8
,0);
2370 VARMOD(UI4
,I8
,100,10,I8
,0);
2371 VARMOD(R4
,I8
,100,10,I8
,0);
2372 VARMOD(R8
,I8
,100,10,I8
,0);
2373 VARMOD(DATE
,I8
,100,10,I8
,0);
2375 VARMOD(I8
,BOOL
,100,10,I8
,0);
2376 VARMOD(I8
,I1
,100,10,I8
,0);
2377 VARMOD(I8
,UI1
,100,10,I8
,0);
2378 VARMOD(I8
,I2
,100,10,I8
,0);
2379 VARMOD(I8
,UI2
,100,10,I8
,0);
2380 VARMOD(I8
,I4
,100,10,I8
,0);
2381 VARMOD(I8
,UI4
,100,10,I8
,0);
2382 VARMOD(I8
,R4
,100,10,I8
,0);
2383 VARMOD(I8
,R8
,100,10,I8
,0);
2384 VARMOD(I8
,I8
,100,10,I8
,0);
2386 VARMOD(BSTR
,I8
,strNum0
,10,I8
,5);
2389 /* test all combinations of types */
2390 for(l
= 0; l
< VT_BSTR_BLOB
; l
++)
2394 for(r
= 0; r
< VT_BSTR_BLOB
; r
++)
2398 if(l
== VT_BSTR
) continue;
2399 if(l
== VT_DISPATCH
) continue;
2400 if(r
== VT_BSTR
) continue;
2401 if(r
== VT_DISPATCH
) continue;
2435 hexpected
= DISP_E_BADVARTYPE
;
2474 if(((l
== VT_I8
) && (r
== VT_INT
)) || ((l
== VT_INT
) && (r
== VT_I8
)))
2476 hexpected
= DISP_E_TYPEMISMATCH
;
2477 } else if((l
== VT_EMPTY
) && (r
== VT_NULL
))
2480 } else if((l
== VT_NULL
) && (r
== VT_EMPTY
))
2483 } else if((l
== VT_EMPTY
) && (r
== VT_CY
))
2486 } else if((l
== VT_EMPTY
) && (r
== VT_RECORD
))
2488 hexpected
= DISP_E_TYPEMISMATCH
;
2489 } else if((r
== VT_EMPTY
) && lFound
&& lValid
)
2491 hexpected
= DISP_E_DIVBYZERO
;
2492 } else if((l
== VT_ERROR
) || ((r
== VT_ERROR
) && lFound
&& lValid
))
2494 hexpected
= DISP_E_TYPEMISMATCH
;
2495 } else if((l
== VT_NULL
) && (r
== VT_NULL
))
2498 } else if((l
== VT_VARIANT
) || ((r
== VT_VARIANT
) && lFound
&& lValid
))
2500 hexpected
= DISP_E_TYPEMISMATCH
;
2501 } else if((l
== VT_NULL
) && (r
== VT_RECORD
))
2503 hexpected
= DISP_E_TYPEMISMATCH
;
2504 } else if((l
== VT_I8
) && (r
== VT_DECIMAL
))
2507 } else if((l
== VT_DECIMAL
) && (r
== VT_I8
))
2510 } else if((l
== VT_UNKNOWN
) || ((r
== VT_UNKNOWN
) && lFound
&& lValid
))
2512 hexpected
= DISP_E_TYPEMISMATCH
;
2513 } else if((l
== VT_NULL
) && rFound
)
2516 } else if(l
== VT_RECORD
)
2518 hexpected
= DISP_E_TYPEMISMATCH
;
2519 } else if((r
== VT_RECORD
) && lValid
&& lFound
)
2521 hexpected
= DISP_E_TYPEMISMATCH
;
2522 } else if((l
== VT_EMPTY
) && (r
== VT_EMPTY
))
2524 hexpected
= DISP_E_DIVBYZERO
;
2525 } else if((l
== VT_CY
) && !rFound
)
2527 hexpected
= DISP_E_BADVARTYPE
;
2528 } else if(lFound
&& !rFound
)
2530 hexpected
= DISP_E_BADVARTYPE
;
2531 } else if(!lFound
&& rFound
)
2533 hexpected
= DISP_E_BADVARTYPE
;
2534 } else if((r
== VT_NULL
) && lFound
&& lValid
)
2537 } else if((l
== VT_NULL
) || (r
== VT_NULL
))
2539 hexpected
= DISP_E_BADVARTYPE
;
2540 } else if((l
== VT_VARIANT
) || (r
== VT_VARIANT
))
2542 hexpected
= DISP_E_BADVARTYPE
;
2543 } else if(lFound
&& !rFound
)
2545 hexpected
= DISP_E_BADVARTYPE
;
2546 } else if(!lFound
&& !rFound
)
2548 hexpected
= DISP_E_BADVARTYPE
;
2555 V_CY(&v1
).int64
= 1000000;
2560 else if(l
== VT_UI8
)
2564 else if(l
== VT_DATE
)
2566 else if (l
== VT_DECIMAL
)
2568 V_DECIMAL(&v1
).Hi32
= 0;
2569 U1(V_DECIMAL(&v1
)).Lo64
= 100;
2570 U(V_DECIMAL(&v1
)).signscale
= 0;
2576 V_CY(&v2
).int64
= 10000;
2581 else if(r
== VT_UI8
)
2585 else if(r
== VT_DATE
)
2587 else if (r
== VT_DECIMAL
)
2589 V_DECIMAL(&v2
).Hi32
= 0;
2590 U1(V_DECIMAL(&v2
)).Lo64
= 100;
2591 U(V_DECIMAL(&v2
)).signscale
= 0;
2596 if ((l
!= VT_I8
&& l
!= VT_UI8
&& r
!= VT_I8
&& r
!= VT_UI8
) || HAVE_OLEAUT32_I8
)
2598 hres
= pVarMod(&v1
,&v2
,&vDst
);
2599 ok(hres
== hexpected
,
2600 "VarMod: expected 0x%x, got 0x%X for l type of %d, r type of %d,\n", hexpected
, hres
, l
, r
);
2606 /****************************/
2607 /* test some bad parameters */
2608 VARMOD(I4
,I4
,-1,-1,I4
,0);
2610 /* test modulus with zero */
2611 VARMOD2(I4
,I4
,100,0,EMPTY
,0,DISP_E_DIVBYZERO
);
2613 VARMOD(I4
,I4
,0,10,I4
,0); /* test 0 mod 10 */
2615 /* right parameter is type empty */
2616 VARMOD2(I4
,EMPTY
,100,10,EMPTY
,0,DISP_E_DIVBYZERO
);
2618 /* left parameter is type empty */
2619 VARMOD2(EMPTY
,I4
,100,10,I4
,0,S_OK
);
2621 /* mod with a null left value */
2622 VARMOD2(NULL
,I4
,125,10,NULL
,0,S_OK
);
2624 /* mod with a null right value */
2625 VARMOD2(I4
,NULL
,100,10,NULL
,0,S_OK
);
2627 /* void left value */
2628 VARMOD2(VOID
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2630 /* void right value */
2631 VARMOD2(I4
,VOID
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2633 /* null left value, void right value */
2634 VARMOD2(NULL
,VOID
,100,10,EMPTY
, 0, DISP_E_BADVARTYPE
);
2636 /* void left value, null right value */
2637 VARMOD2(VOID
,NULL
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2639 /* some currencies */
2642 V_CY(&v1
).int64
= 100000;
2643 V_CY(&v2
).int64
= 100000;
2644 hres
= pVarMod(&v1
,&v2
,&vDst
);
2645 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I4
&& V_I4(&vDst
) == 0,
2646 "VarMod: expected 0x%x,%d,%d, got 0x%X,%d,%d\n", S_OK
, VT_I4
, 0, hres
, V_VT(&vDst
), V_I4(&vDst
));
2651 V_CY(&v2
).int64
= 100000;
2652 hres
= pVarMod(&v1
,&v2
,&vDst
);
2653 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I4
&& V_I4(&vDst
) == 0,
2654 "VarMod: expected 0x%x,%d,%d, got 0x%X,%d,%d\n", S_OK
, VT_I4
, 0, hres
, V_VT(&vDst
), V_I4(&vDst
));
2657 V_VT(&v1
) = VT_DECIMAL
;
2658 V_VT(&v2
) = VT_DECIMAL
;
2659 VarDecFromI4(100, &V_DECIMAL(&v1
));
2660 VarDecFromI4(10, &V_DECIMAL(&v2
));
2661 hres
= pVarMod(&v1
,&v2
,&vDst
);
2662 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I4
&& V_I4(&vDst
) == 0,
2663 "VarMod: expected 0x%x,%d,%d, got 0x%X,%d,%d\n", S_OK
, VT_I4
, 0, hres
, V_VT(&vDst
), V_I4(&vDst
));
2666 V_VT(&v2
) = VT_DECIMAL
;
2668 VarDecFromI4(10, &V_DECIMAL(&v2
));
2669 hres
= pVarMod(&v1
,&v2
,&vDst
);
2670 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I4
&& V_I4(&vDst
) == 0,
2671 "VarMod: expected 0x%x,%d,%d, got 0x%X,%d,%d\n", S_OK
, VT_I4
, 0, hres
, V_VT(&vDst
), V_I4(&vDst
));
2673 VARMOD2(UINT
,I4
,100,10,I4
,0,S_OK
);
2675 /* test that an error results in the type of the result changing but not its value */
2676 V_VT(&v1
) = VT_UNKNOWN
;
2677 V_VT(&v2
) = VT_EMPTY
;
2679 V_CY(&v2
).int64
= 100000;
2680 V_VT(&vDst
) = VT_I4
;
2682 hres
= pVarMod(&v1
,&v2
,&vDst
);
2683 ok(hres
== DISP_E_TYPEMISMATCH
&& V_VT(&vDst
) == VT_EMPTY
&& V_I4(&vDst
) == 1231,
2684 "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
));
2687 /* test some invalid types */
2688 /*TODO: not testing VT_DISPATCH */
2689 if (HAVE_OLEAUT32_I8
)
2691 VARMOD2(I8
,INT
,100,10,EMPTY
,0,DISP_E_TYPEMISMATCH
);
2693 VARMOD2(ERROR
,I4
,100,10,EMPTY
,0,DISP_E_TYPEMISMATCH
);
2694 VARMOD2(VARIANT
,I4
,100,10,EMPTY
,0,DISP_E_TYPEMISMATCH
);
2695 VARMOD2(UNKNOWN
,I4
,100,10,EMPTY
,0,DISP_E_TYPEMISMATCH
);
2696 VARMOD2(VOID
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2697 VARMOD2(HRESULT
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2698 VARMOD2(PTR
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2699 VARMOD2(SAFEARRAY
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2700 VARMOD2(CARRAY
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2701 VARMOD2(USERDEFINED
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2702 VARMOD2(LPSTR
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2703 VARMOD2(LPWSTR
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2704 VARMOD2(RECORD
,I4
,100,10,EMPTY
,0,DISP_E_TYPEMISMATCH
);
2705 VARMOD2(FILETIME
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2706 VARMOD2(BLOB
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2707 VARMOD2(STREAM
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2708 VARMOD2(STORAGE
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2709 VARMOD2(STREAMED_OBJECT
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2710 VARMOD2(STORED_OBJECT
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2711 VARMOD2(BLOB_OBJECT
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2712 VARMOD2(CF
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2713 VARMOD2(CLSID
,CLSID
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2714 VARMOD2(VECTOR
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2715 VARMOD2(ARRAY
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2716 VARMOD2(BYREF
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2718 /* test some more invalid types */
2723 hres
= pVarMod(&v1
,&v2
,&vDst
);
2724 ok(hres
== DISP_E_BADVARTYPE
&& V_VT(&vDst
) == VT_EMPTY
,
2725 "VarMod: expected 0x%x,%d, got 0x%X,%d\n", DISP_E_BADVARTYPE
, VT_EMPTY
, hres
, V_VT(&vDst
));
2728 static HRESULT (WINAPI
*pVarFix
)(LPVARIANT
,LPVARIANT
);
2730 #define VARFIX(vt,val,rvt,rval) \
2731 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
2732 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
2733 test_var_call1( __LINE__, pVarFix, &v, &exp );
2735 static void test_VarFix(void)
2737 static const WCHAR szNumMinus1
[] = {'-','1','\0' };
2739 VARIANT v
, exp
, vDst
;
2740 DECIMAL
*pdec
= &V_DECIMAL(&v
);
2741 CY
*pcy
= &V_CY(&v
);
2746 /* Test all possible V_VT values */
2747 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
2751 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
2753 HRESULT bFail
= TRUE
;
2757 memset(&v
, 0, sizeof(v
));
2758 V_VT(&v
) = vt
| ExtraFlags
[i
];
2759 V_VT(&vDst
) = VT_EMPTY
;
2763 case VT_UI1
: case VT_I2
: case VT_I4
: case VT_R4
: case VT_R8
:
2764 case VT_DECIMAL
: case VT_BOOL
: case VT_NULL
: case VT_EMPTY
:
2765 case VT_DATE
: case VT_CY
:
2769 if (HAVE_OLEAUT32_I8
)
2774 hres
= pVarFix(&v
,&vDst
);
2776 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
2777 "VarFix: expected failure, got 0x%X vt %d|0x%X\n",
2778 hres
, vt
, ExtraFlags
[i
]);
2780 ok(hres
== S_OK
, "VarFix: expected S_OK, got 0x%X vt %d|0x%X\n",
2781 hres
, vt
, ExtraFlags
[i
]);
2785 VARFIX(BOOL
,VARIANT_TRUE
,I2
,VARIANT_TRUE
);
2786 VARFIX(BOOL
,VARIANT_FALSE
,I2
,0);
2787 VARFIX(BOOL
,1,I2
,1);
2788 VARFIX(UI1
,1,UI1
,1);
2789 VARFIX(I2
,-1,I2
,-1);
2790 VARFIX(I4
,-1,I4
,-1);
2791 if (HAVE_OLEAUT32_I8
)
2793 VARFIX(I8
,-1,I8
,-1);
2795 VARFIX(R4
,1.4,R4
,1);
2796 VARFIX(R4
,1.5,R4
,1);
2797 VARFIX(R4
,1.6,R4
,1);
2798 VARFIX(R4
,-1.4,R4
,-1);
2799 VARFIX(R4
,-1.5,R4
,-1);
2800 VARFIX(R4
,-1.6,R4
,-1);
2801 /* DATE & R8 round as for R4 */
2802 VARFIX(DATE
,-1,DATE
,-1);
2803 VARFIX(R8
,-1,R8
,-1);
2804 VARFIX(BSTR
,(BSTR
)szNumMinus1
,R8
,-1);
2806 V_VT(&v
) = VT_EMPTY
;
2807 hres
= pVarFix(&v
,&vDst
);
2808 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I2
&& V_I2(&vDst
) == 0,
2809 "VarFix: expected 0x0,%d,0 got 0x%X,%d,%d\n", VT_EMPTY
,
2810 hres
, V_VT(&vDst
), V_I2(&vDst
));
2813 hres
= pVarFix(&v
,&vDst
);
2814 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_NULL
,
2815 "VarFix: expected 0x0,%d got 0x%X,%d\n", VT_NULL
, hres
, V_VT(&vDst
));
2817 V_VT(&v
) = VT_DECIMAL
;
2818 S(U(*pdec
)).sign
= DECIMAL_NEG
;
2819 S(U(*pdec
)).scale
= 0;
2821 S1(U1(*pdec
)).Mid32
= 0;
2822 S1(U1(*pdec
)).Lo32
= 1;
2823 hres
= pVarFix(&v
,&vDst
);
2824 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_DECIMAL
&& !memcmp(&v
, &vDst
, sizeof(v
)),
2825 "VarFix: expected 0x0,%d,identical, got 0x%X,%d\n", VT_DECIMAL
,
2828 /* FIXME: Test some fractional decimals when VarDecFix is implemented */
2831 pcy
->int64
= -10000;
2832 hres
= pVarFix(&v
,&vDst
);
2833 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_CY
&& V_CY(&vDst
).int64
== -10000,
2834 "VarFix: VT_CY wrong, hres=0x%X\n", hres
);
2837 pcy
->int64
= -16000;
2838 hres
= pVarFix(&v
,&vDst
);
2839 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_CY
&& V_CY(&vDst
).int64
== -10000,
2840 "VarFix: VT_CY wrong, hres=0x%X\n", hres
);
2843 static HRESULT (WINAPI
*pVarInt
)(LPVARIANT
,LPVARIANT
);
2845 #define VARINT(vt,val,rvt,rval) \
2846 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
2847 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
2848 test_var_call1( __LINE__, pVarInt, &v, &exp );
2850 static void test_VarInt(void)
2852 static const WCHAR szNumMinus1
[] = {'-','1','\0' };
2854 VARIANT v
, exp
, vDst
;
2855 DECIMAL
*pdec
= &V_DECIMAL(&v
);
2856 CY
*pcy
= &V_CY(&v
);
2861 /* Test all possible V_VT values */
2862 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
2866 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
2868 HRESULT bFail
= TRUE
;
2872 memset(&v
, 0, sizeof(v
));
2873 V_VT(&v
) = vt
| ExtraFlags
[i
];
2874 V_VT(&vDst
) = VT_EMPTY
;
2878 case VT_UI1
: case VT_I2
: case VT_I4
: case VT_R4
: case VT_R8
:
2879 case VT_DECIMAL
: case VT_BOOL
: case VT_NULL
: case VT_EMPTY
:
2880 case VT_DATE
: case VT_CY
:
2884 if (HAVE_OLEAUT32_I8
)
2889 hres
= pVarInt(&v
,&vDst
);
2891 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
2892 "VarInt: expected failure, got 0x%X vt %d|0x%X\n",
2893 hres
, vt
, ExtraFlags
[i
]);
2895 ok(hres
== S_OK
, "VarInt: expected S_OK, got 0x%X vt %d|0x%X\n",
2896 hres
, vt
, ExtraFlags
[i
]);
2900 VARINT(BOOL
,VARIANT_TRUE
,I2
,VARIANT_TRUE
);
2901 VARINT(BOOL
,VARIANT_FALSE
,I2
,0);
2902 VARINT(BOOL
,1,I2
,1);
2903 VARINT(UI1
,1,UI1
,1);
2904 VARINT(I2
,-1,I2
,-1);
2905 VARINT(I4
,-1,I4
,-1);
2906 if (HAVE_OLEAUT32_I8
)
2908 VARINT(I8
,-1,I8
,-1);
2910 VARINT(R4
,1.4,R4
,1);
2911 VARINT(R4
,1.5,R4
,1);
2912 VARINT(R4
,1.6,R4
,1);
2913 VARINT(R4
,-1.4,R4
,-2); /* Note these 3 are different from VarFix */
2914 VARINT(R4
,-1.5,R4
,-2);
2915 VARINT(R4
,-1.6,R4
,-2);
2916 /* DATE & R8 round as for R4 */
2917 VARINT(DATE
,-1,DATE
,-1);
2918 VARINT(R8
,-1,R8
,-1);
2919 VARINT(BSTR
,(BSTR
)szNumMinus1
,R8
,-1);
2921 V_VT(&v
) = VT_EMPTY
;
2922 hres
= pVarInt(&v
,&vDst
);
2923 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I2
&& V_I2(&vDst
) == 0,
2924 "VarInt: expected 0x0,%d,0 got 0x%X,%d,%d\n", VT_EMPTY
,
2925 hres
, V_VT(&vDst
), V_I2(&vDst
));
2928 hres
= pVarInt(&v
,&vDst
);
2929 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_NULL
,
2930 "VarInt: expected 0x0,%d got 0x%X,%d\n", VT_NULL
, hres
, V_VT(&vDst
));
2932 V_VT(&v
) = VT_DECIMAL
;
2933 S(U(*pdec
)).sign
= DECIMAL_NEG
;
2934 S(U(*pdec
)).scale
= 0;
2936 S1(U1(*pdec
)).Mid32
= 0;
2937 S1(U1(*pdec
)).Lo32
= 1;
2938 hres
= pVarInt(&v
,&vDst
);
2939 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_DECIMAL
&& !memcmp(&v
, &vDst
, sizeof(v
)),
2940 "VarInt: expected 0x0,%d,identical, got 0x%X,%d\n", VT_DECIMAL
,
2943 /* FIXME: Test some fractional decimals when VarDecInt is implemented */
2946 pcy
->int64
= -10000;
2947 hres
= pVarInt(&v
,&vDst
);
2948 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_CY
&& V_CY(&vDst
).int64
== -10000,
2949 "VarInt: VT_CY wrong, hres=0x%X\n", hres
);
2952 pcy
->int64
= -11000;
2953 hres
= pVarInt(&v
,&vDst
);
2954 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_CY
&& V_CY(&vDst
).int64
== -20000,
2955 "VarInt: VT_CY wrong, hres=0x%X 0x%x%08x\n",
2956 hres
, (DWORD
)(V_CY(&vDst
).int64
>> 32), (DWORD
)V_CY(&vDst
).int64
);
2959 static HRESULT (WINAPI
*pVarNeg
)(LPVARIANT
,LPVARIANT
);
2961 #define VARNEG(vt,val,rvt,rval) \
2962 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
2963 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
2964 test_var_call1( __LINE__, pVarNeg, &v, &exp );
2966 static void test_VarNeg(void)
2968 static const WCHAR szNumMinus1
[] = {'-','1','\0' };
2969 static const WCHAR szNum1
[] = {'1','\0' };
2971 VARIANT v
, exp
, vDst
;
2972 DECIMAL
*pdec
= &V_DECIMAL(&v
);
2973 CY
*pcy
= &V_CY(&v
);
2978 /* Test all possible V_VT values. But don't test the exact return values
2979 * except for success/failure, since M$ made a hash of them in the
2980 * native version. This at least ensures (as with all tests here) that
2981 * we will notice if/when new vtypes/flags are added in native.
2983 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
2987 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
2989 HRESULT bFail
= TRUE
;
2993 memset(&v
, 0, sizeof(v
));
2994 V_VT(&v
) = vt
| ExtraFlags
[i
];
2995 V_VT(&vDst
) = VT_EMPTY
;
2999 case VT_UI1
: case VT_I2
: case VT_I4
:
3000 case VT_R4
: case VT_R8
:
3001 case VT_DECIMAL
: case VT_BOOL
: case VT_NULL
: case VT_EMPTY
:
3002 case VT_DATE
: case VT_CY
:
3006 if (HAVE_OLEAUT32_I8
)
3010 hres
= pVarNeg(&v
,&vDst
);
3012 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
3013 "VarNeg: expected failure, got 0x%X vt %d|0x%X\n",
3014 hres
, vt
, ExtraFlags
[i
]);
3016 ok(hres
== S_OK
, "VarNeg: expected S_OK, got 0x%X vt %d|0x%X\n",
3017 hres
, vt
, ExtraFlags
[i
]);
3021 VARNEG(BOOL
,VARIANT_TRUE
,I2
,1);
3022 VARNEG(BOOL
,VARIANT_FALSE
,I2
,0);
3023 VARNEG(BOOL
,1,I2
,-1);
3024 VARNEG(UI1
,1,I2
,-1);
3025 VARNEG(UI1
,254,I2
,-254);
3026 VARNEG(I2
,-32768,I4
,32768);
3029 VARNEG(I4
,-((int)(~0u >> 1)) - 1,R8
,-2147483648u);
3032 if (HAVE_OLEAUT32_I8
)
3039 VARNEG(DATE
,1,DATE
,-1);
3040 VARNEG(DATE
,-1,DATE
,1);
3043 VARNEG(BSTR
,(BSTR
)szNumMinus1
,R8
,1);
3044 VARNEG(BSTR
,(BSTR
)szNum1
,R8
,-1);
3046 V_VT(&v
) = VT_EMPTY
;
3047 hres
= pVarNeg(&v
,&vDst
);
3048 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I2
&& V_I2(&vDst
) == 0,
3049 "VarNeg: expected 0x0,%d,0 got 0x%X,%d,%d\n", VT_EMPTY
,
3050 hres
, V_VT(&vDst
), V_I2(&vDst
));
3053 hres
= pVarNeg(&v
,&vDst
);
3054 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_NULL
,
3055 "VarNeg: expected 0x0,%d got 0x%X,%d\n", VT_NULL
, hres
, V_VT(&vDst
));
3057 V_VT(&v
) = VT_DECIMAL
;
3058 S(U(*pdec
)).sign
= DECIMAL_NEG
;
3059 S(U(*pdec
)).scale
= 0;
3061 S1(U1(*pdec
)).Mid32
= 0;
3062 S1(U1(*pdec
)).Lo32
= 1;
3063 hres
= pVarNeg(&v
,&vDst
);
3064 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_DECIMAL
&&
3065 S(U(V_DECIMAL(&vDst
))).sign
== 0,
3066 "VarNeg: expected 0x0,%d,0x00, got 0x%X,%d,%02x\n", VT_DECIMAL
,
3067 hres
, V_VT(&vDst
), S(U(V_DECIMAL(&vDst
))).sign
);
3069 S(U(*pdec
)).sign
= 0;
3070 hres
= pVarNeg(&v
,&vDst
);
3071 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_DECIMAL
&&
3072 S(U(V_DECIMAL(&vDst
))).sign
== DECIMAL_NEG
,
3073 "VarNeg: expected 0x0,%d,0x7f, got 0x%X,%d,%02x\n", VT_DECIMAL
,
3074 hres
, V_VT(&vDst
), S(U(V_DECIMAL(&vDst
))).sign
);
3077 pcy
->int64
= -10000;
3078 hres
= pVarNeg(&v
,&vDst
);
3079 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_CY
&& V_CY(&vDst
).int64
== 10000,
3080 "VarNeg: VT_CY wrong, hres=0x%X\n", hres
);
3083 static HRESULT (WINAPI
*pVarRound
)(LPVARIANT
,int,LPVARIANT
);
3085 static void test_Round( int line
, VARIANT
*arg
, int deci
, VARIANT
*expected
)
3090 memset( &result
, 0, sizeof(result
) );
3091 hres
= pVarRound( arg
, deci
, &result
);
3092 ok_(__FILE__
,line
)( hres
== S_OK
, "wrong result %x\n", hres
);
3094 ok_(__FILE__
,line
)( is_expected_variant( &result
, expected
),
3095 "got %s expected %s\n", variantstr(&result
), variantstr(expected
) );
3097 #define VARROUND(vt,val,deci,rvt,rval) \
3098 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
3099 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
3100 test_Round( __LINE__, &v, deci, &exp );
3102 static void test_VarRound(void)
3104 static const WCHAR szNumMin
[] = {'-','1','.','4','5','\0' };
3105 static const WCHAR szNum
[] = {'1','.','4','5','\0' };
3107 VARIANT v
, exp
, vDst
;
3108 CY
*pcy
= &V_CY(&v
);
3112 /* first check valid integer types */
3113 VARROUND(BOOL
,VARIANT_TRUE
,0,I2
,-1);
3114 VARROUND(BOOL
,VARIANT_FALSE
,0,I2
,0);
3115 VARROUND(BOOL
,1,0,I2
,1);
3116 VARROUND(UI1
,1,0,UI1
,1);
3117 VARROUND(UI1
,254,0,UI1
,254);
3118 VARROUND(I2
,-32768,0,I2
,-32768);
3119 VARROUND(I2
,-1,0,I2
,-1);
3120 VARROUND(I2
,1,0,I2
,1);
3121 VARROUND(I4
,-((int)(~0u >> 1)) - 1,0,I4
,-((int)(~0u >> 1)) - 1);
3122 VARROUND(I4
,-1,0,I4
,-1);
3123 VARROUND(I4
,1,0,I4
,1);
3126 /* MSDN states that rounding of R4/R8 is dependent on the underlying
3127 * bit pattern of the number and so is architecture dependent. In this
3128 * case Wine returns .2 (which is more correct) and Native returns .3
3131 VARROUND(R4
,1.0,0,R4
,1.0);
3132 VARROUND(R4
,-1.0,0,R4
,-1.0);
3133 VARROUND(R8
,1.0,0,R8
,1.0);
3134 VARROUND(R8
,-1.0,0,R8
,-1.0);
3136 /* floating point numbers aren't exactly equal and we can't just
3137 * compare the first few digits. */
3138 VARROUND(DATE
,1.451,1,DATE
,1.5);
3139 VARROUND(DATE
,-1.45,1,DATE
,-1.4);
3140 VARROUND(BSTR
,(BSTR
)szNumMin
,1,R8
,-1.40);
3141 if (0) { VARROUND(BSTR
,(BSTR
)szNum
,1,R8
,1.50); }
3143 VARROUND(R4
,1.23456,0,R4
,1.0);
3144 VARROUND(R4
,1.23456,1,R4
,1.2);
3145 VARROUND(R4
,1.23456,2,R4
,1.23);
3146 VARROUND(R4
,1.23456,3,R4
,1.235);
3147 VARROUND(R4
,1.23456,4,R4
,1.2346);
3148 VARROUND(R4
,-1.23456,0,R4
,-1.0);
3149 VARROUND(R4
,-1.23456,1,R4
,-1.2);
3150 VARROUND(R4
,-1.23456,2,R4
,-1.23);
3151 VARROUND(R4
,-1.23456,3,R4
,-1.235);
3152 VARROUND(R4
,-1.23456,4,R4
,-1.2346);
3154 VARROUND(R8
,1.23456,0,R8
,1.0);
3155 VARROUND(R8
,1.23456,1,R8
,1.2);
3156 VARROUND(R8
,1.23456,2,R8
,1.23);
3157 VARROUND(R8
,1.23456,3,R8
,1.235);
3158 VARROUND(R8
,1.23456,4,R8
,1.2346);
3159 VARROUND(R8
,-1.23456,0,R8
,-1.0);
3160 VARROUND(R8
,-1.23456,1,R8
,-1.2);
3161 VARROUND(R8
,-1.23456,2,R8
,-1.23);
3162 VARROUND(R8
,-1.23456,3,R8
,-1.235);
3163 VARROUND(R8
,-1.23456,4,R8
,-1.2346);
3165 V_VT(&v
) = VT_EMPTY
;
3166 hres
= pVarRound(&v
,0,&vDst
);
3167 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I2
&& V_I2(&vDst
) == 0,
3168 "VarRound: expected 0x0,%d,0 got 0x%X,%d,%d\n", VT_EMPTY
,
3169 hres
, V_VT(&vDst
), V_I2(&vDst
));
3172 hres
= pVarRound(&v
,0,&vDst
);
3173 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_NULL
,
3174 "VarRound: expected 0x0,%d got 0x%X,%d\n", VT_NULL
, hres
, V_VT(&vDst
));
3176 /* not yet implemented so no use testing yet
3178 DECIMAL *pdec = &V_DECIMAL(&v);
3179 V_VT(&v) = VT_DECIMAL;
3180 S(U(*pdec)).sign = DECIMAL_NEG;
3181 S(U(*pdec)).scale = 0;
3183 S1(U1(*pdec)).Mid32 = 0;
3184 S1(U1(*pdec)).Lo32 = 1;
3185 hres = pVarRound(&v,0,&vDst);
3186 ok(hres == S_OK && V_VT(&vDst) == VT_DECIMAL &&
3187 S(U(V_DECIMAL(&vDst))).sign == 0,
3188 "VarRound: expected 0x0,%d,0x00, got 0x%X,%d,%02x\n", VT_DECIMAL,
3189 hres, V_VT(&vDst), S(U(V_DECIMAL(&vDst))).sign);
3191 S(U(*pdec)).sign = 0;
3192 hres = pVarRound(&v,0,&vDst);
3193 ok(hres == S_OK && V_VT(&vDst) == VT_DECIMAL &&
3194 S(U(V_DECIMAL(&vDst))).sign == DECIMAL_NEG,
3195 "VarRound: expected 0x0,%d,0x7f, got 0x%X,%d,%02x\n", VT_DECIMAL,
3196 hres, V_VT(&vDst), S(U(V_DECIMAL(&vDst))).sign);
3202 hres
= pVarRound(&v
,0,&vDst
);
3203 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_CY
&& V_CY(&vDst
).int64
== 10000,
3204 "VarRound: VT_CY wrong, hres=0x%X\n", hres
);
3208 static HRESULT (WINAPI
*pVarXor
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
3210 #define VARXOR(vt1,val1,vt2,val2,rvt,rval) \
3211 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
3212 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
3213 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
3214 test_var_call2( __LINE__, pVarXor, &left, &right, &exp );
3216 #define VARXORCY(vt1,val1,val2,rvt,rval) \
3217 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
3218 V_VT(&right) = VT_CY; V_CY(&right).int64 = val2; \
3219 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
3220 test_var_call2( __LINE__, pVarXor, &left, &right, &exp );
3222 static void test_VarXor(void)
3224 static const WCHAR szFalse
[] = { '#','F','A','L','S','E','#','\0' };
3225 static const WCHAR szTrue
[] = { '#','T','R','U','E','#','\0' };
3226 VARIANT left
, right
, exp
, result
;
3233 /* Test all possible flag/vt combinations & the resulting vt type */
3234 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
3236 VARTYPE leftvt
, rightvt
, resvt
;
3238 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
3243 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
3249 if (leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
||
3250 leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
||
3251 leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
)
3254 memset(&left
, 0, sizeof(left
));
3255 memset(&right
, 0, sizeof(right
));
3256 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
3257 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
3258 V_VT(&result
) = VT_EMPTY
;
3261 if (ExtraFlags
[i
] & VT_ARRAY
|| ExtraFlags
[i
] & VT_BYREF
||
3262 !IsValidVariantClearVT(leftvt
, ExtraFlags
[i
]) ||
3263 !IsValidVariantClearVT(rightvt
, ExtraFlags
[i
]) ||
3264 leftvt
== VT_CLSID
|| rightvt
== VT_CLSID
||
3265 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
||
3266 leftvt
== VT_VARIANT
|| rightvt
== VT_VARIANT
||
3267 leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
)
3271 if (leftvt
== VT_EMPTY
|| rightvt
== VT_EMPTY
)
3273 if (leftvt
== rightvt
||
3274 leftvt
== VT_I2
|| rightvt
== VT_I2
||
3275 leftvt
== VT_UI1
|| rightvt
== VT_UI1
||
3276 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
3278 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
3280 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
3283 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
3287 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
3289 if (leftvt
== rightvt
)
3291 else if (leftvt
== rightvt
||
3292 leftvt
== VT_I2
|| rightvt
== VT_I2
||
3293 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
3297 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
3300 else if (leftvt
== VT_I2
|| rightvt
== VT_I2
)
3302 if (leftvt
== rightvt
||
3303 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
3305 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
3308 else if (leftvt
== VT_BOOL
&& rightvt
== VT_BOOL
)
3312 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
3314 if (leftvt
== VT_INT
|| rightvt
== VT_INT
)
3319 hres
= pVarXor(&left
, &right
, &result
);
3321 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
3322 "VarXor: %d|0x%X, %d|0x%X: Expected failure, got 0x%X vt %d\n",
3323 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], hres
,
3326 ok(hres
== S_OK
&& V_VT(&result
) == resvt
,
3327 "VarXor: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%X vt %d\n",
3328 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], resvt
, hres
,
3334 /* Test returned values
3335 * FIXME: Test VT_DECIMAL/VT_DISPATCH
3337 VARXOR(EMPTY
,0,EMPTY
,0,I2
,0);
3338 VARXOR(EMPTY
,1,EMPTY
,0,I2
,0);
3339 VARXOR(EMPTY
,0,NULL
,0,NULL
,0);
3340 VARXOR(EMPTY
,0,I1
,0,I4
,0);
3341 VARXOR(EMPTY
,0,I1
,1,I4
,1);
3342 VARXOR(EMPTY
,0,UI1
,0,I2
,0);
3343 VARXOR(EMPTY
,0,UI1
,1,I2
,1);
3344 VARXOR(EMPTY
,0,I2
,0,I2
,0);
3345 VARXOR(EMPTY
,0,I2
,1,I2
,1);
3346 VARXOR(EMPTY
,0,UI2
,0,I4
,0);
3347 VARXOR(EMPTY
,0,UI2
,1,I4
,1);
3348 VARXOR(EMPTY
,0,I4
,0,I4
,0);
3349 VARXOR(EMPTY
,0,I4
,1,I4
,1);
3350 VARXOR(EMPTY
,0,UI4
,0,I4
,0);
3351 VARXOR(EMPTY
,0,UI4
,1,I4
,1);
3352 if (HAVE_OLEAUT32_I8
)
3354 VARXOR(EMPTY
,0,I8
,0,I8
,0);
3355 VARXOR(EMPTY
,0,I8
,1,I8
,1);
3356 VARXOR(EMPTY
,0,UI8
,0,I4
,0);
3357 VARXOR(EMPTY
,0,UI8
,1,I4
,1);
3359 VARXOR(EMPTY
,0,INT
,0,I4
,0);
3360 VARXOR(EMPTY
,0,INT
,1,I4
,1);
3361 VARXOR(EMPTY
,0,UINT
,0,I4
,0);
3362 VARXOR(EMPTY
,0,UINT
,1,I4
,1);
3363 VARXOR(EMPTY
,0,BOOL
,0,I2
,0);
3364 VARXOR(EMPTY
,0,BOOL
,1,I2
,1);
3365 VARXOR(EMPTY
,0,R4
,0,I4
,0);
3366 VARXOR(EMPTY
,0,R4
,1,I4
,1);
3367 VARXOR(EMPTY
,0,R8
,0,I4
,0);
3368 VARXOR(EMPTY
,0,R8
,1,I4
,1);
3369 rbstr
= SysAllocString(szFalse
);
3370 VARXOR(EMPTY
,0,BSTR
,rbstr
,I2
,0);
3371 rbstr
= SysAllocString(szTrue
);
3372 VARXOR(EMPTY
,0,BSTR
,rbstr
,I2
,-1);
3373 VARXORCY(EMPTY
,0,10000,I4
,1);
3375 /* NULL OR 0 = NULL. NULL OR n = n */
3376 VARXOR(NULL
,0,NULL
,0,NULL
,0);
3377 VARXOR(NULL
,1,NULL
,0,NULL
,0);
3378 VARXOR(NULL
,0,I1
,0,NULL
,0);
3379 VARXOR(NULL
,0,I1
,1,NULL
,0);
3380 VARXOR(NULL
,0,UI1
,0,NULL
,0);
3381 VARXOR(NULL
,0,UI1
,1,NULL
,0);
3382 VARXOR(NULL
,0,I2
,0,NULL
,0);
3383 VARXOR(NULL
,0,I2
,1,NULL
,0);
3384 VARXOR(NULL
,0,UI2
,0,NULL
,0);
3385 VARXOR(NULL
,0,UI2
,1,NULL
,0);
3386 VARXOR(NULL
,0,I4
,0,NULL
,0);
3387 VARXOR(NULL
,0,I4
,1,NULL
,0);
3388 VARXOR(NULL
,0,UI4
,0,NULL
,0);
3389 VARXOR(NULL
,0,UI4
,1,NULL
,0);
3390 if (HAVE_OLEAUT32_I8
)
3392 VARXOR(NULL
,0,I8
,0,NULL
,0);
3393 VARXOR(NULL
,0,I8
,1,NULL
,0);
3394 VARXOR(NULL
,0,UI8
,0,NULL
,0);
3395 VARXOR(NULL
,0,UI8
,1,NULL
,0);
3397 VARXOR(NULL
,0,INT
,0,NULL
,0);
3398 VARXOR(NULL
,0,INT
,1,NULL
,0);
3399 VARXOR(NULL
,0,UINT
,0,NULL
,0);
3400 VARXOR(NULL
,0,UINT
,1,NULL
,0);
3401 VARXOR(NULL
,0,BOOL
,0,NULL
,0);
3402 VARXOR(NULL
,0,BOOL
,1,NULL
,0);
3403 VARXOR(NULL
,0,R4
,0,NULL
,0);
3404 VARXOR(NULL
,0,R4
,1,NULL
,0);
3405 VARXOR(NULL
,0,R8
,0,NULL
,0);
3406 VARXOR(NULL
,0,R8
,1,NULL
,0);
3407 rbstr
= SysAllocString(szFalse
);
3408 VARXOR(NULL
,0,BSTR
,rbstr
,NULL
,0);
3409 rbstr
= SysAllocString(szTrue
);
3410 VARXOR(NULL
,0,BSTR
,rbstr
,NULL
,0);
3411 VARXORCY(NULL
,0,10000,NULL
,0);
3412 VARXORCY(NULL
,0,0,NULL
,0);
3414 VARXOR(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
);
3415 VARXOR(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
);
3416 VARXOR(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
);
3417 VARXOR(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_FALSE
);
3418 /* Assume x,y & y,x are the same from now on to reduce the number of tests */
3419 VARXOR(BOOL
,VARIANT_TRUE
,I1
,-1,I4
,0);
3420 VARXOR(BOOL
,VARIANT_TRUE
,I1
,0,I4
,-1);
3421 VARXOR(BOOL
,VARIANT_FALSE
,I1
,0,I4
,0);
3422 VARXOR(BOOL
,VARIANT_TRUE
,UI1
,255,I2
,-256);
3423 VARXOR(BOOL
,VARIANT_TRUE
,UI1
,0,I2
,-1);
3424 VARXOR(BOOL
,VARIANT_FALSE
,UI1
,0,I2
,0);
3425 VARXOR(BOOL
,VARIANT_TRUE
,I2
,-1,I2
,0);
3426 VARXOR(BOOL
,VARIANT_TRUE
,I2
,0,I2
,-1);
3427 VARXOR(BOOL
,VARIANT_FALSE
,I2
,0,I2
,0);
3428 VARXOR(BOOL
,VARIANT_TRUE
,UI2
,65535,I4
,-65536);
3429 VARXOR(BOOL
,VARIANT_TRUE
,UI2
,0,I4
,-1);
3430 VARXOR(BOOL
,VARIANT_FALSE
,UI2
,0,I4
,0);
3431 VARXOR(BOOL
,VARIANT_TRUE
,I4
,-1,I4
,0);
3432 VARXOR(BOOL
,VARIANT_TRUE
,I4
,0,I4
,-1);
3433 VARXOR(BOOL
,VARIANT_FALSE
,I4
,0,I4
,0);
3434 VARXOR(BOOL
,VARIANT_TRUE
,UI4
,0xffffffff,I4
,0);
3435 VARXOR(BOOL
,VARIANT_TRUE
,UI4
,0,I4
,-1);
3436 VARXOR(BOOL
,VARIANT_FALSE
,UI4
,0,I4
,0);
3437 VARXOR(BOOL
,VARIANT_TRUE
,R4
,-1,I4
,0);
3438 VARXOR(BOOL
,VARIANT_TRUE
,R4
,0,I4
,-1);
3439 VARXOR(BOOL
,VARIANT_FALSE
,R4
,0,I4
,0);
3440 VARXOR(BOOL
,VARIANT_TRUE
,R8
,-1,I4
,0);
3441 VARXOR(BOOL
,VARIANT_TRUE
,R8
,0,I4
,-1);
3442 VARXOR(BOOL
,VARIANT_FALSE
,R8
,0,I4
,0);
3443 VARXOR(BOOL
,VARIANT_TRUE
,DATE
,-1,I4
,0);
3444 VARXOR(BOOL
,VARIANT_TRUE
,DATE
,0,I4
,-1);
3445 VARXOR(BOOL
,VARIANT_FALSE
,DATE
,0,I4
,0);
3446 if (HAVE_OLEAUT32_I8
)
3448 VARXOR(BOOL
,VARIANT_TRUE
,I8
,-1,I8
,0);
3449 VARXOR(BOOL
,VARIANT_TRUE
,I8
,0,I8
,-1);
3450 VARXOR(BOOL
,VARIANT_FALSE
,I8
,0,I8
,0);
3451 /* This returns DISP_E_OVERFLOW which indicates that a conversion
3452 * to I4 is performed.
3454 /* VARXOR(BOOL,VARIANT_TRUE,UI8,-1,I4,-1); */
3455 VARXOR(BOOL
,VARIANT_TRUE
,UI8
,0,I4
,-1);
3456 VARXOR(BOOL
,VARIANT_FALSE
,UI8
,0,I4
,0);
3458 VARXOR(BOOL
,VARIANT_TRUE
,INT
,-1,I4
,0);
3459 VARXOR(BOOL
,VARIANT_TRUE
,INT
,0,I4
,-1);
3460 VARXOR(BOOL
,VARIANT_FALSE
,INT
,0,I4
,0);
3461 VARXOR(BOOL
,VARIANT_TRUE
,UINT
,0xffffffff,I4
,0);
3462 VARXOR(BOOL
,VARIANT_TRUE
,UINT
,0,I4
,-1);
3463 VARXOR(BOOL
,VARIANT_FALSE
,UINT
,0,I4
,0);
3464 rbstr
= SysAllocString(szFalse
);
3465 VARXOR(BOOL
,VARIANT_FALSE
,BSTR
,rbstr
,BOOL
,VARIANT_FALSE
);
3466 VARXOR(BOOL
,VARIANT_TRUE
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
3467 rbstr
= SysAllocString(szTrue
);
3468 VARXOR(BOOL
,VARIANT_FALSE
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
3469 VARXOR(BOOL
,VARIANT_TRUE
,BSTR
,rbstr
,BOOL
,VARIANT_FALSE
);
3470 VARXORCY(BOOL
,VARIANT_TRUE
,10000,I4
,-2);
3471 VARXORCY(BOOL
,VARIANT_TRUE
,0,I4
,-1);
3472 VARXORCY(BOOL
,VARIANT_FALSE
,0,I4
,0);
3474 VARXOR(I1
,-1,I1
,-1,I4
,0);
3475 VARXOR(I1
,-1,I1
,0,I4
,-1);
3476 VARXOR(I1
,0,I1
,0,I4
,0);
3477 VARXOR(I1
,-1,UI1
,255,I4
,-256);
3478 VARXOR(I1
,-1,UI1
,0,I4
,-1);
3479 VARXOR(I1
,0,UI1
,0,I4
,0);
3480 VARXOR(I1
,-1,I2
,-1,I4
,0);
3481 VARXOR(I1
,-1,I2
,0,I4
,-1);
3482 VARXOR(I1
,0,I2
,0,I4
,0);
3483 VARXOR(I1
,-1,UI2
,65535,I4
,-65536);
3484 VARXOR(I1
,-1,UI2
,0,I4
,-1);
3485 VARXOR(I1
,0,UI2
,0,I4
,0);
3486 VARXOR(I1
,-1,I4
,-1,I4
,0);
3487 VARXOR(I1
,-1,I4
,0,I4
,-1);
3488 VARXOR(I1
,0,I4
,0,I4
,0);
3489 VARXOR(I1
,-1,UI4
,0xffffffff,I4
,0);
3490 VARXOR(I1
,-1,UI4
,0,I4
,-1);
3491 VARXOR(I1
,0,UI4
,0,I4
,0);
3492 VARXOR(I1
,-1,R4
,-1,I4
,0);
3493 VARXOR(I1
,-1,R4
,0,I4
,-1);
3494 VARXOR(I1
,0,R4
,0,I4
,0);
3495 VARXOR(I1
,-1,R8
,-1,I4
,0);
3496 VARXOR(I1
,-1,R8
,0,I4
,-1);
3497 VARXOR(I1
,0,R8
,0,I4
,0);
3498 VARXOR(I1
,-1,DATE
,-1,I4
,0);
3499 VARXOR(I1
,-1,DATE
,0,I4
,-1);
3500 VARXOR(I1
,0,DATE
,0,I4
,0);
3501 if (HAVE_OLEAUT32_I8
)
3503 VARXOR(I1
,-1,I8
,-1,I8
,0);
3504 VARXOR(I1
,-1,I8
,0,I8
,-1);
3505 VARXOR(I1
,0,I8
,0,I8
,0);
3506 VARXOR(I1
,-1,UI8
,0,I4
,-1);
3507 VARXOR(I1
,0,UI8
,0,I4
,0);
3509 VARXOR(I1
,-1,INT
,-1,I4
,0);
3510 VARXOR(I1
,-1,INT
,0,I4
,-1);
3511 VARXOR(I1
,0,INT
,0,I4
,0);
3512 VARXOR(I1
,-1,UINT
,0xffffffff,I4
,0);
3513 VARXOR(I1
,-1,UINT
,0,I4
,-1);
3514 VARXOR(I1
,0,UINT
,0,I4
,0);
3515 rbstr
= SysAllocString(szFalse
);
3516 VARXOR(I1
,0,BSTR
,rbstr
,I4
,0);
3517 VARXOR(I1
,-1,BSTR
,rbstr
,I4
,-1);
3518 rbstr
= SysAllocString(szTrue
);
3519 VARXOR(I1
,0,BSTR
,rbstr
,I4
,-1);
3520 VARXOR(I1
,-1,BSTR
,rbstr
,I4
,0);
3521 VARXORCY(I1
,-1,10000,I4
,-2);
3522 VARXORCY(I1
,-1,0,I4
,-1);
3523 VARXORCY(I1
,0,0,I4
,0);
3525 VARXOR(UI1
,255,UI1
,255,UI1
,0);
3526 VARXOR(UI1
,255,UI1
,0,UI1
,255);
3527 VARXOR(UI1
,0,UI1
,0,UI1
,0);
3528 VARXOR(UI1
,255,I2
,-1,I2
,-256);
3529 VARXOR(UI1
,255,I2
,0,I2
,255);
3530 VARXOR(UI1
,0,I2
,0,I2
,0);
3531 VARXOR(UI1
,255,UI2
,65535,I4
,65280);
3532 VARXOR(UI1
,255,UI2
,0,I4
,255);
3533 VARXOR(UI1
,0,UI2
,0,I4
,0);
3534 VARXOR(UI1
,255,I4
,-1,I4
,-256);
3535 VARXOR(UI1
,255,I4
,0,I4
,255);
3536 VARXOR(UI1
,0,I4
,0,I4
,0);
3537 VARXOR(UI1
,255,UI4
,0xffffffff,I4
,-256);
3538 VARXOR(UI1
,255,UI4
,0,I4
,255);
3539 VARXOR(UI1
,0,UI4
,0,I4
,0);
3540 VARXOR(UI1
,255,R4
,-1,I4
,-256);
3541 VARXOR(UI1
,255,R4
,0,I4
,255);
3542 VARXOR(UI1
,0,R4
,0,I4
,0);
3543 VARXOR(UI1
,255,R8
,-1,I4
,-256);
3544 VARXOR(UI1
,255,R8
,0,I4
,255);
3545 VARXOR(UI1
,0,R8
,0,I4
,0);
3546 VARXOR(UI1
,255,DATE
,-1,I4
,-256);
3547 VARXOR(UI1
,255,DATE
,0,I4
,255);
3548 VARXOR(UI1
,0,DATE
,0,I4
,0);
3549 if (HAVE_OLEAUT32_I8
)
3551 VARXOR(UI1
,255,I8
,-1,I8
,-256);
3552 VARXOR(UI1
,255,I8
,0,I8
,255);
3553 VARXOR(UI1
,0,I8
,0,I8
,0);
3554 VARXOR(UI1
,255,UI8
,0,I4
,255);
3555 VARXOR(UI1
,0,UI8
,0,I4
,0);
3557 VARXOR(UI1
,255,INT
,-1,I4
,-256);
3558 VARXOR(UI1
,255,INT
,0,I4
,255);
3559 VARXOR(UI1
,0,INT
,0,I4
,0);
3560 VARXOR(UI1
,255,UINT
,0xffffffff,I4
,-256);
3561 VARXOR(UI1
,255,UINT
,0,I4
,255);
3562 VARXOR(UI1
,0,UINT
,0,I4
,0);
3563 rbstr
= SysAllocString(szFalse
);
3564 VARXOR(UI1
,0,BSTR
,rbstr
,I2
,0);
3565 VARXOR(UI1
,255,BSTR
,rbstr
,I2
,255);
3566 rbstr
= SysAllocString(szTrue
);
3567 VARXOR(UI1
,0,BSTR
,rbstr
,I2
,-1);
3568 VARXOR(UI1
,255,BSTR
,rbstr
,I2
,-256);
3569 VARXORCY(UI1
,255,10000,I4
,254);
3570 VARXORCY(UI1
,255,0,I4
,255);
3571 VARXORCY(UI1
,0,0,I4
,0);
3573 VARXOR(I2
,-1,I2
,-1,I2
,0);
3574 VARXOR(I2
,-1,I2
,0,I2
,-1);
3575 VARXOR(I2
,0,I2
,0,I2
,0);
3576 VARXOR(I2
,-1,UI2
,65535,I4
,-65536);
3577 VARXOR(I2
,-1,UI2
,0,I4
,-1);
3578 VARXOR(I2
,0,UI2
,0,I4
,0);
3579 VARXOR(I2
,-1,I4
,-1,I4
,0);
3580 VARXOR(I2
,-1,I4
,0,I4
,-1);
3581 VARXOR(I2
,0,I4
,0,I4
,0);
3582 VARXOR(I2
,-1,UI4
,0xffffffff,I4
,0);
3583 VARXOR(I2
,-1,UI4
,0,I4
,-1);
3584 VARXOR(I2
,0,UI4
,0,I4
,0);
3585 VARXOR(I2
,-1,R4
,-1,I4
,0);
3586 VARXOR(I2
,-1,R4
,0,I4
,-1);
3587 VARXOR(I2
,0,R4
,0,I4
,0);
3588 VARXOR(I2
,-1,R8
,-1,I4
,0);
3589 VARXOR(I2
,-1,R8
,0,I4
,-1);
3590 VARXOR(I2
,0,R8
,0,I4
,0);
3591 VARXOR(I2
,-1,DATE
,-1,I4
,0);
3592 VARXOR(I2
,-1,DATE
,0,I4
,-1);
3593 VARXOR(I2
,0,DATE
,0,I4
,0);
3594 if (HAVE_OLEAUT32_I8
)
3596 VARXOR(I2
,-1,I8
,-1,I8
,0);
3597 VARXOR(I2
,-1,I8
,0,I8
,-1);
3598 VARXOR(I2
,0,I8
,0,I8
,0);
3599 VARXOR(I2
,-1,UI8
,0,I4
,-1);
3600 VARXOR(I2
,0,UI8
,0,I4
,0);
3602 VARXOR(I2
,-1,INT
,-1,I4
,0);
3603 VARXOR(I2
,-1,INT
,0,I4
,-1);
3604 VARXOR(I2
,0,INT
,0,I4
,0);
3605 VARXOR(I2
,-1,UINT
,0xffffffff,I4
,0);
3606 VARXOR(I2
,-1,UINT
,0,I4
,-1);
3607 VARXOR(I2
,0,UINT
,0,I4
,0);
3608 rbstr
= SysAllocString(szFalse
);
3609 VARXOR(I2
,0,BSTR
,rbstr
,I2
,0);
3610 VARXOR(I2
,-1,BSTR
,rbstr
,I2
,-1);
3611 rbstr
= SysAllocString(szTrue
);
3612 VARXOR(I2
,0,BSTR
,rbstr
,I2
,-1);
3613 VARXOR(I2
,-1,BSTR
,rbstr
,I2
,0);
3614 VARXORCY(I2
,-1,10000,I4
,-2);
3615 VARXORCY(I2
,-1,0,I4
,-1);
3616 VARXORCY(I2
,0,0,I4
,0);
3618 VARXOR(UI2
,65535,UI2
,65535,I4
,0);
3619 VARXOR(UI2
,65535,UI2
,0,I4
,65535);
3620 VARXOR(UI2
,0,UI2
,0,I4
,0);
3621 VARXOR(UI2
,65535,I4
,-1,I4
,-65536);
3622 VARXOR(UI2
,65535,I4
,0,I4
,65535);
3623 VARXOR(UI2
,0,I4
,0,I4
,0);
3624 VARXOR(UI2
,65535,UI4
,0xffffffff,I4
,-65536);
3625 VARXOR(UI2
,65535,UI4
,0,I4
,65535);
3626 VARXOR(UI2
,0,UI4
,0,I4
,0);
3627 VARXOR(UI2
,65535,R4
,-1,I4
,-65536);
3628 VARXOR(UI2
,65535,R4
,0,I4
,65535);
3629 VARXOR(UI2
,0,R4
,0,I4
,0);
3630 VARXOR(UI2
,65535,R8
,-1,I4
,-65536);
3631 VARXOR(UI2
,65535,R8
,0,I4
,65535);
3632 VARXOR(UI2
,0,R8
,0,I4
,0);
3633 VARXOR(UI2
,65535,DATE
,-1,I4
,-65536);
3634 VARXOR(UI2
,65535,DATE
,0,I4
,65535);
3635 VARXOR(UI2
,0,DATE
,0,I4
,0);
3636 if (HAVE_OLEAUT32_I8
)
3638 VARXOR(UI2
,65535,I8
,-1,I8
,-65536);
3639 VARXOR(UI2
,65535,I8
,0,I8
,65535);
3640 VARXOR(UI2
,0,I8
,0,I8
,0);
3641 VARXOR(UI2
,65535,UI8
,0,I4
,65535);
3642 VARXOR(UI2
,0,UI8
,0,I4
,0);
3644 VARXOR(UI2
,65535,INT
,-1,I4
,-65536);
3645 VARXOR(UI2
,65535,INT
,0,I4
,65535);
3646 VARXOR(UI2
,0,INT
,0,I4
,0);
3647 VARXOR(UI2
,65535,UINT
,0xffffffff,I4
,-65536);
3648 VARXOR(UI2
,65535,UINT
,0,I4
,65535);
3649 VARXOR(UI2
,0,UINT
,0,I4
,0);
3650 rbstr
= SysAllocString(szFalse
);
3651 VARXOR(UI2
,0,BSTR
,rbstr
,I4
,0);
3652 VARXOR(UI2
,65535,BSTR
,rbstr
,I4
,65535);
3653 rbstr
= SysAllocString(szTrue
);
3654 VARXOR(UI2
,0,BSTR
,rbstr
,I4
,-1);
3655 VARXOR(UI2
,65535,BSTR
,rbstr
,I4
,-65536);
3656 VARXORCY(UI2
,65535,10000,I4
,65534);
3657 VARXORCY(UI2
,65535,0,I4
,65535);
3658 VARXORCY(UI2
,0,0,I4
,0);
3660 VARXOR(I4
,-1,I4
,-1,I4
,0);
3661 VARXOR(I4
,-1,I4
,0,I4
,-1);
3662 VARXOR(I4
,0,I4
,0,I4
,0);
3663 VARXOR(I4
,-1,UI4
,0xffffffff,I4
,0);
3664 VARXOR(I4
,-1,UI4
,0,I4
,-1);
3665 VARXOR(I4
,0,UI4
,0,I4
,0);
3666 VARXOR(I4
,-1,R4
,-1,I4
,0);
3667 VARXOR(I4
,-1,R4
,0,I4
,-1);
3668 VARXOR(I4
,0,R4
,0,I4
,0);
3669 VARXOR(I4
,-1,R8
,-1,I4
,0);
3670 VARXOR(I4
,-1,R8
,0,I4
,-1);
3671 VARXOR(I4
,0,R8
,0,I4
,0);
3672 VARXOR(I4
,-1,DATE
,-1,I4
,0);
3673 VARXOR(I4
,-1,DATE
,0,I4
,-1);
3674 VARXOR(I4
,0,DATE
,0,I4
,0);
3675 if (HAVE_OLEAUT32_I8
)
3677 VARXOR(I4
,-1,I8
,-1,I8
,0);
3678 VARXOR(I4
,-1,I8
,0,I8
,-1);
3679 VARXOR(I4
,0,I8
,0,I8
,0);
3680 VARXOR(I4
,-1,UI8
,0,I4
,-1);
3681 VARXOR(I4
,0,UI8
,0,I4
,0);
3683 VARXOR(I4
,-1,INT
,-1,I4
,0);
3684 VARXOR(I4
,-1,INT
,0,I4
,-1);
3685 VARXOR(I4
,0,INT
,0,I4
,0);
3686 VARXOR(I4
,-1,UINT
,0xffffffff,I4
,0);
3687 VARXOR(I4
,-1,UINT
,0,I4
,-1);
3688 VARXOR(I4
,0,UINT
,0,I4
,0);
3689 rbstr
= SysAllocString(szFalse
);
3690 VARXOR(I4
,0,BSTR
,rbstr
,I4
,0);
3691 VARXOR(I4
,-1,BSTR
,rbstr
,I4
,-1);
3692 rbstr
= SysAllocString(szTrue
);
3693 VARXOR(I4
,0,BSTR
,rbstr
,I4
,-1);
3694 VARXOR(I4
,-1,BSTR
,rbstr
,I4
,0);
3695 VARXORCY(I4
,-1,10000,I4
,-2);
3696 VARXORCY(I4
,-1,0,I4
,-1);
3697 VARXORCY(I4
,0,0,I4
,0);
3699 VARXOR(UI4
,0xffffffff,UI4
,0xffffffff,I4
,0);
3700 VARXOR(UI4
,0xffffffff,UI4
,0,I4
,-1);
3701 VARXOR(UI4
,0,UI4
,0,I4
,0);
3702 VARXOR(UI4
,0xffffffff,R4
,-1,I4
,0);
3703 VARXOR(UI4
,0xffffffff,R4
,0,I4
,-1);
3704 VARXOR(UI4
,0,R4
,0,I4
,0);
3705 VARXOR(UI4
,0xffffffff,R8
,-1,I4
,0);
3706 VARXOR(UI4
,0xffffffff,R8
,0,I4
,-1);
3707 VARXOR(UI4
,0,R8
,0,I4
,0);
3708 VARXOR(UI4
,0xffffffff,DATE
,-1,I4
,0);
3709 VARXOR(UI4
,0xffffffff,DATE
,0,I4
,-1);
3710 VARXOR(UI4
,0,DATE
,0,I4
,0);
3711 if (HAVE_OLEAUT32_I8
)
3713 VARXOR(UI4
,0xffffffff,I8
,0,I8
,0xffffffff);
3714 VARXOR(UI4
,VARIANT_FALSE
,I8
,VARIANT_FALSE
,I8
,0);
3715 VARXOR(UI4
,0,I8
,0,I8
,0);
3716 VARXOR(UI4
,0xffffffff,UI8
,0,I4
,-1);
3717 VARXOR(UI4
,0,UI8
,0,I4
,0);
3719 VARXOR(UI4
,0xffffffff,INT
,-1,I4
,0);
3720 VARXOR(UI4
,0xffffffff,INT
,0,I4
,-1);
3721 VARXOR(UI4
,0,INT
,0,I4
,0);
3722 VARXOR(UI4
,0xffffffff,UINT
,0xffffffff,I4
,0);
3723 VARXOR(UI4
,0xffffffff,UINT
,0,I4
,-1);
3724 VARXOR(UI4
,0,UINT
,0,I4
,0);
3725 rbstr
= SysAllocString(szFalse
);
3726 VARXOR(UI4
,0,BSTR
,rbstr
,I4
,0);
3727 VARXOR(UI4
,0xffffffff,BSTR
,rbstr
,I4
,-1);
3728 rbstr
= SysAllocString(szTrue
);
3729 VARXOR(UI4
,0,BSTR
,rbstr
,I4
,-1);
3730 VARXOR(UI4
,0xffffffff,BSTR
,rbstr
,I4
,0);
3731 VARXORCY(UI4
,0xffffffff,10000,I4
,-2);
3732 VARXORCY(UI4
,0xffffffff,0,I4
,-1);
3733 VARXORCY(UI4
,0,0,I4
,0);
3735 VARXOR(R4
,-1,R4
,-1,I4
,0);
3736 VARXOR(R4
,-1,R4
,0,I4
,-1);
3737 VARXOR(R4
,0,R4
,0,I4
,0);
3738 VARXOR(R4
,-1,R8
,-1,I4
,0);
3739 VARXOR(R4
,-1,R8
,0,I4
,-1);
3740 VARXOR(R4
,0,R8
,0,I4
,0);
3741 VARXOR(R4
,-1,DATE
,-1,I4
,0);
3742 VARXOR(R4
,-1,DATE
,0,I4
,-1);
3743 VARXOR(R4
,0,DATE
,0,I4
,0);
3744 if (HAVE_OLEAUT32_I8
)
3746 VARXOR(R4
,-1,I8
,-1,I8
,0);
3747 VARXOR(R4
,-1,I8
,0,I8
,-1);
3748 VARXOR(R4
,0,I8
,0,I8
,0);
3749 VARXOR(R4
,-1,UI8
,0,I4
,-1);
3750 VARXOR(R4
,0,UI8
,0,I4
,0);
3752 VARXOR(R4
,-1,INT
,-1,I4
,0);
3753 VARXOR(R4
,-1,INT
,0,I4
,-1);
3754 VARXOR(R4
,0,INT
,0,I4
,0);
3755 VARXOR(R4
,-1,UINT
,0xffffffff,I4
,0);
3756 VARXOR(R4
,-1,UINT
,0,I4
,-1);
3757 VARXOR(R4
,0,UINT
,0,I4
,0);
3758 rbstr
= SysAllocString(szFalse
);
3759 VARXOR(R4
,0,BSTR
,rbstr
,I4
,0);
3760 VARXOR(R4
,-1,BSTR
,rbstr
,I4
,-1);
3761 rbstr
= SysAllocString(szTrue
);
3762 VARXOR(R4
,0,BSTR
,rbstr
,I4
,-1);
3763 VARXOR(R4
,-1,BSTR
,rbstr
,I4
,0);
3764 VARXORCY(R4
,-1,10000,I4
,-2);
3765 VARXORCY(R4
,-1,0,I4
,-1);
3766 VARXORCY(R4
,0,0,I4
,0);
3768 VARXOR(R8
,-1,R8
,-1,I4
,0);
3769 VARXOR(R8
,-1,R8
,0,I4
,-1);
3770 VARXOR(R8
,0,R8
,0,I4
,0);
3771 VARXOR(R8
,-1,DATE
,-1,I4
,0);
3772 VARXOR(R8
,-1,DATE
,0,I4
,-1);
3773 VARXOR(R8
,0,DATE
,0,I4
,0);
3774 if (HAVE_OLEAUT32_I8
)
3776 VARXOR(R8
,-1,I8
,-1,I8
,0);
3777 VARXOR(R8
,-1,I8
,0,I8
,-1);
3778 VARXOR(R8
,0,I8
,0,I8
,0);
3779 VARXOR(R8
,-1,UI8
,0,I4
,-1);
3780 VARXOR(R8
,0,UI8
,0,I4
,0);
3782 VARXOR(R8
,-1,INT
,-1,I4
,0);
3783 VARXOR(R8
,-1,INT
,0,I4
,-1);
3784 VARXOR(R8
,0,INT
,0,I4
,0);
3785 VARXOR(R8
,-1,UINT
,0xffffffff,I4
,0);
3786 VARXOR(R8
,-1,UINT
,0,I4
,-1);
3787 VARXOR(R8
,0,UINT
,0,I4
,0);
3788 rbstr
= SysAllocString(szFalse
);
3789 VARXOR(R8
,0,BSTR
,rbstr
,I4
,0);
3790 VARXOR(R8
,-1,BSTR
,rbstr
,I4
,-1);
3791 rbstr
= SysAllocString(szTrue
);
3792 VARXOR(R8
,0,BSTR
,rbstr
,I4
,-1);
3793 VARXOR(R8
,-1,BSTR
,rbstr
,I4
,0);
3794 VARXORCY(R8
,-1,10000,I4
,-2);
3795 VARXORCY(R8
,-1,0,I4
,-1);
3796 VARXORCY(R8
,0,0,I4
,0);
3798 VARXOR(DATE
,-1,DATE
,-1,I4
,0);
3799 VARXOR(DATE
,-1,DATE
,0,I4
,-1);
3800 VARXOR(DATE
,0,DATE
,0,I4
,0);
3801 if (HAVE_OLEAUT32_I8
)
3803 VARXOR(DATE
,-1,I8
,-1,I8
,0);
3804 VARXOR(DATE
,-1,I8
,0,I8
,-1);
3805 VARXOR(DATE
,0,I8
,0,I8
,0);
3806 VARXOR(DATE
,-1,UI8
,0,I4
,-1);
3807 VARXOR(DATE
,0,UI8
,0,I4
,0);
3809 VARXOR(DATE
,-1,INT
,-1,I4
,0);
3810 VARXOR(DATE
,-1,INT
,0,I4
,-1);
3811 VARXOR(DATE
,0,INT
,0,I4
,0);
3812 VARXOR(DATE
,-1,UINT
,0xffffffff,I4
,0);
3813 VARXOR(DATE
,-1,UINT
,0,I4
,-1);
3814 VARXOR(DATE
,0,UINT
,0,I4
,0);
3815 rbstr
= SysAllocString(szFalse
);
3816 VARXOR(DATE
,0,BSTR
,rbstr
,I4
,0);
3817 VARXOR(DATE
,-1,BSTR
,rbstr
,I4
,-1);
3818 rbstr
= SysAllocString(szTrue
);
3819 VARXOR(DATE
,0,BSTR
,rbstr
,I4
,-1);
3820 VARXOR(DATE
,-1,BSTR
,rbstr
,I4
,0);
3821 VARXORCY(DATE
,-1,10000,I4
,-2);
3822 VARXORCY(DATE
,-1,0,I4
,-1);
3823 VARXORCY(DATE
,0,0,I4
,0);
3825 if (HAVE_OLEAUT32_I8
)
3827 VARXOR(I8
,-1,I8
,-1,I8
,0);
3828 VARXOR(I8
,-1,I8
,0,I8
,-1);
3829 VARXOR(I8
,0,I8
,0,I8
,0);
3830 VARXOR(I8
,-1,UI8
,0,I8
,-1);
3831 VARXOR(I8
,0,UI8
,0,I8
,0);
3832 VARXOR(I8
,-1,UINT
,0,I8
,-1);
3833 VARXOR(I8
,0,UINT
,0,I8
,0);
3834 rbstr
= SysAllocString(szFalse
);
3835 VARXOR(I8
,0,BSTR
,rbstr
,I8
,0);
3836 VARXOR(I8
,-1,BSTR
,rbstr
,I8
,-1);
3837 rbstr
= SysAllocString(szTrue
);
3838 VARXOR(I8
,0,BSTR
,rbstr
,I8
,-1);
3839 VARXOR(I8
,-1,BSTR
,rbstr
,I8
,0);
3840 VARXORCY(I8
,-1,10000,I8
,-2);
3841 VARXORCY(I8
,-1,0,I8
,-1);
3842 VARXORCY(I8
,0,0,I8
,0);
3844 VARXOR(UI8
,0xffff,UI8
,0xffff,I4
,0);
3845 VARXOR(UI8
,0xffff,UI8
,0,I4
,0xffff);
3846 VARXOR(UI8
,0,UI8
,0,I4
,0);
3847 VARXOR(UI8
,0xffff,INT
,-1,I4
,-65536);
3848 VARXOR(UI8
,0xffff,INT
,0,I4
,0xffff);
3849 VARXOR(UI8
,0,INT
,0,I4
,0);
3850 VARXOR(UI8
,0xffff,UINT
,0xffff,I4
,0);
3851 VARXOR(UI8
,0xffff,UINT
,0,I4
,0xffff);
3852 VARXOR(UI8
,0,UINT
,0,I4
,0);
3853 rbstr
= SysAllocString(szFalse
);
3854 VARXOR(UI8
,0,BSTR
,rbstr
,I4
,0);
3855 VARXOR(UI8
,0xffff,BSTR
,rbstr
,I4
,0xffff);
3856 rbstr
= SysAllocString(szTrue
);
3857 VARXOR(UI8
,0,BSTR
,rbstr
,I4
,-1);
3858 VARXOR(UI8
,0xffff,BSTR
,rbstr
,I4
,-65536);
3859 VARXORCY(UI8
,0xffff,10000,I4
,65534);
3860 VARXORCY(UI8
,0xffff,0,I4
,0xffff);
3861 VARXORCY(UI8
,0,0,I4
,0);
3864 VARXOR(INT
,-1,INT
,-1,I4
,0);
3865 VARXOR(INT
,-1,INT
,0,I4
,-1);
3866 VARXOR(INT
,0,INT
,0,I4
,0);
3867 VARXOR(INT
,-1,UINT
,0xffff,I4
,-65536);
3868 VARXOR(INT
,-1,UINT
,0,I4
,-1);
3869 VARXOR(INT
,0,UINT
,0,I4
,0);
3870 rbstr
= SysAllocString(szFalse
);
3871 VARXOR(INT
,0,BSTR
,rbstr
,I4
,0);
3872 VARXOR(INT
,-1,BSTR
,rbstr
,I4
,-1);
3873 rbstr
= SysAllocString(szTrue
);
3874 VARXOR(INT
,0,BSTR
,rbstr
,I4
,-1);
3875 VARXOR(INT
,-1,BSTR
,rbstr
,I4
,0);
3876 VARXORCY(INT
,-1,10000,I4
,-2);
3877 VARXORCY(INT
,-1,0,I4
,-1);
3878 VARXORCY(INT
,0,0,I4
,0);
3880 VARXOR(UINT
,0xffff,UINT
,0xffff,I4
,0);
3881 VARXOR(UINT
,0xffff,UINT
,0,I4
,0xffff);
3882 VARXOR(UINT
,0,UINT
,0,I4
,0);
3883 rbstr
= SysAllocString(szFalse
);
3884 VARXOR(UINT
,0,BSTR
,rbstr
,I4
,0);
3885 VARXOR(UINT
,0xffff,BSTR
,rbstr
,I4
,0xffff);
3886 rbstr
= SysAllocString(szTrue
);
3887 VARXOR(UINT
,0,BSTR
,rbstr
,I4
,-1);
3888 VARXOR(UINT
,0xffff,BSTR
,rbstr
,I4
,-65536);
3889 VARXORCY(UINT
,0xffff,10000,I4
,65534);
3890 VARXORCY(UINT
,0xffff,0,I4
,0xffff);
3891 VARXORCY(UINT
,0,0,I4
,0);
3893 lbstr
= SysAllocString(szFalse
);
3894 rbstr
= SysAllocString(szFalse
);
3895 VARXOR(BSTR
,lbstr
,BSTR
,rbstr
,BOOL
,0);
3896 rbstr
= SysAllocString(szTrue
);
3897 VARXOR(BSTR
,lbstr
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
3898 lbstr
= SysAllocString(szTrue
);
3899 VARXOR(BSTR
,lbstr
,BSTR
,rbstr
,BOOL
,VARIANT_FALSE
);
3900 VARXORCY(BSTR
,lbstr
,10000,I4
,-2);
3901 lbstr
= SysAllocString(szFalse
);
3902 VARXORCY(BSTR
,lbstr
,10000,I4
,1);
3905 static HRESULT (WINAPI
*pVarOr
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
3907 #define VAROR(vt1,val1,vt2,val2,rvt,rval) \
3908 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
3909 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
3910 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
3911 test_var_call2( __LINE__, pVarOr, &left, &right, &exp );
3913 #define VARORCY(vt1,val1,val2,rvt,rval) \
3914 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
3915 V_VT(&right) = VT_CY; V_CY(&right).int64 = val2; \
3916 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
3917 test_var_call2( __LINE__, pVarOr, &left, &right, &exp );
3919 static void test_VarOr(void)
3921 static const WCHAR szFalse
[] = { '#','F','A','L','S','E','#','\0' };
3922 static const WCHAR szTrue
[] = { '#','T','R','U','E','#','\0' };
3923 VARIANT left
, right
, exp
, result
;
3930 /* Test all possible flag/vt combinations & the resulting vt type */
3931 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
3933 VARTYPE leftvt
, rightvt
, resvt
;
3935 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
3940 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
3946 if (leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
||
3947 leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
||
3948 leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
)
3951 memset(&left
, 0, sizeof(left
));
3952 memset(&right
, 0, sizeof(right
));
3953 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
3954 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
3955 V_VT(&result
) = VT_EMPTY
;
3958 if (ExtraFlags
[i
] & VT_ARRAY
|| ExtraFlags
[i
] & VT_BYREF
||
3959 !IsValidVariantClearVT(leftvt
, ExtraFlags
[i
]) ||
3960 !IsValidVariantClearVT(rightvt
, ExtraFlags
[i
]) ||
3961 leftvt
== VT_CLSID
|| rightvt
== VT_CLSID
||
3962 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
||
3963 leftvt
== VT_VARIANT
|| rightvt
== VT_VARIANT
||
3964 leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
)
3968 if (leftvt
== VT_EMPTY
|| rightvt
== VT_EMPTY
)
3970 if (leftvt
== rightvt
||
3971 leftvt
== VT_I2
|| rightvt
== VT_I2
||
3972 leftvt
== VT_UI1
|| rightvt
== VT_UI1
||
3973 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
3975 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
3977 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
3980 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
3984 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
3986 if (leftvt
== rightvt
)
3988 else if (leftvt
== rightvt
||
3989 leftvt
== VT_I2
|| rightvt
== VT_I2
||
3990 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
3994 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
3997 else if (leftvt
== VT_I2
|| rightvt
== VT_I2
)
3999 if (leftvt
== rightvt
||
4000 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
4002 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
4005 else if (leftvt
== VT_BOOL
&& rightvt
== VT_BOOL
)
4009 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
4011 if (leftvt
== VT_INT
|| rightvt
== VT_INT
)
4016 hres
= pVarOr(&left
, &right
, &result
);
4018 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
4019 "VarOr: %d|0x%X, %d|0x%X: Expected failure, got 0x%X vt %d\n",
4020 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], hres
,
4023 ok(hres
== S_OK
&& V_VT(&result
) == resvt
,
4024 "VarOr: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%X vt %d\n",
4025 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], resvt
, hres
,
4031 /* Test returned values. Since we know the returned type is correct
4032 * and that we handle all combinations of invalid types, just check
4033 * that good type combinations produce the desired value.
4034 * FIXME: Test VT_DECIMAL/VT_DISPATCH
4036 VAROR(EMPTY
,0,EMPTY
,0,I2
,0);
4037 VAROR(EMPTY
,1,EMPTY
,0,I2
,0);
4038 VAROR(EMPTY
,0,NULL
,0,NULL
,0);
4039 VAROR(EMPTY
,0,I1
,0,I4
,0);
4040 VAROR(EMPTY
,0,I1
,1,I4
,1);
4041 VAROR(EMPTY
,0,UI1
,0,I2
,0);
4042 VAROR(EMPTY
,0,UI1
,1,I2
,1);
4043 VAROR(EMPTY
,0,I2
,0,I2
,0);
4044 VAROR(EMPTY
,0,I2
,1,I2
,1);
4045 VAROR(EMPTY
,0,UI2
,0,I4
,0);
4046 VAROR(EMPTY
,0,UI2
,1,I4
,1);
4047 VAROR(EMPTY
,0,I4
,0,I4
,0);
4048 VAROR(EMPTY
,0,I4
,1,I4
,1);
4049 VAROR(EMPTY
,0,UI4
,0,I4
,0);
4050 VAROR(EMPTY
,0,UI4
,1,I4
,1);
4051 if (HAVE_OLEAUT32_I8
)
4053 VAROR(EMPTY
,0,I8
,0,I8
,0);
4054 VAROR(EMPTY
,0,I8
,1,I8
,1);
4055 VAROR(EMPTY
,0,UI8
,0,I4
,0);
4056 VAROR(EMPTY
,0,UI8
,1,I4
,1);
4058 VAROR(EMPTY
,0,INT
,0,I4
,0);
4059 VAROR(EMPTY
,0,INT
,1,I4
,1);
4060 VAROR(EMPTY
,0,UINT
,0,I4
,0);
4061 VAROR(EMPTY
,0,UINT
,1,I4
,1);
4062 VAROR(EMPTY
,0,BOOL
,0,I2
,0);
4063 VAROR(EMPTY
,0,BOOL
,1,I2
,1);
4064 VAROR(EMPTY
,0,R4
,0,I4
,0);
4065 VAROR(EMPTY
,0,R4
,1,I4
,1);
4066 VAROR(EMPTY
,0,R8
,0,I4
,0);
4067 VAROR(EMPTY
,0,R8
,1,I4
,1);
4068 rbstr
= SysAllocString(szFalse
);
4069 VAROR(EMPTY
,0,BSTR
,rbstr
,I2
,0);
4070 rbstr
= SysAllocString(szTrue
);
4071 VAROR(EMPTY
,0,BSTR
,rbstr
,I2
,-1);
4072 VARORCY(EMPTY
,0,10000,I4
,1);
4074 /* NULL OR 0 = NULL. NULL OR n = n */
4075 VAROR(NULL
,0,NULL
,0,NULL
,0);
4076 VAROR(NULL
,1,NULL
,0,NULL
,0);
4077 VAROR(NULL
,0,I1
,0,NULL
,0);
4078 VAROR(NULL
,0,I1
,1,I4
,1);
4079 VAROR(NULL
,0,UI1
,0,NULL
,0);
4080 VAROR(NULL
,0,UI1
,1,UI1
,1);
4081 VAROR(NULL
,0,I2
,0,NULL
,0);
4082 VAROR(NULL
,0,I2
,1,I2
,1);
4083 VAROR(NULL
,0,UI2
,0,NULL
,0);
4084 VAROR(NULL
,0,UI2
,1,I4
,1);
4085 VAROR(NULL
,0,I4
,0,NULL
,0);
4086 VAROR(NULL
,0,I4
,1,I4
,1);
4087 VAROR(NULL
,0,UI4
,0,NULL
,0);
4088 VAROR(NULL
,0,UI4
,1,I4
,1);
4089 if (HAVE_OLEAUT32_I8
)
4091 VAROR(NULL
,0,I8
,0,NULL
,0);
4092 VAROR(NULL
,0,I8
,1,I8
,1);
4093 VAROR(NULL
,0,UI8
,0,NULL
,0);
4094 VAROR(NULL
,0,UI8
,1,I4
,1);
4096 VAROR(NULL
,0,INT
,0,NULL
,0);
4097 VAROR(NULL
,0,INT
,1,I4
,1);
4098 VAROR(NULL
,0,UINT
,0,NULL
,0);
4099 VAROR(NULL
,0,UINT
,1,I4
,1);
4100 VAROR(NULL
,0,BOOL
,0,NULL
,0);
4101 VAROR(NULL
,0,BOOL
,1,BOOL
,1);
4102 VAROR(NULL
,0,R4
,0,NULL
,0);
4103 VAROR(NULL
,0,R4
,1,I4
,1);
4104 VAROR(NULL
,0,R8
,0,NULL
,0);
4105 VAROR(NULL
,0,R8
,1,I4
,1);
4106 rbstr
= SysAllocString(szFalse
);
4107 VAROR(NULL
,0,BSTR
,rbstr
,NULL
,0);
4108 rbstr
= SysAllocString(szTrue
);
4109 VAROR(NULL
,0,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
4110 VARORCY(NULL
,0,10000,I4
,1);
4111 VARORCY(NULL
,0,0,NULL
,0);
4113 VAROR(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
);
4114 VAROR(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
);
4115 VAROR(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
);
4116 VAROR(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_FALSE
);
4117 /* Assume x,y & y,x are the same from now on to reduce the number of tests */
4118 VAROR(BOOL
,VARIANT_TRUE
,I1
,-1,I4
,-1);
4119 VAROR(BOOL
,VARIANT_TRUE
,I1
,0,I4
,-1);
4120 VAROR(BOOL
,VARIANT_FALSE
,I1
,0,I4
,0);
4121 VAROR(BOOL
,VARIANT_TRUE
,UI1
,255,I2
,-1);
4122 VAROR(BOOL
,VARIANT_TRUE
,UI1
,0,I2
,-1);
4123 VAROR(BOOL
,VARIANT_FALSE
,UI1
,0,I2
,0);
4124 VAROR(BOOL
,VARIANT_TRUE
,I2
,-1,I2
,-1);
4125 VAROR(BOOL
,VARIANT_TRUE
,I2
,0,I2
,-1);
4126 VAROR(BOOL
,VARIANT_FALSE
,I2
,0,I2
,0);
4127 VAROR(BOOL
,VARIANT_TRUE
,UI2
,65535,I4
,-1);
4128 VAROR(BOOL
,VARIANT_TRUE
,UI2
,0,I4
,-1);
4129 VAROR(BOOL
,VARIANT_FALSE
,UI2
,0,I4
,0);
4130 VAROR(BOOL
,VARIANT_TRUE
,I4
,-1,I4
,-1);
4131 VAROR(BOOL
,VARIANT_TRUE
,I4
,0,I4
,-1);
4132 VAROR(BOOL
,VARIANT_FALSE
,I4
,0,I4
,0);
4133 VAROR(BOOL
,VARIANT_TRUE
,UI4
,0xffffffff,I4
,-1);
4134 VAROR(BOOL
,VARIANT_TRUE
,UI4
,0,I4
,-1);
4135 VAROR(BOOL
,VARIANT_FALSE
,UI4
,0,I4
,0);
4136 VAROR(BOOL
,VARIANT_TRUE
,R4
,-1,I4
,-1);
4137 VAROR(BOOL
,VARIANT_TRUE
,R4
,0,I4
,-1);
4138 VAROR(BOOL
,VARIANT_FALSE
,R4
,0,I4
,0);
4139 VAROR(BOOL
,VARIANT_TRUE
,R8
,-1,I4
,-1);
4140 VAROR(BOOL
,VARIANT_TRUE
,R8
,0,I4
,-1);
4141 VAROR(BOOL
,VARIANT_FALSE
,R8
,0,I4
,0);
4142 VAROR(BOOL
,VARIANT_TRUE
,DATE
,-1,I4
,-1);
4143 VAROR(BOOL
,VARIANT_TRUE
,DATE
,0,I4
,-1);
4144 VAROR(BOOL
,VARIANT_FALSE
,DATE
,0,I4
,0);
4145 if (HAVE_OLEAUT32_I8
)
4147 VAROR(BOOL
,VARIANT_TRUE
,I8
,-1,I8
,-1);
4148 VAROR(BOOL
,VARIANT_TRUE
,I8
,0,I8
,-1);
4149 VAROR(BOOL
,VARIANT_FALSE
,I8
,0,I8
,0);
4150 /* This returns DISP_E_OVERFLOW which indicates that a conversion
4151 * to I4 is performed.
4153 /* VAROR(BOOL,VARIANT_TRUE,UI8,-1,I4,-1); */
4154 VAROR(BOOL
,VARIANT_TRUE
,UI8
,0,I4
,-1);
4155 VAROR(BOOL
,VARIANT_FALSE
,UI8
,0,I4
,0);
4157 VAROR(BOOL
,VARIANT_TRUE
,INT
,-1,I4
,-1);
4158 VAROR(BOOL
,VARIANT_TRUE
,INT
,0,I4
,-1);
4159 VAROR(BOOL
,VARIANT_FALSE
,INT
,0,I4
,0);
4160 VAROR(BOOL
,VARIANT_TRUE
,UINT
,0xffffffff,I4
,-1);
4161 VAROR(BOOL
,VARIANT_TRUE
,UINT
,0,I4
,-1);
4162 VAROR(BOOL
,VARIANT_FALSE
,UINT
,0,I4
,0);
4163 rbstr
= SysAllocString(szFalse
);
4164 VAROR(BOOL
,VARIANT_FALSE
,BSTR
,rbstr
,BOOL
,VARIANT_FALSE
);
4165 VAROR(BOOL
,VARIANT_TRUE
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
4166 rbstr
= SysAllocString(szTrue
);
4167 VAROR(BOOL
,VARIANT_FALSE
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
4168 VAROR(BOOL
,VARIANT_TRUE
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
4169 VARORCY(BOOL
,VARIANT_TRUE
,10000,I4
,-1);
4170 VARORCY(BOOL
,VARIANT_TRUE
,0,I4
,-1);
4171 VARORCY(BOOL
,VARIANT_FALSE
,0,I4
,0);
4173 VAROR(I1
,-1,I1
,-1,I4
,-1);
4174 VAROR(I1
,-1,I1
,0,I4
,-1);
4175 VAROR(I1
,0,I1
,0,I4
,0);
4176 VAROR(I1
,-1,UI1
,255,I4
,-1);
4177 VAROR(I1
,-1,UI1
,0,I4
,-1);
4178 VAROR(I1
,0,UI1
,0,I4
,0);
4179 VAROR(I1
,-1,I2
,-1,I4
,-1);
4180 VAROR(I1
,-1,I2
,0,I4
,-1);
4181 VAROR(I1
,0,I2
,0,I4
,0);
4182 VAROR(I1
,-1,UI2
,65535,I4
,-1);
4183 VAROR(I1
,-1,UI2
,0,I4
,-1);
4184 VAROR(I1
,0,UI2
,0,I4
,0);
4185 VAROR(I1
,-1,I4
,-1,I4
,-1);
4186 VAROR(I1
,-1,I4
,0,I4
,-1);
4187 VAROR(I1
,0,I4
,0,I4
,0);
4188 VAROR(I1
,-1,UI4
,0xffffffff,I4
,-1);
4189 VAROR(I1
,-1,UI4
,0,I4
,-1);
4190 VAROR(I1
,0,UI4
,0,I4
,0);
4191 VAROR(I1
,-1,R4
,-1,I4
,-1);
4192 VAROR(I1
,-1,R4
,0,I4
,-1);
4193 VAROR(I1
,0,R4
,0,I4
,0);
4194 VAROR(I1
,-1,R8
,-1,I4
,-1);
4195 VAROR(I1
,-1,R8
,0,I4
,-1);
4196 VAROR(I1
,0,R8
,0,I4
,0);
4197 VAROR(I1
,-1,DATE
,-1,I4
,-1);
4198 VAROR(I1
,-1,DATE
,0,I4
,-1);
4199 VAROR(I1
,0,DATE
,0,I4
,0);
4200 if (HAVE_OLEAUT32_I8
)
4202 VAROR(I1
,-1,I8
,-1,I8
,-1);
4203 VAROR(I1
,-1,I8
,0,I8
,-1);
4204 VAROR(I1
,0,I8
,0,I8
,0);
4205 VAROR(I1
,-1,UI8
,0,I4
,-1);
4206 VAROR(I1
,0,UI8
,0,I4
,0);
4208 VAROR(I1
,-1,INT
,-1,I4
,-1);
4209 VAROR(I1
,-1,INT
,0,I4
,-1);
4210 VAROR(I1
,0,INT
,0,I4
,0);
4211 VAROR(I1
,-1,UINT
,0xffffffff,I4
,-1);
4212 VAROR(I1
,-1,UINT
,0,I4
,-1);
4213 VAROR(I1
,0,UINT
,0,I4
,0);
4214 rbstr
= SysAllocString(szFalse
);
4215 VAROR(I1
,0,BSTR
,rbstr
,I4
,0);
4216 VAROR(I1
,-1,BSTR
,rbstr
,I4
,-1);
4217 rbstr
= SysAllocString(szTrue
);
4218 VAROR(I1
,0,BSTR
,rbstr
,I4
,-1);
4219 VAROR(I1
,-1,BSTR
,rbstr
,I4
,-1);
4220 VARORCY(I1
,-1,10000,I4
,-1);
4221 VARORCY(I1
,-1,0,I4
,-1);
4222 VARORCY(I1
,0,0,I4
,0);
4224 VAROR(UI1
,255,UI1
,255,UI1
,255);
4225 VAROR(UI1
,255,UI1
,0,UI1
,255);
4226 VAROR(UI1
,0,UI1
,0,UI1
,0);
4227 VAROR(UI1
,255,I2
,-1,I2
,-1);
4228 VAROR(UI1
,255,I2
,0,I2
,255);
4229 VAROR(UI1
,0,I2
,0,I2
,0);
4230 VAROR(UI1
,255,UI2
,65535,I4
,65535);
4231 VAROR(UI1
,255,UI2
,0,I4
,255);
4232 VAROR(UI1
,0,UI2
,0,I4
,0);
4233 VAROR(UI1
,255,I4
,-1,I4
,-1);
4234 VAROR(UI1
,255,I4
,0,I4
,255);
4235 VAROR(UI1
,0,I4
,0,I4
,0);
4236 VAROR(UI1
,255,UI4
,0xffffffff,I4
,-1);
4237 VAROR(UI1
,255,UI4
,0,I4
,255);
4238 VAROR(UI1
,0,UI4
,0,I4
,0);
4239 VAROR(UI1
,255,R4
,-1,I4
,-1);
4240 VAROR(UI1
,255,R4
,0,I4
,255);
4241 VAROR(UI1
,0,R4
,0,I4
,0);
4242 VAROR(UI1
,255,R8
,-1,I4
,-1);
4243 VAROR(UI1
,255,R8
,0,I4
,255);
4244 VAROR(UI1
,0,R8
,0,I4
,0);
4245 VAROR(UI1
,255,DATE
,-1,I4
,-1);
4246 VAROR(UI1
,255,DATE
,0,I4
,255);
4247 VAROR(UI1
,0,DATE
,0,I4
,0);
4248 if (HAVE_OLEAUT32_I8
)
4250 VAROR(UI1
,255,I8
,-1,I8
,-1);
4251 VAROR(UI1
,255,I8
,0,I8
,255);
4252 VAROR(UI1
,0,I8
,0,I8
,0);
4253 VAROR(UI1
,255,UI8
,0,I4
,255);
4254 VAROR(UI1
,0,UI8
,0,I4
,0);
4256 VAROR(UI1
,255,INT
,-1,I4
,-1);
4257 VAROR(UI1
,255,INT
,0,I4
,255);
4258 VAROR(UI1
,0,INT
,0,I4
,0);
4259 VAROR(UI1
,255,UINT
,0xffffffff,I4
,-1);
4260 VAROR(UI1
,255,UINT
,0,I4
,255);
4261 VAROR(UI1
,0,UINT
,0,I4
,0);
4262 rbstr
= SysAllocString(szFalse
);
4263 VAROR(UI1
,0,BSTR
,rbstr
,I2
,0);
4264 VAROR(UI1
,255,BSTR
,rbstr
,I2
,255);
4265 rbstr
= SysAllocString(szTrue
);
4266 VAROR(UI1
,0,BSTR
,rbstr
,I2
,-1);
4267 VAROR(UI1
,255,BSTR
,rbstr
,I2
,-1);
4268 VARORCY(UI1
,255,10000,I4
,255);
4269 VARORCY(UI1
,255,0,I4
,255);
4270 VARORCY(UI1
,0,0,I4
,0);
4272 VAROR(I2
,-1,I2
,-1,I2
,-1);
4273 VAROR(I2
,-1,I2
,0,I2
,-1);
4274 VAROR(I2
,0,I2
,0,I2
,0);
4275 VAROR(I2
,-1,UI2
,65535,I4
,-1);
4276 VAROR(I2
,-1,UI2
,0,I4
,-1);
4277 VAROR(I2
,0,UI2
,0,I4
,0);
4278 VAROR(I2
,-1,I4
,-1,I4
,-1);
4279 VAROR(I2
,-1,I4
,0,I4
,-1);
4280 VAROR(I2
,0,I4
,0,I4
,0);
4281 VAROR(I2
,-1,UI4
,0xffffffff,I4
,-1);
4282 VAROR(I2
,-1,UI4
,0,I4
,-1);
4283 VAROR(I2
,0,UI4
,0,I4
,0);
4284 VAROR(I2
,-1,R4
,-1,I4
,-1);
4285 VAROR(I2
,-1,R4
,0,I4
,-1);
4286 VAROR(I2
,0,R4
,0,I4
,0);
4287 VAROR(I2
,-1,R8
,-1,I4
,-1);
4288 VAROR(I2
,-1,R8
,0,I4
,-1);
4289 VAROR(I2
,0,R8
,0,I4
,0);
4290 VAROR(I2
,-1,DATE
,-1,I4
,-1);
4291 VAROR(I2
,-1,DATE
,0,I4
,-1);
4292 VAROR(I2
,0,DATE
,0,I4
,0);
4293 if (HAVE_OLEAUT32_I8
)
4295 VAROR(I2
,-1,I8
,-1,I8
,-1);
4296 VAROR(I2
,-1,I8
,0,I8
,-1);
4297 VAROR(I2
,0,I8
,0,I8
,0);
4298 VAROR(I2
,-1,UI8
,0,I4
,-1);
4299 VAROR(I2
,0,UI8
,0,I4
,0);
4301 VAROR(I2
,-1,INT
,-1,I4
,-1);
4302 VAROR(I2
,-1,INT
,0,I4
,-1);
4303 VAROR(I2
,0,INT
,0,I4
,0);
4304 VAROR(I2
,-1,UINT
,0xffffffff,I4
,-1);
4305 VAROR(I2
,-1,UINT
,0,I4
,-1);
4306 VAROR(I2
,0,UINT
,0,I4
,0);
4307 rbstr
= SysAllocString(szFalse
);
4308 VAROR(I2
,0,BSTR
,rbstr
,I2
,0);
4309 VAROR(I2
,-1,BSTR
,rbstr
,I2
,-1);
4310 rbstr
= SysAllocString(szTrue
);
4311 VAROR(I2
,0,BSTR
,rbstr
,I2
,-1);
4312 VAROR(I2
,-1,BSTR
,rbstr
,I2
,-1);
4313 VARORCY(I2
,-1,10000,I4
,-1);
4314 VARORCY(I2
,-1,0,I4
,-1);
4315 VARORCY(I2
,0,0,I4
,0);
4317 VAROR(UI2
,65535,UI2
,65535,I4
,65535);
4318 VAROR(UI2
,65535,UI2
,0,I4
,65535);
4319 VAROR(UI2
,0,UI2
,0,I4
,0);
4320 VAROR(UI2
,65535,I4
,-1,I4
,-1);
4321 VAROR(UI2
,65535,I4
,0,I4
,65535);
4322 VAROR(UI2
,0,I4
,0,I4
,0);
4323 VAROR(UI2
,65535,UI4
,0xffffffff,I4
,-1);
4324 VAROR(UI2
,65535,UI4
,0,I4
,65535);
4325 VAROR(UI2
,0,UI4
,0,I4
,0);
4326 VAROR(UI2
,65535,R4
,-1,I4
,-1);
4327 VAROR(UI2
,65535,R4
,0,I4
,65535);
4328 VAROR(UI2
,0,R4
,0,I4
,0);
4329 VAROR(UI2
,65535,R8
,-1,I4
,-1);
4330 VAROR(UI2
,65535,R8
,0,I4
,65535);
4331 VAROR(UI2
,0,R8
,0,I4
,0);
4332 VAROR(UI2
,65535,DATE
,-1,I4
,-1);
4333 VAROR(UI2
,65535,DATE
,0,I4
,65535);
4334 VAROR(UI2
,0,DATE
,0,I4
,0);
4335 if (HAVE_OLEAUT32_I8
)
4337 VAROR(UI2
,65535,I8
,-1,I8
,-1);
4338 VAROR(UI2
,65535,I8
,0,I8
,65535);
4339 VAROR(UI2
,0,I8
,0,I8
,0);
4340 VAROR(UI2
,65535,UI8
,0,I4
,65535);
4341 VAROR(UI2
,0,UI8
,0,I4
,0);
4343 VAROR(UI2
,65535,INT
,-1,I4
,-1);
4344 VAROR(UI2
,65535,INT
,0,I4
,65535);
4345 VAROR(UI2
,0,INT
,0,I4
,0);
4346 VAROR(UI2
,65535,UINT
,0xffffffff,I4
,-1);
4347 VAROR(UI2
,65535,UINT
,0,I4
,65535);
4348 VAROR(UI2
,0,UINT
,0,I4
,0);
4349 rbstr
= SysAllocString(szFalse
);
4350 VAROR(UI2
,0,BSTR
,rbstr
,I4
,0);
4351 VAROR(UI2
,65535,BSTR
,rbstr
,I4
,65535);
4352 rbstr
= SysAllocString(szTrue
);
4353 VAROR(UI2
,0,BSTR
,rbstr
,I4
,-1);
4354 VAROR(UI2
,65535,BSTR
,rbstr
,I4
,-1);
4355 VARORCY(UI2
,65535,10000,I4
,65535);
4356 VARORCY(UI2
,65535,0,I4
,65535);
4357 VARORCY(UI2
,0,0,I4
,0);
4359 VAROR(I4
,-1,I4
,-1,I4
,-1);
4360 VAROR(I4
,-1,I4
,0,I4
,-1);
4361 VAROR(I4
,0,I4
,0,I4
,0);
4362 VAROR(I4
,-1,UI4
,0xffffffff,I4
,-1);
4363 VAROR(I4
,-1,UI4
,0,I4
,-1);
4364 VAROR(I4
,0,UI4
,0,I4
,0);
4365 VAROR(I4
,-1,R4
,-1,I4
,-1);
4366 VAROR(I4
,-1,R4
,0,I4
,-1);
4367 VAROR(I4
,0,R4
,0,I4
,0);
4368 VAROR(I4
,-1,R8
,-1,I4
,-1);
4369 VAROR(I4
,-1,R8
,0,I4
,-1);
4370 VAROR(I4
,0,R8
,0,I4
,0);
4371 VAROR(I4
,-1,DATE
,-1,I4
,-1);
4372 VAROR(I4
,-1,DATE
,0,I4
,-1);
4373 VAROR(I4
,0,DATE
,0,I4
,0);
4374 if (HAVE_OLEAUT32_I8
)
4376 VAROR(I4
,-1,I8
,-1,I8
,-1);
4377 VAROR(I4
,-1,I8
,0,I8
,-1);
4378 VAROR(I4
,0,I8
,0,I8
,0);
4379 VAROR(I4
,-1,UI8
,0,I4
,-1);
4380 VAROR(I4
,0,UI8
,0,I4
,0);
4382 VAROR(I4
,-1,INT
,-1,I4
,-1);
4383 VAROR(I4
,-1,INT
,0,I4
,-1);
4384 VAROR(I4
,0,INT
,0,I4
,0);
4385 VAROR(I4
,-1,UINT
,0xffffffff,I4
,-1);
4386 VAROR(I4
,-1,UINT
,0,I4
,-1);
4387 VAROR(I4
,0,UINT
,0,I4
,0);
4388 rbstr
= SysAllocString(szFalse
);
4389 VAROR(I4
,0,BSTR
,rbstr
,I4
,0);
4390 VAROR(I4
,-1,BSTR
,rbstr
,I4
,-1);
4391 rbstr
= SysAllocString(szTrue
);
4392 VAROR(I4
,0,BSTR
,rbstr
,I4
,-1);
4393 VAROR(I4
,-1,BSTR
,rbstr
,I4
,-1);
4394 VARORCY(I4
,-1,10000,I4
,-1);
4395 VARORCY(I4
,-1,0,I4
,-1);
4396 VARORCY(I4
,0,0,I4
,0);
4398 VAROR(UI4
,0xffffffff,UI4
,0xffffffff,I4
,-1);
4399 VAROR(UI4
,0xffffffff,UI4
,0,I4
,-1);
4400 VAROR(UI4
,0,UI4
,0,I4
,0);
4401 VAROR(UI4
,0xffffffff,R4
,-1,I4
,-1);
4402 VAROR(UI4
,0xffffffff,R4
,0,I4
,-1);
4403 VAROR(UI4
,0,R4
,0,I4
,0);
4404 VAROR(UI4
,0xffffffff,R8
,-1,I4
,-1);
4405 VAROR(UI4
,0xffffffff,R8
,0,I4
,-1);
4406 VAROR(UI4
,0,R8
,0,I4
,0);
4407 VAROR(UI4
,0xffffffff,DATE
,-1,I4
,-1);
4408 VAROR(UI4
,0xffffffff,DATE
,0,I4
,-1);
4409 VAROR(UI4
,0,DATE
,0,I4
,0);
4410 if (HAVE_OLEAUT32_I8
)
4412 VAROR(UI4
,0xffffffff,I8
,-1,I8
,-1);
4413 VAROR(UI4
,0xffffffff,I8
,0,I8
,0xffffffff);
4414 VAROR(UI4
,0,I8
,0,I8
,0);
4415 VAROR(UI4
,0xffffffff,UI8
,0,I4
,-1);
4416 VAROR(UI4
,0,UI8
,0,I4
,0);
4418 VAROR(UI4
,0xffffffff,INT
,-1,I4
,-1);
4419 VAROR(UI4
,0xffffffff,INT
,0,I4
,-1);
4420 VAROR(UI4
,0,INT
,0,I4
,0);
4421 VAROR(UI4
,0xffffffff,UINT
,0xffffffff,I4
,-1);
4422 VAROR(UI4
,0xffffffff,UINT
,0,I4
,-1);
4423 VAROR(UI4
,0,UINT
,0,I4
,0);
4424 rbstr
= SysAllocString(szFalse
);
4425 VAROR(UI4
,0,BSTR
,rbstr
,I4
,0);
4426 VAROR(UI4
,0xffffffff,BSTR
,rbstr
,I4
,-1);
4427 rbstr
= SysAllocString(szTrue
);
4428 VAROR(UI4
,0,BSTR
,rbstr
,I4
,-1);
4429 VAROR(UI4
,0xffffffff,BSTR
,rbstr
,I4
,-1);
4430 VARORCY(UI4
,0xffffffff,10000,I4
,-1);
4431 VARORCY(UI4
,0xffffffff,0,I4
,-1);
4432 VARORCY(UI4
,0,0,I4
,0);
4434 VAROR(R4
,-1,R4
,-1,I4
,-1);
4435 VAROR(R4
,-1,R4
,0,I4
,-1);
4436 VAROR(R4
,0,R4
,0,I4
,0);
4437 VAROR(R4
,-1,R8
,-1,I4
,-1);
4438 VAROR(R4
,-1,R8
,0,I4
,-1);
4439 VAROR(R4
,0,R8
,0,I4
,0);
4440 VAROR(R4
,-1,DATE
,-1,I4
,-1);
4441 VAROR(R4
,-1,DATE
,0,I4
,-1);
4442 VAROR(R4
,0,DATE
,0,I4
,0);
4443 if (HAVE_OLEAUT32_I8
)
4445 VAROR(R4
,-1,I8
,-1,I8
,-1);
4446 VAROR(R4
,-1,I8
,0,I8
,-1);
4447 VAROR(R4
,0,I8
,0,I8
,0);
4448 VAROR(R4
,-1,UI8
,0,I4
,-1);
4449 VAROR(R4
,0,UI8
,0,I4
,0);
4451 VAROR(R4
,-1,INT
,-1,I4
,-1);
4452 VAROR(R4
,-1,INT
,0,I4
,-1);
4453 VAROR(R4
,0,INT
,0,I4
,0);
4454 VAROR(R4
,-1,UINT
,0xffffffff,I4
,-1);
4455 VAROR(R4
,-1,UINT
,0,I4
,-1);
4456 VAROR(R4
,0,UINT
,0,I4
,0);
4457 rbstr
= SysAllocString(szFalse
);
4458 VAROR(R4
,0,BSTR
,rbstr
,I4
,0);
4459 VAROR(R4
,-1,BSTR
,rbstr
,I4
,-1);
4460 rbstr
= SysAllocString(szTrue
);
4461 VAROR(R4
,0,BSTR
,rbstr
,I4
,-1);
4462 VAROR(R4
,-1,BSTR
,rbstr
,I4
,-1);
4463 VARORCY(R4
,-1,10000,I4
,-1);
4464 VARORCY(R4
,-1,0,I4
,-1);
4465 VARORCY(R4
,0,0,I4
,0);
4467 VAROR(R8
,-1,R8
,-1,I4
,-1);
4468 VAROR(R8
,-1,R8
,0,I4
,-1);
4469 VAROR(R8
,0,R8
,0,I4
,0);
4470 VAROR(R8
,-1,DATE
,-1,I4
,-1);
4471 VAROR(R8
,-1,DATE
,0,I4
,-1);
4472 VAROR(R8
,0,DATE
,0,I4
,0);
4473 if (HAVE_OLEAUT32_I8
)
4475 VAROR(R8
,-1,I8
,-1,I8
,-1);
4476 VAROR(R8
,-1,I8
,0,I8
,-1);
4477 VAROR(R8
,0,I8
,0,I8
,0);
4478 VAROR(R8
,-1,UI8
,0,I4
,-1);
4479 VAROR(R8
,0,UI8
,0,I4
,0);
4481 VAROR(R8
,-1,INT
,-1,I4
,-1);
4482 VAROR(R8
,-1,INT
,0,I4
,-1);
4483 VAROR(R8
,0,INT
,0,I4
,0);
4484 VAROR(R8
,-1,UINT
,0xffffffff,I4
,-1);
4485 VAROR(R8
,-1,UINT
,0,I4
,-1);
4486 VAROR(R8
,0,UINT
,0,I4
,0);
4487 rbstr
= SysAllocString(szFalse
);
4488 VAROR(R8
,0,BSTR
,rbstr
,I4
,0);
4489 VAROR(R8
,-1,BSTR
,rbstr
,I4
,-1);
4490 rbstr
= SysAllocString(szTrue
);
4491 VAROR(R8
,0,BSTR
,rbstr
,I4
,-1);
4492 VAROR(R8
,-1,BSTR
,rbstr
,I4
,-1);
4493 VARORCY(R8
,-1,10000,I4
,-1);
4494 VARORCY(R8
,-1,0,I4
,-1);
4495 VARORCY(R8
,0,0,I4
,0);
4497 VAROR(DATE
,-1,DATE
,-1,I4
,-1);
4498 VAROR(DATE
,-1,DATE
,0,I4
,-1);
4499 VAROR(DATE
,0,DATE
,0,I4
,0);
4500 if (HAVE_OLEAUT32_I8
)
4502 VAROR(DATE
,-1,I8
,-1,I8
,-1);
4503 VAROR(DATE
,-1,I8
,0,I8
,-1);
4504 VAROR(DATE
,0,I8
,0,I8
,0);
4505 VAROR(DATE
,-1,UI8
,0,I4
,-1);
4506 VAROR(DATE
,0,UI8
,0,I4
,0);
4508 VAROR(DATE
,-1,INT
,-1,I4
,-1);
4509 VAROR(DATE
,-1,INT
,0,I4
,-1);
4510 VAROR(DATE
,0,INT
,0,I4
,0);
4511 VAROR(DATE
,-1,UINT
,0xffffffff,I4
,-1);
4512 VAROR(DATE
,-1,UINT
,0,I4
,-1);
4513 VAROR(DATE
,0,UINT
,0,I4
,0);
4514 rbstr
= SysAllocString(szFalse
);
4515 VAROR(DATE
,0,BSTR
,rbstr
,I4
,0);
4516 VAROR(DATE
,-1,BSTR
,rbstr
,I4
,-1);
4517 rbstr
= SysAllocString(szTrue
);
4518 VAROR(DATE
,0,BSTR
,rbstr
,I4
,-1);
4519 VAROR(DATE
,-1,BSTR
,rbstr
,I4
,-1);
4520 VARORCY(DATE
,-1,10000,I4
,-1);
4521 VARORCY(DATE
,-1,0,I4
,-1);
4522 VARORCY(DATE
,0,0,I4
,0);
4524 if (HAVE_OLEAUT32_I8
)
4526 VAROR(I8
,-1,I8
,-1,I8
,-1);
4527 VAROR(I8
,-1,I8
,0,I8
,-1);
4528 VAROR(I8
,0,I8
,0,I8
,0);
4529 VAROR(I8
,-1,UI8
,0,I8
,-1);
4530 VAROR(I8
,0,UI8
,0,I8
,0);
4531 /* These overflow under native and Wine
4532 VAROR(I8,-1,INT,-1,I4,-1);
4533 VAROR(I8,-1,INT,0,I4,-1);
4534 VAROR(I8,0,INT,0,I4,0); */
4535 VAROR(I8
,-1,UINT
,0xffffffff,I8
,-1);
4536 VAROR(I8
,-1,UINT
,0,I8
,-1);
4537 VAROR(I8
,0,UINT
,0,I8
,0);
4538 rbstr
= SysAllocString(szFalse
);
4539 VAROR(I8
,0,BSTR
,rbstr
,I8
,0);
4540 VAROR(I8
,-1,BSTR
,rbstr
,I8
,-1);
4541 rbstr
= SysAllocString(szTrue
);
4542 VAROR(I8
,0,BSTR
,rbstr
,I8
,-1);
4543 VAROR(I8
,-1,BSTR
,rbstr
,I8
,-1);
4544 VARORCY(I8
,-1,10000,I8
,-1);
4545 VARORCY(I8
,-1,0,I8
,-1);
4546 VARORCY(I8
,0,0,I8
,0);
4548 VAROR(UI8
,0xffff,UI8
,0xffff,I4
,0xffff);
4549 VAROR(UI8
,0xffff,UI8
,0,I4
,0xffff);
4550 VAROR(UI8
,0,UI8
,0,I4
,0);
4551 VAROR(UI8
,0xffff,INT
,-1,I4
,-1);
4552 VAROR(UI8
,0xffff,INT
,0,I4
,0xffff);
4553 VAROR(UI8
,0,INT
,0,I4
,0);
4554 VAROR(UI8
,0xffff,UINT
,0xffff,I4
,0xffff);
4555 VAROR(UI8
,0xffff,UINT
,0,I4
,0xffff);
4556 VAROR(UI8
,0,UINT
,0,I4
,0);
4557 rbstr
= SysAllocString(szFalse
);
4558 VAROR(UI8
,0,BSTR
,rbstr
,I4
,0);
4559 VAROR(UI8
,0xffff,BSTR
,rbstr
,I4
,0xffff);
4560 rbstr
= SysAllocString(szTrue
);
4561 VAROR(UI8
,0,BSTR
,rbstr
,I4
,-1);
4562 VAROR(UI8
,0xffff,BSTR
,rbstr
,I4
,-1);
4563 VARORCY(UI8
,0xffff,10000,I4
,0xffff);
4564 VARORCY(UI8
,0xffff,0,I4
,0xffff);
4565 VARORCY(UI8
,0,0,I4
,0);
4568 VAROR(INT
,-1,INT
,-1,I4
,-1);
4569 VAROR(INT
,-1,INT
,0,I4
,-1);
4570 VAROR(INT
,0,INT
,0,I4
,0);
4571 VAROR(INT
,-1,UINT
,0xffff,I4
,-1);
4572 VAROR(INT
,-1,UINT
,0,I4
,-1);
4573 VAROR(INT
,0,UINT
,0,I4
,0);
4574 rbstr
= SysAllocString(szFalse
);
4575 VAROR(INT
,0,BSTR
,rbstr
,I4
,0);
4576 VAROR(INT
,-1,BSTR
,rbstr
,I4
,-1);
4577 rbstr
= SysAllocString(szTrue
);
4578 VAROR(INT
,0,BSTR
,rbstr
,I4
,-1);
4579 VAROR(INT
,-1,BSTR
,rbstr
,I4
,-1);
4580 VARORCY(INT
,-1,10000,I4
,-1);
4581 VARORCY(INT
,-1,0,I4
,-1);
4582 VARORCY(INT
,0,0,I4
,0);
4584 VAROR(UINT
,0xffff,UINT
,0xffff,I4
,0xffff);
4585 VAROR(UINT
,0xffff,UINT
,0,I4
,0xffff);
4586 VAROR(UINT
,0,UINT
,0,I4
,0);
4587 rbstr
= SysAllocString(szFalse
);
4588 VAROR(UINT
,0,BSTR
,rbstr
,I4
,0);
4589 VAROR(UINT
,0xffff,BSTR
,rbstr
,I4
,0xffff);
4590 rbstr
= SysAllocString(szTrue
);
4591 VAROR(UINT
,0,BSTR
,rbstr
,I4
,-1);
4592 VAROR(UINT
,0xffff,BSTR
,rbstr
,I4
,-1);
4593 VARORCY(UINT
,0xffff,10000,I4
,0xffff);
4594 VARORCY(UINT
,0xffff,0,I4
,0xffff);
4595 VARORCY(UINT
,0,0,I4
,0);
4597 lbstr
= SysAllocString(szFalse
);
4598 rbstr
= SysAllocString(szFalse
);
4599 VAROR(BSTR
,lbstr
,BSTR
,rbstr
,BOOL
,0);
4600 rbstr
= SysAllocString(szTrue
);
4601 VAROR(BSTR
,lbstr
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
4602 lbstr
= SysAllocString(szTrue
);
4603 VAROR(BSTR
,lbstr
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
4604 VARORCY(BSTR
,lbstr
,10000,I4
,-1);
4605 lbstr
= SysAllocString(szFalse
);
4606 VARORCY(BSTR
,lbstr
,10000,I4
,1);
4609 static HRESULT (WINAPI
*pVarEqv
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
4611 #define VAREQV(vt1,val1,vt2,val2,rvt,rval) \
4612 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
4613 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
4614 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
4615 test_var_call2( __LINE__, pVarEqv, &left, &right, &exp );
4617 static void test_VarEqv(void)
4619 VARIANT left
, right
, exp
, result
;
4625 /* Test all possible flag/vt combinations & the resulting vt type */
4626 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
4628 VARTYPE leftvt
, rightvt
, resvt
;
4630 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
4634 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
4640 if (leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
||
4641 leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
||
4642 leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
)
4645 memset(&left
, 0, sizeof(left
));
4646 memset(&right
, 0, sizeof(right
));
4647 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
4648 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
4649 V_VT(&result
) = VT_EMPTY
;
4652 if (ExtraFlags
[i
] & VT_ARRAY
|| ExtraFlags
[i
] & VT_BYREF
||
4653 !IsValidVariantClearVT(leftvt
, ExtraFlags
[i
]) ||
4654 !IsValidVariantClearVT(rightvt
, ExtraFlags
[i
]) ||
4655 leftvt
== VT_CLSID
|| rightvt
== VT_CLSID
||
4656 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
||
4657 leftvt
== VT_VARIANT
|| rightvt
== VT_VARIANT
||
4658 leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
)
4662 if (leftvt
== VT_EMPTY
|| rightvt
== VT_EMPTY
)
4664 if (leftvt
== rightvt
||
4665 leftvt
== VT_I2
|| rightvt
== VT_I2
||
4666 leftvt
== VT_UI1
|| rightvt
== VT_UI1
||
4667 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
4669 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
4671 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
4674 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
4678 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
4680 if (leftvt
== rightvt
)
4682 else if (leftvt
== rightvt
||
4683 leftvt
== VT_I2
|| rightvt
== VT_I2
||
4684 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
4688 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
4691 else if (leftvt
== VT_I2
|| rightvt
== VT_I2
)
4693 if (leftvt
== rightvt
||
4694 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
4696 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
4699 else if (leftvt
== VT_BOOL
&& rightvt
== VT_BOOL
)
4703 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
4705 if (leftvt
== VT_INT
|| rightvt
== VT_INT
)
4710 hres
= pVarEqv(&left
, &right
, &result
);
4712 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
4713 "VarEqv: %d|0x%X, %d|0x%X: Expected failure, got 0x%X vt %d\n",
4714 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], hres
,
4717 ok(hres
== S_OK
&& V_VT(&result
) == resvt
,
4718 "VarEqv: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%X vt %d\n",
4719 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], resvt
, hres
,
4725 /* Test returned values */
4726 VAREQV(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
);
4727 VAREQV(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
);
4728 VAREQV(BOOL
,TRUE
,BOOL
,TRUE
,BOOL
,VARIANT_TRUE
);
4729 VAREQV(BOOL
,FALSE
,BOOL
,FALSE
,BOOL
,VARIANT_TRUE
);
4730 VAREQV(BOOL
,TRUE
,BOOL
,FALSE
,BOOL
,-2);
4731 VAREQV(BOOL
,FALSE
,BOOL
,TRUE
,BOOL
,-2);
4732 VAREQV(BOOL
,6,BOOL
,7,BOOL
,-2);
4733 VAREQV(BOOL
,6,BOOL
,6,BOOL
,VARIANT_TRUE
);
4734 VAREQV(BOOL
,VARIANT_TRUE
,I2
,VARIANT_TRUE
,I2
,VARIANT_TRUE
);
4735 VAREQV(BOOL
,VARIANT_TRUE
,I2
,VARIANT_FALSE
,I2
,VARIANT_FALSE
);
4736 VAREQV(BOOL
,6,I2
,7,I2
,-2);
4737 VAREQV(UI1
,1,UI1
,1,UI1
,255);
4738 VAREQV(UI1
,1,UI1
,0,UI1
,254);
4739 VAREQV(UI1
,0,UI1
,1,UI1
,254);
4740 if (HAVE_OLEAUT32_I8
)
4742 VAREQV(UI4
,VARIANT_FALSE
,I8
,VARIANT_FALSE
,I8
,-1);
4743 VAREQV(UI4
,5,I8
,19,I8
,-23);
4744 VAREQV(UI4
,VARIANT_FALSE
,UI8
,VARIANT_FALSE
,I4
,-1);
4748 static HRESULT (WINAPI
*pVarMul
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
4750 #define VARMUL(vt1,val1,vt2,val2,rvt,rval) \
4751 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
4752 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
4753 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
4754 test_var_call2( __LINE__, pVarMul, &left, &right, &exp );
4756 static void test_VarMul(void)
4758 static const WCHAR sz12
[] = {'1','2','\0'};
4759 VARIANT left
, right
, exp
, result
, cy
, dec
;
4767 lbstr
= SysAllocString(sz12
);
4768 rbstr
= SysAllocString(sz12
);
4770 /* Test all possible flag/vt combinations & the resulting vt type */
4771 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
4773 VARTYPE leftvt
, rightvt
, resvt
;
4775 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
4780 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
4786 if (leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
||
4787 leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
)
4790 memset(&left
, 0, sizeof(left
));
4791 memset(&right
, 0, sizeof(right
));
4792 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
4793 if (leftvt
== VT_BSTR
)
4794 V_BSTR(&left
) = lbstr
;
4795 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
4796 if (rightvt
== VT_BSTR
)
4797 V_BSTR(&right
) = rbstr
;
4798 V_VT(&result
) = VT_EMPTY
;
4801 /* Don't ask me why but native VarMul cannot handle:
4802 VT_I1, VT_UI2, VT_UI4, VT_INT, VT_UINT and VT_UI8.
4803 Tested with DCOM98, Win2k, WinXP */
4804 if (ExtraFlags
[i
] & VT_ARRAY
|| ExtraFlags
[i
] & VT_BYREF
||
4805 !IsValidVariantClearVT(leftvt
, ExtraFlags
[i
]) ||
4806 !IsValidVariantClearVT(rightvt
, ExtraFlags
[i
]) ||
4807 leftvt
== VT_CLSID
|| rightvt
== VT_CLSID
||
4808 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
||
4809 leftvt
== VT_VARIANT
|| rightvt
== VT_VARIANT
||
4810 leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
||
4811 leftvt
== VT_I1
|| rightvt
== VT_I1
||
4812 leftvt
== VT_UI2
|| rightvt
== VT_UI2
||
4813 leftvt
== VT_UI4
|| rightvt
== VT_UI4
||
4814 leftvt
== VT_UI8
|| rightvt
== VT_UI8
||
4815 leftvt
== VT_INT
|| rightvt
== VT_INT
||
4816 leftvt
== VT_UINT
|| rightvt
== VT_UINT
) {
4820 if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
4822 else if (leftvt
== VT_DECIMAL
|| rightvt
== VT_DECIMAL
)
4824 else if (leftvt
== VT_R8
|| rightvt
== VT_R8
||
4825 leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
||
4826 leftvt
== VT_DATE
|| rightvt
== VT_DATE
)
4828 else if (leftvt
== VT_R4
|| rightvt
== VT_R4
) {
4829 if (leftvt
== VT_I4
|| rightvt
== VT_I4
||
4830 leftvt
== VT_I8
|| rightvt
== VT_I8
||
4831 leftvt
== VT_CY
|| rightvt
== VT_CY
)
4835 } else if (leftvt
== VT_CY
|| rightvt
== VT_CY
)
4837 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
4839 else if (leftvt
== VT_I4
|| rightvt
== VT_I4
)
4841 else if (leftvt
== VT_I2
|| rightvt
== VT_I2
||
4842 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
||
4843 (leftvt
== VT_EMPTY
&& rightvt
== VT_EMPTY
))
4845 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
4848 hres
= pVarMul(&left
, &right
, &result
);
4850 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
4851 "VarMul: %d|0x%X, %d|0x%X: Expected failure, got 0x%X vt %d\n",
4852 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], hres
,
4855 ok(hres
== S_OK
&& V_VT(&result
) == resvt
,
4856 "VarMul: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%X vt %d\n",
4857 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], resvt
, hres
,
4864 /* Test returned values */
4865 VARMUL(I4
,4,I4
,2,I4
,8);
4866 VARMUL(I2
,4,I2
,2,I2
,8);
4867 VARMUL(I2
,-13,I4
,5,I4
,-65);
4868 VARMUL(I4
,-13,I4
,5,I4
,-65);
4869 VARMUL(I2
,7,R4
,0.5,R4
,3.5);
4870 VARMUL(R4
,0.5,I4
,5,R8
,2.5);
4871 VARMUL(R8
,7.1,BOOL
,0,R8
,0);
4872 VARMUL(BSTR
,lbstr
,I2
,4,R8
,48);
4873 VARMUL(BSTR
,lbstr
,BOOL
,1,R8
,12);
4874 VARMUL(BSTR
,lbstr
,R4
,0.1,R8
,1.2);
4875 VARMUL(BSTR
,lbstr
,BSTR
,rbstr
,R8
,144);
4876 VARMUL(R4
,0.2,BSTR
,rbstr
,R8
,2.4);
4877 VARMUL(DATE
,2.25,I4
,7,R8
,15.75);
4879 VARMUL(UI1
, UI1_MAX
, UI1
, UI1_MAX
, I4
, UI1_MAX
* UI1_MAX
);
4880 VARMUL(I2
, I2_MAX
, I2
, I2_MAX
, I4
, I2_MAX
* I2_MAX
);
4881 VARMUL(I2
, I2_MAX
, I2
, I2_MIN
, I4
, I2_MAX
* I2_MIN
);
4882 VARMUL(I2
, I2_MIN
, I2
, I2_MIN
, I4
, I2_MIN
* I2_MIN
);
4883 VARMUL(I4
, I4_MAX
, I4
, I4_MAX
, R8
, (double)I4_MAX
* I4_MAX
);
4884 VARMUL(I4
, I4_MAX
, I4
, I4_MIN
, R8
, (double)I4_MAX
* I4_MIN
);
4885 VARMUL(I4
, I4_MIN
, I4
, I4_MIN
, R8
, (double)I4_MIN
* I4_MIN
);
4886 VARMUL(R4
, R4_MAX
, R4
, R4_MAX
, R8
, (double)R4_MAX
* R4_MAX
);
4887 VARMUL(R4
, R4_MAX
, R4
, R4_MIN
, R4
, R4_MAX
* R4_MIN
);
4888 VARMUL(R4
, R4_MIN
, R4
, R4_MIN
, R4
, R4_MIN
* R4_MIN
);
4889 VARMUL(R8
, R8_MAX
, R8
, R8_MIN
, R8
, R8_MAX
* R8_MIN
);
4890 VARMUL(R8
, R8_MIN
, R8
, R8_MIN
, R8
, R8_MIN
* R8_MIN
);
4892 /* Manuly test some VT_CY and VT_DECIMAL variants */
4894 hres
= VarCyFromI4(4711, &V_CY(&cy
));
4895 ok(hres
== S_OK
, "VarCyFromI4 failed!\n");
4896 V_VT(&dec
) = VT_DECIMAL
;
4897 hres
= VarDecFromR8(-4.2, &V_DECIMAL(&dec
));
4898 ok(hres
== S_OK
, "VarDecFromR4 failed!\n");
4899 memset(&left
, 0, sizeof(left
));
4900 memset(&right
, 0, sizeof(right
));
4901 V_VT(&left
) = VT_I4
;
4903 V_VT(&right
) = VT_UI1
;
4906 hres
= VarMul(&cy
, &right
, &result
);
4907 ok(hres
== S_OK
&& V_VT(&result
) == VT_CY
, "VarMul: expected coerced type VT_CY, got %s!\n", vtstr(V_VT(&result
)));
4908 hres
= VarR8FromCy(V_CY(&result
), &r
);
4909 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 42399), "VarMul: CY value %f, expected %f\n", r
, (double)42399);
4911 hres
= VarMul(&left
, &dec
, &result
);
4912 ok(hres
== S_OK
&& V_VT(&result
) == VT_DECIMAL
, "VarMul: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result
)));
4913 hres
= VarR8FromDec(&V_DECIMAL(&result
), &r
);
4914 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 46.2), "VarMul: DECIMAL value %f, expected %f\n", r
, (double)46.2);
4916 SysFreeString(lbstr
);
4917 SysFreeString(rbstr
);
4920 static HRESULT (WINAPI
*pVarAdd
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
4922 #define VARADD(vt1,val1,vt2,val2,rvt,rval) \
4923 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
4924 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
4925 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
4926 test_var_call2( __LINE__, pVarAdd, &left, &right, &exp );
4928 static void test_VarAdd(void)
4930 static const WCHAR sz12
[] = {'1','2','\0'};
4931 VARIANT left
, right
, exp
, result
, cy
, dec
;
4939 lbstr
= SysAllocString(sz12
);
4940 rbstr
= SysAllocString(sz12
);
4942 /* Test all possible flag/vt combinations & the resulting vt type */
4943 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
4945 VARTYPE leftvt
, rightvt
, resvt
;
4947 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
4952 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
4958 if (leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
)
4961 memset(&left
, 0, sizeof(left
));
4962 memset(&right
, 0, sizeof(right
));
4963 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
4964 if (leftvt
== VT_BSTR
)
4965 V_BSTR(&left
) = lbstr
;
4966 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
4967 if (rightvt
== VT_BSTR
)
4968 V_BSTR(&right
) = rbstr
;
4969 V_VT(&result
) = VT_EMPTY
;
4972 /* Don't ask me why but native VarAdd cannot handle:
4973 VT_I1, VT_UI2, VT_UI4, VT_INT, VT_UINT and VT_UI8.
4974 Tested with DCOM98, Win2k, WinXP */
4975 if (ExtraFlags
[i
] & VT_ARRAY
|| ExtraFlags
[i
] & VT_BYREF
||
4976 !IsValidVariantClearVT(leftvt
, ExtraFlags
[i
]) ||
4977 !IsValidVariantClearVT(rightvt
, ExtraFlags
[i
]) ||
4978 leftvt
== VT_CLSID
|| rightvt
== VT_CLSID
||
4979 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
||
4980 leftvt
== VT_VARIANT
|| rightvt
== VT_VARIANT
||
4981 leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
||
4982 leftvt
== VT_I1
|| rightvt
== VT_I1
||
4983 leftvt
== VT_UI2
|| rightvt
== VT_UI2
||
4984 leftvt
== VT_UI4
|| rightvt
== VT_UI4
||
4985 leftvt
== VT_UI8
|| rightvt
== VT_UI8
||
4986 leftvt
== VT_INT
|| rightvt
== VT_INT
||
4987 leftvt
== VT_UINT
|| rightvt
== VT_UINT
) {
4991 if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
4993 else if (leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
)
4995 else if (leftvt
== VT_DECIMAL
|| rightvt
== VT_DECIMAL
)
4997 else if (leftvt
== VT_DATE
|| rightvt
== VT_DATE
)
4999 else if (leftvt
== VT_CY
|| rightvt
== VT_CY
)
5001 else if (leftvt
== VT_R8
|| rightvt
== VT_R8
)
5003 else if (leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
) {
5004 if ((leftvt
== VT_BSTR
&& rightvt
== VT_BSTR
) ||
5005 leftvt
== VT_EMPTY
|| rightvt
== VT_EMPTY
)
5009 } else if (leftvt
== VT_R4
|| rightvt
== VT_R4
) {
5010 if (leftvt
== VT_I4
|| rightvt
== VT_I4
||
5011 leftvt
== VT_I8
|| rightvt
== VT_I8
)
5016 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
5018 else if (leftvt
== VT_I4
|| rightvt
== VT_I4
)
5020 else if (leftvt
== VT_I2
|| rightvt
== VT_I2
||
5021 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
||
5022 (leftvt
== VT_EMPTY
&& rightvt
== VT_EMPTY
))
5024 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
5027 hres
= pVarAdd(&left
, &right
, &result
);
5029 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
5030 "VarAdd: %d|0x%X, %d|0x%X: Expected failure, got 0x%X vt %d\n",
5031 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], hres
,
5034 ok(hres
== S_OK
&& V_VT(&result
) == resvt
,
5035 "VarAdd: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%X vt %d\n",
5036 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], resvt
, hres
,
5043 /* Test returned values */
5044 VARADD(I4
,4,I4
,2,I4
,6);
5045 VARADD(I2
,4,I2
,2,I2
,6);
5046 VARADD(I2
,-13,I4
,5,I4
,-8);
5047 VARADD(I4
,-13,I4
,5,I4
,-8);
5048 VARADD(I2
,7,R4
,0.5,R4
,7.5);
5049 VARADD(R4
,0.5,I4
,5,R8
,5.5);
5050 VARADD(R8
,7.1,BOOL
,0,R8
,7.1);
5051 VARADD(BSTR
,lbstr
,I2
,4,R8
,16);
5052 VARADD(BSTR
,lbstr
,BOOL
,1,R8
,13);
5053 VARADD(BSTR
,lbstr
,R4
,0.1,R8
,12.1);
5054 VARADD(R4
,0.2,BSTR
,rbstr
,R8
,12.2);
5055 VARADD(DATE
,2.25,I4
,7,DATE
,9.25);
5056 VARADD(DATE
,1.25,R4
,-1.7,DATE
,-0.45);
5058 VARADD(UI1
, UI1_MAX
, UI1
, UI1_MAX
, I2
, UI1_MAX
+ UI1_MAX
);
5059 VARADD(I2
, I2_MAX
, I2
, I2_MAX
, I4
, I2_MAX
+ I2_MAX
);
5060 VARADD(I2
, I2_MAX
, I2
, I2_MIN
, I2
, I2_MAX
+ I2_MIN
);
5061 VARADD(I2
, I2_MIN
, I2
, I2_MIN
, I4
, I2_MIN
+ I2_MIN
);
5062 VARADD(I4
, I4_MAX
, I4
, I4_MIN
, I4
, I4_MAX
+ I4_MIN
);
5063 VARADD(I4
, I4_MAX
, I4
, I4_MAX
, R8
, (double)I4_MAX
+ I4_MAX
);
5064 VARADD(I4
, I4_MIN
, I4
, I4_MIN
, R8
, (double)I4_MIN
+ I4_MIN
);
5065 VARADD(R4
, R4_MAX
, R4
, R4_MAX
, R8
, (double)R4_MAX
+ R4_MAX
);
5066 VARADD(R4
, R4_MAX
, R4
, R4_MIN
, R4
, R4_MAX
+ R4_MIN
);
5067 VARADD(R4
, R4_MIN
, R4
, R4_MIN
, R4
, R4_MIN
+ R4_MIN
);
5068 VARADD(R8
, R8_MAX
, R8
, R8_MIN
, R8
, R8_MAX
+ R8_MIN
);
5069 VARADD(R8
, R8_MIN
, R8
, R8_MIN
, R8
, R8_MIN
+ R8_MIN
);
5071 /* Manualy test BSTR + BSTR */
5072 V_VT(&left
) = VT_BSTR
;
5073 V_BSTR(&left
) = lbstr
;
5074 V_VT(&right
) = VT_BSTR
;
5075 V_BSTR(&right
) = rbstr
;
5076 hres
= VarAdd(&left
, &right
, &result
);
5077 ok(hres
== S_OK
&& V_VT(&result
) == VT_BSTR
, "VarAdd: expected coerced type VT_BSTR, got %s!\n", vtstr(V_VT(&result
)));
5078 hres
= VarR8FromStr(V_BSTR(&result
), 0, 0, &r
);
5079 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 1212), "VarAdd: BSTR value %f, expected %f\n", r
, (double)1212);
5081 /* Manuly test some VT_CY and VT_DECIMAL variants */
5083 hres
= VarCyFromI4(4711, &V_CY(&cy
));
5084 ok(hres
== S_OK
, "VarCyFromI4 failed!\n");
5085 V_VT(&dec
) = VT_DECIMAL
;
5086 hres
= VarDecFromR8(-4.2, &V_DECIMAL(&dec
));
5087 ok(hres
== S_OK
, "VarDecFromR4 failed!\n");
5088 memset(&left
, 0, sizeof(left
));
5089 memset(&right
, 0, sizeof(right
));
5090 V_VT(&left
) = VT_I4
;
5092 V_VT(&right
) = VT_UI1
;
5095 hres
= VarAdd(&cy
, &right
, &result
);
5096 ok(hres
== S_OK
&& V_VT(&result
) == VT_CY
, "VarAdd: expected coerced type VT_CY, got %s!\n", vtstr(V_VT(&result
)));
5097 hres
= VarR8FromCy(V_CY(&result
), &r
);
5098 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 4720), "VarAdd: CY value %f, expected %f\n", r
, (double)4720);
5100 hres
= VarAdd(&left
, &dec
, &result
);
5101 ok(hres
== S_OK
&& V_VT(&result
) == VT_DECIMAL
, "VarAdd: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result
)));
5102 hres
= VarR8FromDec(&V_DECIMAL(&result
), &r
);
5103 ok(hres
== S_OK
&& EQ_DOUBLE(r
, -15.2), "VarAdd: DECIMAL value %f, expected %f\n", r
, (double)-15.2);
5105 SysFreeString(lbstr
);
5106 SysFreeString(rbstr
);
5109 static void test_VarCat(void)
5112 VARIANT left
, right
, result
, expected
;
5113 static const WCHAR sz12
[] = {'1','2','\0'};
5114 static const WCHAR sz34
[] = {'3','4','\0'};
5115 static const WCHAR sz1234
[] = {'1','2','3','4','\0'};
5116 static const WCHAR date_sz12
[] = {'9','/','3','0','/','1','9','8','0','1','2','\0'};
5117 static const WCHAR sz12_date
[] = {'1','2','9','/','3','0','/','1','9','8','0','\0'};
5118 static const WCHAR sz_empty
[] = {'\0'};
5119 static const WCHAR sz12_true
[] = {'1','2','T','r','u','e','\0'};
5120 static const WCHAR sz12_false
[] = {'1','2','F','a','l','s','e','\0'};
5121 TCHAR orig_date_format
[128];
5122 VARTYPE leftvt
, rightvt
, resultvt
;
5124 HRESULT expected_error_num
;
5126 /* Set date format for testing */
5127 lcid
= LOCALE_USER_DEFAULT
;
5128 GetLocaleInfo(lcid
,LOCALE_SSHORTDATE
,orig_date_format
,128);
5129 SetLocaleInfo(lcid
,LOCALE_SSHORTDATE
,"M/d/yyyy");
5132 VariantInit(&right
);
5133 VariantInit(&result
);
5134 VariantInit(&expected
);
5136 /* Check expected types for all combinations */
5137 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
5142 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
5146 expected_error_num
= S_OK
;
5147 resultvt
= VT_EMPTY
;
5149 if (leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
||
5150 leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
||
5151 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
||
5152 leftvt
== 15 || rightvt
== 15 /* Undefined type */)
5155 if (leftvt
== VT_NULL
&& rightvt
== VT_NULL
)
5157 else if (leftvt
== VT_VARIANT
&& (rightvt
== VT_ERROR
||
5158 rightvt
== VT_DATE
|| rightvt
== VT_DECIMAL
))
5159 expected_error_num
= DISP_E_TYPEMISMATCH
;
5160 else if ((leftvt
== VT_I2
|| leftvt
== VT_I4
||
5161 leftvt
== VT_R4
|| leftvt
== VT_R8
||
5162 leftvt
== VT_CY
|| leftvt
== VT_BOOL
||
5163 leftvt
== VT_BSTR
|| leftvt
== VT_I1
||
5164 leftvt
== VT_UI1
|| leftvt
== VT_UI2
||
5165 leftvt
== VT_UI4
|| leftvt
== VT_I8
||
5166 leftvt
== VT_UI8
|| leftvt
== VT_INT
||
5167 leftvt
== VT_UINT
|| leftvt
== VT_EMPTY
||
5168 leftvt
== VT_NULL
|| leftvt
== VT_DECIMAL
||
5171 (rightvt
== VT_I2
|| rightvt
== VT_I4
||
5172 rightvt
== VT_R4
|| rightvt
== VT_R8
||
5173 rightvt
== VT_CY
|| rightvt
== VT_BOOL
||
5174 rightvt
== VT_BSTR
|| rightvt
== VT_I1
||
5175 rightvt
== VT_UI1
|| rightvt
== VT_UI2
||
5176 rightvt
== VT_UI4
|| rightvt
== VT_I8
||
5177 rightvt
== VT_UI8
|| rightvt
== VT_INT
||
5178 rightvt
== VT_UINT
|| rightvt
== VT_EMPTY
||
5179 rightvt
== VT_NULL
|| rightvt
== VT_DECIMAL
||
5180 rightvt
== VT_DATE
))
5182 else if (rightvt
== VT_ERROR
&& leftvt
< VT_VOID
)
5183 expected_error_num
= DISP_E_TYPEMISMATCH
;
5184 else if (leftvt
== VT_ERROR
&& (rightvt
== VT_DATE
||
5185 rightvt
== VT_ERROR
|| rightvt
== VT_DECIMAL
))
5186 expected_error_num
= DISP_E_TYPEMISMATCH
;
5187 else if (rightvt
== VT_DATE
|| rightvt
== VT_ERROR
||
5188 rightvt
== VT_DECIMAL
)
5189 expected_error_num
= DISP_E_BADVARTYPE
;
5190 else if (leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
)
5191 expected_error_num
= DISP_E_TYPEMISMATCH
;
5192 else if (leftvt
== VT_VARIANT
)
5193 expected_error_num
= DISP_E_TYPEMISMATCH
;
5194 else if (rightvt
== VT_VARIANT
&& (leftvt
== VT_EMPTY
||
5195 leftvt
== VT_NULL
|| leftvt
== VT_I2
||
5196 leftvt
== VT_I4
|| leftvt
== VT_R4
||
5197 leftvt
== VT_R8
|| leftvt
== VT_CY
||
5198 leftvt
== VT_DATE
|| leftvt
== VT_BSTR
||
5199 leftvt
== VT_BOOL
|| leftvt
== VT_DECIMAL
||
5200 leftvt
== VT_I1
|| leftvt
== VT_UI1
||
5201 leftvt
== VT_UI2
|| leftvt
== VT_UI4
||
5202 leftvt
== VT_I8
|| leftvt
== VT_UI8
||
5203 leftvt
== VT_INT
|| leftvt
== VT_UINT
5205 expected_error_num
= DISP_E_TYPEMISMATCH
;
5207 expected_error_num
= DISP_E_BADVARTYPE
;
5209 V_VT(&left
) = leftvt
;
5210 V_VT(&right
) = rightvt
;
5212 if (leftvt
== VT_BSTR
)
5213 V_BSTR(&left
) = SysAllocString(sz_empty
);
5214 if (rightvt
== VT_BSTR
)
5215 V_BSTR(&right
) = SysAllocString(sz_empty
);
5216 if (leftvt
== VT_DATE
)
5217 V_DATE(&left
) = 0.0;
5218 if (rightvt
== VT_DATE
)
5219 V_DATE(&right
) = 0.0;
5220 if (leftvt
== VT_DECIMAL
)
5221 VarDecFromR8(0.0, &V_DECIMAL(&left
));
5222 if (rightvt
== VT_DECIMAL
)
5223 VarDecFromR8(0.0, &V_DECIMAL(&right
));
5225 hres
= VarCat(&left
, &right
, &result
);
5227 /* Determine the error code for the vt combination */
5228 ok(hres
== expected_error_num
,
5229 "VarCat: %d, %d returned error, 0x%X expected 0x%X.\n",
5230 leftvt
, rightvt
, expected_error_num
, hres
);
5232 /* Check types are correct */
5233 ok(V_VT(&result
) == resultvt
,
5234 "VarCat: %d, %d: expected vt %d, got vt %d\n",
5235 leftvt
, rightvt
, resultvt
, V_VT(&result
));
5237 VariantClear(&left
);
5238 VariantClear(&right
);
5239 VariantClear(&result
);
5243 /* Runnning single comparison tests to compare outputs */
5245 /* Test concat strings */
5246 V_VT(&left
) = VT_BSTR
;
5247 V_VT(&right
) = VT_BSTR
;
5248 V_VT(&expected
) = VT_BSTR
;
5249 V_BSTR(&left
) = SysAllocString(sz12
);
5250 V_BSTR(&right
) = SysAllocString(sz34
);
5251 V_BSTR(&expected
) = SysAllocString(sz1234
);
5252 hres
= VarCat(&left
,&right
,&result
);
5253 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5254 ok(VarCmp(&result
,&expected
,lcid
,0) == VARCMP_EQ
,
5255 "VarCat: VT_BSTR concat with VT_BSTR failed to return correct result\n");
5257 VariantClear(&left
);
5258 VariantClear(&right
);
5259 VariantClear(&result
);
5261 /* Test if expression is VT_ERROR */
5262 V_VT(&left
) = VT_ERROR
;
5263 V_VT(&right
) = VT_BSTR
;
5264 V_BSTR(&right
) = SysAllocString(sz1234
);
5265 hres
= VarCat(&left
,&right
,&result
);
5266 ok(hres
== DISP_E_TYPEMISMATCH
, "VarCat should have returned DISP_E_TYPEMISMATCH instead of 0x%08x\n", hres
);
5267 ok(V_VT(&result
) == VT_EMPTY
,
5268 "VarCat: VT_ERROR concat with VT_BSTR should have returned VT_EMPTY\n");
5270 VariantClear(&left
);
5271 VariantClear(&right
);
5272 VariantClear(&result
);
5274 V_VT(&left
) = VT_BSTR
;
5275 V_VT(&right
) = VT_ERROR
;
5276 V_BSTR(&left
) = SysAllocString(sz1234
);
5277 hres
= VarCat(&left
,&right
,&result
);
5278 ok(hres
== DISP_E_TYPEMISMATCH
, "VarCat should have returned DISP_E_TYPEMISMATCH instead of 0x%08x\n", hres
);
5279 ok(V_VT(&result
) == VT_EMPTY
,
5280 "VarCat: VT_BSTR concat with VT_ERROR should have returned VT_EMPTY\n");
5282 VariantClear(&left
);
5283 VariantClear(&right
);
5284 VariantClear(&result
);
5285 VariantClear(&expected
);
5287 /* Test combining boolean with number */
5288 V_VT(&left
) = VT_INT
;
5289 V_VT(&right
) = VT_BOOL
;
5290 V_VT(&expected
) = VT_BSTR
;
5292 V_BOOL(&right
) = TRUE
;
5293 V_BSTR(&expected
) = SysAllocString(sz12_true
);
5294 hres
= VarCat(&left
,&right
,&result
);
5295 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5296 ok(VarCmp(&result
,&expected
,lcid
,0) == VARCMP_EQ
,
5297 "VarCat: VT_INT concat with VT_BOOL (TRUE) returned incorrect result\n");
5299 VariantClear(&left
);
5300 VariantClear(&right
);
5301 VariantClear(&result
);
5302 VariantClear(&expected
);
5304 V_VT(&left
) = VT_INT
;
5305 V_VT(&right
) = VT_BOOL
;
5306 V_VT(&expected
) = VT_BSTR
;
5308 V_BOOL(&right
) = FALSE
;
5309 V_BSTR(&expected
) = SysAllocString(sz12_false
);
5310 hres
= VarCat(&left
,&right
,&result
);
5311 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5312 ok(VarCmp(&result
,&expected
,lcid
,0) == VARCMP_EQ
,
5313 "VarCat: VT_INT concat with VT_BOOL (FALSE) returned inncorrect result\n");
5315 VariantClear(&left
);
5316 VariantClear(&right
);
5317 VariantClear(&result
);
5318 VariantClear(&expected
);
5320 /* Test when both expressions are numeric */
5321 V_VT(&left
) = VT_INT
;
5322 V_VT(&right
) = VT_INT
;
5323 V_VT(&expected
) = VT_BSTR
;
5326 V_BSTR(&expected
) = SysAllocString(sz1234
);
5327 hres
= VarCat(&left
,&right
,&result
);
5328 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5329 ok(VarCmp(&result
,&expected
,lcid
,0) == VARCMP_EQ
,
5330 "VarCat: NUMBER concat with NUMBER returned inncorrect result\n");
5332 VariantClear(&left
);
5333 VariantClear(&right
);
5334 VariantClear(&result
);
5336 /* Test if one expression is numeric and the other is a string */
5337 V_VT(&left
) = VT_INT
;
5338 V_VT(&right
) = VT_BSTR
;
5340 V_BSTR(&right
) = SysAllocString(sz34
);
5341 hres
= VarCat(&left
,&right
,&result
);
5342 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5343 ok(VarCmp(&result
,&expected
,lcid
,0) == VARCMP_EQ
,
5344 "VarCat: NUMBER concat with VT_BSTR, inncorrect result\n");
5346 VariantClear(&left
);
5347 VariantClear(&right
);
5348 VariantClear(&result
);
5350 V_VT(&left
) = VT_BSTR
;
5351 V_VT(&right
) = VT_INT
;
5352 V_BSTR(&left
) = SysAllocString(sz12
);
5354 hres
= VarCat(&left
,&right
,&result
);
5355 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5356 ok(VarCmp(&result
,&expected
,lcid
,0) == VARCMP_EQ
,
5357 "VarCat: VT_BSTR concat with NUMBER, inncorrect result\n");
5359 VariantClear(&left
);
5360 VariantClear(&right
);
5361 VariantClear(&result
);
5363 /* Test concat dates with strings */
5364 V_VT(&left
) = VT_BSTR
;
5365 V_VT(&right
) = VT_DATE
;
5366 V_VT(&expected
) = VT_BSTR
;
5367 V_BSTR(&left
) = SysAllocString(sz12
);
5368 V_DATE(&right
) = 29494.0;
5369 V_BSTR(&expected
)= SysAllocString(sz12_date
);
5370 hres
= VarCat(&left
,&right
,&result
);
5371 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5372 ok(VarCmp(&result
,&expected
,lcid
,0) == VARCMP_EQ
,
5373 "VarCat: VT_BSTR concat with VT_DATE returned inncorrect result\n");
5375 VariantClear(&left
);
5376 VariantClear(&right
);
5377 VariantClear(&result
);
5378 VariantClear(&expected
);
5380 V_VT(&left
) = VT_DATE
;
5381 V_VT(&right
) = VT_BSTR
;
5382 V_VT(&expected
) = VT_BSTR
;
5383 V_DATE(&left
) = 29494.0;
5384 V_BSTR(&right
) = SysAllocString(sz12
);
5385 V_BSTR(&expected
)= SysAllocString(date_sz12
);
5386 hres
= VarCat(&left
,&right
,&result
);
5387 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5388 ok(VarCmp(&result
,&expected
,lcid
,0) == VARCMP_EQ
,
5389 "VarCat: VT_DATE concat with VT_BSTR returned inncorrect result\n");
5391 VariantClear(&left
);
5392 VariantClear(&right
);
5393 VariantClear(&result
);
5394 VariantClear(&expected
);
5396 /* Test of both expressions are empty */
5397 V_VT(&left
) = VT_BSTR
;
5398 V_VT(&right
) = VT_BSTR
;
5399 V_VT(&expected
) = VT_BSTR
;
5400 V_BSTR(&left
) = SysAllocString(sz_empty
);
5401 V_BSTR(&right
) = SysAllocString(sz_empty
);
5402 V_BSTR(&expected
)= SysAllocString(sz_empty
);
5403 hres
= VarCat(&left
,&right
,&result
);
5404 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5405 ok(VarCmp(&result
,&left
,lcid
,0) == VARCMP_EQ
,
5406 "VarCat: EMPTY concat with EMPTY did not return empty VT_BSTR\n");
5408 /* Restore original date format settings */
5409 SetLocaleInfo(lcid
,LOCALE_SSHORTDATE
,orig_date_format
);
5411 VariantClear(&left
);
5412 VariantClear(&right
);
5413 VariantClear(&result
);
5414 VariantClear(&expected
);
5417 static HRESULT (WINAPI
*pVarAnd
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
5419 #define VARAND(vt1,val1,vt2,val2,rvt,rval) \
5420 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
5421 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
5422 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
5423 test_var_call2( __LINE__, pVarAnd, &left, &right, &exp );
5425 #define VARANDCY(vt1,val1,val2,rvt,rval) \
5426 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
5427 V_VT(&right) = VT_CY; V_CY(&right).int64 = val2; \
5428 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
5429 test_var_call2( __LINE__, pVarAnd, &left, &right, &exp );
5431 /* Skip any type that is not defined or produces a error for every case */
5432 #define SKIPTESTAND(a) \
5433 if (a == VT_ERROR || a == VT_VARIANT || \
5434 a == VT_DISPATCH || a == VT_UNKNOWN || \
5435 a > VT_UINT || a == 15 /*not defined*/) \
5438 static void test_VarAnd(void)
5440 static const WCHAR szFalse
[] = { '#','F','A','L','S','E','#','\0' };
5441 static const WCHAR szTrue
[] = { '#','T','R','U','E','#','\0' };
5442 VARIANT left
, right
, exp
, result
;
5443 BSTR false_str
, true_str
;
5447 true_str
= SysAllocString(szTrue
);
5448 false_str
= SysAllocString(szFalse
);
5452 /* Test all possible flag/vt combinations & the resulting vt type */
5453 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
5455 VARTYPE leftvt
, rightvt
, resvt
;
5457 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
5459 SKIPTESTAND(leftvt
);
5461 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
5464 SKIPTESTAND(rightvt
);
5466 memset(&left
, 0, sizeof(left
));
5467 memset(&right
, 0, sizeof(right
));
5468 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
5469 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
5470 V_VT(&result
) = VT_EMPTY
;
5472 if ((leftvt
| ExtraFlags
[i
]) == VT_BSTR
)
5473 V_BSTR(&left
) = true_str
;
5474 if ((rightvt
| ExtraFlags
[i
]) == VT_BSTR
)
5475 V_BSTR(&right
) = true_str
;
5477 /* Native VarAnd always returns a error when using any extra
5478 * flags or if the variant combination is I8 and INT.
5480 if ((leftvt
== VT_I8
&& rightvt
== VT_INT
) ||
5481 (leftvt
== VT_INT
&& rightvt
== VT_I8
) ||
5485 /* Determine return type */
5486 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
5488 else if (leftvt
== VT_I4
|| rightvt
== VT_I4
||
5489 leftvt
== VT_UINT
|| rightvt
== VT_UINT
||
5490 leftvt
== VT_INT
|| rightvt
== VT_INT
||
5491 leftvt
== VT_UINT
|| rightvt
== VT_UINT
||
5492 leftvt
== VT_R4
|| rightvt
== VT_R4
||
5493 leftvt
== VT_R8
|| rightvt
== VT_R8
||
5494 leftvt
== VT_CY
|| rightvt
== VT_CY
||
5495 leftvt
== VT_DATE
|| rightvt
== VT_DATE
||
5496 leftvt
== VT_I1
|| rightvt
== VT_I1
||
5497 leftvt
== VT_UI2
|| rightvt
== VT_UI2
||
5498 leftvt
== VT_UI4
|| rightvt
== VT_UI4
||
5499 leftvt
== VT_UI8
|| rightvt
== VT_UI8
||
5500 leftvt
== VT_DECIMAL
|| rightvt
== VT_DECIMAL
)
5502 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
||
5503 leftvt
== VT_I2
|| rightvt
== VT_I2
||
5504 leftvt
== VT_EMPTY
|| rightvt
== VT_EMPTY
)
5505 if ((leftvt
== VT_NULL
&& rightvt
== VT_UI1
) ||
5506 (leftvt
== VT_UI1
&& rightvt
== VT_NULL
) ||
5507 (leftvt
== VT_UI1
&& rightvt
== VT_UI1
))
5511 else if (leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
||
5512 (leftvt
== VT_BSTR
&& rightvt
== VT_BSTR
))
5514 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
||
5515 leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
)
5520 hres
= pVarAnd(&left
, &right
, &result
);
5522 /* Check expected HRESULT and if result variant type is correct */
5524 ok (hres
== DISP_E_BADVARTYPE
|| hres
== DISP_E_TYPEMISMATCH
,
5525 "VarAnd: %s|0x%X, %s|0x%X: got vt %s hr 0x%X\n",
5526 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
],
5527 vtstr(V_VT(&result
)), hres
);
5529 ok (hres
== S_OK
&& resvt
== V_VT(&result
),
5530 "VarAnd: %s|0x%X, %s|0x%X: expected vt %s hr 0x%X, got vt %s hr 0x%X\n",
5531 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
], vtstr(resvt
),
5532 S_OK
, vtstr(V_VT(&result
)), hres
);
5538 * Test returned values. Since we know the returned type is correct
5539 * and that we handle all combinations of invalid types, just check
5540 * that good type combinations produce the desired value.
5541 * FIXME: Test VT_DECIMAL
5543 VARAND(EMPTY
,0,EMPTY
,0,I2
,0);
5544 VARAND(EMPTY
,1,EMPTY
,0,I2
,0);
5545 VARAND(EMPTY
,1,EMPTY
,1,I2
,0);
5546 VARAND(EMPTY
,0,NULL
,0,I2
,0);
5547 VARAND(EMPTY
,1,NULL
,0,I2
,0);
5548 VARAND(EMPTY
,1,NULL
,1,I2
,0);
5549 VARAND(EMPTY
,0,I1
,0,I4
,0);
5550 VARAND(EMPTY
,0,I1
,1,I4
,0);
5551 VARAND(EMPTY
,1,I1
,1,I4
,0);
5552 VARAND(EMPTY
,0,UI1
,0,I2
,0);
5553 VARAND(EMPTY
,0,UI1
,1,I2
,0);
5554 VARAND(EMPTY
,1,UI1
,1,I2
,0);
5555 VARAND(EMPTY
,0,I2
,0,I2
,0);
5556 VARAND(EMPTY
,0,I2
,1,I2
,0);
5557 VARAND(EMPTY
,1,I2
,1,I2
,0);
5558 VARAND(EMPTY
,0,UI2
,0,I4
,0);
5559 VARAND(EMPTY
,0,UI2
,1,I4
,0);
5560 VARAND(EMPTY
,1,UI2
,1,I4
,0);
5561 VARAND(EMPTY
,0,I4
,0,I4
,0);
5562 VARAND(EMPTY
,0,I4
,1,I4
,0);
5563 VARAND(EMPTY
,1,I4
,1,I4
,0);
5564 VARAND(EMPTY
,0,UI4
,0,I4
,0);
5565 VARAND(EMPTY
,0,UI4
,1,I4
,0);
5566 VARAND(EMPTY
,1,UI4
,1,I4
,0);
5567 if (HAVE_OLEAUT32_I8
)
5569 VARAND(EMPTY
,0,I8
,0,I8
,0);
5570 VARAND(EMPTY
,0,I8
,1,I8
,0);
5571 VARAND(EMPTY
,1,I8
,1,I8
,0);
5572 VARAND(EMPTY
,0,UI8
,0,I4
,0);
5573 VARAND(EMPTY
,0,UI8
,1,I4
,0);
5574 VARAND(EMPTY
,1,UI8
,1,I4
,0);
5576 VARAND(EMPTY
,0,INT
,0,I4
,0);
5577 VARAND(EMPTY
,0,INT
,1,I4
,0);
5578 VARAND(EMPTY
,1,INT
,1,I4
,0);
5579 VARAND(EMPTY
,0,UINT
,0,I4
,0);
5580 VARAND(EMPTY
,0,UINT
,1,I4
,0);
5581 VARAND(EMPTY
,1,UINT
,1,I4
,0);
5582 VARAND(EMPTY
,0,BOOL
,0,I2
,0);
5583 VARAND(EMPTY
,0,BOOL
,1,I2
,0);
5584 VARAND(EMPTY
,1,BOOL
,1,I2
,0);
5585 VARAND(EMPTY
,0,R4
,0,I4
,0);
5586 VARAND(EMPTY
,0,R4
,1,I4
,0);
5587 VARAND(EMPTY
,1,R4
,1,I4
,0);
5588 VARAND(EMPTY
,0,R8
,0,I4
,0);
5589 VARAND(EMPTY
,0,R8
,1,I4
,0);
5590 VARAND(EMPTY
,1,R8
,1,I4
,0);
5591 VARAND(EMPTY
,0,BSTR
,false_str
,I2
,0);
5592 VARAND(EMPTY
,0,BSTR
,true_str
,I2
,0);
5593 VARANDCY(EMPTY
,0,10000,I4
,0);
5595 /* NULL OR 0 = NULL. NULL OR n = n */
5596 VARAND(NULL
,0,NULL
,0,NULL
,0);
5597 VARAND(NULL
,1,NULL
,0,NULL
,0);
5598 VARAND(NULL
,0,I1
,0,I4
,0);
5599 VARAND(NULL
,0,I1
,1,NULL
,0);
5600 VARAND(NULL
,0,UI1
,0,UI1
,0);
5601 VARAND(NULL
,0,UI1
,1,NULL
,0);
5602 VARAND(NULL
,0,I2
,0,I2
,0);
5603 VARAND(NULL
,0,I2
,1,NULL
,0);
5604 VARAND(NULL
,0,UI2
,0,I4
,0);
5605 VARAND(NULL
,0,UI2
,1,NULL
,0);
5606 VARAND(NULL
,0,I4
,0,I4
,0);
5607 VARAND(NULL
,0,I4
,1,NULL
,0);
5608 VARAND(NULL
,0,UI4
,0,I4
,0);
5609 VARAND(NULL
,0,UI4
,1,NULL
,0);
5610 if (HAVE_OLEAUT32_I8
)
5612 VARAND(NULL
,0,I8
,0,I8
,0);
5613 VARAND(NULL
,0,I8
,1,NULL
,0);
5614 VARAND(NULL
,0,UI8
,0,I4
,0);
5615 VARAND(NULL
,0,UI8
,1,NULL
,0);
5617 VARAND(NULL
,0,INT
,0,I4
,0);
5618 VARAND(NULL
,0,INT
,1,NULL
,0);
5619 VARAND(NULL
,0,UINT
,0,I4
,0);
5620 VARAND(NULL
,0,UINT
,1,NULL
,0);
5621 VARAND(NULL
,0,BOOL
,0,BOOL
,0);
5622 VARAND(NULL
,0,BOOL
,1,NULL
,0);
5623 VARAND(NULL
,0,R4
,0,I4
,0);
5624 VARAND(NULL
,0,R4
,1,NULL
,0);
5625 VARAND(NULL
,0,R8
,0,I4
,0);
5626 VARAND(NULL
,0,R8
,1,NULL
,0);
5627 VARAND(NULL
,0,BSTR
,false_str
,BOOL
,0);
5628 VARAND(NULL
,0,BSTR
,true_str
,NULL
,VARIANT_FALSE
);
5629 VARANDCY(NULL
,0,10000,NULL
,0);
5630 VARANDCY(NULL
,0,0,I4
,0);
5631 VARAND(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
);
5632 VARAND(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_FALSE
);
5633 VARAND(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
);
5634 VARAND(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_FALSE
);
5636 /* Assume x,y & y,x are the same from now on to reduce the number of tests */
5637 VARAND(BOOL
,VARIANT_TRUE
,I1
,-1,I4
,-1);
5638 VARAND(BOOL
,VARIANT_TRUE
,I1
,0,I4
,0);
5639 VARAND(BOOL
,VARIANT_FALSE
,I1
,0,I4
,0);
5640 VARAND(BOOL
,VARIANT_TRUE
,UI1
,255,I2
,255);
5641 VARAND(BOOL
,VARIANT_TRUE
,UI1
,0,I2
,0);
5642 VARAND(BOOL
,VARIANT_FALSE
,UI1
,0,I2
,0);
5643 VARAND(BOOL
,VARIANT_TRUE
,I2
,-1,I2
,-1);
5644 VARAND(BOOL
,VARIANT_TRUE
,I2
,0,I2
,0);
5645 VARAND(BOOL
,VARIANT_FALSE
,I2
,0,I2
,0);
5646 VARAND(BOOL
,VARIANT_TRUE
,UI2
,65535,I4
,65535);
5647 VARAND(BOOL
,VARIANT_TRUE
,UI2
,0,I4
,0);
5648 VARAND(BOOL
,VARIANT_FALSE
,UI2
,0,I4
,0);
5649 VARAND(BOOL
,VARIANT_TRUE
,I4
,-1,I4
,-1);
5650 VARAND(BOOL
,VARIANT_TRUE
,I4
,0,I4
,0);
5651 VARAND(BOOL
,VARIANT_FALSE
,I4
,0,I4
,0);
5652 VARAND(BOOL
,VARIANT_TRUE
,UI4
,0xffffffff,I4
,-1);
5653 VARAND(BOOL
,VARIANT_TRUE
,UI4
,0,I4
,0);
5654 VARAND(BOOL
,VARIANT_FALSE
,UI4
,0,I4
,0);
5655 VARAND(BOOL
,VARIANT_TRUE
,R4
,-1,I4
,-1);
5656 VARAND(BOOL
,VARIANT_TRUE
,R4
,0,I4
,0);
5657 VARAND(BOOL
,VARIANT_FALSE
,R4
,0,I4
,0);
5658 VARAND(BOOL
,VARIANT_TRUE
,R8
,-1,I4
,-1);
5659 VARAND(BOOL
,VARIANT_TRUE
,R8
,0,I4
,0);
5660 VARAND(BOOL
,VARIANT_FALSE
,R8
,0,I4
,0);
5661 VARAND(BOOL
,VARIANT_TRUE
,DATE
,-1,I4
,-1);
5662 VARAND(BOOL
,VARIANT_TRUE
,DATE
,0,I4
,0);
5663 VARAND(BOOL
,VARIANT_FALSE
,DATE
,0,I4
,0);
5664 if (HAVE_OLEAUT32_I8
)
5666 VARAND(BOOL
,VARIANT_TRUE
,I8
,-1,I8
,-1);
5667 VARAND(BOOL
,VARIANT_TRUE
,I8
,0,I8
,0);
5668 VARAND(BOOL
,VARIANT_FALSE
,I8
,0,I8
,0);
5669 VARAND(BOOL
,VARIANT_TRUE
,UI8
,0,I4
,0);
5670 VARAND(BOOL
,VARIANT_FALSE
,UI8
,0,I4
,0);
5672 VARAND(BOOL
,VARIANT_TRUE
,INT
,-1,I4
,-1);
5673 VARAND(BOOL
,VARIANT_TRUE
,INT
,0,I4
,0);
5674 VARAND(BOOL
,VARIANT_FALSE
,INT
,0,I4
,0);
5675 VARAND(BOOL
,VARIANT_TRUE
,UINT
,0xffffffff,I4
,-1);
5676 VARAND(BOOL
,VARIANT_TRUE
,UINT
,0,I4
,0);
5677 VARAND(BOOL
,VARIANT_FALSE
,UINT
,0,I4
,0);
5678 VARAND(BOOL
,VARIANT_FALSE
,BSTR
,false_str
,BOOL
,VARIANT_FALSE
);
5679 VARAND(BOOL
,VARIANT_TRUE
,BSTR
,false_str
,BOOL
,VARIANT_FALSE
);
5680 VARAND(BOOL
,VARIANT_FALSE
,BSTR
,true_str
,BOOL
,VARIANT_FALSE
);
5681 VARAND(BOOL
,VARIANT_TRUE
,BSTR
,true_str
,BOOL
,VARIANT_TRUE
);
5682 VARANDCY(BOOL
,VARIANT_TRUE
,10000,I4
,1);
5683 VARANDCY(BOOL
,VARIANT_TRUE
,0,I4
,0);
5684 VARANDCY(BOOL
,VARIANT_FALSE
,0,I4
,0);
5685 VARAND(I1
,-1,I1
,-1,I4
,-1);
5686 VARAND(I1
,-1,I1
,0,I4
,0);
5687 VARAND(I1
,0,I1
,0,I4
,0);
5688 VARAND(I1
,-1,UI1
,255,I4
,255);
5689 VARAND(I1
,-1,UI1
,0,I4
,0);
5690 VARAND(I1
,0,UI1
,0,I4
,0);
5691 VARAND(I1
,-1,I2
,-1,I4
,-1);
5692 VARAND(I1
,-1,I2
,0,I4
,0);
5693 VARAND(I1
,0,I2
,0,I4
,0);
5694 VARAND(I1
,-1,UI2
,65535,I4
,65535);
5695 VARAND(I1
,-1,UI2
,0,I4
,0);
5696 VARAND(I1
,0,UI2
,0,I4
,0);
5697 VARAND(I1
,-1,I4
,-1,I4
,-1);
5698 VARAND(I1
,-1,I4
,0,I4
,0);
5699 VARAND(I1
,0,I4
,0,I4
,0);
5700 VARAND(I1
,-1,UI4
,0xffffffff,I4
,-1);
5701 VARAND(I1
,-1,UI4
,0,I4
,0);
5702 VARAND(I1
,0,UI4
,0,I4
,0);
5703 VARAND(I1
,-1,R4
,-1,I4
,-1);
5704 VARAND(I1
,-1,R4
,0,I4
,0);
5705 VARAND(I1
,0,R4
,0,I4
,0);
5706 VARAND(I1
,-1,R8
,-1,I4
,-1);
5707 VARAND(I1
,-1,R8
,0,I4
,0);
5708 VARAND(I1
,0,R8
,0,I4
,0);
5709 VARAND(I1
,-1,DATE
,-1,I4
,-1);
5710 VARAND(I1
,-1,DATE
,0,I4
,0);
5711 VARAND(I1
,0,DATE
,0,I4
,0);
5712 if (HAVE_OLEAUT32_I8
)
5714 VARAND(I1
,-1,I8
,-1,I8
,-1);
5715 VARAND(I1
,-1,I8
,0,I8
,0);
5716 VARAND(I1
,0,I8
,0,I8
,0);
5717 VARAND(I1
,-1,UI8
,0,I4
,0);
5718 VARAND(I1
,0,UI8
,0,I4
,0);
5720 VARAND(I1
,-1,INT
,-1,I4
,-1);
5721 VARAND(I1
,-1,INT
,0,I4
,0);
5722 VARAND(I1
,0,INT
,0,I4
,0);
5723 VARAND(I1
,-1,UINT
,0xffffffff,I4
,-1);
5724 VARAND(I1
,-1,UINT
,0,I4
,0);
5725 VARAND(I1
,0,UINT
,0,I4
,0);
5726 VARAND(I1
,0,BSTR
,false_str
,I4
,0);
5727 VARAND(I1
,-1,BSTR
,false_str
,I4
,0);
5728 VARAND(I1
,0,BSTR
,true_str
,I4
,0);
5729 VARAND(I1
,-1,BSTR
,true_str
,I4
,-1);
5730 VARANDCY(I1
,-1,10000,I4
,1);
5731 VARANDCY(I1
,-1,0,I4
,0);
5732 VARANDCY(I1
,0,0,I4
,0);
5734 VARAND(UI1
,255,UI1
,255,UI1
,255);
5735 VARAND(UI1
,255,UI1
,0,UI1
,0);
5736 VARAND(UI1
,0,UI1
,0,UI1
,0);
5737 VARAND(UI1
,255,I2
,-1,I2
,255);
5738 VARAND(UI1
,255,I2
,0,I2
,0);
5739 VARAND(UI1
,0,I2
,0,I2
,0);
5740 VARAND(UI1
,255,UI2
,65535,I4
,255);
5741 VARAND(UI1
,255,UI2
,0,I4
,0);
5742 VARAND(UI1
,0,UI2
,0,I4
,0);
5743 VARAND(UI1
,255,I4
,-1,I4
,255);
5744 VARAND(UI1
,255,I4
,0,I4
,0);
5745 VARAND(UI1
,0,I4
,0,I4
,0);
5746 VARAND(UI1
,255,UI4
,0xffffffff,I4
,255);
5747 VARAND(UI1
,255,UI4
,0,I4
,0);
5748 VARAND(UI1
,0,UI4
,0,I4
,0);
5749 VARAND(UI1
,255,R4
,-1,I4
,255);
5750 VARAND(UI1
,255,R4
,0,I4
,0);
5751 VARAND(UI1
,0,R4
,0,I4
,0);
5752 VARAND(UI1
,255,R8
,-1,I4
,255);
5753 VARAND(UI1
,255,R8
,0,I4
,0);
5754 VARAND(UI1
,0,R8
,0,I4
,0);
5755 VARAND(UI1
,255,DATE
,-1,I4
,255);
5756 VARAND(UI1
,255,DATE
,0,I4
,0);
5757 VARAND(UI1
,0,DATE
,0,I4
,0);
5758 if (HAVE_OLEAUT32_I8
)
5760 VARAND(UI1
,255,I8
,-1,I8
,255);
5761 VARAND(UI1
,255,I8
,0,I8
,0);
5762 VARAND(UI1
,0,I8
,0,I8
,0);
5763 VARAND(UI1
,255,UI8
,0,I4
,0);
5764 VARAND(UI1
,0,UI8
,0,I4
,0);
5766 VARAND(UI1
,255,INT
,-1,I4
,255);
5767 VARAND(UI1
,255,INT
,0,I4
,0);
5768 VARAND(UI1
,0,INT
,0,I4
,0);
5769 VARAND(UI1
,255,UINT
,0xffffffff,I4
,255);
5770 VARAND(UI1
,255,UINT
,0,I4
,0);
5771 VARAND(UI1
,0,UINT
,0,I4
,0);
5772 VARAND(UI1
,0,BSTR
,false_str
,I2
,0);
5773 VARAND(UI1
,255,BSTR
,false_str
,I2
,0);
5774 VARAND(UI1
,0,BSTR
,true_str
,I2
,0);
5775 VARAND(UI1
,255,BSTR
,true_str
,I2
,255);
5776 VARANDCY(UI1
,255,10000,I4
,1);
5777 VARANDCY(UI1
,255,0,I4
,0);
5778 VARANDCY(UI1
,0,0,I4
,0);
5780 VARAND(I2
,-1,I2
,-1,I2
,-1);
5781 VARAND(I2
,-1,I2
,0,I2
,0);
5782 VARAND(I2
,0,I2
,0,I2
,0);
5783 VARAND(I2
,-1,UI2
,65535,I4
,65535);
5784 VARAND(I2
,-1,UI2
,0,I4
,0);
5785 VARAND(I2
,0,UI2
,0,I4
,0);
5786 VARAND(I2
,-1,I4
,-1,I4
,-1);
5787 VARAND(I2
,-1,I4
,0,I4
,0);
5788 VARAND(I2
,0,I4
,0,I4
,0);
5789 VARAND(I2
,-1,UI4
,0xffffffff,I4
,-1);
5790 VARAND(I2
,-1,UI4
,0,I4
,0);
5791 VARAND(I2
,0,UI4
,0,I4
,0);
5792 VARAND(I2
,-1,R4
,-1,I4
,-1);
5793 VARAND(I2
,-1,R4
,0,I4
,0);
5794 VARAND(I2
,0,R4
,0,I4
,0);
5795 VARAND(I2
,-1,R8
,-1,I4
,-1);
5796 VARAND(I2
,-1,R8
,0,I4
,0);
5797 VARAND(I2
,0,R8
,0,I4
,0);
5798 VARAND(I2
,-1,DATE
,-1,I4
,-1);
5799 VARAND(I2
,-1,DATE
,0,I4
,0);
5800 VARAND(I2
,0,DATE
,0,I4
,0);
5801 if (HAVE_OLEAUT32_I8
)
5803 VARAND(I2
,-1,I8
,-1,I8
,-1);
5804 VARAND(I2
,-1,I8
,0,I8
,0);
5805 VARAND(I2
,0,I8
,0,I8
,0);
5806 VARAND(I2
,-1,UI8
,0,I4
,0);
5807 VARAND(I2
,0,UI8
,0,I4
,0);
5809 VARAND(I2
,-1,INT
,-1,I4
,-1);
5810 VARAND(I2
,-1,INT
,0,I4
,0);
5811 VARAND(I2
,0,INT
,0,I4
,0);
5812 VARAND(I2
,-1,UINT
,0xffffffff,I4
,-1);
5813 VARAND(I2
,-1,UINT
,0,I4
,0);
5814 VARAND(I2
,0,UINT
,0,I4
,0);
5815 VARAND(I2
,0,BSTR
,false_str
,I2
,0);
5816 VARAND(I2
,-1,BSTR
,false_str
,I2
,0);
5817 VARAND(I2
,0,BSTR
,true_str
,I2
,0);
5818 VARAND(I2
,-1,BSTR
,true_str
,I2
,-1);
5819 VARANDCY(I2
,-1,10000,I4
,1);
5820 VARANDCY(I2
,-1,0,I4
,0);
5821 VARANDCY(I2
,0,0,I4
,0);
5823 VARAND(UI2
,65535,UI2
,65535,I4
,65535);
5824 VARAND(UI2
,65535,UI2
,0,I4
,0);
5825 VARAND(UI2
,0,UI2
,0,I4
,0);
5826 VARAND(UI2
,65535,I4
,-1,I4
,65535);
5827 VARAND(UI2
,65535,I4
,0,I4
,0);
5828 VARAND(UI2
,0,I4
,0,I4
,0);
5829 VARAND(UI2
,65535,UI4
,0xffffffff,I4
,65535);
5830 VARAND(UI2
,65535,UI4
,0,I4
,0);
5831 VARAND(UI2
,0,UI4
,0,I4
,0);
5832 VARAND(UI2
,65535,R4
,-1,I4
,65535);
5833 VARAND(UI2
,65535,R4
,0,I4
,0);
5834 VARAND(UI2
,0,R4
,0,I4
,0);
5835 VARAND(UI2
,65535,R8
,-1,I4
,65535);
5836 VARAND(UI2
,65535,R8
,0,I4
,0);
5837 VARAND(UI2
,0,R8
,0,I4
,0);
5838 VARAND(UI2
,65535,DATE
,-1,I4
,65535);
5839 VARAND(UI2
,65535,DATE
,0,I4
,0);
5840 VARAND(UI2
,0,DATE
,0,I4
,0);
5841 if (HAVE_OLEAUT32_I8
)
5843 VARAND(UI2
,65535,I8
,-1,I8
,65535);
5844 VARAND(UI2
,65535,I8
,0,I8
,0);
5845 VARAND(UI2
,0,I8
,0,I8
,0);
5846 VARAND(UI2
,65535,UI8
,0,I4
,0);
5847 VARAND(UI2
,0,UI8
,0,I4
,0);
5849 VARAND(UI2
,65535,INT
,-1,I4
,65535);
5850 VARAND(UI2
,65535,INT
,0,I4
,0);
5851 VARAND(UI2
,0,INT
,0,I4
,0);
5852 VARAND(UI2
,65535,UINT
,0xffffffff,I4
,65535);
5853 VARAND(UI2
,65535,UINT
,0,I4
,0);
5854 VARAND(UI2
,0,UINT
,0,I4
,0);
5855 VARAND(UI2
,0,BSTR
,false_str
,I4
,0);
5856 VARAND(UI2
,65535,BSTR
,false_str
,I4
,0);
5857 VARAND(UI2
,0,BSTR
,true_str
,I4
,0);
5858 VARAND(UI2
,65535,BSTR
,true_str
,I4
,65535);
5859 VARANDCY(UI2
,65535,10000,I4
,1);
5860 VARANDCY(UI2
,65535,0,I4
,0);
5861 VARANDCY(UI2
,0,0,I4
,0);
5863 VARAND(I4
,-1,I4
,-1,I4
,-1);
5864 VARAND(I4
,-1,I4
,0,I4
,0);
5865 VARAND(I4
,0,I4
,0,I4
,0);
5866 VARAND(I4
,-1,UI4
,0xffffffff,I4
,-1);
5867 VARAND(I4
,-1,UI4
,0,I4
,0);
5868 VARAND(I4
,0,UI4
,0,I4
,0);
5869 VARAND(I4
,-1,R4
,-1,I4
,-1);
5870 VARAND(I4
,-1,R4
,0,I4
,0);
5871 VARAND(I4
,0,R4
,0,I4
,0);
5872 VARAND(I4
,-1,R8
,-1,I4
,-1);
5873 VARAND(I4
,-1,R8
,0,I4
,0);
5874 VARAND(I4
,0,R8
,0,I4
,0);
5875 VARAND(I4
,-1,DATE
,-1,I4
,-1);
5876 VARAND(I4
,-1,DATE
,0,I4
,0);
5877 VARAND(I4
,0,DATE
,0,I4
,0);
5878 if (HAVE_OLEAUT32_I8
)
5880 VARAND(I4
,-1,I8
,-1,I8
,-1);
5881 VARAND(I4
,-1,I8
,0,I8
,0);
5882 VARAND(I4
,0,I8
,0,I8
,0);
5883 VARAND(I4
,-1,UI8
,0,I4
,0);
5884 VARAND(I4
,0,UI8
,0,I4
,0);
5886 VARAND(I4
,-1,INT
,-1,I4
,-1);
5887 VARAND(I4
,-1,INT
,0,I4
,0);
5888 VARAND(I4
,0,INT
,0,I4
,0);
5889 VARAND(I4
,-1,UINT
,0xffffffff,I4
,-1);
5890 VARAND(I4
,-1,UINT
,0,I4
,0);
5891 VARAND(I4
,0,UINT
,0,I4
,0);
5892 VARAND(I4
,0,BSTR
,false_str
,I4
,0);
5893 VARAND(I4
,-1,BSTR
,false_str
,I4
,0);
5894 VARAND(I4
,0,BSTR
,true_str
,I4
,0);
5895 VARAND(I4
,-1,BSTR
,true_str
,I4
,-1);
5896 VARANDCY(I4
,-1,10000,I4
,1);
5897 VARANDCY(I4
,-1,0,I4
,0);
5898 VARANDCY(I4
,0,0,I4
,0);
5900 VARAND(UI4
,0xffffffff,UI4
,0xffffffff,I4
,-1);
5901 VARAND(UI4
,0xffffffff,UI4
,0,I4
,0);
5902 VARAND(UI4
,0,UI4
,0,I4
,0);
5903 VARAND(UI4
,0xffffffff,R4
,-1,I4
,-1);
5904 VARAND(UI4
,0xffffffff,R4
,0,I4
,0);
5905 VARAND(UI4
,0,R4
,0,I4
,0);
5906 VARAND(UI4
,0xffffffff,R8
,-1,I4
,-1);
5907 VARAND(UI4
,0xffffffff,R8
,0,I4
,0);
5908 VARAND(UI4
,0,R8
,0,I4
,0);
5909 VARAND(UI4
,0xffffffff,DATE
,-1,I4
,-1);
5910 VARAND(UI4
,0xffffffff,DATE
,0,I4
,0);
5911 VARAND(UI4
,0,DATE
,0,I4
,0);
5912 if (HAVE_OLEAUT32_I8
)
5914 VARAND(UI4
,0xffffffff,I8
,0,I8
,0);
5915 VARAND(UI4
,0,I8
,0,I8
,0);
5916 VARAND(UI4
,0xffffffff,UI8
,0,I4
,0);
5917 VARAND(UI4
,0,UI8
,0,I4
,0);
5919 VARAND(UI4
,0xffffffff,INT
,-1,I4
,-1);
5920 VARAND(UI4
,0xffffffff,INT
,0,I4
,0);
5921 VARAND(UI4
,0,INT
,0,I4
,0);
5922 VARAND(UI4
,0xffffffff,UINT
,0xffffffff,I4
,-1);
5923 VARAND(UI4
,0xffffffff,UINT
,0,I4
,0);
5924 VARAND(UI4
,0,UINT
,0,I4
,0);
5925 VARAND(UI4
,0,BSTR
,false_str
,I4
,0);
5926 VARAND(UI4
,0xffffffff,BSTR
,false_str
,I4
,0);
5927 VARAND(UI4
,0,BSTR
,true_str
,I4
,0);
5928 VARAND(UI4
,0xffffffff,BSTR
,true_str
,I4
,-1);
5929 VARANDCY(UI4
,0xffffffff,10000,I4
,1);
5930 VARANDCY(UI4
,0xffffffff,0,I4
,0);
5931 VARANDCY(UI4
,0,0,I4
,0);
5933 VARAND(R4
,-1,R4
,-1,I4
,-1);
5934 VARAND(R4
,-1,R4
,0,I4
,0);
5935 VARAND(R4
,0,R4
,0,I4
,0);
5936 VARAND(R4
,-1,R8
,-1,I4
,-1);
5937 VARAND(R4
,-1,R8
,0,I4
,0);
5938 VARAND(R4
,0,R8
,0,I4
,0);
5939 VARAND(R4
,-1,DATE
,-1,I4
,-1);
5940 VARAND(R4
,-1,DATE
,0,I4
,0);
5941 VARAND(R4
,0,DATE
,0,I4
,0);
5942 if (HAVE_OLEAUT32_I8
)
5944 VARAND(R4
,-1,I8
,-1,I8
,-1);
5945 VARAND(R4
,-1,I8
,0,I8
,0);
5946 VARAND(R4
,0,I8
,0,I8
,0);
5947 VARAND(R4
,-1,UI8
,0,I4
,0);
5948 VARAND(R4
,0,UI8
,0,I4
,0);
5950 VARAND(R4
,-1,INT
,-1,I4
,-1);
5951 VARAND(R4
,-1,INT
,0,I4
,0);
5952 VARAND(R4
,0,INT
,0,I4
,0);
5953 VARAND(R4
,-1,UINT
,0xffffffff,I4
,-1);
5954 VARAND(R4
,-1,UINT
,0,I4
,0);
5955 VARAND(R4
,0,UINT
,0,I4
,0);
5956 VARAND(R4
,0,BSTR
,false_str
,I4
,0);
5957 VARAND(R4
,-1,BSTR
,false_str
,I4
,0);
5958 VARAND(R4
,0,BSTR
,true_str
,I4
,0);
5959 VARAND(R4
,-1,BSTR
,true_str
,I4
,-1);
5960 VARANDCY(R4
,-1,10000,I4
,1);
5961 VARANDCY(R4
,-1,0,I4
,0);
5962 VARANDCY(R4
,0,0,I4
,0);
5964 VARAND(R8
,-1,R8
,-1,I4
,-1);
5965 VARAND(R8
,-1,R8
,0,I4
,0);
5966 VARAND(R8
,0,R8
,0,I4
,0);
5967 VARAND(R8
,-1,DATE
,-1,I4
,-1);
5968 VARAND(R8
,-1,DATE
,0,I4
,0);
5969 VARAND(R8
,0,DATE
,0,I4
,0);
5970 if (HAVE_OLEAUT32_I8
)
5972 VARAND(R8
,-1,I8
,-1,I8
,-1);
5973 VARAND(R8
,-1,I8
,0,I8
,0);
5974 VARAND(R8
,0,I8
,0,I8
,0);
5975 VARAND(R8
,-1,UI8
,0,I4
,0);
5976 VARAND(R8
,0,UI8
,0,I4
,0);
5978 VARAND(R8
,-1,INT
,-1,I4
,-1);
5979 VARAND(R8
,-1,INT
,0,I4
,0);
5980 VARAND(R8
,0,INT
,0,I4
,0);
5981 VARAND(R8
,-1,UINT
,0xffffffff,I4
,-1);
5982 VARAND(R8
,-1,UINT
,0,I4
,0);
5983 VARAND(R8
,0,UINT
,0,I4
,0);
5984 VARAND(R8
,0,BSTR
,false_str
,I4
,0);
5985 VARAND(R8
,-1,BSTR
,false_str
,I4
,0);
5986 VARAND(R8
,0,BSTR
,true_str
,I4
,0);
5987 VARAND(R8
,-1,BSTR
,true_str
,I4
,-1);
5988 VARANDCY(R8
,-1,10000,I4
,1);
5989 VARANDCY(R8
,-1,0,I4
,0);
5990 VARANDCY(R8
,0,0,I4
,0);
5992 VARAND(DATE
,-1,DATE
,-1,I4
,-1);
5993 VARAND(DATE
,-1,DATE
,0,I4
,0);
5994 VARAND(DATE
,0,DATE
,0,I4
,0);
5995 if (HAVE_OLEAUT32_I8
)
5997 VARAND(DATE
,-1,I8
,-1,I8
,-1);
5998 VARAND(DATE
,-1,I8
,0,I8
,0);
5999 VARAND(DATE
,0,I8
,0,I8
,0);
6000 VARAND(DATE
,-1,UI8
,0,I4
,0);
6001 VARAND(DATE
,0,UI8
,0,I4
,0);
6003 VARAND(DATE
,-1,INT
,-1,I4
,-1);
6004 VARAND(DATE
,-1,INT
,0,I4
,0);
6005 VARAND(DATE
,0,INT
,0,I4
,0);
6006 VARAND(DATE
,-1,UINT
,0xffffffff,I4
,-1);
6007 VARAND(DATE
,-1,UINT
,0,I4
,0);
6008 VARAND(DATE
,0,UINT
,0,I4
,0);
6009 VARAND(DATE
,0,BSTR
,false_str
,I4
,0);
6010 VARAND(DATE
,-1,BSTR
,false_str
,I4
,0);
6011 VARAND(DATE
,0,BSTR
,true_str
,I4
,0);
6012 VARAND(DATE
,-1,BSTR
,true_str
,I4
,-1);
6013 VARANDCY(DATE
,-1,10000,I4
,1);
6014 VARANDCY(DATE
,-1,0,I4
,0);
6015 VARANDCY(DATE
,0,0,I4
,0);
6017 if (HAVE_OLEAUT32_I8
)
6019 VARAND(I8
,-1,I8
,-1,I8
,-1);
6020 VARAND(I8
,-1,I8
,0,I8
,0);
6021 VARAND(I8
,0,I8
,0,I8
,0);
6022 VARAND(I8
,-1,UI8
,0,I8
,0);
6023 VARAND(I8
,0,UI8
,0,I8
,0);
6024 VARAND(I8
,-1,UINT
,0,I8
,0);
6025 VARAND(I8
,0,UINT
,0,I8
,0);
6026 VARAND(I8
,0,BSTR
,false_str
,I8
,0);
6027 VARAND(I8
,-1,BSTR
,false_str
,I8
,0);
6028 VARAND(I8
,0,BSTR
,true_str
,I8
,0);
6029 VARAND(I8
,-1,BSTR
,true_str
,I8
,-1);
6030 VARANDCY(I8
,-1,10000,I8
,1);
6031 VARANDCY(I8
,-1,0,I8
,0);
6032 VARANDCY(I8
,0,0,I8
,0);
6034 VARAND(UI8
,0xffff,UI8
,0xffff,I4
,0xffff);
6035 VARAND(UI8
,0xffff,UI8
,0,I4
,0);
6036 VARAND(UI8
,0,UI8
,0,I4
,0);
6037 VARAND(UI8
,0xffff,INT
,-1,I4
,65535);
6038 VARAND(UI8
,0xffff,INT
,0,I4
,0);
6039 VARAND(UI8
,0,INT
,0,I4
,0);
6040 VARAND(UI8
,0xffff,UINT
,0xffff,I4
,0xffff);
6041 VARAND(UI8
,0xffff,UINT
,0,I4
,0);
6042 VARAND(UI8
,0,UINT
,0,I4
,0);
6043 VARAND(UI8
,0,BSTR
,false_str
,I4
,0);
6044 VARAND(UI8
,0xffff,BSTR
,false_str
,I4
,0);
6045 VARAND(UI8
,0,BSTR
,true_str
,I4
,0);
6046 VARAND(UI8
,0xffff,BSTR
,true_str
,I4
,65535);
6047 VARANDCY(UI8
,0xffff,10000,I4
,1);
6048 VARANDCY(UI8
,0xffff,0,I4
,0);
6049 VARANDCY(UI8
,0,0,I4
,0);
6052 VARAND(INT
,-1,INT
,-1,I4
,-1);
6053 VARAND(INT
,-1,INT
,0,I4
,0);
6054 VARAND(INT
,0,INT
,0,I4
,0);
6055 VARAND(INT
,-1,UINT
,0xffff,I4
,65535);
6056 VARAND(INT
,-1,UINT
,0,I4
,0);
6057 VARAND(INT
,0,UINT
,0,I4
,0);
6058 VARAND(INT
,0,BSTR
,false_str
,I4
,0);
6059 VARAND(INT
,-1,BSTR
,false_str
,I4
,0);
6060 VARAND(INT
,0,BSTR
,true_str
,I4
,0);
6061 VARAND(INT
,-1,BSTR
,true_str
,I4
,-1);
6062 VARANDCY(INT
,-1,10000,I4
,1);
6063 VARANDCY(INT
,-1,0,I4
,0);
6064 VARANDCY(INT
,0,0,I4
,0);
6066 VARAND(UINT
,0xffff,UINT
,0xffff,I4
,0xffff);
6067 VARAND(UINT
,0xffff,UINT
,0,I4
,0);
6068 VARAND(UINT
,0,UINT
,0,I4
,0);
6069 VARAND(UINT
,0,BSTR
,false_str
,I4
,0);
6070 VARAND(UINT
,0xffff,BSTR
, false_str
,I4
,0);
6071 VARAND(UINT
,0,BSTR
,true_str
,I4
,0);
6072 VARAND(UINT
,0xffff,BSTR
,true_str
,I4
,65535);
6073 VARANDCY(UINT
,0xffff,10000,I4
,1);
6074 VARANDCY(UINT
,0xffff,0,I4
,0);
6075 VARANDCY(UINT
,0,0,I4
,0);
6077 VARAND(BSTR
,false_str
,BSTR
,false_str
,BOOL
,0);
6078 VARAND(BSTR
,true_str
,BSTR
,false_str
,BOOL
,VARIANT_FALSE
);
6079 VARAND(BSTR
,true_str
,BSTR
,true_str
,BOOL
,VARIANT_TRUE
);
6080 VARANDCY(BSTR
,true_str
,10000,I4
,1);
6081 VARANDCY(BSTR
,false_str
,10000,I4
,0);
6083 SysFreeString(true_str
);
6084 SysFreeString(false_str
);
6087 static HRESULT (WINAPI
*pVarCmp
)(LPVARIANT
,LPVARIANT
,LCID
,ULONG
);
6089 static void test_cmp( int line
, LCID lcid
, UINT flags
, VARIANT
*left
, VARIANT
*right
, HRESULT result
)
6093 hres
= pVarCmp(left
,right
,lcid
,flags
);
6094 ok_(__FILE__
,line
)(hres
== result
, "VarCmp(%s,%s): expected 0x%x, got hres=0x%x\n",
6095 variantstr(left
), variantstr(right
), result
, hres
);
6097 static void test_cmpex( int line
, LCID lcid
, VARIANT
*left
, VARIANT
*right
,
6098 HRESULT res1
, HRESULT res2
, HRESULT res3
, HRESULT res4
)
6100 test_cmp( line
, lcid
, 0, left
, right
, res1
);
6101 V_VT(left
) |= VT_RESERVED
;
6102 test_cmp( line
, lcid
, 0, left
, right
, res2
);
6103 V_VT(left
) &= ~VT_RESERVED
;
6104 V_VT(right
) |= VT_RESERVED
;
6105 test_cmp( line
, lcid
, 0, left
, right
, res3
);
6106 V_VT(left
) |= VT_RESERVED
;
6107 test_cmp( line
, lcid
, 0, left
, right
, res4
);
6108 ok_(__FILE__
,line
)(V_VT(left
) & V_VT(right
) & VT_RESERVED
, "VT_RESERVED filtered out\n");
6111 /* ERROR from wingdi.h is interfering here */
6113 #define _VARCMP(vt1,val1,vtfl1,vt2,val2,vtfl2,lcid,flags,result) \
6114 V_##vt1(&left) = val1; V_VT(&left) = VT_##vt1 | vtfl1; \
6115 V_##vt2(&right) = val2; V_VT(&right) = VT_##vt2 | vtfl2; \
6116 test_cmp( __LINE__, lcid, flags, &left, &right, result );
6117 #define VARCMPEX(vt1,val1,vt2,val2,res1,res2,res3,res4) \
6118 V_##vt1(&left) = val1; V_VT(&left) = VT_##vt1; \
6119 V_##vt2(&right) = val2; V_VT(&right) = VT_##vt2; \
6120 test_cmpex( __LINE__, lcid, &left, &right, res1, res2, res3, res4 );
6121 #define VARCMP(vt1,val1,vt2,val2,result) \
6122 VARCMPEX(vt1,val1,vt2,val2,result,result,result,result)
6123 /* The above macros do not work for VT_NULL as NULL gets expanded first */
6124 #define V_NULL_ V_NULL
6125 #define VT_NULL_ VT_NULL
6127 static void test_VarCmp(void)
6129 VARIANT left
, right
;
6134 static const WCHAR szhuh
[] = {'h','u','h','?','\0'};
6135 static const WCHAR sz2cents
[] = {'2','c','e','n','t','s','\0'};
6136 static const WCHAR szempty
[] = {'\0'};
6137 static const WCHAR sz0
[] = {'0','\0'};
6138 static const WCHAR sz1
[] = {'1','\0'};
6139 static const WCHAR sz7
[] = {'7','\0'};
6140 static const WCHAR sz42
[] = {'4','2','\0'};
6141 static const WCHAR sz1neg
[] = {'-','1','\0'};
6142 static const WCHAR sz666neg
[] = {'-','6','6','6','\0'};
6143 static const WCHAR sz1few
[] = {'1','.','0','0','0','0','0','0','0','1','\0'};
6144 BSTR bstrhuh
, bstrempty
, bstr0
, bstr1
, bstr7
, bstr42
, bstr1neg
, bstr666neg
;
6145 BSTR bstr2cents
, bstr1few
;
6149 lcid
= MAKELCID(MAKELANGID(LANG_ENGLISH
,SUBLANG_ENGLISH_US
),SORT_DEFAULT
);
6150 bstrempty
= SysAllocString(szempty
);
6151 bstrhuh
= SysAllocString(szhuh
);
6152 bstr2cents
= SysAllocString(sz2cents
);
6153 bstr0
= SysAllocString(sz0
);
6154 bstr1
= SysAllocString(sz1
);
6155 bstr7
= SysAllocString(sz7
);
6156 bstr42
= SysAllocString(sz42
);
6157 bstr1neg
= SysAllocString(sz1neg
);
6158 bstr666neg
= SysAllocString(sz666neg
);
6159 bstr1few
= SysAllocString(sz1few
);
6161 /* Test all possible flag/vt combinations & the resulting vt type */
6162 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
6164 VARTYPE leftvt
, rightvt
;
6166 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
6171 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
6174 HRESULT expect
= VARCMP_EQ
;
6178 memset(&left
, 0, sizeof(left
));
6179 memset(&right
, 0, sizeof(right
));
6180 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
6181 if (leftvt
== VT_BSTR
) {
6182 V_BSTR(&left
) = bstr1neg
;
6183 if (ExtraFlags
[i
] & VT_RESERVED
)
6188 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
6189 if (rightvt
== VT_BSTR
) {
6190 V_BSTR(&right
) = bstr1neg
;
6191 if (ExtraFlags
[i
] & VT_RESERVED
)
6197 /* Don't ask me why but native VarCmp cannot handle:
6198 VT_I1, VT_UI2, VT_UI4, VT_UINT and VT_UI8.
6199 VT_INT is only supported as left variant. Go figure.
6200 Tested with DCOM98, Win2k, WinXP */
6201 if (ExtraFlags
[i
] & VT_ARRAY
|| ExtraFlags
[i
] & VT_BYREF
||
6202 !IsValidVariantClearVT(leftvt
, ExtraFlags
[i
] & ~VT_RESERVED
) ||
6203 !IsValidVariantClearVT(rightvt
, ExtraFlags
[i
] & ~VT_RESERVED
) ||
6204 leftvt
== VT_CLSID
|| rightvt
== VT_CLSID
||
6205 leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
||
6206 leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
||
6207 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
||
6208 leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
||
6209 leftvt
== VT_VARIANT
|| rightvt
== VT_VARIANT
||
6210 leftvt
== VT_I1
|| rightvt
== VT_I1
||
6211 leftvt
== VT_UI2
|| rightvt
== VT_UI2
||
6212 leftvt
== VT_UI4
|| rightvt
== VT_UI4
||
6213 leftvt
== VT_UI8
|| rightvt
== VT_UI8
||
6214 rightvt
== VT_INT
||
6215 leftvt
== VT_UINT
|| rightvt
== VT_UINT
) {
6219 if (leftvt
== VT_ERROR
&& rightvt
== VT_ERROR
&&
6220 !(ExtraFlags
[i
] & ~VT_RESERVED
)) {
6223 } else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
6224 expect
= VARCMP_NULL
;
6225 else if (leftvt
== VT_BSTR
&& rightvt
== VT_BSTR
)
6227 else if (leftvt
== VT_BSTR
&& rightvt
== VT_EMPTY
)
6229 else if (leftvt
== VT_EMPTY
&& rightvt
== VT_BSTR
)
6232 hres
= pVarCmp(&left
, &right
, LOCALE_USER_DEFAULT
, 0);
6234 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
6235 "VarCmp: %d|0x%X, %d|0x%X: Expected failure, got 0x%X\n",
6236 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], hres
);
6239 "VarCmp: %d|0x%X, %d|0x%X: Expected 0x%X, got 0x%X\n",
6240 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], expect
,
6247 /* VARCMP{,EX} run each 4 tests with a permutation of all posible
6248 input variants with (1) and without (0) VT_RESERVED set. The order
6249 of the permutations is (0,0); (1,0); (0,1); (1,1) */
6250 VARCMP(INT
,4711,I2
,4711,VARCMP_EQ
);
6251 VARCMP(INT
,4711,I2
,-4711,VARCMP_GT
);
6252 VARCMP(ERROR
,0,ERROR
,0,VARCMP_EQ
);
6253 VARCMP(ERROR
,0,UI1
,0,DISP_E_TYPEMISMATCH
);
6254 VARCMP(EMPTY
,0,EMPTY
,0,VARCMP_EQ
);
6255 VARCMP(I4
,1,R8
,1.0,VARCMP_EQ
);
6256 VARCMP(EMPTY
,19,I2
,0,VARCMP_EQ
);
6257 ok(V_EMPTY(&left
) == 19, "VT_EMPTY modified!\n");
6258 VARCMP(I4
,1,UI1
,1,VARCMP_EQ
);
6259 VARCMP(I2
,2,I2
,2,VARCMP_EQ
);
6260 VARCMP(I2
,1,I2
,2,VARCMP_LT
);
6261 VARCMP(I2
,2,I2
,1,VARCMP_GT
);
6262 VARCMP(I2
,2,EMPTY
,1,VARCMP_GT
);
6263 VARCMP(I2
,2,NULL_
,1,VARCMP_NULL
);
6265 /* BSTR handling, especially in conjunction with VT_RESERVED */
6266 VARCMP(BSTR
,bstr0
,NULL_
,0,VARCMP_NULL
);
6267 VARCMP(BSTR
,bstr0
,BSTR
,bstr0
,VARCMP_EQ
);
6268 VARCMP(BSTR
,bstrempty
,BSTR
,bstr0
,VARCMP_LT
);
6269 VARCMP(BSTR
,bstr7
,BSTR
,bstr0
,VARCMP_GT
);
6270 VARCMP(BSTR
,bstr7
,BSTR
,bstr1neg
,VARCMP_GT
);
6271 VARCMP(BSTR
,bstr0
,BSTR
,NULL
,VARCMP_GT
);
6272 VARCMP(BSTR
,NULL
,BSTR
,NULL
,VARCMP_EQ
);
6273 VARCMP(BSTR
,bstrempty
,BSTR
,NULL
,VARCMP_EQ
);
6274 VARCMP(BSTR
,NULL
,EMPTY
,0,VARCMP_EQ
);
6275 VARCMP(EMPTY
,0,BSTR
,NULL
,VARCMP_EQ
);
6276 VARCMP(EMPTY
,0,BSTR
,bstrempty
,VARCMP_EQ
);
6277 VARCMP(EMPTY
,1,BSTR
,bstrempty
,VARCMP_EQ
);
6278 VARCMP(BSTR
,bstr0
,EMPTY
,0,VARCMP_GT
);
6279 VARCMP(BSTR
,bstr42
,EMPTY
,0,VARCMP_GT
);
6280 VARCMPEX(BSTR
,bstrempty
,UI1
,0,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
6281 VARCMPEX(BSTR
,bstrempty
,I2
,-1,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
6282 VARCMPEX(I4
,0,BSTR
,bstrempty
,VARCMP_LT
,VARCMP_LT
,VARCMP_GT
,VARCMP_LT
);
6283 VARCMPEX(BSTR
,NULL
,UI1
,0,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
6284 VARCMPEX(I4
,7,BSTR
,NULL
,VARCMP_LT
,VARCMP_LT
,VARCMP_GT
,VARCMP_LT
);
6285 _VARCMP(BSTR
,(BSTR
)100,0,I2
,100,0,lcid
,0,VARCMP_GT
);
6286 VARCMPEX(BSTR
,bstr0
,UI1
,0,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_GT
);
6287 VARCMPEX(I2
,0,BSTR
,bstr0
,VARCMP_LT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_LT
);
6288 VARCMP(BSTR
,bstrhuh
,I4
,I4_MAX
,VARCMP_GT
);
6289 VARCMP(BSTR
,bstr2cents
,I4
,2,VARCMP_GT
);
6290 VARCMPEX(BSTR
,bstr2cents
,I4
,42,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
6291 VARCMP(BSTR
,bstr2cents
,I4
,-1,VARCMP_GT
);
6292 VARCMPEX(BSTR
,bstr2cents
,I4
,-666,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
6293 VARCMPEX(BSTR
,bstr0
,I2
,0,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_GT
);
6294 VARCMPEX(BSTR
,bstr0
,I4
,0,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_GT
);
6295 VARCMPEX(BSTR
,bstr0
,I4
,-666,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
6296 VARCMP(BSTR
,bstr1
,I4
,0,VARCMP_GT
);
6297 VARCMPEX(BSTR
,bstr1
,I4
,1,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_GT
);
6298 VARCMPEX(BSTR
,bstr1
,I4
,I4_MAX
,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
,VARCMP_GT
);
6299 VARCMPEX(BSTR
,bstr1
,I4
,-1,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
6300 VARCMP(BSTR
,bstr7
,I4
,1,VARCMP_GT
);
6301 VARCMPEX(BSTR
,bstr7
,I4
,7,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_GT
);
6302 VARCMPEX(BSTR
,bstr7
,I4
,42,VARCMP_GT
,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
);
6303 VARCMPEX(BSTR
,bstr42
,I4
,7,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
6304 VARCMPEX(BSTR
,bstr42
,I4
,42,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_GT
);
6305 VARCMPEX(BSTR
,bstr42
,I4
,I4_MAX
,VARCMP_GT
,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
);
6306 VARCMPEX(BSTR
,bstr1neg
,I4
,1,VARCMP_GT
,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
);
6307 VARCMPEX(BSTR
,bstr1neg
,I4
,42,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
,VARCMP_LT
);
6308 VARCMPEX(BSTR
,bstr1neg
,I4
,-1,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_LT
);
6309 VARCMPEX(BSTR
,bstr1neg
,I4
,-666,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_LT
);
6310 VARCMPEX(BSTR
,bstr666neg
,I4
,1,VARCMP_GT
,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
);
6311 VARCMPEX(BSTR
,bstr666neg
,I4
,7,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
,VARCMP_LT
);
6312 VARCMPEX(BSTR
,bstr666neg
,I4
,42,VARCMP_GT
,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
);
6313 VARCMPEX(BSTR
,bstr666neg
,I4
,I4_MAX
,VARCMP_GT
,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
);
6314 VARCMPEX(BSTR
,bstr666neg
,I4
,-1,VARCMP_GT
,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
);
6315 VARCMPEX(BSTR
,bstr666neg
,I4
,-666,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_LT
);
6316 VARCMPEX(BSTR
,bstr7
,R8
,7.0,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_GT
);
6317 VARCMPEX(R8
,3.141592,BSTR
,NULL
,VARCMP_LT
,VARCMP_LT
,VARCMP_GT
,VARCMP_LT
);
6318 VARCMP(BSTR
,bstr7
,BSTR
,bstr7
,VARCMP_EQ
);
6319 VARCMP(BSTR
,bstr7
,BSTR
,bstr42
,VARCMP_GT
);
6320 VARCMP(BSTR
,bstr42
,BSTR
,bstr7
,VARCMP_LT
);
6322 /* DECIMAL handling */
6323 SETDEC(dec
,0,0,0,0);
6324 VARCMPEX(DECIMAL
,dec
,BSTR
,bstr0
,VARCMP_LT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_LT
);
6325 SETDEC64(dec
,0,0,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF); /* max DECIMAL */
6326 VARCMP(DECIMAL
,dec
,R8
,R8_MAX
,VARCMP_LT
); /* R8 has bigger range */
6327 VARCMP(DECIMAL
,dec
,DATE
,R8_MAX
,VARCMP_LT
); /* DATE has bigger range */
6328 SETDEC64(dec
,0,0x80,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF);
6329 VARCMP(DECIMAL
,dec
,R8
,-R8_MAX
,VARCMP_GT
);
6330 SETDEC64(dec
,20,0,0x5,0x6BC75E2D,0x63100001); /* 1+1e-20 */
6331 VARCMP(DECIMAL
,dec
,R8
,1,VARCMP_GT
); /* DECIMAL has higher precision */
6333 /* Show that DATE is handled just as a R8 */
6334 VARCMP(DATE
,DATE_MAX
,DATE
,DATE_MAX
+1,VARCMP_LT
);
6335 VARCMP(DATE
,DATE_MIN
,DATE
,DATE_MIN
-1,VARCMP_GT
);
6336 VARCMP(DATE
,R8_MIN
,R8
,R8_MIN
,VARCMP_EQ
);
6337 VARCMP(DATE
,1,DATE
,1+1e-15,VARCMP_LT
); /* 1e-15 == 8.64e-11 seconds */
6338 VARCMP(DATE
,25570.0,DATE
,25570.0,VARCMP_EQ
);
6339 VARCMP(DATE
,25570.0,DATE
,25571.0,VARCMP_LT
);
6340 VARCMP(DATE
,25571.0,DATE
,25570.0,VARCMP_GT
);
6341 VARCMP(DATE
,25570.0,EMPTY
,0,VARCMP_GT
);
6342 VARCMP(DATE
,25570.0,NULL_
,0,VARCMP_NULL
);
6344 /* R4 precision handling */
6345 VARCMP(R4
,1,R8
,1+1e-8,VARCMP_EQ
);
6346 VARCMP(R8
,1+1e-8,R4
,1,VARCMP_EQ
);
6347 VARCMP(R8
,1+1e-8,R8
,1,VARCMP_GT
);
6348 VARCMP(R8
,R4_MAX
*1.1,R4
,R4_MAX
,VARCMP_GT
);
6349 VARCMP(R4
,R4_MAX
,R8
,R8_MAX
,VARCMP_LT
);
6350 VARCMP(R4
,1,DATE
,1+1e-8,VARCMP_EQ
);
6351 VARCMP(R4
,1,BSTR
,bstr1few
,VARCMP_LT
); /* bstr1few == 1+1e-8 */
6352 SETDEC(dec
,8,0,0,0x5F5E101); /* 1+1e-8 */
6353 VARCMP(R4
,1,DECIMAL
,dec
,VARCMP_LT
);
6355 SysFreeString(bstrhuh
);
6356 SysFreeString(bstrempty
);
6357 SysFreeString(bstr0
);
6358 SysFreeString(bstr1
);
6359 SysFreeString(bstr7
);
6360 SysFreeString(bstr42
);
6361 SysFreeString(bstr1neg
);
6362 SysFreeString(bstr666neg
);
6363 SysFreeString(bstr2cents
);
6364 SysFreeString(bstr1few
);
6367 static HRESULT (WINAPI
*pVarPow
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
6369 #define VARPOW(vt1,val1,vt2,val2,rvt,rval) \
6370 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
6371 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
6372 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
6373 test_var_call2( __LINE__, pVarPow, &left, &right, &exp );
6375 /* Skip any type that is not defined or produces a error for every case */
6376 #define SKIPTESTPOW(a) \
6377 if (a == VT_ERROR || a == VT_VARIANT || \
6378 a == VT_DISPATCH || a == VT_UNKNOWN || \
6379 a == VT_RECORD || a > VT_UINT || \
6380 a == 15 /*not defined*/) \
6383 static void test_VarPow(void)
6385 static const WCHAR str2
[] = { '2','\0' };
6386 static const WCHAR str3
[] = { '3','\0' };
6387 VARIANT left
, right
, exp
, result
, cy
, dec
;
6388 BSTR num2_str
, num3_str
;
6394 num2_str
= SysAllocString(str2
);
6395 num3_str
= SysAllocString(str3
);
6397 /* Test all possible flag/vt combinations & the resulting vt type */
6398 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
6400 VARTYPE leftvt
, rightvt
, resvt
;
6402 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
6404 SKIPTESTPOW(leftvt
);
6406 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
6409 SKIPTESTPOW(rightvt
);
6411 /* Native crashes with VT_BYREF */
6412 if (ExtraFlags
[i
] == VT_BYREF
)
6415 memset(&left
, 0, sizeof(left
));
6416 memset(&right
, 0, sizeof(right
));
6417 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
6418 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
6419 V_VT(&result
) = VT_EMPTY
;
6422 if (leftvt
== VT_BSTR
)
6423 V_BSTR(&left
) = num2_str
;
6424 if (rightvt
== VT_BSTR
)
6425 V_BSTR(&right
) = num2_str
;
6427 /* Native VarPow always returns a error when using any extra flags */
6428 if (ExtraFlags
[i
] != 0)
6431 /* Determine return type */
6432 else if ((leftvt
== VT_NULL
|| rightvt
== VT_NULL
) &&
6433 ((leftvt
!= VT_I8
&& leftvt
!= VT_UI8
&&
6434 rightvt
!= VT_I8
&& rightvt
!= VT_UI8
) || HAVE_OLEAUT32_I8
))
6436 else if ((leftvt
== VT_EMPTY
|| leftvt
== VT_I2
||
6437 leftvt
== VT_I4
|| leftvt
== VT_R4
||
6438 leftvt
== VT_R8
|| leftvt
== VT_CY
||
6439 leftvt
== VT_DATE
|| leftvt
== VT_BSTR
||
6440 leftvt
== VT_BOOL
|| leftvt
== VT_DECIMAL
||
6441 (leftvt
>= VT_I1
&& leftvt
<= VT_UI4
) ||
6442 (HAVE_OLEAUT32_I8
&& (leftvt
== VT_I8
|| leftvt
== VT_UI8
)) ||
6443 leftvt
== VT_INT
|| leftvt
== VT_UINT
) &&
6444 (rightvt
== VT_EMPTY
|| rightvt
== VT_I2
||
6445 rightvt
== VT_I4
|| rightvt
== VT_R4
||
6446 rightvt
== VT_R8
|| rightvt
== VT_CY
||
6447 rightvt
== VT_DATE
|| rightvt
== VT_BSTR
||
6448 rightvt
== VT_BOOL
|| rightvt
== VT_DECIMAL
||
6449 (rightvt
>= VT_I1
&& rightvt
<= VT_UI4
) ||
6450 (HAVE_OLEAUT32_I8
&& (rightvt
== VT_I8
|| rightvt
== VT_UI8
)) ||
6451 rightvt
== VT_INT
|| rightvt
== VT_UINT
))
6456 hres
= pVarPow(&left
, &right
, &result
);
6458 /* Check expected HRESULT and if result variant type is correct */
6460 ok (hres
== DISP_E_BADVARTYPE
|| hres
== DISP_E_TYPEMISMATCH
,
6461 "VarPow: %s|0x%X, %s|0x%X: got vt %s hr 0x%X\n",
6462 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
],
6463 vtstr(V_VT(&result
)), hres
);
6465 ok (hres
== S_OK
&& resvt
== V_VT(&result
),
6466 "VarPow: %s|0x%X, %s|0x%X: expected vt %s hr 0x%X, got vt %s hr 0x%X\n",
6467 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
], vtstr(resvt
),
6468 S_OK
, vtstr(V_VT(&result
)), hres
);
6473 /* Check return values for valid variant type combinations */
6474 VARPOW(EMPTY
,0,EMPTY
,0,R8
,1.0);
6475 VARPOW(EMPTY
,0,NULL
,0,NULL
,0);
6476 VARPOW(EMPTY
,0,I2
,3,R8
,0.0);
6477 VARPOW(EMPTY
,0,I4
,3,R8
,0.0);
6478 VARPOW(EMPTY
,0,R4
,3.0,R8
,0.0);
6479 VARPOW(EMPTY
,0,R8
,3.0,R8
,0.0);
6480 VARPOW(EMPTY
,0,DATE
,3,R8
,0.0);
6481 VARPOW(EMPTY
,0,BSTR
,num3_str
,R8
,0.0);
6482 VARPOW(EMPTY
,0,BOOL
,VARIANT_FALSE
,R8
,1.0);
6483 VARPOW(EMPTY
,0,I1
,3,R8
,0.0);
6484 VARPOW(EMPTY
,0,UI1
,3,R8
,0.0);
6485 VARPOW(EMPTY
,0,UI2
,3,R8
,0.0);
6486 VARPOW(EMPTY
,0,UI4
,3,R8
,0.0);
6487 if (HAVE_OLEAUT32_I8
)
6489 VARPOW(EMPTY
,0,I8
,3,R8
,0.0);
6490 VARPOW(EMPTY
,0,UI8
,3,R8
,0.0);
6492 VARPOW(EMPTY
,0,INT
,3,R8
,0.0);
6493 VARPOW(EMPTY
,0,UINT
,3,R8
,0.0);
6494 VARPOW(NULL
,0,EMPTY
,0,NULL
,0);
6495 VARPOW(NULL
,0,NULL
,0,NULL
,0);
6496 VARPOW(NULL
,0,I2
,3,NULL
,0);
6497 VARPOW(NULL
,0,I4
,3,NULL
,0);
6498 VARPOW(NULL
,0,R4
,3.0,NULL
,0);
6499 VARPOW(NULL
,0,R8
,3.0,NULL
,0);
6500 VARPOW(NULL
,0,DATE
,3,NULL
,0);
6501 VARPOW(NULL
,0,BSTR
,num3_str
,NULL
,0);
6502 VARPOW(NULL
,0,BOOL
,VARIANT_TRUE
,NULL
,0);
6503 VARPOW(NULL
,0,I1
,3,NULL
,0);
6504 VARPOW(NULL
,0,UI1
,3,NULL
,0);
6505 VARPOW(NULL
,0,UI2
,3,NULL
,0);
6506 VARPOW(NULL
,0,UI4
,3,NULL
,0);
6507 if (HAVE_OLEAUT32_I8
)
6509 VARPOW(NULL
,0,I8
,3,NULL
,0);
6510 VARPOW(NULL
,0,UI8
,3,NULL
,0);
6512 VARPOW(NULL
,0,INT
,3,NULL
,0);
6513 VARPOW(NULL
,0,UINT
,3,NULL
,0);
6514 VARPOW(I2
,2,EMPTY
,0,R8
,1.0);
6515 VARPOW(I2
,2,NULL
,0,NULL
,0);
6516 VARPOW(I2
,2,I2
,3,R8
,8.0);
6517 VARPOW(I2
,2,I4
,3,R8
,8.0);
6518 VARPOW(I2
,2,R4
,3.0,R8
,8.0);
6519 VARPOW(I2
,2,R8
,3.0,R8
,8.0);
6520 VARPOW(I2
,2,DATE
,3,R8
,8.0);
6521 VARPOW(I2
,2,BSTR
,num3_str
,R8
,8.0);
6522 VARPOW(I2
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6523 VARPOW(I2
,2,I1
,3,R8
,8.0);
6524 VARPOW(I2
,2,UI1
,3,R8
,8.0);
6525 VARPOW(I2
,2,UI2
,3,R8
,8.0);
6526 VARPOW(I2
,2,UI4
,3,R8
,8.0);
6527 if (HAVE_OLEAUT32_I8
)
6529 VARPOW(I2
,2,I8
,3,R8
,8.0);
6530 VARPOW(I2
,2,UI8
,3,R8
,8.0);
6532 VARPOW(I2
,2,INT
,3,R8
,8.0);
6533 VARPOW(I2
,2,UINT
,3,R8
,8.0);
6534 VARPOW(I4
,2,EMPTY
,0,R8
,1.0);
6535 VARPOW(I4
,2,NULL
,0,NULL
,0);
6536 VARPOW(I4
,2,I2
,3,R8
,8.0);
6537 VARPOW(I4
,2,I4
,3,R8
,8.0);
6538 VARPOW(I4
,2,R4
,3.0,R8
,8.0);
6539 VARPOW(I4
,2,R8
,3.0,R8
,8.0);
6540 VARPOW(I4
,2,DATE
,3,R8
,8.0);
6541 VARPOW(I4
,2,BSTR
,num3_str
,R8
,8.0);
6542 VARPOW(I4
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6543 VARPOW(I4
,2,I1
,3,R8
,8.0);
6544 VARPOW(I4
,2,UI1
,3,R8
,8.0);
6545 VARPOW(I4
,2,UI2
,3,R8
,8.0);
6546 VARPOW(I4
,2,UI4
,3,R8
,8.0);
6547 if (HAVE_OLEAUT32_I8
)
6549 VARPOW(I4
,2,I8
,3,R8
,8.0);
6550 VARPOW(I4
,2,UI8
,3,R8
,8.0);
6552 VARPOW(I4
,2,INT
,3,R8
,8.0);
6553 VARPOW(I4
,2,UINT
,3,R8
,8.0);
6554 VARPOW(R4
,2,EMPTY
,0,R8
,1.0);
6555 VARPOW(R4
,2,NULL
,0,NULL
,0);
6556 VARPOW(R4
,2,I2
,3,R8
,8.0);
6557 VARPOW(R4
,2,I4
,3,R8
,8.0);
6558 VARPOW(R4
,2,R4
,3.0,R8
,8.0);
6559 VARPOW(R4
,2,R8
,3.0,R8
,8.0);
6560 VARPOW(R4
,2,DATE
,3,R8
,8.0);
6561 VARPOW(R4
,2,BSTR
,num3_str
,R8
,8.0);
6562 VARPOW(R4
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6563 VARPOW(R4
,2,I1
,3,R8
,8.0);
6564 VARPOW(R4
,2,UI1
,3,R8
,8.0);
6565 VARPOW(R4
,2,UI2
,3,R8
,8.0);
6566 VARPOW(R4
,2,UI4
,3,R8
,8.0);
6567 if (HAVE_OLEAUT32_I8
)
6569 VARPOW(R4
,2,I8
,3,R8
,8.0);
6570 VARPOW(R4
,2,UI8
,3,R8
,8.0);
6572 VARPOW(R4
,2,INT
,3,R8
,8.0);
6573 VARPOW(R4
,2,UINT
,3,R8
,8.0);
6574 VARPOW(R8
,2,EMPTY
,0,R8
,1.0);
6575 VARPOW(R8
,2,NULL
,0,NULL
,0);
6576 VARPOW(R8
,2,I2
,3,R8
,8.0);
6577 VARPOW(R8
,2,I4
,3,R8
,8.0);
6578 VARPOW(R8
,2,R4
,3.0,R8
,8.0);
6579 VARPOW(R8
,2,R8
,3.0,R8
,8.0);
6580 VARPOW(R8
,2,DATE
,3,R8
,8.0);
6581 VARPOW(R8
,2,BSTR
,num3_str
,R8
,8.0);
6582 VARPOW(R8
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6583 VARPOW(R8
,2,I1
,3,R8
,8.0);
6584 VARPOW(R8
,2,UI1
,3,R8
,8.0);
6585 VARPOW(R8
,2,UI2
,3,R8
,8.0);
6586 VARPOW(R8
,2,UI4
,3,R8
,8.0);
6587 if (HAVE_OLEAUT32_I8
)
6589 VARPOW(R8
,2,I8
,3,R8
,8.0);
6590 VARPOW(R8
,2,UI8
,3,R8
,8.0);
6592 VARPOW(R8
,2,INT
,3,R8
,8.0);
6593 VARPOW(R8
,2,UINT
,3,R8
,8.0);
6594 VARPOW(DATE
,2,EMPTY
,0,R8
,1.0);
6595 VARPOW(DATE
,2,NULL
,0,NULL
,0);
6596 VARPOW(DATE
,2,I2
,3,R8
,8.0);
6597 VARPOW(DATE
,2,I4
,3,R8
,8.0);
6598 VARPOW(DATE
,2,R4
,3.0,R8
,8.0);
6599 VARPOW(DATE
,2,R8
,3.0,R8
,8.0);
6600 VARPOW(DATE
,2,DATE
,3,R8
,8.0);
6601 VARPOW(DATE
,2,BSTR
,num3_str
,R8
,8.0);
6602 VARPOW(DATE
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6603 VARPOW(DATE
,2,I1
,3,R8
,8.0);
6604 VARPOW(DATE
,2,UI1
,3,R8
,8.0);
6605 VARPOW(DATE
,2,UI2
,3,R8
,8.0);
6606 VARPOW(DATE
,2,UI4
,3,R8
,8.0);
6607 if (HAVE_OLEAUT32_I8
)
6609 VARPOW(DATE
,2,I8
,3,R8
,8.0);
6610 VARPOW(DATE
,2,UI8
,3,R8
,8.0);
6612 VARPOW(DATE
,2,INT
,3,R8
,8.0);
6613 VARPOW(DATE
,2,UINT
,3,R8
,8.0);
6614 VARPOW(BSTR
,num2_str
,EMPTY
,0,R8
,1.0);
6615 VARPOW(BSTR
,num2_str
,NULL
,0,NULL
,0);
6616 VARPOW(BSTR
,num2_str
,I2
,3,R8
,8.0);
6617 VARPOW(BSTR
,num2_str
,I4
,3,R8
,8.0);
6618 VARPOW(BSTR
,num2_str
,R4
,3.0,R8
,8.0);
6619 VARPOW(BSTR
,num2_str
,R8
,3.0,R8
,8.0);
6620 VARPOW(BSTR
,num2_str
,DATE
,3,R8
,8.0);
6621 VARPOW(BSTR
,num2_str
,BSTR
,num3_str
,R8
,8.0);
6622 VARPOW(BSTR
,num2_str
,BOOL
,VARIANT_FALSE
,R8
,1.0);
6623 VARPOW(BSTR
,num2_str
,I1
,3,R8
,8.0);
6624 VARPOW(BSTR
,num2_str
,UI1
,3,R8
,8.0);
6625 VARPOW(BSTR
,num2_str
,UI2
,3,R8
,8.0);
6626 VARPOW(BSTR
,num2_str
,UI4
,3,R8
,8.0);
6627 if (HAVE_OLEAUT32_I8
)
6629 VARPOW(BSTR
,num2_str
,I8
,3,R8
,8.0);
6630 VARPOW(BSTR
,num2_str
,UI8
,3,R8
,8.0);
6632 VARPOW(BSTR
,num2_str
,INT
,3,R8
,8.0);
6633 VARPOW(BSTR
,num2_str
,UINT
,3,R8
,8.0);
6634 VARPOW(BOOL
,VARIANT_TRUE
,EMPTY
,0,R8
,1.0);
6635 VARPOW(BOOL
,VARIANT_TRUE
,NULL
,0,NULL
,0);
6636 VARPOW(BOOL
,VARIANT_TRUE
,I2
,3,R8
,-1.0);
6637 VARPOW(BOOL
,VARIANT_TRUE
,I4
,3,R8
,-1.0);
6638 VARPOW(BOOL
,VARIANT_TRUE
,R4
,3.0,R8
,-1.0);
6639 VARPOW(BOOL
,VARIANT_TRUE
,R8
,3.0,R8
,-1.0);
6640 VARPOW(BOOL
,VARIANT_TRUE
,DATE
,3,R8
,-1.0);
6641 VARPOW(BOOL
,VARIANT_TRUE
,BSTR
,num3_str
,R8
,-1.0);
6642 VARPOW(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
,R8
,-1.0);
6643 VARPOW(BOOL
,VARIANT_TRUE
,I1
,3,R8
,-1.0);
6644 VARPOW(BOOL
,VARIANT_TRUE
,UI1
,3,R8
,-1.0);
6645 VARPOW(BOOL
,VARIANT_TRUE
,UI2
,3,R8
,-1.0);
6646 VARPOW(BOOL
,VARIANT_TRUE
,UI4
,3,R8
,-1.0);
6647 if (HAVE_OLEAUT32_I8
)
6649 VARPOW(BOOL
,VARIANT_TRUE
,I8
,3,R8
,-1.0);
6650 VARPOW(BOOL
,VARIANT_TRUE
,UI8
,3,R8
,-1.0);
6652 VARPOW(BOOL
,VARIANT_TRUE
,INT
,3,R8
,-1.0);
6653 VARPOW(BOOL
,VARIANT_TRUE
,UINT
,3,R8
,-1.0);
6654 VARPOW(I1
,2,EMPTY
,0,R8
,1.0);
6655 VARPOW(I1
,2,NULL
,0,NULL
,0);
6656 VARPOW(I1
,2,I2
,3,R8
,8.0);
6657 VARPOW(I1
,2,I4
,3,R8
,8.0);
6658 VARPOW(I1
,2,R4
,3.0,R8
,8.0);
6659 VARPOW(I1
,2,R8
,3.0,R8
,8.0);
6660 VARPOW(I1
,2,DATE
,3,R8
,8.0);
6661 VARPOW(I1
,2,BSTR
,num3_str
,R8
,8.0);
6662 VARPOW(I1
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6663 VARPOW(I1
,2,I1
,3,R8
,8.0);
6664 VARPOW(I1
,2,UI1
,3,R8
,8.0);
6665 VARPOW(I1
,2,UI2
,3,R8
,8.0);
6666 VARPOW(I1
,2,UI4
,3,R8
,8.0);
6667 if (HAVE_OLEAUT32_I8
)
6669 VARPOW(I1
,2,I8
,3,R8
,8.0);
6670 VARPOW(I1
,2,UI8
,3,R8
,8.0);
6672 VARPOW(I1
,2,INT
,3,R8
,8.0);
6673 VARPOW(I1
,2,UINT
,3,R8
,8.0);
6674 VARPOW(UI1
,2,EMPTY
,0,R8
,1.0);
6675 VARPOW(UI1
,2,NULL
,0,NULL
,0);
6676 VARPOW(UI1
,2,I2
,3,R8
,8.0);
6677 VARPOW(UI1
,2,I4
,3,R8
,8.0);
6678 VARPOW(UI1
,2,R4
,3.0,R8
,8.0);
6679 VARPOW(UI1
,2,R8
,3.0,R8
,8.0);
6680 VARPOW(UI1
,2,DATE
,3,R8
,8.0);
6681 VARPOW(UI1
,2,BSTR
,num3_str
,R8
,8.0);
6682 VARPOW(UI1
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6683 VARPOW(UI1
,2,I1
,3,R8
,8.0);
6684 VARPOW(UI1
,2,UI1
,3,R8
,8.0);
6685 VARPOW(UI1
,2,UI2
,3,R8
,8.0);
6686 VARPOW(UI1
,2,UI4
,3,R8
,8.0);
6687 if (HAVE_OLEAUT32_I8
)
6689 VARPOW(UI1
,2,I8
,3,R8
,8.0);
6690 VARPOW(UI1
,2,UI8
,3,R8
,8.0);
6692 VARPOW(UI1
,2,INT
,3,R8
,8.0);
6693 VARPOW(UI1
,2,UINT
,3,R8
,8.0);
6694 VARPOW(UI2
,2,EMPTY
,0,R8
,1.0);
6695 VARPOW(UI2
,2,NULL
,0,NULL
,0);
6696 VARPOW(UI2
,2,I2
,3,R8
,8.0);
6697 VARPOW(UI2
,2,I4
,3,R8
,8.0);
6698 VARPOW(UI2
,2,R4
,3.0,R8
,8.0);
6699 VARPOW(UI2
,2,R8
,3.0,R8
,8.0);
6700 VARPOW(UI2
,2,DATE
,3,R8
,8.0);
6701 VARPOW(UI2
,2,BSTR
,num3_str
,R8
,8.0);
6702 VARPOW(UI2
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6703 VARPOW(UI2
,2,I1
,3,R8
,8.0);
6704 VARPOW(UI2
,2,UI1
,3,R8
,8.0);
6705 VARPOW(UI2
,2,UI2
,3,R8
,8.0);
6706 VARPOW(UI2
,2,UI4
,3,R8
,8.0);
6707 if (HAVE_OLEAUT32_I8
)
6709 VARPOW(UI2
,2,I8
,3,R8
,8.0);
6710 VARPOW(UI2
,2,UI8
,3,R8
,8.0);
6712 VARPOW(UI2
,2,INT
,3,R8
,8.0);
6713 VARPOW(UI2
,2,UINT
,3,R8
,8.0);
6714 VARPOW(UI4
,2,EMPTY
,0,R8
,1.0);
6715 VARPOW(UI4
,2,NULL
,0,NULL
,0);
6716 VARPOW(UI4
,2,I2
,3,R8
,8.0);
6717 VARPOW(UI4
,2,I4
,3,R8
,8.0);
6718 VARPOW(UI4
,2,R4
,3.0,R8
,8.0);
6719 VARPOW(UI4
,2,R8
,3.0,R8
,8.0);
6720 VARPOW(UI4
,2,DATE
,3,R8
,8.0);
6721 VARPOW(UI4
,2,BSTR
,num3_str
,R8
,8.0);
6722 VARPOW(UI4
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6723 VARPOW(UI4
,2,I1
,3,R8
,8.0);
6724 VARPOW(UI4
,2,UI1
,3,R8
,8.0);
6725 VARPOW(UI4
,2,UI2
,3,R8
,8.0);
6726 VARPOW(UI4
,2,UI4
,3,R8
,8.0);
6727 if (HAVE_OLEAUT32_I8
)
6729 VARPOW(UI4
,2,I8
,3,R8
,8.0);
6730 VARPOW(UI4
,2,UI8
,3,R8
,8.0);
6732 VARPOW(UI4
,2,INT
,3,R8
,8.0);
6733 VARPOW(UI4
,2,UINT
,3,R8
,8.0);
6734 if (HAVE_OLEAUT32_I8
)
6736 VARPOW(I8
,2,EMPTY
,0,R8
,1.0);
6737 VARPOW(I8
,2,NULL
,0,NULL
,0);
6738 VARPOW(I8
,2,I2
,3,R8
,8.0);
6739 VARPOW(I8
,2,I4
,3,R8
,8.0);
6740 VARPOW(I8
,2,R4
,3.0,R8
,8.0);
6741 VARPOW(I8
,2,R8
,3.0,R8
,8.0);
6742 VARPOW(I8
,2,DATE
,3,R8
,8.0);
6743 VARPOW(I8
,2,BSTR
,num3_str
,R8
,8.0);
6744 VARPOW(I8
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6745 VARPOW(I8
,2,I1
,3,R8
,8.0);
6746 VARPOW(I8
,2,UI1
,3,R8
,8.0);
6747 VARPOW(I8
,2,UI2
,3,R8
,8.0);
6748 VARPOW(I8
,2,UI4
,3,R8
,8.0);
6749 VARPOW(I8
,2,I8
,3,R8
,8.0);
6750 VARPOW(I8
,2,UI8
,3,R8
,8.0);
6751 VARPOW(I8
,2,INT
,3,R8
,8.0);
6752 VARPOW(I8
,2,UINT
,3,R8
,8.0);
6753 VARPOW(UI8
,2,EMPTY
,0,R8
,1.0);
6754 VARPOW(UI8
,2,NULL
,0,NULL
,0);
6755 VARPOW(UI8
,2,I2
,3,R8
,8.0);
6756 VARPOW(UI8
,2,I4
,3,R8
,8.0);
6757 VARPOW(UI8
,2,R4
,3.0,R8
,8.0);
6758 VARPOW(UI8
,2,R8
,3.0,R8
,8.0);
6759 VARPOW(UI8
,2,DATE
,3,R8
,8.0);
6760 VARPOW(UI8
,2,BSTR
,num3_str
,R8
,8.0);
6761 VARPOW(UI8
,2,I1
,3,R8
,8.0);
6762 VARPOW(UI8
,2,UI1
,3,R8
,8.0);
6763 VARPOW(UI8
,2,UI2
,3,R8
,8.0);
6764 VARPOW(UI8
,2,UI4
,3,R8
,8.0);
6765 VARPOW(UI8
,2,I8
,3,R8
,8.0);
6766 VARPOW(UI8
,2,UI8
,3,R8
,8.0);
6767 VARPOW(UI8
,2,INT
,3,R8
,8.0);
6768 VARPOW(UI8
,2,UINT
,3,R8
,8.0);
6770 VARPOW(INT
,2,EMPTY
,0,R8
,1.0);
6771 VARPOW(INT
,2,NULL
,0,NULL
,0);
6772 VARPOW(INT
,2,I2
,3,R8
,8.0);
6773 VARPOW(INT
,2,I4
,3,R8
,8.0);
6774 VARPOW(INT
,2,R4
,3.0,R8
,8.0);
6775 VARPOW(INT
,2,R8
,3.0,R8
,8.0);
6776 VARPOW(INT
,2,DATE
,3,R8
,8.0);
6777 VARPOW(INT
,2,BSTR
,num3_str
,R8
,8.0);
6778 VARPOW(INT
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6779 VARPOW(INT
,2,I1
,3,R8
,8.0);
6780 VARPOW(INT
,2,UI1
,3,R8
,8.0);
6781 VARPOW(INT
,2,UI2
,3,R8
,8.0);
6782 VARPOW(INT
,2,UI4
,3,R8
,8.0);
6783 if (HAVE_OLEAUT32_I8
)
6785 VARPOW(INT
,2,I8
,3,R8
,8.0);
6786 VARPOW(INT
,2,UI8
,3,R8
,8.0);
6788 VARPOW(INT
,2,INT
,3,R8
,8.0);
6789 VARPOW(INT
,2,UINT
,3,R8
,8.0);
6790 VARPOW(UINT
,2,EMPTY
,0,R8
,1.0);
6791 VARPOW(UINT
,2,NULL
,0,NULL
,0);
6792 VARPOW(UINT
,2,I2
,3,R8
,8.0);
6793 VARPOW(UINT
,2,I4
,3,R8
,8.0);
6794 VARPOW(UINT
,2,R4
,3.0,R8
,8.0);
6795 VARPOW(UINT
,2,R8
,3.0,R8
,8.0);
6796 VARPOW(UINT
,2,DATE
,3,R8
,8.0);
6797 VARPOW(UINT
,2,BSTR
,num3_str
,R8
,8.0);
6798 VARPOW(UINT
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6799 VARPOW(UINT
,2,I1
,3,R8
,8.0);
6800 VARPOW(UINT
,2,UI1
,3,R8
,8.0);
6801 VARPOW(UINT
,2,UI2
,3,R8
,8.0);
6802 VARPOW(UINT
,2,UI4
,3,R8
,8.0);
6803 if (HAVE_OLEAUT32_I8
)
6805 VARPOW(UINT
,2,I8
,3,R8
,8.0);
6806 VARPOW(UINT
,2,UI8
,3,R8
,8.0);
6808 VARPOW(UINT
,2,INT
,3,R8
,8.0);
6809 VARPOW(UINT
,2,UINT
,3,R8
,8.0);
6811 /* Manually test some VT_CY, VT_DECIMAL variants */
6813 hres
= VarCyFromI4(2, &V_CY(&cy
));
6814 ok(hres
== S_OK
, "VarCyFromI4 failed!\n");
6815 V_VT(&dec
) = VT_DECIMAL
;
6816 hres
= VarDecFromR8(2.0, &V_DECIMAL(&dec
));
6817 ok(hres
== S_OK
, "VarDecFromR4 failed!\n");
6818 memset(&left
, 0, sizeof(left
));
6819 memset(&right
, 0, sizeof(right
));
6820 V_VT(&left
) = VT_I4
;
6822 V_VT(&right
) = VT_I8
;
6825 hres
= pVarPow(&cy
, &cy
, &result
);
6826 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
6827 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
6828 S_OK
, hres
, vtstr(V_VT(&result
)));
6829 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 4.0),
6830 "VARPOW: CY value %f, expected %f\n", V_R8(&result
), 4.0);
6832 hres
= pVarPow(&cy
, &right
, &result
);
6833 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
6834 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
6835 S_OK
, hres
, vtstr(V_VT(&result
)));
6836 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 4.0),
6837 "VARPOW: CY value %f, expected %f\n", V_R8(&result
), 4.0);
6839 hres
= pVarPow(&left
, &cy
, &result
);
6840 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
6841 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
6842 S_OK
, hres
, vtstr(V_VT(&result
)));
6843 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 10000.0),
6844 "VARPOW: CY value %f, expected %f\n", V_R8(&result
), 10000.0);
6846 hres
= pVarPow(&left
, &dec
, &result
);
6847 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
6848 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
6849 S_OK
, hres
, vtstr(V_VT(&result
)));
6850 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
),10000.0),
6851 "VARPOW: DECIMAL value %f, expected %f\n", V_R8(&result
), 10000.0);
6853 hres
= pVarPow(&dec
, &dec
, &result
);
6854 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
6855 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
6856 S_OK
, hres
, vtstr(V_VT(&result
)));
6857 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 4.0),
6858 "VARPOW: DECIMAL value %f, expected %f\n", V_R8(&result
), 4.0);
6860 hres
= pVarPow(&dec
, &right
, &result
);
6861 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
6862 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type%s!\n",
6863 S_OK
, hres
, vtstr(V_VT(&result
)));
6864 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 4.0),
6865 "VARPOW: DECIMAL value %f, expected %f\n", V_R8(&result
), 4.0);
6867 SysFreeString(num2_str
);
6868 SysFreeString(num3_str
);
6871 static HRESULT (WINAPI
*pVarDiv
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
6873 #define VARDIV(vt1,val1,vt2,val2,rvt,rval) \
6874 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
6875 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
6876 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
6877 test_var_call2( __LINE__, pVarDiv, &left, &right, &exp );
6879 /* Skip any type that is not defined or produces a error for every case */
6880 #define SKIPTESTDIV(a) \
6881 if (a == VT_ERROR || a == VT_VARIANT || \
6882 a == VT_DISPATCH || a == VT_UNKNOWN || \
6883 a == VT_RECORD || a > VT_UINT || \
6884 a == VT_I1 || a == VT_UI8 || \
6885 a == VT_INT || a == VT_UINT || \
6886 a == VT_UI2 || a == VT_UI4 || \
6887 a == 15 /*not defined*/) \
6890 static void test_VarDiv(void)
6892 static const WCHAR str1
[] = { '1','\0' };
6893 static const WCHAR str2
[] = { '2','\0' };
6894 VARIANT left
, right
, exp
, result
, cy
, dec
;
6895 BSTR num1_str
, num2_str
;
6897 HRESULT hres
, expectedhres
;
6900 num1_str
= SysAllocString(str1
);
6901 num2_str
= SysAllocString(str2
);
6905 /* Test all possible flag/vt combinations & the resulting vt type */
6906 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
6908 VARTYPE leftvt
, rightvt
, resvt
;
6910 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
6912 SKIPTESTDIV(leftvt
);
6914 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
6917 SKIPTESTDIV(rightvt
);
6919 /* Native crashes with VT_BYREF */
6920 if (ExtraFlags
[i
] == VT_BYREF
)
6923 memset(&left
, 0, sizeof(left
));
6924 memset(&right
, 0, sizeof(right
));
6925 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
6926 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
6927 V_VT(&result
) = VT_EMPTY
;
6929 expectedhres
= S_OK
;
6931 if (leftvt
== VT_BSTR
)
6932 V_BSTR(&left
) = num2_str
;
6933 else if (leftvt
== VT_DECIMAL
)
6935 VarDecFromR8(2.0, &V_DECIMAL(&left
));
6936 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
6939 /* Division by 0 is undefined */
6943 V_BSTR(&right
) = num2_str
;
6946 VarDecFromR8(2.0, &V_DECIMAL(&right
));
6947 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
6950 V_BOOL(&right
) = VARIANT_TRUE
;
6952 case VT_I2
: V_I2(&right
) = 2; break;
6953 case VT_I4
: V_I4(&right
) = 2; break;
6954 case VT_R4
: V_R4(&right
) = 2.0; break;
6955 case VT_R8
: V_R8(&right
) = 2.0; break;
6956 case VT_CY
: V_CY(&right
).int64
= 2; break;
6957 case VT_DATE
: V_DATE(&right
) = 2; break;
6958 case VT_UI1
: V_UI1(&right
) = 2; break;
6959 case VT_I8
: V_I8(&right
) = 2; break;
6963 /* Determine return type */
6964 if (!(rightvt
== VT_EMPTY
))
6966 if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
6968 else if (leftvt
== VT_DECIMAL
|| rightvt
== VT_DECIMAL
)
6970 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
||
6971 leftvt
== VT_CY
|| rightvt
== VT_CY
||
6972 leftvt
== VT_DATE
|| rightvt
== VT_DATE
||
6973 leftvt
== VT_I4
|| rightvt
== VT_I4
||
6974 leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
||
6975 leftvt
== VT_I2
|| rightvt
== VT_I2
||
6976 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
||
6977 leftvt
== VT_R8
|| rightvt
== VT_R8
||
6978 leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
6980 if ((leftvt
== VT_UI1
&& rightvt
== VT_R4
) ||
6981 (leftvt
== VT_R4
&& rightvt
== VT_UI1
))
6983 else if ((leftvt
== VT_R4
&& (rightvt
== VT_BOOL
||
6984 rightvt
== VT_I2
)) || (rightvt
== VT_R4
&&
6985 (leftvt
== VT_BOOL
|| leftvt
== VT_I2
)))
6990 else if (leftvt
== VT_R4
|| rightvt
== VT_R4
)
6993 else if (leftvt
== VT_NULL
&& rightvt
== VT_EMPTY
)
6998 /* Native VarDiv always returns a error when using any extra flags */
6999 if (ExtraFlags
[i
] != 0)
7002 hres
= pVarDiv(&left
, &right
, &result
);
7004 /* Check expected HRESULT and if result variant type is correct */
7006 ok (hres
== DISP_E_BADVARTYPE
|| hres
== DISP_E_TYPEMISMATCH
||
7007 hres
== DISP_E_OVERFLOW
|| hres
== DISP_E_DIVBYZERO
,
7008 "VarDiv: %s|0x%X, %s|0x%X: got vt %s hr 0x%X\n",
7009 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
],
7010 vtstr(V_VT(&result
)), hres
);
7012 ok (hres
== S_OK
&& resvt
== V_VT(&result
),
7013 "VarDiv: %s|0x%X, %s|0x%X: expected vt %s hr 0x%X, got vt %s hr 0x%X\n",
7014 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
], vtstr(resvt
),
7015 S_OK
, vtstr(V_VT(&result
)), hres
);
7020 /* Test return values for all the good cases */
7021 VARDIV(EMPTY
,0,NULL
,0,NULL
,0);
7022 VARDIV(EMPTY
,0,I2
,2,R8
,0.0);
7023 VARDIV(EMPTY
,0,I4
,2,R8
,0.0);
7024 VARDIV(EMPTY
,0,R4
,2.0,R4
,0.0);
7025 VARDIV(EMPTY
,0,R8
,2.0,R8
,0.0);
7026 VARDIV(EMPTY
,0,DATE
,2.0,R8
,0.0);
7027 VARDIV(EMPTY
,0,BSTR
,num2_str
,R8
,0.0);
7028 VARDIV(EMPTY
,0,BOOL
,VARIANT_TRUE
,R8
,0.0);
7029 VARDIV(EMPTY
,0,UI1
,2,R8
,0.0);
7030 VARDIV(EMPTY
,0,I8
,2,R8
,0.0);
7031 VARDIV(NULL
,0,EMPTY
,0,NULL
,0);
7032 VARDIV(NULL
,0,NULL
,0,NULL
,0);
7033 VARDIV(NULL
,0,I2
,2,NULL
,0);
7034 VARDIV(NULL
,0,I4
,2,NULL
,0);
7035 VARDIV(NULL
,0,R4
,2.0,NULL
,0);
7036 VARDIV(NULL
,0,R8
,2.0,NULL
,0);
7037 VARDIV(NULL
,0,DATE
,2,NULL
,0);
7038 VARDIV(NULL
,0,BSTR
,num2_str
,NULL
,0);
7039 VARDIV(NULL
,0,BOOL
,VARIANT_TRUE
,NULL
,0);
7040 VARDIV(NULL
,0,UI1
,2,NULL
,0);
7041 VARDIV(NULL
,0,I8
,2,NULL
,0);
7042 VARDIV(I2
,2,NULL
,0,NULL
,0);
7043 VARDIV(I2
,1,I2
,2,R8
,0.5);
7044 VARDIV(I2
,1,I4
,2,R8
,0.5);
7045 VARDIV(I2
,1,R4
,2,R4
,0.5);
7046 VARDIV(I2
,1,R8
,2.0,R8
,0.5);
7047 VARDIV(I2
,1,DATE
,2,R8
,0.5);
7048 VARDIV(I2
,1,BOOL
,VARIANT_TRUE
,R8
,-1.0);
7049 VARDIV(I2
,1,UI1
,2,R8
,0.5);
7050 VARDIV(I2
,1,I8
,2,R8
,0.5);
7051 VARDIV(I4
,1,NULL
,0,NULL
,0);
7052 VARDIV(I4
,1,I2
,2,R8
,0.5);
7053 VARDIV(I4
,1,I4
,2,R8
,0.5);
7054 VARDIV(I4
,1,R4
,2.0,R8
,0.5);
7055 VARDIV(I4
,1,R8
,2.0,R8
,0.5);
7056 VARDIV(I4
,1,DATE
,2,R8
,0.5);
7057 VARDIV(I4
,1,BSTR
,num2_str
,R8
,0.5);
7058 VARDIV(I4
,1,BOOL
,VARIANT_TRUE
,R8
,-1.0);
7059 VARDIV(I4
,1,UI1
,2,R8
,0.5);
7060 VARDIV(I4
,1,I8
,2.0,R8
,0.5);
7061 VARDIV(R4
,1.0,NULL
,0,NULL
,0);
7062 VARDIV(R4
,1.0,I2
,2,R4
,0.5);
7063 VARDIV(R4
,1.0,I4
,2,R8
,0.5);
7064 VARDIV(R4
,1.0,R4
,2.0,R4
,0.5);
7065 VARDIV(R4
,1.0,R8
,2.0,R8
,0.5);
7066 VARDIV(R4
,1.0,DATE
,2,R8
,0.5);
7067 VARDIV(R4
,1.0,BSTR
,num2_str
,R8
,0.5);
7068 VARDIV(R4
,1.0,BOOL
,VARIANT_TRUE
,R4
,-1);
7069 VARDIV(R4
,1.0,UI1
,2,R4
,0.5);
7070 VARDIV(R4
,1.0,I8
,2,R8
,0.5);
7071 VARDIV(R8
,1.0,NULL
,0,NULL
,0);
7072 VARDIV(R8
,1.0,I2
,2,R8
,0.5);
7073 VARDIV(R8
,1.0,I4
,2,R8
,0.5);
7074 VARDIV(R8
,1.0,R4
,2.0,R8
,0.5);
7075 VARDIV(R8
,1.0,R8
,2.0,R8
,0.5);
7076 VARDIV(R8
,1.0,DATE
,2,R8
,0.5);
7077 VARDIV(R8
,1.0,BSTR
,num2_str
,R8
,0.5);
7078 VARDIV(R8
,1.0,BOOL
,VARIANT_TRUE
,R8
,-1.0);
7079 VARDIV(R8
,1.0,UI1
,2,R8
,0.5);
7080 VARDIV(R8
,1.0,I8
,2,R8
,0.5);
7081 VARDIV(DATE
,1,NULL
,0,NULL
,0);
7082 VARDIV(DATE
,1,I2
,2,R8
,0.5);
7083 VARDIV(DATE
,1,I4
,2,R8
,0.5);
7084 VARDIV(DATE
,1,R4
,2.0,R8
,0.5);
7085 VARDIV(DATE
,1,R8
,2.0,R8
,0.5);
7086 VARDIV(DATE
,1,DATE
,2,R8
,0.5);
7087 VARDIV(DATE
,1,BSTR
,num2_str
,R8
,0.5);
7088 VARDIV(DATE
,1,BOOL
,VARIANT_TRUE
,R8
,-1.0);
7089 VARDIV(DATE
,1,UI1
,2,R8
,0.5);
7090 VARDIV(DATE
,1,I8
,2,R8
,0.5);
7091 VARDIV(BSTR
,num1_str
,NULL
,0,NULL
,0);
7092 VARDIV(BSTR
,num1_str
,I2
,2,R8
,0.5);
7093 VARDIV(BSTR
,num1_str
,I4
,2,R8
,0.5);
7094 VARDIV(BSTR
,num1_str
,R4
,2.0,R8
,0.5);
7095 VARDIV(BSTR
,num1_str
,R8
,2.0,R8
,0.5);
7096 VARDIV(BSTR
,num1_str
,DATE
,2,R8
,0.5);
7097 VARDIV(BSTR
,num1_str
,BSTR
,num2_str
,R8
,0.5);
7098 VARDIV(BSTR
,num1_str
,BOOL
,VARIANT_TRUE
,R8
,-1);
7099 VARDIV(BSTR
,num1_str
,UI1
,2,R8
,0.5);
7100 VARDIV(BSTR
,num1_str
,I8
,2.0,R8
,0.5);
7101 VARDIV(BOOL
,VARIANT_TRUE
,NULL
,0,NULL
,0);
7102 VARDIV(BOOL
,VARIANT_TRUE
,I2
,1,R8
,-1.0);
7103 VARDIV(BOOL
,VARIANT_FALSE
,I2
,1,R8
,0.0);
7104 VARDIV(BOOL
,VARIANT_TRUE
,I4
,1,R8
,-1.0);
7105 VARDIV(BOOL
,VARIANT_FALSE
,I4
,1,R8
,0.0);
7106 VARDIV(BOOL
,VARIANT_TRUE
,R4
,1,R4
,-1.0);
7107 VARDIV(BOOL
,VARIANT_FALSE
,R4
,1,R4
,0.0);
7108 VARDIV(BOOL
,VARIANT_TRUE
,R8
,1.0,R8
,-1.0);
7109 VARDIV(BOOL
,VARIANT_FALSE
,R8
,1.0,R8
,0.0);
7110 VARDIV(BOOL
,VARIANT_FALSE
,DATE
,2,R8
,0.0);
7111 VARDIV(BOOL
,VARIANT_FALSE
,BSTR
,num2_str
,R8
,0.0);
7112 VARDIV(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
,R8
,1.0);
7113 VARDIV(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
,R8
,0.0);
7114 VARDIV(BOOL
,VARIANT_TRUE
,UI1
,1,R8
,-1.0);
7115 VARDIV(BOOL
,VARIANT_TRUE
,I8
,1,R8
,-1.0);
7116 VARDIV(UI1
,1,NULL
,0,NULL
,0);
7117 VARDIV(UI1
,1,I2
,2,R8
,0.5);
7118 VARDIV(UI1
,1,I4
,2,R8
,0.5);
7119 VARDIV(UI1
,1,R4
,2.0,R4
,0.5);
7120 VARDIV(UI1
,1,R8
,2.0,R8
,0.5);
7121 VARDIV(UI1
,1,DATE
,2,R8
,0.5);
7122 VARDIV(UI1
,1,BSTR
,num2_str
,R8
,0.5);
7123 VARDIV(UI1
,1,BOOL
,VARIANT_TRUE
,R8
,-1);
7124 VARDIV(UI1
,1,UI1
,2,R8
,0.5);
7125 VARDIV(UI1
,1,I8
,2,R8
,0.5);
7126 VARDIV(I8
,1,NULL
,0,NULL
,0);
7127 VARDIV(I8
,1,I2
,2,R8
,0.5);
7128 VARDIV(I8
,1,I4
,2,R8
,0.5);
7129 VARDIV(I8
,1,R4
,2.0,R8
,0.5);
7130 VARDIV(I8
,1,R8
,2.0,R8
,0.5);
7131 VARDIV(I8
,1,DATE
,2,R8
,0.5);
7132 VARDIV(I8
,1,BSTR
,num2_str
,R8
,0.5);
7133 VARDIV(I8
,1,BOOL
,VARIANT_TRUE
,R8
,-1);
7134 VARDIV(I8
,1,UI1
,2,R8
,0.5);
7135 VARDIV(I8
,1,I8
,2,R8
,0.5);
7137 /* Manually test some VT_CY, VT_DECIMAL variants */
7139 hres
= VarCyFromI4(10000, &V_CY(&cy
));
7140 ok(hres
== S_OK
, "VarCyFromI4 failed!\n");
7141 V_VT(&dec
) = VT_DECIMAL
;
7142 hres
= VarDecFromR8(2.0, &V_DECIMAL(&dec
));
7143 ok(hres
== S_OK
, "VarDecFromR4 failed!\n");
7144 memset(&left
, 0, sizeof(left
));
7145 memset(&right
, 0, sizeof(right
));
7146 V_VT(&left
) = VT_I4
;
7148 V_VT(&right
) = VT_UI1
;
7151 hres
= pVarDiv(&cy
, &cy
, &result
);
7152 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
7153 "VARDIV: expected coerced type VT_R8, got %s!\n", vtstr(V_VT(&result
)));
7154 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 1.0),
7155 "VARDIV: CY value %f, expected %f\n", V_R8(&result
), (double)1.0);
7157 hres
= pVarDiv(&cy
, &right
, &result
);
7158 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
7159 "VARDIV: expected coerced type VT_R8, got %s!\n", vtstr(V_VT(&result
)));
7160 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 5000.0),
7161 "VARDIV: CY value %f, expected %f\n", V_R8(&result
), (double)5000.0);
7163 hres
= pVarDiv(&left
, &cy
, &result
);
7164 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
7165 "VARDIV: expected coerced type VT_R8, got %s!\n", vtstr(V_VT(&result
)));
7166 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 0.01),
7167 "VARDIV: CY value %f, expected %f\n", V_R8(&result
), (double)0.01);
7169 hres
= pVarDiv(&left
, &dec
, &result
);
7170 ok(hres
== S_OK
&& V_VT(&result
) == VT_DECIMAL
,
7171 "VARDIV: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result
)));
7172 hres
= VarR8FromDec(&V_DECIMAL(&result
), &r
);
7173 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 50.0),
7174 "VARDIV: DECIMAL value %f, expected %f\n", r
, (double)50.0);
7176 hres
= pVarDiv(&dec
, &dec
, &result
);
7177 ok(hres
== S_OK
&& V_VT(&result
) == VT_DECIMAL
,
7178 "VARDIV: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result
)));
7179 hres
= VarR8FromDec(&V_DECIMAL(&result
), &r
);
7180 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 1.0),
7181 "VARDIV: DECIMAL value %f, expected %f\n", r
, (double)1.0);
7183 hres
= pVarDiv(&dec
, &right
, &result
);
7184 ok(hres
== S_OK
&& V_VT(&result
) == VT_DECIMAL
,
7185 "VARDIV: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result
)));
7186 hres
= VarR8FromDec(&V_DECIMAL(&result
), &r
);
7187 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 1.0),
7188 "VARDIV: DECIMAL value %f, expected %f\n", r
, (double)1.0);
7190 /* Check for division by zero and overflow */
7191 V_VT(&left
) = VT_R8
;
7193 V_VT(&right
) = VT_R8
;
7195 hres
= pVarDiv(&left
, &right
, &result
);
7196 ok(hres
== DISP_E_DIVBYZERO
&& V_VT(&result
) == VT_EMPTY
,
7197 "VARDIV: Division by (1.0/0.0) should result in DISP_E_DIVBYZERO but got 0x%X\n", hres
);
7199 V_VT(&left
) = VT_R8
;
7201 V_VT(&right
) = VT_R8
;
7203 hres
= pVarDiv(&left
, &right
, &result
);
7204 ok(hres
== DISP_E_OVERFLOW
&& V_VT(&result
) == VT_EMPTY
,
7205 "VARDIV: Division by (0.0/0.0) should result in DISP_E_OVERFLOW but got 0x%X\n", hres
);
7207 SysFreeString(num1_str
);
7208 SysFreeString(num2_str
);
7211 static HRESULT (WINAPI
*pVarIdiv
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
7213 #define VARIDIV(vt1,val1,vt2,val2,rvt,rval) \
7214 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
7215 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
7216 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
7217 test_var_call2( __LINE__, pVarIdiv, &left, &right, &exp );
7219 /* Skip any type that is not defined or produces a error for every case */
7220 #define SKIPTESTIDIV(a) \
7221 if (a == VT_ERROR || a == VT_VARIANT || \
7222 a == VT_DISPATCH || a == VT_UNKNOWN || \
7223 a == VT_RECORD || a > VT_UINT || \
7224 a == 15 /*not defined*/) \
7227 static void test_VarIdiv(void)
7229 static const WCHAR str1
[] = { '1','\0' };
7230 static const WCHAR str2
[] = { '2','\0' };
7231 VARIANT left
, right
, exp
, result
, cy
, dec
;
7232 BSTR num1_str
, num2_str
;
7238 num1_str
= SysAllocString(str1
);
7239 num2_str
= SysAllocString(str2
);
7241 /* Test all possible flag/vt combinations & the resulting vt type */
7242 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
7244 VARTYPE leftvt
, rightvt
, resvt
;
7246 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
7248 SKIPTESTIDIV(leftvt
);
7250 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
7253 SKIPTESTIDIV(rightvt
);
7255 /* Native crashes with extra flag VT_BYREF */
7256 if (ExtraFlags
[i
] == VT_BYREF
)
7259 memset(&left
, 0, sizeof(left
));
7260 memset(&right
, 0, sizeof(right
));
7261 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
7262 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
7263 V_VT(&result
) = VT_EMPTY
;
7266 if (leftvt
== VT_BSTR
)
7267 V_BSTR(&left
) = num2_str
;
7268 else if (leftvt
== VT_DECIMAL
)
7270 VarDecFromR8(2.0, &V_DECIMAL(&left
));
7271 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
7274 /* Division by 0 is undefined */
7278 V_BSTR(&right
) = num2_str
;
7281 VarDecFromR8(2.0, &V_DECIMAL(&right
));
7282 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
7285 V_BOOL(&right
) = VARIANT_TRUE
;
7288 VarCyFromI4(10000, &V_CY(&right
));
7289 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
7291 case VT_I2
: V_I2(&right
) = 2; break;
7292 case VT_I4
: V_I4(&right
) = 2; break;
7293 case VT_R4
: V_R4(&right
) = 2.0; break;
7294 case VT_R8
: V_R8(&right
) = 2.0; break;
7295 case VT_DATE
: V_DATE(&right
) = 2; break;
7296 case VT_I1
: V_I1(&right
) = 2; break;
7297 case VT_UI1
: V_UI1(&right
) = 2; break;
7298 case VT_UI2
: V_UI2(&right
) = 2; break;
7299 case VT_UI4
: V_UI4(&right
) = 2; break;
7300 case VT_I8
: V_I8(&right
) = 2; break;
7301 case VT_UI8
: V_UI8(&right
) = 2; break;
7302 case VT_INT
: V_INT(&right
) = 2; break;
7303 case VT_UINT
: V_UINT(&right
) = 2; break;
7307 /* Native VarIdiv always returns a error when using any extra
7308 * flags or if the variant combination is I8 and INT.
7310 if ((leftvt
== VT_I8
&& rightvt
== VT_INT
) ||
7311 (leftvt
== VT_INT
&& rightvt
== VT_I8
) ||
7312 (rightvt
== VT_EMPTY
&& leftvt
!= VT_NULL
) ||
7316 /* Determine variant type */
7317 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
7319 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
7321 else if (leftvt
== VT_I4
|| rightvt
== VT_I4
||
7322 leftvt
== VT_INT
|| rightvt
== VT_INT
||
7323 leftvt
== VT_UINT
|| rightvt
== VT_UINT
||
7324 leftvt
== VT_UI8
|| rightvt
== VT_UI8
||
7325 leftvt
== VT_UI4
|| rightvt
== VT_UI4
||
7326 leftvt
== VT_UI2
|| rightvt
== VT_UI2
||
7327 leftvt
== VT_I1
|| rightvt
== VT_I1
||
7328 leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
||
7329 leftvt
== VT_DATE
|| rightvt
== VT_DATE
||
7330 leftvt
== VT_CY
|| rightvt
== VT_CY
||
7331 leftvt
== VT_DECIMAL
|| rightvt
== VT_DECIMAL
||
7332 leftvt
== VT_R8
|| rightvt
== VT_R8
||
7333 leftvt
== VT_R4
|| rightvt
== VT_R4
)
7335 else if (leftvt
== VT_I2
|| rightvt
== VT_I2
||
7336 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
||
7339 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
7344 hres
= pVarIdiv(&left
, &right
, &result
);
7346 /* Check expected HRESULT and if result variant type is correct */
7348 ok (hres
== DISP_E_BADVARTYPE
|| hres
== DISP_E_TYPEMISMATCH
||
7349 hres
== DISP_E_DIVBYZERO
,
7350 "VarIdiv: %s|0x%X, %s|0x%X: got vt %s hr 0x%X\n",
7351 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
],
7352 vtstr(V_VT(&result
)), hres
);
7354 ok (hres
== S_OK
&& resvt
== V_VT(&result
),
7355 "VarIdiv: %s|0x%X, %s|0x%X: expected vt %s hr 0x%X, got vt %s hr 0x%X\n",
7356 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
], vtstr(resvt
),
7357 S_OK
, vtstr(V_VT(&result
)), hres
);
7362 /* Test return values for all the good cases */
7363 VARIDIV(EMPTY
,0,NULL
,0,NULL
,0);
7364 VARIDIV(EMPTY
,0,I2
,1,I2
,0);
7365 VARIDIV(EMPTY
,0,I4
,1,I4
,0);
7366 VARIDIV(EMPTY
,0,R4
,1.0,I4
,0);
7367 VARIDIV(EMPTY
,0,R8
,1.0,I4
,0);
7368 VARIDIV(EMPTY
,0,DATE
,1.0,I4
,0);
7369 VARIDIV(EMPTY
,0,BSTR
,num1_str
,I4
,0);
7370 VARIDIV(EMPTY
,0,BOOL
,VARIANT_TRUE
,I2
,0);
7371 VARIDIV(EMPTY
,0,I1
,1,I4
,0);
7372 VARIDIV(EMPTY
,0,UI1
,1,I2
,0);
7373 VARIDIV(EMPTY
,0,UI2
,1,I4
,0);
7374 VARIDIV(EMPTY
,0,UI4
,1,I4
,0);
7375 VARIDIV(EMPTY
,0,I8
,1,I8
,0);
7376 VARIDIV(EMPTY
,0,UI8
,1,I4
,0);
7377 VARIDIV(EMPTY
,0,INT
,1,I4
,0);
7378 VARIDIV(EMPTY
,0,UINT
,1,I4
,0);
7379 VARIDIV(NULL
,0,EMPTY
,0,NULL
,0);
7380 VARIDIV(NULL
,0,NULL
,0,NULL
,0);
7381 VARIDIV(NULL
,0,I2
,1,NULL
,0);
7382 VARIDIV(NULL
,0,I4
,1,NULL
,0);
7383 VARIDIV(NULL
,0,R4
,1,NULL
,0);
7384 VARIDIV(NULL
,0,R8
,1,NULL
,0);
7385 VARIDIV(NULL
,0,DATE
,1,NULL
,0);
7386 VARIDIV(NULL
,0,BSTR
,num1_str
,NULL
,0);
7387 VARIDIV(NULL
,0,BOOL
,VARIANT_TRUE
,NULL
,0);
7388 VARIDIV(NULL
,0,I1
,1,NULL
,0);
7389 VARIDIV(NULL
,0,UI1
,1,NULL
,0);
7390 VARIDIV(NULL
,0,UI2
,1,NULL
,0);
7391 VARIDIV(NULL
,0,UI4
,1,NULL
,0);
7392 VARIDIV(NULL
,0,I8
,1,NULL
,0);
7393 VARIDIV(NULL
,0,UI8
,1,NULL
,0);
7394 VARIDIV(NULL
,0,INT
,1,NULL
,0);
7395 VARIDIV(NULL
,0,UINT
,1,NULL
,0);
7396 VARIDIV(I2
,2,NULL
,0,NULL
,0);
7397 VARIDIV(I2
,2,I2
,1,I2
,2);
7398 VARIDIV(I2
,2,I4
,1,I4
,2);
7399 VARIDIV(I2
,2,R4
,1,I4
,2);
7400 VARIDIV(I2
,2,R8
,1,I4
,2);
7401 VARIDIV(I2
,2,DATE
,1,I4
,2);
7402 VARIDIV(I2
,2,BSTR
,num1_str
,I4
,2);
7403 VARIDIV(I2
,2,BOOL
,VARIANT_TRUE
,I2
,-2);
7404 VARIDIV(I2
,2,I1
,1,I4
,2);
7405 VARIDIV(I2
,2,UI1
,1,I2
,2);
7406 VARIDIV(I2
,2,UI2
,1,I4
,2);
7407 VARIDIV(I2
,2,UI4
,1,I4
,2);
7408 VARIDIV(I2
,2,I8
,1,I8
,2);
7409 VARIDIV(I2
,2,UI8
,1,I4
,2);
7410 VARIDIV(I2
,2,INT
,1,I4
,2);
7411 VARIDIV(I2
,2,UINT
,1,I4
,2);
7412 VARIDIV(I4
,2,NULL
,0,NULL
,0);
7413 VARIDIV(I4
,2,I2
,1,I4
,2);
7414 VARIDIV(I4
,2,I4
,1,I4
,2);
7415 VARIDIV(I4
,2,R4
,1,I4
,2);
7416 VARIDIV(I4
,2,R8
,1,I4
,2);
7417 VARIDIV(I4
,2,DATE
,1,I4
,2);
7418 VARIDIV(I4
,2,BSTR
,num1_str
,I4
,2);
7419 VARIDIV(I4
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
7420 VARIDIV(I4
,2,I1
,1,I4
,2);
7421 VARIDIV(I4
,2,UI1
,1,I4
,2);
7422 VARIDIV(I4
,2,UI2
,1,I4
,2);
7423 VARIDIV(I4
,2,UI4
,1,I4
,2);
7424 VARIDIV(I4
,2,I8
,1,I8
,2);
7425 VARIDIV(I4
,2,UI8
,1,I4
,2);
7426 VARIDIV(I4
,2,INT
,1,I4
,2);
7427 VARIDIV(I4
,2,UINT
,1,I4
,2);
7428 VARIDIV(R4
,2.0,NULL
,0,NULL
,0);
7429 VARIDIV(R4
,2.0,I2
,1,I4
,2);
7430 VARIDIV(R4
,2.0,I4
,1,I4
,2);
7431 VARIDIV(R4
,2.0,R4
,1.0,I4
,2);
7432 VARIDIV(R4
,2.0,R8
,1.0,I4
,2);
7433 VARIDIV(R4
,2.0,DATE
,1,I4
,2);
7434 VARIDIV(R4
,2.0,BSTR
,num1_str
,I4
,2);
7435 VARIDIV(R4
,2.0,BOOL
,VARIANT_TRUE
,I4
,-2);
7436 VARIDIV(R4
,2.0,I1
,1,I4
,2);
7437 VARIDIV(R4
,2.0,UI1
,1,I4
,2);
7438 VARIDIV(R4
,2.0,UI2
,1,I4
,2);
7439 VARIDIV(R4
,2.0,UI4
,1,I4
,2);
7440 VARIDIV(R4
,2.0,I8
,1,I8
,2);
7441 VARIDIV(R4
,2.0,UI8
,1,I4
,2);
7442 VARIDIV(R4
,2.0,INT
,1,I4
,2);
7443 VARIDIV(R4
,2.0,UINT
,1,I4
,2);
7444 VARIDIV(R8
,2.0,NULL
,0,NULL
,0);
7445 VARIDIV(R8
,2.0,I2
,1,I4
,2);
7446 VARIDIV(R8
,2.0,I4
,1,I4
,2);
7447 VARIDIV(R8
,2.0,R4
,1,I4
,2);
7448 VARIDIV(R8
,2.0,R8
,1,I4
,2);
7449 VARIDIV(R8
,2.0,DATE
,1,I4
,2);
7450 VARIDIV(R8
,2.0,BSTR
,num1_str
,I4
,2);
7451 VARIDIV(R8
,2.0,BOOL
,VARIANT_TRUE
,I4
,-2);
7452 VARIDIV(R8
,2.0,I1
,1,I4
,2);
7453 VARIDIV(R8
,2.0,UI1
,1,I4
,2);
7454 VARIDIV(R8
,2.0,UI2
,1,I4
,2);
7455 VARIDIV(R8
,2.0,UI4
,1,I4
,2);
7456 VARIDIV(R8
,2.0,I8
,1,I8
,2);
7457 VARIDIV(R8
,2.0,UI8
,1,I4
,2);
7458 VARIDIV(R8
,2.0,INT
,1,I4
,2);
7459 VARIDIV(R8
,2.0,UINT
,1,I4
,2);
7460 VARIDIV(DATE
,2,NULL
,0,NULL
,0);
7461 VARIDIV(DATE
,2,I2
,1,I4
,2);
7462 VARIDIV(DATE
,2,I4
,1,I4
,2);
7463 VARIDIV(DATE
,2,R4
,1,I4
,2);
7464 VARIDIV(DATE
,2,R8
,1,I4
,2);
7465 VARIDIV(DATE
,2,DATE
,1,I4
,2);
7466 VARIDIV(DATE
,2,BSTR
,num1_str
,I4
,2);
7467 VARIDIV(DATE
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
7468 VARIDIV(DATE
,2,I1
,1,I4
,2);
7469 VARIDIV(DATE
,2,UI1
,1,I4
,2);
7470 VARIDIV(DATE
,2,UI2
,1,I4
,2);
7471 VARIDIV(DATE
,2,UI4
,1,I4
,2);
7472 VARIDIV(DATE
,2,I8
,1,I8
,2);
7473 VARIDIV(DATE
,2,UI8
,1,I4
,2);
7474 VARIDIV(DATE
,2,INT
,1,I4
,2);
7475 VARIDIV(DATE
,2,UINT
,1,I4
,2);
7476 VARIDIV(BSTR
,num2_str
,NULL
,0,NULL
,0);
7477 VARIDIV(BSTR
,num2_str
,I2
,1,I4
,2);
7478 VARIDIV(BSTR
,num2_str
,I4
,1,I4
,2);
7479 VARIDIV(BSTR
,num2_str
,R4
,1.0,I4
,2);
7480 VARIDIV(BSTR
,num2_str
,R8
,1.0,I4
,2);
7481 VARIDIV(BSTR
,num2_str
,DATE
,1,I4
,2);
7482 VARIDIV(BSTR
,num2_str
,BSTR
,num1_str
,I4
,2);
7483 VARIDIV(BSTR
,num2_str
,BOOL
,VARIANT_TRUE
,I4
,-2);
7484 VARIDIV(BSTR
,num2_str
,I1
,1,I4
,2);
7485 VARIDIV(BSTR
,num2_str
,UI1
,1,I4
,2);
7486 VARIDIV(BSTR
,num2_str
,UI2
,1,I4
,2);
7487 VARIDIV(BSTR
,num2_str
,UI4
,1,I4
,2);
7488 VARIDIV(BSTR
,num2_str
,I8
,1,I8
,2);
7489 VARIDIV(BSTR
,num2_str
,UI8
,1,I4
,2);
7490 VARIDIV(BSTR
,num2_str
,INT
,1,I4
,2);
7491 VARIDIV(BSTR
,num2_str
,UINT
,1,I4
,2);
7492 VARIDIV(BOOL
,VARIANT_TRUE
,NULL
,0,NULL
,0);
7493 VARIDIV(BOOL
,VARIANT_TRUE
,I2
,1,I2
,-1);
7494 VARIDIV(BOOL
,VARIANT_TRUE
,I4
,1,I4
,-1);
7495 VARIDIV(BOOL
,VARIANT_TRUE
,R4
,1.0,I4
,-1);
7496 VARIDIV(BOOL
,VARIANT_TRUE
,R8
,1.0,I4
,-1);
7497 VARIDIV(BOOL
,VARIANT_TRUE
,DATE
,1,I4
,-1);
7498 VARIDIV(BOOL
,VARIANT_TRUE
,BSTR
,num1_str
,I4
,-1);
7499 VARIDIV(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
,I2
,1);
7500 VARIDIV(BOOL
,VARIANT_TRUE
,I1
,1,I4
,-1);
7501 VARIDIV(BOOL
,VARIANT_TRUE
,UI1
,1,I2
,-1);
7502 VARIDIV(BOOL
,VARIANT_TRUE
,UI2
,1,I4
,-1);
7503 VARIDIV(BOOL
,VARIANT_TRUE
,UI4
,1,I4
,-1);
7504 VARIDIV(BOOL
,VARIANT_TRUE
,I8
,1,I8
,-1);
7505 VARIDIV(BOOL
,VARIANT_TRUE
,UI8
,1,I4
,-1);
7506 VARIDIV(BOOL
,VARIANT_TRUE
,INT
,1,I4
,-1);
7507 VARIDIV(BOOL
,VARIANT_TRUE
,UINT
,1,I4
,-1);
7508 VARIDIV(I1
,2,NULL
,0,NULL
,0);
7509 VARIDIV(I1
,2,I2
,1,I4
,2);
7510 VARIDIV(I1
,2,I4
,1,I4
,2);
7511 VARIDIV(I1
,2,R4
,1.0,I4
,2);
7512 VARIDIV(I1
,2,R8
,1.0,I4
,2);
7513 VARIDIV(I1
,2,DATE
,1,I4
,2);
7514 VARIDIV(I1
,2,BSTR
,num1_str
,I4
,2);
7515 VARIDIV(I1
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
7516 VARIDIV(I1
,2,I1
,1,I4
,2);
7517 VARIDIV(I1
,2,UI1
,1,I4
,2);
7518 VARIDIV(I1
,2,UI2
,1,I4
,2);
7519 VARIDIV(I1
,2,UI4
,1,I4
,2);
7520 VARIDIV(I1
,2,I8
,1,I8
,2);
7521 VARIDIV(I1
,2,UI8
,1,I4
,2);
7522 VARIDIV(I1
,2,INT
,1,I4
,2);
7523 VARIDIV(I1
,2,UINT
,1,I4
,2);
7524 VARIDIV(UI1
,2,NULL
,0,NULL
,0);
7525 VARIDIV(UI1
,2,I2
,1,I2
,2);
7526 VARIDIV(UI1
,2,I4
,1,I4
,2);
7527 VARIDIV(UI1
,2,R4
,1.0,I4
,2);
7528 VARIDIV(UI1
,2,R8
,1.0,I4
,2);
7529 VARIDIV(UI1
,2,DATE
,1,I4
,2);
7530 VARIDIV(UI1
,2,BSTR
,num1_str
,I4
,2);
7531 VARIDIV(UI1
,2,BOOL
,VARIANT_TRUE
,I2
,-2);
7532 VARIDIV(UI1
,2,I1
,1,I4
,2);
7533 VARIDIV(UI1
,2,UI1
,1,UI1
,2);
7534 VARIDIV(UI1
,2,UI2
,1,I4
,2);
7535 VARIDIV(UI1
,2,UI4
,1,I4
,2);
7536 VARIDIV(UI1
,2,I8
,1,I8
,2);
7537 VARIDIV(UI1
,2,UI8
,1,I4
,2);
7538 VARIDIV(UI1
,2,INT
,1,I4
,2);
7539 VARIDIV(UI1
,2,UINT
,1,I4
,2);
7540 VARIDIV(UI2
,2,NULL
,0,NULL
,0);
7541 VARIDIV(UI2
,2,I2
,1,I4
,2);
7542 VARIDIV(UI2
,2,I4
,1,I4
,2);
7543 VARIDIV(UI2
,2,R4
,1.0,I4
,2);
7544 VARIDIV(UI2
,2,R8
,1.0,I4
,2);
7545 VARIDIV(UI2
,2,DATE
,1,I4
,2);
7546 VARIDIV(UI2
,2,BSTR
,num1_str
,I4
,2);
7547 VARIDIV(UI2
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
7548 VARIDIV(UI2
,2,I1
,1,I4
,2);
7549 VARIDIV(UI2
,2,UI1
,1,I4
,2);
7550 VARIDIV(UI2
,2,UI2
,1,I4
,2);
7551 VARIDIV(UI2
,2,UI4
,1,I4
,2);
7552 VARIDIV(UI2
,2,I8
,1,I8
,2);
7553 VARIDIV(UI2
,2,UI8
,1,I4
,2);
7554 VARIDIV(UI2
,2,INT
,1,I4
,2);
7555 VARIDIV(UI2
,2,UINT
,1,I4
,2);
7556 VARIDIV(UI4
,2,NULL
,0,NULL
,0);
7557 VARIDIV(UI4
,2,I2
,1,I4
,2);
7558 VARIDIV(UI4
,2,I4
,1,I4
,2);
7559 VARIDIV(UI4
,2,R4
,1.0,I4
,2);
7560 VARIDIV(UI4
,2,R8
,1.0,I4
,2);
7561 VARIDIV(UI4
,2,DATE
,1,I4
,2);
7562 VARIDIV(UI4
,2,BSTR
,num1_str
,I4
,2);
7563 VARIDIV(UI4
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
7564 VARIDIV(UI4
,2,I1
,1,I4
,2);
7565 VARIDIV(UI4
,2,UI1
,1,I4
,2);
7566 VARIDIV(UI4
,2,UI2
,1,I4
,2);
7567 VARIDIV(UI4
,2,UI4
,1,I4
,2);
7568 VARIDIV(UI4
,2,I8
,1,I8
,2);
7569 VARIDIV(UI4
,2,UI8
,1,I4
,2);
7570 VARIDIV(UI4
,2,INT
,1,I4
,2);
7571 VARIDIV(UI4
,2,UINT
,1,I4
,2);
7572 VARIDIV(I8
,2,NULL
,0,NULL
,0);
7573 VARIDIV(I8
,2,I2
,1,I8
,2);
7574 VARIDIV(I8
,2,I4
,1,I8
,2);
7575 VARIDIV(I8
,2,R4
,1.0,I8
,2);
7576 VARIDIV(I8
,2,R8
,1.0,I8
,2);
7577 VARIDIV(I8
,2,DATE
,1,I8
,2);
7578 VARIDIV(I8
,2,BSTR
,num1_str
,I8
,2);
7579 VARIDIV(I8
,2,BOOL
,1,I8
,2);
7580 VARIDIV(I8
,2,I1
,1,I8
,2);
7581 VARIDIV(I8
,2,UI1
,1,I8
,2);
7582 VARIDIV(I8
,2,UI2
,1,I8
,2);
7583 VARIDIV(I8
,2,UI4
,1,I8
,2);
7584 VARIDIV(I8
,2,I8
,1,I8
,2);
7585 VARIDIV(I8
,2,UI8
,1,I8
,2);
7586 VARIDIV(I8
,2,UINT
,1,I8
,2);
7587 VARIDIV(UI8
,2,NULL
,0,NULL
,0);
7588 VARIDIV(UI8
,2,I2
,1,I4
,2);
7589 VARIDIV(UI8
,2,I4
,1,I4
,2);
7590 VARIDIV(UI8
,2,R4
,1.0,I4
,2);
7591 VARIDIV(UI8
,2,R8
,1.0,I4
,2);
7592 VARIDIV(UI8
,2,DATE
,1,I4
,2);
7593 VARIDIV(UI8
,2,BSTR
,num1_str
,I4
,2);
7594 VARIDIV(UI8
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
7595 VARIDIV(UI8
,2,I1
,1,I4
,2);
7596 VARIDIV(UI8
,2,UI1
,1,I4
,2);
7597 VARIDIV(UI8
,2,UI2
,1,I4
,2);
7598 VARIDIV(UI8
,2,UI4
,1,I4
,2);
7599 VARIDIV(UI8
,2,I8
,1,I8
,2);
7600 VARIDIV(UI8
,2,UI8
,1,I4
,2);
7601 VARIDIV(UI8
,2,INT
,1,I4
,2);
7602 VARIDIV(UI8
,2,UINT
,1,I4
,2);
7603 VARIDIV(INT
,2,NULL
,0,NULL
,0);
7604 VARIDIV(INT
,2,I2
,1,I4
,2);
7605 VARIDIV(INT
,2,I4
,1,I4
,2);
7606 VARIDIV(INT
,2,R4
,1.0,I4
,2);
7607 VARIDIV(INT
,2,R8
,1.0,I4
,2);
7608 VARIDIV(INT
,2,DATE
,1,I4
,2);
7609 VARIDIV(INT
,2,BSTR
,num1_str
,I4
,2);
7610 VARIDIV(INT
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
7611 VARIDIV(INT
,2,I1
,1,I4
,2);
7612 VARIDIV(INT
,2,UI1
,1,I4
,2);
7613 VARIDIV(INT
,2,UI2
,1,I4
,2);
7614 VARIDIV(INT
,2,UI4
,1,I4
,2);
7615 VARIDIV(INT
,2,UI8
,1,I4
,2);
7616 VARIDIV(INT
,2,INT
,1,I4
,2);
7617 VARIDIV(INT
,2,UINT
,1,I4
,2);
7618 VARIDIV(UINT
,2,NULL
,0,NULL
,0);
7619 VARIDIV(UINT
,2,I2
,1,I4
,2);
7620 VARIDIV(UINT
,2,I4
,1,I4
,2);
7621 VARIDIV(UINT
,2,R4
,1.0,I4
,2);
7622 VARIDIV(UINT
,2,R8
,1.0,I4
,2);
7623 VARIDIV(UINT
,2,DATE
,1,I4
,2);
7624 VARIDIV(UINT
,2,BSTR
,num1_str
,I4
,2);
7625 VARIDIV(UINT
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
7626 VARIDIV(UINT
,2,I1
,1,I4
,2);
7627 VARIDIV(UINT
,2,UI1
,1,I4
,2);
7628 VARIDIV(UINT
,2,UI2
,1,I4
,2);
7629 VARIDIV(UINT
,2,UI4
,1,I4
,2);
7630 VARIDIV(UINT
,2,I8
,1,I8
,2);
7631 VARIDIV(UINT
,2,UI8
,1,I4
,2);
7632 VARIDIV(UINT
,2,INT
,1,I4
,2);
7633 VARIDIV(UINT
,2,UINT
,1,I4
,2);
7635 /* Manually test some VT_CY, VT_DECIMAL variants */
7637 hres
= VarCyFromI4(10000, &V_CY(&cy
));
7638 ok(hres
== S_OK
, "VarCyFromI4 failed!\n");
7639 V_VT(&dec
) = VT_DECIMAL
;
7640 hres
= VarDecFromR8(2.0, &V_DECIMAL(&dec
));
7641 ok(hres
== S_OK
, "VarDecFromR4 failed!\n");
7642 memset(&left
, 0, sizeof(left
));
7643 memset(&right
, 0, sizeof(right
));
7644 V_VT(&left
) = VT_I4
;
7646 V_VT(&right
) = VT_I8
;
7649 hres
= VarIdiv(&cy
, &cy
, &result
);
7650 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
7651 "VARIDIV: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
7652 S_OK
, hres
, vtstr(V_VT(&result
)));
7653 ok(hres
== S_OK
&& V_I4(&result
) == 1,
7654 "VARIDIV: CY value %d, expected %d\n", V_I4(&result
), 1);
7656 hres
= VarIdiv(&cy
, &right
, &result
);
7657 ok(hres
== S_OK
&& V_VT(&result
) == VT_I8
,
7658 "VARIDIV: expected coerced hres 0x%X type VT_I8, got hres 0x%X type %s!\n",
7659 S_OK
, hres
, vtstr(V_VT(&result
)));
7660 ok(hres
== S_OK
&& V_I8(&result
) == 5000,
7661 "VARIDIV: CY value 0x%x%08x, expected 0x%x\n",
7662 (DWORD
)(V_I8(&result
) >>32), (DWORD
)V_I8(&result
), 5000);
7664 hres
= VarIdiv(&left
, &cy
, &result
);
7665 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
7666 "VARIDIV: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
7667 S_OK
, hres
, vtstr(V_VT(&result
)));
7668 ok(hres
== S_OK
&& V_I4(&result
) == 0,
7669 "VARIDIV: CY value %d, expected %d\n", V_I4(&result
), 0);
7671 hres
= VarIdiv(&left
, &dec
, &result
);
7672 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
7673 "VARIDIV: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
7674 S_OK
, hres
, vtstr(V_VT(&result
)));
7675 ok(hres
== S_OK
&& V_I4(&result
) == 50,
7676 "VARIDIV: DECIMAL value %d, expected %d\n", V_I4(&result
), 50);
7678 hres
= VarIdiv(&dec
, &dec
, &result
);
7679 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
7680 "VARIDIV: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
7681 S_OK
, hres
, vtstr(V_VT(&result
)));
7682 ok(hres
== S_OK
&& V_I4(&result
) == 1,
7683 "VARIDIV: DECIMAL value %d, expected %d\n", V_I4(&result
), 1);
7685 hres
= VarIdiv(&dec
, &right
, &result
);
7686 ok(hres
== S_OK
&& V_VT(&result
) == VT_I8
,
7687 "VARIDIV: expected coerced hres 0x%X type VT_I8, got hres 0x%X type%s!\n",
7688 S_OK
, hres
, vtstr(V_VT(&result
)));
7689 ok(hres
== S_OK
&& V_I8(&result
) == 1,
7690 "VARIDIV: DECIMAL value 0x%x%08x, expected %d\n",
7691 (DWORD
)(V_I8(&result
) >> 32), (DWORD
)V_I8(&result
), 1);
7693 /* Check for division by zero */
7694 V_VT(&left
) = VT_INT
;
7696 V_VT(&right
) = VT_INT
;
7698 hres
= pVarIdiv(&left
, &right
, &result
);
7699 ok(hres
== DISP_E_DIVBYZERO
&& V_VT(&result
) == VT_EMPTY
,
7700 "VARIDIV: Division by 0 should result in DISP_E_DIVBYZERO but got 0x%X\n", hres
);
7702 V_VT(&left
) = VT_INT
;
7704 V_VT(&right
) = VT_INT
;
7706 hres
= pVarIdiv(&left
, &right
, &result
);
7707 ok(hres
== DISP_E_DIVBYZERO
&& V_VT(&result
) == VT_EMPTY
,
7708 "VARIDIV: Division by 0 should result in DISP_E_DIVBYZERO but got 0x%X\n", hres
);
7710 SysFreeString(num1_str
);
7711 SysFreeString(num2_str
);
7715 static HRESULT (WINAPI
*pVarImp
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
7717 #define VARIMP(vt1,val1,vt2,val2,rvt,rval) \
7718 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
7719 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
7720 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
7721 test_var_call2( __LINE__, pVarImp, &left, &right, &exp );
7723 /* Skip any type that is not defined or produces a error for every case */
7724 #define SKIPTESTIMP(a) \
7725 if (a == VT_ERROR || a == VT_VARIANT || \
7726 a == VT_DISPATCH || a == VT_UNKNOWN || \
7727 a == VT_RECORD || a > VT_UINT || \
7728 a == 15 /*not defined*/) \
7731 static void test_VarImp(void)
7733 static const WCHAR szFalse
[] = { '#','F','A','L','S','E','#','\0' };
7734 static const WCHAR szTrue
[] = { '#','T','R','U','E','#','\0' };
7735 VARIANT left
, right
, exp
, result
, cy
, dec
;
7736 BSTR true_str
, false_str
;
7742 true_str
= SysAllocString(szTrue
);
7743 false_str
= SysAllocString(szFalse
);
7745 /* Test all possible flag/vt combinations & the resulting vt type */
7746 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
7748 VARTYPE leftvt
, rightvt
, resvt
;
7750 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
7752 SKIPTESTIMP(leftvt
);
7754 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
7757 SKIPTESTIMP(rightvt
);
7759 /* Native crashes using the the extra flag VT_BYREF
7760 * or with the following VT combinations
7762 if ((leftvt
== VT_UI4
&& rightvt
== VT_BSTR
) ||
7763 (leftvt
== VT_UI8
&& rightvt
== VT_BSTR
) ||
7764 ExtraFlags
[i
] == VT_BYREF
)
7767 memset(&left
, 0, sizeof(left
));
7768 memset(&right
, 0, sizeof(right
));
7769 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
7770 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
7771 V_VT(&result
) = VT_EMPTY
;
7774 if (leftvt
== VT_BSTR
)
7775 V_BSTR(&left
) = true_str
;
7777 /* This allows us to test return types that are not NULL
7778 * (NULL Imp value = n, NULL Imp 0 = NULL)
7783 V_BSTR(&right
) = true_str
;
7786 VarDecFromR8(2.0, &V_DECIMAL(&right
));
7787 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
7790 V_BOOL(&right
) = VARIANT_TRUE
;
7792 case VT_I1
: V_I1(&right
) = 2; break;
7793 case VT_I2
: V_I2(&right
) = 2; break;
7794 case VT_I4
: V_I4(&right
) = 2; break;
7795 case VT_R4
: V_R4(&right
) = 2.0; break;
7796 case VT_R8
: V_R8(&right
) = 2.0; break;
7797 case VT_CY
: V_CY(&right
).int64
= 10000; break;
7798 case VT_DATE
: V_DATE(&right
) = 2; break;
7799 case VT_I8
: V_I8(&right
) = 2; break;
7800 case VT_INT
: V_INT(&right
) = 2; break;
7801 case VT_UINT
: V_UINT(&right
) = 2; break;
7802 case VT_UI1
: V_UI1(&right
) = 2; break;
7803 case VT_UI2
: V_UI2(&right
) = 2; break;
7804 case VT_UI4
: V_UI4(&right
) = 2; break;
7805 case VT_UI8
: V_UI8(&right
) = 2; break;
7809 /* Native VarImp always returns a error when using any extra
7810 * flags or if the variants are I8 and INT.
7812 if ((leftvt
== VT_I8
&& rightvt
== VT_INT
) ||
7816 /* Determine result type */
7817 else if ((leftvt
== VT_BSTR
&& rightvt
== VT_NULL
) ||
7818 (leftvt
== VT_NULL
&& rightvt
== VT_NULL
) ||
7819 (leftvt
== VT_NULL
&& rightvt
== VT_EMPTY
))
7821 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
7823 else if (leftvt
== VT_I4
|| rightvt
== VT_I4
||
7824 leftvt
== VT_INT
|| rightvt
== VT_INT
||
7825 leftvt
== VT_UINT
|| rightvt
== VT_UINT
||
7826 leftvt
== VT_UI4
|| rightvt
== VT_UI4
||
7827 leftvt
== VT_UI8
|| rightvt
== VT_UI8
||
7828 leftvt
== VT_UI2
|| rightvt
== VT_UI2
||
7829 leftvt
== VT_DECIMAL
|| rightvt
== VT_DECIMAL
||
7830 leftvt
== VT_DATE
|| rightvt
== VT_DATE
||
7831 leftvt
== VT_CY
|| rightvt
== VT_CY
||
7832 leftvt
== VT_R8
|| rightvt
== VT_R8
||
7833 leftvt
== VT_R4
|| rightvt
== VT_R4
||
7834 leftvt
== VT_I1
|| rightvt
== VT_I1
)
7836 else if ((leftvt
== VT_UI1
&& rightvt
== VT_UI1
) ||
7837 (leftvt
== VT_UI1
&& rightvt
== VT_NULL
) ||
7838 (leftvt
== VT_NULL
&& rightvt
== VT_UI1
))
7840 else if (leftvt
== VT_EMPTY
|| rightvt
== VT_EMPTY
||
7841 leftvt
== VT_I2
|| rightvt
== VT_I2
||
7842 leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
7844 else if (leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
||
7845 leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
)
7848 hres
= pVarImp(&left
, &right
, &result
);
7850 /* Check expected HRESULT and if result variant type is correct */
7852 ok (hres
== DISP_E_BADVARTYPE
|| hres
== DISP_E_TYPEMISMATCH
,
7853 "VarImp: %s|0x%X, %s|0x%X: got vt %s hr 0x%X\n",
7854 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
],
7855 vtstr(V_VT(&result
)), hres
);
7857 ok (hres
== S_OK
&& resvt
== V_VT(&result
),
7858 "VarImp: %s|0x%X, %s|0x%X: expected vt %s hr 0x%X, got vt %s hr 0x%X\n",
7859 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
], vtstr(resvt
),
7860 S_OK
, vtstr(V_VT(&result
)), hres
);
7865 VARIMP(EMPTY
,0,EMPTY
,0,I2
,-1);
7866 VARIMP(EMPTY
,0,NULL
,0,I2
,-1);
7867 VARIMP(EMPTY
,0,I2
,-1,I2
,-1);
7868 VARIMP(EMPTY
,0,I4
,-1,I4
,-1);
7869 VARIMP(EMPTY
,0,R4
,0.0,I4
,-1);
7870 VARIMP(EMPTY
,0,R8
,-1.0,I4
,-1);
7871 VARIMP(EMPTY
,0,DATE
,0,I4
,-1);
7872 VARIMP(EMPTY
,0,BSTR
,true_str
,I2
,-1);
7873 VARIMP(EMPTY
,0,BOOL
,VARIANT_FALSE
,I2
,-1);
7874 VARIMP(EMPTY
,0,I1
,0,I4
,-1);
7875 VARIMP(EMPTY
,0,UI1
,1,I2
,-1);
7876 VARIMP(EMPTY
,0,UI2
,1,I4
,-1);
7877 VARIMP(EMPTY
,0,UI4
,1,I4
,-1);
7878 VARIMP(EMPTY
,0,I8
,1,I8
,-1);
7879 VARIMP(EMPTY
,0,UI8
,1,I4
,-1);
7880 VARIMP(EMPTY
,0,INT
,-1,I4
,-1);
7881 VARIMP(EMPTY
,0,UINT
,1,I4
,-1);
7882 VARIMP(NULL
,0,EMPTY
,0,NULL
,0);
7883 VARIMP(NULL
,0,NULL
,0,NULL
,0);
7884 VARIMP(NULL
,0,I2
,-1,I2
,-1);
7885 VARIMP(NULL
,0,I4
,-1,I4
,-1);
7886 VARIMP(NULL
,0,R4
,0.0,NULL
,0);
7887 VARIMP(NULL
,0,R8
,-1.0,I4
,-1);
7888 VARIMP(NULL
,0,DATE
,0,NULL
,0);
7889 VARIMP(NULL
,0,BSTR
,true_str
,BOOL
,-1);
7890 VARIMP(NULL
,0,BOOL
,VARIANT_FALSE
,NULL
,0);
7891 VARIMP(NULL
,0,I1
,0,NULL
,0);
7892 VARIMP(NULL
,0,UI1
,1,UI1
,1);
7893 VARIMP(NULL
,0,UI2
,1,I4
,1);
7894 VARIMP(NULL
,0,UI4
,1,I4
,1);
7895 VARIMP(NULL
,0,I8
,1,I8
,1);
7896 VARIMP(NULL
,0,UI8
,1,I4
,1);
7897 VARIMP(NULL
,0,INT
,-1,I4
,-1);
7898 VARIMP(NULL
,0,UINT
,1,I4
,1);
7899 VARIMP(I2
,-1,EMPTY
,0,I2
,0);
7900 VARIMP(I2
,-1,I2
,-1,I2
,-1);
7901 VARIMP(I2
,-1,I4
,-1,I4
,-1);
7902 VARIMP(I2
,-1,R4
,0.0,I4
,0);
7903 VARIMP(I2
,-1,R8
,-1.0,I4
,-1);
7904 VARIMP(I2
,-1,DATE
,0,I4
,0);
7905 VARIMP(I2
,-1,BSTR
,true_str
,I2
,-1);
7906 VARIMP(I2
,-1,BOOL
,VARIANT_FALSE
,I2
,0);
7907 VARIMP(I2
,-1,I1
,0,I4
,0);
7908 VARIMP(I2
,-1,UI1
,1,I2
,1);
7909 VARIMP(I2
,-1,UI2
,1,I4
,1);
7910 VARIMP(I2
,-1,UI4
,1,I4
,1);
7911 VARIMP(I2
,-1,I8
,1,I8
,1);
7912 VARIMP(I2
,-1,UI8
,1,I4
,1);
7913 VARIMP(I2
,-1,INT
,-1,I4
,-1);
7914 VARIMP(I2
,-1,UINT
,1,I4
,1);
7915 VARIMP(I4
,2,EMPTY
,0,I4
,-3);
7916 VARIMP(I4
,2,NULL
,0,I4
,-3);
7917 VARIMP(I4
,2,I2
,-1,I4
,-1);
7918 VARIMP(I4
,2,I4
,-1,I4
,-1);
7919 VARIMP(I4
,2,R4
,0.0,I4
,-3);
7920 VARIMP(I4
,2,R8
,-1.0,I4
,-1);
7921 VARIMP(I4
,2,DATE
,0,I4
,-3);
7922 VARIMP(I4
,2,BSTR
,true_str
,I4
,-1);
7923 VARIMP(I4
,2,BOOL
,VARIANT_FALSE
,I4
,-3);
7924 VARIMP(I4
,2,I1
,0,I4
,-3);
7925 VARIMP(I4
,2,UI1
,1,I4
,-3);
7926 VARIMP(I4
,2,UI2
,1,I4
,-3);
7927 VARIMP(I4
,2,UI4
,1,I4
,-3);
7928 VARIMP(I4
,2,I8
,1,I8
,-3);
7929 VARIMP(I4
,2,UI8
,1,I4
,-3);
7930 VARIMP(I4
,2,INT
,-1,I4
,-1);
7931 VARIMP(I4
,2,UINT
,1,I4
,-3);
7932 VARIMP(R4
,-1.0,EMPTY
,0,I4
,0);
7933 VARIMP(R4
,-1.0,NULL
,0,NULL
,0);
7934 VARIMP(R4
,-1.0,I2
,-1,I4
,-1);
7935 VARIMP(R4
,-1.0,I4
,-1,I4
,-1);
7936 VARIMP(R4
,-1.0,R4
,0.0,I4
,0);
7937 VARIMP(R4
,-1.0,R8
,-1.0,I4
,-1);
7938 VARIMP(R4
,-1.0,DATE
,1,I4
,1);
7939 VARIMP(R4
,-1.0,BSTR
,true_str
,I4
,-1);
7940 VARIMP(R4
,-1.0,BOOL
,VARIANT_FALSE
,I4
,0);
7941 VARIMP(R4
,-1.0,I1
,0,I4
,0);
7942 VARIMP(R4
,-1.0,UI1
,1,I4
,1);
7943 VARIMP(R4
,-1.0,UI2
,1,I4
,1);
7944 VARIMP(R4
,-1.0,UI4
,1,I4
,1);
7945 VARIMP(R4
,-1.0,I8
,1,I8
,1);
7946 VARIMP(R4
,-1.0,UI8
,1,I4
,1);
7947 VARIMP(R4
,-1.0,INT
,-1,I4
,-1);
7948 VARIMP(R4
,-1.0,UINT
,1,I4
,1);
7949 VARIMP(R8
,1.0,EMPTY
,0,I4
,-2);
7950 VARIMP(R8
,1.0,NULL
,0,I4
,-2);
7951 VARIMP(R8
,1.0,I2
,-1,I4
,-1);
7952 VARIMP(R8
,1.0,I4
,-1,I4
,-1);
7953 VARIMP(R8
,1.0,R4
,0.0,I4
,-2);
7954 VARIMP(R8
,1.0,R8
,-1.0,I4
,-1);
7955 VARIMP(R8
,1.0,DATE
,0,I4
,-2);
7956 VARIMP(R8
,1.0,BSTR
,true_str
,I4
,-1);
7957 VARIMP(R8
,1.0,BOOL
,VARIANT_FALSE
,I4
,-2);
7958 VARIMP(R8
,1.0,I1
,0,I4
,-2);
7959 VARIMP(R8
,1.0,UI1
,1,I4
,-1);
7960 VARIMP(R8
,1.0,UI2
,1,I4
,-1);
7961 VARIMP(R8
,1.0,UI4
,1,I4
,-1);
7962 VARIMP(R8
,1.0,I8
,1,I8
,-1);
7963 VARIMP(R8
,1.0,UI8
,1,I4
,-1);
7964 VARIMP(R8
,1.0,INT
,-1,I4
,-1);
7965 VARIMP(R8
,1.0,UINT
,1,I4
,-1);
7966 VARIMP(DATE
,0,EMPTY
,0,I4
,-1);
7967 VARIMP(DATE
,0,NULL
,0,I4
,-1);
7968 VARIMP(DATE
,0,I2
,-1,I4
,-1);
7969 VARIMP(DATE
,0,I4
,-1,I4
,-1);
7970 VARIMP(DATE
,0,R4
,0.0,I4
,-1);
7971 VARIMP(DATE
,0,R8
,-1.0,I4
,-1);
7972 VARIMP(DATE
,0,DATE
,0,I4
,-1);
7973 VARIMP(DATE
,0,BSTR
,true_str
,I4
,-1);
7974 VARIMP(DATE
,0,BOOL
,VARIANT_FALSE
,I4
,-1);
7975 VARIMP(DATE
,0,I1
,0,I4
,-1);
7976 VARIMP(DATE
,0,UI1
,1,I4
,-1);
7977 VARIMP(DATE
,0,UI2
,1,I4
,-1);
7978 VARIMP(DATE
,0,UI4
,1,I4
,-1);
7979 VARIMP(DATE
,0,I8
,1,I8
,-1);
7980 VARIMP(DATE
,0,UI8
,1,I4
,-1);
7981 VARIMP(DATE
,0,INT
,-1,I4
,-1);
7982 VARIMP(DATE
,0,UINT
,1,I4
,-1);
7983 VARIMP(BSTR
,false_str
,EMPTY
,0,I2
,-1);
7984 VARIMP(BSTR
,false_str
,NULL
,0,BOOL
,-1);
7985 VARIMP(BSTR
,false_str
,I2
,-1,I2
,-1);
7986 VARIMP(BSTR
,false_str
,I4
,-1,I4
,-1);
7987 VARIMP(BSTR
,false_str
,R4
,0.0,I4
,-1);
7988 VARIMP(BSTR
,false_str
,R8
,-1.0,I4
,-1);
7989 VARIMP(BSTR
,false_str
,DATE
,0,I4
,-1);
7990 VARIMP(BSTR
,false_str
,BSTR
,true_str
,BOOL
,-1);
7991 VARIMP(BSTR
,false_str
,BOOL
,VARIANT_FALSE
,BOOL
,-1);
7992 VARIMP(BSTR
,false_str
,I1
,0,I4
,-1);
7993 VARIMP(BSTR
,false_str
,UI1
,1,I2
,-1);
7994 VARIMP(BSTR
,false_str
,UI2
,1,I4
,-1);
7995 VARIMP(BSTR
,false_str
,UI4
,1,I4
,-1);
7996 VARIMP(BSTR
,false_str
,I8
,1,I8
,-1);
7997 VARIMP(BSTR
,false_str
,UI8
,1,I4
,-1);
7998 VARIMP(BSTR
,false_str
,INT
,-1,I4
,-1);
7999 VARIMP(BSTR
,false_str
,UINT
,1,I4
,-1);
8000 VARIMP(BOOL
,VARIANT_TRUE
,EMPTY
,0,I2
,0);
8001 VARIMP(BOOL
,VARIANT_TRUE
,NULL
,0,NULL
,0);
8002 VARIMP(BOOL
,VARIANT_TRUE
,I2
,-1,I2
,-1);
8003 VARIMP(BOOL
,VARIANT_TRUE
,I4
,-1,I4
,-1);
8004 VARIMP(BOOL
,VARIANT_TRUE
,R4
,0.0,I4
,0);
8005 VARIMP(BOOL
,VARIANT_TRUE
,R8
,-1.0,I4
,-1);
8006 VARIMP(BOOL
,VARIANT_TRUE
,DATE
,0,I4
,0);
8007 VARIMP(BOOL
,VARIANT_TRUE
,BSTR
,true_str
,BOOL
,-1);
8008 VARIMP(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
,BOOL
,0);
8009 VARIMP(BOOL
,VARIANT_TRUE
,I1
,0,I4
,0);
8010 VARIMP(BOOL
,VARIANT_TRUE
,UI1
,1,I2
,1);
8011 VARIMP(BOOL
,VARIANT_TRUE
,UI2
,1,I4
,1);
8012 VARIMP(BOOL
,VARIANT_TRUE
,UI4
,1,I4
,1);
8013 VARIMP(BOOL
,VARIANT_TRUE
,I8
,1,I8
,1);
8014 VARIMP(BOOL
,VARIANT_TRUE
,UI8
,1,I4
,1);
8015 VARIMP(BOOL
,VARIANT_TRUE
,INT
,-1,I4
,-1);
8016 VARIMP(BOOL
,VARIANT_TRUE
,UINT
,1,I4
,1);
8017 VARIMP(I1
,-1,EMPTY
,0,I4
,0);
8018 VARIMP(I1
,-1,NULL
,0,NULL
,0);
8019 VARIMP(I1
,-1,I2
,-1,I4
,-1);
8020 VARIMP(I1
,-1,I4
,-1,I4
,-1);
8021 VARIMP(I1
,-1,R4
,0.0,I4
,0);
8022 VARIMP(I1
,-1,R8
,-1.0,I4
,-1);
8023 VARIMP(I1
,-1,DATE
,0,I4
,0);
8024 VARIMP(I1
,-1,BSTR
,true_str
,I4
,-1);
8025 VARIMP(I1
,-1,BOOL
,VARIANT_FALSE
,I4
,0);
8026 VARIMP(I1
,-1,I1
,0,I4
,0);
8027 VARIMP(I1
,-1,UI1
,1,I4
,1);
8028 VARIMP(I1
,-1,UI2
,1,I4
,1);
8029 VARIMP(I1
,-1,UI4
,1,I4
,1);
8030 VARIMP(I1
,-1,I8
,1,I8
,1);
8031 VARIMP(I1
,-1,UI8
,1,I4
,1);
8032 VARIMP(I1
,-1,INT
,-1,I4
,-1);
8033 VARIMP(I1
,-1,UINT
,1,I4
,1);
8034 VARIMP(UI1
,0,EMPTY
,0,I2
,-1);
8035 VARIMP(UI1
,0,NULL
,0,UI1
,255);
8036 VARIMP(UI1
,0,I2
,-1,I2
,-1);
8037 VARIMP(UI1
,0,I4
,-1,I4
,-1);
8038 VARIMP(UI1
,0,R4
,0.0,I4
,-1);
8039 VARIMP(UI1
,0,R8
,-1.0,I4
,-1);
8040 VARIMP(UI1
,0,DATE
,0,I4
,-1);
8041 VARIMP(UI1
,0,BSTR
,true_str
,I2
,-1);
8042 VARIMP(UI1
,0,BOOL
,VARIANT_FALSE
,I2
,-1);
8043 VARIMP(UI1
,0,I1
,0,I4
,-1);
8044 VARIMP(UI1
,0,UI1
,1,UI1
,255);
8045 VARIMP(UI1
,0,UI2
,1,I4
,-1);
8046 VARIMP(UI1
,0,UI4
,1,I4
,-1);
8047 VARIMP(UI1
,0,I8
,1,I8
,-1);
8048 VARIMP(UI1
,0,UI8
,1,I4
,-1);
8049 VARIMP(UI1
,0,INT
,-1,I4
,-1);
8050 VARIMP(UI1
,0,UINT
,1,I4
,-1);
8051 VARIMP(UI2
,0,EMPTY
,0,I4
,-1);
8052 VARIMP(UI2
,0,NULL
,0,I4
,-1);
8053 VARIMP(UI2
,0,I2
,-1,I4
,-1);
8054 VARIMP(UI2
,0,I4
,-1,I4
,-1);
8055 VARIMP(UI2
,0,R4
,0.0,I4
,-1);
8056 VARIMP(UI2
,0,R8
,-1.0,I4
,-1);
8057 VARIMP(UI2
,0,DATE
,0,I4
,-1);
8058 VARIMP(UI2
,0,BSTR
,true_str
,I4
,-1);
8059 VARIMP(UI2
,0,BOOL
,VARIANT_FALSE
,I4
,-1);
8060 VARIMP(UI2
,0,I1
,0,I4
,-1);
8061 VARIMP(UI2
,0,UI1
,1,I4
,-1);
8062 VARIMP(UI2
,0,UI2
,1,I4
,-1);
8063 VARIMP(UI2
,0,UI4
,1,I4
,-1);
8064 VARIMP(UI2
,0,I8
,1,I8
,-1);
8065 VARIMP(UI2
,0,UI8
,1,I4
,-1);
8066 VARIMP(UI2
,0,INT
,-1,I4
,-1);
8067 VARIMP(UI2
,0,UINT
,1,I4
,-1);
8068 VARIMP(UI4
,0,EMPTY
,0,I4
,-1);
8069 VARIMP(UI4
,0,NULL
,0,I4
,-1);
8070 VARIMP(UI4
,0,I2
,-1,I4
,-1);
8071 VARIMP(UI4
,0,I4
,-1,I4
,-1);
8072 VARIMP(UI4
,0,R4
,0.0,I4
,-1);
8073 VARIMP(UI4
,0,R8
,-1.0,I4
,-1);
8074 VARIMP(UI4
,0,DATE
,0,I4
,-1);
8075 VARIMP(UI4
,0,BSTR
,true_str
,I4
,-1);
8076 VARIMP(UI4
,0,BOOL
,VARIANT_FALSE
,I4
,-1);
8077 VARIMP(UI4
,0,I1
,0,I4
,-1);
8078 VARIMP(UI4
,0,UI1
,1,I4
,-1);
8079 VARIMP(UI4
,0,UI2
,1,I4
,-1);
8080 VARIMP(UI4
,0,UI4
,1,I4
,-1);
8081 VARIMP(UI4
,0,I8
,1,I8
,-1);
8082 VARIMP(UI4
,0,UI8
,1,I4
,-1);
8083 VARIMP(UI4
,0,INT
,-1,I4
,-1);
8084 VARIMP(UI4
,0,UINT
,1,I4
,-1);
8085 VARIMP(I8
,-1,EMPTY
,0,I8
,0);
8086 VARIMP(I8
,-1,NULL
,0,NULL
,0);
8087 VARIMP(I8
,-1,I2
,-1,I8
,-1);
8088 VARIMP(I8
,-1,I4
,-1,I8
,-1);
8089 VARIMP(I8
,-1,R4
,0.0,I8
,0);
8090 VARIMP(I8
,-1,R8
,-1.0,I8
,-1);
8091 VARIMP(I8
,-1,DATE
,0,I8
,0);
8092 VARIMP(I8
,-1,BSTR
,true_str
,I8
,-1);
8093 VARIMP(I8
,-1,BOOL
,VARIANT_FALSE
,I8
,0);
8094 VARIMP(I8
,-1,I1
,0,I8
,0);
8095 VARIMP(I8
,-1,UI1
,1,I8
,1);
8096 VARIMP(I8
,-1,UI2
,1,I8
,1);
8097 VARIMP(I8
,-1,UI4
,1,I8
,1);
8098 VARIMP(I8
,-1,I8
,1,I8
,1);
8099 VARIMP(I8
,-1,UI8
,1,I8
,1);
8100 VARIMP(I8
,-1,UINT
,1,I8
,1);
8101 VARIMP(UI8
,0,EMPTY
,0,I4
,-1);
8102 VARIMP(UI8
,0,NULL
,0,I4
,-1);
8103 VARIMP(UI8
,0,I2
,-1,I4
,-1);
8104 VARIMP(UI8
,0,I4
,-1,I4
,-1);
8105 VARIMP(UI8
,0,R4
,0.0,I4
,-1);
8106 VARIMP(UI8
,0,R8
,-1.0,I4
,-1);
8107 VARIMP(UI8
,0,DATE
,0,I4
,-1);
8108 VARIMP(UI8
,0,BSTR
,true_str
,I4
,-1);
8109 VARIMP(UI8
,0,BOOL
,VARIANT_FALSE
,I4
,-1);
8110 VARIMP(UI8
,0,I1
,0,I4
,-1);
8111 VARIMP(UI8
,0,UI1
,1,I4
,-1);
8112 VARIMP(UI8
,0,UI2
,1,I4
,-1);
8113 VARIMP(UI8
,0,UI4
,1,I4
,-1);
8114 VARIMP(UI8
,0,I8
,1,I8
,-1);
8115 VARIMP(UI8
,0,UI8
,1,I4
,-1);
8116 VARIMP(UI8
,0,INT
,-1,I4
,-1);
8117 VARIMP(UI8
,0,UINT
,1,I4
,-1);
8118 VARIMP(INT
,-1,EMPTY
,0,I4
,0);
8119 VARIMP(INT
,-1,NULL
,0,NULL
,0);
8120 VARIMP(INT
,-1,I2
,-1,I4
,-1);
8121 VARIMP(INT
,-1,I4
,-1,I4
,-1);
8122 VARIMP(INT
,-1,R4
,0.0,I4
,0);
8123 VARIMP(INT
,-1,R8
,-1.0,I4
,-1);
8124 VARIMP(INT
,-1,DATE
,0,I4
,0);
8125 VARIMP(INT
,-1,BSTR
,true_str
,I4
,-1);
8126 VARIMP(INT
,-1,BOOL
,VARIANT_FALSE
,I4
,0);
8127 VARIMP(INT
,-1,I1
,0,I4
,0);
8128 VARIMP(INT
,-1,UI1
,1,I4
,1);
8129 VARIMP(INT
,-1,UI2
,1,I4
,1);
8130 VARIMP(INT
,-1,UI4
,1,I4
,1);
8131 VARIMP(INT
,-1,I8
,1,I8
,1);
8132 VARIMP(INT
,-1,UI8
,1,I4
,1);
8133 VARIMP(INT
,-1,INT
,-1,I4
,-1);
8134 VARIMP(INT
,-1,UINT
,1,I4
,1);
8135 VARIMP(UINT
,1,EMPTY
,0,I4
,-2);
8136 VARIMP(UINT
,1,NULL
,0,I4
,-2);
8137 VARIMP(UINT
,1,I2
,-1,I4
,-1);
8138 VARIMP(UINT
,1,I4
,-1,I4
,-1);
8139 VARIMP(UINT
,1,R4
,0.0,I4
,-2);
8140 VARIMP(UINT
,1,R8
,-1.0,I4
,-1);
8141 VARIMP(UINT
,1,DATE
,0,I4
,-2);
8142 VARIMP(UINT
,1,BSTR
,true_str
,I4
,-1);
8143 VARIMP(UINT
,1,BOOL
,VARIANT_FALSE
,I4
,-2);
8144 VARIMP(UINT
,1,I1
,0,I4
,-2);
8145 VARIMP(UINT
,1,UI1
,1,I4
,-1);
8146 VARIMP(UINT
,1,UI2
,1,I4
,-1);
8147 VARIMP(UINT
,1,UI4
,1,I4
,-1);
8148 VARIMP(UINT
,1,I8
,1,I8
,-1);
8149 VARIMP(UINT
,1,UI8
,1,I4
,-1);
8150 VARIMP(UINT
,1,INT
,-1,I4
,-1);
8151 VARIMP(UINT
,1,UINT
,1,I4
,-1);
8153 /* Manually test some VT_CY, VT_DECIMAL variants */
8155 hres
= VarCyFromI4(1, &V_CY(&cy
));
8156 ok(hres
== S_OK
, "VarCyFromI4 failed!\n");
8157 V_VT(&dec
) = VT_DECIMAL
;
8158 hres
= VarDecFromR8(2.0, &V_DECIMAL(&dec
));
8159 ok(hres
== S_OK
, "VarDecFromR4 failed!\n");
8160 memset(&left
, 0, sizeof(left
));
8161 memset(&right
, 0, sizeof(right
));
8162 V_VT(&left
) = VT_I4
;
8164 V_VT(&right
) = VT_I8
;
8167 hres
= pVarImp(&cy
, &cy
, &result
);
8168 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
8169 "VARIMP: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8170 S_OK
, hres
, vtstr(V_VT(&result
)));
8171 ok(hres
== S_OK
&& V_I4(&result
) == -1,
8172 "VARIMP: CY value %d, expected %d\n", V_I4(&result
), -1);
8174 hres
= pVarImp(&cy
, &right
, &result
);
8175 ok(hres
== S_OK
&& V_VT(&result
) == VT_I8
,
8176 "VARIMP: expected coerced hres 0x%X type VT_I8, got hres 0x%X type %s!\n",
8177 S_OK
, hres
, vtstr(V_VT(&result
)));
8178 ok(hres
== S_OK
&& V_I8(&result
) == -2,
8179 "VARIMP: CY value %x%08x, expected %d\n",
8180 (DWORD
)((V_I8(&result
)) >> 32), (DWORD
)(V_I8(&result
)), -2);
8182 hres
= pVarImp(&left
, &cy
, &result
);
8183 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
8184 "VARIMP: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8185 S_OK
, hres
, vtstr(V_VT(&result
)));
8186 ok(hres
== S_OK
&& V_I4(&result
) == -1,
8187 "VARIMP: CY value %d, expected %d\n", V_I4(&result
), -1);
8189 hres
= pVarImp(&left
, &dec
, &result
);
8190 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
8191 "VARIMP: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8192 S_OK
, hres
, vtstr(V_VT(&result
)));
8193 ok(hres
== S_OK
&& V_I4(&result
) == -1,
8194 "VARIMP: DECIMAL value %d, expected %d\n", V_I4(&result
), -1);
8196 hres
= pVarImp(&dec
, &dec
, &result
);
8197 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
8198 "VARIMP: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8199 S_OK
, hres
, vtstr(V_VT(&result
)));
8200 ok(hres
== S_OK
&& V_I4(&result
) == -1,
8201 "VARIMP: DECIMAL value %d, expected %d\n", V_I4(&result
), -1);
8203 hres
= pVarImp(&dec
, &right
, &result
);
8204 ok(hres
== S_OK
&& V_VT(&result
) == VT_I8
,
8205 "VARIMP: expected coerced hres 0x%X type VT_I8, got hres 0x%X type%s!\n",
8206 S_OK
, hres
, vtstr(V_VT(&result
)));
8207 ok(hres
== S_OK
&& V_I8(&result
) == -3,
8208 "VARIMP: DECIMAL value 0x%x%08x, expected %d\n",
8209 (DWORD
)(V_I8(&result
) >>32), (DWORD
)V_I8(&result
), -3);
8211 SysFreeString(false_str
);
8212 SysFreeString(true_str
);
8217 hOleaut32
= LoadLibraryA("oleaut32.dll");
8220 test_VariantClear();
8222 test_VariantCopyInd();
8223 test_VarParseNumFromStr();
8224 test_VarNumFromParseNum();
8225 test_VarUdateFromDate();
8226 test_VarDateFromUdate();
8227 test_SystemTimeToVariantTime();
8228 test_VariantTimeToSystemTime();
8229 test_DosDateTimeToVariantTime();
8230 test_VariantTimeToDosDateTime();