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
;
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
;
2566 if(((l
== VT_I8
) && (r
== VT_INT
)) || ((l
== VT_INT
) && (r
== VT_I8
)))
2568 hexpected
= DISP_E_TYPEMISMATCH
;
2569 } else if((l
== VT_EMPTY
) && (r
== VT_NULL
))
2572 } else if((l
== VT_NULL
) && (r
== VT_EMPTY
))
2575 } else if((l
== VT_EMPTY
) && (r
== VT_CY
))
2578 } else if((l
== VT_EMPTY
) && (r
== VT_RECORD
))
2580 hexpected
= DISP_E_TYPEMISMATCH
;
2581 } else if((r
== VT_EMPTY
) && lFound
&& lValid
)
2583 hexpected
= DISP_E_DIVBYZERO
;
2584 } else if((l
== VT_ERROR
) || ((r
== VT_ERROR
) && lFound
&& lValid
))
2586 hexpected
= DISP_E_TYPEMISMATCH
;
2587 } else if((l
== VT_NULL
) && (r
== VT_NULL
))
2590 } else if((l
== VT_VARIANT
) || ((r
== VT_VARIANT
) && lFound
&& lValid
))
2592 hexpected
= DISP_E_TYPEMISMATCH
;
2593 } else if((l
== VT_NULL
) && (r
== VT_RECORD
))
2595 hexpected
= DISP_E_TYPEMISMATCH
;
2596 } else if((l
== VT_I8
) && (r
== VT_DECIMAL
))
2599 } else if((l
== VT_DECIMAL
) && (r
== VT_I8
))
2602 } else if((l
== VT_UNKNOWN
) || ((r
== VT_UNKNOWN
) && lFound
&& lValid
))
2604 hexpected
= DISP_E_TYPEMISMATCH
;
2605 } else if((l
== VT_NULL
) && rFound
)
2608 } else if(l
== VT_RECORD
)
2610 hexpected
= DISP_E_TYPEMISMATCH
;
2611 } else if((r
== VT_RECORD
) && lValid
&& lFound
)
2613 hexpected
= DISP_E_TYPEMISMATCH
;
2614 } else if((l
== VT_EMPTY
) && (r
== VT_EMPTY
))
2616 hexpected
= DISP_E_DIVBYZERO
;
2617 } else if((l
== VT_CY
) && !rFound
)
2619 hexpected
= DISP_E_BADVARTYPE
;
2620 } else if(lFound
&& !rFound
)
2622 hexpected
= DISP_E_BADVARTYPE
;
2623 } else if(!lFound
&& rFound
)
2625 hexpected
= DISP_E_BADVARTYPE
;
2626 } else if((r
== VT_NULL
) && lFound
&& lValid
)
2629 } else if((l
== VT_NULL
) || (r
== VT_NULL
))
2631 hexpected
= DISP_E_BADVARTYPE
;
2632 } else if((l
== VT_VARIANT
) || (r
== VT_VARIANT
))
2634 hexpected
= DISP_E_BADVARTYPE
;
2635 } else if(lFound
&& !rFound
)
2637 hexpected
= DISP_E_BADVARTYPE
;
2638 } else if(!lFound
&& !rFound
)
2640 hexpected
= DISP_E_BADVARTYPE
;
2647 V_CY(&v1
).int64
= 1000000;
2652 else if(l
== VT_UI8
)
2656 else if(l
== VT_DATE
)
2658 else if (l
== VT_DECIMAL
)
2660 V_DECIMAL(&v1
).Hi32
= 0;
2661 U1(V_DECIMAL(&v1
)).Lo64
= 100;
2662 U(V_DECIMAL(&v1
)).signscale
= 0;
2668 V_CY(&v2
).int64
= 10000;
2673 else if(r
== VT_UI8
)
2677 else if(r
== VT_DATE
)
2679 else if (r
== VT_DECIMAL
)
2681 V_DECIMAL(&v2
).Hi32
= 0;
2682 U1(V_DECIMAL(&v2
)).Lo64
= 100;
2683 U(V_DECIMAL(&v2
)).signscale
= 0;
2688 if ((l
!= VT_I8
&& l
!= VT_UI8
&& r
!= VT_I8
&& r
!= VT_UI8
) || HAVE_OLEAUT32_I8
)
2690 hres
= pVarMod(&v1
,&v2
,&vDst
);
2691 ok(hres
== hexpected
,
2692 "VarMod: expected 0x%x, got 0x%X for l type of %d, r type of %d,\n", hexpected
, hres
, l
, r
);
2698 /****************************/
2699 /* test some bad parameters */
2700 VARMOD(I4
,I4
,-1,-1,I4
,0);
2702 /* test modulus with zero */
2703 VARMOD2(I4
,I4
,100,0,EMPTY
,0,DISP_E_DIVBYZERO
);
2705 VARMOD(I4
,I4
,0,10,I4
,0); /* test 0 mod 10 */
2707 /* right parameter is type empty */
2708 VARMOD2(I4
,EMPTY
,100,10,EMPTY
,0,DISP_E_DIVBYZERO
);
2710 /* left parameter is type empty */
2711 VARMOD2(EMPTY
,I4
,100,10,I4
,0,S_OK
);
2713 /* mod with a null left value */
2714 VARMOD2(NULL
,I4
,125,10,NULL
,0,S_OK
);
2716 /* mod with a null right value */
2717 VARMOD2(I4
,NULL
,100,10,NULL
,0,S_OK
);
2719 /* void left value */
2720 VARMOD2(VOID
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2722 /* void right value */
2723 VARMOD2(I4
,VOID
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2725 /* null left value, void right value */
2726 VARMOD2(NULL
,VOID
,100,10,EMPTY
, 0, DISP_E_BADVARTYPE
);
2728 /* void left value, null right value */
2729 VARMOD2(VOID
,NULL
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2731 /* some currencies */
2734 V_CY(&v1
).int64
= 100000;
2735 V_CY(&v2
).int64
= 100000;
2736 hres
= pVarMod(&v1
,&v2
,&vDst
);
2737 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I4
&& V_I4(&vDst
) == 0,
2738 "VarMod: expected 0x%x,%d,%d, got 0x%X,%d,%d\n", S_OK
, VT_I4
, 0, hres
, V_VT(&vDst
), V_I4(&vDst
));
2743 V_CY(&v2
).int64
= 100000;
2744 hres
= pVarMod(&v1
,&v2
,&vDst
);
2745 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I4
&& V_I4(&vDst
) == 0,
2746 "VarMod: expected 0x%x,%d,%d, got 0x%X,%d,%d\n", S_OK
, VT_I4
, 0, hres
, V_VT(&vDst
), V_I4(&vDst
));
2749 V_VT(&v1
) = VT_DECIMAL
;
2750 V_VT(&v2
) = VT_DECIMAL
;
2751 VarDecFromI4(100, &V_DECIMAL(&v1
));
2752 VarDecFromI4(10, &V_DECIMAL(&v2
));
2753 hres
= pVarMod(&v1
,&v2
,&vDst
);
2754 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I4
&& V_I4(&vDst
) == 0,
2755 "VarMod: expected 0x%x,%d,%d, got 0x%X,%d,%d\n", S_OK
, VT_I4
, 0, hres
, V_VT(&vDst
), V_I4(&vDst
));
2758 V_VT(&v2
) = VT_DECIMAL
;
2760 VarDecFromI4(10, &V_DECIMAL(&v2
));
2761 hres
= pVarMod(&v1
,&v2
,&vDst
);
2762 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I4
&& V_I4(&vDst
) == 0,
2763 "VarMod: expected 0x%x,%d,%d, got 0x%X,%d,%d\n", S_OK
, VT_I4
, 0, hres
, V_VT(&vDst
), V_I4(&vDst
));
2765 VARMOD2(UINT
,I4
,100,10,I4
,0,S_OK
);
2767 /* test that an error results in the type of the result changing but not its value */
2768 V_VT(&v1
) = VT_UNKNOWN
;
2769 V_VT(&v2
) = VT_EMPTY
;
2771 V_CY(&v2
).int64
= 100000;
2772 V_VT(&vDst
) = VT_I4
;
2774 hres
= pVarMod(&v1
,&v2
,&vDst
);
2775 ok(hres
== DISP_E_TYPEMISMATCH
&& V_VT(&vDst
) == VT_EMPTY
&& V_I4(&vDst
) == 1231,
2776 "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
));
2779 /* test some invalid types */
2780 /*TODO: not testing VT_DISPATCH */
2781 if (HAVE_OLEAUT32_I8
)
2783 VARMOD2(I8
,INT
,100,10,EMPTY
,0,DISP_E_TYPEMISMATCH
);
2785 VARMOD2(ERROR
,I4
,100,10,EMPTY
,0,DISP_E_TYPEMISMATCH
);
2786 VARMOD2(VARIANT
,I4
,100,10,EMPTY
,0,DISP_E_TYPEMISMATCH
);
2787 VARMOD2(UNKNOWN
,I4
,100,10,EMPTY
,0,DISP_E_TYPEMISMATCH
);
2788 VARMOD2(VOID
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2789 VARMOD2(HRESULT
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2790 VARMOD2(PTR
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2791 VARMOD2(SAFEARRAY
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2792 VARMOD2(CARRAY
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2793 VARMOD2(USERDEFINED
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2794 VARMOD2(LPSTR
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2795 VARMOD2(LPWSTR
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2796 VARMOD2(RECORD
,I4
,100,10,EMPTY
,0,DISP_E_TYPEMISMATCH
);
2797 VARMOD2(FILETIME
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2798 VARMOD2(BLOB
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2799 VARMOD2(STREAM
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2800 VARMOD2(STORAGE
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2801 VARMOD2(STREAMED_OBJECT
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2802 VARMOD2(STORED_OBJECT
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2803 VARMOD2(BLOB_OBJECT
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2804 VARMOD2(CF
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2805 VARMOD2(CLSID
,CLSID
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2806 VARMOD2(VECTOR
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2807 VARMOD2(ARRAY
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2808 VARMOD2(BYREF
,I4
,100,10,EMPTY
,0,DISP_E_BADVARTYPE
);
2810 /* test some more invalid types */
2815 hres
= pVarMod(&v1
,&v2
,&vDst
);
2816 ok(hres
== DISP_E_BADVARTYPE
&& V_VT(&vDst
) == VT_EMPTY
,
2817 "VarMod: expected 0x%x,%d, got 0x%X,%d\n", DISP_E_BADVARTYPE
, VT_EMPTY
, hres
, V_VT(&vDst
));
2819 SysFreeString(strNum0
);
2820 SysFreeString(strNum1
);
2823 static HRESULT (WINAPI
*pVarFix
)(LPVARIANT
,LPVARIANT
);
2825 #define VARFIX(vt,val,rvt,rval) \
2826 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
2827 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
2828 test_var_call1( __LINE__, pVarFix, &v, &exp )
2830 static void test_VarFix(void)
2832 static const WCHAR szNumMinus1
[] = {'-','1','\0' };
2834 VARIANT v
, exp
, vDst
;
2835 DECIMAL
*pdec
= &V_DECIMAL(&v
);
2836 CY
*pcy
= &V_CY(&v
);
2841 /* Test all possible V_VT values */
2842 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
2846 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
2848 HRESULT bFail
= TRUE
;
2852 memset(&v
, 0, sizeof(v
));
2853 V_VT(&v
) = vt
| ExtraFlags
[i
];
2854 V_VT(&vDst
) = VT_EMPTY
;
2858 case VT_UI1
: case VT_I2
: case VT_I4
: case VT_R4
: case VT_R8
:
2859 case VT_DECIMAL
: case VT_BOOL
: case VT_NULL
: case VT_EMPTY
:
2860 case VT_DATE
: case VT_CY
:
2864 if (HAVE_OLEAUT32_I8
)
2869 hres
= pVarFix(&v
,&vDst
);
2871 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
2872 "VarFix: expected failure, got 0x%X vt %d|0x%X\n",
2873 hres
, vt
, ExtraFlags
[i
]);
2875 ok(hres
== S_OK
, "VarFix: expected S_OK, got 0x%X vt %d|0x%X\n",
2876 hres
, vt
, ExtraFlags
[i
]);
2880 VARFIX(BOOL
,VARIANT_TRUE
,I2
,VARIANT_TRUE
);
2881 VARFIX(BOOL
,VARIANT_FALSE
,I2
,0);
2882 VARFIX(BOOL
,1,I2
,1);
2883 VARFIX(UI1
,1,UI1
,1);
2884 VARFIX(I2
,-1,I2
,-1);
2885 VARFIX(I4
,-1,I4
,-1);
2886 if (HAVE_OLEAUT32_I8
)
2888 VARFIX(I8
,-1,I8
,-1);
2890 VARFIX(R4
,1.4f
,R4
,1);
2891 VARFIX(R4
,1.5f
,R4
,1);
2892 VARFIX(R4
,1.6f
,R4
,1);
2893 VARFIX(R4
,-1.4f
,R4
,-1);
2894 VARFIX(R4
,-1.5f
,R4
,-1);
2895 VARFIX(R4
,-1.6f
,R4
,-1);
2896 /* DATE & R8 round as for R4 */
2897 VARFIX(DATE
,-1,DATE
,-1);
2898 VARFIX(R8
,-1,R8
,-1);
2899 VARFIX(BSTR
,(BSTR
)szNumMinus1
,R8
,-1);
2901 V_VT(&v
) = VT_EMPTY
;
2902 hres
= pVarFix(&v
,&vDst
);
2903 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I2
&& V_I2(&vDst
) == 0,
2904 "VarFix: expected 0x0,%d,0 got 0x%X,%d,%d\n", VT_EMPTY
,
2905 hres
, V_VT(&vDst
), V_I2(&vDst
));
2908 hres
= pVarFix(&v
,&vDst
);
2909 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_NULL
,
2910 "VarFix: expected 0x0,%d got 0x%X,%d\n", VT_NULL
, hres
, V_VT(&vDst
));
2912 V_VT(&v
) = VT_DECIMAL
;
2913 S(U(*pdec
)).sign
= DECIMAL_NEG
;
2914 S(U(*pdec
)).scale
= 0;
2916 S1(U1(*pdec
)).Mid32
= 0;
2917 S1(U1(*pdec
)).Lo32
= 1;
2918 hres
= pVarFix(&v
,&vDst
);
2919 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_DECIMAL
&& !memcmp(&V_DECIMAL(&v
), &V_DECIMAL(&vDst
), sizeof(DECIMAL
)),
2920 "VarFix: expected 0x0,%d,identical, got 0x%X,%d\n", VT_DECIMAL
,
2923 /* FIXME: Test some fractional decimals when VarDecFix is implemented */
2926 pcy
->int64
= -10000;
2927 hres
= pVarFix(&v
,&vDst
);
2928 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_CY
&& V_CY(&vDst
).int64
== -10000,
2929 "VarFix: VT_CY wrong, hres=0x%X\n", hres
);
2932 pcy
->int64
= -16000;
2933 hres
= pVarFix(&v
,&vDst
);
2934 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_CY
&& V_CY(&vDst
).int64
== -10000,
2935 "VarFix: VT_CY wrong, hres=0x%X\n", hres
);
2938 static HRESULT (WINAPI
*pVarInt
)(LPVARIANT
,LPVARIANT
);
2940 #define VARINT(vt,val,rvt,rval) \
2941 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
2942 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
2943 test_var_call1( __LINE__, pVarInt, &v, &exp )
2945 static void test_VarInt(void)
2947 static const WCHAR szNumMinus1
[] = {'-','1','\0' };
2949 VARIANT v
, exp
, vDst
;
2950 DECIMAL
*pdec
= &V_DECIMAL(&v
);
2951 CY
*pcy
= &V_CY(&v
);
2956 /* Test all possible V_VT values */
2957 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
2961 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
2963 HRESULT bFail
= TRUE
;
2967 memset(&v
, 0, sizeof(v
));
2968 V_VT(&v
) = vt
| ExtraFlags
[i
];
2969 V_VT(&vDst
) = VT_EMPTY
;
2973 case VT_UI1
: case VT_I2
: case VT_I4
: case VT_R4
: case VT_R8
:
2974 case VT_DECIMAL
: case VT_BOOL
: case VT_NULL
: case VT_EMPTY
:
2975 case VT_DATE
: case VT_CY
:
2979 if (HAVE_OLEAUT32_I8
)
2984 hres
= pVarInt(&v
,&vDst
);
2986 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
2987 "VarInt: expected failure, got 0x%X vt %d|0x%X\n",
2988 hres
, vt
, ExtraFlags
[i
]);
2990 ok(hres
== S_OK
, "VarInt: expected S_OK, got 0x%X vt %d|0x%X\n",
2991 hres
, vt
, ExtraFlags
[i
]);
2995 VARINT(BOOL
,VARIANT_TRUE
,I2
,VARIANT_TRUE
);
2996 VARINT(BOOL
,VARIANT_FALSE
,I2
,0);
2997 VARINT(BOOL
,1,I2
,1);
2998 VARINT(UI1
,1,UI1
,1);
2999 VARINT(I2
,-1,I2
,-1);
3000 VARINT(I4
,-1,I4
,-1);
3001 if (HAVE_OLEAUT32_I8
)
3003 VARINT(I8
,-1,I8
,-1);
3005 VARINT(R4
,1.4f
,R4
,1);
3006 VARINT(R4
,1.5f
,R4
,1);
3007 VARINT(R4
,1.6f
,R4
,1);
3008 VARINT(R4
,-1.4f
,R4
,-2); /* Note these 3 are different from VarFix */
3009 VARINT(R4
,-1.5f
,R4
,-2);
3010 VARINT(R4
,-1.6f
,R4
,-2);
3011 /* DATE & R8 round as for R4 */
3012 VARINT(DATE
,-1,DATE
,-1);
3013 VARINT(R8
,-1,R8
,-1);
3014 VARINT(BSTR
,(BSTR
)szNumMinus1
,R8
,-1);
3016 V_VT(&v
) = VT_EMPTY
;
3017 hres
= pVarInt(&v
,&vDst
);
3018 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I2
&& V_I2(&vDst
) == 0,
3019 "VarInt: expected 0x0,%d,0 got 0x%X,%d,%d\n", VT_EMPTY
,
3020 hres
, V_VT(&vDst
), V_I2(&vDst
));
3023 hres
= pVarInt(&v
,&vDst
);
3024 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_NULL
,
3025 "VarInt: expected 0x0,%d got 0x%X,%d\n", VT_NULL
, hres
, V_VT(&vDst
));
3027 V_VT(&v
) = VT_DECIMAL
;
3028 S(U(*pdec
)).sign
= DECIMAL_NEG
;
3029 S(U(*pdec
)).scale
= 0;
3031 S1(U1(*pdec
)).Mid32
= 0;
3032 S1(U1(*pdec
)).Lo32
= 1;
3033 hres
= pVarInt(&v
,&vDst
);
3034 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_DECIMAL
&& !memcmp(&V_DECIMAL(&v
), &V_DECIMAL(&vDst
), sizeof(DECIMAL
)),
3035 "VarInt: expected 0x0,%d,identical, got 0x%X,%d\n", VT_DECIMAL
,
3038 /* FIXME: Test some fractional decimals when VarDecInt is implemented */
3041 pcy
->int64
= -10000;
3042 hres
= pVarInt(&v
,&vDst
);
3043 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_CY
&& V_CY(&vDst
).int64
== -10000,
3044 "VarInt: VT_CY wrong, hres=0x%X\n", hres
);
3047 pcy
->int64
= -11000;
3048 hres
= pVarInt(&v
,&vDst
);
3049 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_CY
&& V_CY(&vDst
).int64
== -20000,
3050 "VarInt: VT_CY wrong, hres=0x%X 0x%x%08x\n",
3051 hres
, (DWORD
)(V_CY(&vDst
).int64
>> 32), (DWORD
)V_CY(&vDst
).int64
);
3054 static HRESULT (WINAPI
*pVarNeg
)(LPVARIANT
,LPVARIANT
);
3056 #define VARNEG(vt,val,rvt,rval) \
3057 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
3058 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
3059 test_var_call1( __LINE__, pVarNeg, &v, &exp )
3061 static void test_VarNeg(void)
3063 static const WCHAR szNumMinus1
[] = {'-','1','\0' };
3064 static const WCHAR szNum1
[] = {'1','\0' };
3066 VARIANT v
, exp
, vDst
;
3067 DECIMAL
*pdec
= &V_DECIMAL(&v
);
3068 CY
*pcy
= &V_CY(&v
);
3073 /* Test all possible V_VT values. But don't test the exact return values
3074 * except for success/failure, since M$ made a hash of them in the
3075 * native version. This at least ensures (as with all tests here) that
3076 * we will notice if/when new vtypes/flags are added in native.
3078 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
3082 for (vt
= 0; vt
<= VT_BSTR_BLOB
; vt
++)
3084 HRESULT bFail
= TRUE
;
3088 memset(&v
, 0, sizeof(v
));
3089 V_VT(&v
) = vt
| ExtraFlags
[i
];
3090 V_VT(&vDst
) = VT_EMPTY
;
3094 case VT_UI1
: case VT_I2
: case VT_I4
:
3095 case VT_R4
: case VT_R8
:
3096 case VT_DECIMAL
: case VT_BOOL
: case VT_NULL
: case VT_EMPTY
:
3097 case VT_DATE
: case VT_CY
:
3101 if (HAVE_OLEAUT32_I8
)
3105 hres
= pVarNeg(&v
,&vDst
);
3107 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
3108 "VarNeg: expected failure, got 0x%X vt %d|0x%X\n",
3109 hres
, vt
, ExtraFlags
[i
]);
3111 ok(hres
== S_OK
, "VarNeg: expected S_OK, got 0x%X vt %d|0x%X\n",
3112 hres
, vt
, ExtraFlags
[i
]);
3116 VARNEG(BOOL
,VARIANT_TRUE
,I2
,1);
3117 VARNEG(BOOL
,VARIANT_FALSE
,I2
,0);
3118 VARNEG(BOOL
,1,I2
,-1);
3119 VARNEG(UI1
,1,I2
,-1);
3120 VARNEG(UI1
,254,I2
,-254);
3121 VARNEG(I2
,-32768,I4
,32768);
3124 VARNEG(I4
,-((int)(~0u >> 1)) - 1,R8
,-2147483648u);
3127 if (HAVE_OLEAUT32_I8
)
3134 VARNEG(DATE
,1,DATE
,-1);
3135 VARNEG(DATE
,-1,DATE
,1);
3138 VARNEG(BSTR
,(BSTR
)szNumMinus1
,R8
,1);
3139 VARNEG(BSTR
,(BSTR
)szNum1
,R8
,-1);
3141 V_VT(&v
) = VT_EMPTY
;
3142 hres
= pVarNeg(&v
,&vDst
);
3143 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I2
&& V_I2(&vDst
) == 0,
3144 "VarNeg: expected 0x0,%d,0 got 0x%X,%d,%d\n", VT_EMPTY
,
3145 hres
, V_VT(&vDst
), V_I2(&vDst
));
3148 hres
= pVarNeg(&v
,&vDst
);
3149 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_NULL
,
3150 "VarNeg: expected 0x0,%d got 0x%X,%d\n", VT_NULL
, hres
, V_VT(&vDst
));
3152 V_VT(&v
) = VT_DECIMAL
;
3153 S(U(*pdec
)).sign
= DECIMAL_NEG
;
3154 S(U(*pdec
)).scale
= 0;
3156 S1(U1(*pdec
)).Mid32
= 0;
3157 S1(U1(*pdec
)).Lo32
= 1;
3158 hres
= pVarNeg(&v
,&vDst
);
3159 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_DECIMAL
&&
3160 S(U(V_DECIMAL(&vDst
))).sign
== 0,
3161 "VarNeg: expected 0x0,%d,0x00, got 0x%X,%d,%02x\n", VT_DECIMAL
,
3162 hres
, V_VT(&vDst
), S(U(V_DECIMAL(&vDst
))).sign
);
3164 S(U(*pdec
)).sign
= 0;
3165 hres
= pVarNeg(&v
,&vDst
);
3166 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_DECIMAL
&&
3167 S(U(V_DECIMAL(&vDst
))).sign
== DECIMAL_NEG
,
3168 "VarNeg: expected 0x0,%d,0x7f, got 0x%X,%d,%02x\n", VT_DECIMAL
,
3169 hres
, V_VT(&vDst
), S(U(V_DECIMAL(&vDst
))).sign
);
3172 pcy
->int64
= -10000;
3173 hres
= pVarNeg(&v
,&vDst
);
3174 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_CY
&& V_CY(&vDst
).int64
== 10000,
3175 "VarNeg: VT_CY wrong, hres=0x%X\n", hres
);
3178 static HRESULT (WINAPI
*pVarRound
)(LPVARIANT
,int,LPVARIANT
);
3180 static void test_Round( int line
, VARIANT
*arg
, int deci
, VARIANT
*expected
)
3185 memset( &result
, 0, sizeof(result
) );
3186 hres
= pVarRound( arg
, deci
, &result
);
3187 ok_(__FILE__
,line
)( hres
== S_OK
, "wrong result %x\n", hres
);
3189 ok_(__FILE__
,line
)( is_expected_variant( &result
, expected
),
3190 "got %s expected %s\n", variantstr(&result
), variantstr(expected
) );
3192 #define VARROUND(vt,val,deci,rvt,rval) \
3193 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
3194 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
3195 test_Round( __LINE__, &v, deci, &exp )
3197 static void test_VarRound(void)
3199 static WCHAR szNumMin
[] = {'-','1','.','4','4','9','\0' };
3200 static WCHAR szNum
[] = {'1','.','4','5','1','\0' };
3202 VARIANT v
, exp
, vDst
;
3203 CY
*pcy
= &V_CY(&v
);
3208 /* first check valid integer types */
3209 VARROUND(BOOL
,VARIANT_TRUE
,0,I2
,-1);
3210 VARROUND(BOOL
,VARIANT_FALSE
,0,I2
,0);
3211 VARROUND(BOOL
,1,0,I2
,1);
3212 VARROUND(UI1
,1,0,UI1
,1);
3213 VARROUND(UI1
,254,0,UI1
,254);
3214 VARROUND(I2
,-32768,0,I2
,-32768);
3215 VARROUND(I2
,-1,0,I2
,-1);
3216 VARROUND(I2
,1,0,I2
,1);
3217 VARROUND(I4
,-((int)(~0u >> 1)) - 1,0,I4
,-((int)(~0u >> 1)) - 1);
3218 VARROUND(I4
,-1,0,I4
,-1);
3219 VARROUND(I4
,1,0,I4
,1);
3222 /* MSDN states that rounding of R4/R8 is dependent on the underlying
3223 * bit pattern of the number and so is architecture dependent. In this
3224 * case Wine returns .2 (which is more correct) and Native returns .3
3227 VARROUND(R4
,1.0f
,0,R4
,1.0f
);
3228 VARROUND(R4
,-1.0f
,0,R4
,-1.0f
);
3229 VARROUND(R8
,1.0,0,R8
,1.0);
3230 VARROUND(R8
,-1.0,0,R8
,-1.0);
3232 /* floating point numbers aren't exactly equal and we can't just
3233 * compare the first few digits. */
3234 VARROUND(DATE
,1.451,1,DATE
,1.5);
3235 VARROUND(DATE
,-1.449,1,DATE
,-1.4);
3237 /* replace the decimal separator */
3238 GetLocaleInfoA(LOCALE_USER_DEFAULT
, LOCALE_SDECIMAL
, buff
, sizeof(buff
)/sizeof(char));
3240 szNumMin
[2] = buff
[0];
3242 VARROUND(BSTR
,(BSTR
)szNumMin
,1,R8
,-1.40);
3243 VARROUND(BSTR
,(BSTR
)szNum
,1,R8
,1.50);
3245 skip("Skipping VarRound(BSTR) as decimal separator is '%s'\n", buff
);
3248 VARROUND(R4
,1.23456f
,0,R4
,1.0f
);
3249 VARROUND(R4
,1.23456f
,1,R4
,1.2f
);
3250 VARROUND(R4
,1.23456f
,2,R4
,1.23f
);
3251 VARROUND(R4
,1.23456f
,3,R4
,1.235f
);
3252 VARROUND(R4
,1.23456f
,4,R4
,1.2346f
);
3253 VARROUND(R4
,-1.23456f
,0,R4
,-1.0f
);
3254 VARROUND(R4
,-1.23456f
,1,R4
,-1.2f
);
3255 VARROUND(R4
,-1.23456f
,2,R4
,-1.23f
);
3256 VARROUND(R4
,-1.23456f
,3,R4
,-1.235f
);
3257 VARROUND(R4
,-1.23456f
,4,R4
,-1.2346f
);
3259 VARROUND(R8
,1.23456,0,R8
,1.0);
3260 VARROUND(R8
,1.23456,1,R8
,1.2);
3261 VARROUND(R8
,1.23456,2,R8
,1.23);
3262 VARROUND(R8
,1.23456,3,R8
,1.235);
3263 VARROUND(R8
,1.23456,4,R8
,1.2346);
3264 VARROUND(R8
,-1.23456,0,R8
,-1.0);
3265 VARROUND(R8
,-1.23456,1,R8
,-1.2);
3266 VARROUND(R8
,-1.23456,2,R8
,-1.23);
3267 VARROUND(R8
,-1.23456,3,R8
,-1.235);
3268 VARROUND(R8
,-1.23456,4,R8
,-1.2346);
3270 V_VT(&v
) = VT_EMPTY
;
3271 hres
= pVarRound(&v
,0,&vDst
);
3272 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_I2
&& V_I2(&vDst
) == 0,
3273 "VarRound: expected 0x0,%d,0 got 0x%X,%d,%d\n", VT_EMPTY
,
3274 hres
, V_VT(&vDst
), V_I2(&vDst
));
3277 hres
= pVarRound(&v
,0,&vDst
);
3278 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_NULL
,
3279 "VarRound: expected 0x0,%d got 0x%X,%d\n", VT_NULL
, hres
, V_VT(&vDst
));
3281 /* not yet implemented so no use testing yet
3283 DECIMAL *pdec = &V_DECIMAL(&v);
3284 V_VT(&v) = VT_DECIMAL;
3285 S(U(*pdec)).sign = DECIMAL_NEG;
3286 S(U(*pdec)).scale = 0;
3288 S1(U1(*pdec)).Mid32 = 0;
3289 S1(U1(*pdec)).Lo32 = 1;
3290 hres = pVarRound(&v,0,&vDst);
3291 ok(hres == S_OK && V_VT(&vDst) == VT_DECIMAL &&
3292 S(U(V_DECIMAL(&vDst))).sign == 0,
3293 "VarRound: expected 0x0,%d,0x00, got 0x%X,%d,%02x\n", VT_DECIMAL,
3294 hres, V_VT(&vDst), S(U(V_DECIMAL(&vDst))).sign);
3296 S(U(*pdec)).sign = 0;
3297 hres = pVarRound(&v,0,&vDst);
3298 ok(hres == S_OK && V_VT(&vDst) == VT_DECIMAL &&
3299 S(U(V_DECIMAL(&vDst))).sign == DECIMAL_NEG,
3300 "VarRound: expected 0x0,%d,0x7f, got 0x%X,%d,%02x\n", VT_DECIMAL,
3301 hres, V_VT(&vDst), S(U(V_DECIMAL(&vDst))).sign);
3307 hres
= pVarRound(&v
,0,&vDst
);
3308 ok(hres
== S_OK
&& V_VT(&vDst
) == VT_CY
&& V_CY(&vDst
).int64
== 10000,
3309 "VarRound: VT_CY wrong, hres=0x%X\n", hres
);
3313 static HRESULT (WINAPI
*pVarXor
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
3315 #define VARXOR(vt1,val1,vt2,val2,rvt,rval) \
3316 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
3317 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
3318 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
3319 test_var_call2( __LINE__, pVarXor, &left, &right, &exp )
3321 #define VARXORCY(vt1,val1,val2,rvt,rval) \
3322 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
3323 V_VT(&right) = VT_CY; V_CY(&right).int64 = val2; \
3324 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
3325 test_var_call2( __LINE__, pVarXor, &left, &right, &exp )
3327 static void test_VarXor(void)
3329 static const WCHAR szFalse
[] = { '#','F','A','L','S','E','#','\0' };
3330 static const WCHAR szTrue
[] = { '#','T','R','U','E','#','\0' };
3331 VARIANT left
, right
, exp
, result
;
3338 /* Test all possible flag/vt combinations & the resulting vt type */
3339 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
3341 VARTYPE leftvt
, rightvt
, resvt
;
3343 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
3348 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
3354 if (leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
||
3355 leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
||
3356 leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
)
3359 memset(&left
, 0, sizeof(left
));
3360 memset(&right
, 0, sizeof(right
));
3361 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
3362 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
3363 V_VT(&result
) = VT_EMPTY
;
3366 if (ExtraFlags
[i
] & VT_ARRAY
|| ExtraFlags
[i
] & VT_BYREF
||
3367 !IsValidVariantClearVT(leftvt
, ExtraFlags
[i
]) ||
3368 !IsValidVariantClearVT(rightvt
, ExtraFlags
[i
]) ||
3369 leftvt
== VT_CLSID
|| rightvt
== VT_CLSID
||
3370 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
||
3371 leftvt
== VT_VARIANT
|| rightvt
== VT_VARIANT
||
3372 leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
)
3376 if (leftvt
== VT_EMPTY
|| rightvt
== VT_EMPTY
)
3378 if (leftvt
== rightvt
||
3379 leftvt
== VT_I2
|| rightvt
== VT_I2
||
3380 leftvt
== VT_UI1
|| rightvt
== VT_UI1
||
3381 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
3383 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
3385 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
3388 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
3392 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
3394 if (leftvt
== rightvt
)
3396 else if (leftvt
== rightvt
||
3397 leftvt
== VT_I2
|| rightvt
== VT_I2
||
3398 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
3402 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
3405 else if (leftvt
== VT_I2
|| rightvt
== VT_I2
)
3407 if (leftvt
== rightvt
||
3408 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
3410 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
3413 else if (leftvt
== VT_BOOL
&& rightvt
== VT_BOOL
)
3417 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
3419 if (leftvt
== VT_INT
|| rightvt
== VT_INT
)
3424 hres
= pVarXor(&left
, &right
, &result
);
3426 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
3427 "VarXor: %d|0x%X, %d|0x%X: Expected failure, got 0x%X vt %d\n",
3428 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], hres
,
3431 ok(hres
== S_OK
&& V_VT(&result
) == resvt
,
3432 "VarXor: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%X vt %d\n",
3433 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], resvt
, hres
,
3439 /* Test returned values
3440 * FIXME: Test VT_DECIMAL/VT_DISPATCH
3442 VARXOR(EMPTY
,0,EMPTY
,0,I2
,0);
3443 VARXOR(EMPTY
,1,EMPTY
,0,I2
,0);
3444 VARXOR(EMPTY
,0,NULL
,0,NULL
,0);
3445 VARXOR(EMPTY
,0,I1
,0,I4
,0);
3446 VARXOR(EMPTY
,0,I1
,1,I4
,1);
3447 VARXOR(EMPTY
,0,UI1
,0,I2
,0);
3448 VARXOR(EMPTY
,0,UI1
,1,I2
,1);
3449 VARXOR(EMPTY
,0,I2
,0,I2
,0);
3450 VARXOR(EMPTY
,0,I2
,1,I2
,1);
3451 VARXOR(EMPTY
,0,UI2
,0,I4
,0);
3452 VARXOR(EMPTY
,0,UI2
,1,I4
,1);
3453 VARXOR(EMPTY
,0,I4
,0,I4
,0);
3454 VARXOR(EMPTY
,0,I4
,1,I4
,1);
3455 VARXOR(EMPTY
,0,UI4
,0,I4
,0);
3456 VARXOR(EMPTY
,0,UI4
,1,I4
,1);
3457 if (HAVE_OLEAUT32_I8
)
3459 VARXOR(EMPTY
,0,I8
,0,I8
,0);
3460 VARXOR(EMPTY
,0,I8
,1,I8
,1);
3461 VARXOR(EMPTY
,0,UI8
,0,I4
,0);
3462 VARXOR(EMPTY
,0,UI8
,1,I4
,1);
3464 VARXOR(EMPTY
,0,INT
,0,I4
,0);
3465 VARXOR(EMPTY
,0,INT
,1,I4
,1);
3466 VARXOR(EMPTY
,0,UINT
,0,I4
,0);
3467 VARXOR(EMPTY
,0,UINT
,1,I4
,1);
3468 VARXOR(EMPTY
,0,BOOL
,0,I2
,0);
3469 VARXOR(EMPTY
,0,BOOL
,1,I2
,1);
3470 VARXOR(EMPTY
,0,R4
,0,I4
,0);
3471 VARXOR(EMPTY
,0,R4
,1,I4
,1);
3472 VARXOR(EMPTY
,0,R8
,0,I4
,0);
3473 VARXOR(EMPTY
,0,R8
,1,I4
,1);
3474 rbstr
= SysAllocString(szFalse
);
3475 VARXOR(EMPTY
,0,BSTR
,rbstr
,I2
,0);
3476 SysFreeString(rbstr
);
3477 rbstr
= SysAllocString(szTrue
);
3478 VARXOR(EMPTY
,0,BSTR
,rbstr
,I2
,-1);
3479 VARXORCY(EMPTY
,0,10000,I4
,1);
3480 SysFreeString(rbstr
);
3482 /* NULL OR 0 = NULL. NULL OR n = n */
3483 VARXOR(NULL
,0,NULL
,0,NULL
,0);
3484 VARXOR(NULL
,1,NULL
,0,NULL
,0);
3485 VARXOR(NULL
,0,I1
,0,NULL
,0);
3486 VARXOR(NULL
,0,I1
,1,NULL
,0);
3487 VARXOR(NULL
,0,UI1
,0,NULL
,0);
3488 VARXOR(NULL
,0,UI1
,1,NULL
,0);
3489 VARXOR(NULL
,0,I2
,0,NULL
,0);
3490 VARXOR(NULL
,0,I2
,1,NULL
,0);
3491 VARXOR(NULL
,0,UI2
,0,NULL
,0);
3492 VARXOR(NULL
,0,UI2
,1,NULL
,0);
3493 VARXOR(NULL
,0,I4
,0,NULL
,0);
3494 VARXOR(NULL
,0,I4
,1,NULL
,0);
3495 VARXOR(NULL
,0,UI4
,0,NULL
,0);
3496 VARXOR(NULL
,0,UI4
,1,NULL
,0);
3497 if (HAVE_OLEAUT32_I8
)
3499 VARXOR(NULL
,0,I8
,0,NULL
,0);
3500 VARXOR(NULL
,0,I8
,1,NULL
,0);
3501 VARXOR(NULL
,0,UI8
,0,NULL
,0);
3502 VARXOR(NULL
,0,UI8
,1,NULL
,0);
3504 VARXOR(NULL
,0,INT
,0,NULL
,0);
3505 VARXOR(NULL
,0,INT
,1,NULL
,0);
3506 VARXOR(NULL
,0,UINT
,0,NULL
,0);
3507 VARXOR(NULL
,0,UINT
,1,NULL
,0);
3508 VARXOR(NULL
,0,BOOL
,0,NULL
,0);
3509 VARXOR(NULL
,0,BOOL
,1,NULL
,0);
3510 VARXOR(NULL
,0,R4
,0,NULL
,0);
3511 VARXOR(NULL
,0,R4
,1,NULL
,0);
3512 VARXOR(NULL
,0,R8
,0,NULL
,0);
3513 VARXOR(NULL
,0,R8
,1,NULL
,0);
3514 rbstr
= SysAllocString(szFalse
);
3515 VARXOR(NULL
,0,BSTR
,rbstr
,NULL
,0);
3516 SysFreeString(rbstr
);
3517 rbstr
= SysAllocString(szTrue
);
3518 VARXOR(NULL
,0,BSTR
,rbstr
,NULL
,0);
3519 SysFreeString(rbstr
);
3520 VARXORCY(NULL
,0,10000,NULL
,0);
3521 VARXORCY(NULL
,0,0,NULL
,0);
3523 VARXOR(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
);
3524 VARXOR(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
);
3525 VARXOR(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
);
3526 VARXOR(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_FALSE
);
3527 /* Assume x,y & y,x are the same from now on to reduce the number of tests */
3528 VARXOR(BOOL
,VARIANT_TRUE
,I1
,-1,I4
,0);
3529 VARXOR(BOOL
,VARIANT_TRUE
,I1
,0,I4
,-1);
3530 VARXOR(BOOL
,VARIANT_FALSE
,I1
,0,I4
,0);
3531 VARXOR(BOOL
,VARIANT_TRUE
,UI1
,255,I2
,-256);
3532 VARXOR(BOOL
,VARIANT_TRUE
,UI1
,0,I2
,-1);
3533 VARXOR(BOOL
,VARIANT_FALSE
,UI1
,0,I2
,0);
3534 VARXOR(BOOL
,VARIANT_TRUE
,I2
,-1,I2
,0);
3535 VARXOR(BOOL
,VARIANT_TRUE
,I2
,0,I2
,-1);
3536 VARXOR(BOOL
,VARIANT_FALSE
,I2
,0,I2
,0);
3537 VARXOR(BOOL
,VARIANT_TRUE
,UI2
,65535,I4
,-65536);
3538 VARXOR(BOOL
,VARIANT_TRUE
,UI2
,0,I4
,-1);
3539 VARXOR(BOOL
,VARIANT_FALSE
,UI2
,0,I4
,0);
3540 VARXOR(BOOL
,VARIANT_TRUE
,I4
,-1,I4
,0);
3541 VARXOR(BOOL
,VARIANT_TRUE
,I4
,0,I4
,-1);
3542 VARXOR(BOOL
,VARIANT_FALSE
,I4
,0,I4
,0);
3543 VARXOR(BOOL
,VARIANT_TRUE
,UI4
,0xffffffff,I4
,0);
3544 VARXOR(BOOL
,VARIANT_TRUE
,UI4
,0,I4
,-1);
3545 VARXOR(BOOL
,VARIANT_FALSE
,UI4
,0,I4
,0);
3546 VARXOR(BOOL
,VARIANT_TRUE
,R4
,-1,I4
,0);
3547 VARXOR(BOOL
,VARIANT_TRUE
,R4
,0,I4
,-1);
3548 VARXOR(BOOL
,VARIANT_FALSE
,R4
,0,I4
,0);
3549 VARXOR(BOOL
,VARIANT_TRUE
,R8
,-1,I4
,0);
3550 VARXOR(BOOL
,VARIANT_TRUE
,R8
,0,I4
,-1);
3551 VARXOR(BOOL
,VARIANT_FALSE
,R8
,0,I4
,0);
3552 VARXOR(BOOL
,VARIANT_TRUE
,DATE
,-1,I4
,0);
3553 VARXOR(BOOL
,VARIANT_TRUE
,DATE
,0,I4
,-1);
3554 VARXOR(BOOL
,VARIANT_FALSE
,DATE
,0,I4
,0);
3555 if (HAVE_OLEAUT32_I8
)
3557 VARXOR(BOOL
,VARIANT_TRUE
,I8
,-1,I8
,0);
3558 VARXOR(BOOL
,VARIANT_TRUE
,I8
,0,I8
,-1);
3559 VARXOR(BOOL
,VARIANT_FALSE
,I8
,0,I8
,0);
3560 /* This returns DISP_E_OVERFLOW which indicates that a conversion
3561 * to I4 is performed.
3563 /* VARXOR(BOOL,VARIANT_TRUE,UI8,-1,I4,-1); */
3564 VARXOR(BOOL
,VARIANT_TRUE
,UI8
,0,I4
,-1);
3565 VARXOR(BOOL
,VARIANT_FALSE
,UI8
,0,I4
,0);
3567 VARXOR(BOOL
,VARIANT_TRUE
,INT
,-1,I4
,0);
3568 VARXOR(BOOL
,VARIANT_TRUE
,INT
,0,I4
,-1);
3569 VARXOR(BOOL
,VARIANT_FALSE
,INT
,0,I4
,0);
3570 VARXOR(BOOL
,VARIANT_TRUE
,UINT
,0xffffffff,I4
,0);
3571 VARXOR(BOOL
,VARIANT_TRUE
,UINT
,0,I4
,-1);
3572 VARXOR(BOOL
,VARIANT_FALSE
,UINT
,0,I4
,0);
3573 rbstr
= SysAllocString(szFalse
);
3574 VARXOR(BOOL
,VARIANT_FALSE
,BSTR
,rbstr
,BOOL
,VARIANT_FALSE
);
3575 VARXOR(BOOL
,VARIANT_TRUE
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
3576 SysFreeString(rbstr
);
3577 rbstr
= SysAllocString(szTrue
);
3578 VARXOR(BOOL
,VARIANT_FALSE
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
3579 VARXOR(BOOL
,VARIANT_TRUE
,BSTR
,rbstr
,BOOL
,VARIANT_FALSE
);
3580 SysFreeString(rbstr
);
3581 VARXORCY(BOOL
,VARIANT_TRUE
,10000,I4
,-2);
3582 VARXORCY(BOOL
,VARIANT_TRUE
,0,I4
,-1);
3583 VARXORCY(BOOL
,VARIANT_FALSE
,0,I4
,0);
3585 VARXOR(I1
,-1,I1
,-1,I4
,0);
3586 VARXOR(I1
,-1,I1
,0,I4
,-1);
3587 VARXOR(I1
,0,I1
,0,I4
,0);
3588 VARXOR(I1
,-1,UI1
,255,I4
,-256);
3589 VARXOR(I1
,-1,UI1
,0,I4
,-1);
3590 VARXOR(I1
,0,UI1
,0,I4
,0);
3591 VARXOR(I1
,-1,I2
,-1,I4
,0);
3592 VARXOR(I1
,-1,I2
,0,I4
,-1);
3593 VARXOR(I1
,0,I2
,0,I4
,0);
3594 VARXOR(I1
,-1,UI2
,65535,I4
,-65536);
3595 VARXOR(I1
,-1,UI2
,0,I4
,-1);
3596 VARXOR(I1
,0,UI2
,0,I4
,0);
3597 VARXOR(I1
,-1,I4
,-1,I4
,0);
3598 VARXOR(I1
,-1,I4
,0,I4
,-1);
3599 VARXOR(I1
,0,I4
,0,I4
,0);
3600 VARXOR(I1
,-1,UI4
,0xffffffff,I4
,0);
3601 VARXOR(I1
,-1,UI4
,0,I4
,-1);
3602 VARXOR(I1
,0,UI4
,0,I4
,0);
3603 VARXOR(I1
,-1,R4
,-1,I4
,0);
3604 VARXOR(I1
,-1,R4
,0,I4
,-1);
3605 VARXOR(I1
,0,R4
,0,I4
,0);
3606 VARXOR(I1
,-1,R8
,-1,I4
,0);
3607 VARXOR(I1
,-1,R8
,0,I4
,-1);
3608 VARXOR(I1
,0,R8
,0,I4
,0);
3609 VARXOR(I1
,-1,DATE
,-1,I4
,0);
3610 VARXOR(I1
,-1,DATE
,0,I4
,-1);
3611 VARXOR(I1
,0,DATE
,0,I4
,0);
3612 if (HAVE_OLEAUT32_I8
)
3614 VARXOR(I1
,-1,I8
,-1,I8
,0);
3615 VARXOR(I1
,-1,I8
,0,I8
,-1);
3616 VARXOR(I1
,0,I8
,0,I8
,0);
3617 VARXOR(I1
,-1,UI8
,0,I4
,-1);
3618 VARXOR(I1
,0,UI8
,0,I4
,0);
3620 VARXOR(I1
,-1,INT
,-1,I4
,0);
3621 VARXOR(I1
,-1,INT
,0,I4
,-1);
3622 VARXOR(I1
,0,INT
,0,I4
,0);
3623 VARXOR(I1
,-1,UINT
,0xffffffff,I4
,0);
3624 VARXOR(I1
,-1,UINT
,0,I4
,-1);
3625 VARXOR(I1
,0,UINT
,0,I4
,0);
3626 rbstr
= SysAllocString(szFalse
);
3627 VARXOR(I1
,0,BSTR
,rbstr
,I4
,0);
3628 VARXOR(I1
,-1,BSTR
,rbstr
,I4
,-1);
3629 SysFreeString(rbstr
);
3630 rbstr
= SysAllocString(szTrue
);
3631 VARXOR(I1
,0,BSTR
,rbstr
,I4
,-1);
3632 VARXOR(I1
,-1,BSTR
,rbstr
,I4
,0);
3633 SysFreeString(rbstr
);
3634 VARXORCY(I1
,-1,10000,I4
,-2);
3635 VARXORCY(I1
,-1,0,I4
,-1);
3636 VARXORCY(I1
,0,0,I4
,0);
3638 VARXOR(UI1
,255,UI1
,255,UI1
,0);
3639 VARXOR(UI1
,255,UI1
,0,UI1
,255);
3640 VARXOR(UI1
,0,UI1
,0,UI1
,0);
3641 VARXOR(UI1
,255,I2
,-1,I2
,-256);
3642 VARXOR(UI1
,255,I2
,0,I2
,255);
3643 VARXOR(UI1
,0,I2
,0,I2
,0);
3644 VARXOR(UI1
,255,UI2
,65535,I4
,65280);
3645 VARXOR(UI1
,255,UI2
,0,I4
,255);
3646 VARXOR(UI1
,0,UI2
,0,I4
,0);
3647 VARXOR(UI1
,255,I4
,-1,I4
,-256);
3648 VARXOR(UI1
,255,I4
,0,I4
,255);
3649 VARXOR(UI1
,0,I4
,0,I4
,0);
3650 VARXOR(UI1
,255,UI4
,0xffffffff,I4
,-256);
3651 VARXOR(UI1
,255,UI4
,0,I4
,255);
3652 VARXOR(UI1
,0,UI4
,0,I4
,0);
3653 VARXOR(UI1
,255,R4
,-1,I4
,-256);
3654 VARXOR(UI1
,255,R4
,0,I4
,255);
3655 VARXOR(UI1
,0,R4
,0,I4
,0);
3656 VARXOR(UI1
,255,R8
,-1,I4
,-256);
3657 VARXOR(UI1
,255,R8
,0,I4
,255);
3658 VARXOR(UI1
,0,R8
,0,I4
,0);
3659 VARXOR(UI1
,255,DATE
,-1,I4
,-256);
3660 VARXOR(UI1
,255,DATE
,0,I4
,255);
3661 VARXOR(UI1
,0,DATE
,0,I4
,0);
3662 if (HAVE_OLEAUT32_I8
)
3664 VARXOR(UI1
,255,I8
,-1,I8
,-256);
3665 VARXOR(UI1
,255,I8
,0,I8
,255);
3666 VARXOR(UI1
,0,I8
,0,I8
,0);
3667 VARXOR(UI1
,255,UI8
,0,I4
,255);
3668 VARXOR(UI1
,0,UI8
,0,I4
,0);
3670 VARXOR(UI1
,255,INT
,-1,I4
,-256);
3671 VARXOR(UI1
,255,INT
,0,I4
,255);
3672 VARXOR(UI1
,0,INT
,0,I4
,0);
3673 VARXOR(UI1
,255,UINT
,0xffffffff,I4
,-256);
3674 VARXOR(UI1
,255,UINT
,0,I4
,255);
3675 VARXOR(UI1
,0,UINT
,0,I4
,0);
3676 rbstr
= SysAllocString(szFalse
);
3677 VARXOR(UI1
,0,BSTR
,rbstr
,I2
,0);
3678 VARXOR(UI1
,255,BSTR
,rbstr
,I2
,255);
3679 SysFreeString(rbstr
);
3680 rbstr
= SysAllocString(szTrue
);
3681 VARXOR(UI1
,0,BSTR
,rbstr
,I2
,-1);
3682 VARXOR(UI1
,255,BSTR
,rbstr
,I2
,-256);
3683 SysFreeString(rbstr
);
3684 VARXORCY(UI1
,255,10000,I4
,254);
3685 VARXORCY(UI1
,255,0,I4
,255);
3686 VARXORCY(UI1
,0,0,I4
,0);
3688 VARXOR(I2
,-1,I2
,-1,I2
,0);
3689 VARXOR(I2
,-1,I2
,0,I2
,-1);
3690 VARXOR(I2
,0,I2
,0,I2
,0);
3691 VARXOR(I2
,-1,UI2
,65535,I4
,-65536);
3692 VARXOR(I2
,-1,UI2
,0,I4
,-1);
3693 VARXOR(I2
,0,UI2
,0,I4
,0);
3694 VARXOR(I2
,-1,I4
,-1,I4
,0);
3695 VARXOR(I2
,-1,I4
,0,I4
,-1);
3696 VARXOR(I2
,0,I4
,0,I4
,0);
3697 VARXOR(I2
,-1,UI4
,0xffffffff,I4
,0);
3698 VARXOR(I2
,-1,UI4
,0,I4
,-1);
3699 VARXOR(I2
,0,UI4
,0,I4
,0);
3700 VARXOR(I2
,-1,R4
,-1,I4
,0);
3701 VARXOR(I2
,-1,R4
,0,I4
,-1);
3702 VARXOR(I2
,0,R4
,0,I4
,0);
3703 VARXOR(I2
,-1,R8
,-1,I4
,0);
3704 VARXOR(I2
,-1,R8
,0,I4
,-1);
3705 VARXOR(I2
,0,R8
,0,I4
,0);
3706 VARXOR(I2
,-1,DATE
,-1,I4
,0);
3707 VARXOR(I2
,-1,DATE
,0,I4
,-1);
3708 VARXOR(I2
,0,DATE
,0,I4
,0);
3709 if (HAVE_OLEAUT32_I8
)
3711 VARXOR(I2
,-1,I8
,-1,I8
,0);
3712 VARXOR(I2
,-1,I8
,0,I8
,-1);
3713 VARXOR(I2
,0,I8
,0,I8
,0);
3714 VARXOR(I2
,-1,UI8
,0,I4
,-1);
3715 VARXOR(I2
,0,UI8
,0,I4
,0);
3717 VARXOR(I2
,-1,INT
,-1,I4
,0);
3718 VARXOR(I2
,-1,INT
,0,I4
,-1);
3719 VARXOR(I2
,0,INT
,0,I4
,0);
3720 VARXOR(I2
,-1,UINT
,0xffffffff,I4
,0);
3721 VARXOR(I2
,-1,UINT
,0,I4
,-1);
3722 VARXOR(I2
,0,UINT
,0,I4
,0);
3723 rbstr
= SysAllocString(szFalse
);
3724 VARXOR(I2
,0,BSTR
,rbstr
,I2
,0);
3725 VARXOR(I2
,-1,BSTR
,rbstr
,I2
,-1);
3726 SysFreeString(rbstr
);
3727 rbstr
= SysAllocString(szTrue
);
3728 VARXOR(I2
,0,BSTR
,rbstr
,I2
,-1);
3729 VARXOR(I2
,-1,BSTR
,rbstr
,I2
,0);
3730 SysFreeString(rbstr
);
3731 VARXORCY(I2
,-1,10000,I4
,-2);
3732 VARXORCY(I2
,-1,0,I4
,-1);
3733 VARXORCY(I2
,0,0,I4
,0);
3735 VARXOR(UI2
,65535,UI2
,65535,I4
,0);
3736 VARXOR(UI2
,65535,UI2
,0,I4
,65535);
3737 VARXOR(UI2
,0,UI2
,0,I4
,0);
3738 VARXOR(UI2
,65535,I4
,-1,I4
,-65536);
3739 VARXOR(UI2
,65535,I4
,0,I4
,65535);
3740 VARXOR(UI2
,0,I4
,0,I4
,0);
3741 VARXOR(UI2
,65535,UI4
,0xffffffff,I4
,-65536);
3742 VARXOR(UI2
,65535,UI4
,0,I4
,65535);
3743 VARXOR(UI2
,0,UI4
,0,I4
,0);
3744 VARXOR(UI2
,65535,R4
,-1,I4
,-65536);
3745 VARXOR(UI2
,65535,R4
,0,I4
,65535);
3746 VARXOR(UI2
,0,R4
,0,I4
,0);
3747 VARXOR(UI2
,65535,R8
,-1,I4
,-65536);
3748 VARXOR(UI2
,65535,R8
,0,I4
,65535);
3749 VARXOR(UI2
,0,R8
,0,I4
,0);
3750 VARXOR(UI2
,65535,DATE
,-1,I4
,-65536);
3751 VARXOR(UI2
,65535,DATE
,0,I4
,65535);
3752 VARXOR(UI2
,0,DATE
,0,I4
,0);
3753 if (HAVE_OLEAUT32_I8
)
3755 VARXOR(UI2
,65535,I8
,-1,I8
,-65536);
3756 VARXOR(UI2
,65535,I8
,0,I8
,65535);
3757 VARXOR(UI2
,0,I8
,0,I8
,0);
3758 VARXOR(UI2
,65535,UI8
,0,I4
,65535);
3759 VARXOR(UI2
,0,UI8
,0,I4
,0);
3761 VARXOR(UI2
,65535,INT
,-1,I4
,-65536);
3762 VARXOR(UI2
,65535,INT
,0,I4
,65535);
3763 VARXOR(UI2
,0,INT
,0,I4
,0);
3764 VARXOR(UI2
,65535,UINT
,0xffffffff,I4
,-65536);
3765 VARXOR(UI2
,65535,UINT
,0,I4
,65535);
3766 VARXOR(UI2
,0,UINT
,0,I4
,0);
3767 rbstr
= SysAllocString(szFalse
);
3768 VARXOR(UI2
,0,BSTR
,rbstr
,I4
,0);
3769 VARXOR(UI2
,65535,BSTR
,rbstr
,I4
,65535);
3770 SysFreeString(rbstr
);
3771 rbstr
= SysAllocString(szTrue
);
3772 VARXOR(UI2
,0,BSTR
,rbstr
,I4
,-1);
3773 VARXOR(UI2
,65535,BSTR
,rbstr
,I4
,-65536);
3774 SysFreeString(rbstr
);
3775 VARXORCY(UI2
,65535,10000,I4
,65534);
3776 VARXORCY(UI2
,65535,0,I4
,65535);
3777 VARXORCY(UI2
,0,0,I4
,0);
3779 VARXOR(I4
,-1,I4
,-1,I4
,0);
3780 VARXOR(I4
,-1,I4
,0,I4
,-1);
3781 VARXOR(I4
,0,I4
,0,I4
,0);
3782 VARXOR(I4
,-1,UI4
,0xffffffff,I4
,0);
3783 VARXOR(I4
,-1,UI4
,0,I4
,-1);
3784 VARXOR(I4
,0,UI4
,0,I4
,0);
3785 VARXOR(I4
,-1,R4
,-1,I4
,0);
3786 VARXOR(I4
,-1,R4
,0,I4
,-1);
3787 VARXOR(I4
,0,R4
,0,I4
,0);
3788 VARXOR(I4
,-1,R8
,-1,I4
,0);
3789 VARXOR(I4
,-1,R8
,0,I4
,-1);
3790 VARXOR(I4
,0,R8
,0,I4
,0);
3791 VARXOR(I4
,-1,DATE
,-1,I4
,0);
3792 VARXOR(I4
,-1,DATE
,0,I4
,-1);
3793 VARXOR(I4
,0,DATE
,0,I4
,0);
3794 if (HAVE_OLEAUT32_I8
)
3796 VARXOR(I4
,-1,I8
,-1,I8
,0);
3797 VARXOR(I4
,-1,I8
,0,I8
,-1);
3798 VARXOR(I4
,0,I8
,0,I8
,0);
3799 VARXOR(I4
,-1,UI8
,0,I4
,-1);
3800 VARXOR(I4
,0,UI8
,0,I4
,0);
3802 VARXOR(I4
,-1,INT
,-1,I4
,0);
3803 VARXOR(I4
,-1,INT
,0,I4
,-1);
3804 VARXOR(I4
,0,INT
,0,I4
,0);
3805 VARXOR(I4
,-1,UINT
,0xffffffff,I4
,0);
3806 VARXOR(I4
,-1,UINT
,0,I4
,-1);
3807 VARXOR(I4
,0,UINT
,0,I4
,0);
3808 rbstr
= SysAllocString(szFalse
);
3809 VARXOR(I4
,0,BSTR
,rbstr
,I4
,0);
3810 VARXOR(I4
,-1,BSTR
,rbstr
,I4
,-1);
3811 SysFreeString(rbstr
);
3812 rbstr
= SysAllocString(szTrue
);
3813 VARXOR(I4
,0,BSTR
,rbstr
,I4
,-1);
3814 VARXOR(I4
,-1,BSTR
,rbstr
,I4
,0);
3815 SysFreeString(rbstr
);
3816 VARXORCY(I4
,-1,10000,I4
,-2);
3817 VARXORCY(I4
,-1,0,I4
,-1);
3818 VARXORCY(I4
,0,0,I4
,0);
3820 VARXOR(UI4
,0xffffffff,UI4
,0xffffffff,I4
,0);
3821 VARXOR(UI4
,0xffffffff,UI4
,0,I4
,-1);
3822 VARXOR(UI4
,0,UI4
,0,I4
,0);
3823 VARXOR(UI4
,0xffffffff,R4
,-1,I4
,0);
3824 VARXOR(UI4
,0xffffffff,R4
,0,I4
,-1);
3825 VARXOR(UI4
,0,R4
,0,I4
,0);
3826 VARXOR(UI4
,0xffffffff,R8
,-1,I4
,0);
3827 VARXOR(UI4
,0xffffffff,R8
,0,I4
,-1);
3828 VARXOR(UI4
,0,R8
,0,I4
,0);
3829 VARXOR(UI4
,0xffffffff,DATE
,-1,I4
,0);
3830 VARXOR(UI4
,0xffffffff,DATE
,0,I4
,-1);
3831 VARXOR(UI4
,0,DATE
,0,I4
,0);
3832 if (HAVE_OLEAUT32_I8
)
3834 VARXOR(UI4
,0xffffffff,I8
,0,I8
,0xffffffff);
3835 VARXOR(UI4
,VARIANT_FALSE
,I8
,VARIANT_FALSE
,I8
,0);
3836 VARXOR(UI4
,0,I8
,0,I8
,0);
3837 VARXOR(UI4
,0xffffffff,UI8
,0,I4
,-1);
3838 VARXOR(UI4
,0,UI8
,0,I4
,0);
3840 VARXOR(UI4
,0xffffffff,INT
,-1,I4
,0);
3841 VARXOR(UI4
,0xffffffff,INT
,0,I4
,-1);
3842 VARXOR(UI4
,0,INT
,0,I4
,0);
3843 VARXOR(UI4
,0xffffffff,UINT
,0xffffffff,I4
,0);
3844 VARXOR(UI4
,0xffffffff,UINT
,0,I4
,-1);
3845 VARXOR(UI4
,0,UINT
,0,I4
,0);
3846 rbstr
= SysAllocString(szFalse
);
3847 VARXOR(UI4
,0,BSTR
,rbstr
,I4
,0);
3848 VARXOR(UI4
,0xffffffff,BSTR
,rbstr
,I4
,-1);
3849 SysFreeString(rbstr
);
3850 rbstr
= SysAllocString(szTrue
);
3851 VARXOR(UI4
,0,BSTR
,rbstr
,I4
,-1);
3852 VARXOR(UI4
,0xffffffff,BSTR
,rbstr
,I4
,0);
3853 SysFreeString(rbstr
);
3854 VARXORCY(UI4
,0xffffffff,10000,I4
,-2);
3855 VARXORCY(UI4
,0xffffffff,0,I4
,-1);
3856 VARXORCY(UI4
,0,0,I4
,0);
3858 VARXOR(R4
,-1,R4
,-1,I4
,0);
3859 VARXOR(R4
,-1,R4
,0,I4
,-1);
3860 VARXOR(R4
,0,R4
,0,I4
,0);
3861 VARXOR(R4
,-1,R8
,-1,I4
,0);
3862 VARXOR(R4
,-1,R8
,0,I4
,-1);
3863 VARXOR(R4
,0,R8
,0,I4
,0);
3864 VARXOR(R4
,-1,DATE
,-1,I4
,0);
3865 VARXOR(R4
,-1,DATE
,0,I4
,-1);
3866 VARXOR(R4
,0,DATE
,0,I4
,0);
3867 if (HAVE_OLEAUT32_I8
)
3869 VARXOR(R4
,-1,I8
,-1,I8
,0);
3870 VARXOR(R4
,-1,I8
,0,I8
,-1);
3871 VARXOR(R4
,0,I8
,0,I8
,0);
3872 VARXOR(R4
,-1,UI8
,0,I4
,-1);
3873 VARXOR(R4
,0,UI8
,0,I4
,0);
3875 VARXOR(R4
,-1,INT
,-1,I4
,0);
3876 VARXOR(R4
,-1,INT
,0,I4
,-1);
3877 VARXOR(R4
,0,INT
,0,I4
,0);
3878 VARXOR(R4
,-1,UINT
,0xffffffff,I4
,0);
3879 VARXOR(R4
,-1,UINT
,0,I4
,-1);
3880 VARXOR(R4
,0,UINT
,0,I4
,0);
3881 rbstr
= SysAllocString(szFalse
);
3882 VARXOR(R4
,0,BSTR
,rbstr
,I4
,0);
3883 VARXOR(R4
,-1,BSTR
,rbstr
,I4
,-1);
3884 SysFreeString(rbstr
);
3885 rbstr
= SysAllocString(szTrue
);
3886 VARXOR(R4
,0,BSTR
,rbstr
,I4
,-1);
3887 VARXOR(R4
,-1,BSTR
,rbstr
,I4
,0);
3888 SysFreeString(rbstr
);
3889 VARXORCY(R4
,-1,10000,I4
,-2);
3890 VARXORCY(R4
,-1,0,I4
,-1);
3891 VARXORCY(R4
,0,0,I4
,0);
3893 VARXOR(R8
,-1,R8
,-1,I4
,0);
3894 VARXOR(R8
,-1,R8
,0,I4
,-1);
3895 VARXOR(R8
,0,R8
,0,I4
,0);
3896 VARXOR(R8
,-1,DATE
,-1,I4
,0);
3897 VARXOR(R8
,-1,DATE
,0,I4
,-1);
3898 VARXOR(R8
,0,DATE
,0,I4
,0);
3899 if (HAVE_OLEAUT32_I8
)
3901 VARXOR(R8
,-1,I8
,-1,I8
,0);
3902 VARXOR(R8
,-1,I8
,0,I8
,-1);
3903 VARXOR(R8
,0,I8
,0,I8
,0);
3904 VARXOR(R8
,-1,UI8
,0,I4
,-1);
3905 VARXOR(R8
,0,UI8
,0,I4
,0);
3907 VARXOR(R8
,-1,INT
,-1,I4
,0);
3908 VARXOR(R8
,-1,INT
,0,I4
,-1);
3909 VARXOR(R8
,0,INT
,0,I4
,0);
3910 VARXOR(R8
,-1,UINT
,0xffffffff,I4
,0);
3911 VARXOR(R8
,-1,UINT
,0,I4
,-1);
3912 VARXOR(R8
,0,UINT
,0,I4
,0);
3913 rbstr
= SysAllocString(szFalse
);
3914 VARXOR(R8
,0,BSTR
,rbstr
,I4
,0);
3915 VARXOR(R8
,-1,BSTR
,rbstr
,I4
,-1);
3916 SysFreeString(rbstr
);
3917 rbstr
= SysAllocString(szTrue
);
3918 VARXOR(R8
,0,BSTR
,rbstr
,I4
,-1);
3919 VARXOR(R8
,-1,BSTR
,rbstr
,I4
,0);
3920 SysFreeString(rbstr
);
3921 VARXORCY(R8
,-1,10000,I4
,-2);
3922 VARXORCY(R8
,-1,0,I4
,-1);
3923 VARXORCY(R8
,0,0,I4
,0);
3925 VARXOR(DATE
,-1,DATE
,-1,I4
,0);
3926 VARXOR(DATE
,-1,DATE
,0,I4
,-1);
3927 VARXOR(DATE
,0,DATE
,0,I4
,0);
3928 if (HAVE_OLEAUT32_I8
)
3930 VARXOR(DATE
,-1,I8
,-1,I8
,0);
3931 VARXOR(DATE
,-1,I8
,0,I8
,-1);
3932 VARXOR(DATE
,0,I8
,0,I8
,0);
3933 VARXOR(DATE
,-1,UI8
,0,I4
,-1);
3934 VARXOR(DATE
,0,UI8
,0,I4
,0);
3936 VARXOR(DATE
,-1,INT
,-1,I4
,0);
3937 VARXOR(DATE
,-1,INT
,0,I4
,-1);
3938 VARXOR(DATE
,0,INT
,0,I4
,0);
3939 VARXOR(DATE
,-1,UINT
,0xffffffff,I4
,0);
3940 VARXOR(DATE
,-1,UINT
,0,I4
,-1);
3941 VARXOR(DATE
,0,UINT
,0,I4
,0);
3942 rbstr
= SysAllocString(szFalse
);
3943 VARXOR(DATE
,0,BSTR
,rbstr
,I4
,0);
3944 VARXOR(DATE
,-1,BSTR
,rbstr
,I4
,-1);
3945 SysFreeString(rbstr
);
3946 rbstr
= SysAllocString(szTrue
);
3947 VARXOR(DATE
,0,BSTR
,rbstr
,I4
,-1);
3948 VARXOR(DATE
,-1,BSTR
,rbstr
,I4
,0);
3949 SysFreeString(rbstr
);
3950 VARXORCY(DATE
,-1,10000,I4
,-2);
3951 VARXORCY(DATE
,-1,0,I4
,-1);
3952 VARXORCY(DATE
,0,0,I4
,0);
3954 if (HAVE_OLEAUT32_I8
)
3956 VARXOR(I8
,-1,I8
,-1,I8
,0);
3957 VARXOR(I8
,-1,I8
,0,I8
,-1);
3958 VARXOR(I8
,0,I8
,0,I8
,0);
3959 VARXOR(I8
,-1,UI8
,0,I8
,-1);
3960 VARXOR(I8
,0,UI8
,0,I8
,0);
3961 VARXOR(I8
,-1,UINT
,0,I8
,-1);
3962 VARXOR(I8
,0,UINT
,0,I8
,0);
3963 rbstr
= SysAllocString(szFalse
);
3964 VARXOR(I8
,0,BSTR
,rbstr
,I8
,0);
3965 VARXOR(I8
,-1,BSTR
,rbstr
,I8
,-1);
3966 SysFreeString(rbstr
);
3967 rbstr
= SysAllocString(szTrue
);
3968 VARXOR(I8
,0,BSTR
,rbstr
,I8
,-1);
3969 VARXOR(I8
,-1,BSTR
,rbstr
,I8
,0);
3970 SysFreeString(rbstr
);
3971 VARXORCY(I8
,-1,10000,I8
,-2);
3972 VARXORCY(I8
,-1,0,I8
,-1);
3973 VARXORCY(I8
,0,0,I8
,0);
3975 VARXOR(UI8
,0xffff,UI8
,0xffff,I4
,0);
3976 VARXOR(UI8
,0xffff,UI8
,0,I4
,0xffff);
3977 VARXOR(UI8
,0,UI8
,0,I4
,0);
3978 VARXOR(UI8
,0xffff,INT
,-1,I4
,-65536);
3979 VARXOR(UI8
,0xffff,INT
,0,I4
,0xffff);
3980 VARXOR(UI8
,0,INT
,0,I4
,0);
3981 VARXOR(UI8
,0xffff,UINT
,0xffff,I4
,0);
3982 VARXOR(UI8
,0xffff,UINT
,0,I4
,0xffff);
3983 VARXOR(UI8
,0,UINT
,0,I4
,0);
3984 rbstr
= SysAllocString(szFalse
);
3985 VARXOR(UI8
,0,BSTR
,rbstr
,I4
,0);
3986 VARXOR(UI8
,0xffff,BSTR
,rbstr
,I4
,0xffff);
3987 SysFreeString(rbstr
);
3988 rbstr
= SysAllocString(szTrue
);
3989 VARXOR(UI8
,0,BSTR
,rbstr
,I4
,-1);
3990 VARXOR(UI8
,0xffff,BSTR
,rbstr
,I4
,-65536);
3991 SysFreeString(rbstr
);
3992 VARXORCY(UI8
,0xffff,10000,I4
,65534);
3993 VARXORCY(UI8
,0xffff,0,I4
,0xffff);
3994 VARXORCY(UI8
,0,0,I4
,0);
3997 VARXOR(INT
,-1,INT
,-1,I4
,0);
3998 VARXOR(INT
,-1,INT
,0,I4
,-1);
3999 VARXOR(INT
,0,INT
,0,I4
,0);
4000 VARXOR(INT
,-1,UINT
,0xffff,I4
,-65536);
4001 VARXOR(INT
,-1,UINT
,0,I4
,-1);
4002 VARXOR(INT
,0,UINT
,0,I4
,0);
4003 rbstr
= SysAllocString(szFalse
);
4004 VARXOR(INT
,0,BSTR
,rbstr
,I4
,0);
4005 VARXOR(INT
,-1,BSTR
,rbstr
,I4
,-1);
4006 SysFreeString(rbstr
);
4007 rbstr
= SysAllocString(szTrue
);
4008 VARXOR(INT
,0,BSTR
,rbstr
,I4
,-1);
4009 VARXOR(INT
,-1,BSTR
,rbstr
,I4
,0);
4010 SysFreeString(rbstr
);
4011 VARXORCY(INT
,-1,10000,I4
,-2);
4012 VARXORCY(INT
,-1,0,I4
,-1);
4013 VARXORCY(INT
,0,0,I4
,0);
4015 VARXOR(UINT
,0xffff,UINT
,0xffff,I4
,0);
4016 VARXOR(UINT
,0xffff,UINT
,0,I4
,0xffff);
4017 VARXOR(UINT
,0,UINT
,0,I4
,0);
4018 rbstr
= SysAllocString(szFalse
);
4019 VARXOR(UINT
,0,BSTR
,rbstr
,I4
,0);
4020 VARXOR(UINT
,0xffff,BSTR
,rbstr
,I4
,0xffff);
4021 SysFreeString(rbstr
);
4022 rbstr
= SysAllocString(szTrue
);
4023 VARXOR(UINT
,0,BSTR
,rbstr
,I4
,-1);
4024 VARXOR(UINT
,0xffff,BSTR
,rbstr
,I4
,-65536);
4025 SysFreeString(rbstr
);
4026 VARXORCY(UINT
,0xffff,10000,I4
,65534);
4027 VARXORCY(UINT
,0xffff,0,I4
,0xffff);
4028 VARXORCY(UINT
,0,0,I4
,0);
4030 lbstr
= SysAllocString(szFalse
);
4031 rbstr
= SysAllocString(szFalse
);
4032 VARXOR(BSTR
,lbstr
,BSTR
,rbstr
,BOOL
,0);
4033 SysFreeString(rbstr
);
4034 rbstr
= SysAllocString(szTrue
);
4035 VARXOR(BSTR
,lbstr
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
4036 SysFreeString(lbstr
);
4037 lbstr
= SysAllocString(szTrue
);
4038 VARXOR(BSTR
,lbstr
,BSTR
,rbstr
,BOOL
,VARIANT_FALSE
);
4039 VARXORCY(BSTR
,lbstr
,10000,I4
,-2);
4040 SysFreeString(lbstr
);
4041 lbstr
= SysAllocString(szFalse
);
4042 VARXORCY(BSTR
,lbstr
,10000,I4
,1);
4043 SysFreeString(lbstr
);
4044 SysFreeString(rbstr
);
4047 static HRESULT (WINAPI
*pVarOr
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
4049 #define VAROR(vt1,val1,vt2,val2,rvt,rval) \
4050 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
4051 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
4052 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
4053 test_var_call2( __LINE__, pVarOr, &left, &right, &exp )
4055 #define VARORCY(vt1,val1,val2,rvt,rval) \
4056 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
4057 V_VT(&right) = VT_CY; V_CY(&right).int64 = val2; \
4058 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
4059 test_var_call2( __LINE__, pVarOr, &left, &right, &exp )
4061 static void test_VarOr(void)
4063 static const WCHAR szFalse
[] = { '#','F','A','L','S','E','#','\0' };
4064 static const WCHAR szTrue
[] = { '#','T','R','U','E','#','\0' };
4065 VARIANT left
, right
, exp
, result
;
4072 /* Test all possible flag/vt combinations & the resulting vt type */
4073 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
4075 VARTYPE leftvt
, rightvt
, resvt
;
4077 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
4082 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
4088 if (leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
||
4089 leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
||
4090 leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
)
4093 memset(&left
, 0, sizeof(left
));
4094 memset(&right
, 0, sizeof(right
));
4095 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
4096 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
4097 V_VT(&result
) = VT_EMPTY
;
4100 if (ExtraFlags
[i
] & VT_ARRAY
|| ExtraFlags
[i
] & VT_BYREF
||
4101 !IsValidVariantClearVT(leftvt
, ExtraFlags
[i
]) ||
4102 !IsValidVariantClearVT(rightvt
, ExtraFlags
[i
]) ||
4103 leftvt
== VT_CLSID
|| rightvt
== VT_CLSID
||
4104 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
||
4105 leftvt
== VT_VARIANT
|| rightvt
== VT_VARIANT
||
4106 leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
)
4110 if (leftvt
== VT_EMPTY
|| rightvt
== VT_EMPTY
)
4112 if (leftvt
== rightvt
||
4113 leftvt
== VT_I2
|| rightvt
== VT_I2
||
4114 leftvt
== VT_UI1
|| rightvt
== VT_UI1
||
4115 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
4117 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
4119 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
4122 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
4126 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
4128 if (leftvt
== rightvt
)
4130 else if (leftvt
== rightvt
||
4131 leftvt
== VT_I2
|| rightvt
== VT_I2
||
4132 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
4136 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
4139 else if (leftvt
== VT_I2
|| rightvt
== VT_I2
)
4141 if (leftvt
== rightvt
||
4142 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
4144 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
4147 else if (leftvt
== VT_BOOL
&& rightvt
== VT_BOOL
)
4151 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
4153 if (leftvt
== VT_INT
|| rightvt
== VT_INT
)
4158 hres
= pVarOr(&left
, &right
, &result
);
4160 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
4161 "VarOr: %d|0x%X, %d|0x%X: Expected failure, got 0x%X vt %d\n",
4162 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], hres
,
4165 ok(hres
== S_OK
&& V_VT(&result
) == resvt
,
4166 "VarOr: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%X vt %d\n",
4167 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], resvt
, hres
,
4173 /* Test returned values. Since we know the returned type is correct
4174 * and that we handle all combinations of invalid types, just check
4175 * that good type combinations produce the desired value.
4176 * FIXME: Test VT_DECIMAL/VT_DISPATCH
4178 VAROR(EMPTY
,0,EMPTY
,0,I2
,0);
4179 VAROR(EMPTY
,1,EMPTY
,0,I2
,0);
4180 VAROR(EMPTY
,0,NULL
,0,NULL
,0);
4181 VAROR(EMPTY
,0,I1
,0,I4
,0);
4182 VAROR(EMPTY
,0,I1
,1,I4
,1);
4183 VAROR(EMPTY
,0,UI1
,0,I2
,0);
4184 VAROR(EMPTY
,0,UI1
,1,I2
,1);
4185 VAROR(EMPTY
,0,I2
,0,I2
,0);
4186 VAROR(EMPTY
,0,I2
,1,I2
,1);
4187 VAROR(EMPTY
,0,UI2
,0,I4
,0);
4188 VAROR(EMPTY
,0,UI2
,1,I4
,1);
4189 VAROR(EMPTY
,0,I4
,0,I4
,0);
4190 VAROR(EMPTY
,0,I4
,1,I4
,1);
4191 VAROR(EMPTY
,0,UI4
,0,I4
,0);
4192 VAROR(EMPTY
,0,UI4
,1,I4
,1);
4193 if (HAVE_OLEAUT32_I8
)
4195 VAROR(EMPTY
,0,I8
,0,I8
,0);
4196 VAROR(EMPTY
,0,I8
,1,I8
,1);
4197 VAROR(EMPTY
,0,UI8
,0,I4
,0);
4198 VAROR(EMPTY
,0,UI8
,1,I4
,1);
4200 VAROR(EMPTY
,0,INT
,0,I4
,0);
4201 VAROR(EMPTY
,0,INT
,1,I4
,1);
4202 VAROR(EMPTY
,0,UINT
,0,I4
,0);
4203 VAROR(EMPTY
,0,UINT
,1,I4
,1);
4204 VAROR(EMPTY
,0,BOOL
,0,I2
,0);
4205 VAROR(EMPTY
,0,BOOL
,1,I2
,1);
4206 VAROR(EMPTY
,0,R4
,0,I4
,0);
4207 VAROR(EMPTY
,0,R4
,1,I4
,1);
4208 VAROR(EMPTY
,0,R8
,0,I4
,0);
4209 VAROR(EMPTY
,0,R8
,1,I4
,1);
4210 rbstr
= SysAllocString(szFalse
);
4211 VAROR(EMPTY
,0,BSTR
,rbstr
,I2
,0);
4212 SysFreeString(rbstr
);
4213 rbstr
= SysAllocString(szTrue
);
4214 VAROR(EMPTY
,0,BSTR
,rbstr
,I2
,-1);
4215 SysFreeString(rbstr
);
4216 VARORCY(EMPTY
,0,10000,I4
,1);
4218 /* NULL OR 0 = NULL. NULL OR n = n */
4219 VAROR(NULL
,0,NULL
,0,NULL
,0);
4220 VAROR(NULL
,1,NULL
,0,NULL
,0);
4221 VAROR(NULL
,0,I1
,0,NULL
,0);
4222 VAROR(NULL
,0,I1
,1,I4
,1);
4223 VAROR(NULL
,0,UI1
,0,NULL
,0);
4224 VAROR(NULL
,0,UI1
,1,UI1
,1);
4225 VAROR(NULL
,0,I2
,0,NULL
,0);
4226 VAROR(NULL
,0,I2
,1,I2
,1);
4227 VAROR(NULL
,0,UI2
,0,NULL
,0);
4228 VAROR(NULL
,0,UI2
,1,I4
,1);
4229 VAROR(NULL
,0,I4
,0,NULL
,0);
4230 VAROR(NULL
,0,I4
,1,I4
,1);
4231 VAROR(NULL
,0,UI4
,0,NULL
,0);
4232 VAROR(NULL
,0,UI4
,1,I4
,1);
4233 if (HAVE_OLEAUT32_I8
)
4235 VAROR(NULL
,0,I8
,0,NULL
,0);
4236 VAROR(NULL
,0,I8
,1,I8
,1);
4237 VAROR(NULL
,0,UI8
,0,NULL
,0);
4238 VAROR(NULL
,0,UI8
,1,I4
,1);
4240 VAROR(NULL
,0,INT
,0,NULL
,0);
4241 VAROR(NULL
,0,INT
,1,I4
,1);
4242 VAROR(NULL
,0,UINT
,0,NULL
,0);
4243 VAROR(NULL
,0,UINT
,1,I4
,1);
4244 VAROR(NULL
,0,BOOL
,0,NULL
,0);
4245 VAROR(NULL
,0,BOOL
,1,BOOL
,1);
4246 VAROR(NULL
,0,R4
,0,NULL
,0);
4247 VAROR(NULL
,0,R4
,1,I4
,1);
4248 VAROR(NULL
,0,R8
,0,NULL
,0);
4249 VAROR(NULL
,0,R8
,1,I4
,1);
4250 rbstr
= SysAllocString(szFalse
);
4251 VAROR(NULL
,0,BSTR
,rbstr
,NULL
,0);
4252 SysFreeString(rbstr
);
4253 rbstr
= SysAllocString(szTrue
);
4254 VAROR(NULL
,0,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
4255 SysFreeString(rbstr
);
4256 VARORCY(NULL
,0,10000,I4
,1);
4257 VARORCY(NULL
,0,0,NULL
,0);
4259 VAROR(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
);
4260 VAROR(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
);
4261 VAROR(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
);
4262 VAROR(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_FALSE
);
4263 /* Assume x,y & y,x are the same from now on to reduce the number of tests */
4264 VAROR(BOOL
,VARIANT_TRUE
,I1
,-1,I4
,-1);
4265 VAROR(BOOL
,VARIANT_TRUE
,I1
,0,I4
,-1);
4266 VAROR(BOOL
,VARIANT_FALSE
,I1
,0,I4
,0);
4267 VAROR(BOOL
,VARIANT_TRUE
,UI1
,255,I2
,-1);
4268 VAROR(BOOL
,VARIANT_TRUE
,UI1
,0,I2
,-1);
4269 VAROR(BOOL
,VARIANT_FALSE
,UI1
,0,I2
,0);
4270 VAROR(BOOL
,VARIANT_TRUE
,I2
,-1,I2
,-1);
4271 VAROR(BOOL
,VARIANT_TRUE
,I2
,0,I2
,-1);
4272 VAROR(BOOL
,VARIANT_FALSE
,I2
,0,I2
,0);
4273 VAROR(BOOL
,VARIANT_TRUE
,UI2
,65535,I4
,-1);
4274 VAROR(BOOL
,VARIANT_TRUE
,UI2
,0,I4
,-1);
4275 VAROR(BOOL
,VARIANT_FALSE
,UI2
,0,I4
,0);
4276 VAROR(BOOL
,VARIANT_TRUE
,I4
,-1,I4
,-1);
4277 VAROR(BOOL
,VARIANT_TRUE
,I4
,0,I4
,-1);
4278 VAROR(BOOL
,VARIANT_FALSE
,I4
,0,I4
,0);
4279 VAROR(BOOL
,VARIANT_TRUE
,UI4
,0xffffffff,I4
,-1);
4280 VAROR(BOOL
,VARIANT_TRUE
,UI4
,0,I4
,-1);
4281 VAROR(BOOL
,VARIANT_FALSE
,UI4
,0,I4
,0);
4282 VAROR(BOOL
,VARIANT_TRUE
,R4
,-1,I4
,-1);
4283 VAROR(BOOL
,VARIANT_TRUE
,R4
,0,I4
,-1);
4284 VAROR(BOOL
,VARIANT_FALSE
,R4
,0,I4
,0);
4285 VAROR(BOOL
,VARIANT_TRUE
,R8
,-1,I4
,-1);
4286 VAROR(BOOL
,VARIANT_TRUE
,R8
,0,I4
,-1);
4287 VAROR(BOOL
,VARIANT_FALSE
,R8
,0,I4
,0);
4288 VAROR(BOOL
,VARIANT_TRUE
,DATE
,-1,I4
,-1);
4289 VAROR(BOOL
,VARIANT_TRUE
,DATE
,0,I4
,-1);
4290 VAROR(BOOL
,VARIANT_FALSE
,DATE
,0,I4
,0);
4291 if (HAVE_OLEAUT32_I8
)
4293 VAROR(BOOL
,VARIANT_TRUE
,I8
,-1,I8
,-1);
4294 VAROR(BOOL
,VARIANT_TRUE
,I8
,0,I8
,-1);
4295 VAROR(BOOL
,VARIANT_FALSE
,I8
,0,I8
,0);
4296 /* This returns DISP_E_OVERFLOW which indicates that a conversion
4297 * to I4 is performed.
4299 /* VAROR(BOOL,VARIANT_TRUE,UI8,-1,I4,-1); */
4300 VAROR(BOOL
,VARIANT_TRUE
,UI8
,0,I4
,-1);
4301 VAROR(BOOL
,VARIANT_FALSE
,UI8
,0,I4
,0);
4303 VAROR(BOOL
,VARIANT_TRUE
,INT
,-1,I4
,-1);
4304 VAROR(BOOL
,VARIANT_TRUE
,INT
,0,I4
,-1);
4305 VAROR(BOOL
,VARIANT_FALSE
,INT
,0,I4
,0);
4306 VAROR(BOOL
,VARIANT_TRUE
,UINT
,0xffffffff,I4
,-1);
4307 VAROR(BOOL
,VARIANT_TRUE
,UINT
,0,I4
,-1);
4308 VAROR(BOOL
,VARIANT_FALSE
,UINT
,0,I4
,0);
4309 rbstr
= SysAllocString(szFalse
);
4310 VAROR(BOOL
,VARIANT_FALSE
,BSTR
,rbstr
,BOOL
,VARIANT_FALSE
);
4311 VAROR(BOOL
,VARIANT_TRUE
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
4312 SysFreeString(rbstr
);
4313 rbstr
= SysAllocString(szTrue
);
4314 VAROR(BOOL
,VARIANT_FALSE
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
4315 VAROR(BOOL
,VARIANT_TRUE
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
4316 SysFreeString(rbstr
);
4317 VARORCY(BOOL
,VARIANT_TRUE
,10000,I4
,-1);
4318 VARORCY(BOOL
,VARIANT_TRUE
,0,I4
,-1);
4319 VARORCY(BOOL
,VARIANT_FALSE
,0,I4
,0);
4321 VAROR(I1
,-1,I1
,-1,I4
,-1);
4322 VAROR(I1
,-1,I1
,0,I4
,-1);
4323 VAROR(I1
,0,I1
,0,I4
,0);
4324 VAROR(I1
,-1,UI1
,255,I4
,-1);
4325 VAROR(I1
,-1,UI1
,0,I4
,-1);
4326 VAROR(I1
,0,UI1
,0,I4
,0);
4327 VAROR(I1
,-1,I2
,-1,I4
,-1);
4328 VAROR(I1
,-1,I2
,0,I4
,-1);
4329 VAROR(I1
,0,I2
,0,I4
,0);
4330 VAROR(I1
,-1,UI2
,65535,I4
,-1);
4331 VAROR(I1
,-1,UI2
,0,I4
,-1);
4332 VAROR(I1
,0,UI2
,0,I4
,0);
4333 VAROR(I1
,-1,I4
,-1,I4
,-1);
4334 VAROR(I1
,-1,I4
,0,I4
,-1);
4335 VAROR(I1
,0,I4
,0,I4
,0);
4336 VAROR(I1
,-1,UI4
,0xffffffff,I4
,-1);
4337 VAROR(I1
,-1,UI4
,0,I4
,-1);
4338 VAROR(I1
,0,UI4
,0,I4
,0);
4339 VAROR(I1
,-1,R4
,-1,I4
,-1);
4340 VAROR(I1
,-1,R4
,0,I4
,-1);
4341 VAROR(I1
,0,R4
,0,I4
,0);
4342 VAROR(I1
,-1,R8
,-1,I4
,-1);
4343 VAROR(I1
,-1,R8
,0,I4
,-1);
4344 VAROR(I1
,0,R8
,0,I4
,0);
4345 VAROR(I1
,-1,DATE
,-1,I4
,-1);
4346 VAROR(I1
,-1,DATE
,0,I4
,-1);
4347 VAROR(I1
,0,DATE
,0,I4
,0);
4348 if (HAVE_OLEAUT32_I8
)
4350 VAROR(I1
,-1,I8
,-1,I8
,-1);
4351 VAROR(I1
,-1,I8
,0,I8
,-1);
4352 VAROR(I1
,0,I8
,0,I8
,0);
4353 VAROR(I1
,-1,UI8
,0,I4
,-1);
4354 VAROR(I1
,0,UI8
,0,I4
,0);
4356 VAROR(I1
,-1,INT
,-1,I4
,-1);
4357 VAROR(I1
,-1,INT
,0,I4
,-1);
4358 VAROR(I1
,0,INT
,0,I4
,0);
4359 VAROR(I1
,-1,UINT
,0xffffffff,I4
,-1);
4360 VAROR(I1
,-1,UINT
,0,I4
,-1);
4361 VAROR(I1
,0,UINT
,0,I4
,0);
4362 rbstr
= SysAllocString(szFalse
);
4363 VAROR(I1
,0,BSTR
,rbstr
,I4
,0);
4364 VAROR(I1
,-1,BSTR
,rbstr
,I4
,-1);
4365 SysFreeString(rbstr
);
4366 rbstr
= SysAllocString(szTrue
);
4367 VAROR(I1
,0,BSTR
,rbstr
,I4
,-1);
4368 VAROR(I1
,-1,BSTR
,rbstr
,I4
,-1);
4369 SysFreeString(rbstr
);
4370 VARORCY(I1
,-1,10000,I4
,-1);
4371 VARORCY(I1
,-1,0,I4
,-1);
4372 VARORCY(I1
,0,0,I4
,0);
4374 VAROR(UI1
,255,UI1
,255,UI1
,255);
4375 VAROR(UI1
,255,UI1
,0,UI1
,255);
4376 VAROR(UI1
,0,UI1
,0,UI1
,0);
4377 VAROR(UI1
,255,I2
,-1,I2
,-1);
4378 VAROR(UI1
,255,I2
,0,I2
,255);
4379 VAROR(UI1
,0,I2
,0,I2
,0);
4380 VAROR(UI1
,255,UI2
,65535,I4
,65535);
4381 VAROR(UI1
,255,UI2
,0,I4
,255);
4382 VAROR(UI1
,0,UI2
,0,I4
,0);
4383 VAROR(UI1
,255,I4
,-1,I4
,-1);
4384 VAROR(UI1
,255,I4
,0,I4
,255);
4385 VAROR(UI1
,0,I4
,0,I4
,0);
4386 VAROR(UI1
,255,UI4
,0xffffffff,I4
,-1);
4387 VAROR(UI1
,255,UI4
,0,I4
,255);
4388 VAROR(UI1
,0,UI4
,0,I4
,0);
4389 VAROR(UI1
,255,R4
,-1,I4
,-1);
4390 VAROR(UI1
,255,R4
,0,I4
,255);
4391 VAROR(UI1
,0,R4
,0,I4
,0);
4392 VAROR(UI1
,255,R8
,-1,I4
,-1);
4393 VAROR(UI1
,255,R8
,0,I4
,255);
4394 VAROR(UI1
,0,R8
,0,I4
,0);
4395 VAROR(UI1
,255,DATE
,-1,I4
,-1);
4396 VAROR(UI1
,255,DATE
,0,I4
,255);
4397 VAROR(UI1
,0,DATE
,0,I4
,0);
4398 if (HAVE_OLEAUT32_I8
)
4400 VAROR(UI1
,255,I8
,-1,I8
,-1);
4401 VAROR(UI1
,255,I8
,0,I8
,255);
4402 VAROR(UI1
,0,I8
,0,I8
,0);
4403 VAROR(UI1
,255,UI8
,0,I4
,255);
4404 VAROR(UI1
,0,UI8
,0,I4
,0);
4406 VAROR(UI1
,255,INT
,-1,I4
,-1);
4407 VAROR(UI1
,255,INT
,0,I4
,255);
4408 VAROR(UI1
,0,INT
,0,I4
,0);
4409 VAROR(UI1
,255,UINT
,0xffffffff,I4
,-1);
4410 VAROR(UI1
,255,UINT
,0,I4
,255);
4411 VAROR(UI1
,0,UINT
,0,I4
,0);
4412 rbstr
= SysAllocString(szFalse
);
4413 VAROR(UI1
,0,BSTR
,rbstr
,I2
,0);
4414 VAROR(UI1
,255,BSTR
,rbstr
,I2
,255);
4415 SysFreeString(rbstr
);
4416 rbstr
= SysAllocString(szTrue
);
4417 VAROR(UI1
,0,BSTR
,rbstr
,I2
,-1);
4418 VAROR(UI1
,255,BSTR
,rbstr
,I2
,-1);
4419 SysFreeString(rbstr
);
4420 VARORCY(UI1
,255,10000,I4
,255);
4421 VARORCY(UI1
,255,0,I4
,255);
4422 VARORCY(UI1
,0,0,I4
,0);
4424 VAROR(I2
,-1,I2
,-1,I2
,-1);
4425 VAROR(I2
,-1,I2
,0,I2
,-1);
4426 VAROR(I2
,0,I2
,0,I2
,0);
4427 VAROR(I2
,-1,UI2
,65535,I4
,-1);
4428 VAROR(I2
,-1,UI2
,0,I4
,-1);
4429 VAROR(I2
,0,UI2
,0,I4
,0);
4430 VAROR(I2
,-1,I4
,-1,I4
,-1);
4431 VAROR(I2
,-1,I4
,0,I4
,-1);
4432 VAROR(I2
,0,I4
,0,I4
,0);
4433 VAROR(I2
,-1,UI4
,0xffffffff,I4
,-1);
4434 VAROR(I2
,-1,UI4
,0,I4
,-1);
4435 VAROR(I2
,0,UI4
,0,I4
,0);
4436 VAROR(I2
,-1,R4
,-1,I4
,-1);
4437 VAROR(I2
,-1,R4
,0,I4
,-1);
4438 VAROR(I2
,0,R4
,0,I4
,0);
4439 VAROR(I2
,-1,R8
,-1,I4
,-1);
4440 VAROR(I2
,-1,R8
,0,I4
,-1);
4441 VAROR(I2
,0,R8
,0,I4
,0);
4442 VAROR(I2
,-1,DATE
,-1,I4
,-1);
4443 VAROR(I2
,-1,DATE
,0,I4
,-1);
4444 VAROR(I2
,0,DATE
,0,I4
,0);
4445 if (HAVE_OLEAUT32_I8
)
4447 VAROR(I2
,-1,I8
,-1,I8
,-1);
4448 VAROR(I2
,-1,I8
,0,I8
,-1);
4449 VAROR(I2
,0,I8
,0,I8
,0);
4450 VAROR(I2
,-1,UI8
,0,I4
,-1);
4451 VAROR(I2
,0,UI8
,0,I4
,0);
4453 VAROR(I2
,-1,INT
,-1,I4
,-1);
4454 VAROR(I2
,-1,INT
,0,I4
,-1);
4455 VAROR(I2
,0,INT
,0,I4
,0);
4456 VAROR(I2
,-1,UINT
,0xffffffff,I4
,-1);
4457 VAROR(I2
,-1,UINT
,0,I4
,-1);
4458 VAROR(I2
,0,UINT
,0,I4
,0);
4459 rbstr
= SysAllocString(szFalse
);
4460 VAROR(I2
,0,BSTR
,rbstr
,I2
,0);
4461 VAROR(I2
,-1,BSTR
,rbstr
,I2
,-1);
4462 SysFreeString(rbstr
);
4463 rbstr
= SysAllocString(szTrue
);
4464 VAROR(I2
,0,BSTR
,rbstr
,I2
,-1);
4465 VAROR(I2
,-1,BSTR
,rbstr
,I2
,-1);
4466 SysFreeString(rbstr
);
4467 VARORCY(I2
,-1,10000,I4
,-1);
4468 VARORCY(I2
,-1,0,I4
,-1);
4469 VARORCY(I2
,0,0,I4
,0);
4471 VAROR(UI2
,65535,UI2
,65535,I4
,65535);
4472 VAROR(UI2
,65535,UI2
,0,I4
,65535);
4473 VAROR(UI2
,0,UI2
,0,I4
,0);
4474 VAROR(UI2
,65535,I4
,-1,I4
,-1);
4475 VAROR(UI2
,65535,I4
,0,I4
,65535);
4476 VAROR(UI2
,0,I4
,0,I4
,0);
4477 VAROR(UI2
,65535,UI4
,0xffffffff,I4
,-1);
4478 VAROR(UI2
,65535,UI4
,0,I4
,65535);
4479 VAROR(UI2
,0,UI4
,0,I4
,0);
4480 VAROR(UI2
,65535,R4
,-1,I4
,-1);
4481 VAROR(UI2
,65535,R4
,0,I4
,65535);
4482 VAROR(UI2
,0,R4
,0,I4
,0);
4483 VAROR(UI2
,65535,R8
,-1,I4
,-1);
4484 VAROR(UI2
,65535,R8
,0,I4
,65535);
4485 VAROR(UI2
,0,R8
,0,I4
,0);
4486 VAROR(UI2
,65535,DATE
,-1,I4
,-1);
4487 VAROR(UI2
,65535,DATE
,0,I4
,65535);
4488 VAROR(UI2
,0,DATE
,0,I4
,0);
4489 if (HAVE_OLEAUT32_I8
)
4491 VAROR(UI2
,65535,I8
,-1,I8
,-1);
4492 VAROR(UI2
,65535,I8
,0,I8
,65535);
4493 VAROR(UI2
,0,I8
,0,I8
,0);
4494 VAROR(UI2
,65535,UI8
,0,I4
,65535);
4495 VAROR(UI2
,0,UI8
,0,I4
,0);
4497 VAROR(UI2
,65535,INT
,-1,I4
,-1);
4498 VAROR(UI2
,65535,INT
,0,I4
,65535);
4499 VAROR(UI2
,0,INT
,0,I4
,0);
4500 VAROR(UI2
,65535,UINT
,0xffffffff,I4
,-1);
4501 VAROR(UI2
,65535,UINT
,0,I4
,65535);
4502 VAROR(UI2
,0,UINT
,0,I4
,0);
4503 rbstr
= SysAllocString(szFalse
);
4504 VAROR(UI2
,0,BSTR
,rbstr
,I4
,0);
4505 VAROR(UI2
,65535,BSTR
,rbstr
,I4
,65535);
4506 SysFreeString(rbstr
);
4507 rbstr
= SysAllocString(szTrue
);
4508 VAROR(UI2
,0,BSTR
,rbstr
,I4
,-1);
4509 VAROR(UI2
,65535,BSTR
,rbstr
,I4
,-1);
4510 SysFreeString(rbstr
);
4511 VARORCY(UI2
,65535,10000,I4
,65535);
4512 VARORCY(UI2
,65535,0,I4
,65535);
4513 VARORCY(UI2
,0,0,I4
,0);
4515 VAROR(I4
,-1,I4
,-1,I4
,-1);
4516 VAROR(I4
,-1,I4
,0,I4
,-1);
4517 VAROR(I4
,0,I4
,0,I4
,0);
4518 VAROR(I4
,-1,UI4
,0xffffffff,I4
,-1);
4519 VAROR(I4
,-1,UI4
,0,I4
,-1);
4520 VAROR(I4
,0,UI4
,0,I4
,0);
4521 VAROR(I4
,-1,R4
,-1,I4
,-1);
4522 VAROR(I4
,-1,R4
,0,I4
,-1);
4523 VAROR(I4
,0,R4
,0,I4
,0);
4524 VAROR(I4
,-1,R8
,-1,I4
,-1);
4525 VAROR(I4
,-1,R8
,0,I4
,-1);
4526 VAROR(I4
,0,R8
,0,I4
,0);
4527 VAROR(I4
,-1,DATE
,-1,I4
,-1);
4528 VAROR(I4
,-1,DATE
,0,I4
,-1);
4529 VAROR(I4
,0,DATE
,0,I4
,0);
4530 if (HAVE_OLEAUT32_I8
)
4532 VAROR(I4
,-1,I8
,-1,I8
,-1);
4533 VAROR(I4
,-1,I8
,0,I8
,-1);
4534 VAROR(I4
,0,I8
,0,I8
,0);
4535 VAROR(I4
,-1,UI8
,0,I4
,-1);
4536 VAROR(I4
,0,UI8
,0,I4
,0);
4538 VAROR(I4
,-1,INT
,-1,I4
,-1);
4539 VAROR(I4
,-1,INT
,0,I4
,-1);
4540 VAROR(I4
,0,INT
,0,I4
,0);
4541 VAROR(I4
,-1,UINT
,0xffffffff,I4
,-1);
4542 VAROR(I4
,-1,UINT
,0,I4
,-1);
4543 VAROR(I4
,0,UINT
,0,I4
,0);
4544 rbstr
= SysAllocString(szFalse
);
4545 VAROR(I4
,0,BSTR
,rbstr
,I4
,0);
4546 VAROR(I4
,-1,BSTR
,rbstr
,I4
,-1);
4547 SysFreeString(rbstr
);
4548 rbstr
= SysAllocString(szTrue
);
4549 VAROR(I4
,0,BSTR
,rbstr
,I4
,-1);
4550 VAROR(I4
,-1,BSTR
,rbstr
,I4
,-1);
4551 SysFreeString(rbstr
);
4552 VARORCY(I4
,-1,10000,I4
,-1);
4553 VARORCY(I4
,-1,0,I4
,-1);
4554 VARORCY(I4
,0,0,I4
,0);
4556 VAROR(UI4
,0xffffffff,UI4
,0xffffffff,I4
,-1);
4557 VAROR(UI4
,0xffffffff,UI4
,0,I4
,-1);
4558 VAROR(UI4
,0,UI4
,0,I4
,0);
4559 VAROR(UI4
,0xffffffff,R4
,-1,I4
,-1);
4560 VAROR(UI4
,0xffffffff,R4
,0,I4
,-1);
4561 VAROR(UI4
,0,R4
,0,I4
,0);
4562 VAROR(UI4
,0xffffffff,R8
,-1,I4
,-1);
4563 VAROR(UI4
,0xffffffff,R8
,0,I4
,-1);
4564 VAROR(UI4
,0,R8
,0,I4
,0);
4565 VAROR(UI4
,0xffffffff,DATE
,-1,I4
,-1);
4566 VAROR(UI4
,0xffffffff,DATE
,0,I4
,-1);
4567 VAROR(UI4
,0,DATE
,0,I4
,0);
4568 if (HAVE_OLEAUT32_I8
)
4570 VAROR(UI4
,0xffffffff,I8
,-1,I8
,-1);
4571 VAROR(UI4
,0xffffffff,I8
,0,I8
,0xffffffff);
4572 VAROR(UI4
,0,I8
,0,I8
,0);
4573 VAROR(UI4
,0xffffffff,UI8
,0,I4
,-1);
4574 VAROR(UI4
,0,UI8
,0,I4
,0);
4576 VAROR(UI4
,0xffffffff,INT
,-1,I4
,-1);
4577 VAROR(UI4
,0xffffffff,INT
,0,I4
,-1);
4578 VAROR(UI4
,0,INT
,0,I4
,0);
4579 VAROR(UI4
,0xffffffff,UINT
,0xffffffff,I4
,-1);
4580 VAROR(UI4
,0xffffffff,UINT
,0,I4
,-1);
4581 VAROR(UI4
,0,UINT
,0,I4
,0);
4582 rbstr
= SysAllocString(szFalse
);
4583 VAROR(UI4
,0,BSTR
,rbstr
,I4
,0);
4584 VAROR(UI4
,0xffffffff,BSTR
,rbstr
,I4
,-1);
4585 SysFreeString(rbstr
);
4586 rbstr
= SysAllocString(szTrue
);
4587 VAROR(UI4
,0,BSTR
,rbstr
,I4
,-1);
4588 VAROR(UI4
,0xffffffff,BSTR
,rbstr
,I4
,-1);
4589 SysFreeString(rbstr
);
4590 VARORCY(UI4
,0xffffffff,10000,I4
,-1);
4591 VARORCY(UI4
,0xffffffff,0,I4
,-1);
4592 VARORCY(UI4
,0,0,I4
,0);
4594 VAROR(R4
,-1,R4
,-1,I4
,-1);
4595 VAROR(R4
,-1,R4
,0,I4
,-1);
4596 VAROR(R4
,0,R4
,0,I4
,0);
4597 VAROR(R4
,-1,R8
,-1,I4
,-1);
4598 VAROR(R4
,-1,R8
,0,I4
,-1);
4599 VAROR(R4
,0,R8
,0,I4
,0);
4600 VAROR(R4
,-1,DATE
,-1,I4
,-1);
4601 VAROR(R4
,-1,DATE
,0,I4
,-1);
4602 VAROR(R4
,0,DATE
,0,I4
,0);
4603 if (HAVE_OLEAUT32_I8
)
4605 VAROR(R4
,-1,I8
,-1,I8
,-1);
4606 VAROR(R4
,-1,I8
,0,I8
,-1);
4607 VAROR(R4
,0,I8
,0,I8
,0);
4608 VAROR(R4
,-1,UI8
,0,I4
,-1);
4609 VAROR(R4
,0,UI8
,0,I4
,0);
4611 VAROR(R4
,-1,INT
,-1,I4
,-1);
4612 VAROR(R4
,-1,INT
,0,I4
,-1);
4613 VAROR(R4
,0,INT
,0,I4
,0);
4614 VAROR(R4
,-1,UINT
,0xffffffff,I4
,-1);
4615 VAROR(R4
,-1,UINT
,0,I4
,-1);
4616 VAROR(R4
,0,UINT
,0,I4
,0);
4617 rbstr
= SysAllocString(szFalse
);
4618 VAROR(R4
,0,BSTR
,rbstr
,I4
,0);
4619 VAROR(R4
,-1,BSTR
,rbstr
,I4
,-1);
4620 SysFreeString(rbstr
);
4621 rbstr
= SysAllocString(szTrue
);
4622 VAROR(R4
,0,BSTR
,rbstr
,I4
,-1);
4623 VAROR(R4
,-1,BSTR
,rbstr
,I4
,-1);
4624 SysFreeString(rbstr
);
4625 VARORCY(R4
,-1,10000,I4
,-1);
4626 VARORCY(R4
,-1,0,I4
,-1);
4627 VARORCY(R4
,0,0,I4
,0);
4629 VAROR(R8
,-1,R8
,-1,I4
,-1);
4630 VAROR(R8
,-1,R8
,0,I4
,-1);
4631 VAROR(R8
,0,R8
,0,I4
,0);
4632 VAROR(R8
,-1,DATE
,-1,I4
,-1);
4633 VAROR(R8
,-1,DATE
,0,I4
,-1);
4634 VAROR(R8
,0,DATE
,0,I4
,0);
4635 if (HAVE_OLEAUT32_I8
)
4637 VAROR(R8
,-1,I8
,-1,I8
,-1);
4638 VAROR(R8
,-1,I8
,0,I8
,-1);
4639 VAROR(R8
,0,I8
,0,I8
,0);
4640 VAROR(R8
,-1,UI8
,0,I4
,-1);
4641 VAROR(R8
,0,UI8
,0,I4
,0);
4643 VAROR(R8
,-1,INT
,-1,I4
,-1);
4644 VAROR(R8
,-1,INT
,0,I4
,-1);
4645 VAROR(R8
,0,INT
,0,I4
,0);
4646 VAROR(R8
,-1,UINT
,0xffffffff,I4
,-1);
4647 VAROR(R8
,-1,UINT
,0,I4
,-1);
4648 VAROR(R8
,0,UINT
,0,I4
,0);
4649 rbstr
= SysAllocString(szFalse
);
4650 VAROR(R8
,0,BSTR
,rbstr
,I4
,0);
4651 VAROR(R8
,-1,BSTR
,rbstr
,I4
,-1);
4652 SysFreeString(rbstr
);
4653 rbstr
= SysAllocString(szTrue
);
4654 VAROR(R8
,0,BSTR
,rbstr
,I4
,-1);
4655 VAROR(R8
,-1,BSTR
,rbstr
,I4
,-1);
4656 SysFreeString(rbstr
);
4657 VARORCY(R8
,-1,10000,I4
,-1);
4658 VARORCY(R8
,-1,0,I4
,-1);
4659 VARORCY(R8
,0,0,I4
,0);
4661 VAROR(DATE
,-1,DATE
,-1,I4
,-1);
4662 VAROR(DATE
,-1,DATE
,0,I4
,-1);
4663 VAROR(DATE
,0,DATE
,0,I4
,0);
4664 if (HAVE_OLEAUT32_I8
)
4666 VAROR(DATE
,-1,I8
,-1,I8
,-1);
4667 VAROR(DATE
,-1,I8
,0,I8
,-1);
4668 VAROR(DATE
,0,I8
,0,I8
,0);
4669 VAROR(DATE
,-1,UI8
,0,I4
,-1);
4670 VAROR(DATE
,0,UI8
,0,I4
,0);
4672 VAROR(DATE
,-1,INT
,-1,I4
,-1);
4673 VAROR(DATE
,-1,INT
,0,I4
,-1);
4674 VAROR(DATE
,0,INT
,0,I4
,0);
4675 VAROR(DATE
,-1,UINT
,0xffffffff,I4
,-1);
4676 VAROR(DATE
,-1,UINT
,0,I4
,-1);
4677 VAROR(DATE
,0,UINT
,0,I4
,0);
4678 rbstr
= SysAllocString(szFalse
);
4679 VAROR(DATE
,0,BSTR
,rbstr
,I4
,0);
4680 VAROR(DATE
,-1,BSTR
,rbstr
,I4
,-1);
4681 SysFreeString(rbstr
);
4682 rbstr
= SysAllocString(szTrue
);
4683 VAROR(DATE
,0,BSTR
,rbstr
,I4
,-1);
4684 VAROR(DATE
,-1,BSTR
,rbstr
,I4
,-1);
4685 SysFreeString(rbstr
);
4686 VARORCY(DATE
,-1,10000,I4
,-1);
4687 VARORCY(DATE
,-1,0,I4
,-1);
4688 VARORCY(DATE
,0,0,I4
,0);
4690 if (HAVE_OLEAUT32_I8
)
4692 VAROR(I8
,-1,I8
,-1,I8
,-1);
4693 VAROR(I8
,-1,I8
,0,I8
,-1);
4694 VAROR(I8
,0,I8
,0,I8
,0);
4695 VAROR(I8
,-1,UI8
,0,I8
,-1);
4696 VAROR(I8
,0,UI8
,0,I8
,0);
4697 /* These overflow under native and Wine
4698 VAROR(I8,-1,INT,-1,I4,-1);
4699 VAROR(I8,-1,INT,0,I4,-1);
4700 VAROR(I8,0,INT,0,I4,0); */
4701 VAROR(I8
,-1,UINT
,0xffffffff,I8
,-1);
4702 VAROR(I8
,-1,UINT
,0,I8
,-1);
4703 VAROR(I8
,0,UINT
,0,I8
,0);
4704 rbstr
= SysAllocString(szFalse
);
4705 VAROR(I8
,0,BSTR
,rbstr
,I8
,0);
4706 VAROR(I8
,-1,BSTR
,rbstr
,I8
,-1);
4707 SysFreeString(rbstr
);
4708 rbstr
= SysAllocString(szTrue
);
4709 VAROR(I8
,0,BSTR
,rbstr
,I8
,-1);
4710 VAROR(I8
,-1,BSTR
,rbstr
,I8
,-1);
4711 SysFreeString(rbstr
);
4712 VARORCY(I8
,-1,10000,I8
,-1);
4713 VARORCY(I8
,-1,0,I8
,-1);
4714 VARORCY(I8
,0,0,I8
,0);
4716 VAROR(UI8
,0xffff,UI8
,0xffff,I4
,0xffff);
4717 VAROR(UI8
,0xffff,UI8
,0,I4
,0xffff);
4718 VAROR(UI8
,0,UI8
,0,I4
,0);
4719 VAROR(UI8
,0xffff,INT
,-1,I4
,-1);
4720 VAROR(UI8
,0xffff,INT
,0,I4
,0xffff);
4721 VAROR(UI8
,0,INT
,0,I4
,0);
4722 VAROR(UI8
,0xffff,UINT
,0xffff,I4
,0xffff);
4723 VAROR(UI8
,0xffff,UINT
,0,I4
,0xffff);
4724 VAROR(UI8
,0,UINT
,0,I4
,0);
4725 rbstr
= SysAllocString(szFalse
);
4726 VAROR(UI8
,0,BSTR
,rbstr
,I4
,0);
4727 VAROR(UI8
,0xffff,BSTR
,rbstr
,I4
,0xffff);
4728 SysFreeString(rbstr
);
4729 rbstr
= SysAllocString(szTrue
);
4730 VAROR(UI8
,0,BSTR
,rbstr
,I4
,-1);
4731 VAROR(UI8
,0xffff,BSTR
,rbstr
,I4
,-1);
4732 SysFreeString(rbstr
);
4733 VARORCY(UI8
,0xffff,10000,I4
,0xffff);
4734 VARORCY(UI8
,0xffff,0,I4
,0xffff);
4735 VARORCY(UI8
,0,0,I4
,0);
4738 VAROR(INT
,-1,INT
,-1,I4
,-1);
4739 VAROR(INT
,-1,INT
,0,I4
,-1);
4740 VAROR(INT
,0,INT
,0,I4
,0);
4741 VAROR(INT
,-1,UINT
,0xffff,I4
,-1);
4742 VAROR(INT
,-1,UINT
,0,I4
,-1);
4743 VAROR(INT
,0,UINT
,0,I4
,0);
4744 rbstr
= SysAllocString(szFalse
);
4745 VAROR(INT
,0,BSTR
,rbstr
,I4
,0);
4746 VAROR(INT
,-1,BSTR
,rbstr
,I4
,-1);
4747 SysFreeString(rbstr
);
4748 rbstr
= SysAllocString(szTrue
);
4749 VAROR(INT
,0,BSTR
,rbstr
,I4
,-1);
4750 VAROR(INT
,-1,BSTR
,rbstr
,I4
,-1);
4751 SysFreeString(rbstr
);
4752 VARORCY(INT
,-1,10000,I4
,-1);
4753 VARORCY(INT
,-1,0,I4
,-1);
4754 VARORCY(INT
,0,0,I4
,0);
4756 VAROR(UINT
,0xffff,UINT
,0xffff,I4
,0xffff);
4757 VAROR(UINT
,0xffff,UINT
,0,I4
,0xffff);
4758 VAROR(UINT
,0,UINT
,0,I4
,0);
4759 rbstr
= SysAllocString(szFalse
);
4760 VAROR(UINT
,0,BSTR
,rbstr
,I4
,0);
4761 VAROR(UINT
,0xffff,BSTR
,rbstr
,I4
,0xffff);
4762 SysFreeString(rbstr
);
4763 rbstr
= SysAllocString(szTrue
);
4764 VAROR(UINT
,0,BSTR
,rbstr
,I4
,-1);
4765 VAROR(UINT
,0xffff,BSTR
,rbstr
,I4
,-1);
4766 SysFreeString(rbstr
);
4767 VARORCY(UINT
,0xffff,10000,I4
,0xffff);
4768 VARORCY(UINT
,0xffff,0,I4
,0xffff);
4769 VARORCY(UINT
,0,0,I4
,0);
4771 lbstr
= SysAllocString(szFalse
);
4772 rbstr
= SysAllocString(szFalse
);
4773 VAROR(BSTR
,lbstr
,BSTR
,rbstr
,BOOL
,0);
4774 SysFreeString(rbstr
);
4775 rbstr
= SysAllocString(szTrue
);
4776 VAROR(BSTR
,lbstr
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
4777 SysFreeString(lbstr
);
4778 lbstr
= SysAllocString(szTrue
);
4779 VAROR(BSTR
,lbstr
,BSTR
,rbstr
,BOOL
,VARIANT_TRUE
);
4780 VARORCY(BSTR
,lbstr
,10000,I4
,-1);
4781 SysFreeString(lbstr
);
4782 lbstr
= SysAllocString(szFalse
);
4783 VARORCY(BSTR
,lbstr
,10000,I4
,1);
4784 SysFreeString(lbstr
);
4785 SysFreeString(rbstr
);
4788 static HRESULT (WINAPI
*pVarEqv
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
4790 #define VAREQV(vt1,val1,vt2,val2,rvt,rval) \
4791 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
4792 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
4793 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
4794 test_var_call2( __LINE__, pVarEqv, &left, &right, &exp )
4796 static void test_VarEqv(void)
4798 VARIANT left
, right
, exp
, result
;
4804 /* Test all possible flag/vt combinations & the resulting vt type */
4805 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
4807 VARTYPE leftvt
, rightvt
, resvt
;
4809 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
4813 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
4819 if (leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
||
4820 leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
||
4821 leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
)
4824 memset(&left
, 0, sizeof(left
));
4825 memset(&right
, 0, sizeof(right
));
4826 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
4827 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
4828 V_VT(&result
) = VT_EMPTY
;
4831 if (ExtraFlags
[i
] & VT_ARRAY
|| ExtraFlags
[i
] & VT_BYREF
||
4832 !IsValidVariantClearVT(leftvt
, ExtraFlags
[i
]) ||
4833 !IsValidVariantClearVT(rightvt
, ExtraFlags
[i
]) ||
4834 leftvt
== VT_CLSID
|| rightvt
== VT_CLSID
||
4835 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
||
4836 leftvt
== VT_VARIANT
|| rightvt
== VT_VARIANT
||
4837 leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
)
4841 if (leftvt
== VT_EMPTY
|| rightvt
== VT_EMPTY
)
4843 if (leftvt
== rightvt
||
4844 leftvt
== VT_I2
|| rightvt
== VT_I2
||
4845 leftvt
== VT_UI1
|| rightvt
== VT_UI1
||
4846 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
4848 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
4850 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
4853 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
4857 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
4859 if (leftvt
== rightvt
)
4861 else if (leftvt
== rightvt
||
4862 leftvt
== VT_I2
|| rightvt
== VT_I2
||
4863 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
4867 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
4870 else if (leftvt
== VT_I2
|| rightvt
== VT_I2
)
4872 if (leftvt
== rightvt
||
4873 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
)
4875 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
4878 else if (leftvt
== VT_BOOL
&& rightvt
== VT_BOOL
)
4882 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
4884 if (leftvt
== VT_INT
|| rightvt
== VT_INT
)
4889 hres
= pVarEqv(&left
, &right
, &result
);
4891 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
4892 "VarEqv: %d|0x%X, %d|0x%X: Expected failure, got 0x%X vt %d\n",
4893 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], hres
,
4896 ok(hres
== S_OK
&& V_VT(&result
) == resvt
,
4897 "VarEqv: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%X vt %d\n",
4898 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], resvt
, hres
,
4904 /* Test returned values */
4905 VAREQV(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
);
4906 VAREQV(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
);
4907 VAREQV(BOOL
,TRUE
,BOOL
,TRUE
,BOOL
,VARIANT_TRUE
);
4908 VAREQV(BOOL
,FALSE
,BOOL
,FALSE
,BOOL
,VARIANT_TRUE
);
4909 VAREQV(BOOL
,TRUE
,BOOL
,FALSE
,BOOL
,-2);
4910 VAREQV(BOOL
,FALSE
,BOOL
,TRUE
,BOOL
,-2);
4911 VAREQV(BOOL
,6,BOOL
,7,BOOL
,-2);
4912 VAREQV(BOOL
,6,BOOL
,6,BOOL
,VARIANT_TRUE
);
4913 VAREQV(BOOL
,VARIANT_TRUE
,I2
,VARIANT_TRUE
,I2
,VARIANT_TRUE
);
4914 VAREQV(BOOL
,VARIANT_TRUE
,I2
,VARIANT_FALSE
,I2
,VARIANT_FALSE
);
4915 VAREQV(BOOL
,6,I2
,7,I2
,-2);
4916 VAREQV(UI1
,1,UI1
,1,UI1
,255);
4917 VAREQV(UI1
,1,UI1
,0,UI1
,254);
4918 VAREQV(UI1
,0,UI1
,1,UI1
,254);
4919 if (HAVE_OLEAUT32_I8
)
4921 VAREQV(UI4
,VARIANT_FALSE
,I8
,VARIANT_FALSE
,I8
,-1);
4922 VAREQV(UI4
,5,I8
,19,I8
,-23);
4923 VAREQV(UI4
,VARIANT_FALSE
,UI8
,VARIANT_FALSE
,I4
,-1);
4927 static HRESULT (WINAPI
*pVarMul
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
4929 #define VARMUL(vt1,val1,vt2,val2,rvt,rval) \
4930 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
4931 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
4932 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
4933 test_var_call2( __LINE__, pVarMul, &left, &right, &exp )
4935 static void test_VarMul(void)
4937 VARIANT left
, right
, exp
, result
, cy
, dec
;
4945 lbstr
= SysAllocString(sz12
);
4946 rbstr
= SysAllocString(sz12
);
4948 /* Test all possible flag/vt combinations & the resulting vt type */
4949 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
4951 VARTYPE leftvt
, rightvt
, resvt
;
4953 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
4958 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
4964 if (leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
||
4965 leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
)
4968 memset(&left
, 0, sizeof(left
));
4969 memset(&right
, 0, sizeof(right
));
4970 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
4971 if (leftvt
== VT_BSTR
)
4972 V_BSTR(&left
) = lbstr
;
4973 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
4974 if (rightvt
== VT_BSTR
)
4975 V_BSTR(&right
) = rbstr
;
4976 V_VT(&result
) = VT_EMPTY
;
4979 /* Don't ask me why but native VarMul cannot handle:
4980 VT_I1, VT_UI2, VT_UI4, VT_INT, VT_UINT and VT_UI8.
4981 Tested with DCOM98, Win2k, WinXP */
4982 if (ExtraFlags
[i
] & VT_ARRAY
|| ExtraFlags
[i
] & VT_BYREF
||
4983 !IsValidVariantClearVT(leftvt
, ExtraFlags
[i
]) ||
4984 !IsValidVariantClearVT(rightvt
, ExtraFlags
[i
]) ||
4985 leftvt
== VT_CLSID
|| rightvt
== VT_CLSID
||
4986 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
||
4987 leftvt
== VT_VARIANT
|| rightvt
== VT_VARIANT
||
4988 leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
||
4989 leftvt
== VT_I1
|| rightvt
== VT_I1
||
4990 leftvt
== VT_UI2
|| rightvt
== VT_UI2
||
4991 leftvt
== VT_UI4
|| rightvt
== VT_UI4
||
4992 leftvt
== VT_UI8
|| rightvt
== VT_UI8
||
4993 leftvt
== VT_INT
|| rightvt
== VT_INT
||
4994 leftvt
== VT_UINT
|| rightvt
== VT_UINT
) {
4998 if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
5000 else if (leftvt
== VT_DECIMAL
|| rightvt
== VT_DECIMAL
)
5002 else if (leftvt
== VT_R8
|| rightvt
== VT_R8
||
5003 leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
||
5004 leftvt
== VT_DATE
|| rightvt
== VT_DATE
)
5006 else if (leftvt
== VT_R4
|| rightvt
== VT_R4
) {
5007 if (leftvt
== VT_I4
|| rightvt
== VT_I4
||
5008 leftvt
== VT_I8
|| rightvt
== VT_I8
||
5009 leftvt
== VT_CY
|| rightvt
== VT_CY
)
5013 } else if (leftvt
== VT_CY
|| rightvt
== VT_CY
)
5015 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
5017 else if (leftvt
== VT_I4
|| rightvt
== VT_I4
)
5019 else if (leftvt
== VT_I2
|| rightvt
== VT_I2
||
5020 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
||
5021 (leftvt
== VT_EMPTY
&& rightvt
== VT_EMPTY
))
5023 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
5026 hres
= pVarMul(&left
, &right
, &result
);
5028 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
5029 "VarMul: %d|0x%X, %d|0x%X: Expected failure, got 0x%X vt %d\n",
5030 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], hres
,
5033 ok(hres
== S_OK
&& V_VT(&result
) == resvt
,
5034 "VarMul: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%X vt %d\n",
5035 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], resvt
, hres
,
5042 /* Test returned values */
5043 VARMUL(I4
,4,I4
,2,I4
,8);
5044 VARMUL(I2
,4,I2
,2,I2
,8);
5045 VARMUL(I2
,-13,I4
,5,I4
,-65);
5046 VARMUL(I4
,-13,I4
,5,I4
,-65);
5047 VARMUL(I2
,7,R4
,0.5f
,R4
,3.5f
);
5048 VARMUL(R4
,0.5f
,I4
,5,R8
,2.5);
5049 VARMUL(R8
,7.1,BOOL
,0,R8
,0);
5050 VARMUL(BSTR
,lbstr
,I2
,4,R8
,48);
5051 VARMUL(BSTR
,lbstr
,BOOL
,1,R8
,12);
5052 VARMUL(BSTR
,lbstr
,R4
,0.1f
,R8
,1.2);
5053 VARMUL(BSTR
,lbstr
,BSTR
,rbstr
,R8
,144);
5054 VARMUL(R4
,0.2f
,BSTR
,rbstr
,R8
,2.4);
5055 VARMUL(DATE
,2.25,I4
,7,R8
,15.75);
5057 VARMUL(UI1
, UI1_MAX
, UI1
, UI1_MAX
, I4
, UI1_MAX
* UI1_MAX
);
5058 VARMUL(I2
, I2_MAX
, I2
, I2_MAX
, I4
, I2_MAX
* I2_MAX
);
5059 VARMUL(I2
, I2_MAX
, I2
, I2_MIN
, I4
, I2_MAX
* I2_MIN
);
5060 VARMUL(I2
, I2_MIN
, I2
, I2_MIN
, I4
, I2_MIN
* I2_MIN
);
5061 VARMUL(I4
, I4_MAX
, I4
, I4_MAX
, R8
, (double)I4_MAX
* I4_MAX
);
5062 VARMUL(I4
, I4_MAX
, I4
, I4_MIN
, R8
, (double)I4_MAX
* I4_MIN
);
5063 VARMUL(I4
, I4_MIN
, I4
, I4_MIN
, R8
, (double)I4_MIN
* I4_MIN
);
5064 VARMUL(R4
, R4_MAX
, R4
, R4_MAX
, R8
, (double)R4_MAX
* R4_MAX
);
5065 VARMUL(R4
, R4_MAX
, R4
, R4_MIN
, R4
, R4_MAX
* R4_MIN
);
5066 VARMUL(R4
, R4_MIN
, R4
, R4_MIN
, R4
, R4_MIN
* R4_MIN
);
5067 VARMUL(R8
, R8_MAX
, R8
, R8_MIN
, R8
, R8_MAX
* R8_MIN
);
5068 VARMUL(R8
, R8_MIN
, R8
, R8_MIN
, R8
, R8_MIN
* R8_MIN
);
5070 /* Manuly test some VT_CY and VT_DECIMAL variants */
5072 hres
= VarCyFromI4(4711, &V_CY(&cy
));
5073 ok(hres
== S_OK
, "VarCyFromI4 failed!\n");
5074 V_VT(&dec
) = VT_DECIMAL
;
5075 hres
= VarDecFromR8(-4.2, &V_DECIMAL(&dec
));
5076 ok(hres
== S_OK
, "VarDecFromR4 failed!\n");
5077 memset(&left
, 0, sizeof(left
));
5078 memset(&right
, 0, sizeof(right
));
5079 V_VT(&left
) = VT_I4
;
5081 V_VT(&right
) = VT_UI1
;
5084 hres
= VarMul(&cy
, &right
, &result
);
5085 ok(hres
== S_OK
&& V_VT(&result
) == VT_CY
, "VarMul: expected coerced type VT_CY, got %s!\n", vtstr(V_VT(&result
)));
5086 hres
= VarR8FromCy(V_CY(&result
), &r
);
5087 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 42399), "VarMul: CY value %f, expected %f\n", r
, (double)42399);
5089 hres
= VarMul(&left
, &dec
, &result
);
5090 ok(hres
== S_OK
&& V_VT(&result
) == VT_DECIMAL
, "VarMul: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result
)));
5091 hres
= VarR8FromDec(&V_DECIMAL(&result
), &r
);
5092 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 46.2), "VarMul: DECIMAL value %f, expected %f\n", r
, (double)46.2);
5094 SysFreeString(lbstr
);
5095 SysFreeString(rbstr
);
5098 static HRESULT (WINAPI
*pVarAdd
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
5100 #define VARADD(vt1,val1,vt2,val2,rvt,rval) \
5101 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
5102 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
5103 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
5104 test_var_call2( __LINE__, pVarAdd, &left, &right, &exp )
5106 static void test_VarAdd(void)
5108 VARIANT left
, right
, exp
, result
, cy
, dec
;
5116 lbstr
= SysAllocString(sz12
);
5117 rbstr
= SysAllocString(sz12
);
5119 /* Test all possible flag/vt combinations & the resulting vt type */
5120 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
5122 VARTYPE leftvt
, rightvt
, resvt
;
5124 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
5129 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
5135 if (leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
)
5138 memset(&left
, 0, sizeof(left
));
5139 memset(&right
, 0, sizeof(right
));
5140 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
5141 if (leftvt
== VT_BSTR
)
5142 V_BSTR(&left
) = lbstr
;
5143 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
5144 if (rightvt
== VT_BSTR
)
5145 V_BSTR(&right
) = rbstr
;
5146 V_VT(&result
) = VT_EMPTY
;
5149 /* Don't ask me why but native VarAdd cannot handle:
5150 VT_I1, VT_UI2, VT_UI4, VT_INT, VT_UINT and VT_UI8.
5151 Tested with DCOM98, Win2k, WinXP */
5152 if (ExtraFlags
[i
] & VT_ARRAY
|| ExtraFlags
[i
] & VT_BYREF
||
5153 !IsValidVariantClearVT(leftvt
, ExtraFlags
[i
]) ||
5154 !IsValidVariantClearVT(rightvt
, ExtraFlags
[i
]) ||
5155 leftvt
== VT_CLSID
|| rightvt
== VT_CLSID
||
5156 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
||
5157 leftvt
== VT_VARIANT
|| rightvt
== VT_VARIANT
||
5158 leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
||
5159 leftvt
== VT_I1
|| rightvt
== VT_I1
||
5160 leftvt
== VT_UI2
|| rightvt
== VT_UI2
||
5161 leftvt
== VT_UI4
|| rightvt
== VT_UI4
||
5162 leftvt
== VT_UI8
|| rightvt
== VT_UI8
||
5163 leftvt
== VT_INT
|| rightvt
== VT_INT
||
5164 leftvt
== VT_UINT
|| rightvt
== VT_UINT
) {
5168 if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
5170 else if (leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
)
5172 else if (leftvt
== VT_DECIMAL
|| rightvt
== VT_DECIMAL
)
5174 else if (leftvt
== VT_DATE
|| rightvt
== VT_DATE
)
5176 else if (leftvt
== VT_CY
|| rightvt
== VT_CY
)
5178 else if (leftvt
== VT_R8
|| rightvt
== VT_R8
)
5180 else if (leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
) {
5181 if ((leftvt
== VT_BSTR
&& rightvt
== VT_BSTR
) ||
5182 leftvt
== VT_EMPTY
|| rightvt
== VT_EMPTY
)
5186 } else if (leftvt
== VT_R4
|| rightvt
== VT_R4
) {
5187 if (leftvt
== VT_I4
|| rightvt
== VT_I4
||
5188 leftvt
== VT_I8
|| rightvt
== VT_I8
)
5193 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
5195 else if (leftvt
== VT_I4
|| rightvt
== VT_I4
)
5197 else if (leftvt
== VT_I2
|| rightvt
== VT_I2
||
5198 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
||
5199 (leftvt
== VT_EMPTY
&& rightvt
== VT_EMPTY
))
5201 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
5204 hres
= pVarAdd(&left
, &right
, &result
);
5206 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
5207 "VarAdd: %d|0x%X, %d|0x%X: Expected failure, got 0x%X vt %d\n",
5208 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], hres
,
5211 ok(hres
== S_OK
&& V_VT(&result
) == resvt
,
5212 "VarAdd: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%X vt %d\n",
5213 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], resvt
, hres
,
5216 /* Note, we don't clear left/right deliberately here */
5217 VariantClear(&result
);
5222 /* Test returned values */
5223 VARADD(I4
,4,I4
,2,I4
,6);
5224 VARADD(I2
,4,I2
,2,I2
,6);
5225 VARADD(I2
,-13,I4
,5,I4
,-8);
5226 VARADD(I4
,-13,I4
,5,I4
,-8);
5227 VARADD(I2
,7,R4
,0.5f
,R4
,7.5f
);
5228 VARADD(R4
,0.5f
,I4
,5,R8
,5.5);
5229 VARADD(R8
,7.1,BOOL
,0,R8
,7.1);
5230 VARADD(BSTR
,lbstr
,I2
,4,R8
,16);
5231 VARADD(BSTR
,lbstr
,BOOL
,1,R8
,13);
5232 VARADD(BSTR
,lbstr
,R4
,0.1f
,R8
,12.1);
5233 VARADD(R4
,0.2f
,BSTR
,rbstr
,R8
,12.2);
5234 VARADD(DATE
,2.25,I4
,7,DATE
,9.25);
5235 VARADD(DATE
,1.25,R4
,-1.7f
,DATE
,-0.45);
5237 VARADD(UI1
, UI1_MAX
, UI1
, UI1_MAX
, I2
, UI1_MAX
+ UI1_MAX
);
5238 VARADD(I2
, I2_MAX
, I2
, I2_MAX
, I4
, I2_MAX
+ I2_MAX
);
5239 VARADD(I2
, I2_MAX
, I2
, I2_MIN
, I2
, I2_MAX
+ I2_MIN
);
5240 VARADD(I2
, I2_MIN
, I2
, I2_MIN
, I4
, I2_MIN
+ I2_MIN
);
5241 VARADD(I4
, I4_MAX
, I4
, I4_MIN
, I4
, I4_MAX
+ I4_MIN
);
5242 VARADD(I4
, I4_MAX
, I4
, I4_MAX
, R8
, (double)I4_MAX
+ I4_MAX
);
5243 VARADD(I4
, I4_MIN
, I4
, I4_MIN
, R8
, (double)I4_MIN
+ I4_MIN
);
5244 VARADD(R4
, R4_MAX
, R4
, R4_MAX
, R8
, (double)R4_MAX
+ R4_MAX
);
5245 VARADD(R4
, R4_MAX
, R4
, R4_MIN
, R4
, R4_MAX
+ R4_MIN
);
5246 VARADD(R4
, R4_MIN
, R4
, R4_MIN
, R4
, R4_MIN
+ R4_MIN
);
5247 VARADD(R8
, R8_MAX
, R8
, R8_MIN
, R8
, R8_MAX
+ R8_MIN
);
5248 VARADD(R8
, R8_MIN
, R8
, R8_MIN
, R8
, R8_MIN
+ R8_MIN
);
5250 /* Manually test BSTR + BSTR */
5251 V_VT(&left
) = VT_BSTR
;
5252 V_BSTR(&left
) = lbstr
;
5253 V_VT(&right
) = VT_BSTR
;
5254 V_BSTR(&right
) = rbstr
;
5255 hres
= VarAdd(&left
, &right
, &result
);
5256 ok(hres
== S_OK
&& V_VT(&result
) == VT_BSTR
, "VarAdd: expected coerced type VT_BSTR, got %s!\n", vtstr(V_VT(&result
)));
5257 hres
= VarR8FromStr(V_BSTR(&result
), 0, 0, &r
);
5258 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 1212), "VarAdd: BSTR value %f, expected %f\n", r
, (double)1212);
5259 VariantClear(&result
);
5261 /* Manuly test some VT_CY and VT_DECIMAL variants */
5263 hres
= VarCyFromI4(4711, &V_CY(&cy
));
5264 ok(hres
== S_OK
, "VarCyFromI4 failed!\n");
5265 V_VT(&dec
) = VT_DECIMAL
;
5266 hres
= VarDecFromR8(-4.2, &V_DECIMAL(&dec
));
5267 ok(hres
== S_OK
, "VarDecFromR4 failed!\n");
5268 memset(&left
, 0, sizeof(left
));
5269 memset(&right
, 0, sizeof(right
));
5270 V_VT(&left
) = VT_I4
;
5272 V_VT(&right
) = VT_UI1
;
5275 hres
= VarAdd(&cy
, &right
, &result
);
5276 ok(hres
== S_OK
&& V_VT(&result
) == VT_CY
, "VarAdd: expected coerced type VT_CY, got %s!\n", vtstr(V_VT(&result
)));
5277 hres
= VarR8FromCy(V_CY(&result
), &r
);
5278 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 4720), "VarAdd: CY value %f, expected %f\n", r
, (double)4720);
5280 hres
= VarAdd(&left
, &dec
, &result
);
5281 ok(hres
== S_OK
&& V_VT(&result
) == VT_DECIMAL
, "VarAdd: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result
)));
5282 hres
= VarR8FromDec(&V_DECIMAL(&result
), &r
);
5283 ok(hres
== S_OK
&& EQ_DOUBLE(r
, -15.2), "VarAdd: DECIMAL value %f, expected %f\n", r
, (double)-15.2);
5284 VariantClear(&result
);
5286 SysFreeString(lbstr
);
5287 SysFreeString(rbstr
);
5290 static void test_VarCat(void)
5293 VARIANT left
, right
, result
, expected
, expected_broken
;
5294 static const WCHAR sz34
[] = {'3','4','\0'};
5295 static const WCHAR sz1234
[] = {'1','2','3','4','\0'};
5296 static const WCHAR date_sz12
[] = {'9','/','3','0','/','1','9','8','0','1','2','\0'};
5297 static const WCHAR date_sz12_broken
[] = {'9','/','3','0','/','8','0','1','2','\0'};
5298 static const WCHAR sz12_date
[] = {'1','2','9','/','3','0','/','1','9','8','0','\0'};
5299 static const WCHAR sz12_date_broken
[] = {'1','2','9','/','3','0','/','8','0','\0'};
5300 static const WCHAR sz_empty
[] = {'\0'};
5301 TCHAR orig_date_format
[128];
5302 VARTYPE leftvt
, rightvt
, resultvt
;
5304 HRESULT expected_error_num
;
5306 /* Set date format for testing */
5307 lcid
= LOCALE_USER_DEFAULT
;
5308 GetLocaleInfo(lcid
,LOCALE_SSHORTDATE
,orig_date_format
,128);
5309 SetLocaleInfo(lcid
,LOCALE_SSHORTDATE
,"M/d/yyyy");
5312 VariantInit(&right
);
5313 VariantInit(&result
);
5314 VariantInit(&expected
);
5316 /* Check expected types for all combinations */
5317 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
5322 /* Check if we need/have support for I8 and/or UI8 */
5323 if ((leftvt
== VT_I8
|| leftvt
== VT_UI8
) && !HAVE_OLEAUT32_I8
)
5326 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
5330 expected_error_num
= S_OK
;
5331 resultvt
= VT_EMPTY
;
5333 if (leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
||
5334 leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
||
5335 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
||
5336 leftvt
== 15 || rightvt
== 15 /* Undefined type */)
5339 /* Check if we need/have support for I8 and/or UI8 */
5340 if ((rightvt
== VT_I8
|| rightvt
== VT_UI8
) && !HAVE_OLEAUT32_I8
)
5343 if (leftvt
== VT_NULL
&& rightvt
== VT_NULL
)
5345 else if (leftvt
== VT_VARIANT
&& (rightvt
== VT_ERROR
||
5346 rightvt
== VT_DATE
|| rightvt
== VT_DECIMAL
))
5347 expected_error_num
= DISP_E_TYPEMISMATCH
;
5348 else if ((leftvt
== VT_I2
|| leftvt
== VT_I4
||
5349 leftvt
== VT_R4
|| leftvt
== VT_R8
||
5350 leftvt
== VT_CY
|| leftvt
== VT_BOOL
||
5351 leftvt
== VT_BSTR
|| leftvt
== VT_I1
||
5352 leftvt
== VT_UI1
|| leftvt
== VT_UI2
||
5353 leftvt
== VT_UI4
|| leftvt
== VT_I8
||
5354 leftvt
== VT_UI8
|| leftvt
== VT_INT
||
5355 leftvt
== VT_UINT
|| leftvt
== VT_EMPTY
||
5356 leftvt
== VT_NULL
|| leftvt
== VT_DECIMAL
||
5359 (rightvt
== VT_I2
|| rightvt
== VT_I4
||
5360 rightvt
== VT_R4
|| rightvt
== VT_R8
||
5361 rightvt
== VT_CY
|| rightvt
== VT_BOOL
||
5362 rightvt
== VT_BSTR
|| rightvt
== VT_I1
||
5363 rightvt
== VT_UI1
|| rightvt
== VT_UI2
||
5364 rightvt
== VT_UI4
|| rightvt
== VT_I8
||
5365 rightvt
== VT_UI8
|| rightvt
== VT_INT
||
5366 rightvt
== VT_UINT
|| rightvt
== VT_EMPTY
||
5367 rightvt
== VT_NULL
|| rightvt
== VT_DECIMAL
||
5368 rightvt
== VT_DATE
))
5370 else if (rightvt
== VT_ERROR
&& leftvt
< VT_VOID
)
5371 expected_error_num
= DISP_E_TYPEMISMATCH
;
5372 else if (leftvt
== VT_ERROR
&& (rightvt
== VT_DATE
||
5373 rightvt
== VT_ERROR
|| rightvt
== VT_DECIMAL
))
5374 expected_error_num
= DISP_E_TYPEMISMATCH
;
5375 else if (rightvt
== VT_DATE
|| rightvt
== VT_ERROR
||
5376 rightvt
== VT_DECIMAL
)
5377 expected_error_num
= DISP_E_BADVARTYPE
;
5378 else if (leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
)
5379 expected_error_num
= DISP_E_TYPEMISMATCH
;
5380 else if (leftvt
== VT_VARIANT
)
5381 expected_error_num
= DISP_E_TYPEMISMATCH
;
5382 else if (rightvt
== VT_VARIANT
&& (leftvt
== VT_EMPTY
||
5383 leftvt
== VT_NULL
|| leftvt
== VT_I2
||
5384 leftvt
== VT_I4
|| leftvt
== VT_R4
||
5385 leftvt
== VT_R8
|| leftvt
== VT_CY
||
5386 leftvt
== VT_DATE
|| leftvt
== VT_BSTR
||
5387 leftvt
== VT_BOOL
|| leftvt
== VT_DECIMAL
||
5388 leftvt
== VT_I1
|| leftvt
== VT_UI1
||
5389 leftvt
== VT_UI2
|| leftvt
== VT_UI4
||
5390 leftvt
== VT_I8
|| leftvt
== VT_UI8
||
5391 leftvt
== VT_INT
|| leftvt
== VT_UINT
5393 expected_error_num
= DISP_E_TYPEMISMATCH
;
5395 expected_error_num
= DISP_E_BADVARTYPE
;
5397 V_VT(&left
) = leftvt
;
5398 V_VT(&right
) = rightvt
;
5402 V_BSTR(&left
) = SysAllocString(sz_empty
); break;
5404 V_DATE(&left
) = 0.0; break;
5406 VarDecFromR8(0.0, &V_DECIMAL(&left
)); break;
5413 V_BSTR(&right
) = SysAllocString(sz_empty
); break;
5415 V_DATE(&right
) = 0.0; break;
5417 VarDecFromR8(0.0, &V_DECIMAL(&right
)); break;
5422 hres
= VarCat(&left
, &right
, &result
);
5424 /* Determine the error code for the vt combination */
5425 ok(hres
== expected_error_num
,
5426 "VarCat: %d, %d returned error, 0x%X expected 0x%X.\n",
5427 leftvt
, rightvt
, expected_error_num
, hres
);
5429 /* Check types are correct */
5430 ok(V_VT(&result
) == resultvt
,
5431 "VarCat: %d, %d: expected vt %d, got vt %d\n",
5432 leftvt
, rightvt
, resultvt
, V_VT(&result
));
5434 VariantClear(&left
);
5435 VariantClear(&right
);
5436 VariantClear(&result
);
5440 /* Running single comparison tests to compare outputs */
5442 /* Test concat strings */
5443 V_VT(&left
) = VT_BSTR
;
5444 V_VT(&right
) = VT_BSTR
;
5445 V_VT(&expected
) = VT_BSTR
;
5446 V_BSTR(&left
) = SysAllocString(sz12
);
5447 V_BSTR(&right
) = SysAllocString(sz34
);
5448 V_BSTR(&expected
) = SysAllocString(sz1234
);
5449 hres
= VarCat(&left
,&right
,&result
);
5450 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5451 ok(VarCmp(&result
,&expected
,lcid
,0) == VARCMP_EQ
,
5452 "VarCat: VT_BSTR concat with VT_BSTR failed to return correct result\n");
5454 VariantClear(&left
);
5455 VariantClear(&right
);
5456 VariantClear(&result
);
5458 /* Test if expression is VT_ERROR */
5459 V_VT(&left
) = VT_ERROR
;
5460 V_VT(&right
) = VT_BSTR
;
5461 V_BSTR(&right
) = SysAllocString(sz1234
);
5462 hres
= VarCat(&left
,&right
,&result
);
5463 ok(hres
== DISP_E_TYPEMISMATCH
, "VarCat should have returned DISP_E_TYPEMISMATCH instead of 0x%08x\n", hres
);
5464 ok(V_VT(&result
) == VT_EMPTY
,
5465 "VarCat: VT_ERROR concat with VT_BSTR should have returned VT_EMPTY\n");
5467 VariantClear(&left
);
5468 VariantClear(&right
);
5469 VariantClear(&result
);
5471 V_VT(&left
) = VT_BSTR
;
5472 V_VT(&right
) = VT_ERROR
;
5473 V_BSTR(&left
) = SysAllocString(sz1234
);
5474 hres
= VarCat(&left
,&right
,&result
);
5475 ok(hres
== DISP_E_TYPEMISMATCH
, "VarCat should have returned DISP_E_TYPEMISMATCH instead of 0x%08x\n", hres
);
5476 ok(V_VT(&result
) == VT_EMPTY
,
5477 "VarCat: VT_BSTR concat with VT_ERROR should have returned VT_EMPTY\n");
5479 VariantClear(&left
);
5480 VariantClear(&right
);
5481 VariantClear(&result
);
5482 VariantClear(&expected
);
5484 /* Test combining boolean with number */
5485 V_VT(&left
) = VT_INT
;
5486 V_VT(&right
) = VT_BOOL
;
5487 V_VT(&expected
) = VT_BSTR
;
5489 V_BOOL(&right
) = TRUE
;
5490 V_BSTR(&expected
) = SysAllocString(sz12_true
);
5491 hres
= VarCat(&left
,&right
,&result
);
5492 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5493 hres
= VarCmp(&result
,&expected
,lcid
,0);
5494 ok(hres
== VARCMP_EQ
, "Expected VARCMP_EQ, got %08x for %s, %s\n",
5495 hres
, variantstr(&result
), variantstr(&expected
));
5497 VariantClear(&left
);
5498 VariantClear(&right
);
5499 VariantClear(&result
);
5500 VariantClear(&expected
);
5502 V_VT(&left
) = VT_INT
;
5503 V_VT(&right
) = VT_BOOL
;
5504 V_VT(&expected
) = VT_BSTR
;
5506 V_BOOL(&right
) = FALSE
;
5507 V_BSTR(&expected
) = SysAllocString(sz12_false
);
5508 hres
= VarCat(&left
,&right
,&result
);
5509 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5510 hres
= VarCmp(&result
,&expected
,lcid
,0);
5511 ok(hres
== VARCMP_EQ
, "Expected VARCMP_EQ, got %08x for %s, %s\n",
5512 hres
, variantstr(&result
), variantstr(&expected
));
5514 VariantClear(&left
);
5515 VariantClear(&right
);
5516 VariantClear(&result
);
5517 VariantClear(&expected
);
5519 /* Test when both expressions are numeric */
5520 V_VT(&left
) = VT_INT
;
5521 V_VT(&right
) = VT_INT
;
5522 V_VT(&expected
) = VT_BSTR
;
5525 V_BSTR(&expected
) = SysAllocString(sz1234
);
5526 hres
= VarCat(&left
,&right
,&result
);
5527 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5528 ok(VarCmp(&result
,&expected
,lcid
,0) == VARCMP_EQ
,
5529 "VarCat: NUMBER concat with NUMBER returned incorrect result\n");
5531 VariantClear(&left
);
5532 VariantClear(&right
);
5533 VariantClear(&result
);
5535 /* Test if one expression is numeric and the other is a string */
5536 V_VT(&left
) = VT_INT
;
5537 V_VT(&right
) = VT_BSTR
;
5539 V_BSTR(&right
) = SysAllocString(sz34
);
5540 hres
= VarCat(&left
,&right
,&result
);
5541 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5542 ok(VarCmp(&result
,&expected
,lcid
,0) == VARCMP_EQ
,
5543 "VarCat: NUMBER concat with VT_BSTR, incorrect result\n");
5545 VariantClear(&left
);
5546 VariantClear(&right
);
5547 VariantClear(&result
);
5549 V_VT(&left
) = VT_BSTR
;
5550 V_VT(&right
) = VT_INT
;
5551 V_BSTR(&left
) = SysAllocString(sz12
);
5553 hres
= VarCat(&left
,&right
,&result
);
5554 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5555 ok(VarCmp(&result
,&expected
,lcid
,0) == VARCMP_EQ
,
5556 "VarCat: VT_BSTR concat with NUMBER, incorrect result\n");
5558 VariantClear(&left
);
5559 VariantClear(&right
);
5560 VariantClear(&result
);
5561 VariantClear(&expected
);
5563 /* Test concat dates with strings */
5564 V_VT(&left
) = VT_BSTR
;
5565 V_VT(&right
) = VT_DATE
;
5566 V_VT(&expected
) = VT_BSTR
;
5567 V_VT(&expected_broken
) = VT_BSTR
;
5568 V_BSTR(&left
) = SysAllocString(sz12
);
5569 V_DATE(&right
) = 29494.0;
5570 V_BSTR(&expected
)= SysAllocString(sz12_date
);
5571 V_BSTR(&expected_broken
)= SysAllocString(sz12_date_broken
);
5572 hres
= VarCat(&left
,&right
,&result
);
5573 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5574 ok(VarCmp(&result
,&expected
,lcid
,0) == VARCMP_EQ
||
5575 broken(VarCmp(&result
,&expected_broken
,lcid
,0) == VARCMP_EQ
), /* Some W98 and NT4 (intermittent) */
5576 "VarCat: VT_BSTR concat with VT_DATE returned incorrect result\n");
5578 VariantClear(&left
);
5579 VariantClear(&right
);
5580 VariantClear(&result
);
5581 VariantClear(&expected
);
5582 VariantClear(&expected_broken
);
5584 V_VT(&left
) = VT_DATE
;
5585 V_VT(&right
) = VT_BSTR
;
5586 V_VT(&expected
) = VT_BSTR
;
5587 V_VT(&expected_broken
) = VT_BSTR
;
5588 V_DATE(&left
) = 29494.0;
5589 V_BSTR(&right
) = SysAllocString(sz12
);
5590 V_BSTR(&expected
)= SysAllocString(date_sz12
);
5591 V_BSTR(&expected_broken
)= SysAllocString(date_sz12_broken
);
5592 hres
= VarCat(&left
,&right
,&result
);
5593 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5594 ok(VarCmp(&result
,&expected
,lcid
,0) == VARCMP_EQ
||
5595 broken(VarCmp(&result
,&expected_broken
,lcid
,0) == VARCMP_EQ
), /* Some W98 and NT4 (intermittent) */
5596 "VarCat: VT_DATE concat with VT_BSTR returned incorrect result\n");
5598 VariantClear(&left
);
5599 VariantClear(&right
);
5600 VariantClear(&result
);
5601 VariantClear(&expected
);
5602 VariantClear(&expected_broken
);
5604 /* Test of both expressions are empty */
5605 V_VT(&left
) = VT_BSTR
;
5606 V_VT(&right
) = VT_BSTR
;
5607 V_VT(&expected
) = VT_BSTR
;
5608 V_BSTR(&left
) = SysAllocString(sz_empty
);
5609 V_BSTR(&right
) = SysAllocString(sz_empty
);
5610 V_BSTR(&expected
)= SysAllocString(sz_empty
);
5611 hres
= VarCat(&left
,&right
,&result
);
5612 ok(hres
== S_OK
, "VarCat failed with error 0x%08x\n", hres
);
5613 ok(VarCmp(&result
,&left
,lcid
,0) == VARCMP_EQ
,
5614 "VarCat: EMPTY concat with EMPTY did not return empty VT_BSTR\n");
5616 /* Restore original date format settings */
5617 SetLocaleInfo(lcid
,LOCALE_SSHORTDATE
,orig_date_format
);
5619 VariantClear(&left
);
5620 VariantClear(&right
);
5621 VariantClear(&result
);
5622 VariantClear(&expected
);
5625 static HRESULT (WINAPI
*pVarAnd
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
5627 #define VARAND(vt1,val1,vt2,val2,rvt,rval) \
5628 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
5629 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
5630 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
5631 test_var_call2( __LINE__, pVarAnd, &left, &right, &exp )
5633 #define VARANDCY(vt1,val1,val2,rvt,rval) \
5634 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
5635 V_VT(&right) = VT_CY; V_CY(&right).int64 = val2; \
5636 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
5637 test_var_call2( __LINE__, pVarAnd, &left, &right, &exp )
5639 /* Skip any type that is not defined or produces an error for every case */
5640 #define SKIPTESTAND(a) \
5641 if (a == VT_ERROR || a == VT_VARIANT || \
5642 a == VT_DISPATCH || a == VT_UNKNOWN || \
5643 a > VT_UINT || a == 15 /*not defined*/) \
5646 static void test_VarAnd(void)
5648 static const WCHAR szFalse
[] = { '#','F','A','L','S','E','#','\0' };
5649 static const WCHAR szTrue
[] = { '#','T','R','U','E','#','\0' };
5650 VARIANT left
, right
, exp
, result
;
5651 BSTR false_str
, true_str
;
5655 true_str
= SysAllocString(szTrue
);
5656 false_str
= SysAllocString(szFalse
);
5660 /* Test all possible flag/vt combinations & the resulting vt type */
5661 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
5663 VARTYPE leftvt
, rightvt
, resvt
;
5665 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
5667 SKIPTESTAND(leftvt
);
5669 /* Check if we need/have support for I8 and/or UI8 */
5670 if ((leftvt
== VT_I8
|| leftvt
== VT_UI8
) && !HAVE_OLEAUT32_I8
)
5673 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
5676 SKIPTESTAND(rightvt
);
5678 /* Check if we need/have support for I8 and/or UI8 */
5679 if ((rightvt
== VT_I8
|| rightvt
== VT_UI8
) && !HAVE_OLEAUT32_I8
)
5682 memset(&left
, 0, sizeof(left
));
5683 memset(&right
, 0, sizeof(right
));
5684 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
5685 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
5686 V_VT(&result
) = VT_EMPTY
;
5688 if ((leftvt
| ExtraFlags
[i
]) == VT_BSTR
)
5689 V_BSTR(&left
) = true_str
;
5690 if ((rightvt
| ExtraFlags
[i
]) == VT_BSTR
)
5691 V_BSTR(&right
) = true_str
;
5693 /* Native VarAnd always returns an error when using extra
5694 * flags or if the variant combination is I8 and INT.
5696 if ((leftvt
== VT_I8
&& rightvt
== VT_INT
) ||
5697 (leftvt
== VT_INT
&& rightvt
== VT_I8
) ||
5701 /* Determine return type */
5702 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
5704 else if (leftvt
== VT_I4
|| rightvt
== VT_I4
||
5705 leftvt
== VT_UINT
|| rightvt
== VT_UINT
||
5706 leftvt
== VT_INT
|| rightvt
== VT_INT
||
5707 leftvt
== VT_UINT
|| rightvt
== VT_UINT
||
5708 leftvt
== VT_R4
|| rightvt
== VT_R4
||
5709 leftvt
== VT_R8
|| rightvt
== VT_R8
||
5710 leftvt
== VT_CY
|| rightvt
== VT_CY
||
5711 leftvt
== VT_DATE
|| rightvt
== VT_DATE
||
5712 leftvt
== VT_I1
|| rightvt
== VT_I1
||
5713 leftvt
== VT_UI2
|| rightvt
== VT_UI2
||
5714 leftvt
== VT_UI4
|| rightvt
== VT_UI4
||
5715 leftvt
== VT_UI8
|| rightvt
== VT_UI8
||
5716 leftvt
== VT_DECIMAL
|| rightvt
== VT_DECIMAL
)
5718 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
||
5719 leftvt
== VT_I2
|| rightvt
== VT_I2
||
5720 leftvt
== VT_EMPTY
|| rightvt
== VT_EMPTY
)
5721 if ((leftvt
== VT_NULL
&& rightvt
== VT_UI1
) ||
5722 (leftvt
== VT_UI1
&& rightvt
== VT_NULL
) ||
5723 (leftvt
== VT_UI1
&& rightvt
== VT_UI1
))
5727 else if (leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
||
5728 (leftvt
== VT_BSTR
&& rightvt
== VT_BSTR
))
5730 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
||
5731 leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
)
5736 hres
= pVarAnd(&left
, &right
, &result
);
5738 /* Check expected HRESULT and if result variant type is correct */
5740 ok (hres
== DISP_E_BADVARTYPE
|| hres
== DISP_E_TYPEMISMATCH
,
5741 "VarAnd: %s|0x%X, %s|0x%X: got vt %s hr 0x%X\n",
5742 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
],
5743 vtstr(V_VT(&result
)), hres
);
5745 ok (hres
== S_OK
&& resvt
== V_VT(&result
),
5746 "VarAnd: %s|0x%X, %s|0x%X: expected vt %s hr 0x%X, got vt %s hr 0x%X\n",
5747 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
], vtstr(resvt
),
5748 S_OK
, vtstr(V_VT(&result
)), hres
);
5754 * Test returned values. Since we know the returned type is correct
5755 * and that we handle all combinations of invalid types, just check
5756 * that good type combinations produce the desired value.
5757 * FIXME: Test VT_DECIMAL
5759 VARAND(EMPTY
,0,EMPTY
,0,I2
,0);
5760 VARAND(EMPTY
,1,EMPTY
,0,I2
,0);
5761 VARAND(EMPTY
,1,EMPTY
,1,I2
,0);
5762 VARAND(EMPTY
,0,NULL
,0,I2
,0);
5763 VARAND(EMPTY
,1,NULL
,0,I2
,0);
5764 VARAND(EMPTY
,1,NULL
,1,I2
,0);
5765 VARAND(EMPTY
,0,I1
,0,I4
,0);
5766 VARAND(EMPTY
,0,I1
,1,I4
,0);
5767 VARAND(EMPTY
,1,I1
,1,I4
,0);
5768 VARAND(EMPTY
,0,UI1
,0,I2
,0);
5769 VARAND(EMPTY
,0,UI1
,1,I2
,0);
5770 VARAND(EMPTY
,1,UI1
,1,I2
,0);
5771 VARAND(EMPTY
,0,I2
,0,I2
,0);
5772 VARAND(EMPTY
,0,I2
,1,I2
,0);
5773 VARAND(EMPTY
,1,I2
,1,I2
,0);
5774 VARAND(EMPTY
,0,UI2
,0,I4
,0);
5775 VARAND(EMPTY
,0,UI2
,1,I4
,0);
5776 VARAND(EMPTY
,1,UI2
,1,I4
,0);
5777 VARAND(EMPTY
,0,I4
,0,I4
,0);
5778 VARAND(EMPTY
,0,I4
,1,I4
,0);
5779 VARAND(EMPTY
,1,I4
,1,I4
,0);
5780 VARAND(EMPTY
,0,UI4
,0,I4
,0);
5781 VARAND(EMPTY
,0,UI4
,1,I4
,0);
5782 VARAND(EMPTY
,1,UI4
,1,I4
,0);
5783 if (HAVE_OLEAUT32_I8
)
5785 VARAND(EMPTY
,0,I8
,0,I8
,0);
5786 VARAND(EMPTY
,0,I8
,1,I8
,0);
5787 VARAND(EMPTY
,1,I8
,1,I8
,0);
5788 VARAND(EMPTY
,0,UI8
,0,I4
,0);
5789 VARAND(EMPTY
,0,UI8
,1,I4
,0);
5790 VARAND(EMPTY
,1,UI8
,1,I4
,0);
5792 VARAND(EMPTY
,0,INT
,0,I4
,0);
5793 VARAND(EMPTY
,0,INT
,1,I4
,0);
5794 VARAND(EMPTY
,1,INT
,1,I4
,0);
5795 VARAND(EMPTY
,0,UINT
,0,I4
,0);
5796 VARAND(EMPTY
,0,UINT
,1,I4
,0);
5797 VARAND(EMPTY
,1,UINT
,1,I4
,0);
5798 VARAND(EMPTY
,0,BOOL
,0,I2
,0);
5799 VARAND(EMPTY
,0,BOOL
,1,I2
,0);
5800 VARAND(EMPTY
,1,BOOL
,1,I2
,0);
5801 VARAND(EMPTY
,0,R4
,0,I4
,0);
5802 VARAND(EMPTY
,0,R4
,1,I4
,0);
5803 VARAND(EMPTY
,1,R4
,1,I4
,0);
5804 VARAND(EMPTY
,0,R8
,0,I4
,0);
5805 VARAND(EMPTY
,0,R8
,1,I4
,0);
5806 VARAND(EMPTY
,1,R8
,1,I4
,0);
5807 VARAND(EMPTY
,0,BSTR
,false_str
,I2
,0);
5808 VARAND(EMPTY
,0,BSTR
,true_str
,I2
,0);
5809 VARANDCY(EMPTY
,0,10000,I4
,0);
5811 /* NULL OR 0 = NULL. NULL OR n = n */
5812 VARAND(NULL
,0,NULL
,0,NULL
,0);
5813 VARAND(NULL
,1,NULL
,0,NULL
,0);
5814 VARAND(NULL
,0,I1
,0,I4
,0);
5815 VARAND(NULL
,0,I1
,1,NULL
,0);
5816 VARAND(NULL
,0,UI1
,0,UI1
,0);
5817 VARAND(NULL
,0,UI1
,1,NULL
,0);
5818 VARAND(NULL
,0,I2
,0,I2
,0);
5819 VARAND(NULL
,0,I2
,1,NULL
,0);
5820 VARAND(NULL
,0,UI2
,0,I4
,0);
5821 VARAND(NULL
,0,UI2
,1,NULL
,0);
5822 VARAND(NULL
,0,I4
,0,I4
,0);
5823 VARAND(NULL
,0,I4
,1,NULL
,0);
5824 VARAND(NULL
,0,UI4
,0,I4
,0);
5825 VARAND(NULL
,0,UI4
,1,NULL
,0);
5826 if (HAVE_OLEAUT32_I8
)
5828 VARAND(NULL
,0,I8
,0,I8
,0);
5829 VARAND(NULL
,0,I8
,1,NULL
,0);
5830 VARAND(NULL
,0,UI8
,0,I4
,0);
5831 VARAND(NULL
,0,UI8
,1,NULL
,0);
5833 VARAND(NULL
,0,INT
,0,I4
,0);
5834 VARAND(NULL
,0,INT
,1,NULL
,0);
5835 VARAND(NULL
,0,UINT
,0,I4
,0);
5836 VARAND(NULL
,0,UINT
,1,NULL
,0);
5837 VARAND(NULL
,0,BOOL
,0,BOOL
,0);
5838 VARAND(NULL
,0,BOOL
,1,NULL
,0);
5839 VARAND(NULL
,0,R4
,0,I4
,0);
5840 VARAND(NULL
,0,R4
,1,NULL
,0);
5841 VARAND(NULL
,0,R8
,0,I4
,0);
5842 VARAND(NULL
,0,R8
,1,NULL
,0);
5843 VARAND(NULL
,0,BSTR
,false_str
,BOOL
,0);
5844 VARAND(NULL
,0,BSTR
,true_str
,NULL
,VARIANT_FALSE
);
5845 VARANDCY(NULL
,0,10000,NULL
,0);
5846 VARANDCY(NULL
,0,0,I4
,0);
5847 VARAND(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
);
5848 VARAND(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_FALSE
);
5849 VARAND(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
);
5850 VARAND(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_FALSE
);
5852 /* Assume x,y & y,x are the same from now on to reduce the number of tests */
5853 VARAND(BOOL
,VARIANT_TRUE
,I1
,-1,I4
,-1);
5854 VARAND(BOOL
,VARIANT_TRUE
,I1
,0,I4
,0);
5855 VARAND(BOOL
,VARIANT_FALSE
,I1
,0,I4
,0);
5856 VARAND(BOOL
,VARIANT_TRUE
,UI1
,255,I2
,255);
5857 VARAND(BOOL
,VARIANT_TRUE
,UI1
,0,I2
,0);
5858 VARAND(BOOL
,VARIANT_FALSE
,UI1
,0,I2
,0);
5859 VARAND(BOOL
,VARIANT_TRUE
,I2
,-1,I2
,-1);
5860 VARAND(BOOL
,VARIANT_TRUE
,I2
,0,I2
,0);
5861 VARAND(BOOL
,VARIANT_FALSE
,I2
,0,I2
,0);
5862 VARAND(BOOL
,VARIANT_TRUE
,UI2
,65535,I4
,65535);
5863 VARAND(BOOL
,VARIANT_TRUE
,UI2
,0,I4
,0);
5864 VARAND(BOOL
,VARIANT_FALSE
,UI2
,0,I4
,0);
5865 VARAND(BOOL
,VARIANT_TRUE
,I4
,-1,I4
,-1);
5866 VARAND(BOOL
,VARIANT_TRUE
,I4
,0,I4
,0);
5867 VARAND(BOOL
,VARIANT_FALSE
,I4
,0,I4
,0);
5868 VARAND(BOOL
,VARIANT_TRUE
,UI4
,0xffffffff,I4
,-1);
5869 VARAND(BOOL
,VARIANT_TRUE
,UI4
,0,I4
,0);
5870 VARAND(BOOL
,VARIANT_FALSE
,UI4
,0,I4
,0);
5871 VARAND(BOOL
,VARIANT_TRUE
,R4
,-1,I4
,-1);
5872 VARAND(BOOL
,VARIANT_TRUE
,R4
,0,I4
,0);
5873 VARAND(BOOL
,VARIANT_FALSE
,R4
,0,I4
,0);
5874 VARAND(BOOL
,VARIANT_TRUE
,R8
,-1,I4
,-1);
5875 VARAND(BOOL
,VARIANT_TRUE
,R8
,0,I4
,0);
5876 VARAND(BOOL
,VARIANT_FALSE
,R8
,0,I4
,0);
5877 VARAND(BOOL
,VARIANT_TRUE
,DATE
,-1,I4
,-1);
5878 VARAND(BOOL
,VARIANT_TRUE
,DATE
,0,I4
,0);
5879 VARAND(BOOL
,VARIANT_FALSE
,DATE
,0,I4
,0);
5880 if (HAVE_OLEAUT32_I8
)
5882 VARAND(BOOL
,VARIANT_TRUE
,I8
,-1,I8
,-1);
5883 VARAND(BOOL
,VARIANT_TRUE
,I8
,0,I8
,0);
5884 VARAND(BOOL
,VARIANT_FALSE
,I8
,0,I8
,0);
5885 VARAND(BOOL
,VARIANT_TRUE
,UI8
,0,I4
,0);
5886 VARAND(BOOL
,VARIANT_FALSE
,UI8
,0,I4
,0);
5888 VARAND(BOOL
,VARIANT_TRUE
,INT
,-1,I4
,-1);
5889 VARAND(BOOL
,VARIANT_TRUE
,INT
,0,I4
,0);
5890 VARAND(BOOL
,VARIANT_FALSE
,INT
,0,I4
,0);
5891 VARAND(BOOL
,VARIANT_TRUE
,UINT
,0xffffffff,I4
,-1);
5892 VARAND(BOOL
,VARIANT_TRUE
,UINT
,0,I4
,0);
5893 VARAND(BOOL
,VARIANT_FALSE
,UINT
,0,I4
,0);
5894 VARAND(BOOL
,VARIANT_FALSE
,BSTR
,false_str
,BOOL
,VARIANT_FALSE
);
5895 VARAND(BOOL
,VARIANT_TRUE
,BSTR
,false_str
,BOOL
,VARIANT_FALSE
);
5896 VARAND(BOOL
,VARIANT_FALSE
,BSTR
,true_str
,BOOL
,VARIANT_FALSE
);
5897 VARAND(BOOL
,VARIANT_TRUE
,BSTR
,true_str
,BOOL
,VARIANT_TRUE
);
5898 VARANDCY(BOOL
,VARIANT_TRUE
,10000,I4
,1);
5899 VARANDCY(BOOL
,VARIANT_TRUE
,0,I4
,0);
5900 VARANDCY(BOOL
,VARIANT_FALSE
,0,I4
,0);
5901 VARAND(I1
,-1,I1
,-1,I4
,-1);
5902 VARAND(I1
,-1,I1
,0,I4
,0);
5903 VARAND(I1
,0,I1
,0,I4
,0);
5904 VARAND(I1
,-1,UI1
,255,I4
,255);
5905 VARAND(I1
,-1,UI1
,0,I4
,0);
5906 VARAND(I1
,0,UI1
,0,I4
,0);
5907 VARAND(I1
,-1,I2
,-1,I4
,-1);
5908 VARAND(I1
,-1,I2
,0,I4
,0);
5909 VARAND(I1
,0,I2
,0,I4
,0);
5910 VARAND(I1
,-1,UI2
,65535,I4
,65535);
5911 VARAND(I1
,-1,UI2
,0,I4
,0);
5912 VARAND(I1
,0,UI2
,0,I4
,0);
5913 VARAND(I1
,-1,I4
,-1,I4
,-1);
5914 VARAND(I1
,-1,I4
,0,I4
,0);
5915 VARAND(I1
,0,I4
,0,I4
,0);
5916 VARAND(I1
,-1,UI4
,0xffffffff,I4
,-1);
5917 VARAND(I1
,-1,UI4
,0,I4
,0);
5918 VARAND(I1
,0,UI4
,0,I4
,0);
5919 VARAND(I1
,-1,R4
,-1,I4
,-1);
5920 VARAND(I1
,-1,R4
,0,I4
,0);
5921 VARAND(I1
,0,R4
,0,I4
,0);
5922 VARAND(I1
,-1,R8
,-1,I4
,-1);
5923 VARAND(I1
,-1,R8
,0,I4
,0);
5924 VARAND(I1
,0,R8
,0,I4
,0);
5925 VARAND(I1
,-1,DATE
,-1,I4
,-1);
5926 VARAND(I1
,-1,DATE
,0,I4
,0);
5927 VARAND(I1
,0,DATE
,0,I4
,0);
5928 if (HAVE_OLEAUT32_I8
)
5930 VARAND(I1
,-1,I8
,-1,I8
,-1);
5931 VARAND(I1
,-1,I8
,0,I8
,0);
5932 VARAND(I1
,0,I8
,0,I8
,0);
5933 VARAND(I1
,-1,UI8
,0,I4
,0);
5934 VARAND(I1
,0,UI8
,0,I4
,0);
5936 VARAND(I1
,-1,INT
,-1,I4
,-1);
5937 VARAND(I1
,-1,INT
,0,I4
,0);
5938 VARAND(I1
,0,INT
,0,I4
,0);
5939 VARAND(I1
,-1,UINT
,0xffffffff,I4
,-1);
5940 VARAND(I1
,-1,UINT
,0,I4
,0);
5941 VARAND(I1
,0,UINT
,0,I4
,0);
5942 VARAND(I1
,0,BSTR
,false_str
,I4
,0);
5943 VARAND(I1
,-1,BSTR
,false_str
,I4
,0);
5944 VARAND(I1
,0,BSTR
,true_str
,I4
,0);
5945 VARAND(I1
,-1,BSTR
,true_str
,I4
,-1);
5946 VARANDCY(I1
,-1,10000,I4
,1);
5947 VARANDCY(I1
,-1,0,I4
,0);
5948 VARANDCY(I1
,0,0,I4
,0);
5950 VARAND(UI1
,255,UI1
,255,UI1
,255);
5951 VARAND(UI1
,255,UI1
,0,UI1
,0);
5952 VARAND(UI1
,0,UI1
,0,UI1
,0);
5953 VARAND(UI1
,255,I2
,-1,I2
,255);
5954 VARAND(UI1
,255,I2
,0,I2
,0);
5955 VARAND(UI1
,0,I2
,0,I2
,0);
5956 VARAND(UI1
,255,UI2
,65535,I4
,255);
5957 VARAND(UI1
,255,UI2
,0,I4
,0);
5958 VARAND(UI1
,0,UI2
,0,I4
,0);
5959 VARAND(UI1
,255,I4
,-1,I4
,255);
5960 VARAND(UI1
,255,I4
,0,I4
,0);
5961 VARAND(UI1
,0,I4
,0,I4
,0);
5962 VARAND(UI1
,255,UI4
,0xffffffff,I4
,255);
5963 VARAND(UI1
,255,UI4
,0,I4
,0);
5964 VARAND(UI1
,0,UI4
,0,I4
,0);
5965 VARAND(UI1
,255,R4
,-1,I4
,255);
5966 VARAND(UI1
,255,R4
,0,I4
,0);
5967 VARAND(UI1
,0,R4
,0,I4
,0);
5968 VARAND(UI1
,255,R8
,-1,I4
,255);
5969 VARAND(UI1
,255,R8
,0,I4
,0);
5970 VARAND(UI1
,0,R8
,0,I4
,0);
5971 VARAND(UI1
,255,DATE
,-1,I4
,255);
5972 VARAND(UI1
,255,DATE
,0,I4
,0);
5973 VARAND(UI1
,0,DATE
,0,I4
,0);
5974 if (HAVE_OLEAUT32_I8
)
5976 VARAND(UI1
,255,I8
,-1,I8
,255);
5977 VARAND(UI1
,255,I8
,0,I8
,0);
5978 VARAND(UI1
,0,I8
,0,I8
,0);
5979 VARAND(UI1
,255,UI8
,0,I4
,0);
5980 VARAND(UI1
,0,UI8
,0,I4
,0);
5982 VARAND(UI1
,255,INT
,-1,I4
,255);
5983 VARAND(UI1
,255,INT
,0,I4
,0);
5984 VARAND(UI1
,0,INT
,0,I4
,0);
5985 VARAND(UI1
,255,UINT
,0xffffffff,I4
,255);
5986 VARAND(UI1
,255,UINT
,0,I4
,0);
5987 VARAND(UI1
,0,UINT
,0,I4
,0);
5988 VARAND(UI1
,0,BSTR
,false_str
,I2
,0);
5989 VARAND(UI1
,255,BSTR
,false_str
,I2
,0);
5990 VARAND(UI1
,0,BSTR
,true_str
,I2
,0);
5991 VARAND(UI1
,255,BSTR
,true_str
,I2
,255);
5992 VARANDCY(UI1
,255,10000,I4
,1);
5993 VARANDCY(UI1
,255,0,I4
,0);
5994 VARANDCY(UI1
,0,0,I4
,0);
5996 VARAND(I2
,-1,I2
,-1,I2
,-1);
5997 VARAND(I2
,-1,I2
,0,I2
,0);
5998 VARAND(I2
,0,I2
,0,I2
,0);
5999 VARAND(I2
,-1,UI2
,65535,I4
,65535);
6000 VARAND(I2
,-1,UI2
,0,I4
,0);
6001 VARAND(I2
,0,UI2
,0,I4
,0);
6002 VARAND(I2
,-1,I4
,-1,I4
,-1);
6003 VARAND(I2
,-1,I4
,0,I4
,0);
6004 VARAND(I2
,0,I4
,0,I4
,0);
6005 VARAND(I2
,-1,UI4
,0xffffffff,I4
,-1);
6006 VARAND(I2
,-1,UI4
,0,I4
,0);
6007 VARAND(I2
,0,UI4
,0,I4
,0);
6008 VARAND(I2
,-1,R4
,-1,I4
,-1);
6009 VARAND(I2
,-1,R4
,0,I4
,0);
6010 VARAND(I2
,0,R4
,0,I4
,0);
6011 VARAND(I2
,-1,R8
,-1,I4
,-1);
6012 VARAND(I2
,-1,R8
,0,I4
,0);
6013 VARAND(I2
,0,R8
,0,I4
,0);
6014 VARAND(I2
,-1,DATE
,-1,I4
,-1);
6015 VARAND(I2
,-1,DATE
,0,I4
,0);
6016 VARAND(I2
,0,DATE
,0,I4
,0);
6017 if (HAVE_OLEAUT32_I8
)
6019 VARAND(I2
,-1,I8
,-1,I8
,-1);
6020 VARAND(I2
,-1,I8
,0,I8
,0);
6021 VARAND(I2
,0,I8
,0,I8
,0);
6022 VARAND(I2
,-1,UI8
,0,I4
,0);
6023 VARAND(I2
,0,UI8
,0,I4
,0);
6025 VARAND(I2
,-1,INT
,-1,I4
,-1);
6026 VARAND(I2
,-1,INT
,0,I4
,0);
6027 VARAND(I2
,0,INT
,0,I4
,0);
6028 VARAND(I2
,-1,UINT
,0xffffffff,I4
,-1);
6029 VARAND(I2
,-1,UINT
,0,I4
,0);
6030 VARAND(I2
,0,UINT
,0,I4
,0);
6031 VARAND(I2
,0,BSTR
,false_str
,I2
,0);
6032 VARAND(I2
,-1,BSTR
,false_str
,I2
,0);
6033 VARAND(I2
,0,BSTR
,true_str
,I2
,0);
6034 VARAND(I2
,-1,BSTR
,true_str
,I2
,-1);
6035 VARANDCY(I2
,-1,10000,I4
,1);
6036 VARANDCY(I2
,-1,0,I4
,0);
6037 VARANDCY(I2
,0,0,I4
,0);
6039 VARAND(UI2
,65535,UI2
,65535,I4
,65535);
6040 VARAND(UI2
,65535,UI2
,0,I4
,0);
6041 VARAND(UI2
,0,UI2
,0,I4
,0);
6042 VARAND(UI2
,65535,I4
,-1,I4
,65535);
6043 VARAND(UI2
,65535,I4
,0,I4
,0);
6044 VARAND(UI2
,0,I4
,0,I4
,0);
6045 VARAND(UI2
,65535,UI4
,0xffffffff,I4
,65535);
6046 VARAND(UI2
,65535,UI4
,0,I4
,0);
6047 VARAND(UI2
,0,UI4
,0,I4
,0);
6048 VARAND(UI2
,65535,R4
,-1,I4
,65535);
6049 VARAND(UI2
,65535,R4
,0,I4
,0);
6050 VARAND(UI2
,0,R4
,0,I4
,0);
6051 VARAND(UI2
,65535,R8
,-1,I4
,65535);
6052 VARAND(UI2
,65535,R8
,0,I4
,0);
6053 VARAND(UI2
,0,R8
,0,I4
,0);
6054 VARAND(UI2
,65535,DATE
,-1,I4
,65535);
6055 VARAND(UI2
,65535,DATE
,0,I4
,0);
6056 VARAND(UI2
,0,DATE
,0,I4
,0);
6057 if (HAVE_OLEAUT32_I8
)
6059 VARAND(UI2
,65535,I8
,-1,I8
,65535);
6060 VARAND(UI2
,65535,I8
,0,I8
,0);
6061 VARAND(UI2
,0,I8
,0,I8
,0);
6062 VARAND(UI2
,65535,UI8
,0,I4
,0);
6063 VARAND(UI2
,0,UI8
,0,I4
,0);
6065 VARAND(UI2
,65535,INT
,-1,I4
,65535);
6066 VARAND(UI2
,65535,INT
,0,I4
,0);
6067 VARAND(UI2
,0,INT
,0,I4
,0);
6068 VARAND(UI2
,65535,UINT
,0xffffffff,I4
,65535);
6069 VARAND(UI2
,65535,UINT
,0,I4
,0);
6070 VARAND(UI2
,0,UINT
,0,I4
,0);
6071 VARAND(UI2
,0,BSTR
,false_str
,I4
,0);
6072 VARAND(UI2
,65535,BSTR
,false_str
,I4
,0);
6073 VARAND(UI2
,0,BSTR
,true_str
,I4
,0);
6074 VARAND(UI2
,65535,BSTR
,true_str
,I4
,65535);
6075 VARANDCY(UI2
,65535,10000,I4
,1);
6076 VARANDCY(UI2
,65535,0,I4
,0);
6077 VARANDCY(UI2
,0,0,I4
,0);
6079 VARAND(I4
,-1,I4
,-1,I4
,-1);
6080 VARAND(I4
,-1,I4
,0,I4
,0);
6081 VARAND(I4
,0,I4
,0,I4
,0);
6082 VARAND(I4
,-1,UI4
,0xffffffff,I4
,-1);
6083 VARAND(I4
,-1,UI4
,0,I4
,0);
6084 VARAND(I4
,0,UI4
,0,I4
,0);
6085 VARAND(I4
,-1,R4
,-1,I4
,-1);
6086 VARAND(I4
,-1,R4
,0,I4
,0);
6087 VARAND(I4
,0,R4
,0,I4
,0);
6088 VARAND(I4
,-1,R8
,-1,I4
,-1);
6089 VARAND(I4
,-1,R8
,0,I4
,0);
6090 VARAND(I4
,0,R8
,0,I4
,0);
6091 VARAND(I4
,-1,DATE
,-1,I4
,-1);
6092 VARAND(I4
,-1,DATE
,0,I4
,0);
6093 VARAND(I4
,0,DATE
,0,I4
,0);
6094 if (HAVE_OLEAUT32_I8
)
6096 VARAND(I4
,-1,I8
,-1,I8
,-1);
6097 VARAND(I4
,-1,I8
,0,I8
,0);
6098 VARAND(I4
,0,I8
,0,I8
,0);
6099 VARAND(I4
,-1,UI8
,0,I4
,0);
6100 VARAND(I4
,0,UI8
,0,I4
,0);
6102 VARAND(I4
,-1,INT
,-1,I4
,-1);
6103 VARAND(I4
,-1,INT
,0,I4
,0);
6104 VARAND(I4
,0,INT
,0,I4
,0);
6105 VARAND(I4
,-1,UINT
,0xffffffff,I4
,-1);
6106 VARAND(I4
,-1,UINT
,0,I4
,0);
6107 VARAND(I4
,0,UINT
,0,I4
,0);
6108 VARAND(I4
,0,BSTR
,false_str
,I4
,0);
6109 VARAND(I4
,-1,BSTR
,false_str
,I4
,0);
6110 VARAND(I4
,0,BSTR
,true_str
,I4
,0);
6111 VARAND(I4
,-1,BSTR
,true_str
,I4
,-1);
6112 VARANDCY(I4
,-1,10000,I4
,1);
6113 VARANDCY(I4
,-1,0,I4
,0);
6114 VARANDCY(I4
,0,0,I4
,0);
6116 VARAND(UI4
,0xffffffff,UI4
,0xffffffff,I4
,-1);
6117 VARAND(UI4
,0xffffffff,UI4
,0,I4
,0);
6118 VARAND(UI4
,0,UI4
,0,I4
,0);
6119 VARAND(UI4
,0xffffffff,R4
,-1,I4
,-1);
6120 VARAND(UI4
,0xffffffff,R4
,0,I4
,0);
6121 VARAND(UI4
,0,R4
,0,I4
,0);
6122 VARAND(UI4
,0xffffffff,R8
,-1,I4
,-1);
6123 VARAND(UI4
,0xffffffff,R8
,0,I4
,0);
6124 VARAND(UI4
,0,R8
,0,I4
,0);
6125 VARAND(UI4
,0xffffffff,DATE
,-1,I4
,-1);
6126 VARAND(UI4
,0xffffffff,DATE
,0,I4
,0);
6127 VARAND(UI4
,0,DATE
,0,I4
,0);
6128 if (HAVE_OLEAUT32_I8
)
6130 VARAND(UI4
,0xffffffff,I8
,0,I8
,0);
6131 VARAND(UI4
,0,I8
,0,I8
,0);
6132 VARAND(UI4
,0xffffffff,UI8
,0,I4
,0);
6133 VARAND(UI4
,0,UI8
,0,I4
,0);
6135 VARAND(UI4
,0xffffffff,INT
,-1,I4
,-1);
6136 VARAND(UI4
,0xffffffff,INT
,0,I4
,0);
6137 VARAND(UI4
,0,INT
,0,I4
,0);
6138 VARAND(UI4
,0xffffffff,UINT
,0xffffffff,I4
,-1);
6139 VARAND(UI4
,0xffffffff,UINT
,0,I4
,0);
6140 VARAND(UI4
,0,UINT
,0,I4
,0);
6141 VARAND(UI4
,0,BSTR
,false_str
,I4
,0);
6142 VARAND(UI4
,0xffffffff,BSTR
,false_str
,I4
,0);
6143 VARAND(UI4
,0,BSTR
,true_str
,I4
,0);
6144 VARAND(UI4
,0xffffffff,BSTR
,true_str
,I4
,-1);
6145 VARANDCY(UI4
,0xffffffff,10000,I4
,1);
6146 VARANDCY(UI4
,0xffffffff,0,I4
,0);
6147 VARANDCY(UI4
,0,0,I4
,0);
6149 VARAND(R4
,-1,R4
,-1,I4
,-1);
6150 VARAND(R4
,-1,R4
,0,I4
,0);
6151 VARAND(R4
,0,R4
,0,I4
,0);
6152 VARAND(R4
,-1,R8
,-1,I4
,-1);
6153 VARAND(R4
,-1,R8
,0,I4
,0);
6154 VARAND(R4
,0,R8
,0,I4
,0);
6155 VARAND(R4
,-1,DATE
,-1,I4
,-1);
6156 VARAND(R4
,-1,DATE
,0,I4
,0);
6157 VARAND(R4
,0,DATE
,0,I4
,0);
6158 if (HAVE_OLEAUT32_I8
)
6160 VARAND(R4
,-1,I8
,-1,I8
,-1);
6161 VARAND(R4
,-1,I8
,0,I8
,0);
6162 VARAND(R4
,0,I8
,0,I8
,0);
6163 VARAND(R4
,-1,UI8
,0,I4
,0);
6164 VARAND(R4
,0,UI8
,0,I4
,0);
6166 VARAND(R4
,-1,INT
,-1,I4
,-1);
6167 VARAND(R4
,-1,INT
,0,I4
,0);
6168 VARAND(R4
,0,INT
,0,I4
,0);
6169 VARAND(R4
,-1,UINT
,0xffffffff,I4
,-1);
6170 VARAND(R4
,-1,UINT
,0,I4
,0);
6171 VARAND(R4
,0,UINT
,0,I4
,0);
6172 VARAND(R4
,0,BSTR
,false_str
,I4
,0);
6173 VARAND(R4
,-1,BSTR
,false_str
,I4
,0);
6174 VARAND(R4
,0,BSTR
,true_str
,I4
,0);
6175 VARAND(R4
,-1,BSTR
,true_str
,I4
,-1);
6176 VARANDCY(R4
,-1,10000,I4
,1);
6177 VARANDCY(R4
,-1,0,I4
,0);
6178 VARANDCY(R4
,0,0,I4
,0);
6180 VARAND(R8
,-1,R8
,-1,I4
,-1);
6181 VARAND(R8
,-1,R8
,0,I4
,0);
6182 VARAND(R8
,0,R8
,0,I4
,0);
6183 VARAND(R8
,-1,DATE
,-1,I4
,-1);
6184 VARAND(R8
,-1,DATE
,0,I4
,0);
6185 VARAND(R8
,0,DATE
,0,I4
,0);
6186 if (HAVE_OLEAUT32_I8
)
6188 VARAND(R8
,-1,I8
,-1,I8
,-1);
6189 VARAND(R8
,-1,I8
,0,I8
,0);
6190 VARAND(R8
,0,I8
,0,I8
,0);
6191 VARAND(R8
,-1,UI8
,0,I4
,0);
6192 VARAND(R8
,0,UI8
,0,I4
,0);
6194 VARAND(R8
,-1,INT
,-1,I4
,-1);
6195 VARAND(R8
,-1,INT
,0,I4
,0);
6196 VARAND(R8
,0,INT
,0,I4
,0);
6197 VARAND(R8
,-1,UINT
,0xffffffff,I4
,-1);
6198 VARAND(R8
,-1,UINT
,0,I4
,0);
6199 VARAND(R8
,0,UINT
,0,I4
,0);
6200 VARAND(R8
,0,BSTR
,false_str
,I4
,0);
6201 VARAND(R8
,-1,BSTR
,false_str
,I4
,0);
6202 VARAND(R8
,0,BSTR
,true_str
,I4
,0);
6203 VARAND(R8
,-1,BSTR
,true_str
,I4
,-1);
6204 VARANDCY(R8
,-1,10000,I4
,1);
6205 VARANDCY(R8
,-1,0,I4
,0);
6206 VARANDCY(R8
,0,0,I4
,0);
6208 VARAND(DATE
,-1,DATE
,-1,I4
,-1);
6209 VARAND(DATE
,-1,DATE
,0,I4
,0);
6210 VARAND(DATE
,0,DATE
,0,I4
,0);
6211 if (HAVE_OLEAUT32_I8
)
6213 VARAND(DATE
,-1,I8
,-1,I8
,-1);
6214 VARAND(DATE
,-1,I8
,0,I8
,0);
6215 VARAND(DATE
,0,I8
,0,I8
,0);
6216 VARAND(DATE
,-1,UI8
,0,I4
,0);
6217 VARAND(DATE
,0,UI8
,0,I4
,0);
6219 VARAND(DATE
,-1,INT
,-1,I4
,-1);
6220 VARAND(DATE
,-1,INT
,0,I4
,0);
6221 VARAND(DATE
,0,INT
,0,I4
,0);
6222 VARAND(DATE
,-1,UINT
,0xffffffff,I4
,-1);
6223 VARAND(DATE
,-1,UINT
,0,I4
,0);
6224 VARAND(DATE
,0,UINT
,0,I4
,0);
6225 VARAND(DATE
,0,BSTR
,false_str
,I4
,0);
6226 VARAND(DATE
,-1,BSTR
,false_str
,I4
,0);
6227 VARAND(DATE
,0,BSTR
,true_str
,I4
,0);
6228 VARAND(DATE
,-1,BSTR
,true_str
,I4
,-1);
6229 VARANDCY(DATE
,-1,10000,I4
,1);
6230 VARANDCY(DATE
,-1,0,I4
,0);
6231 VARANDCY(DATE
,0,0,I4
,0);
6233 if (HAVE_OLEAUT32_I8
)
6235 VARAND(I8
,-1,I8
,-1,I8
,-1);
6236 VARAND(I8
,-1,I8
,0,I8
,0);
6237 VARAND(I8
,0,I8
,0,I8
,0);
6238 VARAND(I8
,-1,UI8
,0,I8
,0);
6239 VARAND(I8
,0,UI8
,0,I8
,0);
6240 VARAND(I8
,-1,UINT
,0,I8
,0);
6241 VARAND(I8
,0,UINT
,0,I8
,0);
6242 VARAND(I8
,0,BSTR
,false_str
,I8
,0);
6243 VARAND(I8
,-1,BSTR
,false_str
,I8
,0);
6244 VARAND(I8
,0,BSTR
,true_str
,I8
,0);
6245 VARAND(I8
,-1,BSTR
,true_str
,I8
,-1);
6246 VARANDCY(I8
,-1,10000,I8
,1);
6247 VARANDCY(I8
,-1,0,I8
,0);
6248 VARANDCY(I8
,0,0,I8
,0);
6250 VARAND(UI8
,0xffff,UI8
,0xffff,I4
,0xffff);
6251 VARAND(UI8
,0xffff,UI8
,0,I4
,0);
6252 VARAND(UI8
,0,UI8
,0,I4
,0);
6253 VARAND(UI8
,0xffff,INT
,-1,I4
,65535);
6254 VARAND(UI8
,0xffff,INT
,0,I4
,0);
6255 VARAND(UI8
,0,INT
,0,I4
,0);
6256 VARAND(UI8
,0xffff,UINT
,0xffff,I4
,0xffff);
6257 VARAND(UI8
,0xffff,UINT
,0,I4
,0);
6258 VARAND(UI8
,0,UINT
,0,I4
,0);
6259 VARAND(UI8
,0,BSTR
,false_str
,I4
,0);
6260 VARAND(UI8
,0xffff,BSTR
,false_str
,I4
,0);
6261 VARAND(UI8
,0,BSTR
,true_str
,I4
,0);
6262 VARAND(UI8
,0xffff,BSTR
,true_str
,I4
,65535);
6263 VARANDCY(UI8
,0xffff,10000,I4
,1);
6264 VARANDCY(UI8
,0xffff,0,I4
,0);
6265 VARANDCY(UI8
,0,0,I4
,0);
6268 VARAND(INT
,-1,INT
,-1,I4
,-1);
6269 VARAND(INT
,-1,INT
,0,I4
,0);
6270 VARAND(INT
,0,INT
,0,I4
,0);
6271 VARAND(INT
,-1,UINT
,0xffff,I4
,65535);
6272 VARAND(INT
,-1,UINT
,0,I4
,0);
6273 VARAND(INT
,0,UINT
,0,I4
,0);
6274 VARAND(INT
,0,BSTR
,false_str
,I4
,0);
6275 VARAND(INT
,-1,BSTR
,false_str
,I4
,0);
6276 VARAND(INT
,0,BSTR
,true_str
,I4
,0);
6277 VARAND(INT
,-1,BSTR
,true_str
,I4
,-1);
6278 VARANDCY(INT
,-1,10000,I4
,1);
6279 VARANDCY(INT
,-1,0,I4
,0);
6280 VARANDCY(INT
,0,0,I4
,0);
6282 VARAND(UINT
,0xffff,UINT
,0xffff,I4
,0xffff);
6283 VARAND(UINT
,0xffff,UINT
,0,I4
,0);
6284 VARAND(UINT
,0,UINT
,0,I4
,0);
6285 VARAND(UINT
,0,BSTR
,false_str
,I4
,0);
6286 VARAND(UINT
,0xffff,BSTR
, false_str
,I4
,0);
6287 VARAND(UINT
,0,BSTR
,true_str
,I4
,0);
6288 VARAND(UINT
,0xffff,BSTR
,true_str
,I4
,65535);
6289 VARANDCY(UINT
,0xffff,10000,I4
,1);
6290 VARANDCY(UINT
,0xffff,0,I4
,0);
6291 VARANDCY(UINT
,0,0,I4
,0);
6293 VARAND(BSTR
,false_str
,BSTR
,false_str
,BOOL
,0);
6294 VARAND(BSTR
,true_str
,BSTR
,false_str
,BOOL
,VARIANT_FALSE
);
6295 VARAND(BSTR
,true_str
,BSTR
,true_str
,BOOL
,VARIANT_TRUE
);
6296 VARANDCY(BSTR
,true_str
,10000,I4
,1);
6297 VARANDCY(BSTR
,false_str
,10000,I4
,0);
6299 SysFreeString(true_str
);
6300 SysFreeString(false_str
);
6303 static HRESULT (WINAPI
*pVarCmp
)(LPVARIANT
,LPVARIANT
,LCID
,ULONG
);
6305 static void test_cmp( int line
, LCID lcid
, UINT flags
, VARIANT
*left
, VARIANT
*right
, HRESULT result
)
6309 hres
= pVarCmp(left
,right
,lcid
,flags
);
6310 ok_(__FILE__
,line
)(hres
== result
, "VarCmp(%s,%s): expected 0x%x, got hres=0x%x\n",
6311 variantstr(left
), variantstr(right
), result
, hres
);
6313 static void test_cmpex( int line
, LCID lcid
, VARIANT
*left
, VARIANT
*right
,
6314 HRESULT res1
, HRESULT res2
, HRESULT res3
, HRESULT res4
)
6316 test_cmp( line
, lcid
, 0, left
, right
, res1
);
6317 V_VT(left
) |= VT_RESERVED
;
6318 test_cmp( line
, lcid
, 0, left
, right
, res2
);
6319 V_VT(left
) &= ~VT_RESERVED
;
6320 V_VT(right
) |= VT_RESERVED
;
6321 test_cmp( line
, lcid
, 0, left
, right
, res3
);
6322 V_VT(left
) |= VT_RESERVED
;
6323 test_cmp( line
, lcid
, 0, left
, right
, res4
);
6324 ok_(__FILE__
,line
)(V_VT(left
) & V_VT(right
) & VT_RESERVED
, "VT_RESERVED filtered out\n");
6327 /* ERROR from wingdi.h is interfering here */
6329 #define _VARCMP(vt1,val1,vtfl1,vt2,val2,vtfl2,lcid,flags,result) \
6330 V_##vt1(&left) = val1; V_VT(&left) = VT_##vt1 | vtfl1; \
6331 V_##vt2(&right) = val2; V_VT(&right) = VT_##vt2 | vtfl2; \
6332 test_cmp( __LINE__, lcid, flags, &left, &right, result )
6333 #define VARCMPEX(vt1,val1,vt2,val2,res1,res2,res3,res4) \
6334 V_##vt1(&left) = val1; V_VT(&left) = VT_##vt1; \
6335 V_##vt2(&right) = val2; V_VT(&right) = VT_##vt2; \
6336 test_cmpex( __LINE__, lcid, &left, &right, res1, res2, res3, res4 )
6337 #define VARCMP(vt1,val1,vt2,val2,result) \
6338 VARCMPEX(vt1,val1,vt2,val2,result,result,result,result)
6339 /* The above macros do not work for VT_NULL as NULL gets expanded first */
6340 #define V_NULL_ V_NULL
6341 #define VT_NULL_ VT_NULL
6343 static void test_VarCmp(void)
6345 VARIANT left
, right
;
6350 static const WCHAR szhuh
[] = {'h','u','h','?','\0'};
6351 static const WCHAR sz2cents
[] = {'2','c','e','n','t','s','\0'};
6352 static const WCHAR szempty
[] = {'\0'};
6353 static const WCHAR sz0
[] = {'0','\0'};
6354 static const WCHAR sz1
[] = {'1','\0'};
6355 static const WCHAR sz7
[] = {'7','\0'};
6356 static const WCHAR sz42
[] = {'4','2','\0'};
6357 static const WCHAR sz1neg
[] = {'-','1','\0'};
6358 static const WCHAR sz666neg
[] = {'-','6','6','6','\0'};
6359 static const WCHAR sz1few
[] = {'1','.','0','0','0','0','0','0','0','1','\0'};
6360 BSTR bstrhuh
, bstrempty
, bstr0
, bstr1
, bstr7
, bstr42
, bstr1neg
, bstr666neg
;
6361 BSTR bstr2cents
, bstr1few
;
6365 lcid
= MAKELCID(MAKELANGID(LANG_ENGLISH
,SUBLANG_ENGLISH_US
),SORT_DEFAULT
);
6366 bstrempty
= SysAllocString(szempty
);
6367 bstrhuh
= SysAllocString(szhuh
);
6368 bstr2cents
= SysAllocString(sz2cents
);
6369 bstr0
= SysAllocString(sz0
);
6370 bstr1
= SysAllocString(sz1
);
6371 bstr7
= SysAllocString(sz7
);
6372 bstr42
= SysAllocString(sz42
);
6373 bstr1neg
= SysAllocString(sz1neg
);
6374 bstr666neg
= SysAllocString(sz666neg
);
6375 bstr1few
= SysAllocString(sz1few
);
6377 /* Test all possible flag/vt combinations & the resulting vt type */
6378 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
6380 VARTYPE leftvt
, rightvt
;
6382 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
6387 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
6390 HRESULT expect
= VARCMP_EQ
;
6394 memset(&left
, 0, sizeof(left
));
6395 memset(&right
, 0, sizeof(right
));
6396 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
6397 if (leftvt
== VT_BSTR
) {
6398 V_BSTR(&left
) = bstr1neg
;
6399 if (ExtraFlags
[i
] & VT_RESERVED
)
6404 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
6405 if (rightvt
== VT_BSTR
) {
6406 V_BSTR(&right
) = bstr1neg
;
6407 if (ExtraFlags
[i
] & VT_RESERVED
)
6413 /* Don't ask me why but native VarCmp cannot handle:
6414 VT_I1, VT_UI2, VT_UI4, VT_UINT and VT_UI8.
6415 VT_INT is only supported as left variant. Go figure.
6416 Tested with DCOM98, Win2k, WinXP */
6417 if (ExtraFlags
[i
] & VT_ARRAY
|| ExtraFlags
[i
] & VT_BYREF
||
6418 !IsValidVariantClearVT(leftvt
, ExtraFlags
[i
] & ~VT_RESERVED
) ||
6419 !IsValidVariantClearVT(rightvt
, ExtraFlags
[i
] & ~VT_RESERVED
) ||
6420 leftvt
== VT_CLSID
|| rightvt
== VT_CLSID
||
6421 leftvt
== VT_DISPATCH
|| rightvt
== VT_DISPATCH
||
6422 leftvt
== VT_ERROR
|| rightvt
== VT_ERROR
||
6423 leftvt
== VT_RECORD
|| rightvt
== VT_RECORD
||
6424 leftvt
== VT_UNKNOWN
|| rightvt
== VT_UNKNOWN
||
6425 leftvt
== VT_VARIANT
|| rightvt
== VT_VARIANT
||
6426 leftvt
== VT_I1
|| rightvt
== VT_I1
||
6427 leftvt
== VT_UI2
|| rightvt
== VT_UI2
||
6428 leftvt
== VT_UI4
|| rightvt
== VT_UI4
||
6429 leftvt
== VT_UI8
|| rightvt
== VT_UI8
||
6430 rightvt
== VT_INT
||
6431 leftvt
== VT_UINT
|| rightvt
== VT_UINT
) {
6435 if (leftvt
== VT_ERROR
&& rightvt
== VT_ERROR
&&
6436 !(ExtraFlags
[i
] & ~VT_RESERVED
)) {
6439 } else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
6440 expect
= VARCMP_NULL
;
6441 else if (leftvt
== VT_BSTR
&& rightvt
== VT_BSTR
)
6443 else if (leftvt
== VT_BSTR
&& rightvt
== VT_EMPTY
)
6445 else if (leftvt
== VT_EMPTY
&& rightvt
== VT_BSTR
)
6448 hres
= pVarCmp(&left
, &right
, LOCALE_USER_DEFAULT
, 0);
6450 ok(hres
== DISP_E_TYPEMISMATCH
|| hres
== DISP_E_BADVARTYPE
,
6451 "VarCmp: %d|0x%X, %d|0x%X: Expected failure, got 0x%X\n",
6452 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], hres
);
6455 "VarCmp: %d|0x%X, %d|0x%X: Expected 0x%X, got 0x%X\n",
6456 leftvt
, ExtraFlags
[i
], rightvt
, ExtraFlags
[i
], expect
,
6463 /* VARCMP{,EX} run each 4 tests with a permutation of all possible
6464 input variants with (1) and without (0) VT_RESERVED set. The order
6465 of the permutations is (0,0); (1,0); (0,1); (1,1) */
6466 VARCMP(INT
,4711,I2
,4711,VARCMP_EQ
);
6467 VARCMP(INT
,4711,I2
,-4711,VARCMP_GT
);
6468 VARCMP(ERROR
,0,ERROR
,0,VARCMP_EQ
);
6469 VARCMP(ERROR
,0,UI1
,0,DISP_E_TYPEMISMATCH
);
6470 VARCMP(EMPTY
,0,EMPTY
,0,VARCMP_EQ
);
6471 VARCMP(I4
,1,R8
,1.0,VARCMP_EQ
);
6472 VARCMP(EMPTY
,19,I2
,0,VARCMP_EQ
);
6473 ok(V_EMPTY(&left
) == 19, "VT_EMPTY modified!\n");
6474 VARCMP(I4
,1,UI1
,1,VARCMP_EQ
);
6475 VARCMP(I2
,2,I2
,2,VARCMP_EQ
);
6476 VARCMP(I2
,1,I2
,2,VARCMP_LT
);
6477 VARCMP(I2
,2,I2
,1,VARCMP_GT
);
6478 VARCMP(I2
,2,EMPTY
,1,VARCMP_GT
);
6479 VARCMP(I2
,2,NULL_
,1,VARCMP_NULL
);
6481 /* BSTR handling, especially in conjunction with VT_RESERVED */
6482 VARCMP(BSTR
,bstr0
,NULL_
,0,VARCMP_NULL
);
6483 VARCMP(BSTR
,bstr0
,BSTR
,bstr0
,VARCMP_EQ
);
6484 VARCMP(BSTR
,bstrempty
,BSTR
,bstr0
,VARCMP_LT
);
6485 VARCMP(BSTR
,bstr7
,BSTR
,bstr0
,VARCMP_GT
);
6486 VARCMP(BSTR
,bstr7
,BSTR
,bstr1neg
,VARCMP_GT
);
6487 VARCMP(BSTR
,bstr0
,BSTR
,NULL
,VARCMP_GT
);
6488 VARCMP(BSTR
,NULL
,BSTR
,NULL
,VARCMP_EQ
);
6489 VARCMP(BSTR
,bstrempty
,BSTR
,NULL
,VARCMP_EQ
);
6490 VARCMP(BSTR
,NULL
,EMPTY
,0,VARCMP_EQ
);
6491 VARCMP(EMPTY
,0,BSTR
,NULL
,VARCMP_EQ
);
6492 VARCMP(EMPTY
,0,BSTR
,bstrempty
,VARCMP_EQ
);
6493 VARCMP(EMPTY
,1,BSTR
,bstrempty
,VARCMP_EQ
);
6494 VARCMP(BSTR
,bstr0
,EMPTY
,0,VARCMP_GT
);
6495 VARCMP(BSTR
,bstr42
,EMPTY
,0,VARCMP_GT
);
6496 VARCMPEX(BSTR
,bstrempty
,UI1
,0,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
6497 VARCMPEX(BSTR
,bstrempty
,I2
,-1,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
6498 VARCMPEX(I4
,0,BSTR
,bstrempty
,VARCMP_LT
,VARCMP_LT
,VARCMP_GT
,VARCMP_LT
);
6499 VARCMPEX(BSTR
,NULL
,UI1
,0,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
6500 VARCMPEX(I4
,7,BSTR
,NULL
,VARCMP_LT
,VARCMP_LT
,VARCMP_GT
,VARCMP_LT
);
6501 _VARCMP(BSTR
,(BSTR
)100,0,I2
,100,0,lcid
,0,VARCMP_GT
);
6502 VARCMPEX(BSTR
,bstr0
,UI1
,0,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_GT
);
6503 VARCMPEX(I2
,0,BSTR
,bstr0
,VARCMP_LT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_LT
);
6504 VARCMP(BSTR
,bstrhuh
,I4
,I4_MAX
,VARCMP_GT
);
6505 VARCMP(BSTR
,bstr2cents
,I4
,2,VARCMP_GT
);
6506 VARCMPEX(BSTR
,bstr2cents
,I4
,42,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
6507 VARCMP(BSTR
,bstr2cents
,I4
,-1,VARCMP_GT
);
6508 VARCMPEX(BSTR
,bstr2cents
,I4
,-666,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
6509 VARCMPEX(BSTR
,bstr0
,I2
,0,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_GT
);
6510 VARCMPEX(BSTR
,bstr0
,I4
,0,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_GT
);
6511 VARCMPEX(BSTR
,bstr0
,I4
,-666,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
6512 VARCMP(BSTR
,bstr1
,I4
,0,VARCMP_GT
);
6513 VARCMPEX(BSTR
,bstr1
,I4
,1,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_GT
);
6514 VARCMPEX(BSTR
,bstr1
,I4
,I4_MAX
,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
,VARCMP_GT
);
6515 VARCMPEX(BSTR
,bstr1
,I4
,-1,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
6516 VARCMP(BSTR
,bstr7
,I4
,1,VARCMP_GT
);
6517 VARCMPEX(BSTR
,bstr7
,I4
,7,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_GT
);
6518 VARCMPEX(BSTR
,bstr7
,I4
,42,VARCMP_GT
,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
);
6519 VARCMPEX(BSTR
,bstr42
,I4
,7,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_GT
);
6520 VARCMPEX(BSTR
,bstr42
,I4
,42,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_GT
);
6521 VARCMPEX(BSTR
,bstr42
,I4
,I4_MAX
,VARCMP_GT
,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
);
6522 VARCMPEX(BSTR
,bstr1neg
,I4
,1,VARCMP_GT
,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
);
6523 VARCMPEX(BSTR
,bstr1neg
,I4
,42,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
,VARCMP_LT
);
6524 VARCMPEX(BSTR
,bstr1neg
,I4
,-1,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_LT
);
6525 VARCMPEX(BSTR
,bstr1neg
,I4
,-666,VARCMP_GT
,VARCMP_LT
,VARCMP_GT
,VARCMP_LT
);
6526 VARCMPEX(BSTR
,bstr666neg
,I4
,1,VARCMP_GT
,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
);
6527 VARCMPEX(BSTR
,bstr666neg
,I4
,7,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
,VARCMP_LT
);
6528 VARCMPEX(BSTR
,bstr666neg
,I4
,42,VARCMP_GT
,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
);
6529 VARCMPEX(BSTR
,bstr666neg
,I4
,I4_MAX
,VARCMP_GT
,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
);
6530 VARCMPEX(BSTR
,bstr666neg
,I4
,-1,VARCMP_GT
,VARCMP_GT
,VARCMP_LT
,VARCMP_LT
);
6531 VARCMPEX(BSTR
,bstr666neg
,I4
,-666,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_LT
);
6532 VARCMPEX(BSTR
,bstr7
,R8
,7.0,VARCMP_GT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_GT
);
6533 VARCMPEX(R8
,3.141592,BSTR
,NULL
,VARCMP_LT
,VARCMP_LT
,VARCMP_GT
,VARCMP_LT
);
6534 VARCMP(BSTR
,bstr7
,BSTR
,bstr7
,VARCMP_EQ
);
6535 VARCMP(BSTR
,bstr7
,BSTR
,bstr42
,VARCMP_GT
);
6536 VARCMP(BSTR
,bstr42
,BSTR
,bstr7
,VARCMP_LT
);
6538 /* DECIMAL handling */
6539 setdec(&dec
,0,0,0,0);
6540 VARCMPEX(DECIMAL
,dec
,BSTR
,bstr0
,VARCMP_LT
,VARCMP_EQ
,VARCMP_EQ
,VARCMP_LT
);
6541 setdec64(&dec
,0,0,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF); /* max DECIMAL */
6542 VARCMP(DECIMAL
,dec
,R8
,R8_MAX
,VARCMP_LT
); /* R8 has bigger range */
6543 VARCMP(DECIMAL
,dec
,DATE
,R8_MAX
,VARCMP_LT
); /* DATE has bigger range */
6544 setdec64(&dec
,0,0x80,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF);
6545 VARCMP(DECIMAL
,dec
,R8
,-R8_MAX
,VARCMP_GT
);
6546 setdec64(&dec
,20,0,0x5,0x6BC75E2D,0x63100001); /* 1+1e-20 */
6547 VARCMP(DECIMAL
,dec
,R8
,1,VARCMP_GT
); /* DECIMAL has higher precision */
6549 /* Show that DATE is handled just as a R8 */
6550 VARCMP(DATE
,DATE_MAX
,DATE
,DATE_MAX
+1,VARCMP_LT
);
6551 VARCMP(DATE
,DATE_MIN
,DATE
,DATE_MIN
-1,VARCMP_GT
);
6552 VARCMP(DATE
,R8_MIN
,R8
,R8_MIN
,VARCMP_EQ
);
6553 VARCMP(DATE
,1,DATE
,1+1e-15,VARCMP_LT
); /* 1e-15 == 8.64e-11 seconds */
6554 VARCMP(DATE
,25570.0,DATE
,25570.0,VARCMP_EQ
);
6555 VARCMP(DATE
,25570.0,DATE
,25571.0,VARCMP_LT
);
6556 VARCMP(DATE
,25571.0,DATE
,25570.0,VARCMP_GT
);
6557 VARCMP(DATE
,25570.0,EMPTY
,0,VARCMP_GT
);
6558 VARCMP(DATE
,25570.0,NULL_
,0,VARCMP_NULL
);
6560 /* R4 precision handling */
6561 VARCMP(R4
,1,R8
,1+1e-8,VARCMP_EQ
);
6562 VARCMP(R8
,1+1e-8,R4
,1,VARCMP_EQ
);
6563 VARCMP(R8
,1+1e-8,R8
,1,VARCMP_GT
);
6564 VARCMP(R8
,R4_MAX
*1.1,R4
,R4_MAX
,VARCMP_GT
);
6565 VARCMP(R4
,R4_MAX
,R8
,R8_MAX
,VARCMP_LT
);
6566 VARCMP(R4
,1,DATE
,1+1e-8,VARCMP_EQ
);
6567 VARCMP(R4
,1,BSTR
,bstr1few
,VARCMP_LT
); /* bstr1few == 1+1e-8 */
6568 setdec(&dec
,8,0,0,0x5F5E101); /* 1+1e-8 */
6569 VARCMP(R4
,1,DECIMAL
,dec
,VARCMP_LT
);
6571 SysFreeString(bstrhuh
);
6572 SysFreeString(bstrempty
);
6573 SysFreeString(bstr0
);
6574 SysFreeString(bstr1
);
6575 SysFreeString(bstr7
);
6576 SysFreeString(bstr42
);
6577 SysFreeString(bstr1neg
);
6578 SysFreeString(bstr666neg
);
6579 SysFreeString(bstr2cents
);
6580 SysFreeString(bstr1few
);
6583 static HRESULT (WINAPI
*pVarPow
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
6585 #define VARPOW(vt1,val1,vt2,val2,rvt,rval) \
6586 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
6587 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
6588 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
6589 test_var_call2( __LINE__, pVarPow, &left, &right, &exp )
6591 /* Skip any type that is not defined or produces an error for every case */
6592 #define SKIPTESTPOW(a) \
6593 if (a == VT_ERROR || a == VT_VARIANT || \
6594 a == VT_DISPATCH || a == VT_UNKNOWN || \
6595 a == VT_RECORD || a > VT_UINT || \
6596 a == 15 /*not defined*/) \
6599 static void test_VarPow(void)
6601 static const WCHAR str2
[] = { '2','\0' };
6602 static const WCHAR str3
[] = { '3','\0' };
6603 VARIANT left
, right
, exp
, result
, cy
, dec
;
6604 BSTR num2_str
, num3_str
;
6610 num2_str
= SysAllocString(str2
);
6611 num3_str
= SysAllocString(str3
);
6613 /* Test all possible flag/vt combinations & the resulting vt type */
6614 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
6616 VARTYPE leftvt
, rightvt
, resvt
;
6618 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
6620 SKIPTESTPOW(leftvt
);
6622 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
6625 SKIPTESTPOW(rightvt
);
6627 /* Native crashes with VT_BYREF */
6628 if (ExtraFlags
[i
] == VT_BYREF
)
6631 memset(&left
, 0, sizeof(left
));
6632 memset(&right
, 0, sizeof(right
));
6633 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
6634 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
6635 V_VT(&result
) = VT_EMPTY
;
6638 if (leftvt
== VT_BSTR
)
6639 V_BSTR(&left
) = num2_str
;
6640 if (rightvt
== VT_BSTR
)
6641 V_BSTR(&right
) = num2_str
;
6643 /* Native VarPow always returns an error when using extra flags */
6644 if (ExtraFlags
[i
] != 0)
6647 /* Determine return type */
6648 else if ((leftvt
== VT_NULL
|| rightvt
== VT_NULL
) &&
6649 ((leftvt
!= VT_I8
&& leftvt
!= VT_UI8
&&
6650 rightvt
!= VT_I8
&& rightvt
!= VT_UI8
) || HAVE_OLEAUT32_I8
))
6652 else if ((leftvt
== VT_EMPTY
|| leftvt
== VT_I2
||
6653 leftvt
== VT_I4
|| leftvt
== VT_R4
||
6654 leftvt
== VT_R8
|| leftvt
== VT_CY
||
6655 leftvt
== VT_DATE
|| leftvt
== VT_BSTR
||
6656 leftvt
== VT_BOOL
|| leftvt
== VT_DECIMAL
||
6657 (leftvt
>= VT_I1
&& leftvt
<= VT_UI4
) ||
6658 (HAVE_OLEAUT32_I8
&& (leftvt
== VT_I8
|| leftvt
== VT_UI8
)) ||
6659 leftvt
== VT_INT
|| leftvt
== VT_UINT
) &&
6660 (rightvt
== VT_EMPTY
|| rightvt
== VT_I2
||
6661 rightvt
== VT_I4
|| rightvt
== VT_R4
||
6662 rightvt
== VT_R8
|| rightvt
== VT_CY
||
6663 rightvt
== VT_DATE
|| rightvt
== VT_BSTR
||
6664 rightvt
== VT_BOOL
|| rightvt
== VT_DECIMAL
||
6665 (rightvt
>= VT_I1
&& rightvt
<= VT_UI4
) ||
6666 (HAVE_OLEAUT32_I8
&& (rightvt
== VT_I8
|| rightvt
== VT_UI8
)) ||
6667 rightvt
== VT_INT
|| rightvt
== VT_UINT
))
6672 hres
= pVarPow(&left
, &right
, &result
);
6674 /* Check expected HRESULT and if result variant type is correct */
6676 ok (hres
== DISP_E_BADVARTYPE
|| hres
== DISP_E_TYPEMISMATCH
,
6677 "VarPow: %s|0x%X, %s|0x%X: got vt %s hr 0x%X\n",
6678 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
],
6679 vtstr(V_VT(&result
)), hres
);
6681 ok (hres
== S_OK
&& resvt
== V_VT(&result
),
6682 "VarPow: %s|0x%X, %s|0x%X: expected vt %s hr 0x%X, got vt %s hr 0x%X\n",
6683 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
], vtstr(resvt
),
6684 S_OK
, vtstr(V_VT(&result
)), hres
);
6689 /* Check return values for valid variant type combinations */
6690 VARPOW(EMPTY
,0,EMPTY
,0,R8
,1.0);
6691 VARPOW(EMPTY
,0,NULL
,0,NULL
,0);
6692 VARPOW(EMPTY
,0,I2
,3,R8
,0.0);
6693 VARPOW(EMPTY
,0,I4
,3,R8
,0.0);
6694 VARPOW(EMPTY
,0,R4
,3.0f
,R8
,0.0);
6695 VARPOW(EMPTY
,0,R8
,3.0,R8
,0.0);
6696 VARPOW(EMPTY
,0,DATE
,3,R8
,0.0);
6697 VARPOW(EMPTY
,0,BSTR
,num3_str
,R8
,0.0);
6698 VARPOW(EMPTY
,0,BOOL
,VARIANT_FALSE
,R8
,1.0);
6699 VARPOW(EMPTY
,0,I1
,3,R8
,0.0);
6700 VARPOW(EMPTY
,0,UI1
,3,R8
,0.0);
6701 VARPOW(EMPTY
,0,UI2
,3,R8
,0.0);
6702 VARPOW(EMPTY
,0,UI4
,3,R8
,0.0);
6703 if (HAVE_OLEAUT32_I8
)
6705 VARPOW(EMPTY
,0,I8
,3,R8
,0.0);
6706 VARPOW(EMPTY
,0,UI8
,3,R8
,0.0);
6708 VARPOW(EMPTY
,0,INT
,3,R8
,0.0);
6709 VARPOW(EMPTY
,0,UINT
,3,R8
,0.0);
6710 VARPOW(NULL
,0,EMPTY
,0,NULL
,0);
6711 VARPOW(NULL
,0,NULL
,0,NULL
,0);
6712 VARPOW(NULL
,0,I2
,3,NULL
,0);
6713 VARPOW(NULL
,0,I4
,3,NULL
,0);
6714 VARPOW(NULL
,0,R4
,3.0f
,NULL
,0);
6715 VARPOW(NULL
,0,R8
,3.0,NULL
,0);
6716 VARPOW(NULL
,0,DATE
,3,NULL
,0);
6717 VARPOW(NULL
,0,BSTR
,num3_str
,NULL
,0);
6718 VARPOW(NULL
,0,BOOL
,VARIANT_TRUE
,NULL
,0);
6719 VARPOW(NULL
,0,I1
,3,NULL
,0);
6720 VARPOW(NULL
,0,UI1
,3,NULL
,0);
6721 VARPOW(NULL
,0,UI2
,3,NULL
,0);
6722 VARPOW(NULL
,0,UI4
,3,NULL
,0);
6723 if (HAVE_OLEAUT32_I8
)
6725 VARPOW(NULL
,0,I8
,3,NULL
,0);
6726 VARPOW(NULL
,0,UI8
,3,NULL
,0);
6728 VARPOW(NULL
,0,INT
,3,NULL
,0);
6729 VARPOW(NULL
,0,UINT
,3,NULL
,0);
6730 VARPOW(I2
,2,EMPTY
,0,R8
,1.0);
6731 VARPOW(I2
,2,NULL
,0,NULL
,0);
6732 VARPOW(I2
,2,I2
,3,R8
,8.0);
6733 VARPOW(I2
,2,I4
,3,R8
,8.0);
6734 VARPOW(I2
,2,R4
,3.0f
,R8
,8.0);
6735 VARPOW(I2
,2,R8
,3.0,R8
,8.0);
6736 VARPOW(I2
,2,DATE
,3,R8
,8.0);
6737 VARPOW(I2
,2,BSTR
,num3_str
,R8
,8.0);
6738 VARPOW(I2
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6739 VARPOW(I2
,2,I1
,3,R8
,8.0);
6740 VARPOW(I2
,2,UI1
,3,R8
,8.0);
6741 VARPOW(I2
,2,UI2
,3,R8
,8.0);
6742 VARPOW(I2
,2,UI4
,3,R8
,8.0);
6743 if (HAVE_OLEAUT32_I8
)
6745 VARPOW(I2
,2,I8
,3,R8
,8.0);
6746 VARPOW(I2
,2,UI8
,3,R8
,8.0);
6748 VARPOW(I2
,2,INT
,3,R8
,8.0);
6749 VARPOW(I2
,2,UINT
,3,R8
,8.0);
6750 VARPOW(I4
,2,EMPTY
,0,R8
,1.0);
6751 VARPOW(I4
,2,NULL
,0,NULL
,0);
6752 VARPOW(I4
,2,I2
,3,R8
,8.0);
6753 VARPOW(I4
,2,I4
,3,R8
,8.0);
6754 VARPOW(I4
,2,R4
,3.0f
,R8
,8.0);
6755 VARPOW(I4
,2,R8
,3.0,R8
,8.0);
6756 VARPOW(I4
,2,DATE
,3,R8
,8.0);
6757 VARPOW(I4
,2,BSTR
,num3_str
,R8
,8.0);
6758 VARPOW(I4
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6759 VARPOW(I4
,2,I1
,3,R8
,8.0);
6760 VARPOW(I4
,2,UI1
,3,R8
,8.0);
6761 VARPOW(I4
,2,UI2
,3,R8
,8.0);
6762 VARPOW(I4
,2,UI4
,3,R8
,8.0);
6763 if (HAVE_OLEAUT32_I8
)
6765 VARPOW(I4
,2,I8
,3,R8
,8.0);
6766 VARPOW(I4
,2,UI8
,3,R8
,8.0);
6768 VARPOW(I4
,2,INT
,3,R8
,8.0);
6769 VARPOW(I4
,2,UINT
,3,R8
,8.0);
6770 VARPOW(R4
,2,EMPTY
,0,R8
,1.0);
6771 VARPOW(R4
,2,NULL
,0,NULL
,0);
6772 VARPOW(R4
,2,I2
,3,R8
,8.0);
6773 VARPOW(R4
,2,I4
,3,R8
,8.0);
6774 VARPOW(R4
,2,R4
,3.0f
,R8
,8.0);
6775 VARPOW(R4
,2,R8
,3.0,R8
,8.0);
6776 VARPOW(R4
,2,DATE
,3,R8
,8.0);
6777 VARPOW(R4
,2,BSTR
,num3_str
,R8
,8.0);
6778 VARPOW(R4
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6779 VARPOW(R4
,2,I1
,3,R8
,8.0);
6780 VARPOW(R4
,2,UI1
,3,R8
,8.0);
6781 VARPOW(R4
,2,UI2
,3,R8
,8.0);
6782 VARPOW(R4
,2,UI4
,3,R8
,8.0);
6783 if (HAVE_OLEAUT32_I8
)
6785 VARPOW(R4
,2,I8
,3,R8
,8.0);
6786 VARPOW(R4
,2,UI8
,3,R8
,8.0);
6788 VARPOW(R4
,2,INT
,3,R8
,8.0);
6789 VARPOW(R4
,2,UINT
,3,R8
,8.0);
6790 VARPOW(R8
,2,EMPTY
,0,R8
,1.0);
6791 VARPOW(R8
,2,NULL
,0,NULL
,0);
6792 VARPOW(R8
,2,I2
,3,R8
,8.0);
6793 VARPOW(R8
,2,I4
,3,R8
,8.0);
6794 VARPOW(R8
,2,R4
,3.0f
,R8
,8.0);
6795 VARPOW(R8
,2,R8
,3.0,R8
,8.0);
6796 VARPOW(R8
,2,DATE
,3,R8
,8.0);
6797 VARPOW(R8
,2,BSTR
,num3_str
,R8
,8.0);
6798 VARPOW(R8
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6799 VARPOW(R8
,2,I1
,3,R8
,8.0);
6800 VARPOW(R8
,2,UI1
,3,R8
,8.0);
6801 VARPOW(R8
,2,UI2
,3,R8
,8.0);
6802 VARPOW(R8
,2,UI4
,3,R8
,8.0);
6803 if (HAVE_OLEAUT32_I8
)
6805 VARPOW(R8
,2,I8
,3,R8
,8.0);
6806 VARPOW(R8
,2,UI8
,3,R8
,8.0);
6808 VARPOW(R8
,2,INT
,3,R8
,8.0);
6809 VARPOW(R8
,2,UINT
,3,R8
,8.0);
6810 VARPOW(DATE
,2,EMPTY
,0,R8
,1.0);
6811 VARPOW(DATE
,2,NULL
,0,NULL
,0);
6812 VARPOW(DATE
,2,I2
,3,R8
,8.0);
6813 VARPOW(DATE
,2,I4
,3,R8
,8.0);
6814 VARPOW(DATE
,2,R4
,3.0f
,R8
,8.0);
6815 VARPOW(DATE
,2,R8
,3.0,R8
,8.0);
6816 VARPOW(DATE
,2,DATE
,3,R8
,8.0);
6817 VARPOW(DATE
,2,BSTR
,num3_str
,R8
,8.0);
6818 VARPOW(DATE
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6819 VARPOW(DATE
,2,I1
,3,R8
,8.0);
6820 VARPOW(DATE
,2,UI1
,3,R8
,8.0);
6821 VARPOW(DATE
,2,UI2
,3,R8
,8.0);
6822 VARPOW(DATE
,2,UI4
,3,R8
,8.0);
6823 if (HAVE_OLEAUT32_I8
)
6825 VARPOW(DATE
,2,I8
,3,R8
,8.0);
6826 VARPOW(DATE
,2,UI8
,3,R8
,8.0);
6828 VARPOW(DATE
,2,INT
,3,R8
,8.0);
6829 VARPOW(DATE
,2,UINT
,3,R8
,8.0);
6830 VARPOW(BSTR
,num2_str
,EMPTY
,0,R8
,1.0);
6831 VARPOW(BSTR
,num2_str
,NULL
,0,NULL
,0);
6832 VARPOW(BSTR
,num2_str
,I2
,3,R8
,8.0);
6833 VARPOW(BSTR
,num2_str
,I4
,3,R8
,8.0);
6834 VARPOW(BSTR
,num2_str
,R4
,3.0f
,R8
,8.0);
6835 VARPOW(BSTR
,num2_str
,R8
,3.0,R8
,8.0);
6836 VARPOW(BSTR
,num2_str
,DATE
,3,R8
,8.0);
6837 VARPOW(BSTR
,num2_str
,BSTR
,num3_str
,R8
,8.0);
6838 VARPOW(BSTR
,num2_str
,BOOL
,VARIANT_FALSE
,R8
,1.0);
6839 VARPOW(BSTR
,num2_str
,I1
,3,R8
,8.0);
6840 VARPOW(BSTR
,num2_str
,UI1
,3,R8
,8.0);
6841 VARPOW(BSTR
,num2_str
,UI2
,3,R8
,8.0);
6842 VARPOW(BSTR
,num2_str
,UI4
,3,R8
,8.0);
6843 if (HAVE_OLEAUT32_I8
)
6845 VARPOW(BSTR
,num2_str
,I8
,3,R8
,8.0);
6846 VARPOW(BSTR
,num2_str
,UI8
,3,R8
,8.0);
6848 VARPOW(BSTR
,num2_str
,INT
,3,R8
,8.0);
6849 VARPOW(BSTR
,num2_str
,UINT
,3,R8
,8.0);
6850 VARPOW(BOOL
,VARIANT_TRUE
,EMPTY
,0,R8
,1.0);
6851 VARPOW(BOOL
,VARIANT_TRUE
,NULL
,0,NULL
,0);
6852 VARPOW(BOOL
,VARIANT_TRUE
,I2
,3,R8
,-1.0);
6853 VARPOW(BOOL
,VARIANT_TRUE
,I4
,3,R8
,-1.0);
6854 VARPOW(BOOL
,VARIANT_TRUE
,R4
,3.0f
,R8
,-1.0);
6855 VARPOW(BOOL
,VARIANT_TRUE
,R8
,3.0,R8
,-1.0);
6856 VARPOW(BOOL
,VARIANT_TRUE
,DATE
,3,R8
,-1.0);
6857 VARPOW(BOOL
,VARIANT_TRUE
,BSTR
,num3_str
,R8
,-1.0);
6858 VARPOW(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
,R8
,-1.0);
6859 VARPOW(BOOL
,VARIANT_TRUE
,I1
,3,R8
,-1.0);
6860 VARPOW(BOOL
,VARIANT_TRUE
,UI1
,3,R8
,-1.0);
6861 VARPOW(BOOL
,VARIANT_TRUE
,UI2
,3,R8
,-1.0);
6862 VARPOW(BOOL
,VARIANT_TRUE
,UI4
,3,R8
,-1.0);
6863 if (HAVE_OLEAUT32_I8
)
6865 VARPOW(BOOL
,VARIANT_TRUE
,I8
,3,R8
,-1.0);
6866 VARPOW(BOOL
,VARIANT_TRUE
,UI8
,3,R8
,-1.0);
6868 VARPOW(BOOL
,VARIANT_TRUE
,INT
,3,R8
,-1.0);
6869 VARPOW(BOOL
,VARIANT_TRUE
,UINT
,3,R8
,-1.0);
6870 VARPOW(I1
,2,EMPTY
,0,R8
,1.0);
6871 VARPOW(I1
,2,NULL
,0,NULL
,0);
6872 VARPOW(I1
,2,I2
,3,R8
,8.0);
6873 VARPOW(I1
,2,I4
,3,R8
,8.0);
6874 VARPOW(I1
,2,R4
,3.0f
,R8
,8.0);
6875 VARPOW(I1
,2,R8
,3.0,R8
,8.0);
6876 VARPOW(I1
,2,DATE
,3,R8
,8.0);
6877 VARPOW(I1
,2,BSTR
,num3_str
,R8
,8.0);
6878 VARPOW(I1
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6879 VARPOW(I1
,2,I1
,3,R8
,8.0);
6880 VARPOW(I1
,2,UI1
,3,R8
,8.0);
6881 VARPOW(I1
,2,UI2
,3,R8
,8.0);
6882 VARPOW(I1
,2,UI4
,3,R8
,8.0);
6883 if (HAVE_OLEAUT32_I8
)
6885 VARPOW(I1
,2,I8
,3,R8
,8.0);
6886 VARPOW(I1
,2,UI8
,3,R8
,8.0);
6888 VARPOW(I1
,2,INT
,3,R8
,8.0);
6889 VARPOW(I1
,2,UINT
,3,R8
,8.0);
6890 VARPOW(UI1
,2,EMPTY
,0,R8
,1.0);
6891 VARPOW(UI1
,2,NULL
,0,NULL
,0);
6892 VARPOW(UI1
,2,I2
,3,R8
,8.0);
6893 VARPOW(UI1
,2,I4
,3,R8
,8.0);
6894 VARPOW(UI1
,2,R4
,3.0f
,R8
,8.0);
6895 VARPOW(UI1
,2,R8
,3.0,R8
,8.0);
6896 VARPOW(UI1
,2,DATE
,3,R8
,8.0);
6897 VARPOW(UI1
,2,BSTR
,num3_str
,R8
,8.0);
6898 VARPOW(UI1
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6899 VARPOW(UI1
,2,I1
,3,R8
,8.0);
6900 VARPOW(UI1
,2,UI1
,3,R8
,8.0);
6901 VARPOW(UI1
,2,UI2
,3,R8
,8.0);
6902 VARPOW(UI1
,2,UI4
,3,R8
,8.0);
6903 if (HAVE_OLEAUT32_I8
)
6905 VARPOW(UI1
,2,I8
,3,R8
,8.0);
6906 VARPOW(UI1
,2,UI8
,3,R8
,8.0);
6908 VARPOW(UI1
,2,INT
,3,R8
,8.0);
6909 VARPOW(UI1
,2,UINT
,3,R8
,8.0);
6910 VARPOW(UI2
,2,EMPTY
,0,R8
,1.0);
6911 VARPOW(UI2
,2,NULL
,0,NULL
,0);
6912 VARPOW(UI2
,2,I2
,3,R8
,8.0);
6913 VARPOW(UI2
,2,I4
,3,R8
,8.0);
6914 VARPOW(UI2
,2,R4
,3.0f
,R8
,8.0);
6915 VARPOW(UI2
,2,R8
,3.0,R8
,8.0);
6916 VARPOW(UI2
,2,DATE
,3,R8
,8.0);
6917 VARPOW(UI2
,2,BSTR
,num3_str
,R8
,8.0);
6918 VARPOW(UI2
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6919 VARPOW(UI2
,2,I1
,3,R8
,8.0);
6920 VARPOW(UI2
,2,UI1
,3,R8
,8.0);
6921 VARPOW(UI2
,2,UI2
,3,R8
,8.0);
6922 VARPOW(UI2
,2,UI4
,3,R8
,8.0);
6923 if (HAVE_OLEAUT32_I8
)
6925 VARPOW(UI2
,2,I8
,3,R8
,8.0);
6926 VARPOW(UI2
,2,UI8
,3,R8
,8.0);
6928 VARPOW(UI2
,2,INT
,3,R8
,8.0);
6929 VARPOW(UI2
,2,UINT
,3,R8
,8.0);
6930 VARPOW(UI4
,2,EMPTY
,0,R8
,1.0);
6931 VARPOW(UI4
,2,NULL
,0,NULL
,0);
6932 VARPOW(UI4
,2,I2
,3,R8
,8.0);
6933 VARPOW(UI4
,2,I4
,3,R8
,8.0);
6934 VARPOW(UI4
,2,R4
,3.0f
,R8
,8.0);
6935 VARPOW(UI4
,2,R8
,3.0,R8
,8.0);
6936 VARPOW(UI4
,2,DATE
,3,R8
,8.0);
6937 VARPOW(UI4
,2,BSTR
,num3_str
,R8
,8.0);
6938 VARPOW(UI4
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6939 VARPOW(UI4
,2,I1
,3,R8
,8.0);
6940 VARPOW(UI4
,2,UI1
,3,R8
,8.0);
6941 VARPOW(UI4
,2,UI2
,3,R8
,8.0);
6942 VARPOW(UI4
,2,UI4
,3,R8
,8.0);
6943 if (HAVE_OLEAUT32_I8
)
6945 VARPOW(UI4
,2,I8
,3,R8
,8.0);
6946 VARPOW(UI4
,2,UI8
,3,R8
,8.0);
6948 VARPOW(UI4
,2,INT
,3,R8
,8.0);
6949 VARPOW(UI4
,2,UINT
,3,R8
,8.0);
6950 if (HAVE_OLEAUT32_I8
)
6952 VARPOW(I8
,2,EMPTY
,0,R8
,1.0);
6953 VARPOW(I8
,2,NULL
,0,NULL
,0);
6954 VARPOW(I8
,2,I2
,3,R8
,8.0);
6955 VARPOW(I8
,2,I4
,3,R8
,8.0);
6956 VARPOW(I8
,2,R4
,3.0f
,R8
,8.0);
6957 VARPOW(I8
,2,R8
,3.0,R8
,8.0);
6958 VARPOW(I8
,2,DATE
,3,R8
,8.0);
6959 VARPOW(I8
,2,BSTR
,num3_str
,R8
,8.0);
6960 VARPOW(I8
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6961 VARPOW(I8
,2,I1
,3,R8
,8.0);
6962 VARPOW(I8
,2,UI1
,3,R8
,8.0);
6963 VARPOW(I8
,2,UI2
,3,R8
,8.0);
6964 VARPOW(I8
,2,UI4
,3,R8
,8.0);
6965 VARPOW(I8
,2,I8
,3,R8
,8.0);
6966 VARPOW(I8
,2,UI8
,3,R8
,8.0);
6967 VARPOW(I8
,2,INT
,3,R8
,8.0);
6968 VARPOW(I8
,2,UINT
,3,R8
,8.0);
6969 VARPOW(UI8
,2,EMPTY
,0,R8
,1.0);
6970 VARPOW(UI8
,2,NULL
,0,NULL
,0);
6971 VARPOW(UI8
,2,I2
,3,R8
,8.0);
6972 VARPOW(UI8
,2,I4
,3,R8
,8.0);
6973 VARPOW(UI8
,2,R4
,3.0f
,R8
,8.0);
6974 VARPOW(UI8
,2,R8
,3.0,R8
,8.0);
6975 VARPOW(UI8
,2,DATE
,3,R8
,8.0);
6976 VARPOW(UI8
,2,BSTR
,num3_str
,R8
,8.0);
6977 VARPOW(UI8
,2,I1
,3,R8
,8.0);
6978 VARPOW(UI8
,2,UI1
,3,R8
,8.0);
6979 VARPOW(UI8
,2,UI2
,3,R8
,8.0);
6980 VARPOW(UI8
,2,UI4
,3,R8
,8.0);
6981 VARPOW(UI8
,2,I8
,3,R8
,8.0);
6982 VARPOW(UI8
,2,UI8
,3,R8
,8.0);
6983 VARPOW(UI8
,2,INT
,3,R8
,8.0);
6984 VARPOW(UI8
,2,UINT
,3,R8
,8.0);
6986 VARPOW(INT
,2,EMPTY
,0,R8
,1.0);
6987 VARPOW(INT
,2,NULL
,0,NULL
,0);
6988 VARPOW(INT
,2,I2
,3,R8
,8.0);
6989 VARPOW(INT
,2,I4
,3,R8
,8.0);
6990 VARPOW(INT
,2,R4
,3.0f
,R8
,8.0);
6991 VARPOW(INT
,2,R8
,3.0,R8
,8.0);
6992 VARPOW(INT
,2,DATE
,3,R8
,8.0);
6993 VARPOW(INT
,2,BSTR
,num3_str
,R8
,8.0);
6994 VARPOW(INT
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
6995 VARPOW(INT
,2,I1
,3,R8
,8.0);
6996 VARPOW(INT
,2,UI1
,3,R8
,8.0);
6997 VARPOW(INT
,2,UI2
,3,R8
,8.0);
6998 VARPOW(INT
,2,UI4
,3,R8
,8.0);
6999 if (HAVE_OLEAUT32_I8
)
7001 VARPOW(INT
,2,I8
,3,R8
,8.0);
7002 VARPOW(INT
,2,UI8
,3,R8
,8.0);
7004 VARPOW(INT
,2,INT
,3,R8
,8.0);
7005 VARPOW(INT
,2,UINT
,3,R8
,8.0);
7006 VARPOW(UINT
,2,EMPTY
,0,R8
,1.0);
7007 VARPOW(UINT
,2,NULL
,0,NULL
,0);
7008 VARPOW(UINT
,2,I2
,3,R8
,8.0);
7009 VARPOW(UINT
,2,I4
,3,R8
,8.0);
7010 VARPOW(UINT
,2,R4
,3.0f
,R8
,8.0);
7011 VARPOW(UINT
,2,R8
,3.0,R8
,8.0);
7012 VARPOW(UINT
,2,DATE
,3,R8
,8.0);
7013 VARPOW(UINT
,2,BSTR
,num3_str
,R8
,8.0);
7014 VARPOW(UINT
,2,BOOL
,VARIANT_FALSE
,R8
,1.0);
7015 VARPOW(UINT
,2,I1
,3,R8
,8.0);
7016 VARPOW(UINT
,2,UI1
,3,R8
,8.0);
7017 VARPOW(UINT
,2,UI2
,3,R8
,8.0);
7018 VARPOW(UINT
,2,UI4
,3,R8
,8.0);
7019 if (HAVE_OLEAUT32_I8
)
7021 VARPOW(UINT
,2,I8
,3,R8
,8.0);
7022 VARPOW(UINT
,2,UI8
,3,R8
,8.0);
7024 VARPOW(UINT
,2,INT
,3,R8
,8.0);
7025 VARPOW(UINT
,2,UINT
,3,R8
,8.0);
7027 /* Manually test some VT_CY, VT_DECIMAL variants */
7029 hres
= VarCyFromI4(2, &V_CY(&cy
));
7030 ok(hres
== S_OK
, "VarCyFromI4 failed!\n");
7031 V_VT(&dec
) = VT_DECIMAL
;
7032 hres
= VarDecFromR8(2.0, &V_DECIMAL(&dec
));
7033 ok(hres
== S_OK
, "VarDecFromR4 failed!\n");
7034 memset(&left
, 0, sizeof(left
));
7035 memset(&right
, 0, sizeof(right
));
7036 V_VT(&left
) = VT_I4
;
7038 V_VT(&right
) = VT_I8
;
7041 hres
= pVarPow(&cy
, &cy
, &result
);
7042 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
7043 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
7044 S_OK
, hres
, vtstr(V_VT(&result
)));
7045 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 4.0),
7046 "VARPOW: CY value %f, expected %f\n", V_R8(&result
), 4.0);
7048 hres
= pVarPow(&cy
, &right
, &result
);
7051 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
7052 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
7053 S_OK
, hres
, vtstr(V_VT(&result
)));
7054 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 4.0),
7055 "VARPOW: CY value %f, expected %f\n", V_R8(&result
), 4.0);
7059 ok(hres
== DISP_E_BADVARTYPE
&& V_VT(&result
) == VT_EMPTY
,
7060 "VARPOW: expected coerced hres 0x%X type VT_EMPTY, got hres 0x%X type %s!\n",
7061 DISP_E_BADVARTYPE
, hres
, vtstr(V_VT(&result
)));
7064 hres
= pVarPow(&left
, &cy
, &result
);
7065 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
7066 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
7067 S_OK
, hres
, vtstr(V_VT(&result
)));
7068 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 10000.0),
7069 "VARPOW: CY value %f, expected %f\n", V_R8(&result
), 10000.0);
7071 hres
= pVarPow(&left
, &dec
, &result
);
7072 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
7073 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
7074 S_OK
, hres
, vtstr(V_VT(&result
)));
7075 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
),10000.0),
7076 "VARPOW: DECIMAL value %f, expected %f\n", V_R8(&result
), 10000.0);
7078 hres
= pVarPow(&dec
, &dec
, &result
);
7079 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
7080 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
7081 S_OK
, hres
, vtstr(V_VT(&result
)));
7082 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 4.0),
7083 "VARPOW: DECIMAL value %f, expected %f\n", V_R8(&result
), 4.0);
7085 hres
= pVarPow(&dec
, &right
, &result
);
7088 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
7089 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
7090 S_OK
, hres
, vtstr(V_VT(&result
)));
7091 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 4.0),
7092 "VARPOW: DECIMAL value %f, expected %f\n", V_R8(&result
), 4.0);
7096 ok(hres
== DISP_E_BADVARTYPE
&& V_VT(&result
) == VT_EMPTY
,
7097 "VARPOW: expected coerced hres 0x%X type VT_EMPTY, got hres 0x%X type %s!\n",
7098 DISP_E_BADVARTYPE
, hres
, vtstr(V_VT(&result
)));
7101 SysFreeString(num2_str
);
7102 SysFreeString(num3_str
);
7105 static HRESULT (WINAPI
*pVarDiv
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
7107 #define VARDIV(vt1,val1,vt2,val2,rvt,rval) \
7108 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
7109 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
7110 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
7111 test_var_call2( __LINE__, pVarDiv, &left, &right, &exp )
7113 /* Skip any type that is not defined or produces an error for every case */
7114 #define SKIPTESTDIV(a) \
7115 if (a == VT_ERROR || a == VT_VARIANT || \
7116 a == VT_DISPATCH || a == VT_UNKNOWN || \
7117 a == VT_RECORD || a > VT_UINT || \
7118 a == VT_I1 || a == VT_UI8 || \
7119 a == VT_INT || a == VT_UINT || \
7120 a == VT_UI2 || a == VT_UI4 || \
7121 a == 15 /*not defined*/) \
7124 static void test_VarDiv(void)
7126 static const WCHAR str1
[] = { '1','\0' };
7127 static const WCHAR str2
[] = { '2','\0' };
7128 VARIANT left
, right
, exp
, result
, cy
, dec
;
7129 BSTR num1_str
, num2_str
;
7134 num1_str
= SysAllocString(str1
);
7135 num2_str
= SysAllocString(str2
);
7139 /* Test all possible flag/vt combinations & the resulting vt type */
7140 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
7142 VARTYPE leftvt
, rightvt
, resvt
;
7144 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
7146 SKIPTESTDIV(leftvt
);
7148 /* Check if we need/have support for I8 */
7149 if (leftvt
== VT_I8
&& !HAVE_OLEAUT32_I8
)
7152 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
7155 SKIPTESTDIV(rightvt
);
7157 /* Check if we need/have support for I8 */
7158 if (rightvt
== VT_I8
&& !HAVE_OLEAUT32_I8
)
7161 /* Native crashes with VT_BYREF */
7162 if (ExtraFlags
[i
] == VT_BYREF
)
7165 memset(&left
, 0, sizeof(left
));
7166 memset(&right
, 0, sizeof(right
));
7167 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
7168 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
7169 V_VT(&result
) = VT_EMPTY
;
7172 if (leftvt
== VT_BSTR
)
7173 V_BSTR(&left
) = num2_str
;
7174 else if (leftvt
== VT_DECIMAL
)
7176 VarDecFromR8(2.0, &V_DECIMAL(&left
));
7177 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
7180 /* Division by 0 is undefined */
7184 V_BSTR(&right
) = num2_str
;
7187 VarDecFromR8(2.0, &V_DECIMAL(&right
));
7188 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
7191 V_BOOL(&right
) = VARIANT_TRUE
;
7193 case VT_I2
: V_I2(&right
) = 2; break;
7194 case VT_I4
: V_I4(&right
) = 2; break;
7195 case VT_R4
: V_R4(&right
) = 2.0f
; break;
7196 case VT_R8
: V_R8(&right
) = 2.0; break;
7197 case VT_CY
: V_CY(&right
).int64
= 2; break;
7198 case VT_DATE
: V_DATE(&right
) = 2; break;
7199 case VT_UI1
: V_UI1(&right
) = 2; break;
7200 case VT_I8
: V_I8(&right
) = 2; break;
7204 /* Determine return type */
7205 if (!(rightvt
== VT_EMPTY
))
7207 if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
7209 else if (leftvt
== VT_DECIMAL
|| rightvt
== VT_DECIMAL
)
7211 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
||
7212 leftvt
== VT_CY
|| rightvt
== VT_CY
||
7213 leftvt
== VT_DATE
|| rightvt
== VT_DATE
||
7214 leftvt
== VT_I4
|| rightvt
== VT_I4
||
7215 leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
||
7216 leftvt
== VT_I2
|| rightvt
== VT_I2
||
7217 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
||
7218 leftvt
== VT_R8
|| rightvt
== VT_R8
||
7219 leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
7221 if ((leftvt
== VT_UI1
&& rightvt
== VT_R4
) ||
7222 (leftvt
== VT_R4
&& rightvt
== VT_UI1
))
7224 else if ((leftvt
== VT_R4
&& (rightvt
== VT_BOOL
||
7225 rightvt
== VT_I2
)) || (rightvt
== VT_R4
&&
7226 (leftvt
== VT_BOOL
|| leftvt
== VT_I2
)))
7231 else if (leftvt
== VT_R4
|| rightvt
== VT_R4
)
7234 else if (leftvt
== VT_NULL
&& rightvt
== VT_EMPTY
)
7239 /* Native VarDiv always returns an error when using extra flags */
7240 if (ExtraFlags
[i
] != 0)
7243 hres
= pVarDiv(&left
, &right
, &result
);
7245 /* Check expected HRESULT and if result variant type is correct */
7247 ok (hres
== DISP_E_BADVARTYPE
|| hres
== DISP_E_TYPEMISMATCH
||
7248 hres
== DISP_E_OVERFLOW
|| hres
== DISP_E_DIVBYZERO
,
7249 "VarDiv: %s|0x%X, %s|0x%X: got vt %s hr 0x%X\n",
7250 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
],
7251 vtstr(V_VT(&result
)), hres
);
7253 ok (hres
== S_OK
&& resvt
== V_VT(&result
),
7254 "VarDiv: %s|0x%X, %s|0x%X: expected vt %s hr 0x%X, got vt %s hr 0x%X\n",
7255 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
], vtstr(resvt
),
7256 S_OK
, vtstr(V_VT(&result
)), hres
);
7261 /* Test return values for all the good cases */
7262 VARDIV(EMPTY
,0,NULL
,0,NULL
,0);
7263 VARDIV(EMPTY
,0,I2
,2,R8
,0.0);
7264 VARDIV(EMPTY
,0,I4
,2,R8
,0.0);
7265 VARDIV(EMPTY
,0,R4
,2.0f
,R4
,0.0f
);
7266 VARDIV(EMPTY
,0,R8
,2.0,R8
,0.0);
7267 VARDIV(EMPTY
,0,DATE
,2.0,R8
,0.0);
7268 VARDIV(EMPTY
,0,BSTR
,num2_str
,R8
,0.0);
7269 VARDIV(EMPTY
,0,BOOL
,VARIANT_TRUE
,R8
,0.0);
7270 VARDIV(EMPTY
,0,UI1
,2,R8
,0.0);
7271 if (HAVE_OLEAUT32_I8
)
7273 VARDIV(EMPTY
,0,I8
,2,R8
,0.0);
7275 VARDIV(NULL
,0,EMPTY
,0,NULL
,0);
7276 VARDIV(NULL
,0,NULL
,0,NULL
,0);
7277 VARDIV(NULL
,0,I2
,2,NULL
,0);
7278 VARDIV(NULL
,0,I4
,2,NULL
,0);
7279 VARDIV(NULL
,0,R4
,2.0f
,NULL
,0);
7280 VARDIV(NULL
,0,R8
,2.0,NULL
,0);
7281 VARDIV(NULL
,0,DATE
,2,NULL
,0);
7282 VARDIV(NULL
,0,BSTR
,num2_str
,NULL
,0);
7283 VARDIV(NULL
,0,BOOL
,VARIANT_TRUE
,NULL
,0);
7284 VARDIV(NULL
,0,UI1
,2,NULL
,0);
7285 if (HAVE_OLEAUT32_I8
)
7287 VARDIV(NULL
,0,I8
,2,NULL
,0);
7289 VARDIV(I2
,2,NULL
,0,NULL
,0);
7290 VARDIV(I2
,1,I2
,2,R8
,0.5);
7291 VARDIV(I2
,1,I4
,2,R8
,0.5);
7292 VARDIV(I2
,1,R4
,2,R4
,0.5f
);
7293 VARDIV(I2
,1,R8
,2.0,R8
,0.5);
7294 VARDIV(I2
,1,DATE
,2,R8
,0.5);
7295 VARDIV(I2
,1,BOOL
,VARIANT_TRUE
,R8
,-1.0);
7296 VARDIV(I2
,1,UI1
,2,R8
,0.5);
7297 if (HAVE_OLEAUT32_I8
)
7299 VARDIV(I2
,1,I8
,2,R8
,0.5);
7301 VARDIV(I4
,1,NULL
,0,NULL
,0);
7302 VARDIV(I4
,1,I2
,2,R8
,0.5);
7303 VARDIV(I4
,1,I4
,2,R8
,0.5);
7304 VARDIV(I4
,1,R4
,2.0f
,R8
,0.5);
7305 VARDIV(I4
,1,R8
,2.0,R8
,0.5);
7306 VARDIV(I4
,1,DATE
,2,R8
,0.5);
7307 VARDIV(I4
,1,BSTR
,num2_str
,R8
,0.5);
7308 VARDIV(I4
,1,BOOL
,VARIANT_TRUE
,R8
,-1.0);
7309 VARDIV(I4
,1,UI1
,2,R8
,0.5);
7310 if (HAVE_OLEAUT32_I8
)
7312 VARDIV(I4
,1,I8
,2,R8
,0.5);
7314 VARDIV(R4
,1.0f
,NULL
,0,NULL
,0);
7315 VARDIV(R4
,1.0f
,I2
,2,R4
,0.5f
);
7316 VARDIV(R4
,1.0f
,I4
,2,R8
,0.5);
7317 VARDIV(R4
,1.0f
,R4
,2.0f
,R4
,0.5f
);
7318 VARDIV(R4
,1.0f
,R8
,2.0,R8
,0.5);
7319 VARDIV(R4
,1.0f
,DATE
,2,R8
,0.5);
7320 VARDIV(R4
,1.0f
,BSTR
,num2_str
,R8
,0.5);
7321 VARDIV(R4
,1.0f
,BOOL
,VARIANT_TRUE
,R4
,-1);
7322 VARDIV(R4
,1.0f
,UI1
,2,R4
,0.5f
);
7323 if (HAVE_OLEAUT32_I8
)
7325 VARDIV(R4
,1.0f
,I8
,2,R8
,0.5);
7327 VARDIV(R8
,1.0,NULL
,0,NULL
,0);
7328 VARDIV(R8
,1.0,I2
,2,R8
,0.5);
7329 VARDIV(R8
,1.0,I4
,2,R8
,0.5);
7330 VARDIV(R8
,1.0,R4
,2.0f
,R8
,0.5);
7331 VARDIV(R8
,1.0,R8
,2.0,R8
,0.5);
7332 VARDIV(R8
,1.0,DATE
,2,R8
,0.5);
7333 VARDIV(R8
,1.0,BSTR
,num2_str
,R8
,0.5);
7334 VARDIV(R8
,1.0,BOOL
,VARIANT_TRUE
,R8
,-1.0);
7335 VARDIV(R8
,1.0,UI1
,2,R8
,0.5);
7336 if (HAVE_OLEAUT32_I8
)
7338 VARDIV(R8
,1.0,I8
,2,R8
,0.5);
7340 VARDIV(DATE
,1,NULL
,0,NULL
,0);
7341 VARDIV(DATE
,1,I2
,2,R8
,0.5);
7342 VARDIV(DATE
,1,I4
,2,R8
,0.5);
7343 VARDIV(DATE
,1,R4
,2.0f
,R8
,0.5);
7344 VARDIV(DATE
,1,R8
,2.0,R8
,0.5);
7345 VARDIV(DATE
,1,DATE
,2,R8
,0.5);
7346 VARDIV(DATE
,1,BSTR
,num2_str
,R8
,0.5);
7347 VARDIV(DATE
,1,BOOL
,VARIANT_TRUE
,R8
,-1.0);
7348 VARDIV(DATE
,1,UI1
,2,R8
,0.5);
7349 if (HAVE_OLEAUT32_I8
)
7351 VARDIV(DATE
,1,I8
,2,R8
,0.5);
7353 VARDIV(BSTR
,num1_str
,NULL
,0,NULL
,0);
7354 VARDIV(BSTR
,num1_str
,I2
,2,R8
,0.5);
7355 VARDIV(BSTR
,num1_str
,I4
,2,R8
,0.5);
7356 VARDIV(BSTR
,num1_str
,R4
,2.0f
,R8
,0.5);
7357 VARDIV(BSTR
,num1_str
,R8
,2.0,R8
,0.5);
7358 VARDIV(BSTR
,num1_str
,DATE
,2,R8
,0.5);
7359 VARDIV(BSTR
,num1_str
,BSTR
,num2_str
,R8
,0.5);
7360 VARDIV(BSTR
,num1_str
,BOOL
,VARIANT_TRUE
,R8
,-1);
7361 VARDIV(BSTR
,num1_str
,UI1
,2,R8
,0.5);
7362 if (HAVE_OLEAUT32_I8
)
7364 VARDIV(BSTR
,num1_str
,I8
,2,R8
,0.5);
7366 VARDIV(BOOL
,VARIANT_TRUE
,NULL
,0,NULL
,0);
7367 VARDIV(BOOL
,VARIANT_TRUE
,I2
,1,R8
,-1.0);
7368 VARDIV(BOOL
,VARIANT_FALSE
,I2
,1,R8
,0.0);
7369 VARDIV(BOOL
,VARIANT_TRUE
,I4
,1,R8
,-1.0);
7370 VARDIV(BOOL
,VARIANT_FALSE
,I4
,1,R8
,0.0);
7371 VARDIV(BOOL
,VARIANT_TRUE
,R4
,1,R4
,-1.0f
);
7372 VARDIV(BOOL
,VARIANT_FALSE
,R4
,1,R4
,0.0f
);
7373 VARDIV(BOOL
,VARIANT_TRUE
,R8
,1.0,R8
,-1.0);
7374 VARDIV(BOOL
,VARIANT_FALSE
,R8
,1.0,R8
,0.0);
7375 VARDIV(BOOL
,VARIANT_FALSE
,DATE
,2,R8
,0.0);
7376 VARDIV(BOOL
,VARIANT_FALSE
,BSTR
,num2_str
,R8
,0.0);
7377 VARDIV(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
,R8
,1.0);
7378 VARDIV(BOOL
,VARIANT_FALSE
,BOOL
,VARIANT_TRUE
,R8
,0.0);
7379 VARDIV(BOOL
,VARIANT_TRUE
,UI1
,1,R8
,-1.0);
7380 if (HAVE_OLEAUT32_I8
)
7382 VARDIV(BOOL
,VARIANT_TRUE
,I8
,1,R8
,-1.0);
7384 VARDIV(UI1
,1,NULL
,0,NULL
,0);
7385 VARDIV(UI1
,1,I2
,2,R8
,0.5);
7386 VARDIV(UI1
,1,I4
,2,R8
,0.5);
7387 VARDIV(UI1
,1,R4
,2.0f
,R4
,0.5f
);
7388 VARDIV(UI1
,1,R8
,2.0,R8
,0.5);
7389 VARDIV(UI1
,1,DATE
,2,R8
,0.5);
7390 VARDIV(UI1
,1,BSTR
,num2_str
,R8
,0.5);
7391 VARDIV(UI1
,1,BOOL
,VARIANT_TRUE
,R8
,-1);
7392 VARDIV(UI1
,1,UI1
,2,R8
,0.5);
7393 if (HAVE_OLEAUT32_I8
)
7395 VARDIV(UI1
,1,I8
,2,R8
,0.5);
7396 VARDIV(I8
,1,NULL
,0,NULL
,0);
7397 VARDIV(I8
,1,I2
,2,R8
,0.5);
7398 VARDIV(I8
,1,I4
,2,R8
,0.5);
7399 VARDIV(I8
,1,R4
,2.0f
,R8
,0.5);
7400 VARDIV(I8
,1,R8
,2.0,R8
,0.5);
7401 VARDIV(I8
,1,DATE
,2,R8
,0.5);
7402 VARDIV(I8
,1,BSTR
,num2_str
,R8
,0.5);
7403 VARDIV(I8
,1,BOOL
,VARIANT_TRUE
,R8
,-1);
7404 VARDIV(I8
,1,UI1
,2,R8
,0.5);
7405 VARDIV(I8
,1,I8
,2,R8
,0.5);
7408 /* Manually test some VT_CY, VT_DECIMAL variants */
7410 hres
= VarCyFromI4(10000, &V_CY(&cy
));
7411 ok(hres
== S_OK
, "VarCyFromI4 failed!\n");
7412 V_VT(&dec
) = VT_DECIMAL
;
7413 hres
= VarDecFromR8(2.0, &V_DECIMAL(&dec
));
7414 ok(hres
== S_OK
, "VarDecFromR4 failed!\n");
7415 memset(&left
, 0, sizeof(left
));
7416 memset(&right
, 0, sizeof(right
));
7417 V_VT(&left
) = VT_I4
;
7419 V_VT(&right
) = VT_UI1
;
7422 hres
= pVarDiv(&cy
, &cy
, &result
);
7423 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
7424 "VARDIV: expected coerced type VT_R8, got %s!\n", vtstr(V_VT(&result
)));
7425 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 1.0),
7426 "VARDIV: CY value %f, expected %f\n", V_R8(&result
), (double)1.0);
7428 hres
= pVarDiv(&cy
, &right
, &result
);
7429 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
7430 "VARDIV: expected coerced type VT_R8, got %s!\n", vtstr(V_VT(&result
)));
7431 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 5000.0),
7432 "VARDIV: CY value %f, expected %f\n", V_R8(&result
), (double)5000.0);
7434 hres
= pVarDiv(&left
, &cy
, &result
);
7435 ok(hres
== S_OK
&& V_VT(&result
) == VT_R8
,
7436 "VARDIV: expected coerced type VT_R8, got %s!\n", vtstr(V_VT(&result
)));
7437 ok(hres
== S_OK
&& EQ_DOUBLE(V_R8(&result
), 0.01),
7438 "VARDIV: CY value %f, expected %f\n", V_R8(&result
), (double)0.01);
7440 hres
= pVarDiv(&left
, &dec
, &result
);
7441 ok(hres
== S_OK
&& V_VT(&result
) == VT_DECIMAL
,
7442 "VARDIV: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result
)));
7443 hres
= VarR8FromDec(&V_DECIMAL(&result
), &r
);
7444 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 50.0),
7445 "VARDIV: DECIMAL value %f, expected %f\n", r
, (double)50.0);
7447 hres
= pVarDiv(&dec
, &dec
, &result
);
7448 ok(hres
== S_OK
&& V_VT(&result
) == VT_DECIMAL
,
7449 "VARDIV: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result
)));
7450 hres
= VarR8FromDec(&V_DECIMAL(&result
), &r
);
7451 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 1.0),
7452 "VARDIV: DECIMAL value %f, expected %f\n", r
, (double)1.0);
7454 hres
= pVarDiv(&dec
, &right
, &result
);
7455 ok(hres
== S_OK
&& V_VT(&result
) == VT_DECIMAL
,
7456 "VARDIV: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result
)));
7457 hres
= VarR8FromDec(&V_DECIMAL(&result
), &r
);
7458 ok(hres
== S_OK
&& EQ_DOUBLE(r
, 1.0),
7459 "VARDIV: DECIMAL value %f, expected %f\n", r
, (double)1.0);
7461 /* Check for division by zero and overflow */
7462 V_VT(&left
) = VT_R8
;
7464 V_VT(&right
) = VT_R8
;
7466 hres
= pVarDiv(&left
, &right
, &result
);
7467 ok(hres
== DISP_E_DIVBYZERO
&& V_VT(&result
) == VT_EMPTY
,
7468 "VARDIV: Division by (1.0/0.0) should result in DISP_E_DIVBYZERO but got 0x%X\n", hres
);
7470 V_VT(&left
) = VT_R8
;
7472 V_VT(&right
) = VT_R8
;
7474 hres
= pVarDiv(&left
, &right
, &result
);
7475 ok(hres
== DISP_E_OVERFLOW
&& V_VT(&result
) == VT_EMPTY
,
7476 "VARDIV: Division by (0.0/0.0) should result in DISP_E_OVERFLOW but got 0x%X\n", hres
);
7478 SysFreeString(num1_str
);
7479 SysFreeString(num2_str
);
7482 static HRESULT (WINAPI
*pVarIdiv
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
7484 #define VARIDIV(vt1,val1,vt2,val2,rvt,rval) \
7485 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
7486 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
7487 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
7488 test_var_call2( __LINE__, pVarIdiv, &left, &right, &exp )
7490 /* Skip any type that is not defined or produces an error for every case */
7491 #define SKIPTESTIDIV(a) \
7492 if (a == VT_ERROR || a == VT_VARIANT || \
7493 a == VT_DISPATCH || a == VT_UNKNOWN || \
7494 a == VT_RECORD || a > VT_UINT || \
7495 a == 15 /*not defined*/) \
7498 static void test_VarIdiv(void)
7500 static const WCHAR str1
[] = { '1','\0' };
7501 static const WCHAR str2
[] = { '2','\0' };
7502 VARIANT left
, right
, exp
, result
, cy
, dec
;
7503 BSTR num1_str
, num2_str
;
7509 num1_str
= SysAllocString(str1
);
7510 num2_str
= SysAllocString(str2
);
7512 /* Test all possible flag/vt combinations & the resulting vt type */
7513 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
7515 VARTYPE leftvt
, rightvt
, resvt
;
7517 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
7519 SKIPTESTIDIV(leftvt
);
7521 /* Check if we need/have support for I8 and/or UI8 */
7522 if ((leftvt
== VT_I8
|| leftvt
== VT_UI8
) && !HAVE_OLEAUT32_I8
)
7525 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
7528 SKIPTESTIDIV(rightvt
);
7530 /* Native crashes with extra flag VT_BYREF */
7531 if (ExtraFlags
[i
] == VT_BYREF
)
7534 /* Check if we need/have support for I8 and/or UI8 */
7535 if ((rightvt
== VT_I8
|| rightvt
== VT_UI8
) && !HAVE_OLEAUT32_I8
)
7538 memset(&left
, 0, sizeof(left
));
7539 memset(&right
, 0, sizeof(right
));
7540 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
7541 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
7542 V_VT(&result
) = VT_EMPTY
;
7545 if (leftvt
== VT_BSTR
)
7546 V_BSTR(&left
) = num2_str
;
7547 else if (leftvt
== VT_DECIMAL
)
7549 VarDecFromR8(2.0, &V_DECIMAL(&left
));
7550 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
7553 /* Division by 0 is undefined */
7557 V_BSTR(&right
) = num2_str
;
7560 VarDecFromR8(2.0, &V_DECIMAL(&right
));
7561 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
7564 V_BOOL(&right
) = VARIANT_TRUE
;
7567 VarCyFromI4(10000, &V_CY(&right
));
7568 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
7570 case VT_I2
: V_I2(&right
) = 2; break;
7571 case VT_I4
: V_I4(&right
) = 2; break;
7572 case VT_R4
: V_R4(&right
) = 2.0f
; break;
7573 case VT_R8
: V_R8(&right
) = 2.0; break;
7574 case VT_DATE
: V_DATE(&right
) = 2; break;
7575 case VT_I1
: V_I1(&right
) = 2; break;
7576 case VT_UI1
: V_UI1(&right
) = 2; break;
7577 case VT_UI2
: V_UI2(&right
) = 2; break;
7578 case VT_UI4
: V_UI4(&right
) = 2; break;
7579 case VT_I8
: V_I8(&right
) = 2; break;
7580 case VT_UI8
: V_UI8(&right
) = 2; break;
7581 case VT_INT
: V_INT(&right
) = 2; break;
7582 case VT_UINT
: V_UINT(&right
) = 2; break;
7586 /* Native VarIdiv always returns an error when using extra
7587 * flags or if the variant combination is I8 and INT.
7589 if ((leftvt
== VT_I8
&& rightvt
== VT_INT
) ||
7590 (leftvt
== VT_INT
&& rightvt
== VT_I8
) ||
7591 (rightvt
== VT_EMPTY
&& leftvt
!= VT_NULL
) ||
7595 /* Determine variant type */
7596 else if (leftvt
== VT_NULL
|| rightvt
== VT_NULL
)
7598 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
7600 else if (leftvt
== VT_I4
|| rightvt
== VT_I4
||
7601 leftvt
== VT_INT
|| rightvt
== VT_INT
||
7602 leftvt
== VT_UINT
|| rightvt
== VT_UINT
||
7603 leftvt
== VT_UI8
|| rightvt
== VT_UI8
||
7604 leftvt
== VT_UI4
|| rightvt
== VT_UI4
||
7605 leftvt
== VT_UI2
|| rightvt
== VT_UI2
||
7606 leftvt
== VT_I1
|| rightvt
== VT_I1
||
7607 leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
||
7608 leftvt
== VT_DATE
|| rightvt
== VT_DATE
||
7609 leftvt
== VT_CY
|| rightvt
== VT_CY
||
7610 leftvt
== VT_DECIMAL
|| rightvt
== VT_DECIMAL
||
7611 leftvt
== VT_R8
|| rightvt
== VT_R8
||
7612 leftvt
== VT_R4
|| rightvt
== VT_R4
)
7614 else if (leftvt
== VT_I2
|| rightvt
== VT_I2
||
7615 leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
||
7618 else if (leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
7623 hres
= pVarIdiv(&left
, &right
, &result
);
7625 /* Check expected HRESULT and if result variant type is correct */
7627 ok (hres
== DISP_E_BADVARTYPE
|| hres
== DISP_E_TYPEMISMATCH
||
7628 hres
== DISP_E_DIVBYZERO
,
7629 "VarIdiv: %s|0x%X, %s|0x%X: got vt %s hr 0x%X\n",
7630 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
],
7631 vtstr(V_VT(&result
)), hres
);
7633 ok (hres
== S_OK
&& resvt
== V_VT(&result
),
7634 "VarIdiv: %s|0x%X, %s|0x%X: expected vt %s hr 0x%X, got vt %s hr 0x%X\n",
7635 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
], vtstr(resvt
),
7636 S_OK
, vtstr(V_VT(&result
)), hres
);
7641 /* Test return values for all the good cases */
7642 VARIDIV(EMPTY
,0,NULL
,0,NULL
,0);
7643 VARIDIV(EMPTY
,0,I2
,1,I2
,0);
7644 VARIDIV(EMPTY
,0,I4
,1,I4
,0);
7645 VARIDIV(EMPTY
,0,R4
,1.0f
,I4
,0);
7646 VARIDIV(EMPTY
,0,R8
,1.0,I4
,0);
7647 VARIDIV(EMPTY
,0,DATE
,1.0,I4
,0);
7648 VARIDIV(EMPTY
,0,BSTR
,num1_str
,I4
,0);
7649 VARIDIV(EMPTY
,0,BOOL
,VARIANT_TRUE
,I2
,0);
7650 VARIDIV(EMPTY
,0,I1
,1,I4
,0);
7651 VARIDIV(EMPTY
,0,UI1
,1,I2
,0);
7652 VARIDIV(EMPTY
,0,UI2
,1,I4
,0);
7653 VARIDIV(EMPTY
,0,UI4
,1,I4
,0);
7654 if (HAVE_OLEAUT32_I8
)
7656 VARIDIV(EMPTY
,0,I8
,1,I8
,0);
7657 VARIDIV(EMPTY
,0,UI8
,1,I4
,0);
7659 VARIDIV(EMPTY
,0,INT
,1,I4
,0);
7660 VARIDIV(EMPTY
,0,UINT
,1,I4
,0);
7661 VARIDIV(NULL
,0,EMPTY
,0,NULL
,0);
7662 VARIDIV(NULL
,0,NULL
,0,NULL
,0);
7663 VARIDIV(NULL
,0,I2
,1,NULL
,0);
7664 VARIDIV(NULL
,0,I4
,1,NULL
,0);
7665 VARIDIV(NULL
,0,R4
,1,NULL
,0);
7666 VARIDIV(NULL
,0,R8
,1,NULL
,0);
7667 VARIDIV(NULL
,0,DATE
,1,NULL
,0);
7668 VARIDIV(NULL
,0,BSTR
,num1_str
,NULL
,0);
7669 VARIDIV(NULL
,0,BOOL
,VARIANT_TRUE
,NULL
,0);
7670 VARIDIV(NULL
,0,I1
,1,NULL
,0);
7671 VARIDIV(NULL
,0,UI1
,1,NULL
,0);
7672 VARIDIV(NULL
,0,UI2
,1,NULL
,0);
7673 VARIDIV(NULL
,0,UI4
,1,NULL
,0);
7674 if (HAVE_OLEAUT32_I8
)
7676 VARIDIV(NULL
,0,I8
,1,NULL
,0);
7677 VARIDIV(NULL
,0,UI8
,1,NULL
,0);
7679 VARIDIV(NULL
,0,INT
,1,NULL
,0);
7680 VARIDIV(NULL
,0,UINT
,1,NULL
,0);
7681 VARIDIV(I2
,2,NULL
,0,NULL
,0);
7682 VARIDIV(I2
,2,I2
,1,I2
,2);
7683 VARIDIV(I2
,2,I4
,1,I4
,2);
7684 VARIDIV(I2
,2,R4
,1,I4
,2);
7685 VARIDIV(I2
,2,R8
,1,I4
,2);
7686 VARIDIV(I2
,2,DATE
,1,I4
,2);
7687 VARIDIV(I2
,2,BSTR
,num1_str
,I4
,2);
7688 VARIDIV(I2
,2,BOOL
,VARIANT_TRUE
,I2
,-2);
7689 VARIDIV(I2
,2,I1
,1,I4
,2);
7690 VARIDIV(I2
,2,UI1
,1,I2
,2);
7691 VARIDIV(I2
,2,UI2
,1,I4
,2);
7692 VARIDIV(I2
,2,UI4
,1,I4
,2);
7693 if (HAVE_OLEAUT32_I8
)
7695 VARIDIV(I2
,2,I8
,1,I8
,2);
7696 VARIDIV(I2
,2,UI8
,1,I4
,2);
7698 VARIDIV(I2
,2,INT
,1,I4
,2);
7699 VARIDIV(I2
,2,UINT
,1,I4
,2);
7700 VARIDIV(I4
,2,NULL
,0,NULL
,0);
7701 VARIDIV(I4
,2,I2
,1,I4
,2);
7702 VARIDIV(I4
,2,I4
,1,I4
,2);
7703 VARIDIV(I4
,2,R4
,1,I4
,2);
7704 VARIDIV(I4
,2,R8
,1,I4
,2);
7705 VARIDIV(I4
,2,DATE
,1,I4
,2);
7706 VARIDIV(I4
,2,BSTR
,num1_str
,I4
,2);
7707 VARIDIV(I4
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
7708 VARIDIV(I4
,2,I1
,1,I4
,2);
7709 VARIDIV(I4
,2,UI1
,1,I4
,2);
7710 VARIDIV(I4
,2,UI2
,1,I4
,2);
7711 VARIDIV(I4
,2,UI4
,1,I4
,2);
7712 if (HAVE_OLEAUT32_I8
)
7714 VARIDIV(I4
,2,I8
,1,I8
,2);
7715 VARIDIV(I4
,2,UI8
,1,I4
,2);
7717 VARIDIV(I4
,2,INT
,1,I4
,2);
7718 VARIDIV(I4
,2,UINT
,1,I4
,2);
7719 VARIDIV(R4
,2.0f
,NULL
,0,NULL
,0);
7720 VARIDIV(R4
,2.0f
,I2
,1,I4
,2);
7721 VARIDIV(R4
,2.0f
,I4
,1,I4
,2);
7722 VARIDIV(R4
,2.0f
,R4
,1.0f
,I4
,2);
7723 VARIDIV(R4
,2.0f
,R8
,1.0,I4
,2);
7724 VARIDIV(R4
,2.0f
,DATE
,1,I4
,2);
7725 VARIDIV(R4
,2.0f
,BSTR
,num1_str
,I4
,2);
7726 VARIDIV(R4
,2.0f
,BOOL
,VARIANT_TRUE
,I4
,-2);
7727 VARIDIV(R4
,2.0f
,I1
,1,I4
,2);
7728 VARIDIV(R4
,2.0f
,UI1
,1,I4
,2);
7729 VARIDIV(R4
,2.0f
,UI2
,1,I4
,2);
7730 VARIDIV(R4
,2.0f
,UI4
,1,I4
,2);
7731 if (HAVE_OLEAUT32_I8
)
7733 VARIDIV(R4
,2.0f
,I8
,1,I8
,2);
7734 VARIDIV(R4
,2.0f
,UI8
,1,I4
,2);
7736 VARIDIV(R4
,2.0f
,INT
,1,I4
,2);
7737 VARIDIV(R4
,2.0f
,UINT
,1,I4
,2);
7738 VARIDIV(R8
,2.0,NULL
,0,NULL
,0);
7739 VARIDIV(R8
,2.0,I2
,1,I4
,2);
7740 VARIDIV(R8
,2.0,I4
,1,I4
,2);
7741 VARIDIV(R8
,2.0,R4
,1,I4
,2);
7742 VARIDIV(R8
,2.0,R8
,1,I4
,2);
7743 VARIDIV(R8
,2.0,DATE
,1,I4
,2);
7744 VARIDIV(R8
,2.0,BSTR
,num1_str
,I4
,2);
7745 VARIDIV(R8
,2.0,BOOL
,VARIANT_TRUE
,I4
,-2);
7746 VARIDIV(R8
,2.0,I1
,1,I4
,2);
7747 VARIDIV(R8
,2.0,UI1
,1,I4
,2);
7748 VARIDIV(R8
,2.0,UI2
,1,I4
,2);
7749 VARIDIV(R8
,2.0,UI4
,1,I4
,2);
7750 if (HAVE_OLEAUT32_I8
)
7752 VARIDIV(R8
,2.0,I8
,1,I8
,2);
7753 VARIDIV(R8
,2.0,UI8
,1,I4
,2);
7755 VARIDIV(R8
,2.0,INT
,1,I4
,2);
7756 VARIDIV(R8
,2.0,UINT
,1,I4
,2);
7757 VARIDIV(DATE
,2,NULL
,0,NULL
,0);
7758 VARIDIV(DATE
,2,I2
,1,I4
,2);
7759 VARIDIV(DATE
,2,I4
,1,I4
,2);
7760 VARIDIV(DATE
,2,R4
,1,I4
,2);
7761 VARIDIV(DATE
,2,R8
,1,I4
,2);
7762 VARIDIV(DATE
,2,DATE
,1,I4
,2);
7763 VARIDIV(DATE
,2,BSTR
,num1_str
,I4
,2);
7764 VARIDIV(DATE
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
7765 VARIDIV(DATE
,2,I1
,1,I4
,2);
7766 VARIDIV(DATE
,2,UI1
,1,I4
,2);
7767 VARIDIV(DATE
,2,UI2
,1,I4
,2);
7768 VARIDIV(DATE
,2,UI4
,1,I4
,2);
7769 if (HAVE_OLEAUT32_I8
)
7771 VARIDIV(DATE
,2,I8
,1,I8
,2);
7772 VARIDIV(DATE
,2,UI8
,1,I4
,2);
7774 VARIDIV(DATE
,2,INT
,1,I4
,2);
7775 VARIDIV(DATE
,2,UINT
,1,I4
,2);
7776 VARIDIV(BSTR
,num2_str
,NULL
,0,NULL
,0);
7777 VARIDIV(BSTR
,num2_str
,I2
,1,I4
,2);
7778 VARIDIV(BSTR
,num2_str
,I4
,1,I4
,2);
7779 VARIDIV(BSTR
,num2_str
,R4
,1.0f
,I4
,2);
7780 VARIDIV(BSTR
,num2_str
,R8
,1.0,I4
,2);
7781 VARIDIV(BSTR
,num2_str
,DATE
,1,I4
,2);
7782 VARIDIV(BSTR
,num2_str
,BSTR
,num1_str
,I4
,2);
7783 VARIDIV(BSTR
,num2_str
,BOOL
,VARIANT_TRUE
,I4
,-2);
7784 VARIDIV(BSTR
,num2_str
,I1
,1,I4
,2);
7785 VARIDIV(BSTR
,num2_str
,UI1
,1,I4
,2);
7786 VARIDIV(BSTR
,num2_str
,UI2
,1,I4
,2);
7787 VARIDIV(BSTR
,num2_str
,UI4
,1,I4
,2);
7788 if (HAVE_OLEAUT32_I8
)
7790 VARIDIV(BSTR
,num2_str
,I8
,1,I8
,2);
7791 VARIDIV(BSTR
,num2_str
,UI8
,1,I4
,2);
7793 VARIDIV(BSTR
,num2_str
,INT
,1,I4
,2);
7794 VARIDIV(BSTR
,num2_str
,UINT
,1,I4
,2);
7795 VARIDIV(BOOL
,VARIANT_TRUE
,NULL
,0,NULL
,0);
7796 VARIDIV(BOOL
,VARIANT_TRUE
,I2
,1,I2
,-1);
7797 VARIDIV(BOOL
,VARIANT_TRUE
,I4
,1,I4
,-1);
7798 VARIDIV(BOOL
,VARIANT_TRUE
,R4
,1.0f
,I4
,-1);
7799 VARIDIV(BOOL
,VARIANT_TRUE
,R8
,1.0,I4
,-1);
7800 VARIDIV(BOOL
,VARIANT_TRUE
,DATE
,1,I4
,-1);
7801 VARIDIV(BOOL
,VARIANT_TRUE
,BSTR
,num1_str
,I4
,-1);
7802 VARIDIV(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_TRUE
,I2
,1);
7803 VARIDIV(BOOL
,VARIANT_TRUE
,I1
,1,I4
,-1);
7804 VARIDIV(BOOL
,VARIANT_TRUE
,UI1
,1,I2
,-1);
7805 VARIDIV(BOOL
,VARIANT_TRUE
,UI2
,1,I4
,-1);
7806 VARIDIV(BOOL
,VARIANT_TRUE
,UI4
,1,I4
,-1);
7807 if (HAVE_OLEAUT32_I8
)
7809 VARIDIV(BOOL
,VARIANT_TRUE
,I8
,1,I8
,-1);
7810 VARIDIV(BOOL
,VARIANT_TRUE
,UI8
,1,I4
,-1);
7812 VARIDIV(BOOL
,VARIANT_TRUE
,INT
,1,I4
,-1);
7813 VARIDIV(BOOL
,VARIANT_TRUE
,UINT
,1,I4
,-1);
7814 VARIDIV(I1
,2,NULL
,0,NULL
,0);
7815 VARIDIV(I1
,2,I2
,1,I4
,2);
7816 VARIDIV(I1
,2,I4
,1,I4
,2);
7817 VARIDIV(I1
,2,R4
,1.0f
,I4
,2);
7818 VARIDIV(I1
,2,R8
,1.0,I4
,2);
7819 VARIDIV(I1
,2,DATE
,1,I4
,2);
7820 VARIDIV(I1
,2,BSTR
,num1_str
,I4
,2);
7821 VARIDIV(I1
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
7822 VARIDIV(I1
,2,I1
,1,I4
,2);
7823 VARIDIV(I1
,2,UI1
,1,I4
,2);
7824 VARIDIV(I1
,2,UI2
,1,I4
,2);
7825 VARIDIV(I1
,2,UI4
,1,I4
,2);
7826 if (HAVE_OLEAUT32_I8
)
7828 VARIDIV(I1
,2,I8
,1,I8
,2);
7829 VARIDIV(I1
,2,UI8
,1,I4
,2);
7831 VARIDIV(I1
,2,INT
,1,I4
,2);
7832 VARIDIV(I1
,2,UINT
,1,I4
,2);
7833 VARIDIV(UI1
,2,NULL
,0,NULL
,0);
7834 VARIDIV(UI1
,2,I2
,1,I2
,2);
7835 VARIDIV(UI1
,2,I4
,1,I4
,2);
7836 VARIDIV(UI1
,2,R4
,1.0f
,I4
,2);
7837 VARIDIV(UI1
,2,R8
,1.0,I4
,2);
7838 VARIDIV(UI1
,2,DATE
,1,I4
,2);
7839 VARIDIV(UI1
,2,BSTR
,num1_str
,I4
,2);
7840 VARIDIV(UI1
,2,BOOL
,VARIANT_TRUE
,I2
,-2);
7841 VARIDIV(UI1
,2,I1
,1,I4
,2);
7842 VARIDIV(UI1
,2,UI1
,1,UI1
,2);
7843 VARIDIV(UI1
,2,UI2
,1,I4
,2);
7844 VARIDIV(UI1
,2,UI4
,1,I4
,2);
7845 if (HAVE_OLEAUT32_I8
)
7847 VARIDIV(UI1
,2,I8
,1,I8
,2);
7848 VARIDIV(UI1
,2,UI8
,1,I4
,2);
7850 VARIDIV(UI1
,2,INT
,1,I4
,2);
7851 VARIDIV(UI1
,2,UINT
,1,I4
,2);
7852 VARIDIV(UI2
,2,NULL
,0,NULL
,0);
7853 VARIDIV(UI2
,2,I2
,1,I4
,2);
7854 VARIDIV(UI2
,2,I4
,1,I4
,2);
7855 VARIDIV(UI2
,2,R4
,1.0f
,I4
,2);
7856 VARIDIV(UI2
,2,R8
,1.0,I4
,2);
7857 VARIDIV(UI2
,2,DATE
,1,I4
,2);
7858 VARIDIV(UI2
,2,BSTR
,num1_str
,I4
,2);
7859 VARIDIV(UI2
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
7860 VARIDIV(UI2
,2,I1
,1,I4
,2);
7861 VARIDIV(UI2
,2,UI1
,1,I4
,2);
7862 VARIDIV(UI2
,2,UI2
,1,I4
,2);
7863 VARIDIV(UI2
,2,UI4
,1,I4
,2);
7864 if (HAVE_OLEAUT32_I8
)
7866 VARIDIV(UI2
,2,I8
,1,I8
,2);
7867 VARIDIV(UI2
,2,UI8
,1,I4
,2);
7869 VARIDIV(UI2
,2,INT
,1,I4
,2);
7870 VARIDIV(UI2
,2,UINT
,1,I4
,2);
7871 VARIDIV(UI4
,2,NULL
,0,NULL
,0);
7872 VARIDIV(UI4
,2,I2
,1,I4
,2);
7873 VARIDIV(UI4
,2,I4
,1,I4
,2);
7874 VARIDIV(UI4
,2,R4
,1.0f
,I4
,2);
7875 VARIDIV(UI4
,2,R8
,1.0,I4
,2);
7876 VARIDIV(UI4
,2,DATE
,1,I4
,2);
7877 VARIDIV(UI4
,2,BSTR
,num1_str
,I4
,2);
7878 VARIDIV(UI4
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
7879 VARIDIV(UI4
,2,I1
,1,I4
,2);
7880 VARIDIV(UI4
,2,UI1
,1,I4
,2);
7881 VARIDIV(UI4
,2,UI2
,1,I4
,2);
7882 VARIDIV(UI4
,2,UI4
,1,I4
,2);
7883 if (HAVE_OLEAUT32_I8
)
7885 VARIDIV(UI4
,2,I8
,1,I8
,2);
7886 VARIDIV(UI4
,2,UI8
,1,I4
,2);
7888 VARIDIV(UI4
,2,INT
,1,I4
,2);
7889 VARIDIV(UI4
,2,UINT
,1,I4
,2);
7890 if (HAVE_OLEAUT32_I8
)
7892 VARIDIV(I8
,2,NULL
,0,NULL
,0);
7893 VARIDIV(I8
,2,I2
,1,I8
,2);
7894 VARIDIV(I8
,2,I4
,1,I8
,2);
7895 VARIDIV(I8
,2,R4
,1.0f
,I8
,2);
7896 VARIDIV(I8
,2,R8
,1.0,I8
,2);
7897 VARIDIV(I8
,2,DATE
,1,I8
,2);
7898 VARIDIV(I8
,2,BSTR
,num1_str
,I8
,2);
7899 VARIDIV(I8
,2,BOOL
,1,I8
,2);
7900 VARIDIV(I8
,2,I1
,1,I8
,2);
7901 VARIDIV(I8
,2,UI1
,1,I8
,2);
7902 VARIDIV(I8
,2,UI2
,1,I8
,2);
7903 VARIDIV(I8
,2,UI4
,1,I8
,2);
7904 VARIDIV(I8
,2,I8
,1,I8
,2);
7905 VARIDIV(I8
,2,UI8
,1,I8
,2);
7906 VARIDIV(I8
,2,UINT
,1,I8
,2);
7907 VARIDIV(UI8
,2,NULL
,0,NULL
,0);
7908 VARIDIV(UI8
,2,I2
,1,I4
,2);
7909 VARIDIV(UI8
,2,I4
,1,I4
,2);
7910 VARIDIV(UI8
,2,R4
,1.0f
,I4
,2);
7911 VARIDIV(UI8
,2,R8
,1.0,I4
,2);
7912 VARIDIV(UI8
,2,DATE
,1,I4
,2);
7913 VARIDIV(UI8
,2,BSTR
,num1_str
,I4
,2);
7914 VARIDIV(UI8
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
7915 VARIDIV(UI8
,2,I1
,1,I4
,2);
7916 VARIDIV(UI8
,2,UI1
,1,I4
,2);
7917 VARIDIV(UI8
,2,UI2
,1,I4
,2);
7918 VARIDIV(UI8
,2,UI4
,1,I4
,2);
7919 VARIDIV(UI8
,2,I8
,1,I8
,2);
7920 VARIDIV(UI8
,2,UI8
,1,I4
,2);
7921 VARIDIV(UI8
,2,INT
,1,I4
,2);
7922 VARIDIV(UI8
,2,UINT
,1,I4
,2);
7924 VARIDIV(INT
,2,NULL
,0,NULL
,0);
7925 VARIDIV(INT
,2,I2
,1,I4
,2);
7926 VARIDIV(INT
,2,I4
,1,I4
,2);
7927 VARIDIV(INT
,2,R4
,1.0f
,I4
,2);
7928 VARIDIV(INT
,2,R8
,1.0,I4
,2);
7929 VARIDIV(INT
,2,DATE
,1,I4
,2);
7930 VARIDIV(INT
,2,BSTR
,num1_str
,I4
,2);
7931 VARIDIV(INT
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
7932 VARIDIV(INT
,2,I1
,1,I4
,2);
7933 VARIDIV(INT
,2,UI1
,1,I4
,2);
7934 VARIDIV(INT
,2,UI2
,1,I4
,2);
7935 VARIDIV(INT
,2,UI4
,1,I4
,2);
7936 if (HAVE_OLEAUT32_I8
)
7938 VARIDIV(INT
,2,UI8
,1,I4
,2);
7940 VARIDIV(INT
,2,INT
,1,I4
,2);
7941 VARIDIV(INT
,2,UINT
,1,I4
,2);
7942 VARIDIV(UINT
,2,NULL
,0,NULL
,0);
7943 VARIDIV(UINT
,2,I2
,1,I4
,2);
7944 VARIDIV(UINT
,2,I4
,1,I4
,2);
7945 VARIDIV(UINT
,2,R4
,1.0f
,I4
,2);
7946 VARIDIV(UINT
,2,R8
,1.0,I4
,2);
7947 VARIDIV(UINT
,2,DATE
,1,I4
,2);
7948 VARIDIV(UINT
,2,BSTR
,num1_str
,I4
,2);
7949 VARIDIV(UINT
,2,BOOL
,VARIANT_TRUE
,I4
,-2);
7950 VARIDIV(UINT
,2,I1
,1,I4
,2);
7951 VARIDIV(UINT
,2,UI1
,1,I4
,2);
7952 VARIDIV(UINT
,2,UI2
,1,I4
,2);
7953 VARIDIV(UINT
,2,UI4
,1,I4
,2);
7954 if (HAVE_OLEAUT32_I8
)
7956 VARIDIV(UINT
,2,I8
,1,I8
,2);
7957 VARIDIV(UINT
,2,UI8
,1,I4
,2);
7959 VARIDIV(UINT
,2,INT
,1,I4
,2);
7960 VARIDIV(UINT
,2,UINT
,1,I4
,2);
7962 /* Manually test some VT_CY, VT_DECIMAL variants */
7964 hres
= VarCyFromI4(10000, &V_CY(&cy
));
7965 ok(hres
== S_OK
, "VarCyFromI4 failed!\n");
7966 V_VT(&dec
) = VT_DECIMAL
;
7967 hres
= VarDecFromR8(2.0, &V_DECIMAL(&dec
));
7968 ok(hres
== S_OK
, "VarDecFromR4 failed!\n");
7969 memset(&left
, 0, sizeof(left
));
7970 memset(&right
, 0, sizeof(right
));
7971 V_VT(&left
) = VT_I4
;
7973 V_VT(&right
) = VT_I8
;
7976 hres
= VarIdiv(&cy
, &cy
, &result
);
7977 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
7978 "VARIDIV: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
7979 S_OK
, hres
, vtstr(V_VT(&result
)));
7980 ok(hres
== S_OK
&& V_I4(&result
) == 1,
7981 "VARIDIV: CY value %d, expected %d\n", V_I4(&result
), 1);
7983 if (HAVE_OLEAUT32_I8
)
7985 hres
= VarIdiv(&cy
, &right
, &result
);
7986 ok(hres
== S_OK
&& V_VT(&result
) == VT_I8
,
7987 "VARIDIV: expected coerced hres 0x%X type VT_I8, got hres 0x%X type %s!\n",
7988 S_OK
, hres
, vtstr(V_VT(&result
)));
7989 ok(hres
== S_OK
&& V_I8(&result
) == 5000,
7990 "VARIDIV: CY value 0x%x%08x, expected 0x%x\n",
7991 (DWORD
)(V_I8(&result
) >>32), (DWORD
)V_I8(&result
), 5000);
7994 hres
= VarIdiv(&left
, &cy
, &result
);
7995 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
7996 "VARIDIV: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
7997 S_OK
, hres
, vtstr(V_VT(&result
)));
7998 ok(hres
== S_OK
&& V_I4(&result
) == 0,
7999 "VARIDIV: CY value %d, expected %d\n", V_I4(&result
), 0);
8001 hres
= VarIdiv(&left
, &dec
, &result
);
8002 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
8003 "VARIDIV: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8004 S_OK
, hres
, vtstr(V_VT(&result
)));
8005 ok(hres
== S_OK
&& V_I4(&result
) == 50,
8006 "VARIDIV: DECIMAL value %d, expected %d\n", V_I4(&result
), 50);
8008 hres
= VarIdiv(&dec
, &dec
, &result
);
8009 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
8010 "VARIDIV: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8011 S_OK
, hres
, vtstr(V_VT(&result
)));
8012 ok(hres
== S_OK
&& V_I4(&result
) == 1,
8013 "VARIDIV: DECIMAL value %d, expected %d\n", V_I4(&result
), 1);
8015 if (HAVE_OLEAUT32_I8
)
8017 hres
= VarIdiv(&dec
, &right
, &result
);
8018 ok(hres
== S_OK
&& V_VT(&result
) == VT_I8
,
8019 "VARIDIV: expected coerced hres 0x%X type VT_I8, got hres 0x%X type %s!\n",
8020 S_OK
, hres
, vtstr(V_VT(&result
)));
8021 ok(hres
== S_OK
&& V_I8(&result
) == 1,
8022 "VARIDIV: DECIMAL value 0x%x%08x, expected %d\n",
8023 (DWORD
)(V_I8(&result
) >> 32), (DWORD
)V_I8(&result
), 1);
8026 /* Check for division by zero */
8027 V_VT(&left
) = VT_INT
;
8029 V_VT(&right
) = VT_INT
;
8031 hres
= pVarIdiv(&left
, &right
, &result
);
8032 ok(hres
== DISP_E_DIVBYZERO
&& V_VT(&result
) == VT_EMPTY
,
8033 "VARIDIV: Division by 0 should result in DISP_E_DIVBYZERO but got 0x%X\n", hres
);
8035 V_VT(&left
) = VT_INT
;
8037 V_VT(&right
) = VT_INT
;
8039 hres
= pVarIdiv(&left
, &right
, &result
);
8040 ok(hres
== DISP_E_DIVBYZERO
&& V_VT(&result
) == VT_EMPTY
,
8041 "VARIDIV: Division by 0 should result in DISP_E_DIVBYZERO but got 0x%X\n", hres
);
8043 SysFreeString(num1_str
);
8044 SysFreeString(num2_str
);
8048 static HRESULT (WINAPI
*pVarImp
)(LPVARIANT
,LPVARIANT
,LPVARIANT
);
8050 #define VARIMP(vt1,val1,vt2,val2,rvt,rval) \
8051 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
8052 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
8053 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
8054 test_var_call2( __LINE__, pVarImp, &left, &right, &exp )
8056 /* Skip any type that is not defined or produces an error for every case */
8057 #define SKIPTESTIMP(a) \
8058 if (a == VT_ERROR || a == VT_VARIANT || \
8059 a == VT_DISPATCH || a == VT_UNKNOWN || \
8060 a == VT_RECORD || a > VT_UINT || \
8061 a == 15 /*not defined*/) \
8064 static void test_VarImp(void)
8066 static const WCHAR szFalse
[] = { '#','F','A','L','S','E','#','\0' };
8067 static const WCHAR szTrue
[] = { '#','T','R','U','E','#','\0' };
8068 VARIANT left
, right
, exp
, result
, cy
, dec
;
8069 BSTR true_str
, false_str
;
8075 true_str
= SysAllocString(szTrue
);
8076 false_str
= SysAllocString(szFalse
);
8078 /* Test all possible flag/vt combinations & the resulting vt type */
8079 for (i
= 0; i
< sizeof(ExtraFlags
)/sizeof(ExtraFlags
[0]); i
++)
8081 VARTYPE leftvt
, rightvt
, resvt
;
8083 for (leftvt
= 0; leftvt
<= VT_BSTR_BLOB
; leftvt
++)
8085 SKIPTESTIMP(leftvt
);
8087 /* Check if we need/have support for I8 and/or UI8 */
8088 if ((leftvt
== VT_I8
|| leftvt
== VT_UI8
) && !HAVE_OLEAUT32_I8
)
8091 for (rightvt
= 0; rightvt
<= VT_BSTR_BLOB
; rightvt
++)
8094 SKIPTESTIMP(rightvt
);
8096 /* Native crashes when using the extra flag VT_BYREF
8097 * or with the following VT combinations
8099 if ((leftvt
== VT_UI4
&& rightvt
== VT_BSTR
) ||
8100 (leftvt
== VT_UI8
&& rightvt
== VT_BSTR
) ||
8101 ExtraFlags
[i
] == VT_BYREF
)
8104 /* Check if we need/have support for I8 and/or UI8 */
8105 if ((rightvt
== VT_I8
|| rightvt
== VT_UI8
) && !HAVE_OLEAUT32_I8
)
8108 memset(&left
, 0, sizeof(left
));
8109 memset(&right
, 0, sizeof(right
));
8110 V_VT(&left
) = leftvt
| ExtraFlags
[i
];
8111 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
8112 V_VT(&result
) = VT_EMPTY
;
8115 if (leftvt
== VT_BSTR
)
8116 V_BSTR(&left
) = true_str
;
8118 /* This allows us to test return types that are not NULL
8119 * (NULL Imp value = n, NULL Imp 0 = NULL)
8124 V_BSTR(&right
) = true_str
;
8127 VarDecFromR8(2.0, &V_DECIMAL(&right
));
8128 V_VT(&right
) = rightvt
| ExtraFlags
[i
];
8131 V_BOOL(&right
) = VARIANT_TRUE
;
8133 case VT_I1
: V_I1(&right
) = 2; break;
8134 case VT_I2
: V_I2(&right
) = 2; break;
8135 case VT_I4
: V_I4(&right
) = 2; break;
8136 case VT_R4
: V_R4(&right
) = 2.0f
; break;
8137 case VT_R8
: V_R8(&right
) = 2.0; break;
8138 case VT_CY
: V_CY(&right
).int64
= 10000; break;
8139 case VT_DATE
: V_DATE(&right
) = 2; break;
8140 case VT_I8
: V_I8(&right
) = 2; break;
8141 case VT_INT
: V_INT(&right
) = 2; break;
8142 case VT_UINT
: V_UINT(&right
) = 2; break;
8143 case VT_UI1
: V_UI1(&right
) = 2; break;
8144 case VT_UI2
: V_UI2(&right
) = 2; break;
8145 case VT_UI4
: V_UI4(&right
) = 2; break;
8146 case VT_UI8
: V_UI8(&right
) = 2; break;
8150 /* Native VarImp always returns an error when using extra
8151 * flags or if the variants are I8 and INT.
8153 if ((leftvt
== VT_I8
&& rightvt
== VT_INT
) ||
8157 /* Determine result type */
8158 else if ((leftvt
== VT_BSTR
&& rightvt
== VT_NULL
) ||
8159 (leftvt
== VT_NULL
&& rightvt
== VT_NULL
) ||
8160 (leftvt
== VT_NULL
&& rightvt
== VT_EMPTY
))
8162 else if (leftvt
== VT_I8
|| rightvt
== VT_I8
)
8164 else if (leftvt
== VT_I4
|| rightvt
== VT_I4
||
8165 leftvt
== VT_INT
|| rightvt
== VT_INT
||
8166 leftvt
== VT_UINT
|| rightvt
== VT_UINT
||
8167 leftvt
== VT_UI4
|| rightvt
== VT_UI4
||
8168 leftvt
== VT_UI8
|| rightvt
== VT_UI8
||
8169 leftvt
== VT_UI2
|| rightvt
== VT_UI2
||
8170 leftvt
== VT_DECIMAL
|| rightvt
== VT_DECIMAL
||
8171 leftvt
== VT_DATE
|| rightvt
== VT_DATE
||
8172 leftvt
== VT_CY
|| rightvt
== VT_CY
||
8173 leftvt
== VT_R8
|| rightvt
== VT_R8
||
8174 leftvt
== VT_R4
|| rightvt
== VT_R4
||
8175 leftvt
== VT_I1
|| rightvt
== VT_I1
)
8177 else if ((leftvt
== VT_UI1
&& rightvt
== VT_UI1
) ||
8178 (leftvt
== VT_UI1
&& rightvt
== VT_NULL
) ||
8179 (leftvt
== VT_NULL
&& rightvt
== VT_UI1
))
8181 else if (leftvt
== VT_EMPTY
|| rightvt
== VT_EMPTY
||
8182 leftvt
== VT_I2
|| rightvt
== VT_I2
||
8183 leftvt
== VT_UI1
|| rightvt
== VT_UI1
)
8185 else if (leftvt
== VT_BOOL
|| rightvt
== VT_BOOL
||
8186 leftvt
== VT_BSTR
|| rightvt
== VT_BSTR
)
8189 hres
= pVarImp(&left
, &right
, &result
);
8191 /* Check expected HRESULT and if result variant type is correct */
8193 ok (hres
== DISP_E_BADVARTYPE
|| hres
== DISP_E_TYPEMISMATCH
,
8194 "VarImp: %s|0x%X, %s|0x%X: got vt %s hr 0x%X\n",
8195 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
],
8196 vtstr(V_VT(&result
)), hres
);
8198 ok (hres
== S_OK
&& resvt
== V_VT(&result
),
8199 "VarImp: %s|0x%X, %s|0x%X: expected vt %s hr 0x%X, got vt %s hr 0x%X\n",
8200 vtstr(leftvt
), ExtraFlags
[i
], vtstr(rightvt
), ExtraFlags
[i
], vtstr(resvt
),
8201 S_OK
, vtstr(V_VT(&result
)), hres
);
8206 VARIMP(EMPTY
,0,EMPTY
,0,I2
,-1);
8207 VARIMP(EMPTY
,0,NULL
,0,I2
,-1);
8208 VARIMP(EMPTY
,0,I2
,-1,I2
,-1);
8209 VARIMP(EMPTY
,0,I4
,-1,I4
,-1);
8210 VARIMP(EMPTY
,0,R4
,0.0f
,I4
,-1);
8211 VARIMP(EMPTY
,0,R8
,-1.0,I4
,-1);
8212 VARIMP(EMPTY
,0,DATE
,0,I4
,-1);
8213 VARIMP(EMPTY
,0,BSTR
,true_str
,I2
,-1);
8214 VARIMP(EMPTY
,0,BOOL
,VARIANT_FALSE
,I2
,-1);
8215 VARIMP(EMPTY
,0,I1
,0,I4
,-1);
8216 VARIMP(EMPTY
,0,UI1
,1,I2
,-1);
8217 VARIMP(EMPTY
,0,UI2
,1,I4
,-1);
8218 VARIMP(EMPTY
,0,UI4
,1,I4
,-1);
8219 if (HAVE_OLEAUT32_I8
)
8221 VARIMP(EMPTY
,0,I8
,1,I8
,-1);
8222 VARIMP(EMPTY
,0,UI8
,1,I4
,-1);
8224 VARIMP(EMPTY
,0,INT
,-1,I4
,-1);
8225 VARIMP(EMPTY
,0,UINT
,1,I4
,-1);
8226 VARIMP(NULL
,0,EMPTY
,0,NULL
,0);
8227 VARIMP(NULL
,0,NULL
,0,NULL
,0);
8228 VARIMP(NULL
,0,I2
,-1,I2
,-1);
8229 VARIMP(NULL
,0,I4
,-1,I4
,-1);
8230 VARIMP(NULL
,0,R4
,0.0f
,NULL
,0);
8231 VARIMP(NULL
,0,R8
,-1.0,I4
,-1);
8232 VARIMP(NULL
,0,DATE
,0,NULL
,0);
8233 VARIMP(NULL
,0,BSTR
,true_str
,BOOL
,-1);
8234 VARIMP(NULL
,0,BOOL
,VARIANT_FALSE
,NULL
,0);
8235 VARIMP(NULL
,0,I1
,0,NULL
,0);
8236 VARIMP(NULL
,0,UI1
,1,UI1
,1);
8237 VARIMP(NULL
,0,UI2
,1,I4
,1);
8238 VARIMP(NULL
,0,UI4
,1,I4
,1);
8239 if (HAVE_OLEAUT32_I8
)
8241 VARIMP(NULL
,0,I8
,1,I8
,1);
8242 VARIMP(NULL
,0,UI8
,1,I4
,1);
8244 VARIMP(NULL
,0,INT
,-1,I4
,-1);
8245 VARIMP(NULL
,0,UINT
,1,I4
,1);
8246 VARIMP(I2
,-1,EMPTY
,0,I2
,0);
8247 VARIMP(I2
,-1,I2
,-1,I2
,-1);
8248 VARIMP(I2
,-1,I4
,-1,I4
,-1);
8249 VARIMP(I2
,-1,R4
,0.0f
,I4
,0);
8250 VARIMP(I2
,-1,R8
,-1.0,I4
,-1);
8251 VARIMP(I2
,-1,DATE
,0,I4
,0);
8252 VARIMP(I2
,-1,BSTR
,true_str
,I2
,-1);
8253 VARIMP(I2
,-1,BOOL
,VARIANT_FALSE
,I2
,0);
8254 VARIMP(I2
,-1,I1
,0,I4
,0);
8255 VARIMP(I2
,-1,UI1
,1,I2
,1);
8256 VARIMP(I2
,-1,UI2
,1,I4
,1);
8257 VARIMP(I2
,-1,UI4
,1,I4
,1);
8258 if (HAVE_OLEAUT32_I8
)
8260 VARIMP(I2
,-1,I8
,1,I8
,1);
8261 VARIMP(I2
,-1,UI8
,1,I4
,1);
8263 VARIMP(I2
,-1,INT
,-1,I4
,-1);
8264 VARIMP(I2
,-1,UINT
,1,I4
,1);
8265 VARIMP(I4
,2,EMPTY
,0,I4
,-3);
8266 VARIMP(I4
,2,NULL
,0,I4
,-3);
8267 VARIMP(I4
,2,I2
,-1,I4
,-1);
8268 VARIMP(I4
,2,I4
,-1,I4
,-1);
8269 VARIMP(I4
,2,R4
,0.0f
,I4
,-3);
8270 VARIMP(I4
,2,R8
,-1.0,I4
,-1);
8271 VARIMP(I4
,2,DATE
,0,I4
,-3);
8272 VARIMP(I4
,2,BSTR
,true_str
,I4
,-1);
8273 VARIMP(I4
,2,BOOL
,VARIANT_FALSE
,I4
,-3);
8274 VARIMP(I4
,2,I1
,0,I4
,-3);
8275 VARIMP(I4
,2,UI1
,1,I4
,-3);
8276 VARIMP(I4
,2,UI2
,1,I4
,-3);
8277 VARIMP(I4
,2,UI4
,1,I4
,-3);
8278 if (HAVE_OLEAUT32_I8
)
8280 VARIMP(I4
,2,I8
,1,I8
,-3);
8281 VARIMP(I4
,2,UI8
,1,I4
,-3);
8283 VARIMP(I4
,2,INT
,-1,I4
,-1);
8284 VARIMP(I4
,2,UINT
,1,I4
,-3);
8285 VARIMP(R4
,-1.0f
,EMPTY
,0,I4
,0);
8286 VARIMP(R4
,-1.0f
,NULL
,0,NULL
,0);
8287 VARIMP(R4
,-1.0f
,I2
,-1,I4
,-1);
8288 VARIMP(R4
,-1.0f
,I4
,-1,I4
,-1);
8289 VARIMP(R4
,-1.0f
,R4
,0.0f
,I4
,0);
8290 VARIMP(R4
,-1.0f
,R8
,-1.0,I4
,-1);
8291 VARIMP(R4
,-1.0f
,DATE
,1,I4
,1);
8292 VARIMP(R4
,-1.0f
,BSTR
,true_str
,I4
,-1);
8293 VARIMP(R4
,-1.0f
,BOOL
,VARIANT_FALSE
,I4
,0);
8294 VARIMP(R4
,-1.0f
,I1
,0,I4
,0);
8295 VARIMP(R4
,-1.0f
,UI1
,1,I4
,1);
8296 VARIMP(R4
,-1.0f
,UI2
,1,I4
,1);
8297 VARIMP(R4
,-1.0f
,UI4
,1,I4
,1);
8298 if (HAVE_OLEAUT32_I8
)
8300 VARIMP(R4
,-1.0f
,I8
,1,I8
,1);
8301 VARIMP(R4
,-1.0f
,UI8
,1,I4
,1);
8303 VARIMP(R4
,-1.0f
,INT
,-1,I4
,-1);
8304 VARIMP(R4
,-1.0f
,UINT
,1,I4
,1);
8305 VARIMP(R8
,1.0,EMPTY
,0,I4
,-2);
8306 VARIMP(R8
,1.0,NULL
,0,I4
,-2);
8307 VARIMP(R8
,1.0,I2
,-1,I4
,-1);
8308 VARIMP(R8
,1.0,I4
,-1,I4
,-1);
8309 VARIMP(R8
,1.0,R4
,0.0f
,I4
,-2);
8310 VARIMP(R8
,1.0,R8
,-1.0,I4
,-1);
8311 VARIMP(R8
,1.0,DATE
,0,I4
,-2);
8312 VARIMP(R8
,1.0,BSTR
,true_str
,I4
,-1);
8313 VARIMP(R8
,1.0,BOOL
,VARIANT_FALSE
,I4
,-2);
8314 VARIMP(R8
,1.0,I1
,0,I4
,-2);
8315 VARIMP(R8
,1.0,UI1
,1,I4
,-1);
8316 VARIMP(R8
,1.0,UI2
,1,I4
,-1);
8317 VARIMP(R8
,1.0,UI4
,1,I4
,-1);
8318 if (HAVE_OLEAUT32_I8
)
8320 VARIMP(R8
,1.0,I8
,1,I8
,-1);
8321 VARIMP(R8
,1.0,UI8
,1,I4
,-1);
8323 VARIMP(R8
,1.0,INT
,-1,I4
,-1);
8324 VARIMP(R8
,1.0,UINT
,1,I4
,-1);
8325 VARIMP(DATE
,0,EMPTY
,0,I4
,-1);
8326 VARIMP(DATE
,0,NULL
,0,I4
,-1);
8327 VARIMP(DATE
,0,I2
,-1,I4
,-1);
8328 VARIMP(DATE
,0,I4
,-1,I4
,-1);
8329 VARIMP(DATE
,0,R4
,0.0f
,I4
,-1);
8330 VARIMP(DATE
,0,R8
,-1.0,I4
,-1);
8331 VARIMP(DATE
,0,DATE
,0,I4
,-1);
8332 VARIMP(DATE
,0,BSTR
,true_str
,I4
,-1);
8333 VARIMP(DATE
,0,BOOL
,VARIANT_FALSE
,I4
,-1);
8334 VARIMP(DATE
,0,I1
,0,I4
,-1);
8335 VARIMP(DATE
,0,UI1
,1,I4
,-1);
8336 VARIMP(DATE
,0,UI2
,1,I4
,-1);
8337 VARIMP(DATE
,0,UI4
,1,I4
,-1);
8338 if (HAVE_OLEAUT32_I8
)
8340 VARIMP(DATE
,0,I8
,1,I8
,-1);
8341 VARIMP(DATE
,0,UI8
,1,I4
,-1);
8343 VARIMP(DATE
,0,INT
,-1,I4
,-1);
8344 VARIMP(DATE
,0,UINT
,1,I4
,-1);
8345 VARIMP(BSTR
,false_str
,EMPTY
,0,I2
,-1);
8346 VARIMP(BSTR
,false_str
,NULL
,0,BOOL
,-1);
8347 VARIMP(BSTR
,false_str
,I2
,-1,I2
,-1);
8348 VARIMP(BSTR
,false_str
,I4
,-1,I4
,-1);
8349 VARIMP(BSTR
,false_str
,R4
,0.0f
,I4
,-1);
8350 VARIMP(BSTR
,false_str
,R8
,-1.0,I4
,-1);
8351 VARIMP(BSTR
,false_str
,DATE
,0,I4
,-1);
8352 VARIMP(BSTR
,false_str
,BSTR
,true_str
,BOOL
,-1);
8353 VARIMP(BSTR
,false_str
,BOOL
,VARIANT_FALSE
,BOOL
,-1);
8354 VARIMP(BSTR
,false_str
,I1
,0,I4
,-1);
8355 VARIMP(BSTR
,false_str
,UI1
,1,I2
,-1);
8356 VARIMP(BSTR
,false_str
,UI2
,1,I4
,-1);
8357 VARIMP(BSTR
,false_str
,UI4
,1,I4
,-1);
8358 if (HAVE_OLEAUT32_I8
)
8360 VARIMP(BSTR
,false_str
,I8
,1,I8
,-1);
8361 VARIMP(BSTR
,false_str
,UI8
,1,I4
,-1);
8363 VARIMP(BSTR
,false_str
,INT
,-1,I4
,-1);
8364 VARIMP(BSTR
,false_str
,UINT
,1,I4
,-1);
8365 VARIMP(BOOL
,VARIANT_TRUE
,EMPTY
,0,I2
,0);
8366 VARIMP(BOOL
,VARIANT_TRUE
,NULL
,0,NULL
,0);
8367 VARIMP(BOOL
,VARIANT_TRUE
,I2
,-1,I2
,-1);
8368 VARIMP(BOOL
,VARIANT_TRUE
,I4
,-1,I4
,-1);
8369 VARIMP(BOOL
,VARIANT_TRUE
,R4
,0.0f
,I4
,0);
8370 VARIMP(BOOL
,VARIANT_TRUE
,R8
,-1.0,I4
,-1);
8371 VARIMP(BOOL
,VARIANT_TRUE
,DATE
,0,I4
,0);
8372 VARIMP(BOOL
,VARIANT_TRUE
,BSTR
,true_str
,BOOL
,-1);
8373 VARIMP(BOOL
,VARIANT_TRUE
,BOOL
,VARIANT_FALSE
,BOOL
,0);
8374 VARIMP(BOOL
,VARIANT_TRUE
,I1
,0,I4
,0);
8375 VARIMP(BOOL
,VARIANT_TRUE
,UI1
,1,I2
,1);
8376 VARIMP(BOOL
,VARIANT_TRUE
,UI2
,1,I4
,1);
8377 VARIMP(BOOL
,VARIANT_TRUE
,UI4
,1,I4
,1);
8378 if (HAVE_OLEAUT32_I8
)
8380 VARIMP(BOOL
,VARIANT_TRUE
,I8
,1,I8
,1);
8381 VARIMP(BOOL
,VARIANT_TRUE
,UI8
,1,I4
,1);
8383 VARIMP(BOOL
,VARIANT_TRUE
,INT
,-1,I4
,-1);
8384 VARIMP(BOOL
,VARIANT_TRUE
,UINT
,1,I4
,1);
8385 VARIMP(I1
,-1,EMPTY
,0,I4
,0);
8386 VARIMP(I1
,-1,NULL
,0,NULL
,0);
8387 VARIMP(I1
,-1,I2
,-1,I4
,-1);
8388 VARIMP(I1
,-1,I4
,-1,I4
,-1);
8389 VARIMP(I1
,-1,R4
,0.0f
,I4
,0);
8390 VARIMP(I1
,-1,R8
,-1.0,I4
,-1);
8391 VARIMP(I1
,-1,DATE
,0,I4
,0);
8392 VARIMP(I1
,-1,BSTR
,true_str
,I4
,-1);
8393 VARIMP(I1
,-1,BOOL
,VARIANT_FALSE
,I4
,0);
8394 VARIMP(I1
,-1,I1
,0,I4
,0);
8395 VARIMP(I1
,-1,UI1
,1,I4
,1);
8396 VARIMP(I1
,-1,UI2
,1,I4
,1);
8397 VARIMP(I1
,-1,UI4
,1,I4
,1);
8398 if (HAVE_OLEAUT32_I8
)
8400 VARIMP(I1
,-1,I8
,1,I8
,1);
8401 VARIMP(I1
,-1,UI8
,1,I4
,1);
8403 VARIMP(I1
,-1,INT
,-1,I4
,-1);
8404 VARIMP(I1
,-1,UINT
,1,I4
,1);
8405 VARIMP(UI1
,0,EMPTY
,0,I2
,-1);
8406 VARIMP(UI1
,0,NULL
,0,UI1
,255);
8407 VARIMP(UI1
,0,I2
,-1,I2
,-1);
8408 VARIMP(UI1
,0,I4
,-1,I4
,-1);
8409 VARIMP(UI1
,0,R4
,0.0f
,I4
,-1);
8410 VARIMP(UI1
,0,R8
,-1.0,I4
,-1);
8411 VARIMP(UI1
,0,DATE
,0,I4
,-1);
8412 VARIMP(UI1
,0,BSTR
,true_str
,I2
,-1);
8413 VARIMP(UI1
,0,BOOL
,VARIANT_FALSE
,I2
,-1);
8414 VARIMP(UI1
,0,I1
,0,I4
,-1);
8415 VARIMP(UI1
,0,UI1
,1,UI1
,255);
8416 VARIMP(UI1
,0,UI2
,1,I4
,-1);
8417 VARIMP(UI1
,0,UI4
,1,I4
,-1);
8418 if (HAVE_OLEAUT32_I8
)
8420 VARIMP(UI1
,0,I8
,1,I8
,-1);
8421 VARIMP(UI1
,0,UI8
,1,I4
,-1);
8423 VARIMP(UI1
,0,INT
,-1,I4
,-1);
8424 VARIMP(UI1
,0,UINT
,1,I4
,-1);
8425 VARIMP(UI2
,0,EMPTY
,0,I4
,-1);
8426 VARIMP(UI2
,0,NULL
,0,I4
,-1);
8427 VARIMP(UI2
,0,I2
,-1,I4
,-1);
8428 VARIMP(UI2
,0,I4
,-1,I4
,-1);
8429 VARIMP(UI2
,0,R4
,0.0f
,I4
,-1);
8430 VARIMP(UI2
,0,R8
,-1.0,I4
,-1);
8431 VARIMP(UI2
,0,DATE
,0,I4
,-1);
8432 VARIMP(UI2
,0,BSTR
,true_str
,I4
,-1);
8433 VARIMP(UI2
,0,BOOL
,VARIANT_FALSE
,I4
,-1);
8434 VARIMP(UI2
,0,I1
,0,I4
,-1);
8435 VARIMP(UI2
,0,UI1
,1,I4
,-1);
8436 VARIMP(UI2
,0,UI2
,1,I4
,-1);
8437 VARIMP(UI2
,0,UI4
,1,I4
,-1);
8438 if (HAVE_OLEAUT32_I8
)
8440 VARIMP(UI2
,0,I8
,1,I8
,-1);
8441 VARIMP(UI2
,0,UI8
,1,I4
,-1);
8443 VARIMP(UI2
,0,INT
,-1,I4
,-1);
8444 VARIMP(UI2
,0,UINT
,1,I4
,-1);
8445 VARIMP(UI4
,0,EMPTY
,0,I4
,-1);
8446 VARIMP(UI4
,0,NULL
,0,I4
,-1);
8447 VARIMP(UI4
,0,I2
,-1,I4
,-1);
8448 VARIMP(UI4
,0,I4
,-1,I4
,-1);
8449 VARIMP(UI4
,0,R4
,0.0f
,I4
,-1);
8450 VARIMP(UI4
,0,R8
,-1.0,I4
,-1);
8451 VARIMP(UI4
,0,DATE
,0,I4
,-1);
8452 VARIMP(UI4
,0,BSTR
,true_str
,I4
,-1);
8453 VARIMP(UI4
,0,BOOL
,VARIANT_FALSE
,I4
,-1);
8454 VARIMP(UI4
,0,I1
,0,I4
,-1);
8455 VARIMP(UI4
,0,UI1
,1,I4
,-1);
8456 VARIMP(UI4
,0,UI2
,1,I4
,-1);
8457 VARIMP(UI4
,0,UI4
,1,I4
,-1);
8458 if (HAVE_OLEAUT32_I8
)
8460 VARIMP(UI4
,0,I8
,1,I8
,-1);
8461 VARIMP(UI4
,0,UI8
,1,I4
,-1);
8463 VARIMP(UI4
,0,INT
,-1,I4
,-1);
8464 VARIMP(UI4
,0,UINT
,1,I4
,-1);
8465 if (HAVE_OLEAUT32_I8
)
8467 VARIMP(I8
,-1,EMPTY
,0,I8
,0);
8468 VARIMP(I8
,-1,NULL
,0,NULL
,0);
8469 VARIMP(I8
,-1,I2
,-1,I8
,-1);
8470 VARIMP(I8
,-1,I4
,-1,I8
,-1);
8471 VARIMP(I8
,-1,R4
,0.0f
,I8
,0);
8472 VARIMP(I8
,-1,R8
,-1.0,I8
,-1);
8473 VARIMP(I8
,-1,DATE
,0,I8
,0);
8474 VARIMP(I8
,-1,BSTR
,true_str
,I8
,-1);
8475 VARIMP(I8
,-1,BOOL
,VARIANT_FALSE
,I8
,0);
8476 VARIMP(I8
,-1,I1
,0,I8
,0);
8477 VARIMP(I8
,-1,UI1
,1,I8
,1);
8478 VARIMP(I8
,-1,UI2
,1,I8
,1);
8479 VARIMP(I8
,-1,UI4
,1,I8
,1);
8480 VARIMP(I8
,-1,I8
,1,I8
,1);
8481 VARIMP(I8
,-1,UI8
,1,I8
,1);
8482 VARIMP(I8
,-1,UINT
,1,I8
,1);
8483 VARIMP(UI8
,0,EMPTY
,0,I4
,-1);
8484 VARIMP(UI8
,0,NULL
,0,I4
,-1);
8485 VARIMP(UI8
,0,I2
,-1,I4
,-1);
8486 VARIMP(UI8
,0,I4
,-1,I4
,-1);
8487 VARIMP(UI8
,0,R4
,0.0f
,I4
,-1);
8488 VARIMP(UI8
,0,R8
,-1.0,I4
,-1);
8489 VARIMP(UI8
,0,DATE
,0,I4
,-1);
8490 VARIMP(UI8
,0,BSTR
,true_str
,I4
,-1);
8491 VARIMP(UI8
,0,BOOL
,VARIANT_FALSE
,I4
,-1);
8492 VARIMP(UI8
,0,I1
,0,I4
,-1);
8493 VARIMP(UI8
,0,UI1
,1,I4
,-1);
8494 VARIMP(UI8
,0,UI2
,1,I4
,-1);
8495 VARIMP(UI8
,0,UI4
,1,I4
,-1);
8496 VARIMP(UI8
,0,I8
,1,I8
,-1);
8497 VARIMP(UI8
,0,UI8
,1,I4
,-1);
8498 VARIMP(UI8
,0,INT
,-1,I4
,-1);
8499 VARIMP(UI8
,0,UINT
,1,I4
,-1);
8501 VARIMP(INT
,-1,EMPTY
,0,I4
,0);
8502 VARIMP(INT
,-1,NULL
,0,NULL
,0);
8503 VARIMP(INT
,-1,I2
,-1,I4
,-1);
8504 VARIMP(INT
,-1,I4
,-1,I4
,-1);
8505 VARIMP(INT
,-1,R4
,0.0f
,I4
,0);
8506 VARIMP(INT
,-1,R8
,-1.0,I4
,-1);
8507 VARIMP(INT
,-1,DATE
,0,I4
,0);
8508 VARIMP(INT
,-1,BSTR
,true_str
,I4
,-1);
8509 VARIMP(INT
,-1,BOOL
,VARIANT_FALSE
,I4
,0);
8510 VARIMP(INT
,-1,I1
,0,I4
,0);
8511 VARIMP(INT
,-1,UI1
,1,I4
,1);
8512 VARIMP(INT
,-1,UI2
,1,I4
,1);
8513 VARIMP(INT
,-1,UI4
,1,I4
,1);
8514 if (HAVE_OLEAUT32_I8
)
8516 VARIMP(INT
,-1,I8
,1,I8
,1);
8517 VARIMP(INT
,-1,UI8
,1,I4
,1);
8519 VARIMP(INT
,-1,INT
,-1,I4
,-1);
8520 VARIMP(INT
,-1,UINT
,1,I4
,1);
8521 VARIMP(UINT
,1,EMPTY
,0,I4
,-2);
8522 VARIMP(UINT
,1,NULL
,0,I4
,-2);
8523 VARIMP(UINT
,1,I2
,-1,I4
,-1);
8524 VARIMP(UINT
,1,I4
,-1,I4
,-1);
8525 VARIMP(UINT
,1,R4
,0.0f
,I4
,-2);
8526 VARIMP(UINT
,1,R8
,-1.0,I4
,-1);
8527 VARIMP(UINT
,1,DATE
,0,I4
,-2);
8528 VARIMP(UINT
,1,BSTR
,true_str
,I4
,-1);
8529 VARIMP(UINT
,1,BOOL
,VARIANT_FALSE
,I4
,-2);
8530 VARIMP(UINT
,1,I1
,0,I4
,-2);
8531 VARIMP(UINT
,1,UI1
,1,I4
,-1);
8532 VARIMP(UINT
,1,UI2
,1,I4
,-1);
8533 VARIMP(UINT
,1,UI4
,1,I4
,-1);
8534 if (HAVE_OLEAUT32_I8
)
8536 VARIMP(UINT
,1,I8
,1,I8
,-1);
8537 VARIMP(UINT
,1,UI8
,1,I4
,-1);
8539 VARIMP(UINT
,1,INT
,-1,I4
,-1);
8540 VARIMP(UINT
,1,UINT
,1,I4
,-1);
8542 /* Manually test some VT_CY, VT_DECIMAL variants */
8544 hres
= VarCyFromI4(1, &V_CY(&cy
));
8545 ok(hres
== S_OK
, "VarCyFromI4 failed!\n");
8546 V_VT(&dec
) = VT_DECIMAL
;
8547 hres
= VarDecFromR8(2.0, &V_DECIMAL(&dec
));
8548 ok(hres
== S_OK
, "VarDecFromR4 failed!\n");
8549 memset(&left
, 0, sizeof(left
));
8550 memset(&right
, 0, sizeof(right
));
8551 V_VT(&left
) = VT_I4
;
8553 V_VT(&right
) = VT_I8
;
8556 hres
= pVarImp(&cy
, &cy
, &result
);
8557 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
8558 "VARIMP: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8559 S_OK
, hres
, vtstr(V_VT(&result
)));
8560 ok(hres
== S_OK
&& V_I4(&result
) == -1,
8561 "VARIMP: CY value %d, expected %d\n", V_I4(&result
), -1);
8563 if (HAVE_OLEAUT32_I8
)
8565 hres
= pVarImp(&cy
, &right
, &result
);
8566 ok(hres
== S_OK
&& V_VT(&result
) == VT_I8
,
8567 "VARIMP: expected coerced hres 0x%X type VT_I8, got hres 0x%X type %s!\n",
8568 S_OK
, hres
, vtstr(V_VT(&result
)));
8569 ok(hres
== S_OK
&& V_I8(&result
) == -2,
8570 "VARIMP: CY value %x%08x, expected %d\n",
8571 (DWORD
)((V_I8(&result
)) >> 32), (DWORD
)(V_I8(&result
)), -2);
8574 hres
= pVarImp(&left
, &cy
, &result
);
8575 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
8576 "VARIMP: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8577 S_OK
, hres
, vtstr(V_VT(&result
)));
8578 ok(hres
== S_OK
&& V_I4(&result
) == -1,
8579 "VARIMP: CY value %d, expected %d\n", V_I4(&result
), -1);
8581 hres
= pVarImp(&left
, &dec
, &result
);
8582 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
8583 "VARIMP: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8584 S_OK
, hres
, vtstr(V_VT(&result
)));
8585 ok(hres
== S_OK
&& V_I4(&result
) == -1,
8586 "VARIMP: DECIMAL value %d, expected %d\n", V_I4(&result
), -1);
8588 hres
= pVarImp(&dec
, &dec
, &result
);
8589 ok(hres
== S_OK
&& V_VT(&result
) == VT_I4
,
8590 "VARIMP: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8591 S_OK
, hres
, vtstr(V_VT(&result
)));
8592 ok(hres
== S_OK
&& V_I4(&result
) == -1,
8593 "VARIMP: DECIMAL value %d, expected %d\n", V_I4(&result
), -1);
8595 if (HAVE_OLEAUT32_I8
)
8597 hres
= pVarImp(&dec
, &right
, &result
);
8598 ok(hres
== S_OK
&& V_VT(&result
) == VT_I8
,
8599 "VARIMP: expected coerced hres 0x%X type VT_I8, got hres 0x%X type %s!\n",
8600 S_OK
, hres
, vtstr(V_VT(&result
)));
8601 ok(hres
== S_OK
&& V_I8(&result
) == -3,
8602 "VARIMP: DECIMAL value 0x%x%08x, expected %d\n",
8603 (DWORD
)(V_I8(&result
) >>32), (DWORD
)V_I8(&result
), -3);
8606 SysFreeString(false_str
);
8607 SysFreeString(true_str
);
8615 test_VariantClear();
8617 test_VariantCopyInd();
8618 test_VarParseNumFromStr();
8619 test_VarNumFromParseNum();
8620 test_VarUdateFromDate();
8621 test_VarDateFromUdate();
8622 test_SystemTimeToVariantTime();
8623 test_VariantTimeToSystemTime();
8624 test_DosDateTimeToVariantTime();
8625 test_VariantTimeToDosDateTime();