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
32 #include "wine/test.h"
42 static HMODULE hOleaut32
;
44 static HRESULT (WINAPI
*pVarUdateFromDate
)(DATE
,ULONG
,UDATE
*);
45 static HRESULT (WINAPI
*pVarDateFromUdate
)(UDATE
*,ULONG
,DATE
*);
46 static INT (WINAPI
*pSystemTimeToVariantTime
)(LPSYSTEMTIME
,double*);
47 static INT (WINAPI
*pVariantTimeToSystemTime
)(double,LPSYSTEMTIME
);
48 static INT (WINAPI
*pDosDateTimeToVariantTime
)(USHORT
,USHORT
,double*);
49 static INT (WINAPI
*pVariantTimeToDosDateTime
)(double,USHORT
*,USHORT
*);
51 static const WCHAR sz12
[] = {'1','2','\0'};
52 /* the strings are localized */
53 static WCHAR sz12_false
[32];
54 static WCHAR sz12_true
[32];
56 /* Get a conversion function ptr, return if function not available */
57 #define CHECKPTR(func) p##func = (void*)GetProcAddress(hOleaut32, #func); \
58 if (!p##func) { win_skip("function " # func " not available, not testing it\n"); return; }
60 /* Has I8/UI8 data type? */
63 /* When comparing floating point values we cannot expect an exact match
64 * because the rounding errors depend on the exact algorithm.
66 #define EQ_DOUBLE(a,b) (fabs((a)-(b)) / (1.0+fabs(a)+fabs(b)) < 1e-14)
67 #define EQ_FLOAT(a,b) (fabs((a)-(b)) / (1.0+fabs(a)+fabs(b)) < 1e-7)
69 #define SKIPTESTS(a) if((a > VT_CLSID+10) && (a < VT_BSTR_BLOB-10)) continue
71 /* Allow our test macros to work for VT_NULL and VT_EMPTY too */
72 #define V_EMPTY(v) V_I4(v)
73 #define V_NULL(v) V_I4(v)
75 /* Size constraints for overflow tests */
77 #define I1_MIN ((-I1_MAX)-1)
81 #define I2_MIN ((-I2_MAX)-1)
82 #define UI2_MAX 0xffff
84 #define I4_MAX 0x7fffffff
85 #define I4_MIN ((-I4_MAX)-1)
86 #define UI4_MAX 0xffffffff
88 #define I8_MAX (((LONGLONG)I4_MAX << 32) | UI4_MAX)
89 #define I8_MIN ((-I8_MAX)-1)
90 #define UI8_MAX (((ULONGLONG)UI4_MAX << 32) | UI4_MAX)
92 #define DATE_MAX 2958465
93 #define DATE_MIN -657434
94 #define R4_MAX FLT_MAX
95 #define R4_MIN FLT_MIN
96 #define R8_MAX DBL_MAX
97 #define R8_MIN DBL_MIN
99 static void init(void)
104 res
= VarBstrFromBool(VARIANT_TRUE
, LANG_USER_DEFAULT
, VAR_LOCALBOOL
, &bstr
);
105 ok(res
== S_OK
&& (lstrlenW(bstr
) > 0),
106 "Expected localized string for 'True'\n");
107 /* lstrcpyW / lstrcatW do not work on win95 */
108 memcpy(sz12_true
, sz12
, sizeof(sz12
));
109 if (bstr
) memcpy(&sz12_true
[2], bstr
, SysStringByteLen(bstr
) + sizeof(WCHAR
));
112 res
= VarBstrFromBool(VARIANT_FALSE
, LANG_USER_DEFAULT
, VAR_LOCALBOOL
, &bstr
);
113 ok(res
== S_OK
&& (lstrlenW(bstr
) > 0),
114 "Expected localized string for 'False'\n");
115 memcpy(sz12_false
, sz12
, sizeof(sz12
));
116 if (bstr
) memcpy(&sz12_false
[2], bstr
, SysStringByteLen(bstr
) + sizeof(WCHAR
));
119 hOleaut32
= GetModuleHandle("oleaut32.dll");
120 has_i8
= GetProcAddress(hOleaut32
, "VarI8FromI1") != NULL
;
122 skip("No support for I8 and UI8 data types\n");
125 /* Functions to set a DECIMAL */
126 static void setdec(DECIMAL
* dec
, BYTE scl
, BYTE sgn
, ULONG hi32
, ULONG64 lo64
)
128 S(U(*dec
)).scale
= scl
;
129 S(U(*dec
)).sign
= sgn
;
131 U1(*dec
).Lo64
= lo64
;
134 static void setdec64(DECIMAL
* dec
, BYTE scl
, BYTE sgn
, ULONG hi32
, ULONG mid32
, ULONG lo32
)
136 S(U(*dec
)).scale
= scl
;
137 S(U(*dec
)).sign
= sgn
;
139 S1(U1(*dec
)).Mid32
= mid32
;
140 S1(U1(*dec
)).Lo32
= lo32
;
143 static inline int strcmpW( const WCHAR
*str1
, const WCHAR
*str2
)
145 while (*str1
&& (*str1
== *str2
)) { str1
++; str2
++; }
146 return *str1
- *str2
;
149 /* return the string text of a given variant type */
150 static char vtstr_buffer
[16][256];
151 static int vtstr_current
=0;
152 static const char *vtstr(int x
)
155 #define CASE(vt) case VT_##vt: return #vt
194 CASE(STREAMED_OBJECT
);
199 CASE(VERSIONED_STREAM
);
208 return "VT_BSTR_BLOB/VT_ILLEGALMASKED/VT_TYPEMASK";
211 vtstr_current
%= sizeof(vtstr_buffer
)/sizeof(*vtstr_buffer
);
212 sprintf(vtstr_buffer
[vtstr_current
], "unknown variant type %d", x
);
213 return vtstr_buffer
[vtstr_current
++];
217 static const char *variantstr( const VARIANT
*var
)
219 vtstr_current
%= sizeof(vtstr_buffer
)/sizeof(*vtstr_buffer
);
223 sprintf( vtstr_buffer
[vtstr_current
], "VT_I1(%d)", V_I1(var
) ); break;
225 sprintf( vtstr_buffer
[vtstr_current
], "VT_I2(%d)", V_I2(var
) ); break;
227 sprintf( vtstr_buffer
[vtstr_current
], "VT_I4(%d)", V_I4(var
) ); break;
229 sprintf( vtstr_buffer
[vtstr_current
], "VT_INT(%d)", V_INT(var
) ); break;
231 sprintf( vtstr_buffer
[vtstr_current
], "VT_I8(%x%08x)", (UINT
)(V_I8(var
) >> 32), (UINT
)V_I8(var
) ); break;
233 sprintf( vtstr_buffer
[vtstr_current
], "VT_UI8(%x%08x)", (UINT
)(V_UI8(var
) >> 32), (UINT
)V_UI8(var
) ); break;
235 sprintf( vtstr_buffer
[vtstr_current
], "VT_R4(%g)", V_R4(var
) ); break;
237 sprintf( vtstr_buffer
[vtstr_current
], "VT_R8(%g)", V_R8(var
) ); break;
239 sprintf( vtstr_buffer
[vtstr_current
], "VT_UI1(%u)", V_UI1(var
) ); break;
241 sprintf( vtstr_buffer
[vtstr_current
], "VT_UI2(%u)", V_UI2(var
) ); break;
243 sprintf( vtstr_buffer
[vtstr_current
], "VT_UI4(%u)", V_UI4(var
) ); break;
245 sprintf( vtstr_buffer
[vtstr_current
], "VT_UINT(%d)", V_UINT(var
) ); break;
247 sprintf( vtstr_buffer
[vtstr_current
], "VT_CY(%x%08x)", S(V_CY(var
)).Hi
, S(V_CY(var
)).Lo
); break;
249 sprintf( vtstr_buffer
[vtstr_current
], "VT_DATE(%g)", V_DATE(var
) ); break;
251 return vtstr(V_VT(var
));
253 return vtstr_buffer
[vtstr_current
++];
256 static BOOL
is_expected_variant( const VARIANT
*result
, const VARIANT
*expected
)
258 if (V_VT(result
) != V_VT(expected
)) return FALSE
;
259 switch(V_VT(expected
))
265 #define CASE(vt) case VT_##vt: return (V_##vt(result) == V_##vt(expected))
280 return EQ_FLOAT(V_DATE(result
), V_DATE(expected
));
282 return EQ_FLOAT(V_R4(result
), V_R4(expected
));
284 return EQ_FLOAT(V_R8(result
), V_R8(expected
));
286 return (V_CY(result
).int64
== V_CY(expected
).int64
);
288 return !lstrcmpW( V_BSTR(result
), V_BSTR(expected
) );
290 return !memcmp( &V_DECIMAL(result
), &V_DECIMAL(expected
), sizeof(DECIMAL
) );
292 ok(0, "unhandled variant type %s\n",vtstr(V_VT(expected
)));
297 static void test_var_call1( int line
, HRESULT (WINAPI
*func
)(LPVARIANT
,LPVARIANT
),
298 VARIANT
*arg
, VARIANT
*expected
)
300 VARIANT old_arg
= *arg
;
304 memset( &result
, 0, sizeof(result
) );
305 hres
= func( arg
, &result
);
306 ok_(__FILE__
,line
)( hres
== S_OK
, "wrong result %x\n", hres
);
308 ok_(__FILE__
,line
)( is_expected_variant( &result
, expected
),
309 "got %s expected %s\n", variantstr(&result
), variantstr(expected
) );
310 ok_(__FILE__
,line
)( is_expected_variant( arg
, &old_arg
), "Modified argument %s / %s\n",
311 variantstr(&old_arg
), variantstr(arg
));
312 VariantClear( &result
);
315 static void test_var_call2( int line
, HRESULT (WINAPI
*func
)(LPVARIANT
,LPVARIANT
,LPVARIANT
),
316 VARIANT
*left
, VARIANT
*right
, VARIANT
*expected
)
318 VARIANT old_left
= *left
, old_right
= *right
;
322 memset( &result
, 0, sizeof(result
) );
323 hres
= func( left
, right
, &result
);
324 ok_(__FILE__
,line
)( hres
== S_OK
, "wrong result %x\n", hres
);
326 ok_(__FILE__
,line
)( is_expected_variant( &result
, expected
),
327 "got %s expected %s\n", variantstr(&result
), variantstr(expected
) );
328 ok_(__FILE__
,line
)( is_expected_variant( left
, &old_left
), "Modified left argument %s / %s\n",
329 variantstr(&old_left
), variantstr(left
));
330 ok_(__FILE__
,line
)( is_expected_variant( right
, &old_right
), "Modified right argument %s / %s\n",
331 variantstr(&old_right
), variantstr(right
));
332 VariantClear( &result
);
335 static int strcmp_wa(const WCHAR
*strw
, const char *stra
)
338 MultiByteToWideChar(CP_ACP
, 0, stra
, -1, buf
, sizeof(buf
)/sizeof(buf
[0]));
339 return lstrcmpW(strw
, buf
);
342 #define test_bstr_var(a,b) _test_bstr_var(__LINE__,a,b)
343 static void _test_bstr_var(unsigned line
, const VARIANT
*v
, const char *str
)
345 ok_(__FILE__
,line
)(V_VT(v
) == VT_BSTR
, "unexpected vt=%d\n", V_VT(v
));
346 if(V_VT(v
) == VT_BSTR
)
347 ok(!strcmp_wa(V_BSTR(v
), str
), "v=%s, expected %s\n", wine_dbgstr_w(V_BSTR(v
)), str
);
350 static void test_VariantInit(void)
354 /* Test that VariantInit() only sets the type */
355 memset(&v1
, -1, sizeof(v1
));
357 V_VT(&v2
) = VT_EMPTY
;
359 ok(!memcmp(&v1
, &v2
, sizeof(v1
)), "VariantInit() set extra fields\n");
362 /* All possible combinations of extra V_VT() flags */
363 static const VARTYPE ExtraFlags
[16] =
372 VT_VECTOR
|VT_RESERVED
,
373 VT_VECTOR
|VT_ARRAY
|VT_BYREF
,
374 VT_VECTOR
|VT_ARRAY
|VT_RESERVED
,
375 VT_VECTOR
|VT_BYREF
|VT_RESERVED
,
376 VT_VECTOR
|VT_ARRAY
|VT_BYREF
|VT_RESERVED
,
378 VT_ARRAY
|VT_RESERVED
,
379 VT_ARRAY
|VT_BYREF
|VT_RESERVED
,
380 VT_BYREF
|VT_RESERVED
,
383 /* Determine if a vt is valid for VariantClear() */
384 static BOOL
IsValidVariantClearVT(VARTYPE vt
, VARTYPE extraFlags
)
388 /* Only the following flags/types are valid */
389 if ((vt
<= VT_LPWSTR
|| vt
== VT_RECORD
|| vt
== VT_CLSID
) &&
391 (vt
< (VARTYPE
)24 || vt
> (VARTYPE
)31) &&
392 (!(extraFlags
& (VT_BYREF
|VT_ARRAY
)) || vt
> VT_NULL
) &&
393 (extraFlags
== 0 || extraFlags
== VT_BYREF
|| extraFlags
== VT_ARRAY
||
394 extraFlags
== (VT_ARRAY
|VT_BYREF
)))
397 if (!has_i8
&& (vt
== VT_I8
|| vt
== VT_UI8
))
398 ret
= FALSE
; /* Old versions of oleaut32 */
404 IUnknown IUnknown_iface
;
407 } test_VariantClearImpl
;
409 static inline test_VariantClearImpl
*impl_from_IUnknown(IUnknown
*iface
)
411 return CONTAINING_RECORD(iface
, test_VariantClearImpl
, IUnknown_iface
);
414 static HRESULT WINAPI
VC_QueryInterface(LPUNKNOWN iface
,REFIID riid
,LPVOID
*ppobj
)
416 test_VariantClearImpl
*This
= impl_from_IUnknown(iface
);
418 return E_NOINTERFACE
;
421 static ULONG WINAPI
VC_AddRef(LPUNKNOWN iface
) {
422 test_VariantClearImpl
*This
= impl_from_IUnknown(iface
);
424 return InterlockedIncrement(&This
->ref
);
427 static ULONG WINAPI
VC_Release(LPUNKNOWN iface
) {
428 test_VariantClearImpl
*This
= impl_from_IUnknown(iface
);
429 /* static class, won't be freed */
431 return InterlockedDecrement(&This
->ref
);
434 static const IUnknownVtbl test_VariantClear_vtbl
= {
440 static test_VariantClearImpl test_myVariantClearImpl
= {{&test_VariantClear_vtbl
}, 1, 0};
442 static void test_VariantClear(void)
451 /* Crashes: Native does not test input for NULL, so neither does Wine */
455 /* Only the type field is set, to VT_EMPTY */
458 hres
= VariantClear(&v
);
459 ok((hres
== S_OK
&& V_VT(&v
) == VT_EMPTY
),
460 "VariantClear: Type set to %d, res %08x\n", V_VT(&v
), hres
);
461 ok(V_UI4(&v
) == ~0u, "VariantClear: Overwrote value\n");
463 /* Test all possible V_VT values.
464 * Also demonstrates that null pointers in 'v' are not dereferenced.
465 * Individual variant tests should test VariantClear() with non-NULL values.
467 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
471 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
473 HRESULT hExpected
= DISP_E_BADVARTYPE
;
477 memset(&v
, 0, sizeof(v
));
478 V_VT(&v
) = vt
| ExtraFlags
[i
];
480 hres
= VariantClear(&v
);
482 if (IsValidVariantClearVT(vt
, ExtraFlags
[i
]))
485 ok(hres
== hExpected
, "VariantClear: expected 0x%X, got 0x%X for vt %d | 0x%X\n",
486 hExpected
, hres
, vt
, ExtraFlags
[i
]);
490 /* Some BYREF tests with non-NULL ptrs */
495 V_VT(&v
) = VT_VARIANT
| VT_BYREF
;
496 V_VARIANTREF(&v
) = &v2
;
498 hres
= VariantClear(&v
);
499 ok(hres
== S_OK
, "ret %08x\n", hres
);
500 ok(V_VT(&v
) == 0, "vt %04x\n", V_VT(&v
));
501 ok(V_VARIANTREF(&v
) == &v2
, "variant ref %p\n", V_VARIANTREF(&v2
));
502 ok(V_VT(&v2
) == VT_I4
, "vt %04x\n", V_VT(&v2
));
503 ok(V_I4(&v2
) == 0x1234, "i4 %04x\n", V_I4(&v2
));
507 V_VT(&v
) = VT_I4
| VT_BYREF
;
510 hres
= VariantClear(&v
);
511 ok(hres
== S_OK
, "ret %08x\n", hres
);
512 ok(V_VT(&v
) == 0, "vt %04x\n", V_VT(&v
));
513 ok(V_I4REF(&v
) == &i4
, "i4 ref %p\n", V_I4REF(&v2
));
514 ok(i4
== 0x4321, "i4 changed %08x\n", i4
);
518 V_VT(&v
) = VT_UNKNOWN
;
519 V_UNKNOWN(&v
) = &test_myVariantClearImpl
.IUnknown_iface
;
520 test_myVariantClearImpl
.events
= 0;
521 hres
= VariantClear(&v
);
522 ok(hres
== S_OK
, "ret %08x\n", hres
);
523 ok(V_VT(&v
) == 0, "vt %04x\n", V_VT(&v
));
524 ok(V_UNKNOWN(&v
) == &test_myVariantClearImpl
.IUnknown_iface
, "unknown %p\n", V_UNKNOWN(&v
));
525 /* Check that Release got called, but nothing else */
526 ok(test_myVariantClearImpl
.events
== 0x4, "Unexpected call. events %08x\n", test_myVariantClearImpl
.events
);
529 punk
= &test_myVariantClearImpl
.IUnknown_iface
;
530 V_VT(&v
) = VT_UNKNOWN
| VT_BYREF
;
531 V_UNKNOWNREF(&v
) = &punk
;
532 test_myVariantClearImpl
.events
= 0;
533 hres
= VariantClear(&v
);
534 ok(hres
== S_OK
, "ret %08x\n", hres
);
535 ok(V_VT(&v
) == 0, "vt %04x\n", V_VT(&v
));
536 ok(V_UNKNOWNREF(&v
) == &punk
, "unknown ref %p\n", V_UNKNOWNREF(&v
));
537 /* Check that nothing got called */
538 ok(test_myVariantClearImpl
.events
== 0, "Unexpected call. events %08x\n", test_myVariantClearImpl
.events
);
541 V_VT(&v
) = VT_DISPATCH
;
542 V_DISPATCH(&v
) = (IDispatch
*)&test_myVariantClearImpl
;
543 test_myVariantClearImpl
.events
= 0;
544 hres
= VariantClear(&v
);
545 ok(hres
== S_OK
, "ret %08x\n", hres
);
546 ok(V_VT(&v
) == 0, "vt %04x\n", V_VT(&v
));
547 ok(V_DISPATCH(&v
) == (IDispatch
*)&test_myVariantClearImpl
, "dispatch %p\n", V_DISPATCH(&v
));
548 /* Check that Release got called, but nothing else */
549 ok(test_myVariantClearImpl
.events
== 0x4, "Unexpected call. events %08x\n", test_myVariantClearImpl
.events
);
552 punk
= &test_myVariantClearImpl
.IUnknown_iface
;
553 V_VT(&v
) = VT_DISPATCH
| VT_BYREF
;
554 V_DISPATCHREF(&v
) = (IDispatch
**)&punk
;
555 test_myVariantClearImpl
.events
= 0;
556 hres
= VariantClear(&v
);
557 ok(hres
== S_OK
, "ret %08x\n", hres
);
558 ok(V_VT(&v
) == 0, "vt %04x\n", V_VT(&v
));
559 ok(V_DISPATCHREF(&v
) == (IDispatch
**)&punk
, "dispatch ref %p\n", V_DISPATCHREF(&v
));
560 /* Check that nothing got called */
561 ok(test_myVariantClearImpl
.events
== 0, "Unexpected call. events %08x\n", test_myVariantClearImpl
.events
);
564 static void test_VariantCopy(void)
566 VARIANTARG vSrc
, vDst
;
569 HRESULT hres
, hExpected
;
571 /* Establish that the failure/other cases are dealt with. Individual tests
572 * for each type should verify that data is copied correctly, references
577 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
579 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
583 memset(&vSrc
, 0, sizeof(vSrc
));
584 V_VT(&vSrc
) = vt
| ExtraFlags
[i
];
586 hExpected
= DISP_E_BADVARTYPE
;
587 /* src is allowed to be a VT_CLSID */
588 if (vt
!= VT_CLSID
&& IsValidVariantClearVT(vt
, ExtraFlags
[i
]))
591 hres
= VariantCopy(&vSrc
, &vSrc
);
593 ok(hres
== hExpected
,
594 "Copy(src==dst): expected 0x%X, got 0x%X for src==dest vt %d|0x%X\n",
595 hExpected
, hres
, vt
, ExtraFlags
[i
]);
599 /* Test that if VariantClear() fails on dest, the function fails. This also
600 * shows that dest is in fact cleared and not just overwritten
602 memset(&vSrc
, 0, sizeof(vSrc
));
603 V_VT(&vSrc
) = VT_UI1
;
605 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
607 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
611 hExpected
= DISP_E_BADVARTYPE
;
613 memset(&vDst
, 0, sizeof(vDst
));
614 V_VT(&vDst
) = vt
| ExtraFlags
[i
];
616 if (IsValidVariantClearVT(vt
, ExtraFlags
[i
]))
619 hres
= VariantCopy(&vDst
, &vSrc
);
621 ok(hres
== hExpected
,
622 "Copy(bad dst): expected 0x%X, got 0x%X for dest vt %d|0x%X\n",
623 hExpected
, hres
, vt
, ExtraFlags
[i
]);
625 ok(V_VT(&vDst
) == VT_UI1
,
626 "Copy(bad dst): expected vt = VT_UI1, got %d\n", V_VT(&vDst
));
630 /* Test that VariantClear() checks vSrc for validity before copying */
631 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
633 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
637 hExpected
= DISP_E_BADVARTYPE
;
639 memset(&vDst
, 0, sizeof(vDst
));
640 V_VT(&vDst
) = VT_EMPTY
;
642 memset(&vSrc
, 0, sizeof(vSrc
));
643 V_VT(&vSrc
) = vt
| ExtraFlags
[i
];
645 /* src is allowed to be a VT_CLSID */
646 if (vt
!= VT_CLSID
&& IsValidVariantClearVT(vt
, ExtraFlags
[i
]))
649 hres
= VariantCopy(&vDst
, &vSrc
);
651 ok(hres
== hExpected
,
652 "Copy(bad src): expected 0x%X, got 0x%X for src vt %d|0x%X\n",
653 hExpected
, hres
, vt
, ExtraFlags
[i
]);
656 ok(V_VT(&vDst
) == (vt
|ExtraFlags
[i
]),
657 "Copy(bad src): expected vt = %d, got %d\n",
658 vt
| ExtraFlags
[i
], V_VT(&vDst
));
664 /* Test that copying a NULL BSTR results in an empty BSTR */
665 memset(&vDst
, 0, sizeof(vDst
));
666 V_VT(&vDst
) = VT_EMPTY
;
667 memset(&vSrc
, 0, sizeof(vSrc
));
668 V_VT(&vSrc
) = VT_BSTR
;
669 hres
= VariantCopy(&vDst
, &vSrc
);
670 ok(hres
== S_OK
, "Copy(NULL BSTR): Failed to copy a NULL BSTR\n");
673 ok((V_VT(&vDst
) == VT_BSTR
) && V_BSTR(&vDst
),
674 "Copy(NULL BSTR): should have non-NULL result\n");
675 if ((V_VT(&vDst
) == VT_BSTR
) && V_BSTR(&vDst
))
677 ok(*V_BSTR(&vDst
) == 0, "Copy(NULL BSTR): result not empty\n");
683 /* Determine if a vt is valid for VariantCopyInd() */
684 static BOOL
IsValidVariantCopyIndVT(VARTYPE vt
, VARTYPE extraFlags
)
688 if ((extraFlags
& VT_ARRAY
) ||
689 (vt
> VT_NULL
&& vt
!= (VARTYPE
)15 && vt
< VT_VOID
&&
690 !(extraFlags
& (VT_VECTOR
|VT_RESERVED
))))
697 static void test_VariantCopyInd(void)
699 VARIANTARG vSrc
, vDst
, vRef
, vRef2
;
703 HRESULT hres
, hExpected
;
705 memset(buffer
, 0, sizeof(buffer
));
708 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
710 if (ExtraFlags
[i
] & VT_ARRAY
)
711 continue; /* Native crashes on NULL safearray */
713 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
717 memset(&vSrc
, 0, sizeof(vSrc
));
718 V_VT(&vSrc
) = vt
| ExtraFlags
[i
];
720 hExpected
= DISP_E_BADVARTYPE
;
721 if (!(ExtraFlags
[i
] & VT_BYREF
))
723 /* if src is not by-reference, acts as VariantCopy() */
724 if (vt
!= VT_CLSID
&& IsValidVariantClearVT(vt
, ExtraFlags
[i
]))
729 if (vt
== VT_SAFEARRAY
|| vt
== VT_BSTR
|| vt
== VT_UNKNOWN
||
730 vt
== VT_DISPATCH
|| vt
== VT_RECORD
)
731 continue; /* Need valid ptrs for deep copies */
733 V_BYREF(&vSrc
) = &buffer
;
734 hExpected
= E_INVALIDARG
;
736 if ((vt
== VT_I8
|| vt
== VT_UI8
) &&
737 ExtraFlags
[i
] == VT_BYREF
)
740 hExpected
= S_OK
; /* Only valid if I8 is a known type */
742 else if (IsValidVariantCopyIndVT(vt
, ExtraFlags
[i
]))
746 hres
= VariantCopyInd(&vSrc
, &vSrc
);
748 ok(hres
== hExpected
,
749 "CopyInd(src==dst): expected 0x%X, got 0x%X for src==dst vt %d|0x%X\n",
750 hExpected
, hres
, vt
, ExtraFlags
[i
]);
755 memset(&vSrc
, 0, sizeof(vSrc
));
756 V_VT(&vSrc
) = VT_UI1
|VT_BYREF
;
757 V_BYREF(&vSrc
) = &buffer
;
759 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
761 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
765 memset(&vDst
, 0, sizeof(vDst
));
766 V_VT(&vDst
) = vt
| ExtraFlags
[i
];
768 hExpected
= DISP_E_BADVARTYPE
;
770 if (IsValidVariantClearVT(vt
, ExtraFlags
[i
]))
773 hres
= VariantCopyInd(&vDst
, &vSrc
);
775 ok(hres
== hExpected
,
776 "CopyInd(bad dst): expected 0x%X, got 0x%X for dst vt %d|0x%X\n",
777 hExpected
, hres
, vt
, ExtraFlags
[i
]);
779 ok(V_VT(&vDst
) == VT_UI1
,
780 "CopyInd(bad dst): expected vt = VT_UI1, got %d\n", V_VT(&vDst
));
785 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
787 if (ExtraFlags
[i
] & VT_ARRAY
)
788 continue; /* Native crashes on NULL safearray */
790 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
794 memset(&vDst
, 0, sizeof(vDst
));
795 V_VT(&vDst
) = VT_EMPTY
;
797 memset(&vSrc
, 0, sizeof(vSrc
));
798 V_VT(&vSrc
) = vt
| ExtraFlags
[i
];
800 hExpected
= DISP_E_BADVARTYPE
;
801 if (!(ExtraFlags
[i
] & VT_BYREF
))
803 /* if src is not by-reference, acts as VariantCopy() */
804 if (vt
!= VT_CLSID
&& IsValidVariantClearVT(vt
, ExtraFlags
[i
]))
809 if (vt
== VT_SAFEARRAY
|| vt
== VT_BSTR
|| vt
== VT_UNKNOWN
||
810 vt
== VT_DISPATCH
|| vt
== VT_RECORD
)
811 continue; /* Need valid ptrs for deep copies, see vartype.c */
813 V_BYREF(&vSrc
) = &buffer
;
815 hExpected
= E_INVALIDARG
;
817 if ((vt
== VT_I8
|| vt
== VT_UI8
) &&
818 ExtraFlags
[i
] == VT_BYREF
)
821 hExpected
= S_OK
; /* Only valid if I8 is a known type */
823 else if (IsValidVariantCopyIndVT(vt
, ExtraFlags
[i
]))
827 hres
= VariantCopyInd(&vDst
, &vSrc
);
829 ok(hres
== hExpected
,
830 "CopyInd(bad src): expected 0x%X, got 0x%X for src vt %d|0x%X\n",
831 hExpected
, hres
, vt
, ExtraFlags
[i
]);
834 if (vt
== VT_VARIANT
&& ExtraFlags
[i
] == VT_BYREF
)
836 /* Type of vDst should be the type of the referenced variant.
837 * Since we set the buffer to all zeros, its type should be
840 ok(V_VT(&vDst
) == VT_EMPTY
,
841 "CopyInd(bad src): expected dst vt = VT_EMPTY, got %d|0x%X\n",
842 V_VT(&vDst
) & VT_TYPEMASK
, V_VT(&vDst
) & ~VT_TYPEMASK
);
846 ok(V_VT(&vDst
) == (vt
|(ExtraFlags
[i
] & ~VT_BYREF
)),
847 "CopyInd(bad src): expected dst vt = %d|0x%X, got %d|0x%X\n",
848 vt
, ExtraFlags
[i
] & ~VT_BYREF
,
849 V_VT(&vDst
) & VT_TYPEMASK
, V_VT(&vDst
) & ~VT_TYPEMASK
);
856 /* By-reference variants are dereferenced */
857 V_VT(&vRef
) = VT_UI1
;
859 V_VT(&vSrc
) = VT_VARIANT
|VT_BYREF
;
860 V_VARIANTREF(&vSrc
) = &vRef
;
863 hres
= VariantCopyInd(&vDst
, &vSrc
);
864 ok(hres
== S_OK
, "VariantCopyInd failed: 0x%08x\n", hres
);
865 ok(V_VT(&vDst
) == VT_UI1
&& V_UI1(&vDst
) == 0x77,
866 "CopyInd(deref): expected dst vt = VT_UI1, val 0x77, got %d|0x%X, 0x%2X\n",
867 V_VT(&vDst
) & VT_TYPEMASK
, V_VT(&vDst
) & ~VT_TYPEMASK
, V_UI1(&vDst
));
869 /* By-reference variant to a by-reference type succeeds */
870 V_VT(&vRef
) = VT_UI1
|VT_BYREF
;
871 V_UI1REF(&vRef
) = buffer
; buffer
[0] = 0x88;
872 V_VT(&vSrc
) = VT_VARIANT
|VT_BYREF
;
873 V_VARIANTREF(&vSrc
) = &vRef
;
876 hres
= VariantCopyInd(&vDst
, &vSrc
);
877 ok(hres
== S_OK
, "VariantCopyInd failed: 0x%08x\n", hres
);
878 ok(V_VT(&vDst
) == VT_UI1
&& V_UI1(&vDst
) == 0x88,
879 "CopyInd(deref): expected dst vt = VT_UI1, val 0x77, got %d|0x%X, 0x%2X\n",
880 V_VT(&vDst
) & VT_TYPEMASK
, V_VT(&vDst
) & ~VT_TYPEMASK
, V_UI1(&vDst
));
882 /* But a by-reference variant to a by-reference variant fails */
883 V_VT(&vRef2
) = VT_UI1
;
884 V_UI1(&vRef2
) = 0x77;
885 V_VT(&vRef
) = VT_VARIANT
|VT_BYREF
;
886 V_VARIANTREF(&vRef
) = &vRef2
;
887 V_VT(&vSrc
) = VT_VARIANT
|VT_BYREF
;
888 V_VARIANTREF(&vSrc
) = &vRef
;
891 hres
= VariantCopyInd(&vDst
, &vSrc
);
892 ok(hres
== E_INVALIDARG
,
893 "CopyInd(ref->ref): expected E_INVALIDARG, got 0x%08x\n", hres
);
896 static HRESULT (WINAPI
*pVarParseNumFromStr
)(OLECHAR
*,LCID
,ULONG
,NUMPARSE
*,BYTE
*);
898 /* Macros for converting and testing the result of VarParseNumFromStr */
901 static HRESULT
convert_str( const char *str
, INT dig
, ULONG flags
,
902 NUMPARSE
*np
, BYTE rgb
[128], LCID lcid
)
905 MultiByteToWideChar( CP_ACP
,0, str
, -1, buff
, sizeof(buff
)/sizeof(WCHAR
) );
906 memset( rgb
, FAILDIG
, 128 );
907 memset( np
, 255, sizeof(*np
) );
909 np
->dwInFlags
= flags
;
910 return pVarParseNumFromStr( buff
, lcid
, LOCALE_NOUSEROVERRIDE
, np
, rgb
);
913 static void expect_NumFromStr( int line
, HRESULT hres
, NUMPARSE
*np
, INT a
, ULONG b
, ULONG c
,
914 INT d
, INT e
, INT f
)
916 if (hres
== (HRESULT
)S_OK
)
918 ok_(__FILE__
,line
)(np
->cDig
== a
, "Expected cDig = %d, got %d\n", a
, np
->cDig
);
919 ok_(__FILE__
,line
)(np
->dwInFlags
== b
, "Expected dwInFlags = 0x%x, got 0x%x\n", b
, np
->dwInFlags
);
920 ok_(__FILE__
,line
)(np
->dwOutFlags
== c
, "Expected dwOutFlags = 0x%x, got 0x%x\n", c
, np
->dwOutFlags
);
921 ok_(__FILE__
,line
)(np
->cchUsed
== d
, "Expected cchUsed = %d, got %d\n", d
, np
->cchUsed
);
922 ok_(__FILE__
,line
)(np
->nBaseShift
== e
, "Expected nBaseShift = %d, got %d\n", e
, np
->nBaseShift
);
923 ok_(__FILE__
,line
)(np
->nPwr10
== f
, "Expected nPwr10 = %d, got %d\n", f
, np
->nPwr10
);
927 #define CONVERTN(str,dig,flags) hres = convert_str( str, dig, flags, &np, rgb, lcid )
928 #define CONVERT(str,flags) CONVERTN(str,sizeof(rgb),flags)
929 #define EXPECT(a,b,c,d,e,f) expect_NumFromStr( __LINE__, hres, &np, a, b, c, d, e, f )
930 #define EXPECTRGB(a,b) ok(rgb[a] == b, "Digit[%d], expected %d, got %d\n", a, b, rgb[a])
931 #define EXPECTFAIL ok(hres == (HRESULT)DISP_E_TYPEMISMATCH, "Call succeeded, hres = %08x\n", hres)
932 #define EXPECT2(a,b) EXPECTRGB(0,a); EXPECTRGB(1,b)
934 static void test_VarParseNumFromStr(void)
937 /* Ensure all tests are using the same locale characters for '$', ',' etc */
938 LCID lcid
= MAKELCID(MAKELANGID(LANG_ENGLISH
,SUBLANG_ENGLISH_US
),SORT_DEFAULT
);
944 CHECKPTR(VarParseNumFromStr
);
946 /* Consume a single digit */
951 /* cDig is not literal digits - zeros are suppressed and nPwr10 is increased */
954 /* Note: Win32 writes the trailing zeros if they are within cDig's limits,
955 * but then excludes them from the returned cDig count.
956 * In our implementation we don't bother writing them at all.
960 /* if cDig is too small and numbers follow, sets INEXACT */
962 EXPECT(1,0,NUMPRS_INEXACT
,2,0,1);
965 /* Strips leading zeros */
970 /* Strips leading zeros */
976 /* Fails on non digits */
979 EXPECTRGB(0,FAILDIG
);
981 /** NUMPRS_LEADING_WHITE/NUMPRS_TRAILING_WHITE **/
983 /* Without flag, fails on whitespace */
986 EXPECTRGB(0,FAILDIG
);
989 /* With flag, consumes whitespace */
990 CONVERT(" 0", NUMPRS_LEADING_WHITE
);
991 EXPECT(1,NUMPRS_LEADING_WHITE
,NUMPRS_LEADING_WHITE
,2,0,0);
994 /* Test TAB once, then assume it acts as space for all cases */
995 CONVERT("\t0", NUMPRS_LEADING_WHITE
);
996 EXPECT(1,NUMPRS_LEADING_WHITE
,NUMPRS_LEADING_WHITE
,2,0,0);
1000 /* Doesn't pick up trailing whitespace without flag */
1002 EXPECT(1,0,0,1,0,0);
1005 /* With flag, consumes trailing whitespace */
1006 CONVERT("0 ", NUMPRS_TRAILING_WHITE
);
1007 EXPECT(1,NUMPRS_TRAILING_WHITE
,NUMPRS_TRAILING_WHITE
,2,0,0);
1010 /* Leading flag only consumes leading */
1011 CONVERT(" 0 ", NUMPRS_LEADING_WHITE
);
1012 EXPECT(1,NUMPRS_LEADING_WHITE
,NUMPRS_LEADING_WHITE
,2,0,0);
1015 /* Both flags consumes both */
1016 CONVERT(" 0 ", NUMPRS_LEADING_WHITE
|NUMPRS_TRAILING_WHITE
);
1017 EXPECT(1,NUMPRS_LEADING_WHITE
|NUMPRS_TRAILING_WHITE
,NUMPRS_LEADING_WHITE
|NUMPRS_TRAILING_WHITE
,3,0,0);
1020 /** NUMPRS_LEADING_PLUS/NUMPRS_TRAILING_PLUS **/
1022 /* Without flag, fails on + */
1025 EXPECTRGB(0,FAILDIG
);
1027 /* With flag, consumes + */
1028 CONVERT("+0", NUMPRS_LEADING_PLUS
);
1029 EXPECT(1,NUMPRS_LEADING_PLUS
,NUMPRS_LEADING_PLUS
,2,0,0);
1032 /* Without flag, doesn't consume trailing + */
1034 EXPECT(1,0,0,1,0,0);
1037 /* With flag, consumes trailing + */
1038 CONVERT("0+", NUMPRS_TRAILING_PLUS
);
1039 EXPECT(1,NUMPRS_TRAILING_PLUS
,NUMPRS_TRAILING_PLUS
,2,0,0);
1042 /* With leading flag, doesn't consume trailing + */
1043 CONVERT("+0+", NUMPRS_LEADING_PLUS
);
1044 EXPECT(1,NUMPRS_LEADING_PLUS
,NUMPRS_LEADING_PLUS
,2,0,0);
1047 /* Trailing + doesn't get consumed if we specify both (unlike whitespace) */
1048 CONVERT("+0+", NUMPRS_LEADING_PLUS
|NUMPRS_TRAILING_PLUS
);
1049 EXPECT(1,NUMPRS_LEADING_PLUS
|NUMPRS_TRAILING_PLUS
,NUMPRS_LEADING_PLUS
,2,0,0);
1052 /** NUMPRS_LEADING_MINUS/NUMPRS_TRAILING_MINUS **/
1054 /* Without flag, fails on - */
1057 EXPECTRGB(0,FAILDIG
);
1059 /* With flag, consumes - */
1060 CONVERT("-0", NUMPRS_LEADING_MINUS
);
1061 EXPECT(1,NUMPRS_LEADING_MINUS
,NUMPRS_NEG
|NUMPRS_LEADING_MINUS
,2,0,0);
1064 /* Without flag, doesn't consume trailing - */
1066 EXPECT(1,0,0,1,0,0);
1069 /* With flag, consumes trailing - */
1070 CONVERT("0-", NUMPRS_TRAILING_MINUS
);
1071 EXPECT(1,NUMPRS_TRAILING_MINUS
,NUMPRS_NEG
|NUMPRS_TRAILING_MINUS
,2,0,0);
1074 /* With leading flag, doesn't consume trailing - */
1075 CONVERT("-0-", NUMPRS_LEADING_MINUS
);
1076 EXPECT(1,NUMPRS_LEADING_MINUS
,NUMPRS_NEG
|NUMPRS_LEADING_MINUS
,2,0,0);
1079 /* Trailing - doesn't get consumed if we specify both (unlike whitespace) */
1080 CONVERT("-0-", NUMPRS_LEADING_MINUS
|NUMPRS_TRAILING_MINUS
);
1081 EXPECT(1,NUMPRS_LEADING_MINUS
|NUMPRS_TRAILING_MINUS
,NUMPRS_NEG
|NUMPRS_LEADING_MINUS
,2,0,0);
1084 /** NUMPRS_HEX_OCT **/
1086 /* Could be hex, octal or decimal - With flag reads as decimal */
1087 CONVERT("0", NUMPRS_HEX_OCT
);
1088 EXPECT(1,NUMPRS_HEX_OCT
,0,1,0,0);
1091 /* Doesn't recognise hex in .asm syntax */
1092 CONVERT("0h", NUMPRS_HEX_OCT
);
1093 EXPECT(1,NUMPRS_HEX_OCT
,0,1,0,0);
1096 /* Doesn't fail with valid leading string but no digits */
1097 CONVERT("0x", NUMPRS_HEX_OCT
);
1098 EXPECT(1,NUMPRS_HEX_OCT
,0,1,0,0);
1101 /* Doesn't recognise hex format numbers at all! */
1102 CONVERT("0x0", NUMPRS_HEX_OCT
);
1103 EXPECT(1,NUMPRS_HEX_OCT
,0,1,0,0);
1106 /* Doesn't recognise plain hex digits either */
1107 CONVERT("FE", NUMPRS_HEX_OCT
);
1109 EXPECTRGB(0,FAILDIG
);
1112 CONVERT("0100", NUMPRS_HEX_OCT
);
1113 EXPECT(1,NUMPRS_HEX_OCT
,0,4,0,2);
1117 EXPECTRGB(3,FAILDIG
);
1120 CONVERT("&HF800", NUMPRS_HEX_OCT
);
1121 EXPECT(4,NUMPRS_HEX_OCT
,0x40,6,4,0);
1126 EXPECTRGB(4,FAILDIG
);
1128 /* VB hex lower case and leading zero */
1129 CONVERT("&h0abcdef", NUMPRS_HEX_OCT
);
1130 EXPECT(6,NUMPRS_HEX_OCT
,0x40,9,4,0);
1137 EXPECTRGB(6,FAILDIG
);
1140 CONVERT("&O300", NUMPRS_HEX_OCT
);
1141 EXPECT(3,NUMPRS_HEX_OCT
,0x40,5,3,0);
1145 EXPECTRGB(3,FAILDIG
);
1147 /* VB oct lower case and leading zero */
1148 CONVERT("&o0777", NUMPRS_HEX_OCT
);
1149 EXPECT(3,NUMPRS_HEX_OCT
,0x40,6,3,0);
1153 EXPECTRGB(3,FAILDIG
);
1155 /* VB oct char bigger than 7 */
1156 CONVERT("&o128", NUMPRS_HEX_OCT
);
1158 Native versions 2.x of oleaut32 allow this to succeed: later versions and Wine don't
1160 EXPECTRGB(0,FAILDIG);
1162 /** NUMPRS_PARENS **/
1164 /* Empty parens = error */
1165 CONVERT("()", NUMPRS_PARENS
);
1167 EXPECTRGB(0,FAILDIG
);
1169 /* With flag, trailing parens not consumed */
1170 CONVERT("0()", NUMPRS_PARENS
);
1171 EXPECT(1,NUMPRS_PARENS
,0,1,0,0);
1174 /* With flag, Number in parens made negative and parens consumed */
1175 CONVERT("(0)", NUMPRS_PARENS
);
1176 EXPECT(1,NUMPRS_PARENS
,NUMPRS_NEG
|NUMPRS_PARENS
,3,0,0);
1179 /** NUMPRS_THOUSANDS **/
1181 /* With flag, thousands sep. not needed */
1182 CONVERT("0", NUMPRS_THOUSANDS
);
1183 EXPECT(1,NUMPRS_THOUSANDS
,0,1,0,0);
1186 /* With flag, thousands sep. and following digits consumed */
1187 CONVERT("1,000", NUMPRS_THOUSANDS
);
1188 EXPECT(1,NUMPRS_THOUSANDS
,NUMPRS_THOUSANDS
,5,0,3);
1191 /* With flag and decimal point, thousands sep. but not decimals consumed */
1192 CONVERT("1,000.0", NUMPRS_THOUSANDS
);
1193 EXPECT(1,NUMPRS_THOUSANDS
,NUMPRS_THOUSANDS
,5,0,3);
1196 /** NUMPRS_CURRENCY **/
1198 /* Without flag, chokes on currency sign */
1201 EXPECTRGB(0,FAILDIG
);
1203 /* With flag, consumes currency sign */
1204 CONVERT("$11", NUMPRS_CURRENCY
);
1205 EXPECT(2,NUMPRS_CURRENCY
,NUMPRS_CURRENCY
,3,0,0);
1207 EXPECTRGB(2,FAILDIG
);
1209 /* With flag only, doesn't consume decimal point */
1210 CONVERT("$11.1", NUMPRS_CURRENCY
);
1211 EXPECT(2,NUMPRS_CURRENCY
,NUMPRS_CURRENCY
,3,0,0);
1213 EXPECTRGB(2,FAILDIG
);
1215 /* With flag and decimal flag, consumes decimal point and following digits */
1216 CONVERT("$11.1", NUMPRS_CURRENCY
|NUMPRS_DECIMAL
);
1217 EXPECT(3,NUMPRS_CURRENCY
|NUMPRS_DECIMAL
,NUMPRS_CURRENCY
|NUMPRS_DECIMAL
,5,0,-1);
1220 EXPECTRGB(3,FAILDIG
);
1222 /* Thousands flag can only be used with currency */
1223 CONVERT("$1,234", NUMPRS_CURRENCY
|NUMPRS_THOUSANDS
);
1224 EXPECT(4,NUMPRS_CURRENCY
|NUMPRS_THOUSANDS
,NUMPRS_CURRENCY
|NUMPRS_THOUSANDS
,6,0,0);
1228 EXPECTRGB(4,FAILDIG
);
1230 /** NUMPRS_DECIMAL **/
1232 /* With flag, consumes decimal point */
1233 CONVERT("1.1", NUMPRS_DECIMAL
);
1234 EXPECT(2,NUMPRS_DECIMAL
,NUMPRS_DECIMAL
,3,0,-1);
1236 EXPECTRGB(2,FAILDIG
);
1238 /* With flag, consumes decimal point. Skipping the decimal part is not an error */
1239 CONVERT("1.", NUMPRS_DECIMAL
);
1240 EXPECT(1,NUMPRS_DECIMAL
,NUMPRS_DECIMAL
,2,0,0);
1243 /* Consumes only one decimal point */
1244 CONVERT("1.1.", NUMPRS_DECIMAL
);
1245 EXPECT(2,NUMPRS_DECIMAL
,NUMPRS_DECIMAL
,3,0,-1);
1247 EXPECTRGB(2,FAILDIG
);
1249 /** NUMPRS_EXPONENT **/
1251 /* Without flag, doesn't consume exponent */
1253 EXPECT(1,0,0,1,0,0);
1256 /* With flag, consumes exponent */
1257 CONVERT("1e1", NUMPRS_EXPONENT
);
1258 EXPECT(1,NUMPRS_EXPONENT
,NUMPRS_EXPONENT
,3,0,1);
1261 /* Negative exponents are accepted without flags */
1262 CONVERT("1e-1", NUMPRS_EXPONENT
);
1263 EXPECT(1,NUMPRS_EXPONENT
,NUMPRS_EXPONENT
,4,0,-1);
1266 /* As are positive exponents and leading exponent 0s */
1267 CONVERT("1e+01", NUMPRS_EXPONENT
);
1268 EXPECT(1,NUMPRS_EXPONENT
,NUMPRS_EXPONENT
,5,0,1);
1271 /* The same for zero exponents */
1272 CONVERT("1e0", NUMPRS_EXPONENT
);
1273 EXPECT(1,NUMPRS_EXPONENT
,NUMPRS_EXPONENT
,3,0,0);
1276 /* Sign on a zero exponent doesn't matter */
1277 CONVERT("1e+0", NUMPRS_EXPONENT
);
1278 EXPECT(1,NUMPRS_EXPONENT
,NUMPRS_EXPONENT
,4,0,0);
1281 CONVERT("1e-0", NUMPRS_EXPONENT
);
1282 EXPECT(1,NUMPRS_EXPONENT
,NUMPRS_EXPONENT
,4,0,0);
1285 /* Doesn't consume a real number exponent */
1286 CONVERT("1e1.", NUMPRS_EXPONENT
);
1287 EXPECT(1,NUMPRS_EXPONENT
,NUMPRS_EXPONENT
,3,0,1);
1290 /* Powers of 10 are calculated from the position of any decimal point */
1291 CONVERT("1.5e20", NUMPRS_EXPONENT
|NUMPRS_DECIMAL
);
1292 EXPECT(2,NUMPRS_EXPONENT
|NUMPRS_DECIMAL
,NUMPRS_EXPONENT
|NUMPRS_DECIMAL
,6,0,19);
1295 CONVERT("1.5e-20", NUMPRS_EXPONENT
|NUMPRS_DECIMAL
);
1296 EXPECT(2,NUMPRS_EXPONENT
|NUMPRS_DECIMAL
,NUMPRS_EXPONENT
|NUMPRS_DECIMAL
,7,0,-21);
1299 /** NUMPRS_USE_ALL **/
1301 /* Flag expects all digits */
1302 CONVERT("0", NUMPRS_USE_ALL
);
1303 EXPECT(1,NUMPRS_USE_ALL
,0,1,0,0);
1306 /* Rejects anything trailing */
1307 CONVERT("0 ", NUMPRS_USE_ALL
);
1311 /* Unless consumed by trailing flag */
1312 CONVERT("0 ", NUMPRS_USE_ALL
|NUMPRS_TRAILING_WHITE
);
1313 EXPECT(1,NUMPRS_USE_ALL
|NUMPRS_TRAILING_WHITE
,NUMPRS_TRAILING_WHITE
,2,0,0);
1316 /** Combinations **/
1318 /* Leading whitespace and plus, doesn't consume trailing whitespace */
1319 CONVERT("+ 0 ", NUMPRS_LEADING_PLUS
|NUMPRS_LEADING_WHITE
);
1320 EXPECT(1,NUMPRS_LEADING_PLUS
|NUMPRS_LEADING_WHITE
,NUMPRS_LEADING_PLUS
|NUMPRS_LEADING_WHITE
,3,0,0);
1323 /* Order of whitespace and plus is unimportant */
1324 CONVERT(" +0", NUMPRS_LEADING_PLUS
|NUMPRS_LEADING_WHITE
);
1325 EXPECT(1,NUMPRS_LEADING_PLUS
|NUMPRS_LEADING_WHITE
,NUMPRS_LEADING_PLUS
|NUMPRS_LEADING_WHITE
,3,0,0);
1328 /* Leading whitespace can be repeated */
1329 CONVERT(" + 0", NUMPRS_LEADING_PLUS
|NUMPRS_LEADING_WHITE
);
1330 EXPECT(1,NUMPRS_LEADING_PLUS
|NUMPRS_LEADING_WHITE
,NUMPRS_LEADING_PLUS
|NUMPRS_LEADING_WHITE
,4,0,0);
1333 /* But plus/minus etc. cannot */
1334 CONVERT("+ +0", NUMPRS_LEADING_PLUS
|NUMPRS_LEADING_WHITE
);
1336 EXPECTRGB(0,FAILDIG
);
1338 /* Inexact is not set if trailing zeros are removed */
1339 CONVERTN("10", 1, 0);
1340 EXPECT(1,0,0,2,0,1);
1343 /* Make sure a leading 0 is stripped but decimals after it get read */
1344 CONVERT("-0.51", NUMPRS_STD
);
1345 EXPECT(2,NUMPRS_STD
,NUMPRS_NEG
|NUMPRS_DECIMAL
|NUMPRS_LEADING_MINUS
,5,0,-2);
1348 /* Keep trailing zeros on whole number part of a decimal */
1349 CONVERT("10.1", NUMPRS_STD
);
1350 EXPECT(3,NUMPRS_STD
,NUMPRS_DECIMAL
,4,0,-1);
1354 /* Zeros after decimal sign */
1355 CONVERT("0.01", NUMPRS_STD
);
1356 EXPECT(1,NUMPRS_STD
,NUMPRS_DECIMAL
,4,0,-2);
1359 /* Trailing zeros after decimal part */
1360 CONVERT("0.10", NUMPRS_STD
);
1361 EXPECT(1,NUMPRS_STD
,NUMPRS_DECIMAL
,4,0,-1);
1365 static HRESULT (WINAPI
*pVarNumFromParseNum
)(NUMPARSE
*,BYTE
*,ULONG
,VARIANT
*);
1367 /* Macros for converting and testing the result of VarNumFromParseNum */
1368 #define SETRGB(indx,val) if (!indx) memset(rgb, FAILDIG, sizeof(rgb)); rgb[indx] = val
1370 #define CONVERT(a,b,c,d,e,f,bits) \
1371 np.cDig = (a); np.dwInFlags = (b); np.dwOutFlags = (c); np.cchUsed = (d); \
1372 np.nBaseShift = (e); np.nPwr10 = (f); hres = pVarNumFromParseNum(&np, rgb, bits, &vOut)
1373 static const char *szFailOverflow
= "Expected overflow, hres = %08x\n";
1374 #define EXPECT_OVERFLOW ok(hres == (HRESULT)DISP_E_OVERFLOW, szFailOverflow, hres)
1375 static const char *szFailOk
= "Call failed, hres = %08x\n";
1376 #define EXPECT_OK ok(hres == (HRESULT)S_OK, szFailOk, hres); \
1377 if (hres == (HRESULT)S_OK)
1378 #define EXPECT_TYPE(typ) ok(V_VT(&vOut) == typ,"Expected Type = " #typ ", got %d\n", V_VT(&vOut))
1379 #define EXPECT_I1(val) EXPECT_OK { EXPECT_TYPE(VT_I1); \
1380 ok(V_I1(&vOut) == val, "Expected i1 = %d, got %d\n", (signed char)val, V_I1(&vOut)); }
1381 #define EXPECT_UI1(val) EXPECT_OK { EXPECT_TYPE(VT_UI1); \
1382 ok(V_UI1(&vOut) == val, "Expected ui1 = %d, got %d\n", (BYTE)val, V_UI1(&vOut)); }
1383 #define EXPECT_I2(val) EXPECT_OK { EXPECT_TYPE(VT_I2); \
1384 ok(V_I2(&vOut) == val, "Expected i2 = %d, got %d\n", (SHORT)val, V_I2(&vOut)); }
1385 #define EXPECT_UI2(val) EXPECT_OK { EXPECT_TYPE(VT_UI2); \
1386 ok(V_UI2(&vOut) == val, "Expected ui2 = %d, got %d\n", (USHORT)val, V_UI2(&vOut)); }
1387 #define EXPECT_I4(val) EXPECT_OK { EXPECT_TYPE(VT_I4); \
1388 ok(V_I4(&vOut) == val, "Expected i4 = %d, got %d\n", (LONG)val, V_I4(&vOut)); }
1389 #define EXPECT_UI4(val) EXPECT_OK { EXPECT_TYPE(VT_UI4); \
1390 ok(V_UI4(&vOut) == val, "Expected ui4 = %d, got %d\n", (ULONG)val, V_UI4(&vOut)); }
1391 #define EXPECT_I8(high,low) EXPECT_OK { EXPECT_TYPE(VT_I8); \
1392 ok(V_I8(&vOut) == ((((LONG64)(high))<<32)|(low)), "Expected i8 = %x%08x, got %x%08x\n", \
1393 (LONG)(high), (LONG)(low), (LONG)(V_I8(&vOut)>>32), (LONG)V_I8(&vOut) ); }
1394 #define EXPECT_UI8(val) EXPECT_OK { EXPECT_TYPE(VT_UI8); \
1395 ok(V_UI8(&vOut) == val, "Expected ui8 = 0x%x%08x, got 0x%x%08x\n", \
1396 (DWORD)((ULONG64)val >> 32), (DWORD)(ULONG64)val, (DWORD)(V_UI8(&vOut) >> 32), (DWORD)V_UI8(&vOut)); }
1397 #define EXPECT_R4(val) EXPECT_OK { EXPECT_TYPE(VT_R4); \
1398 ok(V_R4(&vOut) == val, "Expected r4 = %f, got %f\n", val, V_R4(&vOut)); }
1399 #define EXPECT_R8(val) EXPECT_OK { EXPECT_TYPE(VT_R8); \
1400 ok(V_R8(&vOut) == val, "Expected r8 = %g, got %g\n", val, V_R8(&vOut)); }
1401 #define CY_MULTIPLIER 10000
1402 #define EXPECT_CY(val) EXPECT_OK { EXPECT_TYPE(VT_CY); \
1403 ok(V_CY(&vOut).int64 == (LONG64)(val * CY_MULTIPLIER), "Expected r8 = 0x%x%08x, got 0x%x%08x\n", \
1404 (DWORD)((LONG64)val >> 23), (DWORD)(LONG64)val, (DWORD)(V_CY(&vOut).int64 >>32), (DWORD)V_CY(&vOut).int64); }
1405 #define EXPECT_DECIMAL(valHi, valMid, valLo) EXPECT_OK { EXPECT_TYPE(VT_DECIMAL); \
1406 ok((V_DECIMAL(&vOut).Hi32 == valHi) && (S1(U1(V_DECIMAL(&vOut))).Mid32 == valMid) && \
1407 (S1(U1(V_DECIMAL(&vOut))).Lo32 == valLo), \
1408 "Expected decimal = %x/0x%x%08x, got %x/0x%x%08x\n", valHi, valMid, valLo, \
1409 V_DECIMAL(&vOut).Hi32, S1(U1(V_DECIMAL(&vOut))).Mid32, S1(U1(V_DECIMAL(&vOut))).Lo32); }
1411 static void test_VarNumFromParseNum(void)
1418 CHECKPTR(VarNumFromParseNum
);
1420 /* Convert the number 1 to different types */
1421 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_I1
); EXPECT_I1(1);
1422 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_UI1
); EXPECT_UI1(1);
1423 /* Prefers a signed type to unsigned of the same size */
1424 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_I1
|VTBIT_UI1
); EXPECT_I1(1);
1425 /* But takes the smaller size if possible */
1426 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_I2
|VTBIT_UI1
); EXPECT_UI1(1);
1428 /* Try different integer sizes */
1429 #define INTEGER_VTBITS (VTBIT_I1|VTBIT_UI1|VTBIT_I2|VTBIT_UI2|VTBIT_I4|VTBIT_UI4|VTBIT_I8|VTBIT_UI8)
1431 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, INTEGER_VTBITS
); EXPECT_I1(1);
1433 SETRGB(0, 1); SETRGB(1, 2); SETRGB(2, 7);
1434 CONVERT(3,0,0,3,0,0, INTEGER_VTBITS
); EXPECT_I1(127);
1436 SETRGB(0, 1); SETRGB(1, 2); SETRGB(2, 8);
1437 CONVERT(3,0,0,3,0,0, INTEGER_VTBITS
); EXPECT_UI1(128);
1439 SETRGB(0, 2); SETRGB(1, 5); SETRGB(2, 5);
1440 CONVERT(3,0,0,3,0,0, INTEGER_VTBITS
); EXPECT_UI1(255);
1442 SETRGB(0, 2); SETRGB(1, 5); SETRGB(2, 6);
1443 CONVERT(3,0,0,3,0,0, INTEGER_VTBITS
); EXPECT_I2(256);
1445 SETRGB(0, 3); SETRGB(1, 2); SETRGB(2, 7); SETRGB(3, 6); SETRGB(4, 7);
1446 CONVERT(5,0,0,5,0,0, INTEGER_VTBITS
); EXPECT_I2(32767);
1448 SETRGB(0, 3); SETRGB(1, 2); SETRGB(2, 7); SETRGB(3, 6); SETRGB(4, 8);
1449 CONVERT(5,0,0,5,0,0, INTEGER_VTBITS
); EXPECT_UI2(32768);
1451 /* Assume the above pattern holds for remaining positive integers; test negative */
1454 SETRGB(0, 1); SETRGB(1, 2); SETRGB(2, 8);
1455 CONVERT(3,0,NUMPRS_NEG
,3,0,0, INTEGER_VTBITS
); EXPECT_I1(-128);
1457 SETRGB(0, 1); SETRGB(1, 2); SETRGB(2, 9);
1458 CONVERT(3,0,NUMPRS_NEG
,3,0,0, INTEGER_VTBITS
); EXPECT_I2(-129);
1460 SETRGB(0, 3); SETRGB(1, 2); SETRGB(2, 7); SETRGB(3, 6); SETRGB(4, 8);
1461 CONVERT(5,0,NUMPRS_NEG
,5,0,0, INTEGER_VTBITS
); EXPECT_I2(-32768);
1463 SETRGB(0, 3); SETRGB(1, 2); SETRGB(2, 7); SETRGB(3, 6); SETRGB(4, 9);
1464 CONVERT(5,0,NUMPRS_NEG
,5,0,0, INTEGER_VTBITS
); EXPECT_I4(-32769);
1466 /* Assume the above pattern holds for remaining negative integers */
1468 /* Test hexadecimal conversions */
1469 SETRGB(0, 1); CONVERT(1,0,0,1,4,0, INTEGER_VTBITS
); EXPECT_I1(0x01);
1471 SETRGB(0, 7); SETRGB(1, 0xf);
1472 CONVERT(2,0,0,2,4,0, INTEGER_VTBITS
); EXPECT_I1(0x7f);
1473 SETRGB(0, 7); SETRGB(1, 0xf);
1474 CONVERT(2,0,0,2,4,0, VTBIT_DECIMAL
); EXPECT_DECIMAL(0,0,0x7f);
1476 SETRGB(0, 7); SETRGB(1, 0xf); SETRGB(2, 0xf); SETRGB(3, 0xf);
1477 CONVERT(4,0,0,4,4,0, INTEGER_VTBITS
); EXPECT_I2(0x7fff);
1479 SETRGB(0, 7); SETRGB(1, 0xf); SETRGB(2, 0xf); SETRGB(3, 0xf);
1480 SETRGB(4, 0xf); SETRGB(5, 0xf); SETRGB(6, 0xf); SETRGB(7, 0xf);
1481 CONVERT(8,0,0,8,4,0, INTEGER_VTBITS
); EXPECT_I4(0x7fffffffL
);
1482 /* 0x7fffffffffffffff (64 bits) */
1483 SETRGB(0, 7); SETRGB(1, 0xf); SETRGB(2, 0xf); SETRGB(3, 0xf);
1484 SETRGB(4, 0xf); SETRGB(5, 0xf); SETRGB(6, 0xf); SETRGB(7, 0xf);
1485 SETRGB(8, 0xf); SETRGB(9, 0xf); SETRGB(10, 0xf); SETRGB(11, 0xf);
1486 SETRGB(12, 0xf); SETRGB(13, 0xf); SETRGB(14, 0xf); SETRGB(15, 0xf);
1489 /* We cannot use INTEGER_VTBITS as WinXP and Win2003 are broken(?). They
1490 truncate the number to the smallest integer size requested:
1491 CONVERT(16,0,0,16,4,0, INTEGER_VTBITS); EXPECT_I1((signed char)0xff); */
1492 CONVERT(16,0,0,16,4,0, VTBIT_I8
); EXPECT_I8(0x7fffffff,0xffffffff);
1495 /* Assume the above pattern holds for numbers without hi-bit set, test (preservation of) hi-bit */
1497 SETRGB(0, 8); SETRGB(1, 2);
1498 CONVERT(2,0,0,2,4,0, INTEGER_VTBITS
);
1499 EXPECT_I1((signed char)0x82);
1501 SETRGB(0, 8); SETRGB(1, 0); SETRGB(2, 0); SETRGB(3, 2);
1502 CONVERT(4,0,0,4,4,0, INTEGER_VTBITS
);
1503 EXPECT_I2((signed short)0x8002);
1505 SETRGB(0, 8); SETRGB(1, 0); SETRGB(2, 0); SETRGB(3, 0);
1506 SETRGB(4, 0); SETRGB(5, 0); SETRGB(6, 0); SETRGB(7, 2);
1507 CONVERT(8,0,0,8,4,0, INTEGER_VTBITS
); EXPECT_I4(0x80000002);
1508 /* 0x8000000000000002 (64 bits) */
1509 SETRGB(0, 8); SETRGB(1, 0); SETRGB(2, 0); SETRGB(3, 0);
1510 SETRGB(4, 0); SETRGB(5, 0); SETRGB(6, 0); SETRGB(7, 0);
1511 SETRGB(8, 0); SETRGB(9, 0); SETRGB(10, 0); SETRGB(11, 0);
1512 SETRGB(12, 0); SETRGB(13, 0); SETRGB(14, 0); SETRGB(15, 2);
1515 /* We cannot use INTEGER_VTBITS as WinXP and Win2003 are broken(?). They
1516 truncate the number to the smallest integer size requested:
1517 CONVERT(16,0,0,16,4,0, INTEGER_VTBITS & ~VTBIT_I1);
1518 EXPECT_I2((signed short)0x0002); */
1519 CONVERT(16,0,0,16,4,0, VTBIT_I8
); EXPECT_I8(0x80000000,0x00000002);
1522 /* Test (preservation of) hi-bit with STRICT type requesting */
1524 SETRGB(0, 8); SETRGB(1, 2);
1525 CONVERT(2,0,0,2,4,0, VTBIT_I1
);
1526 EXPECT_I1((signed char)0x82);
1528 SETRGB(0, 8); SETRGB(1, 0); SETRGB(2, 0); SETRGB(3, 2);
1529 CONVERT(4,0,0,4,4,0, VTBIT_I2
);
1530 EXPECT_I2((signed short)0x8002);
1532 SETRGB(0, 8); SETRGB(1, 0); SETRGB(2, 0); SETRGB(3, 0);
1533 SETRGB(4, 0); SETRGB(5, 0); SETRGB(6, 0); SETRGB(7, 2);
1534 CONVERT(8,0,0,8,4,0, VTBIT_I4
); EXPECT_I4(0x80000002);
1535 /* 0x8000000000000002 (64 bits) */
1536 SETRGB(0, 8); SETRGB(1, 0); SETRGB(2, 0); SETRGB(3, 0);
1537 SETRGB(4, 0); SETRGB(5, 0); SETRGB(6, 0); SETRGB(7, 0);
1538 SETRGB(8, 0); SETRGB(9, 0); SETRGB(10, 0); SETRGB(11, 0);
1539 SETRGB(12, 0); SETRGB(13, 0); SETRGB(14, 0); SETRGB(15, 2);
1542 CONVERT(16,0,0,16,4,0, VTBIT_I8
); EXPECT_I8(0x80000000,0x00000002);
1544 /* Assume the above pattern holds for numbers with hi-bit set */
1546 /* Negative numbers overflow if we have only unsigned outputs */
1548 SETRGB(0, 1); CONVERT(1,0,NUMPRS_NEG
,1,0,0, VTBIT_UI1
); EXPECT_OVERFLOW
;
1550 SETRGB(0, 6); CONVERT(1,0,NUMPRS_NEG
,1,0,~0u, VTBIT_UI1
); EXPECT_OVERFLOW
;
1552 /* Except that rounding is done first, so -0.5 to 0 are accepted as 0 */
1554 SETRGB(0, 5); CONVERT(1,0,NUMPRS_NEG
,1,0,~0u, VTBIT_UI1
); EXPECT_UI1(0);
1556 /* Floating point zero is OK */
1558 SETRGB(0, 0); CONVERT(1,0,NUMPRS_DECIMAL
|NUMPRS_EXPONENT
,12,0,-8, VTBIT_R8
);
1561 /* Float is acceptable for an integer input value */
1562 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_R4
); EXPECT_R4(1.0f
);
1564 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_R8
); EXPECT_R8(1.0);
1565 /* As is currency */
1566 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_CY
); EXPECT_CY(1);
1568 /* Float is preferred over double */
1569 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_R4
|VTBIT_R8
); EXPECT_R4(1.0f
);
1571 /* Double is preferred over currency */
1572 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_R8
|VTBIT_CY
); EXPECT_R8(1.0);
1574 /* Currency is preferred over decimal */
1575 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_CY
|VTBIT_DECIMAL
); EXPECT_CY(1);
1579 static void test_UdateFromDate( int line
, DATE dt
, ULONG flags
, HRESULT r
, WORD d
, WORD m
, WORD y
,
1580 WORD h
, WORD mn
, WORD s
, WORD ms
, WORD dw
, WORD dy
)
1585 memset(&ud
, 0, sizeof(ud
));
1586 res
= pVarUdateFromDate(dt
, flags
, &ud
);
1587 ok_(__FILE__
,line
)(r
== res
&& (res
!= S_OK
|| (ud
.st
.wYear
== y
&& ud
.st
.wMonth
== m
&& ud
.st
.wDay
== d
&&
1588 ud
.st
.wHour
== h
&& ud
.st
.wMinute
== mn
&& ud
.st
.wSecond
== s
&&
1589 ud
.st
.wMilliseconds
== ms
&& ud
.st
.wDayOfWeek
== dw
&& ud
.wDayOfYear
== dy
)),
1590 "%.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",
1591 dt
, r
, d
, m
, y
, h
, mn
, s
, ms
, dw
, dy
,
1592 res
, ud
.st
.wDay
, ud
.st
.wMonth
, ud
.st
.wYear
, ud
.st
.wHour
, ud
.st
.wMinute
,
1593 ud
.st
.wSecond
, ud
.st
.wMilliseconds
, ud
.st
.wDayOfWeek
, ud
.wDayOfYear
);
1595 #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)
1597 static void test_VarUdateFromDate(void)
1599 CHECKPTR(VarUdateFromDate
);
1600 DT2UD(29221.0,0,S_OK
,1,1,1980,0,0,0,0,2,1); /* 1 Jan 1980 */
1601 DT2UD(29222.0,0,S_OK
,2,1,1980,0,0,0,0,3,2); /* 2 Jan 1980 */
1602 DT2UD(33238.0,0,S_OK
,31,12,1990,0,0,0,0,1,365); /* 31 Dec 1990 */
1603 DT2UD(0.0,0,S_OK
,30,12,1899,0,0,0,0,6,364); /* 30 Dec 1899 - VT_DATE 0.0 */
1604 DT2UD(-657434.0,0,S_OK
,1,1,100,0,0,0,0,5,1); /* 1 Jan 100 - Min */
1605 DT2UD(-657435.0,0,E_INVALIDARG
,0,0,0,0,0,0,0,0,0); /* < 1 Jan 100 => err */
1606 DT2UD(2958465.0,0,S_OK
,31,12,9999,0,0,0,0,5,365); /* 31 Dec 9999 - Max */
1607 DT2UD(2958466.0,0,E_INVALIDARG
,0,0,0,0,0,0,0,0,0); /* > 31 Dec 9999 => err */
1609 /* VAR_VALIDDATE doesn't prevent upper and lower bounds being checked */
1610 DT2UD(-657435.0,VAR_VALIDDATE
,E_INVALIDARG
,0,0,0,0,0,0,0,0,0);
1611 DT2UD(2958466.0,VAR_VALIDDATE
,E_INVALIDARG
,0,0,0,0,0,0,0,0,0);
1614 DT2UD(29221.25,0,S_OK
,1,1,1980,6,0,0,0,2,1); /* 6 AM */
1615 DT2UD(29221.33333333,0,S_OK
,1,1,1980,8,0,0,0,2,1); /* 8 AM */
1616 DT2UD(29221.5,0,S_OK
,1,1,1980,12,0,0,0,2,1); /* 12 AM */
1617 DT2UD(29221.9888884444,0,S_OK
,1,1,1980,23,44,0,0,2,1); /* 11:44 PM */
1618 DT2UD(29221.7508765432,0,S_OK
,1,1,1980,18,1,16,0,2,1); /* 6:18:02 PM */
1620 /* Test handling of times on dates prior to the epoch */
1621 DT2UD(-5.25,0,S_OK
,25,12,1899,6,0,0,0,1,359);
1622 DT2UD(-5.9999884259259,0,S_OK
,25,12,1899,23,59,59,0,1,359);
1623 /* This just demonstrates the non-linear nature of values prior to the epoch */
1624 DT2UD(-4.0,0,S_OK
,26,12,1899,0,0,0,0,2,360);
1625 /* Numerical oddity: for 0.0 < x < 1.0, x and -x represent the same datetime */
1626 DT2UD(-0.25,0,S_OK
,30,12,1899,6,0,0,0,6,364);
1627 DT2UD(0.25,0,S_OK
,30,12,1899,6,0,0,0,6,364);
1631 static void test_DateFromUDate( int line
, WORD d
, WORD m
, WORD y
, WORD h
, WORD mn
, WORD s
, WORD ms
,
1632 WORD dw
, WORD dy
, ULONG flags
, HRESULT r
, DATE dt
)
1644 ud
.st
.wMilliseconds
= ms
;
1645 ud
.st
.wDayOfWeek
= dw
;
1647 res
= pVarDateFromUdate(&ud
, flags
, &out
);
1648 ok_(__FILE__
,line
)(r
== res
&& (r
!= S_OK
|| EQ_DOUBLE(out
, dt
)),
1649 "expected %x, %.16g, got %x, %.16g\n", r
, dt
, res
, out
);
1651 #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)
1653 static void test_VarDateFromUdate(void)
1655 CHECKPTR(VarDateFromUdate
);
1656 UD2T(1,1,1980,0,0,0,0,2,1,0,S_OK
,29221.0); /* 1 Jan 1980 */
1657 UD2T(2,1,1980,0,0,0,0,3,2,0,S_OK
,29222.0); /* 2 Jan 1980 */
1658 UD2T(2,1,1980,0,0,0,0,4,5,0,S_OK
,29222.0); /* 2 Jan 1980 */
1659 UD2T(31,12,1990,0,0,0,0,0,0,0,S_OK
,33238.0); /* 31 Dec 1990 */
1660 UD2T(31,12,90,0,0,0,0,0,0,0,S_OK
,33238.0); /* year < 100 is 1900+year! */
1661 UD2T(30,12,1899,0,0,0,0,6,364,0,S_OK
,0.0); /* 30 Dec 1899 - VT_DATE 0.0 */
1662 UD2T(1,1,100,0,0,0,0,0,0,0,S_OK
,-657434.0); /* 1 Jan 100 - Min */
1663 UD2T(31,12,9999,0,0,0,0,0,0,0,S_OK
,2958465.0); /* 31 Dec 9999 - Max */
1664 UD2T(1,1,10000,0,0,0,0,0,0,0,E_INVALIDARG
,0.0); /* > 31 Dec 9999 => err */
1665 UD2T(1,1,-10000,0,0,0,0,0,0,0,E_INVALIDARG
,0.0);/* < -9999 => err */
1667 UD2T(30,12,1899,0,0,0,0,0,0,0,S_OK
,0.0); /* 30 Dec 1899 0:00:00 */
1668 UD2T(30,12,1899,0,0,0,999,0,0,0,S_OK
,0.0); /* Ignore milliseconds */
1670 UD2T(1,1,1980,18,1,16,0,2,1,0,S_OK
,29221.75087962963); /* 6:18:02 PM */
1671 UD2T(1,300,1980,18,1,16,0,2,1,0,S_OK
,38322.75087962963); /* Test fwdrolled month */
1672 UD2T(300,1,1980,18,1,16,0,2,1,0,S_OK
,29520.75087962963); /* Test fwdrolled days */
1673 UD2T(0,1,1980,42,1,16,0,2,1,0,S_OK
,29221.75087962963); /* Test fwdrolled hours */
1674 UD2T(1,1,1980,17,61,16,0,2,1,0,S_OK
,29221.75087962963); /* Test fwdrolled minutes */
1675 UD2T(1,1,1980,18,0,76,0,2,1,0,S_OK
,29221.75087962963); /* Test fwdrolled seconds */
1676 UD2T(1,-300,1980,18,1,16,0,2,1,0,S_OK
,20059.75087962963); /* Test backrolled month */
1677 UD2T(-300,1,1980,18,1,16,0,2,1,0,S_OK
,28920.75087962963); /* Test backrolled days */
1678 UD2T(3,1,1980,-30,1,16,0,2,1,0,S_OK
,29221.75087962963); /* Test backrolled hours */
1679 UD2T(1,1,1980,20,-119,16,0,2,1,0,S_OK
,29221.75087962963); /* Test backrolled minutes */
1680 UD2T(1,1,1980,18,3,-104,0,2,1,0,S_OK
,29221.75087962963); /* Test backrolled seconds */
1681 UD2T(1,12001,-1020,18,1,16,0,0,0,0,S_OK
,29221.75087962963); /* Test rolled year and month */
1682 UD2T(1,-23,1982,18,1,16,0,0,0,0,S_OK
,29221.75087962963); /* Test backrolled month */
1683 UD2T(-59,3,1980,18,1,16,0,0,0,0,S_OK
,29221.75087962963); /* Test backrolled days */
1684 UD2T(1,1,0,0,0,0,0,0,0,0,S_OK
,36526); /* Test zero year */
1685 UD2T(0,0,1980,0,0,0,0,0,0,0,S_OK
,29189); /* Test zero day and month */
1686 UD2T(0,1,1980,0,0,0,0,2,1,0,S_OK
,29220.0); /* Test zero day = LastDayOfMonth */
1687 UD2T(-1,1,1980,18,1,16,0,0,0,0,S_OK
,29219.75087962963); /* Test day -1 = LastDayOfMonth - 1 */
1688 UD2T(1,1,-1,18,1,16,0,0,0,0,S_OK
,36161.75087962963); /* Test year -1 = 1999 */
1689 UD2T(1,-1,1980,18,1,16,0,0,0,0,S_OK
,29160.7508796296); /* Test month -1 = 11 */
1690 UD2T(1,13,1980,0,0,0,0,2,1,0,S_OK
,29587.0); /* Rolls fwd to 1/1/1981 */
1692 /* Test handling of times on dates prior to the epoch */
1693 UD2T(25,12,1899,6,0,0,0,1,359,0,S_OK
,-5.25);
1694 UD2T(25,12,1899,23,59,59,0,1,359,0,S_OK
,-5.9999884259259);
1695 /* This just demonstrates the non-linear nature of values prior to the epoch */
1696 UD2T(26,12,1899,0,0,0,0,2,360,0,S_OK
,-4.0);
1697 /* for DATE values 0.0 < x < 1.0, x and -x represent the same datetime */
1698 /* but when converting to DATE, prefer the positive versions */
1699 UD2T(30,12,1899,6,0,0,0,6,364,0,S_OK
,0.25);
1702 static void test_st2dt(int line
, WORD d
, WORD m
, WORD y
, WORD h
, WORD mn
,
1703 WORD s
, WORD ms
, INT r
, double dt
)
1715 st
.wMilliseconds
= ms
;
1717 res
= pSystemTimeToVariantTime(&st
, &out
);
1718 ok_(__FILE__
,line
)(r
== res
&& (!r
|| EQ_DOUBLE(out
, dt
)),
1719 "expected %d, %.16g, got %d, %.16g\n", r
, dt
, res
, out
);
1721 #define ST2DT(d,m,y,h,mn,s,ms,r,dt) test_st2dt(__LINE__,d,m,y,h,mn,s,ms,r,dt)
1723 static void test_SystemTimeToVariantTime(void)
1725 CHECKPTR(SystemTimeToVariantTime
);
1726 ST2DT(1,1,1980,0,0,0,0,TRUE
,29221.0);
1727 ST2DT(2,1,1980,0,0,0,0,TRUE
,29222.0);
1728 ST2DT(0,1,1980,0,0,0,0,TRUE
,29220.0); /* Rolls back to 31 Dec 1899 */
1729 ST2DT(1,13,1980,0,0,0,0,FALSE
,29587.0); /* Fails on invalid month */
1730 ST2DT(31,12,90,0,0,0,0,TRUE
,33238.0); /* 30 <= year < 100 is 1900+year */
1731 ST2DT(1,1,30,0,0,0,0,TRUE
,10959.0); /* 30 <= year < 100 is 1900+year */
1732 ST2DT(1,1,29,0,0,0,0,TRUE
,47119.0); /* 0 <= year < 30 is 2000+year */
1733 ST2DT(1,1,0,0,0,0,0,TRUE
,36526.0); /* 0 <= year < 30 is 2000+year */
1736 static void test_dt2st(int line
, double dt
, INT r
, WORD d
, WORD m
, WORD y
,
1737 WORD h
, WORD mn
, WORD s
, WORD ms
)
1742 memset(&st
, 0, sizeof(st
));
1743 res
= pVariantTimeToSystemTime(dt
, &st
);
1744 ok_(__FILE__
,line
)(r
== res
&&
1745 (!r
|| (st
.wYear
== y
&& st
.wMonth
== m
&& st
.wDay
== d
&&
1746 st
.wHour
== h
&& st
.wMinute
== mn
&&
1747 st
.wSecond
== s
&& st
.wMilliseconds
== ms
)),
1748 "%.16g expected %d, %d,%d,%d,%d,%d,%d,%d, got %d, %d,%d,%d,%d,%d,%d,%d\n",
1749 dt
, r
, d
, m
, y
, h
, mn
, s
, ms
, res
, st
.wDay
, st
.wMonth
,
1750 st
.wYear
, st
.wHour
, st
.wMinute
, st
.wSecond
,
1753 #define DT2ST(dt,r,d,m,y,h,mn,s,ms) test_dt2st(__LINE__,dt,r,d,m,y,h,mn,s,ms)
1755 static void test_VariantTimeToSystemTime(void)
1757 CHECKPTR(VariantTimeToSystemTime
);
1758 DT2ST(29221.0,1,1,1,1980,0,0,0,0);
1759 DT2ST(29222.0,1,2,1,1980,0,0,0,0);
1762 #define MKDOSDATE(d,m,y) ((d & 0x1f) | ((m & 0xf) << 5) | (((y-1980) & 0x7f) << 9))
1763 #define MKDOSTIME(h,m,s) (((s>>1) & 0x1f) | ((m & 0x3f) << 5) | ((h & 0x1f) << 11))
1765 static void test_dos2dt(int line
, WORD d
, WORD m
, WORD y
, WORD h
, WORD mn
,
1766 WORD s
, INT r
, double dt
)
1768 unsigned short dosDate
, dosTime
;
1773 dosDate
= MKDOSDATE(d
, m
, y
);
1774 dosTime
= MKDOSTIME(h
, mn
, s
);
1775 res
= pDosDateTimeToVariantTime(dosDate
, dosTime
, &out
);
1776 ok_(__FILE__
,line
)(r
== res
&& (!r
|| EQ_DOUBLE(out
, dt
)),
1777 "expected %d, %.16g, got %d, %.16g\n", r
, dt
, res
, out
);
1779 #define DOS2DT(d,m,y,h,mn,s,r,dt) test_dos2dt(__LINE__,d,m,y,h,mn,s,r,dt)
1781 static void test_DosDateTimeToVariantTime(void)
1783 CHECKPTR(DosDateTimeToVariantTime
);
1786 DOS2DT(1,1,1980,0,0,0,1,29221.0); /* 1/1/1980 */
1787 DOS2DT(31,12,2099,0,0,0,1,73050.0); /* 31/12/2099 */
1788 /* Dates are limited to the dos date max of 31/12/2099 */
1789 DOS2DT(31,12,2100,0,0,0,0,0.0); /* 31/12/2100 */
1790 /* Days and months of 0 cause date to roll back 1 day or month */
1791 DOS2DT(0,1,1980,0,0,0,1,29220.0); /* 0 Day => 31/12/1979 */
1792 DOS2DT(1,0,1980,0,0,0,1,29190.0); /* 0 Mth => 1/12/1979 */
1793 DOS2DT(0,0,1980,0,0,0,1,29189.0); /* 0 D/M => 30/11/1979 */
1794 /* Days > days in the month cause date to roll forward 1 month */
1795 DOS2DT(29,2,1981,0,0,0,1,29646.0); /* 29/2/1981 -> 3/1/1980 */
1796 DOS2DT(30,2,1981,0,0,0,1,29647.0); /* 30/2/1981 -> 4/1/1980 */
1797 /* Takes leap years into account when rolling forward */
1798 DOS2DT(29,2,1980,0,0,0,1,29280.0); /* 2/29/1980 */
1799 /* Months > 12 cause an error */
1800 DOS2DT(2,13,1980,0,0,0,0,0.0);
1803 DOS2DT(1,1,1980,0,0,29,1,29221.00032407407); /* 1/1/1980 12:00:28 AM */
1804 DOS2DT(1,1,1980,0,0,31,1,29221.00034722222); /* 1/1/1980 12:00:30 AM */
1805 DOS2DT(1,1,1980,0,59,0,1,29221.04097222222); /* 1/1/1980 12:59:00 AM */
1806 DOS2DT(1,1,1980,0,60,0,0,0.0); /* Invalid minutes */
1807 DOS2DT(1,1,1980,0,0,60,0,0.0); /* Invalid seconds */
1808 DOS2DT(1,1,1980,23,0,0,1,29221.95833333333); /* 1/1/1980 11:00:00 PM */
1809 DOS2DT(1,1,1980,24,0,0,0,0.0); /* Invalid hours */
1811 DOS2DT(1,1,1980,0,0,1,1,29221.0);
1812 DOS2DT(2,1,1980,0,0,0,1,29222.0);
1813 DOS2DT(2,1,1980,0,0,0,1,29222.0);
1814 DOS2DT(31,12,1990,0,0,0,1,33238.0);
1815 DOS2DT(31,12,90,0,0,0,1,40543.0);
1816 DOS2DT(30,12,1899,0,0,0,1,46751.0);
1817 DOS2DT(1,1,100,0,0,0,1,43831.0);
1818 DOS2DT(31,12,9999,0,0,0,1,59901.0);
1819 DOS2DT(1,1,10000,0,0,0,1,59902.0);
1820 DOS2DT(1,1,-10000,0,0,0,1,48214.0);
1822 DOS2DT(30,12,1899,0,0,0,1,46751.0);
1823 DOS2DT(30,12,1899,0,0,1,1,46751.0);
1825 DOS2DT(1,1,1980,18,1,16,1,29221.75087962963);
1826 DOS2DT(1,300,1980,18,1,16,1,29556.75087962963);
1827 DOS2DT(300,1,1980,18,1,16,1,29232.75087962963);
1828 DOS2DT(0,1,1980,42,1,16,1,29220.4175462963);
1829 DOS2DT(1,1,1980,17,61,16,0,0.0);
1830 DOS2DT(1,1,1980,18,0,76,1,29221.75013888889);
1831 DOS2DT(1,-300,1980,18,1,16,1,29312.75087962963);
1832 DOS2DT(-300,1,1980,18,1,16,1,29240.75087962963);
1833 DOS2DT(3,1,1980,-30,1,16,1,29223.08421296296);
1834 DOS2DT(1,1,1980,20,-119,16,1,29221.83976851852);
1835 DOS2DT(1,1,1980,18,3,-104,1,29221.75236111111);
1836 DOS2DT(1,12001,-1020,18,1,16,1,55519.75087962963);
1837 DOS2DT(1,-23,1982,18,1,16,1,30195.75087962963);
1838 DOS2DT(-59,3,1980,18,1,16,1,29285.75087962963);
1839 DOS2DT(1,1,0,0,0,0,1,54058.0);
1840 DOS2DT(0,0,1980,0,0,0,1,29189.0);
1841 DOS2DT(0,1,1980,0,0,0,1,29220.0);
1842 DOS2DT(-1,1,1980,18,1,16,1,29251.75087962963);
1843 DOS2DT(1,1,-1,18,1,16,1,53693.75087962963);
1844 DOS2DT(1,-1,1980,18,1,16,0,0);
1847 static void test_dt2dos(int line
, double dt
, INT r
, WORD d
, WORD m
, WORD y
,
1848 WORD h
, WORD mn
, WORD s
)
1850 unsigned short dosDate
, dosTime
, expDosDate
, expDosTime
;
1853 dosTime
= dosDate
= 0;
1854 expDosDate
= MKDOSDATE(d
,m
,y
);
1855 expDosTime
= MKDOSTIME(h
,mn
,s
);
1856 res
= pVariantTimeToDosDateTime(dt
, &dosDate
, &dosTime
);
1857 ok_(__FILE__
,line
)(r
== res
&& (!r
|| (dosTime
== expDosTime
&& dosDate
== expDosDate
)),
1858 "%g: expected %d,%d(%d/%d/%d),%d(%d:%d:%d) got %d,%d(%d/%d/%d),%d(%d:%d:%d)\n",
1859 dt
, r
, expDosDate
, expDosDate
& 0x1f,
1860 (expDosDate
>> 5) & 0xf, 1980 + (expDosDate
>> 9),
1861 expDosTime
, expDosTime
>> 11, (expDosTime
>> 5) & 0x3f,
1862 (expDosTime
& 0x1f),
1863 res
, dosDate
, dosDate
& 0x1f, (dosDate
>> 5) & 0xf,
1864 1980 + (dosDate
>> 9), dosTime
, dosTime
>> 11,
1865 (dosTime
>> 5) & 0x3f, (dosTime
& 0x1f));
1867 #define DT2DOS(dt,r,d,m,y,h,mn,s) test_dt2dos(__LINE__,dt,r,d,m,y,h,mn,s)
1869 static void test_VariantTimeToDosDateTime(void)
1871 CHECKPTR(VariantTimeToDosDateTime
);
1874 DT2DOS(29221.0,1,1,1,1980,0,0,0); /* 1/1/1980 */
1875 DT2DOS(73050.0,1,31,12,2099,0,0,0); /* 31/12/2099 */
1876 DT2DOS(29220.0,0,0,0,0,0,0,0); /* 31/12/1979 - out of range */
1877 DT2DOS(73415.0,0,0,0,0,0,0,0); /* 31/12/2100 - out of range */
1880 DT2DOS(29221.00032407407,1,1,1,1980,0,0,29); /* 1/1/1980 12:00:28 AM */
1881 DT2DOS(29221.00034722222,1,1,1,1980,0,0,31); /* 1/1/1980 12:00:30 AM */
1882 DT2DOS(29221.04097222222,1,1,1,1980,0,59,0); /* 1/1/1980 12:59:00 AM */
1883 DT2DOS(29221.95833333333,1,1,1,1980,23,0,0); /* 1/1/1980 11:00:00 PM */
1886 static HRESULT (WINAPI
*pVarAbs
)(LPVARIANT
,LPVARIANT
);
1888 #define VARABS(vt,val,rvt,rval) \
1889 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
1890 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
1891 test_var_call1( __LINE__, pVarAbs, &v, &exp )
1893 static void test_VarAbs(void)
1895 static WCHAR szNum
[] = {'-','1','.','1','\0' };
1898 VARIANT v
, vDst
, exp
;
1903 /* Test all possible V_VT values.
1905 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
1909 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
1911 HRESULT hExpected
= DISP_E_BADVARTYPE
;
1915 memset(&v
, 0, sizeof(v
));
1916 V_VT(&v
) = vt
| ExtraFlags
[i
];
1917 V_VT(&vDst
) = VT_EMPTY
;
1919 hres
= pVarAbs(&v
,&vDst
);
1920 if (ExtraFlags
[i
] & (VT_ARRAY
|VT_ARRAY
) ||
1921 (!ExtraFlags
[i
] && (vt
== VT_UNKNOWN
|| vt
== VT_BSTR
||
1922 vt
== VT_DISPATCH
|| vt
== VT_ERROR
|| vt
== VT_RECORD
)))
1924 hExpected
= DISP_E_TYPEMISMATCH
;
1926 else if (ExtraFlags
[i
] || vt
>= VT_CLSID
|| vt
== VT_VARIANT
)
1928 hExpected
= DISP_E_BADVARTYPE
;
1930 else if (IsValidVariantClearVT(vt
, ExtraFlags
[i
]))
1933 /* Native always fails on some vartypes that should be valid. don't
1934 * check that Wine does the same; these are bugs in native.
1936 if (vt
== VT_I8
|| vt
== VT_UI8
|| vt
== VT_INT
|| vt
== VT_UINT
||
1937 vt
== VT_I1
|| vt
== VT_UI2
|| vt
== VT_UI4
)
1939 ok(hres
== hExpected
, "VarAbs: expected 0x%X, got 0x%X for vt %d | 0x%X\n",
1940 hExpected
, hres
, vt
, ExtraFlags
[i
]);
1944 /* BOOL->I2, BSTR->R8, all others remain the same */
1945 VARABS(BOOL
,VARIANT_TRUE
,I2
,-VARIANT_TRUE
);
1946 VARABS(BOOL
,VARIANT_FALSE
,I2
,VARIANT_FALSE
);
1947 VARABS(EMPTY
,0,I2
,0);
1948 VARABS(EMPTY
,1,I2
,0);
1949 VARABS(NULL
,0,NULL
,0);
1950 VARABS(NULL
,1,NULL
,0);
1955 VARABS(UI1
,1,UI1
,1);
1960 VARABS(DATE
,1,DATE
,1);
1961 VARABS(DATE
,-1,DATE
,1);
1963 V_CY(&v
).int64
= -10000;
1964 memset(&vDst
,0,sizeof(vDst
));
1965 hres
= pVarAbs(&v
,&vDst
);
1966 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_CY
&& V_CY(&vDst
).int64
== 10000,
1967 "VarAbs(CY): expected 0x0 got 0x%X\n", hres
);
1968 GetLocaleInfoA(LOCALE_USER_DEFAULT
, LOCALE_SDECIMAL
, buff
, sizeof(buff
)/sizeof(char));
1971 trace("Skipping VarAbs(BSTR) as decimal separator is '%s'\n", buff
);
1977 V_BSTR(&v
) = (BSTR
)szNum
;
1978 memset(&vDst
,0,sizeof(vDst
));
1979 hres
= pVarAbs(&v
,&vDst
);
1980 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_R8
&& V_R8(&vDst
) == 1.1,
1981 "VarAbs: expected 0x0,%d,%g, got 0x%X,%d,%g\n", VT_R8
, 1.1, hres
, V_VT(&vDst
), V_R8(&vDst
));
1984 static HRESULT (WINAPI
*pVarNot
)(LPVARIANT
,LPVARIANT
);
1986 #define VARNOT(vt,val,rvt,rval) \
1987 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
1988 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
1989 test_var_call1( __LINE__, pVarNot, &v, &exp )
1991 static void test_VarNot(void)
1993 static const WCHAR szNum0
[] = {'0','\0' };
1994 static const WCHAR szNum1
[] = {'1','\0' };
1995 static const WCHAR szFalse
[] = { '#','F','A','L','S','E','#','\0' };
1996 static const WCHAR szTrue
[] = { '#','T','R','U','E','#','\0' };
1998 VARIANT v
, exp
, vDst
;
1999 DECIMAL
*pdec
= &V_DECIMAL(&v
);
2000 CY
*pcy
= &V_CY(&v
);
2005 /* Test all possible V_VT values */
2006 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
2010 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
2012 HRESULT hExpected
= DISP_E_BADVARTYPE
;
2016 memset(&v
, 0, sizeof(v
));
2017 V_VT(&v
) = vt
| ExtraFlags
[i
];
2018 V_VT(&vDst
) = VT_EMPTY
;
2022 case VT_I1
: case VT_UI1
: case VT_I2
: case VT_UI2
:
2023 case VT_INT
: case VT_UINT
: case VT_I4
: case VT_UI4
:
2024 case VT_R4
: case VT_R8
:
2025 case VT_DECIMAL
: case VT_BOOL
: case VT_NULL
: case VT_EMPTY
:
2026 case VT_DATE
: case VT_CY
:
2029 case VT_I8
: case VT_UI8
:
2034 hExpected
= DISP_E_TYPEMISMATCH
;
2036 case VT_UNKNOWN
: case VT_BSTR
: case VT_DISPATCH
: case VT_ERROR
:
2037 hExpected
= DISP_E_TYPEMISMATCH
;
2040 if (IsValidVariantClearVT(vt
, ExtraFlags
[i
]) && vt
!= VT_CLSID
)
2041 hExpected
= DISP_E_TYPEMISMATCH
;
2045 hres
= pVarNot(&v
,&vDst
);
2046 ok(hres
== hExpected
, "VarNot: expected 0x%X, got 0x%X vt %d|0x%X\n",
2047 hExpected
, hres
, vt
, ExtraFlags
[i
]);
2050 /* Test the values returned by all cases that can succeed */
2051 VARNOT(EMPTY
,0,I2
,-1);
2052 VARNOT(EMPTY
,1,I2
,-1);
2053 VARNOT(NULL
,0,NULL
,0);
2054 VARNOT(NULL
,1,NULL
,0);
2055 VARNOT(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
);
2056 VARNOT(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
);
2064 VARNOT(UI1
,1,UI1
,254);
2065 VARNOT(UI1
,0,UI1
,255);
2066 VARNOT(UI2
,0,I4
,-1);
2067 VARNOT(UI2
,1,I4
,-2);
2068 VARNOT(UI4
,0,I4
,-1);
2069 VARNOT(UI4
,1,I4
,-2);
2070 VARNOT(INT
,0,I4
,-1);
2071 VARNOT(INT
,1,I4
,-2);
2072 VARNOT(UINT
,0,I4
,-1);
2073 VARNOT(UINT
,1,I4
,-2);
2078 VARNOT(UI8
,0,I4
,-1);
2079 VARNOT(UI8
,1,I4
,-2);
2085 VARNOT(DATE
,1,I4
,-2);
2086 VARNOT(DATE
,0,I4
,-1);
2087 VARNOT(BSTR
,(BSTR
)szNum0
,I4
,-1);
2088 ok(V_VT(&v
) == VT_BSTR
&& V_BSTR(&v
) == szNum0
, "VarNot(0): changed input\n");
2089 VARNOT(BSTR
,(BSTR
)szNum1
,I4
,-2);
2090 ok(V_VT(&v
) == VT_BSTR
&& V_BSTR(&v
) == szNum1
, "VarNot(1): changed input\n");
2091 VARNOT(BSTR
, (BSTR
)szTrue
, BOOL
, VARIANT_FALSE
);
2092 VARNOT(BSTR
, (BSTR
)szFalse
, BOOL
, VARIANT_TRUE
);
2094 V_VT(&v
) = VT_DECIMAL
;
2095 S(U(*pdec
)).sign
= DECIMAL_NEG
;
2096 S(U(*pdec
)).scale
= 0;
2098 S1(U1(*pdec
)).Mid32
= 0;
2099 S1(U1(*pdec
)).Lo32
= 1;
2100 VARNOT(DECIMAL
,*pdec
,I4
,0);
2103 VARNOT(CY
,*pcy
,I4
,-2);
2106 VARNOT(CY
,*pcy
,I4
,-1);
2109 VARNOT(CY
,*pcy
,I4
,-1);
2112 static HRESULT (WINAPI
*pVarSub
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
2114 #define VARSUB(vt1,val1,vt2,val2,rvt,rval) \
2115 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
2116 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
2117 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
2118 test_var_call2( __LINE__, pVarSub, &left, &right, &exp )
2120 static void test_VarSub(void)
2122 VARIANT left
, right
, exp
, result
, cy
, dec
;
2125 HRESULT hres
, expectedhres
;
2130 lbstr
= SysAllocString(sz12
);
2131 rbstr
= SysAllocString(sz12
);
2134 VariantInit(&right
);
2135 VariantInit(&result
);
2137 /* Test all possible flag/vt combinations & the resulting vt type */
2138 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
2141 VARTYPE leftvt
, rightvt
, resvt
;
2143 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
2148 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
2152 expectedhres
= S_OK
;
2154 memset(&left
, 0, sizeof(left
));
2155 memset(&right
, 0, sizeof(right
));
2156 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
2157 if (leftvt
== VT_BSTR
)
2158 V_BSTR(&left
) = lbstr
;
2159 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
2160 if (rightvt
== VT_BSTR
)
2161 V_BSTR(&right
) = rbstr
;
2162 V_VT(&result
) = VT_EMPTY
;
2164 /* All extra flags produce errors */
2165 if (ExtraFlags
[i
] == (VT_VECTOR
|VT_BYREF
|VT_RESERVED
) ||
2166 ExtraFlags
[i
] == (VT_VECTOR
|VT_RESERVED
) ||
2167 ExtraFlags
[i
] == (VT_VECTOR
|VT_BYREF
) ||
2168 ExtraFlags
[i
] == (VT_BYREF
|VT_RESERVED
) ||
2169 ExtraFlags
[i
] == VT_VECTOR
||
2170 ExtraFlags
[i
] == VT_BYREF
||
2171 ExtraFlags
[i
] == VT_RESERVED
)
2173 expectedhres
= DISP_E_BADVARTYPE
;
2176 else if (ExtraFlags
[i
] >= VT_ARRAY
)
2178 expectedhres
= DISP_E_TYPEMISMATCH
;
2181 /* Native VarSub cannot handle: VT_I1, VT_UI2, VT_UI4,
2182 VT_INT, VT_UINT and VT_UI8. Tested with WinXP */
2183 else if (!IsValidVariantClearVT(leftvt
, ExtraFlags
[i
]) ||
2184 !IsValidVariantClearVT(rightvt
, ExtraFlags
[i
]) ||
2185 leftvt
== VT_CLSID
|| rightvt
== VT_CLSID
||
2186 leftvt
== VT_VARIANT
|| rightvt
== VT_VARIANT
||
2187 leftvt
== VT_I1
|| rightvt
== VT_I1
||
2188 leftvt
== VT_UI2
|| rightvt
== VT_UI2
||
2189 leftvt
== VT_UI4
|| rightvt
== VT_UI4
||
2190 leftvt
== VT_UI8
|| rightvt
== VT_UI8
||
2191 leftvt
== VT_INT
|| rightvt
== VT_INT
||
2192 leftvt
== VT_UINT
|| rightvt
== VT_UINT
||
2193 leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
||
2194 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
)
2196 if (leftvt
== VT_RECORD
&& rightvt
== VT_I8
)
2199 expectedhres
= DISP_E_TYPEMISMATCH
;
2201 expectedhres
= DISP_E_BADVARTYPE
;
2203 else if (leftvt
< VT_UI1
&& rightvt
== VT_RECORD
)
2204 expectedhres
= DISP_E_TYPEMISMATCH
;
2205 else if (leftvt
>= VT_UI1
&& rightvt
== VT_RECORD
)
2206 expectedhres
= DISP_E_TYPEMISMATCH
;
2207 else if (leftvt
== VT_RECORD
&& rightvt
<= VT_UI1
)
2208 expectedhres
= DISP_E_TYPEMISMATCH
;
2209 else if (leftvt
== VT_RECORD
&& rightvt
> VT_UI1
)
2210 expectedhres
= DISP_E_BADVARTYPE
;
2212 expectedhres
= DISP_E_BADVARTYPE
;
2215 else if ((leftvt
== VT_NULL
&& rightvt
== VT_DISPATCH
) ||
2216 (leftvt
== VT_DISPATCH
&& rightvt
== VT_NULL
))
2218 else if (leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
||
2219 leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
)
2222 expectedhres
= DISP_E_TYPEMISMATCH
;
2224 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
2226 else if ((leftvt
== VT_EMPTY
&& rightvt
== VT_BSTR
) ||
2227 (leftvt
== VT_DATE
&& rightvt
== VT_DATE
) ||
2228 (leftvt
== VT_BSTR
&& rightvt
== VT_EMPTY
) ||
2229 (leftvt
== VT_BSTR
&& rightvt
== VT_BSTR
))
2231 else if (leftvt
== VT_DECIMAL
|| rightvt
== VT_DECIMAL
)
2233 else if (leftvt
== VT_DATE
|| rightvt
== VT_DATE
)
2235 else if (leftvt
== VT_CY
|| rightvt
== VT_CY
)
2237 else if (leftvt
== VT_R8
|| rightvt
== VT_R8
)
2239 else if (leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
) {
2241 } else if (leftvt
== VT_R4
|| rightvt
== VT_R4
) {
2242 if (leftvt
== VT_I4
|| rightvt
== VT_I4
||
2243 leftvt
== VT_I8
|| rightvt
== VT_I8
)
2248 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
2250 else if (leftvt
== VT_I4
|| rightvt
== VT_I4
)
2252 else if (leftvt
== VT_I2
|| rightvt
== VT_I2
||
2253 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
||
2254 (leftvt
== VT_EMPTY
&& rightvt
== VT_EMPTY
))
2256 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
2261 expectedhres
= DISP_E_TYPEMISMATCH
;
2264 hres
= pVarSub(&left
, &right
, &result
);
2266 ok(hres
== expectedhres
&& V_VT(&result
) == resvt
,
2267 "VarSub: %d|0x%X, %d|0x%X: Expected failure 0x%X, "
2268 "got 0x%X, expected vt %d got vt %d\n",
2269 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
],
2270 expectedhres
, hres
, resvt
, V_VT(&result
));
2275 /* Test returned values */
2276 VARSUB(I4
,4,I4
,2,I4
,2);
2277 VARSUB(I2
,4,I2
,2,I2
,2);
2278 VARSUB(I2
,-13,I4
,5,I4
,-18);
2279 VARSUB(I4
,-13,I4
,5,I4
,-18);
2280 VARSUB(I2
,7,R4
,0.5f
,R4
,6.5f
);
2281 VARSUB(R4
,0.5f
,I4
,5,R8
,-4.5);
2282 VARSUB(R8
,7.1,BOOL
,0,R8
,7.1);
2283 VARSUB(BSTR
,lbstr
,I2
,4,R8
,8);
2284 VARSUB(BSTR
,lbstr
,BOOL
,1,R8
,11);
2285 VARSUB(BSTR
,lbstr
,R4
,0.1f
,R8
,11.9);
2286 VARSUB(R4
,0.2f
,BSTR
,rbstr
,R8
,-11.8);
2287 VARSUB(DATE
,2.25,I4
,7,DATE
,-4.75);
2288 VARSUB(DATE
,1.25,R4
,-1.7f
,DATE
,2.95);
2290 VARSUB(UI1
, UI1_MAX
, UI1
, UI1_MAX
, UI1
, 0);
2291 VARSUB(I2
, I2_MAX
, I2
, I2_MAX
, I2
, 0);
2292 VARSUB(I2
, I2_MIN
, I2
, I2_MIN
, I2
, 0);
2293 VARSUB(I4
, I4_MAX
, I4
, I4_MAX
, I4
, 0);
2294 VARSUB(I4
, I4_MIN
, I4
, I4_MIN
, I4
, 0);
2295 VARSUB(R4
, R4_MAX
, R4
, R4_MAX
, R4
, 0.0f
);
2296 VARSUB(R4
, R4_MAX
, R4
, R4_MIN
, R4
, R4_MAX
- R4_MIN
);
2297 VARSUB(R4
, R4_MIN
, R4
, R4_MIN
, R4
, 0.0f
);
2298 VARSUB(R8
, R8_MAX
, R8
, R8_MIN
, R8
, R8_MAX
- R8_MIN
);
2299 VARSUB(R8
, R8_MIN
, R8
, R8_MIN
, R8
, 0.0);
2301 /* Manually test BSTR + BSTR */
2302 V_VT(&left
) = VT_BSTR
;
2303 V_BSTR(&left
) = lbstr
;
2304 V_VT(&right
) = VT_BSTR
;
2305 V_BSTR(&right
) = rbstr
;
2306 hres
= pVarSub(&left
, &right
, &result
);
2307 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
2308 "VarSub: expected coerced type VT_R8, got %s!\n", vtstr(V_VT(&result
)));
2309 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 0),
2310 "VarSub: BSTR + BSTR, expected %f got %f\n", 0.0, V_R8(&result
));
2312 /* Manually test some VT_CY and VT_DECIMAL variants */
2314 hres
= VarCyFromI4(4711, &V_CY(&cy
));
2315 ok(hres
== S_OK
, "VarCyFromI4 failed!\n");
2316 V_VT(&dec
) = VT_DECIMAL
;
2317 hres
= VarDecFromR8(-4.2, &V_DECIMAL(&dec
));
2318 ok(hres
== S_OK
, "VarDecFromR4 failed!\n");
2319 memset(&left
, 0, sizeof(left
));
2320 memset(&right
, 0, sizeof(right
));
2321 V_VT(&left
) = VT_I4
;
2323 V_VT(&right
) = VT_UI1
;
2326 hres
= pVarSub(&cy
, &right
, &result
);
2327 ok(hres
== S_OK
&& V_VT(&result
) == VT_CY
,
2328 "VarSub: expected coerced type VT_CY, got %s!\n", vtstr(V_VT(&result
)));
2329 hres
= VarR8FromCy(V_CY(&result
), &r
);
2330 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 4702),
2331 "VarSub: CY value %f, expected %f\n", r
, (double)4720);
2333 hres
= pVarSub(&left
, &dec
, &result
);
2334 ok(hres
== S_OK
&& V_VT(&result
) == VT_DECIMAL
,
2335 "VarSub: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result
)));
2336 hres
= VarR8FromDec(&V_DECIMAL(&result
), &r
);
2337 ok(hres
== S_OK
&& EQ_DOUBLE(r
, -6.8),
2338 "VarSub: DECIMAL value %f, expected %f\n", r
, (double)-15.2);
2340 SysFreeString(lbstr
);
2341 SysFreeString(rbstr
);
2344 static HRESULT (WINAPI
*pVarMod
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
2346 static void test_Mod( int line
, VARIANT
*left
, VARIANT
*right
, VARIANT
*expected
, HRESULT expres
)
2351 memset( &result
, 0, sizeof(result
) );
2352 hres
= pVarMod( left
, right
, &result
);
2353 ok_(__FILE__
,line
)( hres
== expres
, "wrong result %x/%x\n", hres
, expres
);
2355 ok_(__FILE__
,line
)( is_expected_variant( &result
, expected
),
2356 "got %s expected %s\n", variantstr(&result
), variantstr(expected
) );
2359 #define VARMOD(vt1,vt2,val1,val2,rvt,rval) \
2360 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
2361 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
2362 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
2363 test_var_call2( __LINE__, pVarMod, &left, &right, &exp )
2365 #define VARMOD2(vt1,vt2,val1,val2,rvt,rval,hexpected) \
2366 V_VT(&left) = VT_##vt1; V_I4(&left) = val1; \
2367 V_VT(&right) = VT_##vt2; V_I4(&right) = val2; \
2368 V_VT(&exp) = VT_##rvt; V_I4(&exp) = rval; \
2369 test_Mod( __LINE__, &left, &right, &exp, hexpected )
2371 static void test_VarMod(void)
2373 VARIANT v1
, v2
, vDst
, left
, right
, exp
;
2375 HRESULT hexpected
= 0;
2376 static const WCHAR szNum0
[] = {'1','2','5','\0'};
2377 static const WCHAR szNum1
[] = {'1','0','\0'};
2379 BOOL lFound
, rFound
;
2381 BSTR strNum0
, strNum1
;
2385 VARMOD(I1
,BOOL
,100,10,I4
,0);
2386 VARMOD(I1
,I1
,100,10,I4
,0);
2387 VARMOD(I1
,UI1
,100,10,I4
,0);
2388 VARMOD(I1
,I2
,100,10,I4
,0);
2389 VARMOD(I1
,UI2
,100,10,I4
,0);
2390 VARMOD(I1
,I4
,100,10,I4
,0);
2391 VARMOD(I1
,UI4
,100,10,I4
,0);
2392 VARMOD(I1
,R4
,100,10,I4
,0);
2393 VARMOD(I1
,R8
,100,10,I4
,0);
2395 VARMOD(UI1
,BOOL
,100,10,I2
,0);
2396 VARMOD(UI1
,I1
,100,10,I4
,0);
2397 VARMOD(UI1
,UI1
,100,10,UI1
,0);
2398 VARMOD(UI1
,I2
,100,10,I2
,0);
2399 VARMOD(UI1
,UI2
,100,10,I4
,0);
2400 VARMOD(UI1
,I4
,100,10,I4
,0);
2401 VARMOD(UI1
,UI4
,100,10,I4
,0);
2402 VARMOD(UI1
,R4
,100,10,I4
,0);
2403 VARMOD(UI1
,R8
,100,10,I4
,0);
2405 VARMOD(I2
,BOOL
,100,10,I2
,0);
2406 VARMOD(I2
,I1
,100,10,I4
,0);
2407 VARMOD(I2
,UI1
,100,10,I2
,0);
2408 VARMOD(I2
,I2
,100,10,I2
,0);
2409 VARMOD(I2
,UI2
,100,10,I4
,0);
2410 VARMOD(I2
,I4
,100,10,I4
,0);
2411 VARMOD(I2
,UI4
,100,10,I4
,0);
2412 VARMOD(I2
,R4
,100,10,I4
,0);
2413 VARMOD(I2
,R8
,100,10,I4
,0);
2415 VARMOD(I4
,BOOL
,100,10,I4
,0);
2416 VARMOD(I4
,I1
,100,10,I4
,0);
2417 VARMOD(I4
,UI1
,100,10,I4
,0);
2418 VARMOD(I4
,I2
,100,10,I4
,0);
2419 VARMOD(I4
,UI2
,100,10,I4
,0);
2420 VARMOD(I4
,I4
,100,10,I4
,0);
2421 VARMOD(I4
,UI4
,100,10,I4
,0);
2422 VARMOD(I4
,R4
,100,10,I4
,0);
2423 VARMOD(I4
,R8
,100,10,I4
,0);
2424 VARMOD(UI4
,BOOL
,100,10,I4
,0);
2425 VARMOD(UI4
,I1
,100,10,I4
,0);
2426 VARMOD(UI4
,UI1
,100,10,I4
,0);
2427 VARMOD(UI4
,I2
,100,10,I4
,0);
2428 VARMOD(UI4
,UI2
,100,10,I4
,0);
2429 VARMOD(UI4
,I4
,100,10,I4
,0);
2430 VARMOD(UI4
,UI4
,100,10,I4
,0);
2431 VARMOD(UI4
,R4
,100,10,I4
,0);
2432 VARMOD(UI4
,R8
,100,10,I4
,0);
2433 VARMOD(R4
,BOOL
,100,10,I4
,0);
2434 VARMOD(R4
,I1
,100,10,I4
,0);
2435 VARMOD(R4
,UI1
,100,10,I4
,0);
2436 VARMOD(R4
,I2
,100,10,I4
,0);
2437 VARMOD(R4
,UI2
,100,10,I4
,0);
2438 VARMOD(R4
,I4
,100,10,I4
,0);
2439 VARMOD(R4
,UI4
,100,10,I4
,0);
2440 VARMOD(R4
,R4
,100,10,I4
,0);
2441 VARMOD(R4
,R8
,100,10,I4
,0);
2442 VARMOD(R8
,BOOL
,100,10,I4
,0);
2443 VARMOD(R8
,I1
,100,10,I4
,0);
2444 VARMOD(R8
,UI1
,100,10,I4
,0);
2445 VARMOD(R8
,I2
,100,10,I4
,0);
2446 VARMOD(R8
,UI2
,100,10,I4
,0);
2447 VARMOD(R8
,I4
,100,10,I4
,0);
2448 VARMOD(R8
,UI4
,100,10,I4
,0);
2449 VARMOD(R8
,R4
,100,10,I4
,0);
2450 VARMOD(R8
,R8
,100,10,I4
,0);
2452 VARMOD(INT
,INT
,100,10,I4
,0);
2453 VARMOD(INT
,UINT
,100,10,I4
,0);
2455 VARMOD(BOOL
,BOOL
,100,10,I2
,0);
2456 VARMOD(BOOL
,I1
,100,10,I4
,0);
2457 VARMOD(BOOL
,UI1
,100,10,I2
,0);
2458 VARMOD(BOOL
,I2
,100,10,I2
,0);
2459 VARMOD(BOOL
,UI2
,100,10,I4
,0);
2460 VARMOD(BOOL
,I4
,100,10,I4
,0);
2461 VARMOD(BOOL
,UI4
,100,10,I4
,0);
2462 VARMOD(BOOL
,R4
,100,10,I4
,0);
2463 VARMOD(BOOL
,R8
,100,10,I4
,0);
2464 VARMOD(BOOL
,DATE
,100,10,I4
,0);
2466 VARMOD(DATE
,BOOL
,100,10,I4
,0);
2467 VARMOD(DATE
,I1
,100,10,I4
,0);
2468 VARMOD(DATE
,UI1
,100,10,I4
,0);
2469 VARMOD(DATE
,I2
,100,10,I4
,0);
2470 VARMOD(DATE
,UI2
,100,10,I4
,0);
2471 VARMOD(DATE
,I4
,100,10,I4
,0);
2472 VARMOD(DATE
,UI4
,100,10,I4
,0);
2473 VARMOD(DATE
,R4
,100,10,I4
,0);
2474 VARMOD(DATE
,R8
,100,10,I4
,0);
2475 VARMOD(DATE
,DATE
,100,10,I4
,0);
2477 strNum0
= SysAllocString(szNum0
);
2478 strNum1
= SysAllocString(szNum1
);
2479 VARMOD(BSTR
,BSTR
,strNum0
,strNum1
,I4
,5);
2480 VARMOD(BSTR
,I1
,strNum0
,10,I4
,5);
2481 VARMOD(BSTR
,I2
,strNum0
,10,I4
,5);
2482 VARMOD(BSTR
,I4
,strNum0
,10,I4
,5);
2483 VARMOD(BSTR
,R4
,strNum0
,10,I4
,5);
2484 VARMOD(BSTR
,R8
,strNum0
,10,I4
,5);
2485 VARMOD(I4
,BSTR
,125,strNum1
,I4
,5);
2489 VARMOD(BOOL
,I8
,100,10,I8
,0);
2490 VARMOD(I1
,I8
,100,10,I8
,0);
2491 VARMOD(UI1
,I8
,100,10,I8
,0);
2492 VARMOD(I2
,I8
,100,10,I8
,0);
2493 VARMOD(I4
,I8
,100,10,I8
,0);
2494 VARMOD(UI4
,I8
,100,10,I8
,0);
2495 VARMOD(R4
,I8
,100,10,I8
,0);
2496 VARMOD(R8
,I8
,100,10,I8
,0);
2497 VARMOD(DATE
,I8
,100,10,I8
,0);
2499 VARMOD(I8
,BOOL
,100,10,I8
,0);
2500 VARMOD(I8
,I1
,100,10,I8
,0);
2501 VARMOD(I8
,UI1
,100,10,I8
,0);
2502 VARMOD(I8
,I2
,100,10,I8
,0);
2503 VARMOD(I8
,UI2
,100,10,I8
,0);
2504 VARMOD(I8
,I4
,100,10,I8
,0);
2505 VARMOD(I8
,UI4
,100,10,I8
,0);
2506 VARMOD(I8
,R4
,100,10,I8
,0);
2507 VARMOD(I8
,R8
,100,10,I8
,0);
2508 VARMOD(I8
,I8
,100,10,I8
,0);
2510 VARMOD(BSTR
,I8
,strNum0
,10,I8
,5);
2513 /* test all combinations of types */
2514 for(l
= 0; l
< VT_BSTR_BLOB
; l
++)
2518 for(r
= 0; r
< VT_BSTR_BLOB
; r
++)
2522 if(l
== VT_BSTR
) continue;
2523 if(l
== VT_DISPATCH
) continue;
2524 if(r
== VT_BSTR
) continue;
2525 if(r
== VT_DISPATCH
) continue;
2559 hexpected
= DISP_E_BADVARTYPE
;
2596 if(((l
== VT_I8
) && (r
== VT_INT
)) || ((l
== VT_INT
) && (r
== VT_I8
)))
2598 hexpected
= DISP_E_TYPEMISMATCH
;
2599 } else if((l
== VT_EMPTY
) && (r
== VT_NULL
))
2602 } else if((l
== VT_NULL
) && (r
== VT_EMPTY
))
2605 } else if((l
== VT_EMPTY
) && (r
== VT_CY
))
2608 } else if((l
== VT_EMPTY
) && (r
== VT_RECORD
))
2610 hexpected
= DISP_E_TYPEMISMATCH
;
2611 } else if((r
== VT_EMPTY
) && lFound
&& lValid
)
2613 hexpected
= DISP_E_DIVBYZERO
;
2614 } else if((l
== VT_ERROR
) || ((r
== VT_ERROR
) && lFound
&& lValid
))
2616 hexpected
= DISP_E_TYPEMISMATCH
;
2617 } else if((l
== VT_NULL
) && (r
== VT_NULL
))
2620 } else if((l
== VT_VARIANT
) || ((r
== VT_VARIANT
) && lFound
&& lValid
))
2622 hexpected
= DISP_E_TYPEMISMATCH
;
2623 } else if((l
== VT_NULL
) && (r
== VT_RECORD
))
2625 hexpected
= DISP_E_TYPEMISMATCH
;
2626 } else if((l
== VT_I8
) && (r
== VT_DECIMAL
))
2629 } else if((l
== VT_DECIMAL
) && (r
== VT_I8
))
2632 } else if((l
== VT_UNKNOWN
) || ((r
== VT_UNKNOWN
) && lFound
&& lValid
))
2634 hexpected
= DISP_E_TYPEMISMATCH
;
2635 } else if((l
== VT_NULL
) && rFound
)
2638 } else if(l
== VT_RECORD
)
2640 hexpected
= DISP_E_TYPEMISMATCH
;
2641 } else if((r
== VT_RECORD
) && lValid
&& lFound
)
2643 hexpected
= DISP_E_TYPEMISMATCH
;
2644 } else if((l
== VT_EMPTY
) && (r
== VT_EMPTY
))
2646 hexpected
= DISP_E_DIVBYZERO
;
2647 } else if((l
== VT_CY
) && !rFound
)
2649 hexpected
= DISP_E_BADVARTYPE
;
2650 } else if(lFound
&& !rFound
)
2652 hexpected
= DISP_E_BADVARTYPE
;
2653 } else if(!lFound
&& rFound
)
2655 hexpected
= DISP_E_BADVARTYPE
;
2656 } else if((r
== VT_NULL
) && lFound
&& lValid
)
2659 } else if((l
== VT_NULL
) || (r
== VT_NULL
))
2661 hexpected
= DISP_E_BADVARTYPE
;
2662 } else if((l
== VT_VARIANT
) || (r
== VT_VARIANT
))
2664 hexpected
= DISP_E_BADVARTYPE
;
2665 } else if(lFound
&& !rFound
)
2667 hexpected
= DISP_E_BADVARTYPE
;
2668 } else if(!lFound
&& !rFound
)
2670 hexpected
= DISP_E_BADVARTYPE
;
2677 V_CY(&v1
).int64
= 1000000;
2682 else if(l
== VT_UI8
)
2686 else if(l
== VT_DATE
)
2688 else if (l
== VT_DECIMAL
)
2690 V_DECIMAL(&v1
).Hi32
= 0;
2691 U1(V_DECIMAL(&v1
)).Lo64
= 100;
2692 U(V_DECIMAL(&v1
)).signscale
= 0;
2698 V_CY(&v2
).int64
= 10000;
2703 else if(r
== VT_UI8
)
2707 else if(r
== VT_DATE
)
2709 else if (r
== VT_DECIMAL
)
2711 V_DECIMAL(&v2
).Hi32
= 0;
2712 U1(V_DECIMAL(&v2
)).Lo64
= 100;
2713 U(V_DECIMAL(&v2
)).signscale
= 0;
2718 if ((l
!= VT_I8
&& l
!= VT_UI8
&& r
!= VT_I8
&& r
!= VT_UI8
) || has_i8
)
2720 hres
= pVarMod(&v1
,&v2
,&vDst
);
2721 ok(hres
== hexpected
,
2722 "VarMod: expected 0x%x, got 0x%X for l type of %d, r type of %d,\n", hexpected
, hres
, l
, r
);
2728 /****************************/
2729 /* test some bad parameters */
2730 VARMOD(I4
,I4
,-1,-1,I4
,0);
2732 /* test modulus with zero */
2733 VARMOD2(I4
,I4
,100,0,EMPTY
,0,DISP_E_DIVBYZERO
);
2735 VARMOD(I4
,I4
,0,10,I4
,0); /* test 0 mod 10 */
2737 /* right parameter is type empty */
2738 VARMOD2(I4
,EMPTY
,100,10,EMPTY
,0,DISP_E_DIVBYZERO
);
2740 /* left parameter is type empty */
2741 VARMOD2(EMPTY
,I4
,100,10,I4
,0,S_OK
);
2743 /* mod with a null left value */
2744 VARMOD2(NULL
,I4
,125,10,NULL
,0,S_OK
);
2746 /* mod with a null right value */
2747 VARMOD2(I4
,NULL
,100,10,NULL
,0,S_OK
);
2749 /* void left value */
2750 VARMOD2(VOID
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2752 /* void right value */
2753 VARMOD2(I4
,VOID
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2755 /* null left value, void right value */
2756 VARMOD2(NULL
,VOID
,100,10,EMPTY
, 0, DISP_E_BADVARTYPE
);
2758 /* void left value, null right value */
2759 VARMOD2(VOID
,NULL
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2761 /* some currencies */
2764 V_CY(&v1
).int64
= 100000;
2765 V_CY(&v2
).int64
= 100000;
2766 hres
= pVarMod(&v1
,&v2
,&vDst
);
2767 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I4
&& V_I4(&vDst
) == 0,
2768 "VarMod: expected 0x%x,%d,%d, got 0x%X,%d,%d\n", S_OK
, VT_I4
, 0, hres
, V_VT(&vDst
), V_I4(&vDst
));
2773 V_CY(&v2
).int64
= 100000;
2774 hres
= pVarMod(&v1
,&v2
,&vDst
);
2775 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I4
&& V_I4(&vDst
) == 0,
2776 "VarMod: expected 0x%x,%d,%d, got 0x%X,%d,%d\n", S_OK
, VT_I4
, 0, hres
, V_VT(&vDst
), V_I4(&vDst
));
2779 V_VT(&v1
) = VT_DECIMAL
;
2780 V_VT(&v2
) = VT_DECIMAL
;
2781 VarDecFromI4(100, &V_DECIMAL(&v1
));
2782 VarDecFromI4(10, &V_DECIMAL(&v2
));
2783 hres
= pVarMod(&v1
,&v2
,&vDst
);
2784 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I4
&& V_I4(&vDst
) == 0,
2785 "VarMod: expected 0x%x,%d,%d, got 0x%X,%d,%d\n", S_OK
, VT_I4
, 0, hres
, V_VT(&vDst
), V_I4(&vDst
));
2788 V_VT(&v2
) = VT_DECIMAL
;
2790 VarDecFromI4(10, &V_DECIMAL(&v2
));
2791 hres
= pVarMod(&v1
,&v2
,&vDst
);
2792 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I4
&& V_I4(&vDst
) == 0,
2793 "VarMod: expected 0x%x,%d,%d, got 0x%X,%d,%d\n", S_OK
, VT_I4
, 0, hres
, V_VT(&vDst
), V_I4(&vDst
));
2795 VARMOD2(UINT
,I4
,100,10,I4
,0,S_OK
);
2797 /* test that an error results in the type of the result changing but not its value */
2798 V_VT(&v1
) = VT_UNKNOWN
;
2799 V_VT(&v2
) = VT_EMPTY
;
2801 V_CY(&v2
).int64
= 100000;
2802 V_VT(&vDst
) = VT_I4
;
2804 hres
= pVarMod(&v1
,&v2
,&vDst
);
2805 ok(hres
== DISP_E_TYPEMISMATCH
&& V_VT(&vDst
) == VT_EMPTY
&& V_I4(&vDst
) == 1231,
2806 "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
));
2809 /* test some invalid types */
2810 /*TODO: not testing VT_DISPATCH */
2813 VARMOD2(I8
,INT
,100,10,EMPTY
,0,DISP_E_TYPEMISMATCH
);
2815 VARMOD2(ERROR
,I4
,100,10,EMPTY
,0,DISP_E_TYPEMISMATCH
);
2816 VARMOD2(VARIANT
,I4
,100,10,EMPTY
,0,DISP_E_TYPEMISMATCH
);
2817 VARMOD2(UNKNOWN
,I4
,100,10,EMPTY
,0,DISP_E_TYPEMISMATCH
);
2818 VARMOD2(VOID
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2819 VARMOD2(HRESULT
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2820 VARMOD2(PTR
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2821 VARMOD2(SAFEARRAY
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2822 VARMOD2(CARRAY
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2823 VARMOD2(USERDEFINED
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2824 VARMOD2(LPSTR
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2825 VARMOD2(LPWSTR
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2826 VARMOD2(RECORD
,I4
,100,10,EMPTY
,0,DISP_E_TYPEMISMATCH
);
2827 VARMOD2(FILETIME
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2828 VARMOD2(BLOB
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2829 VARMOD2(STREAM
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2830 VARMOD2(STORAGE
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2831 VARMOD2(STREAMED_OBJECT
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2832 VARMOD2(STORED_OBJECT
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2833 VARMOD2(BLOB_OBJECT
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2834 VARMOD2(CF
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2835 VARMOD2(CLSID
,CLSID
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2836 VARMOD2(VECTOR
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2837 VARMOD2(ARRAY
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2838 VARMOD2(BYREF
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2840 /* test some more invalid types */
2845 hres
= pVarMod(&v1
,&v2
,&vDst
);
2846 ok(hres
== DISP_E_BADVARTYPE
&& V_VT(&vDst
) == VT_EMPTY
,
2847 "VarMod: expected 0x%x,%d, got 0x%X,%d\n", DISP_E_BADVARTYPE
, VT_EMPTY
, hres
, V_VT(&vDst
));
2849 SysFreeString(strNum0
);
2850 SysFreeString(strNum1
);
2853 static HRESULT (WINAPI
*pVarFix
)(LPVARIANT
,LPVARIANT
);
2855 #define VARFIX(vt,val,rvt,rval) \
2856 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
2857 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
2858 test_var_call1( __LINE__, pVarFix, &v, &exp )
2860 static void test_VarFix(void)
2862 static const WCHAR szNumMinus1
[] = {'-','1','\0' };
2864 VARIANT v
, exp
, vDst
;
2865 DECIMAL
*pdec
= &V_DECIMAL(&v
);
2866 CY
*pcy
= &V_CY(&v
);
2871 /* Test all possible V_VT values */
2872 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
2876 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
2882 memset(&v
, 0, sizeof(v
));
2883 V_VT(&v
) = vt
| ExtraFlags
[i
];
2884 V_VT(&vDst
) = VT_EMPTY
;
2888 case VT_UI1
: case VT_I2
: case VT_I4
: case VT_R4
: case VT_R8
:
2889 case VT_DECIMAL
: case VT_BOOL
: case VT_NULL
: case VT_EMPTY
:
2890 case VT_DATE
: case VT_CY
:
2899 hres
= pVarFix(&v
,&vDst
);
2901 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
2902 "VarFix: expected failure, got 0x%X vt %d|0x%X\n",
2903 hres
, vt
, ExtraFlags
[i
]);
2905 ok(hres
== S_OK
, "VarFix: expected S_OK, got 0x%X vt %d|0x%X\n",
2906 hres
, vt
, ExtraFlags
[i
]);
2910 VARFIX(BOOL
,VARIANT_TRUE
,I2
,VARIANT_TRUE
);
2911 VARFIX(BOOL
,VARIANT_FALSE
,I2
,0);
2912 VARFIX(BOOL
,1,I2
,1);
2913 VARFIX(UI1
,1,UI1
,1);
2914 VARFIX(I2
,-1,I2
,-1);
2915 VARFIX(I4
,-1,I4
,-1);
2918 VARFIX(I8
,-1,I8
,-1);
2920 VARFIX(R4
,1.4f
,R4
,1);
2921 VARFIX(R4
,1.5f
,R4
,1);
2922 VARFIX(R4
,1.6f
,R4
,1);
2923 VARFIX(R4
,-1.4f
,R4
,-1);
2924 VARFIX(R4
,-1.5f
,R4
,-1);
2925 VARFIX(R4
,-1.6f
,R4
,-1);
2926 /* DATE & R8 round as for R4 */
2927 VARFIX(DATE
,-1,DATE
,-1);
2928 VARFIX(R8
,-1,R8
,-1);
2929 VARFIX(BSTR
,(BSTR
)szNumMinus1
,R8
,-1);
2931 V_VT(&v
) = VT_EMPTY
;
2932 hres
= pVarFix(&v
,&vDst
);
2933 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I2
&& V_I2(&vDst
) == 0,
2934 "VarFix: expected 0x0,%d,0 got 0x%X,%d,%d\n", VT_EMPTY
,
2935 hres
, V_VT(&vDst
), V_I2(&vDst
));
2938 hres
= pVarFix(&v
,&vDst
);
2939 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_NULL
,
2940 "VarFix: expected 0x0,%d got 0x%X,%d\n", VT_NULL
, hres
, V_VT(&vDst
));
2942 V_VT(&v
) = VT_DECIMAL
;
2943 S(U(*pdec
)).sign
= DECIMAL_NEG
;
2944 S(U(*pdec
)).scale
= 0;
2946 S1(U1(*pdec
)).Mid32
= 0;
2947 S1(U1(*pdec
)).Lo32
= 1;
2948 hres
= pVarFix(&v
,&vDst
);
2949 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_DECIMAL
&& !memcmp(&V_DECIMAL(&v
), &V_DECIMAL(&vDst
), sizeof(DECIMAL
)),
2950 "VarFix: expected 0x0,%d,identical, got 0x%X,%d\n", VT_DECIMAL
,
2953 /* FIXME: Test some fractional decimals when VarDecFix is implemented */
2956 pcy
->int64
= -10000;
2957 hres
= pVarFix(&v
,&vDst
);
2958 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_CY
&& V_CY(&vDst
).int64
== -10000,
2959 "VarFix: VT_CY wrong, hres=0x%X\n", hres
);
2962 pcy
->int64
= -16000;
2963 hres
= pVarFix(&v
,&vDst
);
2964 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_CY
&& V_CY(&vDst
).int64
== -10000,
2965 "VarFix: VT_CY wrong, hres=0x%X\n", hres
);
2968 static HRESULT (WINAPI
*pVarInt
)(LPVARIANT
,LPVARIANT
);
2970 #define VARINT(vt,val,rvt,rval) \
2971 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
2972 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
2973 test_var_call1( __LINE__, pVarInt, &v, &exp )
2975 static void test_VarInt(void)
2977 static const WCHAR szNumMinus1
[] = {'-','1','\0' };
2979 VARIANT v
, exp
, vDst
;
2980 DECIMAL
*pdec
= &V_DECIMAL(&v
);
2981 CY
*pcy
= &V_CY(&v
);
2986 /* Test all possible V_VT values */
2987 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
2991 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
2997 memset(&v
, 0, sizeof(v
));
2998 V_VT(&v
) = vt
| ExtraFlags
[i
];
2999 V_VT(&vDst
) = VT_EMPTY
;
3003 case VT_UI1
: case VT_I2
: case VT_I4
: case VT_R4
: case VT_R8
:
3004 case VT_DECIMAL
: case VT_BOOL
: case VT_NULL
: case VT_EMPTY
:
3005 case VT_DATE
: case VT_CY
:
3014 hres
= pVarInt(&v
,&vDst
);
3016 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
3017 "VarInt: expected failure, got 0x%X vt %d|0x%X\n",
3018 hres
, vt
, ExtraFlags
[i
]);
3020 ok(hres
== S_OK
, "VarInt: expected S_OK, got 0x%X vt %d|0x%X\n",
3021 hres
, vt
, ExtraFlags
[i
]);
3025 VARINT(BOOL
,VARIANT_TRUE
,I2
,VARIANT_TRUE
);
3026 VARINT(BOOL
,VARIANT_FALSE
,I2
,0);
3027 VARINT(BOOL
,1,I2
,1);
3028 VARINT(UI1
,1,UI1
,1);
3029 VARINT(I2
,-1,I2
,-1);
3030 VARINT(I4
,-1,I4
,-1);
3033 VARINT(I8
,-1,I8
,-1);
3035 VARINT(R4
,1.4f
,R4
,1);
3036 VARINT(R4
,1.5f
,R4
,1);
3037 VARINT(R4
,1.6f
,R4
,1);
3038 VARINT(R4
,-1.4f
,R4
,-2); /* Note these 3 are different from VarFix */
3039 VARINT(R4
,-1.5f
,R4
,-2);
3040 VARINT(R4
,-1.6f
,R4
,-2);
3041 /* DATE & R8 round as for R4 */
3042 VARINT(DATE
,-1,DATE
,-1);
3043 VARINT(R8
,-1,R8
,-1);
3044 VARINT(BSTR
,(BSTR
)szNumMinus1
,R8
,-1);
3046 V_VT(&v
) = VT_EMPTY
;
3047 hres
= pVarInt(&v
,&vDst
);
3048 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I2
&& V_I2(&vDst
) == 0,
3049 "VarInt: expected 0x0,%d,0 got 0x%X,%d,%d\n", VT_EMPTY
,
3050 hres
, V_VT(&vDst
), V_I2(&vDst
));
3053 hres
= pVarInt(&v
,&vDst
);
3054 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_NULL
,
3055 "VarInt: expected 0x0,%d got 0x%X,%d\n", VT_NULL
, hres
, V_VT(&vDst
));
3057 V_VT(&v
) = VT_DECIMAL
;
3058 S(U(*pdec
)).sign
= DECIMAL_NEG
;
3059 S(U(*pdec
)).scale
= 0;
3061 S1(U1(*pdec
)).Mid32
= 0;
3062 S1(U1(*pdec
)).Lo32
= 1;
3063 hres
= pVarInt(&v
,&vDst
);
3064 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_DECIMAL
&& !memcmp(&V_DECIMAL(&v
), &V_DECIMAL(&vDst
), sizeof(DECIMAL
)),
3065 "VarInt: expected 0x0,%d,identical, got 0x%X,%d\n", VT_DECIMAL
,
3068 /* FIXME: Test some fractional decimals when VarDecInt is implemented */
3071 pcy
->int64
= -10000;
3072 hres
= pVarInt(&v
,&vDst
);
3073 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_CY
&& V_CY(&vDst
).int64
== -10000,
3074 "VarInt: VT_CY wrong, hres=0x%X\n", hres
);
3077 pcy
->int64
= -11000;
3078 hres
= pVarInt(&v
,&vDst
);
3079 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_CY
&& V_CY(&vDst
).int64
== -20000,
3080 "VarInt: VT_CY wrong, hres=0x%X 0x%x%08x\n",
3081 hres
, (DWORD
)(V_CY(&vDst
).int64
>> 32), (DWORD
)V_CY(&vDst
).int64
);
3084 static HRESULT (WINAPI
*pVarNeg
)(LPVARIANT
,LPVARIANT
);
3086 #define VARNEG(vt,val,rvt,rval) \
3087 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
3088 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
3089 test_var_call1( __LINE__, pVarNeg, &v, &exp )
3091 static void test_VarNeg(void)
3093 static const WCHAR szNumMinus1
[] = {'-','1','\0' };
3094 static const WCHAR szNum1
[] = {'1','\0' };
3096 VARIANT v
, exp
, vDst
;
3097 DECIMAL
*pdec
= &V_DECIMAL(&v
);
3098 CY
*pcy
= &V_CY(&v
);
3103 /* Test all possible V_VT values. But don't test the exact return values
3104 * except for success/failure, since M$ made a hash of them in the
3105 * native version. This at least ensures (as with all tests here) that
3106 * we will notice if/when new vtypes/flags are added in native.
3108 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
3112 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
3118 memset(&v
, 0, sizeof(v
));
3119 V_VT(&v
) = vt
| ExtraFlags
[i
];
3120 V_VT(&vDst
) = VT_EMPTY
;
3124 case VT_UI1
: case VT_I2
: case VT_I4
:
3125 case VT_R4
: case VT_R8
:
3126 case VT_DECIMAL
: case VT_BOOL
: case VT_NULL
: case VT_EMPTY
:
3127 case VT_DATE
: case VT_CY
:
3135 hres
= pVarNeg(&v
,&vDst
);
3137 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
3138 "VarNeg: expected failure, got 0x%X vt %d|0x%X\n",
3139 hres
, vt
, ExtraFlags
[i
]);
3141 ok(hres
== S_OK
, "VarNeg: expected S_OK, got 0x%X vt %d|0x%X\n",
3142 hres
, vt
, ExtraFlags
[i
]);
3146 VARNEG(BOOL
,VARIANT_TRUE
,I2
,1);
3147 VARNEG(BOOL
,VARIANT_FALSE
,I2
,0);
3148 VARNEG(BOOL
,1,I2
,-1);
3149 VARNEG(UI1
,1,I2
,-1);
3150 VARNEG(UI1
,254,I2
,-254);
3151 VARNEG(I2
,-32768,I4
,32768);
3154 VARNEG(I4
,-((int)(~0u >> 1)) - 1,R8
,-2147483648u);
3164 VARNEG(DATE
,1,DATE
,-1);
3165 VARNEG(DATE
,-1,DATE
,1);
3168 VARNEG(BSTR
,(BSTR
)szNumMinus1
,R8
,1);
3169 VARNEG(BSTR
,(BSTR
)szNum1
,R8
,-1);
3171 V_VT(&v
) = VT_EMPTY
;
3172 hres
= pVarNeg(&v
,&vDst
);
3173 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I2
&& V_I2(&vDst
) == 0,
3174 "VarNeg: expected 0x0,%d,0 got 0x%X,%d,%d\n", VT_EMPTY
,
3175 hres
, V_VT(&vDst
), V_I2(&vDst
));
3178 hres
= pVarNeg(&v
,&vDst
);
3179 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_NULL
,
3180 "VarNeg: expected 0x0,%d got 0x%X,%d\n", VT_NULL
, hres
, V_VT(&vDst
));
3182 V_VT(&v
) = VT_DECIMAL
;
3183 S(U(*pdec
)).sign
= DECIMAL_NEG
;
3184 S(U(*pdec
)).scale
= 0;
3186 S1(U1(*pdec
)).Mid32
= 0;
3187 S1(U1(*pdec
)).Lo32
= 1;
3188 hres
= pVarNeg(&v
,&vDst
);
3189 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_DECIMAL
&&
3190 S(U(V_DECIMAL(&vDst
))).sign
== 0,
3191 "VarNeg: expected 0x0,%d,0x00, got 0x%X,%d,%02x\n", VT_DECIMAL
,
3192 hres
, V_VT(&vDst
), S(U(V_DECIMAL(&vDst
))).sign
);
3194 S(U(*pdec
)).sign
= 0;
3195 hres
= pVarNeg(&v
,&vDst
);
3196 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_DECIMAL
&&
3197 S(U(V_DECIMAL(&vDst
))).sign
== DECIMAL_NEG
,
3198 "VarNeg: expected 0x0,%d,0x7f, got 0x%X,%d,%02x\n", VT_DECIMAL
,
3199 hres
, V_VT(&vDst
), S(U(V_DECIMAL(&vDst
))).sign
);
3202 pcy
->int64
= -10000;
3203 hres
= pVarNeg(&v
,&vDst
);
3204 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_CY
&& V_CY(&vDst
).int64
== 10000,
3205 "VarNeg: VT_CY wrong, hres=0x%X\n", hres
);
3208 static HRESULT (WINAPI
*pVarRound
)(LPVARIANT
,int,LPVARIANT
);
3210 static void test_Round( int line
, VARIANT
*arg
, int deci
, VARIANT
*expected
)
3215 memset( &result
, 0, sizeof(result
) );
3216 hres
= pVarRound( arg
, deci
, &result
);
3217 ok_(__FILE__
,line
)( hres
== S_OK
, "wrong result %x\n", hres
);
3219 ok_(__FILE__
,line
)( is_expected_variant( &result
, expected
),
3220 "got %s expected %s\n", variantstr(&result
), variantstr(expected
) );
3222 #define VARROUND(vt,val,deci,rvt,rval) \
3223 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
3224 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
3225 test_Round( __LINE__, &v, deci, &exp )
3235 struct decimal_round_t
{
3236 struct decimal_t source
;
3237 struct decimal_t ret
;
3241 static const struct decimal_round_t decimal_round_data
[] = {
3242 {{ 0, DECIMAL_NEG
, 0, 0, 1 }, { 0, DECIMAL_NEG
, 0, 0, 1 }, 0},
3243 {{ 0, 0, 0, 0, 1 }, { 0, 0, 0, 0, 1 }, 0},
3244 {{ 2, 0, 0, 0, 155 }, { 0, 0, 0, 0, 16 }, 1},
3245 {{ 2, 0, 0, 0, 155 }, { 1, 0, 0, 0, 2 }, 0},
3246 {{ 2, 0, 0, 0, 199 }, { 1, 0, 0, 0, 20 }, 1},
3247 {{ 2, 0, 0, 0, 199 }, { 2, 0, 0, 0, 199 }, 2},
3248 {{ 2, DECIMAL_NEG
, 0, 0, 199 }, { 2, DECIMAL_NEG
, 0, 0, 199 }, 2},
3249 {{ 2, DECIMAL_NEG
, 0, 0, 55 }, { 2, DECIMAL_NEG
, 0, 0, 6 }, 1},
3250 {{ 2, 0, 0, 0, 55 }, { 2, 0, 0, 0, 6 }, 1}
3253 static void test_VarRound(void)
3255 static WCHAR szNumMin
[] = {'-','1','.','4','4','9','\0' };
3256 static WCHAR szNum
[] = {'1','.','4','5','1','\0' };
3258 VARIANT v
, exp
, vDst
;
3259 CY
*pcy
= &V_CY(&v
);
3265 /* first check valid integer types */
3266 VARROUND(BOOL
,VARIANT_TRUE
,0,I2
,-1);
3267 VARROUND(BOOL
,VARIANT_FALSE
,0,I2
,0);
3268 VARROUND(BOOL
,1,0,I2
,1);
3269 VARROUND(UI1
,1,0,UI1
,1);
3270 VARROUND(UI1
,254,0,UI1
,254);
3271 VARROUND(I2
,-32768,0,I2
,-32768);
3272 VARROUND(I2
,-1,0,I2
,-1);
3273 VARROUND(I2
,1,0,I2
,1);
3274 VARROUND(I4
,-((int)(~0u >> 1)) - 1,0,I4
,-((int)(~0u >> 1)) - 1);
3275 VARROUND(I4
,-1,0,I4
,-1);
3276 VARROUND(I4
,1,0,I4
,1);
3279 /* MSDN states that rounding of R4/R8 is dependent on the underlying
3280 * bit pattern of the number and so is architecture dependent. In this
3281 * case Wine returns .2 (which is more correct) and Native returns .3
3284 VARROUND(R4
,1.0f
,0,R4
,1.0f
);
3285 VARROUND(R4
,-1.0f
,0,R4
,-1.0f
);
3286 VARROUND(R8
,1.0,0,R8
,1.0);
3287 VARROUND(R8
,-1.0,0,R8
,-1.0);
3289 /* floating point numbers aren't exactly equal and we can't just
3290 * compare the first few digits. */
3291 VARROUND(DATE
,1.451,1,DATE
,1.5);
3292 VARROUND(DATE
,-1.449,1,DATE
,-1.4);
3294 /* replace the decimal separator */
3295 GetLocaleInfoA(LOCALE_USER_DEFAULT
, LOCALE_SDECIMAL
, buff
, sizeof(buff
)/sizeof(char));
3297 szNumMin
[2] = buff
[0];
3299 VARROUND(BSTR
,(BSTR
)szNumMin
,1,R8
,-1.40);
3300 VARROUND(BSTR
,(BSTR
)szNum
,1,R8
,1.50);
3302 skip("Skipping VarRound(BSTR) as decimal separator is '%s'\n", buff
);
3305 VARROUND(R4
,1.23456f
,0,R4
,1.0f
);
3306 VARROUND(R4
,1.23456f
,1,R4
,1.2f
);
3307 VARROUND(R4
,1.23456f
,2,R4
,1.23f
);
3308 VARROUND(R4
,1.23456f
,3,R4
,1.235f
);
3309 VARROUND(R4
,1.23456f
,4,R4
,1.2346f
);
3310 VARROUND(R4
,-1.23456f
,0,R4
,-1.0f
);
3311 VARROUND(R4
,-1.23456f
,1,R4
,-1.2f
);
3312 VARROUND(R4
,-1.23456f
,2,R4
,-1.23f
);
3313 VARROUND(R4
,-1.23456f
,3,R4
,-1.235f
);
3314 VARROUND(R4
,-1.23456f
,4,R4
,-1.2346f
);
3316 VARROUND(R8
,1.23456,0,R8
,1.0);
3317 VARROUND(R8
,1.23456,1,R8
,1.2);
3318 VARROUND(R8
,1.23456,2,R8
,1.23);
3319 VARROUND(R8
,1.23456,3,R8
,1.235);
3320 VARROUND(R8
,1.23456,4,R8
,1.2346);
3321 VARROUND(R8
,-1.23456,0,R8
,-1.0);
3322 VARROUND(R8
,-1.23456,1,R8
,-1.2);
3323 VARROUND(R8
,-1.23456,2,R8
,-1.23);
3324 VARROUND(R8
,-1.23456,3,R8
,-1.235);
3325 VARROUND(R8
,-1.23456,4,R8
,-1.2346);
3327 V_VT(&v
) = VT_EMPTY
;
3328 hres
= pVarRound(&v
,0,&vDst
);
3329 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I2
&& V_I2(&vDst
) == 0,
3330 "VarRound: expected 0x0,%d,0 got 0x%X,%d,%d\n", VT_EMPTY
,
3331 hres
, V_VT(&vDst
), V_I2(&vDst
));
3334 hres
= pVarRound(&v
,0,&vDst
);
3335 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_NULL
,
3336 "VarRound: expected 0x0,%d got 0x%X,%d\n", VT_NULL
, hres
, V_VT(&vDst
));
3339 for (i
= 0; i
< sizeof(decimal_round_data
)/sizeof(struct decimal_round_t
); i
++)
3341 const struct decimal_round_t
*ptr
= &decimal_round_data
[i
];
3344 pdec
= &V_DECIMAL(&v
);
3345 V_VT(&v
) = VT_DECIMAL
;
3346 S(U(*pdec
)).sign
= ptr
->source
.sign
;
3347 S(U(*pdec
)).scale
= ptr
->source
.scale
;
3348 pdec
->Hi32
= ptr
->source
.Hi32
;
3349 S1(U1(*pdec
)).Mid32
= ptr
->source
.Mid32
;
3350 S1(U1(*pdec
)).Lo32
= ptr
->source
.Lo32
;
3352 hres
= pVarRound(&v
, ptr
->dec
, &vDst
);
3354 ok(hres
== S_OK
, "%d: got 0x%08x\n", i
, hres
);
3357 ok(V_VT(&vDst
) == VT_DECIMAL
, "%d: got VT %d, expected VT_DECIMAL\n", i
, V_VT(&vDst
));
3358 ok(S(U(V_DECIMAL(&vDst
))).sign
== ptr
->ret
.sign
, "%d: got sign 0x%02x, expected 0x%02x\n",
3359 i
, S(U(V_DECIMAL(&vDst
))).sign
, ptr
->ret
.sign
);
3360 ok(V_DECIMAL(&vDst
).Hi32
== ptr
->ret
.Hi32
, "%d: got Hi32 %d, expected %d\n",
3361 i
, V_DECIMAL(&vDst
).Hi32
, ptr
->ret
.Hi32
);
3362 ok(S1(U1(V_DECIMAL(&vDst
))).Mid32
== ptr
->ret
.Mid32
, "%d: got Mid32 %d, expected %d\n",
3363 i
, S1(U1(V_DECIMAL(&vDst
))).Mid32
, ptr
->ret
.Mid32
);
3364 ok(S1(U1(V_DECIMAL(&vDst
))).Lo32
== ptr
->ret
.Lo32
, "%d: got Lo32 %d, expected %d\n",
3365 i
, S1(U1(V_DECIMAL(&vDst
))).Lo32
, ptr
->ret
.Lo32
);
3372 hres
= pVarRound(&v
,0,&vDst
);
3373 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_CY
&& V_CY(&vDst
).int64
== 10000,
3374 "VarRound: VT_CY wrong, hres=0x%X\n", hres
);
3378 static HRESULT (WINAPI
*pVarXor
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
3380 #define VARXOR(vt1,val1,vt2,val2,rvt,rval) \
3381 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
3382 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
3383 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
3384 test_var_call2( __LINE__, pVarXor, &left, &right, &exp )
3386 #define VARXORCY(vt1,val1,val2,rvt,rval) \
3387 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
3388 V_VT(&right) = VT_CY; V_CY(&right).int64 = val2; \
3389 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
3390 test_var_call2( __LINE__, pVarXor, &left, &right, &exp )
3392 static void test_VarXor(void)
3394 static const WCHAR szFalse
[] = { '#','F','A','L','S','E','#','\0' };
3395 static const WCHAR szTrue
[] = { '#','T','R','U','E','#','\0' };
3396 VARIANT left
, right
, exp
, result
;
3403 /* Test all possible flag/vt combinations & the resulting vt type */
3404 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
3406 VARTYPE leftvt
, rightvt
, resvt
;
3408 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
3413 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
3419 if (leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
||
3420 leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
||
3421 leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
)
3424 memset(&left
, 0, sizeof(left
));
3425 memset(&right
, 0, sizeof(right
));
3426 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
3427 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
3428 V_VT(&result
) = VT_EMPTY
;
3431 if (ExtraFlags
[i
] & VT_ARRAY
|| ExtraFlags
[i
] & VT_BYREF
||
3432 !IsValidVariantClearVT(leftvt
, ExtraFlags
[i
]) ||
3433 !IsValidVariantClearVT(rightvt
, ExtraFlags
[i
]) ||
3434 leftvt
== VT_CLSID
|| rightvt
== VT_CLSID
||
3435 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
||
3436 leftvt
== VT_VARIANT
|| rightvt
== VT_VARIANT
||
3437 leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
)
3441 if (leftvt
== VT_EMPTY
|| rightvt
== VT_EMPTY
)
3443 if (leftvt
== rightvt
||
3444 leftvt
== VT_I2
|| rightvt
== VT_I2
||
3445 leftvt
== VT_UI1
|| rightvt
== VT_UI1
||
3446 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
3448 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
3450 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
3453 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
3457 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
3459 if (leftvt
== rightvt
)
3461 else if (leftvt
== rightvt
||
3462 leftvt
== VT_I2
|| rightvt
== VT_I2
||
3463 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
3467 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
3470 else if (leftvt
== VT_I2
|| rightvt
== VT_I2
)
3472 if (leftvt
== rightvt
||
3473 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
3475 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
3478 else if (leftvt
== VT_BOOL
&& rightvt
== VT_BOOL
)
3482 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
3484 if (leftvt
== VT_INT
|| rightvt
== VT_INT
)
3489 hres
= pVarXor(&left
, &right
, &result
);
3491 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
3492 "VarXor: %d|0x%X, %d|0x%X: Expected failure, got 0x%X vt %d\n",
3493 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], hres
,
3496 ok(hres
== S_OK
&& V_VT(&result
) == resvt
,
3497 "VarXor: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%X vt %d\n",
3498 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], resvt
, hres
,
3504 /* Test returned values
3505 * FIXME: Test VT_DECIMAL/VT_DISPATCH
3507 VARXOR(EMPTY
,0,EMPTY
,0,I2
,0);
3508 VARXOR(EMPTY
,1,EMPTY
,0,I2
,0);
3509 VARXOR(EMPTY
,0,NULL
,0,NULL
,0);
3510 VARXOR(EMPTY
,0,I1
,0,I4
,0);
3511 VARXOR(EMPTY
,0,I1
,1,I4
,1);
3512 VARXOR(EMPTY
,0,UI1
,0,I2
,0);
3513 VARXOR(EMPTY
,0,UI1
,1,I2
,1);
3514 VARXOR(EMPTY
,0,I2
,0,I2
,0);
3515 VARXOR(EMPTY
,0,I2
,1,I2
,1);
3516 VARXOR(EMPTY
,0,UI2
,0,I4
,0);
3517 VARXOR(EMPTY
,0,UI2
,1,I4
,1);
3518 VARXOR(EMPTY
,0,I4
,0,I4
,0);
3519 VARXOR(EMPTY
,0,I4
,1,I4
,1);
3520 VARXOR(EMPTY
,0,UI4
,0,I4
,0);
3521 VARXOR(EMPTY
,0,UI4
,1,I4
,1);
3524 VARXOR(EMPTY
,0,I8
,0,I8
,0);
3525 VARXOR(EMPTY
,0,I8
,1,I8
,1);
3526 VARXOR(EMPTY
,0,UI8
,0,I4
,0);
3527 VARXOR(EMPTY
,0,UI8
,1,I4
,1);
3529 VARXOR(EMPTY
,0,INT
,0,I4
,0);
3530 VARXOR(EMPTY
,0,INT
,1,I4
,1);
3531 VARXOR(EMPTY
,0,UINT
,0,I4
,0);
3532 VARXOR(EMPTY
,0,UINT
,1,I4
,1);
3533 VARXOR(EMPTY
,0,BOOL
,0,I2
,0);
3534 VARXOR(EMPTY
,0,BOOL
,1,I2
,1);
3535 VARXOR(EMPTY
,0,R4
,0,I4
,0);
3536 VARXOR(EMPTY
,0,R4
,1,I4
,1);
3537 VARXOR(EMPTY
,0,R8
,0,I4
,0);
3538 VARXOR(EMPTY
,0,R8
,1,I4
,1);
3539 rbstr
= SysAllocString(szFalse
);
3540 VARXOR(EMPTY
,0,BSTR
,rbstr
,I2
,0);
3541 SysFreeString(rbstr
);
3542 rbstr
= SysAllocString(szTrue
);
3543 VARXOR(EMPTY
,0,BSTR
,rbstr
,I2
,-1);
3544 VARXORCY(EMPTY
,0,10000,I4
,1);
3545 SysFreeString(rbstr
);
3547 /* NULL OR 0 = NULL. NULL OR n = n */
3548 VARXOR(NULL
,0,NULL
,0,NULL
,0);
3549 VARXOR(NULL
,1,NULL
,0,NULL
,0);
3550 VARXOR(NULL
,0,I1
,0,NULL
,0);
3551 VARXOR(NULL
,0,I1
,1,NULL
,0);
3552 VARXOR(NULL
,0,UI1
,0,NULL
,0);
3553 VARXOR(NULL
,0,UI1
,1,NULL
,0);
3554 VARXOR(NULL
,0,I2
,0,NULL
,0);
3555 VARXOR(NULL
,0,I2
,1,NULL
,0);
3556 VARXOR(NULL
,0,UI2
,0,NULL
,0);
3557 VARXOR(NULL
,0,UI2
,1,NULL
,0);
3558 VARXOR(NULL
,0,I4
,0,NULL
,0);
3559 VARXOR(NULL
,0,I4
,1,NULL
,0);
3560 VARXOR(NULL
,0,UI4
,0,NULL
,0);
3561 VARXOR(NULL
,0,UI4
,1,NULL
,0);
3564 VARXOR(NULL
,0,I8
,0,NULL
,0);
3565 VARXOR(NULL
,0,I8
,1,NULL
,0);
3566 VARXOR(NULL
,0,UI8
,0,NULL
,0);
3567 VARXOR(NULL
,0,UI8
,1,NULL
,0);
3569 VARXOR(NULL
,0,INT
,0,NULL
,0);
3570 VARXOR(NULL
,0,INT
,1,NULL
,0);
3571 VARXOR(NULL
,0,UINT
,0,NULL
,0);
3572 VARXOR(NULL
,0,UINT
,1,NULL
,0);
3573 VARXOR(NULL
,0,BOOL
,0,NULL
,0);
3574 VARXOR(NULL
,0,BOOL
,1,NULL
,0);
3575 VARXOR(NULL
,0,R4
,0,NULL
,0);
3576 VARXOR(NULL
,0,R4
,1,NULL
,0);
3577 VARXOR(NULL
,0,R8
,0,NULL
,0);
3578 VARXOR(NULL
,0,R8
,1,NULL
,0);
3579 rbstr
= SysAllocString(szFalse
);
3580 VARXOR(NULL
,0,BSTR
,rbstr
,NULL
,0);
3581 SysFreeString(rbstr
);
3582 rbstr
= SysAllocString(szTrue
);
3583 VARXOR(NULL
,0,BSTR
,rbstr
,NULL
,0);
3584 SysFreeString(rbstr
);
3585 VARXORCY(NULL
,0,10000,NULL
,0);
3586 VARXORCY(NULL
,0,0,NULL
,0);
3588 VARXOR(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
);
3589 VARXOR(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
);
3590 VARXOR(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
);
3591 VARXOR(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_FALSE
);
3592 /* Assume x,y & y,x are the same from now on to reduce the number of tests */
3593 VARXOR(BOOL
,VARIANT_TRUE
,I1
,-1,I4
,0);
3594 VARXOR(BOOL
,VARIANT_TRUE
,I1
,0,I4
,-1);
3595 VARXOR(BOOL
,VARIANT_FALSE
,I1
,0,I4
,0);
3596 VARXOR(BOOL
,VARIANT_TRUE
,UI1
,255,I2
,-256);
3597 VARXOR(BOOL
,VARIANT_TRUE
,UI1
,0,I2
,-1);
3598 VARXOR(BOOL
,VARIANT_FALSE
,UI1
,0,I2
,0);
3599 VARXOR(BOOL
,VARIANT_TRUE
,I2
,-1,I2
,0);
3600 VARXOR(BOOL
,VARIANT_TRUE
,I2
,0,I2
,-1);
3601 VARXOR(BOOL
,VARIANT_FALSE
,I2
,0,I2
,0);
3602 VARXOR(BOOL
,VARIANT_TRUE
,UI2
,65535,I4
,-65536);
3603 VARXOR(BOOL
,VARIANT_TRUE
,UI2
,0,I4
,-1);
3604 VARXOR(BOOL
,VARIANT_FALSE
,UI2
,0,I4
,0);
3605 VARXOR(BOOL
,VARIANT_TRUE
,I4
,-1,I4
,0);
3606 VARXOR(BOOL
,VARIANT_TRUE
,I4
,0,I4
,-1);
3607 VARXOR(BOOL
,VARIANT_FALSE
,I4
,0,I4
,0);
3608 VARXOR(BOOL
,VARIANT_TRUE
,UI4
,0xffffffff,I4
,0);
3609 VARXOR(BOOL
,VARIANT_TRUE
,UI4
,0,I4
,-1);
3610 VARXOR(BOOL
,VARIANT_FALSE
,UI4
,0,I4
,0);
3611 VARXOR(BOOL
,VARIANT_TRUE
,R4
,-1,I4
,0);
3612 VARXOR(BOOL
,VARIANT_TRUE
,R4
,0,I4
,-1);
3613 VARXOR(BOOL
,VARIANT_FALSE
,R4
,0,I4
,0);
3614 VARXOR(BOOL
,VARIANT_TRUE
,R8
,-1,I4
,0);
3615 VARXOR(BOOL
,VARIANT_TRUE
,R8
,0,I4
,-1);
3616 VARXOR(BOOL
,VARIANT_FALSE
,R8
,0,I4
,0);
3617 VARXOR(BOOL
,VARIANT_TRUE
,DATE
,-1,I4
,0);
3618 VARXOR(BOOL
,VARIANT_TRUE
,DATE
,0,I4
,-1);
3619 VARXOR(BOOL
,VARIANT_FALSE
,DATE
,0,I4
,0);
3622 VARXOR(BOOL
,VARIANT_TRUE
,I8
,-1,I8
,0);
3623 VARXOR(BOOL
,VARIANT_TRUE
,I8
,0,I8
,-1);
3624 VARXOR(BOOL
,VARIANT_FALSE
,I8
,0,I8
,0);
3625 /* This returns DISP_E_OVERFLOW which indicates that a conversion
3626 * to I4 is performed.
3628 /* VARXOR(BOOL,VARIANT_TRUE,UI8,-1,I4,-1); */
3629 VARXOR(BOOL
,VARIANT_TRUE
,UI8
,0,I4
,-1);
3630 VARXOR(BOOL
,VARIANT_FALSE
,UI8
,0,I4
,0);
3632 VARXOR(BOOL
,VARIANT_TRUE
,INT
,-1,I4
,0);
3633 VARXOR(BOOL
,VARIANT_TRUE
,INT
,0,I4
,-1);
3634 VARXOR(BOOL
,VARIANT_FALSE
,INT
,0,I4
,0);
3635 VARXOR(BOOL
,VARIANT_TRUE
,UINT
,0xffffffff,I4
,0);
3636 VARXOR(BOOL
,VARIANT_TRUE
,UINT
,0,I4
,-1);
3637 VARXOR(BOOL
,VARIANT_FALSE
,UINT
,0,I4
,0);
3638 rbstr
= SysAllocString(szFalse
);
3639 VARXOR(BOOL
,VARIANT_FALSE
,BSTR
,rbstr
,BOOL
,VARIANT_FALSE
);
3640 VARXOR(BOOL
,VARIANT_TRUE
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
3641 SysFreeString(rbstr
);
3642 rbstr
= SysAllocString(szTrue
);
3643 VARXOR(BOOL
,VARIANT_FALSE
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
3644 VARXOR(BOOL
,VARIANT_TRUE
,BSTR
,rbstr
,BOOL
,VARIANT_FALSE
);
3645 SysFreeString(rbstr
);
3646 VARXORCY(BOOL
,VARIANT_TRUE
,10000,I4
,-2);
3647 VARXORCY(BOOL
,VARIANT_TRUE
,0,I4
,-1);
3648 VARXORCY(BOOL
,VARIANT_FALSE
,0,I4
,0);
3650 VARXOR(I1
,-1,I1
,-1,I4
,0);
3651 VARXOR(I1
,-1,I1
,0,I4
,-1);
3652 VARXOR(I1
,0,I1
,0,I4
,0);
3653 VARXOR(I1
,-1,UI1
,255,I4
,-256);
3654 VARXOR(I1
,-1,UI1
,0,I4
,-1);
3655 VARXOR(I1
,0,UI1
,0,I4
,0);
3656 VARXOR(I1
,-1,I2
,-1,I4
,0);
3657 VARXOR(I1
,-1,I2
,0,I4
,-1);
3658 VARXOR(I1
,0,I2
,0,I4
,0);
3659 VARXOR(I1
,-1,UI2
,65535,I4
,-65536);
3660 VARXOR(I1
,-1,UI2
,0,I4
,-1);
3661 VARXOR(I1
,0,UI2
,0,I4
,0);
3662 VARXOR(I1
,-1,I4
,-1,I4
,0);
3663 VARXOR(I1
,-1,I4
,0,I4
,-1);
3664 VARXOR(I1
,0,I4
,0,I4
,0);
3665 VARXOR(I1
,-1,UI4
,0xffffffff,I4
,0);
3666 VARXOR(I1
,-1,UI4
,0,I4
,-1);
3667 VARXOR(I1
,0,UI4
,0,I4
,0);
3668 VARXOR(I1
,-1,R4
,-1,I4
,0);
3669 VARXOR(I1
,-1,R4
,0,I4
,-1);
3670 VARXOR(I1
,0,R4
,0,I4
,0);
3671 VARXOR(I1
,-1,R8
,-1,I4
,0);
3672 VARXOR(I1
,-1,R8
,0,I4
,-1);
3673 VARXOR(I1
,0,R8
,0,I4
,0);
3674 VARXOR(I1
,-1,DATE
,-1,I4
,0);
3675 VARXOR(I1
,-1,DATE
,0,I4
,-1);
3676 VARXOR(I1
,0,DATE
,0,I4
,0);
3679 VARXOR(I1
,-1,I8
,-1,I8
,0);
3680 VARXOR(I1
,-1,I8
,0,I8
,-1);
3681 VARXOR(I1
,0,I8
,0,I8
,0);
3682 VARXOR(I1
,-1,UI8
,0,I4
,-1);
3683 VARXOR(I1
,0,UI8
,0,I4
,0);
3685 VARXOR(I1
,-1,INT
,-1,I4
,0);
3686 VARXOR(I1
,-1,INT
,0,I4
,-1);
3687 VARXOR(I1
,0,INT
,0,I4
,0);
3688 VARXOR(I1
,-1,UINT
,0xffffffff,I4
,0);
3689 VARXOR(I1
,-1,UINT
,0,I4
,-1);
3690 VARXOR(I1
,0,UINT
,0,I4
,0);
3691 rbstr
= SysAllocString(szFalse
);
3692 VARXOR(I1
,0,BSTR
,rbstr
,I4
,0);
3693 VARXOR(I1
,-1,BSTR
,rbstr
,I4
,-1);
3694 SysFreeString(rbstr
);
3695 rbstr
= SysAllocString(szTrue
);
3696 VARXOR(I1
,0,BSTR
,rbstr
,I4
,-1);
3697 VARXOR(I1
,-1,BSTR
,rbstr
,I4
,0);
3698 SysFreeString(rbstr
);
3699 VARXORCY(I1
,-1,10000,I4
,-2);
3700 VARXORCY(I1
,-1,0,I4
,-1);
3701 VARXORCY(I1
,0,0,I4
,0);
3703 VARXOR(UI1
,255,UI1
,255,UI1
,0);
3704 VARXOR(UI1
,255,UI1
,0,UI1
,255);
3705 VARXOR(UI1
,0,UI1
,0,UI1
,0);
3706 VARXOR(UI1
,255,I2
,-1,I2
,-256);
3707 VARXOR(UI1
,255,I2
,0,I2
,255);
3708 VARXOR(UI1
,0,I2
,0,I2
,0);
3709 VARXOR(UI1
,255,UI2
,65535,I4
,65280);
3710 VARXOR(UI1
,255,UI2
,0,I4
,255);
3711 VARXOR(UI1
,0,UI2
,0,I4
,0);
3712 VARXOR(UI1
,255,I4
,-1,I4
,-256);
3713 VARXOR(UI1
,255,I4
,0,I4
,255);
3714 VARXOR(UI1
,0,I4
,0,I4
,0);
3715 VARXOR(UI1
,255,UI4
,0xffffffff,I4
,-256);
3716 VARXOR(UI1
,255,UI4
,0,I4
,255);
3717 VARXOR(UI1
,0,UI4
,0,I4
,0);
3718 VARXOR(UI1
,255,R4
,-1,I4
,-256);
3719 VARXOR(UI1
,255,R4
,0,I4
,255);
3720 VARXOR(UI1
,0,R4
,0,I4
,0);
3721 VARXOR(UI1
,255,R8
,-1,I4
,-256);
3722 VARXOR(UI1
,255,R8
,0,I4
,255);
3723 VARXOR(UI1
,0,R8
,0,I4
,0);
3724 VARXOR(UI1
,255,DATE
,-1,I4
,-256);
3725 VARXOR(UI1
,255,DATE
,0,I4
,255);
3726 VARXOR(UI1
,0,DATE
,0,I4
,0);
3729 VARXOR(UI1
,255,I8
,-1,I8
,-256);
3730 VARXOR(UI1
,255,I8
,0,I8
,255);
3731 VARXOR(UI1
,0,I8
,0,I8
,0);
3732 VARXOR(UI1
,255,UI8
,0,I4
,255);
3733 VARXOR(UI1
,0,UI8
,0,I4
,0);
3735 VARXOR(UI1
,255,INT
,-1,I4
,-256);
3736 VARXOR(UI1
,255,INT
,0,I4
,255);
3737 VARXOR(UI1
,0,INT
,0,I4
,0);
3738 VARXOR(UI1
,255,UINT
,0xffffffff,I4
,-256);
3739 VARXOR(UI1
,255,UINT
,0,I4
,255);
3740 VARXOR(UI1
,0,UINT
,0,I4
,0);
3741 rbstr
= SysAllocString(szFalse
);
3742 VARXOR(UI1
,0,BSTR
,rbstr
,I2
,0);
3743 VARXOR(UI1
,255,BSTR
,rbstr
,I2
,255);
3744 SysFreeString(rbstr
);
3745 rbstr
= SysAllocString(szTrue
);
3746 VARXOR(UI1
,0,BSTR
,rbstr
,I2
,-1);
3747 VARXOR(UI1
,255,BSTR
,rbstr
,I2
,-256);
3748 SysFreeString(rbstr
);
3749 VARXORCY(UI1
,255,10000,I4
,254);
3750 VARXORCY(UI1
,255,0,I4
,255);
3751 VARXORCY(UI1
,0,0,I4
,0);
3753 VARXOR(I2
,-1,I2
,-1,I2
,0);
3754 VARXOR(I2
,-1,I2
,0,I2
,-1);
3755 VARXOR(I2
,0,I2
,0,I2
,0);
3756 VARXOR(I2
,-1,UI2
,65535,I4
,-65536);
3757 VARXOR(I2
,-1,UI2
,0,I4
,-1);
3758 VARXOR(I2
,0,UI2
,0,I4
,0);
3759 VARXOR(I2
,-1,I4
,-1,I4
,0);
3760 VARXOR(I2
,-1,I4
,0,I4
,-1);
3761 VARXOR(I2
,0,I4
,0,I4
,0);
3762 VARXOR(I2
,-1,UI4
,0xffffffff,I4
,0);
3763 VARXOR(I2
,-1,UI4
,0,I4
,-1);
3764 VARXOR(I2
,0,UI4
,0,I4
,0);
3765 VARXOR(I2
,-1,R4
,-1,I4
,0);
3766 VARXOR(I2
,-1,R4
,0,I4
,-1);
3767 VARXOR(I2
,0,R4
,0,I4
,0);
3768 VARXOR(I2
,-1,R8
,-1,I4
,0);
3769 VARXOR(I2
,-1,R8
,0,I4
,-1);
3770 VARXOR(I2
,0,R8
,0,I4
,0);
3771 VARXOR(I2
,-1,DATE
,-1,I4
,0);
3772 VARXOR(I2
,-1,DATE
,0,I4
,-1);
3773 VARXOR(I2
,0,DATE
,0,I4
,0);
3776 VARXOR(I2
,-1,I8
,-1,I8
,0);
3777 VARXOR(I2
,-1,I8
,0,I8
,-1);
3778 VARXOR(I2
,0,I8
,0,I8
,0);
3779 VARXOR(I2
,-1,UI8
,0,I4
,-1);
3780 VARXOR(I2
,0,UI8
,0,I4
,0);
3782 VARXOR(I2
,-1,INT
,-1,I4
,0);
3783 VARXOR(I2
,-1,INT
,0,I4
,-1);
3784 VARXOR(I2
,0,INT
,0,I4
,0);
3785 VARXOR(I2
,-1,UINT
,0xffffffff,I4
,0);
3786 VARXOR(I2
,-1,UINT
,0,I4
,-1);
3787 VARXOR(I2
,0,UINT
,0,I4
,0);
3788 rbstr
= SysAllocString(szFalse
);
3789 VARXOR(I2
,0,BSTR
,rbstr
,I2
,0);
3790 VARXOR(I2
,-1,BSTR
,rbstr
,I2
,-1);
3791 SysFreeString(rbstr
);
3792 rbstr
= SysAllocString(szTrue
);
3793 VARXOR(I2
,0,BSTR
,rbstr
,I2
,-1);
3794 VARXOR(I2
,-1,BSTR
,rbstr
,I2
,0);
3795 SysFreeString(rbstr
);
3796 VARXORCY(I2
,-1,10000,I4
,-2);
3797 VARXORCY(I2
,-1,0,I4
,-1);
3798 VARXORCY(I2
,0,0,I4
,0);
3800 VARXOR(UI2
,65535,UI2
,65535,I4
,0);
3801 VARXOR(UI2
,65535,UI2
,0,I4
,65535);
3802 VARXOR(UI2
,0,UI2
,0,I4
,0);
3803 VARXOR(UI2
,65535,I4
,-1,I4
,-65536);
3804 VARXOR(UI2
,65535,I4
,0,I4
,65535);
3805 VARXOR(UI2
,0,I4
,0,I4
,0);
3806 VARXOR(UI2
,65535,UI4
,0xffffffff,I4
,-65536);
3807 VARXOR(UI2
,65535,UI4
,0,I4
,65535);
3808 VARXOR(UI2
,0,UI4
,0,I4
,0);
3809 VARXOR(UI2
,65535,R4
,-1,I4
,-65536);
3810 VARXOR(UI2
,65535,R4
,0,I4
,65535);
3811 VARXOR(UI2
,0,R4
,0,I4
,0);
3812 VARXOR(UI2
,65535,R8
,-1,I4
,-65536);
3813 VARXOR(UI2
,65535,R8
,0,I4
,65535);
3814 VARXOR(UI2
,0,R8
,0,I4
,0);
3815 VARXOR(UI2
,65535,DATE
,-1,I4
,-65536);
3816 VARXOR(UI2
,65535,DATE
,0,I4
,65535);
3817 VARXOR(UI2
,0,DATE
,0,I4
,0);
3820 VARXOR(UI2
,65535,I8
,-1,I8
,-65536);
3821 VARXOR(UI2
,65535,I8
,0,I8
,65535);
3822 VARXOR(UI2
,0,I8
,0,I8
,0);
3823 VARXOR(UI2
,65535,UI8
,0,I4
,65535);
3824 VARXOR(UI2
,0,UI8
,0,I4
,0);
3826 VARXOR(UI2
,65535,INT
,-1,I4
,-65536);
3827 VARXOR(UI2
,65535,INT
,0,I4
,65535);
3828 VARXOR(UI2
,0,INT
,0,I4
,0);
3829 VARXOR(UI2
,65535,UINT
,0xffffffff,I4
,-65536);
3830 VARXOR(UI2
,65535,UINT
,0,I4
,65535);
3831 VARXOR(UI2
,0,UINT
,0,I4
,0);
3832 rbstr
= SysAllocString(szFalse
);
3833 VARXOR(UI2
,0,BSTR
,rbstr
,I4
,0);
3834 VARXOR(UI2
,65535,BSTR
,rbstr
,I4
,65535);
3835 SysFreeString(rbstr
);
3836 rbstr
= SysAllocString(szTrue
);
3837 VARXOR(UI2
,0,BSTR
,rbstr
,I4
,-1);
3838 VARXOR(UI2
,65535,BSTR
,rbstr
,I4
,-65536);
3839 SysFreeString(rbstr
);
3840 VARXORCY(UI2
,65535,10000,I4
,65534);
3841 VARXORCY(UI2
,65535,0,I4
,65535);
3842 VARXORCY(UI2
,0,0,I4
,0);
3844 VARXOR(I4
,-1,I4
,-1,I4
,0);
3845 VARXOR(I4
,-1,I4
,0,I4
,-1);
3846 VARXOR(I4
,0,I4
,0,I4
,0);
3847 VARXOR(I4
,-1,UI4
,0xffffffff,I4
,0);
3848 VARXOR(I4
,-1,UI4
,0,I4
,-1);
3849 VARXOR(I4
,0,UI4
,0,I4
,0);
3850 VARXOR(I4
,-1,R4
,-1,I4
,0);
3851 VARXOR(I4
,-1,R4
,0,I4
,-1);
3852 VARXOR(I4
,0,R4
,0,I4
,0);
3853 VARXOR(I4
,-1,R8
,-1,I4
,0);
3854 VARXOR(I4
,-1,R8
,0,I4
,-1);
3855 VARXOR(I4
,0,R8
,0,I4
,0);
3856 VARXOR(I4
,-1,DATE
,-1,I4
,0);
3857 VARXOR(I4
,-1,DATE
,0,I4
,-1);
3858 VARXOR(I4
,0,DATE
,0,I4
,0);
3861 VARXOR(I4
,-1,I8
,-1,I8
,0);
3862 VARXOR(I4
,-1,I8
,0,I8
,-1);
3863 VARXOR(I4
,0,I8
,0,I8
,0);
3864 VARXOR(I4
,-1,UI8
,0,I4
,-1);
3865 VARXOR(I4
,0,UI8
,0,I4
,0);
3867 VARXOR(I4
,-1,INT
,-1,I4
,0);
3868 VARXOR(I4
,-1,INT
,0,I4
,-1);
3869 VARXOR(I4
,0,INT
,0,I4
,0);
3870 VARXOR(I4
,-1,UINT
,0xffffffff,I4
,0);
3871 VARXOR(I4
,-1,UINT
,0,I4
,-1);
3872 VARXOR(I4
,0,UINT
,0,I4
,0);
3873 rbstr
= SysAllocString(szFalse
);
3874 VARXOR(I4
,0,BSTR
,rbstr
,I4
,0);
3875 VARXOR(I4
,-1,BSTR
,rbstr
,I4
,-1);
3876 SysFreeString(rbstr
);
3877 rbstr
= SysAllocString(szTrue
);
3878 VARXOR(I4
,0,BSTR
,rbstr
,I4
,-1);
3879 VARXOR(I4
,-1,BSTR
,rbstr
,I4
,0);
3880 SysFreeString(rbstr
);
3881 VARXORCY(I4
,-1,10000,I4
,-2);
3882 VARXORCY(I4
,-1,0,I4
,-1);
3883 VARXORCY(I4
,0,0,I4
,0);
3885 VARXOR(UI4
,0xffffffff,UI4
,0xffffffff,I4
,0);
3886 VARXOR(UI4
,0xffffffff,UI4
,0,I4
,-1);
3887 VARXOR(UI4
,0,UI4
,0,I4
,0);
3888 VARXOR(UI4
,0xffffffff,R4
,-1,I4
,0);
3889 VARXOR(UI4
,0xffffffff,R4
,0,I4
,-1);
3890 VARXOR(UI4
,0,R4
,0,I4
,0);
3891 VARXOR(UI4
,0xffffffff,R8
,-1,I4
,0);
3892 VARXOR(UI4
,0xffffffff,R8
,0,I4
,-1);
3893 VARXOR(UI4
,0,R8
,0,I4
,0);
3894 VARXOR(UI4
,0xffffffff,DATE
,-1,I4
,0);
3895 VARXOR(UI4
,0xffffffff,DATE
,0,I4
,-1);
3896 VARXOR(UI4
,0,DATE
,0,I4
,0);
3899 VARXOR(UI4
,0xffffffff,I8
,0,I8
,0xffffffff);
3900 VARXOR(UI4
,VARIANT_FALSE
,I8
,VARIANT_FALSE
,I8
,0);
3901 VARXOR(UI4
,0,I8
,0,I8
,0);
3902 VARXOR(UI4
,0xffffffff,UI8
,0,I4
,-1);
3903 VARXOR(UI4
,0,UI8
,0,I4
,0);
3905 VARXOR(UI4
,0xffffffff,INT
,-1,I4
,0);
3906 VARXOR(UI4
,0xffffffff,INT
,0,I4
,-1);
3907 VARXOR(UI4
,0,INT
,0,I4
,0);
3908 VARXOR(UI4
,0xffffffff,UINT
,0xffffffff,I4
,0);
3909 VARXOR(UI4
,0xffffffff,UINT
,0,I4
,-1);
3910 VARXOR(UI4
,0,UINT
,0,I4
,0);
3911 rbstr
= SysAllocString(szFalse
);
3912 VARXOR(UI4
,0,BSTR
,rbstr
,I4
,0);
3913 VARXOR(UI4
,0xffffffff,BSTR
,rbstr
,I4
,-1);
3914 SysFreeString(rbstr
);
3915 rbstr
= SysAllocString(szTrue
);
3916 VARXOR(UI4
,0,BSTR
,rbstr
,I4
,-1);
3917 VARXOR(UI4
,0xffffffff,BSTR
,rbstr
,I4
,0);
3918 SysFreeString(rbstr
);
3919 VARXORCY(UI4
,0xffffffff,10000,I4
,-2);
3920 VARXORCY(UI4
,0xffffffff,0,I4
,-1);
3921 VARXORCY(UI4
,0,0,I4
,0);
3923 VARXOR(R4
,-1,R4
,-1,I4
,0);
3924 VARXOR(R4
,-1,R4
,0,I4
,-1);
3925 VARXOR(R4
,0,R4
,0,I4
,0);
3926 VARXOR(R4
,-1,R8
,-1,I4
,0);
3927 VARXOR(R4
,-1,R8
,0,I4
,-1);
3928 VARXOR(R4
,0,R8
,0,I4
,0);
3929 VARXOR(R4
,-1,DATE
,-1,I4
,0);
3930 VARXOR(R4
,-1,DATE
,0,I4
,-1);
3931 VARXOR(R4
,0,DATE
,0,I4
,0);
3934 VARXOR(R4
,-1,I8
,-1,I8
,0);
3935 VARXOR(R4
,-1,I8
,0,I8
,-1);
3936 VARXOR(R4
,0,I8
,0,I8
,0);
3937 VARXOR(R4
,-1,UI8
,0,I4
,-1);
3938 VARXOR(R4
,0,UI8
,0,I4
,0);
3940 VARXOR(R4
,-1,INT
,-1,I4
,0);
3941 VARXOR(R4
,-1,INT
,0,I4
,-1);
3942 VARXOR(R4
,0,INT
,0,I4
,0);
3943 VARXOR(R4
,-1,UINT
,0xffffffff,I4
,0);
3944 VARXOR(R4
,-1,UINT
,0,I4
,-1);
3945 VARXOR(R4
,0,UINT
,0,I4
,0);
3946 rbstr
= SysAllocString(szFalse
);
3947 VARXOR(R4
,0,BSTR
,rbstr
,I4
,0);
3948 VARXOR(R4
,-1,BSTR
,rbstr
,I4
,-1);
3949 SysFreeString(rbstr
);
3950 rbstr
= SysAllocString(szTrue
);
3951 VARXOR(R4
,0,BSTR
,rbstr
,I4
,-1);
3952 VARXOR(R4
,-1,BSTR
,rbstr
,I4
,0);
3953 SysFreeString(rbstr
);
3954 VARXORCY(R4
,-1,10000,I4
,-2);
3955 VARXORCY(R4
,-1,0,I4
,-1);
3956 VARXORCY(R4
,0,0,I4
,0);
3958 VARXOR(R8
,-1,R8
,-1,I4
,0);
3959 VARXOR(R8
,-1,R8
,0,I4
,-1);
3960 VARXOR(R8
,0,R8
,0,I4
,0);
3961 VARXOR(R8
,-1,DATE
,-1,I4
,0);
3962 VARXOR(R8
,-1,DATE
,0,I4
,-1);
3963 VARXOR(R8
,0,DATE
,0,I4
,0);
3966 VARXOR(R8
,-1,I8
,-1,I8
,0);
3967 VARXOR(R8
,-1,I8
,0,I8
,-1);
3968 VARXOR(R8
,0,I8
,0,I8
,0);
3969 VARXOR(R8
,-1,UI8
,0,I4
,-1);
3970 VARXOR(R8
,0,UI8
,0,I4
,0);
3972 VARXOR(R8
,-1,INT
,-1,I4
,0);
3973 VARXOR(R8
,-1,INT
,0,I4
,-1);
3974 VARXOR(R8
,0,INT
,0,I4
,0);
3975 VARXOR(R8
,-1,UINT
,0xffffffff,I4
,0);
3976 VARXOR(R8
,-1,UINT
,0,I4
,-1);
3977 VARXOR(R8
,0,UINT
,0,I4
,0);
3978 rbstr
= SysAllocString(szFalse
);
3979 VARXOR(R8
,0,BSTR
,rbstr
,I4
,0);
3980 VARXOR(R8
,-1,BSTR
,rbstr
,I4
,-1);
3981 SysFreeString(rbstr
);
3982 rbstr
= SysAllocString(szTrue
);
3983 VARXOR(R8
,0,BSTR
,rbstr
,I4
,-1);
3984 VARXOR(R8
,-1,BSTR
,rbstr
,I4
,0);
3985 SysFreeString(rbstr
);
3986 VARXORCY(R8
,-1,10000,I4
,-2);
3987 VARXORCY(R8
,-1,0,I4
,-1);
3988 VARXORCY(R8
,0,0,I4
,0);
3990 VARXOR(DATE
,-1,DATE
,-1,I4
,0);
3991 VARXOR(DATE
,-1,DATE
,0,I4
,-1);
3992 VARXOR(DATE
,0,DATE
,0,I4
,0);
3995 VARXOR(DATE
,-1,I8
,-1,I8
,0);
3996 VARXOR(DATE
,-1,I8
,0,I8
,-1);
3997 VARXOR(DATE
,0,I8
,0,I8
,0);
3998 VARXOR(DATE
,-1,UI8
,0,I4
,-1);
3999 VARXOR(DATE
,0,UI8
,0,I4
,0);
4001 VARXOR(DATE
,-1,INT
,-1,I4
,0);
4002 VARXOR(DATE
,-1,INT
,0,I4
,-1);
4003 VARXOR(DATE
,0,INT
,0,I4
,0);
4004 VARXOR(DATE
,-1,UINT
,0xffffffff,I4
,0);
4005 VARXOR(DATE
,-1,UINT
,0,I4
,-1);
4006 VARXOR(DATE
,0,UINT
,0,I4
,0);
4007 rbstr
= SysAllocString(szFalse
);
4008 VARXOR(DATE
,0,BSTR
,rbstr
,I4
,0);
4009 VARXOR(DATE
,-1,BSTR
,rbstr
,I4
,-1);
4010 SysFreeString(rbstr
);
4011 rbstr
= SysAllocString(szTrue
);
4012 VARXOR(DATE
,0,BSTR
,rbstr
,I4
,-1);
4013 VARXOR(DATE
,-1,BSTR
,rbstr
,I4
,0);
4014 SysFreeString(rbstr
);
4015 VARXORCY(DATE
,-1,10000,I4
,-2);
4016 VARXORCY(DATE
,-1,0,I4
,-1);
4017 VARXORCY(DATE
,0,0,I4
,0);
4021 VARXOR(I8
,-1,I8
,-1,I8
,0);
4022 VARXOR(I8
,-1,I8
,0,I8
,-1);
4023 VARXOR(I8
,0,I8
,0,I8
,0);
4024 VARXOR(I8
,-1,UI8
,0,I8
,-1);
4025 VARXOR(I8
,0,UI8
,0,I8
,0);
4026 VARXOR(I8
,-1,UINT
,0,I8
,-1);
4027 VARXOR(I8
,0,UINT
,0,I8
,0);
4028 rbstr
= SysAllocString(szFalse
);
4029 VARXOR(I8
,0,BSTR
,rbstr
,I8
,0);
4030 VARXOR(I8
,-1,BSTR
,rbstr
,I8
,-1);
4031 SysFreeString(rbstr
);
4032 rbstr
= SysAllocString(szTrue
);
4033 VARXOR(I8
,0,BSTR
,rbstr
,I8
,-1);
4034 VARXOR(I8
,-1,BSTR
,rbstr
,I8
,0);
4035 SysFreeString(rbstr
);
4036 VARXORCY(I8
,-1,10000,I8
,-2);
4037 VARXORCY(I8
,-1,0,I8
,-1);
4038 VARXORCY(I8
,0,0,I8
,0);
4040 VARXOR(UI8
,0xffff,UI8
,0xffff,I4
,0);
4041 VARXOR(UI8
,0xffff,UI8
,0,I4
,0xffff);
4042 VARXOR(UI8
,0,UI8
,0,I4
,0);
4043 VARXOR(UI8
,0xffff,INT
,-1,I4
,-65536);
4044 VARXOR(UI8
,0xffff,INT
,0,I4
,0xffff);
4045 VARXOR(UI8
,0,INT
,0,I4
,0);
4046 VARXOR(UI8
,0xffff,UINT
,0xffff,I4
,0);
4047 VARXOR(UI8
,0xffff,UINT
,0,I4
,0xffff);
4048 VARXOR(UI8
,0,UINT
,0,I4
,0);
4049 rbstr
= SysAllocString(szFalse
);
4050 VARXOR(UI8
,0,BSTR
,rbstr
,I4
,0);
4051 VARXOR(UI8
,0xffff,BSTR
,rbstr
,I4
,0xffff);
4052 SysFreeString(rbstr
);
4053 rbstr
= SysAllocString(szTrue
);
4054 VARXOR(UI8
,0,BSTR
,rbstr
,I4
,-1);
4055 VARXOR(UI8
,0xffff,BSTR
,rbstr
,I4
,-65536);
4056 SysFreeString(rbstr
);
4057 VARXORCY(UI8
,0xffff,10000,I4
,65534);
4058 VARXORCY(UI8
,0xffff,0,I4
,0xffff);
4059 VARXORCY(UI8
,0,0,I4
,0);
4062 VARXOR(INT
,-1,INT
,-1,I4
,0);
4063 VARXOR(INT
,-1,INT
,0,I4
,-1);
4064 VARXOR(INT
,0,INT
,0,I4
,0);
4065 VARXOR(INT
,-1,UINT
,0xffff,I4
,-65536);
4066 VARXOR(INT
,-1,UINT
,0,I4
,-1);
4067 VARXOR(INT
,0,UINT
,0,I4
,0);
4068 rbstr
= SysAllocString(szFalse
);
4069 VARXOR(INT
,0,BSTR
,rbstr
,I4
,0);
4070 VARXOR(INT
,-1,BSTR
,rbstr
,I4
,-1);
4071 SysFreeString(rbstr
);
4072 rbstr
= SysAllocString(szTrue
);
4073 VARXOR(INT
,0,BSTR
,rbstr
,I4
,-1);
4074 VARXOR(INT
,-1,BSTR
,rbstr
,I4
,0);
4075 SysFreeString(rbstr
);
4076 VARXORCY(INT
,-1,10000,I4
,-2);
4077 VARXORCY(INT
,-1,0,I4
,-1);
4078 VARXORCY(INT
,0,0,I4
,0);
4080 VARXOR(UINT
,0xffff,UINT
,0xffff,I4
,0);
4081 VARXOR(UINT
,0xffff,UINT
,0,I4
,0xffff);
4082 VARXOR(UINT
,0,UINT
,0,I4
,0);
4083 rbstr
= SysAllocString(szFalse
);
4084 VARXOR(UINT
,0,BSTR
,rbstr
,I4
,0);
4085 VARXOR(UINT
,0xffff,BSTR
,rbstr
,I4
,0xffff);
4086 SysFreeString(rbstr
);
4087 rbstr
= SysAllocString(szTrue
);
4088 VARXOR(UINT
,0,BSTR
,rbstr
,I4
,-1);
4089 VARXOR(UINT
,0xffff,BSTR
,rbstr
,I4
,-65536);
4090 SysFreeString(rbstr
);
4091 VARXORCY(UINT
,0xffff,10000,I4
,65534);
4092 VARXORCY(UINT
,0xffff,0,I4
,0xffff);
4093 VARXORCY(UINT
,0,0,I4
,0);
4095 lbstr
= SysAllocString(szFalse
);
4096 rbstr
= SysAllocString(szFalse
);
4097 VARXOR(BSTR
,lbstr
,BSTR
,rbstr
,BOOL
,0);
4098 SysFreeString(rbstr
);
4099 rbstr
= SysAllocString(szTrue
);
4100 VARXOR(BSTR
,lbstr
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
4101 SysFreeString(lbstr
);
4102 lbstr
= SysAllocString(szTrue
);
4103 VARXOR(BSTR
,lbstr
,BSTR
,rbstr
,BOOL
,VARIANT_FALSE
);
4104 VARXORCY(BSTR
,lbstr
,10000,I4
,-2);
4105 SysFreeString(lbstr
);
4106 lbstr
= SysAllocString(szFalse
);
4107 VARXORCY(BSTR
,lbstr
,10000,I4
,1);
4108 SysFreeString(lbstr
);
4109 SysFreeString(rbstr
);
4112 static HRESULT (WINAPI
*pVarOr
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
4114 #define VAROR(vt1,val1,vt2,val2,rvt,rval) \
4115 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
4116 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
4117 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
4118 test_var_call2( __LINE__, pVarOr, &left, &right, &exp )
4120 #define VARORCY(vt1,val1,val2,rvt,rval) \
4121 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
4122 V_VT(&right) = VT_CY; V_CY(&right).int64 = val2; \
4123 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
4124 test_var_call2( __LINE__, pVarOr, &left, &right, &exp )
4126 static void test_VarOr(void)
4128 static const WCHAR szFalse
[] = { '#','F','A','L','S','E','#','\0' };
4129 static const WCHAR szTrue
[] = { '#','T','R','U','E','#','\0' };
4130 VARIANT left
, right
, exp
, result
;
4137 /* Test all possible flag/vt combinations & the resulting vt type */
4138 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
4140 VARTYPE leftvt
, rightvt
, resvt
;
4142 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
4147 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
4153 if (leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
||
4154 leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
||
4155 leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
)
4158 memset(&left
, 0, sizeof(left
));
4159 memset(&right
, 0, sizeof(right
));
4160 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
4161 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
4162 V_VT(&result
) = VT_EMPTY
;
4165 if (ExtraFlags
[i
] & VT_ARRAY
|| ExtraFlags
[i
] & VT_BYREF
||
4166 !IsValidVariantClearVT(leftvt
, ExtraFlags
[i
]) ||
4167 !IsValidVariantClearVT(rightvt
, ExtraFlags
[i
]) ||
4168 leftvt
== VT_CLSID
|| rightvt
== VT_CLSID
||
4169 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
||
4170 leftvt
== VT_VARIANT
|| rightvt
== VT_VARIANT
||
4171 leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
)
4175 if (leftvt
== VT_EMPTY
|| rightvt
== VT_EMPTY
)
4177 if (leftvt
== rightvt
||
4178 leftvt
== VT_I2
|| rightvt
== VT_I2
||
4179 leftvt
== VT_UI1
|| rightvt
== VT_UI1
||
4180 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
4182 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
4184 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
4187 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
4191 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
4193 if (leftvt
== rightvt
)
4195 else if (leftvt
== rightvt
||
4196 leftvt
== VT_I2
|| rightvt
== VT_I2
||
4197 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
4201 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
4204 else if (leftvt
== VT_I2
|| rightvt
== VT_I2
)
4206 if (leftvt
== rightvt
||
4207 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
4209 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
4212 else if (leftvt
== VT_BOOL
&& rightvt
== VT_BOOL
)
4216 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
4218 if (leftvt
== VT_INT
|| rightvt
== VT_INT
)
4223 hres
= pVarOr(&left
, &right
, &result
);
4225 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
4226 "VarOr: %d|0x%X, %d|0x%X: Expected failure, got 0x%X vt %d\n",
4227 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], hres
,
4230 ok(hres
== S_OK
&& V_VT(&result
) == resvt
,
4231 "VarOr: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%X vt %d\n",
4232 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], resvt
, hres
,
4238 /* Test returned values. Since we know the returned type is correct
4239 * and that we handle all combinations of invalid types, just check
4240 * that good type combinations produce the desired value.
4241 * FIXME: Test VT_DECIMAL/VT_DISPATCH
4243 VAROR(EMPTY
,0,EMPTY
,0,I2
,0);
4244 VAROR(EMPTY
,1,EMPTY
,0,I2
,0);
4245 VAROR(EMPTY
,0,NULL
,0,NULL
,0);
4246 VAROR(EMPTY
,0,I1
,0,I4
,0);
4247 VAROR(EMPTY
,0,I1
,1,I4
,1);
4248 VAROR(EMPTY
,0,UI1
,0,I2
,0);
4249 VAROR(EMPTY
,0,UI1
,1,I2
,1);
4250 VAROR(EMPTY
,0,I2
,0,I2
,0);
4251 VAROR(EMPTY
,0,I2
,1,I2
,1);
4252 VAROR(EMPTY
,0,UI2
,0,I4
,0);
4253 VAROR(EMPTY
,0,UI2
,1,I4
,1);
4254 VAROR(EMPTY
,0,I4
,0,I4
,0);
4255 VAROR(EMPTY
,0,I4
,1,I4
,1);
4256 VAROR(EMPTY
,0,UI4
,0,I4
,0);
4257 VAROR(EMPTY
,0,UI4
,1,I4
,1);
4260 VAROR(EMPTY
,0,I8
,0,I8
,0);
4261 VAROR(EMPTY
,0,I8
,1,I8
,1);
4262 VAROR(EMPTY
,0,UI8
,0,I4
,0);
4263 VAROR(EMPTY
,0,UI8
,1,I4
,1);
4265 VAROR(EMPTY
,0,INT
,0,I4
,0);
4266 VAROR(EMPTY
,0,INT
,1,I4
,1);
4267 VAROR(EMPTY
,0,UINT
,0,I4
,0);
4268 VAROR(EMPTY
,0,UINT
,1,I4
,1);
4269 VAROR(EMPTY
,0,BOOL
,0,I2
,0);
4270 VAROR(EMPTY
,0,BOOL
,1,I2
,1);
4271 VAROR(EMPTY
,0,R4
,0,I4
,0);
4272 VAROR(EMPTY
,0,R4
,1,I4
,1);
4273 VAROR(EMPTY
,0,R8
,0,I4
,0);
4274 VAROR(EMPTY
,0,R8
,1,I4
,1);
4275 rbstr
= SysAllocString(szFalse
);
4276 VAROR(EMPTY
,0,BSTR
,rbstr
,I2
,0);
4277 SysFreeString(rbstr
);
4278 rbstr
= SysAllocString(szTrue
);
4279 VAROR(EMPTY
,0,BSTR
,rbstr
,I2
,-1);
4280 SysFreeString(rbstr
);
4281 VARORCY(EMPTY
,0,10000,I4
,1);
4283 /* NULL OR 0 = NULL. NULL OR n = n */
4284 VAROR(NULL
,0,NULL
,0,NULL
,0);
4285 VAROR(NULL
,1,NULL
,0,NULL
,0);
4286 VAROR(NULL
,0,I1
,0,NULL
,0);
4287 VAROR(NULL
,0,I1
,1,I4
,1);
4288 VAROR(NULL
,0,UI1
,0,NULL
,0);
4289 VAROR(NULL
,0,UI1
,1,UI1
,1);
4290 VAROR(NULL
,0,I2
,0,NULL
,0);
4291 VAROR(NULL
,0,I2
,1,I2
,1);
4292 VAROR(NULL
,0,UI2
,0,NULL
,0);
4293 VAROR(NULL
,0,UI2
,1,I4
,1);
4294 VAROR(NULL
,0,I4
,0,NULL
,0);
4295 VAROR(NULL
,0,I4
,1,I4
,1);
4296 VAROR(NULL
,0,UI4
,0,NULL
,0);
4297 VAROR(NULL
,0,UI4
,1,I4
,1);
4300 VAROR(NULL
,0,I8
,0,NULL
,0);
4301 VAROR(NULL
,0,I8
,1,I8
,1);
4302 VAROR(NULL
,0,UI8
,0,NULL
,0);
4303 VAROR(NULL
,0,UI8
,1,I4
,1);
4305 VAROR(NULL
,0,INT
,0,NULL
,0);
4306 VAROR(NULL
,0,INT
,1,I4
,1);
4307 VAROR(NULL
,0,UINT
,0,NULL
,0);
4308 VAROR(NULL
,0,UINT
,1,I4
,1);
4309 VAROR(NULL
,0,BOOL
,0,NULL
,0);
4310 VAROR(NULL
,0,BOOL
,1,BOOL
,1);
4311 VAROR(NULL
,0,R4
,0,NULL
,0);
4312 VAROR(NULL
,0,R4
,1,I4
,1);
4313 VAROR(NULL
,0,R8
,0,NULL
,0);
4314 VAROR(NULL
,0,R8
,1,I4
,1);
4315 rbstr
= SysAllocString(szFalse
);
4316 VAROR(NULL
,0,BSTR
,rbstr
,NULL
,0);
4317 SysFreeString(rbstr
);
4318 rbstr
= SysAllocString(szTrue
);
4319 VAROR(NULL
,0,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
4320 SysFreeString(rbstr
);
4321 VARORCY(NULL
,0,10000,I4
,1);
4322 VARORCY(NULL
,0,0,NULL
,0);
4324 VAROR(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
);
4325 VAROR(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
);
4326 VAROR(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
);
4327 VAROR(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_FALSE
);
4328 /* Assume x,y & y,x are the same from now on to reduce the number of tests */
4329 VAROR(BOOL
,VARIANT_TRUE
,I1
,-1,I4
,-1);
4330 VAROR(BOOL
,VARIANT_TRUE
,I1
,0,I4
,-1);
4331 VAROR(BOOL
,VARIANT_FALSE
,I1
,0,I4
,0);
4332 VAROR(BOOL
,VARIANT_TRUE
,UI1
,255,I2
,-1);
4333 VAROR(BOOL
,VARIANT_TRUE
,UI1
,0,I2
,-1);
4334 VAROR(BOOL
,VARIANT_FALSE
,UI1
,0,I2
,0);
4335 VAROR(BOOL
,VARIANT_TRUE
,I2
,-1,I2
,-1);
4336 VAROR(BOOL
,VARIANT_TRUE
,I2
,0,I2
,-1);
4337 VAROR(BOOL
,VARIANT_FALSE
,I2
,0,I2
,0);
4338 VAROR(BOOL
,VARIANT_TRUE
,UI2
,65535,I4
,-1);
4339 VAROR(BOOL
,VARIANT_TRUE
,UI2
,0,I4
,-1);
4340 VAROR(BOOL
,VARIANT_FALSE
,UI2
,0,I4
,0);
4341 VAROR(BOOL
,VARIANT_TRUE
,I4
,-1,I4
,-1);
4342 VAROR(BOOL
,VARIANT_TRUE
,I4
,0,I4
,-1);
4343 VAROR(BOOL
,VARIANT_FALSE
,I4
,0,I4
,0);
4344 VAROR(BOOL
,VARIANT_TRUE
,UI4
,0xffffffff,I4
,-1);
4345 VAROR(BOOL
,VARIANT_TRUE
,UI4
,0,I4
,-1);
4346 VAROR(BOOL
,VARIANT_FALSE
,UI4
,0,I4
,0);
4347 VAROR(BOOL
,VARIANT_TRUE
,R4
,-1,I4
,-1);
4348 VAROR(BOOL
,VARIANT_TRUE
,R4
,0,I4
,-1);
4349 VAROR(BOOL
,VARIANT_FALSE
,R4
,0,I4
,0);
4350 VAROR(BOOL
,VARIANT_TRUE
,R8
,-1,I4
,-1);
4351 VAROR(BOOL
,VARIANT_TRUE
,R8
,0,I4
,-1);
4352 VAROR(BOOL
,VARIANT_FALSE
,R8
,0,I4
,0);
4353 VAROR(BOOL
,VARIANT_TRUE
,DATE
,-1,I4
,-1);
4354 VAROR(BOOL
,VARIANT_TRUE
,DATE
,0,I4
,-1);
4355 VAROR(BOOL
,VARIANT_FALSE
,DATE
,0,I4
,0);
4358 VAROR(BOOL
,VARIANT_TRUE
,I8
,-1,I8
,-1);
4359 VAROR(BOOL
,VARIANT_TRUE
,I8
,0,I8
,-1);
4360 VAROR(BOOL
,VARIANT_FALSE
,I8
,0,I8
,0);
4361 /* This returns DISP_E_OVERFLOW which indicates that a conversion
4362 * to I4 is performed.
4364 /* VAROR(BOOL,VARIANT_TRUE,UI8,-1,I4,-1); */
4365 VAROR(BOOL
,VARIANT_TRUE
,UI8
,0,I4
,-1);
4366 VAROR(BOOL
,VARIANT_FALSE
,UI8
,0,I4
,0);
4368 VAROR(BOOL
,VARIANT_TRUE
,INT
,-1,I4
,-1);
4369 VAROR(BOOL
,VARIANT_TRUE
,INT
,0,I4
,-1);
4370 VAROR(BOOL
,VARIANT_FALSE
,INT
,0,I4
,0);
4371 VAROR(BOOL
,VARIANT_TRUE
,UINT
,0xffffffff,I4
,-1);
4372 VAROR(BOOL
,VARIANT_TRUE
,UINT
,0,I4
,-1);
4373 VAROR(BOOL
,VARIANT_FALSE
,UINT
,0,I4
,0);
4374 rbstr
= SysAllocString(szFalse
);
4375 VAROR(BOOL
,VARIANT_FALSE
,BSTR
,rbstr
,BOOL
,VARIANT_FALSE
);
4376 VAROR(BOOL
,VARIANT_TRUE
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
4377 SysFreeString(rbstr
);
4378 rbstr
= SysAllocString(szTrue
);
4379 VAROR(BOOL
,VARIANT_FALSE
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
4380 VAROR(BOOL
,VARIANT_TRUE
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
4381 SysFreeString(rbstr
);
4382 VARORCY(BOOL
,VARIANT_TRUE
,10000,I4
,-1);
4383 VARORCY(BOOL
,VARIANT_TRUE
,0,I4
,-1);
4384 VARORCY(BOOL
,VARIANT_FALSE
,0,I4
,0);
4386 VAROR(I1
,-1,I1
,-1,I4
,-1);
4387 VAROR(I1
,-1,I1
,0,I4
,-1);
4388 VAROR(I1
,0,I1
,0,I4
,0);
4389 VAROR(I1
,-1,UI1
,255,I4
,-1);
4390 VAROR(I1
,-1,UI1
,0,I4
,-1);
4391 VAROR(I1
,0,UI1
,0,I4
,0);
4392 VAROR(I1
,-1,I2
,-1,I4
,-1);
4393 VAROR(I1
,-1,I2
,0,I4
,-1);
4394 VAROR(I1
,0,I2
,0,I4
,0);
4395 VAROR(I1
,-1,UI2
,65535,I4
,-1);
4396 VAROR(I1
,-1,UI2
,0,I4
,-1);
4397 VAROR(I1
,0,UI2
,0,I4
,0);
4398 VAROR(I1
,-1,I4
,-1,I4
,-1);
4399 VAROR(I1
,-1,I4
,0,I4
,-1);
4400 VAROR(I1
,0,I4
,0,I4
,0);
4401 VAROR(I1
,-1,UI4
,0xffffffff,I4
,-1);
4402 VAROR(I1
,-1,UI4
,0,I4
,-1);
4403 VAROR(I1
,0,UI4
,0,I4
,0);
4404 VAROR(I1
,-1,R4
,-1,I4
,-1);
4405 VAROR(I1
,-1,R4
,0,I4
,-1);
4406 VAROR(I1
,0,R4
,0,I4
,0);
4407 VAROR(I1
,-1,R8
,-1,I4
,-1);
4408 VAROR(I1
,-1,R8
,0,I4
,-1);
4409 VAROR(I1
,0,R8
,0,I4
,0);
4410 VAROR(I1
,-1,DATE
,-1,I4
,-1);
4411 VAROR(I1
,-1,DATE
,0,I4
,-1);
4412 VAROR(I1
,0,DATE
,0,I4
,0);
4415 VAROR(I1
,-1,I8
,-1,I8
,-1);
4416 VAROR(I1
,-1,I8
,0,I8
,-1);
4417 VAROR(I1
,0,I8
,0,I8
,0);
4418 VAROR(I1
,-1,UI8
,0,I4
,-1);
4419 VAROR(I1
,0,UI8
,0,I4
,0);
4421 VAROR(I1
,-1,INT
,-1,I4
,-1);
4422 VAROR(I1
,-1,INT
,0,I4
,-1);
4423 VAROR(I1
,0,INT
,0,I4
,0);
4424 VAROR(I1
,-1,UINT
,0xffffffff,I4
,-1);
4425 VAROR(I1
,-1,UINT
,0,I4
,-1);
4426 VAROR(I1
,0,UINT
,0,I4
,0);
4427 rbstr
= SysAllocString(szFalse
);
4428 VAROR(I1
,0,BSTR
,rbstr
,I4
,0);
4429 VAROR(I1
,-1,BSTR
,rbstr
,I4
,-1);
4430 SysFreeString(rbstr
);
4431 rbstr
= SysAllocString(szTrue
);
4432 VAROR(I1
,0,BSTR
,rbstr
,I4
,-1);
4433 VAROR(I1
,-1,BSTR
,rbstr
,I4
,-1);
4434 SysFreeString(rbstr
);
4435 VARORCY(I1
,-1,10000,I4
,-1);
4436 VARORCY(I1
,-1,0,I4
,-1);
4437 VARORCY(I1
,0,0,I4
,0);
4439 VAROR(UI1
,255,UI1
,255,UI1
,255);
4440 VAROR(UI1
,255,UI1
,0,UI1
,255);
4441 VAROR(UI1
,0,UI1
,0,UI1
,0);
4442 VAROR(UI1
,255,I2
,-1,I2
,-1);
4443 VAROR(UI1
,255,I2
,0,I2
,255);
4444 VAROR(UI1
,0,I2
,0,I2
,0);
4445 VAROR(UI1
,255,UI2
,65535,I4
,65535);
4446 VAROR(UI1
,255,UI2
,0,I4
,255);
4447 VAROR(UI1
,0,UI2
,0,I4
,0);
4448 VAROR(UI1
,255,I4
,-1,I4
,-1);
4449 VAROR(UI1
,255,I4
,0,I4
,255);
4450 VAROR(UI1
,0,I4
,0,I4
,0);
4451 VAROR(UI1
,255,UI4
,0xffffffff,I4
,-1);
4452 VAROR(UI1
,255,UI4
,0,I4
,255);
4453 VAROR(UI1
,0,UI4
,0,I4
,0);
4454 VAROR(UI1
,255,R4
,-1,I4
,-1);
4455 VAROR(UI1
,255,R4
,0,I4
,255);
4456 VAROR(UI1
,0,R4
,0,I4
,0);
4457 VAROR(UI1
,255,R8
,-1,I4
,-1);
4458 VAROR(UI1
,255,R8
,0,I4
,255);
4459 VAROR(UI1
,0,R8
,0,I4
,0);
4460 VAROR(UI1
,255,DATE
,-1,I4
,-1);
4461 VAROR(UI1
,255,DATE
,0,I4
,255);
4462 VAROR(UI1
,0,DATE
,0,I4
,0);
4465 VAROR(UI1
,255,I8
,-1,I8
,-1);
4466 VAROR(UI1
,255,I8
,0,I8
,255);
4467 VAROR(UI1
,0,I8
,0,I8
,0);
4468 VAROR(UI1
,255,UI8
,0,I4
,255);
4469 VAROR(UI1
,0,UI8
,0,I4
,0);
4471 VAROR(UI1
,255,INT
,-1,I4
,-1);
4472 VAROR(UI1
,255,INT
,0,I4
,255);
4473 VAROR(UI1
,0,INT
,0,I4
,0);
4474 VAROR(UI1
,255,UINT
,0xffffffff,I4
,-1);
4475 VAROR(UI1
,255,UINT
,0,I4
,255);
4476 VAROR(UI1
,0,UINT
,0,I4
,0);
4477 rbstr
= SysAllocString(szFalse
);
4478 VAROR(UI1
,0,BSTR
,rbstr
,I2
,0);
4479 VAROR(UI1
,255,BSTR
,rbstr
,I2
,255);
4480 SysFreeString(rbstr
);
4481 rbstr
= SysAllocString(szTrue
);
4482 VAROR(UI1
,0,BSTR
,rbstr
,I2
,-1);
4483 VAROR(UI1
,255,BSTR
,rbstr
,I2
,-1);
4484 SysFreeString(rbstr
);
4485 VARORCY(UI1
,255,10000,I4
,255);
4486 VARORCY(UI1
,255,0,I4
,255);
4487 VARORCY(UI1
,0,0,I4
,0);
4489 VAROR(I2
,-1,I2
,-1,I2
,-1);
4490 VAROR(I2
,-1,I2
,0,I2
,-1);
4491 VAROR(I2
,0,I2
,0,I2
,0);
4492 VAROR(I2
,-1,UI2
,65535,I4
,-1);
4493 VAROR(I2
,-1,UI2
,0,I4
,-1);
4494 VAROR(I2
,0,UI2
,0,I4
,0);
4495 VAROR(I2
,-1,I4
,-1,I4
,-1);
4496 VAROR(I2
,-1,I4
,0,I4
,-1);
4497 VAROR(I2
,0,I4
,0,I4
,0);
4498 VAROR(I2
,-1,UI4
,0xffffffff,I4
,-1);
4499 VAROR(I2
,-1,UI4
,0,I4
,-1);
4500 VAROR(I2
,0,UI4
,0,I4
,0);
4501 VAROR(I2
,-1,R4
,-1,I4
,-1);
4502 VAROR(I2
,-1,R4
,0,I4
,-1);
4503 VAROR(I2
,0,R4
,0,I4
,0);
4504 VAROR(I2
,-1,R8
,-1,I4
,-1);
4505 VAROR(I2
,-1,R8
,0,I4
,-1);
4506 VAROR(I2
,0,R8
,0,I4
,0);
4507 VAROR(I2
,-1,DATE
,-1,I4
,-1);
4508 VAROR(I2
,-1,DATE
,0,I4
,-1);
4509 VAROR(I2
,0,DATE
,0,I4
,0);
4512 VAROR(I2
,-1,I8
,-1,I8
,-1);
4513 VAROR(I2
,-1,I8
,0,I8
,-1);
4514 VAROR(I2
,0,I8
,0,I8
,0);
4515 VAROR(I2
,-1,UI8
,0,I4
,-1);
4516 VAROR(I2
,0,UI8
,0,I4
,0);
4518 VAROR(I2
,-1,INT
,-1,I4
,-1);
4519 VAROR(I2
,-1,INT
,0,I4
,-1);
4520 VAROR(I2
,0,INT
,0,I4
,0);
4521 VAROR(I2
,-1,UINT
,0xffffffff,I4
,-1);
4522 VAROR(I2
,-1,UINT
,0,I4
,-1);
4523 VAROR(I2
,0,UINT
,0,I4
,0);
4524 rbstr
= SysAllocString(szFalse
);
4525 VAROR(I2
,0,BSTR
,rbstr
,I2
,0);
4526 VAROR(I2
,-1,BSTR
,rbstr
,I2
,-1);
4527 SysFreeString(rbstr
);
4528 rbstr
= SysAllocString(szTrue
);
4529 VAROR(I2
,0,BSTR
,rbstr
,I2
,-1);
4530 VAROR(I2
,-1,BSTR
,rbstr
,I2
,-1);
4531 SysFreeString(rbstr
);
4532 VARORCY(I2
,-1,10000,I4
,-1);
4533 VARORCY(I2
,-1,0,I4
,-1);
4534 VARORCY(I2
,0,0,I4
,0);
4536 VAROR(UI2
,65535,UI2
,65535,I4
,65535);
4537 VAROR(UI2
,65535,UI2
,0,I4
,65535);
4538 VAROR(UI2
,0,UI2
,0,I4
,0);
4539 VAROR(UI2
,65535,I4
,-1,I4
,-1);
4540 VAROR(UI2
,65535,I4
,0,I4
,65535);
4541 VAROR(UI2
,0,I4
,0,I4
,0);
4542 VAROR(UI2
,65535,UI4
,0xffffffff,I4
,-1);
4543 VAROR(UI2
,65535,UI4
,0,I4
,65535);
4544 VAROR(UI2
,0,UI4
,0,I4
,0);
4545 VAROR(UI2
,65535,R4
,-1,I4
,-1);
4546 VAROR(UI2
,65535,R4
,0,I4
,65535);
4547 VAROR(UI2
,0,R4
,0,I4
,0);
4548 VAROR(UI2
,65535,R8
,-1,I4
,-1);
4549 VAROR(UI2
,65535,R8
,0,I4
,65535);
4550 VAROR(UI2
,0,R8
,0,I4
,0);
4551 VAROR(UI2
,65535,DATE
,-1,I4
,-1);
4552 VAROR(UI2
,65535,DATE
,0,I4
,65535);
4553 VAROR(UI2
,0,DATE
,0,I4
,0);
4556 VAROR(UI2
,65535,I8
,-1,I8
,-1);
4557 VAROR(UI2
,65535,I8
,0,I8
,65535);
4558 VAROR(UI2
,0,I8
,0,I8
,0);
4559 VAROR(UI2
,65535,UI8
,0,I4
,65535);
4560 VAROR(UI2
,0,UI8
,0,I4
,0);
4562 VAROR(UI2
,65535,INT
,-1,I4
,-1);
4563 VAROR(UI2
,65535,INT
,0,I4
,65535);
4564 VAROR(UI2
,0,INT
,0,I4
,0);
4565 VAROR(UI2
,65535,UINT
,0xffffffff,I4
,-1);
4566 VAROR(UI2
,65535,UINT
,0,I4
,65535);
4567 VAROR(UI2
,0,UINT
,0,I4
,0);
4568 rbstr
= SysAllocString(szFalse
);
4569 VAROR(UI2
,0,BSTR
,rbstr
,I4
,0);
4570 VAROR(UI2
,65535,BSTR
,rbstr
,I4
,65535);
4571 SysFreeString(rbstr
);
4572 rbstr
= SysAllocString(szTrue
);
4573 VAROR(UI2
,0,BSTR
,rbstr
,I4
,-1);
4574 VAROR(UI2
,65535,BSTR
,rbstr
,I4
,-1);
4575 SysFreeString(rbstr
);
4576 VARORCY(UI2
,65535,10000,I4
,65535);
4577 VARORCY(UI2
,65535,0,I4
,65535);
4578 VARORCY(UI2
,0,0,I4
,0);
4580 VAROR(I4
,-1,I4
,-1,I4
,-1);
4581 VAROR(I4
,-1,I4
,0,I4
,-1);
4582 VAROR(I4
,0,I4
,0,I4
,0);
4583 VAROR(I4
,-1,UI4
,0xffffffff,I4
,-1);
4584 VAROR(I4
,-1,UI4
,0,I4
,-1);
4585 VAROR(I4
,0,UI4
,0,I4
,0);
4586 VAROR(I4
,-1,R4
,-1,I4
,-1);
4587 VAROR(I4
,-1,R4
,0,I4
,-1);
4588 VAROR(I4
,0,R4
,0,I4
,0);
4589 VAROR(I4
,-1,R8
,-1,I4
,-1);
4590 VAROR(I4
,-1,R8
,0,I4
,-1);
4591 VAROR(I4
,0,R8
,0,I4
,0);
4592 VAROR(I4
,-1,DATE
,-1,I4
,-1);
4593 VAROR(I4
,-1,DATE
,0,I4
,-1);
4594 VAROR(I4
,0,DATE
,0,I4
,0);
4597 VAROR(I4
,-1,I8
,-1,I8
,-1);
4598 VAROR(I4
,-1,I8
,0,I8
,-1);
4599 VAROR(I4
,0,I8
,0,I8
,0);
4600 VAROR(I4
,-1,UI8
,0,I4
,-1);
4601 VAROR(I4
,0,UI8
,0,I4
,0);
4603 VAROR(I4
,-1,INT
,-1,I4
,-1);
4604 VAROR(I4
,-1,INT
,0,I4
,-1);
4605 VAROR(I4
,0,INT
,0,I4
,0);
4606 VAROR(I4
,-1,UINT
,0xffffffff,I4
,-1);
4607 VAROR(I4
,-1,UINT
,0,I4
,-1);
4608 VAROR(I4
,0,UINT
,0,I4
,0);
4609 rbstr
= SysAllocString(szFalse
);
4610 VAROR(I4
,0,BSTR
,rbstr
,I4
,0);
4611 VAROR(I4
,-1,BSTR
,rbstr
,I4
,-1);
4612 SysFreeString(rbstr
);
4613 rbstr
= SysAllocString(szTrue
);
4614 VAROR(I4
,0,BSTR
,rbstr
,I4
,-1);
4615 VAROR(I4
,-1,BSTR
,rbstr
,I4
,-1);
4616 SysFreeString(rbstr
);
4617 VARORCY(I4
,-1,10000,I4
,-1);
4618 VARORCY(I4
,-1,0,I4
,-1);
4619 VARORCY(I4
,0,0,I4
,0);
4621 VAROR(UI4
,0xffffffff,UI4
,0xffffffff,I4
,-1);
4622 VAROR(UI4
,0xffffffff,UI4
,0,I4
,-1);
4623 VAROR(UI4
,0,UI4
,0,I4
,0);
4624 VAROR(UI4
,0xffffffff,R4
,-1,I4
,-1);
4625 VAROR(UI4
,0xffffffff,R4
,0,I4
,-1);
4626 VAROR(UI4
,0,R4
,0,I4
,0);
4627 VAROR(UI4
,0xffffffff,R8
,-1,I4
,-1);
4628 VAROR(UI4
,0xffffffff,R8
,0,I4
,-1);
4629 VAROR(UI4
,0,R8
,0,I4
,0);
4630 VAROR(UI4
,0xffffffff,DATE
,-1,I4
,-1);
4631 VAROR(UI4
,0xffffffff,DATE
,0,I4
,-1);
4632 VAROR(UI4
,0,DATE
,0,I4
,0);
4635 VAROR(UI4
,0xffffffff,I8
,-1,I8
,-1);
4636 VAROR(UI4
,0xffffffff,I8
,0,I8
,0xffffffff);
4637 VAROR(UI4
,0,I8
,0,I8
,0);
4638 VAROR(UI4
,0xffffffff,UI8
,0,I4
,-1);
4639 VAROR(UI4
,0,UI8
,0,I4
,0);
4641 VAROR(UI4
,0xffffffff,INT
,-1,I4
,-1);
4642 VAROR(UI4
,0xffffffff,INT
,0,I4
,-1);
4643 VAROR(UI4
,0,INT
,0,I4
,0);
4644 VAROR(UI4
,0xffffffff,UINT
,0xffffffff,I4
,-1);
4645 VAROR(UI4
,0xffffffff,UINT
,0,I4
,-1);
4646 VAROR(UI4
,0,UINT
,0,I4
,0);
4647 rbstr
= SysAllocString(szFalse
);
4648 VAROR(UI4
,0,BSTR
,rbstr
,I4
,0);
4649 VAROR(UI4
,0xffffffff,BSTR
,rbstr
,I4
,-1);
4650 SysFreeString(rbstr
);
4651 rbstr
= SysAllocString(szTrue
);
4652 VAROR(UI4
,0,BSTR
,rbstr
,I4
,-1);
4653 VAROR(UI4
,0xffffffff,BSTR
,rbstr
,I4
,-1);
4654 SysFreeString(rbstr
);
4655 VARORCY(UI4
,0xffffffff,10000,I4
,-1);
4656 VARORCY(UI4
,0xffffffff,0,I4
,-1);
4657 VARORCY(UI4
,0,0,I4
,0);
4659 VAROR(R4
,-1,R4
,-1,I4
,-1);
4660 VAROR(R4
,-1,R4
,0,I4
,-1);
4661 VAROR(R4
,0,R4
,0,I4
,0);
4662 VAROR(R4
,-1,R8
,-1,I4
,-1);
4663 VAROR(R4
,-1,R8
,0,I4
,-1);
4664 VAROR(R4
,0,R8
,0,I4
,0);
4665 VAROR(R4
,-1,DATE
,-1,I4
,-1);
4666 VAROR(R4
,-1,DATE
,0,I4
,-1);
4667 VAROR(R4
,0,DATE
,0,I4
,0);
4670 VAROR(R4
,-1,I8
,-1,I8
,-1);
4671 VAROR(R4
,-1,I8
,0,I8
,-1);
4672 VAROR(R4
,0,I8
,0,I8
,0);
4673 VAROR(R4
,-1,UI8
,0,I4
,-1);
4674 VAROR(R4
,0,UI8
,0,I4
,0);
4676 VAROR(R4
,-1,INT
,-1,I4
,-1);
4677 VAROR(R4
,-1,INT
,0,I4
,-1);
4678 VAROR(R4
,0,INT
,0,I4
,0);
4679 VAROR(R4
,-1,UINT
,0xffffffff,I4
,-1);
4680 VAROR(R4
,-1,UINT
,0,I4
,-1);
4681 VAROR(R4
,0,UINT
,0,I4
,0);
4682 rbstr
= SysAllocString(szFalse
);
4683 VAROR(R4
,0,BSTR
,rbstr
,I4
,0);
4684 VAROR(R4
,-1,BSTR
,rbstr
,I4
,-1);
4685 SysFreeString(rbstr
);
4686 rbstr
= SysAllocString(szTrue
);
4687 VAROR(R4
,0,BSTR
,rbstr
,I4
,-1);
4688 VAROR(R4
,-1,BSTR
,rbstr
,I4
,-1);
4689 SysFreeString(rbstr
);
4690 VARORCY(R4
,-1,10000,I4
,-1);
4691 VARORCY(R4
,-1,0,I4
,-1);
4692 VARORCY(R4
,0,0,I4
,0);
4694 VAROR(R8
,-1,R8
,-1,I4
,-1);
4695 VAROR(R8
,-1,R8
,0,I4
,-1);
4696 VAROR(R8
,0,R8
,0,I4
,0);
4697 VAROR(R8
,-1,DATE
,-1,I4
,-1);
4698 VAROR(R8
,-1,DATE
,0,I4
,-1);
4699 VAROR(R8
,0,DATE
,0,I4
,0);
4702 VAROR(R8
,-1,I8
,-1,I8
,-1);
4703 VAROR(R8
,-1,I8
,0,I8
,-1);
4704 VAROR(R8
,0,I8
,0,I8
,0);
4705 VAROR(R8
,-1,UI8
,0,I4
,-1);
4706 VAROR(R8
,0,UI8
,0,I4
,0);
4708 VAROR(R8
,-1,INT
,-1,I4
,-1);
4709 VAROR(R8
,-1,INT
,0,I4
,-1);
4710 VAROR(R8
,0,INT
,0,I4
,0);
4711 VAROR(R8
,-1,UINT
,0xffffffff,I4
,-1);
4712 VAROR(R8
,-1,UINT
,0,I4
,-1);
4713 VAROR(R8
,0,UINT
,0,I4
,0);
4714 rbstr
= SysAllocString(szFalse
);
4715 VAROR(R8
,0,BSTR
,rbstr
,I4
,0);
4716 VAROR(R8
,-1,BSTR
,rbstr
,I4
,-1);
4717 SysFreeString(rbstr
);
4718 rbstr
= SysAllocString(szTrue
);
4719 VAROR(R8
,0,BSTR
,rbstr
,I4
,-1);
4720 VAROR(R8
,-1,BSTR
,rbstr
,I4
,-1);
4721 SysFreeString(rbstr
);
4722 VARORCY(R8
,-1,10000,I4
,-1);
4723 VARORCY(R8
,-1,0,I4
,-1);
4724 VARORCY(R8
,0,0,I4
,0);
4726 VAROR(DATE
,-1,DATE
,-1,I4
,-1);
4727 VAROR(DATE
,-1,DATE
,0,I4
,-1);
4728 VAROR(DATE
,0,DATE
,0,I4
,0);
4731 VAROR(DATE
,-1,I8
,-1,I8
,-1);
4732 VAROR(DATE
,-1,I8
,0,I8
,-1);
4733 VAROR(DATE
,0,I8
,0,I8
,0);
4734 VAROR(DATE
,-1,UI8
,0,I4
,-1);
4735 VAROR(DATE
,0,UI8
,0,I4
,0);
4737 VAROR(DATE
,-1,INT
,-1,I4
,-1);
4738 VAROR(DATE
,-1,INT
,0,I4
,-1);
4739 VAROR(DATE
,0,INT
,0,I4
,0);
4740 VAROR(DATE
,-1,UINT
,0xffffffff,I4
,-1);
4741 VAROR(DATE
,-1,UINT
,0,I4
,-1);
4742 VAROR(DATE
,0,UINT
,0,I4
,0);
4743 rbstr
= SysAllocString(szFalse
);
4744 VAROR(DATE
,0,BSTR
,rbstr
,I4
,0);
4745 VAROR(DATE
,-1,BSTR
,rbstr
,I4
,-1);
4746 SysFreeString(rbstr
);
4747 rbstr
= SysAllocString(szTrue
);
4748 VAROR(DATE
,0,BSTR
,rbstr
,I4
,-1);
4749 VAROR(DATE
,-1,BSTR
,rbstr
,I4
,-1);
4750 SysFreeString(rbstr
);
4751 VARORCY(DATE
,-1,10000,I4
,-1);
4752 VARORCY(DATE
,-1,0,I4
,-1);
4753 VARORCY(DATE
,0,0,I4
,0);
4757 VAROR(I8
,-1,I8
,-1,I8
,-1);
4758 VAROR(I8
,-1,I8
,0,I8
,-1);
4759 VAROR(I8
,0,I8
,0,I8
,0);
4760 VAROR(I8
,-1,UI8
,0,I8
,-1);
4761 VAROR(I8
,0,UI8
,0,I8
,0);
4762 /* These overflow under native and Wine
4763 VAROR(I8,-1,INT,-1,I4,-1);
4764 VAROR(I8,-1,INT,0,I4,-1);
4765 VAROR(I8,0,INT,0,I4,0); */
4766 VAROR(I8
,-1,UINT
,0xffffffff,I8
,-1);
4767 VAROR(I8
,-1,UINT
,0,I8
,-1);
4768 VAROR(I8
,0,UINT
,0,I8
,0);
4769 rbstr
= SysAllocString(szFalse
);
4770 VAROR(I8
,0,BSTR
,rbstr
,I8
,0);
4771 VAROR(I8
,-1,BSTR
,rbstr
,I8
,-1);
4772 SysFreeString(rbstr
);
4773 rbstr
= SysAllocString(szTrue
);
4774 VAROR(I8
,0,BSTR
,rbstr
,I8
,-1);
4775 VAROR(I8
,-1,BSTR
,rbstr
,I8
,-1);
4776 SysFreeString(rbstr
);
4777 VARORCY(I8
,-1,10000,I8
,-1);
4778 VARORCY(I8
,-1,0,I8
,-1);
4779 VARORCY(I8
,0,0,I8
,0);
4781 VAROR(UI8
,0xffff,UI8
,0xffff,I4
,0xffff);
4782 VAROR(UI8
,0xffff,UI8
,0,I4
,0xffff);
4783 VAROR(UI8
,0,UI8
,0,I4
,0);
4784 VAROR(UI8
,0xffff,INT
,-1,I4
,-1);
4785 VAROR(UI8
,0xffff,INT
,0,I4
,0xffff);
4786 VAROR(UI8
,0,INT
,0,I4
,0);
4787 VAROR(UI8
,0xffff,UINT
,0xffff,I4
,0xffff);
4788 VAROR(UI8
,0xffff,UINT
,0,I4
,0xffff);
4789 VAROR(UI8
,0,UINT
,0,I4
,0);
4790 rbstr
= SysAllocString(szFalse
);
4791 VAROR(UI8
,0,BSTR
,rbstr
,I4
,0);
4792 VAROR(UI8
,0xffff,BSTR
,rbstr
,I4
,0xffff);
4793 SysFreeString(rbstr
);
4794 rbstr
= SysAllocString(szTrue
);
4795 VAROR(UI8
,0,BSTR
,rbstr
,I4
,-1);
4796 VAROR(UI8
,0xffff,BSTR
,rbstr
,I4
,-1);
4797 SysFreeString(rbstr
);
4798 VARORCY(UI8
,0xffff,10000,I4
,0xffff);
4799 VARORCY(UI8
,0xffff,0,I4
,0xffff);
4800 VARORCY(UI8
,0,0,I4
,0);
4803 VAROR(INT
,-1,INT
,-1,I4
,-1);
4804 VAROR(INT
,-1,INT
,0,I4
,-1);
4805 VAROR(INT
,0,INT
,0,I4
,0);
4806 VAROR(INT
,-1,UINT
,0xffff,I4
,-1);
4807 VAROR(INT
,-1,UINT
,0,I4
,-1);
4808 VAROR(INT
,0,UINT
,0,I4
,0);
4809 rbstr
= SysAllocString(szFalse
);
4810 VAROR(INT
,0,BSTR
,rbstr
,I4
,0);
4811 VAROR(INT
,-1,BSTR
,rbstr
,I4
,-1);
4812 SysFreeString(rbstr
);
4813 rbstr
= SysAllocString(szTrue
);
4814 VAROR(INT
,0,BSTR
,rbstr
,I4
,-1);
4815 VAROR(INT
,-1,BSTR
,rbstr
,I4
,-1);
4816 SysFreeString(rbstr
);
4817 VARORCY(INT
,-1,10000,I4
,-1);
4818 VARORCY(INT
,-1,0,I4
,-1);
4819 VARORCY(INT
,0,0,I4
,0);
4821 VAROR(UINT
,0xffff,UINT
,0xffff,I4
,0xffff);
4822 VAROR(UINT
,0xffff,UINT
,0,I4
,0xffff);
4823 VAROR(UINT
,0,UINT
,0,I4
,0);
4824 rbstr
= SysAllocString(szFalse
);
4825 VAROR(UINT
,0,BSTR
,rbstr
,I4
,0);
4826 VAROR(UINT
,0xffff,BSTR
,rbstr
,I4
,0xffff);
4827 SysFreeString(rbstr
);
4828 rbstr
= SysAllocString(szTrue
);
4829 VAROR(UINT
,0,BSTR
,rbstr
,I4
,-1);
4830 VAROR(UINT
,0xffff,BSTR
,rbstr
,I4
,-1);
4831 SysFreeString(rbstr
);
4832 VARORCY(UINT
,0xffff,10000,I4
,0xffff);
4833 VARORCY(UINT
,0xffff,0,I4
,0xffff);
4834 VARORCY(UINT
,0,0,I4
,0);
4836 lbstr
= SysAllocString(szFalse
);
4837 rbstr
= SysAllocString(szFalse
);
4838 VAROR(BSTR
,lbstr
,BSTR
,rbstr
,BOOL
,0);
4839 SysFreeString(rbstr
);
4840 rbstr
= SysAllocString(szTrue
);
4841 VAROR(BSTR
,lbstr
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
4842 SysFreeString(lbstr
);
4843 lbstr
= SysAllocString(szTrue
);
4844 VAROR(BSTR
,lbstr
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
4845 VARORCY(BSTR
,lbstr
,10000,I4
,-1);
4846 SysFreeString(lbstr
);
4847 lbstr
= SysAllocString(szFalse
);
4848 VARORCY(BSTR
,lbstr
,10000,I4
,1);
4849 SysFreeString(lbstr
);
4850 SysFreeString(rbstr
);
4853 static HRESULT (WINAPI
*pVarEqv
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
4855 #define VAREQV(vt1,val1,vt2,val2,rvt,rval) \
4856 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
4857 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
4858 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
4859 test_var_call2( __LINE__, pVarEqv, &left, &right, &exp )
4861 static void test_VarEqv(void)
4863 VARIANT left
, right
, exp
, result
;
4869 /* Test all possible flag/vt combinations & the resulting vt type */
4870 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
4872 VARTYPE leftvt
, rightvt
, resvt
;
4874 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
4878 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
4884 if (leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
||
4885 leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
||
4886 leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
)
4889 memset(&left
, 0, sizeof(left
));
4890 memset(&right
, 0, sizeof(right
));
4891 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
4892 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
4893 V_VT(&result
) = VT_EMPTY
;
4896 if (ExtraFlags
[i
] & VT_ARRAY
|| ExtraFlags
[i
] & VT_BYREF
||
4897 !IsValidVariantClearVT(leftvt
, ExtraFlags
[i
]) ||
4898 !IsValidVariantClearVT(rightvt
, ExtraFlags
[i
]) ||
4899 leftvt
== VT_CLSID
|| rightvt
== VT_CLSID
||
4900 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
||
4901 leftvt
== VT_VARIANT
|| rightvt
== VT_VARIANT
||
4902 leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
)
4906 if (leftvt
== VT_EMPTY
|| rightvt
== VT_EMPTY
)
4908 if (leftvt
== rightvt
||
4909 leftvt
== VT_I2
|| rightvt
== VT_I2
||
4910 leftvt
== VT_UI1
|| rightvt
== VT_UI1
||
4911 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
4913 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
4915 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
4918 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
4922 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
4924 if (leftvt
== rightvt
)
4926 else if (leftvt
== rightvt
||
4927 leftvt
== VT_I2
|| rightvt
== VT_I2
||
4928 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
4932 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
4935 else if (leftvt
== VT_I2
|| rightvt
== VT_I2
)
4937 if (leftvt
== rightvt
||
4938 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
4940 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
4943 else if (leftvt
== VT_BOOL
&& rightvt
== VT_BOOL
)
4947 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
4949 if (leftvt
== VT_INT
|| rightvt
== VT_INT
)
4954 hres
= pVarEqv(&left
, &right
, &result
);
4956 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
4957 "VarEqv: %d|0x%X, %d|0x%X: Expected failure, got 0x%X vt %d\n",
4958 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], hres
,
4961 ok(hres
== S_OK
&& V_VT(&result
) == resvt
,
4962 "VarEqv: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%X vt %d\n",
4963 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], resvt
, hres
,
4969 /* Test returned values */
4970 VAREQV(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
);
4971 VAREQV(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
);
4972 VAREQV(BOOL
,TRUE
,BOOL
,TRUE
,BOOL
,VARIANT_TRUE
);
4973 VAREQV(BOOL
,FALSE
,BOOL
,FALSE
,BOOL
,VARIANT_TRUE
);
4974 VAREQV(BOOL
,TRUE
,BOOL
,FALSE
,BOOL
,-2);
4975 VAREQV(BOOL
,FALSE
,BOOL
,TRUE
,BOOL
,-2);
4976 VAREQV(BOOL
,6,BOOL
,7,BOOL
,-2);
4977 VAREQV(BOOL
,6,BOOL
,6,BOOL
,VARIANT_TRUE
);
4978 VAREQV(BOOL
,VARIANT_TRUE
,I2
,VARIANT_TRUE
,I2
,VARIANT_TRUE
);
4979 VAREQV(BOOL
,VARIANT_TRUE
,I2
,VARIANT_FALSE
,I2
,VARIANT_FALSE
);
4980 VAREQV(BOOL
,6,I2
,7,I2
,-2);
4981 VAREQV(UI1
,1,UI1
,1,UI1
,255);
4982 VAREQV(UI1
,1,UI1
,0,UI1
,254);
4983 VAREQV(UI1
,0,UI1
,1,UI1
,254);
4986 VAREQV(UI4
,VARIANT_FALSE
,I8
,VARIANT_FALSE
,I8
,-1);
4987 VAREQV(UI4
,5,I8
,19,I8
,-23);
4988 VAREQV(UI4
,VARIANT_FALSE
,UI8
,VARIANT_FALSE
,I4
,-1);
4992 static HRESULT (WINAPI
*pVarMul
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
4994 #define VARMUL(vt1,val1,vt2,val2,rvt,rval) \
4995 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
4996 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
4997 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
4998 test_var_call2( __LINE__, pVarMul, &left, &right, &exp )
5000 static void test_VarMul(void)
5002 VARIANT left
, right
, exp
, result
, cy
, dec
;
5010 lbstr
= SysAllocString(sz12
);
5011 rbstr
= SysAllocString(sz12
);
5013 /* Test all possible flag/vt combinations & the resulting vt type */
5014 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
5016 VARTYPE leftvt
, rightvt
, resvt
;
5018 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
5023 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
5029 if (leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
||
5030 leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
)
5033 memset(&left
, 0, sizeof(left
));
5034 memset(&right
, 0, sizeof(right
));
5035 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
5036 if (leftvt
== VT_BSTR
)
5037 V_BSTR(&left
) = lbstr
;
5038 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
5039 if (rightvt
== VT_BSTR
)
5040 V_BSTR(&right
) = rbstr
;
5041 V_VT(&result
) = VT_EMPTY
;
5044 /* Don't ask me why but native VarMul cannot handle:
5045 VT_I1, VT_UI2, VT_UI4, VT_INT, VT_UINT and VT_UI8.
5046 Tested with DCOM98, Win2k, WinXP */
5047 if (ExtraFlags
[i
] & VT_ARRAY
|| ExtraFlags
[i
] & VT_BYREF
||
5048 !IsValidVariantClearVT(leftvt
, ExtraFlags
[i
]) ||
5049 !IsValidVariantClearVT(rightvt
, ExtraFlags
[i
]) ||
5050 leftvt
== VT_CLSID
|| rightvt
== VT_CLSID
||
5051 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
||
5052 leftvt
== VT_VARIANT
|| rightvt
== VT_VARIANT
||
5053 leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
||
5054 leftvt
== VT_I1
|| rightvt
== VT_I1
||
5055 leftvt
== VT_UI2
|| rightvt
== VT_UI2
||
5056 leftvt
== VT_UI4
|| rightvt
== VT_UI4
||
5057 leftvt
== VT_UI8
|| rightvt
== VT_UI8
||
5058 leftvt
== VT_INT
|| rightvt
== VT_INT
||
5059 leftvt
== VT_UINT
|| rightvt
== VT_UINT
) {
5063 if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
5065 else if (leftvt
== VT_DECIMAL
|| rightvt
== VT_DECIMAL
)
5067 else if (leftvt
== VT_R8
|| rightvt
== VT_R8
||
5068 leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
||
5069 leftvt
== VT_DATE
|| rightvt
== VT_DATE
)
5071 else if (leftvt
== VT_R4
|| rightvt
== VT_R4
) {
5072 if (leftvt
== VT_I4
|| rightvt
== VT_I4
||
5073 leftvt
== VT_I8
|| rightvt
== VT_I8
||
5074 leftvt
== VT_CY
|| rightvt
== VT_CY
)
5078 } else if (leftvt
== VT_CY
|| rightvt
== VT_CY
)
5080 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
5082 else if (leftvt
== VT_I4
|| rightvt
== VT_I4
)
5084 else if (leftvt
== VT_I2
|| rightvt
== VT_I2
||
5085 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
||
5086 (leftvt
== VT_EMPTY
&& rightvt
== VT_EMPTY
))
5088 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
5091 hres
= pVarMul(&left
, &right
, &result
);
5093 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
5094 "VarMul: %d|0x%X, %d|0x%X: Expected failure, got 0x%X vt %d\n",
5095 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], hres
,
5098 ok(hres
== S_OK
&& V_VT(&result
) == resvt
,
5099 "VarMul: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%X vt %d\n",
5100 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], resvt
, hres
,
5107 /* Test returned values */
5108 VARMUL(I4
,4,I4
,2,I4
,8);
5109 VARMUL(I2
,4,I2
,2,I2
,8);
5110 VARMUL(I2
,-13,I4
,5,I4
,-65);
5111 VARMUL(I4
,-13,I4
,5,I4
,-65);
5112 VARMUL(I2
,7,R4
,0.5f
,R4
,3.5f
);
5113 VARMUL(R4
,0.5f
,I4
,5,R8
,2.5);
5114 VARMUL(R8
,7.1,BOOL
,0,R8
,0);
5115 VARMUL(BSTR
,lbstr
,I2
,4,R8
,48);
5116 VARMUL(BSTR
,lbstr
,BOOL
,1,R8
,12);
5117 VARMUL(BSTR
,lbstr
,R4
,0.1f
,R8
,1.2);
5118 VARMUL(BSTR
,lbstr
,BSTR
,rbstr
,R8
,144);
5119 VARMUL(R4
,0.2f
,BSTR
,rbstr
,R8
,2.4);
5120 VARMUL(DATE
,2.25,I4
,7,R8
,15.75);
5122 VARMUL(UI1
, UI1_MAX
, UI1
, UI1_MAX
, I4
, UI1_MAX
* UI1_MAX
);
5123 VARMUL(I2
, I2_MAX
, I2
, I2_MAX
, I4
, I2_MAX
* I2_MAX
);
5124 VARMUL(I2
, I2_MAX
, I2
, I2_MIN
, I4
, I2_MAX
* I2_MIN
);
5125 VARMUL(I2
, I2_MIN
, I2
, I2_MIN
, I4
, I2_MIN
* I2_MIN
);
5126 VARMUL(I4
, I4_MAX
, I4
, I4_MAX
, R8
, (double)I4_MAX
* I4_MAX
);
5127 VARMUL(I4
, I4_MAX
, I4
, I4_MIN
, R8
, (double)I4_MAX
* I4_MIN
);
5128 VARMUL(I4
, I4_MIN
, I4
, I4_MIN
, R8
, (double)I4_MIN
* I4_MIN
);
5129 VARMUL(R4
, R4_MAX
, R4
, R4_MAX
, R8
, (double)R4_MAX
* R4_MAX
);
5130 VARMUL(R4
, R4_MAX
, R4
, R4_MIN
, R4
, R4_MAX
* R4_MIN
);
5131 VARMUL(R4
, R4_MIN
, R4
, R4_MIN
, R4
, R4_MIN
* R4_MIN
);
5132 VARMUL(R8
, R8_MAX
, R8
, R8_MIN
, R8
, R8_MAX
* R8_MIN
);
5133 VARMUL(R8
, R8_MIN
, R8
, R8_MIN
, R8
, R8_MIN
* R8_MIN
);
5135 /* Manuly test some VT_CY and VT_DECIMAL variants */
5137 hres
= VarCyFromI4(4711, &V_CY(&cy
));
5138 ok(hres
== S_OK
, "VarCyFromI4 failed!\n");
5139 V_VT(&dec
) = VT_DECIMAL
;
5140 hres
= VarDecFromR8(-4.2, &V_DECIMAL(&dec
));
5141 ok(hres
== S_OK
, "VarDecFromR4 failed!\n");
5142 memset(&left
, 0, sizeof(left
));
5143 memset(&right
, 0, sizeof(right
));
5144 V_VT(&left
) = VT_I4
;
5146 V_VT(&right
) = VT_UI1
;
5149 hres
= pVarMul(&cy
, &right
, &result
);
5150 ok(hres
== S_OK
&& V_VT(&result
) == VT_CY
, "VarMul: expected coerced type VT_CY, got %s!\n", vtstr(V_VT(&result
)));
5151 hres
= VarR8FromCy(V_CY(&result
), &r
);
5152 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 42399), "VarMul: CY value %f, expected %f\n", r
, (double)42399);
5154 hres
= pVarMul(&left
, &dec
, &result
);
5155 ok(hres
== S_OK
&& V_VT(&result
) == VT_DECIMAL
, "VarMul: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result
)));
5156 hres
= VarR8FromDec(&V_DECIMAL(&result
), &r
);
5157 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 46.2), "VarMul: DECIMAL value %f, expected %f\n", r
, (double)46.2);
5159 SysFreeString(lbstr
);
5160 SysFreeString(rbstr
);
5163 static HRESULT (WINAPI
*pVarAdd
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
5165 #define VARADD(vt1,val1,vt2,val2,rvt,rval) \
5166 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
5167 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
5168 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
5169 test_var_call2( __LINE__, pVarAdd, &left, &right, &exp )
5171 static void test_VarAdd(void)
5173 VARIANT left
, right
, exp
, result
, cy
, dec
;
5181 lbstr
= SysAllocString(sz12
);
5182 rbstr
= SysAllocString(sz12
);
5184 /* Test all possible flag/vt combinations & the resulting vt type */
5185 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
5187 VARTYPE leftvt
, rightvt
, resvt
;
5189 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
5194 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
5200 if (leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
)
5203 memset(&left
, 0, sizeof(left
));
5204 memset(&right
, 0, sizeof(right
));
5205 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
5206 if (leftvt
== VT_BSTR
)
5207 V_BSTR(&left
) = lbstr
;
5208 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
5209 if (rightvt
== VT_BSTR
)
5210 V_BSTR(&right
) = rbstr
;
5211 V_VT(&result
) = VT_EMPTY
;
5214 /* Don't ask me why but native VarAdd cannot handle:
5215 VT_I1, VT_UI2, VT_UI4, VT_INT, VT_UINT and VT_UI8.
5216 Tested with DCOM98, Win2k, WinXP */
5217 if (ExtraFlags
[i
] & VT_ARRAY
|| ExtraFlags
[i
] & VT_BYREF
||
5218 !IsValidVariantClearVT(leftvt
, ExtraFlags
[i
]) ||
5219 !IsValidVariantClearVT(rightvt
, ExtraFlags
[i
]) ||
5220 leftvt
== VT_CLSID
|| rightvt
== VT_CLSID
||
5221 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
||
5222 leftvt
== VT_VARIANT
|| rightvt
== VT_VARIANT
||
5223 leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
||
5224 leftvt
== VT_I1
|| rightvt
== VT_I1
||
5225 leftvt
== VT_UI2
|| rightvt
== VT_UI2
||
5226 leftvt
== VT_UI4
|| rightvt
== VT_UI4
||
5227 leftvt
== VT_UI8
|| rightvt
== VT_UI8
||
5228 leftvt
== VT_INT
|| rightvt
== VT_INT
||
5229 leftvt
== VT_UINT
|| rightvt
== VT_UINT
) {
5233 if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
5235 else if (leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
)
5237 else if (leftvt
== VT_DECIMAL
|| rightvt
== VT_DECIMAL
)
5239 else if (leftvt
== VT_DATE
|| rightvt
== VT_DATE
)
5241 else if (leftvt
== VT_CY
|| rightvt
== VT_CY
)
5243 else if (leftvt
== VT_R8
|| rightvt
== VT_R8
)
5245 else if (leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
) {
5246 if ((leftvt
== VT_BSTR
&& rightvt
== VT_BSTR
) ||
5247 leftvt
== VT_EMPTY
|| rightvt
== VT_EMPTY
)
5251 } else if (leftvt
== VT_R4
|| rightvt
== VT_R4
) {
5252 if (leftvt
== VT_I4
|| rightvt
== VT_I4
||
5253 leftvt
== VT_I8
|| rightvt
== VT_I8
)
5258 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
5260 else if (leftvt
== VT_I4
|| rightvt
== VT_I4
)
5262 else if (leftvt
== VT_I2
|| rightvt
== VT_I2
||
5263 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
||
5264 (leftvt
== VT_EMPTY
&& rightvt
== VT_EMPTY
))
5266 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
5269 hres
= pVarAdd(&left
, &right
, &result
);
5271 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
5272 "VarAdd: %d|0x%X, %d|0x%X: Expected failure, got 0x%X vt %d\n",
5273 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], hres
,
5276 ok(hres
== S_OK
&& V_VT(&result
) == resvt
,
5277 "VarAdd: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%X vt %d\n",
5278 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], resvt
, hres
,
5281 /* Note, we don't clear left/right deliberately here */
5282 VariantClear(&result
);
5287 /* Test returned values */
5288 VARADD(I4
,4,I4
,2,I4
,6);
5289 VARADD(I2
,4,I2
,2,I2
,6);
5290 VARADD(I2
,-13,I4
,5,I4
,-8);
5291 VARADD(I4
,-13,I4
,5,I4
,-8);
5292 VARADD(I2
,7,R4
,0.5f
,R4
,7.5f
);
5293 VARADD(R4
,0.5f
,I4
,5,R8
,5.5);
5294 VARADD(R8
,7.1,BOOL
,0,R8
,7.1);
5295 VARADD(BSTR
,lbstr
,I2
,4,R8
,16);
5296 VARADD(BSTR
,lbstr
,BOOL
,1,R8
,13);
5297 VARADD(BSTR
,lbstr
,R4
,0.1f
,R8
,12.1);
5298 VARADD(R4
,0.2f
,BSTR
,rbstr
,R8
,12.2);
5299 VARADD(DATE
,2.25,I4
,7,DATE
,9.25);
5300 VARADD(DATE
,1.25,R4
,-1.7f
,DATE
,-0.45);
5302 VARADD(UI1
, UI1_MAX
, UI1
, UI1_MAX
, I2
, UI1_MAX
+ UI1_MAX
);
5303 VARADD(I2
, I2_MAX
, I2
, I2_MAX
, I4
, I2_MAX
+ I2_MAX
);
5304 VARADD(I2
, I2_MAX
, I2
, I2_MIN
, I2
, I2_MAX
+ I2_MIN
);
5305 VARADD(I2
, I2_MIN
, I2
, I2_MIN
, I4
, I2_MIN
+ I2_MIN
);
5306 VARADD(I4
, I4_MAX
, I4
, I4_MIN
, I4
, I4_MAX
+ I4_MIN
);
5307 VARADD(I4
, I4_MAX
, I4
, I4_MAX
, R8
, (double)I4_MAX
+ I4_MAX
);
5308 VARADD(I4
, I4_MIN
, I4
, I4_MIN
, R8
, (double)I4_MIN
+ I4_MIN
);
5309 VARADD(R4
, R4_MAX
, R4
, R4_MAX
, R8
, (double)R4_MAX
+ R4_MAX
);
5310 VARADD(R4
, R4_MAX
, R4
, R4_MIN
, R4
, R4_MAX
+ R4_MIN
);
5311 VARADD(R4
, R4_MIN
, R4
, R4_MIN
, R4
, R4_MIN
+ R4_MIN
);
5312 VARADD(R8
, R8_MAX
, R8
, R8_MIN
, R8
, R8_MAX
+ R8_MIN
);
5313 VARADD(R8
, R8_MIN
, R8
, R8_MIN
, R8
, R8_MIN
+ R8_MIN
);
5315 /* Manually test BSTR + BSTR */
5316 V_VT(&left
) = VT_BSTR
;
5317 V_BSTR(&left
) = lbstr
;
5318 V_VT(&right
) = VT_BSTR
;
5319 V_BSTR(&right
) = rbstr
;
5320 hres
= pVarAdd(&left
, &right
, &result
);
5321 ok(hres
== S_OK
&& V_VT(&result
) == VT_BSTR
, "VarAdd: expected coerced type VT_BSTR, got %s!\n", vtstr(V_VT(&result
)));
5322 hres
= VarR8FromStr(V_BSTR(&result
), 0, 0, &r
);
5323 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 1212), "VarAdd: BSTR value %f, expected %f\n", r
, (double)1212);
5324 VariantClear(&result
);
5326 /* Manuly test some VT_CY and VT_DECIMAL variants */
5328 hres
= VarCyFromI4(4711, &V_CY(&cy
));
5329 ok(hres
== S_OK
, "VarCyFromI4 failed!\n");
5330 V_VT(&dec
) = VT_DECIMAL
;
5331 hres
= VarDecFromR8(-4.2, &V_DECIMAL(&dec
));
5332 ok(hres
== S_OK
, "VarDecFromR4 failed!\n");
5333 memset(&left
, 0, sizeof(left
));
5334 memset(&right
, 0, sizeof(right
));
5335 V_VT(&left
) = VT_I4
;
5337 V_VT(&right
) = VT_UI1
;
5340 hres
= pVarAdd(&cy
, &right
, &result
);
5341 ok(hres
== S_OK
&& V_VT(&result
) == VT_CY
, "VarAdd: expected coerced type VT_CY, got %s!\n", vtstr(V_VT(&result
)));
5342 hres
= VarR8FromCy(V_CY(&result
), &r
);
5343 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 4720), "VarAdd: CY value %f, expected %f\n", r
, (double)4720);
5345 hres
= pVarAdd(&left
, &dec
, &result
);
5346 ok(hres
== S_OK
&& V_VT(&result
) == VT_DECIMAL
, "VarAdd: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result
)));
5347 hres
= VarR8FromDec(&V_DECIMAL(&result
), &r
);
5348 ok(hres
== S_OK
&& EQ_DOUBLE(r
, -15.2), "VarAdd: DECIMAL value %f, expected %f\n", r
, (double)-15.2);
5349 VariantClear(&result
);
5351 SysFreeString(lbstr
);
5352 SysFreeString(rbstr
);
5355 static HRESULT (WINAPI
*pVarCmp
)(LPVARIANT
,LPVARIANT
,LCID
,ULONG
);
5356 static HRESULT (WINAPI
*pVarCat
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
5358 static void test_VarCat(void)
5361 VARIANT left
, right
, result
, expected
, expected_broken
;
5362 static const WCHAR sz34
[] = {'3','4','\0'};
5363 static const WCHAR sz1234
[] = {'1','2','3','4','\0'};
5364 static const WCHAR date_sz12
[] = {'9','/','3','0','/','1','9','8','0','1','2','\0'};
5365 static const WCHAR date_sz12_broken
[] = {'9','/','3','0','/','8','0','1','2','\0'};
5366 static const WCHAR sz12_date
[] = {'1','2','9','/','3','0','/','1','9','8','0','\0'};
5367 static const WCHAR sz12_date_broken
[] = {'1','2','9','/','3','0','/','8','0','\0'};
5368 static const WCHAR sz_empty
[] = {'\0'};
5369 TCHAR orig_date_format
[128];
5370 VARTYPE leftvt
, rightvt
, resultvt
;
5372 HRESULT expected_error_num
;
5376 /* Set date format for testing */
5377 lcid
= LOCALE_USER_DEFAULT
;
5378 GetLocaleInfo(lcid
,LOCALE_SSHORTDATE
,orig_date_format
,128);
5379 SetLocaleInfo(lcid
,LOCALE_SSHORTDATE
,"M/d/yyyy");
5382 VariantInit(&right
);
5383 VariantInit(&result
);
5384 VariantInit(&expected
);
5386 /* Check expected types for all combinations */
5387 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
5392 /* Check if we need/have support for I8 and/or UI8 */
5393 if ((leftvt
== VT_I8
|| leftvt
== VT_UI8
) && !has_i8
)
5396 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
5400 expected_error_num
= S_OK
;
5401 resultvt
= VT_EMPTY
;
5403 if (leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
||
5404 leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
||
5405 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
||
5406 leftvt
== 15 || rightvt
== 15 /* Undefined type */)
5409 /* Check if we need/have support for I8 and/or UI8 */
5410 if ((rightvt
== VT_I8
|| rightvt
== VT_UI8
) && !has_i8
)
5413 if (leftvt
== VT_NULL
&& rightvt
== VT_NULL
)
5415 else if (leftvt
== VT_VARIANT
&& (rightvt
== VT_ERROR
||
5416 rightvt
== VT_DATE
|| rightvt
== VT_DECIMAL
))
5417 expected_error_num
= DISP_E_TYPEMISMATCH
;
5418 else if ((leftvt
== VT_I2
|| leftvt
== VT_I4
||
5419 leftvt
== VT_R4
|| leftvt
== VT_R8
||
5420 leftvt
== VT_CY
|| leftvt
== VT_BOOL
||
5421 leftvt
== VT_BSTR
|| leftvt
== VT_I1
||
5422 leftvt
== VT_UI1
|| leftvt
== VT_UI2
||
5423 leftvt
== VT_UI4
|| leftvt
== VT_I8
||
5424 leftvt
== VT_UI8
|| leftvt
== VT_INT
||
5425 leftvt
== VT_UINT
|| leftvt
== VT_EMPTY
||
5426 leftvt
== VT_NULL
|| leftvt
== VT_DECIMAL
||
5429 (rightvt
== VT_I2
|| rightvt
== VT_I4
||
5430 rightvt
== VT_R4
|| rightvt
== VT_R8
||
5431 rightvt
== VT_CY
|| rightvt
== VT_BOOL
||
5432 rightvt
== VT_BSTR
|| rightvt
== VT_I1
||
5433 rightvt
== VT_UI1
|| rightvt
== VT_UI2
||
5434 rightvt
== VT_UI4
|| rightvt
== VT_I8
||
5435 rightvt
== VT_UI8
|| rightvt
== VT_INT
||
5436 rightvt
== VT_UINT
|| rightvt
== VT_EMPTY
||
5437 rightvt
== VT_NULL
|| rightvt
== VT_DECIMAL
||
5438 rightvt
== VT_DATE
))
5440 else if (rightvt
== VT_ERROR
&& leftvt
< VT_VOID
)
5441 expected_error_num
= DISP_E_TYPEMISMATCH
;
5442 else if (leftvt
== VT_ERROR
&& (rightvt
== VT_DATE
||
5443 rightvt
== VT_ERROR
|| rightvt
== VT_DECIMAL
))
5444 expected_error_num
= DISP_E_TYPEMISMATCH
;
5445 else if (rightvt
== VT_DATE
|| rightvt
== VT_ERROR
||
5446 rightvt
== VT_DECIMAL
)
5447 expected_error_num
= DISP_E_BADVARTYPE
;
5448 else if (leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
)
5449 expected_error_num
= DISP_E_TYPEMISMATCH
;
5450 else if (leftvt
== VT_VARIANT
)
5451 expected_error_num
= DISP_E_TYPEMISMATCH
;
5452 else if (rightvt
== VT_VARIANT
&& (leftvt
== VT_EMPTY
||
5453 leftvt
== VT_NULL
|| leftvt
== VT_I2
||
5454 leftvt
== VT_I4
|| leftvt
== VT_R4
||
5455 leftvt
== VT_R8
|| leftvt
== VT_CY
||
5456 leftvt
== VT_DATE
|| leftvt
== VT_BSTR
||
5457 leftvt
== VT_BOOL
|| leftvt
== VT_DECIMAL
||
5458 leftvt
== VT_I1
|| leftvt
== VT_UI1
||
5459 leftvt
== VT_UI2
|| leftvt
== VT_UI4
||
5460 leftvt
== VT_I8
|| leftvt
== VT_UI8
||
5461 leftvt
== VT_INT
|| leftvt
== VT_UINT
5463 expected_error_num
= DISP_E_TYPEMISMATCH
;
5465 expected_error_num
= DISP_E_BADVARTYPE
;
5467 V_VT(&left
) = leftvt
;
5468 V_VT(&right
) = rightvt
;
5472 V_BSTR(&left
) = SysAllocString(sz_empty
); break;
5474 V_DATE(&left
) = 0.0; break;
5476 VarDecFromR8(0.0, &V_DECIMAL(&left
)); break;
5483 V_BSTR(&right
) = SysAllocString(sz_empty
); break;
5485 V_DATE(&right
) = 0.0; break;
5487 VarDecFromR8(0.0, &V_DECIMAL(&right
)); break;
5492 hres
= pVarCat(&left
, &right
, &result
);
5494 /* Determine the error code for the vt combination */
5495 ok(hres
== expected_error_num
,
5496 "VarCat: %d, %d returned error, 0x%X expected 0x%X.\n",
5497 leftvt
, rightvt
, hres
, expected_error_num
);
5499 /* Check types are correct */
5500 ok(V_VT(&result
) == resultvt
,
5501 "VarCat: %d, %d: expected vt %d, got vt %d\n",
5502 leftvt
, rightvt
, resultvt
, V_VT(&result
));
5504 VariantClear(&left
);
5505 VariantClear(&right
);
5506 VariantClear(&result
);
5510 /* Running single comparison tests to compare outputs */
5512 /* Test concat strings */
5513 V_VT(&left
) = VT_BSTR
;
5514 V_VT(&right
) = VT_BSTR
;
5515 V_VT(&expected
) = VT_BSTR
;
5516 V_BSTR(&left
) = SysAllocString(sz12
);
5517 V_BSTR(&right
) = SysAllocString(sz34
);
5518 V_BSTR(&expected
) = SysAllocString(sz1234
);
5519 hres
= pVarCat(&left
,&right
,&result
);
5520 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5522 ok(pVarCmp(&result
,&expected
,lcid
,0) == VARCMP_EQ
,
5523 "VarCat: VT_BSTR concat with VT_BSTR failed to return correct result\n");
5525 VariantClear(&left
);
5526 VariantClear(&right
);
5527 VariantClear(&result
);
5529 /* Test if expression is VT_ERROR */
5530 V_VT(&left
) = VT_ERROR
;
5531 V_VT(&right
) = VT_BSTR
;
5532 V_BSTR(&right
) = SysAllocString(sz1234
);
5533 hres
= pVarCat(&left
,&right
,&result
);
5534 ok(hres
== DISP_E_TYPEMISMATCH
, "VarCat should have returned DISP_E_TYPEMISMATCH instead of 0x%08x\n", hres
);
5535 ok(V_VT(&result
) == VT_EMPTY
,
5536 "VarCat: VT_ERROR concat with VT_BSTR should have returned VT_EMPTY\n");
5538 VariantClear(&left
);
5539 VariantClear(&right
);
5540 VariantClear(&result
);
5542 V_VT(&left
) = VT_BSTR
;
5543 V_VT(&right
) = VT_ERROR
;
5544 V_BSTR(&left
) = SysAllocString(sz1234
);
5545 hres
= pVarCat(&left
,&right
,&result
);
5546 ok(hres
== DISP_E_TYPEMISMATCH
, "VarCat should have returned DISP_E_TYPEMISMATCH instead of 0x%08x\n", hres
);
5547 ok(V_VT(&result
) == VT_EMPTY
,
5548 "VarCat: VT_BSTR concat with VT_ERROR should have returned VT_EMPTY\n");
5550 VariantClear(&left
);
5551 VariantClear(&right
);
5552 VariantClear(&result
);
5553 VariantClear(&expected
);
5555 /* Test combining boolean with number */
5556 V_VT(&left
) = VT_INT
;
5557 V_VT(&right
) = VT_BOOL
;
5558 V_VT(&expected
) = VT_BSTR
;
5560 V_BOOL(&right
) = TRUE
;
5561 V_BSTR(&expected
) = SysAllocString(sz12_true
);
5562 hres
= pVarCat(&left
,&right
,&result
);
5563 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5566 hres
= pVarCmp(&result
,&expected
,lcid
,0);
5567 ok(hres
== VARCMP_EQ
, "Expected VARCMP_EQ, got %08x for %s, %s\n",
5568 hres
, variantstr(&result
), variantstr(&expected
));
5571 VariantClear(&left
);
5572 VariantClear(&right
);
5573 VariantClear(&result
);
5574 VariantClear(&expected
);
5576 V_VT(&left
) = VT_INT
;
5577 V_VT(&right
) = VT_BOOL
;
5578 V_VT(&expected
) = VT_BSTR
;
5580 V_BOOL(&right
) = FALSE
;
5581 V_BSTR(&expected
) = SysAllocString(sz12_false
);
5582 hres
= pVarCat(&left
,&right
,&result
);
5583 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5586 hres
= pVarCmp(&result
,&expected
,lcid
,0);
5587 ok(hres
== VARCMP_EQ
, "Expected VARCMP_EQ, got %08x for %s, %s\n",
5588 hres
, variantstr(&result
), variantstr(&expected
));
5591 VariantClear(&left
);
5592 VariantClear(&right
);
5593 VariantClear(&result
);
5594 VariantClear(&expected
);
5596 /* Test when both expressions are numeric */
5597 V_VT(&left
) = VT_INT
;
5598 V_VT(&right
) = VT_INT
;
5599 V_VT(&expected
) = VT_BSTR
;
5602 V_BSTR(&expected
) = SysAllocString(sz1234
);
5603 hres
= pVarCat(&left
,&right
,&result
);
5604 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5606 ok(pVarCmp(&result
,&expected
,lcid
,0) == VARCMP_EQ
,
5607 "VarCat: NUMBER concat with NUMBER returned incorrect result\n");
5609 VariantClear(&left
);
5610 VariantClear(&right
);
5611 VariantClear(&result
);
5613 /* Test if one expression is numeric and the other is a string */
5614 V_VT(&left
) = VT_INT
;
5615 V_VT(&right
) = VT_BSTR
;
5617 V_BSTR(&right
) = SysAllocString(sz34
);
5618 hres
= pVarCat(&left
,&right
,&result
);
5619 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5621 ok(pVarCmp(&result
,&expected
,lcid
,0) == VARCMP_EQ
,
5622 "VarCat: NUMBER concat with VT_BSTR, incorrect result\n");
5624 VariantClear(&left
);
5625 VariantClear(&right
);
5626 VariantClear(&result
);
5628 V_VT(&left
) = VT_BSTR
;
5629 V_VT(&right
) = VT_INT
;
5630 V_BSTR(&left
) = SysAllocString(sz12
);
5632 hres
= pVarCat(&left
,&right
,&result
);
5633 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5635 ok(pVarCmp(&result
,&expected
,lcid
,0) == VARCMP_EQ
,
5636 "VarCat: VT_BSTR concat with NUMBER, incorrect result\n");
5638 VariantClear(&left
);
5639 VariantClear(&right
);
5640 VariantClear(&result
);
5641 VariantClear(&expected
);
5643 /* Test concat dates with strings */
5644 V_VT(&left
) = VT_BSTR
;
5645 V_VT(&right
) = VT_DATE
;
5646 V_VT(&expected
) = VT_BSTR
;
5647 V_VT(&expected_broken
) = VT_BSTR
;
5648 V_BSTR(&left
) = SysAllocString(sz12
);
5649 V_DATE(&right
) = 29494.0;
5650 V_BSTR(&expected
)= SysAllocString(sz12_date
);
5651 V_BSTR(&expected_broken
)= SysAllocString(sz12_date_broken
);
5652 hres
= pVarCat(&left
,&right
,&result
);
5653 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5655 ok(pVarCmp(&result
,&expected
,lcid
,0) == VARCMP_EQ
||
5656 broken(pVarCmp(&result
,&expected_broken
,lcid
,0) == VARCMP_EQ
), /* Some W98 and NT4 (intermittent) */
5657 "VarCat: VT_BSTR concat with VT_DATE returned incorrect result\n");
5659 VariantClear(&left
);
5660 VariantClear(&right
);
5661 VariantClear(&result
);
5662 VariantClear(&expected
);
5663 VariantClear(&expected_broken
);
5665 V_VT(&left
) = VT_DATE
;
5666 V_VT(&right
) = VT_BSTR
;
5667 V_VT(&expected
) = VT_BSTR
;
5668 V_VT(&expected_broken
) = VT_BSTR
;
5669 V_DATE(&left
) = 29494.0;
5670 V_BSTR(&right
) = SysAllocString(sz12
);
5671 V_BSTR(&expected
)= SysAllocString(date_sz12
);
5672 V_BSTR(&expected_broken
)= SysAllocString(date_sz12_broken
);
5673 hres
= pVarCat(&left
,&right
,&result
);
5674 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5676 ok(pVarCmp(&result
,&expected
,lcid
,0) == VARCMP_EQ
||
5677 broken(pVarCmp(&result
,&expected_broken
,lcid
,0) == VARCMP_EQ
), /* Some W98 and NT4 (intermittent) */
5678 "VarCat: VT_DATE concat with VT_BSTR returned incorrect result\n");
5680 VariantClear(&left
);
5681 VariantClear(&right
);
5682 VariantClear(&result
);
5683 VariantClear(&expected
);
5684 VariantClear(&expected_broken
);
5686 /* Test of both expressions are empty */
5687 V_VT(&left
) = VT_BSTR
;
5688 V_VT(&right
) = VT_BSTR
;
5689 V_VT(&expected
) = VT_BSTR
;
5690 V_BSTR(&left
) = SysAllocString(sz_empty
);
5691 V_BSTR(&right
) = SysAllocString(sz_empty
);
5692 V_BSTR(&expected
)= SysAllocString(sz_empty
);
5693 hres
= pVarCat(&left
,&right
,&result
);
5694 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5696 ok(pVarCmp(&result
,&left
,lcid
,0) == VARCMP_EQ
,
5697 "VarCat: EMPTY concat with EMPTY did not return empty VT_BSTR\n");
5699 /* Restore original date format settings */
5700 SetLocaleInfo(lcid
,LOCALE_SSHORTDATE
,orig_date_format
);
5702 VariantClear(&left
);
5703 VariantClear(&right
);
5704 VariantClear(&result
);
5705 VariantClear(&expected
);
5707 /* Test boolean conversion */
5708 V_VT(&left
) = VT_BOOL
;
5709 V_BOOL(&left
) = VARIANT_TRUE
;
5710 V_VT(&right
) = VT_BSTR
;
5711 V_BSTR(&right
) = SysAllocStringLen(NULL
,0);
5712 hres
= pVarCat(&left
, &right
, &result
);
5713 ok(hres
== S_OK
, "VarCat failed: %08x\n", hres
);
5714 if(!strcmp_wa(V_BSTR(&result
), "True")) {
5715 V_VT(&right
) = VT_BOOL
;
5716 V_BOOL(&right
) = 100;
5717 hres
= pVarCat(&left
, &right
, &result
);
5718 ok(hres
== S_OK
, "VarCat failed: %08x\n", hres
);
5719 test_bstr_var(&result
, "TrueTrue");
5720 VariantClear(&result
);
5722 V_BOOL(&right
) = VARIANT_FALSE
;
5723 hres
= pVarCat(&left
, &right
, &result
);
5724 ok(hres
== S_OK
, "VarCat failed: %08x\n", hres
);
5725 test_bstr_var(&result
, "TrueFalse");
5726 VariantClear(&result
);
5728 skip("Got %s as True, assuming non-English locale\n", wine_dbgstr_w(V_BSTR(&result
)));
5732 static HRESULT (WINAPI
*pVarAnd
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
5734 #define VARAND(vt1,val1,vt2,val2,rvt,rval) \
5735 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
5736 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
5737 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
5738 test_var_call2( __LINE__, pVarAnd, &left, &right, &exp )
5740 #define VARANDCY(vt1,val1,val2,rvt,rval) \
5741 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
5742 V_VT(&right) = VT_CY; V_CY(&right).int64 = val2; \
5743 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
5744 test_var_call2( __LINE__, pVarAnd, &left, &right, &exp )
5746 /* Skip any type that is not defined or produces an error for every case */
5747 #define SKIPTESTAND(a) \
5748 if (a == VT_ERROR || a == VT_VARIANT || \
5749 a == VT_DISPATCH || a == VT_UNKNOWN || \
5750 a > VT_UINT || a == 15 /*not defined*/) \
5753 static void test_VarAnd(void)
5755 static const WCHAR szFalse
[] = { '#','F','A','L','S','E','#','\0' };
5756 static const WCHAR szTrue
[] = { '#','T','R','U','E','#','\0' };
5757 VARIANT left
, right
, exp
, result
;
5758 BSTR false_str
, true_str
;
5762 true_str
= SysAllocString(szTrue
);
5763 false_str
= SysAllocString(szFalse
);
5767 /* Test all possible flag/vt combinations & the resulting vt type */
5768 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
5770 VARTYPE leftvt
, rightvt
, resvt
;
5772 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
5774 SKIPTESTAND(leftvt
);
5776 /* Check if we need/have support for I8 and/or UI8 */
5777 if ((leftvt
== VT_I8
|| leftvt
== VT_UI8
) && !has_i8
)
5780 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
5783 SKIPTESTAND(rightvt
);
5785 /* Check if we need/have support for I8 and/or UI8 */
5786 if ((rightvt
== VT_I8
|| rightvt
== VT_UI8
) && !has_i8
)
5789 memset(&left
, 0, sizeof(left
));
5790 memset(&right
, 0, sizeof(right
));
5791 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
5792 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
5793 V_VT(&result
) = VT_EMPTY
;
5795 if ((leftvt
| ExtraFlags
[i
]) == VT_BSTR
)
5796 V_BSTR(&left
) = true_str
;
5797 if ((rightvt
| ExtraFlags
[i
]) == VT_BSTR
)
5798 V_BSTR(&right
) = true_str
;
5800 /* Native VarAnd always returns an error when using extra
5801 * flags or if the variant combination is I8 and INT.
5803 if ((leftvt
== VT_I8
&& rightvt
== VT_INT
) ||
5804 (leftvt
== VT_INT
&& rightvt
== VT_I8
) ||
5808 /* Determine return type */
5809 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
5811 else if (leftvt
== VT_I4
|| rightvt
== VT_I4
||
5812 leftvt
== VT_UINT
|| rightvt
== VT_UINT
||
5813 leftvt
== VT_INT
|| rightvt
== VT_INT
||
5814 leftvt
== VT_UINT
|| rightvt
== VT_UINT
||
5815 leftvt
== VT_R4
|| rightvt
== VT_R4
||
5816 leftvt
== VT_R8
|| rightvt
== VT_R8
||
5817 leftvt
== VT_CY
|| rightvt
== VT_CY
||
5818 leftvt
== VT_DATE
|| rightvt
== VT_DATE
||
5819 leftvt
== VT_I1
|| rightvt
== VT_I1
||
5820 leftvt
== VT_UI2
|| rightvt
== VT_UI2
||
5821 leftvt
== VT_UI4
|| rightvt
== VT_UI4
||
5822 leftvt
== VT_UI8
|| rightvt
== VT_UI8
||
5823 leftvt
== VT_DECIMAL
|| rightvt
== VT_DECIMAL
)
5825 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
||
5826 leftvt
== VT_I2
|| rightvt
== VT_I2
||
5827 leftvt
== VT_EMPTY
|| rightvt
== VT_EMPTY
)
5828 if ((leftvt
== VT_NULL
&& rightvt
== VT_UI1
) ||
5829 (leftvt
== VT_UI1
&& rightvt
== VT_NULL
) ||
5830 (leftvt
== VT_UI1
&& rightvt
== VT_UI1
))
5834 else if (leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
||
5835 (leftvt
== VT_BSTR
&& rightvt
== VT_BSTR
))
5837 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
||
5838 leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
)
5843 hres
= pVarAnd(&left
, &right
, &result
);
5845 /* Check expected HRESULT and if result variant type is correct */
5847 ok (hres
== DISP_E_BADVARTYPE
|| hres
== DISP_E_TYPEMISMATCH
,
5848 "VarAnd: %s|0x%X, %s|0x%X: got vt %s hr 0x%X\n",
5849 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
],
5850 vtstr(V_VT(&result
)), hres
);
5852 ok (hres
== S_OK
&& resvt
== V_VT(&result
),
5853 "VarAnd: %s|0x%X, %s|0x%X: expected vt %s hr 0x%X, got vt %s hr 0x%X\n",
5854 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
], vtstr(resvt
),
5855 S_OK
, vtstr(V_VT(&result
)), hres
);
5861 * Test returned values. Since we know the returned type is correct
5862 * and that we handle all combinations of invalid types, just check
5863 * that good type combinations produce the desired value.
5864 * FIXME: Test VT_DECIMAL
5866 VARAND(EMPTY
,0,EMPTY
,0,I2
,0);
5867 VARAND(EMPTY
,1,EMPTY
,0,I2
,0);
5868 VARAND(EMPTY
,1,EMPTY
,1,I2
,0);
5869 VARAND(EMPTY
,0,NULL
,0,I2
,0);
5870 VARAND(EMPTY
,1,NULL
,0,I2
,0);
5871 VARAND(EMPTY
,1,NULL
,1,I2
,0);
5872 VARAND(EMPTY
,0,I1
,0,I4
,0);
5873 VARAND(EMPTY
,0,I1
,1,I4
,0);
5874 VARAND(EMPTY
,1,I1
,1,I4
,0);
5875 VARAND(EMPTY
,0,UI1
,0,I2
,0);
5876 VARAND(EMPTY
,0,UI1
,1,I2
,0);
5877 VARAND(EMPTY
,1,UI1
,1,I2
,0);
5878 VARAND(EMPTY
,0,I2
,0,I2
,0);
5879 VARAND(EMPTY
,0,I2
,1,I2
,0);
5880 VARAND(EMPTY
,1,I2
,1,I2
,0);
5881 VARAND(EMPTY
,0,UI2
,0,I4
,0);
5882 VARAND(EMPTY
,0,UI2
,1,I4
,0);
5883 VARAND(EMPTY
,1,UI2
,1,I4
,0);
5884 VARAND(EMPTY
,0,I4
,0,I4
,0);
5885 VARAND(EMPTY
,0,I4
,1,I4
,0);
5886 VARAND(EMPTY
,1,I4
,1,I4
,0);
5887 VARAND(EMPTY
,0,UI4
,0,I4
,0);
5888 VARAND(EMPTY
,0,UI4
,1,I4
,0);
5889 VARAND(EMPTY
,1,UI4
,1,I4
,0);
5892 VARAND(EMPTY
,0,I8
,0,I8
,0);
5893 VARAND(EMPTY
,0,I8
,1,I8
,0);
5894 VARAND(EMPTY
,1,I8
,1,I8
,0);
5895 VARAND(EMPTY
,0,UI8
,0,I4
,0);
5896 VARAND(EMPTY
,0,UI8
,1,I4
,0);
5897 VARAND(EMPTY
,1,UI8
,1,I4
,0);
5899 VARAND(EMPTY
,0,INT
,0,I4
,0);
5900 VARAND(EMPTY
,0,INT
,1,I4
,0);
5901 VARAND(EMPTY
,1,INT
,1,I4
,0);
5902 VARAND(EMPTY
,0,UINT
,0,I4
,0);
5903 VARAND(EMPTY
,0,UINT
,1,I4
,0);
5904 VARAND(EMPTY
,1,UINT
,1,I4
,0);
5905 VARAND(EMPTY
,0,BOOL
,0,I2
,0);
5906 VARAND(EMPTY
,0,BOOL
,1,I2
,0);
5907 VARAND(EMPTY
,1,BOOL
,1,I2
,0);
5908 VARAND(EMPTY
,0,R4
,0,I4
,0);
5909 VARAND(EMPTY
,0,R4
,1,I4
,0);
5910 VARAND(EMPTY
,1,R4
,1,I4
,0);
5911 VARAND(EMPTY
,0,R8
,0,I4
,0);
5912 VARAND(EMPTY
,0,R8
,1,I4
,0);
5913 VARAND(EMPTY
,1,R8
,1,I4
,0);
5914 VARAND(EMPTY
,0,BSTR
,false_str
,I2
,0);
5915 VARAND(EMPTY
,0,BSTR
,true_str
,I2
,0);
5916 VARANDCY(EMPTY
,0,10000,I4
,0);
5918 /* NULL OR 0 = NULL. NULL OR n = n */
5919 VARAND(NULL
,0,NULL
,0,NULL
,0);
5920 VARAND(NULL
,1,NULL
,0,NULL
,0);
5921 VARAND(NULL
,0,I1
,0,I4
,0);
5922 VARAND(NULL
,0,I1
,1,NULL
,0);
5923 VARAND(NULL
,0,UI1
,0,UI1
,0);
5924 VARAND(NULL
,0,UI1
,1,NULL
,0);
5925 VARAND(NULL
,0,I2
,0,I2
,0);
5926 VARAND(NULL
,0,I2
,1,NULL
,0);
5927 VARAND(NULL
,0,UI2
,0,I4
,0);
5928 VARAND(NULL
,0,UI2
,1,NULL
,0);
5929 VARAND(NULL
,0,I4
,0,I4
,0);
5930 VARAND(NULL
,0,I4
,1,NULL
,0);
5931 VARAND(NULL
,0,UI4
,0,I4
,0);
5932 VARAND(NULL
,0,UI4
,1,NULL
,0);
5935 VARAND(NULL
,0,I8
,0,I8
,0);
5936 VARAND(NULL
,0,I8
,1,NULL
,0);
5937 VARAND(NULL
,0,UI8
,0,I4
,0);
5938 VARAND(NULL
,0,UI8
,1,NULL
,0);
5940 VARAND(NULL
,0,INT
,0,I4
,0);
5941 VARAND(NULL
,0,INT
,1,NULL
,0);
5942 VARAND(NULL
,0,UINT
,0,I4
,0);
5943 VARAND(NULL
,0,UINT
,1,NULL
,0);
5944 VARAND(NULL
,0,BOOL
,0,BOOL
,0);
5945 VARAND(NULL
,0,BOOL
,1,NULL
,0);
5946 VARAND(NULL
,0,R4
,0,I4
,0);
5947 VARAND(NULL
,0,R4
,1,NULL
,0);
5948 VARAND(NULL
,0,R8
,0,I4
,0);
5949 VARAND(NULL
,0,R8
,1,NULL
,0);
5950 VARAND(NULL
,0,BSTR
,false_str
,BOOL
,0);
5951 VARAND(NULL
,0,BSTR
,true_str
,NULL
,VARIANT_FALSE
);
5952 VARANDCY(NULL
,0,10000,NULL
,0);
5953 VARANDCY(NULL
,0,0,I4
,0);
5954 VARAND(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
);
5955 VARAND(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_FALSE
);
5956 VARAND(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
);
5957 VARAND(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_FALSE
);
5959 /* Assume x,y & y,x are the same from now on to reduce the number of tests */
5960 VARAND(BOOL
,VARIANT_TRUE
,I1
,-1,I4
,-1);
5961 VARAND(BOOL
,VARIANT_TRUE
,I1
,0,I4
,0);
5962 VARAND(BOOL
,VARIANT_FALSE
,I1
,0,I4
,0);
5963 VARAND(BOOL
,VARIANT_TRUE
,UI1
,255,I2
,255);
5964 VARAND(BOOL
,VARIANT_TRUE
,UI1
,0,I2
,0);
5965 VARAND(BOOL
,VARIANT_FALSE
,UI1
,0,I2
,0);
5966 VARAND(BOOL
,VARIANT_TRUE
,I2
,-1,I2
,-1);
5967 VARAND(BOOL
,VARIANT_TRUE
,I2
,0,I2
,0);
5968 VARAND(BOOL
,VARIANT_FALSE
,I2
,0,I2
,0);
5969 VARAND(BOOL
,VARIANT_TRUE
,UI2
,65535,I4
,65535);
5970 VARAND(BOOL
,VARIANT_TRUE
,UI2
,0,I4
,0);
5971 VARAND(BOOL
,VARIANT_FALSE
,UI2
,0,I4
,0);
5972 VARAND(BOOL
,VARIANT_TRUE
,I4
,-1,I4
,-1);
5973 VARAND(BOOL
,VARIANT_TRUE
,I4
,0,I4
,0);
5974 VARAND(BOOL
,VARIANT_FALSE
,I4
,0,I4
,0);
5975 VARAND(BOOL
,VARIANT_TRUE
,UI4
,0xffffffff,I4
,-1);
5976 VARAND(BOOL
,VARIANT_TRUE
,UI4
,0,I4
,0);
5977 VARAND(BOOL
,VARIANT_FALSE
,UI4
,0,I4
,0);
5978 VARAND(BOOL
,VARIANT_TRUE
,R4
,-1,I4
,-1);
5979 VARAND(BOOL
,VARIANT_TRUE
,R4
,0,I4
,0);
5980 VARAND(BOOL
,VARIANT_FALSE
,R4
,0,I4
,0);
5981 VARAND(BOOL
,VARIANT_TRUE
,R8
,-1,I4
,-1);
5982 VARAND(BOOL
,VARIANT_TRUE
,R8
,0,I4
,0);
5983 VARAND(BOOL
,VARIANT_FALSE
,R8
,0,I4
,0);
5984 VARAND(BOOL
,VARIANT_TRUE
,DATE
,-1,I4
,-1);
5985 VARAND(BOOL
,VARIANT_TRUE
,DATE
,0,I4
,0);
5986 VARAND(BOOL
,VARIANT_FALSE
,DATE
,0,I4
,0);
5989 VARAND(BOOL
,VARIANT_TRUE
,I8
,-1,I8
,-1);
5990 VARAND(BOOL
,VARIANT_TRUE
,I8
,0,I8
,0);
5991 VARAND(BOOL
,VARIANT_FALSE
,I8
,0,I8
,0);
5992 VARAND(BOOL
,VARIANT_TRUE
,UI8
,0,I4
,0);
5993 VARAND(BOOL
,VARIANT_FALSE
,UI8
,0,I4
,0);
5995 VARAND(BOOL
,VARIANT_TRUE
,INT
,-1,I4
,-1);
5996 VARAND(BOOL
,VARIANT_TRUE
,INT
,0,I4
,0);
5997 VARAND(BOOL
,VARIANT_FALSE
,INT
,0,I4
,0);
5998 VARAND(BOOL
,VARIANT_TRUE
,UINT
,0xffffffff,I4
,-1);
5999 VARAND(BOOL
,VARIANT_TRUE
,UINT
,0,I4
,0);
6000 VARAND(BOOL
,VARIANT_FALSE
,UINT
,0,I4
,0);
6001 VARAND(BOOL
,VARIANT_FALSE
,BSTR
,false_str
,BOOL
,VARIANT_FALSE
);
6002 VARAND(BOOL
,VARIANT_TRUE
,BSTR
,false_str
,BOOL
,VARIANT_FALSE
);
6003 VARAND(BOOL
,VARIANT_FALSE
,BSTR
,true_str
,BOOL
,VARIANT_FALSE
);
6004 VARAND(BOOL
,VARIANT_TRUE
,BSTR
,true_str
,BOOL
,VARIANT_TRUE
);
6005 VARANDCY(BOOL
,VARIANT_TRUE
,10000,I4
,1);
6006 VARANDCY(BOOL
,VARIANT_TRUE
,0,I4
,0);
6007 VARANDCY(BOOL
,VARIANT_FALSE
,0,I4
,0);
6008 VARAND(I1
,-1,I1
,-1,I4
,-1);
6009 VARAND(I1
,-1,I1
,0,I4
,0);
6010 VARAND(I1
,0,I1
,0,I4
,0);
6011 VARAND(I1
,-1,UI1
,255,I4
,255);
6012 VARAND(I1
,-1,UI1
,0,I4
,0);
6013 VARAND(I1
,0,UI1
,0,I4
,0);
6014 VARAND(I1
,-1,I2
,-1,I4
,-1);
6015 VARAND(I1
,-1,I2
,0,I4
,0);
6016 VARAND(I1
,0,I2
,0,I4
,0);
6017 VARAND(I1
,-1,UI2
,65535,I4
,65535);
6018 VARAND(I1
,-1,UI2
,0,I4
,0);
6019 VARAND(I1
,0,UI2
,0,I4
,0);
6020 VARAND(I1
,-1,I4
,-1,I4
,-1);
6021 VARAND(I1
,-1,I4
,0,I4
,0);
6022 VARAND(I1
,0,I4
,0,I4
,0);
6023 VARAND(I1
,-1,UI4
,0xffffffff,I4
,-1);
6024 VARAND(I1
,-1,UI4
,0,I4
,0);
6025 VARAND(I1
,0,UI4
,0,I4
,0);
6026 VARAND(I1
,-1,R4
,-1,I4
,-1);
6027 VARAND(I1
,-1,R4
,0,I4
,0);
6028 VARAND(I1
,0,R4
,0,I4
,0);
6029 VARAND(I1
,-1,R8
,-1,I4
,-1);
6030 VARAND(I1
,-1,R8
,0,I4
,0);
6031 VARAND(I1
,0,R8
,0,I4
,0);
6032 VARAND(I1
,-1,DATE
,-1,I4
,-1);
6033 VARAND(I1
,-1,DATE
,0,I4
,0);
6034 VARAND(I1
,0,DATE
,0,I4
,0);
6037 VARAND(I1
,-1,I8
,-1,I8
,-1);
6038 VARAND(I1
,-1,I8
,0,I8
,0);
6039 VARAND(I1
,0,I8
,0,I8
,0);
6040 VARAND(I1
,-1,UI8
,0,I4
,0);
6041 VARAND(I1
,0,UI8
,0,I4
,0);
6043 VARAND(I1
,-1,INT
,-1,I4
,-1);
6044 VARAND(I1
,-1,INT
,0,I4
,0);
6045 VARAND(I1
,0,INT
,0,I4
,0);
6046 VARAND(I1
,-1,UINT
,0xffffffff,I4
,-1);
6047 VARAND(I1
,-1,UINT
,0,I4
,0);
6048 VARAND(I1
,0,UINT
,0,I4
,0);
6049 VARAND(I1
,0,BSTR
,false_str
,I4
,0);
6050 VARAND(I1
,-1,BSTR
,false_str
,I4
,0);
6051 VARAND(I1
,0,BSTR
,true_str
,I4
,0);
6052 VARAND(I1
,-1,BSTR
,true_str
,I4
,-1);
6053 VARANDCY(I1
,-1,10000,I4
,1);
6054 VARANDCY(I1
,-1,0,I4
,0);
6055 VARANDCY(I1
,0,0,I4
,0);
6057 VARAND(UI1
,255,UI1
,255,UI1
,255);
6058 VARAND(UI1
,255,UI1
,0,UI1
,0);
6059 VARAND(UI1
,0,UI1
,0,UI1
,0);
6060 VARAND(UI1
,255,I2
,-1,I2
,255);
6061 VARAND(UI1
,255,I2
,0,I2
,0);
6062 VARAND(UI1
,0,I2
,0,I2
,0);
6063 VARAND(UI1
,255,UI2
,65535,I4
,255);
6064 VARAND(UI1
,255,UI2
,0,I4
,0);
6065 VARAND(UI1
,0,UI2
,0,I4
,0);
6066 VARAND(UI1
,255,I4
,-1,I4
,255);
6067 VARAND(UI1
,255,I4
,0,I4
,0);
6068 VARAND(UI1
,0,I4
,0,I4
,0);
6069 VARAND(UI1
,255,UI4
,0xffffffff,I4
,255);
6070 VARAND(UI1
,255,UI4
,0,I4
,0);
6071 VARAND(UI1
,0,UI4
,0,I4
,0);
6072 VARAND(UI1
,255,R4
,-1,I4
,255);
6073 VARAND(UI1
,255,R4
,0,I4
,0);
6074 VARAND(UI1
,0,R4
,0,I4
,0);
6075 VARAND(UI1
,255,R8
,-1,I4
,255);
6076 VARAND(UI1
,255,R8
,0,I4
,0);
6077 VARAND(UI1
,0,R8
,0,I4
,0);
6078 VARAND(UI1
,255,DATE
,-1,I4
,255);
6079 VARAND(UI1
,255,DATE
,0,I4
,0);
6080 VARAND(UI1
,0,DATE
,0,I4
,0);
6083 VARAND(UI1
,255,I8
,-1,I8
,255);
6084 VARAND(UI1
,255,I8
,0,I8
,0);
6085 VARAND(UI1
,0,I8
,0,I8
,0);
6086 VARAND(UI1
,255,UI8
,0,I4
,0);
6087 VARAND(UI1
,0,UI8
,0,I4
,0);
6089 VARAND(UI1
,255,INT
,-1,I4
,255);
6090 VARAND(UI1
,255,INT
,0,I4
,0);
6091 VARAND(UI1
,0,INT
,0,I4
,0);
6092 VARAND(UI1
,255,UINT
,0xffffffff,I4
,255);
6093 VARAND(UI1
,255,UINT
,0,I4
,0);
6094 VARAND(UI1
,0,UINT
,0,I4
,0);
6095 VARAND(UI1
,0,BSTR
,false_str
,I2
,0);
6096 VARAND(UI1
,255,BSTR
,false_str
,I2
,0);
6097 VARAND(UI1
,0,BSTR
,true_str
,I2
,0);
6098 VARAND(UI1
,255,BSTR
,true_str
,I2
,255);
6099 VARANDCY(UI1
,255,10000,I4
,1);
6100 VARANDCY(UI1
,255,0,I4
,0);
6101 VARANDCY(UI1
,0,0,I4
,0);
6103 VARAND(I2
,-1,I2
,-1,I2
,-1);
6104 VARAND(I2
,-1,I2
,0,I2
,0);
6105 VARAND(I2
,0,I2
,0,I2
,0);
6106 VARAND(I2
,-1,UI2
,65535,I4
,65535);
6107 VARAND(I2
,-1,UI2
,0,I4
,0);
6108 VARAND(I2
,0,UI2
,0,I4
,0);
6109 VARAND(I2
,-1,I4
,-1,I4
,-1);
6110 VARAND(I2
,-1,I4
,0,I4
,0);
6111 VARAND(I2
,0,I4
,0,I4
,0);
6112 VARAND(I2
,-1,UI4
,0xffffffff,I4
,-1);
6113 VARAND(I2
,-1,UI4
,0,I4
,0);
6114 VARAND(I2
,0,UI4
,0,I4
,0);
6115 VARAND(I2
,-1,R4
,-1,I4
,-1);
6116 VARAND(I2
,-1,R4
,0,I4
,0);
6117 VARAND(I2
,0,R4
,0,I4
,0);
6118 VARAND(I2
,-1,R8
,-1,I4
,-1);
6119 VARAND(I2
,-1,R8
,0,I4
,0);
6120 VARAND(I2
,0,R8
,0,I4
,0);
6121 VARAND(I2
,-1,DATE
,-1,I4
,-1);
6122 VARAND(I2
,-1,DATE
,0,I4
,0);
6123 VARAND(I2
,0,DATE
,0,I4
,0);
6126 VARAND(I2
,-1,I8
,-1,I8
,-1);
6127 VARAND(I2
,-1,I8
,0,I8
,0);
6128 VARAND(I2
,0,I8
,0,I8
,0);
6129 VARAND(I2
,-1,UI8
,0,I4
,0);
6130 VARAND(I2
,0,UI8
,0,I4
,0);
6132 VARAND(I2
,-1,INT
,-1,I4
,-1);
6133 VARAND(I2
,-1,INT
,0,I4
,0);
6134 VARAND(I2
,0,INT
,0,I4
,0);
6135 VARAND(I2
,-1,UINT
,0xffffffff,I4
,-1);
6136 VARAND(I2
,-1,UINT
,0,I4
,0);
6137 VARAND(I2
,0,UINT
,0,I4
,0);
6138 VARAND(I2
,0,BSTR
,false_str
,I2
,0);
6139 VARAND(I2
,-1,BSTR
,false_str
,I2
,0);
6140 VARAND(I2
,0,BSTR
,true_str
,I2
,0);
6141 VARAND(I2
,-1,BSTR
,true_str
,I2
,-1);
6142 VARANDCY(I2
,-1,10000,I4
,1);
6143 VARANDCY(I2
,-1,0,I4
,0);
6144 VARANDCY(I2
,0,0,I4
,0);
6146 VARAND(UI2
,65535,UI2
,65535,I4
,65535);
6147 VARAND(UI2
,65535,UI2
,0,I4
,0);
6148 VARAND(UI2
,0,UI2
,0,I4
,0);
6149 VARAND(UI2
,65535,I4
,-1,I4
,65535);
6150 VARAND(UI2
,65535,I4
,0,I4
,0);
6151 VARAND(UI2
,0,I4
,0,I4
,0);
6152 VARAND(UI2
,65535,UI4
,0xffffffff,I4
,65535);
6153 VARAND(UI2
,65535,UI4
,0,I4
,0);
6154 VARAND(UI2
,0,UI4
,0,I4
,0);
6155 VARAND(UI2
,65535,R4
,-1,I4
,65535);
6156 VARAND(UI2
,65535,R4
,0,I4
,0);
6157 VARAND(UI2
,0,R4
,0,I4
,0);
6158 VARAND(UI2
,65535,R8
,-1,I4
,65535);
6159 VARAND(UI2
,65535,R8
,0,I4
,0);
6160 VARAND(UI2
,0,R8
,0,I4
,0);
6161 VARAND(UI2
,65535,DATE
,-1,I4
,65535);
6162 VARAND(UI2
,65535,DATE
,0,I4
,0);
6163 VARAND(UI2
,0,DATE
,0,I4
,0);
6166 VARAND(UI2
,65535,I8
,-1,I8
,65535);
6167 VARAND(UI2
,65535,I8
,0,I8
,0);
6168 VARAND(UI2
,0,I8
,0,I8
,0);
6169 VARAND(UI2
,65535,UI8
,0,I4
,0);
6170 VARAND(UI2
,0,UI8
,0,I4
,0);
6172 VARAND(UI2
,65535,INT
,-1,I4
,65535);
6173 VARAND(UI2
,65535,INT
,0,I4
,0);
6174 VARAND(UI2
,0,INT
,0,I4
,0);
6175 VARAND(UI2
,65535,UINT
,0xffffffff,I4
,65535);
6176 VARAND(UI2
,65535,UINT
,0,I4
,0);
6177 VARAND(UI2
,0,UINT
,0,I4
,0);
6178 VARAND(UI2
,0,BSTR
,false_str
,I4
,0);
6179 VARAND(UI2
,65535,BSTR
,false_str
,I4
,0);
6180 VARAND(UI2
,0,BSTR
,true_str
,I4
,0);
6181 VARAND(UI2
,65535,BSTR
,true_str
,I4
,65535);
6182 VARANDCY(UI2
,65535,10000,I4
,1);
6183 VARANDCY(UI2
,65535,0,I4
,0);
6184 VARANDCY(UI2
,0,0,I4
,0);
6186 VARAND(I4
,-1,I4
,-1,I4
,-1);
6187 VARAND(I4
,-1,I4
,0,I4
,0);
6188 VARAND(I4
,0,I4
,0,I4
,0);
6189 VARAND(I4
,-1,UI4
,0xffffffff,I4
,-1);
6190 VARAND(I4
,-1,UI4
,0,I4
,0);
6191 VARAND(I4
,0,UI4
,0,I4
,0);
6192 VARAND(I4
,-1,R4
,-1,I4
,-1);
6193 VARAND(I4
,-1,R4
,0,I4
,0);
6194 VARAND(I4
,0,R4
,0,I4
,0);
6195 VARAND(I4
,-1,R8
,-1,I4
,-1);
6196 VARAND(I4
,-1,R8
,0,I4
,0);
6197 VARAND(I4
,0,R8
,0,I4
,0);
6198 VARAND(I4
,-1,DATE
,-1,I4
,-1);
6199 VARAND(I4
,-1,DATE
,0,I4
,0);
6200 VARAND(I4
,0,DATE
,0,I4
,0);
6203 VARAND(I4
,-1,I8
,-1,I8
,-1);
6204 VARAND(I4
,-1,I8
,0,I8
,0);
6205 VARAND(I4
,0,I8
,0,I8
,0);
6206 VARAND(I4
,-1,UI8
,0,I4
,0);
6207 VARAND(I4
,0,UI8
,0,I4
,0);
6209 VARAND(I4
,-1,INT
,-1,I4
,-1);
6210 VARAND(I4
,-1,INT
,0,I4
,0);
6211 VARAND(I4
,0,INT
,0,I4
,0);
6212 VARAND(I4
,-1,UINT
,0xffffffff,I4
,-1);
6213 VARAND(I4
,-1,UINT
,0,I4
,0);
6214 VARAND(I4
,0,UINT
,0,I4
,0);
6215 VARAND(I4
,0,BSTR
,false_str
,I4
,0);
6216 VARAND(I4
,-1,BSTR
,false_str
,I4
,0);
6217 VARAND(I4
,0,BSTR
,true_str
,I4
,0);
6218 VARAND(I4
,-1,BSTR
,true_str
,I4
,-1);
6219 VARANDCY(I4
,-1,10000,I4
,1);
6220 VARANDCY(I4
,-1,0,I4
,0);
6221 VARANDCY(I4
,0,0,I4
,0);
6223 VARAND(UI4
,0xffffffff,UI4
,0xffffffff,I4
,-1);
6224 VARAND(UI4
,0xffffffff,UI4
,0,I4
,0);
6225 VARAND(UI4
,0,UI4
,0,I4
,0);
6226 VARAND(UI4
,0xffffffff,R4
,-1,I4
,-1);
6227 VARAND(UI4
,0xffffffff,R4
,0,I4
,0);
6228 VARAND(UI4
,0,R4
,0,I4
,0);
6229 VARAND(UI4
,0xffffffff,R8
,-1,I4
,-1);
6230 VARAND(UI4
,0xffffffff,R8
,0,I4
,0);
6231 VARAND(UI4
,0,R8
,0,I4
,0);
6232 VARAND(UI4
,0xffffffff,DATE
,-1,I4
,-1);
6233 VARAND(UI4
,0xffffffff,DATE
,0,I4
,0);
6234 VARAND(UI4
,0,DATE
,0,I4
,0);
6237 VARAND(UI4
,0xffffffff,I8
,0,I8
,0);
6238 VARAND(UI4
,0,I8
,0,I8
,0);
6239 VARAND(UI4
,0xffffffff,UI8
,0,I4
,0);
6240 VARAND(UI4
,0,UI8
,0,I4
,0);
6242 VARAND(UI4
,0xffffffff,INT
,-1,I4
,-1);
6243 VARAND(UI4
,0xffffffff,INT
,0,I4
,0);
6244 VARAND(UI4
,0,INT
,0,I4
,0);
6245 VARAND(UI4
,0xffffffff,UINT
,0xffffffff,I4
,-1);
6246 VARAND(UI4
,0xffffffff,UINT
,0,I4
,0);
6247 VARAND(UI4
,0,UINT
,0,I4
,0);
6248 VARAND(UI4
,0,BSTR
,false_str
,I4
,0);
6249 VARAND(UI4
,0xffffffff,BSTR
,false_str
,I4
,0);
6250 VARAND(UI4
,0,BSTR
,true_str
,I4
,0);
6251 VARAND(UI4
,0xffffffff,BSTR
,true_str
,I4
,-1);
6252 VARANDCY(UI4
,0xffffffff,10000,I4
,1);
6253 VARANDCY(UI4
,0xffffffff,0,I4
,0);
6254 VARANDCY(UI4
,0,0,I4
,0);
6256 VARAND(R4
,-1,R4
,-1,I4
,-1);
6257 VARAND(R4
,-1,R4
,0,I4
,0);
6258 VARAND(R4
,0,R4
,0,I4
,0);
6259 VARAND(R4
,-1,R8
,-1,I4
,-1);
6260 VARAND(R4
,-1,R8
,0,I4
,0);
6261 VARAND(R4
,0,R8
,0,I4
,0);
6262 VARAND(R4
,-1,DATE
,-1,I4
,-1);
6263 VARAND(R4
,-1,DATE
,0,I4
,0);
6264 VARAND(R4
,0,DATE
,0,I4
,0);
6267 VARAND(R4
,-1,I8
,-1,I8
,-1);
6268 VARAND(R4
,-1,I8
,0,I8
,0);
6269 VARAND(R4
,0,I8
,0,I8
,0);
6270 VARAND(R4
,-1,UI8
,0,I4
,0);
6271 VARAND(R4
,0,UI8
,0,I4
,0);
6273 VARAND(R4
,-1,INT
,-1,I4
,-1);
6274 VARAND(R4
,-1,INT
,0,I4
,0);
6275 VARAND(R4
,0,INT
,0,I4
,0);
6276 VARAND(R4
,-1,UINT
,0xffffffff,I4
,-1);
6277 VARAND(R4
,-1,UINT
,0,I4
,0);
6278 VARAND(R4
,0,UINT
,0,I4
,0);
6279 VARAND(R4
,0,BSTR
,false_str
,I4
,0);
6280 VARAND(R4
,-1,BSTR
,false_str
,I4
,0);
6281 VARAND(R4
,0,BSTR
,true_str
,I4
,0);
6282 VARAND(R4
,-1,BSTR
,true_str
,I4
,-1);
6283 VARANDCY(R4
,-1,10000,I4
,1);
6284 VARANDCY(R4
,-1,0,I4
,0);
6285 VARANDCY(R4
,0,0,I4
,0);
6287 VARAND(R8
,-1,R8
,-1,I4
,-1);
6288 VARAND(R8
,-1,R8
,0,I4
,0);
6289 VARAND(R8
,0,R8
,0,I4
,0);
6290 VARAND(R8
,-1,DATE
,-1,I4
,-1);
6291 VARAND(R8
,-1,DATE
,0,I4
,0);
6292 VARAND(R8
,0,DATE
,0,I4
,0);
6295 VARAND(R8
,-1,I8
,-1,I8
,-1);
6296 VARAND(R8
,-1,I8
,0,I8
,0);
6297 VARAND(R8
,0,I8
,0,I8
,0);
6298 VARAND(R8
,-1,UI8
,0,I4
,0);
6299 VARAND(R8
,0,UI8
,0,I4
,0);
6301 VARAND(R8
,-1,INT
,-1,I4
,-1);
6302 VARAND(R8
,-1,INT
,0,I4
,0);
6303 VARAND(R8
,0,INT
,0,I4
,0);
6304 VARAND(R8
,-1,UINT
,0xffffffff,I4
,-1);
6305 VARAND(R8
,-1,UINT
,0,I4
,0);
6306 VARAND(R8
,0,UINT
,0,I4
,0);
6307 VARAND(R8
,0,BSTR
,false_str
,I4
,0);
6308 VARAND(R8
,-1,BSTR
,false_str
,I4
,0);
6309 VARAND(R8
,0,BSTR
,true_str
,I4
,0);
6310 VARAND(R8
,-1,BSTR
,true_str
,I4
,-1);
6311 VARANDCY(R8
,-1,10000,I4
,1);
6312 VARANDCY(R8
,-1,0,I4
,0);
6313 VARANDCY(R8
,0,0,I4
,0);
6315 VARAND(DATE
,-1,DATE
,-1,I4
,-1);
6316 VARAND(DATE
,-1,DATE
,0,I4
,0);
6317 VARAND(DATE
,0,DATE
,0,I4
,0);
6320 VARAND(DATE
,-1,I8
,-1,I8
,-1);
6321 VARAND(DATE
,-1,I8
,0,I8
,0);
6322 VARAND(DATE
,0,I8
,0,I8
,0);
6323 VARAND(DATE
,-1,UI8
,0,I4
,0);
6324 VARAND(DATE
,0,UI8
,0,I4
,0);
6326 VARAND(DATE
,-1,INT
,-1,I4
,-1);
6327 VARAND(DATE
,-1,INT
,0,I4
,0);
6328 VARAND(DATE
,0,INT
,0,I4
,0);
6329 VARAND(DATE
,-1,UINT
,0xffffffff,I4
,-1);
6330 VARAND(DATE
,-1,UINT
,0,I4
,0);
6331 VARAND(DATE
,0,UINT
,0,I4
,0);
6332 VARAND(DATE
,0,BSTR
,false_str
,I4
,0);
6333 VARAND(DATE
,-1,BSTR
,false_str
,I4
,0);
6334 VARAND(DATE
,0,BSTR
,true_str
,I4
,0);
6335 VARAND(DATE
,-1,BSTR
,true_str
,I4
,-1);
6336 VARANDCY(DATE
,-1,10000,I4
,1);
6337 VARANDCY(DATE
,-1,0,I4
,0);
6338 VARANDCY(DATE
,0,0,I4
,0);
6342 VARAND(I8
,-1,I8
,-1,I8
,-1);
6343 VARAND(I8
,-1,I8
,0,I8
,0);
6344 VARAND(I8
,0,I8
,0,I8
,0);
6345 VARAND(I8
,-1,UI8
,0,I8
,0);
6346 VARAND(I8
,0,UI8
,0,I8
,0);
6347 VARAND(I8
,-1,UINT
,0,I8
,0);
6348 VARAND(I8
,0,UINT
,0,I8
,0);
6349 VARAND(I8
,0,BSTR
,false_str
,I8
,0);
6350 VARAND(I8
,-1,BSTR
,false_str
,I8
,0);
6351 VARAND(I8
,0,BSTR
,true_str
,I8
,0);
6352 VARAND(I8
,-1,BSTR
,true_str
,I8
,-1);
6353 VARANDCY(I8
,-1,10000,I8
,1);
6354 VARANDCY(I8
,-1,0,I8
,0);
6355 VARANDCY(I8
,0,0,I8
,0);
6357 VARAND(UI8
,0xffff,UI8
,0xffff,I4
,0xffff);
6358 VARAND(UI8
,0xffff,UI8
,0,I4
,0);
6359 VARAND(UI8
,0,UI8
,0,I4
,0);
6360 VARAND(UI8
,0xffff,INT
,-1,I4
,65535);
6361 VARAND(UI8
,0xffff,INT
,0,I4
,0);
6362 VARAND(UI8
,0,INT
,0,I4
,0);
6363 VARAND(UI8
,0xffff,UINT
,0xffff,I4
,0xffff);
6364 VARAND(UI8
,0xffff,UINT
,0,I4
,0);
6365 VARAND(UI8
,0,UINT
,0,I4
,0);
6366 VARAND(UI8
,0,BSTR
,false_str
,I4
,0);
6367 VARAND(UI8
,0xffff,BSTR
,false_str
,I4
,0);
6368 VARAND(UI8
,0,BSTR
,true_str
,I4
,0);
6369 VARAND(UI8
,0xffff,BSTR
,true_str
,I4
,65535);
6370 VARANDCY(UI8
,0xffff,10000,I4
,1);
6371 VARANDCY(UI8
,0xffff,0,I4
,0);
6372 VARANDCY(UI8
,0,0,I4
,0);
6375 VARAND(INT
,-1,INT
,-1,I4
,-1);
6376 VARAND(INT
,-1,INT
,0,I4
,0);
6377 VARAND(INT
,0,INT
,0,I4
,0);
6378 VARAND(INT
,-1,UINT
,0xffff,I4
,65535);
6379 VARAND(INT
,-1,UINT
,0,I4
,0);
6380 VARAND(INT
,0,UINT
,0,I4
,0);
6381 VARAND(INT
,0,BSTR
,false_str
,I4
,0);
6382 VARAND(INT
,-1,BSTR
,false_str
,I4
,0);
6383 VARAND(INT
,0,BSTR
,true_str
,I4
,0);
6384 VARAND(INT
,-1,BSTR
,true_str
,I4
,-1);
6385 VARANDCY(INT
,-1,10000,I4
,1);
6386 VARANDCY(INT
,-1,0,I4
,0);
6387 VARANDCY(INT
,0,0,I4
,0);
6389 VARAND(UINT
,0xffff,UINT
,0xffff,I4
,0xffff);
6390 VARAND(UINT
,0xffff,UINT
,0,I4
,0);
6391 VARAND(UINT
,0,UINT
,0,I4
,0);
6392 VARAND(UINT
,0,BSTR
,false_str
,I4
,0);
6393 VARAND(UINT
,0xffff,BSTR
, false_str
,I4
,0);
6394 VARAND(UINT
,0,BSTR
,true_str
,I4
,0);
6395 VARAND(UINT
,0xffff,BSTR
,true_str
,I4
,65535);
6396 VARANDCY(UINT
,0xffff,10000,I4
,1);
6397 VARANDCY(UINT
,0xffff,0,I4
,0);
6398 VARANDCY(UINT
,0,0,I4
,0);
6400 VARAND(BSTR
,false_str
,BSTR
,false_str
,BOOL
,0);
6401 VARAND(BSTR
,true_str
,BSTR
,false_str
,BOOL
,VARIANT_FALSE
);
6402 VARAND(BSTR
,true_str
,BSTR
,true_str
,BOOL
,VARIANT_TRUE
);
6403 VARANDCY(BSTR
,true_str
,10000,I4
,1);
6404 VARANDCY(BSTR
,false_str
,10000,I4
,0);
6406 SysFreeString(true_str
);
6407 SysFreeString(false_str
);
6410 static void test_cmp( int line
, LCID lcid
, UINT flags
, VARIANT
*left
, VARIANT
*right
, HRESULT result
)
6416 hres
= pVarCmp(left
,right
,lcid
,flags
);
6417 ok_(__FILE__
,line
)(hres
== result
, "VarCmp(%s,%s): expected 0x%x, got hres=0x%x\n",
6418 variantstr(left
), variantstr(right
), result
, hres
);
6420 static void test_cmpex( int line
, LCID lcid
, VARIANT
*left
, VARIANT
*right
,
6421 HRESULT res1
, HRESULT res2
, HRESULT res3
, HRESULT res4
)
6423 test_cmp( line
, lcid
, 0, left
, right
, res1
);
6424 V_VT(left
) |= VT_RESERVED
;
6425 test_cmp( line
, lcid
, 0, left
, right
, res2
);
6426 V_VT(left
) &= ~VT_RESERVED
;
6427 V_VT(right
) |= VT_RESERVED
;
6428 test_cmp( line
, lcid
, 0, left
, right
, res3
);
6429 V_VT(left
) |= VT_RESERVED
;
6430 test_cmp( line
, lcid
, 0, left
, right
, res4
);
6431 ok_(__FILE__
,line
)(V_VT(left
) & V_VT(right
) & VT_RESERVED
, "VT_RESERVED filtered out\n");
6434 /* ERROR from wingdi.h is interfering here */
6436 #define _VARCMP(vt1,val1,vtfl1,vt2,val2,vtfl2,lcid,flags,result) \
6437 V_##vt1(&left) = val1; V_VT(&left) = VT_##vt1 | vtfl1; \
6438 V_##vt2(&right) = val2; V_VT(&right) = VT_##vt2 | vtfl2; \
6439 test_cmp( __LINE__, lcid, flags, &left, &right, result )
6440 #define VARCMPEX(vt1,val1,vt2,val2,res1,res2,res3,res4) \
6441 V_##vt1(&left) = val1; V_VT(&left) = VT_##vt1; \
6442 V_##vt2(&right) = val2; V_VT(&right) = VT_##vt2; \
6443 test_cmpex( __LINE__, lcid, &left, &right, res1, res2, res3, res4 )
6444 #define VARCMP(vt1,val1,vt2,val2,result) \
6445 VARCMPEX(vt1,val1,vt2,val2,result,result,result,result)
6446 /* The above macros do not work for VT_NULL as NULL gets expanded first */
6447 #define V_NULL_ V_NULL
6448 #define VT_NULL_ VT_NULL
6450 static void test_VarCmp(void)
6452 VARIANT left
, right
;
6457 static const WCHAR szhuh
[] = {'h','u','h','?','\0'};
6458 static const WCHAR sz2cents
[] = {'2','c','e','n','t','s','\0'};
6459 static const WCHAR szempty
[] = {'\0'};
6460 static const WCHAR sz0
[] = {'0','\0'};
6461 static const WCHAR sz1
[] = {'1','\0'};
6462 static const WCHAR sz7
[] = {'7','\0'};
6463 static const WCHAR sz42
[] = {'4','2','\0'};
6464 static const WCHAR sz1neg
[] = {'-','1','\0'};
6465 static const WCHAR sz666neg
[] = {'-','6','6','6','\0'};
6466 static const WCHAR sz1few
[] = {'1','.','0','0','0','0','0','0','0','1','\0'};
6467 BSTR bstrhuh
, bstrempty
, bstr0
, bstr1
, bstr7
, bstr42
, bstr1neg
, bstr666neg
;
6468 BSTR bstr2cents
, bstr1few
;
6472 lcid
= MAKELCID(MAKELANGID(LANG_ENGLISH
,SUBLANG_ENGLISH_US
),SORT_DEFAULT
);
6473 bstrempty
= SysAllocString(szempty
);
6474 bstrhuh
= SysAllocString(szhuh
);
6475 bstr2cents
= SysAllocString(sz2cents
);
6476 bstr0
= SysAllocString(sz0
);
6477 bstr1
= SysAllocString(sz1
);
6478 bstr7
= SysAllocString(sz7
);
6479 bstr42
= SysAllocString(sz42
);
6480 bstr1neg
= SysAllocString(sz1neg
);
6481 bstr666neg
= SysAllocString(sz666neg
);
6482 bstr1few
= SysAllocString(sz1few
);
6484 /* Test all possible flag/vt combinations & the resulting vt type */
6485 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
6487 VARTYPE leftvt
, rightvt
;
6489 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
6494 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
6497 HRESULT expect
= VARCMP_EQ
;
6501 memset(&left
, 0, sizeof(left
));
6502 memset(&right
, 0, sizeof(right
));
6503 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
6504 if (leftvt
== VT_BSTR
) {
6505 V_BSTR(&left
) = bstr1neg
;
6506 if (ExtraFlags
[i
] & VT_RESERVED
)
6511 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
6512 if (rightvt
== VT_BSTR
) {
6513 V_BSTR(&right
) = bstr1neg
;
6514 if (ExtraFlags
[i
] & VT_RESERVED
)
6520 /* Don't ask me why but native VarCmp cannot handle:
6521 VT_I1, VT_UI2, VT_UI4, VT_UINT and VT_UI8.
6522 VT_INT is only supported as left variant. Go figure.
6523 Tested with DCOM98, Win2k, WinXP */
6524 if (ExtraFlags
[i
] & VT_ARRAY
|| ExtraFlags
[i
] & VT_BYREF
||
6525 !IsValidVariantClearVT(leftvt
, ExtraFlags
[i
] & ~VT_RESERVED
) ||
6526 !IsValidVariantClearVT(rightvt
, ExtraFlags
[i
] & ~VT_RESERVED
) ||
6527 leftvt
== VT_CLSID
|| rightvt
== VT_CLSID
||
6528 leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
||
6529 leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
||
6530 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
||
6531 leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
||
6532 leftvt
== VT_VARIANT
|| rightvt
== VT_VARIANT
||
6533 leftvt
== VT_I1
|| rightvt
== VT_I1
||
6534 leftvt
== VT_UI2
|| rightvt
== VT_UI2
||
6535 leftvt
== VT_UI4
|| rightvt
== VT_UI4
||
6536 leftvt
== VT_UI8
|| rightvt
== VT_UI8
||
6537 rightvt
== VT_INT
||
6538 leftvt
== VT_UINT
|| rightvt
== VT_UINT
) {
6542 if (leftvt
== VT_ERROR
&& rightvt
== VT_ERROR
&&
6543 !(ExtraFlags
[i
] & ~VT_RESERVED
)) {
6546 } else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
6547 expect
= VARCMP_NULL
;
6548 else if (leftvt
== VT_BSTR
&& rightvt
== VT_BSTR
)
6550 else if (leftvt
== VT_BSTR
&& rightvt
== VT_EMPTY
)
6552 else if (leftvt
== VT_EMPTY
&& rightvt
== VT_BSTR
)
6555 hres
= pVarCmp(&left
, &right
, LOCALE_USER_DEFAULT
, 0);
6557 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
6558 "VarCmp: %d|0x%X, %d|0x%X: Expected failure, got 0x%X\n",
6559 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], hres
);
6562 "VarCmp: %d|0x%X, %d|0x%X: Expected 0x%X, got 0x%X\n",
6563 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], expect
,
6570 /* VARCMP{,EX} run each 4 tests with a permutation of all possible
6571 input variants with (1) and without (0) VT_RESERVED set. The order
6572 of the permutations is (0,0); (1,0); (0,1); (1,1) */
6573 VARCMP(INT
,4711,I2
,4711,VARCMP_EQ
);
6574 VARCMP(INT
,4711,I2
,-4711,VARCMP_GT
);
6575 VARCMP(ERROR
,0,ERROR
,0,VARCMP_EQ
);
6576 VARCMP(ERROR
,0,UI1
,0,DISP_E_TYPEMISMATCH
);
6577 VARCMP(EMPTY
,0,EMPTY
,0,VARCMP_EQ
);
6578 VARCMP(I4
,1,R8
,1.0,VARCMP_EQ
);
6579 VARCMP(EMPTY
,19,I2
,0,VARCMP_EQ
);
6580 ok(V_EMPTY(&left
) == 19, "VT_EMPTY modified!\n");
6581 VARCMP(I4
,1,UI1
,1,VARCMP_EQ
);
6582 VARCMP(I2
,2,I2
,2,VARCMP_EQ
);
6583 VARCMP(I2
,1,I2
,2,VARCMP_LT
);
6584 VARCMP(I2
,2,I2
,1,VARCMP_GT
);
6585 VARCMP(I2
,2,EMPTY
,1,VARCMP_GT
);
6586 VARCMP(I2
,2,NULL_
,1,VARCMP_NULL
);
6588 /* BSTR handling, especially in conjunction with VT_RESERVED */
6589 VARCMP(BSTR
,bstr0
,NULL_
,0,VARCMP_NULL
);
6590 VARCMP(BSTR
,bstr0
,BSTR
,bstr0
,VARCMP_EQ
);
6591 VARCMP(BSTR
,bstrempty
,BSTR
,bstr0
,VARCMP_LT
);
6592 VARCMP(BSTR
,bstr7
,BSTR
,bstr0
,VARCMP_GT
);
6593 VARCMP(BSTR
,bstr7
,BSTR
,bstr1neg
,VARCMP_GT
);
6594 VARCMP(BSTR
,bstr0
,BSTR
,NULL
,VARCMP_GT
);
6595 VARCMP(BSTR
,NULL
,BSTR
,NULL
,VARCMP_EQ
);
6596 VARCMP(BSTR
,bstrempty
,BSTR
,NULL
,VARCMP_EQ
);
6597 VARCMP(BSTR
,NULL
,EMPTY
,0,VARCMP_EQ
);
6598 VARCMP(EMPTY
,0,BSTR
,NULL
,VARCMP_EQ
);
6599 VARCMP(EMPTY
,0,BSTR
,bstrempty
,VARCMP_EQ
);
6600 VARCMP(EMPTY
,1,BSTR
,bstrempty
,VARCMP_EQ
);
6601 VARCMP(BSTR
,bstr0
,EMPTY
,0,VARCMP_GT
);
6602 VARCMP(BSTR
,bstr42
,EMPTY
,0,VARCMP_GT
);
6603 VARCMPEX(BSTR
,bstrempty
,UI1
,0,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
6604 VARCMPEX(BSTR
,bstrempty
,I2
,-1,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
6605 VARCMPEX(I4
,0,BSTR
,bstrempty
,VARCMP_LT
,VARCMP_LT
,VARCMP_GT
,VARCMP_LT
);
6606 VARCMPEX(BSTR
,NULL
,UI1
,0,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
6607 VARCMPEX(I4
,7,BSTR
,NULL
,VARCMP_LT
,VARCMP_LT
,VARCMP_GT
,VARCMP_LT
);
6608 _VARCMP(BSTR
,(BSTR
)100,0,I2
,100,0,lcid
,0,VARCMP_GT
);
6609 VARCMPEX(BSTR
,bstr0
,UI1
,0,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_GT
);
6610 VARCMPEX(I2
,0,BSTR
,bstr0
,VARCMP_LT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_LT
);
6611 VARCMP(BSTR
,bstrhuh
,I4
,I4_MAX
,VARCMP_GT
);
6612 VARCMP(BSTR
,bstr2cents
,I4
,2,VARCMP_GT
);
6613 VARCMPEX(BSTR
,bstr2cents
,I4
,42,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
6614 VARCMP(BSTR
,bstr2cents
,I4
,-1,VARCMP_GT
);
6615 VARCMPEX(BSTR
,bstr2cents
,I4
,-666,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
6616 VARCMPEX(BSTR
,bstr0
,I2
,0,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_GT
);
6617 VARCMPEX(BSTR
,bstr0
,I4
,0,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_GT
);
6618 VARCMPEX(BSTR
,bstr0
,I4
,-666,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
6619 VARCMP(BSTR
,bstr1
,I4
,0,VARCMP_GT
);
6620 VARCMPEX(BSTR
,bstr1
,I4
,1,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_GT
);
6621 VARCMPEX(BSTR
,bstr1
,I4
,I4_MAX
,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
,VARCMP_GT
);
6622 VARCMPEX(BSTR
,bstr1
,I4
,-1,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
6623 VARCMP(BSTR
,bstr7
,I4
,1,VARCMP_GT
);
6624 VARCMPEX(BSTR
,bstr7
,I4
,7,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_GT
);
6625 VARCMPEX(BSTR
,bstr7
,I4
,42,VARCMP_GT
,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
);
6626 VARCMPEX(BSTR
,bstr42
,I4
,7,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
6627 VARCMPEX(BSTR
,bstr42
,I4
,42,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_GT
);
6628 VARCMPEX(BSTR
,bstr42
,I4
,I4_MAX
,VARCMP_GT
,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
);
6629 VARCMPEX(BSTR
,bstr1neg
,I4
,1,VARCMP_GT
,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
);
6630 VARCMPEX(BSTR
,bstr1neg
,I4
,42,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
,VARCMP_LT
);
6631 VARCMPEX(BSTR
,bstr1neg
,I4
,-1,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_LT
);
6632 VARCMPEX(BSTR
,bstr1neg
,I4
,-666,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_LT
);
6633 VARCMPEX(BSTR
,bstr666neg
,I4
,1,VARCMP_GT
,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
);
6634 VARCMPEX(BSTR
,bstr666neg
,I4
,7,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
,VARCMP_LT
);
6635 VARCMPEX(BSTR
,bstr666neg
,I4
,42,VARCMP_GT
,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
);
6636 VARCMPEX(BSTR
,bstr666neg
,I4
,I4_MAX
,VARCMP_GT
,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
);
6637 VARCMPEX(BSTR
,bstr666neg
,I4
,-1,VARCMP_GT
,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
);
6638 VARCMPEX(BSTR
,bstr666neg
,I4
,-666,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_LT
);
6639 VARCMPEX(BSTR
,bstr7
,R8
,7.0,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_GT
);
6640 VARCMPEX(R8
,3.141592,BSTR
,NULL
,VARCMP_LT
,VARCMP_LT
,VARCMP_GT
,VARCMP_LT
);
6641 VARCMP(BSTR
,bstr7
,BSTR
,bstr7
,VARCMP_EQ
);
6642 VARCMP(BSTR
,bstr7
,BSTR
,bstr42
,VARCMP_GT
);
6643 VARCMP(BSTR
,bstr42
,BSTR
,bstr7
,VARCMP_LT
);
6645 /* DECIMAL handling */
6646 setdec(&dec
,0,0,0,0);
6647 VARCMPEX(DECIMAL
,dec
,BSTR
,bstr0
,VARCMP_LT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_LT
);
6648 setdec64(&dec
,0,0,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF); /* max DECIMAL */
6649 VARCMP(DECIMAL
,dec
,R8
,R8_MAX
,VARCMP_LT
); /* R8 has bigger range */
6650 VARCMP(DECIMAL
,dec
,DATE
,R8_MAX
,VARCMP_LT
); /* DATE has bigger range */
6651 setdec64(&dec
,0,0x80,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF);
6652 VARCMP(DECIMAL
,dec
,R8
,-R8_MAX
,VARCMP_GT
);
6653 setdec64(&dec
,20,0,0x5,0x6BC75E2D,0x63100001); /* 1+1e-20 */
6654 VARCMP(DECIMAL
,dec
,R8
,1,VARCMP_GT
); /* DECIMAL has higher precision */
6656 /* Show that DATE is handled just as a R8 */
6657 VARCMP(DATE
,DATE_MAX
,DATE
,DATE_MAX
+1,VARCMP_LT
);
6658 VARCMP(DATE
,DATE_MIN
,DATE
,DATE_MIN
-1,VARCMP_GT
);
6659 VARCMP(DATE
,R8_MIN
,R8
,R8_MIN
,VARCMP_EQ
);
6660 VARCMP(DATE
,1,DATE
,1+1e-15,VARCMP_LT
); /* 1e-15 == 8.64e-11 seconds */
6661 VARCMP(DATE
,25570.0,DATE
,25570.0,VARCMP_EQ
);
6662 VARCMP(DATE
,25570.0,DATE
,25571.0,VARCMP_LT
);
6663 VARCMP(DATE
,25571.0,DATE
,25570.0,VARCMP_GT
);
6664 VARCMP(DATE
,25570.0,EMPTY
,0,VARCMP_GT
);
6665 VARCMP(DATE
,25570.0,NULL_
,0,VARCMP_NULL
);
6667 /* R4 precision handling */
6668 VARCMP(R4
,1,R8
,1+1e-8,VARCMP_EQ
);
6669 VARCMP(R8
,1+1e-8,R4
,1,VARCMP_EQ
);
6670 VARCMP(R8
,1+1e-8,R8
,1,VARCMP_GT
);
6671 VARCMP(R8
,R4_MAX
*1.1,R4
,R4_MAX
,VARCMP_GT
);
6672 VARCMP(R4
,R4_MAX
,R8
,R8_MAX
,VARCMP_LT
);
6673 VARCMP(R4
,1,DATE
,1+1e-8,VARCMP_EQ
);
6674 VARCMP(R4
,1,BSTR
,bstr1few
,VARCMP_LT
); /* bstr1few == 1+1e-8 */
6675 setdec(&dec
,8,0,0,0x5F5E101); /* 1+1e-8 */
6676 VARCMP(R4
,1,DECIMAL
,dec
,VARCMP_LT
);
6678 SysFreeString(bstrhuh
);
6679 SysFreeString(bstrempty
);
6680 SysFreeString(bstr0
);
6681 SysFreeString(bstr1
);
6682 SysFreeString(bstr7
);
6683 SysFreeString(bstr42
);
6684 SysFreeString(bstr1neg
);
6685 SysFreeString(bstr666neg
);
6686 SysFreeString(bstr2cents
);
6687 SysFreeString(bstr1few
);
6690 static HRESULT (WINAPI
*pVarPow
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
6692 #define VARPOW(vt1,val1,vt2,val2,rvt,rval) \
6693 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
6694 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
6695 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
6696 test_var_call2( __LINE__, pVarPow, &left, &right, &exp )
6698 /* Skip any type that is not defined or produces an error for every case */
6699 #define SKIPTESTPOW(a) \
6700 if (a == VT_ERROR || a == VT_VARIANT || \
6701 a == VT_DISPATCH || a == VT_UNKNOWN || \
6702 a == VT_RECORD || a > VT_UINT || \
6703 a == 15 /*not defined*/) \
6706 static void test_VarPow(void)
6708 static const WCHAR str2
[] = { '2','\0' };
6709 static const WCHAR str3
[] = { '3','\0' };
6710 VARIANT left
, right
, exp
, result
, cy
, dec
;
6711 BSTR num2_str
, num3_str
;
6717 num2_str
= SysAllocString(str2
);
6718 num3_str
= SysAllocString(str3
);
6720 /* Test all possible flag/vt combinations & the resulting vt type */
6721 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
6723 VARTYPE leftvt
, rightvt
, resvt
;
6725 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
6727 SKIPTESTPOW(leftvt
);
6729 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
6732 SKIPTESTPOW(rightvt
);
6734 /* Native crashes with VT_BYREF */
6735 if (ExtraFlags
[i
] == VT_BYREF
)
6738 memset(&left
, 0, sizeof(left
));
6739 memset(&right
, 0, sizeof(right
));
6740 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
6741 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
6742 V_VT(&result
) = VT_EMPTY
;
6745 if (leftvt
== VT_BSTR
)
6746 V_BSTR(&left
) = num2_str
;
6747 if (rightvt
== VT_BSTR
)
6748 V_BSTR(&right
) = num2_str
;
6750 /* Native VarPow always returns an error when using extra flags */
6751 if (ExtraFlags
[i
] != 0)
6754 /* Determine return type */
6755 else if ((leftvt
== VT_NULL
|| rightvt
== VT_NULL
) &&
6756 ((leftvt
!= VT_I8
&& leftvt
!= VT_UI8
&&
6757 rightvt
!= VT_I8
&& rightvt
!= VT_UI8
) || has_i8
))
6759 else if ((leftvt
== VT_EMPTY
|| leftvt
== VT_I2
||
6760 leftvt
== VT_I4
|| leftvt
== VT_R4
||
6761 leftvt
== VT_R8
|| leftvt
== VT_CY
||
6762 leftvt
== VT_DATE
|| leftvt
== VT_BSTR
||
6763 leftvt
== VT_BOOL
|| leftvt
== VT_DECIMAL
||
6764 (leftvt
>= VT_I1
&& leftvt
<= VT_UI4
) ||
6765 (has_i8
&& (leftvt
== VT_I8
|| leftvt
== VT_UI8
)) ||
6766 leftvt
== VT_INT
|| leftvt
== VT_UINT
) &&
6767 (rightvt
== VT_EMPTY
|| rightvt
== VT_I2
||
6768 rightvt
== VT_I4
|| rightvt
== VT_R4
||
6769 rightvt
== VT_R8
|| rightvt
== VT_CY
||
6770 rightvt
== VT_DATE
|| rightvt
== VT_BSTR
||
6771 rightvt
== VT_BOOL
|| rightvt
== VT_DECIMAL
||
6772 (rightvt
>= VT_I1
&& rightvt
<= VT_UI4
) ||
6773 (has_i8
&& (rightvt
== VT_I8
|| rightvt
== VT_UI8
)) ||
6774 rightvt
== VT_INT
|| rightvt
== VT_UINT
))
6779 hres
= pVarPow(&left
, &right
, &result
);
6781 /* Check expected HRESULT and if result variant type is correct */
6783 ok (hres
== DISP_E_BADVARTYPE
|| hres
== DISP_E_TYPEMISMATCH
,
6784 "VarPow: %s|0x%X, %s|0x%X: got vt %s hr 0x%X\n",
6785 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
],
6786 vtstr(V_VT(&result
)), hres
);
6788 ok (hres
== S_OK
&& resvt
== V_VT(&result
),
6789 "VarPow: %s|0x%X, %s|0x%X: expected vt %s hr 0x%X, got vt %s hr 0x%X\n",
6790 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
], vtstr(resvt
),
6791 S_OK
, vtstr(V_VT(&result
)), hres
);
6796 /* Check return values for valid variant type combinations */
6797 VARPOW(EMPTY
,0,EMPTY
,0,R8
,1.0);
6798 VARPOW(EMPTY
,0,NULL
,0,NULL
,0);
6799 VARPOW(EMPTY
,0,I2
,3,R8
,0.0);
6800 VARPOW(EMPTY
,0,I4
,3,R8
,0.0);
6801 VARPOW(EMPTY
,0,R4
,3.0f
,R8
,0.0);
6802 VARPOW(EMPTY
,0,R8
,3.0,R8
,0.0);
6803 VARPOW(EMPTY
,0,DATE
,3,R8
,0.0);
6804 VARPOW(EMPTY
,0,BSTR
,num3_str
,R8
,0.0);
6805 VARPOW(EMPTY
,0,BOOL
,VARIANT_FALSE
,R8
,1.0);
6806 VARPOW(EMPTY
,0,I1
,3,R8
,0.0);
6807 VARPOW(EMPTY
,0,UI1
,3,R8
,0.0);
6808 VARPOW(EMPTY
,0,UI2
,3,R8
,0.0);
6809 VARPOW(EMPTY
,0,UI4
,3,R8
,0.0);
6812 VARPOW(EMPTY
,0,I8
,3,R8
,0.0);
6813 VARPOW(EMPTY
,0,UI8
,3,R8
,0.0);
6815 VARPOW(EMPTY
,0,INT
,3,R8
,0.0);
6816 VARPOW(EMPTY
,0,UINT
,3,R8
,0.0);
6817 VARPOW(NULL
,0,EMPTY
,0,NULL
,0);
6818 VARPOW(NULL
,0,NULL
,0,NULL
,0);
6819 VARPOW(NULL
,0,I2
,3,NULL
,0);
6820 VARPOW(NULL
,0,I4
,3,NULL
,0);
6821 VARPOW(NULL
,0,R4
,3.0f
,NULL
,0);
6822 VARPOW(NULL
,0,R8
,3.0,NULL
,0);
6823 VARPOW(NULL
,0,DATE
,3,NULL
,0);
6824 VARPOW(NULL
,0,BSTR
,num3_str
,NULL
,0);
6825 VARPOW(NULL
,0,BOOL
,VARIANT_TRUE
,NULL
,0);
6826 VARPOW(NULL
,0,I1
,3,NULL
,0);
6827 VARPOW(NULL
,0,UI1
,3,NULL
,0);
6828 VARPOW(NULL
,0,UI2
,3,NULL
,0);
6829 VARPOW(NULL
,0,UI4
,3,NULL
,0);
6832 VARPOW(NULL
,0,I8
,3,NULL
,0);
6833 VARPOW(NULL
,0,UI8
,3,NULL
,0);
6835 VARPOW(NULL
,0,INT
,3,NULL
,0);
6836 VARPOW(NULL
,0,UINT
,3,NULL
,0);
6837 VARPOW(I2
,2,EMPTY
,0,R8
,1.0);
6838 VARPOW(I2
,2,NULL
,0,NULL
,0);
6839 VARPOW(I2
,2,I2
,3,R8
,8.0);
6840 VARPOW(I2
,2,I4
,3,R8
,8.0);
6841 VARPOW(I2
,2,R4
,3.0f
,R8
,8.0);
6842 VARPOW(I2
,2,R8
,3.0,R8
,8.0);
6843 VARPOW(I2
,2,DATE
,3,R8
,8.0);
6844 VARPOW(I2
,2,BSTR
,num3_str
,R8
,8.0);
6845 VARPOW(I2
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6846 VARPOW(I2
,2,I1
,3,R8
,8.0);
6847 VARPOW(I2
,2,UI1
,3,R8
,8.0);
6848 VARPOW(I2
,2,UI2
,3,R8
,8.0);
6849 VARPOW(I2
,2,UI4
,3,R8
,8.0);
6852 VARPOW(I2
,2,I8
,3,R8
,8.0);
6853 VARPOW(I2
,2,UI8
,3,R8
,8.0);
6855 VARPOW(I2
,2,INT
,3,R8
,8.0);
6856 VARPOW(I2
,2,UINT
,3,R8
,8.0);
6857 VARPOW(I4
,2,EMPTY
,0,R8
,1.0);
6858 VARPOW(I4
,2,NULL
,0,NULL
,0);
6859 VARPOW(I4
,2,I2
,3,R8
,8.0);
6860 VARPOW(I4
,2,I4
,3,R8
,8.0);
6861 VARPOW(I4
,2,R4
,3.0f
,R8
,8.0);
6862 VARPOW(I4
,2,R8
,3.0,R8
,8.0);
6863 VARPOW(I4
,2,DATE
,3,R8
,8.0);
6864 VARPOW(I4
,2,BSTR
,num3_str
,R8
,8.0);
6865 VARPOW(I4
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6866 VARPOW(I4
,2,I1
,3,R8
,8.0);
6867 VARPOW(I4
,2,UI1
,3,R8
,8.0);
6868 VARPOW(I4
,2,UI2
,3,R8
,8.0);
6869 VARPOW(I4
,2,UI4
,3,R8
,8.0);
6872 VARPOW(I4
,2,I8
,3,R8
,8.0);
6873 VARPOW(I4
,2,UI8
,3,R8
,8.0);
6875 VARPOW(I4
,2,INT
,3,R8
,8.0);
6876 VARPOW(I4
,2,UINT
,3,R8
,8.0);
6877 VARPOW(R4
,2,EMPTY
,0,R8
,1.0);
6878 VARPOW(R4
,2,NULL
,0,NULL
,0);
6879 VARPOW(R4
,2,I2
,3,R8
,8.0);
6880 VARPOW(R4
,2,I4
,3,R8
,8.0);
6881 VARPOW(R4
,2,R4
,3.0f
,R8
,8.0);
6882 VARPOW(R4
,2,R8
,3.0,R8
,8.0);
6883 VARPOW(R4
,2,DATE
,3,R8
,8.0);
6884 VARPOW(R4
,2,BSTR
,num3_str
,R8
,8.0);
6885 VARPOW(R4
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6886 VARPOW(R4
,2,I1
,3,R8
,8.0);
6887 VARPOW(R4
,2,UI1
,3,R8
,8.0);
6888 VARPOW(R4
,2,UI2
,3,R8
,8.0);
6889 VARPOW(R4
,2,UI4
,3,R8
,8.0);
6892 VARPOW(R4
,2,I8
,3,R8
,8.0);
6893 VARPOW(R4
,2,UI8
,3,R8
,8.0);
6895 VARPOW(R4
,2,INT
,3,R8
,8.0);
6896 VARPOW(R4
,2,UINT
,3,R8
,8.0);
6897 VARPOW(R8
,2,EMPTY
,0,R8
,1.0);
6898 VARPOW(R8
,2,NULL
,0,NULL
,0);
6899 VARPOW(R8
,2,I2
,3,R8
,8.0);
6900 VARPOW(R8
,2,I4
,3,R8
,8.0);
6901 VARPOW(R8
,2,R4
,3.0f
,R8
,8.0);
6902 VARPOW(R8
,2,R8
,3.0,R8
,8.0);
6903 VARPOW(R8
,2,DATE
,3,R8
,8.0);
6904 VARPOW(R8
,2,BSTR
,num3_str
,R8
,8.0);
6905 VARPOW(R8
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6906 VARPOW(R8
,2,I1
,3,R8
,8.0);
6907 VARPOW(R8
,2,UI1
,3,R8
,8.0);
6908 VARPOW(R8
,2,UI2
,3,R8
,8.0);
6909 VARPOW(R8
,2,UI4
,3,R8
,8.0);
6912 VARPOW(R8
,2,I8
,3,R8
,8.0);
6913 VARPOW(R8
,2,UI8
,3,R8
,8.0);
6915 VARPOW(R8
,2,INT
,3,R8
,8.0);
6916 VARPOW(R8
,2,UINT
,3,R8
,8.0);
6917 VARPOW(DATE
,2,EMPTY
,0,R8
,1.0);
6918 VARPOW(DATE
,2,NULL
,0,NULL
,0);
6919 VARPOW(DATE
,2,I2
,3,R8
,8.0);
6920 VARPOW(DATE
,2,I4
,3,R8
,8.0);
6921 VARPOW(DATE
,2,R4
,3.0f
,R8
,8.0);
6922 VARPOW(DATE
,2,R8
,3.0,R8
,8.0);
6923 VARPOW(DATE
,2,DATE
,3,R8
,8.0);
6924 VARPOW(DATE
,2,BSTR
,num3_str
,R8
,8.0);
6925 VARPOW(DATE
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6926 VARPOW(DATE
,2,I1
,3,R8
,8.0);
6927 VARPOW(DATE
,2,UI1
,3,R8
,8.0);
6928 VARPOW(DATE
,2,UI2
,3,R8
,8.0);
6929 VARPOW(DATE
,2,UI4
,3,R8
,8.0);
6932 VARPOW(DATE
,2,I8
,3,R8
,8.0);
6933 VARPOW(DATE
,2,UI8
,3,R8
,8.0);
6935 VARPOW(DATE
,2,INT
,3,R8
,8.0);
6936 VARPOW(DATE
,2,UINT
,3,R8
,8.0);
6937 VARPOW(BSTR
,num2_str
,EMPTY
,0,R8
,1.0);
6938 VARPOW(BSTR
,num2_str
,NULL
,0,NULL
,0);
6939 VARPOW(BSTR
,num2_str
,I2
,3,R8
,8.0);
6940 VARPOW(BSTR
,num2_str
,I4
,3,R8
,8.0);
6941 VARPOW(BSTR
,num2_str
,R4
,3.0f
,R8
,8.0);
6942 VARPOW(BSTR
,num2_str
,R8
,3.0,R8
,8.0);
6943 VARPOW(BSTR
,num2_str
,DATE
,3,R8
,8.0);
6944 VARPOW(BSTR
,num2_str
,BSTR
,num3_str
,R8
,8.0);
6945 VARPOW(BSTR
,num2_str
,BOOL
,VARIANT_FALSE
,R8
,1.0);
6946 VARPOW(BSTR
,num2_str
,I1
,3,R8
,8.0);
6947 VARPOW(BSTR
,num2_str
,UI1
,3,R8
,8.0);
6948 VARPOW(BSTR
,num2_str
,UI2
,3,R8
,8.0);
6949 VARPOW(BSTR
,num2_str
,UI4
,3,R8
,8.0);
6952 VARPOW(BSTR
,num2_str
,I8
,3,R8
,8.0);
6953 VARPOW(BSTR
,num2_str
,UI8
,3,R8
,8.0);
6955 VARPOW(BSTR
,num2_str
,INT
,3,R8
,8.0);
6956 VARPOW(BSTR
,num2_str
,UINT
,3,R8
,8.0);
6957 VARPOW(BOOL
,VARIANT_TRUE
,EMPTY
,0,R8
,1.0);
6958 VARPOW(BOOL
,VARIANT_TRUE
,NULL
,0,NULL
,0);
6959 VARPOW(BOOL
,VARIANT_TRUE
,I2
,3,R8
,-1.0);
6960 VARPOW(BOOL
,VARIANT_TRUE
,I4
,3,R8
,-1.0);
6961 VARPOW(BOOL
,VARIANT_TRUE
,R4
,3.0f
,R8
,-1.0);
6962 VARPOW(BOOL
,VARIANT_TRUE
,R8
,3.0,R8
,-1.0);
6963 VARPOW(BOOL
,VARIANT_TRUE
,DATE
,3,R8
,-1.0);
6964 VARPOW(BOOL
,VARIANT_TRUE
,BSTR
,num3_str
,R8
,-1.0);
6965 VARPOW(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
,R8
,-1.0);
6966 VARPOW(BOOL
,VARIANT_TRUE
,I1
,3,R8
,-1.0);
6967 VARPOW(BOOL
,VARIANT_TRUE
,UI1
,3,R8
,-1.0);
6968 VARPOW(BOOL
,VARIANT_TRUE
,UI2
,3,R8
,-1.0);
6969 VARPOW(BOOL
,VARIANT_TRUE
,UI4
,3,R8
,-1.0);
6972 VARPOW(BOOL
,VARIANT_TRUE
,I8
,3,R8
,-1.0);
6973 VARPOW(BOOL
,VARIANT_TRUE
,UI8
,3,R8
,-1.0);
6975 VARPOW(BOOL
,VARIANT_TRUE
,INT
,3,R8
,-1.0);
6976 VARPOW(BOOL
,VARIANT_TRUE
,UINT
,3,R8
,-1.0);
6977 VARPOW(I1
,2,EMPTY
,0,R8
,1.0);
6978 VARPOW(I1
,2,NULL
,0,NULL
,0);
6979 VARPOW(I1
,2,I2
,3,R8
,8.0);
6980 VARPOW(I1
,2,I4
,3,R8
,8.0);
6981 VARPOW(I1
,2,R4
,3.0f
,R8
,8.0);
6982 VARPOW(I1
,2,R8
,3.0,R8
,8.0);
6983 VARPOW(I1
,2,DATE
,3,R8
,8.0);
6984 VARPOW(I1
,2,BSTR
,num3_str
,R8
,8.0);
6985 VARPOW(I1
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6986 VARPOW(I1
,2,I1
,3,R8
,8.0);
6987 VARPOW(I1
,2,UI1
,3,R8
,8.0);
6988 VARPOW(I1
,2,UI2
,3,R8
,8.0);
6989 VARPOW(I1
,2,UI4
,3,R8
,8.0);
6992 VARPOW(I1
,2,I8
,3,R8
,8.0);
6993 VARPOW(I1
,2,UI8
,3,R8
,8.0);
6995 VARPOW(I1
,2,INT
,3,R8
,8.0);
6996 VARPOW(I1
,2,UINT
,3,R8
,8.0);
6997 VARPOW(UI1
,2,EMPTY
,0,R8
,1.0);
6998 VARPOW(UI1
,2,NULL
,0,NULL
,0);
6999 VARPOW(UI1
,2,I2
,3,R8
,8.0);
7000 VARPOW(UI1
,2,I4
,3,R8
,8.0);
7001 VARPOW(UI1
,2,R4
,3.0f
,R8
,8.0);
7002 VARPOW(UI1
,2,R8
,3.0,R8
,8.0);
7003 VARPOW(UI1
,2,DATE
,3,R8
,8.0);
7004 VARPOW(UI1
,2,BSTR
,num3_str
,R8
,8.0);
7005 VARPOW(UI1
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
7006 VARPOW(UI1
,2,I1
,3,R8
,8.0);
7007 VARPOW(UI1
,2,UI1
,3,R8
,8.0);
7008 VARPOW(UI1
,2,UI2
,3,R8
,8.0);
7009 VARPOW(UI1
,2,UI4
,3,R8
,8.0);
7012 VARPOW(UI1
,2,I8
,3,R8
,8.0);
7013 VARPOW(UI1
,2,UI8
,3,R8
,8.0);
7015 VARPOW(UI1
,2,INT
,3,R8
,8.0);
7016 VARPOW(UI1
,2,UINT
,3,R8
,8.0);
7017 VARPOW(UI2
,2,EMPTY
,0,R8
,1.0);
7018 VARPOW(UI2
,2,NULL
,0,NULL
,0);
7019 VARPOW(UI2
,2,I2
,3,R8
,8.0);
7020 VARPOW(UI2
,2,I4
,3,R8
,8.0);
7021 VARPOW(UI2
,2,R4
,3.0f
,R8
,8.0);
7022 VARPOW(UI2
,2,R8
,3.0,R8
,8.0);
7023 VARPOW(UI2
,2,DATE
,3,R8
,8.0);
7024 VARPOW(UI2
,2,BSTR
,num3_str
,R8
,8.0);
7025 VARPOW(UI2
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
7026 VARPOW(UI2
,2,I1
,3,R8
,8.0);
7027 VARPOW(UI2
,2,UI1
,3,R8
,8.0);
7028 VARPOW(UI2
,2,UI2
,3,R8
,8.0);
7029 VARPOW(UI2
,2,UI4
,3,R8
,8.0);
7032 VARPOW(UI2
,2,I8
,3,R8
,8.0);
7033 VARPOW(UI2
,2,UI8
,3,R8
,8.0);
7035 VARPOW(UI2
,2,INT
,3,R8
,8.0);
7036 VARPOW(UI2
,2,UINT
,3,R8
,8.0);
7037 VARPOW(UI4
,2,EMPTY
,0,R8
,1.0);
7038 VARPOW(UI4
,2,NULL
,0,NULL
,0);
7039 VARPOW(UI4
,2,I2
,3,R8
,8.0);
7040 VARPOW(UI4
,2,I4
,3,R8
,8.0);
7041 VARPOW(UI4
,2,R4
,3.0f
,R8
,8.0);
7042 VARPOW(UI4
,2,R8
,3.0,R8
,8.0);
7043 VARPOW(UI4
,2,DATE
,3,R8
,8.0);
7044 VARPOW(UI4
,2,BSTR
,num3_str
,R8
,8.0);
7045 VARPOW(UI4
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
7046 VARPOW(UI4
,2,I1
,3,R8
,8.0);
7047 VARPOW(UI4
,2,UI1
,3,R8
,8.0);
7048 VARPOW(UI4
,2,UI2
,3,R8
,8.0);
7049 VARPOW(UI4
,2,UI4
,3,R8
,8.0);
7052 VARPOW(UI4
,2,I8
,3,R8
,8.0);
7053 VARPOW(UI4
,2,UI8
,3,R8
,8.0);
7055 VARPOW(UI4
,2,INT
,3,R8
,8.0);
7056 VARPOW(UI4
,2,UINT
,3,R8
,8.0);
7059 VARPOW(I8
,2,EMPTY
,0,R8
,1.0);
7060 VARPOW(I8
,2,NULL
,0,NULL
,0);
7061 VARPOW(I8
,2,I2
,3,R8
,8.0);
7062 VARPOW(I8
,2,I4
,3,R8
,8.0);
7063 VARPOW(I8
,2,R4
,3.0f
,R8
,8.0);
7064 VARPOW(I8
,2,R8
,3.0,R8
,8.0);
7065 VARPOW(I8
,2,DATE
,3,R8
,8.0);
7066 VARPOW(I8
,2,BSTR
,num3_str
,R8
,8.0);
7067 VARPOW(I8
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
7068 VARPOW(I8
,2,I1
,3,R8
,8.0);
7069 VARPOW(I8
,2,UI1
,3,R8
,8.0);
7070 VARPOW(I8
,2,UI2
,3,R8
,8.0);
7071 VARPOW(I8
,2,UI4
,3,R8
,8.0);
7072 VARPOW(I8
,2,I8
,3,R8
,8.0);
7073 VARPOW(I8
,2,UI8
,3,R8
,8.0);
7074 VARPOW(I8
,2,INT
,3,R8
,8.0);
7075 VARPOW(I8
,2,UINT
,3,R8
,8.0);
7076 VARPOW(UI8
,2,EMPTY
,0,R8
,1.0);
7077 VARPOW(UI8
,2,NULL
,0,NULL
,0);
7078 VARPOW(UI8
,2,I2
,3,R8
,8.0);
7079 VARPOW(UI8
,2,I4
,3,R8
,8.0);
7080 VARPOW(UI8
,2,R4
,3.0f
,R8
,8.0);
7081 VARPOW(UI8
,2,R8
,3.0,R8
,8.0);
7082 VARPOW(UI8
,2,DATE
,3,R8
,8.0);
7083 VARPOW(UI8
,2,BSTR
,num3_str
,R8
,8.0);
7084 VARPOW(UI8
,2,I1
,3,R8
,8.0);
7085 VARPOW(UI8
,2,UI1
,3,R8
,8.0);
7086 VARPOW(UI8
,2,UI2
,3,R8
,8.0);
7087 VARPOW(UI8
,2,UI4
,3,R8
,8.0);
7088 VARPOW(UI8
,2,I8
,3,R8
,8.0);
7089 VARPOW(UI8
,2,UI8
,3,R8
,8.0);
7090 VARPOW(UI8
,2,INT
,3,R8
,8.0);
7091 VARPOW(UI8
,2,UINT
,3,R8
,8.0);
7093 VARPOW(INT
,2,EMPTY
,0,R8
,1.0);
7094 VARPOW(INT
,2,NULL
,0,NULL
,0);
7095 VARPOW(INT
,2,I2
,3,R8
,8.0);
7096 VARPOW(INT
,2,I4
,3,R8
,8.0);
7097 VARPOW(INT
,2,R4
,3.0f
,R8
,8.0);
7098 VARPOW(INT
,2,R8
,3.0,R8
,8.0);
7099 VARPOW(INT
,2,DATE
,3,R8
,8.0);
7100 VARPOW(INT
,2,BSTR
,num3_str
,R8
,8.0);
7101 VARPOW(INT
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
7102 VARPOW(INT
,2,I1
,3,R8
,8.0);
7103 VARPOW(INT
,2,UI1
,3,R8
,8.0);
7104 VARPOW(INT
,2,UI2
,3,R8
,8.0);
7105 VARPOW(INT
,2,UI4
,3,R8
,8.0);
7108 VARPOW(INT
,2,I8
,3,R8
,8.0);
7109 VARPOW(INT
,2,UI8
,3,R8
,8.0);
7111 VARPOW(INT
,2,INT
,3,R8
,8.0);
7112 VARPOW(INT
,2,UINT
,3,R8
,8.0);
7113 VARPOW(UINT
,2,EMPTY
,0,R8
,1.0);
7114 VARPOW(UINT
,2,NULL
,0,NULL
,0);
7115 VARPOW(UINT
,2,I2
,3,R8
,8.0);
7116 VARPOW(UINT
,2,I4
,3,R8
,8.0);
7117 VARPOW(UINT
,2,R4
,3.0f
,R8
,8.0);
7118 VARPOW(UINT
,2,R8
,3.0,R8
,8.0);
7119 VARPOW(UINT
,2,DATE
,3,R8
,8.0);
7120 VARPOW(UINT
,2,BSTR
,num3_str
,R8
,8.0);
7121 VARPOW(UINT
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
7122 VARPOW(UINT
,2,I1
,3,R8
,8.0);
7123 VARPOW(UINT
,2,UI1
,3,R8
,8.0);
7124 VARPOW(UINT
,2,UI2
,3,R8
,8.0);
7125 VARPOW(UINT
,2,UI4
,3,R8
,8.0);
7128 VARPOW(UINT
,2,I8
,3,R8
,8.0);
7129 VARPOW(UINT
,2,UI8
,3,R8
,8.0);
7131 VARPOW(UINT
,2,INT
,3,R8
,8.0);
7132 VARPOW(UINT
,2,UINT
,3,R8
,8.0);
7134 /* Manually test some VT_CY, VT_DECIMAL variants */
7136 hres
= VarCyFromI4(2, &V_CY(&cy
));
7137 ok(hres
== S_OK
, "VarCyFromI4 failed!\n");
7138 V_VT(&dec
) = VT_DECIMAL
;
7139 hres
= VarDecFromR8(2.0, &V_DECIMAL(&dec
));
7140 ok(hres
== S_OK
, "VarDecFromR4 failed!\n");
7141 memset(&left
, 0, sizeof(left
));
7142 memset(&right
, 0, sizeof(right
));
7143 V_VT(&left
) = VT_I4
;
7145 V_VT(&right
) = VT_I8
;
7148 hres
= pVarPow(&cy
, &cy
, &result
);
7149 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
7150 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
7151 S_OK
, hres
, vtstr(V_VT(&result
)));
7152 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 4.0),
7153 "VARPOW: CY value %f, expected %f\n", V_R8(&result
), 4.0);
7155 hres
= pVarPow(&cy
, &right
, &result
);
7158 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
7159 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
7160 S_OK
, hres
, vtstr(V_VT(&result
)));
7161 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 4.0),
7162 "VARPOW: CY value %f, expected %f\n", V_R8(&result
), 4.0);
7166 ok(hres
== DISP_E_BADVARTYPE
&& V_VT(&result
) == VT_EMPTY
,
7167 "VARPOW: expected coerced hres 0x%X type VT_EMPTY, got hres 0x%X type %s!\n",
7168 DISP_E_BADVARTYPE
, hres
, vtstr(V_VT(&result
)));
7171 hres
= pVarPow(&left
, &cy
, &result
);
7172 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
7173 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
7174 S_OK
, hres
, vtstr(V_VT(&result
)));
7175 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 10000.0),
7176 "VARPOW: CY value %f, expected %f\n", V_R8(&result
), 10000.0);
7178 hres
= pVarPow(&left
, &dec
, &result
);
7179 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
7180 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
7181 S_OK
, hres
, vtstr(V_VT(&result
)));
7182 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
),10000.0),
7183 "VARPOW: DECIMAL value %f, expected %f\n", V_R8(&result
), 10000.0);
7185 hres
= pVarPow(&dec
, &dec
, &result
);
7186 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
7187 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
7188 S_OK
, hres
, vtstr(V_VT(&result
)));
7189 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 4.0),
7190 "VARPOW: DECIMAL value %f, expected %f\n", V_R8(&result
), 4.0);
7192 hres
= pVarPow(&dec
, &right
, &result
);
7195 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
7196 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
7197 S_OK
, hres
, vtstr(V_VT(&result
)));
7198 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 4.0),
7199 "VARPOW: DECIMAL value %f, expected %f\n", V_R8(&result
), 4.0);
7203 ok(hres
== DISP_E_BADVARTYPE
&& V_VT(&result
) == VT_EMPTY
,
7204 "VARPOW: expected coerced hres 0x%X type VT_EMPTY, got hres 0x%X type %s!\n",
7205 DISP_E_BADVARTYPE
, hres
, vtstr(V_VT(&result
)));
7208 SysFreeString(num2_str
);
7209 SysFreeString(num3_str
);
7212 static HRESULT (WINAPI
*pVarDiv
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
7214 #define VARDIV(vt1,val1,vt2,val2,rvt,rval) \
7215 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
7216 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
7217 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
7218 test_var_call2( __LINE__, pVarDiv, &left, &right, &exp )
7220 /* Skip any type that is not defined or produces an error for every case */
7221 #define SKIPTESTDIV(a) \
7222 if (a == VT_ERROR || a == VT_VARIANT || \
7223 a == VT_DISPATCH || a == VT_UNKNOWN || \
7224 a == VT_RECORD || a > VT_UINT || \
7225 a == VT_I1 || a == VT_UI8 || \
7226 a == VT_INT || a == VT_UINT || \
7227 a == VT_UI2 || a == VT_UI4 || \
7228 a == 15 /*not defined*/) \
7231 static void test_VarDiv(void)
7233 static const WCHAR str1
[] = { '1','\0' };
7234 static const WCHAR str2
[] = { '2','\0' };
7235 VARIANT left
, right
, exp
, result
, cy
, dec
;
7236 BSTR num1_str
, num2_str
;
7241 num1_str
= SysAllocString(str1
);
7242 num2_str
= SysAllocString(str2
);
7246 /* Test all possible flag/vt combinations & the resulting vt type */
7247 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
7249 VARTYPE leftvt
, rightvt
, resvt
;
7251 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
7253 SKIPTESTDIV(leftvt
);
7255 /* Check if we need/have support for I8 */
7256 if (leftvt
== VT_I8
&& !has_i8
)
7259 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
7262 SKIPTESTDIV(rightvt
);
7264 /* Check if we need/have support for I8 */
7265 if (rightvt
== VT_I8
&& !has_i8
)
7268 /* Native crashes with VT_BYREF */
7269 if (ExtraFlags
[i
] == VT_BYREF
)
7272 memset(&left
, 0, sizeof(left
));
7273 memset(&right
, 0, sizeof(right
));
7274 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
7275 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
7276 V_VT(&result
) = VT_EMPTY
;
7279 if (leftvt
== VT_BSTR
)
7280 V_BSTR(&left
) = num2_str
;
7281 else if (leftvt
== VT_DECIMAL
)
7283 VarDecFromR8(2.0, &V_DECIMAL(&left
));
7284 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
7287 /* Division by 0 is undefined */
7291 V_BSTR(&right
) = num2_str
;
7294 VarDecFromR8(2.0, &V_DECIMAL(&right
));
7295 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
7298 V_BOOL(&right
) = VARIANT_TRUE
;
7300 case VT_I2
: V_I2(&right
) = 2; break;
7301 case VT_I4
: V_I4(&right
) = 2; break;
7302 case VT_R4
: V_R4(&right
) = 2.0f
; break;
7303 case VT_R8
: V_R8(&right
) = 2.0; break;
7304 case VT_CY
: V_CY(&right
).int64
= 2; break;
7305 case VT_DATE
: V_DATE(&right
) = 2; break;
7306 case VT_UI1
: V_UI1(&right
) = 2; break;
7307 case VT_I8
: V_I8(&right
) = 2; break;
7311 /* Determine return type */
7312 if (!(rightvt
== VT_EMPTY
))
7314 if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
7316 else if (leftvt
== VT_DECIMAL
|| rightvt
== VT_DECIMAL
)
7318 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
||
7319 leftvt
== VT_CY
|| rightvt
== VT_CY
||
7320 leftvt
== VT_DATE
|| rightvt
== VT_DATE
||
7321 leftvt
== VT_I4
|| rightvt
== VT_I4
||
7322 leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
||
7323 leftvt
== VT_I2
|| rightvt
== VT_I2
||
7324 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
||
7325 leftvt
== VT_R8
|| rightvt
== VT_R8
||
7326 leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
7328 if ((leftvt
== VT_UI1
&& rightvt
== VT_R4
) ||
7329 (leftvt
== VT_R4
&& rightvt
== VT_UI1
))
7331 else if ((leftvt
== VT_R4
&& (rightvt
== VT_BOOL
||
7332 rightvt
== VT_I2
)) || (rightvt
== VT_R4
&&
7333 (leftvt
== VT_BOOL
|| leftvt
== VT_I2
)))
7338 else if (leftvt
== VT_R4
|| rightvt
== VT_R4
)
7341 else if (leftvt
== VT_NULL
&& rightvt
== VT_EMPTY
)
7346 /* Native VarDiv always returns an error when using extra flags */
7347 if (ExtraFlags
[i
] != 0)
7350 hres
= pVarDiv(&left
, &right
, &result
);
7352 /* Check expected HRESULT and if result variant type is correct */
7354 ok (hres
== DISP_E_BADVARTYPE
|| hres
== DISP_E_TYPEMISMATCH
||
7355 hres
== DISP_E_OVERFLOW
|| hres
== DISP_E_DIVBYZERO
,
7356 "VarDiv: %s|0x%X, %s|0x%X: got vt %s hr 0x%X\n",
7357 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
],
7358 vtstr(V_VT(&result
)), hres
);
7360 ok (hres
== S_OK
&& resvt
== V_VT(&result
),
7361 "VarDiv: %s|0x%X, %s|0x%X: expected vt %s hr 0x%X, got vt %s hr 0x%X\n",
7362 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
], vtstr(resvt
),
7363 S_OK
, vtstr(V_VT(&result
)), hres
);
7368 /* Test return values for all the good cases */
7369 VARDIV(EMPTY
,0,NULL
,0,NULL
,0);
7370 VARDIV(EMPTY
,0,I2
,2,R8
,0.0);
7371 VARDIV(EMPTY
,0,I4
,2,R8
,0.0);
7372 VARDIV(EMPTY
,0,R4
,2.0f
,R4
,0.0f
);
7373 VARDIV(EMPTY
,0,R8
,2.0,R8
,0.0);
7374 VARDIV(EMPTY
,0,DATE
,2.0,R8
,0.0);
7375 VARDIV(EMPTY
,0,BSTR
,num2_str
,R8
,0.0);
7376 VARDIV(EMPTY
,0,BOOL
,VARIANT_TRUE
,R8
,0.0);
7377 VARDIV(EMPTY
,0,UI1
,2,R8
,0.0);
7380 VARDIV(EMPTY
,0,I8
,2,R8
,0.0);
7382 VARDIV(NULL
,0,EMPTY
,0,NULL
,0);
7383 VARDIV(NULL
,0,NULL
,0,NULL
,0);
7384 VARDIV(NULL
,0,I2
,2,NULL
,0);
7385 VARDIV(NULL
,0,I4
,2,NULL
,0);
7386 VARDIV(NULL
,0,R4
,2.0f
,NULL
,0);
7387 VARDIV(NULL
,0,R8
,2.0,NULL
,0);
7388 VARDIV(NULL
,0,DATE
,2,NULL
,0);
7389 VARDIV(NULL
,0,BSTR
,num2_str
,NULL
,0);
7390 VARDIV(NULL
,0,BOOL
,VARIANT_TRUE
,NULL
,0);
7391 VARDIV(NULL
,0,UI1
,2,NULL
,0);
7394 VARDIV(NULL
,0,I8
,2,NULL
,0);
7396 VARDIV(I2
,2,NULL
,0,NULL
,0);
7397 VARDIV(I2
,1,I2
,2,R8
,0.5);
7398 VARDIV(I2
,1,I4
,2,R8
,0.5);
7399 VARDIV(I2
,1,R4
,2,R4
,0.5f
);
7400 VARDIV(I2
,1,R8
,2.0,R8
,0.5);
7401 VARDIV(I2
,1,DATE
,2,R8
,0.5);
7402 VARDIV(I2
,1,BOOL
,VARIANT_TRUE
,R8
,-1.0);
7403 VARDIV(I2
,1,UI1
,2,R8
,0.5);
7406 VARDIV(I2
,1,I8
,2,R8
,0.5);
7408 VARDIV(I4
,1,NULL
,0,NULL
,0);
7409 VARDIV(I4
,1,I2
,2,R8
,0.5);
7410 VARDIV(I4
,1,I4
,2,R8
,0.5);
7411 VARDIV(I4
,1,R4
,2.0f
,R8
,0.5);
7412 VARDIV(I4
,1,R8
,2.0,R8
,0.5);
7413 VARDIV(I4
,1,DATE
,2,R8
,0.5);
7414 VARDIV(I4
,1,BSTR
,num2_str
,R8
,0.5);
7415 VARDIV(I4
,1,BOOL
,VARIANT_TRUE
,R8
,-1.0);
7416 VARDIV(I4
,1,UI1
,2,R8
,0.5);
7419 VARDIV(I4
,1,I8
,2,R8
,0.5);
7421 VARDIV(R4
,1.0f
,NULL
,0,NULL
,0);
7422 VARDIV(R4
,1.0f
,I2
,2,R4
,0.5f
);
7423 VARDIV(R4
,1.0f
,I4
,2,R8
,0.5);
7424 VARDIV(R4
,1.0f
,R4
,2.0f
,R4
,0.5f
);
7425 VARDIV(R4
,1.0f
,R8
,2.0,R8
,0.5);
7426 VARDIV(R4
,1.0f
,DATE
,2,R8
,0.5);
7427 VARDIV(R4
,1.0f
,BSTR
,num2_str
,R8
,0.5);
7428 VARDIV(R4
,1.0f
,BOOL
,VARIANT_TRUE
,R4
,-1);
7429 VARDIV(R4
,1.0f
,UI1
,2,R4
,0.5f
);
7432 VARDIV(R4
,1.0f
,I8
,2,R8
,0.5);
7434 VARDIV(R8
,1.0,NULL
,0,NULL
,0);
7435 VARDIV(R8
,1.0,I2
,2,R8
,0.5);
7436 VARDIV(R8
,1.0,I4
,2,R8
,0.5);
7437 VARDIV(R8
,1.0,R4
,2.0f
,R8
,0.5);
7438 VARDIV(R8
,1.0,R8
,2.0,R8
,0.5);
7439 VARDIV(R8
,1.0,DATE
,2,R8
,0.5);
7440 VARDIV(R8
,1.0,BSTR
,num2_str
,R8
,0.5);
7441 VARDIV(R8
,1.0,BOOL
,VARIANT_TRUE
,R8
,-1.0);
7442 VARDIV(R8
,1.0,UI1
,2,R8
,0.5);
7445 VARDIV(R8
,1.0,I8
,2,R8
,0.5);
7447 VARDIV(DATE
,1,NULL
,0,NULL
,0);
7448 VARDIV(DATE
,1,I2
,2,R8
,0.5);
7449 VARDIV(DATE
,1,I4
,2,R8
,0.5);
7450 VARDIV(DATE
,1,R4
,2.0f
,R8
,0.5);
7451 VARDIV(DATE
,1,R8
,2.0,R8
,0.5);
7452 VARDIV(DATE
,1,DATE
,2,R8
,0.5);
7453 VARDIV(DATE
,1,BSTR
,num2_str
,R8
,0.5);
7454 VARDIV(DATE
,1,BOOL
,VARIANT_TRUE
,R8
,-1.0);
7455 VARDIV(DATE
,1,UI1
,2,R8
,0.5);
7458 VARDIV(DATE
,1,I8
,2,R8
,0.5);
7460 VARDIV(BSTR
,num1_str
,NULL
,0,NULL
,0);
7461 VARDIV(BSTR
,num1_str
,I2
,2,R8
,0.5);
7462 VARDIV(BSTR
,num1_str
,I4
,2,R8
,0.5);
7463 VARDIV(BSTR
,num1_str
,R4
,2.0f
,R8
,0.5);
7464 VARDIV(BSTR
,num1_str
,R8
,2.0,R8
,0.5);
7465 VARDIV(BSTR
,num1_str
,DATE
,2,R8
,0.5);
7466 VARDIV(BSTR
,num1_str
,BSTR
,num2_str
,R8
,0.5);
7467 VARDIV(BSTR
,num1_str
,BOOL
,VARIANT_TRUE
,R8
,-1);
7468 VARDIV(BSTR
,num1_str
,UI1
,2,R8
,0.5);
7471 VARDIV(BSTR
,num1_str
,I8
,2,R8
,0.5);
7473 VARDIV(BOOL
,VARIANT_TRUE
,NULL
,0,NULL
,0);
7474 VARDIV(BOOL
,VARIANT_TRUE
,I2
,1,R8
,-1.0);
7475 VARDIV(BOOL
,VARIANT_FALSE
,I2
,1,R8
,0.0);
7476 VARDIV(BOOL
,VARIANT_TRUE
,I4
,1,R8
,-1.0);
7477 VARDIV(BOOL
,VARIANT_FALSE
,I4
,1,R8
,0.0);
7478 VARDIV(BOOL
,VARIANT_TRUE
,R4
,1,R4
,-1.0f
);
7479 VARDIV(BOOL
,VARIANT_FALSE
,R4
,1,R4
,0.0f
);
7480 VARDIV(BOOL
,VARIANT_TRUE
,R8
,1.0,R8
,-1.0);
7481 VARDIV(BOOL
,VARIANT_FALSE
,R8
,1.0,R8
,0.0);
7482 VARDIV(BOOL
,VARIANT_FALSE
,DATE
,2,R8
,0.0);
7483 VARDIV(BOOL
,VARIANT_FALSE
,BSTR
,num2_str
,R8
,0.0);
7484 VARDIV(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
,R8
,1.0);
7485 VARDIV(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
,R8
,0.0);
7486 VARDIV(BOOL
,VARIANT_TRUE
,UI1
,1,R8
,-1.0);
7489 VARDIV(BOOL
,VARIANT_TRUE
,I8
,1,R8
,-1.0);
7491 VARDIV(UI1
,1,NULL
,0,NULL
,0);
7492 VARDIV(UI1
,1,I2
,2,R8
,0.5);
7493 VARDIV(UI1
,1,I4
,2,R8
,0.5);
7494 VARDIV(UI1
,1,R4
,2.0f
,R4
,0.5f
);
7495 VARDIV(UI1
,1,R8
,2.0,R8
,0.5);
7496 VARDIV(UI1
,1,DATE
,2,R8
,0.5);
7497 VARDIV(UI1
,1,BSTR
,num2_str
,R8
,0.5);
7498 VARDIV(UI1
,1,BOOL
,VARIANT_TRUE
,R8
,-1);
7499 VARDIV(UI1
,1,UI1
,2,R8
,0.5);
7502 VARDIV(UI1
,1,I8
,2,R8
,0.5);
7503 VARDIV(I8
,1,NULL
,0,NULL
,0);
7504 VARDIV(I8
,1,I2
,2,R8
,0.5);
7505 VARDIV(I8
,1,I4
,2,R8
,0.5);
7506 VARDIV(I8
,1,R4
,2.0f
,R8
,0.5);
7507 VARDIV(I8
,1,R8
,2.0,R8
,0.5);
7508 VARDIV(I8
,1,DATE
,2,R8
,0.5);
7509 VARDIV(I8
,1,BSTR
,num2_str
,R8
,0.5);
7510 VARDIV(I8
,1,BOOL
,VARIANT_TRUE
,R8
,-1);
7511 VARDIV(I8
,1,UI1
,2,R8
,0.5);
7512 VARDIV(I8
,1,I8
,2,R8
,0.5);
7515 /* Manually test some VT_CY, VT_DECIMAL variants */
7517 hres
= VarCyFromI4(10000, &V_CY(&cy
));
7518 ok(hres
== S_OK
, "VarCyFromI4 failed!\n");
7519 V_VT(&dec
) = VT_DECIMAL
;
7520 hres
= VarDecFromR8(2.0, &V_DECIMAL(&dec
));
7521 ok(hres
== S_OK
, "VarDecFromR4 failed!\n");
7522 memset(&left
, 0, sizeof(left
));
7523 memset(&right
, 0, sizeof(right
));
7524 V_VT(&left
) = VT_I4
;
7526 V_VT(&right
) = VT_UI1
;
7529 hres
= pVarDiv(&cy
, &cy
, &result
);
7530 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
7531 "VARDIV: expected coerced type VT_R8, got %s!\n", vtstr(V_VT(&result
)));
7532 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 1.0),
7533 "VARDIV: CY value %f, expected %f\n", V_R8(&result
), (double)1.0);
7535 hres
= pVarDiv(&cy
, &right
, &result
);
7536 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
7537 "VARDIV: expected coerced type VT_R8, got %s!\n", vtstr(V_VT(&result
)));
7538 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 5000.0),
7539 "VARDIV: CY value %f, expected %f\n", V_R8(&result
), (double)5000.0);
7541 hres
= pVarDiv(&left
, &cy
, &result
);
7542 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
7543 "VARDIV: expected coerced type VT_R8, got %s!\n", vtstr(V_VT(&result
)));
7544 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 0.01),
7545 "VARDIV: CY value %f, expected %f\n", V_R8(&result
), (double)0.01);
7547 hres
= pVarDiv(&left
, &dec
, &result
);
7548 ok(hres
== S_OK
&& V_VT(&result
) == VT_DECIMAL
,
7549 "VARDIV: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result
)));
7550 hres
= VarR8FromDec(&V_DECIMAL(&result
), &r
);
7551 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 50.0),
7552 "VARDIV: DECIMAL value %f, expected %f\n", r
, (double)50.0);
7554 hres
= pVarDiv(&dec
, &dec
, &result
);
7555 ok(hres
== S_OK
&& V_VT(&result
) == VT_DECIMAL
,
7556 "VARDIV: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result
)));
7557 hres
= VarR8FromDec(&V_DECIMAL(&result
), &r
);
7558 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 1.0),
7559 "VARDIV: DECIMAL value %f, expected %f\n", r
, (double)1.0);
7561 hres
= pVarDiv(&dec
, &right
, &result
);
7562 ok(hres
== S_OK
&& V_VT(&result
) == VT_DECIMAL
,
7563 "VARDIV: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result
)));
7564 hres
= VarR8FromDec(&V_DECIMAL(&result
), &r
);
7565 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 1.0),
7566 "VARDIV: DECIMAL value %f, expected %f\n", r
, (double)1.0);
7568 /* Check for division by zero and overflow */
7569 V_VT(&left
) = VT_R8
;
7571 V_VT(&right
) = VT_R8
;
7573 hres
= pVarDiv(&left
, &right
, &result
);
7574 ok(hres
== DISP_E_DIVBYZERO
&& V_VT(&result
) == VT_EMPTY
,
7575 "VARDIV: Division by (1.0/0.0) should result in DISP_E_DIVBYZERO but got 0x%X\n", hres
);
7577 V_VT(&left
) = VT_R8
;
7579 V_VT(&right
) = VT_R8
;
7581 hres
= pVarDiv(&left
, &right
, &result
);
7582 ok(hres
== DISP_E_OVERFLOW
&& V_VT(&result
) == VT_EMPTY
,
7583 "VARDIV: Division by (0.0/0.0) should result in DISP_E_OVERFLOW but got 0x%X\n", hres
);
7585 SysFreeString(num1_str
);
7586 SysFreeString(num2_str
);
7589 static HRESULT (WINAPI
*pVarIdiv
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
7591 #define VARIDIV(vt1,val1,vt2,val2,rvt,rval) \
7592 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
7593 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
7594 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
7595 test_var_call2( __LINE__, pVarIdiv, &left, &right, &exp )
7597 /* Skip any type that is not defined or produces an error for every case */
7598 #define SKIPTESTIDIV(a) \
7599 if (a == VT_ERROR || a == VT_VARIANT || \
7600 a == VT_DISPATCH || a == VT_UNKNOWN || \
7601 a == VT_RECORD || a > VT_UINT || \
7602 a == 15 /*not defined*/) \
7605 static void test_VarIdiv(void)
7607 static const WCHAR str1
[] = { '1','\0' };
7608 static const WCHAR str2
[] = { '2','\0' };
7609 VARIANT left
, right
, exp
, result
, cy
, dec
;
7610 BSTR num1_str
, num2_str
;
7616 num1_str
= SysAllocString(str1
);
7617 num2_str
= SysAllocString(str2
);
7619 /* Test all possible flag/vt combinations & the resulting vt type */
7620 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
7622 VARTYPE leftvt
, rightvt
, resvt
;
7624 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
7626 SKIPTESTIDIV(leftvt
);
7628 /* Check if we need/have support for I8 and/or UI8 */
7629 if ((leftvt
== VT_I8
|| leftvt
== VT_UI8
) && !has_i8
)
7632 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
7635 SKIPTESTIDIV(rightvt
);
7637 /* Native crashes with extra flag VT_BYREF */
7638 if (ExtraFlags
[i
] == VT_BYREF
)
7641 /* Check if we need/have support for I8 and/or UI8 */
7642 if ((rightvt
== VT_I8
|| rightvt
== VT_UI8
) && !has_i8
)
7645 memset(&left
, 0, sizeof(left
));
7646 memset(&right
, 0, sizeof(right
));
7647 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
7648 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
7649 V_VT(&result
) = VT_EMPTY
;
7652 if (leftvt
== VT_BSTR
)
7653 V_BSTR(&left
) = num2_str
;
7654 else if (leftvt
== VT_DECIMAL
)
7656 VarDecFromR8(2.0, &V_DECIMAL(&left
));
7657 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
7660 /* Division by 0 is undefined */
7664 V_BSTR(&right
) = num2_str
;
7667 VarDecFromR8(2.0, &V_DECIMAL(&right
));
7668 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
7671 V_BOOL(&right
) = VARIANT_TRUE
;
7674 VarCyFromI4(10000, &V_CY(&right
));
7675 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
7677 case VT_I2
: V_I2(&right
) = 2; break;
7678 case VT_I4
: V_I4(&right
) = 2; break;
7679 case VT_R4
: V_R4(&right
) = 2.0f
; break;
7680 case VT_R8
: V_R8(&right
) = 2.0; break;
7681 case VT_DATE
: V_DATE(&right
) = 2; break;
7682 case VT_I1
: V_I1(&right
) = 2; break;
7683 case VT_UI1
: V_UI1(&right
) = 2; break;
7684 case VT_UI2
: V_UI2(&right
) = 2; break;
7685 case VT_UI4
: V_UI4(&right
) = 2; break;
7686 case VT_I8
: V_I8(&right
) = 2; break;
7687 case VT_UI8
: V_UI8(&right
) = 2; break;
7688 case VT_INT
: V_INT(&right
) = 2; break;
7689 case VT_UINT
: V_UINT(&right
) = 2; break;
7693 /* Native VarIdiv always returns an error when using extra
7694 * flags or if the variant combination is I8 and INT.
7696 if ((leftvt
== VT_I8
&& rightvt
== VT_INT
) ||
7697 (leftvt
== VT_INT
&& rightvt
== VT_I8
) ||
7698 (rightvt
== VT_EMPTY
&& leftvt
!= VT_NULL
) ||
7702 /* Determine variant type */
7703 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
7705 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
7707 else if (leftvt
== VT_I4
|| rightvt
== VT_I4
||
7708 leftvt
== VT_INT
|| rightvt
== VT_INT
||
7709 leftvt
== VT_UINT
|| rightvt
== VT_UINT
||
7710 leftvt
== VT_UI8
|| rightvt
== VT_UI8
||
7711 leftvt
== VT_UI4
|| rightvt
== VT_UI4
||
7712 leftvt
== VT_UI2
|| rightvt
== VT_UI2
||
7713 leftvt
== VT_I1
|| rightvt
== VT_I1
||
7714 leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
||
7715 leftvt
== VT_DATE
|| rightvt
== VT_DATE
||
7716 leftvt
== VT_CY
|| rightvt
== VT_CY
||
7717 leftvt
== VT_DECIMAL
|| rightvt
== VT_DECIMAL
||
7718 leftvt
== VT_R8
|| rightvt
== VT_R8
||
7719 leftvt
== VT_R4
|| rightvt
== VT_R4
)
7721 else if (leftvt
== VT_I2
|| rightvt
== VT_I2
||
7722 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
||
7725 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
7730 hres
= pVarIdiv(&left
, &right
, &result
);
7732 /* Check expected HRESULT and if result variant type is correct */
7734 ok (hres
== DISP_E_BADVARTYPE
|| hres
== DISP_E_TYPEMISMATCH
||
7735 hres
== DISP_E_DIVBYZERO
,
7736 "VarIdiv: %s|0x%X, %s|0x%X: got vt %s hr 0x%X\n",
7737 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
],
7738 vtstr(V_VT(&result
)), hres
);
7740 ok (hres
== S_OK
&& resvt
== V_VT(&result
),
7741 "VarIdiv: %s|0x%X, %s|0x%X: expected vt %s hr 0x%X, got vt %s hr 0x%X\n",
7742 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
], vtstr(resvt
),
7743 S_OK
, vtstr(V_VT(&result
)), hres
);
7748 /* Test return values for all the good cases */
7749 VARIDIV(EMPTY
,0,NULL
,0,NULL
,0);
7750 VARIDIV(EMPTY
,0,I2
,1,I2
,0);
7751 VARIDIV(EMPTY
,0,I4
,1,I4
,0);
7752 VARIDIV(EMPTY
,0,R4
,1.0f
,I4
,0);
7753 VARIDIV(EMPTY
,0,R8
,1.0,I4
,0);
7754 VARIDIV(EMPTY
,0,DATE
,1.0,I4
,0);
7755 VARIDIV(EMPTY
,0,BSTR
,num1_str
,I4
,0);
7756 VARIDIV(EMPTY
,0,BOOL
,VARIANT_TRUE
,I2
,0);
7757 VARIDIV(EMPTY
,0,I1
,1,I4
,0);
7758 VARIDIV(EMPTY
,0,UI1
,1,I2
,0);
7759 VARIDIV(EMPTY
,0,UI2
,1,I4
,0);
7760 VARIDIV(EMPTY
,0,UI4
,1,I4
,0);
7763 VARIDIV(EMPTY
,0,I8
,1,I8
,0);
7764 VARIDIV(EMPTY
,0,UI8
,1,I4
,0);
7766 VARIDIV(EMPTY
,0,INT
,1,I4
,0);
7767 VARIDIV(EMPTY
,0,UINT
,1,I4
,0);
7768 VARIDIV(NULL
,0,EMPTY
,0,NULL
,0);
7769 VARIDIV(NULL
,0,NULL
,0,NULL
,0);
7770 VARIDIV(NULL
,0,I2
,1,NULL
,0);
7771 VARIDIV(NULL
,0,I4
,1,NULL
,0);
7772 VARIDIV(NULL
,0,R4
,1,NULL
,0);
7773 VARIDIV(NULL
,0,R8
,1,NULL
,0);
7774 VARIDIV(NULL
,0,DATE
,1,NULL
,0);
7775 VARIDIV(NULL
,0,BSTR
,num1_str
,NULL
,0);
7776 VARIDIV(NULL
,0,BOOL
,VARIANT_TRUE
,NULL
,0);
7777 VARIDIV(NULL
,0,I1
,1,NULL
,0);
7778 VARIDIV(NULL
,0,UI1
,1,NULL
,0);
7779 VARIDIV(NULL
,0,UI2
,1,NULL
,0);
7780 VARIDIV(NULL
,0,UI4
,1,NULL
,0);
7783 VARIDIV(NULL
,0,I8
,1,NULL
,0);
7784 VARIDIV(NULL
,0,UI8
,1,NULL
,0);
7786 VARIDIV(NULL
,0,INT
,1,NULL
,0);
7787 VARIDIV(NULL
,0,UINT
,1,NULL
,0);
7788 VARIDIV(I2
,2,NULL
,0,NULL
,0);
7789 VARIDIV(I2
,2,I2
,1,I2
,2);
7790 VARIDIV(I2
,2,I4
,1,I4
,2);
7791 VARIDIV(I2
,2,R4
,1,I4
,2);
7792 VARIDIV(I2
,2,R8
,1,I4
,2);
7793 VARIDIV(I2
,2,DATE
,1,I4
,2);
7794 VARIDIV(I2
,2,BSTR
,num1_str
,I4
,2);
7795 VARIDIV(I2
,2,BOOL
,VARIANT_TRUE
,I2
,-2);
7796 VARIDIV(I2
,2,I1
,1,I4
,2);
7797 VARIDIV(I2
,2,UI1
,1,I2
,2);
7798 VARIDIV(I2
,2,UI2
,1,I4
,2);
7799 VARIDIV(I2
,2,UI4
,1,I4
,2);
7802 VARIDIV(I2
,2,I8
,1,I8
,2);
7803 VARIDIV(I2
,2,UI8
,1,I4
,2);
7805 VARIDIV(I2
,2,INT
,1,I4
,2);
7806 VARIDIV(I2
,2,UINT
,1,I4
,2);
7807 VARIDIV(I4
,2,NULL
,0,NULL
,0);
7808 VARIDIV(I4
,2,I2
,1,I4
,2);
7809 VARIDIV(I4
,2,I4
,1,I4
,2);
7810 VARIDIV(I4
,2,R4
,1,I4
,2);
7811 VARIDIV(I4
,2,R8
,1,I4
,2);
7812 VARIDIV(I4
,2,DATE
,1,I4
,2);
7813 VARIDIV(I4
,2,BSTR
,num1_str
,I4
,2);
7814 VARIDIV(I4
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
7815 VARIDIV(I4
,2,I1
,1,I4
,2);
7816 VARIDIV(I4
,2,UI1
,1,I4
,2);
7817 VARIDIV(I4
,2,UI2
,1,I4
,2);
7818 VARIDIV(I4
,2,UI4
,1,I4
,2);
7821 VARIDIV(I4
,2,I8
,1,I8
,2);
7822 VARIDIV(I4
,2,UI8
,1,I4
,2);
7824 VARIDIV(I4
,2,INT
,1,I4
,2);
7825 VARIDIV(I4
,2,UINT
,1,I4
,2);
7826 VARIDIV(R4
,2.0f
,NULL
,0,NULL
,0);
7827 VARIDIV(R4
,2.0f
,I2
,1,I4
,2);
7828 VARIDIV(R4
,2.0f
,I4
,1,I4
,2);
7829 VARIDIV(R4
,2.0f
,R4
,1.0f
,I4
,2);
7830 VARIDIV(R4
,2.0f
,R8
,1.0,I4
,2);
7831 VARIDIV(R4
,2.0f
,DATE
,1,I4
,2);
7832 VARIDIV(R4
,2.0f
,BSTR
,num1_str
,I4
,2);
7833 VARIDIV(R4
,2.0f
,BOOL
,VARIANT_TRUE
,I4
,-2);
7834 VARIDIV(R4
,2.0f
,I1
,1,I4
,2);
7835 VARIDIV(R4
,2.0f
,UI1
,1,I4
,2);
7836 VARIDIV(R4
,2.0f
,UI2
,1,I4
,2);
7837 VARIDIV(R4
,2.0f
,UI4
,1,I4
,2);
7840 VARIDIV(R4
,2.0f
,I8
,1,I8
,2);
7841 VARIDIV(R4
,2.0f
,UI8
,1,I4
,2);
7843 VARIDIV(R4
,2.0f
,INT
,1,I4
,2);
7844 VARIDIV(R4
,2.0f
,UINT
,1,I4
,2);
7845 VARIDIV(R8
,2.0,NULL
,0,NULL
,0);
7846 VARIDIV(R8
,2.0,I2
,1,I4
,2);
7847 VARIDIV(R8
,2.0,I4
,1,I4
,2);
7848 VARIDIV(R8
,2.0,R4
,1,I4
,2);
7849 VARIDIV(R8
,2.0,R8
,1,I4
,2);
7850 VARIDIV(R8
,2.0,DATE
,1,I4
,2);
7851 VARIDIV(R8
,2.0,BSTR
,num1_str
,I4
,2);
7852 VARIDIV(R8
,2.0,BOOL
,VARIANT_TRUE
,I4
,-2);
7853 VARIDIV(R8
,2.0,I1
,1,I4
,2);
7854 VARIDIV(R8
,2.0,UI1
,1,I4
,2);
7855 VARIDIV(R8
,2.0,UI2
,1,I4
,2);
7856 VARIDIV(R8
,2.0,UI4
,1,I4
,2);
7859 VARIDIV(R8
,2.0,I8
,1,I8
,2);
7860 VARIDIV(R8
,2.0,UI8
,1,I4
,2);
7862 VARIDIV(R8
,2.0,INT
,1,I4
,2);
7863 VARIDIV(R8
,2.0,UINT
,1,I4
,2);
7864 VARIDIV(DATE
,2,NULL
,0,NULL
,0);
7865 VARIDIV(DATE
,2,I2
,1,I4
,2);
7866 VARIDIV(DATE
,2,I4
,1,I4
,2);
7867 VARIDIV(DATE
,2,R4
,1,I4
,2);
7868 VARIDIV(DATE
,2,R8
,1,I4
,2);
7869 VARIDIV(DATE
,2,DATE
,1,I4
,2);
7870 VARIDIV(DATE
,2,BSTR
,num1_str
,I4
,2);
7871 VARIDIV(DATE
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
7872 VARIDIV(DATE
,2,I1
,1,I4
,2);
7873 VARIDIV(DATE
,2,UI1
,1,I4
,2);
7874 VARIDIV(DATE
,2,UI2
,1,I4
,2);
7875 VARIDIV(DATE
,2,UI4
,1,I4
,2);
7878 VARIDIV(DATE
,2,I8
,1,I8
,2);
7879 VARIDIV(DATE
,2,UI8
,1,I4
,2);
7881 VARIDIV(DATE
,2,INT
,1,I4
,2);
7882 VARIDIV(DATE
,2,UINT
,1,I4
,2);
7883 VARIDIV(BSTR
,num2_str
,NULL
,0,NULL
,0);
7884 VARIDIV(BSTR
,num2_str
,I2
,1,I4
,2);
7885 VARIDIV(BSTR
,num2_str
,I4
,1,I4
,2);
7886 VARIDIV(BSTR
,num2_str
,R4
,1.0f
,I4
,2);
7887 VARIDIV(BSTR
,num2_str
,R8
,1.0,I4
,2);
7888 VARIDIV(BSTR
,num2_str
,DATE
,1,I4
,2);
7889 VARIDIV(BSTR
,num2_str
,BSTR
,num1_str
,I4
,2);
7890 VARIDIV(BSTR
,num2_str
,BOOL
,VARIANT_TRUE
,I4
,-2);
7891 VARIDIV(BSTR
,num2_str
,I1
,1,I4
,2);
7892 VARIDIV(BSTR
,num2_str
,UI1
,1,I4
,2);
7893 VARIDIV(BSTR
,num2_str
,UI2
,1,I4
,2);
7894 VARIDIV(BSTR
,num2_str
,UI4
,1,I4
,2);
7897 VARIDIV(BSTR
,num2_str
,I8
,1,I8
,2);
7898 VARIDIV(BSTR
,num2_str
,UI8
,1,I4
,2);
7900 VARIDIV(BSTR
,num2_str
,INT
,1,I4
,2);
7901 VARIDIV(BSTR
,num2_str
,UINT
,1,I4
,2);
7902 VARIDIV(BOOL
,VARIANT_TRUE
,NULL
,0,NULL
,0);
7903 VARIDIV(BOOL
,VARIANT_TRUE
,I2
,1,I2
,-1);
7904 VARIDIV(BOOL
,VARIANT_TRUE
,I4
,1,I4
,-1);
7905 VARIDIV(BOOL
,VARIANT_TRUE
,R4
,1.0f
,I4
,-1);
7906 VARIDIV(BOOL
,VARIANT_TRUE
,R8
,1.0,I4
,-1);
7907 VARIDIV(BOOL
,VARIANT_TRUE
,DATE
,1,I4
,-1);
7908 VARIDIV(BOOL
,VARIANT_TRUE
,BSTR
,num1_str
,I4
,-1);
7909 VARIDIV(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
,I2
,1);
7910 VARIDIV(BOOL
,VARIANT_TRUE
,I1
,1,I4
,-1);
7911 VARIDIV(BOOL
,VARIANT_TRUE
,UI1
,1,I2
,-1);
7912 VARIDIV(BOOL
,VARIANT_TRUE
,UI2
,1,I4
,-1);
7913 VARIDIV(BOOL
,VARIANT_TRUE
,UI4
,1,I4
,-1);
7916 VARIDIV(BOOL
,VARIANT_TRUE
,I8
,1,I8
,-1);
7917 VARIDIV(BOOL
,VARIANT_TRUE
,UI8
,1,I4
,-1);
7919 VARIDIV(BOOL
,VARIANT_TRUE
,INT
,1,I4
,-1);
7920 VARIDIV(BOOL
,VARIANT_TRUE
,UINT
,1,I4
,-1);
7921 VARIDIV(I1
,2,NULL
,0,NULL
,0);
7922 VARIDIV(I1
,2,I2
,1,I4
,2);
7923 VARIDIV(I1
,2,I4
,1,I4
,2);
7924 VARIDIV(I1
,2,R4
,1.0f
,I4
,2);
7925 VARIDIV(I1
,2,R8
,1.0,I4
,2);
7926 VARIDIV(I1
,2,DATE
,1,I4
,2);
7927 VARIDIV(I1
,2,BSTR
,num1_str
,I4
,2);
7928 VARIDIV(I1
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
7929 VARIDIV(I1
,2,I1
,1,I4
,2);
7930 VARIDIV(I1
,2,UI1
,1,I4
,2);
7931 VARIDIV(I1
,2,UI2
,1,I4
,2);
7932 VARIDIV(I1
,2,UI4
,1,I4
,2);
7935 VARIDIV(I1
,2,I8
,1,I8
,2);
7936 VARIDIV(I1
,2,UI8
,1,I4
,2);
7938 VARIDIV(I1
,2,INT
,1,I4
,2);
7939 VARIDIV(I1
,2,UINT
,1,I4
,2);
7940 VARIDIV(UI1
,2,NULL
,0,NULL
,0);
7941 VARIDIV(UI1
,2,I2
,1,I2
,2);
7942 VARIDIV(UI1
,2,I4
,1,I4
,2);
7943 VARIDIV(UI1
,2,R4
,1.0f
,I4
,2);
7944 VARIDIV(UI1
,2,R8
,1.0,I4
,2);
7945 VARIDIV(UI1
,2,DATE
,1,I4
,2);
7946 VARIDIV(UI1
,2,BSTR
,num1_str
,I4
,2);
7947 VARIDIV(UI1
,2,BOOL
,VARIANT_TRUE
,I2
,-2);
7948 VARIDIV(UI1
,2,I1
,1,I4
,2);
7949 VARIDIV(UI1
,2,UI1
,1,UI1
,2);
7950 VARIDIV(UI1
,2,UI2
,1,I4
,2);
7951 VARIDIV(UI1
,2,UI4
,1,I4
,2);
7954 VARIDIV(UI1
,2,I8
,1,I8
,2);
7955 VARIDIV(UI1
,2,UI8
,1,I4
,2);
7957 VARIDIV(UI1
,2,INT
,1,I4
,2);
7958 VARIDIV(UI1
,2,UINT
,1,I4
,2);
7959 VARIDIV(UI2
,2,NULL
,0,NULL
,0);
7960 VARIDIV(UI2
,2,I2
,1,I4
,2);
7961 VARIDIV(UI2
,2,I4
,1,I4
,2);
7962 VARIDIV(UI2
,2,R4
,1.0f
,I4
,2);
7963 VARIDIV(UI2
,2,R8
,1.0,I4
,2);
7964 VARIDIV(UI2
,2,DATE
,1,I4
,2);
7965 VARIDIV(UI2
,2,BSTR
,num1_str
,I4
,2);
7966 VARIDIV(UI2
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
7967 VARIDIV(UI2
,2,I1
,1,I4
,2);
7968 VARIDIV(UI2
,2,UI1
,1,I4
,2);
7969 VARIDIV(UI2
,2,UI2
,1,I4
,2);
7970 VARIDIV(UI2
,2,UI4
,1,I4
,2);
7973 VARIDIV(UI2
,2,I8
,1,I8
,2);
7974 VARIDIV(UI2
,2,UI8
,1,I4
,2);
7976 VARIDIV(UI2
,2,INT
,1,I4
,2);
7977 VARIDIV(UI2
,2,UINT
,1,I4
,2);
7978 VARIDIV(UI4
,2,NULL
,0,NULL
,0);
7979 VARIDIV(UI4
,2,I2
,1,I4
,2);
7980 VARIDIV(UI4
,2,I4
,1,I4
,2);
7981 VARIDIV(UI4
,2,R4
,1.0f
,I4
,2);
7982 VARIDIV(UI4
,2,R8
,1.0,I4
,2);
7983 VARIDIV(UI4
,2,DATE
,1,I4
,2);
7984 VARIDIV(UI4
,2,BSTR
,num1_str
,I4
,2);
7985 VARIDIV(UI4
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
7986 VARIDIV(UI4
,2,I1
,1,I4
,2);
7987 VARIDIV(UI4
,2,UI1
,1,I4
,2);
7988 VARIDIV(UI4
,2,UI2
,1,I4
,2);
7989 VARIDIV(UI4
,2,UI4
,1,I4
,2);
7992 VARIDIV(UI4
,2,I8
,1,I8
,2);
7993 VARIDIV(UI4
,2,UI8
,1,I4
,2);
7995 VARIDIV(UI4
,2,INT
,1,I4
,2);
7996 VARIDIV(UI4
,2,UINT
,1,I4
,2);
7999 VARIDIV(I8
,2,NULL
,0,NULL
,0);
8000 VARIDIV(I8
,2,I2
,1,I8
,2);
8001 VARIDIV(I8
,2,I4
,1,I8
,2);
8002 VARIDIV(I8
,2,R4
,1.0f
,I8
,2);
8003 VARIDIV(I8
,2,R8
,1.0,I8
,2);
8004 VARIDIV(I8
,2,DATE
,1,I8
,2);
8005 VARIDIV(I8
,2,BSTR
,num1_str
,I8
,2);
8006 VARIDIV(I8
,2,BOOL
,1,I8
,2);
8007 VARIDIV(I8
,2,I1
,1,I8
,2);
8008 VARIDIV(I8
,2,UI1
,1,I8
,2);
8009 VARIDIV(I8
,2,UI2
,1,I8
,2);
8010 VARIDIV(I8
,2,UI4
,1,I8
,2);
8011 VARIDIV(I8
,2,I8
,1,I8
,2);
8012 VARIDIV(I8
,2,UI8
,1,I8
,2);
8013 VARIDIV(I8
,2,UINT
,1,I8
,2);
8014 VARIDIV(UI8
,2,NULL
,0,NULL
,0);
8015 VARIDIV(UI8
,2,I2
,1,I4
,2);
8016 VARIDIV(UI8
,2,I4
,1,I4
,2);
8017 VARIDIV(UI8
,2,R4
,1.0f
,I4
,2);
8018 VARIDIV(UI8
,2,R8
,1.0,I4
,2);
8019 VARIDIV(UI8
,2,DATE
,1,I4
,2);
8020 VARIDIV(UI8
,2,BSTR
,num1_str
,I4
,2);
8021 VARIDIV(UI8
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
8022 VARIDIV(UI8
,2,I1
,1,I4
,2);
8023 VARIDIV(UI8
,2,UI1
,1,I4
,2);
8024 VARIDIV(UI8
,2,UI2
,1,I4
,2);
8025 VARIDIV(UI8
,2,UI4
,1,I4
,2);
8026 VARIDIV(UI8
,2,I8
,1,I8
,2);
8027 VARIDIV(UI8
,2,UI8
,1,I4
,2);
8028 VARIDIV(UI8
,2,INT
,1,I4
,2);
8029 VARIDIV(UI8
,2,UINT
,1,I4
,2);
8031 VARIDIV(INT
,2,NULL
,0,NULL
,0);
8032 VARIDIV(INT
,2,I2
,1,I4
,2);
8033 VARIDIV(INT
,2,I4
,1,I4
,2);
8034 VARIDIV(INT
,2,R4
,1.0f
,I4
,2);
8035 VARIDIV(INT
,2,R8
,1.0,I4
,2);
8036 VARIDIV(INT
,2,DATE
,1,I4
,2);
8037 VARIDIV(INT
,2,BSTR
,num1_str
,I4
,2);
8038 VARIDIV(INT
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
8039 VARIDIV(INT
,2,I1
,1,I4
,2);
8040 VARIDIV(INT
,2,UI1
,1,I4
,2);
8041 VARIDIV(INT
,2,UI2
,1,I4
,2);
8042 VARIDIV(INT
,2,UI4
,1,I4
,2);
8045 VARIDIV(INT
,2,UI8
,1,I4
,2);
8047 VARIDIV(INT
,2,INT
,1,I4
,2);
8048 VARIDIV(INT
,2,UINT
,1,I4
,2);
8049 VARIDIV(UINT
,2,NULL
,0,NULL
,0);
8050 VARIDIV(UINT
,2,I2
,1,I4
,2);
8051 VARIDIV(UINT
,2,I4
,1,I4
,2);
8052 VARIDIV(UINT
,2,R4
,1.0f
,I4
,2);
8053 VARIDIV(UINT
,2,R8
,1.0,I4
,2);
8054 VARIDIV(UINT
,2,DATE
,1,I4
,2);
8055 VARIDIV(UINT
,2,BSTR
,num1_str
,I4
,2);
8056 VARIDIV(UINT
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
8057 VARIDIV(UINT
,2,I1
,1,I4
,2);
8058 VARIDIV(UINT
,2,UI1
,1,I4
,2);
8059 VARIDIV(UINT
,2,UI2
,1,I4
,2);
8060 VARIDIV(UINT
,2,UI4
,1,I4
,2);
8063 VARIDIV(UINT
,2,I8
,1,I8
,2);
8064 VARIDIV(UINT
,2,UI8
,1,I4
,2);
8066 VARIDIV(UINT
,2,INT
,1,I4
,2);
8067 VARIDIV(UINT
,2,UINT
,1,I4
,2);
8069 /* Manually test some VT_CY, VT_DECIMAL variants */
8071 hres
= VarCyFromI4(10000, &V_CY(&cy
));
8072 ok(hres
== S_OK
, "VarCyFromI4 failed!\n");
8073 V_VT(&dec
) = VT_DECIMAL
;
8074 hres
= VarDecFromR8(2.0, &V_DECIMAL(&dec
));
8075 ok(hres
== S_OK
, "VarDecFromR4 failed!\n");
8076 memset(&left
, 0, sizeof(left
));
8077 memset(&right
, 0, sizeof(right
));
8078 V_VT(&left
) = VT_I4
;
8080 V_VT(&right
) = VT_I8
;
8083 hres
= pVarIdiv(&cy
, &cy
, &result
);
8084 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
8085 "VARIDIV: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8086 S_OK
, hres
, vtstr(V_VT(&result
)));
8087 ok(hres
== S_OK
&& V_I4(&result
) == 1,
8088 "VARIDIV: CY value %d, expected %d\n", V_I4(&result
), 1);
8092 hres
= pVarIdiv(&cy
, &right
, &result
);
8093 ok(hres
== S_OK
&& V_VT(&result
) == VT_I8
,
8094 "VARIDIV: expected coerced hres 0x%X type VT_I8, got hres 0x%X type %s!\n",
8095 S_OK
, hres
, vtstr(V_VT(&result
)));
8096 ok(hres
== S_OK
&& V_I8(&result
) == 5000,
8097 "VARIDIV: CY value 0x%x%08x, expected 0x%x\n",
8098 (DWORD
)(V_I8(&result
) >>32), (DWORD
)V_I8(&result
), 5000);
8101 hres
= pVarIdiv(&left
, &cy
, &result
);
8102 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
8103 "VARIDIV: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8104 S_OK
, hres
, vtstr(V_VT(&result
)));
8105 ok(hres
== S_OK
&& V_I4(&result
) == 0,
8106 "VARIDIV: CY value %d, expected %d\n", V_I4(&result
), 0);
8108 hres
= pVarIdiv(&left
, &dec
, &result
);
8109 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
8110 "VARIDIV: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8111 S_OK
, hres
, vtstr(V_VT(&result
)));
8112 ok(hres
== S_OK
&& V_I4(&result
) == 50,
8113 "VARIDIV: DECIMAL value %d, expected %d\n", V_I4(&result
), 50);
8115 hres
= pVarIdiv(&dec
, &dec
, &result
);
8116 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
8117 "VARIDIV: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8118 S_OK
, hres
, vtstr(V_VT(&result
)));
8119 ok(hres
== S_OK
&& V_I4(&result
) == 1,
8120 "VARIDIV: DECIMAL value %d, expected %d\n", V_I4(&result
), 1);
8124 hres
= pVarIdiv(&dec
, &right
, &result
);
8125 ok(hres
== S_OK
&& V_VT(&result
) == VT_I8
,
8126 "VARIDIV: expected coerced hres 0x%X type VT_I8, got hres 0x%X type %s!\n",
8127 S_OK
, hres
, vtstr(V_VT(&result
)));
8128 ok(hres
== S_OK
&& V_I8(&result
) == 1,
8129 "VARIDIV: DECIMAL value 0x%x%08x, expected %d\n",
8130 (DWORD
)(V_I8(&result
) >> 32), (DWORD
)V_I8(&result
), 1);
8133 /* Check for division by zero */
8134 V_VT(&left
) = VT_INT
;
8136 V_VT(&right
) = VT_INT
;
8138 hres
= pVarIdiv(&left
, &right
, &result
);
8139 ok(hres
== DISP_E_DIVBYZERO
&& V_VT(&result
) == VT_EMPTY
,
8140 "VARIDIV: Division by 0 should result in DISP_E_DIVBYZERO but got 0x%X\n", hres
);
8142 V_VT(&left
) = VT_INT
;
8144 V_VT(&right
) = VT_INT
;
8146 hres
= pVarIdiv(&left
, &right
, &result
);
8147 ok(hres
== DISP_E_DIVBYZERO
&& V_VT(&result
) == VT_EMPTY
,
8148 "VARIDIV: Division by 0 should result in DISP_E_DIVBYZERO but got 0x%X\n", hres
);
8150 SysFreeString(num1_str
);
8151 SysFreeString(num2_str
);
8155 static HRESULT (WINAPI
*pVarImp
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
8157 #define VARIMP(vt1,val1,vt2,val2,rvt,rval) \
8158 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
8159 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
8160 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
8161 test_var_call2( __LINE__, pVarImp, &left, &right, &exp )
8163 /* Skip any type that is not defined or produces an error for every case */
8164 #define SKIPTESTIMP(a) \
8165 if (a == VT_ERROR || a == VT_VARIANT || \
8166 a == VT_DISPATCH || a == VT_UNKNOWN || \
8167 a == VT_RECORD || a > VT_UINT || \
8168 a == 15 /*not defined*/) \
8171 static void test_VarImp(void)
8173 static const WCHAR szFalse
[] = { '#','F','A','L','S','E','#','\0' };
8174 static const WCHAR szTrue
[] = { '#','T','R','U','E','#','\0' };
8175 VARIANT left
, right
, exp
, result
, cy
, dec
;
8176 BSTR true_str
, false_str
;
8182 true_str
= SysAllocString(szTrue
);
8183 false_str
= SysAllocString(szFalse
);
8185 /* Test all possible flag/vt combinations & the resulting vt type */
8186 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
8188 VARTYPE leftvt
, rightvt
, resvt
;
8190 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
8192 SKIPTESTIMP(leftvt
);
8194 /* Check if we need/have support for I8 and/or UI8 */
8195 if ((leftvt
== VT_I8
|| leftvt
== VT_UI8
) && !has_i8
)
8198 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
8201 SKIPTESTIMP(rightvt
);
8203 /* Native crashes when using the extra flag VT_BYREF
8204 * or with the following VT combinations
8206 if ((leftvt
== VT_UI4
&& rightvt
== VT_BSTR
) ||
8207 (leftvt
== VT_UI8
&& rightvt
== VT_BSTR
) ||
8208 ExtraFlags
[i
] == VT_BYREF
)
8211 /* Check if we need/have support for I8 and/or UI8 */
8212 if ((rightvt
== VT_I8
|| rightvt
== VT_UI8
) && !has_i8
)
8215 memset(&left
, 0, sizeof(left
));
8216 memset(&right
, 0, sizeof(right
));
8217 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
8218 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
8219 V_VT(&result
) = VT_EMPTY
;
8222 if (leftvt
== VT_BSTR
)
8223 V_BSTR(&left
) = true_str
;
8225 /* This allows us to test return types that are not NULL
8226 * (NULL Imp value = n, NULL Imp 0 = NULL)
8231 V_BSTR(&right
) = true_str
;
8234 VarDecFromR8(2.0, &V_DECIMAL(&right
));
8235 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
8238 V_BOOL(&right
) = VARIANT_TRUE
;
8240 case VT_I1
: V_I1(&right
) = 2; break;
8241 case VT_I2
: V_I2(&right
) = 2; break;
8242 case VT_I4
: V_I4(&right
) = 2; break;
8243 case VT_R4
: V_R4(&right
) = 2.0f
; break;
8244 case VT_R8
: V_R8(&right
) = 2.0; break;
8245 case VT_CY
: V_CY(&right
).int64
= 10000; break;
8246 case VT_DATE
: V_DATE(&right
) = 2; break;
8247 case VT_I8
: V_I8(&right
) = 2; break;
8248 case VT_INT
: V_INT(&right
) = 2; break;
8249 case VT_UINT
: V_UINT(&right
) = 2; break;
8250 case VT_UI1
: V_UI1(&right
) = 2; break;
8251 case VT_UI2
: V_UI2(&right
) = 2; break;
8252 case VT_UI4
: V_UI4(&right
) = 2; break;
8253 case VT_UI8
: V_UI8(&right
) = 2; break;
8257 /* Native VarImp always returns an error when using extra
8258 * flags or if the variants are I8 and INT.
8260 if ((leftvt
== VT_I8
&& rightvt
== VT_INT
) ||
8264 /* Determine result type */
8265 else if ((leftvt
== VT_BSTR
&& rightvt
== VT_NULL
) ||
8266 (leftvt
== VT_NULL
&& rightvt
== VT_NULL
) ||
8267 (leftvt
== VT_NULL
&& rightvt
== VT_EMPTY
))
8269 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
8271 else if (leftvt
== VT_I4
|| rightvt
== VT_I4
||
8272 leftvt
== VT_INT
|| rightvt
== VT_INT
||
8273 leftvt
== VT_UINT
|| rightvt
== VT_UINT
||
8274 leftvt
== VT_UI4
|| rightvt
== VT_UI4
||
8275 leftvt
== VT_UI8
|| rightvt
== VT_UI8
||
8276 leftvt
== VT_UI2
|| rightvt
== VT_UI2
||
8277 leftvt
== VT_DECIMAL
|| rightvt
== VT_DECIMAL
||
8278 leftvt
== VT_DATE
|| rightvt
== VT_DATE
||
8279 leftvt
== VT_CY
|| rightvt
== VT_CY
||
8280 leftvt
== VT_R8
|| rightvt
== VT_R8
||
8281 leftvt
== VT_R4
|| rightvt
== VT_R4
||
8282 leftvt
== VT_I1
|| rightvt
== VT_I1
)
8284 else if ((leftvt
== VT_UI1
&& rightvt
== VT_UI1
) ||
8285 (leftvt
== VT_UI1
&& rightvt
== VT_NULL
) ||
8286 (leftvt
== VT_NULL
&& rightvt
== VT_UI1
))
8288 else if (leftvt
== VT_EMPTY
|| rightvt
== VT_EMPTY
||
8289 leftvt
== VT_I2
|| rightvt
== VT_I2
||
8290 leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
8292 else if (leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
||
8293 leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
)
8296 hres
= pVarImp(&left
, &right
, &result
);
8298 /* Check expected HRESULT and if result variant type is correct */
8300 ok (hres
== DISP_E_BADVARTYPE
|| hres
== DISP_E_TYPEMISMATCH
,
8301 "VarImp: %s|0x%X, %s|0x%X: got vt %s hr 0x%X\n",
8302 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
],
8303 vtstr(V_VT(&result
)), hres
);
8305 ok (hres
== S_OK
&& resvt
== V_VT(&result
),
8306 "VarImp: %s|0x%X, %s|0x%X: expected vt %s hr 0x%X, got vt %s hr 0x%X\n",
8307 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
], vtstr(resvt
),
8308 S_OK
, vtstr(V_VT(&result
)), hres
);
8313 VARIMP(EMPTY
,0,EMPTY
,0,I2
,-1);
8314 VARIMP(EMPTY
,0,NULL
,0,I2
,-1);
8315 VARIMP(EMPTY
,0,I2
,-1,I2
,-1);
8316 VARIMP(EMPTY
,0,I4
,-1,I4
,-1);
8317 VARIMP(EMPTY
,0,R4
,0.0f
,I4
,-1);
8318 VARIMP(EMPTY
,0,R8
,-1.0,I4
,-1);
8319 VARIMP(EMPTY
,0,DATE
,0,I4
,-1);
8320 VARIMP(EMPTY
,0,BSTR
,true_str
,I2
,-1);
8321 VARIMP(EMPTY
,0,BOOL
,VARIANT_FALSE
,I2
,-1);
8322 VARIMP(EMPTY
,0,I1
,0,I4
,-1);
8323 VARIMP(EMPTY
,0,UI1
,1,I2
,-1);
8324 VARIMP(EMPTY
,0,UI2
,1,I4
,-1);
8325 VARIMP(EMPTY
,0,UI4
,1,I4
,-1);
8328 VARIMP(EMPTY
,0,I8
,1,I8
,-1);
8329 VARIMP(EMPTY
,0,UI8
,1,I4
,-1);
8331 VARIMP(EMPTY
,0,INT
,-1,I4
,-1);
8332 VARIMP(EMPTY
,0,UINT
,1,I4
,-1);
8333 VARIMP(NULL
,0,EMPTY
,0,NULL
,0);
8334 VARIMP(NULL
,0,NULL
,0,NULL
,0);
8335 VARIMP(NULL
,0,I2
,-1,I2
,-1);
8336 VARIMP(NULL
,0,I4
,-1,I4
,-1);
8337 VARIMP(NULL
,0,R4
,0.0f
,NULL
,0);
8338 VARIMP(NULL
,0,R8
,-1.0,I4
,-1);
8339 VARIMP(NULL
,0,DATE
,0,NULL
,0);
8340 VARIMP(NULL
,0,BSTR
,true_str
,BOOL
,-1);
8341 VARIMP(NULL
,0,BOOL
,VARIANT_FALSE
,NULL
,0);
8342 VARIMP(NULL
,0,I1
,0,NULL
,0);
8343 VARIMP(NULL
,0,UI1
,1,UI1
,1);
8344 VARIMP(NULL
,0,UI2
,1,I4
,1);
8345 VARIMP(NULL
,0,UI4
,1,I4
,1);
8348 VARIMP(NULL
,0,I8
,1,I8
,1);
8349 VARIMP(NULL
,0,UI8
,1,I4
,1);
8351 VARIMP(NULL
,0,INT
,-1,I4
,-1);
8352 VARIMP(NULL
,0,UINT
,1,I4
,1);
8353 VARIMP(I2
,-1,EMPTY
,0,I2
,0);
8354 VARIMP(I2
,-1,I2
,-1,I2
,-1);
8355 VARIMP(I2
,-1,I4
,-1,I4
,-1);
8356 VARIMP(I2
,-1,R4
,0.0f
,I4
,0);
8357 VARIMP(I2
,-1,R8
,-1.0,I4
,-1);
8358 VARIMP(I2
,-1,DATE
,0,I4
,0);
8359 VARIMP(I2
,-1,BSTR
,true_str
,I2
,-1);
8360 VARIMP(I2
,-1,BOOL
,VARIANT_FALSE
,I2
,0);
8361 VARIMP(I2
,-1,I1
,0,I4
,0);
8362 VARIMP(I2
,-1,UI1
,1,I2
,1);
8363 VARIMP(I2
,-1,UI2
,1,I4
,1);
8364 VARIMP(I2
,-1,UI4
,1,I4
,1);
8367 VARIMP(I2
,-1,I8
,1,I8
,1);
8368 VARIMP(I2
,-1,UI8
,1,I4
,1);
8370 VARIMP(I2
,-1,INT
,-1,I4
,-1);
8371 VARIMP(I2
,-1,UINT
,1,I4
,1);
8372 VARIMP(I4
,2,EMPTY
,0,I4
,-3);
8373 VARIMP(I4
,2,NULL
,0,I4
,-3);
8374 VARIMP(I4
,2,I2
,-1,I4
,-1);
8375 VARIMP(I4
,2,I4
,-1,I4
,-1);
8376 VARIMP(I4
,2,R4
,0.0f
,I4
,-3);
8377 VARIMP(I4
,2,R8
,-1.0,I4
,-1);
8378 VARIMP(I4
,2,DATE
,0,I4
,-3);
8379 VARIMP(I4
,2,BSTR
,true_str
,I4
,-1);
8380 VARIMP(I4
,2,BOOL
,VARIANT_FALSE
,I4
,-3);
8381 VARIMP(I4
,2,I1
,0,I4
,-3);
8382 VARIMP(I4
,2,UI1
,1,I4
,-3);
8383 VARIMP(I4
,2,UI2
,1,I4
,-3);
8384 VARIMP(I4
,2,UI4
,1,I4
,-3);
8387 VARIMP(I4
,2,I8
,1,I8
,-3);
8388 VARIMP(I4
,2,UI8
,1,I4
,-3);
8390 VARIMP(I4
,2,INT
,-1,I4
,-1);
8391 VARIMP(I4
,2,UINT
,1,I4
,-3);
8392 VARIMP(R4
,-1.0f
,EMPTY
,0,I4
,0);
8393 VARIMP(R4
,-1.0f
,NULL
,0,NULL
,0);
8394 VARIMP(R4
,-1.0f
,I2
,-1,I4
,-1);
8395 VARIMP(R4
,-1.0f
,I4
,-1,I4
,-1);
8396 VARIMP(R4
,-1.0f
,R4
,0.0f
,I4
,0);
8397 VARIMP(R4
,-1.0f
,R8
,-1.0,I4
,-1);
8398 VARIMP(R4
,-1.0f
,DATE
,1,I4
,1);
8399 VARIMP(R4
,-1.0f
,BSTR
,true_str
,I4
,-1);
8400 VARIMP(R4
,-1.0f
,BOOL
,VARIANT_FALSE
,I4
,0);
8401 VARIMP(R4
,-1.0f
,I1
,0,I4
,0);
8402 VARIMP(R4
,-1.0f
,UI1
,1,I4
,1);
8403 VARIMP(R4
,-1.0f
,UI2
,1,I4
,1);
8404 VARIMP(R4
,-1.0f
,UI4
,1,I4
,1);
8407 VARIMP(R4
,-1.0f
,I8
,1,I8
,1);
8408 VARIMP(R4
,-1.0f
,UI8
,1,I4
,1);
8410 VARIMP(R4
,-1.0f
,INT
,-1,I4
,-1);
8411 VARIMP(R4
,-1.0f
,UINT
,1,I4
,1);
8412 VARIMP(R8
,1.0,EMPTY
,0,I4
,-2);
8413 VARIMP(R8
,1.0,NULL
,0,I4
,-2);
8414 VARIMP(R8
,1.0,I2
,-1,I4
,-1);
8415 VARIMP(R8
,1.0,I4
,-1,I4
,-1);
8416 VARIMP(R8
,1.0,R4
,0.0f
,I4
,-2);
8417 VARIMP(R8
,1.0,R8
,-1.0,I4
,-1);
8418 VARIMP(R8
,1.0,DATE
,0,I4
,-2);
8419 VARIMP(R8
,1.0,BSTR
,true_str
,I4
,-1);
8420 VARIMP(R8
,1.0,BOOL
,VARIANT_FALSE
,I4
,-2);
8421 VARIMP(R8
,1.0,I1
,0,I4
,-2);
8422 VARIMP(R8
,1.0,UI1
,1,I4
,-1);
8423 VARIMP(R8
,1.0,UI2
,1,I4
,-1);
8424 VARIMP(R8
,1.0,UI4
,1,I4
,-1);
8427 VARIMP(R8
,1.0,I8
,1,I8
,-1);
8428 VARIMP(R8
,1.0,UI8
,1,I4
,-1);
8430 VARIMP(R8
,1.0,INT
,-1,I4
,-1);
8431 VARIMP(R8
,1.0,UINT
,1,I4
,-1);
8432 VARIMP(DATE
,0,EMPTY
,0,I4
,-1);
8433 VARIMP(DATE
,0,NULL
,0,I4
,-1);
8434 VARIMP(DATE
,0,I2
,-1,I4
,-1);
8435 VARIMP(DATE
,0,I4
,-1,I4
,-1);
8436 VARIMP(DATE
,0,R4
,0.0f
,I4
,-1);
8437 VARIMP(DATE
,0,R8
,-1.0,I4
,-1);
8438 VARIMP(DATE
,0,DATE
,0,I4
,-1);
8439 VARIMP(DATE
,0,BSTR
,true_str
,I4
,-1);
8440 VARIMP(DATE
,0,BOOL
,VARIANT_FALSE
,I4
,-1);
8441 VARIMP(DATE
,0,I1
,0,I4
,-1);
8442 VARIMP(DATE
,0,UI1
,1,I4
,-1);
8443 VARIMP(DATE
,0,UI2
,1,I4
,-1);
8444 VARIMP(DATE
,0,UI4
,1,I4
,-1);
8447 VARIMP(DATE
,0,I8
,1,I8
,-1);
8448 VARIMP(DATE
,0,UI8
,1,I4
,-1);
8450 VARIMP(DATE
,0,INT
,-1,I4
,-1);
8451 VARIMP(DATE
,0,UINT
,1,I4
,-1);
8452 VARIMP(BSTR
,false_str
,EMPTY
,0,I2
,-1);
8453 VARIMP(BSTR
,false_str
,NULL
,0,BOOL
,-1);
8454 VARIMP(BSTR
,false_str
,I2
,-1,I2
,-1);
8455 VARIMP(BSTR
,false_str
,I4
,-1,I4
,-1);
8456 VARIMP(BSTR
,false_str
,R4
,0.0f
,I4
,-1);
8457 VARIMP(BSTR
,false_str
,R8
,-1.0,I4
,-1);
8458 VARIMP(BSTR
,false_str
,DATE
,0,I4
,-1);
8459 VARIMP(BSTR
,false_str
,BSTR
,true_str
,BOOL
,-1);
8460 VARIMP(BSTR
,false_str
,BOOL
,VARIANT_FALSE
,BOOL
,-1);
8461 VARIMP(BSTR
,false_str
,I1
,0,I4
,-1);
8462 VARIMP(BSTR
,false_str
,UI1
,1,I2
,-1);
8463 VARIMP(BSTR
,false_str
,UI2
,1,I4
,-1);
8464 VARIMP(BSTR
,false_str
,UI4
,1,I4
,-1);
8467 VARIMP(BSTR
,false_str
,I8
,1,I8
,-1);
8468 VARIMP(BSTR
,false_str
,UI8
,1,I4
,-1);
8470 VARIMP(BSTR
,false_str
,INT
,-1,I4
,-1);
8471 VARIMP(BSTR
,false_str
,UINT
,1,I4
,-1);
8472 VARIMP(BOOL
,VARIANT_TRUE
,EMPTY
,0,I2
,0);
8473 VARIMP(BOOL
,VARIANT_TRUE
,NULL
,0,NULL
,0);
8474 VARIMP(BOOL
,VARIANT_TRUE
,I2
,-1,I2
,-1);
8475 VARIMP(BOOL
,VARIANT_TRUE
,I4
,-1,I4
,-1);
8476 VARIMP(BOOL
,VARIANT_TRUE
,R4
,0.0f
,I4
,0);
8477 VARIMP(BOOL
,VARIANT_TRUE
,R8
,-1.0,I4
,-1);
8478 VARIMP(BOOL
,VARIANT_TRUE
,DATE
,0,I4
,0);
8479 VARIMP(BOOL
,VARIANT_TRUE
,BSTR
,true_str
,BOOL
,-1);
8480 VARIMP(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
,BOOL
,0);
8481 VARIMP(BOOL
,VARIANT_TRUE
,I1
,0,I4
,0);
8482 VARIMP(BOOL
,VARIANT_TRUE
,UI1
,1,I2
,1);
8483 VARIMP(BOOL
,VARIANT_TRUE
,UI2
,1,I4
,1);
8484 VARIMP(BOOL
,VARIANT_TRUE
,UI4
,1,I4
,1);
8487 VARIMP(BOOL
,VARIANT_TRUE
,I8
,1,I8
,1);
8488 VARIMP(BOOL
,VARIANT_TRUE
,UI8
,1,I4
,1);
8490 VARIMP(BOOL
,VARIANT_TRUE
,INT
,-1,I4
,-1);
8491 VARIMP(BOOL
,VARIANT_TRUE
,UINT
,1,I4
,1);
8492 VARIMP(I1
,-1,EMPTY
,0,I4
,0);
8493 VARIMP(I1
,-1,NULL
,0,NULL
,0);
8494 VARIMP(I1
,-1,I2
,-1,I4
,-1);
8495 VARIMP(I1
,-1,I4
,-1,I4
,-1);
8496 VARIMP(I1
,-1,R4
,0.0f
,I4
,0);
8497 VARIMP(I1
,-1,R8
,-1.0,I4
,-1);
8498 VARIMP(I1
,-1,DATE
,0,I4
,0);
8499 VARIMP(I1
,-1,BSTR
,true_str
,I4
,-1);
8500 VARIMP(I1
,-1,BOOL
,VARIANT_FALSE
,I4
,0);
8501 VARIMP(I1
,-1,I1
,0,I4
,0);
8502 VARIMP(I1
,-1,UI1
,1,I4
,1);
8503 VARIMP(I1
,-1,UI2
,1,I4
,1);
8504 VARIMP(I1
,-1,UI4
,1,I4
,1);
8507 VARIMP(I1
,-1,I8
,1,I8
,1);
8508 VARIMP(I1
,-1,UI8
,1,I4
,1);
8510 VARIMP(I1
,-1,INT
,-1,I4
,-1);
8511 VARIMP(I1
,-1,UINT
,1,I4
,1);
8512 VARIMP(UI1
,0,EMPTY
,0,I2
,-1);
8513 VARIMP(UI1
,0,NULL
,0,UI1
,255);
8514 VARIMP(UI1
,0,I2
,-1,I2
,-1);
8515 VARIMP(UI1
,0,I4
,-1,I4
,-1);
8516 VARIMP(UI1
,0,R4
,0.0f
,I4
,-1);
8517 VARIMP(UI1
,0,R8
,-1.0,I4
,-1);
8518 VARIMP(UI1
,0,DATE
,0,I4
,-1);
8519 VARIMP(UI1
,0,BSTR
,true_str
,I2
,-1);
8520 VARIMP(UI1
,0,BOOL
,VARIANT_FALSE
,I2
,-1);
8521 VARIMP(UI1
,0,I1
,0,I4
,-1);
8522 VARIMP(UI1
,0,UI1
,1,UI1
,255);
8523 VARIMP(UI1
,0,UI2
,1,I4
,-1);
8524 VARIMP(UI1
,0,UI4
,1,I4
,-1);
8527 VARIMP(UI1
,0,I8
,1,I8
,-1);
8528 VARIMP(UI1
,0,UI8
,1,I4
,-1);
8530 VARIMP(UI1
,0,INT
,-1,I4
,-1);
8531 VARIMP(UI1
,0,UINT
,1,I4
,-1);
8532 VARIMP(UI2
,0,EMPTY
,0,I4
,-1);
8533 VARIMP(UI2
,0,NULL
,0,I4
,-1);
8534 VARIMP(UI2
,0,I2
,-1,I4
,-1);
8535 VARIMP(UI2
,0,I4
,-1,I4
,-1);
8536 VARIMP(UI2
,0,R4
,0.0f
,I4
,-1);
8537 VARIMP(UI2
,0,R8
,-1.0,I4
,-1);
8538 VARIMP(UI2
,0,DATE
,0,I4
,-1);
8539 VARIMP(UI2
,0,BSTR
,true_str
,I4
,-1);
8540 VARIMP(UI2
,0,BOOL
,VARIANT_FALSE
,I4
,-1);
8541 VARIMP(UI2
,0,I1
,0,I4
,-1);
8542 VARIMP(UI2
,0,UI1
,1,I4
,-1);
8543 VARIMP(UI2
,0,UI2
,1,I4
,-1);
8544 VARIMP(UI2
,0,UI4
,1,I4
,-1);
8547 VARIMP(UI2
,0,I8
,1,I8
,-1);
8548 VARIMP(UI2
,0,UI8
,1,I4
,-1);
8550 VARIMP(UI2
,0,INT
,-1,I4
,-1);
8551 VARIMP(UI2
,0,UINT
,1,I4
,-1);
8552 VARIMP(UI4
,0,EMPTY
,0,I4
,-1);
8553 VARIMP(UI4
,0,NULL
,0,I4
,-1);
8554 VARIMP(UI4
,0,I2
,-1,I4
,-1);
8555 VARIMP(UI4
,0,I4
,-1,I4
,-1);
8556 VARIMP(UI4
,0,R4
,0.0f
,I4
,-1);
8557 VARIMP(UI4
,0,R8
,-1.0,I4
,-1);
8558 VARIMP(UI4
,0,DATE
,0,I4
,-1);
8559 VARIMP(UI4
,0,BSTR
,true_str
,I4
,-1);
8560 VARIMP(UI4
,0,BOOL
,VARIANT_FALSE
,I4
,-1);
8561 VARIMP(UI4
,0,I1
,0,I4
,-1);
8562 VARIMP(UI4
,0,UI1
,1,I4
,-1);
8563 VARIMP(UI4
,0,UI2
,1,I4
,-1);
8564 VARIMP(UI4
,0,UI4
,1,I4
,-1);
8567 VARIMP(UI4
,0,I8
,1,I8
,-1);
8568 VARIMP(UI4
,0,UI8
,1,I4
,-1);
8570 VARIMP(UI4
,0,INT
,-1,I4
,-1);
8571 VARIMP(UI4
,0,UINT
,1,I4
,-1);
8574 VARIMP(I8
,-1,EMPTY
,0,I8
,0);
8575 VARIMP(I8
,-1,NULL
,0,NULL
,0);
8576 VARIMP(I8
,-1,I2
,-1,I8
,-1);
8577 VARIMP(I8
,-1,I4
,-1,I8
,-1);
8578 VARIMP(I8
,-1,R4
,0.0f
,I8
,0);
8579 VARIMP(I8
,-1,R8
,-1.0,I8
,-1);
8580 VARIMP(I8
,-1,DATE
,0,I8
,0);
8581 VARIMP(I8
,-1,BSTR
,true_str
,I8
,-1);
8582 VARIMP(I8
,-1,BOOL
,VARIANT_FALSE
,I8
,0);
8583 VARIMP(I8
,-1,I1
,0,I8
,0);
8584 VARIMP(I8
,-1,UI1
,1,I8
,1);
8585 VARIMP(I8
,-1,UI2
,1,I8
,1);
8586 VARIMP(I8
,-1,UI4
,1,I8
,1);
8587 VARIMP(I8
,-1,I8
,1,I8
,1);
8588 VARIMP(I8
,-1,UI8
,1,I8
,1);
8589 VARIMP(I8
,-1,UINT
,1,I8
,1);
8590 VARIMP(UI8
,0,EMPTY
,0,I4
,-1);
8591 VARIMP(UI8
,0,NULL
,0,I4
,-1);
8592 VARIMP(UI8
,0,I2
,-1,I4
,-1);
8593 VARIMP(UI8
,0,I4
,-1,I4
,-1);
8594 VARIMP(UI8
,0,R4
,0.0f
,I4
,-1);
8595 VARIMP(UI8
,0,R8
,-1.0,I4
,-1);
8596 VARIMP(UI8
,0,DATE
,0,I4
,-1);
8597 VARIMP(UI8
,0,BSTR
,true_str
,I4
,-1);
8598 VARIMP(UI8
,0,BOOL
,VARIANT_FALSE
,I4
,-1);
8599 VARIMP(UI8
,0,I1
,0,I4
,-1);
8600 VARIMP(UI8
,0,UI1
,1,I4
,-1);
8601 VARIMP(UI8
,0,UI2
,1,I4
,-1);
8602 VARIMP(UI8
,0,UI4
,1,I4
,-1);
8603 VARIMP(UI8
,0,I8
,1,I8
,-1);
8604 VARIMP(UI8
,0,UI8
,1,I4
,-1);
8605 VARIMP(UI8
,0,INT
,-1,I4
,-1);
8606 VARIMP(UI8
,0,UINT
,1,I4
,-1);
8608 VARIMP(INT
,-1,EMPTY
,0,I4
,0);
8609 VARIMP(INT
,-1,NULL
,0,NULL
,0);
8610 VARIMP(INT
,-1,I2
,-1,I4
,-1);
8611 VARIMP(INT
,-1,I4
,-1,I4
,-1);
8612 VARIMP(INT
,-1,R4
,0.0f
,I4
,0);
8613 VARIMP(INT
,-1,R8
,-1.0,I4
,-1);
8614 VARIMP(INT
,-1,DATE
,0,I4
,0);
8615 VARIMP(INT
,-1,BSTR
,true_str
,I4
,-1);
8616 VARIMP(INT
,-1,BOOL
,VARIANT_FALSE
,I4
,0);
8617 VARIMP(INT
,-1,I1
,0,I4
,0);
8618 VARIMP(INT
,-1,UI1
,1,I4
,1);
8619 VARIMP(INT
,-1,UI2
,1,I4
,1);
8620 VARIMP(INT
,-1,UI4
,1,I4
,1);
8623 VARIMP(INT
,-1,I8
,1,I8
,1);
8624 VARIMP(INT
,-1,UI8
,1,I4
,1);
8626 VARIMP(INT
,-1,INT
,-1,I4
,-1);
8627 VARIMP(INT
,-1,UINT
,1,I4
,1);
8628 VARIMP(UINT
,1,EMPTY
,0,I4
,-2);
8629 VARIMP(UINT
,1,NULL
,0,I4
,-2);
8630 VARIMP(UINT
,1,I2
,-1,I4
,-1);
8631 VARIMP(UINT
,1,I4
,-1,I4
,-1);
8632 VARIMP(UINT
,1,R4
,0.0f
,I4
,-2);
8633 VARIMP(UINT
,1,R8
,-1.0,I4
,-1);
8634 VARIMP(UINT
,1,DATE
,0,I4
,-2);
8635 VARIMP(UINT
,1,BSTR
,true_str
,I4
,-1);
8636 VARIMP(UINT
,1,BOOL
,VARIANT_FALSE
,I4
,-2);
8637 VARIMP(UINT
,1,I1
,0,I4
,-2);
8638 VARIMP(UINT
,1,UI1
,1,I4
,-1);
8639 VARIMP(UINT
,1,UI2
,1,I4
,-1);
8640 VARIMP(UINT
,1,UI4
,1,I4
,-1);
8643 VARIMP(UINT
,1,I8
,1,I8
,-1);
8644 VARIMP(UINT
,1,UI8
,1,I4
,-1);
8646 VARIMP(UINT
,1,INT
,-1,I4
,-1);
8647 VARIMP(UINT
,1,UINT
,1,I4
,-1);
8649 /* Manually test some VT_CY, VT_DECIMAL variants */
8651 hres
= VarCyFromI4(1, &V_CY(&cy
));
8652 ok(hres
== S_OK
, "VarCyFromI4 failed!\n");
8653 V_VT(&dec
) = VT_DECIMAL
;
8654 hres
= VarDecFromR8(2.0, &V_DECIMAL(&dec
));
8655 ok(hres
== S_OK
, "VarDecFromR4 failed!\n");
8656 memset(&left
, 0, sizeof(left
));
8657 memset(&right
, 0, sizeof(right
));
8658 V_VT(&left
) = VT_I4
;
8660 V_VT(&right
) = VT_I8
;
8663 hres
= pVarImp(&cy
, &cy
, &result
);
8664 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
8665 "VARIMP: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8666 S_OK
, hres
, vtstr(V_VT(&result
)));
8667 ok(hres
== S_OK
&& V_I4(&result
) == -1,
8668 "VARIMP: CY value %d, expected %d\n", V_I4(&result
), -1);
8672 hres
= pVarImp(&cy
, &right
, &result
);
8673 ok(hres
== S_OK
&& V_VT(&result
) == VT_I8
,
8674 "VARIMP: expected coerced hres 0x%X type VT_I8, got hres 0x%X type %s!\n",
8675 S_OK
, hres
, vtstr(V_VT(&result
)));
8676 ok(hres
== S_OK
&& V_I8(&result
) == -2,
8677 "VARIMP: CY value %x%08x, expected %d\n",
8678 (DWORD
)((V_I8(&result
)) >> 32), (DWORD
)(V_I8(&result
)), -2);
8681 hres
= pVarImp(&left
, &cy
, &result
);
8682 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
8683 "VARIMP: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8684 S_OK
, hres
, vtstr(V_VT(&result
)));
8685 ok(hres
== S_OK
&& V_I4(&result
) == -1,
8686 "VARIMP: CY value %d, expected %d\n", V_I4(&result
), -1);
8688 hres
= pVarImp(&left
, &dec
, &result
);
8689 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
8690 "VARIMP: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8691 S_OK
, hres
, vtstr(V_VT(&result
)));
8692 ok(hres
== S_OK
&& V_I4(&result
) == -1,
8693 "VARIMP: DECIMAL value %d, expected %d\n", V_I4(&result
), -1);
8695 hres
= pVarImp(&dec
, &dec
, &result
);
8696 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
8697 "VARIMP: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8698 S_OK
, hres
, vtstr(V_VT(&result
)));
8699 ok(hres
== S_OK
&& V_I4(&result
) == -1,
8700 "VARIMP: DECIMAL value %d, expected %d\n", V_I4(&result
), -1);
8704 hres
= pVarImp(&dec
, &right
, &result
);
8705 ok(hres
== S_OK
&& V_VT(&result
) == VT_I8
,
8706 "VARIMP: expected coerced hres 0x%X type VT_I8, got hres 0x%X type %s!\n",
8707 S_OK
, hres
, vtstr(V_VT(&result
)));
8708 ok(hres
== S_OK
&& V_I8(&result
) == -3,
8709 "VARIMP: DECIMAL value 0x%x%08x, expected %d\n",
8710 (DWORD
)(V_I8(&result
) >>32), (DWORD
)V_I8(&result
), -3);
8713 SysFreeString(false_str
);
8714 SysFreeString(true_str
);
8722 test_VariantClear();
8724 test_VariantCopyInd();
8725 test_VarParseNumFromStr();
8726 test_VarNumFromParseNum();
8727 test_VarUdateFromDate();
8728 test_VarDateFromUdate();
8729 test_SystemTimeToVariantTime();
8730 test_VariantTimeToSystemTime();
8731 test_DosDateTimeToVariantTime();
8732 test_VariantTimeToDosDateTime();
8747 test_VarCmp(); /* Before test_VarCat() which needs VarCmp() */