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
29 #define NONAMELESSUNION
34 #include "wine/test.h"
44 static HMODULE hOleaut32
;
46 static HRESULT (WINAPI
*pVarUdateFromDate
)(DATE
,ULONG
,UDATE
*);
47 static HRESULT (WINAPI
*pVarDateFromUdate
)(UDATE
*,ULONG
,DATE
*);
48 static INT (WINAPI
*pSystemTimeToVariantTime
)(LPSYSTEMTIME
,double*);
49 static INT (WINAPI
*pVariantTimeToSystemTime
)(double,LPSYSTEMTIME
);
50 static INT (WINAPI
*pDosDateTimeToVariantTime
)(USHORT
,USHORT
,double*);
51 static INT (WINAPI
*pVariantTimeToDosDateTime
)(double,USHORT
*,USHORT
*);
53 static const WCHAR sz12
[] = {'1','2','\0'};
54 /* the strings are localized */
55 static WCHAR sz12_false
[32];
56 static WCHAR sz12_true
[32];
58 /* Get a conversion function ptr, return if function not available */
59 #define CHECKPTR(func) p##func = (void*)GetProcAddress(hOleaut32, #func); \
60 if (!p##func) { win_skip("function " # func " not available, not testing it\n"); return; }
62 /* Has I8/UI8 data type? */
65 /* When comparing floating point values we cannot expect an exact match
66 * because the rounding errors depend on the exact algorithm.
68 #define EQ_DOUBLE(a,b) (fabs((a)-(b)) / (1.0+fabs(a)+fabs(b)) < 1e-14)
69 #define EQ_FLOAT(a,b) (fabs((a)-(b)) / (1.0+fabs(a)+fabs(b)) < 1e-7)
71 #define SKIPTESTS(a) if((a > VT_CLSID+10) && (a < VT_BSTR_BLOB-10)) continue
73 /* Allow our test macros to work for VT_NULL and VT_EMPTY too */
74 #define V_EMPTY(v) V_I4(v)
75 #define V_NULL(v) V_I4(v)
77 /* Size constraints for overflow tests */
79 #define I1_MIN ((-I1_MAX)-1)
83 #define I2_MIN ((-I2_MAX)-1)
84 #define UI2_MAX 0xffff
86 #define I4_MAX 0x7fffffff
87 #define I4_MIN ((-I4_MAX)-1)
88 #define UI4_MAX 0xffffffff
90 #define I8_MAX (((LONGLONG)I4_MAX << 32) | UI4_MAX)
91 #define I8_MIN ((-I8_MAX)-1)
92 #define UI8_MAX (((ULONGLONG)UI4_MAX << 32) | UI4_MAX)
94 #define DATE_MAX 2958465
95 #define DATE_MIN -657434
96 #define R4_MAX FLT_MAX
97 #define R4_MIN FLT_MIN
98 #define R8_MAX DBL_MAX
99 #define R8_MIN DBL_MIN
101 #define DEFINE_EXPECT(func) \
102 static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
104 #define SET_EXPECT(func) \
105 do { called_ ## func = FALSE; expect_ ## func = TRUE; } while(0)
107 #define CHECK_EXPECT2(func) \
109 ok(expect_ ##func, "unexpected call " #func "\n"); \
110 called_ ## func = TRUE; \
113 #define CHECK_EXPECT(func) \
115 CHECK_EXPECT2(func); \
116 expect_ ## func = FALSE; \
119 #define CHECK_CALLED(func) \
121 ok(called_ ## func, "expected " #func "\n"); \
122 expect_ ## func = called_ ## func = FALSE; \
125 DEFINE_EXPECT(dispatch_invoke
);
129 IDispatch IDispatch_iface
;
134 static inline DummyDispatch
*impl_from_IDispatch(IDispatch
*iface
)
136 return CONTAINING_RECORD(iface
, DummyDispatch
, IDispatch_iface
);
139 static ULONG WINAPI
DummyDispatch_AddRef(IDispatch
*iface
)
144 static ULONG WINAPI
DummyDispatch_Release(IDispatch
*iface
)
149 static HRESULT WINAPI
DummyDispatch_QueryInterface(IDispatch
*iface
,
155 if (IsEqualIID(riid
, &IID_IDispatch
) ||
156 IsEqualIID(riid
, &IID_IUnknown
))
159 IDispatch_AddRef(iface
);
162 return *ppvObject
? S_OK
: E_NOINTERFACE
;
165 static HRESULT WINAPI
DummyDispatch_GetTypeInfoCount(IDispatch
*iface
, UINT
*pctinfo
)
167 ok(0, "Unexpected call\n");
171 static HRESULT WINAPI
DummyDispatch_GetTypeInfo(IDispatch
*iface
, UINT tinfo
, LCID lcid
, ITypeInfo
**ti
)
173 ok(0, "Unexpected call\n");
177 static HRESULT WINAPI
DummyDispatch_GetIDsOfNames(IDispatch
*iface
, REFIID riid
, LPOLESTR
*names
,
178 UINT cnames
, LCID lcid
, DISPID
*dispid
)
180 ok(0, "Unexpected call\n");
184 static HRESULT WINAPI
DummyDispatch_Invoke(IDispatch
*iface
,
185 DISPID dispid
, REFIID riid
,
186 LCID lcid
, WORD wFlags
,
192 DummyDispatch
*This
= impl_from_IDispatch(iface
);
194 CHECK_EXPECT(dispatch_invoke
);
196 ok(dispid
== DISPID_VALUE
, "got dispid %d\n", dispid
);
197 ok(IsEqualIID(riid
, &IID_NULL
), "go riid %s\n", wine_dbgstr_guid(riid
));
198 ok(wFlags
== DISPATCH_PROPERTYGET
, "Flags wrong\n");
200 ok(params
->rgvarg
== NULL
, "got %p\n", params
->rgvarg
);
201 ok(params
->rgdispidNamedArgs
== NULL
, "got %p\n", params
->rgdispidNamedArgs
);
202 ok(params
->cArgs
== 0, "got %d\n", params
->cArgs
);
203 ok(params
->cNamedArgs
== 0, "got %d\n", params
->cNamedArgs
);
205 ok(res
!= NULL
, "got %p\n", res
);
206 ok(V_VT(res
) == VT_EMPTY
, "got %d\n", V_VT(res
));
207 ok(ei
== NULL
, "got %p\n", ei
);
208 ok(arg_err
== NULL
, "got %p\n", arg_err
);
210 if (FAILED(This
->result
))
213 V_VT(res
) = This
->vt
;
214 if (This
->vt
== VT_UI1
)
216 else if (This
->vt
== VT_NULL
)
222 memset(res
, 0, sizeof(*res
));
227 static const IDispatchVtbl DummyDispatch_VTable
=
229 DummyDispatch_QueryInterface
,
230 DummyDispatch_AddRef
,
231 DummyDispatch_Release
,
232 DummyDispatch_GetTypeInfoCount
,
233 DummyDispatch_GetTypeInfo
,
234 DummyDispatch_GetIDsOfNames
,
238 static void init_test_dispatch(VARTYPE vt
, DummyDispatch
*dispatch
)
240 dispatch
->IDispatch_iface
.lpVtbl
= &DummyDispatch_VTable
;
242 dispatch
->result
= S_OK
;
245 typedef struct IRecordInfoImpl
247 IRecordInfo IRecordInfo_iface
;
249 unsigned int recordclear
;
250 unsigned int getsize
;
251 unsigned int recordcopy
;
252 struct __tagBRECORD
*rec
;
255 static inline IRecordInfoImpl
*impl_from_IRecordInfo(IRecordInfo
*iface
)
257 return CONTAINING_RECORD(iface
, IRecordInfoImpl
, IRecordInfo_iface
);
260 static HRESULT WINAPI
RecordInfo_QueryInterface(IRecordInfo
*iface
, REFIID riid
, void **obj
)
264 if (IsEqualIID(riid
, &IID_IUnknown
) ||
265 IsEqualIID(riid
, &IID_IRecordInfo
))
268 IRecordInfo_AddRef(iface
);
272 return E_NOINTERFACE
;
275 static ULONG WINAPI
RecordInfo_AddRef(IRecordInfo
*iface
)
277 IRecordInfoImpl
* This
= impl_from_IRecordInfo(iface
);
278 return InterlockedIncrement(&This
->ref
);
281 static ULONG WINAPI
RecordInfo_Release(IRecordInfo
*iface
)
283 IRecordInfoImpl
* This
= impl_from_IRecordInfo(iface
);
284 ULONG ref
= InterlockedDecrement(&This
->ref
);
287 HeapFree(GetProcessHeap(), 0, This
);
292 static HRESULT WINAPI
RecordInfo_RecordInit(IRecordInfo
*iface
, PVOID pvNew
)
294 ok(0, "unexpected call\n");
298 static HRESULT WINAPI
RecordInfo_RecordClear(IRecordInfo
*iface
, void *data
)
300 IRecordInfoImpl
* This
= impl_from_IRecordInfo(iface
);
302 This
->rec
->pvRecord
= NULL
;
306 static HRESULT WINAPI
RecordInfo_RecordCopy(IRecordInfo
*iface
, void *src
, void *dest
)
308 IRecordInfoImpl
* This
= impl_from_IRecordInfo(iface
);
310 ok(src
== (void*)0xdeadbeef, "wrong src pointer %p\n", src
);
314 static HRESULT WINAPI
RecordInfo_GetGuid(IRecordInfo
*iface
, GUID
*pguid
)
316 ok(0, "unexpected call\n");
320 static HRESULT WINAPI
RecordInfo_GetName(IRecordInfo
*iface
, BSTR
*pbstrName
)
322 ok(0, "unexpected call\n");
326 static HRESULT WINAPI
RecordInfo_GetSize(IRecordInfo
*iface
, ULONG
* size
)
328 IRecordInfoImpl
* This
= impl_from_IRecordInfo(iface
);
334 static HRESULT WINAPI
RecordInfo_GetTypeInfo(IRecordInfo
*iface
, ITypeInfo
**ppTypeInfo
)
336 ok(0, "unexpected call\n");
340 static HRESULT WINAPI
RecordInfo_GetField(IRecordInfo
*iface
, PVOID pvData
,
341 LPCOLESTR szFieldName
, VARIANT
*pvarField
)
343 ok(0, "unexpected call\n");
347 static HRESULT WINAPI
RecordInfo_GetFieldNoCopy(IRecordInfo
*iface
, PVOID pvData
,
348 LPCOLESTR szFieldName
, VARIANT
*pvarField
, PVOID
*ppvDataCArray
)
350 ok(0, "unexpected call\n");
354 static HRESULT WINAPI
RecordInfo_PutField(IRecordInfo
*iface
, ULONG wFlags
, PVOID pvData
,
355 LPCOLESTR szFieldName
, VARIANT
*pvarField
)
357 ok(0, "unexpected call\n");
361 static HRESULT WINAPI
RecordInfo_PutFieldNoCopy(IRecordInfo
*iface
, ULONG wFlags
,
362 PVOID pvData
, LPCOLESTR szFieldName
, VARIANT
*pvarField
)
364 ok(0, "unexpected call\n");
368 static HRESULT WINAPI
RecordInfo_GetFieldNames(IRecordInfo
*iface
, ULONG
*pcNames
,
371 ok(0, "unexpected call\n");
375 static BOOL WINAPI
RecordInfo_IsMatchingType(IRecordInfo
*iface
, IRecordInfo
*info2
)
377 ok(0, "unexpected call\n");
381 static PVOID WINAPI
RecordInfo_RecordCreate(IRecordInfo
*iface
)
383 ok(0, "unexpected call\n");
387 static HRESULT WINAPI
RecordInfo_RecordCreateCopy(IRecordInfo
*iface
, PVOID pvSource
,
390 ok(0, "unexpected call\n");
394 static HRESULT WINAPI
RecordInfo_RecordDestroy(IRecordInfo
*iface
, PVOID pvRecord
)
396 ok(0, "unexpected call\n");
400 static const IRecordInfoVtbl RecordInfoVtbl
=
402 RecordInfo_QueryInterface
,
405 RecordInfo_RecordInit
,
406 RecordInfo_RecordClear
,
407 RecordInfo_RecordCopy
,
411 RecordInfo_GetTypeInfo
,
413 RecordInfo_GetFieldNoCopy
,
415 RecordInfo_PutFieldNoCopy
,
416 RecordInfo_GetFieldNames
,
417 RecordInfo_IsMatchingType
,
418 RecordInfo_RecordCreate
,
419 RecordInfo_RecordCreateCopy
,
420 RecordInfo_RecordDestroy
423 static IRecordInfoImpl
*get_test_recordinfo(void)
425 IRecordInfoImpl
*rec
;
427 rec
= HeapAlloc(GetProcessHeap(), 0, sizeof(IRecordInfoImpl
));
428 rec
->IRecordInfo_iface
.lpVtbl
= &RecordInfoVtbl
;
430 rec
->recordclear
= 0;
437 static void init(void)
442 res
= VarBstrFromBool(VARIANT_TRUE
, LANG_USER_DEFAULT
, VAR_LOCALBOOL
, &bstr
);
443 ok(res
== S_OK
&& bstr
[0], "Expected localized string for 'True'\n");
444 /* lstrcpyW / lstrcatW do not work on win95 */
445 memcpy(sz12_true
, sz12
, sizeof(sz12
));
446 if (bstr
) memcpy(&sz12_true
[2], bstr
, SysStringByteLen(bstr
) + sizeof(WCHAR
));
449 res
= VarBstrFromBool(VARIANT_FALSE
, LANG_USER_DEFAULT
, VAR_LOCALBOOL
, &bstr
);
450 ok(res
== S_OK
&& bstr
[0], "Expected localized string for 'False'\n");
451 memcpy(sz12_false
, sz12
, sizeof(sz12
));
452 if (bstr
) memcpy(&sz12_false
[2], bstr
, SysStringByteLen(bstr
) + sizeof(WCHAR
));
455 hOleaut32
= GetModuleHandleA("oleaut32.dll");
456 has_i8
= GetProcAddress(hOleaut32
, "VarI8FromI1") != NULL
;
458 skip("No support for I8 and UI8 data types\n");
461 /* Functions to set a DECIMAL */
462 static void setdec(DECIMAL
* dec
, BYTE scl
, BYTE sgn
, ULONG hi32
, ULONG64 lo64
)
464 S(U(*dec
)).scale
= scl
;
465 S(U(*dec
)).sign
= sgn
;
467 U1(*dec
).Lo64
= lo64
;
470 static void setdec64(DECIMAL
* dec
, BYTE scl
, BYTE sgn
, ULONG hi32
, ULONG mid32
, ULONG lo32
)
472 S(U(*dec
)).scale
= scl
;
473 S(U(*dec
)).sign
= sgn
;
475 S1(U1(*dec
)).Mid32
= mid32
;
476 S1(U1(*dec
)).Lo32
= lo32
;
479 /* return the string text of a given variant type */
480 static char vtstr_buffer
[16][256];
481 static int vtstr_current
=0;
482 static const char *vtstr(int x
)
485 #define CASE(vt) case VT_##vt: return #vt
524 CASE(STREAMED_OBJECT
);
529 CASE(VERSIONED_STREAM
);
538 return "VT_BSTR_BLOB/VT_ILLEGALMASKED/VT_TYPEMASK";
541 vtstr_current
%= ARRAY_SIZE(vtstr_buffer
);
542 sprintf(vtstr_buffer
[vtstr_current
], "unknown variant type %d", x
);
543 return vtstr_buffer
[vtstr_current
++];
547 static const char *variantstr( const VARIANT
*var
)
549 vtstr_current
%= ARRAY_SIZE(vtstr_buffer
);
553 sprintf( vtstr_buffer
[vtstr_current
], "VT_I1(%d)", V_I1(var
) ); break;
555 sprintf( vtstr_buffer
[vtstr_current
], "VT_I2(%d)", V_I2(var
) ); break;
557 sprintf( vtstr_buffer
[vtstr_current
], "VT_I4(%d)", V_I4(var
) ); break;
559 sprintf( vtstr_buffer
[vtstr_current
], "VT_INT(%d)", V_INT(var
) ); break;
561 sprintf( vtstr_buffer
[vtstr_current
], "VT_I8(%x%08x)", (UINT
)(V_I8(var
) >> 32), (UINT
)V_I8(var
) ); break;
563 sprintf( vtstr_buffer
[vtstr_current
], "VT_UI8(%x%08x)", (UINT
)(V_UI8(var
) >> 32), (UINT
)V_UI8(var
) ); break;
565 sprintf( vtstr_buffer
[vtstr_current
], "VT_R4(%g)", V_R4(var
) ); break;
567 sprintf( vtstr_buffer
[vtstr_current
], "VT_R8(%g)", V_R8(var
) ); break;
569 sprintf( vtstr_buffer
[vtstr_current
], "VT_UI1(%u)", V_UI1(var
) ); break;
571 sprintf( vtstr_buffer
[vtstr_current
], "VT_UI2(%u)", V_UI2(var
) ); break;
573 sprintf( vtstr_buffer
[vtstr_current
], "VT_UI4(%u)", V_UI4(var
) ); break;
575 sprintf( vtstr_buffer
[vtstr_current
], "VT_UINT(%d)", V_UINT(var
) ); break;
577 sprintf( vtstr_buffer
[vtstr_current
], "VT_CY(%x%08x)", S(V_CY(var
)).Hi
, S(V_CY(var
)).Lo
); break;
579 sprintf( vtstr_buffer
[vtstr_current
], "VT_DATE(%g)", V_DATE(var
) ); break;
581 return vtstr(V_VT(var
));
583 return vtstr_buffer
[vtstr_current
++];
586 static BOOL
is_expected_variant( const VARIANT
*result
, const VARIANT
*expected
)
588 if (V_VT(result
) != V_VT(expected
)) return FALSE
;
589 switch(V_VT(expected
))
595 #define CASE(vt) case VT_##vt: return (V_##vt(result) == V_##vt(expected))
610 return EQ_FLOAT(V_DATE(result
), V_DATE(expected
));
612 return EQ_FLOAT(V_R4(result
), V_R4(expected
));
614 return EQ_FLOAT(V_R8(result
), V_R8(expected
));
616 return (V_CY(result
).int64
== V_CY(expected
).int64
);
618 return !lstrcmpW( V_BSTR(result
), V_BSTR(expected
) );
620 return !memcmp( &V_DECIMAL(result
), &V_DECIMAL(expected
), sizeof(DECIMAL
) );
622 ok(0, "unhandled variant type %s\n",vtstr(V_VT(expected
)));
627 static void test_var_call1( int line
, HRESULT (WINAPI
*func
)(LPVARIANT
,LPVARIANT
),
628 VARIANT
*arg
, VARIANT
*expected
)
630 VARIANT old_arg
= *arg
;
634 memset( &result
, 0, sizeof(result
) );
635 hres
= func( arg
, &result
);
636 ok_(__FILE__
,line
)( hres
== S_OK
, "wrong result %x\n", hres
);
638 ok_(__FILE__
,line
)( is_expected_variant( &result
, expected
),
639 "got %s expected %s\n", variantstr(&result
), variantstr(expected
) );
640 ok_(__FILE__
,line
)( is_expected_variant( arg
, &old_arg
), "Modified argument %s / %s\n",
641 variantstr(&old_arg
), variantstr(arg
));
642 VariantClear( &result
);
645 static void test_var_call2( int line
, HRESULT (WINAPI
*func
)(LPVARIANT
,LPVARIANT
,LPVARIANT
),
646 VARIANT
*left
, VARIANT
*right
, VARIANT
*expected
)
648 VARIANT old_left
= *left
, old_right
= *right
;
652 memset( &result
, 0, sizeof(result
) );
653 hres
= func( left
, right
, &result
);
654 ok_(__FILE__
,line
)( hres
== S_OK
, "wrong result %x\n", hres
);
656 ok_(__FILE__
,line
)( is_expected_variant( &result
, expected
),
657 "got %s expected %s\n", variantstr(&result
), variantstr(expected
) );
658 ok_(__FILE__
,line
)( is_expected_variant( left
, &old_left
), "Modified left argument %s / %s\n",
659 variantstr(&old_left
), variantstr(left
));
660 ok_(__FILE__
,line
)( is_expected_variant( right
, &old_right
), "Modified right argument %s / %s\n",
661 variantstr(&old_right
), variantstr(right
));
662 VariantClear( &result
);
665 #define test_bstr_var(a,b) _test_bstr_var(__LINE__,a,b)
666 static void _test_bstr_var(unsigned line
, const VARIANT
*v
, const WCHAR
*str
)
668 ok_(__FILE__
,line
)(V_VT(v
) == VT_BSTR
, "unexpected vt=%d\n", V_VT(v
));
669 if(V_VT(v
) == VT_BSTR
)
670 ok(!lstrcmpW(V_BSTR(v
), str
), "v=%s, expected %s\n", wine_dbgstr_w(V_BSTR(v
)),
674 static void test_VariantInit(void)
678 memset(&v
, -1, sizeof(v
));
680 ok(V_VT(&v
) == VT_EMPTY
, "VariantInit() returned vt %d\n", V_VT(&v
));
683 /* All possible combinations of extra V_VT() flags */
684 static const VARTYPE ExtraFlags
[16] =
693 VT_VECTOR
|VT_RESERVED
,
694 VT_VECTOR
|VT_ARRAY
|VT_BYREF
,
695 VT_VECTOR
|VT_ARRAY
|VT_RESERVED
,
696 VT_VECTOR
|VT_BYREF
|VT_RESERVED
,
697 VT_VECTOR
|VT_ARRAY
|VT_BYREF
|VT_RESERVED
,
699 VT_ARRAY
|VT_RESERVED
,
700 VT_ARRAY
|VT_BYREF
|VT_RESERVED
,
701 VT_BYREF
|VT_RESERVED
,
704 /* Determine if a vt is valid for VariantClear() */
705 static BOOL
IsValidVariantClearVT(VARTYPE vt
, VARTYPE extraFlags
)
709 /* Only the following flags/types are valid */
710 if ((vt
<= VT_LPWSTR
|| vt
== VT_RECORD
|| vt
== VT_CLSID
) &&
712 (vt
< (VARTYPE
)24 || vt
> (VARTYPE
)31) &&
713 (!(extraFlags
& (VT_BYREF
|VT_ARRAY
)) || vt
> VT_NULL
) &&
714 (extraFlags
== 0 || extraFlags
== VT_BYREF
|| extraFlags
== VT_ARRAY
||
715 extraFlags
== (VT_ARRAY
|VT_BYREF
)))
718 if (!has_i8
&& (vt
== VT_I8
|| vt
== VT_UI8
))
719 ret
= FALSE
; /* Old versions of oleaut32 */
725 IUnknown IUnknown_iface
;
728 } test_VariantClearImpl
;
730 static inline test_VariantClearImpl
*impl_from_IUnknown(IUnknown
*iface
)
732 return CONTAINING_RECORD(iface
, test_VariantClearImpl
, IUnknown_iface
);
735 static HRESULT WINAPI
VC_QueryInterface(LPUNKNOWN iface
,REFIID riid
,LPVOID
*ppobj
)
737 test_VariantClearImpl
*This
= impl_from_IUnknown(iface
);
739 return E_NOINTERFACE
;
742 static ULONG WINAPI
VC_AddRef(LPUNKNOWN iface
) {
743 test_VariantClearImpl
*This
= impl_from_IUnknown(iface
);
745 return InterlockedIncrement(&This
->ref
);
748 static ULONG WINAPI
VC_Release(LPUNKNOWN iface
) {
749 test_VariantClearImpl
*This
= impl_from_IUnknown(iface
);
750 /* static class, won't be freed */
752 return InterlockedDecrement(&This
->ref
);
755 static const IUnknownVtbl test_VariantClear_vtbl
= {
761 static test_VariantClearImpl test_myVariantClearImpl
= {{&test_VariantClear_vtbl
}, 1, 0};
763 static void test_VariantClear(void)
765 struct __tagBRECORD
*rec
;
766 IRecordInfoImpl
*recinfo
;
774 /* Crashes: Native does not test input for NULL, so neither does Wine */
778 /* Only the type field is set, to VT_EMPTY */
781 hres
= VariantClear(&v
);
782 ok((hres
== S_OK
&& V_VT(&v
) == VT_EMPTY
),
783 "VariantClear: Type set to %d, res %08x\n", V_VT(&v
), hres
);
784 ok(V_UI4(&v
) == ~0u, "VariantClear: Overwrote value\n");
786 /* Test all possible V_VT values.
787 * Also demonstrates that null pointers in 'v' are not dereferenced.
788 * Individual variant tests should test VariantClear() with non-NULL values.
790 for (i
= 0; i
< ARRAY_SIZE(ExtraFlags
); i
++)
794 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
796 HRESULT hExpected
= DISP_E_BADVARTYPE
;
800 memset(&v
, 0, sizeof(v
));
801 V_VT(&v
) = vt
| ExtraFlags
[i
];
803 hres
= VariantClear(&v
);
805 if (IsValidVariantClearVT(vt
, ExtraFlags
[i
]))
808 ok(hres
== hExpected
, "VariantClear: expected 0x%X, got 0x%X for vt %d | 0x%X\n",
809 hExpected
, hres
, vt
, ExtraFlags
[i
]);
813 /* Some BYREF tests with non-NULL ptrs */
818 V_VT(&v
) = VT_VARIANT
| VT_BYREF
;
819 V_VARIANTREF(&v
) = &v2
;
821 hres
= VariantClear(&v
);
822 ok(hres
== S_OK
, "ret %08x\n", hres
);
823 ok(V_VT(&v
) == 0, "vt %04x\n", V_VT(&v
));
824 ok(V_VARIANTREF(&v
) == &v2
, "variant ref %p\n", V_VARIANTREF(&v2
));
825 ok(V_VT(&v2
) == VT_I4
, "vt %04x\n", V_VT(&v2
));
826 ok(V_I4(&v2
) == 0x1234, "i4 %04x\n", V_I4(&v2
));
830 V_VT(&v
) = VT_I4
| VT_BYREF
;
833 hres
= VariantClear(&v
);
834 ok(hres
== S_OK
, "ret %08x\n", hres
);
835 ok(V_VT(&v
) == 0, "vt %04x\n", V_VT(&v
));
836 ok(V_I4REF(&v
) == &i4
, "i4 ref %p\n", V_I4REF(&v2
));
837 ok(i4
== 0x4321, "i4 changed %08x\n", i4
);
841 V_VT(&v
) = VT_UNKNOWN
;
842 V_UNKNOWN(&v
) = &test_myVariantClearImpl
.IUnknown_iface
;
843 test_myVariantClearImpl
.events
= 0;
844 hres
= VariantClear(&v
);
845 ok(hres
== S_OK
, "ret %08x\n", hres
);
846 ok(V_VT(&v
) == 0, "vt %04x\n", V_VT(&v
));
847 ok(V_UNKNOWN(&v
) == &test_myVariantClearImpl
.IUnknown_iface
, "unknown %p\n", V_UNKNOWN(&v
));
848 /* Check that Release got called, but nothing else */
849 ok(test_myVariantClearImpl
.events
== 0x4, "Unexpected call. events %08x\n", test_myVariantClearImpl
.events
);
852 punk
= &test_myVariantClearImpl
.IUnknown_iface
;
853 V_VT(&v
) = VT_UNKNOWN
| VT_BYREF
;
854 V_UNKNOWNREF(&v
) = &punk
;
855 test_myVariantClearImpl
.events
= 0;
856 hres
= VariantClear(&v
);
857 ok(hres
== S_OK
, "ret %08x\n", hres
);
858 ok(V_VT(&v
) == 0, "vt %04x\n", V_VT(&v
));
859 ok(V_UNKNOWNREF(&v
) == &punk
, "unknown ref %p\n", V_UNKNOWNREF(&v
));
860 /* Check that nothing got called */
861 ok(test_myVariantClearImpl
.events
== 0, "Unexpected call. events %08x\n", test_myVariantClearImpl
.events
);
864 V_VT(&v
) = VT_DISPATCH
;
865 V_DISPATCH(&v
) = (IDispatch
*)&test_myVariantClearImpl
.IUnknown_iface
;
866 test_myVariantClearImpl
.events
= 0;
867 hres
= VariantClear(&v
);
868 ok(hres
== S_OK
, "ret %08x\n", hres
);
869 ok(V_VT(&v
) == 0, "vt %04x\n", V_VT(&v
));
870 ok(V_DISPATCH(&v
) == (IDispatch
*)&test_myVariantClearImpl
.IUnknown_iface
,
871 "dispatch %p\n", V_DISPATCH(&v
));
872 /* Check that Release got called, but nothing else */
873 ok(test_myVariantClearImpl
.events
== 0x4, "Unexpected call. events %08x\n", test_myVariantClearImpl
.events
);
876 punk
= &test_myVariantClearImpl
.IUnknown_iface
;
877 V_VT(&v
) = VT_DISPATCH
| VT_BYREF
;
878 V_DISPATCHREF(&v
) = (IDispatch
**)&punk
;
879 test_myVariantClearImpl
.events
= 0;
880 hres
= VariantClear(&v
);
881 ok(hres
== S_OK
, "ret %08x\n", hres
);
882 ok(V_VT(&v
) == 0, "vt %04x\n", V_VT(&v
));
883 ok(V_DISPATCHREF(&v
) == (IDispatch
**)&punk
, "dispatch ref %p\n", V_DISPATCHREF(&v
));
884 /* Check that nothing got called */
885 ok(test_myVariantClearImpl
.events
== 0, "Unexpected call. events %08x\n", test_myVariantClearImpl
.events
);
888 recinfo
= get_test_recordinfo();
889 V_VT(&v
) = VT_RECORD
;
890 rec
= &V_UNION(&v
, brecVal
);
891 rec
->pRecInfo
= &recinfo
->IRecordInfo_iface
;
892 rec
->pvRecord
= (void*)0xdeadbeef;
893 recinfo
->recordclear
= 0;
896 hres
= VariantClear(&v
);
897 ok(hres
== S_OK
, "ret %08x\n", hres
);
898 ok(rec
->pvRecord
== NULL
, "got %p\n", rec
->pvRecord
);
899 ok(recinfo
->recordclear
== 1, "got %d\n", recinfo
->recordclear
);
900 ok(recinfo
->ref
== 1, "got %d\n", recinfo
->ref
);
901 IRecordInfo_Release(&recinfo
->IRecordInfo_iface
);
904 static void test_VariantCopy(void)
906 struct __tagBRECORD
*rec
;
907 IRecordInfoImpl
*recinfo
;
908 VARIANTARG vSrc
, vDst
;
911 HRESULT hres
, hExpected
;
913 /* Establish that the failure/other cases are dealt with. Individual tests
914 * for each type should verify that data is copied correctly, references
919 for (i
= 0; i
< ARRAY_SIZE(ExtraFlags
); i
++)
921 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
925 memset(&vSrc
, 0, sizeof(vSrc
));
926 V_VT(&vSrc
) = vt
| ExtraFlags
[i
];
928 hExpected
= DISP_E_BADVARTYPE
;
929 /* src is allowed to be a VT_CLSID */
930 if (vt
!= VT_CLSID
&& IsValidVariantClearVT(vt
, ExtraFlags
[i
]))
933 hres
= VariantCopy(&vSrc
, &vSrc
);
935 ok(hres
== hExpected
,
936 "Copy(src==dst): expected 0x%X, got 0x%X for src==dest vt %d|0x%X\n",
937 hExpected
, hres
, vt
, ExtraFlags
[i
]);
941 /* Test that if VariantClear() fails on dest, the function fails. This also
942 * shows that dest is in fact cleared and not just overwritten
944 memset(&vSrc
, 0, sizeof(vSrc
));
945 V_VT(&vSrc
) = VT_UI1
;
947 for (i
= 0; i
< ARRAY_SIZE(ExtraFlags
); i
++)
949 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
953 hExpected
= DISP_E_BADVARTYPE
;
955 memset(&vDst
, 0, sizeof(vDst
));
956 V_VT(&vDst
) = vt
| ExtraFlags
[i
];
958 if (IsValidVariantClearVT(vt
, ExtraFlags
[i
]))
961 hres
= VariantCopy(&vDst
, &vSrc
);
963 ok(hres
== hExpected
,
964 "Copy(bad dst): expected 0x%X, got 0x%X for dest vt %d|0x%X\n",
965 hExpected
, hres
, vt
, ExtraFlags
[i
]);
967 ok(V_VT(&vDst
) == VT_UI1
,
968 "Copy(bad dst): expected vt = VT_UI1, got %d\n", V_VT(&vDst
));
972 /* Test that VariantClear() checks vSrc for validity before copying */
973 for (i
= 0; i
< ARRAY_SIZE(ExtraFlags
); i
++)
975 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
979 hExpected
= DISP_E_BADVARTYPE
;
981 memset(&vDst
, 0, sizeof(vDst
));
982 V_VT(&vDst
) = VT_EMPTY
;
984 memset(&vSrc
, 0, sizeof(vSrc
));
985 V_VT(&vSrc
) = vt
| ExtraFlags
[i
];
987 /* src is allowed to be a VT_CLSID */
988 if (vt
!= VT_CLSID
&& IsValidVariantClearVT(vt
, ExtraFlags
[i
]))
991 hres
= VariantCopy(&vDst
, &vSrc
);
993 ok(hres
== hExpected
,
994 "Copy(bad src): expected 0x%X, got 0x%X for src vt %d|0x%X\n",
995 hExpected
, hres
, vt
, ExtraFlags
[i
]);
998 ok(V_VT(&vDst
) == (vt
|ExtraFlags
[i
]),
999 "Copy(bad src): expected vt = %d, got %d\n",
1000 vt
| ExtraFlags
[i
], V_VT(&vDst
));
1001 VariantClear(&vDst
);
1006 /* Test that copying a NULL BSTR results in an empty BSTR */
1007 memset(&vDst
, 0, sizeof(vDst
));
1008 V_VT(&vDst
) = VT_EMPTY
;
1009 memset(&vSrc
, 0, sizeof(vSrc
));
1010 V_VT(&vSrc
) = VT_BSTR
;
1011 hres
= VariantCopy(&vDst
, &vSrc
);
1012 ok(hres
== S_OK
, "Copy(NULL BSTR): Failed to copy a NULL BSTR\n");
1015 ok((V_VT(&vDst
) == VT_BSTR
) && V_BSTR(&vDst
),
1016 "Copy(NULL BSTR): should have non-NULL result\n");
1017 if ((V_VT(&vDst
) == VT_BSTR
) && V_BSTR(&vDst
))
1019 ok(*V_BSTR(&vDst
) == 0, "Copy(NULL BSTR): result not empty\n");
1021 VariantClear(&vDst
);
1025 recinfo
= get_test_recordinfo();
1027 memset(&vDst
, 0, sizeof(vDst
));
1028 V_VT(&vDst
) = VT_EMPTY
;
1030 V_VT(&vSrc
) = VT_RECORD
;
1031 rec
= &V_UNION(&vSrc
, brecVal
);
1032 rec
->pRecInfo
= &recinfo
->IRecordInfo_iface
;
1033 rec
->pvRecord
= (void*)0xdeadbeef;
1035 recinfo
->recordclear
= 0;
1036 recinfo
->recordcopy
= 0;
1037 recinfo
->getsize
= 0;
1039 hres
= VariantCopy(&vDst
, &vSrc
);
1040 ok(hres
== S_OK
, "ret %08x\n", hres
);
1042 rec
= &V_UNION(&vDst
, brecVal
);
1043 ok(rec
->pvRecord
!= (void*)0xdeadbeef && rec
->pvRecord
!= NULL
, "got %p\n", rec
->pvRecord
);
1044 ok(rec
->pRecInfo
== &recinfo
->IRecordInfo_iface
, "got %p\n", rec
->pRecInfo
);
1045 ok(recinfo
->getsize
== 1, "got %d\n", recinfo
->recordclear
);
1046 ok(recinfo
->recordcopy
== 1, "got %d\n", recinfo
->recordclear
);
1048 VariantClear(&vDst
);
1049 VariantClear(&vSrc
);
1052 /* Determine if a vt is valid for VariantCopyInd() */
1053 static BOOL
IsValidVariantCopyIndVT(VARTYPE vt
, VARTYPE extraFlags
)
1057 if ((extraFlags
& VT_ARRAY
) ||
1058 (vt
> VT_NULL
&& vt
!= (VARTYPE
)15 && vt
< VT_VOID
&&
1059 !(extraFlags
& (VT_VECTOR
|VT_RESERVED
))))
1061 ret
= TRUE
; /* ok */
1066 static void test_VariantCopyInd(void)
1068 VARIANTARG vSrc
, vDst
, vRef
, vRef2
;
1072 HRESULT hres
, hExpected
;
1074 memset(buffer
, 0, sizeof(buffer
));
1077 for (i
= 0; i
< ARRAY_SIZE(ExtraFlags
); i
++)
1079 if (ExtraFlags
[i
] & VT_ARRAY
)
1080 continue; /* Native crashes on NULL safearray */
1082 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
1086 memset(&vSrc
, 0, sizeof(vSrc
));
1087 V_VT(&vSrc
) = vt
| ExtraFlags
[i
];
1089 hExpected
= DISP_E_BADVARTYPE
;
1090 if (!(ExtraFlags
[i
] & VT_BYREF
))
1092 /* if src is not by-reference, acts as VariantCopy() */
1093 if (vt
!= VT_CLSID
&& IsValidVariantClearVT(vt
, ExtraFlags
[i
]))
1098 if (vt
== VT_SAFEARRAY
|| vt
== VT_BSTR
|| vt
== VT_UNKNOWN
||
1099 vt
== VT_DISPATCH
|| vt
== VT_RECORD
)
1100 continue; /* Need valid ptrs for deep copies */
1102 V_BYREF(&vSrc
) = &buffer
;
1103 hExpected
= E_INVALIDARG
;
1105 if ((vt
== VT_I8
|| vt
== VT_UI8
) &&
1106 ExtraFlags
[i
] == VT_BYREF
)
1109 hExpected
= S_OK
; /* Only valid if I8 is a known type */
1111 else if (IsValidVariantCopyIndVT(vt
, ExtraFlags
[i
]))
1115 hres
= VariantCopyInd(&vSrc
, &vSrc
);
1117 ok(hres
== hExpected
,
1118 "CopyInd(src==dst): expected 0x%X, got 0x%X for src==dst vt %d|0x%X\n",
1119 hExpected
, hres
, vt
, ExtraFlags
[i
]);
1124 memset(&vSrc
, 0, sizeof(vSrc
));
1125 V_VT(&vSrc
) = VT_UI1
|VT_BYREF
;
1126 V_BYREF(&vSrc
) = &buffer
;
1128 for (i
= 0; i
< ARRAY_SIZE(ExtraFlags
); i
++)
1130 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
1134 memset(&vDst
, 0, sizeof(vDst
));
1135 V_VT(&vDst
) = vt
| ExtraFlags
[i
];
1137 hExpected
= DISP_E_BADVARTYPE
;
1139 if (IsValidVariantClearVT(vt
, ExtraFlags
[i
]))
1142 hres
= VariantCopyInd(&vDst
, &vSrc
);
1144 ok(hres
== hExpected
,
1145 "CopyInd(bad dst): expected 0x%X, got 0x%X for dst vt %d|0x%X\n",
1146 hExpected
, hres
, vt
, ExtraFlags
[i
]);
1148 ok(V_VT(&vDst
) == VT_UI1
,
1149 "CopyInd(bad dst): expected vt = VT_UI1, got %d\n", V_VT(&vDst
));
1154 for (i
= 0; i
< ARRAY_SIZE(ExtraFlags
); i
++)
1156 if (ExtraFlags
[i
] & VT_ARRAY
)
1157 continue; /* Native crashes on NULL safearray */
1159 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
1163 memset(&vDst
, 0, sizeof(vDst
));
1164 V_VT(&vDst
) = VT_EMPTY
;
1166 memset(&vSrc
, 0, sizeof(vSrc
));
1167 V_VT(&vSrc
) = vt
| ExtraFlags
[i
];
1169 hExpected
= DISP_E_BADVARTYPE
;
1170 if (!(ExtraFlags
[i
] & VT_BYREF
))
1172 /* if src is not by-reference, acts as VariantCopy() */
1173 if (vt
!= VT_CLSID
&& IsValidVariantClearVT(vt
, ExtraFlags
[i
]))
1178 if (vt
== VT_SAFEARRAY
|| vt
== VT_BSTR
|| vt
== VT_UNKNOWN
||
1179 vt
== VT_DISPATCH
|| vt
== VT_RECORD
)
1180 continue; /* Need valid ptrs for deep copies, see vartype.c */
1182 V_BYREF(&vSrc
) = &buffer
;
1184 hExpected
= E_INVALIDARG
;
1186 if ((vt
== VT_I8
|| vt
== VT_UI8
) &&
1187 ExtraFlags
[i
] == VT_BYREF
)
1190 hExpected
= S_OK
; /* Only valid if I8 is a known type */
1192 else if (IsValidVariantCopyIndVT(vt
, ExtraFlags
[i
]))
1196 hres
= VariantCopyInd(&vDst
, &vSrc
);
1198 ok(hres
== hExpected
,
1199 "CopyInd(bad src): expected 0x%X, got 0x%X for src vt %d|0x%X\n",
1200 hExpected
, hres
, vt
, ExtraFlags
[i
]);
1203 if (vt
== VT_VARIANT
&& ExtraFlags
[i
] == VT_BYREF
)
1205 /* Type of vDst should be the type of the referenced variant.
1206 * Since we set the buffer to all zeros, its type should be
1209 ok(V_VT(&vDst
) == VT_EMPTY
,
1210 "CopyInd(bad src): expected dst vt = VT_EMPTY, got %d|0x%X\n",
1211 V_VT(&vDst
) & VT_TYPEMASK
, V_VT(&vDst
) & ~VT_TYPEMASK
);
1215 ok(V_VT(&vDst
) == (vt
|(ExtraFlags
[i
] & ~VT_BYREF
)),
1216 "CopyInd(bad src): expected dst vt = %d|0x%X, got %d|0x%X\n",
1217 vt
, ExtraFlags
[i
] & ~VT_BYREF
,
1218 V_VT(&vDst
) & VT_TYPEMASK
, V_VT(&vDst
) & ~VT_TYPEMASK
);
1220 VariantClear(&vDst
);
1225 /* By-reference variants are dereferenced */
1226 V_VT(&vRef
) = VT_UI1
;
1227 V_UI1(&vRef
) = 0x77;
1228 V_VT(&vSrc
) = VT_VARIANT
|VT_BYREF
;
1229 V_VARIANTREF(&vSrc
) = &vRef
;
1232 hres
= VariantCopyInd(&vDst
, &vSrc
);
1233 ok(hres
== S_OK
, "VariantCopyInd failed: 0x%08x\n", hres
);
1234 ok(V_VT(&vDst
) == VT_UI1
&& V_UI1(&vDst
) == 0x77,
1235 "CopyInd(deref): expected dst vt = VT_UI1, val 0x77, got %d|0x%X, 0x%2X\n",
1236 V_VT(&vDst
) & VT_TYPEMASK
, V_VT(&vDst
) & ~VT_TYPEMASK
, V_UI1(&vDst
));
1238 /* By-reference variant to a by-reference type succeeds */
1239 V_VT(&vRef
) = VT_UI1
|VT_BYREF
;
1240 V_UI1REF(&vRef
) = buffer
; buffer
[0] = 0x88;
1241 V_VT(&vSrc
) = VT_VARIANT
|VT_BYREF
;
1242 V_VARIANTREF(&vSrc
) = &vRef
;
1245 hres
= VariantCopyInd(&vDst
, &vSrc
);
1246 ok(hres
== S_OK
, "VariantCopyInd failed: 0x%08x\n", hres
);
1247 ok(V_VT(&vDst
) == VT_UI1
&& V_UI1(&vDst
) == 0x88,
1248 "CopyInd(deref): expected dst vt = VT_UI1, val 0x77, got %d|0x%X, 0x%2X\n",
1249 V_VT(&vDst
) & VT_TYPEMASK
, V_VT(&vDst
) & ~VT_TYPEMASK
, V_UI1(&vDst
));
1251 /* But a by-reference variant to a by-reference variant fails */
1252 V_VT(&vRef2
) = VT_UI1
;
1253 V_UI1(&vRef2
) = 0x77;
1254 V_VT(&vRef
) = VT_VARIANT
|VT_BYREF
;
1255 V_VARIANTREF(&vRef
) = &vRef2
;
1256 V_VT(&vSrc
) = VT_VARIANT
|VT_BYREF
;
1257 V_VARIANTREF(&vSrc
) = &vRef
;
1260 hres
= VariantCopyInd(&vDst
, &vSrc
);
1261 ok(hres
== E_INVALIDARG
,
1262 "CopyInd(ref->ref): expected E_INVALIDARG, got 0x%08x\n", hres
);
1265 static HRESULT (WINAPI
*pVarParseNumFromStr
)(OLECHAR
*,LCID
,ULONG
,NUMPARSE
*,BYTE
*);
1267 /* Macros for converting and testing the result of VarParseNumFromStr */
1270 static HRESULT
convert_str( const char *str
, INT dig
, ULONG flags
,
1271 NUMPARSE
*np
, BYTE rgb
[128], LCID lcid
)
1274 MultiByteToWideChar( CP_ACP
,0, str
, -1, buff
, ARRAY_SIZE( buff
));
1275 memset( rgb
, FAILDIG
, 128 );
1276 memset( np
, 255, sizeof(*np
) );
1278 np
->dwInFlags
= flags
;
1279 return pVarParseNumFromStr( buff
, lcid
, LOCALE_NOUSEROVERRIDE
, np
, rgb
);
1282 static void expect_NumFromStr( int line
, HRESULT hres
, NUMPARSE
*np
, INT a
, ULONG b
, ULONG c
,
1283 INT d
, INT e
, INT f
)
1285 if (hres
== (HRESULT
)S_OK
)
1287 ok_(__FILE__
,line
)(np
->cDig
== a
, "Expected cDig = %d, got %d\n", a
, np
->cDig
);
1288 ok_(__FILE__
,line
)(np
->dwInFlags
== b
, "Expected dwInFlags = 0x%x, got 0x%x\n", b
, np
->dwInFlags
);
1289 ok_(__FILE__
,line
)(np
->dwOutFlags
== c
, "Expected dwOutFlags = 0x%x, got 0x%x\n", c
, np
->dwOutFlags
);
1290 ok_(__FILE__
,line
)(np
->cchUsed
== d
, "Expected cchUsed = %d, got %d\n", d
, np
->cchUsed
);
1291 ok_(__FILE__
,line
)(np
->nBaseShift
== e
, "Expected nBaseShift = %d, got %d\n", e
, np
->nBaseShift
);
1292 ok_(__FILE__
,line
)(np
->nPwr10
== f
, "Expected nPwr10 = %d, got %d\n", f
, np
->nPwr10
);
1296 #define CONVERTN(str,dig,flags) hres = convert_str( str, dig, flags, &np, rgb, lcid )
1297 #define CONVERT(str,flags) CONVERTN(str,sizeof(rgb),flags)
1298 #define EXPECT(a,b,c,d,e,f) expect_NumFromStr( __LINE__, hres, &np, a, b, c, d, e, f )
1299 #define EXPECTRGB(a,b) ok(rgb[a] == b, "Digit[%d], expected %d, got %d\n", a, b, rgb[a])
1300 #define EXPECTFAIL ok(hres == (HRESULT)DISP_E_TYPEMISMATCH, "Call succeeded, hres = %08x\n", hres)
1301 #define EXPECT2(a,b) EXPECTRGB(0,a); EXPECTRGB(1,b)
1303 static void test_VarParseNumFromStr(void)
1306 /* Ensure all tests are using the same locale characters for '$', ',' etc */
1307 LCID lcid
= MAKELCID(MAKELANGID(LANG_ENGLISH
,SUBLANG_ENGLISH_US
),SORT_DEFAULT
);
1314 CHECKPTR(VarParseNumFromStr
);
1316 /* Consume a single digit */
1318 EXPECT(1,0,0,1,0,0);
1321 /* cDig is not literal digits - zeros are suppressed and nPwr10 is increased */
1323 EXPECT(1,0,0,2,0,1);
1324 /* Note: Win32 writes the trailing zeros if they are within cDig's limits,
1325 * but then excludes them from the returned cDig count.
1326 * In our implementation we don't bother writing them at all.
1330 /* if cDig is too small and numbers follow, sets INEXACT */
1331 CONVERTN("11",1, 0);
1332 EXPECT(1,0,NUMPRS_INEXACT
,2,0,1);
1335 /* Strips leading zeros */
1337 EXPECT(1,0,0,2,0,0);
1340 /* Strips leading zeros */
1341 CONVERTN("01",1, 0);
1342 EXPECT(1,0,0,2,0,0);
1346 /* Fails on non digits */
1349 EXPECTRGB(0,FAILDIG
);
1351 /** NUMPRS_LEADING_WHITE/NUMPRS_TRAILING_WHITE **/
1353 /* Without flag, fails on whitespace */
1356 EXPECTRGB(0,FAILDIG
);
1359 /* With flag, consumes whitespace */
1360 CONVERT(" 0", NUMPRS_LEADING_WHITE
);
1361 EXPECT(1,NUMPRS_LEADING_WHITE
,NUMPRS_LEADING_WHITE
,2,0,0);
1364 /* Test TAB once, then assume it acts as space for all cases */
1365 CONVERT("\t0", NUMPRS_LEADING_WHITE
);
1366 EXPECT(1,NUMPRS_LEADING_WHITE
,NUMPRS_LEADING_WHITE
,2,0,0);
1370 /* Doesn't pick up trailing whitespace without flag */
1372 EXPECT(1,0,0,1,0,0);
1375 /* With flag, consumes trailing whitespace */
1376 CONVERT("0 ", NUMPRS_TRAILING_WHITE
);
1377 EXPECT(1,NUMPRS_TRAILING_WHITE
,NUMPRS_TRAILING_WHITE
,2,0,0);
1380 /* Leading flag only consumes leading */
1381 CONVERT(" 0 ", NUMPRS_LEADING_WHITE
);
1382 EXPECT(1,NUMPRS_LEADING_WHITE
,NUMPRS_LEADING_WHITE
,2,0,0);
1385 /* Both flags consumes both */
1386 CONVERT(" 0 ", NUMPRS_LEADING_WHITE
|NUMPRS_TRAILING_WHITE
);
1387 EXPECT(1,NUMPRS_LEADING_WHITE
|NUMPRS_TRAILING_WHITE
,NUMPRS_LEADING_WHITE
|NUMPRS_TRAILING_WHITE
,3,0,0);
1390 /** NUMPRS_LEADING_PLUS/NUMPRS_TRAILING_PLUS **/
1392 /* Without flag, fails on + */
1395 EXPECTRGB(0,FAILDIG
);
1397 /* With flag, consumes + */
1398 CONVERT("+0", NUMPRS_LEADING_PLUS
);
1399 EXPECT(1,NUMPRS_LEADING_PLUS
,NUMPRS_LEADING_PLUS
,2,0,0);
1402 /* Without flag, doesn't consume trailing + */
1404 EXPECT(1,0,0,1,0,0);
1407 /* With flag, consumes trailing + */
1408 CONVERT("0+", NUMPRS_TRAILING_PLUS
);
1409 EXPECT(1,NUMPRS_TRAILING_PLUS
,NUMPRS_TRAILING_PLUS
,2,0,0);
1412 /* With leading flag, doesn't consume trailing + */
1413 CONVERT("+0+", NUMPRS_LEADING_PLUS
);
1414 EXPECT(1,NUMPRS_LEADING_PLUS
,NUMPRS_LEADING_PLUS
,2,0,0);
1417 /* Trailing + doesn't get consumed if we specify both (unlike whitespace) */
1418 CONVERT("+0+", NUMPRS_LEADING_PLUS
|NUMPRS_TRAILING_PLUS
);
1419 EXPECT(1,NUMPRS_LEADING_PLUS
|NUMPRS_TRAILING_PLUS
,NUMPRS_LEADING_PLUS
,2,0,0);
1422 /** NUMPRS_LEADING_MINUS/NUMPRS_TRAILING_MINUS **/
1424 /* Without flag, fails on - */
1427 EXPECTRGB(0,FAILDIG
);
1429 /* With flag, consumes - */
1430 CONVERT("-0", NUMPRS_LEADING_MINUS
);
1431 EXPECT(1,NUMPRS_LEADING_MINUS
,NUMPRS_NEG
|NUMPRS_LEADING_MINUS
,2,0,0);
1434 /* Without flag, doesn't consume trailing - */
1436 EXPECT(1,0,0,1,0,0);
1439 /* With flag, consumes trailing - */
1440 CONVERT("0-", NUMPRS_TRAILING_MINUS
);
1441 EXPECT(1,NUMPRS_TRAILING_MINUS
,NUMPRS_NEG
|NUMPRS_TRAILING_MINUS
,2,0,0);
1444 /* With leading flag, doesn't consume trailing - */
1445 CONVERT("-0-", NUMPRS_LEADING_MINUS
);
1446 EXPECT(1,NUMPRS_LEADING_MINUS
,NUMPRS_NEG
|NUMPRS_LEADING_MINUS
,2,0,0);
1449 /* Trailing - doesn't get consumed if we specify both (unlike whitespace) */
1450 CONVERT("-0-", NUMPRS_LEADING_MINUS
|NUMPRS_TRAILING_MINUS
);
1451 EXPECT(1,NUMPRS_LEADING_MINUS
|NUMPRS_TRAILING_MINUS
,NUMPRS_NEG
|NUMPRS_LEADING_MINUS
,2,0,0);
1454 /** NUMPRS_HEX_OCT **/
1456 /* Could be hex, octal or decimal - With flag reads as decimal */
1457 CONVERT("0", NUMPRS_HEX_OCT
);
1458 EXPECT(1,NUMPRS_HEX_OCT
,0,1,0,0);
1461 /* Doesn't recognise hex in .asm syntax */
1462 CONVERT("0h", NUMPRS_HEX_OCT
);
1463 EXPECT(1,NUMPRS_HEX_OCT
,0,1,0,0);
1466 /* Doesn't fail with valid leading string but no digits */
1467 CONVERT("0x", NUMPRS_HEX_OCT
);
1468 EXPECT(1,NUMPRS_HEX_OCT
,0,1,0,0);
1471 /* Doesn't recognise hex format numbers at all! */
1472 CONVERT("0x0", NUMPRS_HEX_OCT
);
1473 EXPECT(1,NUMPRS_HEX_OCT
,0,1,0,0);
1476 /* Doesn't recognise plain hex digits either */
1477 CONVERT("FE", NUMPRS_HEX_OCT
);
1479 EXPECTRGB(0,FAILDIG
);
1482 CONVERT("0100", NUMPRS_HEX_OCT
);
1483 EXPECT(1,NUMPRS_HEX_OCT
,0,4,0,2);
1487 EXPECTRGB(3,FAILDIG
);
1490 CONVERT("&HF800", NUMPRS_HEX_OCT
);
1491 EXPECT(4,NUMPRS_HEX_OCT
,0x40,6,4,0);
1496 EXPECTRGB(4,FAILDIG
);
1498 /* VB hex lower case and leading zero */
1499 CONVERT("&h0abcdef", NUMPRS_HEX_OCT
);
1500 EXPECT(6,NUMPRS_HEX_OCT
,0x40,9,4,0);
1507 EXPECTRGB(6,FAILDIG
);
1510 CONVERT("&O300", NUMPRS_HEX_OCT
);
1511 EXPECT(3,NUMPRS_HEX_OCT
,0x40,5,3,0);
1515 EXPECTRGB(3,FAILDIG
);
1517 /* VB oct lower case and leading zero */
1518 CONVERT("&o0777", NUMPRS_HEX_OCT
);
1519 EXPECT(3,NUMPRS_HEX_OCT
,0x40,6,3,0);
1523 EXPECTRGB(3,FAILDIG
);
1525 /* VB oct char bigger than 7 */
1526 CONVERT("&o128", NUMPRS_HEX_OCT
);
1527 EXPECT(2,NUMPRS_HEX_OCT
,0x40,4,3,0);
1530 EXPECTRGB(3,FAILDIG
);
1532 /** NUMPRS_PARENS **/
1534 /* Empty parens = error */
1535 CONVERT("()", NUMPRS_PARENS
);
1537 EXPECTRGB(0,FAILDIG
);
1539 /* With flag, trailing parens not consumed */
1540 CONVERT("0()", NUMPRS_PARENS
);
1541 EXPECT(1,NUMPRS_PARENS
,0,1,0,0);
1544 /* With flag, Number in parens made negative and parens consumed */
1545 CONVERT("(0)", NUMPRS_PARENS
);
1546 EXPECT(1,NUMPRS_PARENS
,NUMPRS_NEG
|NUMPRS_PARENS
,3,0,0);
1549 /** NUMPRS_THOUSANDS **/
1551 /* With flag, thousands sep. not needed */
1552 CONVERT("0", NUMPRS_THOUSANDS
);
1553 EXPECT(1,NUMPRS_THOUSANDS
,0,1,0,0);
1556 /* With flag, thousands sep. and following digits consumed */
1557 CONVERT("1,000", NUMPRS_THOUSANDS
);
1558 EXPECT(1,NUMPRS_THOUSANDS
,NUMPRS_THOUSANDS
,5,0,3);
1561 /* With flag and decimal point, thousands sep. but not decimals consumed */
1562 CONVERT("1,000.0", NUMPRS_THOUSANDS
);
1563 EXPECT(1,NUMPRS_THOUSANDS
,NUMPRS_THOUSANDS
,5,0,3);
1566 /** NUMPRS_CURRENCY **/
1568 /* Without flag, chokes on currency sign */
1571 EXPECTRGB(0,FAILDIG
);
1573 /* With flag, consumes currency sign */
1574 CONVERT("$11", NUMPRS_CURRENCY
);
1575 EXPECT(2,NUMPRS_CURRENCY
,NUMPRS_CURRENCY
,3,0,0);
1577 EXPECTRGB(2,FAILDIG
);
1579 /* With flag only, doesn't consume decimal point */
1580 CONVERT("$11.1", NUMPRS_CURRENCY
);
1581 EXPECT(2,NUMPRS_CURRENCY
,NUMPRS_CURRENCY
,3,0,0);
1583 EXPECTRGB(2,FAILDIG
);
1585 /* With flag and decimal flag, consumes decimal point and following digits */
1586 CONVERT("$11.1", NUMPRS_CURRENCY
|NUMPRS_DECIMAL
);
1587 EXPECT(3,NUMPRS_CURRENCY
|NUMPRS_DECIMAL
,NUMPRS_CURRENCY
|NUMPRS_DECIMAL
,5,0,-1);
1590 EXPECTRGB(3,FAILDIG
);
1592 /* Thousands flag can only be used with currency */
1593 CONVERT("$1,234", NUMPRS_CURRENCY
|NUMPRS_THOUSANDS
);
1594 EXPECT(4,NUMPRS_CURRENCY
|NUMPRS_THOUSANDS
,NUMPRS_CURRENCY
|NUMPRS_THOUSANDS
,6,0,0);
1598 EXPECTRGB(4,FAILDIG
);
1600 /** NUMPRS_DECIMAL **/
1602 /* With flag, consumes decimal point */
1603 CONVERT("1.1", NUMPRS_DECIMAL
);
1604 EXPECT(2,NUMPRS_DECIMAL
,NUMPRS_DECIMAL
,3,0,-1);
1606 EXPECTRGB(2,FAILDIG
);
1608 /* With flag, consumes decimal point. Skipping the decimal part is not an error */
1609 CONVERT("1.", NUMPRS_DECIMAL
);
1610 EXPECT(1,NUMPRS_DECIMAL
,NUMPRS_DECIMAL
,2,0,0);
1613 /* Consumes only one decimal point */
1614 CONVERT("1.1.", NUMPRS_DECIMAL
);
1615 EXPECT(2,NUMPRS_DECIMAL
,NUMPRS_DECIMAL
,3,0,-1);
1617 EXPECTRGB(2,FAILDIG
);
1619 /** NUMPRS_EXPONENT **/
1621 /* Without flag, doesn't consume exponent */
1623 EXPECT(1,0,0,1,0,0);
1626 /* With flag, consumes exponent */
1627 CONVERT("1e1", NUMPRS_EXPONENT
);
1628 EXPECT(1,NUMPRS_EXPONENT
,NUMPRS_EXPONENT
,3,0,1);
1631 /* Negative exponents are accepted without flags */
1632 CONVERT("1e-1", NUMPRS_EXPONENT
);
1633 EXPECT(1,NUMPRS_EXPONENT
,NUMPRS_EXPONENT
,4,0,-1);
1636 /* As are positive exponents and leading exponent 0s */
1637 CONVERT("1e+01", NUMPRS_EXPONENT
);
1638 EXPECT(1,NUMPRS_EXPONENT
,NUMPRS_EXPONENT
,5,0,1);
1641 /* The same for zero exponents */
1642 CONVERT("1e0", NUMPRS_EXPONENT
);
1643 EXPECT(1,NUMPRS_EXPONENT
,NUMPRS_EXPONENT
,3,0,0);
1646 /* Sign on a zero exponent doesn't matter */
1647 CONVERT("1e+0", NUMPRS_EXPONENT
);
1648 EXPECT(1,NUMPRS_EXPONENT
,NUMPRS_EXPONENT
,4,0,0);
1651 CONVERT("1e-0", NUMPRS_EXPONENT
);
1652 EXPECT(1,NUMPRS_EXPONENT
,NUMPRS_EXPONENT
,4,0,0);
1655 /* Doesn't consume a real number exponent */
1656 CONVERT("1e1.", NUMPRS_EXPONENT
);
1657 EXPECT(1,NUMPRS_EXPONENT
,NUMPRS_EXPONENT
,3,0,1);
1660 /* Powers of 10 are calculated from the position of any decimal point */
1661 CONVERT("1.5e20", NUMPRS_EXPONENT
|NUMPRS_DECIMAL
);
1662 EXPECT(2,NUMPRS_EXPONENT
|NUMPRS_DECIMAL
,NUMPRS_EXPONENT
|NUMPRS_DECIMAL
,6,0,19);
1665 CONVERT("1.5e-20", NUMPRS_EXPONENT
|NUMPRS_DECIMAL
);
1666 EXPECT(2,NUMPRS_EXPONENT
|NUMPRS_DECIMAL
,NUMPRS_EXPONENT
|NUMPRS_DECIMAL
,7,0,-21);
1669 /** NUMPRS_USE_ALL **/
1671 /* Flag expects all digits */
1672 CONVERT("0", NUMPRS_USE_ALL
);
1673 EXPECT(1,NUMPRS_USE_ALL
,0,1,0,0);
1676 /* Rejects anything trailing */
1677 CONVERT("0 ", NUMPRS_USE_ALL
);
1681 /* Unless consumed by trailing flag */
1682 CONVERT("0 ", NUMPRS_USE_ALL
|NUMPRS_TRAILING_WHITE
);
1683 EXPECT(1,NUMPRS_USE_ALL
|NUMPRS_TRAILING_WHITE
,NUMPRS_TRAILING_WHITE
,2,0,0);
1686 /** Combinations **/
1688 /* Leading whitespace and plus, doesn't consume trailing whitespace */
1689 CONVERT("+ 0 ", NUMPRS_LEADING_PLUS
|NUMPRS_LEADING_WHITE
);
1690 EXPECT(1,NUMPRS_LEADING_PLUS
|NUMPRS_LEADING_WHITE
,NUMPRS_LEADING_PLUS
|NUMPRS_LEADING_WHITE
,3,0,0);
1693 /* Order of whitespace and plus is unimportant */
1694 CONVERT(" +0", NUMPRS_LEADING_PLUS
|NUMPRS_LEADING_WHITE
);
1695 EXPECT(1,NUMPRS_LEADING_PLUS
|NUMPRS_LEADING_WHITE
,NUMPRS_LEADING_PLUS
|NUMPRS_LEADING_WHITE
,3,0,0);
1698 /* Leading whitespace can be repeated */
1699 CONVERT(" + 0", NUMPRS_LEADING_PLUS
|NUMPRS_LEADING_WHITE
);
1700 EXPECT(1,NUMPRS_LEADING_PLUS
|NUMPRS_LEADING_WHITE
,NUMPRS_LEADING_PLUS
|NUMPRS_LEADING_WHITE
,4,0,0);
1703 /* But plus/minus etc. cannot */
1704 CONVERT("+ +0", NUMPRS_LEADING_PLUS
|NUMPRS_LEADING_WHITE
);
1706 EXPECTRGB(0,FAILDIG
);
1708 /* Inexact is not set if trailing zeros are removed */
1709 CONVERTN("10", 1, 0);
1710 EXPECT(1,0,0,2,0,1);
1713 /* Make sure a leading 0 is stripped but decimals after it get read */
1714 CONVERT("-0.51", NUMPRS_STD
);
1715 EXPECT(2,NUMPRS_STD
,NUMPRS_NEG
|NUMPRS_DECIMAL
|NUMPRS_LEADING_MINUS
,5,0,-2);
1718 /* Keep trailing zeros on whole number part of a decimal */
1719 CONVERT("10.1", NUMPRS_STD
);
1720 EXPECT(3,NUMPRS_STD
,NUMPRS_DECIMAL
,4,0,-1);
1724 /* Zeros after decimal sign */
1725 CONVERT("0.01", NUMPRS_STD
);
1726 EXPECT(1,NUMPRS_STD
,NUMPRS_DECIMAL
,4,0,-2);
1729 /* Trailing zeros after decimal part */
1730 CONVERT("0.10", NUMPRS_STD
);
1731 EXPECT(1,NUMPRS_STD
,NUMPRS_DECIMAL
,4,0,-1);
1736 hres
= pVarParseNumFromStr(str
, lcid
, LOCALE_NOUSEROVERRIDE
, &np
, rgb
);
1737 ok(hres
== DISP_E_TYPEMISMATCH
, "VarParseNumFromStr returned %08x\n", hres
);
1740 static HRESULT (WINAPI
*pVarNumFromParseNum
)(NUMPARSE
*,BYTE
*,ULONG
,VARIANT
*);
1742 /* Macros for converting and testing the result of VarNumFromParseNum */
1743 #define SETRGB(indx,val) if (!indx) memset(rgb, FAILDIG, sizeof(rgb)); rgb[indx] = val
1745 #define CONVERT(a,b,c,d,e,f,bits) \
1746 np.cDig = (a); np.dwInFlags = (b); np.dwOutFlags = (c); np.cchUsed = (d); \
1747 np.nBaseShift = (e); np.nPwr10 = (f); hres = pVarNumFromParseNum(&np, rgb, bits, &vOut)
1748 static const char *szFailOverflow
= "Expected overflow, hres = %08x\n";
1749 #define EXPECT_OVERFLOW ok(hres == (HRESULT)DISP_E_OVERFLOW, szFailOverflow, hres)
1750 static const char *szFailOk
= "Call failed, hres = %08x\n";
1751 #define EXPECT_OK ok(hres == (HRESULT)S_OK, szFailOk, hres); \
1752 if (hres == (HRESULT)S_OK)
1753 #define EXPECT_TYPE(typ) ok(V_VT(&vOut) == typ,"Expected Type = " #typ ", got %d\n", V_VT(&vOut))
1754 #define EXPECT_I1(val) EXPECT_OK { EXPECT_TYPE(VT_I1); \
1755 ok(V_I1(&vOut) == val, "Expected i1 = %d, got %d\n", (signed char)val, V_I1(&vOut)); }
1756 #define EXPECT_UI1(val) EXPECT_OK { EXPECT_TYPE(VT_UI1); \
1757 ok(V_UI1(&vOut) == val, "Expected ui1 = %d, got %d\n", (BYTE)val, V_UI1(&vOut)); }
1758 #define EXPECT_I2(val) EXPECT_OK { EXPECT_TYPE(VT_I2); \
1759 ok(V_I2(&vOut) == val, "Expected i2 = %d, got %d\n", (SHORT)val, V_I2(&vOut)); }
1760 #define EXPECT_UI2(val) EXPECT_OK { EXPECT_TYPE(VT_UI2); \
1761 ok(V_UI2(&vOut) == val, "Expected ui2 = %d, got %d\n", (USHORT)val, V_UI2(&vOut)); }
1762 #define EXPECT_I4(val) EXPECT_OK { EXPECT_TYPE(VT_I4); \
1763 ok(V_I4(&vOut) == val, "Expected i4 = %d, got %d\n", (LONG)val, V_I4(&vOut)); }
1764 #define EXPECT_UI4(val) EXPECT_OK { EXPECT_TYPE(VT_UI4); \
1765 ok(V_UI4(&vOut) == val, "Expected ui4 = %d, got %d\n", (ULONG)val, V_UI4(&vOut)); }
1766 #define EXPECT_I8(high,low) EXPECT_OK { EXPECT_TYPE(VT_I8); \
1767 ok(V_I8(&vOut) == ((((ULONG64)(high))<<32)|(low)), "Expected i8 = %x%08x, got %x%08x\n", \
1768 (LONG)(high), (LONG)(low), (LONG)(V_I8(&vOut)>>32), (LONG)V_I8(&vOut) ); }
1769 #define EXPECT_UI8(val) EXPECT_OK { EXPECT_TYPE(VT_UI8); \
1770 ok(V_UI8(&vOut) == val, "Expected ui8 = 0x%x%08x, got 0x%x%08x\n", \
1771 (DWORD)((ULONG64)val >> 32), (DWORD)(ULONG64)val, (DWORD)(V_UI8(&vOut) >> 32), (DWORD)V_UI8(&vOut)); }
1772 #define EXPECT_R4(val) EXPECT_OK { EXPECT_TYPE(VT_R4); \
1773 ok(V_R4(&vOut) == val, "Expected r4 = %f, got %f\n", val, V_R4(&vOut)); }
1774 #define EXPECT_R8(val) EXPECT_OK { EXPECT_TYPE(VT_R8); \
1775 ok(V_R8(&vOut) == val, "Expected r8 = %g, got %g\n", val, V_R8(&vOut)); }
1776 #define CY_MULTIPLIER 10000
1777 #define EXPECT_CY(val) EXPECT_OK { EXPECT_TYPE(VT_CY); \
1778 ok(V_CY(&vOut).int64 == (LONG64)(val * CY_MULTIPLIER), "Expected r8 = 0x%x%08x, got 0x%x%08x\n", \
1779 (DWORD)((LONG64)val >> 23), (DWORD)(LONG64)val, (DWORD)(V_CY(&vOut).int64 >>32), (DWORD)V_CY(&vOut).int64); }
1780 #define EXPECT_DECIMAL(valHi, valMid, valLo) EXPECT_OK { EXPECT_TYPE(VT_DECIMAL); \
1781 ok((V_DECIMAL(&vOut).Hi32 == valHi) && (S1(U1(V_DECIMAL(&vOut))).Mid32 == valMid) && \
1782 (S1(U1(V_DECIMAL(&vOut))).Lo32 == valLo), \
1783 "Expected decimal = %x/0x%x%08x, got %x/0x%x%08x\n", valHi, valMid, valLo, \
1784 V_DECIMAL(&vOut).Hi32, S1(U1(V_DECIMAL(&vOut))).Mid32, S1(U1(V_DECIMAL(&vOut))).Lo32); }
1786 static void test_VarNumFromParseNum(void)
1793 CHECKPTR(VarNumFromParseNum
);
1795 /* Convert the number 1 to different types */
1796 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_I1
); EXPECT_I1(1);
1797 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_UI1
); EXPECT_UI1(1);
1798 /* Prefers a signed type to unsigned of the same size */
1799 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_I1
|VTBIT_UI1
); EXPECT_I1(1);
1800 /* But takes the smaller size if possible */
1801 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_I2
|VTBIT_UI1
); EXPECT_UI1(1);
1803 /* Try different integer sizes */
1804 #define INTEGER_VTBITS (VTBIT_I1|VTBIT_UI1|VTBIT_I2|VTBIT_UI2|VTBIT_I4|VTBIT_UI4|VTBIT_I8|VTBIT_UI8)
1806 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, INTEGER_VTBITS
); EXPECT_I1(1);
1808 SETRGB(0, 1); SETRGB(1, 2); SETRGB(2, 7);
1809 CONVERT(3,0,0,3,0,0, INTEGER_VTBITS
); EXPECT_I1(127);
1811 SETRGB(0, 1); SETRGB(1, 2); SETRGB(2, 8);
1812 CONVERT(3,0,0,3,0,0, INTEGER_VTBITS
); EXPECT_UI1(128);
1814 SETRGB(0, 2); SETRGB(1, 5); SETRGB(2, 5);
1815 CONVERT(3,0,0,3,0,0, INTEGER_VTBITS
); EXPECT_UI1(255);
1817 SETRGB(0, 2); SETRGB(1, 5); SETRGB(2, 6);
1818 CONVERT(3,0,0,3,0,0, INTEGER_VTBITS
); EXPECT_I2(256);
1820 SETRGB(0, 3); SETRGB(1, 2); SETRGB(2, 7); SETRGB(3, 6); SETRGB(4, 7);
1821 CONVERT(5,0,0,5,0,0, INTEGER_VTBITS
); EXPECT_I2(32767);
1823 SETRGB(0, 3); SETRGB(1, 2); SETRGB(2, 7); SETRGB(3, 6); SETRGB(4, 8);
1824 CONVERT(5,0,0,5,0,0, INTEGER_VTBITS
); EXPECT_UI2(32768);
1826 /* Assume the above pattern holds for remaining positive integers; test negative */
1829 SETRGB(0, 1); SETRGB(1, 2); SETRGB(2, 8);
1830 CONVERT(3,0,NUMPRS_NEG
,3,0,0, INTEGER_VTBITS
); EXPECT_I1(-128);
1832 SETRGB(0, 1); SETRGB(1, 2); SETRGB(2, 9);
1833 CONVERT(3,0,NUMPRS_NEG
,3,0,0, INTEGER_VTBITS
); EXPECT_I2(-129);
1835 SETRGB(0, 3); SETRGB(1, 2); SETRGB(2, 7); SETRGB(3, 6); SETRGB(4, 8);
1836 CONVERT(5,0,NUMPRS_NEG
,5,0,0, INTEGER_VTBITS
); EXPECT_I2(-32768);
1838 SETRGB(0, 3); SETRGB(1, 2); SETRGB(2, 7); SETRGB(3, 6); SETRGB(4, 9);
1839 CONVERT(5,0,NUMPRS_NEG
,5,0,0, INTEGER_VTBITS
); EXPECT_I4(-32769);
1841 /* Assume the above pattern holds for remaining negative integers */
1843 /* Test hexadecimal conversions */
1844 SETRGB(0, 1); CONVERT(1,0,0,1,4,0, INTEGER_VTBITS
); EXPECT_I1(0x01);
1846 SETRGB(0, 7); SETRGB(1, 0xf);
1847 CONVERT(2,0,0,2,4,0, INTEGER_VTBITS
); EXPECT_I1(0x7f);
1848 SETRGB(0, 7); SETRGB(1, 0xf);
1849 CONVERT(2,0,0,2,4,0, VTBIT_DECIMAL
); EXPECT_DECIMAL(0,0,0x7f);
1851 SETRGB(0, 7); SETRGB(1, 0xf); SETRGB(2, 0xf); SETRGB(3, 0xf);
1852 CONVERT(4,0,0,4,4,0, INTEGER_VTBITS
); EXPECT_I2(0x7fff);
1854 SETRGB(0, 7); SETRGB(1, 0xf); SETRGB(2, 0xf); SETRGB(3, 0xf);
1855 SETRGB(4, 0xf); SETRGB(5, 0xf); SETRGB(6, 0xf); SETRGB(7, 0xf);
1856 CONVERT(8,0,0,8,4,0, INTEGER_VTBITS
); EXPECT_I4(0x7fffffffL
);
1857 /* 0x7fffffffffffffff (64 bits) */
1858 SETRGB(0, 7); SETRGB(1, 0xf); SETRGB(2, 0xf); SETRGB(3, 0xf);
1859 SETRGB(4, 0xf); SETRGB(5, 0xf); SETRGB(6, 0xf); SETRGB(7, 0xf);
1860 SETRGB(8, 0xf); SETRGB(9, 0xf); SETRGB(10, 0xf); SETRGB(11, 0xf);
1861 SETRGB(12, 0xf); SETRGB(13, 0xf); SETRGB(14, 0xf); SETRGB(15, 0xf);
1864 /* We cannot use INTEGER_VTBITS as WinXP and Win2003 are broken(?). They
1865 truncate the number to the smallest integer size requested:
1866 CONVERT(16,0,0,16,4,0, INTEGER_VTBITS); EXPECT_I1((signed char)0xff); */
1867 CONVERT(16,0,0,16,4,0, VTBIT_I8
); EXPECT_I8(0x7fffffff,0xffffffff);
1870 /* Assume the above pattern holds for numbers without hi-bit set, test (preservation of) hi-bit */
1872 SETRGB(0, 8); SETRGB(1, 2);
1873 CONVERT(2,0,0,2,4,0, INTEGER_VTBITS
);
1874 EXPECT_I1((signed char)0x82);
1876 SETRGB(0, 8); SETRGB(1, 0); SETRGB(2, 0); SETRGB(3, 2);
1877 CONVERT(4,0,0,4,4,0, INTEGER_VTBITS
);
1878 EXPECT_I2((signed short)0x8002);
1880 SETRGB(0, 8); SETRGB(1, 0); SETRGB(2, 0); SETRGB(3, 0);
1881 SETRGB(4, 0); SETRGB(5, 0); SETRGB(6, 0); SETRGB(7, 2);
1882 CONVERT(8,0,0,8,4,0, INTEGER_VTBITS
); EXPECT_I4(0x80000002);
1883 /* 0x8000000000000002 (64 bits) */
1884 SETRGB(0, 8); SETRGB(1, 0); SETRGB(2, 0); SETRGB(3, 0);
1885 SETRGB(4, 0); SETRGB(5, 0); SETRGB(6, 0); SETRGB(7, 0);
1886 SETRGB(8, 0); SETRGB(9, 0); SETRGB(10, 0); SETRGB(11, 0);
1887 SETRGB(12, 0); SETRGB(13, 0); SETRGB(14, 0); SETRGB(15, 2);
1890 /* We cannot use INTEGER_VTBITS as WinXP and Win2003 are broken(?). They
1891 truncate the number to the smallest integer size requested:
1892 CONVERT(16,0,0,16,4,0, INTEGER_VTBITS & ~VTBIT_I1);
1893 EXPECT_I2((signed short)0x0002); */
1894 CONVERT(16,0,0,16,4,0, VTBIT_I8
); EXPECT_I8(0x80000000,0x00000002);
1897 /* Test (preservation of) hi-bit with STRICT type requesting */
1899 SETRGB(0, 8); SETRGB(1, 2);
1900 CONVERT(2,0,0,2,4,0, VTBIT_I1
);
1901 EXPECT_I1((signed char)0x82);
1903 SETRGB(0, 8); SETRGB(1, 0); SETRGB(2, 0); SETRGB(3, 2);
1904 CONVERT(4,0,0,4,4,0, VTBIT_I2
);
1905 EXPECT_I2((signed short)0x8002);
1907 SETRGB(0, 8); SETRGB(1, 0); SETRGB(2, 0); SETRGB(3, 0);
1908 SETRGB(4, 0); SETRGB(5, 0); SETRGB(6, 0); SETRGB(7, 2);
1909 CONVERT(8,0,0,8,4,0, VTBIT_I4
); EXPECT_I4(0x80000002);
1910 /* 0x8000000000000002 (64 bits) */
1911 SETRGB(0, 8); SETRGB(1, 0); SETRGB(2, 0); SETRGB(3, 0);
1912 SETRGB(4, 0); SETRGB(5, 0); SETRGB(6, 0); SETRGB(7, 0);
1913 SETRGB(8, 0); SETRGB(9, 0); SETRGB(10, 0); SETRGB(11, 0);
1914 SETRGB(12, 0); SETRGB(13, 0); SETRGB(14, 0); SETRGB(15, 2);
1917 CONVERT(16,0,0,16,4,0, VTBIT_I8
); EXPECT_I8(0x80000000,0x00000002);
1919 /* Assume the above pattern holds for numbers with hi-bit set */
1921 /* Negative numbers overflow if we have only unsigned outputs */
1923 SETRGB(0, 1); CONVERT(1,0,NUMPRS_NEG
,1,0,0, VTBIT_UI1
); EXPECT_OVERFLOW
;
1925 SETRGB(0, 6); CONVERT(1,0,NUMPRS_NEG
,1,0,~0u, VTBIT_UI1
); EXPECT_OVERFLOW
;
1927 /* Except that rounding is done first, so -0.5 to 0 are accepted as 0 */
1929 SETRGB(0, 5); CONVERT(1,0,NUMPRS_NEG
,1,0,~0u, VTBIT_UI1
); EXPECT_UI1(0);
1931 /* Floating point zero is OK */
1933 SETRGB(0, 0); CONVERT(1,0,NUMPRS_DECIMAL
|NUMPRS_EXPONENT
,12,0,-8, VTBIT_R8
);
1936 /* Float is acceptable for an integer input value */
1937 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_R4
); EXPECT_R4(1.0f
);
1939 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_R8
); EXPECT_R8(1.0);
1940 /* As is currency */
1941 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_CY
); EXPECT_CY(1);
1943 /* Float is preferred over double */
1944 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_R4
|VTBIT_R8
); EXPECT_R4(1.0f
);
1946 /* Double is preferred over currency */
1947 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_R8
|VTBIT_CY
); EXPECT_R8(1.0);
1949 /* Currency is preferred over decimal */
1950 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_CY
|VTBIT_DECIMAL
); EXPECT_CY(1);
1952 /* Underflow test */
1953 SETRGB(0, 1); CONVERT(1,0,NUMPRS_EXPONENT
,1,0,-94938484, VTBIT_R4
); EXPECT_R4(0.0);
1954 SETRGB(0, 1); CONVERT(1,0,NUMPRS_EXPONENT
,1,0,-94938484, VTBIT_R8
); EXPECT_R8(0.0);
1955 SETRGB(0, 1); CONVERT(1,0,NUMPRS_EXPONENT
,1,0,-94938484, VTBIT_CY
); EXPECT_CY(0);
1959 static void test_UdateFromDate( int line
, DATE dt
, ULONG flags
, HRESULT r
, WORD d
, WORD m
, WORD y
,
1960 WORD h
, WORD mn
, WORD s
, WORD ms
, WORD dw
, WORD dy
)
1965 memset(&ud
, 0, sizeof(ud
));
1966 res
= pVarUdateFromDate(dt
, flags
, &ud
);
1967 ok_(__FILE__
,line
)(r
== res
&& (res
!= S_OK
|| (ud
.st
.wYear
== y
&& ud
.st
.wMonth
== m
&& ud
.st
.wDay
== d
&&
1968 ud
.st
.wHour
== h
&& ud
.st
.wMinute
== mn
&& ud
.st
.wSecond
== s
&&
1969 ud
.st
.wMilliseconds
== ms
&& ud
.st
.wDayOfWeek
== dw
&& ud
.wDayOfYear
== dy
)),
1970 "%.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",
1971 dt
, r
, d
, m
, y
, h
, mn
, s
, ms
, dw
, dy
,
1972 res
, ud
.st
.wDay
, ud
.st
.wMonth
, ud
.st
.wYear
, ud
.st
.wHour
, ud
.st
.wMinute
,
1973 ud
.st
.wSecond
, ud
.st
.wMilliseconds
, ud
.st
.wDayOfWeek
, ud
.wDayOfYear
);
1975 #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)
1977 static void test_VarUdateFromDate(void)
1979 CHECKPTR(VarUdateFromDate
);
1980 DT2UD(29221.0,0,S_OK
,1,1,1980,0,0,0,0,2,1); /* 1 Jan 1980 */
1981 DT2UD(29222.0,0,S_OK
,2,1,1980,0,0,0,0,3,2); /* 2 Jan 1980 */
1982 DT2UD(33238.0,0,S_OK
,31,12,1990,0,0,0,0,1,365); /* 31 Dec 1990 */
1983 DT2UD(0.0,0,S_OK
,30,12,1899,0,0,0,0,6,364); /* 30 Dec 1899 - VT_DATE 0.0 */
1984 DT2UD(-657434.0,0,S_OK
,1,1,100,0,0,0,0,5,1); /* 1 Jan 100 - Min */
1985 DT2UD(-657435.0,0,E_INVALIDARG
,0,0,0,0,0,0,0,0,0); /* < 1 Jan 100 => err */
1986 DT2UD(2958465.0,0,S_OK
,31,12,9999,0,0,0,0,5,365); /* 31 Dec 9999 - Max */
1987 DT2UD(2958466.0,0,E_INVALIDARG
,0,0,0,0,0,0,0,0,0); /* > 31 Dec 9999 => err */
1989 /* VAR_VALIDDATE doesn't prevent upper and lower bounds being checked */
1990 DT2UD(-657435.0,VAR_VALIDDATE
,E_INVALIDARG
,0,0,0,0,0,0,0,0,0);
1991 DT2UD(2958466.0,VAR_VALIDDATE
,E_INVALIDARG
,0,0,0,0,0,0,0,0,0);
1994 DT2UD(29221.25,0,S_OK
,1,1,1980,6,0,0,0,2,1); /* 6 AM */
1995 DT2UD(29221.33333333,0,S_OK
,1,1,1980,8,0,0,0,2,1); /* 8 AM */
1996 DT2UD(29221.5,0,S_OK
,1,1,1980,12,0,0,0,2,1); /* 12 AM */
1997 DT2UD(29221.9888884444,0,S_OK
,1,1,1980,23,44,0,0,2,1); /* 11:44 PM */
1998 DT2UD(29221.7508765432,0,S_OK
,1,1,1980,18,1,16,0,2,1); /* 6:18:02 PM */
2000 /* Test handling of times on dates prior to the epoch */
2001 DT2UD(-5.25,0,S_OK
,25,12,1899,6,0,0,0,1,359);
2002 DT2UD(-5.9999884259259,0,S_OK
,25,12,1899,23,59,59,0,1,359);
2003 /* This just demonstrates the non-linear nature of values prior to the epoch */
2004 DT2UD(-4.0,0,S_OK
,26,12,1899,0,0,0,0,2,360);
2005 /* Numerical oddity: for 0.0 < x < 1.0, x and -x represent the same datetime */
2006 DT2UD(-0.25,0,S_OK
,30,12,1899,6,0,0,0,6,364);
2007 DT2UD(0.25,0,S_OK
,30,12,1899,6,0,0,0,6,364);
2011 static void test_DateFromUDate( int line
, WORD d
, WORD m
, WORD y
, WORD h
, WORD mn
, WORD s
, WORD ms
,
2012 WORD dw
, WORD dy
, ULONG flags
, HRESULT r
, DATE dt
)
2024 ud
.st
.wMilliseconds
= ms
;
2025 ud
.st
.wDayOfWeek
= dw
;
2027 res
= pVarDateFromUdate(&ud
, flags
, &out
);
2028 ok_(__FILE__
,line
)(r
== res
&& (r
!= S_OK
|| EQ_DOUBLE(out
, dt
)),
2029 "expected %x, %.16g, got %x, %.16g\n", r
, dt
, res
, out
);
2031 #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)
2033 static void test_VarDateFromUdate(void)
2035 CHECKPTR(VarDateFromUdate
);
2036 UD2T(1,1,1980,0,0,0,0,2,1,0,S_OK
,29221.0); /* 1 Jan 1980 */
2037 UD2T(2,1,1980,0,0,0,0,3,2,0,S_OK
,29222.0); /* 2 Jan 1980 */
2038 UD2T(2,1,1980,0,0,0,0,4,5,0,S_OK
,29222.0); /* 2 Jan 1980 */
2039 UD2T(31,12,1990,0,0,0,0,0,0,0,S_OK
,33238.0); /* 31 Dec 1990 */
2040 UD2T(31,12,90,0,0,0,0,0,0,0,S_OK
,33238.0); /* year < 100 is 1900+year! */
2041 UD2T(30,12,1899,0,0,0,0,6,364,0,S_OK
,0.0); /* 30 Dec 1899 - VT_DATE 0.0 */
2042 UD2T(1,1,100,0,0,0,0,0,0,0,S_OK
,-657434.0); /* 1 Jan 100 - Min */
2043 UD2T(31,12,9999,0,0,0,0,0,0,0,S_OK
,2958465.0); /* 31 Dec 9999 - Max */
2044 UD2T(1,1,10000,0,0,0,0,0,0,0,E_INVALIDARG
,0.0); /* > 31 Dec 9999 => err */
2045 UD2T(1,1,-10000,0,0,0,0,0,0,0,E_INVALIDARG
,0.0);/* < -9999 => err */
2047 UD2T(30,12,1899,0,0,0,0,0,0,0,S_OK
,0.0); /* 30 Dec 1899 0:00:00 */
2048 UD2T(30,12,1899,0,0,0,999,0,0,0,S_OK
,0.0); /* Ignore milliseconds */
2050 UD2T(1,1,1980,18,1,16,0,2,1,0,S_OK
,29221.75087962963); /* 6:18:02 PM */
2051 UD2T(1,300,1980,18,1,16,0,2,1,0,S_OK
,38322.75087962963); /* Test fwdrolled month */
2052 UD2T(300,1,1980,18,1,16,0,2,1,0,S_OK
,29520.75087962963); /* Test fwdrolled days */
2053 UD2T(0,1,1980,42,1,16,0,2,1,0,S_OK
,29221.75087962963); /* Test fwdrolled hours */
2054 UD2T(1,1,1980,17,61,16,0,2,1,0,S_OK
,29221.75087962963); /* Test fwdrolled minutes */
2055 UD2T(1,1,1980,18,0,76,0,2,1,0,S_OK
,29221.75087962963); /* Test fwdrolled seconds */
2056 UD2T(1,-300,1980,18,1,16,0,2,1,0,S_OK
,20059.75087962963); /* Test backrolled month */
2057 UD2T(-300,1,1980,18,1,16,0,2,1,0,S_OK
,28920.75087962963); /* Test backrolled days */
2058 UD2T(3,1,1980,-30,1,16,0,2,1,0,S_OK
,29221.75087962963); /* Test backrolled hours */
2059 UD2T(1,1,1980,20,-119,16,0,2,1,0,S_OK
,29221.75087962963); /* Test backrolled minutes */
2060 UD2T(1,1,1980,18,3,-104,0,2,1,0,S_OK
,29221.75087962963); /* Test backrolled seconds */
2061 UD2T(1,12001,-1020,18,1,16,0,0,0,0,S_OK
,29221.75087962963); /* Test rolled year and month */
2062 UD2T(1,-23,1982,18,1,16,0,0,0,0,S_OK
,29221.75087962963); /* Test backrolled month */
2063 UD2T(-59,3,1980,18,1,16,0,0,0,0,S_OK
,29221.75087962963); /* Test backrolled days */
2064 UD2T(1,1,0,0,0,0,0,0,0,0,S_OK
,36526); /* Test zero year */
2065 UD2T(0,0,1980,0,0,0,0,0,0,0,S_OK
,29189); /* Test zero day and month */
2066 UD2T(0,1,1980,0,0,0,0,2,1,0,S_OK
,29220.0); /* Test zero day = LastDayOfMonth */
2067 UD2T(-1,1,1980,18,1,16,0,0,0,0,S_OK
,29219.75087962963); /* Test day -1 = LastDayOfMonth - 1 */
2068 UD2T(1,1,-1,18,1,16,0,0,0,0,S_OK
,36161.75087962963); /* Test year -1 = 1999 */
2069 UD2T(1,-1,1980,18,1,16,0,0,0,0,S_OK
,29160.7508796296); /* Test month -1 = 11 */
2070 UD2T(1,13,1980,0,0,0,0,2,1,0,S_OK
,29587.0); /* Rolls fwd to 1/1/1981 */
2072 /* Test handling of times on dates prior to the epoch */
2073 UD2T(25,12,1899,6,0,0,0,1,359,0,S_OK
,-5.25);
2074 UD2T(25,12,1899,23,59,59,0,1,359,0,S_OK
,-5.9999884259259);
2075 /* This just demonstrates the non-linear nature of values prior to the epoch */
2076 UD2T(26,12,1899,0,0,0,0,2,360,0,S_OK
,-4.0);
2077 /* for DATE values 0.0 < x < 1.0, x and -x represent the same datetime */
2078 /* but when converting to DATE, prefer the positive versions */
2079 UD2T(30,12,1899,6,0,0,0,6,364,0,S_OK
,0.25);
2081 UD2T(1,1,1980,18,1,16,0,2,1,VAR_TIMEVALUEONLY
,S_OK
,0.7508796296296296);
2082 UD2T(1,1,1980,18,1,16,0,2,1,VAR_DATEVALUEONLY
,S_OK
,29221.0);
2083 UD2T(25,12,1899,6,0,0,0,1,359,VAR_TIMEVALUEONLY
,S_OK
,0.25);
2084 UD2T(25,12,1899,6,0,0,0,1,359,VAR_DATEVALUEONLY
,S_OK
,-5.0);
2085 UD2T(1,-1,1980,18,1,16,0,0,0,VAR_TIMEVALUEONLY
|VAR_DATEVALUEONLY
,S_OK
,0.7508796296296296);
2088 static void test_st2dt(int line
, WORD d
, WORD m
, WORD y
, WORD h
, WORD mn
,
2089 WORD s
, WORD ms
, INT r
, double dt
)
2101 st
.wMilliseconds
= ms
;
2103 res
= pSystemTimeToVariantTime(&st
, &out
);
2104 ok_(__FILE__
,line
)(r
== res
&& (!r
|| EQ_DOUBLE(out
, dt
)),
2105 "expected %d, %.16g, got %d, %.16g\n", r
, dt
, res
, out
);
2107 #define ST2DT(d,m,y,h,mn,s,ms,r,dt) test_st2dt(__LINE__,d,m,y,h,mn,s,ms,r,dt)
2109 static void test_SystemTimeToVariantTime(void)
2111 CHECKPTR(SystemTimeToVariantTime
);
2112 ST2DT(1,1,1980,0,0,0,0,TRUE
,29221.0);
2113 ST2DT(2,1,1980,0,0,0,0,TRUE
,29222.0);
2114 ST2DT(0,1,1980,0,0,0,0,TRUE
,29220.0); /* Rolls back to 31 Dec 1899 */
2115 ST2DT(1,13,1980,0,0,0,0,FALSE
,29587.0); /* Fails on invalid month */
2116 ST2DT(32,1,1980,0,0,0,0,FALSE
,0.0); /* Fails on invalid day */
2117 ST2DT(1,1,-1,0,0,0,0,FALSE
,0.0); /* Fails on invalid year */
2118 ST2DT(1,1,10000,0,0,0,0,FALSE
,0.0); /* Fails on invalid year */
2119 ST2DT(1,1,9999,0,0,0,0,TRUE
,2958101.0); /* 9999 is last valid year */
2120 ST2DT(31,12,90,0,0,0,0,TRUE
,33238.0); /* 30 <= year < 100 is 1900+year */
2121 ST2DT(1,1,30,0,0,0,0,TRUE
,10959.0); /* 30 <= year < 100 is 1900+year */
2122 ST2DT(1,1,29,0,0,0,0,TRUE
,47119.0); /* 0 <= year < 30 is 2000+year */
2123 ST2DT(1,1,0,0,0,0,0,TRUE
,36526.0); /* 0 <= year < 30 is 2000+year */
2126 static void test_dt2st(int line
, double dt
, INT r
, WORD d
, WORD m
, WORD y
,
2127 WORD h
, WORD mn
, WORD s
, WORD ms
)
2132 memset(&st
, 0, sizeof(st
));
2133 res
= pVariantTimeToSystemTime(dt
, &st
);
2134 ok_(__FILE__
,line
)(r
== res
&&
2135 (!r
|| (st
.wYear
== y
&& st
.wMonth
== m
&& st
.wDay
== d
&&
2136 st
.wHour
== h
&& st
.wMinute
== mn
&&
2137 st
.wSecond
== s
&& st
.wMilliseconds
== ms
)),
2138 "%.16g expected %d, %d,%d,%d,%d,%d,%d,%d, got %d, %d,%d,%d,%d,%d,%d,%d\n",
2139 dt
, r
, d
, m
, y
, h
, mn
, s
, ms
, res
, st
.wDay
, st
.wMonth
,
2140 st
.wYear
, st
.wHour
, st
.wMinute
, st
.wSecond
,
2143 #define DT2ST(dt,r,d,m,y,h,mn,s,ms) test_dt2st(__LINE__,dt,r,d,m,y,h,mn,s,ms)
2145 static void test_VariantTimeToSystemTime(void)
2147 CHECKPTR(VariantTimeToSystemTime
);
2148 DT2ST(29221.0,1,1,1,1980,0,0,0,0);
2149 DT2ST(29222.0,1,2,1,1980,0,0,0,0);
2152 #define MKDOSDATE(d,m,y) ((d & 0x1f) | ((m & 0xf) << 5) | (((y-1980) & 0x7f) << 9))
2153 #define MKDOSTIME(h,m,s) (((s>>1) & 0x1f) | ((m & 0x3f) << 5) | ((h & 0x1f) << 11))
2155 static void test_dos2dt(int line
, WORD d
, WORD m
, WORD y
, WORD h
, WORD mn
,
2156 WORD s
, INT r
, double dt
)
2158 unsigned short dosDate
, dosTime
;
2163 dosDate
= MKDOSDATE(d
, m
, y
);
2164 dosTime
= MKDOSTIME(h
, mn
, s
);
2165 res
= pDosDateTimeToVariantTime(dosDate
, dosTime
, &out
);
2166 ok_(__FILE__
,line
)(r
== res
&& (!r
|| EQ_DOUBLE(out
, dt
)),
2167 "expected %d, %.16g, got %d, %.16g\n", r
, dt
, res
, out
);
2169 #define DOS2DT(d,m,y,h,mn,s,r,dt) test_dos2dt(__LINE__,d,m,y,h,mn,s,r,dt)
2171 static void test_DosDateTimeToVariantTime(void)
2173 CHECKPTR(DosDateTimeToVariantTime
);
2176 DOS2DT(1,1,1980,0,0,0,1,29221.0); /* 1/1/1980 */
2177 DOS2DT(31,12,2099,0,0,0,1,73050.0); /* 31/12/2099 */
2178 /* Dates are limited to the dos date max of 31/12/2099 */
2179 DOS2DT(31,12,2100,0,0,0,0,0.0); /* 31/12/2100 */
2180 /* Days and months of 0 cause date to roll back 1 day or month */
2181 DOS2DT(0,1,1980,0,0,0,1,29220.0); /* 0 Day => 31/12/1979 */
2182 DOS2DT(1,0,1980,0,0,0,1,29190.0); /* 0 Mth => 1/12/1979 */
2183 DOS2DT(0,0,1980,0,0,0,1,29189.0); /* 0 D/M => 30/11/1979 */
2184 /* Days > days in the month cause date to roll forward 1 month */
2185 DOS2DT(29,2,1981,0,0,0,1,29646.0); /* 29/2/1981 -> 3/1/1980 */
2186 DOS2DT(30,2,1981,0,0,0,1,29647.0); /* 30/2/1981 -> 4/1/1980 */
2187 /* Takes leap years into account when rolling forward */
2188 DOS2DT(29,2,1980,0,0,0,1,29280.0); /* 2/29/1980 */
2189 /* Months > 12 cause an error */
2190 DOS2DT(2,13,1980,0,0,0,0,0.0);
2193 DOS2DT(1,1,1980,0,0,29,1,29221.00032407407); /* 1/1/1980 12:00:28 AM */
2194 DOS2DT(1,1,1980,0,0,31,1,29221.00034722222); /* 1/1/1980 12:00:30 AM */
2195 DOS2DT(1,1,1980,0,59,0,1,29221.04097222222); /* 1/1/1980 12:59:00 AM */
2196 DOS2DT(1,1,1980,0,60,0,0,0.0); /* Invalid minutes */
2197 DOS2DT(1,1,1980,0,0,60,0,0.0); /* Invalid seconds */
2198 DOS2DT(1,1,1980,23,0,0,1,29221.95833333333); /* 1/1/1980 11:00:00 PM */
2199 DOS2DT(1,1,1980,24,0,0,0,0.0); /* Invalid hours */
2201 DOS2DT(1,1,1980,0,0,1,1,29221.0);
2202 DOS2DT(2,1,1980,0,0,0,1,29222.0);
2203 DOS2DT(2,1,1980,0,0,0,1,29222.0);
2204 DOS2DT(31,12,1990,0,0,0,1,33238.0);
2205 DOS2DT(31,12,90,0,0,0,1,40543.0);
2206 DOS2DT(30,12,1899,0,0,0,1,46751.0);
2207 DOS2DT(1,1,100,0,0,0,1,43831.0);
2208 DOS2DT(31,12,9999,0,0,0,1,59901.0);
2209 DOS2DT(1,1,10000,0,0,0,1,59902.0);
2210 DOS2DT(1,1,-10000,0,0,0,1,48214.0);
2212 DOS2DT(30,12,1899,0,0,0,1,46751.0);
2213 DOS2DT(30,12,1899,0,0,1,1,46751.0);
2215 DOS2DT(1,1,1980,18,1,16,1,29221.75087962963);
2216 DOS2DT(1,300,1980,18,1,16,1,29556.75087962963);
2217 DOS2DT(300,1,1980,18,1,16,1,29232.75087962963);
2218 DOS2DT(0,1,1980,42,1,16,1,29220.4175462963);
2219 DOS2DT(1,1,1980,17,61,16,0,0.0);
2220 DOS2DT(1,1,1980,18,0,76,1,29221.75013888889);
2221 DOS2DT(1,-300,1980,18,1,16,1,29312.75087962963);
2222 DOS2DT(-300,1,1980,18,1,16,1,29240.75087962963);
2223 DOS2DT(3,1,1980,-30,1,16,1,29223.08421296296);
2224 DOS2DT(1,1,1980,20,-119,16,1,29221.83976851852);
2225 DOS2DT(1,1,1980,18,3,-104,1,29221.75236111111);
2226 DOS2DT(1,12001,-1020,18,1,16,1,55519.75087962963);
2227 DOS2DT(1,-23,1982,18,1,16,1,30195.75087962963);
2228 DOS2DT(-59,3,1980,18,1,16,1,29285.75087962963);
2229 DOS2DT(1,1,0,0,0,0,1,54058.0);
2230 DOS2DT(0,0,1980,0,0,0,1,29189.0);
2231 DOS2DT(0,1,1980,0,0,0,1,29220.0);
2232 DOS2DT(-1,1,1980,18,1,16,1,29251.75087962963);
2233 DOS2DT(1,1,-1,18,1,16,1,53693.75087962963);
2234 DOS2DT(1,-1,1980,18,1,16,0,0);
2237 static void test_dt2dos(int line
, double dt
, INT r
, WORD d
, WORD m
, WORD y
,
2238 WORD h
, WORD mn
, WORD s
)
2240 unsigned short dosDate
, dosTime
, expDosDate
, expDosTime
;
2243 dosTime
= dosDate
= 0;
2244 expDosDate
= MKDOSDATE(d
,m
,y
);
2245 expDosTime
= MKDOSTIME(h
,mn
,s
);
2246 res
= pVariantTimeToDosDateTime(dt
, &dosDate
, &dosTime
);
2247 ok_(__FILE__
,line
)(r
== res
&& (!r
|| (dosTime
== expDosTime
&& dosDate
== expDosDate
)),
2248 "%g: expected %d,%d(%d/%d/%d),%d(%d:%d:%d) got %d,%d(%d/%d/%d),%d(%d:%d:%d)\n",
2249 dt
, r
, expDosDate
, expDosDate
& 0x1f,
2250 (expDosDate
>> 5) & 0xf, 1980 + (expDosDate
>> 9),
2251 expDosTime
, expDosTime
>> 11, (expDosTime
>> 5) & 0x3f,
2252 (expDosTime
& 0x1f),
2253 res
, dosDate
, dosDate
& 0x1f, (dosDate
>> 5) & 0xf,
2254 1980 + (dosDate
>> 9), dosTime
, dosTime
>> 11,
2255 (dosTime
>> 5) & 0x3f, (dosTime
& 0x1f));
2257 #define DT2DOS(dt,r,d,m,y,h,mn,s) test_dt2dos(__LINE__,dt,r,d,m,y,h,mn,s)
2259 static void test_VariantTimeToDosDateTime(void)
2261 CHECKPTR(VariantTimeToDosDateTime
);
2264 DT2DOS(29221.0,1,1,1,1980,0,0,0); /* 1/1/1980 */
2265 DT2DOS(73050.0,1,31,12,2099,0,0,0); /* 31/12/2099 */
2266 DT2DOS(29220.0,0,0,0,0,0,0,0); /* 31/12/1979 - out of range */
2267 DT2DOS(73415.0,0,0,0,0,0,0,0); /* 31/12/2100 - out of range */
2270 DT2DOS(29221.00032407407,1,1,1,1980,0,0,29); /* 1/1/1980 12:00:28 AM */
2271 DT2DOS(29221.00034722222,1,1,1,1980,0,0,31); /* 1/1/1980 12:00:30 AM */
2272 DT2DOS(29221.04097222222,1,1,1,1980,0,59,0); /* 1/1/1980 12:59:00 AM */
2273 DT2DOS(29221.95833333333,1,1,1,1980,23,0,0); /* 1/1/1980 11:00:00 PM */
2276 static HRESULT (WINAPI
*pVarAbs
)(LPVARIANT
,LPVARIANT
);
2278 #define VARABS(vt,val,rvt,rval) \
2279 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
2280 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
2281 test_var_call1( __LINE__, pVarAbs, &v, &exp )
2283 static void test_VarAbs(void)
2285 static WCHAR szNum
[] = {'-','1','.','1','\0' };
2288 VARIANT v
, vDst
, exp
;
2293 /* Test all possible V_VT values.
2295 for (i
= 0; i
< ARRAY_SIZE(ExtraFlags
); i
++)
2299 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
2301 HRESULT hExpected
= DISP_E_BADVARTYPE
;
2305 memset(&v
, 0, sizeof(v
));
2306 V_VT(&v
) = vt
| ExtraFlags
[i
];
2307 V_VT(&vDst
) = VT_EMPTY
;
2309 hres
= pVarAbs(&v
,&vDst
);
2310 if (ExtraFlags
[i
] & VT_ARRAY
||
2311 (!ExtraFlags
[i
] && (vt
== VT_UNKNOWN
|| vt
== VT_BSTR
||
2312 vt
== VT_DISPATCH
|| vt
== VT_ERROR
|| vt
== VT_RECORD
)))
2314 hExpected
= DISP_E_TYPEMISMATCH
;
2316 else if (ExtraFlags
[i
] || vt
>= VT_CLSID
|| vt
== VT_VARIANT
)
2318 hExpected
= DISP_E_BADVARTYPE
;
2320 else if (IsValidVariantClearVT(vt
, ExtraFlags
[i
]))
2323 /* Native always fails on some vartypes that should be valid. don't
2324 * check that Wine does the same; these are bugs in native.
2326 if (vt
== VT_I8
|| vt
== VT_UI8
|| vt
== VT_INT
|| vt
== VT_UINT
||
2327 vt
== VT_I1
|| vt
== VT_UI2
|| vt
== VT_UI4
)
2329 ok(hres
== hExpected
, "VarAbs: expected 0x%X, got 0x%X for vt %d | 0x%X\n",
2330 hExpected
, hres
, vt
, ExtraFlags
[i
]);
2334 /* BOOL->I2, BSTR->R8, all others remain the same */
2335 VARABS(BOOL
,VARIANT_TRUE
,I2
,-VARIANT_TRUE
);
2336 VARABS(BOOL
,VARIANT_FALSE
,I2
,VARIANT_FALSE
);
2337 VARABS(EMPTY
,0,I2
,0);
2338 VARABS(EMPTY
,1,I2
,0);
2339 VARABS(NULL
,0,NULL
,0);
2340 VARABS(NULL
,1,NULL
,0);
2345 VARABS(UI1
,1,UI1
,1);
2350 VARABS(DATE
,1,DATE
,1);
2351 VARABS(DATE
,-1,DATE
,1);
2353 V_CY(&v
).int64
= -10000;
2354 memset(&vDst
,0,sizeof(vDst
));
2355 hres
= pVarAbs(&v
,&vDst
);
2356 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_CY
&& V_CY(&vDst
).int64
== 10000,
2357 "VarAbs(CY): expected 0x0 got 0x%X\n", hres
);
2358 GetLocaleInfoA(LOCALE_USER_DEFAULT
, LOCALE_SDECIMAL
, buff
, ARRAY_SIZE(buff
));
2361 trace("Skipping VarAbs(BSTR) as decimal separator is '%s'\n", buff
);
2367 V_BSTR(&v
) = (BSTR
)szNum
;
2368 memset(&vDst
,0,sizeof(vDst
));
2369 hres
= pVarAbs(&v
,&vDst
);
2370 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_R8
&& V_R8(&vDst
) == 1.1,
2371 "VarAbs: expected 0x0,%d,%g, got 0x%X,%d,%g\n", VT_R8
, 1.1, hres
, V_VT(&vDst
), V_R8(&vDst
));
2374 static HRESULT (WINAPI
*pVarNot
)(LPVARIANT
,LPVARIANT
);
2376 #define VARNOT(vt,val,rvt,rval) \
2377 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
2378 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
2379 test_var_call1( __LINE__, pVarNot, &v, &exp )
2381 static void test_VarNot(void)
2383 static const WCHAR szNum0
[] = {'0','\0' };
2384 static const WCHAR szNum1
[] = {'1','\0' };
2385 static const WCHAR szFalse
[] = { '#','F','A','L','S','E','#','\0' };
2386 static const WCHAR szTrue
[] = { '#','T','R','U','E','#','\0' };
2388 VARIANT v
, exp
, vDst
;
2389 DECIMAL
*pdec
= &V_DECIMAL(&v
);
2390 CY
*pcy
= &V_CY(&v
);
2395 /* Test all possible V_VT values */
2396 for (i
= 0; i
< ARRAY_SIZE(ExtraFlags
); i
++)
2400 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
2402 HRESULT hExpected
= DISP_E_BADVARTYPE
;
2406 memset(&v
, 0, sizeof(v
));
2407 V_VT(&v
) = vt
| ExtraFlags
[i
];
2408 V_VT(&vDst
) = VT_EMPTY
;
2412 case VT_I1
: case VT_UI1
: case VT_I2
: case VT_UI2
:
2413 case VT_INT
: case VT_UINT
: case VT_I4
: case VT_UI4
:
2414 case VT_R4
: case VT_R8
:
2415 case VT_DECIMAL
: case VT_BOOL
: case VT_NULL
: case VT_EMPTY
:
2416 case VT_DATE
: case VT_CY
:
2419 case VT_I8
: case VT_UI8
:
2424 hExpected
= DISP_E_TYPEMISMATCH
;
2426 case VT_UNKNOWN
: case VT_BSTR
: case VT_DISPATCH
: case VT_ERROR
:
2427 hExpected
= DISP_E_TYPEMISMATCH
;
2430 if (IsValidVariantClearVT(vt
, ExtraFlags
[i
]) && vt
!= VT_CLSID
)
2431 hExpected
= DISP_E_TYPEMISMATCH
;
2435 hres
= pVarNot(&v
,&vDst
);
2436 ok(hres
== hExpected
, "VarNot: expected 0x%X, got 0x%X vt %d|0x%X\n",
2437 hExpected
, hres
, vt
, ExtraFlags
[i
]);
2440 /* Test the values returned by all cases that can succeed */
2441 VARNOT(EMPTY
,0,I2
,-1);
2442 VARNOT(EMPTY
,1,I2
,-1);
2443 VARNOT(NULL
,0,NULL
,0);
2444 VARNOT(NULL
,1,NULL
,0);
2445 VARNOT(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
);
2446 VARNOT(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
);
2454 VARNOT(UI1
,1,UI1
,254);
2455 VARNOT(UI1
,0,UI1
,255);
2456 VARNOT(UI2
,0,I4
,-1);
2457 VARNOT(UI2
,1,I4
,-2);
2458 VARNOT(UI4
,0,I4
,-1);
2459 VARNOT(UI4
,1,I4
,-2);
2460 VARNOT(INT
,0,I4
,-1);
2461 VARNOT(INT
,1,I4
,-2);
2462 VARNOT(UINT
,0,I4
,-1);
2463 VARNOT(UINT
,1,I4
,-2);
2468 VARNOT(UI8
,0,I4
,-1);
2469 VARNOT(UI8
,1,I4
,-2);
2475 VARNOT(DATE
,1,I4
,-2);
2476 VARNOT(DATE
,0,I4
,-1);
2477 VARNOT(BSTR
,(BSTR
)szNum0
,I4
,-1);
2478 ok(V_VT(&v
) == VT_BSTR
&& V_BSTR(&v
) == szNum0
, "VarNot(0): changed input\n");
2479 VARNOT(BSTR
,(BSTR
)szNum1
,I4
,-2);
2480 ok(V_VT(&v
) == VT_BSTR
&& V_BSTR(&v
) == szNum1
, "VarNot(1): changed input\n");
2481 VARNOT(BSTR
, (BSTR
)szTrue
, BOOL
, VARIANT_FALSE
);
2482 VARNOT(BSTR
, (BSTR
)szFalse
, BOOL
, VARIANT_TRUE
);
2484 S(U(*pdec
)).sign
= DECIMAL_NEG
;
2485 S(U(*pdec
)).scale
= 0;
2487 S1(U1(*pdec
)).Mid32
= 0;
2488 S1(U1(*pdec
)).Lo32
= 1;
2489 VARNOT(DECIMAL
,*pdec
,I4
,0);
2492 VARNOT(CY
,*pcy
,I4
,-2);
2495 VARNOT(CY
,*pcy
,I4
,-1);
2498 VARNOT(CY
,*pcy
,I4
,-1);
2501 static HRESULT (WINAPI
*pVarSub
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
2503 #define VARSUB(vt1,val1,vt2,val2,rvt,rval) \
2504 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
2505 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
2506 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
2507 test_var_call2( __LINE__, pVarSub, &left, &right, &exp )
2509 static void test_VarSub(void)
2511 VARIANT left
, right
, exp
, result
, cy
, dec
;
2514 HRESULT hres
, expectedhres
;
2519 lbstr
= SysAllocString(sz12
);
2520 rbstr
= SysAllocString(sz12
);
2523 VariantInit(&right
);
2524 VariantInit(&result
);
2526 /* Test all possible flag/vt combinations & the resulting vt type */
2527 for (i
= 0; i
< ARRAY_SIZE(ExtraFlags
); i
++)
2530 VARTYPE leftvt
, rightvt
, resvt
;
2532 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
2537 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
2541 expectedhres
= S_OK
;
2543 memset(&left
, 0, sizeof(left
));
2544 memset(&right
, 0, sizeof(right
));
2545 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
2546 if (leftvt
== VT_BSTR
)
2547 V_BSTR(&left
) = lbstr
;
2548 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
2549 if (rightvt
== VT_BSTR
)
2550 V_BSTR(&right
) = rbstr
;
2551 V_VT(&result
) = VT_EMPTY
;
2553 /* All extra flags produce errors */
2554 if (ExtraFlags
[i
] == (VT_VECTOR
|VT_BYREF
|VT_RESERVED
) ||
2555 ExtraFlags
[i
] == (VT_VECTOR
|VT_RESERVED
) ||
2556 ExtraFlags
[i
] == (VT_VECTOR
|VT_BYREF
) ||
2557 ExtraFlags
[i
] == (VT_BYREF
|VT_RESERVED
) ||
2558 ExtraFlags
[i
] == VT_VECTOR
||
2559 ExtraFlags
[i
] == VT_BYREF
||
2560 ExtraFlags
[i
] == VT_RESERVED
)
2562 expectedhres
= DISP_E_BADVARTYPE
;
2565 else if (ExtraFlags
[i
] >= VT_ARRAY
)
2567 expectedhres
= DISP_E_TYPEMISMATCH
;
2570 /* Native VarSub cannot handle: VT_I1, VT_UI2, VT_UI4,
2571 VT_INT, VT_UINT and VT_UI8. Tested with WinXP */
2572 else if (!IsValidVariantClearVT(leftvt
, ExtraFlags
[i
]) ||
2573 !IsValidVariantClearVT(rightvt
, ExtraFlags
[i
]) ||
2574 leftvt
== VT_CLSID
|| rightvt
== VT_CLSID
||
2575 leftvt
== VT_VARIANT
|| rightvt
== VT_VARIANT
||
2576 leftvt
== VT_I1
|| rightvt
== VT_I1
||
2577 leftvt
== VT_UI2
|| rightvt
== VT_UI2
||
2578 leftvt
== VT_UI4
|| rightvt
== VT_UI4
||
2579 leftvt
== VT_UI8
|| rightvt
== VT_UI8
||
2580 leftvt
== VT_INT
|| rightvt
== VT_INT
||
2581 leftvt
== VT_UINT
|| rightvt
== VT_UINT
||
2582 leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
||
2583 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
)
2585 if (leftvt
== VT_RECORD
&& rightvt
== VT_I8
)
2588 expectedhres
= DISP_E_TYPEMISMATCH
;
2590 expectedhres
= DISP_E_BADVARTYPE
;
2592 else if (leftvt
< VT_UI1
&& rightvt
== VT_RECORD
)
2593 expectedhres
= DISP_E_TYPEMISMATCH
;
2594 else if (leftvt
>= VT_UI1
&& rightvt
== VT_RECORD
)
2595 expectedhres
= DISP_E_TYPEMISMATCH
;
2596 else if (leftvt
== VT_RECORD
&& rightvt
<= VT_UI1
)
2597 expectedhres
= DISP_E_TYPEMISMATCH
;
2598 else if (leftvt
== VT_RECORD
&& rightvt
> VT_UI1
)
2599 expectedhres
= DISP_E_BADVARTYPE
;
2601 expectedhres
= DISP_E_BADVARTYPE
;
2604 else if ((leftvt
== VT_NULL
&& rightvt
== VT_DISPATCH
) ||
2605 (leftvt
== VT_DISPATCH
&& rightvt
== VT_NULL
))
2607 else if (leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
||
2608 leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
)
2611 expectedhres
= DISP_E_TYPEMISMATCH
;
2613 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
2615 else if ((leftvt
== VT_EMPTY
&& rightvt
== VT_BSTR
) ||
2616 (leftvt
== VT_DATE
&& rightvt
== VT_DATE
) ||
2617 (leftvt
== VT_BSTR
&& rightvt
== VT_EMPTY
) ||
2618 (leftvt
== VT_BSTR
&& rightvt
== VT_BSTR
))
2620 else if (leftvt
== VT_DECIMAL
|| rightvt
== VT_DECIMAL
)
2622 else if (leftvt
== VT_DATE
|| rightvt
== VT_DATE
)
2624 else if (leftvt
== VT_CY
|| rightvt
== VT_CY
)
2626 else if (leftvt
== VT_R8
|| rightvt
== VT_R8
)
2628 else if (leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
) {
2630 } else if (leftvt
== VT_R4
|| rightvt
== VT_R4
) {
2631 if (leftvt
== VT_I4
|| rightvt
== VT_I4
||
2632 leftvt
== VT_I8
|| rightvt
== VT_I8
)
2637 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
2639 else if (leftvt
== VT_I4
|| rightvt
== VT_I4
)
2641 else if (leftvt
== VT_I2
|| rightvt
== VT_I2
||
2642 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
||
2643 (leftvt
== VT_EMPTY
&& rightvt
== VT_EMPTY
))
2645 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
2650 expectedhres
= DISP_E_TYPEMISMATCH
;
2653 hres
= pVarSub(&left
, &right
, &result
);
2655 ok(hres
== expectedhres
&& V_VT(&result
) == resvt
,
2656 "VarSub: %d|0x%X, %d|0x%X: Expected failure 0x%X, "
2657 "got 0x%X, expected vt %d got vt %d\n",
2658 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
],
2659 expectedhres
, hres
, resvt
, V_VT(&result
));
2664 /* Test returned values */
2665 VARSUB(I4
,4,I4
,2,I4
,2);
2666 VARSUB(I2
,4,I2
,2,I2
,2);
2667 VARSUB(I2
,-13,I4
,5,I4
,-18);
2668 VARSUB(I4
,-13,I4
,5,I4
,-18);
2669 VARSUB(I2
,7,R4
,0.5f
,R4
,6.5f
);
2670 VARSUB(R4
,0.5f
,I4
,5,R8
,-4.5);
2671 VARSUB(R8
,7.1,BOOL
,0,R8
,7.1);
2672 VARSUB(BSTR
,lbstr
,I2
,4,R8
,8);
2673 VARSUB(BSTR
,lbstr
,BOOL
,1,R8
,11);
2674 VARSUB(BSTR
,lbstr
,R4
,0.1f
,R8
,11.9);
2675 VARSUB(R4
,0.2f
,BSTR
,rbstr
,R8
,-11.8);
2676 VARSUB(DATE
,2.25,I4
,7,DATE
,-4.75);
2677 VARSUB(DATE
,1.25,R4
,-1.7f
,DATE
,2.95);
2679 VARSUB(UI1
, UI1_MAX
, UI1
, UI1_MAX
, UI1
, 0);
2680 VARSUB(I2
, I2_MAX
, I2
, I2_MAX
, I2
, 0);
2681 VARSUB(I2
, I2_MIN
, I2
, I2_MIN
, I2
, 0);
2682 VARSUB(I4
, I4_MAX
, I4
, I4_MAX
, I4
, 0);
2683 VARSUB(I4
, I4_MIN
, I4
, I4_MIN
, I4
, 0);
2684 VARSUB(R4
, R4_MAX
, R4
, R4_MAX
, R4
, 0.0f
);
2685 VARSUB(R4
, R4_MAX
, R4
, R4_MIN
, R4
, R4_MAX
- R4_MIN
);
2686 VARSUB(R4
, R4_MIN
, R4
, R4_MIN
, R4
, 0.0f
);
2687 VARSUB(R8
, R8_MAX
, R8
, R8_MIN
, R8
, R8_MAX
- R8_MIN
);
2688 VARSUB(R8
, R8_MIN
, R8
, R8_MIN
, R8
, 0.0);
2690 /* Manually test BSTR + BSTR */
2691 V_VT(&left
) = VT_BSTR
;
2692 V_BSTR(&left
) = lbstr
;
2693 V_VT(&right
) = VT_BSTR
;
2694 V_BSTR(&right
) = rbstr
;
2695 hres
= pVarSub(&left
, &right
, &result
);
2696 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
2697 "VarSub: expected coerced type VT_R8, got %s!\n", vtstr(V_VT(&result
)));
2698 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 0.0),
2699 "VarSub: BSTR + BSTR, expected %f got %f\n", 0.0, V_R8(&result
));
2701 /* Manually test some VT_CY and VT_DECIMAL variants */
2703 hres
= VarCyFromI4(4711, &V_CY(&cy
));
2704 ok(hres
== S_OK
, "VarCyFromI4 failed!\n");
2705 V_VT(&dec
) = VT_DECIMAL
;
2706 hres
= VarDecFromR8(-4.2, &V_DECIMAL(&dec
));
2707 ok(hres
== S_OK
, "VarDecFromR4 failed!\n");
2708 memset(&left
, 0, sizeof(left
));
2709 memset(&right
, 0, sizeof(right
));
2710 V_VT(&left
) = VT_I4
;
2712 V_VT(&right
) = VT_UI1
;
2715 hres
= pVarSub(&cy
, &right
, &result
);
2716 ok(hres
== S_OK
&& V_VT(&result
) == VT_CY
,
2717 "VarSub: expected coerced type VT_CY, got %s!\n", vtstr(V_VT(&result
)));
2718 hres
= VarR8FromCy(V_CY(&result
), &r
);
2719 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 4702.0), "VarSub: CY value %f, expected %f\n", r
, 4720.0);
2721 hres
= pVarSub(&left
, &dec
, &result
);
2722 ok(hres
== S_OK
&& V_VT(&result
) == VT_DECIMAL
,
2723 "VarSub: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result
)));
2724 hres
= VarR8FromDec(&V_DECIMAL(&result
), &r
);
2725 ok(hres
== S_OK
&& EQ_DOUBLE(r
, -6.8), "VarSub: DECIMAL value %f, expected %f\n", r
, -6.8);
2727 SysFreeString(lbstr
);
2728 SysFreeString(rbstr
);
2731 static HRESULT (WINAPI
*pVarMod
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
2733 static void test_Mod( int line
, VARIANT
*left
, VARIANT
*right
, VARIANT
*expected
, HRESULT expres
)
2738 memset( &result
, 0, sizeof(result
) );
2739 hres
= pVarMod( left
, right
, &result
);
2740 ok_(__FILE__
,line
)( hres
== expres
, "wrong result %x/%x\n", hres
, expres
);
2742 ok_(__FILE__
,line
)( is_expected_variant( &result
, expected
),
2743 "got %s expected %s\n", variantstr(&result
), variantstr(expected
) );
2746 #define VARMOD(vt1,vt2,val1,val2,rvt,rval) \
2747 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
2748 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
2749 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
2750 test_var_call2( __LINE__, pVarMod, &left, &right, &exp )
2752 #define VARMOD2(vt1,vt2,val1,val2,rvt,rval,hexpected) \
2753 V_VT(&left) = VT_##vt1; V_I4(&left) = val1; \
2754 V_VT(&right) = VT_##vt2; V_I4(&right) = val2; \
2755 V_VT(&exp) = VT_##rvt; V_I4(&exp) = rval; \
2756 test_Mod( __LINE__, &left, &right, &exp, hexpected )
2758 static void test_VarMod(void)
2760 VARIANT v1
, v2
, vDst
, left
, right
, exp
;
2762 HRESULT hexpected
= 0;
2763 static const WCHAR szNum0
[] = {'1','2','5','\0'};
2764 static const WCHAR szNum1
[] = {'1','0','\0'};
2766 BOOL lFound
, rFound
;
2768 BSTR strNum0
, strNum1
;
2772 VARMOD(I1
,BOOL
,100,10,I4
,0);
2773 VARMOD(I1
,I1
,100,10,I4
,0);
2774 VARMOD(I1
,UI1
,100,10,I4
,0);
2775 VARMOD(I1
,I2
,100,10,I4
,0);
2776 VARMOD(I1
,UI2
,100,10,I4
,0);
2777 VARMOD(I1
,I4
,100,10,I4
,0);
2778 VARMOD(I1
,UI4
,100,10,I4
,0);
2779 VARMOD(I1
,R4
,100,10,I4
,0);
2780 VARMOD(I1
,R8
,100,10,I4
,0);
2782 VARMOD(UI1
,BOOL
,100,10,I2
,0);
2783 VARMOD(UI1
,I1
,100,10,I4
,0);
2784 VARMOD(UI1
,UI1
,100,10,UI1
,0);
2785 VARMOD(UI1
,I2
,100,10,I2
,0);
2786 VARMOD(UI1
,UI2
,100,10,I4
,0);
2787 VARMOD(UI1
,I4
,100,10,I4
,0);
2788 VARMOD(UI1
,UI4
,100,10,I4
,0);
2789 VARMOD(UI1
,R4
,100,10,I4
,0);
2790 VARMOD(UI1
,R8
,100,10,I4
,0);
2792 VARMOD(I2
,BOOL
,100,10,I2
,0);
2793 VARMOD(I2
,I1
,100,10,I4
,0);
2794 VARMOD(I2
,UI1
,100,10,I2
,0);
2795 VARMOD(I2
,I2
,100,10,I2
,0);
2796 VARMOD(I2
,UI2
,100,10,I4
,0);
2797 VARMOD(I2
,I4
,100,10,I4
,0);
2798 VARMOD(I2
,UI4
,100,10,I4
,0);
2799 VARMOD(I2
,R4
,100,10,I4
,0);
2800 VARMOD(I2
,R8
,100,10,I4
,0);
2802 VARMOD(I4
,BOOL
,100,10,I4
,0);
2803 VARMOD(I4
,I1
,100,10,I4
,0);
2804 VARMOD(I4
,UI1
,100,10,I4
,0);
2805 VARMOD(I4
,I2
,100,10,I4
,0);
2806 VARMOD(I4
,UI2
,100,10,I4
,0);
2807 VARMOD(I4
,I4
,100,10,I4
,0);
2808 VARMOD(I4
,UI4
,100,10,I4
,0);
2809 VARMOD(I4
,R4
,100,10,I4
,0);
2810 VARMOD(I4
,R8
,100,10,I4
,0);
2811 VARMOD(UI4
,BOOL
,100,10,I4
,0);
2812 VARMOD(UI4
,I1
,100,10,I4
,0);
2813 VARMOD(UI4
,UI1
,100,10,I4
,0);
2814 VARMOD(UI4
,I2
,100,10,I4
,0);
2815 VARMOD(UI4
,UI2
,100,10,I4
,0);
2816 VARMOD(UI4
,I4
,100,10,I4
,0);
2817 VARMOD(UI4
,UI4
,100,10,I4
,0);
2818 VARMOD(UI4
,R4
,100,10,I4
,0);
2819 VARMOD(UI4
,R8
,100,10,I4
,0);
2820 VARMOD(R4
,BOOL
,100,10,I4
,0);
2821 VARMOD(R4
,I1
,100,10,I4
,0);
2822 VARMOD(R4
,UI1
,100,10,I4
,0);
2823 VARMOD(R4
,I2
,100,10,I4
,0);
2824 VARMOD(R4
,UI2
,100,10,I4
,0);
2825 VARMOD(R4
,I4
,100,10,I4
,0);
2826 VARMOD(R4
,UI4
,100,10,I4
,0);
2827 VARMOD(R4
,R4
,100,10,I4
,0);
2828 VARMOD(R4
,R8
,100,10,I4
,0);
2829 VARMOD(R8
,BOOL
,100,10,I4
,0);
2830 VARMOD(R8
,I1
,100,10,I4
,0);
2831 VARMOD(R8
,UI1
,100,10,I4
,0);
2832 VARMOD(R8
,I2
,100,10,I4
,0);
2833 VARMOD(R8
,UI2
,100,10,I4
,0);
2834 VARMOD(R8
,I4
,100,10,I4
,0);
2835 VARMOD(R8
,UI4
,100,10,I4
,0);
2836 VARMOD(R8
,R4
,100,10,I4
,0);
2837 VARMOD(R8
,R8
,100,10,I4
,0);
2839 VARMOD(INT
,INT
,100,10,I4
,0);
2840 VARMOD(INT
,UINT
,100,10,I4
,0);
2842 VARMOD(BOOL
,BOOL
,100,10,I2
,0);
2843 VARMOD(BOOL
,I1
,100,10,I4
,0);
2844 VARMOD(BOOL
,UI1
,100,10,I2
,0);
2845 VARMOD(BOOL
,I2
,100,10,I2
,0);
2846 VARMOD(BOOL
,UI2
,100,10,I4
,0);
2847 VARMOD(BOOL
,I4
,100,10,I4
,0);
2848 VARMOD(BOOL
,UI4
,100,10,I4
,0);
2849 VARMOD(BOOL
,R4
,100,10,I4
,0);
2850 VARMOD(BOOL
,R8
,100,10,I4
,0);
2851 VARMOD(BOOL
,DATE
,100,10,I4
,0);
2853 VARMOD(DATE
,BOOL
,100,10,I4
,0);
2854 VARMOD(DATE
,I1
,100,10,I4
,0);
2855 VARMOD(DATE
,UI1
,100,10,I4
,0);
2856 VARMOD(DATE
,I2
,100,10,I4
,0);
2857 VARMOD(DATE
,UI2
,100,10,I4
,0);
2858 VARMOD(DATE
,I4
,100,10,I4
,0);
2859 VARMOD(DATE
,UI4
,100,10,I4
,0);
2860 VARMOD(DATE
,R4
,100,10,I4
,0);
2861 VARMOD(DATE
,R8
,100,10,I4
,0);
2862 VARMOD(DATE
,DATE
,100,10,I4
,0);
2864 strNum0
= SysAllocString(szNum0
);
2865 strNum1
= SysAllocString(szNum1
);
2866 VARMOD(BSTR
,BSTR
,strNum0
,strNum1
,I4
,5);
2867 VARMOD(BSTR
,I1
,strNum0
,10,I4
,5);
2868 VARMOD(BSTR
,I2
,strNum0
,10,I4
,5);
2869 VARMOD(BSTR
,I4
,strNum0
,10,I4
,5);
2870 VARMOD(BSTR
,R4
,strNum0
,10,I4
,5);
2871 VARMOD(BSTR
,R8
,strNum0
,10,I4
,5);
2872 VARMOD(I4
,BSTR
,125,strNum1
,I4
,5);
2876 VARMOD(BOOL
,I8
,100,10,I8
,0);
2877 VARMOD(I1
,I8
,100,10,I8
,0);
2878 VARMOD(UI1
,I8
,100,10,I8
,0);
2879 VARMOD(I2
,I8
,100,10,I8
,0);
2880 VARMOD(I4
,I8
,100,10,I8
,0);
2881 VARMOD(UI4
,I8
,100,10,I8
,0);
2882 VARMOD(R4
,I8
,100,10,I8
,0);
2883 VARMOD(R8
,I8
,100,10,I8
,0);
2884 VARMOD(DATE
,I8
,100,10,I8
,0);
2886 VARMOD(I8
,BOOL
,100,10,I8
,0);
2887 VARMOD(I8
,I1
,100,10,I8
,0);
2888 VARMOD(I8
,UI1
,100,10,I8
,0);
2889 VARMOD(I8
,I2
,100,10,I8
,0);
2890 VARMOD(I8
,UI2
,100,10,I8
,0);
2891 VARMOD(I8
,I4
,100,10,I8
,0);
2892 VARMOD(I8
,UI4
,100,10,I8
,0);
2893 VARMOD(I8
,R4
,100,10,I8
,0);
2894 VARMOD(I8
,R8
,100,10,I8
,0);
2895 VARMOD(I8
,I8
,100,10,I8
,0);
2897 VARMOD(BSTR
,I8
,strNum0
,10,I8
,5);
2900 /* test all combinations of types */
2901 for(l
= 0; l
< VT_BSTR_BLOB
; l
++)
2905 for(r
= 0; r
< VT_BSTR_BLOB
; r
++)
2909 if(l
== VT_BSTR
) continue;
2910 if(l
== VT_DISPATCH
) continue;
2911 if(r
== VT_BSTR
) continue;
2912 if(r
== VT_DISPATCH
) continue;
2946 hexpected
= DISP_E_BADVARTYPE
;
2983 if(((l
== VT_I8
) && (r
== VT_INT
)) || ((l
== VT_INT
) && (r
== VT_I8
)))
2985 hexpected
= DISP_E_TYPEMISMATCH
;
2986 } else if((l
== VT_EMPTY
) && (r
== VT_NULL
))
2989 } else if((l
== VT_NULL
) && (r
== VT_EMPTY
))
2992 } else if((l
== VT_EMPTY
) && (r
== VT_CY
))
2995 } else if((l
== VT_EMPTY
) && (r
== VT_RECORD
))
2997 hexpected
= DISP_E_TYPEMISMATCH
;
2998 } else if((r
== VT_EMPTY
) && lFound
&& lValid
)
3000 hexpected
= DISP_E_DIVBYZERO
;
3001 } else if((l
== VT_ERROR
) || ((r
== VT_ERROR
) && lFound
&& lValid
))
3003 hexpected
= DISP_E_TYPEMISMATCH
;
3004 } else if((l
== VT_NULL
) && (r
== VT_NULL
))
3007 } else if((l
== VT_VARIANT
) || ((r
== VT_VARIANT
) && lFound
&& lValid
))
3009 hexpected
= DISP_E_TYPEMISMATCH
;
3010 } else if((l
== VT_NULL
) && (r
== VT_RECORD
))
3012 hexpected
= DISP_E_TYPEMISMATCH
;
3013 } else if((l
== VT_I8
) && (r
== VT_DECIMAL
))
3016 } else if((l
== VT_DECIMAL
) && (r
== VT_I8
))
3019 } else if((l
== VT_UNKNOWN
) || ((r
== VT_UNKNOWN
) && lFound
&& lValid
))
3021 hexpected
= DISP_E_TYPEMISMATCH
;
3022 } else if((l
== VT_NULL
) && rFound
)
3025 } else if(l
== VT_RECORD
)
3027 hexpected
= DISP_E_TYPEMISMATCH
;
3028 } else if((r
== VT_RECORD
) && lValid
&& lFound
)
3030 hexpected
= DISP_E_TYPEMISMATCH
;
3031 } else if((l
== VT_EMPTY
) && (r
== VT_EMPTY
))
3033 hexpected
= DISP_E_DIVBYZERO
;
3034 } else if((l
== VT_CY
) && !rFound
)
3036 hexpected
= DISP_E_BADVARTYPE
;
3037 } else if(lFound
&& !rFound
)
3039 hexpected
= DISP_E_BADVARTYPE
;
3040 } else if(!lFound
&& rFound
)
3042 hexpected
= DISP_E_BADVARTYPE
;
3043 } else if((r
== VT_NULL
) && lFound
&& lValid
)
3046 } else if((l
== VT_NULL
) || (r
== VT_NULL
))
3048 hexpected
= DISP_E_BADVARTYPE
;
3049 } else if((l
== VT_VARIANT
) || (r
== VT_VARIANT
))
3051 hexpected
= DISP_E_BADVARTYPE
;
3052 } else if(!lFound
&& !rFound
)
3054 hexpected
= DISP_E_BADVARTYPE
;
3061 V_CY(&v1
).int64
= 1000000;
3066 else if(l
== VT_UI8
)
3070 else if(l
== VT_DATE
)
3072 else if (l
== VT_DECIMAL
)
3074 V_DECIMAL(&v1
).Hi32
= 0;
3075 U1(V_DECIMAL(&v1
)).Lo64
= 100;
3076 U(V_DECIMAL(&v1
)).signscale
= 0;
3082 V_CY(&v2
).int64
= 10000;
3087 else if(r
== VT_UI8
)
3091 else if(r
== VT_DATE
)
3093 else if (r
== VT_DECIMAL
)
3095 V_DECIMAL(&v2
).Hi32
= 0;
3096 U1(V_DECIMAL(&v2
)).Lo64
= 100;
3097 U(V_DECIMAL(&v2
)).signscale
= 0;
3102 if ((l
!= VT_I8
&& l
!= VT_UI8
&& r
!= VT_I8
&& r
!= VT_UI8
) || has_i8
)
3104 hres
= pVarMod(&v1
,&v2
,&vDst
);
3105 ok(hres
== hexpected
,
3106 "VarMod: expected 0x%x, got 0x%X for l type of %d, r type of %d,\n", hexpected
, hres
, l
, r
);
3112 /****************************/
3113 /* test some bad parameters */
3114 VARMOD(I4
,I4
,-1,-1,I4
,0);
3116 /* test modulus with zero */
3117 VARMOD2(I4
,I4
,100,0,EMPTY
,0,DISP_E_DIVBYZERO
);
3119 VARMOD(I4
,I4
,0,10,I4
,0); /* test 0 mod 10 */
3121 /* right parameter is type empty */
3122 VARMOD2(I4
,EMPTY
,100,10,EMPTY
,0,DISP_E_DIVBYZERO
);
3124 /* left parameter is type empty */
3125 VARMOD2(EMPTY
,I4
,100,10,I4
,0,S_OK
);
3127 /* mod with a null left value */
3128 VARMOD2(NULL
,I4
,125,10,NULL
,0,S_OK
);
3130 /* mod with a null right value */
3131 VARMOD2(I4
,NULL
,100,10,NULL
,0,S_OK
);
3133 /* void left value */
3134 VARMOD2(VOID
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
3136 /* void right value */
3137 VARMOD2(I4
,VOID
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
3139 /* null left value, void right value */
3140 VARMOD2(NULL
,VOID
,100,10,EMPTY
, 0, DISP_E_BADVARTYPE
);
3142 /* void left value, null right value */
3143 VARMOD2(VOID
,NULL
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
3145 /* some currencies */
3148 V_CY(&v1
).int64
= 100000;
3149 V_CY(&v2
).int64
= 100000;
3150 hres
= pVarMod(&v1
,&v2
,&vDst
);
3151 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I4
&& V_I4(&vDst
) == 0,
3152 "VarMod: expected 0x%x,%d,%d, got 0x%X,%d,%d\n", S_OK
, VT_I4
, 0, hres
, V_VT(&vDst
), V_I4(&vDst
));
3157 V_CY(&v2
).int64
= 100000;
3158 hres
= pVarMod(&v1
,&v2
,&vDst
);
3159 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I4
&& V_I4(&vDst
) == 0,
3160 "VarMod: expected 0x%x,%d,%d, got 0x%X,%d,%d\n", S_OK
, VT_I4
, 0, hres
, V_VT(&vDst
), V_I4(&vDst
));
3163 V_VT(&v1
) = VT_DECIMAL
;
3164 V_VT(&v2
) = VT_DECIMAL
;
3165 VarDecFromI4(100, &V_DECIMAL(&v1
));
3166 VarDecFromI4(10, &V_DECIMAL(&v2
));
3167 hres
= pVarMod(&v1
,&v2
,&vDst
);
3168 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I4
&& V_I4(&vDst
) == 0,
3169 "VarMod: expected 0x%x,%d,%d, got 0x%X,%d,%d\n", S_OK
, VT_I4
, 0, hres
, V_VT(&vDst
), V_I4(&vDst
));
3172 V_VT(&v2
) = VT_DECIMAL
;
3174 VarDecFromI4(10, &V_DECIMAL(&v2
));
3175 hres
= pVarMod(&v1
,&v2
,&vDst
);
3176 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I4
&& V_I4(&vDst
) == 0,
3177 "VarMod: expected 0x%x,%d,%d, got 0x%X,%d,%d\n", S_OK
, VT_I4
, 0, hres
, V_VT(&vDst
), V_I4(&vDst
));
3179 VARMOD2(UINT
,I4
,100,10,I4
,0,S_OK
);
3181 /* test that an error results in the type of the result changing but not its value */
3182 V_VT(&v1
) = VT_UNKNOWN
;
3183 V_VT(&v2
) = VT_EMPTY
;
3185 V_CY(&v2
).int64
= 100000;
3186 V_VT(&vDst
) = VT_I4
;
3188 hres
= pVarMod(&v1
,&v2
,&vDst
);
3189 ok(hres
== DISP_E_TYPEMISMATCH
&& V_VT(&vDst
) == VT_EMPTY
&& V_I4(&vDst
) == 1231,
3190 "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
));
3193 /* test some invalid types */
3194 /*TODO: not testing VT_DISPATCH */
3197 VARMOD2(I8
,INT
,100,10,EMPTY
,0,DISP_E_TYPEMISMATCH
);
3199 VARMOD2(ERROR
,I4
,100,10,EMPTY
,0,DISP_E_TYPEMISMATCH
);
3200 VARMOD2(VARIANT
,I4
,100,10,EMPTY
,0,DISP_E_TYPEMISMATCH
);
3201 VARMOD2(UNKNOWN
,I4
,100,10,EMPTY
,0,DISP_E_TYPEMISMATCH
);
3202 VARMOD2(VOID
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
3203 VARMOD2(HRESULT
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
3204 VARMOD2(PTR
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
3205 VARMOD2(SAFEARRAY
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
3206 VARMOD2(CARRAY
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
3207 VARMOD2(USERDEFINED
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
3208 VARMOD2(LPSTR
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
3209 VARMOD2(LPWSTR
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
3210 VARMOD2(RECORD
,I4
,100,10,EMPTY
,0,DISP_E_TYPEMISMATCH
);
3211 VARMOD2(FILETIME
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
3212 VARMOD2(BLOB
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
3213 VARMOD2(STREAM
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
3214 VARMOD2(STORAGE
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
3215 VARMOD2(STREAMED_OBJECT
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
3216 VARMOD2(STORED_OBJECT
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
3217 VARMOD2(BLOB_OBJECT
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
3218 VARMOD2(CF
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
3219 VARMOD2(CLSID
,CLSID
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
3220 VARMOD2(VECTOR
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
3221 VARMOD2(ARRAY
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
3222 VARMOD2(BYREF
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
3224 /* test some more invalid types */
3229 hres
= pVarMod(&v1
,&v2
,&vDst
);
3230 ok(hres
== DISP_E_BADVARTYPE
&& V_VT(&vDst
) == VT_EMPTY
,
3231 "VarMod: expected 0x%x,%d, got 0x%X,%d\n", DISP_E_BADVARTYPE
, VT_EMPTY
, hres
, V_VT(&vDst
));
3233 SysFreeString(strNum0
);
3234 SysFreeString(strNum1
);
3237 static HRESULT (WINAPI
*pVarFix
)(LPVARIANT
,LPVARIANT
);
3239 #define VARFIX(vt,val,rvt,rval) \
3240 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
3241 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
3242 test_var_call1( __LINE__, pVarFix, &v, &exp )
3244 static void test_VarFix(void)
3246 static const WCHAR szNumMinus1
[] = {'-','1','\0' };
3248 VARIANT v
, exp
, vDst
;
3249 DECIMAL
*pdec
= &V_DECIMAL(&v
);
3250 CY
*pcy
= &V_CY(&v
);
3255 /* Test all possible V_VT values */
3256 for (i
= 0; i
< ARRAY_SIZE(ExtraFlags
); i
++)
3260 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
3266 memset(&v
, 0, sizeof(v
));
3267 V_VT(&v
) = vt
| ExtraFlags
[i
];
3268 V_VT(&vDst
) = VT_EMPTY
;
3272 case VT_UI1
: case VT_I2
: case VT_I4
: case VT_R4
: case VT_R8
:
3273 case VT_DECIMAL
: case VT_BOOL
: case VT_NULL
: case VT_EMPTY
:
3274 case VT_DATE
: case VT_CY
:
3283 hres
= pVarFix(&v
,&vDst
);
3285 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
3286 "VarFix: expected failure, got 0x%X vt %d|0x%X\n",
3287 hres
, vt
, ExtraFlags
[i
]);
3289 ok(hres
== S_OK
, "VarFix: expected S_OK, got 0x%X vt %d|0x%X\n",
3290 hres
, vt
, ExtraFlags
[i
]);
3294 VARFIX(BOOL
,VARIANT_TRUE
,I2
,VARIANT_TRUE
);
3295 VARFIX(BOOL
,VARIANT_FALSE
,I2
,0);
3296 VARFIX(BOOL
,1,I2
,1);
3297 VARFIX(UI1
,1,UI1
,1);
3298 VARFIX(I2
,-1,I2
,-1);
3299 VARFIX(I4
,-1,I4
,-1);
3302 VARFIX(I8
,-1,I8
,-1);
3304 VARFIX(R4
,1.4f
,R4
,1);
3305 VARFIX(R4
,1.5f
,R4
,1);
3306 VARFIX(R4
,1.6f
,R4
,1);
3307 VARFIX(R4
,-1.4f
,R4
,-1);
3308 VARFIX(R4
,-1.5f
,R4
,-1);
3309 VARFIX(R4
,-1.6f
,R4
,-1);
3310 /* DATE & R8 round as for R4 */
3311 VARFIX(DATE
,-1,DATE
,-1);
3312 VARFIX(R8
,-1,R8
,-1);
3313 VARFIX(BSTR
,(BSTR
)szNumMinus1
,R8
,-1);
3315 V_VT(&v
) = VT_EMPTY
;
3316 hres
= pVarFix(&v
,&vDst
);
3317 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I2
&& V_I2(&vDst
) == 0,
3318 "VarFix: expected 0x0,%d,0 got 0x%X,%d,%d\n", VT_EMPTY
,
3319 hres
, V_VT(&vDst
), V_I2(&vDst
));
3322 hres
= pVarFix(&v
,&vDst
);
3323 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_NULL
,
3324 "VarFix: expected 0x0,%d got 0x%X,%d\n", VT_NULL
, hres
, V_VT(&vDst
));
3326 V_VT(&v
) = VT_DECIMAL
;
3327 S(U(*pdec
)).sign
= DECIMAL_NEG
;
3328 S(U(*pdec
)).scale
= 0;
3330 S1(U1(*pdec
)).Mid32
= 0;
3331 S1(U1(*pdec
)).Lo32
= 1;
3332 hres
= pVarFix(&v
,&vDst
);
3333 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_DECIMAL
&& !memcmp(&V_DECIMAL(&v
), &V_DECIMAL(&vDst
), sizeof(DECIMAL
)),
3334 "VarFix: expected 0x0,%d,identical, got 0x%X,%d\n", VT_DECIMAL
,
3337 /* FIXME: Test some fractional decimals when VarDecFix is implemented */
3340 pcy
->int64
= -10000;
3341 hres
= pVarFix(&v
,&vDst
);
3342 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_CY
&& V_CY(&vDst
).int64
== -10000,
3343 "VarFix: VT_CY wrong, hres=0x%X\n", hres
);
3346 pcy
->int64
= -16000;
3347 hres
= pVarFix(&v
,&vDst
);
3348 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_CY
&& V_CY(&vDst
).int64
== -10000,
3349 "VarFix: VT_CY wrong, hres=0x%X\n", hres
);
3352 static HRESULT (WINAPI
*pVarInt
)(LPVARIANT
,LPVARIANT
);
3354 #define VARINT(vt,val,rvt,rval) \
3355 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
3356 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
3357 test_var_call1( __LINE__, pVarInt, &v, &exp )
3359 static void test_VarInt(void)
3361 static const WCHAR szNumMinus1
[] = {'-','1','\0' };
3363 VARIANT v
, exp
, vDst
;
3364 DECIMAL
*pdec
= &V_DECIMAL(&v
);
3365 CY
*pcy
= &V_CY(&v
);
3370 /* Test all possible V_VT values */
3371 for (i
= 0; i
< ARRAY_SIZE(ExtraFlags
); i
++)
3375 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
3381 memset(&v
, 0, sizeof(v
));
3382 V_VT(&v
) = vt
| ExtraFlags
[i
];
3383 V_VT(&vDst
) = VT_EMPTY
;
3387 case VT_UI1
: case VT_I2
: case VT_I4
: case VT_R4
: case VT_R8
:
3388 case VT_DECIMAL
: case VT_BOOL
: case VT_NULL
: case VT_EMPTY
:
3389 case VT_DATE
: case VT_CY
:
3398 hres
= pVarInt(&v
,&vDst
);
3400 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
3401 "VarInt: expected failure, got 0x%X vt %d|0x%X\n",
3402 hres
, vt
, ExtraFlags
[i
]);
3404 ok(hres
== S_OK
, "VarInt: expected S_OK, got 0x%X vt %d|0x%X\n",
3405 hres
, vt
, ExtraFlags
[i
]);
3409 VARINT(BOOL
,VARIANT_TRUE
,I2
,VARIANT_TRUE
);
3410 VARINT(BOOL
,VARIANT_FALSE
,I2
,0);
3411 VARINT(BOOL
,1,I2
,1);
3412 VARINT(UI1
,1,UI1
,1);
3413 VARINT(I2
,-1,I2
,-1);
3414 VARINT(I4
,-1,I4
,-1);
3417 VARINT(I8
,-1,I8
,-1);
3419 VARINT(R4
,1.4f
,R4
,1);
3420 VARINT(R4
,1.5f
,R4
,1);
3421 VARINT(R4
,1.6f
,R4
,1);
3422 VARINT(R4
,-1.4f
,R4
,-2); /* Note these 3 are different from VarFix */
3423 VARINT(R4
,-1.5f
,R4
,-2);
3424 VARINT(R4
,-1.6f
,R4
,-2);
3425 /* DATE & R8 round as for R4 */
3426 VARINT(DATE
,-1,DATE
,-1);
3427 VARINT(R8
,-1,R8
,-1);
3428 VARINT(BSTR
,(BSTR
)szNumMinus1
,R8
,-1);
3430 V_VT(&v
) = VT_EMPTY
;
3431 hres
= pVarInt(&v
,&vDst
);
3432 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I2
&& V_I2(&vDst
) == 0,
3433 "VarInt: expected 0x0,%d,0 got 0x%X,%d,%d\n", VT_EMPTY
,
3434 hres
, V_VT(&vDst
), V_I2(&vDst
));
3437 hres
= pVarInt(&v
,&vDst
);
3438 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_NULL
,
3439 "VarInt: expected 0x0,%d got 0x%X,%d\n", VT_NULL
, hres
, V_VT(&vDst
));
3441 V_VT(&v
) = VT_DECIMAL
;
3442 S(U(*pdec
)).sign
= DECIMAL_NEG
;
3443 S(U(*pdec
)).scale
= 0;
3445 S1(U1(*pdec
)).Mid32
= 0;
3446 S1(U1(*pdec
)).Lo32
= 1;
3447 hres
= pVarInt(&v
,&vDst
);
3448 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_DECIMAL
&& !memcmp(&V_DECIMAL(&v
), &V_DECIMAL(&vDst
), sizeof(DECIMAL
)),
3449 "VarInt: expected 0x0,%d,identical, got 0x%X,%d\n", VT_DECIMAL
,
3452 /* FIXME: Test some fractional decimals when VarDecInt is implemented */
3455 pcy
->int64
= -10000;
3456 hres
= pVarInt(&v
,&vDst
);
3457 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_CY
&& V_CY(&vDst
).int64
== -10000,
3458 "VarInt: VT_CY wrong, hres=0x%X\n", hres
);
3461 pcy
->int64
= -11000;
3462 hres
= pVarInt(&v
,&vDst
);
3463 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_CY
&& V_CY(&vDst
).int64
== -20000,
3464 "VarInt: VT_CY wrong, hres=0x%X 0x%x%08x\n",
3465 hres
, (DWORD
)(V_CY(&vDst
).int64
>> 32), (DWORD
)V_CY(&vDst
).int64
);
3468 static HRESULT (WINAPI
*pVarNeg
)(LPVARIANT
,LPVARIANT
);
3470 #define VARNEG(vt,val,rvt,rval) \
3471 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
3472 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
3473 test_var_call1( __LINE__, pVarNeg, &v, &exp )
3475 static void test_VarNeg(void)
3477 static const WCHAR szNumMinus1
[] = {'-','1','\0' };
3478 static const WCHAR szNum1
[] = {'1','\0' };
3480 VARIANT v
, exp
, vDst
;
3481 DECIMAL
*pdec
= &V_DECIMAL(&v
);
3482 CY
*pcy
= &V_CY(&v
);
3487 /* Test all possible V_VT values. But don't test the exact return values
3488 * except for success/failure, since M$ made a hash of them in the
3489 * native version. This at least ensures (as with all tests here) that
3490 * we will notice if/when new vtypes/flags are added in native.
3492 for (i
= 0; i
< ARRAY_SIZE(ExtraFlags
); i
++)
3496 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
3502 memset(&v
, 0, sizeof(v
));
3503 V_VT(&v
) = vt
| ExtraFlags
[i
];
3504 V_VT(&vDst
) = VT_EMPTY
;
3508 case VT_UI1
: case VT_I2
: case VT_I4
:
3509 case VT_R4
: case VT_R8
:
3510 case VT_DECIMAL
: case VT_BOOL
: case VT_NULL
: case VT_EMPTY
:
3511 case VT_DATE
: case VT_CY
:
3519 hres
= pVarNeg(&v
,&vDst
);
3521 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
3522 "VarNeg: expected failure, got 0x%X vt %d|0x%X\n",
3523 hres
, vt
, ExtraFlags
[i
]);
3525 ok(hres
== S_OK
, "VarNeg: expected S_OK, got 0x%X vt %d|0x%X\n",
3526 hres
, vt
, ExtraFlags
[i
]);
3530 VARNEG(BOOL
,VARIANT_TRUE
,I2
,1);
3531 VARNEG(BOOL
,VARIANT_FALSE
,I2
,0);
3532 VARNEG(BOOL
,1,I2
,-1);
3533 VARNEG(UI1
,1,I2
,-1);
3534 VARNEG(UI1
,254,I2
,-254);
3535 VARNEG(I2
,-32768,I4
,32768);
3538 VARNEG(I4
,-((int)(~0u >> 1)) - 1,R8
,-2147483648u);
3548 VARNEG(DATE
,1,DATE
,-1);
3549 VARNEG(DATE
,-1,DATE
,1);
3552 VARNEG(BSTR
,(BSTR
)szNumMinus1
,R8
,1);
3553 VARNEG(BSTR
,(BSTR
)szNum1
,R8
,-1);
3555 V_VT(&v
) = VT_EMPTY
;
3556 hres
= pVarNeg(&v
,&vDst
);
3557 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I2
&& V_I2(&vDst
) == 0,
3558 "VarNeg: expected 0x0,%d,0 got 0x%X,%d,%d\n", VT_EMPTY
,
3559 hres
, V_VT(&vDst
), V_I2(&vDst
));
3562 hres
= pVarNeg(&v
,&vDst
);
3563 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_NULL
,
3564 "VarNeg: expected 0x0,%d got 0x%X,%d\n", VT_NULL
, hres
, V_VT(&vDst
));
3566 V_VT(&v
) = VT_DECIMAL
;
3567 S(U(*pdec
)).sign
= DECIMAL_NEG
;
3568 S(U(*pdec
)).scale
= 0;
3570 S1(U1(*pdec
)).Mid32
= 0;
3571 S1(U1(*pdec
)).Lo32
= 1;
3572 hres
= pVarNeg(&v
,&vDst
);
3573 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_DECIMAL
&&
3574 S(U(V_DECIMAL(&vDst
))).sign
== 0,
3575 "VarNeg: expected 0x0,%d,0x00, got 0x%X,%d,%02x\n", VT_DECIMAL
,
3576 hres
, V_VT(&vDst
), S(U(V_DECIMAL(&vDst
))).sign
);
3578 S(U(*pdec
)).sign
= 0;
3579 hres
= pVarNeg(&v
,&vDst
);
3580 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_DECIMAL
&&
3581 S(U(V_DECIMAL(&vDst
))).sign
== DECIMAL_NEG
,
3582 "VarNeg: expected 0x0,%d,0x7f, got 0x%X,%d,%02x\n", VT_DECIMAL
,
3583 hres
, V_VT(&vDst
), S(U(V_DECIMAL(&vDst
))).sign
);
3586 pcy
->int64
= -10000;
3587 hres
= pVarNeg(&v
,&vDst
);
3588 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_CY
&& V_CY(&vDst
).int64
== 10000,
3589 "VarNeg: VT_CY wrong, hres=0x%X\n", hres
);
3592 static HRESULT (WINAPI
*pVarRound
)(LPVARIANT
,int,LPVARIANT
);
3594 static void test_Round( int line
, VARIANT
*arg
, int deci
, VARIANT
*expected
)
3599 memset( &result
, 0, sizeof(result
) );
3600 hres
= pVarRound( arg
, deci
, &result
);
3601 ok_(__FILE__
,line
)( hres
== S_OK
, "wrong result %x\n", hres
);
3603 ok_(__FILE__
,line
)( is_expected_variant( &result
, expected
),
3604 "got %s expected %s\n", variantstr(&result
), variantstr(expected
) );
3606 #define VARROUND(vt,val,deci,rvt,rval) \
3607 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
3608 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
3609 test_Round( __LINE__, &v, deci, &exp )
3619 struct decimal_round_t
{
3620 struct decimal_t source
;
3621 struct decimal_t ret
;
3625 static const struct decimal_round_t decimal_round_data
[] = {
3626 {{ 0, DECIMAL_NEG
, 0, 0, 1 }, { 0, DECIMAL_NEG
, 0, 0, 1 }, 0},
3627 {{ 0, 0, 0, 0, 1 }, { 0, 0, 0, 0, 1 }, 0},
3628 {{ 2, 0, 0, 0, 155 }, { 0, 0, 0, 0, 16 }, 1},
3629 {{ 2, 0, 0, 0, 155 }, { 1, 0, 0, 0, 2 }, 0},
3630 {{ 2, 0, 0, 0, 199 }, { 1, 0, 0, 0, 20 }, 1},
3631 {{ 2, 0, 0, 0, 199 }, { 2, 0, 0, 0, 199 }, 2},
3632 {{ 2, DECIMAL_NEG
, 0, 0, 199 }, { 2, DECIMAL_NEG
, 0, 0, 199 }, 2},
3633 {{ 2, DECIMAL_NEG
, 0, 0, 55 }, { 2, DECIMAL_NEG
, 0, 0, 6 }, 1},
3634 {{ 2, 0, 0, 0, 55 }, { 2, 0, 0, 0, 6 }, 1},
3635 {{ 2, 0, 0, 0, 1999 }, { 1, 0, 0, 0, 200 }, 1},
3638 static void test_VarRound(void)
3640 static WCHAR szNumMin
[] = {'-','1','.','4','4','9','\0' };
3641 static WCHAR szNum
[] = {'1','.','4','5','1','\0' };
3643 VARIANT v
, exp
, vDst
;
3644 CY
*pcy
= &V_CY(&v
);
3650 /* first check valid integer types */
3651 VARROUND(BOOL
,VARIANT_TRUE
,0,I2
,-1);
3652 VARROUND(BOOL
,VARIANT_FALSE
,0,I2
,0);
3653 VARROUND(BOOL
,1,0,I2
,1);
3654 VARROUND(UI1
,1,0,UI1
,1);
3655 VARROUND(UI1
,254,0,UI1
,254);
3656 VARROUND(I2
,-32768,0,I2
,-32768);
3657 VARROUND(I2
,-1,0,I2
,-1);
3658 VARROUND(I2
,1,0,I2
,1);
3659 VARROUND(I4
,-((int)(~0u >> 1)) - 1,0,I4
,-((int)(~0u >> 1)) - 1);
3660 VARROUND(I4
,-1,0,I4
,-1);
3661 VARROUND(I4
,1,0,I4
,1);
3664 /* MSDN states that rounding of R4/R8 is dependent on the underlying
3665 * bit pattern of the number and so is architecture dependent. In this
3666 * case Wine returns .2 (which is more correct) and Native returns .3
3669 VARROUND(R4
,1.0f
,0,R4
,1.0f
);
3670 VARROUND(R4
,-1.0f
,0,R4
,-1.0f
);
3671 VARROUND(R8
,1.0,0,R8
,1.0);
3672 VARROUND(R8
,-1.0,0,R8
,-1.0);
3674 /* floating point numbers aren't exactly equal and we can't just
3675 * compare the first few digits. */
3676 VARROUND(DATE
,1.451,1,DATE
,1.5);
3677 VARROUND(DATE
,-1.449,1,DATE
,-1.4);
3679 /* replace the decimal separator */
3680 GetLocaleInfoA(LOCALE_USER_DEFAULT
, LOCALE_SDECIMAL
, buff
, ARRAY_SIZE(buff
));
3682 szNumMin
[2] = buff
[0];
3684 VARROUND(BSTR
,(BSTR
)szNumMin
,1,R8
,-1.40);
3685 VARROUND(BSTR
,(BSTR
)szNum
,1,R8
,1.50);
3687 skip("Skipping VarRound(BSTR) as decimal separator is '%s'\n", buff
);
3690 VARROUND(R4
,1.23456f
,0,R4
,1.0f
);
3691 VARROUND(R4
,1.23456f
,1,R4
,1.2f
);
3692 VARROUND(R4
,1.23456f
,2,R4
,1.23f
);
3693 VARROUND(R4
,1.23456f
,3,R4
,1.235f
);
3694 VARROUND(R4
,1.23456f
,4,R4
,1.2346f
);
3695 VARROUND(R4
,-1.23456f
,0,R4
,-1.0f
);
3696 VARROUND(R4
,-1.23456f
,1,R4
,-1.2f
);
3697 VARROUND(R4
,-1.23456f
,2,R4
,-1.23f
);
3698 VARROUND(R4
,-1.23456f
,3,R4
,-1.235f
);
3699 VARROUND(R4
,-1.23456f
,4,R4
,-1.2346f
);
3701 VARROUND(R8
,1.23456,0,R8
,1.0);
3702 VARROUND(R8
,1.23456,1,R8
,1.2);
3703 VARROUND(R8
,1.23456,2,R8
,1.23);
3704 VARROUND(R8
,1.23456,3,R8
,1.235);
3705 VARROUND(R8
,1.23456,4,R8
,1.2346);
3706 VARROUND(R8
,-1.23456,0,R8
,-1.0);
3707 VARROUND(R8
,-1.23456,1,R8
,-1.2);
3708 VARROUND(R8
,-1.23456,2,R8
,-1.23);
3709 VARROUND(R8
,-1.23456,3,R8
,-1.235);
3710 VARROUND(R8
,-1.23456,4,R8
,-1.2346);
3712 V_VT(&v
) = VT_EMPTY
;
3713 hres
= pVarRound(&v
,0,&vDst
);
3714 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I2
&& V_I2(&vDst
) == 0,
3715 "VarRound: expected 0x0,%d,0 got 0x%X,%d,%d\n", VT_EMPTY
,
3716 hres
, V_VT(&vDst
), V_I2(&vDst
));
3719 hres
= pVarRound(&v
,0,&vDst
);
3720 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_NULL
,
3721 "VarRound: expected 0x0,%d got 0x%X,%d\n", VT_NULL
, hres
, V_VT(&vDst
));
3724 for (i
= 0; i
< ARRAY_SIZE(decimal_round_data
); i
++)
3726 const struct decimal_round_t
*ptr
= &decimal_round_data
[i
];
3729 pdec
= &V_DECIMAL(&v
);
3730 V_VT(&v
) = VT_DECIMAL
;
3731 S(U(*pdec
)).sign
= ptr
->source
.sign
;
3732 S(U(*pdec
)).scale
= ptr
->source
.scale
;
3733 pdec
->Hi32
= ptr
->source
.Hi32
;
3734 S1(U1(*pdec
)).Mid32
= ptr
->source
.Mid32
;
3735 S1(U1(*pdec
)).Lo32
= ptr
->source
.Lo32
;
3737 hres
= pVarRound(&v
, ptr
->dec
, &vDst
);
3738 ok(hres
== S_OK
, "%d: got 0x%08x\n", i
, hres
);
3741 ok(V_VT(&vDst
) == VT_DECIMAL
, "%d: got VT %d, expected VT_DECIMAL\n", i
, V_VT(&vDst
));
3742 ok(S(U(V_DECIMAL(&vDst
))).sign
== ptr
->ret
.sign
, "%d: got sign 0x%02x, expected 0x%02x\n",
3743 i
, S(U(V_DECIMAL(&vDst
))).sign
, ptr
->ret
.sign
);
3744 ok(V_DECIMAL(&vDst
).Hi32
== ptr
->ret
.Hi32
, "%d: got Hi32 %d, expected %d\n",
3745 i
, V_DECIMAL(&vDst
).Hi32
, ptr
->ret
.Hi32
);
3746 ok(S1(U1(V_DECIMAL(&vDst
))).Mid32
== ptr
->ret
.Mid32
, "%d: got Mid32 %d, expected %d\n",
3747 i
, S1(U1(V_DECIMAL(&vDst
))).Mid32
, ptr
->ret
.Mid32
);
3748 ok(S1(U1(V_DECIMAL(&vDst
))).Lo32
== ptr
->ret
.Lo32
, "%d: got Lo32 %d, expected %d\n",
3749 i
, S1(U1(V_DECIMAL(&vDst
))).Lo32
, ptr
->ret
.Lo32
);
3756 hres
= pVarRound(&v
,0,&vDst
);
3757 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_CY
&& V_CY(&vDst
).int64
== 10000,
3758 "VarRound: VT_CY wrong, hres=0x%X\n", hres
);
3762 static HRESULT (WINAPI
*pVarXor
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
3764 #define VARXOR(vt1,val1,vt2,val2,rvt,rval) \
3765 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
3766 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
3767 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
3768 test_var_call2( __LINE__, pVarXor, &left, &right, &exp )
3770 #define VARXORCY(vt1,val1,val2,rvt,rval) \
3771 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
3772 V_VT(&right) = VT_CY; V_CY(&right).int64 = val2; \
3773 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
3774 test_var_call2( __LINE__, pVarXor, &left, &right, &exp )
3776 static void test_VarXor(void)
3778 static const WCHAR szFalse
[] = { '#','F','A','L','S','E','#','\0' };
3779 static const WCHAR szTrue
[] = { '#','T','R','U','E','#','\0' };
3780 VARIANT left
, right
, exp
, result
;
3787 /* Test all possible flag/vt combinations & the resulting vt type */
3788 for (i
= 0; i
< ARRAY_SIZE(ExtraFlags
); i
++)
3790 VARTYPE leftvt
, rightvt
, resvt
;
3792 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
3797 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
3803 if (leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
||
3804 leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
||
3805 leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
)
3808 memset(&left
, 0, sizeof(left
));
3809 memset(&right
, 0, sizeof(right
));
3810 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
3811 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
3812 V_VT(&result
) = VT_EMPTY
;
3815 if (ExtraFlags
[i
] & VT_ARRAY
|| ExtraFlags
[i
] & VT_BYREF
||
3816 !IsValidVariantClearVT(leftvt
, ExtraFlags
[i
]) ||
3817 !IsValidVariantClearVT(rightvt
, ExtraFlags
[i
]) ||
3818 leftvt
== VT_CLSID
|| rightvt
== VT_CLSID
||
3819 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
||
3820 leftvt
== VT_VARIANT
|| rightvt
== VT_VARIANT
||
3821 leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
)
3825 if (leftvt
== VT_EMPTY
|| rightvt
== VT_EMPTY
)
3827 if (leftvt
== rightvt
||
3828 leftvt
== VT_I2
|| rightvt
== VT_I2
||
3829 leftvt
== VT_UI1
|| rightvt
== VT_UI1
||
3830 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
3832 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
3834 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
3837 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
3841 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
3843 if (leftvt
== rightvt
)
3845 else if (leftvt
== rightvt
||
3846 leftvt
== VT_I2
|| rightvt
== VT_I2
||
3847 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
3851 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
3854 else if (leftvt
== VT_I2
|| rightvt
== VT_I2
)
3856 if (leftvt
== rightvt
||
3857 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
3859 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
3862 else if (leftvt
== VT_BOOL
&& rightvt
== VT_BOOL
)
3866 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
3868 if (leftvt
== VT_INT
|| rightvt
== VT_INT
)
3873 hres
= pVarXor(&left
, &right
, &result
);
3875 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
3876 "VarXor: %d|0x%X, %d|0x%X: Expected failure, got 0x%X vt %d\n",
3877 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], hres
,
3880 ok(hres
== S_OK
&& V_VT(&result
) == resvt
,
3881 "VarXor: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%X vt %d\n",
3882 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], resvt
, hres
,
3888 /* Test returned values
3889 * FIXME: Test VT_DECIMAL/VT_DISPATCH
3891 VARXOR(EMPTY
,0,EMPTY
,0,I2
,0);
3892 VARXOR(EMPTY
,1,EMPTY
,0,I2
,0);
3893 VARXOR(EMPTY
,0,NULL
,0,NULL
,0);
3894 VARXOR(EMPTY
,0,I1
,0,I4
,0);
3895 VARXOR(EMPTY
,0,I1
,1,I4
,1);
3896 VARXOR(EMPTY
,0,UI1
,0,I2
,0);
3897 VARXOR(EMPTY
,0,UI1
,1,I2
,1);
3898 VARXOR(EMPTY
,0,I2
,0,I2
,0);
3899 VARXOR(EMPTY
,0,I2
,1,I2
,1);
3900 VARXOR(EMPTY
,0,UI2
,0,I4
,0);
3901 VARXOR(EMPTY
,0,UI2
,1,I4
,1);
3902 VARXOR(EMPTY
,0,I4
,0,I4
,0);
3903 VARXOR(EMPTY
,0,I4
,1,I4
,1);
3904 VARXOR(EMPTY
,0,UI4
,0,I4
,0);
3905 VARXOR(EMPTY
,0,UI4
,1,I4
,1);
3908 VARXOR(EMPTY
,0,I8
,0,I8
,0);
3909 VARXOR(EMPTY
,0,I8
,1,I8
,1);
3910 VARXOR(EMPTY
,0,UI8
,0,I4
,0);
3911 VARXOR(EMPTY
,0,UI8
,1,I4
,1);
3913 VARXOR(EMPTY
,0,INT
,0,I4
,0);
3914 VARXOR(EMPTY
,0,INT
,1,I4
,1);
3915 VARXOR(EMPTY
,0,UINT
,0,I4
,0);
3916 VARXOR(EMPTY
,0,UINT
,1,I4
,1);
3917 VARXOR(EMPTY
,0,BOOL
,0,I2
,0);
3918 VARXOR(EMPTY
,0,BOOL
,1,I2
,1);
3919 VARXOR(EMPTY
,0,R4
,0,I4
,0);
3920 VARXOR(EMPTY
,0,R4
,1,I4
,1);
3921 VARXOR(EMPTY
,0,R8
,0,I4
,0);
3922 VARXOR(EMPTY
,0,R8
,1,I4
,1);
3923 rbstr
= SysAllocString(szFalse
);
3924 VARXOR(EMPTY
,0,BSTR
,rbstr
,I2
,0);
3925 SysFreeString(rbstr
);
3926 rbstr
= SysAllocString(szTrue
);
3927 VARXOR(EMPTY
,0,BSTR
,rbstr
,I2
,-1);
3928 VARXORCY(EMPTY
,0,10000,I4
,1);
3929 SysFreeString(rbstr
);
3931 /* NULL OR 0 = NULL. NULL OR n = n */
3932 VARXOR(NULL
,0,NULL
,0,NULL
,0);
3933 VARXOR(NULL
,1,NULL
,0,NULL
,0);
3934 VARXOR(NULL
,0,I1
,0,NULL
,0);
3935 VARXOR(NULL
,0,I1
,1,NULL
,0);
3936 VARXOR(NULL
,0,UI1
,0,NULL
,0);
3937 VARXOR(NULL
,0,UI1
,1,NULL
,0);
3938 VARXOR(NULL
,0,I2
,0,NULL
,0);
3939 VARXOR(NULL
,0,I2
,1,NULL
,0);
3940 VARXOR(NULL
,0,UI2
,0,NULL
,0);
3941 VARXOR(NULL
,0,UI2
,1,NULL
,0);
3942 VARXOR(NULL
,0,I4
,0,NULL
,0);
3943 VARXOR(NULL
,0,I4
,1,NULL
,0);
3944 VARXOR(NULL
,0,UI4
,0,NULL
,0);
3945 VARXOR(NULL
,0,UI4
,1,NULL
,0);
3948 VARXOR(NULL
,0,I8
,0,NULL
,0);
3949 VARXOR(NULL
,0,I8
,1,NULL
,0);
3950 VARXOR(NULL
,0,UI8
,0,NULL
,0);
3951 VARXOR(NULL
,0,UI8
,1,NULL
,0);
3953 VARXOR(NULL
,0,INT
,0,NULL
,0);
3954 VARXOR(NULL
,0,INT
,1,NULL
,0);
3955 VARXOR(NULL
,0,UINT
,0,NULL
,0);
3956 VARXOR(NULL
,0,UINT
,1,NULL
,0);
3957 VARXOR(NULL
,0,BOOL
,0,NULL
,0);
3958 VARXOR(NULL
,0,BOOL
,1,NULL
,0);
3959 VARXOR(NULL
,0,R4
,0,NULL
,0);
3960 VARXOR(NULL
,0,R4
,1,NULL
,0);
3961 VARXOR(NULL
,0,R8
,0,NULL
,0);
3962 VARXOR(NULL
,0,R8
,1,NULL
,0);
3963 rbstr
= SysAllocString(szFalse
);
3964 VARXOR(NULL
,0,BSTR
,rbstr
,NULL
,0);
3965 SysFreeString(rbstr
);
3966 rbstr
= SysAllocString(szTrue
);
3967 VARXOR(NULL
,0,BSTR
,rbstr
,NULL
,0);
3968 SysFreeString(rbstr
);
3969 VARXORCY(NULL
,0,10000,NULL
,0);
3970 VARXORCY(NULL
,0,0,NULL
,0);
3972 VARXOR(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
);
3973 VARXOR(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
);
3974 VARXOR(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
);
3975 VARXOR(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_FALSE
);
3976 /* Assume x,y & y,x are the same from now on to reduce the number of tests */
3977 VARXOR(BOOL
,VARIANT_TRUE
,I1
,-1,I4
,0);
3978 VARXOR(BOOL
,VARIANT_TRUE
,I1
,0,I4
,-1);
3979 VARXOR(BOOL
,VARIANT_FALSE
,I1
,0,I4
,0);
3980 VARXOR(BOOL
,VARIANT_TRUE
,UI1
,255,I2
,-256);
3981 VARXOR(BOOL
,VARIANT_TRUE
,UI1
,0,I2
,-1);
3982 VARXOR(BOOL
,VARIANT_FALSE
,UI1
,0,I2
,0);
3983 VARXOR(BOOL
,VARIANT_TRUE
,I2
,-1,I2
,0);
3984 VARXOR(BOOL
,VARIANT_TRUE
,I2
,0,I2
,-1);
3985 VARXOR(BOOL
,VARIANT_FALSE
,I2
,0,I2
,0);
3986 VARXOR(BOOL
,VARIANT_TRUE
,UI2
,65535,I4
,-65536);
3987 VARXOR(BOOL
,VARIANT_TRUE
,UI2
,0,I4
,-1);
3988 VARXOR(BOOL
,VARIANT_FALSE
,UI2
,0,I4
,0);
3989 VARXOR(BOOL
,VARIANT_TRUE
,I4
,-1,I4
,0);
3990 VARXOR(BOOL
,VARIANT_TRUE
,I4
,0,I4
,-1);
3991 VARXOR(BOOL
,VARIANT_FALSE
,I4
,0,I4
,0);
3992 VARXOR(BOOL
,VARIANT_TRUE
,UI4
,0xffffffff,I4
,0);
3993 VARXOR(BOOL
,VARIANT_TRUE
,UI4
,0,I4
,-1);
3994 VARXOR(BOOL
,VARIANT_FALSE
,UI4
,0,I4
,0);
3995 VARXOR(BOOL
,VARIANT_TRUE
,R4
,-1,I4
,0);
3996 VARXOR(BOOL
,VARIANT_TRUE
,R4
,0,I4
,-1);
3997 VARXOR(BOOL
,VARIANT_FALSE
,R4
,0,I4
,0);
3998 VARXOR(BOOL
,VARIANT_TRUE
,R8
,-1,I4
,0);
3999 VARXOR(BOOL
,VARIANT_TRUE
,R8
,0,I4
,-1);
4000 VARXOR(BOOL
,VARIANT_FALSE
,R8
,0,I4
,0);
4001 VARXOR(BOOL
,VARIANT_TRUE
,DATE
,-1,I4
,0);
4002 VARXOR(BOOL
,VARIANT_TRUE
,DATE
,0,I4
,-1);
4003 VARXOR(BOOL
,VARIANT_FALSE
,DATE
,0,I4
,0);
4006 VARXOR(BOOL
,VARIANT_TRUE
,I8
,-1,I8
,0);
4007 VARXOR(BOOL
,VARIANT_TRUE
,I8
,0,I8
,-1);
4008 VARXOR(BOOL
,VARIANT_FALSE
,I8
,0,I8
,0);
4009 /* This returns DISP_E_OVERFLOW which indicates that a conversion
4010 * to I4 is performed.
4012 /* VARXOR(BOOL,VARIANT_TRUE,UI8,-1,I4,-1); */
4013 VARXOR(BOOL
,VARIANT_TRUE
,UI8
,0,I4
,-1);
4014 VARXOR(BOOL
,VARIANT_FALSE
,UI8
,0,I4
,0);
4016 VARXOR(BOOL
,VARIANT_TRUE
,INT
,-1,I4
,0);
4017 VARXOR(BOOL
,VARIANT_TRUE
,INT
,0,I4
,-1);
4018 VARXOR(BOOL
,VARIANT_FALSE
,INT
,0,I4
,0);
4019 VARXOR(BOOL
,VARIANT_TRUE
,UINT
,0xffffffff,I4
,0);
4020 VARXOR(BOOL
,VARIANT_TRUE
,UINT
,0,I4
,-1);
4021 VARXOR(BOOL
,VARIANT_FALSE
,UINT
,0,I4
,0);
4022 rbstr
= SysAllocString(szFalse
);
4023 VARXOR(BOOL
,VARIANT_FALSE
,BSTR
,rbstr
,BOOL
,VARIANT_FALSE
);
4024 VARXOR(BOOL
,VARIANT_TRUE
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
4025 SysFreeString(rbstr
);
4026 rbstr
= SysAllocString(szTrue
);
4027 VARXOR(BOOL
,VARIANT_FALSE
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
4028 VARXOR(BOOL
,VARIANT_TRUE
,BSTR
,rbstr
,BOOL
,VARIANT_FALSE
);
4029 SysFreeString(rbstr
);
4030 VARXORCY(BOOL
,VARIANT_TRUE
,10000,I4
,-2);
4031 VARXORCY(BOOL
,VARIANT_TRUE
,0,I4
,-1);
4032 VARXORCY(BOOL
,VARIANT_FALSE
,0,I4
,0);
4034 VARXOR(I1
,-1,I1
,-1,I4
,0);
4035 VARXOR(I1
,-1,I1
,0,I4
,-1);
4036 VARXOR(I1
,0,I1
,0,I4
,0);
4037 VARXOR(I1
,-1,UI1
,255,I4
,-256);
4038 VARXOR(I1
,-1,UI1
,0,I4
,-1);
4039 VARXOR(I1
,0,UI1
,0,I4
,0);
4040 VARXOR(I1
,-1,I2
,-1,I4
,0);
4041 VARXOR(I1
,-1,I2
,0,I4
,-1);
4042 VARXOR(I1
,0,I2
,0,I4
,0);
4043 VARXOR(I1
,-1,UI2
,65535,I4
,-65536);
4044 VARXOR(I1
,-1,UI2
,0,I4
,-1);
4045 VARXOR(I1
,0,UI2
,0,I4
,0);
4046 VARXOR(I1
,-1,I4
,-1,I4
,0);
4047 VARXOR(I1
,-1,I4
,0,I4
,-1);
4048 VARXOR(I1
,0,I4
,0,I4
,0);
4049 VARXOR(I1
,-1,UI4
,0xffffffff,I4
,0);
4050 VARXOR(I1
,-1,UI4
,0,I4
,-1);
4051 VARXOR(I1
,0,UI4
,0,I4
,0);
4052 VARXOR(I1
,-1,R4
,-1,I4
,0);
4053 VARXOR(I1
,-1,R4
,0,I4
,-1);
4054 VARXOR(I1
,0,R4
,0,I4
,0);
4055 VARXOR(I1
,-1,R8
,-1,I4
,0);
4056 VARXOR(I1
,-1,R8
,0,I4
,-1);
4057 VARXOR(I1
,0,R8
,0,I4
,0);
4058 VARXOR(I1
,-1,DATE
,-1,I4
,0);
4059 VARXOR(I1
,-1,DATE
,0,I4
,-1);
4060 VARXOR(I1
,0,DATE
,0,I4
,0);
4063 VARXOR(I1
,-1,I8
,-1,I8
,0);
4064 VARXOR(I1
,-1,I8
,0,I8
,-1);
4065 VARXOR(I1
,0,I8
,0,I8
,0);
4066 VARXOR(I1
,-1,UI8
,0,I4
,-1);
4067 VARXOR(I1
,0,UI8
,0,I4
,0);
4069 VARXOR(I1
,-1,INT
,-1,I4
,0);
4070 VARXOR(I1
,-1,INT
,0,I4
,-1);
4071 VARXOR(I1
,0,INT
,0,I4
,0);
4072 VARXOR(I1
,-1,UINT
,0xffffffff,I4
,0);
4073 VARXOR(I1
,-1,UINT
,0,I4
,-1);
4074 VARXOR(I1
,0,UINT
,0,I4
,0);
4075 rbstr
= SysAllocString(szFalse
);
4076 VARXOR(I1
,0,BSTR
,rbstr
,I4
,0);
4077 VARXOR(I1
,-1,BSTR
,rbstr
,I4
,-1);
4078 SysFreeString(rbstr
);
4079 rbstr
= SysAllocString(szTrue
);
4080 VARXOR(I1
,0,BSTR
,rbstr
,I4
,-1);
4081 VARXOR(I1
,-1,BSTR
,rbstr
,I4
,0);
4082 SysFreeString(rbstr
);
4083 VARXORCY(I1
,-1,10000,I4
,-2);
4084 VARXORCY(I1
,-1,0,I4
,-1);
4085 VARXORCY(I1
,0,0,I4
,0);
4087 VARXOR(UI1
,255,UI1
,255,UI1
,0);
4088 VARXOR(UI1
,255,UI1
,0,UI1
,255);
4089 VARXOR(UI1
,0,UI1
,0,UI1
,0);
4090 VARXOR(UI1
,255,I2
,-1,I2
,-256);
4091 VARXOR(UI1
,255,I2
,0,I2
,255);
4092 VARXOR(UI1
,0,I2
,0,I2
,0);
4093 VARXOR(UI1
,255,UI2
,65535,I4
,65280);
4094 VARXOR(UI1
,255,UI2
,0,I4
,255);
4095 VARXOR(UI1
,0,UI2
,0,I4
,0);
4096 VARXOR(UI1
,255,I4
,-1,I4
,-256);
4097 VARXOR(UI1
,255,I4
,0,I4
,255);
4098 VARXOR(UI1
,0,I4
,0,I4
,0);
4099 VARXOR(UI1
,255,UI4
,0xffffffff,I4
,-256);
4100 VARXOR(UI1
,255,UI4
,0,I4
,255);
4101 VARXOR(UI1
,0,UI4
,0,I4
,0);
4102 VARXOR(UI1
,255,R4
,-1,I4
,-256);
4103 VARXOR(UI1
,255,R4
,0,I4
,255);
4104 VARXOR(UI1
,0,R4
,0,I4
,0);
4105 VARXOR(UI1
,255,R8
,-1,I4
,-256);
4106 VARXOR(UI1
,255,R8
,0,I4
,255);
4107 VARXOR(UI1
,0,R8
,0,I4
,0);
4108 VARXOR(UI1
,255,DATE
,-1,I4
,-256);
4109 VARXOR(UI1
,255,DATE
,0,I4
,255);
4110 VARXOR(UI1
,0,DATE
,0,I4
,0);
4113 VARXOR(UI1
,255,I8
,-1,I8
,-256);
4114 VARXOR(UI1
,255,I8
,0,I8
,255);
4115 VARXOR(UI1
,0,I8
,0,I8
,0);
4116 VARXOR(UI1
,255,UI8
,0,I4
,255);
4117 VARXOR(UI1
,0,UI8
,0,I4
,0);
4119 VARXOR(UI1
,255,INT
,-1,I4
,-256);
4120 VARXOR(UI1
,255,INT
,0,I4
,255);
4121 VARXOR(UI1
,0,INT
,0,I4
,0);
4122 VARXOR(UI1
,255,UINT
,0xffffffff,I4
,-256);
4123 VARXOR(UI1
,255,UINT
,0,I4
,255);
4124 VARXOR(UI1
,0,UINT
,0,I4
,0);
4125 rbstr
= SysAllocString(szFalse
);
4126 VARXOR(UI1
,0,BSTR
,rbstr
,I2
,0);
4127 VARXOR(UI1
,255,BSTR
,rbstr
,I2
,255);
4128 SysFreeString(rbstr
);
4129 rbstr
= SysAllocString(szTrue
);
4130 VARXOR(UI1
,0,BSTR
,rbstr
,I2
,-1);
4131 VARXOR(UI1
,255,BSTR
,rbstr
,I2
,-256);
4132 SysFreeString(rbstr
);
4133 VARXORCY(UI1
,255,10000,I4
,254);
4134 VARXORCY(UI1
,255,0,I4
,255);
4135 VARXORCY(UI1
,0,0,I4
,0);
4137 VARXOR(I2
,-1,I2
,-1,I2
,0);
4138 VARXOR(I2
,-1,I2
,0,I2
,-1);
4139 VARXOR(I2
,0,I2
,0,I2
,0);
4140 VARXOR(I2
,-1,UI2
,65535,I4
,-65536);
4141 VARXOR(I2
,-1,UI2
,0,I4
,-1);
4142 VARXOR(I2
,0,UI2
,0,I4
,0);
4143 VARXOR(I2
,-1,I4
,-1,I4
,0);
4144 VARXOR(I2
,-1,I4
,0,I4
,-1);
4145 VARXOR(I2
,0,I4
,0,I4
,0);
4146 VARXOR(I2
,-1,UI4
,0xffffffff,I4
,0);
4147 VARXOR(I2
,-1,UI4
,0,I4
,-1);
4148 VARXOR(I2
,0,UI4
,0,I4
,0);
4149 VARXOR(I2
,-1,R4
,-1,I4
,0);
4150 VARXOR(I2
,-1,R4
,0,I4
,-1);
4151 VARXOR(I2
,0,R4
,0,I4
,0);
4152 VARXOR(I2
,-1,R8
,-1,I4
,0);
4153 VARXOR(I2
,-1,R8
,0,I4
,-1);
4154 VARXOR(I2
,0,R8
,0,I4
,0);
4155 VARXOR(I2
,-1,DATE
,-1,I4
,0);
4156 VARXOR(I2
,-1,DATE
,0,I4
,-1);
4157 VARXOR(I2
,0,DATE
,0,I4
,0);
4160 VARXOR(I2
,-1,I8
,-1,I8
,0);
4161 VARXOR(I2
,-1,I8
,0,I8
,-1);
4162 VARXOR(I2
,0,I8
,0,I8
,0);
4163 VARXOR(I2
,-1,UI8
,0,I4
,-1);
4164 VARXOR(I2
,0,UI8
,0,I4
,0);
4166 VARXOR(I2
,-1,INT
,-1,I4
,0);
4167 VARXOR(I2
,-1,INT
,0,I4
,-1);
4168 VARXOR(I2
,0,INT
,0,I4
,0);
4169 VARXOR(I2
,-1,UINT
,0xffffffff,I4
,0);
4170 VARXOR(I2
,-1,UINT
,0,I4
,-1);
4171 VARXOR(I2
,0,UINT
,0,I4
,0);
4172 rbstr
= SysAllocString(szFalse
);
4173 VARXOR(I2
,0,BSTR
,rbstr
,I2
,0);
4174 VARXOR(I2
,-1,BSTR
,rbstr
,I2
,-1);
4175 SysFreeString(rbstr
);
4176 rbstr
= SysAllocString(szTrue
);
4177 VARXOR(I2
,0,BSTR
,rbstr
,I2
,-1);
4178 VARXOR(I2
,-1,BSTR
,rbstr
,I2
,0);
4179 SysFreeString(rbstr
);
4180 VARXORCY(I2
,-1,10000,I4
,-2);
4181 VARXORCY(I2
,-1,0,I4
,-1);
4182 VARXORCY(I2
,0,0,I4
,0);
4184 VARXOR(UI2
,65535,UI2
,65535,I4
,0);
4185 VARXOR(UI2
,65535,UI2
,0,I4
,65535);
4186 VARXOR(UI2
,0,UI2
,0,I4
,0);
4187 VARXOR(UI2
,65535,I4
,-1,I4
,-65536);
4188 VARXOR(UI2
,65535,I4
,0,I4
,65535);
4189 VARXOR(UI2
,0,I4
,0,I4
,0);
4190 VARXOR(UI2
,65535,UI4
,0xffffffff,I4
,-65536);
4191 VARXOR(UI2
,65535,UI4
,0,I4
,65535);
4192 VARXOR(UI2
,0,UI4
,0,I4
,0);
4193 VARXOR(UI2
,65535,R4
,-1,I4
,-65536);
4194 VARXOR(UI2
,65535,R4
,0,I4
,65535);
4195 VARXOR(UI2
,0,R4
,0,I4
,0);
4196 VARXOR(UI2
,65535,R8
,-1,I4
,-65536);
4197 VARXOR(UI2
,65535,R8
,0,I4
,65535);
4198 VARXOR(UI2
,0,R8
,0,I4
,0);
4199 VARXOR(UI2
,65535,DATE
,-1,I4
,-65536);
4200 VARXOR(UI2
,65535,DATE
,0,I4
,65535);
4201 VARXOR(UI2
,0,DATE
,0,I4
,0);
4204 VARXOR(UI2
,65535,I8
,-1,I8
,-65536);
4205 VARXOR(UI2
,65535,I8
,0,I8
,65535);
4206 VARXOR(UI2
,0,I8
,0,I8
,0);
4207 VARXOR(UI2
,65535,UI8
,0,I4
,65535);
4208 VARXOR(UI2
,0,UI8
,0,I4
,0);
4210 VARXOR(UI2
,65535,INT
,-1,I4
,-65536);
4211 VARXOR(UI2
,65535,INT
,0,I4
,65535);
4212 VARXOR(UI2
,0,INT
,0,I4
,0);
4213 VARXOR(UI2
,65535,UINT
,0xffffffff,I4
,-65536);
4214 VARXOR(UI2
,65535,UINT
,0,I4
,65535);
4215 VARXOR(UI2
,0,UINT
,0,I4
,0);
4216 rbstr
= SysAllocString(szFalse
);
4217 VARXOR(UI2
,0,BSTR
,rbstr
,I4
,0);
4218 VARXOR(UI2
,65535,BSTR
,rbstr
,I4
,65535);
4219 SysFreeString(rbstr
);
4220 rbstr
= SysAllocString(szTrue
);
4221 VARXOR(UI2
,0,BSTR
,rbstr
,I4
,-1);
4222 VARXOR(UI2
,65535,BSTR
,rbstr
,I4
,-65536);
4223 SysFreeString(rbstr
);
4224 VARXORCY(UI2
,65535,10000,I4
,65534);
4225 VARXORCY(UI2
,65535,0,I4
,65535);
4226 VARXORCY(UI2
,0,0,I4
,0);
4228 VARXOR(I4
,-1,I4
,-1,I4
,0);
4229 VARXOR(I4
,-1,I4
,0,I4
,-1);
4230 VARXOR(I4
,0,I4
,0,I4
,0);
4231 VARXOR(I4
,-1,UI4
,0xffffffff,I4
,0);
4232 VARXOR(I4
,-1,UI4
,0,I4
,-1);
4233 VARXOR(I4
,0,UI4
,0,I4
,0);
4234 VARXOR(I4
,-1,R4
,-1,I4
,0);
4235 VARXOR(I4
,-1,R4
,0,I4
,-1);
4236 VARXOR(I4
,0,R4
,0,I4
,0);
4237 VARXOR(I4
,-1,R8
,-1,I4
,0);
4238 VARXOR(I4
,-1,R8
,0,I4
,-1);
4239 VARXOR(I4
,0,R8
,0,I4
,0);
4240 VARXOR(I4
,-1,DATE
,-1,I4
,0);
4241 VARXOR(I4
,-1,DATE
,0,I4
,-1);
4242 VARXOR(I4
,0,DATE
,0,I4
,0);
4245 VARXOR(I4
,-1,I8
,-1,I8
,0);
4246 VARXOR(I4
,-1,I8
,0,I8
,-1);
4247 VARXOR(I4
,0,I8
,0,I8
,0);
4248 VARXOR(I4
,-1,UI8
,0,I4
,-1);
4249 VARXOR(I4
,0,UI8
,0,I4
,0);
4251 VARXOR(I4
,-1,INT
,-1,I4
,0);
4252 VARXOR(I4
,-1,INT
,0,I4
,-1);
4253 VARXOR(I4
,0,INT
,0,I4
,0);
4254 VARXOR(I4
,-1,UINT
,0xffffffff,I4
,0);
4255 VARXOR(I4
,-1,UINT
,0,I4
,-1);
4256 VARXOR(I4
,0,UINT
,0,I4
,0);
4257 rbstr
= SysAllocString(szFalse
);
4258 VARXOR(I4
,0,BSTR
,rbstr
,I4
,0);
4259 VARXOR(I4
,-1,BSTR
,rbstr
,I4
,-1);
4260 SysFreeString(rbstr
);
4261 rbstr
= SysAllocString(szTrue
);
4262 VARXOR(I4
,0,BSTR
,rbstr
,I4
,-1);
4263 VARXOR(I4
,-1,BSTR
,rbstr
,I4
,0);
4264 SysFreeString(rbstr
);
4265 VARXORCY(I4
,-1,10000,I4
,-2);
4266 VARXORCY(I4
,-1,0,I4
,-1);
4267 VARXORCY(I4
,0,0,I4
,0);
4269 VARXOR(UI4
,0xffffffff,UI4
,0xffffffff,I4
,0);
4270 VARXOR(UI4
,0xffffffff,UI4
,0,I4
,-1);
4271 VARXOR(UI4
,0,UI4
,0,I4
,0);
4272 VARXOR(UI4
,0xffffffff,R4
,-1,I4
,0);
4273 VARXOR(UI4
,0xffffffff,R4
,0,I4
,-1);
4274 VARXOR(UI4
,0,R4
,0,I4
,0);
4275 VARXOR(UI4
,0xffffffff,R8
,-1,I4
,0);
4276 VARXOR(UI4
,0xffffffff,R8
,0,I4
,-1);
4277 VARXOR(UI4
,0,R8
,0,I4
,0);
4278 VARXOR(UI4
,0xffffffff,DATE
,-1,I4
,0);
4279 VARXOR(UI4
,0xffffffff,DATE
,0,I4
,-1);
4280 VARXOR(UI4
,0,DATE
,0,I4
,0);
4283 VARXOR(UI4
,0xffffffff,I8
,0,I8
,0xffffffff);
4284 VARXOR(UI4
,VARIANT_FALSE
,I8
,VARIANT_FALSE
,I8
,0);
4285 VARXOR(UI4
,0,I8
,0,I8
,0);
4286 VARXOR(UI4
,0xffffffff,UI8
,0,I4
,-1);
4287 VARXOR(UI4
,0,UI8
,0,I4
,0);
4289 VARXOR(UI4
,0xffffffff,INT
,-1,I4
,0);
4290 VARXOR(UI4
,0xffffffff,INT
,0,I4
,-1);
4291 VARXOR(UI4
,0,INT
,0,I4
,0);
4292 VARXOR(UI4
,0xffffffff,UINT
,0xffffffff,I4
,0);
4293 VARXOR(UI4
,0xffffffff,UINT
,0,I4
,-1);
4294 VARXOR(UI4
,0,UINT
,0,I4
,0);
4295 rbstr
= SysAllocString(szFalse
);
4296 VARXOR(UI4
,0,BSTR
,rbstr
,I4
,0);
4297 VARXOR(UI4
,0xffffffff,BSTR
,rbstr
,I4
,-1);
4298 SysFreeString(rbstr
);
4299 rbstr
= SysAllocString(szTrue
);
4300 VARXOR(UI4
,0,BSTR
,rbstr
,I4
,-1);
4301 VARXOR(UI4
,0xffffffff,BSTR
,rbstr
,I4
,0);
4302 SysFreeString(rbstr
);
4303 VARXORCY(UI4
,0xffffffff,10000,I4
,-2);
4304 VARXORCY(UI4
,0xffffffff,0,I4
,-1);
4305 VARXORCY(UI4
,0,0,I4
,0);
4307 VARXOR(R4
,-1,R4
,-1,I4
,0);
4308 VARXOR(R4
,-1,R4
,0,I4
,-1);
4309 VARXOR(R4
,0,R4
,0,I4
,0);
4310 VARXOR(R4
,-1,R8
,-1,I4
,0);
4311 VARXOR(R4
,-1,R8
,0,I4
,-1);
4312 VARXOR(R4
,0,R8
,0,I4
,0);
4313 VARXOR(R4
,-1,DATE
,-1,I4
,0);
4314 VARXOR(R4
,-1,DATE
,0,I4
,-1);
4315 VARXOR(R4
,0,DATE
,0,I4
,0);
4318 VARXOR(R4
,-1,I8
,-1,I8
,0);
4319 VARXOR(R4
,-1,I8
,0,I8
,-1);
4320 VARXOR(R4
,0,I8
,0,I8
,0);
4321 VARXOR(R4
,-1,UI8
,0,I4
,-1);
4322 VARXOR(R4
,0,UI8
,0,I4
,0);
4324 VARXOR(R4
,-1,INT
,-1,I4
,0);
4325 VARXOR(R4
,-1,INT
,0,I4
,-1);
4326 VARXOR(R4
,0,INT
,0,I4
,0);
4327 VARXOR(R4
,-1,UINT
,0xffffffff,I4
,0);
4328 VARXOR(R4
,-1,UINT
,0,I4
,-1);
4329 VARXOR(R4
,0,UINT
,0,I4
,0);
4330 rbstr
= SysAllocString(szFalse
);
4331 VARXOR(R4
,0,BSTR
,rbstr
,I4
,0);
4332 VARXOR(R4
,-1,BSTR
,rbstr
,I4
,-1);
4333 SysFreeString(rbstr
);
4334 rbstr
= SysAllocString(szTrue
);
4335 VARXOR(R4
,0,BSTR
,rbstr
,I4
,-1);
4336 VARXOR(R4
,-1,BSTR
,rbstr
,I4
,0);
4337 SysFreeString(rbstr
);
4338 VARXORCY(R4
,-1,10000,I4
,-2);
4339 VARXORCY(R4
,-1,0,I4
,-1);
4340 VARXORCY(R4
,0,0,I4
,0);
4342 VARXOR(R8
,-1,R8
,-1,I4
,0);
4343 VARXOR(R8
,-1,R8
,0,I4
,-1);
4344 VARXOR(R8
,0,R8
,0,I4
,0);
4345 VARXOR(R8
,-1,DATE
,-1,I4
,0);
4346 VARXOR(R8
,-1,DATE
,0,I4
,-1);
4347 VARXOR(R8
,0,DATE
,0,I4
,0);
4350 VARXOR(R8
,-1,I8
,-1,I8
,0);
4351 VARXOR(R8
,-1,I8
,0,I8
,-1);
4352 VARXOR(R8
,0,I8
,0,I8
,0);
4353 VARXOR(R8
,-1,UI8
,0,I4
,-1);
4354 VARXOR(R8
,0,UI8
,0,I4
,0);
4356 VARXOR(R8
,-1,INT
,-1,I4
,0);
4357 VARXOR(R8
,-1,INT
,0,I4
,-1);
4358 VARXOR(R8
,0,INT
,0,I4
,0);
4359 VARXOR(R8
,-1,UINT
,0xffffffff,I4
,0);
4360 VARXOR(R8
,-1,UINT
,0,I4
,-1);
4361 VARXOR(R8
,0,UINT
,0,I4
,0);
4362 rbstr
= SysAllocString(szFalse
);
4363 VARXOR(R8
,0,BSTR
,rbstr
,I4
,0);
4364 VARXOR(R8
,-1,BSTR
,rbstr
,I4
,-1);
4365 SysFreeString(rbstr
);
4366 rbstr
= SysAllocString(szTrue
);
4367 VARXOR(R8
,0,BSTR
,rbstr
,I4
,-1);
4368 VARXOR(R8
,-1,BSTR
,rbstr
,I4
,0);
4369 SysFreeString(rbstr
);
4370 VARXORCY(R8
,-1,10000,I4
,-2);
4371 VARXORCY(R8
,-1,0,I4
,-1);
4372 VARXORCY(R8
,0,0,I4
,0);
4374 VARXOR(DATE
,-1,DATE
,-1,I4
,0);
4375 VARXOR(DATE
,-1,DATE
,0,I4
,-1);
4376 VARXOR(DATE
,0,DATE
,0,I4
,0);
4379 VARXOR(DATE
,-1,I8
,-1,I8
,0);
4380 VARXOR(DATE
,-1,I8
,0,I8
,-1);
4381 VARXOR(DATE
,0,I8
,0,I8
,0);
4382 VARXOR(DATE
,-1,UI8
,0,I4
,-1);
4383 VARXOR(DATE
,0,UI8
,0,I4
,0);
4385 VARXOR(DATE
,-1,INT
,-1,I4
,0);
4386 VARXOR(DATE
,-1,INT
,0,I4
,-1);
4387 VARXOR(DATE
,0,INT
,0,I4
,0);
4388 VARXOR(DATE
,-1,UINT
,0xffffffff,I4
,0);
4389 VARXOR(DATE
,-1,UINT
,0,I4
,-1);
4390 VARXOR(DATE
,0,UINT
,0,I4
,0);
4391 rbstr
= SysAllocString(szFalse
);
4392 VARXOR(DATE
,0,BSTR
,rbstr
,I4
,0);
4393 VARXOR(DATE
,-1,BSTR
,rbstr
,I4
,-1);
4394 SysFreeString(rbstr
);
4395 rbstr
= SysAllocString(szTrue
);
4396 VARXOR(DATE
,0,BSTR
,rbstr
,I4
,-1);
4397 VARXOR(DATE
,-1,BSTR
,rbstr
,I4
,0);
4398 SysFreeString(rbstr
);
4399 VARXORCY(DATE
,-1,10000,I4
,-2);
4400 VARXORCY(DATE
,-1,0,I4
,-1);
4401 VARXORCY(DATE
,0,0,I4
,0);
4405 VARXOR(I8
,-1,I8
,-1,I8
,0);
4406 VARXOR(I8
,-1,I8
,0,I8
,-1);
4407 VARXOR(I8
,0,I8
,0,I8
,0);
4408 VARXOR(I8
,-1,UI8
,0,I8
,-1);
4409 VARXOR(I8
,0,UI8
,0,I8
,0);
4410 VARXOR(I8
,-1,UINT
,0,I8
,-1);
4411 VARXOR(I8
,0,UINT
,0,I8
,0);
4412 rbstr
= SysAllocString(szFalse
);
4413 VARXOR(I8
,0,BSTR
,rbstr
,I8
,0);
4414 VARXOR(I8
,-1,BSTR
,rbstr
,I8
,-1);
4415 SysFreeString(rbstr
);
4416 rbstr
= SysAllocString(szTrue
);
4417 VARXOR(I8
,0,BSTR
,rbstr
,I8
,-1);
4418 VARXOR(I8
,-1,BSTR
,rbstr
,I8
,0);
4419 SysFreeString(rbstr
);
4420 VARXORCY(I8
,-1,10000,I8
,-2);
4421 VARXORCY(I8
,-1,0,I8
,-1);
4422 VARXORCY(I8
,0,0,I8
,0);
4424 VARXOR(UI8
,0xffff,UI8
,0xffff,I4
,0);
4425 VARXOR(UI8
,0xffff,UI8
,0,I4
,0xffff);
4426 VARXOR(UI8
,0,UI8
,0,I4
,0);
4427 VARXOR(UI8
,0xffff,INT
,-1,I4
,-65536);
4428 VARXOR(UI8
,0xffff,INT
,0,I4
,0xffff);
4429 VARXOR(UI8
,0,INT
,0,I4
,0);
4430 VARXOR(UI8
,0xffff,UINT
,0xffff,I4
,0);
4431 VARXOR(UI8
,0xffff,UINT
,0,I4
,0xffff);
4432 VARXOR(UI8
,0,UINT
,0,I4
,0);
4433 rbstr
= SysAllocString(szFalse
);
4434 VARXOR(UI8
,0,BSTR
,rbstr
,I4
,0);
4435 VARXOR(UI8
,0xffff,BSTR
,rbstr
,I4
,0xffff);
4436 SysFreeString(rbstr
);
4437 rbstr
= SysAllocString(szTrue
);
4438 VARXOR(UI8
,0,BSTR
,rbstr
,I4
,-1);
4439 VARXOR(UI8
,0xffff,BSTR
,rbstr
,I4
,-65536);
4440 SysFreeString(rbstr
);
4441 VARXORCY(UI8
,0xffff,10000,I4
,65534);
4442 VARXORCY(UI8
,0xffff,0,I4
,0xffff);
4443 VARXORCY(UI8
,0,0,I4
,0);
4446 VARXOR(INT
,-1,INT
,-1,I4
,0);
4447 VARXOR(INT
,-1,INT
,0,I4
,-1);
4448 VARXOR(INT
,0,INT
,0,I4
,0);
4449 VARXOR(INT
,-1,UINT
,0xffff,I4
,-65536);
4450 VARXOR(INT
,-1,UINT
,0,I4
,-1);
4451 VARXOR(INT
,0,UINT
,0,I4
,0);
4452 rbstr
= SysAllocString(szFalse
);
4453 VARXOR(INT
,0,BSTR
,rbstr
,I4
,0);
4454 VARXOR(INT
,-1,BSTR
,rbstr
,I4
,-1);
4455 SysFreeString(rbstr
);
4456 rbstr
= SysAllocString(szTrue
);
4457 VARXOR(INT
,0,BSTR
,rbstr
,I4
,-1);
4458 VARXOR(INT
,-1,BSTR
,rbstr
,I4
,0);
4459 SysFreeString(rbstr
);
4460 VARXORCY(INT
,-1,10000,I4
,-2);
4461 VARXORCY(INT
,-1,0,I4
,-1);
4462 VARXORCY(INT
,0,0,I4
,0);
4464 VARXOR(UINT
,0xffff,UINT
,0xffff,I4
,0);
4465 VARXOR(UINT
,0xffff,UINT
,0,I4
,0xffff);
4466 VARXOR(UINT
,0,UINT
,0,I4
,0);
4467 rbstr
= SysAllocString(szFalse
);
4468 VARXOR(UINT
,0,BSTR
,rbstr
,I4
,0);
4469 VARXOR(UINT
,0xffff,BSTR
,rbstr
,I4
,0xffff);
4470 SysFreeString(rbstr
);
4471 rbstr
= SysAllocString(szTrue
);
4472 VARXOR(UINT
,0,BSTR
,rbstr
,I4
,-1);
4473 VARXOR(UINT
,0xffff,BSTR
,rbstr
,I4
,-65536);
4474 SysFreeString(rbstr
);
4475 VARXORCY(UINT
,0xffff,10000,I4
,65534);
4476 VARXORCY(UINT
,0xffff,0,I4
,0xffff);
4477 VARXORCY(UINT
,0,0,I4
,0);
4479 lbstr
= SysAllocString(szFalse
);
4480 rbstr
= SysAllocString(szFalse
);
4481 VARXOR(BSTR
,lbstr
,BSTR
,rbstr
,BOOL
,0);
4482 SysFreeString(rbstr
);
4483 rbstr
= SysAllocString(szTrue
);
4484 VARXOR(BSTR
,lbstr
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
4485 SysFreeString(lbstr
);
4486 lbstr
= SysAllocString(szTrue
);
4487 VARXOR(BSTR
,lbstr
,BSTR
,rbstr
,BOOL
,VARIANT_FALSE
);
4488 VARXORCY(BSTR
,lbstr
,10000,I4
,-2);
4489 SysFreeString(lbstr
);
4490 lbstr
= SysAllocString(szFalse
);
4491 VARXORCY(BSTR
,lbstr
,10000,I4
,1);
4492 SysFreeString(lbstr
);
4493 SysFreeString(rbstr
);
4496 static HRESULT (WINAPI
*pVarOr
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
4498 #define VAROR(vt1,val1,vt2,val2,rvt,rval) \
4499 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
4500 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
4501 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
4502 test_var_call2( __LINE__, pVarOr, &left, &right, &exp )
4504 #define VARORCY(vt1,val1,val2,rvt,rval) \
4505 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
4506 V_VT(&right) = VT_CY; V_CY(&right).int64 = val2; \
4507 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
4508 test_var_call2( __LINE__, pVarOr, &left, &right, &exp )
4510 static void test_VarOr(void)
4512 static const WCHAR szFalse
[] = { '#','F','A','L','S','E','#','\0' };
4513 static const WCHAR szTrue
[] = { '#','T','R','U','E','#','\0' };
4514 VARIANT left
, right
, exp
, result
;
4521 /* Test all possible flag/vt combinations & the resulting vt type */
4522 for (i
= 0; i
< ARRAY_SIZE(ExtraFlags
); i
++)
4524 VARTYPE leftvt
, rightvt
, resvt
;
4526 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
4531 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
4537 if (leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
||
4538 leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
||
4539 leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
)
4542 memset(&left
, 0, sizeof(left
));
4543 memset(&right
, 0, sizeof(right
));
4544 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
4545 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
4546 V_VT(&result
) = VT_EMPTY
;
4549 if (ExtraFlags
[i
] & VT_ARRAY
|| ExtraFlags
[i
] & VT_BYREF
||
4550 !IsValidVariantClearVT(leftvt
, ExtraFlags
[i
]) ||
4551 !IsValidVariantClearVT(rightvt
, ExtraFlags
[i
]) ||
4552 leftvt
== VT_CLSID
|| rightvt
== VT_CLSID
||
4553 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
||
4554 leftvt
== VT_VARIANT
|| rightvt
== VT_VARIANT
||
4555 leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
)
4559 if (leftvt
== VT_EMPTY
|| rightvt
== VT_EMPTY
)
4561 if (leftvt
== rightvt
||
4562 leftvt
== VT_I2
|| rightvt
== VT_I2
||
4563 leftvt
== VT_UI1
|| rightvt
== VT_UI1
||
4564 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
4566 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
4568 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
4571 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
4575 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
4577 if (leftvt
== rightvt
)
4579 else if (leftvt
== rightvt
||
4580 leftvt
== VT_I2
|| rightvt
== VT_I2
||
4581 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
4585 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
4588 else if (leftvt
== VT_I2
|| rightvt
== VT_I2
)
4590 if (leftvt
== rightvt
||
4591 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
4593 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
4596 else if (leftvt
== VT_BOOL
&& rightvt
== VT_BOOL
)
4600 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
4602 if (leftvt
== VT_INT
|| rightvt
== VT_INT
)
4607 hres
= pVarOr(&left
, &right
, &result
);
4609 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
4610 "VarOr: %d|0x%X, %d|0x%X: Expected failure, got 0x%X vt %d\n",
4611 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], hres
,
4614 ok(hres
== S_OK
&& V_VT(&result
) == resvt
,
4615 "VarOr: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%X vt %d\n",
4616 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], resvt
, hres
,
4622 /* Test returned values. Since we know the returned type is correct
4623 * and that we handle all combinations of invalid types, just check
4624 * that good type combinations produce the desired value.
4625 * FIXME: Test VT_DECIMAL/VT_DISPATCH
4627 VAROR(EMPTY
,0,EMPTY
,0,I2
,0);
4628 VAROR(EMPTY
,1,EMPTY
,0,I2
,0);
4629 VAROR(EMPTY
,0,NULL
,0,NULL
,0);
4630 VAROR(EMPTY
,0,I1
,0,I4
,0);
4631 VAROR(EMPTY
,0,I1
,1,I4
,1);
4632 VAROR(EMPTY
,0,UI1
,0,I2
,0);
4633 VAROR(EMPTY
,0,UI1
,1,I2
,1);
4634 VAROR(EMPTY
,0,I2
,0,I2
,0);
4635 VAROR(EMPTY
,0,I2
,1,I2
,1);
4636 VAROR(EMPTY
,0,UI2
,0,I4
,0);
4637 VAROR(EMPTY
,0,UI2
,1,I4
,1);
4638 VAROR(EMPTY
,0,I4
,0,I4
,0);
4639 VAROR(EMPTY
,0,I4
,1,I4
,1);
4640 VAROR(EMPTY
,0,UI4
,0,I4
,0);
4641 VAROR(EMPTY
,0,UI4
,1,I4
,1);
4644 VAROR(EMPTY
,0,I8
,0,I8
,0);
4645 VAROR(EMPTY
,0,I8
,1,I8
,1);
4646 VAROR(EMPTY
,0,UI8
,0,I4
,0);
4647 VAROR(EMPTY
,0,UI8
,1,I4
,1);
4649 VAROR(EMPTY
,0,INT
,0,I4
,0);
4650 VAROR(EMPTY
,0,INT
,1,I4
,1);
4651 VAROR(EMPTY
,0,UINT
,0,I4
,0);
4652 VAROR(EMPTY
,0,UINT
,1,I4
,1);
4653 VAROR(EMPTY
,0,BOOL
,0,I2
,0);
4654 VAROR(EMPTY
,0,BOOL
,1,I2
,1);
4655 VAROR(EMPTY
,0,R4
,0,I4
,0);
4656 VAROR(EMPTY
,0,R4
,1,I4
,1);
4657 VAROR(EMPTY
,0,R8
,0,I4
,0);
4658 VAROR(EMPTY
,0,R8
,1,I4
,1);
4659 rbstr
= SysAllocString(szFalse
);
4660 VAROR(EMPTY
,0,BSTR
,rbstr
,I2
,0);
4661 SysFreeString(rbstr
);
4662 rbstr
= SysAllocString(szTrue
);
4663 VAROR(EMPTY
,0,BSTR
,rbstr
,I2
,-1);
4664 SysFreeString(rbstr
);
4665 VARORCY(EMPTY
,0,10000,I4
,1);
4667 /* NULL OR 0 = NULL. NULL OR n = n */
4668 VAROR(NULL
,0,NULL
,0,NULL
,0);
4669 VAROR(NULL
,1,NULL
,0,NULL
,0);
4670 VAROR(NULL
,0,I1
,0,NULL
,0);
4671 VAROR(NULL
,0,I1
,1,I4
,1);
4672 VAROR(NULL
,0,UI1
,0,NULL
,0);
4673 VAROR(NULL
,0,UI1
,1,UI1
,1);
4674 VAROR(NULL
,0,I2
,0,NULL
,0);
4675 VAROR(NULL
,0,I2
,1,I2
,1);
4676 VAROR(NULL
,0,UI2
,0,NULL
,0);
4677 VAROR(NULL
,0,UI2
,1,I4
,1);
4678 VAROR(NULL
,0,I4
,0,NULL
,0);
4679 VAROR(NULL
,0,I4
,1,I4
,1);
4680 VAROR(NULL
,0,UI4
,0,NULL
,0);
4681 VAROR(NULL
,0,UI4
,1,I4
,1);
4684 VAROR(NULL
,0,I8
,0,NULL
,0);
4685 VAROR(NULL
,0,I8
,1,I8
,1);
4686 VAROR(NULL
,0,UI8
,0,NULL
,0);
4687 VAROR(NULL
,0,UI8
,1,I4
,1);
4689 VAROR(NULL
,0,INT
,0,NULL
,0);
4690 VAROR(NULL
,0,INT
,1,I4
,1);
4691 VAROR(NULL
,0,UINT
,0,NULL
,0);
4692 VAROR(NULL
,0,UINT
,1,I4
,1);
4693 VAROR(NULL
,0,BOOL
,0,NULL
,0);
4694 VAROR(NULL
,0,BOOL
,1,BOOL
,1);
4695 VAROR(NULL
,0,R4
,0,NULL
,0);
4696 VAROR(NULL
,0,R4
,1,I4
,1);
4697 VAROR(NULL
,0,R8
,0,NULL
,0);
4698 VAROR(NULL
,0,R8
,1,I4
,1);
4699 rbstr
= SysAllocString(szFalse
);
4700 VAROR(NULL
,0,BSTR
,rbstr
,NULL
,0);
4701 SysFreeString(rbstr
);
4702 rbstr
= SysAllocString(szTrue
);
4703 VAROR(NULL
,0,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
4704 SysFreeString(rbstr
);
4705 VARORCY(NULL
,0,10000,I4
,1);
4706 VARORCY(NULL
,0,0,NULL
,0);
4708 VAROR(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
);
4709 VAROR(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
);
4710 VAROR(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
);
4711 VAROR(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_FALSE
);
4712 /* Assume x,y & y,x are the same from now on to reduce the number of tests */
4713 VAROR(BOOL
,VARIANT_TRUE
,I1
,-1,I4
,-1);
4714 VAROR(BOOL
,VARIANT_TRUE
,I1
,0,I4
,-1);
4715 VAROR(BOOL
,VARIANT_FALSE
,I1
,0,I4
,0);
4716 VAROR(BOOL
,VARIANT_TRUE
,UI1
,255,I2
,-1);
4717 VAROR(BOOL
,VARIANT_TRUE
,UI1
,0,I2
,-1);
4718 VAROR(BOOL
,VARIANT_FALSE
,UI1
,0,I2
,0);
4719 VAROR(BOOL
,VARIANT_TRUE
,I2
,-1,I2
,-1);
4720 VAROR(BOOL
,VARIANT_TRUE
,I2
,0,I2
,-1);
4721 VAROR(BOOL
,VARIANT_FALSE
,I2
,0,I2
,0);
4722 VAROR(BOOL
,VARIANT_TRUE
,UI2
,65535,I4
,-1);
4723 VAROR(BOOL
,VARIANT_TRUE
,UI2
,0,I4
,-1);
4724 VAROR(BOOL
,VARIANT_FALSE
,UI2
,0,I4
,0);
4725 VAROR(BOOL
,VARIANT_TRUE
,I4
,-1,I4
,-1);
4726 VAROR(BOOL
,VARIANT_TRUE
,I4
,0,I4
,-1);
4727 VAROR(BOOL
,VARIANT_FALSE
,I4
,0,I4
,0);
4728 VAROR(BOOL
,VARIANT_TRUE
,UI4
,0xffffffff,I4
,-1);
4729 VAROR(BOOL
,VARIANT_TRUE
,UI4
,0,I4
,-1);
4730 VAROR(BOOL
,VARIANT_FALSE
,UI4
,0,I4
,0);
4731 VAROR(BOOL
,VARIANT_TRUE
,R4
,-1,I4
,-1);
4732 VAROR(BOOL
,VARIANT_TRUE
,R4
,0,I4
,-1);
4733 VAROR(BOOL
,VARIANT_FALSE
,R4
,0,I4
,0);
4734 VAROR(BOOL
,VARIANT_TRUE
,R8
,-1,I4
,-1);
4735 VAROR(BOOL
,VARIANT_TRUE
,R8
,0,I4
,-1);
4736 VAROR(BOOL
,VARIANT_FALSE
,R8
,0,I4
,0);
4737 VAROR(BOOL
,VARIANT_TRUE
,DATE
,-1,I4
,-1);
4738 VAROR(BOOL
,VARIANT_TRUE
,DATE
,0,I4
,-1);
4739 VAROR(BOOL
,VARIANT_FALSE
,DATE
,0,I4
,0);
4742 VAROR(BOOL
,VARIANT_TRUE
,I8
,-1,I8
,-1);
4743 VAROR(BOOL
,VARIANT_TRUE
,I8
,0,I8
,-1);
4744 VAROR(BOOL
,VARIANT_FALSE
,I8
,0,I8
,0);
4745 /* This returns DISP_E_OVERFLOW which indicates that a conversion
4746 * to I4 is performed.
4748 /* VAROR(BOOL,VARIANT_TRUE,UI8,-1,I4,-1); */
4749 VAROR(BOOL
,VARIANT_TRUE
,UI8
,0,I4
,-1);
4750 VAROR(BOOL
,VARIANT_FALSE
,UI8
,0,I4
,0);
4752 VAROR(BOOL
,VARIANT_TRUE
,INT
,-1,I4
,-1);
4753 VAROR(BOOL
,VARIANT_TRUE
,INT
,0,I4
,-1);
4754 VAROR(BOOL
,VARIANT_FALSE
,INT
,0,I4
,0);
4755 VAROR(BOOL
,VARIANT_TRUE
,UINT
,0xffffffff,I4
,-1);
4756 VAROR(BOOL
,VARIANT_TRUE
,UINT
,0,I4
,-1);
4757 VAROR(BOOL
,VARIANT_FALSE
,UINT
,0,I4
,0);
4758 rbstr
= SysAllocString(szFalse
);
4759 VAROR(BOOL
,VARIANT_FALSE
,BSTR
,rbstr
,BOOL
,VARIANT_FALSE
);
4760 VAROR(BOOL
,VARIANT_TRUE
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
4761 SysFreeString(rbstr
);
4762 rbstr
= SysAllocString(szTrue
);
4763 VAROR(BOOL
,VARIANT_FALSE
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
4764 VAROR(BOOL
,VARIANT_TRUE
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
4765 SysFreeString(rbstr
);
4766 VARORCY(BOOL
,VARIANT_TRUE
,10000,I4
,-1);
4767 VARORCY(BOOL
,VARIANT_TRUE
,0,I4
,-1);
4768 VARORCY(BOOL
,VARIANT_FALSE
,0,I4
,0);
4770 VAROR(I1
,-1,I1
,-1,I4
,-1);
4771 VAROR(I1
,-1,I1
,0,I4
,-1);
4772 VAROR(I1
,0,I1
,0,I4
,0);
4773 VAROR(I1
,-1,UI1
,255,I4
,-1);
4774 VAROR(I1
,-1,UI1
,0,I4
,-1);
4775 VAROR(I1
,0,UI1
,0,I4
,0);
4776 VAROR(I1
,-1,I2
,-1,I4
,-1);
4777 VAROR(I1
,-1,I2
,0,I4
,-1);
4778 VAROR(I1
,0,I2
,0,I4
,0);
4779 VAROR(I1
,-1,UI2
,65535,I4
,-1);
4780 VAROR(I1
,-1,UI2
,0,I4
,-1);
4781 VAROR(I1
,0,UI2
,0,I4
,0);
4782 VAROR(I1
,-1,I4
,-1,I4
,-1);
4783 VAROR(I1
,-1,I4
,0,I4
,-1);
4784 VAROR(I1
,0,I4
,0,I4
,0);
4785 VAROR(I1
,-1,UI4
,0xffffffff,I4
,-1);
4786 VAROR(I1
,-1,UI4
,0,I4
,-1);
4787 VAROR(I1
,0,UI4
,0,I4
,0);
4788 VAROR(I1
,-1,R4
,-1,I4
,-1);
4789 VAROR(I1
,-1,R4
,0,I4
,-1);
4790 VAROR(I1
,0,R4
,0,I4
,0);
4791 VAROR(I1
,-1,R8
,-1,I4
,-1);
4792 VAROR(I1
,-1,R8
,0,I4
,-1);
4793 VAROR(I1
,0,R8
,0,I4
,0);
4794 VAROR(I1
,-1,DATE
,-1,I4
,-1);
4795 VAROR(I1
,-1,DATE
,0,I4
,-1);
4796 VAROR(I1
,0,DATE
,0,I4
,0);
4799 VAROR(I1
,-1,I8
,-1,I8
,-1);
4800 VAROR(I1
,-1,I8
,0,I8
,-1);
4801 VAROR(I1
,0,I8
,0,I8
,0);
4802 VAROR(I1
,-1,UI8
,0,I4
,-1);
4803 VAROR(I1
,0,UI8
,0,I4
,0);
4805 VAROR(I1
,-1,INT
,-1,I4
,-1);
4806 VAROR(I1
,-1,INT
,0,I4
,-1);
4807 VAROR(I1
,0,INT
,0,I4
,0);
4808 VAROR(I1
,-1,UINT
,0xffffffff,I4
,-1);
4809 VAROR(I1
,-1,UINT
,0,I4
,-1);
4810 VAROR(I1
,0,UINT
,0,I4
,0);
4811 rbstr
= SysAllocString(szFalse
);
4812 VAROR(I1
,0,BSTR
,rbstr
,I4
,0);
4813 VAROR(I1
,-1,BSTR
,rbstr
,I4
,-1);
4814 SysFreeString(rbstr
);
4815 rbstr
= SysAllocString(szTrue
);
4816 VAROR(I1
,0,BSTR
,rbstr
,I4
,-1);
4817 VAROR(I1
,-1,BSTR
,rbstr
,I4
,-1);
4818 SysFreeString(rbstr
);
4819 VARORCY(I1
,-1,10000,I4
,-1);
4820 VARORCY(I1
,-1,0,I4
,-1);
4821 VARORCY(I1
,0,0,I4
,0);
4823 VAROR(UI1
,255,UI1
,255,UI1
,255);
4824 VAROR(UI1
,255,UI1
,0,UI1
,255);
4825 VAROR(UI1
,0,UI1
,0,UI1
,0);
4826 VAROR(UI1
,255,I2
,-1,I2
,-1);
4827 VAROR(UI1
,255,I2
,0,I2
,255);
4828 VAROR(UI1
,0,I2
,0,I2
,0);
4829 VAROR(UI1
,255,UI2
,65535,I4
,65535);
4830 VAROR(UI1
,255,UI2
,0,I4
,255);
4831 VAROR(UI1
,0,UI2
,0,I4
,0);
4832 VAROR(UI1
,255,I4
,-1,I4
,-1);
4833 VAROR(UI1
,255,I4
,0,I4
,255);
4834 VAROR(UI1
,0,I4
,0,I4
,0);
4835 VAROR(UI1
,255,UI4
,0xffffffff,I4
,-1);
4836 VAROR(UI1
,255,UI4
,0,I4
,255);
4837 VAROR(UI1
,0,UI4
,0,I4
,0);
4838 VAROR(UI1
,255,R4
,-1,I4
,-1);
4839 VAROR(UI1
,255,R4
,0,I4
,255);
4840 VAROR(UI1
,0,R4
,0,I4
,0);
4841 VAROR(UI1
,255,R8
,-1,I4
,-1);
4842 VAROR(UI1
,255,R8
,0,I4
,255);
4843 VAROR(UI1
,0,R8
,0,I4
,0);
4844 VAROR(UI1
,255,DATE
,-1,I4
,-1);
4845 VAROR(UI1
,255,DATE
,0,I4
,255);
4846 VAROR(UI1
,0,DATE
,0,I4
,0);
4849 VAROR(UI1
,255,I8
,-1,I8
,-1);
4850 VAROR(UI1
,255,I8
,0,I8
,255);
4851 VAROR(UI1
,0,I8
,0,I8
,0);
4852 VAROR(UI1
,255,UI8
,0,I4
,255);
4853 VAROR(UI1
,0,UI8
,0,I4
,0);
4855 VAROR(UI1
,255,INT
,-1,I4
,-1);
4856 VAROR(UI1
,255,INT
,0,I4
,255);
4857 VAROR(UI1
,0,INT
,0,I4
,0);
4858 VAROR(UI1
,255,UINT
,0xffffffff,I4
,-1);
4859 VAROR(UI1
,255,UINT
,0,I4
,255);
4860 VAROR(UI1
,0,UINT
,0,I4
,0);
4861 rbstr
= SysAllocString(szFalse
);
4862 VAROR(UI1
,0,BSTR
,rbstr
,I2
,0);
4863 VAROR(UI1
,255,BSTR
,rbstr
,I2
,255);
4864 SysFreeString(rbstr
);
4865 rbstr
= SysAllocString(szTrue
);
4866 VAROR(UI1
,0,BSTR
,rbstr
,I2
,-1);
4867 VAROR(UI1
,255,BSTR
,rbstr
,I2
,-1);
4868 SysFreeString(rbstr
);
4869 VARORCY(UI1
,255,10000,I4
,255);
4870 VARORCY(UI1
,255,0,I4
,255);
4871 VARORCY(UI1
,0,0,I4
,0);
4873 VAROR(I2
,-1,I2
,-1,I2
,-1);
4874 VAROR(I2
,-1,I2
,0,I2
,-1);
4875 VAROR(I2
,0,I2
,0,I2
,0);
4876 VAROR(I2
,-1,UI2
,65535,I4
,-1);
4877 VAROR(I2
,-1,UI2
,0,I4
,-1);
4878 VAROR(I2
,0,UI2
,0,I4
,0);
4879 VAROR(I2
,-1,I4
,-1,I4
,-1);
4880 VAROR(I2
,-1,I4
,0,I4
,-1);
4881 VAROR(I2
,0,I4
,0,I4
,0);
4882 VAROR(I2
,-1,UI4
,0xffffffff,I4
,-1);
4883 VAROR(I2
,-1,UI4
,0,I4
,-1);
4884 VAROR(I2
,0,UI4
,0,I4
,0);
4885 VAROR(I2
,-1,R4
,-1,I4
,-1);
4886 VAROR(I2
,-1,R4
,0,I4
,-1);
4887 VAROR(I2
,0,R4
,0,I4
,0);
4888 VAROR(I2
,-1,R8
,-1,I4
,-1);
4889 VAROR(I2
,-1,R8
,0,I4
,-1);
4890 VAROR(I2
,0,R8
,0,I4
,0);
4891 VAROR(I2
,-1,DATE
,-1,I4
,-1);
4892 VAROR(I2
,-1,DATE
,0,I4
,-1);
4893 VAROR(I2
,0,DATE
,0,I4
,0);
4896 VAROR(I2
,-1,I8
,-1,I8
,-1);
4897 VAROR(I2
,-1,I8
,0,I8
,-1);
4898 VAROR(I2
,0,I8
,0,I8
,0);
4899 VAROR(I2
,-1,UI8
,0,I4
,-1);
4900 VAROR(I2
,0,UI8
,0,I4
,0);
4902 VAROR(I2
,-1,INT
,-1,I4
,-1);
4903 VAROR(I2
,-1,INT
,0,I4
,-1);
4904 VAROR(I2
,0,INT
,0,I4
,0);
4905 VAROR(I2
,-1,UINT
,0xffffffff,I4
,-1);
4906 VAROR(I2
,-1,UINT
,0,I4
,-1);
4907 VAROR(I2
,0,UINT
,0,I4
,0);
4908 rbstr
= SysAllocString(szFalse
);
4909 VAROR(I2
,0,BSTR
,rbstr
,I2
,0);
4910 VAROR(I2
,-1,BSTR
,rbstr
,I2
,-1);
4911 SysFreeString(rbstr
);
4912 rbstr
= SysAllocString(szTrue
);
4913 VAROR(I2
,0,BSTR
,rbstr
,I2
,-1);
4914 VAROR(I2
,-1,BSTR
,rbstr
,I2
,-1);
4915 SysFreeString(rbstr
);
4916 VARORCY(I2
,-1,10000,I4
,-1);
4917 VARORCY(I2
,-1,0,I4
,-1);
4918 VARORCY(I2
,0,0,I4
,0);
4920 VAROR(UI2
,65535,UI2
,65535,I4
,65535);
4921 VAROR(UI2
,65535,UI2
,0,I4
,65535);
4922 VAROR(UI2
,0,UI2
,0,I4
,0);
4923 VAROR(UI2
,65535,I4
,-1,I4
,-1);
4924 VAROR(UI2
,65535,I4
,0,I4
,65535);
4925 VAROR(UI2
,0,I4
,0,I4
,0);
4926 VAROR(UI2
,65535,UI4
,0xffffffff,I4
,-1);
4927 VAROR(UI2
,65535,UI4
,0,I4
,65535);
4928 VAROR(UI2
,0,UI4
,0,I4
,0);
4929 VAROR(UI2
,65535,R4
,-1,I4
,-1);
4930 VAROR(UI2
,65535,R4
,0,I4
,65535);
4931 VAROR(UI2
,0,R4
,0,I4
,0);
4932 VAROR(UI2
,65535,R8
,-1,I4
,-1);
4933 VAROR(UI2
,65535,R8
,0,I4
,65535);
4934 VAROR(UI2
,0,R8
,0,I4
,0);
4935 VAROR(UI2
,65535,DATE
,-1,I4
,-1);
4936 VAROR(UI2
,65535,DATE
,0,I4
,65535);
4937 VAROR(UI2
,0,DATE
,0,I4
,0);
4940 VAROR(UI2
,65535,I8
,-1,I8
,-1);
4941 VAROR(UI2
,65535,I8
,0,I8
,65535);
4942 VAROR(UI2
,0,I8
,0,I8
,0);
4943 VAROR(UI2
,65535,UI8
,0,I4
,65535);
4944 VAROR(UI2
,0,UI8
,0,I4
,0);
4946 VAROR(UI2
,65535,INT
,-1,I4
,-1);
4947 VAROR(UI2
,65535,INT
,0,I4
,65535);
4948 VAROR(UI2
,0,INT
,0,I4
,0);
4949 VAROR(UI2
,65535,UINT
,0xffffffff,I4
,-1);
4950 VAROR(UI2
,65535,UINT
,0,I4
,65535);
4951 VAROR(UI2
,0,UINT
,0,I4
,0);
4952 rbstr
= SysAllocString(szFalse
);
4953 VAROR(UI2
,0,BSTR
,rbstr
,I4
,0);
4954 VAROR(UI2
,65535,BSTR
,rbstr
,I4
,65535);
4955 SysFreeString(rbstr
);
4956 rbstr
= SysAllocString(szTrue
);
4957 VAROR(UI2
,0,BSTR
,rbstr
,I4
,-1);
4958 VAROR(UI2
,65535,BSTR
,rbstr
,I4
,-1);
4959 SysFreeString(rbstr
);
4960 VARORCY(UI2
,65535,10000,I4
,65535);
4961 VARORCY(UI2
,65535,0,I4
,65535);
4962 VARORCY(UI2
,0,0,I4
,0);
4964 VAROR(I4
,-1,I4
,-1,I4
,-1);
4965 VAROR(I4
,-1,I4
,0,I4
,-1);
4966 VAROR(I4
,0,I4
,0,I4
,0);
4967 VAROR(I4
,-1,UI4
,0xffffffff,I4
,-1);
4968 VAROR(I4
,-1,UI4
,0,I4
,-1);
4969 VAROR(I4
,0,UI4
,0,I4
,0);
4970 VAROR(I4
,-1,R4
,-1,I4
,-1);
4971 VAROR(I4
,-1,R4
,0,I4
,-1);
4972 VAROR(I4
,0,R4
,0,I4
,0);
4973 VAROR(I4
,-1,R8
,-1,I4
,-1);
4974 VAROR(I4
,-1,R8
,0,I4
,-1);
4975 VAROR(I4
,0,R8
,0,I4
,0);
4976 VAROR(I4
,-1,DATE
,-1,I4
,-1);
4977 VAROR(I4
,-1,DATE
,0,I4
,-1);
4978 VAROR(I4
,0,DATE
,0,I4
,0);
4981 VAROR(I4
,-1,I8
,-1,I8
,-1);
4982 VAROR(I4
,-1,I8
,0,I8
,-1);
4983 VAROR(I4
,0,I8
,0,I8
,0);
4984 VAROR(I4
,-1,UI8
,0,I4
,-1);
4985 VAROR(I4
,0,UI8
,0,I4
,0);
4987 VAROR(I4
,-1,INT
,-1,I4
,-1);
4988 VAROR(I4
,-1,INT
,0,I4
,-1);
4989 VAROR(I4
,0,INT
,0,I4
,0);
4990 VAROR(I4
,-1,UINT
,0xffffffff,I4
,-1);
4991 VAROR(I4
,-1,UINT
,0,I4
,-1);
4992 VAROR(I4
,0,UINT
,0,I4
,0);
4993 rbstr
= SysAllocString(szFalse
);
4994 VAROR(I4
,0,BSTR
,rbstr
,I4
,0);
4995 VAROR(I4
,-1,BSTR
,rbstr
,I4
,-1);
4996 SysFreeString(rbstr
);
4997 rbstr
= SysAllocString(szTrue
);
4998 VAROR(I4
,0,BSTR
,rbstr
,I4
,-1);
4999 VAROR(I4
,-1,BSTR
,rbstr
,I4
,-1);
5000 SysFreeString(rbstr
);
5001 VARORCY(I4
,-1,10000,I4
,-1);
5002 VARORCY(I4
,-1,0,I4
,-1);
5003 VARORCY(I4
,0,0,I4
,0);
5005 VAROR(UI4
,0xffffffff,UI4
,0xffffffff,I4
,-1);
5006 VAROR(UI4
,0xffffffff,UI4
,0,I4
,-1);
5007 VAROR(UI4
,0,UI4
,0,I4
,0);
5008 VAROR(UI4
,0xffffffff,R4
,-1,I4
,-1);
5009 VAROR(UI4
,0xffffffff,R4
,0,I4
,-1);
5010 VAROR(UI4
,0,R4
,0,I4
,0);
5011 VAROR(UI4
,0xffffffff,R8
,-1,I4
,-1);
5012 VAROR(UI4
,0xffffffff,R8
,0,I4
,-1);
5013 VAROR(UI4
,0,R8
,0,I4
,0);
5014 VAROR(UI4
,0xffffffff,DATE
,-1,I4
,-1);
5015 VAROR(UI4
,0xffffffff,DATE
,0,I4
,-1);
5016 VAROR(UI4
,0,DATE
,0,I4
,0);
5019 VAROR(UI4
,0xffffffff,I8
,-1,I8
,-1);
5020 VAROR(UI4
,0xffffffff,I8
,0,I8
,0xffffffff);
5021 VAROR(UI4
,0,I8
,0,I8
,0);
5022 VAROR(UI4
,0xffffffff,UI8
,0,I4
,-1);
5023 VAROR(UI4
,0,UI8
,0,I4
,0);
5025 VAROR(UI4
,0xffffffff,INT
,-1,I4
,-1);
5026 VAROR(UI4
,0xffffffff,INT
,0,I4
,-1);
5027 VAROR(UI4
,0,INT
,0,I4
,0);
5028 VAROR(UI4
,0xffffffff,UINT
,0xffffffff,I4
,-1);
5029 VAROR(UI4
,0xffffffff,UINT
,0,I4
,-1);
5030 VAROR(UI4
,0,UINT
,0,I4
,0);
5031 rbstr
= SysAllocString(szFalse
);
5032 VAROR(UI4
,0,BSTR
,rbstr
,I4
,0);
5033 VAROR(UI4
,0xffffffff,BSTR
,rbstr
,I4
,-1);
5034 SysFreeString(rbstr
);
5035 rbstr
= SysAllocString(szTrue
);
5036 VAROR(UI4
,0,BSTR
,rbstr
,I4
,-1);
5037 VAROR(UI4
,0xffffffff,BSTR
,rbstr
,I4
,-1);
5038 SysFreeString(rbstr
);
5039 VARORCY(UI4
,0xffffffff,10000,I4
,-1);
5040 VARORCY(UI4
,0xffffffff,0,I4
,-1);
5041 VARORCY(UI4
,0,0,I4
,0);
5043 VAROR(R4
,-1,R4
,-1,I4
,-1);
5044 VAROR(R4
,-1,R4
,0,I4
,-1);
5045 VAROR(R4
,0,R4
,0,I4
,0);
5046 VAROR(R4
,-1,R8
,-1,I4
,-1);
5047 VAROR(R4
,-1,R8
,0,I4
,-1);
5048 VAROR(R4
,0,R8
,0,I4
,0);
5049 VAROR(R4
,-1,DATE
,-1,I4
,-1);
5050 VAROR(R4
,-1,DATE
,0,I4
,-1);
5051 VAROR(R4
,0,DATE
,0,I4
,0);
5054 VAROR(R4
,-1,I8
,-1,I8
,-1);
5055 VAROR(R4
,-1,I8
,0,I8
,-1);
5056 VAROR(R4
,0,I8
,0,I8
,0);
5057 VAROR(R4
,-1,UI8
,0,I4
,-1);
5058 VAROR(R4
,0,UI8
,0,I4
,0);
5060 VAROR(R4
,-1,INT
,-1,I4
,-1);
5061 VAROR(R4
,-1,INT
,0,I4
,-1);
5062 VAROR(R4
,0,INT
,0,I4
,0);
5063 VAROR(R4
,-1,UINT
,0xffffffff,I4
,-1);
5064 VAROR(R4
,-1,UINT
,0,I4
,-1);
5065 VAROR(R4
,0,UINT
,0,I4
,0);
5066 rbstr
= SysAllocString(szFalse
);
5067 VAROR(R4
,0,BSTR
,rbstr
,I4
,0);
5068 VAROR(R4
,-1,BSTR
,rbstr
,I4
,-1);
5069 SysFreeString(rbstr
);
5070 rbstr
= SysAllocString(szTrue
);
5071 VAROR(R4
,0,BSTR
,rbstr
,I4
,-1);
5072 VAROR(R4
,-1,BSTR
,rbstr
,I4
,-1);
5073 SysFreeString(rbstr
);
5074 VARORCY(R4
,-1,10000,I4
,-1);
5075 VARORCY(R4
,-1,0,I4
,-1);
5076 VARORCY(R4
,0,0,I4
,0);
5078 VAROR(R8
,-1,R8
,-1,I4
,-1);
5079 VAROR(R8
,-1,R8
,0,I4
,-1);
5080 VAROR(R8
,0,R8
,0,I4
,0);
5081 VAROR(R8
,-1,DATE
,-1,I4
,-1);
5082 VAROR(R8
,-1,DATE
,0,I4
,-1);
5083 VAROR(R8
,0,DATE
,0,I4
,0);
5086 VAROR(R8
,-1,I8
,-1,I8
,-1);
5087 VAROR(R8
,-1,I8
,0,I8
,-1);
5088 VAROR(R8
,0,I8
,0,I8
,0);
5089 VAROR(R8
,-1,UI8
,0,I4
,-1);
5090 VAROR(R8
,0,UI8
,0,I4
,0);
5092 VAROR(R8
,-1,INT
,-1,I4
,-1);
5093 VAROR(R8
,-1,INT
,0,I4
,-1);
5094 VAROR(R8
,0,INT
,0,I4
,0);
5095 VAROR(R8
,-1,UINT
,0xffffffff,I4
,-1);
5096 VAROR(R8
,-1,UINT
,0,I4
,-1);
5097 VAROR(R8
,0,UINT
,0,I4
,0);
5098 rbstr
= SysAllocString(szFalse
);
5099 VAROR(R8
,0,BSTR
,rbstr
,I4
,0);
5100 VAROR(R8
,-1,BSTR
,rbstr
,I4
,-1);
5101 SysFreeString(rbstr
);
5102 rbstr
= SysAllocString(szTrue
);
5103 VAROR(R8
,0,BSTR
,rbstr
,I4
,-1);
5104 VAROR(R8
,-1,BSTR
,rbstr
,I4
,-1);
5105 SysFreeString(rbstr
);
5106 VARORCY(R8
,-1,10000,I4
,-1);
5107 VARORCY(R8
,-1,0,I4
,-1);
5108 VARORCY(R8
,0,0,I4
,0);
5110 VAROR(DATE
,-1,DATE
,-1,I4
,-1);
5111 VAROR(DATE
,-1,DATE
,0,I4
,-1);
5112 VAROR(DATE
,0,DATE
,0,I4
,0);
5115 VAROR(DATE
,-1,I8
,-1,I8
,-1);
5116 VAROR(DATE
,-1,I8
,0,I8
,-1);
5117 VAROR(DATE
,0,I8
,0,I8
,0);
5118 VAROR(DATE
,-1,UI8
,0,I4
,-1);
5119 VAROR(DATE
,0,UI8
,0,I4
,0);
5121 VAROR(DATE
,-1,INT
,-1,I4
,-1);
5122 VAROR(DATE
,-1,INT
,0,I4
,-1);
5123 VAROR(DATE
,0,INT
,0,I4
,0);
5124 VAROR(DATE
,-1,UINT
,0xffffffff,I4
,-1);
5125 VAROR(DATE
,-1,UINT
,0,I4
,-1);
5126 VAROR(DATE
,0,UINT
,0,I4
,0);
5127 rbstr
= SysAllocString(szFalse
);
5128 VAROR(DATE
,0,BSTR
,rbstr
,I4
,0);
5129 VAROR(DATE
,-1,BSTR
,rbstr
,I4
,-1);
5130 SysFreeString(rbstr
);
5131 rbstr
= SysAllocString(szTrue
);
5132 VAROR(DATE
,0,BSTR
,rbstr
,I4
,-1);
5133 VAROR(DATE
,-1,BSTR
,rbstr
,I4
,-1);
5134 SysFreeString(rbstr
);
5135 VARORCY(DATE
,-1,10000,I4
,-1);
5136 VARORCY(DATE
,-1,0,I4
,-1);
5137 VARORCY(DATE
,0,0,I4
,0);
5141 VAROR(I8
,-1,I8
,-1,I8
,-1);
5142 VAROR(I8
,-1,I8
,0,I8
,-1);
5143 VAROR(I8
,0,I8
,0,I8
,0);
5144 VAROR(I8
,-1,UI8
,0,I8
,-1);
5145 VAROR(I8
,0,UI8
,0,I8
,0);
5146 /* These overflow under native and Wine
5147 VAROR(I8,-1,INT,-1,I4,-1);
5148 VAROR(I8,-1,INT,0,I4,-1);
5149 VAROR(I8,0,INT,0,I4,0); */
5150 VAROR(I8
,-1,UINT
,0xffffffff,I8
,-1);
5151 VAROR(I8
,-1,UINT
,0,I8
,-1);
5152 VAROR(I8
,0,UINT
,0,I8
,0);
5153 rbstr
= SysAllocString(szFalse
);
5154 VAROR(I8
,0,BSTR
,rbstr
,I8
,0);
5155 VAROR(I8
,-1,BSTR
,rbstr
,I8
,-1);
5156 SysFreeString(rbstr
);
5157 rbstr
= SysAllocString(szTrue
);
5158 VAROR(I8
,0,BSTR
,rbstr
,I8
,-1);
5159 VAROR(I8
,-1,BSTR
,rbstr
,I8
,-1);
5160 SysFreeString(rbstr
);
5161 VARORCY(I8
,-1,10000,I8
,-1);
5162 VARORCY(I8
,-1,0,I8
,-1);
5163 VARORCY(I8
,0,0,I8
,0);
5165 VAROR(UI8
,0xffff,UI8
,0xffff,I4
,0xffff);
5166 VAROR(UI8
,0xffff,UI8
,0,I4
,0xffff);
5167 VAROR(UI8
,0,UI8
,0,I4
,0);
5168 VAROR(UI8
,0xffff,INT
,-1,I4
,-1);
5169 VAROR(UI8
,0xffff,INT
,0,I4
,0xffff);
5170 VAROR(UI8
,0,INT
,0,I4
,0);
5171 VAROR(UI8
,0xffff,UINT
,0xffff,I4
,0xffff);
5172 VAROR(UI8
,0xffff,UINT
,0,I4
,0xffff);
5173 VAROR(UI8
,0,UINT
,0,I4
,0);
5174 rbstr
= SysAllocString(szFalse
);
5175 VAROR(UI8
,0,BSTR
,rbstr
,I4
,0);
5176 VAROR(UI8
,0xffff,BSTR
,rbstr
,I4
,0xffff);
5177 SysFreeString(rbstr
);
5178 rbstr
= SysAllocString(szTrue
);
5179 VAROR(UI8
,0,BSTR
,rbstr
,I4
,-1);
5180 VAROR(UI8
,0xffff,BSTR
,rbstr
,I4
,-1);
5181 SysFreeString(rbstr
);
5182 VARORCY(UI8
,0xffff,10000,I4
,0xffff);
5183 VARORCY(UI8
,0xffff,0,I4
,0xffff);
5184 VARORCY(UI8
,0,0,I4
,0);
5187 VAROR(INT
,-1,INT
,-1,I4
,-1);
5188 VAROR(INT
,-1,INT
,0,I4
,-1);
5189 VAROR(INT
,0,INT
,0,I4
,0);
5190 VAROR(INT
,-1,UINT
,0xffff,I4
,-1);
5191 VAROR(INT
,-1,UINT
,0,I4
,-1);
5192 VAROR(INT
,0,UINT
,0,I4
,0);
5193 rbstr
= SysAllocString(szFalse
);
5194 VAROR(INT
,0,BSTR
,rbstr
,I4
,0);
5195 VAROR(INT
,-1,BSTR
,rbstr
,I4
,-1);
5196 SysFreeString(rbstr
);
5197 rbstr
= SysAllocString(szTrue
);
5198 VAROR(INT
,0,BSTR
,rbstr
,I4
,-1);
5199 VAROR(INT
,-1,BSTR
,rbstr
,I4
,-1);
5200 SysFreeString(rbstr
);
5201 VARORCY(INT
,-1,10000,I4
,-1);
5202 VARORCY(INT
,-1,0,I4
,-1);
5203 VARORCY(INT
,0,0,I4
,0);
5205 VAROR(UINT
,0xffff,UINT
,0xffff,I4
,0xffff);
5206 VAROR(UINT
,0xffff,UINT
,0,I4
,0xffff);
5207 VAROR(UINT
,0,UINT
,0,I4
,0);
5208 rbstr
= SysAllocString(szFalse
);
5209 VAROR(UINT
,0,BSTR
,rbstr
,I4
,0);
5210 VAROR(UINT
,0xffff,BSTR
,rbstr
,I4
,0xffff);
5211 SysFreeString(rbstr
);
5212 rbstr
= SysAllocString(szTrue
);
5213 VAROR(UINT
,0,BSTR
,rbstr
,I4
,-1);
5214 VAROR(UINT
,0xffff,BSTR
,rbstr
,I4
,-1);
5215 SysFreeString(rbstr
);
5216 VARORCY(UINT
,0xffff,10000,I4
,0xffff);
5217 VARORCY(UINT
,0xffff,0,I4
,0xffff);
5218 VARORCY(UINT
,0,0,I4
,0);
5220 lbstr
= SysAllocString(szFalse
);
5221 rbstr
= SysAllocString(szFalse
);
5222 VAROR(BSTR
,lbstr
,BSTR
,rbstr
,BOOL
,0);
5223 SysFreeString(rbstr
);
5224 rbstr
= SysAllocString(szTrue
);
5225 VAROR(BSTR
,lbstr
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
5226 SysFreeString(lbstr
);
5227 lbstr
= SysAllocString(szTrue
);
5228 VAROR(BSTR
,lbstr
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
5229 VARORCY(BSTR
,lbstr
,10000,I4
,-1);
5230 SysFreeString(lbstr
);
5231 lbstr
= SysAllocString(szFalse
);
5232 VARORCY(BSTR
,lbstr
,10000,I4
,1);
5233 SysFreeString(lbstr
);
5234 SysFreeString(rbstr
);
5237 static HRESULT (WINAPI
*pVarEqv
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
5239 #define VAREQV(vt1,val1,vt2,val2,rvt,rval) \
5240 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
5241 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
5242 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
5243 test_var_call2( __LINE__, pVarEqv, &left, &right, &exp )
5245 static void test_VarEqv(void)
5247 VARIANT left
, right
, exp
, result
;
5253 /* Test all possible flag/vt combinations & the resulting vt type */
5254 for (i
= 0; i
< ARRAY_SIZE(ExtraFlags
); i
++)
5256 VARTYPE leftvt
, rightvt
, resvt
;
5258 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
5262 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
5268 if (leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
||
5269 leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
||
5270 leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
)
5273 memset(&left
, 0, sizeof(left
));
5274 memset(&right
, 0, sizeof(right
));
5275 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
5276 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
5277 V_VT(&result
) = VT_EMPTY
;
5280 if (ExtraFlags
[i
] & VT_ARRAY
|| ExtraFlags
[i
] & VT_BYREF
||
5281 !IsValidVariantClearVT(leftvt
, ExtraFlags
[i
]) ||
5282 !IsValidVariantClearVT(rightvt
, ExtraFlags
[i
]) ||
5283 leftvt
== VT_CLSID
|| rightvt
== VT_CLSID
||
5284 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
||
5285 leftvt
== VT_VARIANT
|| rightvt
== VT_VARIANT
||
5286 leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
)
5290 if (leftvt
== VT_EMPTY
|| rightvt
== VT_EMPTY
)
5292 if (leftvt
== rightvt
||
5293 leftvt
== VT_I2
|| rightvt
== VT_I2
||
5294 leftvt
== VT_UI1
|| rightvt
== VT_UI1
||
5295 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
5297 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
5299 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
5302 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
5306 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
5308 if (leftvt
== rightvt
)
5310 else if (leftvt
== rightvt
||
5311 leftvt
== VT_I2
|| rightvt
== VT_I2
||
5312 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
5316 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
5319 else if (leftvt
== VT_I2
|| rightvt
== VT_I2
)
5321 if (leftvt
== rightvt
||
5322 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
5324 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
5327 else if (leftvt
== VT_BOOL
&& rightvt
== VT_BOOL
)
5331 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
5333 if (leftvt
== VT_INT
|| rightvt
== VT_INT
)
5338 hres
= pVarEqv(&left
, &right
, &result
);
5340 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
5341 "VarEqv: %d|0x%X, %d|0x%X: Expected failure, got 0x%X vt %d\n",
5342 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], hres
,
5345 ok(hres
== S_OK
&& V_VT(&result
) == resvt
,
5346 "VarEqv: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%X vt %d\n",
5347 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], resvt
, hres
,
5353 /* Test returned values */
5354 VAREQV(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
);
5355 VAREQV(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
);
5356 VAREQV(BOOL
,TRUE
,BOOL
,TRUE
,BOOL
,VARIANT_TRUE
);
5357 VAREQV(BOOL
,FALSE
,BOOL
,FALSE
,BOOL
,VARIANT_TRUE
);
5358 VAREQV(BOOL
,TRUE
,BOOL
,FALSE
,BOOL
,-2);
5359 VAREQV(BOOL
,FALSE
,BOOL
,TRUE
,BOOL
,-2);
5360 VAREQV(BOOL
,6,BOOL
,7,BOOL
,-2);
5361 VAREQV(BOOL
,6,BOOL
,6,BOOL
,VARIANT_TRUE
);
5362 VAREQV(BOOL
,VARIANT_TRUE
,I2
,VARIANT_TRUE
,I2
,VARIANT_TRUE
);
5363 VAREQV(BOOL
,VARIANT_TRUE
,I2
,VARIANT_FALSE
,I2
,VARIANT_FALSE
);
5364 VAREQV(BOOL
,6,I2
,7,I2
,-2);
5365 VAREQV(UI1
,1,UI1
,1,UI1
,255);
5366 VAREQV(UI1
,1,UI1
,0,UI1
,254);
5367 VAREQV(UI1
,0,UI1
,1,UI1
,254);
5370 VAREQV(UI4
,VARIANT_FALSE
,I8
,VARIANT_FALSE
,I8
,-1);
5371 VAREQV(UI4
,5,I8
,19,I8
,-23);
5372 VAREQV(UI4
,VARIANT_FALSE
,UI8
,VARIANT_FALSE
,I4
,-1);
5376 static HRESULT (WINAPI
*pVarMul
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
5378 #define VARMUL(vt1,val1,vt2,val2,rvt,rval) \
5379 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
5380 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
5381 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
5382 test_var_call2( __LINE__, pVarMul, &left, &right, &exp )
5384 static void test_VarMul(void)
5386 VARIANT left
, right
, exp
, result
, cy
, dec
;
5394 lbstr
= SysAllocString(sz12
);
5395 rbstr
= SysAllocString(sz12
);
5397 /* Test all possible flag/vt combinations & the resulting vt type */
5398 for (i
= 0; i
< ARRAY_SIZE(ExtraFlags
); i
++)
5400 VARTYPE leftvt
, rightvt
, resvt
;
5402 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
5407 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
5413 if (leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
||
5414 leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
)
5417 memset(&left
, 0, sizeof(left
));
5418 memset(&right
, 0, sizeof(right
));
5419 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
5420 if (leftvt
== VT_BSTR
)
5421 V_BSTR(&left
) = lbstr
;
5422 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
5423 if (rightvt
== VT_BSTR
)
5424 V_BSTR(&right
) = rbstr
;
5425 V_VT(&result
) = VT_EMPTY
;
5428 /* Don't ask me why but native VarMul cannot handle:
5429 VT_I1, VT_UI2, VT_UI4, VT_INT, VT_UINT and VT_UI8.
5430 Tested with DCOM98, Win2k, WinXP */
5431 if (ExtraFlags
[i
] & VT_ARRAY
|| ExtraFlags
[i
] & VT_BYREF
||
5432 !IsValidVariantClearVT(leftvt
, ExtraFlags
[i
]) ||
5433 !IsValidVariantClearVT(rightvt
, ExtraFlags
[i
]) ||
5434 leftvt
== VT_CLSID
|| rightvt
== VT_CLSID
||
5435 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
||
5436 leftvt
== VT_VARIANT
|| rightvt
== VT_VARIANT
||
5437 leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
||
5438 leftvt
== VT_I1
|| rightvt
== VT_I1
||
5439 leftvt
== VT_UI2
|| rightvt
== VT_UI2
||
5440 leftvt
== VT_UI4
|| rightvt
== VT_UI4
||
5441 leftvt
== VT_UI8
|| rightvt
== VT_UI8
||
5442 leftvt
== VT_INT
|| rightvt
== VT_INT
||
5443 leftvt
== VT_UINT
|| rightvt
== VT_UINT
) {
5447 if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
5449 else if (leftvt
== VT_DECIMAL
|| rightvt
== VT_DECIMAL
)
5451 else if (leftvt
== VT_R8
|| rightvt
== VT_R8
||
5452 leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
||
5453 leftvt
== VT_DATE
|| rightvt
== VT_DATE
)
5455 else if (leftvt
== VT_R4
|| rightvt
== VT_R4
) {
5456 if (leftvt
== VT_I4
|| rightvt
== VT_I4
||
5457 leftvt
== VT_I8
|| rightvt
== VT_I8
||
5458 leftvt
== VT_CY
|| rightvt
== VT_CY
)
5462 } else if (leftvt
== VT_CY
|| rightvt
== VT_CY
)
5464 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
5466 else if (leftvt
== VT_I4
|| rightvt
== VT_I4
)
5468 else if (leftvt
== VT_I2
|| rightvt
== VT_I2
||
5469 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
||
5470 (leftvt
== VT_EMPTY
&& rightvt
== VT_EMPTY
))
5472 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
5475 hres
= pVarMul(&left
, &right
, &result
);
5477 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
5478 "VarMul: %d|0x%X, %d|0x%X: Expected failure, got 0x%X vt %d\n",
5479 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], hres
,
5482 ok(hres
== S_OK
&& V_VT(&result
) == resvt
,
5483 "VarMul: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%X vt %d\n",
5484 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], resvt
, hres
,
5491 /* Test returned values */
5492 VARMUL(I4
,4,I4
,2,I4
,8);
5493 VARMUL(I2
,4,I2
,2,I2
,8);
5494 VARMUL(I2
,-13,I4
,5,I4
,-65);
5495 VARMUL(I4
,-13,I4
,5,I4
,-65);
5496 VARMUL(I2
,7,R4
,0.5f
,R4
,3.5f
);
5497 VARMUL(R4
,0.5f
,I4
,5,R8
,2.5);
5498 VARMUL(R8
,7.1,BOOL
,0,R8
,0);
5499 VARMUL(BSTR
,lbstr
,I2
,4,R8
,48);
5500 VARMUL(BSTR
,lbstr
,BOOL
,1,R8
,12);
5501 VARMUL(BSTR
,lbstr
,R4
,0.1f
,R8
,1.2);
5502 VARMUL(BSTR
,lbstr
,BSTR
,rbstr
,R8
,144);
5503 VARMUL(R4
,0.2f
,BSTR
,rbstr
,R8
,2.4);
5504 VARMUL(DATE
,2.25,I4
,7,R8
,15.75);
5506 VARMUL(UI1
, UI1_MAX
, UI1
, UI1_MAX
, I4
, UI1_MAX
* UI1_MAX
);
5507 VARMUL(I2
, I2_MAX
, I2
, I2_MAX
, I4
, I2_MAX
* I2_MAX
);
5508 VARMUL(I2
, I2_MAX
, I2
, I2_MIN
, I4
, I2_MAX
* I2_MIN
);
5509 VARMUL(I2
, I2_MIN
, I2
, I2_MIN
, I4
, I2_MIN
* I2_MIN
);
5510 VARMUL(I4
, I4_MAX
, I4
, I4_MAX
, R8
, (double)I4_MAX
* I4_MAX
);
5511 VARMUL(I4
, I4_MAX
, I4
, I4_MIN
, R8
, (double)I4_MAX
* I4_MIN
);
5512 VARMUL(I4
, I4_MIN
, I4
, I4_MIN
, R8
, (double)I4_MIN
* I4_MIN
);
5513 VARMUL(R4
, R4_MAX
, R4
, R4_MAX
, R8
, (double)R4_MAX
* R4_MAX
);
5514 VARMUL(R4
, R4_MAX
, R4
, R4_MIN
, R4
, R4_MAX
* R4_MIN
);
5515 VARMUL(R4
, R4_MIN
, R4
, R4_MIN
, R4
, R4_MIN
* R4_MIN
);
5516 VARMUL(R8
, R8_MAX
, R8
, R8_MIN
, R8
, R8_MAX
* R8_MIN
);
5517 VARMUL(R8
, R8_MIN
, R8
, R8_MIN
, R8
, R8_MIN
* R8_MIN
);
5519 /* Manuly test some VT_CY and VT_DECIMAL variants */
5521 hres
= VarCyFromI4(4711, &V_CY(&cy
));
5522 ok(hres
== S_OK
, "VarCyFromI4 failed!\n");
5523 V_VT(&dec
) = VT_DECIMAL
;
5524 hres
= VarDecFromR8(-4.2, &V_DECIMAL(&dec
));
5525 ok(hres
== S_OK
, "VarDecFromR4 failed!\n");
5526 memset(&left
, 0, sizeof(left
));
5527 memset(&right
, 0, sizeof(right
));
5528 V_VT(&left
) = VT_I4
;
5530 V_VT(&right
) = VT_UI1
;
5533 hres
= pVarMul(&cy
, &right
, &result
);
5534 ok(hres
== S_OK
&& V_VT(&result
) == VT_CY
, "VarMul: expected coerced type VT_CY, got %s!\n", vtstr(V_VT(&result
)));
5535 hres
= VarR8FromCy(V_CY(&result
), &r
);
5536 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 42399.0), "VarMul: CY value %f, expected %f\n", r
, 42399.0);
5538 hres
= pVarMul(&left
, &dec
, &result
);
5539 ok(hres
== S_OK
&& V_VT(&result
) == VT_DECIMAL
, "VarMul: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result
)));
5540 hres
= VarR8FromDec(&V_DECIMAL(&result
), &r
);
5541 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 46.2), "VarMul: DECIMAL value %f, expected %f\n", r
, 46.2);
5543 SysFreeString(lbstr
);
5544 SysFreeString(rbstr
);
5547 static HRESULT (WINAPI
*pVarAdd
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
5549 #define VARADD(vt1,val1,vt2,val2,rvt,rval) \
5550 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
5551 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
5552 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
5553 test_var_call2( __LINE__, pVarAdd, &left, &right, &exp )
5555 static void test_VarAdd(void)
5557 VARIANT left
, right
, exp
, result
, cy
, dec
;
5565 lbstr
= SysAllocString(sz12
);
5566 rbstr
= SysAllocString(sz12
);
5568 /* Test all possible flag/vt combinations & the resulting vt type */
5569 for (i
= 0; i
< ARRAY_SIZE(ExtraFlags
); i
++)
5571 VARTYPE leftvt
, rightvt
, resvt
;
5573 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
5578 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
5584 if (leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
)
5587 memset(&left
, 0, sizeof(left
));
5588 memset(&right
, 0, sizeof(right
));
5589 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
5590 if (leftvt
== VT_BSTR
)
5591 V_BSTR(&left
) = lbstr
;
5592 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
5593 if (rightvt
== VT_BSTR
)
5594 V_BSTR(&right
) = rbstr
;
5595 V_VT(&result
) = VT_EMPTY
;
5598 /* Don't ask me why but native VarAdd cannot handle:
5599 VT_I1, VT_UI2, VT_UI4, VT_INT, VT_UINT and VT_UI8.
5600 Tested with DCOM98, Win2k, WinXP */
5601 if (ExtraFlags
[i
] & VT_ARRAY
|| ExtraFlags
[i
] & VT_BYREF
||
5602 !IsValidVariantClearVT(leftvt
, ExtraFlags
[i
]) ||
5603 !IsValidVariantClearVT(rightvt
, ExtraFlags
[i
]) ||
5604 leftvt
== VT_CLSID
|| rightvt
== VT_CLSID
||
5605 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
||
5606 leftvt
== VT_VARIANT
|| rightvt
== VT_VARIANT
||
5607 leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
||
5608 leftvt
== VT_I1
|| rightvt
== VT_I1
||
5609 leftvt
== VT_UI2
|| rightvt
== VT_UI2
||
5610 leftvt
== VT_UI4
|| rightvt
== VT_UI4
||
5611 leftvt
== VT_UI8
|| rightvt
== VT_UI8
||
5612 leftvt
== VT_INT
|| rightvt
== VT_INT
||
5613 leftvt
== VT_UINT
|| rightvt
== VT_UINT
) {
5617 if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
5619 else if (leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
)
5621 else if (leftvt
== VT_DECIMAL
|| rightvt
== VT_DECIMAL
)
5623 else if (leftvt
== VT_DATE
|| rightvt
== VT_DATE
)
5625 else if (leftvt
== VT_CY
|| rightvt
== VT_CY
)
5627 else if (leftvt
== VT_R8
|| rightvt
== VT_R8
)
5629 else if (leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
) {
5630 if ((leftvt
== VT_BSTR
&& rightvt
== VT_BSTR
) ||
5631 leftvt
== VT_EMPTY
|| rightvt
== VT_EMPTY
)
5635 } else if (leftvt
== VT_R4
|| rightvt
== VT_R4
) {
5636 if (leftvt
== VT_I4
|| rightvt
== VT_I4
||
5637 leftvt
== VT_I8
|| rightvt
== VT_I8
)
5642 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
5644 else if (leftvt
== VT_I4
|| rightvt
== VT_I4
)
5646 else if (leftvt
== VT_I2
|| rightvt
== VT_I2
||
5647 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
||
5648 (leftvt
== VT_EMPTY
&& rightvt
== VT_EMPTY
))
5650 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
5653 hres
= pVarAdd(&left
, &right
, &result
);
5655 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
5656 "VarAdd: %d|0x%X, %d|0x%X: Expected failure, got 0x%X vt %d\n",
5657 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], hres
,
5660 ok(hres
== S_OK
&& V_VT(&result
) == resvt
,
5661 "VarAdd: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%X vt %d\n",
5662 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], resvt
, hres
,
5665 /* Note, we don't clear left/right deliberately here */
5666 VariantClear(&result
);
5671 /* Test returned values */
5672 VARADD(I4
,4,I4
,2,I4
,6);
5673 VARADD(I2
,4,I2
,2,I2
,6);
5674 VARADD(I2
,-13,I4
,5,I4
,-8);
5675 VARADD(I4
,-13,I4
,5,I4
,-8);
5676 VARADD(I2
,7,R4
,0.5f
,R4
,7.5f
);
5677 VARADD(R4
,0.5f
,I4
,5,R8
,5.5);
5678 VARADD(R8
,7.1,BOOL
,0,R8
,7.1);
5679 VARADD(BSTR
,lbstr
,I2
,4,R8
,16);
5680 VARADD(BSTR
,lbstr
,BOOL
,1,R8
,13);
5681 VARADD(BSTR
,lbstr
,R4
,0.1f
,R8
,12.1);
5682 VARADD(R4
,0.2f
,BSTR
,rbstr
,R8
,12.2);
5683 VARADD(DATE
,2.25,I4
,7,DATE
,9.25);
5684 VARADD(DATE
,1.25,R4
,-1.7f
,DATE
,-0.45);
5686 VARADD(UI1
, UI1_MAX
, UI1
, UI1_MAX
, I2
, UI1_MAX
+ UI1_MAX
);
5687 VARADD(I2
, I2_MAX
, I2
, I2_MAX
, I4
, I2_MAX
+ I2_MAX
);
5688 VARADD(I2
, I2_MAX
, I2
, I2_MIN
, I2
, I2_MAX
+ I2_MIN
);
5689 VARADD(I2
, I2_MIN
, I2
, I2_MIN
, I4
, I2_MIN
+ I2_MIN
);
5690 VARADD(I4
, I4_MAX
, I4
, I4_MIN
, I4
, I4_MAX
+ I4_MIN
);
5691 VARADD(I4
, I4_MAX
, I4
, I4_MAX
, R8
, (double)I4_MAX
+ I4_MAX
);
5692 VARADD(I4
, I4_MIN
, I4
, I4_MIN
, R8
, (double)I4_MIN
+ I4_MIN
);
5693 VARADD(R4
, R4_MAX
, R4
, R4_MAX
, R8
, (double)R4_MAX
+ R4_MAX
);
5694 VARADD(R4
, R4_MAX
, R4
, R4_MIN
, R4
, R4_MAX
+ R4_MIN
);
5695 VARADD(R4
, R4_MIN
, R4
, R4_MIN
, R4
, R4_MIN
+ R4_MIN
);
5696 VARADD(R8
, R8_MAX
, R8
, R8_MIN
, R8
, R8_MAX
+ R8_MIN
);
5697 VARADD(R8
, R8_MIN
, R8
, R8_MIN
, R8
, R8_MIN
+ R8_MIN
);
5699 /* Manually test BSTR + BSTR */
5700 V_VT(&left
) = VT_BSTR
;
5701 V_BSTR(&left
) = lbstr
;
5702 V_VT(&right
) = VT_BSTR
;
5703 V_BSTR(&right
) = rbstr
;
5704 hres
= pVarAdd(&left
, &right
, &result
);
5705 ok(hres
== S_OK
&& V_VT(&result
) == VT_BSTR
, "VarAdd: expected coerced type VT_BSTR, got %s!\n", vtstr(V_VT(&result
)));
5706 hres
= VarR8FromStr(V_BSTR(&result
), 0, 0, &r
);
5707 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 1212.0), "VarAdd: BSTR value %f, expected %f\n", r
, 1212.0);
5708 VariantClear(&result
);
5710 /* Manuly test some VT_CY and VT_DECIMAL variants */
5712 hres
= VarCyFromI4(4711, &V_CY(&cy
));
5713 ok(hres
== S_OK
, "VarCyFromI4 failed!\n");
5714 V_VT(&dec
) = VT_DECIMAL
;
5715 hres
= VarDecFromR8(-4.2, &V_DECIMAL(&dec
));
5716 ok(hres
== S_OK
, "VarDecFromR4 failed!\n");
5717 memset(&left
, 0, sizeof(left
));
5718 memset(&right
, 0, sizeof(right
));
5719 V_VT(&left
) = VT_I4
;
5721 V_VT(&right
) = VT_UI1
;
5724 hres
= pVarAdd(&cy
, &right
, &result
);
5725 ok(hres
== S_OK
&& V_VT(&result
) == VT_CY
, "VarAdd: expected coerced type VT_CY, got %s!\n", vtstr(V_VT(&result
)));
5726 hres
= VarR8FromCy(V_CY(&result
), &r
);
5727 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 4720.0), "VarAdd: CY value %f, expected %f\n", r
, 4720.0);
5729 hres
= pVarAdd(&left
, &dec
, &result
);
5730 ok(hres
== S_OK
&& V_VT(&result
) == VT_DECIMAL
, "VarAdd: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result
)));
5731 hres
= VarR8FromDec(&V_DECIMAL(&result
), &r
);
5732 ok(hres
== S_OK
&& EQ_DOUBLE(r
, -15.2), "VarAdd: DECIMAL value %f, expected %f\n", r
, -15.2);
5733 VariantClear(&result
);
5735 SysFreeString(lbstr
);
5736 SysFreeString(rbstr
);
5739 static HRESULT (WINAPI
*pVarCmp
)(LPVARIANT
,LPVARIANT
,LCID
,ULONG
);
5740 static HRESULT (WINAPI
*pVarCat
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
5742 static void test_VarCat(void)
5745 VARIANT left
, right
, result
, expected
, expected_broken
;
5746 static const WCHAR sz34
[] = {'3','4','\0'};
5747 static const WCHAR sz1234
[] = {'1','2','3','4','\0'};
5748 static const WCHAR date_sz12
[] = {'9','/','3','0','/','1','9','8','0','1','2','\0'};
5749 static const WCHAR date_sz12_broken
[] = {'9','/','3','0','/','8','0','1','2','\0'};
5750 static const WCHAR sz12_date
[] = {'1','2','9','/','3','0','/','1','9','8','0','\0'};
5751 static const WCHAR sz12_date_broken
[] = {'1','2','9','/','3','0','/','8','0','\0'};
5752 static const WCHAR sz_empty
[] = {'\0'};
5753 CHAR orig_date_format
[128];
5754 VARTYPE leftvt
, rightvt
, resultvt
;
5756 HRESULT expected_error_num
;
5758 DummyDispatch dispatch
;
5762 /* Set date format for testing */
5763 lcid
= LOCALE_USER_DEFAULT
;
5764 GetLocaleInfoA(lcid
,LOCALE_SSHORTDATE
,orig_date_format
,128);
5765 SetLocaleInfoA(lcid
,LOCALE_SSHORTDATE
,"M/d/yyyy");
5768 VariantInit(&right
);
5769 VariantInit(&result
);
5770 VariantInit(&expected
);
5772 /* Check expected types for all combinations */
5773 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
5778 /* Check if we need/have support for I8 and/or UI8 */
5779 if ((leftvt
== VT_I8
|| leftvt
== VT_UI8
) && !has_i8
)
5782 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
5786 expected_error_num
= S_OK
;
5787 resultvt
= VT_EMPTY
;
5789 if (leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
||
5790 leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
||
5791 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
||
5792 leftvt
== 15 || rightvt
== 15 /* Undefined type */)
5795 /* Check if we need/have support for I8 and/or UI8 */
5796 if ((rightvt
== VT_I8
|| rightvt
== VT_UI8
) && !has_i8
)
5799 if (leftvt
== VT_NULL
&& rightvt
== VT_NULL
)
5801 else if (leftvt
== VT_VARIANT
&& (rightvt
== VT_ERROR
||
5802 rightvt
== VT_DATE
|| rightvt
== VT_DECIMAL
))
5803 expected_error_num
= DISP_E_TYPEMISMATCH
;
5804 else if ((leftvt
== VT_I2
|| leftvt
== VT_I4
||
5805 leftvt
== VT_R4
|| leftvt
== VT_R8
||
5806 leftvt
== VT_CY
|| leftvt
== VT_BOOL
||
5807 leftvt
== VT_BSTR
|| leftvt
== VT_I1
||
5808 leftvt
== VT_UI1
|| leftvt
== VT_UI2
||
5809 leftvt
== VT_UI4
|| leftvt
== VT_I8
||
5810 leftvt
== VT_UI8
|| leftvt
== VT_INT
||
5811 leftvt
== VT_UINT
|| leftvt
== VT_EMPTY
||
5812 leftvt
== VT_NULL
|| leftvt
== VT_DECIMAL
||
5815 (rightvt
== VT_I2
|| rightvt
== VT_I4
||
5816 rightvt
== VT_R4
|| rightvt
== VT_R8
||
5817 rightvt
== VT_CY
|| rightvt
== VT_BOOL
||
5818 rightvt
== VT_BSTR
|| rightvt
== VT_I1
||
5819 rightvt
== VT_UI1
|| rightvt
== VT_UI2
||
5820 rightvt
== VT_UI4
|| rightvt
== VT_I8
||
5821 rightvt
== VT_UI8
|| rightvt
== VT_INT
||
5822 rightvt
== VT_UINT
|| rightvt
== VT_EMPTY
||
5823 rightvt
== VT_NULL
|| rightvt
== VT_DECIMAL
||
5824 rightvt
== VT_DATE
))
5826 else if (rightvt
== VT_ERROR
&& leftvt
< VT_VOID
)
5827 expected_error_num
= DISP_E_TYPEMISMATCH
;
5828 else if (leftvt
== VT_ERROR
&& (rightvt
== VT_DATE
||
5829 rightvt
== VT_ERROR
|| rightvt
== VT_DECIMAL
))
5830 expected_error_num
= DISP_E_TYPEMISMATCH
;
5831 else if (rightvt
== VT_DATE
|| rightvt
== VT_ERROR
||
5832 rightvt
== VT_DECIMAL
)
5833 expected_error_num
= DISP_E_BADVARTYPE
;
5834 else if (leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
)
5835 expected_error_num
= DISP_E_TYPEMISMATCH
;
5836 else if (leftvt
== VT_VARIANT
)
5837 expected_error_num
= DISP_E_TYPEMISMATCH
;
5838 else if (rightvt
== VT_VARIANT
&& (leftvt
== VT_EMPTY
||
5839 leftvt
== VT_NULL
|| leftvt
== VT_I2
||
5840 leftvt
== VT_I4
|| leftvt
== VT_R4
||
5841 leftvt
== VT_R8
|| leftvt
== VT_CY
||
5842 leftvt
== VT_DATE
|| leftvt
== VT_BSTR
||
5843 leftvt
== VT_BOOL
|| leftvt
== VT_DECIMAL
||
5844 leftvt
== VT_I1
|| leftvt
== VT_UI1
||
5845 leftvt
== VT_UI2
|| leftvt
== VT_UI4
||
5846 leftvt
== VT_I8
|| leftvt
== VT_UI8
||
5847 leftvt
== VT_INT
|| leftvt
== VT_UINT
5849 expected_error_num
= DISP_E_TYPEMISMATCH
;
5851 expected_error_num
= DISP_E_BADVARTYPE
;
5853 V_VT(&left
) = leftvt
;
5854 V_VT(&right
) = rightvt
;
5858 V_BSTR(&left
) = SysAllocString(sz_empty
); break;
5860 V_DATE(&left
) = 0.0; break;
5862 VarDecFromR8(0.0, &V_DECIMAL(&left
)); break;
5869 V_BSTR(&right
) = SysAllocString(sz_empty
); break;
5871 V_DATE(&right
) = 0.0; break;
5873 VarDecFromR8(0.0, &V_DECIMAL(&right
)); break;
5878 hres
= pVarCat(&left
, &right
, &result
);
5880 /* Determine the error code for the vt combination */
5881 ok(hres
== expected_error_num
,
5882 "VarCat: %d, %d returned error, 0x%X expected 0x%X.\n",
5883 leftvt
, rightvt
, hres
, expected_error_num
);
5885 /* Check types are correct */
5886 ok(V_VT(&result
) == resultvt
,
5887 "VarCat: %d, %d: expected vt %d, got vt %d\n",
5888 leftvt
, rightvt
, resultvt
, V_VT(&result
));
5890 VariantClear(&left
);
5891 VariantClear(&right
);
5892 VariantClear(&result
);
5896 /* Running single comparison tests to compare outputs */
5898 /* Test concat strings */
5899 V_VT(&left
) = VT_BSTR
;
5900 V_VT(&right
) = VT_BSTR
;
5901 V_VT(&expected
) = VT_BSTR
;
5902 V_BSTR(&left
) = SysAllocString(sz12
);
5903 V_BSTR(&right
) = SysAllocString(sz34
);
5904 V_BSTR(&expected
) = SysAllocString(sz1234
);
5905 hres
= pVarCat(&left
,&right
,&result
);
5906 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5908 ok(pVarCmp(&result
,&expected
,lcid
,0) == VARCMP_EQ
,
5909 "VarCat: VT_BSTR concat with VT_BSTR failed to return correct result\n");
5911 VariantClear(&left
);
5912 VariantClear(&right
);
5913 VariantClear(&result
);
5915 /* Test if expression is VT_ERROR */
5916 V_VT(&left
) = VT_ERROR
;
5917 V_VT(&right
) = VT_BSTR
;
5918 V_BSTR(&right
) = SysAllocString(sz1234
);
5919 hres
= pVarCat(&left
,&right
,&result
);
5920 ok(hres
== DISP_E_TYPEMISMATCH
, "VarCat should have returned DISP_E_TYPEMISMATCH instead of 0x%08x\n", hres
);
5921 ok(V_VT(&result
) == VT_EMPTY
,
5922 "VarCat: VT_ERROR concat with VT_BSTR should have returned VT_EMPTY\n");
5924 VariantClear(&left
);
5925 VariantClear(&right
);
5926 VariantClear(&result
);
5928 V_VT(&left
) = VT_BSTR
;
5929 V_VT(&right
) = VT_ERROR
;
5930 V_BSTR(&left
) = SysAllocString(sz1234
);
5931 hres
= pVarCat(&left
,&right
,&result
);
5932 ok(hres
== DISP_E_TYPEMISMATCH
, "VarCat should have returned DISP_E_TYPEMISMATCH instead of 0x%08x\n", hres
);
5933 ok(V_VT(&result
) == VT_EMPTY
,
5934 "VarCat: VT_BSTR concat with VT_ERROR should have returned VT_EMPTY\n");
5936 VariantClear(&left
);
5937 VariantClear(&right
);
5938 VariantClear(&result
);
5939 VariantClear(&expected
);
5941 /* Test combining boolean with number */
5942 V_VT(&left
) = VT_INT
;
5943 V_VT(&right
) = VT_BOOL
;
5944 V_VT(&expected
) = VT_BSTR
;
5946 V_BOOL(&right
) = TRUE
;
5947 V_BSTR(&expected
) = SysAllocString(sz12_true
);
5948 hres
= pVarCat(&left
,&right
,&result
);
5949 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5952 hres
= pVarCmp(&result
,&expected
,lcid
,0);
5953 ok(hres
== VARCMP_EQ
, "Expected VARCMP_EQ, got %08x for %s, %s\n",
5954 hres
, variantstr(&result
), variantstr(&expected
));
5957 VariantClear(&left
);
5958 VariantClear(&right
);
5959 VariantClear(&result
);
5960 VariantClear(&expected
);
5962 V_VT(&left
) = VT_INT
;
5963 V_VT(&right
) = VT_BOOL
;
5964 V_VT(&expected
) = VT_BSTR
;
5966 V_BOOL(&right
) = FALSE
;
5967 V_BSTR(&expected
) = SysAllocString(sz12_false
);
5968 hres
= pVarCat(&left
,&right
,&result
);
5969 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5972 hres
= pVarCmp(&result
,&expected
,lcid
,0);
5973 ok(hres
== VARCMP_EQ
, "Expected VARCMP_EQ, got %08x for %s, %s\n",
5974 hres
, variantstr(&result
), variantstr(&expected
));
5977 VariantClear(&left
);
5978 VariantClear(&right
);
5979 VariantClear(&result
);
5980 VariantClear(&expected
);
5982 /* Test when both expressions are numeric */
5983 V_VT(&left
) = VT_INT
;
5984 V_VT(&right
) = VT_INT
;
5985 V_VT(&expected
) = VT_BSTR
;
5988 V_BSTR(&expected
) = SysAllocString(sz1234
);
5989 hres
= pVarCat(&left
,&right
,&result
);
5990 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5992 ok(pVarCmp(&result
,&expected
,lcid
,0) == VARCMP_EQ
,
5993 "VarCat: NUMBER concat with NUMBER returned incorrect result\n");
5995 VariantClear(&left
);
5996 VariantClear(&right
);
5997 VariantClear(&result
);
5999 /* Test if one expression is numeric and the other is a string */
6000 V_VT(&left
) = VT_INT
;
6001 V_VT(&right
) = VT_BSTR
;
6003 V_BSTR(&right
) = SysAllocString(sz34
);
6004 hres
= pVarCat(&left
,&right
,&result
);
6005 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
6007 ok(pVarCmp(&result
,&expected
,lcid
,0) == VARCMP_EQ
,
6008 "VarCat: NUMBER concat with VT_BSTR, incorrect result\n");
6010 VariantClear(&left
);
6011 VariantClear(&right
);
6012 VariantClear(&result
);
6014 V_VT(&left
) = VT_BSTR
;
6015 V_VT(&right
) = VT_INT
;
6016 V_BSTR(&left
) = SysAllocString(sz12
);
6018 hres
= pVarCat(&left
,&right
,&result
);
6019 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
6021 ok(pVarCmp(&result
,&expected
,lcid
,0) == VARCMP_EQ
,
6022 "VarCat: VT_BSTR concat with NUMBER, incorrect result\n");
6024 VariantClear(&left
);
6025 VariantClear(&right
);
6026 VariantClear(&result
);
6027 VariantClear(&expected
);
6029 /* Test concat dates with strings */
6030 V_VT(&left
) = VT_BSTR
;
6031 V_VT(&right
) = VT_DATE
;
6032 V_VT(&expected
) = VT_BSTR
;
6033 V_VT(&expected_broken
) = VT_BSTR
;
6034 V_BSTR(&left
) = SysAllocString(sz12
);
6035 V_DATE(&right
) = 29494.0;
6036 V_BSTR(&expected
)= SysAllocString(sz12_date
);
6037 V_BSTR(&expected_broken
)= SysAllocString(sz12_date_broken
);
6038 hres
= pVarCat(&left
,&right
,&result
);
6039 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
6041 ok(pVarCmp(&result
,&expected
,lcid
,0) == VARCMP_EQ
||
6042 broken(pVarCmp(&result
,&expected_broken
,lcid
,0) == VARCMP_EQ
), /* Some W98 and NT4 (intermittent) */
6043 "VarCat: VT_BSTR concat with VT_DATE returned incorrect result\n");
6045 VariantClear(&left
);
6046 VariantClear(&right
);
6047 VariantClear(&result
);
6048 VariantClear(&expected
);
6049 VariantClear(&expected_broken
);
6051 V_VT(&left
) = VT_DATE
;
6052 V_VT(&right
) = VT_BSTR
;
6053 V_VT(&expected
) = VT_BSTR
;
6054 V_VT(&expected_broken
) = VT_BSTR
;
6055 V_DATE(&left
) = 29494.0;
6056 V_BSTR(&right
) = SysAllocString(sz12
);
6057 V_BSTR(&expected
)= SysAllocString(date_sz12
);
6058 V_BSTR(&expected_broken
)= SysAllocString(date_sz12_broken
);
6059 hres
= pVarCat(&left
,&right
,&result
);
6060 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
6062 ok(pVarCmp(&result
,&expected
,lcid
,0) == VARCMP_EQ
||
6063 broken(pVarCmp(&result
,&expected_broken
,lcid
,0) == VARCMP_EQ
), /* Some W98 and NT4 (intermittent) */
6064 "VarCat: VT_DATE concat with VT_BSTR returned incorrect result\n");
6066 VariantClear(&left
);
6067 VariantClear(&right
);
6068 VariantClear(&result
);
6069 VariantClear(&expected
);
6070 VariantClear(&expected_broken
);
6072 /* Test of both expressions are empty */
6073 V_VT(&left
) = VT_BSTR
;
6074 V_VT(&right
) = VT_BSTR
;
6075 V_VT(&expected
) = VT_BSTR
;
6076 V_BSTR(&left
) = SysAllocString(sz_empty
);
6077 V_BSTR(&right
) = SysAllocString(sz_empty
);
6078 V_BSTR(&expected
)= SysAllocString(sz_empty
);
6079 hres
= pVarCat(&left
,&right
,&result
);
6080 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
6082 ok(pVarCmp(&result
,&left
,lcid
,0) == VARCMP_EQ
,
6083 "VarCat: EMPTY concat with EMPTY did not return empty VT_BSTR\n");
6085 /* Restore original date format settings */
6086 SetLocaleInfoA(lcid
,LOCALE_SSHORTDATE
,orig_date_format
);
6088 VariantClear(&left
);
6089 VariantClear(&right
);
6090 VariantClear(&result
);
6091 VariantClear(&expected
);
6093 /* Dispatch conversion */
6094 init_test_dispatch(VT_NULL
, &dispatch
);
6095 V_VT(&left
) = VT_DISPATCH
;
6096 V_DISPATCH(&left
) = &dispatch
.IDispatch_iface
;
6098 SET_EXPECT(dispatch_invoke
);
6099 hres
= VarCat(&left
, &right
, &result
);
6100 ok(hres
== S_OK
, "got 0x%08x\n", hres
);
6101 ok(V_VT(&result
) == VT_BSTR
, "got %d\n", V_VT(&result
));
6102 ok(SysStringLen(V_BSTR(&result
)) == 0, "got %d\n", SysStringLen(V_BSTR(&result
)));
6103 CHECK_CALLED(dispatch_invoke
);
6105 VariantClear(&left
);
6106 VariantClear(&right
);
6107 VariantClear(&result
);
6109 init_test_dispatch(VT_NULL
, &dispatch
);
6110 V_VT(&right
) = VT_DISPATCH
;
6111 V_DISPATCH(&right
) = &dispatch
.IDispatch_iface
;
6113 SET_EXPECT(dispatch_invoke
);
6114 hres
= VarCat(&left
, &right
, &result
);
6115 ok(hres
== S_OK
, "got 0x%08x\n", hres
);
6116 ok(V_VT(&result
) == VT_BSTR
, "got %d\n", V_VT(&result
));
6117 ok(SysStringLen(V_BSTR(&result
)) == 0, "got %d\n", SysStringLen(V_BSTR(&result
)));
6118 CHECK_CALLED(dispatch_invoke
);
6120 VariantClear(&left
);
6121 VariantClear(&right
);
6122 VariantClear(&result
);
6124 init_test_dispatch(VT_UI1
, &dispatch
);
6125 V_VT(&right
) = VT_DISPATCH
;
6126 V_DISPATCH(&right
) = &dispatch
.IDispatch_iface
;
6128 V_VT(&left
) = VT_BSTR
;
6129 V_BSTR(&left
) = SysAllocString(sz12
);
6130 SET_EXPECT(dispatch_invoke
);
6131 hres
= pVarCat(&left
,&right
,&result
);
6132 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
6133 CHECK_CALLED(dispatch_invoke
);
6134 ok(!lstrcmpW(V_BSTR(&result
), L
"1234"), "got %s\n", wine_dbgstr_w(V_BSTR(&result
)));
6136 VariantClear(&left
);
6137 VariantClear(&right
);
6138 VariantClear(&result
);
6140 init_test_dispatch(VT_NULL
, &dispatch
);
6141 dispatch
.result
= E_OUTOFMEMORY
;
6142 V_VT(&right
) = VT_DISPATCH
;
6143 V_DISPATCH(&right
) = &dispatch
.IDispatch_iface
;
6145 SET_EXPECT(dispatch_invoke
);
6146 hres
= VarCat(&left
, &right
, &result
);
6147 ok(hres
== E_OUTOFMEMORY
, "got 0x%08x\n", hres
);
6148 CHECK_CALLED(dispatch_invoke
);
6150 VariantClear(&left
);
6151 VariantClear(&right
);
6152 VariantClear(&result
);
6154 init_test_dispatch(VT_NULL
, &dispatch
);
6155 dispatch
.result
= DISP_E_TYPEMISMATCH
;
6156 V_VT(&right
) = VT_DISPATCH
;
6157 V_DISPATCH(&right
) = &dispatch
.IDispatch_iface
;
6159 SET_EXPECT(dispatch_invoke
);
6160 hres
= VarCat(&left
, &right
, &result
);
6161 ok(hres
== DISP_E_TYPEMISMATCH
, "got 0x%08x\n", hres
);
6162 CHECK_CALLED(dispatch_invoke
);
6164 VariantClear(&left
);
6165 VariantClear(&right
);
6166 VariantClear(&result
);
6168 /* Test boolean conversion */
6169 V_VT(&left
) = VT_BOOL
;
6170 V_BOOL(&left
) = VARIANT_TRUE
;
6171 V_VT(&right
) = VT_BSTR
;
6172 V_BSTR(&right
) = SysAllocStringLen(NULL
,0);
6173 hres
= pVarCat(&left
, &right
, &result
);
6174 ok(hres
== S_OK
, "VarCat failed: %08x\n", hres
);
6175 VariantClear(&right
);
6177 cmp
= lstrcmpW(V_BSTR(&result
), L
"True");
6178 VariantClear(&result
);
6180 V_VT(&right
) = VT_BOOL
;
6181 V_BOOL(&right
) = 100;
6182 hres
= pVarCat(&left
, &right
, &result
);
6183 ok(hres
== S_OK
, "VarCat failed: %08x\n", hres
);
6184 test_bstr_var(&result
, L
"TrueTrue");
6185 VariantClear(&result
);
6187 V_BOOL(&right
) = VARIANT_FALSE
;
6188 hres
= pVarCat(&left
, &right
, &result
);
6189 ok(hres
== S_OK
, "VarCat failed: %08x\n", hres
);
6190 test_bstr_var(&result
, L
"TrueFalse");
6191 VariantClear(&result
);
6193 skip("Got %s as True, assuming non-English locale\n", wine_dbgstr_w(V_BSTR(&result
)));
6197 static HRESULT (WINAPI
*pVarAnd
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
6199 #define VARAND(vt1,val1,vt2,val2,rvt,rval) \
6200 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
6201 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
6202 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
6203 test_var_call2( __LINE__, pVarAnd, &left, &right, &exp )
6205 #define VARANDCY(vt1,val1,val2,rvt,rval) \
6206 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
6207 V_VT(&right) = VT_CY; V_CY(&right).int64 = val2; \
6208 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
6209 test_var_call2( __LINE__, pVarAnd, &left, &right, &exp )
6211 /* Skip any type that is not defined or produces an error for every case */
6212 #define SKIPTESTAND(a) \
6213 if (a == VT_ERROR || a == VT_VARIANT || \
6214 a == VT_DISPATCH || a == VT_UNKNOWN || \
6215 a > VT_UINT || a == 15 /*not defined*/) \
6218 static void test_VarAnd(void)
6220 static const WCHAR szFalse
[] = { '#','F','A','L','S','E','#','\0' };
6221 static const WCHAR szTrue
[] = { '#','T','R','U','E','#','\0' };
6222 VARIANT left
, right
, exp
, result
;
6223 BSTR false_str
, true_str
;
6229 true_str
= SysAllocString(szTrue
);
6230 false_str
= SysAllocString(szFalse
);
6232 /* Test all possible flag/vt combinations & the resulting vt type */
6233 for (i
= 0; i
< ARRAY_SIZE(ExtraFlags
); i
++)
6235 VARTYPE leftvt
, rightvt
, resvt
;
6237 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
6239 SKIPTESTAND(leftvt
);
6241 /* Check if we need/have support for I8 and/or UI8 */
6242 if ((leftvt
== VT_I8
|| leftvt
== VT_UI8
) && !has_i8
)
6245 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
6248 SKIPTESTAND(rightvt
);
6250 /* Check if we need/have support for I8 and/or UI8 */
6251 if ((rightvt
== VT_I8
|| rightvt
== VT_UI8
) && !has_i8
)
6254 memset(&left
, 0, sizeof(left
));
6255 memset(&right
, 0, sizeof(right
));
6256 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
6257 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
6258 V_VT(&result
) = VT_EMPTY
;
6260 if ((leftvt
| ExtraFlags
[i
]) == VT_BSTR
)
6261 V_BSTR(&left
) = true_str
;
6262 if ((rightvt
| ExtraFlags
[i
]) == VT_BSTR
)
6263 V_BSTR(&right
) = true_str
;
6265 /* Native VarAnd always returns an error when using extra
6266 * flags or if the variant combination is I8 and INT.
6268 if ((leftvt
== VT_I8
&& rightvt
== VT_INT
) ||
6269 (leftvt
== VT_INT
&& rightvt
== VT_I8
) ||
6273 /* Determine return type */
6274 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
6276 else if (leftvt
== VT_I4
|| rightvt
== VT_I4
||
6277 leftvt
== VT_UINT
|| rightvt
== VT_UINT
||
6278 leftvt
== VT_INT
|| rightvt
== VT_INT
||
6279 leftvt
== VT_R4
|| rightvt
== VT_R4
||
6280 leftvt
== VT_R8
|| rightvt
== VT_R8
||
6281 leftvt
== VT_CY
|| rightvt
== VT_CY
||
6282 leftvt
== VT_DATE
|| rightvt
== VT_DATE
||
6283 leftvt
== VT_I1
|| rightvt
== VT_I1
||
6284 leftvt
== VT_UI2
|| rightvt
== VT_UI2
||
6285 leftvt
== VT_UI4
|| rightvt
== VT_UI4
||
6286 leftvt
== VT_UI8
|| rightvt
== VT_UI8
||
6287 leftvt
== VT_DECIMAL
|| rightvt
== VT_DECIMAL
)
6289 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
||
6290 leftvt
== VT_I2
|| rightvt
== VT_I2
||
6291 leftvt
== VT_EMPTY
|| rightvt
== VT_EMPTY
)
6292 if ((leftvt
== VT_NULL
&& rightvt
== VT_UI1
) ||
6293 (leftvt
== VT_UI1
&& rightvt
== VT_NULL
) ||
6294 (leftvt
== VT_UI1
&& rightvt
== VT_UI1
))
6298 else if (leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
||
6299 (leftvt
== VT_BSTR
&& rightvt
== VT_BSTR
))
6301 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
||
6302 leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
)
6307 hres
= pVarAnd(&left
, &right
, &result
);
6309 /* Check expected HRESULT and if result variant type is correct */
6311 ok (hres
== DISP_E_BADVARTYPE
|| hres
== DISP_E_TYPEMISMATCH
,
6312 "VarAnd: %s|0x%X, %s|0x%X: got vt %s hr 0x%X\n",
6313 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
],
6314 vtstr(V_VT(&result
)), hres
);
6316 ok (hres
== S_OK
&& resvt
== V_VT(&result
),
6317 "VarAnd: %s|0x%X, %s|0x%X: expected vt %s hr 0x%X, got vt %s hr 0x%X\n",
6318 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
], vtstr(resvt
),
6319 S_OK
, vtstr(V_VT(&result
)), hres
);
6325 * Test returned values. Since we know the returned type is correct
6326 * and that we handle all combinations of invalid types, just check
6327 * that good type combinations produce the desired value.
6328 * FIXME: Test VT_DECIMAL
6330 VARAND(EMPTY
,0,EMPTY
,0,I2
,0);
6331 VARAND(EMPTY
,1,EMPTY
,0,I2
,0);
6332 VARAND(EMPTY
,1,EMPTY
,1,I2
,0);
6333 VARAND(EMPTY
,0,NULL
,0,I2
,0);
6334 VARAND(EMPTY
,1,NULL
,0,I2
,0);
6335 VARAND(EMPTY
,1,NULL
,1,I2
,0);
6336 VARAND(EMPTY
,0,I1
,0,I4
,0);
6337 VARAND(EMPTY
,0,I1
,1,I4
,0);
6338 VARAND(EMPTY
,1,I1
,1,I4
,0);
6339 VARAND(EMPTY
,0,UI1
,0,I2
,0);
6340 VARAND(EMPTY
,0,UI1
,1,I2
,0);
6341 VARAND(EMPTY
,1,UI1
,1,I2
,0);
6342 VARAND(EMPTY
,0,I2
,0,I2
,0);
6343 VARAND(EMPTY
,0,I2
,1,I2
,0);
6344 VARAND(EMPTY
,1,I2
,1,I2
,0);
6345 VARAND(EMPTY
,0,UI2
,0,I4
,0);
6346 VARAND(EMPTY
,0,UI2
,1,I4
,0);
6347 VARAND(EMPTY
,1,UI2
,1,I4
,0);
6348 VARAND(EMPTY
,0,I4
,0,I4
,0);
6349 VARAND(EMPTY
,0,I4
,1,I4
,0);
6350 VARAND(EMPTY
,1,I4
,1,I4
,0);
6351 VARAND(EMPTY
,0,UI4
,0,I4
,0);
6352 VARAND(EMPTY
,0,UI4
,1,I4
,0);
6353 VARAND(EMPTY
,1,UI4
,1,I4
,0);
6356 VARAND(EMPTY
,0,I8
,0,I8
,0);
6357 VARAND(EMPTY
,0,I8
,1,I8
,0);
6358 VARAND(EMPTY
,1,I8
,1,I8
,0);
6359 VARAND(EMPTY
,0,UI8
,0,I4
,0);
6360 VARAND(EMPTY
,0,UI8
,1,I4
,0);
6361 VARAND(EMPTY
,1,UI8
,1,I4
,0);
6363 VARAND(EMPTY
,0,INT
,0,I4
,0);
6364 VARAND(EMPTY
,0,INT
,1,I4
,0);
6365 VARAND(EMPTY
,1,INT
,1,I4
,0);
6366 VARAND(EMPTY
,0,UINT
,0,I4
,0);
6367 VARAND(EMPTY
,0,UINT
,1,I4
,0);
6368 VARAND(EMPTY
,1,UINT
,1,I4
,0);
6369 VARAND(EMPTY
,0,BOOL
,0,I2
,0);
6370 VARAND(EMPTY
,0,BOOL
,1,I2
,0);
6371 VARAND(EMPTY
,1,BOOL
,1,I2
,0);
6372 VARAND(EMPTY
,0,R4
,0,I4
,0);
6373 VARAND(EMPTY
,0,R4
,1,I4
,0);
6374 VARAND(EMPTY
,1,R4
,1,I4
,0);
6375 VARAND(EMPTY
,0,R8
,0,I4
,0);
6376 VARAND(EMPTY
,0,R8
,1,I4
,0);
6377 VARAND(EMPTY
,1,R8
,1,I4
,0);
6378 VARAND(EMPTY
,0,BSTR
,false_str
,I2
,0);
6379 VARAND(EMPTY
,0,BSTR
,true_str
,I2
,0);
6380 VARANDCY(EMPTY
,0,10000,I4
,0);
6382 /* NULL OR 0 = NULL. NULL OR n = n */
6383 VARAND(NULL
,0,NULL
,0,NULL
,0);
6384 VARAND(NULL
,1,NULL
,0,NULL
,0);
6385 VARAND(NULL
,0,I1
,0,I4
,0);
6386 VARAND(NULL
,0,I1
,1,NULL
,0);
6387 VARAND(NULL
,0,UI1
,0,UI1
,0);
6388 VARAND(NULL
,0,UI1
,1,NULL
,0);
6389 VARAND(NULL
,0,I2
,0,I2
,0);
6390 VARAND(NULL
,0,I2
,1,NULL
,0);
6391 VARAND(NULL
,0,UI2
,0,I4
,0);
6392 VARAND(NULL
,0,UI2
,1,NULL
,0);
6393 VARAND(NULL
,0,I4
,0,I4
,0);
6394 VARAND(NULL
,0,I4
,1,NULL
,0);
6395 VARAND(NULL
,0,UI4
,0,I4
,0);
6396 VARAND(NULL
,0,UI4
,1,NULL
,0);
6399 VARAND(NULL
,0,I8
,0,I8
,0);
6400 VARAND(NULL
,0,I8
,1,NULL
,0);
6401 VARAND(NULL
,0,UI8
,0,I4
,0);
6402 VARAND(NULL
,0,UI8
,1,NULL
,0);
6404 VARAND(NULL
,0,INT
,0,I4
,0);
6405 VARAND(NULL
,0,INT
,1,NULL
,0);
6406 VARAND(NULL
,0,UINT
,0,I4
,0);
6407 VARAND(NULL
,0,UINT
,1,NULL
,0);
6408 VARAND(NULL
,0,BOOL
,0,BOOL
,0);
6409 VARAND(NULL
,0,BOOL
,1,NULL
,0);
6410 VARAND(NULL
,0,R4
,0,I4
,0);
6411 VARAND(NULL
,0,R4
,1,NULL
,0);
6412 VARAND(NULL
,0,R8
,0,I4
,0);
6413 VARAND(NULL
,0,R8
,1,NULL
,0);
6414 VARAND(NULL
,0,BSTR
,false_str
,BOOL
,0);
6415 VARAND(NULL
,0,BSTR
,true_str
,NULL
,VARIANT_FALSE
);
6416 VARANDCY(NULL
,0,10000,NULL
,0);
6417 VARANDCY(NULL
,0,0,I4
,0);
6418 VARAND(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
);
6419 VARAND(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_FALSE
);
6420 VARAND(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
);
6421 VARAND(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_FALSE
);
6423 /* Assume x,y & y,x are the same from now on to reduce the number of tests */
6424 VARAND(BOOL
,VARIANT_TRUE
,I1
,-1,I4
,-1);
6425 VARAND(BOOL
,VARIANT_TRUE
,I1
,0,I4
,0);
6426 VARAND(BOOL
,VARIANT_FALSE
,I1
,0,I4
,0);
6427 VARAND(BOOL
,VARIANT_TRUE
,UI1
,255,I2
,255);
6428 VARAND(BOOL
,VARIANT_TRUE
,UI1
,0,I2
,0);
6429 VARAND(BOOL
,VARIANT_FALSE
,UI1
,0,I2
,0);
6430 VARAND(BOOL
,VARIANT_TRUE
,I2
,-1,I2
,-1);
6431 VARAND(BOOL
,VARIANT_TRUE
,I2
,0,I2
,0);
6432 VARAND(BOOL
,VARIANT_FALSE
,I2
,0,I2
,0);
6433 VARAND(BOOL
,VARIANT_TRUE
,UI2
,65535,I4
,65535);
6434 VARAND(BOOL
,VARIANT_TRUE
,UI2
,0,I4
,0);
6435 VARAND(BOOL
,VARIANT_FALSE
,UI2
,0,I4
,0);
6436 VARAND(BOOL
,VARIANT_TRUE
,I4
,-1,I4
,-1);
6437 VARAND(BOOL
,VARIANT_TRUE
,I4
,0,I4
,0);
6438 VARAND(BOOL
,VARIANT_FALSE
,I4
,0,I4
,0);
6439 VARAND(BOOL
,VARIANT_TRUE
,UI4
,0xffffffff,I4
,-1);
6440 VARAND(BOOL
,VARIANT_TRUE
,UI4
,0,I4
,0);
6441 VARAND(BOOL
,VARIANT_FALSE
,UI4
,0,I4
,0);
6442 VARAND(BOOL
,VARIANT_TRUE
,R4
,-1,I4
,-1);
6443 VARAND(BOOL
,VARIANT_TRUE
,R4
,0,I4
,0);
6444 VARAND(BOOL
,VARIANT_FALSE
,R4
,0,I4
,0);
6445 VARAND(BOOL
,VARIANT_TRUE
,R8
,-1,I4
,-1);
6446 VARAND(BOOL
,VARIANT_TRUE
,R8
,0,I4
,0);
6447 VARAND(BOOL
,VARIANT_FALSE
,R8
,0,I4
,0);
6448 VARAND(BOOL
,VARIANT_TRUE
,DATE
,-1,I4
,-1);
6449 VARAND(BOOL
,VARIANT_TRUE
,DATE
,0,I4
,0);
6450 VARAND(BOOL
,VARIANT_FALSE
,DATE
,0,I4
,0);
6453 VARAND(BOOL
,VARIANT_TRUE
,I8
,-1,I8
,-1);
6454 VARAND(BOOL
,VARIANT_TRUE
,I8
,0,I8
,0);
6455 VARAND(BOOL
,VARIANT_FALSE
,I8
,0,I8
,0);
6456 VARAND(BOOL
,VARIANT_TRUE
,UI8
,0,I4
,0);
6457 VARAND(BOOL
,VARIANT_FALSE
,UI8
,0,I4
,0);
6459 VARAND(BOOL
,VARIANT_TRUE
,INT
,-1,I4
,-1);
6460 VARAND(BOOL
,VARIANT_TRUE
,INT
,0,I4
,0);
6461 VARAND(BOOL
,VARIANT_FALSE
,INT
,0,I4
,0);
6462 VARAND(BOOL
,VARIANT_TRUE
,UINT
,0xffffffff,I4
,-1);
6463 VARAND(BOOL
,VARIANT_TRUE
,UINT
,0,I4
,0);
6464 VARAND(BOOL
,VARIANT_FALSE
,UINT
,0,I4
,0);
6465 VARAND(BOOL
,VARIANT_FALSE
,BSTR
,false_str
,BOOL
,VARIANT_FALSE
);
6466 VARAND(BOOL
,VARIANT_TRUE
,BSTR
,false_str
,BOOL
,VARIANT_FALSE
);
6467 VARAND(BOOL
,VARIANT_FALSE
,BSTR
,true_str
,BOOL
,VARIANT_FALSE
);
6468 VARAND(BOOL
,VARIANT_TRUE
,BSTR
,true_str
,BOOL
,VARIANT_TRUE
);
6469 VARANDCY(BOOL
,VARIANT_TRUE
,10000,I4
,1);
6470 VARANDCY(BOOL
,VARIANT_TRUE
,0,I4
,0);
6471 VARANDCY(BOOL
,VARIANT_FALSE
,0,I4
,0);
6472 VARAND(I1
,-1,I1
,-1,I4
,-1);
6473 VARAND(I1
,-1,I1
,0,I4
,0);
6474 VARAND(I1
,0,I1
,0,I4
,0);
6475 VARAND(I1
,-1,UI1
,255,I4
,255);
6476 VARAND(I1
,-1,UI1
,0,I4
,0);
6477 VARAND(I1
,0,UI1
,0,I4
,0);
6478 VARAND(I1
,-1,I2
,-1,I4
,-1);
6479 VARAND(I1
,-1,I2
,0,I4
,0);
6480 VARAND(I1
,0,I2
,0,I4
,0);
6481 VARAND(I1
,-1,UI2
,65535,I4
,65535);
6482 VARAND(I1
,-1,UI2
,0,I4
,0);
6483 VARAND(I1
,0,UI2
,0,I4
,0);
6484 VARAND(I1
,-1,I4
,-1,I4
,-1);
6485 VARAND(I1
,-1,I4
,0,I4
,0);
6486 VARAND(I1
,0,I4
,0,I4
,0);
6487 VARAND(I1
,-1,UI4
,0xffffffff,I4
,-1);
6488 VARAND(I1
,-1,UI4
,0,I4
,0);
6489 VARAND(I1
,0,UI4
,0,I4
,0);
6490 VARAND(I1
,-1,R4
,-1,I4
,-1);
6491 VARAND(I1
,-1,R4
,0,I4
,0);
6492 VARAND(I1
,0,R4
,0,I4
,0);
6493 VARAND(I1
,-1,R8
,-1,I4
,-1);
6494 VARAND(I1
,-1,R8
,0,I4
,0);
6495 VARAND(I1
,0,R8
,0,I4
,0);
6496 VARAND(I1
,-1,DATE
,-1,I4
,-1);
6497 VARAND(I1
,-1,DATE
,0,I4
,0);
6498 VARAND(I1
,0,DATE
,0,I4
,0);
6501 VARAND(I1
,-1,I8
,-1,I8
,-1);
6502 VARAND(I1
,-1,I8
,0,I8
,0);
6503 VARAND(I1
,0,I8
,0,I8
,0);
6504 VARAND(I1
,-1,UI8
,0,I4
,0);
6505 VARAND(I1
,0,UI8
,0,I4
,0);
6507 VARAND(I1
,-1,INT
,-1,I4
,-1);
6508 VARAND(I1
,-1,INT
,0,I4
,0);
6509 VARAND(I1
,0,INT
,0,I4
,0);
6510 VARAND(I1
,-1,UINT
,0xffffffff,I4
,-1);
6511 VARAND(I1
,-1,UINT
,0,I4
,0);
6512 VARAND(I1
,0,UINT
,0,I4
,0);
6513 VARAND(I1
,0,BSTR
,false_str
,I4
,0);
6514 VARAND(I1
,-1,BSTR
,false_str
,I4
,0);
6515 VARAND(I1
,0,BSTR
,true_str
,I4
,0);
6516 VARAND(I1
,-1,BSTR
,true_str
,I4
,-1);
6517 VARANDCY(I1
,-1,10000,I4
,1);
6518 VARANDCY(I1
,-1,0,I4
,0);
6519 VARANDCY(I1
,0,0,I4
,0);
6521 VARAND(UI1
,255,UI1
,255,UI1
,255);
6522 VARAND(UI1
,255,UI1
,0,UI1
,0);
6523 VARAND(UI1
,0,UI1
,0,UI1
,0);
6524 VARAND(UI1
,255,I2
,-1,I2
,255);
6525 VARAND(UI1
,255,I2
,0,I2
,0);
6526 VARAND(UI1
,0,I2
,0,I2
,0);
6527 VARAND(UI1
,255,UI2
,65535,I4
,255);
6528 VARAND(UI1
,255,UI2
,0,I4
,0);
6529 VARAND(UI1
,0,UI2
,0,I4
,0);
6530 VARAND(UI1
,255,I4
,-1,I4
,255);
6531 VARAND(UI1
,255,I4
,0,I4
,0);
6532 VARAND(UI1
,0,I4
,0,I4
,0);
6533 VARAND(UI1
,255,UI4
,0xffffffff,I4
,255);
6534 VARAND(UI1
,255,UI4
,0,I4
,0);
6535 VARAND(UI1
,0,UI4
,0,I4
,0);
6536 VARAND(UI1
,255,R4
,-1,I4
,255);
6537 VARAND(UI1
,255,R4
,0,I4
,0);
6538 VARAND(UI1
,0,R4
,0,I4
,0);
6539 VARAND(UI1
,255,R8
,-1,I4
,255);
6540 VARAND(UI1
,255,R8
,0,I4
,0);
6541 VARAND(UI1
,0,R8
,0,I4
,0);
6542 VARAND(UI1
,255,DATE
,-1,I4
,255);
6543 VARAND(UI1
,255,DATE
,0,I4
,0);
6544 VARAND(UI1
,0,DATE
,0,I4
,0);
6547 VARAND(UI1
,255,I8
,-1,I8
,255);
6548 VARAND(UI1
,255,I8
,0,I8
,0);
6549 VARAND(UI1
,0,I8
,0,I8
,0);
6550 VARAND(UI1
,255,UI8
,0,I4
,0);
6551 VARAND(UI1
,0,UI8
,0,I4
,0);
6553 VARAND(UI1
,255,INT
,-1,I4
,255);
6554 VARAND(UI1
,255,INT
,0,I4
,0);
6555 VARAND(UI1
,0,INT
,0,I4
,0);
6556 VARAND(UI1
,255,UINT
,0xffffffff,I4
,255);
6557 VARAND(UI1
,255,UINT
,0,I4
,0);
6558 VARAND(UI1
,0,UINT
,0,I4
,0);
6559 VARAND(UI1
,0,BSTR
,false_str
,I2
,0);
6560 VARAND(UI1
,255,BSTR
,false_str
,I2
,0);
6561 VARAND(UI1
,0,BSTR
,true_str
,I2
,0);
6562 VARAND(UI1
,255,BSTR
,true_str
,I2
,255);
6563 VARANDCY(UI1
,255,10000,I4
,1);
6564 VARANDCY(UI1
,255,0,I4
,0);
6565 VARANDCY(UI1
,0,0,I4
,0);
6567 VARAND(I2
,-1,I2
,-1,I2
,-1);
6568 VARAND(I2
,-1,I2
,0,I2
,0);
6569 VARAND(I2
,0,I2
,0,I2
,0);
6570 VARAND(I2
,-1,UI2
,65535,I4
,65535);
6571 VARAND(I2
,-1,UI2
,0,I4
,0);
6572 VARAND(I2
,0,UI2
,0,I4
,0);
6573 VARAND(I2
,-1,I4
,-1,I4
,-1);
6574 VARAND(I2
,-1,I4
,0,I4
,0);
6575 VARAND(I2
,0,I4
,0,I4
,0);
6576 VARAND(I2
,-1,UI4
,0xffffffff,I4
,-1);
6577 VARAND(I2
,-1,UI4
,0,I4
,0);
6578 VARAND(I2
,0,UI4
,0,I4
,0);
6579 VARAND(I2
,-1,R4
,-1,I4
,-1);
6580 VARAND(I2
,-1,R4
,0,I4
,0);
6581 VARAND(I2
,0,R4
,0,I4
,0);
6582 VARAND(I2
,-1,R8
,-1,I4
,-1);
6583 VARAND(I2
,-1,R8
,0,I4
,0);
6584 VARAND(I2
,0,R8
,0,I4
,0);
6585 VARAND(I2
,-1,DATE
,-1,I4
,-1);
6586 VARAND(I2
,-1,DATE
,0,I4
,0);
6587 VARAND(I2
,0,DATE
,0,I4
,0);
6590 VARAND(I2
,-1,I8
,-1,I8
,-1);
6591 VARAND(I2
,-1,I8
,0,I8
,0);
6592 VARAND(I2
,0,I8
,0,I8
,0);
6593 VARAND(I2
,-1,UI8
,0,I4
,0);
6594 VARAND(I2
,0,UI8
,0,I4
,0);
6596 VARAND(I2
,-1,INT
,-1,I4
,-1);
6597 VARAND(I2
,-1,INT
,0,I4
,0);
6598 VARAND(I2
,0,INT
,0,I4
,0);
6599 VARAND(I2
,-1,UINT
,0xffffffff,I4
,-1);
6600 VARAND(I2
,-1,UINT
,0,I4
,0);
6601 VARAND(I2
,0,UINT
,0,I4
,0);
6602 VARAND(I2
,0,BSTR
,false_str
,I2
,0);
6603 VARAND(I2
,-1,BSTR
,false_str
,I2
,0);
6604 VARAND(I2
,0,BSTR
,true_str
,I2
,0);
6605 VARAND(I2
,-1,BSTR
,true_str
,I2
,-1);
6606 VARANDCY(I2
,-1,10000,I4
,1);
6607 VARANDCY(I2
,-1,0,I4
,0);
6608 VARANDCY(I2
,0,0,I4
,0);
6610 VARAND(UI2
,65535,UI2
,65535,I4
,65535);
6611 VARAND(UI2
,65535,UI2
,0,I4
,0);
6612 VARAND(UI2
,0,UI2
,0,I4
,0);
6613 VARAND(UI2
,65535,I4
,-1,I4
,65535);
6614 VARAND(UI2
,65535,I4
,0,I4
,0);
6615 VARAND(UI2
,0,I4
,0,I4
,0);
6616 VARAND(UI2
,65535,UI4
,0xffffffff,I4
,65535);
6617 VARAND(UI2
,65535,UI4
,0,I4
,0);
6618 VARAND(UI2
,0,UI4
,0,I4
,0);
6619 VARAND(UI2
,65535,R4
,-1,I4
,65535);
6620 VARAND(UI2
,65535,R4
,0,I4
,0);
6621 VARAND(UI2
,0,R4
,0,I4
,0);
6622 VARAND(UI2
,65535,R8
,-1,I4
,65535);
6623 VARAND(UI2
,65535,R8
,0,I4
,0);
6624 VARAND(UI2
,0,R8
,0,I4
,0);
6625 VARAND(UI2
,65535,DATE
,-1,I4
,65535);
6626 VARAND(UI2
,65535,DATE
,0,I4
,0);
6627 VARAND(UI2
,0,DATE
,0,I4
,0);
6630 VARAND(UI2
,65535,I8
,-1,I8
,65535);
6631 VARAND(UI2
,65535,I8
,0,I8
,0);
6632 VARAND(UI2
,0,I8
,0,I8
,0);
6633 VARAND(UI2
,65535,UI8
,0,I4
,0);
6634 VARAND(UI2
,0,UI8
,0,I4
,0);
6636 VARAND(UI2
,65535,INT
,-1,I4
,65535);
6637 VARAND(UI2
,65535,INT
,0,I4
,0);
6638 VARAND(UI2
,0,INT
,0,I4
,0);
6639 VARAND(UI2
,65535,UINT
,0xffffffff,I4
,65535);
6640 VARAND(UI2
,65535,UINT
,0,I4
,0);
6641 VARAND(UI2
,0,UINT
,0,I4
,0);
6642 VARAND(UI2
,0,BSTR
,false_str
,I4
,0);
6643 VARAND(UI2
,65535,BSTR
,false_str
,I4
,0);
6644 VARAND(UI2
,0,BSTR
,true_str
,I4
,0);
6645 VARAND(UI2
,65535,BSTR
,true_str
,I4
,65535);
6646 VARANDCY(UI2
,65535,10000,I4
,1);
6647 VARANDCY(UI2
,65535,0,I4
,0);
6648 VARANDCY(UI2
,0,0,I4
,0);
6650 VARAND(I4
,-1,I4
,-1,I4
,-1);
6651 VARAND(I4
,-1,I4
,0,I4
,0);
6652 VARAND(I4
,0,I4
,0,I4
,0);
6653 VARAND(I4
,-1,UI4
,0xffffffff,I4
,-1);
6654 VARAND(I4
,-1,UI4
,0,I4
,0);
6655 VARAND(I4
,0,UI4
,0,I4
,0);
6656 VARAND(I4
,-1,R4
,-1,I4
,-1);
6657 VARAND(I4
,-1,R4
,0,I4
,0);
6658 VARAND(I4
,0,R4
,0,I4
,0);
6659 VARAND(I4
,-1,R8
,-1,I4
,-1);
6660 VARAND(I4
,-1,R8
,0,I4
,0);
6661 VARAND(I4
,0,R8
,0,I4
,0);
6662 VARAND(I4
,-1,DATE
,-1,I4
,-1);
6663 VARAND(I4
,-1,DATE
,0,I4
,0);
6664 VARAND(I4
,0,DATE
,0,I4
,0);
6667 VARAND(I4
,-1,I8
,-1,I8
,-1);
6668 VARAND(I4
,-1,I8
,0,I8
,0);
6669 VARAND(I4
,0,I8
,0,I8
,0);
6670 VARAND(I4
,-1,UI8
,0,I4
,0);
6671 VARAND(I4
,0,UI8
,0,I4
,0);
6673 VARAND(I4
,-1,INT
,-1,I4
,-1);
6674 VARAND(I4
,-1,INT
,0,I4
,0);
6675 VARAND(I4
,0,INT
,0,I4
,0);
6676 VARAND(I4
,-1,UINT
,0xffffffff,I4
,-1);
6677 VARAND(I4
,-1,UINT
,0,I4
,0);
6678 VARAND(I4
,0,UINT
,0,I4
,0);
6679 VARAND(I4
,0,BSTR
,false_str
,I4
,0);
6680 VARAND(I4
,-1,BSTR
,false_str
,I4
,0);
6681 VARAND(I4
,0,BSTR
,true_str
,I4
,0);
6682 VARAND(I4
,-1,BSTR
,true_str
,I4
,-1);
6683 VARANDCY(I4
,-1,10000,I4
,1);
6684 VARANDCY(I4
,-1,0,I4
,0);
6685 VARANDCY(I4
,0,0,I4
,0);
6687 VARAND(UI4
,0xffffffff,UI4
,0xffffffff,I4
,-1);
6688 VARAND(UI4
,0xffffffff,UI4
,0,I4
,0);
6689 VARAND(UI4
,0,UI4
,0,I4
,0);
6690 VARAND(UI4
,0xffffffff,R4
,-1,I4
,-1);
6691 VARAND(UI4
,0xffffffff,R4
,0,I4
,0);
6692 VARAND(UI4
,0,R4
,0,I4
,0);
6693 VARAND(UI4
,0xffffffff,R8
,-1,I4
,-1);
6694 VARAND(UI4
,0xffffffff,R8
,0,I4
,0);
6695 VARAND(UI4
,0,R8
,0,I4
,0);
6696 VARAND(UI4
,0xffffffff,DATE
,-1,I4
,-1);
6697 VARAND(UI4
,0xffffffff,DATE
,0,I4
,0);
6698 VARAND(UI4
,0,DATE
,0,I4
,0);
6701 VARAND(UI4
,0xffffffff,I8
,0,I8
,0);
6702 VARAND(UI4
,0,I8
,0,I8
,0);
6703 VARAND(UI4
,0xffffffff,UI8
,0,I4
,0);
6704 VARAND(UI4
,0,UI8
,0,I4
,0);
6706 VARAND(UI4
,0xffffffff,INT
,-1,I4
,-1);
6707 VARAND(UI4
,0xffffffff,INT
,0,I4
,0);
6708 VARAND(UI4
,0,INT
,0,I4
,0);
6709 VARAND(UI4
,0xffffffff,UINT
,0xffffffff,I4
,-1);
6710 VARAND(UI4
,0xffffffff,UINT
,0,I4
,0);
6711 VARAND(UI4
,0,UINT
,0,I4
,0);
6712 VARAND(UI4
,0,BSTR
,false_str
,I4
,0);
6713 VARAND(UI4
,0xffffffff,BSTR
,false_str
,I4
,0);
6714 VARAND(UI4
,0,BSTR
,true_str
,I4
,0);
6715 VARAND(UI4
,0xffffffff,BSTR
,true_str
,I4
,-1);
6716 VARANDCY(UI4
,0xffffffff,10000,I4
,1);
6717 VARANDCY(UI4
,0xffffffff,0,I4
,0);
6718 VARANDCY(UI4
,0,0,I4
,0);
6720 VARAND(R4
,-1,R4
,-1,I4
,-1);
6721 VARAND(R4
,-1,R4
,0,I4
,0);
6722 VARAND(R4
,0,R4
,0,I4
,0);
6723 VARAND(R4
,-1,R8
,-1,I4
,-1);
6724 VARAND(R4
,-1,R8
,0,I4
,0);
6725 VARAND(R4
,0,R8
,0,I4
,0);
6726 VARAND(R4
,-1,DATE
,-1,I4
,-1);
6727 VARAND(R4
,-1,DATE
,0,I4
,0);
6728 VARAND(R4
,0,DATE
,0,I4
,0);
6731 VARAND(R4
,-1,I8
,-1,I8
,-1);
6732 VARAND(R4
,-1,I8
,0,I8
,0);
6733 VARAND(R4
,0,I8
,0,I8
,0);
6734 VARAND(R4
,-1,UI8
,0,I4
,0);
6735 VARAND(R4
,0,UI8
,0,I4
,0);
6737 VARAND(R4
,-1,INT
,-1,I4
,-1);
6738 VARAND(R4
,-1,INT
,0,I4
,0);
6739 VARAND(R4
,0,INT
,0,I4
,0);
6740 VARAND(R4
,-1,UINT
,0xffffffff,I4
,-1);
6741 VARAND(R4
,-1,UINT
,0,I4
,0);
6742 VARAND(R4
,0,UINT
,0,I4
,0);
6743 VARAND(R4
,0,BSTR
,false_str
,I4
,0);
6744 VARAND(R4
,-1,BSTR
,false_str
,I4
,0);
6745 VARAND(R4
,0,BSTR
,true_str
,I4
,0);
6746 VARAND(R4
,-1,BSTR
,true_str
,I4
,-1);
6747 VARANDCY(R4
,-1,10000,I4
,1);
6748 VARANDCY(R4
,-1,0,I4
,0);
6749 VARANDCY(R4
,0,0,I4
,0);
6751 VARAND(R8
,-1,R8
,-1,I4
,-1);
6752 VARAND(R8
,-1,R8
,0,I4
,0);
6753 VARAND(R8
,0,R8
,0,I4
,0);
6754 VARAND(R8
,-1,DATE
,-1,I4
,-1);
6755 VARAND(R8
,-1,DATE
,0,I4
,0);
6756 VARAND(R8
,0,DATE
,0,I4
,0);
6759 VARAND(R8
,-1,I8
,-1,I8
,-1);
6760 VARAND(R8
,-1,I8
,0,I8
,0);
6761 VARAND(R8
,0,I8
,0,I8
,0);
6762 VARAND(R8
,-1,UI8
,0,I4
,0);
6763 VARAND(R8
,0,UI8
,0,I4
,0);
6765 VARAND(R8
,-1,INT
,-1,I4
,-1);
6766 VARAND(R8
,-1,INT
,0,I4
,0);
6767 VARAND(R8
,0,INT
,0,I4
,0);
6768 VARAND(R8
,-1,UINT
,0xffffffff,I4
,-1);
6769 VARAND(R8
,-1,UINT
,0,I4
,0);
6770 VARAND(R8
,0,UINT
,0,I4
,0);
6771 VARAND(R8
,0,BSTR
,false_str
,I4
,0);
6772 VARAND(R8
,-1,BSTR
,false_str
,I4
,0);
6773 VARAND(R8
,0,BSTR
,true_str
,I4
,0);
6774 VARAND(R8
,-1,BSTR
,true_str
,I4
,-1);
6775 VARANDCY(R8
,-1,10000,I4
,1);
6776 VARANDCY(R8
,-1,0,I4
,0);
6777 VARANDCY(R8
,0,0,I4
,0);
6779 VARAND(DATE
,-1,DATE
,-1,I4
,-1);
6780 VARAND(DATE
,-1,DATE
,0,I4
,0);
6781 VARAND(DATE
,0,DATE
,0,I4
,0);
6784 VARAND(DATE
,-1,I8
,-1,I8
,-1);
6785 VARAND(DATE
,-1,I8
,0,I8
,0);
6786 VARAND(DATE
,0,I8
,0,I8
,0);
6787 VARAND(DATE
,-1,UI8
,0,I4
,0);
6788 VARAND(DATE
,0,UI8
,0,I4
,0);
6790 VARAND(DATE
,-1,INT
,-1,I4
,-1);
6791 VARAND(DATE
,-1,INT
,0,I4
,0);
6792 VARAND(DATE
,0,INT
,0,I4
,0);
6793 VARAND(DATE
,-1,UINT
,0xffffffff,I4
,-1);
6794 VARAND(DATE
,-1,UINT
,0,I4
,0);
6795 VARAND(DATE
,0,UINT
,0,I4
,0);
6796 VARAND(DATE
,0,BSTR
,false_str
,I4
,0);
6797 VARAND(DATE
,-1,BSTR
,false_str
,I4
,0);
6798 VARAND(DATE
,0,BSTR
,true_str
,I4
,0);
6799 VARAND(DATE
,-1,BSTR
,true_str
,I4
,-1);
6800 VARANDCY(DATE
,-1,10000,I4
,1);
6801 VARANDCY(DATE
,-1,0,I4
,0);
6802 VARANDCY(DATE
,0,0,I4
,0);
6806 VARAND(I8
,-1,I8
,-1,I8
,-1);
6807 VARAND(I8
,-1,I8
,0,I8
,0);
6808 VARAND(I8
,0,I8
,0,I8
,0);
6809 VARAND(I8
,-1,UI8
,0,I8
,0);
6810 VARAND(I8
,0,UI8
,0,I8
,0);
6811 VARAND(I8
,-1,UINT
,0,I8
,0);
6812 VARAND(I8
,0,UINT
,0,I8
,0);
6813 VARAND(I8
,0,BSTR
,false_str
,I8
,0);
6814 VARAND(I8
,-1,BSTR
,false_str
,I8
,0);
6815 VARAND(I8
,0,BSTR
,true_str
,I8
,0);
6816 VARAND(I8
,-1,BSTR
,true_str
,I8
,-1);
6817 VARANDCY(I8
,-1,10000,I8
,1);
6818 VARANDCY(I8
,-1,0,I8
,0);
6819 VARANDCY(I8
,0,0,I8
,0);
6821 VARAND(UI8
,0xffff,UI8
,0xffff,I4
,0xffff);
6822 VARAND(UI8
,0xffff,UI8
,0,I4
,0);
6823 VARAND(UI8
,0,UI8
,0,I4
,0);
6824 VARAND(UI8
,0xffff,INT
,-1,I4
,65535);
6825 VARAND(UI8
,0xffff,INT
,0,I4
,0);
6826 VARAND(UI8
,0,INT
,0,I4
,0);
6827 VARAND(UI8
,0xffff,UINT
,0xffff,I4
,0xffff);
6828 VARAND(UI8
,0xffff,UINT
,0,I4
,0);
6829 VARAND(UI8
,0,UINT
,0,I4
,0);
6830 VARAND(UI8
,0,BSTR
,false_str
,I4
,0);
6831 VARAND(UI8
,0xffff,BSTR
,false_str
,I4
,0);
6832 VARAND(UI8
,0,BSTR
,true_str
,I4
,0);
6833 VARAND(UI8
,0xffff,BSTR
,true_str
,I4
,65535);
6834 VARANDCY(UI8
,0xffff,10000,I4
,1);
6835 VARANDCY(UI8
,0xffff,0,I4
,0);
6836 VARANDCY(UI8
,0,0,I4
,0);
6839 VARAND(INT
,-1,INT
,-1,I4
,-1);
6840 VARAND(INT
,-1,INT
,0,I4
,0);
6841 VARAND(INT
,0,INT
,0,I4
,0);
6842 VARAND(INT
,-1,UINT
,0xffff,I4
,65535);
6843 VARAND(INT
,-1,UINT
,0,I4
,0);
6844 VARAND(INT
,0,UINT
,0,I4
,0);
6845 VARAND(INT
,0,BSTR
,false_str
,I4
,0);
6846 VARAND(INT
,-1,BSTR
,false_str
,I4
,0);
6847 VARAND(INT
,0,BSTR
,true_str
,I4
,0);
6848 VARAND(INT
,-1,BSTR
,true_str
,I4
,-1);
6849 VARANDCY(INT
,-1,10000,I4
,1);
6850 VARANDCY(INT
,-1,0,I4
,0);
6851 VARANDCY(INT
,0,0,I4
,0);
6853 VARAND(UINT
,0xffff,UINT
,0xffff,I4
,0xffff);
6854 VARAND(UINT
,0xffff,UINT
,0,I4
,0);
6855 VARAND(UINT
,0,UINT
,0,I4
,0);
6856 VARAND(UINT
,0,BSTR
,false_str
,I4
,0);
6857 VARAND(UINT
,0xffff,BSTR
, false_str
,I4
,0);
6858 VARAND(UINT
,0,BSTR
,true_str
,I4
,0);
6859 VARAND(UINT
,0xffff,BSTR
,true_str
,I4
,65535);
6860 VARANDCY(UINT
,0xffff,10000,I4
,1);
6861 VARANDCY(UINT
,0xffff,0,I4
,0);
6862 VARANDCY(UINT
,0,0,I4
,0);
6864 VARAND(BSTR
,false_str
,BSTR
,false_str
,BOOL
,0);
6865 VARAND(BSTR
,true_str
,BSTR
,false_str
,BOOL
,VARIANT_FALSE
);
6866 VARAND(BSTR
,true_str
,BSTR
,true_str
,BOOL
,VARIANT_TRUE
);
6867 VARANDCY(BSTR
,true_str
,10000,I4
,1);
6868 VARANDCY(BSTR
,false_str
,10000,I4
,0);
6870 SysFreeString(true_str
);
6871 SysFreeString(false_str
);
6874 static void test_cmp( int line
, LCID lcid
, UINT flags
, VARIANT
*left
, VARIANT
*right
, HRESULT result
)
6880 hres
= pVarCmp(left
,right
,lcid
,flags
);
6881 ok_(__FILE__
,line
)(hres
== result
, "VarCmp(%s,%s): expected 0x%x, got hres=0x%x\n",
6882 variantstr(left
), variantstr(right
), result
, hres
);
6884 static void test_cmpex( int line
, LCID lcid
, VARIANT
*left
, VARIANT
*right
,
6885 HRESULT res1
, HRESULT res2
, HRESULT res3
, HRESULT res4
)
6887 test_cmp( line
, lcid
, 0, left
, right
, res1
);
6888 V_VT(left
) |= VT_RESERVED
;
6889 test_cmp( line
, lcid
, 0, left
, right
, res2
);
6890 V_VT(left
) &= ~VT_RESERVED
;
6891 V_VT(right
) |= VT_RESERVED
;
6892 test_cmp( line
, lcid
, 0, left
, right
, res3
);
6893 V_VT(left
) |= VT_RESERVED
;
6894 test_cmp( line
, lcid
, 0, left
, right
, res4
);
6895 ok_(__FILE__
,line
)(V_VT(left
) & V_VT(right
) & VT_RESERVED
, "VT_RESERVED filtered out\n");
6898 /* ERROR from wingdi.h is interfering here */
6900 #define _VARCMP(vt1,val1,vtfl1,vt2,val2,vtfl2,lcid,flags,result) \
6901 V_##vt1(&left) = val1; V_VT(&left) = VT_##vt1 | vtfl1; \
6902 V_##vt2(&right) = val2; V_VT(&right) = VT_##vt2 | vtfl2; \
6903 test_cmp( __LINE__, lcid, flags, &left, &right, result )
6904 #define VARCMPEX(vt1,val1,vt2,val2,res1,res2,res3,res4) \
6905 V_##vt1(&left) = val1; V_VT(&left) = VT_##vt1; \
6906 V_##vt2(&right) = val2; V_VT(&right) = VT_##vt2; \
6907 test_cmpex( __LINE__, lcid, &left, &right, res1, res2, res3, res4 )
6908 #define VARCMP(vt1,val1,vt2,val2,result) \
6909 VARCMPEX(vt1,val1,vt2,val2,result,result,result,result)
6910 /* The above macros do not work for VT_NULL as NULL gets expanded first */
6911 #define V_NULL_ V_NULL
6912 #define VT_NULL_ VT_NULL
6914 static void test_VarCmp(void)
6916 VARIANT left
, right
;
6921 static const WCHAR szhuh
[] = {'h','u','h','?','\0'};
6922 static const WCHAR sz2cents
[] = {'2','c','e','n','t','s','\0'};
6923 static const WCHAR szempty
[] = {'\0'};
6924 static const WCHAR sz0
[] = {'0','\0'};
6925 static const WCHAR sz1
[] = {'1','\0'};
6926 static const WCHAR sz7
[] = {'7','\0'};
6927 static const WCHAR sz42
[] = {'4','2','\0'};
6928 static const WCHAR sz1neg
[] = {'-','1','\0'};
6929 static const WCHAR sz666neg
[] = {'-','6','6','6','\0'};
6930 static const WCHAR sz1few
[] = {'1','.','0','0','0','0','0','0','0','1','\0'};
6931 BSTR bstrhuh
, bstrempty
, bstr0
, bstr1
, bstr7
, bstr42
, bstr1neg
, bstr666neg
;
6932 BSTR bstr2cents
, bstr1few
;
6936 lcid
= MAKELCID(MAKELANGID(LANG_ENGLISH
,SUBLANG_ENGLISH_US
),SORT_DEFAULT
);
6937 bstrempty
= SysAllocString(szempty
);
6938 bstrhuh
= SysAllocString(szhuh
);
6939 bstr2cents
= SysAllocString(sz2cents
);
6940 bstr0
= SysAllocString(sz0
);
6941 bstr1
= SysAllocString(sz1
);
6942 bstr7
= SysAllocString(sz7
);
6943 bstr42
= SysAllocString(sz42
);
6944 bstr1neg
= SysAllocString(sz1neg
);
6945 bstr666neg
= SysAllocString(sz666neg
);
6946 bstr1few
= SysAllocString(sz1few
);
6948 /* Test all possible flag/vt combinations & the resulting vt type */
6949 for (i
= 0; i
< ARRAY_SIZE(ExtraFlags
); i
++)
6951 VARTYPE leftvt
, rightvt
;
6953 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
6958 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
6961 HRESULT expect
= VARCMP_EQ
;
6965 memset(&left
, 0, sizeof(left
));
6966 memset(&right
, 0, sizeof(right
));
6967 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
6968 if (leftvt
== VT_BSTR
) {
6969 V_BSTR(&left
) = bstr1neg
;
6970 if (ExtraFlags
[i
] & VT_RESERVED
)
6975 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
6976 if (rightvt
== VT_BSTR
) {
6977 V_BSTR(&right
) = bstr1neg
;
6978 if (ExtraFlags
[i
] & VT_RESERVED
)
6984 /* Don't ask me why but native VarCmp cannot handle:
6985 VT_I1, VT_UI2, VT_UI4, VT_UINT and VT_UI8.
6986 VT_INT is only supported as left variant. Go figure.
6987 Tested with DCOM98, Win2k, WinXP */
6988 if (ExtraFlags
[i
] & VT_ARRAY
|| ExtraFlags
[i
] & VT_BYREF
||
6989 !IsValidVariantClearVT(leftvt
, ExtraFlags
[i
] & ~VT_RESERVED
) ||
6990 !IsValidVariantClearVT(rightvt
, ExtraFlags
[i
] & ~VT_RESERVED
) ||
6991 leftvt
== VT_CLSID
|| rightvt
== VT_CLSID
||
6992 leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
||
6993 leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
||
6994 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
||
6995 leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
||
6996 leftvt
== VT_VARIANT
|| rightvt
== VT_VARIANT
||
6997 leftvt
== VT_I1
|| rightvt
== VT_I1
||
6998 leftvt
== VT_UI2
|| rightvt
== VT_UI2
||
6999 leftvt
== VT_UI4
|| rightvt
== VT_UI4
||
7000 leftvt
== VT_UI8
|| rightvt
== VT_UI8
||
7001 rightvt
== VT_INT
||
7002 leftvt
== VT_UINT
|| rightvt
== VT_UINT
) {
7006 if (leftvt
== VT_ERROR
&& rightvt
== VT_ERROR
&&
7007 !(ExtraFlags
[i
] & ~VT_RESERVED
)) {
7010 } else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
7011 expect
= VARCMP_NULL
;
7012 else if (leftvt
== VT_BSTR
&& rightvt
== VT_BSTR
)
7014 else if (leftvt
== VT_BSTR
&& rightvt
== VT_EMPTY
)
7016 else if (leftvt
== VT_EMPTY
&& rightvt
== VT_BSTR
)
7019 hres
= pVarCmp(&left
, &right
, LOCALE_USER_DEFAULT
, 0);
7021 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
7022 "VarCmp: %d|0x%X, %d|0x%X: Expected failure, got 0x%X\n",
7023 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], hres
);
7026 "VarCmp: %d|0x%X, %d|0x%X: Expected 0x%X, got 0x%X\n",
7027 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], expect
,
7034 /* VARCMP{,EX} run each 4 tests with a permutation of all possible
7035 input variants with (1) and without (0) VT_RESERVED set. The order
7036 of the permutations is (0,0); (1,0); (0,1); (1,1) */
7037 VARCMP(INT
,4711,I2
,4711,VARCMP_EQ
);
7038 VARCMP(INT
,4711,I2
,-4711,VARCMP_GT
);
7039 VARCMP(ERROR
,0,ERROR
,0,VARCMP_EQ
);
7040 VARCMP(ERROR
,0,UI1
,0,DISP_E_TYPEMISMATCH
);
7041 VARCMP(EMPTY
,0,EMPTY
,0,VARCMP_EQ
);
7042 VARCMP(I4
,1,R8
,1.0,VARCMP_EQ
);
7043 VARCMP(EMPTY
,19,I2
,0,VARCMP_EQ
);
7044 ok(V_EMPTY(&left
) == 19, "VT_EMPTY modified!\n");
7045 VARCMP(I4
,1,UI1
,1,VARCMP_EQ
);
7046 VARCMP(I2
,2,I2
,2,VARCMP_EQ
);
7047 VARCMP(I2
,1,I2
,2,VARCMP_LT
);
7048 VARCMP(I2
,2,I2
,1,VARCMP_GT
);
7049 VARCMP(I2
,2,EMPTY
,1,VARCMP_GT
);
7050 VARCMP(I2
,2,NULL_
,1,VARCMP_NULL
);
7052 /* BSTR handling, especially in conjunction with VT_RESERVED */
7053 VARCMP(BSTR
,bstr0
,NULL_
,0,VARCMP_NULL
);
7054 VARCMP(BSTR
,bstr0
,BSTR
,bstr0
,VARCMP_EQ
);
7055 VARCMP(BSTR
,bstrempty
,BSTR
,bstr0
,VARCMP_LT
);
7056 VARCMP(BSTR
,bstr7
,BSTR
,bstr0
,VARCMP_GT
);
7057 VARCMP(BSTR
,bstr7
,BSTR
,bstr1neg
,VARCMP_GT
);
7058 VARCMP(BSTR
,bstr0
,BSTR
,NULL
,VARCMP_GT
);
7059 VARCMP(BSTR
,NULL
,BSTR
,NULL
,VARCMP_EQ
);
7060 VARCMP(BSTR
,bstrempty
,BSTR
,NULL
,VARCMP_EQ
);
7061 VARCMP(BSTR
,NULL
,EMPTY
,0,VARCMP_EQ
);
7062 VARCMP(EMPTY
,0,BSTR
,NULL
,VARCMP_EQ
);
7063 VARCMP(EMPTY
,0,BSTR
,bstrempty
,VARCMP_EQ
);
7064 VARCMP(EMPTY
,1,BSTR
,bstrempty
,VARCMP_EQ
);
7065 VARCMP(BSTR
,bstr0
,EMPTY
,0,VARCMP_GT
);
7066 VARCMP(BSTR
,bstr42
,EMPTY
,0,VARCMP_GT
);
7067 VARCMPEX(BSTR
,bstrempty
,UI1
,0,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
7068 VARCMPEX(BSTR
,bstrempty
,I2
,-1,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
7069 VARCMPEX(I4
,0,BSTR
,bstrempty
,VARCMP_LT
,VARCMP_LT
,VARCMP_GT
,VARCMP_LT
);
7070 VARCMPEX(BSTR
,NULL
,UI1
,0,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
7071 VARCMPEX(I4
,7,BSTR
,NULL
,VARCMP_LT
,VARCMP_LT
,VARCMP_GT
,VARCMP_LT
);
7072 _VARCMP(BSTR
,(BSTR
)100,0,I2
,100,0,lcid
,0,VARCMP_GT
);
7073 VARCMPEX(BSTR
,bstr0
,UI1
,0,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_GT
);
7074 VARCMPEX(I2
,0,BSTR
,bstr0
,VARCMP_LT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_LT
);
7075 VARCMP(BSTR
,bstrhuh
,I4
,I4_MAX
,VARCMP_GT
);
7076 VARCMP(BSTR
,bstr2cents
,I4
,2,VARCMP_GT
);
7077 VARCMPEX(BSTR
,bstr2cents
,I4
,42,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
7078 VARCMP(BSTR
,bstr2cents
,I4
,-1,VARCMP_GT
);
7079 VARCMPEX(BSTR
,bstr2cents
,I4
,-666,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
7080 VARCMPEX(BSTR
,bstr0
,I2
,0,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_GT
);
7081 VARCMPEX(BSTR
,bstr0
,I4
,0,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_GT
);
7082 VARCMPEX(BSTR
,bstr0
,I4
,-666,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
7083 VARCMP(BSTR
,bstr1
,I4
,0,VARCMP_GT
);
7084 VARCMPEX(BSTR
,bstr1
,I4
,1,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_GT
);
7085 VARCMPEX(BSTR
,bstr1
,I4
,I4_MAX
,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
,VARCMP_GT
);
7086 VARCMPEX(BSTR
,bstr1
,I4
,-1,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
7087 VARCMP(BSTR
,bstr7
,I4
,1,VARCMP_GT
);
7088 VARCMPEX(BSTR
,bstr7
,I4
,7,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_GT
);
7089 VARCMPEX(BSTR
,bstr7
,I4
,42,VARCMP_GT
,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
);
7090 VARCMPEX(BSTR
,bstr42
,I4
,7,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
7091 VARCMPEX(BSTR
,bstr42
,I4
,42,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_GT
);
7092 VARCMPEX(BSTR
,bstr42
,I4
,I4_MAX
,VARCMP_GT
,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
);
7093 VARCMPEX(BSTR
,bstr1neg
,I4
,1,VARCMP_GT
,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
);
7094 VARCMPEX(BSTR
,bstr1neg
,I4
,42,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
,VARCMP_LT
);
7095 VARCMPEX(BSTR
,bstr1neg
,I4
,-1,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_LT
);
7096 VARCMPEX(BSTR
,bstr1neg
,I4
,-666,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_LT
);
7097 VARCMPEX(BSTR
,bstr666neg
,I4
,1,VARCMP_GT
,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
);
7098 VARCMPEX(BSTR
,bstr666neg
,I4
,7,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
,VARCMP_LT
);
7099 VARCMPEX(BSTR
,bstr666neg
,I4
,42,VARCMP_GT
,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
);
7100 VARCMPEX(BSTR
,bstr666neg
,I4
,I4_MAX
,VARCMP_GT
,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
);
7101 VARCMPEX(BSTR
,bstr666neg
,I4
,-1,VARCMP_GT
,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
);
7102 VARCMPEX(BSTR
,bstr666neg
,I4
,-666,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_LT
);
7103 VARCMPEX(BSTR
,bstr7
,R8
,7.0,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_GT
);
7104 VARCMPEX(R8
,3.141592,BSTR
,NULL
,VARCMP_LT
,VARCMP_LT
,VARCMP_GT
,VARCMP_LT
);
7105 VARCMP(BSTR
,bstr7
,BSTR
,bstr7
,VARCMP_EQ
);
7106 VARCMP(BSTR
,bstr7
,BSTR
,bstr42
,VARCMP_GT
);
7107 VARCMP(BSTR
,bstr42
,BSTR
,bstr7
,VARCMP_LT
);
7109 /* DECIMAL handling */
7110 setdec(&dec
,0,0,0,0);
7111 VARCMPEX(DECIMAL
,dec
,BSTR
,bstr0
,VARCMP_LT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_LT
);
7112 setdec64(&dec
,0,0,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF); /* max DECIMAL */
7113 VARCMP(DECIMAL
,dec
,R8
,R8_MAX
,VARCMP_LT
); /* R8 has bigger range */
7114 VARCMP(DECIMAL
,dec
,DATE
,R8_MAX
,VARCMP_LT
); /* DATE has bigger range */
7115 setdec64(&dec
,0,0x80,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF);
7116 VARCMP(DECIMAL
,dec
,R8
,-R8_MAX
,VARCMP_GT
);
7117 setdec64(&dec
,20,0,0x5,0x6BC75E2D,0x63100001); /* 1+1e-20 */
7118 VARCMP(DECIMAL
,dec
,R8
,1,VARCMP_GT
); /* DECIMAL has higher precision */
7120 /* Show that DATE is handled just as a R8 */
7121 VARCMP(DATE
,DATE_MAX
,DATE
,DATE_MAX
+1,VARCMP_LT
);
7122 VARCMP(DATE
,DATE_MIN
,DATE
,DATE_MIN
-1,VARCMP_GT
);
7123 VARCMP(DATE
,R8_MIN
,R8
,R8_MIN
,VARCMP_EQ
);
7124 VARCMP(DATE
,1,DATE
,1+1e-15,VARCMP_LT
); /* 1e-15 == 8.64e-11 seconds */
7125 VARCMP(DATE
,25570.0,DATE
,25570.0,VARCMP_EQ
);
7126 VARCMP(DATE
,25570.0,DATE
,25571.0,VARCMP_LT
);
7127 VARCMP(DATE
,25571.0,DATE
,25570.0,VARCMP_GT
);
7128 VARCMP(DATE
,25570.0,EMPTY
,0,VARCMP_GT
);
7129 VARCMP(DATE
,25570.0,NULL_
,0,VARCMP_NULL
);
7131 /* R4 precision handling */
7132 VARCMP(R4
,1,R8
,1+1e-8,VARCMP_EQ
);
7133 VARCMP(R8
,1+1e-8,R4
,1,VARCMP_EQ
);
7134 VARCMP(R8
,1+1e-8,R8
,1,VARCMP_GT
);
7135 VARCMP(R8
,R4_MAX
*1.1,R4
,R4_MAX
,VARCMP_GT
);
7136 VARCMP(R4
,R4_MAX
,R8
,R8_MAX
,VARCMP_LT
);
7137 VARCMP(R4
,1,DATE
,1+1e-8,VARCMP_EQ
);
7138 VARCMP(R4
,1,BSTR
,bstr1few
,VARCMP_LT
); /* bstr1few == 1+1e-8 */
7139 setdec(&dec
,8,0,0,0x5F5E101); /* 1+1e-8 */
7140 VARCMP(R4
,1,DECIMAL
,dec
,VARCMP_LT
);
7142 SysFreeString(bstrhuh
);
7143 SysFreeString(bstrempty
);
7144 SysFreeString(bstr0
);
7145 SysFreeString(bstr1
);
7146 SysFreeString(bstr7
);
7147 SysFreeString(bstr42
);
7148 SysFreeString(bstr1neg
);
7149 SysFreeString(bstr666neg
);
7150 SysFreeString(bstr2cents
);
7151 SysFreeString(bstr1few
);
7154 static HRESULT (WINAPI
*pVarPow
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
7156 #define VARPOW(vt1,val1,vt2,val2,rvt,rval) \
7157 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
7158 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
7159 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
7160 test_var_call2( __LINE__, pVarPow, &left, &right, &exp )
7162 /* Skip any type that is not defined or produces an error for every case */
7163 #define SKIPTESTPOW(a) \
7164 if (a == VT_ERROR || a == VT_VARIANT || \
7165 a == VT_DISPATCH || a == VT_UNKNOWN || \
7166 a == VT_RECORD || a > VT_UINT || \
7167 a == 15 /*not defined*/) \
7170 static void test_VarPow(void)
7172 static const WCHAR str2
[] = { '2','\0' };
7173 static const WCHAR str3
[] = { '3','\0' };
7174 VARIANT left
, right
, exp
, result
, cy
, dec
;
7175 BSTR num2_str
, num3_str
;
7181 num2_str
= SysAllocString(str2
);
7182 num3_str
= SysAllocString(str3
);
7184 /* Test all possible flag/vt combinations & the resulting vt type */
7185 for (i
= 0; i
< ARRAY_SIZE(ExtraFlags
); i
++)
7187 VARTYPE leftvt
, rightvt
, resvt
;
7189 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
7191 SKIPTESTPOW(leftvt
);
7193 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
7196 SKIPTESTPOW(rightvt
);
7198 /* Native crashes with VT_BYREF */
7199 if (ExtraFlags
[i
] == VT_BYREF
)
7202 memset(&left
, 0, sizeof(left
));
7203 memset(&right
, 0, sizeof(right
));
7204 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
7205 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
7206 V_VT(&result
) = VT_EMPTY
;
7209 if (leftvt
== VT_BSTR
)
7210 V_BSTR(&left
) = num2_str
;
7211 if (rightvt
== VT_BSTR
)
7212 V_BSTR(&right
) = num2_str
;
7214 /* Native VarPow always returns an error when using extra flags */
7215 if (ExtraFlags
[i
] != 0)
7218 /* Determine return type */
7219 else if ((leftvt
== VT_NULL
|| rightvt
== VT_NULL
) &&
7220 ((leftvt
!= VT_I8
&& leftvt
!= VT_UI8
&&
7221 rightvt
!= VT_I8
&& rightvt
!= VT_UI8
) || has_i8
))
7223 else if ((leftvt
== VT_EMPTY
|| leftvt
== VT_I2
||
7224 leftvt
== VT_I4
|| leftvt
== VT_R4
||
7225 leftvt
== VT_R8
|| leftvt
== VT_CY
||
7226 leftvt
== VT_DATE
|| leftvt
== VT_BSTR
||
7227 leftvt
== VT_BOOL
|| leftvt
== VT_DECIMAL
||
7228 (leftvt
>= VT_I1
&& leftvt
<= VT_UI4
) ||
7229 (has_i8
&& (leftvt
== VT_I8
|| leftvt
== VT_UI8
)) ||
7230 leftvt
== VT_INT
|| leftvt
== VT_UINT
) &&
7231 (rightvt
== VT_EMPTY
|| rightvt
== VT_I2
||
7232 rightvt
== VT_I4
|| rightvt
== VT_R4
||
7233 rightvt
== VT_R8
|| rightvt
== VT_CY
||
7234 rightvt
== VT_DATE
|| rightvt
== VT_BSTR
||
7235 rightvt
== VT_BOOL
|| rightvt
== VT_DECIMAL
||
7236 (rightvt
>= VT_I1
&& rightvt
<= VT_UI4
) ||
7237 (has_i8
&& (rightvt
== VT_I8
|| rightvt
== VT_UI8
)) ||
7238 rightvt
== VT_INT
|| rightvt
== VT_UINT
))
7243 hres
= pVarPow(&left
, &right
, &result
);
7245 /* Check expected HRESULT and if result variant type is correct */
7247 ok (hres
== DISP_E_BADVARTYPE
|| hres
== DISP_E_TYPEMISMATCH
,
7248 "VarPow: %s|0x%X, %s|0x%X: got vt %s hr 0x%X\n",
7249 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
],
7250 vtstr(V_VT(&result
)), hres
);
7252 ok (hres
== S_OK
&& resvt
== V_VT(&result
),
7253 "VarPow: %s|0x%X, %s|0x%X: expected vt %s hr 0x%X, got vt %s hr 0x%X\n",
7254 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
], vtstr(resvt
),
7255 S_OK
, vtstr(V_VT(&result
)), hres
);
7260 /* Check return values for valid variant type combinations */
7261 VARPOW(EMPTY
,0,EMPTY
,0,R8
,1.0);
7262 VARPOW(EMPTY
,0,NULL
,0,NULL
,0);
7263 VARPOW(EMPTY
,0,I2
,3,R8
,0.0);
7264 VARPOW(EMPTY
,0,I4
,3,R8
,0.0);
7265 VARPOW(EMPTY
,0,R4
,3.0f
,R8
,0.0);
7266 VARPOW(EMPTY
,0,R8
,3.0,R8
,0.0);
7267 VARPOW(EMPTY
,0,DATE
,3,R8
,0.0);
7268 VARPOW(EMPTY
,0,BSTR
,num3_str
,R8
,0.0);
7269 VARPOW(EMPTY
,0,BOOL
,VARIANT_FALSE
,R8
,1.0);
7270 VARPOW(EMPTY
,0,I1
,3,R8
,0.0);
7271 VARPOW(EMPTY
,0,UI1
,3,R8
,0.0);
7272 VARPOW(EMPTY
,0,UI2
,3,R8
,0.0);
7273 VARPOW(EMPTY
,0,UI4
,3,R8
,0.0);
7276 VARPOW(EMPTY
,0,I8
,3,R8
,0.0);
7277 VARPOW(EMPTY
,0,UI8
,3,R8
,0.0);
7279 VARPOW(EMPTY
,0,INT
,3,R8
,0.0);
7280 VARPOW(EMPTY
,0,UINT
,3,R8
,0.0);
7281 VARPOW(NULL
,0,EMPTY
,0,NULL
,0);
7282 VARPOW(NULL
,0,NULL
,0,NULL
,0);
7283 VARPOW(NULL
,0,I2
,3,NULL
,0);
7284 VARPOW(NULL
,0,I4
,3,NULL
,0);
7285 VARPOW(NULL
,0,R4
,3.0f
,NULL
,0);
7286 VARPOW(NULL
,0,R8
,3.0,NULL
,0);
7287 VARPOW(NULL
,0,DATE
,3,NULL
,0);
7288 VARPOW(NULL
,0,BSTR
,num3_str
,NULL
,0);
7289 VARPOW(NULL
,0,BOOL
,VARIANT_TRUE
,NULL
,0);
7290 VARPOW(NULL
,0,I1
,3,NULL
,0);
7291 VARPOW(NULL
,0,UI1
,3,NULL
,0);
7292 VARPOW(NULL
,0,UI2
,3,NULL
,0);
7293 VARPOW(NULL
,0,UI4
,3,NULL
,0);
7296 VARPOW(NULL
,0,I8
,3,NULL
,0);
7297 VARPOW(NULL
,0,UI8
,3,NULL
,0);
7299 VARPOW(NULL
,0,INT
,3,NULL
,0);
7300 VARPOW(NULL
,0,UINT
,3,NULL
,0);
7301 VARPOW(I2
,2,EMPTY
,0,R8
,1.0);
7302 VARPOW(I2
,2,NULL
,0,NULL
,0);
7303 VARPOW(I2
,2,I2
,3,R8
,8.0);
7304 VARPOW(I2
,2,I4
,3,R8
,8.0);
7305 VARPOW(I2
,2,R4
,3.0f
,R8
,8.0);
7306 VARPOW(I2
,2,R8
,3.0,R8
,8.0);
7307 VARPOW(I2
,2,DATE
,3,R8
,8.0);
7308 VARPOW(I2
,2,BSTR
,num3_str
,R8
,8.0);
7309 VARPOW(I2
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
7310 VARPOW(I2
,2,I1
,3,R8
,8.0);
7311 VARPOW(I2
,2,UI1
,3,R8
,8.0);
7312 VARPOW(I2
,2,UI2
,3,R8
,8.0);
7313 VARPOW(I2
,2,UI4
,3,R8
,8.0);
7316 VARPOW(I2
,2,I8
,3,R8
,8.0);
7317 VARPOW(I2
,2,UI8
,3,R8
,8.0);
7319 VARPOW(I2
,2,INT
,3,R8
,8.0);
7320 VARPOW(I2
,2,UINT
,3,R8
,8.0);
7321 VARPOW(I4
,2,EMPTY
,0,R8
,1.0);
7322 VARPOW(I4
,2,NULL
,0,NULL
,0);
7323 VARPOW(I4
,2,I2
,3,R8
,8.0);
7324 VARPOW(I4
,2,I4
,3,R8
,8.0);
7325 VARPOW(I4
,2,R4
,3.0f
,R8
,8.0);
7326 VARPOW(I4
,2,R8
,3.0,R8
,8.0);
7327 VARPOW(I4
,2,DATE
,3,R8
,8.0);
7328 VARPOW(I4
,2,BSTR
,num3_str
,R8
,8.0);
7329 VARPOW(I4
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
7330 VARPOW(I4
,2,I1
,3,R8
,8.0);
7331 VARPOW(I4
,2,UI1
,3,R8
,8.0);
7332 VARPOW(I4
,2,UI2
,3,R8
,8.0);
7333 VARPOW(I4
,2,UI4
,3,R8
,8.0);
7336 VARPOW(I4
,2,I8
,3,R8
,8.0);
7337 VARPOW(I4
,2,UI8
,3,R8
,8.0);
7339 VARPOW(I4
,2,INT
,3,R8
,8.0);
7340 VARPOW(I4
,2,UINT
,3,R8
,8.0);
7341 VARPOW(R4
,2,EMPTY
,0,R8
,1.0);
7342 VARPOW(R4
,2,NULL
,0,NULL
,0);
7343 VARPOW(R4
,2,I2
,3,R8
,8.0);
7344 VARPOW(R4
,2,I4
,3,R8
,8.0);
7345 VARPOW(R4
,2,R4
,3.0f
,R8
,8.0);
7346 VARPOW(R4
,2,R8
,3.0,R8
,8.0);
7347 VARPOW(R4
,2,DATE
,3,R8
,8.0);
7348 VARPOW(R4
,2,BSTR
,num3_str
,R8
,8.0);
7349 VARPOW(R4
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
7350 VARPOW(R4
,2,I1
,3,R8
,8.0);
7351 VARPOW(R4
,2,UI1
,3,R8
,8.0);
7352 VARPOW(R4
,2,UI2
,3,R8
,8.0);
7353 VARPOW(R4
,2,UI4
,3,R8
,8.0);
7356 VARPOW(R4
,2,I8
,3,R8
,8.0);
7357 VARPOW(R4
,2,UI8
,3,R8
,8.0);
7359 VARPOW(R4
,2,INT
,3,R8
,8.0);
7360 VARPOW(R4
,2,UINT
,3,R8
,8.0);
7361 VARPOW(R8
,2,EMPTY
,0,R8
,1.0);
7362 VARPOW(R8
,2,NULL
,0,NULL
,0);
7363 VARPOW(R8
,2,I2
,3,R8
,8.0);
7364 VARPOW(R8
,2,I4
,3,R8
,8.0);
7365 VARPOW(R8
,2,R4
,3.0f
,R8
,8.0);
7366 VARPOW(R8
,2,R8
,3.0,R8
,8.0);
7367 VARPOW(R8
,2,DATE
,3,R8
,8.0);
7368 VARPOW(R8
,2,BSTR
,num3_str
,R8
,8.0);
7369 VARPOW(R8
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
7370 VARPOW(R8
,2,I1
,3,R8
,8.0);
7371 VARPOW(R8
,2,UI1
,3,R8
,8.0);
7372 VARPOW(R8
,2,UI2
,3,R8
,8.0);
7373 VARPOW(R8
,2,UI4
,3,R8
,8.0);
7376 VARPOW(R8
,2,I8
,3,R8
,8.0);
7377 VARPOW(R8
,2,UI8
,3,R8
,8.0);
7379 VARPOW(R8
,2,INT
,3,R8
,8.0);
7380 VARPOW(R8
,2,UINT
,3,R8
,8.0);
7381 VARPOW(DATE
,2,EMPTY
,0,R8
,1.0);
7382 VARPOW(DATE
,2,NULL
,0,NULL
,0);
7383 VARPOW(DATE
,2,I2
,3,R8
,8.0);
7384 VARPOW(DATE
,2,I4
,3,R8
,8.0);
7385 VARPOW(DATE
,2,R4
,3.0f
,R8
,8.0);
7386 VARPOW(DATE
,2,R8
,3.0,R8
,8.0);
7387 VARPOW(DATE
,2,DATE
,3,R8
,8.0);
7388 VARPOW(DATE
,2,BSTR
,num3_str
,R8
,8.0);
7389 VARPOW(DATE
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
7390 VARPOW(DATE
,2,I1
,3,R8
,8.0);
7391 VARPOW(DATE
,2,UI1
,3,R8
,8.0);
7392 VARPOW(DATE
,2,UI2
,3,R8
,8.0);
7393 VARPOW(DATE
,2,UI4
,3,R8
,8.0);
7396 VARPOW(DATE
,2,I8
,3,R8
,8.0);
7397 VARPOW(DATE
,2,UI8
,3,R8
,8.0);
7399 VARPOW(DATE
,2,INT
,3,R8
,8.0);
7400 VARPOW(DATE
,2,UINT
,3,R8
,8.0);
7401 VARPOW(BSTR
,num2_str
,EMPTY
,0,R8
,1.0);
7402 VARPOW(BSTR
,num2_str
,NULL
,0,NULL
,0);
7403 VARPOW(BSTR
,num2_str
,I2
,3,R8
,8.0);
7404 VARPOW(BSTR
,num2_str
,I4
,3,R8
,8.0);
7405 VARPOW(BSTR
,num2_str
,R4
,3.0f
,R8
,8.0);
7406 VARPOW(BSTR
,num2_str
,R8
,3.0,R8
,8.0);
7407 VARPOW(BSTR
,num2_str
,DATE
,3,R8
,8.0);
7408 VARPOW(BSTR
,num2_str
,BSTR
,num3_str
,R8
,8.0);
7409 VARPOW(BSTR
,num2_str
,BOOL
,VARIANT_FALSE
,R8
,1.0);
7410 VARPOW(BSTR
,num2_str
,I1
,3,R8
,8.0);
7411 VARPOW(BSTR
,num2_str
,UI1
,3,R8
,8.0);
7412 VARPOW(BSTR
,num2_str
,UI2
,3,R8
,8.0);
7413 VARPOW(BSTR
,num2_str
,UI4
,3,R8
,8.0);
7416 VARPOW(BSTR
,num2_str
,I8
,3,R8
,8.0);
7417 VARPOW(BSTR
,num2_str
,UI8
,3,R8
,8.0);
7419 VARPOW(BSTR
,num2_str
,INT
,3,R8
,8.0);
7420 VARPOW(BSTR
,num2_str
,UINT
,3,R8
,8.0);
7421 VARPOW(BOOL
,VARIANT_TRUE
,EMPTY
,0,R8
,1.0);
7422 VARPOW(BOOL
,VARIANT_TRUE
,NULL
,0,NULL
,0);
7423 VARPOW(BOOL
,VARIANT_TRUE
,I2
,3,R8
,-1.0);
7424 VARPOW(BOOL
,VARIANT_TRUE
,I4
,3,R8
,-1.0);
7425 VARPOW(BOOL
,VARIANT_TRUE
,R4
,3.0f
,R8
,-1.0);
7426 VARPOW(BOOL
,VARIANT_TRUE
,R8
,3.0,R8
,-1.0);
7427 VARPOW(BOOL
,VARIANT_TRUE
,DATE
,3,R8
,-1.0);
7428 VARPOW(BOOL
,VARIANT_TRUE
,BSTR
,num3_str
,R8
,-1.0);
7429 VARPOW(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
,R8
,-1.0);
7430 VARPOW(BOOL
,VARIANT_TRUE
,I1
,3,R8
,-1.0);
7431 VARPOW(BOOL
,VARIANT_TRUE
,UI1
,3,R8
,-1.0);
7432 VARPOW(BOOL
,VARIANT_TRUE
,UI2
,3,R8
,-1.0);
7433 VARPOW(BOOL
,VARIANT_TRUE
,UI4
,3,R8
,-1.0);
7436 VARPOW(BOOL
,VARIANT_TRUE
,I8
,3,R8
,-1.0);
7437 VARPOW(BOOL
,VARIANT_TRUE
,UI8
,3,R8
,-1.0);
7439 VARPOW(BOOL
,VARIANT_TRUE
,INT
,3,R8
,-1.0);
7440 VARPOW(BOOL
,VARIANT_TRUE
,UINT
,3,R8
,-1.0);
7441 VARPOW(I1
,2,EMPTY
,0,R8
,1.0);
7442 VARPOW(I1
,2,NULL
,0,NULL
,0);
7443 VARPOW(I1
,2,I2
,3,R8
,8.0);
7444 VARPOW(I1
,2,I4
,3,R8
,8.0);
7445 VARPOW(I1
,2,R4
,3.0f
,R8
,8.0);
7446 VARPOW(I1
,2,R8
,3.0,R8
,8.0);
7447 VARPOW(I1
,2,DATE
,3,R8
,8.0);
7448 VARPOW(I1
,2,BSTR
,num3_str
,R8
,8.0);
7449 VARPOW(I1
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
7450 VARPOW(I1
,2,I1
,3,R8
,8.0);
7451 VARPOW(I1
,2,UI1
,3,R8
,8.0);
7452 VARPOW(I1
,2,UI2
,3,R8
,8.0);
7453 VARPOW(I1
,2,UI4
,3,R8
,8.0);
7456 VARPOW(I1
,2,I8
,3,R8
,8.0);
7457 VARPOW(I1
,2,UI8
,3,R8
,8.0);
7459 VARPOW(I1
,2,INT
,3,R8
,8.0);
7460 VARPOW(I1
,2,UINT
,3,R8
,8.0);
7461 VARPOW(UI1
,2,EMPTY
,0,R8
,1.0);
7462 VARPOW(UI1
,2,NULL
,0,NULL
,0);
7463 VARPOW(UI1
,2,I2
,3,R8
,8.0);
7464 VARPOW(UI1
,2,I4
,3,R8
,8.0);
7465 VARPOW(UI1
,2,R4
,3.0f
,R8
,8.0);
7466 VARPOW(UI1
,2,R8
,3.0,R8
,8.0);
7467 VARPOW(UI1
,2,DATE
,3,R8
,8.0);
7468 VARPOW(UI1
,2,BSTR
,num3_str
,R8
,8.0);
7469 VARPOW(UI1
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
7470 VARPOW(UI1
,2,I1
,3,R8
,8.0);
7471 VARPOW(UI1
,2,UI1
,3,R8
,8.0);
7472 VARPOW(UI1
,2,UI2
,3,R8
,8.0);
7473 VARPOW(UI1
,2,UI4
,3,R8
,8.0);
7476 VARPOW(UI1
,2,I8
,3,R8
,8.0);
7477 VARPOW(UI1
,2,UI8
,3,R8
,8.0);
7479 VARPOW(UI1
,2,INT
,3,R8
,8.0);
7480 VARPOW(UI1
,2,UINT
,3,R8
,8.0);
7481 VARPOW(UI2
,2,EMPTY
,0,R8
,1.0);
7482 VARPOW(UI2
,2,NULL
,0,NULL
,0);
7483 VARPOW(UI2
,2,I2
,3,R8
,8.0);
7484 VARPOW(UI2
,2,I4
,3,R8
,8.0);
7485 VARPOW(UI2
,2,R4
,3.0f
,R8
,8.0);
7486 VARPOW(UI2
,2,R8
,3.0,R8
,8.0);
7487 VARPOW(UI2
,2,DATE
,3,R8
,8.0);
7488 VARPOW(UI2
,2,BSTR
,num3_str
,R8
,8.0);
7489 VARPOW(UI2
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
7490 VARPOW(UI2
,2,I1
,3,R8
,8.0);
7491 VARPOW(UI2
,2,UI1
,3,R8
,8.0);
7492 VARPOW(UI2
,2,UI2
,3,R8
,8.0);
7493 VARPOW(UI2
,2,UI4
,3,R8
,8.0);
7496 VARPOW(UI2
,2,I8
,3,R8
,8.0);
7497 VARPOW(UI2
,2,UI8
,3,R8
,8.0);
7499 VARPOW(UI2
,2,INT
,3,R8
,8.0);
7500 VARPOW(UI2
,2,UINT
,3,R8
,8.0);
7501 VARPOW(UI4
,2,EMPTY
,0,R8
,1.0);
7502 VARPOW(UI4
,2,NULL
,0,NULL
,0);
7503 VARPOW(UI4
,2,I2
,3,R8
,8.0);
7504 VARPOW(UI4
,2,I4
,3,R8
,8.0);
7505 VARPOW(UI4
,2,R4
,3.0f
,R8
,8.0);
7506 VARPOW(UI4
,2,R8
,3.0,R8
,8.0);
7507 VARPOW(UI4
,2,DATE
,3,R8
,8.0);
7508 VARPOW(UI4
,2,BSTR
,num3_str
,R8
,8.0);
7509 VARPOW(UI4
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
7510 VARPOW(UI4
,2,I1
,3,R8
,8.0);
7511 VARPOW(UI4
,2,UI1
,3,R8
,8.0);
7512 VARPOW(UI4
,2,UI2
,3,R8
,8.0);
7513 VARPOW(UI4
,2,UI4
,3,R8
,8.0);
7516 VARPOW(UI4
,2,I8
,3,R8
,8.0);
7517 VARPOW(UI4
,2,UI8
,3,R8
,8.0);
7519 VARPOW(UI4
,2,INT
,3,R8
,8.0);
7520 VARPOW(UI4
,2,UINT
,3,R8
,8.0);
7523 VARPOW(I8
,2,EMPTY
,0,R8
,1.0);
7524 VARPOW(I8
,2,NULL
,0,NULL
,0);
7525 VARPOW(I8
,2,I2
,3,R8
,8.0);
7526 VARPOW(I8
,2,I4
,3,R8
,8.0);
7527 VARPOW(I8
,2,R4
,3.0f
,R8
,8.0);
7528 VARPOW(I8
,2,R8
,3.0,R8
,8.0);
7529 VARPOW(I8
,2,DATE
,3,R8
,8.0);
7530 VARPOW(I8
,2,BSTR
,num3_str
,R8
,8.0);
7531 VARPOW(I8
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
7532 VARPOW(I8
,2,I1
,3,R8
,8.0);
7533 VARPOW(I8
,2,UI1
,3,R8
,8.0);
7534 VARPOW(I8
,2,UI2
,3,R8
,8.0);
7535 VARPOW(I8
,2,UI4
,3,R8
,8.0);
7536 VARPOW(I8
,2,I8
,3,R8
,8.0);
7537 VARPOW(I8
,2,UI8
,3,R8
,8.0);
7538 VARPOW(I8
,2,INT
,3,R8
,8.0);
7539 VARPOW(I8
,2,UINT
,3,R8
,8.0);
7540 VARPOW(UI8
,2,EMPTY
,0,R8
,1.0);
7541 VARPOW(UI8
,2,NULL
,0,NULL
,0);
7542 VARPOW(UI8
,2,I2
,3,R8
,8.0);
7543 VARPOW(UI8
,2,I4
,3,R8
,8.0);
7544 VARPOW(UI8
,2,R4
,3.0f
,R8
,8.0);
7545 VARPOW(UI8
,2,R8
,3.0,R8
,8.0);
7546 VARPOW(UI8
,2,DATE
,3,R8
,8.0);
7547 VARPOW(UI8
,2,BSTR
,num3_str
,R8
,8.0);
7548 VARPOW(UI8
,2,I1
,3,R8
,8.0);
7549 VARPOW(UI8
,2,UI1
,3,R8
,8.0);
7550 VARPOW(UI8
,2,UI2
,3,R8
,8.0);
7551 VARPOW(UI8
,2,UI4
,3,R8
,8.0);
7552 VARPOW(UI8
,2,I8
,3,R8
,8.0);
7553 VARPOW(UI8
,2,UI8
,3,R8
,8.0);
7554 VARPOW(UI8
,2,INT
,3,R8
,8.0);
7555 VARPOW(UI8
,2,UINT
,3,R8
,8.0);
7557 VARPOW(INT
,2,EMPTY
,0,R8
,1.0);
7558 VARPOW(INT
,2,NULL
,0,NULL
,0);
7559 VARPOW(INT
,2,I2
,3,R8
,8.0);
7560 VARPOW(INT
,2,I4
,3,R8
,8.0);
7561 VARPOW(INT
,2,R4
,3.0f
,R8
,8.0);
7562 VARPOW(INT
,2,R8
,3.0,R8
,8.0);
7563 VARPOW(INT
,2,DATE
,3,R8
,8.0);
7564 VARPOW(INT
,2,BSTR
,num3_str
,R8
,8.0);
7565 VARPOW(INT
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
7566 VARPOW(INT
,2,I1
,3,R8
,8.0);
7567 VARPOW(INT
,2,UI1
,3,R8
,8.0);
7568 VARPOW(INT
,2,UI2
,3,R8
,8.0);
7569 VARPOW(INT
,2,UI4
,3,R8
,8.0);
7572 VARPOW(INT
,2,I8
,3,R8
,8.0);
7573 VARPOW(INT
,2,UI8
,3,R8
,8.0);
7575 VARPOW(INT
,2,INT
,3,R8
,8.0);
7576 VARPOW(INT
,2,UINT
,3,R8
,8.0);
7577 VARPOW(UINT
,2,EMPTY
,0,R8
,1.0);
7578 VARPOW(UINT
,2,NULL
,0,NULL
,0);
7579 VARPOW(UINT
,2,I2
,3,R8
,8.0);
7580 VARPOW(UINT
,2,I4
,3,R8
,8.0);
7581 VARPOW(UINT
,2,R4
,3.0f
,R8
,8.0);
7582 VARPOW(UINT
,2,R8
,3.0,R8
,8.0);
7583 VARPOW(UINT
,2,DATE
,3,R8
,8.0);
7584 VARPOW(UINT
,2,BSTR
,num3_str
,R8
,8.0);
7585 VARPOW(UINT
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
7586 VARPOW(UINT
,2,I1
,3,R8
,8.0);
7587 VARPOW(UINT
,2,UI1
,3,R8
,8.0);
7588 VARPOW(UINT
,2,UI2
,3,R8
,8.0);
7589 VARPOW(UINT
,2,UI4
,3,R8
,8.0);
7592 VARPOW(UINT
,2,I8
,3,R8
,8.0);
7593 VARPOW(UINT
,2,UI8
,3,R8
,8.0);
7595 VARPOW(UINT
,2,INT
,3,R8
,8.0);
7596 VARPOW(UINT
,2,UINT
,3,R8
,8.0);
7598 /* Manually test some VT_CY, VT_DECIMAL variants */
7600 hres
= VarCyFromI4(2, &V_CY(&cy
));
7601 ok(hres
== S_OK
, "VarCyFromI4 failed!\n");
7602 V_VT(&dec
) = VT_DECIMAL
;
7603 hres
= VarDecFromR8(2.0, &V_DECIMAL(&dec
));
7604 ok(hres
== S_OK
, "VarDecFromR4 failed!\n");
7605 memset(&left
, 0, sizeof(left
));
7606 memset(&right
, 0, sizeof(right
));
7607 V_VT(&left
) = VT_I4
;
7609 V_VT(&right
) = VT_I8
;
7612 hres
= pVarPow(&cy
, &cy
, &result
);
7613 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
7614 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
7615 S_OK
, hres
, vtstr(V_VT(&result
)));
7616 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 4.0),
7617 "VARPOW: CY value %f, expected %f\n", V_R8(&result
), 4.0);
7619 hres
= pVarPow(&cy
, &right
, &result
);
7622 ok(V_VT(&result
) == VT_R8
,
7623 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
7624 S_OK
, hres
, vtstr(V_VT(&result
)));
7625 ok(EQ_DOUBLE(V_R8(&result
), 4.0),
7626 "VARPOW: CY value %f, expected %f\n", V_R8(&result
), 4.0);
7630 ok(hres
== DISP_E_BADVARTYPE
&& V_VT(&result
) == VT_EMPTY
,
7631 "VARPOW: expected coerced hres 0x%X type VT_EMPTY, got hres 0x%X type %s!\n",
7632 DISP_E_BADVARTYPE
, hres
, vtstr(V_VT(&result
)));
7635 hres
= pVarPow(&left
, &cy
, &result
);
7636 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
7637 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
7638 S_OK
, hres
, vtstr(V_VT(&result
)));
7639 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 10000.0),
7640 "VARPOW: CY value %f, expected %f\n", V_R8(&result
), 10000.0);
7642 hres
= pVarPow(&left
, &dec
, &result
);
7643 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
7644 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
7645 S_OK
, hres
, vtstr(V_VT(&result
)));
7646 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
),10000.0),
7647 "VARPOW: DECIMAL value %f, expected %f\n", V_R8(&result
), 10000.0);
7649 hres
= pVarPow(&dec
, &dec
, &result
);
7650 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
7651 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
7652 S_OK
, hres
, vtstr(V_VT(&result
)));
7653 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 4.0),
7654 "VARPOW: DECIMAL value %f, expected %f\n", V_R8(&result
), 4.0);
7656 hres
= pVarPow(&dec
, &right
, &result
);
7659 ok(V_VT(&result
) == VT_R8
,
7660 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
7661 S_OK
, hres
, vtstr(V_VT(&result
)));
7662 ok(EQ_DOUBLE(V_R8(&result
), 4.0),
7663 "VARPOW: DECIMAL value %f, expected %f\n", V_R8(&result
), 4.0);
7667 ok(hres
== DISP_E_BADVARTYPE
&& V_VT(&result
) == VT_EMPTY
,
7668 "VARPOW: expected coerced hres 0x%X type VT_EMPTY, got hres 0x%X type %s!\n",
7669 DISP_E_BADVARTYPE
, hres
, vtstr(V_VT(&result
)));
7672 SysFreeString(num2_str
);
7673 SysFreeString(num3_str
);
7676 static HRESULT (WINAPI
*pVarDiv
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
7678 #define VARDIV(vt1,val1,vt2,val2,rvt,rval) \
7679 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
7680 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
7681 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
7682 test_var_call2( __LINE__, pVarDiv, &left, &right, &exp )
7684 /* Skip any type that is not defined or produces an error for every case */
7685 #define SKIPTESTDIV(a) \
7686 if (a == VT_ERROR || a == VT_VARIANT || \
7687 a == VT_DISPATCH || a == VT_UNKNOWN || \
7688 a == VT_RECORD || a > VT_UINT || \
7689 a == VT_I1 || a == VT_UI8 || \
7690 a == VT_INT || a == VT_UINT || \
7691 a == VT_UI2 || a == VT_UI4 || \
7692 a == 15 /*not defined*/) \
7695 static void test_VarDiv(void)
7697 static const WCHAR str1
[] = { '1','\0' };
7698 static const WCHAR str2
[] = { '2','\0' };
7699 VARIANT left
, right
, exp
, result
, cy
, dec
;
7700 BSTR num1_str
, num2_str
;
7707 num1_str
= SysAllocString(str1
);
7708 num2_str
= SysAllocString(str2
);
7710 /* Test all possible flag/vt combinations & the resulting vt type */
7711 for (i
= 0; i
< ARRAY_SIZE(ExtraFlags
); i
++)
7713 VARTYPE leftvt
, rightvt
, resvt
;
7715 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
7717 SKIPTESTDIV(leftvt
);
7719 /* Check if we need/have support for I8 */
7720 if (leftvt
== VT_I8
&& !has_i8
)
7723 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
7726 SKIPTESTDIV(rightvt
);
7728 /* Check if we need/have support for I8 */
7729 if (rightvt
== VT_I8
&& !has_i8
)
7732 /* Native crashes with VT_BYREF */
7733 if (ExtraFlags
[i
] == VT_BYREF
)
7736 memset(&left
, 0, sizeof(left
));
7737 memset(&right
, 0, sizeof(right
));
7738 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
7739 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
7740 V_VT(&result
) = VT_EMPTY
;
7743 if (leftvt
== VT_BSTR
)
7744 V_BSTR(&left
) = num2_str
;
7745 else if (leftvt
== VT_DECIMAL
)
7747 VarDecFromR8(2.0, &V_DECIMAL(&left
));
7748 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
7751 /* Division by 0 is undefined */
7755 V_BSTR(&right
) = num2_str
;
7758 VarDecFromR8(2.0, &V_DECIMAL(&right
));
7759 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
7762 V_BOOL(&right
) = VARIANT_TRUE
;
7764 case VT_I2
: V_I2(&right
) = 2; break;
7765 case VT_I4
: V_I4(&right
) = 2; break;
7766 case VT_R4
: V_R4(&right
) = 2.0f
; break;
7767 case VT_R8
: V_R8(&right
) = 2.0; break;
7768 case VT_CY
: V_CY(&right
).int64
= 2; break;
7769 case VT_DATE
: V_DATE(&right
) = 2; break;
7770 case VT_UI1
: V_UI1(&right
) = 2; break;
7771 case VT_I8
: V_I8(&right
) = 2; break;
7775 /* Determine return type */
7776 if (rightvt
!= VT_EMPTY
)
7778 if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
7780 else if (leftvt
== VT_DECIMAL
|| rightvt
== VT_DECIMAL
)
7782 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
||
7783 leftvt
== VT_CY
|| rightvt
== VT_CY
||
7784 leftvt
== VT_DATE
|| rightvt
== VT_DATE
||
7785 leftvt
== VT_I4
|| rightvt
== VT_I4
||
7786 leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
||
7787 leftvt
== VT_I2
|| rightvt
== VT_I2
||
7788 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
||
7789 leftvt
== VT_R8
|| rightvt
== VT_R8
||
7790 leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
7792 if ((leftvt
== VT_UI1
&& rightvt
== VT_R4
) ||
7793 (leftvt
== VT_R4
&& rightvt
== VT_UI1
))
7795 else if ((leftvt
== VT_R4
&& (rightvt
== VT_BOOL
||
7796 rightvt
== VT_I2
)) || (rightvt
== VT_R4
&&
7797 (leftvt
== VT_BOOL
|| leftvt
== VT_I2
)))
7802 else if (leftvt
== VT_R4
|| rightvt
== VT_R4
)
7805 else if (leftvt
== VT_NULL
)
7810 /* Native VarDiv always returns an error when using extra flags */
7811 if (ExtraFlags
[i
] != 0)
7814 hres
= pVarDiv(&left
, &right
, &result
);
7816 /* Check expected HRESULT and if result variant type is correct */
7818 ok (hres
== DISP_E_BADVARTYPE
|| hres
== DISP_E_TYPEMISMATCH
||
7819 hres
== DISP_E_OVERFLOW
|| hres
== DISP_E_DIVBYZERO
,
7820 "VarDiv: %s|0x%X, %s|0x%X: got vt %s hr 0x%X\n",
7821 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
],
7822 vtstr(V_VT(&result
)), hres
);
7824 ok (hres
== S_OK
&& resvt
== V_VT(&result
),
7825 "VarDiv: %s|0x%X, %s|0x%X: expected vt %s hr 0x%X, got vt %s hr 0x%X\n",
7826 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
], vtstr(resvt
),
7827 S_OK
, vtstr(V_VT(&result
)), hres
);
7832 /* Test return values for all the good cases */
7833 VARDIV(EMPTY
,0,NULL
,0,NULL
,0);
7834 VARDIV(EMPTY
,0,I2
,2,R8
,0.0);
7835 VARDIV(EMPTY
,0,I4
,2,R8
,0.0);
7836 VARDIV(EMPTY
,0,R4
,2.0f
,R4
,0.0f
);
7837 VARDIV(EMPTY
,0,R8
,2.0,R8
,0.0);
7838 VARDIV(EMPTY
,0,DATE
,2.0,R8
,0.0);
7839 VARDIV(EMPTY
,0,BSTR
,num2_str
,R8
,0.0);
7840 VARDIV(EMPTY
,0,BOOL
,VARIANT_TRUE
,R8
,0.0);
7841 VARDIV(EMPTY
,0,UI1
,2,R8
,0.0);
7844 VARDIV(EMPTY
,0,I8
,2,R8
,0.0);
7846 VARDIV(NULL
,0,EMPTY
,0,NULL
,0);
7847 VARDIV(NULL
,0,NULL
,0,NULL
,0);
7848 VARDIV(NULL
,0,I2
,2,NULL
,0);
7849 VARDIV(NULL
,0,I4
,2,NULL
,0);
7850 VARDIV(NULL
,0,R4
,2.0f
,NULL
,0);
7851 VARDIV(NULL
,0,R8
,2.0,NULL
,0);
7852 VARDIV(NULL
,0,DATE
,2,NULL
,0);
7853 VARDIV(NULL
,0,BSTR
,num2_str
,NULL
,0);
7854 VARDIV(NULL
,0,BOOL
,VARIANT_TRUE
,NULL
,0);
7855 VARDIV(NULL
,0,UI1
,2,NULL
,0);
7858 VARDIV(NULL
,0,I8
,2,NULL
,0);
7860 VARDIV(I2
,2,NULL
,0,NULL
,0);
7861 VARDIV(I2
,1,I2
,2,R8
,0.5);
7862 VARDIV(I2
,1,I4
,2,R8
,0.5);
7863 VARDIV(I2
,1,R4
,2,R4
,0.5f
);
7864 VARDIV(I2
,1,R8
,2.0,R8
,0.5);
7865 VARDIV(I2
,1,DATE
,2,R8
,0.5);
7866 VARDIV(I2
,1,BOOL
,VARIANT_TRUE
,R8
,-1.0);
7867 VARDIV(I2
,1,UI1
,2,R8
,0.5);
7870 VARDIV(I2
,1,I8
,2,R8
,0.5);
7872 VARDIV(I4
,1,NULL
,0,NULL
,0);
7873 VARDIV(I4
,1,I2
,2,R8
,0.5);
7874 VARDIV(I4
,1,I4
,2,R8
,0.5);
7875 VARDIV(I4
,1,R4
,2.0f
,R8
,0.5);
7876 VARDIV(I4
,1,R8
,2.0,R8
,0.5);
7877 VARDIV(I4
,1,DATE
,2,R8
,0.5);
7878 VARDIV(I4
,1,BSTR
,num2_str
,R8
,0.5);
7879 VARDIV(I4
,1,BOOL
,VARIANT_TRUE
,R8
,-1.0);
7880 VARDIV(I4
,1,UI1
,2,R8
,0.5);
7883 VARDIV(I4
,1,I8
,2,R8
,0.5);
7885 VARDIV(R4
,1.0f
,NULL
,0,NULL
,0);
7886 VARDIV(R4
,1.0f
,I2
,2,R4
,0.5f
);
7887 VARDIV(R4
,1.0f
,I4
,2,R8
,0.5);
7888 VARDIV(R4
,1.0f
,R4
,2.0f
,R4
,0.5f
);
7889 VARDIV(R4
,1.0f
,R8
,2.0,R8
,0.5);
7890 VARDIV(R4
,1.0f
,DATE
,2,R8
,0.5);
7891 VARDIV(R4
,1.0f
,BSTR
,num2_str
,R8
,0.5);
7892 VARDIV(R4
,1.0f
,BOOL
,VARIANT_TRUE
,R4
,-1);
7893 VARDIV(R4
,1.0f
,UI1
,2,R4
,0.5f
);
7896 VARDIV(R4
,1.0f
,I8
,2,R8
,0.5);
7898 VARDIV(R8
,1.0,NULL
,0,NULL
,0);
7899 VARDIV(R8
,1.0,I2
,2,R8
,0.5);
7900 VARDIV(R8
,1.0,I4
,2,R8
,0.5);
7901 VARDIV(R8
,1.0,R4
,2.0f
,R8
,0.5);
7902 VARDIV(R8
,1.0,R8
,2.0,R8
,0.5);
7903 VARDIV(R8
,1.0,DATE
,2,R8
,0.5);
7904 VARDIV(R8
,1.0,BSTR
,num2_str
,R8
,0.5);
7905 VARDIV(R8
,1.0,BOOL
,VARIANT_TRUE
,R8
,-1.0);
7906 VARDIV(R8
,1.0,UI1
,2,R8
,0.5);
7909 VARDIV(R8
,1.0,I8
,2,R8
,0.5);
7911 VARDIV(DATE
,1,NULL
,0,NULL
,0);
7912 VARDIV(DATE
,1,I2
,2,R8
,0.5);
7913 VARDIV(DATE
,1,I4
,2,R8
,0.5);
7914 VARDIV(DATE
,1,R4
,2.0f
,R8
,0.5);
7915 VARDIV(DATE
,1,R8
,2.0,R8
,0.5);
7916 VARDIV(DATE
,1,DATE
,2,R8
,0.5);
7917 VARDIV(DATE
,1,BSTR
,num2_str
,R8
,0.5);
7918 VARDIV(DATE
,1,BOOL
,VARIANT_TRUE
,R8
,-1.0);
7919 VARDIV(DATE
,1,UI1
,2,R8
,0.5);
7922 VARDIV(DATE
,1,I8
,2,R8
,0.5);
7924 VARDIV(BSTR
,num1_str
,NULL
,0,NULL
,0);
7925 VARDIV(BSTR
,num1_str
,I2
,2,R8
,0.5);
7926 VARDIV(BSTR
,num1_str
,I4
,2,R8
,0.5);
7927 VARDIV(BSTR
,num1_str
,R4
,2.0f
,R8
,0.5);
7928 VARDIV(BSTR
,num1_str
,R8
,2.0,R8
,0.5);
7929 VARDIV(BSTR
,num1_str
,DATE
,2,R8
,0.5);
7930 VARDIV(BSTR
,num1_str
,BSTR
,num2_str
,R8
,0.5);
7931 VARDIV(BSTR
,num1_str
,BOOL
,VARIANT_TRUE
,R8
,-1);
7932 VARDIV(BSTR
,num1_str
,UI1
,2,R8
,0.5);
7935 VARDIV(BSTR
,num1_str
,I8
,2,R8
,0.5);
7937 VARDIV(BOOL
,VARIANT_TRUE
,NULL
,0,NULL
,0);
7938 VARDIV(BOOL
,VARIANT_TRUE
,I2
,1,R8
,-1.0);
7939 VARDIV(BOOL
,VARIANT_FALSE
,I2
,1,R8
,0.0);
7940 VARDIV(BOOL
,VARIANT_TRUE
,I4
,1,R8
,-1.0);
7941 VARDIV(BOOL
,VARIANT_FALSE
,I4
,1,R8
,0.0);
7942 VARDIV(BOOL
,VARIANT_TRUE
,R4
,1,R4
,-1.0f
);
7943 VARDIV(BOOL
,VARIANT_FALSE
,R4
,1,R4
,0.0f
);
7944 VARDIV(BOOL
,VARIANT_TRUE
,R8
,1.0,R8
,-1.0);
7945 VARDIV(BOOL
,VARIANT_FALSE
,R8
,1.0,R8
,0.0);
7946 VARDIV(BOOL
,VARIANT_FALSE
,DATE
,2,R8
,0.0);
7947 VARDIV(BOOL
,VARIANT_FALSE
,BSTR
,num2_str
,R8
,0.0);
7948 VARDIV(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
,R8
,1.0);
7949 VARDIV(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
,R8
,0.0);
7950 VARDIV(BOOL
,VARIANT_TRUE
,UI1
,1,R8
,-1.0);
7953 VARDIV(BOOL
,VARIANT_TRUE
,I8
,1,R8
,-1.0);
7955 VARDIV(UI1
,1,NULL
,0,NULL
,0);
7956 VARDIV(UI1
,1,I2
,2,R8
,0.5);
7957 VARDIV(UI1
,1,I4
,2,R8
,0.5);
7958 VARDIV(UI1
,1,R4
,2.0f
,R4
,0.5f
);
7959 VARDIV(UI1
,1,R8
,2.0,R8
,0.5);
7960 VARDIV(UI1
,1,DATE
,2,R8
,0.5);
7961 VARDIV(UI1
,1,BSTR
,num2_str
,R8
,0.5);
7962 VARDIV(UI1
,1,BOOL
,VARIANT_TRUE
,R8
,-1);
7963 VARDIV(UI1
,1,UI1
,2,R8
,0.5);
7966 VARDIV(UI1
,1,I8
,2,R8
,0.5);
7967 VARDIV(I8
,1,NULL
,0,NULL
,0);
7968 VARDIV(I8
,1,I2
,2,R8
,0.5);
7969 VARDIV(I8
,1,I4
,2,R8
,0.5);
7970 VARDIV(I8
,1,R4
,2.0f
,R8
,0.5);
7971 VARDIV(I8
,1,R8
,2.0,R8
,0.5);
7972 VARDIV(I8
,1,DATE
,2,R8
,0.5);
7973 VARDIV(I8
,1,BSTR
,num2_str
,R8
,0.5);
7974 VARDIV(I8
,1,BOOL
,VARIANT_TRUE
,R8
,-1);
7975 VARDIV(I8
,1,UI1
,2,R8
,0.5);
7976 VARDIV(I8
,1,I8
,2,R8
,0.5);
7979 /* Manually test some VT_CY, VT_DECIMAL variants */
7981 hres
= VarCyFromI4(10000, &V_CY(&cy
));
7982 ok(hres
== S_OK
, "VarCyFromI4 failed!\n");
7983 V_VT(&dec
) = VT_DECIMAL
;
7984 hres
= VarDecFromR8(2.0, &V_DECIMAL(&dec
));
7985 ok(hres
== S_OK
, "VarDecFromR4 failed!\n");
7986 memset(&left
, 0, sizeof(left
));
7987 memset(&right
, 0, sizeof(right
));
7988 V_VT(&left
) = VT_I4
;
7990 V_VT(&right
) = VT_UI1
;
7993 hres
= pVarDiv(&cy
, &cy
, &result
);
7994 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
7995 "VARDIV: expected coerced type VT_R8, got %s!\n", vtstr(V_VT(&result
)));
7996 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 1.0),
7997 "VARDIV: CY value %f, expected %f\n", V_R8(&result
), 1.0);
7999 hres
= pVarDiv(&cy
, &right
, &result
);
8000 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
8001 "VARDIV: expected coerced type VT_R8, got %s!\n", vtstr(V_VT(&result
)));
8002 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 5000.0),
8003 "VARDIV: CY value %f, expected %f\n", V_R8(&result
), 5000.0);
8005 hres
= pVarDiv(&left
, &cy
, &result
);
8006 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
8007 "VARDIV: expected coerced type VT_R8, got %s!\n", vtstr(V_VT(&result
)));
8008 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 0.01),
8009 "VARDIV: CY value %f, expected %f\n", V_R8(&result
), 0.01);
8011 hres
= pVarDiv(&left
, &dec
, &result
);
8012 ok(hres
== S_OK
&& V_VT(&result
) == VT_DECIMAL
,
8013 "VARDIV: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result
)));
8014 hres
= VarR8FromDec(&V_DECIMAL(&result
), &r
);
8015 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 50.0), "VARDIV: DECIMAL value %f, expected %f\n", r
, 50.0);
8017 hres
= pVarDiv(&dec
, &dec
, &result
);
8018 ok(hres
== S_OK
&& V_VT(&result
) == VT_DECIMAL
,
8019 "VARDIV: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result
)));
8020 hres
= VarR8FromDec(&V_DECIMAL(&result
), &r
);
8021 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 1.0), "VARDIV: DECIMAL value %f, expected %f\n", r
, 1.0);
8023 hres
= pVarDiv(&dec
, &right
, &result
);
8024 ok(hres
== S_OK
&& V_VT(&result
) == VT_DECIMAL
,
8025 "VARDIV: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result
)));
8026 hres
= VarR8FromDec(&V_DECIMAL(&result
), &r
);
8027 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 1.0), "VARDIV: DECIMAL value %f, expected %f\n", r
, 1.0);
8029 /* Check for division by zero and overflow */
8030 V_VT(&left
) = VT_R8
;
8032 V_VT(&right
) = VT_R8
;
8034 hres
= pVarDiv(&left
, &right
, &result
);
8035 ok(hres
== DISP_E_DIVBYZERO
&& V_VT(&result
) == VT_EMPTY
,
8036 "VARDIV: Division by (1.0/0.0) should result in DISP_E_DIVBYZERO but got 0x%X\n", hres
);
8038 V_VT(&left
) = VT_R8
;
8040 V_VT(&right
) = VT_R8
;
8042 hres
= pVarDiv(&left
, &right
, &result
);
8043 ok(hres
== DISP_E_OVERFLOW
&& V_VT(&result
) == VT_EMPTY
,
8044 "VARDIV: Division by (0.0/0.0) should result in DISP_E_OVERFLOW but got 0x%X\n", hres
);
8046 SysFreeString(num1_str
);
8047 SysFreeString(num2_str
);
8050 static HRESULT (WINAPI
*pVarIdiv
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
8052 #define VARIDIV(vt1,val1,vt2,val2,rvt,rval) \
8053 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
8054 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
8055 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
8056 test_var_call2( __LINE__, pVarIdiv, &left, &right, &exp )
8058 /* Skip any type that is not defined or produces an error for every case */
8059 #define SKIPTESTIDIV(a) \
8060 if (a == VT_ERROR || a == VT_VARIANT || \
8061 a == VT_DISPATCH || a == VT_UNKNOWN || \
8062 a == VT_RECORD || a > VT_UINT || \
8063 a == 15 /*not defined*/) \
8066 static void test_VarIdiv(void)
8068 static const WCHAR str1
[] = { '1','\0' };
8069 static const WCHAR str2
[] = { '2','\0' };
8070 VARIANT left
, right
, exp
, result
, cy
, dec
;
8071 BSTR num1_str
, num2_str
;
8077 num1_str
= SysAllocString(str1
);
8078 num2_str
= SysAllocString(str2
);
8080 /* Test all possible flag/vt combinations & the resulting vt type */
8081 for (i
= 0; i
< ARRAY_SIZE(ExtraFlags
); i
++)
8083 VARTYPE leftvt
, rightvt
, resvt
;
8085 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
8087 SKIPTESTIDIV(leftvt
);
8089 /* Check if we need/have support for I8 and/or UI8 */
8090 if ((leftvt
== VT_I8
|| leftvt
== VT_UI8
) && !has_i8
)
8093 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
8096 SKIPTESTIDIV(rightvt
);
8098 /* Native crashes with extra flag VT_BYREF */
8099 if (ExtraFlags
[i
] == VT_BYREF
)
8102 /* Check if we need/have support for I8 and/or UI8 */
8103 if ((rightvt
== VT_I8
|| rightvt
== VT_UI8
) && !has_i8
)
8106 memset(&left
, 0, sizeof(left
));
8107 memset(&right
, 0, sizeof(right
));
8108 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
8109 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
8110 V_VT(&result
) = VT_EMPTY
;
8113 if (leftvt
== VT_BSTR
)
8114 V_BSTR(&left
) = num2_str
;
8115 else if (leftvt
== VT_DECIMAL
)
8117 VarDecFromR8(2.0, &V_DECIMAL(&left
));
8118 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
8121 /* Division by 0 is undefined */
8125 V_BSTR(&right
) = num2_str
;
8128 VarDecFromR8(2.0, &V_DECIMAL(&right
));
8129 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
8132 V_BOOL(&right
) = VARIANT_TRUE
;
8135 VarCyFromI4(10000, &V_CY(&right
));
8136 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
8138 case VT_I2
: V_I2(&right
) = 2; break;
8139 case VT_I4
: V_I4(&right
) = 2; break;
8140 case VT_R4
: V_R4(&right
) = 2.0f
; break;
8141 case VT_R8
: V_R8(&right
) = 2.0; break;
8142 case VT_DATE
: V_DATE(&right
) = 2; break;
8143 case VT_I1
: V_I1(&right
) = 2; break;
8144 case VT_UI1
: V_UI1(&right
) = 2; break;
8145 case VT_UI2
: V_UI2(&right
) = 2; break;
8146 case VT_UI4
: V_UI4(&right
) = 2; break;
8147 case VT_I8
: V_I8(&right
) = 2; break;
8148 case VT_UI8
: V_UI8(&right
) = 2; break;
8149 case VT_INT
: V_INT(&right
) = 2; break;
8150 case VT_UINT
: V_UINT(&right
) = 2; break;
8154 /* Native VarIdiv always returns an error when using extra
8155 * flags or if the variant combination is I8 and INT.
8157 if ((leftvt
== VT_I8
&& rightvt
== VT_INT
) ||
8158 (leftvt
== VT_INT
&& rightvt
== VT_I8
) ||
8159 (rightvt
== VT_EMPTY
&& leftvt
!= VT_NULL
) ||
8163 /* Determine variant type */
8164 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
8166 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
8168 else if (leftvt
== VT_I4
|| rightvt
== VT_I4
||
8169 leftvt
== VT_INT
|| rightvt
== VT_INT
||
8170 leftvt
== VT_UINT
|| rightvt
== VT_UINT
||
8171 leftvt
== VT_UI8
|| rightvt
== VT_UI8
||
8172 leftvt
== VT_UI4
|| rightvt
== VT_UI4
||
8173 leftvt
== VT_UI2
|| rightvt
== VT_UI2
||
8174 leftvt
== VT_I1
|| rightvt
== VT_I1
||
8175 leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
||
8176 leftvt
== VT_DATE
|| rightvt
== VT_DATE
||
8177 leftvt
== VT_CY
|| rightvt
== VT_CY
||
8178 leftvt
== VT_DECIMAL
|| rightvt
== VT_DECIMAL
||
8179 leftvt
== VT_R8
|| rightvt
== VT_R8
||
8180 leftvt
== VT_R4
|| rightvt
== VT_R4
)
8182 else if (leftvt
== VT_I2
|| rightvt
== VT_I2
||
8183 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
||
8186 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
8191 hres
= pVarIdiv(&left
, &right
, &result
);
8193 /* Check expected HRESULT and if result variant type is correct */
8195 ok (hres
== DISP_E_BADVARTYPE
|| hres
== DISP_E_TYPEMISMATCH
||
8196 hres
== DISP_E_DIVBYZERO
,
8197 "VarIdiv: %s|0x%X, %s|0x%X: got vt %s hr 0x%X\n",
8198 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
],
8199 vtstr(V_VT(&result
)), hres
);
8201 ok (hres
== S_OK
&& resvt
== V_VT(&result
),
8202 "VarIdiv: %s|0x%X, %s|0x%X: expected vt %s hr 0x%X, got vt %s hr 0x%X\n",
8203 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
], vtstr(resvt
),
8204 S_OK
, vtstr(V_VT(&result
)), hres
);
8209 /* Test return values for all the good cases */
8210 VARIDIV(EMPTY
,0,NULL
,0,NULL
,0);
8211 VARIDIV(EMPTY
,0,I2
,1,I2
,0);
8212 VARIDIV(EMPTY
,0,I4
,1,I4
,0);
8213 VARIDIV(EMPTY
,0,R4
,1.0f
,I4
,0);
8214 VARIDIV(EMPTY
,0,R8
,1.0,I4
,0);
8215 VARIDIV(EMPTY
,0,DATE
,1.0,I4
,0);
8216 VARIDIV(EMPTY
,0,BSTR
,num1_str
,I4
,0);
8217 VARIDIV(EMPTY
,0,BOOL
,VARIANT_TRUE
,I2
,0);
8218 VARIDIV(EMPTY
,0,I1
,1,I4
,0);
8219 VARIDIV(EMPTY
,0,UI1
,1,I2
,0);
8220 VARIDIV(EMPTY
,0,UI2
,1,I4
,0);
8221 VARIDIV(EMPTY
,0,UI4
,1,I4
,0);
8224 VARIDIV(EMPTY
,0,I8
,1,I8
,0);
8225 VARIDIV(EMPTY
,0,UI8
,1,I4
,0);
8227 VARIDIV(EMPTY
,0,INT
,1,I4
,0);
8228 VARIDIV(EMPTY
,0,UINT
,1,I4
,0);
8229 VARIDIV(NULL
,0,EMPTY
,0,NULL
,0);
8230 VARIDIV(NULL
,0,NULL
,0,NULL
,0);
8231 VARIDIV(NULL
,0,I2
,1,NULL
,0);
8232 VARIDIV(NULL
,0,I4
,1,NULL
,0);
8233 VARIDIV(NULL
,0,R4
,1,NULL
,0);
8234 VARIDIV(NULL
,0,R8
,1,NULL
,0);
8235 VARIDIV(NULL
,0,DATE
,1,NULL
,0);
8236 VARIDIV(NULL
,0,BSTR
,num1_str
,NULL
,0);
8237 VARIDIV(NULL
,0,BOOL
,VARIANT_TRUE
,NULL
,0);
8238 VARIDIV(NULL
,0,I1
,1,NULL
,0);
8239 VARIDIV(NULL
,0,UI1
,1,NULL
,0);
8240 VARIDIV(NULL
,0,UI2
,1,NULL
,0);
8241 VARIDIV(NULL
,0,UI4
,1,NULL
,0);
8244 VARIDIV(NULL
,0,I8
,1,NULL
,0);
8245 VARIDIV(NULL
,0,UI8
,1,NULL
,0);
8247 VARIDIV(NULL
,0,INT
,1,NULL
,0);
8248 VARIDIV(NULL
,0,UINT
,1,NULL
,0);
8249 VARIDIV(I2
,2,NULL
,0,NULL
,0);
8250 VARIDIV(I2
,2,I2
,1,I2
,2);
8251 VARIDIV(I2
,2,I4
,1,I4
,2);
8252 VARIDIV(I2
,2,R4
,1,I4
,2);
8253 VARIDIV(I2
,2,R8
,1,I4
,2);
8254 VARIDIV(I2
,2,DATE
,1,I4
,2);
8255 VARIDIV(I2
,2,BSTR
,num1_str
,I4
,2);
8256 VARIDIV(I2
,2,BOOL
,VARIANT_TRUE
,I2
,-2);
8257 VARIDIV(I2
,2,I1
,1,I4
,2);
8258 VARIDIV(I2
,2,UI1
,1,I2
,2);
8259 VARIDIV(I2
,2,UI2
,1,I4
,2);
8260 VARIDIV(I2
,2,UI4
,1,I4
,2);
8263 VARIDIV(I2
,2,I8
,1,I8
,2);
8264 VARIDIV(I2
,2,UI8
,1,I4
,2);
8266 VARIDIV(I2
,2,INT
,1,I4
,2);
8267 VARIDIV(I2
,2,UINT
,1,I4
,2);
8268 VARIDIV(I4
,2,NULL
,0,NULL
,0);
8269 VARIDIV(I4
,2,I2
,1,I4
,2);
8270 VARIDIV(I4
,2,I4
,1,I4
,2);
8271 VARIDIV(I4
,2,R4
,1,I4
,2);
8272 VARIDIV(I4
,2,R8
,1,I4
,2);
8273 VARIDIV(I4
,2,DATE
,1,I4
,2);
8274 VARIDIV(I4
,2,BSTR
,num1_str
,I4
,2);
8275 VARIDIV(I4
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
8276 VARIDIV(I4
,2,I1
,1,I4
,2);
8277 VARIDIV(I4
,2,UI1
,1,I4
,2);
8278 VARIDIV(I4
,2,UI2
,1,I4
,2);
8279 VARIDIV(I4
,2,UI4
,1,I4
,2);
8282 VARIDIV(I4
,2,I8
,1,I8
,2);
8283 VARIDIV(I4
,2,UI8
,1,I4
,2);
8285 VARIDIV(I4
,2,INT
,1,I4
,2);
8286 VARIDIV(I4
,2,UINT
,1,I4
,2);
8287 VARIDIV(R4
,2.0f
,NULL
,0,NULL
,0);
8288 VARIDIV(R4
,2.0f
,I2
,1,I4
,2);
8289 VARIDIV(R4
,2.0f
,I4
,1,I4
,2);
8290 VARIDIV(R4
,2.0f
,R4
,1.0f
,I4
,2);
8291 VARIDIV(R4
,2.0f
,R8
,1.0,I4
,2);
8292 VARIDIV(R4
,2.0f
,DATE
,1,I4
,2);
8293 VARIDIV(R4
,2.0f
,BSTR
,num1_str
,I4
,2);
8294 VARIDIV(R4
,2.0f
,BOOL
,VARIANT_TRUE
,I4
,-2);
8295 VARIDIV(R4
,2.0f
,I1
,1,I4
,2);
8296 VARIDIV(R4
,2.0f
,UI1
,1,I4
,2);
8297 VARIDIV(R4
,2.0f
,UI2
,1,I4
,2);
8298 VARIDIV(R4
,2.0f
,UI4
,1,I4
,2);
8301 VARIDIV(R4
,2.0f
,I8
,1,I8
,2);
8302 VARIDIV(R4
,2.0f
,UI8
,1,I4
,2);
8304 VARIDIV(R4
,2.0f
,INT
,1,I4
,2);
8305 VARIDIV(R4
,2.0f
,UINT
,1,I4
,2);
8306 VARIDIV(R8
,2.0,NULL
,0,NULL
,0);
8307 VARIDIV(R8
,2.0,I2
,1,I4
,2);
8308 VARIDIV(R8
,2.0,I4
,1,I4
,2);
8309 VARIDIV(R8
,2.0,R4
,1,I4
,2);
8310 VARIDIV(R8
,2.0,R8
,1,I4
,2);
8311 VARIDIV(R8
,2.0,DATE
,1,I4
,2);
8312 VARIDIV(R8
,2.0,BSTR
,num1_str
,I4
,2);
8313 VARIDIV(R8
,2.0,BOOL
,VARIANT_TRUE
,I4
,-2);
8314 VARIDIV(R8
,2.0,I1
,1,I4
,2);
8315 VARIDIV(R8
,2.0,UI1
,1,I4
,2);
8316 VARIDIV(R8
,2.0,UI2
,1,I4
,2);
8317 VARIDIV(R8
,2.0,UI4
,1,I4
,2);
8320 VARIDIV(R8
,2.0,I8
,1,I8
,2);
8321 VARIDIV(R8
,2.0,UI8
,1,I4
,2);
8323 VARIDIV(R8
,2.0,INT
,1,I4
,2);
8324 VARIDIV(R8
,2.0,UINT
,1,I4
,2);
8325 VARIDIV(DATE
,2,NULL
,0,NULL
,0);
8326 VARIDIV(DATE
,2,I2
,1,I4
,2);
8327 VARIDIV(DATE
,2,I4
,1,I4
,2);
8328 VARIDIV(DATE
,2,R4
,1,I4
,2);
8329 VARIDIV(DATE
,2,R8
,1,I4
,2);
8330 VARIDIV(DATE
,2,DATE
,1,I4
,2);
8331 VARIDIV(DATE
,2,BSTR
,num1_str
,I4
,2);
8332 VARIDIV(DATE
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
8333 VARIDIV(DATE
,2,I1
,1,I4
,2);
8334 VARIDIV(DATE
,2,UI1
,1,I4
,2);
8335 VARIDIV(DATE
,2,UI2
,1,I4
,2);
8336 VARIDIV(DATE
,2,UI4
,1,I4
,2);
8339 VARIDIV(DATE
,2,I8
,1,I8
,2);
8340 VARIDIV(DATE
,2,UI8
,1,I4
,2);
8342 VARIDIV(DATE
,2,INT
,1,I4
,2);
8343 VARIDIV(DATE
,2,UINT
,1,I4
,2);
8344 VARIDIV(BSTR
,num2_str
,NULL
,0,NULL
,0);
8345 VARIDIV(BSTR
,num2_str
,I2
,1,I4
,2);
8346 VARIDIV(BSTR
,num2_str
,I4
,1,I4
,2);
8347 VARIDIV(BSTR
,num2_str
,R4
,1.0f
,I4
,2);
8348 VARIDIV(BSTR
,num2_str
,R8
,1.0,I4
,2);
8349 VARIDIV(BSTR
,num2_str
,DATE
,1,I4
,2);
8350 VARIDIV(BSTR
,num2_str
,BSTR
,num1_str
,I4
,2);
8351 VARIDIV(BSTR
,num2_str
,BOOL
,VARIANT_TRUE
,I4
,-2);
8352 VARIDIV(BSTR
,num2_str
,I1
,1,I4
,2);
8353 VARIDIV(BSTR
,num2_str
,UI1
,1,I4
,2);
8354 VARIDIV(BSTR
,num2_str
,UI2
,1,I4
,2);
8355 VARIDIV(BSTR
,num2_str
,UI4
,1,I4
,2);
8358 VARIDIV(BSTR
,num2_str
,I8
,1,I8
,2);
8359 VARIDIV(BSTR
,num2_str
,UI8
,1,I4
,2);
8361 VARIDIV(BSTR
,num2_str
,INT
,1,I4
,2);
8362 VARIDIV(BSTR
,num2_str
,UINT
,1,I4
,2);
8363 VARIDIV(BOOL
,VARIANT_TRUE
,NULL
,0,NULL
,0);
8364 VARIDIV(BOOL
,VARIANT_TRUE
,I2
,1,I2
,-1);
8365 VARIDIV(BOOL
,VARIANT_TRUE
,I4
,1,I4
,-1);
8366 VARIDIV(BOOL
,VARIANT_TRUE
,R4
,1.0f
,I4
,-1);
8367 VARIDIV(BOOL
,VARIANT_TRUE
,R8
,1.0,I4
,-1);
8368 VARIDIV(BOOL
,VARIANT_TRUE
,DATE
,1,I4
,-1);
8369 VARIDIV(BOOL
,VARIANT_TRUE
,BSTR
,num1_str
,I4
,-1);
8370 VARIDIV(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
,I2
,1);
8371 VARIDIV(BOOL
,VARIANT_TRUE
,I1
,1,I4
,-1);
8372 VARIDIV(BOOL
,VARIANT_TRUE
,UI1
,1,I2
,-1);
8373 VARIDIV(BOOL
,VARIANT_TRUE
,UI2
,1,I4
,-1);
8374 VARIDIV(BOOL
,VARIANT_TRUE
,UI4
,1,I4
,-1);
8377 VARIDIV(BOOL
,VARIANT_TRUE
,I8
,1,I8
,-1);
8378 VARIDIV(BOOL
,VARIANT_TRUE
,UI8
,1,I4
,-1);
8380 VARIDIV(BOOL
,VARIANT_TRUE
,INT
,1,I4
,-1);
8381 VARIDIV(BOOL
,VARIANT_TRUE
,UINT
,1,I4
,-1);
8382 VARIDIV(I1
,2,NULL
,0,NULL
,0);
8383 VARIDIV(I1
,2,I2
,1,I4
,2);
8384 VARIDIV(I1
,2,I4
,1,I4
,2);
8385 VARIDIV(I1
,2,R4
,1.0f
,I4
,2);
8386 VARIDIV(I1
,2,R8
,1.0,I4
,2);
8387 VARIDIV(I1
,2,DATE
,1,I4
,2);
8388 VARIDIV(I1
,2,BSTR
,num1_str
,I4
,2);
8389 VARIDIV(I1
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
8390 VARIDIV(I1
,2,I1
,1,I4
,2);
8391 VARIDIV(I1
,2,UI1
,1,I4
,2);
8392 VARIDIV(I1
,2,UI2
,1,I4
,2);
8393 VARIDIV(I1
,2,UI4
,1,I4
,2);
8396 VARIDIV(I1
,2,I8
,1,I8
,2);
8397 VARIDIV(I1
,2,UI8
,1,I4
,2);
8399 VARIDIV(I1
,2,INT
,1,I4
,2);
8400 VARIDIV(I1
,2,UINT
,1,I4
,2);
8401 VARIDIV(UI1
,2,NULL
,0,NULL
,0);
8402 VARIDIV(UI1
,2,I2
,1,I2
,2);
8403 VARIDIV(UI1
,2,I4
,1,I4
,2);
8404 VARIDIV(UI1
,2,R4
,1.0f
,I4
,2);
8405 VARIDIV(UI1
,2,R8
,1.0,I4
,2);
8406 VARIDIV(UI1
,2,DATE
,1,I4
,2);
8407 VARIDIV(UI1
,2,BSTR
,num1_str
,I4
,2);
8408 VARIDIV(UI1
,2,BOOL
,VARIANT_TRUE
,I2
,-2);
8409 VARIDIV(UI1
,2,I1
,1,I4
,2);
8410 VARIDIV(UI1
,2,UI1
,1,UI1
,2);
8411 VARIDIV(UI1
,2,UI2
,1,I4
,2);
8412 VARIDIV(UI1
,2,UI4
,1,I4
,2);
8415 VARIDIV(UI1
,2,I8
,1,I8
,2);
8416 VARIDIV(UI1
,2,UI8
,1,I4
,2);
8418 VARIDIV(UI1
,2,INT
,1,I4
,2);
8419 VARIDIV(UI1
,2,UINT
,1,I4
,2);
8420 VARIDIV(UI2
,2,NULL
,0,NULL
,0);
8421 VARIDIV(UI2
,2,I2
,1,I4
,2);
8422 VARIDIV(UI2
,2,I4
,1,I4
,2);
8423 VARIDIV(UI2
,2,R4
,1.0f
,I4
,2);
8424 VARIDIV(UI2
,2,R8
,1.0,I4
,2);
8425 VARIDIV(UI2
,2,DATE
,1,I4
,2);
8426 VARIDIV(UI2
,2,BSTR
,num1_str
,I4
,2);
8427 VARIDIV(UI2
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
8428 VARIDIV(UI2
,2,I1
,1,I4
,2);
8429 VARIDIV(UI2
,2,UI1
,1,I4
,2);
8430 VARIDIV(UI2
,2,UI2
,1,I4
,2);
8431 VARIDIV(UI2
,2,UI4
,1,I4
,2);
8434 VARIDIV(UI2
,2,I8
,1,I8
,2);
8435 VARIDIV(UI2
,2,UI8
,1,I4
,2);
8437 VARIDIV(UI2
,2,INT
,1,I4
,2);
8438 VARIDIV(UI2
,2,UINT
,1,I4
,2);
8439 VARIDIV(UI4
,2,NULL
,0,NULL
,0);
8440 VARIDIV(UI4
,2,I2
,1,I4
,2);
8441 VARIDIV(UI4
,2,I4
,1,I4
,2);
8442 VARIDIV(UI4
,2,R4
,1.0f
,I4
,2);
8443 VARIDIV(UI4
,2,R8
,1.0,I4
,2);
8444 VARIDIV(UI4
,2,DATE
,1,I4
,2);
8445 VARIDIV(UI4
,2,BSTR
,num1_str
,I4
,2);
8446 VARIDIV(UI4
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
8447 VARIDIV(UI4
,2,I1
,1,I4
,2);
8448 VARIDIV(UI4
,2,UI1
,1,I4
,2);
8449 VARIDIV(UI4
,2,UI2
,1,I4
,2);
8450 VARIDIV(UI4
,2,UI4
,1,I4
,2);
8453 VARIDIV(UI4
,2,I8
,1,I8
,2);
8454 VARIDIV(UI4
,2,UI8
,1,I4
,2);
8456 VARIDIV(UI4
,2,INT
,1,I4
,2);
8457 VARIDIV(UI4
,2,UINT
,1,I4
,2);
8460 VARIDIV(I8
,2,NULL
,0,NULL
,0);
8461 VARIDIV(I8
,2,I2
,1,I8
,2);
8462 VARIDIV(I8
,2,I4
,1,I8
,2);
8463 VARIDIV(I8
,2,R4
,1.0f
,I8
,2);
8464 VARIDIV(I8
,2,R8
,1.0,I8
,2);
8465 VARIDIV(I8
,2,DATE
,1,I8
,2);
8466 VARIDIV(I8
,2,BSTR
,num1_str
,I8
,2);
8467 VARIDIV(I8
,2,BOOL
,1,I8
,2);
8468 VARIDIV(I8
,2,I1
,1,I8
,2);
8469 VARIDIV(I8
,2,UI1
,1,I8
,2);
8470 VARIDIV(I8
,2,UI2
,1,I8
,2);
8471 VARIDIV(I8
,2,UI4
,1,I8
,2);
8472 VARIDIV(I8
,2,I8
,1,I8
,2);
8473 VARIDIV(I8
,2,UI8
,1,I8
,2);
8474 VARIDIV(I8
,2,UINT
,1,I8
,2);
8475 VARIDIV(UI8
,2,NULL
,0,NULL
,0);
8476 VARIDIV(UI8
,2,I2
,1,I4
,2);
8477 VARIDIV(UI8
,2,I4
,1,I4
,2);
8478 VARIDIV(UI8
,2,R4
,1.0f
,I4
,2);
8479 VARIDIV(UI8
,2,R8
,1.0,I4
,2);
8480 VARIDIV(UI8
,2,DATE
,1,I4
,2);
8481 VARIDIV(UI8
,2,BSTR
,num1_str
,I4
,2);
8482 VARIDIV(UI8
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
8483 VARIDIV(UI8
,2,I1
,1,I4
,2);
8484 VARIDIV(UI8
,2,UI1
,1,I4
,2);
8485 VARIDIV(UI8
,2,UI2
,1,I4
,2);
8486 VARIDIV(UI8
,2,UI4
,1,I4
,2);
8487 VARIDIV(UI8
,2,I8
,1,I8
,2);
8488 VARIDIV(UI8
,2,UI8
,1,I4
,2);
8489 VARIDIV(UI8
,2,INT
,1,I4
,2);
8490 VARIDIV(UI8
,2,UINT
,1,I4
,2);
8492 VARIDIV(INT
,2,NULL
,0,NULL
,0);
8493 VARIDIV(INT
,2,I2
,1,I4
,2);
8494 VARIDIV(INT
,2,I4
,1,I4
,2);
8495 VARIDIV(INT
,2,R4
,1.0f
,I4
,2);
8496 VARIDIV(INT
,2,R8
,1.0,I4
,2);
8497 VARIDIV(INT
,2,DATE
,1,I4
,2);
8498 VARIDIV(INT
,2,BSTR
,num1_str
,I4
,2);
8499 VARIDIV(INT
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
8500 VARIDIV(INT
,2,I1
,1,I4
,2);
8501 VARIDIV(INT
,2,UI1
,1,I4
,2);
8502 VARIDIV(INT
,2,UI2
,1,I4
,2);
8503 VARIDIV(INT
,2,UI4
,1,I4
,2);
8506 VARIDIV(INT
,2,UI8
,1,I4
,2);
8508 VARIDIV(INT
,2,INT
,1,I4
,2);
8509 VARIDIV(INT
,2,UINT
,1,I4
,2);
8510 VARIDIV(UINT
,2,NULL
,0,NULL
,0);
8511 VARIDIV(UINT
,2,I2
,1,I4
,2);
8512 VARIDIV(UINT
,2,I4
,1,I4
,2);
8513 VARIDIV(UINT
,2,R4
,1.0f
,I4
,2);
8514 VARIDIV(UINT
,2,R8
,1.0,I4
,2);
8515 VARIDIV(UINT
,2,DATE
,1,I4
,2);
8516 VARIDIV(UINT
,2,BSTR
,num1_str
,I4
,2);
8517 VARIDIV(UINT
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
8518 VARIDIV(UINT
,2,I1
,1,I4
,2);
8519 VARIDIV(UINT
,2,UI1
,1,I4
,2);
8520 VARIDIV(UINT
,2,UI2
,1,I4
,2);
8521 VARIDIV(UINT
,2,UI4
,1,I4
,2);
8524 VARIDIV(UINT
,2,I8
,1,I8
,2);
8525 VARIDIV(UINT
,2,UI8
,1,I4
,2);
8527 VARIDIV(UINT
,2,INT
,1,I4
,2);
8528 VARIDIV(UINT
,2,UINT
,1,I4
,2);
8530 /* Manually test some VT_CY, VT_DECIMAL variants */
8532 hres
= VarCyFromI4(10000, &V_CY(&cy
));
8533 ok(hres
== S_OK
, "VarCyFromI4 failed!\n");
8534 V_VT(&dec
) = VT_DECIMAL
;
8535 hres
= VarDecFromR8(2.0, &V_DECIMAL(&dec
));
8536 ok(hres
== S_OK
, "VarDecFromR4 failed!\n");
8537 memset(&left
, 0, sizeof(left
));
8538 memset(&right
, 0, sizeof(right
));
8539 V_VT(&left
) = VT_I4
;
8541 V_VT(&right
) = VT_I8
;
8544 hres
= pVarIdiv(&cy
, &cy
, &result
);
8545 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
8546 "VARIDIV: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8547 S_OK
, hres
, vtstr(V_VT(&result
)));
8548 ok(hres
== S_OK
&& V_I4(&result
) == 1,
8549 "VARIDIV: CY value %d, expected %d\n", V_I4(&result
), 1);
8553 hres
= pVarIdiv(&cy
, &right
, &result
);
8554 ok(hres
== S_OK
&& V_VT(&result
) == VT_I8
,
8555 "VARIDIV: expected coerced hres 0x%X type VT_I8, got hres 0x%X type %s!\n",
8556 S_OK
, hres
, vtstr(V_VT(&result
)));
8557 ok(hres
== S_OK
&& V_I8(&result
) == 5000,
8558 "VARIDIV: CY value 0x%x%08x, expected 0x%x\n",
8559 (DWORD
)(V_I8(&result
) >>32), (DWORD
)V_I8(&result
), 5000);
8562 hres
= pVarIdiv(&left
, &cy
, &result
);
8563 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
8564 "VARIDIV: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8565 S_OK
, hres
, vtstr(V_VT(&result
)));
8566 ok(hres
== S_OK
&& V_I4(&result
) == 0,
8567 "VARIDIV: CY value %d, expected %d\n", V_I4(&result
), 0);
8569 hres
= pVarIdiv(&left
, &dec
, &result
);
8570 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
8571 "VARIDIV: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8572 S_OK
, hres
, vtstr(V_VT(&result
)));
8573 ok(hres
== S_OK
&& V_I4(&result
) == 50,
8574 "VARIDIV: DECIMAL value %d, expected %d\n", V_I4(&result
), 50);
8576 hres
= pVarIdiv(&dec
, &dec
, &result
);
8577 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
8578 "VARIDIV: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8579 S_OK
, hres
, vtstr(V_VT(&result
)));
8580 ok(hres
== S_OK
&& V_I4(&result
) == 1,
8581 "VARIDIV: DECIMAL value %d, expected %d\n", V_I4(&result
), 1);
8585 hres
= pVarIdiv(&dec
, &right
, &result
);
8586 ok(hres
== S_OK
&& V_VT(&result
) == VT_I8
,
8587 "VARIDIV: expected coerced hres 0x%X type VT_I8, got hres 0x%X type %s!\n",
8588 S_OK
, hres
, vtstr(V_VT(&result
)));
8589 ok(hres
== S_OK
&& V_I8(&result
) == 1,
8590 "VARIDIV: DECIMAL value 0x%x%08x, expected %d\n",
8591 (DWORD
)(V_I8(&result
) >> 32), (DWORD
)V_I8(&result
), 1);
8594 /* Check for division by zero */
8595 V_VT(&left
) = VT_INT
;
8597 V_VT(&right
) = VT_INT
;
8599 hres
= pVarIdiv(&left
, &right
, &result
);
8600 ok(hres
== DISP_E_DIVBYZERO
&& V_VT(&result
) == VT_EMPTY
,
8601 "VARIDIV: Division by 0 should result in DISP_E_DIVBYZERO but got 0x%X\n", hres
);
8603 V_VT(&left
) = VT_INT
;
8605 V_VT(&right
) = VT_INT
;
8607 hres
= pVarIdiv(&left
, &right
, &result
);
8608 ok(hres
== DISP_E_DIVBYZERO
&& V_VT(&result
) == VT_EMPTY
,
8609 "VARIDIV: Division by 0 should result in DISP_E_DIVBYZERO but got 0x%X\n", hres
);
8611 SysFreeString(num1_str
);
8612 SysFreeString(num2_str
);
8616 static HRESULT (WINAPI
*pVarImp
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
8618 #define VARIMP(vt1,val1,vt2,val2,rvt,rval) \
8619 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
8620 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
8621 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
8622 test_var_call2( __LINE__, pVarImp, &left, &right, &exp )
8624 /* Skip any type that is not defined or produces an error for every case */
8625 #define SKIPTESTIMP(a) \
8626 if (a == VT_ERROR || a == VT_VARIANT || \
8627 a == VT_DISPATCH || a == VT_UNKNOWN || \
8628 a == VT_RECORD || a > VT_UINT || \
8629 a == 15 /*not defined*/) \
8632 static void test_VarImp(void)
8634 static const WCHAR szFalse
[] = { '#','F','A','L','S','E','#','\0' };
8635 static const WCHAR szTrue
[] = { '#','T','R','U','E','#','\0' };
8636 VARIANT left
, right
, exp
, result
, cy
, dec
;
8637 BSTR true_str
, false_str
;
8643 true_str
= SysAllocString(szTrue
);
8644 false_str
= SysAllocString(szFalse
);
8646 /* Test all possible flag/vt combinations & the resulting vt type */
8647 for (i
= 0; i
< ARRAY_SIZE(ExtraFlags
); i
++)
8649 VARTYPE leftvt
, rightvt
, resvt
;
8651 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
8653 SKIPTESTIMP(leftvt
);
8655 /* Check if we need/have support for I8 and/or UI8 */
8656 if ((leftvt
== VT_I8
|| leftvt
== VT_UI8
) && !has_i8
)
8659 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
8662 SKIPTESTIMP(rightvt
);
8664 /* Native crashes when using the extra flag VT_BYREF
8665 * or with the following VT combinations
8667 if ((leftvt
== VT_UI4
&& rightvt
== VT_BSTR
) ||
8668 (leftvt
== VT_UI8
&& rightvt
== VT_BSTR
) ||
8669 ExtraFlags
[i
] == VT_BYREF
)
8672 /* Check if we need/have support for I8 and/or UI8 */
8673 if ((rightvt
== VT_I8
|| rightvt
== VT_UI8
) && !has_i8
)
8676 memset(&left
, 0, sizeof(left
));
8677 memset(&right
, 0, sizeof(right
));
8678 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
8679 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
8680 V_VT(&result
) = VT_EMPTY
;
8683 if (leftvt
== VT_BSTR
)
8684 V_BSTR(&left
) = true_str
;
8686 /* This allows us to test return types that are not NULL
8687 * (NULL Imp value = n, NULL Imp 0 = NULL)
8692 V_BSTR(&right
) = true_str
;
8695 VarDecFromR8(2.0, &V_DECIMAL(&right
));
8696 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
8699 V_BOOL(&right
) = VARIANT_TRUE
;
8701 case VT_I1
: V_I1(&right
) = 2; break;
8702 case VT_I2
: V_I2(&right
) = 2; break;
8703 case VT_I4
: V_I4(&right
) = 2; break;
8704 case VT_R4
: V_R4(&right
) = 2.0f
; break;
8705 case VT_R8
: V_R8(&right
) = 2.0; break;
8706 case VT_CY
: V_CY(&right
).int64
= 10000; break;
8707 case VT_DATE
: V_DATE(&right
) = 2; break;
8708 case VT_I8
: V_I8(&right
) = 2; break;
8709 case VT_INT
: V_INT(&right
) = 2; break;
8710 case VT_UINT
: V_UINT(&right
) = 2; break;
8711 case VT_UI1
: V_UI1(&right
) = 2; break;
8712 case VT_UI2
: V_UI2(&right
) = 2; break;
8713 case VT_UI4
: V_UI4(&right
) = 2; break;
8714 case VT_UI8
: V_UI8(&right
) = 2; break;
8718 /* Native VarImp always returns an error when using extra
8719 * flags or if the variants are I8 and INT.
8721 if ((leftvt
== VT_I8
&& rightvt
== VT_INT
) ||
8725 /* Determine result type */
8726 else if ((leftvt
== VT_BSTR
&& rightvt
== VT_NULL
) ||
8727 (leftvt
== VT_NULL
&& rightvt
== VT_NULL
) ||
8728 (leftvt
== VT_NULL
&& rightvt
== VT_EMPTY
))
8730 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
8732 else if (leftvt
== VT_I4
|| rightvt
== VT_I4
||
8733 leftvt
== VT_INT
|| rightvt
== VT_INT
||
8734 leftvt
== VT_UINT
|| rightvt
== VT_UINT
||
8735 leftvt
== VT_UI4
|| rightvt
== VT_UI4
||
8736 leftvt
== VT_UI8
|| rightvt
== VT_UI8
||
8737 leftvt
== VT_UI2
|| rightvt
== VT_UI2
||
8738 leftvt
== VT_DECIMAL
|| rightvt
== VT_DECIMAL
||
8739 leftvt
== VT_DATE
|| rightvt
== VT_DATE
||
8740 leftvt
== VT_CY
|| rightvt
== VT_CY
||
8741 leftvt
== VT_R8
|| rightvt
== VT_R8
||
8742 leftvt
== VT_R4
|| rightvt
== VT_R4
||
8743 leftvt
== VT_I1
|| rightvt
== VT_I1
)
8745 else if ((leftvt
== VT_UI1
&& rightvt
== VT_UI1
) ||
8746 (leftvt
== VT_UI1
&& rightvt
== VT_NULL
) ||
8747 (leftvt
== VT_NULL
&& rightvt
== VT_UI1
))
8749 else if (leftvt
== VT_EMPTY
|| rightvt
== VT_EMPTY
||
8750 leftvt
== VT_I2
|| rightvt
== VT_I2
||
8751 leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
8753 else if (leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
||
8754 leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
)
8757 hres
= pVarImp(&left
, &right
, &result
);
8759 /* Check expected HRESULT and if result variant type is correct */
8761 ok (hres
== DISP_E_BADVARTYPE
|| hres
== DISP_E_TYPEMISMATCH
,
8762 "VarImp: %s|0x%X, %s|0x%X: got vt %s hr 0x%X\n",
8763 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
],
8764 vtstr(V_VT(&result
)), hres
);
8766 ok (hres
== S_OK
&& resvt
== V_VT(&result
),
8767 "VarImp: %s|0x%X, %s|0x%X: expected vt %s hr 0x%X, got vt %s hr 0x%X\n",
8768 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
], vtstr(resvt
),
8769 S_OK
, vtstr(V_VT(&result
)), hres
);
8774 VARIMP(EMPTY
,0,EMPTY
,0,I2
,-1);
8775 VARIMP(EMPTY
,0,NULL
,0,I2
,-1);
8776 VARIMP(EMPTY
,0,I2
,-1,I2
,-1);
8777 VARIMP(EMPTY
,0,I4
,-1,I4
,-1);
8778 VARIMP(EMPTY
,0,R4
,0.0f
,I4
,-1);
8779 VARIMP(EMPTY
,0,R8
,-1.0,I4
,-1);
8780 VARIMP(EMPTY
,0,DATE
,0,I4
,-1);
8781 VARIMP(EMPTY
,0,BSTR
,true_str
,I2
,-1);
8782 VARIMP(EMPTY
,0,BOOL
,VARIANT_FALSE
,I2
,-1);
8783 VARIMP(EMPTY
,0,I1
,0,I4
,-1);
8784 VARIMP(EMPTY
,0,UI1
,1,I2
,-1);
8785 VARIMP(EMPTY
,0,UI2
,1,I4
,-1);
8786 VARIMP(EMPTY
,0,UI4
,1,I4
,-1);
8789 VARIMP(EMPTY
,0,I8
,1,I8
,-1);
8790 VARIMP(EMPTY
,0,UI8
,1,I4
,-1);
8792 VARIMP(EMPTY
,0,INT
,-1,I4
,-1);
8793 VARIMP(EMPTY
,0,UINT
,1,I4
,-1);
8794 VARIMP(NULL
,0,EMPTY
,0,NULL
,0);
8795 VARIMP(NULL
,0,NULL
,0,NULL
,0);
8796 VARIMP(NULL
,0,I2
,-1,I2
,-1);
8797 VARIMP(NULL
,0,I4
,-1,I4
,-1);
8798 VARIMP(NULL
,0,R4
,0.0f
,NULL
,0);
8799 VARIMP(NULL
,0,R8
,-1.0,I4
,-1);
8800 VARIMP(NULL
,0,DATE
,0,NULL
,0);
8801 VARIMP(NULL
,0,BSTR
,true_str
,BOOL
,-1);
8802 VARIMP(NULL
,0,BOOL
,VARIANT_FALSE
,NULL
,0);
8803 VARIMP(NULL
,0,I1
,0,NULL
,0);
8804 VARIMP(NULL
,0,UI1
,1,UI1
,1);
8805 VARIMP(NULL
,0,UI2
,1,I4
,1);
8806 VARIMP(NULL
,0,UI4
,1,I4
,1);
8809 VARIMP(NULL
,0,I8
,1,I8
,1);
8810 VARIMP(NULL
,0,UI8
,1,I4
,1);
8812 VARIMP(NULL
,0,INT
,-1,I4
,-1);
8813 VARIMP(NULL
,0,UINT
,1,I4
,1);
8814 VARIMP(I2
,-1,EMPTY
,0,I2
,0);
8815 VARIMP(I2
,-1,I2
,-1,I2
,-1);
8816 VARIMP(I2
,-1,I4
,-1,I4
,-1);
8817 VARIMP(I2
,-1,R4
,0.0f
,I4
,0);
8818 VARIMP(I2
,-1,R8
,-1.0,I4
,-1);
8819 VARIMP(I2
,-1,DATE
,0,I4
,0);
8820 VARIMP(I2
,-1,BSTR
,true_str
,I2
,-1);
8821 VARIMP(I2
,-1,BOOL
,VARIANT_FALSE
,I2
,0);
8822 VARIMP(I2
,-1,I1
,0,I4
,0);
8823 VARIMP(I2
,-1,UI1
,1,I2
,1);
8824 VARIMP(I2
,-1,UI2
,1,I4
,1);
8825 VARIMP(I2
,-1,UI4
,1,I4
,1);
8828 VARIMP(I2
,-1,I8
,1,I8
,1);
8829 VARIMP(I2
,-1,UI8
,1,I4
,1);
8831 VARIMP(I2
,-1,INT
,-1,I4
,-1);
8832 VARIMP(I2
,-1,UINT
,1,I4
,1);
8833 VARIMP(I4
,2,EMPTY
,0,I4
,-3);
8834 VARIMP(I4
,2,NULL
,0,I4
,-3);
8835 VARIMP(I4
,2,I2
,-1,I4
,-1);
8836 VARIMP(I4
,2,I4
,-1,I4
,-1);
8837 VARIMP(I4
,2,R4
,0.0f
,I4
,-3);
8838 VARIMP(I4
,2,R8
,-1.0,I4
,-1);
8839 VARIMP(I4
,2,DATE
,0,I4
,-3);
8840 VARIMP(I4
,2,BSTR
,true_str
,I4
,-1);
8841 VARIMP(I4
,2,BOOL
,VARIANT_FALSE
,I4
,-3);
8842 VARIMP(I4
,2,I1
,0,I4
,-3);
8843 VARIMP(I4
,2,UI1
,1,I4
,-3);
8844 VARIMP(I4
,2,UI2
,1,I4
,-3);
8845 VARIMP(I4
,2,UI4
,1,I4
,-3);
8848 VARIMP(I4
,2,I8
,1,I8
,-3);
8849 VARIMP(I4
,2,UI8
,1,I4
,-3);
8851 VARIMP(I4
,2,INT
,-1,I4
,-1);
8852 VARIMP(I4
,2,UINT
,1,I4
,-3);
8853 VARIMP(R4
,-1.0f
,EMPTY
,0,I4
,0);
8854 VARIMP(R4
,-1.0f
,NULL
,0,NULL
,0);
8855 VARIMP(R4
,-1.0f
,I2
,-1,I4
,-1);
8856 VARIMP(R4
,-1.0f
,I4
,-1,I4
,-1);
8857 VARIMP(R4
,-1.0f
,R4
,0.0f
,I4
,0);
8858 VARIMP(R4
,-1.0f
,R8
,-1.0,I4
,-1);
8859 VARIMP(R4
,-1.0f
,DATE
,1,I4
,1);
8860 VARIMP(R4
,-1.0f
,BSTR
,true_str
,I4
,-1);
8861 VARIMP(R4
,-1.0f
,BOOL
,VARIANT_FALSE
,I4
,0);
8862 VARIMP(R4
,-1.0f
,I1
,0,I4
,0);
8863 VARIMP(R4
,-1.0f
,UI1
,1,I4
,1);
8864 VARIMP(R4
,-1.0f
,UI2
,1,I4
,1);
8865 VARIMP(R4
,-1.0f
,UI4
,1,I4
,1);
8868 VARIMP(R4
,-1.0f
,I8
,1,I8
,1);
8869 VARIMP(R4
,-1.0f
,UI8
,1,I4
,1);
8871 VARIMP(R4
,-1.0f
,INT
,-1,I4
,-1);
8872 VARIMP(R4
,-1.0f
,UINT
,1,I4
,1);
8873 VARIMP(R8
,1.0,EMPTY
,0,I4
,-2);
8874 VARIMP(R8
,1.0,NULL
,0,I4
,-2);
8875 VARIMP(R8
,1.0,I2
,-1,I4
,-1);
8876 VARIMP(R8
,1.0,I4
,-1,I4
,-1);
8877 VARIMP(R8
,1.0,R4
,0.0f
,I4
,-2);
8878 VARIMP(R8
,1.0,R8
,-1.0,I4
,-1);
8879 VARIMP(R8
,1.0,DATE
,0,I4
,-2);
8880 VARIMP(R8
,1.0,BSTR
,true_str
,I4
,-1);
8881 VARIMP(R8
,1.0,BOOL
,VARIANT_FALSE
,I4
,-2);
8882 VARIMP(R8
,1.0,I1
,0,I4
,-2);
8883 VARIMP(R8
,1.0,UI1
,1,I4
,-1);
8884 VARIMP(R8
,1.0,UI2
,1,I4
,-1);
8885 VARIMP(R8
,1.0,UI4
,1,I4
,-1);
8888 VARIMP(R8
,1.0,I8
,1,I8
,-1);
8889 VARIMP(R8
,1.0,UI8
,1,I4
,-1);
8891 VARIMP(R8
,1.0,INT
,-1,I4
,-1);
8892 VARIMP(R8
,1.0,UINT
,1,I4
,-1);
8893 VARIMP(DATE
,0,EMPTY
,0,I4
,-1);
8894 VARIMP(DATE
,0,NULL
,0,I4
,-1);
8895 VARIMP(DATE
,0,I2
,-1,I4
,-1);
8896 VARIMP(DATE
,0,I4
,-1,I4
,-1);
8897 VARIMP(DATE
,0,R4
,0.0f
,I4
,-1);
8898 VARIMP(DATE
,0,R8
,-1.0,I4
,-1);
8899 VARIMP(DATE
,0,DATE
,0,I4
,-1);
8900 VARIMP(DATE
,0,BSTR
,true_str
,I4
,-1);
8901 VARIMP(DATE
,0,BOOL
,VARIANT_FALSE
,I4
,-1);
8902 VARIMP(DATE
,0,I1
,0,I4
,-1);
8903 VARIMP(DATE
,0,UI1
,1,I4
,-1);
8904 VARIMP(DATE
,0,UI2
,1,I4
,-1);
8905 VARIMP(DATE
,0,UI4
,1,I4
,-1);
8908 VARIMP(DATE
,0,I8
,1,I8
,-1);
8909 VARIMP(DATE
,0,UI8
,1,I4
,-1);
8911 VARIMP(DATE
,0,INT
,-1,I4
,-1);
8912 VARIMP(DATE
,0,UINT
,1,I4
,-1);
8913 VARIMP(BSTR
,false_str
,EMPTY
,0,I2
,-1);
8914 VARIMP(BSTR
,false_str
,NULL
,0,BOOL
,-1);
8915 VARIMP(BSTR
,false_str
,I2
,-1,I2
,-1);
8916 VARIMP(BSTR
,false_str
,I4
,-1,I4
,-1);
8917 VARIMP(BSTR
,false_str
,R4
,0.0f
,I4
,-1);
8918 VARIMP(BSTR
,false_str
,R8
,-1.0,I4
,-1);
8919 VARIMP(BSTR
,false_str
,DATE
,0,I4
,-1);
8920 VARIMP(BSTR
,false_str
,BSTR
,true_str
,BOOL
,-1);
8921 VARIMP(BSTR
,false_str
,BOOL
,VARIANT_FALSE
,BOOL
,-1);
8922 VARIMP(BSTR
,false_str
,I1
,0,I4
,-1);
8923 VARIMP(BSTR
,false_str
,UI1
,1,I2
,-1);
8924 VARIMP(BSTR
,false_str
,UI2
,1,I4
,-1);
8925 VARIMP(BSTR
,false_str
,UI4
,1,I4
,-1);
8928 VARIMP(BSTR
,false_str
,I8
,1,I8
,-1);
8929 VARIMP(BSTR
,false_str
,UI8
,1,I4
,-1);
8931 VARIMP(BSTR
,false_str
,INT
,-1,I4
,-1);
8932 VARIMP(BSTR
,false_str
,UINT
,1,I4
,-1);
8933 VARIMP(BOOL
,VARIANT_TRUE
,EMPTY
,0,I2
,0);
8934 VARIMP(BOOL
,VARIANT_TRUE
,NULL
,0,NULL
,0);
8935 VARIMP(BOOL
,VARIANT_TRUE
,I2
,-1,I2
,-1);
8936 VARIMP(BOOL
,VARIANT_TRUE
,I4
,-1,I4
,-1);
8937 VARIMP(BOOL
,VARIANT_TRUE
,R4
,0.0f
,I4
,0);
8938 VARIMP(BOOL
,VARIANT_TRUE
,R8
,-1.0,I4
,-1);
8939 VARIMP(BOOL
,VARIANT_TRUE
,DATE
,0,I4
,0);
8940 VARIMP(BOOL
,VARIANT_TRUE
,BSTR
,true_str
,BOOL
,-1);
8941 VARIMP(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
,BOOL
,0);
8942 VARIMP(BOOL
,VARIANT_TRUE
,I1
,0,I4
,0);
8943 VARIMP(BOOL
,VARIANT_TRUE
,UI1
,1,I2
,1);
8944 VARIMP(BOOL
,VARIANT_TRUE
,UI2
,1,I4
,1);
8945 VARIMP(BOOL
,VARIANT_TRUE
,UI4
,1,I4
,1);
8948 VARIMP(BOOL
,VARIANT_TRUE
,I8
,1,I8
,1);
8949 VARIMP(BOOL
,VARIANT_TRUE
,UI8
,1,I4
,1);
8951 VARIMP(BOOL
,VARIANT_TRUE
,INT
,-1,I4
,-1);
8952 VARIMP(BOOL
,VARIANT_TRUE
,UINT
,1,I4
,1);
8953 VARIMP(I1
,-1,EMPTY
,0,I4
,0);
8954 VARIMP(I1
,-1,NULL
,0,NULL
,0);
8955 VARIMP(I1
,-1,I2
,-1,I4
,-1);
8956 VARIMP(I1
,-1,I4
,-1,I4
,-1);
8957 VARIMP(I1
,-1,R4
,0.0f
,I4
,0);
8958 VARIMP(I1
,-1,R8
,-1.0,I4
,-1);
8959 VARIMP(I1
,-1,DATE
,0,I4
,0);
8960 VARIMP(I1
,-1,BSTR
,true_str
,I4
,-1);
8961 VARIMP(I1
,-1,BOOL
,VARIANT_FALSE
,I4
,0);
8962 VARIMP(I1
,-1,I1
,0,I4
,0);
8963 VARIMP(I1
,-1,UI1
,1,I4
,1);
8964 VARIMP(I1
,-1,UI2
,1,I4
,1);
8965 VARIMP(I1
,-1,UI4
,1,I4
,1);
8968 VARIMP(I1
,-1,I8
,1,I8
,1);
8969 VARIMP(I1
,-1,UI8
,1,I4
,1);
8971 VARIMP(I1
,-1,INT
,-1,I4
,-1);
8972 VARIMP(I1
,-1,UINT
,1,I4
,1);
8973 VARIMP(UI1
,0,EMPTY
,0,I2
,-1);
8974 VARIMP(UI1
,0,NULL
,0,UI1
,255);
8975 VARIMP(UI1
,0,I2
,-1,I2
,-1);
8976 VARIMP(UI1
,0,I4
,-1,I4
,-1);
8977 VARIMP(UI1
,0,R4
,0.0f
,I4
,-1);
8978 VARIMP(UI1
,0,R8
,-1.0,I4
,-1);
8979 VARIMP(UI1
,0,DATE
,0,I4
,-1);
8980 VARIMP(UI1
,0,BSTR
,true_str
,I2
,-1);
8981 VARIMP(UI1
,0,BOOL
,VARIANT_FALSE
,I2
,-1);
8982 VARIMP(UI1
,0,I1
,0,I4
,-1);
8983 VARIMP(UI1
,0,UI1
,1,UI1
,255);
8984 VARIMP(UI1
,0,UI2
,1,I4
,-1);
8985 VARIMP(UI1
,0,UI4
,1,I4
,-1);
8988 VARIMP(UI1
,0,I8
,1,I8
,-1);
8989 VARIMP(UI1
,0,UI8
,1,I4
,-1);
8991 VARIMP(UI1
,0,INT
,-1,I4
,-1);
8992 VARIMP(UI1
,0,UINT
,1,I4
,-1);
8993 VARIMP(UI2
,0,EMPTY
,0,I4
,-1);
8994 VARIMP(UI2
,0,NULL
,0,I4
,-1);
8995 VARIMP(UI2
,0,I2
,-1,I4
,-1);
8996 VARIMP(UI2
,0,I4
,-1,I4
,-1);
8997 VARIMP(UI2
,0,R4
,0.0f
,I4
,-1);
8998 VARIMP(UI2
,0,R8
,-1.0,I4
,-1);
8999 VARIMP(UI2
,0,DATE
,0,I4
,-1);
9000 VARIMP(UI2
,0,BSTR
,true_str
,I4
,-1);
9001 VARIMP(UI2
,0,BOOL
,VARIANT_FALSE
,I4
,-1);
9002 VARIMP(UI2
,0,I1
,0,I4
,-1);
9003 VARIMP(UI2
,0,UI1
,1,I4
,-1);
9004 VARIMP(UI2
,0,UI2
,1,I4
,-1);
9005 VARIMP(UI2
,0,UI4
,1,I4
,-1);
9008 VARIMP(UI2
,0,I8
,1,I8
,-1);
9009 VARIMP(UI2
,0,UI8
,1,I4
,-1);
9011 VARIMP(UI2
,0,INT
,-1,I4
,-1);
9012 VARIMP(UI2
,0,UINT
,1,I4
,-1);
9013 VARIMP(UI4
,0,EMPTY
,0,I4
,-1);
9014 VARIMP(UI4
,0,NULL
,0,I4
,-1);
9015 VARIMP(UI4
,0,I2
,-1,I4
,-1);
9016 VARIMP(UI4
,0,I4
,-1,I4
,-1);
9017 VARIMP(UI4
,0,R4
,0.0f
,I4
,-1);
9018 VARIMP(UI4
,0,R8
,-1.0,I4
,-1);
9019 VARIMP(UI4
,0,DATE
,0,I4
,-1);
9020 VARIMP(UI4
,0,BSTR
,true_str
,I4
,-1);
9021 VARIMP(UI4
,0,BOOL
,VARIANT_FALSE
,I4
,-1);
9022 VARIMP(UI4
,0,I1
,0,I4
,-1);
9023 VARIMP(UI4
,0,UI1
,1,I4
,-1);
9024 VARIMP(UI4
,0,UI2
,1,I4
,-1);
9025 VARIMP(UI4
,0,UI4
,1,I4
,-1);
9028 VARIMP(UI4
,0,I8
,1,I8
,-1);
9029 VARIMP(UI4
,0,UI8
,1,I4
,-1);
9031 VARIMP(UI4
,0,INT
,-1,I4
,-1);
9032 VARIMP(UI4
,0,UINT
,1,I4
,-1);
9035 VARIMP(I8
,-1,EMPTY
,0,I8
,0);
9036 VARIMP(I8
,-1,NULL
,0,NULL
,0);
9037 VARIMP(I8
,-1,I2
,-1,I8
,-1);
9038 VARIMP(I8
,-1,I4
,-1,I8
,-1);
9039 VARIMP(I8
,-1,R4
,0.0f
,I8
,0);
9040 VARIMP(I8
,-1,R8
,-1.0,I8
,-1);
9041 VARIMP(I8
,-1,DATE
,0,I8
,0);
9042 VARIMP(I8
,-1,BSTR
,true_str
,I8
,-1);
9043 VARIMP(I8
,-1,BOOL
,VARIANT_FALSE
,I8
,0);
9044 VARIMP(I8
,-1,I1
,0,I8
,0);
9045 VARIMP(I8
,-1,UI1
,1,I8
,1);
9046 VARIMP(I8
,-1,UI2
,1,I8
,1);
9047 VARIMP(I8
,-1,UI4
,1,I8
,1);
9048 VARIMP(I8
,-1,I8
,1,I8
,1);
9049 VARIMP(I8
,-1,UI8
,1,I8
,1);
9050 VARIMP(I8
,-1,UINT
,1,I8
,1);
9051 VARIMP(UI8
,0,EMPTY
,0,I4
,-1);
9052 VARIMP(UI8
,0,NULL
,0,I4
,-1);
9053 VARIMP(UI8
,0,I2
,-1,I4
,-1);
9054 VARIMP(UI8
,0,I4
,-1,I4
,-1);
9055 VARIMP(UI8
,0,R4
,0.0f
,I4
,-1);
9056 VARIMP(UI8
,0,R8
,-1.0,I4
,-1);
9057 VARIMP(UI8
,0,DATE
,0,I4
,-1);
9058 VARIMP(UI8
,0,BSTR
,true_str
,I4
,-1);
9059 VARIMP(UI8
,0,BOOL
,VARIANT_FALSE
,I4
,-1);
9060 VARIMP(UI8
,0,I1
,0,I4
,-1);
9061 VARIMP(UI8
,0,UI1
,1,I4
,-1);
9062 VARIMP(UI8
,0,UI2
,1,I4
,-1);
9063 VARIMP(UI8
,0,UI4
,1,I4
,-1);
9064 VARIMP(UI8
,0,I8
,1,I8
,-1);
9065 VARIMP(UI8
,0,UI8
,1,I4
,-1);
9066 VARIMP(UI8
,0,INT
,-1,I4
,-1);
9067 VARIMP(UI8
,0,UINT
,1,I4
,-1);
9069 VARIMP(INT
,-1,EMPTY
,0,I4
,0);
9070 VARIMP(INT
,-1,NULL
,0,NULL
,0);
9071 VARIMP(INT
,-1,I2
,-1,I4
,-1);
9072 VARIMP(INT
,-1,I4
,-1,I4
,-1);
9073 VARIMP(INT
,-1,R4
,0.0f
,I4
,0);
9074 VARIMP(INT
,-1,R8
,-1.0,I4
,-1);
9075 VARIMP(INT
,-1,DATE
,0,I4
,0);
9076 VARIMP(INT
,-1,BSTR
,true_str
,I4
,-1);
9077 VARIMP(INT
,-1,BOOL
,VARIANT_FALSE
,I4
,0);
9078 VARIMP(INT
,-1,I1
,0,I4
,0);
9079 VARIMP(INT
,-1,UI1
,1,I4
,1);
9080 VARIMP(INT
,-1,UI2
,1,I4
,1);
9081 VARIMP(INT
,-1,UI4
,1,I4
,1);
9084 VARIMP(INT
,-1,I8
,1,I8
,1);
9085 VARIMP(INT
,-1,UI8
,1,I4
,1);
9087 VARIMP(INT
,-1,INT
,-1,I4
,-1);
9088 VARIMP(INT
,-1,UINT
,1,I4
,1);
9089 VARIMP(UINT
,1,EMPTY
,0,I4
,-2);
9090 VARIMP(UINT
,1,NULL
,0,I4
,-2);
9091 VARIMP(UINT
,1,I2
,-1,I4
,-1);
9092 VARIMP(UINT
,1,I4
,-1,I4
,-1);
9093 VARIMP(UINT
,1,R4
,0.0f
,I4
,-2);
9094 VARIMP(UINT
,1,R8
,-1.0,I4
,-1);
9095 VARIMP(UINT
,1,DATE
,0,I4
,-2);
9096 VARIMP(UINT
,1,BSTR
,true_str
,I4
,-1);
9097 VARIMP(UINT
,1,BOOL
,VARIANT_FALSE
,I4
,-2);
9098 VARIMP(UINT
,1,I1
,0,I4
,-2);
9099 VARIMP(UINT
,1,UI1
,1,I4
,-1);
9100 VARIMP(UINT
,1,UI2
,1,I4
,-1);
9101 VARIMP(UINT
,1,UI4
,1,I4
,-1);
9104 VARIMP(UINT
,1,I8
,1,I8
,-1);
9105 VARIMP(UINT
,1,UI8
,1,I4
,-1);
9107 VARIMP(UINT
,1,INT
,-1,I4
,-1);
9108 VARIMP(UINT
,1,UINT
,1,I4
,-1);
9110 /* Manually test some VT_CY, VT_DECIMAL variants */
9112 hres
= VarCyFromI4(1, &V_CY(&cy
));
9113 ok(hres
== S_OK
, "VarCyFromI4 failed!\n");
9114 V_VT(&dec
) = VT_DECIMAL
;
9115 hres
= VarDecFromR8(2.0, &V_DECIMAL(&dec
));
9116 ok(hres
== S_OK
, "VarDecFromR4 failed!\n");
9117 memset(&left
, 0, sizeof(left
));
9118 memset(&right
, 0, sizeof(right
));
9119 V_VT(&left
) = VT_I4
;
9121 V_VT(&right
) = VT_I8
;
9124 hres
= pVarImp(&cy
, &cy
, &result
);
9125 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
9126 "VARIMP: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
9127 S_OK
, hres
, vtstr(V_VT(&result
)));
9128 ok(hres
== S_OK
&& V_I4(&result
) == -1,
9129 "VARIMP: CY value %d, expected %d\n", V_I4(&result
), -1);
9133 hres
= pVarImp(&cy
, &right
, &result
);
9134 ok(hres
== S_OK
&& V_VT(&result
) == VT_I8
,
9135 "VARIMP: expected coerced hres 0x%X type VT_I8, got hres 0x%X type %s!\n",
9136 S_OK
, hres
, vtstr(V_VT(&result
)));
9137 ok(hres
== S_OK
&& V_I8(&result
) == -2,
9138 "VARIMP: CY value %x%08x, expected %d\n",
9139 (DWORD
)((V_I8(&result
)) >> 32), (DWORD
)(V_I8(&result
)), -2);
9142 hres
= pVarImp(&left
, &cy
, &result
);
9143 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
9144 "VARIMP: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
9145 S_OK
, hres
, vtstr(V_VT(&result
)));
9146 ok(hres
== S_OK
&& V_I4(&result
) == -1,
9147 "VARIMP: CY value %d, expected %d\n", V_I4(&result
), -1);
9149 hres
= pVarImp(&left
, &dec
, &result
);
9150 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
9151 "VARIMP: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
9152 S_OK
, hres
, vtstr(V_VT(&result
)));
9153 ok(hres
== S_OK
&& V_I4(&result
) == -1,
9154 "VARIMP: DECIMAL value %d, expected %d\n", V_I4(&result
), -1);
9156 hres
= pVarImp(&dec
, &dec
, &result
);
9157 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
9158 "VARIMP: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
9159 S_OK
, hres
, vtstr(V_VT(&result
)));
9160 ok(hres
== S_OK
&& V_I4(&result
) == -1,
9161 "VARIMP: DECIMAL value %d, expected %d\n", V_I4(&result
), -1);
9165 hres
= pVarImp(&dec
, &right
, &result
);
9166 ok(hres
== S_OK
&& V_VT(&result
) == VT_I8
,
9167 "VARIMP: expected coerced hres 0x%X type VT_I8, got hres 0x%X type %s!\n",
9168 S_OK
, hres
, vtstr(V_VT(&result
)));
9169 ok(hres
== S_OK
&& V_I8(&result
) == -3,
9170 "VARIMP: DECIMAL value 0x%x%08x, expected %d\n",
9171 (DWORD
)(V_I8(&result
) >>32), (DWORD
)V_I8(&result
), -3);
9174 SysFreeString(false_str
);
9175 SysFreeString(true_str
);
9183 test_VariantClear();
9185 test_VariantCopyInd();
9186 test_VarParseNumFromStr();
9187 test_VarNumFromParseNum();
9188 test_VarUdateFromDate();
9189 test_VarDateFromUdate();
9190 test_SystemTimeToVariantTime();
9191 test_VariantTimeToSystemTime();
9192 test_DosDateTimeToVariantTime();
9193 test_VariantTimeToDosDateTime();
9208 test_VarCmp(); /* Before test_VarCat() which needs VarCmp() */