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
= GetModuleHandleA("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(32,1,1980,0,0,0,0,FALSE
,0.0); /* Fails on invalid day */
1731 ST2DT(1,1,-1,0,0,0,0,FALSE
,0.0); /* Fails on invalid year */
1732 ST2DT(1,1,10000,0,0,0,0,FALSE
,0.0); /* Fails on invalid year */
1733 ST2DT(1,1,9999,0,0,0,0,TRUE
,2958101.0); /* 9999 is last valid year */
1734 ST2DT(31,12,90,0,0,0,0,TRUE
,33238.0); /* 30 <= year < 100 is 1900+year */
1735 ST2DT(1,1,30,0,0,0,0,TRUE
,10959.0); /* 30 <= year < 100 is 1900+year */
1736 ST2DT(1,1,29,0,0,0,0,TRUE
,47119.0); /* 0 <= year < 30 is 2000+year */
1737 ST2DT(1,1,0,0,0,0,0,TRUE
,36526.0); /* 0 <= year < 30 is 2000+year */
1740 static void test_dt2st(int line
, double dt
, INT r
, WORD d
, WORD m
, WORD y
,
1741 WORD h
, WORD mn
, WORD s
, WORD ms
)
1746 memset(&st
, 0, sizeof(st
));
1747 res
= pVariantTimeToSystemTime(dt
, &st
);
1748 ok_(__FILE__
,line
)(r
== res
&&
1749 (!r
|| (st
.wYear
== y
&& st
.wMonth
== m
&& st
.wDay
== d
&&
1750 st
.wHour
== h
&& st
.wMinute
== mn
&&
1751 st
.wSecond
== s
&& st
.wMilliseconds
== ms
)),
1752 "%.16g expected %d, %d,%d,%d,%d,%d,%d,%d, got %d, %d,%d,%d,%d,%d,%d,%d\n",
1753 dt
, r
, d
, m
, y
, h
, mn
, s
, ms
, res
, st
.wDay
, st
.wMonth
,
1754 st
.wYear
, st
.wHour
, st
.wMinute
, st
.wSecond
,
1757 #define DT2ST(dt,r,d,m,y,h,mn,s,ms) test_dt2st(__LINE__,dt,r,d,m,y,h,mn,s,ms)
1759 static void test_VariantTimeToSystemTime(void)
1761 CHECKPTR(VariantTimeToSystemTime
);
1762 DT2ST(29221.0,1,1,1,1980,0,0,0,0);
1763 DT2ST(29222.0,1,2,1,1980,0,0,0,0);
1766 #define MKDOSDATE(d,m,y) ((d & 0x1f) | ((m & 0xf) << 5) | (((y-1980) & 0x7f) << 9))
1767 #define MKDOSTIME(h,m,s) (((s>>1) & 0x1f) | ((m & 0x3f) << 5) | ((h & 0x1f) << 11))
1769 static void test_dos2dt(int line
, WORD d
, WORD m
, WORD y
, WORD h
, WORD mn
,
1770 WORD s
, INT r
, double dt
)
1772 unsigned short dosDate
, dosTime
;
1777 dosDate
= MKDOSDATE(d
, m
, y
);
1778 dosTime
= MKDOSTIME(h
, mn
, s
);
1779 res
= pDosDateTimeToVariantTime(dosDate
, dosTime
, &out
);
1780 ok_(__FILE__
,line
)(r
== res
&& (!r
|| EQ_DOUBLE(out
, dt
)),
1781 "expected %d, %.16g, got %d, %.16g\n", r
, dt
, res
, out
);
1783 #define DOS2DT(d,m,y,h,mn,s,r,dt) test_dos2dt(__LINE__,d,m,y,h,mn,s,r,dt)
1785 static void test_DosDateTimeToVariantTime(void)
1787 CHECKPTR(DosDateTimeToVariantTime
);
1790 DOS2DT(1,1,1980,0,0,0,1,29221.0); /* 1/1/1980 */
1791 DOS2DT(31,12,2099,0,0,0,1,73050.0); /* 31/12/2099 */
1792 /* Dates are limited to the dos date max of 31/12/2099 */
1793 DOS2DT(31,12,2100,0,0,0,0,0.0); /* 31/12/2100 */
1794 /* Days and months of 0 cause date to roll back 1 day or month */
1795 DOS2DT(0,1,1980,0,0,0,1,29220.0); /* 0 Day => 31/12/1979 */
1796 DOS2DT(1,0,1980,0,0,0,1,29190.0); /* 0 Mth => 1/12/1979 */
1797 DOS2DT(0,0,1980,0,0,0,1,29189.0); /* 0 D/M => 30/11/1979 */
1798 /* Days > days in the month cause date to roll forward 1 month */
1799 DOS2DT(29,2,1981,0,0,0,1,29646.0); /* 29/2/1981 -> 3/1/1980 */
1800 DOS2DT(30,2,1981,0,0,0,1,29647.0); /* 30/2/1981 -> 4/1/1980 */
1801 /* Takes leap years into account when rolling forward */
1802 DOS2DT(29,2,1980,0,0,0,1,29280.0); /* 2/29/1980 */
1803 /* Months > 12 cause an error */
1804 DOS2DT(2,13,1980,0,0,0,0,0.0);
1807 DOS2DT(1,1,1980,0,0,29,1,29221.00032407407); /* 1/1/1980 12:00:28 AM */
1808 DOS2DT(1,1,1980,0,0,31,1,29221.00034722222); /* 1/1/1980 12:00:30 AM */
1809 DOS2DT(1,1,1980,0,59,0,1,29221.04097222222); /* 1/1/1980 12:59:00 AM */
1810 DOS2DT(1,1,1980,0,60,0,0,0.0); /* Invalid minutes */
1811 DOS2DT(1,1,1980,0,0,60,0,0.0); /* Invalid seconds */
1812 DOS2DT(1,1,1980,23,0,0,1,29221.95833333333); /* 1/1/1980 11:00:00 PM */
1813 DOS2DT(1,1,1980,24,0,0,0,0.0); /* Invalid hours */
1815 DOS2DT(1,1,1980,0,0,1,1,29221.0);
1816 DOS2DT(2,1,1980,0,0,0,1,29222.0);
1817 DOS2DT(2,1,1980,0,0,0,1,29222.0);
1818 DOS2DT(31,12,1990,0,0,0,1,33238.0);
1819 DOS2DT(31,12,90,0,0,0,1,40543.0);
1820 DOS2DT(30,12,1899,0,0,0,1,46751.0);
1821 DOS2DT(1,1,100,0,0,0,1,43831.0);
1822 DOS2DT(31,12,9999,0,0,0,1,59901.0);
1823 DOS2DT(1,1,10000,0,0,0,1,59902.0);
1824 DOS2DT(1,1,-10000,0,0,0,1,48214.0);
1826 DOS2DT(30,12,1899,0,0,0,1,46751.0);
1827 DOS2DT(30,12,1899,0,0,1,1,46751.0);
1829 DOS2DT(1,1,1980,18,1,16,1,29221.75087962963);
1830 DOS2DT(1,300,1980,18,1,16,1,29556.75087962963);
1831 DOS2DT(300,1,1980,18,1,16,1,29232.75087962963);
1832 DOS2DT(0,1,1980,42,1,16,1,29220.4175462963);
1833 DOS2DT(1,1,1980,17,61,16,0,0.0);
1834 DOS2DT(1,1,1980,18,0,76,1,29221.75013888889);
1835 DOS2DT(1,-300,1980,18,1,16,1,29312.75087962963);
1836 DOS2DT(-300,1,1980,18,1,16,1,29240.75087962963);
1837 DOS2DT(3,1,1980,-30,1,16,1,29223.08421296296);
1838 DOS2DT(1,1,1980,20,-119,16,1,29221.83976851852);
1839 DOS2DT(1,1,1980,18,3,-104,1,29221.75236111111);
1840 DOS2DT(1,12001,-1020,18,1,16,1,55519.75087962963);
1841 DOS2DT(1,-23,1982,18,1,16,1,30195.75087962963);
1842 DOS2DT(-59,3,1980,18,1,16,1,29285.75087962963);
1843 DOS2DT(1,1,0,0,0,0,1,54058.0);
1844 DOS2DT(0,0,1980,0,0,0,1,29189.0);
1845 DOS2DT(0,1,1980,0,0,0,1,29220.0);
1846 DOS2DT(-1,1,1980,18,1,16,1,29251.75087962963);
1847 DOS2DT(1,1,-1,18,1,16,1,53693.75087962963);
1848 DOS2DT(1,-1,1980,18,1,16,0,0);
1851 static void test_dt2dos(int line
, double dt
, INT r
, WORD d
, WORD m
, WORD y
,
1852 WORD h
, WORD mn
, WORD s
)
1854 unsigned short dosDate
, dosTime
, expDosDate
, expDosTime
;
1857 dosTime
= dosDate
= 0;
1858 expDosDate
= MKDOSDATE(d
,m
,y
);
1859 expDosTime
= MKDOSTIME(h
,mn
,s
);
1860 res
= pVariantTimeToDosDateTime(dt
, &dosDate
, &dosTime
);
1861 ok_(__FILE__
,line
)(r
== res
&& (!r
|| (dosTime
== expDosTime
&& dosDate
== expDosDate
)),
1862 "%g: expected %d,%d(%d/%d/%d),%d(%d:%d:%d) got %d,%d(%d/%d/%d),%d(%d:%d:%d)\n",
1863 dt
, r
, expDosDate
, expDosDate
& 0x1f,
1864 (expDosDate
>> 5) & 0xf, 1980 + (expDosDate
>> 9),
1865 expDosTime
, expDosTime
>> 11, (expDosTime
>> 5) & 0x3f,
1866 (expDosTime
& 0x1f),
1867 res
, dosDate
, dosDate
& 0x1f, (dosDate
>> 5) & 0xf,
1868 1980 + (dosDate
>> 9), dosTime
, dosTime
>> 11,
1869 (dosTime
>> 5) & 0x3f, (dosTime
& 0x1f));
1871 #define DT2DOS(dt,r,d,m,y,h,mn,s) test_dt2dos(__LINE__,dt,r,d,m,y,h,mn,s)
1873 static void test_VariantTimeToDosDateTime(void)
1875 CHECKPTR(VariantTimeToDosDateTime
);
1878 DT2DOS(29221.0,1,1,1,1980,0,0,0); /* 1/1/1980 */
1879 DT2DOS(73050.0,1,31,12,2099,0,0,0); /* 31/12/2099 */
1880 DT2DOS(29220.0,0,0,0,0,0,0,0); /* 31/12/1979 - out of range */
1881 DT2DOS(73415.0,0,0,0,0,0,0,0); /* 31/12/2100 - out of range */
1884 DT2DOS(29221.00032407407,1,1,1,1980,0,0,29); /* 1/1/1980 12:00:28 AM */
1885 DT2DOS(29221.00034722222,1,1,1,1980,0,0,31); /* 1/1/1980 12:00:30 AM */
1886 DT2DOS(29221.04097222222,1,1,1,1980,0,59,0); /* 1/1/1980 12:59:00 AM */
1887 DT2DOS(29221.95833333333,1,1,1,1980,23,0,0); /* 1/1/1980 11:00:00 PM */
1890 static HRESULT (WINAPI
*pVarAbs
)(LPVARIANT
,LPVARIANT
);
1892 #define VARABS(vt,val,rvt,rval) \
1893 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
1894 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
1895 test_var_call1( __LINE__, pVarAbs, &v, &exp )
1897 static void test_VarAbs(void)
1899 static WCHAR szNum
[] = {'-','1','.','1','\0' };
1902 VARIANT v
, vDst
, exp
;
1907 /* Test all possible V_VT values.
1909 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
1913 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
1915 HRESULT hExpected
= DISP_E_BADVARTYPE
;
1919 memset(&v
, 0, sizeof(v
));
1920 V_VT(&v
) = vt
| ExtraFlags
[i
];
1921 V_VT(&vDst
) = VT_EMPTY
;
1923 hres
= pVarAbs(&v
,&vDst
);
1924 if (ExtraFlags
[i
] & (VT_ARRAY
|VT_ARRAY
) ||
1925 (!ExtraFlags
[i
] && (vt
== VT_UNKNOWN
|| vt
== VT_BSTR
||
1926 vt
== VT_DISPATCH
|| vt
== VT_ERROR
|| vt
== VT_RECORD
)))
1928 hExpected
= DISP_E_TYPEMISMATCH
;
1930 else if (ExtraFlags
[i
] || vt
>= VT_CLSID
|| vt
== VT_VARIANT
)
1932 hExpected
= DISP_E_BADVARTYPE
;
1934 else if (IsValidVariantClearVT(vt
, ExtraFlags
[i
]))
1937 /* Native always fails on some vartypes that should be valid. don't
1938 * check that Wine does the same; these are bugs in native.
1940 if (vt
== VT_I8
|| vt
== VT_UI8
|| vt
== VT_INT
|| vt
== VT_UINT
||
1941 vt
== VT_I1
|| vt
== VT_UI2
|| vt
== VT_UI4
)
1943 ok(hres
== hExpected
, "VarAbs: expected 0x%X, got 0x%X for vt %d | 0x%X\n",
1944 hExpected
, hres
, vt
, ExtraFlags
[i
]);
1948 /* BOOL->I2, BSTR->R8, all others remain the same */
1949 VARABS(BOOL
,VARIANT_TRUE
,I2
,-VARIANT_TRUE
);
1950 VARABS(BOOL
,VARIANT_FALSE
,I2
,VARIANT_FALSE
);
1951 VARABS(EMPTY
,0,I2
,0);
1952 VARABS(EMPTY
,1,I2
,0);
1953 VARABS(NULL
,0,NULL
,0);
1954 VARABS(NULL
,1,NULL
,0);
1959 VARABS(UI1
,1,UI1
,1);
1964 VARABS(DATE
,1,DATE
,1);
1965 VARABS(DATE
,-1,DATE
,1);
1967 V_CY(&v
).int64
= -10000;
1968 memset(&vDst
,0,sizeof(vDst
));
1969 hres
= pVarAbs(&v
,&vDst
);
1970 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_CY
&& V_CY(&vDst
).int64
== 10000,
1971 "VarAbs(CY): expected 0x0 got 0x%X\n", hres
);
1972 GetLocaleInfoA(LOCALE_USER_DEFAULT
, LOCALE_SDECIMAL
, buff
, sizeof(buff
)/sizeof(char));
1975 trace("Skipping VarAbs(BSTR) as decimal separator is '%s'\n", buff
);
1981 V_BSTR(&v
) = (BSTR
)szNum
;
1982 memset(&vDst
,0,sizeof(vDst
));
1983 hres
= pVarAbs(&v
,&vDst
);
1984 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_R8
&& V_R8(&vDst
) == 1.1,
1985 "VarAbs: expected 0x0,%d,%g, got 0x%X,%d,%g\n", VT_R8
, 1.1, hres
, V_VT(&vDst
), V_R8(&vDst
));
1988 static HRESULT (WINAPI
*pVarNot
)(LPVARIANT
,LPVARIANT
);
1990 #define VARNOT(vt,val,rvt,rval) \
1991 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
1992 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
1993 test_var_call1( __LINE__, pVarNot, &v, &exp )
1995 static void test_VarNot(void)
1997 static const WCHAR szNum0
[] = {'0','\0' };
1998 static const WCHAR szNum1
[] = {'1','\0' };
1999 static const WCHAR szFalse
[] = { '#','F','A','L','S','E','#','\0' };
2000 static const WCHAR szTrue
[] = { '#','T','R','U','E','#','\0' };
2002 VARIANT v
, exp
, vDst
;
2003 DECIMAL
*pdec
= &V_DECIMAL(&v
);
2004 CY
*pcy
= &V_CY(&v
);
2009 /* Test all possible V_VT values */
2010 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
2014 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
2016 HRESULT hExpected
= DISP_E_BADVARTYPE
;
2020 memset(&v
, 0, sizeof(v
));
2021 V_VT(&v
) = vt
| ExtraFlags
[i
];
2022 V_VT(&vDst
) = VT_EMPTY
;
2026 case VT_I1
: case VT_UI1
: case VT_I2
: case VT_UI2
:
2027 case VT_INT
: case VT_UINT
: case VT_I4
: case VT_UI4
:
2028 case VT_R4
: case VT_R8
:
2029 case VT_DECIMAL
: case VT_BOOL
: case VT_NULL
: case VT_EMPTY
:
2030 case VT_DATE
: case VT_CY
:
2033 case VT_I8
: case VT_UI8
:
2038 hExpected
= DISP_E_TYPEMISMATCH
;
2040 case VT_UNKNOWN
: case VT_BSTR
: case VT_DISPATCH
: case VT_ERROR
:
2041 hExpected
= DISP_E_TYPEMISMATCH
;
2044 if (IsValidVariantClearVT(vt
, ExtraFlags
[i
]) && vt
!= VT_CLSID
)
2045 hExpected
= DISP_E_TYPEMISMATCH
;
2049 hres
= pVarNot(&v
,&vDst
);
2050 ok(hres
== hExpected
, "VarNot: expected 0x%X, got 0x%X vt %d|0x%X\n",
2051 hExpected
, hres
, vt
, ExtraFlags
[i
]);
2054 /* Test the values returned by all cases that can succeed */
2055 VARNOT(EMPTY
,0,I2
,-1);
2056 VARNOT(EMPTY
,1,I2
,-1);
2057 VARNOT(NULL
,0,NULL
,0);
2058 VARNOT(NULL
,1,NULL
,0);
2059 VARNOT(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
);
2060 VARNOT(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
);
2068 VARNOT(UI1
,1,UI1
,254);
2069 VARNOT(UI1
,0,UI1
,255);
2070 VARNOT(UI2
,0,I4
,-1);
2071 VARNOT(UI2
,1,I4
,-2);
2072 VARNOT(UI4
,0,I4
,-1);
2073 VARNOT(UI4
,1,I4
,-2);
2074 VARNOT(INT
,0,I4
,-1);
2075 VARNOT(INT
,1,I4
,-2);
2076 VARNOT(UINT
,0,I4
,-1);
2077 VARNOT(UINT
,1,I4
,-2);
2082 VARNOT(UI8
,0,I4
,-1);
2083 VARNOT(UI8
,1,I4
,-2);
2089 VARNOT(DATE
,1,I4
,-2);
2090 VARNOT(DATE
,0,I4
,-1);
2091 VARNOT(BSTR
,(BSTR
)szNum0
,I4
,-1);
2092 ok(V_VT(&v
) == VT_BSTR
&& V_BSTR(&v
) == szNum0
, "VarNot(0): changed input\n");
2093 VARNOT(BSTR
,(BSTR
)szNum1
,I4
,-2);
2094 ok(V_VT(&v
) == VT_BSTR
&& V_BSTR(&v
) == szNum1
, "VarNot(1): changed input\n");
2095 VARNOT(BSTR
, (BSTR
)szTrue
, BOOL
, VARIANT_FALSE
);
2096 VARNOT(BSTR
, (BSTR
)szFalse
, BOOL
, VARIANT_TRUE
);
2098 V_VT(&v
) = VT_DECIMAL
;
2099 S(U(*pdec
)).sign
= DECIMAL_NEG
;
2100 S(U(*pdec
)).scale
= 0;
2102 S1(U1(*pdec
)).Mid32
= 0;
2103 S1(U1(*pdec
)).Lo32
= 1;
2104 VARNOT(DECIMAL
,*pdec
,I4
,0);
2107 VARNOT(CY
,*pcy
,I4
,-2);
2110 VARNOT(CY
,*pcy
,I4
,-1);
2113 VARNOT(CY
,*pcy
,I4
,-1);
2116 static HRESULT (WINAPI
*pVarSub
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
2118 #define VARSUB(vt1,val1,vt2,val2,rvt,rval) \
2119 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
2120 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
2121 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
2122 test_var_call2( __LINE__, pVarSub, &left, &right, &exp )
2124 static void test_VarSub(void)
2126 VARIANT left
, right
, exp
, result
, cy
, dec
;
2129 HRESULT hres
, expectedhres
;
2134 lbstr
= SysAllocString(sz12
);
2135 rbstr
= SysAllocString(sz12
);
2138 VariantInit(&right
);
2139 VariantInit(&result
);
2141 /* Test all possible flag/vt combinations & the resulting vt type */
2142 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
2145 VARTYPE leftvt
, rightvt
, resvt
;
2147 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
2152 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
2156 expectedhres
= S_OK
;
2158 memset(&left
, 0, sizeof(left
));
2159 memset(&right
, 0, sizeof(right
));
2160 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
2161 if (leftvt
== VT_BSTR
)
2162 V_BSTR(&left
) = lbstr
;
2163 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
2164 if (rightvt
== VT_BSTR
)
2165 V_BSTR(&right
) = rbstr
;
2166 V_VT(&result
) = VT_EMPTY
;
2168 /* All extra flags produce errors */
2169 if (ExtraFlags
[i
] == (VT_VECTOR
|VT_BYREF
|VT_RESERVED
) ||
2170 ExtraFlags
[i
] == (VT_VECTOR
|VT_RESERVED
) ||
2171 ExtraFlags
[i
] == (VT_VECTOR
|VT_BYREF
) ||
2172 ExtraFlags
[i
] == (VT_BYREF
|VT_RESERVED
) ||
2173 ExtraFlags
[i
] == VT_VECTOR
||
2174 ExtraFlags
[i
] == VT_BYREF
||
2175 ExtraFlags
[i
] == VT_RESERVED
)
2177 expectedhres
= DISP_E_BADVARTYPE
;
2180 else if (ExtraFlags
[i
] >= VT_ARRAY
)
2182 expectedhres
= DISP_E_TYPEMISMATCH
;
2185 /* Native VarSub cannot handle: VT_I1, VT_UI2, VT_UI4,
2186 VT_INT, VT_UINT and VT_UI8. Tested with WinXP */
2187 else if (!IsValidVariantClearVT(leftvt
, ExtraFlags
[i
]) ||
2188 !IsValidVariantClearVT(rightvt
, ExtraFlags
[i
]) ||
2189 leftvt
== VT_CLSID
|| rightvt
== VT_CLSID
||
2190 leftvt
== VT_VARIANT
|| rightvt
== VT_VARIANT
||
2191 leftvt
== VT_I1
|| rightvt
== VT_I1
||
2192 leftvt
== VT_UI2
|| rightvt
== VT_UI2
||
2193 leftvt
== VT_UI4
|| rightvt
== VT_UI4
||
2194 leftvt
== VT_UI8
|| rightvt
== VT_UI8
||
2195 leftvt
== VT_INT
|| rightvt
== VT_INT
||
2196 leftvt
== VT_UINT
|| rightvt
== VT_UINT
||
2197 leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
||
2198 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
)
2200 if (leftvt
== VT_RECORD
&& rightvt
== VT_I8
)
2203 expectedhres
= DISP_E_TYPEMISMATCH
;
2205 expectedhres
= DISP_E_BADVARTYPE
;
2207 else if (leftvt
< VT_UI1
&& rightvt
== VT_RECORD
)
2208 expectedhres
= DISP_E_TYPEMISMATCH
;
2209 else if (leftvt
>= VT_UI1
&& rightvt
== VT_RECORD
)
2210 expectedhres
= DISP_E_TYPEMISMATCH
;
2211 else if (leftvt
== VT_RECORD
&& rightvt
<= VT_UI1
)
2212 expectedhres
= DISP_E_TYPEMISMATCH
;
2213 else if (leftvt
== VT_RECORD
&& rightvt
> VT_UI1
)
2214 expectedhres
= DISP_E_BADVARTYPE
;
2216 expectedhres
= DISP_E_BADVARTYPE
;
2219 else if ((leftvt
== VT_NULL
&& rightvt
== VT_DISPATCH
) ||
2220 (leftvt
== VT_DISPATCH
&& rightvt
== VT_NULL
))
2222 else if (leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
||
2223 leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
)
2226 expectedhres
= DISP_E_TYPEMISMATCH
;
2228 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
2230 else if ((leftvt
== VT_EMPTY
&& rightvt
== VT_BSTR
) ||
2231 (leftvt
== VT_DATE
&& rightvt
== VT_DATE
) ||
2232 (leftvt
== VT_BSTR
&& rightvt
== VT_EMPTY
) ||
2233 (leftvt
== VT_BSTR
&& rightvt
== VT_BSTR
))
2235 else if (leftvt
== VT_DECIMAL
|| rightvt
== VT_DECIMAL
)
2237 else if (leftvt
== VT_DATE
|| rightvt
== VT_DATE
)
2239 else if (leftvt
== VT_CY
|| rightvt
== VT_CY
)
2241 else if (leftvt
== VT_R8
|| rightvt
== VT_R8
)
2243 else if (leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
) {
2245 } else if (leftvt
== VT_R4
|| rightvt
== VT_R4
) {
2246 if (leftvt
== VT_I4
|| rightvt
== VT_I4
||
2247 leftvt
== VT_I8
|| rightvt
== VT_I8
)
2252 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
2254 else if (leftvt
== VT_I4
|| rightvt
== VT_I4
)
2256 else if (leftvt
== VT_I2
|| rightvt
== VT_I2
||
2257 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
||
2258 (leftvt
== VT_EMPTY
&& rightvt
== VT_EMPTY
))
2260 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
2265 expectedhres
= DISP_E_TYPEMISMATCH
;
2268 hres
= pVarSub(&left
, &right
, &result
);
2270 ok(hres
== expectedhres
&& V_VT(&result
) == resvt
,
2271 "VarSub: %d|0x%X, %d|0x%X: Expected failure 0x%X, "
2272 "got 0x%X, expected vt %d got vt %d\n",
2273 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
],
2274 expectedhres
, hres
, resvt
, V_VT(&result
));
2279 /* Test returned values */
2280 VARSUB(I4
,4,I4
,2,I4
,2);
2281 VARSUB(I2
,4,I2
,2,I2
,2);
2282 VARSUB(I2
,-13,I4
,5,I4
,-18);
2283 VARSUB(I4
,-13,I4
,5,I4
,-18);
2284 VARSUB(I2
,7,R4
,0.5f
,R4
,6.5f
);
2285 VARSUB(R4
,0.5f
,I4
,5,R8
,-4.5);
2286 VARSUB(R8
,7.1,BOOL
,0,R8
,7.1);
2287 VARSUB(BSTR
,lbstr
,I2
,4,R8
,8);
2288 VARSUB(BSTR
,lbstr
,BOOL
,1,R8
,11);
2289 VARSUB(BSTR
,lbstr
,R4
,0.1f
,R8
,11.9);
2290 VARSUB(R4
,0.2f
,BSTR
,rbstr
,R8
,-11.8);
2291 VARSUB(DATE
,2.25,I4
,7,DATE
,-4.75);
2292 VARSUB(DATE
,1.25,R4
,-1.7f
,DATE
,2.95);
2294 VARSUB(UI1
, UI1_MAX
, UI1
, UI1_MAX
, UI1
, 0);
2295 VARSUB(I2
, I2_MAX
, I2
, I2_MAX
, I2
, 0);
2296 VARSUB(I2
, I2_MIN
, I2
, I2_MIN
, I2
, 0);
2297 VARSUB(I4
, I4_MAX
, I4
, I4_MAX
, I4
, 0);
2298 VARSUB(I4
, I4_MIN
, I4
, I4_MIN
, I4
, 0);
2299 VARSUB(R4
, R4_MAX
, R4
, R4_MAX
, R4
, 0.0f
);
2300 VARSUB(R4
, R4_MAX
, R4
, R4_MIN
, R4
, R4_MAX
- R4_MIN
);
2301 VARSUB(R4
, R4_MIN
, R4
, R4_MIN
, R4
, 0.0f
);
2302 VARSUB(R8
, R8_MAX
, R8
, R8_MIN
, R8
, R8_MAX
- R8_MIN
);
2303 VARSUB(R8
, R8_MIN
, R8
, R8_MIN
, R8
, 0.0);
2305 /* Manually test BSTR + BSTR */
2306 V_VT(&left
) = VT_BSTR
;
2307 V_BSTR(&left
) = lbstr
;
2308 V_VT(&right
) = VT_BSTR
;
2309 V_BSTR(&right
) = rbstr
;
2310 hres
= pVarSub(&left
, &right
, &result
);
2311 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
2312 "VarSub: expected coerced type VT_R8, got %s!\n", vtstr(V_VT(&result
)));
2313 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 0),
2314 "VarSub: BSTR + BSTR, expected %f got %f\n", 0.0, V_R8(&result
));
2316 /* Manually test some VT_CY and VT_DECIMAL variants */
2318 hres
= VarCyFromI4(4711, &V_CY(&cy
));
2319 ok(hres
== S_OK
, "VarCyFromI4 failed!\n");
2320 V_VT(&dec
) = VT_DECIMAL
;
2321 hres
= VarDecFromR8(-4.2, &V_DECIMAL(&dec
));
2322 ok(hres
== S_OK
, "VarDecFromR4 failed!\n");
2323 memset(&left
, 0, sizeof(left
));
2324 memset(&right
, 0, sizeof(right
));
2325 V_VT(&left
) = VT_I4
;
2327 V_VT(&right
) = VT_UI1
;
2330 hres
= pVarSub(&cy
, &right
, &result
);
2331 ok(hres
== S_OK
&& V_VT(&result
) == VT_CY
,
2332 "VarSub: expected coerced type VT_CY, got %s!\n", vtstr(V_VT(&result
)));
2333 hres
= VarR8FromCy(V_CY(&result
), &r
);
2334 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 4702),
2335 "VarSub: CY value %f, expected %f\n", r
, (double)4720);
2337 hres
= pVarSub(&left
, &dec
, &result
);
2338 ok(hres
== S_OK
&& V_VT(&result
) == VT_DECIMAL
,
2339 "VarSub: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result
)));
2340 hres
= VarR8FromDec(&V_DECIMAL(&result
), &r
);
2341 ok(hres
== S_OK
&& EQ_DOUBLE(r
, -6.8),
2342 "VarSub: DECIMAL value %f, expected %f\n", r
, (double)-15.2);
2344 SysFreeString(lbstr
);
2345 SysFreeString(rbstr
);
2348 static HRESULT (WINAPI
*pVarMod
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
2350 static void test_Mod( int line
, VARIANT
*left
, VARIANT
*right
, VARIANT
*expected
, HRESULT expres
)
2355 memset( &result
, 0, sizeof(result
) );
2356 hres
= pVarMod( left
, right
, &result
);
2357 ok_(__FILE__
,line
)( hres
== expres
, "wrong result %x/%x\n", hres
, expres
);
2359 ok_(__FILE__
,line
)( is_expected_variant( &result
, expected
),
2360 "got %s expected %s\n", variantstr(&result
), variantstr(expected
) );
2363 #define VARMOD(vt1,vt2,val1,val2,rvt,rval) \
2364 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
2365 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
2366 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
2367 test_var_call2( __LINE__, pVarMod, &left, &right, &exp )
2369 #define VARMOD2(vt1,vt2,val1,val2,rvt,rval,hexpected) \
2370 V_VT(&left) = VT_##vt1; V_I4(&left) = val1; \
2371 V_VT(&right) = VT_##vt2; V_I4(&right) = val2; \
2372 V_VT(&exp) = VT_##rvt; V_I4(&exp) = rval; \
2373 test_Mod( __LINE__, &left, &right, &exp, hexpected )
2375 static void test_VarMod(void)
2377 VARIANT v1
, v2
, vDst
, left
, right
, exp
;
2379 HRESULT hexpected
= 0;
2380 static const WCHAR szNum0
[] = {'1','2','5','\0'};
2381 static const WCHAR szNum1
[] = {'1','0','\0'};
2383 BOOL lFound
, rFound
;
2385 BSTR strNum0
, strNum1
;
2389 VARMOD(I1
,BOOL
,100,10,I4
,0);
2390 VARMOD(I1
,I1
,100,10,I4
,0);
2391 VARMOD(I1
,UI1
,100,10,I4
,0);
2392 VARMOD(I1
,I2
,100,10,I4
,0);
2393 VARMOD(I1
,UI2
,100,10,I4
,0);
2394 VARMOD(I1
,I4
,100,10,I4
,0);
2395 VARMOD(I1
,UI4
,100,10,I4
,0);
2396 VARMOD(I1
,R4
,100,10,I4
,0);
2397 VARMOD(I1
,R8
,100,10,I4
,0);
2399 VARMOD(UI1
,BOOL
,100,10,I2
,0);
2400 VARMOD(UI1
,I1
,100,10,I4
,0);
2401 VARMOD(UI1
,UI1
,100,10,UI1
,0);
2402 VARMOD(UI1
,I2
,100,10,I2
,0);
2403 VARMOD(UI1
,UI2
,100,10,I4
,0);
2404 VARMOD(UI1
,I4
,100,10,I4
,0);
2405 VARMOD(UI1
,UI4
,100,10,I4
,0);
2406 VARMOD(UI1
,R4
,100,10,I4
,0);
2407 VARMOD(UI1
,R8
,100,10,I4
,0);
2409 VARMOD(I2
,BOOL
,100,10,I2
,0);
2410 VARMOD(I2
,I1
,100,10,I4
,0);
2411 VARMOD(I2
,UI1
,100,10,I2
,0);
2412 VARMOD(I2
,I2
,100,10,I2
,0);
2413 VARMOD(I2
,UI2
,100,10,I4
,0);
2414 VARMOD(I2
,I4
,100,10,I4
,0);
2415 VARMOD(I2
,UI4
,100,10,I4
,0);
2416 VARMOD(I2
,R4
,100,10,I4
,0);
2417 VARMOD(I2
,R8
,100,10,I4
,0);
2419 VARMOD(I4
,BOOL
,100,10,I4
,0);
2420 VARMOD(I4
,I1
,100,10,I4
,0);
2421 VARMOD(I4
,UI1
,100,10,I4
,0);
2422 VARMOD(I4
,I2
,100,10,I4
,0);
2423 VARMOD(I4
,UI2
,100,10,I4
,0);
2424 VARMOD(I4
,I4
,100,10,I4
,0);
2425 VARMOD(I4
,UI4
,100,10,I4
,0);
2426 VARMOD(I4
,R4
,100,10,I4
,0);
2427 VARMOD(I4
,R8
,100,10,I4
,0);
2428 VARMOD(UI4
,BOOL
,100,10,I4
,0);
2429 VARMOD(UI4
,I1
,100,10,I4
,0);
2430 VARMOD(UI4
,UI1
,100,10,I4
,0);
2431 VARMOD(UI4
,I2
,100,10,I4
,0);
2432 VARMOD(UI4
,UI2
,100,10,I4
,0);
2433 VARMOD(UI4
,I4
,100,10,I4
,0);
2434 VARMOD(UI4
,UI4
,100,10,I4
,0);
2435 VARMOD(UI4
,R4
,100,10,I4
,0);
2436 VARMOD(UI4
,R8
,100,10,I4
,0);
2437 VARMOD(R4
,BOOL
,100,10,I4
,0);
2438 VARMOD(R4
,I1
,100,10,I4
,0);
2439 VARMOD(R4
,UI1
,100,10,I4
,0);
2440 VARMOD(R4
,I2
,100,10,I4
,0);
2441 VARMOD(R4
,UI2
,100,10,I4
,0);
2442 VARMOD(R4
,I4
,100,10,I4
,0);
2443 VARMOD(R4
,UI4
,100,10,I4
,0);
2444 VARMOD(R4
,R4
,100,10,I4
,0);
2445 VARMOD(R4
,R8
,100,10,I4
,0);
2446 VARMOD(R8
,BOOL
,100,10,I4
,0);
2447 VARMOD(R8
,I1
,100,10,I4
,0);
2448 VARMOD(R8
,UI1
,100,10,I4
,0);
2449 VARMOD(R8
,I2
,100,10,I4
,0);
2450 VARMOD(R8
,UI2
,100,10,I4
,0);
2451 VARMOD(R8
,I4
,100,10,I4
,0);
2452 VARMOD(R8
,UI4
,100,10,I4
,0);
2453 VARMOD(R8
,R4
,100,10,I4
,0);
2454 VARMOD(R8
,R8
,100,10,I4
,0);
2456 VARMOD(INT
,INT
,100,10,I4
,0);
2457 VARMOD(INT
,UINT
,100,10,I4
,0);
2459 VARMOD(BOOL
,BOOL
,100,10,I2
,0);
2460 VARMOD(BOOL
,I1
,100,10,I4
,0);
2461 VARMOD(BOOL
,UI1
,100,10,I2
,0);
2462 VARMOD(BOOL
,I2
,100,10,I2
,0);
2463 VARMOD(BOOL
,UI2
,100,10,I4
,0);
2464 VARMOD(BOOL
,I4
,100,10,I4
,0);
2465 VARMOD(BOOL
,UI4
,100,10,I4
,0);
2466 VARMOD(BOOL
,R4
,100,10,I4
,0);
2467 VARMOD(BOOL
,R8
,100,10,I4
,0);
2468 VARMOD(BOOL
,DATE
,100,10,I4
,0);
2470 VARMOD(DATE
,BOOL
,100,10,I4
,0);
2471 VARMOD(DATE
,I1
,100,10,I4
,0);
2472 VARMOD(DATE
,UI1
,100,10,I4
,0);
2473 VARMOD(DATE
,I2
,100,10,I4
,0);
2474 VARMOD(DATE
,UI2
,100,10,I4
,0);
2475 VARMOD(DATE
,I4
,100,10,I4
,0);
2476 VARMOD(DATE
,UI4
,100,10,I4
,0);
2477 VARMOD(DATE
,R4
,100,10,I4
,0);
2478 VARMOD(DATE
,R8
,100,10,I4
,0);
2479 VARMOD(DATE
,DATE
,100,10,I4
,0);
2481 strNum0
= SysAllocString(szNum0
);
2482 strNum1
= SysAllocString(szNum1
);
2483 VARMOD(BSTR
,BSTR
,strNum0
,strNum1
,I4
,5);
2484 VARMOD(BSTR
,I1
,strNum0
,10,I4
,5);
2485 VARMOD(BSTR
,I2
,strNum0
,10,I4
,5);
2486 VARMOD(BSTR
,I4
,strNum0
,10,I4
,5);
2487 VARMOD(BSTR
,R4
,strNum0
,10,I4
,5);
2488 VARMOD(BSTR
,R8
,strNum0
,10,I4
,5);
2489 VARMOD(I4
,BSTR
,125,strNum1
,I4
,5);
2493 VARMOD(BOOL
,I8
,100,10,I8
,0);
2494 VARMOD(I1
,I8
,100,10,I8
,0);
2495 VARMOD(UI1
,I8
,100,10,I8
,0);
2496 VARMOD(I2
,I8
,100,10,I8
,0);
2497 VARMOD(I4
,I8
,100,10,I8
,0);
2498 VARMOD(UI4
,I8
,100,10,I8
,0);
2499 VARMOD(R4
,I8
,100,10,I8
,0);
2500 VARMOD(R8
,I8
,100,10,I8
,0);
2501 VARMOD(DATE
,I8
,100,10,I8
,0);
2503 VARMOD(I8
,BOOL
,100,10,I8
,0);
2504 VARMOD(I8
,I1
,100,10,I8
,0);
2505 VARMOD(I8
,UI1
,100,10,I8
,0);
2506 VARMOD(I8
,I2
,100,10,I8
,0);
2507 VARMOD(I8
,UI2
,100,10,I8
,0);
2508 VARMOD(I8
,I4
,100,10,I8
,0);
2509 VARMOD(I8
,UI4
,100,10,I8
,0);
2510 VARMOD(I8
,R4
,100,10,I8
,0);
2511 VARMOD(I8
,R8
,100,10,I8
,0);
2512 VARMOD(I8
,I8
,100,10,I8
,0);
2514 VARMOD(BSTR
,I8
,strNum0
,10,I8
,5);
2517 /* test all combinations of types */
2518 for(l
= 0; l
< VT_BSTR_BLOB
; l
++)
2522 for(r
= 0; r
< VT_BSTR_BLOB
; r
++)
2526 if(l
== VT_BSTR
) continue;
2527 if(l
== VT_DISPATCH
) continue;
2528 if(r
== VT_BSTR
) continue;
2529 if(r
== VT_DISPATCH
) continue;
2563 hexpected
= DISP_E_BADVARTYPE
;
2600 if(((l
== VT_I8
) && (r
== VT_INT
)) || ((l
== VT_INT
) && (r
== VT_I8
)))
2602 hexpected
= DISP_E_TYPEMISMATCH
;
2603 } else if((l
== VT_EMPTY
) && (r
== VT_NULL
))
2606 } else if((l
== VT_NULL
) && (r
== VT_EMPTY
))
2609 } else if((l
== VT_EMPTY
) && (r
== VT_CY
))
2612 } else if((l
== VT_EMPTY
) && (r
== VT_RECORD
))
2614 hexpected
= DISP_E_TYPEMISMATCH
;
2615 } else if((r
== VT_EMPTY
) && lFound
&& lValid
)
2617 hexpected
= DISP_E_DIVBYZERO
;
2618 } else if((l
== VT_ERROR
) || ((r
== VT_ERROR
) && lFound
&& lValid
))
2620 hexpected
= DISP_E_TYPEMISMATCH
;
2621 } else if((l
== VT_NULL
) && (r
== VT_NULL
))
2624 } else if((l
== VT_VARIANT
) || ((r
== VT_VARIANT
) && lFound
&& lValid
))
2626 hexpected
= DISP_E_TYPEMISMATCH
;
2627 } else if((l
== VT_NULL
) && (r
== VT_RECORD
))
2629 hexpected
= DISP_E_TYPEMISMATCH
;
2630 } else if((l
== VT_I8
) && (r
== VT_DECIMAL
))
2633 } else if((l
== VT_DECIMAL
) && (r
== VT_I8
))
2636 } else if((l
== VT_UNKNOWN
) || ((r
== VT_UNKNOWN
) && lFound
&& lValid
))
2638 hexpected
= DISP_E_TYPEMISMATCH
;
2639 } else if((l
== VT_NULL
) && rFound
)
2642 } else if(l
== VT_RECORD
)
2644 hexpected
= DISP_E_TYPEMISMATCH
;
2645 } else if((r
== VT_RECORD
) && lValid
&& lFound
)
2647 hexpected
= DISP_E_TYPEMISMATCH
;
2648 } else if((l
== VT_EMPTY
) && (r
== VT_EMPTY
))
2650 hexpected
= DISP_E_DIVBYZERO
;
2651 } else if((l
== VT_CY
) && !rFound
)
2653 hexpected
= DISP_E_BADVARTYPE
;
2654 } else if(lFound
&& !rFound
)
2656 hexpected
= DISP_E_BADVARTYPE
;
2657 } else if(!lFound
&& rFound
)
2659 hexpected
= DISP_E_BADVARTYPE
;
2660 } else if((r
== VT_NULL
) && lFound
&& lValid
)
2663 } else if((l
== VT_NULL
) || (r
== VT_NULL
))
2665 hexpected
= DISP_E_BADVARTYPE
;
2666 } else if((l
== VT_VARIANT
) || (r
== VT_VARIANT
))
2668 hexpected
= DISP_E_BADVARTYPE
;
2669 } else if(lFound
&& !rFound
)
2671 hexpected
= DISP_E_BADVARTYPE
;
2672 } else if(!lFound
&& !rFound
)
2674 hexpected
= DISP_E_BADVARTYPE
;
2681 V_CY(&v1
).int64
= 1000000;
2686 else if(l
== VT_UI8
)
2690 else if(l
== VT_DATE
)
2692 else if (l
== VT_DECIMAL
)
2694 V_DECIMAL(&v1
).Hi32
= 0;
2695 U1(V_DECIMAL(&v1
)).Lo64
= 100;
2696 U(V_DECIMAL(&v1
)).signscale
= 0;
2702 V_CY(&v2
).int64
= 10000;
2707 else if(r
== VT_UI8
)
2711 else if(r
== VT_DATE
)
2713 else if (r
== VT_DECIMAL
)
2715 V_DECIMAL(&v2
).Hi32
= 0;
2716 U1(V_DECIMAL(&v2
)).Lo64
= 100;
2717 U(V_DECIMAL(&v2
)).signscale
= 0;
2722 if ((l
!= VT_I8
&& l
!= VT_UI8
&& r
!= VT_I8
&& r
!= VT_UI8
) || has_i8
)
2724 hres
= pVarMod(&v1
,&v2
,&vDst
);
2725 ok(hres
== hexpected
,
2726 "VarMod: expected 0x%x, got 0x%X for l type of %d, r type of %d,\n", hexpected
, hres
, l
, r
);
2732 /****************************/
2733 /* test some bad parameters */
2734 VARMOD(I4
,I4
,-1,-1,I4
,0);
2736 /* test modulus with zero */
2737 VARMOD2(I4
,I4
,100,0,EMPTY
,0,DISP_E_DIVBYZERO
);
2739 VARMOD(I4
,I4
,0,10,I4
,0); /* test 0 mod 10 */
2741 /* right parameter is type empty */
2742 VARMOD2(I4
,EMPTY
,100,10,EMPTY
,0,DISP_E_DIVBYZERO
);
2744 /* left parameter is type empty */
2745 VARMOD2(EMPTY
,I4
,100,10,I4
,0,S_OK
);
2747 /* mod with a null left value */
2748 VARMOD2(NULL
,I4
,125,10,NULL
,0,S_OK
);
2750 /* mod with a null right value */
2751 VARMOD2(I4
,NULL
,100,10,NULL
,0,S_OK
);
2753 /* void left value */
2754 VARMOD2(VOID
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2756 /* void right value */
2757 VARMOD2(I4
,VOID
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2759 /* null left value, void right value */
2760 VARMOD2(NULL
,VOID
,100,10,EMPTY
, 0, DISP_E_BADVARTYPE
);
2762 /* void left value, null right value */
2763 VARMOD2(VOID
,NULL
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2765 /* some currencies */
2768 V_CY(&v1
).int64
= 100000;
2769 V_CY(&v2
).int64
= 100000;
2770 hres
= pVarMod(&v1
,&v2
,&vDst
);
2771 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I4
&& V_I4(&vDst
) == 0,
2772 "VarMod: expected 0x%x,%d,%d, got 0x%X,%d,%d\n", S_OK
, VT_I4
, 0, hres
, V_VT(&vDst
), V_I4(&vDst
));
2777 V_CY(&v2
).int64
= 100000;
2778 hres
= pVarMod(&v1
,&v2
,&vDst
);
2779 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I4
&& V_I4(&vDst
) == 0,
2780 "VarMod: expected 0x%x,%d,%d, got 0x%X,%d,%d\n", S_OK
, VT_I4
, 0, hres
, V_VT(&vDst
), V_I4(&vDst
));
2783 V_VT(&v1
) = VT_DECIMAL
;
2784 V_VT(&v2
) = VT_DECIMAL
;
2785 VarDecFromI4(100, &V_DECIMAL(&v1
));
2786 VarDecFromI4(10, &V_DECIMAL(&v2
));
2787 hres
= pVarMod(&v1
,&v2
,&vDst
);
2788 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I4
&& V_I4(&vDst
) == 0,
2789 "VarMod: expected 0x%x,%d,%d, got 0x%X,%d,%d\n", S_OK
, VT_I4
, 0, hres
, V_VT(&vDst
), V_I4(&vDst
));
2792 V_VT(&v2
) = VT_DECIMAL
;
2794 VarDecFromI4(10, &V_DECIMAL(&v2
));
2795 hres
= pVarMod(&v1
,&v2
,&vDst
);
2796 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I4
&& V_I4(&vDst
) == 0,
2797 "VarMod: expected 0x%x,%d,%d, got 0x%X,%d,%d\n", S_OK
, VT_I4
, 0, hres
, V_VT(&vDst
), V_I4(&vDst
));
2799 VARMOD2(UINT
,I4
,100,10,I4
,0,S_OK
);
2801 /* test that an error results in the type of the result changing but not its value */
2802 V_VT(&v1
) = VT_UNKNOWN
;
2803 V_VT(&v2
) = VT_EMPTY
;
2805 V_CY(&v2
).int64
= 100000;
2806 V_VT(&vDst
) = VT_I4
;
2808 hres
= pVarMod(&v1
,&v2
,&vDst
);
2809 ok(hres
== DISP_E_TYPEMISMATCH
&& V_VT(&vDst
) == VT_EMPTY
&& V_I4(&vDst
) == 1231,
2810 "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
));
2813 /* test some invalid types */
2814 /*TODO: not testing VT_DISPATCH */
2817 VARMOD2(I8
,INT
,100,10,EMPTY
,0,DISP_E_TYPEMISMATCH
);
2819 VARMOD2(ERROR
,I4
,100,10,EMPTY
,0,DISP_E_TYPEMISMATCH
);
2820 VARMOD2(VARIANT
,I4
,100,10,EMPTY
,0,DISP_E_TYPEMISMATCH
);
2821 VARMOD2(UNKNOWN
,I4
,100,10,EMPTY
,0,DISP_E_TYPEMISMATCH
);
2822 VARMOD2(VOID
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2823 VARMOD2(HRESULT
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2824 VARMOD2(PTR
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2825 VARMOD2(SAFEARRAY
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2826 VARMOD2(CARRAY
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2827 VARMOD2(USERDEFINED
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2828 VARMOD2(LPSTR
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2829 VARMOD2(LPWSTR
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2830 VARMOD2(RECORD
,I4
,100,10,EMPTY
,0,DISP_E_TYPEMISMATCH
);
2831 VARMOD2(FILETIME
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2832 VARMOD2(BLOB
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2833 VARMOD2(STREAM
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2834 VARMOD2(STORAGE
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2835 VARMOD2(STREAMED_OBJECT
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2836 VARMOD2(STORED_OBJECT
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2837 VARMOD2(BLOB_OBJECT
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2838 VARMOD2(CF
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2839 VARMOD2(CLSID
,CLSID
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2840 VARMOD2(VECTOR
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2841 VARMOD2(ARRAY
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2842 VARMOD2(BYREF
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2844 /* test some more invalid types */
2849 hres
= pVarMod(&v1
,&v2
,&vDst
);
2850 ok(hres
== DISP_E_BADVARTYPE
&& V_VT(&vDst
) == VT_EMPTY
,
2851 "VarMod: expected 0x%x,%d, got 0x%X,%d\n", DISP_E_BADVARTYPE
, VT_EMPTY
, hres
, V_VT(&vDst
));
2853 SysFreeString(strNum0
);
2854 SysFreeString(strNum1
);
2857 static HRESULT (WINAPI
*pVarFix
)(LPVARIANT
,LPVARIANT
);
2859 #define VARFIX(vt,val,rvt,rval) \
2860 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
2861 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
2862 test_var_call1( __LINE__, pVarFix, &v, &exp )
2864 static void test_VarFix(void)
2866 static const WCHAR szNumMinus1
[] = {'-','1','\0' };
2868 VARIANT v
, exp
, vDst
;
2869 DECIMAL
*pdec
= &V_DECIMAL(&v
);
2870 CY
*pcy
= &V_CY(&v
);
2875 /* Test all possible V_VT values */
2876 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
2880 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
2886 memset(&v
, 0, sizeof(v
));
2887 V_VT(&v
) = vt
| ExtraFlags
[i
];
2888 V_VT(&vDst
) = VT_EMPTY
;
2892 case VT_UI1
: case VT_I2
: case VT_I4
: case VT_R4
: case VT_R8
:
2893 case VT_DECIMAL
: case VT_BOOL
: case VT_NULL
: case VT_EMPTY
:
2894 case VT_DATE
: case VT_CY
:
2903 hres
= pVarFix(&v
,&vDst
);
2905 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
2906 "VarFix: expected failure, got 0x%X vt %d|0x%X\n",
2907 hres
, vt
, ExtraFlags
[i
]);
2909 ok(hres
== S_OK
, "VarFix: expected S_OK, got 0x%X vt %d|0x%X\n",
2910 hres
, vt
, ExtraFlags
[i
]);
2914 VARFIX(BOOL
,VARIANT_TRUE
,I2
,VARIANT_TRUE
);
2915 VARFIX(BOOL
,VARIANT_FALSE
,I2
,0);
2916 VARFIX(BOOL
,1,I2
,1);
2917 VARFIX(UI1
,1,UI1
,1);
2918 VARFIX(I2
,-1,I2
,-1);
2919 VARFIX(I4
,-1,I4
,-1);
2922 VARFIX(I8
,-1,I8
,-1);
2924 VARFIX(R4
,1.4f
,R4
,1);
2925 VARFIX(R4
,1.5f
,R4
,1);
2926 VARFIX(R4
,1.6f
,R4
,1);
2927 VARFIX(R4
,-1.4f
,R4
,-1);
2928 VARFIX(R4
,-1.5f
,R4
,-1);
2929 VARFIX(R4
,-1.6f
,R4
,-1);
2930 /* DATE & R8 round as for R4 */
2931 VARFIX(DATE
,-1,DATE
,-1);
2932 VARFIX(R8
,-1,R8
,-1);
2933 VARFIX(BSTR
,(BSTR
)szNumMinus1
,R8
,-1);
2935 V_VT(&v
) = VT_EMPTY
;
2936 hres
= pVarFix(&v
,&vDst
);
2937 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I2
&& V_I2(&vDst
) == 0,
2938 "VarFix: expected 0x0,%d,0 got 0x%X,%d,%d\n", VT_EMPTY
,
2939 hres
, V_VT(&vDst
), V_I2(&vDst
));
2942 hres
= pVarFix(&v
,&vDst
);
2943 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_NULL
,
2944 "VarFix: expected 0x0,%d got 0x%X,%d\n", VT_NULL
, hres
, V_VT(&vDst
));
2946 V_VT(&v
) = VT_DECIMAL
;
2947 S(U(*pdec
)).sign
= DECIMAL_NEG
;
2948 S(U(*pdec
)).scale
= 0;
2950 S1(U1(*pdec
)).Mid32
= 0;
2951 S1(U1(*pdec
)).Lo32
= 1;
2952 hres
= pVarFix(&v
,&vDst
);
2953 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_DECIMAL
&& !memcmp(&V_DECIMAL(&v
), &V_DECIMAL(&vDst
), sizeof(DECIMAL
)),
2954 "VarFix: expected 0x0,%d,identical, got 0x%X,%d\n", VT_DECIMAL
,
2957 /* FIXME: Test some fractional decimals when VarDecFix is implemented */
2960 pcy
->int64
= -10000;
2961 hres
= pVarFix(&v
,&vDst
);
2962 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_CY
&& V_CY(&vDst
).int64
== -10000,
2963 "VarFix: VT_CY wrong, hres=0x%X\n", hres
);
2966 pcy
->int64
= -16000;
2967 hres
= pVarFix(&v
,&vDst
);
2968 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_CY
&& V_CY(&vDst
).int64
== -10000,
2969 "VarFix: VT_CY wrong, hres=0x%X\n", hres
);
2972 static HRESULT (WINAPI
*pVarInt
)(LPVARIANT
,LPVARIANT
);
2974 #define VARINT(vt,val,rvt,rval) \
2975 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
2976 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
2977 test_var_call1( __LINE__, pVarInt, &v, &exp )
2979 static void test_VarInt(void)
2981 static const WCHAR szNumMinus1
[] = {'-','1','\0' };
2983 VARIANT v
, exp
, vDst
;
2984 DECIMAL
*pdec
= &V_DECIMAL(&v
);
2985 CY
*pcy
= &V_CY(&v
);
2990 /* Test all possible V_VT values */
2991 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
2995 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
3001 memset(&v
, 0, sizeof(v
));
3002 V_VT(&v
) = vt
| ExtraFlags
[i
];
3003 V_VT(&vDst
) = VT_EMPTY
;
3007 case VT_UI1
: case VT_I2
: case VT_I4
: case VT_R4
: case VT_R8
:
3008 case VT_DECIMAL
: case VT_BOOL
: case VT_NULL
: case VT_EMPTY
:
3009 case VT_DATE
: case VT_CY
:
3018 hres
= pVarInt(&v
,&vDst
);
3020 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
3021 "VarInt: expected failure, got 0x%X vt %d|0x%X\n",
3022 hres
, vt
, ExtraFlags
[i
]);
3024 ok(hres
== S_OK
, "VarInt: expected S_OK, got 0x%X vt %d|0x%X\n",
3025 hres
, vt
, ExtraFlags
[i
]);
3029 VARINT(BOOL
,VARIANT_TRUE
,I2
,VARIANT_TRUE
);
3030 VARINT(BOOL
,VARIANT_FALSE
,I2
,0);
3031 VARINT(BOOL
,1,I2
,1);
3032 VARINT(UI1
,1,UI1
,1);
3033 VARINT(I2
,-1,I2
,-1);
3034 VARINT(I4
,-1,I4
,-1);
3037 VARINT(I8
,-1,I8
,-1);
3039 VARINT(R4
,1.4f
,R4
,1);
3040 VARINT(R4
,1.5f
,R4
,1);
3041 VARINT(R4
,1.6f
,R4
,1);
3042 VARINT(R4
,-1.4f
,R4
,-2); /* Note these 3 are different from VarFix */
3043 VARINT(R4
,-1.5f
,R4
,-2);
3044 VARINT(R4
,-1.6f
,R4
,-2);
3045 /* DATE & R8 round as for R4 */
3046 VARINT(DATE
,-1,DATE
,-1);
3047 VARINT(R8
,-1,R8
,-1);
3048 VARINT(BSTR
,(BSTR
)szNumMinus1
,R8
,-1);
3050 V_VT(&v
) = VT_EMPTY
;
3051 hres
= pVarInt(&v
,&vDst
);
3052 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I2
&& V_I2(&vDst
) == 0,
3053 "VarInt: expected 0x0,%d,0 got 0x%X,%d,%d\n", VT_EMPTY
,
3054 hres
, V_VT(&vDst
), V_I2(&vDst
));
3057 hres
= pVarInt(&v
,&vDst
);
3058 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_NULL
,
3059 "VarInt: expected 0x0,%d got 0x%X,%d\n", VT_NULL
, hres
, V_VT(&vDst
));
3061 V_VT(&v
) = VT_DECIMAL
;
3062 S(U(*pdec
)).sign
= DECIMAL_NEG
;
3063 S(U(*pdec
)).scale
= 0;
3065 S1(U1(*pdec
)).Mid32
= 0;
3066 S1(U1(*pdec
)).Lo32
= 1;
3067 hres
= pVarInt(&v
,&vDst
);
3068 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_DECIMAL
&& !memcmp(&V_DECIMAL(&v
), &V_DECIMAL(&vDst
), sizeof(DECIMAL
)),
3069 "VarInt: expected 0x0,%d,identical, got 0x%X,%d\n", VT_DECIMAL
,
3072 /* FIXME: Test some fractional decimals when VarDecInt is implemented */
3075 pcy
->int64
= -10000;
3076 hres
= pVarInt(&v
,&vDst
);
3077 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_CY
&& V_CY(&vDst
).int64
== -10000,
3078 "VarInt: VT_CY wrong, hres=0x%X\n", hres
);
3081 pcy
->int64
= -11000;
3082 hres
= pVarInt(&v
,&vDst
);
3083 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_CY
&& V_CY(&vDst
).int64
== -20000,
3084 "VarInt: VT_CY wrong, hres=0x%X 0x%x%08x\n",
3085 hres
, (DWORD
)(V_CY(&vDst
).int64
>> 32), (DWORD
)V_CY(&vDst
).int64
);
3088 static HRESULT (WINAPI
*pVarNeg
)(LPVARIANT
,LPVARIANT
);
3090 #define VARNEG(vt,val,rvt,rval) \
3091 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
3092 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
3093 test_var_call1( __LINE__, pVarNeg, &v, &exp )
3095 static void test_VarNeg(void)
3097 static const WCHAR szNumMinus1
[] = {'-','1','\0' };
3098 static const WCHAR szNum1
[] = {'1','\0' };
3100 VARIANT v
, exp
, vDst
;
3101 DECIMAL
*pdec
= &V_DECIMAL(&v
);
3102 CY
*pcy
= &V_CY(&v
);
3107 /* Test all possible V_VT values. But don't test the exact return values
3108 * except for success/failure, since M$ made a hash of them in the
3109 * native version. This at least ensures (as with all tests here) that
3110 * we will notice if/when new vtypes/flags are added in native.
3112 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
3116 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
3122 memset(&v
, 0, sizeof(v
));
3123 V_VT(&v
) = vt
| ExtraFlags
[i
];
3124 V_VT(&vDst
) = VT_EMPTY
;
3128 case VT_UI1
: case VT_I2
: case VT_I4
:
3129 case VT_R4
: case VT_R8
:
3130 case VT_DECIMAL
: case VT_BOOL
: case VT_NULL
: case VT_EMPTY
:
3131 case VT_DATE
: case VT_CY
:
3139 hres
= pVarNeg(&v
,&vDst
);
3141 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
3142 "VarNeg: expected failure, got 0x%X vt %d|0x%X\n",
3143 hres
, vt
, ExtraFlags
[i
]);
3145 ok(hres
== S_OK
, "VarNeg: expected S_OK, got 0x%X vt %d|0x%X\n",
3146 hres
, vt
, ExtraFlags
[i
]);
3150 VARNEG(BOOL
,VARIANT_TRUE
,I2
,1);
3151 VARNEG(BOOL
,VARIANT_FALSE
,I2
,0);
3152 VARNEG(BOOL
,1,I2
,-1);
3153 VARNEG(UI1
,1,I2
,-1);
3154 VARNEG(UI1
,254,I2
,-254);
3155 VARNEG(I2
,-32768,I4
,32768);
3158 VARNEG(I4
,-((int)(~0u >> 1)) - 1,R8
,-2147483648u);
3168 VARNEG(DATE
,1,DATE
,-1);
3169 VARNEG(DATE
,-1,DATE
,1);
3172 VARNEG(BSTR
,(BSTR
)szNumMinus1
,R8
,1);
3173 VARNEG(BSTR
,(BSTR
)szNum1
,R8
,-1);
3175 V_VT(&v
) = VT_EMPTY
;
3176 hres
= pVarNeg(&v
,&vDst
);
3177 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I2
&& V_I2(&vDst
) == 0,
3178 "VarNeg: expected 0x0,%d,0 got 0x%X,%d,%d\n", VT_EMPTY
,
3179 hres
, V_VT(&vDst
), V_I2(&vDst
));
3182 hres
= pVarNeg(&v
,&vDst
);
3183 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_NULL
,
3184 "VarNeg: expected 0x0,%d got 0x%X,%d\n", VT_NULL
, hres
, V_VT(&vDst
));
3186 V_VT(&v
) = VT_DECIMAL
;
3187 S(U(*pdec
)).sign
= DECIMAL_NEG
;
3188 S(U(*pdec
)).scale
= 0;
3190 S1(U1(*pdec
)).Mid32
= 0;
3191 S1(U1(*pdec
)).Lo32
= 1;
3192 hres
= pVarNeg(&v
,&vDst
);
3193 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_DECIMAL
&&
3194 S(U(V_DECIMAL(&vDst
))).sign
== 0,
3195 "VarNeg: expected 0x0,%d,0x00, got 0x%X,%d,%02x\n", VT_DECIMAL
,
3196 hres
, V_VT(&vDst
), S(U(V_DECIMAL(&vDst
))).sign
);
3198 S(U(*pdec
)).sign
= 0;
3199 hres
= pVarNeg(&v
,&vDst
);
3200 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_DECIMAL
&&
3201 S(U(V_DECIMAL(&vDst
))).sign
== DECIMAL_NEG
,
3202 "VarNeg: expected 0x0,%d,0x7f, got 0x%X,%d,%02x\n", VT_DECIMAL
,
3203 hres
, V_VT(&vDst
), S(U(V_DECIMAL(&vDst
))).sign
);
3206 pcy
->int64
= -10000;
3207 hres
= pVarNeg(&v
,&vDst
);
3208 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_CY
&& V_CY(&vDst
).int64
== 10000,
3209 "VarNeg: VT_CY wrong, hres=0x%X\n", hres
);
3212 static HRESULT (WINAPI
*pVarRound
)(LPVARIANT
,int,LPVARIANT
);
3214 static void test_Round( int line
, VARIANT
*arg
, int deci
, VARIANT
*expected
)
3219 memset( &result
, 0, sizeof(result
) );
3220 hres
= pVarRound( arg
, deci
, &result
);
3221 ok_(__FILE__
,line
)( hres
== S_OK
, "wrong result %x\n", hres
);
3223 ok_(__FILE__
,line
)( is_expected_variant( &result
, expected
),
3224 "got %s expected %s\n", variantstr(&result
), variantstr(expected
) );
3226 #define VARROUND(vt,val,deci,rvt,rval) \
3227 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
3228 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
3229 test_Round( __LINE__, &v, deci, &exp )
3239 struct decimal_round_t
{
3240 struct decimal_t source
;
3241 struct decimal_t ret
;
3245 static const struct decimal_round_t decimal_round_data
[] = {
3246 {{ 0, DECIMAL_NEG
, 0, 0, 1 }, { 0, DECIMAL_NEG
, 0, 0, 1 }, 0},
3247 {{ 0, 0, 0, 0, 1 }, { 0, 0, 0, 0, 1 }, 0},
3248 {{ 2, 0, 0, 0, 155 }, { 0, 0, 0, 0, 16 }, 1},
3249 {{ 2, 0, 0, 0, 155 }, { 1, 0, 0, 0, 2 }, 0},
3250 {{ 2, 0, 0, 0, 199 }, { 1, 0, 0, 0, 20 }, 1},
3251 {{ 2, 0, 0, 0, 199 }, { 2, 0, 0, 0, 199 }, 2},
3252 {{ 2, DECIMAL_NEG
, 0, 0, 199 }, { 2, DECIMAL_NEG
, 0, 0, 199 }, 2},
3253 {{ 2, DECIMAL_NEG
, 0, 0, 55 }, { 2, DECIMAL_NEG
, 0, 0, 6 }, 1},
3254 {{ 2, 0, 0, 0, 55 }, { 2, 0, 0, 0, 6 }, 1}
3257 static void test_VarRound(void)
3259 static WCHAR szNumMin
[] = {'-','1','.','4','4','9','\0' };
3260 static WCHAR szNum
[] = {'1','.','4','5','1','\0' };
3262 VARIANT v
, exp
, vDst
;
3263 CY
*pcy
= &V_CY(&v
);
3269 /* first check valid integer types */
3270 VARROUND(BOOL
,VARIANT_TRUE
,0,I2
,-1);
3271 VARROUND(BOOL
,VARIANT_FALSE
,0,I2
,0);
3272 VARROUND(BOOL
,1,0,I2
,1);
3273 VARROUND(UI1
,1,0,UI1
,1);
3274 VARROUND(UI1
,254,0,UI1
,254);
3275 VARROUND(I2
,-32768,0,I2
,-32768);
3276 VARROUND(I2
,-1,0,I2
,-1);
3277 VARROUND(I2
,1,0,I2
,1);
3278 VARROUND(I4
,-((int)(~0u >> 1)) - 1,0,I4
,-((int)(~0u >> 1)) - 1);
3279 VARROUND(I4
,-1,0,I4
,-1);
3280 VARROUND(I4
,1,0,I4
,1);
3283 /* MSDN states that rounding of R4/R8 is dependent on the underlying
3284 * bit pattern of the number and so is architecture dependent. In this
3285 * case Wine returns .2 (which is more correct) and Native returns .3
3288 VARROUND(R4
,1.0f
,0,R4
,1.0f
);
3289 VARROUND(R4
,-1.0f
,0,R4
,-1.0f
);
3290 VARROUND(R8
,1.0,0,R8
,1.0);
3291 VARROUND(R8
,-1.0,0,R8
,-1.0);
3293 /* floating point numbers aren't exactly equal and we can't just
3294 * compare the first few digits. */
3295 VARROUND(DATE
,1.451,1,DATE
,1.5);
3296 VARROUND(DATE
,-1.449,1,DATE
,-1.4);
3298 /* replace the decimal separator */
3299 GetLocaleInfoA(LOCALE_USER_DEFAULT
, LOCALE_SDECIMAL
, buff
, sizeof(buff
)/sizeof(char));
3301 szNumMin
[2] = buff
[0];
3303 VARROUND(BSTR
,(BSTR
)szNumMin
,1,R8
,-1.40);
3304 VARROUND(BSTR
,(BSTR
)szNum
,1,R8
,1.50);
3306 skip("Skipping VarRound(BSTR) as decimal separator is '%s'\n", buff
);
3309 VARROUND(R4
,1.23456f
,0,R4
,1.0f
);
3310 VARROUND(R4
,1.23456f
,1,R4
,1.2f
);
3311 VARROUND(R4
,1.23456f
,2,R4
,1.23f
);
3312 VARROUND(R4
,1.23456f
,3,R4
,1.235f
);
3313 VARROUND(R4
,1.23456f
,4,R4
,1.2346f
);
3314 VARROUND(R4
,-1.23456f
,0,R4
,-1.0f
);
3315 VARROUND(R4
,-1.23456f
,1,R4
,-1.2f
);
3316 VARROUND(R4
,-1.23456f
,2,R4
,-1.23f
);
3317 VARROUND(R4
,-1.23456f
,3,R4
,-1.235f
);
3318 VARROUND(R4
,-1.23456f
,4,R4
,-1.2346f
);
3320 VARROUND(R8
,1.23456,0,R8
,1.0);
3321 VARROUND(R8
,1.23456,1,R8
,1.2);
3322 VARROUND(R8
,1.23456,2,R8
,1.23);
3323 VARROUND(R8
,1.23456,3,R8
,1.235);
3324 VARROUND(R8
,1.23456,4,R8
,1.2346);
3325 VARROUND(R8
,-1.23456,0,R8
,-1.0);
3326 VARROUND(R8
,-1.23456,1,R8
,-1.2);
3327 VARROUND(R8
,-1.23456,2,R8
,-1.23);
3328 VARROUND(R8
,-1.23456,3,R8
,-1.235);
3329 VARROUND(R8
,-1.23456,4,R8
,-1.2346);
3331 V_VT(&v
) = VT_EMPTY
;
3332 hres
= pVarRound(&v
,0,&vDst
);
3333 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I2
&& V_I2(&vDst
) == 0,
3334 "VarRound: expected 0x0,%d,0 got 0x%X,%d,%d\n", VT_EMPTY
,
3335 hres
, V_VT(&vDst
), V_I2(&vDst
));
3338 hres
= pVarRound(&v
,0,&vDst
);
3339 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_NULL
,
3340 "VarRound: expected 0x0,%d got 0x%X,%d\n", VT_NULL
, hres
, V_VT(&vDst
));
3343 for (i
= 0; i
< sizeof(decimal_round_data
)/sizeof(struct decimal_round_t
); i
++)
3345 const struct decimal_round_t
*ptr
= &decimal_round_data
[i
];
3348 pdec
= &V_DECIMAL(&v
);
3349 V_VT(&v
) = VT_DECIMAL
;
3350 S(U(*pdec
)).sign
= ptr
->source
.sign
;
3351 S(U(*pdec
)).scale
= ptr
->source
.scale
;
3352 pdec
->Hi32
= ptr
->source
.Hi32
;
3353 S1(U1(*pdec
)).Mid32
= ptr
->source
.Mid32
;
3354 S1(U1(*pdec
)).Lo32
= ptr
->source
.Lo32
;
3356 hres
= pVarRound(&v
, ptr
->dec
, &vDst
);
3358 ok(hres
== S_OK
, "%d: got 0x%08x\n", i
, hres
);
3361 ok(V_VT(&vDst
) == VT_DECIMAL
, "%d: got VT %d, expected VT_DECIMAL\n", i
, V_VT(&vDst
));
3362 ok(S(U(V_DECIMAL(&vDst
))).sign
== ptr
->ret
.sign
, "%d: got sign 0x%02x, expected 0x%02x\n",
3363 i
, S(U(V_DECIMAL(&vDst
))).sign
, ptr
->ret
.sign
);
3364 ok(V_DECIMAL(&vDst
).Hi32
== ptr
->ret
.Hi32
, "%d: got Hi32 %d, expected %d\n",
3365 i
, V_DECIMAL(&vDst
).Hi32
, ptr
->ret
.Hi32
);
3366 ok(S1(U1(V_DECIMAL(&vDst
))).Mid32
== ptr
->ret
.Mid32
, "%d: got Mid32 %d, expected %d\n",
3367 i
, S1(U1(V_DECIMAL(&vDst
))).Mid32
, ptr
->ret
.Mid32
);
3368 ok(S1(U1(V_DECIMAL(&vDst
))).Lo32
== ptr
->ret
.Lo32
, "%d: got Lo32 %d, expected %d\n",
3369 i
, S1(U1(V_DECIMAL(&vDst
))).Lo32
, ptr
->ret
.Lo32
);
3376 hres
= pVarRound(&v
,0,&vDst
);
3377 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_CY
&& V_CY(&vDst
).int64
== 10000,
3378 "VarRound: VT_CY wrong, hres=0x%X\n", hres
);
3382 static HRESULT (WINAPI
*pVarXor
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
3384 #define VARXOR(vt1,val1,vt2,val2,rvt,rval) \
3385 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
3386 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
3387 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
3388 test_var_call2( __LINE__, pVarXor, &left, &right, &exp )
3390 #define VARXORCY(vt1,val1,val2,rvt,rval) \
3391 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
3392 V_VT(&right) = VT_CY; V_CY(&right).int64 = val2; \
3393 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
3394 test_var_call2( __LINE__, pVarXor, &left, &right, &exp )
3396 static void test_VarXor(void)
3398 static const WCHAR szFalse
[] = { '#','F','A','L','S','E','#','\0' };
3399 static const WCHAR szTrue
[] = { '#','T','R','U','E','#','\0' };
3400 VARIANT left
, right
, exp
, result
;
3407 /* Test all possible flag/vt combinations & the resulting vt type */
3408 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
3410 VARTYPE leftvt
, rightvt
, resvt
;
3412 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
3417 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
3423 if (leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
||
3424 leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
||
3425 leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
)
3428 memset(&left
, 0, sizeof(left
));
3429 memset(&right
, 0, sizeof(right
));
3430 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
3431 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
3432 V_VT(&result
) = VT_EMPTY
;
3435 if (ExtraFlags
[i
] & VT_ARRAY
|| ExtraFlags
[i
] & VT_BYREF
||
3436 !IsValidVariantClearVT(leftvt
, ExtraFlags
[i
]) ||
3437 !IsValidVariantClearVT(rightvt
, ExtraFlags
[i
]) ||
3438 leftvt
== VT_CLSID
|| rightvt
== VT_CLSID
||
3439 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
||
3440 leftvt
== VT_VARIANT
|| rightvt
== VT_VARIANT
||
3441 leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
)
3445 if (leftvt
== VT_EMPTY
|| rightvt
== VT_EMPTY
)
3447 if (leftvt
== rightvt
||
3448 leftvt
== VT_I2
|| rightvt
== VT_I2
||
3449 leftvt
== VT_UI1
|| rightvt
== VT_UI1
||
3450 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
3452 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
3454 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
3457 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
3461 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
3463 if (leftvt
== rightvt
)
3465 else if (leftvt
== rightvt
||
3466 leftvt
== VT_I2
|| rightvt
== VT_I2
||
3467 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
3471 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
3474 else if (leftvt
== VT_I2
|| rightvt
== VT_I2
)
3476 if (leftvt
== rightvt
||
3477 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
3479 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
3482 else if (leftvt
== VT_BOOL
&& rightvt
== VT_BOOL
)
3486 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
3488 if (leftvt
== VT_INT
|| rightvt
== VT_INT
)
3493 hres
= pVarXor(&left
, &right
, &result
);
3495 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
3496 "VarXor: %d|0x%X, %d|0x%X: Expected failure, got 0x%X vt %d\n",
3497 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], hres
,
3500 ok(hres
== S_OK
&& V_VT(&result
) == resvt
,
3501 "VarXor: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%X vt %d\n",
3502 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], resvt
, hres
,
3508 /* Test returned values
3509 * FIXME: Test VT_DECIMAL/VT_DISPATCH
3511 VARXOR(EMPTY
,0,EMPTY
,0,I2
,0);
3512 VARXOR(EMPTY
,1,EMPTY
,0,I2
,0);
3513 VARXOR(EMPTY
,0,NULL
,0,NULL
,0);
3514 VARXOR(EMPTY
,0,I1
,0,I4
,0);
3515 VARXOR(EMPTY
,0,I1
,1,I4
,1);
3516 VARXOR(EMPTY
,0,UI1
,0,I2
,0);
3517 VARXOR(EMPTY
,0,UI1
,1,I2
,1);
3518 VARXOR(EMPTY
,0,I2
,0,I2
,0);
3519 VARXOR(EMPTY
,0,I2
,1,I2
,1);
3520 VARXOR(EMPTY
,0,UI2
,0,I4
,0);
3521 VARXOR(EMPTY
,0,UI2
,1,I4
,1);
3522 VARXOR(EMPTY
,0,I4
,0,I4
,0);
3523 VARXOR(EMPTY
,0,I4
,1,I4
,1);
3524 VARXOR(EMPTY
,0,UI4
,0,I4
,0);
3525 VARXOR(EMPTY
,0,UI4
,1,I4
,1);
3528 VARXOR(EMPTY
,0,I8
,0,I8
,0);
3529 VARXOR(EMPTY
,0,I8
,1,I8
,1);
3530 VARXOR(EMPTY
,0,UI8
,0,I4
,0);
3531 VARXOR(EMPTY
,0,UI8
,1,I4
,1);
3533 VARXOR(EMPTY
,0,INT
,0,I4
,0);
3534 VARXOR(EMPTY
,0,INT
,1,I4
,1);
3535 VARXOR(EMPTY
,0,UINT
,0,I4
,0);
3536 VARXOR(EMPTY
,0,UINT
,1,I4
,1);
3537 VARXOR(EMPTY
,0,BOOL
,0,I2
,0);
3538 VARXOR(EMPTY
,0,BOOL
,1,I2
,1);
3539 VARXOR(EMPTY
,0,R4
,0,I4
,0);
3540 VARXOR(EMPTY
,0,R4
,1,I4
,1);
3541 VARXOR(EMPTY
,0,R8
,0,I4
,0);
3542 VARXOR(EMPTY
,0,R8
,1,I4
,1);
3543 rbstr
= SysAllocString(szFalse
);
3544 VARXOR(EMPTY
,0,BSTR
,rbstr
,I2
,0);
3545 SysFreeString(rbstr
);
3546 rbstr
= SysAllocString(szTrue
);
3547 VARXOR(EMPTY
,0,BSTR
,rbstr
,I2
,-1);
3548 VARXORCY(EMPTY
,0,10000,I4
,1);
3549 SysFreeString(rbstr
);
3551 /* NULL OR 0 = NULL. NULL OR n = n */
3552 VARXOR(NULL
,0,NULL
,0,NULL
,0);
3553 VARXOR(NULL
,1,NULL
,0,NULL
,0);
3554 VARXOR(NULL
,0,I1
,0,NULL
,0);
3555 VARXOR(NULL
,0,I1
,1,NULL
,0);
3556 VARXOR(NULL
,0,UI1
,0,NULL
,0);
3557 VARXOR(NULL
,0,UI1
,1,NULL
,0);
3558 VARXOR(NULL
,0,I2
,0,NULL
,0);
3559 VARXOR(NULL
,0,I2
,1,NULL
,0);
3560 VARXOR(NULL
,0,UI2
,0,NULL
,0);
3561 VARXOR(NULL
,0,UI2
,1,NULL
,0);
3562 VARXOR(NULL
,0,I4
,0,NULL
,0);
3563 VARXOR(NULL
,0,I4
,1,NULL
,0);
3564 VARXOR(NULL
,0,UI4
,0,NULL
,0);
3565 VARXOR(NULL
,0,UI4
,1,NULL
,0);
3568 VARXOR(NULL
,0,I8
,0,NULL
,0);
3569 VARXOR(NULL
,0,I8
,1,NULL
,0);
3570 VARXOR(NULL
,0,UI8
,0,NULL
,0);
3571 VARXOR(NULL
,0,UI8
,1,NULL
,0);
3573 VARXOR(NULL
,0,INT
,0,NULL
,0);
3574 VARXOR(NULL
,0,INT
,1,NULL
,0);
3575 VARXOR(NULL
,0,UINT
,0,NULL
,0);
3576 VARXOR(NULL
,0,UINT
,1,NULL
,0);
3577 VARXOR(NULL
,0,BOOL
,0,NULL
,0);
3578 VARXOR(NULL
,0,BOOL
,1,NULL
,0);
3579 VARXOR(NULL
,0,R4
,0,NULL
,0);
3580 VARXOR(NULL
,0,R4
,1,NULL
,0);
3581 VARXOR(NULL
,0,R8
,0,NULL
,0);
3582 VARXOR(NULL
,0,R8
,1,NULL
,0);
3583 rbstr
= SysAllocString(szFalse
);
3584 VARXOR(NULL
,0,BSTR
,rbstr
,NULL
,0);
3585 SysFreeString(rbstr
);
3586 rbstr
= SysAllocString(szTrue
);
3587 VARXOR(NULL
,0,BSTR
,rbstr
,NULL
,0);
3588 SysFreeString(rbstr
);
3589 VARXORCY(NULL
,0,10000,NULL
,0);
3590 VARXORCY(NULL
,0,0,NULL
,0);
3592 VARXOR(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
);
3593 VARXOR(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
);
3594 VARXOR(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
);
3595 VARXOR(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_FALSE
);
3596 /* Assume x,y & y,x are the same from now on to reduce the number of tests */
3597 VARXOR(BOOL
,VARIANT_TRUE
,I1
,-1,I4
,0);
3598 VARXOR(BOOL
,VARIANT_TRUE
,I1
,0,I4
,-1);
3599 VARXOR(BOOL
,VARIANT_FALSE
,I1
,0,I4
,0);
3600 VARXOR(BOOL
,VARIANT_TRUE
,UI1
,255,I2
,-256);
3601 VARXOR(BOOL
,VARIANT_TRUE
,UI1
,0,I2
,-1);
3602 VARXOR(BOOL
,VARIANT_FALSE
,UI1
,0,I2
,0);
3603 VARXOR(BOOL
,VARIANT_TRUE
,I2
,-1,I2
,0);
3604 VARXOR(BOOL
,VARIANT_TRUE
,I2
,0,I2
,-1);
3605 VARXOR(BOOL
,VARIANT_FALSE
,I2
,0,I2
,0);
3606 VARXOR(BOOL
,VARIANT_TRUE
,UI2
,65535,I4
,-65536);
3607 VARXOR(BOOL
,VARIANT_TRUE
,UI2
,0,I4
,-1);
3608 VARXOR(BOOL
,VARIANT_FALSE
,UI2
,0,I4
,0);
3609 VARXOR(BOOL
,VARIANT_TRUE
,I4
,-1,I4
,0);
3610 VARXOR(BOOL
,VARIANT_TRUE
,I4
,0,I4
,-1);
3611 VARXOR(BOOL
,VARIANT_FALSE
,I4
,0,I4
,0);
3612 VARXOR(BOOL
,VARIANT_TRUE
,UI4
,0xffffffff,I4
,0);
3613 VARXOR(BOOL
,VARIANT_TRUE
,UI4
,0,I4
,-1);
3614 VARXOR(BOOL
,VARIANT_FALSE
,UI4
,0,I4
,0);
3615 VARXOR(BOOL
,VARIANT_TRUE
,R4
,-1,I4
,0);
3616 VARXOR(BOOL
,VARIANT_TRUE
,R4
,0,I4
,-1);
3617 VARXOR(BOOL
,VARIANT_FALSE
,R4
,0,I4
,0);
3618 VARXOR(BOOL
,VARIANT_TRUE
,R8
,-1,I4
,0);
3619 VARXOR(BOOL
,VARIANT_TRUE
,R8
,0,I4
,-1);
3620 VARXOR(BOOL
,VARIANT_FALSE
,R8
,0,I4
,0);
3621 VARXOR(BOOL
,VARIANT_TRUE
,DATE
,-1,I4
,0);
3622 VARXOR(BOOL
,VARIANT_TRUE
,DATE
,0,I4
,-1);
3623 VARXOR(BOOL
,VARIANT_FALSE
,DATE
,0,I4
,0);
3626 VARXOR(BOOL
,VARIANT_TRUE
,I8
,-1,I8
,0);
3627 VARXOR(BOOL
,VARIANT_TRUE
,I8
,0,I8
,-1);
3628 VARXOR(BOOL
,VARIANT_FALSE
,I8
,0,I8
,0);
3629 /* This returns DISP_E_OVERFLOW which indicates that a conversion
3630 * to I4 is performed.
3632 /* VARXOR(BOOL,VARIANT_TRUE,UI8,-1,I4,-1); */
3633 VARXOR(BOOL
,VARIANT_TRUE
,UI8
,0,I4
,-1);
3634 VARXOR(BOOL
,VARIANT_FALSE
,UI8
,0,I4
,0);
3636 VARXOR(BOOL
,VARIANT_TRUE
,INT
,-1,I4
,0);
3637 VARXOR(BOOL
,VARIANT_TRUE
,INT
,0,I4
,-1);
3638 VARXOR(BOOL
,VARIANT_FALSE
,INT
,0,I4
,0);
3639 VARXOR(BOOL
,VARIANT_TRUE
,UINT
,0xffffffff,I4
,0);
3640 VARXOR(BOOL
,VARIANT_TRUE
,UINT
,0,I4
,-1);
3641 VARXOR(BOOL
,VARIANT_FALSE
,UINT
,0,I4
,0);
3642 rbstr
= SysAllocString(szFalse
);
3643 VARXOR(BOOL
,VARIANT_FALSE
,BSTR
,rbstr
,BOOL
,VARIANT_FALSE
);
3644 VARXOR(BOOL
,VARIANT_TRUE
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
3645 SysFreeString(rbstr
);
3646 rbstr
= SysAllocString(szTrue
);
3647 VARXOR(BOOL
,VARIANT_FALSE
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
3648 VARXOR(BOOL
,VARIANT_TRUE
,BSTR
,rbstr
,BOOL
,VARIANT_FALSE
);
3649 SysFreeString(rbstr
);
3650 VARXORCY(BOOL
,VARIANT_TRUE
,10000,I4
,-2);
3651 VARXORCY(BOOL
,VARIANT_TRUE
,0,I4
,-1);
3652 VARXORCY(BOOL
,VARIANT_FALSE
,0,I4
,0);
3654 VARXOR(I1
,-1,I1
,-1,I4
,0);
3655 VARXOR(I1
,-1,I1
,0,I4
,-1);
3656 VARXOR(I1
,0,I1
,0,I4
,0);
3657 VARXOR(I1
,-1,UI1
,255,I4
,-256);
3658 VARXOR(I1
,-1,UI1
,0,I4
,-1);
3659 VARXOR(I1
,0,UI1
,0,I4
,0);
3660 VARXOR(I1
,-1,I2
,-1,I4
,0);
3661 VARXOR(I1
,-1,I2
,0,I4
,-1);
3662 VARXOR(I1
,0,I2
,0,I4
,0);
3663 VARXOR(I1
,-1,UI2
,65535,I4
,-65536);
3664 VARXOR(I1
,-1,UI2
,0,I4
,-1);
3665 VARXOR(I1
,0,UI2
,0,I4
,0);
3666 VARXOR(I1
,-1,I4
,-1,I4
,0);
3667 VARXOR(I1
,-1,I4
,0,I4
,-1);
3668 VARXOR(I1
,0,I4
,0,I4
,0);
3669 VARXOR(I1
,-1,UI4
,0xffffffff,I4
,0);
3670 VARXOR(I1
,-1,UI4
,0,I4
,-1);
3671 VARXOR(I1
,0,UI4
,0,I4
,0);
3672 VARXOR(I1
,-1,R4
,-1,I4
,0);
3673 VARXOR(I1
,-1,R4
,0,I4
,-1);
3674 VARXOR(I1
,0,R4
,0,I4
,0);
3675 VARXOR(I1
,-1,R8
,-1,I4
,0);
3676 VARXOR(I1
,-1,R8
,0,I4
,-1);
3677 VARXOR(I1
,0,R8
,0,I4
,0);
3678 VARXOR(I1
,-1,DATE
,-1,I4
,0);
3679 VARXOR(I1
,-1,DATE
,0,I4
,-1);
3680 VARXOR(I1
,0,DATE
,0,I4
,0);
3683 VARXOR(I1
,-1,I8
,-1,I8
,0);
3684 VARXOR(I1
,-1,I8
,0,I8
,-1);
3685 VARXOR(I1
,0,I8
,0,I8
,0);
3686 VARXOR(I1
,-1,UI8
,0,I4
,-1);
3687 VARXOR(I1
,0,UI8
,0,I4
,0);
3689 VARXOR(I1
,-1,INT
,-1,I4
,0);
3690 VARXOR(I1
,-1,INT
,0,I4
,-1);
3691 VARXOR(I1
,0,INT
,0,I4
,0);
3692 VARXOR(I1
,-1,UINT
,0xffffffff,I4
,0);
3693 VARXOR(I1
,-1,UINT
,0,I4
,-1);
3694 VARXOR(I1
,0,UINT
,0,I4
,0);
3695 rbstr
= SysAllocString(szFalse
);
3696 VARXOR(I1
,0,BSTR
,rbstr
,I4
,0);
3697 VARXOR(I1
,-1,BSTR
,rbstr
,I4
,-1);
3698 SysFreeString(rbstr
);
3699 rbstr
= SysAllocString(szTrue
);
3700 VARXOR(I1
,0,BSTR
,rbstr
,I4
,-1);
3701 VARXOR(I1
,-1,BSTR
,rbstr
,I4
,0);
3702 SysFreeString(rbstr
);
3703 VARXORCY(I1
,-1,10000,I4
,-2);
3704 VARXORCY(I1
,-1,0,I4
,-1);
3705 VARXORCY(I1
,0,0,I4
,0);
3707 VARXOR(UI1
,255,UI1
,255,UI1
,0);
3708 VARXOR(UI1
,255,UI1
,0,UI1
,255);
3709 VARXOR(UI1
,0,UI1
,0,UI1
,0);
3710 VARXOR(UI1
,255,I2
,-1,I2
,-256);
3711 VARXOR(UI1
,255,I2
,0,I2
,255);
3712 VARXOR(UI1
,0,I2
,0,I2
,0);
3713 VARXOR(UI1
,255,UI2
,65535,I4
,65280);
3714 VARXOR(UI1
,255,UI2
,0,I4
,255);
3715 VARXOR(UI1
,0,UI2
,0,I4
,0);
3716 VARXOR(UI1
,255,I4
,-1,I4
,-256);
3717 VARXOR(UI1
,255,I4
,0,I4
,255);
3718 VARXOR(UI1
,0,I4
,0,I4
,0);
3719 VARXOR(UI1
,255,UI4
,0xffffffff,I4
,-256);
3720 VARXOR(UI1
,255,UI4
,0,I4
,255);
3721 VARXOR(UI1
,0,UI4
,0,I4
,0);
3722 VARXOR(UI1
,255,R4
,-1,I4
,-256);
3723 VARXOR(UI1
,255,R4
,0,I4
,255);
3724 VARXOR(UI1
,0,R4
,0,I4
,0);
3725 VARXOR(UI1
,255,R8
,-1,I4
,-256);
3726 VARXOR(UI1
,255,R8
,0,I4
,255);
3727 VARXOR(UI1
,0,R8
,0,I4
,0);
3728 VARXOR(UI1
,255,DATE
,-1,I4
,-256);
3729 VARXOR(UI1
,255,DATE
,0,I4
,255);
3730 VARXOR(UI1
,0,DATE
,0,I4
,0);
3733 VARXOR(UI1
,255,I8
,-1,I8
,-256);
3734 VARXOR(UI1
,255,I8
,0,I8
,255);
3735 VARXOR(UI1
,0,I8
,0,I8
,0);
3736 VARXOR(UI1
,255,UI8
,0,I4
,255);
3737 VARXOR(UI1
,0,UI8
,0,I4
,0);
3739 VARXOR(UI1
,255,INT
,-1,I4
,-256);
3740 VARXOR(UI1
,255,INT
,0,I4
,255);
3741 VARXOR(UI1
,0,INT
,0,I4
,0);
3742 VARXOR(UI1
,255,UINT
,0xffffffff,I4
,-256);
3743 VARXOR(UI1
,255,UINT
,0,I4
,255);
3744 VARXOR(UI1
,0,UINT
,0,I4
,0);
3745 rbstr
= SysAllocString(szFalse
);
3746 VARXOR(UI1
,0,BSTR
,rbstr
,I2
,0);
3747 VARXOR(UI1
,255,BSTR
,rbstr
,I2
,255);
3748 SysFreeString(rbstr
);
3749 rbstr
= SysAllocString(szTrue
);
3750 VARXOR(UI1
,0,BSTR
,rbstr
,I2
,-1);
3751 VARXOR(UI1
,255,BSTR
,rbstr
,I2
,-256);
3752 SysFreeString(rbstr
);
3753 VARXORCY(UI1
,255,10000,I4
,254);
3754 VARXORCY(UI1
,255,0,I4
,255);
3755 VARXORCY(UI1
,0,0,I4
,0);
3757 VARXOR(I2
,-1,I2
,-1,I2
,0);
3758 VARXOR(I2
,-1,I2
,0,I2
,-1);
3759 VARXOR(I2
,0,I2
,0,I2
,0);
3760 VARXOR(I2
,-1,UI2
,65535,I4
,-65536);
3761 VARXOR(I2
,-1,UI2
,0,I4
,-1);
3762 VARXOR(I2
,0,UI2
,0,I4
,0);
3763 VARXOR(I2
,-1,I4
,-1,I4
,0);
3764 VARXOR(I2
,-1,I4
,0,I4
,-1);
3765 VARXOR(I2
,0,I4
,0,I4
,0);
3766 VARXOR(I2
,-1,UI4
,0xffffffff,I4
,0);
3767 VARXOR(I2
,-1,UI4
,0,I4
,-1);
3768 VARXOR(I2
,0,UI4
,0,I4
,0);
3769 VARXOR(I2
,-1,R4
,-1,I4
,0);
3770 VARXOR(I2
,-1,R4
,0,I4
,-1);
3771 VARXOR(I2
,0,R4
,0,I4
,0);
3772 VARXOR(I2
,-1,R8
,-1,I4
,0);
3773 VARXOR(I2
,-1,R8
,0,I4
,-1);
3774 VARXOR(I2
,0,R8
,0,I4
,0);
3775 VARXOR(I2
,-1,DATE
,-1,I4
,0);
3776 VARXOR(I2
,-1,DATE
,0,I4
,-1);
3777 VARXOR(I2
,0,DATE
,0,I4
,0);
3780 VARXOR(I2
,-1,I8
,-1,I8
,0);
3781 VARXOR(I2
,-1,I8
,0,I8
,-1);
3782 VARXOR(I2
,0,I8
,0,I8
,0);
3783 VARXOR(I2
,-1,UI8
,0,I4
,-1);
3784 VARXOR(I2
,0,UI8
,0,I4
,0);
3786 VARXOR(I2
,-1,INT
,-1,I4
,0);
3787 VARXOR(I2
,-1,INT
,0,I4
,-1);
3788 VARXOR(I2
,0,INT
,0,I4
,0);
3789 VARXOR(I2
,-1,UINT
,0xffffffff,I4
,0);
3790 VARXOR(I2
,-1,UINT
,0,I4
,-1);
3791 VARXOR(I2
,0,UINT
,0,I4
,0);
3792 rbstr
= SysAllocString(szFalse
);
3793 VARXOR(I2
,0,BSTR
,rbstr
,I2
,0);
3794 VARXOR(I2
,-1,BSTR
,rbstr
,I2
,-1);
3795 SysFreeString(rbstr
);
3796 rbstr
= SysAllocString(szTrue
);
3797 VARXOR(I2
,0,BSTR
,rbstr
,I2
,-1);
3798 VARXOR(I2
,-1,BSTR
,rbstr
,I2
,0);
3799 SysFreeString(rbstr
);
3800 VARXORCY(I2
,-1,10000,I4
,-2);
3801 VARXORCY(I2
,-1,0,I4
,-1);
3802 VARXORCY(I2
,0,0,I4
,0);
3804 VARXOR(UI2
,65535,UI2
,65535,I4
,0);
3805 VARXOR(UI2
,65535,UI2
,0,I4
,65535);
3806 VARXOR(UI2
,0,UI2
,0,I4
,0);
3807 VARXOR(UI2
,65535,I4
,-1,I4
,-65536);
3808 VARXOR(UI2
,65535,I4
,0,I4
,65535);
3809 VARXOR(UI2
,0,I4
,0,I4
,0);
3810 VARXOR(UI2
,65535,UI4
,0xffffffff,I4
,-65536);
3811 VARXOR(UI2
,65535,UI4
,0,I4
,65535);
3812 VARXOR(UI2
,0,UI4
,0,I4
,0);
3813 VARXOR(UI2
,65535,R4
,-1,I4
,-65536);
3814 VARXOR(UI2
,65535,R4
,0,I4
,65535);
3815 VARXOR(UI2
,0,R4
,0,I4
,0);
3816 VARXOR(UI2
,65535,R8
,-1,I4
,-65536);
3817 VARXOR(UI2
,65535,R8
,0,I4
,65535);
3818 VARXOR(UI2
,0,R8
,0,I4
,0);
3819 VARXOR(UI2
,65535,DATE
,-1,I4
,-65536);
3820 VARXOR(UI2
,65535,DATE
,0,I4
,65535);
3821 VARXOR(UI2
,0,DATE
,0,I4
,0);
3824 VARXOR(UI2
,65535,I8
,-1,I8
,-65536);
3825 VARXOR(UI2
,65535,I8
,0,I8
,65535);
3826 VARXOR(UI2
,0,I8
,0,I8
,0);
3827 VARXOR(UI2
,65535,UI8
,0,I4
,65535);
3828 VARXOR(UI2
,0,UI8
,0,I4
,0);
3830 VARXOR(UI2
,65535,INT
,-1,I4
,-65536);
3831 VARXOR(UI2
,65535,INT
,0,I4
,65535);
3832 VARXOR(UI2
,0,INT
,0,I4
,0);
3833 VARXOR(UI2
,65535,UINT
,0xffffffff,I4
,-65536);
3834 VARXOR(UI2
,65535,UINT
,0,I4
,65535);
3835 VARXOR(UI2
,0,UINT
,0,I4
,0);
3836 rbstr
= SysAllocString(szFalse
);
3837 VARXOR(UI2
,0,BSTR
,rbstr
,I4
,0);
3838 VARXOR(UI2
,65535,BSTR
,rbstr
,I4
,65535);
3839 SysFreeString(rbstr
);
3840 rbstr
= SysAllocString(szTrue
);
3841 VARXOR(UI2
,0,BSTR
,rbstr
,I4
,-1);
3842 VARXOR(UI2
,65535,BSTR
,rbstr
,I4
,-65536);
3843 SysFreeString(rbstr
);
3844 VARXORCY(UI2
,65535,10000,I4
,65534);
3845 VARXORCY(UI2
,65535,0,I4
,65535);
3846 VARXORCY(UI2
,0,0,I4
,0);
3848 VARXOR(I4
,-1,I4
,-1,I4
,0);
3849 VARXOR(I4
,-1,I4
,0,I4
,-1);
3850 VARXOR(I4
,0,I4
,0,I4
,0);
3851 VARXOR(I4
,-1,UI4
,0xffffffff,I4
,0);
3852 VARXOR(I4
,-1,UI4
,0,I4
,-1);
3853 VARXOR(I4
,0,UI4
,0,I4
,0);
3854 VARXOR(I4
,-1,R4
,-1,I4
,0);
3855 VARXOR(I4
,-1,R4
,0,I4
,-1);
3856 VARXOR(I4
,0,R4
,0,I4
,0);
3857 VARXOR(I4
,-1,R8
,-1,I4
,0);
3858 VARXOR(I4
,-1,R8
,0,I4
,-1);
3859 VARXOR(I4
,0,R8
,0,I4
,0);
3860 VARXOR(I4
,-1,DATE
,-1,I4
,0);
3861 VARXOR(I4
,-1,DATE
,0,I4
,-1);
3862 VARXOR(I4
,0,DATE
,0,I4
,0);
3865 VARXOR(I4
,-1,I8
,-1,I8
,0);
3866 VARXOR(I4
,-1,I8
,0,I8
,-1);
3867 VARXOR(I4
,0,I8
,0,I8
,0);
3868 VARXOR(I4
,-1,UI8
,0,I4
,-1);
3869 VARXOR(I4
,0,UI8
,0,I4
,0);
3871 VARXOR(I4
,-1,INT
,-1,I4
,0);
3872 VARXOR(I4
,-1,INT
,0,I4
,-1);
3873 VARXOR(I4
,0,INT
,0,I4
,0);
3874 VARXOR(I4
,-1,UINT
,0xffffffff,I4
,0);
3875 VARXOR(I4
,-1,UINT
,0,I4
,-1);
3876 VARXOR(I4
,0,UINT
,0,I4
,0);
3877 rbstr
= SysAllocString(szFalse
);
3878 VARXOR(I4
,0,BSTR
,rbstr
,I4
,0);
3879 VARXOR(I4
,-1,BSTR
,rbstr
,I4
,-1);
3880 SysFreeString(rbstr
);
3881 rbstr
= SysAllocString(szTrue
);
3882 VARXOR(I4
,0,BSTR
,rbstr
,I4
,-1);
3883 VARXOR(I4
,-1,BSTR
,rbstr
,I4
,0);
3884 SysFreeString(rbstr
);
3885 VARXORCY(I4
,-1,10000,I4
,-2);
3886 VARXORCY(I4
,-1,0,I4
,-1);
3887 VARXORCY(I4
,0,0,I4
,0);
3889 VARXOR(UI4
,0xffffffff,UI4
,0xffffffff,I4
,0);
3890 VARXOR(UI4
,0xffffffff,UI4
,0,I4
,-1);
3891 VARXOR(UI4
,0,UI4
,0,I4
,0);
3892 VARXOR(UI4
,0xffffffff,R4
,-1,I4
,0);
3893 VARXOR(UI4
,0xffffffff,R4
,0,I4
,-1);
3894 VARXOR(UI4
,0,R4
,0,I4
,0);
3895 VARXOR(UI4
,0xffffffff,R8
,-1,I4
,0);
3896 VARXOR(UI4
,0xffffffff,R8
,0,I4
,-1);
3897 VARXOR(UI4
,0,R8
,0,I4
,0);
3898 VARXOR(UI4
,0xffffffff,DATE
,-1,I4
,0);
3899 VARXOR(UI4
,0xffffffff,DATE
,0,I4
,-1);
3900 VARXOR(UI4
,0,DATE
,0,I4
,0);
3903 VARXOR(UI4
,0xffffffff,I8
,0,I8
,0xffffffff);
3904 VARXOR(UI4
,VARIANT_FALSE
,I8
,VARIANT_FALSE
,I8
,0);
3905 VARXOR(UI4
,0,I8
,0,I8
,0);
3906 VARXOR(UI4
,0xffffffff,UI8
,0,I4
,-1);
3907 VARXOR(UI4
,0,UI8
,0,I4
,0);
3909 VARXOR(UI4
,0xffffffff,INT
,-1,I4
,0);
3910 VARXOR(UI4
,0xffffffff,INT
,0,I4
,-1);
3911 VARXOR(UI4
,0,INT
,0,I4
,0);
3912 VARXOR(UI4
,0xffffffff,UINT
,0xffffffff,I4
,0);
3913 VARXOR(UI4
,0xffffffff,UINT
,0,I4
,-1);
3914 VARXOR(UI4
,0,UINT
,0,I4
,0);
3915 rbstr
= SysAllocString(szFalse
);
3916 VARXOR(UI4
,0,BSTR
,rbstr
,I4
,0);
3917 VARXOR(UI4
,0xffffffff,BSTR
,rbstr
,I4
,-1);
3918 SysFreeString(rbstr
);
3919 rbstr
= SysAllocString(szTrue
);
3920 VARXOR(UI4
,0,BSTR
,rbstr
,I4
,-1);
3921 VARXOR(UI4
,0xffffffff,BSTR
,rbstr
,I4
,0);
3922 SysFreeString(rbstr
);
3923 VARXORCY(UI4
,0xffffffff,10000,I4
,-2);
3924 VARXORCY(UI4
,0xffffffff,0,I4
,-1);
3925 VARXORCY(UI4
,0,0,I4
,0);
3927 VARXOR(R4
,-1,R4
,-1,I4
,0);
3928 VARXOR(R4
,-1,R4
,0,I4
,-1);
3929 VARXOR(R4
,0,R4
,0,I4
,0);
3930 VARXOR(R4
,-1,R8
,-1,I4
,0);
3931 VARXOR(R4
,-1,R8
,0,I4
,-1);
3932 VARXOR(R4
,0,R8
,0,I4
,0);
3933 VARXOR(R4
,-1,DATE
,-1,I4
,0);
3934 VARXOR(R4
,-1,DATE
,0,I4
,-1);
3935 VARXOR(R4
,0,DATE
,0,I4
,0);
3938 VARXOR(R4
,-1,I8
,-1,I8
,0);
3939 VARXOR(R4
,-1,I8
,0,I8
,-1);
3940 VARXOR(R4
,0,I8
,0,I8
,0);
3941 VARXOR(R4
,-1,UI8
,0,I4
,-1);
3942 VARXOR(R4
,0,UI8
,0,I4
,0);
3944 VARXOR(R4
,-1,INT
,-1,I4
,0);
3945 VARXOR(R4
,-1,INT
,0,I4
,-1);
3946 VARXOR(R4
,0,INT
,0,I4
,0);
3947 VARXOR(R4
,-1,UINT
,0xffffffff,I4
,0);
3948 VARXOR(R4
,-1,UINT
,0,I4
,-1);
3949 VARXOR(R4
,0,UINT
,0,I4
,0);
3950 rbstr
= SysAllocString(szFalse
);
3951 VARXOR(R4
,0,BSTR
,rbstr
,I4
,0);
3952 VARXOR(R4
,-1,BSTR
,rbstr
,I4
,-1);
3953 SysFreeString(rbstr
);
3954 rbstr
= SysAllocString(szTrue
);
3955 VARXOR(R4
,0,BSTR
,rbstr
,I4
,-1);
3956 VARXOR(R4
,-1,BSTR
,rbstr
,I4
,0);
3957 SysFreeString(rbstr
);
3958 VARXORCY(R4
,-1,10000,I4
,-2);
3959 VARXORCY(R4
,-1,0,I4
,-1);
3960 VARXORCY(R4
,0,0,I4
,0);
3962 VARXOR(R8
,-1,R8
,-1,I4
,0);
3963 VARXOR(R8
,-1,R8
,0,I4
,-1);
3964 VARXOR(R8
,0,R8
,0,I4
,0);
3965 VARXOR(R8
,-1,DATE
,-1,I4
,0);
3966 VARXOR(R8
,-1,DATE
,0,I4
,-1);
3967 VARXOR(R8
,0,DATE
,0,I4
,0);
3970 VARXOR(R8
,-1,I8
,-1,I8
,0);
3971 VARXOR(R8
,-1,I8
,0,I8
,-1);
3972 VARXOR(R8
,0,I8
,0,I8
,0);
3973 VARXOR(R8
,-1,UI8
,0,I4
,-1);
3974 VARXOR(R8
,0,UI8
,0,I4
,0);
3976 VARXOR(R8
,-1,INT
,-1,I4
,0);
3977 VARXOR(R8
,-1,INT
,0,I4
,-1);
3978 VARXOR(R8
,0,INT
,0,I4
,0);
3979 VARXOR(R8
,-1,UINT
,0xffffffff,I4
,0);
3980 VARXOR(R8
,-1,UINT
,0,I4
,-1);
3981 VARXOR(R8
,0,UINT
,0,I4
,0);
3982 rbstr
= SysAllocString(szFalse
);
3983 VARXOR(R8
,0,BSTR
,rbstr
,I4
,0);
3984 VARXOR(R8
,-1,BSTR
,rbstr
,I4
,-1);
3985 SysFreeString(rbstr
);
3986 rbstr
= SysAllocString(szTrue
);
3987 VARXOR(R8
,0,BSTR
,rbstr
,I4
,-1);
3988 VARXOR(R8
,-1,BSTR
,rbstr
,I4
,0);
3989 SysFreeString(rbstr
);
3990 VARXORCY(R8
,-1,10000,I4
,-2);
3991 VARXORCY(R8
,-1,0,I4
,-1);
3992 VARXORCY(R8
,0,0,I4
,0);
3994 VARXOR(DATE
,-1,DATE
,-1,I4
,0);
3995 VARXOR(DATE
,-1,DATE
,0,I4
,-1);
3996 VARXOR(DATE
,0,DATE
,0,I4
,0);
3999 VARXOR(DATE
,-1,I8
,-1,I8
,0);
4000 VARXOR(DATE
,-1,I8
,0,I8
,-1);
4001 VARXOR(DATE
,0,I8
,0,I8
,0);
4002 VARXOR(DATE
,-1,UI8
,0,I4
,-1);
4003 VARXOR(DATE
,0,UI8
,0,I4
,0);
4005 VARXOR(DATE
,-1,INT
,-1,I4
,0);
4006 VARXOR(DATE
,-1,INT
,0,I4
,-1);
4007 VARXOR(DATE
,0,INT
,0,I4
,0);
4008 VARXOR(DATE
,-1,UINT
,0xffffffff,I4
,0);
4009 VARXOR(DATE
,-1,UINT
,0,I4
,-1);
4010 VARXOR(DATE
,0,UINT
,0,I4
,0);
4011 rbstr
= SysAllocString(szFalse
);
4012 VARXOR(DATE
,0,BSTR
,rbstr
,I4
,0);
4013 VARXOR(DATE
,-1,BSTR
,rbstr
,I4
,-1);
4014 SysFreeString(rbstr
);
4015 rbstr
= SysAllocString(szTrue
);
4016 VARXOR(DATE
,0,BSTR
,rbstr
,I4
,-1);
4017 VARXOR(DATE
,-1,BSTR
,rbstr
,I4
,0);
4018 SysFreeString(rbstr
);
4019 VARXORCY(DATE
,-1,10000,I4
,-2);
4020 VARXORCY(DATE
,-1,0,I4
,-1);
4021 VARXORCY(DATE
,0,0,I4
,0);
4025 VARXOR(I8
,-1,I8
,-1,I8
,0);
4026 VARXOR(I8
,-1,I8
,0,I8
,-1);
4027 VARXOR(I8
,0,I8
,0,I8
,0);
4028 VARXOR(I8
,-1,UI8
,0,I8
,-1);
4029 VARXOR(I8
,0,UI8
,0,I8
,0);
4030 VARXOR(I8
,-1,UINT
,0,I8
,-1);
4031 VARXOR(I8
,0,UINT
,0,I8
,0);
4032 rbstr
= SysAllocString(szFalse
);
4033 VARXOR(I8
,0,BSTR
,rbstr
,I8
,0);
4034 VARXOR(I8
,-1,BSTR
,rbstr
,I8
,-1);
4035 SysFreeString(rbstr
);
4036 rbstr
= SysAllocString(szTrue
);
4037 VARXOR(I8
,0,BSTR
,rbstr
,I8
,-1);
4038 VARXOR(I8
,-1,BSTR
,rbstr
,I8
,0);
4039 SysFreeString(rbstr
);
4040 VARXORCY(I8
,-1,10000,I8
,-2);
4041 VARXORCY(I8
,-1,0,I8
,-1);
4042 VARXORCY(I8
,0,0,I8
,0);
4044 VARXOR(UI8
,0xffff,UI8
,0xffff,I4
,0);
4045 VARXOR(UI8
,0xffff,UI8
,0,I4
,0xffff);
4046 VARXOR(UI8
,0,UI8
,0,I4
,0);
4047 VARXOR(UI8
,0xffff,INT
,-1,I4
,-65536);
4048 VARXOR(UI8
,0xffff,INT
,0,I4
,0xffff);
4049 VARXOR(UI8
,0,INT
,0,I4
,0);
4050 VARXOR(UI8
,0xffff,UINT
,0xffff,I4
,0);
4051 VARXOR(UI8
,0xffff,UINT
,0,I4
,0xffff);
4052 VARXOR(UI8
,0,UINT
,0,I4
,0);
4053 rbstr
= SysAllocString(szFalse
);
4054 VARXOR(UI8
,0,BSTR
,rbstr
,I4
,0);
4055 VARXOR(UI8
,0xffff,BSTR
,rbstr
,I4
,0xffff);
4056 SysFreeString(rbstr
);
4057 rbstr
= SysAllocString(szTrue
);
4058 VARXOR(UI8
,0,BSTR
,rbstr
,I4
,-1);
4059 VARXOR(UI8
,0xffff,BSTR
,rbstr
,I4
,-65536);
4060 SysFreeString(rbstr
);
4061 VARXORCY(UI8
,0xffff,10000,I4
,65534);
4062 VARXORCY(UI8
,0xffff,0,I4
,0xffff);
4063 VARXORCY(UI8
,0,0,I4
,0);
4066 VARXOR(INT
,-1,INT
,-1,I4
,0);
4067 VARXOR(INT
,-1,INT
,0,I4
,-1);
4068 VARXOR(INT
,0,INT
,0,I4
,0);
4069 VARXOR(INT
,-1,UINT
,0xffff,I4
,-65536);
4070 VARXOR(INT
,-1,UINT
,0,I4
,-1);
4071 VARXOR(INT
,0,UINT
,0,I4
,0);
4072 rbstr
= SysAllocString(szFalse
);
4073 VARXOR(INT
,0,BSTR
,rbstr
,I4
,0);
4074 VARXOR(INT
,-1,BSTR
,rbstr
,I4
,-1);
4075 SysFreeString(rbstr
);
4076 rbstr
= SysAllocString(szTrue
);
4077 VARXOR(INT
,0,BSTR
,rbstr
,I4
,-1);
4078 VARXOR(INT
,-1,BSTR
,rbstr
,I4
,0);
4079 SysFreeString(rbstr
);
4080 VARXORCY(INT
,-1,10000,I4
,-2);
4081 VARXORCY(INT
,-1,0,I4
,-1);
4082 VARXORCY(INT
,0,0,I4
,0);
4084 VARXOR(UINT
,0xffff,UINT
,0xffff,I4
,0);
4085 VARXOR(UINT
,0xffff,UINT
,0,I4
,0xffff);
4086 VARXOR(UINT
,0,UINT
,0,I4
,0);
4087 rbstr
= SysAllocString(szFalse
);
4088 VARXOR(UINT
,0,BSTR
,rbstr
,I4
,0);
4089 VARXOR(UINT
,0xffff,BSTR
,rbstr
,I4
,0xffff);
4090 SysFreeString(rbstr
);
4091 rbstr
= SysAllocString(szTrue
);
4092 VARXOR(UINT
,0,BSTR
,rbstr
,I4
,-1);
4093 VARXOR(UINT
,0xffff,BSTR
,rbstr
,I4
,-65536);
4094 SysFreeString(rbstr
);
4095 VARXORCY(UINT
,0xffff,10000,I4
,65534);
4096 VARXORCY(UINT
,0xffff,0,I4
,0xffff);
4097 VARXORCY(UINT
,0,0,I4
,0);
4099 lbstr
= SysAllocString(szFalse
);
4100 rbstr
= SysAllocString(szFalse
);
4101 VARXOR(BSTR
,lbstr
,BSTR
,rbstr
,BOOL
,0);
4102 SysFreeString(rbstr
);
4103 rbstr
= SysAllocString(szTrue
);
4104 VARXOR(BSTR
,lbstr
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
4105 SysFreeString(lbstr
);
4106 lbstr
= SysAllocString(szTrue
);
4107 VARXOR(BSTR
,lbstr
,BSTR
,rbstr
,BOOL
,VARIANT_FALSE
);
4108 VARXORCY(BSTR
,lbstr
,10000,I4
,-2);
4109 SysFreeString(lbstr
);
4110 lbstr
= SysAllocString(szFalse
);
4111 VARXORCY(BSTR
,lbstr
,10000,I4
,1);
4112 SysFreeString(lbstr
);
4113 SysFreeString(rbstr
);
4116 static HRESULT (WINAPI
*pVarOr
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
4118 #define VAROR(vt1,val1,vt2,val2,rvt,rval) \
4119 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
4120 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
4121 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
4122 test_var_call2( __LINE__, pVarOr, &left, &right, &exp )
4124 #define VARORCY(vt1,val1,val2,rvt,rval) \
4125 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
4126 V_VT(&right) = VT_CY; V_CY(&right).int64 = val2; \
4127 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
4128 test_var_call2( __LINE__, pVarOr, &left, &right, &exp )
4130 static void test_VarOr(void)
4132 static const WCHAR szFalse
[] = { '#','F','A','L','S','E','#','\0' };
4133 static const WCHAR szTrue
[] = { '#','T','R','U','E','#','\0' };
4134 VARIANT left
, right
, exp
, result
;
4141 /* Test all possible flag/vt combinations & the resulting vt type */
4142 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
4144 VARTYPE leftvt
, rightvt
, resvt
;
4146 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
4151 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
4157 if (leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
||
4158 leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
||
4159 leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
)
4162 memset(&left
, 0, sizeof(left
));
4163 memset(&right
, 0, sizeof(right
));
4164 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
4165 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
4166 V_VT(&result
) = VT_EMPTY
;
4169 if (ExtraFlags
[i
] & VT_ARRAY
|| ExtraFlags
[i
] & VT_BYREF
||
4170 !IsValidVariantClearVT(leftvt
, ExtraFlags
[i
]) ||
4171 !IsValidVariantClearVT(rightvt
, ExtraFlags
[i
]) ||
4172 leftvt
== VT_CLSID
|| rightvt
== VT_CLSID
||
4173 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
||
4174 leftvt
== VT_VARIANT
|| rightvt
== VT_VARIANT
||
4175 leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
)
4179 if (leftvt
== VT_EMPTY
|| rightvt
== VT_EMPTY
)
4181 if (leftvt
== rightvt
||
4182 leftvt
== VT_I2
|| rightvt
== VT_I2
||
4183 leftvt
== VT_UI1
|| rightvt
== VT_UI1
||
4184 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
4186 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
4188 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
4191 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
4195 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
4197 if (leftvt
== rightvt
)
4199 else if (leftvt
== rightvt
||
4200 leftvt
== VT_I2
|| rightvt
== VT_I2
||
4201 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
4205 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
4208 else if (leftvt
== VT_I2
|| rightvt
== VT_I2
)
4210 if (leftvt
== rightvt
||
4211 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
4213 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
4216 else if (leftvt
== VT_BOOL
&& rightvt
== VT_BOOL
)
4220 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
4222 if (leftvt
== VT_INT
|| rightvt
== VT_INT
)
4227 hres
= pVarOr(&left
, &right
, &result
);
4229 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
4230 "VarOr: %d|0x%X, %d|0x%X: Expected failure, got 0x%X vt %d\n",
4231 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], hres
,
4234 ok(hres
== S_OK
&& V_VT(&result
) == resvt
,
4235 "VarOr: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%X vt %d\n",
4236 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], resvt
, hres
,
4242 /* Test returned values. Since we know the returned type is correct
4243 * and that we handle all combinations of invalid types, just check
4244 * that good type combinations produce the desired value.
4245 * FIXME: Test VT_DECIMAL/VT_DISPATCH
4247 VAROR(EMPTY
,0,EMPTY
,0,I2
,0);
4248 VAROR(EMPTY
,1,EMPTY
,0,I2
,0);
4249 VAROR(EMPTY
,0,NULL
,0,NULL
,0);
4250 VAROR(EMPTY
,0,I1
,0,I4
,0);
4251 VAROR(EMPTY
,0,I1
,1,I4
,1);
4252 VAROR(EMPTY
,0,UI1
,0,I2
,0);
4253 VAROR(EMPTY
,0,UI1
,1,I2
,1);
4254 VAROR(EMPTY
,0,I2
,0,I2
,0);
4255 VAROR(EMPTY
,0,I2
,1,I2
,1);
4256 VAROR(EMPTY
,0,UI2
,0,I4
,0);
4257 VAROR(EMPTY
,0,UI2
,1,I4
,1);
4258 VAROR(EMPTY
,0,I4
,0,I4
,0);
4259 VAROR(EMPTY
,0,I4
,1,I4
,1);
4260 VAROR(EMPTY
,0,UI4
,0,I4
,0);
4261 VAROR(EMPTY
,0,UI4
,1,I4
,1);
4264 VAROR(EMPTY
,0,I8
,0,I8
,0);
4265 VAROR(EMPTY
,0,I8
,1,I8
,1);
4266 VAROR(EMPTY
,0,UI8
,0,I4
,0);
4267 VAROR(EMPTY
,0,UI8
,1,I4
,1);
4269 VAROR(EMPTY
,0,INT
,0,I4
,0);
4270 VAROR(EMPTY
,0,INT
,1,I4
,1);
4271 VAROR(EMPTY
,0,UINT
,0,I4
,0);
4272 VAROR(EMPTY
,0,UINT
,1,I4
,1);
4273 VAROR(EMPTY
,0,BOOL
,0,I2
,0);
4274 VAROR(EMPTY
,0,BOOL
,1,I2
,1);
4275 VAROR(EMPTY
,0,R4
,0,I4
,0);
4276 VAROR(EMPTY
,0,R4
,1,I4
,1);
4277 VAROR(EMPTY
,0,R8
,0,I4
,0);
4278 VAROR(EMPTY
,0,R8
,1,I4
,1);
4279 rbstr
= SysAllocString(szFalse
);
4280 VAROR(EMPTY
,0,BSTR
,rbstr
,I2
,0);
4281 SysFreeString(rbstr
);
4282 rbstr
= SysAllocString(szTrue
);
4283 VAROR(EMPTY
,0,BSTR
,rbstr
,I2
,-1);
4284 SysFreeString(rbstr
);
4285 VARORCY(EMPTY
,0,10000,I4
,1);
4287 /* NULL OR 0 = NULL. NULL OR n = n */
4288 VAROR(NULL
,0,NULL
,0,NULL
,0);
4289 VAROR(NULL
,1,NULL
,0,NULL
,0);
4290 VAROR(NULL
,0,I1
,0,NULL
,0);
4291 VAROR(NULL
,0,I1
,1,I4
,1);
4292 VAROR(NULL
,0,UI1
,0,NULL
,0);
4293 VAROR(NULL
,0,UI1
,1,UI1
,1);
4294 VAROR(NULL
,0,I2
,0,NULL
,0);
4295 VAROR(NULL
,0,I2
,1,I2
,1);
4296 VAROR(NULL
,0,UI2
,0,NULL
,0);
4297 VAROR(NULL
,0,UI2
,1,I4
,1);
4298 VAROR(NULL
,0,I4
,0,NULL
,0);
4299 VAROR(NULL
,0,I4
,1,I4
,1);
4300 VAROR(NULL
,0,UI4
,0,NULL
,0);
4301 VAROR(NULL
,0,UI4
,1,I4
,1);
4304 VAROR(NULL
,0,I8
,0,NULL
,0);
4305 VAROR(NULL
,0,I8
,1,I8
,1);
4306 VAROR(NULL
,0,UI8
,0,NULL
,0);
4307 VAROR(NULL
,0,UI8
,1,I4
,1);
4309 VAROR(NULL
,0,INT
,0,NULL
,0);
4310 VAROR(NULL
,0,INT
,1,I4
,1);
4311 VAROR(NULL
,0,UINT
,0,NULL
,0);
4312 VAROR(NULL
,0,UINT
,1,I4
,1);
4313 VAROR(NULL
,0,BOOL
,0,NULL
,0);
4314 VAROR(NULL
,0,BOOL
,1,BOOL
,1);
4315 VAROR(NULL
,0,R4
,0,NULL
,0);
4316 VAROR(NULL
,0,R4
,1,I4
,1);
4317 VAROR(NULL
,0,R8
,0,NULL
,0);
4318 VAROR(NULL
,0,R8
,1,I4
,1);
4319 rbstr
= SysAllocString(szFalse
);
4320 VAROR(NULL
,0,BSTR
,rbstr
,NULL
,0);
4321 SysFreeString(rbstr
);
4322 rbstr
= SysAllocString(szTrue
);
4323 VAROR(NULL
,0,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
4324 SysFreeString(rbstr
);
4325 VARORCY(NULL
,0,10000,I4
,1);
4326 VARORCY(NULL
,0,0,NULL
,0);
4328 VAROR(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
);
4329 VAROR(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
);
4330 VAROR(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
);
4331 VAROR(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_FALSE
);
4332 /* Assume x,y & y,x are the same from now on to reduce the number of tests */
4333 VAROR(BOOL
,VARIANT_TRUE
,I1
,-1,I4
,-1);
4334 VAROR(BOOL
,VARIANT_TRUE
,I1
,0,I4
,-1);
4335 VAROR(BOOL
,VARIANT_FALSE
,I1
,0,I4
,0);
4336 VAROR(BOOL
,VARIANT_TRUE
,UI1
,255,I2
,-1);
4337 VAROR(BOOL
,VARIANT_TRUE
,UI1
,0,I2
,-1);
4338 VAROR(BOOL
,VARIANT_FALSE
,UI1
,0,I2
,0);
4339 VAROR(BOOL
,VARIANT_TRUE
,I2
,-1,I2
,-1);
4340 VAROR(BOOL
,VARIANT_TRUE
,I2
,0,I2
,-1);
4341 VAROR(BOOL
,VARIANT_FALSE
,I2
,0,I2
,0);
4342 VAROR(BOOL
,VARIANT_TRUE
,UI2
,65535,I4
,-1);
4343 VAROR(BOOL
,VARIANT_TRUE
,UI2
,0,I4
,-1);
4344 VAROR(BOOL
,VARIANT_FALSE
,UI2
,0,I4
,0);
4345 VAROR(BOOL
,VARIANT_TRUE
,I4
,-1,I4
,-1);
4346 VAROR(BOOL
,VARIANT_TRUE
,I4
,0,I4
,-1);
4347 VAROR(BOOL
,VARIANT_FALSE
,I4
,0,I4
,0);
4348 VAROR(BOOL
,VARIANT_TRUE
,UI4
,0xffffffff,I4
,-1);
4349 VAROR(BOOL
,VARIANT_TRUE
,UI4
,0,I4
,-1);
4350 VAROR(BOOL
,VARIANT_FALSE
,UI4
,0,I4
,0);
4351 VAROR(BOOL
,VARIANT_TRUE
,R4
,-1,I4
,-1);
4352 VAROR(BOOL
,VARIANT_TRUE
,R4
,0,I4
,-1);
4353 VAROR(BOOL
,VARIANT_FALSE
,R4
,0,I4
,0);
4354 VAROR(BOOL
,VARIANT_TRUE
,R8
,-1,I4
,-1);
4355 VAROR(BOOL
,VARIANT_TRUE
,R8
,0,I4
,-1);
4356 VAROR(BOOL
,VARIANT_FALSE
,R8
,0,I4
,0);
4357 VAROR(BOOL
,VARIANT_TRUE
,DATE
,-1,I4
,-1);
4358 VAROR(BOOL
,VARIANT_TRUE
,DATE
,0,I4
,-1);
4359 VAROR(BOOL
,VARIANT_FALSE
,DATE
,0,I4
,0);
4362 VAROR(BOOL
,VARIANT_TRUE
,I8
,-1,I8
,-1);
4363 VAROR(BOOL
,VARIANT_TRUE
,I8
,0,I8
,-1);
4364 VAROR(BOOL
,VARIANT_FALSE
,I8
,0,I8
,0);
4365 /* This returns DISP_E_OVERFLOW which indicates that a conversion
4366 * to I4 is performed.
4368 /* VAROR(BOOL,VARIANT_TRUE,UI8,-1,I4,-1); */
4369 VAROR(BOOL
,VARIANT_TRUE
,UI8
,0,I4
,-1);
4370 VAROR(BOOL
,VARIANT_FALSE
,UI8
,0,I4
,0);
4372 VAROR(BOOL
,VARIANT_TRUE
,INT
,-1,I4
,-1);
4373 VAROR(BOOL
,VARIANT_TRUE
,INT
,0,I4
,-1);
4374 VAROR(BOOL
,VARIANT_FALSE
,INT
,0,I4
,0);
4375 VAROR(BOOL
,VARIANT_TRUE
,UINT
,0xffffffff,I4
,-1);
4376 VAROR(BOOL
,VARIANT_TRUE
,UINT
,0,I4
,-1);
4377 VAROR(BOOL
,VARIANT_FALSE
,UINT
,0,I4
,0);
4378 rbstr
= SysAllocString(szFalse
);
4379 VAROR(BOOL
,VARIANT_FALSE
,BSTR
,rbstr
,BOOL
,VARIANT_FALSE
);
4380 VAROR(BOOL
,VARIANT_TRUE
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
4381 SysFreeString(rbstr
);
4382 rbstr
= SysAllocString(szTrue
);
4383 VAROR(BOOL
,VARIANT_FALSE
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
4384 VAROR(BOOL
,VARIANT_TRUE
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
4385 SysFreeString(rbstr
);
4386 VARORCY(BOOL
,VARIANT_TRUE
,10000,I4
,-1);
4387 VARORCY(BOOL
,VARIANT_TRUE
,0,I4
,-1);
4388 VARORCY(BOOL
,VARIANT_FALSE
,0,I4
,0);
4390 VAROR(I1
,-1,I1
,-1,I4
,-1);
4391 VAROR(I1
,-1,I1
,0,I4
,-1);
4392 VAROR(I1
,0,I1
,0,I4
,0);
4393 VAROR(I1
,-1,UI1
,255,I4
,-1);
4394 VAROR(I1
,-1,UI1
,0,I4
,-1);
4395 VAROR(I1
,0,UI1
,0,I4
,0);
4396 VAROR(I1
,-1,I2
,-1,I4
,-1);
4397 VAROR(I1
,-1,I2
,0,I4
,-1);
4398 VAROR(I1
,0,I2
,0,I4
,0);
4399 VAROR(I1
,-1,UI2
,65535,I4
,-1);
4400 VAROR(I1
,-1,UI2
,0,I4
,-1);
4401 VAROR(I1
,0,UI2
,0,I4
,0);
4402 VAROR(I1
,-1,I4
,-1,I4
,-1);
4403 VAROR(I1
,-1,I4
,0,I4
,-1);
4404 VAROR(I1
,0,I4
,0,I4
,0);
4405 VAROR(I1
,-1,UI4
,0xffffffff,I4
,-1);
4406 VAROR(I1
,-1,UI4
,0,I4
,-1);
4407 VAROR(I1
,0,UI4
,0,I4
,0);
4408 VAROR(I1
,-1,R4
,-1,I4
,-1);
4409 VAROR(I1
,-1,R4
,0,I4
,-1);
4410 VAROR(I1
,0,R4
,0,I4
,0);
4411 VAROR(I1
,-1,R8
,-1,I4
,-1);
4412 VAROR(I1
,-1,R8
,0,I4
,-1);
4413 VAROR(I1
,0,R8
,0,I4
,0);
4414 VAROR(I1
,-1,DATE
,-1,I4
,-1);
4415 VAROR(I1
,-1,DATE
,0,I4
,-1);
4416 VAROR(I1
,0,DATE
,0,I4
,0);
4419 VAROR(I1
,-1,I8
,-1,I8
,-1);
4420 VAROR(I1
,-1,I8
,0,I8
,-1);
4421 VAROR(I1
,0,I8
,0,I8
,0);
4422 VAROR(I1
,-1,UI8
,0,I4
,-1);
4423 VAROR(I1
,0,UI8
,0,I4
,0);
4425 VAROR(I1
,-1,INT
,-1,I4
,-1);
4426 VAROR(I1
,-1,INT
,0,I4
,-1);
4427 VAROR(I1
,0,INT
,0,I4
,0);
4428 VAROR(I1
,-1,UINT
,0xffffffff,I4
,-1);
4429 VAROR(I1
,-1,UINT
,0,I4
,-1);
4430 VAROR(I1
,0,UINT
,0,I4
,0);
4431 rbstr
= SysAllocString(szFalse
);
4432 VAROR(I1
,0,BSTR
,rbstr
,I4
,0);
4433 VAROR(I1
,-1,BSTR
,rbstr
,I4
,-1);
4434 SysFreeString(rbstr
);
4435 rbstr
= SysAllocString(szTrue
);
4436 VAROR(I1
,0,BSTR
,rbstr
,I4
,-1);
4437 VAROR(I1
,-1,BSTR
,rbstr
,I4
,-1);
4438 SysFreeString(rbstr
);
4439 VARORCY(I1
,-1,10000,I4
,-1);
4440 VARORCY(I1
,-1,0,I4
,-1);
4441 VARORCY(I1
,0,0,I4
,0);
4443 VAROR(UI1
,255,UI1
,255,UI1
,255);
4444 VAROR(UI1
,255,UI1
,0,UI1
,255);
4445 VAROR(UI1
,0,UI1
,0,UI1
,0);
4446 VAROR(UI1
,255,I2
,-1,I2
,-1);
4447 VAROR(UI1
,255,I2
,0,I2
,255);
4448 VAROR(UI1
,0,I2
,0,I2
,0);
4449 VAROR(UI1
,255,UI2
,65535,I4
,65535);
4450 VAROR(UI1
,255,UI2
,0,I4
,255);
4451 VAROR(UI1
,0,UI2
,0,I4
,0);
4452 VAROR(UI1
,255,I4
,-1,I4
,-1);
4453 VAROR(UI1
,255,I4
,0,I4
,255);
4454 VAROR(UI1
,0,I4
,0,I4
,0);
4455 VAROR(UI1
,255,UI4
,0xffffffff,I4
,-1);
4456 VAROR(UI1
,255,UI4
,0,I4
,255);
4457 VAROR(UI1
,0,UI4
,0,I4
,0);
4458 VAROR(UI1
,255,R4
,-1,I4
,-1);
4459 VAROR(UI1
,255,R4
,0,I4
,255);
4460 VAROR(UI1
,0,R4
,0,I4
,0);
4461 VAROR(UI1
,255,R8
,-1,I4
,-1);
4462 VAROR(UI1
,255,R8
,0,I4
,255);
4463 VAROR(UI1
,0,R8
,0,I4
,0);
4464 VAROR(UI1
,255,DATE
,-1,I4
,-1);
4465 VAROR(UI1
,255,DATE
,0,I4
,255);
4466 VAROR(UI1
,0,DATE
,0,I4
,0);
4469 VAROR(UI1
,255,I8
,-1,I8
,-1);
4470 VAROR(UI1
,255,I8
,0,I8
,255);
4471 VAROR(UI1
,0,I8
,0,I8
,0);
4472 VAROR(UI1
,255,UI8
,0,I4
,255);
4473 VAROR(UI1
,0,UI8
,0,I4
,0);
4475 VAROR(UI1
,255,INT
,-1,I4
,-1);
4476 VAROR(UI1
,255,INT
,0,I4
,255);
4477 VAROR(UI1
,0,INT
,0,I4
,0);
4478 VAROR(UI1
,255,UINT
,0xffffffff,I4
,-1);
4479 VAROR(UI1
,255,UINT
,0,I4
,255);
4480 VAROR(UI1
,0,UINT
,0,I4
,0);
4481 rbstr
= SysAllocString(szFalse
);
4482 VAROR(UI1
,0,BSTR
,rbstr
,I2
,0);
4483 VAROR(UI1
,255,BSTR
,rbstr
,I2
,255);
4484 SysFreeString(rbstr
);
4485 rbstr
= SysAllocString(szTrue
);
4486 VAROR(UI1
,0,BSTR
,rbstr
,I2
,-1);
4487 VAROR(UI1
,255,BSTR
,rbstr
,I2
,-1);
4488 SysFreeString(rbstr
);
4489 VARORCY(UI1
,255,10000,I4
,255);
4490 VARORCY(UI1
,255,0,I4
,255);
4491 VARORCY(UI1
,0,0,I4
,0);
4493 VAROR(I2
,-1,I2
,-1,I2
,-1);
4494 VAROR(I2
,-1,I2
,0,I2
,-1);
4495 VAROR(I2
,0,I2
,0,I2
,0);
4496 VAROR(I2
,-1,UI2
,65535,I4
,-1);
4497 VAROR(I2
,-1,UI2
,0,I4
,-1);
4498 VAROR(I2
,0,UI2
,0,I4
,0);
4499 VAROR(I2
,-1,I4
,-1,I4
,-1);
4500 VAROR(I2
,-1,I4
,0,I4
,-1);
4501 VAROR(I2
,0,I4
,0,I4
,0);
4502 VAROR(I2
,-1,UI4
,0xffffffff,I4
,-1);
4503 VAROR(I2
,-1,UI4
,0,I4
,-1);
4504 VAROR(I2
,0,UI4
,0,I4
,0);
4505 VAROR(I2
,-1,R4
,-1,I4
,-1);
4506 VAROR(I2
,-1,R4
,0,I4
,-1);
4507 VAROR(I2
,0,R4
,0,I4
,0);
4508 VAROR(I2
,-1,R8
,-1,I4
,-1);
4509 VAROR(I2
,-1,R8
,0,I4
,-1);
4510 VAROR(I2
,0,R8
,0,I4
,0);
4511 VAROR(I2
,-1,DATE
,-1,I4
,-1);
4512 VAROR(I2
,-1,DATE
,0,I4
,-1);
4513 VAROR(I2
,0,DATE
,0,I4
,0);
4516 VAROR(I2
,-1,I8
,-1,I8
,-1);
4517 VAROR(I2
,-1,I8
,0,I8
,-1);
4518 VAROR(I2
,0,I8
,0,I8
,0);
4519 VAROR(I2
,-1,UI8
,0,I4
,-1);
4520 VAROR(I2
,0,UI8
,0,I4
,0);
4522 VAROR(I2
,-1,INT
,-1,I4
,-1);
4523 VAROR(I2
,-1,INT
,0,I4
,-1);
4524 VAROR(I2
,0,INT
,0,I4
,0);
4525 VAROR(I2
,-1,UINT
,0xffffffff,I4
,-1);
4526 VAROR(I2
,-1,UINT
,0,I4
,-1);
4527 VAROR(I2
,0,UINT
,0,I4
,0);
4528 rbstr
= SysAllocString(szFalse
);
4529 VAROR(I2
,0,BSTR
,rbstr
,I2
,0);
4530 VAROR(I2
,-1,BSTR
,rbstr
,I2
,-1);
4531 SysFreeString(rbstr
);
4532 rbstr
= SysAllocString(szTrue
);
4533 VAROR(I2
,0,BSTR
,rbstr
,I2
,-1);
4534 VAROR(I2
,-1,BSTR
,rbstr
,I2
,-1);
4535 SysFreeString(rbstr
);
4536 VARORCY(I2
,-1,10000,I4
,-1);
4537 VARORCY(I2
,-1,0,I4
,-1);
4538 VARORCY(I2
,0,0,I4
,0);
4540 VAROR(UI2
,65535,UI2
,65535,I4
,65535);
4541 VAROR(UI2
,65535,UI2
,0,I4
,65535);
4542 VAROR(UI2
,0,UI2
,0,I4
,0);
4543 VAROR(UI2
,65535,I4
,-1,I4
,-1);
4544 VAROR(UI2
,65535,I4
,0,I4
,65535);
4545 VAROR(UI2
,0,I4
,0,I4
,0);
4546 VAROR(UI2
,65535,UI4
,0xffffffff,I4
,-1);
4547 VAROR(UI2
,65535,UI4
,0,I4
,65535);
4548 VAROR(UI2
,0,UI4
,0,I4
,0);
4549 VAROR(UI2
,65535,R4
,-1,I4
,-1);
4550 VAROR(UI2
,65535,R4
,0,I4
,65535);
4551 VAROR(UI2
,0,R4
,0,I4
,0);
4552 VAROR(UI2
,65535,R8
,-1,I4
,-1);
4553 VAROR(UI2
,65535,R8
,0,I4
,65535);
4554 VAROR(UI2
,0,R8
,0,I4
,0);
4555 VAROR(UI2
,65535,DATE
,-1,I4
,-1);
4556 VAROR(UI2
,65535,DATE
,0,I4
,65535);
4557 VAROR(UI2
,0,DATE
,0,I4
,0);
4560 VAROR(UI2
,65535,I8
,-1,I8
,-1);
4561 VAROR(UI2
,65535,I8
,0,I8
,65535);
4562 VAROR(UI2
,0,I8
,0,I8
,0);
4563 VAROR(UI2
,65535,UI8
,0,I4
,65535);
4564 VAROR(UI2
,0,UI8
,0,I4
,0);
4566 VAROR(UI2
,65535,INT
,-1,I4
,-1);
4567 VAROR(UI2
,65535,INT
,0,I4
,65535);
4568 VAROR(UI2
,0,INT
,0,I4
,0);
4569 VAROR(UI2
,65535,UINT
,0xffffffff,I4
,-1);
4570 VAROR(UI2
,65535,UINT
,0,I4
,65535);
4571 VAROR(UI2
,0,UINT
,0,I4
,0);
4572 rbstr
= SysAllocString(szFalse
);
4573 VAROR(UI2
,0,BSTR
,rbstr
,I4
,0);
4574 VAROR(UI2
,65535,BSTR
,rbstr
,I4
,65535);
4575 SysFreeString(rbstr
);
4576 rbstr
= SysAllocString(szTrue
);
4577 VAROR(UI2
,0,BSTR
,rbstr
,I4
,-1);
4578 VAROR(UI2
,65535,BSTR
,rbstr
,I4
,-1);
4579 SysFreeString(rbstr
);
4580 VARORCY(UI2
,65535,10000,I4
,65535);
4581 VARORCY(UI2
,65535,0,I4
,65535);
4582 VARORCY(UI2
,0,0,I4
,0);
4584 VAROR(I4
,-1,I4
,-1,I4
,-1);
4585 VAROR(I4
,-1,I4
,0,I4
,-1);
4586 VAROR(I4
,0,I4
,0,I4
,0);
4587 VAROR(I4
,-1,UI4
,0xffffffff,I4
,-1);
4588 VAROR(I4
,-1,UI4
,0,I4
,-1);
4589 VAROR(I4
,0,UI4
,0,I4
,0);
4590 VAROR(I4
,-1,R4
,-1,I4
,-1);
4591 VAROR(I4
,-1,R4
,0,I4
,-1);
4592 VAROR(I4
,0,R4
,0,I4
,0);
4593 VAROR(I4
,-1,R8
,-1,I4
,-1);
4594 VAROR(I4
,-1,R8
,0,I4
,-1);
4595 VAROR(I4
,0,R8
,0,I4
,0);
4596 VAROR(I4
,-1,DATE
,-1,I4
,-1);
4597 VAROR(I4
,-1,DATE
,0,I4
,-1);
4598 VAROR(I4
,0,DATE
,0,I4
,0);
4601 VAROR(I4
,-1,I8
,-1,I8
,-1);
4602 VAROR(I4
,-1,I8
,0,I8
,-1);
4603 VAROR(I4
,0,I8
,0,I8
,0);
4604 VAROR(I4
,-1,UI8
,0,I4
,-1);
4605 VAROR(I4
,0,UI8
,0,I4
,0);
4607 VAROR(I4
,-1,INT
,-1,I4
,-1);
4608 VAROR(I4
,-1,INT
,0,I4
,-1);
4609 VAROR(I4
,0,INT
,0,I4
,0);
4610 VAROR(I4
,-1,UINT
,0xffffffff,I4
,-1);
4611 VAROR(I4
,-1,UINT
,0,I4
,-1);
4612 VAROR(I4
,0,UINT
,0,I4
,0);
4613 rbstr
= SysAllocString(szFalse
);
4614 VAROR(I4
,0,BSTR
,rbstr
,I4
,0);
4615 VAROR(I4
,-1,BSTR
,rbstr
,I4
,-1);
4616 SysFreeString(rbstr
);
4617 rbstr
= SysAllocString(szTrue
);
4618 VAROR(I4
,0,BSTR
,rbstr
,I4
,-1);
4619 VAROR(I4
,-1,BSTR
,rbstr
,I4
,-1);
4620 SysFreeString(rbstr
);
4621 VARORCY(I4
,-1,10000,I4
,-1);
4622 VARORCY(I4
,-1,0,I4
,-1);
4623 VARORCY(I4
,0,0,I4
,0);
4625 VAROR(UI4
,0xffffffff,UI4
,0xffffffff,I4
,-1);
4626 VAROR(UI4
,0xffffffff,UI4
,0,I4
,-1);
4627 VAROR(UI4
,0,UI4
,0,I4
,0);
4628 VAROR(UI4
,0xffffffff,R4
,-1,I4
,-1);
4629 VAROR(UI4
,0xffffffff,R4
,0,I4
,-1);
4630 VAROR(UI4
,0,R4
,0,I4
,0);
4631 VAROR(UI4
,0xffffffff,R8
,-1,I4
,-1);
4632 VAROR(UI4
,0xffffffff,R8
,0,I4
,-1);
4633 VAROR(UI4
,0,R8
,0,I4
,0);
4634 VAROR(UI4
,0xffffffff,DATE
,-1,I4
,-1);
4635 VAROR(UI4
,0xffffffff,DATE
,0,I4
,-1);
4636 VAROR(UI4
,0,DATE
,0,I4
,0);
4639 VAROR(UI4
,0xffffffff,I8
,-1,I8
,-1);
4640 VAROR(UI4
,0xffffffff,I8
,0,I8
,0xffffffff);
4641 VAROR(UI4
,0,I8
,0,I8
,0);
4642 VAROR(UI4
,0xffffffff,UI8
,0,I4
,-1);
4643 VAROR(UI4
,0,UI8
,0,I4
,0);
4645 VAROR(UI4
,0xffffffff,INT
,-1,I4
,-1);
4646 VAROR(UI4
,0xffffffff,INT
,0,I4
,-1);
4647 VAROR(UI4
,0,INT
,0,I4
,0);
4648 VAROR(UI4
,0xffffffff,UINT
,0xffffffff,I4
,-1);
4649 VAROR(UI4
,0xffffffff,UINT
,0,I4
,-1);
4650 VAROR(UI4
,0,UINT
,0,I4
,0);
4651 rbstr
= SysAllocString(szFalse
);
4652 VAROR(UI4
,0,BSTR
,rbstr
,I4
,0);
4653 VAROR(UI4
,0xffffffff,BSTR
,rbstr
,I4
,-1);
4654 SysFreeString(rbstr
);
4655 rbstr
= SysAllocString(szTrue
);
4656 VAROR(UI4
,0,BSTR
,rbstr
,I4
,-1);
4657 VAROR(UI4
,0xffffffff,BSTR
,rbstr
,I4
,-1);
4658 SysFreeString(rbstr
);
4659 VARORCY(UI4
,0xffffffff,10000,I4
,-1);
4660 VARORCY(UI4
,0xffffffff,0,I4
,-1);
4661 VARORCY(UI4
,0,0,I4
,0);
4663 VAROR(R4
,-1,R4
,-1,I4
,-1);
4664 VAROR(R4
,-1,R4
,0,I4
,-1);
4665 VAROR(R4
,0,R4
,0,I4
,0);
4666 VAROR(R4
,-1,R8
,-1,I4
,-1);
4667 VAROR(R4
,-1,R8
,0,I4
,-1);
4668 VAROR(R4
,0,R8
,0,I4
,0);
4669 VAROR(R4
,-1,DATE
,-1,I4
,-1);
4670 VAROR(R4
,-1,DATE
,0,I4
,-1);
4671 VAROR(R4
,0,DATE
,0,I4
,0);
4674 VAROR(R4
,-1,I8
,-1,I8
,-1);
4675 VAROR(R4
,-1,I8
,0,I8
,-1);
4676 VAROR(R4
,0,I8
,0,I8
,0);
4677 VAROR(R4
,-1,UI8
,0,I4
,-1);
4678 VAROR(R4
,0,UI8
,0,I4
,0);
4680 VAROR(R4
,-1,INT
,-1,I4
,-1);
4681 VAROR(R4
,-1,INT
,0,I4
,-1);
4682 VAROR(R4
,0,INT
,0,I4
,0);
4683 VAROR(R4
,-1,UINT
,0xffffffff,I4
,-1);
4684 VAROR(R4
,-1,UINT
,0,I4
,-1);
4685 VAROR(R4
,0,UINT
,0,I4
,0);
4686 rbstr
= SysAllocString(szFalse
);
4687 VAROR(R4
,0,BSTR
,rbstr
,I4
,0);
4688 VAROR(R4
,-1,BSTR
,rbstr
,I4
,-1);
4689 SysFreeString(rbstr
);
4690 rbstr
= SysAllocString(szTrue
);
4691 VAROR(R4
,0,BSTR
,rbstr
,I4
,-1);
4692 VAROR(R4
,-1,BSTR
,rbstr
,I4
,-1);
4693 SysFreeString(rbstr
);
4694 VARORCY(R4
,-1,10000,I4
,-1);
4695 VARORCY(R4
,-1,0,I4
,-1);
4696 VARORCY(R4
,0,0,I4
,0);
4698 VAROR(R8
,-1,R8
,-1,I4
,-1);
4699 VAROR(R8
,-1,R8
,0,I4
,-1);
4700 VAROR(R8
,0,R8
,0,I4
,0);
4701 VAROR(R8
,-1,DATE
,-1,I4
,-1);
4702 VAROR(R8
,-1,DATE
,0,I4
,-1);
4703 VAROR(R8
,0,DATE
,0,I4
,0);
4706 VAROR(R8
,-1,I8
,-1,I8
,-1);
4707 VAROR(R8
,-1,I8
,0,I8
,-1);
4708 VAROR(R8
,0,I8
,0,I8
,0);
4709 VAROR(R8
,-1,UI8
,0,I4
,-1);
4710 VAROR(R8
,0,UI8
,0,I4
,0);
4712 VAROR(R8
,-1,INT
,-1,I4
,-1);
4713 VAROR(R8
,-1,INT
,0,I4
,-1);
4714 VAROR(R8
,0,INT
,0,I4
,0);
4715 VAROR(R8
,-1,UINT
,0xffffffff,I4
,-1);
4716 VAROR(R8
,-1,UINT
,0,I4
,-1);
4717 VAROR(R8
,0,UINT
,0,I4
,0);
4718 rbstr
= SysAllocString(szFalse
);
4719 VAROR(R8
,0,BSTR
,rbstr
,I4
,0);
4720 VAROR(R8
,-1,BSTR
,rbstr
,I4
,-1);
4721 SysFreeString(rbstr
);
4722 rbstr
= SysAllocString(szTrue
);
4723 VAROR(R8
,0,BSTR
,rbstr
,I4
,-1);
4724 VAROR(R8
,-1,BSTR
,rbstr
,I4
,-1);
4725 SysFreeString(rbstr
);
4726 VARORCY(R8
,-1,10000,I4
,-1);
4727 VARORCY(R8
,-1,0,I4
,-1);
4728 VARORCY(R8
,0,0,I4
,0);
4730 VAROR(DATE
,-1,DATE
,-1,I4
,-1);
4731 VAROR(DATE
,-1,DATE
,0,I4
,-1);
4732 VAROR(DATE
,0,DATE
,0,I4
,0);
4735 VAROR(DATE
,-1,I8
,-1,I8
,-1);
4736 VAROR(DATE
,-1,I8
,0,I8
,-1);
4737 VAROR(DATE
,0,I8
,0,I8
,0);
4738 VAROR(DATE
,-1,UI8
,0,I4
,-1);
4739 VAROR(DATE
,0,UI8
,0,I4
,0);
4741 VAROR(DATE
,-1,INT
,-1,I4
,-1);
4742 VAROR(DATE
,-1,INT
,0,I4
,-1);
4743 VAROR(DATE
,0,INT
,0,I4
,0);
4744 VAROR(DATE
,-1,UINT
,0xffffffff,I4
,-1);
4745 VAROR(DATE
,-1,UINT
,0,I4
,-1);
4746 VAROR(DATE
,0,UINT
,0,I4
,0);
4747 rbstr
= SysAllocString(szFalse
);
4748 VAROR(DATE
,0,BSTR
,rbstr
,I4
,0);
4749 VAROR(DATE
,-1,BSTR
,rbstr
,I4
,-1);
4750 SysFreeString(rbstr
);
4751 rbstr
= SysAllocString(szTrue
);
4752 VAROR(DATE
,0,BSTR
,rbstr
,I4
,-1);
4753 VAROR(DATE
,-1,BSTR
,rbstr
,I4
,-1);
4754 SysFreeString(rbstr
);
4755 VARORCY(DATE
,-1,10000,I4
,-1);
4756 VARORCY(DATE
,-1,0,I4
,-1);
4757 VARORCY(DATE
,0,0,I4
,0);
4761 VAROR(I8
,-1,I8
,-1,I8
,-1);
4762 VAROR(I8
,-1,I8
,0,I8
,-1);
4763 VAROR(I8
,0,I8
,0,I8
,0);
4764 VAROR(I8
,-1,UI8
,0,I8
,-1);
4765 VAROR(I8
,0,UI8
,0,I8
,0);
4766 /* These overflow under native and Wine
4767 VAROR(I8,-1,INT,-1,I4,-1);
4768 VAROR(I8,-1,INT,0,I4,-1);
4769 VAROR(I8,0,INT,0,I4,0); */
4770 VAROR(I8
,-1,UINT
,0xffffffff,I8
,-1);
4771 VAROR(I8
,-1,UINT
,0,I8
,-1);
4772 VAROR(I8
,0,UINT
,0,I8
,0);
4773 rbstr
= SysAllocString(szFalse
);
4774 VAROR(I8
,0,BSTR
,rbstr
,I8
,0);
4775 VAROR(I8
,-1,BSTR
,rbstr
,I8
,-1);
4776 SysFreeString(rbstr
);
4777 rbstr
= SysAllocString(szTrue
);
4778 VAROR(I8
,0,BSTR
,rbstr
,I8
,-1);
4779 VAROR(I8
,-1,BSTR
,rbstr
,I8
,-1);
4780 SysFreeString(rbstr
);
4781 VARORCY(I8
,-1,10000,I8
,-1);
4782 VARORCY(I8
,-1,0,I8
,-1);
4783 VARORCY(I8
,0,0,I8
,0);
4785 VAROR(UI8
,0xffff,UI8
,0xffff,I4
,0xffff);
4786 VAROR(UI8
,0xffff,UI8
,0,I4
,0xffff);
4787 VAROR(UI8
,0,UI8
,0,I4
,0);
4788 VAROR(UI8
,0xffff,INT
,-1,I4
,-1);
4789 VAROR(UI8
,0xffff,INT
,0,I4
,0xffff);
4790 VAROR(UI8
,0,INT
,0,I4
,0);
4791 VAROR(UI8
,0xffff,UINT
,0xffff,I4
,0xffff);
4792 VAROR(UI8
,0xffff,UINT
,0,I4
,0xffff);
4793 VAROR(UI8
,0,UINT
,0,I4
,0);
4794 rbstr
= SysAllocString(szFalse
);
4795 VAROR(UI8
,0,BSTR
,rbstr
,I4
,0);
4796 VAROR(UI8
,0xffff,BSTR
,rbstr
,I4
,0xffff);
4797 SysFreeString(rbstr
);
4798 rbstr
= SysAllocString(szTrue
);
4799 VAROR(UI8
,0,BSTR
,rbstr
,I4
,-1);
4800 VAROR(UI8
,0xffff,BSTR
,rbstr
,I4
,-1);
4801 SysFreeString(rbstr
);
4802 VARORCY(UI8
,0xffff,10000,I4
,0xffff);
4803 VARORCY(UI8
,0xffff,0,I4
,0xffff);
4804 VARORCY(UI8
,0,0,I4
,0);
4807 VAROR(INT
,-1,INT
,-1,I4
,-1);
4808 VAROR(INT
,-1,INT
,0,I4
,-1);
4809 VAROR(INT
,0,INT
,0,I4
,0);
4810 VAROR(INT
,-1,UINT
,0xffff,I4
,-1);
4811 VAROR(INT
,-1,UINT
,0,I4
,-1);
4812 VAROR(INT
,0,UINT
,0,I4
,0);
4813 rbstr
= SysAllocString(szFalse
);
4814 VAROR(INT
,0,BSTR
,rbstr
,I4
,0);
4815 VAROR(INT
,-1,BSTR
,rbstr
,I4
,-1);
4816 SysFreeString(rbstr
);
4817 rbstr
= SysAllocString(szTrue
);
4818 VAROR(INT
,0,BSTR
,rbstr
,I4
,-1);
4819 VAROR(INT
,-1,BSTR
,rbstr
,I4
,-1);
4820 SysFreeString(rbstr
);
4821 VARORCY(INT
,-1,10000,I4
,-1);
4822 VARORCY(INT
,-1,0,I4
,-1);
4823 VARORCY(INT
,0,0,I4
,0);
4825 VAROR(UINT
,0xffff,UINT
,0xffff,I4
,0xffff);
4826 VAROR(UINT
,0xffff,UINT
,0,I4
,0xffff);
4827 VAROR(UINT
,0,UINT
,0,I4
,0);
4828 rbstr
= SysAllocString(szFalse
);
4829 VAROR(UINT
,0,BSTR
,rbstr
,I4
,0);
4830 VAROR(UINT
,0xffff,BSTR
,rbstr
,I4
,0xffff);
4831 SysFreeString(rbstr
);
4832 rbstr
= SysAllocString(szTrue
);
4833 VAROR(UINT
,0,BSTR
,rbstr
,I4
,-1);
4834 VAROR(UINT
,0xffff,BSTR
,rbstr
,I4
,-1);
4835 SysFreeString(rbstr
);
4836 VARORCY(UINT
,0xffff,10000,I4
,0xffff);
4837 VARORCY(UINT
,0xffff,0,I4
,0xffff);
4838 VARORCY(UINT
,0,0,I4
,0);
4840 lbstr
= SysAllocString(szFalse
);
4841 rbstr
= SysAllocString(szFalse
);
4842 VAROR(BSTR
,lbstr
,BSTR
,rbstr
,BOOL
,0);
4843 SysFreeString(rbstr
);
4844 rbstr
= SysAllocString(szTrue
);
4845 VAROR(BSTR
,lbstr
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
4846 SysFreeString(lbstr
);
4847 lbstr
= SysAllocString(szTrue
);
4848 VAROR(BSTR
,lbstr
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
4849 VARORCY(BSTR
,lbstr
,10000,I4
,-1);
4850 SysFreeString(lbstr
);
4851 lbstr
= SysAllocString(szFalse
);
4852 VARORCY(BSTR
,lbstr
,10000,I4
,1);
4853 SysFreeString(lbstr
);
4854 SysFreeString(rbstr
);
4857 static HRESULT (WINAPI
*pVarEqv
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
4859 #define VAREQV(vt1,val1,vt2,val2,rvt,rval) \
4860 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
4861 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
4862 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
4863 test_var_call2( __LINE__, pVarEqv, &left, &right, &exp )
4865 static void test_VarEqv(void)
4867 VARIANT left
, right
, exp
, result
;
4873 /* Test all possible flag/vt combinations & the resulting vt type */
4874 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
4876 VARTYPE leftvt
, rightvt
, resvt
;
4878 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
4882 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
4888 if (leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
||
4889 leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
||
4890 leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
)
4893 memset(&left
, 0, sizeof(left
));
4894 memset(&right
, 0, sizeof(right
));
4895 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
4896 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
4897 V_VT(&result
) = VT_EMPTY
;
4900 if (ExtraFlags
[i
] & VT_ARRAY
|| ExtraFlags
[i
] & VT_BYREF
||
4901 !IsValidVariantClearVT(leftvt
, ExtraFlags
[i
]) ||
4902 !IsValidVariantClearVT(rightvt
, ExtraFlags
[i
]) ||
4903 leftvt
== VT_CLSID
|| rightvt
== VT_CLSID
||
4904 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
||
4905 leftvt
== VT_VARIANT
|| rightvt
== VT_VARIANT
||
4906 leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
)
4910 if (leftvt
== VT_EMPTY
|| rightvt
== VT_EMPTY
)
4912 if (leftvt
== rightvt
||
4913 leftvt
== VT_I2
|| rightvt
== VT_I2
||
4914 leftvt
== VT_UI1
|| rightvt
== VT_UI1
||
4915 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
4917 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
4919 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
4922 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
4926 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
4928 if (leftvt
== rightvt
)
4930 else if (leftvt
== rightvt
||
4931 leftvt
== VT_I2
|| rightvt
== VT_I2
||
4932 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
4936 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
4939 else if (leftvt
== VT_I2
|| rightvt
== VT_I2
)
4941 if (leftvt
== rightvt
||
4942 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
4944 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
4947 else if (leftvt
== VT_BOOL
&& rightvt
== VT_BOOL
)
4951 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
4953 if (leftvt
== VT_INT
|| rightvt
== VT_INT
)
4958 hres
= pVarEqv(&left
, &right
, &result
);
4960 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
4961 "VarEqv: %d|0x%X, %d|0x%X: Expected failure, got 0x%X vt %d\n",
4962 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], hres
,
4965 ok(hres
== S_OK
&& V_VT(&result
) == resvt
,
4966 "VarEqv: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%X vt %d\n",
4967 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], resvt
, hres
,
4973 /* Test returned values */
4974 VAREQV(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
);
4975 VAREQV(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
);
4976 VAREQV(BOOL
,TRUE
,BOOL
,TRUE
,BOOL
,VARIANT_TRUE
);
4977 VAREQV(BOOL
,FALSE
,BOOL
,FALSE
,BOOL
,VARIANT_TRUE
);
4978 VAREQV(BOOL
,TRUE
,BOOL
,FALSE
,BOOL
,-2);
4979 VAREQV(BOOL
,FALSE
,BOOL
,TRUE
,BOOL
,-2);
4980 VAREQV(BOOL
,6,BOOL
,7,BOOL
,-2);
4981 VAREQV(BOOL
,6,BOOL
,6,BOOL
,VARIANT_TRUE
);
4982 VAREQV(BOOL
,VARIANT_TRUE
,I2
,VARIANT_TRUE
,I2
,VARIANT_TRUE
);
4983 VAREQV(BOOL
,VARIANT_TRUE
,I2
,VARIANT_FALSE
,I2
,VARIANT_FALSE
);
4984 VAREQV(BOOL
,6,I2
,7,I2
,-2);
4985 VAREQV(UI1
,1,UI1
,1,UI1
,255);
4986 VAREQV(UI1
,1,UI1
,0,UI1
,254);
4987 VAREQV(UI1
,0,UI1
,1,UI1
,254);
4990 VAREQV(UI4
,VARIANT_FALSE
,I8
,VARIANT_FALSE
,I8
,-1);
4991 VAREQV(UI4
,5,I8
,19,I8
,-23);
4992 VAREQV(UI4
,VARIANT_FALSE
,UI8
,VARIANT_FALSE
,I4
,-1);
4996 static HRESULT (WINAPI
*pVarMul
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
4998 #define VARMUL(vt1,val1,vt2,val2,rvt,rval) \
4999 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
5000 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
5001 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
5002 test_var_call2( __LINE__, pVarMul, &left, &right, &exp )
5004 static void test_VarMul(void)
5006 VARIANT left
, right
, exp
, result
, cy
, dec
;
5014 lbstr
= SysAllocString(sz12
);
5015 rbstr
= SysAllocString(sz12
);
5017 /* Test all possible flag/vt combinations & the resulting vt type */
5018 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
5020 VARTYPE leftvt
, rightvt
, resvt
;
5022 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
5027 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
5033 if (leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
||
5034 leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
)
5037 memset(&left
, 0, sizeof(left
));
5038 memset(&right
, 0, sizeof(right
));
5039 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
5040 if (leftvt
== VT_BSTR
)
5041 V_BSTR(&left
) = lbstr
;
5042 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
5043 if (rightvt
== VT_BSTR
)
5044 V_BSTR(&right
) = rbstr
;
5045 V_VT(&result
) = VT_EMPTY
;
5048 /* Don't ask me why but native VarMul cannot handle:
5049 VT_I1, VT_UI2, VT_UI4, VT_INT, VT_UINT and VT_UI8.
5050 Tested with DCOM98, Win2k, WinXP */
5051 if (ExtraFlags
[i
] & VT_ARRAY
|| ExtraFlags
[i
] & VT_BYREF
||
5052 !IsValidVariantClearVT(leftvt
, ExtraFlags
[i
]) ||
5053 !IsValidVariantClearVT(rightvt
, ExtraFlags
[i
]) ||
5054 leftvt
== VT_CLSID
|| rightvt
== VT_CLSID
||
5055 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
||
5056 leftvt
== VT_VARIANT
|| rightvt
== VT_VARIANT
||
5057 leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
||
5058 leftvt
== VT_I1
|| rightvt
== VT_I1
||
5059 leftvt
== VT_UI2
|| rightvt
== VT_UI2
||
5060 leftvt
== VT_UI4
|| rightvt
== VT_UI4
||
5061 leftvt
== VT_UI8
|| rightvt
== VT_UI8
||
5062 leftvt
== VT_INT
|| rightvt
== VT_INT
||
5063 leftvt
== VT_UINT
|| rightvt
== VT_UINT
) {
5067 if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
5069 else if (leftvt
== VT_DECIMAL
|| rightvt
== VT_DECIMAL
)
5071 else if (leftvt
== VT_R8
|| rightvt
== VT_R8
||
5072 leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
||
5073 leftvt
== VT_DATE
|| rightvt
== VT_DATE
)
5075 else if (leftvt
== VT_R4
|| rightvt
== VT_R4
) {
5076 if (leftvt
== VT_I4
|| rightvt
== VT_I4
||
5077 leftvt
== VT_I8
|| rightvt
== VT_I8
||
5078 leftvt
== VT_CY
|| rightvt
== VT_CY
)
5082 } else if (leftvt
== VT_CY
|| rightvt
== VT_CY
)
5084 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
5086 else if (leftvt
== VT_I4
|| rightvt
== VT_I4
)
5088 else if (leftvt
== VT_I2
|| rightvt
== VT_I2
||
5089 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
||
5090 (leftvt
== VT_EMPTY
&& rightvt
== VT_EMPTY
))
5092 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
5095 hres
= pVarMul(&left
, &right
, &result
);
5097 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
5098 "VarMul: %d|0x%X, %d|0x%X: Expected failure, got 0x%X vt %d\n",
5099 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], hres
,
5102 ok(hres
== S_OK
&& V_VT(&result
) == resvt
,
5103 "VarMul: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%X vt %d\n",
5104 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], resvt
, hres
,
5111 /* Test returned values */
5112 VARMUL(I4
,4,I4
,2,I4
,8);
5113 VARMUL(I2
,4,I2
,2,I2
,8);
5114 VARMUL(I2
,-13,I4
,5,I4
,-65);
5115 VARMUL(I4
,-13,I4
,5,I4
,-65);
5116 VARMUL(I2
,7,R4
,0.5f
,R4
,3.5f
);
5117 VARMUL(R4
,0.5f
,I4
,5,R8
,2.5);
5118 VARMUL(R8
,7.1,BOOL
,0,R8
,0);
5119 VARMUL(BSTR
,lbstr
,I2
,4,R8
,48);
5120 VARMUL(BSTR
,lbstr
,BOOL
,1,R8
,12);
5121 VARMUL(BSTR
,lbstr
,R4
,0.1f
,R8
,1.2);
5122 VARMUL(BSTR
,lbstr
,BSTR
,rbstr
,R8
,144);
5123 VARMUL(R4
,0.2f
,BSTR
,rbstr
,R8
,2.4);
5124 VARMUL(DATE
,2.25,I4
,7,R8
,15.75);
5126 VARMUL(UI1
, UI1_MAX
, UI1
, UI1_MAX
, I4
, UI1_MAX
* UI1_MAX
);
5127 VARMUL(I2
, I2_MAX
, I2
, I2_MAX
, I4
, I2_MAX
* I2_MAX
);
5128 VARMUL(I2
, I2_MAX
, I2
, I2_MIN
, I4
, I2_MAX
* I2_MIN
);
5129 VARMUL(I2
, I2_MIN
, I2
, I2_MIN
, I4
, I2_MIN
* I2_MIN
);
5130 VARMUL(I4
, I4_MAX
, I4
, I4_MAX
, R8
, (double)I4_MAX
* I4_MAX
);
5131 VARMUL(I4
, I4_MAX
, I4
, I4_MIN
, R8
, (double)I4_MAX
* I4_MIN
);
5132 VARMUL(I4
, I4_MIN
, I4
, I4_MIN
, R8
, (double)I4_MIN
* I4_MIN
);
5133 VARMUL(R4
, R4_MAX
, R4
, R4_MAX
, R8
, (double)R4_MAX
* R4_MAX
);
5134 VARMUL(R4
, R4_MAX
, R4
, R4_MIN
, R4
, R4_MAX
* R4_MIN
);
5135 VARMUL(R4
, R4_MIN
, R4
, R4_MIN
, R4
, R4_MIN
* R4_MIN
);
5136 VARMUL(R8
, R8_MAX
, R8
, R8_MIN
, R8
, R8_MAX
* R8_MIN
);
5137 VARMUL(R8
, R8_MIN
, R8
, R8_MIN
, R8
, R8_MIN
* R8_MIN
);
5139 /* Manuly test some VT_CY and VT_DECIMAL variants */
5141 hres
= VarCyFromI4(4711, &V_CY(&cy
));
5142 ok(hres
== S_OK
, "VarCyFromI4 failed!\n");
5143 V_VT(&dec
) = VT_DECIMAL
;
5144 hres
= VarDecFromR8(-4.2, &V_DECIMAL(&dec
));
5145 ok(hres
== S_OK
, "VarDecFromR4 failed!\n");
5146 memset(&left
, 0, sizeof(left
));
5147 memset(&right
, 0, sizeof(right
));
5148 V_VT(&left
) = VT_I4
;
5150 V_VT(&right
) = VT_UI1
;
5153 hres
= pVarMul(&cy
, &right
, &result
);
5154 ok(hres
== S_OK
&& V_VT(&result
) == VT_CY
, "VarMul: expected coerced type VT_CY, got %s!\n", vtstr(V_VT(&result
)));
5155 hres
= VarR8FromCy(V_CY(&result
), &r
);
5156 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 42399), "VarMul: CY value %f, expected %f\n", r
, (double)42399);
5158 hres
= pVarMul(&left
, &dec
, &result
);
5159 ok(hres
== S_OK
&& V_VT(&result
) == VT_DECIMAL
, "VarMul: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result
)));
5160 hres
= VarR8FromDec(&V_DECIMAL(&result
), &r
);
5161 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 46.2), "VarMul: DECIMAL value %f, expected %f\n", r
, (double)46.2);
5163 SysFreeString(lbstr
);
5164 SysFreeString(rbstr
);
5167 static HRESULT (WINAPI
*pVarAdd
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
5169 #define VARADD(vt1,val1,vt2,val2,rvt,rval) \
5170 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
5171 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
5172 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
5173 test_var_call2( __LINE__, pVarAdd, &left, &right, &exp )
5175 static void test_VarAdd(void)
5177 VARIANT left
, right
, exp
, result
, cy
, dec
;
5185 lbstr
= SysAllocString(sz12
);
5186 rbstr
= SysAllocString(sz12
);
5188 /* Test all possible flag/vt combinations & the resulting vt type */
5189 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
5191 VARTYPE leftvt
, rightvt
, resvt
;
5193 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
5198 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
5204 if (leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
)
5207 memset(&left
, 0, sizeof(left
));
5208 memset(&right
, 0, sizeof(right
));
5209 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
5210 if (leftvt
== VT_BSTR
)
5211 V_BSTR(&left
) = lbstr
;
5212 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
5213 if (rightvt
== VT_BSTR
)
5214 V_BSTR(&right
) = rbstr
;
5215 V_VT(&result
) = VT_EMPTY
;
5218 /* Don't ask me why but native VarAdd cannot handle:
5219 VT_I1, VT_UI2, VT_UI4, VT_INT, VT_UINT and VT_UI8.
5220 Tested with DCOM98, Win2k, WinXP */
5221 if (ExtraFlags
[i
] & VT_ARRAY
|| ExtraFlags
[i
] & VT_BYREF
||
5222 !IsValidVariantClearVT(leftvt
, ExtraFlags
[i
]) ||
5223 !IsValidVariantClearVT(rightvt
, ExtraFlags
[i
]) ||
5224 leftvt
== VT_CLSID
|| rightvt
== VT_CLSID
||
5225 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
||
5226 leftvt
== VT_VARIANT
|| rightvt
== VT_VARIANT
||
5227 leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
||
5228 leftvt
== VT_I1
|| rightvt
== VT_I1
||
5229 leftvt
== VT_UI2
|| rightvt
== VT_UI2
||
5230 leftvt
== VT_UI4
|| rightvt
== VT_UI4
||
5231 leftvt
== VT_UI8
|| rightvt
== VT_UI8
||
5232 leftvt
== VT_INT
|| rightvt
== VT_INT
||
5233 leftvt
== VT_UINT
|| rightvt
== VT_UINT
) {
5237 if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
5239 else if (leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
)
5241 else if (leftvt
== VT_DECIMAL
|| rightvt
== VT_DECIMAL
)
5243 else if (leftvt
== VT_DATE
|| rightvt
== VT_DATE
)
5245 else if (leftvt
== VT_CY
|| rightvt
== VT_CY
)
5247 else if (leftvt
== VT_R8
|| rightvt
== VT_R8
)
5249 else if (leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
) {
5250 if ((leftvt
== VT_BSTR
&& rightvt
== VT_BSTR
) ||
5251 leftvt
== VT_EMPTY
|| rightvt
== VT_EMPTY
)
5255 } else if (leftvt
== VT_R4
|| rightvt
== VT_R4
) {
5256 if (leftvt
== VT_I4
|| rightvt
== VT_I4
||
5257 leftvt
== VT_I8
|| rightvt
== VT_I8
)
5262 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
5264 else if (leftvt
== VT_I4
|| rightvt
== VT_I4
)
5266 else if (leftvt
== VT_I2
|| rightvt
== VT_I2
||
5267 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
||
5268 (leftvt
== VT_EMPTY
&& rightvt
== VT_EMPTY
))
5270 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
5273 hres
= pVarAdd(&left
, &right
, &result
);
5275 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
5276 "VarAdd: %d|0x%X, %d|0x%X: Expected failure, got 0x%X vt %d\n",
5277 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], hres
,
5280 ok(hres
== S_OK
&& V_VT(&result
) == resvt
,
5281 "VarAdd: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%X vt %d\n",
5282 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], resvt
, hres
,
5285 /* Note, we don't clear left/right deliberately here */
5286 VariantClear(&result
);
5291 /* Test returned values */
5292 VARADD(I4
,4,I4
,2,I4
,6);
5293 VARADD(I2
,4,I2
,2,I2
,6);
5294 VARADD(I2
,-13,I4
,5,I4
,-8);
5295 VARADD(I4
,-13,I4
,5,I4
,-8);
5296 VARADD(I2
,7,R4
,0.5f
,R4
,7.5f
);
5297 VARADD(R4
,0.5f
,I4
,5,R8
,5.5);
5298 VARADD(R8
,7.1,BOOL
,0,R8
,7.1);
5299 VARADD(BSTR
,lbstr
,I2
,4,R8
,16);
5300 VARADD(BSTR
,lbstr
,BOOL
,1,R8
,13);
5301 VARADD(BSTR
,lbstr
,R4
,0.1f
,R8
,12.1);
5302 VARADD(R4
,0.2f
,BSTR
,rbstr
,R8
,12.2);
5303 VARADD(DATE
,2.25,I4
,7,DATE
,9.25);
5304 VARADD(DATE
,1.25,R4
,-1.7f
,DATE
,-0.45);
5306 VARADD(UI1
, UI1_MAX
, UI1
, UI1_MAX
, I2
, UI1_MAX
+ UI1_MAX
);
5307 VARADD(I2
, I2_MAX
, I2
, I2_MAX
, I4
, I2_MAX
+ I2_MAX
);
5308 VARADD(I2
, I2_MAX
, I2
, I2_MIN
, I2
, I2_MAX
+ I2_MIN
);
5309 VARADD(I2
, I2_MIN
, I2
, I2_MIN
, I4
, I2_MIN
+ I2_MIN
);
5310 VARADD(I4
, I4_MAX
, I4
, I4_MIN
, I4
, I4_MAX
+ I4_MIN
);
5311 VARADD(I4
, I4_MAX
, I4
, I4_MAX
, R8
, (double)I4_MAX
+ I4_MAX
);
5312 VARADD(I4
, I4_MIN
, I4
, I4_MIN
, R8
, (double)I4_MIN
+ I4_MIN
);
5313 VARADD(R4
, R4_MAX
, R4
, R4_MAX
, R8
, (double)R4_MAX
+ R4_MAX
);
5314 VARADD(R4
, R4_MAX
, R4
, R4_MIN
, R4
, R4_MAX
+ R4_MIN
);
5315 VARADD(R4
, R4_MIN
, R4
, R4_MIN
, R4
, R4_MIN
+ R4_MIN
);
5316 VARADD(R8
, R8_MAX
, R8
, R8_MIN
, R8
, R8_MAX
+ R8_MIN
);
5317 VARADD(R8
, R8_MIN
, R8
, R8_MIN
, R8
, R8_MIN
+ R8_MIN
);
5319 /* Manually test BSTR + BSTR */
5320 V_VT(&left
) = VT_BSTR
;
5321 V_BSTR(&left
) = lbstr
;
5322 V_VT(&right
) = VT_BSTR
;
5323 V_BSTR(&right
) = rbstr
;
5324 hres
= pVarAdd(&left
, &right
, &result
);
5325 ok(hres
== S_OK
&& V_VT(&result
) == VT_BSTR
, "VarAdd: expected coerced type VT_BSTR, got %s!\n", vtstr(V_VT(&result
)));
5326 hres
= VarR8FromStr(V_BSTR(&result
), 0, 0, &r
);
5327 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 1212), "VarAdd: BSTR value %f, expected %f\n", r
, (double)1212);
5328 VariantClear(&result
);
5330 /* Manuly test some VT_CY and VT_DECIMAL variants */
5332 hres
= VarCyFromI4(4711, &V_CY(&cy
));
5333 ok(hres
== S_OK
, "VarCyFromI4 failed!\n");
5334 V_VT(&dec
) = VT_DECIMAL
;
5335 hres
= VarDecFromR8(-4.2, &V_DECIMAL(&dec
));
5336 ok(hres
== S_OK
, "VarDecFromR4 failed!\n");
5337 memset(&left
, 0, sizeof(left
));
5338 memset(&right
, 0, sizeof(right
));
5339 V_VT(&left
) = VT_I4
;
5341 V_VT(&right
) = VT_UI1
;
5344 hres
= pVarAdd(&cy
, &right
, &result
);
5345 ok(hres
== S_OK
&& V_VT(&result
) == VT_CY
, "VarAdd: expected coerced type VT_CY, got %s!\n", vtstr(V_VT(&result
)));
5346 hres
= VarR8FromCy(V_CY(&result
), &r
);
5347 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 4720), "VarAdd: CY value %f, expected %f\n", r
, (double)4720);
5349 hres
= pVarAdd(&left
, &dec
, &result
);
5350 ok(hres
== S_OK
&& V_VT(&result
) == VT_DECIMAL
, "VarAdd: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result
)));
5351 hres
= VarR8FromDec(&V_DECIMAL(&result
), &r
);
5352 ok(hres
== S_OK
&& EQ_DOUBLE(r
, -15.2), "VarAdd: DECIMAL value %f, expected %f\n", r
, (double)-15.2);
5353 VariantClear(&result
);
5355 SysFreeString(lbstr
);
5356 SysFreeString(rbstr
);
5359 static HRESULT (WINAPI
*pVarCmp
)(LPVARIANT
,LPVARIANT
,LCID
,ULONG
);
5360 static HRESULT (WINAPI
*pVarCat
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
5362 static void test_VarCat(void)
5365 VARIANT left
, right
, result
, expected
, expected_broken
;
5366 static const WCHAR sz34
[] = {'3','4','\0'};
5367 static const WCHAR sz1234
[] = {'1','2','3','4','\0'};
5368 static const WCHAR date_sz12
[] = {'9','/','3','0','/','1','9','8','0','1','2','\0'};
5369 static const WCHAR date_sz12_broken
[] = {'9','/','3','0','/','8','0','1','2','\0'};
5370 static const WCHAR sz12_date
[] = {'1','2','9','/','3','0','/','1','9','8','0','\0'};
5371 static const WCHAR sz12_date_broken
[] = {'1','2','9','/','3','0','/','8','0','\0'};
5372 static const WCHAR sz_empty
[] = {'\0'};
5373 CHAR orig_date_format
[128];
5374 VARTYPE leftvt
, rightvt
, resultvt
;
5376 HRESULT expected_error_num
;
5380 /* Set date format for testing */
5381 lcid
= LOCALE_USER_DEFAULT
;
5382 GetLocaleInfoA(lcid
,LOCALE_SSHORTDATE
,orig_date_format
,128);
5383 SetLocaleInfoA(lcid
,LOCALE_SSHORTDATE
,"M/d/yyyy");
5386 VariantInit(&right
);
5387 VariantInit(&result
);
5388 VariantInit(&expected
);
5390 /* Check expected types for all combinations */
5391 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
5396 /* Check if we need/have support for I8 and/or UI8 */
5397 if ((leftvt
== VT_I8
|| leftvt
== VT_UI8
) && !has_i8
)
5400 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
5404 expected_error_num
= S_OK
;
5405 resultvt
= VT_EMPTY
;
5407 if (leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
||
5408 leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
||
5409 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
||
5410 leftvt
== 15 || rightvt
== 15 /* Undefined type */)
5413 /* Check if we need/have support for I8 and/or UI8 */
5414 if ((rightvt
== VT_I8
|| rightvt
== VT_UI8
) && !has_i8
)
5417 if (leftvt
== VT_NULL
&& rightvt
== VT_NULL
)
5419 else if (leftvt
== VT_VARIANT
&& (rightvt
== VT_ERROR
||
5420 rightvt
== VT_DATE
|| rightvt
== VT_DECIMAL
))
5421 expected_error_num
= DISP_E_TYPEMISMATCH
;
5422 else if ((leftvt
== VT_I2
|| leftvt
== VT_I4
||
5423 leftvt
== VT_R4
|| leftvt
== VT_R8
||
5424 leftvt
== VT_CY
|| leftvt
== VT_BOOL
||
5425 leftvt
== VT_BSTR
|| leftvt
== VT_I1
||
5426 leftvt
== VT_UI1
|| leftvt
== VT_UI2
||
5427 leftvt
== VT_UI4
|| leftvt
== VT_I8
||
5428 leftvt
== VT_UI8
|| leftvt
== VT_INT
||
5429 leftvt
== VT_UINT
|| leftvt
== VT_EMPTY
||
5430 leftvt
== VT_NULL
|| leftvt
== VT_DECIMAL
||
5433 (rightvt
== VT_I2
|| rightvt
== VT_I4
||
5434 rightvt
== VT_R4
|| rightvt
== VT_R8
||
5435 rightvt
== VT_CY
|| rightvt
== VT_BOOL
||
5436 rightvt
== VT_BSTR
|| rightvt
== VT_I1
||
5437 rightvt
== VT_UI1
|| rightvt
== VT_UI2
||
5438 rightvt
== VT_UI4
|| rightvt
== VT_I8
||
5439 rightvt
== VT_UI8
|| rightvt
== VT_INT
||
5440 rightvt
== VT_UINT
|| rightvt
== VT_EMPTY
||
5441 rightvt
== VT_NULL
|| rightvt
== VT_DECIMAL
||
5442 rightvt
== VT_DATE
))
5444 else if (rightvt
== VT_ERROR
&& leftvt
< VT_VOID
)
5445 expected_error_num
= DISP_E_TYPEMISMATCH
;
5446 else if (leftvt
== VT_ERROR
&& (rightvt
== VT_DATE
||
5447 rightvt
== VT_ERROR
|| rightvt
== VT_DECIMAL
))
5448 expected_error_num
= DISP_E_TYPEMISMATCH
;
5449 else if (rightvt
== VT_DATE
|| rightvt
== VT_ERROR
||
5450 rightvt
== VT_DECIMAL
)
5451 expected_error_num
= DISP_E_BADVARTYPE
;
5452 else if (leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
)
5453 expected_error_num
= DISP_E_TYPEMISMATCH
;
5454 else if (leftvt
== VT_VARIANT
)
5455 expected_error_num
= DISP_E_TYPEMISMATCH
;
5456 else if (rightvt
== VT_VARIANT
&& (leftvt
== VT_EMPTY
||
5457 leftvt
== VT_NULL
|| leftvt
== VT_I2
||
5458 leftvt
== VT_I4
|| leftvt
== VT_R4
||
5459 leftvt
== VT_R8
|| leftvt
== VT_CY
||
5460 leftvt
== VT_DATE
|| leftvt
== VT_BSTR
||
5461 leftvt
== VT_BOOL
|| leftvt
== VT_DECIMAL
||
5462 leftvt
== VT_I1
|| leftvt
== VT_UI1
||
5463 leftvt
== VT_UI2
|| leftvt
== VT_UI4
||
5464 leftvt
== VT_I8
|| leftvt
== VT_UI8
||
5465 leftvt
== VT_INT
|| leftvt
== VT_UINT
5467 expected_error_num
= DISP_E_TYPEMISMATCH
;
5469 expected_error_num
= DISP_E_BADVARTYPE
;
5471 V_VT(&left
) = leftvt
;
5472 V_VT(&right
) = rightvt
;
5476 V_BSTR(&left
) = SysAllocString(sz_empty
); break;
5478 V_DATE(&left
) = 0.0; break;
5480 VarDecFromR8(0.0, &V_DECIMAL(&left
)); break;
5487 V_BSTR(&right
) = SysAllocString(sz_empty
); break;
5489 V_DATE(&right
) = 0.0; break;
5491 VarDecFromR8(0.0, &V_DECIMAL(&right
)); break;
5496 hres
= pVarCat(&left
, &right
, &result
);
5498 /* Determine the error code for the vt combination */
5499 ok(hres
== expected_error_num
,
5500 "VarCat: %d, %d returned error, 0x%X expected 0x%X.\n",
5501 leftvt
, rightvt
, hres
, expected_error_num
);
5503 /* Check types are correct */
5504 ok(V_VT(&result
) == resultvt
,
5505 "VarCat: %d, %d: expected vt %d, got vt %d\n",
5506 leftvt
, rightvt
, resultvt
, V_VT(&result
));
5508 VariantClear(&left
);
5509 VariantClear(&right
);
5510 VariantClear(&result
);
5514 /* Running single comparison tests to compare outputs */
5516 /* Test concat strings */
5517 V_VT(&left
) = VT_BSTR
;
5518 V_VT(&right
) = VT_BSTR
;
5519 V_VT(&expected
) = VT_BSTR
;
5520 V_BSTR(&left
) = SysAllocString(sz12
);
5521 V_BSTR(&right
) = SysAllocString(sz34
);
5522 V_BSTR(&expected
) = SysAllocString(sz1234
);
5523 hres
= pVarCat(&left
,&right
,&result
);
5524 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5526 ok(pVarCmp(&result
,&expected
,lcid
,0) == VARCMP_EQ
,
5527 "VarCat: VT_BSTR concat with VT_BSTR failed to return correct result\n");
5529 VariantClear(&left
);
5530 VariantClear(&right
);
5531 VariantClear(&result
);
5533 /* Test if expression is VT_ERROR */
5534 V_VT(&left
) = VT_ERROR
;
5535 V_VT(&right
) = VT_BSTR
;
5536 V_BSTR(&right
) = SysAllocString(sz1234
);
5537 hres
= pVarCat(&left
,&right
,&result
);
5538 ok(hres
== DISP_E_TYPEMISMATCH
, "VarCat should have returned DISP_E_TYPEMISMATCH instead of 0x%08x\n", hres
);
5539 ok(V_VT(&result
) == VT_EMPTY
,
5540 "VarCat: VT_ERROR concat with VT_BSTR should have returned VT_EMPTY\n");
5542 VariantClear(&left
);
5543 VariantClear(&right
);
5544 VariantClear(&result
);
5546 V_VT(&left
) = VT_BSTR
;
5547 V_VT(&right
) = VT_ERROR
;
5548 V_BSTR(&left
) = SysAllocString(sz1234
);
5549 hres
= pVarCat(&left
,&right
,&result
);
5550 ok(hres
== DISP_E_TYPEMISMATCH
, "VarCat should have returned DISP_E_TYPEMISMATCH instead of 0x%08x\n", hres
);
5551 ok(V_VT(&result
) == VT_EMPTY
,
5552 "VarCat: VT_BSTR concat with VT_ERROR should have returned VT_EMPTY\n");
5554 VariantClear(&left
);
5555 VariantClear(&right
);
5556 VariantClear(&result
);
5557 VariantClear(&expected
);
5559 /* Test combining boolean with number */
5560 V_VT(&left
) = VT_INT
;
5561 V_VT(&right
) = VT_BOOL
;
5562 V_VT(&expected
) = VT_BSTR
;
5564 V_BOOL(&right
) = TRUE
;
5565 V_BSTR(&expected
) = SysAllocString(sz12_true
);
5566 hres
= pVarCat(&left
,&right
,&result
);
5567 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5570 hres
= pVarCmp(&result
,&expected
,lcid
,0);
5571 ok(hres
== VARCMP_EQ
, "Expected VARCMP_EQ, got %08x for %s, %s\n",
5572 hres
, variantstr(&result
), variantstr(&expected
));
5575 VariantClear(&left
);
5576 VariantClear(&right
);
5577 VariantClear(&result
);
5578 VariantClear(&expected
);
5580 V_VT(&left
) = VT_INT
;
5581 V_VT(&right
) = VT_BOOL
;
5582 V_VT(&expected
) = VT_BSTR
;
5584 V_BOOL(&right
) = FALSE
;
5585 V_BSTR(&expected
) = SysAllocString(sz12_false
);
5586 hres
= pVarCat(&left
,&right
,&result
);
5587 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5590 hres
= pVarCmp(&result
,&expected
,lcid
,0);
5591 ok(hres
== VARCMP_EQ
, "Expected VARCMP_EQ, got %08x for %s, %s\n",
5592 hres
, variantstr(&result
), variantstr(&expected
));
5595 VariantClear(&left
);
5596 VariantClear(&right
);
5597 VariantClear(&result
);
5598 VariantClear(&expected
);
5600 /* Test when both expressions are numeric */
5601 V_VT(&left
) = VT_INT
;
5602 V_VT(&right
) = VT_INT
;
5603 V_VT(&expected
) = VT_BSTR
;
5606 V_BSTR(&expected
) = SysAllocString(sz1234
);
5607 hres
= pVarCat(&left
,&right
,&result
);
5608 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5610 ok(pVarCmp(&result
,&expected
,lcid
,0) == VARCMP_EQ
,
5611 "VarCat: NUMBER concat with NUMBER returned incorrect result\n");
5613 VariantClear(&left
);
5614 VariantClear(&right
);
5615 VariantClear(&result
);
5617 /* Test if one expression is numeric and the other is a string */
5618 V_VT(&left
) = VT_INT
;
5619 V_VT(&right
) = VT_BSTR
;
5621 V_BSTR(&right
) = SysAllocString(sz34
);
5622 hres
= pVarCat(&left
,&right
,&result
);
5623 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5625 ok(pVarCmp(&result
,&expected
,lcid
,0) == VARCMP_EQ
,
5626 "VarCat: NUMBER concat with VT_BSTR, incorrect result\n");
5628 VariantClear(&left
);
5629 VariantClear(&right
);
5630 VariantClear(&result
);
5632 V_VT(&left
) = VT_BSTR
;
5633 V_VT(&right
) = VT_INT
;
5634 V_BSTR(&left
) = SysAllocString(sz12
);
5636 hres
= pVarCat(&left
,&right
,&result
);
5637 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5639 ok(pVarCmp(&result
,&expected
,lcid
,0) == VARCMP_EQ
,
5640 "VarCat: VT_BSTR concat with NUMBER, incorrect result\n");
5642 VariantClear(&left
);
5643 VariantClear(&right
);
5644 VariantClear(&result
);
5645 VariantClear(&expected
);
5647 /* Test concat dates with strings */
5648 V_VT(&left
) = VT_BSTR
;
5649 V_VT(&right
) = VT_DATE
;
5650 V_VT(&expected
) = VT_BSTR
;
5651 V_VT(&expected_broken
) = VT_BSTR
;
5652 V_BSTR(&left
) = SysAllocString(sz12
);
5653 V_DATE(&right
) = 29494.0;
5654 V_BSTR(&expected
)= SysAllocString(sz12_date
);
5655 V_BSTR(&expected_broken
)= SysAllocString(sz12_date_broken
);
5656 hres
= pVarCat(&left
,&right
,&result
);
5657 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5659 ok(pVarCmp(&result
,&expected
,lcid
,0) == VARCMP_EQ
||
5660 broken(pVarCmp(&result
,&expected_broken
,lcid
,0) == VARCMP_EQ
), /* Some W98 and NT4 (intermittent) */
5661 "VarCat: VT_BSTR concat with VT_DATE returned incorrect result\n");
5663 VariantClear(&left
);
5664 VariantClear(&right
);
5665 VariantClear(&result
);
5666 VariantClear(&expected
);
5667 VariantClear(&expected_broken
);
5669 V_VT(&left
) = VT_DATE
;
5670 V_VT(&right
) = VT_BSTR
;
5671 V_VT(&expected
) = VT_BSTR
;
5672 V_VT(&expected_broken
) = VT_BSTR
;
5673 V_DATE(&left
) = 29494.0;
5674 V_BSTR(&right
) = SysAllocString(sz12
);
5675 V_BSTR(&expected
)= SysAllocString(date_sz12
);
5676 V_BSTR(&expected_broken
)= SysAllocString(date_sz12_broken
);
5677 hres
= pVarCat(&left
,&right
,&result
);
5678 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5680 ok(pVarCmp(&result
,&expected
,lcid
,0) == VARCMP_EQ
||
5681 broken(pVarCmp(&result
,&expected_broken
,lcid
,0) == VARCMP_EQ
), /* Some W98 and NT4 (intermittent) */
5682 "VarCat: VT_DATE concat with VT_BSTR returned incorrect result\n");
5684 VariantClear(&left
);
5685 VariantClear(&right
);
5686 VariantClear(&result
);
5687 VariantClear(&expected
);
5688 VariantClear(&expected_broken
);
5690 /* Test of both expressions are empty */
5691 V_VT(&left
) = VT_BSTR
;
5692 V_VT(&right
) = VT_BSTR
;
5693 V_VT(&expected
) = VT_BSTR
;
5694 V_BSTR(&left
) = SysAllocString(sz_empty
);
5695 V_BSTR(&right
) = SysAllocString(sz_empty
);
5696 V_BSTR(&expected
)= SysAllocString(sz_empty
);
5697 hres
= pVarCat(&left
,&right
,&result
);
5698 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5700 ok(pVarCmp(&result
,&left
,lcid
,0) == VARCMP_EQ
,
5701 "VarCat: EMPTY concat with EMPTY did not return empty VT_BSTR\n");
5703 /* Restore original date format settings */
5704 SetLocaleInfoA(lcid
,LOCALE_SSHORTDATE
,orig_date_format
);
5706 VariantClear(&left
);
5707 VariantClear(&right
);
5708 VariantClear(&result
);
5709 VariantClear(&expected
);
5711 /* Test boolean conversion */
5712 V_VT(&left
) = VT_BOOL
;
5713 V_BOOL(&left
) = VARIANT_TRUE
;
5714 V_VT(&right
) = VT_BSTR
;
5715 V_BSTR(&right
) = SysAllocStringLen(NULL
,0);
5716 hres
= pVarCat(&left
, &right
, &result
);
5717 ok(hres
== S_OK
, "VarCat failed: %08x\n", hres
);
5718 if(!strcmp_wa(V_BSTR(&result
), "True")) {
5719 V_VT(&right
) = VT_BOOL
;
5720 V_BOOL(&right
) = 100;
5721 hres
= pVarCat(&left
, &right
, &result
);
5722 ok(hres
== S_OK
, "VarCat failed: %08x\n", hres
);
5723 test_bstr_var(&result
, "TrueTrue");
5724 VariantClear(&result
);
5726 V_BOOL(&right
) = VARIANT_FALSE
;
5727 hres
= pVarCat(&left
, &right
, &result
);
5728 ok(hres
== S_OK
, "VarCat failed: %08x\n", hres
);
5729 test_bstr_var(&result
, "TrueFalse");
5730 VariantClear(&result
);
5732 skip("Got %s as True, assuming non-English locale\n", wine_dbgstr_w(V_BSTR(&result
)));
5736 static HRESULT (WINAPI
*pVarAnd
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
5738 #define VARAND(vt1,val1,vt2,val2,rvt,rval) \
5739 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
5740 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
5741 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
5742 test_var_call2( __LINE__, pVarAnd, &left, &right, &exp )
5744 #define VARANDCY(vt1,val1,val2,rvt,rval) \
5745 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
5746 V_VT(&right) = VT_CY; V_CY(&right).int64 = val2; \
5747 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
5748 test_var_call2( __LINE__, pVarAnd, &left, &right, &exp )
5750 /* Skip any type that is not defined or produces an error for every case */
5751 #define SKIPTESTAND(a) \
5752 if (a == VT_ERROR || a == VT_VARIANT || \
5753 a == VT_DISPATCH || a == VT_UNKNOWN || \
5754 a > VT_UINT || a == 15 /*not defined*/) \
5757 static void test_VarAnd(void)
5759 static const WCHAR szFalse
[] = { '#','F','A','L','S','E','#','\0' };
5760 static const WCHAR szTrue
[] = { '#','T','R','U','E','#','\0' };
5761 VARIANT left
, right
, exp
, result
;
5762 BSTR false_str
, true_str
;
5766 true_str
= SysAllocString(szTrue
);
5767 false_str
= SysAllocString(szFalse
);
5771 /* Test all possible flag/vt combinations & the resulting vt type */
5772 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
5774 VARTYPE leftvt
, rightvt
, resvt
;
5776 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
5778 SKIPTESTAND(leftvt
);
5780 /* Check if we need/have support for I8 and/or UI8 */
5781 if ((leftvt
== VT_I8
|| leftvt
== VT_UI8
) && !has_i8
)
5784 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
5787 SKIPTESTAND(rightvt
);
5789 /* Check if we need/have support for I8 and/or UI8 */
5790 if ((rightvt
== VT_I8
|| rightvt
== VT_UI8
) && !has_i8
)
5793 memset(&left
, 0, sizeof(left
));
5794 memset(&right
, 0, sizeof(right
));
5795 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
5796 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
5797 V_VT(&result
) = VT_EMPTY
;
5799 if ((leftvt
| ExtraFlags
[i
]) == VT_BSTR
)
5800 V_BSTR(&left
) = true_str
;
5801 if ((rightvt
| ExtraFlags
[i
]) == VT_BSTR
)
5802 V_BSTR(&right
) = true_str
;
5804 /* Native VarAnd always returns an error when using extra
5805 * flags or if the variant combination is I8 and INT.
5807 if ((leftvt
== VT_I8
&& rightvt
== VT_INT
) ||
5808 (leftvt
== VT_INT
&& rightvt
== VT_I8
) ||
5812 /* Determine return type */
5813 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
5815 else if (leftvt
== VT_I4
|| rightvt
== VT_I4
||
5816 leftvt
== VT_UINT
|| rightvt
== VT_UINT
||
5817 leftvt
== VT_INT
|| rightvt
== VT_INT
||
5818 leftvt
== VT_UINT
|| rightvt
== VT_UINT
||
5819 leftvt
== VT_R4
|| rightvt
== VT_R4
||
5820 leftvt
== VT_R8
|| rightvt
== VT_R8
||
5821 leftvt
== VT_CY
|| rightvt
== VT_CY
||
5822 leftvt
== VT_DATE
|| rightvt
== VT_DATE
||
5823 leftvt
== VT_I1
|| rightvt
== VT_I1
||
5824 leftvt
== VT_UI2
|| rightvt
== VT_UI2
||
5825 leftvt
== VT_UI4
|| rightvt
== VT_UI4
||
5826 leftvt
== VT_UI8
|| rightvt
== VT_UI8
||
5827 leftvt
== VT_DECIMAL
|| rightvt
== VT_DECIMAL
)
5829 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
||
5830 leftvt
== VT_I2
|| rightvt
== VT_I2
||
5831 leftvt
== VT_EMPTY
|| rightvt
== VT_EMPTY
)
5832 if ((leftvt
== VT_NULL
&& rightvt
== VT_UI1
) ||
5833 (leftvt
== VT_UI1
&& rightvt
== VT_NULL
) ||
5834 (leftvt
== VT_UI1
&& rightvt
== VT_UI1
))
5838 else if (leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
||
5839 (leftvt
== VT_BSTR
&& rightvt
== VT_BSTR
))
5841 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
||
5842 leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
)
5847 hres
= pVarAnd(&left
, &right
, &result
);
5849 /* Check expected HRESULT and if result variant type is correct */
5851 ok (hres
== DISP_E_BADVARTYPE
|| hres
== DISP_E_TYPEMISMATCH
,
5852 "VarAnd: %s|0x%X, %s|0x%X: got vt %s hr 0x%X\n",
5853 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
],
5854 vtstr(V_VT(&result
)), hres
);
5856 ok (hres
== S_OK
&& resvt
== V_VT(&result
),
5857 "VarAnd: %s|0x%X, %s|0x%X: expected vt %s hr 0x%X, got vt %s hr 0x%X\n",
5858 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
], vtstr(resvt
),
5859 S_OK
, vtstr(V_VT(&result
)), hres
);
5865 * Test returned values. Since we know the returned type is correct
5866 * and that we handle all combinations of invalid types, just check
5867 * that good type combinations produce the desired value.
5868 * FIXME: Test VT_DECIMAL
5870 VARAND(EMPTY
,0,EMPTY
,0,I2
,0);
5871 VARAND(EMPTY
,1,EMPTY
,0,I2
,0);
5872 VARAND(EMPTY
,1,EMPTY
,1,I2
,0);
5873 VARAND(EMPTY
,0,NULL
,0,I2
,0);
5874 VARAND(EMPTY
,1,NULL
,0,I2
,0);
5875 VARAND(EMPTY
,1,NULL
,1,I2
,0);
5876 VARAND(EMPTY
,0,I1
,0,I4
,0);
5877 VARAND(EMPTY
,0,I1
,1,I4
,0);
5878 VARAND(EMPTY
,1,I1
,1,I4
,0);
5879 VARAND(EMPTY
,0,UI1
,0,I2
,0);
5880 VARAND(EMPTY
,0,UI1
,1,I2
,0);
5881 VARAND(EMPTY
,1,UI1
,1,I2
,0);
5882 VARAND(EMPTY
,0,I2
,0,I2
,0);
5883 VARAND(EMPTY
,0,I2
,1,I2
,0);
5884 VARAND(EMPTY
,1,I2
,1,I2
,0);
5885 VARAND(EMPTY
,0,UI2
,0,I4
,0);
5886 VARAND(EMPTY
,0,UI2
,1,I4
,0);
5887 VARAND(EMPTY
,1,UI2
,1,I4
,0);
5888 VARAND(EMPTY
,0,I4
,0,I4
,0);
5889 VARAND(EMPTY
,0,I4
,1,I4
,0);
5890 VARAND(EMPTY
,1,I4
,1,I4
,0);
5891 VARAND(EMPTY
,0,UI4
,0,I4
,0);
5892 VARAND(EMPTY
,0,UI4
,1,I4
,0);
5893 VARAND(EMPTY
,1,UI4
,1,I4
,0);
5896 VARAND(EMPTY
,0,I8
,0,I8
,0);
5897 VARAND(EMPTY
,0,I8
,1,I8
,0);
5898 VARAND(EMPTY
,1,I8
,1,I8
,0);
5899 VARAND(EMPTY
,0,UI8
,0,I4
,0);
5900 VARAND(EMPTY
,0,UI8
,1,I4
,0);
5901 VARAND(EMPTY
,1,UI8
,1,I4
,0);
5903 VARAND(EMPTY
,0,INT
,0,I4
,0);
5904 VARAND(EMPTY
,0,INT
,1,I4
,0);
5905 VARAND(EMPTY
,1,INT
,1,I4
,0);
5906 VARAND(EMPTY
,0,UINT
,0,I4
,0);
5907 VARAND(EMPTY
,0,UINT
,1,I4
,0);
5908 VARAND(EMPTY
,1,UINT
,1,I4
,0);
5909 VARAND(EMPTY
,0,BOOL
,0,I2
,0);
5910 VARAND(EMPTY
,0,BOOL
,1,I2
,0);
5911 VARAND(EMPTY
,1,BOOL
,1,I2
,0);
5912 VARAND(EMPTY
,0,R4
,0,I4
,0);
5913 VARAND(EMPTY
,0,R4
,1,I4
,0);
5914 VARAND(EMPTY
,1,R4
,1,I4
,0);
5915 VARAND(EMPTY
,0,R8
,0,I4
,0);
5916 VARAND(EMPTY
,0,R8
,1,I4
,0);
5917 VARAND(EMPTY
,1,R8
,1,I4
,0);
5918 VARAND(EMPTY
,0,BSTR
,false_str
,I2
,0);
5919 VARAND(EMPTY
,0,BSTR
,true_str
,I2
,0);
5920 VARANDCY(EMPTY
,0,10000,I4
,0);
5922 /* NULL OR 0 = NULL. NULL OR n = n */
5923 VARAND(NULL
,0,NULL
,0,NULL
,0);
5924 VARAND(NULL
,1,NULL
,0,NULL
,0);
5925 VARAND(NULL
,0,I1
,0,I4
,0);
5926 VARAND(NULL
,0,I1
,1,NULL
,0);
5927 VARAND(NULL
,0,UI1
,0,UI1
,0);
5928 VARAND(NULL
,0,UI1
,1,NULL
,0);
5929 VARAND(NULL
,0,I2
,0,I2
,0);
5930 VARAND(NULL
,0,I2
,1,NULL
,0);
5931 VARAND(NULL
,0,UI2
,0,I4
,0);
5932 VARAND(NULL
,0,UI2
,1,NULL
,0);
5933 VARAND(NULL
,0,I4
,0,I4
,0);
5934 VARAND(NULL
,0,I4
,1,NULL
,0);
5935 VARAND(NULL
,0,UI4
,0,I4
,0);
5936 VARAND(NULL
,0,UI4
,1,NULL
,0);
5939 VARAND(NULL
,0,I8
,0,I8
,0);
5940 VARAND(NULL
,0,I8
,1,NULL
,0);
5941 VARAND(NULL
,0,UI8
,0,I4
,0);
5942 VARAND(NULL
,0,UI8
,1,NULL
,0);
5944 VARAND(NULL
,0,INT
,0,I4
,0);
5945 VARAND(NULL
,0,INT
,1,NULL
,0);
5946 VARAND(NULL
,0,UINT
,0,I4
,0);
5947 VARAND(NULL
,0,UINT
,1,NULL
,0);
5948 VARAND(NULL
,0,BOOL
,0,BOOL
,0);
5949 VARAND(NULL
,0,BOOL
,1,NULL
,0);
5950 VARAND(NULL
,0,R4
,0,I4
,0);
5951 VARAND(NULL
,0,R4
,1,NULL
,0);
5952 VARAND(NULL
,0,R8
,0,I4
,0);
5953 VARAND(NULL
,0,R8
,1,NULL
,0);
5954 VARAND(NULL
,0,BSTR
,false_str
,BOOL
,0);
5955 VARAND(NULL
,0,BSTR
,true_str
,NULL
,VARIANT_FALSE
);
5956 VARANDCY(NULL
,0,10000,NULL
,0);
5957 VARANDCY(NULL
,0,0,I4
,0);
5958 VARAND(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
);
5959 VARAND(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_FALSE
);
5960 VARAND(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
);
5961 VARAND(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_FALSE
);
5963 /* Assume x,y & y,x are the same from now on to reduce the number of tests */
5964 VARAND(BOOL
,VARIANT_TRUE
,I1
,-1,I4
,-1);
5965 VARAND(BOOL
,VARIANT_TRUE
,I1
,0,I4
,0);
5966 VARAND(BOOL
,VARIANT_FALSE
,I1
,0,I4
,0);
5967 VARAND(BOOL
,VARIANT_TRUE
,UI1
,255,I2
,255);
5968 VARAND(BOOL
,VARIANT_TRUE
,UI1
,0,I2
,0);
5969 VARAND(BOOL
,VARIANT_FALSE
,UI1
,0,I2
,0);
5970 VARAND(BOOL
,VARIANT_TRUE
,I2
,-1,I2
,-1);
5971 VARAND(BOOL
,VARIANT_TRUE
,I2
,0,I2
,0);
5972 VARAND(BOOL
,VARIANT_FALSE
,I2
,0,I2
,0);
5973 VARAND(BOOL
,VARIANT_TRUE
,UI2
,65535,I4
,65535);
5974 VARAND(BOOL
,VARIANT_TRUE
,UI2
,0,I4
,0);
5975 VARAND(BOOL
,VARIANT_FALSE
,UI2
,0,I4
,0);
5976 VARAND(BOOL
,VARIANT_TRUE
,I4
,-1,I4
,-1);
5977 VARAND(BOOL
,VARIANT_TRUE
,I4
,0,I4
,0);
5978 VARAND(BOOL
,VARIANT_FALSE
,I4
,0,I4
,0);
5979 VARAND(BOOL
,VARIANT_TRUE
,UI4
,0xffffffff,I4
,-1);
5980 VARAND(BOOL
,VARIANT_TRUE
,UI4
,0,I4
,0);
5981 VARAND(BOOL
,VARIANT_FALSE
,UI4
,0,I4
,0);
5982 VARAND(BOOL
,VARIANT_TRUE
,R4
,-1,I4
,-1);
5983 VARAND(BOOL
,VARIANT_TRUE
,R4
,0,I4
,0);
5984 VARAND(BOOL
,VARIANT_FALSE
,R4
,0,I4
,0);
5985 VARAND(BOOL
,VARIANT_TRUE
,R8
,-1,I4
,-1);
5986 VARAND(BOOL
,VARIANT_TRUE
,R8
,0,I4
,0);
5987 VARAND(BOOL
,VARIANT_FALSE
,R8
,0,I4
,0);
5988 VARAND(BOOL
,VARIANT_TRUE
,DATE
,-1,I4
,-1);
5989 VARAND(BOOL
,VARIANT_TRUE
,DATE
,0,I4
,0);
5990 VARAND(BOOL
,VARIANT_FALSE
,DATE
,0,I4
,0);
5993 VARAND(BOOL
,VARIANT_TRUE
,I8
,-1,I8
,-1);
5994 VARAND(BOOL
,VARIANT_TRUE
,I8
,0,I8
,0);
5995 VARAND(BOOL
,VARIANT_FALSE
,I8
,0,I8
,0);
5996 VARAND(BOOL
,VARIANT_TRUE
,UI8
,0,I4
,0);
5997 VARAND(BOOL
,VARIANT_FALSE
,UI8
,0,I4
,0);
5999 VARAND(BOOL
,VARIANT_TRUE
,INT
,-1,I4
,-1);
6000 VARAND(BOOL
,VARIANT_TRUE
,INT
,0,I4
,0);
6001 VARAND(BOOL
,VARIANT_FALSE
,INT
,0,I4
,0);
6002 VARAND(BOOL
,VARIANT_TRUE
,UINT
,0xffffffff,I4
,-1);
6003 VARAND(BOOL
,VARIANT_TRUE
,UINT
,0,I4
,0);
6004 VARAND(BOOL
,VARIANT_FALSE
,UINT
,0,I4
,0);
6005 VARAND(BOOL
,VARIANT_FALSE
,BSTR
,false_str
,BOOL
,VARIANT_FALSE
);
6006 VARAND(BOOL
,VARIANT_TRUE
,BSTR
,false_str
,BOOL
,VARIANT_FALSE
);
6007 VARAND(BOOL
,VARIANT_FALSE
,BSTR
,true_str
,BOOL
,VARIANT_FALSE
);
6008 VARAND(BOOL
,VARIANT_TRUE
,BSTR
,true_str
,BOOL
,VARIANT_TRUE
);
6009 VARANDCY(BOOL
,VARIANT_TRUE
,10000,I4
,1);
6010 VARANDCY(BOOL
,VARIANT_TRUE
,0,I4
,0);
6011 VARANDCY(BOOL
,VARIANT_FALSE
,0,I4
,0);
6012 VARAND(I1
,-1,I1
,-1,I4
,-1);
6013 VARAND(I1
,-1,I1
,0,I4
,0);
6014 VARAND(I1
,0,I1
,0,I4
,0);
6015 VARAND(I1
,-1,UI1
,255,I4
,255);
6016 VARAND(I1
,-1,UI1
,0,I4
,0);
6017 VARAND(I1
,0,UI1
,0,I4
,0);
6018 VARAND(I1
,-1,I2
,-1,I4
,-1);
6019 VARAND(I1
,-1,I2
,0,I4
,0);
6020 VARAND(I1
,0,I2
,0,I4
,0);
6021 VARAND(I1
,-1,UI2
,65535,I4
,65535);
6022 VARAND(I1
,-1,UI2
,0,I4
,0);
6023 VARAND(I1
,0,UI2
,0,I4
,0);
6024 VARAND(I1
,-1,I4
,-1,I4
,-1);
6025 VARAND(I1
,-1,I4
,0,I4
,0);
6026 VARAND(I1
,0,I4
,0,I4
,0);
6027 VARAND(I1
,-1,UI4
,0xffffffff,I4
,-1);
6028 VARAND(I1
,-1,UI4
,0,I4
,0);
6029 VARAND(I1
,0,UI4
,0,I4
,0);
6030 VARAND(I1
,-1,R4
,-1,I4
,-1);
6031 VARAND(I1
,-1,R4
,0,I4
,0);
6032 VARAND(I1
,0,R4
,0,I4
,0);
6033 VARAND(I1
,-1,R8
,-1,I4
,-1);
6034 VARAND(I1
,-1,R8
,0,I4
,0);
6035 VARAND(I1
,0,R8
,0,I4
,0);
6036 VARAND(I1
,-1,DATE
,-1,I4
,-1);
6037 VARAND(I1
,-1,DATE
,0,I4
,0);
6038 VARAND(I1
,0,DATE
,0,I4
,0);
6041 VARAND(I1
,-1,I8
,-1,I8
,-1);
6042 VARAND(I1
,-1,I8
,0,I8
,0);
6043 VARAND(I1
,0,I8
,0,I8
,0);
6044 VARAND(I1
,-1,UI8
,0,I4
,0);
6045 VARAND(I1
,0,UI8
,0,I4
,0);
6047 VARAND(I1
,-1,INT
,-1,I4
,-1);
6048 VARAND(I1
,-1,INT
,0,I4
,0);
6049 VARAND(I1
,0,INT
,0,I4
,0);
6050 VARAND(I1
,-1,UINT
,0xffffffff,I4
,-1);
6051 VARAND(I1
,-1,UINT
,0,I4
,0);
6052 VARAND(I1
,0,UINT
,0,I4
,0);
6053 VARAND(I1
,0,BSTR
,false_str
,I4
,0);
6054 VARAND(I1
,-1,BSTR
,false_str
,I4
,0);
6055 VARAND(I1
,0,BSTR
,true_str
,I4
,0);
6056 VARAND(I1
,-1,BSTR
,true_str
,I4
,-1);
6057 VARANDCY(I1
,-1,10000,I4
,1);
6058 VARANDCY(I1
,-1,0,I4
,0);
6059 VARANDCY(I1
,0,0,I4
,0);
6061 VARAND(UI1
,255,UI1
,255,UI1
,255);
6062 VARAND(UI1
,255,UI1
,0,UI1
,0);
6063 VARAND(UI1
,0,UI1
,0,UI1
,0);
6064 VARAND(UI1
,255,I2
,-1,I2
,255);
6065 VARAND(UI1
,255,I2
,0,I2
,0);
6066 VARAND(UI1
,0,I2
,0,I2
,0);
6067 VARAND(UI1
,255,UI2
,65535,I4
,255);
6068 VARAND(UI1
,255,UI2
,0,I4
,0);
6069 VARAND(UI1
,0,UI2
,0,I4
,0);
6070 VARAND(UI1
,255,I4
,-1,I4
,255);
6071 VARAND(UI1
,255,I4
,0,I4
,0);
6072 VARAND(UI1
,0,I4
,0,I4
,0);
6073 VARAND(UI1
,255,UI4
,0xffffffff,I4
,255);
6074 VARAND(UI1
,255,UI4
,0,I4
,0);
6075 VARAND(UI1
,0,UI4
,0,I4
,0);
6076 VARAND(UI1
,255,R4
,-1,I4
,255);
6077 VARAND(UI1
,255,R4
,0,I4
,0);
6078 VARAND(UI1
,0,R4
,0,I4
,0);
6079 VARAND(UI1
,255,R8
,-1,I4
,255);
6080 VARAND(UI1
,255,R8
,0,I4
,0);
6081 VARAND(UI1
,0,R8
,0,I4
,0);
6082 VARAND(UI1
,255,DATE
,-1,I4
,255);
6083 VARAND(UI1
,255,DATE
,0,I4
,0);
6084 VARAND(UI1
,0,DATE
,0,I4
,0);
6087 VARAND(UI1
,255,I8
,-1,I8
,255);
6088 VARAND(UI1
,255,I8
,0,I8
,0);
6089 VARAND(UI1
,0,I8
,0,I8
,0);
6090 VARAND(UI1
,255,UI8
,0,I4
,0);
6091 VARAND(UI1
,0,UI8
,0,I4
,0);
6093 VARAND(UI1
,255,INT
,-1,I4
,255);
6094 VARAND(UI1
,255,INT
,0,I4
,0);
6095 VARAND(UI1
,0,INT
,0,I4
,0);
6096 VARAND(UI1
,255,UINT
,0xffffffff,I4
,255);
6097 VARAND(UI1
,255,UINT
,0,I4
,0);
6098 VARAND(UI1
,0,UINT
,0,I4
,0);
6099 VARAND(UI1
,0,BSTR
,false_str
,I2
,0);
6100 VARAND(UI1
,255,BSTR
,false_str
,I2
,0);
6101 VARAND(UI1
,0,BSTR
,true_str
,I2
,0);
6102 VARAND(UI1
,255,BSTR
,true_str
,I2
,255);
6103 VARANDCY(UI1
,255,10000,I4
,1);
6104 VARANDCY(UI1
,255,0,I4
,0);
6105 VARANDCY(UI1
,0,0,I4
,0);
6107 VARAND(I2
,-1,I2
,-1,I2
,-1);
6108 VARAND(I2
,-1,I2
,0,I2
,0);
6109 VARAND(I2
,0,I2
,0,I2
,0);
6110 VARAND(I2
,-1,UI2
,65535,I4
,65535);
6111 VARAND(I2
,-1,UI2
,0,I4
,0);
6112 VARAND(I2
,0,UI2
,0,I4
,0);
6113 VARAND(I2
,-1,I4
,-1,I4
,-1);
6114 VARAND(I2
,-1,I4
,0,I4
,0);
6115 VARAND(I2
,0,I4
,0,I4
,0);
6116 VARAND(I2
,-1,UI4
,0xffffffff,I4
,-1);
6117 VARAND(I2
,-1,UI4
,0,I4
,0);
6118 VARAND(I2
,0,UI4
,0,I4
,0);
6119 VARAND(I2
,-1,R4
,-1,I4
,-1);
6120 VARAND(I2
,-1,R4
,0,I4
,0);
6121 VARAND(I2
,0,R4
,0,I4
,0);
6122 VARAND(I2
,-1,R8
,-1,I4
,-1);
6123 VARAND(I2
,-1,R8
,0,I4
,0);
6124 VARAND(I2
,0,R8
,0,I4
,0);
6125 VARAND(I2
,-1,DATE
,-1,I4
,-1);
6126 VARAND(I2
,-1,DATE
,0,I4
,0);
6127 VARAND(I2
,0,DATE
,0,I4
,0);
6130 VARAND(I2
,-1,I8
,-1,I8
,-1);
6131 VARAND(I2
,-1,I8
,0,I8
,0);
6132 VARAND(I2
,0,I8
,0,I8
,0);
6133 VARAND(I2
,-1,UI8
,0,I4
,0);
6134 VARAND(I2
,0,UI8
,0,I4
,0);
6136 VARAND(I2
,-1,INT
,-1,I4
,-1);
6137 VARAND(I2
,-1,INT
,0,I4
,0);
6138 VARAND(I2
,0,INT
,0,I4
,0);
6139 VARAND(I2
,-1,UINT
,0xffffffff,I4
,-1);
6140 VARAND(I2
,-1,UINT
,0,I4
,0);
6141 VARAND(I2
,0,UINT
,0,I4
,0);
6142 VARAND(I2
,0,BSTR
,false_str
,I2
,0);
6143 VARAND(I2
,-1,BSTR
,false_str
,I2
,0);
6144 VARAND(I2
,0,BSTR
,true_str
,I2
,0);
6145 VARAND(I2
,-1,BSTR
,true_str
,I2
,-1);
6146 VARANDCY(I2
,-1,10000,I4
,1);
6147 VARANDCY(I2
,-1,0,I4
,0);
6148 VARANDCY(I2
,0,0,I4
,0);
6150 VARAND(UI2
,65535,UI2
,65535,I4
,65535);
6151 VARAND(UI2
,65535,UI2
,0,I4
,0);
6152 VARAND(UI2
,0,UI2
,0,I4
,0);
6153 VARAND(UI2
,65535,I4
,-1,I4
,65535);
6154 VARAND(UI2
,65535,I4
,0,I4
,0);
6155 VARAND(UI2
,0,I4
,0,I4
,0);
6156 VARAND(UI2
,65535,UI4
,0xffffffff,I4
,65535);
6157 VARAND(UI2
,65535,UI4
,0,I4
,0);
6158 VARAND(UI2
,0,UI4
,0,I4
,0);
6159 VARAND(UI2
,65535,R4
,-1,I4
,65535);
6160 VARAND(UI2
,65535,R4
,0,I4
,0);
6161 VARAND(UI2
,0,R4
,0,I4
,0);
6162 VARAND(UI2
,65535,R8
,-1,I4
,65535);
6163 VARAND(UI2
,65535,R8
,0,I4
,0);
6164 VARAND(UI2
,0,R8
,0,I4
,0);
6165 VARAND(UI2
,65535,DATE
,-1,I4
,65535);
6166 VARAND(UI2
,65535,DATE
,0,I4
,0);
6167 VARAND(UI2
,0,DATE
,0,I4
,0);
6170 VARAND(UI2
,65535,I8
,-1,I8
,65535);
6171 VARAND(UI2
,65535,I8
,0,I8
,0);
6172 VARAND(UI2
,0,I8
,0,I8
,0);
6173 VARAND(UI2
,65535,UI8
,0,I4
,0);
6174 VARAND(UI2
,0,UI8
,0,I4
,0);
6176 VARAND(UI2
,65535,INT
,-1,I4
,65535);
6177 VARAND(UI2
,65535,INT
,0,I4
,0);
6178 VARAND(UI2
,0,INT
,0,I4
,0);
6179 VARAND(UI2
,65535,UINT
,0xffffffff,I4
,65535);
6180 VARAND(UI2
,65535,UINT
,0,I4
,0);
6181 VARAND(UI2
,0,UINT
,0,I4
,0);
6182 VARAND(UI2
,0,BSTR
,false_str
,I4
,0);
6183 VARAND(UI2
,65535,BSTR
,false_str
,I4
,0);
6184 VARAND(UI2
,0,BSTR
,true_str
,I4
,0);
6185 VARAND(UI2
,65535,BSTR
,true_str
,I4
,65535);
6186 VARANDCY(UI2
,65535,10000,I4
,1);
6187 VARANDCY(UI2
,65535,0,I4
,0);
6188 VARANDCY(UI2
,0,0,I4
,0);
6190 VARAND(I4
,-1,I4
,-1,I4
,-1);
6191 VARAND(I4
,-1,I4
,0,I4
,0);
6192 VARAND(I4
,0,I4
,0,I4
,0);
6193 VARAND(I4
,-1,UI4
,0xffffffff,I4
,-1);
6194 VARAND(I4
,-1,UI4
,0,I4
,0);
6195 VARAND(I4
,0,UI4
,0,I4
,0);
6196 VARAND(I4
,-1,R4
,-1,I4
,-1);
6197 VARAND(I4
,-1,R4
,0,I4
,0);
6198 VARAND(I4
,0,R4
,0,I4
,0);
6199 VARAND(I4
,-1,R8
,-1,I4
,-1);
6200 VARAND(I4
,-1,R8
,0,I4
,0);
6201 VARAND(I4
,0,R8
,0,I4
,0);
6202 VARAND(I4
,-1,DATE
,-1,I4
,-1);
6203 VARAND(I4
,-1,DATE
,0,I4
,0);
6204 VARAND(I4
,0,DATE
,0,I4
,0);
6207 VARAND(I4
,-1,I8
,-1,I8
,-1);
6208 VARAND(I4
,-1,I8
,0,I8
,0);
6209 VARAND(I4
,0,I8
,0,I8
,0);
6210 VARAND(I4
,-1,UI8
,0,I4
,0);
6211 VARAND(I4
,0,UI8
,0,I4
,0);
6213 VARAND(I4
,-1,INT
,-1,I4
,-1);
6214 VARAND(I4
,-1,INT
,0,I4
,0);
6215 VARAND(I4
,0,INT
,0,I4
,0);
6216 VARAND(I4
,-1,UINT
,0xffffffff,I4
,-1);
6217 VARAND(I4
,-1,UINT
,0,I4
,0);
6218 VARAND(I4
,0,UINT
,0,I4
,0);
6219 VARAND(I4
,0,BSTR
,false_str
,I4
,0);
6220 VARAND(I4
,-1,BSTR
,false_str
,I4
,0);
6221 VARAND(I4
,0,BSTR
,true_str
,I4
,0);
6222 VARAND(I4
,-1,BSTR
,true_str
,I4
,-1);
6223 VARANDCY(I4
,-1,10000,I4
,1);
6224 VARANDCY(I4
,-1,0,I4
,0);
6225 VARANDCY(I4
,0,0,I4
,0);
6227 VARAND(UI4
,0xffffffff,UI4
,0xffffffff,I4
,-1);
6228 VARAND(UI4
,0xffffffff,UI4
,0,I4
,0);
6229 VARAND(UI4
,0,UI4
,0,I4
,0);
6230 VARAND(UI4
,0xffffffff,R4
,-1,I4
,-1);
6231 VARAND(UI4
,0xffffffff,R4
,0,I4
,0);
6232 VARAND(UI4
,0,R4
,0,I4
,0);
6233 VARAND(UI4
,0xffffffff,R8
,-1,I4
,-1);
6234 VARAND(UI4
,0xffffffff,R8
,0,I4
,0);
6235 VARAND(UI4
,0,R8
,0,I4
,0);
6236 VARAND(UI4
,0xffffffff,DATE
,-1,I4
,-1);
6237 VARAND(UI4
,0xffffffff,DATE
,0,I4
,0);
6238 VARAND(UI4
,0,DATE
,0,I4
,0);
6241 VARAND(UI4
,0xffffffff,I8
,0,I8
,0);
6242 VARAND(UI4
,0,I8
,0,I8
,0);
6243 VARAND(UI4
,0xffffffff,UI8
,0,I4
,0);
6244 VARAND(UI4
,0,UI8
,0,I4
,0);
6246 VARAND(UI4
,0xffffffff,INT
,-1,I4
,-1);
6247 VARAND(UI4
,0xffffffff,INT
,0,I4
,0);
6248 VARAND(UI4
,0,INT
,0,I4
,0);
6249 VARAND(UI4
,0xffffffff,UINT
,0xffffffff,I4
,-1);
6250 VARAND(UI4
,0xffffffff,UINT
,0,I4
,0);
6251 VARAND(UI4
,0,UINT
,0,I4
,0);
6252 VARAND(UI4
,0,BSTR
,false_str
,I4
,0);
6253 VARAND(UI4
,0xffffffff,BSTR
,false_str
,I4
,0);
6254 VARAND(UI4
,0,BSTR
,true_str
,I4
,0);
6255 VARAND(UI4
,0xffffffff,BSTR
,true_str
,I4
,-1);
6256 VARANDCY(UI4
,0xffffffff,10000,I4
,1);
6257 VARANDCY(UI4
,0xffffffff,0,I4
,0);
6258 VARANDCY(UI4
,0,0,I4
,0);
6260 VARAND(R4
,-1,R4
,-1,I4
,-1);
6261 VARAND(R4
,-1,R4
,0,I4
,0);
6262 VARAND(R4
,0,R4
,0,I4
,0);
6263 VARAND(R4
,-1,R8
,-1,I4
,-1);
6264 VARAND(R4
,-1,R8
,0,I4
,0);
6265 VARAND(R4
,0,R8
,0,I4
,0);
6266 VARAND(R4
,-1,DATE
,-1,I4
,-1);
6267 VARAND(R4
,-1,DATE
,0,I4
,0);
6268 VARAND(R4
,0,DATE
,0,I4
,0);
6271 VARAND(R4
,-1,I8
,-1,I8
,-1);
6272 VARAND(R4
,-1,I8
,0,I8
,0);
6273 VARAND(R4
,0,I8
,0,I8
,0);
6274 VARAND(R4
,-1,UI8
,0,I4
,0);
6275 VARAND(R4
,0,UI8
,0,I4
,0);
6277 VARAND(R4
,-1,INT
,-1,I4
,-1);
6278 VARAND(R4
,-1,INT
,0,I4
,0);
6279 VARAND(R4
,0,INT
,0,I4
,0);
6280 VARAND(R4
,-1,UINT
,0xffffffff,I4
,-1);
6281 VARAND(R4
,-1,UINT
,0,I4
,0);
6282 VARAND(R4
,0,UINT
,0,I4
,0);
6283 VARAND(R4
,0,BSTR
,false_str
,I4
,0);
6284 VARAND(R4
,-1,BSTR
,false_str
,I4
,0);
6285 VARAND(R4
,0,BSTR
,true_str
,I4
,0);
6286 VARAND(R4
,-1,BSTR
,true_str
,I4
,-1);
6287 VARANDCY(R4
,-1,10000,I4
,1);
6288 VARANDCY(R4
,-1,0,I4
,0);
6289 VARANDCY(R4
,0,0,I4
,0);
6291 VARAND(R8
,-1,R8
,-1,I4
,-1);
6292 VARAND(R8
,-1,R8
,0,I4
,0);
6293 VARAND(R8
,0,R8
,0,I4
,0);
6294 VARAND(R8
,-1,DATE
,-1,I4
,-1);
6295 VARAND(R8
,-1,DATE
,0,I4
,0);
6296 VARAND(R8
,0,DATE
,0,I4
,0);
6299 VARAND(R8
,-1,I8
,-1,I8
,-1);
6300 VARAND(R8
,-1,I8
,0,I8
,0);
6301 VARAND(R8
,0,I8
,0,I8
,0);
6302 VARAND(R8
,-1,UI8
,0,I4
,0);
6303 VARAND(R8
,0,UI8
,0,I4
,0);
6305 VARAND(R8
,-1,INT
,-1,I4
,-1);
6306 VARAND(R8
,-1,INT
,0,I4
,0);
6307 VARAND(R8
,0,INT
,0,I4
,0);
6308 VARAND(R8
,-1,UINT
,0xffffffff,I4
,-1);
6309 VARAND(R8
,-1,UINT
,0,I4
,0);
6310 VARAND(R8
,0,UINT
,0,I4
,0);
6311 VARAND(R8
,0,BSTR
,false_str
,I4
,0);
6312 VARAND(R8
,-1,BSTR
,false_str
,I4
,0);
6313 VARAND(R8
,0,BSTR
,true_str
,I4
,0);
6314 VARAND(R8
,-1,BSTR
,true_str
,I4
,-1);
6315 VARANDCY(R8
,-1,10000,I4
,1);
6316 VARANDCY(R8
,-1,0,I4
,0);
6317 VARANDCY(R8
,0,0,I4
,0);
6319 VARAND(DATE
,-1,DATE
,-1,I4
,-1);
6320 VARAND(DATE
,-1,DATE
,0,I4
,0);
6321 VARAND(DATE
,0,DATE
,0,I4
,0);
6324 VARAND(DATE
,-1,I8
,-1,I8
,-1);
6325 VARAND(DATE
,-1,I8
,0,I8
,0);
6326 VARAND(DATE
,0,I8
,0,I8
,0);
6327 VARAND(DATE
,-1,UI8
,0,I4
,0);
6328 VARAND(DATE
,0,UI8
,0,I4
,0);
6330 VARAND(DATE
,-1,INT
,-1,I4
,-1);
6331 VARAND(DATE
,-1,INT
,0,I4
,0);
6332 VARAND(DATE
,0,INT
,0,I4
,0);
6333 VARAND(DATE
,-1,UINT
,0xffffffff,I4
,-1);
6334 VARAND(DATE
,-1,UINT
,0,I4
,0);
6335 VARAND(DATE
,0,UINT
,0,I4
,0);
6336 VARAND(DATE
,0,BSTR
,false_str
,I4
,0);
6337 VARAND(DATE
,-1,BSTR
,false_str
,I4
,0);
6338 VARAND(DATE
,0,BSTR
,true_str
,I4
,0);
6339 VARAND(DATE
,-1,BSTR
,true_str
,I4
,-1);
6340 VARANDCY(DATE
,-1,10000,I4
,1);
6341 VARANDCY(DATE
,-1,0,I4
,0);
6342 VARANDCY(DATE
,0,0,I4
,0);
6346 VARAND(I8
,-1,I8
,-1,I8
,-1);
6347 VARAND(I8
,-1,I8
,0,I8
,0);
6348 VARAND(I8
,0,I8
,0,I8
,0);
6349 VARAND(I8
,-1,UI8
,0,I8
,0);
6350 VARAND(I8
,0,UI8
,0,I8
,0);
6351 VARAND(I8
,-1,UINT
,0,I8
,0);
6352 VARAND(I8
,0,UINT
,0,I8
,0);
6353 VARAND(I8
,0,BSTR
,false_str
,I8
,0);
6354 VARAND(I8
,-1,BSTR
,false_str
,I8
,0);
6355 VARAND(I8
,0,BSTR
,true_str
,I8
,0);
6356 VARAND(I8
,-1,BSTR
,true_str
,I8
,-1);
6357 VARANDCY(I8
,-1,10000,I8
,1);
6358 VARANDCY(I8
,-1,0,I8
,0);
6359 VARANDCY(I8
,0,0,I8
,0);
6361 VARAND(UI8
,0xffff,UI8
,0xffff,I4
,0xffff);
6362 VARAND(UI8
,0xffff,UI8
,0,I4
,0);
6363 VARAND(UI8
,0,UI8
,0,I4
,0);
6364 VARAND(UI8
,0xffff,INT
,-1,I4
,65535);
6365 VARAND(UI8
,0xffff,INT
,0,I4
,0);
6366 VARAND(UI8
,0,INT
,0,I4
,0);
6367 VARAND(UI8
,0xffff,UINT
,0xffff,I4
,0xffff);
6368 VARAND(UI8
,0xffff,UINT
,0,I4
,0);
6369 VARAND(UI8
,0,UINT
,0,I4
,0);
6370 VARAND(UI8
,0,BSTR
,false_str
,I4
,0);
6371 VARAND(UI8
,0xffff,BSTR
,false_str
,I4
,0);
6372 VARAND(UI8
,0,BSTR
,true_str
,I4
,0);
6373 VARAND(UI8
,0xffff,BSTR
,true_str
,I4
,65535);
6374 VARANDCY(UI8
,0xffff,10000,I4
,1);
6375 VARANDCY(UI8
,0xffff,0,I4
,0);
6376 VARANDCY(UI8
,0,0,I4
,0);
6379 VARAND(INT
,-1,INT
,-1,I4
,-1);
6380 VARAND(INT
,-1,INT
,0,I4
,0);
6381 VARAND(INT
,0,INT
,0,I4
,0);
6382 VARAND(INT
,-1,UINT
,0xffff,I4
,65535);
6383 VARAND(INT
,-1,UINT
,0,I4
,0);
6384 VARAND(INT
,0,UINT
,0,I4
,0);
6385 VARAND(INT
,0,BSTR
,false_str
,I4
,0);
6386 VARAND(INT
,-1,BSTR
,false_str
,I4
,0);
6387 VARAND(INT
,0,BSTR
,true_str
,I4
,0);
6388 VARAND(INT
,-1,BSTR
,true_str
,I4
,-1);
6389 VARANDCY(INT
,-1,10000,I4
,1);
6390 VARANDCY(INT
,-1,0,I4
,0);
6391 VARANDCY(INT
,0,0,I4
,0);
6393 VARAND(UINT
,0xffff,UINT
,0xffff,I4
,0xffff);
6394 VARAND(UINT
,0xffff,UINT
,0,I4
,0);
6395 VARAND(UINT
,0,UINT
,0,I4
,0);
6396 VARAND(UINT
,0,BSTR
,false_str
,I4
,0);
6397 VARAND(UINT
,0xffff,BSTR
, false_str
,I4
,0);
6398 VARAND(UINT
,0,BSTR
,true_str
,I4
,0);
6399 VARAND(UINT
,0xffff,BSTR
,true_str
,I4
,65535);
6400 VARANDCY(UINT
,0xffff,10000,I4
,1);
6401 VARANDCY(UINT
,0xffff,0,I4
,0);
6402 VARANDCY(UINT
,0,0,I4
,0);
6404 VARAND(BSTR
,false_str
,BSTR
,false_str
,BOOL
,0);
6405 VARAND(BSTR
,true_str
,BSTR
,false_str
,BOOL
,VARIANT_FALSE
);
6406 VARAND(BSTR
,true_str
,BSTR
,true_str
,BOOL
,VARIANT_TRUE
);
6407 VARANDCY(BSTR
,true_str
,10000,I4
,1);
6408 VARANDCY(BSTR
,false_str
,10000,I4
,0);
6410 SysFreeString(true_str
);
6411 SysFreeString(false_str
);
6414 static void test_cmp( int line
, LCID lcid
, UINT flags
, VARIANT
*left
, VARIANT
*right
, HRESULT result
)
6420 hres
= pVarCmp(left
,right
,lcid
,flags
);
6421 ok_(__FILE__
,line
)(hres
== result
, "VarCmp(%s,%s): expected 0x%x, got hres=0x%x\n",
6422 variantstr(left
), variantstr(right
), result
, hres
);
6424 static void test_cmpex( int line
, LCID lcid
, VARIANT
*left
, VARIANT
*right
,
6425 HRESULT res1
, HRESULT res2
, HRESULT res3
, HRESULT res4
)
6427 test_cmp( line
, lcid
, 0, left
, right
, res1
);
6428 V_VT(left
) |= VT_RESERVED
;
6429 test_cmp( line
, lcid
, 0, left
, right
, res2
);
6430 V_VT(left
) &= ~VT_RESERVED
;
6431 V_VT(right
) |= VT_RESERVED
;
6432 test_cmp( line
, lcid
, 0, left
, right
, res3
);
6433 V_VT(left
) |= VT_RESERVED
;
6434 test_cmp( line
, lcid
, 0, left
, right
, res4
);
6435 ok_(__FILE__
,line
)(V_VT(left
) & V_VT(right
) & VT_RESERVED
, "VT_RESERVED filtered out\n");
6438 /* ERROR from wingdi.h is interfering here */
6440 #define _VARCMP(vt1,val1,vtfl1,vt2,val2,vtfl2,lcid,flags,result) \
6441 V_##vt1(&left) = val1; V_VT(&left) = VT_##vt1 | vtfl1; \
6442 V_##vt2(&right) = val2; V_VT(&right) = VT_##vt2 | vtfl2; \
6443 test_cmp( __LINE__, lcid, flags, &left, &right, result )
6444 #define VARCMPEX(vt1,val1,vt2,val2,res1,res2,res3,res4) \
6445 V_##vt1(&left) = val1; V_VT(&left) = VT_##vt1; \
6446 V_##vt2(&right) = val2; V_VT(&right) = VT_##vt2; \
6447 test_cmpex( __LINE__, lcid, &left, &right, res1, res2, res3, res4 )
6448 #define VARCMP(vt1,val1,vt2,val2,result) \
6449 VARCMPEX(vt1,val1,vt2,val2,result,result,result,result)
6450 /* The above macros do not work for VT_NULL as NULL gets expanded first */
6451 #define V_NULL_ V_NULL
6452 #define VT_NULL_ VT_NULL
6454 static void test_VarCmp(void)
6456 VARIANT left
, right
;
6461 static const WCHAR szhuh
[] = {'h','u','h','?','\0'};
6462 static const WCHAR sz2cents
[] = {'2','c','e','n','t','s','\0'};
6463 static const WCHAR szempty
[] = {'\0'};
6464 static const WCHAR sz0
[] = {'0','\0'};
6465 static const WCHAR sz1
[] = {'1','\0'};
6466 static const WCHAR sz7
[] = {'7','\0'};
6467 static const WCHAR sz42
[] = {'4','2','\0'};
6468 static const WCHAR sz1neg
[] = {'-','1','\0'};
6469 static const WCHAR sz666neg
[] = {'-','6','6','6','\0'};
6470 static const WCHAR sz1few
[] = {'1','.','0','0','0','0','0','0','0','1','\0'};
6471 BSTR bstrhuh
, bstrempty
, bstr0
, bstr1
, bstr7
, bstr42
, bstr1neg
, bstr666neg
;
6472 BSTR bstr2cents
, bstr1few
;
6476 lcid
= MAKELCID(MAKELANGID(LANG_ENGLISH
,SUBLANG_ENGLISH_US
),SORT_DEFAULT
);
6477 bstrempty
= SysAllocString(szempty
);
6478 bstrhuh
= SysAllocString(szhuh
);
6479 bstr2cents
= SysAllocString(sz2cents
);
6480 bstr0
= SysAllocString(sz0
);
6481 bstr1
= SysAllocString(sz1
);
6482 bstr7
= SysAllocString(sz7
);
6483 bstr42
= SysAllocString(sz42
);
6484 bstr1neg
= SysAllocString(sz1neg
);
6485 bstr666neg
= SysAllocString(sz666neg
);
6486 bstr1few
= SysAllocString(sz1few
);
6488 /* Test all possible flag/vt combinations & the resulting vt type */
6489 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
6491 VARTYPE leftvt
, rightvt
;
6493 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
6498 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
6501 HRESULT expect
= VARCMP_EQ
;
6505 memset(&left
, 0, sizeof(left
));
6506 memset(&right
, 0, sizeof(right
));
6507 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
6508 if (leftvt
== VT_BSTR
) {
6509 V_BSTR(&left
) = bstr1neg
;
6510 if (ExtraFlags
[i
] & VT_RESERVED
)
6515 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
6516 if (rightvt
== VT_BSTR
) {
6517 V_BSTR(&right
) = bstr1neg
;
6518 if (ExtraFlags
[i
] & VT_RESERVED
)
6524 /* Don't ask me why but native VarCmp cannot handle:
6525 VT_I1, VT_UI2, VT_UI4, VT_UINT and VT_UI8.
6526 VT_INT is only supported as left variant. Go figure.
6527 Tested with DCOM98, Win2k, WinXP */
6528 if (ExtraFlags
[i
] & VT_ARRAY
|| ExtraFlags
[i
] & VT_BYREF
||
6529 !IsValidVariantClearVT(leftvt
, ExtraFlags
[i
] & ~VT_RESERVED
) ||
6530 !IsValidVariantClearVT(rightvt
, ExtraFlags
[i
] & ~VT_RESERVED
) ||
6531 leftvt
== VT_CLSID
|| rightvt
== VT_CLSID
||
6532 leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
||
6533 leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
||
6534 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
||
6535 leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
||
6536 leftvt
== VT_VARIANT
|| rightvt
== VT_VARIANT
||
6537 leftvt
== VT_I1
|| rightvt
== VT_I1
||
6538 leftvt
== VT_UI2
|| rightvt
== VT_UI2
||
6539 leftvt
== VT_UI4
|| rightvt
== VT_UI4
||
6540 leftvt
== VT_UI8
|| rightvt
== VT_UI8
||
6541 rightvt
== VT_INT
||
6542 leftvt
== VT_UINT
|| rightvt
== VT_UINT
) {
6546 if (leftvt
== VT_ERROR
&& rightvt
== VT_ERROR
&&
6547 !(ExtraFlags
[i
] & ~VT_RESERVED
)) {
6550 } else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
6551 expect
= VARCMP_NULL
;
6552 else if (leftvt
== VT_BSTR
&& rightvt
== VT_BSTR
)
6554 else if (leftvt
== VT_BSTR
&& rightvt
== VT_EMPTY
)
6556 else if (leftvt
== VT_EMPTY
&& rightvt
== VT_BSTR
)
6559 hres
= pVarCmp(&left
, &right
, LOCALE_USER_DEFAULT
, 0);
6561 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
6562 "VarCmp: %d|0x%X, %d|0x%X: Expected failure, got 0x%X\n",
6563 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], hres
);
6566 "VarCmp: %d|0x%X, %d|0x%X: Expected 0x%X, got 0x%X\n",
6567 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], expect
,
6574 /* VARCMP{,EX} run each 4 tests with a permutation of all possible
6575 input variants with (1) and without (0) VT_RESERVED set. The order
6576 of the permutations is (0,0); (1,0); (0,1); (1,1) */
6577 VARCMP(INT
,4711,I2
,4711,VARCMP_EQ
);
6578 VARCMP(INT
,4711,I2
,-4711,VARCMP_GT
);
6579 VARCMP(ERROR
,0,ERROR
,0,VARCMP_EQ
);
6580 VARCMP(ERROR
,0,UI1
,0,DISP_E_TYPEMISMATCH
);
6581 VARCMP(EMPTY
,0,EMPTY
,0,VARCMP_EQ
);
6582 VARCMP(I4
,1,R8
,1.0,VARCMP_EQ
);
6583 VARCMP(EMPTY
,19,I2
,0,VARCMP_EQ
);
6584 ok(V_EMPTY(&left
) == 19, "VT_EMPTY modified!\n");
6585 VARCMP(I4
,1,UI1
,1,VARCMP_EQ
);
6586 VARCMP(I2
,2,I2
,2,VARCMP_EQ
);
6587 VARCMP(I2
,1,I2
,2,VARCMP_LT
);
6588 VARCMP(I2
,2,I2
,1,VARCMP_GT
);
6589 VARCMP(I2
,2,EMPTY
,1,VARCMP_GT
);
6590 VARCMP(I2
,2,NULL_
,1,VARCMP_NULL
);
6592 /* BSTR handling, especially in conjunction with VT_RESERVED */
6593 VARCMP(BSTR
,bstr0
,NULL_
,0,VARCMP_NULL
);
6594 VARCMP(BSTR
,bstr0
,BSTR
,bstr0
,VARCMP_EQ
);
6595 VARCMP(BSTR
,bstrempty
,BSTR
,bstr0
,VARCMP_LT
);
6596 VARCMP(BSTR
,bstr7
,BSTR
,bstr0
,VARCMP_GT
);
6597 VARCMP(BSTR
,bstr7
,BSTR
,bstr1neg
,VARCMP_GT
);
6598 VARCMP(BSTR
,bstr0
,BSTR
,NULL
,VARCMP_GT
);
6599 VARCMP(BSTR
,NULL
,BSTR
,NULL
,VARCMP_EQ
);
6600 VARCMP(BSTR
,bstrempty
,BSTR
,NULL
,VARCMP_EQ
);
6601 VARCMP(BSTR
,NULL
,EMPTY
,0,VARCMP_EQ
);
6602 VARCMP(EMPTY
,0,BSTR
,NULL
,VARCMP_EQ
);
6603 VARCMP(EMPTY
,0,BSTR
,bstrempty
,VARCMP_EQ
);
6604 VARCMP(EMPTY
,1,BSTR
,bstrempty
,VARCMP_EQ
);
6605 VARCMP(BSTR
,bstr0
,EMPTY
,0,VARCMP_GT
);
6606 VARCMP(BSTR
,bstr42
,EMPTY
,0,VARCMP_GT
);
6607 VARCMPEX(BSTR
,bstrempty
,UI1
,0,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
6608 VARCMPEX(BSTR
,bstrempty
,I2
,-1,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
6609 VARCMPEX(I4
,0,BSTR
,bstrempty
,VARCMP_LT
,VARCMP_LT
,VARCMP_GT
,VARCMP_LT
);
6610 VARCMPEX(BSTR
,NULL
,UI1
,0,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
6611 VARCMPEX(I4
,7,BSTR
,NULL
,VARCMP_LT
,VARCMP_LT
,VARCMP_GT
,VARCMP_LT
);
6612 _VARCMP(BSTR
,(BSTR
)100,0,I2
,100,0,lcid
,0,VARCMP_GT
);
6613 VARCMPEX(BSTR
,bstr0
,UI1
,0,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_GT
);
6614 VARCMPEX(I2
,0,BSTR
,bstr0
,VARCMP_LT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_LT
);
6615 VARCMP(BSTR
,bstrhuh
,I4
,I4_MAX
,VARCMP_GT
);
6616 VARCMP(BSTR
,bstr2cents
,I4
,2,VARCMP_GT
);
6617 VARCMPEX(BSTR
,bstr2cents
,I4
,42,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
6618 VARCMP(BSTR
,bstr2cents
,I4
,-1,VARCMP_GT
);
6619 VARCMPEX(BSTR
,bstr2cents
,I4
,-666,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
6620 VARCMPEX(BSTR
,bstr0
,I2
,0,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_GT
);
6621 VARCMPEX(BSTR
,bstr0
,I4
,0,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_GT
);
6622 VARCMPEX(BSTR
,bstr0
,I4
,-666,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
6623 VARCMP(BSTR
,bstr1
,I4
,0,VARCMP_GT
);
6624 VARCMPEX(BSTR
,bstr1
,I4
,1,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_GT
);
6625 VARCMPEX(BSTR
,bstr1
,I4
,I4_MAX
,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
,VARCMP_GT
);
6626 VARCMPEX(BSTR
,bstr1
,I4
,-1,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
6627 VARCMP(BSTR
,bstr7
,I4
,1,VARCMP_GT
);
6628 VARCMPEX(BSTR
,bstr7
,I4
,7,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_GT
);
6629 VARCMPEX(BSTR
,bstr7
,I4
,42,VARCMP_GT
,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
);
6630 VARCMPEX(BSTR
,bstr42
,I4
,7,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
6631 VARCMPEX(BSTR
,bstr42
,I4
,42,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_GT
);
6632 VARCMPEX(BSTR
,bstr42
,I4
,I4_MAX
,VARCMP_GT
,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
);
6633 VARCMPEX(BSTR
,bstr1neg
,I4
,1,VARCMP_GT
,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
);
6634 VARCMPEX(BSTR
,bstr1neg
,I4
,42,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
,VARCMP_LT
);
6635 VARCMPEX(BSTR
,bstr1neg
,I4
,-1,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_LT
);
6636 VARCMPEX(BSTR
,bstr1neg
,I4
,-666,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_LT
);
6637 VARCMPEX(BSTR
,bstr666neg
,I4
,1,VARCMP_GT
,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
);
6638 VARCMPEX(BSTR
,bstr666neg
,I4
,7,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
,VARCMP_LT
);
6639 VARCMPEX(BSTR
,bstr666neg
,I4
,42,VARCMP_GT
,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
);
6640 VARCMPEX(BSTR
,bstr666neg
,I4
,I4_MAX
,VARCMP_GT
,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
);
6641 VARCMPEX(BSTR
,bstr666neg
,I4
,-1,VARCMP_GT
,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
);
6642 VARCMPEX(BSTR
,bstr666neg
,I4
,-666,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_LT
);
6643 VARCMPEX(BSTR
,bstr7
,R8
,7.0,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_GT
);
6644 VARCMPEX(R8
,3.141592,BSTR
,NULL
,VARCMP_LT
,VARCMP_LT
,VARCMP_GT
,VARCMP_LT
);
6645 VARCMP(BSTR
,bstr7
,BSTR
,bstr7
,VARCMP_EQ
);
6646 VARCMP(BSTR
,bstr7
,BSTR
,bstr42
,VARCMP_GT
);
6647 VARCMP(BSTR
,bstr42
,BSTR
,bstr7
,VARCMP_LT
);
6649 /* DECIMAL handling */
6650 setdec(&dec
,0,0,0,0);
6651 VARCMPEX(DECIMAL
,dec
,BSTR
,bstr0
,VARCMP_LT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_LT
);
6652 setdec64(&dec
,0,0,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF); /* max DECIMAL */
6653 VARCMP(DECIMAL
,dec
,R8
,R8_MAX
,VARCMP_LT
); /* R8 has bigger range */
6654 VARCMP(DECIMAL
,dec
,DATE
,R8_MAX
,VARCMP_LT
); /* DATE has bigger range */
6655 setdec64(&dec
,0,0x80,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF);
6656 VARCMP(DECIMAL
,dec
,R8
,-R8_MAX
,VARCMP_GT
);
6657 setdec64(&dec
,20,0,0x5,0x6BC75E2D,0x63100001); /* 1+1e-20 */
6658 VARCMP(DECIMAL
,dec
,R8
,1,VARCMP_GT
); /* DECIMAL has higher precision */
6660 /* Show that DATE is handled just as a R8 */
6661 VARCMP(DATE
,DATE_MAX
,DATE
,DATE_MAX
+1,VARCMP_LT
);
6662 VARCMP(DATE
,DATE_MIN
,DATE
,DATE_MIN
-1,VARCMP_GT
);
6663 VARCMP(DATE
,R8_MIN
,R8
,R8_MIN
,VARCMP_EQ
);
6664 VARCMP(DATE
,1,DATE
,1+1e-15,VARCMP_LT
); /* 1e-15 == 8.64e-11 seconds */
6665 VARCMP(DATE
,25570.0,DATE
,25570.0,VARCMP_EQ
);
6666 VARCMP(DATE
,25570.0,DATE
,25571.0,VARCMP_LT
);
6667 VARCMP(DATE
,25571.0,DATE
,25570.0,VARCMP_GT
);
6668 VARCMP(DATE
,25570.0,EMPTY
,0,VARCMP_GT
);
6669 VARCMP(DATE
,25570.0,NULL_
,0,VARCMP_NULL
);
6671 /* R4 precision handling */
6672 VARCMP(R4
,1,R8
,1+1e-8,VARCMP_EQ
);
6673 VARCMP(R8
,1+1e-8,R4
,1,VARCMP_EQ
);
6674 VARCMP(R8
,1+1e-8,R8
,1,VARCMP_GT
);
6675 VARCMP(R8
,R4_MAX
*1.1,R4
,R4_MAX
,VARCMP_GT
);
6676 VARCMP(R4
,R4_MAX
,R8
,R8_MAX
,VARCMP_LT
);
6677 VARCMP(R4
,1,DATE
,1+1e-8,VARCMP_EQ
);
6678 VARCMP(R4
,1,BSTR
,bstr1few
,VARCMP_LT
); /* bstr1few == 1+1e-8 */
6679 setdec(&dec
,8,0,0,0x5F5E101); /* 1+1e-8 */
6680 VARCMP(R4
,1,DECIMAL
,dec
,VARCMP_LT
);
6682 SysFreeString(bstrhuh
);
6683 SysFreeString(bstrempty
);
6684 SysFreeString(bstr0
);
6685 SysFreeString(bstr1
);
6686 SysFreeString(bstr7
);
6687 SysFreeString(bstr42
);
6688 SysFreeString(bstr1neg
);
6689 SysFreeString(bstr666neg
);
6690 SysFreeString(bstr2cents
);
6691 SysFreeString(bstr1few
);
6694 static HRESULT (WINAPI
*pVarPow
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
6696 #define VARPOW(vt1,val1,vt2,val2,rvt,rval) \
6697 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
6698 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
6699 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
6700 test_var_call2( __LINE__, pVarPow, &left, &right, &exp )
6702 /* Skip any type that is not defined or produces an error for every case */
6703 #define SKIPTESTPOW(a) \
6704 if (a == VT_ERROR || a == VT_VARIANT || \
6705 a == VT_DISPATCH || a == VT_UNKNOWN || \
6706 a == VT_RECORD || a > VT_UINT || \
6707 a == 15 /*not defined*/) \
6710 static void test_VarPow(void)
6712 static const WCHAR str2
[] = { '2','\0' };
6713 static const WCHAR str3
[] = { '3','\0' };
6714 VARIANT left
, right
, exp
, result
, cy
, dec
;
6715 BSTR num2_str
, num3_str
;
6721 num2_str
= SysAllocString(str2
);
6722 num3_str
= SysAllocString(str3
);
6724 /* Test all possible flag/vt combinations & the resulting vt type */
6725 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
6727 VARTYPE leftvt
, rightvt
, resvt
;
6729 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
6731 SKIPTESTPOW(leftvt
);
6733 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
6736 SKIPTESTPOW(rightvt
);
6738 /* Native crashes with VT_BYREF */
6739 if (ExtraFlags
[i
] == VT_BYREF
)
6742 memset(&left
, 0, sizeof(left
));
6743 memset(&right
, 0, sizeof(right
));
6744 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
6745 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
6746 V_VT(&result
) = VT_EMPTY
;
6749 if (leftvt
== VT_BSTR
)
6750 V_BSTR(&left
) = num2_str
;
6751 if (rightvt
== VT_BSTR
)
6752 V_BSTR(&right
) = num2_str
;
6754 /* Native VarPow always returns an error when using extra flags */
6755 if (ExtraFlags
[i
] != 0)
6758 /* Determine return type */
6759 else if ((leftvt
== VT_NULL
|| rightvt
== VT_NULL
) &&
6760 ((leftvt
!= VT_I8
&& leftvt
!= VT_UI8
&&
6761 rightvt
!= VT_I8
&& rightvt
!= VT_UI8
) || has_i8
))
6763 else if ((leftvt
== VT_EMPTY
|| leftvt
== VT_I2
||
6764 leftvt
== VT_I4
|| leftvt
== VT_R4
||
6765 leftvt
== VT_R8
|| leftvt
== VT_CY
||
6766 leftvt
== VT_DATE
|| leftvt
== VT_BSTR
||
6767 leftvt
== VT_BOOL
|| leftvt
== VT_DECIMAL
||
6768 (leftvt
>= VT_I1
&& leftvt
<= VT_UI4
) ||
6769 (has_i8
&& (leftvt
== VT_I8
|| leftvt
== VT_UI8
)) ||
6770 leftvt
== VT_INT
|| leftvt
== VT_UINT
) &&
6771 (rightvt
== VT_EMPTY
|| rightvt
== VT_I2
||
6772 rightvt
== VT_I4
|| rightvt
== VT_R4
||
6773 rightvt
== VT_R8
|| rightvt
== VT_CY
||
6774 rightvt
== VT_DATE
|| rightvt
== VT_BSTR
||
6775 rightvt
== VT_BOOL
|| rightvt
== VT_DECIMAL
||
6776 (rightvt
>= VT_I1
&& rightvt
<= VT_UI4
) ||
6777 (has_i8
&& (rightvt
== VT_I8
|| rightvt
== VT_UI8
)) ||
6778 rightvt
== VT_INT
|| rightvt
== VT_UINT
))
6783 hres
= pVarPow(&left
, &right
, &result
);
6785 /* Check expected HRESULT and if result variant type is correct */
6787 ok (hres
== DISP_E_BADVARTYPE
|| hres
== DISP_E_TYPEMISMATCH
,
6788 "VarPow: %s|0x%X, %s|0x%X: got vt %s hr 0x%X\n",
6789 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
],
6790 vtstr(V_VT(&result
)), hres
);
6792 ok (hres
== S_OK
&& resvt
== V_VT(&result
),
6793 "VarPow: %s|0x%X, %s|0x%X: expected vt %s hr 0x%X, got vt %s hr 0x%X\n",
6794 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
], vtstr(resvt
),
6795 S_OK
, vtstr(V_VT(&result
)), hres
);
6800 /* Check return values for valid variant type combinations */
6801 VARPOW(EMPTY
,0,EMPTY
,0,R8
,1.0);
6802 VARPOW(EMPTY
,0,NULL
,0,NULL
,0);
6803 VARPOW(EMPTY
,0,I2
,3,R8
,0.0);
6804 VARPOW(EMPTY
,0,I4
,3,R8
,0.0);
6805 VARPOW(EMPTY
,0,R4
,3.0f
,R8
,0.0);
6806 VARPOW(EMPTY
,0,R8
,3.0,R8
,0.0);
6807 VARPOW(EMPTY
,0,DATE
,3,R8
,0.0);
6808 VARPOW(EMPTY
,0,BSTR
,num3_str
,R8
,0.0);
6809 VARPOW(EMPTY
,0,BOOL
,VARIANT_FALSE
,R8
,1.0);
6810 VARPOW(EMPTY
,0,I1
,3,R8
,0.0);
6811 VARPOW(EMPTY
,0,UI1
,3,R8
,0.0);
6812 VARPOW(EMPTY
,0,UI2
,3,R8
,0.0);
6813 VARPOW(EMPTY
,0,UI4
,3,R8
,0.0);
6816 VARPOW(EMPTY
,0,I8
,3,R8
,0.0);
6817 VARPOW(EMPTY
,0,UI8
,3,R8
,0.0);
6819 VARPOW(EMPTY
,0,INT
,3,R8
,0.0);
6820 VARPOW(EMPTY
,0,UINT
,3,R8
,0.0);
6821 VARPOW(NULL
,0,EMPTY
,0,NULL
,0);
6822 VARPOW(NULL
,0,NULL
,0,NULL
,0);
6823 VARPOW(NULL
,0,I2
,3,NULL
,0);
6824 VARPOW(NULL
,0,I4
,3,NULL
,0);
6825 VARPOW(NULL
,0,R4
,3.0f
,NULL
,0);
6826 VARPOW(NULL
,0,R8
,3.0,NULL
,0);
6827 VARPOW(NULL
,0,DATE
,3,NULL
,0);
6828 VARPOW(NULL
,0,BSTR
,num3_str
,NULL
,0);
6829 VARPOW(NULL
,0,BOOL
,VARIANT_TRUE
,NULL
,0);
6830 VARPOW(NULL
,0,I1
,3,NULL
,0);
6831 VARPOW(NULL
,0,UI1
,3,NULL
,0);
6832 VARPOW(NULL
,0,UI2
,3,NULL
,0);
6833 VARPOW(NULL
,0,UI4
,3,NULL
,0);
6836 VARPOW(NULL
,0,I8
,3,NULL
,0);
6837 VARPOW(NULL
,0,UI8
,3,NULL
,0);
6839 VARPOW(NULL
,0,INT
,3,NULL
,0);
6840 VARPOW(NULL
,0,UINT
,3,NULL
,0);
6841 VARPOW(I2
,2,EMPTY
,0,R8
,1.0);
6842 VARPOW(I2
,2,NULL
,0,NULL
,0);
6843 VARPOW(I2
,2,I2
,3,R8
,8.0);
6844 VARPOW(I2
,2,I4
,3,R8
,8.0);
6845 VARPOW(I2
,2,R4
,3.0f
,R8
,8.0);
6846 VARPOW(I2
,2,R8
,3.0,R8
,8.0);
6847 VARPOW(I2
,2,DATE
,3,R8
,8.0);
6848 VARPOW(I2
,2,BSTR
,num3_str
,R8
,8.0);
6849 VARPOW(I2
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6850 VARPOW(I2
,2,I1
,3,R8
,8.0);
6851 VARPOW(I2
,2,UI1
,3,R8
,8.0);
6852 VARPOW(I2
,2,UI2
,3,R8
,8.0);
6853 VARPOW(I2
,2,UI4
,3,R8
,8.0);
6856 VARPOW(I2
,2,I8
,3,R8
,8.0);
6857 VARPOW(I2
,2,UI8
,3,R8
,8.0);
6859 VARPOW(I2
,2,INT
,3,R8
,8.0);
6860 VARPOW(I2
,2,UINT
,3,R8
,8.0);
6861 VARPOW(I4
,2,EMPTY
,0,R8
,1.0);
6862 VARPOW(I4
,2,NULL
,0,NULL
,0);
6863 VARPOW(I4
,2,I2
,3,R8
,8.0);
6864 VARPOW(I4
,2,I4
,3,R8
,8.0);
6865 VARPOW(I4
,2,R4
,3.0f
,R8
,8.0);
6866 VARPOW(I4
,2,R8
,3.0,R8
,8.0);
6867 VARPOW(I4
,2,DATE
,3,R8
,8.0);
6868 VARPOW(I4
,2,BSTR
,num3_str
,R8
,8.0);
6869 VARPOW(I4
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6870 VARPOW(I4
,2,I1
,3,R8
,8.0);
6871 VARPOW(I4
,2,UI1
,3,R8
,8.0);
6872 VARPOW(I4
,2,UI2
,3,R8
,8.0);
6873 VARPOW(I4
,2,UI4
,3,R8
,8.0);
6876 VARPOW(I4
,2,I8
,3,R8
,8.0);
6877 VARPOW(I4
,2,UI8
,3,R8
,8.0);
6879 VARPOW(I4
,2,INT
,3,R8
,8.0);
6880 VARPOW(I4
,2,UINT
,3,R8
,8.0);
6881 VARPOW(R4
,2,EMPTY
,0,R8
,1.0);
6882 VARPOW(R4
,2,NULL
,0,NULL
,0);
6883 VARPOW(R4
,2,I2
,3,R8
,8.0);
6884 VARPOW(R4
,2,I4
,3,R8
,8.0);
6885 VARPOW(R4
,2,R4
,3.0f
,R8
,8.0);
6886 VARPOW(R4
,2,R8
,3.0,R8
,8.0);
6887 VARPOW(R4
,2,DATE
,3,R8
,8.0);
6888 VARPOW(R4
,2,BSTR
,num3_str
,R8
,8.0);
6889 VARPOW(R4
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6890 VARPOW(R4
,2,I1
,3,R8
,8.0);
6891 VARPOW(R4
,2,UI1
,3,R8
,8.0);
6892 VARPOW(R4
,2,UI2
,3,R8
,8.0);
6893 VARPOW(R4
,2,UI4
,3,R8
,8.0);
6896 VARPOW(R4
,2,I8
,3,R8
,8.0);
6897 VARPOW(R4
,2,UI8
,3,R8
,8.0);
6899 VARPOW(R4
,2,INT
,3,R8
,8.0);
6900 VARPOW(R4
,2,UINT
,3,R8
,8.0);
6901 VARPOW(R8
,2,EMPTY
,0,R8
,1.0);
6902 VARPOW(R8
,2,NULL
,0,NULL
,0);
6903 VARPOW(R8
,2,I2
,3,R8
,8.0);
6904 VARPOW(R8
,2,I4
,3,R8
,8.0);
6905 VARPOW(R8
,2,R4
,3.0f
,R8
,8.0);
6906 VARPOW(R8
,2,R8
,3.0,R8
,8.0);
6907 VARPOW(R8
,2,DATE
,3,R8
,8.0);
6908 VARPOW(R8
,2,BSTR
,num3_str
,R8
,8.0);
6909 VARPOW(R8
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6910 VARPOW(R8
,2,I1
,3,R8
,8.0);
6911 VARPOW(R8
,2,UI1
,3,R8
,8.0);
6912 VARPOW(R8
,2,UI2
,3,R8
,8.0);
6913 VARPOW(R8
,2,UI4
,3,R8
,8.0);
6916 VARPOW(R8
,2,I8
,3,R8
,8.0);
6917 VARPOW(R8
,2,UI8
,3,R8
,8.0);
6919 VARPOW(R8
,2,INT
,3,R8
,8.0);
6920 VARPOW(R8
,2,UINT
,3,R8
,8.0);
6921 VARPOW(DATE
,2,EMPTY
,0,R8
,1.0);
6922 VARPOW(DATE
,2,NULL
,0,NULL
,0);
6923 VARPOW(DATE
,2,I2
,3,R8
,8.0);
6924 VARPOW(DATE
,2,I4
,3,R8
,8.0);
6925 VARPOW(DATE
,2,R4
,3.0f
,R8
,8.0);
6926 VARPOW(DATE
,2,R8
,3.0,R8
,8.0);
6927 VARPOW(DATE
,2,DATE
,3,R8
,8.0);
6928 VARPOW(DATE
,2,BSTR
,num3_str
,R8
,8.0);
6929 VARPOW(DATE
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6930 VARPOW(DATE
,2,I1
,3,R8
,8.0);
6931 VARPOW(DATE
,2,UI1
,3,R8
,8.0);
6932 VARPOW(DATE
,2,UI2
,3,R8
,8.0);
6933 VARPOW(DATE
,2,UI4
,3,R8
,8.0);
6936 VARPOW(DATE
,2,I8
,3,R8
,8.0);
6937 VARPOW(DATE
,2,UI8
,3,R8
,8.0);
6939 VARPOW(DATE
,2,INT
,3,R8
,8.0);
6940 VARPOW(DATE
,2,UINT
,3,R8
,8.0);
6941 VARPOW(BSTR
,num2_str
,EMPTY
,0,R8
,1.0);
6942 VARPOW(BSTR
,num2_str
,NULL
,0,NULL
,0);
6943 VARPOW(BSTR
,num2_str
,I2
,3,R8
,8.0);
6944 VARPOW(BSTR
,num2_str
,I4
,3,R8
,8.0);
6945 VARPOW(BSTR
,num2_str
,R4
,3.0f
,R8
,8.0);
6946 VARPOW(BSTR
,num2_str
,R8
,3.0,R8
,8.0);
6947 VARPOW(BSTR
,num2_str
,DATE
,3,R8
,8.0);
6948 VARPOW(BSTR
,num2_str
,BSTR
,num3_str
,R8
,8.0);
6949 VARPOW(BSTR
,num2_str
,BOOL
,VARIANT_FALSE
,R8
,1.0);
6950 VARPOW(BSTR
,num2_str
,I1
,3,R8
,8.0);
6951 VARPOW(BSTR
,num2_str
,UI1
,3,R8
,8.0);
6952 VARPOW(BSTR
,num2_str
,UI2
,3,R8
,8.0);
6953 VARPOW(BSTR
,num2_str
,UI4
,3,R8
,8.0);
6956 VARPOW(BSTR
,num2_str
,I8
,3,R8
,8.0);
6957 VARPOW(BSTR
,num2_str
,UI8
,3,R8
,8.0);
6959 VARPOW(BSTR
,num2_str
,INT
,3,R8
,8.0);
6960 VARPOW(BSTR
,num2_str
,UINT
,3,R8
,8.0);
6961 VARPOW(BOOL
,VARIANT_TRUE
,EMPTY
,0,R8
,1.0);
6962 VARPOW(BOOL
,VARIANT_TRUE
,NULL
,0,NULL
,0);
6963 VARPOW(BOOL
,VARIANT_TRUE
,I2
,3,R8
,-1.0);
6964 VARPOW(BOOL
,VARIANT_TRUE
,I4
,3,R8
,-1.0);
6965 VARPOW(BOOL
,VARIANT_TRUE
,R4
,3.0f
,R8
,-1.0);
6966 VARPOW(BOOL
,VARIANT_TRUE
,R8
,3.0,R8
,-1.0);
6967 VARPOW(BOOL
,VARIANT_TRUE
,DATE
,3,R8
,-1.0);
6968 VARPOW(BOOL
,VARIANT_TRUE
,BSTR
,num3_str
,R8
,-1.0);
6969 VARPOW(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
,R8
,-1.0);
6970 VARPOW(BOOL
,VARIANT_TRUE
,I1
,3,R8
,-1.0);
6971 VARPOW(BOOL
,VARIANT_TRUE
,UI1
,3,R8
,-1.0);
6972 VARPOW(BOOL
,VARIANT_TRUE
,UI2
,3,R8
,-1.0);
6973 VARPOW(BOOL
,VARIANT_TRUE
,UI4
,3,R8
,-1.0);
6976 VARPOW(BOOL
,VARIANT_TRUE
,I8
,3,R8
,-1.0);
6977 VARPOW(BOOL
,VARIANT_TRUE
,UI8
,3,R8
,-1.0);
6979 VARPOW(BOOL
,VARIANT_TRUE
,INT
,3,R8
,-1.0);
6980 VARPOW(BOOL
,VARIANT_TRUE
,UINT
,3,R8
,-1.0);
6981 VARPOW(I1
,2,EMPTY
,0,R8
,1.0);
6982 VARPOW(I1
,2,NULL
,0,NULL
,0);
6983 VARPOW(I1
,2,I2
,3,R8
,8.0);
6984 VARPOW(I1
,2,I4
,3,R8
,8.0);
6985 VARPOW(I1
,2,R4
,3.0f
,R8
,8.0);
6986 VARPOW(I1
,2,R8
,3.0,R8
,8.0);
6987 VARPOW(I1
,2,DATE
,3,R8
,8.0);
6988 VARPOW(I1
,2,BSTR
,num3_str
,R8
,8.0);
6989 VARPOW(I1
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6990 VARPOW(I1
,2,I1
,3,R8
,8.0);
6991 VARPOW(I1
,2,UI1
,3,R8
,8.0);
6992 VARPOW(I1
,2,UI2
,3,R8
,8.0);
6993 VARPOW(I1
,2,UI4
,3,R8
,8.0);
6996 VARPOW(I1
,2,I8
,3,R8
,8.0);
6997 VARPOW(I1
,2,UI8
,3,R8
,8.0);
6999 VARPOW(I1
,2,INT
,3,R8
,8.0);
7000 VARPOW(I1
,2,UINT
,3,R8
,8.0);
7001 VARPOW(UI1
,2,EMPTY
,0,R8
,1.0);
7002 VARPOW(UI1
,2,NULL
,0,NULL
,0);
7003 VARPOW(UI1
,2,I2
,3,R8
,8.0);
7004 VARPOW(UI1
,2,I4
,3,R8
,8.0);
7005 VARPOW(UI1
,2,R4
,3.0f
,R8
,8.0);
7006 VARPOW(UI1
,2,R8
,3.0,R8
,8.0);
7007 VARPOW(UI1
,2,DATE
,3,R8
,8.0);
7008 VARPOW(UI1
,2,BSTR
,num3_str
,R8
,8.0);
7009 VARPOW(UI1
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
7010 VARPOW(UI1
,2,I1
,3,R8
,8.0);
7011 VARPOW(UI1
,2,UI1
,3,R8
,8.0);
7012 VARPOW(UI1
,2,UI2
,3,R8
,8.0);
7013 VARPOW(UI1
,2,UI4
,3,R8
,8.0);
7016 VARPOW(UI1
,2,I8
,3,R8
,8.0);
7017 VARPOW(UI1
,2,UI8
,3,R8
,8.0);
7019 VARPOW(UI1
,2,INT
,3,R8
,8.0);
7020 VARPOW(UI1
,2,UINT
,3,R8
,8.0);
7021 VARPOW(UI2
,2,EMPTY
,0,R8
,1.0);
7022 VARPOW(UI2
,2,NULL
,0,NULL
,0);
7023 VARPOW(UI2
,2,I2
,3,R8
,8.0);
7024 VARPOW(UI2
,2,I4
,3,R8
,8.0);
7025 VARPOW(UI2
,2,R4
,3.0f
,R8
,8.0);
7026 VARPOW(UI2
,2,R8
,3.0,R8
,8.0);
7027 VARPOW(UI2
,2,DATE
,3,R8
,8.0);
7028 VARPOW(UI2
,2,BSTR
,num3_str
,R8
,8.0);
7029 VARPOW(UI2
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
7030 VARPOW(UI2
,2,I1
,3,R8
,8.0);
7031 VARPOW(UI2
,2,UI1
,3,R8
,8.0);
7032 VARPOW(UI2
,2,UI2
,3,R8
,8.0);
7033 VARPOW(UI2
,2,UI4
,3,R8
,8.0);
7036 VARPOW(UI2
,2,I8
,3,R8
,8.0);
7037 VARPOW(UI2
,2,UI8
,3,R8
,8.0);
7039 VARPOW(UI2
,2,INT
,3,R8
,8.0);
7040 VARPOW(UI2
,2,UINT
,3,R8
,8.0);
7041 VARPOW(UI4
,2,EMPTY
,0,R8
,1.0);
7042 VARPOW(UI4
,2,NULL
,0,NULL
,0);
7043 VARPOW(UI4
,2,I2
,3,R8
,8.0);
7044 VARPOW(UI4
,2,I4
,3,R8
,8.0);
7045 VARPOW(UI4
,2,R4
,3.0f
,R8
,8.0);
7046 VARPOW(UI4
,2,R8
,3.0,R8
,8.0);
7047 VARPOW(UI4
,2,DATE
,3,R8
,8.0);
7048 VARPOW(UI4
,2,BSTR
,num3_str
,R8
,8.0);
7049 VARPOW(UI4
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
7050 VARPOW(UI4
,2,I1
,3,R8
,8.0);
7051 VARPOW(UI4
,2,UI1
,3,R8
,8.0);
7052 VARPOW(UI4
,2,UI2
,3,R8
,8.0);
7053 VARPOW(UI4
,2,UI4
,3,R8
,8.0);
7056 VARPOW(UI4
,2,I8
,3,R8
,8.0);
7057 VARPOW(UI4
,2,UI8
,3,R8
,8.0);
7059 VARPOW(UI4
,2,INT
,3,R8
,8.0);
7060 VARPOW(UI4
,2,UINT
,3,R8
,8.0);
7063 VARPOW(I8
,2,EMPTY
,0,R8
,1.0);
7064 VARPOW(I8
,2,NULL
,0,NULL
,0);
7065 VARPOW(I8
,2,I2
,3,R8
,8.0);
7066 VARPOW(I8
,2,I4
,3,R8
,8.0);
7067 VARPOW(I8
,2,R4
,3.0f
,R8
,8.0);
7068 VARPOW(I8
,2,R8
,3.0,R8
,8.0);
7069 VARPOW(I8
,2,DATE
,3,R8
,8.0);
7070 VARPOW(I8
,2,BSTR
,num3_str
,R8
,8.0);
7071 VARPOW(I8
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
7072 VARPOW(I8
,2,I1
,3,R8
,8.0);
7073 VARPOW(I8
,2,UI1
,3,R8
,8.0);
7074 VARPOW(I8
,2,UI2
,3,R8
,8.0);
7075 VARPOW(I8
,2,UI4
,3,R8
,8.0);
7076 VARPOW(I8
,2,I8
,3,R8
,8.0);
7077 VARPOW(I8
,2,UI8
,3,R8
,8.0);
7078 VARPOW(I8
,2,INT
,3,R8
,8.0);
7079 VARPOW(I8
,2,UINT
,3,R8
,8.0);
7080 VARPOW(UI8
,2,EMPTY
,0,R8
,1.0);
7081 VARPOW(UI8
,2,NULL
,0,NULL
,0);
7082 VARPOW(UI8
,2,I2
,3,R8
,8.0);
7083 VARPOW(UI8
,2,I4
,3,R8
,8.0);
7084 VARPOW(UI8
,2,R4
,3.0f
,R8
,8.0);
7085 VARPOW(UI8
,2,R8
,3.0,R8
,8.0);
7086 VARPOW(UI8
,2,DATE
,3,R8
,8.0);
7087 VARPOW(UI8
,2,BSTR
,num3_str
,R8
,8.0);
7088 VARPOW(UI8
,2,I1
,3,R8
,8.0);
7089 VARPOW(UI8
,2,UI1
,3,R8
,8.0);
7090 VARPOW(UI8
,2,UI2
,3,R8
,8.0);
7091 VARPOW(UI8
,2,UI4
,3,R8
,8.0);
7092 VARPOW(UI8
,2,I8
,3,R8
,8.0);
7093 VARPOW(UI8
,2,UI8
,3,R8
,8.0);
7094 VARPOW(UI8
,2,INT
,3,R8
,8.0);
7095 VARPOW(UI8
,2,UINT
,3,R8
,8.0);
7097 VARPOW(INT
,2,EMPTY
,0,R8
,1.0);
7098 VARPOW(INT
,2,NULL
,0,NULL
,0);
7099 VARPOW(INT
,2,I2
,3,R8
,8.0);
7100 VARPOW(INT
,2,I4
,3,R8
,8.0);
7101 VARPOW(INT
,2,R4
,3.0f
,R8
,8.0);
7102 VARPOW(INT
,2,R8
,3.0,R8
,8.0);
7103 VARPOW(INT
,2,DATE
,3,R8
,8.0);
7104 VARPOW(INT
,2,BSTR
,num3_str
,R8
,8.0);
7105 VARPOW(INT
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
7106 VARPOW(INT
,2,I1
,3,R8
,8.0);
7107 VARPOW(INT
,2,UI1
,3,R8
,8.0);
7108 VARPOW(INT
,2,UI2
,3,R8
,8.0);
7109 VARPOW(INT
,2,UI4
,3,R8
,8.0);
7112 VARPOW(INT
,2,I8
,3,R8
,8.0);
7113 VARPOW(INT
,2,UI8
,3,R8
,8.0);
7115 VARPOW(INT
,2,INT
,3,R8
,8.0);
7116 VARPOW(INT
,2,UINT
,3,R8
,8.0);
7117 VARPOW(UINT
,2,EMPTY
,0,R8
,1.0);
7118 VARPOW(UINT
,2,NULL
,0,NULL
,0);
7119 VARPOW(UINT
,2,I2
,3,R8
,8.0);
7120 VARPOW(UINT
,2,I4
,3,R8
,8.0);
7121 VARPOW(UINT
,2,R4
,3.0f
,R8
,8.0);
7122 VARPOW(UINT
,2,R8
,3.0,R8
,8.0);
7123 VARPOW(UINT
,2,DATE
,3,R8
,8.0);
7124 VARPOW(UINT
,2,BSTR
,num3_str
,R8
,8.0);
7125 VARPOW(UINT
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
7126 VARPOW(UINT
,2,I1
,3,R8
,8.0);
7127 VARPOW(UINT
,2,UI1
,3,R8
,8.0);
7128 VARPOW(UINT
,2,UI2
,3,R8
,8.0);
7129 VARPOW(UINT
,2,UI4
,3,R8
,8.0);
7132 VARPOW(UINT
,2,I8
,3,R8
,8.0);
7133 VARPOW(UINT
,2,UI8
,3,R8
,8.0);
7135 VARPOW(UINT
,2,INT
,3,R8
,8.0);
7136 VARPOW(UINT
,2,UINT
,3,R8
,8.0);
7138 /* Manually test some VT_CY, VT_DECIMAL variants */
7140 hres
= VarCyFromI4(2, &V_CY(&cy
));
7141 ok(hres
== S_OK
, "VarCyFromI4 failed!\n");
7142 V_VT(&dec
) = VT_DECIMAL
;
7143 hres
= VarDecFromR8(2.0, &V_DECIMAL(&dec
));
7144 ok(hres
== S_OK
, "VarDecFromR4 failed!\n");
7145 memset(&left
, 0, sizeof(left
));
7146 memset(&right
, 0, sizeof(right
));
7147 V_VT(&left
) = VT_I4
;
7149 V_VT(&right
) = VT_I8
;
7152 hres
= pVarPow(&cy
, &cy
, &result
);
7153 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
7154 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
7155 S_OK
, hres
, vtstr(V_VT(&result
)));
7156 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 4.0),
7157 "VARPOW: CY value %f, expected %f\n", V_R8(&result
), 4.0);
7159 hres
= pVarPow(&cy
, &right
, &result
);
7162 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
7163 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
7164 S_OK
, hres
, vtstr(V_VT(&result
)));
7165 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 4.0),
7166 "VARPOW: CY value %f, expected %f\n", V_R8(&result
), 4.0);
7170 ok(hres
== DISP_E_BADVARTYPE
&& V_VT(&result
) == VT_EMPTY
,
7171 "VARPOW: expected coerced hres 0x%X type VT_EMPTY, got hres 0x%X type %s!\n",
7172 DISP_E_BADVARTYPE
, hres
, vtstr(V_VT(&result
)));
7175 hres
= pVarPow(&left
, &cy
, &result
);
7176 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
7177 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
7178 S_OK
, hres
, vtstr(V_VT(&result
)));
7179 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 10000.0),
7180 "VARPOW: CY value %f, expected %f\n", V_R8(&result
), 10000.0);
7182 hres
= pVarPow(&left
, &dec
, &result
);
7183 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
7184 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
7185 S_OK
, hres
, vtstr(V_VT(&result
)));
7186 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
),10000.0),
7187 "VARPOW: DECIMAL value %f, expected %f\n", V_R8(&result
), 10000.0);
7189 hres
= pVarPow(&dec
, &dec
, &result
);
7190 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
7191 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
7192 S_OK
, hres
, vtstr(V_VT(&result
)));
7193 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 4.0),
7194 "VARPOW: DECIMAL value %f, expected %f\n", V_R8(&result
), 4.0);
7196 hres
= pVarPow(&dec
, &right
, &result
);
7199 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
7200 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
7201 S_OK
, hres
, vtstr(V_VT(&result
)));
7202 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 4.0),
7203 "VARPOW: DECIMAL value %f, expected %f\n", V_R8(&result
), 4.0);
7207 ok(hres
== DISP_E_BADVARTYPE
&& V_VT(&result
) == VT_EMPTY
,
7208 "VARPOW: expected coerced hres 0x%X type VT_EMPTY, got hres 0x%X type %s!\n",
7209 DISP_E_BADVARTYPE
, hres
, vtstr(V_VT(&result
)));
7212 SysFreeString(num2_str
);
7213 SysFreeString(num3_str
);
7216 static HRESULT (WINAPI
*pVarDiv
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
7218 #define VARDIV(vt1,val1,vt2,val2,rvt,rval) \
7219 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
7220 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
7221 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
7222 test_var_call2( __LINE__, pVarDiv, &left, &right, &exp )
7224 /* Skip any type that is not defined or produces an error for every case */
7225 #define SKIPTESTDIV(a) \
7226 if (a == VT_ERROR || a == VT_VARIANT || \
7227 a == VT_DISPATCH || a == VT_UNKNOWN || \
7228 a == VT_RECORD || a > VT_UINT || \
7229 a == VT_I1 || a == VT_UI8 || \
7230 a == VT_INT || a == VT_UINT || \
7231 a == VT_UI2 || a == VT_UI4 || \
7232 a == 15 /*not defined*/) \
7235 static void test_VarDiv(void)
7237 static const WCHAR str1
[] = { '1','\0' };
7238 static const WCHAR str2
[] = { '2','\0' };
7239 VARIANT left
, right
, exp
, result
, cy
, dec
;
7240 BSTR num1_str
, num2_str
;
7245 num1_str
= SysAllocString(str1
);
7246 num2_str
= SysAllocString(str2
);
7250 /* Test all possible flag/vt combinations & the resulting vt type */
7251 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
7253 VARTYPE leftvt
, rightvt
, resvt
;
7255 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
7257 SKIPTESTDIV(leftvt
);
7259 /* Check if we need/have support for I8 */
7260 if (leftvt
== VT_I8
&& !has_i8
)
7263 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
7266 SKIPTESTDIV(rightvt
);
7268 /* Check if we need/have support for I8 */
7269 if (rightvt
== VT_I8
&& !has_i8
)
7272 /* Native crashes with VT_BYREF */
7273 if (ExtraFlags
[i
] == VT_BYREF
)
7276 memset(&left
, 0, sizeof(left
));
7277 memset(&right
, 0, sizeof(right
));
7278 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
7279 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
7280 V_VT(&result
) = VT_EMPTY
;
7283 if (leftvt
== VT_BSTR
)
7284 V_BSTR(&left
) = num2_str
;
7285 else if (leftvt
== VT_DECIMAL
)
7287 VarDecFromR8(2.0, &V_DECIMAL(&left
));
7288 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
7291 /* Division by 0 is undefined */
7295 V_BSTR(&right
) = num2_str
;
7298 VarDecFromR8(2.0, &V_DECIMAL(&right
));
7299 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
7302 V_BOOL(&right
) = VARIANT_TRUE
;
7304 case VT_I2
: V_I2(&right
) = 2; break;
7305 case VT_I4
: V_I4(&right
) = 2; break;
7306 case VT_R4
: V_R4(&right
) = 2.0f
; break;
7307 case VT_R8
: V_R8(&right
) = 2.0; break;
7308 case VT_CY
: V_CY(&right
).int64
= 2; break;
7309 case VT_DATE
: V_DATE(&right
) = 2; break;
7310 case VT_UI1
: V_UI1(&right
) = 2; break;
7311 case VT_I8
: V_I8(&right
) = 2; break;
7315 /* Determine return type */
7316 if (!(rightvt
== VT_EMPTY
))
7318 if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
7320 else if (leftvt
== VT_DECIMAL
|| rightvt
== VT_DECIMAL
)
7322 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
||
7323 leftvt
== VT_CY
|| rightvt
== VT_CY
||
7324 leftvt
== VT_DATE
|| rightvt
== VT_DATE
||
7325 leftvt
== VT_I4
|| rightvt
== VT_I4
||
7326 leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
||
7327 leftvt
== VT_I2
|| rightvt
== VT_I2
||
7328 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
||
7329 leftvt
== VT_R8
|| rightvt
== VT_R8
||
7330 leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
7332 if ((leftvt
== VT_UI1
&& rightvt
== VT_R4
) ||
7333 (leftvt
== VT_R4
&& rightvt
== VT_UI1
))
7335 else if ((leftvt
== VT_R4
&& (rightvt
== VT_BOOL
||
7336 rightvt
== VT_I2
)) || (rightvt
== VT_R4
&&
7337 (leftvt
== VT_BOOL
|| leftvt
== VT_I2
)))
7342 else if (leftvt
== VT_R4
|| rightvt
== VT_R4
)
7345 else if (leftvt
== VT_NULL
&& rightvt
== VT_EMPTY
)
7350 /* Native VarDiv always returns an error when using extra flags */
7351 if (ExtraFlags
[i
] != 0)
7354 hres
= pVarDiv(&left
, &right
, &result
);
7356 /* Check expected HRESULT and if result variant type is correct */
7358 ok (hres
== DISP_E_BADVARTYPE
|| hres
== DISP_E_TYPEMISMATCH
||
7359 hres
== DISP_E_OVERFLOW
|| hres
== DISP_E_DIVBYZERO
,
7360 "VarDiv: %s|0x%X, %s|0x%X: got vt %s hr 0x%X\n",
7361 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
],
7362 vtstr(V_VT(&result
)), hres
);
7364 ok (hres
== S_OK
&& resvt
== V_VT(&result
),
7365 "VarDiv: %s|0x%X, %s|0x%X: expected vt %s hr 0x%X, got vt %s hr 0x%X\n",
7366 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
], vtstr(resvt
),
7367 S_OK
, vtstr(V_VT(&result
)), hres
);
7372 /* Test return values for all the good cases */
7373 VARDIV(EMPTY
,0,NULL
,0,NULL
,0);
7374 VARDIV(EMPTY
,0,I2
,2,R8
,0.0);
7375 VARDIV(EMPTY
,0,I4
,2,R8
,0.0);
7376 VARDIV(EMPTY
,0,R4
,2.0f
,R4
,0.0f
);
7377 VARDIV(EMPTY
,0,R8
,2.0,R8
,0.0);
7378 VARDIV(EMPTY
,0,DATE
,2.0,R8
,0.0);
7379 VARDIV(EMPTY
,0,BSTR
,num2_str
,R8
,0.0);
7380 VARDIV(EMPTY
,0,BOOL
,VARIANT_TRUE
,R8
,0.0);
7381 VARDIV(EMPTY
,0,UI1
,2,R8
,0.0);
7384 VARDIV(EMPTY
,0,I8
,2,R8
,0.0);
7386 VARDIV(NULL
,0,EMPTY
,0,NULL
,0);
7387 VARDIV(NULL
,0,NULL
,0,NULL
,0);
7388 VARDIV(NULL
,0,I2
,2,NULL
,0);
7389 VARDIV(NULL
,0,I4
,2,NULL
,0);
7390 VARDIV(NULL
,0,R4
,2.0f
,NULL
,0);
7391 VARDIV(NULL
,0,R8
,2.0,NULL
,0);
7392 VARDIV(NULL
,0,DATE
,2,NULL
,0);
7393 VARDIV(NULL
,0,BSTR
,num2_str
,NULL
,0);
7394 VARDIV(NULL
,0,BOOL
,VARIANT_TRUE
,NULL
,0);
7395 VARDIV(NULL
,0,UI1
,2,NULL
,0);
7398 VARDIV(NULL
,0,I8
,2,NULL
,0);
7400 VARDIV(I2
,2,NULL
,0,NULL
,0);
7401 VARDIV(I2
,1,I2
,2,R8
,0.5);
7402 VARDIV(I2
,1,I4
,2,R8
,0.5);
7403 VARDIV(I2
,1,R4
,2,R4
,0.5f
);
7404 VARDIV(I2
,1,R8
,2.0,R8
,0.5);
7405 VARDIV(I2
,1,DATE
,2,R8
,0.5);
7406 VARDIV(I2
,1,BOOL
,VARIANT_TRUE
,R8
,-1.0);
7407 VARDIV(I2
,1,UI1
,2,R8
,0.5);
7410 VARDIV(I2
,1,I8
,2,R8
,0.5);
7412 VARDIV(I4
,1,NULL
,0,NULL
,0);
7413 VARDIV(I4
,1,I2
,2,R8
,0.5);
7414 VARDIV(I4
,1,I4
,2,R8
,0.5);
7415 VARDIV(I4
,1,R4
,2.0f
,R8
,0.5);
7416 VARDIV(I4
,1,R8
,2.0,R8
,0.5);
7417 VARDIV(I4
,1,DATE
,2,R8
,0.5);
7418 VARDIV(I4
,1,BSTR
,num2_str
,R8
,0.5);
7419 VARDIV(I4
,1,BOOL
,VARIANT_TRUE
,R8
,-1.0);
7420 VARDIV(I4
,1,UI1
,2,R8
,0.5);
7423 VARDIV(I4
,1,I8
,2,R8
,0.5);
7425 VARDIV(R4
,1.0f
,NULL
,0,NULL
,0);
7426 VARDIV(R4
,1.0f
,I2
,2,R4
,0.5f
);
7427 VARDIV(R4
,1.0f
,I4
,2,R8
,0.5);
7428 VARDIV(R4
,1.0f
,R4
,2.0f
,R4
,0.5f
);
7429 VARDIV(R4
,1.0f
,R8
,2.0,R8
,0.5);
7430 VARDIV(R4
,1.0f
,DATE
,2,R8
,0.5);
7431 VARDIV(R4
,1.0f
,BSTR
,num2_str
,R8
,0.5);
7432 VARDIV(R4
,1.0f
,BOOL
,VARIANT_TRUE
,R4
,-1);
7433 VARDIV(R4
,1.0f
,UI1
,2,R4
,0.5f
);
7436 VARDIV(R4
,1.0f
,I8
,2,R8
,0.5);
7438 VARDIV(R8
,1.0,NULL
,0,NULL
,0);
7439 VARDIV(R8
,1.0,I2
,2,R8
,0.5);
7440 VARDIV(R8
,1.0,I4
,2,R8
,0.5);
7441 VARDIV(R8
,1.0,R4
,2.0f
,R8
,0.5);
7442 VARDIV(R8
,1.0,R8
,2.0,R8
,0.5);
7443 VARDIV(R8
,1.0,DATE
,2,R8
,0.5);
7444 VARDIV(R8
,1.0,BSTR
,num2_str
,R8
,0.5);
7445 VARDIV(R8
,1.0,BOOL
,VARIANT_TRUE
,R8
,-1.0);
7446 VARDIV(R8
,1.0,UI1
,2,R8
,0.5);
7449 VARDIV(R8
,1.0,I8
,2,R8
,0.5);
7451 VARDIV(DATE
,1,NULL
,0,NULL
,0);
7452 VARDIV(DATE
,1,I2
,2,R8
,0.5);
7453 VARDIV(DATE
,1,I4
,2,R8
,0.5);
7454 VARDIV(DATE
,1,R4
,2.0f
,R8
,0.5);
7455 VARDIV(DATE
,1,R8
,2.0,R8
,0.5);
7456 VARDIV(DATE
,1,DATE
,2,R8
,0.5);
7457 VARDIV(DATE
,1,BSTR
,num2_str
,R8
,0.5);
7458 VARDIV(DATE
,1,BOOL
,VARIANT_TRUE
,R8
,-1.0);
7459 VARDIV(DATE
,1,UI1
,2,R8
,0.5);
7462 VARDIV(DATE
,1,I8
,2,R8
,0.5);
7464 VARDIV(BSTR
,num1_str
,NULL
,0,NULL
,0);
7465 VARDIV(BSTR
,num1_str
,I2
,2,R8
,0.5);
7466 VARDIV(BSTR
,num1_str
,I4
,2,R8
,0.5);
7467 VARDIV(BSTR
,num1_str
,R4
,2.0f
,R8
,0.5);
7468 VARDIV(BSTR
,num1_str
,R8
,2.0,R8
,0.5);
7469 VARDIV(BSTR
,num1_str
,DATE
,2,R8
,0.5);
7470 VARDIV(BSTR
,num1_str
,BSTR
,num2_str
,R8
,0.5);
7471 VARDIV(BSTR
,num1_str
,BOOL
,VARIANT_TRUE
,R8
,-1);
7472 VARDIV(BSTR
,num1_str
,UI1
,2,R8
,0.5);
7475 VARDIV(BSTR
,num1_str
,I8
,2,R8
,0.5);
7477 VARDIV(BOOL
,VARIANT_TRUE
,NULL
,0,NULL
,0);
7478 VARDIV(BOOL
,VARIANT_TRUE
,I2
,1,R8
,-1.0);
7479 VARDIV(BOOL
,VARIANT_FALSE
,I2
,1,R8
,0.0);
7480 VARDIV(BOOL
,VARIANT_TRUE
,I4
,1,R8
,-1.0);
7481 VARDIV(BOOL
,VARIANT_FALSE
,I4
,1,R8
,0.0);
7482 VARDIV(BOOL
,VARIANT_TRUE
,R4
,1,R4
,-1.0f
);
7483 VARDIV(BOOL
,VARIANT_FALSE
,R4
,1,R4
,0.0f
);
7484 VARDIV(BOOL
,VARIANT_TRUE
,R8
,1.0,R8
,-1.0);
7485 VARDIV(BOOL
,VARIANT_FALSE
,R8
,1.0,R8
,0.0);
7486 VARDIV(BOOL
,VARIANT_FALSE
,DATE
,2,R8
,0.0);
7487 VARDIV(BOOL
,VARIANT_FALSE
,BSTR
,num2_str
,R8
,0.0);
7488 VARDIV(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
,R8
,1.0);
7489 VARDIV(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
,R8
,0.0);
7490 VARDIV(BOOL
,VARIANT_TRUE
,UI1
,1,R8
,-1.0);
7493 VARDIV(BOOL
,VARIANT_TRUE
,I8
,1,R8
,-1.0);
7495 VARDIV(UI1
,1,NULL
,0,NULL
,0);
7496 VARDIV(UI1
,1,I2
,2,R8
,0.5);
7497 VARDIV(UI1
,1,I4
,2,R8
,0.5);
7498 VARDIV(UI1
,1,R4
,2.0f
,R4
,0.5f
);
7499 VARDIV(UI1
,1,R8
,2.0,R8
,0.5);
7500 VARDIV(UI1
,1,DATE
,2,R8
,0.5);
7501 VARDIV(UI1
,1,BSTR
,num2_str
,R8
,0.5);
7502 VARDIV(UI1
,1,BOOL
,VARIANT_TRUE
,R8
,-1);
7503 VARDIV(UI1
,1,UI1
,2,R8
,0.5);
7506 VARDIV(UI1
,1,I8
,2,R8
,0.5);
7507 VARDIV(I8
,1,NULL
,0,NULL
,0);
7508 VARDIV(I8
,1,I2
,2,R8
,0.5);
7509 VARDIV(I8
,1,I4
,2,R8
,0.5);
7510 VARDIV(I8
,1,R4
,2.0f
,R8
,0.5);
7511 VARDIV(I8
,1,R8
,2.0,R8
,0.5);
7512 VARDIV(I8
,1,DATE
,2,R8
,0.5);
7513 VARDIV(I8
,1,BSTR
,num2_str
,R8
,0.5);
7514 VARDIV(I8
,1,BOOL
,VARIANT_TRUE
,R8
,-1);
7515 VARDIV(I8
,1,UI1
,2,R8
,0.5);
7516 VARDIV(I8
,1,I8
,2,R8
,0.5);
7519 /* Manually test some VT_CY, VT_DECIMAL variants */
7521 hres
= VarCyFromI4(10000, &V_CY(&cy
));
7522 ok(hres
== S_OK
, "VarCyFromI4 failed!\n");
7523 V_VT(&dec
) = VT_DECIMAL
;
7524 hres
= VarDecFromR8(2.0, &V_DECIMAL(&dec
));
7525 ok(hres
== S_OK
, "VarDecFromR4 failed!\n");
7526 memset(&left
, 0, sizeof(left
));
7527 memset(&right
, 0, sizeof(right
));
7528 V_VT(&left
) = VT_I4
;
7530 V_VT(&right
) = VT_UI1
;
7533 hres
= pVarDiv(&cy
, &cy
, &result
);
7534 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
7535 "VARDIV: expected coerced type VT_R8, got %s!\n", vtstr(V_VT(&result
)));
7536 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 1.0),
7537 "VARDIV: CY value %f, expected %f\n", V_R8(&result
), (double)1.0);
7539 hres
= pVarDiv(&cy
, &right
, &result
);
7540 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
7541 "VARDIV: expected coerced type VT_R8, got %s!\n", vtstr(V_VT(&result
)));
7542 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 5000.0),
7543 "VARDIV: CY value %f, expected %f\n", V_R8(&result
), (double)5000.0);
7545 hres
= pVarDiv(&left
, &cy
, &result
);
7546 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
7547 "VARDIV: expected coerced type VT_R8, got %s!\n", vtstr(V_VT(&result
)));
7548 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 0.01),
7549 "VARDIV: CY value %f, expected %f\n", V_R8(&result
), (double)0.01);
7551 hres
= pVarDiv(&left
, &dec
, &result
);
7552 ok(hres
== S_OK
&& V_VT(&result
) == VT_DECIMAL
,
7553 "VARDIV: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result
)));
7554 hres
= VarR8FromDec(&V_DECIMAL(&result
), &r
);
7555 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 50.0),
7556 "VARDIV: DECIMAL value %f, expected %f\n", r
, (double)50.0);
7558 hres
= pVarDiv(&dec
, &dec
, &result
);
7559 ok(hres
== S_OK
&& V_VT(&result
) == VT_DECIMAL
,
7560 "VARDIV: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result
)));
7561 hres
= VarR8FromDec(&V_DECIMAL(&result
), &r
);
7562 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 1.0),
7563 "VARDIV: DECIMAL value %f, expected %f\n", r
, (double)1.0);
7565 hres
= pVarDiv(&dec
, &right
, &result
);
7566 ok(hres
== S_OK
&& V_VT(&result
) == VT_DECIMAL
,
7567 "VARDIV: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result
)));
7568 hres
= VarR8FromDec(&V_DECIMAL(&result
), &r
);
7569 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 1.0),
7570 "VARDIV: DECIMAL value %f, expected %f\n", r
, (double)1.0);
7572 /* Check for division by zero and overflow */
7573 V_VT(&left
) = VT_R8
;
7575 V_VT(&right
) = VT_R8
;
7577 hres
= pVarDiv(&left
, &right
, &result
);
7578 ok(hres
== DISP_E_DIVBYZERO
&& V_VT(&result
) == VT_EMPTY
,
7579 "VARDIV: Division by (1.0/0.0) should result in DISP_E_DIVBYZERO but got 0x%X\n", hres
);
7581 V_VT(&left
) = VT_R8
;
7583 V_VT(&right
) = VT_R8
;
7585 hres
= pVarDiv(&left
, &right
, &result
);
7586 ok(hres
== DISP_E_OVERFLOW
&& V_VT(&result
) == VT_EMPTY
,
7587 "VARDIV: Division by (0.0/0.0) should result in DISP_E_OVERFLOW but got 0x%X\n", hres
);
7589 SysFreeString(num1_str
);
7590 SysFreeString(num2_str
);
7593 static HRESULT (WINAPI
*pVarIdiv
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
7595 #define VARIDIV(vt1,val1,vt2,val2,rvt,rval) \
7596 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
7597 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
7598 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
7599 test_var_call2( __LINE__, pVarIdiv, &left, &right, &exp )
7601 /* Skip any type that is not defined or produces an error for every case */
7602 #define SKIPTESTIDIV(a) \
7603 if (a == VT_ERROR || a == VT_VARIANT || \
7604 a == VT_DISPATCH || a == VT_UNKNOWN || \
7605 a == VT_RECORD || a > VT_UINT || \
7606 a == 15 /*not defined*/) \
7609 static void test_VarIdiv(void)
7611 static const WCHAR str1
[] = { '1','\0' };
7612 static const WCHAR str2
[] = { '2','\0' };
7613 VARIANT left
, right
, exp
, result
, cy
, dec
;
7614 BSTR num1_str
, num2_str
;
7620 num1_str
= SysAllocString(str1
);
7621 num2_str
= SysAllocString(str2
);
7623 /* Test all possible flag/vt combinations & the resulting vt type */
7624 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
7626 VARTYPE leftvt
, rightvt
, resvt
;
7628 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
7630 SKIPTESTIDIV(leftvt
);
7632 /* Check if we need/have support for I8 and/or UI8 */
7633 if ((leftvt
== VT_I8
|| leftvt
== VT_UI8
) && !has_i8
)
7636 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
7639 SKIPTESTIDIV(rightvt
);
7641 /* Native crashes with extra flag VT_BYREF */
7642 if (ExtraFlags
[i
] == VT_BYREF
)
7645 /* Check if we need/have support for I8 and/or UI8 */
7646 if ((rightvt
== VT_I8
|| rightvt
== VT_UI8
) && !has_i8
)
7649 memset(&left
, 0, sizeof(left
));
7650 memset(&right
, 0, sizeof(right
));
7651 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
7652 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
7653 V_VT(&result
) = VT_EMPTY
;
7656 if (leftvt
== VT_BSTR
)
7657 V_BSTR(&left
) = num2_str
;
7658 else if (leftvt
== VT_DECIMAL
)
7660 VarDecFromR8(2.0, &V_DECIMAL(&left
));
7661 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
7664 /* Division by 0 is undefined */
7668 V_BSTR(&right
) = num2_str
;
7671 VarDecFromR8(2.0, &V_DECIMAL(&right
));
7672 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
7675 V_BOOL(&right
) = VARIANT_TRUE
;
7678 VarCyFromI4(10000, &V_CY(&right
));
7679 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
7681 case VT_I2
: V_I2(&right
) = 2; break;
7682 case VT_I4
: V_I4(&right
) = 2; break;
7683 case VT_R4
: V_R4(&right
) = 2.0f
; break;
7684 case VT_R8
: V_R8(&right
) = 2.0; break;
7685 case VT_DATE
: V_DATE(&right
) = 2; break;
7686 case VT_I1
: V_I1(&right
) = 2; break;
7687 case VT_UI1
: V_UI1(&right
) = 2; break;
7688 case VT_UI2
: V_UI2(&right
) = 2; break;
7689 case VT_UI4
: V_UI4(&right
) = 2; break;
7690 case VT_I8
: V_I8(&right
) = 2; break;
7691 case VT_UI8
: V_UI8(&right
) = 2; break;
7692 case VT_INT
: V_INT(&right
) = 2; break;
7693 case VT_UINT
: V_UINT(&right
) = 2; break;
7697 /* Native VarIdiv always returns an error when using extra
7698 * flags or if the variant combination is I8 and INT.
7700 if ((leftvt
== VT_I8
&& rightvt
== VT_INT
) ||
7701 (leftvt
== VT_INT
&& rightvt
== VT_I8
) ||
7702 (rightvt
== VT_EMPTY
&& leftvt
!= VT_NULL
) ||
7706 /* Determine variant type */
7707 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
7709 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
7711 else if (leftvt
== VT_I4
|| rightvt
== VT_I4
||
7712 leftvt
== VT_INT
|| rightvt
== VT_INT
||
7713 leftvt
== VT_UINT
|| rightvt
== VT_UINT
||
7714 leftvt
== VT_UI8
|| rightvt
== VT_UI8
||
7715 leftvt
== VT_UI4
|| rightvt
== VT_UI4
||
7716 leftvt
== VT_UI2
|| rightvt
== VT_UI2
||
7717 leftvt
== VT_I1
|| rightvt
== VT_I1
||
7718 leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
||
7719 leftvt
== VT_DATE
|| rightvt
== VT_DATE
||
7720 leftvt
== VT_CY
|| rightvt
== VT_CY
||
7721 leftvt
== VT_DECIMAL
|| rightvt
== VT_DECIMAL
||
7722 leftvt
== VT_R8
|| rightvt
== VT_R8
||
7723 leftvt
== VT_R4
|| rightvt
== VT_R4
)
7725 else if (leftvt
== VT_I2
|| rightvt
== VT_I2
||
7726 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
||
7729 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
7734 hres
= pVarIdiv(&left
, &right
, &result
);
7736 /* Check expected HRESULT and if result variant type is correct */
7738 ok (hres
== DISP_E_BADVARTYPE
|| hres
== DISP_E_TYPEMISMATCH
||
7739 hres
== DISP_E_DIVBYZERO
,
7740 "VarIdiv: %s|0x%X, %s|0x%X: got vt %s hr 0x%X\n",
7741 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
],
7742 vtstr(V_VT(&result
)), hres
);
7744 ok (hres
== S_OK
&& resvt
== V_VT(&result
),
7745 "VarIdiv: %s|0x%X, %s|0x%X: expected vt %s hr 0x%X, got vt %s hr 0x%X\n",
7746 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
], vtstr(resvt
),
7747 S_OK
, vtstr(V_VT(&result
)), hres
);
7752 /* Test return values for all the good cases */
7753 VARIDIV(EMPTY
,0,NULL
,0,NULL
,0);
7754 VARIDIV(EMPTY
,0,I2
,1,I2
,0);
7755 VARIDIV(EMPTY
,0,I4
,1,I4
,0);
7756 VARIDIV(EMPTY
,0,R4
,1.0f
,I4
,0);
7757 VARIDIV(EMPTY
,0,R8
,1.0,I4
,0);
7758 VARIDIV(EMPTY
,0,DATE
,1.0,I4
,0);
7759 VARIDIV(EMPTY
,0,BSTR
,num1_str
,I4
,0);
7760 VARIDIV(EMPTY
,0,BOOL
,VARIANT_TRUE
,I2
,0);
7761 VARIDIV(EMPTY
,0,I1
,1,I4
,0);
7762 VARIDIV(EMPTY
,0,UI1
,1,I2
,0);
7763 VARIDIV(EMPTY
,0,UI2
,1,I4
,0);
7764 VARIDIV(EMPTY
,0,UI4
,1,I4
,0);
7767 VARIDIV(EMPTY
,0,I8
,1,I8
,0);
7768 VARIDIV(EMPTY
,0,UI8
,1,I4
,0);
7770 VARIDIV(EMPTY
,0,INT
,1,I4
,0);
7771 VARIDIV(EMPTY
,0,UINT
,1,I4
,0);
7772 VARIDIV(NULL
,0,EMPTY
,0,NULL
,0);
7773 VARIDIV(NULL
,0,NULL
,0,NULL
,0);
7774 VARIDIV(NULL
,0,I2
,1,NULL
,0);
7775 VARIDIV(NULL
,0,I4
,1,NULL
,0);
7776 VARIDIV(NULL
,0,R4
,1,NULL
,0);
7777 VARIDIV(NULL
,0,R8
,1,NULL
,0);
7778 VARIDIV(NULL
,0,DATE
,1,NULL
,0);
7779 VARIDIV(NULL
,0,BSTR
,num1_str
,NULL
,0);
7780 VARIDIV(NULL
,0,BOOL
,VARIANT_TRUE
,NULL
,0);
7781 VARIDIV(NULL
,0,I1
,1,NULL
,0);
7782 VARIDIV(NULL
,0,UI1
,1,NULL
,0);
7783 VARIDIV(NULL
,0,UI2
,1,NULL
,0);
7784 VARIDIV(NULL
,0,UI4
,1,NULL
,0);
7787 VARIDIV(NULL
,0,I8
,1,NULL
,0);
7788 VARIDIV(NULL
,0,UI8
,1,NULL
,0);
7790 VARIDIV(NULL
,0,INT
,1,NULL
,0);
7791 VARIDIV(NULL
,0,UINT
,1,NULL
,0);
7792 VARIDIV(I2
,2,NULL
,0,NULL
,0);
7793 VARIDIV(I2
,2,I2
,1,I2
,2);
7794 VARIDIV(I2
,2,I4
,1,I4
,2);
7795 VARIDIV(I2
,2,R4
,1,I4
,2);
7796 VARIDIV(I2
,2,R8
,1,I4
,2);
7797 VARIDIV(I2
,2,DATE
,1,I4
,2);
7798 VARIDIV(I2
,2,BSTR
,num1_str
,I4
,2);
7799 VARIDIV(I2
,2,BOOL
,VARIANT_TRUE
,I2
,-2);
7800 VARIDIV(I2
,2,I1
,1,I4
,2);
7801 VARIDIV(I2
,2,UI1
,1,I2
,2);
7802 VARIDIV(I2
,2,UI2
,1,I4
,2);
7803 VARIDIV(I2
,2,UI4
,1,I4
,2);
7806 VARIDIV(I2
,2,I8
,1,I8
,2);
7807 VARIDIV(I2
,2,UI8
,1,I4
,2);
7809 VARIDIV(I2
,2,INT
,1,I4
,2);
7810 VARIDIV(I2
,2,UINT
,1,I4
,2);
7811 VARIDIV(I4
,2,NULL
,0,NULL
,0);
7812 VARIDIV(I4
,2,I2
,1,I4
,2);
7813 VARIDIV(I4
,2,I4
,1,I4
,2);
7814 VARIDIV(I4
,2,R4
,1,I4
,2);
7815 VARIDIV(I4
,2,R8
,1,I4
,2);
7816 VARIDIV(I4
,2,DATE
,1,I4
,2);
7817 VARIDIV(I4
,2,BSTR
,num1_str
,I4
,2);
7818 VARIDIV(I4
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
7819 VARIDIV(I4
,2,I1
,1,I4
,2);
7820 VARIDIV(I4
,2,UI1
,1,I4
,2);
7821 VARIDIV(I4
,2,UI2
,1,I4
,2);
7822 VARIDIV(I4
,2,UI4
,1,I4
,2);
7825 VARIDIV(I4
,2,I8
,1,I8
,2);
7826 VARIDIV(I4
,2,UI8
,1,I4
,2);
7828 VARIDIV(I4
,2,INT
,1,I4
,2);
7829 VARIDIV(I4
,2,UINT
,1,I4
,2);
7830 VARIDIV(R4
,2.0f
,NULL
,0,NULL
,0);
7831 VARIDIV(R4
,2.0f
,I2
,1,I4
,2);
7832 VARIDIV(R4
,2.0f
,I4
,1,I4
,2);
7833 VARIDIV(R4
,2.0f
,R4
,1.0f
,I4
,2);
7834 VARIDIV(R4
,2.0f
,R8
,1.0,I4
,2);
7835 VARIDIV(R4
,2.0f
,DATE
,1,I4
,2);
7836 VARIDIV(R4
,2.0f
,BSTR
,num1_str
,I4
,2);
7837 VARIDIV(R4
,2.0f
,BOOL
,VARIANT_TRUE
,I4
,-2);
7838 VARIDIV(R4
,2.0f
,I1
,1,I4
,2);
7839 VARIDIV(R4
,2.0f
,UI1
,1,I4
,2);
7840 VARIDIV(R4
,2.0f
,UI2
,1,I4
,2);
7841 VARIDIV(R4
,2.0f
,UI4
,1,I4
,2);
7844 VARIDIV(R4
,2.0f
,I8
,1,I8
,2);
7845 VARIDIV(R4
,2.0f
,UI8
,1,I4
,2);
7847 VARIDIV(R4
,2.0f
,INT
,1,I4
,2);
7848 VARIDIV(R4
,2.0f
,UINT
,1,I4
,2);
7849 VARIDIV(R8
,2.0,NULL
,0,NULL
,0);
7850 VARIDIV(R8
,2.0,I2
,1,I4
,2);
7851 VARIDIV(R8
,2.0,I4
,1,I4
,2);
7852 VARIDIV(R8
,2.0,R4
,1,I4
,2);
7853 VARIDIV(R8
,2.0,R8
,1,I4
,2);
7854 VARIDIV(R8
,2.0,DATE
,1,I4
,2);
7855 VARIDIV(R8
,2.0,BSTR
,num1_str
,I4
,2);
7856 VARIDIV(R8
,2.0,BOOL
,VARIANT_TRUE
,I4
,-2);
7857 VARIDIV(R8
,2.0,I1
,1,I4
,2);
7858 VARIDIV(R8
,2.0,UI1
,1,I4
,2);
7859 VARIDIV(R8
,2.0,UI2
,1,I4
,2);
7860 VARIDIV(R8
,2.0,UI4
,1,I4
,2);
7863 VARIDIV(R8
,2.0,I8
,1,I8
,2);
7864 VARIDIV(R8
,2.0,UI8
,1,I4
,2);
7866 VARIDIV(R8
,2.0,INT
,1,I4
,2);
7867 VARIDIV(R8
,2.0,UINT
,1,I4
,2);
7868 VARIDIV(DATE
,2,NULL
,0,NULL
,0);
7869 VARIDIV(DATE
,2,I2
,1,I4
,2);
7870 VARIDIV(DATE
,2,I4
,1,I4
,2);
7871 VARIDIV(DATE
,2,R4
,1,I4
,2);
7872 VARIDIV(DATE
,2,R8
,1,I4
,2);
7873 VARIDIV(DATE
,2,DATE
,1,I4
,2);
7874 VARIDIV(DATE
,2,BSTR
,num1_str
,I4
,2);
7875 VARIDIV(DATE
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
7876 VARIDIV(DATE
,2,I1
,1,I4
,2);
7877 VARIDIV(DATE
,2,UI1
,1,I4
,2);
7878 VARIDIV(DATE
,2,UI2
,1,I4
,2);
7879 VARIDIV(DATE
,2,UI4
,1,I4
,2);
7882 VARIDIV(DATE
,2,I8
,1,I8
,2);
7883 VARIDIV(DATE
,2,UI8
,1,I4
,2);
7885 VARIDIV(DATE
,2,INT
,1,I4
,2);
7886 VARIDIV(DATE
,2,UINT
,1,I4
,2);
7887 VARIDIV(BSTR
,num2_str
,NULL
,0,NULL
,0);
7888 VARIDIV(BSTR
,num2_str
,I2
,1,I4
,2);
7889 VARIDIV(BSTR
,num2_str
,I4
,1,I4
,2);
7890 VARIDIV(BSTR
,num2_str
,R4
,1.0f
,I4
,2);
7891 VARIDIV(BSTR
,num2_str
,R8
,1.0,I4
,2);
7892 VARIDIV(BSTR
,num2_str
,DATE
,1,I4
,2);
7893 VARIDIV(BSTR
,num2_str
,BSTR
,num1_str
,I4
,2);
7894 VARIDIV(BSTR
,num2_str
,BOOL
,VARIANT_TRUE
,I4
,-2);
7895 VARIDIV(BSTR
,num2_str
,I1
,1,I4
,2);
7896 VARIDIV(BSTR
,num2_str
,UI1
,1,I4
,2);
7897 VARIDIV(BSTR
,num2_str
,UI2
,1,I4
,2);
7898 VARIDIV(BSTR
,num2_str
,UI4
,1,I4
,2);
7901 VARIDIV(BSTR
,num2_str
,I8
,1,I8
,2);
7902 VARIDIV(BSTR
,num2_str
,UI8
,1,I4
,2);
7904 VARIDIV(BSTR
,num2_str
,INT
,1,I4
,2);
7905 VARIDIV(BSTR
,num2_str
,UINT
,1,I4
,2);
7906 VARIDIV(BOOL
,VARIANT_TRUE
,NULL
,0,NULL
,0);
7907 VARIDIV(BOOL
,VARIANT_TRUE
,I2
,1,I2
,-1);
7908 VARIDIV(BOOL
,VARIANT_TRUE
,I4
,1,I4
,-1);
7909 VARIDIV(BOOL
,VARIANT_TRUE
,R4
,1.0f
,I4
,-1);
7910 VARIDIV(BOOL
,VARIANT_TRUE
,R8
,1.0,I4
,-1);
7911 VARIDIV(BOOL
,VARIANT_TRUE
,DATE
,1,I4
,-1);
7912 VARIDIV(BOOL
,VARIANT_TRUE
,BSTR
,num1_str
,I4
,-1);
7913 VARIDIV(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
,I2
,1);
7914 VARIDIV(BOOL
,VARIANT_TRUE
,I1
,1,I4
,-1);
7915 VARIDIV(BOOL
,VARIANT_TRUE
,UI1
,1,I2
,-1);
7916 VARIDIV(BOOL
,VARIANT_TRUE
,UI2
,1,I4
,-1);
7917 VARIDIV(BOOL
,VARIANT_TRUE
,UI4
,1,I4
,-1);
7920 VARIDIV(BOOL
,VARIANT_TRUE
,I8
,1,I8
,-1);
7921 VARIDIV(BOOL
,VARIANT_TRUE
,UI8
,1,I4
,-1);
7923 VARIDIV(BOOL
,VARIANT_TRUE
,INT
,1,I4
,-1);
7924 VARIDIV(BOOL
,VARIANT_TRUE
,UINT
,1,I4
,-1);
7925 VARIDIV(I1
,2,NULL
,0,NULL
,0);
7926 VARIDIV(I1
,2,I2
,1,I4
,2);
7927 VARIDIV(I1
,2,I4
,1,I4
,2);
7928 VARIDIV(I1
,2,R4
,1.0f
,I4
,2);
7929 VARIDIV(I1
,2,R8
,1.0,I4
,2);
7930 VARIDIV(I1
,2,DATE
,1,I4
,2);
7931 VARIDIV(I1
,2,BSTR
,num1_str
,I4
,2);
7932 VARIDIV(I1
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
7933 VARIDIV(I1
,2,I1
,1,I4
,2);
7934 VARIDIV(I1
,2,UI1
,1,I4
,2);
7935 VARIDIV(I1
,2,UI2
,1,I4
,2);
7936 VARIDIV(I1
,2,UI4
,1,I4
,2);
7939 VARIDIV(I1
,2,I8
,1,I8
,2);
7940 VARIDIV(I1
,2,UI8
,1,I4
,2);
7942 VARIDIV(I1
,2,INT
,1,I4
,2);
7943 VARIDIV(I1
,2,UINT
,1,I4
,2);
7944 VARIDIV(UI1
,2,NULL
,0,NULL
,0);
7945 VARIDIV(UI1
,2,I2
,1,I2
,2);
7946 VARIDIV(UI1
,2,I4
,1,I4
,2);
7947 VARIDIV(UI1
,2,R4
,1.0f
,I4
,2);
7948 VARIDIV(UI1
,2,R8
,1.0,I4
,2);
7949 VARIDIV(UI1
,2,DATE
,1,I4
,2);
7950 VARIDIV(UI1
,2,BSTR
,num1_str
,I4
,2);
7951 VARIDIV(UI1
,2,BOOL
,VARIANT_TRUE
,I2
,-2);
7952 VARIDIV(UI1
,2,I1
,1,I4
,2);
7953 VARIDIV(UI1
,2,UI1
,1,UI1
,2);
7954 VARIDIV(UI1
,2,UI2
,1,I4
,2);
7955 VARIDIV(UI1
,2,UI4
,1,I4
,2);
7958 VARIDIV(UI1
,2,I8
,1,I8
,2);
7959 VARIDIV(UI1
,2,UI8
,1,I4
,2);
7961 VARIDIV(UI1
,2,INT
,1,I4
,2);
7962 VARIDIV(UI1
,2,UINT
,1,I4
,2);
7963 VARIDIV(UI2
,2,NULL
,0,NULL
,0);
7964 VARIDIV(UI2
,2,I2
,1,I4
,2);
7965 VARIDIV(UI2
,2,I4
,1,I4
,2);
7966 VARIDIV(UI2
,2,R4
,1.0f
,I4
,2);
7967 VARIDIV(UI2
,2,R8
,1.0,I4
,2);
7968 VARIDIV(UI2
,2,DATE
,1,I4
,2);
7969 VARIDIV(UI2
,2,BSTR
,num1_str
,I4
,2);
7970 VARIDIV(UI2
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
7971 VARIDIV(UI2
,2,I1
,1,I4
,2);
7972 VARIDIV(UI2
,2,UI1
,1,I4
,2);
7973 VARIDIV(UI2
,2,UI2
,1,I4
,2);
7974 VARIDIV(UI2
,2,UI4
,1,I4
,2);
7977 VARIDIV(UI2
,2,I8
,1,I8
,2);
7978 VARIDIV(UI2
,2,UI8
,1,I4
,2);
7980 VARIDIV(UI2
,2,INT
,1,I4
,2);
7981 VARIDIV(UI2
,2,UINT
,1,I4
,2);
7982 VARIDIV(UI4
,2,NULL
,0,NULL
,0);
7983 VARIDIV(UI4
,2,I2
,1,I4
,2);
7984 VARIDIV(UI4
,2,I4
,1,I4
,2);
7985 VARIDIV(UI4
,2,R4
,1.0f
,I4
,2);
7986 VARIDIV(UI4
,2,R8
,1.0,I4
,2);
7987 VARIDIV(UI4
,2,DATE
,1,I4
,2);
7988 VARIDIV(UI4
,2,BSTR
,num1_str
,I4
,2);
7989 VARIDIV(UI4
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
7990 VARIDIV(UI4
,2,I1
,1,I4
,2);
7991 VARIDIV(UI4
,2,UI1
,1,I4
,2);
7992 VARIDIV(UI4
,2,UI2
,1,I4
,2);
7993 VARIDIV(UI4
,2,UI4
,1,I4
,2);
7996 VARIDIV(UI4
,2,I8
,1,I8
,2);
7997 VARIDIV(UI4
,2,UI8
,1,I4
,2);
7999 VARIDIV(UI4
,2,INT
,1,I4
,2);
8000 VARIDIV(UI4
,2,UINT
,1,I4
,2);
8003 VARIDIV(I8
,2,NULL
,0,NULL
,0);
8004 VARIDIV(I8
,2,I2
,1,I8
,2);
8005 VARIDIV(I8
,2,I4
,1,I8
,2);
8006 VARIDIV(I8
,2,R4
,1.0f
,I8
,2);
8007 VARIDIV(I8
,2,R8
,1.0,I8
,2);
8008 VARIDIV(I8
,2,DATE
,1,I8
,2);
8009 VARIDIV(I8
,2,BSTR
,num1_str
,I8
,2);
8010 VARIDIV(I8
,2,BOOL
,1,I8
,2);
8011 VARIDIV(I8
,2,I1
,1,I8
,2);
8012 VARIDIV(I8
,2,UI1
,1,I8
,2);
8013 VARIDIV(I8
,2,UI2
,1,I8
,2);
8014 VARIDIV(I8
,2,UI4
,1,I8
,2);
8015 VARIDIV(I8
,2,I8
,1,I8
,2);
8016 VARIDIV(I8
,2,UI8
,1,I8
,2);
8017 VARIDIV(I8
,2,UINT
,1,I8
,2);
8018 VARIDIV(UI8
,2,NULL
,0,NULL
,0);
8019 VARIDIV(UI8
,2,I2
,1,I4
,2);
8020 VARIDIV(UI8
,2,I4
,1,I4
,2);
8021 VARIDIV(UI8
,2,R4
,1.0f
,I4
,2);
8022 VARIDIV(UI8
,2,R8
,1.0,I4
,2);
8023 VARIDIV(UI8
,2,DATE
,1,I4
,2);
8024 VARIDIV(UI8
,2,BSTR
,num1_str
,I4
,2);
8025 VARIDIV(UI8
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
8026 VARIDIV(UI8
,2,I1
,1,I4
,2);
8027 VARIDIV(UI8
,2,UI1
,1,I4
,2);
8028 VARIDIV(UI8
,2,UI2
,1,I4
,2);
8029 VARIDIV(UI8
,2,UI4
,1,I4
,2);
8030 VARIDIV(UI8
,2,I8
,1,I8
,2);
8031 VARIDIV(UI8
,2,UI8
,1,I4
,2);
8032 VARIDIV(UI8
,2,INT
,1,I4
,2);
8033 VARIDIV(UI8
,2,UINT
,1,I4
,2);
8035 VARIDIV(INT
,2,NULL
,0,NULL
,0);
8036 VARIDIV(INT
,2,I2
,1,I4
,2);
8037 VARIDIV(INT
,2,I4
,1,I4
,2);
8038 VARIDIV(INT
,2,R4
,1.0f
,I4
,2);
8039 VARIDIV(INT
,2,R8
,1.0,I4
,2);
8040 VARIDIV(INT
,2,DATE
,1,I4
,2);
8041 VARIDIV(INT
,2,BSTR
,num1_str
,I4
,2);
8042 VARIDIV(INT
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
8043 VARIDIV(INT
,2,I1
,1,I4
,2);
8044 VARIDIV(INT
,2,UI1
,1,I4
,2);
8045 VARIDIV(INT
,2,UI2
,1,I4
,2);
8046 VARIDIV(INT
,2,UI4
,1,I4
,2);
8049 VARIDIV(INT
,2,UI8
,1,I4
,2);
8051 VARIDIV(INT
,2,INT
,1,I4
,2);
8052 VARIDIV(INT
,2,UINT
,1,I4
,2);
8053 VARIDIV(UINT
,2,NULL
,0,NULL
,0);
8054 VARIDIV(UINT
,2,I2
,1,I4
,2);
8055 VARIDIV(UINT
,2,I4
,1,I4
,2);
8056 VARIDIV(UINT
,2,R4
,1.0f
,I4
,2);
8057 VARIDIV(UINT
,2,R8
,1.0,I4
,2);
8058 VARIDIV(UINT
,2,DATE
,1,I4
,2);
8059 VARIDIV(UINT
,2,BSTR
,num1_str
,I4
,2);
8060 VARIDIV(UINT
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
8061 VARIDIV(UINT
,2,I1
,1,I4
,2);
8062 VARIDIV(UINT
,2,UI1
,1,I4
,2);
8063 VARIDIV(UINT
,2,UI2
,1,I4
,2);
8064 VARIDIV(UINT
,2,UI4
,1,I4
,2);
8067 VARIDIV(UINT
,2,I8
,1,I8
,2);
8068 VARIDIV(UINT
,2,UI8
,1,I4
,2);
8070 VARIDIV(UINT
,2,INT
,1,I4
,2);
8071 VARIDIV(UINT
,2,UINT
,1,I4
,2);
8073 /* Manually test some VT_CY, VT_DECIMAL variants */
8075 hres
= VarCyFromI4(10000, &V_CY(&cy
));
8076 ok(hres
== S_OK
, "VarCyFromI4 failed!\n");
8077 V_VT(&dec
) = VT_DECIMAL
;
8078 hres
= VarDecFromR8(2.0, &V_DECIMAL(&dec
));
8079 ok(hres
== S_OK
, "VarDecFromR4 failed!\n");
8080 memset(&left
, 0, sizeof(left
));
8081 memset(&right
, 0, sizeof(right
));
8082 V_VT(&left
) = VT_I4
;
8084 V_VT(&right
) = VT_I8
;
8087 hres
= pVarIdiv(&cy
, &cy
, &result
);
8088 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
8089 "VARIDIV: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8090 S_OK
, hres
, vtstr(V_VT(&result
)));
8091 ok(hres
== S_OK
&& V_I4(&result
) == 1,
8092 "VARIDIV: CY value %d, expected %d\n", V_I4(&result
), 1);
8096 hres
= pVarIdiv(&cy
, &right
, &result
);
8097 ok(hres
== S_OK
&& V_VT(&result
) == VT_I8
,
8098 "VARIDIV: expected coerced hres 0x%X type VT_I8, got hres 0x%X type %s!\n",
8099 S_OK
, hres
, vtstr(V_VT(&result
)));
8100 ok(hres
== S_OK
&& V_I8(&result
) == 5000,
8101 "VARIDIV: CY value 0x%x%08x, expected 0x%x\n",
8102 (DWORD
)(V_I8(&result
) >>32), (DWORD
)V_I8(&result
), 5000);
8105 hres
= pVarIdiv(&left
, &cy
, &result
);
8106 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
8107 "VARIDIV: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8108 S_OK
, hres
, vtstr(V_VT(&result
)));
8109 ok(hres
== S_OK
&& V_I4(&result
) == 0,
8110 "VARIDIV: CY value %d, expected %d\n", V_I4(&result
), 0);
8112 hres
= pVarIdiv(&left
, &dec
, &result
);
8113 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
8114 "VARIDIV: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8115 S_OK
, hres
, vtstr(V_VT(&result
)));
8116 ok(hres
== S_OK
&& V_I4(&result
) == 50,
8117 "VARIDIV: DECIMAL value %d, expected %d\n", V_I4(&result
), 50);
8119 hres
= pVarIdiv(&dec
, &dec
, &result
);
8120 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
8121 "VARIDIV: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8122 S_OK
, hres
, vtstr(V_VT(&result
)));
8123 ok(hres
== S_OK
&& V_I4(&result
) == 1,
8124 "VARIDIV: DECIMAL value %d, expected %d\n", V_I4(&result
), 1);
8128 hres
= pVarIdiv(&dec
, &right
, &result
);
8129 ok(hres
== S_OK
&& V_VT(&result
) == VT_I8
,
8130 "VARIDIV: expected coerced hres 0x%X type VT_I8, got hres 0x%X type %s!\n",
8131 S_OK
, hres
, vtstr(V_VT(&result
)));
8132 ok(hres
== S_OK
&& V_I8(&result
) == 1,
8133 "VARIDIV: DECIMAL value 0x%x%08x, expected %d\n",
8134 (DWORD
)(V_I8(&result
) >> 32), (DWORD
)V_I8(&result
), 1);
8137 /* Check for division by zero */
8138 V_VT(&left
) = VT_INT
;
8140 V_VT(&right
) = VT_INT
;
8142 hres
= pVarIdiv(&left
, &right
, &result
);
8143 ok(hres
== DISP_E_DIVBYZERO
&& V_VT(&result
) == VT_EMPTY
,
8144 "VARIDIV: Division by 0 should result in DISP_E_DIVBYZERO but got 0x%X\n", hres
);
8146 V_VT(&left
) = VT_INT
;
8148 V_VT(&right
) = VT_INT
;
8150 hres
= pVarIdiv(&left
, &right
, &result
);
8151 ok(hres
== DISP_E_DIVBYZERO
&& V_VT(&result
) == VT_EMPTY
,
8152 "VARIDIV: Division by 0 should result in DISP_E_DIVBYZERO but got 0x%X\n", hres
);
8154 SysFreeString(num1_str
);
8155 SysFreeString(num2_str
);
8159 static HRESULT (WINAPI
*pVarImp
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
8161 #define VARIMP(vt1,val1,vt2,val2,rvt,rval) \
8162 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
8163 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
8164 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
8165 test_var_call2( __LINE__, pVarImp, &left, &right, &exp )
8167 /* Skip any type that is not defined or produces an error for every case */
8168 #define SKIPTESTIMP(a) \
8169 if (a == VT_ERROR || a == VT_VARIANT || \
8170 a == VT_DISPATCH || a == VT_UNKNOWN || \
8171 a == VT_RECORD || a > VT_UINT || \
8172 a == 15 /*not defined*/) \
8175 static void test_VarImp(void)
8177 static const WCHAR szFalse
[] = { '#','F','A','L','S','E','#','\0' };
8178 static const WCHAR szTrue
[] = { '#','T','R','U','E','#','\0' };
8179 VARIANT left
, right
, exp
, result
, cy
, dec
;
8180 BSTR true_str
, false_str
;
8186 true_str
= SysAllocString(szTrue
);
8187 false_str
= SysAllocString(szFalse
);
8189 /* Test all possible flag/vt combinations & the resulting vt type */
8190 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
8192 VARTYPE leftvt
, rightvt
, resvt
;
8194 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
8196 SKIPTESTIMP(leftvt
);
8198 /* Check if we need/have support for I8 and/or UI8 */
8199 if ((leftvt
== VT_I8
|| leftvt
== VT_UI8
) && !has_i8
)
8202 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
8205 SKIPTESTIMP(rightvt
);
8207 /* Native crashes when using the extra flag VT_BYREF
8208 * or with the following VT combinations
8210 if ((leftvt
== VT_UI4
&& rightvt
== VT_BSTR
) ||
8211 (leftvt
== VT_UI8
&& rightvt
== VT_BSTR
) ||
8212 ExtraFlags
[i
] == VT_BYREF
)
8215 /* Check if we need/have support for I8 and/or UI8 */
8216 if ((rightvt
== VT_I8
|| rightvt
== VT_UI8
) && !has_i8
)
8219 memset(&left
, 0, sizeof(left
));
8220 memset(&right
, 0, sizeof(right
));
8221 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
8222 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
8223 V_VT(&result
) = VT_EMPTY
;
8226 if (leftvt
== VT_BSTR
)
8227 V_BSTR(&left
) = true_str
;
8229 /* This allows us to test return types that are not NULL
8230 * (NULL Imp value = n, NULL Imp 0 = NULL)
8235 V_BSTR(&right
) = true_str
;
8238 VarDecFromR8(2.0, &V_DECIMAL(&right
));
8239 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
8242 V_BOOL(&right
) = VARIANT_TRUE
;
8244 case VT_I1
: V_I1(&right
) = 2; break;
8245 case VT_I2
: V_I2(&right
) = 2; break;
8246 case VT_I4
: V_I4(&right
) = 2; break;
8247 case VT_R4
: V_R4(&right
) = 2.0f
; break;
8248 case VT_R8
: V_R8(&right
) = 2.0; break;
8249 case VT_CY
: V_CY(&right
).int64
= 10000; break;
8250 case VT_DATE
: V_DATE(&right
) = 2; break;
8251 case VT_I8
: V_I8(&right
) = 2; break;
8252 case VT_INT
: V_INT(&right
) = 2; break;
8253 case VT_UINT
: V_UINT(&right
) = 2; break;
8254 case VT_UI1
: V_UI1(&right
) = 2; break;
8255 case VT_UI2
: V_UI2(&right
) = 2; break;
8256 case VT_UI4
: V_UI4(&right
) = 2; break;
8257 case VT_UI8
: V_UI8(&right
) = 2; break;
8261 /* Native VarImp always returns an error when using extra
8262 * flags or if the variants are I8 and INT.
8264 if ((leftvt
== VT_I8
&& rightvt
== VT_INT
) ||
8268 /* Determine result type */
8269 else if ((leftvt
== VT_BSTR
&& rightvt
== VT_NULL
) ||
8270 (leftvt
== VT_NULL
&& rightvt
== VT_NULL
) ||
8271 (leftvt
== VT_NULL
&& rightvt
== VT_EMPTY
))
8273 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
8275 else if (leftvt
== VT_I4
|| rightvt
== VT_I4
||
8276 leftvt
== VT_INT
|| rightvt
== VT_INT
||
8277 leftvt
== VT_UINT
|| rightvt
== VT_UINT
||
8278 leftvt
== VT_UI4
|| rightvt
== VT_UI4
||
8279 leftvt
== VT_UI8
|| rightvt
== VT_UI8
||
8280 leftvt
== VT_UI2
|| rightvt
== VT_UI2
||
8281 leftvt
== VT_DECIMAL
|| rightvt
== VT_DECIMAL
||
8282 leftvt
== VT_DATE
|| rightvt
== VT_DATE
||
8283 leftvt
== VT_CY
|| rightvt
== VT_CY
||
8284 leftvt
== VT_R8
|| rightvt
== VT_R8
||
8285 leftvt
== VT_R4
|| rightvt
== VT_R4
||
8286 leftvt
== VT_I1
|| rightvt
== VT_I1
)
8288 else if ((leftvt
== VT_UI1
&& rightvt
== VT_UI1
) ||
8289 (leftvt
== VT_UI1
&& rightvt
== VT_NULL
) ||
8290 (leftvt
== VT_NULL
&& rightvt
== VT_UI1
))
8292 else if (leftvt
== VT_EMPTY
|| rightvt
== VT_EMPTY
||
8293 leftvt
== VT_I2
|| rightvt
== VT_I2
||
8294 leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
8296 else if (leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
||
8297 leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
)
8300 hres
= pVarImp(&left
, &right
, &result
);
8302 /* Check expected HRESULT and if result variant type is correct */
8304 ok (hres
== DISP_E_BADVARTYPE
|| hres
== DISP_E_TYPEMISMATCH
,
8305 "VarImp: %s|0x%X, %s|0x%X: got vt %s hr 0x%X\n",
8306 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
],
8307 vtstr(V_VT(&result
)), hres
);
8309 ok (hres
== S_OK
&& resvt
== V_VT(&result
),
8310 "VarImp: %s|0x%X, %s|0x%X: expected vt %s hr 0x%X, got vt %s hr 0x%X\n",
8311 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
], vtstr(resvt
),
8312 S_OK
, vtstr(V_VT(&result
)), hres
);
8317 VARIMP(EMPTY
,0,EMPTY
,0,I2
,-1);
8318 VARIMP(EMPTY
,0,NULL
,0,I2
,-1);
8319 VARIMP(EMPTY
,0,I2
,-1,I2
,-1);
8320 VARIMP(EMPTY
,0,I4
,-1,I4
,-1);
8321 VARIMP(EMPTY
,0,R4
,0.0f
,I4
,-1);
8322 VARIMP(EMPTY
,0,R8
,-1.0,I4
,-1);
8323 VARIMP(EMPTY
,0,DATE
,0,I4
,-1);
8324 VARIMP(EMPTY
,0,BSTR
,true_str
,I2
,-1);
8325 VARIMP(EMPTY
,0,BOOL
,VARIANT_FALSE
,I2
,-1);
8326 VARIMP(EMPTY
,0,I1
,0,I4
,-1);
8327 VARIMP(EMPTY
,0,UI1
,1,I2
,-1);
8328 VARIMP(EMPTY
,0,UI2
,1,I4
,-1);
8329 VARIMP(EMPTY
,0,UI4
,1,I4
,-1);
8332 VARIMP(EMPTY
,0,I8
,1,I8
,-1);
8333 VARIMP(EMPTY
,0,UI8
,1,I4
,-1);
8335 VARIMP(EMPTY
,0,INT
,-1,I4
,-1);
8336 VARIMP(EMPTY
,0,UINT
,1,I4
,-1);
8337 VARIMP(NULL
,0,EMPTY
,0,NULL
,0);
8338 VARIMP(NULL
,0,NULL
,0,NULL
,0);
8339 VARIMP(NULL
,0,I2
,-1,I2
,-1);
8340 VARIMP(NULL
,0,I4
,-1,I4
,-1);
8341 VARIMP(NULL
,0,R4
,0.0f
,NULL
,0);
8342 VARIMP(NULL
,0,R8
,-1.0,I4
,-1);
8343 VARIMP(NULL
,0,DATE
,0,NULL
,0);
8344 VARIMP(NULL
,0,BSTR
,true_str
,BOOL
,-1);
8345 VARIMP(NULL
,0,BOOL
,VARIANT_FALSE
,NULL
,0);
8346 VARIMP(NULL
,0,I1
,0,NULL
,0);
8347 VARIMP(NULL
,0,UI1
,1,UI1
,1);
8348 VARIMP(NULL
,0,UI2
,1,I4
,1);
8349 VARIMP(NULL
,0,UI4
,1,I4
,1);
8352 VARIMP(NULL
,0,I8
,1,I8
,1);
8353 VARIMP(NULL
,0,UI8
,1,I4
,1);
8355 VARIMP(NULL
,0,INT
,-1,I4
,-1);
8356 VARIMP(NULL
,0,UINT
,1,I4
,1);
8357 VARIMP(I2
,-1,EMPTY
,0,I2
,0);
8358 VARIMP(I2
,-1,I2
,-1,I2
,-1);
8359 VARIMP(I2
,-1,I4
,-1,I4
,-1);
8360 VARIMP(I2
,-1,R4
,0.0f
,I4
,0);
8361 VARIMP(I2
,-1,R8
,-1.0,I4
,-1);
8362 VARIMP(I2
,-1,DATE
,0,I4
,0);
8363 VARIMP(I2
,-1,BSTR
,true_str
,I2
,-1);
8364 VARIMP(I2
,-1,BOOL
,VARIANT_FALSE
,I2
,0);
8365 VARIMP(I2
,-1,I1
,0,I4
,0);
8366 VARIMP(I2
,-1,UI1
,1,I2
,1);
8367 VARIMP(I2
,-1,UI2
,1,I4
,1);
8368 VARIMP(I2
,-1,UI4
,1,I4
,1);
8371 VARIMP(I2
,-1,I8
,1,I8
,1);
8372 VARIMP(I2
,-1,UI8
,1,I4
,1);
8374 VARIMP(I2
,-1,INT
,-1,I4
,-1);
8375 VARIMP(I2
,-1,UINT
,1,I4
,1);
8376 VARIMP(I4
,2,EMPTY
,0,I4
,-3);
8377 VARIMP(I4
,2,NULL
,0,I4
,-3);
8378 VARIMP(I4
,2,I2
,-1,I4
,-1);
8379 VARIMP(I4
,2,I4
,-1,I4
,-1);
8380 VARIMP(I4
,2,R4
,0.0f
,I4
,-3);
8381 VARIMP(I4
,2,R8
,-1.0,I4
,-1);
8382 VARIMP(I4
,2,DATE
,0,I4
,-3);
8383 VARIMP(I4
,2,BSTR
,true_str
,I4
,-1);
8384 VARIMP(I4
,2,BOOL
,VARIANT_FALSE
,I4
,-3);
8385 VARIMP(I4
,2,I1
,0,I4
,-3);
8386 VARIMP(I4
,2,UI1
,1,I4
,-3);
8387 VARIMP(I4
,2,UI2
,1,I4
,-3);
8388 VARIMP(I4
,2,UI4
,1,I4
,-3);
8391 VARIMP(I4
,2,I8
,1,I8
,-3);
8392 VARIMP(I4
,2,UI8
,1,I4
,-3);
8394 VARIMP(I4
,2,INT
,-1,I4
,-1);
8395 VARIMP(I4
,2,UINT
,1,I4
,-3);
8396 VARIMP(R4
,-1.0f
,EMPTY
,0,I4
,0);
8397 VARIMP(R4
,-1.0f
,NULL
,0,NULL
,0);
8398 VARIMP(R4
,-1.0f
,I2
,-1,I4
,-1);
8399 VARIMP(R4
,-1.0f
,I4
,-1,I4
,-1);
8400 VARIMP(R4
,-1.0f
,R4
,0.0f
,I4
,0);
8401 VARIMP(R4
,-1.0f
,R8
,-1.0,I4
,-1);
8402 VARIMP(R4
,-1.0f
,DATE
,1,I4
,1);
8403 VARIMP(R4
,-1.0f
,BSTR
,true_str
,I4
,-1);
8404 VARIMP(R4
,-1.0f
,BOOL
,VARIANT_FALSE
,I4
,0);
8405 VARIMP(R4
,-1.0f
,I1
,0,I4
,0);
8406 VARIMP(R4
,-1.0f
,UI1
,1,I4
,1);
8407 VARIMP(R4
,-1.0f
,UI2
,1,I4
,1);
8408 VARIMP(R4
,-1.0f
,UI4
,1,I4
,1);
8411 VARIMP(R4
,-1.0f
,I8
,1,I8
,1);
8412 VARIMP(R4
,-1.0f
,UI8
,1,I4
,1);
8414 VARIMP(R4
,-1.0f
,INT
,-1,I4
,-1);
8415 VARIMP(R4
,-1.0f
,UINT
,1,I4
,1);
8416 VARIMP(R8
,1.0,EMPTY
,0,I4
,-2);
8417 VARIMP(R8
,1.0,NULL
,0,I4
,-2);
8418 VARIMP(R8
,1.0,I2
,-1,I4
,-1);
8419 VARIMP(R8
,1.0,I4
,-1,I4
,-1);
8420 VARIMP(R8
,1.0,R4
,0.0f
,I4
,-2);
8421 VARIMP(R8
,1.0,R8
,-1.0,I4
,-1);
8422 VARIMP(R8
,1.0,DATE
,0,I4
,-2);
8423 VARIMP(R8
,1.0,BSTR
,true_str
,I4
,-1);
8424 VARIMP(R8
,1.0,BOOL
,VARIANT_FALSE
,I4
,-2);
8425 VARIMP(R8
,1.0,I1
,0,I4
,-2);
8426 VARIMP(R8
,1.0,UI1
,1,I4
,-1);
8427 VARIMP(R8
,1.0,UI2
,1,I4
,-1);
8428 VARIMP(R8
,1.0,UI4
,1,I4
,-1);
8431 VARIMP(R8
,1.0,I8
,1,I8
,-1);
8432 VARIMP(R8
,1.0,UI8
,1,I4
,-1);
8434 VARIMP(R8
,1.0,INT
,-1,I4
,-1);
8435 VARIMP(R8
,1.0,UINT
,1,I4
,-1);
8436 VARIMP(DATE
,0,EMPTY
,0,I4
,-1);
8437 VARIMP(DATE
,0,NULL
,0,I4
,-1);
8438 VARIMP(DATE
,0,I2
,-1,I4
,-1);
8439 VARIMP(DATE
,0,I4
,-1,I4
,-1);
8440 VARIMP(DATE
,0,R4
,0.0f
,I4
,-1);
8441 VARIMP(DATE
,0,R8
,-1.0,I4
,-1);
8442 VARIMP(DATE
,0,DATE
,0,I4
,-1);
8443 VARIMP(DATE
,0,BSTR
,true_str
,I4
,-1);
8444 VARIMP(DATE
,0,BOOL
,VARIANT_FALSE
,I4
,-1);
8445 VARIMP(DATE
,0,I1
,0,I4
,-1);
8446 VARIMP(DATE
,0,UI1
,1,I4
,-1);
8447 VARIMP(DATE
,0,UI2
,1,I4
,-1);
8448 VARIMP(DATE
,0,UI4
,1,I4
,-1);
8451 VARIMP(DATE
,0,I8
,1,I8
,-1);
8452 VARIMP(DATE
,0,UI8
,1,I4
,-1);
8454 VARIMP(DATE
,0,INT
,-1,I4
,-1);
8455 VARIMP(DATE
,0,UINT
,1,I4
,-1);
8456 VARIMP(BSTR
,false_str
,EMPTY
,0,I2
,-1);
8457 VARIMP(BSTR
,false_str
,NULL
,0,BOOL
,-1);
8458 VARIMP(BSTR
,false_str
,I2
,-1,I2
,-1);
8459 VARIMP(BSTR
,false_str
,I4
,-1,I4
,-1);
8460 VARIMP(BSTR
,false_str
,R4
,0.0f
,I4
,-1);
8461 VARIMP(BSTR
,false_str
,R8
,-1.0,I4
,-1);
8462 VARIMP(BSTR
,false_str
,DATE
,0,I4
,-1);
8463 VARIMP(BSTR
,false_str
,BSTR
,true_str
,BOOL
,-1);
8464 VARIMP(BSTR
,false_str
,BOOL
,VARIANT_FALSE
,BOOL
,-1);
8465 VARIMP(BSTR
,false_str
,I1
,0,I4
,-1);
8466 VARIMP(BSTR
,false_str
,UI1
,1,I2
,-1);
8467 VARIMP(BSTR
,false_str
,UI2
,1,I4
,-1);
8468 VARIMP(BSTR
,false_str
,UI4
,1,I4
,-1);
8471 VARIMP(BSTR
,false_str
,I8
,1,I8
,-1);
8472 VARIMP(BSTR
,false_str
,UI8
,1,I4
,-1);
8474 VARIMP(BSTR
,false_str
,INT
,-1,I4
,-1);
8475 VARIMP(BSTR
,false_str
,UINT
,1,I4
,-1);
8476 VARIMP(BOOL
,VARIANT_TRUE
,EMPTY
,0,I2
,0);
8477 VARIMP(BOOL
,VARIANT_TRUE
,NULL
,0,NULL
,0);
8478 VARIMP(BOOL
,VARIANT_TRUE
,I2
,-1,I2
,-1);
8479 VARIMP(BOOL
,VARIANT_TRUE
,I4
,-1,I4
,-1);
8480 VARIMP(BOOL
,VARIANT_TRUE
,R4
,0.0f
,I4
,0);
8481 VARIMP(BOOL
,VARIANT_TRUE
,R8
,-1.0,I4
,-1);
8482 VARIMP(BOOL
,VARIANT_TRUE
,DATE
,0,I4
,0);
8483 VARIMP(BOOL
,VARIANT_TRUE
,BSTR
,true_str
,BOOL
,-1);
8484 VARIMP(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
,BOOL
,0);
8485 VARIMP(BOOL
,VARIANT_TRUE
,I1
,0,I4
,0);
8486 VARIMP(BOOL
,VARIANT_TRUE
,UI1
,1,I2
,1);
8487 VARIMP(BOOL
,VARIANT_TRUE
,UI2
,1,I4
,1);
8488 VARIMP(BOOL
,VARIANT_TRUE
,UI4
,1,I4
,1);
8491 VARIMP(BOOL
,VARIANT_TRUE
,I8
,1,I8
,1);
8492 VARIMP(BOOL
,VARIANT_TRUE
,UI8
,1,I4
,1);
8494 VARIMP(BOOL
,VARIANT_TRUE
,INT
,-1,I4
,-1);
8495 VARIMP(BOOL
,VARIANT_TRUE
,UINT
,1,I4
,1);
8496 VARIMP(I1
,-1,EMPTY
,0,I4
,0);
8497 VARIMP(I1
,-1,NULL
,0,NULL
,0);
8498 VARIMP(I1
,-1,I2
,-1,I4
,-1);
8499 VARIMP(I1
,-1,I4
,-1,I4
,-1);
8500 VARIMP(I1
,-1,R4
,0.0f
,I4
,0);
8501 VARIMP(I1
,-1,R8
,-1.0,I4
,-1);
8502 VARIMP(I1
,-1,DATE
,0,I4
,0);
8503 VARIMP(I1
,-1,BSTR
,true_str
,I4
,-1);
8504 VARIMP(I1
,-1,BOOL
,VARIANT_FALSE
,I4
,0);
8505 VARIMP(I1
,-1,I1
,0,I4
,0);
8506 VARIMP(I1
,-1,UI1
,1,I4
,1);
8507 VARIMP(I1
,-1,UI2
,1,I4
,1);
8508 VARIMP(I1
,-1,UI4
,1,I4
,1);
8511 VARIMP(I1
,-1,I8
,1,I8
,1);
8512 VARIMP(I1
,-1,UI8
,1,I4
,1);
8514 VARIMP(I1
,-1,INT
,-1,I4
,-1);
8515 VARIMP(I1
,-1,UINT
,1,I4
,1);
8516 VARIMP(UI1
,0,EMPTY
,0,I2
,-1);
8517 VARIMP(UI1
,0,NULL
,0,UI1
,255);
8518 VARIMP(UI1
,0,I2
,-1,I2
,-1);
8519 VARIMP(UI1
,0,I4
,-1,I4
,-1);
8520 VARIMP(UI1
,0,R4
,0.0f
,I4
,-1);
8521 VARIMP(UI1
,0,R8
,-1.0,I4
,-1);
8522 VARIMP(UI1
,0,DATE
,0,I4
,-1);
8523 VARIMP(UI1
,0,BSTR
,true_str
,I2
,-1);
8524 VARIMP(UI1
,0,BOOL
,VARIANT_FALSE
,I2
,-1);
8525 VARIMP(UI1
,0,I1
,0,I4
,-1);
8526 VARIMP(UI1
,0,UI1
,1,UI1
,255);
8527 VARIMP(UI1
,0,UI2
,1,I4
,-1);
8528 VARIMP(UI1
,0,UI4
,1,I4
,-1);
8531 VARIMP(UI1
,0,I8
,1,I8
,-1);
8532 VARIMP(UI1
,0,UI8
,1,I4
,-1);
8534 VARIMP(UI1
,0,INT
,-1,I4
,-1);
8535 VARIMP(UI1
,0,UINT
,1,I4
,-1);
8536 VARIMP(UI2
,0,EMPTY
,0,I4
,-1);
8537 VARIMP(UI2
,0,NULL
,0,I4
,-1);
8538 VARIMP(UI2
,0,I2
,-1,I4
,-1);
8539 VARIMP(UI2
,0,I4
,-1,I4
,-1);
8540 VARIMP(UI2
,0,R4
,0.0f
,I4
,-1);
8541 VARIMP(UI2
,0,R8
,-1.0,I4
,-1);
8542 VARIMP(UI2
,0,DATE
,0,I4
,-1);
8543 VARIMP(UI2
,0,BSTR
,true_str
,I4
,-1);
8544 VARIMP(UI2
,0,BOOL
,VARIANT_FALSE
,I4
,-1);
8545 VARIMP(UI2
,0,I1
,0,I4
,-1);
8546 VARIMP(UI2
,0,UI1
,1,I4
,-1);
8547 VARIMP(UI2
,0,UI2
,1,I4
,-1);
8548 VARIMP(UI2
,0,UI4
,1,I4
,-1);
8551 VARIMP(UI2
,0,I8
,1,I8
,-1);
8552 VARIMP(UI2
,0,UI8
,1,I4
,-1);
8554 VARIMP(UI2
,0,INT
,-1,I4
,-1);
8555 VARIMP(UI2
,0,UINT
,1,I4
,-1);
8556 VARIMP(UI4
,0,EMPTY
,0,I4
,-1);
8557 VARIMP(UI4
,0,NULL
,0,I4
,-1);
8558 VARIMP(UI4
,0,I2
,-1,I4
,-1);
8559 VARIMP(UI4
,0,I4
,-1,I4
,-1);
8560 VARIMP(UI4
,0,R4
,0.0f
,I4
,-1);
8561 VARIMP(UI4
,0,R8
,-1.0,I4
,-1);
8562 VARIMP(UI4
,0,DATE
,0,I4
,-1);
8563 VARIMP(UI4
,0,BSTR
,true_str
,I4
,-1);
8564 VARIMP(UI4
,0,BOOL
,VARIANT_FALSE
,I4
,-1);
8565 VARIMP(UI4
,0,I1
,0,I4
,-1);
8566 VARIMP(UI4
,0,UI1
,1,I4
,-1);
8567 VARIMP(UI4
,0,UI2
,1,I4
,-1);
8568 VARIMP(UI4
,0,UI4
,1,I4
,-1);
8571 VARIMP(UI4
,0,I8
,1,I8
,-1);
8572 VARIMP(UI4
,0,UI8
,1,I4
,-1);
8574 VARIMP(UI4
,0,INT
,-1,I4
,-1);
8575 VARIMP(UI4
,0,UINT
,1,I4
,-1);
8578 VARIMP(I8
,-1,EMPTY
,0,I8
,0);
8579 VARIMP(I8
,-1,NULL
,0,NULL
,0);
8580 VARIMP(I8
,-1,I2
,-1,I8
,-1);
8581 VARIMP(I8
,-1,I4
,-1,I8
,-1);
8582 VARIMP(I8
,-1,R4
,0.0f
,I8
,0);
8583 VARIMP(I8
,-1,R8
,-1.0,I8
,-1);
8584 VARIMP(I8
,-1,DATE
,0,I8
,0);
8585 VARIMP(I8
,-1,BSTR
,true_str
,I8
,-1);
8586 VARIMP(I8
,-1,BOOL
,VARIANT_FALSE
,I8
,0);
8587 VARIMP(I8
,-1,I1
,0,I8
,0);
8588 VARIMP(I8
,-1,UI1
,1,I8
,1);
8589 VARIMP(I8
,-1,UI2
,1,I8
,1);
8590 VARIMP(I8
,-1,UI4
,1,I8
,1);
8591 VARIMP(I8
,-1,I8
,1,I8
,1);
8592 VARIMP(I8
,-1,UI8
,1,I8
,1);
8593 VARIMP(I8
,-1,UINT
,1,I8
,1);
8594 VARIMP(UI8
,0,EMPTY
,0,I4
,-1);
8595 VARIMP(UI8
,0,NULL
,0,I4
,-1);
8596 VARIMP(UI8
,0,I2
,-1,I4
,-1);
8597 VARIMP(UI8
,0,I4
,-1,I4
,-1);
8598 VARIMP(UI8
,0,R4
,0.0f
,I4
,-1);
8599 VARIMP(UI8
,0,R8
,-1.0,I4
,-1);
8600 VARIMP(UI8
,0,DATE
,0,I4
,-1);
8601 VARIMP(UI8
,0,BSTR
,true_str
,I4
,-1);
8602 VARIMP(UI8
,0,BOOL
,VARIANT_FALSE
,I4
,-1);
8603 VARIMP(UI8
,0,I1
,0,I4
,-1);
8604 VARIMP(UI8
,0,UI1
,1,I4
,-1);
8605 VARIMP(UI8
,0,UI2
,1,I4
,-1);
8606 VARIMP(UI8
,0,UI4
,1,I4
,-1);
8607 VARIMP(UI8
,0,I8
,1,I8
,-1);
8608 VARIMP(UI8
,0,UI8
,1,I4
,-1);
8609 VARIMP(UI8
,0,INT
,-1,I4
,-1);
8610 VARIMP(UI8
,0,UINT
,1,I4
,-1);
8612 VARIMP(INT
,-1,EMPTY
,0,I4
,0);
8613 VARIMP(INT
,-1,NULL
,0,NULL
,0);
8614 VARIMP(INT
,-1,I2
,-1,I4
,-1);
8615 VARIMP(INT
,-1,I4
,-1,I4
,-1);
8616 VARIMP(INT
,-1,R4
,0.0f
,I4
,0);
8617 VARIMP(INT
,-1,R8
,-1.0,I4
,-1);
8618 VARIMP(INT
,-1,DATE
,0,I4
,0);
8619 VARIMP(INT
,-1,BSTR
,true_str
,I4
,-1);
8620 VARIMP(INT
,-1,BOOL
,VARIANT_FALSE
,I4
,0);
8621 VARIMP(INT
,-1,I1
,0,I4
,0);
8622 VARIMP(INT
,-1,UI1
,1,I4
,1);
8623 VARIMP(INT
,-1,UI2
,1,I4
,1);
8624 VARIMP(INT
,-1,UI4
,1,I4
,1);
8627 VARIMP(INT
,-1,I8
,1,I8
,1);
8628 VARIMP(INT
,-1,UI8
,1,I4
,1);
8630 VARIMP(INT
,-1,INT
,-1,I4
,-1);
8631 VARIMP(INT
,-1,UINT
,1,I4
,1);
8632 VARIMP(UINT
,1,EMPTY
,0,I4
,-2);
8633 VARIMP(UINT
,1,NULL
,0,I4
,-2);
8634 VARIMP(UINT
,1,I2
,-1,I4
,-1);
8635 VARIMP(UINT
,1,I4
,-1,I4
,-1);
8636 VARIMP(UINT
,1,R4
,0.0f
,I4
,-2);
8637 VARIMP(UINT
,1,R8
,-1.0,I4
,-1);
8638 VARIMP(UINT
,1,DATE
,0,I4
,-2);
8639 VARIMP(UINT
,1,BSTR
,true_str
,I4
,-1);
8640 VARIMP(UINT
,1,BOOL
,VARIANT_FALSE
,I4
,-2);
8641 VARIMP(UINT
,1,I1
,0,I4
,-2);
8642 VARIMP(UINT
,1,UI1
,1,I4
,-1);
8643 VARIMP(UINT
,1,UI2
,1,I4
,-1);
8644 VARIMP(UINT
,1,UI4
,1,I4
,-1);
8647 VARIMP(UINT
,1,I8
,1,I8
,-1);
8648 VARIMP(UINT
,1,UI8
,1,I4
,-1);
8650 VARIMP(UINT
,1,INT
,-1,I4
,-1);
8651 VARIMP(UINT
,1,UINT
,1,I4
,-1);
8653 /* Manually test some VT_CY, VT_DECIMAL variants */
8655 hres
= VarCyFromI4(1, &V_CY(&cy
));
8656 ok(hres
== S_OK
, "VarCyFromI4 failed!\n");
8657 V_VT(&dec
) = VT_DECIMAL
;
8658 hres
= VarDecFromR8(2.0, &V_DECIMAL(&dec
));
8659 ok(hres
== S_OK
, "VarDecFromR4 failed!\n");
8660 memset(&left
, 0, sizeof(left
));
8661 memset(&right
, 0, sizeof(right
));
8662 V_VT(&left
) = VT_I4
;
8664 V_VT(&right
) = VT_I8
;
8667 hres
= pVarImp(&cy
, &cy
, &result
);
8668 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
8669 "VARIMP: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8670 S_OK
, hres
, vtstr(V_VT(&result
)));
8671 ok(hres
== S_OK
&& V_I4(&result
) == -1,
8672 "VARIMP: CY value %d, expected %d\n", V_I4(&result
), -1);
8676 hres
= pVarImp(&cy
, &right
, &result
);
8677 ok(hres
== S_OK
&& V_VT(&result
) == VT_I8
,
8678 "VARIMP: expected coerced hres 0x%X type VT_I8, got hres 0x%X type %s!\n",
8679 S_OK
, hres
, vtstr(V_VT(&result
)));
8680 ok(hres
== S_OK
&& V_I8(&result
) == -2,
8681 "VARIMP: CY value %x%08x, expected %d\n",
8682 (DWORD
)((V_I8(&result
)) >> 32), (DWORD
)(V_I8(&result
)), -2);
8685 hres
= pVarImp(&left
, &cy
, &result
);
8686 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
8687 "VARIMP: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8688 S_OK
, hres
, vtstr(V_VT(&result
)));
8689 ok(hres
== S_OK
&& V_I4(&result
) == -1,
8690 "VARIMP: CY value %d, expected %d\n", V_I4(&result
), -1);
8692 hres
= pVarImp(&left
, &dec
, &result
);
8693 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
8694 "VARIMP: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8695 S_OK
, hres
, vtstr(V_VT(&result
)));
8696 ok(hres
== S_OK
&& V_I4(&result
) == -1,
8697 "VARIMP: DECIMAL value %d, expected %d\n", V_I4(&result
), -1);
8699 hres
= pVarImp(&dec
, &dec
, &result
);
8700 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
8701 "VARIMP: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8702 S_OK
, hres
, vtstr(V_VT(&result
)));
8703 ok(hres
== S_OK
&& V_I4(&result
) == -1,
8704 "VARIMP: DECIMAL value %d, expected %d\n", V_I4(&result
), -1);
8708 hres
= pVarImp(&dec
, &right
, &result
);
8709 ok(hres
== S_OK
&& V_VT(&result
) == VT_I8
,
8710 "VARIMP: expected coerced hres 0x%X type VT_I8, got hres 0x%X type %s!\n",
8711 S_OK
, hres
, vtstr(V_VT(&result
)));
8712 ok(hres
== S_OK
&& V_I8(&result
) == -3,
8713 "VARIMP: DECIMAL value 0x%x%08x, expected %d\n",
8714 (DWORD
)(V_I8(&result
) >>32), (DWORD
)V_I8(&result
), -3);
8717 SysFreeString(false_str
);
8718 SysFreeString(true_str
);
8726 test_VariantClear();
8728 test_VariantCopyInd();
8729 test_VarParseNumFromStr();
8730 test_VarNumFromParseNum();
8731 test_VarUdateFromDate();
8732 test_VarDateFromUdate();
8733 test_SystemTimeToVariantTime();
8734 test_VariantTimeToSystemTime();
8735 test_DosDateTimeToVariantTime();
8736 test_VariantTimeToDosDateTime();
8751 test_VarCmp(); /* Before test_VarCat() which needs VarCmp() */