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(2,1,1980,0,0,0,0,4,5,0,S_OK
,29222.0); /* 2 Jan 1980 */
1643 UD2T(31,12,1990,0,0,0,0,0,0,0,S_OK
,33238.0); /* 31 Dec 1990 */
1644 UD2T(31,12,90,0,0,0,0,0,0,0,S_OK
,33238.0); /* year < 100 is 1900+year! */
1645 UD2T(30,12,1899,0,0,0,0,6,364,0,S_OK
,0.0); /* 30 Dec 1899 - VT_DATE 0.0 */
1646 UD2T(1,1,100,0,0,0,0,0,0,0,S_OK
,-657434.0); /* 1 Jan 100 - Min */
1647 UD2T(31,12,9999,0,0,0,0,0,0,0,S_OK
,2958465.0); /* 31 Dec 9999 - Max */
1648 UD2T(1,1,10000,0,0,0,0,0,0,0,E_INVALIDARG
,0.0); /* > 31 Dec 9999 => err */
1649 UD2T(1,1,-10000,0,0,0,0,0,0,0,E_INVALIDARG
,0.0);/* < -9999 => err */
1651 UD2T(30,12,1899,0,0,0,0,0,0,0,S_OK
,0.0); /* 30 Dec 1899 0:00:00 */
1652 UD2T(30,12,1899,0,0,0,999,0,0,0,S_OK
,0.0); /* Ignore milliseconds */
1654 UD2T(1,1,1980,18,1,16,0,2,1,0,S_OK
,29221.75087962963); /* 6:18:02 PM */
1655 UD2T(1,300,1980,18,1,16,0,2,1,0,S_OK
,38322.75087962963); /* Test fwdrolled month */
1656 UD2T(300,1,1980,18,1,16,0,2,1,0,S_OK
,29520.75087962963); /* Test fwdrolled days */
1657 UD2T(0,1,1980,42,1,16,0,2,1,0,S_OK
,29221.75087962963); /* Test fwdrolled hours */
1658 UD2T(1,1,1980,17,61,16,0,2,1,0,S_OK
,29221.75087962963); /* Test fwdrolled minutes */
1659 UD2T(1,1,1980,18,0,76,0,2,1,0,S_OK
,29221.75087962963); /* Test fwdrolled seconds */
1660 UD2T(1,-300,1980,18,1,16,0,2,1,0,S_OK
,20059.75087962963); /* Test backrolled month */
1661 UD2T(-300,1,1980,18,1,16,0,2,1,0,S_OK
,28920.75087962963); /* Test backrolled days */
1662 UD2T(3,1,1980,-30,1,16,0,2,1,0,S_OK
,29221.75087962963); /* Test backrolled hours */
1663 UD2T(1,1,1980,20,-119,16,0,2,1,0,S_OK
,29221.75087962963); /* Test backrolled minutes */
1664 UD2T(1,1,1980,18,3,-104,0,2,1,0,S_OK
,29221.75087962963); /* Test backrolled seconds */
1665 UD2T(1,12001,-1020,18,1,16,0,0,0,0,S_OK
,29221.75087962963); /* Test rolled year and month */
1666 UD2T(1,-23,1982,18,1,16,0,0,0,0,S_OK
,29221.75087962963); /* Test backrolled month */
1667 UD2T(-59,3,1980,18,1,16,0,0,0,0,S_OK
,29221.75087962963); /* Test backrolled days */
1668 UD2T(1,1,0,0,0,0,0,0,0,0,S_OK
,36526); /* Test zero year */
1669 UD2T(0,0,1980,0,0,0,0,0,0,0,S_OK
,29189); /* Test zero day and month */
1670 UD2T(0,1,1980,0,0,0,0,2,1,0,S_OK
,29220.0); /* Test zero day = LastDayOfMonth */
1671 UD2T(-1,1,1980,18,1,16,0,0,0,0,S_OK
,29219.75087962963); /* Test day -1 = LastDayOfMonth - 1 */
1672 UD2T(1,1,-1,18,1,16,0,0,0,0,S_OK
,36161.75087962963); /* Test year -1 = 1999 */
1673 UD2T(1,-1,1980,18,1,16,0,0,0,0,S_OK
,29160.7508796296); /* Test month -1 = 11 */
1674 UD2T(1,13,1980,0,0,0,0,2,1,0,S_OK
,29587.0); /* Rolls fwd to 1/1/1981 */
1677 static void test_st2dt(int line
, WORD d
, WORD m
, WORD y
, WORD h
, WORD mn
,
1678 WORD s
, WORD ms
, INT r
, double dt
)
1690 st
.wMilliseconds
= ms
;
1692 res
= pSystemTimeToVariantTime(&st
, &out
);
1693 ok_(__FILE__
,line
)(r
== res
&& (!r
|| EQ_DOUBLE(out
, dt
)),
1694 "expected %d, %.16g, got %d, %.16g\n", r
, dt
, res
, out
);
1696 #define ST2DT(d,m,y,h,mn,s,ms,r,dt) test_st2dt(__LINE__,d,m,y,h,mn,s,ms,r,dt)
1698 static void test_SystemTimeToVariantTime(void)
1700 CHECKPTR(SystemTimeToVariantTime
);
1701 ST2DT(1,1,1980,0,0,0,0,TRUE
,29221.0);
1702 ST2DT(2,1,1980,0,0,0,0,TRUE
,29222.0);
1703 ST2DT(0,1,1980,0,0,0,0,TRUE
,29220.0); /* Rolls back to 31 Dec 1899 */
1704 ST2DT(1,13,1980,0,0,0,0,FALSE
,29587.0); /* Fails on invalid month */
1705 ST2DT(31,12,90,0,0,0,0,TRUE
,33238.0); /* year < 100 is 1900+year! */
1708 static void test_dt2st(int line
, double dt
, INT r
, WORD d
, WORD m
, WORD y
,
1709 WORD h
, WORD mn
, WORD s
, WORD ms
)
1714 memset(&st
, 0, sizeof(st
));
1715 res
= pVariantTimeToSystemTime(dt
, &st
);
1716 ok_(__FILE__
,line
)(r
== res
&&
1717 (!r
|| (st
.wYear
== y
&& st
.wMonth
== m
&& st
.wDay
== d
&&
1718 st
.wHour
== h
&& st
.wMinute
== mn
&&
1719 st
.wSecond
== s
&& st
.wMilliseconds
== ms
)),
1720 "%.16g expected %d, %d,%d,%d,%d,%d,%d,%d, got %d, %d,%d,%d,%d,%d,%d,%d\n",
1721 dt
, r
, d
, m
, y
, h
, mn
, s
, ms
, res
, st
.wDay
, st
.wMonth
,
1722 st
.wYear
, st
.wHour
, st
.wMinute
, st
.wSecond
,
1725 #define DT2ST(dt,r,d,m,y,h,mn,s,ms) test_dt2st(__LINE__,dt,r,d,m,y,h,mn,s,ms)
1727 static void test_VariantTimeToSystemTime(void)
1729 CHECKPTR(VariantTimeToSystemTime
);
1730 DT2ST(29221.0,1,1,1,1980,0,0,0,0);
1731 DT2ST(29222.0,1,2,1,1980,0,0,0,0);
1734 #define MKDOSDATE(d,m,y) ((d & 0x1f) | ((m & 0xf) << 5) | (((y-1980) & 0x7f) << 9))
1735 #define MKDOSTIME(h,m,s) (((s>>1) & 0x1f) | ((m & 0x3f) << 5) | ((h & 0x1f) << 11))
1737 static void test_dos2dt(int line
, WORD d
, WORD m
, WORD y
, WORD h
, WORD mn
,
1738 WORD s
, INT r
, double dt
)
1740 unsigned short dosDate
, dosTime
;
1745 dosDate
= MKDOSDATE(d
, m
, y
);
1746 dosTime
= MKDOSTIME(h
, mn
, s
);
1747 res
= pDosDateTimeToVariantTime(dosDate
, dosTime
, &out
);
1748 ok_(__FILE__
,line
)(r
== res
&& (!r
|| EQ_DOUBLE(out
, dt
)),
1749 "expected %d, %.16g, got %d, %.16g\n", r
, dt
, res
, out
);
1751 #define DOS2DT(d,m,y,h,mn,s,r,dt) test_dos2dt(__LINE__,d,m,y,h,mn,s,r,dt)
1753 static void test_DosDateTimeToVariantTime(void)
1755 CHECKPTR(DosDateTimeToVariantTime
);
1758 DOS2DT(1,1,1980,0,0,0,1,29221.0); /* 1/1/1980 */
1759 DOS2DT(31,12,2099,0,0,0,1,73050.0); /* 31/12/2099 */
1760 /* Dates are limited to the dos date max of 31/12/2099 */
1761 DOS2DT(31,12,2100,0,0,0,0,0.0); /* 31/12/2100 */
1762 /* Days and months of 0 cause date to roll back 1 day or month */
1763 DOS2DT(0,1,1980,0,0,0,1,29220.0); /* 0 Day => 31/12/1979 */
1764 DOS2DT(1,0,1980,0,0,0,1,29190.0); /* 0 Mth => 1/12/1979 */
1765 DOS2DT(0,0,1980,0,0,0,1,29189.0); /* 0 D/M => 30/11/1979 */
1766 /* Days > days in the month cause date to roll forward 1 month */
1767 DOS2DT(29,2,1981,0,0,0,1,29646.0); /* 29/2/1981 -> 3/1/1980 */
1768 DOS2DT(30,2,1981,0,0,0,1,29647.0); /* 30/2/1981 -> 4/1/1980 */
1769 /* Takes leap years into account when rolling forward */
1770 DOS2DT(29,2,1980,0,0,0,1,29280.0); /* 2/29/1980 */
1771 /* Months > 12 cause an error */
1772 DOS2DT(2,13,1980,0,0,0,0,0.0);
1775 DOS2DT(1,1,1980,0,0,29,1,29221.00032407407); /* 1/1/1980 12:00:28 AM */
1776 DOS2DT(1,1,1980,0,0,31,1,29221.00034722222); /* 1/1/1980 12:00:30 AM */
1777 DOS2DT(1,1,1980,0,59,0,1,29221.04097222222); /* 1/1/1980 12:59:00 AM */
1778 DOS2DT(1,1,1980,0,60,0,0,0.0); /* Invalid minutes */
1779 DOS2DT(1,1,1980,0,0,60,0,0.0); /* Invalid seconds */
1780 DOS2DT(1,1,1980,23,0,0,1,29221.95833333333); /* 1/1/1980 11:00:00 PM */
1781 DOS2DT(1,1,1980,24,0,0,0,0.0); /* Invalid hours */
1783 DOS2DT(1,1,1980,0,0,1,1,29221.0);
1784 DOS2DT(2,1,1980,0,0,0,1,29222.0);
1785 DOS2DT(2,1,1980,0,0,0,1,29222.0);
1786 DOS2DT(31,12,1990,0,0,0,1,33238.0);
1787 DOS2DT(31,12,90,0,0,0,1,40543.0);
1788 DOS2DT(30,12,1899,0,0,0,1,46751.0);
1789 DOS2DT(1,1,100,0,0,0,1,43831.0);
1790 DOS2DT(31,12,9999,0,0,0,1,59901.0);
1791 DOS2DT(1,1,10000,0,0,0,1,59902.0);
1792 DOS2DT(1,1,-10000,0,0,0,1,48214.0);
1794 DOS2DT(30,12,1899,0,0,0,1,46751.0);
1795 DOS2DT(30,12,1899,0,0,1,1,46751.0);
1797 DOS2DT(1,1,1980,18,1,16,1,29221.75087962963);
1798 DOS2DT(1,300,1980,18,1,16,1,29556.75087962963);
1799 DOS2DT(300,1,1980,18,1,16,1,29232.75087962963);
1800 DOS2DT(0,1,1980,42,1,16,1,29220.4175462963);
1801 DOS2DT(1,1,1980,17,61,16,0,0.0);
1802 DOS2DT(1,1,1980,18,0,76,1,29221.75013888889);
1803 DOS2DT(1,-300,1980,18,1,16,1,29312.75087962963);
1804 DOS2DT(-300,1,1980,18,1,16,1,29240.75087962963);
1805 DOS2DT(3,1,1980,-30,1,16,1,29223.08421296296);
1806 DOS2DT(1,1,1980,20,-119,16,1,29221.83976851852);
1807 DOS2DT(1,1,1980,18,3,-104,1,29221.75236111111);
1808 DOS2DT(1,12001,-1020,18,1,16,1,55519.75087962963);
1809 DOS2DT(1,-23,1982,18,1,16,1,30195.75087962963);
1810 DOS2DT(-59,3,1980,18,1,16,1,29285.75087962963);
1811 DOS2DT(1,1,0,0,0,0,1,54058.0);
1812 DOS2DT(0,0,1980,0,0,0,1,29189.0);
1813 DOS2DT(0,1,1980,0,0,0,1,29220.0);
1814 DOS2DT(-1,1,1980,18,1,16,1,29251.75087962963);
1815 DOS2DT(1,1,-1,18,1,16,1,53693.75087962963);
1816 DOS2DT(1,-1,1980,18,1,16,0,0);
1819 static void test_dt2dos(int line
, double dt
, INT r
, WORD d
, WORD m
, WORD y
,
1820 WORD h
, WORD mn
, WORD s
)
1822 unsigned short dosDate
, dosTime
, expDosDate
, expDosTime
;
1825 dosTime
= dosDate
= 0;
1826 expDosDate
= MKDOSDATE(d
,m
,y
);
1827 expDosTime
= MKDOSTIME(h
,mn
,s
);
1828 res
= pVariantTimeToDosDateTime(dt
, &dosDate
, &dosTime
);
1829 ok_(__FILE__
,line
)(r
== res
&& (!r
|| (dosTime
== expDosTime
&& dosDate
== expDosDate
)),
1830 "%g: expected %d,%d(%d/%d/%d),%d(%d:%d:%d) got %d,%d(%d/%d/%d),%d(%d:%d:%d)\n",
1831 dt
, r
, expDosDate
, expDosDate
& 0x1f,
1832 (expDosDate
>> 5) & 0xf, 1980 + (expDosDate
>> 9),
1833 expDosTime
, expDosTime
>> 11, (expDosTime
>> 5) & 0x3f,
1834 (expDosTime
& 0x1f),
1835 res
, dosDate
, dosDate
& 0x1f, (dosDate
>> 5) & 0xf,
1836 1980 + (dosDate
>> 9), dosTime
, dosTime
>> 11,
1837 (dosTime
>> 5) & 0x3f, (dosTime
& 0x1f));
1839 #define DT2DOS(dt,r,d,m,y,h,mn,s) test_dt2dos(__LINE__,dt,r,d,m,y,h,mn,s)
1841 static void test_VariantTimeToDosDateTime(void)
1843 CHECKPTR(VariantTimeToDosDateTime
);
1846 DT2DOS(29221.0,1,1,1,1980,0,0,0); /* 1/1/1980 */
1847 DT2DOS(73050.0,1,31,12,2099,0,0,0); /* 31/12/2099 */
1848 DT2DOS(29220.0,0,0,0,0,0,0,0); /* 31/12/1979 - out of range */
1849 DT2DOS(73415.0,0,0,0,0,0,0,0); /* 31/12/2100 - out of range */
1852 DT2DOS(29221.00032407407,1,1,1,1980,0,0,29); /* 1/1/1980 12:00:28 AM */
1853 DT2DOS(29221.00034722222,1,1,1,1980,0,0,31); /* 1/1/1980 12:00:30 AM */
1854 DT2DOS(29221.04097222222,1,1,1,1980,0,59,0); /* 1/1/1980 12:59:00 AM */
1855 DT2DOS(29221.95833333333,1,1,1,1980,23,0,0); /* 1/1/1980 11:00:00 PM */
1858 static HRESULT (WINAPI
*pVarAbs
)(LPVARIANT
,LPVARIANT
);
1860 #define VARABS(vt,val,rvt,rval) \
1861 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
1862 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
1863 test_var_call1( __LINE__, pVarAbs, &v, &exp )
1865 static void test_VarAbs(void)
1867 static WCHAR szNum
[] = {'-','1','.','1','\0' };
1870 VARIANT v
, vDst
, exp
;
1875 /* Test all possible V_VT values.
1877 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
1881 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
1883 HRESULT hExpected
= DISP_E_BADVARTYPE
;
1887 memset(&v
, 0, sizeof(v
));
1888 V_VT(&v
) = vt
| ExtraFlags
[i
];
1889 V_VT(&vDst
) = VT_EMPTY
;
1891 hres
= pVarAbs(&v
,&vDst
);
1892 if (ExtraFlags
[i
] & (VT_ARRAY
|VT_ARRAY
) ||
1893 (!ExtraFlags
[i
] && (vt
== VT_UNKNOWN
|| vt
== VT_BSTR
||
1894 vt
== VT_DISPATCH
|| vt
== VT_ERROR
|| vt
== VT_RECORD
)))
1896 hExpected
= DISP_E_TYPEMISMATCH
;
1898 else if (ExtraFlags
[i
] || vt
>= VT_CLSID
|| vt
== VT_VARIANT
)
1900 hExpected
= DISP_E_BADVARTYPE
;
1902 else if (IsValidVariantClearVT(vt
, ExtraFlags
[i
]))
1905 /* Native always fails on some vartypes that should be valid. don't
1906 * check that Wine does the same; these are bugs in native.
1908 if (vt
== VT_I8
|| vt
== VT_UI8
|| vt
== VT_INT
|| vt
== VT_UINT
||
1909 vt
== VT_I1
|| vt
== VT_UI2
|| vt
== VT_UI4
)
1911 ok(hres
== hExpected
, "VarAbs: expected 0x%X, got 0x%X for vt %d | 0x%X\n",
1912 hExpected
, hres
, vt
, ExtraFlags
[i
]);
1916 /* BOOL->I2, BSTR->R8, all others remain the same */
1917 VARABS(BOOL
,VARIANT_TRUE
,I2
,-VARIANT_TRUE
);
1918 VARABS(BOOL
,VARIANT_FALSE
,I2
,VARIANT_FALSE
);
1919 VARABS(EMPTY
,0,I2
,0);
1920 VARABS(EMPTY
,1,I2
,0);
1921 VARABS(NULL
,0,NULL
,0);
1922 VARABS(NULL
,1,NULL
,0);
1927 VARABS(UI1
,1,UI1
,1);
1932 VARABS(DATE
,1,DATE
,1);
1933 VARABS(DATE
,-1,DATE
,1);
1935 V_CY(&v
).int64
= -10000;
1936 memset(&vDst
,0,sizeof(vDst
));
1937 hres
= pVarAbs(&v
,&vDst
);
1938 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_CY
&& V_CY(&vDst
).int64
== 10000,
1939 "VarAbs(CY): expected 0x0 got 0x%X\n", hres
);
1940 GetLocaleInfoA(LOCALE_USER_DEFAULT
, LOCALE_SDECIMAL
, buff
, sizeof(buff
)/sizeof(char));
1943 trace("Skipping VarAbs(BSTR) as decimal separator is '%s'\n", buff
);
1949 V_BSTR(&v
) = (BSTR
)szNum
;
1950 memset(&vDst
,0,sizeof(vDst
));
1951 hres
= pVarAbs(&v
,&vDst
);
1952 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_R8
&& V_R8(&vDst
) == 1.1,
1953 "VarAbs: expected 0x0,%d,%g, got 0x%X,%d,%g\n", VT_R8
, 1.1, hres
, V_VT(&vDst
), V_R8(&vDst
));
1956 static HRESULT (WINAPI
*pVarNot
)(LPVARIANT
,LPVARIANT
);
1958 #define VARNOT(vt,val,rvt,rval) \
1959 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
1960 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
1961 test_var_call1( __LINE__, pVarNot, &v, &exp )
1963 static void test_VarNot(void)
1965 static const WCHAR szNum0
[] = {'0','\0' };
1966 static const WCHAR szNum1
[] = {'1','\0' };
1968 VARIANT v
, exp
, vDst
;
1969 DECIMAL
*pdec
= &V_DECIMAL(&v
);
1970 CY
*pcy
= &V_CY(&v
);
1975 /* Test all possible V_VT values */
1976 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
1980 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
1982 HRESULT hExpected
= DISP_E_BADVARTYPE
;
1986 memset(&v
, 0, sizeof(v
));
1987 V_VT(&v
) = vt
| ExtraFlags
[i
];
1988 V_VT(&vDst
) = VT_EMPTY
;
1992 case VT_I1
: case VT_UI1
: case VT_I2
: case VT_UI2
:
1993 case VT_INT
: case VT_UINT
: case VT_I4
: case VT_UI4
:
1994 case VT_R4
: case VT_R8
:
1995 case VT_DECIMAL
: case VT_BOOL
: case VT_NULL
: case VT_EMPTY
:
1996 case VT_DATE
: case VT_CY
:
1999 case VT_I8
: case VT_UI8
:
2000 if (HAVE_OLEAUT32_I8
)
2004 if (HAVE_OLEAUT32_RECORD
)
2005 hExpected
= DISP_E_TYPEMISMATCH
;
2007 case VT_UNKNOWN
: case VT_BSTR
: case VT_DISPATCH
: case VT_ERROR
:
2008 hExpected
= DISP_E_TYPEMISMATCH
;
2011 if (IsValidVariantClearVT(vt
, ExtraFlags
[i
]) && vt
!= VT_CLSID
)
2012 hExpected
= DISP_E_TYPEMISMATCH
;
2016 hres
= pVarNot(&v
,&vDst
);
2017 ok(hres
== hExpected
, "VarNot: expected 0x%X, got 0x%X vt %d|0x%X\n",
2018 hExpected
, hres
, vt
, ExtraFlags
[i
]);
2021 /* Test the values returned by all cases that can succeed */
2022 VARNOT(EMPTY
,0,I2
,-1);
2023 VARNOT(EMPTY
,1,I2
,-1);
2024 VARNOT(NULL
,0,NULL
,0);
2025 VARNOT(NULL
,1,NULL
,0);
2026 VARNOT(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
);
2027 VARNOT(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
);
2035 VARNOT(UI1
,1,UI1
,254);
2036 VARNOT(UI1
,0,UI1
,255);
2037 VARNOT(UI2
,0,I4
,-1);
2038 VARNOT(UI2
,1,I4
,-2);
2039 VARNOT(UI4
,0,I4
,-1);
2040 VARNOT(UI4
,1,I4
,-2);
2041 VARNOT(INT
,0,I4
,-1);
2042 VARNOT(INT
,1,I4
,-2);
2043 VARNOT(UINT
,0,I4
,-1);
2044 VARNOT(UINT
,1,I4
,-2);
2045 if (HAVE_OLEAUT32_I8
)
2049 VARNOT(UI8
,0,I4
,-1);
2050 VARNOT(UI8
,1,I4
,-2);
2056 VARNOT(DATE
,1,I4
,-2);
2057 VARNOT(DATE
,0,I4
,-1);
2058 VARNOT(BSTR
,(BSTR
)szNum0
,I4
,-1);
2059 ok(V_VT(&v
) == VT_BSTR
&& V_BSTR(&v
) == szNum0
, "VarNot(0): changed input\n");
2060 VARNOT(BSTR
,(BSTR
)szNum1
,I4
,-2);
2061 ok(V_VT(&v
) == VT_BSTR
&& V_BSTR(&v
) == szNum1
, "VarNot(1): changed input\n");
2063 V_VT(&v
) = VT_DECIMAL
;
2064 S(U(*pdec
)).sign
= DECIMAL_NEG
;
2065 S(U(*pdec
)).scale
= 0;
2067 S1(U1(*pdec
)).Mid32
= 0;
2068 S1(U1(*pdec
)).Lo32
= 1;
2069 VARNOT(DECIMAL
,*pdec
,I4
,0);
2072 VARNOT(CY
,*pcy
,I4
,-2);
2075 VARNOT(CY
,*pcy
,I4
,-1);
2078 VARNOT(CY
,*pcy
,I4
,-1);
2081 static HRESULT (WINAPI
*pVarSub
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
2083 #define VARSUB(vt1,val1,vt2,val2,rvt,rval) \
2084 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
2085 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
2086 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
2087 test_var_call2( __LINE__, pVarSub, &left, &right, &exp )
2089 static void test_VarSub(void)
2091 VARIANT left
, right
, exp
, result
, cy
, dec
;
2094 HRESULT hres
, expectedhres
;
2099 lbstr
= SysAllocString(sz12
);
2100 rbstr
= SysAllocString(sz12
);
2103 VariantInit(&right
);
2104 VariantInit(&result
);
2106 /* Test all possible flag/vt combinations & the resulting vt type */
2107 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
2110 VARTYPE leftvt
, rightvt
, resvt
;
2112 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
2117 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
2121 expectedhres
= S_OK
;
2123 memset(&left
, 0, sizeof(left
));
2124 memset(&right
, 0, sizeof(right
));
2125 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
2126 if (leftvt
== VT_BSTR
)
2127 V_BSTR(&left
) = lbstr
;
2128 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
2129 if (rightvt
== VT_BSTR
)
2130 V_BSTR(&right
) = rbstr
;
2131 V_VT(&result
) = VT_EMPTY
;
2134 /* All extra flags produce errors */
2135 if (ExtraFlags
[i
] == (VT_VECTOR
|VT_BYREF
|VT_RESERVED
) ||
2136 ExtraFlags
[i
] == (VT_VECTOR
|VT_RESERVED
) ||
2137 ExtraFlags
[i
] == (VT_VECTOR
|VT_BYREF
) ||
2138 ExtraFlags
[i
] == (VT_BYREF
|VT_RESERVED
) ||
2139 ExtraFlags
[i
] == VT_VECTOR
||
2140 ExtraFlags
[i
] == VT_BYREF
||
2141 ExtraFlags
[i
] == VT_RESERVED
)
2143 expectedhres
= DISP_E_BADVARTYPE
;
2146 else if (ExtraFlags
[i
] >= VT_ARRAY
)
2148 expectedhres
= DISP_E_TYPEMISMATCH
;
2151 /* Native VarSub cannot handle: VT_I1, VT_UI2, VT_UI4,
2152 VT_INT, VT_UINT and VT_UI8. Tested with WinXP */
2153 else if (!IsValidVariantClearVT(leftvt
, ExtraFlags
[i
]) ||
2154 !IsValidVariantClearVT(rightvt
, ExtraFlags
[i
]) ||
2155 leftvt
== VT_CLSID
|| rightvt
== VT_CLSID
||
2156 leftvt
== VT_VARIANT
|| rightvt
== VT_VARIANT
||
2157 leftvt
== VT_I1
|| rightvt
== VT_I1
||
2158 leftvt
== VT_UI2
|| rightvt
== VT_UI2
||
2159 leftvt
== VT_UI4
|| rightvt
== VT_UI4
||
2160 leftvt
== VT_UI8
|| rightvt
== VT_UI8
||
2161 leftvt
== VT_INT
|| rightvt
== VT_INT
||
2162 leftvt
== VT_UINT
|| rightvt
== VT_UINT
||
2163 leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
||
2164 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
)
2166 if (leftvt
== VT_RECORD
&& rightvt
== VT_I8
)
2168 if (HAVE_OLEAUT32_I8
)
2169 expectedhres
= DISP_E_TYPEMISMATCH
;
2171 expectedhres
= DISP_E_BADVARTYPE
;
2173 else if (leftvt
< VT_UI1
&& rightvt
== VT_RECORD
)
2174 expectedhres
= DISP_E_TYPEMISMATCH
;
2175 else if (leftvt
>= VT_UI1
&& rightvt
== VT_RECORD
)
2176 expectedhres
= DISP_E_TYPEMISMATCH
;
2177 else if (leftvt
== VT_RECORD
&& rightvt
<= VT_UI1
)
2178 expectedhres
= DISP_E_TYPEMISMATCH
;
2179 else if (leftvt
== VT_RECORD
&& rightvt
> VT_UI1
)
2180 expectedhres
= DISP_E_BADVARTYPE
;
2182 expectedhres
= DISP_E_BADVARTYPE
;
2185 else if ((leftvt
== VT_NULL
&& rightvt
== VT_DISPATCH
) ||
2186 (leftvt
== VT_DISPATCH
&& rightvt
== VT_NULL
))
2188 else if (leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
||
2189 leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
)
2192 expectedhres
= DISP_E_TYPEMISMATCH
;
2194 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
2196 else if ((leftvt
== VT_EMPTY
&& rightvt
== VT_BSTR
) ||
2197 (leftvt
== VT_DATE
&& rightvt
== VT_DATE
) ||
2198 (leftvt
== VT_BSTR
&& rightvt
== VT_EMPTY
) ||
2199 (leftvt
== VT_BSTR
&& rightvt
== VT_BSTR
))
2201 else if (leftvt
== VT_DECIMAL
|| rightvt
== VT_DECIMAL
)
2203 else if (leftvt
== VT_DATE
|| rightvt
== VT_DATE
)
2205 else if (leftvt
== VT_CY
|| rightvt
== VT_CY
)
2207 else if (leftvt
== VT_R8
|| rightvt
== VT_R8
)
2209 else if (leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
) {
2211 } else if (leftvt
== VT_R4
|| rightvt
== VT_R4
) {
2212 if (leftvt
== VT_I4
|| rightvt
== VT_I4
||
2213 leftvt
== VT_I8
|| rightvt
== VT_I8
)
2218 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
2220 else if (leftvt
== VT_I4
|| rightvt
== VT_I4
)
2222 else if (leftvt
== VT_I2
|| rightvt
== VT_I2
||
2223 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
||
2224 (leftvt
== VT_EMPTY
&& rightvt
== VT_EMPTY
))
2226 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
2231 expectedhres
= DISP_E_TYPEMISMATCH
;
2234 hres
= pVarSub(&left
, &right
, &result
);
2236 ok(hres
== expectedhres
&& V_VT(&result
) == resvt
,
2237 "VarSub: %d|0x%X, %d|0x%X: Expected failure 0x%X, "
2238 "got 0x%X, expected vt %d got vt %d\n",
2239 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
],
2240 expectedhres
, hres
, resvt
, V_VT(&result
));
2245 /* Test returned values */
2246 VARSUB(I4
,4,I4
,2,I4
,2);
2247 VARSUB(I2
,4,I2
,2,I2
,2);
2248 VARSUB(I2
,-13,I4
,5,I4
,-18);
2249 VARSUB(I4
,-13,I4
,5,I4
,-18);
2250 VARSUB(I2
,7,R4
,0.5f
,R4
,6.5f
);
2251 VARSUB(R4
,0.5f
,I4
,5,R8
,-4.5);
2252 VARSUB(R8
,7.1,BOOL
,0,R8
,7.1);
2253 VARSUB(BSTR
,lbstr
,I2
,4,R8
,8);
2254 VARSUB(BSTR
,lbstr
,BOOL
,1,R8
,11);
2255 VARSUB(BSTR
,lbstr
,R4
,0.1f
,R8
,11.9);
2256 VARSUB(R4
,0.2f
,BSTR
,rbstr
,R8
,-11.8);
2257 VARSUB(DATE
,2.25,I4
,7,DATE
,-4.75);
2258 VARSUB(DATE
,1.25,R4
,-1.7f
,DATE
,2.95);
2260 VARSUB(UI1
, UI1_MAX
, UI1
, UI1_MAX
, UI1
, 0);
2261 VARSUB(I2
, I2_MAX
, I2
, I2_MAX
, I2
, 0);
2262 VARSUB(I2
, I2_MIN
, I2
, I2_MIN
, I2
, 0);
2263 VARSUB(I4
, I4_MAX
, I4
, I4_MAX
, I4
, 0);
2264 VARSUB(I4
, I4_MIN
, I4
, I4_MIN
, I4
, 0);
2265 VARSUB(R4
, R4_MAX
, R4
, R4_MAX
, R4
, 0.0f
);
2266 VARSUB(R4
, R4_MAX
, R4
, R4_MIN
, R4
, R4_MAX
- R4_MIN
);
2267 VARSUB(R4
, R4_MIN
, R4
, R4_MIN
, R4
, 0.0f
);
2268 VARSUB(R8
, R8_MAX
, R8
, R8_MIN
, R8
, R8_MAX
- R8_MIN
);
2269 VARSUB(R8
, R8_MIN
, R8
, R8_MIN
, R8
, 0.0);
2271 /* Manually test BSTR + BSTR */
2272 V_VT(&left
) = VT_BSTR
;
2273 V_BSTR(&left
) = lbstr
;
2274 V_VT(&right
) = VT_BSTR
;
2275 V_BSTR(&right
) = rbstr
;
2276 hres
= VarSub(&left
, &right
, &result
);
2277 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
2278 "VarSub: expected coerced type VT_R8, got %s!\n", vtstr(V_VT(&result
)));
2279 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 0),
2280 "VarSub: BSTR + BSTR, expected %f got %f\n", 0.0, V_R8(&result
));
2282 /* Manually test some VT_CY and VT_DECIMAL variants */
2284 hres
= VarCyFromI4(4711, &V_CY(&cy
));
2285 ok(hres
== S_OK
, "VarCyFromI4 failed!\n");
2286 V_VT(&dec
) = VT_DECIMAL
;
2287 hres
= VarDecFromR8(-4.2, &V_DECIMAL(&dec
));
2288 ok(hres
== S_OK
, "VarDecFromR4 failed!\n");
2289 memset(&left
, 0, sizeof(left
));
2290 memset(&right
, 0, sizeof(right
));
2291 V_VT(&left
) = VT_I4
;
2293 V_VT(&right
) = VT_UI1
;
2296 hres
= VarSub(&cy
, &right
, &result
);
2297 ok(hres
== S_OK
&& V_VT(&result
) == VT_CY
,
2298 "VarSub: expected coerced type VT_CY, got %s!\n", vtstr(V_VT(&result
)));
2299 hres
= VarR8FromCy(V_CY(&result
), &r
);
2300 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 4702),
2301 "VarSub: CY value %f, expected %f\n", r
, (double)4720);
2303 hres
= VarSub(&left
, &dec
, &result
);
2304 ok(hres
== S_OK
&& V_VT(&result
) == VT_DECIMAL
,
2305 "VarSub: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result
)));
2306 hres
= VarR8FromDec(&V_DECIMAL(&result
), &r
);
2307 ok(hres
== S_OK
&& EQ_DOUBLE(r
, -6.8),
2308 "VarSub: DECIMAL value %f, expected %f\n", r
, (double)-15.2);
2310 SysFreeString(lbstr
);
2311 SysFreeString(rbstr
);
2314 static HRESULT (WINAPI
*pVarMod
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
2316 static void test_Mod( int line
, VARIANT
*left
, VARIANT
*right
, VARIANT
*expected
, HRESULT expres
)
2321 memset( &result
, 0, sizeof(result
) );
2322 hres
= pVarMod( left
, right
, &result
);
2323 ok_(__FILE__
,line
)( hres
== expres
, "wrong result %x/%x\n", hres
, expres
);
2325 ok_(__FILE__
,line
)( is_expected_variant( &result
, expected
),
2326 "got %s expected %s\n", variantstr(&result
), variantstr(expected
) );
2329 #define VARMOD(vt1,vt2,val1,val2,rvt,rval) \
2330 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
2331 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
2332 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
2333 test_var_call2( __LINE__, pVarMod, &left, &right, &exp )
2335 #define VARMOD2(vt1,vt2,val1,val2,rvt,rval,hexpected) \
2336 V_VT(&left) = VT_##vt1; V_I4(&left) = val1; \
2337 V_VT(&right) = VT_##vt2; V_I4(&right) = val2; \
2338 V_VT(&exp) = VT_##rvt; V_I4(&exp) = rval; \
2339 test_Mod( __LINE__, &left, &right, &exp, hexpected )
2341 static void test_VarMod(void)
2343 VARIANT v1
, v2
, vDst
, left
, right
, exp
;
2345 HRESULT hexpected
= 0;
2346 static const WCHAR szNum0
[] = {'1','2','5','\0'};
2347 static const WCHAR szNum1
[] = {'1','0','\0'};
2349 BOOL lFound
, rFound
;
2350 BOOL lValid
, rValid
;
2351 BSTR strNum0
, strNum1
;
2355 VARMOD(I1
,BOOL
,100,10,I4
,0);
2356 VARMOD(I1
,I1
,100,10,I4
,0);
2357 VARMOD(I1
,UI1
,100,10,I4
,0);
2358 VARMOD(I1
,I2
,100,10,I4
,0);
2359 VARMOD(I1
,UI2
,100,10,I4
,0);
2360 VARMOD(I1
,I4
,100,10,I4
,0);
2361 VARMOD(I1
,UI4
,100,10,I4
,0);
2362 VARMOD(I1
,R4
,100,10,I4
,0);
2363 VARMOD(I1
,R8
,100,10,I4
,0);
2365 VARMOD(UI1
,BOOL
,100,10,I2
,0);
2366 VARMOD(UI1
,I1
,100,10,I4
,0);
2367 VARMOD(UI1
,UI1
,100,10,UI1
,0);
2368 VARMOD(UI1
,I2
,100,10,I2
,0);
2369 VARMOD(UI1
,UI2
,100,10,I4
,0);
2370 VARMOD(UI1
,I4
,100,10,I4
,0);
2371 VARMOD(UI1
,UI4
,100,10,I4
,0);
2372 VARMOD(UI1
,R4
,100,10,I4
,0);
2373 VARMOD(UI1
,R8
,100,10,I4
,0);
2375 VARMOD(I2
,BOOL
,100,10,I2
,0);
2376 VARMOD(I2
,I1
,100,10,I4
,0);
2377 VARMOD(I2
,UI1
,100,10,I2
,0);
2378 VARMOD(I2
,I2
,100,10,I2
,0);
2379 VARMOD(I2
,UI2
,100,10,I4
,0);
2380 VARMOD(I2
,I4
,100,10,I4
,0);
2381 VARMOD(I2
,UI4
,100,10,I4
,0);
2382 VARMOD(I2
,R4
,100,10,I4
,0);
2383 VARMOD(I2
,R8
,100,10,I4
,0);
2385 VARMOD(I4
,BOOL
,100,10,I4
,0);
2386 VARMOD(I4
,I1
,100,10,I4
,0);
2387 VARMOD(I4
,UI1
,100,10,I4
,0);
2388 VARMOD(I4
,I2
,100,10,I4
,0);
2389 VARMOD(I4
,UI2
,100,10,I4
,0);
2390 VARMOD(I4
,I4
,100,10,I4
,0);
2391 VARMOD(I4
,UI4
,100,10,I4
,0);
2392 VARMOD(I4
,R4
,100,10,I4
,0);
2393 VARMOD(I4
,R8
,100,10,I4
,0);
2394 VARMOD(UI4
,BOOL
,100,10,I4
,0);
2395 VARMOD(UI4
,I1
,100,10,I4
,0);
2396 VARMOD(UI4
,UI1
,100,10,I4
,0);
2397 VARMOD(UI4
,I2
,100,10,I4
,0);
2398 VARMOD(UI4
,UI2
,100,10,I4
,0);
2399 VARMOD(UI4
,I4
,100,10,I4
,0);
2400 VARMOD(UI4
,UI4
,100,10,I4
,0);
2401 VARMOD(UI4
,R4
,100,10,I4
,0);
2402 VARMOD(UI4
,R8
,100,10,I4
,0);
2403 VARMOD(R4
,BOOL
,100,10,I4
,0);
2404 VARMOD(R4
,I1
,100,10,I4
,0);
2405 VARMOD(R4
,UI1
,100,10,I4
,0);
2406 VARMOD(R4
,I2
,100,10,I4
,0);
2407 VARMOD(R4
,UI2
,100,10,I4
,0);
2408 VARMOD(R4
,I4
,100,10,I4
,0);
2409 VARMOD(R4
,UI4
,100,10,I4
,0);
2410 VARMOD(R4
,R4
,100,10,I4
,0);
2411 VARMOD(R4
,R8
,100,10,I4
,0);
2412 VARMOD(R8
,BOOL
,100,10,I4
,0);
2413 VARMOD(R8
,I1
,100,10,I4
,0);
2414 VARMOD(R8
,UI1
,100,10,I4
,0);
2415 VARMOD(R8
,I2
,100,10,I4
,0);
2416 VARMOD(R8
,UI2
,100,10,I4
,0);
2417 VARMOD(R8
,I4
,100,10,I4
,0);
2418 VARMOD(R8
,UI4
,100,10,I4
,0);
2419 VARMOD(R8
,R4
,100,10,I4
,0);
2420 VARMOD(R8
,R8
,100,10,I4
,0);
2422 VARMOD(INT
,INT
,100,10,I4
,0);
2423 VARMOD(INT
,UINT
,100,10,I4
,0);
2425 VARMOD(BOOL
,BOOL
,100,10,I2
,0);
2426 VARMOD(BOOL
,I1
,100,10,I4
,0);
2427 VARMOD(BOOL
,UI1
,100,10,I2
,0);
2428 VARMOD(BOOL
,I2
,100,10,I2
,0);
2429 VARMOD(BOOL
,UI2
,100,10,I4
,0);
2430 VARMOD(BOOL
,I4
,100,10,I4
,0);
2431 VARMOD(BOOL
,UI4
,100,10,I4
,0);
2432 VARMOD(BOOL
,R4
,100,10,I4
,0);
2433 VARMOD(BOOL
,R8
,100,10,I4
,0);
2434 VARMOD(BOOL
,DATE
,100,10,I4
,0);
2436 VARMOD(DATE
,BOOL
,100,10,I4
,0);
2437 VARMOD(DATE
,I1
,100,10,I4
,0);
2438 VARMOD(DATE
,UI1
,100,10,I4
,0);
2439 VARMOD(DATE
,I2
,100,10,I4
,0);
2440 VARMOD(DATE
,UI2
,100,10,I4
,0);
2441 VARMOD(DATE
,I4
,100,10,I4
,0);
2442 VARMOD(DATE
,UI4
,100,10,I4
,0);
2443 VARMOD(DATE
,R4
,100,10,I4
,0);
2444 VARMOD(DATE
,R8
,100,10,I4
,0);
2445 VARMOD(DATE
,DATE
,100,10,I4
,0);
2447 strNum0
= SysAllocString(szNum0
);
2448 strNum1
= SysAllocString(szNum1
);
2449 VARMOD(BSTR
,BSTR
,strNum0
,strNum1
,I4
,5);
2450 VARMOD(BSTR
,I1
,strNum0
,10,I4
,5);
2451 VARMOD(BSTR
,I2
,strNum0
,10,I4
,5);
2452 VARMOD(BSTR
,I4
,strNum0
,10,I4
,5);
2453 VARMOD(BSTR
,R4
,strNum0
,10,I4
,5);
2454 VARMOD(BSTR
,R8
,strNum0
,10,I4
,5);
2455 VARMOD(I4
,BSTR
,125,strNum1
,I4
,5);
2457 if (HAVE_OLEAUT32_I8
)
2459 VARMOD(BOOL
,I8
,100,10,I8
,0);
2460 VARMOD(I1
,I8
,100,10,I8
,0);
2461 VARMOD(UI1
,I8
,100,10,I8
,0);
2462 VARMOD(I2
,I8
,100,10,I8
,0);
2463 VARMOD(I4
,I8
,100,10,I8
,0);
2464 VARMOD(UI4
,I8
,100,10,I8
,0);
2465 VARMOD(R4
,I8
,100,10,I8
,0);
2466 VARMOD(R8
,I8
,100,10,I8
,0);
2467 VARMOD(DATE
,I8
,100,10,I8
,0);
2469 VARMOD(I8
,BOOL
,100,10,I8
,0);
2470 VARMOD(I8
,I1
,100,10,I8
,0);
2471 VARMOD(I8
,UI1
,100,10,I8
,0);
2472 VARMOD(I8
,I2
,100,10,I8
,0);
2473 VARMOD(I8
,UI2
,100,10,I8
,0);
2474 VARMOD(I8
,I4
,100,10,I8
,0);
2475 VARMOD(I8
,UI4
,100,10,I8
,0);
2476 VARMOD(I8
,R4
,100,10,I8
,0);
2477 VARMOD(I8
,R8
,100,10,I8
,0);
2478 VARMOD(I8
,I8
,100,10,I8
,0);
2480 VARMOD(BSTR
,I8
,strNum0
,10,I8
,5);
2483 /* test all combinations of types */
2484 for(l
= 0; l
< VT_BSTR_BLOB
; l
++)
2488 for(r
= 0; r
< VT_BSTR_BLOB
; r
++)
2492 if(l
== VT_BSTR
) continue;
2493 if(l
== VT_DISPATCH
) continue;
2494 if(r
== VT_BSTR
) continue;
2495 if(r
== VT_DISPATCH
) continue;
2529 hexpected
= DISP_E_BADVARTYPE
;
2568 if(((l
== VT_I8
) && (r
== VT_INT
)) || ((l
== VT_INT
) && (r
== VT_I8
)))
2570 hexpected
= DISP_E_TYPEMISMATCH
;
2571 } else if((l
== VT_EMPTY
) && (r
== VT_NULL
))
2574 } else if((l
== VT_NULL
) && (r
== VT_EMPTY
))
2577 } else if((l
== VT_EMPTY
) && (r
== VT_CY
))
2580 } else if((l
== VT_EMPTY
) && (r
== VT_RECORD
))
2582 hexpected
= DISP_E_TYPEMISMATCH
;
2583 } else if((r
== VT_EMPTY
) && lFound
&& lValid
)
2585 hexpected
= DISP_E_DIVBYZERO
;
2586 } else if((l
== VT_ERROR
) || ((r
== VT_ERROR
) && lFound
&& lValid
))
2588 hexpected
= DISP_E_TYPEMISMATCH
;
2589 } else if((l
== VT_NULL
) && (r
== VT_NULL
))
2592 } else if((l
== VT_VARIANT
) || ((r
== VT_VARIANT
) && lFound
&& lValid
))
2594 hexpected
= DISP_E_TYPEMISMATCH
;
2595 } else if((l
== VT_NULL
) && (r
== VT_RECORD
))
2597 hexpected
= DISP_E_TYPEMISMATCH
;
2598 } else if((l
== VT_I8
) && (r
== VT_DECIMAL
))
2601 } else if((l
== VT_DECIMAL
) && (r
== VT_I8
))
2604 } else if((l
== VT_UNKNOWN
) || ((r
== VT_UNKNOWN
) && lFound
&& lValid
))
2606 hexpected
= DISP_E_TYPEMISMATCH
;
2607 } else if((l
== VT_NULL
) && rFound
)
2610 } else if(l
== VT_RECORD
)
2612 hexpected
= DISP_E_TYPEMISMATCH
;
2613 } else if((r
== VT_RECORD
) && lValid
&& lFound
)
2615 hexpected
= DISP_E_TYPEMISMATCH
;
2616 } else if((l
== VT_EMPTY
) && (r
== VT_EMPTY
))
2618 hexpected
= DISP_E_DIVBYZERO
;
2619 } else if((l
== VT_CY
) && !rFound
)
2621 hexpected
= DISP_E_BADVARTYPE
;
2622 } else if(lFound
&& !rFound
)
2624 hexpected
= DISP_E_BADVARTYPE
;
2625 } else if(!lFound
&& rFound
)
2627 hexpected
= DISP_E_BADVARTYPE
;
2628 } else if((r
== VT_NULL
) && lFound
&& lValid
)
2631 } else if((l
== VT_NULL
) || (r
== VT_NULL
))
2633 hexpected
= DISP_E_BADVARTYPE
;
2634 } else if((l
== VT_VARIANT
) || (r
== VT_VARIANT
))
2636 hexpected
= DISP_E_BADVARTYPE
;
2637 } else if(lFound
&& !rFound
)
2639 hexpected
= DISP_E_BADVARTYPE
;
2640 } else if(!lFound
&& !rFound
)
2642 hexpected
= DISP_E_BADVARTYPE
;
2649 V_CY(&v1
).int64
= 1000000;
2654 else if(l
== VT_UI8
)
2658 else if(l
== VT_DATE
)
2660 else if (l
== VT_DECIMAL
)
2662 V_DECIMAL(&v1
).Hi32
= 0;
2663 U1(V_DECIMAL(&v1
)).Lo64
= 100;
2664 U(V_DECIMAL(&v1
)).signscale
= 0;
2670 V_CY(&v2
).int64
= 10000;
2675 else if(r
== VT_UI8
)
2679 else if(r
== VT_DATE
)
2681 else if (r
== VT_DECIMAL
)
2683 V_DECIMAL(&v2
).Hi32
= 0;
2684 U1(V_DECIMAL(&v2
)).Lo64
= 100;
2685 U(V_DECIMAL(&v2
)).signscale
= 0;
2690 if ((l
!= VT_I8
&& l
!= VT_UI8
&& r
!= VT_I8
&& r
!= VT_UI8
) || HAVE_OLEAUT32_I8
)
2692 hres
= pVarMod(&v1
,&v2
,&vDst
);
2693 ok(hres
== hexpected
,
2694 "VarMod: expected 0x%x, got 0x%X for l type of %d, r type of %d,\n", hexpected
, hres
, l
, r
);
2700 /****************************/
2701 /* test some bad parameters */
2702 VARMOD(I4
,I4
,-1,-1,I4
,0);
2704 /* test modulus with zero */
2705 VARMOD2(I4
,I4
,100,0,EMPTY
,0,DISP_E_DIVBYZERO
);
2707 VARMOD(I4
,I4
,0,10,I4
,0); /* test 0 mod 10 */
2709 /* right parameter is type empty */
2710 VARMOD2(I4
,EMPTY
,100,10,EMPTY
,0,DISP_E_DIVBYZERO
);
2712 /* left parameter is type empty */
2713 VARMOD2(EMPTY
,I4
,100,10,I4
,0,S_OK
);
2715 /* mod with a null left value */
2716 VARMOD2(NULL
,I4
,125,10,NULL
,0,S_OK
);
2718 /* mod with a null right value */
2719 VARMOD2(I4
,NULL
,100,10,NULL
,0,S_OK
);
2721 /* void left value */
2722 VARMOD2(VOID
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2724 /* void right value */
2725 VARMOD2(I4
,VOID
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2727 /* null left value, void right value */
2728 VARMOD2(NULL
,VOID
,100,10,EMPTY
, 0, DISP_E_BADVARTYPE
);
2730 /* void left value, null right value */
2731 VARMOD2(VOID
,NULL
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2733 /* some currencies */
2736 V_CY(&v1
).int64
= 100000;
2737 V_CY(&v2
).int64
= 100000;
2738 hres
= pVarMod(&v1
,&v2
,&vDst
);
2739 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I4
&& V_I4(&vDst
) == 0,
2740 "VarMod: expected 0x%x,%d,%d, got 0x%X,%d,%d\n", S_OK
, VT_I4
, 0, hres
, V_VT(&vDst
), V_I4(&vDst
));
2745 V_CY(&v2
).int64
= 100000;
2746 hres
= pVarMod(&v1
,&v2
,&vDst
);
2747 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I4
&& V_I4(&vDst
) == 0,
2748 "VarMod: expected 0x%x,%d,%d, got 0x%X,%d,%d\n", S_OK
, VT_I4
, 0, hres
, V_VT(&vDst
), V_I4(&vDst
));
2751 V_VT(&v1
) = VT_DECIMAL
;
2752 V_VT(&v2
) = VT_DECIMAL
;
2753 VarDecFromI4(100, &V_DECIMAL(&v1
));
2754 VarDecFromI4(10, &V_DECIMAL(&v2
));
2755 hres
= pVarMod(&v1
,&v2
,&vDst
);
2756 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I4
&& V_I4(&vDst
) == 0,
2757 "VarMod: expected 0x%x,%d,%d, got 0x%X,%d,%d\n", S_OK
, VT_I4
, 0, hres
, V_VT(&vDst
), V_I4(&vDst
));
2760 V_VT(&v2
) = VT_DECIMAL
;
2762 VarDecFromI4(10, &V_DECIMAL(&v2
));
2763 hres
= pVarMod(&v1
,&v2
,&vDst
);
2764 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I4
&& V_I4(&vDst
) == 0,
2765 "VarMod: expected 0x%x,%d,%d, got 0x%X,%d,%d\n", S_OK
, VT_I4
, 0, hres
, V_VT(&vDst
), V_I4(&vDst
));
2767 VARMOD2(UINT
,I4
,100,10,I4
,0,S_OK
);
2769 /* test that an error results in the type of the result changing but not its value */
2770 V_VT(&v1
) = VT_UNKNOWN
;
2771 V_VT(&v2
) = VT_EMPTY
;
2773 V_CY(&v2
).int64
= 100000;
2774 V_VT(&vDst
) = VT_I4
;
2776 hres
= pVarMod(&v1
,&v2
,&vDst
);
2777 ok(hres
== DISP_E_TYPEMISMATCH
&& V_VT(&vDst
) == VT_EMPTY
&& V_I4(&vDst
) == 1231,
2778 "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
));
2781 /* test some invalid types */
2782 /*TODO: not testing VT_DISPATCH */
2783 if (HAVE_OLEAUT32_I8
)
2785 VARMOD2(I8
,INT
,100,10,EMPTY
,0,DISP_E_TYPEMISMATCH
);
2787 VARMOD2(ERROR
,I4
,100,10,EMPTY
,0,DISP_E_TYPEMISMATCH
);
2788 VARMOD2(VARIANT
,I4
,100,10,EMPTY
,0,DISP_E_TYPEMISMATCH
);
2789 VARMOD2(UNKNOWN
,I4
,100,10,EMPTY
,0,DISP_E_TYPEMISMATCH
);
2790 VARMOD2(VOID
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2791 VARMOD2(HRESULT
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2792 VARMOD2(PTR
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2793 VARMOD2(SAFEARRAY
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2794 VARMOD2(CARRAY
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2795 VARMOD2(USERDEFINED
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2796 VARMOD2(LPSTR
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2797 VARMOD2(LPWSTR
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2798 VARMOD2(RECORD
,I4
,100,10,EMPTY
,0,DISP_E_TYPEMISMATCH
);
2799 VARMOD2(FILETIME
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2800 VARMOD2(BLOB
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2801 VARMOD2(STREAM
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2802 VARMOD2(STORAGE
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2803 VARMOD2(STREAMED_OBJECT
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2804 VARMOD2(STORED_OBJECT
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2805 VARMOD2(BLOB_OBJECT
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2806 VARMOD2(CF
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2807 VARMOD2(CLSID
,CLSID
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2808 VARMOD2(VECTOR
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2809 VARMOD2(ARRAY
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2810 VARMOD2(BYREF
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2812 /* test some more invalid types */
2817 hres
= pVarMod(&v1
,&v2
,&vDst
);
2818 ok(hres
== DISP_E_BADVARTYPE
&& V_VT(&vDst
) == VT_EMPTY
,
2819 "VarMod: expected 0x%x,%d, got 0x%X,%d\n", DISP_E_BADVARTYPE
, VT_EMPTY
, hres
, V_VT(&vDst
));
2821 SysFreeString(strNum0
);
2822 SysFreeString(strNum1
);
2825 static HRESULT (WINAPI
*pVarFix
)(LPVARIANT
,LPVARIANT
);
2827 #define VARFIX(vt,val,rvt,rval) \
2828 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
2829 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
2830 test_var_call1( __LINE__, pVarFix, &v, &exp )
2832 static void test_VarFix(void)
2834 static const WCHAR szNumMinus1
[] = {'-','1','\0' };
2836 VARIANT v
, exp
, vDst
;
2837 DECIMAL
*pdec
= &V_DECIMAL(&v
);
2838 CY
*pcy
= &V_CY(&v
);
2843 /* Test all possible V_VT values */
2844 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
2848 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
2850 HRESULT bFail
= TRUE
;
2854 memset(&v
, 0, sizeof(v
));
2855 V_VT(&v
) = vt
| ExtraFlags
[i
];
2856 V_VT(&vDst
) = VT_EMPTY
;
2860 case VT_UI1
: case VT_I2
: case VT_I4
: case VT_R4
: case VT_R8
:
2861 case VT_DECIMAL
: case VT_BOOL
: case VT_NULL
: case VT_EMPTY
:
2862 case VT_DATE
: case VT_CY
:
2866 if (HAVE_OLEAUT32_I8
)
2871 hres
= pVarFix(&v
,&vDst
);
2873 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
2874 "VarFix: expected failure, got 0x%X vt %d|0x%X\n",
2875 hres
, vt
, ExtraFlags
[i
]);
2877 ok(hres
== S_OK
, "VarFix: expected S_OK, got 0x%X vt %d|0x%X\n",
2878 hres
, vt
, ExtraFlags
[i
]);
2882 VARFIX(BOOL
,VARIANT_TRUE
,I2
,VARIANT_TRUE
);
2883 VARFIX(BOOL
,VARIANT_FALSE
,I2
,0);
2884 VARFIX(BOOL
,1,I2
,1);
2885 VARFIX(UI1
,1,UI1
,1);
2886 VARFIX(I2
,-1,I2
,-1);
2887 VARFIX(I4
,-1,I4
,-1);
2888 if (HAVE_OLEAUT32_I8
)
2890 VARFIX(I8
,-1,I8
,-1);
2892 VARFIX(R4
,1.4f
,R4
,1);
2893 VARFIX(R4
,1.5f
,R4
,1);
2894 VARFIX(R4
,1.6f
,R4
,1);
2895 VARFIX(R4
,-1.4f
,R4
,-1);
2896 VARFIX(R4
,-1.5f
,R4
,-1);
2897 VARFIX(R4
,-1.6f
,R4
,-1);
2898 /* DATE & R8 round as for R4 */
2899 VARFIX(DATE
,-1,DATE
,-1);
2900 VARFIX(R8
,-1,R8
,-1);
2901 VARFIX(BSTR
,(BSTR
)szNumMinus1
,R8
,-1);
2903 V_VT(&v
) = VT_EMPTY
;
2904 hres
= pVarFix(&v
,&vDst
);
2905 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I2
&& V_I2(&vDst
) == 0,
2906 "VarFix: expected 0x0,%d,0 got 0x%X,%d,%d\n", VT_EMPTY
,
2907 hres
, V_VT(&vDst
), V_I2(&vDst
));
2910 hres
= pVarFix(&v
,&vDst
);
2911 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_NULL
,
2912 "VarFix: expected 0x0,%d got 0x%X,%d\n", VT_NULL
, hres
, V_VT(&vDst
));
2914 V_VT(&v
) = VT_DECIMAL
;
2915 S(U(*pdec
)).sign
= DECIMAL_NEG
;
2916 S(U(*pdec
)).scale
= 0;
2918 S1(U1(*pdec
)).Mid32
= 0;
2919 S1(U1(*pdec
)).Lo32
= 1;
2920 hres
= pVarFix(&v
,&vDst
);
2921 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_DECIMAL
&& !memcmp(&V_DECIMAL(&v
), &V_DECIMAL(&vDst
), sizeof(DECIMAL
)),
2922 "VarFix: expected 0x0,%d,identical, got 0x%X,%d\n", VT_DECIMAL
,
2925 /* FIXME: Test some fractional decimals when VarDecFix is implemented */
2928 pcy
->int64
= -10000;
2929 hres
= pVarFix(&v
,&vDst
);
2930 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_CY
&& V_CY(&vDst
).int64
== -10000,
2931 "VarFix: VT_CY wrong, hres=0x%X\n", hres
);
2934 pcy
->int64
= -16000;
2935 hres
= pVarFix(&v
,&vDst
);
2936 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_CY
&& V_CY(&vDst
).int64
== -10000,
2937 "VarFix: VT_CY wrong, hres=0x%X\n", hres
);
2940 static HRESULT (WINAPI
*pVarInt
)(LPVARIANT
,LPVARIANT
);
2942 #define VARINT(vt,val,rvt,rval) \
2943 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
2944 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
2945 test_var_call1( __LINE__, pVarInt, &v, &exp )
2947 static void test_VarInt(void)
2949 static const WCHAR szNumMinus1
[] = {'-','1','\0' };
2951 VARIANT v
, exp
, vDst
;
2952 DECIMAL
*pdec
= &V_DECIMAL(&v
);
2953 CY
*pcy
= &V_CY(&v
);
2958 /* Test all possible V_VT values */
2959 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
2963 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
2965 HRESULT bFail
= TRUE
;
2969 memset(&v
, 0, sizeof(v
));
2970 V_VT(&v
) = vt
| ExtraFlags
[i
];
2971 V_VT(&vDst
) = VT_EMPTY
;
2975 case VT_UI1
: case VT_I2
: case VT_I4
: case VT_R4
: case VT_R8
:
2976 case VT_DECIMAL
: case VT_BOOL
: case VT_NULL
: case VT_EMPTY
:
2977 case VT_DATE
: case VT_CY
:
2981 if (HAVE_OLEAUT32_I8
)
2986 hres
= pVarInt(&v
,&vDst
);
2988 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
2989 "VarInt: expected failure, got 0x%X vt %d|0x%X\n",
2990 hres
, vt
, ExtraFlags
[i
]);
2992 ok(hres
== S_OK
, "VarInt: expected S_OK, got 0x%X vt %d|0x%X\n",
2993 hres
, vt
, ExtraFlags
[i
]);
2997 VARINT(BOOL
,VARIANT_TRUE
,I2
,VARIANT_TRUE
);
2998 VARINT(BOOL
,VARIANT_FALSE
,I2
,0);
2999 VARINT(BOOL
,1,I2
,1);
3000 VARINT(UI1
,1,UI1
,1);
3001 VARINT(I2
,-1,I2
,-1);
3002 VARINT(I4
,-1,I4
,-1);
3003 if (HAVE_OLEAUT32_I8
)
3005 VARINT(I8
,-1,I8
,-1);
3007 VARINT(R4
,1.4f
,R4
,1);
3008 VARINT(R4
,1.5f
,R4
,1);
3009 VARINT(R4
,1.6f
,R4
,1);
3010 VARINT(R4
,-1.4f
,R4
,-2); /* Note these 3 are different from VarFix */
3011 VARINT(R4
,-1.5f
,R4
,-2);
3012 VARINT(R4
,-1.6f
,R4
,-2);
3013 /* DATE & R8 round as for R4 */
3014 VARINT(DATE
,-1,DATE
,-1);
3015 VARINT(R8
,-1,R8
,-1);
3016 VARINT(BSTR
,(BSTR
)szNumMinus1
,R8
,-1);
3018 V_VT(&v
) = VT_EMPTY
;
3019 hres
= pVarInt(&v
,&vDst
);
3020 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I2
&& V_I2(&vDst
) == 0,
3021 "VarInt: expected 0x0,%d,0 got 0x%X,%d,%d\n", VT_EMPTY
,
3022 hres
, V_VT(&vDst
), V_I2(&vDst
));
3025 hres
= pVarInt(&v
,&vDst
);
3026 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_NULL
,
3027 "VarInt: expected 0x0,%d got 0x%X,%d\n", VT_NULL
, hres
, V_VT(&vDst
));
3029 V_VT(&v
) = VT_DECIMAL
;
3030 S(U(*pdec
)).sign
= DECIMAL_NEG
;
3031 S(U(*pdec
)).scale
= 0;
3033 S1(U1(*pdec
)).Mid32
= 0;
3034 S1(U1(*pdec
)).Lo32
= 1;
3035 hres
= pVarInt(&v
,&vDst
);
3036 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_DECIMAL
&& !memcmp(&V_DECIMAL(&v
), &V_DECIMAL(&vDst
), sizeof(DECIMAL
)),
3037 "VarInt: expected 0x0,%d,identical, got 0x%X,%d\n", VT_DECIMAL
,
3040 /* FIXME: Test some fractional decimals when VarDecInt is implemented */
3043 pcy
->int64
= -10000;
3044 hres
= pVarInt(&v
,&vDst
);
3045 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_CY
&& V_CY(&vDst
).int64
== -10000,
3046 "VarInt: VT_CY wrong, hres=0x%X\n", hres
);
3049 pcy
->int64
= -11000;
3050 hres
= pVarInt(&v
,&vDst
);
3051 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_CY
&& V_CY(&vDst
).int64
== -20000,
3052 "VarInt: VT_CY wrong, hres=0x%X 0x%x%08x\n",
3053 hres
, (DWORD
)(V_CY(&vDst
).int64
>> 32), (DWORD
)V_CY(&vDst
).int64
);
3056 static HRESULT (WINAPI
*pVarNeg
)(LPVARIANT
,LPVARIANT
);
3058 #define VARNEG(vt,val,rvt,rval) \
3059 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
3060 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
3061 test_var_call1( __LINE__, pVarNeg, &v, &exp )
3063 static void test_VarNeg(void)
3065 static const WCHAR szNumMinus1
[] = {'-','1','\0' };
3066 static const WCHAR szNum1
[] = {'1','\0' };
3068 VARIANT v
, exp
, vDst
;
3069 DECIMAL
*pdec
= &V_DECIMAL(&v
);
3070 CY
*pcy
= &V_CY(&v
);
3075 /* Test all possible V_VT values. But don't test the exact return values
3076 * except for success/failure, since M$ made a hash of them in the
3077 * native version. This at least ensures (as with all tests here) that
3078 * we will notice if/when new vtypes/flags are added in native.
3080 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
3084 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
3086 HRESULT bFail
= TRUE
;
3090 memset(&v
, 0, sizeof(v
));
3091 V_VT(&v
) = vt
| ExtraFlags
[i
];
3092 V_VT(&vDst
) = VT_EMPTY
;
3096 case VT_UI1
: case VT_I2
: case VT_I4
:
3097 case VT_R4
: case VT_R8
:
3098 case VT_DECIMAL
: case VT_BOOL
: case VT_NULL
: case VT_EMPTY
:
3099 case VT_DATE
: case VT_CY
:
3103 if (HAVE_OLEAUT32_I8
)
3107 hres
= pVarNeg(&v
,&vDst
);
3109 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
3110 "VarNeg: expected failure, got 0x%X vt %d|0x%X\n",
3111 hres
, vt
, ExtraFlags
[i
]);
3113 ok(hres
== S_OK
, "VarNeg: expected S_OK, got 0x%X vt %d|0x%X\n",
3114 hres
, vt
, ExtraFlags
[i
]);
3118 VARNEG(BOOL
,VARIANT_TRUE
,I2
,1);
3119 VARNEG(BOOL
,VARIANT_FALSE
,I2
,0);
3120 VARNEG(BOOL
,1,I2
,-1);
3121 VARNEG(UI1
,1,I2
,-1);
3122 VARNEG(UI1
,254,I2
,-254);
3123 VARNEG(I2
,-32768,I4
,32768);
3126 VARNEG(I4
,-((int)(~0u >> 1)) - 1,R8
,-2147483648u);
3129 if (HAVE_OLEAUT32_I8
)
3136 VARNEG(DATE
,1,DATE
,-1);
3137 VARNEG(DATE
,-1,DATE
,1);
3140 VARNEG(BSTR
,(BSTR
)szNumMinus1
,R8
,1);
3141 VARNEG(BSTR
,(BSTR
)szNum1
,R8
,-1);
3143 V_VT(&v
) = VT_EMPTY
;
3144 hres
= pVarNeg(&v
,&vDst
);
3145 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I2
&& V_I2(&vDst
) == 0,
3146 "VarNeg: expected 0x0,%d,0 got 0x%X,%d,%d\n", VT_EMPTY
,
3147 hres
, V_VT(&vDst
), V_I2(&vDst
));
3150 hres
= pVarNeg(&v
,&vDst
);
3151 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_NULL
,
3152 "VarNeg: expected 0x0,%d got 0x%X,%d\n", VT_NULL
, hres
, V_VT(&vDst
));
3154 V_VT(&v
) = VT_DECIMAL
;
3155 S(U(*pdec
)).sign
= DECIMAL_NEG
;
3156 S(U(*pdec
)).scale
= 0;
3158 S1(U1(*pdec
)).Mid32
= 0;
3159 S1(U1(*pdec
)).Lo32
= 1;
3160 hres
= pVarNeg(&v
,&vDst
);
3161 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_DECIMAL
&&
3162 S(U(V_DECIMAL(&vDst
))).sign
== 0,
3163 "VarNeg: expected 0x0,%d,0x00, got 0x%X,%d,%02x\n", VT_DECIMAL
,
3164 hres
, V_VT(&vDst
), S(U(V_DECIMAL(&vDst
))).sign
);
3166 S(U(*pdec
)).sign
= 0;
3167 hres
= pVarNeg(&v
,&vDst
);
3168 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_DECIMAL
&&
3169 S(U(V_DECIMAL(&vDst
))).sign
== DECIMAL_NEG
,
3170 "VarNeg: expected 0x0,%d,0x7f, got 0x%X,%d,%02x\n", VT_DECIMAL
,
3171 hres
, V_VT(&vDst
), S(U(V_DECIMAL(&vDst
))).sign
);
3174 pcy
->int64
= -10000;
3175 hres
= pVarNeg(&v
,&vDst
);
3176 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_CY
&& V_CY(&vDst
).int64
== 10000,
3177 "VarNeg: VT_CY wrong, hres=0x%X\n", hres
);
3180 static HRESULT (WINAPI
*pVarRound
)(LPVARIANT
,int,LPVARIANT
);
3182 static void test_Round( int line
, VARIANT
*arg
, int deci
, VARIANT
*expected
)
3187 memset( &result
, 0, sizeof(result
) );
3188 hres
= pVarRound( arg
, deci
, &result
);
3189 ok_(__FILE__
,line
)( hres
== S_OK
, "wrong result %x\n", hres
);
3191 ok_(__FILE__
,line
)( is_expected_variant( &result
, expected
),
3192 "got %s expected %s\n", variantstr(&result
), variantstr(expected
) );
3194 #define VARROUND(vt,val,deci,rvt,rval) \
3195 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
3196 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
3197 test_Round( __LINE__, &v, deci, &exp )
3199 static void test_VarRound(void)
3201 static WCHAR szNumMin
[] = {'-','1','.','4','4','9','\0' };
3202 static WCHAR szNum
[] = {'1','.','4','5','1','\0' };
3204 VARIANT v
, exp
, vDst
;
3205 CY
*pcy
= &V_CY(&v
);
3210 /* first check valid integer types */
3211 VARROUND(BOOL
,VARIANT_TRUE
,0,I2
,-1);
3212 VARROUND(BOOL
,VARIANT_FALSE
,0,I2
,0);
3213 VARROUND(BOOL
,1,0,I2
,1);
3214 VARROUND(UI1
,1,0,UI1
,1);
3215 VARROUND(UI1
,254,0,UI1
,254);
3216 VARROUND(I2
,-32768,0,I2
,-32768);
3217 VARROUND(I2
,-1,0,I2
,-1);
3218 VARROUND(I2
,1,0,I2
,1);
3219 VARROUND(I4
,-((int)(~0u >> 1)) - 1,0,I4
,-((int)(~0u >> 1)) - 1);
3220 VARROUND(I4
,-1,0,I4
,-1);
3221 VARROUND(I4
,1,0,I4
,1);
3224 /* MSDN states that rounding of R4/R8 is dependent on the underlying
3225 * bit pattern of the number and so is architecture dependent. In this
3226 * case Wine returns .2 (which is more correct) and Native returns .3
3229 VARROUND(R4
,1.0f
,0,R4
,1.0f
);
3230 VARROUND(R4
,-1.0f
,0,R4
,-1.0f
);
3231 VARROUND(R8
,1.0,0,R8
,1.0);
3232 VARROUND(R8
,-1.0,0,R8
,-1.0);
3234 /* floating point numbers aren't exactly equal and we can't just
3235 * compare the first few digits. */
3236 VARROUND(DATE
,1.451,1,DATE
,1.5);
3237 VARROUND(DATE
,-1.449,1,DATE
,-1.4);
3239 /* replace the decimal separator */
3240 GetLocaleInfoA(LOCALE_USER_DEFAULT
, LOCALE_SDECIMAL
, buff
, sizeof(buff
)/sizeof(char));
3242 szNumMin
[2] = buff
[0];
3244 VARROUND(BSTR
,(BSTR
)szNumMin
,1,R8
,-1.40);
3245 VARROUND(BSTR
,(BSTR
)szNum
,1,R8
,1.50);
3247 skip("Skipping VarRound(BSTR) as decimal separator is '%s'\n", buff
);
3250 VARROUND(R4
,1.23456f
,0,R4
,1.0f
);
3251 VARROUND(R4
,1.23456f
,1,R4
,1.2f
);
3252 VARROUND(R4
,1.23456f
,2,R4
,1.23f
);
3253 VARROUND(R4
,1.23456f
,3,R4
,1.235f
);
3254 VARROUND(R4
,1.23456f
,4,R4
,1.2346f
);
3255 VARROUND(R4
,-1.23456f
,0,R4
,-1.0f
);
3256 VARROUND(R4
,-1.23456f
,1,R4
,-1.2f
);
3257 VARROUND(R4
,-1.23456f
,2,R4
,-1.23f
);
3258 VARROUND(R4
,-1.23456f
,3,R4
,-1.235f
);
3259 VARROUND(R4
,-1.23456f
,4,R4
,-1.2346f
);
3261 VARROUND(R8
,1.23456,0,R8
,1.0);
3262 VARROUND(R8
,1.23456,1,R8
,1.2);
3263 VARROUND(R8
,1.23456,2,R8
,1.23);
3264 VARROUND(R8
,1.23456,3,R8
,1.235);
3265 VARROUND(R8
,1.23456,4,R8
,1.2346);
3266 VARROUND(R8
,-1.23456,0,R8
,-1.0);
3267 VARROUND(R8
,-1.23456,1,R8
,-1.2);
3268 VARROUND(R8
,-1.23456,2,R8
,-1.23);
3269 VARROUND(R8
,-1.23456,3,R8
,-1.235);
3270 VARROUND(R8
,-1.23456,4,R8
,-1.2346);
3272 V_VT(&v
) = VT_EMPTY
;
3273 hres
= pVarRound(&v
,0,&vDst
);
3274 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I2
&& V_I2(&vDst
) == 0,
3275 "VarRound: expected 0x0,%d,0 got 0x%X,%d,%d\n", VT_EMPTY
,
3276 hres
, V_VT(&vDst
), V_I2(&vDst
));
3279 hres
= pVarRound(&v
,0,&vDst
);
3280 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_NULL
,
3281 "VarRound: expected 0x0,%d got 0x%X,%d\n", VT_NULL
, hres
, V_VT(&vDst
));
3283 /* not yet implemented so no use testing yet
3285 DECIMAL *pdec = &V_DECIMAL(&v);
3286 V_VT(&v) = VT_DECIMAL;
3287 S(U(*pdec)).sign = DECIMAL_NEG;
3288 S(U(*pdec)).scale = 0;
3290 S1(U1(*pdec)).Mid32 = 0;
3291 S1(U1(*pdec)).Lo32 = 1;
3292 hres = pVarRound(&v,0,&vDst);
3293 ok(hres == S_OK && V_VT(&vDst) == VT_DECIMAL &&
3294 S(U(V_DECIMAL(&vDst))).sign == 0,
3295 "VarRound: expected 0x0,%d,0x00, got 0x%X,%d,%02x\n", VT_DECIMAL,
3296 hres, V_VT(&vDst), S(U(V_DECIMAL(&vDst))).sign);
3298 S(U(*pdec)).sign = 0;
3299 hres = pVarRound(&v,0,&vDst);
3300 ok(hres == S_OK && V_VT(&vDst) == VT_DECIMAL &&
3301 S(U(V_DECIMAL(&vDst))).sign == DECIMAL_NEG,
3302 "VarRound: expected 0x0,%d,0x7f, got 0x%X,%d,%02x\n", VT_DECIMAL,
3303 hres, V_VT(&vDst), S(U(V_DECIMAL(&vDst))).sign);
3309 hres
= pVarRound(&v
,0,&vDst
);
3310 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_CY
&& V_CY(&vDst
).int64
== 10000,
3311 "VarRound: VT_CY wrong, hres=0x%X\n", hres
);
3315 static HRESULT (WINAPI
*pVarXor
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
3317 #define VARXOR(vt1,val1,vt2,val2,rvt,rval) \
3318 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
3319 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
3320 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
3321 test_var_call2( __LINE__, pVarXor, &left, &right, &exp )
3323 #define VARXORCY(vt1,val1,val2,rvt,rval) \
3324 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
3325 V_VT(&right) = VT_CY; V_CY(&right).int64 = val2; \
3326 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
3327 test_var_call2( __LINE__, pVarXor, &left, &right, &exp )
3329 static void test_VarXor(void)
3331 static const WCHAR szFalse
[] = { '#','F','A','L','S','E','#','\0' };
3332 static const WCHAR szTrue
[] = { '#','T','R','U','E','#','\0' };
3333 VARIANT left
, right
, exp
, result
;
3340 /* Test all possible flag/vt combinations & the resulting vt type */
3341 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
3343 VARTYPE leftvt
, rightvt
, resvt
;
3345 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
3350 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
3356 if (leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
||
3357 leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
||
3358 leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
)
3361 memset(&left
, 0, sizeof(left
));
3362 memset(&right
, 0, sizeof(right
));
3363 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
3364 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
3365 V_VT(&result
) = VT_EMPTY
;
3368 if (ExtraFlags
[i
] & VT_ARRAY
|| ExtraFlags
[i
] & VT_BYREF
||
3369 !IsValidVariantClearVT(leftvt
, ExtraFlags
[i
]) ||
3370 !IsValidVariantClearVT(rightvt
, ExtraFlags
[i
]) ||
3371 leftvt
== VT_CLSID
|| rightvt
== VT_CLSID
||
3372 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
||
3373 leftvt
== VT_VARIANT
|| rightvt
== VT_VARIANT
||
3374 leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
)
3378 if (leftvt
== VT_EMPTY
|| rightvt
== VT_EMPTY
)
3380 if (leftvt
== rightvt
||
3381 leftvt
== VT_I2
|| rightvt
== VT_I2
||
3382 leftvt
== VT_UI1
|| rightvt
== VT_UI1
||
3383 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
3385 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
3387 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
3390 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
3394 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
3396 if (leftvt
== rightvt
)
3398 else if (leftvt
== rightvt
||
3399 leftvt
== VT_I2
|| rightvt
== VT_I2
||
3400 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
3404 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
3407 else if (leftvt
== VT_I2
|| rightvt
== VT_I2
)
3409 if (leftvt
== rightvt
||
3410 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
3412 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
3415 else if (leftvt
== VT_BOOL
&& rightvt
== VT_BOOL
)
3419 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
3421 if (leftvt
== VT_INT
|| rightvt
== VT_INT
)
3426 hres
= pVarXor(&left
, &right
, &result
);
3428 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
3429 "VarXor: %d|0x%X, %d|0x%X: Expected failure, got 0x%X vt %d\n",
3430 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], hres
,
3433 ok(hres
== S_OK
&& V_VT(&result
) == resvt
,
3434 "VarXor: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%X vt %d\n",
3435 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], resvt
, hres
,
3441 /* Test returned values
3442 * FIXME: Test VT_DECIMAL/VT_DISPATCH
3444 VARXOR(EMPTY
,0,EMPTY
,0,I2
,0);
3445 VARXOR(EMPTY
,1,EMPTY
,0,I2
,0);
3446 VARXOR(EMPTY
,0,NULL
,0,NULL
,0);
3447 VARXOR(EMPTY
,0,I1
,0,I4
,0);
3448 VARXOR(EMPTY
,0,I1
,1,I4
,1);
3449 VARXOR(EMPTY
,0,UI1
,0,I2
,0);
3450 VARXOR(EMPTY
,0,UI1
,1,I2
,1);
3451 VARXOR(EMPTY
,0,I2
,0,I2
,0);
3452 VARXOR(EMPTY
,0,I2
,1,I2
,1);
3453 VARXOR(EMPTY
,0,UI2
,0,I4
,0);
3454 VARXOR(EMPTY
,0,UI2
,1,I4
,1);
3455 VARXOR(EMPTY
,0,I4
,0,I4
,0);
3456 VARXOR(EMPTY
,0,I4
,1,I4
,1);
3457 VARXOR(EMPTY
,0,UI4
,0,I4
,0);
3458 VARXOR(EMPTY
,0,UI4
,1,I4
,1);
3459 if (HAVE_OLEAUT32_I8
)
3461 VARXOR(EMPTY
,0,I8
,0,I8
,0);
3462 VARXOR(EMPTY
,0,I8
,1,I8
,1);
3463 VARXOR(EMPTY
,0,UI8
,0,I4
,0);
3464 VARXOR(EMPTY
,0,UI8
,1,I4
,1);
3466 VARXOR(EMPTY
,0,INT
,0,I4
,0);
3467 VARXOR(EMPTY
,0,INT
,1,I4
,1);
3468 VARXOR(EMPTY
,0,UINT
,0,I4
,0);
3469 VARXOR(EMPTY
,0,UINT
,1,I4
,1);
3470 VARXOR(EMPTY
,0,BOOL
,0,I2
,0);
3471 VARXOR(EMPTY
,0,BOOL
,1,I2
,1);
3472 VARXOR(EMPTY
,0,R4
,0,I4
,0);
3473 VARXOR(EMPTY
,0,R4
,1,I4
,1);
3474 VARXOR(EMPTY
,0,R8
,0,I4
,0);
3475 VARXOR(EMPTY
,0,R8
,1,I4
,1);
3476 rbstr
= SysAllocString(szFalse
);
3477 VARXOR(EMPTY
,0,BSTR
,rbstr
,I2
,0);
3478 SysFreeString(rbstr
);
3479 rbstr
= SysAllocString(szTrue
);
3480 VARXOR(EMPTY
,0,BSTR
,rbstr
,I2
,-1);
3481 VARXORCY(EMPTY
,0,10000,I4
,1);
3482 SysFreeString(rbstr
);
3484 /* NULL OR 0 = NULL. NULL OR n = n */
3485 VARXOR(NULL
,0,NULL
,0,NULL
,0);
3486 VARXOR(NULL
,1,NULL
,0,NULL
,0);
3487 VARXOR(NULL
,0,I1
,0,NULL
,0);
3488 VARXOR(NULL
,0,I1
,1,NULL
,0);
3489 VARXOR(NULL
,0,UI1
,0,NULL
,0);
3490 VARXOR(NULL
,0,UI1
,1,NULL
,0);
3491 VARXOR(NULL
,0,I2
,0,NULL
,0);
3492 VARXOR(NULL
,0,I2
,1,NULL
,0);
3493 VARXOR(NULL
,0,UI2
,0,NULL
,0);
3494 VARXOR(NULL
,0,UI2
,1,NULL
,0);
3495 VARXOR(NULL
,0,I4
,0,NULL
,0);
3496 VARXOR(NULL
,0,I4
,1,NULL
,0);
3497 VARXOR(NULL
,0,UI4
,0,NULL
,0);
3498 VARXOR(NULL
,0,UI4
,1,NULL
,0);
3499 if (HAVE_OLEAUT32_I8
)
3501 VARXOR(NULL
,0,I8
,0,NULL
,0);
3502 VARXOR(NULL
,0,I8
,1,NULL
,0);
3503 VARXOR(NULL
,0,UI8
,0,NULL
,0);
3504 VARXOR(NULL
,0,UI8
,1,NULL
,0);
3506 VARXOR(NULL
,0,INT
,0,NULL
,0);
3507 VARXOR(NULL
,0,INT
,1,NULL
,0);
3508 VARXOR(NULL
,0,UINT
,0,NULL
,0);
3509 VARXOR(NULL
,0,UINT
,1,NULL
,0);
3510 VARXOR(NULL
,0,BOOL
,0,NULL
,0);
3511 VARXOR(NULL
,0,BOOL
,1,NULL
,0);
3512 VARXOR(NULL
,0,R4
,0,NULL
,0);
3513 VARXOR(NULL
,0,R4
,1,NULL
,0);
3514 VARXOR(NULL
,0,R8
,0,NULL
,0);
3515 VARXOR(NULL
,0,R8
,1,NULL
,0);
3516 rbstr
= SysAllocString(szFalse
);
3517 VARXOR(NULL
,0,BSTR
,rbstr
,NULL
,0);
3518 SysFreeString(rbstr
);
3519 rbstr
= SysAllocString(szTrue
);
3520 VARXOR(NULL
,0,BSTR
,rbstr
,NULL
,0);
3521 SysFreeString(rbstr
);
3522 VARXORCY(NULL
,0,10000,NULL
,0);
3523 VARXORCY(NULL
,0,0,NULL
,0);
3525 VARXOR(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
);
3526 VARXOR(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
);
3527 VARXOR(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
);
3528 VARXOR(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_FALSE
);
3529 /* Assume x,y & y,x are the same from now on to reduce the number of tests */
3530 VARXOR(BOOL
,VARIANT_TRUE
,I1
,-1,I4
,0);
3531 VARXOR(BOOL
,VARIANT_TRUE
,I1
,0,I4
,-1);
3532 VARXOR(BOOL
,VARIANT_FALSE
,I1
,0,I4
,0);
3533 VARXOR(BOOL
,VARIANT_TRUE
,UI1
,255,I2
,-256);
3534 VARXOR(BOOL
,VARIANT_TRUE
,UI1
,0,I2
,-1);
3535 VARXOR(BOOL
,VARIANT_FALSE
,UI1
,0,I2
,0);
3536 VARXOR(BOOL
,VARIANT_TRUE
,I2
,-1,I2
,0);
3537 VARXOR(BOOL
,VARIANT_TRUE
,I2
,0,I2
,-1);
3538 VARXOR(BOOL
,VARIANT_FALSE
,I2
,0,I2
,0);
3539 VARXOR(BOOL
,VARIANT_TRUE
,UI2
,65535,I4
,-65536);
3540 VARXOR(BOOL
,VARIANT_TRUE
,UI2
,0,I4
,-1);
3541 VARXOR(BOOL
,VARIANT_FALSE
,UI2
,0,I4
,0);
3542 VARXOR(BOOL
,VARIANT_TRUE
,I4
,-1,I4
,0);
3543 VARXOR(BOOL
,VARIANT_TRUE
,I4
,0,I4
,-1);
3544 VARXOR(BOOL
,VARIANT_FALSE
,I4
,0,I4
,0);
3545 VARXOR(BOOL
,VARIANT_TRUE
,UI4
,0xffffffff,I4
,0);
3546 VARXOR(BOOL
,VARIANT_TRUE
,UI4
,0,I4
,-1);
3547 VARXOR(BOOL
,VARIANT_FALSE
,UI4
,0,I4
,0);
3548 VARXOR(BOOL
,VARIANT_TRUE
,R4
,-1,I4
,0);
3549 VARXOR(BOOL
,VARIANT_TRUE
,R4
,0,I4
,-1);
3550 VARXOR(BOOL
,VARIANT_FALSE
,R4
,0,I4
,0);
3551 VARXOR(BOOL
,VARIANT_TRUE
,R8
,-1,I4
,0);
3552 VARXOR(BOOL
,VARIANT_TRUE
,R8
,0,I4
,-1);
3553 VARXOR(BOOL
,VARIANT_FALSE
,R8
,0,I4
,0);
3554 VARXOR(BOOL
,VARIANT_TRUE
,DATE
,-1,I4
,0);
3555 VARXOR(BOOL
,VARIANT_TRUE
,DATE
,0,I4
,-1);
3556 VARXOR(BOOL
,VARIANT_FALSE
,DATE
,0,I4
,0);
3557 if (HAVE_OLEAUT32_I8
)
3559 VARXOR(BOOL
,VARIANT_TRUE
,I8
,-1,I8
,0);
3560 VARXOR(BOOL
,VARIANT_TRUE
,I8
,0,I8
,-1);
3561 VARXOR(BOOL
,VARIANT_FALSE
,I8
,0,I8
,0);
3562 /* This returns DISP_E_OVERFLOW which indicates that a conversion
3563 * to I4 is performed.
3565 /* VARXOR(BOOL,VARIANT_TRUE,UI8,-1,I4,-1); */
3566 VARXOR(BOOL
,VARIANT_TRUE
,UI8
,0,I4
,-1);
3567 VARXOR(BOOL
,VARIANT_FALSE
,UI8
,0,I4
,0);
3569 VARXOR(BOOL
,VARIANT_TRUE
,INT
,-1,I4
,0);
3570 VARXOR(BOOL
,VARIANT_TRUE
,INT
,0,I4
,-1);
3571 VARXOR(BOOL
,VARIANT_FALSE
,INT
,0,I4
,0);
3572 VARXOR(BOOL
,VARIANT_TRUE
,UINT
,0xffffffff,I4
,0);
3573 VARXOR(BOOL
,VARIANT_TRUE
,UINT
,0,I4
,-1);
3574 VARXOR(BOOL
,VARIANT_FALSE
,UINT
,0,I4
,0);
3575 rbstr
= SysAllocString(szFalse
);
3576 VARXOR(BOOL
,VARIANT_FALSE
,BSTR
,rbstr
,BOOL
,VARIANT_FALSE
);
3577 VARXOR(BOOL
,VARIANT_TRUE
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
3578 SysFreeString(rbstr
);
3579 rbstr
= SysAllocString(szTrue
);
3580 VARXOR(BOOL
,VARIANT_FALSE
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
3581 VARXOR(BOOL
,VARIANT_TRUE
,BSTR
,rbstr
,BOOL
,VARIANT_FALSE
);
3582 SysFreeString(rbstr
);
3583 VARXORCY(BOOL
,VARIANT_TRUE
,10000,I4
,-2);
3584 VARXORCY(BOOL
,VARIANT_TRUE
,0,I4
,-1);
3585 VARXORCY(BOOL
,VARIANT_FALSE
,0,I4
,0);
3587 VARXOR(I1
,-1,I1
,-1,I4
,0);
3588 VARXOR(I1
,-1,I1
,0,I4
,-1);
3589 VARXOR(I1
,0,I1
,0,I4
,0);
3590 VARXOR(I1
,-1,UI1
,255,I4
,-256);
3591 VARXOR(I1
,-1,UI1
,0,I4
,-1);
3592 VARXOR(I1
,0,UI1
,0,I4
,0);
3593 VARXOR(I1
,-1,I2
,-1,I4
,0);
3594 VARXOR(I1
,-1,I2
,0,I4
,-1);
3595 VARXOR(I1
,0,I2
,0,I4
,0);
3596 VARXOR(I1
,-1,UI2
,65535,I4
,-65536);
3597 VARXOR(I1
,-1,UI2
,0,I4
,-1);
3598 VARXOR(I1
,0,UI2
,0,I4
,0);
3599 VARXOR(I1
,-1,I4
,-1,I4
,0);
3600 VARXOR(I1
,-1,I4
,0,I4
,-1);
3601 VARXOR(I1
,0,I4
,0,I4
,0);
3602 VARXOR(I1
,-1,UI4
,0xffffffff,I4
,0);
3603 VARXOR(I1
,-1,UI4
,0,I4
,-1);
3604 VARXOR(I1
,0,UI4
,0,I4
,0);
3605 VARXOR(I1
,-1,R4
,-1,I4
,0);
3606 VARXOR(I1
,-1,R4
,0,I4
,-1);
3607 VARXOR(I1
,0,R4
,0,I4
,0);
3608 VARXOR(I1
,-1,R8
,-1,I4
,0);
3609 VARXOR(I1
,-1,R8
,0,I4
,-1);
3610 VARXOR(I1
,0,R8
,0,I4
,0);
3611 VARXOR(I1
,-1,DATE
,-1,I4
,0);
3612 VARXOR(I1
,-1,DATE
,0,I4
,-1);
3613 VARXOR(I1
,0,DATE
,0,I4
,0);
3614 if (HAVE_OLEAUT32_I8
)
3616 VARXOR(I1
,-1,I8
,-1,I8
,0);
3617 VARXOR(I1
,-1,I8
,0,I8
,-1);
3618 VARXOR(I1
,0,I8
,0,I8
,0);
3619 VARXOR(I1
,-1,UI8
,0,I4
,-1);
3620 VARXOR(I1
,0,UI8
,0,I4
,0);
3622 VARXOR(I1
,-1,INT
,-1,I4
,0);
3623 VARXOR(I1
,-1,INT
,0,I4
,-1);
3624 VARXOR(I1
,0,INT
,0,I4
,0);
3625 VARXOR(I1
,-1,UINT
,0xffffffff,I4
,0);
3626 VARXOR(I1
,-1,UINT
,0,I4
,-1);
3627 VARXOR(I1
,0,UINT
,0,I4
,0);
3628 rbstr
= SysAllocString(szFalse
);
3629 VARXOR(I1
,0,BSTR
,rbstr
,I4
,0);
3630 VARXOR(I1
,-1,BSTR
,rbstr
,I4
,-1);
3631 SysFreeString(rbstr
);
3632 rbstr
= SysAllocString(szTrue
);
3633 VARXOR(I1
,0,BSTR
,rbstr
,I4
,-1);
3634 VARXOR(I1
,-1,BSTR
,rbstr
,I4
,0);
3635 SysFreeString(rbstr
);
3636 VARXORCY(I1
,-1,10000,I4
,-2);
3637 VARXORCY(I1
,-1,0,I4
,-1);
3638 VARXORCY(I1
,0,0,I4
,0);
3640 VARXOR(UI1
,255,UI1
,255,UI1
,0);
3641 VARXOR(UI1
,255,UI1
,0,UI1
,255);
3642 VARXOR(UI1
,0,UI1
,0,UI1
,0);
3643 VARXOR(UI1
,255,I2
,-1,I2
,-256);
3644 VARXOR(UI1
,255,I2
,0,I2
,255);
3645 VARXOR(UI1
,0,I2
,0,I2
,0);
3646 VARXOR(UI1
,255,UI2
,65535,I4
,65280);
3647 VARXOR(UI1
,255,UI2
,0,I4
,255);
3648 VARXOR(UI1
,0,UI2
,0,I4
,0);
3649 VARXOR(UI1
,255,I4
,-1,I4
,-256);
3650 VARXOR(UI1
,255,I4
,0,I4
,255);
3651 VARXOR(UI1
,0,I4
,0,I4
,0);
3652 VARXOR(UI1
,255,UI4
,0xffffffff,I4
,-256);
3653 VARXOR(UI1
,255,UI4
,0,I4
,255);
3654 VARXOR(UI1
,0,UI4
,0,I4
,0);
3655 VARXOR(UI1
,255,R4
,-1,I4
,-256);
3656 VARXOR(UI1
,255,R4
,0,I4
,255);
3657 VARXOR(UI1
,0,R4
,0,I4
,0);
3658 VARXOR(UI1
,255,R8
,-1,I4
,-256);
3659 VARXOR(UI1
,255,R8
,0,I4
,255);
3660 VARXOR(UI1
,0,R8
,0,I4
,0);
3661 VARXOR(UI1
,255,DATE
,-1,I4
,-256);
3662 VARXOR(UI1
,255,DATE
,0,I4
,255);
3663 VARXOR(UI1
,0,DATE
,0,I4
,0);
3664 if (HAVE_OLEAUT32_I8
)
3666 VARXOR(UI1
,255,I8
,-1,I8
,-256);
3667 VARXOR(UI1
,255,I8
,0,I8
,255);
3668 VARXOR(UI1
,0,I8
,0,I8
,0);
3669 VARXOR(UI1
,255,UI8
,0,I4
,255);
3670 VARXOR(UI1
,0,UI8
,0,I4
,0);
3672 VARXOR(UI1
,255,INT
,-1,I4
,-256);
3673 VARXOR(UI1
,255,INT
,0,I4
,255);
3674 VARXOR(UI1
,0,INT
,0,I4
,0);
3675 VARXOR(UI1
,255,UINT
,0xffffffff,I4
,-256);
3676 VARXOR(UI1
,255,UINT
,0,I4
,255);
3677 VARXOR(UI1
,0,UINT
,0,I4
,0);
3678 rbstr
= SysAllocString(szFalse
);
3679 VARXOR(UI1
,0,BSTR
,rbstr
,I2
,0);
3680 VARXOR(UI1
,255,BSTR
,rbstr
,I2
,255);
3681 SysFreeString(rbstr
);
3682 rbstr
= SysAllocString(szTrue
);
3683 VARXOR(UI1
,0,BSTR
,rbstr
,I2
,-1);
3684 VARXOR(UI1
,255,BSTR
,rbstr
,I2
,-256);
3685 SysFreeString(rbstr
);
3686 VARXORCY(UI1
,255,10000,I4
,254);
3687 VARXORCY(UI1
,255,0,I4
,255);
3688 VARXORCY(UI1
,0,0,I4
,0);
3690 VARXOR(I2
,-1,I2
,-1,I2
,0);
3691 VARXOR(I2
,-1,I2
,0,I2
,-1);
3692 VARXOR(I2
,0,I2
,0,I2
,0);
3693 VARXOR(I2
,-1,UI2
,65535,I4
,-65536);
3694 VARXOR(I2
,-1,UI2
,0,I4
,-1);
3695 VARXOR(I2
,0,UI2
,0,I4
,0);
3696 VARXOR(I2
,-1,I4
,-1,I4
,0);
3697 VARXOR(I2
,-1,I4
,0,I4
,-1);
3698 VARXOR(I2
,0,I4
,0,I4
,0);
3699 VARXOR(I2
,-1,UI4
,0xffffffff,I4
,0);
3700 VARXOR(I2
,-1,UI4
,0,I4
,-1);
3701 VARXOR(I2
,0,UI4
,0,I4
,0);
3702 VARXOR(I2
,-1,R4
,-1,I4
,0);
3703 VARXOR(I2
,-1,R4
,0,I4
,-1);
3704 VARXOR(I2
,0,R4
,0,I4
,0);
3705 VARXOR(I2
,-1,R8
,-1,I4
,0);
3706 VARXOR(I2
,-1,R8
,0,I4
,-1);
3707 VARXOR(I2
,0,R8
,0,I4
,0);
3708 VARXOR(I2
,-1,DATE
,-1,I4
,0);
3709 VARXOR(I2
,-1,DATE
,0,I4
,-1);
3710 VARXOR(I2
,0,DATE
,0,I4
,0);
3711 if (HAVE_OLEAUT32_I8
)
3713 VARXOR(I2
,-1,I8
,-1,I8
,0);
3714 VARXOR(I2
,-1,I8
,0,I8
,-1);
3715 VARXOR(I2
,0,I8
,0,I8
,0);
3716 VARXOR(I2
,-1,UI8
,0,I4
,-1);
3717 VARXOR(I2
,0,UI8
,0,I4
,0);
3719 VARXOR(I2
,-1,INT
,-1,I4
,0);
3720 VARXOR(I2
,-1,INT
,0,I4
,-1);
3721 VARXOR(I2
,0,INT
,0,I4
,0);
3722 VARXOR(I2
,-1,UINT
,0xffffffff,I4
,0);
3723 VARXOR(I2
,-1,UINT
,0,I4
,-1);
3724 VARXOR(I2
,0,UINT
,0,I4
,0);
3725 rbstr
= SysAllocString(szFalse
);
3726 VARXOR(I2
,0,BSTR
,rbstr
,I2
,0);
3727 VARXOR(I2
,-1,BSTR
,rbstr
,I2
,-1);
3728 SysFreeString(rbstr
);
3729 rbstr
= SysAllocString(szTrue
);
3730 VARXOR(I2
,0,BSTR
,rbstr
,I2
,-1);
3731 VARXOR(I2
,-1,BSTR
,rbstr
,I2
,0);
3732 SysFreeString(rbstr
);
3733 VARXORCY(I2
,-1,10000,I4
,-2);
3734 VARXORCY(I2
,-1,0,I4
,-1);
3735 VARXORCY(I2
,0,0,I4
,0);
3737 VARXOR(UI2
,65535,UI2
,65535,I4
,0);
3738 VARXOR(UI2
,65535,UI2
,0,I4
,65535);
3739 VARXOR(UI2
,0,UI2
,0,I4
,0);
3740 VARXOR(UI2
,65535,I4
,-1,I4
,-65536);
3741 VARXOR(UI2
,65535,I4
,0,I4
,65535);
3742 VARXOR(UI2
,0,I4
,0,I4
,0);
3743 VARXOR(UI2
,65535,UI4
,0xffffffff,I4
,-65536);
3744 VARXOR(UI2
,65535,UI4
,0,I4
,65535);
3745 VARXOR(UI2
,0,UI4
,0,I4
,0);
3746 VARXOR(UI2
,65535,R4
,-1,I4
,-65536);
3747 VARXOR(UI2
,65535,R4
,0,I4
,65535);
3748 VARXOR(UI2
,0,R4
,0,I4
,0);
3749 VARXOR(UI2
,65535,R8
,-1,I4
,-65536);
3750 VARXOR(UI2
,65535,R8
,0,I4
,65535);
3751 VARXOR(UI2
,0,R8
,0,I4
,0);
3752 VARXOR(UI2
,65535,DATE
,-1,I4
,-65536);
3753 VARXOR(UI2
,65535,DATE
,0,I4
,65535);
3754 VARXOR(UI2
,0,DATE
,0,I4
,0);
3755 if (HAVE_OLEAUT32_I8
)
3757 VARXOR(UI2
,65535,I8
,-1,I8
,-65536);
3758 VARXOR(UI2
,65535,I8
,0,I8
,65535);
3759 VARXOR(UI2
,0,I8
,0,I8
,0);
3760 VARXOR(UI2
,65535,UI8
,0,I4
,65535);
3761 VARXOR(UI2
,0,UI8
,0,I4
,0);
3763 VARXOR(UI2
,65535,INT
,-1,I4
,-65536);
3764 VARXOR(UI2
,65535,INT
,0,I4
,65535);
3765 VARXOR(UI2
,0,INT
,0,I4
,0);
3766 VARXOR(UI2
,65535,UINT
,0xffffffff,I4
,-65536);
3767 VARXOR(UI2
,65535,UINT
,0,I4
,65535);
3768 VARXOR(UI2
,0,UINT
,0,I4
,0);
3769 rbstr
= SysAllocString(szFalse
);
3770 VARXOR(UI2
,0,BSTR
,rbstr
,I4
,0);
3771 VARXOR(UI2
,65535,BSTR
,rbstr
,I4
,65535);
3772 SysFreeString(rbstr
);
3773 rbstr
= SysAllocString(szTrue
);
3774 VARXOR(UI2
,0,BSTR
,rbstr
,I4
,-1);
3775 VARXOR(UI2
,65535,BSTR
,rbstr
,I4
,-65536);
3776 SysFreeString(rbstr
);
3777 VARXORCY(UI2
,65535,10000,I4
,65534);
3778 VARXORCY(UI2
,65535,0,I4
,65535);
3779 VARXORCY(UI2
,0,0,I4
,0);
3781 VARXOR(I4
,-1,I4
,-1,I4
,0);
3782 VARXOR(I4
,-1,I4
,0,I4
,-1);
3783 VARXOR(I4
,0,I4
,0,I4
,0);
3784 VARXOR(I4
,-1,UI4
,0xffffffff,I4
,0);
3785 VARXOR(I4
,-1,UI4
,0,I4
,-1);
3786 VARXOR(I4
,0,UI4
,0,I4
,0);
3787 VARXOR(I4
,-1,R4
,-1,I4
,0);
3788 VARXOR(I4
,-1,R4
,0,I4
,-1);
3789 VARXOR(I4
,0,R4
,0,I4
,0);
3790 VARXOR(I4
,-1,R8
,-1,I4
,0);
3791 VARXOR(I4
,-1,R8
,0,I4
,-1);
3792 VARXOR(I4
,0,R8
,0,I4
,0);
3793 VARXOR(I4
,-1,DATE
,-1,I4
,0);
3794 VARXOR(I4
,-1,DATE
,0,I4
,-1);
3795 VARXOR(I4
,0,DATE
,0,I4
,0);
3796 if (HAVE_OLEAUT32_I8
)
3798 VARXOR(I4
,-1,I8
,-1,I8
,0);
3799 VARXOR(I4
,-1,I8
,0,I8
,-1);
3800 VARXOR(I4
,0,I8
,0,I8
,0);
3801 VARXOR(I4
,-1,UI8
,0,I4
,-1);
3802 VARXOR(I4
,0,UI8
,0,I4
,0);
3804 VARXOR(I4
,-1,INT
,-1,I4
,0);
3805 VARXOR(I4
,-1,INT
,0,I4
,-1);
3806 VARXOR(I4
,0,INT
,0,I4
,0);
3807 VARXOR(I4
,-1,UINT
,0xffffffff,I4
,0);
3808 VARXOR(I4
,-1,UINT
,0,I4
,-1);
3809 VARXOR(I4
,0,UINT
,0,I4
,0);
3810 rbstr
= SysAllocString(szFalse
);
3811 VARXOR(I4
,0,BSTR
,rbstr
,I4
,0);
3812 VARXOR(I4
,-1,BSTR
,rbstr
,I4
,-1);
3813 SysFreeString(rbstr
);
3814 rbstr
= SysAllocString(szTrue
);
3815 VARXOR(I4
,0,BSTR
,rbstr
,I4
,-1);
3816 VARXOR(I4
,-1,BSTR
,rbstr
,I4
,0);
3817 SysFreeString(rbstr
);
3818 VARXORCY(I4
,-1,10000,I4
,-2);
3819 VARXORCY(I4
,-1,0,I4
,-1);
3820 VARXORCY(I4
,0,0,I4
,0);
3822 VARXOR(UI4
,0xffffffff,UI4
,0xffffffff,I4
,0);
3823 VARXOR(UI4
,0xffffffff,UI4
,0,I4
,-1);
3824 VARXOR(UI4
,0,UI4
,0,I4
,0);
3825 VARXOR(UI4
,0xffffffff,R4
,-1,I4
,0);
3826 VARXOR(UI4
,0xffffffff,R4
,0,I4
,-1);
3827 VARXOR(UI4
,0,R4
,0,I4
,0);
3828 VARXOR(UI4
,0xffffffff,R8
,-1,I4
,0);
3829 VARXOR(UI4
,0xffffffff,R8
,0,I4
,-1);
3830 VARXOR(UI4
,0,R8
,0,I4
,0);
3831 VARXOR(UI4
,0xffffffff,DATE
,-1,I4
,0);
3832 VARXOR(UI4
,0xffffffff,DATE
,0,I4
,-1);
3833 VARXOR(UI4
,0,DATE
,0,I4
,0);
3834 if (HAVE_OLEAUT32_I8
)
3836 VARXOR(UI4
,0xffffffff,I8
,0,I8
,0xffffffff);
3837 VARXOR(UI4
,VARIANT_FALSE
,I8
,VARIANT_FALSE
,I8
,0);
3838 VARXOR(UI4
,0,I8
,0,I8
,0);
3839 VARXOR(UI4
,0xffffffff,UI8
,0,I4
,-1);
3840 VARXOR(UI4
,0,UI8
,0,I4
,0);
3842 VARXOR(UI4
,0xffffffff,INT
,-1,I4
,0);
3843 VARXOR(UI4
,0xffffffff,INT
,0,I4
,-1);
3844 VARXOR(UI4
,0,INT
,0,I4
,0);
3845 VARXOR(UI4
,0xffffffff,UINT
,0xffffffff,I4
,0);
3846 VARXOR(UI4
,0xffffffff,UINT
,0,I4
,-1);
3847 VARXOR(UI4
,0,UINT
,0,I4
,0);
3848 rbstr
= SysAllocString(szFalse
);
3849 VARXOR(UI4
,0,BSTR
,rbstr
,I4
,0);
3850 VARXOR(UI4
,0xffffffff,BSTR
,rbstr
,I4
,-1);
3851 SysFreeString(rbstr
);
3852 rbstr
= SysAllocString(szTrue
);
3853 VARXOR(UI4
,0,BSTR
,rbstr
,I4
,-1);
3854 VARXOR(UI4
,0xffffffff,BSTR
,rbstr
,I4
,0);
3855 SysFreeString(rbstr
);
3856 VARXORCY(UI4
,0xffffffff,10000,I4
,-2);
3857 VARXORCY(UI4
,0xffffffff,0,I4
,-1);
3858 VARXORCY(UI4
,0,0,I4
,0);
3860 VARXOR(R4
,-1,R4
,-1,I4
,0);
3861 VARXOR(R4
,-1,R4
,0,I4
,-1);
3862 VARXOR(R4
,0,R4
,0,I4
,0);
3863 VARXOR(R4
,-1,R8
,-1,I4
,0);
3864 VARXOR(R4
,-1,R8
,0,I4
,-1);
3865 VARXOR(R4
,0,R8
,0,I4
,0);
3866 VARXOR(R4
,-1,DATE
,-1,I4
,0);
3867 VARXOR(R4
,-1,DATE
,0,I4
,-1);
3868 VARXOR(R4
,0,DATE
,0,I4
,0);
3869 if (HAVE_OLEAUT32_I8
)
3871 VARXOR(R4
,-1,I8
,-1,I8
,0);
3872 VARXOR(R4
,-1,I8
,0,I8
,-1);
3873 VARXOR(R4
,0,I8
,0,I8
,0);
3874 VARXOR(R4
,-1,UI8
,0,I4
,-1);
3875 VARXOR(R4
,0,UI8
,0,I4
,0);
3877 VARXOR(R4
,-1,INT
,-1,I4
,0);
3878 VARXOR(R4
,-1,INT
,0,I4
,-1);
3879 VARXOR(R4
,0,INT
,0,I4
,0);
3880 VARXOR(R4
,-1,UINT
,0xffffffff,I4
,0);
3881 VARXOR(R4
,-1,UINT
,0,I4
,-1);
3882 VARXOR(R4
,0,UINT
,0,I4
,0);
3883 rbstr
= SysAllocString(szFalse
);
3884 VARXOR(R4
,0,BSTR
,rbstr
,I4
,0);
3885 VARXOR(R4
,-1,BSTR
,rbstr
,I4
,-1);
3886 SysFreeString(rbstr
);
3887 rbstr
= SysAllocString(szTrue
);
3888 VARXOR(R4
,0,BSTR
,rbstr
,I4
,-1);
3889 VARXOR(R4
,-1,BSTR
,rbstr
,I4
,0);
3890 SysFreeString(rbstr
);
3891 VARXORCY(R4
,-1,10000,I4
,-2);
3892 VARXORCY(R4
,-1,0,I4
,-1);
3893 VARXORCY(R4
,0,0,I4
,0);
3895 VARXOR(R8
,-1,R8
,-1,I4
,0);
3896 VARXOR(R8
,-1,R8
,0,I4
,-1);
3897 VARXOR(R8
,0,R8
,0,I4
,0);
3898 VARXOR(R8
,-1,DATE
,-1,I4
,0);
3899 VARXOR(R8
,-1,DATE
,0,I4
,-1);
3900 VARXOR(R8
,0,DATE
,0,I4
,0);
3901 if (HAVE_OLEAUT32_I8
)
3903 VARXOR(R8
,-1,I8
,-1,I8
,0);
3904 VARXOR(R8
,-1,I8
,0,I8
,-1);
3905 VARXOR(R8
,0,I8
,0,I8
,0);
3906 VARXOR(R8
,-1,UI8
,0,I4
,-1);
3907 VARXOR(R8
,0,UI8
,0,I4
,0);
3909 VARXOR(R8
,-1,INT
,-1,I4
,0);
3910 VARXOR(R8
,-1,INT
,0,I4
,-1);
3911 VARXOR(R8
,0,INT
,0,I4
,0);
3912 VARXOR(R8
,-1,UINT
,0xffffffff,I4
,0);
3913 VARXOR(R8
,-1,UINT
,0,I4
,-1);
3914 VARXOR(R8
,0,UINT
,0,I4
,0);
3915 rbstr
= SysAllocString(szFalse
);
3916 VARXOR(R8
,0,BSTR
,rbstr
,I4
,0);
3917 VARXOR(R8
,-1,BSTR
,rbstr
,I4
,-1);
3918 SysFreeString(rbstr
);
3919 rbstr
= SysAllocString(szTrue
);
3920 VARXOR(R8
,0,BSTR
,rbstr
,I4
,-1);
3921 VARXOR(R8
,-1,BSTR
,rbstr
,I4
,0);
3922 SysFreeString(rbstr
);
3923 VARXORCY(R8
,-1,10000,I4
,-2);
3924 VARXORCY(R8
,-1,0,I4
,-1);
3925 VARXORCY(R8
,0,0,I4
,0);
3927 VARXOR(DATE
,-1,DATE
,-1,I4
,0);
3928 VARXOR(DATE
,-1,DATE
,0,I4
,-1);
3929 VARXOR(DATE
,0,DATE
,0,I4
,0);
3930 if (HAVE_OLEAUT32_I8
)
3932 VARXOR(DATE
,-1,I8
,-1,I8
,0);
3933 VARXOR(DATE
,-1,I8
,0,I8
,-1);
3934 VARXOR(DATE
,0,I8
,0,I8
,0);
3935 VARXOR(DATE
,-1,UI8
,0,I4
,-1);
3936 VARXOR(DATE
,0,UI8
,0,I4
,0);
3938 VARXOR(DATE
,-1,INT
,-1,I4
,0);
3939 VARXOR(DATE
,-1,INT
,0,I4
,-1);
3940 VARXOR(DATE
,0,INT
,0,I4
,0);
3941 VARXOR(DATE
,-1,UINT
,0xffffffff,I4
,0);
3942 VARXOR(DATE
,-1,UINT
,0,I4
,-1);
3943 VARXOR(DATE
,0,UINT
,0,I4
,0);
3944 rbstr
= SysAllocString(szFalse
);
3945 VARXOR(DATE
,0,BSTR
,rbstr
,I4
,0);
3946 VARXOR(DATE
,-1,BSTR
,rbstr
,I4
,-1);
3947 SysFreeString(rbstr
);
3948 rbstr
= SysAllocString(szTrue
);
3949 VARXOR(DATE
,0,BSTR
,rbstr
,I4
,-1);
3950 VARXOR(DATE
,-1,BSTR
,rbstr
,I4
,0);
3951 SysFreeString(rbstr
);
3952 VARXORCY(DATE
,-1,10000,I4
,-2);
3953 VARXORCY(DATE
,-1,0,I4
,-1);
3954 VARXORCY(DATE
,0,0,I4
,0);
3956 if (HAVE_OLEAUT32_I8
)
3958 VARXOR(I8
,-1,I8
,-1,I8
,0);
3959 VARXOR(I8
,-1,I8
,0,I8
,-1);
3960 VARXOR(I8
,0,I8
,0,I8
,0);
3961 VARXOR(I8
,-1,UI8
,0,I8
,-1);
3962 VARXOR(I8
,0,UI8
,0,I8
,0);
3963 VARXOR(I8
,-1,UINT
,0,I8
,-1);
3964 VARXOR(I8
,0,UINT
,0,I8
,0);
3965 rbstr
= SysAllocString(szFalse
);
3966 VARXOR(I8
,0,BSTR
,rbstr
,I8
,0);
3967 VARXOR(I8
,-1,BSTR
,rbstr
,I8
,-1);
3968 SysFreeString(rbstr
);
3969 rbstr
= SysAllocString(szTrue
);
3970 VARXOR(I8
,0,BSTR
,rbstr
,I8
,-1);
3971 VARXOR(I8
,-1,BSTR
,rbstr
,I8
,0);
3972 SysFreeString(rbstr
);
3973 VARXORCY(I8
,-1,10000,I8
,-2);
3974 VARXORCY(I8
,-1,0,I8
,-1);
3975 VARXORCY(I8
,0,0,I8
,0);
3977 VARXOR(UI8
,0xffff,UI8
,0xffff,I4
,0);
3978 VARXOR(UI8
,0xffff,UI8
,0,I4
,0xffff);
3979 VARXOR(UI8
,0,UI8
,0,I4
,0);
3980 VARXOR(UI8
,0xffff,INT
,-1,I4
,-65536);
3981 VARXOR(UI8
,0xffff,INT
,0,I4
,0xffff);
3982 VARXOR(UI8
,0,INT
,0,I4
,0);
3983 VARXOR(UI8
,0xffff,UINT
,0xffff,I4
,0);
3984 VARXOR(UI8
,0xffff,UINT
,0,I4
,0xffff);
3985 VARXOR(UI8
,0,UINT
,0,I4
,0);
3986 rbstr
= SysAllocString(szFalse
);
3987 VARXOR(UI8
,0,BSTR
,rbstr
,I4
,0);
3988 VARXOR(UI8
,0xffff,BSTR
,rbstr
,I4
,0xffff);
3989 SysFreeString(rbstr
);
3990 rbstr
= SysAllocString(szTrue
);
3991 VARXOR(UI8
,0,BSTR
,rbstr
,I4
,-1);
3992 VARXOR(UI8
,0xffff,BSTR
,rbstr
,I4
,-65536);
3993 SysFreeString(rbstr
);
3994 VARXORCY(UI8
,0xffff,10000,I4
,65534);
3995 VARXORCY(UI8
,0xffff,0,I4
,0xffff);
3996 VARXORCY(UI8
,0,0,I4
,0);
3999 VARXOR(INT
,-1,INT
,-1,I4
,0);
4000 VARXOR(INT
,-1,INT
,0,I4
,-1);
4001 VARXOR(INT
,0,INT
,0,I4
,0);
4002 VARXOR(INT
,-1,UINT
,0xffff,I4
,-65536);
4003 VARXOR(INT
,-1,UINT
,0,I4
,-1);
4004 VARXOR(INT
,0,UINT
,0,I4
,0);
4005 rbstr
= SysAllocString(szFalse
);
4006 VARXOR(INT
,0,BSTR
,rbstr
,I4
,0);
4007 VARXOR(INT
,-1,BSTR
,rbstr
,I4
,-1);
4008 SysFreeString(rbstr
);
4009 rbstr
= SysAllocString(szTrue
);
4010 VARXOR(INT
,0,BSTR
,rbstr
,I4
,-1);
4011 VARXOR(INT
,-1,BSTR
,rbstr
,I4
,0);
4012 SysFreeString(rbstr
);
4013 VARXORCY(INT
,-1,10000,I4
,-2);
4014 VARXORCY(INT
,-1,0,I4
,-1);
4015 VARXORCY(INT
,0,0,I4
,0);
4017 VARXOR(UINT
,0xffff,UINT
,0xffff,I4
,0);
4018 VARXOR(UINT
,0xffff,UINT
,0,I4
,0xffff);
4019 VARXOR(UINT
,0,UINT
,0,I4
,0);
4020 rbstr
= SysAllocString(szFalse
);
4021 VARXOR(UINT
,0,BSTR
,rbstr
,I4
,0);
4022 VARXOR(UINT
,0xffff,BSTR
,rbstr
,I4
,0xffff);
4023 SysFreeString(rbstr
);
4024 rbstr
= SysAllocString(szTrue
);
4025 VARXOR(UINT
,0,BSTR
,rbstr
,I4
,-1);
4026 VARXOR(UINT
,0xffff,BSTR
,rbstr
,I4
,-65536);
4027 SysFreeString(rbstr
);
4028 VARXORCY(UINT
,0xffff,10000,I4
,65534);
4029 VARXORCY(UINT
,0xffff,0,I4
,0xffff);
4030 VARXORCY(UINT
,0,0,I4
,0);
4032 lbstr
= SysAllocString(szFalse
);
4033 rbstr
= SysAllocString(szFalse
);
4034 VARXOR(BSTR
,lbstr
,BSTR
,rbstr
,BOOL
,0);
4035 SysFreeString(rbstr
);
4036 rbstr
= SysAllocString(szTrue
);
4037 VARXOR(BSTR
,lbstr
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
4038 SysFreeString(lbstr
);
4039 lbstr
= SysAllocString(szTrue
);
4040 VARXOR(BSTR
,lbstr
,BSTR
,rbstr
,BOOL
,VARIANT_FALSE
);
4041 VARXORCY(BSTR
,lbstr
,10000,I4
,-2);
4042 SysFreeString(lbstr
);
4043 lbstr
= SysAllocString(szFalse
);
4044 VARXORCY(BSTR
,lbstr
,10000,I4
,1);
4045 SysFreeString(lbstr
);
4046 SysFreeString(rbstr
);
4049 static HRESULT (WINAPI
*pVarOr
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
4051 #define VAROR(vt1,val1,vt2,val2,rvt,rval) \
4052 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
4053 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
4054 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
4055 test_var_call2( __LINE__, pVarOr, &left, &right, &exp )
4057 #define VARORCY(vt1,val1,val2,rvt,rval) \
4058 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
4059 V_VT(&right) = VT_CY; V_CY(&right).int64 = val2; \
4060 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
4061 test_var_call2( __LINE__, pVarOr, &left, &right, &exp )
4063 static void test_VarOr(void)
4065 static const WCHAR szFalse
[] = { '#','F','A','L','S','E','#','\0' };
4066 static const WCHAR szTrue
[] = { '#','T','R','U','E','#','\0' };
4067 VARIANT left
, right
, exp
, result
;
4074 /* Test all possible flag/vt combinations & the resulting vt type */
4075 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
4077 VARTYPE leftvt
, rightvt
, resvt
;
4079 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
4084 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
4090 if (leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
||
4091 leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
||
4092 leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
)
4095 memset(&left
, 0, sizeof(left
));
4096 memset(&right
, 0, sizeof(right
));
4097 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
4098 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
4099 V_VT(&result
) = VT_EMPTY
;
4102 if (ExtraFlags
[i
] & VT_ARRAY
|| ExtraFlags
[i
] & VT_BYREF
||
4103 !IsValidVariantClearVT(leftvt
, ExtraFlags
[i
]) ||
4104 !IsValidVariantClearVT(rightvt
, ExtraFlags
[i
]) ||
4105 leftvt
== VT_CLSID
|| rightvt
== VT_CLSID
||
4106 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
||
4107 leftvt
== VT_VARIANT
|| rightvt
== VT_VARIANT
||
4108 leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
)
4112 if (leftvt
== VT_EMPTY
|| rightvt
== VT_EMPTY
)
4114 if (leftvt
== rightvt
||
4115 leftvt
== VT_I2
|| rightvt
== VT_I2
||
4116 leftvt
== VT_UI1
|| rightvt
== VT_UI1
||
4117 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
4119 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
4121 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
4124 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
4128 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
4130 if (leftvt
== rightvt
)
4132 else if (leftvt
== rightvt
||
4133 leftvt
== VT_I2
|| rightvt
== VT_I2
||
4134 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
4138 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
4141 else if (leftvt
== VT_I2
|| rightvt
== VT_I2
)
4143 if (leftvt
== rightvt
||
4144 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
4146 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
4149 else if (leftvt
== VT_BOOL
&& rightvt
== VT_BOOL
)
4153 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
4155 if (leftvt
== VT_INT
|| rightvt
== VT_INT
)
4160 hres
= pVarOr(&left
, &right
, &result
);
4162 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
4163 "VarOr: %d|0x%X, %d|0x%X: Expected failure, got 0x%X vt %d\n",
4164 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], hres
,
4167 ok(hres
== S_OK
&& V_VT(&result
) == resvt
,
4168 "VarOr: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%X vt %d\n",
4169 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], resvt
, hres
,
4175 /* Test returned values. Since we know the returned type is correct
4176 * and that we handle all combinations of invalid types, just check
4177 * that good type combinations produce the desired value.
4178 * FIXME: Test VT_DECIMAL/VT_DISPATCH
4180 VAROR(EMPTY
,0,EMPTY
,0,I2
,0);
4181 VAROR(EMPTY
,1,EMPTY
,0,I2
,0);
4182 VAROR(EMPTY
,0,NULL
,0,NULL
,0);
4183 VAROR(EMPTY
,0,I1
,0,I4
,0);
4184 VAROR(EMPTY
,0,I1
,1,I4
,1);
4185 VAROR(EMPTY
,0,UI1
,0,I2
,0);
4186 VAROR(EMPTY
,0,UI1
,1,I2
,1);
4187 VAROR(EMPTY
,0,I2
,0,I2
,0);
4188 VAROR(EMPTY
,0,I2
,1,I2
,1);
4189 VAROR(EMPTY
,0,UI2
,0,I4
,0);
4190 VAROR(EMPTY
,0,UI2
,1,I4
,1);
4191 VAROR(EMPTY
,0,I4
,0,I4
,0);
4192 VAROR(EMPTY
,0,I4
,1,I4
,1);
4193 VAROR(EMPTY
,0,UI4
,0,I4
,0);
4194 VAROR(EMPTY
,0,UI4
,1,I4
,1);
4195 if (HAVE_OLEAUT32_I8
)
4197 VAROR(EMPTY
,0,I8
,0,I8
,0);
4198 VAROR(EMPTY
,0,I8
,1,I8
,1);
4199 VAROR(EMPTY
,0,UI8
,0,I4
,0);
4200 VAROR(EMPTY
,0,UI8
,1,I4
,1);
4202 VAROR(EMPTY
,0,INT
,0,I4
,0);
4203 VAROR(EMPTY
,0,INT
,1,I4
,1);
4204 VAROR(EMPTY
,0,UINT
,0,I4
,0);
4205 VAROR(EMPTY
,0,UINT
,1,I4
,1);
4206 VAROR(EMPTY
,0,BOOL
,0,I2
,0);
4207 VAROR(EMPTY
,0,BOOL
,1,I2
,1);
4208 VAROR(EMPTY
,0,R4
,0,I4
,0);
4209 VAROR(EMPTY
,0,R4
,1,I4
,1);
4210 VAROR(EMPTY
,0,R8
,0,I4
,0);
4211 VAROR(EMPTY
,0,R8
,1,I4
,1);
4212 rbstr
= SysAllocString(szFalse
);
4213 VAROR(EMPTY
,0,BSTR
,rbstr
,I2
,0);
4214 SysFreeString(rbstr
);
4215 rbstr
= SysAllocString(szTrue
);
4216 VAROR(EMPTY
,0,BSTR
,rbstr
,I2
,-1);
4217 SysFreeString(rbstr
);
4218 VARORCY(EMPTY
,0,10000,I4
,1);
4220 /* NULL OR 0 = NULL. NULL OR n = n */
4221 VAROR(NULL
,0,NULL
,0,NULL
,0);
4222 VAROR(NULL
,1,NULL
,0,NULL
,0);
4223 VAROR(NULL
,0,I1
,0,NULL
,0);
4224 VAROR(NULL
,0,I1
,1,I4
,1);
4225 VAROR(NULL
,0,UI1
,0,NULL
,0);
4226 VAROR(NULL
,0,UI1
,1,UI1
,1);
4227 VAROR(NULL
,0,I2
,0,NULL
,0);
4228 VAROR(NULL
,0,I2
,1,I2
,1);
4229 VAROR(NULL
,0,UI2
,0,NULL
,0);
4230 VAROR(NULL
,0,UI2
,1,I4
,1);
4231 VAROR(NULL
,0,I4
,0,NULL
,0);
4232 VAROR(NULL
,0,I4
,1,I4
,1);
4233 VAROR(NULL
,0,UI4
,0,NULL
,0);
4234 VAROR(NULL
,0,UI4
,1,I4
,1);
4235 if (HAVE_OLEAUT32_I8
)
4237 VAROR(NULL
,0,I8
,0,NULL
,0);
4238 VAROR(NULL
,0,I8
,1,I8
,1);
4239 VAROR(NULL
,0,UI8
,0,NULL
,0);
4240 VAROR(NULL
,0,UI8
,1,I4
,1);
4242 VAROR(NULL
,0,INT
,0,NULL
,0);
4243 VAROR(NULL
,0,INT
,1,I4
,1);
4244 VAROR(NULL
,0,UINT
,0,NULL
,0);
4245 VAROR(NULL
,0,UINT
,1,I4
,1);
4246 VAROR(NULL
,0,BOOL
,0,NULL
,0);
4247 VAROR(NULL
,0,BOOL
,1,BOOL
,1);
4248 VAROR(NULL
,0,R4
,0,NULL
,0);
4249 VAROR(NULL
,0,R4
,1,I4
,1);
4250 VAROR(NULL
,0,R8
,0,NULL
,0);
4251 VAROR(NULL
,0,R8
,1,I4
,1);
4252 rbstr
= SysAllocString(szFalse
);
4253 VAROR(NULL
,0,BSTR
,rbstr
,NULL
,0);
4254 SysFreeString(rbstr
);
4255 rbstr
= SysAllocString(szTrue
);
4256 VAROR(NULL
,0,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
4257 SysFreeString(rbstr
);
4258 VARORCY(NULL
,0,10000,I4
,1);
4259 VARORCY(NULL
,0,0,NULL
,0);
4261 VAROR(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
);
4262 VAROR(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
);
4263 VAROR(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
);
4264 VAROR(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_FALSE
);
4265 /* Assume x,y & y,x are the same from now on to reduce the number of tests */
4266 VAROR(BOOL
,VARIANT_TRUE
,I1
,-1,I4
,-1);
4267 VAROR(BOOL
,VARIANT_TRUE
,I1
,0,I4
,-1);
4268 VAROR(BOOL
,VARIANT_FALSE
,I1
,0,I4
,0);
4269 VAROR(BOOL
,VARIANT_TRUE
,UI1
,255,I2
,-1);
4270 VAROR(BOOL
,VARIANT_TRUE
,UI1
,0,I2
,-1);
4271 VAROR(BOOL
,VARIANT_FALSE
,UI1
,0,I2
,0);
4272 VAROR(BOOL
,VARIANT_TRUE
,I2
,-1,I2
,-1);
4273 VAROR(BOOL
,VARIANT_TRUE
,I2
,0,I2
,-1);
4274 VAROR(BOOL
,VARIANT_FALSE
,I2
,0,I2
,0);
4275 VAROR(BOOL
,VARIANT_TRUE
,UI2
,65535,I4
,-1);
4276 VAROR(BOOL
,VARIANT_TRUE
,UI2
,0,I4
,-1);
4277 VAROR(BOOL
,VARIANT_FALSE
,UI2
,0,I4
,0);
4278 VAROR(BOOL
,VARIANT_TRUE
,I4
,-1,I4
,-1);
4279 VAROR(BOOL
,VARIANT_TRUE
,I4
,0,I4
,-1);
4280 VAROR(BOOL
,VARIANT_FALSE
,I4
,0,I4
,0);
4281 VAROR(BOOL
,VARIANT_TRUE
,UI4
,0xffffffff,I4
,-1);
4282 VAROR(BOOL
,VARIANT_TRUE
,UI4
,0,I4
,-1);
4283 VAROR(BOOL
,VARIANT_FALSE
,UI4
,0,I4
,0);
4284 VAROR(BOOL
,VARIANT_TRUE
,R4
,-1,I4
,-1);
4285 VAROR(BOOL
,VARIANT_TRUE
,R4
,0,I4
,-1);
4286 VAROR(BOOL
,VARIANT_FALSE
,R4
,0,I4
,0);
4287 VAROR(BOOL
,VARIANT_TRUE
,R8
,-1,I4
,-1);
4288 VAROR(BOOL
,VARIANT_TRUE
,R8
,0,I4
,-1);
4289 VAROR(BOOL
,VARIANT_FALSE
,R8
,0,I4
,0);
4290 VAROR(BOOL
,VARIANT_TRUE
,DATE
,-1,I4
,-1);
4291 VAROR(BOOL
,VARIANT_TRUE
,DATE
,0,I4
,-1);
4292 VAROR(BOOL
,VARIANT_FALSE
,DATE
,0,I4
,0);
4293 if (HAVE_OLEAUT32_I8
)
4295 VAROR(BOOL
,VARIANT_TRUE
,I8
,-1,I8
,-1);
4296 VAROR(BOOL
,VARIANT_TRUE
,I8
,0,I8
,-1);
4297 VAROR(BOOL
,VARIANT_FALSE
,I8
,0,I8
,0);
4298 /* This returns DISP_E_OVERFLOW which indicates that a conversion
4299 * to I4 is performed.
4301 /* VAROR(BOOL,VARIANT_TRUE,UI8,-1,I4,-1); */
4302 VAROR(BOOL
,VARIANT_TRUE
,UI8
,0,I4
,-1);
4303 VAROR(BOOL
,VARIANT_FALSE
,UI8
,0,I4
,0);
4305 VAROR(BOOL
,VARIANT_TRUE
,INT
,-1,I4
,-1);
4306 VAROR(BOOL
,VARIANT_TRUE
,INT
,0,I4
,-1);
4307 VAROR(BOOL
,VARIANT_FALSE
,INT
,0,I4
,0);
4308 VAROR(BOOL
,VARIANT_TRUE
,UINT
,0xffffffff,I4
,-1);
4309 VAROR(BOOL
,VARIANT_TRUE
,UINT
,0,I4
,-1);
4310 VAROR(BOOL
,VARIANT_FALSE
,UINT
,0,I4
,0);
4311 rbstr
= SysAllocString(szFalse
);
4312 VAROR(BOOL
,VARIANT_FALSE
,BSTR
,rbstr
,BOOL
,VARIANT_FALSE
);
4313 VAROR(BOOL
,VARIANT_TRUE
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
4314 SysFreeString(rbstr
);
4315 rbstr
= SysAllocString(szTrue
);
4316 VAROR(BOOL
,VARIANT_FALSE
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
4317 VAROR(BOOL
,VARIANT_TRUE
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
4318 SysFreeString(rbstr
);
4319 VARORCY(BOOL
,VARIANT_TRUE
,10000,I4
,-1);
4320 VARORCY(BOOL
,VARIANT_TRUE
,0,I4
,-1);
4321 VARORCY(BOOL
,VARIANT_FALSE
,0,I4
,0);
4323 VAROR(I1
,-1,I1
,-1,I4
,-1);
4324 VAROR(I1
,-1,I1
,0,I4
,-1);
4325 VAROR(I1
,0,I1
,0,I4
,0);
4326 VAROR(I1
,-1,UI1
,255,I4
,-1);
4327 VAROR(I1
,-1,UI1
,0,I4
,-1);
4328 VAROR(I1
,0,UI1
,0,I4
,0);
4329 VAROR(I1
,-1,I2
,-1,I4
,-1);
4330 VAROR(I1
,-1,I2
,0,I4
,-1);
4331 VAROR(I1
,0,I2
,0,I4
,0);
4332 VAROR(I1
,-1,UI2
,65535,I4
,-1);
4333 VAROR(I1
,-1,UI2
,0,I4
,-1);
4334 VAROR(I1
,0,UI2
,0,I4
,0);
4335 VAROR(I1
,-1,I4
,-1,I4
,-1);
4336 VAROR(I1
,-1,I4
,0,I4
,-1);
4337 VAROR(I1
,0,I4
,0,I4
,0);
4338 VAROR(I1
,-1,UI4
,0xffffffff,I4
,-1);
4339 VAROR(I1
,-1,UI4
,0,I4
,-1);
4340 VAROR(I1
,0,UI4
,0,I4
,0);
4341 VAROR(I1
,-1,R4
,-1,I4
,-1);
4342 VAROR(I1
,-1,R4
,0,I4
,-1);
4343 VAROR(I1
,0,R4
,0,I4
,0);
4344 VAROR(I1
,-1,R8
,-1,I4
,-1);
4345 VAROR(I1
,-1,R8
,0,I4
,-1);
4346 VAROR(I1
,0,R8
,0,I4
,0);
4347 VAROR(I1
,-1,DATE
,-1,I4
,-1);
4348 VAROR(I1
,-1,DATE
,0,I4
,-1);
4349 VAROR(I1
,0,DATE
,0,I4
,0);
4350 if (HAVE_OLEAUT32_I8
)
4352 VAROR(I1
,-1,I8
,-1,I8
,-1);
4353 VAROR(I1
,-1,I8
,0,I8
,-1);
4354 VAROR(I1
,0,I8
,0,I8
,0);
4355 VAROR(I1
,-1,UI8
,0,I4
,-1);
4356 VAROR(I1
,0,UI8
,0,I4
,0);
4358 VAROR(I1
,-1,INT
,-1,I4
,-1);
4359 VAROR(I1
,-1,INT
,0,I4
,-1);
4360 VAROR(I1
,0,INT
,0,I4
,0);
4361 VAROR(I1
,-1,UINT
,0xffffffff,I4
,-1);
4362 VAROR(I1
,-1,UINT
,0,I4
,-1);
4363 VAROR(I1
,0,UINT
,0,I4
,0);
4364 rbstr
= SysAllocString(szFalse
);
4365 VAROR(I1
,0,BSTR
,rbstr
,I4
,0);
4366 VAROR(I1
,-1,BSTR
,rbstr
,I4
,-1);
4367 SysFreeString(rbstr
);
4368 rbstr
= SysAllocString(szTrue
);
4369 VAROR(I1
,0,BSTR
,rbstr
,I4
,-1);
4370 VAROR(I1
,-1,BSTR
,rbstr
,I4
,-1);
4371 SysFreeString(rbstr
);
4372 VARORCY(I1
,-1,10000,I4
,-1);
4373 VARORCY(I1
,-1,0,I4
,-1);
4374 VARORCY(I1
,0,0,I4
,0);
4376 VAROR(UI1
,255,UI1
,255,UI1
,255);
4377 VAROR(UI1
,255,UI1
,0,UI1
,255);
4378 VAROR(UI1
,0,UI1
,0,UI1
,0);
4379 VAROR(UI1
,255,I2
,-1,I2
,-1);
4380 VAROR(UI1
,255,I2
,0,I2
,255);
4381 VAROR(UI1
,0,I2
,0,I2
,0);
4382 VAROR(UI1
,255,UI2
,65535,I4
,65535);
4383 VAROR(UI1
,255,UI2
,0,I4
,255);
4384 VAROR(UI1
,0,UI2
,0,I4
,0);
4385 VAROR(UI1
,255,I4
,-1,I4
,-1);
4386 VAROR(UI1
,255,I4
,0,I4
,255);
4387 VAROR(UI1
,0,I4
,0,I4
,0);
4388 VAROR(UI1
,255,UI4
,0xffffffff,I4
,-1);
4389 VAROR(UI1
,255,UI4
,0,I4
,255);
4390 VAROR(UI1
,0,UI4
,0,I4
,0);
4391 VAROR(UI1
,255,R4
,-1,I4
,-1);
4392 VAROR(UI1
,255,R4
,0,I4
,255);
4393 VAROR(UI1
,0,R4
,0,I4
,0);
4394 VAROR(UI1
,255,R8
,-1,I4
,-1);
4395 VAROR(UI1
,255,R8
,0,I4
,255);
4396 VAROR(UI1
,0,R8
,0,I4
,0);
4397 VAROR(UI1
,255,DATE
,-1,I4
,-1);
4398 VAROR(UI1
,255,DATE
,0,I4
,255);
4399 VAROR(UI1
,0,DATE
,0,I4
,0);
4400 if (HAVE_OLEAUT32_I8
)
4402 VAROR(UI1
,255,I8
,-1,I8
,-1);
4403 VAROR(UI1
,255,I8
,0,I8
,255);
4404 VAROR(UI1
,0,I8
,0,I8
,0);
4405 VAROR(UI1
,255,UI8
,0,I4
,255);
4406 VAROR(UI1
,0,UI8
,0,I4
,0);
4408 VAROR(UI1
,255,INT
,-1,I4
,-1);
4409 VAROR(UI1
,255,INT
,0,I4
,255);
4410 VAROR(UI1
,0,INT
,0,I4
,0);
4411 VAROR(UI1
,255,UINT
,0xffffffff,I4
,-1);
4412 VAROR(UI1
,255,UINT
,0,I4
,255);
4413 VAROR(UI1
,0,UINT
,0,I4
,0);
4414 rbstr
= SysAllocString(szFalse
);
4415 VAROR(UI1
,0,BSTR
,rbstr
,I2
,0);
4416 VAROR(UI1
,255,BSTR
,rbstr
,I2
,255);
4417 SysFreeString(rbstr
);
4418 rbstr
= SysAllocString(szTrue
);
4419 VAROR(UI1
,0,BSTR
,rbstr
,I2
,-1);
4420 VAROR(UI1
,255,BSTR
,rbstr
,I2
,-1);
4421 SysFreeString(rbstr
);
4422 VARORCY(UI1
,255,10000,I4
,255);
4423 VARORCY(UI1
,255,0,I4
,255);
4424 VARORCY(UI1
,0,0,I4
,0);
4426 VAROR(I2
,-1,I2
,-1,I2
,-1);
4427 VAROR(I2
,-1,I2
,0,I2
,-1);
4428 VAROR(I2
,0,I2
,0,I2
,0);
4429 VAROR(I2
,-1,UI2
,65535,I4
,-1);
4430 VAROR(I2
,-1,UI2
,0,I4
,-1);
4431 VAROR(I2
,0,UI2
,0,I4
,0);
4432 VAROR(I2
,-1,I4
,-1,I4
,-1);
4433 VAROR(I2
,-1,I4
,0,I4
,-1);
4434 VAROR(I2
,0,I4
,0,I4
,0);
4435 VAROR(I2
,-1,UI4
,0xffffffff,I4
,-1);
4436 VAROR(I2
,-1,UI4
,0,I4
,-1);
4437 VAROR(I2
,0,UI4
,0,I4
,0);
4438 VAROR(I2
,-1,R4
,-1,I4
,-1);
4439 VAROR(I2
,-1,R4
,0,I4
,-1);
4440 VAROR(I2
,0,R4
,0,I4
,0);
4441 VAROR(I2
,-1,R8
,-1,I4
,-1);
4442 VAROR(I2
,-1,R8
,0,I4
,-1);
4443 VAROR(I2
,0,R8
,0,I4
,0);
4444 VAROR(I2
,-1,DATE
,-1,I4
,-1);
4445 VAROR(I2
,-1,DATE
,0,I4
,-1);
4446 VAROR(I2
,0,DATE
,0,I4
,0);
4447 if (HAVE_OLEAUT32_I8
)
4449 VAROR(I2
,-1,I8
,-1,I8
,-1);
4450 VAROR(I2
,-1,I8
,0,I8
,-1);
4451 VAROR(I2
,0,I8
,0,I8
,0);
4452 VAROR(I2
,-1,UI8
,0,I4
,-1);
4453 VAROR(I2
,0,UI8
,0,I4
,0);
4455 VAROR(I2
,-1,INT
,-1,I4
,-1);
4456 VAROR(I2
,-1,INT
,0,I4
,-1);
4457 VAROR(I2
,0,INT
,0,I4
,0);
4458 VAROR(I2
,-1,UINT
,0xffffffff,I4
,-1);
4459 VAROR(I2
,-1,UINT
,0,I4
,-1);
4460 VAROR(I2
,0,UINT
,0,I4
,0);
4461 rbstr
= SysAllocString(szFalse
);
4462 VAROR(I2
,0,BSTR
,rbstr
,I2
,0);
4463 VAROR(I2
,-1,BSTR
,rbstr
,I2
,-1);
4464 SysFreeString(rbstr
);
4465 rbstr
= SysAllocString(szTrue
);
4466 VAROR(I2
,0,BSTR
,rbstr
,I2
,-1);
4467 VAROR(I2
,-1,BSTR
,rbstr
,I2
,-1);
4468 SysFreeString(rbstr
);
4469 VARORCY(I2
,-1,10000,I4
,-1);
4470 VARORCY(I2
,-1,0,I4
,-1);
4471 VARORCY(I2
,0,0,I4
,0);
4473 VAROR(UI2
,65535,UI2
,65535,I4
,65535);
4474 VAROR(UI2
,65535,UI2
,0,I4
,65535);
4475 VAROR(UI2
,0,UI2
,0,I4
,0);
4476 VAROR(UI2
,65535,I4
,-1,I4
,-1);
4477 VAROR(UI2
,65535,I4
,0,I4
,65535);
4478 VAROR(UI2
,0,I4
,0,I4
,0);
4479 VAROR(UI2
,65535,UI4
,0xffffffff,I4
,-1);
4480 VAROR(UI2
,65535,UI4
,0,I4
,65535);
4481 VAROR(UI2
,0,UI4
,0,I4
,0);
4482 VAROR(UI2
,65535,R4
,-1,I4
,-1);
4483 VAROR(UI2
,65535,R4
,0,I4
,65535);
4484 VAROR(UI2
,0,R4
,0,I4
,0);
4485 VAROR(UI2
,65535,R8
,-1,I4
,-1);
4486 VAROR(UI2
,65535,R8
,0,I4
,65535);
4487 VAROR(UI2
,0,R8
,0,I4
,0);
4488 VAROR(UI2
,65535,DATE
,-1,I4
,-1);
4489 VAROR(UI2
,65535,DATE
,0,I4
,65535);
4490 VAROR(UI2
,0,DATE
,0,I4
,0);
4491 if (HAVE_OLEAUT32_I8
)
4493 VAROR(UI2
,65535,I8
,-1,I8
,-1);
4494 VAROR(UI2
,65535,I8
,0,I8
,65535);
4495 VAROR(UI2
,0,I8
,0,I8
,0);
4496 VAROR(UI2
,65535,UI8
,0,I4
,65535);
4497 VAROR(UI2
,0,UI8
,0,I4
,0);
4499 VAROR(UI2
,65535,INT
,-1,I4
,-1);
4500 VAROR(UI2
,65535,INT
,0,I4
,65535);
4501 VAROR(UI2
,0,INT
,0,I4
,0);
4502 VAROR(UI2
,65535,UINT
,0xffffffff,I4
,-1);
4503 VAROR(UI2
,65535,UINT
,0,I4
,65535);
4504 VAROR(UI2
,0,UINT
,0,I4
,0);
4505 rbstr
= SysAllocString(szFalse
);
4506 VAROR(UI2
,0,BSTR
,rbstr
,I4
,0);
4507 VAROR(UI2
,65535,BSTR
,rbstr
,I4
,65535);
4508 SysFreeString(rbstr
);
4509 rbstr
= SysAllocString(szTrue
);
4510 VAROR(UI2
,0,BSTR
,rbstr
,I4
,-1);
4511 VAROR(UI2
,65535,BSTR
,rbstr
,I4
,-1);
4512 SysFreeString(rbstr
);
4513 VARORCY(UI2
,65535,10000,I4
,65535);
4514 VARORCY(UI2
,65535,0,I4
,65535);
4515 VARORCY(UI2
,0,0,I4
,0);
4517 VAROR(I4
,-1,I4
,-1,I4
,-1);
4518 VAROR(I4
,-1,I4
,0,I4
,-1);
4519 VAROR(I4
,0,I4
,0,I4
,0);
4520 VAROR(I4
,-1,UI4
,0xffffffff,I4
,-1);
4521 VAROR(I4
,-1,UI4
,0,I4
,-1);
4522 VAROR(I4
,0,UI4
,0,I4
,0);
4523 VAROR(I4
,-1,R4
,-1,I4
,-1);
4524 VAROR(I4
,-1,R4
,0,I4
,-1);
4525 VAROR(I4
,0,R4
,0,I4
,0);
4526 VAROR(I4
,-1,R8
,-1,I4
,-1);
4527 VAROR(I4
,-1,R8
,0,I4
,-1);
4528 VAROR(I4
,0,R8
,0,I4
,0);
4529 VAROR(I4
,-1,DATE
,-1,I4
,-1);
4530 VAROR(I4
,-1,DATE
,0,I4
,-1);
4531 VAROR(I4
,0,DATE
,0,I4
,0);
4532 if (HAVE_OLEAUT32_I8
)
4534 VAROR(I4
,-1,I8
,-1,I8
,-1);
4535 VAROR(I4
,-1,I8
,0,I8
,-1);
4536 VAROR(I4
,0,I8
,0,I8
,0);
4537 VAROR(I4
,-1,UI8
,0,I4
,-1);
4538 VAROR(I4
,0,UI8
,0,I4
,0);
4540 VAROR(I4
,-1,INT
,-1,I4
,-1);
4541 VAROR(I4
,-1,INT
,0,I4
,-1);
4542 VAROR(I4
,0,INT
,0,I4
,0);
4543 VAROR(I4
,-1,UINT
,0xffffffff,I4
,-1);
4544 VAROR(I4
,-1,UINT
,0,I4
,-1);
4545 VAROR(I4
,0,UINT
,0,I4
,0);
4546 rbstr
= SysAllocString(szFalse
);
4547 VAROR(I4
,0,BSTR
,rbstr
,I4
,0);
4548 VAROR(I4
,-1,BSTR
,rbstr
,I4
,-1);
4549 SysFreeString(rbstr
);
4550 rbstr
= SysAllocString(szTrue
);
4551 VAROR(I4
,0,BSTR
,rbstr
,I4
,-1);
4552 VAROR(I4
,-1,BSTR
,rbstr
,I4
,-1);
4553 SysFreeString(rbstr
);
4554 VARORCY(I4
,-1,10000,I4
,-1);
4555 VARORCY(I4
,-1,0,I4
,-1);
4556 VARORCY(I4
,0,0,I4
,0);
4558 VAROR(UI4
,0xffffffff,UI4
,0xffffffff,I4
,-1);
4559 VAROR(UI4
,0xffffffff,UI4
,0,I4
,-1);
4560 VAROR(UI4
,0,UI4
,0,I4
,0);
4561 VAROR(UI4
,0xffffffff,R4
,-1,I4
,-1);
4562 VAROR(UI4
,0xffffffff,R4
,0,I4
,-1);
4563 VAROR(UI4
,0,R4
,0,I4
,0);
4564 VAROR(UI4
,0xffffffff,R8
,-1,I4
,-1);
4565 VAROR(UI4
,0xffffffff,R8
,0,I4
,-1);
4566 VAROR(UI4
,0,R8
,0,I4
,0);
4567 VAROR(UI4
,0xffffffff,DATE
,-1,I4
,-1);
4568 VAROR(UI4
,0xffffffff,DATE
,0,I4
,-1);
4569 VAROR(UI4
,0,DATE
,0,I4
,0);
4570 if (HAVE_OLEAUT32_I8
)
4572 VAROR(UI4
,0xffffffff,I8
,-1,I8
,-1);
4573 VAROR(UI4
,0xffffffff,I8
,0,I8
,0xffffffff);
4574 VAROR(UI4
,0,I8
,0,I8
,0);
4575 VAROR(UI4
,0xffffffff,UI8
,0,I4
,-1);
4576 VAROR(UI4
,0,UI8
,0,I4
,0);
4578 VAROR(UI4
,0xffffffff,INT
,-1,I4
,-1);
4579 VAROR(UI4
,0xffffffff,INT
,0,I4
,-1);
4580 VAROR(UI4
,0,INT
,0,I4
,0);
4581 VAROR(UI4
,0xffffffff,UINT
,0xffffffff,I4
,-1);
4582 VAROR(UI4
,0xffffffff,UINT
,0,I4
,-1);
4583 VAROR(UI4
,0,UINT
,0,I4
,0);
4584 rbstr
= SysAllocString(szFalse
);
4585 VAROR(UI4
,0,BSTR
,rbstr
,I4
,0);
4586 VAROR(UI4
,0xffffffff,BSTR
,rbstr
,I4
,-1);
4587 SysFreeString(rbstr
);
4588 rbstr
= SysAllocString(szTrue
);
4589 VAROR(UI4
,0,BSTR
,rbstr
,I4
,-1);
4590 VAROR(UI4
,0xffffffff,BSTR
,rbstr
,I4
,-1);
4591 SysFreeString(rbstr
);
4592 VARORCY(UI4
,0xffffffff,10000,I4
,-1);
4593 VARORCY(UI4
,0xffffffff,0,I4
,-1);
4594 VARORCY(UI4
,0,0,I4
,0);
4596 VAROR(R4
,-1,R4
,-1,I4
,-1);
4597 VAROR(R4
,-1,R4
,0,I4
,-1);
4598 VAROR(R4
,0,R4
,0,I4
,0);
4599 VAROR(R4
,-1,R8
,-1,I4
,-1);
4600 VAROR(R4
,-1,R8
,0,I4
,-1);
4601 VAROR(R4
,0,R8
,0,I4
,0);
4602 VAROR(R4
,-1,DATE
,-1,I4
,-1);
4603 VAROR(R4
,-1,DATE
,0,I4
,-1);
4604 VAROR(R4
,0,DATE
,0,I4
,0);
4605 if (HAVE_OLEAUT32_I8
)
4607 VAROR(R4
,-1,I8
,-1,I8
,-1);
4608 VAROR(R4
,-1,I8
,0,I8
,-1);
4609 VAROR(R4
,0,I8
,0,I8
,0);
4610 VAROR(R4
,-1,UI8
,0,I4
,-1);
4611 VAROR(R4
,0,UI8
,0,I4
,0);
4613 VAROR(R4
,-1,INT
,-1,I4
,-1);
4614 VAROR(R4
,-1,INT
,0,I4
,-1);
4615 VAROR(R4
,0,INT
,0,I4
,0);
4616 VAROR(R4
,-1,UINT
,0xffffffff,I4
,-1);
4617 VAROR(R4
,-1,UINT
,0,I4
,-1);
4618 VAROR(R4
,0,UINT
,0,I4
,0);
4619 rbstr
= SysAllocString(szFalse
);
4620 VAROR(R4
,0,BSTR
,rbstr
,I4
,0);
4621 VAROR(R4
,-1,BSTR
,rbstr
,I4
,-1);
4622 SysFreeString(rbstr
);
4623 rbstr
= SysAllocString(szTrue
);
4624 VAROR(R4
,0,BSTR
,rbstr
,I4
,-1);
4625 VAROR(R4
,-1,BSTR
,rbstr
,I4
,-1);
4626 SysFreeString(rbstr
);
4627 VARORCY(R4
,-1,10000,I4
,-1);
4628 VARORCY(R4
,-1,0,I4
,-1);
4629 VARORCY(R4
,0,0,I4
,0);
4631 VAROR(R8
,-1,R8
,-1,I4
,-1);
4632 VAROR(R8
,-1,R8
,0,I4
,-1);
4633 VAROR(R8
,0,R8
,0,I4
,0);
4634 VAROR(R8
,-1,DATE
,-1,I4
,-1);
4635 VAROR(R8
,-1,DATE
,0,I4
,-1);
4636 VAROR(R8
,0,DATE
,0,I4
,0);
4637 if (HAVE_OLEAUT32_I8
)
4639 VAROR(R8
,-1,I8
,-1,I8
,-1);
4640 VAROR(R8
,-1,I8
,0,I8
,-1);
4641 VAROR(R8
,0,I8
,0,I8
,0);
4642 VAROR(R8
,-1,UI8
,0,I4
,-1);
4643 VAROR(R8
,0,UI8
,0,I4
,0);
4645 VAROR(R8
,-1,INT
,-1,I4
,-1);
4646 VAROR(R8
,-1,INT
,0,I4
,-1);
4647 VAROR(R8
,0,INT
,0,I4
,0);
4648 VAROR(R8
,-1,UINT
,0xffffffff,I4
,-1);
4649 VAROR(R8
,-1,UINT
,0,I4
,-1);
4650 VAROR(R8
,0,UINT
,0,I4
,0);
4651 rbstr
= SysAllocString(szFalse
);
4652 VAROR(R8
,0,BSTR
,rbstr
,I4
,0);
4653 VAROR(R8
,-1,BSTR
,rbstr
,I4
,-1);
4654 SysFreeString(rbstr
);
4655 rbstr
= SysAllocString(szTrue
);
4656 VAROR(R8
,0,BSTR
,rbstr
,I4
,-1);
4657 VAROR(R8
,-1,BSTR
,rbstr
,I4
,-1);
4658 SysFreeString(rbstr
);
4659 VARORCY(R8
,-1,10000,I4
,-1);
4660 VARORCY(R8
,-1,0,I4
,-1);
4661 VARORCY(R8
,0,0,I4
,0);
4663 VAROR(DATE
,-1,DATE
,-1,I4
,-1);
4664 VAROR(DATE
,-1,DATE
,0,I4
,-1);
4665 VAROR(DATE
,0,DATE
,0,I4
,0);
4666 if (HAVE_OLEAUT32_I8
)
4668 VAROR(DATE
,-1,I8
,-1,I8
,-1);
4669 VAROR(DATE
,-1,I8
,0,I8
,-1);
4670 VAROR(DATE
,0,I8
,0,I8
,0);
4671 VAROR(DATE
,-1,UI8
,0,I4
,-1);
4672 VAROR(DATE
,0,UI8
,0,I4
,0);
4674 VAROR(DATE
,-1,INT
,-1,I4
,-1);
4675 VAROR(DATE
,-1,INT
,0,I4
,-1);
4676 VAROR(DATE
,0,INT
,0,I4
,0);
4677 VAROR(DATE
,-1,UINT
,0xffffffff,I4
,-1);
4678 VAROR(DATE
,-1,UINT
,0,I4
,-1);
4679 VAROR(DATE
,0,UINT
,0,I4
,0);
4680 rbstr
= SysAllocString(szFalse
);
4681 VAROR(DATE
,0,BSTR
,rbstr
,I4
,0);
4682 VAROR(DATE
,-1,BSTR
,rbstr
,I4
,-1);
4683 SysFreeString(rbstr
);
4684 rbstr
= SysAllocString(szTrue
);
4685 VAROR(DATE
,0,BSTR
,rbstr
,I4
,-1);
4686 VAROR(DATE
,-1,BSTR
,rbstr
,I4
,-1);
4687 SysFreeString(rbstr
);
4688 VARORCY(DATE
,-1,10000,I4
,-1);
4689 VARORCY(DATE
,-1,0,I4
,-1);
4690 VARORCY(DATE
,0,0,I4
,0);
4692 if (HAVE_OLEAUT32_I8
)
4694 VAROR(I8
,-1,I8
,-1,I8
,-1);
4695 VAROR(I8
,-1,I8
,0,I8
,-1);
4696 VAROR(I8
,0,I8
,0,I8
,0);
4697 VAROR(I8
,-1,UI8
,0,I8
,-1);
4698 VAROR(I8
,0,UI8
,0,I8
,0);
4699 /* These overflow under native and Wine
4700 VAROR(I8,-1,INT,-1,I4,-1);
4701 VAROR(I8,-1,INT,0,I4,-1);
4702 VAROR(I8,0,INT,0,I4,0); */
4703 VAROR(I8
,-1,UINT
,0xffffffff,I8
,-1);
4704 VAROR(I8
,-1,UINT
,0,I8
,-1);
4705 VAROR(I8
,0,UINT
,0,I8
,0);
4706 rbstr
= SysAllocString(szFalse
);
4707 VAROR(I8
,0,BSTR
,rbstr
,I8
,0);
4708 VAROR(I8
,-1,BSTR
,rbstr
,I8
,-1);
4709 SysFreeString(rbstr
);
4710 rbstr
= SysAllocString(szTrue
);
4711 VAROR(I8
,0,BSTR
,rbstr
,I8
,-1);
4712 VAROR(I8
,-1,BSTR
,rbstr
,I8
,-1);
4713 SysFreeString(rbstr
);
4714 VARORCY(I8
,-1,10000,I8
,-1);
4715 VARORCY(I8
,-1,0,I8
,-1);
4716 VARORCY(I8
,0,0,I8
,0);
4718 VAROR(UI8
,0xffff,UI8
,0xffff,I4
,0xffff);
4719 VAROR(UI8
,0xffff,UI8
,0,I4
,0xffff);
4720 VAROR(UI8
,0,UI8
,0,I4
,0);
4721 VAROR(UI8
,0xffff,INT
,-1,I4
,-1);
4722 VAROR(UI8
,0xffff,INT
,0,I4
,0xffff);
4723 VAROR(UI8
,0,INT
,0,I4
,0);
4724 VAROR(UI8
,0xffff,UINT
,0xffff,I4
,0xffff);
4725 VAROR(UI8
,0xffff,UINT
,0,I4
,0xffff);
4726 VAROR(UI8
,0,UINT
,0,I4
,0);
4727 rbstr
= SysAllocString(szFalse
);
4728 VAROR(UI8
,0,BSTR
,rbstr
,I4
,0);
4729 VAROR(UI8
,0xffff,BSTR
,rbstr
,I4
,0xffff);
4730 SysFreeString(rbstr
);
4731 rbstr
= SysAllocString(szTrue
);
4732 VAROR(UI8
,0,BSTR
,rbstr
,I4
,-1);
4733 VAROR(UI8
,0xffff,BSTR
,rbstr
,I4
,-1);
4734 SysFreeString(rbstr
);
4735 VARORCY(UI8
,0xffff,10000,I4
,0xffff);
4736 VARORCY(UI8
,0xffff,0,I4
,0xffff);
4737 VARORCY(UI8
,0,0,I4
,0);
4740 VAROR(INT
,-1,INT
,-1,I4
,-1);
4741 VAROR(INT
,-1,INT
,0,I4
,-1);
4742 VAROR(INT
,0,INT
,0,I4
,0);
4743 VAROR(INT
,-1,UINT
,0xffff,I4
,-1);
4744 VAROR(INT
,-1,UINT
,0,I4
,-1);
4745 VAROR(INT
,0,UINT
,0,I4
,0);
4746 rbstr
= SysAllocString(szFalse
);
4747 VAROR(INT
,0,BSTR
,rbstr
,I4
,0);
4748 VAROR(INT
,-1,BSTR
,rbstr
,I4
,-1);
4749 SysFreeString(rbstr
);
4750 rbstr
= SysAllocString(szTrue
);
4751 VAROR(INT
,0,BSTR
,rbstr
,I4
,-1);
4752 VAROR(INT
,-1,BSTR
,rbstr
,I4
,-1);
4753 SysFreeString(rbstr
);
4754 VARORCY(INT
,-1,10000,I4
,-1);
4755 VARORCY(INT
,-1,0,I4
,-1);
4756 VARORCY(INT
,0,0,I4
,0);
4758 VAROR(UINT
,0xffff,UINT
,0xffff,I4
,0xffff);
4759 VAROR(UINT
,0xffff,UINT
,0,I4
,0xffff);
4760 VAROR(UINT
,0,UINT
,0,I4
,0);
4761 rbstr
= SysAllocString(szFalse
);
4762 VAROR(UINT
,0,BSTR
,rbstr
,I4
,0);
4763 VAROR(UINT
,0xffff,BSTR
,rbstr
,I4
,0xffff);
4764 SysFreeString(rbstr
);
4765 rbstr
= SysAllocString(szTrue
);
4766 VAROR(UINT
,0,BSTR
,rbstr
,I4
,-1);
4767 VAROR(UINT
,0xffff,BSTR
,rbstr
,I4
,-1);
4768 SysFreeString(rbstr
);
4769 VARORCY(UINT
,0xffff,10000,I4
,0xffff);
4770 VARORCY(UINT
,0xffff,0,I4
,0xffff);
4771 VARORCY(UINT
,0,0,I4
,0);
4773 lbstr
= SysAllocString(szFalse
);
4774 rbstr
= SysAllocString(szFalse
);
4775 VAROR(BSTR
,lbstr
,BSTR
,rbstr
,BOOL
,0);
4776 SysFreeString(rbstr
);
4777 rbstr
= SysAllocString(szTrue
);
4778 VAROR(BSTR
,lbstr
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
4779 SysFreeString(lbstr
);
4780 lbstr
= SysAllocString(szTrue
);
4781 VAROR(BSTR
,lbstr
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
4782 VARORCY(BSTR
,lbstr
,10000,I4
,-1);
4783 SysFreeString(lbstr
);
4784 lbstr
= SysAllocString(szFalse
);
4785 VARORCY(BSTR
,lbstr
,10000,I4
,1);
4786 SysFreeString(lbstr
);
4787 SysFreeString(rbstr
);
4790 static HRESULT (WINAPI
*pVarEqv
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
4792 #define VAREQV(vt1,val1,vt2,val2,rvt,rval) \
4793 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
4794 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
4795 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
4796 test_var_call2( __LINE__, pVarEqv, &left, &right, &exp )
4798 static void test_VarEqv(void)
4800 VARIANT left
, right
, exp
, result
;
4806 /* Test all possible flag/vt combinations & the resulting vt type */
4807 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
4809 VARTYPE leftvt
, rightvt
, resvt
;
4811 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
4815 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
4821 if (leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
||
4822 leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
||
4823 leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
)
4826 memset(&left
, 0, sizeof(left
));
4827 memset(&right
, 0, sizeof(right
));
4828 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
4829 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
4830 V_VT(&result
) = VT_EMPTY
;
4833 if (ExtraFlags
[i
] & VT_ARRAY
|| ExtraFlags
[i
] & VT_BYREF
||
4834 !IsValidVariantClearVT(leftvt
, ExtraFlags
[i
]) ||
4835 !IsValidVariantClearVT(rightvt
, ExtraFlags
[i
]) ||
4836 leftvt
== VT_CLSID
|| rightvt
== VT_CLSID
||
4837 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
||
4838 leftvt
== VT_VARIANT
|| rightvt
== VT_VARIANT
||
4839 leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
)
4843 if (leftvt
== VT_EMPTY
|| rightvt
== VT_EMPTY
)
4845 if (leftvt
== rightvt
||
4846 leftvt
== VT_I2
|| rightvt
== VT_I2
||
4847 leftvt
== VT_UI1
|| rightvt
== VT_UI1
||
4848 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
4850 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
4852 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
4855 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
4859 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
4861 if (leftvt
== rightvt
)
4863 else if (leftvt
== rightvt
||
4864 leftvt
== VT_I2
|| rightvt
== VT_I2
||
4865 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
4869 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
4872 else if (leftvt
== VT_I2
|| rightvt
== VT_I2
)
4874 if (leftvt
== rightvt
||
4875 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
4877 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
4880 else if (leftvt
== VT_BOOL
&& rightvt
== VT_BOOL
)
4884 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
4886 if (leftvt
== VT_INT
|| rightvt
== VT_INT
)
4891 hres
= pVarEqv(&left
, &right
, &result
);
4893 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
4894 "VarEqv: %d|0x%X, %d|0x%X: Expected failure, got 0x%X vt %d\n",
4895 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], hres
,
4898 ok(hres
== S_OK
&& V_VT(&result
) == resvt
,
4899 "VarEqv: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%X vt %d\n",
4900 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], resvt
, hres
,
4906 /* Test returned values */
4907 VAREQV(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
);
4908 VAREQV(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
);
4909 VAREQV(BOOL
,TRUE
,BOOL
,TRUE
,BOOL
,VARIANT_TRUE
);
4910 VAREQV(BOOL
,FALSE
,BOOL
,FALSE
,BOOL
,VARIANT_TRUE
);
4911 VAREQV(BOOL
,TRUE
,BOOL
,FALSE
,BOOL
,-2);
4912 VAREQV(BOOL
,FALSE
,BOOL
,TRUE
,BOOL
,-2);
4913 VAREQV(BOOL
,6,BOOL
,7,BOOL
,-2);
4914 VAREQV(BOOL
,6,BOOL
,6,BOOL
,VARIANT_TRUE
);
4915 VAREQV(BOOL
,VARIANT_TRUE
,I2
,VARIANT_TRUE
,I2
,VARIANT_TRUE
);
4916 VAREQV(BOOL
,VARIANT_TRUE
,I2
,VARIANT_FALSE
,I2
,VARIANT_FALSE
);
4917 VAREQV(BOOL
,6,I2
,7,I2
,-2);
4918 VAREQV(UI1
,1,UI1
,1,UI1
,255);
4919 VAREQV(UI1
,1,UI1
,0,UI1
,254);
4920 VAREQV(UI1
,0,UI1
,1,UI1
,254);
4921 if (HAVE_OLEAUT32_I8
)
4923 VAREQV(UI4
,VARIANT_FALSE
,I8
,VARIANT_FALSE
,I8
,-1);
4924 VAREQV(UI4
,5,I8
,19,I8
,-23);
4925 VAREQV(UI4
,VARIANT_FALSE
,UI8
,VARIANT_FALSE
,I4
,-1);
4929 static HRESULT (WINAPI
*pVarMul
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
4931 #define VARMUL(vt1,val1,vt2,val2,rvt,rval) \
4932 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
4933 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
4934 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
4935 test_var_call2( __LINE__, pVarMul, &left, &right, &exp )
4937 static void test_VarMul(void)
4939 VARIANT left
, right
, exp
, result
, cy
, dec
;
4947 lbstr
= SysAllocString(sz12
);
4948 rbstr
= SysAllocString(sz12
);
4950 /* Test all possible flag/vt combinations & the resulting vt type */
4951 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
4953 VARTYPE leftvt
, rightvt
, resvt
;
4955 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
4960 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
4966 if (leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
||
4967 leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
)
4970 memset(&left
, 0, sizeof(left
));
4971 memset(&right
, 0, sizeof(right
));
4972 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
4973 if (leftvt
== VT_BSTR
)
4974 V_BSTR(&left
) = lbstr
;
4975 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
4976 if (rightvt
== VT_BSTR
)
4977 V_BSTR(&right
) = rbstr
;
4978 V_VT(&result
) = VT_EMPTY
;
4981 /* Don't ask me why but native VarMul cannot handle:
4982 VT_I1, VT_UI2, VT_UI4, VT_INT, VT_UINT and VT_UI8.
4983 Tested with DCOM98, Win2k, WinXP */
4984 if (ExtraFlags
[i
] & VT_ARRAY
|| ExtraFlags
[i
] & VT_BYREF
||
4985 !IsValidVariantClearVT(leftvt
, ExtraFlags
[i
]) ||
4986 !IsValidVariantClearVT(rightvt
, ExtraFlags
[i
]) ||
4987 leftvt
== VT_CLSID
|| rightvt
== VT_CLSID
||
4988 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
||
4989 leftvt
== VT_VARIANT
|| rightvt
== VT_VARIANT
||
4990 leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
||
4991 leftvt
== VT_I1
|| rightvt
== VT_I1
||
4992 leftvt
== VT_UI2
|| rightvt
== VT_UI2
||
4993 leftvt
== VT_UI4
|| rightvt
== VT_UI4
||
4994 leftvt
== VT_UI8
|| rightvt
== VT_UI8
||
4995 leftvt
== VT_INT
|| rightvt
== VT_INT
||
4996 leftvt
== VT_UINT
|| rightvt
== VT_UINT
) {
5000 if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
5002 else if (leftvt
== VT_DECIMAL
|| rightvt
== VT_DECIMAL
)
5004 else if (leftvt
== VT_R8
|| rightvt
== VT_R8
||
5005 leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
||
5006 leftvt
== VT_DATE
|| rightvt
== VT_DATE
)
5008 else if (leftvt
== VT_R4
|| rightvt
== VT_R4
) {
5009 if (leftvt
== VT_I4
|| rightvt
== VT_I4
||
5010 leftvt
== VT_I8
|| rightvt
== VT_I8
||
5011 leftvt
== VT_CY
|| rightvt
== VT_CY
)
5015 } else if (leftvt
== VT_CY
|| rightvt
== VT_CY
)
5017 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
5019 else if (leftvt
== VT_I4
|| rightvt
== VT_I4
)
5021 else if (leftvt
== VT_I2
|| rightvt
== VT_I2
||
5022 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
||
5023 (leftvt
== VT_EMPTY
&& rightvt
== VT_EMPTY
))
5025 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
5028 hres
= pVarMul(&left
, &right
, &result
);
5030 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
5031 "VarMul: %d|0x%X, %d|0x%X: Expected failure, got 0x%X vt %d\n",
5032 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], hres
,
5035 ok(hres
== S_OK
&& V_VT(&result
) == resvt
,
5036 "VarMul: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%X vt %d\n",
5037 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], resvt
, hres
,
5044 /* Test returned values */
5045 VARMUL(I4
,4,I4
,2,I4
,8);
5046 VARMUL(I2
,4,I2
,2,I2
,8);
5047 VARMUL(I2
,-13,I4
,5,I4
,-65);
5048 VARMUL(I4
,-13,I4
,5,I4
,-65);
5049 VARMUL(I2
,7,R4
,0.5f
,R4
,3.5f
);
5050 VARMUL(R4
,0.5f
,I4
,5,R8
,2.5);
5051 VARMUL(R8
,7.1,BOOL
,0,R8
,0);
5052 VARMUL(BSTR
,lbstr
,I2
,4,R8
,48);
5053 VARMUL(BSTR
,lbstr
,BOOL
,1,R8
,12);
5054 VARMUL(BSTR
,lbstr
,R4
,0.1f
,R8
,1.2);
5055 VARMUL(BSTR
,lbstr
,BSTR
,rbstr
,R8
,144);
5056 VARMUL(R4
,0.2f
,BSTR
,rbstr
,R8
,2.4);
5057 VARMUL(DATE
,2.25,I4
,7,R8
,15.75);
5059 VARMUL(UI1
, UI1_MAX
, UI1
, UI1_MAX
, I4
, UI1_MAX
* UI1_MAX
);
5060 VARMUL(I2
, I2_MAX
, I2
, I2_MAX
, I4
, I2_MAX
* I2_MAX
);
5061 VARMUL(I2
, I2_MAX
, I2
, I2_MIN
, I4
, I2_MAX
* I2_MIN
);
5062 VARMUL(I2
, I2_MIN
, I2
, I2_MIN
, I4
, I2_MIN
* I2_MIN
);
5063 VARMUL(I4
, I4_MAX
, I4
, I4_MAX
, R8
, (double)I4_MAX
* I4_MAX
);
5064 VARMUL(I4
, I4_MAX
, I4
, I4_MIN
, R8
, (double)I4_MAX
* I4_MIN
);
5065 VARMUL(I4
, I4_MIN
, I4
, I4_MIN
, R8
, (double)I4_MIN
* I4_MIN
);
5066 VARMUL(R4
, R4_MAX
, R4
, R4_MAX
, R8
, (double)R4_MAX
* R4_MAX
);
5067 VARMUL(R4
, R4_MAX
, R4
, R4_MIN
, R4
, R4_MAX
* R4_MIN
);
5068 VARMUL(R4
, R4_MIN
, R4
, R4_MIN
, R4
, R4_MIN
* R4_MIN
);
5069 VARMUL(R8
, R8_MAX
, R8
, R8_MIN
, R8
, R8_MAX
* R8_MIN
);
5070 VARMUL(R8
, R8_MIN
, R8
, R8_MIN
, R8
, R8_MIN
* R8_MIN
);
5072 /* Manuly test some VT_CY and VT_DECIMAL variants */
5074 hres
= VarCyFromI4(4711, &V_CY(&cy
));
5075 ok(hres
== S_OK
, "VarCyFromI4 failed!\n");
5076 V_VT(&dec
) = VT_DECIMAL
;
5077 hres
= VarDecFromR8(-4.2, &V_DECIMAL(&dec
));
5078 ok(hres
== S_OK
, "VarDecFromR4 failed!\n");
5079 memset(&left
, 0, sizeof(left
));
5080 memset(&right
, 0, sizeof(right
));
5081 V_VT(&left
) = VT_I4
;
5083 V_VT(&right
) = VT_UI1
;
5086 hres
= VarMul(&cy
, &right
, &result
);
5087 ok(hres
== S_OK
&& V_VT(&result
) == VT_CY
, "VarMul: expected coerced type VT_CY, got %s!\n", vtstr(V_VT(&result
)));
5088 hres
= VarR8FromCy(V_CY(&result
), &r
);
5089 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 42399), "VarMul: CY value %f, expected %f\n", r
, (double)42399);
5091 hres
= VarMul(&left
, &dec
, &result
);
5092 ok(hres
== S_OK
&& V_VT(&result
) == VT_DECIMAL
, "VarMul: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result
)));
5093 hres
= VarR8FromDec(&V_DECIMAL(&result
), &r
);
5094 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 46.2), "VarMul: DECIMAL value %f, expected %f\n", r
, (double)46.2);
5096 SysFreeString(lbstr
);
5097 SysFreeString(rbstr
);
5100 static HRESULT (WINAPI
*pVarAdd
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
5102 #define VARADD(vt1,val1,vt2,val2,rvt,rval) \
5103 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
5104 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
5105 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
5106 test_var_call2( __LINE__, pVarAdd, &left, &right, &exp )
5108 static void test_VarAdd(void)
5110 VARIANT left
, right
, exp
, result
, cy
, dec
;
5118 lbstr
= SysAllocString(sz12
);
5119 rbstr
= SysAllocString(sz12
);
5121 /* Test all possible flag/vt combinations & the resulting vt type */
5122 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
5124 VARTYPE leftvt
, rightvt
, resvt
;
5126 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
5131 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
5137 if (leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
)
5140 memset(&left
, 0, sizeof(left
));
5141 memset(&right
, 0, sizeof(right
));
5142 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
5143 if (leftvt
== VT_BSTR
)
5144 V_BSTR(&left
) = lbstr
;
5145 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
5146 if (rightvt
== VT_BSTR
)
5147 V_BSTR(&right
) = rbstr
;
5148 V_VT(&result
) = VT_EMPTY
;
5151 /* Don't ask me why but native VarAdd cannot handle:
5152 VT_I1, VT_UI2, VT_UI4, VT_INT, VT_UINT and VT_UI8.
5153 Tested with DCOM98, Win2k, WinXP */
5154 if (ExtraFlags
[i
] & VT_ARRAY
|| ExtraFlags
[i
] & VT_BYREF
||
5155 !IsValidVariantClearVT(leftvt
, ExtraFlags
[i
]) ||
5156 !IsValidVariantClearVT(rightvt
, ExtraFlags
[i
]) ||
5157 leftvt
== VT_CLSID
|| rightvt
== VT_CLSID
||
5158 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
||
5159 leftvt
== VT_VARIANT
|| rightvt
== VT_VARIANT
||
5160 leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
||
5161 leftvt
== VT_I1
|| rightvt
== VT_I1
||
5162 leftvt
== VT_UI2
|| rightvt
== VT_UI2
||
5163 leftvt
== VT_UI4
|| rightvt
== VT_UI4
||
5164 leftvt
== VT_UI8
|| rightvt
== VT_UI8
||
5165 leftvt
== VT_INT
|| rightvt
== VT_INT
||
5166 leftvt
== VT_UINT
|| rightvt
== VT_UINT
) {
5170 if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
5172 else if (leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
)
5174 else if (leftvt
== VT_DECIMAL
|| rightvt
== VT_DECIMAL
)
5176 else if (leftvt
== VT_DATE
|| rightvt
== VT_DATE
)
5178 else if (leftvt
== VT_CY
|| rightvt
== VT_CY
)
5180 else if (leftvt
== VT_R8
|| rightvt
== VT_R8
)
5182 else if (leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
) {
5183 if ((leftvt
== VT_BSTR
&& rightvt
== VT_BSTR
) ||
5184 leftvt
== VT_EMPTY
|| rightvt
== VT_EMPTY
)
5188 } else if (leftvt
== VT_R4
|| rightvt
== VT_R4
) {
5189 if (leftvt
== VT_I4
|| rightvt
== VT_I4
||
5190 leftvt
== VT_I8
|| rightvt
== VT_I8
)
5195 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
5197 else if (leftvt
== VT_I4
|| rightvt
== VT_I4
)
5199 else if (leftvt
== VT_I2
|| rightvt
== VT_I2
||
5200 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
||
5201 (leftvt
== VT_EMPTY
&& rightvt
== VT_EMPTY
))
5203 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
5206 hres
= pVarAdd(&left
, &right
, &result
);
5208 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
5209 "VarAdd: %d|0x%X, %d|0x%X: Expected failure, got 0x%X vt %d\n",
5210 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], hres
,
5213 ok(hres
== S_OK
&& V_VT(&result
) == resvt
,
5214 "VarAdd: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%X vt %d\n",
5215 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], resvt
, hres
,
5218 /* Note, we don't clear left/right deliberately here */
5219 VariantClear(&result
);
5224 /* Test returned values */
5225 VARADD(I4
,4,I4
,2,I4
,6);
5226 VARADD(I2
,4,I2
,2,I2
,6);
5227 VARADD(I2
,-13,I4
,5,I4
,-8);
5228 VARADD(I4
,-13,I4
,5,I4
,-8);
5229 VARADD(I2
,7,R4
,0.5f
,R4
,7.5f
);
5230 VARADD(R4
,0.5f
,I4
,5,R8
,5.5);
5231 VARADD(R8
,7.1,BOOL
,0,R8
,7.1);
5232 VARADD(BSTR
,lbstr
,I2
,4,R8
,16);
5233 VARADD(BSTR
,lbstr
,BOOL
,1,R8
,13);
5234 VARADD(BSTR
,lbstr
,R4
,0.1f
,R8
,12.1);
5235 VARADD(R4
,0.2f
,BSTR
,rbstr
,R8
,12.2);
5236 VARADD(DATE
,2.25,I4
,7,DATE
,9.25);
5237 VARADD(DATE
,1.25,R4
,-1.7f
,DATE
,-0.45);
5239 VARADD(UI1
, UI1_MAX
, UI1
, UI1_MAX
, I2
, UI1_MAX
+ UI1_MAX
);
5240 VARADD(I2
, I2_MAX
, I2
, I2_MAX
, I4
, I2_MAX
+ I2_MAX
);
5241 VARADD(I2
, I2_MAX
, I2
, I2_MIN
, I2
, I2_MAX
+ I2_MIN
);
5242 VARADD(I2
, I2_MIN
, I2
, I2_MIN
, I4
, I2_MIN
+ I2_MIN
);
5243 VARADD(I4
, I4_MAX
, I4
, I4_MIN
, I4
, I4_MAX
+ I4_MIN
);
5244 VARADD(I4
, I4_MAX
, I4
, I4_MAX
, R8
, (double)I4_MAX
+ I4_MAX
);
5245 VARADD(I4
, I4_MIN
, I4
, I4_MIN
, R8
, (double)I4_MIN
+ I4_MIN
);
5246 VARADD(R4
, R4_MAX
, R4
, R4_MAX
, R8
, (double)R4_MAX
+ R4_MAX
);
5247 VARADD(R4
, R4_MAX
, R4
, R4_MIN
, R4
, R4_MAX
+ R4_MIN
);
5248 VARADD(R4
, R4_MIN
, R4
, R4_MIN
, R4
, R4_MIN
+ R4_MIN
);
5249 VARADD(R8
, R8_MAX
, R8
, R8_MIN
, R8
, R8_MAX
+ R8_MIN
);
5250 VARADD(R8
, R8_MIN
, R8
, R8_MIN
, R8
, R8_MIN
+ R8_MIN
);
5252 /* Manually test BSTR + BSTR */
5253 V_VT(&left
) = VT_BSTR
;
5254 V_BSTR(&left
) = lbstr
;
5255 V_VT(&right
) = VT_BSTR
;
5256 V_BSTR(&right
) = rbstr
;
5257 hres
= VarAdd(&left
, &right
, &result
);
5258 ok(hres
== S_OK
&& V_VT(&result
) == VT_BSTR
, "VarAdd: expected coerced type VT_BSTR, got %s!\n", vtstr(V_VT(&result
)));
5259 hres
= VarR8FromStr(V_BSTR(&result
), 0, 0, &r
);
5260 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 1212), "VarAdd: BSTR value %f, expected %f\n", r
, (double)1212);
5261 VariantClear(&result
);
5263 /* Manuly test some VT_CY and VT_DECIMAL variants */
5265 hres
= VarCyFromI4(4711, &V_CY(&cy
));
5266 ok(hres
== S_OK
, "VarCyFromI4 failed!\n");
5267 V_VT(&dec
) = VT_DECIMAL
;
5268 hres
= VarDecFromR8(-4.2, &V_DECIMAL(&dec
));
5269 ok(hres
== S_OK
, "VarDecFromR4 failed!\n");
5270 memset(&left
, 0, sizeof(left
));
5271 memset(&right
, 0, sizeof(right
));
5272 V_VT(&left
) = VT_I4
;
5274 V_VT(&right
) = VT_UI1
;
5277 hres
= VarAdd(&cy
, &right
, &result
);
5278 ok(hres
== S_OK
&& V_VT(&result
) == VT_CY
, "VarAdd: expected coerced type VT_CY, got %s!\n", vtstr(V_VT(&result
)));
5279 hres
= VarR8FromCy(V_CY(&result
), &r
);
5280 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 4720), "VarAdd: CY value %f, expected %f\n", r
, (double)4720);
5282 hres
= VarAdd(&left
, &dec
, &result
);
5283 ok(hres
== S_OK
&& V_VT(&result
) == VT_DECIMAL
, "VarAdd: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result
)));
5284 hres
= VarR8FromDec(&V_DECIMAL(&result
), &r
);
5285 ok(hres
== S_OK
&& EQ_DOUBLE(r
, -15.2), "VarAdd: DECIMAL value %f, expected %f\n", r
, (double)-15.2);
5286 VariantClear(&result
);
5288 SysFreeString(lbstr
);
5289 SysFreeString(rbstr
);
5292 static void test_VarCat(void)
5295 VARIANT left
, right
, result
, expected
, expected_broken
;
5296 static const WCHAR sz34
[] = {'3','4','\0'};
5297 static const WCHAR sz1234
[] = {'1','2','3','4','\0'};
5298 static const WCHAR date_sz12
[] = {'9','/','3','0','/','1','9','8','0','1','2','\0'};
5299 static const WCHAR date_sz12_broken
[] = {'9','/','3','0','/','8','0','1','2','\0'};
5300 static const WCHAR sz12_date
[] = {'1','2','9','/','3','0','/','1','9','8','0','\0'};
5301 static const WCHAR sz12_date_broken
[] = {'1','2','9','/','3','0','/','8','0','\0'};
5302 static const WCHAR sz_empty
[] = {'\0'};
5303 TCHAR orig_date_format
[128];
5304 VARTYPE leftvt
, rightvt
, resultvt
;
5306 HRESULT expected_error_num
;
5308 /* Set date format for testing */
5309 lcid
= LOCALE_USER_DEFAULT
;
5310 GetLocaleInfo(lcid
,LOCALE_SSHORTDATE
,orig_date_format
,128);
5311 SetLocaleInfo(lcid
,LOCALE_SSHORTDATE
,"M/d/yyyy");
5314 VariantInit(&right
);
5315 VariantInit(&result
);
5316 VariantInit(&expected
);
5318 /* Check expected types for all combinations */
5319 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
5324 /* Check if we need/have support for I8 and/or UI8 */
5325 if ((leftvt
== VT_I8
|| leftvt
== VT_UI8
) && !HAVE_OLEAUT32_I8
)
5328 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
5332 expected_error_num
= S_OK
;
5333 resultvt
= VT_EMPTY
;
5335 if (leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
||
5336 leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
||
5337 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
||
5338 leftvt
== 15 || rightvt
== 15 /* Undefined type */)
5341 /* Check if we need/have support for I8 and/or UI8 */
5342 if ((rightvt
== VT_I8
|| rightvt
== VT_UI8
) && !HAVE_OLEAUT32_I8
)
5345 if (leftvt
== VT_NULL
&& rightvt
== VT_NULL
)
5347 else if (leftvt
== VT_VARIANT
&& (rightvt
== VT_ERROR
||
5348 rightvt
== VT_DATE
|| rightvt
== VT_DECIMAL
))
5349 expected_error_num
= DISP_E_TYPEMISMATCH
;
5350 else if ((leftvt
== VT_I2
|| leftvt
== VT_I4
||
5351 leftvt
== VT_R4
|| leftvt
== VT_R8
||
5352 leftvt
== VT_CY
|| leftvt
== VT_BOOL
||
5353 leftvt
== VT_BSTR
|| leftvt
== VT_I1
||
5354 leftvt
== VT_UI1
|| leftvt
== VT_UI2
||
5355 leftvt
== VT_UI4
|| leftvt
== VT_I8
||
5356 leftvt
== VT_UI8
|| leftvt
== VT_INT
||
5357 leftvt
== VT_UINT
|| leftvt
== VT_EMPTY
||
5358 leftvt
== VT_NULL
|| leftvt
== VT_DECIMAL
||
5361 (rightvt
== VT_I2
|| rightvt
== VT_I4
||
5362 rightvt
== VT_R4
|| rightvt
== VT_R8
||
5363 rightvt
== VT_CY
|| rightvt
== VT_BOOL
||
5364 rightvt
== VT_BSTR
|| rightvt
== VT_I1
||
5365 rightvt
== VT_UI1
|| rightvt
== VT_UI2
||
5366 rightvt
== VT_UI4
|| rightvt
== VT_I8
||
5367 rightvt
== VT_UI8
|| rightvt
== VT_INT
||
5368 rightvt
== VT_UINT
|| rightvt
== VT_EMPTY
||
5369 rightvt
== VT_NULL
|| rightvt
== VT_DECIMAL
||
5370 rightvt
== VT_DATE
))
5372 else if (rightvt
== VT_ERROR
&& leftvt
< VT_VOID
)
5373 expected_error_num
= DISP_E_TYPEMISMATCH
;
5374 else if (leftvt
== VT_ERROR
&& (rightvt
== VT_DATE
||
5375 rightvt
== VT_ERROR
|| rightvt
== VT_DECIMAL
))
5376 expected_error_num
= DISP_E_TYPEMISMATCH
;
5377 else if (rightvt
== VT_DATE
|| rightvt
== VT_ERROR
||
5378 rightvt
== VT_DECIMAL
)
5379 expected_error_num
= DISP_E_BADVARTYPE
;
5380 else if (leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
)
5381 expected_error_num
= DISP_E_TYPEMISMATCH
;
5382 else if (leftvt
== VT_VARIANT
)
5383 expected_error_num
= DISP_E_TYPEMISMATCH
;
5384 else if (rightvt
== VT_VARIANT
&& (leftvt
== VT_EMPTY
||
5385 leftvt
== VT_NULL
|| leftvt
== VT_I2
||
5386 leftvt
== VT_I4
|| leftvt
== VT_R4
||
5387 leftvt
== VT_R8
|| leftvt
== VT_CY
||
5388 leftvt
== VT_DATE
|| leftvt
== VT_BSTR
||
5389 leftvt
== VT_BOOL
|| leftvt
== VT_DECIMAL
||
5390 leftvt
== VT_I1
|| leftvt
== VT_UI1
||
5391 leftvt
== VT_UI2
|| leftvt
== VT_UI4
||
5392 leftvt
== VT_I8
|| leftvt
== VT_UI8
||
5393 leftvt
== VT_INT
|| leftvt
== VT_UINT
5395 expected_error_num
= DISP_E_TYPEMISMATCH
;
5397 expected_error_num
= DISP_E_BADVARTYPE
;
5399 V_VT(&left
) = leftvt
;
5400 V_VT(&right
) = rightvt
;
5404 V_BSTR(&left
) = SysAllocString(sz_empty
); break;
5406 V_DATE(&left
) = 0.0; break;
5408 VarDecFromR8(0.0, &V_DECIMAL(&left
)); break;
5415 V_BSTR(&right
) = SysAllocString(sz_empty
); break;
5417 V_DATE(&right
) = 0.0; break;
5419 VarDecFromR8(0.0, &V_DECIMAL(&right
)); break;
5424 hres
= VarCat(&left
, &right
, &result
);
5426 /* Determine the error code for the vt combination */
5427 ok(hres
== expected_error_num
,
5428 "VarCat: %d, %d returned error, 0x%X expected 0x%X.\n",
5429 leftvt
, rightvt
, expected_error_num
, hres
);
5431 /* Check types are correct */
5432 ok(V_VT(&result
) == resultvt
,
5433 "VarCat: %d, %d: expected vt %d, got vt %d\n",
5434 leftvt
, rightvt
, resultvt
, V_VT(&result
));
5436 VariantClear(&left
);
5437 VariantClear(&right
);
5438 VariantClear(&result
);
5442 /* Running single comparison tests to compare outputs */
5444 /* Test concat strings */
5445 V_VT(&left
) = VT_BSTR
;
5446 V_VT(&right
) = VT_BSTR
;
5447 V_VT(&expected
) = VT_BSTR
;
5448 V_BSTR(&left
) = SysAllocString(sz12
);
5449 V_BSTR(&right
) = SysAllocString(sz34
);
5450 V_BSTR(&expected
) = SysAllocString(sz1234
);
5451 hres
= VarCat(&left
,&right
,&result
);
5452 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5453 ok(VarCmp(&result
,&expected
,lcid
,0) == VARCMP_EQ
,
5454 "VarCat: VT_BSTR concat with VT_BSTR failed to return correct result\n");
5456 VariantClear(&left
);
5457 VariantClear(&right
);
5458 VariantClear(&result
);
5460 /* Test if expression is VT_ERROR */
5461 V_VT(&left
) = VT_ERROR
;
5462 V_VT(&right
) = VT_BSTR
;
5463 V_BSTR(&right
) = SysAllocString(sz1234
);
5464 hres
= VarCat(&left
,&right
,&result
);
5465 ok(hres
== DISP_E_TYPEMISMATCH
, "VarCat should have returned DISP_E_TYPEMISMATCH instead of 0x%08x\n", hres
);
5466 ok(V_VT(&result
) == VT_EMPTY
,
5467 "VarCat: VT_ERROR concat with VT_BSTR should have returned VT_EMPTY\n");
5469 VariantClear(&left
);
5470 VariantClear(&right
);
5471 VariantClear(&result
);
5473 V_VT(&left
) = VT_BSTR
;
5474 V_VT(&right
) = VT_ERROR
;
5475 V_BSTR(&left
) = SysAllocString(sz1234
);
5476 hres
= VarCat(&left
,&right
,&result
);
5477 ok(hres
== DISP_E_TYPEMISMATCH
, "VarCat should have returned DISP_E_TYPEMISMATCH instead of 0x%08x\n", hres
);
5478 ok(V_VT(&result
) == VT_EMPTY
,
5479 "VarCat: VT_BSTR concat with VT_ERROR should have returned VT_EMPTY\n");
5481 VariantClear(&left
);
5482 VariantClear(&right
);
5483 VariantClear(&result
);
5484 VariantClear(&expected
);
5486 /* Test combining boolean with number */
5487 V_VT(&left
) = VT_INT
;
5488 V_VT(&right
) = VT_BOOL
;
5489 V_VT(&expected
) = VT_BSTR
;
5491 V_BOOL(&right
) = TRUE
;
5492 V_BSTR(&expected
) = SysAllocString(sz12_true
);
5493 hres
= VarCat(&left
,&right
,&result
);
5494 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5495 hres
= VarCmp(&result
,&expected
,lcid
,0);
5496 ok(hres
== VARCMP_EQ
, "Expected VARCMP_EQ, got %08x for %s, %s\n",
5497 hres
, variantstr(&result
), variantstr(&expected
));
5499 VariantClear(&left
);
5500 VariantClear(&right
);
5501 VariantClear(&result
);
5502 VariantClear(&expected
);
5504 V_VT(&left
) = VT_INT
;
5505 V_VT(&right
) = VT_BOOL
;
5506 V_VT(&expected
) = VT_BSTR
;
5508 V_BOOL(&right
) = FALSE
;
5509 V_BSTR(&expected
) = SysAllocString(sz12_false
);
5510 hres
= VarCat(&left
,&right
,&result
);
5511 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5512 hres
= VarCmp(&result
,&expected
,lcid
,0);
5513 ok(hres
== VARCMP_EQ
, "Expected VARCMP_EQ, got %08x for %s, %s\n",
5514 hres
, variantstr(&result
), variantstr(&expected
));
5516 VariantClear(&left
);
5517 VariantClear(&right
);
5518 VariantClear(&result
);
5519 VariantClear(&expected
);
5521 /* Test when both expressions are numeric */
5522 V_VT(&left
) = VT_INT
;
5523 V_VT(&right
) = VT_INT
;
5524 V_VT(&expected
) = VT_BSTR
;
5527 V_BSTR(&expected
) = SysAllocString(sz1234
);
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: NUMBER concat with NUMBER returned incorrect result\n");
5533 VariantClear(&left
);
5534 VariantClear(&right
);
5535 VariantClear(&result
);
5537 /* Test if one expression is numeric and the other is a string */
5538 V_VT(&left
) = VT_INT
;
5539 V_VT(&right
) = VT_BSTR
;
5541 V_BSTR(&right
) = SysAllocString(sz34
);
5542 hres
= VarCat(&left
,&right
,&result
);
5543 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5544 ok(VarCmp(&result
,&expected
,lcid
,0) == VARCMP_EQ
,
5545 "VarCat: NUMBER concat with VT_BSTR, incorrect result\n");
5547 VariantClear(&left
);
5548 VariantClear(&right
);
5549 VariantClear(&result
);
5551 V_VT(&left
) = VT_BSTR
;
5552 V_VT(&right
) = VT_INT
;
5553 V_BSTR(&left
) = SysAllocString(sz12
);
5555 hres
= VarCat(&left
,&right
,&result
);
5556 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5557 ok(VarCmp(&result
,&expected
,lcid
,0) == VARCMP_EQ
,
5558 "VarCat: VT_BSTR concat with NUMBER, incorrect result\n");
5560 VariantClear(&left
);
5561 VariantClear(&right
);
5562 VariantClear(&result
);
5563 VariantClear(&expected
);
5565 /* Test concat dates with strings */
5566 V_VT(&left
) = VT_BSTR
;
5567 V_VT(&right
) = VT_DATE
;
5568 V_VT(&expected
) = VT_BSTR
;
5569 V_VT(&expected_broken
) = VT_BSTR
;
5570 V_BSTR(&left
) = SysAllocString(sz12
);
5571 V_DATE(&right
) = 29494.0;
5572 V_BSTR(&expected
)= SysAllocString(sz12_date
);
5573 V_BSTR(&expected_broken
)= SysAllocString(sz12_date_broken
);
5574 hres
= VarCat(&left
,&right
,&result
);
5575 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5576 ok(VarCmp(&result
,&expected
,lcid
,0) == VARCMP_EQ
||
5577 broken(VarCmp(&result
,&expected_broken
,lcid
,0) == VARCMP_EQ
), /* Some W98 and NT4 (intermittent) */
5578 "VarCat: VT_BSTR concat with VT_DATE returned incorrect result\n");
5580 VariantClear(&left
);
5581 VariantClear(&right
);
5582 VariantClear(&result
);
5583 VariantClear(&expected
);
5584 VariantClear(&expected_broken
);
5586 V_VT(&left
) = VT_DATE
;
5587 V_VT(&right
) = VT_BSTR
;
5588 V_VT(&expected
) = VT_BSTR
;
5589 V_VT(&expected_broken
) = VT_BSTR
;
5590 V_DATE(&left
) = 29494.0;
5591 V_BSTR(&right
) = SysAllocString(sz12
);
5592 V_BSTR(&expected
)= SysAllocString(date_sz12
);
5593 V_BSTR(&expected_broken
)= SysAllocString(date_sz12_broken
);
5594 hres
= VarCat(&left
,&right
,&result
);
5595 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5596 ok(VarCmp(&result
,&expected
,lcid
,0) == VARCMP_EQ
||
5597 broken(VarCmp(&result
,&expected_broken
,lcid
,0) == VARCMP_EQ
), /* Some W98 and NT4 (intermittent) */
5598 "VarCat: VT_DATE concat with VT_BSTR returned incorrect result\n");
5600 VariantClear(&left
);
5601 VariantClear(&right
);
5602 VariantClear(&result
);
5603 VariantClear(&expected
);
5604 VariantClear(&expected_broken
);
5606 /* Test of both expressions are empty */
5607 V_VT(&left
) = VT_BSTR
;
5608 V_VT(&right
) = VT_BSTR
;
5609 V_VT(&expected
) = VT_BSTR
;
5610 V_BSTR(&left
) = SysAllocString(sz_empty
);
5611 V_BSTR(&right
) = SysAllocString(sz_empty
);
5612 V_BSTR(&expected
)= SysAllocString(sz_empty
);
5613 hres
= VarCat(&left
,&right
,&result
);
5614 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5615 ok(VarCmp(&result
,&left
,lcid
,0) == VARCMP_EQ
,
5616 "VarCat: EMPTY concat with EMPTY did not return empty VT_BSTR\n");
5618 /* Restore original date format settings */
5619 SetLocaleInfo(lcid
,LOCALE_SSHORTDATE
,orig_date_format
);
5621 VariantClear(&left
);
5622 VariantClear(&right
);
5623 VariantClear(&result
);
5624 VariantClear(&expected
);
5627 static HRESULT (WINAPI
*pVarAnd
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
5629 #define VARAND(vt1,val1,vt2,val2,rvt,rval) \
5630 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
5631 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
5632 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
5633 test_var_call2( __LINE__, pVarAnd, &left, &right, &exp )
5635 #define VARANDCY(vt1,val1,val2,rvt,rval) \
5636 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
5637 V_VT(&right) = VT_CY; V_CY(&right).int64 = val2; \
5638 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
5639 test_var_call2( __LINE__, pVarAnd, &left, &right, &exp )
5641 /* Skip any type that is not defined or produces an error for every case */
5642 #define SKIPTESTAND(a) \
5643 if (a == VT_ERROR || a == VT_VARIANT || \
5644 a == VT_DISPATCH || a == VT_UNKNOWN || \
5645 a > VT_UINT || a == 15 /*not defined*/) \
5648 static void test_VarAnd(void)
5650 static const WCHAR szFalse
[] = { '#','F','A','L','S','E','#','\0' };
5651 static const WCHAR szTrue
[] = { '#','T','R','U','E','#','\0' };
5652 VARIANT left
, right
, exp
, result
;
5653 BSTR false_str
, true_str
;
5657 true_str
= SysAllocString(szTrue
);
5658 false_str
= SysAllocString(szFalse
);
5662 /* Test all possible flag/vt combinations & the resulting vt type */
5663 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
5665 VARTYPE leftvt
, rightvt
, resvt
;
5667 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
5669 SKIPTESTAND(leftvt
);
5671 /* Check if we need/have support for I8 and/or UI8 */
5672 if ((leftvt
== VT_I8
|| leftvt
== VT_UI8
) && !HAVE_OLEAUT32_I8
)
5675 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
5678 SKIPTESTAND(rightvt
);
5680 /* Check if we need/have support for I8 and/or UI8 */
5681 if ((rightvt
== VT_I8
|| rightvt
== VT_UI8
) && !HAVE_OLEAUT32_I8
)
5684 memset(&left
, 0, sizeof(left
));
5685 memset(&right
, 0, sizeof(right
));
5686 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
5687 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
5688 V_VT(&result
) = VT_EMPTY
;
5690 if ((leftvt
| ExtraFlags
[i
]) == VT_BSTR
)
5691 V_BSTR(&left
) = true_str
;
5692 if ((rightvt
| ExtraFlags
[i
]) == VT_BSTR
)
5693 V_BSTR(&right
) = true_str
;
5695 /* Native VarAnd always returns an error when using extra
5696 * flags or if the variant combination is I8 and INT.
5698 if ((leftvt
== VT_I8
&& rightvt
== VT_INT
) ||
5699 (leftvt
== VT_INT
&& rightvt
== VT_I8
) ||
5703 /* Determine return type */
5704 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
5706 else if (leftvt
== VT_I4
|| rightvt
== VT_I4
||
5707 leftvt
== VT_UINT
|| rightvt
== VT_UINT
||
5708 leftvt
== VT_INT
|| rightvt
== VT_INT
||
5709 leftvt
== VT_UINT
|| rightvt
== VT_UINT
||
5710 leftvt
== VT_R4
|| rightvt
== VT_R4
||
5711 leftvt
== VT_R8
|| rightvt
== VT_R8
||
5712 leftvt
== VT_CY
|| rightvt
== VT_CY
||
5713 leftvt
== VT_DATE
|| rightvt
== VT_DATE
||
5714 leftvt
== VT_I1
|| rightvt
== VT_I1
||
5715 leftvt
== VT_UI2
|| rightvt
== VT_UI2
||
5716 leftvt
== VT_UI4
|| rightvt
== VT_UI4
||
5717 leftvt
== VT_UI8
|| rightvt
== VT_UI8
||
5718 leftvt
== VT_DECIMAL
|| rightvt
== VT_DECIMAL
)
5720 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
||
5721 leftvt
== VT_I2
|| rightvt
== VT_I2
||
5722 leftvt
== VT_EMPTY
|| rightvt
== VT_EMPTY
)
5723 if ((leftvt
== VT_NULL
&& rightvt
== VT_UI1
) ||
5724 (leftvt
== VT_UI1
&& rightvt
== VT_NULL
) ||
5725 (leftvt
== VT_UI1
&& rightvt
== VT_UI1
))
5729 else if (leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
||
5730 (leftvt
== VT_BSTR
&& rightvt
== VT_BSTR
))
5732 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
||
5733 leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
)
5738 hres
= pVarAnd(&left
, &right
, &result
);
5740 /* Check expected HRESULT and if result variant type is correct */
5742 ok (hres
== DISP_E_BADVARTYPE
|| hres
== DISP_E_TYPEMISMATCH
,
5743 "VarAnd: %s|0x%X, %s|0x%X: got vt %s hr 0x%X\n",
5744 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
],
5745 vtstr(V_VT(&result
)), hres
);
5747 ok (hres
== S_OK
&& resvt
== V_VT(&result
),
5748 "VarAnd: %s|0x%X, %s|0x%X: expected vt %s hr 0x%X, got vt %s hr 0x%X\n",
5749 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
], vtstr(resvt
),
5750 S_OK
, vtstr(V_VT(&result
)), hres
);
5756 * Test returned values. Since we know the returned type is correct
5757 * and that we handle all combinations of invalid types, just check
5758 * that good type combinations produce the desired value.
5759 * FIXME: Test VT_DECIMAL
5761 VARAND(EMPTY
,0,EMPTY
,0,I2
,0);
5762 VARAND(EMPTY
,1,EMPTY
,0,I2
,0);
5763 VARAND(EMPTY
,1,EMPTY
,1,I2
,0);
5764 VARAND(EMPTY
,0,NULL
,0,I2
,0);
5765 VARAND(EMPTY
,1,NULL
,0,I2
,0);
5766 VARAND(EMPTY
,1,NULL
,1,I2
,0);
5767 VARAND(EMPTY
,0,I1
,0,I4
,0);
5768 VARAND(EMPTY
,0,I1
,1,I4
,0);
5769 VARAND(EMPTY
,1,I1
,1,I4
,0);
5770 VARAND(EMPTY
,0,UI1
,0,I2
,0);
5771 VARAND(EMPTY
,0,UI1
,1,I2
,0);
5772 VARAND(EMPTY
,1,UI1
,1,I2
,0);
5773 VARAND(EMPTY
,0,I2
,0,I2
,0);
5774 VARAND(EMPTY
,0,I2
,1,I2
,0);
5775 VARAND(EMPTY
,1,I2
,1,I2
,0);
5776 VARAND(EMPTY
,0,UI2
,0,I4
,0);
5777 VARAND(EMPTY
,0,UI2
,1,I4
,0);
5778 VARAND(EMPTY
,1,UI2
,1,I4
,0);
5779 VARAND(EMPTY
,0,I4
,0,I4
,0);
5780 VARAND(EMPTY
,0,I4
,1,I4
,0);
5781 VARAND(EMPTY
,1,I4
,1,I4
,0);
5782 VARAND(EMPTY
,0,UI4
,0,I4
,0);
5783 VARAND(EMPTY
,0,UI4
,1,I4
,0);
5784 VARAND(EMPTY
,1,UI4
,1,I4
,0);
5785 if (HAVE_OLEAUT32_I8
)
5787 VARAND(EMPTY
,0,I8
,0,I8
,0);
5788 VARAND(EMPTY
,0,I8
,1,I8
,0);
5789 VARAND(EMPTY
,1,I8
,1,I8
,0);
5790 VARAND(EMPTY
,0,UI8
,0,I4
,0);
5791 VARAND(EMPTY
,0,UI8
,1,I4
,0);
5792 VARAND(EMPTY
,1,UI8
,1,I4
,0);
5794 VARAND(EMPTY
,0,INT
,0,I4
,0);
5795 VARAND(EMPTY
,0,INT
,1,I4
,0);
5796 VARAND(EMPTY
,1,INT
,1,I4
,0);
5797 VARAND(EMPTY
,0,UINT
,0,I4
,0);
5798 VARAND(EMPTY
,0,UINT
,1,I4
,0);
5799 VARAND(EMPTY
,1,UINT
,1,I4
,0);
5800 VARAND(EMPTY
,0,BOOL
,0,I2
,0);
5801 VARAND(EMPTY
,0,BOOL
,1,I2
,0);
5802 VARAND(EMPTY
,1,BOOL
,1,I2
,0);
5803 VARAND(EMPTY
,0,R4
,0,I4
,0);
5804 VARAND(EMPTY
,0,R4
,1,I4
,0);
5805 VARAND(EMPTY
,1,R4
,1,I4
,0);
5806 VARAND(EMPTY
,0,R8
,0,I4
,0);
5807 VARAND(EMPTY
,0,R8
,1,I4
,0);
5808 VARAND(EMPTY
,1,R8
,1,I4
,0);
5809 VARAND(EMPTY
,0,BSTR
,false_str
,I2
,0);
5810 VARAND(EMPTY
,0,BSTR
,true_str
,I2
,0);
5811 VARANDCY(EMPTY
,0,10000,I4
,0);
5813 /* NULL OR 0 = NULL. NULL OR n = n */
5814 VARAND(NULL
,0,NULL
,0,NULL
,0);
5815 VARAND(NULL
,1,NULL
,0,NULL
,0);
5816 VARAND(NULL
,0,I1
,0,I4
,0);
5817 VARAND(NULL
,0,I1
,1,NULL
,0);
5818 VARAND(NULL
,0,UI1
,0,UI1
,0);
5819 VARAND(NULL
,0,UI1
,1,NULL
,0);
5820 VARAND(NULL
,0,I2
,0,I2
,0);
5821 VARAND(NULL
,0,I2
,1,NULL
,0);
5822 VARAND(NULL
,0,UI2
,0,I4
,0);
5823 VARAND(NULL
,0,UI2
,1,NULL
,0);
5824 VARAND(NULL
,0,I4
,0,I4
,0);
5825 VARAND(NULL
,0,I4
,1,NULL
,0);
5826 VARAND(NULL
,0,UI4
,0,I4
,0);
5827 VARAND(NULL
,0,UI4
,1,NULL
,0);
5828 if (HAVE_OLEAUT32_I8
)
5830 VARAND(NULL
,0,I8
,0,I8
,0);
5831 VARAND(NULL
,0,I8
,1,NULL
,0);
5832 VARAND(NULL
,0,UI8
,0,I4
,0);
5833 VARAND(NULL
,0,UI8
,1,NULL
,0);
5835 VARAND(NULL
,0,INT
,0,I4
,0);
5836 VARAND(NULL
,0,INT
,1,NULL
,0);
5837 VARAND(NULL
,0,UINT
,0,I4
,0);
5838 VARAND(NULL
,0,UINT
,1,NULL
,0);
5839 VARAND(NULL
,0,BOOL
,0,BOOL
,0);
5840 VARAND(NULL
,0,BOOL
,1,NULL
,0);
5841 VARAND(NULL
,0,R4
,0,I4
,0);
5842 VARAND(NULL
,0,R4
,1,NULL
,0);
5843 VARAND(NULL
,0,R8
,0,I4
,0);
5844 VARAND(NULL
,0,R8
,1,NULL
,0);
5845 VARAND(NULL
,0,BSTR
,false_str
,BOOL
,0);
5846 VARAND(NULL
,0,BSTR
,true_str
,NULL
,VARIANT_FALSE
);
5847 VARANDCY(NULL
,0,10000,NULL
,0);
5848 VARANDCY(NULL
,0,0,I4
,0);
5849 VARAND(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
);
5850 VARAND(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_FALSE
);
5851 VARAND(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
);
5852 VARAND(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_FALSE
);
5854 /* Assume x,y & y,x are the same from now on to reduce the number of tests */
5855 VARAND(BOOL
,VARIANT_TRUE
,I1
,-1,I4
,-1);
5856 VARAND(BOOL
,VARIANT_TRUE
,I1
,0,I4
,0);
5857 VARAND(BOOL
,VARIANT_FALSE
,I1
,0,I4
,0);
5858 VARAND(BOOL
,VARIANT_TRUE
,UI1
,255,I2
,255);
5859 VARAND(BOOL
,VARIANT_TRUE
,UI1
,0,I2
,0);
5860 VARAND(BOOL
,VARIANT_FALSE
,UI1
,0,I2
,0);
5861 VARAND(BOOL
,VARIANT_TRUE
,I2
,-1,I2
,-1);
5862 VARAND(BOOL
,VARIANT_TRUE
,I2
,0,I2
,0);
5863 VARAND(BOOL
,VARIANT_FALSE
,I2
,0,I2
,0);
5864 VARAND(BOOL
,VARIANT_TRUE
,UI2
,65535,I4
,65535);
5865 VARAND(BOOL
,VARIANT_TRUE
,UI2
,0,I4
,0);
5866 VARAND(BOOL
,VARIANT_FALSE
,UI2
,0,I4
,0);
5867 VARAND(BOOL
,VARIANT_TRUE
,I4
,-1,I4
,-1);
5868 VARAND(BOOL
,VARIANT_TRUE
,I4
,0,I4
,0);
5869 VARAND(BOOL
,VARIANT_FALSE
,I4
,0,I4
,0);
5870 VARAND(BOOL
,VARIANT_TRUE
,UI4
,0xffffffff,I4
,-1);
5871 VARAND(BOOL
,VARIANT_TRUE
,UI4
,0,I4
,0);
5872 VARAND(BOOL
,VARIANT_FALSE
,UI4
,0,I4
,0);
5873 VARAND(BOOL
,VARIANT_TRUE
,R4
,-1,I4
,-1);
5874 VARAND(BOOL
,VARIANT_TRUE
,R4
,0,I4
,0);
5875 VARAND(BOOL
,VARIANT_FALSE
,R4
,0,I4
,0);
5876 VARAND(BOOL
,VARIANT_TRUE
,R8
,-1,I4
,-1);
5877 VARAND(BOOL
,VARIANT_TRUE
,R8
,0,I4
,0);
5878 VARAND(BOOL
,VARIANT_FALSE
,R8
,0,I4
,0);
5879 VARAND(BOOL
,VARIANT_TRUE
,DATE
,-1,I4
,-1);
5880 VARAND(BOOL
,VARIANT_TRUE
,DATE
,0,I4
,0);
5881 VARAND(BOOL
,VARIANT_FALSE
,DATE
,0,I4
,0);
5882 if (HAVE_OLEAUT32_I8
)
5884 VARAND(BOOL
,VARIANT_TRUE
,I8
,-1,I8
,-1);
5885 VARAND(BOOL
,VARIANT_TRUE
,I8
,0,I8
,0);
5886 VARAND(BOOL
,VARIANT_FALSE
,I8
,0,I8
,0);
5887 VARAND(BOOL
,VARIANT_TRUE
,UI8
,0,I4
,0);
5888 VARAND(BOOL
,VARIANT_FALSE
,UI8
,0,I4
,0);
5890 VARAND(BOOL
,VARIANT_TRUE
,INT
,-1,I4
,-1);
5891 VARAND(BOOL
,VARIANT_TRUE
,INT
,0,I4
,0);
5892 VARAND(BOOL
,VARIANT_FALSE
,INT
,0,I4
,0);
5893 VARAND(BOOL
,VARIANT_TRUE
,UINT
,0xffffffff,I4
,-1);
5894 VARAND(BOOL
,VARIANT_TRUE
,UINT
,0,I4
,0);
5895 VARAND(BOOL
,VARIANT_FALSE
,UINT
,0,I4
,0);
5896 VARAND(BOOL
,VARIANT_FALSE
,BSTR
,false_str
,BOOL
,VARIANT_FALSE
);
5897 VARAND(BOOL
,VARIANT_TRUE
,BSTR
,false_str
,BOOL
,VARIANT_FALSE
);
5898 VARAND(BOOL
,VARIANT_FALSE
,BSTR
,true_str
,BOOL
,VARIANT_FALSE
);
5899 VARAND(BOOL
,VARIANT_TRUE
,BSTR
,true_str
,BOOL
,VARIANT_TRUE
);
5900 VARANDCY(BOOL
,VARIANT_TRUE
,10000,I4
,1);
5901 VARANDCY(BOOL
,VARIANT_TRUE
,0,I4
,0);
5902 VARANDCY(BOOL
,VARIANT_FALSE
,0,I4
,0);
5903 VARAND(I1
,-1,I1
,-1,I4
,-1);
5904 VARAND(I1
,-1,I1
,0,I4
,0);
5905 VARAND(I1
,0,I1
,0,I4
,0);
5906 VARAND(I1
,-1,UI1
,255,I4
,255);
5907 VARAND(I1
,-1,UI1
,0,I4
,0);
5908 VARAND(I1
,0,UI1
,0,I4
,0);
5909 VARAND(I1
,-1,I2
,-1,I4
,-1);
5910 VARAND(I1
,-1,I2
,0,I4
,0);
5911 VARAND(I1
,0,I2
,0,I4
,0);
5912 VARAND(I1
,-1,UI2
,65535,I4
,65535);
5913 VARAND(I1
,-1,UI2
,0,I4
,0);
5914 VARAND(I1
,0,UI2
,0,I4
,0);
5915 VARAND(I1
,-1,I4
,-1,I4
,-1);
5916 VARAND(I1
,-1,I4
,0,I4
,0);
5917 VARAND(I1
,0,I4
,0,I4
,0);
5918 VARAND(I1
,-1,UI4
,0xffffffff,I4
,-1);
5919 VARAND(I1
,-1,UI4
,0,I4
,0);
5920 VARAND(I1
,0,UI4
,0,I4
,0);
5921 VARAND(I1
,-1,R4
,-1,I4
,-1);
5922 VARAND(I1
,-1,R4
,0,I4
,0);
5923 VARAND(I1
,0,R4
,0,I4
,0);
5924 VARAND(I1
,-1,R8
,-1,I4
,-1);
5925 VARAND(I1
,-1,R8
,0,I4
,0);
5926 VARAND(I1
,0,R8
,0,I4
,0);
5927 VARAND(I1
,-1,DATE
,-1,I4
,-1);
5928 VARAND(I1
,-1,DATE
,0,I4
,0);
5929 VARAND(I1
,0,DATE
,0,I4
,0);
5930 if (HAVE_OLEAUT32_I8
)
5932 VARAND(I1
,-1,I8
,-1,I8
,-1);
5933 VARAND(I1
,-1,I8
,0,I8
,0);
5934 VARAND(I1
,0,I8
,0,I8
,0);
5935 VARAND(I1
,-1,UI8
,0,I4
,0);
5936 VARAND(I1
,0,UI8
,0,I4
,0);
5938 VARAND(I1
,-1,INT
,-1,I4
,-1);
5939 VARAND(I1
,-1,INT
,0,I4
,0);
5940 VARAND(I1
,0,INT
,0,I4
,0);
5941 VARAND(I1
,-1,UINT
,0xffffffff,I4
,-1);
5942 VARAND(I1
,-1,UINT
,0,I4
,0);
5943 VARAND(I1
,0,UINT
,0,I4
,0);
5944 VARAND(I1
,0,BSTR
,false_str
,I4
,0);
5945 VARAND(I1
,-1,BSTR
,false_str
,I4
,0);
5946 VARAND(I1
,0,BSTR
,true_str
,I4
,0);
5947 VARAND(I1
,-1,BSTR
,true_str
,I4
,-1);
5948 VARANDCY(I1
,-1,10000,I4
,1);
5949 VARANDCY(I1
,-1,0,I4
,0);
5950 VARANDCY(I1
,0,0,I4
,0);
5952 VARAND(UI1
,255,UI1
,255,UI1
,255);
5953 VARAND(UI1
,255,UI1
,0,UI1
,0);
5954 VARAND(UI1
,0,UI1
,0,UI1
,0);
5955 VARAND(UI1
,255,I2
,-1,I2
,255);
5956 VARAND(UI1
,255,I2
,0,I2
,0);
5957 VARAND(UI1
,0,I2
,0,I2
,0);
5958 VARAND(UI1
,255,UI2
,65535,I4
,255);
5959 VARAND(UI1
,255,UI2
,0,I4
,0);
5960 VARAND(UI1
,0,UI2
,0,I4
,0);
5961 VARAND(UI1
,255,I4
,-1,I4
,255);
5962 VARAND(UI1
,255,I4
,0,I4
,0);
5963 VARAND(UI1
,0,I4
,0,I4
,0);
5964 VARAND(UI1
,255,UI4
,0xffffffff,I4
,255);
5965 VARAND(UI1
,255,UI4
,0,I4
,0);
5966 VARAND(UI1
,0,UI4
,0,I4
,0);
5967 VARAND(UI1
,255,R4
,-1,I4
,255);
5968 VARAND(UI1
,255,R4
,0,I4
,0);
5969 VARAND(UI1
,0,R4
,0,I4
,0);
5970 VARAND(UI1
,255,R8
,-1,I4
,255);
5971 VARAND(UI1
,255,R8
,0,I4
,0);
5972 VARAND(UI1
,0,R8
,0,I4
,0);
5973 VARAND(UI1
,255,DATE
,-1,I4
,255);
5974 VARAND(UI1
,255,DATE
,0,I4
,0);
5975 VARAND(UI1
,0,DATE
,0,I4
,0);
5976 if (HAVE_OLEAUT32_I8
)
5978 VARAND(UI1
,255,I8
,-1,I8
,255);
5979 VARAND(UI1
,255,I8
,0,I8
,0);
5980 VARAND(UI1
,0,I8
,0,I8
,0);
5981 VARAND(UI1
,255,UI8
,0,I4
,0);
5982 VARAND(UI1
,0,UI8
,0,I4
,0);
5984 VARAND(UI1
,255,INT
,-1,I4
,255);
5985 VARAND(UI1
,255,INT
,0,I4
,0);
5986 VARAND(UI1
,0,INT
,0,I4
,0);
5987 VARAND(UI1
,255,UINT
,0xffffffff,I4
,255);
5988 VARAND(UI1
,255,UINT
,0,I4
,0);
5989 VARAND(UI1
,0,UINT
,0,I4
,0);
5990 VARAND(UI1
,0,BSTR
,false_str
,I2
,0);
5991 VARAND(UI1
,255,BSTR
,false_str
,I2
,0);
5992 VARAND(UI1
,0,BSTR
,true_str
,I2
,0);
5993 VARAND(UI1
,255,BSTR
,true_str
,I2
,255);
5994 VARANDCY(UI1
,255,10000,I4
,1);
5995 VARANDCY(UI1
,255,0,I4
,0);
5996 VARANDCY(UI1
,0,0,I4
,0);
5998 VARAND(I2
,-1,I2
,-1,I2
,-1);
5999 VARAND(I2
,-1,I2
,0,I2
,0);
6000 VARAND(I2
,0,I2
,0,I2
,0);
6001 VARAND(I2
,-1,UI2
,65535,I4
,65535);
6002 VARAND(I2
,-1,UI2
,0,I4
,0);
6003 VARAND(I2
,0,UI2
,0,I4
,0);
6004 VARAND(I2
,-1,I4
,-1,I4
,-1);
6005 VARAND(I2
,-1,I4
,0,I4
,0);
6006 VARAND(I2
,0,I4
,0,I4
,0);
6007 VARAND(I2
,-1,UI4
,0xffffffff,I4
,-1);
6008 VARAND(I2
,-1,UI4
,0,I4
,0);
6009 VARAND(I2
,0,UI4
,0,I4
,0);
6010 VARAND(I2
,-1,R4
,-1,I4
,-1);
6011 VARAND(I2
,-1,R4
,0,I4
,0);
6012 VARAND(I2
,0,R4
,0,I4
,0);
6013 VARAND(I2
,-1,R8
,-1,I4
,-1);
6014 VARAND(I2
,-1,R8
,0,I4
,0);
6015 VARAND(I2
,0,R8
,0,I4
,0);
6016 VARAND(I2
,-1,DATE
,-1,I4
,-1);
6017 VARAND(I2
,-1,DATE
,0,I4
,0);
6018 VARAND(I2
,0,DATE
,0,I4
,0);
6019 if (HAVE_OLEAUT32_I8
)
6021 VARAND(I2
,-1,I8
,-1,I8
,-1);
6022 VARAND(I2
,-1,I8
,0,I8
,0);
6023 VARAND(I2
,0,I8
,0,I8
,0);
6024 VARAND(I2
,-1,UI8
,0,I4
,0);
6025 VARAND(I2
,0,UI8
,0,I4
,0);
6027 VARAND(I2
,-1,INT
,-1,I4
,-1);
6028 VARAND(I2
,-1,INT
,0,I4
,0);
6029 VARAND(I2
,0,INT
,0,I4
,0);
6030 VARAND(I2
,-1,UINT
,0xffffffff,I4
,-1);
6031 VARAND(I2
,-1,UINT
,0,I4
,0);
6032 VARAND(I2
,0,UINT
,0,I4
,0);
6033 VARAND(I2
,0,BSTR
,false_str
,I2
,0);
6034 VARAND(I2
,-1,BSTR
,false_str
,I2
,0);
6035 VARAND(I2
,0,BSTR
,true_str
,I2
,0);
6036 VARAND(I2
,-1,BSTR
,true_str
,I2
,-1);
6037 VARANDCY(I2
,-1,10000,I4
,1);
6038 VARANDCY(I2
,-1,0,I4
,0);
6039 VARANDCY(I2
,0,0,I4
,0);
6041 VARAND(UI2
,65535,UI2
,65535,I4
,65535);
6042 VARAND(UI2
,65535,UI2
,0,I4
,0);
6043 VARAND(UI2
,0,UI2
,0,I4
,0);
6044 VARAND(UI2
,65535,I4
,-1,I4
,65535);
6045 VARAND(UI2
,65535,I4
,0,I4
,0);
6046 VARAND(UI2
,0,I4
,0,I4
,0);
6047 VARAND(UI2
,65535,UI4
,0xffffffff,I4
,65535);
6048 VARAND(UI2
,65535,UI4
,0,I4
,0);
6049 VARAND(UI2
,0,UI4
,0,I4
,0);
6050 VARAND(UI2
,65535,R4
,-1,I4
,65535);
6051 VARAND(UI2
,65535,R4
,0,I4
,0);
6052 VARAND(UI2
,0,R4
,0,I4
,0);
6053 VARAND(UI2
,65535,R8
,-1,I4
,65535);
6054 VARAND(UI2
,65535,R8
,0,I4
,0);
6055 VARAND(UI2
,0,R8
,0,I4
,0);
6056 VARAND(UI2
,65535,DATE
,-1,I4
,65535);
6057 VARAND(UI2
,65535,DATE
,0,I4
,0);
6058 VARAND(UI2
,0,DATE
,0,I4
,0);
6059 if (HAVE_OLEAUT32_I8
)
6061 VARAND(UI2
,65535,I8
,-1,I8
,65535);
6062 VARAND(UI2
,65535,I8
,0,I8
,0);
6063 VARAND(UI2
,0,I8
,0,I8
,0);
6064 VARAND(UI2
,65535,UI8
,0,I4
,0);
6065 VARAND(UI2
,0,UI8
,0,I4
,0);
6067 VARAND(UI2
,65535,INT
,-1,I4
,65535);
6068 VARAND(UI2
,65535,INT
,0,I4
,0);
6069 VARAND(UI2
,0,INT
,0,I4
,0);
6070 VARAND(UI2
,65535,UINT
,0xffffffff,I4
,65535);
6071 VARAND(UI2
,65535,UINT
,0,I4
,0);
6072 VARAND(UI2
,0,UINT
,0,I4
,0);
6073 VARAND(UI2
,0,BSTR
,false_str
,I4
,0);
6074 VARAND(UI2
,65535,BSTR
,false_str
,I4
,0);
6075 VARAND(UI2
,0,BSTR
,true_str
,I4
,0);
6076 VARAND(UI2
,65535,BSTR
,true_str
,I4
,65535);
6077 VARANDCY(UI2
,65535,10000,I4
,1);
6078 VARANDCY(UI2
,65535,0,I4
,0);
6079 VARANDCY(UI2
,0,0,I4
,0);
6081 VARAND(I4
,-1,I4
,-1,I4
,-1);
6082 VARAND(I4
,-1,I4
,0,I4
,0);
6083 VARAND(I4
,0,I4
,0,I4
,0);
6084 VARAND(I4
,-1,UI4
,0xffffffff,I4
,-1);
6085 VARAND(I4
,-1,UI4
,0,I4
,0);
6086 VARAND(I4
,0,UI4
,0,I4
,0);
6087 VARAND(I4
,-1,R4
,-1,I4
,-1);
6088 VARAND(I4
,-1,R4
,0,I4
,0);
6089 VARAND(I4
,0,R4
,0,I4
,0);
6090 VARAND(I4
,-1,R8
,-1,I4
,-1);
6091 VARAND(I4
,-1,R8
,0,I4
,0);
6092 VARAND(I4
,0,R8
,0,I4
,0);
6093 VARAND(I4
,-1,DATE
,-1,I4
,-1);
6094 VARAND(I4
,-1,DATE
,0,I4
,0);
6095 VARAND(I4
,0,DATE
,0,I4
,0);
6096 if (HAVE_OLEAUT32_I8
)
6098 VARAND(I4
,-1,I8
,-1,I8
,-1);
6099 VARAND(I4
,-1,I8
,0,I8
,0);
6100 VARAND(I4
,0,I8
,0,I8
,0);
6101 VARAND(I4
,-1,UI8
,0,I4
,0);
6102 VARAND(I4
,0,UI8
,0,I4
,0);
6104 VARAND(I4
,-1,INT
,-1,I4
,-1);
6105 VARAND(I4
,-1,INT
,0,I4
,0);
6106 VARAND(I4
,0,INT
,0,I4
,0);
6107 VARAND(I4
,-1,UINT
,0xffffffff,I4
,-1);
6108 VARAND(I4
,-1,UINT
,0,I4
,0);
6109 VARAND(I4
,0,UINT
,0,I4
,0);
6110 VARAND(I4
,0,BSTR
,false_str
,I4
,0);
6111 VARAND(I4
,-1,BSTR
,false_str
,I4
,0);
6112 VARAND(I4
,0,BSTR
,true_str
,I4
,0);
6113 VARAND(I4
,-1,BSTR
,true_str
,I4
,-1);
6114 VARANDCY(I4
,-1,10000,I4
,1);
6115 VARANDCY(I4
,-1,0,I4
,0);
6116 VARANDCY(I4
,0,0,I4
,0);
6118 VARAND(UI4
,0xffffffff,UI4
,0xffffffff,I4
,-1);
6119 VARAND(UI4
,0xffffffff,UI4
,0,I4
,0);
6120 VARAND(UI4
,0,UI4
,0,I4
,0);
6121 VARAND(UI4
,0xffffffff,R4
,-1,I4
,-1);
6122 VARAND(UI4
,0xffffffff,R4
,0,I4
,0);
6123 VARAND(UI4
,0,R4
,0,I4
,0);
6124 VARAND(UI4
,0xffffffff,R8
,-1,I4
,-1);
6125 VARAND(UI4
,0xffffffff,R8
,0,I4
,0);
6126 VARAND(UI4
,0,R8
,0,I4
,0);
6127 VARAND(UI4
,0xffffffff,DATE
,-1,I4
,-1);
6128 VARAND(UI4
,0xffffffff,DATE
,0,I4
,0);
6129 VARAND(UI4
,0,DATE
,0,I4
,0);
6130 if (HAVE_OLEAUT32_I8
)
6132 VARAND(UI4
,0xffffffff,I8
,0,I8
,0);
6133 VARAND(UI4
,0,I8
,0,I8
,0);
6134 VARAND(UI4
,0xffffffff,UI8
,0,I4
,0);
6135 VARAND(UI4
,0,UI8
,0,I4
,0);
6137 VARAND(UI4
,0xffffffff,INT
,-1,I4
,-1);
6138 VARAND(UI4
,0xffffffff,INT
,0,I4
,0);
6139 VARAND(UI4
,0,INT
,0,I4
,0);
6140 VARAND(UI4
,0xffffffff,UINT
,0xffffffff,I4
,-1);
6141 VARAND(UI4
,0xffffffff,UINT
,0,I4
,0);
6142 VARAND(UI4
,0,UINT
,0,I4
,0);
6143 VARAND(UI4
,0,BSTR
,false_str
,I4
,0);
6144 VARAND(UI4
,0xffffffff,BSTR
,false_str
,I4
,0);
6145 VARAND(UI4
,0,BSTR
,true_str
,I4
,0);
6146 VARAND(UI4
,0xffffffff,BSTR
,true_str
,I4
,-1);
6147 VARANDCY(UI4
,0xffffffff,10000,I4
,1);
6148 VARANDCY(UI4
,0xffffffff,0,I4
,0);
6149 VARANDCY(UI4
,0,0,I4
,0);
6151 VARAND(R4
,-1,R4
,-1,I4
,-1);
6152 VARAND(R4
,-1,R4
,0,I4
,0);
6153 VARAND(R4
,0,R4
,0,I4
,0);
6154 VARAND(R4
,-1,R8
,-1,I4
,-1);
6155 VARAND(R4
,-1,R8
,0,I4
,0);
6156 VARAND(R4
,0,R8
,0,I4
,0);
6157 VARAND(R4
,-1,DATE
,-1,I4
,-1);
6158 VARAND(R4
,-1,DATE
,0,I4
,0);
6159 VARAND(R4
,0,DATE
,0,I4
,0);
6160 if (HAVE_OLEAUT32_I8
)
6162 VARAND(R4
,-1,I8
,-1,I8
,-1);
6163 VARAND(R4
,-1,I8
,0,I8
,0);
6164 VARAND(R4
,0,I8
,0,I8
,0);
6165 VARAND(R4
,-1,UI8
,0,I4
,0);
6166 VARAND(R4
,0,UI8
,0,I4
,0);
6168 VARAND(R4
,-1,INT
,-1,I4
,-1);
6169 VARAND(R4
,-1,INT
,0,I4
,0);
6170 VARAND(R4
,0,INT
,0,I4
,0);
6171 VARAND(R4
,-1,UINT
,0xffffffff,I4
,-1);
6172 VARAND(R4
,-1,UINT
,0,I4
,0);
6173 VARAND(R4
,0,UINT
,0,I4
,0);
6174 VARAND(R4
,0,BSTR
,false_str
,I4
,0);
6175 VARAND(R4
,-1,BSTR
,false_str
,I4
,0);
6176 VARAND(R4
,0,BSTR
,true_str
,I4
,0);
6177 VARAND(R4
,-1,BSTR
,true_str
,I4
,-1);
6178 VARANDCY(R4
,-1,10000,I4
,1);
6179 VARANDCY(R4
,-1,0,I4
,0);
6180 VARANDCY(R4
,0,0,I4
,0);
6182 VARAND(R8
,-1,R8
,-1,I4
,-1);
6183 VARAND(R8
,-1,R8
,0,I4
,0);
6184 VARAND(R8
,0,R8
,0,I4
,0);
6185 VARAND(R8
,-1,DATE
,-1,I4
,-1);
6186 VARAND(R8
,-1,DATE
,0,I4
,0);
6187 VARAND(R8
,0,DATE
,0,I4
,0);
6188 if (HAVE_OLEAUT32_I8
)
6190 VARAND(R8
,-1,I8
,-1,I8
,-1);
6191 VARAND(R8
,-1,I8
,0,I8
,0);
6192 VARAND(R8
,0,I8
,0,I8
,0);
6193 VARAND(R8
,-1,UI8
,0,I4
,0);
6194 VARAND(R8
,0,UI8
,0,I4
,0);
6196 VARAND(R8
,-1,INT
,-1,I4
,-1);
6197 VARAND(R8
,-1,INT
,0,I4
,0);
6198 VARAND(R8
,0,INT
,0,I4
,0);
6199 VARAND(R8
,-1,UINT
,0xffffffff,I4
,-1);
6200 VARAND(R8
,-1,UINT
,0,I4
,0);
6201 VARAND(R8
,0,UINT
,0,I4
,0);
6202 VARAND(R8
,0,BSTR
,false_str
,I4
,0);
6203 VARAND(R8
,-1,BSTR
,false_str
,I4
,0);
6204 VARAND(R8
,0,BSTR
,true_str
,I4
,0);
6205 VARAND(R8
,-1,BSTR
,true_str
,I4
,-1);
6206 VARANDCY(R8
,-1,10000,I4
,1);
6207 VARANDCY(R8
,-1,0,I4
,0);
6208 VARANDCY(R8
,0,0,I4
,0);
6210 VARAND(DATE
,-1,DATE
,-1,I4
,-1);
6211 VARAND(DATE
,-1,DATE
,0,I4
,0);
6212 VARAND(DATE
,0,DATE
,0,I4
,0);
6213 if (HAVE_OLEAUT32_I8
)
6215 VARAND(DATE
,-1,I8
,-1,I8
,-1);
6216 VARAND(DATE
,-1,I8
,0,I8
,0);
6217 VARAND(DATE
,0,I8
,0,I8
,0);
6218 VARAND(DATE
,-1,UI8
,0,I4
,0);
6219 VARAND(DATE
,0,UI8
,0,I4
,0);
6221 VARAND(DATE
,-1,INT
,-1,I4
,-1);
6222 VARAND(DATE
,-1,INT
,0,I4
,0);
6223 VARAND(DATE
,0,INT
,0,I4
,0);
6224 VARAND(DATE
,-1,UINT
,0xffffffff,I4
,-1);
6225 VARAND(DATE
,-1,UINT
,0,I4
,0);
6226 VARAND(DATE
,0,UINT
,0,I4
,0);
6227 VARAND(DATE
,0,BSTR
,false_str
,I4
,0);
6228 VARAND(DATE
,-1,BSTR
,false_str
,I4
,0);
6229 VARAND(DATE
,0,BSTR
,true_str
,I4
,0);
6230 VARAND(DATE
,-1,BSTR
,true_str
,I4
,-1);
6231 VARANDCY(DATE
,-1,10000,I4
,1);
6232 VARANDCY(DATE
,-1,0,I4
,0);
6233 VARANDCY(DATE
,0,0,I4
,0);
6235 if (HAVE_OLEAUT32_I8
)
6237 VARAND(I8
,-1,I8
,-1,I8
,-1);
6238 VARAND(I8
,-1,I8
,0,I8
,0);
6239 VARAND(I8
,0,I8
,0,I8
,0);
6240 VARAND(I8
,-1,UI8
,0,I8
,0);
6241 VARAND(I8
,0,UI8
,0,I8
,0);
6242 VARAND(I8
,-1,UINT
,0,I8
,0);
6243 VARAND(I8
,0,UINT
,0,I8
,0);
6244 VARAND(I8
,0,BSTR
,false_str
,I8
,0);
6245 VARAND(I8
,-1,BSTR
,false_str
,I8
,0);
6246 VARAND(I8
,0,BSTR
,true_str
,I8
,0);
6247 VARAND(I8
,-1,BSTR
,true_str
,I8
,-1);
6248 VARANDCY(I8
,-1,10000,I8
,1);
6249 VARANDCY(I8
,-1,0,I8
,0);
6250 VARANDCY(I8
,0,0,I8
,0);
6252 VARAND(UI8
,0xffff,UI8
,0xffff,I4
,0xffff);
6253 VARAND(UI8
,0xffff,UI8
,0,I4
,0);
6254 VARAND(UI8
,0,UI8
,0,I4
,0);
6255 VARAND(UI8
,0xffff,INT
,-1,I4
,65535);
6256 VARAND(UI8
,0xffff,INT
,0,I4
,0);
6257 VARAND(UI8
,0,INT
,0,I4
,0);
6258 VARAND(UI8
,0xffff,UINT
,0xffff,I4
,0xffff);
6259 VARAND(UI8
,0xffff,UINT
,0,I4
,0);
6260 VARAND(UI8
,0,UINT
,0,I4
,0);
6261 VARAND(UI8
,0,BSTR
,false_str
,I4
,0);
6262 VARAND(UI8
,0xffff,BSTR
,false_str
,I4
,0);
6263 VARAND(UI8
,0,BSTR
,true_str
,I4
,0);
6264 VARAND(UI8
,0xffff,BSTR
,true_str
,I4
,65535);
6265 VARANDCY(UI8
,0xffff,10000,I4
,1);
6266 VARANDCY(UI8
,0xffff,0,I4
,0);
6267 VARANDCY(UI8
,0,0,I4
,0);
6270 VARAND(INT
,-1,INT
,-1,I4
,-1);
6271 VARAND(INT
,-1,INT
,0,I4
,0);
6272 VARAND(INT
,0,INT
,0,I4
,0);
6273 VARAND(INT
,-1,UINT
,0xffff,I4
,65535);
6274 VARAND(INT
,-1,UINT
,0,I4
,0);
6275 VARAND(INT
,0,UINT
,0,I4
,0);
6276 VARAND(INT
,0,BSTR
,false_str
,I4
,0);
6277 VARAND(INT
,-1,BSTR
,false_str
,I4
,0);
6278 VARAND(INT
,0,BSTR
,true_str
,I4
,0);
6279 VARAND(INT
,-1,BSTR
,true_str
,I4
,-1);
6280 VARANDCY(INT
,-1,10000,I4
,1);
6281 VARANDCY(INT
,-1,0,I4
,0);
6282 VARANDCY(INT
,0,0,I4
,0);
6284 VARAND(UINT
,0xffff,UINT
,0xffff,I4
,0xffff);
6285 VARAND(UINT
,0xffff,UINT
,0,I4
,0);
6286 VARAND(UINT
,0,UINT
,0,I4
,0);
6287 VARAND(UINT
,0,BSTR
,false_str
,I4
,0);
6288 VARAND(UINT
,0xffff,BSTR
, false_str
,I4
,0);
6289 VARAND(UINT
,0,BSTR
,true_str
,I4
,0);
6290 VARAND(UINT
,0xffff,BSTR
,true_str
,I4
,65535);
6291 VARANDCY(UINT
,0xffff,10000,I4
,1);
6292 VARANDCY(UINT
,0xffff,0,I4
,0);
6293 VARANDCY(UINT
,0,0,I4
,0);
6295 VARAND(BSTR
,false_str
,BSTR
,false_str
,BOOL
,0);
6296 VARAND(BSTR
,true_str
,BSTR
,false_str
,BOOL
,VARIANT_FALSE
);
6297 VARAND(BSTR
,true_str
,BSTR
,true_str
,BOOL
,VARIANT_TRUE
);
6298 VARANDCY(BSTR
,true_str
,10000,I4
,1);
6299 VARANDCY(BSTR
,false_str
,10000,I4
,0);
6301 SysFreeString(true_str
);
6302 SysFreeString(false_str
);
6305 static HRESULT (WINAPI
*pVarCmp
)(LPVARIANT
,LPVARIANT
,LCID
,ULONG
);
6307 static void test_cmp( int line
, LCID lcid
, UINT flags
, VARIANT
*left
, VARIANT
*right
, HRESULT result
)
6311 hres
= pVarCmp(left
,right
,lcid
,flags
);
6312 ok_(__FILE__
,line
)(hres
== result
, "VarCmp(%s,%s): expected 0x%x, got hres=0x%x\n",
6313 variantstr(left
), variantstr(right
), result
, hres
);
6315 static void test_cmpex( int line
, LCID lcid
, VARIANT
*left
, VARIANT
*right
,
6316 HRESULT res1
, HRESULT res2
, HRESULT res3
, HRESULT res4
)
6318 test_cmp( line
, lcid
, 0, left
, right
, res1
);
6319 V_VT(left
) |= VT_RESERVED
;
6320 test_cmp( line
, lcid
, 0, left
, right
, res2
);
6321 V_VT(left
) &= ~VT_RESERVED
;
6322 V_VT(right
) |= VT_RESERVED
;
6323 test_cmp( line
, lcid
, 0, left
, right
, res3
);
6324 V_VT(left
) |= VT_RESERVED
;
6325 test_cmp( line
, lcid
, 0, left
, right
, res4
);
6326 ok_(__FILE__
,line
)(V_VT(left
) & V_VT(right
) & VT_RESERVED
, "VT_RESERVED filtered out\n");
6329 /* ERROR from wingdi.h is interfering here */
6331 #define _VARCMP(vt1,val1,vtfl1,vt2,val2,vtfl2,lcid,flags,result) \
6332 V_##vt1(&left) = val1; V_VT(&left) = VT_##vt1 | vtfl1; \
6333 V_##vt2(&right) = val2; V_VT(&right) = VT_##vt2 | vtfl2; \
6334 test_cmp( __LINE__, lcid, flags, &left, &right, result )
6335 #define VARCMPEX(vt1,val1,vt2,val2,res1,res2,res3,res4) \
6336 V_##vt1(&left) = val1; V_VT(&left) = VT_##vt1; \
6337 V_##vt2(&right) = val2; V_VT(&right) = VT_##vt2; \
6338 test_cmpex( __LINE__, lcid, &left, &right, res1, res2, res3, res4 )
6339 #define VARCMP(vt1,val1,vt2,val2,result) \
6340 VARCMPEX(vt1,val1,vt2,val2,result,result,result,result)
6341 /* The above macros do not work for VT_NULL as NULL gets expanded first */
6342 #define V_NULL_ V_NULL
6343 #define VT_NULL_ VT_NULL
6345 static void test_VarCmp(void)
6347 VARIANT left
, right
;
6352 static const WCHAR szhuh
[] = {'h','u','h','?','\0'};
6353 static const WCHAR sz2cents
[] = {'2','c','e','n','t','s','\0'};
6354 static const WCHAR szempty
[] = {'\0'};
6355 static const WCHAR sz0
[] = {'0','\0'};
6356 static const WCHAR sz1
[] = {'1','\0'};
6357 static const WCHAR sz7
[] = {'7','\0'};
6358 static const WCHAR sz42
[] = {'4','2','\0'};
6359 static const WCHAR sz1neg
[] = {'-','1','\0'};
6360 static const WCHAR sz666neg
[] = {'-','6','6','6','\0'};
6361 static const WCHAR sz1few
[] = {'1','.','0','0','0','0','0','0','0','1','\0'};
6362 BSTR bstrhuh
, bstrempty
, bstr0
, bstr1
, bstr7
, bstr42
, bstr1neg
, bstr666neg
;
6363 BSTR bstr2cents
, bstr1few
;
6367 lcid
= MAKELCID(MAKELANGID(LANG_ENGLISH
,SUBLANG_ENGLISH_US
),SORT_DEFAULT
);
6368 bstrempty
= SysAllocString(szempty
);
6369 bstrhuh
= SysAllocString(szhuh
);
6370 bstr2cents
= SysAllocString(sz2cents
);
6371 bstr0
= SysAllocString(sz0
);
6372 bstr1
= SysAllocString(sz1
);
6373 bstr7
= SysAllocString(sz7
);
6374 bstr42
= SysAllocString(sz42
);
6375 bstr1neg
= SysAllocString(sz1neg
);
6376 bstr666neg
= SysAllocString(sz666neg
);
6377 bstr1few
= SysAllocString(sz1few
);
6379 /* Test all possible flag/vt combinations & the resulting vt type */
6380 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
6382 VARTYPE leftvt
, rightvt
;
6384 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
6389 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
6392 HRESULT expect
= VARCMP_EQ
;
6396 memset(&left
, 0, sizeof(left
));
6397 memset(&right
, 0, sizeof(right
));
6398 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
6399 if (leftvt
== VT_BSTR
) {
6400 V_BSTR(&left
) = bstr1neg
;
6401 if (ExtraFlags
[i
] & VT_RESERVED
)
6406 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
6407 if (rightvt
== VT_BSTR
) {
6408 V_BSTR(&right
) = bstr1neg
;
6409 if (ExtraFlags
[i
] & VT_RESERVED
)
6415 /* Don't ask me why but native VarCmp cannot handle:
6416 VT_I1, VT_UI2, VT_UI4, VT_UINT and VT_UI8.
6417 VT_INT is only supported as left variant. Go figure.
6418 Tested with DCOM98, Win2k, WinXP */
6419 if (ExtraFlags
[i
] & VT_ARRAY
|| ExtraFlags
[i
] & VT_BYREF
||
6420 !IsValidVariantClearVT(leftvt
, ExtraFlags
[i
] & ~VT_RESERVED
) ||
6421 !IsValidVariantClearVT(rightvt
, ExtraFlags
[i
] & ~VT_RESERVED
) ||
6422 leftvt
== VT_CLSID
|| rightvt
== VT_CLSID
||
6423 leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
||
6424 leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
||
6425 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
||
6426 leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
||
6427 leftvt
== VT_VARIANT
|| rightvt
== VT_VARIANT
||
6428 leftvt
== VT_I1
|| rightvt
== VT_I1
||
6429 leftvt
== VT_UI2
|| rightvt
== VT_UI2
||
6430 leftvt
== VT_UI4
|| rightvt
== VT_UI4
||
6431 leftvt
== VT_UI8
|| rightvt
== VT_UI8
||
6432 rightvt
== VT_INT
||
6433 leftvt
== VT_UINT
|| rightvt
== VT_UINT
) {
6437 if (leftvt
== VT_ERROR
&& rightvt
== VT_ERROR
&&
6438 !(ExtraFlags
[i
] & ~VT_RESERVED
)) {
6441 } else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
6442 expect
= VARCMP_NULL
;
6443 else if (leftvt
== VT_BSTR
&& rightvt
== VT_BSTR
)
6445 else if (leftvt
== VT_BSTR
&& rightvt
== VT_EMPTY
)
6447 else if (leftvt
== VT_EMPTY
&& rightvt
== VT_BSTR
)
6450 hres
= pVarCmp(&left
, &right
, LOCALE_USER_DEFAULT
, 0);
6452 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
6453 "VarCmp: %d|0x%X, %d|0x%X: Expected failure, got 0x%X\n",
6454 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], hres
);
6457 "VarCmp: %d|0x%X, %d|0x%X: Expected 0x%X, got 0x%X\n",
6458 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], expect
,
6465 /* VARCMP{,EX} run each 4 tests with a permutation of all possible
6466 input variants with (1) and without (0) VT_RESERVED set. The order
6467 of the permutations is (0,0); (1,0); (0,1); (1,1) */
6468 VARCMP(INT
,4711,I2
,4711,VARCMP_EQ
);
6469 VARCMP(INT
,4711,I2
,-4711,VARCMP_GT
);
6470 VARCMP(ERROR
,0,ERROR
,0,VARCMP_EQ
);
6471 VARCMP(ERROR
,0,UI1
,0,DISP_E_TYPEMISMATCH
);
6472 VARCMP(EMPTY
,0,EMPTY
,0,VARCMP_EQ
);
6473 VARCMP(I4
,1,R8
,1.0,VARCMP_EQ
);
6474 VARCMP(EMPTY
,19,I2
,0,VARCMP_EQ
);
6475 ok(V_EMPTY(&left
) == 19, "VT_EMPTY modified!\n");
6476 VARCMP(I4
,1,UI1
,1,VARCMP_EQ
);
6477 VARCMP(I2
,2,I2
,2,VARCMP_EQ
);
6478 VARCMP(I2
,1,I2
,2,VARCMP_LT
);
6479 VARCMP(I2
,2,I2
,1,VARCMP_GT
);
6480 VARCMP(I2
,2,EMPTY
,1,VARCMP_GT
);
6481 VARCMP(I2
,2,NULL_
,1,VARCMP_NULL
);
6483 /* BSTR handling, especially in conjunction with VT_RESERVED */
6484 VARCMP(BSTR
,bstr0
,NULL_
,0,VARCMP_NULL
);
6485 VARCMP(BSTR
,bstr0
,BSTR
,bstr0
,VARCMP_EQ
);
6486 VARCMP(BSTR
,bstrempty
,BSTR
,bstr0
,VARCMP_LT
);
6487 VARCMP(BSTR
,bstr7
,BSTR
,bstr0
,VARCMP_GT
);
6488 VARCMP(BSTR
,bstr7
,BSTR
,bstr1neg
,VARCMP_GT
);
6489 VARCMP(BSTR
,bstr0
,BSTR
,NULL
,VARCMP_GT
);
6490 VARCMP(BSTR
,NULL
,BSTR
,NULL
,VARCMP_EQ
);
6491 VARCMP(BSTR
,bstrempty
,BSTR
,NULL
,VARCMP_EQ
);
6492 VARCMP(BSTR
,NULL
,EMPTY
,0,VARCMP_EQ
);
6493 VARCMP(EMPTY
,0,BSTR
,NULL
,VARCMP_EQ
);
6494 VARCMP(EMPTY
,0,BSTR
,bstrempty
,VARCMP_EQ
);
6495 VARCMP(EMPTY
,1,BSTR
,bstrempty
,VARCMP_EQ
);
6496 VARCMP(BSTR
,bstr0
,EMPTY
,0,VARCMP_GT
);
6497 VARCMP(BSTR
,bstr42
,EMPTY
,0,VARCMP_GT
);
6498 VARCMPEX(BSTR
,bstrempty
,UI1
,0,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
6499 VARCMPEX(BSTR
,bstrempty
,I2
,-1,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
6500 VARCMPEX(I4
,0,BSTR
,bstrempty
,VARCMP_LT
,VARCMP_LT
,VARCMP_GT
,VARCMP_LT
);
6501 VARCMPEX(BSTR
,NULL
,UI1
,0,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
6502 VARCMPEX(I4
,7,BSTR
,NULL
,VARCMP_LT
,VARCMP_LT
,VARCMP_GT
,VARCMP_LT
);
6503 _VARCMP(BSTR
,(BSTR
)100,0,I2
,100,0,lcid
,0,VARCMP_GT
);
6504 VARCMPEX(BSTR
,bstr0
,UI1
,0,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_GT
);
6505 VARCMPEX(I2
,0,BSTR
,bstr0
,VARCMP_LT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_LT
);
6506 VARCMP(BSTR
,bstrhuh
,I4
,I4_MAX
,VARCMP_GT
);
6507 VARCMP(BSTR
,bstr2cents
,I4
,2,VARCMP_GT
);
6508 VARCMPEX(BSTR
,bstr2cents
,I4
,42,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
6509 VARCMP(BSTR
,bstr2cents
,I4
,-1,VARCMP_GT
);
6510 VARCMPEX(BSTR
,bstr2cents
,I4
,-666,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
6511 VARCMPEX(BSTR
,bstr0
,I2
,0,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_GT
);
6512 VARCMPEX(BSTR
,bstr0
,I4
,0,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_GT
);
6513 VARCMPEX(BSTR
,bstr0
,I4
,-666,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
6514 VARCMP(BSTR
,bstr1
,I4
,0,VARCMP_GT
);
6515 VARCMPEX(BSTR
,bstr1
,I4
,1,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_GT
);
6516 VARCMPEX(BSTR
,bstr1
,I4
,I4_MAX
,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
,VARCMP_GT
);
6517 VARCMPEX(BSTR
,bstr1
,I4
,-1,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
6518 VARCMP(BSTR
,bstr7
,I4
,1,VARCMP_GT
);
6519 VARCMPEX(BSTR
,bstr7
,I4
,7,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_GT
);
6520 VARCMPEX(BSTR
,bstr7
,I4
,42,VARCMP_GT
,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
);
6521 VARCMPEX(BSTR
,bstr42
,I4
,7,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
6522 VARCMPEX(BSTR
,bstr42
,I4
,42,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_GT
);
6523 VARCMPEX(BSTR
,bstr42
,I4
,I4_MAX
,VARCMP_GT
,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
);
6524 VARCMPEX(BSTR
,bstr1neg
,I4
,1,VARCMP_GT
,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
);
6525 VARCMPEX(BSTR
,bstr1neg
,I4
,42,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
,VARCMP_LT
);
6526 VARCMPEX(BSTR
,bstr1neg
,I4
,-1,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_LT
);
6527 VARCMPEX(BSTR
,bstr1neg
,I4
,-666,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_LT
);
6528 VARCMPEX(BSTR
,bstr666neg
,I4
,1,VARCMP_GT
,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
);
6529 VARCMPEX(BSTR
,bstr666neg
,I4
,7,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
,VARCMP_LT
);
6530 VARCMPEX(BSTR
,bstr666neg
,I4
,42,VARCMP_GT
,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
);
6531 VARCMPEX(BSTR
,bstr666neg
,I4
,I4_MAX
,VARCMP_GT
,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
);
6532 VARCMPEX(BSTR
,bstr666neg
,I4
,-1,VARCMP_GT
,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
);
6533 VARCMPEX(BSTR
,bstr666neg
,I4
,-666,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_LT
);
6534 VARCMPEX(BSTR
,bstr7
,R8
,7.0,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_GT
);
6535 VARCMPEX(R8
,3.141592,BSTR
,NULL
,VARCMP_LT
,VARCMP_LT
,VARCMP_GT
,VARCMP_LT
);
6536 VARCMP(BSTR
,bstr7
,BSTR
,bstr7
,VARCMP_EQ
);
6537 VARCMP(BSTR
,bstr7
,BSTR
,bstr42
,VARCMP_GT
);
6538 VARCMP(BSTR
,bstr42
,BSTR
,bstr7
,VARCMP_LT
);
6540 /* DECIMAL handling */
6541 setdec(&dec
,0,0,0,0);
6542 VARCMPEX(DECIMAL
,dec
,BSTR
,bstr0
,VARCMP_LT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_LT
);
6543 setdec64(&dec
,0,0,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF); /* max DECIMAL */
6544 VARCMP(DECIMAL
,dec
,R8
,R8_MAX
,VARCMP_LT
); /* R8 has bigger range */
6545 VARCMP(DECIMAL
,dec
,DATE
,R8_MAX
,VARCMP_LT
); /* DATE has bigger range */
6546 setdec64(&dec
,0,0x80,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF);
6547 VARCMP(DECIMAL
,dec
,R8
,-R8_MAX
,VARCMP_GT
);
6548 setdec64(&dec
,20,0,0x5,0x6BC75E2D,0x63100001); /* 1+1e-20 */
6549 VARCMP(DECIMAL
,dec
,R8
,1,VARCMP_GT
); /* DECIMAL has higher precision */
6551 /* Show that DATE is handled just as a R8 */
6552 VARCMP(DATE
,DATE_MAX
,DATE
,DATE_MAX
+1,VARCMP_LT
);
6553 VARCMP(DATE
,DATE_MIN
,DATE
,DATE_MIN
-1,VARCMP_GT
);
6554 VARCMP(DATE
,R8_MIN
,R8
,R8_MIN
,VARCMP_EQ
);
6555 VARCMP(DATE
,1,DATE
,1+1e-15,VARCMP_LT
); /* 1e-15 == 8.64e-11 seconds */
6556 VARCMP(DATE
,25570.0,DATE
,25570.0,VARCMP_EQ
);
6557 VARCMP(DATE
,25570.0,DATE
,25571.0,VARCMP_LT
);
6558 VARCMP(DATE
,25571.0,DATE
,25570.0,VARCMP_GT
);
6559 VARCMP(DATE
,25570.0,EMPTY
,0,VARCMP_GT
);
6560 VARCMP(DATE
,25570.0,NULL_
,0,VARCMP_NULL
);
6562 /* R4 precision handling */
6563 VARCMP(R4
,1,R8
,1+1e-8,VARCMP_EQ
);
6564 VARCMP(R8
,1+1e-8,R4
,1,VARCMP_EQ
);
6565 VARCMP(R8
,1+1e-8,R8
,1,VARCMP_GT
);
6566 VARCMP(R8
,R4_MAX
*1.1,R4
,R4_MAX
,VARCMP_GT
);
6567 VARCMP(R4
,R4_MAX
,R8
,R8_MAX
,VARCMP_LT
);
6568 VARCMP(R4
,1,DATE
,1+1e-8,VARCMP_EQ
);
6569 VARCMP(R4
,1,BSTR
,bstr1few
,VARCMP_LT
); /* bstr1few == 1+1e-8 */
6570 setdec(&dec
,8,0,0,0x5F5E101); /* 1+1e-8 */
6571 VARCMP(R4
,1,DECIMAL
,dec
,VARCMP_LT
);
6573 SysFreeString(bstrhuh
);
6574 SysFreeString(bstrempty
);
6575 SysFreeString(bstr0
);
6576 SysFreeString(bstr1
);
6577 SysFreeString(bstr7
);
6578 SysFreeString(bstr42
);
6579 SysFreeString(bstr1neg
);
6580 SysFreeString(bstr666neg
);
6581 SysFreeString(bstr2cents
);
6582 SysFreeString(bstr1few
);
6585 static HRESULT (WINAPI
*pVarPow
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
6587 #define VARPOW(vt1,val1,vt2,val2,rvt,rval) \
6588 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
6589 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
6590 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
6591 test_var_call2( __LINE__, pVarPow, &left, &right, &exp )
6593 /* Skip any type that is not defined or produces an error for every case */
6594 #define SKIPTESTPOW(a) \
6595 if (a == VT_ERROR || a == VT_VARIANT || \
6596 a == VT_DISPATCH || a == VT_UNKNOWN || \
6597 a == VT_RECORD || a > VT_UINT || \
6598 a == 15 /*not defined*/) \
6601 static void test_VarPow(void)
6603 static const WCHAR str2
[] = { '2','\0' };
6604 static const WCHAR str3
[] = { '3','\0' };
6605 VARIANT left
, right
, exp
, result
, cy
, dec
;
6606 BSTR num2_str
, num3_str
;
6612 num2_str
= SysAllocString(str2
);
6613 num3_str
= SysAllocString(str3
);
6615 /* Test all possible flag/vt combinations & the resulting vt type */
6616 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
6618 VARTYPE leftvt
, rightvt
, resvt
;
6620 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
6622 SKIPTESTPOW(leftvt
);
6624 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
6627 SKIPTESTPOW(rightvt
);
6629 /* Native crashes with VT_BYREF */
6630 if (ExtraFlags
[i
] == VT_BYREF
)
6633 memset(&left
, 0, sizeof(left
));
6634 memset(&right
, 0, sizeof(right
));
6635 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
6636 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
6637 V_VT(&result
) = VT_EMPTY
;
6640 if (leftvt
== VT_BSTR
)
6641 V_BSTR(&left
) = num2_str
;
6642 if (rightvt
== VT_BSTR
)
6643 V_BSTR(&right
) = num2_str
;
6645 /* Native VarPow always returns an error when using extra flags */
6646 if (ExtraFlags
[i
] != 0)
6649 /* Determine return type */
6650 else if ((leftvt
== VT_NULL
|| rightvt
== VT_NULL
) &&
6651 ((leftvt
!= VT_I8
&& leftvt
!= VT_UI8
&&
6652 rightvt
!= VT_I8
&& rightvt
!= VT_UI8
) || HAVE_OLEAUT32_I8
))
6654 else if ((leftvt
== VT_EMPTY
|| leftvt
== VT_I2
||
6655 leftvt
== VT_I4
|| leftvt
== VT_R4
||
6656 leftvt
== VT_R8
|| leftvt
== VT_CY
||
6657 leftvt
== VT_DATE
|| leftvt
== VT_BSTR
||
6658 leftvt
== VT_BOOL
|| leftvt
== VT_DECIMAL
||
6659 (leftvt
>= VT_I1
&& leftvt
<= VT_UI4
) ||
6660 (HAVE_OLEAUT32_I8
&& (leftvt
== VT_I8
|| leftvt
== VT_UI8
)) ||
6661 leftvt
== VT_INT
|| leftvt
== VT_UINT
) &&
6662 (rightvt
== VT_EMPTY
|| rightvt
== VT_I2
||
6663 rightvt
== VT_I4
|| rightvt
== VT_R4
||
6664 rightvt
== VT_R8
|| rightvt
== VT_CY
||
6665 rightvt
== VT_DATE
|| rightvt
== VT_BSTR
||
6666 rightvt
== VT_BOOL
|| rightvt
== VT_DECIMAL
||
6667 (rightvt
>= VT_I1
&& rightvt
<= VT_UI4
) ||
6668 (HAVE_OLEAUT32_I8
&& (rightvt
== VT_I8
|| rightvt
== VT_UI8
)) ||
6669 rightvt
== VT_INT
|| rightvt
== VT_UINT
))
6674 hres
= pVarPow(&left
, &right
, &result
);
6676 /* Check expected HRESULT and if result variant type is correct */
6678 ok (hres
== DISP_E_BADVARTYPE
|| hres
== DISP_E_TYPEMISMATCH
,
6679 "VarPow: %s|0x%X, %s|0x%X: got vt %s hr 0x%X\n",
6680 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
],
6681 vtstr(V_VT(&result
)), hres
);
6683 ok (hres
== S_OK
&& resvt
== V_VT(&result
),
6684 "VarPow: %s|0x%X, %s|0x%X: expected vt %s hr 0x%X, got vt %s hr 0x%X\n",
6685 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
], vtstr(resvt
),
6686 S_OK
, vtstr(V_VT(&result
)), hres
);
6691 /* Check return values for valid variant type combinations */
6692 VARPOW(EMPTY
,0,EMPTY
,0,R8
,1.0);
6693 VARPOW(EMPTY
,0,NULL
,0,NULL
,0);
6694 VARPOW(EMPTY
,0,I2
,3,R8
,0.0);
6695 VARPOW(EMPTY
,0,I4
,3,R8
,0.0);
6696 VARPOW(EMPTY
,0,R4
,3.0f
,R8
,0.0);
6697 VARPOW(EMPTY
,0,R8
,3.0,R8
,0.0);
6698 VARPOW(EMPTY
,0,DATE
,3,R8
,0.0);
6699 VARPOW(EMPTY
,0,BSTR
,num3_str
,R8
,0.0);
6700 VARPOW(EMPTY
,0,BOOL
,VARIANT_FALSE
,R8
,1.0);
6701 VARPOW(EMPTY
,0,I1
,3,R8
,0.0);
6702 VARPOW(EMPTY
,0,UI1
,3,R8
,0.0);
6703 VARPOW(EMPTY
,0,UI2
,3,R8
,0.0);
6704 VARPOW(EMPTY
,0,UI4
,3,R8
,0.0);
6705 if (HAVE_OLEAUT32_I8
)
6707 VARPOW(EMPTY
,0,I8
,3,R8
,0.0);
6708 VARPOW(EMPTY
,0,UI8
,3,R8
,0.0);
6710 VARPOW(EMPTY
,0,INT
,3,R8
,0.0);
6711 VARPOW(EMPTY
,0,UINT
,3,R8
,0.0);
6712 VARPOW(NULL
,0,EMPTY
,0,NULL
,0);
6713 VARPOW(NULL
,0,NULL
,0,NULL
,0);
6714 VARPOW(NULL
,0,I2
,3,NULL
,0);
6715 VARPOW(NULL
,0,I4
,3,NULL
,0);
6716 VARPOW(NULL
,0,R4
,3.0f
,NULL
,0);
6717 VARPOW(NULL
,0,R8
,3.0,NULL
,0);
6718 VARPOW(NULL
,0,DATE
,3,NULL
,0);
6719 VARPOW(NULL
,0,BSTR
,num3_str
,NULL
,0);
6720 VARPOW(NULL
,0,BOOL
,VARIANT_TRUE
,NULL
,0);
6721 VARPOW(NULL
,0,I1
,3,NULL
,0);
6722 VARPOW(NULL
,0,UI1
,3,NULL
,0);
6723 VARPOW(NULL
,0,UI2
,3,NULL
,0);
6724 VARPOW(NULL
,0,UI4
,3,NULL
,0);
6725 if (HAVE_OLEAUT32_I8
)
6727 VARPOW(NULL
,0,I8
,3,NULL
,0);
6728 VARPOW(NULL
,0,UI8
,3,NULL
,0);
6730 VARPOW(NULL
,0,INT
,3,NULL
,0);
6731 VARPOW(NULL
,0,UINT
,3,NULL
,0);
6732 VARPOW(I2
,2,EMPTY
,0,R8
,1.0);
6733 VARPOW(I2
,2,NULL
,0,NULL
,0);
6734 VARPOW(I2
,2,I2
,3,R8
,8.0);
6735 VARPOW(I2
,2,I4
,3,R8
,8.0);
6736 VARPOW(I2
,2,R4
,3.0f
,R8
,8.0);
6737 VARPOW(I2
,2,R8
,3.0,R8
,8.0);
6738 VARPOW(I2
,2,DATE
,3,R8
,8.0);
6739 VARPOW(I2
,2,BSTR
,num3_str
,R8
,8.0);
6740 VARPOW(I2
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6741 VARPOW(I2
,2,I1
,3,R8
,8.0);
6742 VARPOW(I2
,2,UI1
,3,R8
,8.0);
6743 VARPOW(I2
,2,UI2
,3,R8
,8.0);
6744 VARPOW(I2
,2,UI4
,3,R8
,8.0);
6745 if (HAVE_OLEAUT32_I8
)
6747 VARPOW(I2
,2,I8
,3,R8
,8.0);
6748 VARPOW(I2
,2,UI8
,3,R8
,8.0);
6750 VARPOW(I2
,2,INT
,3,R8
,8.0);
6751 VARPOW(I2
,2,UINT
,3,R8
,8.0);
6752 VARPOW(I4
,2,EMPTY
,0,R8
,1.0);
6753 VARPOW(I4
,2,NULL
,0,NULL
,0);
6754 VARPOW(I4
,2,I2
,3,R8
,8.0);
6755 VARPOW(I4
,2,I4
,3,R8
,8.0);
6756 VARPOW(I4
,2,R4
,3.0f
,R8
,8.0);
6757 VARPOW(I4
,2,R8
,3.0,R8
,8.0);
6758 VARPOW(I4
,2,DATE
,3,R8
,8.0);
6759 VARPOW(I4
,2,BSTR
,num3_str
,R8
,8.0);
6760 VARPOW(I4
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6761 VARPOW(I4
,2,I1
,3,R8
,8.0);
6762 VARPOW(I4
,2,UI1
,3,R8
,8.0);
6763 VARPOW(I4
,2,UI2
,3,R8
,8.0);
6764 VARPOW(I4
,2,UI4
,3,R8
,8.0);
6765 if (HAVE_OLEAUT32_I8
)
6767 VARPOW(I4
,2,I8
,3,R8
,8.0);
6768 VARPOW(I4
,2,UI8
,3,R8
,8.0);
6770 VARPOW(I4
,2,INT
,3,R8
,8.0);
6771 VARPOW(I4
,2,UINT
,3,R8
,8.0);
6772 VARPOW(R4
,2,EMPTY
,0,R8
,1.0);
6773 VARPOW(R4
,2,NULL
,0,NULL
,0);
6774 VARPOW(R4
,2,I2
,3,R8
,8.0);
6775 VARPOW(R4
,2,I4
,3,R8
,8.0);
6776 VARPOW(R4
,2,R4
,3.0f
,R8
,8.0);
6777 VARPOW(R4
,2,R8
,3.0,R8
,8.0);
6778 VARPOW(R4
,2,DATE
,3,R8
,8.0);
6779 VARPOW(R4
,2,BSTR
,num3_str
,R8
,8.0);
6780 VARPOW(R4
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6781 VARPOW(R4
,2,I1
,3,R8
,8.0);
6782 VARPOW(R4
,2,UI1
,3,R8
,8.0);
6783 VARPOW(R4
,2,UI2
,3,R8
,8.0);
6784 VARPOW(R4
,2,UI4
,3,R8
,8.0);
6785 if (HAVE_OLEAUT32_I8
)
6787 VARPOW(R4
,2,I8
,3,R8
,8.0);
6788 VARPOW(R4
,2,UI8
,3,R8
,8.0);
6790 VARPOW(R4
,2,INT
,3,R8
,8.0);
6791 VARPOW(R4
,2,UINT
,3,R8
,8.0);
6792 VARPOW(R8
,2,EMPTY
,0,R8
,1.0);
6793 VARPOW(R8
,2,NULL
,0,NULL
,0);
6794 VARPOW(R8
,2,I2
,3,R8
,8.0);
6795 VARPOW(R8
,2,I4
,3,R8
,8.0);
6796 VARPOW(R8
,2,R4
,3.0f
,R8
,8.0);
6797 VARPOW(R8
,2,R8
,3.0,R8
,8.0);
6798 VARPOW(R8
,2,DATE
,3,R8
,8.0);
6799 VARPOW(R8
,2,BSTR
,num3_str
,R8
,8.0);
6800 VARPOW(R8
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6801 VARPOW(R8
,2,I1
,3,R8
,8.0);
6802 VARPOW(R8
,2,UI1
,3,R8
,8.0);
6803 VARPOW(R8
,2,UI2
,3,R8
,8.0);
6804 VARPOW(R8
,2,UI4
,3,R8
,8.0);
6805 if (HAVE_OLEAUT32_I8
)
6807 VARPOW(R8
,2,I8
,3,R8
,8.0);
6808 VARPOW(R8
,2,UI8
,3,R8
,8.0);
6810 VARPOW(R8
,2,INT
,3,R8
,8.0);
6811 VARPOW(R8
,2,UINT
,3,R8
,8.0);
6812 VARPOW(DATE
,2,EMPTY
,0,R8
,1.0);
6813 VARPOW(DATE
,2,NULL
,0,NULL
,0);
6814 VARPOW(DATE
,2,I2
,3,R8
,8.0);
6815 VARPOW(DATE
,2,I4
,3,R8
,8.0);
6816 VARPOW(DATE
,2,R4
,3.0f
,R8
,8.0);
6817 VARPOW(DATE
,2,R8
,3.0,R8
,8.0);
6818 VARPOW(DATE
,2,DATE
,3,R8
,8.0);
6819 VARPOW(DATE
,2,BSTR
,num3_str
,R8
,8.0);
6820 VARPOW(DATE
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6821 VARPOW(DATE
,2,I1
,3,R8
,8.0);
6822 VARPOW(DATE
,2,UI1
,3,R8
,8.0);
6823 VARPOW(DATE
,2,UI2
,3,R8
,8.0);
6824 VARPOW(DATE
,2,UI4
,3,R8
,8.0);
6825 if (HAVE_OLEAUT32_I8
)
6827 VARPOW(DATE
,2,I8
,3,R8
,8.0);
6828 VARPOW(DATE
,2,UI8
,3,R8
,8.0);
6830 VARPOW(DATE
,2,INT
,3,R8
,8.0);
6831 VARPOW(DATE
,2,UINT
,3,R8
,8.0);
6832 VARPOW(BSTR
,num2_str
,EMPTY
,0,R8
,1.0);
6833 VARPOW(BSTR
,num2_str
,NULL
,0,NULL
,0);
6834 VARPOW(BSTR
,num2_str
,I2
,3,R8
,8.0);
6835 VARPOW(BSTR
,num2_str
,I4
,3,R8
,8.0);
6836 VARPOW(BSTR
,num2_str
,R4
,3.0f
,R8
,8.0);
6837 VARPOW(BSTR
,num2_str
,R8
,3.0,R8
,8.0);
6838 VARPOW(BSTR
,num2_str
,DATE
,3,R8
,8.0);
6839 VARPOW(BSTR
,num2_str
,BSTR
,num3_str
,R8
,8.0);
6840 VARPOW(BSTR
,num2_str
,BOOL
,VARIANT_FALSE
,R8
,1.0);
6841 VARPOW(BSTR
,num2_str
,I1
,3,R8
,8.0);
6842 VARPOW(BSTR
,num2_str
,UI1
,3,R8
,8.0);
6843 VARPOW(BSTR
,num2_str
,UI2
,3,R8
,8.0);
6844 VARPOW(BSTR
,num2_str
,UI4
,3,R8
,8.0);
6845 if (HAVE_OLEAUT32_I8
)
6847 VARPOW(BSTR
,num2_str
,I8
,3,R8
,8.0);
6848 VARPOW(BSTR
,num2_str
,UI8
,3,R8
,8.0);
6850 VARPOW(BSTR
,num2_str
,INT
,3,R8
,8.0);
6851 VARPOW(BSTR
,num2_str
,UINT
,3,R8
,8.0);
6852 VARPOW(BOOL
,VARIANT_TRUE
,EMPTY
,0,R8
,1.0);
6853 VARPOW(BOOL
,VARIANT_TRUE
,NULL
,0,NULL
,0);
6854 VARPOW(BOOL
,VARIANT_TRUE
,I2
,3,R8
,-1.0);
6855 VARPOW(BOOL
,VARIANT_TRUE
,I4
,3,R8
,-1.0);
6856 VARPOW(BOOL
,VARIANT_TRUE
,R4
,3.0f
,R8
,-1.0);
6857 VARPOW(BOOL
,VARIANT_TRUE
,R8
,3.0,R8
,-1.0);
6858 VARPOW(BOOL
,VARIANT_TRUE
,DATE
,3,R8
,-1.0);
6859 VARPOW(BOOL
,VARIANT_TRUE
,BSTR
,num3_str
,R8
,-1.0);
6860 VARPOW(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
,R8
,-1.0);
6861 VARPOW(BOOL
,VARIANT_TRUE
,I1
,3,R8
,-1.0);
6862 VARPOW(BOOL
,VARIANT_TRUE
,UI1
,3,R8
,-1.0);
6863 VARPOW(BOOL
,VARIANT_TRUE
,UI2
,3,R8
,-1.0);
6864 VARPOW(BOOL
,VARIANT_TRUE
,UI4
,3,R8
,-1.0);
6865 if (HAVE_OLEAUT32_I8
)
6867 VARPOW(BOOL
,VARIANT_TRUE
,I8
,3,R8
,-1.0);
6868 VARPOW(BOOL
,VARIANT_TRUE
,UI8
,3,R8
,-1.0);
6870 VARPOW(BOOL
,VARIANT_TRUE
,INT
,3,R8
,-1.0);
6871 VARPOW(BOOL
,VARIANT_TRUE
,UINT
,3,R8
,-1.0);
6872 VARPOW(I1
,2,EMPTY
,0,R8
,1.0);
6873 VARPOW(I1
,2,NULL
,0,NULL
,0);
6874 VARPOW(I1
,2,I2
,3,R8
,8.0);
6875 VARPOW(I1
,2,I4
,3,R8
,8.0);
6876 VARPOW(I1
,2,R4
,3.0f
,R8
,8.0);
6877 VARPOW(I1
,2,R8
,3.0,R8
,8.0);
6878 VARPOW(I1
,2,DATE
,3,R8
,8.0);
6879 VARPOW(I1
,2,BSTR
,num3_str
,R8
,8.0);
6880 VARPOW(I1
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6881 VARPOW(I1
,2,I1
,3,R8
,8.0);
6882 VARPOW(I1
,2,UI1
,3,R8
,8.0);
6883 VARPOW(I1
,2,UI2
,3,R8
,8.0);
6884 VARPOW(I1
,2,UI4
,3,R8
,8.0);
6885 if (HAVE_OLEAUT32_I8
)
6887 VARPOW(I1
,2,I8
,3,R8
,8.0);
6888 VARPOW(I1
,2,UI8
,3,R8
,8.0);
6890 VARPOW(I1
,2,INT
,3,R8
,8.0);
6891 VARPOW(I1
,2,UINT
,3,R8
,8.0);
6892 VARPOW(UI1
,2,EMPTY
,0,R8
,1.0);
6893 VARPOW(UI1
,2,NULL
,0,NULL
,0);
6894 VARPOW(UI1
,2,I2
,3,R8
,8.0);
6895 VARPOW(UI1
,2,I4
,3,R8
,8.0);
6896 VARPOW(UI1
,2,R4
,3.0f
,R8
,8.0);
6897 VARPOW(UI1
,2,R8
,3.0,R8
,8.0);
6898 VARPOW(UI1
,2,DATE
,3,R8
,8.0);
6899 VARPOW(UI1
,2,BSTR
,num3_str
,R8
,8.0);
6900 VARPOW(UI1
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6901 VARPOW(UI1
,2,I1
,3,R8
,8.0);
6902 VARPOW(UI1
,2,UI1
,3,R8
,8.0);
6903 VARPOW(UI1
,2,UI2
,3,R8
,8.0);
6904 VARPOW(UI1
,2,UI4
,3,R8
,8.0);
6905 if (HAVE_OLEAUT32_I8
)
6907 VARPOW(UI1
,2,I8
,3,R8
,8.0);
6908 VARPOW(UI1
,2,UI8
,3,R8
,8.0);
6910 VARPOW(UI1
,2,INT
,3,R8
,8.0);
6911 VARPOW(UI1
,2,UINT
,3,R8
,8.0);
6912 VARPOW(UI2
,2,EMPTY
,0,R8
,1.0);
6913 VARPOW(UI2
,2,NULL
,0,NULL
,0);
6914 VARPOW(UI2
,2,I2
,3,R8
,8.0);
6915 VARPOW(UI2
,2,I4
,3,R8
,8.0);
6916 VARPOW(UI2
,2,R4
,3.0f
,R8
,8.0);
6917 VARPOW(UI2
,2,R8
,3.0,R8
,8.0);
6918 VARPOW(UI2
,2,DATE
,3,R8
,8.0);
6919 VARPOW(UI2
,2,BSTR
,num3_str
,R8
,8.0);
6920 VARPOW(UI2
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6921 VARPOW(UI2
,2,I1
,3,R8
,8.0);
6922 VARPOW(UI2
,2,UI1
,3,R8
,8.0);
6923 VARPOW(UI2
,2,UI2
,3,R8
,8.0);
6924 VARPOW(UI2
,2,UI4
,3,R8
,8.0);
6925 if (HAVE_OLEAUT32_I8
)
6927 VARPOW(UI2
,2,I8
,3,R8
,8.0);
6928 VARPOW(UI2
,2,UI8
,3,R8
,8.0);
6930 VARPOW(UI2
,2,INT
,3,R8
,8.0);
6931 VARPOW(UI2
,2,UINT
,3,R8
,8.0);
6932 VARPOW(UI4
,2,EMPTY
,0,R8
,1.0);
6933 VARPOW(UI4
,2,NULL
,0,NULL
,0);
6934 VARPOW(UI4
,2,I2
,3,R8
,8.0);
6935 VARPOW(UI4
,2,I4
,3,R8
,8.0);
6936 VARPOW(UI4
,2,R4
,3.0f
,R8
,8.0);
6937 VARPOW(UI4
,2,R8
,3.0,R8
,8.0);
6938 VARPOW(UI4
,2,DATE
,3,R8
,8.0);
6939 VARPOW(UI4
,2,BSTR
,num3_str
,R8
,8.0);
6940 VARPOW(UI4
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6941 VARPOW(UI4
,2,I1
,3,R8
,8.0);
6942 VARPOW(UI4
,2,UI1
,3,R8
,8.0);
6943 VARPOW(UI4
,2,UI2
,3,R8
,8.0);
6944 VARPOW(UI4
,2,UI4
,3,R8
,8.0);
6945 if (HAVE_OLEAUT32_I8
)
6947 VARPOW(UI4
,2,I8
,3,R8
,8.0);
6948 VARPOW(UI4
,2,UI8
,3,R8
,8.0);
6950 VARPOW(UI4
,2,INT
,3,R8
,8.0);
6951 VARPOW(UI4
,2,UINT
,3,R8
,8.0);
6952 if (HAVE_OLEAUT32_I8
)
6954 VARPOW(I8
,2,EMPTY
,0,R8
,1.0);
6955 VARPOW(I8
,2,NULL
,0,NULL
,0);
6956 VARPOW(I8
,2,I2
,3,R8
,8.0);
6957 VARPOW(I8
,2,I4
,3,R8
,8.0);
6958 VARPOW(I8
,2,R4
,3.0f
,R8
,8.0);
6959 VARPOW(I8
,2,R8
,3.0,R8
,8.0);
6960 VARPOW(I8
,2,DATE
,3,R8
,8.0);
6961 VARPOW(I8
,2,BSTR
,num3_str
,R8
,8.0);
6962 VARPOW(I8
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6963 VARPOW(I8
,2,I1
,3,R8
,8.0);
6964 VARPOW(I8
,2,UI1
,3,R8
,8.0);
6965 VARPOW(I8
,2,UI2
,3,R8
,8.0);
6966 VARPOW(I8
,2,UI4
,3,R8
,8.0);
6967 VARPOW(I8
,2,I8
,3,R8
,8.0);
6968 VARPOW(I8
,2,UI8
,3,R8
,8.0);
6969 VARPOW(I8
,2,INT
,3,R8
,8.0);
6970 VARPOW(I8
,2,UINT
,3,R8
,8.0);
6971 VARPOW(UI8
,2,EMPTY
,0,R8
,1.0);
6972 VARPOW(UI8
,2,NULL
,0,NULL
,0);
6973 VARPOW(UI8
,2,I2
,3,R8
,8.0);
6974 VARPOW(UI8
,2,I4
,3,R8
,8.0);
6975 VARPOW(UI8
,2,R4
,3.0f
,R8
,8.0);
6976 VARPOW(UI8
,2,R8
,3.0,R8
,8.0);
6977 VARPOW(UI8
,2,DATE
,3,R8
,8.0);
6978 VARPOW(UI8
,2,BSTR
,num3_str
,R8
,8.0);
6979 VARPOW(UI8
,2,I1
,3,R8
,8.0);
6980 VARPOW(UI8
,2,UI1
,3,R8
,8.0);
6981 VARPOW(UI8
,2,UI2
,3,R8
,8.0);
6982 VARPOW(UI8
,2,UI4
,3,R8
,8.0);
6983 VARPOW(UI8
,2,I8
,3,R8
,8.0);
6984 VARPOW(UI8
,2,UI8
,3,R8
,8.0);
6985 VARPOW(UI8
,2,INT
,3,R8
,8.0);
6986 VARPOW(UI8
,2,UINT
,3,R8
,8.0);
6988 VARPOW(INT
,2,EMPTY
,0,R8
,1.0);
6989 VARPOW(INT
,2,NULL
,0,NULL
,0);
6990 VARPOW(INT
,2,I2
,3,R8
,8.0);
6991 VARPOW(INT
,2,I4
,3,R8
,8.0);
6992 VARPOW(INT
,2,R4
,3.0f
,R8
,8.0);
6993 VARPOW(INT
,2,R8
,3.0,R8
,8.0);
6994 VARPOW(INT
,2,DATE
,3,R8
,8.0);
6995 VARPOW(INT
,2,BSTR
,num3_str
,R8
,8.0);
6996 VARPOW(INT
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6997 VARPOW(INT
,2,I1
,3,R8
,8.0);
6998 VARPOW(INT
,2,UI1
,3,R8
,8.0);
6999 VARPOW(INT
,2,UI2
,3,R8
,8.0);
7000 VARPOW(INT
,2,UI4
,3,R8
,8.0);
7001 if (HAVE_OLEAUT32_I8
)
7003 VARPOW(INT
,2,I8
,3,R8
,8.0);
7004 VARPOW(INT
,2,UI8
,3,R8
,8.0);
7006 VARPOW(INT
,2,INT
,3,R8
,8.0);
7007 VARPOW(INT
,2,UINT
,3,R8
,8.0);
7008 VARPOW(UINT
,2,EMPTY
,0,R8
,1.0);
7009 VARPOW(UINT
,2,NULL
,0,NULL
,0);
7010 VARPOW(UINT
,2,I2
,3,R8
,8.0);
7011 VARPOW(UINT
,2,I4
,3,R8
,8.0);
7012 VARPOW(UINT
,2,R4
,3.0f
,R8
,8.0);
7013 VARPOW(UINT
,2,R8
,3.0,R8
,8.0);
7014 VARPOW(UINT
,2,DATE
,3,R8
,8.0);
7015 VARPOW(UINT
,2,BSTR
,num3_str
,R8
,8.0);
7016 VARPOW(UINT
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
7017 VARPOW(UINT
,2,I1
,3,R8
,8.0);
7018 VARPOW(UINT
,2,UI1
,3,R8
,8.0);
7019 VARPOW(UINT
,2,UI2
,3,R8
,8.0);
7020 VARPOW(UINT
,2,UI4
,3,R8
,8.0);
7021 if (HAVE_OLEAUT32_I8
)
7023 VARPOW(UINT
,2,I8
,3,R8
,8.0);
7024 VARPOW(UINT
,2,UI8
,3,R8
,8.0);
7026 VARPOW(UINT
,2,INT
,3,R8
,8.0);
7027 VARPOW(UINT
,2,UINT
,3,R8
,8.0);
7029 /* Manually test some VT_CY, VT_DECIMAL variants */
7031 hres
= VarCyFromI4(2, &V_CY(&cy
));
7032 ok(hres
== S_OK
, "VarCyFromI4 failed!\n");
7033 V_VT(&dec
) = VT_DECIMAL
;
7034 hres
= VarDecFromR8(2.0, &V_DECIMAL(&dec
));
7035 ok(hres
== S_OK
, "VarDecFromR4 failed!\n");
7036 memset(&left
, 0, sizeof(left
));
7037 memset(&right
, 0, sizeof(right
));
7038 V_VT(&left
) = VT_I4
;
7040 V_VT(&right
) = VT_I8
;
7043 hres
= pVarPow(&cy
, &cy
, &result
);
7044 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
7045 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
7046 S_OK
, hres
, vtstr(V_VT(&result
)));
7047 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 4.0),
7048 "VARPOW: CY value %f, expected %f\n", V_R8(&result
), 4.0);
7050 hres
= pVarPow(&cy
, &right
, &result
);
7053 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
7054 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
7055 S_OK
, hres
, vtstr(V_VT(&result
)));
7056 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 4.0),
7057 "VARPOW: CY value %f, expected %f\n", V_R8(&result
), 4.0);
7061 ok(hres
== DISP_E_BADVARTYPE
&& V_VT(&result
) == VT_EMPTY
,
7062 "VARPOW: expected coerced hres 0x%X type VT_EMPTY, got hres 0x%X type %s!\n",
7063 DISP_E_BADVARTYPE
, hres
, vtstr(V_VT(&result
)));
7066 hres
= pVarPow(&left
, &cy
, &result
);
7067 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
7068 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
7069 S_OK
, hres
, vtstr(V_VT(&result
)));
7070 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 10000.0),
7071 "VARPOW: CY value %f, expected %f\n", V_R8(&result
), 10000.0);
7073 hres
= pVarPow(&left
, &dec
, &result
);
7074 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
7075 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
7076 S_OK
, hres
, vtstr(V_VT(&result
)));
7077 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
),10000.0),
7078 "VARPOW: DECIMAL value %f, expected %f\n", V_R8(&result
), 10000.0);
7080 hres
= pVarPow(&dec
, &dec
, &result
);
7081 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
7082 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
7083 S_OK
, hres
, vtstr(V_VT(&result
)));
7084 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 4.0),
7085 "VARPOW: DECIMAL value %f, expected %f\n", V_R8(&result
), 4.0);
7087 hres
= pVarPow(&dec
, &right
, &result
);
7090 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
7091 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
7092 S_OK
, hres
, vtstr(V_VT(&result
)));
7093 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 4.0),
7094 "VARPOW: DECIMAL value %f, expected %f\n", V_R8(&result
), 4.0);
7098 ok(hres
== DISP_E_BADVARTYPE
&& V_VT(&result
) == VT_EMPTY
,
7099 "VARPOW: expected coerced hres 0x%X type VT_EMPTY, got hres 0x%X type %s!\n",
7100 DISP_E_BADVARTYPE
, hres
, vtstr(V_VT(&result
)));
7103 SysFreeString(num2_str
);
7104 SysFreeString(num3_str
);
7107 static HRESULT (WINAPI
*pVarDiv
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
7109 #define VARDIV(vt1,val1,vt2,val2,rvt,rval) \
7110 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
7111 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
7112 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
7113 test_var_call2( __LINE__, pVarDiv, &left, &right, &exp )
7115 /* Skip any type that is not defined or produces an error for every case */
7116 #define SKIPTESTDIV(a) \
7117 if (a == VT_ERROR || a == VT_VARIANT || \
7118 a == VT_DISPATCH || a == VT_UNKNOWN || \
7119 a == VT_RECORD || a > VT_UINT || \
7120 a == VT_I1 || a == VT_UI8 || \
7121 a == VT_INT || a == VT_UINT || \
7122 a == VT_UI2 || a == VT_UI4 || \
7123 a == 15 /*not defined*/) \
7126 static void test_VarDiv(void)
7128 static const WCHAR str1
[] = { '1','\0' };
7129 static const WCHAR str2
[] = { '2','\0' };
7130 VARIANT left
, right
, exp
, result
, cy
, dec
;
7131 BSTR num1_str
, num2_str
;
7133 HRESULT hres
, expectedhres
;
7136 num1_str
= SysAllocString(str1
);
7137 num2_str
= SysAllocString(str2
);
7141 /* Test all possible flag/vt combinations & the resulting vt type */
7142 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
7144 VARTYPE leftvt
, rightvt
, resvt
;
7146 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
7148 SKIPTESTDIV(leftvt
);
7150 /* Check if we need/have support for I8 */
7151 if (leftvt
== VT_I8
&& !HAVE_OLEAUT32_I8
)
7154 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
7157 SKIPTESTDIV(rightvt
);
7159 /* Check if we need/have support for I8 */
7160 if (rightvt
== VT_I8
&& !HAVE_OLEAUT32_I8
)
7163 /* Native crashes with VT_BYREF */
7164 if (ExtraFlags
[i
] == VT_BYREF
)
7167 memset(&left
, 0, sizeof(left
));
7168 memset(&right
, 0, sizeof(right
));
7169 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
7170 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
7171 V_VT(&result
) = VT_EMPTY
;
7173 expectedhres
= S_OK
;
7175 if (leftvt
== VT_BSTR
)
7176 V_BSTR(&left
) = num2_str
;
7177 else if (leftvt
== VT_DECIMAL
)
7179 VarDecFromR8(2.0, &V_DECIMAL(&left
));
7180 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
7183 /* Division by 0 is undefined */
7187 V_BSTR(&right
) = num2_str
;
7190 VarDecFromR8(2.0, &V_DECIMAL(&right
));
7191 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
7194 V_BOOL(&right
) = VARIANT_TRUE
;
7196 case VT_I2
: V_I2(&right
) = 2; break;
7197 case VT_I4
: V_I4(&right
) = 2; break;
7198 case VT_R4
: V_R4(&right
) = 2.0f
; break;
7199 case VT_R8
: V_R8(&right
) = 2.0; break;
7200 case VT_CY
: V_CY(&right
).int64
= 2; break;
7201 case VT_DATE
: V_DATE(&right
) = 2; break;
7202 case VT_UI1
: V_UI1(&right
) = 2; break;
7203 case VT_I8
: V_I8(&right
) = 2; break;
7207 /* Determine return type */
7208 if (!(rightvt
== VT_EMPTY
))
7210 if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
7212 else if (leftvt
== VT_DECIMAL
|| rightvt
== VT_DECIMAL
)
7214 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
||
7215 leftvt
== VT_CY
|| rightvt
== VT_CY
||
7216 leftvt
== VT_DATE
|| rightvt
== VT_DATE
||
7217 leftvt
== VT_I4
|| rightvt
== VT_I4
||
7218 leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
||
7219 leftvt
== VT_I2
|| rightvt
== VT_I2
||
7220 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
||
7221 leftvt
== VT_R8
|| rightvt
== VT_R8
||
7222 leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
7224 if ((leftvt
== VT_UI1
&& rightvt
== VT_R4
) ||
7225 (leftvt
== VT_R4
&& rightvt
== VT_UI1
))
7227 else if ((leftvt
== VT_R4
&& (rightvt
== VT_BOOL
||
7228 rightvt
== VT_I2
)) || (rightvt
== VT_R4
&&
7229 (leftvt
== VT_BOOL
|| leftvt
== VT_I2
)))
7234 else if (leftvt
== VT_R4
|| rightvt
== VT_R4
)
7237 else if (leftvt
== VT_NULL
&& rightvt
== VT_EMPTY
)
7242 /* Native VarDiv always returns an error when using extra flags */
7243 if (ExtraFlags
[i
] != 0)
7246 hres
= pVarDiv(&left
, &right
, &result
);
7248 /* Check expected HRESULT and if result variant type is correct */
7250 ok (hres
== DISP_E_BADVARTYPE
|| hres
== DISP_E_TYPEMISMATCH
||
7251 hres
== DISP_E_OVERFLOW
|| hres
== DISP_E_DIVBYZERO
,
7252 "VarDiv: %s|0x%X, %s|0x%X: got vt %s hr 0x%X\n",
7253 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
],
7254 vtstr(V_VT(&result
)), hres
);
7256 ok (hres
== S_OK
&& resvt
== V_VT(&result
),
7257 "VarDiv: %s|0x%X, %s|0x%X: expected vt %s hr 0x%X, got vt %s hr 0x%X\n",
7258 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
], vtstr(resvt
),
7259 S_OK
, vtstr(V_VT(&result
)), hres
);
7264 /* Test return values for all the good cases */
7265 VARDIV(EMPTY
,0,NULL
,0,NULL
,0);
7266 VARDIV(EMPTY
,0,I2
,2,R8
,0.0);
7267 VARDIV(EMPTY
,0,I4
,2,R8
,0.0);
7268 VARDIV(EMPTY
,0,R4
,2.0f
,R4
,0.0f
);
7269 VARDIV(EMPTY
,0,R8
,2.0,R8
,0.0);
7270 VARDIV(EMPTY
,0,DATE
,2.0,R8
,0.0);
7271 VARDIV(EMPTY
,0,BSTR
,num2_str
,R8
,0.0);
7272 VARDIV(EMPTY
,0,BOOL
,VARIANT_TRUE
,R8
,0.0);
7273 VARDIV(EMPTY
,0,UI1
,2,R8
,0.0);
7274 if (HAVE_OLEAUT32_I8
)
7276 VARDIV(EMPTY
,0,I8
,2,R8
,0.0);
7278 VARDIV(NULL
,0,EMPTY
,0,NULL
,0);
7279 VARDIV(NULL
,0,NULL
,0,NULL
,0);
7280 VARDIV(NULL
,0,I2
,2,NULL
,0);
7281 VARDIV(NULL
,0,I4
,2,NULL
,0);
7282 VARDIV(NULL
,0,R4
,2.0f
,NULL
,0);
7283 VARDIV(NULL
,0,R8
,2.0,NULL
,0);
7284 VARDIV(NULL
,0,DATE
,2,NULL
,0);
7285 VARDIV(NULL
,0,BSTR
,num2_str
,NULL
,0);
7286 VARDIV(NULL
,0,BOOL
,VARIANT_TRUE
,NULL
,0);
7287 VARDIV(NULL
,0,UI1
,2,NULL
,0);
7288 if (HAVE_OLEAUT32_I8
)
7290 VARDIV(NULL
,0,I8
,2,NULL
,0);
7292 VARDIV(I2
,2,NULL
,0,NULL
,0);
7293 VARDIV(I2
,1,I2
,2,R8
,0.5);
7294 VARDIV(I2
,1,I4
,2,R8
,0.5);
7295 VARDIV(I2
,1,R4
,2,R4
,0.5f
);
7296 VARDIV(I2
,1,R8
,2.0,R8
,0.5);
7297 VARDIV(I2
,1,DATE
,2,R8
,0.5);
7298 VARDIV(I2
,1,BOOL
,VARIANT_TRUE
,R8
,-1.0);
7299 VARDIV(I2
,1,UI1
,2,R8
,0.5);
7300 if (HAVE_OLEAUT32_I8
)
7302 VARDIV(I2
,1,I8
,2,R8
,0.5);
7304 VARDIV(I4
,1,NULL
,0,NULL
,0);
7305 VARDIV(I4
,1,I2
,2,R8
,0.5);
7306 VARDIV(I4
,1,I4
,2,R8
,0.5);
7307 VARDIV(I4
,1,R4
,2.0f
,R8
,0.5);
7308 VARDIV(I4
,1,R8
,2.0,R8
,0.5);
7309 VARDIV(I4
,1,DATE
,2,R8
,0.5);
7310 VARDIV(I4
,1,BSTR
,num2_str
,R8
,0.5);
7311 VARDIV(I4
,1,BOOL
,VARIANT_TRUE
,R8
,-1.0);
7312 VARDIV(I4
,1,UI1
,2,R8
,0.5);
7313 if (HAVE_OLEAUT32_I8
)
7315 VARDIV(I4
,1,I8
,2,R8
,0.5);
7317 VARDIV(R4
,1.0f
,NULL
,0,NULL
,0);
7318 VARDIV(R4
,1.0f
,I2
,2,R4
,0.5f
);
7319 VARDIV(R4
,1.0f
,I4
,2,R8
,0.5);
7320 VARDIV(R4
,1.0f
,R4
,2.0f
,R4
,0.5f
);
7321 VARDIV(R4
,1.0f
,R8
,2.0,R8
,0.5);
7322 VARDIV(R4
,1.0f
,DATE
,2,R8
,0.5);
7323 VARDIV(R4
,1.0f
,BSTR
,num2_str
,R8
,0.5);
7324 VARDIV(R4
,1.0f
,BOOL
,VARIANT_TRUE
,R4
,-1);
7325 VARDIV(R4
,1.0f
,UI1
,2,R4
,0.5f
);
7326 if (HAVE_OLEAUT32_I8
)
7328 VARDIV(R4
,1.0f
,I8
,2,R8
,0.5);
7330 VARDIV(R8
,1.0,NULL
,0,NULL
,0);
7331 VARDIV(R8
,1.0,I2
,2,R8
,0.5);
7332 VARDIV(R8
,1.0,I4
,2,R8
,0.5);
7333 VARDIV(R8
,1.0,R4
,2.0f
,R8
,0.5);
7334 VARDIV(R8
,1.0,R8
,2.0,R8
,0.5);
7335 VARDIV(R8
,1.0,DATE
,2,R8
,0.5);
7336 VARDIV(R8
,1.0,BSTR
,num2_str
,R8
,0.5);
7337 VARDIV(R8
,1.0,BOOL
,VARIANT_TRUE
,R8
,-1.0);
7338 VARDIV(R8
,1.0,UI1
,2,R8
,0.5);
7339 if (HAVE_OLEAUT32_I8
)
7341 VARDIV(R8
,1.0,I8
,2,R8
,0.5);
7343 VARDIV(DATE
,1,NULL
,0,NULL
,0);
7344 VARDIV(DATE
,1,I2
,2,R8
,0.5);
7345 VARDIV(DATE
,1,I4
,2,R8
,0.5);
7346 VARDIV(DATE
,1,R4
,2.0f
,R8
,0.5);
7347 VARDIV(DATE
,1,R8
,2.0,R8
,0.5);
7348 VARDIV(DATE
,1,DATE
,2,R8
,0.5);
7349 VARDIV(DATE
,1,BSTR
,num2_str
,R8
,0.5);
7350 VARDIV(DATE
,1,BOOL
,VARIANT_TRUE
,R8
,-1.0);
7351 VARDIV(DATE
,1,UI1
,2,R8
,0.5);
7352 if (HAVE_OLEAUT32_I8
)
7354 VARDIV(DATE
,1,I8
,2,R8
,0.5);
7356 VARDIV(BSTR
,num1_str
,NULL
,0,NULL
,0);
7357 VARDIV(BSTR
,num1_str
,I2
,2,R8
,0.5);
7358 VARDIV(BSTR
,num1_str
,I4
,2,R8
,0.5);
7359 VARDIV(BSTR
,num1_str
,R4
,2.0f
,R8
,0.5);
7360 VARDIV(BSTR
,num1_str
,R8
,2.0,R8
,0.5);
7361 VARDIV(BSTR
,num1_str
,DATE
,2,R8
,0.5);
7362 VARDIV(BSTR
,num1_str
,BSTR
,num2_str
,R8
,0.5);
7363 VARDIV(BSTR
,num1_str
,BOOL
,VARIANT_TRUE
,R8
,-1);
7364 VARDIV(BSTR
,num1_str
,UI1
,2,R8
,0.5);
7365 if (HAVE_OLEAUT32_I8
)
7367 VARDIV(BSTR
,num1_str
,I8
,2,R8
,0.5);
7369 VARDIV(BOOL
,VARIANT_TRUE
,NULL
,0,NULL
,0);
7370 VARDIV(BOOL
,VARIANT_TRUE
,I2
,1,R8
,-1.0);
7371 VARDIV(BOOL
,VARIANT_FALSE
,I2
,1,R8
,0.0);
7372 VARDIV(BOOL
,VARIANT_TRUE
,I4
,1,R8
,-1.0);
7373 VARDIV(BOOL
,VARIANT_FALSE
,I4
,1,R8
,0.0);
7374 VARDIV(BOOL
,VARIANT_TRUE
,R4
,1,R4
,-1.0f
);
7375 VARDIV(BOOL
,VARIANT_FALSE
,R4
,1,R4
,0.0f
);
7376 VARDIV(BOOL
,VARIANT_TRUE
,R8
,1.0,R8
,-1.0);
7377 VARDIV(BOOL
,VARIANT_FALSE
,R8
,1.0,R8
,0.0);
7378 VARDIV(BOOL
,VARIANT_FALSE
,DATE
,2,R8
,0.0);
7379 VARDIV(BOOL
,VARIANT_FALSE
,BSTR
,num2_str
,R8
,0.0);
7380 VARDIV(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
,R8
,1.0);
7381 VARDIV(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
,R8
,0.0);
7382 VARDIV(BOOL
,VARIANT_TRUE
,UI1
,1,R8
,-1.0);
7383 if (HAVE_OLEAUT32_I8
)
7385 VARDIV(BOOL
,VARIANT_TRUE
,I8
,1,R8
,-1.0);
7387 VARDIV(UI1
,1,NULL
,0,NULL
,0);
7388 VARDIV(UI1
,1,I2
,2,R8
,0.5);
7389 VARDIV(UI1
,1,I4
,2,R8
,0.5);
7390 VARDIV(UI1
,1,R4
,2.0f
,R4
,0.5f
);
7391 VARDIV(UI1
,1,R8
,2.0,R8
,0.5);
7392 VARDIV(UI1
,1,DATE
,2,R8
,0.5);
7393 VARDIV(UI1
,1,BSTR
,num2_str
,R8
,0.5);
7394 VARDIV(UI1
,1,BOOL
,VARIANT_TRUE
,R8
,-1);
7395 VARDIV(UI1
,1,UI1
,2,R8
,0.5);
7396 if (HAVE_OLEAUT32_I8
)
7398 VARDIV(UI1
,1,I8
,2,R8
,0.5);
7399 VARDIV(I8
,1,NULL
,0,NULL
,0);
7400 VARDIV(I8
,1,I2
,2,R8
,0.5);
7401 VARDIV(I8
,1,I4
,2,R8
,0.5);
7402 VARDIV(I8
,1,R4
,2.0f
,R8
,0.5);
7403 VARDIV(I8
,1,R8
,2.0,R8
,0.5);
7404 VARDIV(I8
,1,DATE
,2,R8
,0.5);
7405 VARDIV(I8
,1,BSTR
,num2_str
,R8
,0.5);
7406 VARDIV(I8
,1,BOOL
,VARIANT_TRUE
,R8
,-1);
7407 VARDIV(I8
,1,UI1
,2,R8
,0.5);
7408 VARDIV(I8
,1,I8
,2,R8
,0.5);
7411 /* Manually test some VT_CY, VT_DECIMAL variants */
7413 hres
= VarCyFromI4(10000, &V_CY(&cy
));
7414 ok(hres
== S_OK
, "VarCyFromI4 failed!\n");
7415 V_VT(&dec
) = VT_DECIMAL
;
7416 hres
= VarDecFromR8(2.0, &V_DECIMAL(&dec
));
7417 ok(hres
== S_OK
, "VarDecFromR4 failed!\n");
7418 memset(&left
, 0, sizeof(left
));
7419 memset(&right
, 0, sizeof(right
));
7420 V_VT(&left
) = VT_I4
;
7422 V_VT(&right
) = VT_UI1
;
7425 hres
= pVarDiv(&cy
, &cy
, &result
);
7426 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
7427 "VARDIV: expected coerced type VT_R8, got %s!\n", vtstr(V_VT(&result
)));
7428 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 1.0),
7429 "VARDIV: CY value %f, expected %f\n", V_R8(&result
), (double)1.0);
7431 hres
= pVarDiv(&cy
, &right
, &result
);
7432 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
7433 "VARDIV: expected coerced type VT_R8, got %s!\n", vtstr(V_VT(&result
)));
7434 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 5000.0),
7435 "VARDIV: CY value %f, expected %f\n", V_R8(&result
), (double)5000.0);
7437 hres
= pVarDiv(&left
, &cy
, &result
);
7438 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
7439 "VARDIV: expected coerced type VT_R8, got %s!\n", vtstr(V_VT(&result
)));
7440 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 0.01),
7441 "VARDIV: CY value %f, expected %f\n", V_R8(&result
), (double)0.01);
7443 hres
= pVarDiv(&left
, &dec
, &result
);
7444 ok(hres
== S_OK
&& V_VT(&result
) == VT_DECIMAL
,
7445 "VARDIV: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result
)));
7446 hres
= VarR8FromDec(&V_DECIMAL(&result
), &r
);
7447 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 50.0),
7448 "VARDIV: DECIMAL value %f, expected %f\n", r
, (double)50.0);
7450 hres
= pVarDiv(&dec
, &dec
, &result
);
7451 ok(hres
== S_OK
&& V_VT(&result
) == VT_DECIMAL
,
7452 "VARDIV: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result
)));
7453 hres
= VarR8FromDec(&V_DECIMAL(&result
), &r
);
7454 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 1.0),
7455 "VARDIV: DECIMAL value %f, expected %f\n", r
, (double)1.0);
7457 hres
= pVarDiv(&dec
, &right
, &result
);
7458 ok(hres
== S_OK
&& V_VT(&result
) == VT_DECIMAL
,
7459 "VARDIV: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result
)));
7460 hres
= VarR8FromDec(&V_DECIMAL(&result
), &r
);
7461 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 1.0),
7462 "VARDIV: DECIMAL value %f, expected %f\n", r
, (double)1.0);
7464 /* Check for division by zero and overflow */
7465 V_VT(&left
) = VT_R8
;
7467 V_VT(&right
) = VT_R8
;
7469 hres
= pVarDiv(&left
, &right
, &result
);
7470 ok(hres
== DISP_E_DIVBYZERO
&& V_VT(&result
) == VT_EMPTY
,
7471 "VARDIV: Division by (1.0/0.0) should result in DISP_E_DIVBYZERO but got 0x%X\n", hres
);
7473 V_VT(&left
) = VT_R8
;
7475 V_VT(&right
) = VT_R8
;
7477 hres
= pVarDiv(&left
, &right
, &result
);
7478 ok(hres
== DISP_E_OVERFLOW
&& V_VT(&result
) == VT_EMPTY
,
7479 "VARDIV: Division by (0.0/0.0) should result in DISP_E_OVERFLOW but got 0x%X\n", hres
);
7481 SysFreeString(num1_str
);
7482 SysFreeString(num2_str
);
7485 static HRESULT (WINAPI
*pVarIdiv
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
7487 #define VARIDIV(vt1,val1,vt2,val2,rvt,rval) \
7488 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
7489 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
7490 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
7491 test_var_call2( __LINE__, pVarIdiv, &left, &right, &exp )
7493 /* Skip any type that is not defined or produces an error for every case */
7494 #define SKIPTESTIDIV(a) \
7495 if (a == VT_ERROR || a == VT_VARIANT || \
7496 a == VT_DISPATCH || a == VT_UNKNOWN || \
7497 a == VT_RECORD || a > VT_UINT || \
7498 a == 15 /*not defined*/) \
7501 static void test_VarIdiv(void)
7503 static const WCHAR str1
[] = { '1','\0' };
7504 static const WCHAR str2
[] = { '2','\0' };
7505 VARIANT left
, right
, exp
, result
, cy
, dec
;
7506 BSTR num1_str
, num2_str
;
7512 num1_str
= SysAllocString(str1
);
7513 num2_str
= SysAllocString(str2
);
7515 /* Test all possible flag/vt combinations & the resulting vt type */
7516 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
7518 VARTYPE leftvt
, rightvt
, resvt
;
7520 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
7522 SKIPTESTIDIV(leftvt
);
7524 /* Check if we need/have support for I8 and/or UI8 */
7525 if ((leftvt
== VT_I8
|| leftvt
== VT_UI8
) && !HAVE_OLEAUT32_I8
)
7528 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
7531 SKIPTESTIDIV(rightvt
);
7533 /* Native crashes with extra flag VT_BYREF */
7534 if (ExtraFlags
[i
] == VT_BYREF
)
7537 /* Check if we need/have support for I8 and/or UI8 */
7538 if ((rightvt
== VT_I8
|| rightvt
== VT_UI8
) && !HAVE_OLEAUT32_I8
)
7541 memset(&left
, 0, sizeof(left
));
7542 memset(&right
, 0, sizeof(right
));
7543 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
7544 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
7545 V_VT(&result
) = VT_EMPTY
;
7548 if (leftvt
== VT_BSTR
)
7549 V_BSTR(&left
) = num2_str
;
7550 else if (leftvt
== VT_DECIMAL
)
7552 VarDecFromR8(2.0, &V_DECIMAL(&left
));
7553 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
7556 /* Division by 0 is undefined */
7560 V_BSTR(&right
) = num2_str
;
7563 VarDecFromR8(2.0, &V_DECIMAL(&right
));
7564 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
7567 V_BOOL(&right
) = VARIANT_TRUE
;
7570 VarCyFromI4(10000, &V_CY(&right
));
7571 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
7573 case VT_I2
: V_I2(&right
) = 2; break;
7574 case VT_I4
: V_I4(&right
) = 2; break;
7575 case VT_R4
: V_R4(&right
) = 2.0f
; break;
7576 case VT_R8
: V_R8(&right
) = 2.0; break;
7577 case VT_DATE
: V_DATE(&right
) = 2; break;
7578 case VT_I1
: V_I1(&right
) = 2; break;
7579 case VT_UI1
: V_UI1(&right
) = 2; break;
7580 case VT_UI2
: V_UI2(&right
) = 2; break;
7581 case VT_UI4
: V_UI4(&right
) = 2; break;
7582 case VT_I8
: V_I8(&right
) = 2; break;
7583 case VT_UI8
: V_UI8(&right
) = 2; break;
7584 case VT_INT
: V_INT(&right
) = 2; break;
7585 case VT_UINT
: V_UINT(&right
) = 2; break;
7589 /* Native VarIdiv always returns an error when using extra
7590 * flags or if the variant combination is I8 and INT.
7592 if ((leftvt
== VT_I8
&& rightvt
== VT_INT
) ||
7593 (leftvt
== VT_INT
&& rightvt
== VT_I8
) ||
7594 (rightvt
== VT_EMPTY
&& leftvt
!= VT_NULL
) ||
7598 /* Determine variant type */
7599 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
7601 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
7603 else if (leftvt
== VT_I4
|| rightvt
== VT_I4
||
7604 leftvt
== VT_INT
|| rightvt
== VT_INT
||
7605 leftvt
== VT_UINT
|| rightvt
== VT_UINT
||
7606 leftvt
== VT_UI8
|| rightvt
== VT_UI8
||
7607 leftvt
== VT_UI4
|| rightvt
== VT_UI4
||
7608 leftvt
== VT_UI2
|| rightvt
== VT_UI2
||
7609 leftvt
== VT_I1
|| rightvt
== VT_I1
||
7610 leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
||
7611 leftvt
== VT_DATE
|| rightvt
== VT_DATE
||
7612 leftvt
== VT_CY
|| rightvt
== VT_CY
||
7613 leftvt
== VT_DECIMAL
|| rightvt
== VT_DECIMAL
||
7614 leftvt
== VT_R8
|| rightvt
== VT_R8
||
7615 leftvt
== VT_R4
|| rightvt
== VT_R4
)
7617 else if (leftvt
== VT_I2
|| rightvt
== VT_I2
||
7618 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
||
7621 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
7626 hres
= pVarIdiv(&left
, &right
, &result
);
7628 /* Check expected HRESULT and if result variant type is correct */
7630 ok (hres
== DISP_E_BADVARTYPE
|| hres
== DISP_E_TYPEMISMATCH
||
7631 hres
== DISP_E_DIVBYZERO
,
7632 "VarIdiv: %s|0x%X, %s|0x%X: got vt %s hr 0x%X\n",
7633 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
],
7634 vtstr(V_VT(&result
)), hres
);
7636 ok (hres
== S_OK
&& resvt
== V_VT(&result
),
7637 "VarIdiv: %s|0x%X, %s|0x%X: expected vt %s hr 0x%X, got vt %s hr 0x%X\n",
7638 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
], vtstr(resvt
),
7639 S_OK
, vtstr(V_VT(&result
)), hres
);
7644 /* Test return values for all the good cases */
7645 VARIDIV(EMPTY
,0,NULL
,0,NULL
,0);
7646 VARIDIV(EMPTY
,0,I2
,1,I2
,0);
7647 VARIDIV(EMPTY
,0,I4
,1,I4
,0);
7648 VARIDIV(EMPTY
,0,R4
,1.0f
,I4
,0);
7649 VARIDIV(EMPTY
,0,R8
,1.0,I4
,0);
7650 VARIDIV(EMPTY
,0,DATE
,1.0,I4
,0);
7651 VARIDIV(EMPTY
,0,BSTR
,num1_str
,I4
,0);
7652 VARIDIV(EMPTY
,0,BOOL
,VARIANT_TRUE
,I2
,0);
7653 VARIDIV(EMPTY
,0,I1
,1,I4
,0);
7654 VARIDIV(EMPTY
,0,UI1
,1,I2
,0);
7655 VARIDIV(EMPTY
,0,UI2
,1,I4
,0);
7656 VARIDIV(EMPTY
,0,UI4
,1,I4
,0);
7657 if (HAVE_OLEAUT32_I8
)
7659 VARIDIV(EMPTY
,0,I8
,1,I8
,0);
7660 VARIDIV(EMPTY
,0,UI8
,1,I4
,0);
7662 VARIDIV(EMPTY
,0,INT
,1,I4
,0);
7663 VARIDIV(EMPTY
,0,UINT
,1,I4
,0);
7664 VARIDIV(NULL
,0,EMPTY
,0,NULL
,0);
7665 VARIDIV(NULL
,0,NULL
,0,NULL
,0);
7666 VARIDIV(NULL
,0,I2
,1,NULL
,0);
7667 VARIDIV(NULL
,0,I4
,1,NULL
,0);
7668 VARIDIV(NULL
,0,R4
,1,NULL
,0);
7669 VARIDIV(NULL
,0,R8
,1,NULL
,0);
7670 VARIDIV(NULL
,0,DATE
,1,NULL
,0);
7671 VARIDIV(NULL
,0,BSTR
,num1_str
,NULL
,0);
7672 VARIDIV(NULL
,0,BOOL
,VARIANT_TRUE
,NULL
,0);
7673 VARIDIV(NULL
,0,I1
,1,NULL
,0);
7674 VARIDIV(NULL
,0,UI1
,1,NULL
,0);
7675 VARIDIV(NULL
,0,UI2
,1,NULL
,0);
7676 VARIDIV(NULL
,0,UI4
,1,NULL
,0);
7677 if (HAVE_OLEAUT32_I8
)
7679 VARIDIV(NULL
,0,I8
,1,NULL
,0);
7680 VARIDIV(NULL
,0,UI8
,1,NULL
,0);
7682 VARIDIV(NULL
,0,INT
,1,NULL
,0);
7683 VARIDIV(NULL
,0,UINT
,1,NULL
,0);
7684 VARIDIV(I2
,2,NULL
,0,NULL
,0);
7685 VARIDIV(I2
,2,I2
,1,I2
,2);
7686 VARIDIV(I2
,2,I4
,1,I4
,2);
7687 VARIDIV(I2
,2,R4
,1,I4
,2);
7688 VARIDIV(I2
,2,R8
,1,I4
,2);
7689 VARIDIV(I2
,2,DATE
,1,I4
,2);
7690 VARIDIV(I2
,2,BSTR
,num1_str
,I4
,2);
7691 VARIDIV(I2
,2,BOOL
,VARIANT_TRUE
,I2
,-2);
7692 VARIDIV(I2
,2,I1
,1,I4
,2);
7693 VARIDIV(I2
,2,UI1
,1,I2
,2);
7694 VARIDIV(I2
,2,UI2
,1,I4
,2);
7695 VARIDIV(I2
,2,UI4
,1,I4
,2);
7696 if (HAVE_OLEAUT32_I8
)
7698 VARIDIV(I2
,2,I8
,1,I8
,2);
7699 VARIDIV(I2
,2,UI8
,1,I4
,2);
7701 VARIDIV(I2
,2,INT
,1,I4
,2);
7702 VARIDIV(I2
,2,UINT
,1,I4
,2);
7703 VARIDIV(I4
,2,NULL
,0,NULL
,0);
7704 VARIDIV(I4
,2,I2
,1,I4
,2);
7705 VARIDIV(I4
,2,I4
,1,I4
,2);
7706 VARIDIV(I4
,2,R4
,1,I4
,2);
7707 VARIDIV(I4
,2,R8
,1,I4
,2);
7708 VARIDIV(I4
,2,DATE
,1,I4
,2);
7709 VARIDIV(I4
,2,BSTR
,num1_str
,I4
,2);
7710 VARIDIV(I4
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
7711 VARIDIV(I4
,2,I1
,1,I4
,2);
7712 VARIDIV(I4
,2,UI1
,1,I4
,2);
7713 VARIDIV(I4
,2,UI2
,1,I4
,2);
7714 VARIDIV(I4
,2,UI4
,1,I4
,2);
7715 if (HAVE_OLEAUT32_I8
)
7717 VARIDIV(I4
,2,I8
,1,I8
,2);
7718 VARIDIV(I4
,2,UI8
,1,I4
,2);
7720 VARIDIV(I4
,2,INT
,1,I4
,2);
7721 VARIDIV(I4
,2,UINT
,1,I4
,2);
7722 VARIDIV(R4
,2.0f
,NULL
,0,NULL
,0);
7723 VARIDIV(R4
,2.0f
,I2
,1,I4
,2);
7724 VARIDIV(R4
,2.0f
,I4
,1,I4
,2);
7725 VARIDIV(R4
,2.0f
,R4
,1.0f
,I4
,2);
7726 VARIDIV(R4
,2.0f
,R8
,1.0,I4
,2);
7727 VARIDIV(R4
,2.0f
,DATE
,1,I4
,2);
7728 VARIDIV(R4
,2.0f
,BSTR
,num1_str
,I4
,2);
7729 VARIDIV(R4
,2.0f
,BOOL
,VARIANT_TRUE
,I4
,-2);
7730 VARIDIV(R4
,2.0f
,I1
,1,I4
,2);
7731 VARIDIV(R4
,2.0f
,UI1
,1,I4
,2);
7732 VARIDIV(R4
,2.0f
,UI2
,1,I4
,2);
7733 VARIDIV(R4
,2.0f
,UI4
,1,I4
,2);
7734 if (HAVE_OLEAUT32_I8
)
7736 VARIDIV(R4
,2.0f
,I8
,1,I8
,2);
7737 VARIDIV(R4
,2.0f
,UI8
,1,I4
,2);
7739 VARIDIV(R4
,2.0f
,INT
,1,I4
,2);
7740 VARIDIV(R4
,2.0f
,UINT
,1,I4
,2);
7741 VARIDIV(R8
,2.0,NULL
,0,NULL
,0);
7742 VARIDIV(R8
,2.0,I2
,1,I4
,2);
7743 VARIDIV(R8
,2.0,I4
,1,I4
,2);
7744 VARIDIV(R8
,2.0,R4
,1,I4
,2);
7745 VARIDIV(R8
,2.0,R8
,1,I4
,2);
7746 VARIDIV(R8
,2.0,DATE
,1,I4
,2);
7747 VARIDIV(R8
,2.0,BSTR
,num1_str
,I4
,2);
7748 VARIDIV(R8
,2.0,BOOL
,VARIANT_TRUE
,I4
,-2);
7749 VARIDIV(R8
,2.0,I1
,1,I4
,2);
7750 VARIDIV(R8
,2.0,UI1
,1,I4
,2);
7751 VARIDIV(R8
,2.0,UI2
,1,I4
,2);
7752 VARIDIV(R8
,2.0,UI4
,1,I4
,2);
7753 if (HAVE_OLEAUT32_I8
)
7755 VARIDIV(R8
,2.0,I8
,1,I8
,2);
7756 VARIDIV(R8
,2.0,UI8
,1,I4
,2);
7758 VARIDIV(R8
,2.0,INT
,1,I4
,2);
7759 VARIDIV(R8
,2.0,UINT
,1,I4
,2);
7760 VARIDIV(DATE
,2,NULL
,0,NULL
,0);
7761 VARIDIV(DATE
,2,I2
,1,I4
,2);
7762 VARIDIV(DATE
,2,I4
,1,I4
,2);
7763 VARIDIV(DATE
,2,R4
,1,I4
,2);
7764 VARIDIV(DATE
,2,R8
,1,I4
,2);
7765 VARIDIV(DATE
,2,DATE
,1,I4
,2);
7766 VARIDIV(DATE
,2,BSTR
,num1_str
,I4
,2);
7767 VARIDIV(DATE
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
7768 VARIDIV(DATE
,2,I1
,1,I4
,2);
7769 VARIDIV(DATE
,2,UI1
,1,I4
,2);
7770 VARIDIV(DATE
,2,UI2
,1,I4
,2);
7771 VARIDIV(DATE
,2,UI4
,1,I4
,2);
7772 if (HAVE_OLEAUT32_I8
)
7774 VARIDIV(DATE
,2,I8
,1,I8
,2);
7775 VARIDIV(DATE
,2,UI8
,1,I4
,2);
7777 VARIDIV(DATE
,2,INT
,1,I4
,2);
7778 VARIDIV(DATE
,2,UINT
,1,I4
,2);
7779 VARIDIV(BSTR
,num2_str
,NULL
,0,NULL
,0);
7780 VARIDIV(BSTR
,num2_str
,I2
,1,I4
,2);
7781 VARIDIV(BSTR
,num2_str
,I4
,1,I4
,2);
7782 VARIDIV(BSTR
,num2_str
,R4
,1.0f
,I4
,2);
7783 VARIDIV(BSTR
,num2_str
,R8
,1.0,I4
,2);
7784 VARIDIV(BSTR
,num2_str
,DATE
,1,I4
,2);
7785 VARIDIV(BSTR
,num2_str
,BSTR
,num1_str
,I4
,2);
7786 VARIDIV(BSTR
,num2_str
,BOOL
,VARIANT_TRUE
,I4
,-2);
7787 VARIDIV(BSTR
,num2_str
,I1
,1,I4
,2);
7788 VARIDIV(BSTR
,num2_str
,UI1
,1,I4
,2);
7789 VARIDIV(BSTR
,num2_str
,UI2
,1,I4
,2);
7790 VARIDIV(BSTR
,num2_str
,UI4
,1,I4
,2);
7791 if (HAVE_OLEAUT32_I8
)
7793 VARIDIV(BSTR
,num2_str
,I8
,1,I8
,2);
7794 VARIDIV(BSTR
,num2_str
,UI8
,1,I4
,2);
7796 VARIDIV(BSTR
,num2_str
,INT
,1,I4
,2);
7797 VARIDIV(BSTR
,num2_str
,UINT
,1,I4
,2);
7798 VARIDIV(BOOL
,VARIANT_TRUE
,NULL
,0,NULL
,0);
7799 VARIDIV(BOOL
,VARIANT_TRUE
,I2
,1,I2
,-1);
7800 VARIDIV(BOOL
,VARIANT_TRUE
,I4
,1,I4
,-1);
7801 VARIDIV(BOOL
,VARIANT_TRUE
,R4
,1.0f
,I4
,-1);
7802 VARIDIV(BOOL
,VARIANT_TRUE
,R8
,1.0,I4
,-1);
7803 VARIDIV(BOOL
,VARIANT_TRUE
,DATE
,1,I4
,-1);
7804 VARIDIV(BOOL
,VARIANT_TRUE
,BSTR
,num1_str
,I4
,-1);
7805 VARIDIV(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
,I2
,1);
7806 VARIDIV(BOOL
,VARIANT_TRUE
,I1
,1,I4
,-1);
7807 VARIDIV(BOOL
,VARIANT_TRUE
,UI1
,1,I2
,-1);
7808 VARIDIV(BOOL
,VARIANT_TRUE
,UI2
,1,I4
,-1);
7809 VARIDIV(BOOL
,VARIANT_TRUE
,UI4
,1,I4
,-1);
7810 if (HAVE_OLEAUT32_I8
)
7812 VARIDIV(BOOL
,VARIANT_TRUE
,I8
,1,I8
,-1);
7813 VARIDIV(BOOL
,VARIANT_TRUE
,UI8
,1,I4
,-1);
7815 VARIDIV(BOOL
,VARIANT_TRUE
,INT
,1,I4
,-1);
7816 VARIDIV(BOOL
,VARIANT_TRUE
,UINT
,1,I4
,-1);
7817 VARIDIV(I1
,2,NULL
,0,NULL
,0);
7818 VARIDIV(I1
,2,I2
,1,I4
,2);
7819 VARIDIV(I1
,2,I4
,1,I4
,2);
7820 VARIDIV(I1
,2,R4
,1.0f
,I4
,2);
7821 VARIDIV(I1
,2,R8
,1.0,I4
,2);
7822 VARIDIV(I1
,2,DATE
,1,I4
,2);
7823 VARIDIV(I1
,2,BSTR
,num1_str
,I4
,2);
7824 VARIDIV(I1
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
7825 VARIDIV(I1
,2,I1
,1,I4
,2);
7826 VARIDIV(I1
,2,UI1
,1,I4
,2);
7827 VARIDIV(I1
,2,UI2
,1,I4
,2);
7828 VARIDIV(I1
,2,UI4
,1,I4
,2);
7829 if (HAVE_OLEAUT32_I8
)
7831 VARIDIV(I1
,2,I8
,1,I8
,2);
7832 VARIDIV(I1
,2,UI8
,1,I4
,2);
7834 VARIDIV(I1
,2,INT
,1,I4
,2);
7835 VARIDIV(I1
,2,UINT
,1,I4
,2);
7836 VARIDIV(UI1
,2,NULL
,0,NULL
,0);
7837 VARIDIV(UI1
,2,I2
,1,I2
,2);
7838 VARIDIV(UI1
,2,I4
,1,I4
,2);
7839 VARIDIV(UI1
,2,R4
,1.0f
,I4
,2);
7840 VARIDIV(UI1
,2,R8
,1.0,I4
,2);
7841 VARIDIV(UI1
,2,DATE
,1,I4
,2);
7842 VARIDIV(UI1
,2,BSTR
,num1_str
,I4
,2);
7843 VARIDIV(UI1
,2,BOOL
,VARIANT_TRUE
,I2
,-2);
7844 VARIDIV(UI1
,2,I1
,1,I4
,2);
7845 VARIDIV(UI1
,2,UI1
,1,UI1
,2);
7846 VARIDIV(UI1
,2,UI2
,1,I4
,2);
7847 VARIDIV(UI1
,2,UI4
,1,I4
,2);
7848 if (HAVE_OLEAUT32_I8
)
7850 VARIDIV(UI1
,2,I8
,1,I8
,2);
7851 VARIDIV(UI1
,2,UI8
,1,I4
,2);
7853 VARIDIV(UI1
,2,INT
,1,I4
,2);
7854 VARIDIV(UI1
,2,UINT
,1,I4
,2);
7855 VARIDIV(UI2
,2,NULL
,0,NULL
,0);
7856 VARIDIV(UI2
,2,I2
,1,I4
,2);
7857 VARIDIV(UI2
,2,I4
,1,I4
,2);
7858 VARIDIV(UI2
,2,R4
,1.0f
,I4
,2);
7859 VARIDIV(UI2
,2,R8
,1.0,I4
,2);
7860 VARIDIV(UI2
,2,DATE
,1,I4
,2);
7861 VARIDIV(UI2
,2,BSTR
,num1_str
,I4
,2);
7862 VARIDIV(UI2
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
7863 VARIDIV(UI2
,2,I1
,1,I4
,2);
7864 VARIDIV(UI2
,2,UI1
,1,I4
,2);
7865 VARIDIV(UI2
,2,UI2
,1,I4
,2);
7866 VARIDIV(UI2
,2,UI4
,1,I4
,2);
7867 if (HAVE_OLEAUT32_I8
)
7869 VARIDIV(UI2
,2,I8
,1,I8
,2);
7870 VARIDIV(UI2
,2,UI8
,1,I4
,2);
7872 VARIDIV(UI2
,2,INT
,1,I4
,2);
7873 VARIDIV(UI2
,2,UINT
,1,I4
,2);
7874 VARIDIV(UI4
,2,NULL
,0,NULL
,0);
7875 VARIDIV(UI4
,2,I2
,1,I4
,2);
7876 VARIDIV(UI4
,2,I4
,1,I4
,2);
7877 VARIDIV(UI4
,2,R4
,1.0f
,I4
,2);
7878 VARIDIV(UI4
,2,R8
,1.0,I4
,2);
7879 VARIDIV(UI4
,2,DATE
,1,I4
,2);
7880 VARIDIV(UI4
,2,BSTR
,num1_str
,I4
,2);
7881 VARIDIV(UI4
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
7882 VARIDIV(UI4
,2,I1
,1,I4
,2);
7883 VARIDIV(UI4
,2,UI1
,1,I4
,2);
7884 VARIDIV(UI4
,2,UI2
,1,I4
,2);
7885 VARIDIV(UI4
,2,UI4
,1,I4
,2);
7886 if (HAVE_OLEAUT32_I8
)
7888 VARIDIV(UI4
,2,I8
,1,I8
,2);
7889 VARIDIV(UI4
,2,UI8
,1,I4
,2);
7891 VARIDIV(UI4
,2,INT
,1,I4
,2);
7892 VARIDIV(UI4
,2,UINT
,1,I4
,2);
7893 if (HAVE_OLEAUT32_I8
)
7895 VARIDIV(I8
,2,NULL
,0,NULL
,0);
7896 VARIDIV(I8
,2,I2
,1,I8
,2);
7897 VARIDIV(I8
,2,I4
,1,I8
,2);
7898 VARIDIV(I8
,2,R4
,1.0f
,I8
,2);
7899 VARIDIV(I8
,2,R8
,1.0,I8
,2);
7900 VARIDIV(I8
,2,DATE
,1,I8
,2);
7901 VARIDIV(I8
,2,BSTR
,num1_str
,I8
,2);
7902 VARIDIV(I8
,2,BOOL
,1,I8
,2);
7903 VARIDIV(I8
,2,I1
,1,I8
,2);
7904 VARIDIV(I8
,2,UI1
,1,I8
,2);
7905 VARIDIV(I8
,2,UI2
,1,I8
,2);
7906 VARIDIV(I8
,2,UI4
,1,I8
,2);
7907 VARIDIV(I8
,2,I8
,1,I8
,2);
7908 VARIDIV(I8
,2,UI8
,1,I8
,2);
7909 VARIDIV(I8
,2,UINT
,1,I8
,2);
7910 VARIDIV(UI8
,2,NULL
,0,NULL
,0);
7911 VARIDIV(UI8
,2,I2
,1,I4
,2);
7912 VARIDIV(UI8
,2,I4
,1,I4
,2);
7913 VARIDIV(UI8
,2,R4
,1.0f
,I4
,2);
7914 VARIDIV(UI8
,2,R8
,1.0,I4
,2);
7915 VARIDIV(UI8
,2,DATE
,1,I4
,2);
7916 VARIDIV(UI8
,2,BSTR
,num1_str
,I4
,2);
7917 VARIDIV(UI8
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
7918 VARIDIV(UI8
,2,I1
,1,I4
,2);
7919 VARIDIV(UI8
,2,UI1
,1,I4
,2);
7920 VARIDIV(UI8
,2,UI2
,1,I4
,2);
7921 VARIDIV(UI8
,2,UI4
,1,I4
,2);
7922 VARIDIV(UI8
,2,I8
,1,I8
,2);
7923 VARIDIV(UI8
,2,UI8
,1,I4
,2);
7924 VARIDIV(UI8
,2,INT
,1,I4
,2);
7925 VARIDIV(UI8
,2,UINT
,1,I4
,2);
7927 VARIDIV(INT
,2,NULL
,0,NULL
,0);
7928 VARIDIV(INT
,2,I2
,1,I4
,2);
7929 VARIDIV(INT
,2,I4
,1,I4
,2);
7930 VARIDIV(INT
,2,R4
,1.0f
,I4
,2);
7931 VARIDIV(INT
,2,R8
,1.0,I4
,2);
7932 VARIDIV(INT
,2,DATE
,1,I4
,2);
7933 VARIDIV(INT
,2,BSTR
,num1_str
,I4
,2);
7934 VARIDIV(INT
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
7935 VARIDIV(INT
,2,I1
,1,I4
,2);
7936 VARIDIV(INT
,2,UI1
,1,I4
,2);
7937 VARIDIV(INT
,2,UI2
,1,I4
,2);
7938 VARIDIV(INT
,2,UI4
,1,I4
,2);
7939 if (HAVE_OLEAUT32_I8
)
7941 VARIDIV(INT
,2,UI8
,1,I4
,2);
7943 VARIDIV(INT
,2,INT
,1,I4
,2);
7944 VARIDIV(INT
,2,UINT
,1,I4
,2);
7945 VARIDIV(UINT
,2,NULL
,0,NULL
,0);
7946 VARIDIV(UINT
,2,I2
,1,I4
,2);
7947 VARIDIV(UINT
,2,I4
,1,I4
,2);
7948 VARIDIV(UINT
,2,R4
,1.0f
,I4
,2);
7949 VARIDIV(UINT
,2,R8
,1.0,I4
,2);
7950 VARIDIV(UINT
,2,DATE
,1,I4
,2);
7951 VARIDIV(UINT
,2,BSTR
,num1_str
,I4
,2);
7952 VARIDIV(UINT
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
7953 VARIDIV(UINT
,2,I1
,1,I4
,2);
7954 VARIDIV(UINT
,2,UI1
,1,I4
,2);
7955 VARIDIV(UINT
,2,UI2
,1,I4
,2);
7956 VARIDIV(UINT
,2,UI4
,1,I4
,2);
7957 if (HAVE_OLEAUT32_I8
)
7959 VARIDIV(UINT
,2,I8
,1,I8
,2);
7960 VARIDIV(UINT
,2,UI8
,1,I4
,2);
7962 VARIDIV(UINT
,2,INT
,1,I4
,2);
7963 VARIDIV(UINT
,2,UINT
,1,I4
,2);
7965 /* Manually test some VT_CY, VT_DECIMAL variants */
7967 hres
= VarCyFromI4(10000, &V_CY(&cy
));
7968 ok(hres
== S_OK
, "VarCyFromI4 failed!\n");
7969 V_VT(&dec
) = VT_DECIMAL
;
7970 hres
= VarDecFromR8(2.0, &V_DECIMAL(&dec
));
7971 ok(hres
== S_OK
, "VarDecFromR4 failed!\n");
7972 memset(&left
, 0, sizeof(left
));
7973 memset(&right
, 0, sizeof(right
));
7974 V_VT(&left
) = VT_I4
;
7976 V_VT(&right
) = VT_I8
;
7979 hres
= VarIdiv(&cy
, &cy
, &result
);
7980 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
7981 "VARIDIV: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
7982 S_OK
, hres
, vtstr(V_VT(&result
)));
7983 ok(hres
== S_OK
&& V_I4(&result
) == 1,
7984 "VARIDIV: CY value %d, expected %d\n", V_I4(&result
), 1);
7986 if (HAVE_OLEAUT32_I8
)
7988 hres
= VarIdiv(&cy
, &right
, &result
);
7989 ok(hres
== S_OK
&& V_VT(&result
) == VT_I8
,
7990 "VARIDIV: expected coerced hres 0x%X type VT_I8, got hres 0x%X type %s!\n",
7991 S_OK
, hres
, vtstr(V_VT(&result
)));
7992 ok(hres
== S_OK
&& V_I8(&result
) == 5000,
7993 "VARIDIV: CY value 0x%x%08x, expected 0x%x\n",
7994 (DWORD
)(V_I8(&result
) >>32), (DWORD
)V_I8(&result
), 5000);
7997 hres
= VarIdiv(&left
, &cy
, &result
);
7998 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
7999 "VARIDIV: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8000 S_OK
, hres
, vtstr(V_VT(&result
)));
8001 ok(hres
== S_OK
&& V_I4(&result
) == 0,
8002 "VARIDIV: CY value %d, expected %d\n", V_I4(&result
), 0);
8004 hres
= VarIdiv(&left
, &dec
, &result
);
8005 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
8006 "VARIDIV: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8007 S_OK
, hres
, vtstr(V_VT(&result
)));
8008 ok(hres
== S_OK
&& V_I4(&result
) == 50,
8009 "VARIDIV: DECIMAL value %d, expected %d\n", V_I4(&result
), 50);
8011 hres
= VarIdiv(&dec
, &dec
, &result
);
8012 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
8013 "VARIDIV: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8014 S_OK
, hres
, vtstr(V_VT(&result
)));
8015 ok(hres
== S_OK
&& V_I4(&result
) == 1,
8016 "VARIDIV: DECIMAL value %d, expected %d\n", V_I4(&result
), 1);
8018 if (HAVE_OLEAUT32_I8
)
8020 hres
= VarIdiv(&dec
, &right
, &result
);
8021 ok(hres
== S_OK
&& V_VT(&result
) == VT_I8
,
8022 "VARIDIV: expected coerced hres 0x%X type VT_I8, got hres 0x%X type %s!\n",
8023 S_OK
, hres
, vtstr(V_VT(&result
)));
8024 ok(hres
== S_OK
&& V_I8(&result
) == 1,
8025 "VARIDIV: DECIMAL value 0x%x%08x, expected %d\n",
8026 (DWORD
)(V_I8(&result
) >> 32), (DWORD
)V_I8(&result
), 1);
8029 /* Check for division by zero */
8030 V_VT(&left
) = VT_INT
;
8032 V_VT(&right
) = VT_INT
;
8034 hres
= pVarIdiv(&left
, &right
, &result
);
8035 ok(hres
== DISP_E_DIVBYZERO
&& V_VT(&result
) == VT_EMPTY
,
8036 "VARIDIV: Division by 0 should result in DISP_E_DIVBYZERO but got 0x%X\n", hres
);
8038 V_VT(&left
) = VT_INT
;
8040 V_VT(&right
) = VT_INT
;
8042 hres
= pVarIdiv(&left
, &right
, &result
);
8043 ok(hres
== DISP_E_DIVBYZERO
&& V_VT(&result
) == VT_EMPTY
,
8044 "VARIDIV: Division by 0 should result in DISP_E_DIVBYZERO but got 0x%X\n", hres
);
8046 SysFreeString(num1_str
);
8047 SysFreeString(num2_str
);
8051 static HRESULT (WINAPI
*pVarImp
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
8053 #define VARIMP(vt1,val1,vt2,val2,rvt,rval) \
8054 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
8055 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
8056 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
8057 test_var_call2( __LINE__, pVarImp, &left, &right, &exp )
8059 /* Skip any type that is not defined or produces an error for every case */
8060 #define SKIPTESTIMP(a) \
8061 if (a == VT_ERROR || a == VT_VARIANT || \
8062 a == VT_DISPATCH || a == VT_UNKNOWN || \
8063 a == VT_RECORD || a > VT_UINT || \
8064 a == 15 /*not defined*/) \
8067 static void test_VarImp(void)
8069 static const WCHAR szFalse
[] = { '#','F','A','L','S','E','#','\0' };
8070 static const WCHAR szTrue
[] = { '#','T','R','U','E','#','\0' };
8071 VARIANT left
, right
, exp
, result
, cy
, dec
;
8072 BSTR true_str
, false_str
;
8078 true_str
= SysAllocString(szTrue
);
8079 false_str
= SysAllocString(szFalse
);
8081 /* Test all possible flag/vt combinations & the resulting vt type */
8082 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
8084 VARTYPE leftvt
, rightvt
, resvt
;
8086 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
8088 SKIPTESTIMP(leftvt
);
8090 /* Check if we need/have support for I8 and/or UI8 */
8091 if ((leftvt
== VT_I8
|| leftvt
== VT_UI8
) && !HAVE_OLEAUT32_I8
)
8094 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
8097 SKIPTESTIMP(rightvt
);
8099 /* Native crashes when using the extra flag VT_BYREF
8100 * or with the following VT combinations
8102 if ((leftvt
== VT_UI4
&& rightvt
== VT_BSTR
) ||
8103 (leftvt
== VT_UI8
&& rightvt
== VT_BSTR
) ||
8104 ExtraFlags
[i
] == VT_BYREF
)
8107 /* Check if we need/have support for I8 and/or UI8 */
8108 if ((rightvt
== VT_I8
|| rightvt
== VT_UI8
) && !HAVE_OLEAUT32_I8
)
8111 memset(&left
, 0, sizeof(left
));
8112 memset(&right
, 0, sizeof(right
));
8113 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
8114 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
8115 V_VT(&result
) = VT_EMPTY
;
8118 if (leftvt
== VT_BSTR
)
8119 V_BSTR(&left
) = true_str
;
8121 /* This allows us to test return types that are not NULL
8122 * (NULL Imp value = n, NULL Imp 0 = NULL)
8127 V_BSTR(&right
) = true_str
;
8130 VarDecFromR8(2.0, &V_DECIMAL(&right
));
8131 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
8134 V_BOOL(&right
) = VARIANT_TRUE
;
8136 case VT_I1
: V_I1(&right
) = 2; break;
8137 case VT_I2
: V_I2(&right
) = 2; break;
8138 case VT_I4
: V_I4(&right
) = 2; break;
8139 case VT_R4
: V_R4(&right
) = 2.0f
; break;
8140 case VT_R8
: V_R8(&right
) = 2.0; break;
8141 case VT_CY
: V_CY(&right
).int64
= 10000; break;
8142 case VT_DATE
: V_DATE(&right
) = 2; break;
8143 case VT_I8
: V_I8(&right
) = 2; break;
8144 case VT_INT
: V_INT(&right
) = 2; break;
8145 case VT_UINT
: V_UINT(&right
) = 2; break;
8146 case VT_UI1
: V_UI1(&right
) = 2; break;
8147 case VT_UI2
: V_UI2(&right
) = 2; break;
8148 case VT_UI4
: V_UI4(&right
) = 2; break;
8149 case VT_UI8
: V_UI8(&right
) = 2; break;
8153 /* Native VarImp always returns an error when using extra
8154 * flags or if the variants are I8 and INT.
8156 if ((leftvt
== VT_I8
&& rightvt
== VT_INT
) ||
8160 /* Determine result type */
8161 else if ((leftvt
== VT_BSTR
&& rightvt
== VT_NULL
) ||
8162 (leftvt
== VT_NULL
&& rightvt
== VT_NULL
) ||
8163 (leftvt
== VT_NULL
&& rightvt
== VT_EMPTY
))
8165 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
8167 else if (leftvt
== VT_I4
|| rightvt
== VT_I4
||
8168 leftvt
== VT_INT
|| rightvt
== VT_INT
||
8169 leftvt
== VT_UINT
|| rightvt
== VT_UINT
||
8170 leftvt
== VT_UI4
|| rightvt
== VT_UI4
||
8171 leftvt
== VT_UI8
|| rightvt
== VT_UI8
||
8172 leftvt
== VT_UI2
|| rightvt
== VT_UI2
||
8173 leftvt
== VT_DECIMAL
|| rightvt
== VT_DECIMAL
||
8174 leftvt
== VT_DATE
|| rightvt
== VT_DATE
||
8175 leftvt
== VT_CY
|| rightvt
== VT_CY
||
8176 leftvt
== VT_R8
|| rightvt
== VT_R8
||
8177 leftvt
== VT_R4
|| rightvt
== VT_R4
||
8178 leftvt
== VT_I1
|| rightvt
== VT_I1
)
8180 else if ((leftvt
== VT_UI1
&& rightvt
== VT_UI1
) ||
8181 (leftvt
== VT_UI1
&& rightvt
== VT_NULL
) ||
8182 (leftvt
== VT_NULL
&& rightvt
== VT_UI1
))
8184 else if (leftvt
== VT_EMPTY
|| rightvt
== VT_EMPTY
||
8185 leftvt
== VT_I2
|| rightvt
== VT_I2
||
8186 leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
8188 else if (leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
||
8189 leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
)
8192 hres
= pVarImp(&left
, &right
, &result
);
8194 /* Check expected HRESULT and if result variant type is correct */
8196 ok (hres
== DISP_E_BADVARTYPE
|| hres
== DISP_E_TYPEMISMATCH
,
8197 "VarImp: %s|0x%X, %s|0x%X: got vt %s hr 0x%X\n",
8198 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
],
8199 vtstr(V_VT(&result
)), hres
);
8201 ok (hres
== S_OK
&& resvt
== V_VT(&result
),
8202 "VarImp: %s|0x%X, %s|0x%X: expected vt %s hr 0x%X, got vt %s hr 0x%X\n",
8203 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
], vtstr(resvt
),
8204 S_OK
, vtstr(V_VT(&result
)), hres
);
8209 VARIMP(EMPTY
,0,EMPTY
,0,I2
,-1);
8210 VARIMP(EMPTY
,0,NULL
,0,I2
,-1);
8211 VARIMP(EMPTY
,0,I2
,-1,I2
,-1);
8212 VARIMP(EMPTY
,0,I4
,-1,I4
,-1);
8213 VARIMP(EMPTY
,0,R4
,0.0f
,I4
,-1);
8214 VARIMP(EMPTY
,0,R8
,-1.0,I4
,-1);
8215 VARIMP(EMPTY
,0,DATE
,0,I4
,-1);
8216 VARIMP(EMPTY
,0,BSTR
,true_str
,I2
,-1);
8217 VARIMP(EMPTY
,0,BOOL
,VARIANT_FALSE
,I2
,-1);
8218 VARIMP(EMPTY
,0,I1
,0,I4
,-1);
8219 VARIMP(EMPTY
,0,UI1
,1,I2
,-1);
8220 VARIMP(EMPTY
,0,UI2
,1,I4
,-1);
8221 VARIMP(EMPTY
,0,UI4
,1,I4
,-1);
8222 if (HAVE_OLEAUT32_I8
)
8224 VARIMP(EMPTY
,0,I8
,1,I8
,-1);
8225 VARIMP(EMPTY
,0,UI8
,1,I4
,-1);
8227 VARIMP(EMPTY
,0,INT
,-1,I4
,-1);
8228 VARIMP(EMPTY
,0,UINT
,1,I4
,-1);
8229 VARIMP(NULL
,0,EMPTY
,0,NULL
,0);
8230 VARIMP(NULL
,0,NULL
,0,NULL
,0);
8231 VARIMP(NULL
,0,I2
,-1,I2
,-1);
8232 VARIMP(NULL
,0,I4
,-1,I4
,-1);
8233 VARIMP(NULL
,0,R4
,0.0f
,NULL
,0);
8234 VARIMP(NULL
,0,R8
,-1.0,I4
,-1);
8235 VARIMP(NULL
,0,DATE
,0,NULL
,0);
8236 VARIMP(NULL
,0,BSTR
,true_str
,BOOL
,-1);
8237 VARIMP(NULL
,0,BOOL
,VARIANT_FALSE
,NULL
,0);
8238 VARIMP(NULL
,0,I1
,0,NULL
,0);
8239 VARIMP(NULL
,0,UI1
,1,UI1
,1);
8240 VARIMP(NULL
,0,UI2
,1,I4
,1);
8241 VARIMP(NULL
,0,UI4
,1,I4
,1);
8242 if (HAVE_OLEAUT32_I8
)
8244 VARIMP(NULL
,0,I8
,1,I8
,1);
8245 VARIMP(NULL
,0,UI8
,1,I4
,1);
8247 VARIMP(NULL
,0,INT
,-1,I4
,-1);
8248 VARIMP(NULL
,0,UINT
,1,I4
,1);
8249 VARIMP(I2
,-1,EMPTY
,0,I2
,0);
8250 VARIMP(I2
,-1,I2
,-1,I2
,-1);
8251 VARIMP(I2
,-1,I4
,-1,I4
,-1);
8252 VARIMP(I2
,-1,R4
,0.0f
,I4
,0);
8253 VARIMP(I2
,-1,R8
,-1.0,I4
,-1);
8254 VARIMP(I2
,-1,DATE
,0,I4
,0);
8255 VARIMP(I2
,-1,BSTR
,true_str
,I2
,-1);
8256 VARIMP(I2
,-1,BOOL
,VARIANT_FALSE
,I2
,0);
8257 VARIMP(I2
,-1,I1
,0,I4
,0);
8258 VARIMP(I2
,-1,UI1
,1,I2
,1);
8259 VARIMP(I2
,-1,UI2
,1,I4
,1);
8260 VARIMP(I2
,-1,UI4
,1,I4
,1);
8261 if (HAVE_OLEAUT32_I8
)
8263 VARIMP(I2
,-1,I8
,1,I8
,1);
8264 VARIMP(I2
,-1,UI8
,1,I4
,1);
8266 VARIMP(I2
,-1,INT
,-1,I4
,-1);
8267 VARIMP(I2
,-1,UINT
,1,I4
,1);
8268 VARIMP(I4
,2,EMPTY
,0,I4
,-3);
8269 VARIMP(I4
,2,NULL
,0,I4
,-3);
8270 VARIMP(I4
,2,I2
,-1,I4
,-1);
8271 VARIMP(I4
,2,I4
,-1,I4
,-1);
8272 VARIMP(I4
,2,R4
,0.0f
,I4
,-3);
8273 VARIMP(I4
,2,R8
,-1.0,I4
,-1);
8274 VARIMP(I4
,2,DATE
,0,I4
,-3);
8275 VARIMP(I4
,2,BSTR
,true_str
,I4
,-1);
8276 VARIMP(I4
,2,BOOL
,VARIANT_FALSE
,I4
,-3);
8277 VARIMP(I4
,2,I1
,0,I4
,-3);
8278 VARIMP(I4
,2,UI1
,1,I4
,-3);
8279 VARIMP(I4
,2,UI2
,1,I4
,-3);
8280 VARIMP(I4
,2,UI4
,1,I4
,-3);
8281 if (HAVE_OLEAUT32_I8
)
8283 VARIMP(I4
,2,I8
,1,I8
,-3);
8284 VARIMP(I4
,2,UI8
,1,I4
,-3);
8286 VARIMP(I4
,2,INT
,-1,I4
,-1);
8287 VARIMP(I4
,2,UINT
,1,I4
,-3);
8288 VARIMP(R4
,-1.0f
,EMPTY
,0,I4
,0);
8289 VARIMP(R4
,-1.0f
,NULL
,0,NULL
,0);
8290 VARIMP(R4
,-1.0f
,I2
,-1,I4
,-1);
8291 VARIMP(R4
,-1.0f
,I4
,-1,I4
,-1);
8292 VARIMP(R4
,-1.0f
,R4
,0.0f
,I4
,0);
8293 VARIMP(R4
,-1.0f
,R8
,-1.0,I4
,-1);
8294 VARIMP(R4
,-1.0f
,DATE
,1,I4
,1);
8295 VARIMP(R4
,-1.0f
,BSTR
,true_str
,I4
,-1);
8296 VARIMP(R4
,-1.0f
,BOOL
,VARIANT_FALSE
,I4
,0);
8297 VARIMP(R4
,-1.0f
,I1
,0,I4
,0);
8298 VARIMP(R4
,-1.0f
,UI1
,1,I4
,1);
8299 VARIMP(R4
,-1.0f
,UI2
,1,I4
,1);
8300 VARIMP(R4
,-1.0f
,UI4
,1,I4
,1);
8301 if (HAVE_OLEAUT32_I8
)
8303 VARIMP(R4
,-1.0f
,I8
,1,I8
,1);
8304 VARIMP(R4
,-1.0f
,UI8
,1,I4
,1);
8306 VARIMP(R4
,-1.0f
,INT
,-1,I4
,-1);
8307 VARIMP(R4
,-1.0f
,UINT
,1,I4
,1);
8308 VARIMP(R8
,1.0,EMPTY
,0,I4
,-2);
8309 VARIMP(R8
,1.0,NULL
,0,I4
,-2);
8310 VARIMP(R8
,1.0,I2
,-1,I4
,-1);
8311 VARIMP(R8
,1.0,I4
,-1,I4
,-1);
8312 VARIMP(R8
,1.0,R4
,0.0f
,I4
,-2);
8313 VARIMP(R8
,1.0,R8
,-1.0,I4
,-1);
8314 VARIMP(R8
,1.0,DATE
,0,I4
,-2);
8315 VARIMP(R8
,1.0,BSTR
,true_str
,I4
,-1);
8316 VARIMP(R8
,1.0,BOOL
,VARIANT_FALSE
,I4
,-2);
8317 VARIMP(R8
,1.0,I1
,0,I4
,-2);
8318 VARIMP(R8
,1.0,UI1
,1,I4
,-1);
8319 VARIMP(R8
,1.0,UI2
,1,I4
,-1);
8320 VARIMP(R8
,1.0,UI4
,1,I4
,-1);
8321 if (HAVE_OLEAUT32_I8
)
8323 VARIMP(R8
,1.0,I8
,1,I8
,-1);
8324 VARIMP(R8
,1.0,UI8
,1,I4
,-1);
8326 VARIMP(R8
,1.0,INT
,-1,I4
,-1);
8327 VARIMP(R8
,1.0,UINT
,1,I4
,-1);
8328 VARIMP(DATE
,0,EMPTY
,0,I4
,-1);
8329 VARIMP(DATE
,0,NULL
,0,I4
,-1);
8330 VARIMP(DATE
,0,I2
,-1,I4
,-1);
8331 VARIMP(DATE
,0,I4
,-1,I4
,-1);
8332 VARIMP(DATE
,0,R4
,0.0f
,I4
,-1);
8333 VARIMP(DATE
,0,R8
,-1.0,I4
,-1);
8334 VARIMP(DATE
,0,DATE
,0,I4
,-1);
8335 VARIMP(DATE
,0,BSTR
,true_str
,I4
,-1);
8336 VARIMP(DATE
,0,BOOL
,VARIANT_FALSE
,I4
,-1);
8337 VARIMP(DATE
,0,I1
,0,I4
,-1);
8338 VARIMP(DATE
,0,UI1
,1,I4
,-1);
8339 VARIMP(DATE
,0,UI2
,1,I4
,-1);
8340 VARIMP(DATE
,0,UI4
,1,I4
,-1);
8341 if (HAVE_OLEAUT32_I8
)
8343 VARIMP(DATE
,0,I8
,1,I8
,-1);
8344 VARIMP(DATE
,0,UI8
,1,I4
,-1);
8346 VARIMP(DATE
,0,INT
,-1,I4
,-1);
8347 VARIMP(DATE
,0,UINT
,1,I4
,-1);
8348 VARIMP(BSTR
,false_str
,EMPTY
,0,I2
,-1);
8349 VARIMP(BSTR
,false_str
,NULL
,0,BOOL
,-1);
8350 VARIMP(BSTR
,false_str
,I2
,-1,I2
,-1);
8351 VARIMP(BSTR
,false_str
,I4
,-1,I4
,-1);
8352 VARIMP(BSTR
,false_str
,R4
,0.0f
,I4
,-1);
8353 VARIMP(BSTR
,false_str
,R8
,-1.0,I4
,-1);
8354 VARIMP(BSTR
,false_str
,DATE
,0,I4
,-1);
8355 VARIMP(BSTR
,false_str
,BSTR
,true_str
,BOOL
,-1);
8356 VARIMP(BSTR
,false_str
,BOOL
,VARIANT_FALSE
,BOOL
,-1);
8357 VARIMP(BSTR
,false_str
,I1
,0,I4
,-1);
8358 VARIMP(BSTR
,false_str
,UI1
,1,I2
,-1);
8359 VARIMP(BSTR
,false_str
,UI2
,1,I4
,-1);
8360 VARIMP(BSTR
,false_str
,UI4
,1,I4
,-1);
8361 if (HAVE_OLEAUT32_I8
)
8363 VARIMP(BSTR
,false_str
,I8
,1,I8
,-1);
8364 VARIMP(BSTR
,false_str
,UI8
,1,I4
,-1);
8366 VARIMP(BSTR
,false_str
,INT
,-1,I4
,-1);
8367 VARIMP(BSTR
,false_str
,UINT
,1,I4
,-1);
8368 VARIMP(BOOL
,VARIANT_TRUE
,EMPTY
,0,I2
,0);
8369 VARIMP(BOOL
,VARIANT_TRUE
,NULL
,0,NULL
,0);
8370 VARIMP(BOOL
,VARIANT_TRUE
,I2
,-1,I2
,-1);
8371 VARIMP(BOOL
,VARIANT_TRUE
,I4
,-1,I4
,-1);
8372 VARIMP(BOOL
,VARIANT_TRUE
,R4
,0.0f
,I4
,0);
8373 VARIMP(BOOL
,VARIANT_TRUE
,R8
,-1.0,I4
,-1);
8374 VARIMP(BOOL
,VARIANT_TRUE
,DATE
,0,I4
,0);
8375 VARIMP(BOOL
,VARIANT_TRUE
,BSTR
,true_str
,BOOL
,-1);
8376 VARIMP(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
,BOOL
,0);
8377 VARIMP(BOOL
,VARIANT_TRUE
,I1
,0,I4
,0);
8378 VARIMP(BOOL
,VARIANT_TRUE
,UI1
,1,I2
,1);
8379 VARIMP(BOOL
,VARIANT_TRUE
,UI2
,1,I4
,1);
8380 VARIMP(BOOL
,VARIANT_TRUE
,UI4
,1,I4
,1);
8381 if (HAVE_OLEAUT32_I8
)
8383 VARIMP(BOOL
,VARIANT_TRUE
,I8
,1,I8
,1);
8384 VARIMP(BOOL
,VARIANT_TRUE
,UI8
,1,I4
,1);
8386 VARIMP(BOOL
,VARIANT_TRUE
,INT
,-1,I4
,-1);
8387 VARIMP(BOOL
,VARIANT_TRUE
,UINT
,1,I4
,1);
8388 VARIMP(I1
,-1,EMPTY
,0,I4
,0);
8389 VARIMP(I1
,-1,NULL
,0,NULL
,0);
8390 VARIMP(I1
,-1,I2
,-1,I4
,-1);
8391 VARIMP(I1
,-1,I4
,-1,I4
,-1);
8392 VARIMP(I1
,-1,R4
,0.0f
,I4
,0);
8393 VARIMP(I1
,-1,R8
,-1.0,I4
,-1);
8394 VARIMP(I1
,-1,DATE
,0,I4
,0);
8395 VARIMP(I1
,-1,BSTR
,true_str
,I4
,-1);
8396 VARIMP(I1
,-1,BOOL
,VARIANT_FALSE
,I4
,0);
8397 VARIMP(I1
,-1,I1
,0,I4
,0);
8398 VARIMP(I1
,-1,UI1
,1,I4
,1);
8399 VARIMP(I1
,-1,UI2
,1,I4
,1);
8400 VARIMP(I1
,-1,UI4
,1,I4
,1);
8401 if (HAVE_OLEAUT32_I8
)
8403 VARIMP(I1
,-1,I8
,1,I8
,1);
8404 VARIMP(I1
,-1,UI8
,1,I4
,1);
8406 VARIMP(I1
,-1,INT
,-1,I4
,-1);
8407 VARIMP(I1
,-1,UINT
,1,I4
,1);
8408 VARIMP(UI1
,0,EMPTY
,0,I2
,-1);
8409 VARIMP(UI1
,0,NULL
,0,UI1
,255);
8410 VARIMP(UI1
,0,I2
,-1,I2
,-1);
8411 VARIMP(UI1
,0,I4
,-1,I4
,-1);
8412 VARIMP(UI1
,0,R4
,0.0f
,I4
,-1);
8413 VARIMP(UI1
,0,R8
,-1.0,I4
,-1);
8414 VARIMP(UI1
,0,DATE
,0,I4
,-1);
8415 VARIMP(UI1
,0,BSTR
,true_str
,I2
,-1);
8416 VARIMP(UI1
,0,BOOL
,VARIANT_FALSE
,I2
,-1);
8417 VARIMP(UI1
,0,I1
,0,I4
,-1);
8418 VARIMP(UI1
,0,UI1
,1,UI1
,255);
8419 VARIMP(UI1
,0,UI2
,1,I4
,-1);
8420 VARIMP(UI1
,0,UI4
,1,I4
,-1);
8421 if (HAVE_OLEAUT32_I8
)
8423 VARIMP(UI1
,0,I8
,1,I8
,-1);
8424 VARIMP(UI1
,0,UI8
,1,I4
,-1);
8426 VARIMP(UI1
,0,INT
,-1,I4
,-1);
8427 VARIMP(UI1
,0,UINT
,1,I4
,-1);
8428 VARIMP(UI2
,0,EMPTY
,0,I4
,-1);
8429 VARIMP(UI2
,0,NULL
,0,I4
,-1);
8430 VARIMP(UI2
,0,I2
,-1,I4
,-1);
8431 VARIMP(UI2
,0,I4
,-1,I4
,-1);
8432 VARIMP(UI2
,0,R4
,0.0f
,I4
,-1);
8433 VARIMP(UI2
,0,R8
,-1.0,I4
,-1);
8434 VARIMP(UI2
,0,DATE
,0,I4
,-1);
8435 VARIMP(UI2
,0,BSTR
,true_str
,I4
,-1);
8436 VARIMP(UI2
,0,BOOL
,VARIANT_FALSE
,I4
,-1);
8437 VARIMP(UI2
,0,I1
,0,I4
,-1);
8438 VARIMP(UI2
,0,UI1
,1,I4
,-1);
8439 VARIMP(UI2
,0,UI2
,1,I4
,-1);
8440 VARIMP(UI2
,0,UI4
,1,I4
,-1);
8441 if (HAVE_OLEAUT32_I8
)
8443 VARIMP(UI2
,0,I8
,1,I8
,-1);
8444 VARIMP(UI2
,0,UI8
,1,I4
,-1);
8446 VARIMP(UI2
,0,INT
,-1,I4
,-1);
8447 VARIMP(UI2
,0,UINT
,1,I4
,-1);
8448 VARIMP(UI4
,0,EMPTY
,0,I4
,-1);
8449 VARIMP(UI4
,0,NULL
,0,I4
,-1);
8450 VARIMP(UI4
,0,I2
,-1,I4
,-1);
8451 VARIMP(UI4
,0,I4
,-1,I4
,-1);
8452 VARIMP(UI4
,0,R4
,0.0f
,I4
,-1);
8453 VARIMP(UI4
,0,R8
,-1.0,I4
,-1);
8454 VARIMP(UI4
,0,DATE
,0,I4
,-1);
8455 VARIMP(UI4
,0,BSTR
,true_str
,I4
,-1);
8456 VARIMP(UI4
,0,BOOL
,VARIANT_FALSE
,I4
,-1);
8457 VARIMP(UI4
,0,I1
,0,I4
,-1);
8458 VARIMP(UI4
,0,UI1
,1,I4
,-1);
8459 VARIMP(UI4
,0,UI2
,1,I4
,-1);
8460 VARIMP(UI4
,0,UI4
,1,I4
,-1);
8461 if (HAVE_OLEAUT32_I8
)
8463 VARIMP(UI4
,0,I8
,1,I8
,-1);
8464 VARIMP(UI4
,0,UI8
,1,I4
,-1);
8466 VARIMP(UI4
,0,INT
,-1,I4
,-1);
8467 VARIMP(UI4
,0,UINT
,1,I4
,-1);
8468 if (HAVE_OLEAUT32_I8
)
8470 VARIMP(I8
,-1,EMPTY
,0,I8
,0);
8471 VARIMP(I8
,-1,NULL
,0,NULL
,0);
8472 VARIMP(I8
,-1,I2
,-1,I8
,-1);
8473 VARIMP(I8
,-1,I4
,-1,I8
,-1);
8474 VARIMP(I8
,-1,R4
,0.0f
,I8
,0);
8475 VARIMP(I8
,-1,R8
,-1.0,I8
,-1);
8476 VARIMP(I8
,-1,DATE
,0,I8
,0);
8477 VARIMP(I8
,-1,BSTR
,true_str
,I8
,-1);
8478 VARIMP(I8
,-1,BOOL
,VARIANT_FALSE
,I8
,0);
8479 VARIMP(I8
,-1,I1
,0,I8
,0);
8480 VARIMP(I8
,-1,UI1
,1,I8
,1);
8481 VARIMP(I8
,-1,UI2
,1,I8
,1);
8482 VARIMP(I8
,-1,UI4
,1,I8
,1);
8483 VARIMP(I8
,-1,I8
,1,I8
,1);
8484 VARIMP(I8
,-1,UI8
,1,I8
,1);
8485 VARIMP(I8
,-1,UINT
,1,I8
,1);
8486 VARIMP(UI8
,0,EMPTY
,0,I4
,-1);
8487 VARIMP(UI8
,0,NULL
,0,I4
,-1);
8488 VARIMP(UI8
,0,I2
,-1,I4
,-1);
8489 VARIMP(UI8
,0,I4
,-1,I4
,-1);
8490 VARIMP(UI8
,0,R4
,0.0f
,I4
,-1);
8491 VARIMP(UI8
,0,R8
,-1.0,I4
,-1);
8492 VARIMP(UI8
,0,DATE
,0,I4
,-1);
8493 VARIMP(UI8
,0,BSTR
,true_str
,I4
,-1);
8494 VARIMP(UI8
,0,BOOL
,VARIANT_FALSE
,I4
,-1);
8495 VARIMP(UI8
,0,I1
,0,I4
,-1);
8496 VARIMP(UI8
,0,UI1
,1,I4
,-1);
8497 VARIMP(UI8
,0,UI2
,1,I4
,-1);
8498 VARIMP(UI8
,0,UI4
,1,I4
,-1);
8499 VARIMP(UI8
,0,I8
,1,I8
,-1);
8500 VARIMP(UI8
,0,UI8
,1,I4
,-1);
8501 VARIMP(UI8
,0,INT
,-1,I4
,-1);
8502 VARIMP(UI8
,0,UINT
,1,I4
,-1);
8504 VARIMP(INT
,-1,EMPTY
,0,I4
,0);
8505 VARIMP(INT
,-1,NULL
,0,NULL
,0);
8506 VARIMP(INT
,-1,I2
,-1,I4
,-1);
8507 VARIMP(INT
,-1,I4
,-1,I4
,-1);
8508 VARIMP(INT
,-1,R4
,0.0f
,I4
,0);
8509 VARIMP(INT
,-1,R8
,-1.0,I4
,-1);
8510 VARIMP(INT
,-1,DATE
,0,I4
,0);
8511 VARIMP(INT
,-1,BSTR
,true_str
,I4
,-1);
8512 VARIMP(INT
,-1,BOOL
,VARIANT_FALSE
,I4
,0);
8513 VARIMP(INT
,-1,I1
,0,I4
,0);
8514 VARIMP(INT
,-1,UI1
,1,I4
,1);
8515 VARIMP(INT
,-1,UI2
,1,I4
,1);
8516 VARIMP(INT
,-1,UI4
,1,I4
,1);
8517 if (HAVE_OLEAUT32_I8
)
8519 VARIMP(INT
,-1,I8
,1,I8
,1);
8520 VARIMP(INT
,-1,UI8
,1,I4
,1);
8522 VARIMP(INT
,-1,INT
,-1,I4
,-1);
8523 VARIMP(INT
,-1,UINT
,1,I4
,1);
8524 VARIMP(UINT
,1,EMPTY
,0,I4
,-2);
8525 VARIMP(UINT
,1,NULL
,0,I4
,-2);
8526 VARIMP(UINT
,1,I2
,-1,I4
,-1);
8527 VARIMP(UINT
,1,I4
,-1,I4
,-1);
8528 VARIMP(UINT
,1,R4
,0.0f
,I4
,-2);
8529 VARIMP(UINT
,1,R8
,-1.0,I4
,-1);
8530 VARIMP(UINT
,1,DATE
,0,I4
,-2);
8531 VARIMP(UINT
,1,BSTR
,true_str
,I4
,-1);
8532 VARIMP(UINT
,1,BOOL
,VARIANT_FALSE
,I4
,-2);
8533 VARIMP(UINT
,1,I1
,0,I4
,-2);
8534 VARIMP(UINT
,1,UI1
,1,I4
,-1);
8535 VARIMP(UINT
,1,UI2
,1,I4
,-1);
8536 VARIMP(UINT
,1,UI4
,1,I4
,-1);
8537 if (HAVE_OLEAUT32_I8
)
8539 VARIMP(UINT
,1,I8
,1,I8
,-1);
8540 VARIMP(UINT
,1,UI8
,1,I4
,-1);
8542 VARIMP(UINT
,1,INT
,-1,I4
,-1);
8543 VARIMP(UINT
,1,UINT
,1,I4
,-1);
8545 /* Manually test some VT_CY, VT_DECIMAL variants */
8547 hres
= VarCyFromI4(1, &V_CY(&cy
));
8548 ok(hres
== S_OK
, "VarCyFromI4 failed!\n");
8549 V_VT(&dec
) = VT_DECIMAL
;
8550 hres
= VarDecFromR8(2.0, &V_DECIMAL(&dec
));
8551 ok(hres
== S_OK
, "VarDecFromR4 failed!\n");
8552 memset(&left
, 0, sizeof(left
));
8553 memset(&right
, 0, sizeof(right
));
8554 V_VT(&left
) = VT_I4
;
8556 V_VT(&right
) = VT_I8
;
8559 hres
= pVarImp(&cy
, &cy
, &result
);
8560 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
8561 "VARIMP: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8562 S_OK
, hres
, vtstr(V_VT(&result
)));
8563 ok(hres
== S_OK
&& V_I4(&result
) == -1,
8564 "VARIMP: CY value %d, expected %d\n", V_I4(&result
), -1);
8566 if (HAVE_OLEAUT32_I8
)
8568 hres
= pVarImp(&cy
, &right
, &result
);
8569 ok(hres
== S_OK
&& V_VT(&result
) == VT_I8
,
8570 "VARIMP: expected coerced hres 0x%X type VT_I8, got hres 0x%X type %s!\n",
8571 S_OK
, hres
, vtstr(V_VT(&result
)));
8572 ok(hres
== S_OK
&& V_I8(&result
) == -2,
8573 "VARIMP: CY value %x%08x, expected %d\n",
8574 (DWORD
)((V_I8(&result
)) >> 32), (DWORD
)(V_I8(&result
)), -2);
8577 hres
= pVarImp(&left
, &cy
, &result
);
8578 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
8579 "VARIMP: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8580 S_OK
, hres
, vtstr(V_VT(&result
)));
8581 ok(hres
== S_OK
&& V_I4(&result
) == -1,
8582 "VARIMP: CY value %d, expected %d\n", V_I4(&result
), -1);
8584 hres
= pVarImp(&left
, &dec
, &result
);
8585 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
8586 "VARIMP: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8587 S_OK
, hres
, vtstr(V_VT(&result
)));
8588 ok(hres
== S_OK
&& V_I4(&result
) == -1,
8589 "VARIMP: DECIMAL value %d, expected %d\n", V_I4(&result
), -1);
8591 hres
= pVarImp(&dec
, &dec
, &result
);
8592 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
8593 "VARIMP: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8594 S_OK
, hres
, vtstr(V_VT(&result
)));
8595 ok(hres
== S_OK
&& V_I4(&result
) == -1,
8596 "VARIMP: DECIMAL value %d, expected %d\n", V_I4(&result
), -1);
8598 if (HAVE_OLEAUT32_I8
)
8600 hres
= pVarImp(&dec
, &right
, &result
);
8601 ok(hres
== S_OK
&& V_VT(&result
) == VT_I8
,
8602 "VARIMP: expected coerced hres 0x%X type VT_I8, got hres 0x%X type %s!\n",
8603 S_OK
, hres
, vtstr(V_VT(&result
)));
8604 ok(hres
== S_OK
&& V_I8(&result
) == -3,
8605 "VARIMP: DECIMAL value 0x%x%08x, expected %d\n",
8606 (DWORD
)(V_I8(&result
) >>32), (DWORD
)V_I8(&result
), -3);
8609 SysFreeString(false_str
);
8610 SysFreeString(true_str
);
8618 test_VariantClear();
8620 test_VariantCopyInd();
8621 test_VarParseNumFromStr();
8622 test_VarNumFromParseNum();
8623 test_VarUdateFromDate();
8624 test_VarDateFromUdate();
8625 test_SystemTimeToVariantTime();
8626 test_VariantTimeToSystemTime();
8627 test_DosDateTimeToVariantTime();
8628 test_VariantTimeToDosDateTime();