4 * Copyright 1998 Jean-Claude Cote
5 * Copyright 2006 Google (Benjamin Arai)
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
32 #include "wine/test.h"
42 static HMODULE hOleaut32;
44 static HRESULT (WINAPI *pVarUdateFromDate)(DATE,ULONG,UDATE*);
45 static HRESULT (WINAPI *pVarDateFromUdate)(UDATE*,ULONG,DATE*);
46 static INT (WINAPI *pSystemTimeToVariantTime)(LPSYSTEMTIME,double*);
47 static INT (WINAPI *pVariantTimeToSystemTime)(double,LPSYSTEMTIME);
48 static INT (WINAPI *pDosDateTimeToVariantTime)(USHORT,USHORT,double*);
49 static INT (WINAPI *pVariantTimeToDosDateTime)(double,USHORT*,USHORT *);
51 static const WCHAR sz12[] = {'1','2','\0'};
52 /* the strings are localized */
53 static WCHAR sz12_false[32];
54 static WCHAR sz12_true[32];
56 /* Get a conversion function ptr, return if function not available */
57 #define CHECKPTR(func) p##func = (void*)GetProcAddress(hOleaut32, #func); \
58 if (!p##func) { win_skip("function " # func " not available, not testing it\n"); return; }
60 /* Have IRecordInfo data type? */
61 static int HAVE_OLEAUT32_RECORD = 0;
62 /* Have I8/UI8 data type? */
63 static int HAVE_OLEAUT32_I8 = 0;
64 /* Is this an ancient version with support for only I2/I4/R4/R8/DATE? */
65 static int IS_ANCIENT = 0;
67 /* When comparing floating point values we cannot expect an exact match
68 * because the rounding errors depend on the exact algorithm.
70 #define EQ_DOUBLE(a,b) (fabs((a)-(b)) / (1.0+fabs(a)+fabs(b)) < 1e-14)
71 #define EQ_FLOAT(a,b) (fabs((a)-(b)) / (1.0+fabs(a)+fabs(b)) < 1e-7)
73 #define SKIPTESTS(a) if((a > VT_CLSID+10) && (a < VT_BSTR_BLOB-10)) continue
75 /* Allow our test macros to work for VT_NULL and VT_EMPTY too */
76 #define V_EMPTY(v) V_I4(v)
77 #define V_NULL(v) V_I4(v)
79 /* Size constraints for overflow tests */
81 #define I1_MIN ((-I1_MAX)-1)
85 #define I2_MIN ((-I2_MAX)-1)
86 #define UI2_MAX 0xffff
88 #define I4_MAX 0x7fffffff
89 #define I4_MIN ((-I4_MAX)-1)
90 #define UI4_MAX 0xffffffff
92 #define I8_MAX (((LONGLONG)I4_MAX << 32) | UI4_MAX)
93 #define I8_MIN ((-I8_MAX)-1)
94 #define UI8_MAX (((ULONGLONG)UI4_MAX << 32) | UI4_MAX)
96 #define DATE_MAX 2958465
97 #define DATE_MIN -657434
98 #define R4_MAX FLT_MAX
99 #define R4_MIN FLT_MIN
100 #define R8_MAX DBL_MAX
101 #define R8_MIN DBL_MIN
103 static void init(void)
108 res = VarBstrFromBool(VARIANT_TRUE, LANG_USER_DEFAULT, VAR_LOCALBOOL, &bstr);
109 ok(res == S_OK && (lstrlenW(bstr) > 0),
110 "Expected localized string for 'True'\n");
111 /* lstrcpyW / lstrcatW do not work on win95 */
112 memcpy(sz12_true, sz12, sizeof(sz12));
113 if (bstr) memcpy(&sz12_true[2], bstr, SysStringByteLen(bstr) + sizeof(WCHAR));
116 res = VarBstrFromBool(VARIANT_FALSE, LANG_USER_DEFAULT, VAR_LOCALBOOL, &bstr);
117 ok(res == S_OK && (lstrlenW(bstr) > 0),
118 "Expected localized string for 'False'\n");
119 memcpy(sz12_false, sz12, sizeof(sz12));
120 if (bstr) memcpy(&sz12_false[2], bstr, SysStringByteLen(bstr) + sizeof(WCHAR));
123 hOleaut32 = GetModuleHandle("oleaut32.dll");
125 /* Is a given function exported from oleaut32? */
126 #define HAVE_FUNC(func) ((void*)GetProcAddress(hOleaut32, #func) != NULL)
128 HAVE_OLEAUT32_I8 = HAVE_FUNC(VarI8FromI1);
129 if (!HAVE_OLEAUT32_I8)
130 skip("No support for I8 and UI8 data types\n");
132 HAVE_OLEAUT32_RECORD = HAVE_FUNC(SafeArraySetRecordInfo);
133 IS_ANCIENT = (!HAVE_FUNC(VarI1FromI2));
138 /* Functions to set a DECIMAL */
139 static void setdec(DECIMAL* dec, BYTE scl, BYTE sgn, ULONG hi32, ULONG64 lo64)
141 S(U(*dec)).scale = scl;
142 S(U(*dec)).sign = sgn;
144 U1(*dec).Lo64 = lo64;
147 static void setdec64(DECIMAL* dec, BYTE scl, BYTE sgn, ULONG hi32, ULONG mid32, ULONG lo32)
149 S(U(*dec)).scale = scl;
150 S(U(*dec)).sign = sgn;
152 S1(U1(*dec)).Mid32 = mid32;
153 S1(U1(*dec)).Lo32 = lo32;
156 static inline int strcmpW( const WCHAR *str1, const WCHAR *str2 )
158 while (*str1 && (*str1 == *str2)) { str1++; str2++; }
159 return *str1 - *str2;
162 /* return the string text of a given variant type */
163 static char vtstr_buffer[16][256];
164 static int vtstr_current=0;
165 static const char *vtstr(int x)
168 #define CASE(vt) case VT_##vt: return #vt
207 CASE(STREAMED_OBJECT);
212 CASE(VERSIONED_STREAM);
221 return "VT_BSTR_BLOB/VT_ILLEGALMASKED/VT_TYPEMASK";
224 vtstr_current %= sizeof(vtstr_buffer)/sizeof(*vtstr_buffer);
225 sprintf(vtstr_buffer[vtstr_current], "unknown variant type %d", x);
226 return vtstr_buffer[vtstr_current++];
230 static const char *variantstr( const VARIANT *var )
232 vtstr_current %= sizeof(vtstr_buffer)/sizeof(*vtstr_buffer);
236 sprintf( vtstr_buffer[vtstr_current], "VT_I1(%d)", V_I1(var) ); break;
238 sprintf( vtstr_buffer[vtstr_current], "VT_I2(%d)", V_I2(var) ); break;
240 sprintf( vtstr_buffer[vtstr_current], "VT_I4(%d)", V_I4(var) ); break;
242 sprintf( vtstr_buffer[vtstr_current], "VT_INT(%d)", V_INT(var) ); break;
244 sprintf( vtstr_buffer[vtstr_current], "VT_I8(%x%08x)", (UINT)(V_I8(var) >> 32), (UINT)V_I8(var) ); break;
246 sprintf( vtstr_buffer[vtstr_current], "VT_UI8(%x%08x)", (UINT)(V_UI8(var) >> 32), (UINT)V_UI8(var) ); break;
248 sprintf( vtstr_buffer[vtstr_current], "VT_R4(%g)", V_R4(var) ); break;
250 sprintf( vtstr_buffer[vtstr_current], "VT_R8(%g)", V_R8(var) ); break;
252 sprintf( vtstr_buffer[vtstr_current], "VT_UI1(%u)", V_UI1(var) ); break;
254 sprintf( vtstr_buffer[vtstr_current], "VT_UI2(%u)", V_UI2(var) ); break;
256 sprintf( vtstr_buffer[vtstr_current], "VT_UI4(%u)", V_UI4(var) ); break;
258 sprintf( vtstr_buffer[vtstr_current], "VT_UINT(%d)", V_UINT(var) ); break;
260 sprintf( vtstr_buffer[vtstr_current], "VT_CY(%x%08x)", S(V_CY(var)).Hi, S(V_CY(var)).Lo ); break;
262 sprintf( vtstr_buffer[vtstr_current], "VT_DATE(%g)", V_DATE(var) ); break;
264 return vtstr(V_VT(var));
266 return vtstr_buffer[vtstr_current++];
269 static BOOL is_expected_variant( const VARIANT *result, const VARIANT *expected )
271 if (V_VT(result) != V_VT(expected)) return FALSE;
272 switch(V_VT(expected))
278 #define CASE(vt) case VT_##vt: return (V_##vt(result) == V_##vt(expected))
293 return EQ_FLOAT(V_DATE(result), V_DATE(expected));
295 return EQ_FLOAT(V_R4(result), V_R4(expected));
297 return EQ_FLOAT(V_R8(result), V_R8(expected));
299 return (V_CY(result).int64 == V_CY(expected).int64);
301 return !lstrcmpW( V_BSTR(result), V_BSTR(expected) );
303 return !memcmp( &V_DECIMAL(result), &V_DECIMAL(expected), sizeof(DECIMAL) );
305 ok(0, "unhandled variant type %s\n",vtstr(V_VT(expected)));
310 static void test_var_call1( int line, HRESULT (WINAPI *func)(LPVARIANT,LPVARIANT),
311 VARIANT *arg, VARIANT *expected )
313 VARIANT old_arg = *arg;
317 memset( &result, 0, sizeof(result) );
318 hres = func( arg, &result );
319 ok_(__FILE__,line)( hres == S_OK, "wrong result %x\n", hres );
321 ok_(__FILE__,line)( is_expected_variant( &result, expected ),
322 "got %s expected %s\n", variantstr(&result), variantstr(expected) );
323 ok_(__FILE__,line)( is_expected_variant( arg, &old_arg ), "Modified argument %s / %s\n",
324 variantstr(&old_arg), variantstr(arg));
325 VariantClear( &result );
328 static void test_var_call2( int line, HRESULT (WINAPI *func)(LPVARIANT,LPVARIANT,LPVARIANT),
329 VARIANT *left, VARIANT *right, VARIANT *expected )
331 VARIANT old_left = *left, old_right = *right;
335 memset( &result, 0, sizeof(result) );
336 hres = func( left, right, &result );
337 ok_(__FILE__,line)( hres == S_OK, "wrong result %x\n", hres );
339 ok_(__FILE__,line)( is_expected_variant( &result, expected ),
340 "got %s expected %s\n", variantstr(&result), variantstr(expected) );
341 ok_(__FILE__,line)( is_expected_variant( left, &old_left ), "Modified left argument %s / %s\n",
342 variantstr(&old_left), variantstr(left));
343 ok_(__FILE__,line)( is_expected_variant( right, &old_right ), "Modified right argument %s / %s\n",
344 variantstr(&old_right), variantstr(right));
345 VariantClear( &result );
348 static int strcmp_wa(const WCHAR *strw, const char *stra)
351 MultiByteToWideChar(CP_ACP, 0, stra, -1, buf, sizeof(buf)/sizeof(buf[0]));
352 return lstrcmpW(strw, buf);
355 #define test_bstr_var(a,b) _test_bstr_var(__LINE__,a,b)
356 static void _test_bstr_var(unsigned line, const VARIANT *v, const char *str)
358 ok_(__FILE__,line)(V_VT(v) == VT_BSTR, "unexpected vt=%d\n", V_VT(v));
359 if(V_VT(v) == VT_BSTR)
360 ok(!strcmp_wa(V_BSTR(v), str), "v=%s, expected %s\n", wine_dbgstr_w(V_BSTR(v)), str);
363 static void test_VariantInit(void)
367 /* Test that VariantInit() only sets the type */
368 memset(&v1, -1, sizeof(v1));
370 V_VT(&v2) = VT_EMPTY;
372 ok(!memcmp(&v1, &v2, sizeof(v1)), "VariantInit() set extra fields\n");
375 /* All possible combinations of extra V_VT() flags */
376 static const VARTYPE ExtraFlags[16] =
385 VT_VECTOR|VT_RESERVED,
386 VT_VECTOR|VT_ARRAY|VT_BYREF,
387 VT_VECTOR|VT_ARRAY|VT_RESERVED,
388 VT_VECTOR|VT_BYREF|VT_RESERVED,
389 VT_VECTOR|VT_ARRAY|VT_BYREF|VT_RESERVED,
391 VT_ARRAY|VT_RESERVED,
392 VT_ARRAY|VT_BYREF|VT_RESERVED,
393 VT_BYREF|VT_RESERVED,
396 /* Determine if a vt is valid for VariantClear() */
397 static int IsValidVariantClearVT(VARTYPE vt, VARTYPE extraFlags)
401 /* Only the following flags/types are valid */
402 if ((vt <= VT_LPWSTR || vt == VT_RECORD || vt == VT_CLSID) &&
404 (vt < (VARTYPE)24 || vt > (VARTYPE)31) &&
405 (!(extraFlags & (VT_BYREF|VT_ARRAY)) || vt > VT_NULL) &&
406 (extraFlags == 0 || extraFlags == VT_BYREF || extraFlags == VT_ARRAY ||
407 extraFlags == (VT_ARRAY|VT_BYREF)))
410 if ((vt == VT_RECORD && !HAVE_OLEAUT32_RECORD) ||
411 ((vt == VT_I8 || vt == VT_UI8) && !HAVE_OLEAUT32_I8))
412 ret = 0; /* Old versions of oleaut32 */
418 IUnknown IUnknown_iface;
421 } test_VariantClearImpl;
423 static inline test_VariantClearImpl *impl_from_IUnknown(IUnknown *iface)
425 return CONTAINING_RECORD(iface, test_VariantClearImpl, IUnknown_iface);
428 static HRESULT WINAPI VC_QueryInterface(LPUNKNOWN iface,REFIID riid,LPVOID *ppobj)
430 test_VariantClearImpl *This = impl_from_IUnknown(iface);
432 return E_NOINTERFACE;
435 static ULONG WINAPI VC_AddRef(LPUNKNOWN iface) {
436 test_VariantClearImpl *This = impl_from_IUnknown(iface);
438 return InterlockedIncrement(&This->ref);
441 static ULONG WINAPI VC_Release(LPUNKNOWN iface) {
442 test_VariantClearImpl *This = impl_from_IUnknown(iface);
443 /* static class, won't be freed */
445 return InterlockedDecrement(&This->ref);
448 static const IUnknownVtbl test_VariantClear_vtbl = {
454 static test_VariantClearImpl test_myVariantClearImpl = {{&test_VariantClear_vtbl}, 1, 0};
456 static void test_VariantClear(void)
465 /* Crashes: Native does not test input for NULL, so neither does Wine */
469 /* Only the type field is set, to VT_EMPTY */
472 hres = VariantClear(&v);
473 ok((hres == S_OK && V_VT(&v) == VT_EMPTY) ||
474 (IS_ANCIENT && hres == DISP_E_BADVARTYPE && V_VT(&v) == VT_UI4),
475 "VariantClear: Type set to %d, res %08x\n", V_VT(&v), hres);
476 ok(V_UI4(&v) == ~0u, "VariantClear: Overwrote value\n");
478 /* Test all possible V_VT values.
479 * Also demonstrates that null pointers in 'v' are not dereferenced.
480 * Individual variant tests should test VariantClear() with non-NULL values.
482 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]) && !IS_ANCIENT; i++)
486 for (vt = 0; vt <= VT_BSTR_BLOB; vt++)
488 HRESULT hExpected = DISP_E_BADVARTYPE;
492 memset(&v, 0, sizeof(v));
493 V_VT(&v) = vt | ExtraFlags[i];
495 hres = VariantClear(&v);
497 if (IsValidVariantClearVT(vt, ExtraFlags[i]))
500 ok(hres == hExpected, "VariantClear: expected 0x%X, got 0x%X for vt %d | 0x%X\n",
501 hExpected, hres, vt, ExtraFlags[i]);
505 /* Some BYREF tests with non-NULL ptrs */
510 V_VT(&v) = VT_VARIANT | VT_BYREF;
511 V_VARIANTREF(&v) = &v2;
513 hres = VariantClear(&v);
514 ok(hres == S_OK, "ret %08x\n", hres);
515 ok(V_VT(&v) == 0, "vt %04x\n", V_VT(&v));
516 ok(V_VARIANTREF(&v) == &v2, "variant ref %p\n", V_VARIANTREF(&v2));
517 ok(V_VT(&v2) == VT_I4, "vt %04x\n", V_VT(&v2));
518 ok(V_I4(&v2) == 0x1234, "i4 %04x\n", V_I4(&v2));
522 V_VT(&v) = VT_I4 | VT_BYREF;
525 hres = VariantClear(&v);
526 ok(hres == S_OK, "ret %08x\n", hres);
527 ok(V_VT(&v) == 0, "vt %04x\n", V_VT(&v));
528 ok(V_I4REF(&v) == &i4, "i4 ref %p\n", V_I4REF(&v2));
529 ok(i4 == 0x4321, "i4 changed %08x\n", i4);
533 V_VT(&v) = VT_UNKNOWN;
534 V_UNKNOWN(&v) = &test_myVariantClearImpl.IUnknown_iface;
535 test_myVariantClearImpl.events = 0;
536 hres = VariantClear(&v);
537 ok(hres == S_OK, "ret %08x\n", hres);
538 ok(V_VT(&v) == 0, "vt %04x\n", V_VT(&v));
539 ok(V_UNKNOWN(&v) == &test_myVariantClearImpl.IUnknown_iface, "unknown %p\n", V_UNKNOWN(&v));
540 /* Check that Release got called, but nothing else */
541 ok(test_myVariantClearImpl.events == 0x4, "Unexpected call. events %08x\n", test_myVariantClearImpl.events);
544 punk = &test_myVariantClearImpl.IUnknown_iface;
545 V_VT(&v) = VT_UNKNOWN | VT_BYREF;
546 V_UNKNOWNREF(&v) = &punk;
547 test_myVariantClearImpl.events = 0;
548 hres = VariantClear(&v);
549 ok(hres == S_OK, "ret %08x\n", hres);
550 ok(V_VT(&v) == 0, "vt %04x\n", V_VT(&v));
551 ok(V_UNKNOWNREF(&v) == &punk, "unknown ref %p\n", V_UNKNOWNREF(&v));
552 /* Check that nothing got called */
553 ok(test_myVariantClearImpl.events == 0, "Unexpected call. events %08x\n", test_myVariantClearImpl.events);
556 V_VT(&v) = VT_DISPATCH;
557 V_DISPATCH(&v) = (IDispatch*)&test_myVariantClearImpl;
558 test_myVariantClearImpl.events = 0;
559 hres = VariantClear(&v);
560 ok(hres == S_OK, "ret %08x\n", hres);
561 ok(V_VT(&v) == 0, "vt %04x\n", V_VT(&v));
562 ok(V_DISPATCH(&v) == (IDispatch*)&test_myVariantClearImpl, "dispatch %p\n", V_DISPATCH(&v));
563 /* Check that Release got called, but nothing else */
564 ok(test_myVariantClearImpl.events == 0x4, "Unexpected call. events %08x\n", test_myVariantClearImpl.events);
567 punk = &test_myVariantClearImpl.IUnknown_iface;
568 V_VT(&v) = VT_DISPATCH | VT_BYREF;
569 V_DISPATCHREF(&v) = (IDispatch**)&punk;
570 test_myVariantClearImpl.events = 0;
571 hres = VariantClear(&v);
572 ok(hres == S_OK, "ret %08x\n", hres);
573 ok(V_VT(&v) == 0, "vt %04x\n", V_VT(&v));
574 ok(V_DISPATCHREF(&v) == (IDispatch**)&punk, "dispatch ref %p\n", V_DISPATCHREF(&v));
575 /* Check that nothing got called */
576 ok(test_myVariantClearImpl.events == 0, "Unexpected call. events %08x\n", test_myVariantClearImpl.events);
579 static void test_VariantCopy(void)
581 VARIANTARG vSrc, vDst;
584 HRESULT hres, hExpected;
586 /* Establish that the failure/other cases are dealt with. Individual tests
587 * for each type should verify that data is copied correctly, references
592 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]) && !IS_ANCIENT; i++)
594 for (vt = 0; vt <= VT_BSTR_BLOB; vt++)
598 memset(&vSrc, 0, sizeof(vSrc));
599 V_VT(&vSrc) = vt | ExtraFlags[i];
601 hExpected = DISP_E_BADVARTYPE;
602 /* src is allowed to be a VT_CLSID */
603 if (vt != VT_CLSID && IsValidVariantClearVT(vt, ExtraFlags[i]))
606 hres = VariantCopy(&vSrc, &vSrc);
608 ok(hres == hExpected,
609 "Copy(src==dst): expected 0x%X, got 0x%X for src==dest vt %d|0x%X\n",
610 hExpected, hres, vt, ExtraFlags[i]);
614 /* Test that if VariantClear() fails on dest, the function fails. This also
615 * shows that dest is in fact cleared and not just overwritten
617 memset(&vSrc, 0, sizeof(vSrc));
618 V_VT(&vSrc) = VT_UI1;
620 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]) && !IS_ANCIENT; i++)
622 for (vt = 0; vt <= VT_BSTR_BLOB; vt++)
626 hExpected = DISP_E_BADVARTYPE;
628 memset(&vDst, 0, sizeof(vDst));
629 V_VT(&vDst) = vt | ExtraFlags[i];
631 if (IsValidVariantClearVT(vt, ExtraFlags[i]))
634 hres = VariantCopy(&vDst, &vSrc);
636 ok(hres == hExpected,
637 "Copy(bad dst): expected 0x%X, got 0x%X for dest vt %d|0x%X\n",
638 hExpected, hres, vt, ExtraFlags[i]);
640 ok(V_VT(&vDst) == VT_UI1,
641 "Copy(bad dst): expected vt = VT_UI1, got %d\n", V_VT(&vDst));
645 /* Test that VariantClear() checks vSrc for validity before copying */
646 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]) && !IS_ANCIENT; i++)
648 for (vt = 0; vt <= VT_BSTR_BLOB; vt++)
652 hExpected = DISP_E_BADVARTYPE;
654 memset(&vDst, 0, sizeof(vDst));
655 V_VT(&vDst) = VT_EMPTY;
657 memset(&vSrc, 0, sizeof(vSrc));
658 V_VT(&vSrc) = vt | ExtraFlags[i];
660 /* src is allowed to be a VT_CLSID */
661 if (vt != VT_CLSID && IsValidVariantClearVT(vt, ExtraFlags[i]))
664 hres = VariantCopy(&vDst, &vSrc);
666 ok(hres == hExpected,
667 "Copy(bad src): expected 0x%X, got 0x%X for src vt %d|0x%X\n",
668 hExpected, hres, vt, ExtraFlags[i]);
671 ok(V_VT(&vDst) == (vt|ExtraFlags[i]),
672 "Copy(bad src): expected vt = %d, got %d\n",
673 vt | ExtraFlags[i], V_VT(&vDst));
679 /* Test that copying a NULL BSTR results in an empty BSTR */
680 memset(&vDst, 0, sizeof(vDst));
681 V_VT(&vDst) = VT_EMPTY;
682 memset(&vSrc, 0, sizeof(vSrc));
683 V_VT(&vSrc) = VT_BSTR;
684 hres = VariantCopy(&vDst, &vSrc);
685 ok(hres == S_OK, "Copy(NULL BSTR): Failed to copy a NULL BSTR\n");
688 ok((V_VT(&vDst) == VT_BSTR) && V_BSTR(&vDst),
689 "Copy(NULL BSTR): should have non-NULL result\n");
690 if ((V_VT(&vDst) == VT_BSTR) && V_BSTR(&vDst))
692 ok(*V_BSTR(&vDst) == 0, "Copy(NULL BSTR): result not empty\n");
698 /* Determine if a vt is valid for VariantCopyInd() */
699 static int IsValidVariantCopyIndVT(VARTYPE vt, VARTYPE extraFlags)
703 if ((extraFlags & VT_ARRAY) ||
704 (vt > VT_NULL && vt != (VARTYPE)15 && vt < VT_VOID &&
705 !(extraFlags & (VT_VECTOR|VT_RESERVED))))
712 static void test_VariantCopyInd(void)
714 VARIANTARG vSrc, vDst, vRef, vRef2;
718 HRESULT hres, hExpected;
720 memset(buffer, 0, sizeof(buffer));
723 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]) && !IS_ANCIENT; i++)
725 if (ExtraFlags[i] & VT_ARRAY)
726 continue; /* Native crashes on NULL safearray */
728 for (vt = 0; vt <= VT_BSTR_BLOB; vt++)
732 memset(&vSrc, 0, sizeof(vSrc));
733 V_VT(&vSrc) = vt | ExtraFlags[i];
735 hExpected = DISP_E_BADVARTYPE;
736 if (!(ExtraFlags[i] & VT_BYREF))
738 /* if src is not by-reference, acts as VariantCopy() */
739 if (vt != VT_CLSID && IsValidVariantClearVT(vt, ExtraFlags[i]))
744 if (vt == VT_SAFEARRAY || vt == VT_BSTR || vt == VT_UNKNOWN ||
745 vt == VT_DISPATCH || vt == VT_RECORD)
746 continue; /* Need valid ptrs for deep copies */
748 V_BYREF(&vSrc) = &buffer;
749 hExpected = E_INVALIDARG;
751 if ((vt == VT_I8 || vt == VT_UI8) &&
752 ExtraFlags[i] == VT_BYREF)
754 if (HAVE_OLEAUT32_I8)
755 hExpected = S_OK; /* Only valid if I8 is a known type */
757 else if (IsValidVariantCopyIndVT(vt, ExtraFlags[i]))
761 hres = VariantCopyInd(&vSrc, &vSrc);
763 ok(hres == hExpected,
764 "CopyInd(src==dst): expected 0x%X, got 0x%X for src==dst vt %d|0x%X\n",
765 hExpected, hres, vt, ExtraFlags[i]);
770 memset(&vSrc, 0, sizeof(vSrc));
771 V_VT(&vSrc) = VT_UI1|VT_BYREF;
772 V_BYREF(&vSrc) = &buffer;
774 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]) && !IS_ANCIENT; i++)
776 for (vt = 0; vt <= VT_BSTR_BLOB; vt++)
780 memset(&vDst, 0, sizeof(vDst));
781 V_VT(&vDst) = vt | ExtraFlags[i];
783 hExpected = DISP_E_BADVARTYPE;
785 if (IsValidVariantClearVT(vt, ExtraFlags[i]))
788 hres = VariantCopyInd(&vDst, &vSrc);
790 ok(hres == hExpected,
791 "CopyInd(bad dst): expected 0x%X, got 0x%X for dst vt %d|0x%X\n",
792 hExpected, hres, vt, ExtraFlags[i]);
794 ok(V_VT(&vDst) == VT_UI1,
795 "CopyInd(bad dst): expected vt = VT_UI1, got %d\n", V_VT(&vDst));
800 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]) && !IS_ANCIENT; i++)
802 if (ExtraFlags[i] & VT_ARRAY)
803 continue; /* Native crashes on NULL safearray */
805 for (vt = 0; vt <= VT_BSTR_BLOB; vt++)
809 memset(&vDst, 0, sizeof(vDst));
810 V_VT(&vDst) = VT_EMPTY;
812 memset(&vSrc, 0, sizeof(vSrc));
813 V_VT(&vSrc) = vt | ExtraFlags[i];
815 hExpected = DISP_E_BADVARTYPE;
816 if (!(ExtraFlags[i] & VT_BYREF))
818 /* if src is not by-reference, acts as VariantCopy() */
819 if (vt != VT_CLSID && IsValidVariantClearVT(vt, ExtraFlags[i]))
824 if (vt == VT_SAFEARRAY || vt == VT_BSTR || vt == VT_UNKNOWN ||
825 vt == VT_DISPATCH || vt == VT_RECORD)
826 continue; /* Need valid ptrs for deep copies, see vartype.c */
828 V_BYREF(&vSrc) = &buffer;
830 hExpected = E_INVALIDARG;
832 if ((vt == VT_I8 || vt == VT_UI8) &&
833 ExtraFlags[i] == VT_BYREF)
835 if (HAVE_OLEAUT32_I8)
836 hExpected = S_OK; /* Only valid if I8 is a known type */
838 else if (IsValidVariantCopyIndVT(vt, ExtraFlags[i]))
842 hres = VariantCopyInd(&vDst, &vSrc);
844 ok(hres == hExpected,
845 "CopyInd(bad src): expected 0x%X, got 0x%X for src vt %d|0x%X\n",
846 hExpected, hres, vt, ExtraFlags[i]);
849 if (vt == VT_VARIANT && ExtraFlags[i] == VT_BYREF)
851 /* Type of vDst should be the type of the referenced variant.
852 * Since we set the buffer to all zeros, its type should be
855 ok(V_VT(&vDst) == VT_EMPTY,
856 "CopyInd(bad src): expected dst vt = VT_EMPTY, got %d|0x%X\n",
857 V_VT(&vDst) & VT_TYPEMASK, V_VT(&vDst) & ~VT_TYPEMASK);
861 ok(V_VT(&vDst) == (vt|(ExtraFlags[i] & ~VT_BYREF)),
862 "CopyInd(bad src): expected dst vt = %d|0x%X, got %d|0x%X\n",
863 vt, ExtraFlags[i] & ~VT_BYREF,
864 V_VT(&vDst) & VT_TYPEMASK, V_VT(&vDst) & ~VT_TYPEMASK);
871 /* By-reference variants are dereferenced */
872 V_VT(&vRef) = VT_UI1;
874 V_VT(&vSrc) = VT_VARIANT|VT_BYREF;
875 V_VARIANTREF(&vSrc) = &vRef;
878 hres = VariantCopyInd(&vDst, &vSrc);
879 ok(hres == S_OK, "VariantCopyInd failed: 0x%08x\n", hres);
880 ok(V_VT(&vDst) == VT_UI1 && V_UI1(&vDst) == 0x77,
881 "CopyInd(deref): expected dst vt = VT_UI1, val 0x77, got %d|0x%X, 0x%2X\n",
882 V_VT(&vDst) & VT_TYPEMASK, V_VT(&vDst) & ~VT_TYPEMASK, V_UI1(&vDst));
884 /* By-reference variant to a by-reference type succeeds */
885 V_VT(&vRef) = VT_UI1|VT_BYREF;
886 V_UI1REF(&vRef) = buffer; buffer[0] = 0x88;
887 V_VT(&vSrc) = VT_VARIANT|VT_BYREF;
888 V_VARIANTREF(&vSrc) = &vRef;
891 hres = VariantCopyInd(&vDst, &vSrc);
892 ok(hres == S_OK, "VariantCopyInd failed: 0x%08x\n", hres);
893 ok(V_VT(&vDst) == VT_UI1 && V_UI1(&vDst) == 0x88,
894 "CopyInd(deref): expected dst vt = VT_UI1, val 0x77, got %d|0x%X, 0x%2X\n",
895 V_VT(&vDst) & VT_TYPEMASK, V_VT(&vDst) & ~VT_TYPEMASK, V_UI1(&vDst));
897 /* But a by-reference variant to a by-reference variant fails */
898 V_VT(&vRef2) = VT_UI1;
899 V_UI1(&vRef2) = 0x77;
900 V_VT(&vRef) = VT_VARIANT|VT_BYREF;
901 V_VARIANTREF(&vRef) = &vRef2;
902 V_VT(&vSrc) = VT_VARIANT|VT_BYREF;
903 V_VARIANTREF(&vSrc) = &vRef;
906 hres = VariantCopyInd(&vDst, &vSrc);
907 ok(hres == E_INVALIDARG,
908 "CopyInd(ref->ref): expected E_INVALIDARG, got 0x%08x\n", hres);
911 static HRESULT (WINAPI *pVarParseNumFromStr)(OLECHAR*,LCID,ULONG,NUMPARSE*,BYTE*);
913 /* Macros for converting and testing the result of VarParseNumFromStr */
916 static HRESULT convert_str( const char *str, INT dig, ULONG flags,
917 NUMPARSE *np, BYTE rgb[128], LCID lcid )
920 MultiByteToWideChar( CP_ACP,0, str, -1, buff, sizeof(buff)/sizeof(WCHAR) );
921 memset( rgb, FAILDIG, 128 );
922 memset( np, 255, sizeof(*np) );
924 np->dwInFlags = flags;
925 return pVarParseNumFromStr( buff, lcid, LOCALE_NOUSEROVERRIDE, np, rgb);
928 static void expect_NumFromStr( int line, HRESULT hres, NUMPARSE *np, INT a, ULONG b, ULONG c,
929 INT d, INT e, INT f )
931 if (hres == (HRESULT)S_OK)
933 ok_(__FILE__,line)(np->cDig == a, "Expected cDig = %d, got %d\n", a, np->cDig);
934 ok_(__FILE__,line)(np->dwInFlags == b, "Expected dwInFlags = 0x%x, got 0x%x\n", b, np->dwInFlags);
935 ok_(__FILE__,line)(np->dwOutFlags == c, "Expected dwOutFlags = 0x%x, got 0x%x\n", c, np->dwOutFlags);
936 ok_(__FILE__,line)(np->cchUsed == d, "Expected cchUsed = %d, got %d\n", d, np->cchUsed);
937 ok_(__FILE__,line)(np->nBaseShift == e, "Expected nBaseShift = %d, got %d\n", e, np->nBaseShift);
938 ok_(__FILE__,line)(np->nPwr10 == f, "Expected nPwr10 = %d, got %d\n", f, np->nPwr10);
942 #define CONVERTN(str,dig,flags) hres = convert_str( str, dig, flags, &np, rgb, lcid )
943 #define CONVERT(str,flags) CONVERTN(str,sizeof(rgb),flags)
944 #define EXPECT(a,b,c,d,e,f) expect_NumFromStr( __LINE__, hres, &np, a, b, c, d, e, f )
945 #define EXPECTRGB(a,b) ok(rgb[a] == b, "Digit[%d], expected %d, got %d\n", a, b, rgb[a])
946 #define EXPECTFAIL ok(hres == (HRESULT)DISP_E_TYPEMISMATCH, "Call succeeded, hres = %08x\n", hres)
947 #define EXPECT2(a,b) EXPECTRGB(0,a); EXPECTRGB(1,b)
949 static void test_VarParseNumFromStr(void)
952 /* Ensure all tests are using the same locale characters for '$', ',' etc */
953 LCID lcid = MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT);
959 CHECKPTR(VarParseNumFromStr);
961 /* Consume a single digit */
966 /* cDig is not literal digits - zeros are suppressed and nPwr10 is increased */
969 /* Note: Win32 writes the trailing zeros if they are within cDig's limits,
970 * but then excludes them from the returned cDig count.
971 * In our implementation we don't bother writing them at all.
975 /* if cDig is too small and numbers follow, sets INEXACT */
977 EXPECT(1,0,NUMPRS_INEXACT,2,0,1);
980 /* Strips leading zeros */
985 /* Strips leading zeros */
991 /* Fails on non digits */
994 EXPECTRGB(0,FAILDIG);
996 /** NUMPRS_LEADING_WHITE/NUMPRS_TRAILING_WHITE **/
998 /* Without flag, fails on whitespace */
1001 EXPECTRGB(0,FAILDIG);
1004 /* With flag, consumes whitespace */
1005 CONVERT(" 0", NUMPRS_LEADING_WHITE);
1006 EXPECT(1,NUMPRS_LEADING_WHITE,NUMPRS_LEADING_WHITE,2,0,0);
1009 /* Test TAB once, then assume it acts as space for all cases */
1010 CONVERT("\t0", NUMPRS_LEADING_WHITE);
1011 EXPECT(1,NUMPRS_LEADING_WHITE,NUMPRS_LEADING_WHITE,2,0,0);
1015 /* Doesn't pick up trailing whitespace without flag */
1017 EXPECT(1,0,0,1,0,0);
1020 /* With flag, consumes trailing whitespace */
1021 CONVERT("0 ", NUMPRS_TRAILING_WHITE);
1022 EXPECT(1,NUMPRS_TRAILING_WHITE,NUMPRS_TRAILING_WHITE,2,0,0);
1025 /* Leading flag only consumes leading */
1026 CONVERT(" 0 ", NUMPRS_LEADING_WHITE);
1027 EXPECT(1,NUMPRS_LEADING_WHITE,NUMPRS_LEADING_WHITE,2,0,0);
1030 /* Both flags consumes both */
1031 CONVERT(" 0 ", NUMPRS_LEADING_WHITE|NUMPRS_TRAILING_WHITE);
1032 EXPECT(1,NUMPRS_LEADING_WHITE|NUMPRS_TRAILING_WHITE,NUMPRS_LEADING_WHITE|NUMPRS_TRAILING_WHITE,3,0,0);
1035 /** NUMPRS_LEADING_PLUS/NUMPRS_TRAILING_PLUS **/
1037 /* Without flag, fails on + */
1040 EXPECTRGB(0,FAILDIG);
1042 /* With flag, consumes + */
1043 CONVERT("+0", NUMPRS_LEADING_PLUS);
1044 EXPECT(1,NUMPRS_LEADING_PLUS,NUMPRS_LEADING_PLUS,2,0,0);
1047 /* Without flag, doesn't consume trailing + */
1049 EXPECT(1,0,0,1,0,0);
1052 /* With flag, consumes trailing + */
1053 CONVERT("0+", NUMPRS_TRAILING_PLUS);
1054 EXPECT(1,NUMPRS_TRAILING_PLUS,NUMPRS_TRAILING_PLUS,2,0,0);
1057 /* With leading flag, doesn't consume trailing + */
1058 CONVERT("+0+", NUMPRS_LEADING_PLUS);
1059 EXPECT(1,NUMPRS_LEADING_PLUS,NUMPRS_LEADING_PLUS,2,0,0);
1062 /* Trailing + doesn't get consumed if we specify both (unlike whitespace) */
1063 CONVERT("+0+", NUMPRS_LEADING_PLUS|NUMPRS_TRAILING_PLUS);
1064 EXPECT(1,NUMPRS_LEADING_PLUS|NUMPRS_TRAILING_PLUS,NUMPRS_LEADING_PLUS,2,0,0);
1067 /** NUMPRS_LEADING_MINUS/NUMPRS_TRAILING_MINUS **/
1069 /* Without flag, fails on - */
1072 EXPECTRGB(0,FAILDIG);
1074 /* With flag, consumes - */
1075 CONVERT("-0", NUMPRS_LEADING_MINUS);
1076 EXPECT(1,NUMPRS_LEADING_MINUS,NUMPRS_NEG|NUMPRS_LEADING_MINUS,2,0,0);
1079 /* Without flag, doesn't consume trailing - */
1081 EXPECT(1,0,0,1,0,0);
1084 /* With flag, consumes trailing - */
1085 CONVERT("0-", NUMPRS_TRAILING_MINUS);
1086 EXPECT(1,NUMPRS_TRAILING_MINUS,NUMPRS_NEG|NUMPRS_TRAILING_MINUS,2,0,0);
1089 /* With leading flag, doesn't consume trailing - */
1090 CONVERT("-0-", NUMPRS_LEADING_MINUS);
1091 EXPECT(1,NUMPRS_LEADING_MINUS,NUMPRS_NEG|NUMPRS_LEADING_MINUS,2,0,0);
1094 /* Trailing - doesn't get consumed if we specify both (unlike whitespace) */
1095 CONVERT("-0-", NUMPRS_LEADING_MINUS|NUMPRS_TRAILING_MINUS);
1096 EXPECT(1,NUMPRS_LEADING_MINUS|NUMPRS_TRAILING_MINUS,NUMPRS_NEG|NUMPRS_LEADING_MINUS,2,0,0);
1099 /** NUMPRS_HEX_OCT **/
1101 /* Could be hex, octal or decimal - With flag reads as decimal */
1102 CONVERT("0", NUMPRS_HEX_OCT);
1103 EXPECT(1,NUMPRS_HEX_OCT,0,1,0,0);
1106 /* Doesn't recognise hex in .asm syntax */
1107 CONVERT("0h", NUMPRS_HEX_OCT);
1108 EXPECT(1,NUMPRS_HEX_OCT,0,1,0,0);
1111 /* Doesn't fail with valid leading string but no digits */
1112 CONVERT("0x", NUMPRS_HEX_OCT);
1113 EXPECT(1,NUMPRS_HEX_OCT,0,1,0,0);
1116 /* Doesn't recognise hex format numbers at all! */
1117 CONVERT("0x0", NUMPRS_HEX_OCT);
1118 EXPECT(1,NUMPRS_HEX_OCT,0,1,0,0);
1121 /* Doesn't recognise plain hex digits either */
1122 CONVERT("FE", NUMPRS_HEX_OCT);
1124 EXPECTRGB(0,FAILDIG);
1127 CONVERT("0100", NUMPRS_HEX_OCT);
1128 EXPECT(1,NUMPRS_HEX_OCT,0,4,0,2);
1132 EXPECTRGB(3,FAILDIG);
1135 CONVERT("&HF800", NUMPRS_HEX_OCT);
1136 EXPECT(4,NUMPRS_HEX_OCT,0x40,6,4,0);
1141 EXPECTRGB(4,FAILDIG);
1143 /* VB hex lower case and leading zero */
1144 CONVERT("&h0abcdef", NUMPRS_HEX_OCT);
1145 EXPECT(6,NUMPRS_HEX_OCT,0x40,9,4,0);
1152 EXPECTRGB(6,FAILDIG);
1155 CONVERT("&O300", NUMPRS_HEX_OCT);
1156 EXPECT(3,NUMPRS_HEX_OCT,0x40,5,3,0);
1160 EXPECTRGB(3,FAILDIG);
1162 /* VB oct lower case and leading zero */
1163 CONVERT("&o0777", NUMPRS_HEX_OCT);
1164 EXPECT(3,NUMPRS_HEX_OCT,0x40,6,3,0);
1168 EXPECTRGB(3,FAILDIG);
1170 /* VB oct char bigger than 7 */
1171 CONVERT("&o128", NUMPRS_HEX_OCT);
1173 Native versions 2.x of oleaut32 allow this to succeed: later versions and Wine don't
1175 EXPECTRGB(0,FAILDIG);
1177 /** NUMPRS_PARENS **/
1179 /* Empty parens = error */
1180 CONVERT("()", NUMPRS_PARENS);
1182 EXPECTRGB(0,FAILDIG);
1184 /* With flag, trailing parens not consumed */
1185 CONVERT("0()", NUMPRS_PARENS);
1186 EXPECT(1,NUMPRS_PARENS,0,1,0,0);
1189 /* With flag, Number in parens made negative and parens consumed */
1190 CONVERT("(0)", NUMPRS_PARENS);
1191 EXPECT(1,NUMPRS_PARENS,NUMPRS_NEG|NUMPRS_PARENS,3,0,0);
1194 /** NUMPRS_THOUSANDS **/
1196 /* With flag, thousands sep. not needed */
1197 CONVERT("0", NUMPRS_THOUSANDS);
1198 EXPECT(1,NUMPRS_THOUSANDS,0,1,0,0);
1201 /* With flag, thousands sep. and following digits consumed */
1202 CONVERT("1,000", NUMPRS_THOUSANDS);
1203 EXPECT(1,NUMPRS_THOUSANDS,NUMPRS_THOUSANDS,5,0,3);
1206 /* With flag and decimal point, thousands sep. but not decimals consumed */
1207 CONVERT("1,000.0", NUMPRS_THOUSANDS);
1208 EXPECT(1,NUMPRS_THOUSANDS,NUMPRS_THOUSANDS,5,0,3);
1211 /** NUMPRS_CURRENCY **/
1213 /* Without flag, chokes on currency sign */
1216 EXPECTRGB(0,FAILDIG);
1218 /* With flag, consumes currency sign */
1219 CONVERT("$11", NUMPRS_CURRENCY);
1220 EXPECT(2,NUMPRS_CURRENCY,NUMPRS_CURRENCY,3,0,0);
1222 EXPECTRGB(2,FAILDIG);
1224 /* With flag only, doesn't consume decimal point */
1225 CONVERT("$11.1", NUMPRS_CURRENCY);
1226 EXPECT(2,NUMPRS_CURRENCY,NUMPRS_CURRENCY,3,0,0);
1228 EXPECTRGB(2,FAILDIG);
1230 /* With flag and decimal flag, consumes decimal point and following digits */
1231 CONVERT("$11.1", NUMPRS_CURRENCY|NUMPRS_DECIMAL);
1232 EXPECT(3,NUMPRS_CURRENCY|NUMPRS_DECIMAL,NUMPRS_CURRENCY|NUMPRS_DECIMAL,5,0,-1);
1235 EXPECTRGB(3,FAILDIG);
1237 /* Thousands flag can only be used with currency */
1238 CONVERT("$1,234", NUMPRS_CURRENCY|NUMPRS_THOUSANDS);
1239 EXPECT(4,NUMPRS_CURRENCY|NUMPRS_THOUSANDS,NUMPRS_CURRENCY|NUMPRS_THOUSANDS,6,0,0);
1243 EXPECTRGB(4,FAILDIG);
1245 /** NUMPRS_DECIMAL **/
1247 /* With flag, consumes decimal point */
1248 CONVERT("1.1", NUMPRS_DECIMAL);
1249 EXPECT(2,NUMPRS_DECIMAL,NUMPRS_DECIMAL,3,0,-1);
1251 EXPECTRGB(2,FAILDIG);
1253 /* With flag, consumes decimal point. Skipping the decimal part is not an error */
1254 CONVERT("1.", NUMPRS_DECIMAL);
1255 EXPECT(1,NUMPRS_DECIMAL,NUMPRS_DECIMAL,2,0,0);
1258 /* Consumes only one decimal point */
1259 CONVERT("1.1.", NUMPRS_DECIMAL);
1260 EXPECT(2,NUMPRS_DECIMAL,NUMPRS_DECIMAL,3,0,-1);
1262 EXPECTRGB(2,FAILDIG);
1264 /** NUMPRS_EXPONENT **/
1266 /* Without flag, doesn't consume exponent */
1268 EXPECT(1,0,0,1,0,0);
1271 /* With flag, consumes exponent */
1272 CONVERT("1e1", NUMPRS_EXPONENT);
1273 EXPECT(1,NUMPRS_EXPONENT,NUMPRS_EXPONENT,3,0,1);
1276 /* Negative exponents are accepted without flags */
1277 CONVERT("1e-1", NUMPRS_EXPONENT);
1278 EXPECT(1,NUMPRS_EXPONENT,NUMPRS_EXPONENT,4,0,-1);
1281 /* As are positive exponents and leading exponent 0s */
1282 CONVERT("1e+01", NUMPRS_EXPONENT);
1283 EXPECT(1,NUMPRS_EXPONENT,NUMPRS_EXPONENT,5,0,1);
1286 /* The same for zero exponents */
1287 CONVERT("1e0", NUMPRS_EXPONENT);
1288 EXPECT(1,NUMPRS_EXPONENT,NUMPRS_EXPONENT,3,0,0);
1291 /* Sign on a zero exponent doesn't matter */
1292 CONVERT("1e+0", NUMPRS_EXPONENT);
1293 EXPECT(1,NUMPRS_EXPONENT,NUMPRS_EXPONENT,4,0,0);
1296 CONVERT("1e-0", NUMPRS_EXPONENT);
1297 EXPECT(1,NUMPRS_EXPONENT,NUMPRS_EXPONENT,4,0,0);
1300 /* Doesn't consume a real number exponent */
1301 CONVERT("1e1.", NUMPRS_EXPONENT);
1302 EXPECT(1,NUMPRS_EXPONENT,NUMPRS_EXPONENT,3,0,1);
1305 /* Powers of 10 are calculated from the position of any decimal point */
1306 CONVERT("1.5e20", NUMPRS_EXPONENT|NUMPRS_DECIMAL);
1307 EXPECT(2,NUMPRS_EXPONENT|NUMPRS_DECIMAL,NUMPRS_EXPONENT|NUMPRS_DECIMAL,6,0,19);
1310 CONVERT("1.5e-20", NUMPRS_EXPONENT|NUMPRS_DECIMAL);
1311 EXPECT(2,NUMPRS_EXPONENT|NUMPRS_DECIMAL,NUMPRS_EXPONENT|NUMPRS_DECIMAL,7,0,-21);
1314 /** NUMPRS_USE_ALL **/
1316 /* Flag expects all digits */
1317 CONVERT("0", NUMPRS_USE_ALL);
1318 EXPECT(1,NUMPRS_USE_ALL,0,1,0,0);
1321 /* Rejects anything trailing */
1322 CONVERT("0 ", NUMPRS_USE_ALL);
1326 /* Unless consumed by trailing flag */
1327 CONVERT("0 ", NUMPRS_USE_ALL|NUMPRS_TRAILING_WHITE);
1328 EXPECT(1,NUMPRS_USE_ALL|NUMPRS_TRAILING_WHITE,NUMPRS_TRAILING_WHITE,2,0,0);
1331 /** Combinations **/
1333 /* Leading whitespace and plus, doesn't consume trailing whitespace */
1334 CONVERT("+ 0 ", NUMPRS_LEADING_PLUS|NUMPRS_LEADING_WHITE);
1335 EXPECT(1,NUMPRS_LEADING_PLUS|NUMPRS_LEADING_WHITE,NUMPRS_LEADING_PLUS|NUMPRS_LEADING_WHITE,3,0,0);
1338 /* Order of whitespace and plus is unimportant */
1339 CONVERT(" +0", NUMPRS_LEADING_PLUS|NUMPRS_LEADING_WHITE);
1340 EXPECT(1,NUMPRS_LEADING_PLUS|NUMPRS_LEADING_WHITE,NUMPRS_LEADING_PLUS|NUMPRS_LEADING_WHITE,3,0,0);
1343 /* Leading whitespace can be repeated */
1344 CONVERT(" + 0", NUMPRS_LEADING_PLUS|NUMPRS_LEADING_WHITE);
1345 EXPECT(1,NUMPRS_LEADING_PLUS|NUMPRS_LEADING_WHITE,NUMPRS_LEADING_PLUS|NUMPRS_LEADING_WHITE,4,0,0);
1348 /* But plus/minus etc. cannot */
1349 CONVERT("+ +0", NUMPRS_LEADING_PLUS|NUMPRS_LEADING_WHITE);
1351 EXPECTRGB(0,FAILDIG);
1353 /* Inexact is not set if trailing zeros are removed */
1354 CONVERTN("10", 1, 0);
1355 EXPECT(1,0,0,2,0,1);
1358 /* Make sure a leading 0 is stripped but decimals after it get read */
1359 CONVERT("-0.51", NUMPRS_STD);
1360 EXPECT(2,NUMPRS_STD,NUMPRS_NEG|NUMPRS_DECIMAL|NUMPRS_LEADING_MINUS,5,0,-2);
1363 /* Keep trailing zeros on whole number part of a decimal */
1364 CONVERT("10.1", NUMPRS_STD);
1365 EXPECT(3,NUMPRS_STD,NUMPRS_DECIMAL,4,0,-1);
1369 /* Zeros after decimal sign */
1370 CONVERT("0.01", NUMPRS_STD);
1371 EXPECT(1,NUMPRS_STD,NUMPRS_DECIMAL,4,0,-2);
1374 /* Trailing zeros after decimal part */
1375 CONVERT("0.10", NUMPRS_STD);
1376 EXPECT(1,NUMPRS_STD,NUMPRS_DECIMAL,4,0,-1);
1380 static HRESULT (WINAPI *pVarNumFromParseNum)(NUMPARSE*,BYTE*,ULONG,VARIANT*);
1382 /* Macros for converting and testing the result of VarNumFromParseNum */
1383 #define SETRGB(indx,val) if (!indx) memset(rgb, FAILDIG, sizeof(rgb)); rgb[indx] = val
1385 #define CONVERT(a,b,c,d,e,f,bits) \
1386 np.cDig = (a); np.dwInFlags = (b); np.dwOutFlags = (c); np.cchUsed = (d); \
1387 np.nBaseShift = (e); np.nPwr10 = (f); hres = pVarNumFromParseNum(&np, rgb, bits, &vOut)
1388 static const char *szFailOverflow = "Expected overflow, hres = %08x\n";
1389 #define EXPECT_OVERFLOW ok(hres == (HRESULT)DISP_E_OVERFLOW, szFailOverflow, hres)
1390 static const char *szFailOk = "Call failed, hres = %08x\n";
1391 #define EXPECT_OK ok(hres == (HRESULT)S_OK, szFailOk, hres); \
1392 if (hres == (HRESULT)S_OK)
1393 #define EXPECT_TYPE(typ) ok(V_VT(&vOut) == typ,"Expected Type = " #typ ", got %d\n", V_VT(&vOut))
1394 #define EXPECT_I1(val) EXPECT_OK { EXPECT_TYPE(VT_I1); \
1395 ok(V_I1(&vOut) == val, "Expected i1 = %d, got %d\n", (signed char)val, V_I1(&vOut)); }
1396 #define EXPECT_UI1(val) EXPECT_OK { EXPECT_TYPE(VT_UI1); \
1397 ok(V_UI1(&vOut) == val, "Expected ui1 = %d, got %d\n", (BYTE)val, V_UI1(&vOut)); }
1398 #define EXPECT_I2(val) EXPECT_OK { EXPECT_TYPE(VT_I2); \
1399 ok(V_I2(&vOut) == val, "Expected i2 = %d, got %d\n", (SHORT)val, V_I2(&vOut)); }
1400 #define EXPECT_UI2(val) EXPECT_OK { EXPECT_TYPE(VT_UI2); \
1401 ok(V_UI2(&vOut) == val, "Expected ui2 = %d, got %d\n", (USHORT)val, V_UI2(&vOut)); }
1402 #define EXPECT_I4(val) EXPECT_OK { EXPECT_TYPE(VT_I4); \
1403 ok(V_I4(&vOut) == val, "Expected i4 = %d, got %d\n", (LONG)val, V_I4(&vOut)); }
1404 #define EXPECT_UI4(val) EXPECT_OK { EXPECT_TYPE(VT_UI4); \
1405 ok(V_UI4(&vOut) == val, "Expected ui4 = %d, got %d\n", (ULONG)val, V_UI4(&vOut)); }
1406 #define EXPECT_I8(high,low) EXPECT_OK { EXPECT_TYPE(VT_I8); \
1407 ok(V_I8(&vOut) == ((((LONG64)(high))<<32)|(low)), "Expected i8 = %x%08x, got %x%08x\n", \
1408 (LONG)(high), (LONG)(low), (LONG)(V_I8(&vOut)>>32), (LONG)V_I8(&vOut) ); }
1409 #define EXPECT_UI8(val) EXPECT_OK { EXPECT_TYPE(VT_UI8); \
1410 ok(V_UI8(&vOut) == val, "Expected ui8 = 0x%x%08x, got 0x%x%08x\n", \
1411 (DWORD)((ULONG64)val >> 32), (DWORD)(ULONG64)val, (DWORD)(V_UI8(&vOut) >> 32), (DWORD)V_UI8(&vOut)); }
1412 #define EXPECT_R4(val) EXPECT_OK { EXPECT_TYPE(VT_R4); \
1413 ok(V_R4(&vOut) == val, "Expected r4 = %f, got %f\n", val, V_R4(&vOut)); }
1414 #define EXPECT_R8(val) EXPECT_OK { EXPECT_TYPE(VT_R8); \
1415 ok(V_R8(&vOut) == val, "Expected r8 = %g, got %g\n", val, V_R8(&vOut)); }
1416 #define CY_MULTIPLIER 10000
1417 #define EXPECT_CY(val) EXPECT_OK { EXPECT_TYPE(VT_CY); \
1418 ok(V_CY(&vOut).int64 == (LONG64)(val * CY_MULTIPLIER), "Expected r8 = 0x%x%08x, got 0x%x%08x\n", \
1419 (DWORD)((LONG64)val >> 23), (DWORD)(LONG64)val, (DWORD)(V_CY(&vOut).int64 >>32), (DWORD)V_CY(&vOut).int64); }
1420 #define EXPECT_DECIMAL(valHi, valMid, valLo) EXPECT_OK { EXPECT_TYPE(VT_DECIMAL); \
1421 ok((V_DECIMAL(&vOut).Hi32 == valHi) && (S1(U1(V_DECIMAL(&vOut))).Mid32 == valMid) && \
1422 (S1(U1(V_DECIMAL(&vOut))).Lo32 == valLo), \
1423 "Expected decimal = %x/0x%x%08x, got %x/0x%x%08x\n", valHi, valMid, valLo, \
1424 V_DECIMAL(&vOut).Hi32, S1(U1(V_DECIMAL(&vOut))).Mid32, S1(U1(V_DECIMAL(&vOut))).Lo32); }
1426 static void test_VarNumFromParseNum(void)
1433 CHECKPTR(VarNumFromParseNum);
1435 /* Convert the number 1 to different types */
1436 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_I1); EXPECT_I1(1);
1437 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_UI1); EXPECT_UI1(1);
1438 /* Prefers a signed type to unsigned of the same size */
1439 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_I1|VTBIT_UI1); EXPECT_I1(1);
1440 /* But takes the smaller size if possible */
1441 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_I2|VTBIT_UI1); EXPECT_UI1(1);
1443 /* Try different integer sizes */
1444 #define INTEGER_VTBITS (VTBIT_I1|VTBIT_UI1|VTBIT_I2|VTBIT_UI2|VTBIT_I4|VTBIT_UI4|VTBIT_I8|VTBIT_UI8)
1446 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, INTEGER_VTBITS); EXPECT_I1(1);
1448 SETRGB(0, 1); SETRGB(1, 2); SETRGB(2, 7);
1449 CONVERT(3,0,0,3,0,0, INTEGER_VTBITS); EXPECT_I1(127);
1451 SETRGB(0, 1); SETRGB(1, 2); SETRGB(2, 8);
1452 CONVERT(3,0,0,3,0,0, INTEGER_VTBITS); EXPECT_UI1(128);
1454 SETRGB(0, 2); SETRGB(1, 5); SETRGB(2, 5);
1455 CONVERT(3,0,0,3,0,0, INTEGER_VTBITS); EXPECT_UI1(255);
1457 SETRGB(0, 2); SETRGB(1, 5); SETRGB(2, 6);
1458 CONVERT(3,0,0,3,0,0, INTEGER_VTBITS); EXPECT_I2(256);
1460 SETRGB(0, 3); SETRGB(1, 2); SETRGB(2, 7); SETRGB(3, 6); SETRGB(4, 7);
1461 CONVERT(5,0,0,5,0,0, INTEGER_VTBITS); EXPECT_I2(32767);
1463 SETRGB(0, 3); SETRGB(1, 2); SETRGB(2, 7); SETRGB(3, 6); SETRGB(4, 8);
1464 CONVERT(5,0,0,5,0,0, INTEGER_VTBITS); EXPECT_UI2(32768);
1466 /* Assume the above pattern holds for remaining positive integers; test negative */
1469 SETRGB(0, 1); SETRGB(1, 2); SETRGB(2, 8);
1470 CONVERT(3,0,NUMPRS_NEG,3,0,0, INTEGER_VTBITS); EXPECT_I1(-128);
1472 SETRGB(0, 1); SETRGB(1, 2); SETRGB(2, 9);
1473 CONVERT(3,0,NUMPRS_NEG,3,0,0, INTEGER_VTBITS); EXPECT_I2(-129);
1475 SETRGB(0, 3); SETRGB(1, 2); SETRGB(2, 7); SETRGB(3, 6); SETRGB(4, 8);
1476 CONVERT(5,0,NUMPRS_NEG,5,0,0, INTEGER_VTBITS); EXPECT_I2(-32768);
1478 SETRGB(0, 3); SETRGB(1, 2); SETRGB(2, 7); SETRGB(3, 6); SETRGB(4, 9);
1479 CONVERT(5,0,NUMPRS_NEG,5,0,0, INTEGER_VTBITS); EXPECT_I4(-32769);
1481 /* Assume the above pattern holds for remaining negative integers */
1483 /* Test hexadecimal conversions */
1484 SETRGB(0, 1); CONVERT(1,0,0,1,4,0, INTEGER_VTBITS); EXPECT_I1(0x01);
1486 SETRGB(0, 7); SETRGB(1, 0xf);
1487 CONVERT(2,0,0,2,4,0, INTEGER_VTBITS); EXPECT_I1(0x7f);
1488 SETRGB(0, 7); SETRGB(1, 0xf);
1489 CONVERT(2,0,0,2,4,0, VTBIT_DECIMAL); EXPECT_DECIMAL(0,0,0x7f);
1491 SETRGB(0, 7); SETRGB(1, 0xf); SETRGB(2, 0xf); SETRGB(3, 0xf);
1492 CONVERT(4,0,0,4,4,0, INTEGER_VTBITS); EXPECT_I2(0x7fff);
1494 SETRGB(0, 7); SETRGB(1, 0xf); SETRGB(2, 0xf); SETRGB(3, 0xf);
1495 SETRGB(4, 0xf); SETRGB(5, 0xf); SETRGB(6, 0xf); SETRGB(7, 0xf);
1496 CONVERT(8,0,0,8,4,0, INTEGER_VTBITS); EXPECT_I4(0x7fffffffL);
1497 /* 0x7fffffffffffffff (64 bits) */
1498 SETRGB(0, 7); SETRGB(1, 0xf); SETRGB(2, 0xf); SETRGB(3, 0xf);
1499 SETRGB(4, 0xf); SETRGB(5, 0xf); SETRGB(6, 0xf); SETRGB(7, 0xf);
1500 SETRGB(8, 0xf); SETRGB(9, 0xf); SETRGB(10, 0xf); SETRGB(11, 0xf);
1501 SETRGB(12, 0xf); SETRGB(13, 0xf); SETRGB(14, 0xf); SETRGB(15, 0xf);
1502 if (HAVE_OLEAUT32_I8)
1504 /* We cannot use INTEGER_VTBITS as WinXP and Win2003 are broken(?). They
1505 truncate the number to the smallest integer size requested:
1506 CONVERT(16,0,0,16,4,0, INTEGER_VTBITS); EXPECT_I1((signed char)0xff); */
1507 CONVERT(16,0,0,16,4,0, VTBIT_I8); EXPECT_I8(0x7fffffff,0xffffffff);
1510 /* Assume the above pattern holds for numbers without hi-bit set, test (preservation of) hi-bit */
1512 SETRGB(0, 8); SETRGB(1, 2);
1513 CONVERT(2,0,0,2,4,0, INTEGER_VTBITS);
1514 EXPECT_I1((signed char)0x82);
1516 SETRGB(0, 8); SETRGB(1, 0); SETRGB(2, 0); SETRGB(3, 2);
1517 CONVERT(4,0,0,4,4,0, INTEGER_VTBITS);
1518 EXPECT_I2((signed short)0x8002);
1520 SETRGB(0, 8); SETRGB(1, 0); SETRGB(2, 0); SETRGB(3, 0);
1521 SETRGB(4, 0); SETRGB(5, 0); SETRGB(6, 0); SETRGB(7, 2);
1522 CONVERT(8,0,0,8,4,0, INTEGER_VTBITS); EXPECT_I4(0x80000002);
1523 /* 0x8000000000000002 (64 bits) */
1524 SETRGB(0, 8); SETRGB(1, 0); SETRGB(2, 0); SETRGB(3, 0);
1525 SETRGB(4, 0); SETRGB(5, 0); SETRGB(6, 0); SETRGB(7, 0);
1526 SETRGB(8, 0); SETRGB(9, 0); SETRGB(10, 0); SETRGB(11, 0);
1527 SETRGB(12, 0); SETRGB(13, 0); SETRGB(14, 0); SETRGB(15, 2);
1528 if (HAVE_OLEAUT32_I8)
1530 /* We cannot use INTEGER_VTBITS as WinXP and Win2003 are broken(?). They
1531 truncate the number to the smallest integer size requested:
1532 CONVERT(16,0,0,16,4,0, INTEGER_VTBITS & ~VTBIT_I1);
1533 EXPECT_I2((signed short)0x0002); */
1534 CONVERT(16,0,0,16,4,0, VTBIT_I8); EXPECT_I8(0x80000000,0x00000002);
1537 /* Test (preservation of) hi-bit with STRICT type requesting */
1539 SETRGB(0, 8); SETRGB(1, 2);
1540 CONVERT(2,0,0,2,4,0, VTBIT_I1);
1541 EXPECT_I1((signed char)0x82);
1543 SETRGB(0, 8); SETRGB(1, 0); SETRGB(2, 0); SETRGB(3, 2);
1544 CONVERT(4,0,0,4,4,0, VTBIT_I2);
1545 EXPECT_I2((signed short)0x8002);
1547 SETRGB(0, 8); SETRGB(1, 0); SETRGB(2, 0); SETRGB(3, 0);
1548 SETRGB(4, 0); SETRGB(5, 0); SETRGB(6, 0); SETRGB(7, 2);
1549 CONVERT(8,0,0,8,4,0, VTBIT_I4); EXPECT_I4(0x80000002);
1550 /* 0x8000000000000002 (64 bits) */
1551 SETRGB(0, 8); SETRGB(1, 0); SETRGB(2, 0); SETRGB(3, 0);
1552 SETRGB(4, 0); SETRGB(5, 0); SETRGB(6, 0); SETRGB(7, 0);
1553 SETRGB(8, 0); SETRGB(9, 0); SETRGB(10, 0); SETRGB(11, 0);
1554 SETRGB(12, 0); SETRGB(13, 0); SETRGB(14, 0); SETRGB(15, 2);
1555 if (HAVE_OLEAUT32_I8)
1557 CONVERT(16,0,0,16,4,0, VTBIT_I8); EXPECT_I8(0x80000000,0x00000002);
1559 /* Assume the above pattern holds for numbers with hi-bit set */
1561 /* Negative numbers overflow if we have only unsigned outputs */
1563 SETRGB(0, 1); CONVERT(1,0,NUMPRS_NEG,1,0,0, VTBIT_UI1); EXPECT_OVERFLOW;
1565 SETRGB(0, 6); CONVERT(1,0,NUMPRS_NEG,1,0,~0u, VTBIT_UI1); EXPECT_OVERFLOW;
1567 /* Except that rounding is done first, so -0.5 to 0 are accepted as 0 */
1569 SETRGB(0, 5); CONVERT(1,0,NUMPRS_NEG,1,0,~0u, VTBIT_UI1); EXPECT_UI1(0);
1571 /* Floating point zero is OK */
1573 SETRGB(0, 0); CONVERT(1,0,NUMPRS_DECIMAL|NUMPRS_EXPONENT,12,0,-8, VTBIT_R8);
1576 /* Float is acceptable for an integer input value */
1577 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_R4); EXPECT_R4(1.0f);
1579 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_R8); EXPECT_R8(1.0);
1580 /* As is currency */
1581 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_CY); EXPECT_CY(1);
1583 /* Float is preferred over double */
1584 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_R4|VTBIT_R8); EXPECT_R4(1.0f);
1586 /* Double is preferred over currency */
1587 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_R8|VTBIT_CY); EXPECT_R8(1.0);
1589 /* Currency is preferred over decimal */
1590 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_CY|VTBIT_DECIMAL); EXPECT_CY(1);
1594 static void test_UdateFromDate( int line, DATE dt, ULONG flags, HRESULT r, WORD d, WORD m, WORD y,
1595 WORD h, WORD mn, WORD s, WORD ms, WORD dw, WORD dy)
1600 memset(&ud, 0, sizeof(ud));
1601 res = pVarUdateFromDate(dt, flags, &ud);
1602 ok_(__FILE__,line)(r == res && (res != S_OK || (ud.st.wYear == y && ud.st.wMonth == m && ud.st.wDay == d &&
1603 ud.st.wHour == h && ud.st.wMinute == mn && ud.st.wSecond == s &&
1604 ud.st.wMilliseconds == ms && ud.st.wDayOfWeek == dw && ud.wDayOfYear == dy)),
1605 "%.16g expected res(%x) %d,%d,%d,%d,%d,%d,%d %d %d, got res(%x) %d,%d,%d,%d,%d,%d,%d %d %d\n",
1606 dt, r, d, m, y, h, mn, s, ms, dw, dy,
1607 res, ud.st.wDay, ud.st.wMonth, ud.st.wYear, ud.st.wHour, ud.st.wMinute,
1608 ud.st.wSecond, ud.st.wMilliseconds, ud.st.wDayOfWeek, ud.wDayOfYear );
1610 #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)
1612 static void test_VarUdateFromDate(void)
1614 CHECKPTR(VarUdateFromDate);
1615 DT2UD(29221.0,0,S_OK,1,1,1980,0,0,0,0,2,1); /* 1 Jan 1980 */
1616 DT2UD(29222.0,0,S_OK,2,1,1980,0,0,0,0,3,2); /* 2 Jan 1980 */
1617 DT2UD(33238.0,0,S_OK,31,12,1990,0,0,0,0,1,365); /* 31 Dec 1990 */
1618 DT2UD(0.0,0,S_OK,30,12,1899,0,0,0,0,6,364); /* 30 Dec 1899 - VT_DATE 0.0 */
1619 DT2UD(-657434.0,0,S_OK,1,1,100,0,0,0,0,5,1); /* 1 Jan 100 - Min */
1620 DT2UD(-657435.0,0,E_INVALIDARG,0,0,0,0,0,0,0,0,0); /* < 1 Jan 100 => err */
1621 DT2UD(2958465.0,0,S_OK,31,12,9999,0,0,0,0,5,365); /* 31 Dec 9999 - Max */
1622 DT2UD(2958466.0,0,E_INVALIDARG,0,0,0,0,0,0,0,0,0); /* > 31 Dec 9999 => err */
1624 /* VAR_VALIDDATE doesn't prevent upper and lower bounds being checked */
1625 DT2UD(-657435.0,VAR_VALIDDATE,E_INVALIDARG,0,0,0,0,0,0,0,0,0);
1626 DT2UD(2958466.0,VAR_VALIDDATE,E_INVALIDARG,0,0,0,0,0,0,0,0,0);
1629 DT2UD(29221.25,0,S_OK,1,1,1980,6,0,0,0,2,1); /* 6 AM */
1630 DT2UD(29221.33333333,0,S_OK,1,1,1980,8,0,0,0,2,1); /* 8 AM */
1631 DT2UD(29221.5,0,S_OK,1,1,1980,12,0,0,0,2,1); /* 12 AM */
1632 DT2UD(29221.9888884444,0,S_OK,1,1,1980,23,44,0,0,2,1); /* 11:44 PM */
1633 DT2UD(29221.7508765432,0,S_OK,1,1,1980,18,1,16,0,2,1); /* 6:18:02 PM */
1635 /* Test handling of times on dates prior to the epoch */
1636 DT2UD(-5.25,0,S_OK,25,12,1899,6,0,0,0,1,359);
1637 DT2UD(-5.9999884259259,0,S_OK,25,12,1899,23,59,59,0,1,359);
1638 /* This just demonstrates the non-linear nature of values prior to the epoch */
1639 DT2UD(-4.0,0,S_OK,26,12,1899,0,0,0,0,2,360);
1640 /* Numerical oddity: for 0.0 < x < 1.0, x and -x represent the same datetime */
1641 DT2UD(-0.25,0,S_OK,30,12,1899,6,0,0,0,6,364);
1642 DT2UD(0.25,0,S_OK,30,12,1899,6,0,0,0,6,364);
1646 static void test_DateFromUDate( int line, WORD d, WORD m, WORD y, WORD h, WORD mn, WORD s, WORD ms,
1647 WORD dw, WORD dy, ULONG flags, HRESULT r, DATE dt )
1659 ud.st.wMilliseconds = ms;
1660 ud.st.wDayOfWeek = dw;
1662 res = pVarDateFromUdate(&ud, flags, &out);
1663 ok_(__FILE__,line)(r == res && (r != S_OK || EQ_DOUBLE(out, dt)),
1664 "expected %x, %.16g, got %x, %.16g\n", r, dt, res, out);
1666 #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)
1668 static void test_VarDateFromUdate(void)
1670 CHECKPTR(VarDateFromUdate);
1671 UD2T(1,1,1980,0,0,0,0,2,1,0,S_OK,29221.0); /* 1 Jan 1980 */
1672 UD2T(2,1,1980,0,0,0,0,3,2,0,S_OK,29222.0); /* 2 Jan 1980 */
1673 UD2T(2,1,1980,0,0,0,0,4,5,0,S_OK,29222.0); /* 2 Jan 1980 */
1674 UD2T(31,12,1990,0,0,0,0,0,0,0,S_OK,33238.0); /* 31 Dec 1990 */
1675 UD2T(31,12,90,0,0,0,0,0,0,0,S_OK,33238.0); /* year < 100 is 1900+year! */
1676 UD2T(30,12,1899,0,0,0,0,6,364,0,S_OK,0.0); /* 30 Dec 1899 - VT_DATE 0.0 */
1677 UD2T(1,1,100,0,0,0,0,0,0,0,S_OK,-657434.0); /* 1 Jan 100 - Min */
1678 UD2T(31,12,9999,0,0,0,0,0,0,0,S_OK,2958465.0); /* 31 Dec 9999 - Max */
1679 UD2T(1,1,10000,0,0,0,0,0,0,0,E_INVALIDARG,0.0); /* > 31 Dec 9999 => err */
1680 UD2T(1,1,-10000,0,0,0,0,0,0,0,E_INVALIDARG,0.0);/* < -9999 => err */
1682 UD2T(30,12,1899,0,0,0,0,0,0,0,S_OK,0.0); /* 30 Dec 1899 0:00:00 */
1683 UD2T(30,12,1899,0,0,0,999,0,0,0,S_OK,0.0); /* Ignore milliseconds */
1685 UD2T(1,1,1980,18,1,16,0,2,1,0,S_OK,29221.75087962963); /* 6:18:02 PM */
1686 UD2T(1,300,1980,18,1,16,0,2,1,0,S_OK,38322.75087962963); /* Test fwdrolled month */
1687 UD2T(300,1,1980,18,1,16,0,2,1,0,S_OK,29520.75087962963); /* Test fwdrolled days */
1688 UD2T(0,1,1980,42,1,16,0,2,1,0,S_OK,29221.75087962963); /* Test fwdrolled hours */
1689 UD2T(1,1,1980,17,61,16,0,2,1,0,S_OK,29221.75087962963); /* Test fwdrolled minutes */
1690 UD2T(1,1,1980,18,0,76,0,2,1,0,S_OK,29221.75087962963); /* Test fwdrolled seconds */
1691 UD2T(1,-300,1980,18,1,16,0,2,1,0,S_OK,20059.75087962963); /* Test backrolled month */
1692 UD2T(-300,1,1980,18,1,16,0,2,1,0,S_OK,28920.75087962963); /* Test backrolled days */
1693 UD2T(3,1,1980,-30,1,16,0,2,1,0,S_OK,29221.75087962963); /* Test backrolled hours */
1694 UD2T(1,1,1980,20,-119,16,0,2,1,0,S_OK,29221.75087962963); /* Test backrolled minutes */
1695 UD2T(1,1,1980,18,3,-104,0,2,1,0,S_OK,29221.75087962963); /* Test backrolled seconds */
1696 UD2T(1,12001,-1020,18,1,16,0,0,0,0,S_OK,29221.75087962963); /* Test rolled year and month */
1697 UD2T(1,-23,1982,18,1,16,0,0,0,0,S_OK,29221.75087962963); /* Test backrolled month */
1698 UD2T(-59,3,1980,18,1,16,0,0,0,0,S_OK,29221.75087962963); /* Test backrolled days */
1699 UD2T(1,1,0,0,0,0,0,0,0,0,S_OK,36526); /* Test zero year */
1700 UD2T(0,0,1980,0,0,0,0,0,0,0,S_OK,29189); /* Test zero day and month */
1701 UD2T(0,1,1980,0,0,0,0,2,1,0,S_OK,29220.0); /* Test zero day = LastDayOfMonth */
1702 UD2T(-1,1,1980,18,1,16,0,0,0,0,S_OK,29219.75087962963); /* Test day -1 = LastDayOfMonth - 1 */
1703 UD2T(1,1,-1,18,1,16,0,0,0,0,S_OK,36161.75087962963); /* Test year -1 = 1999 */
1704 UD2T(1,-1,1980,18,1,16,0,0,0,0,S_OK,29160.7508796296); /* Test month -1 = 11 */
1705 UD2T(1,13,1980,0,0,0,0,2,1,0,S_OK,29587.0); /* Rolls fwd to 1/1/1981 */
1707 /* Test handling of times on dates prior to the epoch */
1708 UD2T(25,12,1899,6,0,0,0,1,359,0,S_OK,-5.25);
1709 UD2T(25,12,1899,23,59,59,0,1,359,0,S_OK,-5.9999884259259);
1710 /* This just demonstrates the non-linear nature of values prior to the epoch */
1711 UD2T(26,12,1899,0,0,0,0,2,360,0,S_OK,-4.0);
1712 /* for DATE values 0.0 < x < 1.0, x and -x represent the same datetime */
1713 /* but when converting to DATE, prefer the positive versions */
1714 UD2T(30,12,1899,6,0,0,0,6,364,0,S_OK,0.25);
1717 static void test_st2dt(int line, WORD d, WORD m, WORD y, WORD h, WORD mn,
1718 WORD s, WORD ms, INT r, double dt)
1730 st.wMilliseconds = ms;
1732 res = pSystemTimeToVariantTime(&st, &out);
1733 ok_(__FILE__,line)(r == res && (!r || EQ_DOUBLE(out, dt)),
1734 "expected %d, %.16g, got %d, %.16g\n", r, dt, res, out);
1736 #define ST2DT(d,m,y,h,mn,s,ms,r,dt) test_st2dt(__LINE__,d,m,y,h,mn,s,ms,r,dt)
1738 static void test_SystemTimeToVariantTime(void)
1740 CHECKPTR(SystemTimeToVariantTime);
1741 ST2DT(1,1,1980,0,0,0,0,TRUE,29221.0);
1742 ST2DT(2,1,1980,0,0,0,0,TRUE,29222.0);
1743 ST2DT(0,1,1980,0,0,0,0,TRUE,29220.0); /* Rolls back to 31 Dec 1899 */
1744 ST2DT(1,13,1980,0,0,0,0,FALSE,29587.0); /* Fails on invalid month */
1745 ST2DT(31,12,90,0,0,0,0,TRUE,33238.0); /* 30 <= year < 100 is 1900+year */
1746 ST2DT(1,1,30,0,0,0,0,TRUE,10959.0); /* 30 <= year < 100 is 1900+year */
1747 ST2DT(1,1,29,0,0,0,0,TRUE,47119.0); /* 0 <= year < 30 is 2000+year */
1748 ST2DT(1,1,0,0,0,0,0,TRUE,36526.0); /* 0 <= year < 30 is 2000+year */
1751 static void test_dt2st(int line, double dt, INT r, WORD d, WORD m, WORD y,
1752 WORD h, WORD mn, WORD s, WORD ms)
1757 memset(&st, 0, sizeof(st));
1758 res = pVariantTimeToSystemTime(dt, &st);
1759 ok_(__FILE__,line)(r == res &&
1760 (!r || (st.wYear == y && st.wMonth == m && st.wDay == d &&
1761 st.wHour == h && st.wMinute == mn &&
1762 st.wSecond == s && st.wMilliseconds == ms)),
1763 "%.16g expected %d, %d,%d,%d,%d,%d,%d,%d, got %d, %d,%d,%d,%d,%d,%d,%d\n",
1764 dt, r, d, m, y, h, mn, s, ms, res, st.wDay, st.wMonth,
1765 st.wYear, st.wHour, st.wMinute, st.wSecond,
1768 #define DT2ST(dt,r,d,m,y,h,mn,s,ms) test_dt2st(__LINE__,dt,r,d,m,y,h,mn,s,ms)
1770 static void test_VariantTimeToSystemTime(void)
1772 CHECKPTR(VariantTimeToSystemTime);
1773 DT2ST(29221.0,1,1,1,1980,0,0,0,0);
1774 DT2ST(29222.0,1,2,1,1980,0,0,0,0);
1777 #define MKDOSDATE(d,m,y) ((d & 0x1f) | ((m & 0xf) << 5) | (((y-1980) & 0x7f) << 9))
1778 #define MKDOSTIME(h,m,s) (((s>>1) & 0x1f) | ((m & 0x3f) << 5) | ((h & 0x1f) << 11))
1780 static void test_dos2dt(int line, WORD d, WORD m, WORD y, WORD h, WORD mn,
1781 WORD s, INT r, double dt)
1783 unsigned short dosDate, dosTime;
1788 dosDate = MKDOSDATE(d, m, y);
1789 dosTime = MKDOSTIME(h, mn, s);
1790 res = pDosDateTimeToVariantTime(dosDate, dosTime, &out);
1791 ok_(__FILE__,line)(r == res && (!r || EQ_DOUBLE(out, dt)),
1792 "expected %d, %.16g, got %d, %.16g\n", r, dt, res, out);
1794 #define DOS2DT(d,m,y,h,mn,s,r,dt) test_dos2dt(__LINE__,d,m,y,h,mn,s,r,dt)
1796 static void test_DosDateTimeToVariantTime(void)
1798 CHECKPTR(DosDateTimeToVariantTime);
1801 DOS2DT(1,1,1980,0,0,0,1,29221.0); /* 1/1/1980 */
1802 DOS2DT(31,12,2099,0,0,0,1,73050.0); /* 31/12/2099 */
1803 /* Dates are limited to the dos date max of 31/12/2099 */
1804 DOS2DT(31,12,2100,0,0,0,0,0.0); /* 31/12/2100 */
1805 /* Days and months of 0 cause date to roll back 1 day or month */
1806 DOS2DT(0,1,1980,0,0,0,1,29220.0); /* 0 Day => 31/12/1979 */
1807 DOS2DT(1,0,1980,0,0,0,1,29190.0); /* 0 Mth => 1/12/1979 */
1808 DOS2DT(0,0,1980,0,0,0,1,29189.0); /* 0 D/M => 30/11/1979 */
1809 /* Days > days in the month cause date to roll forward 1 month */
1810 DOS2DT(29,2,1981,0,0,0,1,29646.0); /* 29/2/1981 -> 3/1/1980 */
1811 DOS2DT(30,2,1981,0,0,0,1,29647.0); /* 30/2/1981 -> 4/1/1980 */
1812 /* Takes leap years into account when rolling forward */
1813 DOS2DT(29,2,1980,0,0,0,1,29280.0); /* 2/29/1980 */
1814 /* Months > 12 cause an error */
1815 DOS2DT(2,13,1980,0,0,0,0,0.0);
1818 DOS2DT(1,1,1980,0,0,29,1,29221.00032407407); /* 1/1/1980 12:00:28 AM */
1819 DOS2DT(1,1,1980,0,0,31,1,29221.00034722222); /* 1/1/1980 12:00:30 AM */
1820 DOS2DT(1,1,1980,0,59,0,1,29221.04097222222); /* 1/1/1980 12:59:00 AM */
1821 DOS2DT(1,1,1980,0,60,0,0,0.0); /* Invalid minutes */
1822 DOS2DT(1,1,1980,0,0,60,0,0.0); /* Invalid seconds */
1823 DOS2DT(1,1,1980,23,0,0,1,29221.95833333333); /* 1/1/1980 11:00:00 PM */
1824 DOS2DT(1,1,1980,24,0,0,0,0.0); /* Invalid hours */
1826 DOS2DT(1,1,1980,0,0,1,1,29221.0);
1827 DOS2DT(2,1,1980,0,0,0,1,29222.0);
1828 DOS2DT(2,1,1980,0,0,0,1,29222.0);
1829 DOS2DT(31,12,1990,0,0,0,1,33238.0);
1830 DOS2DT(31,12,90,0,0,0,1,40543.0);
1831 DOS2DT(30,12,1899,0,0,0,1,46751.0);
1832 DOS2DT(1,1,100,0,0,0,1,43831.0);
1833 DOS2DT(31,12,9999,0,0,0,1,59901.0);
1834 DOS2DT(1,1,10000,0,0,0,1,59902.0);
1835 DOS2DT(1,1,-10000,0,0,0,1,48214.0);
1837 DOS2DT(30,12,1899,0,0,0,1,46751.0);
1838 DOS2DT(30,12,1899,0,0,1,1,46751.0);
1840 DOS2DT(1,1,1980,18,1,16,1,29221.75087962963);
1841 DOS2DT(1,300,1980,18,1,16,1,29556.75087962963);
1842 DOS2DT(300,1,1980,18,1,16,1,29232.75087962963);
1843 DOS2DT(0,1,1980,42,1,16,1,29220.4175462963);
1844 DOS2DT(1,1,1980,17,61,16,0,0.0);
1845 DOS2DT(1,1,1980,18,0,76,1,29221.75013888889);
1846 DOS2DT(1,-300,1980,18,1,16,1,29312.75087962963);
1847 DOS2DT(-300,1,1980,18,1,16,1,29240.75087962963);
1848 DOS2DT(3,1,1980,-30,1,16,1,29223.08421296296);
1849 DOS2DT(1,1,1980,20,-119,16,1,29221.83976851852);
1850 DOS2DT(1,1,1980,18,3,-104,1,29221.75236111111);
1851 DOS2DT(1,12001,-1020,18,1,16,1,55519.75087962963);
1852 DOS2DT(1,-23,1982,18,1,16,1,30195.75087962963);
1853 DOS2DT(-59,3,1980,18,1,16,1,29285.75087962963);
1854 DOS2DT(1,1,0,0,0,0,1,54058.0);
1855 DOS2DT(0,0,1980,0,0,0,1,29189.0);
1856 DOS2DT(0,1,1980,0,0,0,1,29220.0);
1857 DOS2DT(-1,1,1980,18,1,16,1,29251.75087962963);
1858 DOS2DT(1,1,-1,18,1,16,1,53693.75087962963);
1859 DOS2DT(1,-1,1980,18,1,16,0,0);
1862 static void test_dt2dos(int line, double dt, INT r, WORD d, WORD m, WORD y,
1863 WORD h, WORD mn, WORD s)
1865 unsigned short dosDate, dosTime, expDosDate, expDosTime;
1868 dosTime = dosDate = 0;
1869 expDosDate = MKDOSDATE(d,m,y);
1870 expDosTime = MKDOSTIME(h,mn,s);
1871 res = pVariantTimeToDosDateTime(dt, &dosDate, &dosTime);
1872 ok_(__FILE__,line)(r == res && (!r || (dosTime == expDosTime && dosDate == expDosDate)),
1873 "%g: expected %d,%d(%d/%d/%d),%d(%d:%d:%d) got %d,%d(%d/%d/%d),%d(%d:%d:%d)\n",
1874 dt, r, expDosDate, expDosDate & 0x1f,
1875 (expDosDate >> 5) & 0xf, 1980 + (expDosDate >> 9),
1876 expDosTime, expDosTime >> 11, (expDosTime >> 5) & 0x3f,
1877 (expDosTime & 0x1f),
1878 res, dosDate, dosDate & 0x1f, (dosDate >> 5) & 0xf,
1879 1980 + (dosDate >> 9), dosTime, dosTime >> 11,
1880 (dosTime >> 5) & 0x3f, (dosTime & 0x1f));
1882 #define DT2DOS(dt,r,d,m,y,h,mn,s) test_dt2dos(__LINE__,dt,r,d,m,y,h,mn,s)
1884 static void test_VariantTimeToDosDateTime(void)
1886 CHECKPTR(VariantTimeToDosDateTime);
1889 DT2DOS(29221.0,1,1,1,1980,0,0,0); /* 1/1/1980 */
1890 DT2DOS(73050.0,1,31,12,2099,0,0,0); /* 31/12/2099 */
1891 DT2DOS(29220.0,0,0,0,0,0,0,0); /* 31/12/1979 - out of range */
1892 DT2DOS(73415.0,0,0,0,0,0,0,0); /* 31/12/2100 - out of range */
1895 DT2DOS(29221.00032407407,1,1,1,1980,0,0,29); /* 1/1/1980 12:00:28 AM */
1896 DT2DOS(29221.00034722222,1,1,1,1980,0,0,31); /* 1/1/1980 12:00:30 AM */
1897 DT2DOS(29221.04097222222,1,1,1,1980,0,59,0); /* 1/1/1980 12:59:00 AM */
1898 DT2DOS(29221.95833333333,1,1,1,1980,23,0,0); /* 1/1/1980 11:00:00 PM */
1901 static HRESULT (WINAPI *pVarAbs)(LPVARIANT,LPVARIANT);
1903 #define VARABS(vt,val,rvt,rval) \
1904 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
1905 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
1906 test_var_call1( __LINE__, pVarAbs, &v, &exp )
1908 static void test_VarAbs(void)
1910 static WCHAR szNum[] = {'-','1','.','1','\0' };
1913 VARIANT v, vDst, exp;
1918 /* Test all possible V_VT values.
1920 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
1924 for (vt = 0; vt <= VT_BSTR_BLOB; vt++)
1926 HRESULT hExpected = DISP_E_BADVARTYPE;
1930 memset(&v, 0, sizeof(v));
1931 V_VT(&v) = vt | ExtraFlags[i];
1932 V_VT(&vDst) = VT_EMPTY;
1934 hres = pVarAbs(&v,&vDst);
1935 if (ExtraFlags[i] & (VT_ARRAY|VT_ARRAY) ||
1936 (!ExtraFlags[i] && (vt == VT_UNKNOWN || vt == VT_BSTR ||
1937 vt == VT_DISPATCH || vt == VT_ERROR || vt == VT_RECORD)))
1939 hExpected = DISP_E_TYPEMISMATCH;
1941 else if (ExtraFlags[i] || vt >= VT_CLSID || vt == VT_VARIANT)
1943 hExpected = DISP_E_BADVARTYPE;
1945 else if (IsValidVariantClearVT(vt, ExtraFlags[i]))
1948 /* Native always fails on some vartypes that should be valid. don't
1949 * check that Wine does the same; these are bugs in native.
1951 if (vt == VT_I8 || vt == VT_UI8 || vt == VT_INT || vt == VT_UINT ||
1952 vt == VT_I1 || vt == VT_UI2 || vt == VT_UI4)
1954 ok(hres == hExpected, "VarAbs: expected 0x%X, got 0x%X for vt %d | 0x%X\n",
1955 hExpected, hres, vt, ExtraFlags[i]);
1959 /* BOOL->I2, BSTR->R8, all others remain the same */
1960 VARABS(BOOL,VARIANT_TRUE,I2,-VARIANT_TRUE);
1961 VARABS(BOOL,VARIANT_FALSE,I2,VARIANT_FALSE);
1962 VARABS(EMPTY,0,I2,0);
1963 VARABS(EMPTY,1,I2,0);
1964 VARABS(NULL,0,NULL,0);
1965 VARABS(NULL,1,NULL,0);
1970 VARABS(UI1,1,UI1,1);
1975 VARABS(DATE,1,DATE,1);
1976 VARABS(DATE,-1,DATE,1);
1978 V_CY(&v).int64 = -10000;
1979 memset(&vDst,0,sizeof(vDst));
1980 hres = pVarAbs(&v,&vDst);
1981 ok(hres == S_OK && V_VT(&vDst) == VT_CY && V_CY(&vDst).int64 == 10000,
1982 "VarAbs(CY): expected 0x0 got 0x%X\n", hres);
1983 GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, buff, sizeof(buff)/sizeof(char));
1986 trace("Skipping VarAbs(BSTR) as decimal separator is '%s'\n", buff);
1992 V_BSTR(&v) = (BSTR)szNum;
1993 memset(&vDst,0,sizeof(vDst));
1994 hres = pVarAbs(&v,&vDst);
1995 ok(hres == S_OK && V_VT(&vDst) == VT_R8 && V_R8(&vDst) == 1.1,
1996 "VarAbs: expected 0x0,%d,%g, got 0x%X,%d,%g\n", VT_R8, 1.1, hres, V_VT(&vDst), V_R8(&vDst));
1999 static HRESULT (WINAPI *pVarNot)(LPVARIANT,LPVARIANT);
2001 #define VARNOT(vt,val,rvt,rval) \
2002 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
2003 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
2004 test_var_call1( __LINE__, pVarNot, &v, &exp )
2006 static void test_VarNot(void)
2008 static const WCHAR szNum0[] = {'0','\0' };
2009 static const WCHAR szNum1[] = {'1','\0' };
2010 static const WCHAR szFalse[] = { '#','F','A','L','S','E','#','\0' };
2011 static const WCHAR szTrue[] = { '#','T','R','U','E','#','\0' };
2013 VARIANT v, exp, vDst;
2014 DECIMAL *pdec = &V_DECIMAL(&v);
2015 CY *pcy = &V_CY(&v);
2020 /* Test all possible V_VT values */
2021 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
2025 for (vt = 0; vt <= VT_BSTR_BLOB; vt++)
2027 HRESULT hExpected = DISP_E_BADVARTYPE;
2031 memset(&v, 0, sizeof(v));
2032 V_VT(&v) = vt | ExtraFlags[i];
2033 V_VT(&vDst) = VT_EMPTY;
2037 case VT_I1: case VT_UI1: case VT_I2: case VT_UI2:
2038 case VT_INT: case VT_UINT: case VT_I4: case VT_UI4:
2039 case VT_R4: case VT_R8:
2040 case VT_DECIMAL: case VT_BOOL: case VT_NULL: case VT_EMPTY:
2041 case VT_DATE: case VT_CY:
2044 case VT_I8: case VT_UI8:
2045 if (HAVE_OLEAUT32_I8)
2049 if (HAVE_OLEAUT32_RECORD)
2050 hExpected = DISP_E_TYPEMISMATCH;
2052 case VT_UNKNOWN: case VT_BSTR: case VT_DISPATCH: case VT_ERROR:
2053 hExpected = DISP_E_TYPEMISMATCH;
2056 if (IsValidVariantClearVT(vt, ExtraFlags[i]) && vt != VT_CLSID)
2057 hExpected = DISP_E_TYPEMISMATCH;
2061 hres = pVarNot(&v,&vDst);
2062 ok(hres == hExpected, "VarNot: expected 0x%X, got 0x%X vt %d|0x%X\n",
2063 hExpected, hres, vt, ExtraFlags[i]);
2066 /* Test the values returned by all cases that can succeed */
2067 VARNOT(EMPTY,0,I2,-1);
2068 VARNOT(EMPTY,1,I2,-1);
2069 VARNOT(NULL,0,NULL,0);
2070 VARNOT(NULL,1,NULL,0);
2071 VARNOT(BOOL,VARIANT_TRUE,BOOL,VARIANT_FALSE);
2072 VARNOT(BOOL,VARIANT_FALSE,BOOL,VARIANT_TRUE);
2080 VARNOT(UI1,1,UI1,254);
2081 VARNOT(UI1,0,UI1,255);
2082 VARNOT(UI2,0,I4,-1);
2083 VARNOT(UI2,1,I4,-2);
2084 VARNOT(UI4,0,I4,-1);
2085 VARNOT(UI4,1,I4,-2);
2086 VARNOT(INT,0,I4,-1);
2087 VARNOT(INT,1,I4,-2);
2088 VARNOT(UINT,0,I4,-1);
2089 VARNOT(UINT,1,I4,-2);
2090 if (HAVE_OLEAUT32_I8)
2094 VARNOT(UI8,0,I4,-1);
2095 VARNOT(UI8,1,I4,-2);
2101 VARNOT(DATE,1,I4,-2);
2102 VARNOT(DATE,0,I4,-1);
2103 VARNOT(BSTR,(BSTR)szNum0,I4,-1);
2104 ok(V_VT(&v) == VT_BSTR && V_BSTR(&v) == szNum0, "VarNot(0): changed input\n");
2105 VARNOT(BSTR,(BSTR)szNum1,I4,-2);
2106 ok(V_VT(&v) == VT_BSTR && V_BSTR(&v) == szNum1, "VarNot(1): changed input\n");
2107 VARNOT(BSTR, (BSTR)szTrue, BOOL, VARIANT_FALSE);
2108 VARNOT(BSTR, (BSTR)szFalse, BOOL, VARIANT_TRUE);
2110 V_VT(&v) = VT_DECIMAL;
2111 S(U(*pdec)).sign = DECIMAL_NEG;
2112 S(U(*pdec)).scale = 0;
2114 S1(U1(*pdec)).Mid32 = 0;
2115 S1(U1(*pdec)).Lo32 = 1;
2116 VARNOT(DECIMAL,*pdec,I4,0);
2119 VARNOT(CY,*pcy,I4,-2);
2122 VARNOT(CY,*pcy,I4,-1);
2125 VARNOT(CY,*pcy,I4,-1);
2128 static HRESULT (WINAPI *pVarSub)(LPVARIANT,LPVARIANT,LPVARIANT);
2130 #define VARSUB(vt1,val1,vt2,val2,rvt,rval) \
2131 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
2132 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
2133 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
2134 test_var_call2( __LINE__, pVarSub, &left, &right, &exp )
2136 static void test_VarSub(void)
2138 VARIANT left, right, exp, result, cy, dec;
2141 HRESULT hres, expectedhres;
2146 lbstr = SysAllocString(sz12);
2147 rbstr = SysAllocString(sz12);
2150 VariantInit(&right);
2151 VariantInit(&result);
2153 /* Test all possible flag/vt combinations & the resulting vt type */
2154 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
2157 VARTYPE leftvt, rightvt, resvt;
2159 for (leftvt = 0; leftvt <= VT_BSTR_BLOB; leftvt++)
2164 for (rightvt = 0; rightvt <= VT_BSTR_BLOB; rightvt++)
2168 expectedhres = S_OK;
2170 memset(&left, 0, sizeof(left));
2171 memset(&right, 0, sizeof(right));
2172 V_VT(&left) = leftvt | ExtraFlags[i];
2173 if (leftvt == VT_BSTR)
2174 V_BSTR(&left) = lbstr;
2175 V_VT(&right) = rightvt | ExtraFlags[i];
2176 if (rightvt == VT_BSTR)
2177 V_BSTR(&right) = rbstr;
2178 V_VT(&result) = VT_EMPTY;
2180 /* All extra flags produce errors */
2181 if (ExtraFlags[i] == (VT_VECTOR|VT_BYREF|VT_RESERVED) ||
2182 ExtraFlags[i] == (VT_VECTOR|VT_RESERVED) ||
2183 ExtraFlags[i] == (VT_VECTOR|VT_BYREF) ||
2184 ExtraFlags[i] == (VT_BYREF|VT_RESERVED) ||
2185 ExtraFlags[i] == VT_VECTOR ||
2186 ExtraFlags[i] == VT_BYREF ||
2187 ExtraFlags[i] == VT_RESERVED)
2189 expectedhres = DISP_E_BADVARTYPE;
2192 else if (ExtraFlags[i] >= VT_ARRAY)
2194 expectedhres = DISP_E_TYPEMISMATCH;
2197 /* Native VarSub cannot handle: VT_I1, VT_UI2, VT_UI4,
2198 VT_INT, VT_UINT and VT_UI8. Tested with WinXP */
2199 else if (!IsValidVariantClearVT(leftvt, ExtraFlags[i]) ||
2200 !IsValidVariantClearVT(rightvt, ExtraFlags[i]) ||
2201 leftvt == VT_CLSID || rightvt == VT_CLSID ||
2202 leftvt == VT_VARIANT || rightvt == VT_VARIANT ||
2203 leftvt == VT_I1 || rightvt == VT_I1 ||
2204 leftvt == VT_UI2 || rightvt == VT_UI2 ||
2205 leftvt == VT_UI4 || rightvt == VT_UI4 ||
2206 leftvt == VT_UI8 || rightvt == VT_UI8 ||
2207 leftvt == VT_INT || rightvt == VT_INT ||
2208 leftvt == VT_UINT || rightvt == VT_UINT ||
2209 leftvt == VT_UNKNOWN || rightvt == VT_UNKNOWN ||
2210 leftvt == VT_RECORD || rightvt == VT_RECORD)
2212 if (leftvt == VT_RECORD && rightvt == VT_I8)
2214 if (HAVE_OLEAUT32_I8)
2215 expectedhres = DISP_E_TYPEMISMATCH;
2217 expectedhres = DISP_E_BADVARTYPE;
2219 else if (leftvt < VT_UI1 && rightvt == VT_RECORD)
2220 expectedhres = DISP_E_TYPEMISMATCH;
2221 else if (leftvt >= VT_UI1 && rightvt == VT_RECORD)
2222 expectedhres = DISP_E_TYPEMISMATCH;
2223 else if (leftvt == VT_RECORD && rightvt <= VT_UI1)
2224 expectedhres = DISP_E_TYPEMISMATCH;
2225 else if (leftvt == VT_RECORD && rightvt > VT_UI1)
2226 expectedhres = DISP_E_BADVARTYPE;
2228 expectedhres = DISP_E_BADVARTYPE;
2231 else if ((leftvt == VT_NULL && rightvt == VT_DISPATCH) ||
2232 (leftvt == VT_DISPATCH && rightvt == VT_NULL))
2234 else if (leftvt == VT_DISPATCH || rightvt == VT_DISPATCH ||
2235 leftvt == VT_ERROR || rightvt == VT_ERROR)
2238 expectedhres = DISP_E_TYPEMISMATCH;
2240 else if (leftvt == VT_NULL || rightvt == VT_NULL)
2242 else if ((leftvt == VT_EMPTY && rightvt == VT_BSTR) ||
2243 (leftvt == VT_DATE && rightvt == VT_DATE) ||
2244 (leftvt == VT_BSTR && rightvt == VT_EMPTY) ||
2245 (leftvt == VT_BSTR && rightvt == VT_BSTR))
2247 else if (leftvt == VT_DECIMAL || rightvt == VT_DECIMAL)
2249 else if (leftvt == VT_DATE || rightvt == VT_DATE)
2251 else if (leftvt == VT_CY || rightvt == VT_CY)
2253 else if (leftvt == VT_R8 || rightvt == VT_R8)
2255 else if (leftvt == VT_BSTR || rightvt == VT_BSTR) {
2257 } else if (leftvt == VT_R4 || rightvt == VT_R4) {
2258 if (leftvt == VT_I4 || rightvt == VT_I4 ||
2259 leftvt == VT_I8 || rightvt == VT_I8)
2264 else if (leftvt == VT_I8 || rightvt == VT_I8)
2266 else if (leftvt == VT_I4 || rightvt == VT_I4)
2268 else if (leftvt == VT_I2 || rightvt == VT_I2 ||
2269 leftvt == VT_BOOL || rightvt == VT_BOOL ||
2270 (leftvt == VT_EMPTY && rightvt == VT_EMPTY))
2272 else if (leftvt == VT_UI1 || rightvt == VT_UI1)
2277 expectedhres = DISP_E_TYPEMISMATCH;
2280 hres = pVarSub(&left, &right, &result);
2282 ok(hres == expectedhres && V_VT(&result) == resvt,
2283 "VarSub: %d|0x%X, %d|0x%X: Expected failure 0x%X, "
2284 "got 0x%X, expected vt %d got vt %d\n",
2285 leftvt, ExtraFlags[i], rightvt, ExtraFlags[i],
2286 expectedhres, hres, resvt, V_VT(&result));
2291 /* Test returned values */
2292 VARSUB(I4,4,I4,2,I4,2);
2293 VARSUB(I2,4,I2,2,I2,2);
2294 VARSUB(I2,-13,I4,5,I4,-18);
2295 VARSUB(I4,-13,I4,5,I4,-18);
2296 VARSUB(I2,7,R4,0.5f,R4,6.5f);
2297 VARSUB(R4,0.5f,I4,5,R8,-4.5);
2298 VARSUB(R8,7.1,BOOL,0,R8,7.1);
2299 VARSUB(BSTR,lbstr,I2,4,R8,8);
2300 VARSUB(BSTR,lbstr,BOOL,1,R8,11);
2301 VARSUB(BSTR,lbstr,R4,0.1f,R8,11.9);
2302 VARSUB(R4,0.2f,BSTR,rbstr,R8,-11.8);
2303 VARSUB(DATE,2.25,I4,7,DATE,-4.75);
2304 VARSUB(DATE,1.25,R4,-1.7f,DATE,2.95);
2306 VARSUB(UI1, UI1_MAX, UI1, UI1_MAX, UI1, 0);
2307 VARSUB(I2, I2_MAX, I2, I2_MAX, I2, 0);
2308 VARSUB(I2, I2_MIN, I2, I2_MIN, I2, 0);
2309 VARSUB(I4, I4_MAX, I4, I4_MAX, I4, 0);
2310 VARSUB(I4, I4_MIN, I4, I4_MIN, I4, 0);
2311 VARSUB(R4, R4_MAX, R4, R4_MAX, R4, 0.0f);
2312 VARSUB(R4, R4_MAX, R4, R4_MIN, R4, R4_MAX - R4_MIN);
2313 VARSUB(R4, R4_MIN, R4, R4_MIN, R4, 0.0f);
2314 VARSUB(R8, R8_MAX, R8, R8_MIN, R8, R8_MAX - R8_MIN);
2315 VARSUB(R8, R8_MIN, R8, R8_MIN, R8, 0.0);
2317 /* Manually test BSTR + BSTR */
2318 V_VT(&left) = VT_BSTR;
2319 V_BSTR(&left) = lbstr;
2320 V_VT(&right) = VT_BSTR;
2321 V_BSTR(&right) = rbstr;
2322 hres = pVarSub(&left, &right, &result);
2323 ok(hres == S_OK && V_VT(&result) == VT_R8,
2324 "VarSub: expected coerced type VT_R8, got %s!\n", vtstr(V_VT(&result)));
2325 ok(hres == S_OK && EQ_DOUBLE(V_R8(&result), 0),
2326 "VarSub: BSTR + BSTR, expected %f got %f\n", 0.0, V_R8(&result));
2328 /* Manually test some VT_CY and VT_DECIMAL variants */
2330 hres = VarCyFromI4(4711, &V_CY(&cy));
2331 ok(hres == S_OK, "VarCyFromI4 failed!\n");
2332 V_VT(&dec) = VT_DECIMAL;
2333 hres = VarDecFromR8(-4.2, &V_DECIMAL(&dec));
2334 ok(hres == S_OK, "VarDecFromR4 failed!\n");
2335 memset(&left, 0, sizeof(left));
2336 memset(&right, 0, sizeof(right));
2337 V_VT(&left) = VT_I4;
2339 V_VT(&right) = VT_UI1;
2342 hres = pVarSub(&cy, &right, &result);
2343 ok(hres == S_OK && V_VT(&result) == VT_CY,
2344 "VarSub: expected coerced type VT_CY, got %s!\n", vtstr(V_VT(&result)));
2345 hres = VarR8FromCy(V_CY(&result), &r);
2346 ok(hres == S_OK && EQ_DOUBLE(r, 4702),
2347 "VarSub: CY value %f, expected %f\n", r, (double)4720);
2349 hres = pVarSub(&left, &dec, &result);
2350 ok(hres == S_OK && V_VT(&result) == VT_DECIMAL,
2351 "VarSub: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result)));
2352 hres = VarR8FromDec(&V_DECIMAL(&result), &r);
2353 ok(hres == S_OK && EQ_DOUBLE(r, -6.8),
2354 "VarSub: DECIMAL value %f, expected %f\n", r, (double)-15.2);
2356 SysFreeString(lbstr);
2357 SysFreeString(rbstr);
2360 static HRESULT (WINAPI *pVarMod)(LPVARIANT,LPVARIANT,LPVARIANT);
2362 static void test_Mod( int line, VARIANT *left, VARIANT *right, VARIANT *expected, HRESULT expres )
2367 memset( &result, 0, sizeof(result) );
2368 hres = pVarMod( left, right, &result );
2369 ok_(__FILE__,line)( hres == expres, "wrong result %x/%x\n", hres, expres );
2371 ok_(__FILE__,line)( is_expected_variant( &result, expected ),
2372 "got %s expected %s\n", variantstr(&result), variantstr(expected) );
2375 #define VARMOD(vt1,vt2,val1,val2,rvt,rval) \
2376 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
2377 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
2378 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
2379 test_var_call2( __LINE__, pVarMod, &left, &right, &exp )
2381 #define VARMOD2(vt1,vt2,val1,val2,rvt,rval,hexpected) \
2382 V_VT(&left) = VT_##vt1; V_I4(&left) = val1; \
2383 V_VT(&right) = VT_##vt2; V_I4(&right) = val2; \
2384 V_VT(&exp) = VT_##rvt; V_I4(&exp) = rval; \
2385 test_Mod( __LINE__, &left, &right, &exp, hexpected )
2387 static void test_VarMod(void)
2389 VARIANT v1, v2, vDst, left, right, exp;
2391 HRESULT hexpected = 0;
2392 static const WCHAR szNum0[] = {'1','2','5','\0'};
2393 static const WCHAR szNum1[] = {'1','0','\0'};
2395 BOOL lFound, rFound;
2397 BSTR strNum0, strNum1;
2401 VARMOD(I1,BOOL,100,10,I4,0);
2402 VARMOD(I1,I1,100,10,I4,0);
2403 VARMOD(I1,UI1,100,10,I4,0);
2404 VARMOD(I1,I2,100,10,I4,0);
2405 VARMOD(I1,UI2,100,10,I4,0);
2406 VARMOD(I1,I4,100,10,I4,0);
2407 VARMOD(I1,UI4,100,10,I4,0);
2408 VARMOD(I1,R4,100,10,I4,0);
2409 VARMOD(I1,R8,100,10,I4,0);
2411 VARMOD(UI1,BOOL,100,10,I2,0);
2412 VARMOD(UI1,I1,100,10,I4,0);
2413 VARMOD(UI1,UI1,100,10,UI1,0);
2414 VARMOD(UI1,I2,100,10,I2,0);
2415 VARMOD(UI1,UI2,100,10,I4,0);
2416 VARMOD(UI1,I4,100,10,I4,0);
2417 VARMOD(UI1,UI4,100,10,I4,0);
2418 VARMOD(UI1,R4,100,10,I4,0);
2419 VARMOD(UI1,R8,100,10,I4,0);
2421 VARMOD(I2,BOOL,100,10,I2,0);
2422 VARMOD(I2,I1,100,10,I4,0);
2423 VARMOD(I2,UI1,100,10,I2,0);
2424 VARMOD(I2,I2,100,10,I2,0);
2425 VARMOD(I2,UI2,100,10,I4,0);
2426 VARMOD(I2,I4,100,10,I4,0);
2427 VARMOD(I2,UI4,100,10,I4,0);
2428 VARMOD(I2,R4,100,10,I4,0);
2429 VARMOD(I2,R8,100,10,I4,0);
2431 VARMOD(I4,BOOL,100,10,I4,0);
2432 VARMOD(I4,I1,100,10,I4,0);
2433 VARMOD(I4,UI1,100,10,I4,0);
2434 VARMOD(I4,I2,100,10,I4,0);
2435 VARMOD(I4,UI2,100,10,I4,0);
2436 VARMOD(I4,I4,100,10,I4,0);
2437 VARMOD(I4,UI4,100,10,I4,0);
2438 VARMOD(I4,R4,100,10,I4,0);
2439 VARMOD(I4,R8,100,10,I4,0);
2440 VARMOD(UI4,BOOL,100,10,I4,0);
2441 VARMOD(UI4,I1,100,10,I4,0);
2442 VARMOD(UI4,UI1,100,10,I4,0);
2443 VARMOD(UI4,I2,100,10,I4,0);
2444 VARMOD(UI4,UI2,100,10,I4,0);
2445 VARMOD(UI4,I4,100,10,I4,0);
2446 VARMOD(UI4,UI4,100,10,I4,0);
2447 VARMOD(UI4,R4,100,10,I4,0);
2448 VARMOD(UI4,R8,100,10,I4,0);
2449 VARMOD(R4,BOOL,100,10,I4,0);
2450 VARMOD(R4,I1,100,10,I4,0);
2451 VARMOD(R4,UI1,100,10,I4,0);
2452 VARMOD(R4,I2,100,10,I4,0);
2453 VARMOD(R4,UI2,100,10,I4,0);
2454 VARMOD(R4,I4,100,10,I4,0);
2455 VARMOD(R4,UI4,100,10,I4,0);
2456 VARMOD(R4,R4,100,10,I4,0);
2457 VARMOD(R4,R8,100,10,I4,0);
2458 VARMOD(R8,BOOL,100,10,I4,0);
2459 VARMOD(R8,I1,100,10,I4,0);
2460 VARMOD(R8,UI1,100,10,I4,0);
2461 VARMOD(R8,I2,100,10,I4,0);
2462 VARMOD(R8,UI2,100,10,I4,0);
2463 VARMOD(R8,I4,100,10,I4,0);
2464 VARMOD(R8,UI4,100,10,I4,0);
2465 VARMOD(R8,R4,100,10,I4,0);
2466 VARMOD(R8,R8,100,10,I4,0);
2468 VARMOD(INT,INT,100,10,I4,0);
2469 VARMOD(INT,UINT,100,10,I4,0);
2471 VARMOD(BOOL,BOOL,100,10,I2,0);
2472 VARMOD(BOOL,I1,100,10,I4,0);
2473 VARMOD(BOOL,UI1,100,10,I2,0);
2474 VARMOD(BOOL,I2,100,10,I2,0);
2475 VARMOD(BOOL,UI2,100,10,I4,0);
2476 VARMOD(BOOL,I4,100,10,I4,0);
2477 VARMOD(BOOL,UI4,100,10,I4,0);
2478 VARMOD(BOOL,R4,100,10,I4,0);
2479 VARMOD(BOOL,R8,100,10,I4,0);
2480 VARMOD(BOOL,DATE,100,10,I4,0);
2482 VARMOD(DATE,BOOL,100,10,I4,0);
2483 VARMOD(DATE,I1,100,10,I4,0);
2484 VARMOD(DATE,UI1,100,10,I4,0);
2485 VARMOD(DATE,I2,100,10,I4,0);
2486 VARMOD(DATE,UI2,100,10,I4,0);
2487 VARMOD(DATE,I4,100,10,I4,0);
2488 VARMOD(DATE,UI4,100,10,I4,0);
2489 VARMOD(DATE,R4,100,10,I4,0);
2490 VARMOD(DATE,R8,100,10,I4,0);
2491 VARMOD(DATE,DATE,100,10,I4,0);
2493 strNum0 = SysAllocString(szNum0);
2494 strNum1 = SysAllocString(szNum1);
2495 VARMOD(BSTR,BSTR,strNum0,strNum1,I4,5);
2496 VARMOD(BSTR,I1,strNum0,10,I4,5);
2497 VARMOD(BSTR,I2,strNum0,10,I4,5);
2498 VARMOD(BSTR,I4,strNum0,10,I4,5);
2499 VARMOD(BSTR,R4,strNum0,10,I4,5);
2500 VARMOD(BSTR,R8,strNum0,10,I4,5);
2501 VARMOD(I4,BSTR,125,strNum1,I4,5);
2503 if (HAVE_OLEAUT32_I8)
2505 VARMOD(BOOL,I8,100,10,I8,0);
2506 VARMOD(I1,I8,100,10,I8,0);
2507 VARMOD(UI1,I8,100,10,I8,0);
2508 VARMOD(I2,I8,100,10,I8,0);
2509 VARMOD(I4,I8,100,10,I8,0);
2510 VARMOD(UI4,I8,100,10,I8,0);
2511 VARMOD(R4,I8,100,10,I8,0);
2512 VARMOD(R8,I8,100,10,I8,0);
2513 VARMOD(DATE,I8,100,10,I8,0);
2515 VARMOD(I8,BOOL,100,10,I8,0);
2516 VARMOD(I8,I1,100,10,I8,0);
2517 VARMOD(I8,UI1,100,10,I8,0);
2518 VARMOD(I8,I2,100,10,I8,0);
2519 VARMOD(I8,UI2,100,10,I8,0);
2520 VARMOD(I8,I4,100,10,I8,0);
2521 VARMOD(I8,UI4,100,10,I8,0);
2522 VARMOD(I8,R4,100,10,I8,0);
2523 VARMOD(I8,R8,100,10,I8,0);
2524 VARMOD(I8,I8,100,10,I8,0);
2526 VARMOD(BSTR,I8,strNum0,10,I8,5);
2529 /* test all combinations of types */
2530 for(l = 0; l < VT_BSTR_BLOB; l++)
2534 for(r = 0; r < VT_BSTR_BLOB; r++)
2538 if(l == VT_BSTR) continue;
2539 if(l == VT_DISPATCH) continue;
2540 if(r == VT_BSTR) continue;
2541 if(r == VT_DISPATCH) continue;
2575 hexpected = DISP_E_BADVARTYPE;
2612 if(((l == VT_I8) && (r == VT_INT)) || ((l == VT_INT) && (r == VT_I8)))
2614 hexpected = DISP_E_TYPEMISMATCH;
2615 } else if((l == VT_EMPTY) && (r == VT_NULL))
2618 } else if((l == VT_NULL) && (r == VT_EMPTY))
2621 } else if((l == VT_EMPTY) && (r == VT_CY))
2624 } else if((l == VT_EMPTY) && (r == VT_RECORD))
2626 hexpected = DISP_E_TYPEMISMATCH;
2627 } else if((r == VT_EMPTY) && lFound && lValid)
2629 hexpected = DISP_E_DIVBYZERO;
2630 } else if((l == VT_ERROR) || ((r == VT_ERROR) && lFound && lValid))
2632 hexpected = DISP_E_TYPEMISMATCH;
2633 } else if((l == VT_NULL) && (r == VT_NULL))
2636 } else if((l == VT_VARIANT) || ((r == VT_VARIANT) && lFound && lValid))
2638 hexpected = DISP_E_TYPEMISMATCH;
2639 } else if((l == VT_NULL) && (r == VT_RECORD))
2641 hexpected = DISP_E_TYPEMISMATCH;
2642 } else if((l == VT_I8) && (r == VT_DECIMAL))
2645 } else if((l == VT_DECIMAL) && (r == VT_I8))
2648 } else if((l == VT_UNKNOWN) || ((r == VT_UNKNOWN) && lFound && lValid))
2650 hexpected = DISP_E_TYPEMISMATCH;
2651 } else if((l == VT_NULL) && rFound)
2654 } else if(l == VT_RECORD)
2656 hexpected = DISP_E_TYPEMISMATCH;
2657 } else if((r == VT_RECORD) && lValid && lFound)
2659 hexpected = DISP_E_TYPEMISMATCH;
2660 } else if((l == VT_EMPTY) && (r == VT_EMPTY))
2662 hexpected = DISP_E_DIVBYZERO;
2663 } else if((l == VT_CY) && !rFound)
2665 hexpected = DISP_E_BADVARTYPE;
2666 } else if(lFound && !rFound)
2668 hexpected = DISP_E_BADVARTYPE;
2669 } else if(!lFound && rFound)
2671 hexpected = DISP_E_BADVARTYPE;
2672 } else if((r == VT_NULL) && lFound && lValid)
2675 } else if((l == VT_NULL) || (r == VT_NULL))
2677 hexpected = DISP_E_BADVARTYPE;
2678 } else if((l == VT_VARIANT) || (r == VT_VARIANT))
2680 hexpected = DISP_E_BADVARTYPE;
2681 } else if(lFound && !rFound)
2683 hexpected = DISP_E_BADVARTYPE;
2684 } else if(!lFound && !rFound)
2686 hexpected = DISP_E_BADVARTYPE;
2693 V_CY(&v1).int64 = 1000000;
2698 else if(l == VT_UI8)
2702 else if(l == VT_DATE)
2704 else if (l == VT_DECIMAL)
2706 V_DECIMAL(&v1).Hi32 = 0;
2707 U1(V_DECIMAL(&v1)).Lo64 = 100;
2708 U(V_DECIMAL(&v1)).signscale = 0;
2714 V_CY(&v2).int64 = 10000;
2719 else if(r == VT_UI8)
2723 else if(r == VT_DATE)
2725 else if (r == VT_DECIMAL)
2727 V_DECIMAL(&v2).Hi32 = 0;
2728 U1(V_DECIMAL(&v2)).Lo64 = 100;
2729 U(V_DECIMAL(&v2)).signscale = 0;
2734 if ((l != VT_I8 && l != VT_UI8 && r != VT_I8 && r != VT_UI8) || HAVE_OLEAUT32_I8)
2736 hres = pVarMod(&v1,&v2,&vDst);
2737 ok(hres == hexpected,
2738 "VarMod: expected 0x%x, got 0x%X for l type of %d, r type of %d,\n", hexpected, hres, l, r);
2744 /****************************/
2745 /* test some bad parameters */
2746 VARMOD(I4,I4,-1,-1,I4,0);
2748 /* test modulus with zero */
2749 VARMOD2(I4,I4,100,0,EMPTY,0,DISP_E_DIVBYZERO);
2751 VARMOD(I4,I4,0,10,I4,0); /* test 0 mod 10 */
2753 /* right parameter is type empty */
2754 VARMOD2(I4,EMPTY,100,10,EMPTY,0,DISP_E_DIVBYZERO);
2756 /* left parameter is type empty */
2757 VARMOD2(EMPTY,I4,100,10,I4,0,S_OK);
2759 /* mod with a null left value */
2760 VARMOD2(NULL,I4,125,10,NULL,0,S_OK);
2762 /* mod with a null right value */
2763 VARMOD2(I4,NULL,100,10,NULL,0,S_OK);
2765 /* void left value */
2766 VARMOD2(VOID,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2768 /* void right value */
2769 VARMOD2(I4,VOID,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2771 /* null left value, void right value */
2772 VARMOD2(NULL,VOID,100,10,EMPTY, 0, DISP_E_BADVARTYPE);
2774 /* void left value, null right value */
2775 VARMOD2(VOID,NULL,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2777 /* some currencies */
2780 V_CY(&v1).int64 = 100000;
2781 V_CY(&v2).int64 = 100000;
2782 hres = pVarMod(&v1,&v2,&vDst);
2783 ok(hres == S_OK && V_VT(&vDst) == VT_I4 && V_I4(&vDst) == 0,
2784 "VarMod: expected 0x%x,%d,%d, got 0x%X,%d,%d\n", S_OK, VT_I4, 0, hres, V_VT(&vDst), V_I4(&vDst));
2789 V_CY(&v2).int64 = 100000;
2790 hres = pVarMod(&v1,&v2,&vDst);
2791 ok(hres == S_OK && V_VT(&vDst) == VT_I4 && V_I4(&vDst) == 0,
2792 "VarMod: expected 0x%x,%d,%d, got 0x%X,%d,%d\n", S_OK, VT_I4, 0, hres, V_VT(&vDst), V_I4(&vDst));
2795 V_VT(&v1) = VT_DECIMAL;
2796 V_VT(&v2) = VT_DECIMAL;
2797 VarDecFromI4(100, &V_DECIMAL(&v1));
2798 VarDecFromI4(10, &V_DECIMAL(&v2));
2799 hres = pVarMod(&v1,&v2,&vDst);
2800 ok(hres == S_OK && V_VT(&vDst) == VT_I4 && V_I4(&vDst) == 0,
2801 "VarMod: expected 0x%x,%d,%d, got 0x%X,%d,%d\n", S_OK, VT_I4, 0, hres, V_VT(&vDst), V_I4(&vDst));
2804 V_VT(&v2) = VT_DECIMAL;
2806 VarDecFromI4(10, &V_DECIMAL(&v2));
2807 hres = pVarMod(&v1,&v2,&vDst);
2808 ok(hres == S_OK && V_VT(&vDst) == VT_I4 && V_I4(&vDst) == 0,
2809 "VarMod: expected 0x%x,%d,%d, got 0x%X,%d,%d\n", S_OK, VT_I4, 0, hres, V_VT(&vDst), V_I4(&vDst));
2811 VARMOD2(UINT,I4,100,10,I4,0,S_OK);
2813 /* test that an error results in the type of the result changing but not its value */
2814 V_VT(&v1) = VT_UNKNOWN;
2815 V_VT(&v2) = VT_EMPTY;
2817 V_CY(&v2).int64 = 100000;
2818 V_VT(&vDst) = VT_I4;
2820 hres = pVarMod(&v1,&v2,&vDst);
2821 ok(hres == DISP_E_TYPEMISMATCH && V_VT(&vDst) == VT_EMPTY && V_I4(&vDst) == 1231,
2822 "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));
2825 /* test some invalid types */
2826 /*TODO: not testing VT_DISPATCH */
2827 if (HAVE_OLEAUT32_I8)
2829 VARMOD2(I8,INT,100,10,EMPTY,0,DISP_E_TYPEMISMATCH);
2831 VARMOD2(ERROR,I4,100,10,EMPTY,0,DISP_E_TYPEMISMATCH);
2832 VARMOD2(VARIANT,I4,100,10,EMPTY,0,DISP_E_TYPEMISMATCH);
2833 VARMOD2(UNKNOWN,I4,100,10,EMPTY,0,DISP_E_TYPEMISMATCH);
2834 VARMOD2(VOID,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2835 VARMOD2(HRESULT,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2836 VARMOD2(PTR,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2837 VARMOD2(SAFEARRAY,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2838 VARMOD2(CARRAY,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2839 VARMOD2(USERDEFINED,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2840 VARMOD2(LPSTR,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2841 VARMOD2(LPWSTR,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2842 VARMOD2(RECORD,I4,100,10,EMPTY,0,DISP_E_TYPEMISMATCH);
2843 VARMOD2(FILETIME,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2844 VARMOD2(BLOB,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2845 VARMOD2(STREAM,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2846 VARMOD2(STORAGE,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2847 VARMOD2(STREAMED_OBJECT,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2848 VARMOD2(STORED_OBJECT,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2849 VARMOD2(BLOB_OBJECT,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2850 VARMOD2(CF,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2851 VARMOD2(CLSID,CLSID,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2852 VARMOD2(VECTOR,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2853 VARMOD2(ARRAY,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2854 VARMOD2(BYREF,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2856 /* test some more invalid types */
2861 hres = pVarMod(&v1,&v2,&vDst);
2862 ok(hres == DISP_E_BADVARTYPE && V_VT(&vDst) == VT_EMPTY,
2863 "VarMod: expected 0x%x,%d, got 0x%X,%d\n", DISP_E_BADVARTYPE, VT_EMPTY, hres, V_VT(&vDst));
2865 SysFreeString(strNum0);
2866 SysFreeString(strNum1);
2869 static HRESULT (WINAPI *pVarFix)(LPVARIANT,LPVARIANT);
2871 #define VARFIX(vt,val,rvt,rval) \
2872 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
2873 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
2874 test_var_call1( __LINE__, pVarFix, &v, &exp )
2876 static void test_VarFix(void)
2878 static const WCHAR szNumMinus1[] = {'-','1','\0' };
2880 VARIANT v, exp, vDst;
2881 DECIMAL *pdec = &V_DECIMAL(&v);
2882 CY *pcy = &V_CY(&v);
2887 /* Test all possible V_VT values */
2888 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
2892 for (vt = 0; vt <= VT_BSTR_BLOB; vt++)
2894 HRESULT bFail = TRUE;
2898 memset(&v, 0, sizeof(v));
2899 V_VT(&v) = vt | ExtraFlags[i];
2900 V_VT(&vDst) = VT_EMPTY;
2904 case VT_UI1: case VT_I2: case VT_I4: case VT_R4: case VT_R8:
2905 case VT_DECIMAL: case VT_BOOL: case VT_NULL: case VT_EMPTY:
2906 case VT_DATE: case VT_CY:
2910 if (HAVE_OLEAUT32_I8)
2915 hres = pVarFix(&v,&vDst);
2917 ok(hres == DISP_E_TYPEMISMATCH || hres == DISP_E_BADVARTYPE,
2918 "VarFix: expected failure, got 0x%X vt %d|0x%X\n",
2919 hres, vt, ExtraFlags[i]);
2921 ok(hres == S_OK, "VarFix: expected S_OK, got 0x%X vt %d|0x%X\n",
2922 hres, vt, ExtraFlags[i]);
2926 VARFIX(BOOL,VARIANT_TRUE,I2,VARIANT_TRUE);
2927 VARFIX(BOOL,VARIANT_FALSE,I2,0);
2928 VARFIX(BOOL,1,I2,1);
2929 VARFIX(UI1,1,UI1,1);
2930 VARFIX(I2,-1,I2,-1);
2931 VARFIX(I4,-1,I4,-1);
2932 if (HAVE_OLEAUT32_I8)
2934 VARFIX(I8,-1,I8,-1);
2936 VARFIX(R4,1.4f,R4,1);
2937 VARFIX(R4,1.5f,R4,1);
2938 VARFIX(R4,1.6f,R4,1);
2939 VARFIX(R4,-1.4f,R4,-1);
2940 VARFIX(R4,-1.5f,R4,-1);
2941 VARFIX(R4,-1.6f,R4,-1);
2942 /* DATE & R8 round as for R4 */
2943 VARFIX(DATE,-1,DATE,-1);
2944 VARFIX(R8,-1,R8,-1);
2945 VARFIX(BSTR,(BSTR)szNumMinus1,R8,-1);
2947 V_VT(&v) = VT_EMPTY;
2948 hres = pVarFix(&v,&vDst);
2949 ok(hres == S_OK && V_VT(&vDst) == VT_I2 && V_I2(&vDst) == 0,
2950 "VarFix: expected 0x0,%d,0 got 0x%X,%d,%d\n", VT_EMPTY,
2951 hres, V_VT(&vDst), V_I2(&vDst));
2954 hres = pVarFix(&v,&vDst);
2955 ok(hres == S_OK && V_VT(&vDst) == VT_NULL,
2956 "VarFix: expected 0x0,%d got 0x%X,%d\n", VT_NULL, hres, V_VT(&vDst));
2958 V_VT(&v) = VT_DECIMAL;
2959 S(U(*pdec)).sign = DECIMAL_NEG;
2960 S(U(*pdec)).scale = 0;
2962 S1(U1(*pdec)).Mid32 = 0;
2963 S1(U1(*pdec)).Lo32 = 1;
2964 hres = pVarFix(&v,&vDst);
2965 ok(hres == S_OK && V_VT(&vDst) == VT_DECIMAL && !memcmp(&V_DECIMAL(&v), &V_DECIMAL(&vDst), sizeof(DECIMAL)),
2966 "VarFix: expected 0x0,%d,identical, got 0x%X,%d\n", VT_DECIMAL,
2969 /* FIXME: Test some fractional decimals when VarDecFix is implemented */
2972 pcy->int64 = -10000;
2973 hres = pVarFix(&v,&vDst);
2974 ok(hres == S_OK && V_VT(&vDst) == VT_CY && V_CY(&vDst).int64 == -10000,
2975 "VarFix: VT_CY wrong, hres=0x%X\n", hres);
2978 pcy->int64 = -16000;
2979 hres = pVarFix(&v,&vDst);
2980 ok(hres == S_OK && V_VT(&vDst) == VT_CY && V_CY(&vDst).int64 == -10000,
2981 "VarFix: VT_CY wrong, hres=0x%X\n", hres);
2984 static HRESULT (WINAPI *pVarInt)(LPVARIANT,LPVARIANT);
2986 #define VARINT(vt,val,rvt,rval) \
2987 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
2988 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
2989 test_var_call1( __LINE__, pVarInt, &v, &exp )
2991 static void test_VarInt(void)
2993 static const WCHAR szNumMinus1[] = {'-','1','\0' };
2995 VARIANT v, exp, vDst;
2996 DECIMAL *pdec = &V_DECIMAL(&v);
2997 CY *pcy = &V_CY(&v);
3002 /* Test all possible V_VT values */
3003 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
3007 for (vt = 0; vt <= VT_BSTR_BLOB; vt++)
3009 HRESULT bFail = TRUE;
3013 memset(&v, 0, sizeof(v));
3014 V_VT(&v) = vt | ExtraFlags[i];
3015 V_VT(&vDst) = VT_EMPTY;
3019 case VT_UI1: case VT_I2: case VT_I4: case VT_R4: case VT_R8:
3020 case VT_DECIMAL: case VT_BOOL: case VT_NULL: case VT_EMPTY:
3021 case VT_DATE: case VT_CY:
3025 if (HAVE_OLEAUT32_I8)
3030 hres = pVarInt(&v,&vDst);
3032 ok(hres == DISP_E_TYPEMISMATCH || hres == DISP_E_BADVARTYPE,
3033 "VarInt: expected failure, got 0x%X vt %d|0x%X\n",
3034 hres, vt, ExtraFlags[i]);
3036 ok(hres == S_OK, "VarInt: expected S_OK, got 0x%X vt %d|0x%X\n",
3037 hres, vt, ExtraFlags[i]);
3041 VARINT(BOOL,VARIANT_TRUE,I2,VARIANT_TRUE);
3042 VARINT(BOOL,VARIANT_FALSE,I2,0);
3043 VARINT(BOOL,1,I2,1);
3044 VARINT(UI1,1,UI1,1);
3045 VARINT(I2,-1,I2,-1);
3046 VARINT(I4,-1,I4,-1);
3047 if (HAVE_OLEAUT32_I8)
3049 VARINT(I8,-1,I8,-1);
3051 VARINT(R4,1.4f,R4,1);
3052 VARINT(R4,1.5f,R4,1);
3053 VARINT(R4,1.6f,R4,1);
3054 VARINT(R4,-1.4f,R4,-2); /* Note these 3 are different from VarFix */
3055 VARINT(R4,-1.5f,R4,-2);
3056 VARINT(R4,-1.6f,R4,-2);
3057 /* DATE & R8 round as for R4 */
3058 VARINT(DATE,-1,DATE,-1);
3059 VARINT(R8,-1,R8,-1);
3060 VARINT(BSTR,(BSTR)szNumMinus1,R8,-1);
3062 V_VT(&v) = VT_EMPTY;
3063 hres = pVarInt(&v,&vDst);
3064 ok(hres == S_OK && V_VT(&vDst) == VT_I2 && V_I2(&vDst) == 0,
3065 "VarInt: expected 0x0,%d,0 got 0x%X,%d,%d\n", VT_EMPTY,
3066 hres, V_VT(&vDst), V_I2(&vDst));
3069 hres = pVarInt(&v,&vDst);
3070 ok(hres == S_OK && V_VT(&vDst) == VT_NULL,
3071 "VarInt: expected 0x0,%d got 0x%X,%d\n", VT_NULL, hres, V_VT(&vDst));
3073 V_VT(&v) = VT_DECIMAL;
3074 S(U(*pdec)).sign = DECIMAL_NEG;
3075 S(U(*pdec)).scale = 0;
3077 S1(U1(*pdec)).Mid32 = 0;
3078 S1(U1(*pdec)).Lo32 = 1;
3079 hres = pVarInt(&v,&vDst);
3080 ok(hres == S_OK && V_VT(&vDst) == VT_DECIMAL && !memcmp(&V_DECIMAL(&v), &V_DECIMAL(&vDst), sizeof(DECIMAL)),
3081 "VarInt: expected 0x0,%d,identical, got 0x%X,%d\n", VT_DECIMAL,
3084 /* FIXME: Test some fractional decimals when VarDecInt is implemented */
3087 pcy->int64 = -10000;
3088 hres = pVarInt(&v,&vDst);
3089 ok(hres == S_OK && V_VT(&vDst) == VT_CY && V_CY(&vDst).int64 == -10000,
3090 "VarInt: VT_CY wrong, hres=0x%X\n", hres);
3093 pcy->int64 = -11000;
3094 hres = pVarInt(&v,&vDst);
3095 ok(hres == S_OK && V_VT(&vDst) == VT_CY && V_CY(&vDst).int64 == -20000,
3096 "VarInt: VT_CY wrong, hres=0x%X 0x%x%08x\n",
3097 hres, (DWORD)(V_CY(&vDst).int64 >> 32), (DWORD)V_CY(&vDst).int64);
3100 static HRESULT (WINAPI *pVarNeg)(LPVARIANT,LPVARIANT);
3102 #define VARNEG(vt,val,rvt,rval) \
3103 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
3104 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
3105 test_var_call1( __LINE__, pVarNeg, &v, &exp )
3107 static void test_VarNeg(void)
3109 static const WCHAR szNumMinus1[] = {'-','1','\0' };
3110 static const WCHAR szNum1[] = {'1','\0' };
3112 VARIANT v, exp, vDst;
3113 DECIMAL *pdec = &V_DECIMAL(&v);
3114 CY *pcy = &V_CY(&v);
3119 /* Test all possible V_VT values. But don't test the exact return values
3120 * except for success/failure, since M$ made a hash of them in the
3121 * native version. This at least ensures (as with all tests here) that
3122 * we will notice if/when new vtypes/flags are added in native.
3124 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
3128 for (vt = 0; vt <= VT_BSTR_BLOB; vt++)
3130 HRESULT bFail = TRUE;
3134 memset(&v, 0, sizeof(v));
3135 V_VT(&v) = vt | ExtraFlags[i];
3136 V_VT(&vDst) = VT_EMPTY;
3140 case VT_UI1: case VT_I2: case VT_I4:
3141 case VT_R4: case VT_R8:
3142 case VT_DECIMAL: case VT_BOOL: case VT_NULL: case VT_EMPTY:
3143 case VT_DATE: case VT_CY:
3147 if (HAVE_OLEAUT32_I8)
3151 hres = pVarNeg(&v,&vDst);
3153 ok(hres == DISP_E_TYPEMISMATCH || hres == DISP_E_BADVARTYPE,
3154 "VarNeg: expected failure, got 0x%X vt %d|0x%X\n",
3155 hres, vt, ExtraFlags[i]);
3157 ok(hres == S_OK, "VarNeg: expected S_OK, got 0x%X vt %d|0x%X\n",
3158 hres, vt, ExtraFlags[i]);
3162 VARNEG(BOOL,VARIANT_TRUE,I2,1);
3163 VARNEG(BOOL,VARIANT_FALSE,I2,0);
3164 VARNEG(BOOL,1,I2,-1);
3165 VARNEG(UI1,1,I2,-1);
3166 VARNEG(UI1,254,I2,-254);
3167 VARNEG(I2,-32768,I4,32768);
3170 VARNEG(I4,-((int)(~0u >> 1)) - 1,R8,-2147483648u);
3173 if (HAVE_OLEAUT32_I8)
3180 VARNEG(DATE,1,DATE,-1);
3181 VARNEG(DATE,-1,DATE,1);
3184 VARNEG(BSTR,(BSTR)szNumMinus1,R8,1);
3185 VARNEG(BSTR,(BSTR)szNum1,R8,-1);
3187 V_VT(&v) = VT_EMPTY;
3188 hres = pVarNeg(&v,&vDst);
3189 ok(hres == S_OK && V_VT(&vDst) == VT_I2 && V_I2(&vDst) == 0,
3190 "VarNeg: expected 0x0,%d,0 got 0x%X,%d,%d\n", VT_EMPTY,
3191 hres, V_VT(&vDst), V_I2(&vDst));
3194 hres = pVarNeg(&v,&vDst);
3195 ok(hres == S_OK && V_VT(&vDst) == VT_NULL,
3196 "VarNeg: expected 0x0,%d got 0x%X,%d\n", VT_NULL, hres, V_VT(&vDst));
3198 V_VT(&v) = VT_DECIMAL;
3199 S(U(*pdec)).sign = DECIMAL_NEG;
3200 S(U(*pdec)).scale = 0;
3202 S1(U1(*pdec)).Mid32 = 0;
3203 S1(U1(*pdec)).Lo32 = 1;
3204 hres = pVarNeg(&v,&vDst);
3205 ok(hres == S_OK && V_VT(&vDst) == VT_DECIMAL &&
3206 S(U(V_DECIMAL(&vDst))).sign == 0,
3207 "VarNeg: expected 0x0,%d,0x00, got 0x%X,%d,%02x\n", VT_DECIMAL,
3208 hres, V_VT(&vDst), S(U(V_DECIMAL(&vDst))).sign);
3210 S(U(*pdec)).sign = 0;
3211 hres = pVarNeg(&v,&vDst);
3212 ok(hres == S_OK && V_VT(&vDst) == VT_DECIMAL &&
3213 S(U(V_DECIMAL(&vDst))).sign == DECIMAL_NEG,
3214 "VarNeg: expected 0x0,%d,0x7f, got 0x%X,%d,%02x\n", VT_DECIMAL,
3215 hres, V_VT(&vDst), S(U(V_DECIMAL(&vDst))).sign);
3218 pcy->int64 = -10000;
3219 hres = pVarNeg(&v,&vDst);
3220 ok(hres == S_OK && V_VT(&vDst) == VT_CY && V_CY(&vDst).int64 == 10000,
3221 "VarNeg: VT_CY wrong, hres=0x%X\n", hres);
3224 static HRESULT (WINAPI *pVarRound)(LPVARIANT,int,LPVARIANT);
3226 static void test_Round( int line, VARIANT *arg, int deci, VARIANT *expected )
3231 memset( &result, 0, sizeof(result) );
3232 hres = pVarRound( arg, deci, &result );
3233 ok_(__FILE__,line)( hres == S_OK, "wrong result %x\n", hres );
3235 ok_(__FILE__,line)( is_expected_variant( &result, expected ),
3236 "got %s expected %s\n", variantstr(&result), variantstr(expected) );
3238 #define VARROUND(vt,val,deci,rvt,rval) \
3239 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
3240 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
3241 test_Round( __LINE__, &v, deci, &exp )
3251 struct decimal_round_t {
3252 struct decimal_t source;
3253 struct decimal_t ret;
3257 static const struct decimal_round_t decimal_round_data[] = {
3258 {{ 0, DECIMAL_NEG, 0, 0, 1 }, { 0, DECIMAL_NEG, 0, 0, 1 }, 0},
3259 {{ 0, 0, 0, 0, 1 }, { 0, 0, 0, 0, 1 }, 0},
3260 {{ 2, 0, 0, 0, 155 }, { 0, 0, 0, 0, 16 }, 1},
3261 {{ 2, 0, 0, 0, 155 }, { 1, 0, 0, 0, 2 }, 0},
3262 {{ 2, 0, 0, 0, 199 }, { 1, 0, 0, 0, 20 }, 1},
3263 {{ 2, 0, 0, 0, 199 }, { 2, 0, 0, 0, 199 }, 2},
3264 {{ 2, DECIMAL_NEG, 0, 0, 199 }, { 2, DECIMAL_NEG, 0, 0, 199 }, 2},
3265 {{ 2, DECIMAL_NEG, 0, 0, 55 }, { 2, DECIMAL_NEG, 0, 0, 6 }, 1},
3266 {{ 2, 0, 0, 0, 55 }, { 2, 0, 0, 0, 6 }, 1}
3269 static void test_VarRound(void)
3271 static WCHAR szNumMin[] = {'-','1','.','4','4','9','\0' };
3272 static WCHAR szNum[] = {'1','.','4','5','1','\0' };
3274 VARIANT v, exp, vDst;
3275 CY *pcy = &V_CY(&v);
3281 /* first check valid integer types */
3282 VARROUND(BOOL,VARIANT_TRUE,0,I2,-1);
3283 VARROUND(BOOL,VARIANT_FALSE,0,I2,0);
3284 VARROUND(BOOL,1,0,I2,1);
3285 VARROUND(UI1,1,0,UI1,1);
3286 VARROUND(UI1,254,0,UI1,254);
3287 VARROUND(I2,-32768,0,I2,-32768);
3288 VARROUND(I2,-1,0,I2,-1);
3289 VARROUND(I2,1,0,I2,1);
3290 VARROUND(I4,-((int)(~0u >> 1)) - 1,0,I4,-((int)(~0u >> 1)) - 1);
3291 VARROUND(I4,-1,0,I4,-1);
3292 VARROUND(I4,1,0,I4,1);
3295 /* MSDN states that rounding of R4/R8 is dependent on the underlying
3296 * bit pattern of the number and so is architecture dependent. In this
3297 * case Wine returns .2 (which is more correct) and Native returns .3
3300 VARROUND(R4,1.0f,0,R4,1.0f);
3301 VARROUND(R4,-1.0f,0,R4,-1.0f);
3302 VARROUND(R8,1.0,0,R8,1.0);
3303 VARROUND(R8,-1.0,0,R8,-1.0);
3305 /* floating point numbers aren't exactly equal and we can't just
3306 * compare the first few digits. */
3307 VARROUND(DATE,1.451,1,DATE,1.5);
3308 VARROUND(DATE,-1.449,1,DATE,-1.4);
3310 /* replace the decimal separator */
3311 GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, buff, sizeof(buff)/sizeof(char));
3313 szNumMin[2] = buff[0];
3315 VARROUND(BSTR,(BSTR)szNumMin,1,R8,-1.40);
3316 VARROUND(BSTR,(BSTR)szNum,1,R8,1.50);
3318 skip("Skipping VarRound(BSTR) as decimal separator is '%s'\n", buff);
3321 VARROUND(R4,1.23456f,0,R4,1.0f);
3322 VARROUND(R4,1.23456f,1,R4,1.2f);
3323 VARROUND(R4,1.23456f,2,R4,1.23f);
3324 VARROUND(R4,1.23456f,3,R4,1.235f);
3325 VARROUND(R4,1.23456f,4,R4,1.2346f);
3326 VARROUND(R4,-1.23456f,0,R4,-1.0f);
3327 VARROUND(R4,-1.23456f,1,R4,-1.2f);
3328 VARROUND(R4,-1.23456f,2,R4,-1.23f);
3329 VARROUND(R4,-1.23456f,3,R4,-1.235f);
3330 VARROUND(R4,-1.23456f,4,R4,-1.2346f);
3332 VARROUND(R8,1.23456,0,R8,1.0);
3333 VARROUND(R8,1.23456,1,R8,1.2);
3334 VARROUND(R8,1.23456,2,R8,1.23);
3335 VARROUND(R8,1.23456,3,R8,1.235);
3336 VARROUND(R8,1.23456,4,R8,1.2346);
3337 VARROUND(R8,-1.23456,0,R8,-1.0);
3338 VARROUND(R8,-1.23456,1,R8,-1.2);
3339 VARROUND(R8,-1.23456,2,R8,-1.23);
3340 VARROUND(R8,-1.23456,3,R8,-1.235);
3341 VARROUND(R8,-1.23456,4,R8,-1.2346);
3343 V_VT(&v) = VT_EMPTY;
3344 hres = pVarRound(&v,0,&vDst);
3345 ok(hres == S_OK && V_VT(&vDst) == VT_I2 && V_I2(&vDst) == 0,
3346 "VarRound: expected 0x0,%d,0 got 0x%X,%d,%d\n", VT_EMPTY,
3347 hres, V_VT(&vDst), V_I2(&vDst));
3350 hres = pVarRound(&v,0,&vDst);
3351 ok(hres == S_OK && V_VT(&vDst) == VT_NULL,
3352 "VarRound: expected 0x0,%d got 0x%X,%d\n", VT_NULL, hres, V_VT(&vDst));
3355 for (i = 0; i < sizeof(decimal_round_data)/sizeof(struct decimal_round_t); i++)
3357 const struct decimal_round_t *ptr = &decimal_round_data[i];
3360 pdec = &V_DECIMAL(&v);
3361 V_VT(&v) = VT_DECIMAL;
3362 S(U(*pdec)).sign = ptr->source.sign;
3363 S(U(*pdec)).scale = ptr->source.scale;
3364 pdec->Hi32 = ptr->source.Hi32;
3365 S1(U1(*pdec)).Mid32 = ptr->source.Mid32;
3366 S1(U1(*pdec)).Lo32 = ptr->source.Lo32;
3368 hres = pVarRound(&v, ptr->dec, &vDst);
3370 ok(hres == S_OK, "%d: got 0x%08x\n", i, hres);
3373 ok(V_VT(&vDst) == VT_DECIMAL, "%d: got VT %d, expected VT_DECIMAL\n", i, V_VT(&vDst));
3374 ok(S(U(V_DECIMAL(&vDst))).sign == ptr->ret.sign, "%d: got sign 0x%02x, expected 0x%02x\n",
3375 i, S(U(V_DECIMAL(&vDst))).sign, ptr->ret.sign);
3376 ok(V_DECIMAL(&vDst).Hi32 == ptr->ret.Hi32, "%d: got Hi32 %d, expected %d\n",
3377 i, V_DECIMAL(&vDst).Hi32, ptr->ret.Hi32);
3378 ok(S1(U1(V_DECIMAL(&vDst))).Mid32 == ptr->ret.Mid32, "%d: got Mid32 %d, expected %d\n",
3379 i, S1(U1(V_DECIMAL(&vDst))).Mid32, ptr->ret.Mid32);
3380 ok(S1(U1(V_DECIMAL(&vDst))).Lo32 == ptr->ret.Lo32, "%d: got Lo32 %d, expected %d\n",
3381 i, S1(U1(V_DECIMAL(&vDst))).Lo32, ptr->ret.Lo32);
3388 hres = pVarRound(&v,0,&vDst);
3389 ok(hres == S_OK && V_VT(&vDst) == VT_CY && V_CY(&vDst).int64 == 10000,
3390 "VarRound: VT_CY wrong, hres=0x%X\n", hres);
3394 static HRESULT (WINAPI *pVarXor)(LPVARIANT,LPVARIANT,LPVARIANT);
3396 #define VARXOR(vt1,val1,vt2,val2,rvt,rval) \
3397 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
3398 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
3399 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
3400 test_var_call2( __LINE__, pVarXor, &left, &right, &exp )
3402 #define VARXORCY(vt1,val1,val2,rvt,rval) \
3403 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
3404 V_VT(&right) = VT_CY; V_CY(&right).int64 = val2; \
3405 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
3406 test_var_call2( __LINE__, pVarXor, &left, &right, &exp )
3408 static void test_VarXor(void)
3410 static const WCHAR szFalse[] = { '#','F','A','L','S','E','#','\0' };
3411 static const WCHAR szTrue[] = { '#','T','R','U','E','#','\0' };
3412 VARIANT left, right, exp, result;
3419 /* Test all possible flag/vt combinations & the resulting vt type */
3420 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
3422 VARTYPE leftvt, rightvt, resvt;
3424 for (leftvt = 0; leftvt <= VT_BSTR_BLOB; leftvt++)
3429 for (rightvt = 0; rightvt <= VT_BSTR_BLOB; rightvt++)
3435 if (leftvt == VT_BSTR || rightvt == VT_BSTR ||
3436 leftvt == VT_DISPATCH || rightvt == VT_DISPATCH ||
3437 leftvt == VT_UNKNOWN || rightvt == VT_UNKNOWN)
3440 memset(&left, 0, sizeof(left));
3441 memset(&right, 0, sizeof(right));
3442 V_VT(&left) = leftvt | ExtraFlags[i];
3443 V_VT(&right) = rightvt | ExtraFlags[i];
3444 V_VT(&result) = VT_EMPTY;
3447 if (ExtraFlags[i] & VT_ARRAY || ExtraFlags[i] & VT_BYREF ||
3448 !IsValidVariantClearVT(leftvt, ExtraFlags[i]) ||
3449 !IsValidVariantClearVT(rightvt, ExtraFlags[i]) ||
3450 leftvt == VT_CLSID || rightvt == VT_CLSID ||
3451 leftvt == VT_RECORD || rightvt == VT_RECORD ||
3452 leftvt == VT_VARIANT || rightvt == VT_VARIANT ||
3453 leftvt == VT_ERROR || rightvt == VT_ERROR)
3457 if (leftvt == VT_EMPTY || rightvt == VT_EMPTY)
3459 if (leftvt == rightvt ||
3460 leftvt == VT_I2 || rightvt == VT_I2 ||
3461 leftvt == VT_UI1 || rightvt == VT_UI1 ||
3462 leftvt == VT_BOOL || rightvt == VT_BOOL)
3464 else if (leftvt == VT_NULL || rightvt == VT_NULL)
3466 else if (leftvt == VT_I8 || rightvt == VT_I8)
3469 else if (leftvt == VT_NULL || rightvt == VT_NULL)
3473 else if (leftvt == VT_UI1 || rightvt == VT_UI1)
3475 if (leftvt == rightvt)
3477 else if (leftvt == rightvt ||
3478 leftvt == VT_I2 || rightvt == VT_I2 ||
3479 leftvt == VT_BOOL || rightvt == VT_BOOL)
3483 else if (leftvt == VT_I8 || rightvt == VT_I8)
3486 else if (leftvt == VT_I2 || rightvt == VT_I2)
3488 if (leftvt == rightvt ||
3489 leftvt == VT_BOOL || rightvt == VT_BOOL)
3491 else if (leftvt == VT_I8 || rightvt == VT_I8)
3494 else if (leftvt == VT_BOOL && rightvt == VT_BOOL)
3498 else if (leftvt == VT_I8 || rightvt == VT_I8)
3500 if (leftvt == VT_INT || rightvt == VT_INT)
3505 hres = pVarXor(&left, &right, &result);
3507 ok(hres == DISP_E_TYPEMISMATCH || hres == DISP_E_BADVARTYPE,
3508 "VarXor: %d|0x%X, %d|0x%X: Expected failure, got 0x%X vt %d\n",
3509 leftvt, ExtraFlags[i], rightvt, ExtraFlags[i], hres,
3512 ok(hres == S_OK && V_VT(&result) == resvt,
3513 "VarXor: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%X vt %d\n",
3514 leftvt, ExtraFlags[i], rightvt, ExtraFlags[i], resvt, hres,
3520 /* Test returned values
3521 * FIXME: Test VT_DECIMAL/VT_DISPATCH
3523 VARXOR(EMPTY,0,EMPTY,0,I2,0);
3524 VARXOR(EMPTY,1,EMPTY,0,I2,0);
3525 VARXOR(EMPTY,0,NULL,0,NULL,0);
3526 VARXOR(EMPTY,0,I1,0,I4,0);
3527 VARXOR(EMPTY,0,I1,1,I4,1);
3528 VARXOR(EMPTY,0,UI1,0,I2,0);
3529 VARXOR(EMPTY,0,UI1,1,I2,1);
3530 VARXOR(EMPTY,0,I2,0,I2,0);
3531 VARXOR(EMPTY,0,I2,1,I2,1);
3532 VARXOR(EMPTY,0,UI2,0,I4,0);
3533 VARXOR(EMPTY,0,UI2,1,I4,1);
3534 VARXOR(EMPTY,0,I4,0,I4,0);
3535 VARXOR(EMPTY,0,I4,1,I4,1);
3536 VARXOR(EMPTY,0,UI4,0,I4,0);
3537 VARXOR(EMPTY,0,UI4,1,I4,1);
3538 if (HAVE_OLEAUT32_I8)
3540 VARXOR(EMPTY,0,I8,0,I8,0);
3541 VARXOR(EMPTY,0,I8,1,I8,1);
3542 VARXOR(EMPTY,0,UI8,0,I4,0);
3543 VARXOR(EMPTY,0,UI8,1,I4,1);
3545 VARXOR(EMPTY,0,INT,0,I4,0);
3546 VARXOR(EMPTY,0,INT,1,I4,1);
3547 VARXOR(EMPTY,0,UINT,0,I4,0);
3548 VARXOR(EMPTY,0,UINT,1,I4,1);
3549 VARXOR(EMPTY,0,BOOL,0,I2,0);
3550 VARXOR(EMPTY,0,BOOL,1,I2,1);
3551 VARXOR(EMPTY,0,R4,0,I4,0);
3552 VARXOR(EMPTY,0,R4,1,I4,1);
3553 VARXOR(EMPTY,0,R8,0,I4,0);
3554 VARXOR(EMPTY,0,R8,1,I4,1);
3555 rbstr = SysAllocString(szFalse);
3556 VARXOR(EMPTY,0,BSTR,rbstr,I2,0);
3557 SysFreeString(rbstr);
3558 rbstr = SysAllocString(szTrue);
3559 VARXOR(EMPTY,0,BSTR,rbstr,I2,-1);
3560 VARXORCY(EMPTY,0,10000,I4,1);
3561 SysFreeString(rbstr);
3563 /* NULL OR 0 = NULL. NULL OR n = n */
3564 VARXOR(NULL,0,NULL,0,NULL,0);
3565 VARXOR(NULL,1,NULL,0,NULL,0);
3566 VARXOR(NULL,0,I1,0,NULL,0);
3567 VARXOR(NULL,0,I1,1,NULL,0);
3568 VARXOR(NULL,0,UI1,0,NULL,0);
3569 VARXOR(NULL,0,UI1,1,NULL,0);
3570 VARXOR(NULL,0,I2,0,NULL,0);
3571 VARXOR(NULL,0,I2,1,NULL,0);
3572 VARXOR(NULL,0,UI2,0,NULL,0);
3573 VARXOR(NULL,0,UI2,1,NULL,0);
3574 VARXOR(NULL,0,I4,0,NULL,0);
3575 VARXOR(NULL,0,I4,1,NULL,0);
3576 VARXOR(NULL,0,UI4,0,NULL,0);
3577 VARXOR(NULL,0,UI4,1,NULL,0);
3578 if (HAVE_OLEAUT32_I8)
3580 VARXOR(NULL,0,I8,0,NULL,0);
3581 VARXOR(NULL,0,I8,1,NULL,0);
3582 VARXOR(NULL,0,UI8,0,NULL,0);
3583 VARXOR(NULL,0,UI8,1,NULL,0);
3585 VARXOR(NULL,0,INT,0,NULL,0);
3586 VARXOR(NULL,0,INT,1,NULL,0);
3587 VARXOR(NULL,0,UINT,0,NULL,0);
3588 VARXOR(NULL,0,UINT,1,NULL,0);
3589 VARXOR(NULL,0,BOOL,0,NULL,0);
3590 VARXOR(NULL,0,BOOL,1,NULL,0);
3591 VARXOR(NULL,0,R4,0,NULL,0);
3592 VARXOR(NULL,0,R4,1,NULL,0);
3593 VARXOR(NULL,0,R8,0,NULL,0);
3594 VARXOR(NULL,0,R8,1,NULL,0);
3595 rbstr = SysAllocString(szFalse);
3596 VARXOR(NULL,0,BSTR,rbstr,NULL,0);
3597 SysFreeString(rbstr);
3598 rbstr = SysAllocString(szTrue);
3599 VARXOR(NULL,0,BSTR,rbstr,NULL,0);
3600 SysFreeString(rbstr);
3601 VARXORCY(NULL,0,10000,NULL,0);
3602 VARXORCY(NULL,0,0,NULL,0);
3604 VARXOR(BOOL,VARIANT_TRUE,BOOL,VARIANT_TRUE,BOOL,VARIANT_FALSE);
3605 VARXOR(BOOL,VARIANT_TRUE,BOOL,VARIANT_FALSE,BOOL,VARIANT_TRUE);
3606 VARXOR(BOOL,VARIANT_FALSE,BOOL,VARIANT_TRUE,BOOL,VARIANT_TRUE);
3607 VARXOR(BOOL,VARIANT_FALSE,BOOL,VARIANT_FALSE,BOOL,VARIANT_FALSE);
3608 /* Assume x,y & y,x are the same from now on to reduce the number of tests */
3609 VARXOR(BOOL,VARIANT_TRUE,I1,-1,I4,0);
3610 VARXOR(BOOL,VARIANT_TRUE,I1,0,I4,-1);
3611 VARXOR(BOOL,VARIANT_FALSE,I1,0,I4,0);
3612 VARXOR(BOOL,VARIANT_TRUE,UI1,255,I2,-256);
3613 VARXOR(BOOL,VARIANT_TRUE,UI1,0,I2,-1);
3614 VARXOR(BOOL,VARIANT_FALSE,UI1,0,I2,0);
3615 VARXOR(BOOL,VARIANT_TRUE,I2,-1,I2,0);
3616 VARXOR(BOOL,VARIANT_TRUE,I2,0,I2,-1);
3617 VARXOR(BOOL,VARIANT_FALSE,I2,0,I2,0);
3618 VARXOR(BOOL,VARIANT_TRUE,UI2,65535,I4,-65536);
3619 VARXOR(BOOL,VARIANT_TRUE,UI2,0,I4,-1);
3620 VARXOR(BOOL,VARIANT_FALSE,UI2,0,I4,0);
3621 VARXOR(BOOL,VARIANT_TRUE,I4,-1,I4,0);
3622 VARXOR(BOOL,VARIANT_TRUE,I4,0,I4,-1);
3623 VARXOR(BOOL,VARIANT_FALSE,I4,0,I4,0);
3624 VARXOR(BOOL,VARIANT_TRUE,UI4,0xffffffff,I4,0);
3625 VARXOR(BOOL,VARIANT_TRUE,UI4,0,I4,-1);
3626 VARXOR(BOOL,VARIANT_FALSE,UI4,0,I4,0);
3627 VARXOR(BOOL,VARIANT_TRUE,R4,-1,I4,0);
3628 VARXOR(BOOL,VARIANT_TRUE,R4,0,I4,-1);
3629 VARXOR(BOOL,VARIANT_FALSE,R4,0,I4,0);
3630 VARXOR(BOOL,VARIANT_TRUE,R8,-1,I4,0);
3631 VARXOR(BOOL,VARIANT_TRUE,R8,0,I4,-1);
3632 VARXOR(BOOL,VARIANT_FALSE,R8,0,I4,0);
3633 VARXOR(BOOL,VARIANT_TRUE,DATE,-1,I4,0);
3634 VARXOR(BOOL,VARIANT_TRUE,DATE,0,I4,-1);
3635 VARXOR(BOOL,VARIANT_FALSE,DATE,0,I4,0);
3636 if (HAVE_OLEAUT32_I8)
3638 VARXOR(BOOL,VARIANT_TRUE,I8,-1,I8,0);
3639 VARXOR(BOOL,VARIANT_TRUE,I8,0,I8,-1);
3640 VARXOR(BOOL,VARIANT_FALSE,I8,0,I8,0);
3641 /* This returns DISP_E_OVERFLOW which indicates that a conversion
3642 * to I4 is performed.
3644 /* VARXOR(BOOL,VARIANT_TRUE,UI8,-1,I4,-1); */
3645 VARXOR(BOOL,VARIANT_TRUE,UI8,0,I4,-1);
3646 VARXOR(BOOL,VARIANT_FALSE,UI8,0,I4,0);
3648 VARXOR(BOOL,VARIANT_TRUE,INT,-1,I4,0);
3649 VARXOR(BOOL,VARIANT_TRUE,INT,0,I4,-1);
3650 VARXOR(BOOL,VARIANT_FALSE,INT,0,I4,0);
3651 VARXOR(BOOL,VARIANT_TRUE,UINT,0xffffffff,I4,0);
3652 VARXOR(BOOL,VARIANT_TRUE,UINT,0,I4,-1);
3653 VARXOR(BOOL,VARIANT_FALSE,UINT,0,I4,0);
3654 rbstr = SysAllocString(szFalse);
3655 VARXOR(BOOL,VARIANT_FALSE,BSTR,rbstr,BOOL,VARIANT_FALSE);
3656 VARXOR(BOOL,VARIANT_TRUE,BSTR,rbstr,BOOL,VARIANT_TRUE);
3657 SysFreeString(rbstr);
3658 rbstr = SysAllocString(szTrue);
3659 VARXOR(BOOL,VARIANT_FALSE,BSTR,rbstr,BOOL,VARIANT_TRUE);
3660 VARXOR(BOOL,VARIANT_TRUE,BSTR,rbstr,BOOL,VARIANT_FALSE);
3661 SysFreeString(rbstr);
3662 VARXORCY(BOOL,VARIANT_TRUE,10000,I4,-2);
3663 VARXORCY(BOOL,VARIANT_TRUE,0,I4,-1);
3664 VARXORCY(BOOL,VARIANT_FALSE,0,I4,0);
3666 VARXOR(I1,-1,I1,-1,I4,0);
3667 VARXOR(I1,-1,I1,0,I4,-1);
3668 VARXOR(I1,0,I1,0,I4,0);
3669 VARXOR(I1,-1,UI1,255,I4,-256);
3670 VARXOR(I1,-1,UI1,0,I4,-1);
3671 VARXOR(I1,0,UI1,0,I4,0);
3672 VARXOR(I1,-1,I2,-1,I4,0);
3673 VARXOR(I1,-1,I2,0,I4,-1);
3674 VARXOR(I1,0,I2,0,I4,0);
3675 VARXOR(I1,-1,UI2,65535,I4,-65536);
3676 VARXOR(I1,-1,UI2,0,I4,-1);
3677 VARXOR(I1,0,UI2,0,I4,0);
3678 VARXOR(I1,-1,I4,-1,I4,0);
3679 VARXOR(I1,-1,I4,0,I4,-1);
3680 VARXOR(I1,0,I4,0,I4,0);
3681 VARXOR(I1,-1,UI4,0xffffffff,I4,0);
3682 VARXOR(I1,-1,UI4,0,I4,-1);
3683 VARXOR(I1,0,UI4,0,I4,0);
3684 VARXOR(I1,-1,R4,-1,I4,0);
3685 VARXOR(I1,-1,R4,0,I4,-1);
3686 VARXOR(I1,0,R4,0,I4,0);
3687 VARXOR(I1,-1,R8,-1,I4,0);
3688 VARXOR(I1,-1,R8,0,I4,-1);
3689 VARXOR(I1,0,R8,0,I4,0);
3690 VARXOR(I1,-1,DATE,-1,I4,0);
3691 VARXOR(I1,-1,DATE,0,I4,-1);
3692 VARXOR(I1,0,DATE,0,I4,0);
3693 if (HAVE_OLEAUT32_I8)
3695 VARXOR(I1,-1,I8,-1,I8,0);
3696 VARXOR(I1,-1,I8,0,I8,-1);
3697 VARXOR(I1,0,I8,0,I8,0);
3698 VARXOR(I1,-1,UI8,0,I4,-1);
3699 VARXOR(I1,0,UI8,0,I4,0);
3701 VARXOR(I1,-1,INT,-1,I4,0);
3702 VARXOR(I1,-1,INT,0,I4,-1);
3703 VARXOR(I1,0,INT,0,I4,0);
3704 VARXOR(I1,-1,UINT,0xffffffff,I4,0);
3705 VARXOR(I1,-1,UINT,0,I4,-1);
3706 VARXOR(I1,0,UINT,0,I4,0);
3707 rbstr = SysAllocString(szFalse);
3708 VARXOR(I1,0,BSTR,rbstr,I4,0);
3709 VARXOR(I1,-1,BSTR,rbstr,I4,-1);
3710 SysFreeString(rbstr);
3711 rbstr = SysAllocString(szTrue);
3712 VARXOR(I1,0,BSTR,rbstr,I4,-1);
3713 VARXOR(I1,-1,BSTR,rbstr,I4,0);
3714 SysFreeString(rbstr);
3715 VARXORCY(I1,-1,10000,I4,-2);
3716 VARXORCY(I1,-1,0,I4,-1);
3717 VARXORCY(I1,0,0,I4,0);
3719 VARXOR(UI1,255,UI1,255,UI1,0);
3720 VARXOR(UI1,255,UI1,0,UI1,255);
3721 VARXOR(UI1,0,UI1,0,UI1,0);
3722 VARXOR(UI1,255,I2,-1,I2,-256);
3723 VARXOR(UI1,255,I2,0,I2,255);
3724 VARXOR(UI1,0,I2,0,I2,0);
3725 VARXOR(UI1,255,UI2,65535,I4,65280);
3726 VARXOR(UI1,255,UI2,0,I4,255);
3727 VARXOR(UI1,0,UI2,0,I4,0);
3728 VARXOR(UI1,255,I4,-1,I4,-256);
3729 VARXOR(UI1,255,I4,0,I4,255);
3730 VARXOR(UI1,0,I4,0,I4,0);
3731 VARXOR(UI1,255,UI4,0xffffffff,I4,-256);
3732 VARXOR(UI1,255,UI4,0,I4,255);
3733 VARXOR(UI1,0,UI4,0,I4,0);
3734 VARXOR(UI1,255,R4,-1,I4,-256);
3735 VARXOR(UI1,255,R4,0,I4,255);
3736 VARXOR(UI1,0,R4,0,I4,0);
3737 VARXOR(UI1,255,R8,-1,I4,-256);
3738 VARXOR(UI1,255,R8,0,I4,255);
3739 VARXOR(UI1,0,R8,0,I4,0);
3740 VARXOR(UI1,255,DATE,-1,I4,-256);
3741 VARXOR(UI1,255,DATE,0,I4,255);
3742 VARXOR(UI1,0,DATE,0,I4,0);
3743 if (HAVE_OLEAUT32_I8)
3745 VARXOR(UI1,255,I8,-1,I8,-256);
3746 VARXOR(UI1,255,I8,0,I8,255);
3747 VARXOR(UI1,0,I8,0,I8,0);
3748 VARXOR(UI1,255,UI8,0,I4,255);
3749 VARXOR(UI1,0,UI8,0,I4,0);
3751 VARXOR(UI1,255,INT,-1,I4,-256);
3752 VARXOR(UI1,255,INT,0,I4,255);
3753 VARXOR(UI1,0,INT,0,I4,0);
3754 VARXOR(UI1,255,UINT,0xffffffff,I4,-256);
3755 VARXOR(UI1,255,UINT,0,I4,255);
3756 VARXOR(UI1,0,UINT,0,I4,0);
3757 rbstr = SysAllocString(szFalse);
3758 VARXOR(UI1,0,BSTR,rbstr,I2,0);
3759 VARXOR(UI1,255,BSTR,rbstr,I2,255);
3760 SysFreeString(rbstr);
3761 rbstr = SysAllocString(szTrue);
3762 VARXOR(UI1,0,BSTR,rbstr,I2,-1);
3763 VARXOR(UI1,255,BSTR,rbstr,I2,-256);
3764 SysFreeString(rbstr);
3765 VARXORCY(UI1,255,10000,I4,254);
3766 VARXORCY(UI1,255,0,I4,255);
3767 VARXORCY(UI1,0,0,I4,0);
3769 VARXOR(I2,-1,I2,-1,I2,0);
3770 VARXOR(I2,-1,I2,0,I2,-1);
3771 VARXOR(I2,0,I2,0,I2,0);
3772 VARXOR(I2,-1,UI2,65535,I4,-65536);
3773 VARXOR(I2,-1,UI2,0,I4,-1);
3774 VARXOR(I2,0,UI2,0,I4,0);
3775 VARXOR(I2,-1,I4,-1,I4,0);
3776 VARXOR(I2,-1,I4,0,I4,-1);
3777 VARXOR(I2,0,I4,0,I4,0);
3778 VARXOR(I2,-1,UI4,0xffffffff,I4,0);
3779 VARXOR(I2,-1,UI4,0,I4,-1);
3780 VARXOR(I2,0,UI4,0,I4,0);
3781 VARXOR(I2,-1,R4,-1,I4,0);
3782 VARXOR(I2,-1,R4,0,I4,-1);
3783 VARXOR(I2,0,R4,0,I4,0);
3784 VARXOR(I2,-1,R8,-1,I4,0);
3785 VARXOR(I2,-1,R8,0,I4,-1);
3786 VARXOR(I2,0,R8,0,I4,0);
3787 VARXOR(I2,-1,DATE,-1,I4,0);
3788 VARXOR(I2,-1,DATE,0,I4,-1);
3789 VARXOR(I2,0,DATE,0,I4,0);
3790 if (HAVE_OLEAUT32_I8)
3792 VARXOR(I2,-1,I8,-1,I8,0);
3793 VARXOR(I2,-1,I8,0,I8,-1);
3794 VARXOR(I2,0,I8,0,I8,0);
3795 VARXOR(I2,-1,UI8,0,I4,-1);
3796 VARXOR(I2,0,UI8,0,I4,0);
3798 VARXOR(I2,-1,INT,-1,I4,0);
3799 VARXOR(I2,-1,INT,0,I4,-1);
3800 VARXOR(I2,0,INT,0,I4,0);
3801 VARXOR(I2,-1,UINT,0xffffffff,I4,0);
3802 VARXOR(I2,-1,UINT,0,I4,-1);
3803 VARXOR(I2,0,UINT,0,I4,0);
3804 rbstr = SysAllocString(szFalse);
3805 VARXOR(I2,0,BSTR,rbstr,I2,0);
3806 VARXOR(I2,-1,BSTR,rbstr,I2,-1);
3807 SysFreeString(rbstr);
3808 rbstr = SysAllocString(szTrue);
3809 VARXOR(I2,0,BSTR,rbstr,I2,-1);
3810 VARXOR(I2,-1,BSTR,rbstr,I2,0);
3811 SysFreeString(rbstr);
3812 VARXORCY(I2,-1,10000,I4,-2);
3813 VARXORCY(I2,-1,0,I4,-1);
3814 VARXORCY(I2,0,0,I4,0);
3816 VARXOR(UI2,65535,UI2,65535,I4,0);
3817 VARXOR(UI2,65535,UI2,0,I4,65535);
3818 VARXOR(UI2,0,UI2,0,I4,0);
3819 VARXOR(UI2,65535,I4,-1,I4,-65536);
3820 VARXOR(UI2,65535,I4,0,I4,65535);
3821 VARXOR(UI2,0,I4,0,I4,0);
3822 VARXOR(UI2,65535,UI4,0xffffffff,I4,-65536);
3823 VARXOR(UI2,65535,UI4,0,I4,65535);
3824 VARXOR(UI2,0,UI4,0,I4,0);
3825 VARXOR(UI2,65535,R4,-1,I4,-65536);
3826 VARXOR(UI2,65535,R4,0,I4,65535);
3827 VARXOR(UI2,0,R4,0,I4,0);
3828 VARXOR(UI2,65535,R8,-1,I4,-65536);
3829 VARXOR(UI2,65535,R8,0,I4,65535);
3830 VARXOR(UI2,0,R8,0,I4,0);
3831 VARXOR(UI2,65535,DATE,-1,I4,-65536);
3832 VARXOR(UI2,65535,DATE,0,I4,65535);
3833 VARXOR(UI2,0,DATE,0,I4,0);
3834 if (HAVE_OLEAUT32_I8)
3836 VARXOR(UI2,65535,I8,-1,I8,-65536);
3837 VARXOR(UI2,65535,I8,0,I8,65535);
3838 VARXOR(UI2,0,I8,0,I8,0);
3839 VARXOR(UI2,65535,UI8,0,I4,65535);
3840 VARXOR(UI2,0,UI8,0,I4,0);
3842 VARXOR(UI2,65535,INT,-1,I4,-65536);
3843 VARXOR(UI2,65535,INT,0,I4,65535);
3844 VARXOR(UI2,0,INT,0,I4,0);
3845 VARXOR(UI2,65535,UINT,0xffffffff,I4,-65536);
3846 VARXOR(UI2,65535,UINT,0,I4,65535);
3847 VARXOR(UI2,0,UINT,0,I4,0);
3848 rbstr = SysAllocString(szFalse);
3849 VARXOR(UI2,0,BSTR,rbstr,I4,0);
3850 VARXOR(UI2,65535,BSTR,rbstr,I4,65535);
3851 SysFreeString(rbstr);
3852 rbstr = SysAllocString(szTrue);
3853 VARXOR(UI2,0,BSTR,rbstr,I4,-1);
3854 VARXOR(UI2,65535,BSTR,rbstr,I4,-65536);
3855 SysFreeString(rbstr);
3856 VARXORCY(UI2,65535,10000,I4,65534);
3857 VARXORCY(UI2,65535,0,I4,65535);
3858 VARXORCY(UI2,0,0,I4,0);
3860 VARXOR(I4,-1,I4,-1,I4,0);
3861 VARXOR(I4,-1,I4,0,I4,-1);
3862 VARXOR(I4,0,I4,0,I4,0);
3863 VARXOR(I4,-1,UI4,0xffffffff,I4,0);
3864 VARXOR(I4,-1,UI4,0,I4,-1);
3865 VARXOR(I4,0,UI4,0,I4,0);
3866 VARXOR(I4,-1,R4,-1,I4,0);
3867 VARXOR(I4,-1,R4,0,I4,-1);
3868 VARXOR(I4,0,R4,0,I4,0);
3869 VARXOR(I4,-1,R8,-1,I4,0);
3870 VARXOR(I4,-1,R8,0,I4,-1);
3871 VARXOR(I4,0,R8,0,I4,0);
3872 VARXOR(I4,-1,DATE,-1,I4,0);
3873 VARXOR(I4,-1,DATE,0,I4,-1);
3874 VARXOR(I4,0,DATE,0,I4,0);
3875 if (HAVE_OLEAUT32_I8)
3877 VARXOR(I4,-1,I8,-1,I8,0);
3878 VARXOR(I4,-1,I8,0,I8,-1);
3879 VARXOR(I4,0,I8,0,I8,0);
3880 VARXOR(I4,-1,UI8,0,I4,-1);
3881 VARXOR(I4,0,UI8,0,I4,0);
3883 VARXOR(I4,-1,INT,-1,I4,0);
3884 VARXOR(I4,-1,INT,0,I4,-1);
3885 VARXOR(I4,0,INT,0,I4,0);
3886 VARXOR(I4,-1,UINT,0xffffffff,I4,0);
3887 VARXOR(I4,-1,UINT,0,I4,-1);
3888 VARXOR(I4,0,UINT,0,I4,0);
3889 rbstr = SysAllocString(szFalse);
3890 VARXOR(I4,0,BSTR,rbstr,I4,0);
3891 VARXOR(I4,-1,BSTR,rbstr,I4,-1);
3892 SysFreeString(rbstr);
3893 rbstr = SysAllocString(szTrue);
3894 VARXOR(I4,0,BSTR,rbstr,I4,-1);
3895 VARXOR(I4,-1,BSTR,rbstr,I4,0);
3896 SysFreeString(rbstr);
3897 VARXORCY(I4,-1,10000,I4,-2);
3898 VARXORCY(I4,-1,0,I4,-1);
3899 VARXORCY(I4,0,0,I4,0);
3901 VARXOR(UI4,0xffffffff,UI4,0xffffffff,I4,0);
3902 VARXOR(UI4,0xffffffff,UI4,0,I4,-1);
3903 VARXOR(UI4,0,UI4,0,I4,0);
3904 VARXOR(UI4,0xffffffff,R4,-1,I4,0);
3905 VARXOR(UI4,0xffffffff,R4,0,I4,-1);
3906 VARXOR(UI4,0,R4,0,I4,0);
3907 VARXOR(UI4,0xffffffff,R8,-1,I4,0);
3908 VARXOR(UI4,0xffffffff,R8,0,I4,-1);
3909 VARXOR(UI4,0,R8,0,I4,0);
3910 VARXOR(UI4,0xffffffff,DATE,-1,I4,0);
3911 VARXOR(UI4,0xffffffff,DATE,0,I4,-1);
3912 VARXOR(UI4,0,DATE,0,I4,0);
3913 if (HAVE_OLEAUT32_I8)
3915 VARXOR(UI4,0xffffffff,I8,0,I8,0xffffffff);
3916 VARXOR(UI4,VARIANT_FALSE,I8,VARIANT_FALSE,I8,0);
3917 VARXOR(UI4,0,I8,0,I8,0);
3918 VARXOR(UI4,0xffffffff,UI8,0,I4,-1);
3919 VARXOR(UI4,0,UI8,0,I4,0);
3921 VARXOR(UI4,0xffffffff,INT,-1,I4,0);
3922 VARXOR(UI4,0xffffffff,INT,0,I4,-1);
3923 VARXOR(UI4,0,INT,0,I4,0);
3924 VARXOR(UI4,0xffffffff,UINT,0xffffffff,I4,0);
3925 VARXOR(UI4,0xffffffff,UINT,0,I4,-1);
3926 VARXOR(UI4,0,UINT,0,I4,0);
3927 rbstr = SysAllocString(szFalse);
3928 VARXOR(UI4,0,BSTR,rbstr,I4,0);
3929 VARXOR(UI4,0xffffffff,BSTR,rbstr,I4,-1);
3930 SysFreeString(rbstr);
3931 rbstr = SysAllocString(szTrue);
3932 VARXOR(UI4,0,BSTR,rbstr,I4,-1);
3933 VARXOR(UI4,0xffffffff,BSTR,rbstr,I4,0);
3934 SysFreeString(rbstr);
3935 VARXORCY(UI4,0xffffffff,10000,I4,-2);
3936 VARXORCY(UI4,0xffffffff,0,I4,-1);
3937 VARXORCY(UI4,0,0,I4,0);
3939 VARXOR(R4,-1,R4,-1,I4,0);
3940 VARXOR(R4,-1,R4,0,I4,-1);
3941 VARXOR(R4,0,R4,0,I4,0);
3942 VARXOR(R4,-1,R8,-1,I4,0);
3943 VARXOR(R4,-1,R8,0,I4,-1);
3944 VARXOR(R4,0,R8,0,I4,0);
3945 VARXOR(R4,-1,DATE,-1,I4,0);
3946 VARXOR(R4,-1,DATE,0,I4,-1);
3947 VARXOR(R4,0,DATE,0,I4,0);
3948 if (HAVE_OLEAUT32_I8)
3950 VARXOR(R4,-1,I8,-1,I8,0);
3951 VARXOR(R4,-1,I8,0,I8,-1);
3952 VARXOR(R4,0,I8,0,I8,0);
3953 VARXOR(R4,-1,UI8,0,I4,-1);
3954 VARXOR(R4,0,UI8,0,I4,0);
3956 VARXOR(R4,-1,INT,-1,I4,0);
3957 VARXOR(R4,-1,INT,0,I4,-1);
3958 VARXOR(R4,0,INT,0,I4,0);
3959 VARXOR(R4,-1,UINT,0xffffffff,I4,0);
3960 VARXOR(R4,-1,UINT,0,I4,-1);
3961 VARXOR(R4,0,UINT,0,I4,0);
3962 rbstr = SysAllocString(szFalse);
3963 VARXOR(R4,0,BSTR,rbstr,I4,0);
3964 VARXOR(R4,-1,BSTR,rbstr,I4,-1);
3965 SysFreeString(rbstr);
3966 rbstr = SysAllocString(szTrue);
3967 VARXOR(R4,0,BSTR,rbstr,I4,-1);
3968 VARXOR(R4,-1,BSTR,rbstr,I4,0);
3969 SysFreeString(rbstr);
3970 VARXORCY(R4,-1,10000,I4,-2);
3971 VARXORCY(R4,-1,0,I4,-1);
3972 VARXORCY(R4,0,0,I4,0);
3974 VARXOR(R8,-1,R8,-1,I4,0);
3975 VARXOR(R8,-1,R8,0,I4,-1);
3976 VARXOR(R8,0,R8,0,I4,0);
3977 VARXOR(R8,-1,DATE,-1,I4,0);
3978 VARXOR(R8,-1,DATE,0,I4,-1);
3979 VARXOR(R8,0,DATE,0,I4,0);
3980 if (HAVE_OLEAUT32_I8)
3982 VARXOR(R8,-1,I8,-1,I8,0);
3983 VARXOR(R8,-1,I8,0,I8,-1);
3984 VARXOR(R8,0,I8,0,I8,0);
3985 VARXOR(R8,-1,UI8,0,I4,-1);
3986 VARXOR(R8,0,UI8,0,I4,0);
3988 VARXOR(R8,-1,INT,-1,I4,0);
3989 VARXOR(R8,-1,INT,0,I4,-1);
3990 VARXOR(R8,0,INT,0,I4,0);
3991 VARXOR(R8,-1,UINT,0xffffffff,I4,0);
3992 VARXOR(R8,-1,UINT,0,I4,-1);
3993 VARXOR(R8,0,UINT,0,I4,0);
3994 rbstr = SysAllocString(szFalse);
3995 VARXOR(R8,0,BSTR,rbstr,I4,0);
3996 VARXOR(R8,-1,BSTR,rbstr,I4,-1);
3997 SysFreeString(rbstr);
3998 rbstr = SysAllocString(szTrue);
3999 VARXOR(R8,0,BSTR,rbstr,I4,-1);
4000 VARXOR(R8,-1,BSTR,rbstr,I4,0);
4001 SysFreeString(rbstr);
4002 VARXORCY(R8,-1,10000,I4,-2);
4003 VARXORCY(R8,-1,0,I4,-1);
4004 VARXORCY(R8,0,0,I4,0);
4006 VARXOR(DATE,-1,DATE,-1,I4,0);
4007 VARXOR(DATE,-1,DATE,0,I4,-1);
4008 VARXOR(DATE,0,DATE,0,I4,0);
4009 if (HAVE_OLEAUT32_I8)
4011 VARXOR(DATE,-1,I8,-1,I8,0);
4012 VARXOR(DATE,-1,I8,0,I8,-1);
4013 VARXOR(DATE,0,I8,0,I8,0);
4014 VARXOR(DATE,-1,UI8,0,I4,-1);
4015 VARXOR(DATE,0,UI8,0,I4,0);
4017 VARXOR(DATE,-1,INT,-1,I4,0);
4018 VARXOR(DATE,-1,INT,0,I4,-1);
4019 VARXOR(DATE,0,INT,0,I4,0);
4020 VARXOR(DATE,-1,UINT,0xffffffff,I4,0);
4021 VARXOR(DATE,-1,UINT,0,I4,-1);
4022 VARXOR(DATE,0,UINT,0,I4,0);
4023 rbstr = SysAllocString(szFalse);
4024 VARXOR(DATE,0,BSTR,rbstr,I4,0);
4025 VARXOR(DATE,-1,BSTR,rbstr,I4,-1);
4026 SysFreeString(rbstr);
4027 rbstr = SysAllocString(szTrue);
4028 VARXOR(DATE,0,BSTR,rbstr,I4,-1);
4029 VARXOR(DATE,-1,BSTR,rbstr,I4,0);
4030 SysFreeString(rbstr);
4031 VARXORCY(DATE,-1,10000,I4,-2);
4032 VARXORCY(DATE,-1,0,I4,-1);
4033 VARXORCY(DATE,0,0,I4,0);
4035 if (HAVE_OLEAUT32_I8)
4037 VARXOR(I8,-1,I8,-1,I8,0);
4038 VARXOR(I8,-1,I8,0,I8,-1);
4039 VARXOR(I8,0,I8,0,I8,0);
4040 VARXOR(I8,-1,UI8,0,I8,-1);
4041 VARXOR(I8,0,UI8,0,I8,0);
4042 VARXOR(I8,-1,UINT,0,I8,-1);
4043 VARXOR(I8,0,UINT,0,I8,0);
4044 rbstr = SysAllocString(szFalse);
4045 VARXOR(I8,0,BSTR,rbstr,I8,0);
4046 VARXOR(I8,-1,BSTR,rbstr,I8,-1);
4047 SysFreeString(rbstr);
4048 rbstr = SysAllocString(szTrue);
4049 VARXOR(I8,0,BSTR,rbstr,I8,-1);
4050 VARXOR(I8,-1,BSTR,rbstr,I8,0);
4051 SysFreeString(rbstr);
4052 VARXORCY(I8,-1,10000,I8,-2);
4053 VARXORCY(I8,-1,0,I8,-1);
4054 VARXORCY(I8,0,0,I8,0);
4056 VARXOR(UI8,0xffff,UI8,0xffff,I4,0);
4057 VARXOR(UI8,0xffff,UI8,0,I4,0xffff);
4058 VARXOR(UI8,0,UI8,0,I4,0);
4059 VARXOR(UI8,0xffff,INT,-1,I4,-65536);
4060 VARXOR(UI8,0xffff,INT,0,I4,0xffff);
4061 VARXOR(UI8,0,INT,0,I4,0);
4062 VARXOR(UI8,0xffff,UINT,0xffff,I4,0);
4063 VARXOR(UI8,0xffff,UINT,0,I4,0xffff);
4064 VARXOR(UI8,0,UINT,0,I4,0);
4065 rbstr = SysAllocString(szFalse);
4066 VARXOR(UI8,0,BSTR,rbstr,I4,0);
4067 VARXOR(UI8,0xffff,BSTR,rbstr,I4,0xffff);
4068 SysFreeString(rbstr);
4069 rbstr = SysAllocString(szTrue);
4070 VARXOR(UI8,0,BSTR,rbstr,I4,-1);
4071 VARXOR(UI8,0xffff,BSTR,rbstr,I4,-65536);
4072 SysFreeString(rbstr);
4073 VARXORCY(UI8,0xffff,10000,I4,65534);
4074 VARXORCY(UI8,0xffff,0,I4,0xffff);
4075 VARXORCY(UI8,0,0,I4,0);
4078 VARXOR(INT,-1,INT,-1,I4,0);
4079 VARXOR(INT,-1,INT,0,I4,-1);
4080 VARXOR(INT,0,INT,0,I4,0);
4081 VARXOR(INT,-1,UINT,0xffff,I4,-65536);
4082 VARXOR(INT,-1,UINT,0,I4,-1);
4083 VARXOR(INT,0,UINT,0,I4,0);
4084 rbstr = SysAllocString(szFalse);
4085 VARXOR(INT,0,BSTR,rbstr,I4,0);
4086 VARXOR(INT,-1,BSTR,rbstr,I4,-1);
4087 SysFreeString(rbstr);
4088 rbstr = SysAllocString(szTrue);
4089 VARXOR(INT,0,BSTR,rbstr,I4,-1);
4090 VARXOR(INT,-1,BSTR,rbstr,I4,0);
4091 SysFreeString(rbstr);
4092 VARXORCY(INT,-1,10000,I4,-2);
4093 VARXORCY(INT,-1,0,I4,-1);
4094 VARXORCY(INT,0,0,I4,0);
4096 VARXOR(UINT,0xffff,UINT,0xffff,I4,0);
4097 VARXOR(UINT,0xffff,UINT,0,I4,0xffff);
4098 VARXOR(UINT,0,UINT,0,I4,0);
4099 rbstr = SysAllocString(szFalse);
4100 VARXOR(UINT,0,BSTR,rbstr,I4,0);
4101 VARXOR(UINT,0xffff,BSTR,rbstr,I4,0xffff);
4102 SysFreeString(rbstr);
4103 rbstr = SysAllocString(szTrue);
4104 VARXOR(UINT,0,BSTR,rbstr,I4,-1);
4105 VARXOR(UINT,0xffff,BSTR,rbstr,I4,-65536);
4106 SysFreeString(rbstr);
4107 VARXORCY(UINT,0xffff,10000,I4,65534);
4108 VARXORCY(UINT,0xffff,0,I4,0xffff);
4109 VARXORCY(UINT,0,0,I4,0);
4111 lbstr = SysAllocString(szFalse);
4112 rbstr = SysAllocString(szFalse);
4113 VARXOR(BSTR,lbstr,BSTR,rbstr,BOOL,0);
4114 SysFreeString(rbstr);
4115 rbstr = SysAllocString(szTrue);
4116 VARXOR(BSTR,lbstr,BSTR,rbstr,BOOL,VARIANT_TRUE);
4117 SysFreeString(lbstr);
4118 lbstr = SysAllocString(szTrue);
4119 VARXOR(BSTR,lbstr,BSTR,rbstr,BOOL,VARIANT_FALSE);
4120 VARXORCY(BSTR,lbstr,10000,I4,-2);
4121 SysFreeString(lbstr);
4122 lbstr = SysAllocString(szFalse);
4123 VARXORCY(BSTR,lbstr,10000,I4,1);
4124 SysFreeString(lbstr);
4125 SysFreeString(rbstr);
4128 static HRESULT (WINAPI *pVarOr)(LPVARIANT,LPVARIANT,LPVARIANT);
4130 #define VAROR(vt1,val1,vt2,val2,rvt,rval) \
4131 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
4132 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
4133 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
4134 test_var_call2( __LINE__, pVarOr, &left, &right, &exp )
4136 #define VARORCY(vt1,val1,val2,rvt,rval) \
4137 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
4138 V_VT(&right) = VT_CY; V_CY(&right).int64 = val2; \
4139 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
4140 test_var_call2( __LINE__, pVarOr, &left, &right, &exp )
4142 static void test_VarOr(void)
4144 static const WCHAR szFalse[] = { '#','F','A','L','S','E','#','\0' };
4145 static const WCHAR szTrue[] = { '#','T','R','U','E','#','\0' };
4146 VARIANT left, right, exp, result;
4153 /* Test all possible flag/vt combinations & the resulting vt type */
4154 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
4156 VARTYPE leftvt, rightvt, resvt;
4158 for (leftvt = 0; leftvt <= VT_BSTR_BLOB; leftvt++)
4163 for (rightvt = 0; rightvt <= VT_BSTR_BLOB; rightvt++)
4169 if (leftvt == VT_BSTR || rightvt == VT_BSTR ||
4170 leftvt == VT_DISPATCH || rightvt == VT_DISPATCH ||
4171 leftvt == VT_UNKNOWN || rightvt == VT_UNKNOWN)
4174 memset(&left, 0, sizeof(left));
4175 memset(&right, 0, sizeof(right));
4176 V_VT(&left) = leftvt | ExtraFlags[i];
4177 V_VT(&right) = rightvt | ExtraFlags[i];
4178 V_VT(&result) = VT_EMPTY;
4181 if (ExtraFlags[i] & VT_ARRAY || ExtraFlags[i] & VT_BYREF ||
4182 !IsValidVariantClearVT(leftvt, ExtraFlags[i]) ||
4183 !IsValidVariantClearVT(rightvt, ExtraFlags[i]) ||
4184 leftvt == VT_CLSID || rightvt == VT_CLSID ||
4185 leftvt == VT_RECORD || rightvt == VT_RECORD ||
4186 leftvt == VT_VARIANT || rightvt == VT_VARIANT ||
4187 leftvt == VT_ERROR || rightvt == VT_ERROR)
4191 if (leftvt == VT_EMPTY || rightvt == VT_EMPTY)
4193 if (leftvt == rightvt ||
4194 leftvt == VT_I2 || rightvt == VT_I2 ||
4195 leftvt == VT_UI1 || rightvt == VT_UI1 ||
4196 leftvt == VT_BOOL || rightvt == VT_BOOL)
4198 else if (leftvt == VT_NULL || rightvt == VT_NULL)
4200 else if (leftvt == VT_I8 || rightvt == VT_I8)
4203 else if (leftvt == VT_NULL || rightvt == VT_NULL)
4207 else if (leftvt == VT_UI1 || rightvt == VT_UI1)
4209 if (leftvt == rightvt)
4211 else if (leftvt == rightvt ||
4212 leftvt == VT_I2 || rightvt == VT_I2 ||
4213 leftvt == VT_BOOL || rightvt == VT_BOOL)
4217 else if (leftvt == VT_I8 || rightvt == VT_I8)
4220 else if (leftvt == VT_I2 || rightvt == VT_I2)
4222 if (leftvt == rightvt ||
4223 leftvt == VT_BOOL || rightvt == VT_BOOL)
4225 else if (leftvt == VT_I8 || rightvt == VT_I8)
4228 else if (leftvt == VT_BOOL && rightvt == VT_BOOL)
4232 else if (leftvt == VT_I8 || rightvt == VT_I8)
4234 if (leftvt == VT_INT || rightvt == VT_INT)
4239 hres = pVarOr(&left, &right, &result);
4241 ok(hres == DISP_E_TYPEMISMATCH || hres == DISP_E_BADVARTYPE,
4242 "VarOr: %d|0x%X, %d|0x%X: Expected failure, got 0x%X vt %d\n",
4243 leftvt, ExtraFlags[i], rightvt, ExtraFlags[i], hres,
4246 ok(hres == S_OK && V_VT(&result) == resvt,
4247 "VarOr: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%X vt %d\n",
4248 leftvt, ExtraFlags[i], rightvt, ExtraFlags[i], resvt, hres,
4254 /* Test returned values. Since we know the returned type is correct
4255 * and that we handle all combinations of invalid types, just check
4256 * that good type combinations produce the desired value.
4257 * FIXME: Test VT_DECIMAL/VT_DISPATCH
4259 VAROR(EMPTY,0,EMPTY,0,I2,0);
4260 VAROR(EMPTY,1,EMPTY,0,I2,0);
4261 VAROR(EMPTY,0,NULL,0,NULL,0);
4262 VAROR(EMPTY,0,I1,0,I4,0);
4263 VAROR(EMPTY,0,I1,1,I4,1);
4264 VAROR(EMPTY,0,UI1,0,I2,0);
4265 VAROR(EMPTY,0,UI1,1,I2,1);
4266 VAROR(EMPTY,0,I2,0,I2,0);
4267 VAROR(EMPTY,0,I2,1,I2,1);
4268 VAROR(EMPTY,0,UI2,0,I4,0);
4269 VAROR(EMPTY,0,UI2,1,I4,1);
4270 VAROR(EMPTY,0,I4,0,I4,0);
4271 VAROR(EMPTY,0,I4,1,I4,1);
4272 VAROR(EMPTY,0,UI4,0,I4,0);
4273 VAROR(EMPTY,0,UI4,1,I4,1);
4274 if (HAVE_OLEAUT32_I8)
4276 VAROR(EMPTY,0,I8,0,I8,0);
4277 VAROR(EMPTY,0,I8,1,I8,1);
4278 VAROR(EMPTY,0,UI8,0,I4,0);
4279 VAROR(EMPTY,0,UI8,1,I4,1);
4281 VAROR(EMPTY,0,INT,0,I4,0);
4282 VAROR(EMPTY,0,INT,1,I4,1);
4283 VAROR(EMPTY,0,UINT,0,I4,0);
4284 VAROR(EMPTY,0,UINT,1,I4,1);
4285 VAROR(EMPTY,0,BOOL,0,I2,0);
4286 VAROR(EMPTY,0,BOOL,1,I2,1);
4287 VAROR(EMPTY,0,R4,0,I4,0);
4288 VAROR(EMPTY,0,R4,1,I4,1);
4289 VAROR(EMPTY,0,R8,0,I4,0);
4290 VAROR(EMPTY,0,R8,1,I4,1);
4291 rbstr = SysAllocString(szFalse);
4292 VAROR(EMPTY,0,BSTR,rbstr,I2,0);
4293 SysFreeString(rbstr);
4294 rbstr = SysAllocString(szTrue);
4295 VAROR(EMPTY,0,BSTR,rbstr,I2,-1);
4296 SysFreeString(rbstr);
4297 VARORCY(EMPTY,0,10000,I4,1);
4299 /* NULL OR 0 = NULL. NULL OR n = n */
4300 VAROR(NULL,0,NULL,0,NULL,0);
4301 VAROR(NULL,1,NULL,0,NULL,0);
4302 VAROR(NULL,0,I1,0,NULL,0);
4303 VAROR(NULL,0,I1,1,I4,1);
4304 VAROR(NULL,0,UI1,0,NULL,0);
4305 VAROR(NULL,0,UI1,1,UI1,1);
4306 VAROR(NULL,0,I2,0,NULL,0);
4307 VAROR(NULL,0,I2,1,I2,1);
4308 VAROR(NULL,0,UI2,0,NULL,0);
4309 VAROR(NULL,0,UI2,1,I4,1);
4310 VAROR(NULL,0,I4,0,NULL,0);
4311 VAROR(NULL,0,I4,1,I4,1);
4312 VAROR(NULL,0,UI4,0,NULL,0);
4313 VAROR(NULL,0,UI4,1,I4,1);
4314 if (HAVE_OLEAUT32_I8)
4316 VAROR(NULL,0,I8,0,NULL,0);
4317 VAROR(NULL,0,I8,1,I8,1);
4318 VAROR(NULL,0,UI8,0,NULL,0);
4319 VAROR(NULL,0,UI8,1,I4,1);
4321 VAROR(NULL,0,INT,0,NULL,0);
4322 VAROR(NULL,0,INT,1,I4,1);
4323 VAROR(NULL,0,UINT,0,NULL,0);
4324 VAROR(NULL,0,UINT,1,I4,1);
4325 VAROR(NULL,0,BOOL,0,NULL,0);
4326 VAROR(NULL,0,BOOL,1,BOOL,1);
4327 VAROR(NULL,0,R4,0,NULL,0);
4328 VAROR(NULL,0,R4,1,I4,1);
4329 VAROR(NULL,0,R8,0,NULL,0);
4330 VAROR(NULL,0,R8,1,I4,1);
4331 rbstr = SysAllocString(szFalse);
4332 VAROR(NULL,0,BSTR,rbstr,NULL,0);
4333 SysFreeString(rbstr);
4334 rbstr = SysAllocString(szTrue);
4335 VAROR(NULL,0,BSTR,rbstr,BOOL,VARIANT_TRUE);
4336 SysFreeString(rbstr);
4337 VARORCY(NULL,0,10000,I4,1);
4338 VARORCY(NULL,0,0,NULL,0);
4340 VAROR(BOOL,VARIANT_TRUE,BOOL,VARIANT_TRUE,BOOL,VARIANT_TRUE);
4341 VAROR(BOOL,VARIANT_TRUE,BOOL,VARIANT_FALSE,BOOL,VARIANT_TRUE);
4342 VAROR(BOOL,VARIANT_FALSE,BOOL,VARIANT_TRUE,BOOL,VARIANT_TRUE);
4343 VAROR(BOOL,VARIANT_FALSE,BOOL,VARIANT_FALSE,BOOL,VARIANT_FALSE);
4344 /* Assume x,y & y,x are the same from now on to reduce the number of tests */
4345 VAROR(BOOL,VARIANT_TRUE,I1,-1,I4,-1);
4346 VAROR(BOOL,VARIANT_TRUE,I1,0,I4,-1);
4347 VAROR(BOOL,VARIANT_FALSE,I1,0,I4,0);
4348 VAROR(BOOL,VARIANT_TRUE,UI1,255,I2,-1);
4349 VAROR(BOOL,VARIANT_TRUE,UI1,0,I2,-1);
4350 VAROR(BOOL,VARIANT_FALSE,UI1,0,I2,0);
4351 VAROR(BOOL,VARIANT_TRUE,I2,-1,I2,-1);
4352 VAROR(BOOL,VARIANT_TRUE,I2,0,I2,-1);
4353 VAROR(BOOL,VARIANT_FALSE,I2,0,I2,0);
4354 VAROR(BOOL,VARIANT_TRUE,UI2,65535,I4,-1);
4355 VAROR(BOOL,VARIANT_TRUE,UI2,0,I4,-1);
4356 VAROR(BOOL,VARIANT_FALSE,UI2,0,I4,0);
4357 VAROR(BOOL,VARIANT_TRUE,I4,-1,I4,-1);
4358 VAROR(BOOL,VARIANT_TRUE,I4,0,I4,-1);
4359 VAROR(BOOL,VARIANT_FALSE,I4,0,I4,0);
4360 VAROR(BOOL,VARIANT_TRUE,UI4,0xffffffff,I4,-1);
4361 VAROR(BOOL,VARIANT_TRUE,UI4,0,I4,-1);
4362 VAROR(BOOL,VARIANT_FALSE,UI4,0,I4,0);
4363 VAROR(BOOL,VARIANT_TRUE,R4,-1,I4,-1);
4364 VAROR(BOOL,VARIANT_TRUE,R4,0,I4,-1);
4365 VAROR(BOOL,VARIANT_FALSE,R4,0,I4,0);
4366 VAROR(BOOL,VARIANT_TRUE,R8,-1,I4,-1);
4367 VAROR(BOOL,VARIANT_TRUE,R8,0,I4,-1);
4368 VAROR(BOOL,VARIANT_FALSE,R8,0,I4,0);
4369 VAROR(BOOL,VARIANT_TRUE,DATE,-1,I4,-1);
4370 VAROR(BOOL,VARIANT_TRUE,DATE,0,I4,-1);
4371 VAROR(BOOL,VARIANT_FALSE,DATE,0,I4,0);
4372 if (HAVE_OLEAUT32_I8)
4374 VAROR(BOOL,VARIANT_TRUE,I8,-1,I8,-1);
4375 VAROR(BOOL,VARIANT_TRUE,I8,0,I8,-1);
4376 VAROR(BOOL,VARIANT_FALSE,I8,0,I8,0);
4377 /* This returns DISP_E_OVERFLOW which indicates that a conversion
4378 * to I4 is performed.
4380 /* VAROR(BOOL,VARIANT_TRUE,UI8,-1,I4,-1); */
4381 VAROR(BOOL,VARIANT_TRUE,UI8,0,I4,-1);
4382 VAROR(BOOL,VARIANT_FALSE,UI8,0,I4,0);
4384 VAROR(BOOL,VARIANT_TRUE,INT,-1,I4,-1);
4385 VAROR(BOOL,VARIANT_TRUE,INT,0,I4,-1);
4386 VAROR(BOOL,VARIANT_FALSE,INT,0,I4,0);
4387 VAROR(BOOL,VARIANT_TRUE,UINT,0xffffffff,I4,-1);
4388 VAROR(BOOL,VARIANT_TRUE,UINT,0,I4,-1);
4389 VAROR(BOOL,VARIANT_FALSE,UINT,0,I4,0);
4390 rbstr = SysAllocString(szFalse);
4391 VAROR(BOOL,VARIANT_FALSE,BSTR,rbstr,BOOL,VARIANT_FALSE);
4392 VAROR(BOOL,VARIANT_TRUE,BSTR,rbstr,BOOL,VARIANT_TRUE);
4393 SysFreeString(rbstr);
4394 rbstr = SysAllocString(szTrue);
4395 VAROR(BOOL,VARIANT_FALSE,BSTR,rbstr,BOOL,VARIANT_TRUE);
4396 VAROR(BOOL,VARIANT_TRUE,BSTR,rbstr,BOOL,VARIANT_TRUE);
4397 SysFreeString(rbstr);
4398 VARORCY(BOOL,VARIANT_TRUE,10000,I4,-1);
4399 VARORCY(BOOL,VARIANT_TRUE,0,I4,-1);
4400 VARORCY(BOOL,VARIANT_FALSE,0,I4,0);
4402 VAROR(I1,-1,I1,-1,I4,-1);
4403 VAROR(I1,-1,I1,0,I4,-1);
4404 VAROR(I1,0,I1,0,I4,0);
4405 VAROR(I1,-1,UI1,255,I4,-1);
4406 VAROR(I1,-1,UI1,0,I4,-1);
4407 VAROR(I1,0,UI1,0,I4,0);
4408 VAROR(I1,-1,I2,-1,I4,-1);
4409 VAROR(I1,-1,I2,0,I4,-1);
4410 VAROR(I1,0,I2,0,I4,0);
4411 VAROR(I1,-1,UI2,65535,I4,-1);
4412 VAROR(I1,-1,UI2,0,I4,-1);
4413 VAROR(I1,0,UI2,0,I4,0);
4414 VAROR(I1,-1,I4,-1,I4,-1);
4415 VAROR(I1,-1,I4,0,I4,-1);
4416 VAROR(I1,0,I4,0,I4,0);
4417 VAROR(I1,-1,UI4,0xffffffff,I4,-1);
4418 VAROR(I1,-1,UI4,0,I4,-1);
4419 VAROR(I1,0,UI4,0,I4,0);
4420 VAROR(I1,-1,R4,-1,I4,-1);
4421 VAROR(I1,-1,R4,0,I4,-1);
4422 VAROR(I1,0,R4,0,I4,0);
4423 VAROR(I1,-1,R8,-1,I4,-1);
4424 VAROR(I1,-1,R8,0,I4,-1);
4425 VAROR(I1,0,R8,0,I4,0);
4426 VAROR(I1,-1,DATE,-1,I4,-1);
4427 VAROR(I1,-1,DATE,0,I4,-1);
4428 VAROR(I1,0,DATE,0,I4,0);
4429 if (HAVE_OLEAUT32_I8)
4431 VAROR(I1,-1,I8,-1,I8,-1);
4432 VAROR(I1,-1,I8,0,I8,-1);
4433 VAROR(I1,0,I8,0,I8,0);
4434 VAROR(I1,-1,UI8,0,I4,-1);
4435 VAROR(I1,0,UI8,0,I4,0);
4437 VAROR(I1,-1,INT,-1,I4,-1);
4438 VAROR(I1,-1,INT,0,I4,-1);
4439 VAROR(I1,0,INT,0,I4,0);
4440 VAROR(I1,-1,UINT,0xffffffff,I4,-1);
4441 VAROR(I1,-1,UINT,0,I4,-1);
4442 VAROR(I1,0,UINT,0,I4,0);
4443 rbstr = SysAllocString(szFalse);
4444 VAROR(I1,0,BSTR,rbstr,I4,0);
4445 VAROR(I1,-1,BSTR,rbstr,I4,-1);
4446 SysFreeString(rbstr);
4447 rbstr = SysAllocString(szTrue);
4448 VAROR(I1,0,BSTR,rbstr,I4,-1);
4449 VAROR(I1,-1,BSTR,rbstr,I4,-1);
4450 SysFreeString(rbstr);
4451 VARORCY(I1,-1,10000,I4,-1);
4452 VARORCY(I1,-1,0,I4,-1);
4453 VARORCY(I1,0,0,I4,0);
4455 VAROR(UI1,255,UI1,255,UI1,255);
4456 VAROR(UI1,255,UI1,0,UI1,255);
4457 VAROR(UI1,0,UI1,0,UI1,0);
4458 VAROR(UI1,255,I2,-1,I2,-1);
4459 VAROR(UI1,255,I2,0,I2,255);
4460 VAROR(UI1,0,I2,0,I2,0);
4461 VAROR(UI1,255,UI2,65535,I4,65535);
4462 VAROR(UI1,255,UI2,0,I4,255);
4463 VAROR(UI1,0,UI2,0,I4,0);
4464 VAROR(UI1,255,I4,-1,I4,-1);
4465 VAROR(UI1,255,I4,0,I4,255);
4466 VAROR(UI1,0,I4,0,I4,0);
4467 VAROR(UI1,255,UI4,0xffffffff,I4,-1);
4468 VAROR(UI1,255,UI4,0,I4,255);
4469 VAROR(UI1,0,UI4,0,I4,0);
4470 VAROR(UI1,255,R4,-1,I4,-1);
4471 VAROR(UI1,255,R4,0,I4,255);
4472 VAROR(UI1,0,R4,0,I4,0);
4473 VAROR(UI1,255,R8,-1,I4,-1);
4474 VAROR(UI1,255,R8,0,I4,255);
4475 VAROR(UI1,0,R8,0,I4,0);
4476 VAROR(UI1,255,DATE,-1,I4,-1);
4477 VAROR(UI1,255,DATE,0,I4,255);
4478 VAROR(UI1,0,DATE,0,I4,0);
4479 if (HAVE_OLEAUT32_I8)
4481 VAROR(UI1,255,I8,-1,I8,-1);
4482 VAROR(UI1,255,I8,0,I8,255);
4483 VAROR(UI1,0,I8,0,I8,0);
4484 VAROR(UI1,255,UI8,0,I4,255);
4485 VAROR(UI1,0,UI8,0,I4,0);
4487 VAROR(UI1,255,INT,-1,I4,-1);
4488 VAROR(UI1,255,INT,0,I4,255);
4489 VAROR(UI1,0,INT,0,I4,0);
4490 VAROR(UI1,255,UINT,0xffffffff,I4,-1);
4491 VAROR(UI1,255,UINT,0,I4,255);
4492 VAROR(UI1,0,UINT,0,I4,0);
4493 rbstr = SysAllocString(szFalse);
4494 VAROR(UI1,0,BSTR,rbstr,I2,0);
4495 VAROR(UI1,255,BSTR,rbstr,I2,255);
4496 SysFreeString(rbstr);
4497 rbstr = SysAllocString(szTrue);
4498 VAROR(UI1,0,BSTR,rbstr,I2,-1);
4499 VAROR(UI1,255,BSTR,rbstr,I2,-1);
4500 SysFreeString(rbstr);
4501 VARORCY(UI1,255,10000,I4,255);
4502 VARORCY(UI1,255,0,I4,255);
4503 VARORCY(UI1,0,0,I4,0);
4505 VAROR(I2,-1,I2,-1,I2,-1);
4506 VAROR(I2,-1,I2,0,I2,-1);
4507 VAROR(I2,0,I2,0,I2,0);
4508 VAROR(I2,-1,UI2,65535,I4,-1);
4509 VAROR(I2,-1,UI2,0,I4,-1);
4510 VAROR(I2,0,UI2,0,I4,0);
4511 VAROR(I2,-1,I4,-1,I4,-1);
4512 VAROR(I2,-1,I4,0,I4,-1);
4513 VAROR(I2,0,I4,0,I4,0);
4514 VAROR(I2,-1,UI4,0xffffffff,I4,-1);
4515 VAROR(I2,-1,UI4,0,I4,-1);
4516 VAROR(I2,0,UI4,0,I4,0);
4517 VAROR(I2,-1,R4,-1,I4,-1);
4518 VAROR(I2,-1,R4,0,I4,-1);
4519 VAROR(I2,0,R4,0,I4,0);
4520 VAROR(I2,-1,R8,-1,I4,-1);
4521 VAROR(I2,-1,R8,0,I4,-1);
4522 VAROR(I2,0,R8,0,I4,0);
4523 VAROR(I2,-1,DATE,-1,I4,-1);
4524 VAROR(I2,-1,DATE,0,I4,-1);
4525 VAROR(I2,0,DATE,0,I4,0);
4526 if (HAVE_OLEAUT32_I8)
4528 VAROR(I2,-1,I8,-1,I8,-1);
4529 VAROR(I2,-1,I8,0,I8,-1);
4530 VAROR(I2,0,I8,0,I8,0);
4531 VAROR(I2,-1,UI8,0,I4,-1);
4532 VAROR(I2,0,UI8,0,I4,0);
4534 VAROR(I2,-1,INT,-1,I4,-1);
4535 VAROR(I2,-1,INT,0,I4,-1);
4536 VAROR(I2,0,INT,0,I4,0);
4537 VAROR(I2,-1,UINT,0xffffffff,I4,-1);
4538 VAROR(I2,-1,UINT,0,I4,-1);
4539 VAROR(I2,0,UINT,0,I4,0);
4540 rbstr = SysAllocString(szFalse);
4541 VAROR(I2,0,BSTR,rbstr,I2,0);
4542 VAROR(I2,-1,BSTR,rbstr,I2,-1);
4543 SysFreeString(rbstr);
4544 rbstr = SysAllocString(szTrue);
4545 VAROR(I2,0,BSTR,rbstr,I2,-1);
4546 VAROR(I2,-1,BSTR,rbstr,I2,-1);
4547 SysFreeString(rbstr);
4548 VARORCY(I2,-1,10000,I4,-1);
4549 VARORCY(I2,-1,0,I4,-1);
4550 VARORCY(I2,0,0,I4,0);
4552 VAROR(UI2,65535,UI2,65535,I4,65535);
4553 VAROR(UI2,65535,UI2,0,I4,65535);
4554 VAROR(UI2,0,UI2,0,I4,0);
4555 VAROR(UI2,65535,I4,-1,I4,-1);
4556 VAROR(UI2,65535,I4,0,I4,65535);
4557 VAROR(UI2,0,I4,0,I4,0);
4558 VAROR(UI2,65535,UI4,0xffffffff,I4,-1);
4559 VAROR(UI2,65535,UI4,0,I4,65535);
4560 VAROR(UI2,0,UI4,0,I4,0);
4561 VAROR(UI2,65535,R4,-1,I4,-1);
4562 VAROR(UI2,65535,R4,0,I4,65535);
4563 VAROR(UI2,0,R4,0,I4,0);
4564 VAROR(UI2,65535,R8,-1,I4,-1);
4565 VAROR(UI2,65535,R8,0,I4,65535);
4566 VAROR(UI2,0,R8,0,I4,0);
4567 VAROR(UI2,65535,DATE,-1,I4,-1);
4568 VAROR(UI2,65535,DATE,0,I4,65535);
4569 VAROR(UI2,0,DATE,0,I4,0);
4570 if (HAVE_OLEAUT32_I8)
4572 VAROR(UI2,65535,I8,-1,I8,-1);
4573 VAROR(UI2,65535,I8,0,I8,65535);
4574 VAROR(UI2,0,I8,0,I8,0);
4575 VAROR(UI2,65535,UI8,0,I4,65535);
4576 VAROR(UI2,0,UI8,0,I4,0);
4578 VAROR(UI2,65535,INT,-1,I4,-1);
4579 VAROR(UI2,65535,INT,0,I4,65535);
4580 VAROR(UI2,0,INT,0,I4,0);
4581 VAROR(UI2,65535,UINT,0xffffffff,I4,-1);
4582 VAROR(UI2,65535,UINT,0,I4,65535);
4583 VAROR(UI2,0,UINT,0,I4,0);
4584 rbstr = SysAllocString(szFalse);
4585 VAROR(UI2,0,BSTR,rbstr,I4,0);
4586 VAROR(UI2,65535,BSTR,rbstr,I4,65535);
4587 SysFreeString(rbstr);
4588 rbstr = SysAllocString(szTrue);
4589 VAROR(UI2,0,BSTR,rbstr,I4,-1);
4590 VAROR(UI2,65535,BSTR,rbstr,I4,-1);
4591 SysFreeString(rbstr);
4592 VARORCY(UI2,65535,10000,I4,65535);
4593 VARORCY(UI2,65535,0,I4,65535);
4594 VARORCY(UI2,0,0,I4,0);
4596 VAROR(I4,-1,I4,-1,I4,-1);
4597 VAROR(I4,-1,I4,0,I4,-1);
4598 VAROR(I4,0,I4,0,I4,0);
4599 VAROR(I4,-1,UI4,0xffffffff,I4,-1);
4600 VAROR(I4,-1,UI4,0,I4,-1);
4601 VAROR(I4,0,UI4,0,I4,0);
4602 VAROR(I4,-1,R4,-1,I4,-1);
4603 VAROR(I4,-1,R4,0,I4,-1);
4604 VAROR(I4,0,R4,0,I4,0);
4605 VAROR(I4,-1,R8,-1,I4,-1);
4606 VAROR(I4,-1,R8,0,I4,-1);
4607 VAROR(I4,0,R8,0,I4,0);
4608 VAROR(I4,-1,DATE,-1,I4,-1);
4609 VAROR(I4,-1,DATE,0,I4,-1);
4610 VAROR(I4,0,DATE,0,I4,0);
4611 if (HAVE_OLEAUT32_I8)
4613 VAROR(I4,-1,I8,-1,I8,-1);
4614 VAROR(I4,-1,I8,0,I8,-1);
4615 VAROR(I4,0,I8,0,I8,0);
4616 VAROR(I4,-1,UI8,0,I4,-1);
4617 VAROR(I4,0,UI8,0,I4,0);
4619 VAROR(I4,-1,INT,-1,I4,-1);
4620 VAROR(I4,-1,INT,0,I4,-1);
4621 VAROR(I4,0,INT,0,I4,0);
4622 VAROR(I4,-1,UINT,0xffffffff,I4,-1);
4623 VAROR(I4,-1,UINT,0,I4,-1);
4624 VAROR(I4,0,UINT,0,I4,0);
4625 rbstr = SysAllocString(szFalse);
4626 VAROR(I4,0,BSTR,rbstr,I4,0);
4627 VAROR(I4,-1,BSTR,rbstr,I4,-1);
4628 SysFreeString(rbstr);
4629 rbstr = SysAllocString(szTrue);
4630 VAROR(I4,0,BSTR,rbstr,I4,-1);
4631 VAROR(I4,-1,BSTR,rbstr,I4,-1);
4632 SysFreeString(rbstr);
4633 VARORCY(I4,-1,10000,I4,-1);
4634 VARORCY(I4,-1,0,I4,-1);
4635 VARORCY(I4,0,0,I4,0);
4637 VAROR(UI4,0xffffffff,UI4,0xffffffff,I4,-1);
4638 VAROR(UI4,0xffffffff,UI4,0,I4,-1);
4639 VAROR(UI4,0,UI4,0,I4,0);
4640 VAROR(UI4,0xffffffff,R4,-1,I4,-1);
4641 VAROR(UI4,0xffffffff,R4,0,I4,-1);
4642 VAROR(UI4,0,R4,0,I4,0);
4643 VAROR(UI4,0xffffffff,R8,-1,I4,-1);
4644 VAROR(UI4,0xffffffff,R8,0,I4,-1);
4645 VAROR(UI4,0,R8,0,I4,0);
4646 VAROR(UI4,0xffffffff,DATE,-1,I4,-1);
4647 VAROR(UI4,0xffffffff,DATE,0,I4,-1);
4648 VAROR(UI4,0,DATE,0,I4,0);
4649 if (HAVE_OLEAUT32_I8)
4651 VAROR(UI4,0xffffffff,I8,-1,I8,-1);
4652 VAROR(UI4,0xffffffff,I8,0,I8,0xffffffff);
4653 VAROR(UI4,0,I8,0,I8,0);
4654 VAROR(UI4,0xffffffff,UI8,0,I4,-1);
4655 VAROR(UI4,0,UI8,0,I4,0);
4657 VAROR(UI4,0xffffffff,INT,-1,I4,-1);
4658 VAROR(UI4,0xffffffff,INT,0,I4,-1);
4659 VAROR(UI4,0,INT,0,I4,0);
4660 VAROR(UI4,0xffffffff,UINT,0xffffffff,I4,-1);
4661 VAROR(UI4,0xffffffff,UINT,0,I4,-1);
4662 VAROR(UI4,0,UINT,0,I4,0);
4663 rbstr = SysAllocString(szFalse);
4664 VAROR(UI4,0,BSTR,rbstr,I4,0);
4665 VAROR(UI4,0xffffffff,BSTR,rbstr,I4,-1);
4666 SysFreeString(rbstr);
4667 rbstr = SysAllocString(szTrue);
4668 VAROR(UI4,0,BSTR,rbstr,I4,-1);
4669 VAROR(UI4,0xffffffff,BSTR,rbstr,I4,-1);
4670 SysFreeString(rbstr);
4671 VARORCY(UI4,0xffffffff,10000,I4,-1);
4672 VARORCY(UI4,0xffffffff,0,I4,-1);
4673 VARORCY(UI4,0,0,I4,0);
4675 VAROR(R4,-1,R4,-1,I4,-1);
4676 VAROR(R4,-1,R4,0,I4,-1);
4677 VAROR(R4,0,R4,0,I4,0);
4678 VAROR(R4,-1,R8,-1,I4,-1);
4679 VAROR(R4,-1,R8,0,I4,-1);
4680 VAROR(R4,0,R8,0,I4,0);
4681 VAROR(R4,-1,DATE,-1,I4,-1);
4682 VAROR(R4,-1,DATE,0,I4,-1);
4683 VAROR(R4,0,DATE,0,I4,0);
4684 if (HAVE_OLEAUT32_I8)
4686 VAROR(R4,-1,I8,-1,I8,-1);
4687 VAROR(R4,-1,I8,0,I8,-1);
4688 VAROR(R4,0,I8,0,I8,0);
4689 VAROR(R4,-1,UI8,0,I4,-1);
4690 VAROR(R4,0,UI8,0,I4,0);
4692 VAROR(R4,-1,INT,-1,I4,-1);
4693 VAROR(R4,-1,INT,0,I4,-1);
4694 VAROR(R4,0,INT,0,I4,0);
4695 VAROR(R4,-1,UINT,0xffffffff,I4,-1);
4696 VAROR(R4,-1,UINT,0,I4,-1);
4697 VAROR(R4,0,UINT,0,I4,0);
4698 rbstr = SysAllocString(szFalse);
4699 VAROR(R4,0,BSTR,rbstr,I4,0);
4700 VAROR(R4,-1,BSTR,rbstr,I4,-1);
4701 SysFreeString(rbstr);
4702 rbstr = SysAllocString(szTrue);
4703 VAROR(R4,0,BSTR,rbstr,I4,-1);
4704 VAROR(R4,-1,BSTR,rbstr,I4,-1);
4705 SysFreeString(rbstr);
4706 VARORCY(R4,-1,10000,I4,-1);
4707 VARORCY(R4,-1,0,I4,-1);
4708 VARORCY(R4,0,0,I4,0);
4710 VAROR(R8,-1,R8,-1,I4,-1);
4711 VAROR(R8,-1,R8,0,I4,-1);
4712 VAROR(R8,0,R8,0,I4,0);
4713 VAROR(R8,-1,DATE,-1,I4,-1);
4714 VAROR(R8,-1,DATE,0,I4,-1);
4715 VAROR(R8,0,DATE,0,I4,0);
4716 if (HAVE_OLEAUT32_I8)
4718 VAROR(R8,-1,I8,-1,I8,-1);
4719 VAROR(R8,-1,I8,0,I8,-1);
4720 VAROR(R8,0,I8,0,I8,0);
4721 VAROR(R8,-1,UI8,0,I4,-1);
4722 VAROR(R8,0,UI8,0,I4,0);
4724 VAROR(R8,-1,INT,-1,I4,-1);
4725 VAROR(R8,-1,INT,0,I4,-1);
4726 VAROR(R8,0,INT,0,I4,0);
4727 VAROR(R8,-1,UINT,0xffffffff,I4,-1);
4728 VAROR(R8,-1,UINT,0,I4,-1);
4729 VAROR(R8,0,UINT,0,I4,0);
4730 rbstr = SysAllocString(szFalse);
4731 VAROR(R8,0,BSTR,rbstr,I4,0);
4732 VAROR(R8,-1,BSTR,rbstr,I4,-1);
4733 SysFreeString(rbstr);
4734 rbstr = SysAllocString(szTrue);
4735 VAROR(R8,0,BSTR,rbstr,I4,-1);
4736 VAROR(R8,-1,BSTR,rbstr,I4,-1);
4737 SysFreeString(rbstr);
4738 VARORCY(R8,-1,10000,I4,-1);
4739 VARORCY(R8,-1,0,I4,-1);
4740 VARORCY(R8,0,0,I4,0);
4742 VAROR(DATE,-1,DATE,-1,I4,-1);
4743 VAROR(DATE,-1,DATE,0,I4,-1);
4744 VAROR(DATE,0,DATE,0,I4,0);
4745 if (HAVE_OLEAUT32_I8)
4747 VAROR(DATE,-1,I8,-1,I8,-1);
4748 VAROR(DATE,-1,I8,0,I8,-1);
4749 VAROR(DATE,0,I8,0,I8,0);
4750 VAROR(DATE,-1,UI8,0,I4,-1);
4751 VAROR(DATE,0,UI8,0,I4,0);
4753 VAROR(DATE,-1,INT,-1,I4,-1);
4754 VAROR(DATE,-1,INT,0,I4,-1);
4755 VAROR(DATE,0,INT,0,I4,0);
4756 VAROR(DATE,-1,UINT,0xffffffff,I4,-1);
4757 VAROR(DATE,-1,UINT,0,I4,-1);
4758 VAROR(DATE,0,UINT,0,I4,0);
4759 rbstr = SysAllocString(szFalse);
4760 VAROR(DATE,0,BSTR,rbstr,I4,0);
4761 VAROR(DATE,-1,BSTR,rbstr,I4,-1);
4762 SysFreeString(rbstr);
4763 rbstr = SysAllocString(szTrue);
4764 VAROR(DATE,0,BSTR,rbstr,I4,-1);
4765 VAROR(DATE,-1,BSTR,rbstr,I4,-1);
4766 SysFreeString(rbstr);
4767 VARORCY(DATE,-1,10000,I4,-1);
4768 VARORCY(DATE,-1,0,I4,-1);
4769 VARORCY(DATE,0,0,I4,0);
4771 if (HAVE_OLEAUT32_I8)
4773 VAROR(I8,-1,I8,-1,I8,-1);
4774 VAROR(I8,-1,I8,0,I8,-1);
4775 VAROR(I8,0,I8,0,I8,0);
4776 VAROR(I8,-1,UI8,0,I8,-1);
4777 VAROR(I8,0,UI8,0,I8,0);
4778 /* These overflow under native and Wine
4779 VAROR(I8,-1,INT,-1,I4,-1);
4780 VAROR(I8,-1,INT,0,I4,-1);
4781 VAROR(I8,0,INT,0,I4,0); */
4782 VAROR(I8,-1,UINT,0xffffffff,I8,-1);
4783 VAROR(I8,-1,UINT,0,I8,-1);
4784 VAROR(I8,0,UINT,0,I8,0);
4785 rbstr = SysAllocString(szFalse);
4786 VAROR(I8,0,BSTR,rbstr,I8,0);
4787 VAROR(I8,-1,BSTR,rbstr,I8,-1);
4788 SysFreeString(rbstr);
4789 rbstr = SysAllocString(szTrue);
4790 VAROR(I8,0,BSTR,rbstr,I8,-1);
4791 VAROR(I8,-1,BSTR,rbstr,I8,-1);
4792 SysFreeString(rbstr);
4793 VARORCY(I8,-1,10000,I8,-1);
4794 VARORCY(I8,-1,0,I8,-1);
4795 VARORCY(I8,0,0,I8,0);
4797 VAROR(UI8,0xffff,UI8,0xffff,I4,0xffff);
4798 VAROR(UI8,0xffff,UI8,0,I4,0xffff);
4799 VAROR(UI8,0,UI8,0,I4,0);
4800 VAROR(UI8,0xffff,INT,-1,I4,-1);
4801 VAROR(UI8,0xffff,INT,0,I4,0xffff);
4802 VAROR(UI8,0,INT,0,I4,0);
4803 VAROR(UI8,0xffff,UINT,0xffff,I4,0xffff);
4804 VAROR(UI8,0xffff,UINT,0,I4,0xffff);
4805 VAROR(UI8,0,UINT,0,I4,0);
4806 rbstr = SysAllocString(szFalse);
4807 VAROR(UI8,0,BSTR,rbstr,I4,0);
4808 VAROR(UI8,0xffff,BSTR,rbstr,I4,0xffff);
4809 SysFreeString(rbstr);
4810 rbstr = SysAllocString(szTrue);
4811 VAROR(UI8,0,BSTR,rbstr,I4,-1);
4812 VAROR(UI8,0xffff,BSTR,rbstr,I4,-1);
4813 SysFreeString(rbstr);
4814 VARORCY(UI8,0xffff,10000,I4,0xffff);
4815 VARORCY(UI8,0xffff,0,I4,0xffff);
4816 VARORCY(UI8,0,0,I4,0);
4819 VAROR(INT,-1,INT,-1,I4,-1);
4820 VAROR(INT,-1,INT,0,I4,-1);
4821 VAROR(INT,0,INT,0,I4,0);
4822 VAROR(INT,-1,UINT,0xffff,I4,-1);
4823 VAROR(INT,-1,UINT,0,I4,-1);
4824 VAROR(INT,0,UINT,0,I4,0);
4825 rbstr = SysAllocString(szFalse);
4826 VAROR(INT,0,BSTR,rbstr,I4,0);
4827 VAROR(INT,-1,BSTR,rbstr,I4,-1);
4828 SysFreeString(rbstr);
4829 rbstr = SysAllocString(szTrue);
4830 VAROR(INT,0,BSTR,rbstr,I4,-1);
4831 VAROR(INT,-1,BSTR,rbstr,I4,-1);
4832 SysFreeString(rbstr);
4833 VARORCY(INT,-1,10000,I4,-1);
4834 VARORCY(INT,-1,0,I4,-1);
4835 VARORCY(INT,0,0,I4,0);
4837 VAROR(UINT,0xffff,UINT,0xffff,I4,0xffff);
4838 VAROR(UINT,0xffff,UINT,0,I4,0xffff);
4839 VAROR(UINT,0,UINT,0,I4,0);
4840 rbstr = SysAllocString(szFalse);
4841 VAROR(UINT,0,BSTR,rbstr,I4,0);
4842 VAROR(UINT,0xffff,BSTR,rbstr,I4,0xffff);
4843 SysFreeString(rbstr);
4844 rbstr = SysAllocString(szTrue);
4845 VAROR(UINT,0,BSTR,rbstr,I4,-1);
4846 VAROR(UINT,0xffff,BSTR,rbstr,I4,-1);
4847 SysFreeString(rbstr);
4848 VARORCY(UINT,0xffff,10000,I4,0xffff);
4849 VARORCY(UINT,0xffff,0,I4,0xffff);
4850 VARORCY(UINT,0,0,I4,0);
4852 lbstr = SysAllocString(szFalse);
4853 rbstr = SysAllocString(szFalse);
4854 VAROR(BSTR,lbstr,BSTR,rbstr,BOOL,0);
4855 SysFreeString(rbstr);
4856 rbstr = SysAllocString(szTrue);
4857 VAROR(BSTR,lbstr,BSTR,rbstr,BOOL,VARIANT_TRUE);
4858 SysFreeString(lbstr);
4859 lbstr = SysAllocString(szTrue);
4860 VAROR(BSTR,lbstr,BSTR,rbstr,BOOL,VARIANT_TRUE);
4861 VARORCY(BSTR,lbstr,10000,I4,-1);
4862 SysFreeString(lbstr);
4863 lbstr = SysAllocString(szFalse);
4864 VARORCY(BSTR,lbstr,10000,I4,1);
4865 SysFreeString(lbstr);
4866 SysFreeString(rbstr);
4869 static HRESULT (WINAPI *pVarEqv)(LPVARIANT,LPVARIANT,LPVARIANT);
4871 #define VAREQV(vt1,val1,vt2,val2,rvt,rval) \
4872 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
4873 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
4874 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
4875 test_var_call2( __LINE__, pVarEqv, &left, &right, &exp )
4877 static void test_VarEqv(void)
4879 VARIANT left, right, exp, result;
4885 /* Test all possible flag/vt combinations & the resulting vt type */
4886 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
4888 VARTYPE leftvt, rightvt, resvt;
4890 for (leftvt = 0; leftvt <= VT_BSTR_BLOB; leftvt++)
4894 for (rightvt = 0; rightvt <= VT_BSTR_BLOB; rightvt++)
4900 if (leftvt == VT_BSTR || rightvt == VT_BSTR ||
4901 leftvt == VT_DISPATCH || rightvt == VT_DISPATCH ||
4902 leftvt == VT_UNKNOWN || rightvt == VT_UNKNOWN)
4905 memset(&left, 0, sizeof(left));
4906 memset(&right, 0, sizeof(right));
4907 V_VT(&left) = leftvt | ExtraFlags[i];
4908 V_VT(&right) = rightvt | ExtraFlags[i];
4909 V_VT(&result) = VT_EMPTY;
4912 if (ExtraFlags[i] & VT_ARRAY || ExtraFlags[i] & VT_BYREF ||
4913 !IsValidVariantClearVT(leftvt, ExtraFlags[i]) ||
4914 !IsValidVariantClearVT(rightvt, ExtraFlags[i]) ||
4915 leftvt == VT_CLSID || rightvt == VT_CLSID ||
4916 leftvt == VT_RECORD || rightvt == VT_RECORD ||
4917 leftvt == VT_VARIANT || rightvt == VT_VARIANT ||
4918 leftvt == VT_ERROR || rightvt == VT_ERROR)
4922 if (leftvt == VT_EMPTY || rightvt == VT_EMPTY)
4924 if (leftvt == rightvt ||
4925 leftvt == VT_I2 || rightvt == VT_I2 ||
4926 leftvt == VT_UI1 || rightvt == VT_UI1 ||
4927 leftvt == VT_BOOL || rightvt == VT_BOOL)
4929 else if (leftvt == VT_NULL || rightvt == VT_NULL)
4931 else if (leftvt == VT_I8 || rightvt == VT_I8)
4934 else if (leftvt == VT_NULL || rightvt == VT_NULL)
4938 else if (leftvt == VT_UI1 || rightvt == VT_UI1)
4940 if (leftvt == rightvt)
4942 else if (leftvt == rightvt ||
4943 leftvt == VT_I2 || rightvt == VT_I2 ||
4944 leftvt == VT_BOOL || rightvt == VT_BOOL)
4948 else if (leftvt == VT_I8 || rightvt == VT_I8)
4951 else if (leftvt == VT_I2 || rightvt == VT_I2)
4953 if (leftvt == rightvt ||
4954 leftvt == VT_BOOL || rightvt == VT_BOOL)
4956 else if (leftvt == VT_I8 || rightvt == VT_I8)
4959 else if (leftvt == VT_BOOL && rightvt == VT_BOOL)
4963 else if (leftvt == VT_I8 || rightvt == VT_I8)
4965 if (leftvt == VT_INT || rightvt == VT_INT)
4970 hres = pVarEqv(&left, &right, &result);
4972 ok(hres == DISP_E_TYPEMISMATCH || hres == DISP_E_BADVARTYPE,
4973 "VarEqv: %d|0x%X, %d|0x%X: Expected failure, got 0x%X vt %d\n",
4974 leftvt, ExtraFlags[i], rightvt, ExtraFlags[i], hres,
4977 ok(hres == S_OK && V_VT(&result) == resvt,
4978 "VarEqv: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%X vt %d\n",
4979 leftvt, ExtraFlags[i], rightvt, ExtraFlags[i], resvt, hres,
4985 /* Test returned values */
4986 VAREQV(BOOL,VARIANT_TRUE,BOOL,VARIANT_TRUE,BOOL,VARIANT_TRUE);
4987 VAREQV(BOOL,VARIANT_FALSE,BOOL,VARIANT_TRUE,BOOL,VARIANT_FALSE);
4988 VAREQV(BOOL,TRUE,BOOL,TRUE,BOOL,VARIANT_TRUE);
4989 VAREQV(BOOL,FALSE,BOOL,FALSE,BOOL,VARIANT_TRUE);
4990 VAREQV(BOOL,TRUE,BOOL,FALSE,BOOL,-2);
4991 VAREQV(BOOL,FALSE,BOOL,TRUE,BOOL,-2);
4992 VAREQV(BOOL,6,BOOL,7,BOOL,-2);
4993 VAREQV(BOOL,6,BOOL,6,BOOL,VARIANT_TRUE);
4994 VAREQV(BOOL,VARIANT_TRUE,I2,VARIANT_TRUE,I2,VARIANT_TRUE);
4995 VAREQV(BOOL,VARIANT_TRUE,I2,VARIANT_FALSE,I2,VARIANT_FALSE);
4996 VAREQV(BOOL,6,I2,7,I2,-2);
4997 VAREQV(UI1,1,UI1,1,UI1,255);
4998 VAREQV(UI1,1,UI1,0,UI1,254);
4999 VAREQV(UI1,0,UI1,1,UI1,254);
5000 if (HAVE_OLEAUT32_I8)
5002 VAREQV(UI4,VARIANT_FALSE,I8,VARIANT_FALSE,I8,-1);
5003 VAREQV(UI4,5,I8,19,I8,-23);
5004 VAREQV(UI4,VARIANT_FALSE,UI8,VARIANT_FALSE,I4,-1);
5008 static HRESULT (WINAPI *pVarMul)(LPVARIANT,LPVARIANT,LPVARIANT);
5010 #define VARMUL(vt1,val1,vt2,val2,rvt,rval) \
5011 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
5012 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
5013 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
5014 test_var_call2( __LINE__, pVarMul, &left, &right, &exp )
5016 static void test_VarMul(void)
5018 VARIANT left, right, exp, result, cy, dec;
5026 lbstr = SysAllocString(sz12);
5027 rbstr = SysAllocString(sz12);
5029 /* Test all possible flag/vt combinations & the resulting vt type */
5030 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
5032 VARTYPE leftvt, rightvt, resvt;
5034 for (leftvt = 0; leftvt <= VT_BSTR_BLOB; leftvt++)
5039 for (rightvt = 0; rightvt <= VT_BSTR_BLOB; rightvt++)
5045 if (leftvt == VT_DISPATCH || rightvt == VT_DISPATCH ||
5046 leftvt == VT_UNKNOWN || rightvt == VT_UNKNOWN)
5049 memset(&left, 0, sizeof(left));
5050 memset(&right, 0, sizeof(right));
5051 V_VT(&left) = leftvt | ExtraFlags[i];
5052 if (leftvt == VT_BSTR)
5053 V_BSTR(&left) = lbstr;
5054 V_VT(&right) = rightvt | ExtraFlags[i];
5055 if (rightvt == VT_BSTR)
5056 V_BSTR(&right) = rbstr;
5057 V_VT(&result) = VT_EMPTY;
5060 /* Don't ask me why but native VarMul cannot handle:
5061 VT_I1, VT_UI2, VT_UI4, VT_INT, VT_UINT and VT_UI8.
5062 Tested with DCOM98, Win2k, WinXP */
5063 if (ExtraFlags[i] & VT_ARRAY || ExtraFlags[i] & VT_BYREF ||
5064 !IsValidVariantClearVT(leftvt, ExtraFlags[i]) ||
5065 !IsValidVariantClearVT(rightvt, ExtraFlags[i]) ||
5066 leftvt == VT_CLSID || rightvt == VT_CLSID ||
5067 leftvt == VT_RECORD || rightvt == VT_RECORD ||
5068 leftvt == VT_VARIANT || rightvt == VT_VARIANT ||
5069 leftvt == VT_ERROR || rightvt == VT_ERROR ||
5070 leftvt == VT_I1 || rightvt == VT_I1 ||
5071 leftvt == VT_UI2 || rightvt == VT_UI2 ||
5072 leftvt == VT_UI4 || rightvt == VT_UI4 ||
5073 leftvt == VT_UI8 || rightvt == VT_UI8 ||
5074 leftvt == VT_INT || rightvt == VT_INT ||
5075 leftvt == VT_UINT || rightvt == VT_UINT) {
5079 if (leftvt == VT_NULL || rightvt == VT_NULL)
5081 else if (leftvt == VT_DECIMAL || rightvt == VT_DECIMAL)
5083 else if (leftvt == VT_R8 || rightvt == VT_R8 ||
5084 leftvt == VT_BSTR || rightvt == VT_BSTR ||
5085 leftvt == VT_DATE || rightvt == VT_DATE)
5087 else if (leftvt == VT_R4 || rightvt == VT_R4) {
5088 if (leftvt == VT_I4 || rightvt == VT_I4 ||
5089 leftvt == VT_I8 || rightvt == VT_I8 ||
5090 leftvt == VT_CY || rightvt == VT_CY)
5094 } else if (leftvt == VT_CY || rightvt == VT_CY)
5096 else if (leftvt == VT_I8 || rightvt == VT_I8)
5098 else if (leftvt == VT_I4 || rightvt == VT_I4)
5100 else if (leftvt == VT_I2 || rightvt == VT_I2 ||
5101 leftvt == VT_BOOL || rightvt == VT_BOOL ||
5102 (leftvt == VT_EMPTY && rightvt == VT_EMPTY))
5104 else if (leftvt == VT_UI1 || rightvt == VT_UI1)
5107 hres = pVarMul(&left, &right, &result);
5109 ok(hres == DISP_E_TYPEMISMATCH || hres == DISP_E_BADVARTYPE,
5110 "VarMul: %d|0x%X, %d|0x%X: Expected failure, got 0x%X vt %d\n",
5111 leftvt, ExtraFlags[i], rightvt, ExtraFlags[i], hres,
5114 ok(hres == S_OK && V_VT(&result) == resvt,
5115 "VarMul: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%X vt %d\n",
5116 leftvt, ExtraFlags[i], rightvt, ExtraFlags[i], resvt, hres,
5123 /* Test returned values */
5124 VARMUL(I4,4,I4,2,I4,8);
5125 VARMUL(I2,4,I2,2,I2,8);
5126 VARMUL(I2,-13,I4,5,I4,-65);
5127 VARMUL(I4,-13,I4,5,I4,-65);
5128 VARMUL(I2,7,R4,0.5f,R4,3.5f);
5129 VARMUL(R4,0.5f,I4,5,R8,2.5);
5130 VARMUL(R8,7.1,BOOL,0,R8,0);
5131 VARMUL(BSTR,lbstr,I2,4,R8,48);
5132 VARMUL(BSTR,lbstr,BOOL,1,R8,12);
5133 VARMUL(BSTR,lbstr,R4,0.1f,R8,1.2);
5134 VARMUL(BSTR,lbstr,BSTR,rbstr,R8,144);
5135 VARMUL(R4,0.2f,BSTR,rbstr,R8,2.4);
5136 VARMUL(DATE,2.25,I4,7,R8,15.75);
5138 VARMUL(UI1, UI1_MAX, UI1, UI1_MAX, I4, UI1_MAX * UI1_MAX);
5139 VARMUL(I2, I2_MAX, I2, I2_MAX, I4, I2_MAX * I2_MAX);
5140 VARMUL(I2, I2_MAX, I2, I2_MIN, I4, I2_MAX * I2_MIN);
5141 VARMUL(I2, I2_MIN, I2, I2_MIN, I4, I2_MIN * I2_MIN);
5142 VARMUL(I4, I4_MAX, I4, I4_MAX, R8, (double)I4_MAX * I4_MAX);
5143 VARMUL(I4, I4_MAX, I4, I4_MIN, R8, (double)I4_MAX * I4_MIN);
5144 VARMUL(I4, I4_MIN, I4, I4_MIN, R8, (double)I4_MIN * I4_MIN);
5145 VARMUL(R4, R4_MAX, R4, R4_MAX, R8, (double)R4_MAX * R4_MAX);
5146 VARMUL(R4, R4_MAX, R4, R4_MIN, R4, R4_MAX * R4_MIN);
5147 VARMUL(R4, R4_MIN, R4, R4_MIN, R4, R4_MIN * R4_MIN);
5148 VARMUL(R8, R8_MAX, R8, R8_MIN, R8, R8_MAX * R8_MIN);
5149 VARMUL(R8, R8_MIN, R8, R8_MIN, R8, R8_MIN * R8_MIN);
5151 /* Manuly test some VT_CY and VT_DECIMAL variants */
5153 hres = VarCyFromI4(4711, &V_CY(&cy));
5154 ok(hres == S_OK, "VarCyFromI4 failed!\n");
5155 V_VT(&dec) = VT_DECIMAL;
5156 hres = VarDecFromR8(-4.2, &V_DECIMAL(&dec));
5157 ok(hres == S_OK, "VarDecFromR4 failed!\n");
5158 memset(&left, 0, sizeof(left));
5159 memset(&right, 0, sizeof(right));
5160 V_VT(&left) = VT_I4;
5162 V_VT(&right) = VT_UI1;
5165 hres = pVarMul(&cy, &right, &result);
5166 ok(hres == S_OK && V_VT(&result) == VT_CY, "VarMul: expected coerced type VT_CY, got %s!\n", vtstr(V_VT(&result)));
5167 hres = VarR8FromCy(V_CY(&result), &r);
5168 ok(hres == S_OK && EQ_DOUBLE(r, 42399), "VarMul: CY value %f, expected %f\n", r, (double)42399);
5170 hres = pVarMul(&left, &dec, &result);
5171 ok(hres == S_OK && V_VT(&result) == VT_DECIMAL, "VarMul: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result)));
5172 hres = VarR8FromDec(&V_DECIMAL(&result), &r);
5173 ok(hres == S_OK && EQ_DOUBLE(r, 46.2), "VarMul: DECIMAL value %f, expected %f\n", r, (double)46.2);
5175 SysFreeString(lbstr);
5176 SysFreeString(rbstr);
5179 static HRESULT (WINAPI *pVarAdd)(LPVARIANT,LPVARIANT,LPVARIANT);
5181 #define VARADD(vt1,val1,vt2,val2,rvt,rval) \
5182 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
5183 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
5184 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
5185 test_var_call2( __LINE__, pVarAdd, &left, &right, &exp )
5187 static void test_VarAdd(void)
5189 VARIANT left, right, exp, result, cy, dec;
5197 lbstr = SysAllocString(sz12);
5198 rbstr = SysAllocString(sz12);
5200 /* Test all possible flag/vt combinations & the resulting vt type */
5201 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
5203 VARTYPE leftvt, rightvt, resvt;
5205 for (leftvt = 0; leftvt <= VT_BSTR_BLOB; leftvt++)
5210 for (rightvt = 0; rightvt <= VT_BSTR_BLOB; rightvt++)
5216 if (leftvt == VT_UNKNOWN || rightvt == VT_UNKNOWN)
5219 memset(&left, 0, sizeof(left));
5220 memset(&right, 0, sizeof(right));
5221 V_VT(&left) = leftvt | ExtraFlags[i];
5222 if (leftvt == VT_BSTR)
5223 V_BSTR(&left) = lbstr;
5224 V_VT(&right) = rightvt | ExtraFlags[i];
5225 if (rightvt == VT_BSTR)
5226 V_BSTR(&right) = rbstr;
5227 V_VT(&result) = VT_EMPTY;
5230 /* Don't ask me why but native VarAdd cannot handle:
5231 VT_I1, VT_UI2, VT_UI4, VT_INT, VT_UINT and VT_UI8.
5232 Tested with DCOM98, Win2k, WinXP */
5233 if (ExtraFlags[i] & VT_ARRAY || ExtraFlags[i] & VT_BYREF ||
5234 !IsValidVariantClearVT(leftvt, ExtraFlags[i]) ||
5235 !IsValidVariantClearVT(rightvt, ExtraFlags[i]) ||
5236 leftvt == VT_CLSID || rightvt == VT_CLSID ||
5237 leftvt == VT_RECORD || rightvt == VT_RECORD ||
5238 leftvt == VT_VARIANT || rightvt == VT_VARIANT ||
5239 leftvt == VT_ERROR || rightvt == VT_ERROR ||
5240 leftvt == VT_I1 || rightvt == VT_I1 ||
5241 leftvt == VT_UI2 || rightvt == VT_UI2 ||
5242 leftvt == VT_UI4 || rightvt == VT_UI4 ||
5243 leftvt == VT_UI8 || rightvt == VT_UI8 ||
5244 leftvt == VT_INT || rightvt == VT_INT ||
5245 leftvt == VT_UINT || rightvt == VT_UINT) {
5249 if (leftvt == VT_NULL || rightvt == VT_NULL)
5251 else if (leftvt == VT_DISPATCH || rightvt == VT_DISPATCH)
5253 else if (leftvt == VT_DECIMAL || rightvt == VT_DECIMAL)
5255 else if (leftvt == VT_DATE || rightvt == VT_DATE)
5257 else if (leftvt == VT_CY || rightvt == VT_CY)
5259 else if (leftvt == VT_R8 || rightvt == VT_R8)
5261 else if (leftvt == VT_BSTR || rightvt == VT_BSTR) {
5262 if ((leftvt == VT_BSTR && rightvt == VT_BSTR) ||
5263 leftvt == VT_EMPTY || rightvt == VT_EMPTY)
5267 } else if (leftvt == VT_R4 || rightvt == VT_R4) {
5268 if (leftvt == VT_I4 || rightvt == VT_I4 ||
5269 leftvt == VT_I8 || rightvt == VT_I8)
5274 else if (leftvt == VT_I8 || rightvt == VT_I8)
5276 else if (leftvt == VT_I4 || rightvt == VT_I4)
5278 else if (leftvt == VT_I2 || rightvt == VT_I2 ||
5279 leftvt == VT_BOOL || rightvt == VT_BOOL ||
5280 (leftvt == VT_EMPTY && rightvt == VT_EMPTY))
5282 else if (leftvt == VT_UI1 || rightvt == VT_UI1)
5285 hres = pVarAdd(&left, &right, &result);
5287 ok(hres == DISP_E_TYPEMISMATCH || hres == DISP_E_BADVARTYPE,
5288 "VarAdd: %d|0x%X, %d|0x%X: Expected failure, got 0x%X vt %d\n",
5289 leftvt, ExtraFlags[i], rightvt, ExtraFlags[i], hres,
5292 ok(hres == S_OK && V_VT(&result) == resvt,
5293 "VarAdd: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%X vt %d\n",
5294 leftvt, ExtraFlags[i], rightvt, ExtraFlags[i], resvt, hres,
5297 /* Note, we don't clear left/right deliberately here */
5298 VariantClear(&result);
5303 /* Test returned values */
5304 VARADD(I4,4,I4,2,I4,6);
5305 VARADD(I2,4,I2,2,I2,6);
5306 VARADD(I2,-13,I4,5,I4,-8);
5307 VARADD(I4,-13,I4,5,I4,-8);
5308 VARADD(I2,7,R4,0.5f,R4,7.5f);
5309 VARADD(R4,0.5f,I4,5,R8,5.5);
5310 VARADD(R8,7.1,BOOL,0,R8,7.1);
5311 VARADD(BSTR,lbstr,I2,4,R8,16);
5312 VARADD(BSTR,lbstr,BOOL,1,R8,13);
5313 VARADD(BSTR,lbstr,R4,0.1f,R8,12.1);
5314 VARADD(R4,0.2f,BSTR,rbstr,R8,12.2);
5315 VARADD(DATE,2.25,I4,7,DATE,9.25);
5316 VARADD(DATE,1.25,R4,-1.7f,DATE,-0.45);
5318 VARADD(UI1, UI1_MAX, UI1, UI1_MAX, I2, UI1_MAX + UI1_MAX);
5319 VARADD(I2, I2_MAX, I2, I2_MAX, I4, I2_MAX + I2_MAX);
5320 VARADD(I2, I2_MAX, I2, I2_MIN, I2, I2_MAX + I2_MIN);
5321 VARADD(I2, I2_MIN, I2, I2_MIN, I4, I2_MIN + I2_MIN);
5322 VARADD(I4, I4_MAX, I4, I4_MIN, I4, I4_MAX + I4_MIN);
5323 VARADD(I4, I4_MAX, I4, I4_MAX, R8, (double)I4_MAX + I4_MAX);
5324 VARADD(I4, I4_MIN, I4, I4_MIN, R8, (double)I4_MIN + I4_MIN);
5325 VARADD(R4, R4_MAX, R4, R4_MAX, R8, (double)R4_MAX + R4_MAX);
5326 VARADD(R4, R4_MAX, R4, R4_MIN, R4, R4_MAX + R4_MIN);
5327 VARADD(R4, R4_MIN, R4, R4_MIN, R4, R4_MIN + R4_MIN);
5328 VARADD(R8, R8_MAX, R8, R8_MIN, R8, R8_MAX + R8_MIN);
5329 VARADD(R8, R8_MIN, R8, R8_MIN, R8, R8_MIN + R8_MIN);
5331 /* Manually test BSTR + BSTR */
5332 V_VT(&left) = VT_BSTR;
5333 V_BSTR(&left) = lbstr;
5334 V_VT(&right) = VT_BSTR;
5335 V_BSTR(&right) = rbstr;
5336 hres = pVarAdd(&left, &right, &result);
5337 ok(hres == S_OK && V_VT(&result) == VT_BSTR, "VarAdd: expected coerced type VT_BSTR, got %s!\n", vtstr(V_VT(&result)));
5338 hres = VarR8FromStr(V_BSTR(&result), 0, 0, &r);
5339 ok(hres == S_OK && EQ_DOUBLE(r, 1212), "VarAdd: BSTR value %f, expected %f\n", r, (double)1212);
5340 VariantClear(&result);
5342 /* Manuly test some VT_CY and VT_DECIMAL variants */
5344 hres = VarCyFromI4(4711, &V_CY(&cy));
5345 ok(hres == S_OK, "VarCyFromI4 failed!\n");
5346 V_VT(&dec) = VT_DECIMAL;
5347 hres = VarDecFromR8(-4.2, &V_DECIMAL(&dec));
5348 ok(hres == S_OK, "VarDecFromR4 failed!\n");
5349 memset(&left, 0, sizeof(left));
5350 memset(&right, 0, sizeof(right));
5351 V_VT(&left) = VT_I4;
5353 V_VT(&right) = VT_UI1;
5356 hres = pVarAdd(&cy, &right, &result);
5357 ok(hres == S_OK && V_VT(&result) == VT_CY, "VarAdd: expected coerced type VT_CY, got %s!\n", vtstr(V_VT(&result)));
5358 hres = VarR8FromCy(V_CY(&result), &r);
5359 ok(hres == S_OK && EQ_DOUBLE(r, 4720), "VarAdd: CY value %f, expected %f\n", r, (double)4720);
5361 hres = pVarAdd(&left, &dec, &result);
5362 ok(hres == S_OK && V_VT(&result) == VT_DECIMAL, "VarAdd: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result)));
5363 hres = VarR8FromDec(&V_DECIMAL(&result), &r);
5364 ok(hres == S_OK && EQ_DOUBLE(r, -15.2), "VarAdd: DECIMAL value %f, expected %f\n", r, (double)-15.2);
5365 VariantClear(&result);
5367 SysFreeString(lbstr);
5368 SysFreeString(rbstr);
5371 static HRESULT (WINAPI *pVarCmp)(LPVARIANT,LPVARIANT,LCID,ULONG);
5372 static HRESULT (WINAPI *pVarCat)(LPVARIANT,LPVARIANT,LPVARIANT);
5374 static void test_VarCat(void)
5377 VARIANT left, right, result, expected, expected_broken;
5378 static const WCHAR sz34[] = {'3','4','\0'};
5379 static const WCHAR sz1234[] = {'1','2','3','4','\0'};
5380 static const WCHAR date_sz12[] = {'9','/','3','0','/','1','9','8','0','1','2','\0'};
5381 static const WCHAR date_sz12_broken[] = {'9','/','3','0','/','8','0','1','2','\0'};
5382 static const WCHAR sz12_date[] = {'1','2','9','/','3','0','/','1','9','8','0','\0'};
5383 static const WCHAR sz12_date_broken[] = {'1','2','9','/','3','0','/','8','0','\0'};
5384 static const WCHAR sz_empty[] = {'\0'};
5385 TCHAR orig_date_format[128];
5386 VARTYPE leftvt, rightvt, resultvt;
5388 HRESULT expected_error_num;
5392 /* Set date format for testing */
5393 lcid = LOCALE_USER_DEFAULT;
5394 GetLocaleInfo(lcid,LOCALE_SSHORTDATE,orig_date_format,128);
5395 SetLocaleInfo(lcid,LOCALE_SSHORTDATE,"M/d/yyyy");
5398 VariantInit(&right);
5399 VariantInit(&result);
5400 VariantInit(&expected);
5402 /* Check expected types for all combinations */
5403 for (leftvt = 0; leftvt <= VT_BSTR_BLOB; leftvt++)
5408 /* Check if we need/have support for I8 and/or UI8 */
5409 if ((leftvt == VT_I8 || leftvt == VT_UI8) && !HAVE_OLEAUT32_I8)
5412 for (rightvt = 0; rightvt <= VT_BSTR_BLOB; rightvt++)
5416 expected_error_num = S_OK;
5417 resultvt = VT_EMPTY;
5419 if (leftvt == VT_DISPATCH || rightvt == VT_DISPATCH ||
5420 leftvt == VT_UNKNOWN || rightvt == VT_UNKNOWN ||
5421 leftvt == VT_RECORD || rightvt == VT_RECORD ||
5422 leftvt == 15 || rightvt == 15 /* Undefined type */)
5425 /* Check if we need/have support for I8 and/or UI8 */
5426 if ((rightvt == VT_I8 || rightvt == VT_UI8) && !HAVE_OLEAUT32_I8)
5429 if (leftvt == VT_NULL && rightvt == VT_NULL)
5431 else if (leftvt == VT_VARIANT && (rightvt == VT_ERROR ||
5432 rightvt == VT_DATE || rightvt == VT_DECIMAL))
5433 expected_error_num = DISP_E_TYPEMISMATCH;
5434 else if ((leftvt == VT_I2 || leftvt == VT_I4 ||
5435 leftvt == VT_R4 || leftvt == VT_R8 ||
5436 leftvt == VT_CY || leftvt == VT_BOOL ||
5437 leftvt == VT_BSTR || leftvt == VT_I1 ||
5438 leftvt == VT_UI1 || leftvt == VT_UI2 ||
5439 leftvt == VT_UI4 || leftvt == VT_I8 ||
5440 leftvt == VT_UI8 || leftvt == VT_INT ||
5441 leftvt == VT_UINT || leftvt == VT_EMPTY ||
5442 leftvt == VT_NULL || leftvt == VT_DECIMAL ||
5445 (rightvt == VT_I2 || rightvt == VT_I4 ||
5446 rightvt == VT_R4 || rightvt == VT_R8 ||
5447 rightvt == VT_CY || rightvt == VT_BOOL ||
5448 rightvt == VT_BSTR || rightvt == VT_I1 ||
5449 rightvt == VT_UI1 || rightvt == VT_UI2 ||
5450 rightvt == VT_UI4 || rightvt == VT_I8 ||
5451 rightvt == VT_UI8 || rightvt == VT_INT ||
5452 rightvt == VT_UINT || rightvt == VT_EMPTY ||
5453 rightvt == VT_NULL || rightvt == VT_DECIMAL ||
5454 rightvt == VT_DATE))
5456 else if (rightvt == VT_ERROR && leftvt < VT_VOID)
5457 expected_error_num = DISP_E_TYPEMISMATCH;
5458 else if (leftvt == VT_ERROR && (rightvt == VT_DATE ||
5459 rightvt == VT_ERROR || rightvt == VT_DECIMAL))
5460 expected_error_num = DISP_E_TYPEMISMATCH;
5461 else if (rightvt == VT_DATE || rightvt == VT_ERROR ||
5462 rightvt == VT_DECIMAL)
5463 expected_error_num = DISP_E_BADVARTYPE;
5464 else if (leftvt == VT_ERROR || rightvt == VT_ERROR)
5465 expected_error_num = DISP_E_TYPEMISMATCH;
5466 else if (leftvt == VT_VARIANT)
5467 expected_error_num = DISP_E_TYPEMISMATCH;
5468 else if (rightvt == VT_VARIANT && (leftvt == VT_EMPTY ||
5469 leftvt == VT_NULL || leftvt == VT_I2 ||
5470 leftvt == VT_I4 || leftvt == VT_R4 ||
5471 leftvt == VT_R8 || leftvt == VT_CY ||
5472 leftvt == VT_DATE || leftvt == VT_BSTR ||
5473 leftvt == VT_BOOL || leftvt == VT_DECIMAL ||
5474 leftvt == VT_I1 || leftvt == VT_UI1 ||
5475 leftvt == VT_UI2 || leftvt == VT_UI4 ||
5476 leftvt == VT_I8 || leftvt == VT_UI8 ||
5477 leftvt == VT_INT || leftvt == VT_UINT
5479 expected_error_num = DISP_E_TYPEMISMATCH;
5481 expected_error_num = DISP_E_BADVARTYPE;
5483 V_VT(&left) = leftvt;
5484 V_VT(&right) = rightvt;
5488 V_BSTR(&left) = SysAllocString(sz_empty); break;
5490 V_DATE(&left) = 0.0; break;
5492 VarDecFromR8(0.0, &V_DECIMAL(&left)); break;
5499 V_BSTR(&right) = SysAllocString(sz_empty); break;
5501 V_DATE(&right) = 0.0; break;
5503 VarDecFromR8(0.0, &V_DECIMAL(&right)); break;
5508 hres = pVarCat(&left, &right, &result);
5510 /* Determine the error code for the vt combination */
5511 ok(hres == expected_error_num,
5512 "VarCat: %d, %d returned error, 0x%X expected 0x%X.\n",
5513 leftvt, rightvt, expected_error_num, hres);
5515 /* Check types are correct */
5516 ok(V_VT(&result) == resultvt,
5517 "VarCat: %d, %d: expected vt %d, got vt %d\n",
5518 leftvt, rightvt, resultvt, V_VT(&result));
5520 VariantClear(&left);
5521 VariantClear(&right);
5522 VariantClear(&result);
5526 /* Running single comparison tests to compare outputs */
5528 /* Test concat strings */
5529 V_VT(&left) = VT_BSTR;
5530 V_VT(&right) = VT_BSTR;
5531 V_VT(&expected) = VT_BSTR;
5532 V_BSTR(&left) = SysAllocString(sz12);
5533 V_BSTR(&right) = SysAllocString(sz34);
5534 V_BSTR(&expected) = SysAllocString(sz1234);
5535 hres = pVarCat(&left,&right,&result);
5536 ok(hres == S_OK, "VarCat failed with error 0x%08x\n", hres);
5538 ok(pVarCmp(&result,&expected,lcid,0) == VARCMP_EQ,
5539 "VarCat: VT_BSTR concat with VT_BSTR failed to return correct result\n");
5541 VariantClear(&left);
5542 VariantClear(&right);
5543 VariantClear(&result);
5545 /* Test if expression is VT_ERROR */
5546 V_VT(&left) = VT_ERROR;
5547 V_VT(&right) = VT_BSTR;
5548 V_BSTR(&right) = SysAllocString(sz1234);
5549 hres = pVarCat(&left,&right,&result);
5550 ok(hres == DISP_E_TYPEMISMATCH, "VarCat should have returned DISP_E_TYPEMISMATCH instead of 0x%08x\n", hres);
5551 ok(V_VT(&result) == VT_EMPTY,
5552 "VarCat: VT_ERROR concat with VT_BSTR should have returned VT_EMPTY\n");
5554 VariantClear(&left);
5555 VariantClear(&right);
5556 VariantClear(&result);
5558 V_VT(&left) = VT_BSTR;
5559 V_VT(&right) = VT_ERROR;
5560 V_BSTR(&left) = SysAllocString(sz1234);
5561 hres = pVarCat(&left,&right,&result);
5562 ok(hres == DISP_E_TYPEMISMATCH, "VarCat should have returned DISP_E_TYPEMISMATCH instead of 0x%08x\n", hres);
5563 ok(V_VT(&result) == VT_EMPTY,
5564 "VarCat: VT_BSTR concat with VT_ERROR should have returned VT_EMPTY\n");
5566 VariantClear(&left);
5567 VariantClear(&right);
5568 VariantClear(&result);
5569 VariantClear(&expected);
5571 /* Test combining boolean with number */
5572 V_VT(&left) = VT_INT;
5573 V_VT(&right) = VT_BOOL;
5574 V_VT(&expected) = VT_BSTR;
5576 V_BOOL(&right) = TRUE;
5577 V_BSTR(&expected) = SysAllocString(sz12_true);
5578 hres = pVarCat(&left,&right,&result);
5579 ok(hres == S_OK, "VarCat failed with error 0x%08x\n", hres);
5582 hres = pVarCmp(&result,&expected,lcid,0);
5583 ok(hres == VARCMP_EQ, "Expected VARCMP_EQ, got %08x for %s, %s\n",
5584 hres, variantstr(&result), variantstr(&expected));
5587 VariantClear(&left);
5588 VariantClear(&right);
5589 VariantClear(&result);
5590 VariantClear(&expected);
5592 V_VT(&left) = VT_INT;
5593 V_VT(&right) = VT_BOOL;
5594 V_VT(&expected) = VT_BSTR;
5596 V_BOOL(&right) = FALSE;
5597 V_BSTR(&expected) = SysAllocString(sz12_false);
5598 hres = pVarCat(&left,&right,&result);
5599 ok(hres == S_OK, "VarCat failed with error 0x%08x\n", hres);
5602 hres = pVarCmp(&result,&expected,lcid,0);
5603 ok(hres == VARCMP_EQ, "Expected VARCMP_EQ, got %08x for %s, %s\n",
5604 hres, variantstr(&result), variantstr(&expected));
5607 VariantClear(&left);
5608 VariantClear(&right);
5609 VariantClear(&result);
5610 VariantClear(&expected);
5612 /* Test when both expressions are numeric */
5613 V_VT(&left) = VT_INT;
5614 V_VT(&right) = VT_INT;
5615 V_VT(&expected) = VT_BSTR;
5618 V_BSTR(&expected) = SysAllocString(sz1234);
5619 hres = pVarCat(&left,&right,&result);
5620 ok(hres == S_OK, "VarCat failed with error 0x%08x\n", hres);
5622 ok(pVarCmp(&result,&expected,lcid,0) == VARCMP_EQ,
5623 "VarCat: NUMBER concat with NUMBER returned incorrect result\n");
5625 VariantClear(&left);
5626 VariantClear(&right);
5627 VariantClear(&result);
5629 /* Test if one expression is numeric and the other is a string */
5630 V_VT(&left) = VT_INT;
5631 V_VT(&right) = VT_BSTR;
5633 V_BSTR(&right) = SysAllocString(sz34);
5634 hres = pVarCat(&left,&right,&result);
5635 ok(hres == S_OK, "VarCat failed with error 0x%08x\n", hres);
5637 ok(pVarCmp(&result,&expected,lcid,0) == VARCMP_EQ,
5638 "VarCat: NUMBER concat with VT_BSTR, incorrect result\n");
5640 VariantClear(&left);
5641 VariantClear(&right);
5642 VariantClear(&result);
5644 V_VT(&left) = VT_BSTR;
5645 V_VT(&right) = VT_INT;
5646 V_BSTR(&left) = SysAllocString(sz12);
5648 hres = pVarCat(&left,&right,&result);
5649 ok(hres == S_OK, "VarCat failed with error 0x%08x\n", hres);
5651 ok(pVarCmp(&result,&expected,lcid,0) == VARCMP_EQ,
5652 "VarCat: VT_BSTR concat with NUMBER, incorrect result\n");
5654 VariantClear(&left);
5655 VariantClear(&right);
5656 VariantClear(&result);
5657 VariantClear(&expected);
5659 /* Test concat dates with strings */
5660 V_VT(&left) = VT_BSTR;
5661 V_VT(&right) = VT_DATE;
5662 V_VT(&expected) = VT_BSTR;
5663 V_VT(&expected_broken) = VT_BSTR;
5664 V_BSTR(&left) = SysAllocString(sz12);
5665 V_DATE(&right) = 29494.0;
5666 V_BSTR(&expected)= SysAllocString(sz12_date);
5667 V_BSTR(&expected_broken)= SysAllocString(sz12_date_broken);
5668 hres = pVarCat(&left,&right,&result);
5669 ok(hres == S_OK, "VarCat failed with error 0x%08x\n", hres);
5671 ok(pVarCmp(&result,&expected,lcid,0) == VARCMP_EQ ||
5672 broken(pVarCmp(&result,&expected_broken,lcid,0) == VARCMP_EQ), /* Some W98 and NT4 (intermittent) */
5673 "VarCat: VT_BSTR concat with VT_DATE returned incorrect result\n");
5675 VariantClear(&left);
5676 VariantClear(&right);
5677 VariantClear(&result);
5678 VariantClear(&expected);
5679 VariantClear(&expected_broken);
5681 V_VT(&left) = VT_DATE;
5682 V_VT(&right) = VT_BSTR;
5683 V_VT(&expected) = VT_BSTR;
5684 V_VT(&expected_broken) = VT_BSTR;
5685 V_DATE(&left) = 29494.0;
5686 V_BSTR(&right) = SysAllocString(sz12);
5687 V_BSTR(&expected)= SysAllocString(date_sz12);
5688 V_BSTR(&expected_broken)= SysAllocString(date_sz12_broken);
5689 hres = pVarCat(&left,&right,&result);
5690 ok(hres == S_OK, "VarCat failed with error 0x%08x\n", hres);
5692 ok(pVarCmp(&result,&expected,lcid,0) == VARCMP_EQ ||
5693 broken(pVarCmp(&result,&expected_broken,lcid,0) == VARCMP_EQ), /* Some W98 and NT4 (intermittent) */
5694 "VarCat: VT_DATE concat with VT_BSTR returned incorrect result\n");
5696 VariantClear(&left);
5697 VariantClear(&right);
5698 VariantClear(&result);
5699 VariantClear(&expected);
5700 VariantClear(&expected_broken);
5702 /* Test of both expressions are empty */
5703 V_VT(&left) = VT_BSTR;
5704 V_VT(&right) = VT_BSTR;
5705 V_VT(&expected) = VT_BSTR;
5706 V_BSTR(&left) = SysAllocString(sz_empty);
5707 V_BSTR(&right) = SysAllocString(sz_empty);
5708 V_BSTR(&expected)= SysAllocString(sz_empty);
5709 hres = pVarCat(&left,&right,&result);
5710 ok(hres == S_OK, "VarCat failed with error 0x%08x\n", hres);
5712 ok(pVarCmp(&result,&left,lcid,0) == VARCMP_EQ,
5713 "VarCat: EMPTY concat with EMPTY did not return empty VT_BSTR\n");
5715 /* Restore original date format settings */
5716 SetLocaleInfo(lcid,LOCALE_SSHORTDATE,orig_date_format);
5718 VariantClear(&left);
5719 VariantClear(&right);
5720 VariantClear(&result);
5721 VariantClear(&expected);
5723 /* Test boolean conversion */
5724 V_VT(&left) = VT_BOOL;
5725 V_BOOL(&left) = VARIANT_TRUE;
5726 V_VT(&right) = VT_BSTR;
5727 V_BSTR(&right) = SysAllocStringLen(NULL,0);
5728 hres = pVarCat(&left, &right, &result);
5729 ok(hres == S_OK, "VarCat failed: %08x\n", hres);
5730 if(!strcmp_wa(V_BSTR(&result), "True")) {
5731 V_VT(&right) = VT_BOOL;
5732 V_BOOL(&right) = 100;
5733 hres = pVarCat(&left, &right, &result);
5734 ok(hres == S_OK, "VarCat failed: %08x\n", hres);
5735 test_bstr_var(&result, "TrueTrue");
5736 VariantClear(&result);
5738 V_BOOL(&right) = VARIANT_FALSE;
5739 hres = pVarCat(&left, &right, &result);
5740 ok(hres == S_OK, "VarCat failed: %08x\n", hres);
5741 test_bstr_var(&result, "TrueFalse");
5742 VariantClear(&result);
5744 skip("Got %s as True, assuming non-English locale\n", wine_dbgstr_w(V_BSTR(&result)));
5748 static HRESULT (WINAPI *pVarAnd)(LPVARIANT,LPVARIANT,LPVARIANT);
5750 #define VARAND(vt1,val1,vt2,val2,rvt,rval) \
5751 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
5752 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
5753 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
5754 test_var_call2( __LINE__, pVarAnd, &left, &right, &exp )
5756 #define VARANDCY(vt1,val1,val2,rvt,rval) \
5757 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
5758 V_VT(&right) = VT_CY; V_CY(&right).int64 = val2; \
5759 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
5760 test_var_call2( __LINE__, pVarAnd, &left, &right, &exp )
5762 /* Skip any type that is not defined or produces an error for every case */
5763 #define SKIPTESTAND(a) \
5764 if (a == VT_ERROR || a == VT_VARIANT || \
5765 a == VT_DISPATCH || a == VT_UNKNOWN || \
5766 a > VT_UINT || a == 15 /*not defined*/) \
5769 static void test_VarAnd(void)
5771 static const WCHAR szFalse[] = { '#','F','A','L','S','E','#','\0' };
5772 static const WCHAR szTrue[] = { '#','T','R','U','E','#','\0' };
5773 VARIANT left, right, exp, result;
5774 BSTR false_str, true_str;
5778 true_str = SysAllocString(szTrue);
5779 false_str = SysAllocString(szFalse);
5783 /* Test all possible flag/vt combinations & the resulting vt type */
5784 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
5786 VARTYPE leftvt, rightvt, resvt;
5788 for (leftvt = 0; leftvt <= VT_BSTR_BLOB; leftvt++)
5790 SKIPTESTAND(leftvt);
5792 /* Check if we need/have support for I8 and/or UI8 */
5793 if ((leftvt == VT_I8 || leftvt == VT_UI8) && !HAVE_OLEAUT32_I8)
5796 for (rightvt = 0; rightvt <= VT_BSTR_BLOB; rightvt++)
5799 SKIPTESTAND(rightvt);
5801 /* Check if we need/have support for I8 and/or UI8 */
5802 if ((rightvt == VT_I8 || rightvt == VT_UI8) && !HAVE_OLEAUT32_I8)
5805 memset(&left, 0, sizeof(left));
5806 memset(&right, 0, sizeof(right));
5807 V_VT(&left) = leftvt | ExtraFlags[i];
5808 V_VT(&right) = rightvt | ExtraFlags[i];
5809 V_VT(&result) = VT_EMPTY;
5811 if ((leftvt | ExtraFlags[i]) == VT_BSTR)
5812 V_BSTR(&left) = true_str;
5813 if ((rightvt | ExtraFlags[i]) == VT_BSTR)
5814 V_BSTR(&right) = true_str;
5816 /* Native VarAnd always returns an error when using extra
5817 * flags or if the variant combination is I8 and INT.
5819 if ((leftvt == VT_I8 && rightvt == VT_INT) ||
5820 (leftvt == VT_INT && rightvt == VT_I8) ||
5824 /* Determine return type */
5825 else if (leftvt == VT_I8 || rightvt == VT_I8)
5827 else if (leftvt == VT_I4 || rightvt == VT_I4 ||
5828 leftvt == VT_UINT || rightvt == VT_UINT ||
5829 leftvt == VT_INT || rightvt == VT_INT ||
5830 leftvt == VT_UINT || rightvt == VT_UINT ||
5831 leftvt == VT_R4 || rightvt == VT_R4 ||
5832 leftvt == VT_R8 || rightvt == VT_R8 ||
5833 leftvt == VT_CY || rightvt == VT_CY ||
5834 leftvt == VT_DATE || rightvt == VT_DATE ||
5835 leftvt == VT_I1 || rightvt == VT_I1 ||
5836 leftvt == VT_UI2 || rightvt == VT_UI2 ||
5837 leftvt == VT_UI4 || rightvt == VT_UI4 ||
5838 leftvt == VT_UI8 || rightvt == VT_UI8 ||
5839 leftvt == VT_DECIMAL || rightvt == VT_DECIMAL)
5841 else if (leftvt == VT_UI1 || rightvt == VT_UI1 ||
5842 leftvt == VT_I2 || rightvt == VT_I2 ||
5843 leftvt == VT_EMPTY || rightvt == VT_EMPTY)
5844 if ((leftvt == VT_NULL && rightvt == VT_UI1) ||
5845 (leftvt == VT_UI1 && rightvt == VT_NULL) ||
5846 (leftvt == VT_UI1 && rightvt == VT_UI1))
5850 else if (leftvt == VT_BOOL || rightvt == VT_BOOL ||
5851 (leftvt == VT_BSTR && rightvt == VT_BSTR))
5853 else if (leftvt == VT_NULL || rightvt == VT_NULL ||
5854 leftvt == VT_BSTR || rightvt == VT_BSTR)
5859 hres = pVarAnd(&left, &right, &result);
5861 /* Check expected HRESULT and if result variant type is correct */
5863 ok (hres == DISP_E_BADVARTYPE || hres == DISP_E_TYPEMISMATCH,
5864 "VarAnd: %s|0x%X, %s|0x%X: got vt %s hr 0x%X\n",
5865 vtstr(leftvt), ExtraFlags[i], vtstr(rightvt), ExtraFlags[i],
5866 vtstr(V_VT(&result)), hres);
5868 ok (hres == S_OK && resvt == V_VT(&result),
5869 "VarAnd: %s|0x%X, %s|0x%X: expected vt %s hr 0x%X, got vt %s hr 0x%X\n",
5870 vtstr(leftvt), ExtraFlags[i], vtstr(rightvt), ExtraFlags[i], vtstr(resvt),
5871 S_OK, vtstr(V_VT(&result)), hres);
5877 * Test returned values. Since we know the returned type is correct
5878 * and that we handle all combinations of invalid types, just check
5879 * that good type combinations produce the desired value.
5880 * FIXME: Test VT_DECIMAL
5882 VARAND(EMPTY,0,EMPTY,0,I2,0);
5883 VARAND(EMPTY,1,EMPTY,0,I2,0);
5884 VARAND(EMPTY,1,EMPTY,1,I2,0);
5885 VARAND(EMPTY,0,NULL,0,I2,0);
5886 VARAND(EMPTY,1,NULL,0,I2,0);
5887 VARAND(EMPTY,1,NULL,1,I2,0);
5888 VARAND(EMPTY,0,I1,0,I4,0);
5889 VARAND(EMPTY,0,I1,1,I4,0);
5890 VARAND(EMPTY,1,I1,1,I4,0);
5891 VARAND(EMPTY,0,UI1,0,I2,0);
5892 VARAND(EMPTY,0,UI1,1,I2,0);
5893 VARAND(EMPTY,1,UI1,1,I2,0);
5894 VARAND(EMPTY,0,I2,0,I2,0);
5895 VARAND(EMPTY,0,I2,1,I2,0);
5896 VARAND(EMPTY,1,I2,1,I2,0);
5897 VARAND(EMPTY,0,UI2,0,I4,0);
5898 VARAND(EMPTY,0,UI2,1,I4,0);
5899 VARAND(EMPTY,1,UI2,1,I4,0);
5900 VARAND(EMPTY,0,I4,0,I4,0);
5901 VARAND(EMPTY,0,I4,1,I4,0);
5902 VARAND(EMPTY,1,I4,1,I4,0);
5903 VARAND(EMPTY,0,UI4,0,I4,0);
5904 VARAND(EMPTY,0,UI4,1,I4,0);
5905 VARAND(EMPTY,1,UI4,1,I4,0);
5906 if (HAVE_OLEAUT32_I8)
5908 VARAND(EMPTY,0,I8,0,I8,0);
5909 VARAND(EMPTY,0,I8,1,I8,0);
5910 VARAND(EMPTY,1,I8,1,I8,0);
5911 VARAND(EMPTY,0,UI8,0,I4,0);
5912 VARAND(EMPTY,0,UI8,1,I4,0);
5913 VARAND(EMPTY,1,UI8,1,I4,0);
5915 VARAND(EMPTY,0,INT,0,I4,0);
5916 VARAND(EMPTY,0,INT,1,I4,0);
5917 VARAND(EMPTY,1,INT,1,I4,0);
5918 VARAND(EMPTY,0,UINT,0,I4,0);
5919 VARAND(EMPTY,0,UINT,1,I4,0);
5920 VARAND(EMPTY,1,UINT,1,I4,0);
5921 VARAND(EMPTY,0,BOOL,0,I2,0);
5922 VARAND(EMPTY,0,BOOL,1,I2,0);
5923 VARAND(EMPTY,1,BOOL,1,I2,0);
5924 VARAND(EMPTY,0,R4,0,I4,0);
5925 VARAND(EMPTY,0,R4,1,I4,0);
5926 VARAND(EMPTY,1,R4,1,I4,0);
5927 VARAND(EMPTY,0,R8,0,I4,0);
5928 VARAND(EMPTY,0,R8,1,I4,0);
5929 VARAND(EMPTY,1,R8,1,I4,0);
5930 VARAND(EMPTY,0,BSTR,false_str,I2,0);
5931 VARAND(EMPTY,0,BSTR,true_str,I2,0);
5932 VARANDCY(EMPTY,0,10000,I4,0);
5934 /* NULL OR 0 = NULL. NULL OR n = n */
5935 VARAND(NULL,0,NULL,0,NULL,0);
5936 VARAND(NULL,1,NULL,0,NULL,0);
5937 VARAND(NULL,0,I1,0,I4,0);
5938 VARAND(NULL,0,I1,1,NULL,0);
5939 VARAND(NULL,0,UI1,0,UI1,0);
5940 VARAND(NULL,0,UI1,1,NULL,0);
5941 VARAND(NULL,0,I2,0,I2,0);
5942 VARAND(NULL,0,I2,1,NULL,0);
5943 VARAND(NULL,0,UI2,0,I4,0);
5944 VARAND(NULL,0,UI2,1,NULL,0);
5945 VARAND(NULL,0,I4,0,I4,0);
5946 VARAND(NULL,0,I4,1,NULL,0);
5947 VARAND(NULL,0,UI4,0,I4,0);
5948 VARAND(NULL,0,UI4,1,NULL,0);
5949 if (HAVE_OLEAUT32_I8)
5951 VARAND(NULL,0,I8,0,I8,0);
5952 VARAND(NULL,0,I8,1,NULL,0);
5953 VARAND(NULL,0,UI8,0,I4,0);
5954 VARAND(NULL,0,UI8,1,NULL,0);
5956 VARAND(NULL,0,INT,0,I4,0);
5957 VARAND(NULL,0,INT,1,NULL,0);
5958 VARAND(NULL,0,UINT,0,I4,0);
5959 VARAND(NULL,0,UINT,1,NULL,0);
5960 VARAND(NULL,0,BOOL,0,BOOL,0);
5961 VARAND(NULL,0,BOOL,1,NULL,0);
5962 VARAND(NULL,0,R4,0,I4,0);
5963 VARAND(NULL,0,R4,1,NULL,0);
5964 VARAND(NULL,0,R8,0,I4,0);
5965 VARAND(NULL,0,R8,1,NULL,0);
5966 VARAND(NULL,0,BSTR,false_str,BOOL,0);
5967 VARAND(NULL,0,BSTR,true_str,NULL,VARIANT_FALSE);
5968 VARANDCY(NULL,0,10000,NULL,0);
5969 VARANDCY(NULL,0,0,I4,0);
5970 VARAND(BOOL,VARIANT_TRUE,BOOL,VARIANT_TRUE,BOOL,VARIANT_TRUE);
5971 VARAND(BOOL,VARIANT_TRUE,BOOL,VARIANT_FALSE,BOOL,VARIANT_FALSE);
5972 VARAND(BOOL,VARIANT_FALSE,BOOL,VARIANT_TRUE,BOOL,VARIANT_FALSE);
5973 VARAND(BOOL,VARIANT_FALSE,BOOL,VARIANT_FALSE,BOOL,VARIANT_FALSE);
5975 /* Assume x,y & y,x are the same from now on to reduce the number of tests */
5976 VARAND(BOOL,VARIANT_TRUE,I1,-1,I4,-1);
5977 VARAND(BOOL,VARIANT_TRUE,I1,0,I4,0);
5978 VARAND(BOOL,VARIANT_FALSE,I1,0,I4,0);
5979 VARAND(BOOL,VARIANT_TRUE,UI1,255,I2,255);
5980 VARAND(BOOL,VARIANT_TRUE,UI1,0,I2,0);
5981 VARAND(BOOL,VARIANT_FALSE,UI1,0,I2,0);
5982 VARAND(BOOL,VARIANT_TRUE,I2,-1,I2,-1);
5983 VARAND(BOOL,VARIANT_TRUE,I2,0,I2,0);
5984 VARAND(BOOL,VARIANT_FALSE,I2,0,I2,0);
5985 VARAND(BOOL,VARIANT_TRUE,UI2,65535,I4,65535);
5986 VARAND(BOOL,VARIANT_TRUE,UI2,0,I4,0);
5987 VARAND(BOOL,VARIANT_FALSE,UI2,0,I4,0);
5988 VARAND(BOOL,VARIANT_TRUE,I4,-1,I4,-1);
5989 VARAND(BOOL,VARIANT_TRUE,I4,0,I4,0);
5990 VARAND(BOOL,VARIANT_FALSE,I4,0,I4,0);
5991 VARAND(BOOL,VARIANT_TRUE,UI4,0xffffffff,I4,-1);
5992 VARAND(BOOL,VARIANT_TRUE,UI4,0,I4,0);
5993 VARAND(BOOL,VARIANT_FALSE,UI4,0,I4,0);
5994 VARAND(BOOL,VARIANT_TRUE,R4,-1,I4,-1);
5995 VARAND(BOOL,VARIANT_TRUE,R4,0,I4,0);
5996 VARAND(BOOL,VARIANT_FALSE,R4,0,I4,0);
5997 VARAND(BOOL,VARIANT_TRUE,R8,-1,I4,-1);
5998 VARAND(BOOL,VARIANT_TRUE,R8,0,I4,0);
5999 VARAND(BOOL,VARIANT_FALSE,R8,0,I4,0);
6000 VARAND(BOOL,VARIANT_TRUE,DATE,-1,I4,-1);
6001 VARAND(BOOL,VARIANT_TRUE,DATE,0,I4,0);
6002 VARAND(BOOL,VARIANT_FALSE,DATE,0,I4,0);
6003 if (HAVE_OLEAUT32_I8)
6005 VARAND(BOOL,VARIANT_TRUE,I8,-1,I8,-1);
6006 VARAND(BOOL,VARIANT_TRUE,I8,0,I8,0);
6007 VARAND(BOOL,VARIANT_FALSE,I8,0,I8,0);
6008 VARAND(BOOL,VARIANT_TRUE,UI8,0,I4,0);
6009 VARAND(BOOL,VARIANT_FALSE,UI8,0,I4,0);
6011 VARAND(BOOL,VARIANT_TRUE,INT,-1,I4,-1);
6012 VARAND(BOOL,VARIANT_TRUE,INT,0,I4,0);
6013 VARAND(BOOL,VARIANT_FALSE,INT,0,I4,0);
6014 VARAND(BOOL,VARIANT_TRUE,UINT,0xffffffff,I4,-1);
6015 VARAND(BOOL,VARIANT_TRUE,UINT,0,I4,0);
6016 VARAND(BOOL,VARIANT_FALSE,UINT,0,I4,0);
6017 VARAND(BOOL,VARIANT_FALSE,BSTR,false_str,BOOL,VARIANT_FALSE);
6018 VARAND(BOOL,VARIANT_TRUE,BSTR,false_str,BOOL,VARIANT_FALSE);
6019 VARAND(BOOL,VARIANT_FALSE,BSTR,true_str,BOOL,VARIANT_FALSE);
6020 VARAND(BOOL,VARIANT_TRUE,BSTR,true_str,BOOL,VARIANT_TRUE);
6021 VARANDCY(BOOL,VARIANT_TRUE,10000,I4,1);
6022 VARANDCY(BOOL,VARIANT_TRUE,0,I4,0);
6023 VARANDCY(BOOL,VARIANT_FALSE,0,I4,0);
6024 VARAND(I1,-1,I1,-1,I4,-1);
6025 VARAND(I1,-1,I1,0,I4,0);
6026 VARAND(I1,0,I1,0,I4,0);
6027 VARAND(I1,-1,UI1,255,I4,255);
6028 VARAND(I1,-1,UI1,0,I4,0);
6029 VARAND(I1,0,UI1,0,I4,0);
6030 VARAND(I1,-1,I2,-1,I4,-1);
6031 VARAND(I1,-1,I2,0,I4,0);
6032 VARAND(I1,0,I2,0,I4,0);
6033 VARAND(I1,-1,UI2,65535,I4,65535);
6034 VARAND(I1,-1,UI2,0,I4,0);
6035 VARAND(I1,0,UI2,0,I4,0);
6036 VARAND(I1,-1,I4,-1,I4,-1);
6037 VARAND(I1,-1,I4,0,I4,0);
6038 VARAND(I1,0,I4,0,I4,0);
6039 VARAND(I1,-1,UI4,0xffffffff,I4,-1);
6040 VARAND(I1,-1,UI4,0,I4,0);
6041 VARAND(I1,0,UI4,0,I4,0);
6042 VARAND(I1,-1,R4,-1,I4,-1);
6043 VARAND(I1,-1,R4,0,I4,0);
6044 VARAND(I1,0,R4,0,I4,0);
6045 VARAND(I1,-1,R8,-1,I4,-1);
6046 VARAND(I1,-1,R8,0,I4,0);
6047 VARAND(I1,0,R8,0,I4,0);
6048 VARAND(I1,-1,DATE,-1,I4,-1);
6049 VARAND(I1,-1,DATE,0,I4,0);
6050 VARAND(I1,0,DATE,0,I4,0);
6051 if (HAVE_OLEAUT32_I8)
6053 VARAND(I1,-1,I8,-1,I8,-1);
6054 VARAND(I1,-1,I8,0,I8,0);
6055 VARAND(I1,0,I8,0,I8,0);
6056 VARAND(I1,-1,UI8,0,I4,0);
6057 VARAND(I1,0,UI8,0,I4,0);
6059 VARAND(I1,-1,INT,-1,I4,-1);
6060 VARAND(I1,-1,INT,0,I4,0);
6061 VARAND(I1,0,INT,0,I4,0);
6062 VARAND(I1,-1,UINT,0xffffffff,I4,-1);
6063 VARAND(I1,-1,UINT,0,I4,0);
6064 VARAND(I1,0,UINT,0,I4,0);
6065 VARAND(I1,0,BSTR,false_str,I4,0);
6066 VARAND(I1,-1,BSTR,false_str,I4,0);
6067 VARAND(I1,0,BSTR,true_str,I4,0);
6068 VARAND(I1,-1,BSTR,true_str,I4,-1);
6069 VARANDCY(I1,-1,10000,I4,1);
6070 VARANDCY(I1,-1,0,I4,0);
6071 VARANDCY(I1,0,0,I4,0);
6073 VARAND(UI1,255,UI1,255,UI1,255);
6074 VARAND(UI1,255,UI1,0,UI1,0);
6075 VARAND(UI1,0,UI1,0,UI1,0);
6076 VARAND(UI1,255,I2,-1,I2,255);
6077 VARAND(UI1,255,I2,0,I2,0);
6078 VARAND(UI1,0,I2,0,I2,0);
6079 VARAND(UI1,255,UI2,65535,I4,255);
6080 VARAND(UI1,255,UI2,0,I4,0);
6081 VARAND(UI1,0,UI2,0,I4,0);
6082 VARAND(UI1,255,I4,-1,I4,255);
6083 VARAND(UI1,255,I4,0,I4,0);
6084 VARAND(UI1,0,I4,0,I4,0);
6085 VARAND(UI1,255,UI4,0xffffffff,I4,255);
6086 VARAND(UI1,255,UI4,0,I4,0);
6087 VARAND(UI1,0,UI4,0,I4,0);
6088 VARAND(UI1,255,R4,-1,I4,255);
6089 VARAND(UI1,255,R4,0,I4,0);
6090 VARAND(UI1,0,R4,0,I4,0);
6091 VARAND(UI1,255,R8,-1,I4,255);
6092 VARAND(UI1,255,R8,0,I4,0);
6093 VARAND(UI1,0,R8,0,I4,0);
6094 VARAND(UI1,255,DATE,-1,I4,255);
6095 VARAND(UI1,255,DATE,0,I4,0);
6096 VARAND(UI1,0,DATE,0,I4,0);
6097 if (HAVE_OLEAUT32_I8)
6099 VARAND(UI1,255,I8,-1,I8,255);
6100 VARAND(UI1,255,I8,0,I8,0);
6101 VARAND(UI1,0,I8,0,I8,0);
6102 VARAND(UI1,255,UI8,0,I4,0);
6103 VARAND(UI1,0,UI8,0,I4,0);
6105 VARAND(UI1,255,INT,-1,I4,255);
6106 VARAND(UI1,255,INT,0,I4,0);
6107 VARAND(UI1,0,INT,0,I4,0);
6108 VARAND(UI1,255,UINT,0xffffffff,I4,255);
6109 VARAND(UI1,255,UINT,0,I4,0);
6110 VARAND(UI1,0,UINT,0,I4,0);
6111 VARAND(UI1,0,BSTR,false_str,I2,0);
6112 VARAND(UI1,255,BSTR,false_str,I2,0);
6113 VARAND(UI1,0,BSTR,true_str,I2,0);
6114 VARAND(UI1,255,BSTR,true_str,I2,255);
6115 VARANDCY(UI1,255,10000,I4,1);
6116 VARANDCY(UI1,255,0,I4,0);
6117 VARANDCY(UI1,0,0,I4,0);
6119 VARAND(I2,-1,I2,-1,I2,-1);
6120 VARAND(I2,-1,I2,0,I2,0);
6121 VARAND(I2,0,I2,0,I2,0);
6122 VARAND(I2,-1,UI2,65535,I4,65535);
6123 VARAND(I2,-1,UI2,0,I4,0);
6124 VARAND(I2,0,UI2,0,I4,0);
6125 VARAND(I2,-1,I4,-1,I4,-1);
6126 VARAND(I2,-1,I4,0,I4,0);
6127 VARAND(I2,0,I4,0,I4,0);
6128 VARAND(I2,-1,UI4,0xffffffff,I4,-1);
6129 VARAND(I2,-1,UI4,0,I4,0);
6130 VARAND(I2,0,UI4,0,I4,0);
6131 VARAND(I2,-1,R4,-1,I4,-1);
6132 VARAND(I2,-1,R4,0,I4,0);
6133 VARAND(I2,0,R4,0,I4,0);
6134 VARAND(I2,-1,R8,-1,I4,-1);
6135 VARAND(I2,-1,R8,0,I4,0);
6136 VARAND(I2,0,R8,0,I4,0);
6137 VARAND(I2,-1,DATE,-1,I4,-1);
6138 VARAND(I2,-1,DATE,0,I4,0);
6139 VARAND(I2,0,DATE,0,I4,0);
6140 if (HAVE_OLEAUT32_I8)
6142 VARAND(I2,-1,I8,-1,I8,-1);
6143 VARAND(I2,-1,I8,0,I8,0);
6144 VARAND(I2,0,I8,0,I8,0);
6145 VARAND(I2,-1,UI8,0,I4,0);
6146 VARAND(I2,0,UI8,0,I4,0);
6148 VARAND(I2,-1,INT,-1,I4,-1);
6149 VARAND(I2,-1,INT,0,I4,0);
6150 VARAND(I2,0,INT,0,I4,0);
6151 VARAND(I2,-1,UINT,0xffffffff,I4,-1);
6152 VARAND(I2,-1,UINT,0,I4,0);
6153 VARAND(I2,0,UINT,0,I4,0);
6154 VARAND(I2,0,BSTR,false_str,I2,0);
6155 VARAND(I2,-1,BSTR,false_str,I2,0);
6156 VARAND(I2,0,BSTR,true_str,I2,0);
6157 VARAND(I2,-1,BSTR,true_str,I2,-1);
6158 VARANDCY(I2,-1,10000,I4,1);
6159 VARANDCY(I2,-1,0,I4,0);
6160 VARANDCY(I2,0,0,I4,0);
6162 VARAND(UI2,65535,UI2,65535,I4,65535);
6163 VARAND(UI2,65535,UI2,0,I4,0);
6164 VARAND(UI2,0,UI2,0,I4,0);
6165 VARAND(UI2,65535,I4,-1,I4,65535);
6166 VARAND(UI2,65535,I4,0,I4,0);
6167 VARAND(UI2,0,I4,0,I4,0);
6168 VARAND(UI2,65535,UI4,0xffffffff,I4,65535);
6169 VARAND(UI2,65535,UI4,0,I4,0);
6170 VARAND(UI2,0,UI4,0,I4,0);
6171 VARAND(UI2,65535,R4,-1,I4,65535);
6172 VARAND(UI2,65535,R4,0,I4,0);
6173 VARAND(UI2,0,R4,0,I4,0);
6174 VARAND(UI2,65535,R8,-1,I4,65535);
6175 VARAND(UI2,65535,R8,0,I4,0);
6176 VARAND(UI2,0,R8,0,I4,0);
6177 VARAND(UI2,65535,DATE,-1,I4,65535);
6178 VARAND(UI2,65535,DATE,0,I4,0);
6179 VARAND(UI2,0,DATE,0,I4,0);
6180 if (HAVE_OLEAUT32_I8)
6182 VARAND(UI2,65535,I8,-1,I8,65535);
6183 VARAND(UI2,65535,I8,0,I8,0);
6184 VARAND(UI2,0,I8,0,I8,0);
6185 VARAND(UI2,65535,UI8,0,I4,0);
6186 VARAND(UI2,0,UI8,0,I4,0);
6188 VARAND(UI2,65535,INT,-1,I4,65535);
6189 VARAND(UI2,65535,INT,0,I4,0);
6190 VARAND(UI2,0,INT,0,I4,0);
6191 VARAND(UI2,65535,UINT,0xffffffff,I4,65535);
6192 VARAND(UI2,65535,UINT,0,I4,0);
6193 VARAND(UI2,0,UINT,0,I4,0);
6194 VARAND(UI2,0,BSTR,false_str,I4,0);
6195 VARAND(UI2,65535,BSTR,false_str,I4,0);
6196 VARAND(UI2,0,BSTR,true_str,I4,0);
6197 VARAND(UI2,65535,BSTR,true_str,I4,65535);
6198 VARANDCY(UI2,65535,10000,I4,1);
6199 VARANDCY(UI2,65535,0,I4,0);
6200 VARANDCY(UI2,0,0,I4,0);
6202 VARAND(I4,-1,I4,-1,I4,-1);
6203 VARAND(I4,-1,I4,0,I4,0);
6204 VARAND(I4,0,I4,0,I4,0);
6205 VARAND(I4,-1,UI4,0xffffffff,I4,-1);
6206 VARAND(I4,-1,UI4,0,I4,0);
6207 VARAND(I4,0,UI4,0,I4,0);
6208 VARAND(I4,-1,R4,-1,I4,-1);
6209 VARAND(I4,-1,R4,0,I4,0);
6210 VARAND(I4,0,R4,0,I4,0);
6211 VARAND(I4,-1,R8,-1,I4,-1);
6212 VARAND(I4,-1,R8,0,I4,0);
6213 VARAND(I4,0,R8,0,I4,0);
6214 VARAND(I4,-1,DATE,-1,I4,-1);
6215 VARAND(I4,-1,DATE,0,I4,0);
6216 VARAND(I4,0,DATE,0,I4,0);
6217 if (HAVE_OLEAUT32_I8)
6219 VARAND(I4,-1,I8,-1,I8,-1);
6220 VARAND(I4,-1,I8,0,I8,0);
6221 VARAND(I4,0,I8,0,I8,0);
6222 VARAND(I4,-1,UI8,0,I4,0);
6223 VARAND(I4,0,UI8,0,I4,0);
6225 VARAND(I4,-1,INT,-1,I4,-1);
6226 VARAND(I4,-1,INT,0,I4,0);
6227 VARAND(I4,0,INT,0,I4,0);
6228 VARAND(I4,-1,UINT,0xffffffff,I4,-1);
6229 VARAND(I4,-1,UINT,0,I4,0);
6230 VARAND(I4,0,UINT,0,I4,0);
6231 VARAND(I4,0,BSTR,false_str,I4,0);
6232 VARAND(I4,-1,BSTR,false_str,I4,0);
6233 VARAND(I4,0,BSTR,true_str,I4,0);
6234 VARAND(I4,-1,BSTR,true_str,I4,-1);
6235 VARANDCY(I4,-1,10000,I4,1);
6236 VARANDCY(I4,-1,0,I4,0);
6237 VARANDCY(I4,0,0,I4,0);
6239 VARAND(UI4,0xffffffff,UI4,0xffffffff,I4,-1);
6240 VARAND(UI4,0xffffffff,UI4,0,I4,0);
6241 VARAND(UI4,0,UI4,0,I4,0);
6242 VARAND(UI4,0xffffffff,R4,-1,I4,-1);
6243 VARAND(UI4,0xffffffff,R4,0,I4,0);
6244 VARAND(UI4,0,R4,0,I4,0);
6245 VARAND(UI4,0xffffffff,R8,-1,I4,-1);
6246 VARAND(UI4,0xffffffff,R8,0,I4,0);
6247 VARAND(UI4,0,R8,0,I4,0);
6248 VARAND(UI4,0xffffffff,DATE,-1,I4,-1);
6249 VARAND(UI4,0xffffffff,DATE,0,I4,0);
6250 VARAND(UI4,0,DATE,0,I4,0);
6251 if (HAVE_OLEAUT32_I8)
6253 VARAND(UI4,0xffffffff,I8,0,I8,0);
6254 VARAND(UI4,0,I8,0,I8,0);
6255 VARAND(UI4,0xffffffff,UI8,0,I4,0);
6256 VARAND(UI4,0,UI8,0,I4,0);
6258 VARAND(UI4,0xffffffff,INT,-1,I4,-1);
6259 VARAND(UI4,0xffffffff,INT,0,I4,0);
6260 VARAND(UI4,0,INT,0,I4,0);
6261 VARAND(UI4,0xffffffff,UINT,0xffffffff,I4,-1);
6262 VARAND(UI4,0xffffffff,UINT,0,I4,0);
6263 VARAND(UI4,0,UINT,0,I4,0);
6264 VARAND(UI4,0,BSTR,false_str,I4,0);
6265 VARAND(UI4,0xffffffff,BSTR,false_str,I4,0);
6266 VARAND(UI4,0,BSTR,true_str,I4,0);
6267 VARAND(UI4,0xffffffff,BSTR,true_str,I4,-1);
6268 VARANDCY(UI4,0xffffffff,10000,I4,1);
6269 VARANDCY(UI4,0xffffffff,0,I4,0);
6270 VARANDCY(UI4,0,0,I4,0);
6272 VARAND(R4,-1,R4,-1,I4,-1);
6273 VARAND(R4,-1,R4,0,I4,0);
6274 VARAND(R4,0,R4,0,I4,0);
6275 VARAND(R4,-1,R8,-1,I4,-1);
6276 VARAND(R4,-1,R8,0,I4,0);
6277 VARAND(R4,0,R8,0,I4,0);
6278 VARAND(R4,-1,DATE,-1,I4,-1);
6279 VARAND(R4,-1,DATE,0,I4,0);
6280 VARAND(R4,0,DATE,0,I4,0);
6281 if (HAVE_OLEAUT32_I8)
6283 VARAND(R4,-1,I8,-1,I8,-1);
6284 VARAND(R4,-1,I8,0,I8,0);
6285 VARAND(R4,0,I8,0,I8,0);
6286 VARAND(R4,-1,UI8,0,I4,0);
6287 VARAND(R4,0,UI8,0,I4,0);
6289 VARAND(R4,-1,INT,-1,I4,-1);
6290 VARAND(R4,-1,INT,0,I4,0);
6291 VARAND(R4,0,INT,0,I4,0);
6292 VARAND(R4,-1,UINT,0xffffffff,I4,-1);
6293 VARAND(R4,-1,UINT,0,I4,0);
6294 VARAND(R4,0,UINT,0,I4,0);
6295 VARAND(R4,0,BSTR,false_str,I4,0);
6296 VARAND(R4,-1,BSTR,false_str,I4,0);
6297 VARAND(R4,0,BSTR,true_str,I4,0);
6298 VARAND(R4,-1,BSTR,true_str,I4,-1);
6299 VARANDCY(R4,-1,10000,I4,1);
6300 VARANDCY(R4,-1,0,I4,0);
6301 VARANDCY(R4,0,0,I4,0);
6303 VARAND(R8,-1,R8,-1,I4,-1);
6304 VARAND(R8,-1,R8,0,I4,0);
6305 VARAND(R8,0,R8,0,I4,0);
6306 VARAND(R8,-1,DATE,-1,I4,-1);
6307 VARAND(R8,-1,DATE,0,I4,0);
6308 VARAND(R8,0,DATE,0,I4,0);
6309 if (HAVE_OLEAUT32_I8)
6311 VARAND(R8,-1,I8,-1,I8,-1);
6312 VARAND(R8,-1,I8,0,I8,0);
6313 VARAND(R8,0,I8,0,I8,0);
6314 VARAND(R8,-1,UI8,0,I4,0);
6315 VARAND(R8,0,UI8,0,I4,0);
6317 VARAND(R8,-1,INT,-1,I4,-1);
6318 VARAND(R8,-1,INT,0,I4,0);
6319 VARAND(R8,0,INT,0,I4,0);
6320 VARAND(R8,-1,UINT,0xffffffff,I4,-1);
6321 VARAND(R8,-1,UINT,0,I4,0);
6322 VARAND(R8,0,UINT,0,I4,0);
6323 VARAND(R8,0,BSTR,false_str,I4,0);
6324 VARAND(R8,-1,BSTR,false_str,I4,0);
6325 VARAND(R8,0,BSTR,true_str,I4,0);
6326 VARAND(R8,-1,BSTR,true_str,I4,-1);
6327 VARANDCY(R8,-1,10000,I4,1);
6328 VARANDCY(R8,-1,0,I4,0);
6329 VARANDCY(R8,0,0,I4,0);
6331 VARAND(DATE,-1,DATE,-1,I4,-1);
6332 VARAND(DATE,-1,DATE,0,I4,0);
6333 VARAND(DATE,0,DATE,0,I4,0);
6334 if (HAVE_OLEAUT32_I8)
6336 VARAND(DATE,-1,I8,-1,I8,-1);
6337 VARAND(DATE,-1,I8,0,I8,0);
6338 VARAND(DATE,0,I8,0,I8,0);
6339 VARAND(DATE,-1,UI8,0,I4,0);
6340 VARAND(DATE,0,UI8,0,I4,0);
6342 VARAND(DATE,-1,INT,-1,I4,-1);
6343 VARAND(DATE,-1,INT,0,I4,0);
6344 VARAND(DATE,0,INT,0,I4,0);
6345 VARAND(DATE,-1,UINT,0xffffffff,I4,-1);
6346 VARAND(DATE,-1,UINT,0,I4,0);
6347 VARAND(DATE,0,UINT,0,I4,0);
6348 VARAND(DATE,0,BSTR,false_str,I4,0);
6349 VARAND(DATE,-1,BSTR,false_str,I4,0);
6350 VARAND(DATE,0,BSTR,true_str,I4,0);
6351 VARAND(DATE,-1,BSTR,true_str,I4,-1);
6352 VARANDCY(DATE,-1,10000,I4,1);
6353 VARANDCY(DATE,-1,0,I4,0);
6354 VARANDCY(DATE,0,0,I4,0);
6356 if (HAVE_OLEAUT32_I8)
6358 VARAND(I8,-1,I8,-1,I8,-1);
6359 VARAND(I8,-1,I8,0,I8,0);
6360 VARAND(I8,0,I8,0,I8,0);
6361 VARAND(I8,-1,UI8,0,I8,0);
6362 VARAND(I8,0,UI8,0,I8,0);
6363 VARAND(I8,-1,UINT,0,I8,0);
6364 VARAND(I8,0,UINT,0,I8,0);
6365 VARAND(I8,0,BSTR,false_str,I8,0);
6366 VARAND(I8,-1,BSTR,false_str,I8,0);
6367 VARAND(I8,0,BSTR,true_str,I8,0);
6368 VARAND(I8,-1,BSTR,true_str,I8,-1);
6369 VARANDCY(I8,-1,10000,I8,1);
6370 VARANDCY(I8,-1,0,I8,0);
6371 VARANDCY(I8,0,0,I8,0);
6373 VARAND(UI8,0xffff,UI8,0xffff,I4,0xffff);
6374 VARAND(UI8,0xffff,UI8,0,I4,0);
6375 VARAND(UI8,0,UI8,0,I4,0);
6376 VARAND(UI8,0xffff,INT,-1,I4,65535);
6377 VARAND(UI8,0xffff,INT,0,I4,0);
6378 VARAND(UI8,0,INT,0,I4,0);
6379 VARAND(UI8,0xffff,UINT,0xffff,I4,0xffff);
6380 VARAND(UI8,0xffff,UINT,0,I4,0);
6381 VARAND(UI8,0,UINT,0,I4,0);
6382 VARAND(UI8,0,BSTR,false_str,I4,0);
6383 VARAND(UI8,0xffff,BSTR,false_str,I4,0);
6384 VARAND(UI8,0,BSTR,true_str,I4,0);
6385 VARAND(UI8,0xffff,BSTR,true_str,I4,65535);
6386 VARANDCY(UI8,0xffff,10000,I4,1);
6387 VARANDCY(UI8,0xffff,0,I4,0);
6388 VARANDCY(UI8,0,0,I4,0);
6391 VARAND(INT,-1,INT,-1,I4,-1);
6392 VARAND(INT,-1,INT,0,I4,0);
6393 VARAND(INT,0,INT,0,I4,0);
6394 VARAND(INT,-1,UINT,0xffff,I4,65535);
6395 VARAND(INT,-1,UINT,0,I4,0);
6396 VARAND(INT,0,UINT,0,I4,0);
6397 VARAND(INT,0,BSTR,false_str,I4,0);
6398 VARAND(INT,-1,BSTR,false_str,I4,0);
6399 VARAND(INT,0,BSTR,true_str,I4,0);
6400 VARAND(INT,-1,BSTR,true_str,I4,-1);
6401 VARANDCY(INT,-1,10000,I4,1);
6402 VARANDCY(INT,-1,0,I4,0);
6403 VARANDCY(INT,0,0,I4,0);
6405 VARAND(UINT,0xffff,UINT,0xffff,I4,0xffff);
6406 VARAND(UINT,0xffff,UINT,0,I4,0);
6407 VARAND(UINT,0,UINT,0,I4,0);
6408 VARAND(UINT,0,BSTR,false_str,I4,0);
6409 VARAND(UINT,0xffff,BSTR, false_str,I4,0);
6410 VARAND(UINT,0,BSTR,true_str,I4,0);
6411 VARAND(UINT,0xffff,BSTR,true_str,I4,65535);
6412 VARANDCY(UINT,0xffff,10000,I4,1);
6413 VARANDCY(UINT,0xffff,0,I4,0);
6414 VARANDCY(UINT,0,0,I4,0);
6416 VARAND(BSTR,false_str,BSTR,false_str,BOOL,0);
6417 VARAND(BSTR,true_str,BSTR,false_str,BOOL,VARIANT_FALSE);
6418 VARAND(BSTR,true_str,BSTR,true_str,BOOL,VARIANT_TRUE);
6419 VARANDCY(BSTR,true_str,10000,I4,1);
6420 VARANDCY(BSTR,false_str,10000,I4,0);
6422 SysFreeString(true_str);
6423 SysFreeString(false_str);
6426 static void test_cmp( int line, LCID lcid, UINT flags, VARIANT *left, VARIANT *right, HRESULT result )
6432 hres = pVarCmp(left,right,lcid,flags);
6433 ok_(__FILE__,line)(hres == result, "VarCmp(%s,%s): expected 0x%x, got hres=0x%x\n",
6434 variantstr(left), variantstr(right), result, hres );
6436 static void test_cmpex( int line, LCID lcid, VARIANT *left, VARIANT *right,
6437 HRESULT res1, HRESULT res2, HRESULT res3, HRESULT res4 )
6439 test_cmp( line, lcid, 0, left, right, res1 );
6440 V_VT(left) |= VT_RESERVED;
6441 test_cmp( line, lcid, 0, left, right, res2 );
6442 V_VT(left) &= ~VT_RESERVED;
6443 V_VT(right) |= VT_RESERVED;
6444 test_cmp( line, lcid, 0, left, right, res3 );
6445 V_VT(left) |= VT_RESERVED;
6446 test_cmp( line, lcid, 0, left, right, res4 );
6447 ok_(__FILE__,line)(V_VT(left) & V_VT(right) & VT_RESERVED, "VT_RESERVED filtered out\n");
6450 /* ERROR from wingdi.h is interfering here */
6452 #define _VARCMP(vt1,val1,vtfl1,vt2,val2,vtfl2,lcid,flags,result) \
6453 V_##vt1(&left) = val1; V_VT(&left) = VT_##vt1 | vtfl1; \
6454 V_##vt2(&right) = val2; V_VT(&right) = VT_##vt2 | vtfl2; \
6455 test_cmp( __LINE__, lcid, flags, &left, &right, result )
6456 #define VARCMPEX(vt1,val1,vt2,val2,res1,res2,res3,res4) \
6457 V_##vt1(&left) = val1; V_VT(&left) = VT_##vt1; \
6458 V_##vt2(&right) = val2; V_VT(&right) = VT_##vt2; \
6459 test_cmpex( __LINE__, lcid, &left, &right, res1, res2, res3, res4 )
6460 #define VARCMP(vt1,val1,vt2,val2,result) \
6461 VARCMPEX(vt1,val1,vt2,val2,result,result,result,result)
6462 /* The above macros do not work for VT_NULL as NULL gets expanded first */
6463 #define V_NULL_ V_NULL
6464 #define VT_NULL_ VT_NULL
6466 static void test_VarCmp(void)
6468 VARIANT left, right;
6473 static const WCHAR szhuh[] = {'h','u','h','?','\0'};
6474 static const WCHAR sz2cents[] = {'2','c','e','n','t','s','\0'};
6475 static const WCHAR szempty[] = {'\0'};
6476 static const WCHAR sz0[] = {'0','\0'};
6477 static const WCHAR sz1[] = {'1','\0'};
6478 static const WCHAR sz7[] = {'7','\0'};
6479 static const WCHAR sz42[] = {'4','2','\0'};
6480 static const WCHAR sz1neg[] = {'-','1','\0'};
6481 static const WCHAR sz666neg[] = {'-','6','6','6','\0'};
6482 static const WCHAR sz1few[] = {'1','.','0','0','0','0','0','0','0','1','\0'};
6483 BSTR bstrhuh, bstrempty, bstr0, bstr1, bstr7, bstr42, bstr1neg, bstr666neg;
6484 BSTR bstr2cents, bstr1few;
6488 lcid = MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT);
6489 bstrempty = SysAllocString(szempty);
6490 bstrhuh = SysAllocString(szhuh);
6491 bstr2cents = SysAllocString(sz2cents);
6492 bstr0 = SysAllocString(sz0);
6493 bstr1 = SysAllocString(sz1);
6494 bstr7 = SysAllocString(sz7);
6495 bstr42 = SysAllocString(sz42);
6496 bstr1neg = SysAllocString(sz1neg);
6497 bstr666neg = SysAllocString(sz666neg);
6498 bstr1few = SysAllocString(sz1few);
6500 /* Test all possible flag/vt combinations & the resulting vt type */
6501 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
6503 VARTYPE leftvt, rightvt;
6505 for (leftvt = 0; leftvt <= VT_BSTR_BLOB; leftvt++)
6510 for (rightvt = 0; rightvt <= VT_BSTR_BLOB; rightvt++)
6513 HRESULT expect = VARCMP_EQ;
6517 memset(&left, 0, sizeof(left));
6518 memset(&right, 0, sizeof(right));
6519 V_VT(&left) = leftvt | ExtraFlags[i];
6520 if (leftvt == VT_BSTR) {
6521 V_BSTR(&left) = bstr1neg;
6522 if (ExtraFlags[i] & VT_RESERVED)
6527 V_VT(&right) = rightvt | ExtraFlags[i];
6528 if (rightvt == VT_BSTR) {
6529 V_BSTR(&right) = bstr1neg;
6530 if (ExtraFlags[i] & VT_RESERVED)
6536 /* Don't ask me why but native VarCmp cannot handle:
6537 VT_I1, VT_UI2, VT_UI4, VT_UINT and VT_UI8.
6538 VT_INT is only supported as left variant. Go figure.
6539 Tested with DCOM98, Win2k, WinXP */
6540 if (ExtraFlags[i] & VT_ARRAY || ExtraFlags[i] & VT_BYREF ||
6541 !IsValidVariantClearVT(leftvt, ExtraFlags[i] & ~VT_RESERVED) ||
6542 !IsValidVariantClearVT(rightvt, ExtraFlags[i] & ~VT_RESERVED) ||
6543 leftvt == VT_CLSID || rightvt == VT_CLSID ||
6544 leftvt == VT_DISPATCH || rightvt == VT_DISPATCH ||
6545 leftvt == VT_ERROR || rightvt == VT_ERROR ||
6546 leftvt == VT_RECORD || rightvt == VT_RECORD ||
6547 leftvt == VT_UNKNOWN || rightvt == VT_UNKNOWN ||
6548 leftvt == VT_VARIANT || rightvt == VT_VARIANT ||
6549 leftvt == VT_I1 || rightvt == VT_I1 ||
6550 leftvt == VT_UI2 || rightvt == VT_UI2 ||
6551 leftvt == VT_UI4 || rightvt == VT_UI4 ||
6552 leftvt == VT_UI8 || rightvt == VT_UI8 ||
6553 rightvt == VT_INT ||
6554 leftvt == VT_UINT || rightvt == VT_UINT) {
6558 if (leftvt == VT_ERROR && rightvt == VT_ERROR &&
6559 !(ExtraFlags[i] & ~VT_RESERVED)) {
6562 } else if (leftvt == VT_NULL || rightvt == VT_NULL)
6563 expect = VARCMP_NULL;
6564 else if (leftvt == VT_BSTR && rightvt == VT_BSTR)
6566 else if (leftvt == VT_BSTR && rightvt == VT_EMPTY)
6568 else if (leftvt == VT_EMPTY && rightvt == VT_BSTR)
6571 hres = pVarCmp(&left, &right, LOCALE_USER_DEFAULT, 0);
6573 ok(hres == DISP_E_TYPEMISMATCH || hres == DISP_E_BADVARTYPE,
6574 "VarCmp: %d|0x%X, %d|0x%X: Expected failure, got 0x%X\n",
6575 leftvt, ExtraFlags[i], rightvt, ExtraFlags[i], hres);
6578 "VarCmp: %d|0x%X, %d|0x%X: Expected 0x%X, got 0x%X\n",
6579 leftvt, ExtraFlags[i], rightvt, ExtraFlags[i], expect,
6586 /* VARCMP{,EX} run each 4 tests with a permutation of all possible
6587 input variants with (1) and without (0) VT_RESERVED set. The order
6588 of the permutations is (0,0); (1,0); (0,1); (1,1) */
6589 VARCMP(INT,4711,I2,4711,VARCMP_EQ);
6590 VARCMP(INT,4711,I2,-4711,VARCMP_GT);
6591 VARCMP(ERROR,0,ERROR,0,VARCMP_EQ);
6592 VARCMP(ERROR,0,UI1,0,DISP_E_TYPEMISMATCH);
6593 VARCMP(EMPTY,0,EMPTY,0,VARCMP_EQ);
6594 VARCMP(I4,1,R8,1.0,VARCMP_EQ);
6595 VARCMP(EMPTY,19,I2,0,VARCMP_EQ);
6596 ok(V_EMPTY(&left) == 19, "VT_EMPTY modified!\n");
6597 VARCMP(I4,1,UI1,1,VARCMP_EQ);
6598 VARCMP(I2,2,I2,2,VARCMP_EQ);
6599 VARCMP(I2,1,I2,2,VARCMP_LT);
6600 VARCMP(I2,2,I2,1,VARCMP_GT);
6601 VARCMP(I2,2,EMPTY,1,VARCMP_GT);
6602 VARCMP(I2,2,NULL_,1,VARCMP_NULL);
6604 /* BSTR handling, especially in conjunction with VT_RESERVED */
6605 VARCMP(BSTR,bstr0,NULL_,0,VARCMP_NULL);
6606 VARCMP(BSTR,bstr0,BSTR,bstr0,VARCMP_EQ);
6607 VARCMP(BSTR,bstrempty,BSTR,bstr0,VARCMP_LT);
6608 VARCMP(BSTR,bstr7,BSTR,bstr0,VARCMP_GT);
6609 VARCMP(BSTR,bstr7,BSTR,bstr1neg,VARCMP_GT);
6610 VARCMP(BSTR,bstr0,BSTR,NULL,VARCMP_GT);
6611 VARCMP(BSTR,NULL,BSTR,NULL,VARCMP_EQ);
6612 VARCMP(BSTR,bstrempty,BSTR,NULL,VARCMP_EQ);
6613 VARCMP(BSTR,NULL,EMPTY,0,VARCMP_EQ);
6614 VARCMP(EMPTY,0,BSTR,NULL,VARCMP_EQ);
6615 VARCMP(EMPTY,0,BSTR,bstrempty,VARCMP_EQ);
6616 VARCMP(EMPTY,1,BSTR,bstrempty,VARCMP_EQ);
6617 VARCMP(BSTR,bstr0,EMPTY,0,VARCMP_GT);
6618 VARCMP(BSTR,bstr42,EMPTY,0,VARCMP_GT);
6619 VARCMPEX(BSTR,bstrempty,UI1,0,VARCMP_GT,VARCMP_LT,VARCMP_GT,VARCMP_GT);
6620 VARCMPEX(BSTR,bstrempty,I2,-1,VARCMP_GT,VARCMP_LT,VARCMP_GT,VARCMP_GT);
6621 VARCMPEX(I4,0,BSTR,bstrempty,VARCMP_LT,VARCMP_LT,VARCMP_GT,VARCMP_LT);
6622 VARCMPEX(BSTR,NULL,UI1,0,VARCMP_GT,VARCMP_LT,VARCMP_GT,VARCMP_GT);
6623 VARCMPEX(I4,7,BSTR,NULL,VARCMP_LT,VARCMP_LT,VARCMP_GT,VARCMP_LT);
6624 _VARCMP(BSTR,(BSTR)100,0,I2,100,0,lcid,0,VARCMP_GT);
6625 VARCMPEX(BSTR,bstr0,UI1,0,VARCMP_GT,VARCMP_EQ,VARCMP_EQ,VARCMP_GT);
6626 VARCMPEX(I2,0,BSTR,bstr0,VARCMP_LT,VARCMP_EQ,VARCMP_EQ,VARCMP_LT);
6627 VARCMP(BSTR,bstrhuh,I4,I4_MAX,VARCMP_GT);
6628 VARCMP(BSTR,bstr2cents,I4,2,VARCMP_GT);
6629 VARCMPEX(BSTR,bstr2cents,I4,42,VARCMP_GT,VARCMP_LT,VARCMP_GT,VARCMP_GT);
6630 VARCMP(BSTR,bstr2cents,I4,-1,VARCMP_GT);
6631 VARCMPEX(BSTR,bstr2cents,I4,-666,VARCMP_GT,VARCMP_LT,VARCMP_GT,VARCMP_GT);
6632 VARCMPEX(BSTR,bstr0,I2,0,VARCMP_GT,VARCMP_EQ,VARCMP_EQ,VARCMP_GT);
6633 VARCMPEX(BSTR,bstr0,I4,0,VARCMP_GT,VARCMP_EQ,VARCMP_EQ,VARCMP_GT);
6634 VARCMPEX(BSTR,bstr0,I4,-666,VARCMP_GT,VARCMP_LT,VARCMP_GT,VARCMP_GT);
6635 VARCMP(BSTR,bstr1,I4,0,VARCMP_GT);
6636 VARCMPEX(BSTR,bstr1,I4,1,VARCMP_GT,VARCMP_EQ,VARCMP_EQ,VARCMP_GT);
6637 VARCMPEX(BSTR,bstr1,I4,I4_MAX,VARCMP_GT,VARCMP_LT,VARCMP_LT,VARCMP_GT);
6638 VARCMPEX(BSTR,bstr1,I4,-1,VARCMP_GT,VARCMP_LT,VARCMP_GT,VARCMP_GT);
6639 VARCMP(BSTR,bstr7,I4,1,VARCMP_GT);
6640 VARCMPEX(BSTR,bstr7,I4,7,VARCMP_GT,VARCMP_EQ,VARCMP_EQ,VARCMP_GT);
6641 VARCMPEX(BSTR,bstr7,I4,42,VARCMP_GT,VARCMP_GT,VARCMP_LT,VARCMP_GT);
6642 VARCMPEX(BSTR,bstr42,I4,7,VARCMP_GT,VARCMP_LT,VARCMP_GT,VARCMP_GT);
6643 VARCMPEX(BSTR,bstr42,I4,42,VARCMP_GT,VARCMP_EQ,VARCMP_EQ,VARCMP_GT);
6644 VARCMPEX(BSTR,bstr42,I4,I4_MAX,VARCMP_GT,VARCMP_GT,VARCMP_LT,VARCMP_GT);
6645 VARCMPEX(BSTR,bstr1neg,I4,1,VARCMP_GT,VARCMP_GT,VARCMP_LT,VARCMP_LT);
6646 VARCMPEX(BSTR,bstr1neg,I4,42,VARCMP_GT,VARCMP_LT,VARCMP_LT,VARCMP_LT);
6647 VARCMPEX(BSTR,bstr1neg,I4,-1,VARCMP_GT,VARCMP_EQ,VARCMP_EQ,VARCMP_LT);
6648 VARCMPEX(BSTR,bstr1neg,I4,-666,VARCMP_GT,VARCMP_LT,VARCMP_GT,VARCMP_LT);
6649 VARCMPEX(BSTR,bstr666neg,I4,1,VARCMP_GT,VARCMP_GT,VARCMP_LT,VARCMP_LT);
6650 VARCMPEX(BSTR,bstr666neg,I4,7,VARCMP_GT,VARCMP_LT,VARCMP_LT,VARCMP_LT);
6651 VARCMPEX(BSTR,bstr666neg,I4,42,VARCMP_GT,VARCMP_GT,VARCMP_LT,VARCMP_LT);
6652 VARCMPEX(BSTR,bstr666neg,I4,I4_MAX,VARCMP_GT,VARCMP_GT,VARCMP_LT,VARCMP_LT);
6653 VARCMPEX(BSTR,bstr666neg,I4,-1,VARCMP_GT,VARCMP_GT,VARCMP_LT,VARCMP_LT);
6654 VARCMPEX(BSTR,bstr666neg,I4,-666,VARCMP_GT,VARCMP_EQ,VARCMP_EQ,VARCMP_LT);
6655 VARCMPEX(BSTR,bstr7,R8,7.0,VARCMP_GT,VARCMP_EQ,VARCMP_EQ,VARCMP_GT);
6656 VARCMPEX(R8,3.141592,BSTR,NULL,VARCMP_LT,VARCMP_LT,VARCMP_GT,VARCMP_LT);
6657 VARCMP(BSTR,bstr7,BSTR,bstr7,VARCMP_EQ);
6658 VARCMP(BSTR,bstr7,BSTR,bstr42,VARCMP_GT);
6659 VARCMP(BSTR,bstr42,BSTR,bstr7,VARCMP_LT);
6661 /* DECIMAL handling */
6662 setdec(&dec,0,0,0,0);
6663 VARCMPEX(DECIMAL,dec,BSTR,bstr0,VARCMP_LT,VARCMP_EQ,VARCMP_EQ,VARCMP_LT);
6664 setdec64(&dec,0,0,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF); /* max DECIMAL */
6665 VARCMP(DECIMAL,dec,R8,R8_MAX,VARCMP_LT); /* R8 has bigger range */
6666 VARCMP(DECIMAL,dec,DATE,R8_MAX,VARCMP_LT); /* DATE has bigger range */
6667 setdec64(&dec,0,0x80,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF);
6668 VARCMP(DECIMAL,dec,R8,-R8_MAX,VARCMP_GT);
6669 setdec64(&dec,20,0,0x5,0x6BC75E2D,0x63100001); /* 1+1e-20 */
6670 VARCMP(DECIMAL,dec,R8,1,VARCMP_GT); /* DECIMAL has higher precision */
6672 /* Show that DATE is handled just as a R8 */
6673 VARCMP(DATE,DATE_MAX,DATE,DATE_MAX+1,VARCMP_LT);
6674 VARCMP(DATE,DATE_MIN,DATE,DATE_MIN-1,VARCMP_GT);
6675 VARCMP(DATE,R8_MIN,R8,R8_MIN,VARCMP_EQ);
6676 VARCMP(DATE,1,DATE,1+1e-15,VARCMP_LT); /* 1e-15 == 8.64e-11 seconds */
6677 VARCMP(DATE,25570.0,DATE,25570.0,VARCMP_EQ);
6678 VARCMP(DATE,25570.0,DATE,25571.0,VARCMP_LT);
6679 VARCMP(DATE,25571.0,DATE,25570.0,VARCMP_GT);
6680 VARCMP(DATE,25570.0,EMPTY,0,VARCMP_GT);
6681 VARCMP(DATE,25570.0,NULL_,0,VARCMP_NULL);
6683 /* R4 precision handling */
6684 VARCMP(R4,1,R8,1+1e-8,VARCMP_EQ);
6685 VARCMP(R8,1+1e-8,R4,1,VARCMP_EQ);
6686 VARCMP(R8,1+1e-8,R8,1,VARCMP_GT);
6687 VARCMP(R8,R4_MAX*1.1,R4,R4_MAX,VARCMP_GT);
6688 VARCMP(R4,R4_MAX,R8,R8_MAX,VARCMP_LT);
6689 VARCMP(R4,1,DATE,1+1e-8,VARCMP_EQ);
6690 VARCMP(R4,1,BSTR,bstr1few,VARCMP_LT); /* bstr1few == 1+1e-8 */
6691 setdec(&dec,8,0,0,0x5F5E101); /* 1+1e-8 */
6692 VARCMP(R4,1,DECIMAL,dec,VARCMP_LT);
6694 SysFreeString(bstrhuh);
6695 SysFreeString(bstrempty);
6696 SysFreeString(bstr0);
6697 SysFreeString(bstr1);
6698 SysFreeString(bstr7);
6699 SysFreeString(bstr42);
6700 SysFreeString(bstr1neg);
6701 SysFreeString(bstr666neg);
6702 SysFreeString(bstr2cents);
6703 SysFreeString(bstr1few);
6706 static HRESULT (WINAPI *pVarPow)(LPVARIANT,LPVARIANT,LPVARIANT);
6708 #define VARPOW(vt1,val1,vt2,val2,rvt,rval) \
6709 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
6710 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
6711 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
6712 test_var_call2( __LINE__, pVarPow, &left, &right, &exp )
6714 /* Skip any type that is not defined or produces an error for every case */
6715 #define SKIPTESTPOW(a) \
6716 if (a == VT_ERROR || a == VT_VARIANT || \
6717 a == VT_DISPATCH || a == VT_UNKNOWN || \
6718 a == VT_RECORD || a > VT_UINT || \
6719 a == 15 /*not defined*/) \
6722 static void test_VarPow(void)
6724 static const WCHAR str2[] = { '2','\0' };
6725 static const WCHAR str3[] = { '3','\0' };
6726 VARIANT left, right, exp, result, cy, dec;
6727 BSTR num2_str, num3_str;
6733 num2_str = SysAllocString(str2);
6734 num3_str = SysAllocString(str3);
6736 /* Test all possible flag/vt combinations & the resulting vt type */
6737 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
6739 VARTYPE leftvt, rightvt, resvt;
6741 for (leftvt = 0; leftvt <= VT_BSTR_BLOB; leftvt++)
6743 SKIPTESTPOW(leftvt);
6745 for (rightvt = 0; rightvt <= VT_BSTR_BLOB; rightvt++)
6748 SKIPTESTPOW(rightvt);
6750 /* Native crashes with VT_BYREF */
6751 if (ExtraFlags[i] == VT_BYREF)
6754 memset(&left, 0, sizeof(left));
6755 memset(&right, 0, sizeof(right));
6756 V_VT(&left) = leftvt | ExtraFlags[i];
6757 V_VT(&right) = rightvt | ExtraFlags[i];
6758 V_VT(&result) = VT_EMPTY;
6761 if (leftvt == VT_BSTR)
6762 V_BSTR(&left) = num2_str;
6763 if (rightvt == VT_BSTR)
6764 V_BSTR(&right) = num2_str;
6766 /* Native VarPow always returns an error when using extra flags */
6767 if (ExtraFlags[i] != 0)
6770 /* Determine return type */
6771 else if ((leftvt == VT_NULL || rightvt == VT_NULL) &&
6772 ((leftvt != VT_I8 && leftvt != VT_UI8 &&
6773 rightvt != VT_I8 && rightvt != VT_UI8) || HAVE_OLEAUT32_I8))
6775 else if ((leftvt == VT_EMPTY || leftvt == VT_I2 ||
6776 leftvt == VT_I4 || leftvt == VT_R4 ||
6777 leftvt == VT_R8 || leftvt == VT_CY ||
6778 leftvt == VT_DATE || leftvt == VT_BSTR ||
6779 leftvt == VT_BOOL || leftvt == VT_DECIMAL ||
6780 (leftvt >= VT_I1 && leftvt <= VT_UI4) ||
6781 (HAVE_OLEAUT32_I8 && (leftvt == VT_I8 || leftvt == VT_UI8)) ||
6782 leftvt == VT_INT || leftvt == VT_UINT) &&
6783 (rightvt == VT_EMPTY || rightvt == VT_I2 ||
6784 rightvt == VT_I4 || rightvt == VT_R4 ||
6785 rightvt == VT_R8 || rightvt == VT_CY ||
6786 rightvt == VT_DATE || rightvt == VT_BSTR ||
6787 rightvt == VT_BOOL || rightvt == VT_DECIMAL ||
6788 (rightvt >= VT_I1 && rightvt <= VT_UI4) ||
6789 (HAVE_OLEAUT32_I8 && (rightvt == VT_I8 || rightvt == VT_UI8)) ||
6790 rightvt == VT_INT || rightvt == VT_UINT))
6795 hres = pVarPow(&left, &right, &result);
6797 /* Check expected HRESULT and if result variant type is correct */
6799 ok (hres == DISP_E_BADVARTYPE || hres == DISP_E_TYPEMISMATCH,
6800 "VarPow: %s|0x%X, %s|0x%X: got vt %s hr 0x%X\n",
6801 vtstr(leftvt), ExtraFlags[i], vtstr(rightvt), ExtraFlags[i],
6802 vtstr(V_VT(&result)), hres);
6804 ok (hres == S_OK && resvt == V_VT(&result),
6805 "VarPow: %s|0x%X, %s|0x%X: expected vt %s hr 0x%X, got vt %s hr 0x%X\n",
6806 vtstr(leftvt), ExtraFlags[i], vtstr(rightvt), ExtraFlags[i], vtstr(resvt),
6807 S_OK, vtstr(V_VT(&result)), hres);
6812 /* Check return values for valid variant type combinations */
6813 VARPOW(EMPTY,0,EMPTY,0,R8,1.0);
6814 VARPOW(EMPTY,0,NULL,0,NULL,0);
6815 VARPOW(EMPTY,0,I2,3,R8,0.0);
6816 VARPOW(EMPTY,0,I4,3,R8,0.0);
6817 VARPOW(EMPTY,0,R4,3.0f,R8,0.0);
6818 VARPOW(EMPTY,0,R8,3.0,R8,0.0);
6819 VARPOW(EMPTY,0,DATE,3,R8,0.0);
6820 VARPOW(EMPTY,0,BSTR,num3_str,R8,0.0);
6821 VARPOW(EMPTY,0,BOOL,VARIANT_FALSE,R8,1.0);
6822 VARPOW(EMPTY,0,I1,3,R8,0.0);
6823 VARPOW(EMPTY,0,UI1,3,R8,0.0);
6824 VARPOW(EMPTY,0,UI2,3,R8,0.0);
6825 VARPOW(EMPTY,0,UI4,3,R8,0.0);
6826 if (HAVE_OLEAUT32_I8)
6828 VARPOW(EMPTY,0,I8,3,R8,0.0);
6829 VARPOW(EMPTY,0,UI8,3,R8,0.0);
6831 VARPOW(EMPTY,0,INT,3,R8,0.0);
6832 VARPOW(EMPTY,0,UINT,3,R8,0.0);
6833 VARPOW(NULL,0,EMPTY,0,NULL,0);
6834 VARPOW(NULL,0,NULL,0,NULL,0);
6835 VARPOW(NULL,0,I2,3,NULL,0);
6836 VARPOW(NULL,0,I4,3,NULL,0);
6837 VARPOW(NULL,0,R4,3.0f,NULL,0);
6838 VARPOW(NULL,0,R8,3.0,NULL,0);
6839 VARPOW(NULL,0,DATE,3,NULL,0);
6840 VARPOW(NULL,0,BSTR,num3_str,NULL,0);
6841 VARPOW(NULL,0,BOOL,VARIANT_TRUE,NULL,0);
6842 VARPOW(NULL,0,I1,3,NULL,0);
6843 VARPOW(NULL,0,UI1,3,NULL,0);
6844 VARPOW(NULL,0,UI2,3,NULL,0);
6845 VARPOW(NULL,0,UI4,3,NULL,0);
6846 if (HAVE_OLEAUT32_I8)
6848 VARPOW(NULL,0,I8,3,NULL,0);
6849 VARPOW(NULL,0,UI8,3,NULL,0);
6851 VARPOW(NULL,0,INT,3,NULL,0);
6852 VARPOW(NULL,0,UINT,3,NULL,0);
6853 VARPOW(I2,2,EMPTY,0,R8,1.0);
6854 VARPOW(I2,2,NULL,0,NULL,0);
6855 VARPOW(I2,2,I2,3,R8,8.0);
6856 VARPOW(I2,2,I4,3,R8,8.0);
6857 VARPOW(I2,2,R4,3.0f,R8,8.0);
6858 VARPOW(I2,2,R8,3.0,R8,8.0);
6859 VARPOW(I2,2,DATE,3,R8,8.0);
6860 VARPOW(I2,2,BSTR,num3_str,R8,8.0);
6861 VARPOW(I2,2,BOOL,VARIANT_FALSE,R8,1.0);
6862 VARPOW(I2,2,I1,3,R8,8.0);
6863 VARPOW(I2,2,UI1,3,R8,8.0);
6864 VARPOW(I2,2,UI2,3,R8,8.0);
6865 VARPOW(I2,2,UI4,3,R8,8.0);
6866 if (HAVE_OLEAUT32_I8)
6868 VARPOW(I2,2,I8,3,R8,8.0);
6869 VARPOW(I2,2,UI8,3,R8,8.0);
6871 VARPOW(I2,2,INT,3,R8,8.0);
6872 VARPOW(I2,2,UINT,3,R8,8.0);
6873 VARPOW(I4,2,EMPTY,0,R8,1.0);
6874 VARPOW(I4,2,NULL,0,NULL,0);
6875 VARPOW(I4,2,I2,3,R8,8.0);
6876 VARPOW(I4,2,I4,3,R8,8.0);
6877 VARPOW(I4,2,R4,3.0f,R8,8.0);
6878 VARPOW(I4,2,R8,3.0,R8,8.0);
6879 VARPOW(I4,2,DATE,3,R8,8.0);
6880 VARPOW(I4,2,BSTR,num3_str,R8,8.0);
6881 VARPOW(I4,2,BOOL,VARIANT_FALSE,R8,1.0);
6882 VARPOW(I4,2,I1,3,R8,8.0);
6883 VARPOW(I4,2,UI1,3,R8,8.0);
6884 VARPOW(I4,2,UI2,3,R8,8.0);
6885 VARPOW(I4,2,UI4,3,R8,8.0);
6886 if (HAVE_OLEAUT32_I8)
6888 VARPOW(I4,2,I8,3,R8,8.0);
6889 VARPOW(I4,2,UI8,3,R8,8.0);
6891 VARPOW(I4,2,INT,3,R8,8.0);
6892 VARPOW(I4,2,UINT,3,R8,8.0);
6893 VARPOW(R4,2,EMPTY,0,R8,1.0);
6894 VARPOW(R4,2,NULL,0,NULL,0);
6895 VARPOW(R4,2,I2,3,R8,8.0);
6896 VARPOW(R4,2,I4,3,R8,8.0);
6897 VARPOW(R4,2,R4,3.0f,R8,8.0);
6898 VARPOW(R4,2,R8,3.0,R8,8.0);
6899 VARPOW(R4,2,DATE,3,R8,8.0);
6900 VARPOW(R4,2,BSTR,num3_str,R8,8.0);
6901 VARPOW(R4,2,BOOL,VARIANT_FALSE,R8,1.0);
6902 VARPOW(R4,2,I1,3,R8,8.0);
6903 VARPOW(R4,2,UI1,3,R8,8.0);
6904 VARPOW(R4,2,UI2,3,R8,8.0);
6905 VARPOW(R4,2,UI4,3,R8,8.0);
6906 if (HAVE_OLEAUT32_I8)
6908 VARPOW(R4,2,I8,3,R8,8.0);
6909 VARPOW(R4,2,UI8,3,R8,8.0);
6911 VARPOW(R4,2,INT,3,R8,8.0);
6912 VARPOW(R4,2,UINT,3,R8,8.0);
6913 VARPOW(R8,2,EMPTY,0,R8,1.0);
6914 VARPOW(R8,2,NULL,0,NULL,0);
6915 VARPOW(R8,2,I2,3,R8,8.0);
6916 VARPOW(R8,2,I4,3,R8,8.0);
6917 VARPOW(R8,2,R4,3.0f,R8,8.0);
6918 VARPOW(R8,2,R8,3.0,R8,8.0);
6919 VARPOW(R8,2,DATE,3,R8,8.0);
6920 VARPOW(R8,2,BSTR,num3_str,R8,8.0);
6921 VARPOW(R8,2,BOOL,VARIANT_FALSE,R8,1.0);
6922 VARPOW(R8,2,I1,3,R8,8.0);
6923 VARPOW(R8,2,UI1,3,R8,8.0);
6924 VARPOW(R8,2,UI2,3,R8,8.0);
6925 VARPOW(R8,2,UI4,3,R8,8.0);
6926 if (HAVE_OLEAUT32_I8)
6928 VARPOW(R8,2,I8,3,R8,8.0);
6929 VARPOW(R8,2,UI8,3,R8,8.0);
6931 VARPOW(R8,2,INT,3,R8,8.0);
6932 VARPOW(R8,2,UINT,3,R8,8.0);
6933 VARPOW(DATE,2,EMPTY,0,R8,1.0);
6934 VARPOW(DATE,2,NULL,0,NULL,0);
6935 VARPOW(DATE,2,I2,3,R8,8.0);
6936 VARPOW(DATE,2,I4,3,R8,8.0);
6937 VARPOW(DATE,2,R4,3.0f,R8,8.0);
6938 VARPOW(DATE,2,R8,3.0,R8,8.0);
6939 VARPOW(DATE,2,DATE,3,R8,8.0);
6940 VARPOW(DATE,2,BSTR,num3_str,R8,8.0);
6941 VARPOW(DATE,2,BOOL,VARIANT_FALSE,R8,1.0);
6942 VARPOW(DATE,2,I1,3,R8,8.0);
6943 VARPOW(DATE,2,UI1,3,R8,8.0);
6944 VARPOW(DATE,2,UI2,3,R8,8.0);
6945 VARPOW(DATE,2,UI4,3,R8,8.0);
6946 if (HAVE_OLEAUT32_I8)
6948 VARPOW(DATE,2,I8,3,R8,8.0);
6949 VARPOW(DATE,2,UI8,3,R8,8.0);
6951 VARPOW(DATE,2,INT,3,R8,8.0);
6952 VARPOW(DATE,2,UINT,3,R8,8.0);
6953 VARPOW(BSTR,num2_str,EMPTY,0,R8,1.0);
6954 VARPOW(BSTR,num2_str,NULL,0,NULL,0);
6955 VARPOW(BSTR,num2_str,I2,3,R8,8.0);
6956 VARPOW(BSTR,num2_str,I4,3,R8,8.0);
6957 VARPOW(BSTR,num2_str,R4,3.0f,R8,8.0);
6958 VARPOW(BSTR,num2_str,R8,3.0,R8,8.0);
6959 VARPOW(BSTR,num2_str,DATE,3,R8,8.0);
6960 VARPOW(BSTR,num2_str,BSTR,num3_str,R8,8.0);
6961 VARPOW(BSTR,num2_str,BOOL,VARIANT_FALSE,R8,1.0);
6962 VARPOW(BSTR,num2_str,I1,3,R8,8.0);
6963 VARPOW(BSTR,num2_str,UI1,3,R8,8.0);
6964 VARPOW(BSTR,num2_str,UI2,3,R8,8.0);
6965 VARPOW(BSTR,num2_str,UI4,3,R8,8.0);
6966 if (HAVE_OLEAUT32_I8)
6968 VARPOW(BSTR,num2_str,I8,3,R8,8.0);
6969 VARPOW(BSTR,num2_str,UI8,3,R8,8.0);
6971 VARPOW(BSTR,num2_str,INT,3,R8,8.0);
6972 VARPOW(BSTR,num2_str,UINT,3,R8,8.0);
6973 VARPOW(BOOL,VARIANT_TRUE,EMPTY,0,R8,1.0);
6974 VARPOW(BOOL,VARIANT_TRUE,NULL,0,NULL,0);
6975 VARPOW(BOOL,VARIANT_TRUE,I2,3,R8,-1.0);
6976 VARPOW(BOOL,VARIANT_TRUE,I4,3,R8,-1.0);
6977 VARPOW(BOOL,VARIANT_TRUE,R4,3.0f,R8,-1.0);
6978 VARPOW(BOOL,VARIANT_TRUE,R8,3.0,R8,-1.0);
6979 VARPOW(BOOL,VARIANT_TRUE,DATE,3,R8,-1.0);
6980 VARPOW(BOOL,VARIANT_TRUE,BSTR,num3_str,R8,-1.0);
6981 VARPOW(BOOL,VARIANT_TRUE,BOOL,VARIANT_TRUE,R8,-1.0);
6982 VARPOW(BOOL,VARIANT_TRUE,I1,3,R8,-1.0);
6983 VARPOW(BOOL,VARIANT_TRUE,UI1,3,R8,-1.0);
6984 VARPOW(BOOL,VARIANT_TRUE,UI2,3,R8,-1.0);
6985 VARPOW(BOOL,VARIANT_TRUE,UI4,3,R8,-1.0);
6986 if (HAVE_OLEAUT32_I8)
6988 VARPOW(BOOL,VARIANT_TRUE,I8,3,R8,-1.0);
6989 VARPOW(BOOL,VARIANT_TRUE,UI8,3,R8,-1.0);
6991 VARPOW(BOOL,VARIANT_TRUE,INT,3,R8,-1.0);
6992 VARPOW(BOOL,VARIANT_TRUE,UINT,3,R8,-1.0);
6993 VARPOW(I1,2,EMPTY,0,R8,1.0);
6994 VARPOW(I1,2,NULL,0,NULL,0);
6995 VARPOW(I1,2,I2,3,R8,8.0);
6996 VARPOW(I1,2,I4,3,R8,8.0);
6997 VARPOW(I1,2,R4,3.0f,R8,8.0);
6998 VARPOW(I1,2,R8,3.0,R8,8.0);
6999 VARPOW(I1,2,DATE,3,R8,8.0);
7000 VARPOW(I1,2,BSTR,num3_str,R8,8.0);
7001 VARPOW(I1,2,BOOL,VARIANT_FALSE,R8,1.0);
7002 VARPOW(I1,2,I1,3,R8,8.0);
7003 VARPOW(I1,2,UI1,3,R8,8.0);
7004 VARPOW(I1,2,UI2,3,R8,8.0);
7005 VARPOW(I1,2,UI4,3,R8,8.0);
7006 if (HAVE_OLEAUT32_I8)
7008 VARPOW(I1,2,I8,3,R8,8.0);
7009 VARPOW(I1,2,UI8,3,R8,8.0);
7011 VARPOW(I1,2,INT,3,R8,8.0);
7012 VARPOW(I1,2,UINT,3,R8,8.0);
7013 VARPOW(UI1,2,EMPTY,0,R8,1.0);
7014 VARPOW(UI1,2,NULL,0,NULL,0);
7015 VARPOW(UI1,2,I2,3,R8,8.0);
7016 VARPOW(UI1,2,I4,3,R8,8.0);
7017 VARPOW(UI1,2,R4,3.0f,R8,8.0);
7018 VARPOW(UI1,2,R8,3.0,R8,8.0);
7019 VARPOW(UI1,2,DATE,3,R8,8.0);
7020 VARPOW(UI1,2,BSTR,num3_str,R8,8.0);
7021 VARPOW(UI1,2,BOOL,VARIANT_FALSE,R8,1.0);
7022 VARPOW(UI1,2,I1,3,R8,8.0);
7023 VARPOW(UI1,2,UI1,3,R8,8.0);
7024 VARPOW(UI1,2,UI2,3,R8,8.0);
7025 VARPOW(UI1,2,UI4,3,R8,8.0);
7026 if (HAVE_OLEAUT32_I8)
7028 VARPOW(UI1,2,I8,3,R8,8.0);
7029 VARPOW(UI1,2,UI8,3,R8,8.0);
7031 VARPOW(UI1,2,INT,3,R8,8.0);
7032 VARPOW(UI1,2,UINT,3,R8,8.0);
7033 VARPOW(UI2,2,EMPTY,0,R8,1.0);
7034 VARPOW(UI2,2,NULL,0,NULL,0);
7035 VARPOW(UI2,2,I2,3,R8,8.0);
7036 VARPOW(UI2,2,I4,3,R8,8.0);
7037 VARPOW(UI2,2,R4,3.0f,R8,8.0);
7038 VARPOW(UI2,2,R8,3.0,R8,8.0);
7039 VARPOW(UI2,2,DATE,3,R8,8.0);
7040 VARPOW(UI2,2,BSTR,num3_str,R8,8.0);
7041 VARPOW(UI2,2,BOOL,VARIANT_FALSE,R8,1.0);
7042 VARPOW(UI2,2,I1,3,R8,8.0);
7043 VARPOW(UI2,2,UI1,3,R8,8.0);
7044 VARPOW(UI2,2,UI2,3,R8,8.0);
7045 VARPOW(UI2,2,UI4,3,R8,8.0);
7046 if (HAVE_OLEAUT32_I8)
7048 VARPOW(UI2,2,I8,3,R8,8.0);
7049 VARPOW(UI2,2,UI8,3,R8,8.0);
7051 VARPOW(UI2,2,INT,3,R8,8.0);
7052 VARPOW(UI2,2,UINT,3,R8,8.0);
7053 VARPOW(UI4,2,EMPTY,0,R8,1.0);
7054 VARPOW(UI4,2,NULL,0,NULL,0);
7055 VARPOW(UI4,2,I2,3,R8,8.0);
7056 VARPOW(UI4,2,I4,3,R8,8.0);
7057 VARPOW(UI4,2,R4,3.0f,R8,8.0);
7058 VARPOW(UI4,2,R8,3.0,R8,8.0);
7059 VARPOW(UI4,2,DATE,3,R8,8.0);
7060 VARPOW(UI4,2,BSTR,num3_str,R8,8.0);
7061 VARPOW(UI4,2,BOOL,VARIANT_FALSE,R8,1.0);
7062 VARPOW(UI4,2,I1,3,R8,8.0);
7063 VARPOW(UI4,2,UI1,3,R8,8.0);
7064 VARPOW(UI4,2,UI2,3,R8,8.0);
7065 VARPOW(UI4,2,UI4,3,R8,8.0);
7066 if (HAVE_OLEAUT32_I8)
7068 VARPOW(UI4,2,I8,3,R8,8.0);
7069 VARPOW(UI4,2,UI8,3,R8,8.0);
7071 VARPOW(UI4,2,INT,3,R8,8.0);
7072 VARPOW(UI4,2,UINT,3,R8,8.0);
7073 if (HAVE_OLEAUT32_I8)
7075 VARPOW(I8,2,EMPTY,0,R8,1.0);
7076 VARPOW(I8,2,NULL,0,NULL,0);
7077 VARPOW(I8,2,I2,3,R8,8.0);
7078 VARPOW(I8,2,I4,3,R8,8.0);
7079 VARPOW(I8,2,R4,3.0f,R8,8.0);
7080 VARPOW(I8,2,R8,3.0,R8,8.0);
7081 VARPOW(I8,2,DATE,3,R8,8.0);
7082 VARPOW(I8,2,BSTR,num3_str,R8,8.0);
7083 VARPOW(I8,2,BOOL,VARIANT_FALSE,R8,1.0);
7084 VARPOW(I8,2,I1,3,R8,8.0);
7085 VARPOW(I8,2,UI1,3,R8,8.0);
7086 VARPOW(I8,2,UI2,3,R8,8.0);
7087 VARPOW(I8,2,UI4,3,R8,8.0);
7088 VARPOW(I8,2,I8,3,R8,8.0);
7089 VARPOW(I8,2,UI8,3,R8,8.0);
7090 VARPOW(I8,2,INT,3,R8,8.0);
7091 VARPOW(I8,2,UINT,3,R8,8.0);
7092 VARPOW(UI8,2,EMPTY,0,R8,1.0);
7093 VARPOW(UI8,2,NULL,0,NULL,0);
7094 VARPOW(UI8,2,I2,3,R8,8.0);
7095 VARPOW(UI8,2,I4,3,R8,8.0);
7096 VARPOW(UI8,2,R4,3.0f,R8,8.0);
7097 VARPOW(UI8,2,R8,3.0,R8,8.0);
7098 VARPOW(UI8,2,DATE,3,R8,8.0);
7099 VARPOW(UI8,2,BSTR,num3_str,R8,8.0);
7100 VARPOW(UI8,2,I1,3,R8,8.0);
7101 VARPOW(UI8,2,UI1,3,R8,8.0);
7102 VARPOW(UI8,2,UI2,3,R8,8.0);
7103 VARPOW(UI8,2,UI4,3,R8,8.0);
7104 VARPOW(UI8,2,I8,3,R8,8.0);
7105 VARPOW(UI8,2,UI8,3,R8,8.0);
7106 VARPOW(UI8,2,INT,3,R8,8.0);
7107 VARPOW(UI8,2,UINT,3,R8,8.0);
7109 VARPOW(INT,2,EMPTY,0,R8,1.0);
7110 VARPOW(INT,2,NULL,0,NULL,0);
7111 VARPOW(INT,2,I2,3,R8,8.0);
7112 VARPOW(INT,2,I4,3,R8,8.0);
7113 VARPOW(INT,2,R4,3.0f,R8,8.0);
7114 VARPOW(INT,2,R8,3.0,R8,8.0);
7115 VARPOW(INT,2,DATE,3,R8,8.0);
7116 VARPOW(INT,2,BSTR,num3_str,R8,8.0);
7117 VARPOW(INT,2,BOOL,VARIANT_FALSE,R8,1.0);
7118 VARPOW(INT,2,I1,3,R8,8.0);
7119 VARPOW(INT,2,UI1,3,R8,8.0);
7120 VARPOW(INT,2,UI2,3,R8,8.0);
7121 VARPOW(INT,2,UI4,3,R8,8.0);
7122 if (HAVE_OLEAUT32_I8)
7124 VARPOW(INT,2,I8,3,R8,8.0);
7125 VARPOW(INT,2,UI8,3,R8,8.0);
7127 VARPOW(INT,2,INT,3,R8,8.0);
7128 VARPOW(INT,2,UINT,3,R8,8.0);
7129 VARPOW(UINT,2,EMPTY,0,R8,1.0);
7130 VARPOW(UINT,2,NULL,0,NULL,0);
7131 VARPOW(UINT,2,I2,3,R8,8.0);
7132 VARPOW(UINT,2,I4,3,R8,8.0);
7133 VARPOW(UINT,2,R4,3.0f,R8,8.0);
7134 VARPOW(UINT,2,R8,3.0,R8,8.0);
7135 VARPOW(UINT,2,DATE,3,R8,8.0);
7136 VARPOW(UINT,2,BSTR,num3_str,R8,8.0);
7137 VARPOW(UINT,2,BOOL,VARIANT_FALSE,R8,1.0);
7138 VARPOW(UINT,2,I1,3,R8,8.0);
7139 VARPOW(UINT,2,UI1,3,R8,8.0);
7140 VARPOW(UINT,2,UI2,3,R8,8.0);
7141 VARPOW(UINT,2,UI4,3,R8,8.0);
7142 if (HAVE_OLEAUT32_I8)
7144 VARPOW(UINT,2,I8,3,R8,8.0);
7145 VARPOW(UINT,2,UI8,3,R8,8.0);
7147 VARPOW(UINT,2,INT,3,R8,8.0);
7148 VARPOW(UINT,2,UINT,3,R8,8.0);
7150 /* Manually test some VT_CY, VT_DECIMAL variants */
7152 hres = VarCyFromI4(2, &V_CY(&cy));
7153 ok(hres == S_OK, "VarCyFromI4 failed!\n");
7154 V_VT(&dec) = VT_DECIMAL;
7155 hres = VarDecFromR8(2.0, &V_DECIMAL(&dec));
7156 ok(hres == S_OK, "VarDecFromR4 failed!\n");
7157 memset(&left, 0, sizeof(left));
7158 memset(&right, 0, sizeof(right));
7159 V_VT(&left) = VT_I4;
7161 V_VT(&right) = VT_I8;
7164 hres = pVarPow(&cy, &cy, &result);
7165 ok(hres == S_OK && V_VT(&result) == VT_R8,
7166 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
7167 S_OK, hres, vtstr(V_VT(&result)));
7168 ok(hres == S_OK && EQ_DOUBLE(V_R8(&result), 4.0),
7169 "VARPOW: CY value %f, expected %f\n", V_R8(&result), 4.0);
7171 hres = pVarPow(&cy, &right, &result);
7174 ok(hres == S_OK && V_VT(&result) == VT_R8,
7175 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
7176 S_OK, hres, vtstr(V_VT(&result)));
7177 ok(hres == S_OK && EQ_DOUBLE(V_R8(&result), 4.0),
7178 "VARPOW: CY value %f, expected %f\n", V_R8(&result), 4.0);
7182 ok(hres == DISP_E_BADVARTYPE && V_VT(&result) == VT_EMPTY,
7183 "VARPOW: expected coerced hres 0x%X type VT_EMPTY, got hres 0x%X type %s!\n",
7184 DISP_E_BADVARTYPE, hres, vtstr(V_VT(&result)));
7187 hres = pVarPow(&left, &cy, &result);
7188 ok(hres == S_OK && V_VT(&result) == VT_R8,
7189 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
7190 S_OK, hres, vtstr(V_VT(&result)));
7191 ok(hres == S_OK && EQ_DOUBLE(V_R8(&result), 10000.0),
7192 "VARPOW: CY value %f, expected %f\n", V_R8(&result), 10000.0);
7194 hres = pVarPow(&left, &dec, &result);
7195 ok(hres == S_OK && V_VT(&result) == VT_R8,
7196 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
7197 S_OK, hres, vtstr(V_VT(&result)));
7198 ok(hres == S_OK && EQ_DOUBLE(V_R8(&result),10000.0),
7199 "VARPOW: DECIMAL value %f, expected %f\n", V_R8(&result), 10000.0);
7201 hres = pVarPow(&dec, &dec, &result);
7202 ok(hres == S_OK && V_VT(&result) == VT_R8,
7203 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
7204 S_OK, hres, vtstr(V_VT(&result)));
7205 ok(hres == S_OK && EQ_DOUBLE(V_R8(&result), 4.0),
7206 "VARPOW: DECIMAL value %f, expected %f\n", V_R8(&result), 4.0);
7208 hres = pVarPow(&dec, &right, &result);
7211 ok(hres == S_OK && V_VT(&result) == VT_R8,
7212 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
7213 S_OK, hres, vtstr(V_VT(&result)));
7214 ok(hres == S_OK && EQ_DOUBLE(V_R8(&result), 4.0),
7215 "VARPOW: DECIMAL value %f, expected %f\n", V_R8(&result), 4.0);
7219 ok(hres == DISP_E_BADVARTYPE && V_VT(&result) == VT_EMPTY,
7220 "VARPOW: expected coerced hres 0x%X type VT_EMPTY, got hres 0x%X type %s!\n",
7221 DISP_E_BADVARTYPE, hres, vtstr(V_VT(&result)));
7224 SysFreeString(num2_str);
7225 SysFreeString(num3_str);
7228 static HRESULT (WINAPI *pVarDiv)(LPVARIANT,LPVARIANT,LPVARIANT);
7230 #define VARDIV(vt1,val1,vt2,val2,rvt,rval) \
7231 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
7232 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
7233 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
7234 test_var_call2( __LINE__, pVarDiv, &left, &right, &exp )
7236 /* Skip any type that is not defined or produces an error for every case */
7237 #define SKIPTESTDIV(a) \
7238 if (a == VT_ERROR || a == VT_VARIANT || \
7239 a == VT_DISPATCH || a == VT_UNKNOWN || \
7240 a == VT_RECORD || a > VT_UINT || \
7241 a == VT_I1 || a == VT_UI8 || \
7242 a == VT_INT || a == VT_UINT || \
7243 a == VT_UI2 || a == VT_UI4 || \
7244 a == 15 /*not defined*/) \
7247 static void test_VarDiv(void)
7249 static const WCHAR str1[] = { '1','\0' };
7250 static const WCHAR str2[] = { '2','\0' };
7251 VARIANT left, right, exp, result, cy, dec;
7252 BSTR num1_str, num2_str;
7257 num1_str = SysAllocString(str1);
7258 num2_str = SysAllocString(str2);
7262 /* Test all possible flag/vt combinations & the resulting vt type */
7263 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
7265 VARTYPE leftvt, rightvt, resvt;
7267 for (leftvt = 0; leftvt <= VT_BSTR_BLOB; leftvt++)
7269 SKIPTESTDIV(leftvt);
7271 /* Check if we need/have support for I8 */
7272 if (leftvt == VT_I8 && !HAVE_OLEAUT32_I8)
7275 for (rightvt = 0; rightvt <= VT_BSTR_BLOB; rightvt++)
7278 SKIPTESTDIV(rightvt);
7280 /* Check if we need/have support for I8 */
7281 if (rightvt == VT_I8 && !HAVE_OLEAUT32_I8)
7284 /* Native crashes with VT_BYREF */
7285 if (ExtraFlags[i] == VT_BYREF)
7288 memset(&left, 0, sizeof(left));
7289 memset(&right, 0, sizeof(right));
7290 V_VT(&left) = leftvt | ExtraFlags[i];
7291 V_VT(&right) = rightvt | ExtraFlags[i];
7292 V_VT(&result) = VT_EMPTY;
7295 if (leftvt == VT_BSTR)
7296 V_BSTR(&left) = num2_str;
7297 else if (leftvt == VT_DECIMAL)
7299 VarDecFromR8(2.0, &V_DECIMAL(&left));
7300 V_VT(&left) = leftvt | ExtraFlags[i];
7303 /* Division by 0 is undefined */
7307 V_BSTR(&right) = num2_str;
7310 VarDecFromR8(2.0, &V_DECIMAL(&right));
7311 V_VT(&right) = rightvt | ExtraFlags[i];
7314 V_BOOL(&right) = VARIANT_TRUE;
7316 case VT_I2: V_I2(&right) = 2; break;
7317 case VT_I4: V_I4(&right) = 2; break;
7318 case VT_R4: V_R4(&right) = 2.0f; break;
7319 case VT_R8: V_R8(&right) = 2.0; break;
7320 case VT_CY: V_CY(&right).int64 = 2; break;
7321 case VT_DATE: V_DATE(&right) = 2; break;
7322 case VT_UI1: V_UI1(&right) = 2; break;
7323 case VT_I8: V_I8(&right) = 2; break;
7327 /* Determine return type */
7328 if (!(rightvt == VT_EMPTY))
7330 if (leftvt == VT_NULL || rightvt == VT_NULL)
7332 else if (leftvt == VT_DECIMAL || rightvt == VT_DECIMAL)
7334 else if (leftvt == VT_I8 || rightvt == VT_I8 ||
7335 leftvt == VT_CY || rightvt == VT_CY ||
7336 leftvt == VT_DATE || rightvt == VT_DATE ||
7337 leftvt == VT_I4 || rightvt == VT_I4 ||
7338 leftvt == VT_BSTR || rightvt == VT_BSTR ||
7339 leftvt == VT_I2 || rightvt == VT_I2 ||
7340 leftvt == VT_BOOL || rightvt == VT_BOOL ||
7341 leftvt == VT_R8 || rightvt == VT_R8 ||
7342 leftvt == VT_UI1 || rightvt == VT_UI1)
7344 if ((leftvt == VT_UI1 && rightvt == VT_R4) ||
7345 (leftvt == VT_R4 && rightvt == VT_UI1))
7347 else if ((leftvt == VT_R4 && (rightvt == VT_BOOL ||
7348 rightvt == VT_I2)) || (rightvt == VT_R4 &&
7349 (leftvt == VT_BOOL || leftvt == VT_I2)))
7354 else if (leftvt == VT_R4 || rightvt == VT_R4)
7357 else if (leftvt == VT_NULL && rightvt == VT_EMPTY)
7362 /* Native VarDiv always returns an error when using extra flags */
7363 if (ExtraFlags[i] != 0)
7366 hres = pVarDiv(&left, &right, &result);
7368 /* Check expected HRESULT and if result variant type is correct */
7370 ok (hres == DISP_E_BADVARTYPE || hres == DISP_E_TYPEMISMATCH ||
7371 hres == DISP_E_OVERFLOW || hres == DISP_E_DIVBYZERO,
7372 "VarDiv: %s|0x%X, %s|0x%X: got vt %s hr 0x%X\n",
7373 vtstr(leftvt), ExtraFlags[i], vtstr(rightvt), ExtraFlags[i],
7374 vtstr(V_VT(&result)), hres);
7376 ok (hres == S_OK && resvt == V_VT(&result),
7377 "VarDiv: %s|0x%X, %s|0x%X: expected vt %s hr 0x%X, got vt %s hr 0x%X\n",
7378 vtstr(leftvt), ExtraFlags[i], vtstr(rightvt), ExtraFlags[i], vtstr(resvt),
7379 S_OK, vtstr(V_VT(&result)), hres);
7384 /* Test return values for all the good cases */
7385 VARDIV(EMPTY,0,NULL,0,NULL,0);
7386 VARDIV(EMPTY,0,I2,2,R8,0.0);
7387 VARDIV(EMPTY,0,I4,2,R8,0.0);
7388 VARDIV(EMPTY,0,R4,2.0f,R4,0.0f);
7389 VARDIV(EMPTY,0,R8,2.0,R8,0.0);
7390 VARDIV(EMPTY,0,DATE,2.0,R8,0.0);
7391 VARDIV(EMPTY,0,BSTR,num2_str,R8,0.0);
7392 VARDIV(EMPTY,0,BOOL,VARIANT_TRUE,R8,0.0);
7393 VARDIV(EMPTY,0,UI1,2,R8,0.0);
7394 if (HAVE_OLEAUT32_I8)
7396 VARDIV(EMPTY,0,I8,2,R8,0.0);
7398 VARDIV(NULL,0,EMPTY,0,NULL,0);
7399 VARDIV(NULL,0,NULL,0,NULL,0);
7400 VARDIV(NULL,0,I2,2,NULL,0);
7401 VARDIV(NULL,0,I4,2,NULL,0);
7402 VARDIV(NULL,0,R4,2.0f,NULL,0);
7403 VARDIV(NULL,0,R8,2.0,NULL,0);
7404 VARDIV(NULL,0,DATE,2,NULL,0);
7405 VARDIV(NULL,0,BSTR,num2_str,NULL,0);
7406 VARDIV(NULL,0,BOOL,VARIANT_TRUE,NULL,0);
7407 VARDIV(NULL,0,UI1,2,NULL,0);
7408 if (HAVE_OLEAUT32_I8)
7410 VARDIV(NULL,0,I8,2,NULL,0);
7412 VARDIV(I2,2,NULL,0,NULL,0);
7413 VARDIV(I2,1,I2,2,R8,0.5);
7414 VARDIV(I2,1,I4,2,R8,0.5);
7415 VARDIV(I2,1,R4,2,R4,0.5f);
7416 VARDIV(I2,1,R8,2.0,R8,0.5);
7417 VARDIV(I2,1,DATE,2,R8,0.5);
7418 VARDIV(I2,1,BOOL,VARIANT_TRUE,R8,-1.0);
7419 VARDIV(I2,1,UI1,2,R8,0.5);
7420 if (HAVE_OLEAUT32_I8)
7422 VARDIV(I2,1,I8,2,R8,0.5);
7424 VARDIV(I4,1,NULL,0,NULL,0);
7425 VARDIV(I4,1,I2,2,R8,0.5);
7426 VARDIV(I4,1,I4,2,R8,0.5);
7427 VARDIV(I4,1,R4,2.0f,R8,0.5);
7428 VARDIV(I4,1,R8,2.0,R8,0.5);
7429 VARDIV(I4,1,DATE,2,R8,0.5);
7430 VARDIV(I4,1,BSTR,num2_str,R8,0.5);
7431 VARDIV(I4,1,BOOL,VARIANT_TRUE,R8,-1.0);
7432 VARDIV(I4,1,UI1,2,R8,0.5);
7433 if (HAVE_OLEAUT32_I8)
7435 VARDIV(I4,1,I8,2,R8,0.5);
7437 VARDIV(R4,1.0f,NULL,0,NULL,0);
7438 VARDIV(R4,1.0f,I2,2,R4,0.5f);
7439 VARDIV(R4,1.0f,I4,2,R8,0.5);
7440 VARDIV(R4,1.0f,R4,2.0f,R4,0.5f);
7441 VARDIV(R4,1.0f,R8,2.0,R8,0.5);
7442 VARDIV(R4,1.0f,DATE,2,R8,0.5);
7443 VARDIV(R4,1.0f,BSTR,num2_str,R8,0.5);
7444 VARDIV(R4,1.0f,BOOL,VARIANT_TRUE,R4,-1);
7445 VARDIV(R4,1.0f,UI1,2,R4,0.5f);
7446 if (HAVE_OLEAUT32_I8)
7448 VARDIV(R4,1.0f,I8,2,R8,0.5);
7450 VARDIV(R8,1.0,NULL,0,NULL,0);
7451 VARDIV(R8,1.0,I2,2,R8,0.5);
7452 VARDIV(R8,1.0,I4,2,R8,0.5);
7453 VARDIV(R8,1.0,R4,2.0f,R8,0.5);
7454 VARDIV(R8,1.0,R8,2.0,R8,0.5);
7455 VARDIV(R8,1.0,DATE,2,R8,0.5);
7456 VARDIV(R8,1.0,BSTR,num2_str,R8,0.5);
7457 VARDIV(R8,1.0,BOOL,VARIANT_TRUE,R8,-1.0);
7458 VARDIV(R8,1.0,UI1,2,R8,0.5);
7459 if (HAVE_OLEAUT32_I8)
7461 VARDIV(R8,1.0,I8,2,R8,0.5);
7463 VARDIV(DATE,1,NULL,0,NULL,0);
7464 VARDIV(DATE,1,I2,2,R8,0.5);
7465 VARDIV(DATE,1,I4,2,R8,0.5);
7466 VARDIV(DATE,1,R4,2.0f,R8,0.5);
7467 VARDIV(DATE,1,R8,2.0,R8,0.5);
7468 VARDIV(DATE,1,DATE,2,R8,0.5);
7469 VARDIV(DATE,1,BSTR,num2_str,R8,0.5);
7470 VARDIV(DATE,1,BOOL,VARIANT_TRUE,R8,-1.0);
7471 VARDIV(DATE,1,UI1,2,R8,0.5);
7472 if (HAVE_OLEAUT32_I8)
7474 VARDIV(DATE,1,I8,2,R8,0.5);
7476 VARDIV(BSTR,num1_str,NULL,0,NULL,0);
7477 VARDIV(BSTR,num1_str,I2,2,R8,0.5);
7478 VARDIV(BSTR,num1_str,I4,2,R8,0.5);
7479 VARDIV(BSTR,num1_str,R4,2.0f,R8,0.5);
7480 VARDIV(BSTR,num1_str,R8,2.0,R8,0.5);
7481 VARDIV(BSTR,num1_str,DATE,2,R8,0.5);
7482 VARDIV(BSTR,num1_str,BSTR,num2_str,R8,0.5);
7483 VARDIV(BSTR,num1_str,BOOL,VARIANT_TRUE,R8,-1);
7484 VARDIV(BSTR,num1_str,UI1,2,R8,0.5);
7485 if (HAVE_OLEAUT32_I8)
7487 VARDIV(BSTR,num1_str,I8,2,R8,0.5);
7489 VARDIV(BOOL,VARIANT_TRUE,NULL,0,NULL,0);
7490 VARDIV(BOOL,VARIANT_TRUE,I2,1,R8,-1.0);
7491 VARDIV(BOOL,VARIANT_FALSE,I2,1,R8,0.0);
7492 VARDIV(BOOL,VARIANT_TRUE,I4,1,R8,-1.0);
7493 VARDIV(BOOL,VARIANT_FALSE,I4,1,R8,0.0);
7494 VARDIV(BOOL,VARIANT_TRUE,R4,1,R4,-1.0f);
7495 VARDIV(BOOL,VARIANT_FALSE,R4,1,R4,0.0f);
7496 VARDIV(BOOL,VARIANT_TRUE,R8,1.0,R8,-1.0);
7497 VARDIV(BOOL,VARIANT_FALSE,R8,1.0,R8,0.0);
7498 VARDIV(BOOL,VARIANT_FALSE,DATE,2,R8,0.0);
7499 VARDIV(BOOL,VARIANT_FALSE,BSTR,num2_str,R8,0.0);
7500 VARDIV(BOOL,VARIANT_TRUE,BOOL,VARIANT_TRUE,R8,1.0);
7501 VARDIV(BOOL,VARIANT_FALSE,BOOL,VARIANT_TRUE,R8,0.0);
7502 VARDIV(BOOL,VARIANT_TRUE,UI1,1,R8,-1.0);
7503 if (HAVE_OLEAUT32_I8)
7505 VARDIV(BOOL,VARIANT_TRUE,I8,1,R8,-1.0);
7507 VARDIV(UI1,1,NULL,0,NULL,0);
7508 VARDIV(UI1,1,I2,2,R8,0.5);
7509 VARDIV(UI1,1,I4,2,R8,0.5);
7510 VARDIV(UI1,1,R4,2.0f,R4,0.5f);
7511 VARDIV(UI1,1,R8,2.0,R8,0.5);
7512 VARDIV(UI1,1,DATE,2,R8,0.5);
7513 VARDIV(UI1,1,BSTR,num2_str,R8,0.5);
7514 VARDIV(UI1,1,BOOL,VARIANT_TRUE,R8,-1);
7515 VARDIV(UI1,1,UI1,2,R8,0.5);
7516 if (HAVE_OLEAUT32_I8)
7518 VARDIV(UI1,1,I8,2,R8,0.5);
7519 VARDIV(I8,1,NULL,0,NULL,0);
7520 VARDIV(I8,1,I2,2,R8,0.5);
7521 VARDIV(I8,1,I4,2,R8,0.5);
7522 VARDIV(I8,1,R4,2.0f,R8,0.5);
7523 VARDIV(I8,1,R8,2.0,R8,0.5);
7524 VARDIV(I8,1,DATE,2,R8,0.5);
7525 VARDIV(I8,1,BSTR,num2_str,R8,0.5);
7526 VARDIV(I8,1,BOOL,VARIANT_TRUE,R8,-1);
7527 VARDIV(I8,1,UI1,2,R8,0.5);
7528 VARDIV(I8,1,I8,2,R8,0.5);
7531 /* Manually test some VT_CY, VT_DECIMAL variants */
7533 hres = VarCyFromI4(10000, &V_CY(&cy));
7534 ok(hres == S_OK, "VarCyFromI4 failed!\n");
7535 V_VT(&dec) = VT_DECIMAL;
7536 hres = VarDecFromR8(2.0, &V_DECIMAL(&dec));
7537 ok(hres == S_OK, "VarDecFromR4 failed!\n");
7538 memset(&left, 0, sizeof(left));
7539 memset(&right, 0, sizeof(right));
7540 V_VT(&left) = VT_I4;
7542 V_VT(&right) = VT_UI1;
7545 hres = pVarDiv(&cy, &cy, &result);
7546 ok(hres == S_OK && V_VT(&result) == VT_R8,
7547 "VARDIV: expected coerced type VT_R8, got %s!\n", vtstr(V_VT(&result)));
7548 ok(hres == S_OK && EQ_DOUBLE(V_R8(&result), 1.0),
7549 "VARDIV: CY value %f, expected %f\n", V_R8(&result), (double)1.0);
7551 hres = pVarDiv(&cy, &right, &result);
7552 ok(hres == S_OK && V_VT(&result) == VT_R8,
7553 "VARDIV: expected coerced type VT_R8, got %s!\n", vtstr(V_VT(&result)));
7554 ok(hres == S_OK && EQ_DOUBLE(V_R8(&result), 5000.0),
7555 "VARDIV: CY value %f, expected %f\n", V_R8(&result), (double)5000.0);
7557 hres = pVarDiv(&left, &cy, &result);
7558 ok(hres == S_OK && V_VT(&result) == VT_R8,
7559 "VARDIV: expected coerced type VT_R8, got %s!\n", vtstr(V_VT(&result)));
7560 ok(hres == S_OK && EQ_DOUBLE(V_R8(&result), 0.01),
7561 "VARDIV: CY value %f, expected %f\n", V_R8(&result), (double)0.01);
7563 hres = pVarDiv(&left, &dec, &result);
7564 ok(hres == S_OK && V_VT(&result) == VT_DECIMAL,
7565 "VARDIV: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result)));
7566 hres = VarR8FromDec(&V_DECIMAL(&result), &r);
7567 ok(hres == S_OK && EQ_DOUBLE(r, 50.0),
7568 "VARDIV: DECIMAL value %f, expected %f\n", r, (double)50.0);
7570 hres = pVarDiv(&dec, &dec, &result);
7571 ok(hres == S_OK && V_VT(&result) == VT_DECIMAL,
7572 "VARDIV: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result)));
7573 hres = VarR8FromDec(&V_DECIMAL(&result), &r);
7574 ok(hres == S_OK && EQ_DOUBLE(r, 1.0),
7575 "VARDIV: DECIMAL value %f, expected %f\n", r, (double)1.0);
7577 hres = pVarDiv(&dec, &right, &result);
7578 ok(hres == S_OK && V_VT(&result) == VT_DECIMAL,
7579 "VARDIV: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result)));
7580 hres = VarR8FromDec(&V_DECIMAL(&result), &r);
7581 ok(hres == S_OK && EQ_DOUBLE(r, 1.0),
7582 "VARDIV: DECIMAL value %f, expected %f\n", r, (double)1.0);
7584 /* Check for division by zero and overflow */
7585 V_VT(&left) = VT_R8;
7587 V_VT(&right) = VT_R8;
7589 hres = pVarDiv(&left, &right, &result);
7590 ok(hres == DISP_E_DIVBYZERO && V_VT(&result) == VT_EMPTY,
7591 "VARDIV: Division by (1.0/0.0) should result in DISP_E_DIVBYZERO but got 0x%X\n", hres);
7593 V_VT(&left) = VT_R8;
7595 V_VT(&right) = VT_R8;
7597 hres = pVarDiv(&left, &right, &result);
7598 ok(hres == DISP_E_OVERFLOW && V_VT(&result) == VT_EMPTY,
7599 "VARDIV: Division by (0.0/0.0) should result in DISP_E_OVERFLOW but got 0x%X\n", hres);
7601 SysFreeString(num1_str);
7602 SysFreeString(num2_str);
7605 static HRESULT (WINAPI *pVarIdiv)(LPVARIANT,LPVARIANT,LPVARIANT);
7607 #define VARIDIV(vt1,val1,vt2,val2,rvt,rval) \
7608 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
7609 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
7610 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
7611 test_var_call2( __LINE__, pVarIdiv, &left, &right, &exp )
7613 /* Skip any type that is not defined or produces an error for every case */
7614 #define SKIPTESTIDIV(a) \
7615 if (a == VT_ERROR || a == VT_VARIANT || \
7616 a == VT_DISPATCH || a == VT_UNKNOWN || \
7617 a == VT_RECORD || a > VT_UINT || \
7618 a == 15 /*not defined*/) \
7621 static void test_VarIdiv(void)
7623 static const WCHAR str1[] = { '1','\0' };
7624 static const WCHAR str2[] = { '2','\0' };
7625 VARIANT left, right, exp, result, cy, dec;
7626 BSTR num1_str, num2_str;
7632 num1_str = SysAllocString(str1);
7633 num2_str = SysAllocString(str2);
7635 /* Test all possible flag/vt combinations & the resulting vt type */
7636 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
7638 VARTYPE leftvt, rightvt, resvt;
7640 for (leftvt = 0; leftvt <= VT_BSTR_BLOB; leftvt++)
7642 SKIPTESTIDIV(leftvt);
7644 /* Check if we need/have support for I8 and/or UI8 */
7645 if ((leftvt == VT_I8 || leftvt == VT_UI8) && !HAVE_OLEAUT32_I8)
7648 for (rightvt = 0; rightvt <= VT_BSTR_BLOB; rightvt++)
7651 SKIPTESTIDIV(rightvt);
7653 /* Native crashes with extra flag VT_BYREF */
7654 if (ExtraFlags[i] == VT_BYREF)
7657 /* Check if we need/have support for I8 and/or UI8 */
7658 if ((rightvt == VT_I8 || rightvt == VT_UI8) && !HAVE_OLEAUT32_I8)
7661 memset(&left, 0, sizeof(left));
7662 memset(&right, 0, sizeof(right));
7663 V_VT(&left) = leftvt | ExtraFlags[i];
7664 V_VT(&right) = rightvt | ExtraFlags[i];
7665 V_VT(&result) = VT_EMPTY;
7668 if (leftvt == VT_BSTR)
7669 V_BSTR(&left) = num2_str;
7670 else if (leftvt == VT_DECIMAL)
7672 VarDecFromR8(2.0, &V_DECIMAL(&left));
7673 V_VT(&left) = leftvt | ExtraFlags[i];
7676 /* Division by 0 is undefined */
7680 V_BSTR(&right) = num2_str;
7683 VarDecFromR8(2.0, &V_DECIMAL(&right));
7684 V_VT(&right) = rightvt | ExtraFlags[i];
7687 V_BOOL(&right) = VARIANT_TRUE;
7690 VarCyFromI4(10000, &V_CY(&right));
7691 V_VT(&right) = rightvt | ExtraFlags[i];
7693 case VT_I2: V_I2(&right) = 2; break;
7694 case VT_I4: V_I4(&right) = 2; break;
7695 case VT_R4: V_R4(&right) = 2.0f; break;
7696 case VT_R8: V_R8(&right) = 2.0; break;
7697 case VT_DATE: V_DATE(&right) = 2; break;
7698 case VT_I1: V_I1(&right) = 2; break;
7699 case VT_UI1: V_UI1(&right) = 2; break;
7700 case VT_UI2: V_UI2(&right) = 2; break;
7701 case VT_UI4: V_UI4(&right) = 2; break;
7702 case VT_I8: V_I8(&right) = 2; break;
7703 case VT_UI8: V_UI8(&right) = 2; break;
7704 case VT_INT: V_INT(&right) = 2; break;
7705 case VT_UINT: V_UINT(&right) = 2; break;
7709 /* Native VarIdiv always returns an error when using extra
7710 * flags or if the variant combination is I8 and INT.
7712 if ((leftvt == VT_I8 && rightvt == VT_INT) ||
7713 (leftvt == VT_INT && rightvt == VT_I8) ||
7714 (rightvt == VT_EMPTY && leftvt != VT_NULL) ||
7718 /* Determine variant type */
7719 else if (leftvt == VT_NULL || rightvt == VT_NULL)
7721 else if (leftvt == VT_I8 || rightvt == VT_I8)
7723 else if (leftvt == VT_I4 || rightvt == VT_I4 ||
7724 leftvt == VT_INT || rightvt == VT_INT ||
7725 leftvt == VT_UINT || rightvt == VT_UINT ||
7726 leftvt == VT_UI8 || rightvt == VT_UI8 ||
7727 leftvt == VT_UI4 || rightvt == VT_UI4 ||
7728 leftvt == VT_UI2 || rightvt == VT_UI2 ||
7729 leftvt == VT_I1 || rightvt == VT_I1 ||
7730 leftvt == VT_BSTR || rightvt == VT_BSTR ||
7731 leftvt == VT_DATE || rightvt == VT_DATE ||
7732 leftvt == VT_CY || rightvt == VT_CY ||
7733 leftvt == VT_DECIMAL || rightvt == VT_DECIMAL ||
7734 leftvt == VT_R8 || rightvt == VT_R8 ||
7735 leftvt == VT_R4 || rightvt == VT_R4)
7737 else if (leftvt == VT_I2 || rightvt == VT_I2 ||
7738 leftvt == VT_BOOL || rightvt == VT_BOOL ||
7741 else if (leftvt == VT_UI1 || rightvt == VT_UI1)
7746 hres = pVarIdiv(&left, &right, &result);
7748 /* Check expected HRESULT and if result variant type is correct */
7750 ok (hres == DISP_E_BADVARTYPE || hres == DISP_E_TYPEMISMATCH ||
7751 hres == DISP_E_DIVBYZERO,
7752 "VarIdiv: %s|0x%X, %s|0x%X: got vt %s hr 0x%X\n",
7753 vtstr(leftvt), ExtraFlags[i], vtstr(rightvt), ExtraFlags[i],
7754 vtstr(V_VT(&result)), hres);
7756 ok (hres == S_OK && resvt == V_VT(&result),
7757 "VarIdiv: %s|0x%X, %s|0x%X: expected vt %s hr 0x%X, got vt %s hr 0x%X\n",
7758 vtstr(leftvt), ExtraFlags[i], vtstr(rightvt), ExtraFlags[i], vtstr(resvt),
7759 S_OK, vtstr(V_VT(&result)), hres);
7764 /* Test return values for all the good cases */
7765 VARIDIV(EMPTY,0,NULL,0,NULL,0);
7766 VARIDIV(EMPTY,0,I2,1,I2,0);
7767 VARIDIV(EMPTY,0,I4,1,I4,0);
7768 VARIDIV(EMPTY,0,R4,1.0f,I4,0);
7769 VARIDIV(EMPTY,0,R8,1.0,I4,0);
7770 VARIDIV(EMPTY,0,DATE,1.0,I4,0);
7771 VARIDIV(EMPTY,0,BSTR,num1_str,I4,0);
7772 VARIDIV(EMPTY,0,BOOL,VARIANT_TRUE,I2,0);
7773 VARIDIV(EMPTY,0,I1,1,I4,0);
7774 VARIDIV(EMPTY,0,UI1,1,I2,0);
7775 VARIDIV(EMPTY,0,UI2,1,I4,0);
7776 VARIDIV(EMPTY,0,UI4,1,I4,0);
7777 if (HAVE_OLEAUT32_I8)
7779 VARIDIV(EMPTY,0,I8,1,I8,0);
7780 VARIDIV(EMPTY,0,UI8,1,I4,0);
7782 VARIDIV(EMPTY,0,INT,1,I4,0);
7783 VARIDIV(EMPTY,0,UINT,1,I4,0);
7784 VARIDIV(NULL,0,EMPTY,0,NULL,0);
7785 VARIDIV(NULL,0,NULL,0,NULL,0);
7786 VARIDIV(NULL,0,I2,1,NULL,0);
7787 VARIDIV(NULL,0,I4,1,NULL,0);
7788 VARIDIV(NULL,0,R4,1,NULL,0);
7789 VARIDIV(NULL,0,R8,1,NULL,0);
7790 VARIDIV(NULL,0,DATE,1,NULL,0);
7791 VARIDIV(NULL,0,BSTR,num1_str,NULL,0);
7792 VARIDIV(NULL,0,BOOL,VARIANT_TRUE,NULL,0);
7793 VARIDIV(NULL,0,I1,1,NULL,0);
7794 VARIDIV(NULL,0,UI1,1,NULL,0);
7795 VARIDIV(NULL,0,UI2,1,NULL,0);
7796 VARIDIV(NULL,0,UI4,1,NULL,0);
7797 if (HAVE_OLEAUT32_I8)
7799 VARIDIV(NULL,0,I8,1,NULL,0);
7800 VARIDIV(NULL,0,UI8,1,NULL,0);
7802 VARIDIV(NULL,0,INT,1,NULL,0);
7803 VARIDIV(NULL,0,UINT,1,NULL,0);
7804 VARIDIV(I2,2,NULL,0,NULL,0);
7805 VARIDIV(I2,2,I2,1,I2,2);
7806 VARIDIV(I2,2,I4,1,I4,2);
7807 VARIDIV(I2,2,R4,1,I4,2);
7808 VARIDIV(I2,2,R8,1,I4,2);
7809 VARIDIV(I2,2,DATE,1,I4,2);
7810 VARIDIV(I2,2,BSTR,num1_str,I4,2);
7811 VARIDIV(I2,2,BOOL,VARIANT_TRUE,I2,-2);
7812 VARIDIV(I2,2,I1,1,I4,2);
7813 VARIDIV(I2,2,UI1,1,I2,2);
7814 VARIDIV(I2,2,UI2,1,I4,2);
7815 VARIDIV(I2,2,UI4,1,I4,2);
7816 if (HAVE_OLEAUT32_I8)
7818 VARIDIV(I2,2,I8,1,I8,2);
7819 VARIDIV(I2,2,UI8,1,I4,2);
7821 VARIDIV(I2,2,INT,1,I4,2);
7822 VARIDIV(I2,2,UINT,1,I4,2);
7823 VARIDIV(I4,2,NULL,0,NULL,0);
7824 VARIDIV(I4,2,I2,1,I4,2);
7825 VARIDIV(I4,2,I4,1,I4,2);
7826 VARIDIV(I4,2,R4,1,I4,2);
7827 VARIDIV(I4,2,R8,1,I4,2);
7828 VARIDIV(I4,2,DATE,1,I4,2);
7829 VARIDIV(I4,2,BSTR,num1_str,I4,2);
7830 VARIDIV(I4,2,BOOL,VARIANT_TRUE,I4,-2);
7831 VARIDIV(I4,2,I1,1,I4,2);
7832 VARIDIV(I4,2,UI1,1,I4,2);
7833 VARIDIV(I4,2,UI2,1,I4,2);
7834 VARIDIV(I4,2,UI4,1,I4,2);
7835 if (HAVE_OLEAUT32_I8)
7837 VARIDIV(I4,2,I8,1,I8,2);
7838 VARIDIV(I4,2,UI8,1,I4,2);
7840 VARIDIV(I4,2,INT,1,I4,2);
7841 VARIDIV(I4,2,UINT,1,I4,2);
7842 VARIDIV(R4,2.0f,NULL,0,NULL,0);
7843 VARIDIV(R4,2.0f,I2,1,I4,2);
7844 VARIDIV(R4,2.0f,I4,1,I4,2);
7845 VARIDIV(R4,2.0f,R4,1.0f,I4,2);
7846 VARIDIV(R4,2.0f,R8,1.0,I4,2);
7847 VARIDIV(R4,2.0f,DATE,1,I4,2);
7848 VARIDIV(R4,2.0f,BSTR,num1_str,I4,2);
7849 VARIDIV(R4,2.0f,BOOL,VARIANT_TRUE,I4,-2);
7850 VARIDIV(R4,2.0f,I1,1,I4,2);
7851 VARIDIV(R4,2.0f,UI1,1,I4,2);
7852 VARIDIV(R4,2.0f,UI2,1,I4,2);
7853 VARIDIV(R4,2.0f,UI4,1,I4,2);
7854 if (HAVE_OLEAUT32_I8)
7856 VARIDIV(R4,2.0f,I8,1,I8,2);
7857 VARIDIV(R4,2.0f,UI8,1,I4,2);
7859 VARIDIV(R4,2.0f,INT,1,I4,2);
7860 VARIDIV(R4,2.0f,UINT,1,I4,2);
7861 VARIDIV(R8,2.0,NULL,0,NULL,0);
7862 VARIDIV(R8,2.0,I2,1,I4,2);
7863 VARIDIV(R8,2.0,I4,1,I4,2);
7864 VARIDIV(R8,2.0,R4,1,I4,2);
7865 VARIDIV(R8,2.0,R8,1,I4,2);
7866 VARIDIV(R8,2.0,DATE,1,I4,2);
7867 VARIDIV(R8,2.0,BSTR,num1_str,I4,2);
7868 VARIDIV(R8,2.0,BOOL,VARIANT_TRUE,I4,-2);
7869 VARIDIV(R8,2.0,I1,1,I4,2);
7870 VARIDIV(R8,2.0,UI1,1,I4,2);
7871 VARIDIV(R8,2.0,UI2,1,I4,2);
7872 VARIDIV(R8,2.0,UI4,1,I4,2);
7873 if (HAVE_OLEAUT32_I8)
7875 VARIDIV(R8,2.0,I8,1,I8,2);
7876 VARIDIV(R8,2.0,UI8,1,I4,2);
7878 VARIDIV(R8,2.0,INT,1,I4,2);
7879 VARIDIV(R8,2.0,UINT,1,I4,2);
7880 VARIDIV(DATE,2,NULL,0,NULL,0);
7881 VARIDIV(DATE,2,I2,1,I4,2);
7882 VARIDIV(DATE,2,I4,1,I4,2);
7883 VARIDIV(DATE,2,R4,1,I4,2);
7884 VARIDIV(DATE,2,R8,1,I4,2);
7885 VARIDIV(DATE,2,DATE,1,I4,2);
7886 VARIDIV(DATE,2,BSTR,num1_str,I4,2);
7887 VARIDIV(DATE,2,BOOL,VARIANT_TRUE,I4,-2);
7888 VARIDIV(DATE,2,I1,1,I4,2);
7889 VARIDIV(DATE,2,UI1,1,I4,2);
7890 VARIDIV(DATE,2,UI2,1,I4,2);
7891 VARIDIV(DATE,2,UI4,1,I4,2);
7892 if (HAVE_OLEAUT32_I8)
7894 VARIDIV(DATE,2,I8,1,I8,2);
7895 VARIDIV(DATE,2,UI8,1,I4,2);
7897 VARIDIV(DATE,2,INT,1,I4,2);
7898 VARIDIV(DATE,2,UINT,1,I4,2);
7899 VARIDIV(BSTR,num2_str,NULL,0,NULL,0);
7900 VARIDIV(BSTR,num2_str,I2,1,I4,2);
7901 VARIDIV(BSTR,num2_str,I4,1,I4,2);
7902 VARIDIV(BSTR,num2_str,R4,1.0f,I4,2);
7903 VARIDIV(BSTR,num2_str,R8,1.0,I4,2);
7904 VARIDIV(BSTR,num2_str,DATE,1,I4,2);
7905 VARIDIV(BSTR,num2_str,BSTR,num1_str,I4,2);
7906 VARIDIV(BSTR,num2_str,BOOL,VARIANT_TRUE,I4,-2);
7907 VARIDIV(BSTR,num2_str,I1,1,I4,2);
7908 VARIDIV(BSTR,num2_str,UI1,1,I4,2);
7909 VARIDIV(BSTR,num2_str,UI2,1,I4,2);
7910 VARIDIV(BSTR,num2_str,UI4,1,I4,2);
7911 if (HAVE_OLEAUT32_I8)
7913 VARIDIV(BSTR,num2_str,I8,1,I8,2);
7914 VARIDIV(BSTR,num2_str,UI8,1,I4,2);
7916 VARIDIV(BSTR,num2_str,INT,1,I4,2);
7917 VARIDIV(BSTR,num2_str,UINT,1,I4,2);
7918 VARIDIV(BOOL,VARIANT_TRUE,NULL,0,NULL,0);
7919 VARIDIV(BOOL,VARIANT_TRUE,I2,1,I2,-1);
7920 VARIDIV(BOOL,VARIANT_TRUE,I4,1,I4,-1);
7921 VARIDIV(BOOL,VARIANT_TRUE,R4,1.0f,I4,-1);
7922 VARIDIV(BOOL,VARIANT_TRUE,R8,1.0,I4,-1);
7923 VARIDIV(BOOL,VARIANT_TRUE,DATE,1,I4,-1);
7924 VARIDIV(BOOL,VARIANT_TRUE,BSTR,num1_str,I4,-1);
7925 VARIDIV(BOOL,VARIANT_TRUE,BOOL,VARIANT_TRUE,I2,1);
7926 VARIDIV(BOOL,VARIANT_TRUE,I1,1,I4,-1);
7927 VARIDIV(BOOL,VARIANT_TRUE,UI1,1,I2,-1);
7928 VARIDIV(BOOL,VARIANT_TRUE,UI2,1,I4,-1);
7929 VARIDIV(BOOL,VARIANT_TRUE,UI4,1,I4,-1);
7930 if (HAVE_OLEAUT32_I8)
7932 VARIDIV(BOOL,VARIANT_TRUE,I8,1,I8,-1);
7933 VARIDIV(BOOL,VARIANT_TRUE,UI8,1,I4,-1);
7935 VARIDIV(BOOL,VARIANT_TRUE,INT,1,I4,-1);
7936 VARIDIV(BOOL,VARIANT_TRUE,UINT,1,I4,-1);
7937 VARIDIV(I1,2,NULL,0,NULL,0);
7938 VARIDIV(I1,2,I2,1,I4,2);
7939 VARIDIV(I1,2,I4,1,I4,2);
7940 VARIDIV(I1,2,R4,1.0f,I4,2);
7941 VARIDIV(I1,2,R8,1.0,I4,2);
7942 VARIDIV(I1,2,DATE,1,I4,2);
7943 VARIDIV(I1,2,BSTR,num1_str,I4,2);
7944 VARIDIV(I1,2,BOOL,VARIANT_TRUE,I4,-2);
7945 VARIDIV(I1,2,I1,1,I4,2);
7946 VARIDIV(I1,2,UI1,1,I4,2);
7947 VARIDIV(I1,2,UI2,1,I4,2);
7948 VARIDIV(I1,2,UI4,1,I4,2);
7949 if (HAVE_OLEAUT32_I8)
7951 VARIDIV(I1,2,I8,1,I8,2);
7952 VARIDIV(I1,2,UI8,1,I4,2);
7954 VARIDIV(I1,2,INT,1,I4,2);
7955 VARIDIV(I1,2,UINT,1,I4,2);
7956 VARIDIV(UI1,2,NULL,0,NULL,0);
7957 VARIDIV(UI1,2,I2,1,I2,2);
7958 VARIDIV(UI1,2,I4,1,I4,2);
7959 VARIDIV(UI1,2,R4,1.0f,I4,2);
7960 VARIDIV(UI1,2,R8,1.0,I4,2);
7961 VARIDIV(UI1,2,DATE,1,I4,2);
7962 VARIDIV(UI1,2,BSTR,num1_str,I4,2);
7963 VARIDIV(UI1,2,BOOL,VARIANT_TRUE,I2,-2);
7964 VARIDIV(UI1,2,I1,1,I4,2);
7965 VARIDIV(UI1,2,UI1,1,UI1,2);
7966 VARIDIV(UI1,2,UI2,1,I4,2);
7967 VARIDIV(UI1,2,UI4,1,I4,2);
7968 if (HAVE_OLEAUT32_I8)
7970 VARIDIV(UI1,2,I8,1,I8,2);
7971 VARIDIV(UI1,2,UI8,1,I4,2);
7973 VARIDIV(UI1,2,INT,1,I4,2);
7974 VARIDIV(UI1,2,UINT,1,I4,2);
7975 VARIDIV(UI2,2,NULL,0,NULL,0);
7976 VARIDIV(UI2,2,I2,1,I4,2);
7977 VARIDIV(UI2,2,I4,1,I4,2);
7978 VARIDIV(UI2,2,R4,1.0f,I4,2);
7979 VARIDIV(UI2,2,R8,1.0,I4,2);
7980 VARIDIV(UI2,2,DATE,1,I4,2);
7981 VARIDIV(UI2,2,BSTR,num1_str,I4,2);
7982 VARIDIV(UI2,2,BOOL,VARIANT_TRUE,I4,-2);
7983 VARIDIV(UI2,2,I1,1,I4,2);
7984 VARIDIV(UI2,2,UI1,1,I4,2);
7985 VARIDIV(UI2,2,UI2,1,I4,2);
7986 VARIDIV(UI2,2,UI4,1,I4,2);
7987 if (HAVE_OLEAUT32_I8)
7989 VARIDIV(UI2,2,I8,1,I8,2);
7990 VARIDIV(UI2,2,UI8,1,I4,2);
7992 VARIDIV(UI2,2,INT,1,I4,2);
7993 VARIDIV(UI2,2,UINT,1,I4,2);
7994 VARIDIV(UI4,2,NULL,0,NULL,0);
7995 VARIDIV(UI4,2,I2,1,I4,2);
7996 VARIDIV(UI4,2,I4,1,I4,2);
7997 VARIDIV(UI4,2,R4,1.0f,I4,2);
7998 VARIDIV(UI4,2,R8,1.0,I4,2);
7999 VARIDIV(UI4,2,DATE,1,I4,2);
8000 VARIDIV(UI4,2,BSTR,num1_str,I4,2);
8001 VARIDIV(UI4,2,BOOL,VARIANT_TRUE,I4,-2);
8002 VARIDIV(UI4,2,I1,1,I4,2);
8003 VARIDIV(UI4,2,UI1,1,I4,2);
8004 VARIDIV(UI4,2,UI2,1,I4,2);
8005 VARIDIV(UI4,2,UI4,1,I4,2);
8006 if (HAVE_OLEAUT32_I8)
8008 VARIDIV(UI4,2,I8,1,I8,2);
8009 VARIDIV(UI4,2,UI8,1,I4,2);
8011 VARIDIV(UI4,2,INT,1,I4,2);
8012 VARIDIV(UI4,2,UINT,1,I4,2);
8013 if (HAVE_OLEAUT32_I8)
8015 VARIDIV(I8,2,NULL,0,NULL,0);
8016 VARIDIV(I8,2,I2,1,I8,2);
8017 VARIDIV(I8,2,I4,1,I8,2);
8018 VARIDIV(I8,2,R4,1.0f,I8,2);
8019 VARIDIV(I8,2,R8,1.0,I8,2);
8020 VARIDIV(I8,2,DATE,1,I8,2);
8021 VARIDIV(I8,2,BSTR,num1_str,I8,2);
8022 VARIDIV(I8,2,BOOL,1,I8,2);
8023 VARIDIV(I8,2,I1,1,I8,2);
8024 VARIDIV(I8,2,UI1,1,I8,2);
8025 VARIDIV(I8,2,UI2,1,I8,2);
8026 VARIDIV(I8,2,UI4,1,I8,2);
8027 VARIDIV(I8,2,I8,1,I8,2);
8028 VARIDIV(I8,2,UI8,1,I8,2);
8029 VARIDIV(I8,2,UINT,1,I8,2);
8030 VARIDIV(UI8,2,NULL,0,NULL,0);
8031 VARIDIV(UI8,2,I2,1,I4,2);
8032 VARIDIV(UI8,2,I4,1,I4,2);
8033 VARIDIV(UI8,2,R4,1.0f,I4,2);
8034 VARIDIV(UI8,2,R8,1.0,I4,2);
8035 VARIDIV(UI8,2,DATE,1,I4,2);
8036 VARIDIV(UI8,2,BSTR,num1_str,I4,2);
8037 VARIDIV(UI8,2,BOOL,VARIANT_TRUE,I4,-2);
8038 VARIDIV(UI8,2,I1,1,I4,2);
8039 VARIDIV(UI8,2,UI1,1,I4,2);
8040 VARIDIV(UI8,2,UI2,1,I4,2);
8041 VARIDIV(UI8,2,UI4,1,I4,2);
8042 VARIDIV(UI8,2,I8,1,I8,2);
8043 VARIDIV(UI8,2,UI8,1,I4,2);
8044 VARIDIV(UI8,2,INT,1,I4,2);
8045 VARIDIV(UI8,2,UINT,1,I4,2);
8047 VARIDIV(INT,2,NULL,0,NULL,0);
8048 VARIDIV(INT,2,I2,1,I4,2);
8049 VARIDIV(INT,2,I4,1,I4,2);
8050 VARIDIV(INT,2,R4,1.0f,I4,2);
8051 VARIDIV(INT,2,R8,1.0,I4,2);
8052 VARIDIV(INT,2,DATE,1,I4,2);
8053 VARIDIV(INT,2,BSTR,num1_str,I4,2);
8054 VARIDIV(INT,2,BOOL,VARIANT_TRUE,I4,-2);
8055 VARIDIV(INT,2,I1,1,I4,2);
8056 VARIDIV(INT,2,UI1,1,I4,2);
8057 VARIDIV(INT,2,UI2,1,I4,2);
8058 VARIDIV(INT,2,UI4,1,I4,2);
8059 if (HAVE_OLEAUT32_I8)
8061 VARIDIV(INT,2,UI8,1,I4,2);
8063 VARIDIV(INT,2,INT,1,I4,2);
8064 VARIDIV(INT,2,UINT,1,I4,2);
8065 VARIDIV(UINT,2,NULL,0,NULL,0);
8066 VARIDIV(UINT,2,I2,1,I4,2);
8067 VARIDIV(UINT,2,I4,1,I4,2);
8068 VARIDIV(UINT,2,R4,1.0f,I4,2);
8069 VARIDIV(UINT,2,R8,1.0,I4,2);
8070 VARIDIV(UINT,2,DATE,1,I4,2);
8071 VARIDIV(UINT,2,BSTR,num1_str,I4,2);
8072 VARIDIV(UINT,2,BOOL,VARIANT_TRUE,I4,-2);
8073 VARIDIV(UINT,2,I1,1,I4,2);
8074 VARIDIV(UINT,2,UI1,1,I4,2);
8075 VARIDIV(UINT,2,UI2,1,I4,2);
8076 VARIDIV(UINT,2,UI4,1,I4,2);
8077 if (HAVE_OLEAUT32_I8)
8079 VARIDIV(UINT,2,I8,1,I8,2);
8080 VARIDIV(UINT,2,UI8,1,I4,2);
8082 VARIDIV(UINT,2,INT,1,I4,2);
8083 VARIDIV(UINT,2,UINT,1,I4,2);
8085 /* Manually test some VT_CY, VT_DECIMAL variants */
8087 hres = VarCyFromI4(10000, &V_CY(&cy));
8088 ok(hres == S_OK, "VarCyFromI4 failed!\n");
8089 V_VT(&dec) = VT_DECIMAL;
8090 hres = VarDecFromR8(2.0, &V_DECIMAL(&dec));
8091 ok(hres == S_OK, "VarDecFromR4 failed!\n");
8092 memset(&left, 0, sizeof(left));
8093 memset(&right, 0, sizeof(right));
8094 V_VT(&left) = VT_I4;
8096 V_VT(&right) = VT_I8;
8099 hres = pVarIdiv(&cy, &cy, &result);
8100 ok(hres == S_OK && V_VT(&result) == VT_I4,
8101 "VARIDIV: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8102 S_OK, hres, vtstr(V_VT(&result)));
8103 ok(hres == S_OK && V_I4(&result) == 1,
8104 "VARIDIV: CY value %d, expected %d\n", V_I4(&result), 1);
8106 if (HAVE_OLEAUT32_I8)
8108 hres = pVarIdiv(&cy, &right, &result);
8109 ok(hres == S_OK && V_VT(&result) == VT_I8,
8110 "VARIDIV: expected coerced hres 0x%X type VT_I8, got hres 0x%X type %s!\n",
8111 S_OK, hres, vtstr(V_VT(&result)));
8112 ok(hres == S_OK && V_I8(&result) == 5000,
8113 "VARIDIV: CY value 0x%x%08x, expected 0x%x\n",
8114 (DWORD)(V_I8(&result) >>32), (DWORD)V_I8(&result), 5000);
8117 hres = pVarIdiv(&left, &cy, &result);
8118 ok(hres == S_OK && V_VT(&result) == VT_I4,
8119 "VARIDIV: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8120 S_OK, hres, vtstr(V_VT(&result)));
8121 ok(hres == S_OK && V_I4(&result) == 0,
8122 "VARIDIV: CY value %d, expected %d\n", V_I4(&result), 0);
8124 hres = pVarIdiv(&left, &dec, &result);
8125 ok(hres == S_OK && V_VT(&result) == VT_I4,
8126 "VARIDIV: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8127 S_OK, hres, vtstr(V_VT(&result)));
8128 ok(hres == S_OK && V_I4(&result) == 50,
8129 "VARIDIV: DECIMAL value %d, expected %d\n", V_I4(&result), 50);
8131 hres = pVarIdiv(&dec, &dec, &result);
8132 ok(hres == S_OK && V_VT(&result) == VT_I4,
8133 "VARIDIV: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8134 S_OK, hres, vtstr(V_VT(&result)));
8135 ok(hres == S_OK && V_I4(&result) == 1,
8136 "VARIDIV: DECIMAL value %d, expected %d\n", V_I4(&result), 1);
8138 if (HAVE_OLEAUT32_I8)
8140 hres = pVarIdiv(&dec, &right, &result);
8141 ok(hres == S_OK && V_VT(&result) == VT_I8,
8142 "VARIDIV: expected coerced hres 0x%X type VT_I8, got hres 0x%X type %s!\n",
8143 S_OK, hres, vtstr(V_VT(&result)));
8144 ok(hres == S_OK && V_I8(&result) == 1,
8145 "VARIDIV: DECIMAL value 0x%x%08x, expected %d\n",
8146 (DWORD)(V_I8(&result) >> 32), (DWORD)V_I8(&result), 1);
8149 /* Check for division by zero */
8150 V_VT(&left) = VT_INT;
8152 V_VT(&right) = VT_INT;
8154 hres = pVarIdiv(&left, &right, &result);
8155 ok(hres == DISP_E_DIVBYZERO && V_VT(&result) == VT_EMPTY,
8156 "VARIDIV: Division by 0 should result in DISP_E_DIVBYZERO but got 0x%X\n", hres);
8158 V_VT(&left) = VT_INT;
8160 V_VT(&right) = VT_INT;
8162 hres = pVarIdiv(&left, &right, &result);
8163 ok(hres == DISP_E_DIVBYZERO && V_VT(&result) == VT_EMPTY,
8164 "VARIDIV: Division by 0 should result in DISP_E_DIVBYZERO but got 0x%X\n", hres);
8166 SysFreeString(num1_str);
8167 SysFreeString(num2_str);
8171 static HRESULT (WINAPI *pVarImp)(LPVARIANT,LPVARIANT,LPVARIANT);
8173 #define VARIMP(vt1,val1,vt2,val2,rvt,rval) \
8174 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
8175 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
8176 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
8177 test_var_call2( __LINE__, pVarImp, &left, &right, &exp )
8179 /* Skip any type that is not defined or produces an error for every case */
8180 #define SKIPTESTIMP(a) \
8181 if (a == VT_ERROR || a == VT_VARIANT || \
8182 a == VT_DISPATCH || a == VT_UNKNOWN || \
8183 a == VT_RECORD || a > VT_UINT || \
8184 a == 15 /*not defined*/) \
8187 static void test_VarImp(void)
8189 static const WCHAR szFalse[] = { '#','F','A','L','S','E','#','\0' };
8190 static const WCHAR szTrue[] = { '#','T','R','U','E','#','\0' };
8191 VARIANT left, right, exp, result, cy, dec;
8192 BSTR true_str, false_str;
8198 true_str = SysAllocString(szTrue);
8199 false_str = SysAllocString(szFalse);
8201 /* Test all possible flag/vt combinations & the resulting vt type */
8202 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
8204 VARTYPE leftvt, rightvt, resvt;
8206 for (leftvt = 0; leftvt <= VT_BSTR_BLOB; leftvt++)
8208 SKIPTESTIMP(leftvt);
8210 /* Check if we need/have support for I8 and/or UI8 */
8211 if ((leftvt == VT_I8 || leftvt == VT_UI8) && !HAVE_OLEAUT32_I8)
8214 for (rightvt = 0; rightvt <= VT_BSTR_BLOB; rightvt++)
8217 SKIPTESTIMP(rightvt);
8219 /* Native crashes when using the extra flag VT_BYREF
8220 * or with the following VT combinations
8222 if ((leftvt == VT_UI4 && rightvt == VT_BSTR) ||
8223 (leftvt == VT_UI8 && rightvt == VT_BSTR) ||
8224 ExtraFlags[i] == VT_BYREF)
8227 /* Check if we need/have support for I8 and/or UI8 */
8228 if ((rightvt == VT_I8 || rightvt == VT_UI8) && !HAVE_OLEAUT32_I8)
8231 memset(&left, 0, sizeof(left));
8232 memset(&right, 0, sizeof(right));
8233 V_VT(&left) = leftvt | ExtraFlags[i];
8234 V_VT(&right) = rightvt | ExtraFlags[i];
8235 V_VT(&result) = VT_EMPTY;
8238 if (leftvt == VT_BSTR)
8239 V_BSTR(&left) = true_str;
8241 /* This allows us to test return types that are not NULL
8242 * (NULL Imp value = n, NULL Imp 0 = NULL)
8247 V_BSTR(&right) = true_str;
8250 VarDecFromR8(2.0, &V_DECIMAL(&right));
8251 V_VT(&right) = rightvt | ExtraFlags[i];
8254 V_BOOL(&right) = VARIANT_TRUE;
8256 case VT_I1: V_I1(&right) = 2; break;
8257 case VT_I2: V_I2(&right) = 2; break;
8258 case VT_I4: V_I4(&right) = 2; break;
8259 case VT_R4: V_R4(&right) = 2.0f; break;
8260 case VT_R8: V_R8(&right) = 2.0; break;
8261 case VT_CY: V_CY(&right).int64 = 10000; break;
8262 case VT_DATE: V_DATE(&right) = 2; break;
8263 case VT_I8: V_I8(&right) = 2; break;
8264 case VT_INT: V_INT(&right) = 2; break;
8265 case VT_UINT: V_UINT(&right) = 2; break;
8266 case VT_UI1: V_UI1(&right) = 2; break;
8267 case VT_UI2: V_UI2(&right) = 2; break;
8268 case VT_UI4: V_UI4(&right) = 2; break;
8269 case VT_UI8: V_UI8(&right) = 2; break;
8273 /* Native VarImp always returns an error when using extra
8274 * flags or if the variants are I8 and INT.
8276 if ((leftvt == VT_I8 && rightvt == VT_INT) ||
8280 /* Determine result type */
8281 else if ((leftvt == VT_BSTR && rightvt == VT_NULL) ||
8282 (leftvt == VT_NULL && rightvt == VT_NULL) ||
8283 (leftvt == VT_NULL && rightvt == VT_EMPTY))
8285 else if (leftvt == VT_I8 || rightvt == VT_I8)
8287 else if (leftvt == VT_I4 || rightvt == VT_I4 ||
8288 leftvt == VT_INT || rightvt == VT_INT ||
8289 leftvt == VT_UINT || rightvt == VT_UINT ||
8290 leftvt == VT_UI4 || rightvt == VT_UI4 ||
8291 leftvt == VT_UI8 || rightvt == VT_UI8 ||
8292 leftvt == VT_UI2 || rightvt == VT_UI2 ||
8293 leftvt == VT_DECIMAL || rightvt == VT_DECIMAL ||
8294 leftvt == VT_DATE || rightvt == VT_DATE ||
8295 leftvt == VT_CY || rightvt == VT_CY ||
8296 leftvt == VT_R8 || rightvt == VT_R8 ||
8297 leftvt == VT_R4 || rightvt == VT_R4 ||
8298 leftvt == VT_I1 || rightvt == VT_I1)
8300 else if ((leftvt == VT_UI1 && rightvt == VT_UI1) ||
8301 (leftvt == VT_UI1 && rightvt == VT_NULL) ||
8302 (leftvt == VT_NULL && rightvt == VT_UI1))
8304 else if (leftvt == VT_EMPTY || rightvt == VT_EMPTY ||
8305 leftvt == VT_I2 || rightvt == VT_I2 ||
8306 leftvt == VT_UI1 || rightvt == VT_UI1)
8308 else if (leftvt == VT_BOOL || rightvt == VT_BOOL ||
8309 leftvt == VT_BSTR || rightvt == VT_BSTR)
8312 hres = pVarImp(&left, &right, &result);
8314 /* Check expected HRESULT and if result variant type is correct */
8316 ok (hres == DISP_E_BADVARTYPE || hres == DISP_E_TYPEMISMATCH,
8317 "VarImp: %s|0x%X, %s|0x%X: got vt %s hr 0x%X\n",
8318 vtstr(leftvt), ExtraFlags[i], vtstr(rightvt), ExtraFlags[i],
8319 vtstr(V_VT(&result)), hres);
8321 ok (hres == S_OK && resvt == V_VT(&result),
8322 "VarImp: %s|0x%X, %s|0x%X: expected vt %s hr 0x%X, got vt %s hr 0x%X\n",
8323 vtstr(leftvt), ExtraFlags[i], vtstr(rightvt), ExtraFlags[i], vtstr(resvt),
8324 S_OK, vtstr(V_VT(&result)), hres);
8329 VARIMP(EMPTY,0,EMPTY,0,I2,-1);
8330 VARIMP(EMPTY,0,NULL,0,I2,-1);
8331 VARIMP(EMPTY,0,I2,-1,I2,-1);
8332 VARIMP(EMPTY,0,I4,-1,I4,-1);
8333 VARIMP(EMPTY,0,R4,0.0f,I4,-1);
8334 VARIMP(EMPTY,0,R8,-1.0,I4,-1);
8335 VARIMP(EMPTY,0,DATE,0,I4,-1);
8336 VARIMP(EMPTY,0,BSTR,true_str,I2,-1);
8337 VARIMP(EMPTY,0,BOOL,VARIANT_FALSE,I2,-1);
8338 VARIMP(EMPTY,0,I1,0,I4,-1);
8339 VARIMP(EMPTY,0,UI1,1,I2,-1);
8340 VARIMP(EMPTY,0,UI2,1,I4,-1);
8341 VARIMP(EMPTY,0,UI4,1,I4,-1);
8342 if (HAVE_OLEAUT32_I8)
8344 VARIMP(EMPTY,0,I8,1,I8,-1);
8345 VARIMP(EMPTY,0,UI8,1,I4,-1);
8347 VARIMP(EMPTY,0,INT,-1,I4,-1);
8348 VARIMP(EMPTY,0,UINT,1,I4,-1);
8349 VARIMP(NULL,0,EMPTY,0,NULL,0);
8350 VARIMP(NULL,0,NULL,0,NULL,0);
8351 VARIMP(NULL,0,I2,-1,I2,-1);
8352 VARIMP(NULL,0,I4,-1,I4,-1);
8353 VARIMP(NULL,0,R4,0.0f,NULL,0);
8354 VARIMP(NULL,0,R8,-1.0,I4,-1);
8355 VARIMP(NULL,0,DATE,0,NULL,0);
8356 VARIMP(NULL,0,BSTR,true_str,BOOL,-1);
8357 VARIMP(NULL,0,BOOL,VARIANT_FALSE,NULL,0);
8358 VARIMP(NULL,0,I1,0,NULL,0);
8359 VARIMP(NULL,0,UI1,1,UI1,1);
8360 VARIMP(NULL,0,UI2,1,I4,1);
8361 VARIMP(NULL,0,UI4,1,I4,1);
8362 if (HAVE_OLEAUT32_I8)
8364 VARIMP(NULL,0,I8,1,I8,1);
8365 VARIMP(NULL,0,UI8,1,I4,1);
8367 VARIMP(NULL,0,INT,-1,I4,-1);
8368 VARIMP(NULL,0,UINT,1,I4,1);
8369 VARIMP(I2,-1,EMPTY,0,I2,0);
8370 VARIMP(I2,-1,I2,-1,I2,-1);
8371 VARIMP(I2,-1,I4,-1,I4,-1);
8372 VARIMP(I2,-1,R4,0.0f,I4,0);
8373 VARIMP(I2,-1,R8,-1.0,I4,-1);
8374 VARIMP(I2,-1,DATE,0,I4,0);
8375 VARIMP(I2,-1,BSTR,true_str,I2,-1);
8376 VARIMP(I2,-1,BOOL,VARIANT_FALSE,I2,0);
8377 VARIMP(I2,-1,I1,0,I4,0);
8378 VARIMP(I2,-1,UI1,1,I2,1);
8379 VARIMP(I2,-1,UI2,1,I4,1);
8380 VARIMP(I2,-1,UI4,1,I4,1);
8381 if (HAVE_OLEAUT32_I8)
8383 VARIMP(I2,-1,I8,1,I8,1);
8384 VARIMP(I2,-1,UI8,1,I4,1);
8386 VARIMP(I2,-1,INT,-1,I4,-1);
8387 VARIMP(I2,-1,UINT,1,I4,1);
8388 VARIMP(I4,2,EMPTY,0,I4,-3);
8389 VARIMP(I4,2,NULL,0,I4,-3);
8390 VARIMP(I4,2,I2,-1,I4,-1);
8391 VARIMP(I4,2,I4,-1,I4,-1);
8392 VARIMP(I4,2,R4,0.0f,I4,-3);
8393 VARIMP(I4,2,R8,-1.0,I4,-1);
8394 VARIMP(I4,2,DATE,0,I4,-3);
8395 VARIMP(I4,2,BSTR,true_str,I4,-1);
8396 VARIMP(I4,2,BOOL,VARIANT_FALSE,I4,-3);
8397 VARIMP(I4,2,I1,0,I4,-3);
8398 VARIMP(I4,2,UI1,1,I4,-3);
8399 VARIMP(I4,2,UI2,1,I4,-3);
8400 VARIMP(I4,2,UI4,1,I4,-3);
8401 if (HAVE_OLEAUT32_I8)
8403 VARIMP(I4,2,I8,1,I8,-3);
8404 VARIMP(I4,2,UI8,1,I4,-3);
8406 VARIMP(I4,2,INT,-1,I4,-1);
8407 VARIMP(I4,2,UINT,1,I4,-3);
8408 VARIMP(R4,-1.0f,EMPTY,0,I4,0);
8409 VARIMP(R4,-1.0f,NULL,0,NULL,0);
8410 VARIMP(R4,-1.0f,I2,-1,I4,-1);
8411 VARIMP(R4,-1.0f,I4,-1,I4,-1);
8412 VARIMP(R4,-1.0f,R4,0.0f,I4,0);
8413 VARIMP(R4,-1.0f,R8,-1.0,I4,-1);
8414 VARIMP(R4,-1.0f,DATE,1,I4,1);
8415 VARIMP(R4,-1.0f,BSTR,true_str,I4,-1);
8416 VARIMP(R4,-1.0f,BOOL,VARIANT_FALSE,I4,0);
8417 VARIMP(R4,-1.0f,I1,0,I4,0);
8418 VARIMP(R4,-1.0f,UI1,1,I4,1);
8419 VARIMP(R4,-1.0f,UI2,1,I4,1);
8420 VARIMP(R4,-1.0f,UI4,1,I4,1);
8421 if (HAVE_OLEAUT32_I8)
8423 VARIMP(R4,-1.0f,I8,1,I8,1);
8424 VARIMP(R4,-1.0f,UI8,1,I4,1);
8426 VARIMP(R4,-1.0f,INT,-1,I4,-1);
8427 VARIMP(R4,-1.0f,UINT,1,I4,1);
8428 VARIMP(R8,1.0,EMPTY,0,I4,-2);
8429 VARIMP(R8,1.0,NULL,0,I4,-2);
8430 VARIMP(R8,1.0,I2,-1,I4,-1);
8431 VARIMP(R8,1.0,I4,-1,I4,-1);
8432 VARIMP(R8,1.0,R4,0.0f,I4,-2);
8433 VARIMP(R8,1.0,R8,-1.0,I4,-1);
8434 VARIMP(R8,1.0,DATE,0,I4,-2);
8435 VARIMP(R8,1.0,BSTR,true_str,I4,-1);
8436 VARIMP(R8,1.0,BOOL,VARIANT_FALSE,I4,-2);
8437 VARIMP(R8,1.0,I1,0,I4,-2);
8438 VARIMP(R8,1.0,UI1,1,I4,-1);
8439 VARIMP(R8,1.0,UI2,1,I4,-1);
8440 VARIMP(R8,1.0,UI4,1,I4,-1);
8441 if (HAVE_OLEAUT32_I8)
8443 VARIMP(R8,1.0,I8,1,I8,-1);
8444 VARIMP(R8,1.0,UI8,1,I4,-1);
8446 VARIMP(R8,1.0,INT,-1,I4,-1);
8447 VARIMP(R8,1.0,UINT,1,I4,-1);
8448 VARIMP(DATE,0,EMPTY,0,I4,-1);
8449 VARIMP(DATE,0,NULL,0,I4,-1);
8450 VARIMP(DATE,0,I2,-1,I4,-1);
8451 VARIMP(DATE,0,I4,-1,I4,-1);
8452 VARIMP(DATE,0,R4,0.0f,I4,-1);
8453 VARIMP(DATE,0,R8,-1.0,I4,-1);
8454 VARIMP(DATE,0,DATE,0,I4,-1);
8455 VARIMP(DATE,0,BSTR,true_str,I4,-1);
8456 VARIMP(DATE,0,BOOL,VARIANT_FALSE,I4,-1);
8457 VARIMP(DATE,0,I1,0,I4,-1);
8458 VARIMP(DATE,0,UI1,1,I4,-1);
8459 VARIMP(DATE,0,UI2,1,I4,-1);
8460 VARIMP(DATE,0,UI4,1,I4,-1);
8461 if (HAVE_OLEAUT32_I8)
8463 VARIMP(DATE,0,I8,1,I8,-1);
8464 VARIMP(DATE,0,UI8,1,I4,-1);
8466 VARIMP(DATE,0,INT,-1,I4,-1);
8467 VARIMP(DATE,0,UINT,1,I4,-1);
8468 VARIMP(BSTR,false_str,EMPTY,0,I2,-1);
8469 VARIMP(BSTR,false_str,NULL,0,BOOL,-1);
8470 VARIMP(BSTR,false_str,I2,-1,I2,-1);
8471 VARIMP(BSTR,false_str,I4,-1,I4,-1);
8472 VARIMP(BSTR,false_str,R4,0.0f,I4,-1);
8473 VARIMP(BSTR,false_str,R8,-1.0,I4,-1);
8474 VARIMP(BSTR,false_str,DATE,0,I4,-1);
8475 VARIMP(BSTR,false_str,BSTR,true_str,BOOL,-1);
8476 VARIMP(BSTR,false_str,BOOL,VARIANT_FALSE,BOOL,-1);
8477 VARIMP(BSTR,false_str,I1,0,I4,-1);
8478 VARIMP(BSTR,false_str,UI1,1,I2,-1);
8479 VARIMP(BSTR,false_str,UI2,1,I4,-1);
8480 VARIMP(BSTR,false_str,UI4,1,I4,-1);
8481 if (HAVE_OLEAUT32_I8)
8483 VARIMP(BSTR,false_str,I8,1,I8,-1);
8484 VARIMP(BSTR,false_str,UI8,1,I4,-1);
8486 VARIMP(BSTR,false_str,INT,-1,I4,-1);
8487 VARIMP(BSTR,false_str,UINT,1,I4,-1);
8488 VARIMP(BOOL,VARIANT_TRUE,EMPTY,0,I2,0);
8489 VARIMP(BOOL,VARIANT_TRUE,NULL,0,NULL,0);
8490 VARIMP(BOOL,VARIANT_TRUE,I2,-1,I2,-1);
8491 VARIMP(BOOL,VARIANT_TRUE,I4,-1,I4,-1);
8492 VARIMP(BOOL,VARIANT_TRUE,R4,0.0f,I4,0);
8493 VARIMP(BOOL,VARIANT_TRUE,R8,-1.0,I4,-1);
8494 VARIMP(BOOL,VARIANT_TRUE,DATE,0,I4,0);
8495 VARIMP(BOOL,VARIANT_TRUE,BSTR,true_str,BOOL,-1);
8496 VARIMP(BOOL,VARIANT_TRUE,BOOL,VARIANT_FALSE,BOOL,0);
8497 VARIMP(BOOL,VARIANT_TRUE,I1,0,I4,0);
8498 VARIMP(BOOL,VARIANT_TRUE,UI1,1,I2,1);
8499 VARIMP(BOOL,VARIANT_TRUE,UI2,1,I4,1);
8500 VARIMP(BOOL,VARIANT_TRUE,UI4,1,I4,1);
8501 if (HAVE_OLEAUT32_I8)
8503 VARIMP(BOOL,VARIANT_TRUE,I8,1,I8,1);
8504 VARIMP(BOOL,VARIANT_TRUE,UI8,1,I4,1);
8506 VARIMP(BOOL,VARIANT_TRUE,INT,-1,I4,-1);
8507 VARIMP(BOOL,VARIANT_TRUE,UINT,1,I4,1);
8508 VARIMP(I1,-1,EMPTY,0,I4,0);
8509 VARIMP(I1,-1,NULL,0,NULL,0);
8510 VARIMP(I1,-1,I2,-1,I4,-1);
8511 VARIMP(I1,-1,I4,-1,I4,-1);
8512 VARIMP(I1,-1,R4,0.0f,I4,0);
8513 VARIMP(I1,-1,R8,-1.0,I4,-1);
8514 VARIMP(I1,-1,DATE,0,I4,0);
8515 VARIMP(I1,-1,BSTR,true_str,I4,-1);
8516 VARIMP(I1,-1,BOOL,VARIANT_FALSE,I4,0);
8517 VARIMP(I1,-1,I1,0,I4,0);
8518 VARIMP(I1,-1,UI1,1,I4,1);
8519 VARIMP(I1,-1,UI2,1,I4,1);
8520 VARIMP(I1,-1,UI4,1,I4,1);
8521 if (HAVE_OLEAUT32_I8)
8523 VARIMP(I1,-1,I8,1,I8,1);
8524 VARIMP(I1,-1,UI8,1,I4,1);
8526 VARIMP(I1,-1,INT,-1,I4,-1);
8527 VARIMP(I1,-1,UINT,1,I4,1);
8528 VARIMP(UI1,0,EMPTY,0,I2,-1);
8529 VARIMP(UI1,0,NULL,0,UI1,255);
8530 VARIMP(UI1,0,I2,-1,I2,-1);
8531 VARIMP(UI1,0,I4,-1,I4,-1);
8532 VARIMP(UI1,0,R4,0.0f,I4,-1);
8533 VARIMP(UI1,0,R8,-1.0,I4,-1);
8534 VARIMP(UI1,0,DATE,0,I4,-1);
8535 VARIMP(UI1,0,BSTR,true_str,I2,-1);
8536 VARIMP(UI1,0,BOOL,VARIANT_FALSE,I2,-1);
8537 VARIMP(UI1,0,I1,0,I4,-1);
8538 VARIMP(UI1,0,UI1,1,UI1,255);
8539 VARIMP(UI1,0,UI2,1,I4,-1);
8540 VARIMP(UI1,0,UI4,1,I4,-1);
8541 if (HAVE_OLEAUT32_I8)
8543 VARIMP(UI1,0,I8,1,I8,-1);
8544 VARIMP(UI1,0,UI8,1,I4,-1);
8546 VARIMP(UI1,0,INT,-1,I4,-1);
8547 VARIMP(UI1,0,UINT,1,I4,-1);
8548 VARIMP(UI2,0,EMPTY,0,I4,-1);
8549 VARIMP(UI2,0,NULL,0,I4,-1);
8550 VARIMP(UI2,0,I2,-1,I4,-1);
8551 VARIMP(UI2,0,I4,-1,I4,-1);
8552 VARIMP(UI2,0,R4,0.0f,I4,-1);
8553 VARIMP(UI2,0,R8,-1.0,I4,-1);
8554 VARIMP(UI2,0,DATE,0,I4,-1);
8555 VARIMP(UI2,0,BSTR,true_str,I4,-1);
8556 VARIMP(UI2,0,BOOL,VARIANT_FALSE,I4,-1);
8557 VARIMP(UI2,0,I1,0,I4,-1);
8558 VARIMP(UI2,0,UI1,1,I4,-1);
8559 VARIMP(UI2,0,UI2,1,I4,-1);
8560 VARIMP(UI2,0,UI4,1,I4,-1);
8561 if (HAVE_OLEAUT32_I8)
8563 VARIMP(UI2,0,I8,1,I8,-1);
8564 VARIMP(UI2,0,UI8,1,I4,-1);
8566 VARIMP(UI2,0,INT,-1,I4,-1);
8567 VARIMP(UI2,0,UINT,1,I4,-1);
8568 VARIMP(UI4,0,EMPTY,0,I4,-1);
8569 VARIMP(UI4,0,NULL,0,I4,-1);
8570 VARIMP(UI4,0,I2,-1,I4,-1);
8571 VARIMP(UI4,0,I4,-1,I4,-1);
8572 VARIMP(UI4,0,R4,0.0f,I4,-1);
8573 VARIMP(UI4,0,R8,-1.0,I4,-1);
8574 VARIMP(UI4,0,DATE,0,I4,-1);
8575 VARIMP(UI4,0,BSTR,true_str,I4,-1);
8576 VARIMP(UI4,0,BOOL,VARIANT_FALSE,I4,-1);
8577 VARIMP(UI4,0,I1,0,I4,-1);
8578 VARIMP(UI4,0,UI1,1,I4,-1);
8579 VARIMP(UI4,0,UI2,1,I4,-1);
8580 VARIMP(UI4,0,UI4,1,I4,-1);
8581 if (HAVE_OLEAUT32_I8)
8583 VARIMP(UI4,0,I8,1,I8,-1);
8584 VARIMP(UI4,0,UI8,1,I4,-1);
8586 VARIMP(UI4,0,INT,-1,I4,-1);
8587 VARIMP(UI4,0,UINT,1,I4,-1);
8588 if (HAVE_OLEAUT32_I8)
8590 VARIMP(I8,-1,EMPTY,0,I8,0);
8591 VARIMP(I8,-1,NULL,0,NULL,0);
8592 VARIMP(I8,-1,I2,-1,I8,-1);
8593 VARIMP(I8,-1,I4,-1,I8,-1);
8594 VARIMP(I8,-1,R4,0.0f,I8,0);
8595 VARIMP(I8,-1,R8,-1.0,I8,-1);
8596 VARIMP(I8,-1,DATE,0,I8,0);
8597 VARIMP(I8,-1,BSTR,true_str,I8,-1);
8598 VARIMP(I8,-1,BOOL,VARIANT_FALSE,I8,0);
8599 VARIMP(I8,-1,I1,0,I8,0);
8600 VARIMP(I8,-1,UI1,1,I8,1);
8601 VARIMP(I8,-1,UI2,1,I8,1);
8602 VARIMP(I8,-1,UI4,1,I8,1);
8603 VARIMP(I8,-1,I8,1,I8,1);
8604 VARIMP(I8,-1,UI8,1,I8,1);
8605 VARIMP(I8,-1,UINT,1,I8,1);
8606 VARIMP(UI8,0,EMPTY,0,I4,-1);
8607 VARIMP(UI8,0,NULL,0,I4,-1);
8608 VARIMP(UI8,0,I2,-1,I4,-1);
8609 VARIMP(UI8,0,I4,-1,I4,-1);
8610 VARIMP(UI8,0,R4,0.0f,I4,-1);
8611 VARIMP(UI8,0,R8,-1.0,I4,-1);
8612 VARIMP(UI8,0,DATE,0,I4,-1);
8613 VARIMP(UI8,0,BSTR,true_str,I4,-1);
8614 VARIMP(UI8,0,BOOL,VARIANT_FALSE,I4,-1);
8615 VARIMP(UI8,0,I1,0,I4,-1);
8616 VARIMP(UI8,0,UI1,1,I4,-1);
8617 VARIMP(UI8,0,UI2,1,I4,-1);
8618 VARIMP(UI8,0,UI4,1,I4,-1);
8619 VARIMP(UI8,0,I8,1,I8,-1);
8620 VARIMP(UI8,0,UI8,1,I4,-1);
8621 VARIMP(UI8,0,INT,-1,I4,-1);
8622 VARIMP(UI8,0,UINT,1,I4,-1);
8624 VARIMP(INT,-1,EMPTY,0,I4,0);
8625 VARIMP(INT,-1,NULL,0,NULL,0);
8626 VARIMP(INT,-1,I2,-1,I4,-1);
8627 VARIMP(INT,-1,I4,-1,I4,-1);
8628 VARIMP(INT,-1,R4,0.0f,I4,0);
8629 VARIMP(INT,-1,R8,-1.0,I4,-1);
8630 VARIMP(INT,-1,DATE,0,I4,0);
8631 VARIMP(INT,-1,BSTR,true_str,I4,-1);
8632 VARIMP(INT,-1,BOOL,VARIANT_FALSE,I4,0);
8633 VARIMP(INT,-1,I1,0,I4,0);
8634 VARIMP(INT,-1,UI1,1,I4,1);
8635 VARIMP(INT,-1,UI2,1,I4,1);
8636 VARIMP(INT,-1,UI4,1,I4,1);
8637 if (HAVE_OLEAUT32_I8)
8639 VARIMP(INT,-1,I8,1,I8,1);
8640 VARIMP(INT,-1,UI8,1,I4,1);
8642 VARIMP(INT,-1,INT,-1,I4,-1);
8643 VARIMP(INT,-1,UINT,1,I4,1);
8644 VARIMP(UINT,1,EMPTY,0,I4,-2);
8645 VARIMP(UINT,1,NULL,0,I4,-2);
8646 VARIMP(UINT,1,I2,-1,I4,-1);
8647 VARIMP(UINT,1,I4,-1,I4,-1);
8648 VARIMP(UINT,1,R4,0.0f,I4,-2);
8649 VARIMP(UINT,1,R8,-1.0,I4,-1);
8650 VARIMP(UINT,1,DATE,0,I4,-2);
8651 VARIMP(UINT,1,BSTR,true_str,I4,-1);
8652 VARIMP(UINT,1,BOOL,VARIANT_FALSE,I4,-2);
8653 VARIMP(UINT,1,I1,0,I4,-2);
8654 VARIMP(UINT,1,UI1,1,I4,-1);
8655 VARIMP(UINT,1,UI2,1,I4,-1);
8656 VARIMP(UINT,1,UI4,1,I4,-1);
8657 if (HAVE_OLEAUT32_I8)
8659 VARIMP(UINT,1,I8,1,I8,-1);
8660 VARIMP(UINT,1,UI8,1,I4,-1);
8662 VARIMP(UINT,1,INT,-1,I4,-1);
8663 VARIMP(UINT,1,UINT,1,I4,-1);
8665 /* Manually test some VT_CY, VT_DECIMAL variants */
8667 hres = VarCyFromI4(1, &V_CY(&cy));
8668 ok(hres == S_OK, "VarCyFromI4 failed!\n");
8669 V_VT(&dec) = VT_DECIMAL;
8670 hres = VarDecFromR8(2.0, &V_DECIMAL(&dec));
8671 ok(hres == S_OK, "VarDecFromR4 failed!\n");
8672 memset(&left, 0, sizeof(left));
8673 memset(&right, 0, sizeof(right));
8674 V_VT(&left) = VT_I4;
8676 V_VT(&right) = VT_I8;
8679 hres = pVarImp(&cy, &cy, &result);
8680 ok(hres == S_OK && V_VT(&result) == VT_I4,
8681 "VARIMP: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8682 S_OK, hres, vtstr(V_VT(&result)));
8683 ok(hres == S_OK && V_I4(&result) == -1,
8684 "VARIMP: CY value %d, expected %d\n", V_I4(&result), -1);
8686 if (HAVE_OLEAUT32_I8)
8688 hres = pVarImp(&cy, &right, &result);
8689 ok(hres == S_OK && V_VT(&result) == VT_I8,
8690 "VARIMP: expected coerced hres 0x%X type VT_I8, got hres 0x%X type %s!\n",
8691 S_OK, hres, vtstr(V_VT(&result)));
8692 ok(hres == S_OK && V_I8(&result) == -2,
8693 "VARIMP: CY value %x%08x, expected %d\n",
8694 (DWORD)((V_I8(&result)) >> 32), (DWORD)(V_I8(&result)), -2);
8697 hres = pVarImp(&left, &cy, &result);
8698 ok(hres == S_OK && V_VT(&result) == VT_I4,
8699 "VARIMP: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8700 S_OK, hres, vtstr(V_VT(&result)));
8701 ok(hres == S_OK && V_I4(&result) == -1,
8702 "VARIMP: CY value %d, expected %d\n", V_I4(&result), -1);
8704 hres = pVarImp(&left, &dec, &result);
8705 ok(hres == S_OK && V_VT(&result) == VT_I4,
8706 "VARIMP: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8707 S_OK, hres, vtstr(V_VT(&result)));
8708 ok(hres == S_OK && V_I4(&result) == -1,
8709 "VARIMP: DECIMAL value %d, expected %d\n", V_I4(&result), -1);
8711 hres = pVarImp(&dec, &dec, &result);
8712 ok(hres == S_OK && V_VT(&result) == VT_I4,
8713 "VARIMP: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8714 S_OK, hres, vtstr(V_VT(&result)));
8715 ok(hres == S_OK && V_I4(&result) == -1,
8716 "VARIMP: DECIMAL value %d, expected %d\n", V_I4(&result), -1);
8718 if (HAVE_OLEAUT32_I8)
8720 hres = pVarImp(&dec, &right, &result);
8721 ok(hres == S_OK && V_VT(&result) == VT_I8,
8722 "VARIMP: expected coerced hres 0x%X type VT_I8, got hres 0x%X type %s!\n",
8723 S_OK, hres, vtstr(V_VT(&result)));
8724 ok(hres == S_OK && V_I8(&result) == -3,
8725 "VARIMP: DECIMAL value 0x%x%08x, expected %d\n",
8726 (DWORD)(V_I8(&result) >>32), (DWORD)V_I8(&result), -3);
8729 SysFreeString(false_str);
8730 SysFreeString(true_str);
8738 test_VariantClear();
8740 test_VariantCopyInd();
8741 test_VarParseNumFromStr();
8742 test_VarNumFromParseNum();
8743 test_VarUdateFromDate();
8744 test_VarDateFromUdate();
8745 test_SystemTimeToVariantTime();
8746 test_VariantTimeToSystemTime();
8747 test_DosDateTimeToVariantTime();
8748 test_VariantTimeToDosDateTime();
8763 test_VarCmp(); /* Before test_VarCat() which needs VarCmp() */