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
30 #include "wine/test.h"
40 static HMODULE hOleaut32
;
42 static HRESULT (WINAPI
*pVarUdateFromDate
)(DATE
,ULONG
,UDATE
*);
43 static HRESULT (WINAPI
*pVarDateFromUdate
)(UDATE
*,ULONG
,DATE
*);
44 static INT (WINAPI
*pSystemTimeToVariantTime
)(LPSYSTEMTIME
,double*);
45 static INT (WINAPI
*pVariantTimeToSystemTime
)(double,LPSYSTEMTIME
);
46 static INT (WINAPI
*pDosDateTimeToVariantTime
)(USHORT
,USHORT
,double*);
47 static INT (WINAPI
*pVariantTimeToDosDateTime
)(double,USHORT
*,USHORT
*);
49 static const WCHAR sz12
[] = {'1','2','\0'};
50 /* the strings are localized */
51 static WCHAR sz12_false
[32];
52 static WCHAR sz12_true
[32];
54 /* Get a conversion function ptr, return if function not available */
55 #define CHECKPTR(func) p##func = (void*)GetProcAddress(hOleaut32, #func); \
56 if (!p##func) { trace("function " # func " not available, not testing it\n"); return; }
58 /* Have IRecordInfo data type? */
59 static int HAVE_OLEAUT32_RECORD
= 0;
60 /* Have I8/UI8 data type? */
61 static int HAVE_OLEAUT32_I8
= 0;
62 /* Is this an ancient version with support for only I2/I4/R4/R8/DATE? */
63 static int IS_ANCIENT
= 0;
65 /* When comparing floating point values we cannot expect an exact match
66 * because the rounding errors depend on the exact algorithm.
68 #define EQ_DOUBLE(a,b) (fabs((a)-(b)) / (1.0+fabs(a)+fabs(b)) < 1e-14)
69 #define EQ_FLOAT(a,b) (fabs((a)-(b)) / (1.0+fabs(a)+fabs(b)) < 1e-7)
71 #define SKIPTESTS(a) if((a > VT_CLSID+10) && (a < VT_BSTR_BLOB-10)) continue
73 /* Allow our test macros to work for VT_NULL and VT_EMPTY too */
74 #define V_EMPTY(v) V_I4(v)
75 #define V_NULL(v) V_I4(v)
77 /* Size constraints for overflow tests */
79 #define I1_MIN ((-I1_MAX)-1)
83 #define I2_MIN ((-I2_MAX)-1)
84 #define UI2_MAX 0xffff
86 #define I4_MAX 0x7fffffff
87 #define I4_MIN ((-I4_MAX)-1)
88 #define UI4_MAX 0xffffffff
90 #define I8_MAX (((LONGLONG)I4_MAX << 32) | UI4_MAX)
91 #define I8_MIN ((-I8_MAX)-1)
92 #define UI8_MAX (((ULONGLONG)UI4_MAX << 32) | UI4_MAX)
94 #define DATE_MAX 2958465
95 #define DATE_MIN -657434
96 #define R4_MAX FLT_MAX
97 #define R4_MIN FLT_MIN
98 #define R8_MAX DBL_MAX
99 #define R8_MIN DBL_MIN
101 static void init(void)
106 res
= VarBstrFromBool(VARIANT_TRUE
, LANG_USER_DEFAULT
, VAR_LOCALBOOL
, &bstr
);
107 ok(SUCCEEDED(res
) && (lstrlenW(bstr
) > 0),
108 "Expected localized string for 'True'\n");
109 /* lstrcpyW / lstrcatW do not work on win95 */
110 memcpy(sz12_true
, sz12
, sizeof(sz12
));
111 if (bstr
) memcpy(&sz12_true
[2], bstr
, SysStringByteLen(bstr
) + sizeof(WCHAR
));
114 res
= VarBstrFromBool(VARIANT_FALSE
, LANG_USER_DEFAULT
, VAR_LOCALBOOL
, &bstr
);
115 ok(SUCCEEDED(res
) && (lstrlenW(bstr
) > 0),
116 "Expected localized string for 'False'\n");
117 memcpy(sz12_false
, sz12
, sizeof(sz12
));
118 if (bstr
) memcpy(&sz12_false
[2], bstr
, SysStringByteLen(bstr
) + sizeof(WCHAR
));
121 hOleaut32
= GetModuleHandle("oleaut32.dll");
123 /* Is a given function exported from oleaut32? */
124 #define HAVE_FUNC(func) ((void*)GetProcAddress(hOleaut32, #func) != NULL)
126 HAVE_OLEAUT32_I8
= HAVE_FUNC(VarI8FromI1
);
127 if (!HAVE_OLEAUT32_I8
)
128 skip("No support for I8 and UI8 data types\n");
130 HAVE_OLEAUT32_RECORD
= HAVE_FUNC(SafeArraySetRecordInfo
);
131 IS_ANCIENT
= (!HAVE_FUNC(VarI1FromI2
));
136 /* Functions to set a DECIMAL */
137 static void setdec(DECIMAL
* dec
, BYTE scl
, BYTE sgn
, ULONG hi32
, ULONG64 lo64
)
139 S(U(*dec
)).scale
= scl
;
140 S(U(*dec
)).sign
= sgn
;
142 U1(*dec
).Lo64
= lo64
;
145 static void setdec64(DECIMAL
* dec
, BYTE scl
, BYTE sgn
, ULONG hi32
, ULONG mid32
, ULONG lo32
)
147 S(U(*dec
)).scale
= scl
;
148 S(U(*dec
)).sign
= sgn
;
150 S1(U1(*dec
)).Mid32
= mid32
;
151 S1(U1(*dec
)).Lo32
= lo32
;
154 static inline int strcmpW( const WCHAR
*str1
, const WCHAR
*str2
)
156 while (*str1
&& (*str1
== *str2
)) { str1
++; str2
++; }
157 return *str1
- *str2
;
160 /* return the string text of a given variant type */
161 static char vtstr_buffer
[16][256];
162 static int vtstr_current
=0;
163 static const char *vtstr(int x
)
166 #define CASE(vt) case VT_##vt: return #vt
205 CASE(STREAMED_OBJECT
);
210 CASE(VERSIONED_STREAM
);
219 return "VT_BSTR_BLOB/VT_ILLEGALMASKED/VT_TYPEMASK";
222 vtstr_current
%= sizeof(vtstr_buffer
)/sizeof(*vtstr_buffer
);
223 sprintf(vtstr_buffer
[vtstr_current
], "unknown variant type %d", x
);
224 return vtstr_buffer
[vtstr_current
++];
228 static const char *variantstr( const VARIANT
*var
)
230 vtstr_current
%= sizeof(vtstr_buffer
)/sizeof(*vtstr_buffer
);
234 sprintf( vtstr_buffer
[vtstr_current
], "VT_I1(%d)", V_I1(var
) ); break;
236 sprintf( vtstr_buffer
[vtstr_current
], "VT_I2(%d)", V_I2(var
) ); break;
238 sprintf( vtstr_buffer
[vtstr_current
], "VT_I4(%d)", V_I4(var
) ); break;
240 sprintf( vtstr_buffer
[vtstr_current
], "VT_INT(%d)", V_INT(var
) ); break;
242 sprintf( vtstr_buffer
[vtstr_current
], "VT_I8(%x%08x)", (UINT
)(V_I8(var
) >> 32), (UINT
)V_I8(var
) ); break;
244 sprintf( vtstr_buffer
[vtstr_current
], "VT_UI8(%x%08x)", (UINT
)(V_UI8(var
) >> 32), (UINT
)V_UI8(var
) ); break;
246 sprintf( vtstr_buffer
[vtstr_current
], "VT_R4(%g)", V_R4(var
) ); break;
248 sprintf( vtstr_buffer
[vtstr_current
], "VT_R8(%g)", V_R8(var
) ); break;
250 sprintf( vtstr_buffer
[vtstr_current
], "VT_UI1(%u)", V_UI1(var
) ); break;
252 sprintf( vtstr_buffer
[vtstr_current
], "VT_UI2(%u)", V_UI2(var
) ); break;
254 sprintf( vtstr_buffer
[vtstr_current
], "VT_UI4(%u)", V_UI4(var
) ); break;
256 sprintf( vtstr_buffer
[vtstr_current
], "VT_UINT(%d)", V_UINT(var
) ); break;
258 sprintf( vtstr_buffer
[vtstr_current
], "VT_CY(%x%08x)", S(V_CY(var
)).Hi
, S(V_CY(var
)).Lo
); break;
260 sprintf( vtstr_buffer
[vtstr_current
], "VT_DATE(%g)", V_DATE(var
) ); break;
262 return vtstr(V_VT(var
));
264 return vtstr_buffer
[vtstr_current
++];
267 static BOOL
is_expected_variant( const VARIANT
*result
, const VARIANT
*expected
)
269 if (V_VT(result
) != V_VT(expected
)) return FALSE
;
270 switch(V_VT(expected
))
276 #define CASE(vt) case VT_##vt: return (V_##vt(result) == V_##vt(expected))
291 return EQ_FLOAT(V_DATE(result
), V_DATE(expected
));
293 return EQ_FLOAT(V_R4(result
), V_R4(expected
));
295 return EQ_FLOAT(V_R8(result
), V_R8(expected
));
297 return (V_CY(result
).int64
== V_CY(expected
).int64
);
299 return !lstrcmpW( V_BSTR(result
), V_BSTR(expected
) );
301 return !memcmp( &V_DECIMAL(result
), &V_DECIMAL(expected
), sizeof(DECIMAL
) );
303 ok(0, "unhandled variant type %s\n",vtstr(V_VT(expected
)));
308 static void test_var_call1( int line
, HRESULT (WINAPI
*func
)(LPVARIANT
,LPVARIANT
),
309 VARIANT
*arg
, VARIANT
*expected
)
311 VARIANT old_arg
= *arg
;
315 memset( &result
, 0, sizeof(result
) );
316 hres
= func( arg
, &result
);
317 ok_(__FILE__
,line
)( hres
== S_OK
, "wrong result %x\n", hres
);
319 ok_(__FILE__
,line
)( is_expected_variant( &result
, expected
),
320 "got %s expected %s\n", variantstr(&result
), variantstr(expected
) );
321 ok_(__FILE__
,line
)( is_expected_variant( arg
, &old_arg
), "Modified argument %s / %s\n",
322 variantstr(&old_arg
), variantstr(arg
));
323 VariantClear( &result
);
326 static void test_var_call2( int line
, HRESULT (WINAPI
*func
)(LPVARIANT
,LPVARIANT
,LPVARIANT
),
327 VARIANT
*left
, VARIANT
*right
, VARIANT
*expected
)
329 VARIANT old_left
= *left
, old_right
= *right
;
333 memset( &result
, 0, sizeof(result
) );
334 hres
= func( left
, right
, &result
);
335 ok_(__FILE__
,line
)( hres
== S_OK
, "wrong result %x\n", hres
);
337 ok_(__FILE__
,line
)( is_expected_variant( &result
, expected
),
338 "got %s expected %s\n", variantstr(&result
), variantstr(expected
) );
339 ok_(__FILE__
,line
)( is_expected_variant( left
, &old_left
), "Modified left argument %s / %s\n",
340 variantstr(&old_left
), variantstr(left
));
341 ok_(__FILE__
,line
)( is_expected_variant( right
, &old_right
), "Modified right argument %s / %s\n",
342 variantstr(&old_right
), variantstr(right
));
343 VariantClear( &result
);
347 static void test_VariantInit(void)
351 /* Test that VariantInit() only sets the type */
352 memset(&v1
, -1, sizeof(v1
));
354 V_VT(&v2
) = VT_EMPTY
;
356 ok(!memcmp(&v1
, &v2
, sizeof(v1
)), "VariantInit() set extra fields\n");
359 /* All possible combinations of extra V_VT() flags */
360 static const VARTYPE ExtraFlags
[16] =
369 VT_VECTOR
|VT_RESERVED
,
370 VT_VECTOR
|VT_ARRAY
|VT_BYREF
,
371 VT_VECTOR
|VT_ARRAY
|VT_RESERVED
,
372 VT_VECTOR
|VT_BYREF
|VT_RESERVED
,
373 VT_VECTOR
|VT_ARRAY
|VT_BYREF
|VT_RESERVED
,
375 VT_ARRAY
|VT_RESERVED
,
376 VT_ARRAY
|VT_BYREF
|VT_RESERVED
,
377 VT_BYREF
|VT_RESERVED
,
380 /* Determine if a vt is valid for VariantClear() */
381 static int IsValidVariantClearVT(VARTYPE vt
, VARTYPE extraFlags
)
385 /* Only the following flags/types are valid */
386 if ((vt
<= VT_LPWSTR
|| vt
== VT_RECORD
|| vt
== VT_CLSID
) &&
388 (vt
< (VARTYPE
)24 || vt
> (VARTYPE
)31) &&
389 (!(extraFlags
& (VT_BYREF
|VT_ARRAY
)) || vt
> VT_NULL
) &&
390 (extraFlags
== 0 || extraFlags
== VT_BYREF
|| extraFlags
== VT_ARRAY
||
391 extraFlags
== (VT_ARRAY
|VT_BYREF
)))
394 if ((vt
== VT_RECORD
&& !HAVE_OLEAUT32_RECORD
) ||
395 ((vt
== VT_I8
|| vt
== VT_UI8
) && !HAVE_OLEAUT32_I8
))
396 ret
= 0; /* Old versions of oleaut32 */
402 const IUnknownVtbl
*lpVtbl
;
405 } test_VariantClearImpl
;
407 static HRESULT WINAPI
VC_QueryInterface(LPUNKNOWN iface
,REFIID riid
,LPVOID
*ppobj
)
409 test_VariantClearImpl
*This
= (test_VariantClearImpl
*)iface
;
411 return E_NOINTERFACE
;
414 static ULONG WINAPI
VC_AddRef(LPUNKNOWN iface
) {
415 test_VariantClearImpl
*This
= (test_VariantClearImpl
*)iface
;
417 return InterlockedIncrement(&This
->ref
);
420 static ULONG WINAPI
VC_Release(LPUNKNOWN iface
) {
421 test_VariantClearImpl
*This
= (test_VariantClearImpl
*)iface
;
422 /* static class, won't be freed */
424 return InterlockedDecrement(&This
->ref
);
427 static const IUnknownVtbl test_VariantClear_vtbl
= {
433 static test_VariantClearImpl test_myVariantClearImpl
= {&test_VariantClear_vtbl
, 1, 0};
435 static void test_VariantClear(void)
444 /* Crashes: Native does not test input for NULL, so neither does Wine */
445 if (0) hres
= VariantClear(NULL
);
447 /* Only the type field is set, to VT_EMPTY */
450 hres
= VariantClear(&v
);
451 ok((hres
== S_OK
&& V_VT(&v
) == VT_EMPTY
) ||
452 (IS_ANCIENT
&& hres
== DISP_E_BADVARTYPE
&& V_VT(&v
) == VT_UI4
),
453 "VariantClear: Type set to %d, res %08x\n", V_VT(&v
), hres
);
454 ok(V_UI4(&v
) == ~0u, "VariantClear: Overwrote value\n");
456 /* Test all possible V_VT values.
457 * Also demonstrates that null pointers in 'v' are not dereferenced.
458 * Individual variant tests should test VariantClear() with non-NULL values.
460 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]) && !IS_ANCIENT
; i
++)
464 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
466 HRESULT hExpected
= DISP_E_BADVARTYPE
;
470 memset(&v
, 0, sizeof(v
));
471 V_VT(&v
) = vt
| ExtraFlags
[i
];
473 hres
= VariantClear(&v
);
475 if (IsValidVariantClearVT(vt
, ExtraFlags
[i
]))
478 ok(hres
== hExpected
, "VariantClear: expected 0x%X, got 0x%X for vt %d | 0x%X\n",
479 hExpected
, hres
, vt
, ExtraFlags
[i
]);
483 /* Some BYREF tests with non-NULL ptrs */
488 V_VT(&v
) = VT_VARIANT
| VT_BYREF
;
489 V_VARIANTREF(&v
) = &v2
;
491 hres
= VariantClear(&v
);
492 ok(hres
== S_OK
, "ret %08x\n", hres
);
493 ok(V_VT(&v
) == 0, "vt %04x\n", V_VT(&v
));
494 ok(V_VARIANTREF(&v
) == &v2
, "variant ref %p\n", V_VARIANTREF(&v2
));
495 ok(V_VT(&v2
) == VT_I4
, "vt %04x\n", V_VT(&v2
));
496 ok(V_I4(&v2
) == 0x1234, "i4 %04x\n", V_I4(&v2
));
500 V_VT(&v
) = VT_I4
| VT_BYREF
;
503 hres
= VariantClear(&v
);
504 ok(hres
== S_OK
, "ret %08x\n", hres
);
505 ok(V_VT(&v
) == 0, "vt %04x\n", V_VT(&v
));
506 ok(V_I4REF(&v
) == &i4
, "i4 ref %p\n", V_I4REF(&v2
));
507 ok(i4
== 0x4321, "i4 changed %08x\n", i4
);
511 V_VT(&v
) = VT_UNKNOWN
;
512 V_UNKNOWN(&v
) = (IUnknown
*)&test_myVariantClearImpl
;
513 test_myVariantClearImpl
.events
= 0;
514 hres
= VariantClear(&v
);
515 ok(hres
== S_OK
, "ret %08x\n", hres
);
516 ok(V_VT(&v
) == 0, "vt %04x\n", V_VT(&v
));
517 ok(V_UNKNOWN(&v
) == (IUnknown
*)&test_myVariantClearImpl
, "unknown %p\n", V_UNKNOWN(&v
));
518 /* Check that Release got called, but nothing else */
519 ok(test_myVariantClearImpl
.events
== 0x4, "Unexpected call. events %08x\n", test_myVariantClearImpl
.events
);
522 punk
= (IUnknown
*)&test_myVariantClearImpl
;
523 V_VT(&v
) = VT_UNKNOWN
| VT_BYREF
;
524 V_UNKNOWNREF(&v
) = &punk
;
525 test_myVariantClearImpl
.events
= 0;
526 hres
= VariantClear(&v
);
527 ok(hres
== S_OK
, "ret %08x\n", hres
);
528 ok(V_VT(&v
) == 0, "vt %04x\n", V_VT(&v
));
529 ok(V_UNKNOWNREF(&v
) == &punk
, "unknown ref %p\n", V_UNKNOWNREF(&v
));
530 /* Check that nothing got called */
531 ok(test_myVariantClearImpl
.events
== 0, "Unexpected call. events %08x\n", test_myVariantClearImpl
.events
);
534 V_VT(&v
) = VT_DISPATCH
;
535 V_DISPATCH(&v
) = (IDispatch
*)&test_myVariantClearImpl
;
536 test_myVariantClearImpl
.events
= 0;
537 hres
= VariantClear(&v
);
538 ok(hres
== S_OK
, "ret %08x\n", hres
);
539 ok(V_VT(&v
) == 0, "vt %04x\n", V_VT(&v
));
540 ok(V_DISPATCH(&v
) == (IDispatch
*)&test_myVariantClearImpl
, "dispatch %p\n", V_DISPATCH(&v
));
541 /* Check that Release got called, but nothing else */
542 ok(test_myVariantClearImpl
.events
== 0x4, "Unexpected call. events %08x\n", test_myVariantClearImpl
.events
);
545 punk
= (IUnknown
*)&test_myVariantClearImpl
;
546 V_VT(&v
) = VT_DISPATCH
| VT_BYREF
;
547 V_DISPATCHREF(&v
) = (IDispatch
**)&punk
;
548 test_myVariantClearImpl
.events
= 0;
549 hres
= VariantClear(&v
);
550 ok(hres
== S_OK
, "ret %08x\n", hres
);
551 ok(V_VT(&v
) == 0, "vt %04x\n", V_VT(&v
));
552 ok(V_DISPATCHREF(&v
) == (IDispatch
**)&punk
, "dispatch ref %p\n", V_DISPATCHREF(&v
));
553 /* Check that nothing got called */
554 ok(test_myVariantClearImpl
.events
== 0, "Unexpected call. events %08x\n", test_myVariantClearImpl
.events
);
557 static void test_VariantCopy(void)
559 VARIANTARG vSrc
, vDst
;
562 HRESULT hres
, hExpected
;
564 /* Establish that the failure/other cases are dealt with. Individual tests
565 * for each type should verify that data is copied correctly, references
570 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]) && !IS_ANCIENT
; i
++)
572 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
576 memset(&vSrc
, 0, sizeof(vSrc
));
577 V_VT(&vSrc
) = vt
| ExtraFlags
[i
];
579 hExpected
= DISP_E_BADVARTYPE
;
580 /* src is allowed to be a VT_CLSID */
581 if (vt
!= VT_CLSID
&& IsValidVariantClearVT(vt
, ExtraFlags
[i
]))
584 hres
= VariantCopy(&vSrc
, &vSrc
);
586 ok(hres
== hExpected
,
587 "Copy(src==dst): expected 0x%X, got 0x%X for src==dest vt %d|0x%X\n",
588 hExpected
, hres
, vt
, ExtraFlags
[i
]);
592 /* Test that if VariantClear() fails on dest, the function fails. This also
593 * shows that dest is in fact cleared and not just overwritten
595 memset(&vSrc
, 0, sizeof(vSrc
));
596 V_VT(&vSrc
) = VT_UI1
;
598 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]) && !IS_ANCIENT
; i
++)
600 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
604 hExpected
= DISP_E_BADVARTYPE
;
606 memset(&vDst
, 0, sizeof(vDst
));
607 V_VT(&vDst
) = vt
| ExtraFlags
[i
];
609 if (IsValidVariantClearVT(vt
, ExtraFlags
[i
]))
612 hres
= VariantCopy(&vDst
, &vSrc
);
614 ok(hres
== hExpected
,
615 "Copy(bad dst): expected 0x%X, got 0x%X for dest vt %d|0x%X\n",
616 hExpected
, hres
, vt
, ExtraFlags
[i
]);
618 ok(V_VT(&vDst
) == VT_UI1
,
619 "Copy(bad dst): expected vt = VT_UI1, got %d\n", V_VT(&vDst
));
623 /* Test that VariantClear() checks vSrc for validity before copying */
624 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]) && !IS_ANCIENT
; i
++)
626 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
630 hExpected
= DISP_E_BADVARTYPE
;
632 memset(&vDst
, 0, sizeof(vDst
));
633 V_VT(&vDst
) = VT_EMPTY
;
635 memset(&vSrc
, 0, sizeof(vSrc
));
636 V_VT(&vSrc
) = vt
| ExtraFlags
[i
];
638 /* src is allowed to be a VT_CLSID */
639 if (vt
!= VT_CLSID
&& IsValidVariantClearVT(vt
, ExtraFlags
[i
]))
642 hres
= VariantCopy(&vDst
, &vSrc
);
644 ok(hres
== hExpected
,
645 "Copy(bad src): expected 0x%X, got 0x%X for src vt %d|0x%X\n",
646 hExpected
, hres
, vt
, ExtraFlags
[i
]);
649 ok(V_VT(&vDst
) == (vt
|ExtraFlags
[i
]),
650 "Copy(bad src): expected vt = %d, got %d\n",
651 vt
| ExtraFlags
[i
], V_VT(&vDst
));
657 /* Test that copying a NULL BSTR results in an empty BSTR */
658 memset(&vDst
, 0, sizeof(vDst
));
659 V_VT(&vDst
) = VT_EMPTY
;
660 memset(&vSrc
, 0, sizeof(vSrc
));
661 V_VT(&vSrc
) = VT_BSTR
;
662 hres
= VariantCopy(&vDst
, &vSrc
);
663 ok(hres
== S_OK
, "Copy(NULL BSTR): Failed to copy a NULL BSTR\n");
666 ok((V_VT(&vDst
) == VT_BSTR
) && V_BSTR(&vDst
),
667 "Copy(NULL BSTR): should have non-NULL result\n");
668 if ((V_VT(&vDst
) == VT_BSTR
) && V_BSTR(&vDst
))
670 ok(*V_BSTR(&vDst
) == 0, "Copy(NULL BSTR): result not empty\n");
676 /* Determine if a vt is valid for VariantCopyInd() */
677 static int IsValidVariantCopyIndVT(VARTYPE vt
, VARTYPE extraFlags
)
681 if ((extraFlags
& VT_ARRAY
) ||
682 (vt
> VT_NULL
&& vt
!= (VARTYPE
)15 && vt
< VT_VOID
&&
683 !(extraFlags
& (VT_VECTOR
|VT_RESERVED
))))
690 static void test_VariantCopyInd(void)
692 VARIANTARG vSrc
, vDst
, vRef
, vRef2
;
696 HRESULT hres
, hExpected
;
698 memset(buffer
, 0, sizeof(buffer
));
701 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]) && !IS_ANCIENT
; i
++)
703 if (ExtraFlags
[i
] & VT_ARRAY
)
704 continue; /* Native crashes on NULL safearray */
706 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
710 memset(&vSrc
, 0, sizeof(vSrc
));
711 V_VT(&vSrc
) = vt
| ExtraFlags
[i
];
713 hExpected
= DISP_E_BADVARTYPE
;
714 if (!(ExtraFlags
[i
] & VT_BYREF
))
716 /* if src is not by-reference, acts as VariantCopy() */
717 if (vt
!= VT_CLSID
&& IsValidVariantClearVT(vt
, ExtraFlags
[i
]))
722 if (vt
== VT_SAFEARRAY
|| vt
== VT_BSTR
|| vt
== VT_UNKNOWN
||
723 vt
== VT_DISPATCH
|| vt
== VT_RECORD
)
724 continue; /* Need valid ptrs for deep copies */
726 V_BYREF(&vSrc
) = &buffer
;
727 hExpected
= E_INVALIDARG
;
729 if ((vt
== VT_I8
|| vt
== VT_UI8
) &&
730 ExtraFlags
[i
] == VT_BYREF
)
732 if (HAVE_OLEAUT32_I8
)
733 hExpected
= S_OK
; /* Only valid if I8 is a known type */
735 else if (IsValidVariantCopyIndVT(vt
, ExtraFlags
[i
]))
739 hres
= VariantCopyInd(&vSrc
, &vSrc
);
741 ok(hres
== hExpected
,
742 "CopyInd(src==dst): expected 0x%X, got 0x%X for src==dst vt %d|0x%X\n",
743 hExpected
, hres
, vt
, ExtraFlags
[i
]);
748 memset(&vSrc
, 0, sizeof(vSrc
));
749 V_VT(&vSrc
) = VT_UI1
|VT_BYREF
;
750 V_BYREF(&vSrc
) = &buffer
;
752 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]) && !IS_ANCIENT
; i
++)
754 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
758 memset(&vDst
, 0, sizeof(vDst
));
759 V_VT(&vDst
) = vt
| ExtraFlags
[i
];
761 hExpected
= DISP_E_BADVARTYPE
;
763 if (IsValidVariantClearVT(vt
, ExtraFlags
[i
]))
766 hres
= VariantCopyInd(&vDst
, &vSrc
);
768 ok(hres
== hExpected
,
769 "CopyInd(bad dst): expected 0x%X, got 0x%X for dst vt %d|0x%X\n",
770 hExpected
, hres
, vt
, ExtraFlags
[i
]);
772 ok(V_VT(&vDst
) == VT_UI1
,
773 "CopyInd(bad dst): expected vt = VT_UI1, got %d\n", V_VT(&vDst
));
778 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]) && !IS_ANCIENT
; i
++)
780 if (ExtraFlags
[i
] & VT_ARRAY
)
781 continue; /* Native crashes on NULL safearray */
783 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
787 memset(&vDst
, 0, sizeof(vDst
));
788 V_VT(&vDst
) = VT_EMPTY
;
790 memset(&vSrc
, 0, sizeof(vSrc
));
791 V_VT(&vSrc
) = vt
| ExtraFlags
[i
];
793 hExpected
= DISP_E_BADVARTYPE
;
794 if (!(ExtraFlags
[i
] & VT_BYREF
))
796 /* if src is not by-reference, acts as VariantCopy() */
797 if (vt
!= VT_CLSID
&& IsValidVariantClearVT(vt
, ExtraFlags
[i
]))
802 if (vt
== VT_SAFEARRAY
|| vt
== VT_BSTR
|| vt
== VT_UNKNOWN
||
803 vt
== VT_DISPATCH
|| vt
== VT_RECORD
)
804 continue; /* Need valid ptrs for deep copies, see vartype.c */
806 V_BYREF(&vSrc
) = &buffer
;
808 hExpected
= E_INVALIDARG
;
810 if ((vt
== VT_I8
|| vt
== VT_UI8
) &&
811 ExtraFlags
[i
] == VT_BYREF
)
813 if (HAVE_OLEAUT32_I8
)
814 hExpected
= S_OK
; /* Only valid if I8 is a known type */
816 else if (IsValidVariantCopyIndVT(vt
, ExtraFlags
[i
]))
820 hres
= VariantCopyInd(&vDst
, &vSrc
);
822 ok(hres
== hExpected
,
823 "CopyInd(bad src): expected 0x%X, got 0x%X for src vt %d|0x%X\n",
824 hExpected
, hres
, vt
, ExtraFlags
[i
]);
827 if (vt
== VT_VARIANT
&& ExtraFlags
[i
] == VT_BYREF
)
829 /* Type of vDst should be the type of the referenced variant.
830 * Since we set the buffer to all zeros, its type should be
833 ok(V_VT(&vDst
) == VT_EMPTY
,
834 "CopyInd(bad src): expected dst vt = VT_EMPTY, got %d|0x%X\n",
835 V_VT(&vDst
) & VT_TYPEMASK
, V_VT(&vDst
) & ~VT_TYPEMASK
);
839 ok(V_VT(&vDst
) == (vt
|(ExtraFlags
[i
] & ~VT_BYREF
)),
840 "CopyInd(bad src): expected dst vt = %d|0x%X, got %d|0x%X\n",
841 vt
, ExtraFlags
[i
] & ~VT_BYREF
,
842 V_VT(&vDst
) & VT_TYPEMASK
, V_VT(&vDst
) & ~VT_TYPEMASK
);
849 /* By-reference variants are dereferenced */
850 V_VT(&vRef
) = VT_UI1
;
852 V_VT(&vSrc
) = VT_VARIANT
|VT_BYREF
;
853 V_VARIANTREF(&vSrc
) = &vRef
;
856 hres
= VariantCopyInd(&vDst
, &vSrc
);
857 ok(V_VT(&vDst
) == VT_UI1
&& V_UI1(&vDst
) == 0x77,
858 "CopyInd(deref): expected dst vt = VT_UI1, val 0x77, got %d|0x%X, 0x%2X\n",
859 V_VT(&vDst
) & VT_TYPEMASK
, V_VT(&vDst
) & ~VT_TYPEMASK
, V_UI1(&vDst
));
861 /* By-reference variant to a by-reference type succeeds */
862 V_VT(&vRef
) = VT_UI1
|VT_BYREF
;
863 V_UI1REF(&vRef
) = buffer
; buffer
[0] = 0x88;
864 V_VT(&vSrc
) = VT_VARIANT
|VT_BYREF
;
865 V_VARIANTREF(&vSrc
) = &vRef
;
868 hres
= VariantCopyInd(&vDst
, &vSrc
);
869 ok(V_VT(&vDst
) == VT_UI1
&& V_UI1(&vDst
) == 0x88,
870 "CopyInd(deref): expected dst vt = VT_UI1, val 0x77, got %d|0x%X, 0x%2X\n",
871 V_VT(&vDst
) & VT_TYPEMASK
, V_VT(&vDst
) & ~VT_TYPEMASK
, V_UI1(&vDst
));
873 /* But a by-reference variant to a by-reference variant fails */
874 V_VT(&vRef2
) = VT_UI1
;
875 V_UI1(&vRef2
) = 0x77;
876 V_VT(&vRef
) = VT_VARIANT
|VT_BYREF
;
877 V_VARIANTREF(&vRef
) = &vRef2
;
878 V_VT(&vSrc
) = VT_VARIANT
|VT_BYREF
;
879 V_VARIANTREF(&vSrc
) = &vRef
;
882 hres
= VariantCopyInd(&vDst
, &vSrc
);
883 ok(hres
== E_INVALIDARG
,
884 "CopyInd(ref->ref): expected E_INVALIDARG, got 0x%08x\n", hres
);
887 static HRESULT (WINAPI
*pVarParseNumFromStr
)(OLECHAR
*,LCID
,ULONG
,NUMPARSE
*,BYTE
*);
889 /* Macros for converting and testing the result of VarParseNumFromStr */
892 static HRESULT
convert_str( const char *str
, INT dig
, ULONG flags
,
893 NUMPARSE
*np
, BYTE rgb
[128], LCID lcid
)
896 MultiByteToWideChar( CP_ACP
,0, str
, -1, buff
, sizeof(buff
)/sizeof(WCHAR
) );
897 memset( rgb
, FAILDIG
, 128 );
898 memset( np
, 255, sizeof(*np
) );
900 np
->dwInFlags
= flags
;
901 return pVarParseNumFromStr( buff
, lcid
, LOCALE_NOUSEROVERRIDE
, np
, rgb
);
904 static void expect_NumFromStr( int line
, HRESULT hres
, NUMPARSE
*np
, INT a
, ULONG b
, ULONG c
,
905 INT d
, INT e
, INT f
)
907 if (hres
== (HRESULT
)S_OK
)
909 ok_(__FILE__
,line
)(np
->cDig
== a
, "Expected cDig = %d, got %d\n", a
, np
->cDig
);
910 ok_(__FILE__
,line
)(np
->dwInFlags
== b
, "Expected dwInFlags = 0x%x, got 0x%x\n", b
, np
->dwInFlags
);
911 ok_(__FILE__
,line
)(np
->dwOutFlags
== c
, "Expected dwOutFlags = 0x%x, got 0x%x\n", c
, np
->dwOutFlags
);
912 ok_(__FILE__
,line
)(np
->cchUsed
== d
, "Expected cchUsed = %d, got %d\n", d
, np
->cchUsed
);
913 ok_(__FILE__
,line
)(np
->nBaseShift
== e
, "Expected nBaseShift = %d, got %d\n", e
, np
->nBaseShift
);
914 ok_(__FILE__
,line
)(np
->nPwr10
== f
, "Expected nPwr10 = %d, got %d\n", f
, np
->nPwr10
);
918 #define CONVERTN(str,dig,flags) hres = convert_str( str, dig, flags, &np, rgb, lcid )
919 #define CONVERT(str,flags) CONVERTN(str,sizeof(rgb),flags)
920 #define EXPECT(a,b,c,d,e,f) expect_NumFromStr( __LINE__, hres, &np, a, b, c, d, e, f )
921 #define EXPECTRGB(a,b) ok(rgb[a] == b, "Digit[%d], expected %d, got %d\n", a, b, rgb[a])
922 #define EXPECTFAIL ok(hres == (HRESULT)DISP_E_TYPEMISMATCH, "Call succeeded, hres = %08x\n", hres)
923 #define EXPECT2(a,b) EXPECTRGB(0,a); EXPECTRGB(1,b)
925 static void test_VarParseNumFromStr(void)
928 /* Ensure all tests are using the same locale characters for '$', ',' etc */
929 LCID lcid
= MAKELCID(MAKELANGID(LANG_ENGLISH
,SUBLANG_ENGLISH_US
),SORT_DEFAULT
);
935 CHECKPTR(VarParseNumFromStr
);
937 /* Consume a single digit */
942 /* cDig is not literal digits - zeros are suppressed and nPwr10 is increased */
945 /* Note: Win32 writes the trailing zeros if they are within cDig's limits,
946 * but then excludes them from the returned cDig count.
947 * In our implementation we don't bother writing them at all.
951 /* if cDig is too small and numbers follow, sets INEXACT */
953 EXPECT(1,0,NUMPRS_INEXACT
,2,0,1);
956 /* Strips leading zeros */
961 /* Strips leading zeros */
967 /* Fails on non digits */
970 EXPECTRGB(0,FAILDIG
);
972 /** NUMPRS_LEADING_WHITE/NUMPRS_TRAILING_WHITE **/
974 /* Without flag, fails on whitespace */
977 EXPECTRGB(0,FAILDIG
);
980 /* With flag, consumes whitespace */
981 CONVERT(" 0", NUMPRS_LEADING_WHITE
);
982 EXPECT(1,NUMPRS_LEADING_WHITE
,NUMPRS_LEADING_WHITE
,2,0,0);
985 /* Test TAB once, then assume it acts as space for all cases */
986 CONVERT("\t0", NUMPRS_LEADING_WHITE
);
987 EXPECT(1,NUMPRS_LEADING_WHITE
,NUMPRS_LEADING_WHITE
,2,0,0);
991 /* Doesn't pick up trailing whitespace without flag */
996 /* With flag, consumes trailing whitespace */
997 CONVERT("0 ", NUMPRS_TRAILING_WHITE
);
998 EXPECT(1,NUMPRS_TRAILING_WHITE
,NUMPRS_TRAILING_WHITE
,2,0,0);
1001 /* Leading flag only consumes leading */
1002 CONVERT(" 0 ", NUMPRS_LEADING_WHITE
);
1003 EXPECT(1,NUMPRS_LEADING_WHITE
,NUMPRS_LEADING_WHITE
,2,0,0);
1006 /* Both flags consumes both */
1007 CONVERT(" 0 ", NUMPRS_LEADING_WHITE
|NUMPRS_TRAILING_WHITE
);
1008 EXPECT(1,NUMPRS_LEADING_WHITE
|NUMPRS_TRAILING_WHITE
,NUMPRS_LEADING_WHITE
|NUMPRS_TRAILING_WHITE
,3,0,0);
1011 /** NUMPRS_LEADING_PLUS/NUMPRS_TRAILING_PLUS **/
1013 /* Without flag, fails on + */
1016 EXPECTRGB(0,FAILDIG
);
1018 /* With flag, consumes + */
1019 CONVERT("+0", NUMPRS_LEADING_PLUS
);
1020 EXPECT(1,NUMPRS_LEADING_PLUS
,NUMPRS_LEADING_PLUS
,2,0,0);
1023 /* Without flag, doesn't consume trailing + */
1025 EXPECT(1,0,0,1,0,0);
1028 /* With flag, consumes trailing + */
1029 CONVERT("0+", NUMPRS_TRAILING_PLUS
);
1030 EXPECT(1,NUMPRS_TRAILING_PLUS
,NUMPRS_TRAILING_PLUS
,2,0,0);
1033 /* With leading flag, doesn't consume trailing + */
1034 CONVERT("+0+", NUMPRS_LEADING_PLUS
);
1035 EXPECT(1,NUMPRS_LEADING_PLUS
,NUMPRS_LEADING_PLUS
,2,0,0);
1038 /* Trailing + doesn't get consumed if we specify both (unlike whitespace) */
1039 CONVERT("+0+", NUMPRS_LEADING_PLUS
|NUMPRS_TRAILING_PLUS
);
1040 EXPECT(1,NUMPRS_LEADING_PLUS
|NUMPRS_TRAILING_PLUS
,NUMPRS_LEADING_PLUS
,2,0,0);
1043 /** NUMPRS_LEADING_MINUS/NUMPRS_TRAILING_MINUS **/
1045 /* Without flag, fails on - */
1048 EXPECTRGB(0,FAILDIG
);
1050 /* With flag, consumes - */
1051 CONVERT("-0", NUMPRS_LEADING_MINUS
);
1052 EXPECT(1,NUMPRS_LEADING_MINUS
,NUMPRS_NEG
|NUMPRS_LEADING_MINUS
,2,0,0);
1055 /* Without flag, doesn't consume trailing - */
1057 EXPECT(1,0,0,1,0,0);
1060 /* With flag, consumes trailing - */
1061 CONVERT("0-", NUMPRS_TRAILING_MINUS
);
1062 EXPECT(1,NUMPRS_TRAILING_MINUS
,NUMPRS_NEG
|NUMPRS_TRAILING_MINUS
,2,0,0);
1065 /* With leading flag, doesn't consume trailing - */
1066 CONVERT("-0-", NUMPRS_LEADING_MINUS
);
1067 EXPECT(1,NUMPRS_LEADING_MINUS
,NUMPRS_NEG
|NUMPRS_LEADING_MINUS
,2,0,0);
1070 /* Trailing - doesn't get consumed if we specify both (unlike whitespace) */
1071 CONVERT("-0-", NUMPRS_LEADING_MINUS
|NUMPRS_TRAILING_MINUS
);
1072 EXPECT(1,NUMPRS_LEADING_MINUS
|NUMPRS_TRAILING_MINUS
,NUMPRS_NEG
|NUMPRS_LEADING_MINUS
,2,0,0);
1075 /** NUMPRS_HEX_OCT **/
1077 /* Could be hex, octal or decimal - With flag reads as decimal */
1078 CONVERT("0", NUMPRS_HEX_OCT
);
1079 EXPECT(1,NUMPRS_HEX_OCT
,0,1,0,0);
1082 /* Doesn't recognise hex in .asm syntax */
1083 CONVERT("0h", NUMPRS_HEX_OCT
);
1084 EXPECT(1,NUMPRS_HEX_OCT
,0,1,0,0);
1087 /* Doesn't fail with valid leading string but no digits */
1088 CONVERT("0x", NUMPRS_HEX_OCT
);
1089 EXPECT(1,NUMPRS_HEX_OCT
,0,1,0,0);
1092 /* Doesn't recognise hex format numbers at all! */
1093 CONVERT("0x0", NUMPRS_HEX_OCT
);
1094 EXPECT(1,NUMPRS_HEX_OCT
,0,1,0,0);
1097 /* Doesn't recognise plain hex digits either */
1098 CONVERT("FE", NUMPRS_HEX_OCT
);
1100 EXPECTRGB(0,FAILDIG
);
1103 CONVERT("0100", NUMPRS_HEX_OCT
);
1104 EXPECT(1,NUMPRS_HEX_OCT
,0,4,0,2);
1108 EXPECTRGB(3,FAILDIG
);
1111 CONVERT("&HF800", NUMPRS_HEX_OCT
);
1112 EXPECT(4,NUMPRS_HEX_OCT
,0x40,6,4,0);
1117 EXPECTRGB(4,FAILDIG
);
1119 /* VB hex lower case and leading zero */
1120 CONVERT("&h0abcdef", NUMPRS_HEX_OCT
);
1121 EXPECT(6,NUMPRS_HEX_OCT
,0x40,9,4,0);
1128 EXPECTRGB(6,FAILDIG
);
1131 CONVERT("&O300", NUMPRS_HEX_OCT
);
1132 EXPECT(3,NUMPRS_HEX_OCT
,0x40,5,3,0);
1136 EXPECTRGB(3,FAILDIG
);
1138 /* VB oct lower case and leading zero */
1139 CONVERT("&o0777", NUMPRS_HEX_OCT
);
1140 EXPECT(3,NUMPRS_HEX_OCT
,0x40,6,3,0);
1144 EXPECTRGB(3,FAILDIG
);
1146 /* VB oct char bigger than 7 */
1147 CONVERT("&o128", NUMPRS_HEX_OCT
);
1149 Native versions 2.x of oleaut32 allow this to succeed: later versions and Wine don't
1151 EXPECTRGB(0,FAILDIG);
1153 /** NUMPRS_PARENS **/
1155 /* Empty parens = error */
1156 CONVERT("()", NUMPRS_PARENS
);
1158 EXPECTRGB(0,FAILDIG
);
1160 /* With flag, trailing parens not consumed */
1161 CONVERT("0()", NUMPRS_PARENS
);
1162 EXPECT(1,NUMPRS_PARENS
,0,1,0,0);
1165 /* With flag, Number in parens made negative and parens consumed */
1166 CONVERT("(0)", NUMPRS_PARENS
);
1167 EXPECT(1,NUMPRS_PARENS
,NUMPRS_NEG
|NUMPRS_PARENS
,3,0,0);
1170 /** NUMPRS_THOUSANDS **/
1172 /* With flag, thousands sep. not needed */
1173 CONVERT("0", NUMPRS_THOUSANDS
);
1174 EXPECT(1,NUMPRS_THOUSANDS
,0,1,0,0);
1177 /* With flag, thousands sep. and following digits consumed */
1178 CONVERT("1,000", NUMPRS_THOUSANDS
);
1179 EXPECT(1,NUMPRS_THOUSANDS
,NUMPRS_THOUSANDS
,5,0,3);
1182 /* With flag and decimal point, thousands sep. but not decimals consumed */
1183 CONVERT("1,000.0", NUMPRS_THOUSANDS
);
1184 EXPECT(1,NUMPRS_THOUSANDS
,NUMPRS_THOUSANDS
,5,0,3);
1187 /** NUMPRS_CURRENCY **/
1189 /* Without flag, chokes on currency sign */
1192 EXPECTRGB(0,FAILDIG
);
1194 /* With flag, consumes currency sign */
1195 CONVERT("$11", NUMPRS_CURRENCY
);
1196 EXPECT(2,NUMPRS_CURRENCY
,NUMPRS_CURRENCY
,3,0,0);
1198 EXPECTRGB(2,FAILDIG
);
1200 /* With flag only, doesn't consume decimal point */
1201 CONVERT("$11.1", NUMPRS_CURRENCY
);
1202 EXPECT(2,NUMPRS_CURRENCY
,NUMPRS_CURRENCY
,3,0,0);
1204 EXPECTRGB(2,FAILDIG
);
1206 /* With flag and decimal flag, consumes decimal point and following digits */
1207 CONVERT("$11.1", NUMPRS_CURRENCY
|NUMPRS_DECIMAL
);
1208 EXPECT(3,NUMPRS_CURRENCY
|NUMPRS_DECIMAL
,NUMPRS_CURRENCY
|NUMPRS_DECIMAL
,5,0,-1);
1211 EXPECTRGB(3,FAILDIG
);
1213 /* Thousands flag can only be used with currency */
1214 CONVERT("$1,234", NUMPRS_CURRENCY
|NUMPRS_THOUSANDS
);
1215 EXPECT(4,NUMPRS_CURRENCY
|NUMPRS_THOUSANDS
,NUMPRS_CURRENCY
|NUMPRS_THOUSANDS
,6,0,0);
1219 EXPECTRGB(4,FAILDIG
);
1221 /** NUMPRS_DECIMAL **/
1223 /* With flag, consumes decimal point */
1224 CONVERT("1.1", NUMPRS_DECIMAL
);
1225 EXPECT(2,NUMPRS_DECIMAL
,NUMPRS_DECIMAL
,3,0,-1);
1227 EXPECTRGB(2,FAILDIG
);
1229 /* With flag, consumes decimal point. Skipping the decimal part is not an error */
1230 CONVERT("1.", NUMPRS_DECIMAL
);
1231 EXPECT(1,NUMPRS_DECIMAL
,NUMPRS_DECIMAL
,2,0,0);
1234 /* Consumes only one decimal point */
1235 CONVERT("1.1.", NUMPRS_DECIMAL
);
1236 EXPECT(2,NUMPRS_DECIMAL
,NUMPRS_DECIMAL
,3,0,-1);
1238 EXPECTRGB(2,FAILDIG
);
1240 /** NUMPRS_EXPONENT **/
1242 /* Without flag, doesn't consume exponent */
1244 EXPECT(1,0,0,1,0,0);
1247 /* With flag, consumes exponent */
1248 CONVERT("1e1", NUMPRS_EXPONENT
);
1249 EXPECT(1,NUMPRS_EXPONENT
,NUMPRS_EXPONENT
,3,0,1);
1252 /* Negative exponents are accepted without flags */
1253 CONVERT("1e-1", NUMPRS_EXPONENT
);
1254 EXPECT(1,NUMPRS_EXPONENT
,NUMPRS_EXPONENT
,4,0,-1);
1257 /* As are positive exponents and leading exponent 0s */
1258 CONVERT("1e+01", NUMPRS_EXPONENT
);
1259 EXPECT(1,NUMPRS_EXPONENT
,NUMPRS_EXPONENT
,5,0,1);
1262 /* The same for zero exponents */
1263 CONVERT("1e0", NUMPRS_EXPONENT
);
1264 EXPECT(1,NUMPRS_EXPONENT
,NUMPRS_EXPONENT
,3,0,0);
1267 /* Sign on a zero exponent doesn't matter */
1268 CONVERT("1e+0", NUMPRS_EXPONENT
);
1269 EXPECT(1,NUMPRS_EXPONENT
,NUMPRS_EXPONENT
,4,0,0);
1272 CONVERT("1e-0", NUMPRS_EXPONENT
);
1273 EXPECT(1,NUMPRS_EXPONENT
,NUMPRS_EXPONENT
,4,0,0);
1276 /* Doesn't consume a real number exponent */
1277 CONVERT("1e1.", NUMPRS_EXPONENT
);
1278 EXPECT(1,NUMPRS_EXPONENT
,NUMPRS_EXPONENT
,3,0,1);
1281 /* Powers of 10 are calculated from the position of any decimal point */
1282 CONVERT("1.5e20", NUMPRS_EXPONENT
|NUMPRS_DECIMAL
);
1283 EXPECT(2,NUMPRS_EXPONENT
|NUMPRS_DECIMAL
,NUMPRS_EXPONENT
|NUMPRS_DECIMAL
,6,0,19);
1286 CONVERT("1.5e-20", NUMPRS_EXPONENT
|NUMPRS_DECIMAL
);
1287 EXPECT(2,NUMPRS_EXPONENT
|NUMPRS_DECIMAL
,NUMPRS_EXPONENT
|NUMPRS_DECIMAL
,7,0,-21);
1290 /** NUMPRS_USE_ALL **/
1292 /* Flag expects all digits */
1293 CONVERT("0", NUMPRS_USE_ALL
);
1294 EXPECT(1,NUMPRS_USE_ALL
,0,1,0,0);
1297 /* Rejects anything trailing */
1298 CONVERT("0 ", NUMPRS_USE_ALL
);
1302 /* Unless consumed by trailing flag */
1303 CONVERT("0 ", NUMPRS_USE_ALL
|NUMPRS_TRAILING_WHITE
);
1304 EXPECT(1,NUMPRS_USE_ALL
|NUMPRS_TRAILING_WHITE
,NUMPRS_TRAILING_WHITE
,2,0,0);
1307 /** Combinations **/
1309 /* Leading whitespace and plus, doesn't consume trailing whitespace */
1310 CONVERT("+ 0 ", NUMPRS_LEADING_PLUS
|NUMPRS_LEADING_WHITE
);
1311 EXPECT(1,NUMPRS_LEADING_PLUS
|NUMPRS_LEADING_WHITE
,NUMPRS_LEADING_PLUS
|NUMPRS_LEADING_WHITE
,3,0,0);
1314 /* Order of whitespace and plus is unimportant */
1315 CONVERT(" +0", NUMPRS_LEADING_PLUS
|NUMPRS_LEADING_WHITE
);
1316 EXPECT(1,NUMPRS_LEADING_PLUS
|NUMPRS_LEADING_WHITE
,NUMPRS_LEADING_PLUS
|NUMPRS_LEADING_WHITE
,3,0,0);
1319 /* Leading whitespace can be repeated */
1320 CONVERT(" + 0", NUMPRS_LEADING_PLUS
|NUMPRS_LEADING_WHITE
);
1321 EXPECT(1,NUMPRS_LEADING_PLUS
|NUMPRS_LEADING_WHITE
,NUMPRS_LEADING_PLUS
|NUMPRS_LEADING_WHITE
,4,0,0);
1324 /* But plus/minus etc. cannot */
1325 CONVERT("+ +0", NUMPRS_LEADING_PLUS
|NUMPRS_LEADING_WHITE
);
1327 EXPECTRGB(0,FAILDIG
);
1329 /* Inexact is not set if trailing zeros are removed */
1330 CONVERTN("10", 1, 0);
1331 EXPECT(1,0,0,2,0,1);
1334 /* Make sure a leading 0 is stripped but decimals after it get read */
1335 CONVERT("-0.51", NUMPRS_STD
);
1336 EXPECT(2,NUMPRS_STD
,NUMPRS_NEG
|NUMPRS_DECIMAL
|NUMPRS_LEADING_MINUS
,5,0,-2);
1339 /* Keep trailing zeros on whole number part of a decimal */
1340 CONVERT("10.1", NUMPRS_STD
);
1341 EXPECT(3,NUMPRS_STD
,NUMPRS_DECIMAL
,4,0,-1);
1345 /* Zeros after decimal sign */
1346 CONVERT("0.01", NUMPRS_STD
);
1347 EXPECT(1,NUMPRS_STD
,NUMPRS_DECIMAL
,4,0,-2);
1350 /* Trailing zeros after decimal part */
1351 CONVERT("0.10", NUMPRS_STD
);
1352 EXPECT(1,NUMPRS_STD
,NUMPRS_DECIMAL
,4,0,-1);
1356 static HRESULT (WINAPI
*pVarNumFromParseNum
)(NUMPARSE
*,BYTE
*,ULONG
,VARIANT
*);
1358 /* Macros for converting and testing the result of VarNumFromParseNum */
1359 #define SETRGB(indx,val) if (!indx) memset(rgb, FAILDIG, sizeof(rgb)); rgb[indx] = val
1361 #define CONVERT(a,b,c,d,e,f,bits) \
1362 np.cDig = (a); np.dwInFlags = (b); np.dwOutFlags = (c); np.cchUsed = (d); \
1363 np.nBaseShift = (e); np.nPwr10 = (f); hres = pVarNumFromParseNum(&np, rgb, bits, &vOut)
1364 static const char *szFailOverflow
= "Expected overflow, hres = %08x\n";
1365 #define EXPECT_OVERFLOW ok(hres == (HRESULT)DISP_E_OVERFLOW, szFailOverflow, hres)
1366 static const char *szFailOk
= "Call failed, hres = %08x\n";
1367 #define EXPECT_OK ok(hres == (HRESULT)S_OK, szFailOk, hres); \
1368 if (hres == (HRESULT)S_OK)
1369 #define EXPECT_TYPE(typ) ok(V_VT(&vOut) == typ,"Expected Type = " #typ ", got %d\n", V_VT(&vOut))
1370 #define EXPECT_I1(val) EXPECT_OK { EXPECT_TYPE(VT_I1); \
1371 ok(V_I1(&vOut) == val, "Expected i1 = %d, got %d\n", (signed char)val, V_I1(&vOut)); }
1372 #define EXPECT_UI1(val) EXPECT_OK { EXPECT_TYPE(VT_UI1); \
1373 ok(V_UI1(&vOut) == val, "Expected ui1 = %d, got %d\n", (BYTE)val, V_UI1(&vOut)); }
1374 #define EXPECT_I2(val) EXPECT_OK { EXPECT_TYPE(VT_I2); \
1375 ok(V_I2(&vOut) == val, "Expected i2 = %d, got %d\n", (SHORT)val, V_I2(&vOut)); }
1376 #define EXPECT_UI2(val) EXPECT_OK { EXPECT_TYPE(VT_UI2); \
1377 ok(V_UI2(&vOut) == val, "Expected ui2 = %d, got %d\n", (USHORT)val, V_UI2(&vOut)); }
1378 #define EXPECT_I4(val) EXPECT_OK { EXPECT_TYPE(VT_I4); \
1379 ok(V_I4(&vOut) == val, "Expected i4 = %d, got %d\n", (LONG)val, V_I4(&vOut)); }
1380 #define EXPECT_UI4(val) EXPECT_OK { EXPECT_TYPE(VT_UI4); \
1381 ok(V_UI4(&vOut) == val, "Expected ui4 = %d, got %d\n", (ULONG)val, V_UI4(&vOut)); }
1382 #define EXPECT_I8(high,low) EXPECT_OK { EXPECT_TYPE(VT_I8); \
1383 ok(V_I8(&vOut) == ((((LONG64)(high))<<32)|(low)), "Expected i8 = %x%08x, got %x%08x\n", \
1384 (LONG)(high), (LONG)(low), (LONG)(V_I8(&vOut)>>32), (LONG)V_I8(&vOut) ); }
1385 #define EXPECT_UI8(val) EXPECT_OK { EXPECT_TYPE(VT_UI8); \
1386 ok(V_UI8(&vOut) == val, "Expected ui8 = 0x%x%08x, got 0x%x%08x\n", \
1387 (DWORD)((ULONG64)val >> 32), (DWORD)(ULONG64)val, (DWORD)(V_UI8(&vOut) >> 32), (DWORD)V_UI8(&vOut)); }
1388 #define EXPECT_R4(val) EXPECT_OK { EXPECT_TYPE(VT_R4); \
1389 ok(V_R4(&vOut) == val, "Expected r4 = %f, got %f\n", val, V_R4(&vOut)); }
1390 #define EXPECT_R8(val) EXPECT_OK { EXPECT_TYPE(VT_R8); \
1391 ok(V_R8(&vOut) == val, "Expected r8 = %g, got %g\n", val, V_R8(&vOut)); }
1392 #define CY_MULTIPLIER 10000
1393 #define EXPECT_CY(val) EXPECT_OK { EXPECT_TYPE(VT_CY); \
1394 ok(V_CY(&vOut).int64 == (LONG64)(val * CY_MULTIPLIER), "Expected r8 = 0x%x%08x, got 0x%x%08x\n", \
1395 (DWORD)((LONG64)val >> 23), (DWORD)(LONG64)val, (DWORD)(V_CY(&vOut).int64 >>32), (DWORD)V_CY(&vOut).int64); }
1396 #define EXPECT_DECIMAL(valHi, valMid, valLo) EXPECT_OK { EXPECT_TYPE(VT_DECIMAL); \
1397 ok((V_DECIMAL(&vOut).Hi32 == valHi) && (S1(U1(V_DECIMAL(&vOut))).Mid32 == valMid) && \
1398 (S1(U1(V_DECIMAL(&vOut))).Lo32 == valLo), \
1399 "Expected decimal = %x/0x%x%08x, got %x/0x%x%08x\n", valHi, valMid, valLo, \
1400 V_DECIMAL(&vOut).Hi32, S1(U1(V_DECIMAL(&vOut))).Mid32, S1(U1(V_DECIMAL(&vOut))).Lo32); }
1402 static void test_VarNumFromParseNum(void)
1409 CHECKPTR(VarNumFromParseNum
);
1411 /* Convert the number 1 to different types */
1412 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_I1
); EXPECT_I1(1);
1413 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_UI1
); EXPECT_UI1(1);
1414 /* Prefers a signed type to unsigned of the same size */
1415 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_I1
|VTBIT_UI1
); EXPECT_I1(1);
1416 /* But takes the smaller size if possible */
1417 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_I2
|VTBIT_UI1
); EXPECT_UI1(1);
1419 /* Try different integer sizes */
1420 #define INTEGER_VTBITS (VTBIT_I1|VTBIT_UI1|VTBIT_I2|VTBIT_UI2|VTBIT_I4|VTBIT_UI4|VTBIT_I8|VTBIT_UI8)
1422 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, INTEGER_VTBITS
); EXPECT_I1(1);
1424 SETRGB(0, 1); SETRGB(1, 2); SETRGB(2, 7);
1425 CONVERT(3,0,0,3,0,0, INTEGER_VTBITS
); EXPECT_I1(127);
1427 SETRGB(0, 1); SETRGB(1, 2); SETRGB(2, 8);
1428 CONVERT(3,0,0,3,0,0, INTEGER_VTBITS
); EXPECT_UI1(128);
1430 SETRGB(0, 2); SETRGB(1, 5); SETRGB(2, 5);
1431 CONVERT(3,0,0,3,0,0, INTEGER_VTBITS
); EXPECT_UI1(255);
1433 SETRGB(0, 2); SETRGB(1, 5); SETRGB(2, 6);
1434 CONVERT(3,0,0,3,0,0, INTEGER_VTBITS
); EXPECT_I2(256);
1436 SETRGB(0, 3); SETRGB(1, 2); SETRGB(2, 7); SETRGB(3, 6); SETRGB(4, 7);
1437 CONVERT(5,0,0,5,0,0, INTEGER_VTBITS
); EXPECT_I2(32767);
1439 SETRGB(0, 3); SETRGB(1, 2); SETRGB(2, 7); SETRGB(3, 6); SETRGB(4, 8);
1440 CONVERT(5,0,0,5,0,0, INTEGER_VTBITS
); EXPECT_UI2(32768);
1442 /* Assume the above pattern holds for remaining positive integers; test negative */
1445 SETRGB(0, 1); SETRGB(1, 2); SETRGB(2, 8);
1446 CONVERT(3,0,NUMPRS_NEG
,3,0,0, INTEGER_VTBITS
); EXPECT_I1(-128);
1448 SETRGB(0, 1); SETRGB(1, 2); SETRGB(2, 9);
1449 CONVERT(3,0,NUMPRS_NEG
,3,0,0, INTEGER_VTBITS
); EXPECT_I2(-129);
1451 SETRGB(0, 3); SETRGB(1, 2); SETRGB(2, 7); SETRGB(3, 6); SETRGB(4, 8);
1452 CONVERT(5,0,NUMPRS_NEG
,5,0,0, INTEGER_VTBITS
); EXPECT_I2(-32768);
1454 SETRGB(0, 3); SETRGB(1, 2); SETRGB(2, 7); SETRGB(3, 6); SETRGB(4, 9);
1455 CONVERT(5,0,NUMPRS_NEG
,5,0,0, INTEGER_VTBITS
); EXPECT_I4(-32769);
1457 /* Assume the above pattern holds for remaining negative integers */
1459 /* Test hexadecimal conversions */
1460 SETRGB(0, 1); CONVERT(1,0,0,1,4,0, INTEGER_VTBITS
); EXPECT_I1(0x01);
1462 SETRGB(0, 7); SETRGB(1, 0xf);
1463 CONVERT(2,0,0,2,4,0, INTEGER_VTBITS
); EXPECT_I1(0x7f);
1464 SETRGB(0, 7); SETRGB(1, 0xf);
1465 CONVERT(2,0,0,2,4,0, VTBIT_DECIMAL
); EXPECT_DECIMAL(0,0,0x7f);
1467 SETRGB(0, 7); SETRGB(1, 0xf); SETRGB(2, 0xf); SETRGB(3, 0xf);
1468 CONVERT(4,0,0,4,4,0, INTEGER_VTBITS
); EXPECT_I2(0x7fff);
1470 SETRGB(0, 7); SETRGB(1, 0xf); SETRGB(2, 0xf); SETRGB(3, 0xf);
1471 SETRGB(4, 0xf); SETRGB(5, 0xf); SETRGB(6, 0xf); SETRGB(7, 0xf);
1472 CONVERT(8,0,0,8,4,0, INTEGER_VTBITS
); EXPECT_I4(0x7fffffffL
);
1473 /* 0x7fffffffffffffff (64 bits) */
1474 SETRGB(0, 7); SETRGB(1, 0xf); SETRGB(2, 0xf); SETRGB(3, 0xf);
1475 SETRGB(4, 0xf); SETRGB(5, 0xf); SETRGB(6, 0xf); SETRGB(7, 0xf);
1476 SETRGB(8, 0xf); SETRGB(9, 0xf); SETRGB(10, 0xf); SETRGB(11, 0xf);
1477 SETRGB(12, 0xf); SETRGB(13, 0xf); SETRGB(14, 0xf); SETRGB(15, 0xf);
1478 if (HAVE_OLEAUT32_I8
)
1480 /* We cannot use INTEGER_VTBITS as WinXP and Win2003 are broken(?). They
1481 truncate the number to the smallest integer size requested:
1482 CONVERT(16,0,0,16,4,0, INTEGER_VTBITS); EXPECT_I1((signed char)0xff); */
1483 CONVERT(16,0,0,16,4,0, VTBIT_I8
); EXPECT_I8(0x7fffffff,0xffffffff);
1486 /* Assume the above pattern holds for numbers without hi-bit set, test (preservation of) hi-bit */
1488 SETRGB(0, 8); SETRGB(1, 2);
1489 CONVERT(2,0,0,2,4,0, INTEGER_VTBITS
);
1490 EXPECT_I1((signed char)0x82);
1492 SETRGB(0, 8); SETRGB(1, 0); SETRGB(2, 0); SETRGB(3, 2);
1493 CONVERT(4,0,0,4,4,0, INTEGER_VTBITS
);
1494 EXPECT_I2((signed short)0x8002);
1496 SETRGB(0, 8); SETRGB(1, 0); SETRGB(2, 0); SETRGB(3, 0);
1497 SETRGB(4, 0); SETRGB(5, 0); SETRGB(6, 0); SETRGB(7, 2);
1498 CONVERT(8,0,0,8,4,0, INTEGER_VTBITS
); EXPECT_I4(0x80000002);
1499 /* 0x8000000000000002 (64 bits) */
1500 SETRGB(0, 8); SETRGB(1, 0); SETRGB(2, 0); SETRGB(3, 0);
1501 SETRGB(4, 0); SETRGB(5, 0); SETRGB(6, 0); SETRGB(7, 0);
1502 SETRGB(8, 0); SETRGB(9, 0); SETRGB(10, 0); SETRGB(11, 0);
1503 SETRGB(12, 0); SETRGB(13, 0); SETRGB(14, 0); SETRGB(15, 2);
1504 if (HAVE_OLEAUT32_I8
)
1506 /* We cannot use INTEGER_VTBITS as WinXP and Win2003 are broken(?). They
1507 truncate the number to the smallest integer size requested:
1508 CONVERT(16,0,0,16,4,0, INTEGER_VTBITS & ~VTBIT_I1);
1509 EXPECT_I2((signed short)0x0002); */
1510 CONVERT(16,0,0,16,4,0, VTBIT_I8
); EXPECT_I8(0x80000000,0x00000002);
1513 /* Test (preservation of) hi-bit with STRICT type requesting */
1515 SETRGB(0, 8); SETRGB(1, 2);
1516 CONVERT(2,0,0,2,4,0, VTBIT_I1
);
1517 EXPECT_I1((signed char)0x82);
1519 SETRGB(0, 8); SETRGB(1, 0); SETRGB(2, 0); SETRGB(3, 2);
1520 CONVERT(4,0,0,4,4,0, VTBIT_I2
);
1521 EXPECT_I2((signed short)0x8002);
1523 SETRGB(0, 8); SETRGB(1, 0); SETRGB(2, 0); SETRGB(3, 0);
1524 SETRGB(4, 0); SETRGB(5, 0); SETRGB(6, 0); SETRGB(7, 2);
1525 CONVERT(8,0,0,8,4,0, VTBIT_I4
); EXPECT_I4(0x80000002);
1526 /* 0x8000000000000002 (64 bits) */
1527 SETRGB(0, 8); SETRGB(1, 0); SETRGB(2, 0); SETRGB(3, 0);
1528 SETRGB(4, 0); SETRGB(5, 0); SETRGB(6, 0); SETRGB(7, 0);
1529 SETRGB(8, 0); SETRGB(9, 0); SETRGB(10, 0); SETRGB(11, 0);
1530 SETRGB(12, 0); SETRGB(13, 0); SETRGB(14, 0); SETRGB(15, 2);
1531 if (HAVE_OLEAUT32_I8
)
1533 CONVERT(16,0,0,16,4,0, VTBIT_I8
); EXPECT_I8(0x80000000,0x00000002);
1535 /* Assume the above pattern holds for numbers with hi-bit set */
1537 /* Negative numbers overflow if we have only unsigned outputs */
1539 SETRGB(0, 1); CONVERT(1,0,NUMPRS_NEG
,1,0,0, VTBIT_UI1
); EXPECT_OVERFLOW
;
1541 SETRGB(0, 6); CONVERT(1,0,NUMPRS_NEG
,1,0,~0u, VTBIT_UI1
); EXPECT_OVERFLOW
;
1543 /* Except that rounding is done first, so -0.5 to 0 are accepted as 0 */
1545 SETRGB(0, 5); CONVERT(1,0,NUMPRS_NEG
,1,0,~0u, VTBIT_UI1
); EXPECT_UI1(0);
1547 /* Floating point zero is OK */
1549 SETRGB(0, 0); CONVERT(1,0,NUMPRS_DECIMAL
|NUMPRS_EXPONENT
,12,0,-8, VTBIT_R8
);
1552 /* Float is acceptable for an integer input value */
1553 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_R4
); EXPECT_R4(1.0f
);
1555 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_R8
); EXPECT_R8(1.0);
1556 /* As is currency */
1557 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_CY
); EXPECT_CY(1);
1559 /* Float is preferred over double */
1560 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_R4
|VTBIT_R8
); EXPECT_R4(1.0f
);
1562 /* Double is preferred over currency */
1563 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_R8
|VTBIT_CY
); EXPECT_R8(1.0);
1565 /* Currency is preferred over decimal */
1566 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_CY
|VTBIT_DECIMAL
); EXPECT_CY(1);
1570 static void test_UdateFromDate( int line
, DATE dt
, ULONG flags
, HRESULT r
, WORD d
, WORD m
, WORD y
,
1571 WORD h
, WORD mn
, WORD s
, WORD ms
, WORD dw
, WORD dy
)
1576 memset(&ud
, 0, sizeof(ud
));
1577 res
= pVarUdateFromDate(dt
, flags
, &ud
);
1578 ok_(__FILE__
,line
)(r
== res
, "Wrong result %x/%x\n", r
, res
);
1580 ok_(__FILE__
,line
)(ud
.st
.wYear
== y
&& ud
.st
.wMonth
== m
&& ud
.st
.wDay
== d
&&
1581 ud
.st
.wHour
== h
&& ud
.st
.wMinute
== mn
&& ud
.st
.wSecond
== s
&&
1582 ud
.st
.wMilliseconds
== ms
&& ud
.st
.wDayOfWeek
== dw
&& ud
.wDayOfYear
== dy
,
1583 "%.16g expected %d,%d,%d,%d,%d,%d,%d %d %d, got %d,%d,%d,%d,%d,%d,%d %d %d\n",
1584 dt
, d
, m
, y
, h
, mn
, s
, ms
, dw
, dy
,
1585 ud
.st
.wDay
, ud
.st
.wMonth
, ud
.st
.wYear
, ud
.st
.wHour
, ud
.st
.wMinute
,
1586 ud
.st
.wSecond
, ud
.st
.wMilliseconds
, ud
.st
.wDayOfWeek
, ud
.wDayOfYear
);
1588 #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)
1590 static void test_VarUdateFromDate(void)
1592 CHECKPTR(VarUdateFromDate
);
1593 DT2UD(29221.0,0,S_OK
,1,1,1980,0,0,0,0,2,1); /* 1 Jan 1980 */
1594 DT2UD(29222.0,0,S_OK
,2,1,1980,0,0,0,0,3,2); /* 2 Jan 1980 */
1595 DT2UD(33238.0,0,S_OK
,31,12,1990,0,0,0,0,1,365); /* 31 Dec 1990 */
1596 DT2UD(0.0,0,S_OK
,30,12,1899,0,0,0,0,6,364); /* 30 Dec 1899 - VT_DATE 0.0 */
1597 DT2UD(-657434.0,0,S_OK
,1,1,100,0,0,0,0,5,1); /* 1 Jan 100 - Min */
1598 DT2UD(-657435.0,0,E_INVALIDARG
,0,0,0,0,0,0,0,0,0); /* < 1 Jan 100 => err */
1599 DT2UD(2958465.0,0,S_OK
,31,12,9999,0,0,0,0,5,365); /* 31 Dec 9999 - Max */
1600 DT2UD(2958466.0,0,E_INVALIDARG
,0,0,0,0,0,0,0,0,0); /* > 31 Dec 9999 => err */
1602 /* VAR_VALIDDATE doesn't prevent upper and lower bounds being checked */
1603 DT2UD(-657435.0,VAR_VALIDDATE
,E_INVALIDARG
,0,0,0,0,0,0,0,0,0);
1604 DT2UD(2958466.0,VAR_VALIDDATE
,E_INVALIDARG
,0,0,0,0,0,0,0,0,0);
1607 DT2UD(29221.25,0,S_OK
,1,1,1980,6,0,0,0,2,1); /* 6 AM */
1608 DT2UD(29221.33333333,0,S_OK
,1,1,1980,8,0,0,0,2,1); /* 8 AM */
1609 DT2UD(29221.5,0,S_OK
,1,1,1980,12,0,0,0,2,1); /* 12 AM */
1610 DT2UD(29221.9888884444,0,S_OK
,1,1,1980,23,44,0,0,2,1); /* 11:44 PM */
1611 DT2UD(29221.7508765432,0,S_OK
,1,1,1980,18,1,16,0,2,1); /* 6:18:02 PM */
1615 static void test_DateFromUDate( int line
, WORD d
, WORD m
, WORD y
, WORD h
, WORD mn
, WORD s
, WORD ms
,
1616 WORD dw
, WORD dy
, ULONG flags
, HRESULT r
, DATE dt
)
1628 ud
.st
.wMilliseconds
= ms
;
1629 ud
.st
.wDayOfWeek
= dw
;
1631 res
= pVarDateFromUdate(&ud
, flags
, &out
);
1632 ok_(__FILE__
,line
)(r
== res
&& (FAILED(r
) || EQ_DOUBLE(out
, dt
)),
1633 "expected %x, %.16g, got %x, %.16g\n", r
, dt
, res
, out
);
1635 #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)
1637 static void test_VarDateFromUdate(void)
1639 CHECKPTR(VarDateFromUdate
);
1640 UD2T(1,1,1980,0,0,0,0,2,1,0,S_OK
,29221.0); /* 1 Jan 1980 */
1641 UD2T(2,1,1980,0,0,0,0,3,2,0,S_OK
,29222.0); /* 2 Jan 1980 */
1642 UD2T(31,12,1990,0,0,0,0,0,0,0,S_OK
,33238.0); /* 31 Dec 1990 */
1643 UD2T(31,12,90,0,0,0,0,0,0,0,S_OK
,33238.0); /* year < 100 is 1900+year! */
1644 UD2T(30,12,1899,0,0,0,0,6,364,0,S_OK
,0.0); /* 30 Dec 1899 - VT_DATE 0.0 */
1645 UD2T(1,1,100,0,0,0,0,0,0,0,S_OK
,-657434.0); /* 1 Jan 100 - Min */
1646 UD2T(31,12,9999,0,0,0,0,0,0,0,S_OK
,2958465.0); /* 31 Dec 9999 - Max */
1647 UD2T(1,1,10000,0,0,0,0,0,0,0,E_INVALIDARG
,0.0); /* > 31 Dec 9999 => err */
1649 UD2T(1,1,1980,18,1,16,0,2,1,0,S_OK
,29221.75087962963); /* 6:18:02 PM */
1651 UD2T(0,1,1980,0,0,0,0,2,1,0,S_OK
,29220.0); /* Rolls back to 31 Dec 1899 */
1652 UD2T(1,13,1980,0,0,0,0,2,1,0,S_OK
,29587.0); /* Rolls fwd to 1/1/1981 */
1655 static void test_st2dt(int line
, WORD d
, WORD m
, WORD y
, WORD h
, WORD mn
,
1656 WORD s
, WORD ms
, INT r
, double dt
)
1668 st
.wMilliseconds
= ms
;
1670 res
= pSystemTimeToVariantTime(&st
, &out
);
1671 ok_(__FILE__
,line
)(r
== res
&& (!r
|| EQ_DOUBLE(out
, dt
)),
1672 "expected %d, %.16g, got %d, %.16g\n", r
, dt
, res
, out
);
1674 #define ST2DT(d,m,y,h,mn,s,ms,r,dt) test_st2dt(__LINE__,d,m,y,h,mn,s,ms,r,dt)
1676 static void test_SystemTimeToVariantTime(void)
1678 CHECKPTR(SystemTimeToVariantTime
);
1679 ST2DT(1,1,1980,0,0,0,0,TRUE
,29221.0);
1680 ST2DT(2,1,1980,0,0,0,0,TRUE
,29222.0);
1681 ST2DT(0,1,1980,0,0,0,0,TRUE
,29220.0); /* Rolls back to 31 Dec 1899 */
1682 ST2DT(1,13,1980,0,0,0,0,FALSE
,29587.0); /* Fails on invalid month */
1683 ST2DT(31,12,90,0,0,0,0,TRUE
,33238.0); /* year < 100 is 1900+year! */
1686 static void test_dt2st(int line
, double dt
, INT r
, WORD d
, WORD m
, WORD y
,
1687 WORD h
, WORD mn
, WORD s
, WORD ms
)
1692 memset(&st
, 0, sizeof(st
));
1693 res
= pVariantTimeToSystemTime(dt
, &st
);
1694 ok_(__FILE__
,line
)(r
== res
&&
1695 (!r
|| (st
.wYear
== y
&& st
.wMonth
== m
&& st
.wDay
== d
&&
1696 st
.wHour
== h
&& st
.wMinute
== mn
&&
1697 st
.wSecond
== s
&& st
.wMilliseconds
== ms
)),
1698 "%.16g expected %d, %d,%d,%d,%d,%d,%d,%d, got %d, %d,%d,%d,%d,%d,%d,%d\n",
1699 dt
, r
, d
, m
, y
, h
, mn
, s
, ms
, res
, st
.wDay
, st
.wMonth
,
1700 st
.wYear
, st
.wHour
, st
.wMinute
, st
.wSecond
,
1703 #define DT2ST(dt,r,d,m,y,h,mn,s,ms) test_dt2st(__LINE__,dt,r,d,m,y,h,mn,s,ms)
1705 static void test_VariantTimeToSystemTime(void)
1707 CHECKPTR(VariantTimeToSystemTime
);
1708 DT2ST(29221.0,1,1,1,1980,0,0,0,0);
1709 DT2ST(29222.0,1,2,1,1980,0,0,0,0);
1712 #define MKDOSDATE(d,m,y) ((d & 0x1f) | ((m & 0xf) << 5) | (((y-1980) & 0x7f) << 9))
1713 #define MKDOSTIME(h,m,s) (((s>>1) & 0x1f) | ((m & 0x3f) << 5) | ((h & 0x1f) << 11))
1715 static void test_dos2dt(int line
, WORD d
, WORD m
, WORD y
, WORD h
, WORD mn
,
1716 WORD s
, INT r
, double dt
)
1718 unsigned short dosDate
, dosTime
;
1723 dosDate
= MKDOSDATE(d
, m
, y
);
1724 dosTime
= MKDOSTIME(h
, mn
, s
);
1725 res
= pDosDateTimeToVariantTime(dosDate
, dosTime
, &out
);
1726 ok_(__FILE__
,line
)(r
== res
&& (!r
|| EQ_DOUBLE(out
, dt
)),
1727 "expected %d, %.16g, got %d, %.16g\n", r
, dt
, res
, out
);
1729 #define DOS2DT(d,m,y,h,mn,s,r,dt) test_dos2dt(__LINE__,d,m,y,h,mn,s,r,dt)
1731 static void test_DosDateTimeToVariantTime(void)
1733 CHECKPTR(DosDateTimeToVariantTime
);
1736 DOS2DT(1,1,1980,0,0,0,1,29221.0); /* 1/1/1980 */
1737 DOS2DT(31,12,2099,0,0,0,1,73050.0); /* 31/12/2099 */
1738 /* Dates are limited to the dos date max of 31/12/2099 */
1739 DOS2DT(31,12,2100,0,0,0,0,0.0); /* 31/12/2100 */
1740 /* Days and months of 0 cause date to roll back 1 day or month */
1741 DOS2DT(0,1,1980,0,0,0,1,29220.0); /* 0 Day => 31/12/1979 */
1742 DOS2DT(1,0,1980,0,0,0,1,29190.0); /* 0 Mth => 1/12/1979 */
1743 DOS2DT(0,0,1980,0,0,0,1,29189.0); /* 0 D/M => 30/11/1979 */
1744 /* Days > days in the month cause date to roll forward 1 month */
1745 DOS2DT(29,2,1981,0,0,0,1,29646.0); /* 29/2/1981 -> 3/1/1980 */
1746 DOS2DT(30,2,1981,0,0,0,1,29647.0); /* 30/2/1981 -> 4/1/1980 */
1747 /* Takes leap years into account when rolling forward */
1748 DOS2DT(29,2,1980,0,0,0,1,29280.0); /* 2/29/1980 */
1749 /* Months > 12 cause an error */
1750 DOS2DT(2,13,1980,0,0,0,0,0.0);
1753 DOS2DT(1,1,1980,0,0,29,1,29221.00032407407); /* 1/1/1980 12:00:28 AM */
1754 DOS2DT(1,1,1980,0,0,31,1,29221.00034722222); /* 1/1/1980 12:00:30 AM */
1755 DOS2DT(1,1,1980,0,59,0,1,29221.04097222222); /* 1/1/1980 12:59:00 AM */
1756 DOS2DT(1,1,1980,0,60,0,0,0.0); /* Invalid seconds */
1757 DOS2DT(1,1,1980,23,0,0,1,29221.95833333333); /* 1/1/1980 11:00:00 PM */
1758 DOS2DT(1,1,1980,24,0,0,0,0.0); /* Invalid hours */
1761 static void test_dt2dos(int line
, double dt
, INT r
, WORD d
, WORD m
, WORD y
,
1762 WORD h
, WORD mn
, WORD s
)
1764 unsigned short dosDate
, dosTime
, expDosDate
, expDosTime
;
1767 dosTime
= dosDate
= 0;
1768 expDosDate
= MKDOSDATE(d
,m
,y
);
1769 expDosTime
= MKDOSTIME(h
,mn
,s
);
1770 res
= pVariantTimeToDosDateTime(dt
, &dosDate
, &dosTime
);
1771 ok_(__FILE__
,line
)(r
== res
&& (!r
|| (dosTime
== expDosTime
&& dosDate
== expDosDate
)),
1772 "%g: expected %d,%d(%d/%d/%d),%d(%d:%d:%d) got %d,%d(%d/%d/%d),%d(%d:%d:%d)\n",
1773 dt
, r
, expDosDate
, expDosDate
& 0x1f,
1774 (expDosDate
>> 5) & 0xf, 1980 + (expDosDate
>> 9),
1775 expDosTime
, expDosTime
>> 11, (expDosTime
>> 5) & 0x3f,
1776 (expDosTime
& 0x1f),
1777 res
, dosDate
, dosDate
& 0x1f, (dosDate
>> 5) & 0xf,
1778 1980 + (dosDate
>> 9), dosTime
, dosTime
>> 11,
1779 (dosTime
>> 5) & 0x3f, (dosTime
& 0x1f));
1781 #define DT2DOS(dt,r,d,m,y,h,mn,s) test_dt2dos(__LINE__,dt,r,d,m,y,h,mn,s)
1783 static void test_VariantTimeToDosDateTime(void)
1785 CHECKPTR(VariantTimeToDosDateTime
);
1788 DT2DOS(29221.0,1,1,1,1980,0,0,0); /* 1/1/1980 */
1789 DT2DOS(73050.0,1,31,12,2099,0,0,0); /* 31/12/2099 */
1790 DT2DOS(29220.0,0,0,0,0,0,0,0); /* 31/12/1979 - out of range */
1791 DT2DOS(73415.0,0,0,0,0,0,0,0); /* 31/12/2100 - out of range */
1794 DT2DOS(29221.00032407407,1,1,1,1980,0,0,29); /* 1/1/1980 12:00:28 AM */
1795 DT2DOS(29221.00034722222,1,1,1,1980,0,0,31); /* 1/1/1980 12:00:30 AM */
1796 DT2DOS(29221.04097222222,1,1,1,1980,0,59,0); /* 1/1/1980 12:59:00 AM */
1797 DT2DOS(29221.95833333333,1,1,1,1980,23,0,0); /* 1/1/1980 11:00:00 PM */
1800 static HRESULT (WINAPI
*pVarAbs
)(LPVARIANT
,LPVARIANT
);
1802 #define VARABS(vt,val,rvt,rval) \
1803 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
1804 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
1805 test_var_call1( __LINE__, pVarAbs, &v, &exp )
1807 static void test_VarAbs(void)
1809 static WCHAR szNum
[] = {'-','1','.','1','\0' };
1812 VARIANT v
, vDst
, exp
;
1817 /* Test all possible V_VT values.
1819 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
1823 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
1825 HRESULT hExpected
= DISP_E_BADVARTYPE
;
1829 memset(&v
, 0, sizeof(v
));
1830 V_VT(&v
) = vt
| ExtraFlags
[i
];
1831 V_VT(&vDst
) = VT_EMPTY
;
1833 hres
= pVarAbs(&v
,&vDst
);
1834 if (ExtraFlags
[i
] & (VT_ARRAY
|VT_ARRAY
) ||
1835 (!ExtraFlags
[i
] && (vt
== VT_UNKNOWN
|| vt
== VT_BSTR
||
1836 vt
== VT_DISPATCH
|| vt
== VT_ERROR
|| vt
== VT_RECORD
)))
1838 hExpected
= DISP_E_TYPEMISMATCH
;
1840 else if (ExtraFlags
[i
] || vt
>= VT_CLSID
|| vt
== VT_VARIANT
)
1842 hExpected
= DISP_E_BADVARTYPE
;
1844 else if (IsValidVariantClearVT(vt
, ExtraFlags
[i
]))
1847 /* Native always fails on some vartypes that should be valid. don't
1848 * check that Wine does the same; these are bugs in native.
1850 if (vt
== VT_I8
|| vt
== VT_UI8
|| vt
== VT_INT
|| vt
== VT_UINT
||
1851 vt
== VT_I1
|| vt
== VT_UI2
|| vt
== VT_UI4
)
1853 ok(hres
== hExpected
, "VarAbs: expected 0x%X, got 0x%X for vt %d | 0x%X\n",
1854 hExpected
, hres
, vt
, ExtraFlags
[i
]);
1858 /* BOOL->I2, BSTR->R8, all others remain the same */
1859 VARABS(BOOL
,VARIANT_TRUE
,I2
,-VARIANT_TRUE
);
1860 VARABS(BOOL
,VARIANT_FALSE
,I2
,VARIANT_FALSE
);
1861 VARABS(EMPTY
,0,I2
,0);
1862 VARABS(EMPTY
,1,I2
,0);
1863 VARABS(NULL
,0,NULL
,0);
1864 VARABS(NULL
,1,NULL
,0);
1869 VARABS(UI1
,1,UI1
,1);
1874 VARABS(DATE
,1,DATE
,1);
1875 VARABS(DATE
,-1,DATE
,1);
1877 V_CY(&v
).int64
= -10000;
1878 memset(&vDst
,0,sizeof(vDst
));
1879 hres
= pVarAbs(&v
,&vDst
);
1880 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_CY
&& V_CY(&vDst
).int64
== 10000,
1881 "VarAbs(CY): expected 0x0 got 0x%X\n", hres
);
1882 GetLocaleInfoA(LOCALE_USER_DEFAULT
, LOCALE_SDECIMAL
, buff
, sizeof(buff
)/sizeof(char));
1885 trace("Skipping VarAbs(BSTR) as decimal separator is '%s'\n", buff
);
1891 V_BSTR(&v
) = (BSTR
)szNum
;
1892 memset(&vDst
,0,sizeof(vDst
));
1893 hres
= pVarAbs(&v
,&vDst
);
1894 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_R8
&& V_R8(&vDst
) == 1.1,
1895 "VarAbs: expected 0x0,%d,%g, got 0x%X,%d,%g\n", VT_R8
, 1.1, hres
, V_VT(&vDst
), V_R8(&vDst
));
1898 static HRESULT (WINAPI
*pVarNot
)(LPVARIANT
,LPVARIANT
);
1900 #define VARNOT(vt,val,rvt,rval) \
1901 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
1902 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
1903 test_var_call1( __LINE__, pVarNot, &v, &exp )
1905 static void test_VarNot(void)
1907 static const WCHAR szNum0
[] = {'0','\0' };
1908 static const WCHAR szNum1
[] = {'1','\0' };
1910 VARIANT v
, exp
, vDst
;
1911 DECIMAL
*pdec
= &V_DECIMAL(&v
);
1912 CY
*pcy
= &V_CY(&v
);
1917 /* Test all possible V_VT values */
1918 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
1922 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
1924 HRESULT hExpected
= DISP_E_BADVARTYPE
;
1928 memset(&v
, 0, sizeof(v
));
1929 V_VT(&v
) = vt
| ExtraFlags
[i
];
1930 V_VT(&vDst
) = VT_EMPTY
;
1934 case VT_I1
: case VT_UI1
: case VT_I2
: case VT_UI2
:
1935 case VT_INT
: case VT_UINT
: case VT_I4
: case VT_UI4
:
1936 case VT_R4
: case VT_R8
:
1937 case VT_DECIMAL
: case VT_BOOL
: case VT_NULL
: case VT_EMPTY
:
1938 case VT_DATE
: case VT_CY
:
1941 case VT_I8
: case VT_UI8
:
1942 if (HAVE_OLEAUT32_I8
)
1946 if (HAVE_OLEAUT32_RECORD
)
1947 hExpected
= DISP_E_TYPEMISMATCH
;
1949 case VT_UNKNOWN
: case VT_BSTR
: case VT_DISPATCH
: case VT_ERROR
:
1950 hExpected
= DISP_E_TYPEMISMATCH
;
1953 if (IsValidVariantClearVT(vt
, ExtraFlags
[i
]) && vt
!= VT_CLSID
)
1954 hExpected
= DISP_E_TYPEMISMATCH
;
1958 hres
= pVarNot(&v
,&vDst
);
1959 ok(hres
== hExpected
, "VarNot: expected 0x%X, got 0x%X vt %d|0x%X\n",
1960 hExpected
, hres
, vt
, ExtraFlags
[i
]);
1963 /* Test the values returned by all cases that can succeed */
1964 VARNOT(EMPTY
,0,I2
,-1);
1965 VARNOT(EMPTY
,1,I2
,-1);
1966 VARNOT(NULL
,0,NULL
,0);
1967 VARNOT(NULL
,1,NULL
,0);
1968 VARNOT(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
);
1969 VARNOT(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
);
1977 VARNOT(UI1
,1,UI1
,254);
1978 VARNOT(UI1
,0,UI1
,255);
1979 VARNOT(UI2
,0,I4
,-1);
1980 VARNOT(UI2
,1,I4
,-2);
1981 VARNOT(UI4
,0,I4
,-1);
1982 VARNOT(UI4
,1,I4
,-2);
1983 VARNOT(INT
,0,I4
,-1);
1984 VARNOT(INT
,1,I4
,-2);
1985 VARNOT(UINT
,0,I4
,-1);
1986 VARNOT(UINT
,1,I4
,-2);
1987 if (HAVE_OLEAUT32_I8
)
1991 VARNOT(UI8
,0,I4
,-1);
1992 VARNOT(UI8
,1,I4
,-2);
1998 VARNOT(DATE
,1,I4
,-2);
1999 VARNOT(DATE
,0,I4
,-1);
2000 VARNOT(BSTR
,(BSTR
)szNum0
,I4
,-1);
2001 ok(V_VT(&v
) == VT_BSTR
&& V_BSTR(&v
) == szNum0
, "VarNot(0): changed input\n");
2002 VARNOT(BSTR
,(BSTR
)szNum1
,I4
,-2);
2003 ok(V_VT(&v
) == VT_BSTR
&& V_BSTR(&v
) == szNum1
, "VarNot(1): changed input\n");
2005 V_VT(&v
) = VT_DECIMAL
;
2006 S(U(*pdec
)).sign
= DECIMAL_NEG
;
2007 S(U(*pdec
)).scale
= 0;
2009 S1(U1(*pdec
)).Mid32
= 0;
2010 S1(U1(*pdec
)).Lo32
= 1;
2011 VARNOT(DECIMAL
,*pdec
,I4
,0);
2014 VARNOT(CY
,*pcy
,I4
,-2);
2017 VARNOT(CY
,*pcy
,I4
,-1);
2020 VARNOT(CY
,*pcy
,I4
,-1);
2023 static HRESULT (WINAPI
*pVarSub
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
2025 #define VARSUB(vt1,val1,vt2,val2,rvt,rval) \
2026 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
2027 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
2028 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
2029 test_var_call2( __LINE__, pVarSub, &left, &right, &exp )
2031 static void test_VarSub(void)
2033 VARIANT left
, right
, exp
, result
, cy
, dec
;
2036 HRESULT hres
, expectedhres
;
2041 lbstr
= SysAllocString(sz12
);
2042 rbstr
= SysAllocString(sz12
);
2045 VariantInit(&right
);
2046 VariantInit(&result
);
2048 /* Test all possible flag/vt combinations & the resulting vt type */
2049 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
2052 VARTYPE leftvt
, rightvt
, resvt
;
2054 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
2059 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
2063 expectedhres
= S_OK
;
2065 memset(&left
, 0, sizeof(left
));
2066 memset(&right
, 0, sizeof(right
));
2067 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
2068 if (leftvt
== VT_BSTR
)
2069 V_BSTR(&left
) = lbstr
;
2070 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
2071 if (rightvt
== VT_BSTR
)
2072 V_BSTR(&right
) = rbstr
;
2073 V_VT(&result
) = VT_EMPTY
;
2076 /* All extra flags produce errors */
2077 if (ExtraFlags
[i
] == (VT_VECTOR
|VT_BYREF
|VT_RESERVED
) ||
2078 ExtraFlags
[i
] == (VT_VECTOR
|VT_RESERVED
) ||
2079 ExtraFlags
[i
] == (VT_VECTOR
|VT_BYREF
) ||
2080 ExtraFlags
[i
] == (VT_BYREF
|VT_RESERVED
) ||
2081 ExtraFlags
[i
] == VT_VECTOR
||
2082 ExtraFlags
[i
] == VT_BYREF
||
2083 ExtraFlags
[i
] == VT_RESERVED
)
2085 expectedhres
= DISP_E_BADVARTYPE
;
2088 else if (ExtraFlags
[i
] >= VT_ARRAY
)
2090 expectedhres
= DISP_E_TYPEMISMATCH
;
2093 /* Native VarSub cannot handle: VT_I1, VT_UI2, VT_UI4,
2094 VT_INT, VT_UINT and VT_UI8. Tested with WinXP */
2095 else if (!IsValidVariantClearVT(leftvt
, ExtraFlags
[i
]) ||
2096 !IsValidVariantClearVT(rightvt
, ExtraFlags
[i
]) ||
2097 leftvt
== VT_CLSID
|| rightvt
== VT_CLSID
||
2098 leftvt
== VT_VARIANT
|| rightvt
== VT_VARIANT
||
2099 leftvt
== VT_I1
|| rightvt
== VT_I1
||
2100 leftvt
== VT_UI2
|| rightvt
== VT_UI2
||
2101 leftvt
== VT_UI4
|| rightvt
== VT_UI4
||
2102 leftvt
== VT_UI8
|| rightvt
== VT_UI8
||
2103 leftvt
== VT_INT
|| rightvt
== VT_INT
||
2104 leftvt
== VT_UINT
|| rightvt
== VT_UINT
||
2105 leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
||
2106 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
)
2108 if (leftvt
== VT_RECORD
&& rightvt
== VT_I8
)
2110 if (HAVE_OLEAUT32_I8
)
2111 expectedhres
= DISP_E_TYPEMISMATCH
;
2113 expectedhres
= DISP_E_BADVARTYPE
;
2115 else if (leftvt
< VT_UI1
&& rightvt
== VT_RECORD
)
2116 expectedhres
= DISP_E_TYPEMISMATCH
;
2117 else if (leftvt
>= VT_UI1
&& rightvt
== VT_RECORD
)
2118 expectedhres
= DISP_E_TYPEMISMATCH
;
2119 else if (leftvt
== VT_RECORD
&& rightvt
<= VT_UI1
)
2120 expectedhres
= DISP_E_TYPEMISMATCH
;
2121 else if (leftvt
== VT_RECORD
&& rightvt
> VT_UI1
)
2122 expectedhres
= DISP_E_BADVARTYPE
;
2124 expectedhres
= DISP_E_BADVARTYPE
;
2127 else if ((leftvt
== VT_NULL
&& rightvt
== VT_DISPATCH
) ||
2128 (leftvt
== VT_DISPATCH
&& rightvt
== VT_NULL
))
2130 else if (leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
||
2131 leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
)
2134 expectedhres
= DISP_E_TYPEMISMATCH
;
2136 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
2138 else if ((leftvt
== VT_EMPTY
&& rightvt
== VT_BSTR
) ||
2139 (leftvt
== VT_DATE
&& rightvt
== VT_DATE
) ||
2140 (leftvt
== VT_BSTR
&& rightvt
== VT_EMPTY
) ||
2141 (leftvt
== VT_BSTR
&& rightvt
== VT_BSTR
))
2143 else if (leftvt
== VT_DECIMAL
|| rightvt
== VT_DECIMAL
)
2145 else if (leftvt
== VT_DATE
|| rightvt
== VT_DATE
)
2147 else if (leftvt
== VT_CY
|| rightvt
== VT_CY
)
2149 else if (leftvt
== VT_R8
|| rightvt
== VT_R8
)
2151 else if (leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
) {
2153 } else if (leftvt
== VT_R4
|| rightvt
== VT_R4
) {
2154 if (leftvt
== VT_I4
|| rightvt
== VT_I4
||
2155 leftvt
== VT_I8
|| rightvt
== VT_I8
)
2160 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
2162 else if (leftvt
== VT_I4
|| rightvt
== VT_I4
)
2164 else if (leftvt
== VT_I2
|| rightvt
== VT_I2
||
2165 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
||
2166 (leftvt
== VT_EMPTY
&& rightvt
== VT_EMPTY
))
2168 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
2173 expectedhres
= DISP_E_TYPEMISMATCH
;
2176 hres
= pVarSub(&left
, &right
, &result
);
2178 ok(hres
== expectedhres
&& V_VT(&result
) == resvt
,
2179 "VarSub: %d|0x%X, %d|0x%X: Expected failure 0x%X, "
2180 "got 0x%X, expected vt %d got vt %d\n",
2181 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
],
2182 expectedhres
, hres
, resvt
, V_VT(&result
));
2187 /* Test returned values */
2188 VARSUB(I4
,4,I4
,2,I4
,2);
2189 VARSUB(I2
,4,I2
,2,I2
,2);
2190 VARSUB(I2
,-13,I4
,5,I4
,-18);
2191 VARSUB(I4
,-13,I4
,5,I4
,-18);
2192 VARSUB(I2
,7,R4
,0.5f
,R4
,6.5f
);
2193 VARSUB(R4
,0.5f
,I4
,5,R8
,-4.5);
2194 VARSUB(R8
,7.1,BOOL
,0,R8
,7.1);
2195 VARSUB(BSTR
,lbstr
,I2
,4,R8
,8);
2196 VARSUB(BSTR
,lbstr
,BOOL
,1,R8
,11);
2197 VARSUB(BSTR
,lbstr
,R4
,0.1f
,R8
,11.9);
2198 VARSUB(R4
,0.2f
,BSTR
,rbstr
,R8
,-11.8);
2199 VARSUB(DATE
,2.25,I4
,7,DATE
,-4.75);
2200 VARSUB(DATE
,1.25,R4
,-1.7f
,DATE
,2.95);
2202 VARSUB(UI1
, UI1_MAX
, UI1
, UI1_MAX
, UI1
, 0);
2203 VARSUB(I2
, I2_MAX
, I2
, I2_MAX
, I2
, 0);
2204 VARSUB(I2
, I2_MIN
, I2
, I2_MIN
, I2
, 0);
2205 VARSUB(I4
, I4_MAX
, I4
, I4_MAX
, I4
, 0);
2206 VARSUB(I4
, I4_MIN
, I4
, I4_MIN
, I4
, 0);
2207 VARSUB(R4
, R4_MAX
, R4
, R4_MAX
, R4
, 0.0f
);
2208 VARSUB(R4
, R4_MAX
, R4
, R4_MIN
, R4
, R4_MAX
- R4_MIN
);
2209 VARSUB(R4
, R4_MIN
, R4
, R4_MIN
, R4
, 0.0f
);
2210 VARSUB(R8
, R8_MAX
, R8
, R8_MIN
, R8
, R8_MAX
- R8_MIN
);
2211 VARSUB(R8
, R8_MIN
, R8
, R8_MIN
, R8
, 0.0);
2213 /* Manually test BSTR + BSTR */
2214 V_VT(&left
) = VT_BSTR
;
2215 V_BSTR(&left
) = lbstr
;
2216 V_VT(&right
) = VT_BSTR
;
2217 V_BSTR(&right
) = rbstr
;
2218 hres
= VarSub(&left
, &right
, &result
);
2219 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
2220 "VarSub: expected coerced type VT_R8, got %s!\n", vtstr(V_VT(&result
)));
2221 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 0),
2222 "VarSub: BSTR + BSTR, expected %f got %f\n", 0.0, V_R8(&result
));
2224 /* Manually test some VT_CY and VT_DECIMAL variants */
2226 hres
= VarCyFromI4(4711, &V_CY(&cy
));
2227 ok(hres
== S_OK
, "VarCyFromI4 failed!\n");
2228 V_VT(&dec
) = VT_DECIMAL
;
2229 hres
= VarDecFromR8(-4.2, &V_DECIMAL(&dec
));
2230 ok(hres
== S_OK
, "VarDecFromR4 failed!\n");
2231 memset(&left
, 0, sizeof(left
));
2232 memset(&right
, 0, sizeof(right
));
2233 V_VT(&left
) = VT_I4
;
2235 V_VT(&right
) = VT_UI1
;
2238 hres
= VarSub(&cy
, &right
, &result
);
2239 ok(hres
== S_OK
&& V_VT(&result
) == VT_CY
,
2240 "VarSub: expected coerced type VT_CY, got %s!\n", vtstr(V_VT(&result
)));
2241 hres
= VarR8FromCy(V_CY(&result
), &r
);
2242 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 4702),
2243 "VarSub: CY value %f, expected %f\n", r
, (double)4720);
2245 hres
= VarSub(&left
, &dec
, &result
);
2246 ok(hres
== S_OK
&& V_VT(&result
) == VT_DECIMAL
,
2247 "VarSub: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result
)));
2248 hres
= VarR8FromDec(&V_DECIMAL(&result
), &r
);
2249 ok(hres
== S_OK
&& EQ_DOUBLE(r
, -6.8),
2250 "VarSub: DECIMAL value %f, expected %f\n", r
, (double)-15.2);
2252 SysFreeString(lbstr
);
2253 SysFreeString(rbstr
);
2256 static HRESULT (WINAPI
*pVarMod
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
2258 static void test_Mod( int line
, VARIANT
*left
, VARIANT
*right
, VARIANT
*expected
, HRESULT expres
)
2263 memset( &result
, 0, sizeof(result
) );
2264 hres
= pVarMod( left
, right
, &result
);
2265 ok_(__FILE__
,line
)( hres
== expres
, "wrong result %x/%x\n", hres
, expres
);
2267 ok_(__FILE__
,line
)( is_expected_variant( &result
, expected
),
2268 "got %s expected %s\n", variantstr(&result
), variantstr(expected
) );
2271 #define VARMOD(vt1,vt2,val1,val2,rvt,rval) \
2272 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
2273 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
2274 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
2275 test_var_call2( __LINE__, pVarMod, &left, &right, &exp )
2277 #define VARMOD2(vt1,vt2,val1,val2,rvt,rval,hexpected) \
2278 V_VT(&left) = VT_##vt1; V_I4(&left) = val1; \
2279 V_VT(&right) = VT_##vt2; V_I4(&right) = val2; \
2280 V_VT(&exp) = VT_##rvt; V_I4(&exp) = rval; \
2281 test_Mod( __LINE__, &left, &right, &exp, hexpected )
2283 static void test_VarMod(void)
2285 VARIANT v1
, v2
, vDst
, left
, right
, exp
;
2287 HRESULT hexpected
= 0;
2288 static const WCHAR szNum0
[] = {'1','2','5','\0'};
2289 static const WCHAR szNum1
[] = {'1','0','\0'};
2291 BOOL lFound
, rFound
;
2292 BOOL lValid
, rValid
;
2293 BSTR strNum0
, strNum1
;
2297 VARMOD(I1
,BOOL
,100,10,I4
,0);
2298 VARMOD(I1
,I1
,100,10,I4
,0);
2299 VARMOD(I1
,UI1
,100,10,I4
,0);
2300 VARMOD(I1
,I2
,100,10,I4
,0);
2301 VARMOD(I1
,UI2
,100,10,I4
,0);
2302 VARMOD(I1
,I4
,100,10,I4
,0);
2303 VARMOD(I1
,UI4
,100,10,I4
,0);
2304 VARMOD(I1
,R4
,100,10,I4
,0);
2305 VARMOD(I1
,R8
,100,10,I4
,0);
2307 VARMOD(UI1
,BOOL
,100,10,I2
,0);
2308 VARMOD(UI1
,I1
,100,10,I4
,0);
2309 VARMOD(UI1
,UI1
,100,10,UI1
,0);
2310 VARMOD(UI1
,I2
,100,10,I2
,0);
2311 VARMOD(UI1
,UI2
,100,10,I4
,0);
2312 VARMOD(UI1
,I4
,100,10,I4
,0);
2313 VARMOD(UI1
,UI4
,100,10,I4
,0);
2314 VARMOD(UI1
,R4
,100,10,I4
,0);
2315 VARMOD(UI1
,R8
,100,10,I4
,0);
2317 VARMOD(I2
,BOOL
,100,10,I2
,0);
2318 VARMOD(I2
,I1
,100,10,I4
,0);
2319 VARMOD(I2
,UI1
,100,10,I2
,0);
2320 VARMOD(I2
,I2
,100,10,I2
,0);
2321 VARMOD(I2
,UI2
,100,10,I4
,0);
2322 VARMOD(I2
,I4
,100,10,I4
,0);
2323 VARMOD(I2
,UI4
,100,10,I4
,0);
2324 VARMOD(I2
,R4
,100,10,I4
,0);
2325 VARMOD(I2
,R8
,100,10,I4
,0);
2327 VARMOD(I4
,BOOL
,100,10,I4
,0);
2328 VARMOD(I4
,I1
,100,10,I4
,0);
2329 VARMOD(I4
,UI1
,100,10,I4
,0);
2330 VARMOD(I4
,I2
,100,10,I4
,0);
2331 VARMOD(I4
,UI2
,100,10,I4
,0);
2332 VARMOD(I4
,I4
,100,10,I4
,0);
2333 VARMOD(I4
,UI4
,100,10,I4
,0);
2334 VARMOD(I4
,R4
,100,10,I4
,0);
2335 VARMOD(I4
,R8
,100,10,I4
,0);
2336 VARMOD(UI4
,BOOL
,100,10,I4
,0);
2337 VARMOD(UI4
,I1
,100,10,I4
,0);
2338 VARMOD(UI4
,UI1
,100,10,I4
,0);
2339 VARMOD(UI4
,I2
,100,10,I4
,0);
2340 VARMOD(UI4
,UI2
,100,10,I4
,0);
2341 VARMOD(UI4
,I4
,100,10,I4
,0);
2342 VARMOD(UI4
,UI4
,100,10,I4
,0);
2343 VARMOD(UI4
,R4
,100,10,I4
,0);
2344 VARMOD(UI4
,R8
,100,10,I4
,0);
2345 VARMOD(R4
,BOOL
,100,10,I4
,0);
2346 VARMOD(R4
,I1
,100,10,I4
,0);
2347 VARMOD(R4
,UI1
,100,10,I4
,0);
2348 VARMOD(R4
,I2
,100,10,I4
,0);
2349 VARMOD(R4
,UI2
,100,10,I4
,0);
2350 VARMOD(R4
,I4
,100,10,I4
,0);
2351 VARMOD(R4
,UI4
,100,10,I4
,0);
2352 VARMOD(R4
,R4
,100,10,I4
,0);
2353 VARMOD(R4
,R8
,100,10,I4
,0);
2354 VARMOD(R8
,BOOL
,100,10,I4
,0);
2355 VARMOD(R8
,I1
,100,10,I4
,0);
2356 VARMOD(R8
,UI1
,100,10,I4
,0);
2357 VARMOD(R8
,I2
,100,10,I4
,0);
2358 VARMOD(R8
,UI2
,100,10,I4
,0);
2359 VARMOD(R8
,I4
,100,10,I4
,0);
2360 VARMOD(R8
,UI4
,100,10,I4
,0);
2361 VARMOD(R8
,R4
,100,10,I4
,0);
2362 VARMOD(R8
,R8
,100,10,I4
,0);
2364 VARMOD(INT
,INT
,100,10,I4
,0);
2365 VARMOD(INT
,UINT
,100,10,I4
,0);
2367 VARMOD(BOOL
,BOOL
,100,10,I2
,0);
2368 VARMOD(BOOL
,I1
,100,10,I4
,0);
2369 VARMOD(BOOL
,UI1
,100,10,I2
,0);
2370 VARMOD(BOOL
,I2
,100,10,I2
,0);
2371 VARMOD(BOOL
,UI2
,100,10,I4
,0);
2372 VARMOD(BOOL
,I4
,100,10,I4
,0);
2373 VARMOD(BOOL
,UI4
,100,10,I4
,0);
2374 VARMOD(BOOL
,R4
,100,10,I4
,0);
2375 VARMOD(BOOL
,R8
,100,10,I4
,0);
2376 VARMOD(BOOL
,DATE
,100,10,I4
,0);
2378 VARMOD(DATE
,BOOL
,100,10,I4
,0);
2379 VARMOD(DATE
,I1
,100,10,I4
,0);
2380 VARMOD(DATE
,UI1
,100,10,I4
,0);
2381 VARMOD(DATE
,I2
,100,10,I4
,0);
2382 VARMOD(DATE
,UI2
,100,10,I4
,0);
2383 VARMOD(DATE
,I4
,100,10,I4
,0);
2384 VARMOD(DATE
,UI4
,100,10,I4
,0);
2385 VARMOD(DATE
,R4
,100,10,I4
,0);
2386 VARMOD(DATE
,R8
,100,10,I4
,0);
2387 VARMOD(DATE
,DATE
,100,10,I4
,0);
2389 strNum0
= SysAllocString(szNum0
);
2390 strNum1
= SysAllocString(szNum1
);
2391 VARMOD(BSTR
,BSTR
,strNum0
,strNum1
,I4
,5);
2392 VARMOD(BSTR
,I1
,strNum0
,10,I4
,5);
2393 VARMOD(BSTR
,I2
,strNum0
,10,I4
,5);
2394 VARMOD(BSTR
,I4
,strNum0
,10,I4
,5);
2395 VARMOD(BSTR
,R4
,strNum0
,10,I4
,5);
2396 VARMOD(BSTR
,R8
,strNum0
,10,I4
,5);
2397 VARMOD(I4
,BSTR
,125,strNum1
,I4
,5);
2399 if (HAVE_OLEAUT32_I8
)
2401 VARMOD(BOOL
,I8
,100,10,I8
,0);
2402 VARMOD(I1
,I8
,100,10,I8
,0);
2403 VARMOD(UI1
,I8
,100,10,I8
,0);
2404 VARMOD(I2
,I8
,100,10,I8
,0);
2405 VARMOD(I4
,I8
,100,10,I8
,0);
2406 VARMOD(UI4
,I8
,100,10,I8
,0);
2407 VARMOD(R4
,I8
,100,10,I8
,0);
2408 VARMOD(R8
,I8
,100,10,I8
,0);
2409 VARMOD(DATE
,I8
,100,10,I8
,0);
2411 VARMOD(I8
,BOOL
,100,10,I8
,0);
2412 VARMOD(I8
,I1
,100,10,I8
,0);
2413 VARMOD(I8
,UI1
,100,10,I8
,0);
2414 VARMOD(I8
,I2
,100,10,I8
,0);
2415 VARMOD(I8
,UI2
,100,10,I8
,0);
2416 VARMOD(I8
,I4
,100,10,I8
,0);
2417 VARMOD(I8
,UI4
,100,10,I8
,0);
2418 VARMOD(I8
,R4
,100,10,I8
,0);
2419 VARMOD(I8
,R8
,100,10,I8
,0);
2420 VARMOD(I8
,I8
,100,10,I8
,0);
2422 VARMOD(BSTR
,I8
,strNum0
,10,I8
,5);
2425 /* test all combinations of types */
2426 for(l
= 0; l
< VT_BSTR_BLOB
; l
++)
2430 for(r
= 0; r
< VT_BSTR_BLOB
; r
++)
2434 if(l
== VT_BSTR
) continue;
2435 if(l
== VT_DISPATCH
) continue;
2436 if(r
== VT_BSTR
) continue;
2437 if(r
== VT_DISPATCH
) continue;
2471 hexpected
= DISP_E_BADVARTYPE
;
2510 if(((l
== VT_I8
) && (r
== VT_INT
)) || ((l
== VT_INT
) && (r
== VT_I8
)))
2512 hexpected
= DISP_E_TYPEMISMATCH
;
2513 } else if((l
== VT_EMPTY
) && (r
== VT_NULL
))
2516 } else if((l
== VT_NULL
) && (r
== VT_EMPTY
))
2519 } else if((l
== VT_EMPTY
) && (r
== VT_CY
))
2522 } else if((l
== VT_EMPTY
) && (r
== VT_RECORD
))
2524 hexpected
= DISP_E_TYPEMISMATCH
;
2525 } else if((r
== VT_EMPTY
) && lFound
&& lValid
)
2527 hexpected
= DISP_E_DIVBYZERO
;
2528 } else if((l
== VT_ERROR
) || ((r
== VT_ERROR
) && lFound
&& lValid
))
2530 hexpected
= DISP_E_TYPEMISMATCH
;
2531 } else if((l
== VT_NULL
) && (r
== VT_NULL
))
2534 } else if((l
== VT_VARIANT
) || ((r
== VT_VARIANT
) && lFound
&& lValid
))
2536 hexpected
= DISP_E_TYPEMISMATCH
;
2537 } else if((l
== VT_NULL
) && (r
== VT_RECORD
))
2539 hexpected
= DISP_E_TYPEMISMATCH
;
2540 } else if((l
== VT_I8
) && (r
== VT_DECIMAL
))
2543 } else if((l
== VT_DECIMAL
) && (r
== VT_I8
))
2546 } else if((l
== VT_UNKNOWN
) || ((r
== VT_UNKNOWN
) && lFound
&& lValid
))
2548 hexpected
= DISP_E_TYPEMISMATCH
;
2549 } else if((l
== VT_NULL
) && rFound
)
2552 } else if(l
== VT_RECORD
)
2554 hexpected
= DISP_E_TYPEMISMATCH
;
2555 } else if((r
== VT_RECORD
) && lValid
&& lFound
)
2557 hexpected
= DISP_E_TYPEMISMATCH
;
2558 } else if((l
== VT_EMPTY
) && (r
== VT_EMPTY
))
2560 hexpected
= DISP_E_DIVBYZERO
;
2561 } else if((l
== VT_CY
) && !rFound
)
2563 hexpected
= DISP_E_BADVARTYPE
;
2564 } else if(lFound
&& !rFound
)
2566 hexpected
= DISP_E_BADVARTYPE
;
2567 } else if(!lFound
&& rFound
)
2569 hexpected
= DISP_E_BADVARTYPE
;
2570 } else if((r
== VT_NULL
) && lFound
&& lValid
)
2573 } else if((l
== VT_NULL
) || (r
== VT_NULL
))
2575 hexpected
= DISP_E_BADVARTYPE
;
2576 } else if((l
== VT_VARIANT
) || (r
== VT_VARIANT
))
2578 hexpected
= DISP_E_BADVARTYPE
;
2579 } else if(lFound
&& !rFound
)
2581 hexpected
= DISP_E_BADVARTYPE
;
2582 } else if(!lFound
&& !rFound
)
2584 hexpected
= DISP_E_BADVARTYPE
;
2591 V_CY(&v1
).int64
= 1000000;
2596 else if(l
== VT_UI8
)
2600 else if(l
== VT_DATE
)
2602 else if (l
== VT_DECIMAL
)
2604 V_DECIMAL(&v1
).Hi32
= 0;
2605 U1(V_DECIMAL(&v1
)).Lo64
= 100;
2606 U(V_DECIMAL(&v1
)).signscale
= 0;
2612 V_CY(&v2
).int64
= 10000;
2617 else if(r
== VT_UI8
)
2621 else if(r
== VT_DATE
)
2623 else if (r
== VT_DECIMAL
)
2625 V_DECIMAL(&v2
).Hi32
= 0;
2626 U1(V_DECIMAL(&v2
)).Lo64
= 100;
2627 U(V_DECIMAL(&v2
)).signscale
= 0;
2632 if ((l
!= VT_I8
&& l
!= VT_UI8
&& r
!= VT_I8
&& r
!= VT_UI8
) || HAVE_OLEAUT32_I8
)
2634 hres
= pVarMod(&v1
,&v2
,&vDst
);
2635 ok(hres
== hexpected
,
2636 "VarMod: expected 0x%x, got 0x%X for l type of %d, r type of %d,\n", hexpected
, hres
, l
, r
);
2642 /****************************/
2643 /* test some bad parameters */
2644 VARMOD(I4
,I4
,-1,-1,I4
,0);
2646 /* test modulus with zero */
2647 VARMOD2(I4
,I4
,100,0,EMPTY
,0,DISP_E_DIVBYZERO
);
2649 VARMOD(I4
,I4
,0,10,I4
,0); /* test 0 mod 10 */
2651 /* right parameter is type empty */
2652 VARMOD2(I4
,EMPTY
,100,10,EMPTY
,0,DISP_E_DIVBYZERO
);
2654 /* left parameter is type empty */
2655 VARMOD2(EMPTY
,I4
,100,10,I4
,0,S_OK
);
2657 /* mod with a null left value */
2658 VARMOD2(NULL
,I4
,125,10,NULL
,0,S_OK
);
2660 /* mod with a null right value */
2661 VARMOD2(I4
,NULL
,100,10,NULL
,0,S_OK
);
2663 /* void left value */
2664 VARMOD2(VOID
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2666 /* void right value */
2667 VARMOD2(I4
,VOID
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2669 /* null left value, void right value */
2670 VARMOD2(NULL
,VOID
,100,10,EMPTY
, 0, DISP_E_BADVARTYPE
);
2672 /* void left value, null right value */
2673 VARMOD2(VOID
,NULL
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2675 /* some currencies */
2678 V_CY(&v1
).int64
= 100000;
2679 V_CY(&v2
).int64
= 100000;
2680 hres
= pVarMod(&v1
,&v2
,&vDst
);
2681 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I4
&& V_I4(&vDst
) == 0,
2682 "VarMod: expected 0x%x,%d,%d, got 0x%X,%d,%d\n", S_OK
, VT_I4
, 0, hres
, V_VT(&vDst
), V_I4(&vDst
));
2687 V_CY(&v2
).int64
= 100000;
2688 hres
= pVarMod(&v1
,&v2
,&vDst
);
2689 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I4
&& V_I4(&vDst
) == 0,
2690 "VarMod: expected 0x%x,%d,%d, got 0x%X,%d,%d\n", S_OK
, VT_I4
, 0, hres
, V_VT(&vDst
), V_I4(&vDst
));
2693 V_VT(&v1
) = VT_DECIMAL
;
2694 V_VT(&v2
) = VT_DECIMAL
;
2695 VarDecFromI4(100, &V_DECIMAL(&v1
));
2696 VarDecFromI4(10, &V_DECIMAL(&v2
));
2697 hres
= pVarMod(&v1
,&v2
,&vDst
);
2698 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I4
&& V_I4(&vDst
) == 0,
2699 "VarMod: expected 0x%x,%d,%d, got 0x%X,%d,%d\n", S_OK
, VT_I4
, 0, hres
, V_VT(&vDst
), V_I4(&vDst
));
2702 V_VT(&v2
) = VT_DECIMAL
;
2704 VarDecFromI4(10, &V_DECIMAL(&v2
));
2705 hres
= pVarMod(&v1
,&v2
,&vDst
);
2706 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I4
&& V_I4(&vDst
) == 0,
2707 "VarMod: expected 0x%x,%d,%d, got 0x%X,%d,%d\n", S_OK
, VT_I4
, 0, hres
, V_VT(&vDst
), V_I4(&vDst
));
2709 VARMOD2(UINT
,I4
,100,10,I4
,0,S_OK
);
2711 /* test that an error results in the type of the result changing but not its value */
2712 V_VT(&v1
) = VT_UNKNOWN
;
2713 V_VT(&v2
) = VT_EMPTY
;
2715 V_CY(&v2
).int64
= 100000;
2716 V_VT(&vDst
) = VT_I4
;
2718 hres
= pVarMod(&v1
,&v2
,&vDst
);
2719 ok(hres
== DISP_E_TYPEMISMATCH
&& V_VT(&vDst
) == VT_EMPTY
&& V_I4(&vDst
) == 1231,
2720 "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
));
2723 /* test some invalid types */
2724 /*TODO: not testing VT_DISPATCH */
2725 if (HAVE_OLEAUT32_I8
)
2727 VARMOD2(I8
,INT
,100,10,EMPTY
,0,DISP_E_TYPEMISMATCH
);
2729 VARMOD2(ERROR
,I4
,100,10,EMPTY
,0,DISP_E_TYPEMISMATCH
);
2730 VARMOD2(VARIANT
,I4
,100,10,EMPTY
,0,DISP_E_TYPEMISMATCH
);
2731 VARMOD2(UNKNOWN
,I4
,100,10,EMPTY
,0,DISP_E_TYPEMISMATCH
);
2732 VARMOD2(VOID
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2733 VARMOD2(HRESULT
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2734 VARMOD2(PTR
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2735 VARMOD2(SAFEARRAY
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2736 VARMOD2(CARRAY
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2737 VARMOD2(USERDEFINED
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2738 VARMOD2(LPSTR
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2739 VARMOD2(LPWSTR
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2740 VARMOD2(RECORD
,I4
,100,10,EMPTY
,0,DISP_E_TYPEMISMATCH
);
2741 VARMOD2(FILETIME
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2742 VARMOD2(BLOB
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2743 VARMOD2(STREAM
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2744 VARMOD2(STORAGE
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2745 VARMOD2(STREAMED_OBJECT
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2746 VARMOD2(STORED_OBJECT
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2747 VARMOD2(BLOB_OBJECT
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2748 VARMOD2(CF
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2749 VARMOD2(CLSID
,CLSID
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2750 VARMOD2(VECTOR
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2751 VARMOD2(ARRAY
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2752 VARMOD2(BYREF
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2754 /* test some more invalid types */
2759 hres
= pVarMod(&v1
,&v2
,&vDst
);
2760 ok(hres
== DISP_E_BADVARTYPE
&& V_VT(&vDst
) == VT_EMPTY
,
2761 "VarMod: expected 0x%x,%d, got 0x%X,%d\n", DISP_E_BADVARTYPE
, VT_EMPTY
, hres
, V_VT(&vDst
));
2763 SysFreeString(strNum0
);
2764 SysFreeString(strNum1
);
2767 static HRESULT (WINAPI
*pVarFix
)(LPVARIANT
,LPVARIANT
);
2769 #define VARFIX(vt,val,rvt,rval) \
2770 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
2771 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
2772 test_var_call1( __LINE__, pVarFix, &v, &exp )
2774 static void test_VarFix(void)
2776 static const WCHAR szNumMinus1
[] = {'-','1','\0' };
2778 VARIANT v
, exp
, vDst
;
2779 DECIMAL
*pdec
= &V_DECIMAL(&v
);
2780 CY
*pcy
= &V_CY(&v
);
2785 /* Test all possible V_VT values */
2786 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
2790 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
2792 HRESULT bFail
= TRUE
;
2796 memset(&v
, 0, sizeof(v
));
2797 V_VT(&v
) = vt
| ExtraFlags
[i
];
2798 V_VT(&vDst
) = VT_EMPTY
;
2802 case VT_UI1
: case VT_I2
: case VT_I4
: case VT_R4
: case VT_R8
:
2803 case VT_DECIMAL
: case VT_BOOL
: case VT_NULL
: case VT_EMPTY
:
2804 case VT_DATE
: case VT_CY
:
2808 if (HAVE_OLEAUT32_I8
)
2813 hres
= pVarFix(&v
,&vDst
);
2815 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
2816 "VarFix: expected failure, got 0x%X vt %d|0x%X\n",
2817 hres
, vt
, ExtraFlags
[i
]);
2819 ok(hres
== S_OK
, "VarFix: expected S_OK, got 0x%X vt %d|0x%X\n",
2820 hres
, vt
, ExtraFlags
[i
]);
2824 VARFIX(BOOL
,VARIANT_TRUE
,I2
,VARIANT_TRUE
);
2825 VARFIX(BOOL
,VARIANT_FALSE
,I2
,0);
2826 VARFIX(BOOL
,1,I2
,1);
2827 VARFIX(UI1
,1,UI1
,1);
2828 VARFIX(I2
,-1,I2
,-1);
2829 VARFIX(I4
,-1,I4
,-1);
2830 if (HAVE_OLEAUT32_I8
)
2832 VARFIX(I8
,-1,I8
,-1);
2834 VARFIX(R4
,1.4f
,R4
,1);
2835 VARFIX(R4
,1.5f
,R4
,1);
2836 VARFIX(R4
,1.6f
,R4
,1);
2837 VARFIX(R4
,-1.4f
,R4
,-1);
2838 VARFIX(R4
,-1.5f
,R4
,-1);
2839 VARFIX(R4
,-1.6f
,R4
,-1);
2840 /* DATE & R8 round as for R4 */
2841 VARFIX(DATE
,-1,DATE
,-1);
2842 VARFIX(R8
,-1,R8
,-1);
2843 VARFIX(BSTR
,(BSTR
)szNumMinus1
,R8
,-1);
2845 V_VT(&v
) = VT_EMPTY
;
2846 hres
= pVarFix(&v
,&vDst
);
2847 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I2
&& V_I2(&vDst
) == 0,
2848 "VarFix: expected 0x0,%d,0 got 0x%X,%d,%d\n", VT_EMPTY
,
2849 hres
, V_VT(&vDst
), V_I2(&vDst
));
2852 hres
= pVarFix(&v
,&vDst
);
2853 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_NULL
,
2854 "VarFix: expected 0x0,%d got 0x%X,%d\n", VT_NULL
, hres
, V_VT(&vDst
));
2856 V_VT(&v
) = VT_DECIMAL
;
2857 S(U(*pdec
)).sign
= DECIMAL_NEG
;
2858 S(U(*pdec
)).scale
= 0;
2860 S1(U1(*pdec
)).Mid32
= 0;
2861 S1(U1(*pdec
)).Lo32
= 1;
2862 hres
= pVarFix(&v
,&vDst
);
2863 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_DECIMAL
&& !memcmp(&V_DECIMAL(&v
), &V_DECIMAL(&vDst
), sizeof(DECIMAL
)),
2864 "VarFix: expected 0x0,%d,identical, got 0x%X,%d\n", VT_DECIMAL
,
2867 /* FIXME: Test some fractional decimals when VarDecFix is implemented */
2870 pcy
->int64
= -10000;
2871 hres
= pVarFix(&v
,&vDst
);
2872 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_CY
&& V_CY(&vDst
).int64
== -10000,
2873 "VarFix: VT_CY wrong, hres=0x%X\n", hres
);
2876 pcy
->int64
= -16000;
2877 hres
= pVarFix(&v
,&vDst
);
2878 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_CY
&& V_CY(&vDst
).int64
== -10000,
2879 "VarFix: VT_CY wrong, hres=0x%X\n", hres
);
2882 static HRESULT (WINAPI
*pVarInt
)(LPVARIANT
,LPVARIANT
);
2884 #define VARINT(vt,val,rvt,rval) \
2885 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
2886 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
2887 test_var_call1( __LINE__, pVarInt, &v, &exp )
2889 static void test_VarInt(void)
2891 static const WCHAR szNumMinus1
[] = {'-','1','\0' };
2893 VARIANT v
, exp
, vDst
;
2894 DECIMAL
*pdec
= &V_DECIMAL(&v
);
2895 CY
*pcy
= &V_CY(&v
);
2900 /* Test all possible V_VT values */
2901 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
2905 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
2907 HRESULT bFail
= TRUE
;
2911 memset(&v
, 0, sizeof(v
));
2912 V_VT(&v
) = vt
| ExtraFlags
[i
];
2913 V_VT(&vDst
) = VT_EMPTY
;
2917 case VT_UI1
: case VT_I2
: case VT_I4
: case VT_R4
: case VT_R8
:
2918 case VT_DECIMAL
: case VT_BOOL
: case VT_NULL
: case VT_EMPTY
:
2919 case VT_DATE
: case VT_CY
:
2923 if (HAVE_OLEAUT32_I8
)
2928 hres
= pVarInt(&v
,&vDst
);
2930 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
2931 "VarInt: expected failure, got 0x%X vt %d|0x%X\n",
2932 hres
, vt
, ExtraFlags
[i
]);
2934 ok(hres
== S_OK
, "VarInt: expected S_OK, got 0x%X vt %d|0x%X\n",
2935 hres
, vt
, ExtraFlags
[i
]);
2939 VARINT(BOOL
,VARIANT_TRUE
,I2
,VARIANT_TRUE
);
2940 VARINT(BOOL
,VARIANT_FALSE
,I2
,0);
2941 VARINT(BOOL
,1,I2
,1);
2942 VARINT(UI1
,1,UI1
,1);
2943 VARINT(I2
,-1,I2
,-1);
2944 VARINT(I4
,-1,I4
,-1);
2945 if (HAVE_OLEAUT32_I8
)
2947 VARINT(I8
,-1,I8
,-1);
2949 VARINT(R4
,1.4f
,R4
,1);
2950 VARINT(R4
,1.5f
,R4
,1);
2951 VARINT(R4
,1.6f
,R4
,1);
2952 VARINT(R4
,-1.4f
,R4
,-2); /* Note these 3 are different from VarFix */
2953 VARINT(R4
,-1.5f
,R4
,-2);
2954 VARINT(R4
,-1.6f
,R4
,-2);
2955 /* DATE & R8 round as for R4 */
2956 VARINT(DATE
,-1,DATE
,-1);
2957 VARINT(R8
,-1,R8
,-1);
2958 VARINT(BSTR
,(BSTR
)szNumMinus1
,R8
,-1);
2960 V_VT(&v
) = VT_EMPTY
;
2961 hres
= pVarInt(&v
,&vDst
);
2962 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I2
&& V_I2(&vDst
) == 0,
2963 "VarInt: expected 0x0,%d,0 got 0x%X,%d,%d\n", VT_EMPTY
,
2964 hres
, V_VT(&vDst
), V_I2(&vDst
));
2967 hres
= pVarInt(&v
,&vDst
);
2968 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_NULL
,
2969 "VarInt: expected 0x0,%d got 0x%X,%d\n", VT_NULL
, hres
, V_VT(&vDst
));
2971 V_VT(&v
) = VT_DECIMAL
;
2972 S(U(*pdec
)).sign
= DECIMAL_NEG
;
2973 S(U(*pdec
)).scale
= 0;
2975 S1(U1(*pdec
)).Mid32
= 0;
2976 S1(U1(*pdec
)).Lo32
= 1;
2977 hres
= pVarInt(&v
,&vDst
);
2978 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_DECIMAL
&& !memcmp(&V_DECIMAL(&v
), &V_DECIMAL(&vDst
), sizeof(DECIMAL
)),
2979 "VarInt: expected 0x0,%d,identical, got 0x%X,%d\n", VT_DECIMAL
,
2982 /* FIXME: Test some fractional decimals when VarDecInt is implemented */
2985 pcy
->int64
= -10000;
2986 hres
= pVarInt(&v
,&vDst
);
2987 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_CY
&& V_CY(&vDst
).int64
== -10000,
2988 "VarInt: VT_CY wrong, hres=0x%X\n", hres
);
2991 pcy
->int64
= -11000;
2992 hres
= pVarInt(&v
,&vDst
);
2993 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_CY
&& V_CY(&vDst
).int64
== -20000,
2994 "VarInt: VT_CY wrong, hres=0x%X 0x%x%08x\n",
2995 hres
, (DWORD
)(V_CY(&vDst
).int64
>> 32), (DWORD
)V_CY(&vDst
).int64
);
2998 static HRESULT (WINAPI
*pVarNeg
)(LPVARIANT
,LPVARIANT
);
3000 #define VARNEG(vt,val,rvt,rval) \
3001 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
3002 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
3003 test_var_call1( __LINE__, pVarNeg, &v, &exp )
3005 static void test_VarNeg(void)
3007 static const WCHAR szNumMinus1
[] = {'-','1','\0' };
3008 static const WCHAR szNum1
[] = {'1','\0' };
3010 VARIANT v
, exp
, vDst
;
3011 DECIMAL
*pdec
= &V_DECIMAL(&v
);
3012 CY
*pcy
= &V_CY(&v
);
3017 /* Test all possible V_VT values. But don't test the exact return values
3018 * except for success/failure, since M$ made a hash of them in the
3019 * native version. This at least ensures (as with all tests here) that
3020 * we will notice if/when new vtypes/flags are added in native.
3022 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
3026 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
3028 HRESULT bFail
= TRUE
;
3032 memset(&v
, 0, sizeof(v
));
3033 V_VT(&v
) = vt
| ExtraFlags
[i
];
3034 V_VT(&vDst
) = VT_EMPTY
;
3038 case VT_UI1
: case VT_I2
: case VT_I4
:
3039 case VT_R4
: case VT_R8
:
3040 case VT_DECIMAL
: case VT_BOOL
: case VT_NULL
: case VT_EMPTY
:
3041 case VT_DATE
: case VT_CY
:
3045 if (HAVE_OLEAUT32_I8
)
3049 hres
= pVarNeg(&v
,&vDst
);
3051 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
3052 "VarNeg: expected failure, got 0x%X vt %d|0x%X\n",
3053 hres
, vt
, ExtraFlags
[i
]);
3055 ok(hres
== S_OK
, "VarNeg: expected S_OK, got 0x%X vt %d|0x%X\n",
3056 hres
, vt
, ExtraFlags
[i
]);
3060 VARNEG(BOOL
,VARIANT_TRUE
,I2
,1);
3061 VARNEG(BOOL
,VARIANT_FALSE
,I2
,0);
3062 VARNEG(BOOL
,1,I2
,-1);
3063 VARNEG(UI1
,1,I2
,-1);
3064 VARNEG(UI1
,254,I2
,-254);
3065 VARNEG(I2
,-32768,I4
,32768);
3068 VARNEG(I4
,-((int)(~0u >> 1)) - 1,R8
,-2147483648u);
3071 if (HAVE_OLEAUT32_I8
)
3078 VARNEG(DATE
,1,DATE
,-1);
3079 VARNEG(DATE
,-1,DATE
,1);
3082 VARNEG(BSTR
,(BSTR
)szNumMinus1
,R8
,1);
3083 VARNEG(BSTR
,(BSTR
)szNum1
,R8
,-1);
3085 V_VT(&v
) = VT_EMPTY
;
3086 hres
= pVarNeg(&v
,&vDst
);
3087 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I2
&& V_I2(&vDst
) == 0,
3088 "VarNeg: expected 0x0,%d,0 got 0x%X,%d,%d\n", VT_EMPTY
,
3089 hres
, V_VT(&vDst
), V_I2(&vDst
));
3092 hres
= pVarNeg(&v
,&vDst
);
3093 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_NULL
,
3094 "VarNeg: expected 0x0,%d got 0x%X,%d\n", VT_NULL
, hres
, V_VT(&vDst
));
3096 V_VT(&v
) = VT_DECIMAL
;
3097 S(U(*pdec
)).sign
= DECIMAL_NEG
;
3098 S(U(*pdec
)).scale
= 0;
3100 S1(U1(*pdec
)).Mid32
= 0;
3101 S1(U1(*pdec
)).Lo32
= 1;
3102 hres
= pVarNeg(&v
,&vDst
);
3103 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_DECIMAL
&&
3104 S(U(V_DECIMAL(&vDst
))).sign
== 0,
3105 "VarNeg: expected 0x0,%d,0x00, got 0x%X,%d,%02x\n", VT_DECIMAL
,
3106 hres
, V_VT(&vDst
), S(U(V_DECIMAL(&vDst
))).sign
);
3108 S(U(*pdec
)).sign
= 0;
3109 hres
= pVarNeg(&v
,&vDst
);
3110 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_DECIMAL
&&
3111 S(U(V_DECIMAL(&vDst
))).sign
== DECIMAL_NEG
,
3112 "VarNeg: expected 0x0,%d,0x7f, got 0x%X,%d,%02x\n", VT_DECIMAL
,
3113 hres
, V_VT(&vDst
), S(U(V_DECIMAL(&vDst
))).sign
);
3116 pcy
->int64
= -10000;
3117 hres
= pVarNeg(&v
,&vDst
);
3118 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_CY
&& V_CY(&vDst
).int64
== 10000,
3119 "VarNeg: VT_CY wrong, hres=0x%X\n", hres
);
3122 static HRESULT (WINAPI
*pVarRound
)(LPVARIANT
,int,LPVARIANT
);
3124 static void test_Round( int line
, VARIANT
*arg
, int deci
, VARIANT
*expected
)
3129 memset( &result
, 0, sizeof(result
) );
3130 hres
= pVarRound( arg
, deci
, &result
);
3131 ok_(__FILE__
,line
)( hres
== S_OK
, "wrong result %x\n", hres
);
3133 ok_(__FILE__
,line
)( is_expected_variant( &result
, expected
),
3134 "got %s expected %s\n", variantstr(&result
), variantstr(expected
) );
3136 #define VARROUND(vt,val,deci,rvt,rval) \
3137 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
3138 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
3139 test_Round( __LINE__, &v, deci, &exp )
3141 static void test_VarRound(void)
3143 static WCHAR szNumMin
[] = {'-','1','.','4','4','9','\0' };
3144 static WCHAR szNum
[] = {'1','.','4','5','1','\0' };
3146 VARIANT v
, exp
, vDst
;
3147 CY
*pcy
= &V_CY(&v
);
3152 /* first check valid integer types */
3153 VARROUND(BOOL
,VARIANT_TRUE
,0,I2
,-1);
3154 VARROUND(BOOL
,VARIANT_FALSE
,0,I2
,0);
3155 VARROUND(BOOL
,1,0,I2
,1);
3156 VARROUND(UI1
,1,0,UI1
,1);
3157 VARROUND(UI1
,254,0,UI1
,254);
3158 VARROUND(I2
,-32768,0,I2
,-32768);
3159 VARROUND(I2
,-1,0,I2
,-1);
3160 VARROUND(I2
,1,0,I2
,1);
3161 VARROUND(I4
,-((int)(~0u >> 1)) - 1,0,I4
,-((int)(~0u >> 1)) - 1);
3162 VARROUND(I4
,-1,0,I4
,-1);
3163 VARROUND(I4
,1,0,I4
,1);
3166 /* MSDN states that rounding of R4/R8 is dependent on the underlying
3167 * bit pattern of the number and so is architecture dependent. In this
3168 * case Wine returns .2 (which is more correct) and Native returns .3
3171 VARROUND(R4
,1.0f
,0,R4
,1.0f
);
3172 VARROUND(R4
,-1.0f
,0,R4
,-1.0f
);
3173 VARROUND(R8
,1.0,0,R8
,1.0);
3174 VARROUND(R8
,-1.0,0,R8
,-1.0);
3176 /* floating point numbers aren't exactly equal and we can't just
3177 * compare the first few digits. */
3178 VARROUND(DATE
,1.451,1,DATE
,1.5);
3179 VARROUND(DATE
,-1.449,1,DATE
,-1.4);
3181 /* replace the decimal separator */
3182 GetLocaleInfoA(LOCALE_USER_DEFAULT
, LOCALE_SDECIMAL
, buff
, sizeof(buff
)/sizeof(char));
3184 szNumMin
[2] = buff
[0];
3186 VARROUND(BSTR
,(BSTR
)szNumMin
,1,R8
,-1.40);
3187 VARROUND(BSTR
,(BSTR
)szNum
,1,R8
,1.50);
3189 skip("Skipping VarRound(BSTR) as decimal separator is '%s'\n", buff
);
3192 VARROUND(R4
,1.23456f
,0,R4
,1.0f
);
3193 VARROUND(R4
,1.23456f
,1,R4
,1.2f
);
3194 VARROUND(R4
,1.23456f
,2,R4
,1.23f
);
3195 VARROUND(R4
,1.23456f
,3,R4
,1.235f
);
3196 VARROUND(R4
,1.23456f
,4,R4
,1.2346f
);
3197 VARROUND(R4
,-1.23456f
,0,R4
,-1.0f
);
3198 VARROUND(R4
,-1.23456f
,1,R4
,-1.2f
);
3199 VARROUND(R4
,-1.23456f
,2,R4
,-1.23f
);
3200 VARROUND(R4
,-1.23456f
,3,R4
,-1.235f
);
3201 VARROUND(R4
,-1.23456f
,4,R4
,-1.2346f
);
3203 VARROUND(R8
,1.23456,0,R8
,1.0);
3204 VARROUND(R8
,1.23456,1,R8
,1.2);
3205 VARROUND(R8
,1.23456,2,R8
,1.23);
3206 VARROUND(R8
,1.23456,3,R8
,1.235);
3207 VARROUND(R8
,1.23456,4,R8
,1.2346);
3208 VARROUND(R8
,-1.23456,0,R8
,-1.0);
3209 VARROUND(R8
,-1.23456,1,R8
,-1.2);
3210 VARROUND(R8
,-1.23456,2,R8
,-1.23);
3211 VARROUND(R8
,-1.23456,3,R8
,-1.235);
3212 VARROUND(R8
,-1.23456,4,R8
,-1.2346);
3214 V_VT(&v
) = VT_EMPTY
;
3215 hres
= pVarRound(&v
,0,&vDst
);
3216 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I2
&& V_I2(&vDst
) == 0,
3217 "VarRound: expected 0x0,%d,0 got 0x%X,%d,%d\n", VT_EMPTY
,
3218 hres
, V_VT(&vDst
), V_I2(&vDst
));
3221 hres
= pVarRound(&v
,0,&vDst
);
3222 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_NULL
,
3223 "VarRound: expected 0x0,%d got 0x%X,%d\n", VT_NULL
, hres
, V_VT(&vDst
));
3225 /* not yet implemented so no use testing yet
3227 DECIMAL *pdec = &V_DECIMAL(&v);
3228 V_VT(&v) = VT_DECIMAL;
3229 S(U(*pdec)).sign = DECIMAL_NEG;
3230 S(U(*pdec)).scale = 0;
3232 S1(U1(*pdec)).Mid32 = 0;
3233 S1(U1(*pdec)).Lo32 = 1;
3234 hres = pVarRound(&v,0,&vDst);
3235 ok(hres == S_OK && V_VT(&vDst) == VT_DECIMAL &&
3236 S(U(V_DECIMAL(&vDst))).sign == 0,
3237 "VarRound: expected 0x0,%d,0x00, got 0x%X,%d,%02x\n", VT_DECIMAL,
3238 hres, V_VT(&vDst), S(U(V_DECIMAL(&vDst))).sign);
3240 S(U(*pdec)).sign = 0;
3241 hres = pVarRound(&v,0,&vDst);
3242 ok(hres == S_OK && V_VT(&vDst) == VT_DECIMAL &&
3243 S(U(V_DECIMAL(&vDst))).sign == DECIMAL_NEG,
3244 "VarRound: expected 0x0,%d,0x7f, got 0x%X,%d,%02x\n", VT_DECIMAL,
3245 hres, V_VT(&vDst), S(U(V_DECIMAL(&vDst))).sign);
3251 hres
= pVarRound(&v
,0,&vDst
);
3252 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_CY
&& V_CY(&vDst
).int64
== 10000,
3253 "VarRound: VT_CY wrong, hres=0x%X\n", hres
);
3257 static HRESULT (WINAPI
*pVarXor
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
3259 #define VARXOR(vt1,val1,vt2,val2,rvt,rval) \
3260 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
3261 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
3262 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
3263 test_var_call2( __LINE__, pVarXor, &left, &right, &exp )
3265 #define VARXORCY(vt1,val1,val2,rvt,rval) \
3266 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
3267 V_VT(&right) = VT_CY; V_CY(&right).int64 = val2; \
3268 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
3269 test_var_call2( __LINE__, pVarXor, &left, &right, &exp )
3271 static void test_VarXor(void)
3273 static const WCHAR szFalse
[] = { '#','F','A','L','S','E','#','\0' };
3274 static const WCHAR szTrue
[] = { '#','T','R','U','E','#','\0' };
3275 VARIANT left
, right
, exp
, result
;
3282 /* Test all possible flag/vt combinations & the resulting vt type */
3283 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
3285 VARTYPE leftvt
, rightvt
, resvt
;
3287 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
3292 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
3298 if (leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
||
3299 leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
||
3300 leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
)
3303 memset(&left
, 0, sizeof(left
));
3304 memset(&right
, 0, sizeof(right
));
3305 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
3306 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
3307 V_VT(&result
) = VT_EMPTY
;
3310 if (ExtraFlags
[i
] & VT_ARRAY
|| ExtraFlags
[i
] & VT_BYREF
||
3311 !IsValidVariantClearVT(leftvt
, ExtraFlags
[i
]) ||
3312 !IsValidVariantClearVT(rightvt
, ExtraFlags
[i
]) ||
3313 leftvt
== VT_CLSID
|| rightvt
== VT_CLSID
||
3314 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
||
3315 leftvt
== VT_VARIANT
|| rightvt
== VT_VARIANT
||
3316 leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
)
3320 if (leftvt
== VT_EMPTY
|| rightvt
== VT_EMPTY
)
3322 if (leftvt
== rightvt
||
3323 leftvt
== VT_I2
|| rightvt
== VT_I2
||
3324 leftvt
== VT_UI1
|| rightvt
== VT_UI1
||
3325 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
3327 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
3329 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
3332 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
3336 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
3338 if (leftvt
== rightvt
)
3340 else if (leftvt
== rightvt
||
3341 leftvt
== VT_I2
|| rightvt
== VT_I2
||
3342 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
3346 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
3349 else if (leftvt
== VT_I2
|| rightvt
== VT_I2
)
3351 if (leftvt
== rightvt
||
3352 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
3354 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
3357 else if (leftvt
== VT_BOOL
&& rightvt
== VT_BOOL
)
3361 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
3363 if (leftvt
== VT_INT
|| rightvt
== VT_INT
)
3368 hres
= pVarXor(&left
, &right
, &result
);
3370 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
3371 "VarXor: %d|0x%X, %d|0x%X: Expected failure, got 0x%X vt %d\n",
3372 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], hres
,
3375 ok(hres
== S_OK
&& V_VT(&result
) == resvt
,
3376 "VarXor: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%X vt %d\n",
3377 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], resvt
, hres
,
3383 /* Test returned values
3384 * FIXME: Test VT_DECIMAL/VT_DISPATCH
3386 VARXOR(EMPTY
,0,EMPTY
,0,I2
,0);
3387 VARXOR(EMPTY
,1,EMPTY
,0,I2
,0);
3388 VARXOR(EMPTY
,0,NULL
,0,NULL
,0);
3389 VARXOR(EMPTY
,0,I1
,0,I4
,0);
3390 VARXOR(EMPTY
,0,I1
,1,I4
,1);
3391 VARXOR(EMPTY
,0,UI1
,0,I2
,0);
3392 VARXOR(EMPTY
,0,UI1
,1,I2
,1);
3393 VARXOR(EMPTY
,0,I2
,0,I2
,0);
3394 VARXOR(EMPTY
,0,I2
,1,I2
,1);
3395 VARXOR(EMPTY
,0,UI2
,0,I4
,0);
3396 VARXOR(EMPTY
,0,UI2
,1,I4
,1);
3397 VARXOR(EMPTY
,0,I4
,0,I4
,0);
3398 VARXOR(EMPTY
,0,I4
,1,I4
,1);
3399 VARXOR(EMPTY
,0,UI4
,0,I4
,0);
3400 VARXOR(EMPTY
,0,UI4
,1,I4
,1);
3401 if (HAVE_OLEAUT32_I8
)
3403 VARXOR(EMPTY
,0,I8
,0,I8
,0);
3404 VARXOR(EMPTY
,0,I8
,1,I8
,1);
3405 VARXOR(EMPTY
,0,UI8
,0,I4
,0);
3406 VARXOR(EMPTY
,0,UI8
,1,I4
,1);
3408 VARXOR(EMPTY
,0,INT
,0,I4
,0);
3409 VARXOR(EMPTY
,0,INT
,1,I4
,1);
3410 VARXOR(EMPTY
,0,UINT
,0,I4
,0);
3411 VARXOR(EMPTY
,0,UINT
,1,I4
,1);
3412 VARXOR(EMPTY
,0,BOOL
,0,I2
,0);
3413 VARXOR(EMPTY
,0,BOOL
,1,I2
,1);
3414 VARXOR(EMPTY
,0,R4
,0,I4
,0);
3415 VARXOR(EMPTY
,0,R4
,1,I4
,1);
3416 VARXOR(EMPTY
,0,R8
,0,I4
,0);
3417 VARXOR(EMPTY
,0,R8
,1,I4
,1);
3418 rbstr
= SysAllocString(szFalse
);
3419 VARXOR(EMPTY
,0,BSTR
,rbstr
,I2
,0);
3420 SysFreeString(rbstr
);
3421 rbstr
= SysAllocString(szTrue
);
3422 VARXOR(EMPTY
,0,BSTR
,rbstr
,I2
,-1);
3423 VARXORCY(EMPTY
,0,10000,I4
,1);
3424 SysFreeString(rbstr
);
3426 /* NULL OR 0 = NULL. NULL OR n = n */
3427 VARXOR(NULL
,0,NULL
,0,NULL
,0);
3428 VARXOR(NULL
,1,NULL
,0,NULL
,0);
3429 VARXOR(NULL
,0,I1
,0,NULL
,0);
3430 VARXOR(NULL
,0,I1
,1,NULL
,0);
3431 VARXOR(NULL
,0,UI1
,0,NULL
,0);
3432 VARXOR(NULL
,0,UI1
,1,NULL
,0);
3433 VARXOR(NULL
,0,I2
,0,NULL
,0);
3434 VARXOR(NULL
,0,I2
,1,NULL
,0);
3435 VARXOR(NULL
,0,UI2
,0,NULL
,0);
3436 VARXOR(NULL
,0,UI2
,1,NULL
,0);
3437 VARXOR(NULL
,0,I4
,0,NULL
,0);
3438 VARXOR(NULL
,0,I4
,1,NULL
,0);
3439 VARXOR(NULL
,0,UI4
,0,NULL
,0);
3440 VARXOR(NULL
,0,UI4
,1,NULL
,0);
3441 if (HAVE_OLEAUT32_I8
)
3443 VARXOR(NULL
,0,I8
,0,NULL
,0);
3444 VARXOR(NULL
,0,I8
,1,NULL
,0);
3445 VARXOR(NULL
,0,UI8
,0,NULL
,0);
3446 VARXOR(NULL
,0,UI8
,1,NULL
,0);
3448 VARXOR(NULL
,0,INT
,0,NULL
,0);
3449 VARXOR(NULL
,0,INT
,1,NULL
,0);
3450 VARXOR(NULL
,0,UINT
,0,NULL
,0);
3451 VARXOR(NULL
,0,UINT
,1,NULL
,0);
3452 VARXOR(NULL
,0,BOOL
,0,NULL
,0);
3453 VARXOR(NULL
,0,BOOL
,1,NULL
,0);
3454 VARXOR(NULL
,0,R4
,0,NULL
,0);
3455 VARXOR(NULL
,0,R4
,1,NULL
,0);
3456 VARXOR(NULL
,0,R8
,0,NULL
,0);
3457 VARXOR(NULL
,0,R8
,1,NULL
,0);
3458 rbstr
= SysAllocString(szFalse
);
3459 VARXOR(NULL
,0,BSTR
,rbstr
,NULL
,0);
3460 SysFreeString(rbstr
);
3461 rbstr
= SysAllocString(szTrue
);
3462 VARXOR(NULL
,0,BSTR
,rbstr
,NULL
,0);
3463 SysFreeString(rbstr
);
3464 VARXORCY(NULL
,0,10000,NULL
,0);
3465 VARXORCY(NULL
,0,0,NULL
,0);
3467 VARXOR(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
);
3468 VARXOR(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
);
3469 VARXOR(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
);
3470 VARXOR(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_FALSE
);
3471 /* Assume x,y & y,x are the same from now on to reduce the number of tests */
3472 VARXOR(BOOL
,VARIANT_TRUE
,I1
,-1,I4
,0);
3473 VARXOR(BOOL
,VARIANT_TRUE
,I1
,0,I4
,-1);
3474 VARXOR(BOOL
,VARIANT_FALSE
,I1
,0,I4
,0);
3475 VARXOR(BOOL
,VARIANT_TRUE
,UI1
,255,I2
,-256);
3476 VARXOR(BOOL
,VARIANT_TRUE
,UI1
,0,I2
,-1);
3477 VARXOR(BOOL
,VARIANT_FALSE
,UI1
,0,I2
,0);
3478 VARXOR(BOOL
,VARIANT_TRUE
,I2
,-1,I2
,0);
3479 VARXOR(BOOL
,VARIANT_TRUE
,I2
,0,I2
,-1);
3480 VARXOR(BOOL
,VARIANT_FALSE
,I2
,0,I2
,0);
3481 VARXOR(BOOL
,VARIANT_TRUE
,UI2
,65535,I4
,-65536);
3482 VARXOR(BOOL
,VARIANT_TRUE
,UI2
,0,I4
,-1);
3483 VARXOR(BOOL
,VARIANT_FALSE
,UI2
,0,I4
,0);
3484 VARXOR(BOOL
,VARIANT_TRUE
,I4
,-1,I4
,0);
3485 VARXOR(BOOL
,VARIANT_TRUE
,I4
,0,I4
,-1);
3486 VARXOR(BOOL
,VARIANT_FALSE
,I4
,0,I4
,0);
3487 VARXOR(BOOL
,VARIANT_TRUE
,UI4
,0xffffffff,I4
,0);
3488 VARXOR(BOOL
,VARIANT_TRUE
,UI4
,0,I4
,-1);
3489 VARXOR(BOOL
,VARIANT_FALSE
,UI4
,0,I4
,0);
3490 VARXOR(BOOL
,VARIANT_TRUE
,R4
,-1,I4
,0);
3491 VARXOR(BOOL
,VARIANT_TRUE
,R4
,0,I4
,-1);
3492 VARXOR(BOOL
,VARIANT_FALSE
,R4
,0,I4
,0);
3493 VARXOR(BOOL
,VARIANT_TRUE
,R8
,-1,I4
,0);
3494 VARXOR(BOOL
,VARIANT_TRUE
,R8
,0,I4
,-1);
3495 VARXOR(BOOL
,VARIANT_FALSE
,R8
,0,I4
,0);
3496 VARXOR(BOOL
,VARIANT_TRUE
,DATE
,-1,I4
,0);
3497 VARXOR(BOOL
,VARIANT_TRUE
,DATE
,0,I4
,-1);
3498 VARXOR(BOOL
,VARIANT_FALSE
,DATE
,0,I4
,0);
3499 if (HAVE_OLEAUT32_I8
)
3501 VARXOR(BOOL
,VARIANT_TRUE
,I8
,-1,I8
,0);
3502 VARXOR(BOOL
,VARIANT_TRUE
,I8
,0,I8
,-1);
3503 VARXOR(BOOL
,VARIANT_FALSE
,I8
,0,I8
,0);
3504 /* This returns DISP_E_OVERFLOW which indicates that a conversion
3505 * to I4 is performed.
3507 /* VARXOR(BOOL,VARIANT_TRUE,UI8,-1,I4,-1); */
3508 VARXOR(BOOL
,VARIANT_TRUE
,UI8
,0,I4
,-1);
3509 VARXOR(BOOL
,VARIANT_FALSE
,UI8
,0,I4
,0);
3511 VARXOR(BOOL
,VARIANT_TRUE
,INT
,-1,I4
,0);
3512 VARXOR(BOOL
,VARIANT_TRUE
,INT
,0,I4
,-1);
3513 VARXOR(BOOL
,VARIANT_FALSE
,INT
,0,I4
,0);
3514 VARXOR(BOOL
,VARIANT_TRUE
,UINT
,0xffffffff,I4
,0);
3515 VARXOR(BOOL
,VARIANT_TRUE
,UINT
,0,I4
,-1);
3516 VARXOR(BOOL
,VARIANT_FALSE
,UINT
,0,I4
,0);
3517 rbstr
= SysAllocString(szFalse
);
3518 VARXOR(BOOL
,VARIANT_FALSE
,BSTR
,rbstr
,BOOL
,VARIANT_FALSE
);
3519 VARXOR(BOOL
,VARIANT_TRUE
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
3520 SysFreeString(rbstr
);
3521 rbstr
= SysAllocString(szTrue
);
3522 VARXOR(BOOL
,VARIANT_FALSE
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
3523 VARXOR(BOOL
,VARIANT_TRUE
,BSTR
,rbstr
,BOOL
,VARIANT_FALSE
);
3524 SysFreeString(rbstr
);
3525 VARXORCY(BOOL
,VARIANT_TRUE
,10000,I4
,-2);
3526 VARXORCY(BOOL
,VARIANT_TRUE
,0,I4
,-1);
3527 VARXORCY(BOOL
,VARIANT_FALSE
,0,I4
,0);
3529 VARXOR(I1
,-1,I1
,-1,I4
,0);
3530 VARXOR(I1
,-1,I1
,0,I4
,-1);
3531 VARXOR(I1
,0,I1
,0,I4
,0);
3532 VARXOR(I1
,-1,UI1
,255,I4
,-256);
3533 VARXOR(I1
,-1,UI1
,0,I4
,-1);
3534 VARXOR(I1
,0,UI1
,0,I4
,0);
3535 VARXOR(I1
,-1,I2
,-1,I4
,0);
3536 VARXOR(I1
,-1,I2
,0,I4
,-1);
3537 VARXOR(I1
,0,I2
,0,I4
,0);
3538 VARXOR(I1
,-1,UI2
,65535,I4
,-65536);
3539 VARXOR(I1
,-1,UI2
,0,I4
,-1);
3540 VARXOR(I1
,0,UI2
,0,I4
,0);
3541 VARXOR(I1
,-1,I4
,-1,I4
,0);
3542 VARXOR(I1
,-1,I4
,0,I4
,-1);
3543 VARXOR(I1
,0,I4
,0,I4
,0);
3544 VARXOR(I1
,-1,UI4
,0xffffffff,I4
,0);
3545 VARXOR(I1
,-1,UI4
,0,I4
,-1);
3546 VARXOR(I1
,0,UI4
,0,I4
,0);
3547 VARXOR(I1
,-1,R4
,-1,I4
,0);
3548 VARXOR(I1
,-1,R4
,0,I4
,-1);
3549 VARXOR(I1
,0,R4
,0,I4
,0);
3550 VARXOR(I1
,-1,R8
,-1,I4
,0);
3551 VARXOR(I1
,-1,R8
,0,I4
,-1);
3552 VARXOR(I1
,0,R8
,0,I4
,0);
3553 VARXOR(I1
,-1,DATE
,-1,I4
,0);
3554 VARXOR(I1
,-1,DATE
,0,I4
,-1);
3555 VARXOR(I1
,0,DATE
,0,I4
,0);
3556 if (HAVE_OLEAUT32_I8
)
3558 VARXOR(I1
,-1,I8
,-1,I8
,0);
3559 VARXOR(I1
,-1,I8
,0,I8
,-1);
3560 VARXOR(I1
,0,I8
,0,I8
,0);
3561 VARXOR(I1
,-1,UI8
,0,I4
,-1);
3562 VARXOR(I1
,0,UI8
,0,I4
,0);
3564 VARXOR(I1
,-1,INT
,-1,I4
,0);
3565 VARXOR(I1
,-1,INT
,0,I4
,-1);
3566 VARXOR(I1
,0,INT
,0,I4
,0);
3567 VARXOR(I1
,-1,UINT
,0xffffffff,I4
,0);
3568 VARXOR(I1
,-1,UINT
,0,I4
,-1);
3569 VARXOR(I1
,0,UINT
,0,I4
,0);
3570 rbstr
= SysAllocString(szFalse
);
3571 VARXOR(I1
,0,BSTR
,rbstr
,I4
,0);
3572 VARXOR(I1
,-1,BSTR
,rbstr
,I4
,-1);
3573 SysFreeString(rbstr
);
3574 rbstr
= SysAllocString(szTrue
);
3575 VARXOR(I1
,0,BSTR
,rbstr
,I4
,-1);
3576 VARXOR(I1
,-1,BSTR
,rbstr
,I4
,0);
3577 SysFreeString(rbstr
);
3578 VARXORCY(I1
,-1,10000,I4
,-2);
3579 VARXORCY(I1
,-1,0,I4
,-1);
3580 VARXORCY(I1
,0,0,I4
,0);
3582 VARXOR(UI1
,255,UI1
,255,UI1
,0);
3583 VARXOR(UI1
,255,UI1
,0,UI1
,255);
3584 VARXOR(UI1
,0,UI1
,0,UI1
,0);
3585 VARXOR(UI1
,255,I2
,-1,I2
,-256);
3586 VARXOR(UI1
,255,I2
,0,I2
,255);
3587 VARXOR(UI1
,0,I2
,0,I2
,0);
3588 VARXOR(UI1
,255,UI2
,65535,I4
,65280);
3589 VARXOR(UI1
,255,UI2
,0,I4
,255);
3590 VARXOR(UI1
,0,UI2
,0,I4
,0);
3591 VARXOR(UI1
,255,I4
,-1,I4
,-256);
3592 VARXOR(UI1
,255,I4
,0,I4
,255);
3593 VARXOR(UI1
,0,I4
,0,I4
,0);
3594 VARXOR(UI1
,255,UI4
,0xffffffff,I4
,-256);
3595 VARXOR(UI1
,255,UI4
,0,I4
,255);
3596 VARXOR(UI1
,0,UI4
,0,I4
,0);
3597 VARXOR(UI1
,255,R4
,-1,I4
,-256);
3598 VARXOR(UI1
,255,R4
,0,I4
,255);
3599 VARXOR(UI1
,0,R4
,0,I4
,0);
3600 VARXOR(UI1
,255,R8
,-1,I4
,-256);
3601 VARXOR(UI1
,255,R8
,0,I4
,255);
3602 VARXOR(UI1
,0,R8
,0,I4
,0);
3603 VARXOR(UI1
,255,DATE
,-1,I4
,-256);
3604 VARXOR(UI1
,255,DATE
,0,I4
,255);
3605 VARXOR(UI1
,0,DATE
,0,I4
,0);
3606 if (HAVE_OLEAUT32_I8
)
3608 VARXOR(UI1
,255,I8
,-1,I8
,-256);
3609 VARXOR(UI1
,255,I8
,0,I8
,255);
3610 VARXOR(UI1
,0,I8
,0,I8
,0);
3611 VARXOR(UI1
,255,UI8
,0,I4
,255);
3612 VARXOR(UI1
,0,UI8
,0,I4
,0);
3614 VARXOR(UI1
,255,INT
,-1,I4
,-256);
3615 VARXOR(UI1
,255,INT
,0,I4
,255);
3616 VARXOR(UI1
,0,INT
,0,I4
,0);
3617 VARXOR(UI1
,255,UINT
,0xffffffff,I4
,-256);
3618 VARXOR(UI1
,255,UINT
,0,I4
,255);
3619 VARXOR(UI1
,0,UINT
,0,I4
,0);
3620 rbstr
= SysAllocString(szFalse
);
3621 VARXOR(UI1
,0,BSTR
,rbstr
,I2
,0);
3622 VARXOR(UI1
,255,BSTR
,rbstr
,I2
,255);
3623 SysFreeString(rbstr
);
3624 rbstr
= SysAllocString(szTrue
);
3625 VARXOR(UI1
,0,BSTR
,rbstr
,I2
,-1);
3626 VARXOR(UI1
,255,BSTR
,rbstr
,I2
,-256);
3627 SysFreeString(rbstr
);
3628 VARXORCY(UI1
,255,10000,I4
,254);
3629 VARXORCY(UI1
,255,0,I4
,255);
3630 VARXORCY(UI1
,0,0,I4
,0);
3632 VARXOR(I2
,-1,I2
,-1,I2
,0);
3633 VARXOR(I2
,-1,I2
,0,I2
,-1);
3634 VARXOR(I2
,0,I2
,0,I2
,0);
3635 VARXOR(I2
,-1,UI2
,65535,I4
,-65536);
3636 VARXOR(I2
,-1,UI2
,0,I4
,-1);
3637 VARXOR(I2
,0,UI2
,0,I4
,0);
3638 VARXOR(I2
,-1,I4
,-1,I4
,0);
3639 VARXOR(I2
,-1,I4
,0,I4
,-1);
3640 VARXOR(I2
,0,I4
,0,I4
,0);
3641 VARXOR(I2
,-1,UI4
,0xffffffff,I4
,0);
3642 VARXOR(I2
,-1,UI4
,0,I4
,-1);
3643 VARXOR(I2
,0,UI4
,0,I4
,0);
3644 VARXOR(I2
,-1,R4
,-1,I4
,0);
3645 VARXOR(I2
,-1,R4
,0,I4
,-1);
3646 VARXOR(I2
,0,R4
,0,I4
,0);
3647 VARXOR(I2
,-1,R8
,-1,I4
,0);
3648 VARXOR(I2
,-1,R8
,0,I4
,-1);
3649 VARXOR(I2
,0,R8
,0,I4
,0);
3650 VARXOR(I2
,-1,DATE
,-1,I4
,0);
3651 VARXOR(I2
,-1,DATE
,0,I4
,-1);
3652 VARXOR(I2
,0,DATE
,0,I4
,0);
3653 if (HAVE_OLEAUT32_I8
)
3655 VARXOR(I2
,-1,I8
,-1,I8
,0);
3656 VARXOR(I2
,-1,I8
,0,I8
,-1);
3657 VARXOR(I2
,0,I8
,0,I8
,0);
3658 VARXOR(I2
,-1,UI8
,0,I4
,-1);
3659 VARXOR(I2
,0,UI8
,0,I4
,0);
3661 VARXOR(I2
,-1,INT
,-1,I4
,0);
3662 VARXOR(I2
,-1,INT
,0,I4
,-1);
3663 VARXOR(I2
,0,INT
,0,I4
,0);
3664 VARXOR(I2
,-1,UINT
,0xffffffff,I4
,0);
3665 VARXOR(I2
,-1,UINT
,0,I4
,-1);
3666 VARXOR(I2
,0,UINT
,0,I4
,0);
3667 rbstr
= SysAllocString(szFalse
);
3668 VARXOR(I2
,0,BSTR
,rbstr
,I2
,0);
3669 VARXOR(I2
,-1,BSTR
,rbstr
,I2
,-1);
3670 SysFreeString(rbstr
);
3671 rbstr
= SysAllocString(szTrue
);
3672 VARXOR(I2
,0,BSTR
,rbstr
,I2
,-1);
3673 VARXOR(I2
,-1,BSTR
,rbstr
,I2
,0);
3674 SysFreeString(rbstr
);
3675 VARXORCY(I2
,-1,10000,I4
,-2);
3676 VARXORCY(I2
,-1,0,I4
,-1);
3677 VARXORCY(I2
,0,0,I4
,0);
3679 VARXOR(UI2
,65535,UI2
,65535,I4
,0);
3680 VARXOR(UI2
,65535,UI2
,0,I4
,65535);
3681 VARXOR(UI2
,0,UI2
,0,I4
,0);
3682 VARXOR(UI2
,65535,I4
,-1,I4
,-65536);
3683 VARXOR(UI2
,65535,I4
,0,I4
,65535);
3684 VARXOR(UI2
,0,I4
,0,I4
,0);
3685 VARXOR(UI2
,65535,UI4
,0xffffffff,I4
,-65536);
3686 VARXOR(UI2
,65535,UI4
,0,I4
,65535);
3687 VARXOR(UI2
,0,UI4
,0,I4
,0);
3688 VARXOR(UI2
,65535,R4
,-1,I4
,-65536);
3689 VARXOR(UI2
,65535,R4
,0,I4
,65535);
3690 VARXOR(UI2
,0,R4
,0,I4
,0);
3691 VARXOR(UI2
,65535,R8
,-1,I4
,-65536);
3692 VARXOR(UI2
,65535,R8
,0,I4
,65535);
3693 VARXOR(UI2
,0,R8
,0,I4
,0);
3694 VARXOR(UI2
,65535,DATE
,-1,I4
,-65536);
3695 VARXOR(UI2
,65535,DATE
,0,I4
,65535);
3696 VARXOR(UI2
,0,DATE
,0,I4
,0);
3697 if (HAVE_OLEAUT32_I8
)
3699 VARXOR(UI2
,65535,I8
,-1,I8
,-65536);
3700 VARXOR(UI2
,65535,I8
,0,I8
,65535);
3701 VARXOR(UI2
,0,I8
,0,I8
,0);
3702 VARXOR(UI2
,65535,UI8
,0,I4
,65535);
3703 VARXOR(UI2
,0,UI8
,0,I4
,0);
3705 VARXOR(UI2
,65535,INT
,-1,I4
,-65536);
3706 VARXOR(UI2
,65535,INT
,0,I4
,65535);
3707 VARXOR(UI2
,0,INT
,0,I4
,0);
3708 VARXOR(UI2
,65535,UINT
,0xffffffff,I4
,-65536);
3709 VARXOR(UI2
,65535,UINT
,0,I4
,65535);
3710 VARXOR(UI2
,0,UINT
,0,I4
,0);
3711 rbstr
= SysAllocString(szFalse
);
3712 VARXOR(UI2
,0,BSTR
,rbstr
,I4
,0);
3713 VARXOR(UI2
,65535,BSTR
,rbstr
,I4
,65535);
3714 SysFreeString(rbstr
);
3715 rbstr
= SysAllocString(szTrue
);
3716 VARXOR(UI2
,0,BSTR
,rbstr
,I4
,-1);
3717 VARXOR(UI2
,65535,BSTR
,rbstr
,I4
,-65536);
3718 SysFreeString(rbstr
);
3719 VARXORCY(UI2
,65535,10000,I4
,65534);
3720 VARXORCY(UI2
,65535,0,I4
,65535);
3721 VARXORCY(UI2
,0,0,I4
,0);
3723 VARXOR(I4
,-1,I4
,-1,I4
,0);
3724 VARXOR(I4
,-1,I4
,0,I4
,-1);
3725 VARXOR(I4
,0,I4
,0,I4
,0);
3726 VARXOR(I4
,-1,UI4
,0xffffffff,I4
,0);
3727 VARXOR(I4
,-1,UI4
,0,I4
,-1);
3728 VARXOR(I4
,0,UI4
,0,I4
,0);
3729 VARXOR(I4
,-1,R4
,-1,I4
,0);
3730 VARXOR(I4
,-1,R4
,0,I4
,-1);
3731 VARXOR(I4
,0,R4
,0,I4
,0);
3732 VARXOR(I4
,-1,R8
,-1,I4
,0);
3733 VARXOR(I4
,-1,R8
,0,I4
,-1);
3734 VARXOR(I4
,0,R8
,0,I4
,0);
3735 VARXOR(I4
,-1,DATE
,-1,I4
,0);
3736 VARXOR(I4
,-1,DATE
,0,I4
,-1);
3737 VARXOR(I4
,0,DATE
,0,I4
,0);
3738 if (HAVE_OLEAUT32_I8
)
3740 VARXOR(I4
,-1,I8
,-1,I8
,0);
3741 VARXOR(I4
,-1,I8
,0,I8
,-1);
3742 VARXOR(I4
,0,I8
,0,I8
,0);
3743 VARXOR(I4
,-1,UI8
,0,I4
,-1);
3744 VARXOR(I4
,0,UI8
,0,I4
,0);
3746 VARXOR(I4
,-1,INT
,-1,I4
,0);
3747 VARXOR(I4
,-1,INT
,0,I4
,-1);
3748 VARXOR(I4
,0,INT
,0,I4
,0);
3749 VARXOR(I4
,-1,UINT
,0xffffffff,I4
,0);
3750 VARXOR(I4
,-1,UINT
,0,I4
,-1);
3751 VARXOR(I4
,0,UINT
,0,I4
,0);
3752 rbstr
= SysAllocString(szFalse
);
3753 VARXOR(I4
,0,BSTR
,rbstr
,I4
,0);
3754 VARXOR(I4
,-1,BSTR
,rbstr
,I4
,-1);
3755 SysFreeString(rbstr
);
3756 rbstr
= SysAllocString(szTrue
);
3757 VARXOR(I4
,0,BSTR
,rbstr
,I4
,-1);
3758 VARXOR(I4
,-1,BSTR
,rbstr
,I4
,0);
3759 SysFreeString(rbstr
);
3760 VARXORCY(I4
,-1,10000,I4
,-2);
3761 VARXORCY(I4
,-1,0,I4
,-1);
3762 VARXORCY(I4
,0,0,I4
,0);
3764 VARXOR(UI4
,0xffffffff,UI4
,0xffffffff,I4
,0);
3765 VARXOR(UI4
,0xffffffff,UI4
,0,I4
,-1);
3766 VARXOR(UI4
,0,UI4
,0,I4
,0);
3767 VARXOR(UI4
,0xffffffff,R4
,-1,I4
,0);
3768 VARXOR(UI4
,0xffffffff,R4
,0,I4
,-1);
3769 VARXOR(UI4
,0,R4
,0,I4
,0);
3770 VARXOR(UI4
,0xffffffff,R8
,-1,I4
,0);
3771 VARXOR(UI4
,0xffffffff,R8
,0,I4
,-1);
3772 VARXOR(UI4
,0,R8
,0,I4
,0);
3773 VARXOR(UI4
,0xffffffff,DATE
,-1,I4
,0);
3774 VARXOR(UI4
,0xffffffff,DATE
,0,I4
,-1);
3775 VARXOR(UI4
,0,DATE
,0,I4
,0);
3776 if (HAVE_OLEAUT32_I8
)
3778 VARXOR(UI4
,0xffffffff,I8
,0,I8
,0xffffffff);
3779 VARXOR(UI4
,VARIANT_FALSE
,I8
,VARIANT_FALSE
,I8
,0);
3780 VARXOR(UI4
,0,I8
,0,I8
,0);
3781 VARXOR(UI4
,0xffffffff,UI8
,0,I4
,-1);
3782 VARXOR(UI4
,0,UI8
,0,I4
,0);
3784 VARXOR(UI4
,0xffffffff,INT
,-1,I4
,0);
3785 VARXOR(UI4
,0xffffffff,INT
,0,I4
,-1);
3786 VARXOR(UI4
,0,INT
,0,I4
,0);
3787 VARXOR(UI4
,0xffffffff,UINT
,0xffffffff,I4
,0);
3788 VARXOR(UI4
,0xffffffff,UINT
,0,I4
,-1);
3789 VARXOR(UI4
,0,UINT
,0,I4
,0);
3790 rbstr
= SysAllocString(szFalse
);
3791 VARXOR(UI4
,0,BSTR
,rbstr
,I4
,0);
3792 VARXOR(UI4
,0xffffffff,BSTR
,rbstr
,I4
,-1);
3793 SysFreeString(rbstr
);
3794 rbstr
= SysAllocString(szTrue
);
3795 VARXOR(UI4
,0,BSTR
,rbstr
,I4
,-1);
3796 VARXOR(UI4
,0xffffffff,BSTR
,rbstr
,I4
,0);
3797 SysFreeString(rbstr
);
3798 VARXORCY(UI4
,0xffffffff,10000,I4
,-2);
3799 VARXORCY(UI4
,0xffffffff,0,I4
,-1);
3800 VARXORCY(UI4
,0,0,I4
,0);
3802 VARXOR(R4
,-1,R4
,-1,I4
,0);
3803 VARXOR(R4
,-1,R4
,0,I4
,-1);
3804 VARXOR(R4
,0,R4
,0,I4
,0);
3805 VARXOR(R4
,-1,R8
,-1,I4
,0);
3806 VARXOR(R4
,-1,R8
,0,I4
,-1);
3807 VARXOR(R4
,0,R8
,0,I4
,0);
3808 VARXOR(R4
,-1,DATE
,-1,I4
,0);
3809 VARXOR(R4
,-1,DATE
,0,I4
,-1);
3810 VARXOR(R4
,0,DATE
,0,I4
,0);
3811 if (HAVE_OLEAUT32_I8
)
3813 VARXOR(R4
,-1,I8
,-1,I8
,0);
3814 VARXOR(R4
,-1,I8
,0,I8
,-1);
3815 VARXOR(R4
,0,I8
,0,I8
,0);
3816 VARXOR(R4
,-1,UI8
,0,I4
,-1);
3817 VARXOR(R4
,0,UI8
,0,I4
,0);
3819 VARXOR(R4
,-1,INT
,-1,I4
,0);
3820 VARXOR(R4
,-1,INT
,0,I4
,-1);
3821 VARXOR(R4
,0,INT
,0,I4
,0);
3822 VARXOR(R4
,-1,UINT
,0xffffffff,I4
,0);
3823 VARXOR(R4
,-1,UINT
,0,I4
,-1);
3824 VARXOR(R4
,0,UINT
,0,I4
,0);
3825 rbstr
= SysAllocString(szFalse
);
3826 VARXOR(R4
,0,BSTR
,rbstr
,I4
,0);
3827 VARXOR(R4
,-1,BSTR
,rbstr
,I4
,-1);
3828 SysFreeString(rbstr
);
3829 rbstr
= SysAllocString(szTrue
);
3830 VARXOR(R4
,0,BSTR
,rbstr
,I4
,-1);
3831 VARXOR(R4
,-1,BSTR
,rbstr
,I4
,0);
3832 SysFreeString(rbstr
);
3833 VARXORCY(R4
,-1,10000,I4
,-2);
3834 VARXORCY(R4
,-1,0,I4
,-1);
3835 VARXORCY(R4
,0,0,I4
,0);
3837 VARXOR(R8
,-1,R8
,-1,I4
,0);
3838 VARXOR(R8
,-1,R8
,0,I4
,-1);
3839 VARXOR(R8
,0,R8
,0,I4
,0);
3840 VARXOR(R8
,-1,DATE
,-1,I4
,0);
3841 VARXOR(R8
,-1,DATE
,0,I4
,-1);
3842 VARXOR(R8
,0,DATE
,0,I4
,0);
3843 if (HAVE_OLEAUT32_I8
)
3845 VARXOR(R8
,-1,I8
,-1,I8
,0);
3846 VARXOR(R8
,-1,I8
,0,I8
,-1);
3847 VARXOR(R8
,0,I8
,0,I8
,0);
3848 VARXOR(R8
,-1,UI8
,0,I4
,-1);
3849 VARXOR(R8
,0,UI8
,0,I4
,0);
3851 VARXOR(R8
,-1,INT
,-1,I4
,0);
3852 VARXOR(R8
,-1,INT
,0,I4
,-1);
3853 VARXOR(R8
,0,INT
,0,I4
,0);
3854 VARXOR(R8
,-1,UINT
,0xffffffff,I4
,0);
3855 VARXOR(R8
,-1,UINT
,0,I4
,-1);
3856 VARXOR(R8
,0,UINT
,0,I4
,0);
3857 rbstr
= SysAllocString(szFalse
);
3858 VARXOR(R8
,0,BSTR
,rbstr
,I4
,0);
3859 VARXOR(R8
,-1,BSTR
,rbstr
,I4
,-1);
3860 SysFreeString(rbstr
);
3861 rbstr
= SysAllocString(szTrue
);
3862 VARXOR(R8
,0,BSTR
,rbstr
,I4
,-1);
3863 VARXOR(R8
,-1,BSTR
,rbstr
,I4
,0);
3864 SysFreeString(rbstr
);
3865 VARXORCY(R8
,-1,10000,I4
,-2);
3866 VARXORCY(R8
,-1,0,I4
,-1);
3867 VARXORCY(R8
,0,0,I4
,0);
3869 VARXOR(DATE
,-1,DATE
,-1,I4
,0);
3870 VARXOR(DATE
,-1,DATE
,0,I4
,-1);
3871 VARXOR(DATE
,0,DATE
,0,I4
,0);
3872 if (HAVE_OLEAUT32_I8
)
3874 VARXOR(DATE
,-1,I8
,-1,I8
,0);
3875 VARXOR(DATE
,-1,I8
,0,I8
,-1);
3876 VARXOR(DATE
,0,I8
,0,I8
,0);
3877 VARXOR(DATE
,-1,UI8
,0,I4
,-1);
3878 VARXOR(DATE
,0,UI8
,0,I4
,0);
3880 VARXOR(DATE
,-1,INT
,-1,I4
,0);
3881 VARXOR(DATE
,-1,INT
,0,I4
,-1);
3882 VARXOR(DATE
,0,INT
,0,I4
,0);
3883 VARXOR(DATE
,-1,UINT
,0xffffffff,I4
,0);
3884 VARXOR(DATE
,-1,UINT
,0,I4
,-1);
3885 VARXOR(DATE
,0,UINT
,0,I4
,0);
3886 rbstr
= SysAllocString(szFalse
);
3887 VARXOR(DATE
,0,BSTR
,rbstr
,I4
,0);
3888 VARXOR(DATE
,-1,BSTR
,rbstr
,I4
,-1);
3889 SysFreeString(rbstr
);
3890 rbstr
= SysAllocString(szTrue
);
3891 VARXOR(DATE
,0,BSTR
,rbstr
,I4
,-1);
3892 VARXOR(DATE
,-1,BSTR
,rbstr
,I4
,0);
3893 SysFreeString(rbstr
);
3894 VARXORCY(DATE
,-1,10000,I4
,-2);
3895 VARXORCY(DATE
,-1,0,I4
,-1);
3896 VARXORCY(DATE
,0,0,I4
,0);
3898 if (HAVE_OLEAUT32_I8
)
3900 VARXOR(I8
,-1,I8
,-1,I8
,0);
3901 VARXOR(I8
,-1,I8
,0,I8
,-1);
3902 VARXOR(I8
,0,I8
,0,I8
,0);
3903 VARXOR(I8
,-1,UI8
,0,I8
,-1);
3904 VARXOR(I8
,0,UI8
,0,I8
,0);
3905 VARXOR(I8
,-1,UINT
,0,I8
,-1);
3906 VARXOR(I8
,0,UINT
,0,I8
,0);
3907 rbstr
= SysAllocString(szFalse
);
3908 VARXOR(I8
,0,BSTR
,rbstr
,I8
,0);
3909 VARXOR(I8
,-1,BSTR
,rbstr
,I8
,-1);
3910 SysFreeString(rbstr
);
3911 rbstr
= SysAllocString(szTrue
);
3912 VARXOR(I8
,0,BSTR
,rbstr
,I8
,-1);
3913 VARXOR(I8
,-1,BSTR
,rbstr
,I8
,0);
3914 SysFreeString(rbstr
);
3915 VARXORCY(I8
,-1,10000,I8
,-2);
3916 VARXORCY(I8
,-1,0,I8
,-1);
3917 VARXORCY(I8
,0,0,I8
,0);
3919 VARXOR(UI8
,0xffff,UI8
,0xffff,I4
,0);
3920 VARXOR(UI8
,0xffff,UI8
,0,I4
,0xffff);
3921 VARXOR(UI8
,0,UI8
,0,I4
,0);
3922 VARXOR(UI8
,0xffff,INT
,-1,I4
,-65536);
3923 VARXOR(UI8
,0xffff,INT
,0,I4
,0xffff);
3924 VARXOR(UI8
,0,INT
,0,I4
,0);
3925 VARXOR(UI8
,0xffff,UINT
,0xffff,I4
,0);
3926 VARXOR(UI8
,0xffff,UINT
,0,I4
,0xffff);
3927 VARXOR(UI8
,0,UINT
,0,I4
,0);
3928 rbstr
= SysAllocString(szFalse
);
3929 VARXOR(UI8
,0,BSTR
,rbstr
,I4
,0);
3930 VARXOR(UI8
,0xffff,BSTR
,rbstr
,I4
,0xffff);
3931 SysFreeString(rbstr
);
3932 rbstr
= SysAllocString(szTrue
);
3933 VARXOR(UI8
,0,BSTR
,rbstr
,I4
,-1);
3934 VARXOR(UI8
,0xffff,BSTR
,rbstr
,I4
,-65536);
3935 SysFreeString(rbstr
);
3936 VARXORCY(UI8
,0xffff,10000,I4
,65534);
3937 VARXORCY(UI8
,0xffff,0,I4
,0xffff);
3938 VARXORCY(UI8
,0,0,I4
,0);
3941 VARXOR(INT
,-1,INT
,-1,I4
,0);
3942 VARXOR(INT
,-1,INT
,0,I4
,-1);
3943 VARXOR(INT
,0,INT
,0,I4
,0);
3944 VARXOR(INT
,-1,UINT
,0xffff,I4
,-65536);
3945 VARXOR(INT
,-1,UINT
,0,I4
,-1);
3946 VARXOR(INT
,0,UINT
,0,I4
,0);
3947 rbstr
= SysAllocString(szFalse
);
3948 VARXOR(INT
,0,BSTR
,rbstr
,I4
,0);
3949 VARXOR(INT
,-1,BSTR
,rbstr
,I4
,-1);
3950 SysFreeString(rbstr
);
3951 rbstr
= SysAllocString(szTrue
);
3952 VARXOR(INT
,0,BSTR
,rbstr
,I4
,-1);
3953 VARXOR(INT
,-1,BSTR
,rbstr
,I4
,0);
3954 SysFreeString(rbstr
);
3955 VARXORCY(INT
,-1,10000,I4
,-2);
3956 VARXORCY(INT
,-1,0,I4
,-1);
3957 VARXORCY(INT
,0,0,I4
,0);
3959 VARXOR(UINT
,0xffff,UINT
,0xffff,I4
,0);
3960 VARXOR(UINT
,0xffff,UINT
,0,I4
,0xffff);
3961 VARXOR(UINT
,0,UINT
,0,I4
,0);
3962 rbstr
= SysAllocString(szFalse
);
3963 VARXOR(UINT
,0,BSTR
,rbstr
,I4
,0);
3964 VARXOR(UINT
,0xffff,BSTR
,rbstr
,I4
,0xffff);
3965 SysFreeString(rbstr
);
3966 rbstr
= SysAllocString(szTrue
);
3967 VARXOR(UINT
,0,BSTR
,rbstr
,I4
,-1);
3968 VARXOR(UINT
,0xffff,BSTR
,rbstr
,I4
,-65536);
3969 SysFreeString(rbstr
);
3970 VARXORCY(UINT
,0xffff,10000,I4
,65534);
3971 VARXORCY(UINT
,0xffff,0,I4
,0xffff);
3972 VARXORCY(UINT
,0,0,I4
,0);
3974 lbstr
= SysAllocString(szFalse
);
3975 rbstr
= SysAllocString(szFalse
);
3976 VARXOR(BSTR
,lbstr
,BSTR
,rbstr
,BOOL
,0);
3977 SysFreeString(rbstr
);
3978 rbstr
= SysAllocString(szTrue
);
3979 VARXOR(BSTR
,lbstr
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
3980 SysFreeString(lbstr
);
3981 lbstr
= SysAllocString(szTrue
);
3982 VARXOR(BSTR
,lbstr
,BSTR
,rbstr
,BOOL
,VARIANT_FALSE
);
3983 VARXORCY(BSTR
,lbstr
,10000,I4
,-2);
3984 SysFreeString(lbstr
);
3985 lbstr
= SysAllocString(szFalse
);
3986 VARXORCY(BSTR
,lbstr
,10000,I4
,1);
3987 SysFreeString(lbstr
);
3988 SysFreeString(rbstr
);
3991 static HRESULT (WINAPI
*pVarOr
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
3993 #define VAROR(vt1,val1,vt2,val2,rvt,rval) \
3994 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
3995 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
3996 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
3997 test_var_call2( __LINE__, pVarOr, &left, &right, &exp )
3999 #define VARORCY(vt1,val1,val2,rvt,rval) \
4000 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
4001 V_VT(&right) = VT_CY; V_CY(&right).int64 = val2; \
4002 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
4003 test_var_call2( __LINE__, pVarOr, &left, &right, &exp )
4005 static void test_VarOr(void)
4007 static const WCHAR szFalse
[] = { '#','F','A','L','S','E','#','\0' };
4008 static const WCHAR szTrue
[] = { '#','T','R','U','E','#','\0' };
4009 VARIANT left
, right
, exp
, result
;
4016 /* Test all possible flag/vt combinations & the resulting vt type */
4017 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
4019 VARTYPE leftvt
, rightvt
, resvt
;
4021 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
4026 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
4032 if (leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
||
4033 leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
||
4034 leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
)
4037 memset(&left
, 0, sizeof(left
));
4038 memset(&right
, 0, sizeof(right
));
4039 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
4040 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
4041 V_VT(&result
) = VT_EMPTY
;
4044 if (ExtraFlags
[i
] & VT_ARRAY
|| ExtraFlags
[i
] & VT_BYREF
||
4045 !IsValidVariantClearVT(leftvt
, ExtraFlags
[i
]) ||
4046 !IsValidVariantClearVT(rightvt
, ExtraFlags
[i
]) ||
4047 leftvt
== VT_CLSID
|| rightvt
== VT_CLSID
||
4048 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
||
4049 leftvt
== VT_VARIANT
|| rightvt
== VT_VARIANT
||
4050 leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
)
4054 if (leftvt
== VT_EMPTY
|| rightvt
== VT_EMPTY
)
4056 if (leftvt
== rightvt
||
4057 leftvt
== VT_I2
|| rightvt
== VT_I2
||
4058 leftvt
== VT_UI1
|| rightvt
== VT_UI1
||
4059 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
4061 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
4063 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
4066 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
4070 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
4072 if (leftvt
== rightvt
)
4074 else if (leftvt
== rightvt
||
4075 leftvt
== VT_I2
|| rightvt
== VT_I2
||
4076 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
4080 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
4083 else if (leftvt
== VT_I2
|| rightvt
== VT_I2
)
4085 if (leftvt
== rightvt
||
4086 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
4088 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
4091 else if (leftvt
== VT_BOOL
&& rightvt
== VT_BOOL
)
4095 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
4097 if (leftvt
== VT_INT
|| rightvt
== VT_INT
)
4102 hres
= pVarOr(&left
, &right
, &result
);
4104 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
4105 "VarOr: %d|0x%X, %d|0x%X: Expected failure, got 0x%X vt %d\n",
4106 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], hres
,
4109 ok(hres
== S_OK
&& V_VT(&result
) == resvt
,
4110 "VarOr: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%X vt %d\n",
4111 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], resvt
, hres
,
4117 /* Test returned values. Since we know the returned type is correct
4118 * and that we handle all combinations of invalid types, just check
4119 * that good type combinations produce the desired value.
4120 * FIXME: Test VT_DECIMAL/VT_DISPATCH
4122 VAROR(EMPTY
,0,EMPTY
,0,I2
,0);
4123 VAROR(EMPTY
,1,EMPTY
,0,I2
,0);
4124 VAROR(EMPTY
,0,NULL
,0,NULL
,0);
4125 VAROR(EMPTY
,0,I1
,0,I4
,0);
4126 VAROR(EMPTY
,0,I1
,1,I4
,1);
4127 VAROR(EMPTY
,0,UI1
,0,I2
,0);
4128 VAROR(EMPTY
,0,UI1
,1,I2
,1);
4129 VAROR(EMPTY
,0,I2
,0,I2
,0);
4130 VAROR(EMPTY
,0,I2
,1,I2
,1);
4131 VAROR(EMPTY
,0,UI2
,0,I4
,0);
4132 VAROR(EMPTY
,0,UI2
,1,I4
,1);
4133 VAROR(EMPTY
,0,I4
,0,I4
,0);
4134 VAROR(EMPTY
,0,I4
,1,I4
,1);
4135 VAROR(EMPTY
,0,UI4
,0,I4
,0);
4136 VAROR(EMPTY
,0,UI4
,1,I4
,1);
4137 if (HAVE_OLEAUT32_I8
)
4139 VAROR(EMPTY
,0,I8
,0,I8
,0);
4140 VAROR(EMPTY
,0,I8
,1,I8
,1);
4141 VAROR(EMPTY
,0,UI8
,0,I4
,0);
4142 VAROR(EMPTY
,0,UI8
,1,I4
,1);
4144 VAROR(EMPTY
,0,INT
,0,I4
,0);
4145 VAROR(EMPTY
,0,INT
,1,I4
,1);
4146 VAROR(EMPTY
,0,UINT
,0,I4
,0);
4147 VAROR(EMPTY
,0,UINT
,1,I4
,1);
4148 VAROR(EMPTY
,0,BOOL
,0,I2
,0);
4149 VAROR(EMPTY
,0,BOOL
,1,I2
,1);
4150 VAROR(EMPTY
,0,R4
,0,I4
,0);
4151 VAROR(EMPTY
,0,R4
,1,I4
,1);
4152 VAROR(EMPTY
,0,R8
,0,I4
,0);
4153 VAROR(EMPTY
,0,R8
,1,I4
,1);
4154 rbstr
= SysAllocString(szFalse
);
4155 VAROR(EMPTY
,0,BSTR
,rbstr
,I2
,0);
4156 SysFreeString(rbstr
);
4157 rbstr
= SysAllocString(szTrue
);
4158 VAROR(EMPTY
,0,BSTR
,rbstr
,I2
,-1);
4159 SysFreeString(rbstr
);
4160 VARORCY(EMPTY
,0,10000,I4
,1);
4162 /* NULL OR 0 = NULL. NULL OR n = n */
4163 VAROR(NULL
,0,NULL
,0,NULL
,0);
4164 VAROR(NULL
,1,NULL
,0,NULL
,0);
4165 VAROR(NULL
,0,I1
,0,NULL
,0);
4166 VAROR(NULL
,0,I1
,1,I4
,1);
4167 VAROR(NULL
,0,UI1
,0,NULL
,0);
4168 VAROR(NULL
,0,UI1
,1,UI1
,1);
4169 VAROR(NULL
,0,I2
,0,NULL
,0);
4170 VAROR(NULL
,0,I2
,1,I2
,1);
4171 VAROR(NULL
,0,UI2
,0,NULL
,0);
4172 VAROR(NULL
,0,UI2
,1,I4
,1);
4173 VAROR(NULL
,0,I4
,0,NULL
,0);
4174 VAROR(NULL
,0,I4
,1,I4
,1);
4175 VAROR(NULL
,0,UI4
,0,NULL
,0);
4176 VAROR(NULL
,0,UI4
,1,I4
,1);
4177 if (HAVE_OLEAUT32_I8
)
4179 VAROR(NULL
,0,I8
,0,NULL
,0);
4180 VAROR(NULL
,0,I8
,1,I8
,1);
4181 VAROR(NULL
,0,UI8
,0,NULL
,0);
4182 VAROR(NULL
,0,UI8
,1,I4
,1);
4184 VAROR(NULL
,0,INT
,0,NULL
,0);
4185 VAROR(NULL
,0,INT
,1,I4
,1);
4186 VAROR(NULL
,0,UINT
,0,NULL
,0);
4187 VAROR(NULL
,0,UINT
,1,I4
,1);
4188 VAROR(NULL
,0,BOOL
,0,NULL
,0);
4189 VAROR(NULL
,0,BOOL
,1,BOOL
,1);
4190 VAROR(NULL
,0,R4
,0,NULL
,0);
4191 VAROR(NULL
,0,R4
,1,I4
,1);
4192 VAROR(NULL
,0,R8
,0,NULL
,0);
4193 VAROR(NULL
,0,R8
,1,I4
,1);
4194 rbstr
= SysAllocString(szFalse
);
4195 VAROR(NULL
,0,BSTR
,rbstr
,NULL
,0);
4196 SysFreeString(rbstr
);
4197 rbstr
= SysAllocString(szTrue
);
4198 VAROR(NULL
,0,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
4199 SysFreeString(rbstr
);
4200 VARORCY(NULL
,0,10000,I4
,1);
4201 VARORCY(NULL
,0,0,NULL
,0);
4203 VAROR(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
);
4204 VAROR(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
);
4205 VAROR(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
);
4206 VAROR(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_FALSE
);
4207 /* Assume x,y & y,x are the same from now on to reduce the number of tests */
4208 VAROR(BOOL
,VARIANT_TRUE
,I1
,-1,I4
,-1);
4209 VAROR(BOOL
,VARIANT_TRUE
,I1
,0,I4
,-1);
4210 VAROR(BOOL
,VARIANT_FALSE
,I1
,0,I4
,0);
4211 VAROR(BOOL
,VARIANT_TRUE
,UI1
,255,I2
,-1);
4212 VAROR(BOOL
,VARIANT_TRUE
,UI1
,0,I2
,-1);
4213 VAROR(BOOL
,VARIANT_FALSE
,UI1
,0,I2
,0);
4214 VAROR(BOOL
,VARIANT_TRUE
,I2
,-1,I2
,-1);
4215 VAROR(BOOL
,VARIANT_TRUE
,I2
,0,I2
,-1);
4216 VAROR(BOOL
,VARIANT_FALSE
,I2
,0,I2
,0);
4217 VAROR(BOOL
,VARIANT_TRUE
,UI2
,65535,I4
,-1);
4218 VAROR(BOOL
,VARIANT_TRUE
,UI2
,0,I4
,-1);
4219 VAROR(BOOL
,VARIANT_FALSE
,UI2
,0,I4
,0);
4220 VAROR(BOOL
,VARIANT_TRUE
,I4
,-1,I4
,-1);
4221 VAROR(BOOL
,VARIANT_TRUE
,I4
,0,I4
,-1);
4222 VAROR(BOOL
,VARIANT_FALSE
,I4
,0,I4
,0);
4223 VAROR(BOOL
,VARIANT_TRUE
,UI4
,0xffffffff,I4
,-1);
4224 VAROR(BOOL
,VARIANT_TRUE
,UI4
,0,I4
,-1);
4225 VAROR(BOOL
,VARIANT_FALSE
,UI4
,0,I4
,0);
4226 VAROR(BOOL
,VARIANT_TRUE
,R4
,-1,I4
,-1);
4227 VAROR(BOOL
,VARIANT_TRUE
,R4
,0,I4
,-1);
4228 VAROR(BOOL
,VARIANT_FALSE
,R4
,0,I4
,0);
4229 VAROR(BOOL
,VARIANT_TRUE
,R8
,-1,I4
,-1);
4230 VAROR(BOOL
,VARIANT_TRUE
,R8
,0,I4
,-1);
4231 VAROR(BOOL
,VARIANT_FALSE
,R8
,0,I4
,0);
4232 VAROR(BOOL
,VARIANT_TRUE
,DATE
,-1,I4
,-1);
4233 VAROR(BOOL
,VARIANT_TRUE
,DATE
,0,I4
,-1);
4234 VAROR(BOOL
,VARIANT_FALSE
,DATE
,0,I4
,0);
4235 if (HAVE_OLEAUT32_I8
)
4237 VAROR(BOOL
,VARIANT_TRUE
,I8
,-1,I8
,-1);
4238 VAROR(BOOL
,VARIANT_TRUE
,I8
,0,I8
,-1);
4239 VAROR(BOOL
,VARIANT_FALSE
,I8
,0,I8
,0);
4240 /* This returns DISP_E_OVERFLOW which indicates that a conversion
4241 * to I4 is performed.
4243 /* VAROR(BOOL,VARIANT_TRUE,UI8,-1,I4,-1); */
4244 VAROR(BOOL
,VARIANT_TRUE
,UI8
,0,I4
,-1);
4245 VAROR(BOOL
,VARIANT_FALSE
,UI8
,0,I4
,0);
4247 VAROR(BOOL
,VARIANT_TRUE
,INT
,-1,I4
,-1);
4248 VAROR(BOOL
,VARIANT_TRUE
,INT
,0,I4
,-1);
4249 VAROR(BOOL
,VARIANT_FALSE
,INT
,0,I4
,0);
4250 VAROR(BOOL
,VARIANT_TRUE
,UINT
,0xffffffff,I4
,-1);
4251 VAROR(BOOL
,VARIANT_TRUE
,UINT
,0,I4
,-1);
4252 VAROR(BOOL
,VARIANT_FALSE
,UINT
,0,I4
,0);
4253 rbstr
= SysAllocString(szFalse
);
4254 VAROR(BOOL
,VARIANT_FALSE
,BSTR
,rbstr
,BOOL
,VARIANT_FALSE
);
4255 VAROR(BOOL
,VARIANT_TRUE
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
4256 SysFreeString(rbstr
);
4257 rbstr
= SysAllocString(szTrue
);
4258 VAROR(BOOL
,VARIANT_FALSE
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
4259 VAROR(BOOL
,VARIANT_TRUE
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
4260 SysFreeString(rbstr
);
4261 VARORCY(BOOL
,VARIANT_TRUE
,10000,I4
,-1);
4262 VARORCY(BOOL
,VARIANT_TRUE
,0,I4
,-1);
4263 VARORCY(BOOL
,VARIANT_FALSE
,0,I4
,0);
4265 VAROR(I1
,-1,I1
,-1,I4
,-1);
4266 VAROR(I1
,-1,I1
,0,I4
,-1);
4267 VAROR(I1
,0,I1
,0,I4
,0);
4268 VAROR(I1
,-1,UI1
,255,I4
,-1);
4269 VAROR(I1
,-1,UI1
,0,I4
,-1);
4270 VAROR(I1
,0,UI1
,0,I4
,0);
4271 VAROR(I1
,-1,I2
,-1,I4
,-1);
4272 VAROR(I1
,-1,I2
,0,I4
,-1);
4273 VAROR(I1
,0,I2
,0,I4
,0);
4274 VAROR(I1
,-1,UI2
,65535,I4
,-1);
4275 VAROR(I1
,-1,UI2
,0,I4
,-1);
4276 VAROR(I1
,0,UI2
,0,I4
,0);
4277 VAROR(I1
,-1,I4
,-1,I4
,-1);
4278 VAROR(I1
,-1,I4
,0,I4
,-1);
4279 VAROR(I1
,0,I4
,0,I4
,0);
4280 VAROR(I1
,-1,UI4
,0xffffffff,I4
,-1);
4281 VAROR(I1
,-1,UI4
,0,I4
,-1);
4282 VAROR(I1
,0,UI4
,0,I4
,0);
4283 VAROR(I1
,-1,R4
,-1,I4
,-1);
4284 VAROR(I1
,-1,R4
,0,I4
,-1);
4285 VAROR(I1
,0,R4
,0,I4
,0);
4286 VAROR(I1
,-1,R8
,-1,I4
,-1);
4287 VAROR(I1
,-1,R8
,0,I4
,-1);
4288 VAROR(I1
,0,R8
,0,I4
,0);
4289 VAROR(I1
,-1,DATE
,-1,I4
,-1);
4290 VAROR(I1
,-1,DATE
,0,I4
,-1);
4291 VAROR(I1
,0,DATE
,0,I4
,0);
4292 if (HAVE_OLEAUT32_I8
)
4294 VAROR(I1
,-1,I8
,-1,I8
,-1);
4295 VAROR(I1
,-1,I8
,0,I8
,-1);
4296 VAROR(I1
,0,I8
,0,I8
,0);
4297 VAROR(I1
,-1,UI8
,0,I4
,-1);
4298 VAROR(I1
,0,UI8
,0,I4
,0);
4300 VAROR(I1
,-1,INT
,-1,I4
,-1);
4301 VAROR(I1
,-1,INT
,0,I4
,-1);
4302 VAROR(I1
,0,INT
,0,I4
,0);
4303 VAROR(I1
,-1,UINT
,0xffffffff,I4
,-1);
4304 VAROR(I1
,-1,UINT
,0,I4
,-1);
4305 VAROR(I1
,0,UINT
,0,I4
,0);
4306 rbstr
= SysAllocString(szFalse
);
4307 VAROR(I1
,0,BSTR
,rbstr
,I4
,0);
4308 VAROR(I1
,-1,BSTR
,rbstr
,I4
,-1);
4309 SysFreeString(rbstr
);
4310 rbstr
= SysAllocString(szTrue
);
4311 VAROR(I1
,0,BSTR
,rbstr
,I4
,-1);
4312 VAROR(I1
,-1,BSTR
,rbstr
,I4
,-1);
4313 SysFreeString(rbstr
);
4314 VARORCY(I1
,-1,10000,I4
,-1);
4315 VARORCY(I1
,-1,0,I4
,-1);
4316 VARORCY(I1
,0,0,I4
,0);
4318 VAROR(UI1
,255,UI1
,255,UI1
,255);
4319 VAROR(UI1
,255,UI1
,0,UI1
,255);
4320 VAROR(UI1
,0,UI1
,0,UI1
,0);
4321 VAROR(UI1
,255,I2
,-1,I2
,-1);
4322 VAROR(UI1
,255,I2
,0,I2
,255);
4323 VAROR(UI1
,0,I2
,0,I2
,0);
4324 VAROR(UI1
,255,UI2
,65535,I4
,65535);
4325 VAROR(UI1
,255,UI2
,0,I4
,255);
4326 VAROR(UI1
,0,UI2
,0,I4
,0);
4327 VAROR(UI1
,255,I4
,-1,I4
,-1);
4328 VAROR(UI1
,255,I4
,0,I4
,255);
4329 VAROR(UI1
,0,I4
,0,I4
,0);
4330 VAROR(UI1
,255,UI4
,0xffffffff,I4
,-1);
4331 VAROR(UI1
,255,UI4
,0,I4
,255);
4332 VAROR(UI1
,0,UI4
,0,I4
,0);
4333 VAROR(UI1
,255,R4
,-1,I4
,-1);
4334 VAROR(UI1
,255,R4
,0,I4
,255);
4335 VAROR(UI1
,0,R4
,0,I4
,0);
4336 VAROR(UI1
,255,R8
,-1,I4
,-1);
4337 VAROR(UI1
,255,R8
,0,I4
,255);
4338 VAROR(UI1
,0,R8
,0,I4
,0);
4339 VAROR(UI1
,255,DATE
,-1,I4
,-1);
4340 VAROR(UI1
,255,DATE
,0,I4
,255);
4341 VAROR(UI1
,0,DATE
,0,I4
,0);
4342 if (HAVE_OLEAUT32_I8
)
4344 VAROR(UI1
,255,I8
,-1,I8
,-1);
4345 VAROR(UI1
,255,I8
,0,I8
,255);
4346 VAROR(UI1
,0,I8
,0,I8
,0);
4347 VAROR(UI1
,255,UI8
,0,I4
,255);
4348 VAROR(UI1
,0,UI8
,0,I4
,0);
4350 VAROR(UI1
,255,INT
,-1,I4
,-1);
4351 VAROR(UI1
,255,INT
,0,I4
,255);
4352 VAROR(UI1
,0,INT
,0,I4
,0);
4353 VAROR(UI1
,255,UINT
,0xffffffff,I4
,-1);
4354 VAROR(UI1
,255,UINT
,0,I4
,255);
4355 VAROR(UI1
,0,UINT
,0,I4
,0);
4356 rbstr
= SysAllocString(szFalse
);
4357 VAROR(UI1
,0,BSTR
,rbstr
,I2
,0);
4358 VAROR(UI1
,255,BSTR
,rbstr
,I2
,255);
4359 SysFreeString(rbstr
);
4360 rbstr
= SysAllocString(szTrue
);
4361 VAROR(UI1
,0,BSTR
,rbstr
,I2
,-1);
4362 VAROR(UI1
,255,BSTR
,rbstr
,I2
,-1);
4363 SysFreeString(rbstr
);
4364 VARORCY(UI1
,255,10000,I4
,255);
4365 VARORCY(UI1
,255,0,I4
,255);
4366 VARORCY(UI1
,0,0,I4
,0);
4368 VAROR(I2
,-1,I2
,-1,I2
,-1);
4369 VAROR(I2
,-1,I2
,0,I2
,-1);
4370 VAROR(I2
,0,I2
,0,I2
,0);
4371 VAROR(I2
,-1,UI2
,65535,I4
,-1);
4372 VAROR(I2
,-1,UI2
,0,I4
,-1);
4373 VAROR(I2
,0,UI2
,0,I4
,0);
4374 VAROR(I2
,-1,I4
,-1,I4
,-1);
4375 VAROR(I2
,-1,I4
,0,I4
,-1);
4376 VAROR(I2
,0,I4
,0,I4
,0);
4377 VAROR(I2
,-1,UI4
,0xffffffff,I4
,-1);
4378 VAROR(I2
,-1,UI4
,0,I4
,-1);
4379 VAROR(I2
,0,UI4
,0,I4
,0);
4380 VAROR(I2
,-1,R4
,-1,I4
,-1);
4381 VAROR(I2
,-1,R4
,0,I4
,-1);
4382 VAROR(I2
,0,R4
,0,I4
,0);
4383 VAROR(I2
,-1,R8
,-1,I4
,-1);
4384 VAROR(I2
,-1,R8
,0,I4
,-1);
4385 VAROR(I2
,0,R8
,0,I4
,0);
4386 VAROR(I2
,-1,DATE
,-1,I4
,-1);
4387 VAROR(I2
,-1,DATE
,0,I4
,-1);
4388 VAROR(I2
,0,DATE
,0,I4
,0);
4389 if (HAVE_OLEAUT32_I8
)
4391 VAROR(I2
,-1,I8
,-1,I8
,-1);
4392 VAROR(I2
,-1,I8
,0,I8
,-1);
4393 VAROR(I2
,0,I8
,0,I8
,0);
4394 VAROR(I2
,-1,UI8
,0,I4
,-1);
4395 VAROR(I2
,0,UI8
,0,I4
,0);
4397 VAROR(I2
,-1,INT
,-1,I4
,-1);
4398 VAROR(I2
,-1,INT
,0,I4
,-1);
4399 VAROR(I2
,0,INT
,0,I4
,0);
4400 VAROR(I2
,-1,UINT
,0xffffffff,I4
,-1);
4401 VAROR(I2
,-1,UINT
,0,I4
,-1);
4402 VAROR(I2
,0,UINT
,0,I4
,0);
4403 rbstr
= SysAllocString(szFalse
);
4404 VAROR(I2
,0,BSTR
,rbstr
,I2
,0);
4405 VAROR(I2
,-1,BSTR
,rbstr
,I2
,-1);
4406 SysFreeString(rbstr
);
4407 rbstr
= SysAllocString(szTrue
);
4408 VAROR(I2
,0,BSTR
,rbstr
,I2
,-1);
4409 VAROR(I2
,-1,BSTR
,rbstr
,I2
,-1);
4410 SysFreeString(rbstr
);
4411 VARORCY(I2
,-1,10000,I4
,-1);
4412 VARORCY(I2
,-1,0,I4
,-1);
4413 VARORCY(I2
,0,0,I4
,0);
4415 VAROR(UI2
,65535,UI2
,65535,I4
,65535);
4416 VAROR(UI2
,65535,UI2
,0,I4
,65535);
4417 VAROR(UI2
,0,UI2
,0,I4
,0);
4418 VAROR(UI2
,65535,I4
,-1,I4
,-1);
4419 VAROR(UI2
,65535,I4
,0,I4
,65535);
4420 VAROR(UI2
,0,I4
,0,I4
,0);
4421 VAROR(UI2
,65535,UI4
,0xffffffff,I4
,-1);
4422 VAROR(UI2
,65535,UI4
,0,I4
,65535);
4423 VAROR(UI2
,0,UI4
,0,I4
,0);
4424 VAROR(UI2
,65535,R4
,-1,I4
,-1);
4425 VAROR(UI2
,65535,R4
,0,I4
,65535);
4426 VAROR(UI2
,0,R4
,0,I4
,0);
4427 VAROR(UI2
,65535,R8
,-1,I4
,-1);
4428 VAROR(UI2
,65535,R8
,0,I4
,65535);
4429 VAROR(UI2
,0,R8
,0,I4
,0);
4430 VAROR(UI2
,65535,DATE
,-1,I4
,-1);
4431 VAROR(UI2
,65535,DATE
,0,I4
,65535);
4432 VAROR(UI2
,0,DATE
,0,I4
,0);
4433 if (HAVE_OLEAUT32_I8
)
4435 VAROR(UI2
,65535,I8
,-1,I8
,-1);
4436 VAROR(UI2
,65535,I8
,0,I8
,65535);
4437 VAROR(UI2
,0,I8
,0,I8
,0);
4438 VAROR(UI2
,65535,UI8
,0,I4
,65535);
4439 VAROR(UI2
,0,UI8
,0,I4
,0);
4441 VAROR(UI2
,65535,INT
,-1,I4
,-1);
4442 VAROR(UI2
,65535,INT
,0,I4
,65535);
4443 VAROR(UI2
,0,INT
,0,I4
,0);
4444 VAROR(UI2
,65535,UINT
,0xffffffff,I4
,-1);
4445 VAROR(UI2
,65535,UINT
,0,I4
,65535);
4446 VAROR(UI2
,0,UINT
,0,I4
,0);
4447 rbstr
= SysAllocString(szFalse
);
4448 VAROR(UI2
,0,BSTR
,rbstr
,I4
,0);
4449 VAROR(UI2
,65535,BSTR
,rbstr
,I4
,65535);
4450 SysFreeString(rbstr
);
4451 rbstr
= SysAllocString(szTrue
);
4452 VAROR(UI2
,0,BSTR
,rbstr
,I4
,-1);
4453 VAROR(UI2
,65535,BSTR
,rbstr
,I4
,-1);
4454 SysFreeString(rbstr
);
4455 VARORCY(UI2
,65535,10000,I4
,65535);
4456 VARORCY(UI2
,65535,0,I4
,65535);
4457 VARORCY(UI2
,0,0,I4
,0);
4459 VAROR(I4
,-1,I4
,-1,I4
,-1);
4460 VAROR(I4
,-1,I4
,0,I4
,-1);
4461 VAROR(I4
,0,I4
,0,I4
,0);
4462 VAROR(I4
,-1,UI4
,0xffffffff,I4
,-1);
4463 VAROR(I4
,-1,UI4
,0,I4
,-1);
4464 VAROR(I4
,0,UI4
,0,I4
,0);
4465 VAROR(I4
,-1,R4
,-1,I4
,-1);
4466 VAROR(I4
,-1,R4
,0,I4
,-1);
4467 VAROR(I4
,0,R4
,0,I4
,0);
4468 VAROR(I4
,-1,R8
,-1,I4
,-1);
4469 VAROR(I4
,-1,R8
,0,I4
,-1);
4470 VAROR(I4
,0,R8
,0,I4
,0);
4471 VAROR(I4
,-1,DATE
,-1,I4
,-1);
4472 VAROR(I4
,-1,DATE
,0,I4
,-1);
4473 VAROR(I4
,0,DATE
,0,I4
,0);
4474 if (HAVE_OLEAUT32_I8
)
4476 VAROR(I4
,-1,I8
,-1,I8
,-1);
4477 VAROR(I4
,-1,I8
,0,I8
,-1);
4478 VAROR(I4
,0,I8
,0,I8
,0);
4479 VAROR(I4
,-1,UI8
,0,I4
,-1);
4480 VAROR(I4
,0,UI8
,0,I4
,0);
4482 VAROR(I4
,-1,INT
,-1,I4
,-1);
4483 VAROR(I4
,-1,INT
,0,I4
,-1);
4484 VAROR(I4
,0,INT
,0,I4
,0);
4485 VAROR(I4
,-1,UINT
,0xffffffff,I4
,-1);
4486 VAROR(I4
,-1,UINT
,0,I4
,-1);
4487 VAROR(I4
,0,UINT
,0,I4
,0);
4488 rbstr
= SysAllocString(szFalse
);
4489 VAROR(I4
,0,BSTR
,rbstr
,I4
,0);
4490 VAROR(I4
,-1,BSTR
,rbstr
,I4
,-1);
4491 SysFreeString(rbstr
);
4492 rbstr
= SysAllocString(szTrue
);
4493 VAROR(I4
,0,BSTR
,rbstr
,I4
,-1);
4494 VAROR(I4
,-1,BSTR
,rbstr
,I4
,-1);
4495 SysFreeString(rbstr
);
4496 VARORCY(I4
,-1,10000,I4
,-1);
4497 VARORCY(I4
,-1,0,I4
,-1);
4498 VARORCY(I4
,0,0,I4
,0);
4500 VAROR(UI4
,0xffffffff,UI4
,0xffffffff,I4
,-1);
4501 VAROR(UI4
,0xffffffff,UI4
,0,I4
,-1);
4502 VAROR(UI4
,0,UI4
,0,I4
,0);
4503 VAROR(UI4
,0xffffffff,R4
,-1,I4
,-1);
4504 VAROR(UI4
,0xffffffff,R4
,0,I4
,-1);
4505 VAROR(UI4
,0,R4
,0,I4
,0);
4506 VAROR(UI4
,0xffffffff,R8
,-1,I4
,-1);
4507 VAROR(UI4
,0xffffffff,R8
,0,I4
,-1);
4508 VAROR(UI4
,0,R8
,0,I4
,0);
4509 VAROR(UI4
,0xffffffff,DATE
,-1,I4
,-1);
4510 VAROR(UI4
,0xffffffff,DATE
,0,I4
,-1);
4511 VAROR(UI4
,0,DATE
,0,I4
,0);
4512 if (HAVE_OLEAUT32_I8
)
4514 VAROR(UI4
,0xffffffff,I8
,-1,I8
,-1);
4515 VAROR(UI4
,0xffffffff,I8
,0,I8
,0xffffffff);
4516 VAROR(UI4
,0,I8
,0,I8
,0);
4517 VAROR(UI4
,0xffffffff,UI8
,0,I4
,-1);
4518 VAROR(UI4
,0,UI8
,0,I4
,0);
4520 VAROR(UI4
,0xffffffff,INT
,-1,I4
,-1);
4521 VAROR(UI4
,0xffffffff,INT
,0,I4
,-1);
4522 VAROR(UI4
,0,INT
,0,I4
,0);
4523 VAROR(UI4
,0xffffffff,UINT
,0xffffffff,I4
,-1);
4524 VAROR(UI4
,0xffffffff,UINT
,0,I4
,-1);
4525 VAROR(UI4
,0,UINT
,0,I4
,0);
4526 rbstr
= SysAllocString(szFalse
);
4527 VAROR(UI4
,0,BSTR
,rbstr
,I4
,0);
4528 VAROR(UI4
,0xffffffff,BSTR
,rbstr
,I4
,-1);
4529 SysFreeString(rbstr
);
4530 rbstr
= SysAllocString(szTrue
);
4531 VAROR(UI4
,0,BSTR
,rbstr
,I4
,-1);
4532 VAROR(UI4
,0xffffffff,BSTR
,rbstr
,I4
,-1);
4533 SysFreeString(rbstr
);
4534 VARORCY(UI4
,0xffffffff,10000,I4
,-1);
4535 VARORCY(UI4
,0xffffffff,0,I4
,-1);
4536 VARORCY(UI4
,0,0,I4
,0);
4538 VAROR(R4
,-1,R4
,-1,I4
,-1);
4539 VAROR(R4
,-1,R4
,0,I4
,-1);
4540 VAROR(R4
,0,R4
,0,I4
,0);
4541 VAROR(R4
,-1,R8
,-1,I4
,-1);
4542 VAROR(R4
,-1,R8
,0,I4
,-1);
4543 VAROR(R4
,0,R8
,0,I4
,0);
4544 VAROR(R4
,-1,DATE
,-1,I4
,-1);
4545 VAROR(R4
,-1,DATE
,0,I4
,-1);
4546 VAROR(R4
,0,DATE
,0,I4
,0);
4547 if (HAVE_OLEAUT32_I8
)
4549 VAROR(R4
,-1,I8
,-1,I8
,-1);
4550 VAROR(R4
,-1,I8
,0,I8
,-1);
4551 VAROR(R4
,0,I8
,0,I8
,0);
4552 VAROR(R4
,-1,UI8
,0,I4
,-1);
4553 VAROR(R4
,0,UI8
,0,I4
,0);
4555 VAROR(R4
,-1,INT
,-1,I4
,-1);
4556 VAROR(R4
,-1,INT
,0,I4
,-1);
4557 VAROR(R4
,0,INT
,0,I4
,0);
4558 VAROR(R4
,-1,UINT
,0xffffffff,I4
,-1);
4559 VAROR(R4
,-1,UINT
,0,I4
,-1);
4560 VAROR(R4
,0,UINT
,0,I4
,0);
4561 rbstr
= SysAllocString(szFalse
);
4562 VAROR(R4
,0,BSTR
,rbstr
,I4
,0);
4563 VAROR(R4
,-1,BSTR
,rbstr
,I4
,-1);
4564 SysFreeString(rbstr
);
4565 rbstr
= SysAllocString(szTrue
);
4566 VAROR(R4
,0,BSTR
,rbstr
,I4
,-1);
4567 VAROR(R4
,-1,BSTR
,rbstr
,I4
,-1);
4568 SysFreeString(rbstr
);
4569 VARORCY(R4
,-1,10000,I4
,-1);
4570 VARORCY(R4
,-1,0,I4
,-1);
4571 VARORCY(R4
,0,0,I4
,0);
4573 VAROR(R8
,-1,R8
,-1,I4
,-1);
4574 VAROR(R8
,-1,R8
,0,I4
,-1);
4575 VAROR(R8
,0,R8
,0,I4
,0);
4576 VAROR(R8
,-1,DATE
,-1,I4
,-1);
4577 VAROR(R8
,-1,DATE
,0,I4
,-1);
4578 VAROR(R8
,0,DATE
,0,I4
,0);
4579 if (HAVE_OLEAUT32_I8
)
4581 VAROR(R8
,-1,I8
,-1,I8
,-1);
4582 VAROR(R8
,-1,I8
,0,I8
,-1);
4583 VAROR(R8
,0,I8
,0,I8
,0);
4584 VAROR(R8
,-1,UI8
,0,I4
,-1);
4585 VAROR(R8
,0,UI8
,0,I4
,0);
4587 VAROR(R8
,-1,INT
,-1,I4
,-1);
4588 VAROR(R8
,-1,INT
,0,I4
,-1);
4589 VAROR(R8
,0,INT
,0,I4
,0);
4590 VAROR(R8
,-1,UINT
,0xffffffff,I4
,-1);
4591 VAROR(R8
,-1,UINT
,0,I4
,-1);
4592 VAROR(R8
,0,UINT
,0,I4
,0);
4593 rbstr
= SysAllocString(szFalse
);
4594 VAROR(R8
,0,BSTR
,rbstr
,I4
,0);
4595 VAROR(R8
,-1,BSTR
,rbstr
,I4
,-1);
4596 SysFreeString(rbstr
);
4597 rbstr
= SysAllocString(szTrue
);
4598 VAROR(R8
,0,BSTR
,rbstr
,I4
,-1);
4599 VAROR(R8
,-1,BSTR
,rbstr
,I4
,-1);
4600 SysFreeString(rbstr
);
4601 VARORCY(R8
,-1,10000,I4
,-1);
4602 VARORCY(R8
,-1,0,I4
,-1);
4603 VARORCY(R8
,0,0,I4
,0);
4605 VAROR(DATE
,-1,DATE
,-1,I4
,-1);
4606 VAROR(DATE
,-1,DATE
,0,I4
,-1);
4607 VAROR(DATE
,0,DATE
,0,I4
,0);
4608 if (HAVE_OLEAUT32_I8
)
4610 VAROR(DATE
,-1,I8
,-1,I8
,-1);
4611 VAROR(DATE
,-1,I8
,0,I8
,-1);
4612 VAROR(DATE
,0,I8
,0,I8
,0);
4613 VAROR(DATE
,-1,UI8
,0,I4
,-1);
4614 VAROR(DATE
,0,UI8
,0,I4
,0);
4616 VAROR(DATE
,-1,INT
,-1,I4
,-1);
4617 VAROR(DATE
,-1,INT
,0,I4
,-1);
4618 VAROR(DATE
,0,INT
,0,I4
,0);
4619 VAROR(DATE
,-1,UINT
,0xffffffff,I4
,-1);
4620 VAROR(DATE
,-1,UINT
,0,I4
,-1);
4621 VAROR(DATE
,0,UINT
,0,I4
,0);
4622 rbstr
= SysAllocString(szFalse
);
4623 VAROR(DATE
,0,BSTR
,rbstr
,I4
,0);
4624 VAROR(DATE
,-1,BSTR
,rbstr
,I4
,-1);
4625 SysFreeString(rbstr
);
4626 rbstr
= SysAllocString(szTrue
);
4627 VAROR(DATE
,0,BSTR
,rbstr
,I4
,-1);
4628 VAROR(DATE
,-1,BSTR
,rbstr
,I4
,-1);
4629 SysFreeString(rbstr
);
4630 VARORCY(DATE
,-1,10000,I4
,-1);
4631 VARORCY(DATE
,-1,0,I4
,-1);
4632 VARORCY(DATE
,0,0,I4
,0);
4634 if (HAVE_OLEAUT32_I8
)
4636 VAROR(I8
,-1,I8
,-1,I8
,-1);
4637 VAROR(I8
,-1,I8
,0,I8
,-1);
4638 VAROR(I8
,0,I8
,0,I8
,0);
4639 VAROR(I8
,-1,UI8
,0,I8
,-1);
4640 VAROR(I8
,0,UI8
,0,I8
,0);
4641 /* These overflow under native and Wine
4642 VAROR(I8,-1,INT,-1,I4,-1);
4643 VAROR(I8,-1,INT,0,I4,-1);
4644 VAROR(I8,0,INT,0,I4,0); */
4645 VAROR(I8
,-1,UINT
,0xffffffff,I8
,-1);
4646 VAROR(I8
,-1,UINT
,0,I8
,-1);
4647 VAROR(I8
,0,UINT
,0,I8
,0);
4648 rbstr
= SysAllocString(szFalse
);
4649 VAROR(I8
,0,BSTR
,rbstr
,I8
,0);
4650 VAROR(I8
,-1,BSTR
,rbstr
,I8
,-1);
4651 SysFreeString(rbstr
);
4652 rbstr
= SysAllocString(szTrue
);
4653 VAROR(I8
,0,BSTR
,rbstr
,I8
,-1);
4654 VAROR(I8
,-1,BSTR
,rbstr
,I8
,-1);
4655 SysFreeString(rbstr
);
4656 VARORCY(I8
,-1,10000,I8
,-1);
4657 VARORCY(I8
,-1,0,I8
,-1);
4658 VARORCY(I8
,0,0,I8
,0);
4660 VAROR(UI8
,0xffff,UI8
,0xffff,I4
,0xffff);
4661 VAROR(UI8
,0xffff,UI8
,0,I4
,0xffff);
4662 VAROR(UI8
,0,UI8
,0,I4
,0);
4663 VAROR(UI8
,0xffff,INT
,-1,I4
,-1);
4664 VAROR(UI8
,0xffff,INT
,0,I4
,0xffff);
4665 VAROR(UI8
,0,INT
,0,I4
,0);
4666 VAROR(UI8
,0xffff,UINT
,0xffff,I4
,0xffff);
4667 VAROR(UI8
,0xffff,UINT
,0,I4
,0xffff);
4668 VAROR(UI8
,0,UINT
,0,I4
,0);
4669 rbstr
= SysAllocString(szFalse
);
4670 VAROR(UI8
,0,BSTR
,rbstr
,I4
,0);
4671 VAROR(UI8
,0xffff,BSTR
,rbstr
,I4
,0xffff);
4672 SysFreeString(rbstr
);
4673 rbstr
= SysAllocString(szTrue
);
4674 VAROR(UI8
,0,BSTR
,rbstr
,I4
,-1);
4675 VAROR(UI8
,0xffff,BSTR
,rbstr
,I4
,-1);
4676 SysFreeString(rbstr
);
4677 VARORCY(UI8
,0xffff,10000,I4
,0xffff);
4678 VARORCY(UI8
,0xffff,0,I4
,0xffff);
4679 VARORCY(UI8
,0,0,I4
,0);
4682 VAROR(INT
,-1,INT
,-1,I4
,-1);
4683 VAROR(INT
,-1,INT
,0,I4
,-1);
4684 VAROR(INT
,0,INT
,0,I4
,0);
4685 VAROR(INT
,-1,UINT
,0xffff,I4
,-1);
4686 VAROR(INT
,-1,UINT
,0,I4
,-1);
4687 VAROR(INT
,0,UINT
,0,I4
,0);
4688 rbstr
= SysAllocString(szFalse
);
4689 VAROR(INT
,0,BSTR
,rbstr
,I4
,0);
4690 VAROR(INT
,-1,BSTR
,rbstr
,I4
,-1);
4691 SysFreeString(rbstr
);
4692 rbstr
= SysAllocString(szTrue
);
4693 VAROR(INT
,0,BSTR
,rbstr
,I4
,-1);
4694 VAROR(INT
,-1,BSTR
,rbstr
,I4
,-1);
4695 SysFreeString(rbstr
);
4696 VARORCY(INT
,-1,10000,I4
,-1);
4697 VARORCY(INT
,-1,0,I4
,-1);
4698 VARORCY(INT
,0,0,I4
,0);
4700 VAROR(UINT
,0xffff,UINT
,0xffff,I4
,0xffff);
4701 VAROR(UINT
,0xffff,UINT
,0,I4
,0xffff);
4702 VAROR(UINT
,0,UINT
,0,I4
,0);
4703 rbstr
= SysAllocString(szFalse
);
4704 VAROR(UINT
,0,BSTR
,rbstr
,I4
,0);
4705 VAROR(UINT
,0xffff,BSTR
,rbstr
,I4
,0xffff);
4706 SysFreeString(rbstr
);
4707 rbstr
= SysAllocString(szTrue
);
4708 VAROR(UINT
,0,BSTR
,rbstr
,I4
,-1);
4709 VAROR(UINT
,0xffff,BSTR
,rbstr
,I4
,-1);
4710 SysFreeString(rbstr
);
4711 VARORCY(UINT
,0xffff,10000,I4
,0xffff);
4712 VARORCY(UINT
,0xffff,0,I4
,0xffff);
4713 VARORCY(UINT
,0,0,I4
,0);
4715 lbstr
= SysAllocString(szFalse
);
4716 rbstr
= SysAllocString(szFalse
);
4717 VAROR(BSTR
,lbstr
,BSTR
,rbstr
,BOOL
,0);
4718 SysFreeString(rbstr
);
4719 rbstr
= SysAllocString(szTrue
);
4720 VAROR(BSTR
,lbstr
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
4721 SysFreeString(lbstr
);
4722 lbstr
= SysAllocString(szTrue
);
4723 VAROR(BSTR
,lbstr
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
4724 VARORCY(BSTR
,lbstr
,10000,I4
,-1);
4725 SysFreeString(lbstr
);
4726 lbstr
= SysAllocString(szFalse
);
4727 VARORCY(BSTR
,lbstr
,10000,I4
,1);
4728 SysFreeString(lbstr
);
4729 SysFreeString(rbstr
);
4732 static HRESULT (WINAPI
*pVarEqv
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
4734 #define VAREQV(vt1,val1,vt2,val2,rvt,rval) \
4735 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
4736 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
4737 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
4738 test_var_call2( __LINE__, pVarEqv, &left, &right, &exp )
4740 static void test_VarEqv(void)
4742 VARIANT left
, right
, exp
, result
;
4748 /* Test all possible flag/vt combinations & the resulting vt type */
4749 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
4751 VARTYPE leftvt
, rightvt
, resvt
;
4753 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
4757 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
4763 if (leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
||
4764 leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
||
4765 leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
)
4768 memset(&left
, 0, sizeof(left
));
4769 memset(&right
, 0, sizeof(right
));
4770 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
4771 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
4772 V_VT(&result
) = VT_EMPTY
;
4775 if (ExtraFlags
[i
] & VT_ARRAY
|| ExtraFlags
[i
] & VT_BYREF
||
4776 !IsValidVariantClearVT(leftvt
, ExtraFlags
[i
]) ||
4777 !IsValidVariantClearVT(rightvt
, ExtraFlags
[i
]) ||
4778 leftvt
== VT_CLSID
|| rightvt
== VT_CLSID
||
4779 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
||
4780 leftvt
== VT_VARIANT
|| rightvt
== VT_VARIANT
||
4781 leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
)
4785 if (leftvt
== VT_EMPTY
|| rightvt
== VT_EMPTY
)
4787 if (leftvt
== rightvt
||
4788 leftvt
== VT_I2
|| rightvt
== VT_I2
||
4789 leftvt
== VT_UI1
|| rightvt
== VT_UI1
||
4790 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
4792 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
4794 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
4797 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
4801 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
4803 if (leftvt
== rightvt
)
4805 else if (leftvt
== rightvt
||
4806 leftvt
== VT_I2
|| rightvt
== VT_I2
||
4807 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
4811 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
4814 else if (leftvt
== VT_I2
|| rightvt
== VT_I2
)
4816 if (leftvt
== rightvt
||
4817 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
4819 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
4822 else if (leftvt
== VT_BOOL
&& rightvt
== VT_BOOL
)
4826 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
4828 if (leftvt
== VT_INT
|| rightvt
== VT_INT
)
4833 hres
= pVarEqv(&left
, &right
, &result
);
4835 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
4836 "VarEqv: %d|0x%X, %d|0x%X: Expected failure, got 0x%X vt %d\n",
4837 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], hres
,
4840 ok(hres
== S_OK
&& V_VT(&result
) == resvt
,
4841 "VarEqv: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%X vt %d\n",
4842 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], resvt
, hres
,
4848 /* Test returned values */
4849 VAREQV(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
);
4850 VAREQV(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
);
4851 VAREQV(BOOL
,TRUE
,BOOL
,TRUE
,BOOL
,VARIANT_TRUE
);
4852 VAREQV(BOOL
,FALSE
,BOOL
,FALSE
,BOOL
,VARIANT_TRUE
);
4853 VAREQV(BOOL
,TRUE
,BOOL
,FALSE
,BOOL
,-2);
4854 VAREQV(BOOL
,FALSE
,BOOL
,TRUE
,BOOL
,-2);
4855 VAREQV(BOOL
,6,BOOL
,7,BOOL
,-2);
4856 VAREQV(BOOL
,6,BOOL
,6,BOOL
,VARIANT_TRUE
);
4857 VAREQV(BOOL
,VARIANT_TRUE
,I2
,VARIANT_TRUE
,I2
,VARIANT_TRUE
);
4858 VAREQV(BOOL
,VARIANT_TRUE
,I2
,VARIANT_FALSE
,I2
,VARIANT_FALSE
);
4859 VAREQV(BOOL
,6,I2
,7,I2
,-2);
4860 VAREQV(UI1
,1,UI1
,1,UI1
,255);
4861 VAREQV(UI1
,1,UI1
,0,UI1
,254);
4862 VAREQV(UI1
,0,UI1
,1,UI1
,254);
4863 if (HAVE_OLEAUT32_I8
)
4865 VAREQV(UI4
,VARIANT_FALSE
,I8
,VARIANT_FALSE
,I8
,-1);
4866 VAREQV(UI4
,5,I8
,19,I8
,-23);
4867 VAREQV(UI4
,VARIANT_FALSE
,UI8
,VARIANT_FALSE
,I4
,-1);
4871 static HRESULT (WINAPI
*pVarMul
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
4873 #define VARMUL(vt1,val1,vt2,val2,rvt,rval) \
4874 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
4875 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
4876 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
4877 test_var_call2( __LINE__, pVarMul, &left, &right, &exp )
4879 static void test_VarMul(void)
4881 VARIANT left
, right
, exp
, result
, cy
, dec
;
4889 lbstr
= SysAllocString(sz12
);
4890 rbstr
= SysAllocString(sz12
);
4892 /* Test all possible flag/vt combinations & the resulting vt type */
4893 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
4895 VARTYPE leftvt
, rightvt
, resvt
;
4897 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
4902 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
4908 if (leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
||
4909 leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
)
4912 memset(&left
, 0, sizeof(left
));
4913 memset(&right
, 0, sizeof(right
));
4914 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
4915 if (leftvt
== VT_BSTR
)
4916 V_BSTR(&left
) = lbstr
;
4917 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
4918 if (rightvt
== VT_BSTR
)
4919 V_BSTR(&right
) = rbstr
;
4920 V_VT(&result
) = VT_EMPTY
;
4923 /* Don't ask me why but native VarMul cannot handle:
4924 VT_I1, VT_UI2, VT_UI4, VT_INT, VT_UINT and VT_UI8.
4925 Tested with DCOM98, Win2k, WinXP */
4926 if (ExtraFlags
[i
] & VT_ARRAY
|| ExtraFlags
[i
] & VT_BYREF
||
4927 !IsValidVariantClearVT(leftvt
, ExtraFlags
[i
]) ||
4928 !IsValidVariantClearVT(rightvt
, ExtraFlags
[i
]) ||
4929 leftvt
== VT_CLSID
|| rightvt
== VT_CLSID
||
4930 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
||
4931 leftvt
== VT_VARIANT
|| rightvt
== VT_VARIANT
||
4932 leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
||
4933 leftvt
== VT_I1
|| rightvt
== VT_I1
||
4934 leftvt
== VT_UI2
|| rightvt
== VT_UI2
||
4935 leftvt
== VT_UI4
|| rightvt
== VT_UI4
||
4936 leftvt
== VT_UI8
|| rightvt
== VT_UI8
||
4937 leftvt
== VT_INT
|| rightvt
== VT_INT
||
4938 leftvt
== VT_UINT
|| rightvt
== VT_UINT
) {
4942 if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
4944 else if (leftvt
== VT_DECIMAL
|| rightvt
== VT_DECIMAL
)
4946 else if (leftvt
== VT_R8
|| rightvt
== VT_R8
||
4947 leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
||
4948 leftvt
== VT_DATE
|| rightvt
== VT_DATE
)
4950 else if (leftvt
== VT_R4
|| rightvt
== VT_R4
) {
4951 if (leftvt
== VT_I4
|| rightvt
== VT_I4
||
4952 leftvt
== VT_I8
|| rightvt
== VT_I8
||
4953 leftvt
== VT_CY
|| rightvt
== VT_CY
)
4957 } else if (leftvt
== VT_CY
|| rightvt
== VT_CY
)
4959 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
4961 else if (leftvt
== VT_I4
|| rightvt
== VT_I4
)
4963 else if (leftvt
== VT_I2
|| rightvt
== VT_I2
||
4964 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
||
4965 (leftvt
== VT_EMPTY
&& rightvt
== VT_EMPTY
))
4967 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
4970 hres
= pVarMul(&left
, &right
, &result
);
4972 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
4973 "VarMul: %d|0x%X, %d|0x%X: Expected failure, got 0x%X vt %d\n",
4974 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], hres
,
4977 ok(hres
== S_OK
&& V_VT(&result
) == resvt
,
4978 "VarMul: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%X vt %d\n",
4979 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], resvt
, hres
,
4986 /* Test returned values */
4987 VARMUL(I4
,4,I4
,2,I4
,8);
4988 VARMUL(I2
,4,I2
,2,I2
,8);
4989 VARMUL(I2
,-13,I4
,5,I4
,-65);
4990 VARMUL(I4
,-13,I4
,5,I4
,-65);
4991 VARMUL(I2
,7,R4
,0.5f
,R4
,3.5f
);
4992 VARMUL(R4
,0.5f
,I4
,5,R8
,2.5);
4993 VARMUL(R8
,7.1,BOOL
,0,R8
,0);
4994 VARMUL(BSTR
,lbstr
,I2
,4,R8
,48);
4995 VARMUL(BSTR
,lbstr
,BOOL
,1,R8
,12);
4996 VARMUL(BSTR
,lbstr
,R4
,0.1f
,R8
,1.2);
4997 VARMUL(BSTR
,lbstr
,BSTR
,rbstr
,R8
,144);
4998 VARMUL(R4
,0.2f
,BSTR
,rbstr
,R8
,2.4);
4999 VARMUL(DATE
,2.25,I4
,7,R8
,15.75);
5001 VARMUL(UI1
, UI1_MAX
, UI1
, UI1_MAX
, I4
, UI1_MAX
* UI1_MAX
);
5002 VARMUL(I2
, I2_MAX
, I2
, I2_MAX
, I4
, I2_MAX
* I2_MAX
);
5003 VARMUL(I2
, I2_MAX
, I2
, I2_MIN
, I4
, I2_MAX
* I2_MIN
);
5004 VARMUL(I2
, I2_MIN
, I2
, I2_MIN
, I4
, I2_MIN
* I2_MIN
);
5005 VARMUL(I4
, I4_MAX
, I4
, I4_MAX
, R8
, (double)I4_MAX
* I4_MAX
);
5006 VARMUL(I4
, I4_MAX
, I4
, I4_MIN
, R8
, (double)I4_MAX
* I4_MIN
);
5007 VARMUL(I4
, I4_MIN
, I4
, I4_MIN
, R8
, (double)I4_MIN
* I4_MIN
);
5008 VARMUL(R4
, R4_MAX
, R4
, R4_MAX
, R8
, (double)R4_MAX
* R4_MAX
);
5009 VARMUL(R4
, R4_MAX
, R4
, R4_MIN
, R4
, R4_MAX
* R4_MIN
);
5010 VARMUL(R4
, R4_MIN
, R4
, R4_MIN
, R4
, R4_MIN
* R4_MIN
);
5011 VARMUL(R8
, R8_MAX
, R8
, R8_MIN
, R8
, R8_MAX
* R8_MIN
);
5012 VARMUL(R8
, R8_MIN
, R8
, R8_MIN
, R8
, R8_MIN
* R8_MIN
);
5014 /* Manuly test some VT_CY and VT_DECIMAL variants */
5016 hres
= VarCyFromI4(4711, &V_CY(&cy
));
5017 ok(hres
== S_OK
, "VarCyFromI4 failed!\n");
5018 V_VT(&dec
) = VT_DECIMAL
;
5019 hres
= VarDecFromR8(-4.2, &V_DECIMAL(&dec
));
5020 ok(hres
== S_OK
, "VarDecFromR4 failed!\n");
5021 memset(&left
, 0, sizeof(left
));
5022 memset(&right
, 0, sizeof(right
));
5023 V_VT(&left
) = VT_I4
;
5025 V_VT(&right
) = VT_UI1
;
5028 hres
= VarMul(&cy
, &right
, &result
);
5029 ok(hres
== S_OK
&& V_VT(&result
) == VT_CY
, "VarMul: expected coerced type VT_CY, got %s!\n", vtstr(V_VT(&result
)));
5030 hres
= VarR8FromCy(V_CY(&result
), &r
);
5031 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 42399), "VarMul: CY value %f, expected %f\n", r
, (double)42399);
5033 hres
= VarMul(&left
, &dec
, &result
);
5034 ok(hres
== S_OK
&& V_VT(&result
) == VT_DECIMAL
, "VarMul: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result
)));
5035 hres
= VarR8FromDec(&V_DECIMAL(&result
), &r
);
5036 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 46.2), "VarMul: DECIMAL value %f, expected %f\n", r
, (double)46.2);
5038 SysFreeString(lbstr
);
5039 SysFreeString(rbstr
);
5042 static HRESULT (WINAPI
*pVarAdd
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
5044 #define VARADD(vt1,val1,vt2,val2,rvt,rval) \
5045 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
5046 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
5047 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
5048 test_var_call2( __LINE__, pVarAdd, &left, &right, &exp )
5050 static void test_VarAdd(void)
5052 VARIANT left
, right
, exp
, result
, cy
, dec
;
5060 lbstr
= SysAllocString(sz12
);
5061 rbstr
= SysAllocString(sz12
);
5063 /* Test all possible flag/vt combinations & the resulting vt type */
5064 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
5066 VARTYPE leftvt
, rightvt
, resvt
;
5068 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
5073 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
5079 if (leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
)
5082 memset(&left
, 0, sizeof(left
));
5083 memset(&right
, 0, sizeof(right
));
5084 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
5085 if (leftvt
== VT_BSTR
)
5086 V_BSTR(&left
) = lbstr
;
5087 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
5088 if (rightvt
== VT_BSTR
)
5089 V_BSTR(&right
) = rbstr
;
5090 V_VT(&result
) = VT_EMPTY
;
5093 /* Don't ask me why but native VarAdd cannot handle:
5094 VT_I1, VT_UI2, VT_UI4, VT_INT, VT_UINT and VT_UI8.
5095 Tested with DCOM98, Win2k, WinXP */
5096 if (ExtraFlags
[i
] & VT_ARRAY
|| ExtraFlags
[i
] & VT_BYREF
||
5097 !IsValidVariantClearVT(leftvt
, ExtraFlags
[i
]) ||
5098 !IsValidVariantClearVT(rightvt
, ExtraFlags
[i
]) ||
5099 leftvt
== VT_CLSID
|| rightvt
== VT_CLSID
||
5100 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
||
5101 leftvt
== VT_VARIANT
|| rightvt
== VT_VARIANT
||
5102 leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
||
5103 leftvt
== VT_I1
|| rightvt
== VT_I1
||
5104 leftvt
== VT_UI2
|| rightvt
== VT_UI2
||
5105 leftvt
== VT_UI4
|| rightvt
== VT_UI4
||
5106 leftvt
== VT_UI8
|| rightvt
== VT_UI8
||
5107 leftvt
== VT_INT
|| rightvt
== VT_INT
||
5108 leftvt
== VT_UINT
|| rightvt
== VT_UINT
) {
5112 if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
5114 else if (leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
)
5116 else if (leftvt
== VT_DECIMAL
|| rightvt
== VT_DECIMAL
)
5118 else if (leftvt
== VT_DATE
|| rightvt
== VT_DATE
)
5120 else if (leftvt
== VT_CY
|| rightvt
== VT_CY
)
5122 else if (leftvt
== VT_R8
|| rightvt
== VT_R8
)
5124 else if (leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
) {
5125 if ((leftvt
== VT_BSTR
&& rightvt
== VT_BSTR
) ||
5126 leftvt
== VT_EMPTY
|| rightvt
== VT_EMPTY
)
5130 } else if (leftvt
== VT_R4
|| rightvt
== VT_R4
) {
5131 if (leftvt
== VT_I4
|| rightvt
== VT_I4
||
5132 leftvt
== VT_I8
|| rightvt
== VT_I8
)
5137 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
5139 else if (leftvt
== VT_I4
|| rightvt
== VT_I4
)
5141 else if (leftvt
== VT_I2
|| rightvt
== VT_I2
||
5142 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
||
5143 (leftvt
== VT_EMPTY
&& rightvt
== VT_EMPTY
))
5145 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
5148 hres
= pVarAdd(&left
, &right
, &result
);
5150 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
5151 "VarAdd: %d|0x%X, %d|0x%X: Expected failure, got 0x%X vt %d\n",
5152 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], hres
,
5155 ok(hres
== S_OK
&& V_VT(&result
) == resvt
,
5156 "VarAdd: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%X vt %d\n",
5157 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], resvt
, hres
,
5160 /* Note, we don't clear left/right deliberately here */
5161 VariantClear(&result
);
5166 /* Test returned values */
5167 VARADD(I4
,4,I4
,2,I4
,6);
5168 VARADD(I2
,4,I2
,2,I2
,6);
5169 VARADD(I2
,-13,I4
,5,I4
,-8);
5170 VARADD(I4
,-13,I4
,5,I4
,-8);
5171 VARADD(I2
,7,R4
,0.5f
,R4
,7.5f
);
5172 VARADD(R4
,0.5f
,I4
,5,R8
,5.5);
5173 VARADD(R8
,7.1,BOOL
,0,R8
,7.1);
5174 VARADD(BSTR
,lbstr
,I2
,4,R8
,16);
5175 VARADD(BSTR
,lbstr
,BOOL
,1,R8
,13);
5176 VARADD(BSTR
,lbstr
,R4
,0.1f
,R8
,12.1);
5177 VARADD(R4
,0.2f
,BSTR
,rbstr
,R8
,12.2);
5178 VARADD(DATE
,2.25,I4
,7,DATE
,9.25);
5179 VARADD(DATE
,1.25,R4
,-1.7f
,DATE
,-0.45);
5181 VARADD(UI1
, UI1_MAX
, UI1
, UI1_MAX
, I2
, UI1_MAX
+ UI1_MAX
);
5182 VARADD(I2
, I2_MAX
, I2
, I2_MAX
, I4
, I2_MAX
+ I2_MAX
);
5183 VARADD(I2
, I2_MAX
, I2
, I2_MIN
, I2
, I2_MAX
+ I2_MIN
);
5184 VARADD(I2
, I2_MIN
, I2
, I2_MIN
, I4
, I2_MIN
+ I2_MIN
);
5185 VARADD(I4
, I4_MAX
, I4
, I4_MIN
, I4
, I4_MAX
+ I4_MIN
);
5186 VARADD(I4
, I4_MAX
, I4
, I4_MAX
, R8
, (double)I4_MAX
+ I4_MAX
);
5187 VARADD(I4
, I4_MIN
, I4
, I4_MIN
, R8
, (double)I4_MIN
+ I4_MIN
);
5188 VARADD(R4
, R4_MAX
, R4
, R4_MAX
, R8
, (double)R4_MAX
+ R4_MAX
);
5189 VARADD(R4
, R4_MAX
, R4
, R4_MIN
, R4
, R4_MAX
+ R4_MIN
);
5190 VARADD(R4
, R4_MIN
, R4
, R4_MIN
, R4
, R4_MIN
+ R4_MIN
);
5191 VARADD(R8
, R8_MAX
, R8
, R8_MIN
, R8
, R8_MAX
+ R8_MIN
);
5192 VARADD(R8
, R8_MIN
, R8
, R8_MIN
, R8
, R8_MIN
+ R8_MIN
);
5194 /* Manually test BSTR + BSTR */
5195 V_VT(&left
) = VT_BSTR
;
5196 V_BSTR(&left
) = lbstr
;
5197 V_VT(&right
) = VT_BSTR
;
5198 V_BSTR(&right
) = rbstr
;
5199 hres
= VarAdd(&left
, &right
, &result
);
5200 ok(hres
== S_OK
&& V_VT(&result
) == VT_BSTR
, "VarAdd: expected coerced type VT_BSTR, got %s!\n", vtstr(V_VT(&result
)));
5201 hres
= VarR8FromStr(V_BSTR(&result
), 0, 0, &r
);
5202 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 1212), "VarAdd: BSTR value %f, expected %f\n", r
, (double)1212);
5203 VariantClear(&result
);
5205 /* Manuly test some VT_CY and VT_DECIMAL variants */
5207 hres
= VarCyFromI4(4711, &V_CY(&cy
));
5208 ok(hres
== S_OK
, "VarCyFromI4 failed!\n");
5209 V_VT(&dec
) = VT_DECIMAL
;
5210 hres
= VarDecFromR8(-4.2, &V_DECIMAL(&dec
));
5211 ok(hres
== S_OK
, "VarDecFromR4 failed!\n");
5212 memset(&left
, 0, sizeof(left
));
5213 memset(&right
, 0, sizeof(right
));
5214 V_VT(&left
) = VT_I4
;
5216 V_VT(&right
) = VT_UI1
;
5219 hres
= VarAdd(&cy
, &right
, &result
);
5220 ok(hres
== S_OK
&& V_VT(&result
) == VT_CY
, "VarAdd: expected coerced type VT_CY, got %s!\n", vtstr(V_VT(&result
)));
5221 hres
= VarR8FromCy(V_CY(&result
), &r
);
5222 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 4720), "VarAdd: CY value %f, expected %f\n", r
, (double)4720);
5224 hres
= VarAdd(&left
, &dec
, &result
);
5225 ok(hres
== S_OK
&& V_VT(&result
) == VT_DECIMAL
, "VarAdd: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result
)));
5226 hres
= VarR8FromDec(&V_DECIMAL(&result
), &r
);
5227 ok(hres
== S_OK
&& EQ_DOUBLE(r
, -15.2), "VarAdd: DECIMAL value %f, expected %f\n", r
, (double)-15.2);
5228 VariantClear(&result
);
5230 SysFreeString(lbstr
);
5231 SysFreeString(rbstr
);
5234 static void test_VarCat(void)
5237 VARIANT left
, right
, result
, expected
;
5238 static const WCHAR sz34
[] = {'3','4','\0'};
5239 static const WCHAR sz1234
[] = {'1','2','3','4','\0'};
5240 static const WCHAR date_sz12
[] = {'9','/','3','0','/','1','9','8','0','1','2','\0'};
5241 static const WCHAR sz12_date
[] = {'1','2','9','/','3','0','/','1','9','8','0','\0'};
5242 static const WCHAR sz_empty
[] = {'\0'};
5243 TCHAR orig_date_format
[128];
5244 VARTYPE leftvt
, rightvt
, resultvt
;
5246 HRESULT expected_error_num
;
5248 /* Set date format for testing */
5249 lcid
= LOCALE_USER_DEFAULT
;
5250 GetLocaleInfo(lcid
,LOCALE_SSHORTDATE
,orig_date_format
,128);
5251 SetLocaleInfo(lcid
,LOCALE_SSHORTDATE
,"M/d/yyyy");
5254 VariantInit(&right
);
5255 VariantInit(&result
);
5256 VariantInit(&expected
);
5258 /* Check expected types for all combinations */
5259 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
5264 /* Check if we need/have support for I8 and/or UI8 */
5265 if ((leftvt
== VT_I8
|| leftvt
== VT_UI8
) && !HAVE_OLEAUT32_I8
)
5268 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
5272 expected_error_num
= S_OK
;
5273 resultvt
= VT_EMPTY
;
5275 if (leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
||
5276 leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
||
5277 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
||
5278 leftvt
== 15 || rightvt
== 15 /* Undefined type */)
5281 /* Check if we need/have support for I8 and/or UI8 */
5282 if ((rightvt
== VT_I8
|| rightvt
== VT_UI8
) && !HAVE_OLEAUT32_I8
)
5285 if (leftvt
== VT_NULL
&& rightvt
== VT_NULL
)
5287 else if (leftvt
== VT_VARIANT
&& (rightvt
== VT_ERROR
||
5288 rightvt
== VT_DATE
|| rightvt
== VT_DECIMAL
))
5289 expected_error_num
= DISP_E_TYPEMISMATCH
;
5290 else if ((leftvt
== VT_I2
|| leftvt
== VT_I4
||
5291 leftvt
== VT_R4
|| leftvt
== VT_R8
||
5292 leftvt
== VT_CY
|| leftvt
== VT_BOOL
||
5293 leftvt
== VT_BSTR
|| leftvt
== VT_I1
||
5294 leftvt
== VT_UI1
|| leftvt
== VT_UI2
||
5295 leftvt
== VT_UI4
|| leftvt
== VT_I8
||
5296 leftvt
== VT_UI8
|| leftvt
== VT_INT
||
5297 leftvt
== VT_UINT
|| leftvt
== VT_EMPTY
||
5298 leftvt
== VT_NULL
|| leftvt
== VT_DECIMAL
||
5301 (rightvt
== VT_I2
|| rightvt
== VT_I4
||
5302 rightvt
== VT_R4
|| rightvt
== VT_R8
||
5303 rightvt
== VT_CY
|| rightvt
== VT_BOOL
||
5304 rightvt
== VT_BSTR
|| rightvt
== VT_I1
||
5305 rightvt
== VT_UI1
|| rightvt
== VT_UI2
||
5306 rightvt
== VT_UI4
|| rightvt
== VT_I8
||
5307 rightvt
== VT_UI8
|| rightvt
== VT_INT
||
5308 rightvt
== VT_UINT
|| rightvt
== VT_EMPTY
||
5309 rightvt
== VT_NULL
|| rightvt
== VT_DECIMAL
||
5310 rightvt
== VT_DATE
))
5312 else if (rightvt
== VT_ERROR
&& leftvt
< VT_VOID
)
5313 expected_error_num
= DISP_E_TYPEMISMATCH
;
5314 else if (leftvt
== VT_ERROR
&& (rightvt
== VT_DATE
||
5315 rightvt
== VT_ERROR
|| rightvt
== VT_DECIMAL
))
5316 expected_error_num
= DISP_E_TYPEMISMATCH
;
5317 else if (rightvt
== VT_DATE
|| rightvt
== VT_ERROR
||
5318 rightvt
== VT_DECIMAL
)
5319 expected_error_num
= DISP_E_BADVARTYPE
;
5320 else if (leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
)
5321 expected_error_num
= DISP_E_TYPEMISMATCH
;
5322 else if (leftvt
== VT_VARIANT
)
5323 expected_error_num
= DISP_E_TYPEMISMATCH
;
5324 else if (rightvt
== VT_VARIANT
&& (leftvt
== VT_EMPTY
||
5325 leftvt
== VT_NULL
|| leftvt
== VT_I2
||
5326 leftvt
== VT_I4
|| leftvt
== VT_R4
||
5327 leftvt
== VT_R8
|| leftvt
== VT_CY
||
5328 leftvt
== VT_DATE
|| leftvt
== VT_BSTR
||
5329 leftvt
== VT_BOOL
|| leftvt
== VT_DECIMAL
||
5330 leftvt
== VT_I1
|| leftvt
== VT_UI1
||
5331 leftvt
== VT_UI2
|| leftvt
== VT_UI4
||
5332 leftvt
== VT_I8
|| leftvt
== VT_UI8
||
5333 leftvt
== VT_INT
|| leftvt
== VT_UINT
5335 expected_error_num
= DISP_E_TYPEMISMATCH
;
5337 expected_error_num
= DISP_E_BADVARTYPE
;
5339 V_VT(&left
) = leftvt
;
5340 V_VT(&right
) = rightvt
;
5344 V_BSTR(&left
) = SysAllocString(sz_empty
); break;
5346 V_DATE(&left
) = 0.0; break;
5348 VarDecFromR8(0.0, &V_DECIMAL(&left
)); break;
5355 V_BSTR(&right
) = SysAllocString(sz_empty
); break;
5357 V_DATE(&right
) = 0.0; break;
5359 VarDecFromR8(0.0, &V_DECIMAL(&right
)); break;
5364 hres
= VarCat(&left
, &right
, &result
);
5366 /* Determine the error code for the vt combination */
5367 ok(hres
== expected_error_num
,
5368 "VarCat: %d, %d returned error, 0x%X expected 0x%X.\n",
5369 leftvt
, rightvt
, expected_error_num
, hres
);
5371 /* Check types are correct */
5372 ok(V_VT(&result
) == resultvt
,
5373 "VarCat: %d, %d: expected vt %d, got vt %d\n",
5374 leftvt
, rightvt
, resultvt
, V_VT(&result
));
5376 VariantClear(&left
);
5377 VariantClear(&right
);
5378 VariantClear(&result
);
5382 /* Running single comparison tests to compare outputs */
5384 /* Test concat strings */
5385 V_VT(&left
) = VT_BSTR
;
5386 V_VT(&right
) = VT_BSTR
;
5387 V_VT(&expected
) = VT_BSTR
;
5388 V_BSTR(&left
) = SysAllocString(sz12
);
5389 V_BSTR(&right
) = SysAllocString(sz34
);
5390 V_BSTR(&expected
) = SysAllocString(sz1234
);
5391 hres
= VarCat(&left
,&right
,&result
);
5392 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5393 ok(VarCmp(&result
,&expected
,lcid
,0) == VARCMP_EQ
,
5394 "VarCat: VT_BSTR concat with VT_BSTR failed to return correct result\n");
5396 VariantClear(&left
);
5397 VariantClear(&right
);
5398 VariantClear(&result
);
5400 /* Test if expression is VT_ERROR */
5401 V_VT(&left
) = VT_ERROR
;
5402 V_VT(&right
) = VT_BSTR
;
5403 V_BSTR(&right
) = SysAllocString(sz1234
);
5404 hres
= VarCat(&left
,&right
,&result
);
5405 ok(hres
== DISP_E_TYPEMISMATCH
, "VarCat should have returned DISP_E_TYPEMISMATCH instead of 0x%08x\n", hres
);
5406 ok(V_VT(&result
) == VT_EMPTY
,
5407 "VarCat: VT_ERROR concat with VT_BSTR should have returned VT_EMPTY\n");
5409 VariantClear(&left
);
5410 VariantClear(&right
);
5411 VariantClear(&result
);
5413 V_VT(&left
) = VT_BSTR
;
5414 V_VT(&right
) = VT_ERROR
;
5415 V_BSTR(&left
) = SysAllocString(sz1234
);
5416 hres
= VarCat(&left
,&right
,&result
);
5417 ok(hres
== DISP_E_TYPEMISMATCH
, "VarCat should have returned DISP_E_TYPEMISMATCH instead of 0x%08x\n", hres
);
5418 ok(V_VT(&result
) == VT_EMPTY
,
5419 "VarCat: VT_BSTR concat with VT_ERROR should have returned VT_EMPTY\n");
5421 VariantClear(&left
);
5422 VariantClear(&right
);
5423 VariantClear(&result
);
5424 VariantClear(&expected
);
5426 /* Test combining boolean with number */
5427 V_VT(&left
) = VT_INT
;
5428 V_VT(&right
) = VT_BOOL
;
5429 V_VT(&expected
) = VT_BSTR
;
5431 V_BOOL(&right
) = TRUE
;
5432 V_BSTR(&expected
) = SysAllocString(sz12_true
);
5433 hres
= VarCat(&left
,&right
,&result
);
5434 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5435 hres
= VarCmp(&result
,&expected
,lcid
,0);
5436 ok(hres
== VARCMP_EQ
, "Expected VARCMP_EQ, got %08x for %s, %s\n",
5437 hres
, variantstr(&result
), variantstr(&expected
));
5439 VariantClear(&left
);
5440 VariantClear(&right
);
5441 VariantClear(&result
);
5442 VariantClear(&expected
);
5444 V_VT(&left
) = VT_INT
;
5445 V_VT(&right
) = VT_BOOL
;
5446 V_VT(&expected
) = VT_BSTR
;
5448 V_BOOL(&right
) = FALSE
;
5449 V_BSTR(&expected
) = SysAllocString(sz12_false
);
5450 hres
= VarCat(&left
,&right
,&result
);
5451 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5452 hres
= VarCmp(&result
,&expected
,lcid
,0);
5453 ok(hres
== VARCMP_EQ
, "Expected VARCMP_EQ, got %08x for %s, %s\n",
5454 hres
, variantstr(&result
), variantstr(&expected
));
5456 VariantClear(&left
);
5457 VariantClear(&right
);
5458 VariantClear(&result
);
5459 VariantClear(&expected
);
5461 /* Test when both expressions are numeric */
5462 V_VT(&left
) = VT_INT
;
5463 V_VT(&right
) = VT_INT
;
5464 V_VT(&expected
) = VT_BSTR
;
5467 V_BSTR(&expected
) = SysAllocString(sz1234
);
5468 hres
= VarCat(&left
,&right
,&result
);
5469 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5470 ok(VarCmp(&result
,&expected
,lcid
,0) == VARCMP_EQ
,
5471 "VarCat: NUMBER concat with NUMBER returned incorrect result\n");
5473 VariantClear(&left
);
5474 VariantClear(&right
);
5475 VariantClear(&result
);
5477 /* Test if one expression is numeric and the other is a string */
5478 V_VT(&left
) = VT_INT
;
5479 V_VT(&right
) = VT_BSTR
;
5481 V_BSTR(&right
) = SysAllocString(sz34
);
5482 hres
= VarCat(&left
,&right
,&result
);
5483 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5484 ok(VarCmp(&result
,&expected
,lcid
,0) == VARCMP_EQ
,
5485 "VarCat: NUMBER concat with VT_BSTR, incorrect result\n");
5487 VariantClear(&left
);
5488 VariantClear(&right
);
5489 VariantClear(&result
);
5491 V_VT(&left
) = VT_BSTR
;
5492 V_VT(&right
) = VT_INT
;
5493 V_BSTR(&left
) = SysAllocString(sz12
);
5495 hres
= VarCat(&left
,&right
,&result
);
5496 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5497 ok(VarCmp(&result
,&expected
,lcid
,0) == VARCMP_EQ
,
5498 "VarCat: VT_BSTR concat with NUMBER, incorrect result\n");
5500 VariantClear(&left
);
5501 VariantClear(&right
);
5502 VariantClear(&result
);
5503 VariantClear(&expected
);
5505 /* Test concat dates with strings */
5506 V_VT(&left
) = VT_BSTR
;
5507 V_VT(&right
) = VT_DATE
;
5508 V_VT(&expected
) = VT_BSTR
;
5509 V_BSTR(&left
) = SysAllocString(sz12
);
5510 V_DATE(&right
) = 29494.0;
5511 V_BSTR(&expected
)= SysAllocString(sz12_date
);
5512 hres
= VarCat(&left
,&right
,&result
);
5513 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5514 ok(VarCmp(&result
,&expected
,lcid
,0) == VARCMP_EQ
,
5515 "VarCat: VT_BSTR concat with VT_DATE returned incorrect result\n");
5517 VariantClear(&left
);
5518 VariantClear(&right
);
5519 VariantClear(&result
);
5520 VariantClear(&expected
);
5522 V_VT(&left
) = VT_DATE
;
5523 V_VT(&right
) = VT_BSTR
;
5524 V_VT(&expected
) = VT_BSTR
;
5525 V_DATE(&left
) = 29494.0;
5526 V_BSTR(&right
) = SysAllocString(sz12
);
5527 V_BSTR(&expected
)= SysAllocString(date_sz12
);
5528 hres
= VarCat(&left
,&right
,&result
);
5529 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5530 ok(VarCmp(&result
,&expected
,lcid
,0) == VARCMP_EQ
,
5531 "VarCat: VT_DATE concat with VT_BSTR returned incorrect result\n");
5533 VariantClear(&left
);
5534 VariantClear(&right
);
5535 VariantClear(&result
);
5536 VariantClear(&expected
);
5538 /* Test of both expressions are empty */
5539 V_VT(&left
) = VT_BSTR
;
5540 V_VT(&right
) = VT_BSTR
;
5541 V_VT(&expected
) = VT_BSTR
;
5542 V_BSTR(&left
) = SysAllocString(sz_empty
);
5543 V_BSTR(&right
) = SysAllocString(sz_empty
);
5544 V_BSTR(&expected
)= SysAllocString(sz_empty
);
5545 hres
= VarCat(&left
,&right
,&result
);
5546 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5547 ok(VarCmp(&result
,&left
,lcid
,0) == VARCMP_EQ
,
5548 "VarCat: EMPTY concat with EMPTY did not return empty VT_BSTR\n");
5550 /* Restore original date format settings */
5551 SetLocaleInfo(lcid
,LOCALE_SSHORTDATE
,orig_date_format
);
5553 VariantClear(&left
);
5554 VariantClear(&right
);
5555 VariantClear(&result
);
5556 VariantClear(&expected
);
5559 static HRESULT (WINAPI
*pVarAnd
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
5561 #define VARAND(vt1,val1,vt2,val2,rvt,rval) \
5562 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
5563 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
5564 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
5565 test_var_call2( __LINE__, pVarAnd, &left, &right, &exp )
5567 #define VARANDCY(vt1,val1,val2,rvt,rval) \
5568 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
5569 V_VT(&right) = VT_CY; V_CY(&right).int64 = val2; \
5570 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
5571 test_var_call2( __LINE__, pVarAnd, &left, &right, &exp )
5573 /* Skip any type that is not defined or produces an error for every case */
5574 #define SKIPTESTAND(a) \
5575 if (a == VT_ERROR || a == VT_VARIANT || \
5576 a == VT_DISPATCH || a == VT_UNKNOWN || \
5577 a > VT_UINT || a == 15 /*not defined*/) \
5580 static void test_VarAnd(void)
5582 static const WCHAR szFalse
[] = { '#','F','A','L','S','E','#','\0' };
5583 static const WCHAR szTrue
[] = { '#','T','R','U','E','#','\0' };
5584 VARIANT left
, right
, exp
, result
;
5585 BSTR false_str
, true_str
;
5589 true_str
= SysAllocString(szTrue
);
5590 false_str
= SysAllocString(szFalse
);
5594 /* Test all possible flag/vt combinations & the resulting vt type */
5595 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
5597 VARTYPE leftvt
, rightvt
, resvt
;
5599 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
5601 SKIPTESTAND(leftvt
);
5603 /* Check if we need/have support for I8 and/or UI8 */
5604 if ((leftvt
== VT_I8
|| leftvt
== VT_UI8
) && !HAVE_OLEAUT32_I8
)
5607 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
5610 SKIPTESTAND(rightvt
);
5612 /* Check if we need/have support for I8 and/or UI8 */
5613 if ((rightvt
== VT_I8
|| rightvt
== VT_UI8
) && !HAVE_OLEAUT32_I8
)
5616 memset(&left
, 0, sizeof(left
));
5617 memset(&right
, 0, sizeof(right
));
5618 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
5619 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
5620 V_VT(&result
) = VT_EMPTY
;
5622 if ((leftvt
| ExtraFlags
[i
]) == VT_BSTR
)
5623 V_BSTR(&left
) = true_str
;
5624 if ((rightvt
| ExtraFlags
[i
]) == VT_BSTR
)
5625 V_BSTR(&right
) = true_str
;
5627 /* Native VarAnd always returns an error when using extra
5628 * flags or if the variant combination is I8 and INT.
5630 if ((leftvt
== VT_I8
&& rightvt
== VT_INT
) ||
5631 (leftvt
== VT_INT
&& rightvt
== VT_I8
) ||
5635 /* Determine return type */
5636 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
5638 else if (leftvt
== VT_I4
|| rightvt
== VT_I4
||
5639 leftvt
== VT_UINT
|| rightvt
== VT_UINT
||
5640 leftvt
== VT_INT
|| rightvt
== VT_INT
||
5641 leftvt
== VT_UINT
|| rightvt
== VT_UINT
||
5642 leftvt
== VT_R4
|| rightvt
== VT_R4
||
5643 leftvt
== VT_R8
|| rightvt
== VT_R8
||
5644 leftvt
== VT_CY
|| rightvt
== VT_CY
||
5645 leftvt
== VT_DATE
|| rightvt
== VT_DATE
||
5646 leftvt
== VT_I1
|| rightvt
== VT_I1
||
5647 leftvt
== VT_UI2
|| rightvt
== VT_UI2
||
5648 leftvt
== VT_UI4
|| rightvt
== VT_UI4
||
5649 leftvt
== VT_UI8
|| rightvt
== VT_UI8
||
5650 leftvt
== VT_DECIMAL
|| rightvt
== VT_DECIMAL
)
5652 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
||
5653 leftvt
== VT_I2
|| rightvt
== VT_I2
||
5654 leftvt
== VT_EMPTY
|| rightvt
== VT_EMPTY
)
5655 if ((leftvt
== VT_NULL
&& rightvt
== VT_UI1
) ||
5656 (leftvt
== VT_UI1
&& rightvt
== VT_NULL
) ||
5657 (leftvt
== VT_UI1
&& rightvt
== VT_UI1
))
5661 else if (leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
||
5662 (leftvt
== VT_BSTR
&& rightvt
== VT_BSTR
))
5664 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
||
5665 leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
)
5670 hres
= pVarAnd(&left
, &right
, &result
);
5672 /* Check expected HRESULT and if result variant type is correct */
5674 ok (hres
== DISP_E_BADVARTYPE
|| hres
== DISP_E_TYPEMISMATCH
,
5675 "VarAnd: %s|0x%X, %s|0x%X: got vt %s hr 0x%X\n",
5676 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
],
5677 vtstr(V_VT(&result
)), hres
);
5679 ok (hres
== S_OK
&& resvt
== V_VT(&result
),
5680 "VarAnd: %s|0x%X, %s|0x%X: expected vt %s hr 0x%X, got vt %s hr 0x%X\n",
5681 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
], vtstr(resvt
),
5682 S_OK
, vtstr(V_VT(&result
)), hres
);
5688 * Test returned values. Since we know the returned type is correct
5689 * and that we handle all combinations of invalid types, just check
5690 * that good type combinations produce the desired value.
5691 * FIXME: Test VT_DECIMAL
5693 VARAND(EMPTY
,0,EMPTY
,0,I2
,0);
5694 VARAND(EMPTY
,1,EMPTY
,0,I2
,0);
5695 VARAND(EMPTY
,1,EMPTY
,1,I2
,0);
5696 VARAND(EMPTY
,0,NULL
,0,I2
,0);
5697 VARAND(EMPTY
,1,NULL
,0,I2
,0);
5698 VARAND(EMPTY
,1,NULL
,1,I2
,0);
5699 VARAND(EMPTY
,0,I1
,0,I4
,0);
5700 VARAND(EMPTY
,0,I1
,1,I4
,0);
5701 VARAND(EMPTY
,1,I1
,1,I4
,0);
5702 VARAND(EMPTY
,0,UI1
,0,I2
,0);
5703 VARAND(EMPTY
,0,UI1
,1,I2
,0);
5704 VARAND(EMPTY
,1,UI1
,1,I2
,0);
5705 VARAND(EMPTY
,0,I2
,0,I2
,0);
5706 VARAND(EMPTY
,0,I2
,1,I2
,0);
5707 VARAND(EMPTY
,1,I2
,1,I2
,0);
5708 VARAND(EMPTY
,0,UI2
,0,I4
,0);
5709 VARAND(EMPTY
,0,UI2
,1,I4
,0);
5710 VARAND(EMPTY
,1,UI2
,1,I4
,0);
5711 VARAND(EMPTY
,0,I4
,0,I4
,0);
5712 VARAND(EMPTY
,0,I4
,1,I4
,0);
5713 VARAND(EMPTY
,1,I4
,1,I4
,0);
5714 VARAND(EMPTY
,0,UI4
,0,I4
,0);
5715 VARAND(EMPTY
,0,UI4
,1,I4
,0);
5716 VARAND(EMPTY
,1,UI4
,1,I4
,0);
5717 if (HAVE_OLEAUT32_I8
)
5719 VARAND(EMPTY
,0,I8
,0,I8
,0);
5720 VARAND(EMPTY
,0,I8
,1,I8
,0);
5721 VARAND(EMPTY
,1,I8
,1,I8
,0);
5722 VARAND(EMPTY
,0,UI8
,0,I4
,0);
5723 VARAND(EMPTY
,0,UI8
,1,I4
,0);
5724 VARAND(EMPTY
,1,UI8
,1,I4
,0);
5726 VARAND(EMPTY
,0,INT
,0,I4
,0);
5727 VARAND(EMPTY
,0,INT
,1,I4
,0);
5728 VARAND(EMPTY
,1,INT
,1,I4
,0);
5729 VARAND(EMPTY
,0,UINT
,0,I4
,0);
5730 VARAND(EMPTY
,0,UINT
,1,I4
,0);
5731 VARAND(EMPTY
,1,UINT
,1,I4
,0);
5732 VARAND(EMPTY
,0,BOOL
,0,I2
,0);
5733 VARAND(EMPTY
,0,BOOL
,1,I2
,0);
5734 VARAND(EMPTY
,1,BOOL
,1,I2
,0);
5735 VARAND(EMPTY
,0,R4
,0,I4
,0);
5736 VARAND(EMPTY
,0,R4
,1,I4
,0);
5737 VARAND(EMPTY
,1,R4
,1,I4
,0);
5738 VARAND(EMPTY
,0,R8
,0,I4
,0);
5739 VARAND(EMPTY
,0,R8
,1,I4
,0);
5740 VARAND(EMPTY
,1,R8
,1,I4
,0);
5741 VARAND(EMPTY
,0,BSTR
,false_str
,I2
,0);
5742 VARAND(EMPTY
,0,BSTR
,true_str
,I2
,0);
5743 VARANDCY(EMPTY
,0,10000,I4
,0);
5745 /* NULL OR 0 = NULL. NULL OR n = n */
5746 VARAND(NULL
,0,NULL
,0,NULL
,0);
5747 VARAND(NULL
,1,NULL
,0,NULL
,0);
5748 VARAND(NULL
,0,I1
,0,I4
,0);
5749 VARAND(NULL
,0,I1
,1,NULL
,0);
5750 VARAND(NULL
,0,UI1
,0,UI1
,0);
5751 VARAND(NULL
,0,UI1
,1,NULL
,0);
5752 VARAND(NULL
,0,I2
,0,I2
,0);
5753 VARAND(NULL
,0,I2
,1,NULL
,0);
5754 VARAND(NULL
,0,UI2
,0,I4
,0);
5755 VARAND(NULL
,0,UI2
,1,NULL
,0);
5756 VARAND(NULL
,0,I4
,0,I4
,0);
5757 VARAND(NULL
,0,I4
,1,NULL
,0);
5758 VARAND(NULL
,0,UI4
,0,I4
,0);
5759 VARAND(NULL
,0,UI4
,1,NULL
,0);
5760 if (HAVE_OLEAUT32_I8
)
5762 VARAND(NULL
,0,I8
,0,I8
,0);
5763 VARAND(NULL
,0,I8
,1,NULL
,0);
5764 VARAND(NULL
,0,UI8
,0,I4
,0);
5765 VARAND(NULL
,0,UI8
,1,NULL
,0);
5767 VARAND(NULL
,0,INT
,0,I4
,0);
5768 VARAND(NULL
,0,INT
,1,NULL
,0);
5769 VARAND(NULL
,0,UINT
,0,I4
,0);
5770 VARAND(NULL
,0,UINT
,1,NULL
,0);
5771 VARAND(NULL
,0,BOOL
,0,BOOL
,0);
5772 VARAND(NULL
,0,BOOL
,1,NULL
,0);
5773 VARAND(NULL
,0,R4
,0,I4
,0);
5774 VARAND(NULL
,0,R4
,1,NULL
,0);
5775 VARAND(NULL
,0,R8
,0,I4
,0);
5776 VARAND(NULL
,0,R8
,1,NULL
,0);
5777 VARAND(NULL
,0,BSTR
,false_str
,BOOL
,0);
5778 VARAND(NULL
,0,BSTR
,true_str
,NULL
,VARIANT_FALSE
);
5779 VARANDCY(NULL
,0,10000,NULL
,0);
5780 VARANDCY(NULL
,0,0,I4
,0);
5781 VARAND(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
);
5782 VARAND(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_FALSE
);
5783 VARAND(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
);
5784 VARAND(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_FALSE
);
5786 /* Assume x,y & y,x are the same from now on to reduce the number of tests */
5787 VARAND(BOOL
,VARIANT_TRUE
,I1
,-1,I4
,-1);
5788 VARAND(BOOL
,VARIANT_TRUE
,I1
,0,I4
,0);
5789 VARAND(BOOL
,VARIANT_FALSE
,I1
,0,I4
,0);
5790 VARAND(BOOL
,VARIANT_TRUE
,UI1
,255,I2
,255);
5791 VARAND(BOOL
,VARIANT_TRUE
,UI1
,0,I2
,0);
5792 VARAND(BOOL
,VARIANT_FALSE
,UI1
,0,I2
,0);
5793 VARAND(BOOL
,VARIANT_TRUE
,I2
,-1,I2
,-1);
5794 VARAND(BOOL
,VARIANT_TRUE
,I2
,0,I2
,0);
5795 VARAND(BOOL
,VARIANT_FALSE
,I2
,0,I2
,0);
5796 VARAND(BOOL
,VARIANT_TRUE
,UI2
,65535,I4
,65535);
5797 VARAND(BOOL
,VARIANT_TRUE
,UI2
,0,I4
,0);
5798 VARAND(BOOL
,VARIANT_FALSE
,UI2
,0,I4
,0);
5799 VARAND(BOOL
,VARIANT_TRUE
,I4
,-1,I4
,-1);
5800 VARAND(BOOL
,VARIANT_TRUE
,I4
,0,I4
,0);
5801 VARAND(BOOL
,VARIANT_FALSE
,I4
,0,I4
,0);
5802 VARAND(BOOL
,VARIANT_TRUE
,UI4
,0xffffffff,I4
,-1);
5803 VARAND(BOOL
,VARIANT_TRUE
,UI4
,0,I4
,0);
5804 VARAND(BOOL
,VARIANT_FALSE
,UI4
,0,I4
,0);
5805 VARAND(BOOL
,VARIANT_TRUE
,R4
,-1,I4
,-1);
5806 VARAND(BOOL
,VARIANT_TRUE
,R4
,0,I4
,0);
5807 VARAND(BOOL
,VARIANT_FALSE
,R4
,0,I4
,0);
5808 VARAND(BOOL
,VARIANT_TRUE
,R8
,-1,I4
,-1);
5809 VARAND(BOOL
,VARIANT_TRUE
,R8
,0,I4
,0);
5810 VARAND(BOOL
,VARIANT_FALSE
,R8
,0,I4
,0);
5811 VARAND(BOOL
,VARIANT_TRUE
,DATE
,-1,I4
,-1);
5812 VARAND(BOOL
,VARIANT_TRUE
,DATE
,0,I4
,0);
5813 VARAND(BOOL
,VARIANT_FALSE
,DATE
,0,I4
,0);
5814 if (HAVE_OLEAUT32_I8
)
5816 VARAND(BOOL
,VARIANT_TRUE
,I8
,-1,I8
,-1);
5817 VARAND(BOOL
,VARIANT_TRUE
,I8
,0,I8
,0);
5818 VARAND(BOOL
,VARIANT_FALSE
,I8
,0,I8
,0);
5819 VARAND(BOOL
,VARIANT_TRUE
,UI8
,0,I4
,0);
5820 VARAND(BOOL
,VARIANT_FALSE
,UI8
,0,I4
,0);
5822 VARAND(BOOL
,VARIANT_TRUE
,INT
,-1,I4
,-1);
5823 VARAND(BOOL
,VARIANT_TRUE
,INT
,0,I4
,0);
5824 VARAND(BOOL
,VARIANT_FALSE
,INT
,0,I4
,0);
5825 VARAND(BOOL
,VARIANT_TRUE
,UINT
,0xffffffff,I4
,-1);
5826 VARAND(BOOL
,VARIANT_TRUE
,UINT
,0,I4
,0);
5827 VARAND(BOOL
,VARIANT_FALSE
,UINT
,0,I4
,0);
5828 VARAND(BOOL
,VARIANT_FALSE
,BSTR
,false_str
,BOOL
,VARIANT_FALSE
);
5829 VARAND(BOOL
,VARIANT_TRUE
,BSTR
,false_str
,BOOL
,VARIANT_FALSE
);
5830 VARAND(BOOL
,VARIANT_FALSE
,BSTR
,true_str
,BOOL
,VARIANT_FALSE
);
5831 VARAND(BOOL
,VARIANT_TRUE
,BSTR
,true_str
,BOOL
,VARIANT_TRUE
);
5832 VARANDCY(BOOL
,VARIANT_TRUE
,10000,I4
,1);
5833 VARANDCY(BOOL
,VARIANT_TRUE
,0,I4
,0);
5834 VARANDCY(BOOL
,VARIANT_FALSE
,0,I4
,0);
5835 VARAND(I1
,-1,I1
,-1,I4
,-1);
5836 VARAND(I1
,-1,I1
,0,I4
,0);
5837 VARAND(I1
,0,I1
,0,I4
,0);
5838 VARAND(I1
,-1,UI1
,255,I4
,255);
5839 VARAND(I1
,-1,UI1
,0,I4
,0);
5840 VARAND(I1
,0,UI1
,0,I4
,0);
5841 VARAND(I1
,-1,I2
,-1,I4
,-1);
5842 VARAND(I1
,-1,I2
,0,I4
,0);
5843 VARAND(I1
,0,I2
,0,I4
,0);
5844 VARAND(I1
,-1,UI2
,65535,I4
,65535);
5845 VARAND(I1
,-1,UI2
,0,I4
,0);
5846 VARAND(I1
,0,UI2
,0,I4
,0);
5847 VARAND(I1
,-1,I4
,-1,I4
,-1);
5848 VARAND(I1
,-1,I4
,0,I4
,0);
5849 VARAND(I1
,0,I4
,0,I4
,0);
5850 VARAND(I1
,-1,UI4
,0xffffffff,I4
,-1);
5851 VARAND(I1
,-1,UI4
,0,I4
,0);
5852 VARAND(I1
,0,UI4
,0,I4
,0);
5853 VARAND(I1
,-1,R4
,-1,I4
,-1);
5854 VARAND(I1
,-1,R4
,0,I4
,0);
5855 VARAND(I1
,0,R4
,0,I4
,0);
5856 VARAND(I1
,-1,R8
,-1,I4
,-1);
5857 VARAND(I1
,-1,R8
,0,I4
,0);
5858 VARAND(I1
,0,R8
,0,I4
,0);
5859 VARAND(I1
,-1,DATE
,-1,I4
,-1);
5860 VARAND(I1
,-1,DATE
,0,I4
,0);
5861 VARAND(I1
,0,DATE
,0,I4
,0);
5862 if (HAVE_OLEAUT32_I8
)
5864 VARAND(I1
,-1,I8
,-1,I8
,-1);
5865 VARAND(I1
,-1,I8
,0,I8
,0);
5866 VARAND(I1
,0,I8
,0,I8
,0);
5867 VARAND(I1
,-1,UI8
,0,I4
,0);
5868 VARAND(I1
,0,UI8
,0,I4
,0);
5870 VARAND(I1
,-1,INT
,-1,I4
,-1);
5871 VARAND(I1
,-1,INT
,0,I4
,0);
5872 VARAND(I1
,0,INT
,0,I4
,0);
5873 VARAND(I1
,-1,UINT
,0xffffffff,I4
,-1);
5874 VARAND(I1
,-1,UINT
,0,I4
,0);
5875 VARAND(I1
,0,UINT
,0,I4
,0);
5876 VARAND(I1
,0,BSTR
,false_str
,I4
,0);
5877 VARAND(I1
,-1,BSTR
,false_str
,I4
,0);
5878 VARAND(I1
,0,BSTR
,true_str
,I4
,0);
5879 VARAND(I1
,-1,BSTR
,true_str
,I4
,-1);
5880 VARANDCY(I1
,-1,10000,I4
,1);
5881 VARANDCY(I1
,-1,0,I4
,0);
5882 VARANDCY(I1
,0,0,I4
,0);
5884 VARAND(UI1
,255,UI1
,255,UI1
,255);
5885 VARAND(UI1
,255,UI1
,0,UI1
,0);
5886 VARAND(UI1
,0,UI1
,0,UI1
,0);
5887 VARAND(UI1
,255,I2
,-1,I2
,255);
5888 VARAND(UI1
,255,I2
,0,I2
,0);
5889 VARAND(UI1
,0,I2
,0,I2
,0);
5890 VARAND(UI1
,255,UI2
,65535,I4
,255);
5891 VARAND(UI1
,255,UI2
,0,I4
,0);
5892 VARAND(UI1
,0,UI2
,0,I4
,0);
5893 VARAND(UI1
,255,I4
,-1,I4
,255);
5894 VARAND(UI1
,255,I4
,0,I4
,0);
5895 VARAND(UI1
,0,I4
,0,I4
,0);
5896 VARAND(UI1
,255,UI4
,0xffffffff,I4
,255);
5897 VARAND(UI1
,255,UI4
,0,I4
,0);
5898 VARAND(UI1
,0,UI4
,0,I4
,0);
5899 VARAND(UI1
,255,R4
,-1,I4
,255);
5900 VARAND(UI1
,255,R4
,0,I4
,0);
5901 VARAND(UI1
,0,R4
,0,I4
,0);
5902 VARAND(UI1
,255,R8
,-1,I4
,255);
5903 VARAND(UI1
,255,R8
,0,I4
,0);
5904 VARAND(UI1
,0,R8
,0,I4
,0);
5905 VARAND(UI1
,255,DATE
,-1,I4
,255);
5906 VARAND(UI1
,255,DATE
,0,I4
,0);
5907 VARAND(UI1
,0,DATE
,0,I4
,0);
5908 if (HAVE_OLEAUT32_I8
)
5910 VARAND(UI1
,255,I8
,-1,I8
,255);
5911 VARAND(UI1
,255,I8
,0,I8
,0);
5912 VARAND(UI1
,0,I8
,0,I8
,0);
5913 VARAND(UI1
,255,UI8
,0,I4
,0);
5914 VARAND(UI1
,0,UI8
,0,I4
,0);
5916 VARAND(UI1
,255,INT
,-1,I4
,255);
5917 VARAND(UI1
,255,INT
,0,I4
,0);
5918 VARAND(UI1
,0,INT
,0,I4
,0);
5919 VARAND(UI1
,255,UINT
,0xffffffff,I4
,255);
5920 VARAND(UI1
,255,UINT
,0,I4
,0);
5921 VARAND(UI1
,0,UINT
,0,I4
,0);
5922 VARAND(UI1
,0,BSTR
,false_str
,I2
,0);
5923 VARAND(UI1
,255,BSTR
,false_str
,I2
,0);
5924 VARAND(UI1
,0,BSTR
,true_str
,I2
,0);
5925 VARAND(UI1
,255,BSTR
,true_str
,I2
,255);
5926 VARANDCY(UI1
,255,10000,I4
,1);
5927 VARANDCY(UI1
,255,0,I4
,0);
5928 VARANDCY(UI1
,0,0,I4
,0);
5930 VARAND(I2
,-1,I2
,-1,I2
,-1);
5931 VARAND(I2
,-1,I2
,0,I2
,0);
5932 VARAND(I2
,0,I2
,0,I2
,0);
5933 VARAND(I2
,-1,UI2
,65535,I4
,65535);
5934 VARAND(I2
,-1,UI2
,0,I4
,0);
5935 VARAND(I2
,0,UI2
,0,I4
,0);
5936 VARAND(I2
,-1,I4
,-1,I4
,-1);
5937 VARAND(I2
,-1,I4
,0,I4
,0);
5938 VARAND(I2
,0,I4
,0,I4
,0);
5939 VARAND(I2
,-1,UI4
,0xffffffff,I4
,-1);
5940 VARAND(I2
,-1,UI4
,0,I4
,0);
5941 VARAND(I2
,0,UI4
,0,I4
,0);
5942 VARAND(I2
,-1,R4
,-1,I4
,-1);
5943 VARAND(I2
,-1,R4
,0,I4
,0);
5944 VARAND(I2
,0,R4
,0,I4
,0);
5945 VARAND(I2
,-1,R8
,-1,I4
,-1);
5946 VARAND(I2
,-1,R8
,0,I4
,0);
5947 VARAND(I2
,0,R8
,0,I4
,0);
5948 VARAND(I2
,-1,DATE
,-1,I4
,-1);
5949 VARAND(I2
,-1,DATE
,0,I4
,0);
5950 VARAND(I2
,0,DATE
,0,I4
,0);
5951 if (HAVE_OLEAUT32_I8
)
5953 VARAND(I2
,-1,I8
,-1,I8
,-1);
5954 VARAND(I2
,-1,I8
,0,I8
,0);
5955 VARAND(I2
,0,I8
,0,I8
,0);
5956 VARAND(I2
,-1,UI8
,0,I4
,0);
5957 VARAND(I2
,0,UI8
,0,I4
,0);
5959 VARAND(I2
,-1,INT
,-1,I4
,-1);
5960 VARAND(I2
,-1,INT
,0,I4
,0);
5961 VARAND(I2
,0,INT
,0,I4
,0);
5962 VARAND(I2
,-1,UINT
,0xffffffff,I4
,-1);
5963 VARAND(I2
,-1,UINT
,0,I4
,0);
5964 VARAND(I2
,0,UINT
,0,I4
,0);
5965 VARAND(I2
,0,BSTR
,false_str
,I2
,0);
5966 VARAND(I2
,-1,BSTR
,false_str
,I2
,0);
5967 VARAND(I2
,0,BSTR
,true_str
,I2
,0);
5968 VARAND(I2
,-1,BSTR
,true_str
,I2
,-1);
5969 VARANDCY(I2
,-1,10000,I4
,1);
5970 VARANDCY(I2
,-1,0,I4
,0);
5971 VARANDCY(I2
,0,0,I4
,0);
5973 VARAND(UI2
,65535,UI2
,65535,I4
,65535);
5974 VARAND(UI2
,65535,UI2
,0,I4
,0);
5975 VARAND(UI2
,0,UI2
,0,I4
,0);
5976 VARAND(UI2
,65535,I4
,-1,I4
,65535);
5977 VARAND(UI2
,65535,I4
,0,I4
,0);
5978 VARAND(UI2
,0,I4
,0,I4
,0);
5979 VARAND(UI2
,65535,UI4
,0xffffffff,I4
,65535);
5980 VARAND(UI2
,65535,UI4
,0,I4
,0);
5981 VARAND(UI2
,0,UI4
,0,I4
,0);
5982 VARAND(UI2
,65535,R4
,-1,I4
,65535);
5983 VARAND(UI2
,65535,R4
,0,I4
,0);
5984 VARAND(UI2
,0,R4
,0,I4
,0);
5985 VARAND(UI2
,65535,R8
,-1,I4
,65535);
5986 VARAND(UI2
,65535,R8
,0,I4
,0);
5987 VARAND(UI2
,0,R8
,0,I4
,0);
5988 VARAND(UI2
,65535,DATE
,-1,I4
,65535);
5989 VARAND(UI2
,65535,DATE
,0,I4
,0);
5990 VARAND(UI2
,0,DATE
,0,I4
,0);
5991 if (HAVE_OLEAUT32_I8
)
5993 VARAND(UI2
,65535,I8
,-1,I8
,65535);
5994 VARAND(UI2
,65535,I8
,0,I8
,0);
5995 VARAND(UI2
,0,I8
,0,I8
,0);
5996 VARAND(UI2
,65535,UI8
,0,I4
,0);
5997 VARAND(UI2
,0,UI8
,0,I4
,0);
5999 VARAND(UI2
,65535,INT
,-1,I4
,65535);
6000 VARAND(UI2
,65535,INT
,0,I4
,0);
6001 VARAND(UI2
,0,INT
,0,I4
,0);
6002 VARAND(UI2
,65535,UINT
,0xffffffff,I4
,65535);
6003 VARAND(UI2
,65535,UINT
,0,I4
,0);
6004 VARAND(UI2
,0,UINT
,0,I4
,0);
6005 VARAND(UI2
,0,BSTR
,false_str
,I4
,0);
6006 VARAND(UI2
,65535,BSTR
,false_str
,I4
,0);
6007 VARAND(UI2
,0,BSTR
,true_str
,I4
,0);
6008 VARAND(UI2
,65535,BSTR
,true_str
,I4
,65535);
6009 VARANDCY(UI2
,65535,10000,I4
,1);
6010 VARANDCY(UI2
,65535,0,I4
,0);
6011 VARANDCY(UI2
,0,0,I4
,0);
6013 VARAND(I4
,-1,I4
,-1,I4
,-1);
6014 VARAND(I4
,-1,I4
,0,I4
,0);
6015 VARAND(I4
,0,I4
,0,I4
,0);
6016 VARAND(I4
,-1,UI4
,0xffffffff,I4
,-1);
6017 VARAND(I4
,-1,UI4
,0,I4
,0);
6018 VARAND(I4
,0,UI4
,0,I4
,0);
6019 VARAND(I4
,-1,R4
,-1,I4
,-1);
6020 VARAND(I4
,-1,R4
,0,I4
,0);
6021 VARAND(I4
,0,R4
,0,I4
,0);
6022 VARAND(I4
,-1,R8
,-1,I4
,-1);
6023 VARAND(I4
,-1,R8
,0,I4
,0);
6024 VARAND(I4
,0,R8
,0,I4
,0);
6025 VARAND(I4
,-1,DATE
,-1,I4
,-1);
6026 VARAND(I4
,-1,DATE
,0,I4
,0);
6027 VARAND(I4
,0,DATE
,0,I4
,0);
6028 if (HAVE_OLEAUT32_I8
)
6030 VARAND(I4
,-1,I8
,-1,I8
,-1);
6031 VARAND(I4
,-1,I8
,0,I8
,0);
6032 VARAND(I4
,0,I8
,0,I8
,0);
6033 VARAND(I4
,-1,UI8
,0,I4
,0);
6034 VARAND(I4
,0,UI8
,0,I4
,0);
6036 VARAND(I4
,-1,INT
,-1,I4
,-1);
6037 VARAND(I4
,-1,INT
,0,I4
,0);
6038 VARAND(I4
,0,INT
,0,I4
,0);
6039 VARAND(I4
,-1,UINT
,0xffffffff,I4
,-1);
6040 VARAND(I4
,-1,UINT
,0,I4
,0);
6041 VARAND(I4
,0,UINT
,0,I4
,0);
6042 VARAND(I4
,0,BSTR
,false_str
,I4
,0);
6043 VARAND(I4
,-1,BSTR
,false_str
,I4
,0);
6044 VARAND(I4
,0,BSTR
,true_str
,I4
,0);
6045 VARAND(I4
,-1,BSTR
,true_str
,I4
,-1);
6046 VARANDCY(I4
,-1,10000,I4
,1);
6047 VARANDCY(I4
,-1,0,I4
,0);
6048 VARANDCY(I4
,0,0,I4
,0);
6050 VARAND(UI4
,0xffffffff,UI4
,0xffffffff,I4
,-1);
6051 VARAND(UI4
,0xffffffff,UI4
,0,I4
,0);
6052 VARAND(UI4
,0,UI4
,0,I4
,0);
6053 VARAND(UI4
,0xffffffff,R4
,-1,I4
,-1);
6054 VARAND(UI4
,0xffffffff,R4
,0,I4
,0);
6055 VARAND(UI4
,0,R4
,0,I4
,0);
6056 VARAND(UI4
,0xffffffff,R8
,-1,I4
,-1);
6057 VARAND(UI4
,0xffffffff,R8
,0,I4
,0);
6058 VARAND(UI4
,0,R8
,0,I4
,0);
6059 VARAND(UI4
,0xffffffff,DATE
,-1,I4
,-1);
6060 VARAND(UI4
,0xffffffff,DATE
,0,I4
,0);
6061 VARAND(UI4
,0,DATE
,0,I4
,0);
6062 if (HAVE_OLEAUT32_I8
)
6064 VARAND(UI4
,0xffffffff,I8
,0,I8
,0);
6065 VARAND(UI4
,0,I8
,0,I8
,0);
6066 VARAND(UI4
,0xffffffff,UI8
,0,I4
,0);
6067 VARAND(UI4
,0,UI8
,0,I4
,0);
6069 VARAND(UI4
,0xffffffff,INT
,-1,I4
,-1);
6070 VARAND(UI4
,0xffffffff,INT
,0,I4
,0);
6071 VARAND(UI4
,0,INT
,0,I4
,0);
6072 VARAND(UI4
,0xffffffff,UINT
,0xffffffff,I4
,-1);
6073 VARAND(UI4
,0xffffffff,UINT
,0,I4
,0);
6074 VARAND(UI4
,0,UINT
,0,I4
,0);
6075 VARAND(UI4
,0,BSTR
,false_str
,I4
,0);
6076 VARAND(UI4
,0xffffffff,BSTR
,false_str
,I4
,0);
6077 VARAND(UI4
,0,BSTR
,true_str
,I4
,0);
6078 VARAND(UI4
,0xffffffff,BSTR
,true_str
,I4
,-1);
6079 VARANDCY(UI4
,0xffffffff,10000,I4
,1);
6080 VARANDCY(UI4
,0xffffffff,0,I4
,0);
6081 VARANDCY(UI4
,0,0,I4
,0);
6083 VARAND(R4
,-1,R4
,-1,I4
,-1);
6084 VARAND(R4
,-1,R4
,0,I4
,0);
6085 VARAND(R4
,0,R4
,0,I4
,0);
6086 VARAND(R4
,-1,R8
,-1,I4
,-1);
6087 VARAND(R4
,-1,R8
,0,I4
,0);
6088 VARAND(R4
,0,R8
,0,I4
,0);
6089 VARAND(R4
,-1,DATE
,-1,I4
,-1);
6090 VARAND(R4
,-1,DATE
,0,I4
,0);
6091 VARAND(R4
,0,DATE
,0,I4
,0);
6092 if (HAVE_OLEAUT32_I8
)
6094 VARAND(R4
,-1,I8
,-1,I8
,-1);
6095 VARAND(R4
,-1,I8
,0,I8
,0);
6096 VARAND(R4
,0,I8
,0,I8
,0);
6097 VARAND(R4
,-1,UI8
,0,I4
,0);
6098 VARAND(R4
,0,UI8
,0,I4
,0);
6100 VARAND(R4
,-1,INT
,-1,I4
,-1);
6101 VARAND(R4
,-1,INT
,0,I4
,0);
6102 VARAND(R4
,0,INT
,0,I4
,0);
6103 VARAND(R4
,-1,UINT
,0xffffffff,I4
,-1);
6104 VARAND(R4
,-1,UINT
,0,I4
,0);
6105 VARAND(R4
,0,UINT
,0,I4
,0);
6106 VARAND(R4
,0,BSTR
,false_str
,I4
,0);
6107 VARAND(R4
,-1,BSTR
,false_str
,I4
,0);
6108 VARAND(R4
,0,BSTR
,true_str
,I4
,0);
6109 VARAND(R4
,-1,BSTR
,true_str
,I4
,-1);
6110 VARANDCY(R4
,-1,10000,I4
,1);
6111 VARANDCY(R4
,-1,0,I4
,0);
6112 VARANDCY(R4
,0,0,I4
,0);
6114 VARAND(R8
,-1,R8
,-1,I4
,-1);
6115 VARAND(R8
,-1,R8
,0,I4
,0);
6116 VARAND(R8
,0,R8
,0,I4
,0);
6117 VARAND(R8
,-1,DATE
,-1,I4
,-1);
6118 VARAND(R8
,-1,DATE
,0,I4
,0);
6119 VARAND(R8
,0,DATE
,0,I4
,0);
6120 if (HAVE_OLEAUT32_I8
)
6122 VARAND(R8
,-1,I8
,-1,I8
,-1);
6123 VARAND(R8
,-1,I8
,0,I8
,0);
6124 VARAND(R8
,0,I8
,0,I8
,0);
6125 VARAND(R8
,-1,UI8
,0,I4
,0);
6126 VARAND(R8
,0,UI8
,0,I4
,0);
6128 VARAND(R8
,-1,INT
,-1,I4
,-1);
6129 VARAND(R8
,-1,INT
,0,I4
,0);
6130 VARAND(R8
,0,INT
,0,I4
,0);
6131 VARAND(R8
,-1,UINT
,0xffffffff,I4
,-1);
6132 VARAND(R8
,-1,UINT
,0,I4
,0);
6133 VARAND(R8
,0,UINT
,0,I4
,0);
6134 VARAND(R8
,0,BSTR
,false_str
,I4
,0);
6135 VARAND(R8
,-1,BSTR
,false_str
,I4
,0);
6136 VARAND(R8
,0,BSTR
,true_str
,I4
,0);
6137 VARAND(R8
,-1,BSTR
,true_str
,I4
,-1);
6138 VARANDCY(R8
,-1,10000,I4
,1);
6139 VARANDCY(R8
,-1,0,I4
,0);
6140 VARANDCY(R8
,0,0,I4
,0);
6142 VARAND(DATE
,-1,DATE
,-1,I4
,-1);
6143 VARAND(DATE
,-1,DATE
,0,I4
,0);
6144 VARAND(DATE
,0,DATE
,0,I4
,0);
6145 if (HAVE_OLEAUT32_I8
)
6147 VARAND(DATE
,-1,I8
,-1,I8
,-1);
6148 VARAND(DATE
,-1,I8
,0,I8
,0);
6149 VARAND(DATE
,0,I8
,0,I8
,0);
6150 VARAND(DATE
,-1,UI8
,0,I4
,0);
6151 VARAND(DATE
,0,UI8
,0,I4
,0);
6153 VARAND(DATE
,-1,INT
,-1,I4
,-1);
6154 VARAND(DATE
,-1,INT
,0,I4
,0);
6155 VARAND(DATE
,0,INT
,0,I4
,0);
6156 VARAND(DATE
,-1,UINT
,0xffffffff,I4
,-1);
6157 VARAND(DATE
,-1,UINT
,0,I4
,0);
6158 VARAND(DATE
,0,UINT
,0,I4
,0);
6159 VARAND(DATE
,0,BSTR
,false_str
,I4
,0);
6160 VARAND(DATE
,-1,BSTR
,false_str
,I4
,0);
6161 VARAND(DATE
,0,BSTR
,true_str
,I4
,0);
6162 VARAND(DATE
,-1,BSTR
,true_str
,I4
,-1);
6163 VARANDCY(DATE
,-1,10000,I4
,1);
6164 VARANDCY(DATE
,-1,0,I4
,0);
6165 VARANDCY(DATE
,0,0,I4
,0);
6167 if (HAVE_OLEAUT32_I8
)
6169 VARAND(I8
,-1,I8
,-1,I8
,-1);
6170 VARAND(I8
,-1,I8
,0,I8
,0);
6171 VARAND(I8
,0,I8
,0,I8
,0);
6172 VARAND(I8
,-1,UI8
,0,I8
,0);
6173 VARAND(I8
,0,UI8
,0,I8
,0);
6174 VARAND(I8
,-1,UINT
,0,I8
,0);
6175 VARAND(I8
,0,UINT
,0,I8
,0);
6176 VARAND(I8
,0,BSTR
,false_str
,I8
,0);
6177 VARAND(I8
,-1,BSTR
,false_str
,I8
,0);
6178 VARAND(I8
,0,BSTR
,true_str
,I8
,0);
6179 VARAND(I8
,-1,BSTR
,true_str
,I8
,-1);
6180 VARANDCY(I8
,-1,10000,I8
,1);
6181 VARANDCY(I8
,-1,0,I8
,0);
6182 VARANDCY(I8
,0,0,I8
,0);
6184 VARAND(UI8
,0xffff,UI8
,0xffff,I4
,0xffff);
6185 VARAND(UI8
,0xffff,UI8
,0,I4
,0);
6186 VARAND(UI8
,0,UI8
,0,I4
,0);
6187 VARAND(UI8
,0xffff,INT
,-1,I4
,65535);
6188 VARAND(UI8
,0xffff,INT
,0,I4
,0);
6189 VARAND(UI8
,0,INT
,0,I4
,0);
6190 VARAND(UI8
,0xffff,UINT
,0xffff,I4
,0xffff);
6191 VARAND(UI8
,0xffff,UINT
,0,I4
,0);
6192 VARAND(UI8
,0,UINT
,0,I4
,0);
6193 VARAND(UI8
,0,BSTR
,false_str
,I4
,0);
6194 VARAND(UI8
,0xffff,BSTR
,false_str
,I4
,0);
6195 VARAND(UI8
,0,BSTR
,true_str
,I4
,0);
6196 VARAND(UI8
,0xffff,BSTR
,true_str
,I4
,65535);
6197 VARANDCY(UI8
,0xffff,10000,I4
,1);
6198 VARANDCY(UI8
,0xffff,0,I4
,0);
6199 VARANDCY(UI8
,0,0,I4
,0);
6202 VARAND(INT
,-1,INT
,-1,I4
,-1);
6203 VARAND(INT
,-1,INT
,0,I4
,0);
6204 VARAND(INT
,0,INT
,0,I4
,0);
6205 VARAND(INT
,-1,UINT
,0xffff,I4
,65535);
6206 VARAND(INT
,-1,UINT
,0,I4
,0);
6207 VARAND(INT
,0,UINT
,0,I4
,0);
6208 VARAND(INT
,0,BSTR
,false_str
,I4
,0);
6209 VARAND(INT
,-1,BSTR
,false_str
,I4
,0);
6210 VARAND(INT
,0,BSTR
,true_str
,I4
,0);
6211 VARAND(INT
,-1,BSTR
,true_str
,I4
,-1);
6212 VARANDCY(INT
,-1,10000,I4
,1);
6213 VARANDCY(INT
,-1,0,I4
,0);
6214 VARANDCY(INT
,0,0,I4
,0);
6216 VARAND(UINT
,0xffff,UINT
,0xffff,I4
,0xffff);
6217 VARAND(UINT
,0xffff,UINT
,0,I4
,0);
6218 VARAND(UINT
,0,UINT
,0,I4
,0);
6219 VARAND(UINT
,0,BSTR
,false_str
,I4
,0);
6220 VARAND(UINT
,0xffff,BSTR
, false_str
,I4
,0);
6221 VARAND(UINT
,0,BSTR
,true_str
,I4
,0);
6222 VARAND(UINT
,0xffff,BSTR
,true_str
,I4
,65535);
6223 VARANDCY(UINT
,0xffff,10000,I4
,1);
6224 VARANDCY(UINT
,0xffff,0,I4
,0);
6225 VARANDCY(UINT
,0,0,I4
,0);
6227 VARAND(BSTR
,false_str
,BSTR
,false_str
,BOOL
,0);
6228 VARAND(BSTR
,true_str
,BSTR
,false_str
,BOOL
,VARIANT_FALSE
);
6229 VARAND(BSTR
,true_str
,BSTR
,true_str
,BOOL
,VARIANT_TRUE
);
6230 VARANDCY(BSTR
,true_str
,10000,I4
,1);
6231 VARANDCY(BSTR
,false_str
,10000,I4
,0);
6233 SysFreeString(true_str
);
6234 SysFreeString(false_str
);
6237 static HRESULT (WINAPI
*pVarCmp
)(LPVARIANT
,LPVARIANT
,LCID
,ULONG
);
6239 static void test_cmp( int line
, LCID lcid
, UINT flags
, VARIANT
*left
, VARIANT
*right
, HRESULT result
)
6243 hres
= pVarCmp(left
,right
,lcid
,flags
);
6244 ok_(__FILE__
,line
)(hres
== result
, "VarCmp(%s,%s): expected 0x%x, got hres=0x%x\n",
6245 variantstr(left
), variantstr(right
), result
, hres
);
6247 static void test_cmpex( int line
, LCID lcid
, VARIANT
*left
, VARIANT
*right
,
6248 HRESULT res1
, HRESULT res2
, HRESULT res3
, HRESULT res4
)
6250 test_cmp( line
, lcid
, 0, left
, right
, res1
);
6251 V_VT(left
) |= VT_RESERVED
;
6252 test_cmp( line
, lcid
, 0, left
, right
, res2
);
6253 V_VT(left
) &= ~VT_RESERVED
;
6254 V_VT(right
) |= VT_RESERVED
;
6255 test_cmp( line
, lcid
, 0, left
, right
, res3
);
6256 V_VT(left
) |= VT_RESERVED
;
6257 test_cmp( line
, lcid
, 0, left
, right
, res4
);
6258 ok_(__FILE__
,line
)(V_VT(left
) & V_VT(right
) & VT_RESERVED
, "VT_RESERVED filtered out\n");
6261 /* ERROR from wingdi.h is interfering here */
6263 #define _VARCMP(vt1,val1,vtfl1,vt2,val2,vtfl2,lcid,flags,result) \
6264 V_##vt1(&left) = val1; V_VT(&left) = VT_##vt1 | vtfl1; \
6265 V_##vt2(&right) = val2; V_VT(&right) = VT_##vt2 | vtfl2; \
6266 test_cmp( __LINE__, lcid, flags, &left, &right, result )
6267 #define VARCMPEX(vt1,val1,vt2,val2,res1,res2,res3,res4) \
6268 V_##vt1(&left) = val1; V_VT(&left) = VT_##vt1; \
6269 V_##vt2(&right) = val2; V_VT(&right) = VT_##vt2; \
6270 test_cmpex( __LINE__, lcid, &left, &right, res1, res2, res3, res4 )
6271 #define VARCMP(vt1,val1,vt2,val2,result) \
6272 VARCMPEX(vt1,val1,vt2,val2,result,result,result,result)
6273 /* The above macros do not work for VT_NULL as NULL gets expanded first */
6274 #define V_NULL_ V_NULL
6275 #define VT_NULL_ VT_NULL
6277 static void test_VarCmp(void)
6279 VARIANT left
, right
;
6284 static const WCHAR szhuh
[] = {'h','u','h','?','\0'};
6285 static const WCHAR sz2cents
[] = {'2','c','e','n','t','s','\0'};
6286 static const WCHAR szempty
[] = {'\0'};
6287 static const WCHAR sz0
[] = {'0','\0'};
6288 static const WCHAR sz1
[] = {'1','\0'};
6289 static const WCHAR sz7
[] = {'7','\0'};
6290 static const WCHAR sz42
[] = {'4','2','\0'};
6291 static const WCHAR sz1neg
[] = {'-','1','\0'};
6292 static const WCHAR sz666neg
[] = {'-','6','6','6','\0'};
6293 static const WCHAR sz1few
[] = {'1','.','0','0','0','0','0','0','0','1','\0'};
6294 BSTR bstrhuh
, bstrempty
, bstr0
, bstr1
, bstr7
, bstr42
, bstr1neg
, bstr666neg
;
6295 BSTR bstr2cents
, bstr1few
;
6299 lcid
= MAKELCID(MAKELANGID(LANG_ENGLISH
,SUBLANG_ENGLISH_US
),SORT_DEFAULT
);
6300 bstrempty
= SysAllocString(szempty
);
6301 bstrhuh
= SysAllocString(szhuh
);
6302 bstr2cents
= SysAllocString(sz2cents
);
6303 bstr0
= SysAllocString(sz0
);
6304 bstr1
= SysAllocString(sz1
);
6305 bstr7
= SysAllocString(sz7
);
6306 bstr42
= SysAllocString(sz42
);
6307 bstr1neg
= SysAllocString(sz1neg
);
6308 bstr666neg
= SysAllocString(sz666neg
);
6309 bstr1few
= SysAllocString(sz1few
);
6311 /* Test all possible flag/vt combinations & the resulting vt type */
6312 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
6314 VARTYPE leftvt
, rightvt
;
6316 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
6321 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
6324 HRESULT expect
= VARCMP_EQ
;
6328 memset(&left
, 0, sizeof(left
));
6329 memset(&right
, 0, sizeof(right
));
6330 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
6331 if (leftvt
== VT_BSTR
) {
6332 V_BSTR(&left
) = bstr1neg
;
6333 if (ExtraFlags
[i
] & VT_RESERVED
)
6338 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
6339 if (rightvt
== VT_BSTR
) {
6340 V_BSTR(&right
) = bstr1neg
;
6341 if (ExtraFlags
[i
] & VT_RESERVED
)
6347 /* Don't ask me why but native VarCmp cannot handle:
6348 VT_I1, VT_UI2, VT_UI4, VT_UINT and VT_UI8.
6349 VT_INT is only supported as left variant. Go figure.
6350 Tested with DCOM98, Win2k, WinXP */
6351 if (ExtraFlags
[i
] & VT_ARRAY
|| ExtraFlags
[i
] & VT_BYREF
||
6352 !IsValidVariantClearVT(leftvt
, ExtraFlags
[i
] & ~VT_RESERVED
) ||
6353 !IsValidVariantClearVT(rightvt
, ExtraFlags
[i
] & ~VT_RESERVED
) ||
6354 leftvt
== VT_CLSID
|| rightvt
== VT_CLSID
||
6355 leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
||
6356 leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
||
6357 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
||
6358 leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
||
6359 leftvt
== VT_VARIANT
|| rightvt
== VT_VARIANT
||
6360 leftvt
== VT_I1
|| rightvt
== VT_I1
||
6361 leftvt
== VT_UI2
|| rightvt
== VT_UI2
||
6362 leftvt
== VT_UI4
|| rightvt
== VT_UI4
||
6363 leftvt
== VT_UI8
|| rightvt
== VT_UI8
||
6364 rightvt
== VT_INT
||
6365 leftvt
== VT_UINT
|| rightvt
== VT_UINT
) {
6369 if (leftvt
== VT_ERROR
&& rightvt
== VT_ERROR
&&
6370 !(ExtraFlags
[i
] & ~VT_RESERVED
)) {
6373 } else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
6374 expect
= VARCMP_NULL
;
6375 else if (leftvt
== VT_BSTR
&& rightvt
== VT_BSTR
)
6377 else if (leftvt
== VT_BSTR
&& rightvt
== VT_EMPTY
)
6379 else if (leftvt
== VT_EMPTY
&& rightvt
== VT_BSTR
)
6382 hres
= pVarCmp(&left
, &right
, LOCALE_USER_DEFAULT
, 0);
6384 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
6385 "VarCmp: %d|0x%X, %d|0x%X: Expected failure, got 0x%X\n",
6386 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], hres
);
6389 "VarCmp: %d|0x%X, %d|0x%X: Expected 0x%X, got 0x%X\n",
6390 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], expect
,
6397 /* VARCMP{,EX} run each 4 tests with a permutation of all possible
6398 input variants with (1) and without (0) VT_RESERVED set. The order
6399 of the permutations is (0,0); (1,0); (0,1); (1,1) */
6400 VARCMP(INT
,4711,I2
,4711,VARCMP_EQ
);
6401 VARCMP(INT
,4711,I2
,-4711,VARCMP_GT
);
6402 VARCMP(ERROR
,0,ERROR
,0,VARCMP_EQ
);
6403 VARCMP(ERROR
,0,UI1
,0,DISP_E_TYPEMISMATCH
);
6404 VARCMP(EMPTY
,0,EMPTY
,0,VARCMP_EQ
);
6405 VARCMP(I4
,1,R8
,1.0,VARCMP_EQ
);
6406 VARCMP(EMPTY
,19,I2
,0,VARCMP_EQ
);
6407 ok(V_EMPTY(&left
) == 19, "VT_EMPTY modified!\n");
6408 VARCMP(I4
,1,UI1
,1,VARCMP_EQ
);
6409 VARCMP(I2
,2,I2
,2,VARCMP_EQ
);
6410 VARCMP(I2
,1,I2
,2,VARCMP_LT
);
6411 VARCMP(I2
,2,I2
,1,VARCMP_GT
);
6412 VARCMP(I2
,2,EMPTY
,1,VARCMP_GT
);
6413 VARCMP(I2
,2,NULL_
,1,VARCMP_NULL
);
6415 /* BSTR handling, especially in conjunction with VT_RESERVED */
6416 VARCMP(BSTR
,bstr0
,NULL_
,0,VARCMP_NULL
);
6417 VARCMP(BSTR
,bstr0
,BSTR
,bstr0
,VARCMP_EQ
);
6418 VARCMP(BSTR
,bstrempty
,BSTR
,bstr0
,VARCMP_LT
);
6419 VARCMP(BSTR
,bstr7
,BSTR
,bstr0
,VARCMP_GT
);
6420 VARCMP(BSTR
,bstr7
,BSTR
,bstr1neg
,VARCMP_GT
);
6421 VARCMP(BSTR
,bstr0
,BSTR
,NULL
,VARCMP_GT
);
6422 VARCMP(BSTR
,NULL
,BSTR
,NULL
,VARCMP_EQ
);
6423 VARCMP(BSTR
,bstrempty
,BSTR
,NULL
,VARCMP_EQ
);
6424 VARCMP(BSTR
,NULL
,EMPTY
,0,VARCMP_EQ
);
6425 VARCMP(EMPTY
,0,BSTR
,NULL
,VARCMP_EQ
);
6426 VARCMP(EMPTY
,0,BSTR
,bstrempty
,VARCMP_EQ
);
6427 VARCMP(EMPTY
,1,BSTR
,bstrempty
,VARCMP_EQ
);
6428 VARCMP(BSTR
,bstr0
,EMPTY
,0,VARCMP_GT
);
6429 VARCMP(BSTR
,bstr42
,EMPTY
,0,VARCMP_GT
);
6430 VARCMPEX(BSTR
,bstrempty
,UI1
,0,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
6431 VARCMPEX(BSTR
,bstrempty
,I2
,-1,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
6432 VARCMPEX(I4
,0,BSTR
,bstrempty
,VARCMP_LT
,VARCMP_LT
,VARCMP_GT
,VARCMP_LT
);
6433 VARCMPEX(BSTR
,NULL
,UI1
,0,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
6434 VARCMPEX(I4
,7,BSTR
,NULL
,VARCMP_LT
,VARCMP_LT
,VARCMP_GT
,VARCMP_LT
);
6435 _VARCMP(BSTR
,(BSTR
)100,0,I2
,100,0,lcid
,0,VARCMP_GT
);
6436 VARCMPEX(BSTR
,bstr0
,UI1
,0,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_GT
);
6437 VARCMPEX(I2
,0,BSTR
,bstr0
,VARCMP_LT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_LT
);
6438 VARCMP(BSTR
,bstrhuh
,I4
,I4_MAX
,VARCMP_GT
);
6439 VARCMP(BSTR
,bstr2cents
,I4
,2,VARCMP_GT
);
6440 VARCMPEX(BSTR
,bstr2cents
,I4
,42,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
6441 VARCMP(BSTR
,bstr2cents
,I4
,-1,VARCMP_GT
);
6442 VARCMPEX(BSTR
,bstr2cents
,I4
,-666,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
6443 VARCMPEX(BSTR
,bstr0
,I2
,0,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_GT
);
6444 VARCMPEX(BSTR
,bstr0
,I4
,0,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_GT
);
6445 VARCMPEX(BSTR
,bstr0
,I4
,-666,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
6446 VARCMP(BSTR
,bstr1
,I4
,0,VARCMP_GT
);
6447 VARCMPEX(BSTR
,bstr1
,I4
,1,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_GT
);
6448 VARCMPEX(BSTR
,bstr1
,I4
,I4_MAX
,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
,VARCMP_GT
);
6449 VARCMPEX(BSTR
,bstr1
,I4
,-1,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
6450 VARCMP(BSTR
,bstr7
,I4
,1,VARCMP_GT
);
6451 VARCMPEX(BSTR
,bstr7
,I4
,7,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_GT
);
6452 VARCMPEX(BSTR
,bstr7
,I4
,42,VARCMP_GT
,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
);
6453 VARCMPEX(BSTR
,bstr42
,I4
,7,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
6454 VARCMPEX(BSTR
,bstr42
,I4
,42,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_GT
);
6455 VARCMPEX(BSTR
,bstr42
,I4
,I4_MAX
,VARCMP_GT
,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
);
6456 VARCMPEX(BSTR
,bstr1neg
,I4
,1,VARCMP_GT
,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
);
6457 VARCMPEX(BSTR
,bstr1neg
,I4
,42,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
,VARCMP_LT
);
6458 VARCMPEX(BSTR
,bstr1neg
,I4
,-1,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_LT
);
6459 VARCMPEX(BSTR
,bstr1neg
,I4
,-666,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_LT
);
6460 VARCMPEX(BSTR
,bstr666neg
,I4
,1,VARCMP_GT
,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
);
6461 VARCMPEX(BSTR
,bstr666neg
,I4
,7,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
,VARCMP_LT
);
6462 VARCMPEX(BSTR
,bstr666neg
,I4
,42,VARCMP_GT
,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
);
6463 VARCMPEX(BSTR
,bstr666neg
,I4
,I4_MAX
,VARCMP_GT
,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
);
6464 VARCMPEX(BSTR
,bstr666neg
,I4
,-1,VARCMP_GT
,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
);
6465 VARCMPEX(BSTR
,bstr666neg
,I4
,-666,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_LT
);
6466 VARCMPEX(BSTR
,bstr7
,R8
,7.0,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_GT
);
6467 VARCMPEX(R8
,3.141592,BSTR
,NULL
,VARCMP_LT
,VARCMP_LT
,VARCMP_GT
,VARCMP_LT
);
6468 VARCMP(BSTR
,bstr7
,BSTR
,bstr7
,VARCMP_EQ
);
6469 VARCMP(BSTR
,bstr7
,BSTR
,bstr42
,VARCMP_GT
);
6470 VARCMP(BSTR
,bstr42
,BSTR
,bstr7
,VARCMP_LT
);
6472 /* DECIMAL handling */
6473 setdec(&dec
,0,0,0,0);
6474 VARCMPEX(DECIMAL
,dec
,BSTR
,bstr0
,VARCMP_LT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_LT
);
6475 setdec64(&dec
,0,0,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF); /* max DECIMAL */
6476 VARCMP(DECIMAL
,dec
,R8
,R8_MAX
,VARCMP_LT
); /* R8 has bigger range */
6477 VARCMP(DECIMAL
,dec
,DATE
,R8_MAX
,VARCMP_LT
); /* DATE has bigger range */
6478 setdec64(&dec
,0,0x80,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF);
6479 VARCMP(DECIMAL
,dec
,R8
,-R8_MAX
,VARCMP_GT
);
6480 setdec64(&dec
,20,0,0x5,0x6BC75E2D,0x63100001); /* 1+1e-20 */
6481 VARCMP(DECIMAL
,dec
,R8
,1,VARCMP_GT
); /* DECIMAL has higher precision */
6483 /* Show that DATE is handled just as a R8 */
6484 VARCMP(DATE
,DATE_MAX
,DATE
,DATE_MAX
+1,VARCMP_LT
);
6485 VARCMP(DATE
,DATE_MIN
,DATE
,DATE_MIN
-1,VARCMP_GT
);
6486 VARCMP(DATE
,R8_MIN
,R8
,R8_MIN
,VARCMP_EQ
);
6487 VARCMP(DATE
,1,DATE
,1+1e-15,VARCMP_LT
); /* 1e-15 == 8.64e-11 seconds */
6488 VARCMP(DATE
,25570.0,DATE
,25570.0,VARCMP_EQ
);
6489 VARCMP(DATE
,25570.0,DATE
,25571.0,VARCMP_LT
);
6490 VARCMP(DATE
,25571.0,DATE
,25570.0,VARCMP_GT
);
6491 VARCMP(DATE
,25570.0,EMPTY
,0,VARCMP_GT
);
6492 VARCMP(DATE
,25570.0,NULL_
,0,VARCMP_NULL
);
6494 /* R4 precision handling */
6495 VARCMP(R4
,1,R8
,1+1e-8,VARCMP_EQ
);
6496 VARCMP(R8
,1+1e-8,R4
,1,VARCMP_EQ
);
6497 VARCMP(R8
,1+1e-8,R8
,1,VARCMP_GT
);
6498 VARCMP(R8
,R4_MAX
*1.1,R4
,R4_MAX
,VARCMP_GT
);
6499 VARCMP(R4
,R4_MAX
,R8
,R8_MAX
,VARCMP_LT
);
6500 VARCMP(R4
,1,DATE
,1+1e-8,VARCMP_EQ
);
6501 VARCMP(R4
,1,BSTR
,bstr1few
,VARCMP_LT
); /* bstr1few == 1+1e-8 */
6502 setdec(&dec
,8,0,0,0x5F5E101); /* 1+1e-8 */
6503 VARCMP(R4
,1,DECIMAL
,dec
,VARCMP_LT
);
6505 SysFreeString(bstrhuh
);
6506 SysFreeString(bstrempty
);
6507 SysFreeString(bstr0
);
6508 SysFreeString(bstr1
);
6509 SysFreeString(bstr7
);
6510 SysFreeString(bstr42
);
6511 SysFreeString(bstr1neg
);
6512 SysFreeString(bstr666neg
);
6513 SysFreeString(bstr2cents
);
6514 SysFreeString(bstr1few
);
6517 static HRESULT (WINAPI
*pVarPow
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
6519 #define VARPOW(vt1,val1,vt2,val2,rvt,rval) \
6520 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
6521 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
6522 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
6523 test_var_call2( __LINE__, pVarPow, &left, &right, &exp )
6525 /* Skip any type that is not defined or produces an error for every case */
6526 #define SKIPTESTPOW(a) \
6527 if (a == VT_ERROR || a == VT_VARIANT || \
6528 a == VT_DISPATCH || a == VT_UNKNOWN || \
6529 a == VT_RECORD || a > VT_UINT || \
6530 a == 15 /*not defined*/) \
6533 static void test_VarPow(void)
6535 static const WCHAR str2
[] = { '2','\0' };
6536 static const WCHAR str3
[] = { '3','\0' };
6537 VARIANT left
, right
, exp
, result
, cy
, dec
;
6538 BSTR num2_str
, num3_str
;
6544 num2_str
= SysAllocString(str2
);
6545 num3_str
= SysAllocString(str3
);
6547 /* Test all possible flag/vt combinations & the resulting vt type */
6548 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
6550 VARTYPE leftvt
, rightvt
, resvt
;
6552 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
6554 SKIPTESTPOW(leftvt
);
6556 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
6559 SKIPTESTPOW(rightvt
);
6561 /* Native crashes with VT_BYREF */
6562 if (ExtraFlags
[i
] == VT_BYREF
)
6565 memset(&left
, 0, sizeof(left
));
6566 memset(&right
, 0, sizeof(right
));
6567 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
6568 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
6569 V_VT(&result
) = VT_EMPTY
;
6572 if (leftvt
== VT_BSTR
)
6573 V_BSTR(&left
) = num2_str
;
6574 if (rightvt
== VT_BSTR
)
6575 V_BSTR(&right
) = num2_str
;
6577 /* Native VarPow always returns an error when using extra flags */
6578 if (ExtraFlags
[i
] != 0)
6581 /* Determine return type */
6582 else if ((leftvt
== VT_NULL
|| rightvt
== VT_NULL
) &&
6583 ((leftvt
!= VT_I8
&& leftvt
!= VT_UI8
&&
6584 rightvt
!= VT_I8
&& rightvt
!= VT_UI8
) || HAVE_OLEAUT32_I8
))
6586 else if ((leftvt
== VT_EMPTY
|| leftvt
== VT_I2
||
6587 leftvt
== VT_I4
|| leftvt
== VT_R4
||
6588 leftvt
== VT_R8
|| leftvt
== VT_CY
||
6589 leftvt
== VT_DATE
|| leftvt
== VT_BSTR
||
6590 leftvt
== VT_BOOL
|| leftvt
== VT_DECIMAL
||
6591 (leftvt
>= VT_I1
&& leftvt
<= VT_UI4
) ||
6592 (HAVE_OLEAUT32_I8
&& (leftvt
== VT_I8
|| leftvt
== VT_UI8
)) ||
6593 leftvt
== VT_INT
|| leftvt
== VT_UINT
) &&
6594 (rightvt
== VT_EMPTY
|| rightvt
== VT_I2
||
6595 rightvt
== VT_I4
|| rightvt
== VT_R4
||
6596 rightvt
== VT_R8
|| rightvt
== VT_CY
||
6597 rightvt
== VT_DATE
|| rightvt
== VT_BSTR
||
6598 rightvt
== VT_BOOL
|| rightvt
== VT_DECIMAL
||
6599 (rightvt
>= VT_I1
&& rightvt
<= VT_UI4
) ||
6600 (HAVE_OLEAUT32_I8
&& (rightvt
== VT_I8
|| rightvt
== VT_UI8
)) ||
6601 rightvt
== VT_INT
|| rightvt
== VT_UINT
))
6606 hres
= pVarPow(&left
, &right
, &result
);
6608 /* Check expected HRESULT and if result variant type is correct */
6610 ok (hres
== DISP_E_BADVARTYPE
|| hres
== DISP_E_TYPEMISMATCH
,
6611 "VarPow: %s|0x%X, %s|0x%X: got vt %s hr 0x%X\n",
6612 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
],
6613 vtstr(V_VT(&result
)), hres
);
6615 ok (hres
== S_OK
&& resvt
== V_VT(&result
),
6616 "VarPow: %s|0x%X, %s|0x%X: expected vt %s hr 0x%X, got vt %s hr 0x%X\n",
6617 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
], vtstr(resvt
),
6618 S_OK
, vtstr(V_VT(&result
)), hres
);
6623 /* Check return values for valid variant type combinations */
6624 VARPOW(EMPTY
,0,EMPTY
,0,R8
,1.0);
6625 VARPOW(EMPTY
,0,NULL
,0,NULL
,0);
6626 VARPOW(EMPTY
,0,I2
,3,R8
,0.0);
6627 VARPOW(EMPTY
,0,I4
,3,R8
,0.0);
6628 VARPOW(EMPTY
,0,R4
,3.0f
,R8
,0.0);
6629 VARPOW(EMPTY
,0,R8
,3.0,R8
,0.0);
6630 VARPOW(EMPTY
,0,DATE
,3,R8
,0.0);
6631 VARPOW(EMPTY
,0,BSTR
,num3_str
,R8
,0.0);
6632 VARPOW(EMPTY
,0,BOOL
,VARIANT_FALSE
,R8
,1.0);
6633 VARPOW(EMPTY
,0,I1
,3,R8
,0.0);
6634 VARPOW(EMPTY
,0,UI1
,3,R8
,0.0);
6635 VARPOW(EMPTY
,0,UI2
,3,R8
,0.0);
6636 VARPOW(EMPTY
,0,UI4
,3,R8
,0.0);
6637 if (HAVE_OLEAUT32_I8
)
6639 VARPOW(EMPTY
,0,I8
,3,R8
,0.0);
6640 VARPOW(EMPTY
,0,UI8
,3,R8
,0.0);
6642 VARPOW(EMPTY
,0,INT
,3,R8
,0.0);
6643 VARPOW(EMPTY
,0,UINT
,3,R8
,0.0);
6644 VARPOW(NULL
,0,EMPTY
,0,NULL
,0);
6645 VARPOW(NULL
,0,NULL
,0,NULL
,0);
6646 VARPOW(NULL
,0,I2
,3,NULL
,0);
6647 VARPOW(NULL
,0,I4
,3,NULL
,0);
6648 VARPOW(NULL
,0,R4
,3.0f
,NULL
,0);
6649 VARPOW(NULL
,0,R8
,3.0,NULL
,0);
6650 VARPOW(NULL
,0,DATE
,3,NULL
,0);
6651 VARPOW(NULL
,0,BSTR
,num3_str
,NULL
,0);
6652 VARPOW(NULL
,0,BOOL
,VARIANT_TRUE
,NULL
,0);
6653 VARPOW(NULL
,0,I1
,3,NULL
,0);
6654 VARPOW(NULL
,0,UI1
,3,NULL
,0);
6655 VARPOW(NULL
,0,UI2
,3,NULL
,0);
6656 VARPOW(NULL
,0,UI4
,3,NULL
,0);
6657 if (HAVE_OLEAUT32_I8
)
6659 VARPOW(NULL
,0,I8
,3,NULL
,0);
6660 VARPOW(NULL
,0,UI8
,3,NULL
,0);
6662 VARPOW(NULL
,0,INT
,3,NULL
,0);
6663 VARPOW(NULL
,0,UINT
,3,NULL
,0);
6664 VARPOW(I2
,2,EMPTY
,0,R8
,1.0);
6665 VARPOW(I2
,2,NULL
,0,NULL
,0);
6666 VARPOW(I2
,2,I2
,3,R8
,8.0);
6667 VARPOW(I2
,2,I4
,3,R8
,8.0);
6668 VARPOW(I2
,2,R4
,3.0f
,R8
,8.0);
6669 VARPOW(I2
,2,R8
,3.0,R8
,8.0);
6670 VARPOW(I2
,2,DATE
,3,R8
,8.0);
6671 VARPOW(I2
,2,BSTR
,num3_str
,R8
,8.0);
6672 VARPOW(I2
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6673 VARPOW(I2
,2,I1
,3,R8
,8.0);
6674 VARPOW(I2
,2,UI1
,3,R8
,8.0);
6675 VARPOW(I2
,2,UI2
,3,R8
,8.0);
6676 VARPOW(I2
,2,UI4
,3,R8
,8.0);
6677 if (HAVE_OLEAUT32_I8
)
6679 VARPOW(I2
,2,I8
,3,R8
,8.0);
6680 VARPOW(I2
,2,UI8
,3,R8
,8.0);
6682 VARPOW(I2
,2,INT
,3,R8
,8.0);
6683 VARPOW(I2
,2,UINT
,3,R8
,8.0);
6684 VARPOW(I4
,2,EMPTY
,0,R8
,1.0);
6685 VARPOW(I4
,2,NULL
,0,NULL
,0);
6686 VARPOW(I4
,2,I2
,3,R8
,8.0);
6687 VARPOW(I4
,2,I4
,3,R8
,8.0);
6688 VARPOW(I4
,2,R4
,3.0f
,R8
,8.0);
6689 VARPOW(I4
,2,R8
,3.0,R8
,8.0);
6690 VARPOW(I4
,2,DATE
,3,R8
,8.0);
6691 VARPOW(I4
,2,BSTR
,num3_str
,R8
,8.0);
6692 VARPOW(I4
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6693 VARPOW(I4
,2,I1
,3,R8
,8.0);
6694 VARPOW(I4
,2,UI1
,3,R8
,8.0);
6695 VARPOW(I4
,2,UI2
,3,R8
,8.0);
6696 VARPOW(I4
,2,UI4
,3,R8
,8.0);
6697 if (HAVE_OLEAUT32_I8
)
6699 VARPOW(I4
,2,I8
,3,R8
,8.0);
6700 VARPOW(I4
,2,UI8
,3,R8
,8.0);
6702 VARPOW(I4
,2,INT
,3,R8
,8.0);
6703 VARPOW(I4
,2,UINT
,3,R8
,8.0);
6704 VARPOW(R4
,2,EMPTY
,0,R8
,1.0);
6705 VARPOW(R4
,2,NULL
,0,NULL
,0);
6706 VARPOW(R4
,2,I2
,3,R8
,8.0);
6707 VARPOW(R4
,2,I4
,3,R8
,8.0);
6708 VARPOW(R4
,2,R4
,3.0f
,R8
,8.0);
6709 VARPOW(R4
,2,R8
,3.0,R8
,8.0);
6710 VARPOW(R4
,2,DATE
,3,R8
,8.0);
6711 VARPOW(R4
,2,BSTR
,num3_str
,R8
,8.0);
6712 VARPOW(R4
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6713 VARPOW(R4
,2,I1
,3,R8
,8.0);
6714 VARPOW(R4
,2,UI1
,3,R8
,8.0);
6715 VARPOW(R4
,2,UI2
,3,R8
,8.0);
6716 VARPOW(R4
,2,UI4
,3,R8
,8.0);
6717 if (HAVE_OLEAUT32_I8
)
6719 VARPOW(R4
,2,I8
,3,R8
,8.0);
6720 VARPOW(R4
,2,UI8
,3,R8
,8.0);
6722 VARPOW(R4
,2,INT
,3,R8
,8.0);
6723 VARPOW(R4
,2,UINT
,3,R8
,8.0);
6724 VARPOW(R8
,2,EMPTY
,0,R8
,1.0);
6725 VARPOW(R8
,2,NULL
,0,NULL
,0);
6726 VARPOW(R8
,2,I2
,3,R8
,8.0);
6727 VARPOW(R8
,2,I4
,3,R8
,8.0);
6728 VARPOW(R8
,2,R4
,3.0f
,R8
,8.0);
6729 VARPOW(R8
,2,R8
,3.0,R8
,8.0);
6730 VARPOW(R8
,2,DATE
,3,R8
,8.0);
6731 VARPOW(R8
,2,BSTR
,num3_str
,R8
,8.0);
6732 VARPOW(R8
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6733 VARPOW(R8
,2,I1
,3,R8
,8.0);
6734 VARPOW(R8
,2,UI1
,3,R8
,8.0);
6735 VARPOW(R8
,2,UI2
,3,R8
,8.0);
6736 VARPOW(R8
,2,UI4
,3,R8
,8.0);
6737 if (HAVE_OLEAUT32_I8
)
6739 VARPOW(R8
,2,I8
,3,R8
,8.0);
6740 VARPOW(R8
,2,UI8
,3,R8
,8.0);
6742 VARPOW(R8
,2,INT
,3,R8
,8.0);
6743 VARPOW(R8
,2,UINT
,3,R8
,8.0);
6744 VARPOW(DATE
,2,EMPTY
,0,R8
,1.0);
6745 VARPOW(DATE
,2,NULL
,0,NULL
,0);
6746 VARPOW(DATE
,2,I2
,3,R8
,8.0);
6747 VARPOW(DATE
,2,I4
,3,R8
,8.0);
6748 VARPOW(DATE
,2,R4
,3.0f
,R8
,8.0);
6749 VARPOW(DATE
,2,R8
,3.0,R8
,8.0);
6750 VARPOW(DATE
,2,DATE
,3,R8
,8.0);
6751 VARPOW(DATE
,2,BSTR
,num3_str
,R8
,8.0);
6752 VARPOW(DATE
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6753 VARPOW(DATE
,2,I1
,3,R8
,8.0);
6754 VARPOW(DATE
,2,UI1
,3,R8
,8.0);
6755 VARPOW(DATE
,2,UI2
,3,R8
,8.0);
6756 VARPOW(DATE
,2,UI4
,3,R8
,8.0);
6757 if (HAVE_OLEAUT32_I8
)
6759 VARPOW(DATE
,2,I8
,3,R8
,8.0);
6760 VARPOW(DATE
,2,UI8
,3,R8
,8.0);
6762 VARPOW(DATE
,2,INT
,3,R8
,8.0);
6763 VARPOW(DATE
,2,UINT
,3,R8
,8.0);
6764 VARPOW(BSTR
,num2_str
,EMPTY
,0,R8
,1.0);
6765 VARPOW(BSTR
,num2_str
,NULL
,0,NULL
,0);
6766 VARPOW(BSTR
,num2_str
,I2
,3,R8
,8.0);
6767 VARPOW(BSTR
,num2_str
,I4
,3,R8
,8.0);
6768 VARPOW(BSTR
,num2_str
,R4
,3.0f
,R8
,8.0);
6769 VARPOW(BSTR
,num2_str
,R8
,3.0,R8
,8.0);
6770 VARPOW(BSTR
,num2_str
,DATE
,3,R8
,8.0);
6771 VARPOW(BSTR
,num2_str
,BSTR
,num3_str
,R8
,8.0);
6772 VARPOW(BSTR
,num2_str
,BOOL
,VARIANT_FALSE
,R8
,1.0);
6773 VARPOW(BSTR
,num2_str
,I1
,3,R8
,8.0);
6774 VARPOW(BSTR
,num2_str
,UI1
,3,R8
,8.0);
6775 VARPOW(BSTR
,num2_str
,UI2
,3,R8
,8.0);
6776 VARPOW(BSTR
,num2_str
,UI4
,3,R8
,8.0);
6777 if (HAVE_OLEAUT32_I8
)
6779 VARPOW(BSTR
,num2_str
,I8
,3,R8
,8.0);
6780 VARPOW(BSTR
,num2_str
,UI8
,3,R8
,8.0);
6782 VARPOW(BSTR
,num2_str
,INT
,3,R8
,8.0);
6783 VARPOW(BSTR
,num2_str
,UINT
,3,R8
,8.0);
6784 VARPOW(BOOL
,VARIANT_TRUE
,EMPTY
,0,R8
,1.0);
6785 VARPOW(BOOL
,VARIANT_TRUE
,NULL
,0,NULL
,0);
6786 VARPOW(BOOL
,VARIANT_TRUE
,I2
,3,R8
,-1.0);
6787 VARPOW(BOOL
,VARIANT_TRUE
,I4
,3,R8
,-1.0);
6788 VARPOW(BOOL
,VARIANT_TRUE
,R4
,3.0f
,R8
,-1.0);
6789 VARPOW(BOOL
,VARIANT_TRUE
,R8
,3.0,R8
,-1.0);
6790 VARPOW(BOOL
,VARIANT_TRUE
,DATE
,3,R8
,-1.0);
6791 VARPOW(BOOL
,VARIANT_TRUE
,BSTR
,num3_str
,R8
,-1.0);
6792 VARPOW(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
,R8
,-1.0);
6793 VARPOW(BOOL
,VARIANT_TRUE
,I1
,3,R8
,-1.0);
6794 VARPOW(BOOL
,VARIANT_TRUE
,UI1
,3,R8
,-1.0);
6795 VARPOW(BOOL
,VARIANT_TRUE
,UI2
,3,R8
,-1.0);
6796 VARPOW(BOOL
,VARIANT_TRUE
,UI4
,3,R8
,-1.0);
6797 if (HAVE_OLEAUT32_I8
)
6799 VARPOW(BOOL
,VARIANT_TRUE
,I8
,3,R8
,-1.0);
6800 VARPOW(BOOL
,VARIANT_TRUE
,UI8
,3,R8
,-1.0);
6802 VARPOW(BOOL
,VARIANT_TRUE
,INT
,3,R8
,-1.0);
6803 VARPOW(BOOL
,VARIANT_TRUE
,UINT
,3,R8
,-1.0);
6804 VARPOW(I1
,2,EMPTY
,0,R8
,1.0);
6805 VARPOW(I1
,2,NULL
,0,NULL
,0);
6806 VARPOW(I1
,2,I2
,3,R8
,8.0);
6807 VARPOW(I1
,2,I4
,3,R8
,8.0);
6808 VARPOW(I1
,2,R4
,3.0f
,R8
,8.0);
6809 VARPOW(I1
,2,R8
,3.0,R8
,8.0);
6810 VARPOW(I1
,2,DATE
,3,R8
,8.0);
6811 VARPOW(I1
,2,BSTR
,num3_str
,R8
,8.0);
6812 VARPOW(I1
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6813 VARPOW(I1
,2,I1
,3,R8
,8.0);
6814 VARPOW(I1
,2,UI1
,3,R8
,8.0);
6815 VARPOW(I1
,2,UI2
,3,R8
,8.0);
6816 VARPOW(I1
,2,UI4
,3,R8
,8.0);
6817 if (HAVE_OLEAUT32_I8
)
6819 VARPOW(I1
,2,I8
,3,R8
,8.0);
6820 VARPOW(I1
,2,UI8
,3,R8
,8.0);
6822 VARPOW(I1
,2,INT
,3,R8
,8.0);
6823 VARPOW(I1
,2,UINT
,3,R8
,8.0);
6824 VARPOW(UI1
,2,EMPTY
,0,R8
,1.0);
6825 VARPOW(UI1
,2,NULL
,0,NULL
,0);
6826 VARPOW(UI1
,2,I2
,3,R8
,8.0);
6827 VARPOW(UI1
,2,I4
,3,R8
,8.0);
6828 VARPOW(UI1
,2,R4
,3.0f
,R8
,8.0);
6829 VARPOW(UI1
,2,R8
,3.0,R8
,8.0);
6830 VARPOW(UI1
,2,DATE
,3,R8
,8.0);
6831 VARPOW(UI1
,2,BSTR
,num3_str
,R8
,8.0);
6832 VARPOW(UI1
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6833 VARPOW(UI1
,2,I1
,3,R8
,8.0);
6834 VARPOW(UI1
,2,UI1
,3,R8
,8.0);
6835 VARPOW(UI1
,2,UI2
,3,R8
,8.0);
6836 VARPOW(UI1
,2,UI4
,3,R8
,8.0);
6837 if (HAVE_OLEAUT32_I8
)
6839 VARPOW(UI1
,2,I8
,3,R8
,8.0);
6840 VARPOW(UI1
,2,UI8
,3,R8
,8.0);
6842 VARPOW(UI1
,2,INT
,3,R8
,8.0);
6843 VARPOW(UI1
,2,UINT
,3,R8
,8.0);
6844 VARPOW(UI2
,2,EMPTY
,0,R8
,1.0);
6845 VARPOW(UI2
,2,NULL
,0,NULL
,0);
6846 VARPOW(UI2
,2,I2
,3,R8
,8.0);
6847 VARPOW(UI2
,2,I4
,3,R8
,8.0);
6848 VARPOW(UI2
,2,R4
,3.0f
,R8
,8.0);
6849 VARPOW(UI2
,2,R8
,3.0,R8
,8.0);
6850 VARPOW(UI2
,2,DATE
,3,R8
,8.0);
6851 VARPOW(UI2
,2,BSTR
,num3_str
,R8
,8.0);
6852 VARPOW(UI2
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6853 VARPOW(UI2
,2,I1
,3,R8
,8.0);
6854 VARPOW(UI2
,2,UI1
,3,R8
,8.0);
6855 VARPOW(UI2
,2,UI2
,3,R8
,8.0);
6856 VARPOW(UI2
,2,UI4
,3,R8
,8.0);
6857 if (HAVE_OLEAUT32_I8
)
6859 VARPOW(UI2
,2,I8
,3,R8
,8.0);
6860 VARPOW(UI2
,2,UI8
,3,R8
,8.0);
6862 VARPOW(UI2
,2,INT
,3,R8
,8.0);
6863 VARPOW(UI2
,2,UINT
,3,R8
,8.0);
6864 VARPOW(UI4
,2,EMPTY
,0,R8
,1.0);
6865 VARPOW(UI4
,2,NULL
,0,NULL
,0);
6866 VARPOW(UI4
,2,I2
,3,R8
,8.0);
6867 VARPOW(UI4
,2,I4
,3,R8
,8.0);
6868 VARPOW(UI4
,2,R4
,3.0f
,R8
,8.0);
6869 VARPOW(UI4
,2,R8
,3.0,R8
,8.0);
6870 VARPOW(UI4
,2,DATE
,3,R8
,8.0);
6871 VARPOW(UI4
,2,BSTR
,num3_str
,R8
,8.0);
6872 VARPOW(UI4
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6873 VARPOW(UI4
,2,I1
,3,R8
,8.0);
6874 VARPOW(UI4
,2,UI1
,3,R8
,8.0);
6875 VARPOW(UI4
,2,UI2
,3,R8
,8.0);
6876 VARPOW(UI4
,2,UI4
,3,R8
,8.0);
6877 if (HAVE_OLEAUT32_I8
)
6879 VARPOW(UI4
,2,I8
,3,R8
,8.0);
6880 VARPOW(UI4
,2,UI8
,3,R8
,8.0);
6882 VARPOW(UI4
,2,INT
,3,R8
,8.0);
6883 VARPOW(UI4
,2,UINT
,3,R8
,8.0);
6884 if (HAVE_OLEAUT32_I8
)
6886 VARPOW(I8
,2,EMPTY
,0,R8
,1.0);
6887 VARPOW(I8
,2,NULL
,0,NULL
,0);
6888 VARPOW(I8
,2,I2
,3,R8
,8.0);
6889 VARPOW(I8
,2,I4
,3,R8
,8.0);
6890 VARPOW(I8
,2,R4
,3.0f
,R8
,8.0);
6891 VARPOW(I8
,2,R8
,3.0,R8
,8.0);
6892 VARPOW(I8
,2,DATE
,3,R8
,8.0);
6893 VARPOW(I8
,2,BSTR
,num3_str
,R8
,8.0);
6894 VARPOW(I8
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6895 VARPOW(I8
,2,I1
,3,R8
,8.0);
6896 VARPOW(I8
,2,UI1
,3,R8
,8.0);
6897 VARPOW(I8
,2,UI2
,3,R8
,8.0);
6898 VARPOW(I8
,2,UI4
,3,R8
,8.0);
6899 VARPOW(I8
,2,I8
,3,R8
,8.0);
6900 VARPOW(I8
,2,UI8
,3,R8
,8.0);
6901 VARPOW(I8
,2,INT
,3,R8
,8.0);
6902 VARPOW(I8
,2,UINT
,3,R8
,8.0);
6903 VARPOW(UI8
,2,EMPTY
,0,R8
,1.0);
6904 VARPOW(UI8
,2,NULL
,0,NULL
,0);
6905 VARPOW(UI8
,2,I2
,3,R8
,8.0);
6906 VARPOW(UI8
,2,I4
,3,R8
,8.0);
6907 VARPOW(UI8
,2,R4
,3.0f
,R8
,8.0);
6908 VARPOW(UI8
,2,R8
,3.0,R8
,8.0);
6909 VARPOW(UI8
,2,DATE
,3,R8
,8.0);
6910 VARPOW(UI8
,2,BSTR
,num3_str
,R8
,8.0);
6911 VARPOW(UI8
,2,I1
,3,R8
,8.0);
6912 VARPOW(UI8
,2,UI1
,3,R8
,8.0);
6913 VARPOW(UI8
,2,UI2
,3,R8
,8.0);
6914 VARPOW(UI8
,2,UI4
,3,R8
,8.0);
6915 VARPOW(UI8
,2,I8
,3,R8
,8.0);
6916 VARPOW(UI8
,2,UI8
,3,R8
,8.0);
6917 VARPOW(UI8
,2,INT
,3,R8
,8.0);
6918 VARPOW(UI8
,2,UINT
,3,R8
,8.0);
6920 VARPOW(INT
,2,EMPTY
,0,R8
,1.0);
6921 VARPOW(INT
,2,NULL
,0,NULL
,0);
6922 VARPOW(INT
,2,I2
,3,R8
,8.0);
6923 VARPOW(INT
,2,I4
,3,R8
,8.0);
6924 VARPOW(INT
,2,R4
,3.0f
,R8
,8.0);
6925 VARPOW(INT
,2,R8
,3.0,R8
,8.0);
6926 VARPOW(INT
,2,DATE
,3,R8
,8.0);
6927 VARPOW(INT
,2,BSTR
,num3_str
,R8
,8.0);
6928 VARPOW(INT
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6929 VARPOW(INT
,2,I1
,3,R8
,8.0);
6930 VARPOW(INT
,2,UI1
,3,R8
,8.0);
6931 VARPOW(INT
,2,UI2
,3,R8
,8.0);
6932 VARPOW(INT
,2,UI4
,3,R8
,8.0);
6933 if (HAVE_OLEAUT32_I8
)
6935 VARPOW(INT
,2,I8
,3,R8
,8.0);
6936 VARPOW(INT
,2,UI8
,3,R8
,8.0);
6938 VARPOW(INT
,2,INT
,3,R8
,8.0);
6939 VARPOW(INT
,2,UINT
,3,R8
,8.0);
6940 VARPOW(UINT
,2,EMPTY
,0,R8
,1.0);
6941 VARPOW(UINT
,2,NULL
,0,NULL
,0);
6942 VARPOW(UINT
,2,I2
,3,R8
,8.0);
6943 VARPOW(UINT
,2,I4
,3,R8
,8.0);
6944 VARPOW(UINT
,2,R4
,3.0f
,R8
,8.0);
6945 VARPOW(UINT
,2,R8
,3.0,R8
,8.0);
6946 VARPOW(UINT
,2,DATE
,3,R8
,8.0);
6947 VARPOW(UINT
,2,BSTR
,num3_str
,R8
,8.0);
6948 VARPOW(UINT
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6949 VARPOW(UINT
,2,I1
,3,R8
,8.0);
6950 VARPOW(UINT
,2,UI1
,3,R8
,8.0);
6951 VARPOW(UINT
,2,UI2
,3,R8
,8.0);
6952 VARPOW(UINT
,2,UI4
,3,R8
,8.0);
6953 if (HAVE_OLEAUT32_I8
)
6955 VARPOW(UINT
,2,I8
,3,R8
,8.0);
6956 VARPOW(UINT
,2,UI8
,3,R8
,8.0);
6958 VARPOW(UINT
,2,INT
,3,R8
,8.0);
6959 VARPOW(UINT
,2,UINT
,3,R8
,8.0);
6961 /* Manually test some VT_CY, VT_DECIMAL variants */
6963 hres
= VarCyFromI4(2, &V_CY(&cy
));
6964 ok(hres
== S_OK
, "VarCyFromI4 failed!\n");
6965 V_VT(&dec
) = VT_DECIMAL
;
6966 hres
= VarDecFromR8(2.0, &V_DECIMAL(&dec
));
6967 ok(hres
== S_OK
, "VarDecFromR4 failed!\n");
6968 memset(&left
, 0, sizeof(left
));
6969 memset(&right
, 0, sizeof(right
));
6970 V_VT(&left
) = VT_I4
;
6972 V_VT(&right
) = VT_I8
;
6975 hres
= pVarPow(&cy
, &cy
, &result
);
6976 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
6977 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
6978 S_OK
, hres
, vtstr(V_VT(&result
)));
6979 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 4.0),
6980 "VARPOW: CY value %f, expected %f\n", V_R8(&result
), 4.0);
6982 hres
= pVarPow(&cy
, &right
, &result
);
6985 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
6986 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
6987 S_OK
, hres
, vtstr(V_VT(&result
)));
6988 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 4.0),
6989 "VARPOW: CY value %f, expected %f\n", V_R8(&result
), 4.0);
6993 ok(hres
== DISP_E_BADVARTYPE
&& V_VT(&result
) == VT_EMPTY
,
6994 "VARPOW: expected coerced hres 0x%X type VT_EMPTY, got hres 0x%X type %s!\n",
6995 DISP_E_BADVARTYPE
, hres
, vtstr(V_VT(&result
)));
6998 hres
= pVarPow(&left
, &cy
, &result
);
6999 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
7000 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
7001 S_OK
, hres
, vtstr(V_VT(&result
)));
7002 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 10000.0),
7003 "VARPOW: CY value %f, expected %f\n", V_R8(&result
), 10000.0);
7005 hres
= pVarPow(&left
, &dec
, &result
);
7006 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
7007 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
7008 S_OK
, hres
, vtstr(V_VT(&result
)));
7009 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
),10000.0),
7010 "VARPOW: DECIMAL value %f, expected %f\n", V_R8(&result
), 10000.0);
7012 hres
= pVarPow(&dec
, &dec
, &result
);
7013 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
7014 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
7015 S_OK
, hres
, vtstr(V_VT(&result
)));
7016 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 4.0),
7017 "VARPOW: DECIMAL value %f, expected %f\n", V_R8(&result
), 4.0);
7019 hres
= pVarPow(&dec
, &right
, &result
);
7022 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
7023 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
7024 S_OK
, hres
, vtstr(V_VT(&result
)));
7025 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 4.0),
7026 "VARPOW: DECIMAL value %f, expected %f\n", V_R8(&result
), 4.0);
7030 ok(hres
== DISP_E_BADVARTYPE
&& V_VT(&result
) == VT_EMPTY
,
7031 "VARPOW: expected coerced hres 0x%X type VT_EMPTY, got hres 0x%X type %s!\n",
7032 DISP_E_BADVARTYPE
, hres
, vtstr(V_VT(&result
)));
7035 SysFreeString(num2_str
);
7036 SysFreeString(num3_str
);
7039 static HRESULT (WINAPI
*pVarDiv
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
7041 #define VARDIV(vt1,val1,vt2,val2,rvt,rval) \
7042 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
7043 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
7044 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
7045 test_var_call2( __LINE__, pVarDiv, &left, &right, &exp )
7047 /* Skip any type that is not defined or produces an error for every case */
7048 #define SKIPTESTDIV(a) \
7049 if (a == VT_ERROR || a == VT_VARIANT || \
7050 a == VT_DISPATCH || a == VT_UNKNOWN || \
7051 a == VT_RECORD || a > VT_UINT || \
7052 a == VT_I1 || a == VT_UI8 || \
7053 a == VT_INT || a == VT_UINT || \
7054 a == VT_UI2 || a == VT_UI4 || \
7055 a == 15 /*not defined*/) \
7058 static void test_VarDiv(void)
7060 static const WCHAR str1
[] = { '1','\0' };
7061 static const WCHAR str2
[] = { '2','\0' };
7062 VARIANT left
, right
, exp
, result
, cy
, dec
;
7063 BSTR num1_str
, num2_str
;
7065 HRESULT hres
, expectedhres
;
7068 num1_str
= SysAllocString(str1
);
7069 num2_str
= SysAllocString(str2
);
7073 /* Test all possible flag/vt combinations & the resulting vt type */
7074 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
7076 VARTYPE leftvt
, rightvt
, resvt
;
7078 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
7080 SKIPTESTDIV(leftvt
);
7082 /* Check if we need/have support for I8 */
7083 if (leftvt
== VT_I8
&& !HAVE_OLEAUT32_I8
)
7086 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
7089 SKIPTESTDIV(rightvt
);
7091 /* Check if we need/have support for I8 */
7092 if (rightvt
== VT_I8
&& !HAVE_OLEAUT32_I8
)
7095 /* Native crashes with VT_BYREF */
7096 if (ExtraFlags
[i
] == VT_BYREF
)
7099 memset(&left
, 0, sizeof(left
));
7100 memset(&right
, 0, sizeof(right
));
7101 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
7102 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
7103 V_VT(&result
) = VT_EMPTY
;
7105 expectedhres
= S_OK
;
7107 if (leftvt
== VT_BSTR
)
7108 V_BSTR(&left
) = num2_str
;
7109 else if (leftvt
== VT_DECIMAL
)
7111 VarDecFromR8(2.0, &V_DECIMAL(&left
));
7112 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
7115 /* Division by 0 is undefined */
7119 V_BSTR(&right
) = num2_str
;
7122 VarDecFromR8(2.0, &V_DECIMAL(&right
));
7123 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
7126 V_BOOL(&right
) = VARIANT_TRUE
;
7128 case VT_I2
: V_I2(&right
) = 2; break;
7129 case VT_I4
: V_I4(&right
) = 2; break;
7130 case VT_R4
: V_R4(&right
) = 2.0f
; break;
7131 case VT_R8
: V_R8(&right
) = 2.0; break;
7132 case VT_CY
: V_CY(&right
).int64
= 2; break;
7133 case VT_DATE
: V_DATE(&right
) = 2; break;
7134 case VT_UI1
: V_UI1(&right
) = 2; break;
7135 case VT_I8
: V_I8(&right
) = 2; break;
7139 /* Determine return type */
7140 if (!(rightvt
== VT_EMPTY
))
7142 if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
7144 else if (leftvt
== VT_DECIMAL
|| rightvt
== VT_DECIMAL
)
7146 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
||
7147 leftvt
== VT_CY
|| rightvt
== VT_CY
||
7148 leftvt
== VT_DATE
|| rightvt
== VT_DATE
||
7149 leftvt
== VT_I4
|| rightvt
== VT_I4
||
7150 leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
||
7151 leftvt
== VT_I2
|| rightvt
== VT_I2
||
7152 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
||
7153 leftvt
== VT_R8
|| rightvt
== VT_R8
||
7154 leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
7156 if ((leftvt
== VT_UI1
&& rightvt
== VT_R4
) ||
7157 (leftvt
== VT_R4
&& rightvt
== VT_UI1
))
7159 else if ((leftvt
== VT_R4
&& (rightvt
== VT_BOOL
||
7160 rightvt
== VT_I2
)) || (rightvt
== VT_R4
&&
7161 (leftvt
== VT_BOOL
|| leftvt
== VT_I2
)))
7166 else if (leftvt
== VT_R4
|| rightvt
== VT_R4
)
7169 else if (leftvt
== VT_NULL
&& rightvt
== VT_EMPTY
)
7174 /* Native VarDiv always returns an error when using extra flags */
7175 if (ExtraFlags
[i
] != 0)
7178 hres
= pVarDiv(&left
, &right
, &result
);
7180 /* Check expected HRESULT and if result variant type is correct */
7182 ok (hres
== DISP_E_BADVARTYPE
|| hres
== DISP_E_TYPEMISMATCH
||
7183 hres
== DISP_E_OVERFLOW
|| hres
== DISP_E_DIVBYZERO
,
7184 "VarDiv: %s|0x%X, %s|0x%X: got vt %s hr 0x%X\n",
7185 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
],
7186 vtstr(V_VT(&result
)), hres
);
7188 ok (hres
== S_OK
&& resvt
== V_VT(&result
),
7189 "VarDiv: %s|0x%X, %s|0x%X: expected vt %s hr 0x%X, got vt %s hr 0x%X\n",
7190 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
], vtstr(resvt
),
7191 S_OK
, vtstr(V_VT(&result
)), hres
);
7196 /* Test return values for all the good cases */
7197 VARDIV(EMPTY
,0,NULL
,0,NULL
,0);
7198 VARDIV(EMPTY
,0,I2
,2,R8
,0.0);
7199 VARDIV(EMPTY
,0,I4
,2,R8
,0.0);
7200 VARDIV(EMPTY
,0,R4
,2.0f
,R4
,0.0f
);
7201 VARDIV(EMPTY
,0,R8
,2.0,R8
,0.0);
7202 VARDIV(EMPTY
,0,DATE
,2.0,R8
,0.0);
7203 VARDIV(EMPTY
,0,BSTR
,num2_str
,R8
,0.0);
7204 VARDIV(EMPTY
,0,BOOL
,VARIANT_TRUE
,R8
,0.0);
7205 VARDIV(EMPTY
,0,UI1
,2,R8
,0.0);
7206 if (HAVE_OLEAUT32_I8
)
7208 VARDIV(EMPTY
,0,I8
,2,R8
,0.0);
7210 VARDIV(NULL
,0,EMPTY
,0,NULL
,0);
7211 VARDIV(NULL
,0,NULL
,0,NULL
,0);
7212 VARDIV(NULL
,0,I2
,2,NULL
,0);
7213 VARDIV(NULL
,0,I4
,2,NULL
,0);
7214 VARDIV(NULL
,0,R4
,2.0f
,NULL
,0);
7215 VARDIV(NULL
,0,R8
,2.0,NULL
,0);
7216 VARDIV(NULL
,0,DATE
,2,NULL
,0);
7217 VARDIV(NULL
,0,BSTR
,num2_str
,NULL
,0);
7218 VARDIV(NULL
,0,BOOL
,VARIANT_TRUE
,NULL
,0);
7219 VARDIV(NULL
,0,UI1
,2,NULL
,0);
7220 if (HAVE_OLEAUT32_I8
)
7222 VARDIV(NULL
,0,I8
,2,NULL
,0);
7224 VARDIV(I2
,2,NULL
,0,NULL
,0);
7225 VARDIV(I2
,1,I2
,2,R8
,0.5);
7226 VARDIV(I2
,1,I4
,2,R8
,0.5);
7227 VARDIV(I2
,1,R4
,2,R4
,0.5f
);
7228 VARDIV(I2
,1,R8
,2.0,R8
,0.5);
7229 VARDIV(I2
,1,DATE
,2,R8
,0.5);
7230 VARDIV(I2
,1,BOOL
,VARIANT_TRUE
,R8
,-1.0);
7231 VARDIV(I2
,1,UI1
,2,R8
,0.5);
7232 if (HAVE_OLEAUT32_I8
)
7234 VARDIV(I2
,1,I8
,2,R8
,0.5);
7236 VARDIV(I4
,1,NULL
,0,NULL
,0);
7237 VARDIV(I4
,1,I2
,2,R8
,0.5);
7238 VARDIV(I4
,1,I4
,2,R8
,0.5);
7239 VARDIV(I4
,1,R4
,2.0f
,R8
,0.5);
7240 VARDIV(I4
,1,R8
,2.0,R8
,0.5);
7241 VARDIV(I4
,1,DATE
,2,R8
,0.5);
7242 VARDIV(I4
,1,BSTR
,num2_str
,R8
,0.5);
7243 VARDIV(I4
,1,BOOL
,VARIANT_TRUE
,R8
,-1.0);
7244 VARDIV(I4
,1,UI1
,2,R8
,0.5);
7245 if (HAVE_OLEAUT32_I8
)
7247 VARDIV(I4
,1,I8
,2,R8
,0.5);
7249 VARDIV(R4
,1.0f
,NULL
,0,NULL
,0);
7250 VARDIV(R4
,1.0f
,I2
,2,R4
,0.5f
);
7251 VARDIV(R4
,1.0f
,I4
,2,R8
,0.5);
7252 VARDIV(R4
,1.0f
,R4
,2.0f
,R4
,0.5f
);
7253 VARDIV(R4
,1.0f
,R8
,2.0,R8
,0.5);
7254 VARDIV(R4
,1.0f
,DATE
,2,R8
,0.5);
7255 VARDIV(R4
,1.0f
,BSTR
,num2_str
,R8
,0.5);
7256 VARDIV(R4
,1.0f
,BOOL
,VARIANT_TRUE
,R4
,-1);
7257 VARDIV(R4
,1.0f
,UI1
,2,R4
,0.5f
);
7258 if (HAVE_OLEAUT32_I8
)
7260 VARDIV(R4
,1.0f
,I8
,2,R8
,0.5);
7262 VARDIV(R8
,1.0,NULL
,0,NULL
,0);
7263 VARDIV(R8
,1.0,I2
,2,R8
,0.5);
7264 VARDIV(R8
,1.0,I4
,2,R8
,0.5);
7265 VARDIV(R8
,1.0,R4
,2.0f
,R8
,0.5);
7266 VARDIV(R8
,1.0,R8
,2.0,R8
,0.5);
7267 VARDIV(R8
,1.0,DATE
,2,R8
,0.5);
7268 VARDIV(R8
,1.0,BSTR
,num2_str
,R8
,0.5);
7269 VARDIV(R8
,1.0,BOOL
,VARIANT_TRUE
,R8
,-1.0);
7270 VARDIV(R8
,1.0,UI1
,2,R8
,0.5);
7271 if (HAVE_OLEAUT32_I8
)
7273 VARDIV(R8
,1.0,I8
,2,R8
,0.5);
7275 VARDIV(DATE
,1,NULL
,0,NULL
,0);
7276 VARDIV(DATE
,1,I2
,2,R8
,0.5);
7277 VARDIV(DATE
,1,I4
,2,R8
,0.5);
7278 VARDIV(DATE
,1,R4
,2.0f
,R8
,0.5);
7279 VARDIV(DATE
,1,R8
,2.0,R8
,0.5);
7280 VARDIV(DATE
,1,DATE
,2,R8
,0.5);
7281 VARDIV(DATE
,1,BSTR
,num2_str
,R8
,0.5);
7282 VARDIV(DATE
,1,BOOL
,VARIANT_TRUE
,R8
,-1.0);
7283 VARDIV(DATE
,1,UI1
,2,R8
,0.5);
7284 if (HAVE_OLEAUT32_I8
)
7286 VARDIV(DATE
,1,I8
,2,R8
,0.5);
7288 VARDIV(BSTR
,num1_str
,NULL
,0,NULL
,0);
7289 VARDIV(BSTR
,num1_str
,I2
,2,R8
,0.5);
7290 VARDIV(BSTR
,num1_str
,I4
,2,R8
,0.5);
7291 VARDIV(BSTR
,num1_str
,R4
,2.0f
,R8
,0.5);
7292 VARDIV(BSTR
,num1_str
,R8
,2.0,R8
,0.5);
7293 VARDIV(BSTR
,num1_str
,DATE
,2,R8
,0.5);
7294 VARDIV(BSTR
,num1_str
,BSTR
,num2_str
,R8
,0.5);
7295 VARDIV(BSTR
,num1_str
,BOOL
,VARIANT_TRUE
,R8
,-1);
7296 VARDIV(BSTR
,num1_str
,UI1
,2,R8
,0.5);
7297 if (HAVE_OLEAUT32_I8
)
7299 VARDIV(BSTR
,num1_str
,I8
,2,R8
,0.5);
7301 VARDIV(BOOL
,VARIANT_TRUE
,NULL
,0,NULL
,0);
7302 VARDIV(BOOL
,VARIANT_TRUE
,I2
,1,R8
,-1.0);
7303 VARDIV(BOOL
,VARIANT_FALSE
,I2
,1,R8
,0.0);
7304 VARDIV(BOOL
,VARIANT_TRUE
,I4
,1,R8
,-1.0);
7305 VARDIV(BOOL
,VARIANT_FALSE
,I4
,1,R8
,0.0);
7306 VARDIV(BOOL
,VARIANT_TRUE
,R4
,1,R4
,-1.0f
);
7307 VARDIV(BOOL
,VARIANT_FALSE
,R4
,1,R4
,0.0f
);
7308 VARDIV(BOOL
,VARIANT_TRUE
,R8
,1.0,R8
,-1.0);
7309 VARDIV(BOOL
,VARIANT_FALSE
,R8
,1.0,R8
,0.0);
7310 VARDIV(BOOL
,VARIANT_FALSE
,DATE
,2,R8
,0.0);
7311 VARDIV(BOOL
,VARIANT_FALSE
,BSTR
,num2_str
,R8
,0.0);
7312 VARDIV(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
,R8
,1.0);
7313 VARDIV(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
,R8
,0.0);
7314 VARDIV(BOOL
,VARIANT_TRUE
,UI1
,1,R8
,-1.0);
7315 if (HAVE_OLEAUT32_I8
)
7317 VARDIV(BOOL
,VARIANT_TRUE
,I8
,1,R8
,-1.0);
7319 VARDIV(UI1
,1,NULL
,0,NULL
,0);
7320 VARDIV(UI1
,1,I2
,2,R8
,0.5);
7321 VARDIV(UI1
,1,I4
,2,R8
,0.5);
7322 VARDIV(UI1
,1,R4
,2.0f
,R4
,0.5f
);
7323 VARDIV(UI1
,1,R8
,2.0,R8
,0.5);
7324 VARDIV(UI1
,1,DATE
,2,R8
,0.5);
7325 VARDIV(UI1
,1,BSTR
,num2_str
,R8
,0.5);
7326 VARDIV(UI1
,1,BOOL
,VARIANT_TRUE
,R8
,-1);
7327 VARDIV(UI1
,1,UI1
,2,R8
,0.5);
7328 if (HAVE_OLEAUT32_I8
)
7330 VARDIV(UI1
,1,I8
,2,R8
,0.5);
7331 VARDIV(I8
,1,NULL
,0,NULL
,0);
7332 VARDIV(I8
,1,I2
,2,R8
,0.5);
7333 VARDIV(I8
,1,I4
,2,R8
,0.5);
7334 VARDIV(I8
,1,R4
,2.0f
,R8
,0.5);
7335 VARDIV(I8
,1,R8
,2.0,R8
,0.5);
7336 VARDIV(I8
,1,DATE
,2,R8
,0.5);
7337 VARDIV(I8
,1,BSTR
,num2_str
,R8
,0.5);
7338 VARDIV(I8
,1,BOOL
,VARIANT_TRUE
,R8
,-1);
7339 VARDIV(I8
,1,UI1
,2,R8
,0.5);
7340 VARDIV(I8
,1,I8
,2,R8
,0.5);
7343 /* Manually test some VT_CY, VT_DECIMAL variants */
7345 hres
= VarCyFromI4(10000, &V_CY(&cy
));
7346 ok(hres
== S_OK
, "VarCyFromI4 failed!\n");
7347 V_VT(&dec
) = VT_DECIMAL
;
7348 hres
= VarDecFromR8(2.0, &V_DECIMAL(&dec
));
7349 ok(hres
== S_OK
, "VarDecFromR4 failed!\n");
7350 memset(&left
, 0, sizeof(left
));
7351 memset(&right
, 0, sizeof(right
));
7352 V_VT(&left
) = VT_I4
;
7354 V_VT(&right
) = VT_UI1
;
7357 hres
= pVarDiv(&cy
, &cy
, &result
);
7358 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
7359 "VARDIV: expected coerced type VT_R8, got %s!\n", vtstr(V_VT(&result
)));
7360 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 1.0),
7361 "VARDIV: CY value %f, expected %f\n", V_R8(&result
), (double)1.0);
7363 hres
= pVarDiv(&cy
, &right
, &result
);
7364 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
7365 "VARDIV: expected coerced type VT_R8, got %s!\n", vtstr(V_VT(&result
)));
7366 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 5000.0),
7367 "VARDIV: CY value %f, expected %f\n", V_R8(&result
), (double)5000.0);
7369 hres
= pVarDiv(&left
, &cy
, &result
);
7370 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
7371 "VARDIV: expected coerced type VT_R8, got %s!\n", vtstr(V_VT(&result
)));
7372 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 0.01),
7373 "VARDIV: CY value %f, expected %f\n", V_R8(&result
), (double)0.01);
7375 hres
= pVarDiv(&left
, &dec
, &result
);
7376 ok(hres
== S_OK
&& V_VT(&result
) == VT_DECIMAL
,
7377 "VARDIV: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result
)));
7378 hres
= VarR8FromDec(&V_DECIMAL(&result
), &r
);
7379 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 50.0),
7380 "VARDIV: DECIMAL value %f, expected %f\n", r
, (double)50.0);
7382 hres
= pVarDiv(&dec
, &dec
, &result
);
7383 ok(hres
== S_OK
&& V_VT(&result
) == VT_DECIMAL
,
7384 "VARDIV: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result
)));
7385 hres
= VarR8FromDec(&V_DECIMAL(&result
), &r
);
7386 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 1.0),
7387 "VARDIV: DECIMAL value %f, expected %f\n", r
, (double)1.0);
7389 hres
= pVarDiv(&dec
, &right
, &result
);
7390 ok(hres
== S_OK
&& V_VT(&result
) == VT_DECIMAL
,
7391 "VARDIV: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result
)));
7392 hres
= VarR8FromDec(&V_DECIMAL(&result
), &r
);
7393 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 1.0),
7394 "VARDIV: DECIMAL value %f, expected %f\n", r
, (double)1.0);
7396 /* Check for division by zero and overflow */
7397 V_VT(&left
) = VT_R8
;
7399 V_VT(&right
) = VT_R8
;
7401 hres
= pVarDiv(&left
, &right
, &result
);
7402 ok(hres
== DISP_E_DIVBYZERO
&& V_VT(&result
) == VT_EMPTY
,
7403 "VARDIV: Division by (1.0/0.0) should result in DISP_E_DIVBYZERO but got 0x%X\n", hres
);
7405 V_VT(&left
) = VT_R8
;
7407 V_VT(&right
) = VT_R8
;
7409 hres
= pVarDiv(&left
, &right
, &result
);
7410 ok(hres
== DISP_E_OVERFLOW
&& V_VT(&result
) == VT_EMPTY
,
7411 "VARDIV: Division by (0.0/0.0) should result in DISP_E_OVERFLOW but got 0x%X\n", hres
);
7413 SysFreeString(num1_str
);
7414 SysFreeString(num2_str
);
7417 static HRESULT (WINAPI
*pVarIdiv
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
7419 #define VARIDIV(vt1,val1,vt2,val2,rvt,rval) \
7420 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
7421 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
7422 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
7423 test_var_call2( __LINE__, pVarIdiv, &left, &right, &exp )
7425 /* Skip any type that is not defined or produces an error for every case */
7426 #define SKIPTESTIDIV(a) \
7427 if (a == VT_ERROR || a == VT_VARIANT || \
7428 a == VT_DISPATCH || a == VT_UNKNOWN || \
7429 a == VT_RECORD || a > VT_UINT || \
7430 a == 15 /*not defined*/) \
7433 static void test_VarIdiv(void)
7435 static const WCHAR str1
[] = { '1','\0' };
7436 static const WCHAR str2
[] = { '2','\0' };
7437 VARIANT left
, right
, exp
, result
, cy
, dec
;
7438 BSTR num1_str
, num2_str
;
7444 num1_str
= SysAllocString(str1
);
7445 num2_str
= SysAllocString(str2
);
7447 /* Test all possible flag/vt combinations & the resulting vt type */
7448 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
7450 VARTYPE leftvt
, rightvt
, resvt
;
7452 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
7454 SKIPTESTIDIV(leftvt
);
7456 /* Check if we need/have support for I8 and/or UI8 */
7457 if ((leftvt
== VT_I8
|| leftvt
== VT_UI8
) && !HAVE_OLEAUT32_I8
)
7460 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
7463 SKIPTESTIDIV(rightvt
);
7465 /* Native crashes with extra flag VT_BYREF */
7466 if (ExtraFlags
[i
] == VT_BYREF
)
7469 /* Check if we need/have support for I8 and/or UI8 */
7470 if ((rightvt
== VT_I8
|| rightvt
== VT_UI8
) && !HAVE_OLEAUT32_I8
)
7473 memset(&left
, 0, sizeof(left
));
7474 memset(&right
, 0, sizeof(right
));
7475 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
7476 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
7477 V_VT(&result
) = VT_EMPTY
;
7480 if (leftvt
== VT_BSTR
)
7481 V_BSTR(&left
) = num2_str
;
7482 else if (leftvt
== VT_DECIMAL
)
7484 VarDecFromR8(2.0, &V_DECIMAL(&left
));
7485 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
7488 /* Division by 0 is undefined */
7492 V_BSTR(&right
) = num2_str
;
7495 VarDecFromR8(2.0, &V_DECIMAL(&right
));
7496 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
7499 V_BOOL(&right
) = VARIANT_TRUE
;
7502 VarCyFromI4(10000, &V_CY(&right
));
7503 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
7505 case VT_I2
: V_I2(&right
) = 2; break;
7506 case VT_I4
: V_I4(&right
) = 2; break;
7507 case VT_R4
: V_R4(&right
) = 2.0f
; break;
7508 case VT_R8
: V_R8(&right
) = 2.0; break;
7509 case VT_DATE
: V_DATE(&right
) = 2; break;
7510 case VT_I1
: V_I1(&right
) = 2; break;
7511 case VT_UI1
: V_UI1(&right
) = 2; break;
7512 case VT_UI2
: V_UI2(&right
) = 2; break;
7513 case VT_UI4
: V_UI4(&right
) = 2; break;
7514 case VT_I8
: V_I8(&right
) = 2; break;
7515 case VT_UI8
: V_UI8(&right
) = 2; break;
7516 case VT_INT
: V_INT(&right
) = 2; break;
7517 case VT_UINT
: V_UINT(&right
) = 2; break;
7521 /* Native VarIdiv always returns an error when using extra
7522 * flags or if the variant combination is I8 and INT.
7524 if ((leftvt
== VT_I8
&& rightvt
== VT_INT
) ||
7525 (leftvt
== VT_INT
&& rightvt
== VT_I8
) ||
7526 (rightvt
== VT_EMPTY
&& leftvt
!= VT_NULL
) ||
7530 /* Determine variant type */
7531 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
7533 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
7535 else if (leftvt
== VT_I4
|| rightvt
== VT_I4
||
7536 leftvt
== VT_INT
|| rightvt
== VT_INT
||
7537 leftvt
== VT_UINT
|| rightvt
== VT_UINT
||
7538 leftvt
== VT_UI8
|| rightvt
== VT_UI8
||
7539 leftvt
== VT_UI4
|| rightvt
== VT_UI4
||
7540 leftvt
== VT_UI2
|| rightvt
== VT_UI2
||
7541 leftvt
== VT_I1
|| rightvt
== VT_I1
||
7542 leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
||
7543 leftvt
== VT_DATE
|| rightvt
== VT_DATE
||
7544 leftvt
== VT_CY
|| rightvt
== VT_CY
||
7545 leftvt
== VT_DECIMAL
|| rightvt
== VT_DECIMAL
||
7546 leftvt
== VT_R8
|| rightvt
== VT_R8
||
7547 leftvt
== VT_R4
|| rightvt
== VT_R4
)
7549 else if (leftvt
== VT_I2
|| rightvt
== VT_I2
||
7550 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
||
7553 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
7558 hres
= pVarIdiv(&left
, &right
, &result
);
7560 /* Check expected HRESULT and if result variant type is correct */
7562 ok (hres
== DISP_E_BADVARTYPE
|| hres
== DISP_E_TYPEMISMATCH
||
7563 hres
== DISP_E_DIVBYZERO
,
7564 "VarIdiv: %s|0x%X, %s|0x%X: got vt %s hr 0x%X\n",
7565 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
],
7566 vtstr(V_VT(&result
)), hres
);
7568 ok (hres
== S_OK
&& resvt
== V_VT(&result
),
7569 "VarIdiv: %s|0x%X, %s|0x%X: expected vt %s hr 0x%X, got vt %s hr 0x%X\n",
7570 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
], vtstr(resvt
),
7571 S_OK
, vtstr(V_VT(&result
)), hres
);
7576 /* Test return values for all the good cases */
7577 VARIDIV(EMPTY
,0,NULL
,0,NULL
,0);
7578 VARIDIV(EMPTY
,0,I2
,1,I2
,0);
7579 VARIDIV(EMPTY
,0,I4
,1,I4
,0);
7580 VARIDIV(EMPTY
,0,R4
,1.0f
,I4
,0);
7581 VARIDIV(EMPTY
,0,R8
,1.0,I4
,0);
7582 VARIDIV(EMPTY
,0,DATE
,1.0,I4
,0);
7583 VARIDIV(EMPTY
,0,BSTR
,num1_str
,I4
,0);
7584 VARIDIV(EMPTY
,0,BOOL
,VARIANT_TRUE
,I2
,0);
7585 VARIDIV(EMPTY
,0,I1
,1,I4
,0);
7586 VARIDIV(EMPTY
,0,UI1
,1,I2
,0);
7587 VARIDIV(EMPTY
,0,UI2
,1,I4
,0);
7588 VARIDIV(EMPTY
,0,UI4
,1,I4
,0);
7589 if (HAVE_OLEAUT32_I8
)
7591 VARIDIV(EMPTY
,0,I8
,1,I8
,0);
7592 VARIDIV(EMPTY
,0,UI8
,1,I4
,0);
7594 VARIDIV(EMPTY
,0,INT
,1,I4
,0);
7595 VARIDIV(EMPTY
,0,UINT
,1,I4
,0);
7596 VARIDIV(NULL
,0,EMPTY
,0,NULL
,0);
7597 VARIDIV(NULL
,0,NULL
,0,NULL
,0);
7598 VARIDIV(NULL
,0,I2
,1,NULL
,0);
7599 VARIDIV(NULL
,0,I4
,1,NULL
,0);
7600 VARIDIV(NULL
,0,R4
,1,NULL
,0);
7601 VARIDIV(NULL
,0,R8
,1,NULL
,0);
7602 VARIDIV(NULL
,0,DATE
,1,NULL
,0);
7603 VARIDIV(NULL
,0,BSTR
,num1_str
,NULL
,0);
7604 VARIDIV(NULL
,0,BOOL
,VARIANT_TRUE
,NULL
,0);
7605 VARIDIV(NULL
,0,I1
,1,NULL
,0);
7606 VARIDIV(NULL
,0,UI1
,1,NULL
,0);
7607 VARIDIV(NULL
,0,UI2
,1,NULL
,0);
7608 VARIDIV(NULL
,0,UI4
,1,NULL
,0);
7609 if (HAVE_OLEAUT32_I8
)
7611 VARIDIV(NULL
,0,I8
,1,NULL
,0);
7612 VARIDIV(NULL
,0,UI8
,1,NULL
,0);
7614 VARIDIV(NULL
,0,INT
,1,NULL
,0);
7615 VARIDIV(NULL
,0,UINT
,1,NULL
,0);
7616 VARIDIV(I2
,2,NULL
,0,NULL
,0);
7617 VARIDIV(I2
,2,I2
,1,I2
,2);
7618 VARIDIV(I2
,2,I4
,1,I4
,2);
7619 VARIDIV(I2
,2,R4
,1,I4
,2);
7620 VARIDIV(I2
,2,R8
,1,I4
,2);
7621 VARIDIV(I2
,2,DATE
,1,I4
,2);
7622 VARIDIV(I2
,2,BSTR
,num1_str
,I4
,2);
7623 VARIDIV(I2
,2,BOOL
,VARIANT_TRUE
,I2
,-2);
7624 VARIDIV(I2
,2,I1
,1,I4
,2);
7625 VARIDIV(I2
,2,UI1
,1,I2
,2);
7626 VARIDIV(I2
,2,UI2
,1,I4
,2);
7627 VARIDIV(I2
,2,UI4
,1,I4
,2);
7628 if (HAVE_OLEAUT32_I8
)
7630 VARIDIV(I2
,2,I8
,1,I8
,2);
7631 VARIDIV(I2
,2,UI8
,1,I4
,2);
7633 VARIDIV(I2
,2,INT
,1,I4
,2);
7634 VARIDIV(I2
,2,UINT
,1,I4
,2);
7635 VARIDIV(I4
,2,NULL
,0,NULL
,0);
7636 VARIDIV(I4
,2,I2
,1,I4
,2);
7637 VARIDIV(I4
,2,I4
,1,I4
,2);
7638 VARIDIV(I4
,2,R4
,1,I4
,2);
7639 VARIDIV(I4
,2,R8
,1,I4
,2);
7640 VARIDIV(I4
,2,DATE
,1,I4
,2);
7641 VARIDIV(I4
,2,BSTR
,num1_str
,I4
,2);
7642 VARIDIV(I4
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
7643 VARIDIV(I4
,2,I1
,1,I4
,2);
7644 VARIDIV(I4
,2,UI1
,1,I4
,2);
7645 VARIDIV(I4
,2,UI2
,1,I4
,2);
7646 VARIDIV(I4
,2,UI4
,1,I4
,2);
7647 if (HAVE_OLEAUT32_I8
)
7649 VARIDIV(I4
,2,I8
,1,I8
,2);
7650 VARIDIV(I4
,2,UI8
,1,I4
,2);
7652 VARIDIV(I4
,2,INT
,1,I4
,2);
7653 VARIDIV(I4
,2,UINT
,1,I4
,2);
7654 VARIDIV(R4
,2.0f
,NULL
,0,NULL
,0);
7655 VARIDIV(R4
,2.0f
,I2
,1,I4
,2);
7656 VARIDIV(R4
,2.0f
,I4
,1,I4
,2);
7657 VARIDIV(R4
,2.0f
,R4
,1.0f
,I4
,2);
7658 VARIDIV(R4
,2.0f
,R8
,1.0,I4
,2);
7659 VARIDIV(R4
,2.0f
,DATE
,1,I4
,2);
7660 VARIDIV(R4
,2.0f
,BSTR
,num1_str
,I4
,2);
7661 VARIDIV(R4
,2.0f
,BOOL
,VARIANT_TRUE
,I4
,-2);
7662 VARIDIV(R4
,2.0f
,I1
,1,I4
,2);
7663 VARIDIV(R4
,2.0f
,UI1
,1,I4
,2);
7664 VARIDIV(R4
,2.0f
,UI2
,1,I4
,2);
7665 VARIDIV(R4
,2.0f
,UI4
,1,I4
,2);
7666 if (HAVE_OLEAUT32_I8
)
7668 VARIDIV(R4
,2.0f
,I8
,1,I8
,2);
7669 VARIDIV(R4
,2.0f
,UI8
,1,I4
,2);
7671 VARIDIV(R4
,2.0f
,INT
,1,I4
,2);
7672 VARIDIV(R4
,2.0f
,UINT
,1,I4
,2);
7673 VARIDIV(R8
,2.0,NULL
,0,NULL
,0);
7674 VARIDIV(R8
,2.0,I2
,1,I4
,2);
7675 VARIDIV(R8
,2.0,I4
,1,I4
,2);
7676 VARIDIV(R8
,2.0,R4
,1,I4
,2);
7677 VARIDIV(R8
,2.0,R8
,1,I4
,2);
7678 VARIDIV(R8
,2.0,DATE
,1,I4
,2);
7679 VARIDIV(R8
,2.0,BSTR
,num1_str
,I4
,2);
7680 VARIDIV(R8
,2.0,BOOL
,VARIANT_TRUE
,I4
,-2);
7681 VARIDIV(R8
,2.0,I1
,1,I4
,2);
7682 VARIDIV(R8
,2.0,UI1
,1,I4
,2);
7683 VARIDIV(R8
,2.0,UI2
,1,I4
,2);
7684 VARIDIV(R8
,2.0,UI4
,1,I4
,2);
7685 if (HAVE_OLEAUT32_I8
)
7687 VARIDIV(R8
,2.0,I8
,1,I8
,2);
7688 VARIDIV(R8
,2.0,UI8
,1,I4
,2);
7690 VARIDIV(R8
,2.0,INT
,1,I4
,2);
7691 VARIDIV(R8
,2.0,UINT
,1,I4
,2);
7692 VARIDIV(DATE
,2,NULL
,0,NULL
,0);
7693 VARIDIV(DATE
,2,I2
,1,I4
,2);
7694 VARIDIV(DATE
,2,I4
,1,I4
,2);
7695 VARIDIV(DATE
,2,R4
,1,I4
,2);
7696 VARIDIV(DATE
,2,R8
,1,I4
,2);
7697 VARIDIV(DATE
,2,DATE
,1,I4
,2);
7698 VARIDIV(DATE
,2,BSTR
,num1_str
,I4
,2);
7699 VARIDIV(DATE
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
7700 VARIDIV(DATE
,2,I1
,1,I4
,2);
7701 VARIDIV(DATE
,2,UI1
,1,I4
,2);
7702 VARIDIV(DATE
,2,UI2
,1,I4
,2);
7703 VARIDIV(DATE
,2,UI4
,1,I4
,2);
7704 if (HAVE_OLEAUT32_I8
)
7706 VARIDIV(DATE
,2,I8
,1,I8
,2);
7707 VARIDIV(DATE
,2,UI8
,1,I4
,2);
7709 VARIDIV(DATE
,2,INT
,1,I4
,2);
7710 VARIDIV(DATE
,2,UINT
,1,I4
,2);
7711 VARIDIV(BSTR
,num2_str
,NULL
,0,NULL
,0);
7712 VARIDIV(BSTR
,num2_str
,I2
,1,I4
,2);
7713 VARIDIV(BSTR
,num2_str
,I4
,1,I4
,2);
7714 VARIDIV(BSTR
,num2_str
,R4
,1.0f
,I4
,2);
7715 VARIDIV(BSTR
,num2_str
,R8
,1.0,I4
,2);
7716 VARIDIV(BSTR
,num2_str
,DATE
,1,I4
,2);
7717 VARIDIV(BSTR
,num2_str
,BSTR
,num1_str
,I4
,2);
7718 VARIDIV(BSTR
,num2_str
,BOOL
,VARIANT_TRUE
,I4
,-2);
7719 VARIDIV(BSTR
,num2_str
,I1
,1,I4
,2);
7720 VARIDIV(BSTR
,num2_str
,UI1
,1,I4
,2);
7721 VARIDIV(BSTR
,num2_str
,UI2
,1,I4
,2);
7722 VARIDIV(BSTR
,num2_str
,UI4
,1,I4
,2);
7723 if (HAVE_OLEAUT32_I8
)
7725 VARIDIV(BSTR
,num2_str
,I8
,1,I8
,2);
7726 VARIDIV(BSTR
,num2_str
,UI8
,1,I4
,2);
7728 VARIDIV(BSTR
,num2_str
,INT
,1,I4
,2);
7729 VARIDIV(BSTR
,num2_str
,UINT
,1,I4
,2);
7730 VARIDIV(BOOL
,VARIANT_TRUE
,NULL
,0,NULL
,0);
7731 VARIDIV(BOOL
,VARIANT_TRUE
,I2
,1,I2
,-1);
7732 VARIDIV(BOOL
,VARIANT_TRUE
,I4
,1,I4
,-1);
7733 VARIDIV(BOOL
,VARIANT_TRUE
,R4
,1.0f
,I4
,-1);
7734 VARIDIV(BOOL
,VARIANT_TRUE
,R8
,1.0,I4
,-1);
7735 VARIDIV(BOOL
,VARIANT_TRUE
,DATE
,1,I4
,-1);
7736 VARIDIV(BOOL
,VARIANT_TRUE
,BSTR
,num1_str
,I4
,-1);
7737 VARIDIV(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
,I2
,1);
7738 VARIDIV(BOOL
,VARIANT_TRUE
,I1
,1,I4
,-1);
7739 VARIDIV(BOOL
,VARIANT_TRUE
,UI1
,1,I2
,-1);
7740 VARIDIV(BOOL
,VARIANT_TRUE
,UI2
,1,I4
,-1);
7741 VARIDIV(BOOL
,VARIANT_TRUE
,UI4
,1,I4
,-1);
7742 if (HAVE_OLEAUT32_I8
)
7744 VARIDIV(BOOL
,VARIANT_TRUE
,I8
,1,I8
,-1);
7745 VARIDIV(BOOL
,VARIANT_TRUE
,UI8
,1,I4
,-1);
7747 VARIDIV(BOOL
,VARIANT_TRUE
,INT
,1,I4
,-1);
7748 VARIDIV(BOOL
,VARIANT_TRUE
,UINT
,1,I4
,-1);
7749 VARIDIV(I1
,2,NULL
,0,NULL
,0);
7750 VARIDIV(I1
,2,I2
,1,I4
,2);
7751 VARIDIV(I1
,2,I4
,1,I4
,2);
7752 VARIDIV(I1
,2,R4
,1.0f
,I4
,2);
7753 VARIDIV(I1
,2,R8
,1.0,I4
,2);
7754 VARIDIV(I1
,2,DATE
,1,I4
,2);
7755 VARIDIV(I1
,2,BSTR
,num1_str
,I4
,2);
7756 VARIDIV(I1
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
7757 VARIDIV(I1
,2,I1
,1,I4
,2);
7758 VARIDIV(I1
,2,UI1
,1,I4
,2);
7759 VARIDIV(I1
,2,UI2
,1,I4
,2);
7760 VARIDIV(I1
,2,UI4
,1,I4
,2);
7761 if (HAVE_OLEAUT32_I8
)
7763 VARIDIV(I1
,2,I8
,1,I8
,2);
7764 VARIDIV(I1
,2,UI8
,1,I4
,2);
7766 VARIDIV(I1
,2,INT
,1,I4
,2);
7767 VARIDIV(I1
,2,UINT
,1,I4
,2);
7768 VARIDIV(UI1
,2,NULL
,0,NULL
,0);
7769 VARIDIV(UI1
,2,I2
,1,I2
,2);
7770 VARIDIV(UI1
,2,I4
,1,I4
,2);
7771 VARIDIV(UI1
,2,R4
,1.0f
,I4
,2);
7772 VARIDIV(UI1
,2,R8
,1.0,I4
,2);
7773 VARIDIV(UI1
,2,DATE
,1,I4
,2);
7774 VARIDIV(UI1
,2,BSTR
,num1_str
,I4
,2);
7775 VARIDIV(UI1
,2,BOOL
,VARIANT_TRUE
,I2
,-2);
7776 VARIDIV(UI1
,2,I1
,1,I4
,2);
7777 VARIDIV(UI1
,2,UI1
,1,UI1
,2);
7778 VARIDIV(UI1
,2,UI2
,1,I4
,2);
7779 VARIDIV(UI1
,2,UI4
,1,I4
,2);
7780 if (HAVE_OLEAUT32_I8
)
7782 VARIDIV(UI1
,2,I8
,1,I8
,2);
7783 VARIDIV(UI1
,2,UI8
,1,I4
,2);
7785 VARIDIV(UI1
,2,INT
,1,I4
,2);
7786 VARIDIV(UI1
,2,UINT
,1,I4
,2);
7787 VARIDIV(UI2
,2,NULL
,0,NULL
,0);
7788 VARIDIV(UI2
,2,I2
,1,I4
,2);
7789 VARIDIV(UI2
,2,I4
,1,I4
,2);
7790 VARIDIV(UI2
,2,R4
,1.0f
,I4
,2);
7791 VARIDIV(UI2
,2,R8
,1.0,I4
,2);
7792 VARIDIV(UI2
,2,DATE
,1,I4
,2);
7793 VARIDIV(UI2
,2,BSTR
,num1_str
,I4
,2);
7794 VARIDIV(UI2
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
7795 VARIDIV(UI2
,2,I1
,1,I4
,2);
7796 VARIDIV(UI2
,2,UI1
,1,I4
,2);
7797 VARIDIV(UI2
,2,UI2
,1,I4
,2);
7798 VARIDIV(UI2
,2,UI4
,1,I4
,2);
7799 if (HAVE_OLEAUT32_I8
)
7801 VARIDIV(UI2
,2,I8
,1,I8
,2);
7802 VARIDIV(UI2
,2,UI8
,1,I4
,2);
7804 VARIDIV(UI2
,2,INT
,1,I4
,2);
7805 VARIDIV(UI2
,2,UINT
,1,I4
,2);
7806 VARIDIV(UI4
,2,NULL
,0,NULL
,0);
7807 VARIDIV(UI4
,2,I2
,1,I4
,2);
7808 VARIDIV(UI4
,2,I4
,1,I4
,2);
7809 VARIDIV(UI4
,2,R4
,1.0f
,I4
,2);
7810 VARIDIV(UI4
,2,R8
,1.0,I4
,2);
7811 VARIDIV(UI4
,2,DATE
,1,I4
,2);
7812 VARIDIV(UI4
,2,BSTR
,num1_str
,I4
,2);
7813 VARIDIV(UI4
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
7814 VARIDIV(UI4
,2,I1
,1,I4
,2);
7815 VARIDIV(UI4
,2,UI1
,1,I4
,2);
7816 VARIDIV(UI4
,2,UI2
,1,I4
,2);
7817 VARIDIV(UI4
,2,UI4
,1,I4
,2);
7818 if (HAVE_OLEAUT32_I8
)
7820 VARIDIV(UI4
,2,I8
,1,I8
,2);
7821 VARIDIV(UI4
,2,UI8
,1,I4
,2);
7823 VARIDIV(UI4
,2,INT
,1,I4
,2);
7824 VARIDIV(UI4
,2,UINT
,1,I4
,2);
7825 if (HAVE_OLEAUT32_I8
)
7827 VARIDIV(I8
,2,NULL
,0,NULL
,0);
7828 VARIDIV(I8
,2,I2
,1,I8
,2);
7829 VARIDIV(I8
,2,I4
,1,I8
,2);
7830 VARIDIV(I8
,2,R4
,1.0f
,I8
,2);
7831 VARIDIV(I8
,2,R8
,1.0,I8
,2);
7832 VARIDIV(I8
,2,DATE
,1,I8
,2);
7833 VARIDIV(I8
,2,BSTR
,num1_str
,I8
,2);
7834 VARIDIV(I8
,2,BOOL
,1,I8
,2);
7835 VARIDIV(I8
,2,I1
,1,I8
,2);
7836 VARIDIV(I8
,2,UI1
,1,I8
,2);
7837 VARIDIV(I8
,2,UI2
,1,I8
,2);
7838 VARIDIV(I8
,2,UI4
,1,I8
,2);
7839 VARIDIV(I8
,2,I8
,1,I8
,2);
7840 VARIDIV(I8
,2,UI8
,1,I8
,2);
7841 VARIDIV(I8
,2,UINT
,1,I8
,2);
7842 VARIDIV(UI8
,2,NULL
,0,NULL
,0);
7843 VARIDIV(UI8
,2,I2
,1,I4
,2);
7844 VARIDIV(UI8
,2,I4
,1,I4
,2);
7845 VARIDIV(UI8
,2,R4
,1.0f
,I4
,2);
7846 VARIDIV(UI8
,2,R8
,1.0,I4
,2);
7847 VARIDIV(UI8
,2,DATE
,1,I4
,2);
7848 VARIDIV(UI8
,2,BSTR
,num1_str
,I4
,2);
7849 VARIDIV(UI8
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
7850 VARIDIV(UI8
,2,I1
,1,I4
,2);
7851 VARIDIV(UI8
,2,UI1
,1,I4
,2);
7852 VARIDIV(UI8
,2,UI2
,1,I4
,2);
7853 VARIDIV(UI8
,2,UI4
,1,I4
,2);
7854 VARIDIV(UI8
,2,I8
,1,I8
,2);
7855 VARIDIV(UI8
,2,UI8
,1,I4
,2);
7856 VARIDIV(UI8
,2,INT
,1,I4
,2);
7857 VARIDIV(UI8
,2,UINT
,1,I4
,2);
7859 VARIDIV(INT
,2,NULL
,0,NULL
,0);
7860 VARIDIV(INT
,2,I2
,1,I4
,2);
7861 VARIDIV(INT
,2,I4
,1,I4
,2);
7862 VARIDIV(INT
,2,R4
,1.0f
,I4
,2);
7863 VARIDIV(INT
,2,R8
,1.0,I4
,2);
7864 VARIDIV(INT
,2,DATE
,1,I4
,2);
7865 VARIDIV(INT
,2,BSTR
,num1_str
,I4
,2);
7866 VARIDIV(INT
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
7867 VARIDIV(INT
,2,I1
,1,I4
,2);
7868 VARIDIV(INT
,2,UI1
,1,I4
,2);
7869 VARIDIV(INT
,2,UI2
,1,I4
,2);
7870 VARIDIV(INT
,2,UI4
,1,I4
,2);
7871 if (HAVE_OLEAUT32_I8
)
7873 VARIDIV(INT
,2,UI8
,1,I4
,2);
7875 VARIDIV(INT
,2,INT
,1,I4
,2);
7876 VARIDIV(INT
,2,UINT
,1,I4
,2);
7877 VARIDIV(UINT
,2,NULL
,0,NULL
,0);
7878 VARIDIV(UINT
,2,I2
,1,I4
,2);
7879 VARIDIV(UINT
,2,I4
,1,I4
,2);
7880 VARIDIV(UINT
,2,R4
,1.0f
,I4
,2);
7881 VARIDIV(UINT
,2,R8
,1.0,I4
,2);
7882 VARIDIV(UINT
,2,DATE
,1,I4
,2);
7883 VARIDIV(UINT
,2,BSTR
,num1_str
,I4
,2);
7884 VARIDIV(UINT
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
7885 VARIDIV(UINT
,2,I1
,1,I4
,2);
7886 VARIDIV(UINT
,2,UI1
,1,I4
,2);
7887 VARIDIV(UINT
,2,UI2
,1,I4
,2);
7888 VARIDIV(UINT
,2,UI4
,1,I4
,2);
7889 if (HAVE_OLEAUT32_I8
)
7891 VARIDIV(UINT
,2,I8
,1,I8
,2);
7892 VARIDIV(UINT
,2,UI8
,1,I4
,2);
7894 VARIDIV(UINT
,2,INT
,1,I4
,2);
7895 VARIDIV(UINT
,2,UINT
,1,I4
,2);
7897 /* Manually test some VT_CY, VT_DECIMAL variants */
7899 hres
= VarCyFromI4(10000, &V_CY(&cy
));
7900 ok(hres
== S_OK
, "VarCyFromI4 failed!\n");
7901 V_VT(&dec
) = VT_DECIMAL
;
7902 hres
= VarDecFromR8(2.0, &V_DECIMAL(&dec
));
7903 ok(hres
== S_OK
, "VarDecFromR4 failed!\n");
7904 memset(&left
, 0, sizeof(left
));
7905 memset(&right
, 0, sizeof(right
));
7906 V_VT(&left
) = VT_I4
;
7908 V_VT(&right
) = VT_I8
;
7911 hres
= VarIdiv(&cy
, &cy
, &result
);
7912 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
7913 "VARIDIV: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
7914 S_OK
, hres
, vtstr(V_VT(&result
)));
7915 ok(hres
== S_OK
&& V_I4(&result
) == 1,
7916 "VARIDIV: CY value %d, expected %d\n", V_I4(&result
), 1);
7918 if (HAVE_OLEAUT32_I8
)
7920 hres
= VarIdiv(&cy
, &right
, &result
);
7921 ok(hres
== S_OK
&& V_VT(&result
) == VT_I8
,
7922 "VARIDIV: expected coerced hres 0x%X type VT_I8, got hres 0x%X type %s!\n",
7923 S_OK
, hres
, vtstr(V_VT(&result
)));
7924 ok(hres
== S_OK
&& V_I8(&result
) == 5000,
7925 "VARIDIV: CY value 0x%x%08x, expected 0x%x\n",
7926 (DWORD
)(V_I8(&result
) >>32), (DWORD
)V_I8(&result
), 5000);
7929 hres
= VarIdiv(&left
, &cy
, &result
);
7930 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
7931 "VARIDIV: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
7932 S_OK
, hres
, vtstr(V_VT(&result
)));
7933 ok(hres
== S_OK
&& V_I4(&result
) == 0,
7934 "VARIDIV: CY value %d, expected %d\n", V_I4(&result
), 0);
7936 hres
= VarIdiv(&left
, &dec
, &result
);
7937 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
7938 "VARIDIV: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
7939 S_OK
, hres
, vtstr(V_VT(&result
)));
7940 ok(hres
== S_OK
&& V_I4(&result
) == 50,
7941 "VARIDIV: DECIMAL value %d, expected %d\n", V_I4(&result
), 50);
7943 hres
= VarIdiv(&dec
, &dec
, &result
);
7944 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
7945 "VARIDIV: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
7946 S_OK
, hres
, vtstr(V_VT(&result
)));
7947 ok(hres
== S_OK
&& V_I4(&result
) == 1,
7948 "VARIDIV: DECIMAL value %d, expected %d\n", V_I4(&result
), 1);
7950 if (HAVE_OLEAUT32_I8
)
7952 hres
= VarIdiv(&dec
, &right
, &result
);
7953 ok(hres
== S_OK
&& V_VT(&result
) == VT_I8
,
7954 "VARIDIV: expected coerced hres 0x%X type VT_I8, got hres 0x%X type %s!\n",
7955 S_OK
, hres
, vtstr(V_VT(&result
)));
7956 ok(hres
== S_OK
&& V_I8(&result
) == 1,
7957 "VARIDIV: DECIMAL value 0x%x%08x, expected %d\n",
7958 (DWORD
)(V_I8(&result
) >> 32), (DWORD
)V_I8(&result
), 1);
7961 /* Check for division by zero */
7962 V_VT(&left
) = VT_INT
;
7964 V_VT(&right
) = VT_INT
;
7966 hres
= pVarIdiv(&left
, &right
, &result
);
7967 ok(hres
== DISP_E_DIVBYZERO
&& V_VT(&result
) == VT_EMPTY
,
7968 "VARIDIV: Division by 0 should result in DISP_E_DIVBYZERO but got 0x%X\n", hres
);
7970 V_VT(&left
) = VT_INT
;
7972 V_VT(&right
) = VT_INT
;
7974 hres
= pVarIdiv(&left
, &right
, &result
);
7975 ok(hres
== DISP_E_DIVBYZERO
&& V_VT(&result
) == VT_EMPTY
,
7976 "VARIDIV: Division by 0 should result in DISP_E_DIVBYZERO but got 0x%X\n", hres
);
7978 SysFreeString(num1_str
);
7979 SysFreeString(num2_str
);
7983 static HRESULT (WINAPI
*pVarImp
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
7985 #define VARIMP(vt1,val1,vt2,val2,rvt,rval) \
7986 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
7987 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
7988 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
7989 test_var_call2( __LINE__, pVarImp, &left, &right, &exp )
7991 /* Skip any type that is not defined or produces an error for every case */
7992 #define SKIPTESTIMP(a) \
7993 if (a == VT_ERROR || a == VT_VARIANT || \
7994 a == VT_DISPATCH || a == VT_UNKNOWN || \
7995 a == VT_RECORD || a > VT_UINT || \
7996 a == 15 /*not defined*/) \
7999 static void test_VarImp(void)
8001 static const WCHAR szFalse
[] = { '#','F','A','L','S','E','#','\0' };
8002 static const WCHAR szTrue
[] = { '#','T','R','U','E','#','\0' };
8003 VARIANT left
, right
, exp
, result
, cy
, dec
;
8004 BSTR true_str
, false_str
;
8010 true_str
= SysAllocString(szTrue
);
8011 false_str
= SysAllocString(szFalse
);
8013 /* Test all possible flag/vt combinations & the resulting vt type */
8014 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
8016 VARTYPE leftvt
, rightvt
, resvt
;
8018 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
8020 SKIPTESTIMP(leftvt
);
8022 /* Check if we need/have support for I8 and/or UI8 */
8023 if ((leftvt
== VT_I8
|| leftvt
== VT_UI8
) && !HAVE_OLEAUT32_I8
)
8026 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
8029 SKIPTESTIMP(rightvt
);
8031 /* Native crashes when using the extra flag VT_BYREF
8032 * or with the following VT combinations
8034 if ((leftvt
== VT_UI4
&& rightvt
== VT_BSTR
) ||
8035 (leftvt
== VT_UI8
&& rightvt
== VT_BSTR
) ||
8036 ExtraFlags
[i
] == VT_BYREF
)
8039 /* Check if we need/have support for I8 and/or UI8 */
8040 if ((rightvt
== VT_I8
|| rightvt
== VT_UI8
) && !HAVE_OLEAUT32_I8
)
8043 memset(&left
, 0, sizeof(left
));
8044 memset(&right
, 0, sizeof(right
));
8045 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
8046 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
8047 V_VT(&result
) = VT_EMPTY
;
8050 if (leftvt
== VT_BSTR
)
8051 V_BSTR(&left
) = true_str
;
8053 /* This allows us to test return types that are not NULL
8054 * (NULL Imp value = n, NULL Imp 0 = NULL)
8059 V_BSTR(&right
) = true_str
;
8062 VarDecFromR8(2.0, &V_DECIMAL(&right
));
8063 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
8066 V_BOOL(&right
) = VARIANT_TRUE
;
8068 case VT_I1
: V_I1(&right
) = 2; break;
8069 case VT_I2
: V_I2(&right
) = 2; break;
8070 case VT_I4
: V_I4(&right
) = 2; break;
8071 case VT_R4
: V_R4(&right
) = 2.0f
; break;
8072 case VT_R8
: V_R8(&right
) = 2.0; break;
8073 case VT_CY
: V_CY(&right
).int64
= 10000; break;
8074 case VT_DATE
: V_DATE(&right
) = 2; break;
8075 case VT_I8
: V_I8(&right
) = 2; break;
8076 case VT_INT
: V_INT(&right
) = 2; break;
8077 case VT_UINT
: V_UINT(&right
) = 2; break;
8078 case VT_UI1
: V_UI1(&right
) = 2; break;
8079 case VT_UI2
: V_UI2(&right
) = 2; break;
8080 case VT_UI4
: V_UI4(&right
) = 2; break;
8081 case VT_UI8
: V_UI8(&right
) = 2; break;
8085 /* Native VarImp always returns an error when using extra
8086 * flags or if the variants are I8 and INT.
8088 if ((leftvt
== VT_I8
&& rightvt
== VT_INT
) ||
8092 /* Determine result type */
8093 else if ((leftvt
== VT_BSTR
&& rightvt
== VT_NULL
) ||
8094 (leftvt
== VT_NULL
&& rightvt
== VT_NULL
) ||
8095 (leftvt
== VT_NULL
&& rightvt
== VT_EMPTY
))
8097 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
8099 else if (leftvt
== VT_I4
|| rightvt
== VT_I4
||
8100 leftvt
== VT_INT
|| rightvt
== VT_INT
||
8101 leftvt
== VT_UINT
|| rightvt
== VT_UINT
||
8102 leftvt
== VT_UI4
|| rightvt
== VT_UI4
||
8103 leftvt
== VT_UI8
|| rightvt
== VT_UI8
||
8104 leftvt
== VT_UI2
|| rightvt
== VT_UI2
||
8105 leftvt
== VT_DECIMAL
|| rightvt
== VT_DECIMAL
||
8106 leftvt
== VT_DATE
|| rightvt
== VT_DATE
||
8107 leftvt
== VT_CY
|| rightvt
== VT_CY
||
8108 leftvt
== VT_R8
|| rightvt
== VT_R8
||
8109 leftvt
== VT_R4
|| rightvt
== VT_R4
||
8110 leftvt
== VT_I1
|| rightvt
== VT_I1
)
8112 else if ((leftvt
== VT_UI1
&& rightvt
== VT_UI1
) ||
8113 (leftvt
== VT_UI1
&& rightvt
== VT_NULL
) ||
8114 (leftvt
== VT_NULL
&& rightvt
== VT_UI1
))
8116 else if (leftvt
== VT_EMPTY
|| rightvt
== VT_EMPTY
||
8117 leftvt
== VT_I2
|| rightvt
== VT_I2
||
8118 leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
8120 else if (leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
||
8121 leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
)
8124 hres
= pVarImp(&left
, &right
, &result
);
8126 /* Check expected HRESULT and if result variant type is correct */
8128 ok (hres
== DISP_E_BADVARTYPE
|| hres
== DISP_E_TYPEMISMATCH
,
8129 "VarImp: %s|0x%X, %s|0x%X: got vt %s hr 0x%X\n",
8130 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
],
8131 vtstr(V_VT(&result
)), hres
);
8133 ok (hres
== S_OK
&& resvt
== V_VT(&result
),
8134 "VarImp: %s|0x%X, %s|0x%X: expected vt %s hr 0x%X, got vt %s hr 0x%X\n",
8135 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
], vtstr(resvt
),
8136 S_OK
, vtstr(V_VT(&result
)), hres
);
8141 VARIMP(EMPTY
,0,EMPTY
,0,I2
,-1);
8142 VARIMP(EMPTY
,0,NULL
,0,I2
,-1);
8143 VARIMP(EMPTY
,0,I2
,-1,I2
,-1);
8144 VARIMP(EMPTY
,0,I4
,-1,I4
,-1);
8145 VARIMP(EMPTY
,0,R4
,0.0f
,I4
,-1);
8146 VARIMP(EMPTY
,0,R8
,-1.0,I4
,-1);
8147 VARIMP(EMPTY
,0,DATE
,0,I4
,-1);
8148 VARIMP(EMPTY
,0,BSTR
,true_str
,I2
,-1);
8149 VARIMP(EMPTY
,0,BOOL
,VARIANT_FALSE
,I2
,-1);
8150 VARIMP(EMPTY
,0,I1
,0,I4
,-1);
8151 VARIMP(EMPTY
,0,UI1
,1,I2
,-1);
8152 VARIMP(EMPTY
,0,UI2
,1,I4
,-1);
8153 VARIMP(EMPTY
,0,UI4
,1,I4
,-1);
8154 if (HAVE_OLEAUT32_I8
)
8156 VARIMP(EMPTY
,0,I8
,1,I8
,-1);
8157 VARIMP(EMPTY
,0,UI8
,1,I4
,-1);
8159 VARIMP(EMPTY
,0,INT
,-1,I4
,-1);
8160 VARIMP(EMPTY
,0,UINT
,1,I4
,-1);
8161 VARIMP(NULL
,0,EMPTY
,0,NULL
,0);
8162 VARIMP(NULL
,0,NULL
,0,NULL
,0);
8163 VARIMP(NULL
,0,I2
,-1,I2
,-1);
8164 VARIMP(NULL
,0,I4
,-1,I4
,-1);
8165 VARIMP(NULL
,0,R4
,0.0f
,NULL
,0);
8166 VARIMP(NULL
,0,R8
,-1.0,I4
,-1);
8167 VARIMP(NULL
,0,DATE
,0,NULL
,0);
8168 VARIMP(NULL
,0,BSTR
,true_str
,BOOL
,-1);
8169 VARIMP(NULL
,0,BOOL
,VARIANT_FALSE
,NULL
,0);
8170 VARIMP(NULL
,0,I1
,0,NULL
,0);
8171 VARIMP(NULL
,0,UI1
,1,UI1
,1);
8172 VARIMP(NULL
,0,UI2
,1,I4
,1);
8173 VARIMP(NULL
,0,UI4
,1,I4
,1);
8174 if (HAVE_OLEAUT32_I8
)
8176 VARIMP(NULL
,0,I8
,1,I8
,1);
8177 VARIMP(NULL
,0,UI8
,1,I4
,1);
8179 VARIMP(NULL
,0,INT
,-1,I4
,-1);
8180 VARIMP(NULL
,0,UINT
,1,I4
,1);
8181 VARIMP(I2
,-1,EMPTY
,0,I2
,0);
8182 VARIMP(I2
,-1,I2
,-1,I2
,-1);
8183 VARIMP(I2
,-1,I4
,-1,I4
,-1);
8184 VARIMP(I2
,-1,R4
,0.0f
,I4
,0);
8185 VARIMP(I2
,-1,R8
,-1.0,I4
,-1);
8186 VARIMP(I2
,-1,DATE
,0,I4
,0);
8187 VARIMP(I2
,-1,BSTR
,true_str
,I2
,-1);
8188 VARIMP(I2
,-1,BOOL
,VARIANT_FALSE
,I2
,0);
8189 VARIMP(I2
,-1,I1
,0,I4
,0);
8190 VARIMP(I2
,-1,UI1
,1,I2
,1);
8191 VARIMP(I2
,-1,UI2
,1,I4
,1);
8192 VARIMP(I2
,-1,UI4
,1,I4
,1);
8193 if (HAVE_OLEAUT32_I8
)
8195 VARIMP(I2
,-1,I8
,1,I8
,1);
8196 VARIMP(I2
,-1,UI8
,1,I4
,1);
8198 VARIMP(I2
,-1,INT
,-1,I4
,-1);
8199 VARIMP(I2
,-1,UINT
,1,I4
,1);
8200 VARIMP(I4
,2,EMPTY
,0,I4
,-3);
8201 VARIMP(I4
,2,NULL
,0,I4
,-3);
8202 VARIMP(I4
,2,I2
,-1,I4
,-1);
8203 VARIMP(I4
,2,I4
,-1,I4
,-1);
8204 VARIMP(I4
,2,R4
,0.0f
,I4
,-3);
8205 VARIMP(I4
,2,R8
,-1.0,I4
,-1);
8206 VARIMP(I4
,2,DATE
,0,I4
,-3);
8207 VARIMP(I4
,2,BSTR
,true_str
,I4
,-1);
8208 VARIMP(I4
,2,BOOL
,VARIANT_FALSE
,I4
,-3);
8209 VARIMP(I4
,2,I1
,0,I4
,-3);
8210 VARIMP(I4
,2,UI1
,1,I4
,-3);
8211 VARIMP(I4
,2,UI2
,1,I4
,-3);
8212 VARIMP(I4
,2,UI4
,1,I4
,-3);
8213 if (HAVE_OLEAUT32_I8
)
8215 VARIMP(I4
,2,I8
,1,I8
,-3);
8216 VARIMP(I4
,2,UI8
,1,I4
,-3);
8218 VARIMP(I4
,2,INT
,-1,I4
,-1);
8219 VARIMP(I4
,2,UINT
,1,I4
,-3);
8220 VARIMP(R4
,-1.0f
,EMPTY
,0,I4
,0);
8221 VARIMP(R4
,-1.0f
,NULL
,0,NULL
,0);
8222 VARIMP(R4
,-1.0f
,I2
,-1,I4
,-1);
8223 VARIMP(R4
,-1.0f
,I4
,-1,I4
,-1);
8224 VARIMP(R4
,-1.0f
,R4
,0.0f
,I4
,0);
8225 VARIMP(R4
,-1.0f
,R8
,-1.0,I4
,-1);
8226 VARIMP(R4
,-1.0f
,DATE
,1,I4
,1);
8227 VARIMP(R4
,-1.0f
,BSTR
,true_str
,I4
,-1);
8228 VARIMP(R4
,-1.0f
,BOOL
,VARIANT_FALSE
,I4
,0);
8229 VARIMP(R4
,-1.0f
,I1
,0,I4
,0);
8230 VARIMP(R4
,-1.0f
,UI1
,1,I4
,1);
8231 VARIMP(R4
,-1.0f
,UI2
,1,I4
,1);
8232 VARIMP(R4
,-1.0f
,UI4
,1,I4
,1);
8233 if (HAVE_OLEAUT32_I8
)
8235 VARIMP(R4
,-1.0f
,I8
,1,I8
,1);
8236 VARIMP(R4
,-1.0f
,UI8
,1,I4
,1);
8238 VARIMP(R4
,-1.0f
,INT
,-1,I4
,-1);
8239 VARIMP(R4
,-1.0f
,UINT
,1,I4
,1);
8240 VARIMP(R8
,1.0,EMPTY
,0,I4
,-2);
8241 VARIMP(R8
,1.0,NULL
,0,I4
,-2);
8242 VARIMP(R8
,1.0,I2
,-1,I4
,-1);
8243 VARIMP(R8
,1.0,I4
,-1,I4
,-1);
8244 VARIMP(R8
,1.0,R4
,0.0f
,I4
,-2);
8245 VARIMP(R8
,1.0,R8
,-1.0,I4
,-1);
8246 VARIMP(R8
,1.0,DATE
,0,I4
,-2);
8247 VARIMP(R8
,1.0,BSTR
,true_str
,I4
,-1);
8248 VARIMP(R8
,1.0,BOOL
,VARIANT_FALSE
,I4
,-2);
8249 VARIMP(R8
,1.0,I1
,0,I4
,-2);
8250 VARIMP(R8
,1.0,UI1
,1,I4
,-1);
8251 VARIMP(R8
,1.0,UI2
,1,I4
,-1);
8252 VARIMP(R8
,1.0,UI4
,1,I4
,-1);
8253 if (HAVE_OLEAUT32_I8
)
8255 VARIMP(R8
,1.0,I8
,1,I8
,-1);
8256 VARIMP(R8
,1.0,UI8
,1,I4
,-1);
8258 VARIMP(R8
,1.0,INT
,-1,I4
,-1);
8259 VARIMP(R8
,1.0,UINT
,1,I4
,-1);
8260 VARIMP(DATE
,0,EMPTY
,0,I4
,-1);
8261 VARIMP(DATE
,0,NULL
,0,I4
,-1);
8262 VARIMP(DATE
,0,I2
,-1,I4
,-1);
8263 VARIMP(DATE
,0,I4
,-1,I4
,-1);
8264 VARIMP(DATE
,0,R4
,0.0f
,I4
,-1);
8265 VARIMP(DATE
,0,R8
,-1.0,I4
,-1);
8266 VARIMP(DATE
,0,DATE
,0,I4
,-1);
8267 VARIMP(DATE
,0,BSTR
,true_str
,I4
,-1);
8268 VARIMP(DATE
,0,BOOL
,VARIANT_FALSE
,I4
,-1);
8269 VARIMP(DATE
,0,I1
,0,I4
,-1);
8270 VARIMP(DATE
,0,UI1
,1,I4
,-1);
8271 VARIMP(DATE
,0,UI2
,1,I4
,-1);
8272 VARIMP(DATE
,0,UI4
,1,I4
,-1);
8273 if (HAVE_OLEAUT32_I8
)
8275 VARIMP(DATE
,0,I8
,1,I8
,-1);
8276 VARIMP(DATE
,0,UI8
,1,I4
,-1);
8278 VARIMP(DATE
,0,INT
,-1,I4
,-1);
8279 VARIMP(DATE
,0,UINT
,1,I4
,-1);
8280 VARIMP(BSTR
,false_str
,EMPTY
,0,I2
,-1);
8281 VARIMP(BSTR
,false_str
,NULL
,0,BOOL
,-1);
8282 VARIMP(BSTR
,false_str
,I2
,-1,I2
,-1);
8283 VARIMP(BSTR
,false_str
,I4
,-1,I4
,-1);
8284 VARIMP(BSTR
,false_str
,R4
,0.0f
,I4
,-1);
8285 VARIMP(BSTR
,false_str
,R8
,-1.0,I4
,-1);
8286 VARIMP(BSTR
,false_str
,DATE
,0,I4
,-1);
8287 VARIMP(BSTR
,false_str
,BSTR
,true_str
,BOOL
,-1);
8288 VARIMP(BSTR
,false_str
,BOOL
,VARIANT_FALSE
,BOOL
,-1);
8289 VARIMP(BSTR
,false_str
,I1
,0,I4
,-1);
8290 VARIMP(BSTR
,false_str
,UI1
,1,I2
,-1);
8291 VARIMP(BSTR
,false_str
,UI2
,1,I4
,-1);
8292 VARIMP(BSTR
,false_str
,UI4
,1,I4
,-1);
8293 if (HAVE_OLEAUT32_I8
)
8295 VARIMP(BSTR
,false_str
,I8
,1,I8
,-1);
8296 VARIMP(BSTR
,false_str
,UI8
,1,I4
,-1);
8298 VARIMP(BSTR
,false_str
,INT
,-1,I4
,-1);
8299 VARIMP(BSTR
,false_str
,UINT
,1,I4
,-1);
8300 VARIMP(BOOL
,VARIANT_TRUE
,EMPTY
,0,I2
,0);
8301 VARIMP(BOOL
,VARIANT_TRUE
,NULL
,0,NULL
,0);
8302 VARIMP(BOOL
,VARIANT_TRUE
,I2
,-1,I2
,-1);
8303 VARIMP(BOOL
,VARIANT_TRUE
,I4
,-1,I4
,-1);
8304 VARIMP(BOOL
,VARIANT_TRUE
,R4
,0.0f
,I4
,0);
8305 VARIMP(BOOL
,VARIANT_TRUE
,R8
,-1.0,I4
,-1);
8306 VARIMP(BOOL
,VARIANT_TRUE
,DATE
,0,I4
,0);
8307 VARIMP(BOOL
,VARIANT_TRUE
,BSTR
,true_str
,BOOL
,-1);
8308 VARIMP(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
,BOOL
,0);
8309 VARIMP(BOOL
,VARIANT_TRUE
,I1
,0,I4
,0);
8310 VARIMP(BOOL
,VARIANT_TRUE
,UI1
,1,I2
,1);
8311 VARIMP(BOOL
,VARIANT_TRUE
,UI2
,1,I4
,1);
8312 VARIMP(BOOL
,VARIANT_TRUE
,UI4
,1,I4
,1);
8313 if (HAVE_OLEAUT32_I8
)
8315 VARIMP(BOOL
,VARIANT_TRUE
,I8
,1,I8
,1);
8316 VARIMP(BOOL
,VARIANT_TRUE
,UI8
,1,I4
,1);
8318 VARIMP(BOOL
,VARIANT_TRUE
,INT
,-1,I4
,-1);
8319 VARIMP(BOOL
,VARIANT_TRUE
,UINT
,1,I4
,1);
8320 VARIMP(I1
,-1,EMPTY
,0,I4
,0);
8321 VARIMP(I1
,-1,NULL
,0,NULL
,0);
8322 VARIMP(I1
,-1,I2
,-1,I4
,-1);
8323 VARIMP(I1
,-1,I4
,-1,I4
,-1);
8324 VARIMP(I1
,-1,R4
,0.0f
,I4
,0);
8325 VARIMP(I1
,-1,R8
,-1.0,I4
,-1);
8326 VARIMP(I1
,-1,DATE
,0,I4
,0);
8327 VARIMP(I1
,-1,BSTR
,true_str
,I4
,-1);
8328 VARIMP(I1
,-1,BOOL
,VARIANT_FALSE
,I4
,0);
8329 VARIMP(I1
,-1,I1
,0,I4
,0);
8330 VARIMP(I1
,-1,UI1
,1,I4
,1);
8331 VARIMP(I1
,-1,UI2
,1,I4
,1);
8332 VARIMP(I1
,-1,UI4
,1,I4
,1);
8333 if (HAVE_OLEAUT32_I8
)
8335 VARIMP(I1
,-1,I8
,1,I8
,1);
8336 VARIMP(I1
,-1,UI8
,1,I4
,1);
8338 VARIMP(I1
,-1,INT
,-1,I4
,-1);
8339 VARIMP(I1
,-1,UINT
,1,I4
,1);
8340 VARIMP(UI1
,0,EMPTY
,0,I2
,-1);
8341 VARIMP(UI1
,0,NULL
,0,UI1
,255);
8342 VARIMP(UI1
,0,I2
,-1,I2
,-1);
8343 VARIMP(UI1
,0,I4
,-1,I4
,-1);
8344 VARIMP(UI1
,0,R4
,0.0f
,I4
,-1);
8345 VARIMP(UI1
,0,R8
,-1.0,I4
,-1);
8346 VARIMP(UI1
,0,DATE
,0,I4
,-1);
8347 VARIMP(UI1
,0,BSTR
,true_str
,I2
,-1);
8348 VARIMP(UI1
,0,BOOL
,VARIANT_FALSE
,I2
,-1);
8349 VARIMP(UI1
,0,I1
,0,I4
,-1);
8350 VARIMP(UI1
,0,UI1
,1,UI1
,255);
8351 VARIMP(UI1
,0,UI2
,1,I4
,-1);
8352 VARIMP(UI1
,0,UI4
,1,I4
,-1);
8353 if (HAVE_OLEAUT32_I8
)
8355 VARIMP(UI1
,0,I8
,1,I8
,-1);
8356 VARIMP(UI1
,0,UI8
,1,I4
,-1);
8358 VARIMP(UI1
,0,INT
,-1,I4
,-1);
8359 VARIMP(UI1
,0,UINT
,1,I4
,-1);
8360 VARIMP(UI2
,0,EMPTY
,0,I4
,-1);
8361 VARIMP(UI2
,0,NULL
,0,I4
,-1);
8362 VARIMP(UI2
,0,I2
,-1,I4
,-1);
8363 VARIMP(UI2
,0,I4
,-1,I4
,-1);
8364 VARIMP(UI2
,0,R4
,0.0f
,I4
,-1);
8365 VARIMP(UI2
,0,R8
,-1.0,I4
,-1);
8366 VARIMP(UI2
,0,DATE
,0,I4
,-1);
8367 VARIMP(UI2
,0,BSTR
,true_str
,I4
,-1);
8368 VARIMP(UI2
,0,BOOL
,VARIANT_FALSE
,I4
,-1);
8369 VARIMP(UI2
,0,I1
,0,I4
,-1);
8370 VARIMP(UI2
,0,UI1
,1,I4
,-1);
8371 VARIMP(UI2
,0,UI2
,1,I4
,-1);
8372 VARIMP(UI2
,0,UI4
,1,I4
,-1);
8373 if (HAVE_OLEAUT32_I8
)
8375 VARIMP(UI2
,0,I8
,1,I8
,-1);
8376 VARIMP(UI2
,0,UI8
,1,I4
,-1);
8378 VARIMP(UI2
,0,INT
,-1,I4
,-1);
8379 VARIMP(UI2
,0,UINT
,1,I4
,-1);
8380 VARIMP(UI4
,0,EMPTY
,0,I4
,-1);
8381 VARIMP(UI4
,0,NULL
,0,I4
,-1);
8382 VARIMP(UI4
,0,I2
,-1,I4
,-1);
8383 VARIMP(UI4
,0,I4
,-1,I4
,-1);
8384 VARIMP(UI4
,0,R4
,0.0f
,I4
,-1);
8385 VARIMP(UI4
,0,R8
,-1.0,I4
,-1);
8386 VARIMP(UI4
,0,DATE
,0,I4
,-1);
8387 VARIMP(UI4
,0,BSTR
,true_str
,I4
,-1);
8388 VARIMP(UI4
,0,BOOL
,VARIANT_FALSE
,I4
,-1);
8389 VARIMP(UI4
,0,I1
,0,I4
,-1);
8390 VARIMP(UI4
,0,UI1
,1,I4
,-1);
8391 VARIMP(UI4
,0,UI2
,1,I4
,-1);
8392 VARIMP(UI4
,0,UI4
,1,I4
,-1);
8393 if (HAVE_OLEAUT32_I8
)
8395 VARIMP(UI4
,0,I8
,1,I8
,-1);
8396 VARIMP(UI4
,0,UI8
,1,I4
,-1);
8398 VARIMP(UI4
,0,INT
,-1,I4
,-1);
8399 VARIMP(UI4
,0,UINT
,1,I4
,-1);
8400 if (HAVE_OLEAUT32_I8
)
8402 VARIMP(I8
,-1,EMPTY
,0,I8
,0);
8403 VARIMP(I8
,-1,NULL
,0,NULL
,0);
8404 VARIMP(I8
,-1,I2
,-1,I8
,-1);
8405 VARIMP(I8
,-1,I4
,-1,I8
,-1);
8406 VARIMP(I8
,-1,R4
,0.0f
,I8
,0);
8407 VARIMP(I8
,-1,R8
,-1.0,I8
,-1);
8408 VARIMP(I8
,-1,DATE
,0,I8
,0);
8409 VARIMP(I8
,-1,BSTR
,true_str
,I8
,-1);
8410 VARIMP(I8
,-1,BOOL
,VARIANT_FALSE
,I8
,0);
8411 VARIMP(I8
,-1,I1
,0,I8
,0);
8412 VARIMP(I8
,-1,UI1
,1,I8
,1);
8413 VARIMP(I8
,-1,UI2
,1,I8
,1);
8414 VARIMP(I8
,-1,UI4
,1,I8
,1);
8415 VARIMP(I8
,-1,I8
,1,I8
,1);
8416 VARIMP(I8
,-1,UI8
,1,I8
,1);
8417 VARIMP(I8
,-1,UINT
,1,I8
,1);
8418 VARIMP(UI8
,0,EMPTY
,0,I4
,-1);
8419 VARIMP(UI8
,0,NULL
,0,I4
,-1);
8420 VARIMP(UI8
,0,I2
,-1,I4
,-1);
8421 VARIMP(UI8
,0,I4
,-1,I4
,-1);
8422 VARIMP(UI8
,0,R4
,0.0f
,I4
,-1);
8423 VARIMP(UI8
,0,R8
,-1.0,I4
,-1);
8424 VARIMP(UI8
,0,DATE
,0,I4
,-1);
8425 VARIMP(UI8
,0,BSTR
,true_str
,I4
,-1);
8426 VARIMP(UI8
,0,BOOL
,VARIANT_FALSE
,I4
,-1);
8427 VARIMP(UI8
,0,I1
,0,I4
,-1);
8428 VARIMP(UI8
,0,UI1
,1,I4
,-1);
8429 VARIMP(UI8
,0,UI2
,1,I4
,-1);
8430 VARIMP(UI8
,0,UI4
,1,I4
,-1);
8431 VARIMP(UI8
,0,I8
,1,I8
,-1);
8432 VARIMP(UI8
,0,UI8
,1,I4
,-1);
8433 VARIMP(UI8
,0,INT
,-1,I4
,-1);
8434 VARIMP(UI8
,0,UINT
,1,I4
,-1);
8436 VARIMP(INT
,-1,EMPTY
,0,I4
,0);
8437 VARIMP(INT
,-1,NULL
,0,NULL
,0);
8438 VARIMP(INT
,-1,I2
,-1,I4
,-1);
8439 VARIMP(INT
,-1,I4
,-1,I4
,-1);
8440 VARIMP(INT
,-1,R4
,0.0f
,I4
,0);
8441 VARIMP(INT
,-1,R8
,-1.0,I4
,-1);
8442 VARIMP(INT
,-1,DATE
,0,I4
,0);
8443 VARIMP(INT
,-1,BSTR
,true_str
,I4
,-1);
8444 VARIMP(INT
,-1,BOOL
,VARIANT_FALSE
,I4
,0);
8445 VARIMP(INT
,-1,I1
,0,I4
,0);
8446 VARIMP(INT
,-1,UI1
,1,I4
,1);
8447 VARIMP(INT
,-1,UI2
,1,I4
,1);
8448 VARIMP(INT
,-1,UI4
,1,I4
,1);
8449 if (HAVE_OLEAUT32_I8
)
8451 VARIMP(INT
,-1,I8
,1,I8
,1);
8452 VARIMP(INT
,-1,UI8
,1,I4
,1);
8454 VARIMP(INT
,-1,INT
,-1,I4
,-1);
8455 VARIMP(INT
,-1,UINT
,1,I4
,1);
8456 VARIMP(UINT
,1,EMPTY
,0,I4
,-2);
8457 VARIMP(UINT
,1,NULL
,0,I4
,-2);
8458 VARIMP(UINT
,1,I2
,-1,I4
,-1);
8459 VARIMP(UINT
,1,I4
,-1,I4
,-1);
8460 VARIMP(UINT
,1,R4
,0.0f
,I4
,-2);
8461 VARIMP(UINT
,1,R8
,-1.0,I4
,-1);
8462 VARIMP(UINT
,1,DATE
,0,I4
,-2);
8463 VARIMP(UINT
,1,BSTR
,true_str
,I4
,-1);
8464 VARIMP(UINT
,1,BOOL
,VARIANT_FALSE
,I4
,-2);
8465 VARIMP(UINT
,1,I1
,0,I4
,-2);
8466 VARIMP(UINT
,1,UI1
,1,I4
,-1);
8467 VARIMP(UINT
,1,UI2
,1,I4
,-1);
8468 VARIMP(UINT
,1,UI4
,1,I4
,-1);
8469 if (HAVE_OLEAUT32_I8
)
8471 VARIMP(UINT
,1,I8
,1,I8
,-1);
8472 VARIMP(UINT
,1,UI8
,1,I4
,-1);
8474 VARIMP(UINT
,1,INT
,-1,I4
,-1);
8475 VARIMP(UINT
,1,UINT
,1,I4
,-1);
8477 /* Manually test some VT_CY, VT_DECIMAL variants */
8479 hres
= VarCyFromI4(1, &V_CY(&cy
));
8480 ok(hres
== S_OK
, "VarCyFromI4 failed!\n");
8481 V_VT(&dec
) = VT_DECIMAL
;
8482 hres
= VarDecFromR8(2.0, &V_DECIMAL(&dec
));
8483 ok(hres
== S_OK
, "VarDecFromR4 failed!\n");
8484 memset(&left
, 0, sizeof(left
));
8485 memset(&right
, 0, sizeof(right
));
8486 V_VT(&left
) = VT_I4
;
8488 V_VT(&right
) = VT_I8
;
8491 hres
= pVarImp(&cy
, &cy
, &result
);
8492 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
8493 "VARIMP: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8494 S_OK
, hres
, vtstr(V_VT(&result
)));
8495 ok(hres
== S_OK
&& V_I4(&result
) == -1,
8496 "VARIMP: CY value %d, expected %d\n", V_I4(&result
), -1);
8498 if (HAVE_OLEAUT32_I8
)
8500 hres
= pVarImp(&cy
, &right
, &result
);
8501 ok(hres
== S_OK
&& V_VT(&result
) == VT_I8
,
8502 "VARIMP: expected coerced hres 0x%X type VT_I8, got hres 0x%X type %s!\n",
8503 S_OK
, hres
, vtstr(V_VT(&result
)));
8504 ok(hres
== S_OK
&& V_I8(&result
) == -2,
8505 "VARIMP: CY value %x%08x, expected %d\n",
8506 (DWORD
)((V_I8(&result
)) >> 32), (DWORD
)(V_I8(&result
)), -2);
8509 hres
= pVarImp(&left
, &cy
, &result
);
8510 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
8511 "VARIMP: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8512 S_OK
, hres
, vtstr(V_VT(&result
)));
8513 ok(hres
== S_OK
&& V_I4(&result
) == -1,
8514 "VARIMP: CY value %d, expected %d\n", V_I4(&result
), -1);
8516 hres
= pVarImp(&left
, &dec
, &result
);
8517 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
8518 "VARIMP: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8519 S_OK
, hres
, vtstr(V_VT(&result
)));
8520 ok(hres
== S_OK
&& V_I4(&result
) == -1,
8521 "VARIMP: DECIMAL value %d, expected %d\n", V_I4(&result
), -1);
8523 hres
= pVarImp(&dec
, &dec
, &result
);
8524 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
8525 "VARIMP: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8526 S_OK
, hres
, vtstr(V_VT(&result
)));
8527 ok(hres
== S_OK
&& V_I4(&result
) == -1,
8528 "VARIMP: DECIMAL value %d, expected %d\n", V_I4(&result
), -1);
8530 if (HAVE_OLEAUT32_I8
)
8532 hres
= pVarImp(&dec
, &right
, &result
);
8533 ok(hres
== S_OK
&& V_VT(&result
) == VT_I8
,
8534 "VARIMP: expected coerced hres 0x%X type VT_I8, got hres 0x%X type %s!\n",
8535 S_OK
, hres
, vtstr(V_VT(&result
)));
8536 ok(hres
== S_OK
&& V_I8(&result
) == -3,
8537 "VARIMP: DECIMAL value 0x%x%08x, expected %d\n",
8538 (DWORD
)(V_I8(&result
) >>32), (DWORD
)V_I8(&result
), -3);
8541 SysFreeString(false_str
);
8542 SysFreeString(true_str
);
8550 test_VariantClear();
8552 test_VariantCopyInd();
8553 test_VarParseNumFromStr();
8554 test_VarNumFromParseNum();
8555 test_VarUdateFromDate();
8556 test_VarDateFromUdate();
8557 test_SystemTimeToVariantTime();
8558 test_VariantTimeToSystemTime();
8559 test_DosDateTimeToVariantTime();
8560 test_VariantTimeToDosDateTime();