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
33 #include "wine/test.h"
43 static HMODULE hOleaut32
;
45 static HRESULT (WINAPI
*pVarUdateFromDate
)(DATE
,ULONG
,UDATE
*);
46 static HRESULT (WINAPI
*pVarDateFromUdate
)(UDATE
*,ULONG
,DATE
*);
47 static INT (WINAPI
*pSystemTimeToVariantTime
)(LPSYSTEMTIME
,double*);
48 static INT (WINAPI
*pVariantTimeToSystemTime
)(double,LPSYSTEMTIME
);
49 static INT (WINAPI
*pDosDateTimeToVariantTime
)(USHORT
,USHORT
,double*);
50 static INT (WINAPI
*pVariantTimeToDosDateTime
)(double,USHORT
*,USHORT
*);
52 static const WCHAR sz12
[] = {'1','2','\0'};
53 /* the strings are localized */
54 static WCHAR sz12_false
[32];
55 static WCHAR sz12_true
[32];
57 /* Get a conversion function ptr, return if function not available */
58 #define CHECKPTR(func) p##func = (void*)GetProcAddress(hOleaut32, #func); \
59 if (!p##func) { win_skip("function " # func " not available, not testing it\n"); return; }
61 /* Has I8/UI8 data type? */
64 /* When comparing floating point values we cannot expect an exact match
65 * because the rounding errors depend on the exact algorithm.
67 #define EQ_DOUBLE(a,b) (fabs((a)-(b)) / (1.0+fabs(a)+fabs(b)) < 1e-14)
68 #define EQ_FLOAT(a,b) (fabs((a)-(b)) / (1.0+fabs(a)+fabs(b)) < 1e-7)
70 #define SKIPTESTS(a) if((a > VT_CLSID+10) && (a < VT_BSTR_BLOB-10)) continue
72 /* Allow our test macros to work for VT_NULL and VT_EMPTY too */
73 #define V_EMPTY(v) V_I4(v)
74 #define V_NULL(v) V_I4(v)
76 /* Size constraints for overflow tests */
78 #define I1_MIN ((-I1_MAX)-1)
82 #define I2_MIN ((-I2_MAX)-1)
83 #define UI2_MAX 0xffff
85 #define I4_MAX 0x7fffffff
86 #define I4_MIN ((-I4_MAX)-1)
87 #define UI4_MAX 0xffffffff
89 #define I8_MAX (((LONGLONG)I4_MAX << 32) | UI4_MAX)
90 #define I8_MIN ((-I8_MAX)-1)
91 #define UI8_MAX (((ULONGLONG)UI4_MAX << 32) | UI4_MAX)
93 #define DATE_MAX 2958465
94 #define DATE_MIN -657434
95 #define R4_MAX FLT_MAX
96 #define R4_MIN FLT_MIN
97 #define R8_MAX DBL_MAX
98 #define R8_MIN DBL_MIN
100 typedef struct IRecordInfoImpl
102 IRecordInfo IRecordInfo_iface
;
104 unsigned int recordclear
;
105 unsigned int getsize
;
106 unsigned int recordcopy
;
107 struct __tagBRECORD
*rec
;
110 static inline IRecordInfoImpl
*impl_from_IRecordInfo(IRecordInfo
*iface
)
112 return CONTAINING_RECORD(iface
, IRecordInfoImpl
, IRecordInfo_iface
);
115 static HRESULT WINAPI
RecordInfo_QueryInterface(IRecordInfo
*iface
, REFIID riid
, void **obj
)
119 if (IsEqualIID(riid
, &IID_IUnknown
) ||
120 IsEqualIID(riid
, &IID_IRecordInfo
))
123 IRecordInfo_AddRef(iface
);
127 return E_NOINTERFACE
;
130 static ULONG WINAPI
RecordInfo_AddRef(IRecordInfo
*iface
)
132 IRecordInfoImpl
* This
= impl_from_IRecordInfo(iface
);
133 return InterlockedIncrement(&This
->ref
);
136 static ULONG WINAPI
RecordInfo_Release(IRecordInfo
*iface
)
138 IRecordInfoImpl
* This
= impl_from_IRecordInfo(iface
);
139 ULONG ref
= InterlockedDecrement(&This
->ref
);
142 HeapFree(GetProcessHeap(), 0, This
);
147 static HRESULT WINAPI
RecordInfo_RecordInit(IRecordInfo
*iface
, PVOID pvNew
)
149 ok(0, "unexpected call\n");
153 static HRESULT WINAPI
RecordInfo_RecordClear(IRecordInfo
*iface
, void *data
)
155 IRecordInfoImpl
* This
= impl_from_IRecordInfo(iface
);
157 This
->rec
->pvRecord
= NULL
;
161 static HRESULT WINAPI
RecordInfo_RecordCopy(IRecordInfo
*iface
, void *src
, void *dest
)
163 IRecordInfoImpl
* This
= impl_from_IRecordInfo(iface
);
165 ok(src
== (void*)0xdeadbeef, "wrong src pointer %p\n", src
);
169 static HRESULT WINAPI
RecordInfo_GetGuid(IRecordInfo
*iface
, GUID
*pguid
)
171 ok(0, "unexpected call\n");
175 static HRESULT WINAPI
RecordInfo_GetName(IRecordInfo
*iface
, BSTR
*pbstrName
)
177 ok(0, "unexpected call\n");
181 static HRESULT WINAPI
RecordInfo_GetSize(IRecordInfo
*iface
, ULONG
* size
)
183 IRecordInfoImpl
* This
= impl_from_IRecordInfo(iface
);
189 static HRESULT WINAPI
RecordInfo_GetTypeInfo(IRecordInfo
*iface
, ITypeInfo
**ppTypeInfo
)
191 ok(0, "unexpected call\n");
195 static HRESULT WINAPI
RecordInfo_GetField(IRecordInfo
*iface
, PVOID pvData
,
196 LPCOLESTR szFieldName
, VARIANT
*pvarField
)
198 ok(0, "unexpected call\n");
202 static HRESULT WINAPI
RecordInfo_GetFieldNoCopy(IRecordInfo
*iface
, PVOID pvData
,
203 LPCOLESTR szFieldName
, VARIANT
*pvarField
, PVOID
*ppvDataCArray
)
205 ok(0, "unexpected call\n");
209 static HRESULT WINAPI
RecordInfo_PutField(IRecordInfo
*iface
, ULONG wFlags
, PVOID pvData
,
210 LPCOLESTR szFieldName
, VARIANT
*pvarField
)
212 ok(0, "unexpected call\n");
216 static HRESULT WINAPI
RecordInfo_PutFieldNoCopy(IRecordInfo
*iface
, ULONG wFlags
,
217 PVOID pvData
, LPCOLESTR szFieldName
, VARIANT
*pvarField
)
219 ok(0, "unexpected call\n");
223 static HRESULT WINAPI
RecordInfo_GetFieldNames(IRecordInfo
*iface
, ULONG
*pcNames
,
226 ok(0, "unexpected call\n");
230 static BOOL WINAPI
RecordInfo_IsMatchingType(IRecordInfo
*iface
, IRecordInfo
*info2
)
232 ok(0, "unexpected call\n");
236 static PVOID WINAPI
RecordInfo_RecordCreate(IRecordInfo
*iface
)
238 ok(0, "unexpected call\n");
242 static HRESULT WINAPI
RecordInfo_RecordCreateCopy(IRecordInfo
*iface
, PVOID pvSource
,
245 ok(0, "unexpected call\n");
249 static HRESULT WINAPI
RecordInfo_RecordDestroy(IRecordInfo
*iface
, PVOID pvRecord
)
251 ok(0, "unexpected call\n");
255 static const IRecordInfoVtbl RecordInfoVtbl
=
257 RecordInfo_QueryInterface
,
260 RecordInfo_RecordInit
,
261 RecordInfo_RecordClear
,
262 RecordInfo_RecordCopy
,
266 RecordInfo_GetTypeInfo
,
268 RecordInfo_GetFieldNoCopy
,
270 RecordInfo_PutFieldNoCopy
,
271 RecordInfo_GetFieldNames
,
272 RecordInfo_IsMatchingType
,
273 RecordInfo_RecordCreate
,
274 RecordInfo_RecordCreateCopy
,
275 RecordInfo_RecordDestroy
278 static IRecordInfoImpl
*get_test_recordinfo(void)
280 IRecordInfoImpl
*rec
;
282 rec
= HeapAlloc(GetProcessHeap(), 0, sizeof(IRecordInfoImpl
));
283 rec
->IRecordInfo_iface
.lpVtbl
= &RecordInfoVtbl
;
285 rec
->recordclear
= 0;
292 static void init(void)
297 res
= VarBstrFromBool(VARIANT_TRUE
, LANG_USER_DEFAULT
, VAR_LOCALBOOL
, &bstr
);
298 ok(res
== S_OK
&& (lstrlenW(bstr
) > 0),
299 "Expected localized string for 'True'\n");
300 /* lstrcpyW / lstrcatW do not work on win95 */
301 memcpy(sz12_true
, sz12
, sizeof(sz12
));
302 if (bstr
) memcpy(&sz12_true
[2], bstr
, SysStringByteLen(bstr
) + sizeof(WCHAR
));
305 res
= VarBstrFromBool(VARIANT_FALSE
, LANG_USER_DEFAULT
, VAR_LOCALBOOL
, &bstr
);
306 ok(res
== S_OK
&& (lstrlenW(bstr
) > 0),
307 "Expected localized string for 'False'\n");
308 memcpy(sz12_false
, sz12
, sizeof(sz12
));
309 if (bstr
) memcpy(&sz12_false
[2], bstr
, SysStringByteLen(bstr
) + sizeof(WCHAR
));
312 hOleaut32
= GetModuleHandleA("oleaut32.dll");
313 has_i8
= GetProcAddress(hOleaut32
, "VarI8FromI1") != NULL
;
315 skip("No support for I8 and UI8 data types\n");
318 /* Functions to set a DECIMAL */
319 static void setdec(DECIMAL
* dec
, BYTE scl
, BYTE sgn
, ULONG hi32
, ULONG64 lo64
)
321 S(U(*dec
)).scale
= scl
;
322 S(U(*dec
)).sign
= sgn
;
324 U1(*dec
).Lo64
= lo64
;
327 static void setdec64(DECIMAL
* dec
, BYTE scl
, BYTE sgn
, ULONG hi32
, ULONG mid32
, ULONG lo32
)
329 S(U(*dec
)).scale
= scl
;
330 S(U(*dec
)).sign
= sgn
;
332 S1(U1(*dec
)).Mid32
= mid32
;
333 S1(U1(*dec
)).Lo32
= lo32
;
336 static inline int strcmpW( const WCHAR
*str1
, const WCHAR
*str2
)
338 while (*str1
&& (*str1
== *str2
)) { str1
++; str2
++; }
339 return *str1
- *str2
;
342 /* return the string text of a given variant type */
343 static char vtstr_buffer
[16][256];
344 static int vtstr_current
=0;
345 static const char *vtstr(int x
)
348 #define CASE(vt) case VT_##vt: return #vt
387 CASE(STREAMED_OBJECT
);
392 CASE(VERSIONED_STREAM
);
401 return "VT_BSTR_BLOB/VT_ILLEGALMASKED/VT_TYPEMASK";
404 vtstr_current
%= sizeof(vtstr_buffer
)/sizeof(*vtstr_buffer
);
405 sprintf(vtstr_buffer
[vtstr_current
], "unknown variant type %d", x
);
406 return vtstr_buffer
[vtstr_current
++];
410 static const char *variantstr( const VARIANT
*var
)
412 vtstr_current
%= sizeof(vtstr_buffer
)/sizeof(*vtstr_buffer
);
416 sprintf( vtstr_buffer
[vtstr_current
], "VT_I1(%d)", V_I1(var
) ); break;
418 sprintf( vtstr_buffer
[vtstr_current
], "VT_I2(%d)", V_I2(var
) ); break;
420 sprintf( vtstr_buffer
[vtstr_current
], "VT_I4(%d)", V_I4(var
) ); break;
422 sprintf( vtstr_buffer
[vtstr_current
], "VT_INT(%d)", V_INT(var
) ); break;
424 sprintf( vtstr_buffer
[vtstr_current
], "VT_I8(%x%08x)", (UINT
)(V_I8(var
) >> 32), (UINT
)V_I8(var
) ); break;
426 sprintf( vtstr_buffer
[vtstr_current
], "VT_UI8(%x%08x)", (UINT
)(V_UI8(var
) >> 32), (UINT
)V_UI8(var
) ); break;
428 sprintf( vtstr_buffer
[vtstr_current
], "VT_R4(%g)", V_R4(var
) ); break;
430 sprintf( vtstr_buffer
[vtstr_current
], "VT_R8(%g)", V_R8(var
) ); break;
432 sprintf( vtstr_buffer
[vtstr_current
], "VT_UI1(%u)", V_UI1(var
) ); break;
434 sprintf( vtstr_buffer
[vtstr_current
], "VT_UI2(%u)", V_UI2(var
) ); break;
436 sprintf( vtstr_buffer
[vtstr_current
], "VT_UI4(%u)", V_UI4(var
) ); break;
438 sprintf( vtstr_buffer
[vtstr_current
], "VT_UINT(%d)", V_UINT(var
) ); break;
440 sprintf( vtstr_buffer
[vtstr_current
], "VT_CY(%x%08x)", S(V_CY(var
)).Hi
, S(V_CY(var
)).Lo
); break;
442 sprintf( vtstr_buffer
[vtstr_current
], "VT_DATE(%g)", V_DATE(var
) ); break;
444 return vtstr(V_VT(var
));
446 return vtstr_buffer
[vtstr_current
++];
449 static BOOL
is_expected_variant( const VARIANT
*result
, const VARIANT
*expected
)
451 if (V_VT(result
) != V_VT(expected
)) return FALSE
;
452 switch(V_VT(expected
))
458 #define CASE(vt) case VT_##vt: return (V_##vt(result) == V_##vt(expected))
473 return EQ_FLOAT(V_DATE(result
), V_DATE(expected
));
475 return EQ_FLOAT(V_R4(result
), V_R4(expected
));
477 return EQ_FLOAT(V_R8(result
), V_R8(expected
));
479 return (V_CY(result
).int64
== V_CY(expected
).int64
);
481 return !lstrcmpW( V_BSTR(result
), V_BSTR(expected
) );
483 return !memcmp( &V_DECIMAL(result
), &V_DECIMAL(expected
), sizeof(DECIMAL
) );
485 ok(0, "unhandled variant type %s\n",vtstr(V_VT(expected
)));
490 static void test_var_call1( int line
, HRESULT (WINAPI
*func
)(LPVARIANT
,LPVARIANT
),
491 VARIANT
*arg
, VARIANT
*expected
)
493 VARIANT old_arg
= *arg
;
497 memset( &result
, 0, sizeof(result
) );
498 hres
= func( arg
, &result
);
499 ok_(__FILE__
,line
)( hres
== S_OK
, "wrong result %x\n", hres
);
501 ok_(__FILE__
,line
)( is_expected_variant( &result
, expected
),
502 "got %s expected %s\n", variantstr(&result
), variantstr(expected
) );
503 ok_(__FILE__
,line
)( is_expected_variant( arg
, &old_arg
), "Modified argument %s / %s\n",
504 variantstr(&old_arg
), variantstr(arg
));
505 VariantClear( &result
);
508 static void test_var_call2( int line
, HRESULT (WINAPI
*func
)(LPVARIANT
,LPVARIANT
,LPVARIANT
),
509 VARIANT
*left
, VARIANT
*right
, VARIANT
*expected
)
511 VARIANT old_left
= *left
, old_right
= *right
;
515 memset( &result
, 0, sizeof(result
) );
516 hres
= func( left
, right
, &result
);
517 ok_(__FILE__
,line
)( hres
== S_OK
, "wrong result %x\n", hres
);
519 ok_(__FILE__
,line
)( is_expected_variant( &result
, expected
),
520 "got %s expected %s\n", variantstr(&result
), variantstr(expected
) );
521 ok_(__FILE__
,line
)( is_expected_variant( left
, &old_left
), "Modified left argument %s / %s\n",
522 variantstr(&old_left
), variantstr(left
));
523 ok_(__FILE__
,line
)( is_expected_variant( right
, &old_right
), "Modified right argument %s / %s\n",
524 variantstr(&old_right
), variantstr(right
));
525 VariantClear( &result
);
528 static int strcmp_wa(const WCHAR
*strw
, const char *stra
)
531 MultiByteToWideChar(CP_ACP
, 0, stra
, -1, buf
, sizeof(buf
)/sizeof(buf
[0]));
532 return lstrcmpW(strw
, buf
);
535 #define test_bstr_var(a,b) _test_bstr_var(__LINE__,a,b)
536 static void _test_bstr_var(unsigned line
, const VARIANT
*v
, const char *str
)
538 ok_(__FILE__
,line
)(V_VT(v
) == VT_BSTR
, "unexpected vt=%d\n", V_VT(v
));
539 if(V_VT(v
) == VT_BSTR
)
540 ok(!strcmp_wa(V_BSTR(v
), str
), "v=%s, expected %s\n", wine_dbgstr_w(V_BSTR(v
)), str
);
543 static void test_VariantInit(void)
547 /* Test that VariantInit() only sets the type */
548 memset(&v1
, -1, sizeof(v1
));
550 V_VT(&v2
) = VT_EMPTY
;
552 ok(!memcmp(&v1
, &v2
, sizeof(v1
)), "VariantInit() set extra fields\n");
555 /* All possible combinations of extra V_VT() flags */
556 static const VARTYPE ExtraFlags
[16] =
565 VT_VECTOR
|VT_RESERVED
,
566 VT_VECTOR
|VT_ARRAY
|VT_BYREF
,
567 VT_VECTOR
|VT_ARRAY
|VT_RESERVED
,
568 VT_VECTOR
|VT_BYREF
|VT_RESERVED
,
569 VT_VECTOR
|VT_ARRAY
|VT_BYREF
|VT_RESERVED
,
571 VT_ARRAY
|VT_RESERVED
,
572 VT_ARRAY
|VT_BYREF
|VT_RESERVED
,
573 VT_BYREF
|VT_RESERVED
,
576 /* Determine if a vt is valid for VariantClear() */
577 static BOOL
IsValidVariantClearVT(VARTYPE vt
, VARTYPE extraFlags
)
581 /* Only the following flags/types are valid */
582 if ((vt
<= VT_LPWSTR
|| vt
== VT_RECORD
|| vt
== VT_CLSID
) &&
584 (vt
< (VARTYPE
)24 || vt
> (VARTYPE
)31) &&
585 (!(extraFlags
& (VT_BYREF
|VT_ARRAY
)) || vt
> VT_NULL
) &&
586 (extraFlags
== 0 || extraFlags
== VT_BYREF
|| extraFlags
== VT_ARRAY
||
587 extraFlags
== (VT_ARRAY
|VT_BYREF
)))
590 if (!has_i8
&& (vt
== VT_I8
|| vt
== VT_UI8
))
591 ret
= FALSE
; /* Old versions of oleaut32 */
597 IUnknown IUnknown_iface
;
600 } test_VariantClearImpl
;
602 static inline test_VariantClearImpl
*impl_from_IUnknown(IUnknown
*iface
)
604 return CONTAINING_RECORD(iface
, test_VariantClearImpl
, IUnknown_iface
);
607 static HRESULT WINAPI
VC_QueryInterface(LPUNKNOWN iface
,REFIID riid
,LPVOID
*ppobj
)
609 test_VariantClearImpl
*This
= impl_from_IUnknown(iface
);
611 return E_NOINTERFACE
;
614 static ULONG WINAPI
VC_AddRef(LPUNKNOWN iface
) {
615 test_VariantClearImpl
*This
= impl_from_IUnknown(iface
);
617 return InterlockedIncrement(&This
->ref
);
620 static ULONG WINAPI
VC_Release(LPUNKNOWN iface
) {
621 test_VariantClearImpl
*This
= impl_from_IUnknown(iface
);
622 /* static class, won't be freed */
624 return InterlockedDecrement(&This
->ref
);
627 static const IUnknownVtbl test_VariantClear_vtbl
= {
633 static test_VariantClearImpl test_myVariantClearImpl
= {{&test_VariantClear_vtbl
}, 1, 0};
635 static void test_VariantClear(void)
637 struct __tagBRECORD
*rec
;
638 IRecordInfoImpl
*recinfo
;
646 /* Crashes: Native does not test input for NULL, so neither does Wine */
650 /* Only the type field is set, to VT_EMPTY */
653 hres
= VariantClear(&v
);
654 ok((hres
== S_OK
&& V_VT(&v
) == VT_EMPTY
),
655 "VariantClear: Type set to %d, res %08x\n", V_VT(&v
), hres
);
656 ok(V_UI4(&v
) == ~0u, "VariantClear: Overwrote value\n");
658 /* Test all possible V_VT values.
659 * Also demonstrates that null pointers in 'v' are not dereferenced.
660 * Individual variant tests should test VariantClear() with non-NULL values.
662 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
666 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
668 HRESULT hExpected
= DISP_E_BADVARTYPE
;
672 memset(&v
, 0, sizeof(v
));
673 V_VT(&v
) = vt
| ExtraFlags
[i
];
675 hres
= VariantClear(&v
);
677 if (IsValidVariantClearVT(vt
, ExtraFlags
[i
]))
680 ok(hres
== hExpected
, "VariantClear: expected 0x%X, got 0x%X for vt %d | 0x%X\n",
681 hExpected
, hres
, vt
, ExtraFlags
[i
]);
685 /* Some BYREF tests with non-NULL ptrs */
690 V_VT(&v
) = VT_VARIANT
| VT_BYREF
;
691 V_VARIANTREF(&v
) = &v2
;
693 hres
= VariantClear(&v
);
694 ok(hres
== S_OK
, "ret %08x\n", hres
);
695 ok(V_VT(&v
) == 0, "vt %04x\n", V_VT(&v
));
696 ok(V_VARIANTREF(&v
) == &v2
, "variant ref %p\n", V_VARIANTREF(&v2
));
697 ok(V_VT(&v2
) == VT_I4
, "vt %04x\n", V_VT(&v2
));
698 ok(V_I4(&v2
) == 0x1234, "i4 %04x\n", V_I4(&v2
));
702 V_VT(&v
) = VT_I4
| VT_BYREF
;
705 hres
= VariantClear(&v
);
706 ok(hres
== S_OK
, "ret %08x\n", hres
);
707 ok(V_VT(&v
) == 0, "vt %04x\n", V_VT(&v
));
708 ok(V_I4REF(&v
) == &i4
, "i4 ref %p\n", V_I4REF(&v2
));
709 ok(i4
== 0x4321, "i4 changed %08x\n", i4
);
713 V_VT(&v
) = VT_UNKNOWN
;
714 V_UNKNOWN(&v
) = &test_myVariantClearImpl
.IUnknown_iface
;
715 test_myVariantClearImpl
.events
= 0;
716 hres
= VariantClear(&v
);
717 ok(hres
== S_OK
, "ret %08x\n", hres
);
718 ok(V_VT(&v
) == 0, "vt %04x\n", V_VT(&v
));
719 ok(V_UNKNOWN(&v
) == &test_myVariantClearImpl
.IUnknown_iface
, "unknown %p\n", V_UNKNOWN(&v
));
720 /* Check that Release got called, but nothing else */
721 ok(test_myVariantClearImpl
.events
== 0x4, "Unexpected call. events %08x\n", test_myVariantClearImpl
.events
);
724 punk
= &test_myVariantClearImpl
.IUnknown_iface
;
725 V_VT(&v
) = VT_UNKNOWN
| VT_BYREF
;
726 V_UNKNOWNREF(&v
) = &punk
;
727 test_myVariantClearImpl
.events
= 0;
728 hres
= VariantClear(&v
);
729 ok(hres
== S_OK
, "ret %08x\n", hres
);
730 ok(V_VT(&v
) == 0, "vt %04x\n", V_VT(&v
));
731 ok(V_UNKNOWNREF(&v
) == &punk
, "unknown ref %p\n", V_UNKNOWNREF(&v
));
732 /* Check that nothing got called */
733 ok(test_myVariantClearImpl
.events
== 0, "Unexpected call. events %08x\n", test_myVariantClearImpl
.events
);
736 V_VT(&v
) = VT_DISPATCH
;
737 V_DISPATCH(&v
) = (IDispatch
*)&test_myVariantClearImpl
;
738 test_myVariantClearImpl
.events
= 0;
739 hres
= VariantClear(&v
);
740 ok(hres
== S_OK
, "ret %08x\n", hres
);
741 ok(V_VT(&v
) == 0, "vt %04x\n", V_VT(&v
));
742 ok(V_DISPATCH(&v
) == (IDispatch
*)&test_myVariantClearImpl
, "dispatch %p\n", V_DISPATCH(&v
));
743 /* Check that Release got called, but nothing else */
744 ok(test_myVariantClearImpl
.events
== 0x4, "Unexpected call. events %08x\n", test_myVariantClearImpl
.events
);
747 punk
= &test_myVariantClearImpl
.IUnknown_iface
;
748 V_VT(&v
) = VT_DISPATCH
| VT_BYREF
;
749 V_DISPATCHREF(&v
) = (IDispatch
**)&punk
;
750 test_myVariantClearImpl
.events
= 0;
751 hres
= VariantClear(&v
);
752 ok(hres
== S_OK
, "ret %08x\n", hres
);
753 ok(V_VT(&v
) == 0, "vt %04x\n", V_VT(&v
));
754 ok(V_DISPATCHREF(&v
) == (IDispatch
**)&punk
, "dispatch ref %p\n", V_DISPATCHREF(&v
));
755 /* Check that nothing got called */
756 ok(test_myVariantClearImpl
.events
== 0, "Unexpected call. events %08x\n", test_myVariantClearImpl
.events
);
759 recinfo
= get_test_recordinfo();
760 V_VT(&v
) = VT_RECORD
;
761 rec
= &V_UNION(&v
, brecVal
);
762 rec
->pRecInfo
= &recinfo
->IRecordInfo_iface
;
763 rec
->pvRecord
= (void*)0xdeadbeef;
764 recinfo
->recordclear
= 0;
767 hres
= VariantClear(&v
);
768 ok(hres
== S_OK
, "ret %08x\n", hres
);
769 ok(rec
->pvRecord
== NULL
, "got %p\n", rec
->pvRecord
);
770 ok(recinfo
->recordclear
== 1, "got %d\n", recinfo
->recordclear
);
771 ok(recinfo
->ref
== 1, "got %d\n", recinfo
->ref
);
772 IRecordInfo_Release(&recinfo
->IRecordInfo_iface
);
775 static void test_VariantCopy(void)
777 struct __tagBRECORD
*rec
;
778 IRecordInfoImpl
*recinfo
;
779 VARIANTARG vSrc
, vDst
;
782 HRESULT hres
, hExpected
;
784 /* Establish that the failure/other cases are dealt with. Individual tests
785 * for each type should verify that data is copied correctly, references
790 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
792 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
796 memset(&vSrc
, 0, sizeof(vSrc
));
797 V_VT(&vSrc
) = vt
| ExtraFlags
[i
];
799 hExpected
= DISP_E_BADVARTYPE
;
800 /* src is allowed to be a VT_CLSID */
801 if (vt
!= VT_CLSID
&& IsValidVariantClearVT(vt
, ExtraFlags
[i
]))
804 hres
= VariantCopy(&vSrc
, &vSrc
);
806 ok(hres
== hExpected
,
807 "Copy(src==dst): expected 0x%X, got 0x%X for src==dest vt %d|0x%X\n",
808 hExpected
, hres
, vt
, ExtraFlags
[i
]);
812 /* Test that if VariantClear() fails on dest, the function fails. This also
813 * shows that dest is in fact cleared and not just overwritten
815 memset(&vSrc
, 0, sizeof(vSrc
));
816 V_VT(&vSrc
) = VT_UI1
;
818 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
820 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
824 hExpected
= DISP_E_BADVARTYPE
;
826 memset(&vDst
, 0, sizeof(vDst
));
827 V_VT(&vDst
) = vt
| ExtraFlags
[i
];
829 if (IsValidVariantClearVT(vt
, ExtraFlags
[i
]))
832 hres
= VariantCopy(&vDst
, &vSrc
);
834 ok(hres
== hExpected
,
835 "Copy(bad dst): expected 0x%X, got 0x%X for dest vt %d|0x%X\n",
836 hExpected
, hres
, vt
, ExtraFlags
[i
]);
838 ok(V_VT(&vDst
) == VT_UI1
,
839 "Copy(bad dst): expected vt = VT_UI1, got %d\n", V_VT(&vDst
));
843 /* Test that VariantClear() checks vSrc for validity before copying */
844 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
846 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
850 hExpected
= DISP_E_BADVARTYPE
;
852 memset(&vDst
, 0, sizeof(vDst
));
853 V_VT(&vDst
) = VT_EMPTY
;
855 memset(&vSrc
, 0, sizeof(vSrc
));
856 V_VT(&vSrc
) = vt
| ExtraFlags
[i
];
858 /* src is allowed to be a VT_CLSID */
859 if (vt
!= VT_CLSID
&& IsValidVariantClearVT(vt
, ExtraFlags
[i
]))
862 hres
= VariantCopy(&vDst
, &vSrc
);
864 ok(hres
== hExpected
,
865 "Copy(bad src): expected 0x%X, got 0x%X for src vt %d|0x%X\n",
866 hExpected
, hres
, vt
, ExtraFlags
[i
]);
869 ok(V_VT(&vDst
) == (vt
|ExtraFlags
[i
]),
870 "Copy(bad src): expected vt = %d, got %d\n",
871 vt
| ExtraFlags
[i
], V_VT(&vDst
));
877 /* Test that copying a NULL BSTR results in an empty BSTR */
878 memset(&vDst
, 0, sizeof(vDst
));
879 V_VT(&vDst
) = VT_EMPTY
;
880 memset(&vSrc
, 0, sizeof(vSrc
));
881 V_VT(&vSrc
) = VT_BSTR
;
882 hres
= VariantCopy(&vDst
, &vSrc
);
883 ok(hres
== S_OK
, "Copy(NULL BSTR): Failed to copy a NULL BSTR\n");
886 ok((V_VT(&vDst
) == VT_BSTR
) && V_BSTR(&vDst
),
887 "Copy(NULL BSTR): should have non-NULL result\n");
888 if ((V_VT(&vDst
) == VT_BSTR
) && V_BSTR(&vDst
))
890 ok(*V_BSTR(&vDst
) == 0, "Copy(NULL BSTR): result not empty\n");
896 recinfo
= get_test_recordinfo();
898 memset(&vDst
, 0, sizeof(vDst
));
899 V_VT(&vDst
) = VT_EMPTY
;
901 V_VT(&vSrc
) = VT_RECORD
;
902 rec
= &V_UNION(&vSrc
, brecVal
);
903 rec
->pRecInfo
= &recinfo
->IRecordInfo_iface
;
904 rec
->pvRecord
= (void*)0xdeadbeef;
906 recinfo
->recordclear
= 0;
907 recinfo
->recordcopy
= 0;
908 recinfo
->getsize
= 0;
910 hres
= VariantCopy(&vDst
, &vSrc
);
911 ok(hres
== S_OK
, "ret %08x\n", hres
);
913 rec
= &V_UNION(&vDst
, brecVal
);
914 ok(rec
->pvRecord
!= (void*)0xdeadbeef && rec
->pvRecord
!= NULL
, "got %p\n", rec
->pvRecord
);
915 ok(rec
->pRecInfo
== &recinfo
->IRecordInfo_iface
, "got %p\n", rec
->pRecInfo
);
916 ok(recinfo
->getsize
== 1, "got %d\n", recinfo
->recordclear
);
917 ok(recinfo
->recordcopy
== 1, "got %d\n", recinfo
->recordclear
);
923 /* Determine if a vt is valid for VariantCopyInd() */
924 static BOOL
IsValidVariantCopyIndVT(VARTYPE vt
, VARTYPE extraFlags
)
928 if ((extraFlags
& VT_ARRAY
) ||
929 (vt
> VT_NULL
&& vt
!= (VARTYPE
)15 && vt
< VT_VOID
&&
930 !(extraFlags
& (VT_VECTOR
|VT_RESERVED
))))
937 static void test_VariantCopyInd(void)
939 VARIANTARG vSrc
, vDst
, vRef
, vRef2
;
943 HRESULT hres
, hExpected
;
945 memset(buffer
, 0, sizeof(buffer
));
948 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
950 if (ExtraFlags
[i
] & VT_ARRAY
)
951 continue; /* Native crashes on NULL safearray */
953 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
957 memset(&vSrc
, 0, sizeof(vSrc
));
958 V_VT(&vSrc
) = vt
| ExtraFlags
[i
];
960 hExpected
= DISP_E_BADVARTYPE
;
961 if (!(ExtraFlags
[i
] & VT_BYREF
))
963 /* if src is not by-reference, acts as VariantCopy() */
964 if (vt
!= VT_CLSID
&& IsValidVariantClearVT(vt
, ExtraFlags
[i
]))
969 if (vt
== VT_SAFEARRAY
|| vt
== VT_BSTR
|| vt
== VT_UNKNOWN
||
970 vt
== VT_DISPATCH
|| vt
== VT_RECORD
)
971 continue; /* Need valid ptrs for deep copies */
973 V_BYREF(&vSrc
) = &buffer
;
974 hExpected
= E_INVALIDARG
;
976 if ((vt
== VT_I8
|| vt
== VT_UI8
) &&
977 ExtraFlags
[i
] == VT_BYREF
)
980 hExpected
= S_OK
; /* Only valid if I8 is a known type */
982 else if (IsValidVariantCopyIndVT(vt
, ExtraFlags
[i
]))
986 hres
= VariantCopyInd(&vSrc
, &vSrc
);
988 ok(hres
== hExpected
,
989 "CopyInd(src==dst): expected 0x%X, got 0x%X for src==dst vt %d|0x%X\n",
990 hExpected
, hres
, vt
, ExtraFlags
[i
]);
995 memset(&vSrc
, 0, sizeof(vSrc
));
996 V_VT(&vSrc
) = VT_UI1
|VT_BYREF
;
997 V_BYREF(&vSrc
) = &buffer
;
999 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
1001 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
1005 memset(&vDst
, 0, sizeof(vDst
));
1006 V_VT(&vDst
) = vt
| ExtraFlags
[i
];
1008 hExpected
= DISP_E_BADVARTYPE
;
1010 if (IsValidVariantClearVT(vt
, ExtraFlags
[i
]))
1013 hres
= VariantCopyInd(&vDst
, &vSrc
);
1015 ok(hres
== hExpected
,
1016 "CopyInd(bad dst): expected 0x%X, got 0x%X for dst vt %d|0x%X\n",
1017 hExpected
, hres
, vt
, ExtraFlags
[i
]);
1019 ok(V_VT(&vDst
) == VT_UI1
,
1020 "CopyInd(bad dst): expected vt = VT_UI1, got %d\n", V_VT(&vDst
));
1025 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
1027 if (ExtraFlags
[i
] & VT_ARRAY
)
1028 continue; /* Native crashes on NULL safearray */
1030 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
1034 memset(&vDst
, 0, sizeof(vDst
));
1035 V_VT(&vDst
) = VT_EMPTY
;
1037 memset(&vSrc
, 0, sizeof(vSrc
));
1038 V_VT(&vSrc
) = vt
| ExtraFlags
[i
];
1040 hExpected
= DISP_E_BADVARTYPE
;
1041 if (!(ExtraFlags
[i
] & VT_BYREF
))
1043 /* if src is not by-reference, acts as VariantCopy() */
1044 if (vt
!= VT_CLSID
&& IsValidVariantClearVT(vt
, ExtraFlags
[i
]))
1049 if (vt
== VT_SAFEARRAY
|| vt
== VT_BSTR
|| vt
== VT_UNKNOWN
||
1050 vt
== VT_DISPATCH
|| vt
== VT_RECORD
)
1051 continue; /* Need valid ptrs for deep copies, see vartype.c */
1053 V_BYREF(&vSrc
) = &buffer
;
1055 hExpected
= E_INVALIDARG
;
1057 if ((vt
== VT_I8
|| vt
== VT_UI8
) &&
1058 ExtraFlags
[i
] == VT_BYREF
)
1061 hExpected
= S_OK
; /* Only valid if I8 is a known type */
1063 else if (IsValidVariantCopyIndVT(vt
, ExtraFlags
[i
]))
1067 hres
= VariantCopyInd(&vDst
, &vSrc
);
1069 ok(hres
== hExpected
,
1070 "CopyInd(bad src): expected 0x%X, got 0x%X for src vt %d|0x%X\n",
1071 hExpected
, hres
, vt
, ExtraFlags
[i
]);
1074 if (vt
== VT_VARIANT
&& ExtraFlags
[i
] == VT_BYREF
)
1076 /* Type of vDst should be the type of the referenced variant.
1077 * Since we set the buffer to all zeros, its type should be
1080 ok(V_VT(&vDst
) == VT_EMPTY
,
1081 "CopyInd(bad src): expected dst vt = VT_EMPTY, got %d|0x%X\n",
1082 V_VT(&vDst
) & VT_TYPEMASK
, V_VT(&vDst
) & ~VT_TYPEMASK
);
1086 ok(V_VT(&vDst
) == (vt
|(ExtraFlags
[i
] & ~VT_BYREF
)),
1087 "CopyInd(bad src): expected dst vt = %d|0x%X, got %d|0x%X\n",
1088 vt
, ExtraFlags
[i
] & ~VT_BYREF
,
1089 V_VT(&vDst
) & VT_TYPEMASK
, V_VT(&vDst
) & ~VT_TYPEMASK
);
1091 VariantClear(&vDst
);
1096 /* By-reference variants are dereferenced */
1097 V_VT(&vRef
) = VT_UI1
;
1098 V_UI1(&vRef
) = 0x77;
1099 V_VT(&vSrc
) = VT_VARIANT
|VT_BYREF
;
1100 V_VARIANTREF(&vSrc
) = &vRef
;
1103 hres
= VariantCopyInd(&vDst
, &vSrc
);
1104 ok(hres
== S_OK
, "VariantCopyInd failed: 0x%08x\n", hres
);
1105 ok(V_VT(&vDst
) == VT_UI1
&& V_UI1(&vDst
) == 0x77,
1106 "CopyInd(deref): expected dst vt = VT_UI1, val 0x77, got %d|0x%X, 0x%2X\n",
1107 V_VT(&vDst
) & VT_TYPEMASK
, V_VT(&vDst
) & ~VT_TYPEMASK
, V_UI1(&vDst
));
1109 /* By-reference variant to a by-reference type succeeds */
1110 V_VT(&vRef
) = VT_UI1
|VT_BYREF
;
1111 V_UI1REF(&vRef
) = buffer
; buffer
[0] = 0x88;
1112 V_VT(&vSrc
) = VT_VARIANT
|VT_BYREF
;
1113 V_VARIANTREF(&vSrc
) = &vRef
;
1116 hres
= VariantCopyInd(&vDst
, &vSrc
);
1117 ok(hres
== S_OK
, "VariantCopyInd failed: 0x%08x\n", hres
);
1118 ok(V_VT(&vDst
) == VT_UI1
&& V_UI1(&vDst
) == 0x88,
1119 "CopyInd(deref): expected dst vt = VT_UI1, val 0x77, got %d|0x%X, 0x%2X\n",
1120 V_VT(&vDst
) & VT_TYPEMASK
, V_VT(&vDst
) & ~VT_TYPEMASK
, V_UI1(&vDst
));
1122 /* But a by-reference variant to a by-reference variant fails */
1123 V_VT(&vRef2
) = VT_UI1
;
1124 V_UI1(&vRef2
) = 0x77;
1125 V_VT(&vRef
) = VT_VARIANT
|VT_BYREF
;
1126 V_VARIANTREF(&vRef
) = &vRef2
;
1127 V_VT(&vSrc
) = VT_VARIANT
|VT_BYREF
;
1128 V_VARIANTREF(&vSrc
) = &vRef
;
1131 hres
= VariantCopyInd(&vDst
, &vSrc
);
1132 ok(hres
== E_INVALIDARG
,
1133 "CopyInd(ref->ref): expected E_INVALIDARG, got 0x%08x\n", hres
);
1136 static HRESULT (WINAPI
*pVarParseNumFromStr
)(OLECHAR
*,LCID
,ULONG
,NUMPARSE
*,BYTE
*);
1138 /* Macros for converting and testing the result of VarParseNumFromStr */
1141 static HRESULT
convert_str( const char *str
, INT dig
, ULONG flags
,
1142 NUMPARSE
*np
, BYTE rgb
[128], LCID lcid
)
1145 MultiByteToWideChar( CP_ACP
,0, str
, -1, buff
, sizeof(buff
)/sizeof(WCHAR
) );
1146 memset( rgb
, FAILDIG
, 128 );
1147 memset( np
, 255, sizeof(*np
) );
1149 np
->dwInFlags
= flags
;
1150 return pVarParseNumFromStr( buff
, lcid
, LOCALE_NOUSEROVERRIDE
, np
, rgb
);
1153 static void expect_NumFromStr( int line
, HRESULT hres
, NUMPARSE
*np
, INT a
, ULONG b
, ULONG c
,
1154 INT d
, INT e
, INT f
)
1156 if (hres
== (HRESULT
)S_OK
)
1158 ok_(__FILE__
,line
)(np
->cDig
== a
, "Expected cDig = %d, got %d\n", a
, np
->cDig
);
1159 ok_(__FILE__
,line
)(np
->dwInFlags
== b
, "Expected dwInFlags = 0x%x, got 0x%x\n", b
, np
->dwInFlags
);
1160 ok_(__FILE__
,line
)(np
->dwOutFlags
== c
, "Expected dwOutFlags = 0x%x, got 0x%x\n", c
, np
->dwOutFlags
);
1161 ok_(__FILE__
,line
)(np
->cchUsed
== d
, "Expected cchUsed = %d, got %d\n", d
, np
->cchUsed
);
1162 ok_(__FILE__
,line
)(np
->nBaseShift
== e
, "Expected nBaseShift = %d, got %d\n", e
, np
->nBaseShift
);
1163 ok_(__FILE__
,line
)(np
->nPwr10
== f
, "Expected nPwr10 = %d, got %d\n", f
, np
->nPwr10
);
1167 #define CONVERTN(str,dig,flags) hres = convert_str( str, dig, flags, &np, rgb, lcid )
1168 #define CONVERT(str,flags) CONVERTN(str,sizeof(rgb),flags)
1169 #define EXPECT(a,b,c,d,e,f) expect_NumFromStr( __LINE__, hres, &np, a, b, c, d, e, f )
1170 #define EXPECTRGB(a,b) ok(rgb[a] == b, "Digit[%d], expected %d, got %d\n", a, b, rgb[a])
1171 #define EXPECTFAIL ok(hres == (HRESULT)DISP_E_TYPEMISMATCH, "Call succeeded, hres = %08x\n", hres)
1172 #define EXPECT2(a,b) EXPECTRGB(0,a); EXPECTRGB(1,b)
1174 static void test_VarParseNumFromStr(void)
1177 /* Ensure all tests are using the same locale characters for '$', ',' etc */
1178 LCID lcid
= MAKELCID(MAKELANGID(LANG_ENGLISH
,SUBLANG_ENGLISH_US
),SORT_DEFAULT
);
1184 CHECKPTR(VarParseNumFromStr
);
1186 /* Consume a single digit */
1188 EXPECT(1,0,0,1,0,0);
1191 /* cDig is not literal digits - zeros are suppressed and nPwr10 is increased */
1193 EXPECT(1,0,0,2,0,1);
1194 /* Note: Win32 writes the trailing zeros if they are within cDig's limits,
1195 * but then excludes them from the returned cDig count.
1196 * In our implementation we don't bother writing them at all.
1200 /* if cDig is too small and numbers follow, sets INEXACT */
1201 CONVERTN("11",1, 0);
1202 EXPECT(1,0,NUMPRS_INEXACT
,2,0,1);
1205 /* Strips leading zeros */
1207 EXPECT(1,0,0,2,0,0);
1210 /* Strips leading zeros */
1211 CONVERTN("01",1, 0);
1212 EXPECT(1,0,0,2,0,0);
1216 /* Fails on non digits */
1219 EXPECTRGB(0,FAILDIG
);
1221 /** NUMPRS_LEADING_WHITE/NUMPRS_TRAILING_WHITE **/
1223 /* Without flag, fails on whitespace */
1226 EXPECTRGB(0,FAILDIG
);
1229 /* With flag, consumes whitespace */
1230 CONVERT(" 0", NUMPRS_LEADING_WHITE
);
1231 EXPECT(1,NUMPRS_LEADING_WHITE
,NUMPRS_LEADING_WHITE
,2,0,0);
1234 /* Test TAB once, then assume it acts as space for all cases */
1235 CONVERT("\t0", NUMPRS_LEADING_WHITE
);
1236 EXPECT(1,NUMPRS_LEADING_WHITE
,NUMPRS_LEADING_WHITE
,2,0,0);
1240 /* Doesn't pick up trailing whitespace without flag */
1242 EXPECT(1,0,0,1,0,0);
1245 /* With flag, consumes trailing whitespace */
1246 CONVERT("0 ", NUMPRS_TRAILING_WHITE
);
1247 EXPECT(1,NUMPRS_TRAILING_WHITE
,NUMPRS_TRAILING_WHITE
,2,0,0);
1250 /* Leading flag only consumes leading */
1251 CONVERT(" 0 ", NUMPRS_LEADING_WHITE
);
1252 EXPECT(1,NUMPRS_LEADING_WHITE
,NUMPRS_LEADING_WHITE
,2,0,0);
1255 /* Both flags consumes both */
1256 CONVERT(" 0 ", NUMPRS_LEADING_WHITE
|NUMPRS_TRAILING_WHITE
);
1257 EXPECT(1,NUMPRS_LEADING_WHITE
|NUMPRS_TRAILING_WHITE
,NUMPRS_LEADING_WHITE
|NUMPRS_TRAILING_WHITE
,3,0,0);
1260 /** NUMPRS_LEADING_PLUS/NUMPRS_TRAILING_PLUS **/
1262 /* Without flag, fails on + */
1265 EXPECTRGB(0,FAILDIG
);
1267 /* With flag, consumes + */
1268 CONVERT("+0", NUMPRS_LEADING_PLUS
);
1269 EXPECT(1,NUMPRS_LEADING_PLUS
,NUMPRS_LEADING_PLUS
,2,0,0);
1272 /* Without flag, doesn't consume trailing + */
1274 EXPECT(1,0,0,1,0,0);
1277 /* With flag, consumes trailing + */
1278 CONVERT("0+", NUMPRS_TRAILING_PLUS
);
1279 EXPECT(1,NUMPRS_TRAILING_PLUS
,NUMPRS_TRAILING_PLUS
,2,0,0);
1282 /* With leading flag, doesn't consume trailing + */
1283 CONVERT("+0+", NUMPRS_LEADING_PLUS
);
1284 EXPECT(1,NUMPRS_LEADING_PLUS
,NUMPRS_LEADING_PLUS
,2,0,0);
1287 /* Trailing + doesn't get consumed if we specify both (unlike whitespace) */
1288 CONVERT("+0+", NUMPRS_LEADING_PLUS
|NUMPRS_TRAILING_PLUS
);
1289 EXPECT(1,NUMPRS_LEADING_PLUS
|NUMPRS_TRAILING_PLUS
,NUMPRS_LEADING_PLUS
,2,0,0);
1292 /** NUMPRS_LEADING_MINUS/NUMPRS_TRAILING_MINUS **/
1294 /* Without flag, fails on - */
1297 EXPECTRGB(0,FAILDIG
);
1299 /* With flag, consumes - */
1300 CONVERT("-0", NUMPRS_LEADING_MINUS
);
1301 EXPECT(1,NUMPRS_LEADING_MINUS
,NUMPRS_NEG
|NUMPRS_LEADING_MINUS
,2,0,0);
1304 /* Without flag, doesn't consume trailing - */
1306 EXPECT(1,0,0,1,0,0);
1309 /* With flag, consumes trailing - */
1310 CONVERT("0-", NUMPRS_TRAILING_MINUS
);
1311 EXPECT(1,NUMPRS_TRAILING_MINUS
,NUMPRS_NEG
|NUMPRS_TRAILING_MINUS
,2,0,0);
1314 /* With leading flag, doesn't consume trailing - */
1315 CONVERT("-0-", NUMPRS_LEADING_MINUS
);
1316 EXPECT(1,NUMPRS_LEADING_MINUS
,NUMPRS_NEG
|NUMPRS_LEADING_MINUS
,2,0,0);
1319 /* Trailing - doesn't get consumed if we specify both (unlike whitespace) */
1320 CONVERT("-0-", NUMPRS_LEADING_MINUS
|NUMPRS_TRAILING_MINUS
);
1321 EXPECT(1,NUMPRS_LEADING_MINUS
|NUMPRS_TRAILING_MINUS
,NUMPRS_NEG
|NUMPRS_LEADING_MINUS
,2,0,0);
1324 /** NUMPRS_HEX_OCT **/
1326 /* Could be hex, octal or decimal - With flag reads as decimal */
1327 CONVERT("0", NUMPRS_HEX_OCT
);
1328 EXPECT(1,NUMPRS_HEX_OCT
,0,1,0,0);
1331 /* Doesn't recognise hex in .asm syntax */
1332 CONVERT("0h", NUMPRS_HEX_OCT
);
1333 EXPECT(1,NUMPRS_HEX_OCT
,0,1,0,0);
1336 /* Doesn't fail with valid leading string but no digits */
1337 CONVERT("0x", NUMPRS_HEX_OCT
);
1338 EXPECT(1,NUMPRS_HEX_OCT
,0,1,0,0);
1341 /* Doesn't recognise hex format numbers at all! */
1342 CONVERT("0x0", NUMPRS_HEX_OCT
);
1343 EXPECT(1,NUMPRS_HEX_OCT
,0,1,0,0);
1346 /* Doesn't recognise plain hex digits either */
1347 CONVERT("FE", NUMPRS_HEX_OCT
);
1349 EXPECTRGB(0,FAILDIG
);
1352 CONVERT("0100", NUMPRS_HEX_OCT
);
1353 EXPECT(1,NUMPRS_HEX_OCT
,0,4,0,2);
1357 EXPECTRGB(3,FAILDIG
);
1360 CONVERT("&HF800", NUMPRS_HEX_OCT
);
1361 EXPECT(4,NUMPRS_HEX_OCT
,0x40,6,4,0);
1366 EXPECTRGB(4,FAILDIG
);
1368 /* VB hex lower case and leading zero */
1369 CONVERT("&h0abcdef", NUMPRS_HEX_OCT
);
1370 EXPECT(6,NUMPRS_HEX_OCT
,0x40,9,4,0);
1377 EXPECTRGB(6,FAILDIG
);
1380 CONVERT("&O300", NUMPRS_HEX_OCT
);
1381 EXPECT(3,NUMPRS_HEX_OCT
,0x40,5,3,0);
1385 EXPECTRGB(3,FAILDIG
);
1387 /* VB oct lower case and leading zero */
1388 CONVERT("&o0777", NUMPRS_HEX_OCT
);
1389 EXPECT(3,NUMPRS_HEX_OCT
,0x40,6,3,0);
1393 EXPECTRGB(3,FAILDIG
);
1395 /* VB oct char bigger than 7 */
1396 CONVERT("&o128", NUMPRS_HEX_OCT
);
1398 Native versions 2.x of oleaut32 allow this to succeed: later versions and Wine don't
1400 EXPECTRGB(0,FAILDIG);
1402 /** NUMPRS_PARENS **/
1404 /* Empty parens = error */
1405 CONVERT("()", NUMPRS_PARENS
);
1407 EXPECTRGB(0,FAILDIG
);
1409 /* With flag, trailing parens not consumed */
1410 CONVERT("0()", NUMPRS_PARENS
);
1411 EXPECT(1,NUMPRS_PARENS
,0,1,0,0);
1414 /* With flag, Number in parens made negative and parens consumed */
1415 CONVERT("(0)", NUMPRS_PARENS
);
1416 EXPECT(1,NUMPRS_PARENS
,NUMPRS_NEG
|NUMPRS_PARENS
,3,0,0);
1419 /** NUMPRS_THOUSANDS **/
1421 /* With flag, thousands sep. not needed */
1422 CONVERT("0", NUMPRS_THOUSANDS
);
1423 EXPECT(1,NUMPRS_THOUSANDS
,0,1,0,0);
1426 /* With flag, thousands sep. and following digits consumed */
1427 CONVERT("1,000", NUMPRS_THOUSANDS
);
1428 EXPECT(1,NUMPRS_THOUSANDS
,NUMPRS_THOUSANDS
,5,0,3);
1431 /* With flag and decimal point, thousands sep. but not decimals consumed */
1432 CONVERT("1,000.0", NUMPRS_THOUSANDS
);
1433 EXPECT(1,NUMPRS_THOUSANDS
,NUMPRS_THOUSANDS
,5,0,3);
1436 /** NUMPRS_CURRENCY **/
1438 /* Without flag, chokes on currency sign */
1441 EXPECTRGB(0,FAILDIG
);
1443 /* With flag, consumes currency sign */
1444 CONVERT("$11", NUMPRS_CURRENCY
);
1445 EXPECT(2,NUMPRS_CURRENCY
,NUMPRS_CURRENCY
,3,0,0);
1447 EXPECTRGB(2,FAILDIG
);
1449 /* With flag only, doesn't consume decimal point */
1450 CONVERT("$11.1", NUMPRS_CURRENCY
);
1451 EXPECT(2,NUMPRS_CURRENCY
,NUMPRS_CURRENCY
,3,0,0);
1453 EXPECTRGB(2,FAILDIG
);
1455 /* With flag and decimal flag, consumes decimal point and following digits */
1456 CONVERT("$11.1", NUMPRS_CURRENCY
|NUMPRS_DECIMAL
);
1457 EXPECT(3,NUMPRS_CURRENCY
|NUMPRS_DECIMAL
,NUMPRS_CURRENCY
|NUMPRS_DECIMAL
,5,0,-1);
1460 EXPECTRGB(3,FAILDIG
);
1462 /* Thousands flag can only be used with currency */
1463 CONVERT("$1,234", NUMPRS_CURRENCY
|NUMPRS_THOUSANDS
);
1464 EXPECT(4,NUMPRS_CURRENCY
|NUMPRS_THOUSANDS
,NUMPRS_CURRENCY
|NUMPRS_THOUSANDS
,6,0,0);
1468 EXPECTRGB(4,FAILDIG
);
1470 /** NUMPRS_DECIMAL **/
1472 /* With flag, consumes decimal point */
1473 CONVERT("1.1", NUMPRS_DECIMAL
);
1474 EXPECT(2,NUMPRS_DECIMAL
,NUMPRS_DECIMAL
,3,0,-1);
1476 EXPECTRGB(2,FAILDIG
);
1478 /* With flag, consumes decimal point. Skipping the decimal part is not an error */
1479 CONVERT("1.", NUMPRS_DECIMAL
);
1480 EXPECT(1,NUMPRS_DECIMAL
,NUMPRS_DECIMAL
,2,0,0);
1483 /* Consumes only one decimal point */
1484 CONVERT("1.1.", NUMPRS_DECIMAL
);
1485 EXPECT(2,NUMPRS_DECIMAL
,NUMPRS_DECIMAL
,3,0,-1);
1487 EXPECTRGB(2,FAILDIG
);
1489 /** NUMPRS_EXPONENT **/
1491 /* Without flag, doesn't consume exponent */
1493 EXPECT(1,0,0,1,0,0);
1496 /* With flag, consumes exponent */
1497 CONVERT("1e1", NUMPRS_EXPONENT
);
1498 EXPECT(1,NUMPRS_EXPONENT
,NUMPRS_EXPONENT
,3,0,1);
1501 /* Negative exponents are accepted without flags */
1502 CONVERT("1e-1", NUMPRS_EXPONENT
);
1503 EXPECT(1,NUMPRS_EXPONENT
,NUMPRS_EXPONENT
,4,0,-1);
1506 /* As are positive exponents and leading exponent 0s */
1507 CONVERT("1e+01", NUMPRS_EXPONENT
);
1508 EXPECT(1,NUMPRS_EXPONENT
,NUMPRS_EXPONENT
,5,0,1);
1511 /* The same for zero exponents */
1512 CONVERT("1e0", NUMPRS_EXPONENT
);
1513 EXPECT(1,NUMPRS_EXPONENT
,NUMPRS_EXPONENT
,3,0,0);
1516 /* Sign on a zero exponent doesn't matter */
1517 CONVERT("1e+0", NUMPRS_EXPONENT
);
1518 EXPECT(1,NUMPRS_EXPONENT
,NUMPRS_EXPONENT
,4,0,0);
1521 CONVERT("1e-0", NUMPRS_EXPONENT
);
1522 EXPECT(1,NUMPRS_EXPONENT
,NUMPRS_EXPONENT
,4,0,0);
1525 /* Doesn't consume a real number exponent */
1526 CONVERT("1e1.", NUMPRS_EXPONENT
);
1527 EXPECT(1,NUMPRS_EXPONENT
,NUMPRS_EXPONENT
,3,0,1);
1530 /* Powers of 10 are calculated from the position of any decimal point */
1531 CONVERT("1.5e20", NUMPRS_EXPONENT
|NUMPRS_DECIMAL
);
1532 EXPECT(2,NUMPRS_EXPONENT
|NUMPRS_DECIMAL
,NUMPRS_EXPONENT
|NUMPRS_DECIMAL
,6,0,19);
1535 CONVERT("1.5e-20", NUMPRS_EXPONENT
|NUMPRS_DECIMAL
);
1536 EXPECT(2,NUMPRS_EXPONENT
|NUMPRS_DECIMAL
,NUMPRS_EXPONENT
|NUMPRS_DECIMAL
,7,0,-21);
1539 /** NUMPRS_USE_ALL **/
1541 /* Flag expects all digits */
1542 CONVERT("0", NUMPRS_USE_ALL
);
1543 EXPECT(1,NUMPRS_USE_ALL
,0,1,0,0);
1546 /* Rejects anything trailing */
1547 CONVERT("0 ", NUMPRS_USE_ALL
);
1551 /* Unless consumed by trailing flag */
1552 CONVERT("0 ", NUMPRS_USE_ALL
|NUMPRS_TRAILING_WHITE
);
1553 EXPECT(1,NUMPRS_USE_ALL
|NUMPRS_TRAILING_WHITE
,NUMPRS_TRAILING_WHITE
,2,0,0);
1556 /** Combinations **/
1558 /* Leading whitespace and plus, doesn't consume trailing whitespace */
1559 CONVERT("+ 0 ", NUMPRS_LEADING_PLUS
|NUMPRS_LEADING_WHITE
);
1560 EXPECT(1,NUMPRS_LEADING_PLUS
|NUMPRS_LEADING_WHITE
,NUMPRS_LEADING_PLUS
|NUMPRS_LEADING_WHITE
,3,0,0);
1563 /* Order of whitespace and plus is unimportant */
1564 CONVERT(" +0", NUMPRS_LEADING_PLUS
|NUMPRS_LEADING_WHITE
);
1565 EXPECT(1,NUMPRS_LEADING_PLUS
|NUMPRS_LEADING_WHITE
,NUMPRS_LEADING_PLUS
|NUMPRS_LEADING_WHITE
,3,0,0);
1568 /* Leading whitespace can be repeated */
1569 CONVERT(" + 0", NUMPRS_LEADING_PLUS
|NUMPRS_LEADING_WHITE
);
1570 EXPECT(1,NUMPRS_LEADING_PLUS
|NUMPRS_LEADING_WHITE
,NUMPRS_LEADING_PLUS
|NUMPRS_LEADING_WHITE
,4,0,0);
1573 /* But plus/minus etc. cannot */
1574 CONVERT("+ +0", NUMPRS_LEADING_PLUS
|NUMPRS_LEADING_WHITE
);
1576 EXPECTRGB(0,FAILDIG
);
1578 /* Inexact is not set if trailing zeros are removed */
1579 CONVERTN("10", 1, 0);
1580 EXPECT(1,0,0,2,0,1);
1583 /* Make sure a leading 0 is stripped but decimals after it get read */
1584 CONVERT("-0.51", NUMPRS_STD
);
1585 EXPECT(2,NUMPRS_STD
,NUMPRS_NEG
|NUMPRS_DECIMAL
|NUMPRS_LEADING_MINUS
,5,0,-2);
1588 /* Keep trailing zeros on whole number part of a decimal */
1589 CONVERT("10.1", NUMPRS_STD
);
1590 EXPECT(3,NUMPRS_STD
,NUMPRS_DECIMAL
,4,0,-1);
1594 /* Zeros after decimal sign */
1595 CONVERT("0.01", NUMPRS_STD
);
1596 EXPECT(1,NUMPRS_STD
,NUMPRS_DECIMAL
,4,0,-2);
1599 /* Trailing zeros after decimal part */
1600 CONVERT("0.10", NUMPRS_STD
);
1601 EXPECT(1,NUMPRS_STD
,NUMPRS_DECIMAL
,4,0,-1);
1605 static HRESULT (WINAPI
*pVarNumFromParseNum
)(NUMPARSE
*,BYTE
*,ULONG
,VARIANT
*);
1607 /* Macros for converting and testing the result of VarNumFromParseNum */
1608 #define SETRGB(indx,val) if (!indx) memset(rgb, FAILDIG, sizeof(rgb)); rgb[indx] = val
1610 #define CONVERT(a,b,c,d,e,f,bits) \
1611 np.cDig = (a); np.dwInFlags = (b); np.dwOutFlags = (c); np.cchUsed = (d); \
1612 np.nBaseShift = (e); np.nPwr10 = (f); hres = pVarNumFromParseNum(&np, rgb, bits, &vOut)
1613 static const char *szFailOverflow
= "Expected overflow, hres = %08x\n";
1614 #define EXPECT_OVERFLOW ok(hres == (HRESULT)DISP_E_OVERFLOW, szFailOverflow, hres)
1615 static const char *szFailOk
= "Call failed, hres = %08x\n";
1616 #define EXPECT_OK ok(hres == (HRESULT)S_OK, szFailOk, hres); \
1617 if (hres == (HRESULT)S_OK)
1618 #define EXPECT_TYPE(typ) ok(V_VT(&vOut) == typ,"Expected Type = " #typ ", got %d\n", V_VT(&vOut))
1619 #define EXPECT_I1(val) EXPECT_OK { EXPECT_TYPE(VT_I1); \
1620 ok(V_I1(&vOut) == val, "Expected i1 = %d, got %d\n", (signed char)val, V_I1(&vOut)); }
1621 #define EXPECT_UI1(val) EXPECT_OK { EXPECT_TYPE(VT_UI1); \
1622 ok(V_UI1(&vOut) == val, "Expected ui1 = %d, got %d\n", (BYTE)val, V_UI1(&vOut)); }
1623 #define EXPECT_I2(val) EXPECT_OK { EXPECT_TYPE(VT_I2); \
1624 ok(V_I2(&vOut) == val, "Expected i2 = %d, got %d\n", (SHORT)val, V_I2(&vOut)); }
1625 #define EXPECT_UI2(val) EXPECT_OK { EXPECT_TYPE(VT_UI2); \
1626 ok(V_UI2(&vOut) == val, "Expected ui2 = %d, got %d\n", (USHORT)val, V_UI2(&vOut)); }
1627 #define EXPECT_I4(val) EXPECT_OK { EXPECT_TYPE(VT_I4); \
1628 ok(V_I4(&vOut) == val, "Expected i4 = %d, got %d\n", (LONG)val, V_I4(&vOut)); }
1629 #define EXPECT_UI4(val) EXPECT_OK { EXPECT_TYPE(VT_UI4); \
1630 ok(V_UI4(&vOut) == val, "Expected ui4 = %d, got %d\n", (ULONG)val, V_UI4(&vOut)); }
1631 #define EXPECT_I8(high,low) EXPECT_OK { EXPECT_TYPE(VT_I8); \
1632 ok(V_I8(&vOut) == ((((LONG64)(high))<<32)|(low)), "Expected i8 = %x%08x, got %x%08x\n", \
1633 (LONG)(high), (LONG)(low), (LONG)(V_I8(&vOut)>>32), (LONG)V_I8(&vOut) ); }
1634 #define EXPECT_UI8(val) EXPECT_OK { EXPECT_TYPE(VT_UI8); \
1635 ok(V_UI8(&vOut) == val, "Expected ui8 = 0x%x%08x, got 0x%x%08x\n", \
1636 (DWORD)((ULONG64)val >> 32), (DWORD)(ULONG64)val, (DWORD)(V_UI8(&vOut) >> 32), (DWORD)V_UI8(&vOut)); }
1637 #define EXPECT_R4(val) EXPECT_OK { EXPECT_TYPE(VT_R4); \
1638 ok(V_R4(&vOut) == val, "Expected r4 = %f, got %f\n", val, V_R4(&vOut)); }
1639 #define EXPECT_R8(val) EXPECT_OK { EXPECT_TYPE(VT_R8); \
1640 ok(V_R8(&vOut) == val, "Expected r8 = %g, got %g\n", val, V_R8(&vOut)); }
1641 #define CY_MULTIPLIER 10000
1642 #define EXPECT_CY(val) EXPECT_OK { EXPECT_TYPE(VT_CY); \
1643 ok(V_CY(&vOut).int64 == (LONG64)(val * CY_MULTIPLIER), "Expected r8 = 0x%x%08x, got 0x%x%08x\n", \
1644 (DWORD)((LONG64)val >> 23), (DWORD)(LONG64)val, (DWORD)(V_CY(&vOut).int64 >>32), (DWORD)V_CY(&vOut).int64); }
1645 #define EXPECT_DECIMAL(valHi, valMid, valLo) EXPECT_OK { EXPECT_TYPE(VT_DECIMAL); \
1646 ok((V_DECIMAL(&vOut).Hi32 == valHi) && (S1(U1(V_DECIMAL(&vOut))).Mid32 == valMid) && \
1647 (S1(U1(V_DECIMAL(&vOut))).Lo32 == valLo), \
1648 "Expected decimal = %x/0x%x%08x, got %x/0x%x%08x\n", valHi, valMid, valLo, \
1649 V_DECIMAL(&vOut).Hi32, S1(U1(V_DECIMAL(&vOut))).Mid32, S1(U1(V_DECIMAL(&vOut))).Lo32); }
1651 static void test_VarNumFromParseNum(void)
1658 CHECKPTR(VarNumFromParseNum
);
1660 /* Convert the number 1 to different types */
1661 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_I1
); EXPECT_I1(1);
1662 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_UI1
); EXPECT_UI1(1);
1663 /* Prefers a signed type to unsigned of the same size */
1664 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_I1
|VTBIT_UI1
); EXPECT_I1(1);
1665 /* But takes the smaller size if possible */
1666 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_I2
|VTBIT_UI1
); EXPECT_UI1(1);
1668 /* Try different integer sizes */
1669 #define INTEGER_VTBITS (VTBIT_I1|VTBIT_UI1|VTBIT_I2|VTBIT_UI2|VTBIT_I4|VTBIT_UI4|VTBIT_I8|VTBIT_UI8)
1671 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, INTEGER_VTBITS
); EXPECT_I1(1);
1673 SETRGB(0, 1); SETRGB(1, 2); SETRGB(2, 7);
1674 CONVERT(3,0,0,3,0,0, INTEGER_VTBITS
); EXPECT_I1(127);
1676 SETRGB(0, 1); SETRGB(1, 2); SETRGB(2, 8);
1677 CONVERT(3,0,0,3,0,0, INTEGER_VTBITS
); EXPECT_UI1(128);
1679 SETRGB(0, 2); SETRGB(1, 5); SETRGB(2, 5);
1680 CONVERT(3,0,0,3,0,0, INTEGER_VTBITS
); EXPECT_UI1(255);
1682 SETRGB(0, 2); SETRGB(1, 5); SETRGB(2, 6);
1683 CONVERT(3,0,0,3,0,0, INTEGER_VTBITS
); EXPECT_I2(256);
1685 SETRGB(0, 3); SETRGB(1, 2); SETRGB(2, 7); SETRGB(3, 6); SETRGB(4, 7);
1686 CONVERT(5,0,0,5,0,0, INTEGER_VTBITS
); EXPECT_I2(32767);
1688 SETRGB(0, 3); SETRGB(1, 2); SETRGB(2, 7); SETRGB(3, 6); SETRGB(4, 8);
1689 CONVERT(5,0,0,5,0,0, INTEGER_VTBITS
); EXPECT_UI2(32768);
1691 /* Assume the above pattern holds for remaining positive integers; test negative */
1694 SETRGB(0, 1); SETRGB(1, 2); SETRGB(2, 8);
1695 CONVERT(3,0,NUMPRS_NEG
,3,0,0, INTEGER_VTBITS
); EXPECT_I1(-128);
1697 SETRGB(0, 1); SETRGB(1, 2); SETRGB(2, 9);
1698 CONVERT(3,0,NUMPRS_NEG
,3,0,0, INTEGER_VTBITS
); EXPECT_I2(-129);
1700 SETRGB(0, 3); SETRGB(1, 2); SETRGB(2, 7); SETRGB(3, 6); SETRGB(4, 8);
1701 CONVERT(5,0,NUMPRS_NEG
,5,0,0, INTEGER_VTBITS
); EXPECT_I2(-32768);
1703 SETRGB(0, 3); SETRGB(1, 2); SETRGB(2, 7); SETRGB(3, 6); SETRGB(4, 9);
1704 CONVERT(5,0,NUMPRS_NEG
,5,0,0, INTEGER_VTBITS
); EXPECT_I4(-32769);
1706 /* Assume the above pattern holds for remaining negative integers */
1708 /* Test hexadecimal conversions */
1709 SETRGB(0, 1); CONVERT(1,0,0,1,4,0, INTEGER_VTBITS
); EXPECT_I1(0x01);
1711 SETRGB(0, 7); SETRGB(1, 0xf);
1712 CONVERT(2,0,0,2,4,0, INTEGER_VTBITS
); EXPECT_I1(0x7f);
1713 SETRGB(0, 7); SETRGB(1, 0xf);
1714 CONVERT(2,0,0,2,4,0, VTBIT_DECIMAL
); EXPECT_DECIMAL(0,0,0x7f);
1716 SETRGB(0, 7); SETRGB(1, 0xf); SETRGB(2, 0xf); SETRGB(3, 0xf);
1717 CONVERT(4,0,0,4,4,0, INTEGER_VTBITS
); EXPECT_I2(0x7fff);
1719 SETRGB(0, 7); SETRGB(1, 0xf); SETRGB(2, 0xf); SETRGB(3, 0xf);
1720 SETRGB(4, 0xf); SETRGB(5, 0xf); SETRGB(6, 0xf); SETRGB(7, 0xf);
1721 CONVERT(8,0,0,8,4,0, INTEGER_VTBITS
); EXPECT_I4(0x7fffffffL
);
1722 /* 0x7fffffffffffffff (64 bits) */
1723 SETRGB(0, 7); SETRGB(1, 0xf); SETRGB(2, 0xf); SETRGB(3, 0xf);
1724 SETRGB(4, 0xf); SETRGB(5, 0xf); SETRGB(6, 0xf); SETRGB(7, 0xf);
1725 SETRGB(8, 0xf); SETRGB(9, 0xf); SETRGB(10, 0xf); SETRGB(11, 0xf);
1726 SETRGB(12, 0xf); SETRGB(13, 0xf); SETRGB(14, 0xf); SETRGB(15, 0xf);
1729 /* We cannot use INTEGER_VTBITS as WinXP and Win2003 are broken(?). They
1730 truncate the number to the smallest integer size requested:
1731 CONVERT(16,0,0,16,4,0, INTEGER_VTBITS); EXPECT_I1((signed char)0xff); */
1732 CONVERT(16,0,0,16,4,0, VTBIT_I8
); EXPECT_I8(0x7fffffff,0xffffffff);
1735 /* Assume the above pattern holds for numbers without hi-bit set, test (preservation of) hi-bit */
1737 SETRGB(0, 8); SETRGB(1, 2);
1738 CONVERT(2,0,0,2,4,0, INTEGER_VTBITS
);
1739 EXPECT_I1((signed char)0x82);
1741 SETRGB(0, 8); SETRGB(1, 0); SETRGB(2, 0); SETRGB(3, 2);
1742 CONVERT(4,0,0,4,4,0, INTEGER_VTBITS
);
1743 EXPECT_I2((signed short)0x8002);
1745 SETRGB(0, 8); SETRGB(1, 0); SETRGB(2, 0); SETRGB(3, 0);
1746 SETRGB(4, 0); SETRGB(5, 0); SETRGB(6, 0); SETRGB(7, 2);
1747 CONVERT(8,0,0,8,4,0, INTEGER_VTBITS
); EXPECT_I4(0x80000002);
1748 /* 0x8000000000000002 (64 bits) */
1749 SETRGB(0, 8); SETRGB(1, 0); SETRGB(2, 0); SETRGB(3, 0);
1750 SETRGB(4, 0); SETRGB(5, 0); SETRGB(6, 0); SETRGB(7, 0);
1751 SETRGB(8, 0); SETRGB(9, 0); SETRGB(10, 0); SETRGB(11, 0);
1752 SETRGB(12, 0); SETRGB(13, 0); SETRGB(14, 0); SETRGB(15, 2);
1755 /* We cannot use INTEGER_VTBITS as WinXP and Win2003 are broken(?). They
1756 truncate the number to the smallest integer size requested:
1757 CONVERT(16,0,0,16,4,0, INTEGER_VTBITS & ~VTBIT_I1);
1758 EXPECT_I2((signed short)0x0002); */
1759 CONVERT(16,0,0,16,4,0, VTBIT_I8
); EXPECT_I8(0x80000000,0x00000002);
1762 /* Test (preservation of) hi-bit with STRICT type requesting */
1764 SETRGB(0, 8); SETRGB(1, 2);
1765 CONVERT(2,0,0,2,4,0, VTBIT_I1
);
1766 EXPECT_I1((signed char)0x82);
1768 SETRGB(0, 8); SETRGB(1, 0); SETRGB(2, 0); SETRGB(3, 2);
1769 CONVERT(4,0,0,4,4,0, VTBIT_I2
);
1770 EXPECT_I2((signed short)0x8002);
1772 SETRGB(0, 8); SETRGB(1, 0); SETRGB(2, 0); SETRGB(3, 0);
1773 SETRGB(4, 0); SETRGB(5, 0); SETRGB(6, 0); SETRGB(7, 2);
1774 CONVERT(8,0,0,8,4,0, VTBIT_I4
); EXPECT_I4(0x80000002);
1775 /* 0x8000000000000002 (64 bits) */
1776 SETRGB(0, 8); SETRGB(1, 0); SETRGB(2, 0); SETRGB(3, 0);
1777 SETRGB(4, 0); SETRGB(5, 0); SETRGB(6, 0); SETRGB(7, 0);
1778 SETRGB(8, 0); SETRGB(9, 0); SETRGB(10, 0); SETRGB(11, 0);
1779 SETRGB(12, 0); SETRGB(13, 0); SETRGB(14, 0); SETRGB(15, 2);
1782 CONVERT(16,0,0,16,4,0, VTBIT_I8
); EXPECT_I8(0x80000000,0x00000002);
1784 /* Assume the above pattern holds for numbers with hi-bit set */
1786 /* Negative numbers overflow if we have only unsigned outputs */
1788 SETRGB(0, 1); CONVERT(1,0,NUMPRS_NEG
,1,0,0, VTBIT_UI1
); EXPECT_OVERFLOW
;
1790 SETRGB(0, 6); CONVERT(1,0,NUMPRS_NEG
,1,0,~0u, VTBIT_UI1
); EXPECT_OVERFLOW
;
1792 /* Except that rounding is done first, so -0.5 to 0 are accepted as 0 */
1794 SETRGB(0, 5); CONVERT(1,0,NUMPRS_NEG
,1,0,~0u, VTBIT_UI1
); EXPECT_UI1(0);
1796 /* Floating point zero is OK */
1798 SETRGB(0, 0); CONVERT(1,0,NUMPRS_DECIMAL
|NUMPRS_EXPONENT
,12,0,-8, VTBIT_R8
);
1801 /* Float is acceptable for an integer input value */
1802 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_R4
); EXPECT_R4(1.0f
);
1804 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_R8
); EXPECT_R8(1.0);
1805 /* As is currency */
1806 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_CY
); EXPECT_CY(1);
1808 /* Float is preferred over double */
1809 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_R4
|VTBIT_R8
); EXPECT_R4(1.0f
);
1811 /* Double is preferred over currency */
1812 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_R8
|VTBIT_CY
); EXPECT_R8(1.0);
1814 /* Currency is preferred over decimal */
1815 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_CY
|VTBIT_DECIMAL
); EXPECT_CY(1);
1819 static void test_UdateFromDate( int line
, DATE dt
, ULONG flags
, HRESULT r
, WORD d
, WORD m
, WORD y
,
1820 WORD h
, WORD mn
, WORD s
, WORD ms
, WORD dw
, WORD dy
)
1825 memset(&ud
, 0, sizeof(ud
));
1826 res
= pVarUdateFromDate(dt
, flags
, &ud
);
1827 ok_(__FILE__
,line
)(r
== res
&& (res
!= S_OK
|| (ud
.st
.wYear
== y
&& ud
.st
.wMonth
== m
&& ud
.st
.wDay
== d
&&
1828 ud
.st
.wHour
== h
&& ud
.st
.wMinute
== mn
&& ud
.st
.wSecond
== s
&&
1829 ud
.st
.wMilliseconds
== ms
&& ud
.st
.wDayOfWeek
== dw
&& ud
.wDayOfYear
== dy
)),
1830 "%.16g expected res(%x) %d,%d,%d,%d,%d,%d,%d %d %d, got res(%x) %d,%d,%d,%d,%d,%d,%d %d %d\n",
1831 dt
, r
, d
, m
, y
, h
, mn
, s
, ms
, dw
, dy
,
1832 res
, ud
.st
.wDay
, ud
.st
.wMonth
, ud
.st
.wYear
, ud
.st
.wHour
, ud
.st
.wMinute
,
1833 ud
.st
.wSecond
, ud
.st
.wMilliseconds
, ud
.st
.wDayOfWeek
, ud
.wDayOfYear
);
1835 #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)
1837 static void test_VarUdateFromDate(void)
1839 CHECKPTR(VarUdateFromDate
);
1840 DT2UD(29221.0,0,S_OK
,1,1,1980,0,0,0,0,2,1); /* 1 Jan 1980 */
1841 DT2UD(29222.0,0,S_OK
,2,1,1980,0,0,0,0,3,2); /* 2 Jan 1980 */
1842 DT2UD(33238.0,0,S_OK
,31,12,1990,0,0,0,0,1,365); /* 31 Dec 1990 */
1843 DT2UD(0.0,0,S_OK
,30,12,1899,0,0,0,0,6,364); /* 30 Dec 1899 - VT_DATE 0.0 */
1844 DT2UD(-657434.0,0,S_OK
,1,1,100,0,0,0,0,5,1); /* 1 Jan 100 - Min */
1845 DT2UD(-657435.0,0,E_INVALIDARG
,0,0,0,0,0,0,0,0,0); /* < 1 Jan 100 => err */
1846 DT2UD(2958465.0,0,S_OK
,31,12,9999,0,0,0,0,5,365); /* 31 Dec 9999 - Max */
1847 DT2UD(2958466.0,0,E_INVALIDARG
,0,0,0,0,0,0,0,0,0); /* > 31 Dec 9999 => err */
1849 /* VAR_VALIDDATE doesn't prevent upper and lower bounds being checked */
1850 DT2UD(-657435.0,VAR_VALIDDATE
,E_INVALIDARG
,0,0,0,0,0,0,0,0,0);
1851 DT2UD(2958466.0,VAR_VALIDDATE
,E_INVALIDARG
,0,0,0,0,0,0,0,0,0);
1854 DT2UD(29221.25,0,S_OK
,1,1,1980,6,0,0,0,2,1); /* 6 AM */
1855 DT2UD(29221.33333333,0,S_OK
,1,1,1980,8,0,0,0,2,1); /* 8 AM */
1856 DT2UD(29221.5,0,S_OK
,1,1,1980,12,0,0,0,2,1); /* 12 AM */
1857 DT2UD(29221.9888884444,0,S_OK
,1,1,1980,23,44,0,0,2,1); /* 11:44 PM */
1858 DT2UD(29221.7508765432,0,S_OK
,1,1,1980,18,1,16,0,2,1); /* 6:18:02 PM */
1860 /* Test handling of times on dates prior to the epoch */
1861 DT2UD(-5.25,0,S_OK
,25,12,1899,6,0,0,0,1,359);
1862 DT2UD(-5.9999884259259,0,S_OK
,25,12,1899,23,59,59,0,1,359);
1863 /* This just demonstrates the non-linear nature of values prior to the epoch */
1864 DT2UD(-4.0,0,S_OK
,26,12,1899,0,0,0,0,2,360);
1865 /* Numerical oddity: for 0.0 < x < 1.0, x and -x represent the same datetime */
1866 DT2UD(-0.25,0,S_OK
,30,12,1899,6,0,0,0,6,364);
1867 DT2UD(0.25,0,S_OK
,30,12,1899,6,0,0,0,6,364);
1871 static void test_DateFromUDate( int line
, WORD d
, WORD m
, WORD y
, WORD h
, WORD mn
, WORD s
, WORD ms
,
1872 WORD dw
, WORD dy
, ULONG flags
, HRESULT r
, DATE dt
)
1884 ud
.st
.wMilliseconds
= ms
;
1885 ud
.st
.wDayOfWeek
= dw
;
1887 res
= pVarDateFromUdate(&ud
, flags
, &out
);
1888 ok_(__FILE__
,line
)(r
== res
&& (r
!= S_OK
|| EQ_DOUBLE(out
, dt
)),
1889 "expected %x, %.16g, got %x, %.16g\n", r
, dt
, res
, out
);
1891 #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)
1893 static void test_VarDateFromUdate(void)
1895 CHECKPTR(VarDateFromUdate
);
1896 UD2T(1,1,1980,0,0,0,0,2,1,0,S_OK
,29221.0); /* 1 Jan 1980 */
1897 UD2T(2,1,1980,0,0,0,0,3,2,0,S_OK
,29222.0); /* 2 Jan 1980 */
1898 UD2T(2,1,1980,0,0,0,0,4,5,0,S_OK
,29222.0); /* 2 Jan 1980 */
1899 UD2T(31,12,1990,0,0,0,0,0,0,0,S_OK
,33238.0); /* 31 Dec 1990 */
1900 UD2T(31,12,90,0,0,0,0,0,0,0,S_OK
,33238.0); /* year < 100 is 1900+year! */
1901 UD2T(30,12,1899,0,0,0,0,6,364,0,S_OK
,0.0); /* 30 Dec 1899 - VT_DATE 0.0 */
1902 UD2T(1,1,100,0,0,0,0,0,0,0,S_OK
,-657434.0); /* 1 Jan 100 - Min */
1903 UD2T(31,12,9999,0,0,0,0,0,0,0,S_OK
,2958465.0); /* 31 Dec 9999 - Max */
1904 UD2T(1,1,10000,0,0,0,0,0,0,0,E_INVALIDARG
,0.0); /* > 31 Dec 9999 => err */
1905 UD2T(1,1,-10000,0,0,0,0,0,0,0,E_INVALIDARG
,0.0);/* < -9999 => err */
1907 UD2T(30,12,1899,0,0,0,0,0,0,0,S_OK
,0.0); /* 30 Dec 1899 0:00:00 */
1908 UD2T(30,12,1899,0,0,0,999,0,0,0,S_OK
,0.0); /* Ignore milliseconds */
1910 UD2T(1,1,1980,18,1,16,0,2,1,0,S_OK
,29221.75087962963); /* 6:18:02 PM */
1911 UD2T(1,300,1980,18,1,16,0,2,1,0,S_OK
,38322.75087962963); /* Test fwdrolled month */
1912 UD2T(300,1,1980,18,1,16,0,2,1,0,S_OK
,29520.75087962963); /* Test fwdrolled days */
1913 UD2T(0,1,1980,42,1,16,0,2,1,0,S_OK
,29221.75087962963); /* Test fwdrolled hours */
1914 UD2T(1,1,1980,17,61,16,0,2,1,0,S_OK
,29221.75087962963); /* Test fwdrolled minutes */
1915 UD2T(1,1,1980,18,0,76,0,2,1,0,S_OK
,29221.75087962963); /* Test fwdrolled seconds */
1916 UD2T(1,-300,1980,18,1,16,0,2,1,0,S_OK
,20059.75087962963); /* Test backrolled month */
1917 UD2T(-300,1,1980,18,1,16,0,2,1,0,S_OK
,28920.75087962963); /* Test backrolled days */
1918 UD2T(3,1,1980,-30,1,16,0,2,1,0,S_OK
,29221.75087962963); /* Test backrolled hours */
1919 UD2T(1,1,1980,20,-119,16,0,2,1,0,S_OK
,29221.75087962963); /* Test backrolled minutes */
1920 UD2T(1,1,1980,18,3,-104,0,2,1,0,S_OK
,29221.75087962963); /* Test backrolled seconds */
1921 UD2T(1,12001,-1020,18,1,16,0,0,0,0,S_OK
,29221.75087962963); /* Test rolled year and month */
1922 UD2T(1,-23,1982,18,1,16,0,0,0,0,S_OK
,29221.75087962963); /* Test backrolled month */
1923 UD2T(-59,3,1980,18,1,16,0,0,0,0,S_OK
,29221.75087962963); /* Test backrolled days */
1924 UD2T(1,1,0,0,0,0,0,0,0,0,S_OK
,36526); /* Test zero year */
1925 UD2T(0,0,1980,0,0,0,0,0,0,0,S_OK
,29189); /* Test zero day and month */
1926 UD2T(0,1,1980,0,0,0,0,2,1,0,S_OK
,29220.0); /* Test zero day = LastDayOfMonth */
1927 UD2T(-1,1,1980,18,1,16,0,0,0,0,S_OK
,29219.75087962963); /* Test day -1 = LastDayOfMonth - 1 */
1928 UD2T(1,1,-1,18,1,16,0,0,0,0,S_OK
,36161.75087962963); /* Test year -1 = 1999 */
1929 UD2T(1,-1,1980,18,1,16,0,0,0,0,S_OK
,29160.7508796296); /* Test month -1 = 11 */
1930 UD2T(1,13,1980,0,0,0,0,2,1,0,S_OK
,29587.0); /* Rolls fwd to 1/1/1981 */
1932 /* Test handling of times on dates prior to the epoch */
1933 UD2T(25,12,1899,6,0,0,0,1,359,0,S_OK
,-5.25);
1934 UD2T(25,12,1899,23,59,59,0,1,359,0,S_OK
,-5.9999884259259);
1935 /* This just demonstrates the non-linear nature of values prior to the epoch */
1936 UD2T(26,12,1899,0,0,0,0,2,360,0,S_OK
,-4.0);
1937 /* for DATE values 0.0 < x < 1.0, x and -x represent the same datetime */
1938 /* but when converting to DATE, prefer the positive versions */
1939 UD2T(30,12,1899,6,0,0,0,6,364,0,S_OK
,0.25);
1942 static void test_st2dt(int line
, WORD d
, WORD m
, WORD y
, WORD h
, WORD mn
,
1943 WORD s
, WORD ms
, INT r
, double dt
)
1955 st
.wMilliseconds
= ms
;
1957 res
= pSystemTimeToVariantTime(&st
, &out
);
1958 ok_(__FILE__
,line
)(r
== res
&& (!r
|| EQ_DOUBLE(out
, dt
)),
1959 "expected %d, %.16g, got %d, %.16g\n", r
, dt
, res
, out
);
1961 #define ST2DT(d,m,y,h,mn,s,ms,r,dt) test_st2dt(__LINE__,d,m,y,h,mn,s,ms,r,dt)
1963 static void test_SystemTimeToVariantTime(void)
1965 CHECKPTR(SystemTimeToVariantTime
);
1966 ST2DT(1,1,1980,0,0,0,0,TRUE
,29221.0);
1967 ST2DT(2,1,1980,0,0,0,0,TRUE
,29222.0);
1968 ST2DT(0,1,1980,0,0,0,0,TRUE
,29220.0); /* Rolls back to 31 Dec 1899 */
1969 ST2DT(1,13,1980,0,0,0,0,FALSE
,29587.0); /* Fails on invalid month */
1970 ST2DT(32,1,1980,0,0,0,0,FALSE
,0.0); /* Fails on invalid day */
1971 ST2DT(1,1,-1,0,0,0,0,FALSE
,0.0); /* Fails on invalid year */
1972 ST2DT(1,1,10000,0,0,0,0,FALSE
,0.0); /* Fails on invalid year */
1973 ST2DT(1,1,9999,0,0,0,0,TRUE
,2958101.0); /* 9999 is last valid year */
1974 ST2DT(31,12,90,0,0,0,0,TRUE
,33238.0); /* 30 <= year < 100 is 1900+year */
1975 ST2DT(1,1,30,0,0,0,0,TRUE
,10959.0); /* 30 <= year < 100 is 1900+year */
1976 ST2DT(1,1,29,0,0,0,0,TRUE
,47119.0); /* 0 <= year < 30 is 2000+year */
1977 ST2DT(1,1,0,0,0,0,0,TRUE
,36526.0); /* 0 <= year < 30 is 2000+year */
1980 static void test_dt2st(int line
, double dt
, INT r
, WORD d
, WORD m
, WORD y
,
1981 WORD h
, WORD mn
, WORD s
, WORD ms
)
1986 memset(&st
, 0, sizeof(st
));
1987 res
= pVariantTimeToSystemTime(dt
, &st
);
1988 ok_(__FILE__
,line
)(r
== res
&&
1989 (!r
|| (st
.wYear
== y
&& st
.wMonth
== m
&& st
.wDay
== d
&&
1990 st
.wHour
== h
&& st
.wMinute
== mn
&&
1991 st
.wSecond
== s
&& st
.wMilliseconds
== ms
)),
1992 "%.16g expected %d, %d,%d,%d,%d,%d,%d,%d, got %d, %d,%d,%d,%d,%d,%d,%d\n",
1993 dt
, r
, d
, m
, y
, h
, mn
, s
, ms
, res
, st
.wDay
, st
.wMonth
,
1994 st
.wYear
, st
.wHour
, st
.wMinute
, st
.wSecond
,
1997 #define DT2ST(dt,r,d,m,y,h,mn,s,ms) test_dt2st(__LINE__,dt,r,d,m,y,h,mn,s,ms)
1999 static void test_VariantTimeToSystemTime(void)
2001 CHECKPTR(VariantTimeToSystemTime
);
2002 DT2ST(29221.0,1,1,1,1980,0,0,0,0);
2003 DT2ST(29222.0,1,2,1,1980,0,0,0,0);
2006 #define MKDOSDATE(d,m,y) ((d & 0x1f) | ((m & 0xf) << 5) | (((y-1980) & 0x7f) << 9))
2007 #define MKDOSTIME(h,m,s) (((s>>1) & 0x1f) | ((m & 0x3f) << 5) | ((h & 0x1f) << 11))
2009 static void test_dos2dt(int line
, WORD d
, WORD m
, WORD y
, WORD h
, WORD mn
,
2010 WORD s
, INT r
, double dt
)
2012 unsigned short dosDate
, dosTime
;
2017 dosDate
= MKDOSDATE(d
, m
, y
);
2018 dosTime
= MKDOSTIME(h
, mn
, s
);
2019 res
= pDosDateTimeToVariantTime(dosDate
, dosTime
, &out
);
2020 ok_(__FILE__
,line
)(r
== res
&& (!r
|| EQ_DOUBLE(out
, dt
)),
2021 "expected %d, %.16g, got %d, %.16g\n", r
, dt
, res
, out
);
2023 #define DOS2DT(d,m,y,h,mn,s,r,dt) test_dos2dt(__LINE__,d,m,y,h,mn,s,r,dt)
2025 static void test_DosDateTimeToVariantTime(void)
2027 CHECKPTR(DosDateTimeToVariantTime
);
2030 DOS2DT(1,1,1980,0,0,0,1,29221.0); /* 1/1/1980 */
2031 DOS2DT(31,12,2099,0,0,0,1,73050.0); /* 31/12/2099 */
2032 /* Dates are limited to the dos date max of 31/12/2099 */
2033 DOS2DT(31,12,2100,0,0,0,0,0.0); /* 31/12/2100 */
2034 /* Days and months of 0 cause date to roll back 1 day or month */
2035 DOS2DT(0,1,1980,0,0,0,1,29220.0); /* 0 Day => 31/12/1979 */
2036 DOS2DT(1,0,1980,0,0,0,1,29190.0); /* 0 Mth => 1/12/1979 */
2037 DOS2DT(0,0,1980,0,0,0,1,29189.0); /* 0 D/M => 30/11/1979 */
2038 /* Days > days in the month cause date to roll forward 1 month */
2039 DOS2DT(29,2,1981,0,0,0,1,29646.0); /* 29/2/1981 -> 3/1/1980 */
2040 DOS2DT(30,2,1981,0,0,0,1,29647.0); /* 30/2/1981 -> 4/1/1980 */
2041 /* Takes leap years into account when rolling forward */
2042 DOS2DT(29,2,1980,0,0,0,1,29280.0); /* 2/29/1980 */
2043 /* Months > 12 cause an error */
2044 DOS2DT(2,13,1980,0,0,0,0,0.0);
2047 DOS2DT(1,1,1980,0,0,29,1,29221.00032407407); /* 1/1/1980 12:00:28 AM */
2048 DOS2DT(1,1,1980,0,0,31,1,29221.00034722222); /* 1/1/1980 12:00:30 AM */
2049 DOS2DT(1,1,1980,0,59,0,1,29221.04097222222); /* 1/1/1980 12:59:00 AM */
2050 DOS2DT(1,1,1980,0,60,0,0,0.0); /* Invalid minutes */
2051 DOS2DT(1,1,1980,0,0,60,0,0.0); /* Invalid seconds */
2052 DOS2DT(1,1,1980,23,0,0,1,29221.95833333333); /* 1/1/1980 11:00:00 PM */
2053 DOS2DT(1,1,1980,24,0,0,0,0.0); /* Invalid hours */
2055 DOS2DT(1,1,1980,0,0,1,1,29221.0);
2056 DOS2DT(2,1,1980,0,0,0,1,29222.0);
2057 DOS2DT(2,1,1980,0,0,0,1,29222.0);
2058 DOS2DT(31,12,1990,0,0,0,1,33238.0);
2059 DOS2DT(31,12,90,0,0,0,1,40543.0);
2060 DOS2DT(30,12,1899,0,0,0,1,46751.0);
2061 DOS2DT(1,1,100,0,0,0,1,43831.0);
2062 DOS2DT(31,12,9999,0,0,0,1,59901.0);
2063 DOS2DT(1,1,10000,0,0,0,1,59902.0);
2064 DOS2DT(1,1,-10000,0,0,0,1,48214.0);
2066 DOS2DT(30,12,1899,0,0,0,1,46751.0);
2067 DOS2DT(30,12,1899,0,0,1,1,46751.0);
2069 DOS2DT(1,1,1980,18,1,16,1,29221.75087962963);
2070 DOS2DT(1,300,1980,18,1,16,1,29556.75087962963);
2071 DOS2DT(300,1,1980,18,1,16,1,29232.75087962963);
2072 DOS2DT(0,1,1980,42,1,16,1,29220.4175462963);
2073 DOS2DT(1,1,1980,17,61,16,0,0.0);
2074 DOS2DT(1,1,1980,18,0,76,1,29221.75013888889);
2075 DOS2DT(1,-300,1980,18,1,16,1,29312.75087962963);
2076 DOS2DT(-300,1,1980,18,1,16,1,29240.75087962963);
2077 DOS2DT(3,1,1980,-30,1,16,1,29223.08421296296);
2078 DOS2DT(1,1,1980,20,-119,16,1,29221.83976851852);
2079 DOS2DT(1,1,1980,18,3,-104,1,29221.75236111111);
2080 DOS2DT(1,12001,-1020,18,1,16,1,55519.75087962963);
2081 DOS2DT(1,-23,1982,18,1,16,1,30195.75087962963);
2082 DOS2DT(-59,3,1980,18,1,16,1,29285.75087962963);
2083 DOS2DT(1,1,0,0,0,0,1,54058.0);
2084 DOS2DT(0,0,1980,0,0,0,1,29189.0);
2085 DOS2DT(0,1,1980,0,0,0,1,29220.0);
2086 DOS2DT(-1,1,1980,18,1,16,1,29251.75087962963);
2087 DOS2DT(1,1,-1,18,1,16,1,53693.75087962963);
2088 DOS2DT(1,-1,1980,18,1,16,0,0);
2091 static void test_dt2dos(int line
, double dt
, INT r
, WORD d
, WORD m
, WORD y
,
2092 WORD h
, WORD mn
, WORD s
)
2094 unsigned short dosDate
, dosTime
, expDosDate
, expDosTime
;
2097 dosTime
= dosDate
= 0;
2098 expDosDate
= MKDOSDATE(d
,m
,y
);
2099 expDosTime
= MKDOSTIME(h
,mn
,s
);
2100 res
= pVariantTimeToDosDateTime(dt
, &dosDate
, &dosTime
);
2101 ok_(__FILE__
,line
)(r
== res
&& (!r
|| (dosTime
== expDosTime
&& dosDate
== expDosDate
)),
2102 "%g: expected %d,%d(%d/%d/%d),%d(%d:%d:%d) got %d,%d(%d/%d/%d),%d(%d:%d:%d)\n",
2103 dt
, r
, expDosDate
, expDosDate
& 0x1f,
2104 (expDosDate
>> 5) & 0xf, 1980 + (expDosDate
>> 9),
2105 expDosTime
, expDosTime
>> 11, (expDosTime
>> 5) & 0x3f,
2106 (expDosTime
& 0x1f),
2107 res
, dosDate
, dosDate
& 0x1f, (dosDate
>> 5) & 0xf,
2108 1980 + (dosDate
>> 9), dosTime
, dosTime
>> 11,
2109 (dosTime
>> 5) & 0x3f, (dosTime
& 0x1f));
2111 #define DT2DOS(dt,r,d,m,y,h,mn,s) test_dt2dos(__LINE__,dt,r,d,m,y,h,mn,s)
2113 static void test_VariantTimeToDosDateTime(void)
2115 CHECKPTR(VariantTimeToDosDateTime
);
2118 DT2DOS(29221.0,1,1,1,1980,0,0,0); /* 1/1/1980 */
2119 DT2DOS(73050.0,1,31,12,2099,0,0,0); /* 31/12/2099 */
2120 DT2DOS(29220.0,0,0,0,0,0,0,0); /* 31/12/1979 - out of range */
2121 DT2DOS(73415.0,0,0,0,0,0,0,0); /* 31/12/2100 - out of range */
2124 DT2DOS(29221.00032407407,1,1,1,1980,0,0,29); /* 1/1/1980 12:00:28 AM */
2125 DT2DOS(29221.00034722222,1,1,1,1980,0,0,31); /* 1/1/1980 12:00:30 AM */
2126 DT2DOS(29221.04097222222,1,1,1,1980,0,59,0); /* 1/1/1980 12:59:00 AM */
2127 DT2DOS(29221.95833333333,1,1,1,1980,23,0,0); /* 1/1/1980 11:00:00 PM */
2130 static HRESULT (WINAPI
*pVarAbs
)(LPVARIANT
,LPVARIANT
);
2132 #define VARABS(vt,val,rvt,rval) \
2133 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
2134 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
2135 test_var_call1( __LINE__, pVarAbs, &v, &exp )
2137 static void test_VarAbs(void)
2139 static WCHAR szNum
[] = {'-','1','.','1','\0' };
2142 VARIANT v
, vDst
, exp
;
2147 /* Test all possible V_VT values.
2149 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
2153 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
2155 HRESULT hExpected
= DISP_E_BADVARTYPE
;
2159 memset(&v
, 0, sizeof(v
));
2160 V_VT(&v
) = vt
| ExtraFlags
[i
];
2161 V_VT(&vDst
) = VT_EMPTY
;
2163 hres
= pVarAbs(&v
,&vDst
);
2164 if (ExtraFlags
[i
] & (VT_ARRAY
|VT_ARRAY
) ||
2165 (!ExtraFlags
[i
] && (vt
== VT_UNKNOWN
|| vt
== VT_BSTR
||
2166 vt
== VT_DISPATCH
|| vt
== VT_ERROR
|| vt
== VT_RECORD
)))
2168 hExpected
= DISP_E_TYPEMISMATCH
;
2170 else if (ExtraFlags
[i
] || vt
>= VT_CLSID
|| vt
== VT_VARIANT
)
2172 hExpected
= DISP_E_BADVARTYPE
;
2174 else if (IsValidVariantClearVT(vt
, ExtraFlags
[i
]))
2177 /* Native always fails on some vartypes that should be valid. don't
2178 * check that Wine does the same; these are bugs in native.
2180 if (vt
== VT_I8
|| vt
== VT_UI8
|| vt
== VT_INT
|| vt
== VT_UINT
||
2181 vt
== VT_I1
|| vt
== VT_UI2
|| vt
== VT_UI4
)
2183 ok(hres
== hExpected
, "VarAbs: expected 0x%X, got 0x%X for vt %d | 0x%X\n",
2184 hExpected
, hres
, vt
, ExtraFlags
[i
]);
2188 /* BOOL->I2, BSTR->R8, all others remain the same */
2189 VARABS(BOOL
,VARIANT_TRUE
,I2
,-VARIANT_TRUE
);
2190 VARABS(BOOL
,VARIANT_FALSE
,I2
,VARIANT_FALSE
);
2191 VARABS(EMPTY
,0,I2
,0);
2192 VARABS(EMPTY
,1,I2
,0);
2193 VARABS(NULL
,0,NULL
,0);
2194 VARABS(NULL
,1,NULL
,0);
2199 VARABS(UI1
,1,UI1
,1);
2204 VARABS(DATE
,1,DATE
,1);
2205 VARABS(DATE
,-1,DATE
,1);
2207 V_CY(&v
).int64
= -10000;
2208 memset(&vDst
,0,sizeof(vDst
));
2209 hres
= pVarAbs(&v
,&vDst
);
2210 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_CY
&& V_CY(&vDst
).int64
== 10000,
2211 "VarAbs(CY): expected 0x0 got 0x%X\n", hres
);
2212 GetLocaleInfoA(LOCALE_USER_DEFAULT
, LOCALE_SDECIMAL
, buff
, sizeof(buff
)/sizeof(char));
2215 trace("Skipping VarAbs(BSTR) as decimal separator is '%s'\n", buff
);
2221 V_BSTR(&v
) = (BSTR
)szNum
;
2222 memset(&vDst
,0,sizeof(vDst
));
2223 hres
= pVarAbs(&v
,&vDst
);
2224 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_R8
&& V_R8(&vDst
) == 1.1,
2225 "VarAbs: expected 0x0,%d,%g, got 0x%X,%d,%g\n", VT_R8
, 1.1, hres
, V_VT(&vDst
), V_R8(&vDst
));
2228 static HRESULT (WINAPI
*pVarNot
)(LPVARIANT
,LPVARIANT
);
2230 #define VARNOT(vt,val,rvt,rval) \
2231 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
2232 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
2233 test_var_call1( __LINE__, pVarNot, &v, &exp )
2235 static void test_VarNot(void)
2237 static const WCHAR szNum0
[] = {'0','\0' };
2238 static const WCHAR szNum1
[] = {'1','\0' };
2239 static const WCHAR szFalse
[] = { '#','F','A','L','S','E','#','\0' };
2240 static const WCHAR szTrue
[] = { '#','T','R','U','E','#','\0' };
2242 VARIANT v
, exp
, vDst
;
2243 DECIMAL
*pdec
= &V_DECIMAL(&v
);
2244 CY
*pcy
= &V_CY(&v
);
2249 /* Test all possible V_VT values */
2250 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
2254 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
2256 HRESULT hExpected
= DISP_E_BADVARTYPE
;
2260 memset(&v
, 0, sizeof(v
));
2261 V_VT(&v
) = vt
| ExtraFlags
[i
];
2262 V_VT(&vDst
) = VT_EMPTY
;
2266 case VT_I1
: case VT_UI1
: case VT_I2
: case VT_UI2
:
2267 case VT_INT
: case VT_UINT
: case VT_I4
: case VT_UI4
:
2268 case VT_R4
: case VT_R8
:
2269 case VT_DECIMAL
: case VT_BOOL
: case VT_NULL
: case VT_EMPTY
:
2270 case VT_DATE
: case VT_CY
:
2273 case VT_I8
: case VT_UI8
:
2278 hExpected
= DISP_E_TYPEMISMATCH
;
2280 case VT_UNKNOWN
: case VT_BSTR
: case VT_DISPATCH
: case VT_ERROR
:
2281 hExpected
= DISP_E_TYPEMISMATCH
;
2284 if (IsValidVariantClearVT(vt
, ExtraFlags
[i
]) && vt
!= VT_CLSID
)
2285 hExpected
= DISP_E_TYPEMISMATCH
;
2289 hres
= pVarNot(&v
,&vDst
);
2290 ok(hres
== hExpected
, "VarNot: expected 0x%X, got 0x%X vt %d|0x%X\n",
2291 hExpected
, hres
, vt
, ExtraFlags
[i
]);
2294 /* Test the values returned by all cases that can succeed */
2295 VARNOT(EMPTY
,0,I2
,-1);
2296 VARNOT(EMPTY
,1,I2
,-1);
2297 VARNOT(NULL
,0,NULL
,0);
2298 VARNOT(NULL
,1,NULL
,0);
2299 VARNOT(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
);
2300 VARNOT(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
);
2308 VARNOT(UI1
,1,UI1
,254);
2309 VARNOT(UI1
,0,UI1
,255);
2310 VARNOT(UI2
,0,I4
,-1);
2311 VARNOT(UI2
,1,I4
,-2);
2312 VARNOT(UI4
,0,I4
,-1);
2313 VARNOT(UI4
,1,I4
,-2);
2314 VARNOT(INT
,0,I4
,-1);
2315 VARNOT(INT
,1,I4
,-2);
2316 VARNOT(UINT
,0,I4
,-1);
2317 VARNOT(UINT
,1,I4
,-2);
2322 VARNOT(UI8
,0,I4
,-1);
2323 VARNOT(UI8
,1,I4
,-2);
2329 VARNOT(DATE
,1,I4
,-2);
2330 VARNOT(DATE
,0,I4
,-1);
2331 VARNOT(BSTR
,(BSTR
)szNum0
,I4
,-1);
2332 ok(V_VT(&v
) == VT_BSTR
&& V_BSTR(&v
) == szNum0
, "VarNot(0): changed input\n");
2333 VARNOT(BSTR
,(BSTR
)szNum1
,I4
,-2);
2334 ok(V_VT(&v
) == VT_BSTR
&& V_BSTR(&v
) == szNum1
, "VarNot(1): changed input\n");
2335 VARNOT(BSTR
, (BSTR
)szTrue
, BOOL
, VARIANT_FALSE
);
2336 VARNOT(BSTR
, (BSTR
)szFalse
, BOOL
, VARIANT_TRUE
);
2338 V_VT(&v
) = VT_DECIMAL
;
2339 S(U(*pdec
)).sign
= DECIMAL_NEG
;
2340 S(U(*pdec
)).scale
= 0;
2342 S1(U1(*pdec
)).Mid32
= 0;
2343 S1(U1(*pdec
)).Lo32
= 1;
2344 VARNOT(DECIMAL
,*pdec
,I4
,0);
2347 VARNOT(CY
,*pcy
,I4
,-2);
2350 VARNOT(CY
,*pcy
,I4
,-1);
2353 VARNOT(CY
,*pcy
,I4
,-1);
2356 static HRESULT (WINAPI
*pVarSub
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
2358 #define VARSUB(vt1,val1,vt2,val2,rvt,rval) \
2359 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
2360 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
2361 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
2362 test_var_call2( __LINE__, pVarSub, &left, &right, &exp )
2364 static void test_VarSub(void)
2366 VARIANT left
, right
, exp
, result
, cy
, dec
;
2369 HRESULT hres
, expectedhres
;
2374 lbstr
= SysAllocString(sz12
);
2375 rbstr
= SysAllocString(sz12
);
2378 VariantInit(&right
);
2379 VariantInit(&result
);
2381 /* Test all possible flag/vt combinations & the resulting vt type */
2382 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
2385 VARTYPE leftvt
, rightvt
, resvt
;
2387 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
2392 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
2396 expectedhres
= S_OK
;
2398 memset(&left
, 0, sizeof(left
));
2399 memset(&right
, 0, sizeof(right
));
2400 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
2401 if (leftvt
== VT_BSTR
)
2402 V_BSTR(&left
) = lbstr
;
2403 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
2404 if (rightvt
== VT_BSTR
)
2405 V_BSTR(&right
) = rbstr
;
2406 V_VT(&result
) = VT_EMPTY
;
2408 /* All extra flags produce errors */
2409 if (ExtraFlags
[i
] == (VT_VECTOR
|VT_BYREF
|VT_RESERVED
) ||
2410 ExtraFlags
[i
] == (VT_VECTOR
|VT_RESERVED
) ||
2411 ExtraFlags
[i
] == (VT_VECTOR
|VT_BYREF
) ||
2412 ExtraFlags
[i
] == (VT_BYREF
|VT_RESERVED
) ||
2413 ExtraFlags
[i
] == VT_VECTOR
||
2414 ExtraFlags
[i
] == VT_BYREF
||
2415 ExtraFlags
[i
] == VT_RESERVED
)
2417 expectedhres
= DISP_E_BADVARTYPE
;
2420 else if (ExtraFlags
[i
] >= VT_ARRAY
)
2422 expectedhres
= DISP_E_TYPEMISMATCH
;
2425 /* Native VarSub cannot handle: VT_I1, VT_UI2, VT_UI4,
2426 VT_INT, VT_UINT and VT_UI8. Tested with WinXP */
2427 else if (!IsValidVariantClearVT(leftvt
, ExtraFlags
[i
]) ||
2428 !IsValidVariantClearVT(rightvt
, ExtraFlags
[i
]) ||
2429 leftvt
== VT_CLSID
|| rightvt
== VT_CLSID
||
2430 leftvt
== VT_VARIANT
|| rightvt
== VT_VARIANT
||
2431 leftvt
== VT_I1
|| rightvt
== VT_I1
||
2432 leftvt
== VT_UI2
|| rightvt
== VT_UI2
||
2433 leftvt
== VT_UI4
|| rightvt
== VT_UI4
||
2434 leftvt
== VT_UI8
|| rightvt
== VT_UI8
||
2435 leftvt
== VT_INT
|| rightvt
== VT_INT
||
2436 leftvt
== VT_UINT
|| rightvt
== VT_UINT
||
2437 leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
||
2438 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
)
2440 if (leftvt
== VT_RECORD
&& rightvt
== VT_I8
)
2443 expectedhres
= DISP_E_TYPEMISMATCH
;
2445 expectedhres
= DISP_E_BADVARTYPE
;
2447 else if (leftvt
< VT_UI1
&& rightvt
== VT_RECORD
)
2448 expectedhres
= DISP_E_TYPEMISMATCH
;
2449 else if (leftvt
>= VT_UI1
&& rightvt
== VT_RECORD
)
2450 expectedhres
= DISP_E_TYPEMISMATCH
;
2451 else if (leftvt
== VT_RECORD
&& rightvt
<= VT_UI1
)
2452 expectedhres
= DISP_E_TYPEMISMATCH
;
2453 else if (leftvt
== VT_RECORD
&& rightvt
> VT_UI1
)
2454 expectedhres
= DISP_E_BADVARTYPE
;
2456 expectedhres
= DISP_E_BADVARTYPE
;
2459 else if ((leftvt
== VT_NULL
&& rightvt
== VT_DISPATCH
) ||
2460 (leftvt
== VT_DISPATCH
&& rightvt
== VT_NULL
))
2462 else if (leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
||
2463 leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
)
2466 expectedhres
= DISP_E_TYPEMISMATCH
;
2468 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
2470 else if ((leftvt
== VT_EMPTY
&& rightvt
== VT_BSTR
) ||
2471 (leftvt
== VT_DATE
&& rightvt
== VT_DATE
) ||
2472 (leftvt
== VT_BSTR
&& rightvt
== VT_EMPTY
) ||
2473 (leftvt
== VT_BSTR
&& rightvt
== VT_BSTR
))
2475 else if (leftvt
== VT_DECIMAL
|| rightvt
== VT_DECIMAL
)
2477 else if (leftvt
== VT_DATE
|| rightvt
== VT_DATE
)
2479 else if (leftvt
== VT_CY
|| rightvt
== VT_CY
)
2481 else if (leftvt
== VT_R8
|| rightvt
== VT_R8
)
2483 else if (leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
) {
2485 } else if (leftvt
== VT_R4
|| rightvt
== VT_R4
) {
2486 if (leftvt
== VT_I4
|| rightvt
== VT_I4
||
2487 leftvt
== VT_I8
|| rightvt
== VT_I8
)
2492 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
2494 else if (leftvt
== VT_I4
|| rightvt
== VT_I4
)
2496 else if (leftvt
== VT_I2
|| rightvt
== VT_I2
||
2497 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
||
2498 (leftvt
== VT_EMPTY
&& rightvt
== VT_EMPTY
))
2500 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
2505 expectedhres
= DISP_E_TYPEMISMATCH
;
2508 hres
= pVarSub(&left
, &right
, &result
);
2510 ok(hres
== expectedhres
&& V_VT(&result
) == resvt
,
2511 "VarSub: %d|0x%X, %d|0x%X: Expected failure 0x%X, "
2512 "got 0x%X, expected vt %d got vt %d\n",
2513 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
],
2514 expectedhres
, hres
, resvt
, V_VT(&result
));
2519 /* Test returned values */
2520 VARSUB(I4
,4,I4
,2,I4
,2);
2521 VARSUB(I2
,4,I2
,2,I2
,2);
2522 VARSUB(I2
,-13,I4
,5,I4
,-18);
2523 VARSUB(I4
,-13,I4
,5,I4
,-18);
2524 VARSUB(I2
,7,R4
,0.5f
,R4
,6.5f
);
2525 VARSUB(R4
,0.5f
,I4
,5,R8
,-4.5);
2526 VARSUB(R8
,7.1,BOOL
,0,R8
,7.1);
2527 VARSUB(BSTR
,lbstr
,I2
,4,R8
,8);
2528 VARSUB(BSTR
,lbstr
,BOOL
,1,R8
,11);
2529 VARSUB(BSTR
,lbstr
,R4
,0.1f
,R8
,11.9);
2530 VARSUB(R4
,0.2f
,BSTR
,rbstr
,R8
,-11.8);
2531 VARSUB(DATE
,2.25,I4
,7,DATE
,-4.75);
2532 VARSUB(DATE
,1.25,R4
,-1.7f
,DATE
,2.95);
2534 VARSUB(UI1
, UI1_MAX
, UI1
, UI1_MAX
, UI1
, 0);
2535 VARSUB(I2
, I2_MAX
, I2
, I2_MAX
, I2
, 0);
2536 VARSUB(I2
, I2_MIN
, I2
, I2_MIN
, I2
, 0);
2537 VARSUB(I4
, I4_MAX
, I4
, I4_MAX
, I4
, 0);
2538 VARSUB(I4
, I4_MIN
, I4
, I4_MIN
, I4
, 0);
2539 VARSUB(R4
, R4_MAX
, R4
, R4_MAX
, R4
, 0.0f
);
2540 VARSUB(R4
, R4_MAX
, R4
, R4_MIN
, R4
, R4_MAX
- R4_MIN
);
2541 VARSUB(R4
, R4_MIN
, R4
, R4_MIN
, R4
, 0.0f
);
2542 VARSUB(R8
, R8_MAX
, R8
, R8_MIN
, R8
, R8_MAX
- R8_MIN
);
2543 VARSUB(R8
, R8_MIN
, R8
, R8_MIN
, R8
, 0.0);
2545 /* Manually test BSTR + BSTR */
2546 V_VT(&left
) = VT_BSTR
;
2547 V_BSTR(&left
) = lbstr
;
2548 V_VT(&right
) = VT_BSTR
;
2549 V_BSTR(&right
) = rbstr
;
2550 hres
= pVarSub(&left
, &right
, &result
);
2551 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
2552 "VarSub: expected coerced type VT_R8, got %s!\n", vtstr(V_VT(&result
)));
2553 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 0),
2554 "VarSub: BSTR + BSTR, expected %f got %f\n", 0.0, V_R8(&result
));
2556 /* Manually test some VT_CY and VT_DECIMAL variants */
2558 hres
= VarCyFromI4(4711, &V_CY(&cy
));
2559 ok(hres
== S_OK
, "VarCyFromI4 failed!\n");
2560 V_VT(&dec
) = VT_DECIMAL
;
2561 hres
= VarDecFromR8(-4.2, &V_DECIMAL(&dec
));
2562 ok(hres
== S_OK
, "VarDecFromR4 failed!\n");
2563 memset(&left
, 0, sizeof(left
));
2564 memset(&right
, 0, sizeof(right
));
2565 V_VT(&left
) = VT_I4
;
2567 V_VT(&right
) = VT_UI1
;
2570 hres
= pVarSub(&cy
, &right
, &result
);
2571 ok(hres
== S_OK
&& V_VT(&result
) == VT_CY
,
2572 "VarSub: expected coerced type VT_CY, got %s!\n", vtstr(V_VT(&result
)));
2573 hres
= VarR8FromCy(V_CY(&result
), &r
);
2574 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 4702),
2575 "VarSub: CY value %f, expected %f\n", r
, (double)4720);
2577 hres
= pVarSub(&left
, &dec
, &result
);
2578 ok(hres
== S_OK
&& V_VT(&result
) == VT_DECIMAL
,
2579 "VarSub: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result
)));
2580 hres
= VarR8FromDec(&V_DECIMAL(&result
), &r
);
2581 ok(hres
== S_OK
&& EQ_DOUBLE(r
, -6.8),
2582 "VarSub: DECIMAL value %f, expected %f\n", r
, (double)-15.2);
2584 SysFreeString(lbstr
);
2585 SysFreeString(rbstr
);
2588 static HRESULT (WINAPI
*pVarMod
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
2590 static void test_Mod( int line
, VARIANT
*left
, VARIANT
*right
, VARIANT
*expected
, HRESULT expres
)
2595 memset( &result
, 0, sizeof(result
) );
2596 hres
= pVarMod( left
, right
, &result
);
2597 ok_(__FILE__
,line
)( hres
== expres
, "wrong result %x/%x\n", hres
, expres
);
2599 ok_(__FILE__
,line
)( is_expected_variant( &result
, expected
),
2600 "got %s expected %s\n", variantstr(&result
), variantstr(expected
) );
2603 #define VARMOD(vt1,vt2,val1,val2,rvt,rval) \
2604 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
2605 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
2606 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
2607 test_var_call2( __LINE__, pVarMod, &left, &right, &exp )
2609 #define VARMOD2(vt1,vt2,val1,val2,rvt,rval,hexpected) \
2610 V_VT(&left) = VT_##vt1; V_I4(&left) = val1; \
2611 V_VT(&right) = VT_##vt2; V_I4(&right) = val2; \
2612 V_VT(&exp) = VT_##rvt; V_I4(&exp) = rval; \
2613 test_Mod( __LINE__, &left, &right, &exp, hexpected )
2615 static void test_VarMod(void)
2617 VARIANT v1
, v2
, vDst
, left
, right
, exp
;
2619 HRESULT hexpected
= 0;
2620 static const WCHAR szNum0
[] = {'1','2','5','\0'};
2621 static const WCHAR szNum1
[] = {'1','0','\0'};
2623 BOOL lFound
, rFound
;
2625 BSTR strNum0
, strNum1
;
2629 VARMOD(I1
,BOOL
,100,10,I4
,0);
2630 VARMOD(I1
,I1
,100,10,I4
,0);
2631 VARMOD(I1
,UI1
,100,10,I4
,0);
2632 VARMOD(I1
,I2
,100,10,I4
,0);
2633 VARMOD(I1
,UI2
,100,10,I4
,0);
2634 VARMOD(I1
,I4
,100,10,I4
,0);
2635 VARMOD(I1
,UI4
,100,10,I4
,0);
2636 VARMOD(I1
,R4
,100,10,I4
,0);
2637 VARMOD(I1
,R8
,100,10,I4
,0);
2639 VARMOD(UI1
,BOOL
,100,10,I2
,0);
2640 VARMOD(UI1
,I1
,100,10,I4
,0);
2641 VARMOD(UI1
,UI1
,100,10,UI1
,0);
2642 VARMOD(UI1
,I2
,100,10,I2
,0);
2643 VARMOD(UI1
,UI2
,100,10,I4
,0);
2644 VARMOD(UI1
,I4
,100,10,I4
,0);
2645 VARMOD(UI1
,UI4
,100,10,I4
,0);
2646 VARMOD(UI1
,R4
,100,10,I4
,0);
2647 VARMOD(UI1
,R8
,100,10,I4
,0);
2649 VARMOD(I2
,BOOL
,100,10,I2
,0);
2650 VARMOD(I2
,I1
,100,10,I4
,0);
2651 VARMOD(I2
,UI1
,100,10,I2
,0);
2652 VARMOD(I2
,I2
,100,10,I2
,0);
2653 VARMOD(I2
,UI2
,100,10,I4
,0);
2654 VARMOD(I2
,I4
,100,10,I4
,0);
2655 VARMOD(I2
,UI4
,100,10,I4
,0);
2656 VARMOD(I2
,R4
,100,10,I4
,0);
2657 VARMOD(I2
,R8
,100,10,I4
,0);
2659 VARMOD(I4
,BOOL
,100,10,I4
,0);
2660 VARMOD(I4
,I1
,100,10,I4
,0);
2661 VARMOD(I4
,UI1
,100,10,I4
,0);
2662 VARMOD(I4
,I2
,100,10,I4
,0);
2663 VARMOD(I4
,UI2
,100,10,I4
,0);
2664 VARMOD(I4
,I4
,100,10,I4
,0);
2665 VARMOD(I4
,UI4
,100,10,I4
,0);
2666 VARMOD(I4
,R4
,100,10,I4
,0);
2667 VARMOD(I4
,R8
,100,10,I4
,0);
2668 VARMOD(UI4
,BOOL
,100,10,I4
,0);
2669 VARMOD(UI4
,I1
,100,10,I4
,0);
2670 VARMOD(UI4
,UI1
,100,10,I4
,0);
2671 VARMOD(UI4
,I2
,100,10,I4
,0);
2672 VARMOD(UI4
,UI2
,100,10,I4
,0);
2673 VARMOD(UI4
,I4
,100,10,I4
,0);
2674 VARMOD(UI4
,UI4
,100,10,I4
,0);
2675 VARMOD(UI4
,R4
,100,10,I4
,0);
2676 VARMOD(UI4
,R8
,100,10,I4
,0);
2677 VARMOD(R4
,BOOL
,100,10,I4
,0);
2678 VARMOD(R4
,I1
,100,10,I4
,0);
2679 VARMOD(R4
,UI1
,100,10,I4
,0);
2680 VARMOD(R4
,I2
,100,10,I4
,0);
2681 VARMOD(R4
,UI2
,100,10,I4
,0);
2682 VARMOD(R4
,I4
,100,10,I4
,0);
2683 VARMOD(R4
,UI4
,100,10,I4
,0);
2684 VARMOD(R4
,R4
,100,10,I4
,0);
2685 VARMOD(R4
,R8
,100,10,I4
,0);
2686 VARMOD(R8
,BOOL
,100,10,I4
,0);
2687 VARMOD(R8
,I1
,100,10,I4
,0);
2688 VARMOD(R8
,UI1
,100,10,I4
,0);
2689 VARMOD(R8
,I2
,100,10,I4
,0);
2690 VARMOD(R8
,UI2
,100,10,I4
,0);
2691 VARMOD(R8
,I4
,100,10,I4
,0);
2692 VARMOD(R8
,UI4
,100,10,I4
,0);
2693 VARMOD(R8
,R4
,100,10,I4
,0);
2694 VARMOD(R8
,R8
,100,10,I4
,0);
2696 VARMOD(INT
,INT
,100,10,I4
,0);
2697 VARMOD(INT
,UINT
,100,10,I4
,0);
2699 VARMOD(BOOL
,BOOL
,100,10,I2
,0);
2700 VARMOD(BOOL
,I1
,100,10,I4
,0);
2701 VARMOD(BOOL
,UI1
,100,10,I2
,0);
2702 VARMOD(BOOL
,I2
,100,10,I2
,0);
2703 VARMOD(BOOL
,UI2
,100,10,I4
,0);
2704 VARMOD(BOOL
,I4
,100,10,I4
,0);
2705 VARMOD(BOOL
,UI4
,100,10,I4
,0);
2706 VARMOD(BOOL
,R4
,100,10,I4
,0);
2707 VARMOD(BOOL
,R8
,100,10,I4
,0);
2708 VARMOD(BOOL
,DATE
,100,10,I4
,0);
2710 VARMOD(DATE
,BOOL
,100,10,I4
,0);
2711 VARMOD(DATE
,I1
,100,10,I4
,0);
2712 VARMOD(DATE
,UI1
,100,10,I4
,0);
2713 VARMOD(DATE
,I2
,100,10,I4
,0);
2714 VARMOD(DATE
,UI2
,100,10,I4
,0);
2715 VARMOD(DATE
,I4
,100,10,I4
,0);
2716 VARMOD(DATE
,UI4
,100,10,I4
,0);
2717 VARMOD(DATE
,R4
,100,10,I4
,0);
2718 VARMOD(DATE
,R8
,100,10,I4
,0);
2719 VARMOD(DATE
,DATE
,100,10,I4
,0);
2721 strNum0
= SysAllocString(szNum0
);
2722 strNum1
= SysAllocString(szNum1
);
2723 VARMOD(BSTR
,BSTR
,strNum0
,strNum1
,I4
,5);
2724 VARMOD(BSTR
,I1
,strNum0
,10,I4
,5);
2725 VARMOD(BSTR
,I2
,strNum0
,10,I4
,5);
2726 VARMOD(BSTR
,I4
,strNum0
,10,I4
,5);
2727 VARMOD(BSTR
,R4
,strNum0
,10,I4
,5);
2728 VARMOD(BSTR
,R8
,strNum0
,10,I4
,5);
2729 VARMOD(I4
,BSTR
,125,strNum1
,I4
,5);
2733 VARMOD(BOOL
,I8
,100,10,I8
,0);
2734 VARMOD(I1
,I8
,100,10,I8
,0);
2735 VARMOD(UI1
,I8
,100,10,I8
,0);
2736 VARMOD(I2
,I8
,100,10,I8
,0);
2737 VARMOD(I4
,I8
,100,10,I8
,0);
2738 VARMOD(UI4
,I8
,100,10,I8
,0);
2739 VARMOD(R4
,I8
,100,10,I8
,0);
2740 VARMOD(R8
,I8
,100,10,I8
,0);
2741 VARMOD(DATE
,I8
,100,10,I8
,0);
2743 VARMOD(I8
,BOOL
,100,10,I8
,0);
2744 VARMOD(I8
,I1
,100,10,I8
,0);
2745 VARMOD(I8
,UI1
,100,10,I8
,0);
2746 VARMOD(I8
,I2
,100,10,I8
,0);
2747 VARMOD(I8
,UI2
,100,10,I8
,0);
2748 VARMOD(I8
,I4
,100,10,I8
,0);
2749 VARMOD(I8
,UI4
,100,10,I8
,0);
2750 VARMOD(I8
,R4
,100,10,I8
,0);
2751 VARMOD(I8
,R8
,100,10,I8
,0);
2752 VARMOD(I8
,I8
,100,10,I8
,0);
2754 VARMOD(BSTR
,I8
,strNum0
,10,I8
,5);
2757 /* test all combinations of types */
2758 for(l
= 0; l
< VT_BSTR_BLOB
; l
++)
2762 for(r
= 0; r
< VT_BSTR_BLOB
; r
++)
2766 if(l
== VT_BSTR
) continue;
2767 if(l
== VT_DISPATCH
) continue;
2768 if(r
== VT_BSTR
) continue;
2769 if(r
== VT_DISPATCH
) continue;
2803 hexpected
= DISP_E_BADVARTYPE
;
2840 if(((l
== VT_I8
) && (r
== VT_INT
)) || ((l
== VT_INT
) && (r
== VT_I8
)))
2842 hexpected
= DISP_E_TYPEMISMATCH
;
2843 } else if((l
== VT_EMPTY
) && (r
== VT_NULL
))
2846 } else if((l
== VT_NULL
) && (r
== VT_EMPTY
))
2849 } else if((l
== VT_EMPTY
) && (r
== VT_CY
))
2852 } else if((l
== VT_EMPTY
) && (r
== VT_RECORD
))
2854 hexpected
= DISP_E_TYPEMISMATCH
;
2855 } else if((r
== VT_EMPTY
) && lFound
&& lValid
)
2857 hexpected
= DISP_E_DIVBYZERO
;
2858 } else if((l
== VT_ERROR
) || ((r
== VT_ERROR
) && lFound
&& lValid
))
2860 hexpected
= DISP_E_TYPEMISMATCH
;
2861 } else if((l
== VT_NULL
) && (r
== VT_NULL
))
2864 } else if((l
== VT_VARIANT
) || ((r
== VT_VARIANT
) && lFound
&& lValid
))
2866 hexpected
= DISP_E_TYPEMISMATCH
;
2867 } else if((l
== VT_NULL
) && (r
== VT_RECORD
))
2869 hexpected
= DISP_E_TYPEMISMATCH
;
2870 } else if((l
== VT_I8
) && (r
== VT_DECIMAL
))
2873 } else if((l
== VT_DECIMAL
) && (r
== VT_I8
))
2876 } else if((l
== VT_UNKNOWN
) || ((r
== VT_UNKNOWN
) && lFound
&& lValid
))
2878 hexpected
= DISP_E_TYPEMISMATCH
;
2879 } else if((l
== VT_NULL
) && rFound
)
2882 } else if(l
== VT_RECORD
)
2884 hexpected
= DISP_E_TYPEMISMATCH
;
2885 } else if((r
== VT_RECORD
) && lValid
&& lFound
)
2887 hexpected
= DISP_E_TYPEMISMATCH
;
2888 } else if((l
== VT_EMPTY
) && (r
== VT_EMPTY
))
2890 hexpected
= DISP_E_DIVBYZERO
;
2891 } else if((l
== VT_CY
) && !rFound
)
2893 hexpected
= DISP_E_BADVARTYPE
;
2894 } else if(lFound
&& !rFound
)
2896 hexpected
= DISP_E_BADVARTYPE
;
2897 } else if(!lFound
&& rFound
)
2899 hexpected
= DISP_E_BADVARTYPE
;
2900 } else if((r
== VT_NULL
) && lFound
&& lValid
)
2903 } else if((l
== VT_NULL
) || (r
== VT_NULL
))
2905 hexpected
= DISP_E_BADVARTYPE
;
2906 } else if((l
== VT_VARIANT
) || (r
== VT_VARIANT
))
2908 hexpected
= DISP_E_BADVARTYPE
;
2909 } else if(lFound
&& !rFound
)
2911 hexpected
= DISP_E_BADVARTYPE
;
2912 } else if(!lFound
&& !rFound
)
2914 hexpected
= DISP_E_BADVARTYPE
;
2921 V_CY(&v1
).int64
= 1000000;
2926 else if(l
== VT_UI8
)
2930 else if(l
== VT_DATE
)
2932 else if (l
== VT_DECIMAL
)
2934 V_DECIMAL(&v1
).Hi32
= 0;
2935 U1(V_DECIMAL(&v1
)).Lo64
= 100;
2936 U(V_DECIMAL(&v1
)).signscale
= 0;
2942 V_CY(&v2
).int64
= 10000;
2947 else if(r
== VT_UI8
)
2951 else if(r
== VT_DATE
)
2953 else if (r
== VT_DECIMAL
)
2955 V_DECIMAL(&v2
).Hi32
= 0;
2956 U1(V_DECIMAL(&v2
)).Lo64
= 100;
2957 U(V_DECIMAL(&v2
)).signscale
= 0;
2962 if ((l
!= VT_I8
&& l
!= VT_UI8
&& r
!= VT_I8
&& r
!= VT_UI8
) || has_i8
)
2964 hres
= pVarMod(&v1
,&v2
,&vDst
);
2965 ok(hres
== hexpected
,
2966 "VarMod: expected 0x%x, got 0x%X for l type of %d, r type of %d,\n", hexpected
, hres
, l
, r
);
2972 /****************************/
2973 /* test some bad parameters */
2974 VARMOD(I4
,I4
,-1,-1,I4
,0);
2976 /* test modulus with zero */
2977 VARMOD2(I4
,I4
,100,0,EMPTY
,0,DISP_E_DIVBYZERO
);
2979 VARMOD(I4
,I4
,0,10,I4
,0); /* test 0 mod 10 */
2981 /* right parameter is type empty */
2982 VARMOD2(I4
,EMPTY
,100,10,EMPTY
,0,DISP_E_DIVBYZERO
);
2984 /* left parameter is type empty */
2985 VARMOD2(EMPTY
,I4
,100,10,I4
,0,S_OK
);
2987 /* mod with a null left value */
2988 VARMOD2(NULL
,I4
,125,10,NULL
,0,S_OK
);
2990 /* mod with a null right value */
2991 VARMOD2(I4
,NULL
,100,10,NULL
,0,S_OK
);
2993 /* void left value */
2994 VARMOD2(VOID
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2996 /* void right value */
2997 VARMOD2(I4
,VOID
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2999 /* null left value, void right value */
3000 VARMOD2(NULL
,VOID
,100,10,EMPTY
, 0, DISP_E_BADVARTYPE
);
3002 /* void left value, null right value */
3003 VARMOD2(VOID
,NULL
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
3005 /* some currencies */
3008 V_CY(&v1
).int64
= 100000;
3009 V_CY(&v2
).int64
= 100000;
3010 hres
= pVarMod(&v1
,&v2
,&vDst
);
3011 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I4
&& V_I4(&vDst
) == 0,
3012 "VarMod: expected 0x%x,%d,%d, got 0x%X,%d,%d\n", S_OK
, VT_I4
, 0, hres
, V_VT(&vDst
), V_I4(&vDst
));
3017 V_CY(&v2
).int64
= 100000;
3018 hres
= pVarMod(&v1
,&v2
,&vDst
);
3019 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I4
&& V_I4(&vDst
) == 0,
3020 "VarMod: expected 0x%x,%d,%d, got 0x%X,%d,%d\n", S_OK
, VT_I4
, 0, hres
, V_VT(&vDst
), V_I4(&vDst
));
3023 V_VT(&v1
) = VT_DECIMAL
;
3024 V_VT(&v2
) = VT_DECIMAL
;
3025 VarDecFromI4(100, &V_DECIMAL(&v1
));
3026 VarDecFromI4(10, &V_DECIMAL(&v2
));
3027 hres
= pVarMod(&v1
,&v2
,&vDst
);
3028 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I4
&& V_I4(&vDst
) == 0,
3029 "VarMod: expected 0x%x,%d,%d, got 0x%X,%d,%d\n", S_OK
, VT_I4
, 0, hres
, V_VT(&vDst
), V_I4(&vDst
));
3032 V_VT(&v2
) = VT_DECIMAL
;
3034 VarDecFromI4(10, &V_DECIMAL(&v2
));
3035 hres
= pVarMod(&v1
,&v2
,&vDst
);
3036 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I4
&& V_I4(&vDst
) == 0,
3037 "VarMod: expected 0x%x,%d,%d, got 0x%X,%d,%d\n", S_OK
, VT_I4
, 0, hres
, V_VT(&vDst
), V_I4(&vDst
));
3039 VARMOD2(UINT
,I4
,100,10,I4
,0,S_OK
);
3041 /* test that an error results in the type of the result changing but not its value */
3042 V_VT(&v1
) = VT_UNKNOWN
;
3043 V_VT(&v2
) = VT_EMPTY
;
3045 V_CY(&v2
).int64
= 100000;
3046 V_VT(&vDst
) = VT_I4
;
3048 hres
= pVarMod(&v1
,&v2
,&vDst
);
3049 ok(hres
== DISP_E_TYPEMISMATCH
&& V_VT(&vDst
) == VT_EMPTY
&& V_I4(&vDst
) == 1231,
3050 "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
));
3053 /* test some invalid types */
3054 /*TODO: not testing VT_DISPATCH */
3057 VARMOD2(I8
,INT
,100,10,EMPTY
,0,DISP_E_TYPEMISMATCH
);
3059 VARMOD2(ERROR
,I4
,100,10,EMPTY
,0,DISP_E_TYPEMISMATCH
);
3060 VARMOD2(VARIANT
,I4
,100,10,EMPTY
,0,DISP_E_TYPEMISMATCH
);
3061 VARMOD2(UNKNOWN
,I4
,100,10,EMPTY
,0,DISP_E_TYPEMISMATCH
);
3062 VARMOD2(VOID
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
3063 VARMOD2(HRESULT
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
3064 VARMOD2(PTR
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
3065 VARMOD2(SAFEARRAY
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
3066 VARMOD2(CARRAY
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
3067 VARMOD2(USERDEFINED
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
3068 VARMOD2(LPSTR
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
3069 VARMOD2(LPWSTR
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
3070 VARMOD2(RECORD
,I4
,100,10,EMPTY
,0,DISP_E_TYPEMISMATCH
);
3071 VARMOD2(FILETIME
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
3072 VARMOD2(BLOB
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
3073 VARMOD2(STREAM
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
3074 VARMOD2(STORAGE
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
3075 VARMOD2(STREAMED_OBJECT
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
3076 VARMOD2(STORED_OBJECT
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
3077 VARMOD2(BLOB_OBJECT
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
3078 VARMOD2(CF
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
3079 VARMOD2(CLSID
,CLSID
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
3080 VARMOD2(VECTOR
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
3081 VARMOD2(ARRAY
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
3082 VARMOD2(BYREF
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
3084 /* test some more invalid types */
3089 hres
= pVarMod(&v1
,&v2
,&vDst
);
3090 ok(hres
== DISP_E_BADVARTYPE
&& V_VT(&vDst
) == VT_EMPTY
,
3091 "VarMod: expected 0x%x,%d, got 0x%X,%d\n", DISP_E_BADVARTYPE
, VT_EMPTY
, hres
, V_VT(&vDst
));
3093 SysFreeString(strNum0
);
3094 SysFreeString(strNum1
);
3097 static HRESULT (WINAPI
*pVarFix
)(LPVARIANT
,LPVARIANT
);
3099 #define VARFIX(vt,val,rvt,rval) \
3100 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
3101 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
3102 test_var_call1( __LINE__, pVarFix, &v, &exp )
3104 static void test_VarFix(void)
3106 static const WCHAR szNumMinus1
[] = {'-','1','\0' };
3108 VARIANT v
, exp
, vDst
;
3109 DECIMAL
*pdec
= &V_DECIMAL(&v
);
3110 CY
*pcy
= &V_CY(&v
);
3115 /* Test all possible V_VT values */
3116 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
3120 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
3126 memset(&v
, 0, sizeof(v
));
3127 V_VT(&v
) = vt
| ExtraFlags
[i
];
3128 V_VT(&vDst
) = VT_EMPTY
;
3132 case VT_UI1
: case VT_I2
: case VT_I4
: case VT_R4
: case VT_R8
:
3133 case VT_DECIMAL
: case VT_BOOL
: case VT_NULL
: case VT_EMPTY
:
3134 case VT_DATE
: case VT_CY
:
3143 hres
= pVarFix(&v
,&vDst
);
3145 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
3146 "VarFix: expected failure, got 0x%X vt %d|0x%X\n",
3147 hres
, vt
, ExtraFlags
[i
]);
3149 ok(hres
== S_OK
, "VarFix: expected S_OK, got 0x%X vt %d|0x%X\n",
3150 hres
, vt
, ExtraFlags
[i
]);
3154 VARFIX(BOOL
,VARIANT_TRUE
,I2
,VARIANT_TRUE
);
3155 VARFIX(BOOL
,VARIANT_FALSE
,I2
,0);
3156 VARFIX(BOOL
,1,I2
,1);
3157 VARFIX(UI1
,1,UI1
,1);
3158 VARFIX(I2
,-1,I2
,-1);
3159 VARFIX(I4
,-1,I4
,-1);
3162 VARFIX(I8
,-1,I8
,-1);
3164 VARFIX(R4
,1.4f
,R4
,1);
3165 VARFIX(R4
,1.5f
,R4
,1);
3166 VARFIX(R4
,1.6f
,R4
,1);
3167 VARFIX(R4
,-1.4f
,R4
,-1);
3168 VARFIX(R4
,-1.5f
,R4
,-1);
3169 VARFIX(R4
,-1.6f
,R4
,-1);
3170 /* DATE & R8 round as for R4 */
3171 VARFIX(DATE
,-1,DATE
,-1);
3172 VARFIX(R8
,-1,R8
,-1);
3173 VARFIX(BSTR
,(BSTR
)szNumMinus1
,R8
,-1);
3175 V_VT(&v
) = VT_EMPTY
;
3176 hres
= pVarFix(&v
,&vDst
);
3177 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I2
&& V_I2(&vDst
) == 0,
3178 "VarFix: expected 0x0,%d,0 got 0x%X,%d,%d\n", VT_EMPTY
,
3179 hres
, V_VT(&vDst
), V_I2(&vDst
));
3182 hres
= pVarFix(&v
,&vDst
);
3183 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_NULL
,
3184 "VarFix: expected 0x0,%d got 0x%X,%d\n", VT_NULL
, hres
, V_VT(&vDst
));
3186 V_VT(&v
) = VT_DECIMAL
;
3187 S(U(*pdec
)).sign
= DECIMAL_NEG
;
3188 S(U(*pdec
)).scale
= 0;
3190 S1(U1(*pdec
)).Mid32
= 0;
3191 S1(U1(*pdec
)).Lo32
= 1;
3192 hres
= pVarFix(&v
,&vDst
);
3193 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_DECIMAL
&& !memcmp(&V_DECIMAL(&v
), &V_DECIMAL(&vDst
), sizeof(DECIMAL
)),
3194 "VarFix: expected 0x0,%d,identical, got 0x%X,%d\n", VT_DECIMAL
,
3197 /* FIXME: Test some fractional decimals when VarDecFix is implemented */
3200 pcy
->int64
= -10000;
3201 hres
= pVarFix(&v
,&vDst
);
3202 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_CY
&& V_CY(&vDst
).int64
== -10000,
3203 "VarFix: VT_CY wrong, hres=0x%X\n", hres
);
3206 pcy
->int64
= -16000;
3207 hres
= pVarFix(&v
,&vDst
);
3208 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_CY
&& V_CY(&vDst
).int64
== -10000,
3209 "VarFix: VT_CY wrong, hres=0x%X\n", hres
);
3212 static HRESULT (WINAPI
*pVarInt
)(LPVARIANT
,LPVARIANT
);
3214 #define VARINT(vt,val,rvt,rval) \
3215 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
3216 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
3217 test_var_call1( __LINE__, pVarInt, &v, &exp )
3219 static void test_VarInt(void)
3221 static const WCHAR szNumMinus1
[] = {'-','1','\0' };
3223 VARIANT v
, exp
, vDst
;
3224 DECIMAL
*pdec
= &V_DECIMAL(&v
);
3225 CY
*pcy
= &V_CY(&v
);
3230 /* Test all possible V_VT values */
3231 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
3235 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
3241 memset(&v
, 0, sizeof(v
));
3242 V_VT(&v
) = vt
| ExtraFlags
[i
];
3243 V_VT(&vDst
) = VT_EMPTY
;
3247 case VT_UI1
: case VT_I2
: case VT_I4
: case VT_R4
: case VT_R8
:
3248 case VT_DECIMAL
: case VT_BOOL
: case VT_NULL
: case VT_EMPTY
:
3249 case VT_DATE
: case VT_CY
:
3258 hres
= pVarInt(&v
,&vDst
);
3260 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
3261 "VarInt: expected failure, got 0x%X vt %d|0x%X\n",
3262 hres
, vt
, ExtraFlags
[i
]);
3264 ok(hres
== S_OK
, "VarInt: expected S_OK, got 0x%X vt %d|0x%X\n",
3265 hres
, vt
, ExtraFlags
[i
]);
3269 VARINT(BOOL
,VARIANT_TRUE
,I2
,VARIANT_TRUE
);
3270 VARINT(BOOL
,VARIANT_FALSE
,I2
,0);
3271 VARINT(BOOL
,1,I2
,1);
3272 VARINT(UI1
,1,UI1
,1);
3273 VARINT(I2
,-1,I2
,-1);
3274 VARINT(I4
,-1,I4
,-1);
3277 VARINT(I8
,-1,I8
,-1);
3279 VARINT(R4
,1.4f
,R4
,1);
3280 VARINT(R4
,1.5f
,R4
,1);
3281 VARINT(R4
,1.6f
,R4
,1);
3282 VARINT(R4
,-1.4f
,R4
,-2); /* Note these 3 are different from VarFix */
3283 VARINT(R4
,-1.5f
,R4
,-2);
3284 VARINT(R4
,-1.6f
,R4
,-2);
3285 /* DATE & R8 round as for R4 */
3286 VARINT(DATE
,-1,DATE
,-1);
3287 VARINT(R8
,-1,R8
,-1);
3288 VARINT(BSTR
,(BSTR
)szNumMinus1
,R8
,-1);
3290 V_VT(&v
) = VT_EMPTY
;
3291 hres
= pVarInt(&v
,&vDst
);
3292 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I2
&& V_I2(&vDst
) == 0,
3293 "VarInt: expected 0x0,%d,0 got 0x%X,%d,%d\n", VT_EMPTY
,
3294 hres
, V_VT(&vDst
), V_I2(&vDst
));
3297 hres
= pVarInt(&v
,&vDst
);
3298 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_NULL
,
3299 "VarInt: expected 0x0,%d got 0x%X,%d\n", VT_NULL
, hres
, V_VT(&vDst
));
3301 V_VT(&v
) = VT_DECIMAL
;
3302 S(U(*pdec
)).sign
= DECIMAL_NEG
;
3303 S(U(*pdec
)).scale
= 0;
3305 S1(U1(*pdec
)).Mid32
= 0;
3306 S1(U1(*pdec
)).Lo32
= 1;
3307 hres
= pVarInt(&v
,&vDst
);
3308 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_DECIMAL
&& !memcmp(&V_DECIMAL(&v
), &V_DECIMAL(&vDst
), sizeof(DECIMAL
)),
3309 "VarInt: expected 0x0,%d,identical, got 0x%X,%d\n", VT_DECIMAL
,
3312 /* FIXME: Test some fractional decimals when VarDecInt is implemented */
3315 pcy
->int64
= -10000;
3316 hres
= pVarInt(&v
,&vDst
);
3317 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_CY
&& V_CY(&vDst
).int64
== -10000,
3318 "VarInt: VT_CY wrong, hres=0x%X\n", hres
);
3321 pcy
->int64
= -11000;
3322 hres
= pVarInt(&v
,&vDst
);
3323 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_CY
&& V_CY(&vDst
).int64
== -20000,
3324 "VarInt: VT_CY wrong, hres=0x%X 0x%x%08x\n",
3325 hres
, (DWORD
)(V_CY(&vDst
).int64
>> 32), (DWORD
)V_CY(&vDst
).int64
);
3328 static HRESULT (WINAPI
*pVarNeg
)(LPVARIANT
,LPVARIANT
);
3330 #define VARNEG(vt,val,rvt,rval) \
3331 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
3332 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
3333 test_var_call1( __LINE__, pVarNeg, &v, &exp )
3335 static void test_VarNeg(void)
3337 static const WCHAR szNumMinus1
[] = {'-','1','\0' };
3338 static const WCHAR szNum1
[] = {'1','\0' };
3340 VARIANT v
, exp
, vDst
;
3341 DECIMAL
*pdec
= &V_DECIMAL(&v
);
3342 CY
*pcy
= &V_CY(&v
);
3347 /* Test all possible V_VT values. But don't test the exact return values
3348 * except for success/failure, since M$ made a hash of them in the
3349 * native version. This at least ensures (as with all tests here) that
3350 * we will notice if/when new vtypes/flags are added in native.
3352 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
3356 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
3362 memset(&v
, 0, sizeof(v
));
3363 V_VT(&v
) = vt
| ExtraFlags
[i
];
3364 V_VT(&vDst
) = VT_EMPTY
;
3368 case VT_UI1
: case VT_I2
: case VT_I4
:
3369 case VT_R4
: case VT_R8
:
3370 case VT_DECIMAL
: case VT_BOOL
: case VT_NULL
: case VT_EMPTY
:
3371 case VT_DATE
: case VT_CY
:
3379 hres
= pVarNeg(&v
,&vDst
);
3381 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
3382 "VarNeg: expected failure, got 0x%X vt %d|0x%X\n",
3383 hres
, vt
, ExtraFlags
[i
]);
3385 ok(hres
== S_OK
, "VarNeg: expected S_OK, got 0x%X vt %d|0x%X\n",
3386 hres
, vt
, ExtraFlags
[i
]);
3390 VARNEG(BOOL
,VARIANT_TRUE
,I2
,1);
3391 VARNEG(BOOL
,VARIANT_FALSE
,I2
,0);
3392 VARNEG(BOOL
,1,I2
,-1);
3393 VARNEG(UI1
,1,I2
,-1);
3394 VARNEG(UI1
,254,I2
,-254);
3395 VARNEG(I2
,-32768,I4
,32768);
3398 VARNEG(I4
,-((int)(~0u >> 1)) - 1,R8
,-2147483648u);
3408 VARNEG(DATE
,1,DATE
,-1);
3409 VARNEG(DATE
,-1,DATE
,1);
3412 VARNEG(BSTR
,(BSTR
)szNumMinus1
,R8
,1);
3413 VARNEG(BSTR
,(BSTR
)szNum1
,R8
,-1);
3415 V_VT(&v
) = VT_EMPTY
;
3416 hres
= pVarNeg(&v
,&vDst
);
3417 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I2
&& V_I2(&vDst
) == 0,
3418 "VarNeg: expected 0x0,%d,0 got 0x%X,%d,%d\n", VT_EMPTY
,
3419 hres
, V_VT(&vDst
), V_I2(&vDst
));
3422 hres
= pVarNeg(&v
,&vDst
);
3423 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_NULL
,
3424 "VarNeg: expected 0x0,%d got 0x%X,%d\n", VT_NULL
, hres
, V_VT(&vDst
));
3426 V_VT(&v
) = VT_DECIMAL
;
3427 S(U(*pdec
)).sign
= DECIMAL_NEG
;
3428 S(U(*pdec
)).scale
= 0;
3430 S1(U1(*pdec
)).Mid32
= 0;
3431 S1(U1(*pdec
)).Lo32
= 1;
3432 hres
= pVarNeg(&v
,&vDst
);
3433 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_DECIMAL
&&
3434 S(U(V_DECIMAL(&vDst
))).sign
== 0,
3435 "VarNeg: expected 0x0,%d,0x00, got 0x%X,%d,%02x\n", VT_DECIMAL
,
3436 hres
, V_VT(&vDst
), S(U(V_DECIMAL(&vDst
))).sign
);
3438 S(U(*pdec
)).sign
= 0;
3439 hres
= pVarNeg(&v
,&vDst
);
3440 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_DECIMAL
&&
3441 S(U(V_DECIMAL(&vDst
))).sign
== DECIMAL_NEG
,
3442 "VarNeg: expected 0x0,%d,0x7f, got 0x%X,%d,%02x\n", VT_DECIMAL
,
3443 hres
, V_VT(&vDst
), S(U(V_DECIMAL(&vDst
))).sign
);
3446 pcy
->int64
= -10000;
3447 hres
= pVarNeg(&v
,&vDst
);
3448 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_CY
&& V_CY(&vDst
).int64
== 10000,
3449 "VarNeg: VT_CY wrong, hres=0x%X\n", hres
);
3452 static HRESULT (WINAPI
*pVarRound
)(LPVARIANT
,int,LPVARIANT
);
3454 static void test_Round( int line
, VARIANT
*arg
, int deci
, VARIANT
*expected
)
3459 memset( &result
, 0, sizeof(result
) );
3460 hres
= pVarRound( arg
, deci
, &result
);
3461 ok_(__FILE__
,line
)( hres
== S_OK
, "wrong result %x\n", hres
);
3463 ok_(__FILE__
,line
)( is_expected_variant( &result
, expected
),
3464 "got %s expected %s\n", variantstr(&result
), variantstr(expected
) );
3466 #define VARROUND(vt,val,deci,rvt,rval) \
3467 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
3468 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
3469 test_Round( __LINE__, &v, deci, &exp )
3479 struct decimal_round_t
{
3480 struct decimal_t source
;
3481 struct decimal_t ret
;
3485 static const struct decimal_round_t decimal_round_data
[] = {
3486 {{ 0, DECIMAL_NEG
, 0, 0, 1 }, { 0, DECIMAL_NEG
, 0, 0, 1 }, 0},
3487 {{ 0, 0, 0, 0, 1 }, { 0, 0, 0, 0, 1 }, 0},
3488 {{ 2, 0, 0, 0, 155 }, { 0, 0, 0, 0, 16 }, 1},
3489 {{ 2, 0, 0, 0, 155 }, { 1, 0, 0, 0, 2 }, 0},
3490 {{ 2, 0, 0, 0, 199 }, { 1, 0, 0, 0, 20 }, 1},
3491 {{ 2, 0, 0, 0, 199 }, { 2, 0, 0, 0, 199 }, 2},
3492 {{ 2, DECIMAL_NEG
, 0, 0, 199 }, { 2, DECIMAL_NEG
, 0, 0, 199 }, 2},
3493 {{ 2, DECIMAL_NEG
, 0, 0, 55 }, { 2, DECIMAL_NEG
, 0, 0, 6 }, 1},
3494 {{ 2, 0, 0, 0, 55 }, { 2, 0, 0, 0, 6 }, 1}
3497 static void test_VarRound(void)
3499 static WCHAR szNumMin
[] = {'-','1','.','4','4','9','\0' };
3500 static WCHAR szNum
[] = {'1','.','4','5','1','\0' };
3502 VARIANT v
, exp
, vDst
;
3503 CY
*pcy
= &V_CY(&v
);
3509 /* first check valid integer types */
3510 VARROUND(BOOL
,VARIANT_TRUE
,0,I2
,-1);
3511 VARROUND(BOOL
,VARIANT_FALSE
,0,I2
,0);
3512 VARROUND(BOOL
,1,0,I2
,1);
3513 VARROUND(UI1
,1,0,UI1
,1);
3514 VARROUND(UI1
,254,0,UI1
,254);
3515 VARROUND(I2
,-32768,0,I2
,-32768);
3516 VARROUND(I2
,-1,0,I2
,-1);
3517 VARROUND(I2
,1,0,I2
,1);
3518 VARROUND(I4
,-((int)(~0u >> 1)) - 1,0,I4
,-((int)(~0u >> 1)) - 1);
3519 VARROUND(I4
,-1,0,I4
,-1);
3520 VARROUND(I4
,1,0,I4
,1);
3523 /* MSDN states that rounding of R4/R8 is dependent on the underlying
3524 * bit pattern of the number and so is architecture dependent. In this
3525 * case Wine returns .2 (which is more correct) and Native returns .3
3528 VARROUND(R4
,1.0f
,0,R4
,1.0f
);
3529 VARROUND(R4
,-1.0f
,0,R4
,-1.0f
);
3530 VARROUND(R8
,1.0,0,R8
,1.0);
3531 VARROUND(R8
,-1.0,0,R8
,-1.0);
3533 /* floating point numbers aren't exactly equal and we can't just
3534 * compare the first few digits. */
3535 VARROUND(DATE
,1.451,1,DATE
,1.5);
3536 VARROUND(DATE
,-1.449,1,DATE
,-1.4);
3538 /* replace the decimal separator */
3539 GetLocaleInfoA(LOCALE_USER_DEFAULT
, LOCALE_SDECIMAL
, buff
, sizeof(buff
)/sizeof(char));
3541 szNumMin
[2] = buff
[0];
3543 VARROUND(BSTR
,(BSTR
)szNumMin
,1,R8
,-1.40);
3544 VARROUND(BSTR
,(BSTR
)szNum
,1,R8
,1.50);
3546 skip("Skipping VarRound(BSTR) as decimal separator is '%s'\n", buff
);
3549 VARROUND(R4
,1.23456f
,0,R4
,1.0f
);
3550 VARROUND(R4
,1.23456f
,1,R4
,1.2f
);
3551 VARROUND(R4
,1.23456f
,2,R4
,1.23f
);
3552 VARROUND(R4
,1.23456f
,3,R4
,1.235f
);
3553 VARROUND(R4
,1.23456f
,4,R4
,1.2346f
);
3554 VARROUND(R4
,-1.23456f
,0,R4
,-1.0f
);
3555 VARROUND(R4
,-1.23456f
,1,R4
,-1.2f
);
3556 VARROUND(R4
,-1.23456f
,2,R4
,-1.23f
);
3557 VARROUND(R4
,-1.23456f
,3,R4
,-1.235f
);
3558 VARROUND(R4
,-1.23456f
,4,R4
,-1.2346f
);
3560 VARROUND(R8
,1.23456,0,R8
,1.0);
3561 VARROUND(R8
,1.23456,1,R8
,1.2);
3562 VARROUND(R8
,1.23456,2,R8
,1.23);
3563 VARROUND(R8
,1.23456,3,R8
,1.235);
3564 VARROUND(R8
,1.23456,4,R8
,1.2346);
3565 VARROUND(R8
,-1.23456,0,R8
,-1.0);
3566 VARROUND(R8
,-1.23456,1,R8
,-1.2);
3567 VARROUND(R8
,-1.23456,2,R8
,-1.23);
3568 VARROUND(R8
,-1.23456,3,R8
,-1.235);
3569 VARROUND(R8
,-1.23456,4,R8
,-1.2346);
3571 V_VT(&v
) = VT_EMPTY
;
3572 hres
= pVarRound(&v
,0,&vDst
);
3573 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I2
&& V_I2(&vDst
) == 0,
3574 "VarRound: expected 0x0,%d,0 got 0x%X,%d,%d\n", VT_EMPTY
,
3575 hres
, V_VT(&vDst
), V_I2(&vDst
));
3578 hres
= pVarRound(&v
,0,&vDst
);
3579 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_NULL
,
3580 "VarRound: expected 0x0,%d got 0x%X,%d\n", VT_NULL
, hres
, V_VT(&vDst
));
3583 for (i
= 0; i
< sizeof(decimal_round_data
)/sizeof(struct decimal_round_t
); i
++)
3585 const struct decimal_round_t
*ptr
= &decimal_round_data
[i
];
3588 pdec
= &V_DECIMAL(&v
);
3589 V_VT(&v
) = VT_DECIMAL
;
3590 S(U(*pdec
)).sign
= ptr
->source
.sign
;
3591 S(U(*pdec
)).scale
= ptr
->source
.scale
;
3592 pdec
->Hi32
= ptr
->source
.Hi32
;
3593 S1(U1(*pdec
)).Mid32
= ptr
->source
.Mid32
;
3594 S1(U1(*pdec
)).Lo32
= ptr
->source
.Lo32
;
3596 hres
= pVarRound(&v
, ptr
->dec
, &vDst
);
3598 ok(hres
== S_OK
, "%d: got 0x%08x\n", i
, hres
);
3601 ok(V_VT(&vDst
) == VT_DECIMAL
, "%d: got VT %d, expected VT_DECIMAL\n", i
, V_VT(&vDst
));
3602 ok(S(U(V_DECIMAL(&vDst
))).sign
== ptr
->ret
.sign
, "%d: got sign 0x%02x, expected 0x%02x\n",
3603 i
, S(U(V_DECIMAL(&vDst
))).sign
, ptr
->ret
.sign
);
3604 ok(V_DECIMAL(&vDst
).Hi32
== ptr
->ret
.Hi32
, "%d: got Hi32 %d, expected %d\n",
3605 i
, V_DECIMAL(&vDst
).Hi32
, ptr
->ret
.Hi32
);
3606 ok(S1(U1(V_DECIMAL(&vDst
))).Mid32
== ptr
->ret
.Mid32
, "%d: got Mid32 %d, expected %d\n",
3607 i
, S1(U1(V_DECIMAL(&vDst
))).Mid32
, ptr
->ret
.Mid32
);
3608 ok(S1(U1(V_DECIMAL(&vDst
))).Lo32
== ptr
->ret
.Lo32
, "%d: got Lo32 %d, expected %d\n",
3609 i
, S1(U1(V_DECIMAL(&vDst
))).Lo32
, ptr
->ret
.Lo32
);
3616 hres
= pVarRound(&v
,0,&vDst
);
3617 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_CY
&& V_CY(&vDst
).int64
== 10000,
3618 "VarRound: VT_CY wrong, hres=0x%X\n", hres
);
3622 static HRESULT (WINAPI
*pVarXor
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
3624 #define VARXOR(vt1,val1,vt2,val2,rvt,rval) \
3625 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
3626 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
3627 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
3628 test_var_call2( __LINE__, pVarXor, &left, &right, &exp )
3630 #define VARXORCY(vt1,val1,val2,rvt,rval) \
3631 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
3632 V_VT(&right) = VT_CY; V_CY(&right).int64 = val2; \
3633 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
3634 test_var_call2( __LINE__, pVarXor, &left, &right, &exp )
3636 static void test_VarXor(void)
3638 static const WCHAR szFalse
[] = { '#','F','A','L','S','E','#','\0' };
3639 static const WCHAR szTrue
[] = { '#','T','R','U','E','#','\0' };
3640 VARIANT left
, right
, exp
, result
;
3647 /* Test all possible flag/vt combinations & the resulting vt type */
3648 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
3650 VARTYPE leftvt
, rightvt
, resvt
;
3652 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
3657 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
3663 if (leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
||
3664 leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
||
3665 leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
)
3668 memset(&left
, 0, sizeof(left
));
3669 memset(&right
, 0, sizeof(right
));
3670 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
3671 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
3672 V_VT(&result
) = VT_EMPTY
;
3675 if (ExtraFlags
[i
] & VT_ARRAY
|| ExtraFlags
[i
] & VT_BYREF
||
3676 !IsValidVariantClearVT(leftvt
, ExtraFlags
[i
]) ||
3677 !IsValidVariantClearVT(rightvt
, ExtraFlags
[i
]) ||
3678 leftvt
== VT_CLSID
|| rightvt
== VT_CLSID
||
3679 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
||
3680 leftvt
== VT_VARIANT
|| rightvt
== VT_VARIANT
||
3681 leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
)
3685 if (leftvt
== VT_EMPTY
|| rightvt
== VT_EMPTY
)
3687 if (leftvt
== rightvt
||
3688 leftvt
== VT_I2
|| rightvt
== VT_I2
||
3689 leftvt
== VT_UI1
|| rightvt
== VT_UI1
||
3690 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
3692 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
3694 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
3697 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
3701 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
3703 if (leftvt
== rightvt
)
3705 else if (leftvt
== rightvt
||
3706 leftvt
== VT_I2
|| rightvt
== VT_I2
||
3707 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
3711 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
3714 else if (leftvt
== VT_I2
|| rightvt
== VT_I2
)
3716 if (leftvt
== rightvt
||
3717 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
3719 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
3722 else if (leftvt
== VT_BOOL
&& rightvt
== VT_BOOL
)
3726 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
3728 if (leftvt
== VT_INT
|| rightvt
== VT_INT
)
3733 hres
= pVarXor(&left
, &right
, &result
);
3735 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
3736 "VarXor: %d|0x%X, %d|0x%X: Expected failure, got 0x%X vt %d\n",
3737 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], hres
,
3740 ok(hres
== S_OK
&& V_VT(&result
) == resvt
,
3741 "VarXor: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%X vt %d\n",
3742 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], resvt
, hres
,
3748 /* Test returned values
3749 * FIXME: Test VT_DECIMAL/VT_DISPATCH
3751 VARXOR(EMPTY
,0,EMPTY
,0,I2
,0);
3752 VARXOR(EMPTY
,1,EMPTY
,0,I2
,0);
3753 VARXOR(EMPTY
,0,NULL
,0,NULL
,0);
3754 VARXOR(EMPTY
,0,I1
,0,I4
,0);
3755 VARXOR(EMPTY
,0,I1
,1,I4
,1);
3756 VARXOR(EMPTY
,0,UI1
,0,I2
,0);
3757 VARXOR(EMPTY
,0,UI1
,1,I2
,1);
3758 VARXOR(EMPTY
,0,I2
,0,I2
,0);
3759 VARXOR(EMPTY
,0,I2
,1,I2
,1);
3760 VARXOR(EMPTY
,0,UI2
,0,I4
,0);
3761 VARXOR(EMPTY
,0,UI2
,1,I4
,1);
3762 VARXOR(EMPTY
,0,I4
,0,I4
,0);
3763 VARXOR(EMPTY
,0,I4
,1,I4
,1);
3764 VARXOR(EMPTY
,0,UI4
,0,I4
,0);
3765 VARXOR(EMPTY
,0,UI4
,1,I4
,1);
3768 VARXOR(EMPTY
,0,I8
,0,I8
,0);
3769 VARXOR(EMPTY
,0,I8
,1,I8
,1);
3770 VARXOR(EMPTY
,0,UI8
,0,I4
,0);
3771 VARXOR(EMPTY
,0,UI8
,1,I4
,1);
3773 VARXOR(EMPTY
,0,INT
,0,I4
,0);
3774 VARXOR(EMPTY
,0,INT
,1,I4
,1);
3775 VARXOR(EMPTY
,0,UINT
,0,I4
,0);
3776 VARXOR(EMPTY
,0,UINT
,1,I4
,1);
3777 VARXOR(EMPTY
,0,BOOL
,0,I2
,0);
3778 VARXOR(EMPTY
,0,BOOL
,1,I2
,1);
3779 VARXOR(EMPTY
,0,R4
,0,I4
,0);
3780 VARXOR(EMPTY
,0,R4
,1,I4
,1);
3781 VARXOR(EMPTY
,0,R8
,0,I4
,0);
3782 VARXOR(EMPTY
,0,R8
,1,I4
,1);
3783 rbstr
= SysAllocString(szFalse
);
3784 VARXOR(EMPTY
,0,BSTR
,rbstr
,I2
,0);
3785 SysFreeString(rbstr
);
3786 rbstr
= SysAllocString(szTrue
);
3787 VARXOR(EMPTY
,0,BSTR
,rbstr
,I2
,-1);
3788 VARXORCY(EMPTY
,0,10000,I4
,1);
3789 SysFreeString(rbstr
);
3791 /* NULL OR 0 = NULL. NULL OR n = n */
3792 VARXOR(NULL
,0,NULL
,0,NULL
,0);
3793 VARXOR(NULL
,1,NULL
,0,NULL
,0);
3794 VARXOR(NULL
,0,I1
,0,NULL
,0);
3795 VARXOR(NULL
,0,I1
,1,NULL
,0);
3796 VARXOR(NULL
,0,UI1
,0,NULL
,0);
3797 VARXOR(NULL
,0,UI1
,1,NULL
,0);
3798 VARXOR(NULL
,0,I2
,0,NULL
,0);
3799 VARXOR(NULL
,0,I2
,1,NULL
,0);
3800 VARXOR(NULL
,0,UI2
,0,NULL
,0);
3801 VARXOR(NULL
,0,UI2
,1,NULL
,0);
3802 VARXOR(NULL
,0,I4
,0,NULL
,0);
3803 VARXOR(NULL
,0,I4
,1,NULL
,0);
3804 VARXOR(NULL
,0,UI4
,0,NULL
,0);
3805 VARXOR(NULL
,0,UI4
,1,NULL
,0);
3808 VARXOR(NULL
,0,I8
,0,NULL
,0);
3809 VARXOR(NULL
,0,I8
,1,NULL
,0);
3810 VARXOR(NULL
,0,UI8
,0,NULL
,0);
3811 VARXOR(NULL
,0,UI8
,1,NULL
,0);
3813 VARXOR(NULL
,0,INT
,0,NULL
,0);
3814 VARXOR(NULL
,0,INT
,1,NULL
,0);
3815 VARXOR(NULL
,0,UINT
,0,NULL
,0);
3816 VARXOR(NULL
,0,UINT
,1,NULL
,0);
3817 VARXOR(NULL
,0,BOOL
,0,NULL
,0);
3818 VARXOR(NULL
,0,BOOL
,1,NULL
,0);
3819 VARXOR(NULL
,0,R4
,0,NULL
,0);
3820 VARXOR(NULL
,0,R4
,1,NULL
,0);
3821 VARXOR(NULL
,0,R8
,0,NULL
,0);
3822 VARXOR(NULL
,0,R8
,1,NULL
,0);
3823 rbstr
= SysAllocString(szFalse
);
3824 VARXOR(NULL
,0,BSTR
,rbstr
,NULL
,0);
3825 SysFreeString(rbstr
);
3826 rbstr
= SysAllocString(szTrue
);
3827 VARXOR(NULL
,0,BSTR
,rbstr
,NULL
,0);
3828 SysFreeString(rbstr
);
3829 VARXORCY(NULL
,0,10000,NULL
,0);
3830 VARXORCY(NULL
,0,0,NULL
,0);
3832 VARXOR(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
);
3833 VARXOR(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
);
3834 VARXOR(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
);
3835 VARXOR(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_FALSE
);
3836 /* Assume x,y & y,x are the same from now on to reduce the number of tests */
3837 VARXOR(BOOL
,VARIANT_TRUE
,I1
,-1,I4
,0);
3838 VARXOR(BOOL
,VARIANT_TRUE
,I1
,0,I4
,-1);
3839 VARXOR(BOOL
,VARIANT_FALSE
,I1
,0,I4
,0);
3840 VARXOR(BOOL
,VARIANT_TRUE
,UI1
,255,I2
,-256);
3841 VARXOR(BOOL
,VARIANT_TRUE
,UI1
,0,I2
,-1);
3842 VARXOR(BOOL
,VARIANT_FALSE
,UI1
,0,I2
,0);
3843 VARXOR(BOOL
,VARIANT_TRUE
,I2
,-1,I2
,0);
3844 VARXOR(BOOL
,VARIANT_TRUE
,I2
,0,I2
,-1);
3845 VARXOR(BOOL
,VARIANT_FALSE
,I2
,0,I2
,0);
3846 VARXOR(BOOL
,VARIANT_TRUE
,UI2
,65535,I4
,-65536);
3847 VARXOR(BOOL
,VARIANT_TRUE
,UI2
,0,I4
,-1);
3848 VARXOR(BOOL
,VARIANT_FALSE
,UI2
,0,I4
,0);
3849 VARXOR(BOOL
,VARIANT_TRUE
,I4
,-1,I4
,0);
3850 VARXOR(BOOL
,VARIANT_TRUE
,I4
,0,I4
,-1);
3851 VARXOR(BOOL
,VARIANT_FALSE
,I4
,0,I4
,0);
3852 VARXOR(BOOL
,VARIANT_TRUE
,UI4
,0xffffffff,I4
,0);
3853 VARXOR(BOOL
,VARIANT_TRUE
,UI4
,0,I4
,-1);
3854 VARXOR(BOOL
,VARIANT_FALSE
,UI4
,0,I4
,0);
3855 VARXOR(BOOL
,VARIANT_TRUE
,R4
,-1,I4
,0);
3856 VARXOR(BOOL
,VARIANT_TRUE
,R4
,0,I4
,-1);
3857 VARXOR(BOOL
,VARIANT_FALSE
,R4
,0,I4
,0);
3858 VARXOR(BOOL
,VARIANT_TRUE
,R8
,-1,I4
,0);
3859 VARXOR(BOOL
,VARIANT_TRUE
,R8
,0,I4
,-1);
3860 VARXOR(BOOL
,VARIANT_FALSE
,R8
,0,I4
,0);
3861 VARXOR(BOOL
,VARIANT_TRUE
,DATE
,-1,I4
,0);
3862 VARXOR(BOOL
,VARIANT_TRUE
,DATE
,0,I4
,-1);
3863 VARXOR(BOOL
,VARIANT_FALSE
,DATE
,0,I4
,0);
3866 VARXOR(BOOL
,VARIANT_TRUE
,I8
,-1,I8
,0);
3867 VARXOR(BOOL
,VARIANT_TRUE
,I8
,0,I8
,-1);
3868 VARXOR(BOOL
,VARIANT_FALSE
,I8
,0,I8
,0);
3869 /* This returns DISP_E_OVERFLOW which indicates that a conversion
3870 * to I4 is performed.
3872 /* VARXOR(BOOL,VARIANT_TRUE,UI8,-1,I4,-1); */
3873 VARXOR(BOOL
,VARIANT_TRUE
,UI8
,0,I4
,-1);
3874 VARXOR(BOOL
,VARIANT_FALSE
,UI8
,0,I4
,0);
3876 VARXOR(BOOL
,VARIANT_TRUE
,INT
,-1,I4
,0);
3877 VARXOR(BOOL
,VARIANT_TRUE
,INT
,0,I4
,-1);
3878 VARXOR(BOOL
,VARIANT_FALSE
,INT
,0,I4
,0);
3879 VARXOR(BOOL
,VARIANT_TRUE
,UINT
,0xffffffff,I4
,0);
3880 VARXOR(BOOL
,VARIANT_TRUE
,UINT
,0,I4
,-1);
3881 VARXOR(BOOL
,VARIANT_FALSE
,UINT
,0,I4
,0);
3882 rbstr
= SysAllocString(szFalse
);
3883 VARXOR(BOOL
,VARIANT_FALSE
,BSTR
,rbstr
,BOOL
,VARIANT_FALSE
);
3884 VARXOR(BOOL
,VARIANT_TRUE
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
3885 SysFreeString(rbstr
);
3886 rbstr
= SysAllocString(szTrue
);
3887 VARXOR(BOOL
,VARIANT_FALSE
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
3888 VARXOR(BOOL
,VARIANT_TRUE
,BSTR
,rbstr
,BOOL
,VARIANT_FALSE
);
3889 SysFreeString(rbstr
);
3890 VARXORCY(BOOL
,VARIANT_TRUE
,10000,I4
,-2);
3891 VARXORCY(BOOL
,VARIANT_TRUE
,0,I4
,-1);
3892 VARXORCY(BOOL
,VARIANT_FALSE
,0,I4
,0);
3894 VARXOR(I1
,-1,I1
,-1,I4
,0);
3895 VARXOR(I1
,-1,I1
,0,I4
,-1);
3896 VARXOR(I1
,0,I1
,0,I4
,0);
3897 VARXOR(I1
,-1,UI1
,255,I4
,-256);
3898 VARXOR(I1
,-1,UI1
,0,I4
,-1);
3899 VARXOR(I1
,0,UI1
,0,I4
,0);
3900 VARXOR(I1
,-1,I2
,-1,I4
,0);
3901 VARXOR(I1
,-1,I2
,0,I4
,-1);
3902 VARXOR(I1
,0,I2
,0,I4
,0);
3903 VARXOR(I1
,-1,UI2
,65535,I4
,-65536);
3904 VARXOR(I1
,-1,UI2
,0,I4
,-1);
3905 VARXOR(I1
,0,UI2
,0,I4
,0);
3906 VARXOR(I1
,-1,I4
,-1,I4
,0);
3907 VARXOR(I1
,-1,I4
,0,I4
,-1);
3908 VARXOR(I1
,0,I4
,0,I4
,0);
3909 VARXOR(I1
,-1,UI4
,0xffffffff,I4
,0);
3910 VARXOR(I1
,-1,UI4
,0,I4
,-1);
3911 VARXOR(I1
,0,UI4
,0,I4
,0);
3912 VARXOR(I1
,-1,R4
,-1,I4
,0);
3913 VARXOR(I1
,-1,R4
,0,I4
,-1);
3914 VARXOR(I1
,0,R4
,0,I4
,0);
3915 VARXOR(I1
,-1,R8
,-1,I4
,0);
3916 VARXOR(I1
,-1,R8
,0,I4
,-1);
3917 VARXOR(I1
,0,R8
,0,I4
,0);
3918 VARXOR(I1
,-1,DATE
,-1,I4
,0);
3919 VARXOR(I1
,-1,DATE
,0,I4
,-1);
3920 VARXOR(I1
,0,DATE
,0,I4
,0);
3923 VARXOR(I1
,-1,I8
,-1,I8
,0);
3924 VARXOR(I1
,-1,I8
,0,I8
,-1);
3925 VARXOR(I1
,0,I8
,0,I8
,0);
3926 VARXOR(I1
,-1,UI8
,0,I4
,-1);
3927 VARXOR(I1
,0,UI8
,0,I4
,0);
3929 VARXOR(I1
,-1,INT
,-1,I4
,0);
3930 VARXOR(I1
,-1,INT
,0,I4
,-1);
3931 VARXOR(I1
,0,INT
,0,I4
,0);
3932 VARXOR(I1
,-1,UINT
,0xffffffff,I4
,0);
3933 VARXOR(I1
,-1,UINT
,0,I4
,-1);
3934 VARXOR(I1
,0,UINT
,0,I4
,0);
3935 rbstr
= SysAllocString(szFalse
);
3936 VARXOR(I1
,0,BSTR
,rbstr
,I4
,0);
3937 VARXOR(I1
,-1,BSTR
,rbstr
,I4
,-1);
3938 SysFreeString(rbstr
);
3939 rbstr
= SysAllocString(szTrue
);
3940 VARXOR(I1
,0,BSTR
,rbstr
,I4
,-1);
3941 VARXOR(I1
,-1,BSTR
,rbstr
,I4
,0);
3942 SysFreeString(rbstr
);
3943 VARXORCY(I1
,-1,10000,I4
,-2);
3944 VARXORCY(I1
,-1,0,I4
,-1);
3945 VARXORCY(I1
,0,0,I4
,0);
3947 VARXOR(UI1
,255,UI1
,255,UI1
,0);
3948 VARXOR(UI1
,255,UI1
,0,UI1
,255);
3949 VARXOR(UI1
,0,UI1
,0,UI1
,0);
3950 VARXOR(UI1
,255,I2
,-1,I2
,-256);
3951 VARXOR(UI1
,255,I2
,0,I2
,255);
3952 VARXOR(UI1
,0,I2
,0,I2
,0);
3953 VARXOR(UI1
,255,UI2
,65535,I4
,65280);
3954 VARXOR(UI1
,255,UI2
,0,I4
,255);
3955 VARXOR(UI1
,0,UI2
,0,I4
,0);
3956 VARXOR(UI1
,255,I4
,-1,I4
,-256);
3957 VARXOR(UI1
,255,I4
,0,I4
,255);
3958 VARXOR(UI1
,0,I4
,0,I4
,0);
3959 VARXOR(UI1
,255,UI4
,0xffffffff,I4
,-256);
3960 VARXOR(UI1
,255,UI4
,0,I4
,255);
3961 VARXOR(UI1
,0,UI4
,0,I4
,0);
3962 VARXOR(UI1
,255,R4
,-1,I4
,-256);
3963 VARXOR(UI1
,255,R4
,0,I4
,255);
3964 VARXOR(UI1
,0,R4
,0,I4
,0);
3965 VARXOR(UI1
,255,R8
,-1,I4
,-256);
3966 VARXOR(UI1
,255,R8
,0,I4
,255);
3967 VARXOR(UI1
,0,R8
,0,I4
,0);
3968 VARXOR(UI1
,255,DATE
,-1,I4
,-256);
3969 VARXOR(UI1
,255,DATE
,0,I4
,255);
3970 VARXOR(UI1
,0,DATE
,0,I4
,0);
3973 VARXOR(UI1
,255,I8
,-1,I8
,-256);
3974 VARXOR(UI1
,255,I8
,0,I8
,255);
3975 VARXOR(UI1
,0,I8
,0,I8
,0);
3976 VARXOR(UI1
,255,UI8
,0,I4
,255);
3977 VARXOR(UI1
,0,UI8
,0,I4
,0);
3979 VARXOR(UI1
,255,INT
,-1,I4
,-256);
3980 VARXOR(UI1
,255,INT
,0,I4
,255);
3981 VARXOR(UI1
,0,INT
,0,I4
,0);
3982 VARXOR(UI1
,255,UINT
,0xffffffff,I4
,-256);
3983 VARXOR(UI1
,255,UINT
,0,I4
,255);
3984 VARXOR(UI1
,0,UINT
,0,I4
,0);
3985 rbstr
= SysAllocString(szFalse
);
3986 VARXOR(UI1
,0,BSTR
,rbstr
,I2
,0);
3987 VARXOR(UI1
,255,BSTR
,rbstr
,I2
,255);
3988 SysFreeString(rbstr
);
3989 rbstr
= SysAllocString(szTrue
);
3990 VARXOR(UI1
,0,BSTR
,rbstr
,I2
,-1);
3991 VARXOR(UI1
,255,BSTR
,rbstr
,I2
,-256);
3992 SysFreeString(rbstr
);
3993 VARXORCY(UI1
,255,10000,I4
,254);
3994 VARXORCY(UI1
,255,0,I4
,255);
3995 VARXORCY(UI1
,0,0,I4
,0);
3997 VARXOR(I2
,-1,I2
,-1,I2
,0);
3998 VARXOR(I2
,-1,I2
,0,I2
,-1);
3999 VARXOR(I2
,0,I2
,0,I2
,0);
4000 VARXOR(I2
,-1,UI2
,65535,I4
,-65536);
4001 VARXOR(I2
,-1,UI2
,0,I4
,-1);
4002 VARXOR(I2
,0,UI2
,0,I4
,0);
4003 VARXOR(I2
,-1,I4
,-1,I4
,0);
4004 VARXOR(I2
,-1,I4
,0,I4
,-1);
4005 VARXOR(I2
,0,I4
,0,I4
,0);
4006 VARXOR(I2
,-1,UI4
,0xffffffff,I4
,0);
4007 VARXOR(I2
,-1,UI4
,0,I4
,-1);
4008 VARXOR(I2
,0,UI4
,0,I4
,0);
4009 VARXOR(I2
,-1,R4
,-1,I4
,0);
4010 VARXOR(I2
,-1,R4
,0,I4
,-1);
4011 VARXOR(I2
,0,R4
,0,I4
,0);
4012 VARXOR(I2
,-1,R8
,-1,I4
,0);
4013 VARXOR(I2
,-1,R8
,0,I4
,-1);
4014 VARXOR(I2
,0,R8
,0,I4
,0);
4015 VARXOR(I2
,-1,DATE
,-1,I4
,0);
4016 VARXOR(I2
,-1,DATE
,0,I4
,-1);
4017 VARXOR(I2
,0,DATE
,0,I4
,0);
4020 VARXOR(I2
,-1,I8
,-1,I8
,0);
4021 VARXOR(I2
,-1,I8
,0,I8
,-1);
4022 VARXOR(I2
,0,I8
,0,I8
,0);
4023 VARXOR(I2
,-1,UI8
,0,I4
,-1);
4024 VARXOR(I2
,0,UI8
,0,I4
,0);
4026 VARXOR(I2
,-1,INT
,-1,I4
,0);
4027 VARXOR(I2
,-1,INT
,0,I4
,-1);
4028 VARXOR(I2
,0,INT
,0,I4
,0);
4029 VARXOR(I2
,-1,UINT
,0xffffffff,I4
,0);
4030 VARXOR(I2
,-1,UINT
,0,I4
,-1);
4031 VARXOR(I2
,0,UINT
,0,I4
,0);
4032 rbstr
= SysAllocString(szFalse
);
4033 VARXOR(I2
,0,BSTR
,rbstr
,I2
,0);
4034 VARXOR(I2
,-1,BSTR
,rbstr
,I2
,-1);
4035 SysFreeString(rbstr
);
4036 rbstr
= SysAllocString(szTrue
);
4037 VARXOR(I2
,0,BSTR
,rbstr
,I2
,-1);
4038 VARXOR(I2
,-1,BSTR
,rbstr
,I2
,0);
4039 SysFreeString(rbstr
);
4040 VARXORCY(I2
,-1,10000,I4
,-2);
4041 VARXORCY(I2
,-1,0,I4
,-1);
4042 VARXORCY(I2
,0,0,I4
,0);
4044 VARXOR(UI2
,65535,UI2
,65535,I4
,0);
4045 VARXOR(UI2
,65535,UI2
,0,I4
,65535);
4046 VARXOR(UI2
,0,UI2
,0,I4
,0);
4047 VARXOR(UI2
,65535,I4
,-1,I4
,-65536);
4048 VARXOR(UI2
,65535,I4
,0,I4
,65535);
4049 VARXOR(UI2
,0,I4
,0,I4
,0);
4050 VARXOR(UI2
,65535,UI4
,0xffffffff,I4
,-65536);
4051 VARXOR(UI2
,65535,UI4
,0,I4
,65535);
4052 VARXOR(UI2
,0,UI4
,0,I4
,0);
4053 VARXOR(UI2
,65535,R4
,-1,I4
,-65536);
4054 VARXOR(UI2
,65535,R4
,0,I4
,65535);
4055 VARXOR(UI2
,0,R4
,0,I4
,0);
4056 VARXOR(UI2
,65535,R8
,-1,I4
,-65536);
4057 VARXOR(UI2
,65535,R8
,0,I4
,65535);
4058 VARXOR(UI2
,0,R8
,0,I4
,0);
4059 VARXOR(UI2
,65535,DATE
,-1,I4
,-65536);
4060 VARXOR(UI2
,65535,DATE
,0,I4
,65535);
4061 VARXOR(UI2
,0,DATE
,0,I4
,0);
4064 VARXOR(UI2
,65535,I8
,-1,I8
,-65536);
4065 VARXOR(UI2
,65535,I8
,0,I8
,65535);
4066 VARXOR(UI2
,0,I8
,0,I8
,0);
4067 VARXOR(UI2
,65535,UI8
,0,I4
,65535);
4068 VARXOR(UI2
,0,UI8
,0,I4
,0);
4070 VARXOR(UI2
,65535,INT
,-1,I4
,-65536);
4071 VARXOR(UI2
,65535,INT
,0,I4
,65535);
4072 VARXOR(UI2
,0,INT
,0,I4
,0);
4073 VARXOR(UI2
,65535,UINT
,0xffffffff,I4
,-65536);
4074 VARXOR(UI2
,65535,UINT
,0,I4
,65535);
4075 VARXOR(UI2
,0,UINT
,0,I4
,0);
4076 rbstr
= SysAllocString(szFalse
);
4077 VARXOR(UI2
,0,BSTR
,rbstr
,I4
,0);
4078 VARXOR(UI2
,65535,BSTR
,rbstr
,I4
,65535);
4079 SysFreeString(rbstr
);
4080 rbstr
= SysAllocString(szTrue
);
4081 VARXOR(UI2
,0,BSTR
,rbstr
,I4
,-1);
4082 VARXOR(UI2
,65535,BSTR
,rbstr
,I4
,-65536);
4083 SysFreeString(rbstr
);
4084 VARXORCY(UI2
,65535,10000,I4
,65534);
4085 VARXORCY(UI2
,65535,0,I4
,65535);
4086 VARXORCY(UI2
,0,0,I4
,0);
4088 VARXOR(I4
,-1,I4
,-1,I4
,0);
4089 VARXOR(I4
,-1,I4
,0,I4
,-1);
4090 VARXOR(I4
,0,I4
,0,I4
,0);
4091 VARXOR(I4
,-1,UI4
,0xffffffff,I4
,0);
4092 VARXOR(I4
,-1,UI4
,0,I4
,-1);
4093 VARXOR(I4
,0,UI4
,0,I4
,0);
4094 VARXOR(I4
,-1,R4
,-1,I4
,0);
4095 VARXOR(I4
,-1,R4
,0,I4
,-1);
4096 VARXOR(I4
,0,R4
,0,I4
,0);
4097 VARXOR(I4
,-1,R8
,-1,I4
,0);
4098 VARXOR(I4
,-1,R8
,0,I4
,-1);
4099 VARXOR(I4
,0,R8
,0,I4
,0);
4100 VARXOR(I4
,-1,DATE
,-1,I4
,0);
4101 VARXOR(I4
,-1,DATE
,0,I4
,-1);
4102 VARXOR(I4
,0,DATE
,0,I4
,0);
4105 VARXOR(I4
,-1,I8
,-1,I8
,0);
4106 VARXOR(I4
,-1,I8
,0,I8
,-1);
4107 VARXOR(I4
,0,I8
,0,I8
,0);
4108 VARXOR(I4
,-1,UI8
,0,I4
,-1);
4109 VARXOR(I4
,0,UI8
,0,I4
,0);
4111 VARXOR(I4
,-1,INT
,-1,I4
,0);
4112 VARXOR(I4
,-1,INT
,0,I4
,-1);
4113 VARXOR(I4
,0,INT
,0,I4
,0);
4114 VARXOR(I4
,-1,UINT
,0xffffffff,I4
,0);
4115 VARXOR(I4
,-1,UINT
,0,I4
,-1);
4116 VARXOR(I4
,0,UINT
,0,I4
,0);
4117 rbstr
= SysAllocString(szFalse
);
4118 VARXOR(I4
,0,BSTR
,rbstr
,I4
,0);
4119 VARXOR(I4
,-1,BSTR
,rbstr
,I4
,-1);
4120 SysFreeString(rbstr
);
4121 rbstr
= SysAllocString(szTrue
);
4122 VARXOR(I4
,0,BSTR
,rbstr
,I4
,-1);
4123 VARXOR(I4
,-1,BSTR
,rbstr
,I4
,0);
4124 SysFreeString(rbstr
);
4125 VARXORCY(I4
,-1,10000,I4
,-2);
4126 VARXORCY(I4
,-1,0,I4
,-1);
4127 VARXORCY(I4
,0,0,I4
,0);
4129 VARXOR(UI4
,0xffffffff,UI4
,0xffffffff,I4
,0);
4130 VARXOR(UI4
,0xffffffff,UI4
,0,I4
,-1);
4131 VARXOR(UI4
,0,UI4
,0,I4
,0);
4132 VARXOR(UI4
,0xffffffff,R4
,-1,I4
,0);
4133 VARXOR(UI4
,0xffffffff,R4
,0,I4
,-1);
4134 VARXOR(UI4
,0,R4
,0,I4
,0);
4135 VARXOR(UI4
,0xffffffff,R8
,-1,I4
,0);
4136 VARXOR(UI4
,0xffffffff,R8
,0,I4
,-1);
4137 VARXOR(UI4
,0,R8
,0,I4
,0);
4138 VARXOR(UI4
,0xffffffff,DATE
,-1,I4
,0);
4139 VARXOR(UI4
,0xffffffff,DATE
,0,I4
,-1);
4140 VARXOR(UI4
,0,DATE
,0,I4
,0);
4143 VARXOR(UI4
,0xffffffff,I8
,0,I8
,0xffffffff);
4144 VARXOR(UI4
,VARIANT_FALSE
,I8
,VARIANT_FALSE
,I8
,0);
4145 VARXOR(UI4
,0,I8
,0,I8
,0);
4146 VARXOR(UI4
,0xffffffff,UI8
,0,I4
,-1);
4147 VARXOR(UI4
,0,UI8
,0,I4
,0);
4149 VARXOR(UI4
,0xffffffff,INT
,-1,I4
,0);
4150 VARXOR(UI4
,0xffffffff,INT
,0,I4
,-1);
4151 VARXOR(UI4
,0,INT
,0,I4
,0);
4152 VARXOR(UI4
,0xffffffff,UINT
,0xffffffff,I4
,0);
4153 VARXOR(UI4
,0xffffffff,UINT
,0,I4
,-1);
4154 VARXOR(UI4
,0,UINT
,0,I4
,0);
4155 rbstr
= SysAllocString(szFalse
);
4156 VARXOR(UI4
,0,BSTR
,rbstr
,I4
,0);
4157 VARXOR(UI4
,0xffffffff,BSTR
,rbstr
,I4
,-1);
4158 SysFreeString(rbstr
);
4159 rbstr
= SysAllocString(szTrue
);
4160 VARXOR(UI4
,0,BSTR
,rbstr
,I4
,-1);
4161 VARXOR(UI4
,0xffffffff,BSTR
,rbstr
,I4
,0);
4162 SysFreeString(rbstr
);
4163 VARXORCY(UI4
,0xffffffff,10000,I4
,-2);
4164 VARXORCY(UI4
,0xffffffff,0,I4
,-1);
4165 VARXORCY(UI4
,0,0,I4
,0);
4167 VARXOR(R4
,-1,R4
,-1,I4
,0);
4168 VARXOR(R4
,-1,R4
,0,I4
,-1);
4169 VARXOR(R4
,0,R4
,0,I4
,0);
4170 VARXOR(R4
,-1,R8
,-1,I4
,0);
4171 VARXOR(R4
,-1,R8
,0,I4
,-1);
4172 VARXOR(R4
,0,R8
,0,I4
,0);
4173 VARXOR(R4
,-1,DATE
,-1,I4
,0);
4174 VARXOR(R4
,-1,DATE
,0,I4
,-1);
4175 VARXOR(R4
,0,DATE
,0,I4
,0);
4178 VARXOR(R4
,-1,I8
,-1,I8
,0);
4179 VARXOR(R4
,-1,I8
,0,I8
,-1);
4180 VARXOR(R4
,0,I8
,0,I8
,0);
4181 VARXOR(R4
,-1,UI8
,0,I4
,-1);
4182 VARXOR(R4
,0,UI8
,0,I4
,0);
4184 VARXOR(R4
,-1,INT
,-1,I4
,0);
4185 VARXOR(R4
,-1,INT
,0,I4
,-1);
4186 VARXOR(R4
,0,INT
,0,I4
,0);
4187 VARXOR(R4
,-1,UINT
,0xffffffff,I4
,0);
4188 VARXOR(R4
,-1,UINT
,0,I4
,-1);
4189 VARXOR(R4
,0,UINT
,0,I4
,0);
4190 rbstr
= SysAllocString(szFalse
);
4191 VARXOR(R4
,0,BSTR
,rbstr
,I4
,0);
4192 VARXOR(R4
,-1,BSTR
,rbstr
,I4
,-1);
4193 SysFreeString(rbstr
);
4194 rbstr
= SysAllocString(szTrue
);
4195 VARXOR(R4
,0,BSTR
,rbstr
,I4
,-1);
4196 VARXOR(R4
,-1,BSTR
,rbstr
,I4
,0);
4197 SysFreeString(rbstr
);
4198 VARXORCY(R4
,-1,10000,I4
,-2);
4199 VARXORCY(R4
,-1,0,I4
,-1);
4200 VARXORCY(R4
,0,0,I4
,0);
4202 VARXOR(R8
,-1,R8
,-1,I4
,0);
4203 VARXOR(R8
,-1,R8
,0,I4
,-1);
4204 VARXOR(R8
,0,R8
,0,I4
,0);
4205 VARXOR(R8
,-1,DATE
,-1,I4
,0);
4206 VARXOR(R8
,-1,DATE
,0,I4
,-1);
4207 VARXOR(R8
,0,DATE
,0,I4
,0);
4210 VARXOR(R8
,-1,I8
,-1,I8
,0);
4211 VARXOR(R8
,-1,I8
,0,I8
,-1);
4212 VARXOR(R8
,0,I8
,0,I8
,0);
4213 VARXOR(R8
,-1,UI8
,0,I4
,-1);
4214 VARXOR(R8
,0,UI8
,0,I4
,0);
4216 VARXOR(R8
,-1,INT
,-1,I4
,0);
4217 VARXOR(R8
,-1,INT
,0,I4
,-1);
4218 VARXOR(R8
,0,INT
,0,I4
,0);
4219 VARXOR(R8
,-1,UINT
,0xffffffff,I4
,0);
4220 VARXOR(R8
,-1,UINT
,0,I4
,-1);
4221 VARXOR(R8
,0,UINT
,0,I4
,0);
4222 rbstr
= SysAllocString(szFalse
);
4223 VARXOR(R8
,0,BSTR
,rbstr
,I4
,0);
4224 VARXOR(R8
,-1,BSTR
,rbstr
,I4
,-1);
4225 SysFreeString(rbstr
);
4226 rbstr
= SysAllocString(szTrue
);
4227 VARXOR(R8
,0,BSTR
,rbstr
,I4
,-1);
4228 VARXOR(R8
,-1,BSTR
,rbstr
,I4
,0);
4229 SysFreeString(rbstr
);
4230 VARXORCY(R8
,-1,10000,I4
,-2);
4231 VARXORCY(R8
,-1,0,I4
,-1);
4232 VARXORCY(R8
,0,0,I4
,0);
4234 VARXOR(DATE
,-1,DATE
,-1,I4
,0);
4235 VARXOR(DATE
,-1,DATE
,0,I4
,-1);
4236 VARXOR(DATE
,0,DATE
,0,I4
,0);
4239 VARXOR(DATE
,-1,I8
,-1,I8
,0);
4240 VARXOR(DATE
,-1,I8
,0,I8
,-1);
4241 VARXOR(DATE
,0,I8
,0,I8
,0);
4242 VARXOR(DATE
,-1,UI8
,0,I4
,-1);
4243 VARXOR(DATE
,0,UI8
,0,I4
,0);
4245 VARXOR(DATE
,-1,INT
,-1,I4
,0);
4246 VARXOR(DATE
,-1,INT
,0,I4
,-1);
4247 VARXOR(DATE
,0,INT
,0,I4
,0);
4248 VARXOR(DATE
,-1,UINT
,0xffffffff,I4
,0);
4249 VARXOR(DATE
,-1,UINT
,0,I4
,-1);
4250 VARXOR(DATE
,0,UINT
,0,I4
,0);
4251 rbstr
= SysAllocString(szFalse
);
4252 VARXOR(DATE
,0,BSTR
,rbstr
,I4
,0);
4253 VARXOR(DATE
,-1,BSTR
,rbstr
,I4
,-1);
4254 SysFreeString(rbstr
);
4255 rbstr
= SysAllocString(szTrue
);
4256 VARXOR(DATE
,0,BSTR
,rbstr
,I4
,-1);
4257 VARXOR(DATE
,-1,BSTR
,rbstr
,I4
,0);
4258 SysFreeString(rbstr
);
4259 VARXORCY(DATE
,-1,10000,I4
,-2);
4260 VARXORCY(DATE
,-1,0,I4
,-1);
4261 VARXORCY(DATE
,0,0,I4
,0);
4265 VARXOR(I8
,-1,I8
,-1,I8
,0);
4266 VARXOR(I8
,-1,I8
,0,I8
,-1);
4267 VARXOR(I8
,0,I8
,0,I8
,0);
4268 VARXOR(I8
,-1,UI8
,0,I8
,-1);
4269 VARXOR(I8
,0,UI8
,0,I8
,0);
4270 VARXOR(I8
,-1,UINT
,0,I8
,-1);
4271 VARXOR(I8
,0,UINT
,0,I8
,0);
4272 rbstr
= SysAllocString(szFalse
);
4273 VARXOR(I8
,0,BSTR
,rbstr
,I8
,0);
4274 VARXOR(I8
,-1,BSTR
,rbstr
,I8
,-1);
4275 SysFreeString(rbstr
);
4276 rbstr
= SysAllocString(szTrue
);
4277 VARXOR(I8
,0,BSTR
,rbstr
,I8
,-1);
4278 VARXOR(I8
,-1,BSTR
,rbstr
,I8
,0);
4279 SysFreeString(rbstr
);
4280 VARXORCY(I8
,-1,10000,I8
,-2);
4281 VARXORCY(I8
,-1,0,I8
,-1);
4282 VARXORCY(I8
,0,0,I8
,0);
4284 VARXOR(UI8
,0xffff,UI8
,0xffff,I4
,0);
4285 VARXOR(UI8
,0xffff,UI8
,0,I4
,0xffff);
4286 VARXOR(UI8
,0,UI8
,0,I4
,0);
4287 VARXOR(UI8
,0xffff,INT
,-1,I4
,-65536);
4288 VARXOR(UI8
,0xffff,INT
,0,I4
,0xffff);
4289 VARXOR(UI8
,0,INT
,0,I4
,0);
4290 VARXOR(UI8
,0xffff,UINT
,0xffff,I4
,0);
4291 VARXOR(UI8
,0xffff,UINT
,0,I4
,0xffff);
4292 VARXOR(UI8
,0,UINT
,0,I4
,0);
4293 rbstr
= SysAllocString(szFalse
);
4294 VARXOR(UI8
,0,BSTR
,rbstr
,I4
,0);
4295 VARXOR(UI8
,0xffff,BSTR
,rbstr
,I4
,0xffff);
4296 SysFreeString(rbstr
);
4297 rbstr
= SysAllocString(szTrue
);
4298 VARXOR(UI8
,0,BSTR
,rbstr
,I4
,-1);
4299 VARXOR(UI8
,0xffff,BSTR
,rbstr
,I4
,-65536);
4300 SysFreeString(rbstr
);
4301 VARXORCY(UI8
,0xffff,10000,I4
,65534);
4302 VARXORCY(UI8
,0xffff,0,I4
,0xffff);
4303 VARXORCY(UI8
,0,0,I4
,0);
4306 VARXOR(INT
,-1,INT
,-1,I4
,0);
4307 VARXOR(INT
,-1,INT
,0,I4
,-1);
4308 VARXOR(INT
,0,INT
,0,I4
,0);
4309 VARXOR(INT
,-1,UINT
,0xffff,I4
,-65536);
4310 VARXOR(INT
,-1,UINT
,0,I4
,-1);
4311 VARXOR(INT
,0,UINT
,0,I4
,0);
4312 rbstr
= SysAllocString(szFalse
);
4313 VARXOR(INT
,0,BSTR
,rbstr
,I4
,0);
4314 VARXOR(INT
,-1,BSTR
,rbstr
,I4
,-1);
4315 SysFreeString(rbstr
);
4316 rbstr
= SysAllocString(szTrue
);
4317 VARXOR(INT
,0,BSTR
,rbstr
,I4
,-1);
4318 VARXOR(INT
,-1,BSTR
,rbstr
,I4
,0);
4319 SysFreeString(rbstr
);
4320 VARXORCY(INT
,-1,10000,I4
,-2);
4321 VARXORCY(INT
,-1,0,I4
,-1);
4322 VARXORCY(INT
,0,0,I4
,0);
4324 VARXOR(UINT
,0xffff,UINT
,0xffff,I4
,0);
4325 VARXOR(UINT
,0xffff,UINT
,0,I4
,0xffff);
4326 VARXOR(UINT
,0,UINT
,0,I4
,0);
4327 rbstr
= SysAllocString(szFalse
);
4328 VARXOR(UINT
,0,BSTR
,rbstr
,I4
,0);
4329 VARXOR(UINT
,0xffff,BSTR
,rbstr
,I4
,0xffff);
4330 SysFreeString(rbstr
);
4331 rbstr
= SysAllocString(szTrue
);
4332 VARXOR(UINT
,0,BSTR
,rbstr
,I4
,-1);
4333 VARXOR(UINT
,0xffff,BSTR
,rbstr
,I4
,-65536);
4334 SysFreeString(rbstr
);
4335 VARXORCY(UINT
,0xffff,10000,I4
,65534);
4336 VARXORCY(UINT
,0xffff,0,I4
,0xffff);
4337 VARXORCY(UINT
,0,0,I4
,0);
4339 lbstr
= SysAllocString(szFalse
);
4340 rbstr
= SysAllocString(szFalse
);
4341 VARXOR(BSTR
,lbstr
,BSTR
,rbstr
,BOOL
,0);
4342 SysFreeString(rbstr
);
4343 rbstr
= SysAllocString(szTrue
);
4344 VARXOR(BSTR
,lbstr
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
4345 SysFreeString(lbstr
);
4346 lbstr
= SysAllocString(szTrue
);
4347 VARXOR(BSTR
,lbstr
,BSTR
,rbstr
,BOOL
,VARIANT_FALSE
);
4348 VARXORCY(BSTR
,lbstr
,10000,I4
,-2);
4349 SysFreeString(lbstr
);
4350 lbstr
= SysAllocString(szFalse
);
4351 VARXORCY(BSTR
,lbstr
,10000,I4
,1);
4352 SysFreeString(lbstr
);
4353 SysFreeString(rbstr
);
4356 static HRESULT (WINAPI
*pVarOr
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
4358 #define VAROR(vt1,val1,vt2,val2,rvt,rval) \
4359 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
4360 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
4361 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
4362 test_var_call2( __LINE__, pVarOr, &left, &right, &exp )
4364 #define VARORCY(vt1,val1,val2,rvt,rval) \
4365 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
4366 V_VT(&right) = VT_CY; V_CY(&right).int64 = val2; \
4367 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
4368 test_var_call2( __LINE__, pVarOr, &left, &right, &exp )
4370 static void test_VarOr(void)
4372 static const WCHAR szFalse
[] = { '#','F','A','L','S','E','#','\0' };
4373 static const WCHAR szTrue
[] = { '#','T','R','U','E','#','\0' };
4374 VARIANT left
, right
, exp
, result
;
4381 /* Test all possible flag/vt combinations & the resulting vt type */
4382 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
4384 VARTYPE leftvt
, rightvt
, resvt
;
4386 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
4391 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
4397 if (leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
||
4398 leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
||
4399 leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
)
4402 memset(&left
, 0, sizeof(left
));
4403 memset(&right
, 0, sizeof(right
));
4404 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
4405 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
4406 V_VT(&result
) = VT_EMPTY
;
4409 if (ExtraFlags
[i
] & VT_ARRAY
|| ExtraFlags
[i
] & VT_BYREF
||
4410 !IsValidVariantClearVT(leftvt
, ExtraFlags
[i
]) ||
4411 !IsValidVariantClearVT(rightvt
, ExtraFlags
[i
]) ||
4412 leftvt
== VT_CLSID
|| rightvt
== VT_CLSID
||
4413 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
||
4414 leftvt
== VT_VARIANT
|| rightvt
== VT_VARIANT
||
4415 leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
)
4419 if (leftvt
== VT_EMPTY
|| rightvt
== VT_EMPTY
)
4421 if (leftvt
== rightvt
||
4422 leftvt
== VT_I2
|| rightvt
== VT_I2
||
4423 leftvt
== VT_UI1
|| rightvt
== VT_UI1
||
4424 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
4426 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
4428 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
4431 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
4435 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
4437 if (leftvt
== rightvt
)
4439 else if (leftvt
== rightvt
||
4440 leftvt
== VT_I2
|| rightvt
== VT_I2
||
4441 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
4445 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
4448 else if (leftvt
== VT_I2
|| rightvt
== VT_I2
)
4450 if (leftvt
== rightvt
||
4451 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
4453 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
4456 else if (leftvt
== VT_BOOL
&& rightvt
== VT_BOOL
)
4460 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
4462 if (leftvt
== VT_INT
|| rightvt
== VT_INT
)
4467 hres
= pVarOr(&left
, &right
, &result
);
4469 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
4470 "VarOr: %d|0x%X, %d|0x%X: Expected failure, got 0x%X vt %d\n",
4471 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], hres
,
4474 ok(hres
== S_OK
&& V_VT(&result
) == resvt
,
4475 "VarOr: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%X vt %d\n",
4476 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], resvt
, hres
,
4482 /* Test returned values. Since we know the returned type is correct
4483 * and that we handle all combinations of invalid types, just check
4484 * that good type combinations produce the desired value.
4485 * FIXME: Test VT_DECIMAL/VT_DISPATCH
4487 VAROR(EMPTY
,0,EMPTY
,0,I2
,0);
4488 VAROR(EMPTY
,1,EMPTY
,0,I2
,0);
4489 VAROR(EMPTY
,0,NULL
,0,NULL
,0);
4490 VAROR(EMPTY
,0,I1
,0,I4
,0);
4491 VAROR(EMPTY
,0,I1
,1,I4
,1);
4492 VAROR(EMPTY
,0,UI1
,0,I2
,0);
4493 VAROR(EMPTY
,0,UI1
,1,I2
,1);
4494 VAROR(EMPTY
,0,I2
,0,I2
,0);
4495 VAROR(EMPTY
,0,I2
,1,I2
,1);
4496 VAROR(EMPTY
,0,UI2
,0,I4
,0);
4497 VAROR(EMPTY
,0,UI2
,1,I4
,1);
4498 VAROR(EMPTY
,0,I4
,0,I4
,0);
4499 VAROR(EMPTY
,0,I4
,1,I4
,1);
4500 VAROR(EMPTY
,0,UI4
,0,I4
,0);
4501 VAROR(EMPTY
,0,UI4
,1,I4
,1);
4504 VAROR(EMPTY
,0,I8
,0,I8
,0);
4505 VAROR(EMPTY
,0,I8
,1,I8
,1);
4506 VAROR(EMPTY
,0,UI8
,0,I4
,0);
4507 VAROR(EMPTY
,0,UI8
,1,I4
,1);
4509 VAROR(EMPTY
,0,INT
,0,I4
,0);
4510 VAROR(EMPTY
,0,INT
,1,I4
,1);
4511 VAROR(EMPTY
,0,UINT
,0,I4
,0);
4512 VAROR(EMPTY
,0,UINT
,1,I4
,1);
4513 VAROR(EMPTY
,0,BOOL
,0,I2
,0);
4514 VAROR(EMPTY
,0,BOOL
,1,I2
,1);
4515 VAROR(EMPTY
,0,R4
,0,I4
,0);
4516 VAROR(EMPTY
,0,R4
,1,I4
,1);
4517 VAROR(EMPTY
,0,R8
,0,I4
,0);
4518 VAROR(EMPTY
,0,R8
,1,I4
,1);
4519 rbstr
= SysAllocString(szFalse
);
4520 VAROR(EMPTY
,0,BSTR
,rbstr
,I2
,0);
4521 SysFreeString(rbstr
);
4522 rbstr
= SysAllocString(szTrue
);
4523 VAROR(EMPTY
,0,BSTR
,rbstr
,I2
,-1);
4524 SysFreeString(rbstr
);
4525 VARORCY(EMPTY
,0,10000,I4
,1);
4527 /* NULL OR 0 = NULL. NULL OR n = n */
4528 VAROR(NULL
,0,NULL
,0,NULL
,0);
4529 VAROR(NULL
,1,NULL
,0,NULL
,0);
4530 VAROR(NULL
,0,I1
,0,NULL
,0);
4531 VAROR(NULL
,0,I1
,1,I4
,1);
4532 VAROR(NULL
,0,UI1
,0,NULL
,0);
4533 VAROR(NULL
,0,UI1
,1,UI1
,1);
4534 VAROR(NULL
,0,I2
,0,NULL
,0);
4535 VAROR(NULL
,0,I2
,1,I2
,1);
4536 VAROR(NULL
,0,UI2
,0,NULL
,0);
4537 VAROR(NULL
,0,UI2
,1,I4
,1);
4538 VAROR(NULL
,0,I4
,0,NULL
,0);
4539 VAROR(NULL
,0,I4
,1,I4
,1);
4540 VAROR(NULL
,0,UI4
,0,NULL
,0);
4541 VAROR(NULL
,0,UI4
,1,I4
,1);
4544 VAROR(NULL
,0,I8
,0,NULL
,0);
4545 VAROR(NULL
,0,I8
,1,I8
,1);
4546 VAROR(NULL
,0,UI8
,0,NULL
,0);
4547 VAROR(NULL
,0,UI8
,1,I4
,1);
4549 VAROR(NULL
,0,INT
,0,NULL
,0);
4550 VAROR(NULL
,0,INT
,1,I4
,1);
4551 VAROR(NULL
,0,UINT
,0,NULL
,0);
4552 VAROR(NULL
,0,UINT
,1,I4
,1);
4553 VAROR(NULL
,0,BOOL
,0,NULL
,0);
4554 VAROR(NULL
,0,BOOL
,1,BOOL
,1);
4555 VAROR(NULL
,0,R4
,0,NULL
,0);
4556 VAROR(NULL
,0,R4
,1,I4
,1);
4557 VAROR(NULL
,0,R8
,0,NULL
,0);
4558 VAROR(NULL
,0,R8
,1,I4
,1);
4559 rbstr
= SysAllocString(szFalse
);
4560 VAROR(NULL
,0,BSTR
,rbstr
,NULL
,0);
4561 SysFreeString(rbstr
);
4562 rbstr
= SysAllocString(szTrue
);
4563 VAROR(NULL
,0,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
4564 SysFreeString(rbstr
);
4565 VARORCY(NULL
,0,10000,I4
,1);
4566 VARORCY(NULL
,0,0,NULL
,0);
4568 VAROR(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
);
4569 VAROR(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
);
4570 VAROR(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
);
4571 VAROR(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_FALSE
);
4572 /* Assume x,y & y,x are the same from now on to reduce the number of tests */
4573 VAROR(BOOL
,VARIANT_TRUE
,I1
,-1,I4
,-1);
4574 VAROR(BOOL
,VARIANT_TRUE
,I1
,0,I4
,-1);
4575 VAROR(BOOL
,VARIANT_FALSE
,I1
,0,I4
,0);
4576 VAROR(BOOL
,VARIANT_TRUE
,UI1
,255,I2
,-1);
4577 VAROR(BOOL
,VARIANT_TRUE
,UI1
,0,I2
,-1);
4578 VAROR(BOOL
,VARIANT_FALSE
,UI1
,0,I2
,0);
4579 VAROR(BOOL
,VARIANT_TRUE
,I2
,-1,I2
,-1);
4580 VAROR(BOOL
,VARIANT_TRUE
,I2
,0,I2
,-1);
4581 VAROR(BOOL
,VARIANT_FALSE
,I2
,0,I2
,0);
4582 VAROR(BOOL
,VARIANT_TRUE
,UI2
,65535,I4
,-1);
4583 VAROR(BOOL
,VARIANT_TRUE
,UI2
,0,I4
,-1);
4584 VAROR(BOOL
,VARIANT_FALSE
,UI2
,0,I4
,0);
4585 VAROR(BOOL
,VARIANT_TRUE
,I4
,-1,I4
,-1);
4586 VAROR(BOOL
,VARIANT_TRUE
,I4
,0,I4
,-1);
4587 VAROR(BOOL
,VARIANT_FALSE
,I4
,0,I4
,0);
4588 VAROR(BOOL
,VARIANT_TRUE
,UI4
,0xffffffff,I4
,-1);
4589 VAROR(BOOL
,VARIANT_TRUE
,UI4
,0,I4
,-1);
4590 VAROR(BOOL
,VARIANT_FALSE
,UI4
,0,I4
,0);
4591 VAROR(BOOL
,VARIANT_TRUE
,R4
,-1,I4
,-1);
4592 VAROR(BOOL
,VARIANT_TRUE
,R4
,0,I4
,-1);
4593 VAROR(BOOL
,VARIANT_FALSE
,R4
,0,I4
,0);
4594 VAROR(BOOL
,VARIANT_TRUE
,R8
,-1,I4
,-1);
4595 VAROR(BOOL
,VARIANT_TRUE
,R8
,0,I4
,-1);
4596 VAROR(BOOL
,VARIANT_FALSE
,R8
,0,I4
,0);
4597 VAROR(BOOL
,VARIANT_TRUE
,DATE
,-1,I4
,-1);
4598 VAROR(BOOL
,VARIANT_TRUE
,DATE
,0,I4
,-1);
4599 VAROR(BOOL
,VARIANT_FALSE
,DATE
,0,I4
,0);
4602 VAROR(BOOL
,VARIANT_TRUE
,I8
,-1,I8
,-1);
4603 VAROR(BOOL
,VARIANT_TRUE
,I8
,0,I8
,-1);
4604 VAROR(BOOL
,VARIANT_FALSE
,I8
,0,I8
,0);
4605 /* This returns DISP_E_OVERFLOW which indicates that a conversion
4606 * to I4 is performed.
4608 /* VAROR(BOOL,VARIANT_TRUE,UI8,-1,I4,-1); */
4609 VAROR(BOOL
,VARIANT_TRUE
,UI8
,0,I4
,-1);
4610 VAROR(BOOL
,VARIANT_FALSE
,UI8
,0,I4
,0);
4612 VAROR(BOOL
,VARIANT_TRUE
,INT
,-1,I4
,-1);
4613 VAROR(BOOL
,VARIANT_TRUE
,INT
,0,I4
,-1);
4614 VAROR(BOOL
,VARIANT_FALSE
,INT
,0,I4
,0);
4615 VAROR(BOOL
,VARIANT_TRUE
,UINT
,0xffffffff,I4
,-1);
4616 VAROR(BOOL
,VARIANT_TRUE
,UINT
,0,I4
,-1);
4617 VAROR(BOOL
,VARIANT_FALSE
,UINT
,0,I4
,0);
4618 rbstr
= SysAllocString(szFalse
);
4619 VAROR(BOOL
,VARIANT_FALSE
,BSTR
,rbstr
,BOOL
,VARIANT_FALSE
);
4620 VAROR(BOOL
,VARIANT_TRUE
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
4621 SysFreeString(rbstr
);
4622 rbstr
= SysAllocString(szTrue
);
4623 VAROR(BOOL
,VARIANT_FALSE
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
4624 VAROR(BOOL
,VARIANT_TRUE
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
4625 SysFreeString(rbstr
);
4626 VARORCY(BOOL
,VARIANT_TRUE
,10000,I4
,-1);
4627 VARORCY(BOOL
,VARIANT_TRUE
,0,I4
,-1);
4628 VARORCY(BOOL
,VARIANT_FALSE
,0,I4
,0);
4630 VAROR(I1
,-1,I1
,-1,I4
,-1);
4631 VAROR(I1
,-1,I1
,0,I4
,-1);
4632 VAROR(I1
,0,I1
,0,I4
,0);
4633 VAROR(I1
,-1,UI1
,255,I4
,-1);
4634 VAROR(I1
,-1,UI1
,0,I4
,-1);
4635 VAROR(I1
,0,UI1
,0,I4
,0);
4636 VAROR(I1
,-1,I2
,-1,I4
,-1);
4637 VAROR(I1
,-1,I2
,0,I4
,-1);
4638 VAROR(I1
,0,I2
,0,I4
,0);
4639 VAROR(I1
,-1,UI2
,65535,I4
,-1);
4640 VAROR(I1
,-1,UI2
,0,I4
,-1);
4641 VAROR(I1
,0,UI2
,0,I4
,0);
4642 VAROR(I1
,-1,I4
,-1,I4
,-1);
4643 VAROR(I1
,-1,I4
,0,I4
,-1);
4644 VAROR(I1
,0,I4
,0,I4
,0);
4645 VAROR(I1
,-1,UI4
,0xffffffff,I4
,-1);
4646 VAROR(I1
,-1,UI4
,0,I4
,-1);
4647 VAROR(I1
,0,UI4
,0,I4
,0);
4648 VAROR(I1
,-1,R4
,-1,I4
,-1);
4649 VAROR(I1
,-1,R4
,0,I4
,-1);
4650 VAROR(I1
,0,R4
,0,I4
,0);
4651 VAROR(I1
,-1,R8
,-1,I4
,-1);
4652 VAROR(I1
,-1,R8
,0,I4
,-1);
4653 VAROR(I1
,0,R8
,0,I4
,0);
4654 VAROR(I1
,-1,DATE
,-1,I4
,-1);
4655 VAROR(I1
,-1,DATE
,0,I4
,-1);
4656 VAROR(I1
,0,DATE
,0,I4
,0);
4659 VAROR(I1
,-1,I8
,-1,I8
,-1);
4660 VAROR(I1
,-1,I8
,0,I8
,-1);
4661 VAROR(I1
,0,I8
,0,I8
,0);
4662 VAROR(I1
,-1,UI8
,0,I4
,-1);
4663 VAROR(I1
,0,UI8
,0,I4
,0);
4665 VAROR(I1
,-1,INT
,-1,I4
,-1);
4666 VAROR(I1
,-1,INT
,0,I4
,-1);
4667 VAROR(I1
,0,INT
,0,I4
,0);
4668 VAROR(I1
,-1,UINT
,0xffffffff,I4
,-1);
4669 VAROR(I1
,-1,UINT
,0,I4
,-1);
4670 VAROR(I1
,0,UINT
,0,I4
,0);
4671 rbstr
= SysAllocString(szFalse
);
4672 VAROR(I1
,0,BSTR
,rbstr
,I4
,0);
4673 VAROR(I1
,-1,BSTR
,rbstr
,I4
,-1);
4674 SysFreeString(rbstr
);
4675 rbstr
= SysAllocString(szTrue
);
4676 VAROR(I1
,0,BSTR
,rbstr
,I4
,-1);
4677 VAROR(I1
,-1,BSTR
,rbstr
,I4
,-1);
4678 SysFreeString(rbstr
);
4679 VARORCY(I1
,-1,10000,I4
,-1);
4680 VARORCY(I1
,-1,0,I4
,-1);
4681 VARORCY(I1
,0,0,I4
,0);
4683 VAROR(UI1
,255,UI1
,255,UI1
,255);
4684 VAROR(UI1
,255,UI1
,0,UI1
,255);
4685 VAROR(UI1
,0,UI1
,0,UI1
,0);
4686 VAROR(UI1
,255,I2
,-1,I2
,-1);
4687 VAROR(UI1
,255,I2
,0,I2
,255);
4688 VAROR(UI1
,0,I2
,0,I2
,0);
4689 VAROR(UI1
,255,UI2
,65535,I4
,65535);
4690 VAROR(UI1
,255,UI2
,0,I4
,255);
4691 VAROR(UI1
,0,UI2
,0,I4
,0);
4692 VAROR(UI1
,255,I4
,-1,I4
,-1);
4693 VAROR(UI1
,255,I4
,0,I4
,255);
4694 VAROR(UI1
,0,I4
,0,I4
,0);
4695 VAROR(UI1
,255,UI4
,0xffffffff,I4
,-1);
4696 VAROR(UI1
,255,UI4
,0,I4
,255);
4697 VAROR(UI1
,0,UI4
,0,I4
,0);
4698 VAROR(UI1
,255,R4
,-1,I4
,-1);
4699 VAROR(UI1
,255,R4
,0,I4
,255);
4700 VAROR(UI1
,0,R4
,0,I4
,0);
4701 VAROR(UI1
,255,R8
,-1,I4
,-1);
4702 VAROR(UI1
,255,R8
,0,I4
,255);
4703 VAROR(UI1
,0,R8
,0,I4
,0);
4704 VAROR(UI1
,255,DATE
,-1,I4
,-1);
4705 VAROR(UI1
,255,DATE
,0,I4
,255);
4706 VAROR(UI1
,0,DATE
,0,I4
,0);
4709 VAROR(UI1
,255,I8
,-1,I8
,-1);
4710 VAROR(UI1
,255,I8
,0,I8
,255);
4711 VAROR(UI1
,0,I8
,0,I8
,0);
4712 VAROR(UI1
,255,UI8
,0,I4
,255);
4713 VAROR(UI1
,0,UI8
,0,I4
,0);
4715 VAROR(UI1
,255,INT
,-1,I4
,-1);
4716 VAROR(UI1
,255,INT
,0,I4
,255);
4717 VAROR(UI1
,0,INT
,0,I4
,0);
4718 VAROR(UI1
,255,UINT
,0xffffffff,I4
,-1);
4719 VAROR(UI1
,255,UINT
,0,I4
,255);
4720 VAROR(UI1
,0,UINT
,0,I4
,0);
4721 rbstr
= SysAllocString(szFalse
);
4722 VAROR(UI1
,0,BSTR
,rbstr
,I2
,0);
4723 VAROR(UI1
,255,BSTR
,rbstr
,I2
,255);
4724 SysFreeString(rbstr
);
4725 rbstr
= SysAllocString(szTrue
);
4726 VAROR(UI1
,0,BSTR
,rbstr
,I2
,-1);
4727 VAROR(UI1
,255,BSTR
,rbstr
,I2
,-1);
4728 SysFreeString(rbstr
);
4729 VARORCY(UI1
,255,10000,I4
,255);
4730 VARORCY(UI1
,255,0,I4
,255);
4731 VARORCY(UI1
,0,0,I4
,0);
4733 VAROR(I2
,-1,I2
,-1,I2
,-1);
4734 VAROR(I2
,-1,I2
,0,I2
,-1);
4735 VAROR(I2
,0,I2
,0,I2
,0);
4736 VAROR(I2
,-1,UI2
,65535,I4
,-1);
4737 VAROR(I2
,-1,UI2
,0,I4
,-1);
4738 VAROR(I2
,0,UI2
,0,I4
,0);
4739 VAROR(I2
,-1,I4
,-1,I4
,-1);
4740 VAROR(I2
,-1,I4
,0,I4
,-1);
4741 VAROR(I2
,0,I4
,0,I4
,0);
4742 VAROR(I2
,-1,UI4
,0xffffffff,I4
,-1);
4743 VAROR(I2
,-1,UI4
,0,I4
,-1);
4744 VAROR(I2
,0,UI4
,0,I4
,0);
4745 VAROR(I2
,-1,R4
,-1,I4
,-1);
4746 VAROR(I2
,-1,R4
,0,I4
,-1);
4747 VAROR(I2
,0,R4
,0,I4
,0);
4748 VAROR(I2
,-1,R8
,-1,I4
,-1);
4749 VAROR(I2
,-1,R8
,0,I4
,-1);
4750 VAROR(I2
,0,R8
,0,I4
,0);
4751 VAROR(I2
,-1,DATE
,-1,I4
,-1);
4752 VAROR(I2
,-1,DATE
,0,I4
,-1);
4753 VAROR(I2
,0,DATE
,0,I4
,0);
4756 VAROR(I2
,-1,I8
,-1,I8
,-1);
4757 VAROR(I2
,-1,I8
,0,I8
,-1);
4758 VAROR(I2
,0,I8
,0,I8
,0);
4759 VAROR(I2
,-1,UI8
,0,I4
,-1);
4760 VAROR(I2
,0,UI8
,0,I4
,0);
4762 VAROR(I2
,-1,INT
,-1,I4
,-1);
4763 VAROR(I2
,-1,INT
,0,I4
,-1);
4764 VAROR(I2
,0,INT
,0,I4
,0);
4765 VAROR(I2
,-1,UINT
,0xffffffff,I4
,-1);
4766 VAROR(I2
,-1,UINT
,0,I4
,-1);
4767 VAROR(I2
,0,UINT
,0,I4
,0);
4768 rbstr
= SysAllocString(szFalse
);
4769 VAROR(I2
,0,BSTR
,rbstr
,I2
,0);
4770 VAROR(I2
,-1,BSTR
,rbstr
,I2
,-1);
4771 SysFreeString(rbstr
);
4772 rbstr
= SysAllocString(szTrue
);
4773 VAROR(I2
,0,BSTR
,rbstr
,I2
,-1);
4774 VAROR(I2
,-1,BSTR
,rbstr
,I2
,-1);
4775 SysFreeString(rbstr
);
4776 VARORCY(I2
,-1,10000,I4
,-1);
4777 VARORCY(I2
,-1,0,I4
,-1);
4778 VARORCY(I2
,0,0,I4
,0);
4780 VAROR(UI2
,65535,UI2
,65535,I4
,65535);
4781 VAROR(UI2
,65535,UI2
,0,I4
,65535);
4782 VAROR(UI2
,0,UI2
,0,I4
,0);
4783 VAROR(UI2
,65535,I4
,-1,I4
,-1);
4784 VAROR(UI2
,65535,I4
,0,I4
,65535);
4785 VAROR(UI2
,0,I4
,0,I4
,0);
4786 VAROR(UI2
,65535,UI4
,0xffffffff,I4
,-1);
4787 VAROR(UI2
,65535,UI4
,0,I4
,65535);
4788 VAROR(UI2
,0,UI4
,0,I4
,0);
4789 VAROR(UI2
,65535,R4
,-1,I4
,-1);
4790 VAROR(UI2
,65535,R4
,0,I4
,65535);
4791 VAROR(UI2
,0,R4
,0,I4
,0);
4792 VAROR(UI2
,65535,R8
,-1,I4
,-1);
4793 VAROR(UI2
,65535,R8
,0,I4
,65535);
4794 VAROR(UI2
,0,R8
,0,I4
,0);
4795 VAROR(UI2
,65535,DATE
,-1,I4
,-1);
4796 VAROR(UI2
,65535,DATE
,0,I4
,65535);
4797 VAROR(UI2
,0,DATE
,0,I4
,0);
4800 VAROR(UI2
,65535,I8
,-1,I8
,-1);
4801 VAROR(UI2
,65535,I8
,0,I8
,65535);
4802 VAROR(UI2
,0,I8
,0,I8
,0);
4803 VAROR(UI2
,65535,UI8
,0,I4
,65535);
4804 VAROR(UI2
,0,UI8
,0,I4
,0);
4806 VAROR(UI2
,65535,INT
,-1,I4
,-1);
4807 VAROR(UI2
,65535,INT
,0,I4
,65535);
4808 VAROR(UI2
,0,INT
,0,I4
,0);
4809 VAROR(UI2
,65535,UINT
,0xffffffff,I4
,-1);
4810 VAROR(UI2
,65535,UINT
,0,I4
,65535);
4811 VAROR(UI2
,0,UINT
,0,I4
,0);
4812 rbstr
= SysAllocString(szFalse
);
4813 VAROR(UI2
,0,BSTR
,rbstr
,I4
,0);
4814 VAROR(UI2
,65535,BSTR
,rbstr
,I4
,65535);
4815 SysFreeString(rbstr
);
4816 rbstr
= SysAllocString(szTrue
);
4817 VAROR(UI2
,0,BSTR
,rbstr
,I4
,-1);
4818 VAROR(UI2
,65535,BSTR
,rbstr
,I4
,-1);
4819 SysFreeString(rbstr
);
4820 VARORCY(UI2
,65535,10000,I4
,65535);
4821 VARORCY(UI2
,65535,0,I4
,65535);
4822 VARORCY(UI2
,0,0,I4
,0);
4824 VAROR(I4
,-1,I4
,-1,I4
,-1);
4825 VAROR(I4
,-1,I4
,0,I4
,-1);
4826 VAROR(I4
,0,I4
,0,I4
,0);
4827 VAROR(I4
,-1,UI4
,0xffffffff,I4
,-1);
4828 VAROR(I4
,-1,UI4
,0,I4
,-1);
4829 VAROR(I4
,0,UI4
,0,I4
,0);
4830 VAROR(I4
,-1,R4
,-1,I4
,-1);
4831 VAROR(I4
,-1,R4
,0,I4
,-1);
4832 VAROR(I4
,0,R4
,0,I4
,0);
4833 VAROR(I4
,-1,R8
,-1,I4
,-1);
4834 VAROR(I4
,-1,R8
,0,I4
,-1);
4835 VAROR(I4
,0,R8
,0,I4
,0);
4836 VAROR(I4
,-1,DATE
,-1,I4
,-1);
4837 VAROR(I4
,-1,DATE
,0,I4
,-1);
4838 VAROR(I4
,0,DATE
,0,I4
,0);
4841 VAROR(I4
,-1,I8
,-1,I8
,-1);
4842 VAROR(I4
,-1,I8
,0,I8
,-1);
4843 VAROR(I4
,0,I8
,0,I8
,0);
4844 VAROR(I4
,-1,UI8
,0,I4
,-1);
4845 VAROR(I4
,0,UI8
,0,I4
,0);
4847 VAROR(I4
,-1,INT
,-1,I4
,-1);
4848 VAROR(I4
,-1,INT
,0,I4
,-1);
4849 VAROR(I4
,0,INT
,0,I4
,0);
4850 VAROR(I4
,-1,UINT
,0xffffffff,I4
,-1);
4851 VAROR(I4
,-1,UINT
,0,I4
,-1);
4852 VAROR(I4
,0,UINT
,0,I4
,0);
4853 rbstr
= SysAllocString(szFalse
);
4854 VAROR(I4
,0,BSTR
,rbstr
,I4
,0);
4855 VAROR(I4
,-1,BSTR
,rbstr
,I4
,-1);
4856 SysFreeString(rbstr
);
4857 rbstr
= SysAllocString(szTrue
);
4858 VAROR(I4
,0,BSTR
,rbstr
,I4
,-1);
4859 VAROR(I4
,-1,BSTR
,rbstr
,I4
,-1);
4860 SysFreeString(rbstr
);
4861 VARORCY(I4
,-1,10000,I4
,-1);
4862 VARORCY(I4
,-1,0,I4
,-1);
4863 VARORCY(I4
,0,0,I4
,0);
4865 VAROR(UI4
,0xffffffff,UI4
,0xffffffff,I4
,-1);
4866 VAROR(UI4
,0xffffffff,UI4
,0,I4
,-1);
4867 VAROR(UI4
,0,UI4
,0,I4
,0);
4868 VAROR(UI4
,0xffffffff,R4
,-1,I4
,-1);
4869 VAROR(UI4
,0xffffffff,R4
,0,I4
,-1);
4870 VAROR(UI4
,0,R4
,0,I4
,0);
4871 VAROR(UI4
,0xffffffff,R8
,-1,I4
,-1);
4872 VAROR(UI4
,0xffffffff,R8
,0,I4
,-1);
4873 VAROR(UI4
,0,R8
,0,I4
,0);
4874 VAROR(UI4
,0xffffffff,DATE
,-1,I4
,-1);
4875 VAROR(UI4
,0xffffffff,DATE
,0,I4
,-1);
4876 VAROR(UI4
,0,DATE
,0,I4
,0);
4879 VAROR(UI4
,0xffffffff,I8
,-1,I8
,-1);
4880 VAROR(UI4
,0xffffffff,I8
,0,I8
,0xffffffff);
4881 VAROR(UI4
,0,I8
,0,I8
,0);
4882 VAROR(UI4
,0xffffffff,UI8
,0,I4
,-1);
4883 VAROR(UI4
,0,UI8
,0,I4
,0);
4885 VAROR(UI4
,0xffffffff,INT
,-1,I4
,-1);
4886 VAROR(UI4
,0xffffffff,INT
,0,I4
,-1);
4887 VAROR(UI4
,0,INT
,0,I4
,0);
4888 VAROR(UI4
,0xffffffff,UINT
,0xffffffff,I4
,-1);
4889 VAROR(UI4
,0xffffffff,UINT
,0,I4
,-1);
4890 VAROR(UI4
,0,UINT
,0,I4
,0);
4891 rbstr
= SysAllocString(szFalse
);
4892 VAROR(UI4
,0,BSTR
,rbstr
,I4
,0);
4893 VAROR(UI4
,0xffffffff,BSTR
,rbstr
,I4
,-1);
4894 SysFreeString(rbstr
);
4895 rbstr
= SysAllocString(szTrue
);
4896 VAROR(UI4
,0,BSTR
,rbstr
,I4
,-1);
4897 VAROR(UI4
,0xffffffff,BSTR
,rbstr
,I4
,-1);
4898 SysFreeString(rbstr
);
4899 VARORCY(UI4
,0xffffffff,10000,I4
,-1);
4900 VARORCY(UI4
,0xffffffff,0,I4
,-1);
4901 VARORCY(UI4
,0,0,I4
,0);
4903 VAROR(R4
,-1,R4
,-1,I4
,-1);
4904 VAROR(R4
,-1,R4
,0,I4
,-1);
4905 VAROR(R4
,0,R4
,0,I4
,0);
4906 VAROR(R4
,-1,R8
,-1,I4
,-1);
4907 VAROR(R4
,-1,R8
,0,I4
,-1);
4908 VAROR(R4
,0,R8
,0,I4
,0);
4909 VAROR(R4
,-1,DATE
,-1,I4
,-1);
4910 VAROR(R4
,-1,DATE
,0,I4
,-1);
4911 VAROR(R4
,0,DATE
,0,I4
,0);
4914 VAROR(R4
,-1,I8
,-1,I8
,-1);
4915 VAROR(R4
,-1,I8
,0,I8
,-1);
4916 VAROR(R4
,0,I8
,0,I8
,0);
4917 VAROR(R4
,-1,UI8
,0,I4
,-1);
4918 VAROR(R4
,0,UI8
,0,I4
,0);
4920 VAROR(R4
,-1,INT
,-1,I4
,-1);
4921 VAROR(R4
,-1,INT
,0,I4
,-1);
4922 VAROR(R4
,0,INT
,0,I4
,0);
4923 VAROR(R4
,-1,UINT
,0xffffffff,I4
,-1);
4924 VAROR(R4
,-1,UINT
,0,I4
,-1);
4925 VAROR(R4
,0,UINT
,0,I4
,0);
4926 rbstr
= SysAllocString(szFalse
);
4927 VAROR(R4
,0,BSTR
,rbstr
,I4
,0);
4928 VAROR(R4
,-1,BSTR
,rbstr
,I4
,-1);
4929 SysFreeString(rbstr
);
4930 rbstr
= SysAllocString(szTrue
);
4931 VAROR(R4
,0,BSTR
,rbstr
,I4
,-1);
4932 VAROR(R4
,-1,BSTR
,rbstr
,I4
,-1);
4933 SysFreeString(rbstr
);
4934 VARORCY(R4
,-1,10000,I4
,-1);
4935 VARORCY(R4
,-1,0,I4
,-1);
4936 VARORCY(R4
,0,0,I4
,0);
4938 VAROR(R8
,-1,R8
,-1,I4
,-1);
4939 VAROR(R8
,-1,R8
,0,I4
,-1);
4940 VAROR(R8
,0,R8
,0,I4
,0);
4941 VAROR(R8
,-1,DATE
,-1,I4
,-1);
4942 VAROR(R8
,-1,DATE
,0,I4
,-1);
4943 VAROR(R8
,0,DATE
,0,I4
,0);
4946 VAROR(R8
,-1,I8
,-1,I8
,-1);
4947 VAROR(R8
,-1,I8
,0,I8
,-1);
4948 VAROR(R8
,0,I8
,0,I8
,0);
4949 VAROR(R8
,-1,UI8
,0,I4
,-1);
4950 VAROR(R8
,0,UI8
,0,I4
,0);
4952 VAROR(R8
,-1,INT
,-1,I4
,-1);
4953 VAROR(R8
,-1,INT
,0,I4
,-1);
4954 VAROR(R8
,0,INT
,0,I4
,0);
4955 VAROR(R8
,-1,UINT
,0xffffffff,I4
,-1);
4956 VAROR(R8
,-1,UINT
,0,I4
,-1);
4957 VAROR(R8
,0,UINT
,0,I4
,0);
4958 rbstr
= SysAllocString(szFalse
);
4959 VAROR(R8
,0,BSTR
,rbstr
,I4
,0);
4960 VAROR(R8
,-1,BSTR
,rbstr
,I4
,-1);
4961 SysFreeString(rbstr
);
4962 rbstr
= SysAllocString(szTrue
);
4963 VAROR(R8
,0,BSTR
,rbstr
,I4
,-1);
4964 VAROR(R8
,-1,BSTR
,rbstr
,I4
,-1);
4965 SysFreeString(rbstr
);
4966 VARORCY(R8
,-1,10000,I4
,-1);
4967 VARORCY(R8
,-1,0,I4
,-1);
4968 VARORCY(R8
,0,0,I4
,0);
4970 VAROR(DATE
,-1,DATE
,-1,I4
,-1);
4971 VAROR(DATE
,-1,DATE
,0,I4
,-1);
4972 VAROR(DATE
,0,DATE
,0,I4
,0);
4975 VAROR(DATE
,-1,I8
,-1,I8
,-1);
4976 VAROR(DATE
,-1,I8
,0,I8
,-1);
4977 VAROR(DATE
,0,I8
,0,I8
,0);
4978 VAROR(DATE
,-1,UI8
,0,I4
,-1);
4979 VAROR(DATE
,0,UI8
,0,I4
,0);
4981 VAROR(DATE
,-1,INT
,-1,I4
,-1);
4982 VAROR(DATE
,-1,INT
,0,I4
,-1);
4983 VAROR(DATE
,0,INT
,0,I4
,0);
4984 VAROR(DATE
,-1,UINT
,0xffffffff,I4
,-1);
4985 VAROR(DATE
,-1,UINT
,0,I4
,-1);
4986 VAROR(DATE
,0,UINT
,0,I4
,0);
4987 rbstr
= SysAllocString(szFalse
);
4988 VAROR(DATE
,0,BSTR
,rbstr
,I4
,0);
4989 VAROR(DATE
,-1,BSTR
,rbstr
,I4
,-1);
4990 SysFreeString(rbstr
);
4991 rbstr
= SysAllocString(szTrue
);
4992 VAROR(DATE
,0,BSTR
,rbstr
,I4
,-1);
4993 VAROR(DATE
,-1,BSTR
,rbstr
,I4
,-1);
4994 SysFreeString(rbstr
);
4995 VARORCY(DATE
,-1,10000,I4
,-1);
4996 VARORCY(DATE
,-1,0,I4
,-1);
4997 VARORCY(DATE
,0,0,I4
,0);
5001 VAROR(I8
,-1,I8
,-1,I8
,-1);
5002 VAROR(I8
,-1,I8
,0,I8
,-1);
5003 VAROR(I8
,0,I8
,0,I8
,0);
5004 VAROR(I8
,-1,UI8
,0,I8
,-1);
5005 VAROR(I8
,0,UI8
,0,I8
,0);
5006 /* These overflow under native and Wine
5007 VAROR(I8,-1,INT,-1,I4,-1);
5008 VAROR(I8,-1,INT,0,I4,-1);
5009 VAROR(I8,0,INT,0,I4,0); */
5010 VAROR(I8
,-1,UINT
,0xffffffff,I8
,-1);
5011 VAROR(I8
,-1,UINT
,0,I8
,-1);
5012 VAROR(I8
,0,UINT
,0,I8
,0);
5013 rbstr
= SysAllocString(szFalse
);
5014 VAROR(I8
,0,BSTR
,rbstr
,I8
,0);
5015 VAROR(I8
,-1,BSTR
,rbstr
,I8
,-1);
5016 SysFreeString(rbstr
);
5017 rbstr
= SysAllocString(szTrue
);
5018 VAROR(I8
,0,BSTR
,rbstr
,I8
,-1);
5019 VAROR(I8
,-1,BSTR
,rbstr
,I8
,-1);
5020 SysFreeString(rbstr
);
5021 VARORCY(I8
,-1,10000,I8
,-1);
5022 VARORCY(I8
,-1,0,I8
,-1);
5023 VARORCY(I8
,0,0,I8
,0);
5025 VAROR(UI8
,0xffff,UI8
,0xffff,I4
,0xffff);
5026 VAROR(UI8
,0xffff,UI8
,0,I4
,0xffff);
5027 VAROR(UI8
,0,UI8
,0,I4
,0);
5028 VAROR(UI8
,0xffff,INT
,-1,I4
,-1);
5029 VAROR(UI8
,0xffff,INT
,0,I4
,0xffff);
5030 VAROR(UI8
,0,INT
,0,I4
,0);
5031 VAROR(UI8
,0xffff,UINT
,0xffff,I4
,0xffff);
5032 VAROR(UI8
,0xffff,UINT
,0,I4
,0xffff);
5033 VAROR(UI8
,0,UINT
,0,I4
,0);
5034 rbstr
= SysAllocString(szFalse
);
5035 VAROR(UI8
,0,BSTR
,rbstr
,I4
,0);
5036 VAROR(UI8
,0xffff,BSTR
,rbstr
,I4
,0xffff);
5037 SysFreeString(rbstr
);
5038 rbstr
= SysAllocString(szTrue
);
5039 VAROR(UI8
,0,BSTR
,rbstr
,I4
,-1);
5040 VAROR(UI8
,0xffff,BSTR
,rbstr
,I4
,-1);
5041 SysFreeString(rbstr
);
5042 VARORCY(UI8
,0xffff,10000,I4
,0xffff);
5043 VARORCY(UI8
,0xffff,0,I4
,0xffff);
5044 VARORCY(UI8
,0,0,I4
,0);
5047 VAROR(INT
,-1,INT
,-1,I4
,-1);
5048 VAROR(INT
,-1,INT
,0,I4
,-1);
5049 VAROR(INT
,0,INT
,0,I4
,0);
5050 VAROR(INT
,-1,UINT
,0xffff,I4
,-1);
5051 VAROR(INT
,-1,UINT
,0,I4
,-1);
5052 VAROR(INT
,0,UINT
,0,I4
,0);
5053 rbstr
= SysAllocString(szFalse
);
5054 VAROR(INT
,0,BSTR
,rbstr
,I4
,0);
5055 VAROR(INT
,-1,BSTR
,rbstr
,I4
,-1);
5056 SysFreeString(rbstr
);
5057 rbstr
= SysAllocString(szTrue
);
5058 VAROR(INT
,0,BSTR
,rbstr
,I4
,-1);
5059 VAROR(INT
,-1,BSTR
,rbstr
,I4
,-1);
5060 SysFreeString(rbstr
);
5061 VARORCY(INT
,-1,10000,I4
,-1);
5062 VARORCY(INT
,-1,0,I4
,-1);
5063 VARORCY(INT
,0,0,I4
,0);
5065 VAROR(UINT
,0xffff,UINT
,0xffff,I4
,0xffff);
5066 VAROR(UINT
,0xffff,UINT
,0,I4
,0xffff);
5067 VAROR(UINT
,0,UINT
,0,I4
,0);
5068 rbstr
= SysAllocString(szFalse
);
5069 VAROR(UINT
,0,BSTR
,rbstr
,I4
,0);
5070 VAROR(UINT
,0xffff,BSTR
,rbstr
,I4
,0xffff);
5071 SysFreeString(rbstr
);
5072 rbstr
= SysAllocString(szTrue
);
5073 VAROR(UINT
,0,BSTR
,rbstr
,I4
,-1);
5074 VAROR(UINT
,0xffff,BSTR
,rbstr
,I4
,-1);
5075 SysFreeString(rbstr
);
5076 VARORCY(UINT
,0xffff,10000,I4
,0xffff);
5077 VARORCY(UINT
,0xffff,0,I4
,0xffff);
5078 VARORCY(UINT
,0,0,I4
,0);
5080 lbstr
= SysAllocString(szFalse
);
5081 rbstr
= SysAllocString(szFalse
);
5082 VAROR(BSTR
,lbstr
,BSTR
,rbstr
,BOOL
,0);
5083 SysFreeString(rbstr
);
5084 rbstr
= SysAllocString(szTrue
);
5085 VAROR(BSTR
,lbstr
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
5086 SysFreeString(lbstr
);
5087 lbstr
= SysAllocString(szTrue
);
5088 VAROR(BSTR
,lbstr
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
5089 VARORCY(BSTR
,lbstr
,10000,I4
,-1);
5090 SysFreeString(lbstr
);
5091 lbstr
= SysAllocString(szFalse
);
5092 VARORCY(BSTR
,lbstr
,10000,I4
,1);
5093 SysFreeString(lbstr
);
5094 SysFreeString(rbstr
);
5097 static HRESULT (WINAPI
*pVarEqv
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
5099 #define VAREQV(vt1,val1,vt2,val2,rvt,rval) \
5100 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
5101 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
5102 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
5103 test_var_call2( __LINE__, pVarEqv, &left, &right, &exp )
5105 static void test_VarEqv(void)
5107 VARIANT left
, right
, exp
, result
;
5113 /* Test all possible flag/vt combinations & the resulting vt type */
5114 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
5116 VARTYPE leftvt
, rightvt
, resvt
;
5118 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
5122 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
5128 if (leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
||
5129 leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
||
5130 leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
)
5133 memset(&left
, 0, sizeof(left
));
5134 memset(&right
, 0, sizeof(right
));
5135 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
5136 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
5137 V_VT(&result
) = VT_EMPTY
;
5140 if (ExtraFlags
[i
] & VT_ARRAY
|| ExtraFlags
[i
] & VT_BYREF
||
5141 !IsValidVariantClearVT(leftvt
, ExtraFlags
[i
]) ||
5142 !IsValidVariantClearVT(rightvt
, ExtraFlags
[i
]) ||
5143 leftvt
== VT_CLSID
|| rightvt
== VT_CLSID
||
5144 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
||
5145 leftvt
== VT_VARIANT
|| rightvt
== VT_VARIANT
||
5146 leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
)
5150 if (leftvt
== VT_EMPTY
|| rightvt
== VT_EMPTY
)
5152 if (leftvt
== rightvt
||
5153 leftvt
== VT_I2
|| rightvt
== VT_I2
||
5154 leftvt
== VT_UI1
|| rightvt
== VT_UI1
||
5155 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
5157 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
5159 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
5162 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
5166 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
5168 if (leftvt
== rightvt
)
5170 else if (leftvt
== rightvt
||
5171 leftvt
== VT_I2
|| rightvt
== VT_I2
||
5172 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
5176 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
5179 else if (leftvt
== VT_I2
|| rightvt
== VT_I2
)
5181 if (leftvt
== rightvt
||
5182 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
5184 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
5187 else if (leftvt
== VT_BOOL
&& rightvt
== VT_BOOL
)
5191 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
5193 if (leftvt
== VT_INT
|| rightvt
== VT_INT
)
5198 hres
= pVarEqv(&left
, &right
, &result
);
5200 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
5201 "VarEqv: %d|0x%X, %d|0x%X: Expected failure, got 0x%X vt %d\n",
5202 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], hres
,
5205 ok(hres
== S_OK
&& V_VT(&result
) == resvt
,
5206 "VarEqv: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%X vt %d\n",
5207 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], resvt
, hres
,
5213 /* Test returned values */
5214 VAREQV(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
);
5215 VAREQV(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
);
5216 VAREQV(BOOL
,TRUE
,BOOL
,TRUE
,BOOL
,VARIANT_TRUE
);
5217 VAREQV(BOOL
,FALSE
,BOOL
,FALSE
,BOOL
,VARIANT_TRUE
);
5218 VAREQV(BOOL
,TRUE
,BOOL
,FALSE
,BOOL
,-2);
5219 VAREQV(BOOL
,FALSE
,BOOL
,TRUE
,BOOL
,-2);
5220 VAREQV(BOOL
,6,BOOL
,7,BOOL
,-2);
5221 VAREQV(BOOL
,6,BOOL
,6,BOOL
,VARIANT_TRUE
);
5222 VAREQV(BOOL
,VARIANT_TRUE
,I2
,VARIANT_TRUE
,I2
,VARIANT_TRUE
);
5223 VAREQV(BOOL
,VARIANT_TRUE
,I2
,VARIANT_FALSE
,I2
,VARIANT_FALSE
);
5224 VAREQV(BOOL
,6,I2
,7,I2
,-2);
5225 VAREQV(UI1
,1,UI1
,1,UI1
,255);
5226 VAREQV(UI1
,1,UI1
,0,UI1
,254);
5227 VAREQV(UI1
,0,UI1
,1,UI1
,254);
5230 VAREQV(UI4
,VARIANT_FALSE
,I8
,VARIANT_FALSE
,I8
,-1);
5231 VAREQV(UI4
,5,I8
,19,I8
,-23);
5232 VAREQV(UI4
,VARIANT_FALSE
,UI8
,VARIANT_FALSE
,I4
,-1);
5236 static HRESULT (WINAPI
*pVarMul
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
5238 #define VARMUL(vt1,val1,vt2,val2,rvt,rval) \
5239 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
5240 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
5241 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
5242 test_var_call2( __LINE__, pVarMul, &left, &right, &exp )
5244 static void test_VarMul(void)
5246 VARIANT left
, right
, exp
, result
, cy
, dec
;
5254 lbstr
= SysAllocString(sz12
);
5255 rbstr
= SysAllocString(sz12
);
5257 /* Test all possible flag/vt combinations & the resulting vt type */
5258 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
5260 VARTYPE leftvt
, rightvt
, resvt
;
5262 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
5267 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
5273 if (leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
||
5274 leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
)
5277 memset(&left
, 0, sizeof(left
));
5278 memset(&right
, 0, sizeof(right
));
5279 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
5280 if (leftvt
== VT_BSTR
)
5281 V_BSTR(&left
) = lbstr
;
5282 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
5283 if (rightvt
== VT_BSTR
)
5284 V_BSTR(&right
) = rbstr
;
5285 V_VT(&result
) = VT_EMPTY
;
5288 /* Don't ask me why but native VarMul cannot handle:
5289 VT_I1, VT_UI2, VT_UI4, VT_INT, VT_UINT and VT_UI8.
5290 Tested with DCOM98, Win2k, WinXP */
5291 if (ExtraFlags
[i
] & VT_ARRAY
|| ExtraFlags
[i
] & VT_BYREF
||
5292 !IsValidVariantClearVT(leftvt
, ExtraFlags
[i
]) ||
5293 !IsValidVariantClearVT(rightvt
, ExtraFlags
[i
]) ||
5294 leftvt
== VT_CLSID
|| rightvt
== VT_CLSID
||
5295 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
||
5296 leftvt
== VT_VARIANT
|| rightvt
== VT_VARIANT
||
5297 leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
||
5298 leftvt
== VT_I1
|| rightvt
== VT_I1
||
5299 leftvt
== VT_UI2
|| rightvt
== VT_UI2
||
5300 leftvt
== VT_UI4
|| rightvt
== VT_UI4
||
5301 leftvt
== VT_UI8
|| rightvt
== VT_UI8
||
5302 leftvt
== VT_INT
|| rightvt
== VT_INT
||
5303 leftvt
== VT_UINT
|| rightvt
== VT_UINT
) {
5307 if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
5309 else if (leftvt
== VT_DECIMAL
|| rightvt
== VT_DECIMAL
)
5311 else if (leftvt
== VT_R8
|| rightvt
== VT_R8
||
5312 leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
||
5313 leftvt
== VT_DATE
|| rightvt
== VT_DATE
)
5315 else if (leftvt
== VT_R4
|| rightvt
== VT_R4
) {
5316 if (leftvt
== VT_I4
|| rightvt
== VT_I4
||
5317 leftvt
== VT_I8
|| rightvt
== VT_I8
||
5318 leftvt
== VT_CY
|| rightvt
== VT_CY
)
5322 } else if (leftvt
== VT_CY
|| rightvt
== VT_CY
)
5324 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
5326 else if (leftvt
== VT_I4
|| rightvt
== VT_I4
)
5328 else if (leftvt
== VT_I2
|| rightvt
== VT_I2
||
5329 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
||
5330 (leftvt
== VT_EMPTY
&& rightvt
== VT_EMPTY
))
5332 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
5335 hres
= pVarMul(&left
, &right
, &result
);
5337 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
5338 "VarMul: %d|0x%X, %d|0x%X: Expected failure, got 0x%X vt %d\n",
5339 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], hres
,
5342 ok(hres
== S_OK
&& V_VT(&result
) == resvt
,
5343 "VarMul: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%X vt %d\n",
5344 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], resvt
, hres
,
5351 /* Test returned values */
5352 VARMUL(I4
,4,I4
,2,I4
,8);
5353 VARMUL(I2
,4,I2
,2,I2
,8);
5354 VARMUL(I2
,-13,I4
,5,I4
,-65);
5355 VARMUL(I4
,-13,I4
,5,I4
,-65);
5356 VARMUL(I2
,7,R4
,0.5f
,R4
,3.5f
);
5357 VARMUL(R4
,0.5f
,I4
,5,R8
,2.5);
5358 VARMUL(R8
,7.1,BOOL
,0,R8
,0);
5359 VARMUL(BSTR
,lbstr
,I2
,4,R8
,48);
5360 VARMUL(BSTR
,lbstr
,BOOL
,1,R8
,12);
5361 VARMUL(BSTR
,lbstr
,R4
,0.1f
,R8
,1.2);
5362 VARMUL(BSTR
,lbstr
,BSTR
,rbstr
,R8
,144);
5363 VARMUL(R4
,0.2f
,BSTR
,rbstr
,R8
,2.4);
5364 VARMUL(DATE
,2.25,I4
,7,R8
,15.75);
5366 VARMUL(UI1
, UI1_MAX
, UI1
, UI1_MAX
, I4
, UI1_MAX
* UI1_MAX
);
5367 VARMUL(I2
, I2_MAX
, I2
, I2_MAX
, I4
, I2_MAX
* I2_MAX
);
5368 VARMUL(I2
, I2_MAX
, I2
, I2_MIN
, I4
, I2_MAX
* I2_MIN
);
5369 VARMUL(I2
, I2_MIN
, I2
, I2_MIN
, I4
, I2_MIN
* I2_MIN
);
5370 VARMUL(I4
, I4_MAX
, I4
, I4_MAX
, R8
, (double)I4_MAX
* I4_MAX
);
5371 VARMUL(I4
, I4_MAX
, I4
, I4_MIN
, R8
, (double)I4_MAX
* I4_MIN
);
5372 VARMUL(I4
, I4_MIN
, I4
, I4_MIN
, R8
, (double)I4_MIN
* I4_MIN
);
5373 VARMUL(R4
, R4_MAX
, R4
, R4_MAX
, R8
, (double)R4_MAX
* R4_MAX
);
5374 VARMUL(R4
, R4_MAX
, R4
, R4_MIN
, R4
, R4_MAX
* R4_MIN
);
5375 VARMUL(R4
, R4_MIN
, R4
, R4_MIN
, R4
, R4_MIN
* R4_MIN
);
5376 VARMUL(R8
, R8_MAX
, R8
, R8_MIN
, R8
, R8_MAX
* R8_MIN
);
5377 VARMUL(R8
, R8_MIN
, R8
, R8_MIN
, R8
, R8_MIN
* R8_MIN
);
5379 /* Manuly test some VT_CY and VT_DECIMAL variants */
5381 hres
= VarCyFromI4(4711, &V_CY(&cy
));
5382 ok(hres
== S_OK
, "VarCyFromI4 failed!\n");
5383 V_VT(&dec
) = VT_DECIMAL
;
5384 hres
= VarDecFromR8(-4.2, &V_DECIMAL(&dec
));
5385 ok(hres
== S_OK
, "VarDecFromR4 failed!\n");
5386 memset(&left
, 0, sizeof(left
));
5387 memset(&right
, 0, sizeof(right
));
5388 V_VT(&left
) = VT_I4
;
5390 V_VT(&right
) = VT_UI1
;
5393 hres
= pVarMul(&cy
, &right
, &result
);
5394 ok(hres
== S_OK
&& V_VT(&result
) == VT_CY
, "VarMul: expected coerced type VT_CY, got %s!\n", vtstr(V_VT(&result
)));
5395 hres
= VarR8FromCy(V_CY(&result
), &r
);
5396 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 42399), "VarMul: CY value %f, expected %f\n", r
, (double)42399);
5398 hres
= pVarMul(&left
, &dec
, &result
);
5399 ok(hres
== S_OK
&& V_VT(&result
) == VT_DECIMAL
, "VarMul: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result
)));
5400 hres
= VarR8FromDec(&V_DECIMAL(&result
), &r
);
5401 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 46.2), "VarMul: DECIMAL value %f, expected %f\n", r
, (double)46.2);
5403 SysFreeString(lbstr
);
5404 SysFreeString(rbstr
);
5407 static HRESULT (WINAPI
*pVarAdd
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
5409 #define VARADD(vt1,val1,vt2,val2,rvt,rval) \
5410 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
5411 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
5412 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
5413 test_var_call2( __LINE__, pVarAdd, &left, &right, &exp )
5415 static void test_VarAdd(void)
5417 VARIANT left
, right
, exp
, result
, cy
, dec
;
5425 lbstr
= SysAllocString(sz12
);
5426 rbstr
= SysAllocString(sz12
);
5428 /* Test all possible flag/vt combinations & the resulting vt type */
5429 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
5431 VARTYPE leftvt
, rightvt
, resvt
;
5433 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
5438 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
5444 if (leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
)
5447 memset(&left
, 0, sizeof(left
));
5448 memset(&right
, 0, sizeof(right
));
5449 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
5450 if (leftvt
== VT_BSTR
)
5451 V_BSTR(&left
) = lbstr
;
5452 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
5453 if (rightvt
== VT_BSTR
)
5454 V_BSTR(&right
) = rbstr
;
5455 V_VT(&result
) = VT_EMPTY
;
5458 /* Don't ask me why but native VarAdd cannot handle:
5459 VT_I1, VT_UI2, VT_UI4, VT_INT, VT_UINT and VT_UI8.
5460 Tested with DCOM98, Win2k, WinXP */
5461 if (ExtraFlags
[i
] & VT_ARRAY
|| ExtraFlags
[i
] & VT_BYREF
||
5462 !IsValidVariantClearVT(leftvt
, ExtraFlags
[i
]) ||
5463 !IsValidVariantClearVT(rightvt
, ExtraFlags
[i
]) ||
5464 leftvt
== VT_CLSID
|| rightvt
== VT_CLSID
||
5465 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
||
5466 leftvt
== VT_VARIANT
|| rightvt
== VT_VARIANT
||
5467 leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
||
5468 leftvt
== VT_I1
|| rightvt
== VT_I1
||
5469 leftvt
== VT_UI2
|| rightvt
== VT_UI2
||
5470 leftvt
== VT_UI4
|| rightvt
== VT_UI4
||
5471 leftvt
== VT_UI8
|| rightvt
== VT_UI8
||
5472 leftvt
== VT_INT
|| rightvt
== VT_INT
||
5473 leftvt
== VT_UINT
|| rightvt
== VT_UINT
) {
5477 if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
5479 else if (leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
)
5481 else if (leftvt
== VT_DECIMAL
|| rightvt
== VT_DECIMAL
)
5483 else if (leftvt
== VT_DATE
|| rightvt
== VT_DATE
)
5485 else if (leftvt
== VT_CY
|| rightvt
== VT_CY
)
5487 else if (leftvt
== VT_R8
|| rightvt
== VT_R8
)
5489 else if (leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
) {
5490 if ((leftvt
== VT_BSTR
&& rightvt
== VT_BSTR
) ||
5491 leftvt
== VT_EMPTY
|| rightvt
== VT_EMPTY
)
5495 } else if (leftvt
== VT_R4
|| rightvt
== VT_R4
) {
5496 if (leftvt
== VT_I4
|| rightvt
== VT_I4
||
5497 leftvt
== VT_I8
|| rightvt
== VT_I8
)
5502 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
5504 else if (leftvt
== VT_I4
|| rightvt
== VT_I4
)
5506 else if (leftvt
== VT_I2
|| rightvt
== VT_I2
||
5507 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
||
5508 (leftvt
== VT_EMPTY
&& rightvt
== VT_EMPTY
))
5510 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
5513 hres
= pVarAdd(&left
, &right
, &result
);
5515 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
5516 "VarAdd: %d|0x%X, %d|0x%X: Expected failure, got 0x%X vt %d\n",
5517 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], hres
,
5520 ok(hres
== S_OK
&& V_VT(&result
) == resvt
,
5521 "VarAdd: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%X vt %d\n",
5522 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], resvt
, hres
,
5525 /* Note, we don't clear left/right deliberately here */
5526 VariantClear(&result
);
5531 /* Test returned values */
5532 VARADD(I4
,4,I4
,2,I4
,6);
5533 VARADD(I2
,4,I2
,2,I2
,6);
5534 VARADD(I2
,-13,I4
,5,I4
,-8);
5535 VARADD(I4
,-13,I4
,5,I4
,-8);
5536 VARADD(I2
,7,R4
,0.5f
,R4
,7.5f
);
5537 VARADD(R4
,0.5f
,I4
,5,R8
,5.5);
5538 VARADD(R8
,7.1,BOOL
,0,R8
,7.1);
5539 VARADD(BSTR
,lbstr
,I2
,4,R8
,16);
5540 VARADD(BSTR
,lbstr
,BOOL
,1,R8
,13);
5541 VARADD(BSTR
,lbstr
,R4
,0.1f
,R8
,12.1);
5542 VARADD(R4
,0.2f
,BSTR
,rbstr
,R8
,12.2);
5543 VARADD(DATE
,2.25,I4
,7,DATE
,9.25);
5544 VARADD(DATE
,1.25,R4
,-1.7f
,DATE
,-0.45);
5546 VARADD(UI1
, UI1_MAX
, UI1
, UI1_MAX
, I2
, UI1_MAX
+ UI1_MAX
);
5547 VARADD(I2
, I2_MAX
, I2
, I2_MAX
, I4
, I2_MAX
+ I2_MAX
);
5548 VARADD(I2
, I2_MAX
, I2
, I2_MIN
, I2
, I2_MAX
+ I2_MIN
);
5549 VARADD(I2
, I2_MIN
, I2
, I2_MIN
, I4
, I2_MIN
+ I2_MIN
);
5550 VARADD(I4
, I4_MAX
, I4
, I4_MIN
, I4
, I4_MAX
+ I4_MIN
);
5551 VARADD(I4
, I4_MAX
, I4
, I4_MAX
, R8
, (double)I4_MAX
+ I4_MAX
);
5552 VARADD(I4
, I4_MIN
, I4
, I4_MIN
, R8
, (double)I4_MIN
+ I4_MIN
);
5553 VARADD(R4
, R4_MAX
, R4
, R4_MAX
, R8
, (double)R4_MAX
+ R4_MAX
);
5554 VARADD(R4
, R4_MAX
, R4
, R4_MIN
, R4
, R4_MAX
+ R4_MIN
);
5555 VARADD(R4
, R4_MIN
, R4
, R4_MIN
, R4
, R4_MIN
+ R4_MIN
);
5556 VARADD(R8
, R8_MAX
, R8
, R8_MIN
, R8
, R8_MAX
+ R8_MIN
);
5557 VARADD(R8
, R8_MIN
, R8
, R8_MIN
, R8
, R8_MIN
+ R8_MIN
);
5559 /* Manually test BSTR + BSTR */
5560 V_VT(&left
) = VT_BSTR
;
5561 V_BSTR(&left
) = lbstr
;
5562 V_VT(&right
) = VT_BSTR
;
5563 V_BSTR(&right
) = rbstr
;
5564 hres
= pVarAdd(&left
, &right
, &result
);
5565 ok(hres
== S_OK
&& V_VT(&result
) == VT_BSTR
, "VarAdd: expected coerced type VT_BSTR, got %s!\n", vtstr(V_VT(&result
)));
5566 hres
= VarR8FromStr(V_BSTR(&result
), 0, 0, &r
);
5567 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 1212), "VarAdd: BSTR value %f, expected %f\n", r
, (double)1212);
5568 VariantClear(&result
);
5570 /* Manuly test some VT_CY and VT_DECIMAL variants */
5572 hres
= VarCyFromI4(4711, &V_CY(&cy
));
5573 ok(hres
== S_OK
, "VarCyFromI4 failed!\n");
5574 V_VT(&dec
) = VT_DECIMAL
;
5575 hres
= VarDecFromR8(-4.2, &V_DECIMAL(&dec
));
5576 ok(hres
== S_OK
, "VarDecFromR4 failed!\n");
5577 memset(&left
, 0, sizeof(left
));
5578 memset(&right
, 0, sizeof(right
));
5579 V_VT(&left
) = VT_I4
;
5581 V_VT(&right
) = VT_UI1
;
5584 hres
= pVarAdd(&cy
, &right
, &result
);
5585 ok(hres
== S_OK
&& V_VT(&result
) == VT_CY
, "VarAdd: expected coerced type VT_CY, got %s!\n", vtstr(V_VT(&result
)));
5586 hres
= VarR8FromCy(V_CY(&result
), &r
);
5587 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 4720), "VarAdd: CY value %f, expected %f\n", r
, (double)4720);
5589 hres
= pVarAdd(&left
, &dec
, &result
);
5590 ok(hres
== S_OK
&& V_VT(&result
) == VT_DECIMAL
, "VarAdd: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result
)));
5591 hres
= VarR8FromDec(&V_DECIMAL(&result
), &r
);
5592 ok(hres
== S_OK
&& EQ_DOUBLE(r
, -15.2), "VarAdd: DECIMAL value %f, expected %f\n", r
, (double)-15.2);
5593 VariantClear(&result
);
5595 SysFreeString(lbstr
);
5596 SysFreeString(rbstr
);
5599 static HRESULT (WINAPI
*pVarCmp
)(LPVARIANT
,LPVARIANT
,LCID
,ULONG
);
5600 static HRESULT (WINAPI
*pVarCat
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
5602 static void test_VarCat(void)
5605 VARIANT left
, right
, result
, expected
, expected_broken
;
5606 static const WCHAR sz34
[] = {'3','4','\0'};
5607 static const WCHAR sz1234
[] = {'1','2','3','4','\0'};
5608 static const WCHAR date_sz12
[] = {'9','/','3','0','/','1','9','8','0','1','2','\0'};
5609 static const WCHAR date_sz12_broken
[] = {'9','/','3','0','/','8','0','1','2','\0'};
5610 static const WCHAR sz12_date
[] = {'1','2','9','/','3','0','/','1','9','8','0','\0'};
5611 static const WCHAR sz12_date_broken
[] = {'1','2','9','/','3','0','/','8','0','\0'};
5612 static const WCHAR sz_empty
[] = {'\0'};
5613 CHAR orig_date_format
[128];
5614 VARTYPE leftvt
, rightvt
, resultvt
;
5616 HRESULT expected_error_num
;
5620 /* Set date format for testing */
5621 lcid
= LOCALE_USER_DEFAULT
;
5622 GetLocaleInfoA(lcid
,LOCALE_SSHORTDATE
,orig_date_format
,128);
5623 SetLocaleInfoA(lcid
,LOCALE_SSHORTDATE
,"M/d/yyyy");
5626 VariantInit(&right
);
5627 VariantInit(&result
);
5628 VariantInit(&expected
);
5630 /* Check expected types for all combinations */
5631 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
5636 /* Check if we need/have support for I8 and/or UI8 */
5637 if ((leftvt
== VT_I8
|| leftvt
== VT_UI8
) && !has_i8
)
5640 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
5644 expected_error_num
= S_OK
;
5645 resultvt
= VT_EMPTY
;
5647 if (leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
||
5648 leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
||
5649 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
||
5650 leftvt
== 15 || rightvt
== 15 /* Undefined type */)
5653 /* Check if we need/have support for I8 and/or UI8 */
5654 if ((rightvt
== VT_I8
|| rightvt
== VT_UI8
) && !has_i8
)
5657 if (leftvt
== VT_NULL
&& rightvt
== VT_NULL
)
5659 else if (leftvt
== VT_VARIANT
&& (rightvt
== VT_ERROR
||
5660 rightvt
== VT_DATE
|| rightvt
== VT_DECIMAL
))
5661 expected_error_num
= DISP_E_TYPEMISMATCH
;
5662 else if ((leftvt
== VT_I2
|| leftvt
== VT_I4
||
5663 leftvt
== VT_R4
|| leftvt
== VT_R8
||
5664 leftvt
== VT_CY
|| leftvt
== VT_BOOL
||
5665 leftvt
== VT_BSTR
|| leftvt
== VT_I1
||
5666 leftvt
== VT_UI1
|| leftvt
== VT_UI2
||
5667 leftvt
== VT_UI4
|| leftvt
== VT_I8
||
5668 leftvt
== VT_UI8
|| leftvt
== VT_INT
||
5669 leftvt
== VT_UINT
|| leftvt
== VT_EMPTY
||
5670 leftvt
== VT_NULL
|| leftvt
== VT_DECIMAL
||
5673 (rightvt
== VT_I2
|| rightvt
== VT_I4
||
5674 rightvt
== VT_R4
|| rightvt
== VT_R8
||
5675 rightvt
== VT_CY
|| rightvt
== VT_BOOL
||
5676 rightvt
== VT_BSTR
|| rightvt
== VT_I1
||
5677 rightvt
== VT_UI1
|| rightvt
== VT_UI2
||
5678 rightvt
== VT_UI4
|| rightvt
== VT_I8
||
5679 rightvt
== VT_UI8
|| rightvt
== VT_INT
||
5680 rightvt
== VT_UINT
|| rightvt
== VT_EMPTY
||
5681 rightvt
== VT_NULL
|| rightvt
== VT_DECIMAL
||
5682 rightvt
== VT_DATE
))
5684 else if (rightvt
== VT_ERROR
&& leftvt
< VT_VOID
)
5685 expected_error_num
= DISP_E_TYPEMISMATCH
;
5686 else if (leftvt
== VT_ERROR
&& (rightvt
== VT_DATE
||
5687 rightvt
== VT_ERROR
|| rightvt
== VT_DECIMAL
))
5688 expected_error_num
= DISP_E_TYPEMISMATCH
;
5689 else if (rightvt
== VT_DATE
|| rightvt
== VT_ERROR
||
5690 rightvt
== VT_DECIMAL
)
5691 expected_error_num
= DISP_E_BADVARTYPE
;
5692 else if (leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
)
5693 expected_error_num
= DISP_E_TYPEMISMATCH
;
5694 else if (leftvt
== VT_VARIANT
)
5695 expected_error_num
= DISP_E_TYPEMISMATCH
;
5696 else if (rightvt
== VT_VARIANT
&& (leftvt
== VT_EMPTY
||
5697 leftvt
== VT_NULL
|| leftvt
== VT_I2
||
5698 leftvt
== VT_I4
|| leftvt
== VT_R4
||
5699 leftvt
== VT_R8
|| leftvt
== VT_CY
||
5700 leftvt
== VT_DATE
|| leftvt
== VT_BSTR
||
5701 leftvt
== VT_BOOL
|| leftvt
== VT_DECIMAL
||
5702 leftvt
== VT_I1
|| leftvt
== VT_UI1
||
5703 leftvt
== VT_UI2
|| leftvt
== VT_UI4
||
5704 leftvt
== VT_I8
|| leftvt
== VT_UI8
||
5705 leftvt
== VT_INT
|| leftvt
== VT_UINT
5707 expected_error_num
= DISP_E_TYPEMISMATCH
;
5709 expected_error_num
= DISP_E_BADVARTYPE
;
5711 V_VT(&left
) = leftvt
;
5712 V_VT(&right
) = rightvt
;
5716 V_BSTR(&left
) = SysAllocString(sz_empty
); break;
5718 V_DATE(&left
) = 0.0; break;
5720 VarDecFromR8(0.0, &V_DECIMAL(&left
)); break;
5727 V_BSTR(&right
) = SysAllocString(sz_empty
); break;
5729 V_DATE(&right
) = 0.0; break;
5731 VarDecFromR8(0.0, &V_DECIMAL(&right
)); break;
5736 hres
= pVarCat(&left
, &right
, &result
);
5738 /* Determine the error code for the vt combination */
5739 ok(hres
== expected_error_num
,
5740 "VarCat: %d, %d returned error, 0x%X expected 0x%X.\n",
5741 leftvt
, rightvt
, hres
, expected_error_num
);
5743 /* Check types are correct */
5744 ok(V_VT(&result
) == resultvt
,
5745 "VarCat: %d, %d: expected vt %d, got vt %d\n",
5746 leftvt
, rightvt
, resultvt
, V_VT(&result
));
5748 VariantClear(&left
);
5749 VariantClear(&right
);
5750 VariantClear(&result
);
5754 /* Running single comparison tests to compare outputs */
5756 /* Test concat strings */
5757 V_VT(&left
) = VT_BSTR
;
5758 V_VT(&right
) = VT_BSTR
;
5759 V_VT(&expected
) = VT_BSTR
;
5760 V_BSTR(&left
) = SysAllocString(sz12
);
5761 V_BSTR(&right
) = SysAllocString(sz34
);
5762 V_BSTR(&expected
) = SysAllocString(sz1234
);
5763 hres
= pVarCat(&left
,&right
,&result
);
5764 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5766 ok(pVarCmp(&result
,&expected
,lcid
,0) == VARCMP_EQ
,
5767 "VarCat: VT_BSTR concat with VT_BSTR failed to return correct result\n");
5769 VariantClear(&left
);
5770 VariantClear(&right
);
5771 VariantClear(&result
);
5773 /* Test if expression is VT_ERROR */
5774 V_VT(&left
) = VT_ERROR
;
5775 V_VT(&right
) = VT_BSTR
;
5776 V_BSTR(&right
) = SysAllocString(sz1234
);
5777 hres
= pVarCat(&left
,&right
,&result
);
5778 ok(hres
== DISP_E_TYPEMISMATCH
, "VarCat should have returned DISP_E_TYPEMISMATCH instead of 0x%08x\n", hres
);
5779 ok(V_VT(&result
) == VT_EMPTY
,
5780 "VarCat: VT_ERROR concat with VT_BSTR should have returned VT_EMPTY\n");
5782 VariantClear(&left
);
5783 VariantClear(&right
);
5784 VariantClear(&result
);
5786 V_VT(&left
) = VT_BSTR
;
5787 V_VT(&right
) = VT_ERROR
;
5788 V_BSTR(&left
) = SysAllocString(sz1234
);
5789 hres
= pVarCat(&left
,&right
,&result
);
5790 ok(hres
== DISP_E_TYPEMISMATCH
, "VarCat should have returned DISP_E_TYPEMISMATCH instead of 0x%08x\n", hres
);
5791 ok(V_VT(&result
) == VT_EMPTY
,
5792 "VarCat: VT_BSTR concat with VT_ERROR should have returned VT_EMPTY\n");
5794 VariantClear(&left
);
5795 VariantClear(&right
);
5796 VariantClear(&result
);
5797 VariantClear(&expected
);
5799 /* Test combining boolean with number */
5800 V_VT(&left
) = VT_INT
;
5801 V_VT(&right
) = VT_BOOL
;
5802 V_VT(&expected
) = VT_BSTR
;
5804 V_BOOL(&right
) = TRUE
;
5805 V_BSTR(&expected
) = SysAllocString(sz12_true
);
5806 hres
= pVarCat(&left
,&right
,&result
);
5807 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5810 hres
= pVarCmp(&result
,&expected
,lcid
,0);
5811 ok(hres
== VARCMP_EQ
, "Expected VARCMP_EQ, got %08x for %s, %s\n",
5812 hres
, variantstr(&result
), variantstr(&expected
));
5815 VariantClear(&left
);
5816 VariantClear(&right
);
5817 VariantClear(&result
);
5818 VariantClear(&expected
);
5820 V_VT(&left
) = VT_INT
;
5821 V_VT(&right
) = VT_BOOL
;
5822 V_VT(&expected
) = VT_BSTR
;
5824 V_BOOL(&right
) = FALSE
;
5825 V_BSTR(&expected
) = SysAllocString(sz12_false
);
5826 hres
= pVarCat(&left
,&right
,&result
);
5827 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5830 hres
= pVarCmp(&result
,&expected
,lcid
,0);
5831 ok(hres
== VARCMP_EQ
, "Expected VARCMP_EQ, got %08x for %s, %s\n",
5832 hres
, variantstr(&result
), variantstr(&expected
));
5835 VariantClear(&left
);
5836 VariantClear(&right
);
5837 VariantClear(&result
);
5838 VariantClear(&expected
);
5840 /* Test when both expressions are numeric */
5841 V_VT(&left
) = VT_INT
;
5842 V_VT(&right
) = VT_INT
;
5843 V_VT(&expected
) = VT_BSTR
;
5846 V_BSTR(&expected
) = SysAllocString(sz1234
);
5847 hres
= pVarCat(&left
,&right
,&result
);
5848 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5850 ok(pVarCmp(&result
,&expected
,lcid
,0) == VARCMP_EQ
,
5851 "VarCat: NUMBER concat with NUMBER returned incorrect result\n");
5853 VariantClear(&left
);
5854 VariantClear(&right
);
5855 VariantClear(&result
);
5857 /* Test if one expression is numeric and the other is a string */
5858 V_VT(&left
) = VT_INT
;
5859 V_VT(&right
) = VT_BSTR
;
5861 V_BSTR(&right
) = SysAllocString(sz34
);
5862 hres
= pVarCat(&left
,&right
,&result
);
5863 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5865 ok(pVarCmp(&result
,&expected
,lcid
,0) == VARCMP_EQ
,
5866 "VarCat: NUMBER concat with VT_BSTR, incorrect result\n");
5868 VariantClear(&left
);
5869 VariantClear(&right
);
5870 VariantClear(&result
);
5872 V_VT(&left
) = VT_BSTR
;
5873 V_VT(&right
) = VT_INT
;
5874 V_BSTR(&left
) = SysAllocString(sz12
);
5876 hres
= pVarCat(&left
,&right
,&result
);
5877 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5879 ok(pVarCmp(&result
,&expected
,lcid
,0) == VARCMP_EQ
,
5880 "VarCat: VT_BSTR concat with NUMBER, incorrect result\n");
5882 VariantClear(&left
);
5883 VariantClear(&right
);
5884 VariantClear(&result
);
5885 VariantClear(&expected
);
5887 /* Test concat dates with strings */
5888 V_VT(&left
) = VT_BSTR
;
5889 V_VT(&right
) = VT_DATE
;
5890 V_VT(&expected
) = VT_BSTR
;
5891 V_VT(&expected_broken
) = VT_BSTR
;
5892 V_BSTR(&left
) = SysAllocString(sz12
);
5893 V_DATE(&right
) = 29494.0;
5894 V_BSTR(&expected
)= SysAllocString(sz12_date
);
5895 V_BSTR(&expected_broken
)= SysAllocString(sz12_date_broken
);
5896 hres
= pVarCat(&left
,&right
,&result
);
5897 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5899 ok(pVarCmp(&result
,&expected
,lcid
,0) == VARCMP_EQ
||
5900 broken(pVarCmp(&result
,&expected_broken
,lcid
,0) == VARCMP_EQ
), /* Some W98 and NT4 (intermittent) */
5901 "VarCat: VT_BSTR concat with VT_DATE returned incorrect result\n");
5903 VariantClear(&left
);
5904 VariantClear(&right
);
5905 VariantClear(&result
);
5906 VariantClear(&expected
);
5907 VariantClear(&expected_broken
);
5909 V_VT(&left
) = VT_DATE
;
5910 V_VT(&right
) = VT_BSTR
;
5911 V_VT(&expected
) = VT_BSTR
;
5912 V_VT(&expected_broken
) = VT_BSTR
;
5913 V_DATE(&left
) = 29494.0;
5914 V_BSTR(&right
) = SysAllocString(sz12
);
5915 V_BSTR(&expected
)= SysAllocString(date_sz12
);
5916 V_BSTR(&expected_broken
)= SysAllocString(date_sz12_broken
);
5917 hres
= pVarCat(&left
,&right
,&result
);
5918 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5920 ok(pVarCmp(&result
,&expected
,lcid
,0) == VARCMP_EQ
||
5921 broken(pVarCmp(&result
,&expected_broken
,lcid
,0) == VARCMP_EQ
), /* Some W98 and NT4 (intermittent) */
5922 "VarCat: VT_DATE concat with VT_BSTR returned incorrect result\n");
5924 VariantClear(&left
);
5925 VariantClear(&right
);
5926 VariantClear(&result
);
5927 VariantClear(&expected
);
5928 VariantClear(&expected_broken
);
5930 /* Test of both expressions are empty */
5931 V_VT(&left
) = VT_BSTR
;
5932 V_VT(&right
) = VT_BSTR
;
5933 V_VT(&expected
) = VT_BSTR
;
5934 V_BSTR(&left
) = SysAllocString(sz_empty
);
5935 V_BSTR(&right
) = SysAllocString(sz_empty
);
5936 V_BSTR(&expected
)= SysAllocString(sz_empty
);
5937 hres
= pVarCat(&left
,&right
,&result
);
5938 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5940 ok(pVarCmp(&result
,&left
,lcid
,0) == VARCMP_EQ
,
5941 "VarCat: EMPTY concat with EMPTY did not return empty VT_BSTR\n");
5943 /* Restore original date format settings */
5944 SetLocaleInfoA(lcid
,LOCALE_SSHORTDATE
,orig_date_format
);
5946 VariantClear(&left
);
5947 VariantClear(&right
);
5948 VariantClear(&result
);
5949 VariantClear(&expected
);
5951 /* Test boolean conversion */
5952 V_VT(&left
) = VT_BOOL
;
5953 V_BOOL(&left
) = VARIANT_TRUE
;
5954 V_VT(&right
) = VT_BSTR
;
5955 V_BSTR(&right
) = SysAllocStringLen(NULL
,0);
5956 hres
= pVarCat(&left
, &right
, &result
);
5957 ok(hres
== S_OK
, "VarCat failed: %08x\n", hres
);
5958 if(!strcmp_wa(V_BSTR(&result
), "True")) {
5959 V_VT(&right
) = VT_BOOL
;
5960 V_BOOL(&right
) = 100;
5961 hres
= pVarCat(&left
, &right
, &result
);
5962 ok(hres
== S_OK
, "VarCat failed: %08x\n", hres
);
5963 test_bstr_var(&result
, "TrueTrue");
5964 VariantClear(&result
);
5966 V_BOOL(&right
) = VARIANT_FALSE
;
5967 hres
= pVarCat(&left
, &right
, &result
);
5968 ok(hres
== S_OK
, "VarCat failed: %08x\n", hres
);
5969 test_bstr_var(&result
, "TrueFalse");
5970 VariantClear(&result
);
5972 skip("Got %s as True, assuming non-English locale\n", wine_dbgstr_w(V_BSTR(&result
)));
5976 static HRESULT (WINAPI
*pVarAnd
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
5978 #define VARAND(vt1,val1,vt2,val2,rvt,rval) \
5979 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
5980 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
5981 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
5982 test_var_call2( __LINE__, pVarAnd, &left, &right, &exp )
5984 #define VARANDCY(vt1,val1,val2,rvt,rval) \
5985 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
5986 V_VT(&right) = VT_CY; V_CY(&right).int64 = val2; \
5987 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
5988 test_var_call2( __LINE__, pVarAnd, &left, &right, &exp )
5990 /* Skip any type that is not defined or produces an error for every case */
5991 #define SKIPTESTAND(a) \
5992 if (a == VT_ERROR || a == VT_VARIANT || \
5993 a == VT_DISPATCH || a == VT_UNKNOWN || \
5994 a > VT_UINT || a == 15 /*not defined*/) \
5997 static void test_VarAnd(void)
5999 static const WCHAR szFalse
[] = { '#','F','A','L','S','E','#','\0' };
6000 static const WCHAR szTrue
[] = { '#','T','R','U','E','#','\0' };
6001 VARIANT left
, right
, exp
, result
;
6002 BSTR false_str
, true_str
;
6006 true_str
= SysAllocString(szTrue
);
6007 false_str
= SysAllocString(szFalse
);
6011 /* Test all possible flag/vt combinations & the resulting vt type */
6012 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
6014 VARTYPE leftvt
, rightvt
, resvt
;
6016 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
6018 SKIPTESTAND(leftvt
);
6020 /* Check if we need/have support for I8 and/or UI8 */
6021 if ((leftvt
== VT_I8
|| leftvt
== VT_UI8
) && !has_i8
)
6024 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
6027 SKIPTESTAND(rightvt
);
6029 /* Check if we need/have support for I8 and/or UI8 */
6030 if ((rightvt
== VT_I8
|| rightvt
== VT_UI8
) && !has_i8
)
6033 memset(&left
, 0, sizeof(left
));
6034 memset(&right
, 0, sizeof(right
));
6035 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
6036 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
6037 V_VT(&result
) = VT_EMPTY
;
6039 if ((leftvt
| ExtraFlags
[i
]) == VT_BSTR
)
6040 V_BSTR(&left
) = true_str
;
6041 if ((rightvt
| ExtraFlags
[i
]) == VT_BSTR
)
6042 V_BSTR(&right
) = true_str
;
6044 /* Native VarAnd always returns an error when using extra
6045 * flags or if the variant combination is I8 and INT.
6047 if ((leftvt
== VT_I8
&& rightvt
== VT_INT
) ||
6048 (leftvt
== VT_INT
&& rightvt
== VT_I8
) ||
6052 /* Determine return type */
6053 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
6055 else if (leftvt
== VT_I4
|| rightvt
== VT_I4
||
6056 leftvt
== VT_UINT
|| rightvt
== VT_UINT
||
6057 leftvt
== VT_INT
|| rightvt
== VT_INT
||
6058 leftvt
== VT_UINT
|| rightvt
== VT_UINT
||
6059 leftvt
== VT_R4
|| rightvt
== VT_R4
||
6060 leftvt
== VT_R8
|| rightvt
== VT_R8
||
6061 leftvt
== VT_CY
|| rightvt
== VT_CY
||
6062 leftvt
== VT_DATE
|| rightvt
== VT_DATE
||
6063 leftvt
== VT_I1
|| rightvt
== VT_I1
||
6064 leftvt
== VT_UI2
|| rightvt
== VT_UI2
||
6065 leftvt
== VT_UI4
|| rightvt
== VT_UI4
||
6066 leftvt
== VT_UI8
|| rightvt
== VT_UI8
||
6067 leftvt
== VT_DECIMAL
|| rightvt
== VT_DECIMAL
)
6069 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
||
6070 leftvt
== VT_I2
|| rightvt
== VT_I2
||
6071 leftvt
== VT_EMPTY
|| rightvt
== VT_EMPTY
)
6072 if ((leftvt
== VT_NULL
&& rightvt
== VT_UI1
) ||
6073 (leftvt
== VT_UI1
&& rightvt
== VT_NULL
) ||
6074 (leftvt
== VT_UI1
&& rightvt
== VT_UI1
))
6078 else if (leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
||
6079 (leftvt
== VT_BSTR
&& rightvt
== VT_BSTR
))
6081 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
||
6082 leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
)
6087 hres
= pVarAnd(&left
, &right
, &result
);
6089 /* Check expected HRESULT and if result variant type is correct */
6091 ok (hres
== DISP_E_BADVARTYPE
|| hres
== DISP_E_TYPEMISMATCH
,
6092 "VarAnd: %s|0x%X, %s|0x%X: got vt %s hr 0x%X\n",
6093 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
],
6094 vtstr(V_VT(&result
)), hres
);
6096 ok (hres
== S_OK
&& resvt
== V_VT(&result
),
6097 "VarAnd: %s|0x%X, %s|0x%X: expected vt %s hr 0x%X, got vt %s hr 0x%X\n",
6098 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
], vtstr(resvt
),
6099 S_OK
, vtstr(V_VT(&result
)), hres
);
6105 * Test returned values. Since we know the returned type is correct
6106 * and that we handle all combinations of invalid types, just check
6107 * that good type combinations produce the desired value.
6108 * FIXME: Test VT_DECIMAL
6110 VARAND(EMPTY
,0,EMPTY
,0,I2
,0);
6111 VARAND(EMPTY
,1,EMPTY
,0,I2
,0);
6112 VARAND(EMPTY
,1,EMPTY
,1,I2
,0);
6113 VARAND(EMPTY
,0,NULL
,0,I2
,0);
6114 VARAND(EMPTY
,1,NULL
,0,I2
,0);
6115 VARAND(EMPTY
,1,NULL
,1,I2
,0);
6116 VARAND(EMPTY
,0,I1
,0,I4
,0);
6117 VARAND(EMPTY
,0,I1
,1,I4
,0);
6118 VARAND(EMPTY
,1,I1
,1,I4
,0);
6119 VARAND(EMPTY
,0,UI1
,0,I2
,0);
6120 VARAND(EMPTY
,0,UI1
,1,I2
,0);
6121 VARAND(EMPTY
,1,UI1
,1,I2
,0);
6122 VARAND(EMPTY
,0,I2
,0,I2
,0);
6123 VARAND(EMPTY
,0,I2
,1,I2
,0);
6124 VARAND(EMPTY
,1,I2
,1,I2
,0);
6125 VARAND(EMPTY
,0,UI2
,0,I4
,0);
6126 VARAND(EMPTY
,0,UI2
,1,I4
,0);
6127 VARAND(EMPTY
,1,UI2
,1,I4
,0);
6128 VARAND(EMPTY
,0,I4
,0,I4
,0);
6129 VARAND(EMPTY
,0,I4
,1,I4
,0);
6130 VARAND(EMPTY
,1,I4
,1,I4
,0);
6131 VARAND(EMPTY
,0,UI4
,0,I4
,0);
6132 VARAND(EMPTY
,0,UI4
,1,I4
,0);
6133 VARAND(EMPTY
,1,UI4
,1,I4
,0);
6136 VARAND(EMPTY
,0,I8
,0,I8
,0);
6137 VARAND(EMPTY
,0,I8
,1,I8
,0);
6138 VARAND(EMPTY
,1,I8
,1,I8
,0);
6139 VARAND(EMPTY
,0,UI8
,0,I4
,0);
6140 VARAND(EMPTY
,0,UI8
,1,I4
,0);
6141 VARAND(EMPTY
,1,UI8
,1,I4
,0);
6143 VARAND(EMPTY
,0,INT
,0,I4
,0);
6144 VARAND(EMPTY
,0,INT
,1,I4
,0);
6145 VARAND(EMPTY
,1,INT
,1,I4
,0);
6146 VARAND(EMPTY
,0,UINT
,0,I4
,0);
6147 VARAND(EMPTY
,0,UINT
,1,I4
,0);
6148 VARAND(EMPTY
,1,UINT
,1,I4
,0);
6149 VARAND(EMPTY
,0,BOOL
,0,I2
,0);
6150 VARAND(EMPTY
,0,BOOL
,1,I2
,0);
6151 VARAND(EMPTY
,1,BOOL
,1,I2
,0);
6152 VARAND(EMPTY
,0,R4
,0,I4
,0);
6153 VARAND(EMPTY
,0,R4
,1,I4
,0);
6154 VARAND(EMPTY
,1,R4
,1,I4
,0);
6155 VARAND(EMPTY
,0,R8
,0,I4
,0);
6156 VARAND(EMPTY
,0,R8
,1,I4
,0);
6157 VARAND(EMPTY
,1,R8
,1,I4
,0);
6158 VARAND(EMPTY
,0,BSTR
,false_str
,I2
,0);
6159 VARAND(EMPTY
,0,BSTR
,true_str
,I2
,0);
6160 VARANDCY(EMPTY
,0,10000,I4
,0);
6162 /* NULL OR 0 = NULL. NULL OR n = n */
6163 VARAND(NULL
,0,NULL
,0,NULL
,0);
6164 VARAND(NULL
,1,NULL
,0,NULL
,0);
6165 VARAND(NULL
,0,I1
,0,I4
,0);
6166 VARAND(NULL
,0,I1
,1,NULL
,0);
6167 VARAND(NULL
,0,UI1
,0,UI1
,0);
6168 VARAND(NULL
,0,UI1
,1,NULL
,0);
6169 VARAND(NULL
,0,I2
,0,I2
,0);
6170 VARAND(NULL
,0,I2
,1,NULL
,0);
6171 VARAND(NULL
,0,UI2
,0,I4
,0);
6172 VARAND(NULL
,0,UI2
,1,NULL
,0);
6173 VARAND(NULL
,0,I4
,0,I4
,0);
6174 VARAND(NULL
,0,I4
,1,NULL
,0);
6175 VARAND(NULL
,0,UI4
,0,I4
,0);
6176 VARAND(NULL
,0,UI4
,1,NULL
,0);
6179 VARAND(NULL
,0,I8
,0,I8
,0);
6180 VARAND(NULL
,0,I8
,1,NULL
,0);
6181 VARAND(NULL
,0,UI8
,0,I4
,0);
6182 VARAND(NULL
,0,UI8
,1,NULL
,0);
6184 VARAND(NULL
,0,INT
,0,I4
,0);
6185 VARAND(NULL
,0,INT
,1,NULL
,0);
6186 VARAND(NULL
,0,UINT
,0,I4
,0);
6187 VARAND(NULL
,0,UINT
,1,NULL
,0);
6188 VARAND(NULL
,0,BOOL
,0,BOOL
,0);
6189 VARAND(NULL
,0,BOOL
,1,NULL
,0);
6190 VARAND(NULL
,0,R4
,0,I4
,0);
6191 VARAND(NULL
,0,R4
,1,NULL
,0);
6192 VARAND(NULL
,0,R8
,0,I4
,0);
6193 VARAND(NULL
,0,R8
,1,NULL
,0);
6194 VARAND(NULL
,0,BSTR
,false_str
,BOOL
,0);
6195 VARAND(NULL
,0,BSTR
,true_str
,NULL
,VARIANT_FALSE
);
6196 VARANDCY(NULL
,0,10000,NULL
,0);
6197 VARANDCY(NULL
,0,0,I4
,0);
6198 VARAND(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
);
6199 VARAND(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_FALSE
);
6200 VARAND(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
);
6201 VARAND(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_FALSE
);
6203 /* Assume x,y & y,x are the same from now on to reduce the number of tests */
6204 VARAND(BOOL
,VARIANT_TRUE
,I1
,-1,I4
,-1);
6205 VARAND(BOOL
,VARIANT_TRUE
,I1
,0,I4
,0);
6206 VARAND(BOOL
,VARIANT_FALSE
,I1
,0,I4
,0);
6207 VARAND(BOOL
,VARIANT_TRUE
,UI1
,255,I2
,255);
6208 VARAND(BOOL
,VARIANT_TRUE
,UI1
,0,I2
,0);
6209 VARAND(BOOL
,VARIANT_FALSE
,UI1
,0,I2
,0);
6210 VARAND(BOOL
,VARIANT_TRUE
,I2
,-1,I2
,-1);
6211 VARAND(BOOL
,VARIANT_TRUE
,I2
,0,I2
,0);
6212 VARAND(BOOL
,VARIANT_FALSE
,I2
,0,I2
,0);
6213 VARAND(BOOL
,VARIANT_TRUE
,UI2
,65535,I4
,65535);
6214 VARAND(BOOL
,VARIANT_TRUE
,UI2
,0,I4
,0);
6215 VARAND(BOOL
,VARIANT_FALSE
,UI2
,0,I4
,0);
6216 VARAND(BOOL
,VARIANT_TRUE
,I4
,-1,I4
,-1);
6217 VARAND(BOOL
,VARIANT_TRUE
,I4
,0,I4
,0);
6218 VARAND(BOOL
,VARIANT_FALSE
,I4
,0,I4
,0);
6219 VARAND(BOOL
,VARIANT_TRUE
,UI4
,0xffffffff,I4
,-1);
6220 VARAND(BOOL
,VARIANT_TRUE
,UI4
,0,I4
,0);
6221 VARAND(BOOL
,VARIANT_FALSE
,UI4
,0,I4
,0);
6222 VARAND(BOOL
,VARIANT_TRUE
,R4
,-1,I4
,-1);
6223 VARAND(BOOL
,VARIANT_TRUE
,R4
,0,I4
,0);
6224 VARAND(BOOL
,VARIANT_FALSE
,R4
,0,I4
,0);
6225 VARAND(BOOL
,VARIANT_TRUE
,R8
,-1,I4
,-1);
6226 VARAND(BOOL
,VARIANT_TRUE
,R8
,0,I4
,0);
6227 VARAND(BOOL
,VARIANT_FALSE
,R8
,0,I4
,0);
6228 VARAND(BOOL
,VARIANT_TRUE
,DATE
,-1,I4
,-1);
6229 VARAND(BOOL
,VARIANT_TRUE
,DATE
,0,I4
,0);
6230 VARAND(BOOL
,VARIANT_FALSE
,DATE
,0,I4
,0);
6233 VARAND(BOOL
,VARIANT_TRUE
,I8
,-1,I8
,-1);
6234 VARAND(BOOL
,VARIANT_TRUE
,I8
,0,I8
,0);
6235 VARAND(BOOL
,VARIANT_FALSE
,I8
,0,I8
,0);
6236 VARAND(BOOL
,VARIANT_TRUE
,UI8
,0,I4
,0);
6237 VARAND(BOOL
,VARIANT_FALSE
,UI8
,0,I4
,0);
6239 VARAND(BOOL
,VARIANT_TRUE
,INT
,-1,I4
,-1);
6240 VARAND(BOOL
,VARIANT_TRUE
,INT
,0,I4
,0);
6241 VARAND(BOOL
,VARIANT_FALSE
,INT
,0,I4
,0);
6242 VARAND(BOOL
,VARIANT_TRUE
,UINT
,0xffffffff,I4
,-1);
6243 VARAND(BOOL
,VARIANT_TRUE
,UINT
,0,I4
,0);
6244 VARAND(BOOL
,VARIANT_FALSE
,UINT
,0,I4
,0);
6245 VARAND(BOOL
,VARIANT_FALSE
,BSTR
,false_str
,BOOL
,VARIANT_FALSE
);
6246 VARAND(BOOL
,VARIANT_TRUE
,BSTR
,false_str
,BOOL
,VARIANT_FALSE
);
6247 VARAND(BOOL
,VARIANT_FALSE
,BSTR
,true_str
,BOOL
,VARIANT_FALSE
);
6248 VARAND(BOOL
,VARIANT_TRUE
,BSTR
,true_str
,BOOL
,VARIANT_TRUE
);
6249 VARANDCY(BOOL
,VARIANT_TRUE
,10000,I4
,1);
6250 VARANDCY(BOOL
,VARIANT_TRUE
,0,I4
,0);
6251 VARANDCY(BOOL
,VARIANT_FALSE
,0,I4
,0);
6252 VARAND(I1
,-1,I1
,-1,I4
,-1);
6253 VARAND(I1
,-1,I1
,0,I4
,0);
6254 VARAND(I1
,0,I1
,0,I4
,0);
6255 VARAND(I1
,-1,UI1
,255,I4
,255);
6256 VARAND(I1
,-1,UI1
,0,I4
,0);
6257 VARAND(I1
,0,UI1
,0,I4
,0);
6258 VARAND(I1
,-1,I2
,-1,I4
,-1);
6259 VARAND(I1
,-1,I2
,0,I4
,0);
6260 VARAND(I1
,0,I2
,0,I4
,0);
6261 VARAND(I1
,-1,UI2
,65535,I4
,65535);
6262 VARAND(I1
,-1,UI2
,0,I4
,0);
6263 VARAND(I1
,0,UI2
,0,I4
,0);
6264 VARAND(I1
,-1,I4
,-1,I4
,-1);
6265 VARAND(I1
,-1,I4
,0,I4
,0);
6266 VARAND(I1
,0,I4
,0,I4
,0);
6267 VARAND(I1
,-1,UI4
,0xffffffff,I4
,-1);
6268 VARAND(I1
,-1,UI4
,0,I4
,0);
6269 VARAND(I1
,0,UI4
,0,I4
,0);
6270 VARAND(I1
,-1,R4
,-1,I4
,-1);
6271 VARAND(I1
,-1,R4
,0,I4
,0);
6272 VARAND(I1
,0,R4
,0,I4
,0);
6273 VARAND(I1
,-1,R8
,-1,I4
,-1);
6274 VARAND(I1
,-1,R8
,0,I4
,0);
6275 VARAND(I1
,0,R8
,0,I4
,0);
6276 VARAND(I1
,-1,DATE
,-1,I4
,-1);
6277 VARAND(I1
,-1,DATE
,0,I4
,0);
6278 VARAND(I1
,0,DATE
,0,I4
,0);
6281 VARAND(I1
,-1,I8
,-1,I8
,-1);
6282 VARAND(I1
,-1,I8
,0,I8
,0);
6283 VARAND(I1
,0,I8
,0,I8
,0);
6284 VARAND(I1
,-1,UI8
,0,I4
,0);
6285 VARAND(I1
,0,UI8
,0,I4
,0);
6287 VARAND(I1
,-1,INT
,-1,I4
,-1);
6288 VARAND(I1
,-1,INT
,0,I4
,0);
6289 VARAND(I1
,0,INT
,0,I4
,0);
6290 VARAND(I1
,-1,UINT
,0xffffffff,I4
,-1);
6291 VARAND(I1
,-1,UINT
,0,I4
,0);
6292 VARAND(I1
,0,UINT
,0,I4
,0);
6293 VARAND(I1
,0,BSTR
,false_str
,I4
,0);
6294 VARAND(I1
,-1,BSTR
,false_str
,I4
,0);
6295 VARAND(I1
,0,BSTR
,true_str
,I4
,0);
6296 VARAND(I1
,-1,BSTR
,true_str
,I4
,-1);
6297 VARANDCY(I1
,-1,10000,I4
,1);
6298 VARANDCY(I1
,-1,0,I4
,0);
6299 VARANDCY(I1
,0,0,I4
,0);
6301 VARAND(UI1
,255,UI1
,255,UI1
,255);
6302 VARAND(UI1
,255,UI1
,0,UI1
,0);
6303 VARAND(UI1
,0,UI1
,0,UI1
,0);
6304 VARAND(UI1
,255,I2
,-1,I2
,255);
6305 VARAND(UI1
,255,I2
,0,I2
,0);
6306 VARAND(UI1
,0,I2
,0,I2
,0);
6307 VARAND(UI1
,255,UI2
,65535,I4
,255);
6308 VARAND(UI1
,255,UI2
,0,I4
,0);
6309 VARAND(UI1
,0,UI2
,0,I4
,0);
6310 VARAND(UI1
,255,I4
,-1,I4
,255);
6311 VARAND(UI1
,255,I4
,0,I4
,0);
6312 VARAND(UI1
,0,I4
,0,I4
,0);
6313 VARAND(UI1
,255,UI4
,0xffffffff,I4
,255);
6314 VARAND(UI1
,255,UI4
,0,I4
,0);
6315 VARAND(UI1
,0,UI4
,0,I4
,0);
6316 VARAND(UI1
,255,R4
,-1,I4
,255);
6317 VARAND(UI1
,255,R4
,0,I4
,0);
6318 VARAND(UI1
,0,R4
,0,I4
,0);
6319 VARAND(UI1
,255,R8
,-1,I4
,255);
6320 VARAND(UI1
,255,R8
,0,I4
,0);
6321 VARAND(UI1
,0,R8
,0,I4
,0);
6322 VARAND(UI1
,255,DATE
,-1,I4
,255);
6323 VARAND(UI1
,255,DATE
,0,I4
,0);
6324 VARAND(UI1
,0,DATE
,0,I4
,0);
6327 VARAND(UI1
,255,I8
,-1,I8
,255);
6328 VARAND(UI1
,255,I8
,0,I8
,0);
6329 VARAND(UI1
,0,I8
,0,I8
,0);
6330 VARAND(UI1
,255,UI8
,0,I4
,0);
6331 VARAND(UI1
,0,UI8
,0,I4
,0);
6333 VARAND(UI1
,255,INT
,-1,I4
,255);
6334 VARAND(UI1
,255,INT
,0,I4
,0);
6335 VARAND(UI1
,0,INT
,0,I4
,0);
6336 VARAND(UI1
,255,UINT
,0xffffffff,I4
,255);
6337 VARAND(UI1
,255,UINT
,0,I4
,0);
6338 VARAND(UI1
,0,UINT
,0,I4
,0);
6339 VARAND(UI1
,0,BSTR
,false_str
,I2
,0);
6340 VARAND(UI1
,255,BSTR
,false_str
,I2
,0);
6341 VARAND(UI1
,0,BSTR
,true_str
,I2
,0);
6342 VARAND(UI1
,255,BSTR
,true_str
,I2
,255);
6343 VARANDCY(UI1
,255,10000,I4
,1);
6344 VARANDCY(UI1
,255,0,I4
,0);
6345 VARANDCY(UI1
,0,0,I4
,0);
6347 VARAND(I2
,-1,I2
,-1,I2
,-1);
6348 VARAND(I2
,-1,I2
,0,I2
,0);
6349 VARAND(I2
,0,I2
,0,I2
,0);
6350 VARAND(I2
,-1,UI2
,65535,I4
,65535);
6351 VARAND(I2
,-1,UI2
,0,I4
,0);
6352 VARAND(I2
,0,UI2
,0,I4
,0);
6353 VARAND(I2
,-1,I4
,-1,I4
,-1);
6354 VARAND(I2
,-1,I4
,0,I4
,0);
6355 VARAND(I2
,0,I4
,0,I4
,0);
6356 VARAND(I2
,-1,UI4
,0xffffffff,I4
,-1);
6357 VARAND(I2
,-1,UI4
,0,I4
,0);
6358 VARAND(I2
,0,UI4
,0,I4
,0);
6359 VARAND(I2
,-1,R4
,-1,I4
,-1);
6360 VARAND(I2
,-1,R4
,0,I4
,0);
6361 VARAND(I2
,0,R4
,0,I4
,0);
6362 VARAND(I2
,-1,R8
,-1,I4
,-1);
6363 VARAND(I2
,-1,R8
,0,I4
,0);
6364 VARAND(I2
,0,R8
,0,I4
,0);
6365 VARAND(I2
,-1,DATE
,-1,I4
,-1);
6366 VARAND(I2
,-1,DATE
,0,I4
,0);
6367 VARAND(I2
,0,DATE
,0,I4
,0);
6370 VARAND(I2
,-1,I8
,-1,I8
,-1);
6371 VARAND(I2
,-1,I8
,0,I8
,0);
6372 VARAND(I2
,0,I8
,0,I8
,0);
6373 VARAND(I2
,-1,UI8
,0,I4
,0);
6374 VARAND(I2
,0,UI8
,0,I4
,0);
6376 VARAND(I2
,-1,INT
,-1,I4
,-1);
6377 VARAND(I2
,-1,INT
,0,I4
,0);
6378 VARAND(I2
,0,INT
,0,I4
,0);
6379 VARAND(I2
,-1,UINT
,0xffffffff,I4
,-1);
6380 VARAND(I2
,-1,UINT
,0,I4
,0);
6381 VARAND(I2
,0,UINT
,0,I4
,0);
6382 VARAND(I2
,0,BSTR
,false_str
,I2
,0);
6383 VARAND(I2
,-1,BSTR
,false_str
,I2
,0);
6384 VARAND(I2
,0,BSTR
,true_str
,I2
,0);
6385 VARAND(I2
,-1,BSTR
,true_str
,I2
,-1);
6386 VARANDCY(I2
,-1,10000,I4
,1);
6387 VARANDCY(I2
,-1,0,I4
,0);
6388 VARANDCY(I2
,0,0,I4
,0);
6390 VARAND(UI2
,65535,UI2
,65535,I4
,65535);
6391 VARAND(UI2
,65535,UI2
,0,I4
,0);
6392 VARAND(UI2
,0,UI2
,0,I4
,0);
6393 VARAND(UI2
,65535,I4
,-1,I4
,65535);
6394 VARAND(UI2
,65535,I4
,0,I4
,0);
6395 VARAND(UI2
,0,I4
,0,I4
,0);
6396 VARAND(UI2
,65535,UI4
,0xffffffff,I4
,65535);
6397 VARAND(UI2
,65535,UI4
,0,I4
,0);
6398 VARAND(UI2
,0,UI4
,0,I4
,0);
6399 VARAND(UI2
,65535,R4
,-1,I4
,65535);
6400 VARAND(UI2
,65535,R4
,0,I4
,0);
6401 VARAND(UI2
,0,R4
,0,I4
,0);
6402 VARAND(UI2
,65535,R8
,-1,I4
,65535);
6403 VARAND(UI2
,65535,R8
,0,I4
,0);
6404 VARAND(UI2
,0,R8
,0,I4
,0);
6405 VARAND(UI2
,65535,DATE
,-1,I4
,65535);
6406 VARAND(UI2
,65535,DATE
,0,I4
,0);
6407 VARAND(UI2
,0,DATE
,0,I4
,0);
6410 VARAND(UI2
,65535,I8
,-1,I8
,65535);
6411 VARAND(UI2
,65535,I8
,0,I8
,0);
6412 VARAND(UI2
,0,I8
,0,I8
,0);
6413 VARAND(UI2
,65535,UI8
,0,I4
,0);
6414 VARAND(UI2
,0,UI8
,0,I4
,0);
6416 VARAND(UI2
,65535,INT
,-1,I4
,65535);
6417 VARAND(UI2
,65535,INT
,0,I4
,0);
6418 VARAND(UI2
,0,INT
,0,I4
,0);
6419 VARAND(UI2
,65535,UINT
,0xffffffff,I4
,65535);
6420 VARAND(UI2
,65535,UINT
,0,I4
,0);
6421 VARAND(UI2
,0,UINT
,0,I4
,0);
6422 VARAND(UI2
,0,BSTR
,false_str
,I4
,0);
6423 VARAND(UI2
,65535,BSTR
,false_str
,I4
,0);
6424 VARAND(UI2
,0,BSTR
,true_str
,I4
,0);
6425 VARAND(UI2
,65535,BSTR
,true_str
,I4
,65535);
6426 VARANDCY(UI2
,65535,10000,I4
,1);
6427 VARANDCY(UI2
,65535,0,I4
,0);
6428 VARANDCY(UI2
,0,0,I4
,0);
6430 VARAND(I4
,-1,I4
,-1,I4
,-1);
6431 VARAND(I4
,-1,I4
,0,I4
,0);
6432 VARAND(I4
,0,I4
,0,I4
,0);
6433 VARAND(I4
,-1,UI4
,0xffffffff,I4
,-1);
6434 VARAND(I4
,-1,UI4
,0,I4
,0);
6435 VARAND(I4
,0,UI4
,0,I4
,0);
6436 VARAND(I4
,-1,R4
,-1,I4
,-1);
6437 VARAND(I4
,-1,R4
,0,I4
,0);
6438 VARAND(I4
,0,R4
,0,I4
,0);
6439 VARAND(I4
,-1,R8
,-1,I4
,-1);
6440 VARAND(I4
,-1,R8
,0,I4
,0);
6441 VARAND(I4
,0,R8
,0,I4
,0);
6442 VARAND(I4
,-1,DATE
,-1,I4
,-1);
6443 VARAND(I4
,-1,DATE
,0,I4
,0);
6444 VARAND(I4
,0,DATE
,0,I4
,0);
6447 VARAND(I4
,-1,I8
,-1,I8
,-1);
6448 VARAND(I4
,-1,I8
,0,I8
,0);
6449 VARAND(I4
,0,I8
,0,I8
,0);
6450 VARAND(I4
,-1,UI8
,0,I4
,0);
6451 VARAND(I4
,0,UI8
,0,I4
,0);
6453 VARAND(I4
,-1,INT
,-1,I4
,-1);
6454 VARAND(I4
,-1,INT
,0,I4
,0);
6455 VARAND(I4
,0,INT
,0,I4
,0);
6456 VARAND(I4
,-1,UINT
,0xffffffff,I4
,-1);
6457 VARAND(I4
,-1,UINT
,0,I4
,0);
6458 VARAND(I4
,0,UINT
,0,I4
,0);
6459 VARAND(I4
,0,BSTR
,false_str
,I4
,0);
6460 VARAND(I4
,-1,BSTR
,false_str
,I4
,0);
6461 VARAND(I4
,0,BSTR
,true_str
,I4
,0);
6462 VARAND(I4
,-1,BSTR
,true_str
,I4
,-1);
6463 VARANDCY(I4
,-1,10000,I4
,1);
6464 VARANDCY(I4
,-1,0,I4
,0);
6465 VARANDCY(I4
,0,0,I4
,0);
6467 VARAND(UI4
,0xffffffff,UI4
,0xffffffff,I4
,-1);
6468 VARAND(UI4
,0xffffffff,UI4
,0,I4
,0);
6469 VARAND(UI4
,0,UI4
,0,I4
,0);
6470 VARAND(UI4
,0xffffffff,R4
,-1,I4
,-1);
6471 VARAND(UI4
,0xffffffff,R4
,0,I4
,0);
6472 VARAND(UI4
,0,R4
,0,I4
,0);
6473 VARAND(UI4
,0xffffffff,R8
,-1,I4
,-1);
6474 VARAND(UI4
,0xffffffff,R8
,0,I4
,0);
6475 VARAND(UI4
,0,R8
,0,I4
,0);
6476 VARAND(UI4
,0xffffffff,DATE
,-1,I4
,-1);
6477 VARAND(UI4
,0xffffffff,DATE
,0,I4
,0);
6478 VARAND(UI4
,0,DATE
,0,I4
,0);
6481 VARAND(UI4
,0xffffffff,I8
,0,I8
,0);
6482 VARAND(UI4
,0,I8
,0,I8
,0);
6483 VARAND(UI4
,0xffffffff,UI8
,0,I4
,0);
6484 VARAND(UI4
,0,UI8
,0,I4
,0);
6486 VARAND(UI4
,0xffffffff,INT
,-1,I4
,-1);
6487 VARAND(UI4
,0xffffffff,INT
,0,I4
,0);
6488 VARAND(UI4
,0,INT
,0,I4
,0);
6489 VARAND(UI4
,0xffffffff,UINT
,0xffffffff,I4
,-1);
6490 VARAND(UI4
,0xffffffff,UINT
,0,I4
,0);
6491 VARAND(UI4
,0,UINT
,0,I4
,0);
6492 VARAND(UI4
,0,BSTR
,false_str
,I4
,0);
6493 VARAND(UI4
,0xffffffff,BSTR
,false_str
,I4
,0);
6494 VARAND(UI4
,0,BSTR
,true_str
,I4
,0);
6495 VARAND(UI4
,0xffffffff,BSTR
,true_str
,I4
,-1);
6496 VARANDCY(UI4
,0xffffffff,10000,I4
,1);
6497 VARANDCY(UI4
,0xffffffff,0,I4
,0);
6498 VARANDCY(UI4
,0,0,I4
,0);
6500 VARAND(R4
,-1,R4
,-1,I4
,-1);
6501 VARAND(R4
,-1,R4
,0,I4
,0);
6502 VARAND(R4
,0,R4
,0,I4
,0);
6503 VARAND(R4
,-1,R8
,-1,I4
,-1);
6504 VARAND(R4
,-1,R8
,0,I4
,0);
6505 VARAND(R4
,0,R8
,0,I4
,0);
6506 VARAND(R4
,-1,DATE
,-1,I4
,-1);
6507 VARAND(R4
,-1,DATE
,0,I4
,0);
6508 VARAND(R4
,0,DATE
,0,I4
,0);
6511 VARAND(R4
,-1,I8
,-1,I8
,-1);
6512 VARAND(R4
,-1,I8
,0,I8
,0);
6513 VARAND(R4
,0,I8
,0,I8
,0);
6514 VARAND(R4
,-1,UI8
,0,I4
,0);
6515 VARAND(R4
,0,UI8
,0,I4
,0);
6517 VARAND(R4
,-1,INT
,-1,I4
,-1);
6518 VARAND(R4
,-1,INT
,0,I4
,0);
6519 VARAND(R4
,0,INT
,0,I4
,0);
6520 VARAND(R4
,-1,UINT
,0xffffffff,I4
,-1);
6521 VARAND(R4
,-1,UINT
,0,I4
,0);
6522 VARAND(R4
,0,UINT
,0,I4
,0);
6523 VARAND(R4
,0,BSTR
,false_str
,I4
,0);
6524 VARAND(R4
,-1,BSTR
,false_str
,I4
,0);
6525 VARAND(R4
,0,BSTR
,true_str
,I4
,0);
6526 VARAND(R4
,-1,BSTR
,true_str
,I4
,-1);
6527 VARANDCY(R4
,-1,10000,I4
,1);
6528 VARANDCY(R4
,-1,0,I4
,0);
6529 VARANDCY(R4
,0,0,I4
,0);
6531 VARAND(R8
,-1,R8
,-1,I4
,-1);
6532 VARAND(R8
,-1,R8
,0,I4
,0);
6533 VARAND(R8
,0,R8
,0,I4
,0);
6534 VARAND(R8
,-1,DATE
,-1,I4
,-1);
6535 VARAND(R8
,-1,DATE
,0,I4
,0);
6536 VARAND(R8
,0,DATE
,0,I4
,0);
6539 VARAND(R8
,-1,I8
,-1,I8
,-1);
6540 VARAND(R8
,-1,I8
,0,I8
,0);
6541 VARAND(R8
,0,I8
,0,I8
,0);
6542 VARAND(R8
,-1,UI8
,0,I4
,0);
6543 VARAND(R8
,0,UI8
,0,I4
,0);
6545 VARAND(R8
,-1,INT
,-1,I4
,-1);
6546 VARAND(R8
,-1,INT
,0,I4
,0);
6547 VARAND(R8
,0,INT
,0,I4
,0);
6548 VARAND(R8
,-1,UINT
,0xffffffff,I4
,-1);
6549 VARAND(R8
,-1,UINT
,0,I4
,0);
6550 VARAND(R8
,0,UINT
,0,I4
,0);
6551 VARAND(R8
,0,BSTR
,false_str
,I4
,0);
6552 VARAND(R8
,-1,BSTR
,false_str
,I4
,0);
6553 VARAND(R8
,0,BSTR
,true_str
,I4
,0);
6554 VARAND(R8
,-1,BSTR
,true_str
,I4
,-1);
6555 VARANDCY(R8
,-1,10000,I4
,1);
6556 VARANDCY(R8
,-1,0,I4
,0);
6557 VARANDCY(R8
,0,0,I4
,0);
6559 VARAND(DATE
,-1,DATE
,-1,I4
,-1);
6560 VARAND(DATE
,-1,DATE
,0,I4
,0);
6561 VARAND(DATE
,0,DATE
,0,I4
,0);
6564 VARAND(DATE
,-1,I8
,-1,I8
,-1);
6565 VARAND(DATE
,-1,I8
,0,I8
,0);
6566 VARAND(DATE
,0,I8
,0,I8
,0);
6567 VARAND(DATE
,-1,UI8
,0,I4
,0);
6568 VARAND(DATE
,0,UI8
,0,I4
,0);
6570 VARAND(DATE
,-1,INT
,-1,I4
,-1);
6571 VARAND(DATE
,-1,INT
,0,I4
,0);
6572 VARAND(DATE
,0,INT
,0,I4
,0);
6573 VARAND(DATE
,-1,UINT
,0xffffffff,I4
,-1);
6574 VARAND(DATE
,-1,UINT
,0,I4
,0);
6575 VARAND(DATE
,0,UINT
,0,I4
,0);
6576 VARAND(DATE
,0,BSTR
,false_str
,I4
,0);
6577 VARAND(DATE
,-1,BSTR
,false_str
,I4
,0);
6578 VARAND(DATE
,0,BSTR
,true_str
,I4
,0);
6579 VARAND(DATE
,-1,BSTR
,true_str
,I4
,-1);
6580 VARANDCY(DATE
,-1,10000,I4
,1);
6581 VARANDCY(DATE
,-1,0,I4
,0);
6582 VARANDCY(DATE
,0,0,I4
,0);
6586 VARAND(I8
,-1,I8
,-1,I8
,-1);
6587 VARAND(I8
,-1,I8
,0,I8
,0);
6588 VARAND(I8
,0,I8
,0,I8
,0);
6589 VARAND(I8
,-1,UI8
,0,I8
,0);
6590 VARAND(I8
,0,UI8
,0,I8
,0);
6591 VARAND(I8
,-1,UINT
,0,I8
,0);
6592 VARAND(I8
,0,UINT
,0,I8
,0);
6593 VARAND(I8
,0,BSTR
,false_str
,I8
,0);
6594 VARAND(I8
,-1,BSTR
,false_str
,I8
,0);
6595 VARAND(I8
,0,BSTR
,true_str
,I8
,0);
6596 VARAND(I8
,-1,BSTR
,true_str
,I8
,-1);
6597 VARANDCY(I8
,-1,10000,I8
,1);
6598 VARANDCY(I8
,-1,0,I8
,0);
6599 VARANDCY(I8
,0,0,I8
,0);
6601 VARAND(UI8
,0xffff,UI8
,0xffff,I4
,0xffff);
6602 VARAND(UI8
,0xffff,UI8
,0,I4
,0);
6603 VARAND(UI8
,0,UI8
,0,I4
,0);
6604 VARAND(UI8
,0xffff,INT
,-1,I4
,65535);
6605 VARAND(UI8
,0xffff,INT
,0,I4
,0);
6606 VARAND(UI8
,0,INT
,0,I4
,0);
6607 VARAND(UI8
,0xffff,UINT
,0xffff,I4
,0xffff);
6608 VARAND(UI8
,0xffff,UINT
,0,I4
,0);
6609 VARAND(UI8
,0,UINT
,0,I4
,0);
6610 VARAND(UI8
,0,BSTR
,false_str
,I4
,0);
6611 VARAND(UI8
,0xffff,BSTR
,false_str
,I4
,0);
6612 VARAND(UI8
,0,BSTR
,true_str
,I4
,0);
6613 VARAND(UI8
,0xffff,BSTR
,true_str
,I4
,65535);
6614 VARANDCY(UI8
,0xffff,10000,I4
,1);
6615 VARANDCY(UI8
,0xffff,0,I4
,0);
6616 VARANDCY(UI8
,0,0,I4
,0);
6619 VARAND(INT
,-1,INT
,-1,I4
,-1);
6620 VARAND(INT
,-1,INT
,0,I4
,0);
6621 VARAND(INT
,0,INT
,0,I4
,0);
6622 VARAND(INT
,-1,UINT
,0xffff,I4
,65535);
6623 VARAND(INT
,-1,UINT
,0,I4
,0);
6624 VARAND(INT
,0,UINT
,0,I4
,0);
6625 VARAND(INT
,0,BSTR
,false_str
,I4
,0);
6626 VARAND(INT
,-1,BSTR
,false_str
,I4
,0);
6627 VARAND(INT
,0,BSTR
,true_str
,I4
,0);
6628 VARAND(INT
,-1,BSTR
,true_str
,I4
,-1);
6629 VARANDCY(INT
,-1,10000,I4
,1);
6630 VARANDCY(INT
,-1,0,I4
,0);
6631 VARANDCY(INT
,0,0,I4
,0);
6633 VARAND(UINT
,0xffff,UINT
,0xffff,I4
,0xffff);
6634 VARAND(UINT
,0xffff,UINT
,0,I4
,0);
6635 VARAND(UINT
,0,UINT
,0,I4
,0);
6636 VARAND(UINT
,0,BSTR
,false_str
,I4
,0);
6637 VARAND(UINT
,0xffff,BSTR
, false_str
,I4
,0);
6638 VARAND(UINT
,0,BSTR
,true_str
,I4
,0);
6639 VARAND(UINT
,0xffff,BSTR
,true_str
,I4
,65535);
6640 VARANDCY(UINT
,0xffff,10000,I4
,1);
6641 VARANDCY(UINT
,0xffff,0,I4
,0);
6642 VARANDCY(UINT
,0,0,I4
,0);
6644 VARAND(BSTR
,false_str
,BSTR
,false_str
,BOOL
,0);
6645 VARAND(BSTR
,true_str
,BSTR
,false_str
,BOOL
,VARIANT_FALSE
);
6646 VARAND(BSTR
,true_str
,BSTR
,true_str
,BOOL
,VARIANT_TRUE
);
6647 VARANDCY(BSTR
,true_str
,10000,I4
,1);
6648 VARANDCY(BSTR
,false_str
,10000,I4
,0);
6650 SysFreeString(true_str
);
6651 SysFreeString(false_str
);
6654 static void test_cmp( int line
, LCID lcid
, UINT flags
, VARIANT
*left
, VARIANT
*right
, HRESULT result
)
6660 hres
= pVarCmp(left
,right
,lcid
,flags
);
6661 ok_(__FILE__
,line
)(hres
== result
, "VarCmp(%s,%s): expected 0x%x, got hres=0x%x\n",
6662 variantstr(left
), variantstr(right
), result
, hres
);
6664 static void test_cmpex( int line
, LCID lcid
, VARIANT
*left
, VARIANT
*right
,
6665 HRESULT res1
, HRESULT res2
, HRESULT res3
, HRESULT res4
)
6667 test_cmp( line
, lcid
, 0, left
, right
, res1
);
6668 V_VT(left
) |= VT_RESERVED
;
6669 test_cmp( line
, lcid
, 0, left
, right
, res2
);
6670 V_VT(left
) &= ~VT_RESERVED
;
6671 V_VT(right
) |= VT_RESERVED
;
6672 test_cmp( line
, lcid
, 0, left
, right
, res3
);
6673 V_VT(left
) |= VT_RESERVED
;
6674 test_cmp( line
, lcid
, 0, left
, right
, res4
);
6675 ok_(__FILE__
,line
)(V_VT(left
) & V_VT(right
) & VT_RESERVED
, "VT_RESERVED filtered out\n");
6678 /* ERROR from wingdi.h is interfering here */
6680 #define _VARCMP(vt1,val1,vtfl1,vt2,val2,vtfl2,lcid,flags,result) \
6681 V_##vt1(&left) = val1; V_VT(&left) = VT_##vt1 | vtfl1; \
6682 V_##vt2(&right) = val2; V_VT(&right) = VT_##vt2 | vtfl2; \
6683 test_cmp( __LINE__, lcid, flags, &left, &right, result )
6684 #define VARCMPEX(vt1,val1,vt2,val2,res1,res2,res3,res4) \
6685 V_##vt1(&left) = val1; V_VT(&left) = VT_##vt1; \
6686 V_##vt2(&right) = val2; V_VT(&right) = VT_##vt2; \
6687 test_cmpex( __LINE__, lcid, &left, &right, res1, res2, res3, res4 )
6688 #define VARCMP(vt1,val1,vt2,val2,result) \
6689 VARCMPEX(vt1,val1,vt2,val2,result,result,result,result)
6690 /* The above macros do not work for VT_NULL as NULL gets expanded first */
6691 #define V_NULL_ V_NULL
6692 #define VT_NULL_ VT_NULL
6694 static void test_VarCmp(void)
6696 VARIANT left
, right
;
6701 static const WCHAR szhuh
[] = {'h','u','h','?','\0'};
6702 static const WCHAR sz2cents
[] = {'2','c','e','n','t','s','\0'};
6703 static const WCHAR szempty
[] = {'\0'};
6704 static const WCHAR sz0
[] = {'0','\0'};
6705 static const WCHAR sz1
[] = {'1','\0'};
6706 static const WCHAR sz7
[] = {'7','\0'};
6707 static const WCHAR sz42
[] = {'4','2','\0'};
6708 static const WCHAR sz1neg
[] = {'-','1','\0'};
6709 static const WCHAR sz666neg
[] = {'-','6','6','6','\0'};
6710 static const WCHAR sz1few
[] = {'1','.','0','0','0','0','0','0','0','1','\0'};
6711 BSTR bstrhuh
, bstrempty
, bstr0
, bstr1
, bstr7
, bstr42
, bstr1neg
, bstr666neg
;
6712 BSTR bstr2cents
, bstr1few
;
6716 lcid
= MAKELCID(MAKELANGID(LANG_ENGLISH
,SUBLANG_ENGLISH_US
),SORT_DEFAULT
);
6717 bstrempty
= SysAllocString(szempty
);
6718 bstrhuh
= SysAllocString(szhuh
);
6719 bstr2cents
= SysAllocString(sz2cents
);
6720 bstr0
= SysAllocString(sz0
);
6721 bstr1
= SysAllocString(sz1
);
6722 bstr7
= SysAllocString(sz7
);
6723 bstr42
= SysAllocString(sz42
);
6724 bstr1neg
= SysAllocString(sz1neg
);
6725 bstr666neg
= SysAllocString(sz666neg
);
6726 bstr1few
= SysAllocString(sz1few
);
6728 /* Test all possible flag/vt combinations & the resulting vt type */
6729 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
6731 VARTYPE leftvt
, rightvt
;
6733 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
6738 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
6741 HRESULT expect
= VARCMP_EQ
;
6745 memset(&left
, 0, sizeof(left
));
6746 memset(&right
, 0, sizeof(right
));
6747 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
6748 if (leftvt
== VT_BSTR
) {
6749 V_BSTR(&left
) = bstr1neg
;
6750 if (ExtraFlags
[i
] & VT_RESERVED
)
6755 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
6756 if (rightvt
== VT_BSTR
) {
6757 V_BSTR(&right
) = bstr1neg
;
6758 if (ExtraFlags
[i
] & VT_RESERVED
)
6764 /* Don't ask me why but native VarCmp cannot handle:
6765 VT_I1, VT_UI2, VT_UI4, VT_UINT and VT_UI8.
6766 VT_INT is only supported as left variant. Go figure.
6767 Tested with DCOM98, Win2k, WinXP */
6768 if (ExtraFlags
[i
] & VT_ARRAY
|| ExtraFlags
[i
] & VT_BYREF
||
6769 !IsValidVariantClearVT(leftvt
, ExtraFlags
[i
] & ~VT_RESERVED
) ||
6770 !IsValidVariantClearVT(rightvt
, ExtraFlags
[i
] & ~VT_RESERVED
) ||
6771 leftvt
== VT_CLSID
|| rightvt
== VT_CLSID
||
6772 leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
||
6773 leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
||
6774 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
||
6775 leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
||
6776 leftvt
== VT_VARIANT
|| rightvt
== VT_VARIANT
||
6777 leftvt
== VT_I1
|| rightvt
== VT_I1
||
6778 leftvt
== VT_UI2
|| rightvt
== VT_UI2
||
6779 leftvt
== VT_UI4
|| rightvt
== VT_UI4
||
6780 leftvt
== VT_UI8
|| rightvt
== VT_UI8
||
6781 rightvt
== VT_INT
||
6782 leftvt
== VT_UINT
|| rightvt
== VT_UINT
) {
6786 if (leftvt
== VT_ERROR
&& rightvt
== VT_ERROR
&&
6787 !(ExtraFlags
[i
] & ~VT_RESERVED
)) {
6790 } else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
6791 expect
= VARCMP_NULL
;
6792 else if (leftvt
== VT_BSTR
&& rightvt
== VT_BSTR
)
6794 else if (leftvt
== VT_BSTR
&& rightvt
== VT_EMPTY
)
6796 else if (leftvt
== VT_EMPTY
&& rightvt
== VT_BSTR
)
6799 hres
= pVarCmp(&left
, &right
, LOCALE_USER_DEFAULT
, 0);
6801 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
6802 "VarCmp: %d|0x%X, %d|0x%X: Expected failure, got 0x%X\n",
6803 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], hres
);
6806 "VarCmp: %d|0x%X, %d|0x%X: Expected 0x%X, got 0x%X\n",
6807 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], expect
,
6814 /* VARCMP{,EX} run each 4 tests with a permutation of all possible
6815 input variants with (1) and without (0) VT_RESERVED set. The order
6816 of the permutations is (0,0); (1,0); (0,1); (1,1) */
6817 VARCMP(INT
,4711,I2
,4711,VARCMP_EQ
);
6818 VARCMP(INT
,4711,I2
,-4711,VARCMP_GT
);
6819 VARCMP(ERROR
,0,ERROR
,0,VARCMP_EQ
);
6820 VARCMP(ERROR
,0,UI1
,0,DISP_E_TYPEMISMATCH
);
6821 VARCMP(EMPTY
,0,EMPTY
,0,VARCMP_EQ
);
6822 VARCMP(I4
,1,R8
,1.0,VARCMP_EQ
);
6823 VARCMP(EMPTY
,19,I2
,0,VARCMP_EQ
);
6824 ok(V_EMPTY(&left
) == 19, "VT_EMPTY modified!\n");
6825 VARCMP(I4
,1,UI1
,1,VARCMP_EQ
);
6826 VARCMP(I2
,2,I2
,2,VARCMP_EQ
);
6827 VARCMP(I2
,1,I2
,2,VARCMP_LT
);
6828 VARCMP(I2
,2,I2
,1,VARCMP_GT
);
6829 VARCMP(I2
,2,EMPTY
,1,VARCMP_GT
);
6830 VARCMP(I2
,2,NULL_
,1,VARCMP_NULL
);
6832 /* BSTR handling, especially in conjunction with VT_RESERVED */
6833 VARCMP(BSTR
,bstr0
,NULL_
,0,VARCMP_NULL
);
6834 VARCMP(BSTR
,bstr0
,BSTR
,bstr0
,VARCMP_EQ
);
6835 VARCMP(BSTR
,bstrempty
,BSTR
,bstr0
,VARCMP_LT
);
6836 VARCMP(BSTR
,bstr7
,BSTR
,bstr0
,VARCMP_GT
);
6837 VARCMP(BSTR
,bstr7
,BSTR
,bstr1neg
,VARCMP_GT
);
6838 VARCMP(BSTR
,bstr0
,BSTR
,NULL
,VARCMP_GT
);
6839 VARCMP(BSTR
,NULL
,BSTR
,NULL
,VARCMP_EQ
);
6840 VARCMP(BSTR
,bstrempty
,BSTR
,NULL
,VARCMP_EQ
);
6841 VARCMP(BSTR
,NULL
,EMPTY
,0,VARCMP_EQ
);
6842 VARCMP(EMPTY
,0,BSTR
,NULL
,VARCMP_EQ
);
6843 VARCMP(EMPTY
,0,BSTR
,bstrempty
,VARCMP_EQ
);
6844 VARCMP(EMPTY
,1,BSTR
,bstrempty
,VARCMP_EQ
);
6845 VARCMP(BSTR
,bstr0
,EMPTY
,0,VARCMP_GT
);
6846 VARCMP(BSTR
,bstr42
,EMPTY
,0,VARCMP_GT
);
6847 VARCMPEX(BSTR
,bstrempty
,UI1
,0,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
6848 VARCMPEX(BSTR
,bstrempty
,I2
,-1,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
6849 VARCMPEX(I4
,0,BSTR
,bstrempty
,VARCMP_LT
,VARCMP_LT
,VARCMP_GT
,VARCMP_LT
);
6850 VARCMPEX(BSTR
,NULL
,UI1
,0,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
6851 VARCMPEX(I4
,7,BSTR
,NULL
,VARCMP_LT
,VARCMP_LT
,VARCMP_GT
,VARCMP_LT
);
6852 _VARCMP(BSTR
,(BSTR
)100,0,I2
,100,0,lcid
,0,VARCMP_GT
);
6853 VARCMPEX(BSTR
,bstr0
,UI1
,0,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_GT
);
6854 VARCMPEX(I2
,0,BSTR
,bstr0
,VARCMP_LT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_LT
);
6855 VARCMP(BSTR
,bstrhuh
,I4
,I4_MAX
,VARCMP_GT
);
6856 VARCMP(BSTR
,bstr2cents
,I4
,2,VARCMP_GT
);
6857 VARCMPEX(BSTR
,bstr2cents
,I4
,42,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
6858 VARCMP(BSTR
,bstr2cents
,I4
,-1,VARCMP_GT
);
6859 VARCMPEX(BSTR
,bstr2cents
,I4
,-666,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
6860 VARCMPEX(BSTR
,bstr0
,I2
,0,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_GT
);
6861 VARCMPEX(BSTR
,bstr0
,I4
,0,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_GT
);
6862 VARCMPEX(BSTR
,bstr0
,I4
,-666,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
6863 VARCMP(BSTR
,bstr1
,I4
,0,VARCMP_GT
);
6864 VARCMPEX(BSTR
,bstr1
,I4
,1,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_GT
);
6865 VARCMPEX(BSTR
,bstr1
,I4
,I4_MAX
,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
,VARCMP_GT
);
6866 VARCMPEX(BSTR
,bstr1
,I4
,-1,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
6867 VARCMP(BSTR
,bstr7
,I4
,1,VARCMP_GT
);
6868 VARCMPEX(BSTR
,bstr7
,I4
,7,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_GT
);
6869 VARCMPEX(BSTR
,bstr7
,I4
,42,VARCMP_GT
,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
);
6870 VARCMPEX(BSTR
,bstr42
,I4
,7,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
6871 VARCMPEX(BSTR
,bstr42
,I4
,42,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_GT
);
6872 VARCMPEX(BSTR
,bstr42
,I4
,I4_MAX
,VARCMP_GT
,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
);
6873 VARCMPEX(BSTR
,bstr1neg
,I4
,1,VARCMP_GT
,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
);
6874 VARCMPEX(BSTR
,bstr1neg
,I4
,42,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
,VARCMP_LT
);
6875 VARCMPEX(BSTR
,bstr1neg
,I4
,-1,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_LT
);
6876 VARCMPEX(BSTR
,bstr1neg
,I4
,-666,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_LT
);
6877 VARCMPEX(BSTR
,bstr666neg
,I4
,1,VARCMP_GT
,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
);
6878 VARCMPEX(BSTR
,bstr666neg
,I4
,7,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
,VARCMP_LT
);
6879 VARCMPEX(BSTR
,bstr666neg
,I4
,42,VARCMP_GT
,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
);
6880 VARCMPEX(BSTR
,bstr666neg
,I4
,I4_MAX
,VARCMP_GT
,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
);
6881 VARCMPEX(BSTR
,bstr666neg
,I4
,-1,VARCMP_GT
,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
);
6882 VARCMPEX(BSTR
,bstr666neg
,I4
,-666,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_LT
);
6883 VARCMPEX(BSTR
,bstr7
,R8
,7.0,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_GT
);
6884 VARCMPEX(R8
,3.141592,BSTR
,NULL
,VARCMP_LT
,VARCMP_LT
,VARCMP_GT
,VARCMP_LT
);
6885 VARCMP(BSTR
,bstr7
,BSTR
,bstr7
,VARCMP_EQ
);
6886 VARCMP(BSTR
,bstr7
,BSTR
,bstr42
,VARCMP_GT
);
6887 VARCMP(BSTR
,bstr42
,BSTR
,bstr7
,VARCMP_LT
);
6889 /* DECIMAL handling */
6890 setdec(&dec
,0,0,0,0);
6891 VARCMPEX(DECIMAL
,dec
,BSTR
,bstr0
,VARCMP_LT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_LT
);
6892 setdec64(&dec
,0,0,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF); /* max DECIMAL */
6893 VARCMP(DECIMAL
,dec
,R8
,R8_MAX
,VARCMP_LT
); /* R8 has bigger range */
6894 VARCMP(DECIMAL
,dec
,DATE
,R8_MAX
,VARCMP_LT
); /* DATE has bigger range */
6895 setdec64(&dec
,0,0x80,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF);
6896 VARCMP(DECIMAL
,dec
,R8
,-R8_MAX
,VARCMP_GT
);
6897 setdec64(&dec
,20,0,0x5,0x6BC75E2D,0x63100001); /* 1+1e-20 */
6898 VARCMP(DECIMAL
,dec
,R8
,1,VARCMP_GT
); /* DECIMAL has higher precision */
6900 /* Show that DATE is handled just as a R8 */
6901 VARCMP(DATE
,DATE_MAX
,DATE
,DATE_MAX
+1,VARCMP_LT
);
6902 VARCMP(DATE
,DATE_MIN
,DATE
,DATE_MIN
-1,VARCMP_GT
);
6903 VARCMP(DATE
,R8_MIN
,R8
,R8_MIN
,VARCMP_EQ
);
6904 VARCMP(DATE
,1,DATE
,1+1e-15,VARCMP_LT
); /* 1e-15 == 8.64e-11 seconds */
6905 VARCMP(DATE
,25570.0,DATE
,25570.0,VARCMP_EQ
);
6906 VARCMP(DATE
,25570.0,DATE
,25571.0,VARCMP_LT
);
6907 VARCMP(DATE
,25571.0,DATE
,25570.0,VARCMP_GT
);
6908 VARCMP(DATE
,25570.0,EMPTY
,0,VARCMP_GT
);
6909 VARCMP(DATE
,25570.0,NULL_
,0,VARCMP_NULL
);
6911 /* R4 precision handling */
6912 VARCMP(R4
,1,R8
,1+1e-8,VARCMP_EQ
);
6913 VARCMP(R8
,1+1e-8,R4
,1,VARCMP_EQ
);
6914 VARCMP(R8
,1+1e-8,R8
,1,VARCMP_GT
);
6915 VARCMP(R8
,R4_MAX
*1.1,R4
,R4_MAX
,VARCMP_GT
);
6916 VARCMP(R4
,R4_MAX
,R8
,R8_MAX
,VARCMP_LT
);
6917 VARCMP(R4
,1,DATE
,1+1e-8,VARCMP_EQ
);
6918 VARCMP(R4
,1,BSTR
,bstr1few
,VARCMP_LT
); /* bstr1few == 1+1e-8 */
6919 setdec(&dec
,8,0,0,0x5F5E101); /* 1+1e-8 */
6920 VARCMP(R4
,1,DECIMAL
,dec
,VARCMP_LT
);
6922 SysFreeString(bstrhuh
);
6923 SysFreeString(bstrempty
);
6924 SysFreeString(bstr0
);
6925 SysFreeString(bstr1
);
6926 SysFreeString(bstr7
);
6927 SysFreeString(bstr42
);
6928 SysFreeString(bstr1neg
);
6929 SysFreeString(bstr666neg
);
6930 SysFreeString(bstr2cents
);
6931 SysFreeString(bstr1few
);
6934 static HRESULT (WINAPI
*pVarPow
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
6936 #define VARPOW(vt1,val1,vt2,val2,rvt,rval) \
6937 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
6938 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
6939 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
6940 test_var_call2( __LINE__, pVarPow, &left, &right, &exp )
6942 /* Skip any type that is not defined or produces an error for every case */
6943 #define SKIPTESTPOW(a) \
6944 if (a == VT_ERROR || a == VT_VARIANT || \
6945 a == VT_DISPATCH || a == VT_UNKNOWN || \
6946 a == VT_RECORD || a > VT_UINT || \
6947 a == 15 /*not defined*/) \
6950 static void test_VarPow(void)
6952 static const WCHAR str2
[] = { '2','\0' };
6953 static const WCHAR str3
[] = { '3','\0' };
6954 VARIANT left
, right
, exp
, result
, cy
, dec
;
6955 BSTR num2_str
, num3_str
;
6961 num2_str
= SysAllocString(str2
);
6962 num3_str
= SysAllocString(str3
);
6964 /* Test all possible flag/vt combinations & the resulting vt type */
6965 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
6967 VARTYPE leftvt
, rightvt
, resvt
;
6969 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
6971 SKIPTESTPOW(leftvt
);
6973 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
6976 SKIPTESTPOW(rightvt
);
6978 /* Native crashes with VT_BYREF */
6979 if (ExtraFlags
[i
] == VT_BYREF
)
6982 memset(&left
, 0, sizeof(left
));
6983 memset(&right
, 0, sizeof(right
));
6984 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
6985 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
6986 V_VT(&result
) = VT_EMPTY
;
6989 if (leftvt
== VT_BSTR
)
6990 V_BSTR(&left
) = num2_str
;
6991 if (rightvt
== VT_BSTR
)
6992 V_BSTR(&right
) = num2_str
;
6994 /* Native VarPow always returns an error when using extra flags */
6995 if (ExtraFlags
[i
] != 0)
6998 /* Determine return type */
6999 else if ((leftvt
== VT_NULL
|| rightvt
== VT_NULL
) &&
7000 ((leftvt
!= VT_I8
&& leftvt
!= VT_UI8
&&
7001 rightvt
!= VT_I8
&& rightvt
!= VT_UI8
) || has_i8
))
7003 else if ((leftvt
== VT_EMPTY
|| leftvt
== VT_I2
||
7004 leftvt
== VT_I4
|| leftvt
== VT_R4
||
7005 leftvt
== VT_R8
|| leftvt
== VT_CY
||
7006 leftvt
== VT_DATE
|| leftvt
== VT_BSTR
||
7007 leftvt
== VT_BOOL
|| leftvt
== VT_DECIMAL
||
7008 (leftvt
>= VT_I1
&& leftvt
<= VT_UI4
) ||
7009 (has_i8
&& (leftvt
== VT_I8
|| leftvt
== VT_UI8
)) ||
7010 leftvt
== VT_INT
|| leftvt
== VT_UINT
) &&
7011 (rightvt
== VT_EMPTY
|| rightvt
== VT_I2
||
7012 rightvt
== VT_I4
|| rightvt
== VT_R4
||
7013 rightvt
== VT_R8
|| rightvt
== VT_CY
||
7014 rightvt
== VT_DATE
|| rightvt
== VT_BSTR
||
7015 rightvt
== VT_BOOL
|| rightvt
== VT_DECIMAL
||
7016 (rightvt
>= VT_I1
&& rightvt
<= VT_UI4
) ||
7017 (has_i8
&& (rightvt
== VT_I8
|| rightvt
== VT_UI8
)) ||
7018 rightvt
== VT_INT
|| rightvt
== VT_UINT
))
7023 hres
= pVarPow(&left
, &right
, &result
);
7025 /* Check expected HRESULT and if result variant type is correct */
7027 ok (hres
== DISP_E_BADVARTYPE
|| hres
== DISP_E_TYPEMISMATCH
,
7028 "VarPow: %s|0x%X, %s|0x%X: got vt %s hr 0x%X\n",
7029 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
],
7030 vtstr(V_VT(&result
)), hres
);
7032 ok (hres
== S_OK
&& resvt
== V_VT(&result
),
7033 "VarPow: %s|0x%X, %s|0x%X: expected vt %s hr 0x%X, got vt %s hr 0x%X\n",
7034 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
], vtstr(resvt
),
7035 S_OK
, vtstr(V_VT(&result
)), hres
);
7040 /* Check return values for valid variant type combinations */
7041 VARPOW(EMPTY
,0,EMPTY
,0,R8
,1.0);
7042 VARPOW(EMPTY
,0,NULL
,0,NULL
,0);
7043 VARPOW(EMPTY
,0,I2
,3,R8
,0.0);
7044 VARPOW(EMPTY
,0,I4
,3,R8
,0.0);
7045 VARPOW(EMPTY
,0,R4
,3.0f
,R8
,0.0);
7046 VARPOW(EMPTY
,0,R8
,3.0,R8
,0.0);
7047 VARPOW(EMPTY
,0,DATE
,3,R8
,0.0);
7048 VARPOW(EMPTY
,0,BSTR
,num3_str
,R8
,0.0);
7049 VARPOW(EMPTY
,0,BOOL
,VARIANT_FALSE
,R8
,1.0);
7050 VARPOW(EMPTY
,0,I1
,3,R8
,0.0);
7051 VARPOW(EMPTY
,0,UI1
,3,R8
,0.0);
7052 VARPOW(EMPTY
,0,UI2
,3,R8
,0.0);
7053 VARPOW(EMPTY
,0,UI4
,3,R8
,0.0);
7056 VARPOW(EMPTY
,0,I8
,3,R8
,0.0);
7057 VARPOW(EMPTY
,0,UI8
,3,R8
,0.0);
7059 VARPOW(EMPTY
,0,INT
,3,R8
,0.0);
7060 VARPOW(EMPTY
,0,UINT
,3,R8
,0.0);
7061 VARPOW(NULL
,0,EMPTY
,0,NULL
,0);
7062 VARPOW(NULL
,0,NULL
,0,NULL
,0);
7063 VARPOW(NULL
,0,I2
,3,NULL
,0);
7064 VARPOW(NULL
,0,I4
,3,NULL
,0);
7065 VARPOW(NULL
,0,R4
,3.0f
,NULL
,0);
7066 VARPOW(NULL
,0,R8
,3.0,NULL
,0);
7067 VARPOW(NULL
,0,DATE
,3,NULL
,0);
7068 VARPOW(NULL
,0,BSTR
,num3_str
,NULL
,0);
7069 VARPOW(NULL
,0,BOOL
,VARIANT_TRUE
,NULL
,0);
7070 VARPOW(NULL
,0,I1
,3,NULL
,0);
7071 VARPOW(NULL
,0,UI1
,3,NULL
,0);
7072 VARPOW(NULL
,0,UI2
,3,NULL
,0);
7073 VARPOW(NULL
,0,UI4
,3,NULL
,0);
7076 VARPOW(NULL
,0,I8
,3,NULL
,0);
7077 VARPOW(NULL
,0,UI8
,3,NULL
,0);
7079 VARPOW(NULL
,0,INT
,3,NULL
,0);
7080 VARPOW(NULL
,0,UINT
,3,NULL
,0);
7081 VARPOW(I2
,2,EMPTY
,0,R8
,1.0);
7082 VARPOW(I2
,2,NULL
,0,NULL
,0);
7083 VARPOW(I2
,2,I2
,3,R8
,8.0);
7084 VARPOW(I2
,2,I4
,3,R8
,8.0);
7085 VARPOW(I2
,2,R4
,3.0f
,R8
,8.0);
7086 VARPOW(I2
,2,R8
,3.0,R8
,8.0);
7087 VARPOW(I2
,2,DATE
,3,R8
,8.0);
7088 VARPOW(I2
,2,BSTR
,num3_str
,R8
,8.0);
7089 VARPOW(I2
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
7090 VARPOW(I2
,2,I1
,3,R8
,8.0);
7091 VARPOW(I2
,2,UI1
,3,R8
,8.0);
7092 VARPOW(I2
,2,UI2
,3,R8
,8.0);
7093 VARPOW(I2
,2,UI4
,3,R8
,8.0);
7096 VARPOW(I2
,2,I8
,3,R8
,8.0);
7097 VARPOW(I2
,2,UI8
,3,R8
,8.0);
7099 VARPOW(I2
,2,INT
,3,R8
,8.0);
7100 VARPOW(I2
,2,UINT
,3,R8
,8.0);
7101 VARPOW(I4
,2,EMPTY
,0,R8
,1.0);
7102 VARPOW(I4
,2,NULL
,0,NULL
,0);
7103 VARPOW(I4
,2,I2
,3,R8
,8.0);
7104 VARPOW(I4
,2,I4
,3,R8
,8.0);
7105 VARPOW(I4
,2,R4
,3.0f
,R8
,8.0);
7106 VARPOW(I4
,2,R8
,3.0,R8
,8.0);
7107 VARPOW(I4
,2,DATE
,3,R8
,8.0);
7108 VARPOW(I4
,2,BSTR
,num3_str
,R8
,8.0);
7109 VARPOW(I4
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
7110 VARPOW(I4
,2,I1
,3,R8
,8.0);
7111 VARPOW(I4
,2,UI1
,3,R8
,8.0);
7112 VARPOW(I4
,2,UI2
,3,R8
,8.0);
7113 VARPOW(I4
,2,UI4
,3,R8
,8.0);
7116 VARPOW(I4
,2,I8
,3,R8
,8.0);
7117 VARPOW(I4
,2,UI8
,3,R8
,8.0);
7119 VARPOW(I4
,2,INT
,3,R8
,8.0);
7120 VARPOW(I4
,2,UINT
,3,R8
,8.0);
7121 VARPOW(R4
,2,EMPTY
,0,R8
,1.0);
7122 VARPOW(R4
,2,NULL
,0,NULL
,0);
7123 VARPOW(R4
,2,I2
,3,R8
,8.0);
7124 VARPOW(R4
,2,I4
,3,R8
,8.0);
7125 VARPOW(R4
,2,R4
,3.0f
,R8
,8.0);
7126 VARPOW(R4
,2,R8
,3.0,R8
,8.0);
7127 VARPOW(R4
,2,DATE
,3,R8
,8.0);
7128 VARPOW(R4
,2,BSTR
,num3_str
,R8
,8.0);
7129 VARPOW(R4
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
7130 VARPOW(R4
,2,I1
,3,R8
,8.0);
7131 VARPOW(R4
,2,UI1
,3,R8
,8.0);
7132 VARPOW(R4
,2,UI2
,3,R8
,8.0);
7133 VARPOW(R4
,2,UI4
,3,R8
,8.0);
7136 VARPOW(R4
,2,I8
,3,R8
,8.0);
7137 VARPOW(R4
,2,UI8
,3,R8
,8.0);
7139 VARPOW(R4
,2,INT
,3,R8
,8.0);
7140 VARPOW(R4
,2,UINT
,3,R8
,8.0);
7141 VARPOW(R8
,2,EMPTY
,0,R8
,1.0);
7142 VARPOW(R8
,2,NULL
,0,NULL
,0);
7143 VARPOW(R8
,2,I2
,3,R8
,8.0);
7144 VARPOW(R8
,2,I4
,3,R8
,8.0);
7145 VARPOW(R8
,2,R4
,3.0f
,R8
,8.0);
7146 VARPOW(R8
,2,R8
,3.0,R8
,8.0);
7147 VARPOW(R8
,2,DATE
,3,R8
,8.0);
7148 VARPOW(R8
,2,BSTR
,num3_str
,R8
,8.0);
7149 VARPOW(R8
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
7150 VARPOW(R8
,2,I1
,3,R8
,8.0);
7151 VARPOW(R8
,2,UI1
,3,R8
,8.0);
7152 VARPOW(R8
,2,UI2
,3,R8
,8.0);
7153 VARPOW(R8
,2,UI4
,3,R8
,8.0);
7156 VARPOW(R8
,2,I8
,3,R8
,8.0);
7157 VARPOW(R8
,2,UI8
,3,R8
,8.0);
7159 VARPOW(R8
,2,INT
,3,R8
,8.0);
7160 VARPOW(R8
,2,UINT
,3,R8
,8.0);
7161 VARPOW(DATE
,2,EMPTY
,0,R8
,1.0);
7162 VARPOW(DATE
,2,NULL
,0,NULL
,0);
7163 VARPOW(DATE
,2,I2
,3,R8
,8.0);
7164 VARPOW(DATE
,2,I4
,3,R8
,8.0);
7165 VARPOW(DATE
,2,R4
,3.0f
,R8
,8.0);
7166 VARPOW(DATE
,2,R8
,3.0,R8
,8.0);
7167 VARPOW(DATE
,2,DATE
,3,R8
,8.0);
7168 VARPOW(DATE
,2,BSTR
,num3_str
,R8
,8.0);
7169 VARPOW(DATE
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
7170 VARPOW(DATE
,2,I1
,3,R8
,8.0);
7171 VARPOW(DATE
,2,UI1
,3,R8
,8.0);
7172 VARPOW(DATE
,2,UI2
,3,R8
,8.0);
7173 VARPOW(DATE
,2,UI4
,3,R8
,8.0);
7176 VARPOW(DATE
,2,I8
,3,R8
,8.0);
7177 VARPOW(DATE
,2,UI8
,3,R8
,8.0);
7179 VARPOW(DATE
,2,INT
,3,R8
,8.0);
7180 VARPOW(DATE
,2,UINT
,3,R8
,8.0);
7181 VARPOW(BSTR
,num2_str
,EMPTY
,0,R8
,1.0);
7182 VARPOW(BSTR
,num2_str
,NULL
,0,NULL
,0);
7183 VARPOW(BSTR
,num2_str
,I2
,3,R8
,8.0);
7184 VARPOW(BSTR
,num2_str
,I4
,3,R8
,8.0);
7185 VARPOW(BSTR
,num2_str
,R4
,3.0f
,R8
,8.0);
7186 VARPOW(BSTR
,num2_str
,R8
,3.0,R8
,8.0);
7187 VARPOW(BSTR
,num2_str
,DATE
,3,R8
,8.0);
7188 VARPOW(BSTR
,num2_str
,BSTR
,num3_str
,R8
,8.0);
7189 VARPOW(BSTR
,num2_str
,BOOL
,VARIANT_FALSE
,R8
,1.0);
7190 VARPOW(BSTR
,num2_str
,I1
,3,R8
,8.0);
7191 VARPOW(BSTR
,num2_str
,UI1
,3,R8
,8.0);
7192 VARPOW(BSTR
,num2_str
,UI2
,3,R8
,8.0);
7193 VARPOW(BSTR
,num2_str
,UI4
,3,R8
,8.0);
7196 VARPOW(BSTR
,num2_str
,I8
,3,R8
,8.0);
7197 VARPOW(BSTR
,num2_str
,UI8
,3,R8
,8.0);
7199 VARPOW(BSTR
,num2_str
,INT
,3,R8
,8.0);
7200 VARPOW(BSTR
,num2_str
,UINT
,3,R8
,8.0);
7201 VARPOW(BOOL
,VARIANT_TRUE
,EMPTY
,0,R8
,1.0);
7202 VARPOW(BOOL
,VARIANT_TRUE
,NULL
,0,NULL
,0);
7203 VARPOW(BOOL
,VARIANT_TRUE
,I2
,3,R8
,-1.0);
7204 VARPOW(BOOL
,VARIANT_TRUE
,I4
,3,R8
,-1.0);
7205 VARPOW(BOOL
,VARIANT_TRUE
,R4
,3.0f
,R8
,-1.0);
7206 VARPOW(BOOL
,VARIANT_TRUE
,R8
,3.0,R8
,-1.0);
7207 VARPOW(BOOL
,VARIANT_TRUE
,DATE
,3,R8
,-1.0);
7208 VARPOW(BOOL
,VARIANT_TRUE
,BSTR
,num3_str
,R8
,-1.0);
7209 VARPOW(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
,R8
,-1.0);
7210 VARPOW(BOOL
,VARIANT_TRUE
,I1
,3,R8
,-1.0);
7211 VARPOW(BOOL
,VARIANT_TRUE
,UI1
,3,R8
,-1.0);
7212 VARPOW(BOOL
,VARIANT_TRUE
,UI2
,3,R8
,-1.0);
7213 VARPOW(BOOL
,VARIANT_TRUE
,UI4
,3,R8
,-1.0);
7216 VARPOW(BOOL
,VARIANT_TRUE
,I8
,3,R8
,-1.0);
7217 VARPOW(BOOL
,VARIANT_TRUE
,UI8
,3,R8
,-1.0);
7219 VARPOW(BOOL
,VARIANT_TRUE
,INT
,3,R8
,-1.0);
7220 VARPOW(BOOL
,VARIANT_TRUE
,UINT
,3,R8
,-1.0);
7221 VARPOW(I1
,2,EMPTY
,0,R8
,1.0);
7222 VARPOW(I1
,2,NULL
,0,NULL
,0);
7223 VARPOW(I1
,2,I2
,3,R8
,8.0);
7224 VARPOW(I1
,2,I4
,3,R8
,8.0);
7225 VARPOW(I1
,2,R4
,3.0f
,R8
,8.0);
7226 VARPOW(I1
,2,R8
,3.0,R8
,8.0);
7227 VARPOW(I1
,2,DATE
,3,R8
,8.0);
7228 VARPOW(I1
,2,BSTR
,num3_str
,R8
,8.0);
7229 VARPOW(I1
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
7230 VARPOW(I1
,2,I1
,3,R8
,8.0);
7231 VARPOW(I1
,2,UI1
,3,R8
,8.0);
7232 VARPOW(I1
,2,UI2
,3,R8
,8.0);
7233 VARPOW(I1
,2,UI4
,3,R8
,8.0);
7236 VARPOW(I1
,2,I8
,3,R8
,8.0);
7237 VARPOW(I1
,2,UI8
,3,R8
,8.0);
7239 VARPOW(I1
,2,INT
,3,R8
,8.0);
7240 VARPOW(I1
,2,UINT
,3,R8
,8.0);
7241 VARPOW(UI1
,2,EMPTY
,0,R8
,1.0);
7242 VARPOW(UI1
,2,NULL
,0,NULL
,0);
7243 VARPOW(UI1
,2,I2
,3,R8
,8.0);
7244 VARPOW(UI1
,2,I4
,3,R8
,8.0);
7245 VARPOW(UI1
,2,R4
,3.0f
,R8
,8.0);
7246 VARPOW(UI1
,2,R8
,3.0,R8
,8.0);
7247 VARPOW(UI1
,2,DATE
,3,R8
,8.0);
7248 VARPOW(UI1
,2,BSTR
,num3_str
,R8
,8.0);
7249 VARPOW(UI1
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
7250 VARPOW(UI1
,2,I1
,3,R8
,8.0);
7251 VARPOW(UI1
,2,UI1
,3,R8
,8.0);
7252 VARPOW(UI1
,2,UI2
,3,R8
,8.0);
7253 VARPOW(UI1
,2,UI4
,3,R8
,8.0);
7256 VARPOW(UI1
,2,I8
,3,R8
,8.0);
7257 VARPOW(UI1
,2,UI8
,3,R8
,8.0);
7259 VARPOW(UI1
,2,INT
,3,R8
,8.0);
7260 VARPOW(UI1
,2,UINT
,3,R8
,8.0);
7261 VARPOW(UI2
,2,EMPTY
,0,R8
,1.0);
7262 VARPOW(UI2
,2,NULL
,0,NULL
,0);
7263 VARPOW(UI2
,2,I2
,3,R8
,8.0);
7264 VARPOW(UI2
,2,I4
,3,R8
,8.0);
7265 VARPOW(UI2
,2,R4
,3.0f
,R8
,8.0);
7266 VARPOW(UI2
,2,R8
,3.0,R8
,8.0);
7267 VARPOW(UI2
,2,DATE
,3,R8
,8.0);
7268 VARPOW(UI2
,2,BSTR
,num3_str
,R8
,8.0);
7269 VARPOW(UI2
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
7270 VARPOW(UI2
,2,I1
,3,R8
,8.0);
7271 VARPOW(UI2
,2,UI1
,3,R8
,8.0);
7272 VARPOW(UI2
,2,UI2
,3,R8
,8.0);
7273 VARPOW(UI2
,2,UI4
,3,R8
,8.0);
7276 VARPOW(UI2
,2,I8
,3,R8
,8.0);
7277 VARPOW(UI2
,2,UI8
,3,R8
,8.0);
7279 VARPOW(UI2
,2,INT
,3,R8
,8.0);
7280 VARPOW(UI2
,2,UINT
,3,R8
,8.0);
7281 VARPOW(UI4
,2,EMPTY
,0,R8
,1.0);
7282 VARPOW(UI4
,2,NULL
,0,NULL
,0);
7283 VARPOW(UI4
,2,I2
,3,R8
,8.0);
7284 VARPOW(UI4
,2,I4
,3,R8
,8.0);
7285 VARPOW(UI4
,2,R4
,3.0f
,R8
,8.0);
7286 VARPOW(UI4
,2,R8
,3.0,R8
,8.0);
7287 VARPOW(UI4
,2,DATE
,3,R8
,8.0);
7288 VARPOW(UI4
,2,BSTR
,num3_str
,R8
,8.0);
7289 VARPOW(UI4
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
7290 VARPOW(UI4
,2,I1
,3,R8
,8.0);
7291 VARPOW(UI4
,2,UI1
,3,R8
,8.0);
7292 VARPOW(UI4
,2,UI2
,3,R8
,8.0);
7293 VARPOW(UI4
,2,UI4
,3,R8
,8.0);
7296 VARPOW(UI4
,2,I8
,3,R8
,8.0);
7297 VARPOW(UI4
,2,UI8
,3,R8
,8.0);
7299 VARPOW(UI4
,2,INT
,3,R8
,8.0);
7300 VARPOW(UI4
,2,UINT
,3,R8
,8.0);
7303 VARPOW(I8
,2,EMPTY
,0,R8
,1.0);
7304 VARPOW(I8
,2,NULL
,0,NULL
,0);
7305 VARPOW(I8
,2,I2
,3,R8
,8.0);
7306 VARPOW(I8
,2,I4
,3,R8
,8.0);
7307 VARPOW(I8
,2,R4
,3.0f
,R8
,8.0);
7308 VARPOW(I8
,2,R8
,3.0,R8
,8.0);
7309 VARPOW(I8
,2,DATE
,3,R8
,8.0);
7310 VARPOW(I8
,2,BSTR
,num3_str
,R8
,8.0);
7311 VARPOW(I8
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
7312 VARPOW(I8
,2,I1
,3,R8
,8.0);
7313 VARPOW(I8
,2,UI1
,3,R8
,8.0);
7314 VARPOW(I8
,2,UI2
,3,R8
,8.0);
7315 VARPOW(I8
,2,UI4
,3,R8
,8.0);
7316 VARPOW(I8
,2,I8
,3,R8
,8.0);
7317 VARPOW(I8
,2,UI8
,3,R8
,8.0);
7318 VARPOW(I8
,2,INT
,3,R8
,8.0);
7319 VARPOW(I8
,2,UINT
,3,R8
,8.0);
7320 VARPOW(UI8
,2,EMPTY
,0,R8
,1.0);
7321 VARPOW(UI8
,2,NULL
,0,NULL
,0);
7322 VARPOW(UI8
,2,I2
,3,R8
,8.0);
7323 VARPOW(UI8
,2,I4
,3,R8
,8.0);
7324 VARPOW(UI8
,2,R4
,3.0f
,R8
,8.0);
7325 VARPOW(UI8
,2,R8
,3.0,R8
,8.0);
7326 VARPOW(UI8
,2,DATE
,3,R8
,8.0);
7327 VARPOW(UI8
,2,BSTR
,num3_str
,R8
,8.0);
7328 VARPOW(UI8
,2,I1
,3,R8
,8.0);
7329 VARPOW(UI8
,2,UI1
,3,R8
,8.0);
7330 VARPOW(UI8
,2,UI2
,3,R8
,8.0);
7331 VARPOW(UI8
,2,UI4
,3,R8
,8.0);
7332 VARPOW(UI8
,2,I8
,3,R8
,8.0);
7333 VARPOW(UI8
,2,UI8
,3,R8
,8.0);
7334 VARPOW(UI8
,2,INT
,3,R8
,8.0);
7335 VARPOW(UI8
,2,UINT
,3,R8
,8.0);
7337 VARPOW(INT
,2,EMPTY
,0,R8
,1.0);
7338 VARPOW(INT
,2,NULL
,0,NULL
,0);
7339 VARPOW(INT
,2,I2
,3,R8
,8.0);
7340 VARPOW(INT
,2,I4
,3,R8
,8.0);
7341 VARPOW(INT
,2,R4
,3.0f
,R8
,8.0);
7342 VARPOW(INT
,2,R8
,3.0,R8
,8.0);
7343 VARPOW(INT
,2,DATE
,3,R8
,8.0);
7344 VARPOW(INT
,2,BSTR
,num3_str
,R8
,8.0);
7345 VARPOW(INT
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
7346 VARPOW(INT
,2,I1
,3,R8
,8.0);
7347 VARPOW(INT
,2,UI1
,3,R8
,8.0);
7348 VARPOW(INT
,2,UI2
,3,R8
,8.0);
7349 VARPOW(INT
,2,UI4
,3,R8
,8.0);
7352 VARPOW(INT
,2,I8
,3,R8
,8.0);
7353 VARPOW(INT
,2,UI8
,3,R8
,8.0);
7355 VARPOW(INT
,2,INT
,3,R8
,8.0);
7356 VARPOW(INT
,2,UINT
,3,R8
,8.0);
7357 VARPOW(UINT
,2,EMPTY
,0,R8
,1.0);
7358 VARPOW(UINT
,2,NULL
,0,NULL
,0);
7359 VARPOW(UINT
,2,I2
,3,R8
,8.0);
7360 VARPOW(UINT
,2,I4
,3,R8
,8.0);
7361 VARPOW(UINT
,2,R4
,3.0f
,R8
,8.0);
7362 VARPOW(UINT
,2,R8
,3.0,R8
,8.0);
7363 VARPOW(UINT
,2,DATE
,3,R8
,8.0);
7364 VARPOW(UINT
,2,BSTR
,num3_str
,R8
,8.0);
7365 VARPOW(UINT
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
7366 VARPOW(UINT
,2,I1
,3,R8
,8.0);
7367 VARPOW(UINT
,2,UI1
,3,R8
,8.0);
7368 VARPOW(UINT
,2,UI2
,3,R8
,8.0);
7369 VARPOW(UINT
,2,UI4
,3,R8
,8.0);
7372 VARPOW(UINT
,2,I8
,3,R8
,8.0);
7373 VARPOW(UINT
,2,UI8
,3,R8
,8.0);
7375 VARPOW(UINT
,2,INT
,3,R8
,8.0);
7376 VARPOW(UINT
,2,UINT
,3,R8
,8.0);
7378 /* Manually test some VT_CY, VT_DECIMAL variants */
7380 hres
= VarCyFromI4(2, &V_CY(&cy
));
7381 ok(hres
== S_OK
, "VarCyFromI4 failed!\n");
7382 V_VT(&dec
) = VT_DECIMAL
;
7383 hres
= VarDecFromR8(2.0, &V_DECIMAL(&dec
));
7384 ok(hres
== S_OK
, "VarDecFromR4 failed!\n");
7385 memset(&left
, 0, sizeof(left
));
7386 memset(&right
, 0, sizeof(right
));
7387 V_VT(&left
) = VT_I4
;
7389 V_VT(&right
) = VT_I8
;
7392 hres
= pVarPow(&cy
, &cy
, &result
);
7393 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
7394 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
7395 S_OK
, hres
, vtstr(V_VT(&result
)));
7396 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 4.0),
7397 "VARPOW: CY value %f, expected %f\n", V_R8(&result
), 4.0);
7399 hres
= pVarPow(&cy
, &right
, &result
);
7402 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
7403 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
7404 S_OK
, hres
, vtstr(V_VT(&result
)));
7405 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 4.0),
7406 "VARPOW: CY value %f, expected %f\n", V_R8(&result
), 4.0);
7410 ok(hres
== DISP_E_BADVARTYPE
&& V_VT(&result
) == VT_EMPTY
,
7411 "VARPOW: expected coerced hres 0x%X type VT_EMPTY, got hres 0x%X type %s!\n",
7412 DISP_E_BADVARTYPE
, hres
, vtstr(V_VT(&result
)));
7415 hres
= pVarPow(&left
, &cy
, &result
);
7416 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
7417 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
7418 S_OK
, hres
, vtstr(V_VT(&result
)));
7419 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 10000.0),
7420 "VARPOW: CY value %f, expected %f\n", V_R8(&result
), 10000.0);
7422 hres
= pVarPow(&left
, &dec
, &result
);
7423 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
7424 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
7425 S_OK
, hres
, vtstr(V_VT(&result
)));
7426 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
),10000.0),
7427 "VARPOW: DECIMAL value %f, expected %f\n", V_R8(&result
), 10000.0);
7429 hres
= pVarPow(&dec
, &dec
, &result
);
7430 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
7431 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
7432 S_OK
, hres
, vtstr(V_VT(&result
)));
7433 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 4.0),
7434 "VARPOW: DECIMAL value %f, expected %f\n", V_R8(&result
), 4.0);
7436 hres
= pVarPow(&dec
, &right
, &result
);
7439 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
7440 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
7441 S_OK
, hres
, vtstr(V_VT(&result
)));
7442 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 4.0),
7443 "VARPOW: DECIMAL value %f, expected %f\n", V_R8(&result
), 4.0);
7447 ok(hres
== DISP_E_BADVARTYPE
&& V_VT(&result
) == VT_EMPTY
,
7448 "VARPOW: expected coerced hres 0x%X type VT_EMPTY, got hres 0x%X type %s!\n",
7449 DISP_E_BADVARTYPE
, hres
, vtstr(V_VT(&result
)));
7452 SysFreeString(num2_str
);
7453 SysFreeString(num3_str
);
7456 static HRESULT (WINAPI
*pVarDiv
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
7458 #define VARDIV(vt1,val1,vt2,val2,rvt,rval) \
7459 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
7460 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
7461 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
7462 test_var_call2( __LINE__, pVarDiv, &left, &right, &exp )
7464 /* Skip any type that is not defined or produces an error for every case */
7465 #define SKIPTESTDIV(a) \
7466 if (a == VT_ERROR || a == VT_VARIANT || \
7467 a == VT_DISPATCH || a == VT_UNKNOWN || \
7468 a == VT_RECORD || a > VT_UINT || \
7469 a == VT_I1 || a == VT_UI8 || \
7470 a == VT_INT || a == VT_UINT || \
7471 a == VT_UI2 || a == VT_UI4 || \
7472 a == 15 /*not defined*/) \
7475 static void test_VarDiv(void)
7477 static const WCHAR str1
[] = { '1','\0' };
7478 static const WCHAR str2
[] = { '2','\0' };
7479 VARIANT left
, right
, exp
, result
, cy
, dec
;
7480 BSTR num1_str
, num2_str
;
7485 num1_str
= SysAllocString(str1
);
7486 num2_str
= SysAllocString(str2
);
7490 /* Test all possible flag/vt combinations & the resulting vt type */
7491 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
7493 VARTYPE leftvt
, rightvt
, resvt
;
7495 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
7497 SKIPTESTDIV(leftvt
);
7499 /* Check if we need/have support for I8 */
7500 if (leftvt
== VT_I8
&& !has_i8
)
7503 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
7506 SKIPTESTDIV(rightvt
);
7508 /* Check if we need/have support for I8 */
7509 if (rightvt
== VT_I8
&& !has_i8
)
7512 /* Native crashes with VT_BYREF */
7513 if (ExtraFlags
[i
] == VT_BYREF
)
7516 memset(&left
, 0, sizeof(left
));
7517 memset(&right
, 0, sizeof(right
));
7518 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
7519 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
7520 V_VT(&result
) = VT_EMPTY
;
7523 if (leftvt
== VT_BSTR
)
7524 V_BSTR(&left
) = num2_str
;
7525 else if (leftvt
== VT_DECIMAL
)
7527 VarDecFromR8(2.0, &V_DECIMAL(&left
));
7528 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
7531 /* Division by 0 is undefined */
7535 V_BSTR(&right
) = num2_str
;
7538 VarDecFromR8(2.0, &V_DECIMAL(&right
));
7539 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
7542 V_BOOL(&right
) = VARIANT_TRUE
;
7544 case VT_I2
: V_I2(&right
) = 2; break;
7545 case VT_I4
: V_I4(&right
) = 2; break;
7546 case VT_R4
: V_R4(&right
) = 2.0f
; break;
7547 case VT_R8
: V_R8(&right
) = 2.0; break;
7548 case VT_CY
: V_CY(&right
).int64
= 2; break;
7549 case VT_DATE
: V_DATE(&right
) = 2; break;
7550 case VT_UI1
: V_UI1(&right
) = 2; break;
7551 case VT_I8
: V_I8(&right
) = 2; break;
7555 /* Determine return type */
7556 if (!(rightvt
== VT_EMPTY
))
7558 if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
7560 else if (leftvt
== VT_DECIMAL
|| rightvt
== VT_DECIMAL
)
7562 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
||
7563 leftvt
== VT_CY
|| rightvt
== VT_CY
||
7564 leftvt
== VT_DATE
|| rightvt
== VT_DATE
||
7565 leftvt
== VT_I4
|| rightvt
== VT_I4
||
7566 leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
||
7567 leftvt
== VT_I2
|| rightvt
== VT_I2
||
7568 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
||
7569 leftvt
== VT_R8
|| rightvt
== VT_R8
||
7570 leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
7572 if ((leftvt
== VT_UI1
&& rightvt
== VT_R4
) ||
7573 (leftvt
== VT_R4
&& rightvt
== VT_UI1
))
7575 else if ((leftvt
== VT_R4
&& (rightvt
== VT_BOOL
||
7576 rightvt
== VT_I2
)) || (rightvt
== VT_R4
&&
7577 (leftvt
== VT_BOOL
|| leftvt
== VT_I2
)))
7582 else if (leftvt
== VT_R4
|| rightvt
== VT_R4
)
7585 else if (leftvt
== VT_NULL
&& rightvt
== VT_EMPTY
)
7590 /* Native VarDiv always returns an error when using extra flags */
7591 if (ExtraFlags
[i
] != 0)
7594 hres
= pVarDiv(&left
, &right
, &result
);
7596 /* Check expected HRESULT and if result variant type is correct */
7598 ok (hres
== DISP_E_BADVARTYPE
|| hres
== DISP_E_TYPEMISMATCH
||
7599 hres
== DISP_E_OVERFLOW
|| hres
== DISP_E_DIVBYZERO
,
7600 "VarDiv: %s|0x%X, %s|0x%X: got vt %s hr 0x%X\n",
7601 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
],
7602 vtstr(V_VT(&result
)), hres
);
7604 ok (hres
== S_OK
&& resvt
== V_VT(&result
),
7605 "VarDiv: %s|0x%X, %s|0x%X: expected vt %s hr 0x%X, got vt %s hr 0x%X\n",
7606 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
], vtstr(resvt
),
7607 S_OK
, vtstr(V_VT(&result
)), hres
);
7612 /* Test return values for all the good cases */
7613 VARDIV(EMPTY
,0,NULL
,0,NULL
,0);
7614 VARDIV(EMPTY
,0,I2
,2,R8
,0.0);
7615 VARDIV(EMPTY
,0,I4
,2,R8
,0.0);
7616 VARDIV(EMPTY
,0,R4
,2.0f
,R4
,0.0f
);
7617 VARDIV(EMPTY
,0,R8
,2.0,R8
,0.0);
7618 VARDIV(EMPTY
,0,DATE
,2.0,R8
,0.0);
7619 VARDIV(EMPTY
,0,BSTR
,num2_str
,R8
,0.0);
7620 VARDIV(EMPTY
,0,BOOL
,VARIANT_TRUE
,R8
,0.0);
7621 VARDIV(EMPTY
,0,UI1
,2,R8
,0.0);
7624 VARDIV(EMPTY
,0,I8
,2,R8
,0.0);
7626 VARDIV(NULL
,0,EMPTY
,0,NULL
,0);
7627 VARDIV(NULL
,0,NULL
,0,NULL
,0);
7628 VARDIV(NULL
,0,I2
,2,NULL
,0);
7629 VARDIV(NULL
,0,I4
,2,NULL
,0);
7630 VARDIV(NULL
,0,R4
,2.0f
,NULL
,0);
7631 VARDIV(NULL
,0,R8
,2.0,NULL
,0);
7632 VARDIV(NULL
,0,DATE
,2,NULL
,0);
7633 VARDIV(NULL
,0,BSTR
,num2_str
,NULL
,0);
7634 VARDIV(NULL
,0,BOOL
,VARIANT_TRUE
,NULL
,0);
7635 VARDIV(NULL
,0,UI1
,2,NULL
,0);
7638 VARDIV(NULL
,0,I8
,2,NULL
,0);
7640 VARDIV(I2
,2,NULL
,0,NULL
,0);
7641 VARDIV(I2
,1,I2
,2,R8
,0.5);
7642 VARDIV(I2
,1,I4
,2,R8
,0.5);
7643 VARDIV(I2
,1,R4
,2,R4
,0.5f
);
7644 VARDIV(I2
,1,R8
,2.0,R8
,0.5);
7645 VARDIV(I2
,1,DATE
,2,R8
,0.5);
7646 VARDIV(I2
,1,BOOL
,VARIANT_TRUE
,R8
,-1.0);
7647 VARDIV(I2
,1,UI1
,2,R8
,0.5);
7650 VARDIV(I2
,1,I8
,2,R8
,0.5);
7652 VARDIV(I4
,1,NULL
,0,NULL
,0);
7653 VARDIV(I4
,1,I2
,2,R8
,0.5);
7654 VARDIV(I4
,1,I4
,2,R8
,0.5);
7655 VARDIV(I4
,1,R4
,2.0f
,R8
,0.5);
7656 VARDIV(I4
,1,R8
,2.0,R8
,0.5);
7657 VARDIV(I4
,1,DATE
,2,R8
,0.5);
7658 VARDIV(I4
,1,BSTR
,num2_str
,R8
,0.5);
7659 VARDIV(I4
,1,BOOL
,VARIANT_TRUE
,R8
,-1.0);
7660 VARDIV(I4
,1,UI1
,2,R8
,0.5);
7663 VARDIV(I4
,1,I8
,2,R8
,0.5);
7665 VARDIV(R4
,1.0f
,NULL
,0,NULL
,0);
7666 VARDIV(R4
,1.0f
,I2
,2,R4
,0.5f
);
7667 VARDIV(R4
,1.0f
,I4
,2,R8
,0.5);
7668 VARDIV(R4
,1.0f
,R4
,2.0f
,R4
,0.5f
);
7669 VARDIV(R4
,1.0f
,R8
,2.0,R8
,0.5);
7670 VARDIV(R4
,1.0f
,DATE
,2,R8
,0.5);
7671 VARDIV(R4
,1.0f
,BSTR
,num2_str
,R8
,0.5);
7672 VARDIV(R4
,1.0f
,BOOL
,VARIANT_TRUE
,R4
,-1);
7673 VARDIV(R4
,1.0f
,UI1
,2,R4
,0.5f
);
7676 VARDIV(R4
,1.0f
,I8
,2,R8
,0.5);
7678 VARDIV(R8
,1.0,NULL
,0,NULL
,0);
7679 VARDIV(R8
,1.0,I2
,2,R8
,0.5);
7680 VARDIV(R8
,1.0,I4
,2,R8
,0.5);
7681 VARDIV(R8
,1.0,R4
,2.0f
,R8
,0.5);
7682 VARDIV(R8
,1.0,R8
,2.0,R8
,0.5);
7683 VARDIV(R8
,1.0,DATE
,2,R8
,0.5);
7684 VARDIV(R8
,1.0,BSTR
,num2_str
,R8
,0.5);
7685 VARDIV(R8
,1.0,BOOL
,VARIANT_TRUE
,R8
,-1.0);
7686 VARDIV(R8
,1.0,UI1
,2,R8
,0.5);
7689 VARDIV(R8
,1.0,I8
,2,R8
,0.5);
7691 VARDIV(DATE
,1,NULL
,0,NULL
,0);
7692 VARDIV(DATE
,1,I2
,2,R8
,0.5);
7693 VARDIV(DATE
,1,I4
,2,R8
,0.5);
7694 VARDIV(DATE
,1,R4
,2.0f
,R8
,0.5);
7695 VARDIV(DATE
,1,R8
,2.0,R8
,0.5);
7696 VARDIV(DATE
,1,DATE
,2,R8
,0.5);
7697 VARDIV(DATE
,1,BSTR
,num2_str
,R8
,0.5);
7698 VARDIV(DATE
,1,BOOL
,VARIANT_TRUE
,R8
,-1.0);
7699 VARDIV(DATE
,1,UI1
,2,R8
,0.5);
7702 VARDIV(DATE
,1,I8
,2,R8
,0.5);
7704 VARDIV(BSTR
,num1_str
,NULL
,0,NULL
,0);
7705 VARDIV(BSTR
,num1_str
,I2
,2,R8
,0.5);
7706 VARDIV(BSTR
,num1_str
,I4
,2,R8
,0.5);
7707 VARDIV(BSTR
,num1_str
,R4
,2.0f
,R8
,0.5);
7708 VARDIV(BSTR
,num1_str
,R8
,2.0,R8
,0.5);
7709 VARDIV(BSTR
,num1_str
,DATE
,2,R8
,0.5);
7710 VARDIV(BSTR
,num1_str
,BSTR
,num2_str
,R8
,0.5);
7711 VARDIV(BSTR
,num1_str
,BOOL
,VARIANT_TRUE
,R8
,-1);
7712 VARDIV(BSTR
,num1_str
,UI1
,2,R8
,0.5);
7715 VARDIV(BSTR
,num1_str
,I8
,2,R8
,0.5);
7717 VARDIV(BOOL
,VARIANT_TRUE
,NULL
,0,NULL
,0);
7718 VARDIV(BOOL
,VARIANT_TRUE
,I2
,1,R8
,-1.0);
7719 VARDIV(BOOL
,VARIANT_FALSE
,I2
,1,R8
,0.0);
7720 VARDIV(BOOL
,VARIANT_TRUE
,I4
,1,R8
,-1.0);
7721 VARDIV(BOOL
,VARIANT_FALSE
,I4
,1,R8
,0.0);
7722 VARDIV(BOOL
,VARIANT_TRUE
,R4
,1,R4
,-1.0f
);
7723 VARDIV(BOOL
,VARIANT_FALSE
,R4
,1,R4
,0.0f
);
7724 VARDIV(BOOL
,VARIANT_TRUE
,R8
,1.0,R8
,-1.0);
7725 VARDIV(BOOL
,VARIANT_FALSE
,R8
,1.0,R8
,0.0);
7726 VARDIV(BOOL
,VARIANT_FALSE
,DATE
,2,R8
,0.0);
7727 VARDIV(BOOL
,VARIANT_FALSE
,BSTR
,num2_str
,R8
,0.0);
7728 VARDIV(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
,R8
,1.0);
7729 VARDIV(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
,R8
,0.0);
7730 VARDIV(BOOL
,VARIANT_TRUE
,UI1
,1,R8
,-1.0);
7733 VARDIV(BOOL
,VARIANT_TRUE
,I8
,1,R8
,-1.0);
7735 VARDIV(UI1
,1,NULL
,0,NULL
,0);
7736 VARDIV(UI1
,1,I2
,2,R8
,0.5);
7737 VARDIV(UI1
,1,I4
,2,R8
,0.5);
7738 VARDIV(UI1
,1,R4
,2.0f
,R4
,0.5f
);
7739 VARDIV(UI1
,1,R8
,2.0,R8
,0.5);
7740 VARDIV(UI1
,1,DATE
,2,R8
,0.5);
7741 VARDIV(UI1
,1,BSTR
,num2_str
,R8
,0.5);
7742 VARDIV(UI1
,1,BOOL
,VARIANT_TRUE
,R8
,-1);
7743 VARDIV(UI1
,1,UI1
,2,R8
,0.5);
7746 VARDIV(UI1
,1,I8
,2,R8
,0.5);
7747 VARDIV(I8
,1,NULL
,0,NULL
,0);
7748 VARDIV(I8
,1,I2
,2,R8
,0.5);
7749 VARDIV(I8
,1,I4
,2,R8
,0.5);
7750 VARDIV(I8
,1,R4
,2.0f
,R8
,0.5);
7751 VARDIV(I8
,1,R8
,2.0,R8
,0.5);
7752 VARDIV(I8
,1,DATE
,2,R8
,0.5);
7753 VARDIV(I8
,1,BSTR
,num2_str
,R8
,0.5);
7754 VARDIV(I8
,1,BOOL
,VARIANT_TRUE
,R8
,-1);
7755 VARDIV(I8
,1,UI1
,2,R8
,0.5);
7756 VARDIV(I8
,1,I8
,2,R8
,0.5);
7759 /* Manually test some VT_CY, VT_DECIMAL variants */
7761 hres
= VarCyFromI4(10000, &V_CY(&cy
));
7762 ok(hres
== S_OK
, "VarCyFromI4 failed!\n");
7763 V_VT(&dec
) = VT_DECIMAL
;
7764 hres
= VarDecFromR8(2.0, &V_DECIMAL(&dec
));
7765 ok(hres
== S_OK
, "VarDecFromR4 failed!\n");
7766 memset(&left
, 0, sizeof(left
));
7767 memset(&right
, 0, sizeof(right
));
7768 V_VT(&left
) = VT_I4
;
7770 V_VT(&right
) = VT_UI1
;
7773 hres
= pVarDiv(&cy
, &cy
, &result
);
7774 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
7775 "VARDIV: expected coerced type VT_R8, got %s!\n", vtstr(V_VT(&result
)));
7776 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 1.0),
7777 "VARDIV: CY value %f, expected %f\n", V_R8(&result
), (double)1.0);
7779 hres
= pVarDiv(&cy
, &right
, &result
);
7780 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
7781 "VARDIV: expected coerced type VT_R8, got %s!\n", vtstr(V_VT(&result
)));
7782 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 5000.0),
7783 "VARDIV: CY value %f, expected %f\n", V_R8(&result
), (double)5000.0);
7785 hres
= pVarDiv(&left
, &cy
, &result
);
7786 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
7787 "VARDIV: expected coerced type VT_R8, got %s!\n", vtstr(V_VT(&result
)));
7788 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 0.01),
7789 "VARDIV: CY value %f, expected %f\n", V_R8(&result
), (double)0.01);
7791 hres
= pVarDiv(&left
, &dec
, &result
);
7792 ok(hres
== S_OK
&& V_VT(&result
) == VT_DECIMAL
,
7793 "VARDIV: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result
)));
7794 hres
= VarR8FromDec(&V_DECIMAL(&result
), &r
);
7795 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 50.0),
7796 "VARDIV: DECIMAL value %f, expected %f\n", r
, (double)50.0);
7798 hres
= pVarDiv(&dec
, &dec
, &result
);
7799 ok(hres
== S_OK
&& V_VT(&result
) == VT_DECIMAL
,
7800 "VARDIV: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result
)));
7801 hres
= VarR8FromDec(&V_DECIMAL(&result
), &r
);
7802 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 1.0),
7803 "VARDIV: DECIMAL value %f, expected %f\n", r
, (double)1.0);
7805 hres
= pVarDiv(&dec
, &right
, &result
);
7806 ok(hres
== S_OK
&& V_VT(&result
) == VT_DECIMAL
,
7807 "VARDIV: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result
)));
7808 hres
= VarR8FromDec(&V_DECIMAL(&result
), &r
);
7809 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 1.0),
7810 "VARDIV: DECIMAL value %f, expected %f\n", r
, (double)1.0);
7812 /* Check for division by zero and overflow */
7813 V_VT(&left
) = VT_R8
;
7815 V_VT(&right
) = VT_R8
;
7817 hres
= pVarDiv(&left
, &right
, &result
);
7818 ok(hres
== DISP_E_DIVBYZERO
&& V_VT(&result
) == VT_EMPTY
,
7819 "VARDIV: Division by (1.0/0.0) should result in DISP_E_DIVBYZERO but got 0x%X\n", hres
);
7821 V_VT(&left
) = VT_R8
;
7823 V_VT(&right
) = VT_R8
;
7825 hres
= pVarDiv(&left
, &right
, &result
);
7826 ok(hres
== DISP_E_OVERFLOW
&& V_VT(&result
) == VT_EMPTY
,
7827 "VARDIV: Division by (0.0/0.0) should result in DISP_E_OVERFLOW but got 0x%X\n", hres
);
7829 SysFreeString(num1_str
);
7830 SysFreeString(num2_str
);
7833 static HRESULT (WINAPI
*pVarIdiv
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
7835 #define VARIDIV(vt1,val1,vt2,val2,rvt,rval) \
7836 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
7837 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
7838 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
7839 test_var_call2( __LINE__, pVarIdiv, &left, &right, &exp )
7841 /* Skip any type that is not defined or produces an error for every case */
7842 #define SKIPTESTIDIV(a) \
7843 if (a == VT_ERROR || a == VT_VARIANT || \
7844 a == VT_DISPATCH || a == VT_UNKNOWN || \
7845 a == VT_RECORD || a > VT_UINT || \
7846 a == 15 /*not defined*/) \
7849 static void test_VarIdiv(void)
7851 static const WCHAR str1
[] = { '1','\0' };
7852 static const WCHAR str2
[] = { '2','\0' };
7853 VARIANT left
, right
, exp
, result
, cy
, dec
;
7854 BSTR num1_str
, num2_str
;
7860 num1_str
= SysAllocString(str1
);
7861 num2_str
= SysAllocString(str2
);
7863 /* Test all possible flag/vt combinations & the resulting vt type */
7864 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
7866 VARTYPE leftvt
, rightvt
, resvt
;
7868 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
7870 SKIPTESTIDIV(leftvt
);
7872 /* Check if we need/have support for I8 and/or UI8 */
7873 if ((leftvt
== VT_I8
|| leftvt
== VT_UI8
) && !has_i8
)
7876 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
7879 SKIPTESTIDIV(rightvt
);
7881 /* Native crashes with extra flag VT_BYREF */
7882 if (ExtraFlags
[i
] == VT_BYREF
)
7885 /* Check if we need/have support for I8 and/or UI8 */
7886 if ((rightvt
== VT_I8
|| rightvt
== VT_UI8
) && !has_i8
)
7889 memset(&left
, 0, sizeof(left
));
7890 memset(&right
, 0, sizeof(right
));
7891 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
7892 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
7893 V_VT(&result
) = VT_EMPTY
;
7896 if (leftvt
== VT_BSTR
)
7897 V_BSTR(&left
) = num2_str
;
7898 else if (leftvt
== VT_DECIMAL
)
7900 VarDecFromR8(2.0, &V_DECIMAL(&left
));
7901 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
7904 /* Division by 0 is undefined */
7908 V_BSTR(&right
) = num2_str
;
7911 VarDecFromR8(2.0, &V_DECIMAL(&right
));
7912 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
7915 V_BOOL(&right
) = VARIANT_TRUE
;
7918 VarCyFromI4(10000, &V_CY(&right
));
7919 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
7921 case VT_I2
: V_I2(&right
) = 2; break;
7922 case VT_I4
: V_I4(&right
) = 2; break;
7923 case VT_R4
: V_R4(&right
) = 2.0f
; break;
7924 case VT_R8
: V_R8(&right
) = 2.0; break;
7925 case VT_DATE
: V_DATE(&right
) = 2; break;
7926 case VT_I1
: V_I1(&right
) = 2; break;
7927 case VT_UI1
: V_UI1(&right
) = 2; break;
7928 case VT_UI2
: V_UI2(&right
) = 2; break;
7929 case VT_UI4
: V_UI4(&right
) = 2; break;
7930 case VT_I8
: V_I8(&right
) = 2; break;
7931 case VT_UI8
: V_UI8(&right
) = 2; break;
7932 case VT_INT
: V_INT(&right
) = 2; break;
7933 case VT_UINT
: V_UINT(&right
) = 2; break;
7937 /* Native VarIdiv always returns an error when using extra
7938 * flags or if the variant combination is I8 and INT.
7940 if ((leftvt
== VT_I8
&& rightvt
== VT_INT
) ||
7941 (leftvt
== VT_INT
&& rightvt
== VT_I8
) ||
7942 (rightvt
== VT_EMPTY
&& leftvt
!= VT_NULL
) ||
7946 /* Determine variant type */
7947 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
7949 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
7951 else if (leftvt
== VT_I4
|| rightvt
== VT_I4
||
7952 leftvt
== VT_INT
|| rightvt
== VT_INT
||
7953 leftvt
== VT_UINT
|| rightvt
== VT_UINT
||
7954 leftvt
== VT_UI8
|| rightvt
== VT_UI8
||
7955 leftvt
== VT_UI4
|| rightvt
== VT_UI4
||
7956 leftvt
== VT_UI2
|| rightvt
== VT_UI2
||
7957 leftvt
== VT_I1
|| rightvt
== VT_I1
||
7958 leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
||
7959 leftvt
== VT_DATE
|| rightvt
== VT_DATE
||
7960 leftvt
== VT_CY
|| rightvt
== VT_CY
||
7961 leftvt
== VT_DECIMAL
|| rightvt
== VT_DECIMAL
||
7962 leftvt
== VT_R8
|| rightvt
== VT_R8
||
7963 leftvt
== VT_R4
|| rightvt
== VT_R4
)
7965 else if (leftvt
== VT_I2
|| rightvt
== VT_I2
||
7966 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
||
7969 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
7974 hres
= pVarIdiv(&left
, &right
, &result
);
7976 /* Check expected HRESULT and if result variant type is correct */
7978 ok (hres
== DISP_E_BADVARTYPE
|| hres
== DISP_E_TYPEMISMATCH
||
7979 hres
== DISP_E_DIVBYZERO
,
7980 "VarIdiv: %s|0x%X, %s|0x%X: got vt %s hr 0x%X\n",
7981 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
],
7982 vtstr(V_VT(&result
)), hres
);
7984 ok (hres
== S_OK
&& resvt
== V_VT(&result
),
7985 "VarIdiv: %s|0x%X, %s|0x%X: expected vt %s hr 0x%X, got vt %s hr 0x%X\n",
7986 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
], vtstr(resvt
),
7987 S_OK
, vtstr(V_VT(&result
)), hres
);
7992 /* Test return values for all the good cases */
7993 VARIDIV(EMPTY
,0,NULL
,0,NULL
,0);
7994 VARIDIV(EMPTY
,0,I2
,1,I2
,0);
7995 VARIDIV(EMPTY
,0,I4
,1,I4
,0);
7996 VARIDIV(EMPTY
,0,R4
,1.0f
,I4
,0);
7997 VARIDIV(EMPTY
,0,R8
,1.0,I4
,0);
7998 VARIDIV(EMPTY
,0,DATE
,1.0,I4
,0);
7999 VARIDIV(EMPTY
,0,BSTR
,num1_str
,I4
,0);
8000 VARIDIV(EMPTY
,0,BOOL
,VARIANT_TRUE
,I2
,0);
8001 VARIDIV(EMPTY
,0,I1
,1,I4
,0);
8002 VARIDIV(EMPTY
,0,UI1
,1,I2
,0);
8003 VARIDIV(EMPTY
,0,UI2
,1,I4
,0);
8004 VARIDIV(EMPTY
,0,UI4
,1,I4
,0);
8007 VARIDIV(EMPTY
,0,I8
,1,I8
,0);
8008 VARIDIV(EMPTY
,0,UI8
,1,I4
,0);
8010 VARIDIV(EMPTY
,0,INT
,1,I4
,0);
8011 VARIDIV(EMPTY
,0,UINT
,1,I4
,0);
8012 VARIDIV(NULL
,0,EMPTY
,0,NULL
,0);
8013 VARIDIV(NULL
,0,NULL
,0,NULL
,0);
8014 VARIDIV(NULL
,0,I2
,1,NULL
,0);
8015 VARIDIV(NULL
,0,I4
,1,NULL
,0);
8016 VARIDIV(NULL
,0,R4
,1,NULL
,0);
8017 VARIDIV(NULL
,0,R8
,1,NULL
,0);
8018 VARIDIV(NULL
,0,DATE
,1,NULL
,0);
8019 VARIDIV(NULL
,0,BSTR
,num1_str
,NULL
,0);
8020 VARIDIV(NULL
,0,BOOL
,VARIANT_TRUE
,NULL
,0);
8021 VARIDIV(NULL
,0,I1
,1,NULL
,0);
8022 VARIDIV(NULL
,0,UI1
,1,NULL
,0);
8023 VARIDIV(NULL
,0,UI2
,1,NULL
,0);
8024 VARIDIV(NULL
,0,UI4
,1,NULL
,0);
8027 VARIDIV(NULL
,0,I8
,1,NULL
,0);
8028 VARIDIV(NULL
,0,UI8
,1,NULL
,0);
8030 VARIDIV(NULL
,0,INT
,1,NULL
,0);
8031 VARIDIV(NULL
,0,UINT
,1,NULL
,0);
8032 VARIDIV(I2
,2,NULL
,0,NULL
,0);
8033 VARIDIV(I2
,2,I2
,1,I2
,2);
8034 VARIDIV(I2
,2,I4
,1,I4
,2);
8035 VARIDIV(I2
,2,R4
,1,I4
,2);
8036 VARIDIV(I2
,2,R8
,1,I4
,2);
8037 VARIDIV(I2
,2,DATE
,1,I4
,2);
8038 VARIDIV(I2
,2,BSTR
,num1_str
,I4
,2);
8039 VARIDIV(I2
,2,BOOL
,VARIANT_TRUE
,I2
,-2);
8040 VARIDIV(I2
,2,I1
,1,I4
,2);
8041 VARIDIV(I2
,2,UI1
,1,I2
,2);
8042 VARIDIV(I2
,2,UI2
,1,I4
,2);
8043 VARIDIV(I2
,2,UI4
,1,I4
,2);
8046 VARIDIV(I2
,2,I8
,1,I8
,2);
8047 VARIDIV(I2
,2,UI8
,1,I4
,2);
8049 VARIDIV(I2
,2,INT
,1,I4
,2);
8050 VARIDIV(I2
,2,UINT
,1,I4
,2);
8051 VARIDIV(I4
,2,NULL
,0,NULL
,0);
8052 VARIDIV(I4
,2,I2
,1,I4
,2);
8053 VARIDIV(I4
,2,I4
,1,I4
,2);
8054 VARIDIV(I4
,2,R4
,1,I4
,2);
8055 VARIDIV(I4
,2,R8
,1,I4
,2);
8056 VARIDIV(I4
,2,DATE
,1,I4
,2);
8057 VARIDIV(I4
,2,BSTR
,num1_str
,I4
,2);
8058 VARIDIV(I4
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
8059 VARIDIV(I4
,2,I1
,1,I4
,2);
8060 VARIDIV(I4
,2,UI1
,1,I4
,2);
8061 VARIDIV(I4
,2,UI2
,1,I4
,2);
8062 VARIDIV(I4
,2,UI4
,1,I4
,2);
8065 VARIDIV(I4
,2,I8
,1,I8
,2);
8066 VARIDIV(I4
,2,UI8
,1,I4
,2);
8068 VARIDIV(I4
,2,INT
,1,I4
,2);
8069 VARIDIV(I4
,2,UINT
,1,I4
,2);
8070 VARIDIV(R4
,2.0f
,NULL
,0,NULL
,0);
8071 VARIDIV(R4
,2.0f
,I2
,1,I4
,2);
8072 VARIDIV(R4
,2.0f
,I4
,1,I4
,2);
8073 VARIDIV(R4
,2.0f
,R4
,1.0f
,I4
,2);
8074 VARIDIV(R4
,2.0f
,R8
,1.0,I4
,2);
8075 VARIDIV(R4
,2.0f
,DATE
,1,I4
,2);
8076 VARIDIV(R4
,2.0f
,BSTR
,num1_str
,I4
,2);
8077 VARIDIV(R4
,2.0f
,BOOL
,VARIANT_TRUE
,I4
,-2);
8078 VARIDIV(R4
,2.0f
,I1
,1,I4
,2);
8079 VARIDIV(R4
,2.0f
,UI1
,1,I4
,2);
8080 VARIDIV(R4
,2.0f
,UI2
,1,I4
,2);
8081 VARIDIV(R4
,2.0f
,UI4
,1,I4
,2);
8084 VARIDIV(R4
,2.0f
,I8
,1,I8
,2);
8085 VARIDIV(R4
,2.0f
,UI8
,1,I4
,2);
8087 VARIDIV(R4
,2.0f
,INT
,1,I4
,2);
8088 VARIDIV(R4
,2.0f
,UINT
,1,I4
,2);
8089 VARIDIV(R8
,2.0,NULL
,0,NULL
,0);
8090 VARIDIV(R8
,2.0,I2
,1,I4
,2);
8091 VARIDIV(R8
,2.0,I4
,1,I4
,2);
8092 VARIDIV(R8
,2.0,R4
,1,I4
,2);
8093 VARIDIV(R8
,2.0,R8
,1,I4
,2);
8094 VARIDIV(R8
,2.0,DATE
,1,I4
,2);
8095 VARIDIV(R8
,2.0,BSTR
,num1_str
,I4
,2);
8096 VARIDIV(R8
,2.0,BOOL
,VARIANT_TRUE
,I4
,-2);
8097 VARIDIV(R8
,2.0,I1
,1,I4
,2);
8098 VARIDIV(R8
,2.0,UI1
,1,I4
,2);
8099 VARIDIV(R8
,2.0,UI2
,1,I4
,2);
8100 VARIDIV(R8
,2.0,UI4
,1,I4
,2);
8103 VARIDIV(R8
,2.0,I8
,1,I8
,2);
8104 VARIDIV(R8
,2.0,UI8
,1,I4
,2);
8106 VARIDIV(R8
,2.0,INT
,1,I4
,2);
8107 VARIDIV(R8
,2.0,UINT
,1,I4
,2);
8108 VARIDIV(DATE
,2,NULL
,0,NULL
,0);
8109 VARIDIV(DATE
,2,I2
,1,I4
,2);
8110 VARIDIV(DATE
,2,I4
,1,I4
,2);
8111 VARIDIV(DATE
,2,R4
,1,I4
,2);
8112 VARIDIV(DATE
,2,R8
,1,I4
,2);
8113 VARIDIV(DATE
,2,DATE
,1,I4
,2);
8114 VARIDIV(DATE
,2,BSTR
,num1_str
,I4
,2);
8115 VARIDIV(DATE
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
8116 VARIDIV(DATE
,2,I1
,1,I4
,2);
8117 VARIDIV(DATE
,2,UI1
,1,I4
,2);
8118 VARIDIV(DATE
,2,UI2
,1,I4
,2);
8119 VARIDIV(DATE
,2,UI4
,1,I4
,2);
8122 VARIDIV(DATE
,2,I8
,1,I8
,2);
8123 VARIDIV(DATE
,2,UI8
,1,I4
,2);
8125 VARIDIV(DATE
,2,INT
,1,I4
,2);
8126 VARIDIV(DATE
,2,UINT
,1,I4
,2);
8127 VARIDIV(BSTR
,num2_str
,NULL
,0,NULL
,0);
8128 VARIDIV(BSTR
,num2_str
,I2
,1,I4
,2);
8129 VARIDIV(BSTR
,num2_str
,I4
,1,I4
,2);
8130 VARIDIV(BSTR
,num2_str
,R4
,1.0f
,I4
,2);
8131 VARIDIV(BSTR
,num2_str
,R8
,1.0,I4
,2);
8132 VARIDIV(BSTR
,num2_str
,DATE
,1,I4
,2);
8133 VARIDIV(BSTR
,num2_str
,BSTR
,num1_str
,I4
,2);
8134 VARIDIV(BSTR
,num2_str
,BOOL
,VARIANT_TRUE
,I4
,-2);
8135 VARIDIV(BSTR
,num2_str
,I1
,1,I4
,2);
8136 VARIDIV(BSTR
,num2_str
,UI1
,1,I4
,2);
8137 VARIDIV(BSTR
,num2_str
,UI2
,1,I4
,2);
8138 VARIDIV(BSTR
,num2_str
,UI4
,1,I4
,2);
8141 VARIDIV(BSTR
,num2_str
,I8
,1,I8
,2);
8142 VARIDIV(BSTR
,num2_str
,UI8
,1,I4
,2);
8144 VARIDIV(BSTR
,num2_str
,INT
,1,I4
,2);
8145 VARIDIV(BSTR
,num2_str
,UINT
,1,I4
,2);
8146 VARIDIV(BOOL
,VARIANT_TRUE
,NULL
,0,NULL
,0);
8147 VARIDIV(BOOL
,VARIANT_TRUE
,I2
,1,I2
,-1);
8148 VARIDIV(BOOL
,VARIANT_TRUE
,I4
,1,I4
,-1);
8149 VARIDIV(BOOL
,VARIANT_TRUE
,R4
,1.0f
,I4
,-1);
8150 VARIDIV(BOOL
,VARIANT_TRUE
,R8
,1.0,I4
,-1);
8151 VARIDIV(BOOL
,VARIANT_TRUE
,DATE
,1,I4
,-1);
8152 VARIDIV(BOOL
,VARIANT_TRUE
,BSTR
,num1_str
,I4
,-1);
8153 VARIDIV(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
,I2
,1);
8154 VARIDIV(BOOL
,VARIANT_TRUE
,I1
,1,I4
,-1);
8155 VARIDIV(BOOL
,VARIANT_TRUE
,UI1
,1,I2
,-1);
8156 VARIDIV(BOOL
,VARIANT_TRUE
,UI2
,1,I4
,-1);
8157 VARIDIV(BOOL
,VARIANT_TRUE
,UI4
,1,I4
,-1);
8160 VARIDIV(BOOL
,VARIANT_TRUE
,I8
,1,I8
,-1);
8161 VARIDIV(BOOL
,VARIANT_TRUE
,UI8
,1,I4
,-1);
8163 VARIDIV(BOOL
,VARIANT_TRUE
,INT
,1,I4
,-1);
8164 VARIDIV(BOOL
,VARIANT_TRUE
,UINT
,1,I4
,-1);
8165 VARIDIV(I1
,2,NULL
,0,NULL
,0);
8166 VARIDIV(I1
,2,I2
,1,I4
,2);
8167 VARIDIV(I1
,2,I4
,1,I4
,2);
8168 VARIDIV(I1
,2,R4
,1.0f
,I4
,2);
8169 VARIDIV(I1
,2,R8
,1.0,I4
,2);
8170 VARIDIV(I1
,2,DATE
,1,I4
,2);
8171 VARIDIV(I1
,2,BSTR
,num1_str
,I4
,2);
8172 VARIDIV(I1
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
8173 VARIDIV(I1
,2,I1
,1,I4
,2);
8174 VARIDIV(I1
,2,UI1
,1,I4
,2);
8175 VARIDIV(I1
,2,UI2
,1,I4
,2);
8176 VARIDIV(I1
,2,UI4
,1,I4
,2);
8179 VARIDIV(I1
,2,I8
,1,I8
,2);
8180 VARIDIV(I1
,2,UI8
,1,I4
,2);
8182 VARIDIV(I1
,2,INT
,1,I4
,2);
8183 VARIDIV(I1
,2,UINT
,1,I4
,2);
8184 VARIDIV(UI1
,2,NULL
,0,NULL
,0);
8185 VARIDIV(UI1
,2,I2
,1,I2
,2);
8186 VARIDIV(UI1
,2,I4
,1,I4
,2);
8187 VARIDIV(UI1
,2,R4
,1.0f
,I4
,2);
8188 VARIDIV(UI1
,2,R8
,1.0,I4
,2);
8189 VARIDIV(UI1
,2,DATE
,1,I4
,2);
8190 VARIDIV(UI1
,2,BSTR
,num1_str
,I4
,2);
8191 VARIDIV(UI1
,2,BOOL
,VARIANT_TRUE
,I2
,-2);
8192 VARIDIV(UI1
,2,I1
,1,I4
,2);
8193 VARIDIV(UI1
,2,UI1
,1,UI1
,2);
8194 VARIDIV(UI1
,2,UI2
,1,I4
,2);
8195 VARIDIV(UI1
,2,UI4
,1,I4
,2);
8198 VARIDIV(UI1
,2,I8
,1,I8
,2);
8199 VARIDIV(UI1
,2,UI8
,1,I4
,2);
8201 VARIDIV(UI1
,2,INT
,1,I4
,2);
8202 VARIDIV(UI1
,2,UINT
,1,I4
,2);
8203 VARIDIV(UI2
,2,NULL
,0,NULL
,0);
8204 VARIDIV(UI2
,2,I2
,1,I4
,2);
8205 VARIDIV(UI2
,2,I4
,1,I4
,2);
8206 VARIDIV(UI2
,2,R4
,1.0f
,I4
,2);
8207 VARIDIV(UI2
,2,R8
,1.0,I4
,2);
8208 VARIDIV(UI2
,2,DATE
,1,I4
,2);
8209 VARIDIV(UI2
,2,BSTR
,num1_str
,I4
,2);
8210 VARIDIV(UI2
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
8211 VARIDIV(UI2
,2,I1
,1,I4
,2);
8212 VARIDIV(UI2
,2,UI1
,1,I4
,2);
8213 VARIDIV(UI2
,2,UI2
,1,I4
,2);
8214 VARIDIV(UI2
,2,UI4
,1,I4
,2);
8217 VARIDIV(UI2
,2,I8
,1,I8
,2);
8218 VARIDIV(UI2
,2,UI8
,1,I4
,2);
8220 VARIDIV(UI2
,2,INT
,1,I4
,2);
8221 VARIDIV(UI2
,2,UINT
,1,I4
,2);
8222 VARIDIV(UI4
,2,NULL
,0,NULL
,0);
8223 VARIDIV(UI4
,2,I2
,1,I4
,2);
8224 VARIDIV(UI4
,2,I4
,1,I4
,2);
8225 VARIDIV(UI4
,2,R4
,1.0f
,I4
,2);
8226 VARIDIV(UI4
,2,R8
,1.0,I4
,2);
8227 VARIDIV(UI4
,2,DATE
,1,I4
,2);
8228 VARIDIV(UI4
,2,BSTR
,num1_str
,I4
,2);
8229 VARIDIV(UI4
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
8230 VARIDIV(UI4
,2,I1
,1,I4
,2);
8231 VARIDIV(UI4
,2,UI1
,1,I4
,2);
8232 VARIDIV(UI4
,2,UI2
,1,I4
,2);
8233 VARIDIV(UI4
,2,UI4
,1,I4
,2);
8236 VARIDIV(UI4
,2,I8
,1,I8
,2);
8237 VARIDIV(UI4
,2,UI8
,1,I4
,2);
8239 VARIDIV(UI4
,2,INT
,1,I4
,2);
8240 VARIDIV(UI4
,2,UINT
,1,I4
,2);
8243 VARIDIV(I8
,2,NULL
,0,NULL
,0);
8244 VARIDIV(I8
,2,I2
,1,I8
,2);
8245 VARIDIV(I8
,2,I4
,1,I8
,2);
8246 VARIDIV(I8
,2,R4
,1.0f
,I8
,2);
8247 VARIDIV(I8
,2,R8
,1.0,I8
,2);
8248 VARIDIV(I8
,2,DATE
,1,I8
,2);
8249 VARIDIV(I8
,2,BSTR
,num1_str
,I8
,2);
8250 VARIDIV(I8
,2,BOOL
,1,I8
,2);
8251 VARIDIV(I8
,2,I1
,1,I8
,2);
8252 VARIDIV(I8
,2,UI1
,1,I8
,2);
8253 VARIDIV(I8
,2,UI2
,1,I8
,2);
8254 VARIDIV(I8
,2,UI4
,1,I8
,2);
8255 VARIDIV(I8
,2,I8
,1,I8
,2);
8256 VARIDIV(I8
,2,UI8
,1,I8
,2);
8257 VARIDIV(I8
,2,UINT
,1,I8
,2);
8258 VARIDIV(UI8
,2,NULL
,0,NULL
,0);
8259 VARIDIV(UI8
,2,I2
,1,I4
,2);
8260 VARIDIV(UI8
,2,I4
,1,I4
,2);
8261 VARIDIV(UI8
,2,R4
,1.0f
,I4
,2);
8262 VARIDIV(UI8
,2,R8
,1.0,I4
,2);
8263 VARIDIV(UI8
,2,DATE
,1,I4
,2);
8264 VARIDIV(UI8
,2,BSTR
,num1_str
,I4
,2);
8265 VARIDIV(UI8
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
8266 VARIDIV(UI8
,2,I1
,1,I4
,2);
8267 VARIDIV(UI8
,2,UI1
,1,I4
,2);
8268 VARIDIV(UI8
,2,UI2
,1,I4
,2);
8269 VARIDIV(UI8
,2,UI4
,1,I4
,2);
8270 VARIDIV(UI8
,2,I8
,1,I8
,2);
8271 VARIDIV(UI8
,2,UI8
,1,I4
,2);
8272 VARIDIV(UI8
,2,INT
,1,I4
,2);
8273 VARIDIV(UI8
,2,UINT
,1,I4
,2);
8275 VARIDIV(INT
,2,NULL
,0,NULL
,0);
8276 VARIDIV(INT
,2,I2
,1,I4
,2);
8277 VARIDIV(INT
,2,I4
,1,I4
,2);
8278 VARIDIV(INT
,2,R4
,1.0f
,I4
,2);
8279 VARIDIV(INT
,2,R8
,1.0,I4
,2);
8280 VARIDIV(INT
,2,DATE
,1,I4
,2);
8281 VARIDIV(INT
,2,BSTR
,num1_str
,I4
,2);
8282 VARIDIV(INT
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
8283 VARIDIV(INT
,2,I1
,1,I4
,2);
8284 VARIDIV(INT
,2,UI1
,1,I4
,2);
8285 VARIDIV(INT
,2,UI2
,1,I4
,2);
8286 VARIDIV(INT
,2,UI4
,1,I4
,2);
8289 VARIDIV(INT
,2,UI8
,1,I4
,2);
8291 VARIDIV(INT
,2,INT
,1,I4
,2);
8292 VARIDIV(INT
,2,UINT
,1,I4
,2);
8293 VARIDIV(UINT
,2,NULL
,0,NULL
,0);
8294 VARIDIV(UINT
,2,I2
,1,I4
,2);
8295 VARIDIV(UINT
,2,I4
,1,I4
,2);
8296 VARIDIV(UINT
,2,R4
,1.0f
,I4
,2);
8297 VARIDIV(UINT
,2,R8
,1.0,I4
,2);
8298 VARIDIV(UINT
,2,DATE
,1,I4
,2);
8299 VARIDIV(UINT
,2,BSTR
,num1_str
,I4
,2);
8300 VARIDIV(UINT
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
8301 VARIDIV(UINT
,2,I1
,1,I4
,2);
8302 VARIDIV(UINT
,2,UI1
,1,I4
,2);
8303 VARIDIV(UINT
,2,UI2
,1,I4
,2);
8304 VARIDIV(UINT
,2,UI4
,1,I4
,2);
8307 VARIDIV(UINT
,2,I8
,1,I8
,2);
8308 VARIDIV(UINT
,2,UI8
,1,I4
,2);
8310 VARIDIV(UINT
,2,INT
,1,I4
,2);
8311 VARIDIV(UINT
,2,UINT
,1,I4
,2);
8313 /* Manually test some VT_CY, VT_DECIMAL variants */
8315 hres
= VarCyFromI4(10000, &V_CY(&cy
));
8316 ok(hres
== S_OK
, "VarCyFromI4 failed!\n");
8317 V_VT(&dec
) = VT_DECIMAL
;
8318 hres
= VarDecFromR8(2.0, &V_DECIMAL(&dec
));
8319 ok(hres
== S_OK
, "VarDecFromR4 failed!\n");
8320 memset(&left
, 0, sizeof(left
));
8321 memset(&right
, 0, sizeof(right
));
8322 V_VT(&left
) = VT_I4
;
8324 V_VT(&right
) = VT_I8
;
8327 hres
= pVarIdiv(&cy
, &cy
, &result
);
8328 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
8329 "VARIDIV: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8330 S_OK
, hres
, vtstr(V_VT(&result
)));
8331 ok(hres
== S_OK
&& V_I4(&result
) == 1,
8332 "VARIDIV: CY value %d, expected %d\n", V_I4(&result
), 1);
8336 hres
= pVarIdiv(&cy
, &right
, &result
);
8337 ok(hres
== S_OK
&& V_VT(&result
) == VT_I8
,
8338 "VARIDIV: expected coerced hres 0x%X type VT_I8, got hres 0x%X type %s!\n",
8339 S_OK
, hres
, vtstr(V_VT(&result
)));
8340 ok(hres
== S_OK
&& V_I8(&result
) == 5000,
8341 "VARIDIV: CY value 0x%x%08x, expected 0x%x\n",
8342 (DWORD
)(V_I8(&result
) >>32), (DWORD
)V_I8(&result
), 5000);
8345 hres
= pVarIdiv(&left
, &cy
, &result
);
8346 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
8347 "VARIDIV: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8348 S_OK
, hres
, vtstr(V_VT(&result
)));
8349 ok(hres
== S_OK
&& V_I4(&result
) == 0,
8350 "VARIDIV: CY value %d, expected %d\n", V_I4(&result
), 0);
8352 hres
= pVarIdiv(&left
, &dec
, &result
);
8353 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
8354 "VARIDIV: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8355 S_OK
, hres
, vtstr(V_VT(&result
)));
8356 ok(hres
== S_OK
&& V_I4(&result
) == 50,
8357 "VARIDIV: DECIMAL value %d, expected %d\n", V_I4(&result
), 50);
8359 hres
= pVarIdiv(&dec
, &dec
, &result
);
8360 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
8361 "VARIDIV: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8362 S_OK
, hres
, vtstr(V_VT(&result
)));
8363 ok(hres
== S_OK
&& V_I4(&result
) == 1,
8364 "VARIDIV: DECIMAL value %d, expected %d\n", V_I4(&result
), 1);
8368 hres
= pVarIdiv(&dec
, &right
, &result
);
8369 ok(hres
== S_OK
&& V_VT(&result
) == VT_I8
,
8370 "VARIDIV: expected coerced hres 0x%X type VT_I8, got hres 0x%X type %s!\n",
8371 S_OK
, hres
, vtstr(V_VT(&result
)));
8372 ok(hres
== S_OK
&& V_I8(&result
) == 1,
8373 "VARIDIV: DECIMAL value 0x%x%08x, expected %d\n",
8374 (DWORD
)(V_I8(&result
) >> 32), (DWORD
)V_I8(&result
), 1);
8377 /* Check for division by zero */
8378 V_VT(&left
) = VT_INT
;
8380 V_VT(&right
) = VT_INT
;
8382 hres
= pVarIdiv(&left
, &right
, &result
);
8383 ok(hres
== DISP_E_DIVBYZERO
&& V_VT(&result
) == VT_EMPTY
,
8384 "VARIDIV: Division by 0 should result in DISP_E_DIVBYZERO but got 0x%X\n", hres
);
8386 V_VT(&left
) = VT_INT
;
8388 V_VT(&right
) = VT_INT
;
8390 hres
= pVarIdiv(&left
, &right
, &result
);
8391 ok(hres
== DISP_E_DIVBYZERO
&& V_VT(&result
) == VT_EMPTY
,
8392 "VARIDIV: Division by 0 should result in DISP_E_DIVBYZERO but got 0x%X\n", hres
);
8394 SysFreeString(num1_str
);
8395 SysFreeString(num2_str
);
8399 static HRESULT (WINAPI
*pVarImp
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
8401 #define VARIMP(vt1,val1,vt2,val2,rvt,rval) \
8402 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
8403 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
8404 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
8405 test_var_call2( __LINE__, pVarImp, &left, &right, &exp )
8407 /* Skip any type that is not defined or produces an error for every case */
8408 #define SKIPTESTIMP(a) \
8409 if (a == VT_ERROR || a == VT_VARIANT || \
8410 a == VT_DISPATCH || a == VT_UNKNOWN || \
8411 a == VT_RECORD || a > VT_UINT || \
8412 a == 15 /*not defined*/) \
8415 static void test_VarImp(void)
8417 static const WCHAR szFalse
[] = { '#','F','A','L','S','E','#','\0' };
8418 static const WCHAR szTrue
[] = { '#','T','R','U','E','#','\0' };
8419 VARIANT left
, right
, exp
, result
, cy
, dec
;
8420 BSTR true_str
, false_str
;
8426 true_str
= SysAllocString(szTrue
);
8427 false_str
= SysAllocString(szFalse
);
8429 /* Test all possible flag/vt combinations & the resulting vt type */
8430 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
8432 VARTYPE leftvt
, rightvt
, resvt
;
8434 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
8436 SKIPTESTIMP(leftvt
);
8438 /* Check if we need/have support for I8 and/or UI8 */
8439 if ((leftvt
== VT_I8
|| leftvt
== VT_UI8
) && !has_i8
)
8442 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
8445 SKIPTESTIMP(rightvt
);
8447 /* Native crashes when using the extra flag VT_BYREF
8448 * or with the following VT combinations
8450 if ((leftvt
== VT_UI4
&& rightvt
== VT_BSTR
) ||
8451 (leftvt
== VT_UI8
&& rightvt
== VT_BSTR
) ||
8452 ExtraFlags
[i
] == VT_BYREF
)
8455 /* Check if we need/have support for I8 and/or UI8 */
8456 if ((rightvt
== VT_I8
|| rightvt
== VT_UI8
) && !has_i8
)
8459 memset(&left
, 0, sizeof(left
));
8460 memset(&right
, 0, sizeof(right
));
8461 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
8462 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
8463 V_VT(&result
) = VT_EMPTY
;
8466 if (leftvt
== VT_BSTR
)
8467 V_BSTR(&left
) = true_str
;
8469 /* This allows us to test return types that are not NULL
8470 * (NULL Imp value = n, NULL Imp 0 = NULL)
8475 V_BSTR(&right
) = true_str
;
8478 VarDecFromR8(2.0, &V_DECIMAL(&right
));
8479 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
8482 V_BOOL(&right
) = VARIANT_TRUE
;
8484 case VT_I1
: V_I1(&right
) = 2; break;
8485 case VT_I2
: V_I2(&right
) = 2; break;
8486 case VT_I4
: V_I4(&right
) = 2; break;
8487 case VT_R4
: V_R4(&right
) = 2.0f
; break;
8488 case VT_R8
: V_R8(&right
) = 2.0; break;
8489 case VT_CY
: V_CY(&right
).int64
= 10000; break;
8490 case VT_DATE
: V_DATE(&right
) = 2; break;
8491 case VT_I8
: V_I8(&right
) = 2; break;
8492 case VT_INT
: V_INT(&right
) = 2; break;
8493 case VT_UINT
: V_UINT(&right
) = 2; break;
8494 case VT_UI1
: V_UI1(&right
) = 2; break;
8495 case VT_UI2
: V_UI2(&right
) = 2; break;
8496 case VT_UI4
: V_UI4(&right
) = 2; break;
8497 case VT_UI8
: V_UI8(&right
) = 2; break;
8501 /* Native VarImp always returns an error when using extra
8502 * flags or if the variants are I8 and INT.
8504 if ((leftvt
== VT_I8
&& rightvt
== VT_INT
) ||
8508 /* Determine result type */
8509 else if ((leftvt
== VT_BSTR
&& rightvt
== VT_NULL
) ||
8510 (leftvt
== VT_NULL
&& rightvt
== VT_NULL
) ||
8511 (leftvt
== VT_NULL
&& rightvt
== VT_EMPTY
))
8513 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
8515 else if (leftvt
== VT_I4
|| rightvt
== VT_I4
||
8516 leftvt
== VT_INT
|| rightvt
== VT_INT
||
8517 leftvt
== VT_UINT
|| rightvt
== VT_UINT
||
8518 leftvt
== VT_UI4
|| rightvt
== VT_UI4
||
8519 leftvt
== VT_UI8
|| rightvt
== VT_UI8
||
8520 leftvt
== VT_UI2
|| rightvt
== VT_UI2
||
8521 leftvt
== VT_DECIMAL
|| rightvt
== VT_DECIMAL
||
8522 leftvt
== VT_DATE
|| rightvt
== VT_DATE
||
8523 leftvt
== VT_CY
|| rightvt
== VT_CY
||
8524 leftvt
== VT_R8
|| rightvt
== VT_R8
||
8525 leftvt
== VT_R4
|| rightvt
== VT_R4
||
8526 leftvt
== VT_I1
|| rightvt
== VT_I1
)
8528 else if ((leftvt
== VT_UI1
&& rightvt
== VT_UI1
) ||
8529 (leftvt
== VT_UI1
&& rightvt
== VT_NULL
) ||
8530 (leftvt
== VT_NULL
&& rightvt
== VT_UI1
))
8532 else if (leftvt
== VT_EMPTY
|| rightvt
== VT_EMPTY
||
8533 leftvt
== VT_I2
|| rightvt
== VT_I2
||
8534 leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
8536 else if (leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
||
8537 leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
)
8540 hres
= pVarImp(&left
, &right
, &result
);
8542 /* Check expected HRESULT and if result variant type is correct */
8544 ok (hres
== DISP_E_BADVARTYPE
|| hres
== DISP_E_TYPEMISMATCH
,
8545 "VarImp: %s|0x%X, %s|0x%X: got vt %s hr 0x%X\n",
8546 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
],
8547 vtstr(V_VT(&result
)), hres
);
8549 ok (hres
== S_OK
&& resvt
== V_VT(&result
),
8550 "VarImp: %s|0x%X, %s|0x%X: expected vt %s hr 0x%X, got vt %s hr 0x%X\n",
8551 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
], vtstr(resvt
),
8552 S_OK
, vtstr(V_VT(&result
)), hres
);
8557 VARIMP(EMPTY
,0,EMPTY
,0,I2
,-1);
8558 VARIMP(EMPTY
,0,NULL
,0,I2
,-1);
8559 VARIMP(EMPTY
,0,I2
,-1,I2
,-1);
8560 VARIMP(EMPTY
,0,I4
,-1,I4
,-1);
8561 VARIMP(EMPTY
,0,R4
,0.0f
,I4
,-1);
8562 VARIMP(EMPTY
,0,R8
,-1.0,I4
,-1);
8563 VARIMP(EMPTY
,0,DATE
,0,I4
,-1);
8564 VARIMP(EMPTY
,0,BSTR
,true_str
,I2
,-1);
8565 VARIMP(EMPTY
,0,BOOL
,VARIANT_FALSE
,I2
,-1);
8566 VARIMP(EMPTY
,0,I1
,0,I4
,-1);
8567 VARIMP(EMPTY
,0,UI1
,1,I2
,-1);
8568 VARIMP(EMPTY
,0,UI2
,1,I4
,-1);
8569 VARIMP(EMPTY
,0,UI4
,1,I4
,-1);
8572 VARIMP(EMPTY
,0,I8
,1,I8
,-1);
8573 VARIMP(EMPTY
,0,UI8
,1,I4
,-1);
8575 VARIMP(EMPTY
,0,INT
,-1,I4
,-1);
8576 VARIMP(EMPTY
,0,UINT
,1,I4
,-1);
8577 VARIMP(NULL
,0,EMPTY
,0,NULL
,0);
8578 VARIMP(NULL
,0,NULL
,0,NULL
,0);
8579 VARIMP(NULL
,0,I2
,-1,I2
,-1);
8580 VARIMP(NULL
,0,I4
,-1,I4
,-1);
8581 VARIMP(NULL
,0,R4
,0.0f
,NULL
,0);
8582 VARIMP(NULL
,0,R8
,-1.0,I4
,-1);
8583 VARIMP(NULL
,0,DATE
,0,NULL
,0);
8584 VARIMP(NULL
,0,BSTR
,true_str
,BOOL
,-1);
8585 VARIMP(NULL
,0,BOOL
,VARIANT_FALSE
,NULL
,0);
8586 VARIMP(NULL
,0,I1
,0,NULL
,0);
8587 VARIMP(NULL
,0,UI1
,1,UI1
,1);
8588 VARIMP(NULL
,0,UI2
,1,I4
,1);
8589 VARIMP(NULL
,0,UI4
,1,I4
,1);
8592 VARIMP(NULL
,0,I8
,1,I8
,1);
8593 VARIMP(NULL
,0,UI8
,1,I4
,1);
8595 VARIMP(NULL
,0,INT
,-1,I4
,-1);
8596 VARIMP(NULL
,0,UINT
,1,I4
,1);
8597 VARIMP(I2
,-1,EMPTY
,0,I2
,0);
8598 VARIMP(I2
,-1,I2
,-1,I2
,-1);
8599 VARIMP(I2
,-1,I4
,-1,I4
,-1);
8600 VARIMP(I2
,-1,R4
,0.0f
,I4
,0);
8601 VARIMP(I2
,-1,R8
,-1.0,I4
,-1);
8602 VARIMP(I2
,-1,DATE
,0,I4
,0);
8603 VARIMP(I2
,-1,BSTR
,true_str
,I2
,-1);
8604 VARIMP(I2
,-1,BOOL
,VARIANT_FALSE
,I2
,0);
8605 VARIMP(I2
,-1,I1
,0,I4
,0);
8606 VARIMP(I2
,-1,UI1
,1,I2
,1);
8607 VARIMP(I2
,-1,UI2
,1,I4
,1);
8608 VARIMP(I2
,-1,UI4
,1,I4
,1);
8611 VARIMP(I2
,-1,I8
,1,I8
,1);
8612 VARIMP(I2
,-1,UI8
,1,I4
,1);
8614 VARIMP(I2
,-1,INT
,-1,I4
,-1);
8615 VARIMP(I2
,-1,UINT
,1,I4
,1);
8616 VARIMP(I4
,2,EMPTY
,0,I4
,-3);
8617 VARIMP(I4
,2,NULL
,0,I4
,-3);
8618 VARIMP(I4
,2,I2
,-1,I4
,-1);
8619 VARIMP(I4
,2,I4
,-1,I4
,-1);
8620 VARIMP(I4
,2,R4
,0.0f
,I4
,-3);
8621 VARIMP(I4
,2,R8
,-1.0,I4
,-1);
8622 VARIMP(I4
,2,DATE
,0,I4
,-3);
8623 VARIMP(I4
,2,BSTR
,true_str
,I4
,-1);
8624 VARIMP(I4
,2,BOOL
,VARIANT_FALSE
,I4
,-3);
8625 VARIMP(I4
,2,I1
,0,I4
,-3);
8626 VARIMP(I4
,2,UI1
,1,I4
,-3);
8627 VARIMP(I4
,2,UI2
,1,I4
,-3);
8628 VARIMP(I4
,2,UI4
,1,I4
,-3);
8631 VARIMP(I4
,2,I8
,1,I8
,-3);
8632 VARIMP(I4
,2,UI8
,1,I4
,-3);
8634 VARIMP(I4
,2,INT
,-1,I4
,-1);
8635 VARIMP(I4
,2,UINT
,1,I4
,-3);
8636 VARIMP(R4
,-1.0f
,EMPTY
,0,I4
,0);
8637 VARIMP(R4
,-1.0f
,NULL
,0,NULL
,0);
8638 VARIMP(R4
,-1.0f
,I2
,-1,I4
,-1);
8639 VARIMP(R4
,-1.0f
,I4
,-1,I4
,-1);
8640 VARIMP(R4
,-1.0f
,R4
,0.0f
,I4
,0);
8641 VARIMP(R4
,-1.0f
,R8
,-1.0,I4
,-1);
8642 VARIMP(R4
,-1.0f
,DATE
,1,I4
,1);
8643 VARIMP(R4
,-1.0f
,BSTR
,true_str
,I4
,-1);
8644 VARIMP(R4
,-1.0f
,BOOL
,VARIANT_FALSE
,I4
,0);
8645 VARIMP(R4
,-1.0f
,I1
,0,I4
,0);
8646 VARIMP(R4
,-1.0f
,UI1
,1,I4
,1);
8647 VARIMP(R4
,-1.0f
,UI2
,1,I4
,1);
8648 VARIMP(R4
,-1.0f
,UI4
,1,I4
,1);
8651 VARIMP(R4
,-1.0f
,I8
,1,I8
,1);
8652 VARIMP(R4
,-1.0f
,UI8
,1,I4
,1);
8654 VARIMP(R4
,-1.0f
,INT
,-1,I4
,-1);
8655 VARIMP(R4
,-1.0f
,UINT
,1,I4
,1);
8656 VARIMP(R8
,1.0,EMPTY
,0,I4
,-2);
8657 VARIMP(R8
,1.0,NULL
,0,I4
,-2);
8658 VARIMP(R8
,1.0,I2
,-1,I4
,-1);
8659 VARIMP(R8
,1.0,I4
,-1,I4
,-1);
8660 VARIMP(R8
,1.0,R4
,0.0f
,I4
,-2);
8661 VARIMP(R8
,1.0,R8
,-1.0,I4
,-1);
8662 VARIMP(R8
,1.0,DATE
,0,I4
,-2);
8663 VARIMP(R8
,1.0,BSTR
,true_str
,I4
,-1);
8664 VARIMP(R8
,1.0,BOOL
,VARIANT_FALSE
,I4
,-2);
8665 VARIMP(R8
,1.0,I1
,0,I4
,-2);
8666 VARIMP(R8
,1.0,UI1
,1,I4
,-1);
8667 VARIMP(R8
,1.0,UI2
,1,I4
,-1);
8668 VARIMP(R8
,1.0,UI4
,1,I4
,-1);
8671 VARIMP(R8
,1.0,I8
,1,I8
,-1);
8672 VARIMP(R8
,1.0,UI8
,1,I4
,-1);
8674 VARIMP(R8
,1.0,INT
,-1,I4
,-1);
8675 VARIMP(R8
,1.0,UINT
,1,I4
,-1);
8676 VARIMP(DATE
,0,EMPTY
,0,I4
,-1);
8677 VARIMP(DATE
,0,NULL
,0,I4
,-1);
8678 VARIMP(DATE
,0,I2
,-1,I4
,-1);
8679 VARIMP(DATE
,0,I4
,-1,I4
,-1);
8680 VARIMP(DATE
,0,R4
,0.0f
,I4
,-1);
8681 VARIMP(DATE
,0,R8
,-1.0,I4
,-1);
8682 VARIMP(DATE
,0,DATE
,0,I4
,-1);
8683 VARIMP(DATE
,0,BSTR
,true_str
,I4
,-1);
8684 VARIMP(DATE
,0,BOOL
,VARIANT_FALSE
,I4
,-1);
8685 VARIMP(DATE
,0,I1
,0,I4
,-1);
8686 VARIMP(DATE
,0,UI1
,1,I4
,-1);
8687 VARIMP(DATE
,0,UI2
,1,I4
,-1);
8688 VARIMP(DATE
,0,UI4
,1,I4
,-1);
8691 VARIMP(DATE
,0,I8
,1,I8
,-1);
8692 VARIMP(DATE
,0,UI8
,1,I4
,-1);
8694 VARIMP(DATE
,0,INT
,-1,I4
,-1);
8695 VARIMP(DATE
,0,UINT
,1,I4
,-1);
8696 VARIMP(BSTR
,false_str
,EMPTY
,0,I2
,-1);
8697 VARIMP(BSTR
,false_str
,NULL
,0,BOOL
,-1);
8698 VARIMP(BSTR
,false_str
,I2
,-1,I2
,-1);
8699 VARIMP(BSTR
,false_str
,I4
,-1,I4
,-1);
8700 VARIMP(BSTR
,false_str
,R4
,0.0f
,I4
,-1);
8701 VARIMP(BSTR
,false_str
,R8
,-1.0,I4
,-1);
8702 VARIMP(BSTR
,false_str
,DATE
,0,I4
,-1);
8703 VARIMP(BSTR
,false_str
,BSTR
,true_str
,BOOL
,-1);
8704 VARIMP(BSTR
,false_str
,BOOL
,VARIANT_FALSE
,BOOL
,-1);
8705 VARIMP(BSTR
,false_str
,I1
,0,I4
,-1);
8706 VARIMP(BSTR
,false_str
,UI1
,1,I2
,-1);
8707 VARIMP(BSTR
,false_str
,UI2
,1,I4
,-1);
8708 VARIMP(BSTR
,false_str
,UI4
,1,I4
,-1);
8711 VARIMP(BSTR
,false_str
,I8
,1,I8
,-1);
8712 VARIMP(BSTR
,false_str
,UI8
,1,I4
,-1);
8714 VARIMP(BSTR
,false_str
,INT
,-1,I4
,-1);
8715 VARIMP(BSTR
,false_str
,UINT
,1,I4
,-1);
8716 VARIMP(BOOL
,VARIANT_TRUE
,EMPTY
,0,I2
,0);
8717 VARIMP(BOOL
,VARIANT_TRUE
,NULL
,0,NULL
,0);
8718 VARIMP(BOOL
,VARIANT_TRUE
,I2
,-1,I2
,-1);
8719 VARIMP(BOOL
,VARIANT_TRUE
,I4
,-1,I4
,-1);
8720 VARIMP(BOOL
,VARIANT_TRUE
,R4
,0.0f
,I4
,0);
8721 VARIMP(BOOL
,VARIANT_TRUE
,R8
,-1.0,I4
,-1);
8722 VARIMP(BOOL
,VARIANT_TRUE
,DATE
,0,I4
,0);
8723 VARIMP(BOOL
,VARIANT_TRUE
,BSTR
,true_str
,BOOL
,-1);
8724 VARIMP(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
,BOOL
,0);
8725 VARIMP(BOOL
,VARIANT_TRUE
,I1
,0,I4
,0);
8726 VARIMP(BOOL
,VARIANT_TRUE
,UI1
,1,I2
,1);
8727 VARIMP(BOOL
,VARIANT_TRUE
,UI2
,1,I4
,1);
8728 VARIMP(BOOL
,VARIANT_TRUE
,UI4
,1,I4
,1);
8731 VARIMP(BOOL
,VARIANT_TRUE
,I8
,1,I8
,1);
8732 VARIMP(BOOL
,VARIANT_TRUE
,UI8
,1,I4
,1);
8734 VARIMP(BOOL
,VARIANT_TRUE
,INT
,-1,I4
,-1);
8735 VARIMP(BOOL
,VARIANT_TRUE
,UINT
,1,I4
,1);
8736 VARIMP(I1
,-1,EMPTY
,0,I4
,0);
8737 VARIMP(I1
,-1,NULL
,0,NULL
,0);
8738 VARIMP(I1
,-1,I2
,-1,I4
,-1);
8739 VARIMP(I1
,-1,I4
,-1,I4
,-1);
8740 VARIMP(I1
,-1,R4
,0.0f
,I4
,0);
8741 VARIMP(I1
,-1,R8
,-1.0,I4
,-1);
8742 VARIMP(I1
,-1,DATE
,0,I4
,0);
8743 VARIMP(I1
,-1,BSTR
,true_str
,I4
,-1);
8744 VARIMP(I1
,-1,BOOL
,VARIANT_FALSE
,I4
,0);
8745 VARIMP(I1
,-1,I1
,0,I4
,0);
8746 VARIMP(I1
,-1,UI1
,1,I4
,1);
8747 VARIMP(I1
,-1,UI2
,1,I4
,1);
8748 VARIMP(I1
,-1,UI4
,1,I4
,1);
8751 VARIMP(I1
,-1,I8
,1,I8
,1);
8752 VARIMP(I1
,-1,UI8
,1,I4
,1);
8754 VARIMP(I1
,-1,INT
,-1,I4
,-1);
8755 VARIMP(I1
,-1,UINT
,1,I4
,1);
8756 VARIMP(UI1
,0,EMPTY
,0,I2
,-1);
8757 VARIMP(UI1
,0,NULL
,0,UI1
,255);
8758 VARIMP(UI1
,0,I2
,-1,I2
,-1);
8759 VARIMP(UI1
,0,I4
,-1,I4
,-1);
8760 VARIMP(UI1
,0,R4
,0.0f
,I4
,-1);
8761 VARIMP(UI1
,0,R8
,-1.0,I4
,-1);
8762 VARIMP(UI1
,0,DATE
,0,I4
,-1);
8763 VARIMP(UI1
,0,BSTR
,true_str
,I2
,-1);
8764 VARIMP(UI1
,0,BOOL
,VARIANT_FALSE
,I2
,-1);
8765 VARIMP(UI1
,0,I1
,0,I4
,-1);
8766 VARIMP(UI1
,0,UI1
,1,UI1
,255);
8767 VARIMP(UI1
,0,UI2
,1,I4
,-1);
8768 VARIMP(UI1
,0,UI4
,1,I4
,-1);
8771 VARIMP(UI1
,0,I8
,1,I8
,-1);
8772 VARIMP(UI1
,0,UI8
,1,I4
,-1);
8774 VARIMP(UI1
,0,INT
,-1,I4
,-1);
8775 VARIMP(UI1
,0,UINT
,1,I4
,-1);
8776 VARIMP(UI2
,0,EMPTY
,0,I4
,-1);
8777 VARIMP(UI2
,0,NULL
,0,I4
,-1);
8778 VARIMP(UI2
,0,I2
,-1,I4
,-1);
8779 VARIMP(UI2
,0,I4
,-1,I4
,-1);
8780 VARIMP(UI2
,0,R4
,0.0f
,I4
,-1);
8781 VARIMP(UI2
,0,R8
,-1.0,I4
,-1);
8782 VARIMP(UI2
,0,DATE
,0,I4
,-1);
8783 VARIMP(UI2
,0,BSTR
,true_str
,I4
,-1);
8784 VARIMP(UI2
,0,BOOL
,VARIANT_FALSE
,I4
,-1);
8785 VARIMP(UI2
,0,I1
,0,I4
,-1);
8786 VARIMP(UI2
,0,UI1
,1,I4
,-1);
8787 VARIMP(UI2
,0,UI2
,1,I4
,-1);
8788 VARIMP(UI2
,0,UI4
,1,I4
,-1);
8791 VARIMP(UI2
,0,I8
,1,I8
,-1);
8792 VARIMP(UI2
,0,UI8
,1,I4
,-1);
8794 VARIMP(UI2
,0,INT
,-1,I4
,-1);
8795 VARIMP(UI2
,0,UINT
,1,I4
,-1);
8796 VARIMP(UI4
,0,EMPTY
,0,I4
,-1);
8797 VARIMP(UI4
,0,NULL
,0,I4
,-1);
8798 VARIMP(UI4
,0,I2
,-1,I4
,-1);
8799 VARIMP(UI4
,0,I4
,-1,I4
,-1);
8800 VARIMP(UI4
,0,R4
,0.0f
,I4
,-1);
8801 VARIMP(UI4
,0,R8
,-1.0,I4
,-1);
8802 VARIMP(UI4
,0,DATE
,0,I4
,-1);
8803 VARIMP(UI4
,0,BSTR
,true_str
,I4
,-1);
8804 VARIMP(UI4
,0,BOOL
,VARIANT_FALSE
,I4
,-1);
8805 VARIMP(UI4
,0,I1
,0,I4
,-1);
8806 VARIMP(UI4
,0,UI1
,1,I4
,-1);
8807 VARIMP(UI4
,0,UI2
,1,I4
,-1);
8808 VARIMP(UI4
,0,UI4
,1,I4
,-1);
8811 VARIMP(UI4
,0,I8
,1,I8
,-1);
8812 VARIMP(UI4
,0,UI8
,1,I4
,-1);
8814 VARIMP(UI4
,0,INT
,-1,I4
,-1);
8815 VARIMP(UI4
,0,UINT
,1,I4
,-1);
8818 VARIMP(I8
,-1,EMPTY
,0,I8
,0);
8819 VARIMP(I8
,-1,NULL
,0,NULL
,0);
8820 VARIMP(I8
,-1,I2
,-1,I8
,-1);
8821 VARIMP(I8
,-1,I4
,-1,I8
,-1);
8822 VARIMP(I8
,-1,R4
,0.0f
,I8
,0);
8823 VARIMP(I8
,-1,R8
,-1.0,I8
,-1);
8824 VARIMP(I8
,-1,DATE
,0,I8
,0);
8825 VARIMP(I8
,-1,BSTR
,true_str
,I8
,-1);
8826 VARIMP(I8
,-1,BOOL
,VARIANT_FALSE
,I8
,0);
8827 VARIMP(I8
,-1,I1
,0,I8
,0);
8828 VARIMP(I8
,-1,UI1
,1,I8
,1);
8829 VARIMP(I8
,-1,UI2
,1,I8
,1);
8830 VARIMP(I8
,-1,UI4
,1,I8
,1);
8831 VARIMP(I8
,-1,I8
,1,I8
,1);
8832 VARIMP(I8
,-1,UI8
,1,I8
,1);
8833 VARIMP(I8
,-1,UINT
,1,I8
,1);
8834 VARIMP(UI8
,0,EMPTY
,0,I4
,-1);
8835 VARIMP(UI8
,0,NULL
,0,I4
,-1);
8836 VARIMP(UI8
,0,I2
,-1,I4
,-1);
8837 VARIMP(UI8
,0,I4
,-1,I4
,-1);
8838 VARIMP(UI8
,0,R4
,0.0f
,I4
,-1);
8839 VARIMP(UI8
,0,R8
,-1.0,I4
,-1);
8840 VARIMP(UI8
,0,DATE
,0,I4
,-1);
8841 VARIMP(UI8
,0,BSTR
,true_str
,I4
,-1);
8842 VARIMP(UI8
,0,BOOL
,VARIANT_FALSE
,I4
,-1);
8843 VARIMP(UI8
,0,I1
,0,I4
,-1);
8844 VARIMP(UI8
,0,UI1
,1,I4
,-1);
8845 VARIMP(UI8
,0,UI2
,1,I4
,-1);
8846 VARIMP(UI8
,0,UI4
,1,I4
,-1);
8847 VARIMP(UI8
,0,I8
,1,I8
,-1);
8848 VARIMP(UI8
,0,UI8
,1,I4
,-1);
8849 VARIMP(UI8
,0,INT
,-1,I4
,-1);
8850 VARIMP(UI8
,0,UINT
,1,I4
,-1);
8852 VARIMP(INT
,-1,EMPTY
,0,I4
,0);
8853 VARIMP(INT
,-1,NULL
,0,NULL
,0);
8854 VARIMP(INT
,-1,I2
,-1,I4
,-1);
8855 VARIMP(INT
,-1,I4
,-1,I4
,-1);
8856 VARIMP(INT
,-1,R4
,0.0f
,I4
,0);
8857 VARIMP(INT
,-1,R8
,-1.0,I4
,-1);
8858 VARIMP(INT
,-1,DATE
,0,I4
,0);
8859 VARIMP(INT
,-1,BSTR
,true_str
,I4
,-1);
8860 VARIMP(INT
,-1,BOOL
,VARIANT_FALSE
,I4
,0);
8861 VARIMP(INT
,-1,I1
,0,I4
,0);
8862 VARIMP(INT
,-1,UI1
,1,I4
,1);
8863 VARIMP(INT
,-1,UI2
,1,I4
,1);
8864 VARIMP(INT
,-1,UI4
,1,I4
,1);
8867 VARIMP(INT
,-1,I8
,1,I8
,1);
8868 VARIMP(INT
,-1,UI8
,1,I4
,1);
8870 VARIMP(INT
,-1,INT
,-1,I4
,-1);
8871 VARIMP(INT
,-1,UINT
,1,I4
,1);
8872 VARIMP(UINT
,1,EMPTY
,0,I4
,-2);
8873 VARIMP(UINT
,1,NULL
,0,I4
,-2);
8874 VARIMP(UINT
,1,I2
,-1,I4
,-1);
8875 VARIMP(UINT
,1,I4
,-1,I4
,-1);
8876 VARIMP(UINT
,1,R4
,0.0f
,I4
,-2);
8877 VARIMP(UINT
,1,R8
,-1.0,I4
,-1);
8878 VARIMP(UINT
,1,DATE
,0,I4
,-2);
8879 VARIMP(UINT
,1,BSTR
,true_str
,I4
,-1);
8880 VARIMP(UINT
,1,BOOL
,VARIANT_FALSE
,I4
,-2);
8881 VARIMP(UINT
,1,I1
,0,I4
,-2);
8882 VARIMP(UINT
,1,UI1
,1,I4
,-1);
8883 VARIMP(UINT
,1,UI2
,1,I4
,-1);
8884 VARIMP(UINT
,1,UI4
,1,I4
,-1);
8887 VARIMP(UINT
,1,I8
,1,I8
,-1);
8888 VARIMP(UINT
,1,UI8
,1,I4
,-1);
8890 VARIMP(UINT
,1,INT
,-1,I4
,-1);
8891 VARIMP(UINT
,1,UINT
,1,I4
,-1);
8893 /* Manually test some VT_CY, VT_DECIMAL variants */
8895 hres
= VarCyFromI4(1, &V_CY(&cy
));
8896 ok(hres
== S_OK
, "VarCyFromI4 failed!\n");
8897 V_VT(&dec
) = VT_DECIMAL
;
8898 hres
= VarDecFromR8(2.0, &V_DECIMAL(&dec
));
8899 ok(hres
== S_OK
, "VarDecFromR4 failed!\n");
8900 memset(&left
, 0, sizeof(left
));
8901 memset(&right
, 0, sizeof(right
));
8902 V_VT(&left
) = VT_I4
;
8904 V_VT(&right
) = VT_I8
;
8907 hres
= pVarImp(&cy
, &cy
, &result
);
8908 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
8909 "VARIMP: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8910 S_OK
, hres
, vtstr(V_VT(&result
)));
8911 ok(hres
== S_OK
&& V_I4(&result
) == -1,
8912 "VARIMP: CY value %d, expected %d\n", V_I4(&result
), -1);
8916 hres
= pVarImp(&cy
, &right
, &result
);
8917 ok(hres
== S_OK
&& V_VT(&result
) == VT_I8
,
8918 "VARIMP: expected coerced hres 0x%X type VT_I8, got hres 0x%X type %s!\n",
8919 S_OK
, hres
, vtstr(V_VT(&result
)));
8920 ok(hres
== S_OK
&& V_I8(&result
) == -2,
8921 "VARIMP: CY value %x%08x, expected %d\n",
8922 (DWORD
)((V_I8(&result
)) >> 32), (DWORD
)(V_I8(&result
)), -2);
8925 hres
= pVarImp(&left
, &cy
, &result
);
8926 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
8927 "VARIMP: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8928 S_OK
, hres
, vtstr(V_VT(&result
)));
8929 ok(hres
== S_OK
&& V_I4(&result
) == -1,
8930 "VARIMP: CY value %d, expected %d\n", V_I4(&result
), -1);
8932 hres
= pVarImp(&left
, &dec
, &result
);
8933 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
8934 "VARIMP: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8935 S_OK
, hres
, vtstr(V_VT(&result
)));
8936 ok(hres
== S_OK
&& V_I4(&result
) == -1,
8937 "VARIMP: DECIMAL value %d, expected %d\n", V_I4(&result
), -1);
8939 hres
= pVarImp(&dec
, &dec
, &result
);
8940 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
8941 "VARIMP: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8942 S_OK
, hres
, vtstr(V_VT(&result
)));
8943 ok(hres
== S_OK
&& V_I4(&result
) == -1,
8944 "VARIMP: DECIMAL value %d, expected %d\n", V_I4(&result
), -1);
8948 hres
= pVarImp(&dec
, &right
, &result
);
8949 ok(hres
== S_OK
&& V_VT(&result
) == VT_I8
,
8950 "VARIMP: expected coerced hres 0x%X type VT_I8, got hres 0x%X type %s!\n",
8951 S_OK
, hres
, vtstr(V_VT(&result
)));
8952 ok(hres
== S_OK
&& V_I8(&result
) == -3,
8953 "VARIMP: DECIMAL value 0x%x%08x, expected %d\n",
8954 (DWORD
)(V_I8(&result
) >>32), (DWORD
)V_I8(&result
), -3);
8957 SysFreeString(false_str
);
8958 SysFreeString(true_str
);
8966 test_VariantClear();
8968 test_VariantCopyInd();
8969 test_VarParseNumFromStr();
8970 test_VarNumFromParseNum();
8971 test_VarUdateFromDate();
8972 test_VarDateFromUdate();
8973 test_SystemTimeToVariantTime();
8974 test_VariantTimeToSystemTime();
8975 test_DosDateTimeToVariantTime();
8976 test_VariantTimeToDosDateTime();
8991 test_VarCmp(); /* Before test_VarCat() which needs VarCmp() */