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
31 #include "wine/test.h"
41 static HMODULE hOleaut32;
43 static HRESULT (WINAPI *pVarUdateFromDate)(DATE,ULONG,UDATE*);
44 static HRESULT (WINAPI *pVarDateFromUdate)(UDATE*,ULONG,DATE*);
45 static INT (WINAPI *pSystemTimeToVariantTime)(LPSYSTEMTIME,double*);
46 static INT (WINAPI *pVariantTimeToSystemTime)(double,LPSYSTEMTIME);
47 static INT (WINAPI *pDosDateTimeToVariantTime)(USHORT,USHORT,double*);
48 static INT (WINAPI *pVariantTimeToDosDateTime)(double,USHORT*,USHORT *);
50 /* Get a conversion function ptr, return if function not available */
51 #define CHECKPTR(func) p##func = (void*)GetProcAddress(hOleaut32, #func); \
52 if (!p##func) { trace("function " # func " not available, not testing it\n"); return; }
54 /* Have IRecordInfo data type? */
55 static int HAVE_OLEAUT32_RECORD = 0;
56 /* Have I8/UI8 data type? */
57 static int HAVE_OLEAUT32_I8 = 0;
58 /* Is this an ancient version with support for only I2/I4/R4/R8/DATE? */
59 static int IS_ANCIENT = 0;
61 /* When comparing floating point values we cannot expect an exact match
62 * because the rounding errors depend on the exact algorithm.
64 #define EQ_DOUBLE(a,b) (fabs((a)-(b)) / (1.0+fabs(a)+fabs(b)) < 1e-14)
65 #define EQ_FLOAT(a,b) (fabs((a)-(b)) / (1.0+fabs(a)+fabs(b)) < 1e-7)
67 #define SKIPTESTS(a) if((a > VT_CLSID+10) && (a < VT_BSTR_BLOB-10)) continue
69 /* Allow our test macros to work for VT_NULL and VT_EMPTY too */
70 #define V_EMPTY(v) V_I4(v)
71 #define V_NULL(v) V_I4(v)
73 /* Size constraints for overflow tests */
75 #define I1_MIN ((-I1_MAX)-1)
79 #define I2_MIN ((-I2_MAX)-1)
80 #define UI2_MAX 0xffff
82 #define I4_MAX 0x7fffffff
83 #define I4_MIN ((-I4_MAX)-1)
84 #define UI4_MAX 0xffffffff
86 #define I8_MAX (((LONGLONG)I4_MAX << 32) | UI4_MAX)
87 #define I8_MIN ((-I8_MAX)-1)
88 #define UI8_MAX (((ULONGLONG)UI4_MAX << 32) | UI4_MAX)
90 #define DATE_MAX 2958465
91 #define DATE_MIN -657434
92 #define R4_MAX FLT_MAX
93 #define R4_MIN FLT_MIN
94 #define R8_MAX DBL_MAX
95 #define R8_MIN DBL_MIN
97 static void init(void)
99 hOleaut32 = GetModuleHandle("oleaut32.dll");
101 /* Is a given function exported from oleaut32? */
102 #define HAVE_FUNC(func) ((void*)GetProcAddress(hOleaut32, #func) != NULL)
104 HAVE_OLEAUT32_I8 = HAVE_FUNC(VarI8FromI1);
105 if (!HAVE_OLEAUT32_I8)
106 skip("No support for I8 and UI8 data types\n");
108 HAVE_OLEAUT32_RECORD = HAVE_FUNC(SafeArraySetRecordInfo);
109 IS_ANCIENT = (!HAVE_FUNC(VarI1FromI2));
114 /* Functions to set a DECIMAL */
115 static void setdec(DECIMAL* dec, BYTE scl, BYTE sgn, ULONG hi32, ULONG64 lo64)
117 S(U(*dec)).scale = scl;
118 S(U(*dec)).sign = sgn;
120 U1(*dec).Lo64 = lo64;
123 static void setdec64(DECIMAL* dec, BYTE scl, BYTE sgn, ULONG hi32, ULONG mid32, ULONG lo32)
125 S(U(*dec)).scale = scl;
126 S(U(*dec)).sign = sgn;
128 S1(U1(*dec)).Mid32 = mid32;
129 S1(U1(*dec)).Lo32 = lo32;
132 static inline int strcmpW( const WCHAR *str1, const WCHAR *str2 )
134 while (*str1 && (*str1 == *str2)) { str1++; str2++; }
135 return *str1 - *str2;
138 /* return the string text of a given variant type */
139 static char vtstr_buffer[16][256];
140 static int vtstr_current=0;
141 static const char *vtstr(int x)
144 #define CASE(vt) case VT_##vt: return #vt
183 CASE(STREAMED_OBJECT);
188 CASE(VERSIONED_STREAM);
197 return "VT_BSTR_BLOB/VT_ILLEGALMASKED/VT_TYPEMASK";
200 vtstr_current %= sizeof(vtstr_buffer)/sizeof(*vtstr_buffer);
201 sprintf(vtstr_buffer[vtstr_current], "unknown variant type %d", x);
202 return vtstr_buffer[vtstr_current++];
206 static const char *variantstr( const VARIANT *var )
208 vtstr_current %= sizeof(vtstr_buffer)/sizeof(*vtstr_buffer);
212 sprintf( vtstr_buffer[vtstr_current], "VT_I1(%d)", V_I1(var) ); break;
214 sprintf( vtstr_buffer[vtstr_current], "VT_I2(%d)", V_I2(var) ); break;
216 sprintf( vtstr_buffer[vtstr_current], "VT_I4(%d)", V_I4(var) ); break;
218 sprintf( vtstr_buffer[vtstr_current], "VT_INT(%d)", V_INT(var) ); break;
220 sprintf( vtstr_buffer[vtstr_current], "VT_I8(%x%08x)", (UINT)(V_I8(var) >> 32), (UINT)V_I8(var) ); break;
222 sprintf( vtstr_buffer[vtstr_current], "VT_UI8(%x%08x)", (UINT)(V_UI8(var) >> 32), (UINT)V_UI8(var) ); break;
224 sprintf( vtstr_buffer[vtstr_current], "VT_R4(%g)", V_R4(var) ); break;
226 sprintf( vtstr_buffer[vtstr_current], "VT_R8(%g)", V_R8(var) ); break;
228 sprintf( vtstr_buffer[vtstr_current], "VT_UI1(%u)", V_UI1(var) ); break;
230 sprintf( vtstr_buffer[vtstr_current], "VT_UI2(%u)", V_UI2(var) ); break;
232 sprintf( vtstr_buffer[vtstr_current], "VT_UI4(%u)", V_UI4(var) ); break;
234 sprintf( vtstr_buffer[vtstr_current], "VT_UINT(%d)", V_UINT(var) ); break;
236 sprintf( vtstr_buffer[vtstr_current], "VT_CY(%x%08x)", S(V_CY(var)).Hi, S(V_CY(var)).Lo ); break;
238 sprintf( vtstr_buffer[vtstr_current], "VT_DATE(%g)", V_DATE(var) ); break;
240 return vtstr(V_VT(var));
242 return vtstr_buffer[vtstr_current++];
245 static BOOL is_expected_variant( const VARIANT *result, const VARIANT *expected )
247 if (V_VT(result) != V_VT(expected)) return FALSE;
248 switch(V_VT(expected))
254 #define CASE(vt) case VT_##vt: return (V_##vt(result) == V_##vt(expected))
269 return EQ_FLOAT(V_DATE(result), V_DATE(expected));
271 return EQ_FLOAT(V_R4(result), V_R4(expected));
273 return EQ_FLOAT(V_R8(result), V_R8(expected));
275 return (V_CY(result).int64 == V_CY(expected).int64);
277 return !lstrcmpW( V_BSTR(result), V_BSTR(expected) );
279 return !memcmp( &V_DECIMAL(result), &V_DECIMAL(expected), sizeof(DECIMAL) );
281 ok(0, "unhandled variant type %s\n",vtstr(V_VT(expected)));
286 static void test_var_call1( int line, HRESULT (WINAPI *func)(LPVARIANT,LPVARIANT),
287 VARIANT *arg, VARIANT *expected )
289 VARIANT old_arg = *arg;
293 memset( &result, 0, sizeof(result) );
294 hres = func( arg, &result );
295 ok_(__FILE__,line)( hres == S_OK, "wrong result %x\n", hres );
297 ok_(__FILE__,line)( is_expected_variant( &result, expected ),
298 "got %s expected %s\n", variantstr(&result), variantstr(expected) );
299 ok_(__FILE__,line)( is_expected_variant( arg, &old_arg ), "Modified argument %s / %s\n",
300 variantstr(&old_arg), variantstr(arg));
303 static void test_var_call2( int line, HRESULT (WINAPI *func)(LPVARIANT,LPVARIANT,LPVARIANT),
304 VARIANT *left, VARIANT *right, VARIANT *expected )
306 VARIANT old_left = *left, old_right = *right;
310 memset( &result, 0, sizeof(result) );
311 hres = func( left, right, &result );
312 ok_(__FILE__,line)( hres == S_OK, "wrong result %x\n", hres );
314 ok_(__FILE__,line)( is_expected_variant( &result, expected ),
315 "got %s expected %s\n", variantstr(&result), variantstr(expected) );
316 ok_(__FILE__,line)( is_expected_variant( left, &old_left ), "Modified left argument %s / %s\n",
317 variantstr(&old_left), variantstr(left));
318 ok_(__FILE__,line)( is_expected_variant( right, &old_right ), "Modified right argument %s / %s\n",
319 variantstr(&old_right), variantstr(right));
323 static void test_VariantInit(void)
327 /* Test that VariantInit() only sets the type */
328 memset(&v1, -1, sizeof(v1));
330 V_VT(&v2) = VT_EMPTY;
332 ok(!memcmp(&v1, &v2, sizeof(v1)), "VariantInit() set extra fields\n");
335 /* All possible combinations of extra V_VT() flags */
336 static const VARTYPE ExtraFlags[16] =
345 VT_VECTOR|VT_RESERVED,
346 VT_VECTOR|VT_ARRAY|VT_BYREF,
347 VT_VECTOR|VT_ARRAY|VT_RESERVED,
348 VT_VECTOR|VT_BYREF|VT_RESERVED,
349 VT_VECTOR|VT_ARRAY|VT_BYREF|VT_RESERVED,
351 VT_ARRAY|VT_RESERVED,
352 VT_ARRAY|VT_BYREF|VT_RESERVED,
353 VT_BYREF|VT_RESERVED,
356 /* Determine if a vt is valid for VariantClear() */
357 static int IsValidVariantClearVT(VARTYPE vt, VARTYPE extraFlags)
361 /* Only the following flags/types are valid */
362 if ((vt <= VT_LPWSTR || vt == VT_RECORD || vt == VT_CLSID) &&
364 (vt < (VARTYPE)24 || vt > (VARTYPE)31) &&
365 (!(extraFlags & (VT_BYREF|VT_ARRAY)) || vt > VT_NULL) &&
366 (extraFlags == 0 || extraFlags == VT_BYREF || extraFlags == VT_ARRAY ||
367 extraFlags == (VT_ARRAY|VT_BYREF)))
370 if ((vt == VT_RECORD && !HAVE_OLEAUT32_RECORD) ||
371 ((vt == VT_I8 || vt == VT_UI8) && !HAVE_OLEAUT32_I8))
372 ret = 0; /* Old versions of oleaut32 */
378 const IUnknownVtbl *lpVtbl;
381 } test_VariantClearImpl;
383 static HRESULT WINAPI VC_QueryInterface(LPUNKNOWN iface,REFIID riid,LPVOID *ppobj)
385 test_VariantClearImpl *This = (test_VariantClearImpl *)iface;
387 return E_NOINTERFACE;
390 static ULONG WINAPI VC_AddRef(LPUNKNOWN iface) {
391 test_VariantClearImpl *This = (test_VariantClearImpl *)iface;
393 return InterlockedIncrement(&This->ref);
396 static ULONG WINAPI VC_Release(LPUNKNOWN iface) {
397 test_VariantClearImpl *This = (test_VariantClearImpl *)iface;
398 /* static class, won't be freed */
400 return InterlockedDecrement(&This->ref);
403 static const IUnknownVtbl test_VariantClear_vtbl = {
409 static test_VariantClearImpl test_myVariantClearImpl = {&test_VariantClear_vtbl, 1, 0};
411 static void test_VariantClear(void)
420 /* Crashes: Native does not test input for NULL, so neither does Wine */
421 if (0) hres = VariantClear(NULL);
423 /* Only the type field is set, to VT_EMPTY */
426 hres = VariantClear(&v);
427 ok((hres == S_OK && V_VT(&v) == VT_EMPTY) ||
428 (IS_ANCIENT && hres == DISP_E_BADVARTYPE && V_VT(&v) == VT_UI4),
429 "VariantClear: Type set to %d, res %08x\n", V_VT(&v), hres);
430 ok(V_UI4(&v) == ~0u, "VariantClear: Overwrote value\n");
432 /* Test all possible V_VT values.
433 * Also demonstrates that null pointers in 'v' are not dereferenced.
434 * Individual variant tests should test VariantClear() with non-NULL values.
436 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]) && !IS_ANCIENT; i++)
440 for (vt = 0; vt <= VT_BSTR_BLOB; vt++)
442 HRESULT hExpected = DISP_E_BADVARTYPE;
446 memset(&v, 0, sizeof(v));
447 V_VT(&v) = vt | ExtraFlags[i];
449 hres = VariantClear(&v);
451 if (IsValidVariantClearVT(vt, ExtraFlags[i]))
454 ok(hres == hExpected, "VariantClear: expected 0x%X, got 0x%X for vt %d | 0x%X\n",
455 hExpected, hres, vt, ExtraFlags[i]);
459 /* Some BYREF tests with non-NULL ptrs */
464 V_VT(&v) = VT_VARIANT | VT_BYREF;
465 V_VARIANTREF(&v) = &v2;
467 hres = VariantClear(&v);
468 ok(hres == S_OK, "ret %08x\n", hres);
469 ok(V_VT(&v) == 0, "vt %04x\n", V_VT(&v));
470 ok(V_VARIANTREF(&v) == &v2, "variant ref %p\n", V_VARIANTREF(&v2));
471 ok(V_VT(&v2) == VT_I4, "vt %04x\n", V_VT(&v2));
472 ok(V_I4(&v2) == 0x1234, "i4 %04x\n", V_I4(&v2));
476 V_VT(&v) = VT_I4 | VT_BYREF;
479 hres = VariantClear(&v);
480 ok(hres == S_OK, "ret %08x\n", hres);
481 ok(V_VT(&v) == 0, "vt %04x\n", V_VT(&v));
482 ok(V_I4REF(&v) == &i4, "i4 ref %p\n", V_I4REF(&v2));
483 ok(i4 == 0x4321, "i4 changed %08x\n", i4);
487 V_VT(&v) = VT_UNKNOWN;
488 V_UNKNOWN(&v) = (IUnknown*)&test_myVariantClearImpl;
489 test_myVariantClearImpl.events = 0;
490 hres = VariantClear(&v);
491 ok(hres == S_OK, "ret %08x\n", hres);
492 ok(V_VT(&v) == 0, "vt %04x\n", V_VT(&v));
493 ok(V_UNKNOWN(&v) == (IUnknown*)&test_myVariantClearImpl, "unknown %p\n", V_UNKNOWN(&v));
494 /* Check that Release got called, but nothing else */
495 ok(test_myVariantClearImpl.events == 0x4, "Unexpected call. events %08x\n", test_myVariantClearImpl.events);
498 punk = (IUnknown*)&test_myVariantClearImpl;
499 V_VT(&v) = VT_UNKNOWN | VT_BYREF;
500 V_UNKNOWNREF(&v) = &punk;
501 test_myVariantClearImpl.events = 0;
502 hres = VariantClear(&v);
503 ok(hres == S_OK, "ret %08x\n", hres);
504 ok(V_VT(&v) == 0, "vt %04x\n", V_VT(&v));
505 ok(V_UNKNOWNREF(&v) == &punk, "unknown ref %p\n", V_UNKNOWNREF(&v));
506 /* Check that nothing got called */
507 ok(test_myVariantClearImpl.events == 0, "Unexpected call. events %08x\n", test_myVariantClearImpl.events);
510 V_VT(&v) = VT_DISPATCH;
511 V_DISPATCH(&v) = (IDispatch*)&test_myVariantClearImpl;
512 test_myVariantClearImpl.events = 0;
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_DISPATCH(&v) == (IDispatch*)&test_myVariantClearImpl, "dispatch %p\n", V_DISPATCH(&v));
517 /* Check that Release got called, but nothing else */
518 ok(test_myVariantClearImpl.events == 0x4, "Unexpected call. events %08x\n", test_myVariantClearImpl.events);
521 punk = (IUnknown*)&test_myVariantClearImpl;
522 V_VT(&v) = VT_DISPATCH | VT_BYREF;
523 V_DISPATCHREF(&v) = (IDispatch**)&punk;
524 test_myVariantClearImpl.events = 0;
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_DISPATCHREF(&v) == (IDispatch**)&punk, "dispatch ref %p\n", V_DISPATCHREF(&v));
529 /* Check that nothing got called */
530 ok(test_myVariantClearImpl.events == 0, "Unexpected call. events %08x\n", test_myVariantClearImpl.events);
533 static void test_VariantCopy(void)
535 VARIANTARG vSrc, vDst;
538 HRESULT hres, hExpected;
540 /* Establish that the failure/other cases are dealt with. Individual tests
541 * for each type should verify that data is copied correctly, references
546 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]) && !IS_ANCIENT; i++)
548 for (vt = 0; vt <= VT_BSTR_BLOB; vt++)
552 memset(&vSrc, 0, sizeof(vSrc));
553 V_VT(&vSrc) = vt | ExtraFlags[i];
555 hExpected = DISP_E_BADVARTYPE;
556 /* src is allowed to be a VT_CLSID */
557 if (vt != VT_CLSID && IsValidVariantClearVT(vt, ExtraFlags[i]))
560 hres = VariantCopy(&vSrc, &vSrc);
562 ok(hres == hExpected,
563 "Copy(src==dst): expected 0x%X, got 0x%X for src==dest vt %d|0x%X\n",
564 hExpected, hres, vt, ExtraFlags[i]);
568 /* Test that if VariantClear() fails on dest, the function fails. This also
569 * shows that dest is in fact cleared and not just overwritten
571 memset(&vSrc, 0, sizeof(vSrc));
572 V_VT(&vSrc) = VT_UI1;
574 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]) && !IS_ANCIENT; i++)
576 for (vt = 0; vt <= VT_BSTR_BLOB; vt++)
580 hExpected = DISP_E_BADVARTYPE;
582 memset(&vDst, 0, sizeof(vDst));
583 V_VT(&vDst) = vt | ExtraFlags[i];
585 if (IsValidVariantClearVT(vt, ExtraFlags[i]))
588 hres = VariantCopy(&vDst, &vSrc);
590 ok(hres == hExpected,
591 "Copy(bad dst): expected 0x%X, got 0x%X for dest vt %d|0x%X\n",
592 hExpected, hres, vt, ExtraFlags[i]);
594 ok(V_VT(&vDst) == VT_UI1,
595 "Copy(bad dst): expected vt = VT_UI1, got %d\n", V_VT(&vDst));
599 /* Test that VariantClear() checks vSrc for validity before copying */
600 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]) && !IS_ANCIENT; i++)
602 for (vt = 0; vt <= VT_BSTR_BLOB; vt++)
606 hExpected = DISP_E_BADVARTYPE;
608 memset(&vDst, 0, sizeof(vDst));
609 V_VT(&vDst) = VT_EMPTY;
611 memset(&vSrc, 0, sizeof(vSrc));
612 V_VT(&vSrc) = vt | ExtraFlags[i];
614 /* src is allowed to be a VT_CLSID */
615 if (vt != VT_CLSID && IsValidVariantClearVT(vt, ExtraFlags[i]))
618 hres = VariantCopy(&vDst, &vSrc);
620 ok(hres == hExpected,
621 "Copy(bad src): expected 0x%X, got 0x%X for src vt %d|0x%X\n",
622 hExpected, hres, vt, ExtraFlags[i]);
624 ok(V_VT(&vDst) == (vt|ExtraFlags[i]),
625 "Copy(bad src): expected vt = %d, got %d\n",
626 vt | ExtraFlags[i], V_VT(&vDst));
630 /* Test that copying a NULL BSTR results in an empty BSTR */
631 memset(&vDst, 0, sizeof(vDst));
632 V_VT(&vDst) = VT_EMPTY;
633 memset(&vSrc, 0, sizeof(vSrc));
634 V_VT(&vSrc) = VT_BSTR;
635 hres = VariantCopy(&vDst, &vSrc);
636 ok(hres == S_OK, "Copy(NULL BSTR): Failed to copy a NULL BSTR\n");
639 ok((V_VT(&vDst) == VT_BSTR) && V_BSTR(&vDst),
640 "Copy(NULL BSTR): should have non-NULL result\n");
641 if ((V_VT(&vDst) == VT_BSTR) && V_BSTR(&vDst))
643 ok(*V_BSTR(&vDst) == 0, "Copy(NULL BSTR): result not empty\n");
648 /* Determine if a vt is valid for VariantCopyInd() */
649 static int IsValidVariantCopyIndVT(VARTYPE vt, VARTYPE extraFlags)
653 if ((extraFlags & VT_ARRAY) ||
654 (vt > VT_NULL && vt != (VARTYPE)15 && vt < VT_VOID &&
655 !(extraFlags & (VT_VECTOR|VT_RESERVED))))
662 static void test_VariantCopyInd(void)
664 VARIANTARG vSrc, vDst, vRef, vRef2;
668 HRESULT hres, hExpected;
670 memset(buffer, 0, sizeof(buffer));
673 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]) && !IS_ANCIENT; i++)
675 if (ExtraFlags[i] & VT_ARRAY)
676 continue; /* Native crashes on NULL safearray */
678 for (vt = 0; vt <= VT_BSTR_BLOB; vt++)
682 memset(&vSrc, 0, sizeof(vSrc));
683 V_VT(&vSrc) = vt | ExtraFlags[i];
685 hExpected = DISP_E_BADVARTYPE;
686 if (!(ExtraFlags[i] & VT_BYREF))
688 /* if src is not by-reference, acts as VariantCopy() */
689 if (vt != VT_CLSID && IsValidVariantClearVT(vt, ExtraFlags[i]))
694 if (vt == VT_SAFEARRAY || vt == VT_BSTR || vt == VT_UNKNOWN ||
695 vt == VT_DISPATCH || vt == VT_RECORD)
696 continue; /* Need valid ptrs for deep copies */
698 V_BYREF(&vSrc) = &buffer;
699 hExpected = E_INVALIDARG;
701 if ((vt == VT_I8 || vt == VT_UI8) &&
702 ExtraFlags[i] == VT_BYREF)
704 if (HAVE_OLEAUT32_I8)
705 hExpected = S_OK; /* Only valid if I8 is a known type */
707 else if (IsValidVariantCopyIndVT(vt, ExtraFlags[i]))
711 hres = VariantCopyInd(&vSrc, &vSrc);
713 ok(hres == hExpected,
714 "CopyInd(src==dst): expected 0x%X, got 0x%X for src==dst vt %d|0x%X\n",
715 hExpected, hres, vt, ExtraFlags[i]);
720 memset(&vSrc, 0, sizeof(vSrc));
721 V_VT(&vSrc) = VT_UI1|VT_BYREF;
722 V_BYREF(&vSrc) = &buffer;
724 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]) && !IS_ANCIENT; i++)
726 for (vt = 0; vt <= VT_BSTR_BLOB; vt++)
730 memset(&vDst, 0, sizeof(vDst));
731 V_VT(&vDst) = vt | ExtraFlags[i];
733 hExpected = DISP_E_BADVARTYPE;
735 if (IsValidVariantClearVT(vt, ExtraFlags[i]))
738 hres = VariantCopyInd(&vDst, &vSrc);
740 ok(hres == hExpected,
741 "CopyInd(bad dst): expected 0x%X, got 0x%X for dst vt %d|0x%X\n",
742 hExpected, hres, vt, ExtraFlags[i]);
744 ok(V_VT(&vDst) == VT_UI1,
745 "CopyInd(bad dst): expected vt = VT_UI1, got %d\n", V_VT(&vDst));
750 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]) && !IS_ANCIENT; i++)
752 if (ExtraFlags[i] & VT_ARRAY)
753 continue; /* Native crashes on NULL safearray */
755 for (vt = 0; vt <= VT_BSTR_BLOB; vt++)
759 memset(&vDst, 0, sizeof(vDst));
760 V_VT(&vDst) = VT_EMPTY;
762 memset(&vSrc, 0, sizeof(vSrc));
763 V_VT(&vSrc) = vt | ExtraFlags[i];
765 hExpected = DISP_E_BADVARTYPE;
766 if (!(ExtraFlags[i] & VT_BYREF))
768 /* if src is not by-reference, acts as VariantCopy() */
769 if (vt != VT_CLSID && IsValidVariantClearVT(vt, ExtraFlags[i]))
774 if (vt == VT_SAFEARRAY || vt == VT_BSTR || vt == VT_UNKNOWN ||
775 vt == VT_DISPATCH || vt == VT_RECORD)
776 continue; /* Need valid ptrs for deep copies, see vartype.c */
778 V_BYREF(&vSrc) = &buffer;
780 hExpected = E_INVALIDARG;
782 if ((vt == VT_I8 || vt == VT_UI8) &&
783 ExtraFlags[i] == VT_BYREF)
785 if (HAVE_OLEAUT32_I8)
786 hExpected = S_OK; /* Only valid if I8 is a known type */
788 else if (IsValidVariantCopyIndVT(vt, ExtraFlags[i]))
792 hres = VariantCopyInd(&vDst, &vSrc);
794 ok(hres == hExpected,
795 "CopyInd(bad src): expected 0x%X, got 0x%X for src vt %d|0x%X\n",
796 hExpected, hres, vt, ExtraFlags[i]);
799 if (vt == VT_VARIANT && ExtraFlags[i] == VT_BYREF)
801 /* Type of vDst should be the type of the referenced variant.
802 * Since we set the buffer to all zeros, its type should be
805 ok(V_VT(&vDst) == VT_EMPTY,
806 "CopyInd(bad src): expected dst vt = VT_EMPTY, got %d|0x%X\n",
807 V_VT(&vDst) & VT_TYPEMASK, V_VT(&vDst) & ~VT_TYPEMASK);
811 ok(V_VT(&vDst) == (vt|(ExtraFlags[i] & ~VT_BYREF)),
812 "CopyInd(bad src): expected dst vt = %d|0x%X, got %d|0x%X\n",
813 vt, ExtraFlags[i] & ~VT_BYREF,
814 V_VT(&vDst) & VT_TYPEMASK, V_VT(&vDst) & ~VT_TYPEMASK);
820 /* By-reference variants are dereferenced */
821 V_VT(&vRef) = VT_UI1;
823 V_VT(&vSrc) = VT_VARIANT|VT_BYREF;
824 V_VARIANTREF(&vSrc) = &vRef;
827 hres = VariantCopyInd(&vDst, &vSrc);
828 ok(V_VT(&vDst) == VT_UI1 && V_UI1(&vDst) == 0x77,
829 "CopyInd(deref): expected dst vt = VT_UI1, val 0x77, got %d|0x%X, 0x%2X\n",
830 V_VT(&vDst) & VT_TYPEMASK, V_VT(&vDst) & ~VT_TYPEMASK, V_UI1(&vDst));
832 /* By-reference variant to a by-reference type succeeds */
833 V_VT(&vRef) = VT_UI1|VT_BYREF;
834 V_UI1REF(&vRef) = buffer; buffer[0] = 0x88;
835 V_VT(&vSrc) = VT_VARIANT|VT_BYREF;
836 V_VARIANTREF(&vSrc) = &vRef;
839 hres = VariantCopyInd(&vDst, &vSrc);
840 ok(V_VT(&vDst) == VT_UI1 && V_UI1(&vDst) == 0x88,
841 "CopyInd(deref): expected dst vt = VT_UI1, val 0x77, got %d|0x%X, 0x%2X\n",
842 V_VT(&vDst) & VT_TYPEMASK, V_VT(&vDst) & ~VT_TYPEMASK, V_UI1(&vDst));
844 /* But a by-reference variant to a by-reference variant fails */
845 V_VT(&vRef2) = VT_UI1;
846 V_UI1(&vRef2) = 0x77;
847 V_VT(&vRef) = VT_VARIANT|VT_BYREF;
848 V_VARIANTREF(&vRef) = &vRef2;
849 V_VT(&vSrc) = VT_VARIANT|VT_BYREF;
850 V_VARIANTREF(&vSrc) = &vRef;
853 hres = VariantCopyInd(&vDst, &vSrc);
854 ok(hres == E_INVALIDARG,
855 "CopyInd(ref->ref): expected E_INVALIDARG, got 0x%08x\n", hres);
858 static HRESULT (WINAPI *pVarParseNumFromStr)(OLECHAR*,LCID,ULONG,NUMPARSE*,BYTE*);
860 /* Macros for converting and testing the result of VarParseNumFromStr */
863 static HRESULT convert_str( const char *str, INT dig, ULONG flags,
864 NUMPARSE *np, BYTE rgb[128], LCID lcid )
867 MultiByteToWideChar( CP_ACP,0, str, -1, buff, sizeof(buff)/sizeof(WCHAR) );
868 memset( rgb, FAILDIG, 128 );
869 memset( np, 255, sizeof(*np) );
871 np->dwInFlags = flags;
872 return pVarParseNumFromStr( buff, lcid, LOCALE_NOUSEROVERRIDE, np, rgb);
875 static void expect_NumFromStr( int line, HRESULT hres, NUMPARSE *np, INT a, ULONG b, ULONG c,
876 INT d, INT e, INT f )
878 if (hres == (HRESULT)S_OK)
880 ok_(__FILE__,line)(np->cDig == a, "Expected cDig = %d, got %d\n", a, np->cDig);
881 ok_(__FILE__,line)(np->dwInFlags == b, "Expected dwInFlags = 0x%x, got 0x%x\n", b, np->dwInFlags);
882 ok_(__FILE__,line)(np->dwOutFlags == c, "Expected dwOutFlags = 0x%x, got 0x%x\n", c, np->dwOutFlags);
883 ok_(__FILE__,line)(np->cchUsed == d, "Expected cchUsed = %d, got %d\n", d, np->cchUsed);
884 ok_(__FILE__,line)(np->nBaseShift == e, "Expected nBaseShift = %d, got %d\n", e, np->nBaseShift);
885 ok_(__FILE__,line)(np->nPwr10 == f, "Expected nPwr10 = %d, got %d\n", f, np->nPwr10);
889 #define CONVERTN(str,dig,flags) hres = convert_str( str, dig, flags, &np, rgb, lcid )
890 #define CONVERT(str,flags) CONVERTN(str,sizeof(rgb),flags)
891 #define EXPECT(a,b,c,d,e,f) expect_NumFromStr( __LINE__, hres, &np, a, b, c, d, e, f )
892 #define EXPECTRGB(a,b) ok(rgb[a] == b, "Digit[%d], expected %d, got %d\n", a, b, rgb[a])
893 #define EXPECTFAIL ok(hres == (HRESULT)DISP_E_TYPEMISMATCH, "Call succeeded, hres = %08x\n", hres)
894 #define EXPECT2(a,b) EXPECTRGB(0,a); EXPECTRGB(1,b)
896 static void test_VarParseNumFromStr(void)
899 /* Ensure all tests are using the same locale characters for '$', ',' etc */
900 LCID lcid = MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT);
906 CHECKPTR(VarParseNumFromStr);
908 /* Consume a single digit */
913 /* cDig is not literal digits - zeros are suppressed and nPwr10 is increased */
916 /* Note: Win32 writes the trailing zeros if they are within cDig's limits,
917 * but then excludes them from the returned cDig count.
918 * In our implementation we don't bother writing them at all.
922 /* if cDig is too small and numbers follow, sets INEXACT */
924 EXPECT(1,0,NUMPRS_INEXACT,2,0,1);
927 /* Strips leading zeros */
932 /* Strips leading zeros */
938 /* Fails on non digits */
941 EXPECTRGB(0,FAILDIG);
943 /** NUMPRS_LEADING_WHITE/NUMPRS_TRAILING_WHITE **/
945 /* Without flag, fails on whitespace */
948 EXPECTRGB(0,FAILDIG);
951 /* With flag, consumes whitespace */
952 CONVERT(" 0", NUMPRS_LEADING_WHITE);
953 EXPECT(1,NUMPRS_LEADING_WHITE,NUMPRS_LEADING_WHITE,2,0,0);
956 /* Test TAB once, then assume it acts as space for all cases */
957 CONVERT("\t0", NUMPRS_LEADING_WHITE);
958 EXPECT(1,NUMPRS_LEADING_WHITE,NUMPRS_LEADING_WHITE,2,0,0);
962 /* Doesn't pick up trailing whitespace without flag */
967 /* With flag, consumes trailing whitespace */
968 CONVERT("0 ", NUMPRS_TRAILING_WHITE);
969 EXPECT(1,NUMPRS_TRAILING_WHITE,NUMPRS_TRAILING_WHITE,2,0,0);
972 /* Leading flag only consumes leading */
973 CONVERT(" 0 ", NUMPRS_LEADING_WHITE);
974 EXPECT(1,NUMPRS_LEADING_WHITE,NUMPRS_LEADING_WHITE,2,0,0);
977 /* Both flags consumes both */
978 CONVERT(" 0 ", NUMPRS_LEADING_WHITE|NUMPRS_TRAILING_WHITE);
979 EXPECT(1,NUMPRS_LEADING_WHITE|NUMPRS_TRAILING_WHITE,NUMPRS_LEADING_WHITE|NUMPRS_TRAILING_WHITE,3,0,0);
982 /** NUMPRS_LEADING_PLUS/NUMPRS_TRAILING_PLUS **/
984 /* Without flag, fails on + */
987 EXPECTRGB(0,FAILDIG);
989 /* With flag, consumes + */
990 CONVERT("+0", NUMPRS_LEADING_PLUS);
991 EXPECT(1,NUMPRS_LEADING_PLUS,NUMPRS_LEADING_PLUS,2,0,0);
994 /* Without flag, doesn't consume trailing + */
999 /* With flag, consumes trailing + */
1000 CONVERT("0+", NUMPRS_TRAILING_PLUS);
1001 EXPECT(1,NUMPRS_TRAILING_PLUS,NUMPRS_TRAILING_PLUS,2,0,0);
1004 /* With leading flag, doesn't consume trailing + */
1005 CONVERT("+0+", NUMPRS_LEADING_PLUS);
1006 EXPECT(1,NUMPRS_LEADING_PLUS,NUMPRS_LEADING_PLUS,2,0,0);
1009 /* Trailing + doesn't get consumed if we specify both (unlike whitespace) */
1010 CONVERT("+0+", NUMPRS_LEADING_PLUS|NUMPRS_TRAILING_PLUS);
1011 EXPECT(1,NUMPRS_LEADING_PLUS|NUMPRS_TRAILING_PLUS,NUMPRS_LEADING_PLUS,2,0,0);
1014 /** NUMPRS_LEADING_MINUS/NUMPRS_TRAILING_MINUS **/
1016 /* Without flag, fails on - */
1019 EXPECTRGB(0,FAILDIG);
1021 /* With flag, consumes - */
1022 CONVERT("-0", NUMPRS_LEADING_MINUS);
1023 EXPECT(1,NUMPRS_LEADING_MINUS,NUMPRS_NEG|NUMPRS_LEADING_MINUS,2,0,0);
1026 /* Without flag, doesn't consume trailing - */
1028 EXPECT(1,0,0,1,0,0);
1031 /* With flag, consumes trailing - */
1032 CONVERT("0-", NUMPRS_TRAILING_MINUS);
1033 EXPECT(1,NUMPRS_TRAILING_MINUS,NUMPRS_NEG|NUMPRS_TRAILING_MINUS,2,0,0);
1036 /* With leading flag, doesn't consume trailing - */
1037 CONVERT("-0-", NUMPRS_LEADING_MINUS);
1038 EXPECT(1,NUMPRS_LEADING_MINUS,NUMPRS_NEG|NUMPRS_LEADING_MINUS,2,0,0);
1041 /* Trailing - doesn't get consumed if we specify both (unlike whitespace) */
1042 CONVERT("-0-", NUMPRS_LEADING_MINUS|NUMPRS_TRAILING_MINUS);
1043 EXPECT(1,NUMPRS_LEADING_MINUS|NUMPRS_TRAILING_MINUS,NUMPRS_NEG|NUMPRS_LEADING_MINUS,2,0,0);
1046 /** NUMPRS_HEX_OCT **/
1048 /* Could be hex, octal or decimal - With flag reads as decimal */
1049 CONVERT("0", NUMPRS_HEX_OCT);
1050 EXPECT(1,NUMPRS_HEX_OCT,0,1,0,0);
1053 /* Doesn't recognise hex in .asm sytax */
1054 CONVERT("0h", NUMPRS_HEX_OCT);
1055 EXPECT(1,NUMPRS_HEX_OCT,0,1,0,0);
1058 /* Doesn't fail with valid leading string but no digits */
1059 CONVERT("0x", NUMPRS_HEX_OCT);
1060 EXPECT(1,NUMPRS_HEX_OCT,0,1,0,0);
1063 /* Doesn't recognise hex format humbers at all! */
1064 CONVERT("0x0", NUMPRS_HEX_OCT);
1065 EXPECT(1,NUMPRS_HEX_OCT,0,1,0,0);
1068 /* Doesn't recognise plain hex digits either */
1069 CONVERT("FE", NUMPRS_HEX_OCT);
1071 EXPECTRGB(0,FAILDIG);
1074 CONVERT("0100", NUMPRS_HEX_OCT);
1075 EXPECT(1,NUMPRS_HEX_OCT,0,4,0,2);
1079 EXPECTRGB(3,FAILDIG);
1082 CONVERT("&HF800", NUMPRS_HEX_OCT);
1083 EXPECT(4,NUMPRS_HEX_OCT,0x40,6,4,0);
1088 EXPECTRGB(4,FAILDIG);
1090 /* VB hex lower case and leading zero */
1091 CONVERT("&h0abcdef", NUMPRS_HEX_OCT);
1092 EXPECT(6,NUMPRS_HEX_OCT,0x40,9,4,0);
1099 EXPECTRGB(6,FAILDIG);
1102 CONVERT("&O300", NUMPRS_HEX_OCT);
1103 EXPECT(3,NUMPRS_HEX_OCT,0x40,5,3,0);
1107 EXPECTRGB(3,FAILDIG);
1109 /* VB oct lower case and leading zero */
1110 CONVERT("&o0777", NUMPRS_HEX_OCT);
1111 EXPECT(3,NUMPRS_HEX_OCT,0x40,6,3,0);
1115 EXPECTRGB(3,FAILDIG);
1117 /* VB oct char bigger than 7 */
1118 CONVERT("&o128", NUMPRS_HEX_OCT);
1120 Native versions 2.x of oleaut32 allow this to succeed: later versions and Wine don't
1122 EXPECTRGB(0,FAILDIG);
1124 /** NUMPRS_PARENS **/
1126 /* Empty parens = error */
1127 CONVERT("()", NUMPRS_PARENS);
1129 EXPECTRGB(0,FAILDIG);
1131 /* With flag, trailing parens not consumed */
1132 CONVERT("0()", NUMPRS_PARENS);
1133 EXPECT(1,NUMPRS_PARENS,0,1,0,0);
1136 /* With flag, Number in parens made negative and parens consumed */
1137 CONVERT("(0)", NUMPRS_PARENS);
1138 EXPECT(1,NUMPRS_PARENS,NUMPRS_NEG|NUMPRS_PARENS,3,0,0);
1141 /** NUMPRS_THOUSANDS **/
1143 /* With flag, thousands sep. not needed */
1144 CONVERT("0", NUMPRS_THOUSANDS);
1145 EXPECT(1,NUMPRS_THOUSANDS,0,1,0,0);
1148 /* With flag, thousands sep. and following digits consumed */
1149 CONVERT("1,000", NUMPRS_THOUSANDS);
1150 EXPECT(1,NUMPRS_THOUSANDS,NUMPRS_THOUSANDS,5,0,3);
1153 /* With flag and decimal point, thousands sep. but not decimals consumed */
1154 CONVERT("1,000.0", NUMPRS_THOUSANDS);
1155 EXPECT(1,NUMPRS_THOUSANDS,NUMPRS_THOUSANDS,5,0,3);
1158 /** NUMPRS_CURRENCY **/
1160 /* Without flag, chokes on currency sign */
1163 EXPECTRGB(0,FAILDIG);
1165 /* With flag, consumes currency sign */
1166 CONVERT("$11", NUMPRS_CURRENCY);
1167 EXPECT(2,NUMPRS_CURRENCY,NUMPRS_CURRENCY,3,0,0);
1169 EXPECTRGB(2,FAILDIG);
1171 /* With flag only, doesn't consume decimal point */
1172 CONVERT("$11.1", NUMPRS_CURRENCY);
1173 EXPECT(2,NUMPRS_CURRENCY,NUMPRS_CURRENCY,3,0,0);
1175 EXPECTRGB(2,FAILDIG);
1177 /* With flag and decimal flag, consumes decimal point and following digits */
1178 CONVERT("$11.1", NUMPRS_CURRENCY|NUMPRS_DECIMAL);
1179 EXPECT(3,NUMPRS_CURRENCY|NUMPRS_DECIMAL,NUMPRS_CURRENCY|NUMPRS_DECIMAL,5,0,-1);
1182 EXPECTRGB(3,FAILDIG);
1184 /* Thousands flag can only be used with currency */
1185 CONVERT("$1,234", NUMPRS_CURRENCY|NUMPRS_THOUSANDS);
1186 EXPECT(4,NUMPRS_CURRENCY|NUMPRS_THOUSANDS,NUMPRS_CURRENCY|NUMPRS_THOUSANDS,6,0,0);
1190 EXPECTRGB(4,FAILDIG);
1192 /** NUMPRS_DECIMAL **/
1194 /* With flag, consumes decimal point */
1195 CONVERT("1.1", NUMPRS_DECIMAL);
1196 EXPECT(2,NUMPRS_DECIMAL,NUMPRS_DECIMAL,3,0,-1);
1198 EXPECTRGB(2,FAILDIG);
1200 /* With flag, consumes decimal point. Skipping the decimal part is not an error */
1201 CONVERT("1.", NUMPRS_DECIMAL);
1202 EXPECT(1,NUMPRS_DECIMAL,NUMPRS_DECIMAL,2,0,0);
1205 /* Consumes only one decimal point */
1206 CONVERT("1.1.", NUMPRS_DECIMAL);
1207 EXPECT(2,NUMPRS_DECIMAL,NUMPRS_DECIMAL,3,0,-1);
1209 EXPECTRGB(2,FAILDIG);
1211 /** NUMPRS_EXPONENT **/
1213 /* Without flag, doesn't consume exponent */
1215 EXPECT(1,0,0,1,0,0);
1218 /* With flag, consumes exponent */
1219 CONVERT("1e1", NUMPRS_EXPONENT);
1220 EXPECT(1,NUMPRS_EXPONENT,NUMPRS_EXPONENT,3,0,1);
1223 /* Negative exponents are accepted without flags */
1224 CONVERT("1e-1", NUMPRS_EXPONENT);
1225 EXPECT(1,NUMPRS_EXPONENT,NUMPRS_EXPONENT,4,0,-1);
1228 /* As are positive exponents and leading exponent 0s */
1229 CONVERT("1e+01", NUMPRS_EXPONENT);
1230 EXPECT(1,NUMPRS_EXPONENT,NUMPRS_EXPONENT,5,0,1);
1233 /* The same for zero exponents */
1234 CONVERT("1e0", NUMPRS_EXPONENT);
1235 EXPECT(1,NUMPRS_EXPONENT,NUMPRS_EXPONENT,3,0,0);
1238 /* Sign on a zero exponent doesn't matter */
1239 CONVERT("1e+0", NUMPRS_EXPONENT);
1240 EXPECT(1,NUMPRS_EXPONENT,NUMPRS_EXPONENT,4,0,0);
1243 CONVERT("1e-0", NUMPRS_EXPONENT);
1244 EXPECT(1,NUMPRS_EXPONENT,NUMPRS_EXPONENT,4,0,0);
1247 /* Doesn't consume a real number exponent */
1248 CONVERT("1e1.", NUMPRS_EXPONENT);
1249 EXPECT(1,NUMPRS_EXPONENT,NUMPRS_EXPONENT,3,0,1);
1252 /* Powers of 10 are calculated from the position of any decimal point */
1253 CONVERT("1.5e20", NUMPRS_EXPONENT|NUMPRS_DECIMAL);
1254 EXPECT(2,NUMPRS_EXPONENT|NUMPRS_DECIMAL,NUMPRS_EXPONENT|NUMPRS_DECIMAL,6,0,19);
1257 CONVERT("1.5e-20", NUMPRS_EXPONENT|NUMPRS_DECIMAL);
1258 EXPECT(2,NUMPRS_EXPONENT|NUMPRS_DECIMAL,NUMPRS_EXPONENT|NUMPRS_DECIMAL,7,0,-21);
1261 /** NUMPRS_USE_ALL **/
1263 /* Flag expects all digits */
1264 CONVERT("0", NUMPRS_USE_ALL);
1265 EXPECT(1,NUMPRS_USE_ALL,0,1,0,0);
1268 /* Rejects anything trailing */
1269 CONVERT("0 ", NUMPRS_USE_ALL);
1273 /* Unless consumed by trailing flag */
1274 CONVERT("0 ", NUMPRS_USE_ALL|NUMPRS_TRAILING_WHITE);
1275 EXPECT(1,NUMPRS_USE_ALL|NUMPRS_TRAILING_WHITE,NUMPRS_TRAILING_WHITE,2,0,0);
1278 /** Combinations **/
1280 /* Leading whitespace and plus, doesn't consume trailing whitespace */
1281 CONVERT("+ 0 ", NUMPRS_LEADING_PLUS|NUMPRS_LEADING_WHITE);
1282 EXPECT(1,NUMPRS_LEADING_PLUS|NUMPRS_LEADING_WHITE,NUMPRS_LEADING_PLUS|NUMPRS_LEADING_WHITE,3,0,0);
1285 /* Order of whitespace and plus is unimportant */
1286 CONVERT(" +0", NUMPRS_LEADING_PLUS|NUMPRS_LEADING_WHITE);
1287 EXPECT(1,NUMPRS_LEADING_PLUS|NUMPRS_LEADING_WHITE,NUMPRS_LEADING_PLUS|NUMPRS_LEADING_WHITE,3,0,0);
1290 /* Leading whitespace can be repeated */
1291 CONVERT(" + 0", NUMPRS_LEADING_PLUS|NUMPRS_LEADING_WHITE);
1292 EXPECT(1,NUMPRS_LEADING_PLUS|NUMPRS_LEADING_WHITE,NUMPRS_LEADING_PLUS|NUMPRS_LEADING_WHITE,4,0,0);
1295 /* But plus/minus etc. cannot */
1296 CONVERT("+ +0", NUMPRS_LEADING_PLUS|NUMPRS_LEADING_WHITE);
1298 EXPECTRGB(0,FAILDIG);
1300 /* Inexact is not set if trailing zeros are removed */
1301 CONVERTN("10", 1, 0);
1302 EXPECT(1,0,0,2,0,1);
1305 /* Make sure a leading 0 is stripped but decimals after it get read */
1306 CONVERT("-0.51", NUMPRS_STD);
1307 EXPECT(2,NUMPRS_STD,NUMPRS_NEG|NUMPRS_DECIMAL|NUMPRS_LEADING_MINUS,5,0,-2);
1310 /* Keep trailing zeros on whole number part of a decimal */
1311 CONVERT("10.1", NUMPRS_STD);
1312 EXPECT(3,NUMPRS_STD,NUMPRS_DECIMAL,4,0,-1);
1316 /* Zeros after decimal sign */
1317 CONVERT("0.01", NUMPRS_STD);
1318 EXPECT(1,NUMPRS_STD,NUMPRS_DECIMAL,4,0,-2);
1321 /* Trailing zeros after decimal part */
1322 CONVERT("0.10", NUMPRS_STD);
1323 EXPECT(1,NUMPRS_STD,NUMPRS_DECIMAL,4,0,-1);
1327 static HRESULT (WINAPI *pVarNumFromParseNum)(NUMPARSE*,BYTE*,ULONG,VARIANT*);
1329 /* Macros for converting and testing the result of VarNumFromParseNum */
1330 #define SETRGB(indx,val) if (!indx) memset(rgb, FAILDIG, sizeof(rgb)); rgb[indx] = val
1332 #define CONVERT(a,b,c,d,e,f,bits) \
1333 np.cDig = (a); np.dwInFlags = (b); np.dwOutFlags = (c); np.cchUsed = (d); \
1334 np.nBaseShift = (e); np.nPwr10 = (f); hres = pVarNumFromParseNum(&np, rgb, bits, &vOut)
1335 static const char *szFailOverflow = "Expected overflow, hres = %08x\n";
1336 #define EXPECT_OVERFLOW ok(hres == (HRESULT)DISP_E_OVERFLOW, szFailOverflow, hres)
1337 static const char *szFailOk = "Call failed, hres = %08x\n";
1338 #define EXPECT_OK ok(hres == (HRESULT)S_OK, szFailOk, hres); \
1339 if (hres == (HRESULT)S_OK)
1340 #define EXPECT_TYPE(typ) ok(V_VT(&vOut) == typ,"Expected Type = " #typ ", got %d\n", V_VT(&vOut))
1341 #define EXPECT_I1(val) EXPECT_OK { EXPECT_TYPE(VT_I1); \
1342 ok(V_I1(&vOut) == val, "Expected i1 = %d, got %d\n", (signed char)val, V_I1(&vOut)); }
1343 #define EXPECT_UI1(val) EXPECT_OK { EXPECT_TYPE(VT_UI1); \
1344 ok(V_UI1(&vOut) == val, "Expected ui1 = %d, got %d\n", (BYTE)val, V_UI1(&vOut)); }
1345 #define EXPECT_I2(val) EXPECT_OK { EXPECT_TYPE(VT_I2); \
1346 ok(V_I2(&vOut) == val, "Expected i2 = %d, got %d\n", (SHORT)val, V_I2(&vOut)); }
1347 #define EXPECT_UI2(val) EXPECT_OK { EXPECT_TYPE(VT_UI2); \
1348 ok(V_UI2(&vOut) == val, "Expected ui2 = %d, got %d\n", (USHORT)val, V_UI2(&vOut)); }
1349 #define EXPECT_I4(val) EXPECT_OK { EXPECT_TYPE(VT_I4); \
1350 ok(V_I4(&vOut) == val, "Expected i4 = %d, got %d\n", (LONG)val, V_I4(&vOut)); }
1351 #define EXPECT_UI4(val) EXPECT_OK { EXPECT_TYPE(VT_UI4); \
1352 ok(V_UI4(&vOut) == val, "Expected ui4 = %d, got %d\n", (ULONG)val, V_UI4(&vOut)); }
1353 #define EXPECT_I8(high,low) EXPECT_OK { EXPECT_TYPE(VT_I8); \
1354 ok(V_I8(&vOut) == ((((LONG64)(high))<<32)|(low)), "Expected i8 = %x%08x, got %x%08x\n", \
1355 (LONG)(high), (LONG)(low), (LONG)(V_I8(&vOut)>>32), (LONG)V_I8(&vOut) ); }
1356 #define EXPECT_UI8(val) EXPECT_OK { EXPECT_TYPE(VT_UI8); \
1357 ok(V_UI8(&vOut) == val, "Expected ui8 = 0x%x%08x, got 0x%x%08x\n", \
1358 (DWORD)((ULONG64)val >> 32), (DWORD)(ULONG64)val, (DWORD)(V_UI8(&vOut) >> 32), (DWORD)V_UI8(&vOut)); }
1359 #define EXPECT_R4(val) EXPECT_OK { EXPECT_TYPE(VT_R4); \
1360 ok(V_R4(&vOut) == val, "Expected r4 = %f, got %f\n", val, V_R4(&vOut)); }
1361 #define EXPECT_R8(val) EXPECT_OK { EXPECT_TYPE(VT_R8); \
1362 ok(V_R8(&vOut) == val, "Expected r8 = %g, got %g\n", val, V_R8(&vOut)); }
1363 #define CY_MULTIPLIER 10000
1364 #define EXPECT_CY(val) EXPECT_OK { EXPECT_TYPE(VT_CY); \
1365 ok(V_CY(&vOut).int64 == (LONG64)(val * CY_MULTIPLIER), "Expected r8 = 0x%x%08x, got 0x%x%08x\n", \
1366 (DWORD)((LONG64)val >> 23), (DWORD)(LONG64)val, (DWORD)(V_CY(&vOut).int64 >>32), (DWORD)V_CY(&vOut).int64); }
1367 #define EXPECT_DECIMAL(valHi, valMid, valLo) EXPECT_OK { EXPECT_TYPE(VT_DECIMAL); \
1368 ok((V_DECIMAL(&vOut).Hi32 == valHi) && (S1(U1(V_DECIMAL(&vOut))).Mid32 == valMid) && \
1369 (S1(U1(V_DECIMAL(&vOut))).Lo32 == valLo), \
1370 "Expected decimal = %x/0x%x%08x, got %x/0x%x%08x\n", valHi, valMid, valLo, \
1371 V_DECIMAL(&vOut).Hi32, S1(U1(V_DECIMAL(&vOut))).Mid32, S1(U1(V_DECIMAL(&vOut))).Lo32); }
1373 static void test_VarNumFromParseNum(void)
1380 CHECKPTR(VarNumFromParseNum);
1382 /* Convert the number 1 to different types */
1383 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_I1); EXPECT_I1(1);
1384 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_UI1); EXPECT_UI1(1);
1385 /* Prefers a signed type to unsigned of the same size */
1386 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_I1|VTBIT_UI1); EXPECT_I1(1);
1387 /* But takes the smaller size if possible */
1388 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_I2|VTBIT_UI1); EXPECT_UI1(1);
1390 /* Try different integer sizes */
1391 #define INTEGER_VTBITS (VTBIT_I1|VTBIT_UI1|VTBIT_I2|VTBIT_UI2|VTBIT_I4|VTBIT_UI4|VTBIT_I8|VTBIT_UI8)
1393 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, INTEGER_VTBITS); EXPECT_I1(1);
1395 SETRGB(0, 1); SETRGB(1, 2); SETRGB(2, 7);
1396 CONVERT(3,0,0,3,0,0, INTEGER_VTBITS); EXPECT_I1(127);
1398 SETRGB(0, 1); SETRGB(1, 2); SETRGB(2, 8);
1399 CONVERT(3,0,0,3,0,0, INTEGER_VTBITS); EXPECT_UI1(128);
1401 SETRGB(0, 2); SETRGB(1, 5); SETRGB(2, 5);
1402 CONVERT(3,0,0,3,0,0, INTEGER_VTBITS); EXPECT_UI1(255);
1404 SETRGB(0, 2); SETRGB(1, 5); SETRGB(2, 6);
1405 CONVERT(3,0,0,3,0,0, INTEGER_VTBITS); EXPECT_I2(256);
1407 SETRGB(0, 3); SETRGB(1, 2); SETRGB(2, 7); SETRGB(3, 6); SETRGB(4, 7);
1408 CONVERT(5,0,0,5,0,0, INTEGER_VTBITS); EXPECT_I2(32767);
1410 SETRGB(0, 3); SETRGB(1, 2); SETRGB(2, 7); SETRGB(3, 6); SETRGB(4, 8);
1411 CONVERT(5,0,0,5,0,0, INTEGER_VTBITS); EXPECT_UI2(32768);
1413 /* Assume the above pattern holds for remaining positive integers; test negative */
1416 SETRGB(0, 1); SETRGB(1, 2); SETRGB(2, 8);
1417 CONVERT(3,0,NUMPRS_NEG,3,0,0, INTEGER_VTBITS); EXPECT_I1(-128);
1419 SETRGB(0, 1); SETRGB(1, 2); SETRGB(2, 9);
1420 CONVERT(3,0,NUMPRS_NEG,3,0,0, INTEGER_VTBITS); EXPECT_I2(-129);
1422 SETRGB(0, 3); SETRGB(1, 2); SETRGB(2, 7); SETRGB(3, 6); SETRGB(4, 8);
1423 CONVERT(5,0,NUMPRS_NEG,5,0,0, INTEGER_VTBITS); EXPECT_I2(-32768);
1425 SETRGB(0, 3); SETRGB(1, 2); SETRGB(2, 7); SETRGB(3, 6); SETRGB(4, 9);
1426 CONVERT(5,0,NUMPRS_NEG,5,0,0, INTEGER_VTBITS); EXPECT_I4(-32769);
1428 /* Assume the above pattern holds for remaining negative integers */
1430 /* Test hexadecimal conversions */
1431 SETRGB(0, 1); CONVERT(1,0,0,1,4,0, INTEGER_VTBITS); EXPECT_I1(0x01);
1433 SETRGB(0, 7); SETRGB(1, 0xf);
1434 CONVERT(2,0,0,2,4,0, INTEGER_VTBITS); EXPECT_I1(0x7f);
1435 SETRGB(0, 7); SETRGB(1, 0xf);
1436 CONVERT(2,0,0,2,4,0, VTBIT_DECIMAL); EXPECT_DECIMAL(0,0,0x7f);
1438 SETRGB(0, 7); SETRGB(1, 0xf); SETRGB(2, 0xf); SETRGB(3, 0xf);
1439 CONVERT(4,0,0,4,4,0, INTEGER_VTBITS); EXPECT_I2(0x7fff);
1441 SETRGB(0, 7); SETRGB(1, 0xf); SETRGB(2, 0xf); SETRGB(3, 0xf);
1442 SETRGB(4, 0xf); SETRGB(5, 0xf); SETRGB(6, 0xf); SETRGB(7, 0xf);
1443 CONVERT(8,0,0,8,4,0, INTEGER_VTBITS); EXPECT_I4(0x7fffffffL);
1444 /* 0x7fffffffffffffff (64 bits) */
1445 SETRGB(0, 7); SETRGB(1, 0xf); SETRGB(2, 0xf); SETRGB(3, 0xf);
1446 SETRGB(4, 0xf); SETRGB(5, 0xf); SETRGB(6, 0xf); SETRGB(7, 0xf);
1447 SETRGB(8, 0xf); SETRGB(9, 0xf); SETRGB(10, 0xf); SETRGB(11, 0xf);
1448 SETRGB(12, 0xf); SETRGB(13, 0xf); SETRGB(14, 0xf); SETRGB(15, 0xf);
1449 if (HAVE_OLEAUT32_I8)
1451 /* We cannot use INTEGER_VTBITS as WinXP and Win2003 are broken(?). They
1452 truncate the number to the smallest integer size requested:
1453 CONVERT(16,0,0,16,4,0, INTEGER_VTBITS); EXPECT_I1((signed char)0xff); */
1454 CONVERT(16,0,0,16,4,0, VTBIT_I8); EXPECT_I8(0x7fffffff,0xffffffff);
1457 /* Assume the above pattern holds for numbers without hi-bit set, test (preservation of) hi-bit */
1459 SETRGB(0, 8); SETRGB(1, 2);
1460 CONVERT(2,0,0,2,4,0, INTEGER_VTBITS);
1461 EXPECT_I1((signed char)0x82);
1463 SETRGB(0, 8); SETRGB(1, 0); SETRGB(2, 0); SETRGB(3, 2);
1464 CONVERT(4,0,0,4,4,0, INTEGER_VTBITS);
1465 EXPECT_I2((signed short)0x8002);
1467 SETRGB(0, 8); SETRGB(1, 0); SETRGB(2, 0); SETRGB(3, 0);
1468 SETRGB(4, 0); SETRGB(5, 0); SETRGB(6, 0); SETRGB(7, 2);
1469 CONVERT(8,0,0,8,4,0, INTEGER_VTBITS); EXPECT_I4(0x80000002);
1470 /* 0x8000000000000002 (64 bits) */
1471 SETRGB(0, 8); SETRGB(1, 0); SETRGB(2, 0); SETRGB(3, 0);
1472 SETRGB(4, 0); SETRGB(5, 0); SETRGB(6, 0); SETRGB(7, 0);
1473 SETRGB(8, 0); SETRGB(9, 0); SETRGB(10, 0); SETRGB(11, 0);
1474 SETRGB(12, 0); SETRGB(13, 0); SETRGB(14, 0); SETRGB(15, 2);
1475 if (HAVE_OLEAUT32_I8)
1477 /* We cannot use INTEGER_VTBITS as WinXP and Win2003 are broken(?). They
1478 truncate the number to the smallest integer size requested:
1479 CONVERT(16,0,0,16,4,0, INTEGER_VTBITS & ~VTBIT_I1);
1480 EXPECT_I2((signed short)0x0002); */
1481 CONVERT(16,0,0,16,4,0, VTBIT_I8); EXPECT_I8(0x80000000,0x00000002);
1484 /* Test (preservation of) hi-bit with STRICT type requesting */
1486 SETRGB(0, 8); SETRGB(1, 2);
1487 CONVERT(2,0,0,2,4,0, VTBIT_I1);
1488 EXPECT_I1((signed char)0x82);
1490 SETRGB(0, 8); SETRGB(1, 0); SETRGB(2, 0); SETRGB(3, 2);
1491 CONVERT(4,0,0,4,4,0, VTBIT_I2);
1492 EXPECT_I2((signed short)0x8002);
1494 SETRGB(0, 8); SETRGB(1, 0); SETRGB(2, 0); SETRGB(3, 0);
1495 SETRGB(4, 0); SETRGB(5, 0); SETRGB(6, 0); SETRGB(7, 2);
1496 CONVERT(8,0,0,8,4,0, VTBIT_I4); EXPECT_I4(0x80000002);
1497 /* 0x8000000000000002 (64 bits) */
1498 SETRGB(0, 8); SETRGB(1, 0); SETRGB(2, 0); SETRGB(3, 0);
1499 SETRGB(4, 0); SETRGB(5, 0); SETRGB(6, 0); SETRGB(7, 0);
1500 SETRGB(8, 0); SETRGB(9, 0); SETRGB(10, 0); SETRGB(11, 0);
1501 SETRGB(12, 0); SETRGB(13, 0); SETRGB(14, 0); SETRGB(15, 2);
1502 if (HAVE_OLEAUT32_I8)
1504 CONVERT(16,0,0,16,4,0, VTBIT_I8); EXPECT_I8(0x80000000,0x00000002);
1506 /* Assume the above pattern holds for numbers with hi-bit set */
1508 /* Negative numbers overflow if we have only unsigned outputs */
1510 SETRGB(0, 1); CONVERT(1,0,NUMPRS_NEG,1,0,0, VTBIT_UI1); EXPECT_OVERFLOW;
1512 SETRGB(0, 6); CONVERT(1,0,NUMPRS_NEG,1,0,~0u, VTBIT_UI1); EXPECT_OVERFLOW;
1514 /* Except that rounding is done first, so -0.5 to 0 are accepted as 0 */
1516 SETRGB(0, 5); CONVERT(1,0,NUMPRS_NEG,1,0,~0u, VTBIT_UI1); EXPECT_UI1(0);
1518 /* Floating point zero is OK */
1520 SETRGB(0, 0); CONVERT(1,0,NUMPRS_DECIMAL|NUMPRS_EXPONENT,12,0,-8, VTBIT_R8);
1523 /* Float is acceptable for an integer input value */
1524 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_R4); EXPECT_R4(1.0f);
1526 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_R8); EXPECT_R8(1.0);
1527 /* As is currency */
1528 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_CY); EXPECT_CY(1);
1530 /* Float is preferred over double */
1531 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_R4|VTBIT_R8); EXPECT_R4(1.0f);
1533 /* Double is preferred over currency */
1534 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_R8|VTBIT_CY); EXPECT_R8(1.0);
1536 /* Currency is preferred over decimal */
1537 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_CY|VTBIT_DECIMAL); EXPECT_CY(1);
1541 static void test_UdateFromDate( int line, DATE dt, ULONG flags, HRESULT r, WORD d, WORD m, WORD y,
1542 WORD h, WORD mn, WORD s, WORD ms, WORD dw, WORD dy)
1547 memset(&ud, 0, sizeof(ud));
1548 res = pVarUdateFromDate(dt, flags, &ud);
1549 ok_(__FILE__,line)(r == res, "Wrong result %x/%x\n", r, res);
1551 ok_(__FILE__,line)(ud.st.wYear == y && ud.st.wMonth == m && ud.st.wDay == d &&
1552 ud.st.wHour == h && ud.st.wMinute == mn && ud.st.wSecond == s &&
1553 ud.st.wMilliseconds == ms && ud.st.wDayOfWeek == dw && ud.wDayOfYear == dy,
1554 "%.16g expected %d,%d,%d,%d,%d,%d,%d %d %d, got %d,%d,%d,%d,%d,%d,%d %d %d\n",
1555 dt, d, m, y, h, mn, s, ms, dw, dy,
1556 ud.st.wDay, ud.st.wMonth, ud.st.wYear, ud.st.wHour, ud.st.wMinute,
1557 ud.st.wSecond, ud.st.wMilliseconds, ud.st.wDayOfWeek, ud.wDayOfYear );
1559 #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)
1561 static void test_VarUdateFromDate(void)
1563 CHECKPTR(VarUdateFromDate);
1564 DT2UD(29221.0,0,S_OK,1,1,1980,0,0,0,0,2,1); /* 1 Jan 1980 */
1565 DT2UD(29222.0,0,S_OK,2,1,1980,0,0,0,0,3,2); /* 2 Jan 1980 */
1566 DT2UD(33238.0,0,S_OK,31,12,1990,0,0,0,0,1,365); /* 31 Dec 1990 */
1567 DT2UD(0.0,0,S_OK,30,12,1899,0,0,0,0,6,364); /* 30 Dec 1899 - VT_DATE 0.0 */
1568 DT2UD(-657434.0,0,S_OK,1,1,100,0,0,0,0,5,1); /* 1 Jan 100 - Min */
1569 DT2UD(-657435.0,0,E_INVALIDARG,0,0,0,0,0,0,0,0,0); /* < 1 Jan 100 => err */
1570 DT2UD(2958465.0,0,S_OK,31,12,9999,0,0,0,0,5,365); /* 31 Dec 9999 - Max */
1571 DT2UD(2958466.0,0,E_INVALIDARG,0,0,0,0,0,0,0,0,0); /* > 31 Dec 9999 => err */
1573 /* VAR_VALIDDATE doesn't prevent upper and lower bounds being checked */
1574 DT2UD(-657435.0,VAR_VALIDDATE,E_INVALIDARG,0,0,0,0,0,0,0,0,0);
1575 DT2UD(2958466.0,VAR_VALIDDATE,E_INVALIDARG,0,0,0,0,0,0,0,0,0);
1578 DT2UD(29221.25,0,S_OK,1,1,1980,6,0,0,0,2,1); /* 6 AM */
1579 DT2UD(29221.33333333,0,S_OK,1,1,1980,8,0,0,0,2,1); /* 8 AM */
1580 DT2UD(29221.5,0,S_OK,1,1,1980,12,0,0,0,2,1); /* 12 AM */
1581 DT2UD(29221.9888884444,0,S_OK,1,1,1980,23,44,0,0,2,1); /* 11:44 PM */
1582 DT2UD(29221.7508765432,0,S_OK,1,1,1980,18,1,16,0,2,1); /* 6:18:02 PM */
1586 static void test_DateFromUDate( int line, WORD d, WORD m, WORD y, WORD h, WORD mn, WORD s, WORD ms,
1587 WORD dw, WORD dy, ULONG flags, HRESULT r, DATE dt )
1599 ud.st.wMilliseconds = ms;
1600 ud.st.wDayOfWeek = dw;
1602 res = pVarDateFromUdate(&ud, flags, &out);
1603 ok_(__FILE__,line)(r == res && (FAILED(r) || EQ_DOUBLE(out, dt)),
1604 "expected %x, %.16g, got %x, %.16g\n", r, dt, res, out);
1606 #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)
1608 static void test_VarDateFromUdate(void)
1610 CHECKPTR(VarDateFromUdate);
1611 UD2T(1,1,1980,0,0,0,0,2,1,0,S_OK,29221.0); /* 1 Jan 1980 */
1612 UD2T(2,1,1980,0,0,0,0,3,2,0,S_OK,29222.0); /* 2 Jan 1980 */
1613 UD2T(31,12,1990,0,0,0,0,0,0,0,S_OK,33238.0); /* 31 Dec 1990 */
1614 UD2T(31,12,90,0,0,0,0,0,0,0,S_OK,33238.0); /* year < 100 is 1900+year! */
1615 UD2T(30,12,1899,0,0,0,0,6,364,0,S_OK,0.0); /* 30 Dec 1899 - VT_DATE 0.0 */
1616 UD2T(1,1,100,0,0,0,0,0,0,0,S_OK,-657434.0); /* 1 Jan 100 - Min */
1617 UD2T(31,12,9999,0,0,0,0,0,0,0,S_OK,2958465.0); /* 31 Dec 9999 - Max */
1618 UD2T(1,1,10000,0,0,0,0,0,0,0,E_INVALIDARG,0.0); /* > 31 Dec 9999 => err */
1620 UD2T(1,1,1980,18,1,16,0,2,1,0,S_OK,29221.75087962963); /* 6:18:02 PM */
1622 UD2T(0,1,1980,0,0,0,0,2,1,0,S_OK,29220.0); /* Rolls back to 31 Dec 1899 */
1623 UD2T(1,13,1980,0,0,0,0,2,1,0,S_OK,29587.0); /* Rolls fwd to 1/1/1981 */
1626 static void test_st2dt(int line, WORD d, WORD m, WORD y, WORD h, WORD mn,
1627 WORD s, WORD ms, INT r, double dt)
1639 st.wMilliseconds = ms;
1641 res = pSystemTimeToVariantTime(&st, &out);
1642 ok_(__FILE__,line)(r == res && (!r || EQ_DOUBLE(out, dt)),
1643 "expected %d, %.16g, got %d, %.16g\n", r, dt, res, out);
1645 #define ST2DT(d,m,y,h,mn,s,ms,r,dt) test_st2dt(__LINE__,d,m,y,h,mn,s,ms,r,dt)
1647 static void test_SystemTimeToVariantTime(void)
1649 CHECKPTR(SystemTimeToVariantTime);
1650 ST2DT(1,1,1980,0,0,0,0,TRUE,29221.0);
1651 ST2DT(2,1,1980,0,0,0,0,TRUE,29222.0);
1652 ST2DT(0,1,1980,0,0,0,0,TRUE,29220.0); /* Rolls back to 31 Dec 1899 */
1653 ST2DT(1,13,1980,0,0,0,0,FALSE,29587.0); /* Fails on invalid month */
1654 ST2DT(31,12,90,0,0,0,0,TRUE,33238.0); /* year < 100 is 1900+year! */
1657 static void test_dt2st(int line, double dt, INT r, WORD d, WORD m, WORD y,
1658 WORD h, WORD mn, WORD s, WORD ms)
1663 memset(&st, 0, sizeof(st));
1664 res = pVariantTimeToSystemTime(dt, &st);
1665 ok_(__FILE__,line)(r == res &&
1666 (!r || (st.wYear == y && st.wMonth == m && st.wDay == d &&
1667 st.wHour == h && st.wMinute == mn &&
1668 st.wSecond == s && st.wMilliseconds == ms)),
1669 "%.16g expected %d, %d,%d,%d,%d,%d,%d,%d, got %d, %d,%d,%d,%d,%d,%d,%d\n",
1670 dt, r, d, m, y, h, mn, s, ms, res, st.wDay, st.wMonth,
1671 st.wYear, st.wHour, st.wMinute, st.wSecond,
1674 #define DT2ST(dt,r,d,m,y,h,mn,s,ms) test_dt2st(__LINE__,dt,r,d,m,y,h,mn,s,ms)
1676 static void test_VariantTimeToSystemTime(void)
1678 CHECKPTR(VariantTimeToSystemTime);
1679 DT2ST(29221.0,1,1,1,1980,0,0,0,0);
1680 DT2ST(29222.0,1,2,1,1980,0,0,0,0);
1683 #define MKDOSDATE(d,m,y) ((d & 0x1f) | ((m & 0xf) << 5) | (((y-1980) & 0x7f) << 9))
1684 #define MKDOSTIME(h,m,s) (((s>>1) & 0x1f) | ((m & 0x3f) << 5) | ((h & 0x1f) << 11))
1686 static void test_dos2dt(int line, WORD d, WORD m, WORD y, WORD h, WORD mn,
1687 WORD s, INT r, double dt)
1689 unsigned short dosDate, dosTime;
1694 dosDate = MKDOSDATE(d, m, y);
1695 dosTime = MKDOSTIME(h, mn, s);
1696 res = pDosDateTimeToVariantTime(dosDate, dosTime, &out);
1697 ok_(__FILE__,line)(r == res && (!r || EQ_DOUBLE(out, dt)),
1698 "expected %d, %.16g, got %d, %.16g\n", r, dt, res, out);
1700 #define DOS2DT(d,m,y,h,mn,s,r,dt) test_dos2dt(__LINE__,d,m,y,h,mn,s,r,dt)
1702 static void test_DosDateTimeToVariantTime(void)
1704 CHECKPTR(DosDateTimeToVariantTime);
1707 DOS2DT(1,1,1980,0,0,0,1,29221.0); /* 1/1/1980 */
1708 DOS2DT(31,12,2099,0,0,0,1,73050.0); /* 31/12/2099 */
1709 /* Dates are limited to the dos date max of 31/12/2099 */
1710 DOS2DT(31,12,2100,0,0,0,0,0.0); /* 31/12/2100 */
1711 /* Days and months of 0 cause date to roll back 1 day or month */
1712 DOS2DT(0,1,1980,0,0,0,1,29220.0); /* 0 Day => 31/12/1979 */
1713 DOS2DT(1,0,1980,0,0,0,1,29190.0); /* 0 Mth => 1/12/1979 */
1714 DOS2DT(0,0,1980,0,0,0,1,29189.0); /* 0 D/M => 30/11/1979 */
1715 /* Days > days in the month cause date to roll forward 1 month */
1716 DOS2DT(29,2,1981,0,0,0,1,29646.0); /* 29/2/1981 -> 3/1/1980 */
1717 DOS2DT(30,2,1981,0,0,0,1,29647.0); /* 30/2/1981 -> 4/1/1980 */
1718 /* Takes leap years into account when rolling forward */
1719 DOS2DT(29,2,1980,0,0,0,1,29280.0); /* 2/29/1980 */
1720 /* Months > 12 cause an error */
1721 DOS2DT(2,13,1980,0,0,0,0,0.0);
1724 DOS2DT(1,1,1980,0,0,29,1,29221.00032407407); /* 1/1/1980 12:00:28 AM */
1725 DOS2DT(1,1,1980,0,0,31,1,29221.00034722222); /* 1/1/1980 12:00:30 AM */
1726 DOS2DT(1,1,1980,0,59,0,1,29221.04097222222); /* 1/1/1980 12:59:00 AM */
1727 DOS2DT(1,1,1980,0,60,0,0,0.0); /* Invalid seconds */
1728 DOS2DT(1,1,1980,23,0,0,1,29221.95833333333); /* 1/1/1980 11:00:00 PM */
1729 DOS2DT(1,1,1980,24,0,0,0,0.0); /* Invalid hours */
1732 static void test_dt2dos(int line, double dt, INT r, WORD d, WORD m, WORD y,
1733 WORD h, WORD mn, WORD s)
1735 unsigned short dosDate, dosTime, expDosDate, expDosTime;
1738 dosTime = dosDate = 0;
1739 expDosDate = MKDOSDATE(d,m,y);
1740 expDosTime = MKDOSTIME(h,mn,s);
1741 res = pVariantTimeToDosDateTime(dt, &dosDate, &dosTime);
1742 ok_(__FILE__,line)(r == res && (!r || (dosTime == expDosTime && dosDate == expDosDate)),
1743 "%g: expected %d,%d(%d/%d/%d),%d(%d:%d:%d) got %d,%d(%d/%d/%d),%d(%d:%d:%d)\n",
1744 dt, r, expDosDate, expDosDate & 0x1f,
1745 (expDosDate >> 5) & 0xf, 1980 + (expDosDate >> 9),
1746 expDosTime, expDosTime >> 11, (expDosTime >> 5) & 0x3f,
1747 (expDosTime & 0x1f),
1748 res, dosDate, dosDate & 0x1f, (dosDate >> 5) & 0xf,
1749 1980 + (dosDate >> 9), dosTime, dosTime >> 11,
1750 (dosTime >> 5) & 0x3f, (dosTime & 0x1f));
1752 #define DT2DOS(dt,r,d,m,y,h,mn,s) test_dt2dos(__LINE__,dt,r,d,m,y,h,mn,s)
1754 static void test_VariantTimeToDosDateTime(void)
1756 CHECKPTR(VariantTimeToDosDateTime);
1759 DT2DOS(29221.0,1,1,1,1980,0,0,0); /* 1/1/1980 */
1760 DT2DOS(73050.0,1,31,12,2099,0,0,0); /* 31/12/2099 */
1761 DT2DOS(29220.0,0,0,0,0,0,0,0); /* 31/12/1979 - out of range */
1762 DT2DOS(73415.0,0,0,0,0,0,0,0); /* 31/12/2100 - out of range */
1765 DT2DOS(29221.00032407407,1,1,1,1980,0,0,29); /* 1/1/1980 12:00:28 AM */
1766 DT2DOS(29221.00034722222,1,1,1,1980,0,0,31); /* 1/1/1980 12:00:30 AM */
1767 DT2DOS(29221.04097222222,1,1,1,1980,0,59,0); /* 1/1/1980 12:59:00 AM */
1768 DT2DOS(29221.95833333333,1,1,1,1980,23,0,0); /* 1/1/1980 11:00:00 PM */
1771 static HRESULT (WINAPI *pVarAbs)(LPVARIANT,LPVARIANT);
1773 #define VARABS(vt,val,rvt,rval) \
1774 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
1775 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
1776 test_var_call1( __LINE__, pVarAbs, &v, &exp )
1778 static void test_VarAbs(void)
1780 static WCHAR szNum[] = {'-','1','.','1','\0' };
1783 VARIANT v, vDst, exp;
1788 /* Test all possible V_VT values.
1790 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
1794 for (vt = 0; vt <= VT_BSTR_BLOB; vt++)
1796 HRESULT hExpected = DISP_E_BADVARTYPE;
1800 memset(&v, 0, sizeof(v));
1801 V_VT(&v) = vt | ExtraFlags[i];
1802 V_VT(&vDst) = VT_EMPTY;
1804 hres = pVarAbs(&v,&vDst);
1805 if (ExtraFlags[i] & (VT_ARRAY|VT_ARRAY) ||
1806 (!ExtraFlags[i] && (vt == VT_UNKNOWN || vt == VT_BSTR ||
1807 vt == VT_DISPATCH || vt == VT_ERROR || vt == VT_RECORD)))
1809 hExpected = DISP_E_TYPEMISMATCH;
1811 else if (ExtraFlags[i] || vt >= VT_CLSID || vt == VT_VARIANT)
1813 hExpected = DISP_E_BADVARTYPE;
1815 else if (IsValidVariantClearVT(vt, ExtraFlags[i]))
1818 /* Native always fails on some vartypes that should be valid. don't
1819 * check that Wine does the same; these are bugs in native.
1821 if (vt == VT_I8 || vt == VT_UI8 || vt == VT_INT || vt == VT_UINT ||
1822 vt == VT_I1 || vt == VT_UI2 || vt == VT_UI4)
1824 ok(hres == hExpected, "VarAbs: expected 0x%X, got 0x%X for vt %d | 0x%X\n",
1825 hExpected, hres, vt, ExtraFlags[i]);
1829 /* BOOL->I2, BSTR->R8, all others remain the same */
1830 VARABS(BOOL,VARIANT_TRUE,I2,-VARIANT_TRUE);
1831 VARABS(BOOL,VARIANT_FALSE,I2,VARIANT_FALSE);
1832 VARABS(EMPTY,0,I2,0);
1833 VARABS(EMPTY,1,I2,0);
1834 VARABS(NULL,0,NULL,0);
1835 VARABS(NULL,1,NULL,0);
1840 VARABS(UI1,1,UI1,1);
1845 VARABS(DATE,1,DATE,1);
1846 VARABS(DATE,-1,DATE,1);
1848 V_CY(&v).int64 = -10000;
1849 memset(&vDst,0,sizeof(vDst));
1850 hres = pVarAbs(&v,&vDst);
1851 ok(hres == S_OK && V_VT(&vDst) == VT_CY && V_CY(&vDst).int64 == 10000,
1852 "VarAbs(CY): expected 0x0 got 0x%X\n", hres);
1853 GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, buff, sizeof(buff)/sizeof(char));
1856 trace("Skipping VarAbs(BSTR) as decimal separator is '%s'\n", buff);
1862 V_BSTR(&v) = (BSTR)szNum;
1863 memset(&vDst,0,sizeof(vDst));
1864 hres = pVarAbs(&v,&vDst);
1865 ok(hres == S_OK && V_VT(&vDst) == VT_R8 && V_R8(&vDst) == 1.1,
1866 "VarAbs: expected 0x0,%d,%g, got 0x%X,%d,%g\n", VT_R8, 1.1, hres, V_VT(&vDst), V_R8(&vDst));
1869 static HRESULT (WINAPI *pVarNot)(LPVARIANT,LPVARIANT);
1871 #define VARNOT(vt,val,rvt,rval) \
1872 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
1873 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
1874 test_var_call1( __LINE__, pVarNot, &v, &exp )
1876 static void test_VarNot(void)
1878 static const WCHAR szNum0[] = {'0','\0' };
1879 static const WCHAR szNum1[] = {'1','\0' };
1881 VARIANT v, exp, vDst;
1882 DECIMAL *pdec = &V_DECIMAL(&v);
1883 CY *pcy = &V_CY(&v);
1888 /* Test all possible V_VT values */
1889 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
1893 for (vt = 0; vt <= VT_BSTR_BLOB; vt++)
1895 HRESULT hExpected = DISP_E_BADVARTYPE;
1899 memset(&v, 0, sizeof(v));
1900 V_VT(&v) = vt | ExtraFlags[i];
1901 V_VT(&vDst) = VT_EMPTY;
1905 case VT_I1: case VT_UI1: case VT_I2: case VT_UI2:
1906 case VT_INT: case VT_UINT: case VT_I4: case VT_UI4:
1907 case VT_R4: case VT_R8:
1908 case VT_DECIMAL: case VT_BOOL: case VT_NULL: case VT_EMPTY:
1909 case VT_DATE: case VT_CY:
1912 case VT_I8: case VT_UI8:
1913 if (HAVE_OLEAUT32_I8)
1917 if (HAVE_OLEAUT32_RECORD)
1918 hExpected = DISP_E_TYPEMISMATCH;
1920 case VT_UNKNOWN: case VT_BSTR: case VT_DISPATCH: case VT_ERROR:
1921 hExpected = DISP_E_TYPEMISMATCH;
1924 if (IsValidVariantClearVT(vt, ExtraFlags[i]) && vt != VT_CLSID)
1925 hExpected = DISP_E_TYPEMISMATCH;
1929 hres = pVarNot(&v,&vDst);
1930 ok(hres == hExpected, "VarNot: expected 0x%X, got 0x%X vt %d|0x%X\n",
1931 hExpected, hres, vt, ExtraFlags[i]);
1934 /* Test the values returned by all cases that can succeed */
1935 VARNOT(EMPTY,0,I2,-1);
1936 VARNOT(EMPTY,1,I2,-1);
1937 VARNOT(NULL,0,NULL,0);
1938 VARNOT(NULL,1,NULL,0);
1939 VARNOT(BOOL,VARIANT_TRUE,BOOL,VARIANT_FALSE);
1940 VARNOT(BOOL,VARIANT_FALSE,BOOL,VARIANT_TRUE);
1948 VARNOT(UI1,1,UI1,254);
1949 VARNOT(UI1,0,UI1,255);
1950 VARNOT(UI2,0,I4,-1);
1951 VARNOT(UI2,1,I4,-2);
1952 VARNOT(UI4,0,I4,-1);
1953 VARNOT(UI4,1,I4,-2);
1954 VARNOT(INT,0,I4,-1);
1955 VARNOT(INT,1,I4,-2);
1956 VARNOT(UINT,0,I4,-1);
1957 VARNOT(UINT,1,I4,-2);
1958 if (HAVE_OLEAUT32_I8)
1962 VARNOT(UI8,0,I4,-1);
1963 VARNOT(UI8,1,I4,-2);
1969 VARNOT(DATE,1,I4,-2);
1970 VARNOT(DATE,0,I4,-1);
1971 VARNOT(BSTR,(BSTR)szNum0,I4,-1);
1972 ok(V_VT(&v) == VT_BSTR && V_BSTR(&v) == szNum0, "VarNot(0): changed input\n");
1973 VARNOT(BSTR,(BSTR)szNum1,I4,-2);
1974 ok(V_VT(&v) == VT_BSTR && V_BSTR(&v) == szNum1, "VarNot(1): changed input\n");
1976 V_VT(&v) = VT_DECIMAL;
1977 S(U(*pdec)).sign = DECIMAL_NEG;
1978 S(U(*pdec)).scale = 0;
1980 S1(U1(*pdec)).Mid32 = 0;
1981 S1(U1(*pdec)).Lo32 = 1;
1982 VARNOT(DECIMAL,*pdec,I4,0);
1985 VARNOT(CY,*pcy,I4,-2);
1988 VARNOT(CY,*pcy,I4,-1);
1991 VARNOT(CY,*pcy,I4,-1);
1994 static HRESULT (WINAPI *pVarSub)(LPVARIANT,LPVARIANT,LPVARIANT);
1996 #define VARSUB(vt1,val1,vt2,val2,rvt,rval) \
1997 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
1998 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
1999 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
2000 test_var_call2( __LINE__, pVarSub, &left, &right, &exp )
2002 static void test_VarSub(void)
2004 static const WCHAR sz12[] = {'1','2','\0'};
2005 VARIANT left, right, exp, result, cy, dec;
2008 HRESULT hres, expectedhres;
2013 lbstr = SysAllocString(sz12);
2014 rbstr = SysAllocString(sz12);
2017 VariantInit(&right);
2018 VariantInit(&result);
2020 /* Test all possible flag/vt combinations & the resulting vt type */
2021 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
2024 VARTYPE leftvt, rightvt, resvt;
2026 for (leftvt = 0; leftvt <= VT_BSTR_BLOB; leftvt++)
2031 for (rightvt = 0; rightvt <= VT_BSTR_BLOB; rightvt++)
2035 expectedhres = S_OK;
2037 memset(&left, 0, sizeof(left));
2038 memset(&right, 0, sizeof(right));
2039 V_VT(&left) = leftvt | ExtraFlags[i];
2040 if (leftvt == VT_BSTR)
2041 V_BSTR(&left) = lbstr;
2042 V_VT(&right) = rightvt | ExtraFlags[i];
2043 if (rightvt == VT_BSTR)
2044 V_BSTR(&right) = rbstr;
2045 V_VT(&result) = VT_EMPTY;
2048 /* All extra flags produce errors */
2049 if (ExtraFlags[i] == (VT_VECTOR|VT_BYREF|VT_RESERVED) ||
2050 ExtraFlags[i] == (VT_VECTOR|VT_RESERVED) ||
2051 ExtraFlags[i] == (VT_VECTOR|VT_BYREF) ||
2052 ExtraFlags[i] == (VT_BYREF|VT_RESERVED) ||
2053 ExtraFlags[i] == VT_VECTOR ||
2054 ExtraFlags[i] == VT_BYREF ||
2055 ExtraFlags[i] == VT_RESERVED)
2057 expectedhres = DISP_E_BADVARTYPE;
2060 else if (ExtraFlags[i] >= VT_ARRAY)
2062 expectedhres = DISP_E_TYPEMISMATCH;
2065 /* Native VarSub cannot handle: VT_I1, VT_UI2, VT_UI4,
2066 VT_INT, VT_UINT and VT_UI8. Tested with WinXP */
2067 else if (!IsValidVariantClearVT(leftvt, ExtraFlags[i]) ||
2068 !IsValidVariantClearVT(rightvt, ExtraFlags[i]) ||
2069 leftvt == VT_CLSID || rightvt == VT_CLSID ||
2070 leftvt == VT_VARIANT || rightvt == VT_VARIANT ||
2071 leftvt == VT_I1 || rightvt == VT_I1 ||
2072 leftvt == VT_UI2 || rightvt == VT_UI2 ||
2073 leftvt == VT_UI4 || rightvt == VT_UI4 ||
2074 leftvt == VT_UI8 || rightvt == VT_UI8 ||
2075 leftvt == VT_INT || rightvt == VT_INT ||
2076 leftvt == VT_UINT || rightvt == VT_UINT ||
2077 leftvt == VT_UNKNOWN || rightvt == VT_UNKNOWN ||
2078 leftvt == VT_RECORD || rightvt == VT_RECORD)
2080 if (leftvt == VT_RECORD && rightvt == VT_I8)
2081 expectedhres = DISP_E_TYPEMISMATCH;
2082 else if (leftvt < VT_UI1 && rightvt == VT_RECORD)
2083 expectedhres = DISP_E_TYPEMISMATCH;
2084 else if (leftvt >= VT_UI1 && rightvt == VT_RECORD)
2085 expectedhres = DISP_E_TYPEMISMATCH;
2086 else if (leftvt == VT_RECORD && rightvt <= VT_UI1)
2087 expectedhres = DISP_E_TYPEMISMATCH;
2088 else if (leftvt == VT_RECORD && rightvt > VT_UI1)
2089 expectedhres = DISP_E_BADVARTYPE;
2091 expectedhres = DISP_E_BADVARTYPE;
2094 else if ((leftvt == VT_NULL && rightvt == VT_DISPATCH) ||
2095 (leftvt == VT_DISPATCH && rightvt == VT_NULL))
2097 else if (leftvt == VT_DISPATCH || rightvt == VT_DISPATCH ||
2098 leftvt == VT_ERROR || rightvt == VT_ERROR)
2101 expectedhres = DISP_E_TYPEMISMATCH;
2103 else if (leftvt == VT_NULL || rightvt == VT_NULL)
2105 else if ((leftvt == VT_EMPTY && rightvt == VT_BSTR) ||
2106 (leftvt == VT_DATE && rightvt == VT_DATE) ||
2107 (leftvt == VT_BSTR && rightvt == VT_EMPTY) ||
2108 (leftvt == VT_BSTR && rightvt == VT_BSTR))
2110 else if (leftvt == VT_DECIMAL || rightvt == VT_DECIMAL)
2112 else if (leftvt == VT_DATE || rightvt == VT_DATE)
2114 else if (leftvt == VT_CY || rightvt == VT_CY)
2116 else if (leftvt == VT_R8 || rightvt == VT_R8)
2118 else if (leftvt == VT_BSTR || rightvt == VT_BSTR) {
2120 } else if (leftvt == VT_R4 || rightvt == VT_R4) {
2121 if (leftvt == VT_I4 || rightvt == VT_I4 ||
2122 leftvt == VT_I8 || rightvt == VT_I8)
2127 else if (leftvt == VT_I8 || rightvt == VT_I8)
2129 else if (leftvt == VT_I4 || rightvt == VT_I4)
2131 else if (leftvt == VT_I2 || rightvt == VT_I2 ||
2132 leftvt == VT_BOOL || rightvt == VT_BOOL ||
2133 (leftvt == VT_EMPTY && rightvt == VT_EMPTY))
2135 else if (leftvt == VT_UI1 || rightvt == VT_UI1)
2140 expectedhres = DISP_E_TYPEMISMATCH;
2143 hres = pVarSub(&left, &right, &result);
2145 ok(hres == expectedhres && V_VT(&result) == resvt,
2146 "VarSub: %d|0x%X, %d|0x%X: Expected failure 0x%X, "
2147 "got 0x%X, expected vt %d got vt %d\n",
2148 leftvt, ExtraFlags[i], rightvt, ExtraFlags[i],
2149 expectedhres, hres, resvt, V_VT(&result));
2154 /* Test returned values */
2155 VARSUB(I4,4,I4,2,I4,2);
2156 VARSUB(I2,4,I2,2,I2,2);
2157 VARSUB(I2,-13,I4,5,I4,-18);
2158 VARSUB(I4,-13,I4,5,I4,-18);
2159 VARSUB(I2,7,R4,0.5f,R4,6.5f);
2160 VARSUB(R4,0.5f,I4,5,R8,-4.5);
2161 VARSUB(R8,7.1,BOOL,0,R8,7.1);
2162 VARSUB(BSTR,lbstr,I2,4,R8,8);
2163 VARSUB(BSTR,lbstr,BOOL,1,R8,11);
2164 VARSUB(BSTR,lbstr,R4,0.1f,R8,11.9);
2165 VARSUB(R4,0.2f,BSTR,rbstr,R8,-11.8);
2166 VARSUB(DATE,2.25,I4,7,DATE,-4.75);
2167 VARSUB(DATE,1.25,R4,-1.7f,DATE,2.95);
2169 VARSUB(UI1, UI1_MAX, UI1, UI1_MAX, UI1, 0);
2170 VARSUB(I2, I2_MAX, I2, I2_MAX, I2, 0);
2171 VARSUB(I2, I2_MIN, I2, I2_MIN, I2, 0);
2172 VARSUB(I4, I4_MAX, I4, I4_MAX, I4, 0);
2173 VARSUB(I4, I4_MIN, I4, I4_MIN, I4, 0);
2174 VARSUB(R4, R4_MAX, R4, R4_MAX, R4, 0.0f);
2175 VARSUB(R4, R4_MAX, R4, R4_MIN, R4, R4_MAX - R4_MIN);
2176 VARSUB(R4, R4_MIN, R4, R4_MIN, R4, 0.0f);
2177 VARSUB(R8, R8_MAX, R8, R8_MIN, R8, R8_MAX - R8_MIN);
2178 VARSUB(R8, R8_MIN, R8, R8_MIN, R8, 0.0);
2180 /* Manually test BSTR + BSTR */
2181 V_VT(&left) = VT_BSTR;
2182 V_BSTR(&left) = lbstr;
2183 V_VT(&right) = VT_BSTR;
2184 V_BSTR(&right) = rbstr;
2185 hres = VarSub(&left, &right, &result);
2186 ok(hres == S_OK && V_VT(&result) == VT_R8,
2187 "VarSub: expected coerced type VT_R8, got %s!\n", vtstr(V_VT(&result)));
2188 ok(hres == S_OK && EQ_DOUBLE(V_R8(&result), 0),
2189 "VarSub: BSTR + BSTR, expected %f got %f\n", 0.0, V_R8(&result));
2191 /* Manually test some VT_CY and VT_DECIMAL variants */
2193 hres = VarCyFromI4(4711, &V_CY(&cy));
2194 ok(hres == S_OK, "VarCyFromI4 failed!\n");
2195 V_VT(&dec) = VT_DECIMAL;
2196 hres = VarDecFromR8(-4.2, &V_DECIMAL(&dec));
2197 ok(hres == S_OK, "VarDecFromR4 failed!\n");
2198 memset(&left, 0, sizeof(left));
2199 memset(&right, 0, sizeof(right));
2200 V_VT(&left) = VT_I4;
2202 V_VT(&right) = VT_UI1;
2205 hres = VarSub(&cy, &right, &result);
2206 ok(hres == S_OK && V_VT(&result) == VT_CY,
2207 "VarSub: expected coerced type VT_CY, got %s!\n", vtstr(V_VT(&result)));
2208 hres = VarR8FromCy(V_CY(&result), &r);
2209 ok(hres == S_OK && EQ_DOUBLE(r, 4702),
2210 "VarSub: CY value %f, expected %f\n", r, (double)4720);
2212 hres = VarSub(&left, &dec, &result);
2213 ok(hres == S_OK && V_VT(&result) == VT_DECIMAL,
2214 "VarSub: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result)));
2215 hres = VarR8FromDec(&V_DECIMAL(&result), &r);
2216 ok(hres == S_OK && EQ_DOUBLE(r, -6.8),
2217 "VarSub: DECIMAL value %f, expected %f\n", r, (double)-15.2);
2219 SysFreeString(lbstr);
2220 SysFreeString(rbstr);
2223 static HRESULT (WINAPI *pVarMod)(LPVARIANT,LPVARIANT,LPVARIANT);
2225 static void test_Mod( int line, VARIANT *left, VARIANT *right, VARIANT *expected, HRESULT expres )
2230 memset( &result, 0, sizeof(result) );
2231 hres = pVarMod( left, right, &result );
2232 ok_(__FILE__,line)( hres == expres, "wrong result %x/%x\n", hres, expres );
2234 ok_(__FILE__,line)( is_expected_variant( &result, expected ),
2235 "got %s expected %s\n", variantstr(&result), variantstr(expected) );
2238 #define VARMOD(vt1,vt2,val1,val2,rvt,rval) \
2239 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
2240 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
2241 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
2242 test_var_call2( __LINE__, pVarMod, &left, &right, &exp )
2244 #define VARMOD2(vt1,vt2,val1,val2,rvt,rval,hexpected) \
2245 V_VT(&left) = VT_##vt1; V_I4(&left) = val1; \
2246 V_VT(&right) = VT_##vt2; V_I4(&right) = val2; \
2247 V_VT(&exp) = VT_##rvt; V_I4(&exp) = rval; \
2248 test_Mod( __LINE__, &left, &right, &exp, hexpected )
2250 static void test_VarMod(void)
2252 VARIANT v1, v2, vDst, left, right, exp;
2254 HRESULT hexpected = 0;
2255 static const WCHAR szNum0[] = {'1','2','5','\0'};
2256 static const WCHAR szNum1[] = {'1','0','\0'};
2258 BOOL lFound, rFound;
2259 BOOL lValid, rValid;
2260 BSTR strNum0, strNum1;
2264 VARMOD(I1,BOOL,100,10,I4,0);
2265 VARMOD(I1,I1,100,10,I4,0);
2266 VARMOD(I1,UI1,100,10,I4,0);
2267 VARMOD(I1,I2,100,10,I4,0);
2268 VARMOD(I1,UI2,100,10,I4,0);
2269 VARMOD(I1,I4,100,10,I4,0);
2270 VARMOD(I1,UI4,100,10,I4,0);
2271 VARMOD(I1,R4,100,10,I4,0);
2272 VARMOD(I1,R8,100,10,I4,0);
2274 VARMOD(UI1,BOOL,100,10,I2,0);
2275 VARMOD(UI1,I1,100,10,I4,0);
2276 VARMOD(UI1,UI1,100,10,UI1,0);
2277 VARMOD(UI1,I2,100,10,I2,0);
2278 VARMOD(UI1,UI2,100,10,I4,0);
2279 VARMOD(UI1,I4,100,10,I4,0);
2280 VARMOD(UI1,UI4,100,10,I4,0);
2281 VARMOD(UI1,R4,100,10,I4,0);
2282 VARMOD(UI1,R8,100,10,I4,0);
2284 VARMOD(I2,BOOL,100,10,I2,0);
2285 VARMOD(I2,I1,100,10,I4,0);
2286 VARMOD(I2,UI1,100,10,I2,0);
2287 VARMOD(I2,I2,100,10,I2,0);
2288 VARMOD(I2,UI2,100,10,I4,0);
2289 VARMOD(I2,I4,100,10,I4,0);
2290 VARMOD(I2,UI4,100,10,I4,0);
2291 VARMOD(I2,R4,100,10,I4,0);
2292 VARMOD(I2,R8,100,10,I4,0);
2294 VARMOD(I4,BOOL,100,10,I4,0);
2295 VARMOD(I4,I1,100,10,I4,0);
2296 VARMOD(I4,UI1,100,10,I4,0);
2297 VARMOD(I4,I2,100,10,I4,0);
2298 VARMOD(I4,UI2,100,10,I4,0);
2299 VARMOD(I4,I4,100,10,I4,0);
2300 VARMOD(I4,UI4,100,10,I4,0);
2301 VARMOD(I4,R4,100,10,I4,0);
2302 VARMOD(I4,R8,100,10,I4,0);
2303 VARMOD(UI4,BOOL,100,10,I4,0);
2304 VARMOD(UI4,I1,100,10,I4,0);
2305 VARMOD(UI4,UI1,100,10,I4,0);
2306 VARMOD(UI4,I2,100,10,I4,0);
2307 VARMOD(UI4,UI2,100,10,I4,0);
2308 VARMOD(UI4,I4,100,10,I4,0);
2309 VARMOD(UI4,UI4,100,10,I4,0);
2310 VARMOD(UI4,R4,100,10,I4,0);
2311 VARMOD(UI4,R8,100,10,I4,0);
2312 VARMOD(R4,BOOL,100,10,I4,0);
2313 VARMOD(R4,I1,100,10,I4,0);
2314 VARMOD(R4,UI1,100,10,I4,0);
2315 VARMOD(R4,I2,100,10,I4,0);
2316 VARMOD(R4,UI2,100,10,I4,0);
2317 VARMOD(R4,I4,100,10,I4,0);
2318 VARMOD(R4,UI4,100,10,I4,0);
2319 VARMOD(R4,R4,100,10,I4,0);
2320 VARMOD(R4,R8,100,10,I4,0);
2321 VARMOD(R8,BOOL,100,10,I4,0);
2322 VARMOD(R8,I1,100,10,I4,0);
2323 VARMOD(R8,UI1,100,10,I4,0);
2324 VARMOD(R8,I2,100,10,I4,0);
2325 VARMOD(R8,UI2,100,10,I4,0);
2326 VARMOD(R8,I4,100,10,I4,0);
2327 VARMOD(R8,UI4,100,10,I4,0);
2328 VARMOD(R8,R4,100,10,I4,0);
2329 VARMOD(R8,R8,100,10,I4,0);
2331 VARMOD(INT,INT,100,10,I4,0);
2332 VARMOD(INT,UINT,100,10,I4,0);
2334 VARMOD(BOOL,BOOL,100,10,I2,0);
2335 VARMOD(BOOL,I1,100,10,I4,0);
2336 VARMOD(BOOL,UI1,100,10,I2,0);
2337 VARMOD(BOOL,I2,100,10,I2,0);
2338 VARMOD(BOOL,UI2,100,10,I4,0);
2339 VARMOD(BOOL,I4,100,10,I4,0);
2340 VARMOD(BOOL,UI4,100,10,I4,0);
2341 VARMOD(BOOL,R4,100,10,I4,0);
2342 VARMOD(BOOL,R8,100,10,I4,0);
2343 VARMOD(BOOL,DATE,100,10,I4,0);
2345 VARMOD(DATE,BOOL,100,10,I4,0);
2346 VARMOD(DATE,I1,100,10,I4,0);
2347 VARMOD(DATE,UI1,100,10,I4,0);
2348 VARMOD(DATE,I2,100,10,I4,0);
2349 VARMOD(DATE,UI2,100,10,I4,0);
2350 VARMOD(DATE,I4,100,10,I4,0);
2351 VARMOD(DATE,UI4,100,10,I4,0);
2352 VARMOD(DATE,R4,100,10,I4,0);
2353 VARMOD(DATE,R8,100,10,I4,0);
2354 VARMOD(DATE,DATE,100,10,I4,0);
2356 strNum0 = SysAllocString(szNum0);
2357 strNum1 = SysAllocString(szNum1);
2358 VARMOD(BSTR,BSTR,strNum0,strNum1,I4,5);
2359 VARMOD(BSTR,I1,strNum0,10,I4,5);
2360 VARMOD(BSTR,I2,strNum0,10,I4,5);
2361 VARMOD(BSTR,I4,strNum0,10,I4,5);
2362 VARMOD(BSTR,R4,strNum0,10,I4,5);
2363 VARMOD(BSTR,R8,strNum0,10,I4,5);
2364 VARMOD(I4,BSTR,125,strNum1,I4,5);
2366 if (HAVE_OLEAUT32_I8)
2368 VARMOD(BOOL,I8,100,10,I8,0);
2369 VARMOD(I1,I8,100,10,I8,0);
2370 VARMOD(UI1,I8,100,10,I8,0);
2371 VARMOD(I2,I8,100,10,I8,0);
2372 VARMOD(I4,I8,100,10,I8,0);
2373 VARMOD(UI4,I8,100,10,I8,0);
2374 VARMOD(R4,I8,100,10,I8,0);
2375 VARMOD(R8,I8,100,10,I8,0);
2376 VARMOD(DATE,I8,100,10,I8,0);
2378 VARMOD(I8,BOOL,100,10,I8,0);
2379 VARMOD(I8,I1,100,10,I8,0);
2380 VARMOD(I8,UI1,100,10,I8,0);
2381 VARMOD(I8,I2,100,10,I8,0);
2382 VARMOD(I8,UI2,100,10,I8,0);
2383 VARMOD(I8,I4,100,10,I8,0);
2384 VARMOD(I8,UI4,100,10,I8,0);
2385 VARMOD(I8,R4,100,10,I8,0);
2386 VARMOD(I8,R8,100,10,I8,0);
2387 VARMOD(I8,I8,100,10,I8,0);
2389 VARMOD(BSTR,I8,strNum0,10,I8,5);
2392 /* test all combinations of types */
2393 for(l = 0; l < VT_BSTR_BLOB; l++)
2397 for(r = 0; r < VT_BSTR_BLOB; r++)
2401 if(l == VT_BSTR) continue;
2402 if(l == VT_DISPATCH) continue;
2403 if(r == VT_BSTR) continue;
2404 if(r == VT_DISPATCH) continue;
2438 hexpected = DISP_E_BADVARTYPE;
2477 if(((l == VT_I8) && (r == VT_INT)) || ((l == VT_INT) && (r == VT_I8)))
2479 hexpected = DISP_E_TYPEMISMATCH;
2480 } else if((l == VT_EMPTY) && (r == VT_NULL))
2483 } else if((l == VT_NULL) && (r == VT_EMPTY))
2486 } else if((l == VT_EMPTY) && (r == VT_CY))
2489 } else if((l == VT_EMPTY) && (r == VT_RECORD))
2491 hexpected = DISP_E_TYPEMISMATCH;
2492 } else if((r == VT_EMPTY) && lFound && lValid)
2494 hexpected = DISP_E_DIVBYZERO;
2495 } else if((l == VT_ERROR) || ((r == VT_ERROR) && lFound && lValid))
2497 hexpected = DISP_E_TYPEMISMATCH;
2498 } else if((l == VT_NULL) && (r == VT_NULL))
2501 } else if((l == VT_VARIANT) || ((r == VT_VARIANT) && lFound && lValid))
2503 hexpected = DISP_E_TYPEMISMATCH;
2504 } else if((l == VT_NULL) && (r == VT_RECORD))
2506 hexpected = DISP_E_TYPEMISMATCH;
2507 } else if((l == VT_I8) && (r == VT_DECIMAL))
2510 } else if((l == VT_DECIMAL) && (r == VT_I8))
2513 } else if((l == VT_UNKNOWN) || ((r == VT_UNKNOWN) && lFound && lValid))
2515 hexpected = DISP_E_TYPEMISMATCH;
2516 } else if((l == VT_NULL) && rFound)
2519 } else if(l == VT_RECORD)
2521 hexpected = DISP_E_TYPEMISMATCH;
2522 } else if((r == VT_RECORD) && lValid && lFound)
2524 hexpected = DISP_E_TYPEMISMATCH;
2525 } else if((l == VT_EMPTY) && (r == VT_EMPTY))
2527 hexpected = DISP_E_DIVBYZERO;
2528 } else if((l == VT_CY) && !rFound)
2530 hexpected = DISP_E_BADVARTYPE;
2531 } else if(lFound && !rFound)
2533 hexpected = DISP_E_BADVARTYPE;
2534 } else if(!lFound && rFound)
2536 hexpected = DISP_E_BADVARTYPE;
2537 } else if((r == VT_NULL) && lFound && lValid)
2540 } else if((l == VT_NULL) || (r == VT_NULL))
2542 hexpected = DISP_E_BADVARTYPE;
2543 } else if((l == VT_VARIANT) || (r == VT_VARIANT))
2545 hexpected = DISP_E_BADVARTYPE;
2546 } else if(lFound && !rFound)
2548 hexpected = DISP_E_BADVARTYPE;
2549 } else if(!lFound && !rFound)
2551 hexpected = DISP_E_BADVARTYPE;
2558 V_CY(&v1).int64 = 1000000;
2563 else if(l == VT_UI8)
2567 else if(l == VT_DATE)
2569 else if (l == VT_DECIMAL)
2571 V_DECIMAL(&v1).Hi32 = 0;
2572 U1(V_DECIMAL(&v1)).Lo64 = 100;
2573 U(V_DECIMAL(&v1)).signscale = 0;
2579 V_CY(&v2).int64 = 10000;
2584 else if(r == VT_UI8)
2588 else if(r == VT_DATE)
2590 else if (r == VT_DECIMAL)
2592 V_DECIMAL(&v2).Hi32 = 0;
2593 U1(V_DECIMAL(&v2)).Lo64 = 100;
2594 U(V_DECIMAL(&v2)).signscale = 0;
2599 if ((l != VT_I8 && l != VT_UI8 && r != VT_I8 && r != VT_UI8) || HAVE_OLEAUT32_I8)
2601 hres = pVarMod(&v1,&v2,&vDst);
2602 ok(hres == hexpected,
2603 "VarMod: expected 0x%x, got 0x%X for l type of %d, r type of %d,\n", hexpected, hres, l, r);
2609 /****************************/
2610 /* test some bad parameters */
2611 VARMOD(I4,I4,-1,-1,I4,0);
2613 /* test modulus with zero */
2614 VARMOD2(I4,I4,100,0,EMPTY,0,DISP_E_DIVBYZERO);
2616 VARMOD(I4,I4,0,10,I4,0); /* test 0 mod 10 */
2618 /* right parameter is type empty */
2619 VARMOD2(I4,EMPTY,100,10,EMPTY,0,DISP_E_DIVBYZERO);
2621 /* left parameter is type empty */
2622 VARMOD2(EMPTY,I4,100,10,I4,0,S_OK);
2624 /* mod with a null left value */
2625 VARMOD2(NULL,I4,125,10,NULL,0,S_OK);
2627 /* mod with a null right value */
2628 VARMOD2(I4,NULL,100,10,NULL,0,S_OK);
2630 /* void left value */
2631 VARMOD2(VOID,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2633 /* void right value */
2634 VARMOD2(I4,VOID,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2636 /* null left value, void right value */
2637 VARMOD2(NULL,VOID,100,10,EMPTY, 0, DISP_E_BADVARTYPE);
2639 /* void left value, null right value */
2640 VARMOD2(VOID,NULL,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2642 /* some currencies */
2645 V_CY(&v1).int64 = 100000;
2646 V_CY(&v2).int64 = 100000;
2647 hres = pVarMod(&v1,&v2,&vDst);
2648 ok(hres == S_OK && V_VT(&vDst) == VT_I4 && V_I4(&vDst) == 0,
2649 "VarMod: expected 0x%x,%d,%d, got 0x%X,%d,%d\n", S_OK, VT_I4, 0, hres, V_VT(&vDst), V_I4(&vDst));
2654 V_CY(&v2).int64 = 100000;
2655 hres = pVarMod(&v1,&v2,&vDst);
2656 ok(hres == S_OK && V_VT(&vDst) == VT_I4 && V_I4(&vDst) == 0,
2657 "VarMod: expected 0x%x,%d,%d, got 0x%X,%d,%d\n", S_OK, VT_I4, 0, hres, V_VT(&vDst), V_I4(&vDst));
2660 V_VT(&v1) = VT_DECIMAL;
2661 V_VT(&v2) = VT_DECIMAL;
2662 VarDecFromI4(100, &V_DECIMAL(&v1));
2663 VarDecFromI4(10, &V_DECIMAL(&v2));
2664 hres = pVarMod(&v1,&v2,&vDst);
2665 ok(hres == S_OK && V_VT(&vDst) == VT_I4 && V_I4(&vDst) == 0,
2666 "VarMod: expected 0x%x,%d,%d, got 0x%X,%d,%d\n", S_OK, VT_I4, 0, hres, V_VT(&vDst), V_I4(&vDst));
2669 V_VT(&v2) = VT_DECIMAL;
2671 VarDecFromI4(10, &V_DECIMAL(&v2));
2672 hres = pVarMod(&v1,&v2,&vDst);
2673 ok(hres == S_OK && V_VT(&vDst) == VT_I4 && V_I4(&vDst) == 0,
2674 "VarMod: expected 0x%x,%d,%d, got 0x%X,%d,%d\n", S_OK, VT_I4, 0, hres, V_VT(&vDst), V_I4(&vDst));
2676 VARMOD2(UINT,I4,100,10,I4,0,S_OK);
2678 /* test that an error results in the type of the result changing but not its value */
2679 V_VT(&v1) = VT_UNKNOWN;
2680 V_VT(&v2) = VT_EMPTY;
2682 V_CY(&v2).int64 = 100000;
2683 V_VT(&vDst) = VT_I4;
2685 hres = pVarMod(&v1,&v2,&vDst);
2686 ok(hres == DISP_E_TYPEMISMATCH && V_VT(&vDst) == VT_EMPTY && V_I4(&vDst) == 1231,
2687 "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));
2690 /* test some invalid types */
2691 /*TODO: not testing VT_DISPATCH */
2692 if (HAVE_OLEAUT32_I8)
2694 VARMOD2(I8,INT,100,10,EMPTY,0,DISP_E_TYPEMISMATCH);
2696 VARMOD2(ERROR,I4,100,10,EMPTY,0,DISP_E_TYPEMISMATCH);
2697 VARMOD2(VARIANT,I4,100,10,EMPTY,0,DISP_E_TYPEMISMATCH);
2698 VARMOD2(UNKNOWN,I4,100,10,EMPTY,0,DISP_E_TYPEMISMATCH);
2699 VARMOD2(VOID,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2700 VARMOD2(HRESULT,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2701 VARMOD2(PTR,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2702 VARMOD2(SAFEARRAY,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2703 VARMOD2(CARRAY,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2704 VARMOD2(USERDEFINED,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2705 VARMOD2(LPSTR,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2706 VARMOD2(LPWSTR,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2707 VARMOD2(RECORD,I4,100,10,EMPTY,0,DISP_E_TYPEMISMATCH);
2708 VARMOD2(FILETIME,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2709 VARMOD2(BLOB,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2710 VARMOD2(STREAM,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2711 VARMOD2(STORAGE,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2712 VARMOD2(STREAMED_OBJECT,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2713 VARMOD2(STORED_OBJECT,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2714 VARMOD2(BLOB_OBJECT,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2715 VARMOD2(CF,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2716 VARMOD2(CLSID,CLSID,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2717 VARMOD2(VECTOR,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2718 VARMOD2(ARRAY,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2719 VARMOD2(BYREF,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2721 /* test some more invalid types */
2726 hres = pVarMod(&v1,&v2,&vDst);
2727 ok(hres == DISP_E_BADVARTYPE && V_VT(&vDst) == VT_EMPTY,
2728 "VarMod: expected 0x%x,%d, got 0x%X,%d\n", DISP_E_BADVARTYPE, VT_EMPTY, hres, V_VT(&vDst));
2731 static HRESULT (WINAPI *pVarFix)(LPVARIANT,LPVARIANT);
2733 #define VARFIX(vt,val,rvt,rval) \
2734 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
2735 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
2736 test_var_call1( __LINE__, pVarFix, &v, &exp )
2738 static void test_VarFix(void)
2740 static const WCHAR szNumMinus1[] = {'-','1','\0' };
2742 VARIANT v, exp, vDst;
2743 DECIMAL *pdec = &V_DECIMAL(&v);
2744 CY *pcy = &V_CY(&v);
2749 /* Test all possible V_VT values */
2750 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
2754 for (vt = 0; vt <= VT_BSTR_BLOB; vt++)
2756 HRESULT bFail = TRUE;
2760 memset(&v, 0, sizeof(v));
2761 V_VT(&v) = vt | ExtraFlags[i];
2762 V_VT(&vDst) = VT_EMPTY;
2766 case VT_UI1: case VT_I2: case VT_I4: case VT_R4: case VT_R8:
2767 case VT_DECIMAL: case VT_BOOL: case VT_NULL: case VT_EMPTY:
2768 case VT_DATE: case VT_CY:
2772 if (HAVE_OLEAUT32_I8)
2777 hres = pVarFix(&v,&vDst);
2779 ok(hres == DISP_E_TYPEMISMATCH || hres == DISP_E_BADVARTYPE,
2780 "VarFix: expected failure, got 0x%X vt %d|0x%X\n",
2781 hres, vt, ExtraFlags[i]);
2783 ok(hres == S_OK, "VarFix: expected S_OK, got 0x%X vt %d|0x%X\n",
2784 hres, vt, ExtraFlags[i]);
2788 VARFIX(BOOL,VARIANT_TRUE,I2,VARIANT_TRUE);
2789 VARFIX(BOOL,VARIANT_FALSE,I2,0);
2790 VARFIX(BOOL,1,I2,1);
2791 VARFIX(UI1,1,UI1,1);
2792 VARFIX(I2,-1,I2,-1);
2793 VARFIX(I4,-1,I4,-1);
2794 if (HAVE_OLEAUT32_I8)
2796 VARFIX(I8,-1,I8,-1);
2798 VARFIX(R4,1.4f,R4,1);
2799 VARFIX(R4,1.5f,R4,1);
2800 VARFIX(R4,1.6f,R4,1);
2801 VARFIX(R4,-1.4f,R4,-1);
2802 VARFIX(R4,-1.5f,R4,-1);
2803 VARFIX(R4,-1.6f,R4,-1);
2804 /* DATE & R8 round as for R4 */
2805 VARFIX(DATE,-1,DATE,-1);
2806 VARFIX(R8,-1,R8,-1);
2807 VARFIX(BSTR,(BSTR)szNumMinus1,R8,-1);
2809 V_VT(&v) = VT_EMPTY;
2810 hres = pVarFix(&v,&vDst);
2811 ok(hres == S_OK && V_VT(&vDst) == VT_I2 && V_I2(&vDst) == 0,
2812 "VarFix: expected 0x0,%d,0 got 0x%X,%d,%d\n", VT_EMPTY,
2813 hres, V_VT(&vDst), V_I2(&vDst));
2816 hres = pVarFix(&v,&vDst);
2817 ok(hres == S_OK && V_VT(&vDst) == VT_NULL,
2818 "VarFix: expected 0x0,%d got 0x%X,%d\n", VT_NULL, hres, V_VT(&vDst));
2820 V_VT(&v) = VT_DECIMAL;
2821 S(U(*pdec)).sign = DECIMAL_NEG;
2822 S(U(*pdec)).scale = 0;
2824 S1(U1(*pdec)).Mid32 = 0;
2825 S1(U1(*pdec)).Lo32 = 1;
2826 hres = pVarFix(&v,&vDst);
2827 ok(hres == S_OK && V_VT(&vDst) == VT_DECIMAL && !memcmp(&v, &vDst, sizeof(v)),
2828 "VarFix: expected 0x0,%d,identical, got 0x%X,%d\n", VT_DECIMAL,
2831 /* FIXME: Test some fractional decimals when VarDecFix is implemented */
2834 pcy->int64 = -10000;
2835 hres = pVarFix(&v,&vDst);
2836 ok(hres == S_OK && V_VT(&vDst) == VT_CY && V_CY(&vDst).int64 == -10000,
2837 "VarFix: VT_CY wrong, hres=0x%X\n", hres);
2840 pcy->int64 = -16000;
2841 hres = pVarFix(&v,&vDst);
2842 ok(hres == S_OK && V_VT(&vDst) == VT_CY && V_CY(&vDst).int64 == -10000,
2843 "VarFix: VT_CY wrong, hres=0x%X\n", hres);
2846 static HRESULT (WINAPI *pVarInt)(LPVARIANT,LPVARIANT);
2848 #define VARINT(vt,val,rvt,rval) \
2849 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
2850 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
2851 test_var_call1( __LINE__, pVarInt, &v, &exp )
2853 static void test_VarInt(void)
2855 static const WCHAR szNumMinus1[] = {'-','1','\0' };
2857 VARIANT v, exp, vDst;
2858 DECIMAL *pdec = &V_DECIMAL(&v);
2859 CY *pcy = &V_CY(&v);
2864 /* Test all possible V_VT values */
2865 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
2869 for (vt = 0; vt <= VT_BSTR_BLOB; vt++)
2871 HRESULT bFail = TRUE;
2875 memset(&v, 0, sizeof(v));
2876 V_VT(&v) = vt | ExtraFlags[i];
2877 V_VT(&vDst) = VT_EMPTY;
2881 case VT_UI1: case VT_I2: case VT_I4: case VT_R4: case VT_R8:
2882 case VT_DECIMAL: case VT_BOOL: case VT_NULL: case VT_EMPTY:
2883 case VT_DATE: case VT_CY:
2887 if (HAVE_OLEAUT32_I8)
2892 hres = pVarInt(&v,&vDst);
2894 ok(hres == DISP_E_TYPEMISMATCH || hres == DISP_E_BADVARTYPE,
2895 "VarInt: expected failure, got 0x%X vt %d|0x%X\n",
2896 hres, vt, ExtraFlags[i]);
2898 ok(hres == S_OK, "VarInt: expected S_OK, got 0x%X vt %d|0x%X\n",
2899 hres, vt, ExtraFlags[i]);
2903 VARINT(BOOL,VARIANT_TRUE,I2,VARIANT_TRUE);
2904 VARINT(BOOL,VARIANT_FALSE,I2,0);
2905 VARINT(BOOL,1,I2,1);
2906 VARINT(UI1,1,UI1,1);
2907 VARINT(I2,-1,I2,-1);
2908 VARINT(I4,-1,I4,-1);
2909 if (HAVE_OLEAUT32_I8)
2911 VARINT(I8,-1,I8,-1);
2913 VARINT(R4,1.4f,R4,1);
2914 VARINT(R4,1.5f,R4,1);
2915 VARINT(R4,1.6f,R4,1);
2916 VARINT(R4,-1.4f,R4,-2); /* Note these 3 are different from VarFix */
2917 VARINT(R4,-1.5f,R4,-2);
2918 VARINT(R4,-1.6f,R4,-2);
2919 /* DATE & R8 round as for R4 */
2920 VARINT(DATE,-1,DATE,-1);
2921 VARINT(R8,-1,R8,-1);
2922 VARINT(BSTR,(BSTR)szNumMinus1,R8,-1);
2924 V_VT(&v) = VT_EMPTY;
2925 hres = pVarInt(&v,&vDst);
2926 ok(hres == S_OK && V_VT(&vDst) == VT_I2 && V_I2(&vDst) == 0,
2927 "VarInt: expected 0x0,%d,0 got 0x%X,%d,%d\n", VT_EMPTY,
2928 hres, V_VT(&vDst), V_I2(&vDst));
2931 hres = pVarInt(&v,&vDst);
2932 ok(hres == S_OK && V_VT(&vDst) == VT_NULL,
2933 "VarInt: expected 0x0,%d got 0x%X,%d\n", VT_NULL, hres, V_VT(&vDst));
2935 V_VT(&v) = VT_DECIMAL;
2936 S(U(*pdec)).sign = DECIMAL_NEG;
2937 S(U(*pdec)).scale = 0;
2939 S1(U1(*pdec)).Mid32 = 0;
2940 S1(U1(*pdec)).Lo32 = 1;
2941 hres = pVarInt(&v,&vDst);
2942 ok(hres == S_OK && V_VT(&vDst) == VT_DECIMAL && !memcmp(&v, &vDst, sizeof(v)),
2943 "VarInt: expected 0x0,%d,identical, got 0x%X,%d\n", VT_DECIMAL,
2946 /* FIXME: Test some fractional decimals when VarDecInt is implemented */
2949 pcy->int64 = -10000;
2950 hres = pVarInt(&v,&vDst);
2951 ok(hres == S_OK && V_VT(&vDst) == VT_CY && V_CY(&vDst).int64 == -10000,
2952 "VarInt: VT_CY wrong, hres=0x%X\n", hres);
2955 pcy->int64 = -11000;
2956 hres = pVarInt(&v,&vDst);
2957 ok(hres == S_OK && V_VT(&vDst) == VT_CY && V_CY(&vDst).int64 == -20000,
2958 "VarInt: VT_CY wrong, hres=0x%X 0x%x%08x\n",
2959 hres, (DWORD)(V_CY(&vDst).int64 >> 32), (DWORD)V_CY(&vDst).int64);
2962 static HRESULT (WINAPI *pVarNeg)(LPVARIANT,LPVARIANT);
2964 #define VARNEG(vt,val,rvt,rval) \
2965 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
2966 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
2967 test_var_call1( __LINE__, pVarNeg, &v, &exp )
2969 static void test_VarNeg(void)
2971 static const WCHAR szNumMinus1[] = {'-','1','\0' };
2972 static const WCHAR szNum1[] = {'1','\0' };
2974 VARIANT v, exp, vDst;
2975 DECIMAL *pdec = &V_DECIMAL(&v);
2976 CY *pcy = &V_CY(&v);
2981 /* Test all possible V_VT values. But don't test the exact return values
2982 * except for success/failure, since M$ made a hash of them in the
2983 * native version. This at least ensures (as with all tests here) that
2984 * we will notice if/when new vtypes/flags are added in native.
2986 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
2990 for (vt = 0; vt <= VT_BSTR_BLOB; vt++)
2992 HRESULT bFail = TRUE;
2996 memset(&v, 0, sizeof(v));
2997 V_VT(&v) = vt | ExtraFlags[i];
2998 V_VT(&vDst) = VT_EMPTY;
3002 case VT_UI1: case VT_I2: case VT_I4:
3003 case VT_R4: case VT_R8:
3004 case VT_DECIMAL: case VT_BOOL: case VT_NULL: case VT_EMPTY:
3005 case VT_DATE: case VT_CY:
3009 if (HAVE_OLEAUT32_I8)
3013 hres = pVarNeg(&v,&vDst);
3015 ok(hres == DISP_E_TYPEMISMATCH || hres == DISP_E_BADVARTYPE,
3016 "VarNeg: expected failure, got 0x%X vt %d|0x%X\n",
3017 hres, vt, ExtraFlags[i]);
3019 ok(hres == S_OK, "VarNeg: expected S_OK, got 0x%X vt %d|0x%X\n",
3020 hres, vt, ExtraFlags[i]);
3024 VARNEG(BOOL,VARIANT_TRUE,I2,1);
3025 VARNEG(BOOL,VARIANT_FALSE,I2,0);
3026 VARNEG(BOOL,1,I2,-1);
3027 VARNEG(UI1,1,I2,-1);
3028 VARNEG(UI1,254,I2,-254);
3029 VARNEG(I2,-32768,I4,32768);
3032 VARNEG(I4,-((int)(~0u >> 1)) - 1,R8,-2147483648u);
3035 if (HAVE_OLEAUT32_I8)
3042 VARNEG(DATE,1,DATE,-1);
3043 VARNEG(DATE,-1,DATE,1);
3046 VARNEG(BSTR,(BSTR)szNumMinus1,R8,1);
3047 VARNEG(BSTR,(BSTR)szNum1,R8,-1);
3049 V_VT(&v) = VT_EMPTY;
3050 hres = pVarNeg(&v,&vDst);
3051 ok(hres == S_OK && V_VT(&vDst) == VT_I2 && V_I2(&vDst) == 0,
3052 "VarNeg: expected 0x0,%d,0 got 0x%X,%d,%d\n", VT_EMPTY,
3053 hres, V_VT(&vDst), V_I2(&vDst));
3056 hres = pVarNeg(&v,&vDst);
3057 ok(hres == S_OK && V_VT(&vDst) == VT_NULL,
3058 "VarNeg: expected 0x0,%d got 0x%X,%d\n", VT_NULL, hres, V_VT(&vDst));
3060 V_VT(&v) = VT_DECIMAL;
3061 S(U(*pdec)).sign = DECIMAL_NEG;
3062 S(U(*pdec)).scale = 0;
3064 S1(U1(*pdec)).Mid32 = 0;
3065 S1(U1(*pdec)).Lo32 = 1;
3066 hres = pVarNeg(&v,&vDst);
3067 ok(hres == S_OK && V_VT(&vDst) == VT_DECIMAL &&
3068 S(U(V_DECIMAL(&vDst))).sign == 0,
3069 "VarNeg: expected 0x0,%d,0x00, got 0x%X,%d,%02x\n", VT_DECIMAL,
3070 hres, V_VT(&vDst), S(U(V_DECIMAL(&vDst))).sign);
3072 S(U(*pdec)).sign = 0;
3073 hres = pVarNeg(&v,&vDst);
3074 ok(hres == S_OK && V_VT(&vDst) == VT_DECIMAL &&
3075 S(U(V_DECIMAL(&vDst))).sign == DECIMAL_NEG,
3076 "VarNeg: expected 0x0,%d,0x7f, got 0x%X,%d,%02x\n", VT_DECIMAL,
3077 hres, V_VT(&vDst), S(U(V_DECIMAL(&vDst))).sign);
3080 pcy->int64 = -10000;
3081 hres = pVarNeg(&v,&vDst);
3082 ok(hres == S_OK && V_VT(&vDst) == VT_CY && V_CY(&vDst).int64 == 10000,
3083 "VarNeg: VT_CY wrong, hres=0x%X\n", hres);
3086 static HRESULT (WINAPI *pVarRound)(LPVARIANT,int,LPVARIANT);
3088 static void test_Round( int line, VARIANT *arg, int deci, VARIANT *expected )
3093 memset( &result, 0, sizeof(result) );
3094 hres = pVarRound( arg, deci, &result );
3095 ok_(__FILE__,line)( hres == S_OK, "wrong result %x\n", hres );
3097 ok_(__FILE__,line)( is_expected_variant( &result, expected ),
3098 "got %s expected %s\n", variantstr(&result), variantstr(expected) );
3100 #define VARROUND(vt,val,deci,rvt,rval) \
3101 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
3102 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
3103 test_Round( __LINE__, &v, deci, &exp )
3105 static void test_VarRound(void)
3107 static WCHAR szNumMin[] = {'-','1','.','4','4','9','\0' };
3108 static WCHAR szNum[] = {'1','.','4','5','1','\0' };
3110 VARIANT v, exp, vDst;
3111 CY *pcy = &V_CY(&v);
3116 /* first check valid integer types */
3117 VARROUND(BOOL,VARIANT_TRUE,0,I2,-1);
3118 VARROUND(BOOL,VARIANT_FALSE,0,I2,0);
3119 VARROUND(BOOL,1,0,I2,1);
3120 VARROUND(UI1,1,0,UI1,1);
3121 VARROUND(UI1,254,0,UI1,254);
3122 VARROUND(I2,-32768,0,I2,-32768);
3123 VARROUND(I2,-1,0,I2,-1);
3124 VARROUND(I2,1,0,I2,1);
3125 VARROUND(I4,-((int)(~0u >> 1)) - 1,0,I4,-((int)(~0u >> 1)) - 1);
3126 VARROUND(I4,-1,0,I4,-1);
3127 VARROUND(I4,1,0,I4,1);
3130 /* MSDN states that rounding of R4/R8 is dependent on the underlying
3131 * bit pattern of the number and so is architecture dependent. In this
3132 * case Wine returns .2 (which is more correct) and Native returns .3
3135 VARROUND(R4,1.0f,0,R4,1.0f);
3136 VARROUND(R4,-1.0f,0,R4,-1.0f);
3137 VARROUND(R8,1.0,0,R8,1.0);
3138 VARROUND(R8,-1.0,0,R8,-1.0);
3140 /* floating point numbers aren't exactly equal and we can't just
3141 * compare the first few digits. */
3142 VARROUND(DATE,1.451,1,DATE,1.5);
3143 VARROUND(DATE,-1.449,1,DATE,-1.4);
3145 /* replace the decimal separator */
3146 GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, buff, sizeof(buff)/sizeof(char));
3148 szNumMin[2] = buff[0];
3150 VARROUND(BSTR,(BSTR)szNumMin,1,R8,-1.40);
3151 VARROUND(BSTR,(BSTR)szNum,1,R8,1.50);
3153 skip("Skipping VarRound(BSTR) as decimal separator is '%s'\n", buff);
3156 VARROUND(R4,1.23456f,0,R4,1.0f);
3157 VARROUND(R4,1.23456f,1,R4,1.2f);
3158 VARROUND(R4,1.23456f,2,R4,1.23f);
3159 VARROUND(R4,1.23456f,3,R4,1.235f);
3160 VARROUND(R4,1.23456f,4,R4,1.2346f);
3161 VARROUND(R4,-1.23456f,0,R4,-1.0f);
3162 VARROUND(R4,-1.23456f,1,R4,-1.2f);
3163 VARROUND(R4,-1.23456f,2,R4,-1.23f);
3164 VARROUND(R4,-1.23456f,3,R4,-1.235f);
3165 VARROUND(R4,-1.23456f,4,R4,-1.2346f);
3167 VARROUND(R8,1.23456,0,R8,1.0);
3168 VARROUND(R8,1.23456,1,R8,1.2);
3169 VARROUND(R8,1.23456,2,R8,1.23);
3170 VARROUND(R8,1.23456,3,R8,1.235);
3171 VARROUND(R8,1.23456,4,R8,1.2346);
3172 VARROUND(R8,-1.23456,0,R8,-1.0);
3173 VARROUND(R8,-1.23456,1,R8,-1.2);
3174 VARROUND(R8,-1.23456,2,R8,-1.23);
3175 VARROUND(R8,-1.23456,3,R8,-1.235);
3176 VARROUND(R8,-1.23456,4,R8,-1.2346);
3178 V_VT(&v) = VT_EMPTY;
3179 hres = pVarRound(&v,0,&vDst);
3180 ok(hres == S_OK && V_VT(&vDst) == VT_I2 && V_I2(&vDst) == 0,
3181 "VarRound: expected 0x0,%d,0 got 0x%X,%d,%d\n", VT_EMPTY,
3182 hres, V_VT(&vDst), V_I2(&vDst));
3185 hres = pVarRound(&v,0,&vDst);
3186 ok(hres == S_OK && V_VT(&vDst) == VT_NULL,
3187 "VarRound: expected 0x0,%d got 0x%X,%d\n", VT_NULL, hres, V_VT(&vDst));
3189 /* not yet implemented so no use testing yet
3191 DECIMAL *pdec = &V_DECIMAL(&v);
3192 V_VT(&v) = VT_DECIMAL;
3193 S(U(*pdec)).sign = DECIMAL_NEG;
3194 S(U(*pdec)).scale = 0;
3196 S1(U1(*pdec)).Mid32 = 0;
3197 S1(U1(*pdec)).Lo32 = 1;
3198 hres = pVarRound(&v,0,&vDst);
3199 ok(hres == S_OK && V_VT(&vDst) == VT_DECIMAL &&
3200 S(U(V_DECIMAL(&vDst))).sign == 0,
3201 "VarRound: expected 0x0,%d,0x00, got 0x%X,%d,%02x\n", VT_DECIMAL,
3202 hres, V_VT(&vDst), S(U(V_DECIMAL(&vDst))).sign);
3204 S(U(*pdec)).sign = 0;
3205 hres = pVarRound(&v,0,&vDst);
3206 ok(hres == S_OK && V_VT(&vDst) == VT_DECIMAL &&
3207 S(U(V_DECIMAL(&vDst))).sign == DECIMAL_NEG,
3208 "VarRound: expected 0x0,%d,0x7f, got 0x%X,%d,%02x\n", VT_DECIMAL,
3209 hres, V_VT(&vDst), S(U(V_DECIMAL(&vDst))).sign);
3215 hres = pVarRound(&v,0,&vDst);
3216 ok(hres == S_OK && V_VT(&vDst) == VT_CY && V_CY(&vDst).int64 == 10000,
3217 "VarRound: VT_CY wrong, hres=0x%X\n", hres);
3221 static HRESULT (WINAPI *pVarXor)(LPVARIANT,LPVARIANT,LPVARIANT);
3223 #define VARXOR(vt1,val1,vt2,val2,rvt,rval) \
3224 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
3225 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
3226 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
3227 test_var_call2( __LINE__, pVarXor, &left, &right, &exp )
3229 #define VARXORCY(vt1,val1,val2,rvt,rval) \
3230 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
3231 V_VT(&right) = VT_CY; V_CY(&right).int64 = val2; \
3232 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
3233 test_var_call2( __LINE__, pVarXor, &left, &right, &exp )
3235 static void test_VarXor(void)
3237 static const WCHAR szFalse[] = { '#','F','A','L','S','E','#','\0' };
3238 static const WCHAR szTrue[] = { '#','T','R','U','E','#','\0' };
3239 VARIANT left, right, exp, result;
3246 /* Test all possible flag/vt combinations & the resulting vt type */
3247 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
3249 VARTYPE leftvt, rightvt, resvt;
3251 for (leftvt = 0; leftvt <= VT_BSTR_BLOB; leftvt++)
3256 for (rightvt = 0; rightvt <= VT_BSTR_BLOB; rightvt++)
3262 if (leftvt == VT_BSTR || rightvt == VT_BSTR ||
3263 leftvt == VT_DISPATCH || rightvt == VT_DISPATCH ||
3264 leftvt == VT_UNKNOWN || rightvt == VT_UNKNOWN)
3267 memset(&left, 0, sizeof(left));
3268 memset(&right, 0, sizeof(right));
3269 V_VT(&left) = leftvt | ExtraFlags[i];
3270 V_VT(&right) = rightvt | ExtraFlags[i];
3271 V_VT(&result) = VT_EMPTY;
3274 if (ExtraFlags[i] & VT_ARRAY || ExtraFlags[i] & VT_BYREF ||
3275 !IsValidVariantClearVT(leftvt, ExtraFlags[i]) ||
3276 !IsValidVariantClearVT(rightvt, ExtraFlags[i]) ||
3277 leftvt == VT_CLSID || rightvt == VT_CLSID ||
3278 leftvt == VT_RECORD || rightvt == VT_RECORD ||
3279 leftvt == VT_VARIANT || rightvt == VT_VARIANT ||
3280 leftvt == VT_ERROR || rightvt == VT_ERROR)
3284 if (leftvt == VT_EMPTY || rightvt == VT_EMPTY)
3286 if (leftvt == rightvt ||
3287 leftvt == VT_I2 || rightvt == VT_I2 ||
3288 leftvt == VT_UI1 || rightvt == VT_UI1 ||
3289 leftvt == VT_BOOL || rightvt == VT_BOOL)
3291 else if (leftvt == VT_NULL || rightvt == VT_NULL)
3293 else if (leftvt == VT_I8 || rightvt == VT_I8)
3296 else if (leftvt == VT_NULL || rightvt == VT_NULL)
3300 else if (leftvt == VT_UI1 || rightvt == VT_UI1)
3302 if (leftvt == rightvt)
3304 else if (leftvt == rightvt ||
3305 leftvt == VT_I2 || rightvt == VT_I2 ||
3306 leftvt == VT_BOOL || rightvt == VT_BOOL)
3310 else if (leftvt == VT_I8 || rightvt == VT_I8)
3313 else if (leftvt == VT_I2 || rightvt == VT_I2)
3315 if (leftvt == rightvt ||
3316 leftvt == VT_BOOL || rightvt == VT_BOOL)
3318 else if (leftvt == VT_I8 || rightvt == VT_I8)
3321 else if (leftvt == VT_BOOL && rightvt == VT_BOOL)
3325 else if (leftvt == VT_I8 || rightvt == VT_I8)
3327 if (leftvt == VT_INT || rightvt == VT_INT)
3332 hres = pVarXor(&left, &right, &result);
3334 ok(hres == DISP_E_TYPEMISMATCH || hres == DISP_E_BADVARTYPE,
3335 "VarXor: %d|0x%X, %d|0x%X: Expected failure, got 0x%X vt %d\n",
3336 leftvt, ExtraFlags[i], rightvt, ExtraFlags[i], hres,
3339 ok(hres == S_OK && V_VT(&result) == resvt,
3340 "VarXor: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%X vt %d\n",
3341 leftvt, ExtraFlags[i], rightvt, ExtraFlags[i], resvt, hres,
3347 /* Test returned values
3348 * FIXME: Test VT_DECIMAL/VT_DISPATCH
3350 VARXOR(EMPTY,0,EMPTY,0,I2,0);
3351 VARXOR(EMPTY,1,EMPTY,0,I2,0);
3352 VARXOR(EMPTY,0,NULL,0,NULL,0);
3353 VARXOR(EMPTY,0,I1,0,I4,0);
3354 VARXOR(EMPTY,0,I1,1,I4,1);
3355 VARXOR(EMPTY,0,UI1,0,I2,0);
3356 VARXOR(EMPTY,0,UI1,1,I2,1);
3357 VARXOR(EMPTY,0,I2,0,I2,0);
3358 VARXOR(EMPTY,0,I2,1,I2,1);
3359 VARXOR(EMPTY,0,UI2,0,I4,0);
3360 VARXOR(EMPTY,0,UI2,1,I4,1);
3361 VARXOR(EMPTY,0,I4,0,I4,0);
3362 VARXOR(EMPTY,0,I4,1,I4,1);
3363 VARXOR(EMPTY,0,UI4,0,I4,0);
3364 VARXOR(EMPTY,0,UI4,1,I4,1);
3365 if (HAVE_OLEAUT32_I8)
3367 VARXOR(EMPTY,0,I8,0,I8,0);
3368 VARXOR(EMPTY,0,I8,1,I8,1);
3369 VARXOR(EMPTY,0,UI8,0,I4,0);
3370 VARXOR(EMPTY,0,UI8,1,I4,1);
3372 VARXOR(EMPTY,0,INT,0,I4,0);
3373 VARXOR(EMPTY,0,INT,1,I4,1);
3374 VARXOR(EMPTY,0,UINT,0,I4,0);
3375 VARXOR(EMPTY,0,UINT,1,I4,1);
3376 VARXOR(EMPTY,0,BOOL,0,I2,0);
3377 VARXOR(EMPTY,0,BOOL,1,I2,1);
3378 VARXOR(EMPTY,0,R4,0,I4,0);
3379 VARXOR(EMPTY,0,R4,1,I4,1);
3380 VARXOR(EMPTY,0,R8,0,I4,0);
3381 VARXOR(EMPTY,0,R8,1,I4,1);
3382 rbstr = SysAllocString(szFalse);
3383 VARXOR(EMPTY,0,BSTR,rbstr,I2,0);
3384 rbstr = SysAllocString(szTrue);
3385 VARXOR(EMPTY,0,BSTR,rbstr,I2,-1);
3386 VARXORCY(EMPTY,0,10000,I4,1);
3388 /* NULL OR 0 = NULL. NULL OR n = n */
3389 VARXOR(NULL,0,NULL,0,NULL,0);
3390 VARXOR(NULL,1,NULL,0,NULL,0);
3391 VARXOR(NULL,0,I1,0,NULL,0);
3392 VARXOR(NULL,0,I1,1,NULL,0);
3393 VARXOR(NULL,0,UI1,0,NULL,0);
3394 VARXOR(NULL,0,UI1,1,NULL,0);
3395 VARXOR(NULL,0,I2,0,NULL,0);
3396 VARXOR(NULL,0,I2,1,NULL,0);
3397 VARXOR(NULL,0,UI2,0,NULL,0);
3398 VARXOR(NULL,0,UI2,1,NULL,0);
3399 VARXOR(NULL,0,I4,0,NULL,0);
3400 VARXOR(NULL,0,I4,1,NULL,0);
3401 VARXOR(NULL,0,UI4,0,NULL,0);
3402 VARXOR(NULL,0,UI4,1,NULL,0);
3403 if (HAVE_OLEAUT32_I8)
3405 VARXOR(NULL,0,I8,0,NULL,0);
3406 VARXOR(NULL,0,I8,1,NULL,0);
3407 VARXOR(NULL,0,UI8,0,NULL,0);
3408 VARXOR(NULL,0,UI8,1,NULL,0);
3410 VARXOR(NULL,0,INT,0,NULL,0);
3411 VARXOR(NULL,0,INT,1,NULL,0);
3412 VARXOR(NULL,0,UINT,0,NULL,0);
3413 VARXOR(NULL,0,UINT,1,NULL,0);
3414 VARXOR(NULL,0,BOOL,0,NULL,0);
3415 VARXOR(NULL,0,BOOL,1,NULL,0);
3416 VARXOR(NULL,0,R4,0,NULL,0);
3417 VARXOR(NULL,0,R4,1,NULL,0);
3418 VARXOR(NULL,0,R8,0,NULL,0);
3419 VARXOR(NULL,0,R8,1,NULL,0);
3420 rbstr = SysAllocString(szFalse);
3421 VARXOR(NULL,0,BSTR,rbstr,NULL,0);
3422 rbstr = SysAllocString(szTrue);
3423 VARXOR(NULL,0,BSTR,rbstr,NULL,0);
3424 VARXORCY(NULL,0,10000,NULL,0);
3425 VARXORCY(NULL,0,0,NULL,0);
3427 VARXOR(BOOL,VARIANT_TRUE,BOOL,VARIANT_TRUE,BOOL,VARIANT_FALSE);
3428 VARXOR(BOOL,VARIANT_TRUE,BOOL,VARIANT_FALSE,BOOL,VARIANT_TRUE);
3429 VARXOR(BOOL,VARIANT_FALSE,BOOL,VARIANT_TRUE,BOOL,VARIANT_TRUE);
3430 VARXOR(BOOL,VARIANT_FALSE,BOOL,VARIANT_FALSE,BOOL,VARIANT_FALSE);
3431 /* Assume x,y & y,x are the same from now on to reduce the number of tests */
3432 VARXOR(BOOL,VARIANT_TRUE,I1,-1,I4,0);
3433 VARXOR(BOOL,VARIANT_TRUE,I1,0,I4,-1);
3434 VARXOR(BOOL,VARIANT_FALSE,I1,0,I4,0);
3435 VARXOR(BOOL,VARIANT_TRUE,UI1,255,I2,-256);
3436 VARXOR(BOOL,VARIANT_TRUE,UI1,0,I2,-1);
3437 VARXOR(BOOL,VARIANT_FALSE,UI1,0,I2,0);
3438 VARXOR(BOOL,VARIANT_TRUE,I2,-1,I2,0);
3439 VARXOR(BOOL,VARIANT_TRUE,I2,0,I2,-1);
3440 VARXOR(BOOL,VARIANT_FALSE,I2,0,I2,0);
3441 VARXOR(BOOL,VARIANT_TRUE,UI2,65535,I4,-65536);
3442 VARXOR(BOOL,VARIANT_TRUE,UI2,0,I4,-1);
3443 VARXOR(BOOL,VARIANT_FALSE,UI2,0,I4,0);
3444 VARXOR(BOOL,VARIANT_TRUE,I4,-1,I4,0);
3445 VARXOR(BOOL,VARIANT_TRUE,I4,0,I4,-1);
3446 VARXOR(BOOL,VARIANT_FALSE,I4,0,I4,0);
3447 VARXOR(BOOL,VARIANT_TRUE,UI4,0xffffffff,I4,0);
3448 VARXOR(BOOL,VARIANT_TRUE,UI4,0,I4,-1);
3449 VARXOR(BOOL,VARIANT_FALSE,UI4,0,I4,0);
3450 VARXOR(BOOL,VARIANT_TRUE,R4,-1,I4,0);
3451 VARXOR(BOOL,VARIANT_TRUE,R4,0,I4,-1);
3452 VARXOR(BOOL,VARIANT_FALSE,R4,0,I4,0);
3453 VARXOR(BOOL,VARIANT_TRUE,R8,-1,I4,0);
3454 VARXOR(BOOL,VARIANT_TRUE,R8,0,I4,-1);
3455 VARXOR(BOOL,VARIANT_FALSE,R8,0,I4,0);
3456 VARXOR(BOOL,VARIANT_TRUE,DATE,-1,I4,0);
3457 VARXOR(BOOL,VARIANT_TRUE,DATE,0,I4,-1);
3458 VARXOR(BOOL,VARIANT_FALSE,DATE,0,I4,0);
3459 if (HAVE_OLEAUT32_I8)
3461 VARXOR(BOOL,VARIANT_TRUE,I8,-1,I8,0);
3462 VARXOR(BOOL,VARIANT_TRUE,I8,0,I8,-1);
3463 VARXOR(BOOL,VARIANT_FALSE,I8,0,I8,0);
3464 /* This returns DISP_E_OVERFLOW which indicates that a conversion
3465 * to I4 is performed.
3467 /* VARXOR(BOOL,VARIANT_TRUE,UI8,-1,I4,-1); */
3468 VARXOR(BOOL,VARIANT_TRUE,UI8,0,I4,-1);
3469 VARXOR(BOOL,VARIANT_FALSE,UI8,0,I4,0);
3471 VARXOR(BOOL,VARIANT_TRUE,INT,-1,I4,0);
3472 VARXOR(BOOL,VARIANT_TRUE,INT,0,I4,-1);
3473 VARXOR(BOOL,VARIANT_FALSE,INT,0,I4,0);
3474 VARXOR(BOOL,VARIANT_TRUE,UINT,0xffffffff,I4,0);
3475 VARXOR(BOOL,VARIANT_TRUE,UINT,0,I4,-1);
3476 VARXOR(BOOL,VARIANT_FALSE,UINT,0,I4,0);
3477 rbstr = SysAllocString(szFalse);
3478 VARXOR(BOOL,VARIANT_FALSE,BSTR,rbstr,BOOL,VARIANT_FALSE);
3479 VARXOR(BOOL,VARIANT_TRUE,BSTR,rbstr,BOOL,VARIANT_TRUE);
3480 rbstr = SysAllocString(szTrue);
3481 VARXOR(BOOL,VARIANT_FALSE,BSTR,rbstr,BOOL,VARIANT_TRUE);
3482 VARXOR(BOOL,VARIANT_TRUE,BSTR,rbstr,BOOL,VARIANT_FALSE);
3483 VARXORCY(BOOL,VARIANT_TRUE,10000,I4,-2);
3484 VARXORCY(BOOL,VARIANT_TRUE,0,I4,-1);
3485 VARXORCY(BOOL,VARIANT_FALSE,0,I4,0);
3487 VARXOR(I1,-1,I1,-1,I4,0);
3488 VARXOR(I1,-1,I1,0,I4,-1);
3489 VARXOR(I1,0,I1,0,I4,0);
3490 VARXOR(I1,-1,UI1,255,I4,-256);
3491 VARXOR(I1,-1,UI1,0,I4,-1);
3492 VARXOR(I1,0,UI1,0,I4,0);
3493 VARXOR(I1,-1,I2,-1,I4,0);
3494 VARXOR(I1,-1,I2,0,I4,-1);
3495 VARXOR(I1,0,I2,0,I4,0);
3496 VARXOR(I1,-1,UI2,65535,I4,-65536);
3497 VARXOR(I1,-1,UI2,0,I4,-1);
3498 VARXOR(I1,0,UI2,0,I4,0);
3499 VARXOR(I1,-1,I4,-1,I4,0);
3500 VARXOR(I1,-1,I4,0,I4,-1);
3501 VARXOR(I1,0,I4,0,I4,0);
3502 VARXOR(I1,-1,UI4,0xffffffff,I4,0);
3503 VARXOR(I1,-1,UI4,0,I4,-1);
3504 VARXOR(I1,0,UI4,0,I4,0);
3505 VARXOR(I1,-1,R4,-1,I4,0);
3506 VARXOR(I1,-1,R4,0,I4,-1);
3507 VARXOR(I1,0,R4,0,I4,0);
3508 VARXOR(I1,-1,R8,-1,I4,0);
3509 VARXOR(I1,-1,R8,0,I4,-1);
3510 VARXOR(I1,0,R8,0,I4,0);
3511 VARXOR(I1,-1,DATE,-1,I4,0);
3512 VARXOR(I1,-1,DATE,0,I4,-1);
3513 VARXOR(I1,0,DATE,0,I4,0);
3514 if (HAVE_OLEAUT32_I8)
3516 VARXOR(I1,-1,I8,-1,I8,0);
3517 VARXOR(I1,-1,I8,0,I8,-1);
3518 VARXOR(I1,0,I8,0,I8,0);
3519 VARXOR(I1,-1,UI8,0,I4,-1);
3520 VARXOR(I1,0,UI8,0,I4,0);
3522 VARXOR(I1,-1,INT,-1,I4,0);
3523 VARXOR(I1,-1,INT,0,I4,-1);
3524 VARXOR(I1,0,INT,0,I4,0);
3525 VARXOR(I1,-1,UINT,0xffffffff,I4,0);
3526 VARXOR(I1,-1,UINT,0,I4,-1);
3527 VARXOR(I1,0,UINT,0,I4,0);
3528 rbstr = SysAllocString(szFalse);
3529 VARXOR(I1,0,BSTR,rbstr,I4,0);
3530 VARXOR(I1,-1,BSTR,rbstr,I4,-1);
3531 rbstr = SysAllocString(szTrue);
3532 VARXOR(I1,0,BSTR,rbstr,I4,-1);
3533 VARXOR(I1,-1,BSTR,rbstr,I4,0);
3534 VARXORCY(I1,-1,10000,I4,-2);
3535 VARXORCY(I1,-1,0,I4,-1);
3536 VARXORCY(I1,0,0,I4,0);
3538 VARXOR(UI1,255,UI1,255,UI1,0);
3539 VARXOR(UI1,255,UI1,0,UI1,255);
3540 VARXOR(UI1,0,UI1,0,UI1,0);
3541 VARXOR(UI1,255,I2,-1,I2,-256);
3542 VARXOR(UI1,255,I2,0,I2,255);
3543 VARXOR(UI1,0,I2,0,I2,0);
3544 VARXOR(UI1,255,UI2,65535,I4,65280);
3545 VARXOR(UI1,255,UI2,0,I4,255);
3546 VARXOR(UI1,0,UI2,0,I4,0);
3547 VARXOR(UI1,255,I4,-1,I4,-256);
3548 VARXOR(UI1,255,I4,0,I4,255);
3549 VARXOR(UI1,0,I4,0,I4,0);
3550 VARXOR(UI1,255,UI4,0xffffffff,I4,-256);
3551 VARXOR(UI1,255,UI4,0,I4,255);
3552 VARXOR(UI1,0,UI4,0,I4,0);
3553 VARXOR(UI1,255,R4,-1,I4,-256);
3554 VARXOR(UI1,255,R4,0,I4,255);
3555 VARXOR(UI1,0,R4,0,I4,0);
3556 VARXOR(UI1,255,R8,-1,I4,-256);
3557 VARXOR(UI1,255,R8,0,I4,255);
3558 VARXOR(UI1,0,R8,0,I4,0);
3559 VARXOR(UI1,255,DATE,-1,I4,-256);
3560 VARXOR(UI1,255,DATE,0,I4,255);
3561 VARXOR(UI1,0,DATE,0,I4,0);
3562 if (HAVE_OLEAUT32_I8)
3564 VARXOR(UI1,255,I8,-1,I8,-256);
3565 VARXOR(UI1,255,I8,0,I8,255);
3566 VARXOR(UI1,0,I8,0,I8,0);
3567 VARXOR(UI1,255,UI8,0,I4,255);
3568 VARXOR(UI1,0,UI8,0,I4,0);
3570 VARXOR(UI1,255,INT,-1,I4,-256);
3571 VARXOR(UI1,255,INT,0,I4,255);
3572 VARXOR(UI1,0,INT,0,I4,0);
3573 VARXOR(UI1,255,UINT,0xffffffff,I4,-256);
3574 VARXOR(UI1,255,UINT,0,I4,255);
3575 VARXOR(UI1,0,UINT,0,I4,0);
3576 rbstr = SysAllocString(szFalse);
3577 VARXOR(UI1,0,BSTR,rbstr,I2,0);
3578 VARXOR(UI1,255,BSTR,rbstr,I2,255);
3579 rbstr = SysAllocString(szTrue);
3580 VARXOR(UI1,0,BSTR,rbstr,I2,-1);
3581 VARXOR(UI1,255,BSTR,rbstr,I2,-256);
3582 VARXORCY(UI1,255,10000,I4,254);
3583 VARXORCY(UI1,255,0,I4,255);
3584 VARXORCY(UI1,0,0,I4,0);
3586 VARXOR(I2,-1,I2,-1,I2,0);
3587 VARXOR(I2,-1,I2,0,I2,-1);
3588 VARXOR(I2,0,I2,0,I2,0);
3589 VARXOR(I2,-1,UI2,65535,I4,-65536);
3590 VARXOR(I2,-1,UI2,0,I4,-1);
3591 VARXOR(I2,0,UI2,0,I4,0);
3592 VARXOR(I2,-1,I4,-1,I4,0);
3593 VARXOR(I2,-1,I4,0,I4,-1);
3594 VARXOR(I2,0,I4,0,I4,0);
3595 VARXOR(I2,-1,UI4,0xffffffff,I4,0);
3596 VARXOR(I2,-1,UI4,0,I4,-1);
3597 VARXOR(I2,0,UI4,0,I4,0);
3598 VARXOR(I2,-1,R4,-1,I4,0);
3599 VARXOR(I2,-1,R4,0,I4,-1);
3600 VARXOR(I2,0,R4,0,I4,0);
3601 VARXOR(I2,-1,R8,-1,I4,0);
3602 VARXOR(I2,-1,R8,0,I4,-1);
3603 VARXOR(I2,0,R8,0,I4,0);
3604 VARXOR(I2,-1,DATE,-1,I4,0);
3605 VARXOR(I2,-1,DATE,0,I4,-1);
3606 VARXOR(I2,0,DATE,0,I4,0);
3607 if (HAVE_OLEAUT32_I8)
3609 VARXOR(I2,-1,I8,-1,I8,0);
3610 VARXOR(I2,-1,I8,0,I8,-1);
3611 VARXOR(I2,0,I8,0,I8,0);
3612 VARXOR(I2,-1,UI8,0,I4,-1);
3613 VARXOR(I2,0,UI8,0,I4,0);
3615 VARXOR(I2,-1,INT,-1,I4,0);
3616 VARXOR(I2,-1,INT,0,I4,-1);
3617 VARXOR(I2,0,INT,0,I4,0);
3618 VARXOR(I2,-1,UINT,0xffffffff,I4,0);
3619 VARXOR(I2,-1,UINT,0,I4,-1);
3620 VARXOR(I2,0,UINT,0,I4,0);
3621 rbstr = SysAllocString(szFalse);
3622 VARXOR(I2,0,BSTR,rbstr,I2,0);
3623 VARXOR(I2,-1,BSTR,rbstr,I2,-1);
3624 rbstr = SysAllocString(szTrue);
3625 VARXOR(I2,0,BSTR,rbstr,I2,-1);
3626 VARXOR(I2,-1,BSTR,rbstr,I2,0);
3627 VARXORCY(I2,-1,10000,I4,-2);
3628 VARXORCY(I2,-1,0,I4,-1);
3629 VARXORCY(I2,0,0,I4,0);
3631 VARXOR(UI2,65535,UI2,65535,I4,0);
3632 VARXOR(UI2,65535,UI2,0,I4,65535);
3633 VARXOR(UI2,0,UI2,0,I4,0);
3634 VARXOR(UI2,65535,I4,-1,I4,-65536);
3635 VARXOR(UI2,65535,I4,0,I4,65535);
3636 VARXOR(UI2,0,I4,0,I4,0);
3637 VARXOR(UI2,65535,UI4,0xffffffff,I4,-65536);
3638 VARXOR(UI2,65535,UI4,0,I4,65535);
3639 VARXOR(UI2,0,UI4,0,I4,0);
3640 VARXOR(UI2,65535,R4,-1,I4,-65536);
3641 VARXOR(UI2,65535,R4,0,I4,65535);
3642 VARXOR(UI2,0,R4,0,I4,0);
3643 VARXOR(UI2,65535,R8,-1,I4,-65536);
3644 VARXOR(UI2,65535,R8,0,I4,65535);
3645 VARXOR(UI2,0,R8,0,I4,0);
3646 VARXOR(UI2,65535,DATE,-1,I4,-65536);
3647 VARXOR(UI2,65535,DATE,0,I4,65535);
3648 VARXOR(UI2,0,DATE,0,I4,0);
3649 if (HAVE_OLEAUT32_I8)
3651 VARXOR(UI2,65535,I8,-1,I8,-65536);
3652 VARXOR(UI2,65535,I8,0,I8,65535);
3653 VARXOR(UI2,0,I8,0,I8,0);
3654 VARXOR(UI2,65535,UI8,0,I4,65535);
3655 VARXOR(UI2,0,UI8,0,I4,0);
3657 VARXOR(UI2,65535,INT,-1,I4,-65536);
3658 VARXOR(UI2,65535,INT,0,I4,65535);
3659 VARXOR(UI2,0,INT,0,I4,0);
3660 VARXOR(UI2,65535,UINT,0xffffffff,I4,-65536);
3661 VARXOR(UI2,65535,UINT,0,I4,65535);
3662 VARXOR(UI2,0,UINT,0,I4,0);
3663 rbstr = SysAllocString(szFalse);
3664 VARXOR(UI2,0,BSTR,rbstr,I4,0);
3665 VARXOR(UI2,65535,BSTR,rbstr,I4,65535);
3666 rbstr = SysAllocString(szTrue);
3667 VARXOR(UI2,0,BSTR,rbstr,I4,-1);
3668 VARXOR(UI2,65535,BSTR,rbstr,I4,-65536);
3669 VARXORCY(UI2,65535,10000,I4,65534);
3670 VARXORCY(UI2,65535,0,I4,65535);
3671 VARXORCY(UI2,0,0,I4,0);
3673 VARXOR(I4,-1,I4,-1,I4,0);
3674 VARXOR(I4,-1,I4,0,I4,-1);
3675 VARXOR(I4,0,I4,0,I4,0);
3676 VARXOR(I4,-1,UI4,0xffffffff,I4,0);
3677 VARXOR(I4,-1,UI4,0,I4,-1);
3678 VARXOR(I4,0,UI4,0,I4,0);
3679 VARXOR(I4,-1,R4,-1,I4,0);
3680 VARXOR(I4,-1,R4,0,I4,-1);
3681 VARXOR(I4,0,R4,0,I4,0);
3682 VARXOR(I4,-1,R8,-1,I4,0);
3683 VARXOR(I4,-1,R8,0,I4,-1);
3684 VARXOR(I4,0,R8,0,I4,0);
3685 VARXOR(I4,-1,DATE,-1,I4,0);
3686 VARXOR(I4,-1,DATE,0,I4,-1);
3687 VARXOR(I4,0,DATE,0,I4,0);
3688 if (HAVE_OLEAUT32_I8)
3690 VARXOR(I4,-1,I8,-1,I8,0);
3691 VARXOR(I4,-1,I8,0,I8,-1);
3692 VARXOR(I4,0,I8,0,I8,0);
3693 VARXOR(I4,-1,UI8,0,I4,-1);
3694 VARXOR(I4,0,UI8,0,I4,0);
3696 VARXOR(I4,-1,INT,-1,I4,0);
3697 VARXOR(I4,-1,INT,0,I4,-1);
3698 VARXOR(I4,0,INT,0,I4,0);
3699 VARXOR(I4,-1,UINT,0xffffffff,I4,0);
3700 VARXOR(I4,-1,UINT,0,I4,-1);
3701 VARXOR(I4,0,UINT,0,I4,0);
3702 rbstr = SysAllocString(szFalse);
3703 VARXOR(I4,0,BSTR,rbstr,I4,0);
3704 VARXOR(I4,-1,BSTR,rbstr,I4,-1);
3705 rbstr = SysAllocString(szTrue);
3706 VARXOR(I4,0,BSTR,rbstr,I4,-1);
3707 VARXOR(I4,-1,BSTR,rbstr,I4,0);
3708 VARXORCY(I4,-1,10000,I4,-2);
3709 VARXORCY(I4,-1,0,I4,-1);
3710 VARXORCY(I4,0,0,I4,0);
3712 VARXOR(UI4,0xffffffff,UI4,0xffffffff,I4,0);
3713 VARXOR(UI4,0xffffffff,UI4,0,I4,-1);
3714 VARXOR(UI4,0,UI4,0,I4,0);
3715 VARXOR(UI4,0xffffffff,R4,-1,I4,0);
3716 VARXOR(UI4,0xffffffff,R4,0,I4,-1);
3717 VARXOR(UI4,0,R4,0,I4,0);
3718 VARXOR(UI4,0xffffffff,R8,-1,I4,0);
3719 VARXOR(UI4,0xffffffff,R8,0,I4,-1);
3720 VARXOR(UI4,0,R8,0,I4,0);
3721 VARXOR(UI4,0xffffffff,DATE,-1,I4,0);
3722 VARXOR(UI4,0xffffffff,DATE,0,I4,-1);
3723 VARXOR(UI4,0,DATE,0,I4,0);
3724 if (HAVE_OLEAUT32_I8)
3726 VARXOR(UI4,0xffffffff,I8,0,I8,0xffffffff);
3727 VARXOR(UI4,VARIANT_FALSE,I8,VARIANT_FALSE,I8,0);
3728 VARXOR(UI4,0,I8,0,I8,0);
3729 VARXOR(UI4,0xffffffff,UI8,0,I4,-1);
3730 VARXOR(UI4,0,UI8,0,I4,0);
3732 VARXOR(UI4,0xffffffff,INT,-1,I4,0);
3733 VARXOR(UI4,0xffffffff,INT,0,I4,-1);
3734 VARXOR(UI4,0,INT,0,I4,0);
3735 VARXOR(UI4,0xffffffff,UINT,0xffffffff,I4,0);
3736 VARXOR(UI4,0xffffffff,UINT,0,I4,-1);
3737 VARXOR(UI4,0,UINT,0,I4,0);
3738 rbstr = SysAllocString(szFalse);
3739 VARXOR(UI4,0,BSTR,rbstr,I4,0);
3740 VARXOR(UI4,0xffffffff,BSTR,rbstr,I4,-1);
3741 rbstr = SysAllocString(szTrue);
3742 VARXOR(UI4,0,BSTR,rbstr,I4,-1);
3743 VARXOR(UI4,0xffffffff,BSTR,rbstr,I4,0);
3744 VARXORCY(UI4,0xffffffff,10000,I4,-2);
3745 VARXORCY(UI4,0xffffffff,0,I4,-1);
3746 VARXORCY(UI4,0,0,I4,0);
3748 VARXOR(R4,-1,R4,-1,I4,0);
3749 VARXOR(R4,-1,R4,0,I4,-1);
3750 VARXOR(R4,0,R4,0,I4,0);
3751 VARXOR(R4,-1,R8,-1,I4,0);
3752 VARXOR(R4,-1,R8,0,I4,-1);
3753 VARXOR(R4,0,R8,0,I4,0);
3754 VARXOR(R4,-1,DATE,-1,I4,0);
3755 VARXOR(R4,-1,DATE,0,I4,-1);
3756 VARXOR(R4,0,DATE,0,I4,0);
3757 if (HAVE_OLEAUT32_I8)
3759 VARXOR(R4,-1,I8,-1,I8,0);
3760 VARXOR(R4,-1,I8,0,I8,-1);
3761 VARXOR(R4,0,I8,0,I8,0);
3762 VARXOR(R4,-1,UI8,0,I4,-1);
3763 VARXOR(R4,0,UI8,0,I4,0);
3765 VARXOR(R4,-1,INT,-1,I4,0);
3766 VARXOR(R4,-1,INT,0,I4,-1);
3767 VARXOR(R4,0,INT,0,I4,0);
3768 VARXOR(R4,-1,UINT,0xffffffff,I4,0);
3769 VARXOR(R4,-1,UINT,0,I4,-1);
3770 VARXOR(R4,0,UINT,0,I4,0);
3771 rbstr = SysAllocString(szFalse);
3772 VARXOR(R4,0,BSTR,rbstr,I4,0);
3773 VARXOR(R4,-1,BSTR,rbstr,I4,-1);
3774 rbstr = SysAllocString(szTrue);
3775 VARXOR(R4,0,BSTR,rbstr,I4,-1);
3776 VARXOR(R4,-1,BSTR,rbstr,I4,0);
3777 VARXORCY(R4,-1,10000,I4,-2);
3778 VARXORCY(R4,-1,0,I4,-1);
3779 VARXORCY(R4,0,0,I4,0);
3781 VARXOR(R8,-1,R8,-1,I4,0);
3782 VARXOR(R8,-1,R8,0,I4,-1);
3783 VARXOR(R8,0,R8,0,I4,0);
3784 VARXOR(R8,-1,DATE,-1,I4,0);
3785 VARXOR(R8,-1,DATE,0,I4,-1);
3786 VARXOR(R8,0,DATE,0,I4,0);
3787 if (HAVE_OLEAUT32_I8)
3789 VARXOR(R8,-1,I8,-1,I8,0);
3790 VARXOR(R8,-1,I8,0,I8,-1);
3791 VARXOR(R8,0,I8,0,I8,0);
3792 VARXOR(R8,-1,UI8,0,I4,-1);
3793 VARXOR(R8,0,UI8,0,I4,0);
3795 VARXOR(R8,-1,INT,-1,I4,0);
3796 VARXOR(R8,-1,INT,0,I4,-1);
3797 VARXOR(R8,0,INT,0,I4,0);
3798 VARXOR(R8,-1,UINT,0xffffffff,I4,0);
3799 VARXOR(R8,-1,UINT,0,I4,-1);
3800 VARXOR(R8,0,UINT,0,I4,0);
3801 rbstr = SysAllocString(szFalse);
3802 VARXOR(R8,0,BSTR,rbstr,I4,0);
3803 VARXOR(R8,-1,BSTR,rbstr,I4,-1);
3804 rbstr = SysAllocString(szTrue);
3805 VARXOR(R8,0,BSTR,rbstr,I4,-1);
3806 VARXOR(R8,-1,BSTR,rbstr,I4,0);
3807 VARXORCY(R8,-1,10000,I4,-2);
3808 VARXORCY(R8,-1,0,I4,-1);
3809 VARXORCY(R8,0,0,I4,0);
3811 VARXOR(DATE,-1,DATE,-1,I4,0);
3812 VARXOR(DATE,-1,DATE,0,I4,-1);
3813 VARXOR(DATE,0,DATE,0,I4,0);
3814 if (HAVE_OLEAUT32_I8)
3816 VARXOR(DATE,-1,I8,-1,I8,0);
3817 VARXOR(DATE,-1,I8,0,I8,-1);
3818 VARXOR(DATE,0,I8,0,I8,0);
3819 VARXOR(DATE,-1,UI8,0,I4,-1);
3820 VARXOR(DATE,0,UI8,0,I4,0);
3822 VARXOR(DATE,-1,INT,-1,I4,0);
3823 VARXOR(DATE,-1,INT,0,I4,-1);
3824 VARXOR(DATE,0,INT,0,I4,0);
3825 VARXOR(DATE,-1,UINT,0xffffffff,I4,0);
3826 VARXOR(DATE,-1,UINT,0,I4,-1);
3827 VARXOR(DATE,0,UINT,0,I4,0);
3828 rbstr = SysAllocString(szFalse);
3829 VARXOR(DATE,0,BSTR,rbstr,I4,0);
3830 VARXOR(DATE,-1,BSTR,rbstr,I4,-1);
3831 rbstr = SysAllocString(szTrue);
3832 VARXOR(DATE,0,BSTR,rbstr,I4,-1);
3833 VARXOR(DATE,-1,BSTR,rbstr,I4,0);
3834 VARXORCY(DATE,-1,10000,I4,-2);
3835 VARXORCY(DATE,-1,0,I4,-1);
3836 VARXORCY(DATE,0,0,I4,0);
3838 if (HAVE_OLEAUT32_I8)
3840 VARXOR(I8,-1,I8,-1,I8,0);
3841 VARXOR(I8,-1,I8,0,I8,-1);
3842 VARXOR(I8,0,I8,0,I8,0);
3843 VARXOR(I8,-1,UI8,0,I8,-1);
3844 VARXOR(I8,0,UI8,0,I8,0);
3845 VARXOR(I8,-1,UINT,0,I8,-1);
3846 VARXOR(I8,0,UINT,0,I8,0);
3847 rbstr = SysAllocString(szFalse);
3848 VARXOR(I8,0,BSTR,rbstr,I8,0);
3849 VARXOR(I8,-1,BSTR,rbstr,I8,-1);
3850 rbstr = SysAllocString(szTrue);
3851 VARXOR(I8,0,BSTR,rbstr,I8,-1);
3852 VARXOR(I8,-1,BSTR,rbstr,I8,0);
3853 VARXORCY(I8,-1,10000,I8,-2);
3854 VARXORCY(I8,-1,0,I8,-1);
3855 VARXORCY(I8,0,0,I8,0);
3857 VARXOR(UI8,0xffff,UI8,0xffff,I4,0);
3858 VARXOR(UI8,0xffff,UI8,0,I4,0xffff);
3859 VARXOR(UI8,0,UI8,0,I4,0);
3860 VARXOR(UI8,0xffff,INT,-1,I4,-65536);
3861 VARXOR(UI8,0xffff,INT,0,I4,0xffff);
3862 VARXOR(UI8,0,INT,0,I4,0);
3863 VARXOR(UI8,0xffff,UINT,0xffff,I4,0);
3864 VARXOR(UI8,0xffff,UINT,0,I4,0xffff);
3865 VARXOR(UI8,0,UINT,0,I4,0);
3866 rbstr = SysAllocString(szFalse);
3867 VARXOR(UI8,0,BSTR,rbstr,I4,0);
3868 VARXOR(UI8,0xffff,BSTR,rbstr,I4,0xffff);
3869 rbstr = SysAllocString(szTrue);
3870 VARXOR(UI8,0,BSTR,rbstr,I4,-1);
3871 VARXOR(UI8,0xffff,BSTR,rbstr,I4,-65536);
3872 VARXORCY(UI8,0xffff,10000,I4,65534);
3873 VARXORCY(UI8,0xffff,0,I4,0xffff);
3874 VARXORCY(UI8,0,0,I4,0);
3877 VARXOR(INT,-1,INT,-1,I4,0);
3878 VARXOR(INT,-1,INT,0,I4,-1);
3879 VARXOR(INT,0,INT,0,I4,0);
3880 VARXOR(INT,-1,UINT,0xffff,I4,-65536);
3881 VARXOR(INT,-1,UINT,0,I4,-1);
3882 VARXOR(INT,0,UINT,0,I4,0);
3883 rbstr = SysAllocString(szFalse);
3884 VARXOR(INT,0,BSTR,rbstr,I4,0);
3885 VARXOR(INT,-1,BSTR,rbstr,I4,-1);
3886 rbstr = SysAllocString(szTrue);
3887 VARXOR(INT,0,BSTR,rbstr,I4,-1);
3888 VARXOR(INT,-1,BSTR,rbstr,I4,0);
3889 VARXORCY(INT,-1,10000,I4,-2);
3890 VARXORCY(INT,-1,0,I4,-1);
3891 VARXORCY(INT,0,0,I4,0);
3893 VARXOR(UINT,0xffff,UINT,0xffff,I4,0);
3894 VARXOR(UINT,0xffff,UINT,0,I4,0xffff);
3895 VARXOR(UINT,0,UINT,0,I4,0);
3896 rbstr = SysAllocString(szFalse);
3897 VARXOR(UINT,0,BSTR,rbstr,I4,0);
3898 VARXOR(UINT,0xffff,BSTR,rbstr,I4,0xffff);
3899 rbstr = SysAllocString(szTrue);
3900 VARXOR(UINT,0,BSTR,rbstr,I4,-1);
3901 VARXOR(UINT,0xffff,BSTR,rbstr,I4,-65536);
3902 VARXORCY(UINT,0xffff,10000,I4,65534);
3903 VARXORCY(UINT,0xffff,0,I4,0xffff);
3904 VARXORCY(UINT,0,0,I4,0);
3906 lbstr = SysAllocString(szFalse);
3907 rbstr = SysAllocString(szFalse);
3908 VARXOR(BSTR,lbstr,BSTR,rbstr,BOOL,0);
3909 rbstr = SysAllocString(szTrue);
3910 VARXOR(BSTR,lbstr,BSTR,rbstr,BOOL,VARIANT_TRUE);
3911 lbstr = SysAllocString(szTrue);
3912 VARXOR(BSTR,lbstr,BSTR,rbstr,BOOL,VARIANT_FALSE);
3913 VARXORCY(BSTR,lbstr,10000,I4,-2);
3914 lbstr = SysAllocString(szFalse);
3915 VARXORCY(BSTR,lbstr,10000,I4,1);
3918 static HRESULT (WINAPI *pVarOr)(LPVARIANT,LPVARIANT,LPVARIANT);
3920 #define VAROR(vt1,val1,vt2,val2,rvt,rval) \
3921 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
3922 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
3923 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
3924 test_var_call2( __LINE__, pVarOr, &left, &right, &exp )
3926 #define VARORCY(vt1,val1,val2,rvt,rval) \
3927 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
3928 V_VT(&right) = VT_CY; V_CY(&right).int64 = val2; \
3929 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
3930 test_var_call2( __LINE__, pVarOr, &left, &right, &exp )
3932 static void test_VarOr(void)
3934 static const WCHAR szFalse[] = { '#','F','A','L','S','E','#','\0' };
3935 static const WCHAR szTrue[] = { '#','T','R','U','E','#','\0' };
3936 VARIANT left, right, exp, result;
3943 /* Test all possible flag/vt combinations & the resulting vt type */
3944 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
3946 VARTYPE leftvt, rightvt, resvt;
3948 for (leftvt = 0; leftvt <= VT_BSTR_BLOB; leftvt++)
3953 for (rightvt = 0; rightvt <= VT_BSTR_BLOB; rightvt++)
3959 if (leftvt == VT_BSTR || rightvt == VT_BSTR ||
3960 leftvt == VT_DISPATCH || rightvt == VT_DISPATCH ||
3961 leftvt == VT_UNKNOWN || rightvt == VT_UNKNOWN)
3964 memset(&left, 0, sizeof(left));
3965 memset(&right, 0, sizeof(right));
3966 V_VT(&left) = leftvt | ExtraFlags[i];
3967 V_VT(&right) = rightvt | ExtraFlags[i];
3968 V_VT(&result) = VT_EMPTY;
3971 if (ExtraFlags[i] & VT_ARRAY || ExtraFlags[i] & VT_BYREF ||
3972 !IsValidVariantClearVT(leftvt, ExtraFlags[i]) ||
3973 !IsValidVariantClearVT(rightvt, ExtraFlags[i]) ||
3974 leftvt == VT_CLSID || rightvt == VT_CLSID ||
3975 leftvt == VT_RECORD || rightvt == VT_RECORD ||
3976 leftvt == VT_VARIANT || rightvt == VT_VARIANT ||
3977 leftvt == VT_ERROR || rightvt == VT_ERROR)
3981 if (leftvt == VT_EMPTY || rightvt == VT_EMPTY)
3983 if (leftvt == rightvt ||
3984 leftvt == VT_I2 || rightvt == VT_I2 ||
3985 leftvt == VT_UI1 || rightvt == VT_UI1 ||
3986 leftvt == VT_BOOL || rightvt == VT_BOOL)
3988 else if (leftvt == VT_NULL || rightvt == VT_NULL)
3990 else if (leftvt == VT_I8 || rightvt == VT_I8)
3993 else if (leftvt == VT_NULL || rightvt == VT_NULL)
3997 else if (leftvt == VT_UI1 || rightvt == VT_UI1)
3999 if (leftvt == rightvt)
4001 else if (leftvt == rightvt ||
4002 leftvt == VT_I2 || rightvt == VT_I2 ||
4003 leftvt == VT_BOOL || rightvt == VT_BOOL)
4007 else if (leftvt == VT_I8 || rightvt == VT_I8)
4010 else if (leftvt == VT_I2 || rightvt == VT_I2)
4012 if (leftvt == rightvt ||
4013 leftvt == VT_BOOL || rightvt == VT_BOOL)
4015 else if (leftvt == VT_I8 || rightvt == VT_I8)
4018 else if (leftvt == VT_BOOL && rightvt == VT_BOOL)
4022 else if (leftvt == VT_I8 || rightvt == VT_I8)
4024 if (leftvt == VT_INT || rightvt == VT_INT)
4029 hres = pVarOr(&left, &right, &result);
4031 ok(hres == DISP_E_TYPEMISMATCH || hres == DISP_E_BADVARTYPE,
4032 "VarOr: %d|0x%X, %d|0x%X: Expected failure, got 0x%X vt %d\n",
4033 leftvt, ExtraFlags[i], rightvt, ExtraFlags[i], hres,
4036 ok(hres == S_OK && V_VT(&result) == resvt,
4037 "VarOr: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%X vt %d\n",
4038 leftvt, ExtraFlags[i], rightvt, ExtraFlags[i], resvt, hres,
4044 /* Test returned values. Since we know the returned type is correct
4045 * and that we handle all combinations of invalid types, just check
4046 * that good type combinations produce the desired value.
4047 * FIXME: Test VT_DECIMAL/VT_DISPATCH
4049 VAROR(EMPTY,0,EMPTY,0,I2,0);
4050 VAROR(EMPTY,1,EMPTY,0,I2,0);
4051 VAROR(EMPTY,0,NULL,0,NULL,0);
4052 VAROR(EMPTY,0,I1,0,I4,0);
4053 VAROR(EMPTY,0,I1,1,I4,1);
4054 VAROR(EMPTY,0,UI1,0,I2,0);
4055 VAROR(EMPTY,0,UI1,1,I2,1);
4056 VAROR(EMPTY,0,I2,0,I2,0);
4057 VAROR(EMPTY,0,I2,1,I2,1);
4058 VAROR(EMPTY,0,UI2,0,I4,0);
4059 VAROR(EMPTY,0,UI2,1,I4,1);
4060 VAROR(EMPTY,0,I4,0,I4,0);
4061 VAROR(EMPTY,0,I4,1,I4,1);
4062 VAROR(EMPTY,0,UI4,0,I4,0);
4063 VAROR(EMPTY,0,UI4,1,I4,1);
4064 if (HAVE_OLEAUT32_I8)
4066 VAROR(EMPTY,0,I8,0,I8,0);
4067 VAROR(EMPTY,0,I8,1,I8,1);
4068 VAROR(EMPTY,0,UI8,0,I4,0);
4069 VAROR(EMPTY,0,UI8,1,I4,1);
4071 VAROR(EMPTY,0,INT,0,I4,0);
4072 VAROR(EMPTY,0,INT,1,I4,1);
4073 VAROR(EMPTY,0,UINT,0,I4,0);
4074 VAROR(EMPTY,0,UINT,1,I4,1);
4075 VAROR(EMPTY,0,BOOL,0,I2,0);
4076 VAROR(EMPTY,0,BOOL,1,I2,1);
4077 VAROR(EMPTY,0,R4,0,I4,0);
4078 VAROR(EMPTY,0,R4,1,I4,1);
4079 VAROR(EMPTY,0,R8,0,I4,0);
4080 VAROR(EMPTY,0,R8,1,I4,1);
4081 rbstr = SysAllocString(szFalse);
4082 VAROR(EMPTY,0,BSTR,rbstr,I2,0);
4083 rbstr = SysAllocString(szTrue);
4084 VAROR(EMPTY,0,BSTR,rbstr,I2,-1);
4085 VARORCY(EMPTY,0,10000,I4,1);
4087 /* NULL OR 0 = NULL. NULL OR n = n */
4088 VAROR(NULL,0,NULL,0,NULL,0);
4089 VAROR(NULL,1,NULL,0,NULL,0);
4090 VAROR(NULL,0,I1,0,NULL,0);
4091 VAROR(NULL,0,I1,1,I4,1);
4092 VAROR(NULL,0,UI1,0,NULL,0);
4093 VAROR(NULL,0,UI1,1,UI1,1);
4094 VAROR(NULL,0,I2,0,NULL,0);
4095 VAROR(NULL,0,I2,1,I2,1);
4096 VAROR(NULL,0,UI2,0,NULL,0);
4097 VAROR(NULL,0,UI2,1,I4,1);
4098 VAROR(NULL,0,I4,0,NULL,0);
4099 VAROR(NULL,0,I4,1,I4,1);
4100 VAROR(NULL,0,UI4,0,NULL,0);
4101 VAROR(NULL,0,UI4,1,I4,1);
4102 if (HAVE_OLEAUT32_I8)
4104 VAROR(NULL,0,I8,0,NULL,0);
4105 VAROR(NULL,0,I8,1,I8,1);
4106 VAROR(NULL,0,UI8,0,NULL,0);
4107 VAROR(NULL,0,UI8,1,I4,1);
4109 VAROR(NULL,0,INT,0,NULL,0);
4110 VAROR(NULL,0,INT,1,I4,1);
4111 VAROR(NULL,0,UINT,0,NULL,0);
4112 VAROR(NULL,0,UINT,1,I4,1);
4113 VAROR(NULL,0,BOOL,0,NULL,0);
4114 VAROR(NULL,0,BOOL,1,BOOL,1);
4115 VAROR(NULL,0,R4,0,NULL,0);
4116 VAROR(NULL,0,R4,1,I4,1);
4117 VAROR(NULL,0,R8,0,NULL,0);
4118 VAROR(NULL,0,R8,1,I4,1);
4119 rbstr = SysAllocString(szFalse);
4120 VAROR(NULL,0,BSTR,rbstr,NULL,0);
4121 rbstr = SysAllocString(szTrue);
4122 VAROR(NULL,0,BSTR,rbstr,BOOL,VARIANT_TRUE);
4123 VARORCY(NULL,0,10000,I4,1);
4124 VARORCY(NULL,0,0,NULL,0);
4126 VAROR(BOOL,VARIANT_TRUE,BOOL,VARIANT_TRUE,BOOL,VARIANT_TRUE);
4127 VAROR(BOOL,VARIANT_TRUE,BOOL,VARIANT_FALSE,BOOL,VARIANT_TRUE);
4128 VAROR(BOOL,VARIANT_FALSE,BOOL,VARIANT_TRUE,BOOL,VARIANT_TRUE);
4129 VAROR(BOOL,VARIANT_FALSE,BOOL,VARIANT_FALSE,BOOL,VARIANT_FALSE);
4130 /* Assume x,y & y,x are the same from now on to reduce the number of tests */
4131 VAROR(BOOL,VARIANT_TRUE,I1,-1,I4,-1);
4132 VAROR(BOOL,VARIANT_TRUE,I1,0,I4,-1);
4133 VAROR(BOOL,VARIANT_FALSE,I1,0,I4,0);
4134 VAROR(BOOL,VARIANT_TRUE,UI1,255,I2,-1);
4135 VAROR(BOOL,VARIANT_TRUE,UI1,0,I2,-1);
4136 VAROR(BOOL,VARIANT_FALSE,UI1,0,I2,0);
4137 VAROR(BOOL,VARIANT_TRUE,I2,-1,I2,-1);
4138 VAROR(BOOL,VARIANT_TRUE,I2,0,I2,-1);
4139 VAROR(BOOL,VARIANT_FALSE,I2,0,I2,0);
4140 VAROR(BOOL,VARIANT_TRUE,UI2,65535,I4,-1);
4141 VAROR(BOOL,VARIANT_TRUE,UI2,0,I4,-1);
4142 VAROR(BOOL,VARIANT_FALSE,UI2,0,I4,0);
4143 VAROR(BOOL,VARIANT_TRUE,I4,-1,I4,-1);
4144 VAROR(BOOL,VARIANT_TRUE,I4,0,I4,-1);
4145 VAROR(BOOL,VARIANT_FALSE,I4,0,I4,0);
4146 VAROR(BOOL,VARIANT_TRUE,UI4,0xffffffff,I4,-1);
4147 VAROR(BOOL,VARIANT_TRUE,UI4,0,I4,-1);
4148 VAROR(BOOL,VARIANT_FALSE,UI4,0,I4,0);
4149 VAROR(BOOL,VARIANT_TRUE,R4,-1,I4,-1);
4150 VAROR(BOOL,VARIANT_TRUE,R4,0,I4,-1);
4151 VAROR(BOOL,VARIANT_FALSE,R4,0,I4,0);
4152 VAROR(BOOL,VARIANT_TRUE,R8,-1,I4,-1);
4153 VAROR(BOOL,VARIANT_TRUE,R8,0,I4,-1);
4154 VAROR(BOOL,VARIANT_FALSE,R8,0,I4,0);
4155 VAROR(BOOL,VARIANT_TRUE,DATE,-1,I4,-1);
4156 VAROR(BOOL,VARIANT_TRUE,DATE,0,I4,-1);
4157 VAROR(BOOL,VARIANT_FALSE,DATE,0,I4,0);
4158 if (HAVE_OLEAUT32_I8)
4160 VAROR(BOOL,VARIANT_TRUE,I8,-1,I8,-1);
4161 VAROR(BOOL,VARIANT_TRUE,I8,0,I8,-1);
4162 VAROR(BOOL,VARIANT_FALSE,I8,0,I8,0);
4163 /* This returns DISP_E_OVERFLOW which indicates that a conversion
4164 * to I4 is performed.
4166 /* VAROR(BOOL,VARIANT_TRUE,UI8,-1,I4,-1); */
4167 VAROR(BOOL,VARIANT_TRUE,UI8,0,I4,-1);
4168 VAROR(BOOL,VARIANT_FALSE,UI8,0,I4,0);
4170 VAROR(BOOL,VARIANT_TRUE,INT,-1,I4,-1);
4171 VAROR(BOOL,VARIANT_TRUE,INT,0,I4,-1);
4172 VAROR(BOOL,VARIANT_FALSE,INT,0,I4,0);
4173 VAROR(BOOL,VARIANT_TRUE,UINT,0xffffffff,I4,-1);
4174 VAROR(BOOL,VARIANT_TRUE,UINT,0,I4,-1);
4175 VAROR(BOOL,VARIANT_FALSE,UINT,0,I4,0);
4176 rbstr = SysAllocString(szFalse);
4177 VAROR(BOOL,VARIANT_FALSE,BSTR,rbstr,BOOL,VARIANT_FALSE);
4178 VAROR(BOOL,VARIANT_TRUE,BSTR,rbstr,BOOL,VARIANT_TRUE);
4179 rbstr = SysAllocString(szTrue);
4180 VAROR(BOOL,VARIANT_FALSE,BSTR,rbstr,BOOL,VARIANT_TRUE);
4181 VAROR(BOOL,VARIANT_TRUE,BSTR,rbstr,BOOL,VARIANT_TRUE);
4182 VARORCY(BOOL,VARIANT_TRUE,10000,I4,-1);
4183 VARORCY(BOOL,VARIANT_TRUE,0,I4,-1);
4184 VARORCY(BOOL,VARIANT_FALSE,0,I4,0);
4186 VAROR(I1,-1,I1,-1,I4,-1);
4187 VAROR(I1,-1,I1,0,I4,-1);
4188 VAROR(I1,0,I1,0,I4,0);
4189 VAROR(I1,-1,UI1,255,I4,-1);
4190 VAROR(I1,-1,UI1,0,I4,-1);
4191 VAROR(I1,0,UI1,0,I4,0);
4192 VAROR(I1,-1,I2,-1,I4,-1);
4193 VAROR(I1,-1,I2,0,I4,-1);
4194 VAROR(I1,0,I2,0,I4,0);
4195 VAROR(I1,-1,UI2,65535,I4,-1);
4196 VAROR(I1,-1,UI2,0,I4,-1);
4197 VAROR(I1,0,UI2,0,I4,0);
4198 VAROR(I1,-1,I4,-1,I4,-1);
4199 VAROR(I1,-1,I4,0,I4,-1);
4200 VAROR(I1,0,I4,0,I4,0);
4201 VAROR(I1,-1,UI4,0xffffffff,I4,-1);
4202 VAROR(I1,-1,UI4,0,I4,-1);
4203 VAROR(I1,0,UI4,0,I4,0);
4204 VAROR(I1,-1,R4,-1,I4,-1);
4205 VAROR(I1,-1,R4,0,I4,-1);
4206 VAROR(I1,0,R4,0,I4,0);
4207 VAROR(I1,-1,R8,-1,I4,-1);
4208 VAROR(I1,-1,R8,0,I4,-1);
4209 VAROR(I1,0,R8,0,I4,0);
4210 VAROR(I1,-1,DATE,-1,I4,-1);
4211 VAROR(I1,-1,DATE,0,I4,-1);
4212 VAROR(I1,0,DATE,0,I4,0);
4213 if (HAVE_OLEAUT32_I8)
4215 VAROR(I1,-1,I8,-1,I8,-1);
4216 VAROR(I1,-1,I8,0,I8,-1);
4217 VAROR(I1,0,I8,0,I8,0);
4218 VAROR(I1,-1,UI8,0,I4,-1);
4219 VAROR(I1,0,UI8,0,I4,0);
4221 VAROR(I1,-1,INT,-1,I4,-1);
4222 VAROR(I1,-1,INT,0,I4,-1);
4223 VAROR(I1,0,INT,0,I4,0);
4224 VAROR(I1,-1,UINT,0xffffffff,I4,-1);
4225 VAROR(I1,-1,UINT,0,I4,-1);
4226 VAROR(I1,0,UINT,0,I4,0);
4227 rbstr = SysAllocString(szFalse);
4228 VAROR(I1,0,BSTR,rbstr,I4,0);
4229 VAROR(I1,-1,BSTR,rbstr,I4,-1);
4230 rbstr = SysAllocString(szTrue);
4231 VAROR(I1,0,BSTR,rbstr,I4,-1);
4232 VAROR(I1,-1,BSTR,rbstr,I4,-1);
4233 VARORCY(I1,-1,10000,I4,-1);
4234 VARORCY(I1,-1,0,I4,-1);
4235 VARORCY(I1,0,0,I4,0);
4237 VAROR(UI1,255,UI1,255,UI1,255);
4238 VAROR(UI1,255,UI1,0,UI1,255);
4239 VAROR(UI1,0,UI1,0,UI1,0);
4240 VAROR(UI1,255,I2,-1,I2,-1);
4241 VAROR(UI1,255,I2,0,I2,255);
4242 VAROR(UI1,0,I2,0,I2,0);
4243 VAROR(UI1,255,UI2,65535,I4,65535);
4244 VAROR(UI1,255,UI2,0,I4,255);
4245 VAROR(UI1,0,UI2,0,I4,0);
4246 VAROR(UI1,255,I4,-1,I4,-1);
4247 VAROR(UI1,255,I4,0,I4,255);
4248 VAROR(UI1,0,I4,0,I4,0);
4249 VAROR(UI1,255,UI4,0xffffffff,I4,-1);
4250 VAROR(UI1,255,UI4,0,I4,255);
4251 VAROR(UI1,0,UI4,0,I4,0);
4252 VAROR(UI1,255,R4,-1,I4,-1);
4253 VAROR(UI1,255,R4,0,I4,255);
4254 VAROR(UI1,0,R4,0,I4,0);
4255 VAROR(UI1,255,R8,-1,I4,-1);
4256 VAROR(UI1,255,R8,0,I4,255);
4257 VAROR(UI1,0,R8,0,I4,0);
4258 VAROR(UI1,255,DATE,-1,I4,-1);
4259 VAROR(UI1,255,DATE,0,I4,255);
4260 VAROR(UI1,0,DATE,0,I4,0);
4261 if (HAVE_OLEAUT32_I8)
4263 VAROR(UI1,255,I8,-1,I8,-1);
4264 VAROR(UI1,255,I8,0,I8,255);
4265 VAROR(UI1,0,I8,0,I8,0);
4266 VAROR(UI1,255,UI8,0,I4,255);
4267 VAROR(UI1,0,UI8,0,I4,0);
4269 VAROR(UI1,255,INT,-1,I4,-1);
4270 VAROR(UI1,255,INT,0,I4,255);
4271 VAROR(UI1,0,INT,0,I4,0);
4272 VAROR(UI1,255,UINT,0xffffffff,I4,-1);
4273 VAROR(UI1,255,UINT,0,I4,255);
4274 VAROR(UI1,0,UINT,0,I4,0);
4275 rbstr = SysAllocString(szFalse);
4276 VAROR(UI1,0,BSTR,rbstr,I2,0);
4277 VAROR(UI1,255,BSTR,rbstr,I2,255);
4278 rbstr = SysAllocString(szTrue);
4279 VAROR(UI1,0,BSTR,rbstr,I2,-1);
4280 VAROR(UI1,255,BSTR,rbstr,I2,-1);
4281 VARORCY(UI1,255,10000,I4,255);
4282 VARORCY(UI1,255,0,I4,255);
4283 VARORCY(UI1,0,0,I4,0);
4285 VAROR(I2,-1,I2,-1,I2,-1);
4286 VAROR(I2,-1,I2,0,I2,-1);
4287 VAROR(I2,0,I2,0,I2,0);
4288 VAROR(I2,-1,UI2,65535,I4,-1);
4289 VAROR(I2,-1,UI2,0,I4,-1);
4290 VAROR(I2,0,UI2,0,I4,0);
4291 VAROR(I2,-1,I4,-1,I4,-1);
4292 VAROR(I2,-1,I4,0,I4,-1);
4293 VAROR(I2,0,I4,0,I4,0);
4294 VAROR(I2,-1,UI4,0xffffffff,I4,-1);
4295 VAROR(I2,-1,UI4,0,I4,-1);
4296 VAROR(I2,0,UI4,0,I4,0);
4297 VAROR(I2,-1,R4,-1,I4,-1);
4298 VAROR(I2,-1,R4,0,I4,-1);
4299 VAROR(I2,0,R4,0,I4,0);
4300 VAROR(I2,-1,R8,-1,I4,-1);
4301 VAROR(I2,-1,R8,0,I4,-1);
4302 VAROR(I2,0,R8,0,I4,0);
4303 VAROR(I2,-1,DATE,-1,I4,-1);
4304 VAROR(I2,-1,DATE,0,I4,-1);
4305 VAROR(I2,0,DATE,0,I4,0);
4306 if (HAVE_OLEAUT32_I8)
4308 VAROR(I2,-1,I8,-1,I8,-1);
4309 VAROR(I2,-1,I8,0,I8,-1);
4310 VAROR(I2,0,I8,0,I8,0);
4311 VAROR(I2,-1,UI8,0,I4,-1);
4312 VAROR(I2,0,UI8,0,I4,0);
4314 VAROR(I2,-1,INT,-1,I4,-1);
4315 VAROR(I2,-1,INT,0,I4,-1);
4316 VAROR(I2,0,INT,0,I4,0);
4317 VAROR(I2,-1,UINT,0xffffffff,I4,-1);
4318 VAROR(I2,-1,UINT,0,I4,-1);
4319 VAROR(I2,0,UINT,0,I4,0);
4320 rbstr = SysAllocString(szFalse);
4321 VAROR(I2,0,BSTR,rbstr,I2,0);
4322 VAROR(I2,-1,BSTR,rbstr,I2,-1);
4323 rbstr = SysAllocString(szTrue);
4324 VAROR(I2,0,BSTR,rbstr,I2,-1);
4325 VAROR(I2,-1,BSTR,rbstr,I2,-1);
4326 VARORCY(I2,-1,10000,I4,-1);
4327 VARORCY(I2,-1,0,I4,-1);
4328 VARORCY(I2,0,0,I4,0);
4330 VAROR(UI2,65535,UI2,65535,I4,65535);
4331 VAROR(UI2,65535,UI2,0,I4,65535);
4332 VAROR(UI2,0,UI2,0,I4,0);
4333 VAROR(UI2,65535,I4,-1,I4,-1);
4334 VAROR(UI2,65535,I4,0,I4,65535);
4335 VAROR(UI2,0,I4,0,I4,0);
4336 VAROR(UI2,65535,UI4,0xffffffff,I4,-1);
4337 VAROR(UI2,65535,UI4,0,I4,65535);
4338 VAROR(UI2,0,UI4,0,I4,0);
4339 VAROR(UI2,65535,R4,-1,I4,-1);
4340 VAROR(UI2,65535,R4,0,I4,65535);
4341 VAROR(UI2,0,R4,0,I4,0);
4342 VAROR(UI2,65535,R8,-1,I4,-1);
4343 VAROR(UI2,65535,R8,0,I4,65535);
4344 VAROR(UI2,0,R8,0,I4,0);
4345 VAROR(UI2,65535,DATE,-1,I4,-1);
4346 VAROR(UI2,65535,DATE,0,I4,65535);
4347 VAROR(UI2,0,DATE,0,I4,0);
4348 if (HAVE_OLEAUT32_I8)
4350 VAROR(UI2,65535,I8,-1,I8,-1);
4351 VAROR(UI2,65535,I8,0,I8,65535);
4352 VAROR(UI2,0,I8,0,I8,0);
4353 VAROR(UI2,65535,UI8,0,I4,65535);
4354 VAROR(UI2,0,UI8,0,I4,0);
4356 VAROR(UI2,65535,INT,-1,I4,-1);
4357 VAROR(UI2,65535,INT,0,I4,65535);
4358 VAROR(UI2,0,INT,0,I4,0);
4359 VAROR(UI2,65535,UINT,0xffffffff,I4,-1);
4360 VAROR(UI2,65535,UINT,0,I4,65535);
4361 VAROR(UI2,0,UINT,0,I4,0);
4362 rbstr = SysAllocString(szFalse);
4363 VAROR(UI2,0,BSTR,rbstr,I4,0);
4364 VAROR(UI2,65535,BSTR,rbstr,I4,65535);
4365 rbstr = SysAllocString(szTrue);
4366 VAROR(UI2,0,BSTR,rbstr,I4,-1);
4367 VAROR(UI2,65535,BSTR,rbstr,I4,-1);
4368 VARORCY(UI2,65535,10000,I4,65535);
4369 VARORCY(UI2,65535,0,I4,65535);
4370 VARORCY(UI2,0,0,I4,0);
4372 VAROR(I4,-1,I4,-1,I4,-1);
4373 VAROR(I4,-1,I4,0,I4,-1);
4374 VAROR(I4,0,I4,0,I4,0);
4375 VAROR(I4,-1,UI4,0xffffffff,I4,-1);
4376 VAROR(I4,-1,UI4,0,I4,-1);
4377 VAROR(I4,0,UI4,0,I4,0);
4378 VAROR(I4,-1,R4,-1,I4,-1);
4379 VAROR(I4,-1,R4,0,I4,-1);
4380 VAROR(I4,0,R4,0,I4,0);
4381 VAROR(I4,-1,R8,-1,I4,-1);
4382 VAROR(I4,-1,R8,0,I4,-1);
4383 VAROR(I4,0,R8,0,I4,0);
4384 VAROR(I4,-1,DATE,-1,I4,-1);
4385 VAROR(I4,-1,DATE,0,I4,-1);
4386 VAROR(I4,0,DATE,0,I4,0);
4387 if (HAVE_OLEAUT32_I8)
4389 VAROR(I4,-1,I8,-1,I8,-1);
4390 VAROR(I4,-1,I8,0,I8,-1);
4391 VAROR(I4,0,I8,0,I8,0);
4392 VAROR(I4,-1,UI8,0,I4,-1);
4393 VAROR(I4,0,UI8,0,I4,0);
4395 VAROR(I4,-1,INT,-1,I4,-1);
4396 VAROR(I4,-1,INT,0,I4,-1);
4397 VAROR(I4,0,INT,0,I4,0);
4398 VAROR(I4,-1,UINT,0xffffffff,I4,-1);
4399 VAROR(I4,-1,UINT,0,I4,-1);
4400 VAROR(I4,0,UINT,0,I4,0);
4401 rbstr = SysAllocString(szFalse);
4402 VAROR(I4,0,BSTR,rbstr,I4,0);
4403 VAROR(I4,-1,BSTR,rbstr,I4,-1);
4404 rbstr = SysAllocString(szTrue);
4405 VAROR(I4,0,BSTR,rbstr,I4,-1);
4406 VAROR(I4,-1,BSTR,rbstr,I4,-1);
4407 VARORCY(I4,-1,10000,I4,-1);
4408 VARORCY(I4,-1,0,I4,-1);
4409 VARORCY(I4,0,0,I4,0);
4411 VAROR(UI4,0xffffffff,UI4,0xffffffff,I4,-1);
4412 VAROR(UI4,0xffffffff,UI4,0,I4,-1);
4413 VAROR(UI4,0,UI4,0,I4,0);
4414 VAROR(UI4,0xffffffff,R4,-1,I4,-1);
4415 VAROR(UI4,0xffffffff,R4,0,I4,-1);
4416 VAROR(UI4,0,R4,0,I4,0);
4417 VAROR(UI4,0xffffffff,R8,-1,I4,-1);
4418 VAROR(UI4,0xffffffff,R8,0,I4,-1);
4419 VAROR(UI4,0,R8,0,I4,0);
4420 VAROR(UI4,0xffffffff,DATE,-1,I4,-1);
4421 VAROR(UI4,0xffffffff,DATE,0,I4,-1);
4422 VAROR(UI4,0,DATE,0,I4,0);
4423 if (HAVE_OLEAUT32_I8)
4425 VAROR(UI4,0xffffffff,I8,-1,I8,-1);
4426 VAROR(UI4,0xffffffff,I8,0,I8,0xffffffff);
4427 VAROR(UI4,0,I8,0,I8,0);
4428 VAROR(UI4,0xffffffff,UI8,0,I4,-1);
4429 VAROR(UI4,0,UI8,0,I4,0);
4431 VAROR(UI4,0xffffffff,INT,-1,I4,-1);
4432 VAROR(UI4,0xffffffff,INT,0,I4,-1);
4433 VAROR(UI4,0,INT,0,I4,0);
4434 VAROR(UI4,0xffffffff,UINT,0xffffffff,I4,-1);
4435 VAROR(UI4,0xffffffff,UINT,0,I4,-1);
4436 VAROR(UI4,0,UINT,0,I4,0);
4437 rbstr = SysAllocString(szFalse);
4438 VAROR(UI4,0,BSTR,rbstr,I4,0);
4439 VAROR(UI4,0xffffffff,BSTR,rbstr,I4,-1);
4440 rbstr = SysAllocString(szTrue);
4441 VAROR(UI4,0,BSTR,rbstr,I4,-1);
4442 VAROR(UI4,0xffffffff,BSTR,rbstr,I4,-1);
4443 VARORCY(UI4,0xffffffff,10000,I4,-1);
4444 VARORCY(UI4,0xffffffff,0,I4,-1);
4445 VARORCY(UI4,0,0,I4,0);
4447 VAROR(R4,-1,R4,-1,I4,-1);
4448 VAROR(R4,-1,R4,0,I4,-1);
4449 VAROR(R4,0,R4,0,I4,0);
4450 VAROR(R4,-1,R8,-1,I4,-1);
4451 VAROR(R4,-1,R8,0,I4,-1);
4452 VAROR(R4,0,R8,0,I4,0);
4453 VAROR(R4,-1,DATE,-1,I4,-1);
4454 VAROR(R4,-1,DATE,0,I4,-1);
4455 VAROR(R4,0,DATE,0,I4,0);
4456 if (HAVE_OLEAUT32_I8)
4458 VAROR(R4,-1,I8,-1,I8,-1);
4459 VAROR(R4,-1,I8,0,I8,-1);
4460 VAROR(R4,0,I8,0,I8,0);
4461 VAROR(R4,-1,UI8,0,I4,-1);
4462 VAROR(R4,0,UI8,0,I4,0);
4464 VAROR(R4,-1,INT,-1,I4,-1);
4465 VAROR(R4,-1,INT,0,I4,-1);
4466 VAROR(R4,0,INT,0,I4,0);
4467 VAROR(R4,-1,UINT,0xffffffff,I4,-1);
4468 VAROR(R4,-1,UINT,0,I4,-1);
4469 VAROR(R4,0,UINT,0,I4,0);
4470 rbstr = SysAllocString(szFalse);
4471 VAROR(R4,0,BSTR,rbstr,I4,0);
4472 VAROR(R4,-1,BSTR,rbstr,I4,-1);
4473 rbstr = SysAllocString(szTrue);
4474 VAROR(R4,0,BSTR,rbstr,I4,-1);
4475 VAROR(R4,-1,BSTR,rbstr,I4,-1);
4476 VARORCY(R4,-1,10000,I4,-1);
4477 VARORCY(R4,-1,0,I4,-1);
4478 VARORCY(R4,0,0,I4,0);
4480 VAROR(R8,-1,R8,-1,I4,-1);
4481 VAROR(R8,-1,R8,0,I4,-1);
4482 VAROR(R8,0,R8,0,I4,0);
4483 VAROR(R8,-1,DATE,-1,I4,-1);
4484 VAROR(R8,-1,DATE,0,I4,-1);
4485 VAROR(R8,0,DATE,0,I4,0);
4486 if (HAVE_OLEAUT32_I8)
4488 VAROR(R8,-1,I8,-1,I8,-1);
4489 VAROR(R8,-1,I8,0,I8,-1);
4490 VAROR(R8,0,I8,0,I8,0);
4491 VAROR(R8,-1,UI8,0,I4,-1);
4492 VAROR(R8,0,UI8,0,I4,0);
4494 VAROR(R8,-1,INT,-1,I4,-1);
4495 VAROR(R8,-1,INT,0,I4,-1);
4496 VAROR(R8,0,INT,0,I4,0);
4497 VAROR(R8,-1,UINT,0xffffffff,I4,-1);
4498 VAROR(R8,-1,UINT,0,I4,-1);
4499 VAROR(R8,0,UINT,0,I4,0);
4500 rbstr = SysAllocString(szFalse);
4501 VAROR(R8,0,BSTR,rbstr,I4,0);
4502 VAROR(R8,-1,BSTR,rbstr,I4,-1);
4503 rbstr = SysAllocString(szTrue);
4504 VAROR(R8,0,BSTR,rbstr,I4,-1);
4505 VAROR(R8,-1,BSTR,rbstr,I4,-1);
4506 VARORCY(R8,-1,10000,I4,-1);
4507 VARORCY(R8,-1,0,I4,-1);
4508 VARORCY(R8,0,0,I4,0);
4510 VAROR(DATE,-1,DATE,-1,I4,-1);
4511 VAROR(DATE,-1,DATE,0,I4,-1);
4512 VAROR(DATE,0,DATE,0,I4,0);
4513 if (HAVE_OLEAUT32_I8)
4515 VAROR(DATE,-1,I8,-1,I8,-1);
4516 VAROR(DATE,-1,I8,0,I8,-1);
4517 VAROR(DATE,0,I8,0,I8,0);
4518 VAROR(DATE,-1,UI8,0,I4,-1);
4519 VAROR(DATE,0,UI8,0,I4,0);
4521 VAROR(DATE,-1,INT,-1,I4,-1);
4522 VAROR(DATE,-1,INT,0,I4,-1);
4523 VAROR(DATE,0,INT,0,I4,0);
4524 VAROR(DATE,-1,UINT,0xffffffff,I4,-1);
4525 VAROR(DATE,-1,UINT,0,I4,-1);
4526 VAROR(DATE,0,UINT,0,I4,0);
4527 rbstr = SysAllocString(szFalse);
4528 VAROR(DATE,0,BSTR,rbstr,I4,0);
4529 VAROR(DATE,-1,BSTR,rbstr,I4,-1);
4530 rbstr = SysAllocString(szTrue);
4531 VAROR(DATE,0,BSTR,rbstr,I4,-1);
4532 VAROR(DATE,-1,BSTR,rbstr,I4,-1);
4533 VARORCY(DATE,-1,10000,I4,-1);
4534 VARORCY(DATE,-1,0,I4,-1);
4535 VARORCY(DATE,0,0,I4,0);
4537 if (HAVE_OLEAUT32_I8)
4539 VAROR(I8,-1,I8,-1,I8,-1);
4540 VAROR(I8,-1,I8,0,I8,-1);
4541 VAROR(I8,0,I8,0,I8,0);
4542 VAROR(I8,-1,UI8,0,I8,-1);
4543 VAROR(I8,0,UI8,0,I8,0);
4544 /* These overflow under native and Wine
4545 VAROR(I8,-1,INT,-1,I4,-1);
4546 VAROR(I8,-1,INT,0,I4,-1);
4547 VAROR(I8,0,INT,0,I4,0); */
4548 VAROR(I8,-1,UINT,0xffffffff,I8,-1);
4549 VAROR(I8,-1,UINT,0,I8,-1);
4550 VAROR(I8,0,UINT,0,I8,0);
4551 rbstr = SysAllocString(szFalse);
4552 VAROR(I8,0,BSTR,rbstr,I8,0);
4553 VAROR(I8,-1,BSTR,rbstr,I8,-1);
4554 rbstr = SysAllocString(szTrue);
4555 VAROR(I8,0,BSTR,rbstr,I8,-1);
4556 VAROR(I8,-1,BSTR,rbstr,I8,-1);
4557 VARORCY(I8,-1,10000,I8,-1);
4558 VARORCY(I8,-1,0,I8,-1);
4559 VARORCY(I8,0,0,I8,0);
4561 VAROR(UI8,0xffff,UI8,0xffff,I4,0xffff);
4562 VAROR(UI8,0xffff,UI8,0,I4,0xffff);
4563 VAROR(UI8,0,UI8,0,I4,0);
4564 VAROR(UI8,0xffff,INT,-1,I4,-1);
4565 VAROR(UI8,0xffff,INT,0,I4,0xffff);
4566 VAROR(UI8,0,INT,0,I4,0);
4567 VAROR(UI8,0xffff,UINT,0xffff,I4,0xffff);
4568 VAROR(UI8,0xffff,UINT,0,I4,0xffff);
4569 VAROR(UI8,0,UINT,0,I4,0);
4570 rbstr = SysAllocString(szFalse);
4571 VAROR(UI8,0,BSTR,rbstr,I4,0);
4572 VAROR(UI8,0xffff,BSTR,rbstr,I4,0xffff);
4573 rbstr = SysAllocString(szTrue);
4574 VAROR(UI8,0,BSTR,rbstr,I4,-1);
4575 VAROR(UI8,0xffff,BSTR,rbstr,I4,-1);
4576 VARORCY(UI8,0xffff,10000,I4,0xffff);
4577 VARORCY(UI8,0xffff,0,I4,0xffff);
4578 VARORCY(UI8,0,0,I4,0);
4581 VAROR(INT,-1,INT,-1,I4,-1);
4582 VAROR(INT,-1,INT,0,I4,-1);
4583 VAROR(INT,0,INT,0,I4,0);
4584 VAROR(INT,-1,UINT,0xffff,I4,-1);
4585 VAROR(INT,-1,UINT,0,I4,-1);
4586 VAROR(INT,0,UINT,0,I4,0);
4587 rbstr = SysAllocString(szFalse);
4588 VAROR(INT,0,BSTR,rbstr,I4,0);
4589 VAROR(INT,-1,BSTR,rbstr,I4,-1);
4590 rbstr = SysAllocString(szTrue);
4591 VAROR(INT,0,BSTR,rbstr,I4,-1);
4592 VAROR(INT,-1,BSTR,rbstr,I4,-1);
4593 VARORCY(INT,-1,10000,I4,-1);
4594 VARORCY(INT,-1,0,I4,-1);
4595 VARORCY(INT,0,0,I4,0);
4597 VAROR(UINT,0xffff,UINT,0xffff,I4,0xffff);
4598 VAROR(UINT,0xffff,UINT,0,I4,0xffff);
4599 VAROR(UINT,0,UINT,0,I4,0);
4600 rbstr = SysAllocString(szFalse);
4601 VAROR(UINT,0,BSTR,rbstr,I4,0);
4602 VAROR(UINT,0xffff,BSTR,rbstr,I4,0xffff);
4603 rbstr = SysAllocString(szTrue);
4604 VAROR(UINT,0,BSTR,rbstr,I4,-1);
4605 VAROR(UINT,0xffff,BSTR,rbstr,I4,-1);
4606 VARORCY(UINT,0xffff,10000,I4,0xffff);
4607 VARORCY(UINT,0xffff,0,I4,0xffff);
4608 VARORCY(UINT,0,0,I4,0);
4610 lbstr = SysAllocString(szFalse);
4611 rbstr = SysAllocString(szFalse);
4612 VAROR(BSTR,lbstr,BSTR,rbstr,BOOL,0);
4613 rbstr = SysAllocString(szTrue);
4614 VAROR(BSTR,lbstr,BSTR,rbstr,BOOL,VARIANT_TRUE);
4615 lbstr = SysAllocString(szTrue);
4616 VAROR(BSTR,lbstr,BSTR,rbstr,BOOL,VARIANT_TRUE);
4617 VARORCY(BSTR,lbstr,10000,I4,-1);
4618 lbstr = SysAllocString(szFalse);
4619 VARORCY(BSTR,lbstr,10000,I4,1);
4622 static HRESULT (WINAPI *pVarEqv)(LPVARIANT,LPVARIANT,LPVARIANT);
4624 #define VAREQV(vt1,val1,vt2,val2,rvt,rval) \
4625 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
4626 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
4627 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
4628 test_var_call2( __LINE__, pVarEqv, &left, &right, &exp )
4630 static void test_VarEqv(void)
4632 VARIANT left, right, exp, result;
4638 /* Test all possible flag/vt combinations & the resulting vt type */
4639 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
4641 VARTYPE leftvt, rightvt, resvt;
4643 for (leftvt = 0; leftvt <= VT_BSTR_BLOB; leftvt++)
4647 for (rightvt = 0; rightvt <= VT_BSTR_BLOB; rightvt++)
4653 if (leftvt == VT_BSTR || rightvt == VT_BSTR ||
4654 leftvt == VT_DISPATCH || rightvt == VT_DISPATCH ||
4655 leftvt == VT_UNKNOWN || rightvt == VT_UNKNOWN)
4658 memset(&left, 0, sizeof(left));
4659 memset(&right, 0, sizeof(right));
4660 V_VT(&left) = leftvt | ExtraFlags[i];
4661 V_VT(&right) = rightvt | ExtraFlags[i];
4662 V_VT(&result) = VT_EMPTY;
4665 if (ExtraFlags[i] & VT_ARRAY || ExtraFlags[i] & VT_BYREF ||
4666 !IsValidVariantClearVT(leftvt, ExtraFlags[i]) ||
4667 !IsValidVariantClearVT(rightvt, ExtraFlags[i]) ||
4668 leftvt == VT_CLSID || rightvt == VT_CLSID ||
4669 leftvt == VT_RECORD || rightvt == VT_RECORD ||
4670 leftvt == VT_VARIANT || rightvt == VT_VARIANT ||
4671 leftvt == VT_ERROR || rightvt == VT_ERROR)
4675 if (leftvt == VT_EMPTY || rightvt == VT_EMPTY)
4677 if (leftvt == rightvt ||
4678 leftvt == VT_I2 || rightvt == VT_I2 ||
4679 leftvt == VT_UI1 || rightvt == VT_UI1 ||
4680 leftvt == VT_BOOL || rightvt == VT_BOOL)
4682 else if (leftvt == VT_NULL || rightvt == VT_NULL)
4684 else if (leftvt == VT_I8 || rightvt == VT_I8)
4687 else if (leftvt == VT_NULL || rightvt == VT_NULL)
4691 else if (leftvt == VT_UI1 || rightvt == VT_UI1)
4693 if (leftvt == rightvt)
4695 else if (leftvt == rightvt ||
4696 leftvt == VT_I2 || rightvt == VT_I2 ||
4697 leftvt == VT_BOOL || rightvt == VT_BOOL)
4701 else if (leftvt == VT_I8 || rightvt == VT_I8)
4704 else if (leftvt == VT_I2 || rightvt == VT_I2)
4706 if (leftvt == rightvt ||
4707 leftvt == VT_BOOL || rightvt == VT_BOOL)
4709 else if (leftvt == VT_I8 || rightvt == VT_I8)
4712 else if (leftvt == VT_BOOL && rightvt == VT_BOOL)
4716 else if (leftvt == VT_I8 || rightvt == VT_I8)
4718 if (leftvt == VT_INT || rightvt == VT_INT)
4723 hres = pVarEqv(&left, &right, &result);
4725 ok(hres == DISP_E_TYPEMISMATCH || hres == DISP_E_BADVARTYPE,
4726 "VarEqv: %d|0x%X, %d|0x%X: Expected failure, got 0x%X vt %d\n",
4727 leftvt, ExtraFlags[i], rightvt, ExtraFlags[i], hres,
4730 ok(hres == S_OK && V_VT(&result) == resvt,
4731 "VarEqv: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%X vt %d\n",
4732 leftvt, ExtraFlags[i], rightvt, ExtraFlags[i], resvt, hres,
4738 /* Test returned values */
4739 VAREQV(BOOL,VARIANT_TRUE,BOOL,VARIANT_TRUE,BOOL,VARIANT_TRUE);
4740 VAREQV(BOOL,VARIANT_FALSE,BOOL,VARIANT_TRUE,BOOL,VARIANT_FALSE);
4741 VAREQV(BOOL,TRUE,BOOL,TRUE,BOOL,VARIANT_TRUE);
4742 VAREQV(BOOL,FALSE,BOOL,FALSE,BOOL,VARIANT_TRUE);
4743 VAREQV(BOOL,TRUE,BOOL,FALSE,BOOL,-2);
4744 VAREQV(BOOL,FALSE,BOOL,TRUE,BOOL,-2);
4745 VAREQV(BOOL,6,BOOL,7,BOOL,-2);
4746 VAREQV(BOOL,6,BOOL,6,BOOL,VARIANT_TRUE);
4747 VAREQV(BOOL,VARIANT_TRUE,I2,VARIANT_TRUE,I2,VARIANT_TRUE);
4748 VAREQV(BOOL,VARIANT_TRUE,I2,VARIANT_FALSE,I2,VARIANT_FALSE);
4749 VAREQV(BOOL,6,I2,7,I2,-2);
4750 VAREQV(UI1,1,UI1,1,UI1,255);
4751 VAREQV(UI1,1,UI1,0,UI1,254);
4752 VAREQV(UI1,0,UI1,1,UI1,254);
4753 if (HAVE_OLEAUT32_I8)
4755 VAREQV(UI4,VARIANT_FALSE,I8,VARIANT_FALSE,I8,-1);
4756 VAREQV(UI4,5,I8,19,I8,-23);
4757 VAREQV(UI4,VARIANT_FALSE,UI8,VARIANT_FALSE,I4,-1);
4761 static HRESULT (WINAPI *pVarMul)(LPVARIANT,LPVARIANT,LPVARIANT);
4763 #define VARMUL(vt1,val1,vt2,val2,rvt,rval) \
4764 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
4765 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
4766 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
4767 test_var_call2( __LINE__, pVarMul, &left, &right, &exp )
4769 static void test_VarMul(void)
4771 static const WCHAR sz12[] = {'1','2','\0'};
4772 VARIANT left, right, exp, result, cy, dec;
4780 lbstr = SysAllocString(sz12);
4781 rbstr = SysAllocString(sz12);
4783 /* Test all possible flag/vt combinations & the resulting vt type */
4784 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
4786 VARTYPE leftvt, rightvt, resvt;
4788 for (leftvt = 0; leftvt <= VT_BSTR_BLOB; leftvt++)
4793 for (rightvt = 0; rightvt <= VT_BSTR_BLOB; rightvt++)
4799 if (leftvt == VT_DISPATCH || rightvt == VT_DISPATCH ||
4800 leftvt == VT_UNKNOWN || rightvt == VT_UNKNOWN)
4803 memset(&left, 0, sizeof(left));
4804 memset(&right, 0, sizeof(right));
4805 V_VT(&left) = leftvt | ExtraFlags[i];
4806 if (leftvt == VT_BSTR)
4807 V_BSTR(&left) = lbstr;
4808 V_VT(&right) = rightvt | ExtraFlags[i];
4809 if (rightvt == VT_BSTR)
4810 V_BSTR(&right) = rbstr;
4811 V_VT(&result) = VT_EMPTY;
4814 /* Don't ask me why but native VarMul cannot handle:
4815 VT_I1, VT_UI2, VT_UI4, VT_INT, VT_UINT and VT_UI8.
4816 Tested with DCOM98, Win2k, WinXP */
4817 if (ExtraFlags[i] & VT_ARRAY || ExtraFlags[i] & VT_BYREF ||
4818 !IsValidVariantClearVT(leftvt, ExtraFlags[i]) ||
4819 !IsValidVariantClearVT(rightvt, ExtraFlags[i]) ||
4820 leftvt == VT_CLSID || rightvt == VT_CLSID ||
4821 leftvt == VT_RECORD || rightvt == VT_RECORD ||
4822 leftvt == VT_VARIANT || rightvt == VT_VARIANT ||
4823 leftvt == VT_ERROR || rightvt == VT_ERROR ||
4824 leftvt == VT_I1 || rightvt == VT_I1 ||
4825 leftvt == VT_UI2 || rightvt == VT_UI2 ||
4826 leftvt == VT_UI4 || rightvt == VT_UI4 ||
4827 leftvt == VT_UI8 || rightvt == VT_UI8 ||
4828 leftvt == VT_INT || rightvt == VT_INT ||
4829 leftvt == VT_UINT || rightvt == VT_UINT) {
4833 if (leftvt == VT_NULL || rightvt == VT_NULL)
4835 else if (leftvt == VT_DECIMAL || rightvt == VT_DECIMAL)
4837 else if (leftvt == VT_R8 || rightvt == VT_R8 ||
4838 leftvt == VT_BSTR || rightvt == VT_BSTR ||
4839 leftvt == VT_DATE || rightvt == VT_DATE)
4841 else if (leftvt == VT_R4 || rightvt == VT_R4) {
4842 if (leftvt == VT_I4 || rightvt == VT_I4 ||
4843 leftvt == VT_I8 || rightvt == VT_I8 ||
4844 leftvt == VT_CY || rightvt == VT_CY)
4848 } else if (leftvt == VT_CY || rightvt == VT_CY)
4850 else if (leftvt == VT_I8 || rightvt == VT_I8)
4852 else if (leftvt == VT_I4 || rightvt == VT_I4)
4854 else if (leftvt == VT_I2 || rightvt == VT_I2 ||
4855 leftvt == VT_BOOL || rightvt == VT_BOOL ||
4856 (leftvt == VT_EMPTY && rightvt == VT_EMPTY))
4858 else if (leftvt == VT_UI1 || rightvt == VT_UI1)
4861 hres = pVarMul(&left, &right, &result);
4863 ok(hres == DISP_E_TYPEMISMATCH || hres == DISP_E_BADVARTYPE,
4864 "VarMul: %d|0x%X, %d|0x%X: Expected failure, got 0x%X vt %d\n",
4865 leftvt, ExtraFlags[i], rightvt, ExtraFlags[i], hres,
4868 ok(hres == S_OK && V_VT(&result) == resvt,
4869 "VarMul: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%X vt %d\n",
4870 leftvt, ExtraFlags[i], rightvt, ExtraFlags[i], resvt, hres,
4877 /* Test returned values */
4878 VARMUL(I4,4,I4,2,I4,8);
4879 VARMUL(I2,4,I2,2,I2,8);
4880 VARMUL(I2,-13,I4,5,I4,-65);
4881 VARMUL(I4,-13,I4,5,I4,-65);
4882 VARMUL(I2,7,R4,0.5f,R4,3.5f);
4883 VARMUL(R4,0.5f,I4,5,R8,2.5);
4884 VARMUL(R8,7.1,BOOL,0,R8,0);
4885 VARMUL(BSTR,lbstr,I2,4,R8,48);
4886 VARMUL(BSTR,lbstr,BOOL,1,R8,12);
4887 VARMUL(BSTR,lbstr,R4,0.1f,R8,1.2);
4888 VARMUL(BSTR,lbstr,BSTR,rbstr,R8,144);
4889 VARMUL(R4,0.2f,BSTR,rbstr,R8,2.4);
4890 VARMUL(DATE,2.25,I4,7,R8,15.75);
4892 VARMUL(UI1, UI1_MAX, UI1, UI1_MAX, I4, UI1_MAX * UI1_MAX);
4893 VARMUL(I2, I2_MAX, I2, I2_MAX, I4, I2_MAX * I2_MAX);
4894 VARMUL(I2, I2_MAX, I2, I2_MIN, I4, I2_MAX * I2_MIN);
4895 VARMUL(I2, I2_MIN, I2, I2_MIN, I4, I2_MIN * I2_MIN);
4896 VARMUL(I4, I4_MAX, I4, I4_MAX, R8, (double)I4_MAX * I4_MAX);
4897 VARMUL(I4, I4_MAX, I4, I4_MIN, R8, (double)I4_MAX * I4_MIN);
4898 VARMUL(I4, I4_MIN, I4, I4_MIN, R8, (double)I4_MIN * I4_MIN);
4899 VARMUL(R4, R4_MAX, R4, R4_MAX, R8, (double)R4_MAX * R4_MAX);
4900 VARMUL(R4, R4_MAX, R4, R4_MIN, R4, R4_MAX * R4_MIN);
4901 VARMUL(R4, R4_MIN, R4, R4_MIN, R4, R4_MIN * R4_MIN);
4902 VARMUL(R8, R8_MAX, R8, R8_MIN, R8, R8_MAX * R8_MIN);
4903 VARMUL(R8, R8_MIN, R8, R8_MIN, R8, R8_MIN * R8_MIN);
4905 /* Manuly test some VT_CY and VT_DECIMAL variants */
4907 hres = VarCyFromI4(4711, &V_CY(&cy));
4908 ok(hres == S_OK, "VarCyFromI4 failed!\n");
4909 V_VT(&dec) = VT_DECIMAL;
4910 hres = VarDecFromR8(-4.2, &V_DECIMAL(&dec));
4911 ok(hres == S_OK, "VarDecFromR4 failed!\n");
4912 memset(&left, 0, sizeof(left));
4913 memset(&right, 0, sizeof(right));
4914 V_VT(&left) = VT_I4;
4916 V_VT(&right) = VT_UI1;
4919 hres = VarMul(&cy, &right, &result);
4920 ok(hres == S_OK && V_VT(&result) == VT_CY, "VarMul: expected coerced type VT_CY, got %s!\n", vtstr(V_VT(&result)));
4921 hres = VarR8FromCy(V_CY(&result), &r);
4922 ok(hres == S_OK && EQ_DOUBLE(r, 42399), "VarMul: CY value %f, expected %f\n", r, (double)42399);
4924 hres = VarMul(&left, &dec, &result);
4925 ok(hres == S_OK && V_VT(&result) == VT_DECIMAL, "VarMul: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result)));
4926 hres = VarR8FromDec(&V_DECIMAL(&result), &r);
4927 ok(hres == S_OK && EQ_DOUBLE(r, 46.2), "VarMul: DECIMAL value %f, expected %f\n", r, (double)46.2);
4929 SysFreeString(lbstr);
4930 SysFreeString(rbstr);
4933 static HRESULT (WINAPI *pVarAdd)(LPVARIANT,LPVARIANT,LPVARIANT);
4935 #define VARADD(vt1,val1,vt2,val2,rvt,rval) \
4936 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
4937 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
4938 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
4939 test_var_call2( __LINE__, pVarAdd, &left, &right, &exp )
4941 static void test_VarAdd(void)
4943 static const WCHAR sz12[] = {'1','2','\0'};
4944 VARIANT left, right, exp, result, cy, dec;
4952 lbstr = SysAllocString(sz12);
4953 rbstr = SysAllocString(sz12);
4955 /* Test all possible flag/vt combinations & the resulting vt type */
4956 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
4958 VARTYPE leftvt, rightvt, resvt;
4960 for (leftvt = 0; leftvt <= VT_BSTR_BLOB; leftvt++)
4965 for (rightvt = 0; rightvt <= VT_BSTR_BLOB; rightvt++)
4971 if (leftvt == VT_UNKNOWN || rightvt == VT_UNKNOWN)
4974 memset(&left, 0, sizeof(left));
4975 memset(&right, 0, sizeof(right));
4976 V_VT(&left) = leftvt | ExtraFlags[i];
4977 if (leftvt == VT_BSTR)
4978 V_BSTR(&left) = lbstr;
4979 V_VT(&right) = rightvt | ExtraFlags[i];
4980 if (rightvt == VT_BSTR)
4981 V_BSTR(&right) = rbstr;
4982 V_VT(&result) = VT_EMPTY;
4985 /* Don't ask me why but native VarAdd cannot handle:
4986 VT_I1, VT_UI2, VT_UI4, VT_INT, VT_UINT and VT_UI8.
4987 Tested with DCOM98, Win2k, WinXP */
4988 if (ExtraFlags[i] & VT_ARRAY || ExtraFlags[i] & VT_BYREF ||
4989 !IsValidVariantClearVT(leftvt, ExtraFlags[i]) ||
4990 !IsValidVariantClearVT(rightvt, ExtraFlags[i]) ||
4991 leftvt == VT_CLSID || rightvt == VT_CLSID ||
4992 leftvt == VT_RECORD || rightvt == VT_RECORD ||
4993 leftvt == VT_VARIANT || rightvt == VT_VARIANT ||
4994 leftvt == VT_ERROR || rightvt == VT_ERROR ||
4995 leftvt == VT_I1 || rightvt == VT_I1 ||
4996 leftvt == VT_UI2 || rightvt == VT_UI2 ||
4997 leftvt == VT_UI4 || rightvt == VT_UI4 ||
4998 leftvt == VT_UI8 || rightvt == VT_UI8 ||
4999 leftvt == VT_INT || rightvt == VT_INT ||
5000 leftvt == VT_UINT || rightvt == VT_UINT) {
5004 if (leftvt == VT_NULL || rightvt == VT_NULL)
5006 else if (leftvt == VT_DISPATCH || rightvt == VT_DISPATCH)
5008 else if (leftvt == VT_DECIMAL || rightvt == VT_DECIMAL)
5010 else if (leftvt == VT_DATE || rightvt == VT_DATE)
5012 else if (leftvt == VT_CY || rightvt == VT_CY)
5014 else if (leftvt == VT_R8 || rightvt == VT_R8)
5016 else if (leftvt == VT_BSTR || rightvt == VT_BSTR) {
5017 if ((leftvt == VT_BSTR && rightvt == VT_BSTR) ||
5018 leftvt == VT_EMPTY || rightvt == VT_EMPTY)
5022 } else if (leftvt == VT_R4 || rightvt == VT_R4) {
5023 if (leftvt == VT_I4 || rightvt == VT_I4 ||
5024 leftvt == VT_I8 || rightvt == VT_I8)
5029 else if (leftvt == VT_I8 || rightvt == VT_I8)
5031 else if (leftvt == VT_I4 || rightvt == VT_I4)
5033 else if (leftvt == VT_I2 || rightvt == VT_I2 ||
5034 leftvt == VT_BOOL || rightvt == VT_BOOL ||
5035 (leftvt == VT_EMPTY && rightvt == VT_EMPTY))
5037 else if (leftvt == VT_UI1 || rightvt == VT_UI1)
5040 hres = pVarAdd(&left, &right, &result);
5042 ok(hres == DISP_E_TYPEMISMATCH || hres == DISP_E_BADVARTYPE,
5043 "VarAdd: %d|0x%X, %d|0x%X: Expected failure, got 0x%X vt %d\n",
5044 leftvt, ExtraFlags[i], rightvt, ExtraFlags[i], hres,
5047 ok(hres == S_OK && V_VT(&result) == resvt,
5048 "VarAdd: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%X vt %d\n",
5049 leftvt, ExtraFlags[i], rightvt, ExtraFlags[i], resvt, hres,
5056 /* Test returned values */
5057 VARADD(I4,4,I4,2,I4,6);
5058 VARADD(I2,4,I2,2,I2,6);
5059 VARADD(I2,-13,I4,5,I4,-8);
5060 VARADD(I4,-13,I4,5,I4,-8);
5061 VARADD(I2,7,R4,0.5f,R4,7.5f);
5062 VARADD(R4,0.5f,I4,5,R8,5.5);
5063 VARADD(R8,7.1,BOOL,0,R8,7.1);
5064 VARADD(BSTR,lbstr,I2,4,R8,16);
5065 VARADD(BSTR,lbstr,BOOL,1,R8,13);
5066 VARADD(BSTR,lbstr,R4,0.1f,R8,12.1);
5067 VARADD(R4,0.2f,BSTR,rbstr,R8,12.2);
5068 VARADD(DATE,2.25,I4,7,DATE,9.25);
5069 VARADD(DATE,1.25,R4,-1.7f,DATE,-0.45);
5071 VARADD(UI1, UI1_MAX, UI1, UI1_MAX, I2, UI1_MAX + UI1_MAX);
5072 VARADD(I2, I2_MAX, I2, I2_MAX, I4, I2_MAX + I2_MAX);
5073 VARADD(I2, I2_MAX, I2, I2_MIN, I2, I2_MAX + I2_MIN);
5074 VARADD(I2, I2_MIN, I2, I2_MIN, I4, I2_MIN + I2_MIN);
5075 VARADD(I4, I4_MAX, I4, I4_MIN, I4, I4_MAX + I4_MIN);
5076 VARADD(I4, I4_MAX, I4, I4_MAX, R8, (double)I4_MAX + I4_MAX);
5077 VARADD(I4, I4_MIN, I4, I4_MIN, R8, (double)I4_MIN + I4_MIN);
5078 VARADD(R4, R4_MAX, R4, R4_MAX, R8, (double)R4_MAX + R4_MAX);
5079 VARADD(R4, R4_MAX, R4, R4_MIN, R4, R4_MAX + R4_MIN);
5080 VARADD(R4, R4_MIN, R4, R4_MIN, R4, R4_MIN + R4_MIN);
5081 VARADD(R8, R8_MAX, R8, R8_MIN, R8, R8_MAX + R8_MIN);
5082 VARADD(R8, R8_MIN, R8, R8_MIN, R8, R8_MIN + R8_MIN);
5084 /* Manually test BSTR + BSTR */
5085 V_VT(&left) = VT_BSTR;
5086 V_BSTR(&left) = lbstr;
5087 V_VT(&right) = VT_BSTR;
5088 V_BSTR(&right) = rbstr;
5089 hres = VarAdd(&left, &right, &result);
5090 ok(hres == S_OK && V_VT(&result) == VT_BSTR, "VarAdd: expected coerced type VT_BSTR, got %s!\n", vtstr(V_VT(&result)));
5091 hres = VarR8FromStr(V_BSTR(&result), 0, 0, &r);
5092 ok(hres == S_OK && EQ_DOUBLE(r, 1212), "VarAdd: BSTR value %f, expected %f\n", r, (double)1212);
5094 /* Manuly test some VT_CY and VT_DECIMAL variants */
5096 hres = VarCyFromI4(4711, &V_CY(&cy));
5097 ok(hres == S_OK, "VarCyFromI4 failed!\n");
5098 V_VT(&dec) = VT_DECIMAL;
5099 hres = VarDecFromR8(-4.2, &V_DECIMAL(&dec));
5100 ok(hres == S_OK, "VarDecFromR4 failed!\n");
5101 memset(&left, 0, sizeof(left));
5102 memset(&right, 0, sizeof(right));
5103 V_VT(&left) = VT_I4;
5105 V_VT(&right) = VT_UI1;
5108 hres = VarAdd(&cy, &right, &result);
5109 ok(hres == S_OK && V_VT(&result) == VT_CY, "VarAdd: expected coerced type VT_CY, got %s!\n", vtstr(V_VT(&result)));
5110 hres = VarR8FromCy(V_CY(&result), &r);
5111 ok(hres == S_OK && EQ_DOUBLE(r, 4720), "VarAdd: CY value %f, expected %f\n", r, (double)4720);
5113 hres = VarAdd(&left, &dec, &result);
5114 ok(hres == S_OK && V_VT(&result) == VT_DECIMAL, "VarAdd: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result)));
5115 hres = VarR8FromDec(&V_DECIMAL(&result), &r);
5116 ok(hres == S_OK && EQ_DOUBLE(r, -15.2), "VarAdd: DECIMAL value %f, expected %f\n", r, (double)-15.2);
5118 SysFreeString(lbstr);
5119 SysFreeString(rbstr);
5122 static void test_VarCat(void)
5125 VARIANT left, right, result, expected;
5126 static const WCHAR sz12[] = {'1','2','\0'};
5127 static const WCHAR sz34[] = {'3','4','\0'};
5128 static const WCHAR sz1234[] = {'1','2','3','4','\0'};
5129 static const WCHAR date_sz12[] = {'9','/','3','0','/','1','9','8','0','1','2','\0'};
5130 static const WCHAR sz12_date[] = {'1','2','9','/','3','0','/','1','9','8','0','\0'};
5131 static const WCHAR sz_empty[] = {'\0'};
5132 static const WCHAR sz12_true[] = {'1','2','T','r','u','e','\0'};
5133 static const WCHAR sz12_false[] = {'1','2','F','a','l','s','e','\0'};
5134 TCHAR orig_date_format[128];
5135 VARTYPE leftvt, rightvt, resultvt;
5137 HRESULT expected_error_num;
5139 /* Set date format for testing */
5140 lcid = LOCALE_USER_DEFAULT;
5141 GetLocaleInfo(lcid,LOCALE_SSHORTDATE,orig_date_format,128);
5142 SetLocaleInfo(lcid,LOCALE_SSHORTDATE,"M/d/yyyy");
5145 VariantInit(&right);
5146 VariantInit(&result);
5147 VariantInit(&expected);
5149 /* Check expected types for all combinations */
5150 for (leftvt = 0; leftvt <= VT_BSTR_BLOB; leftvt++)
5155 /* Check if we need/have support for I8 and/or UI8 */
5156 if ((leftvt == VT_I8 || leftvt == VT_UI8) && !HAVE_OLEAUT32_I8)
5159 for (rightvt = 0; rightvt <= VT_BSTR_BLOB; rightvt++)
5163 expected_error_num = S_OK;
5164 resultvt = VT_EMPTY;
5166 if (leftvt == VT_DISPATCH || rightvt == VT_DISPATCH ||
5167 leftvt == VT_UNKNOWN || rightvt == VT_UNKNOWN ||
5168 leftvt == VT_RECORD || rightvt == VT_RECORD ||
5169 leftvt == 15 || rightvt == 15 /* Undefined type */)
5172 /* Check if we need/have support for I8 and/or UI8 */
5173 if ((rightvt == VT_I8 || rightvt == VT_UI8) && !HAVE_OLEAUT32_I8)
5176 if (leftvt == VT_NULL && rightvt == VT_NULL)
5178 else if (leftvt == VT_VARIANT && (rightvt == VT_ERROR ||
5179 rightvt == VT_DATE || rightvt == VT_DECIMAL))
5180 expected_error_num = DISP_E_TYPEMISMATCH;
5181 else if ((leftvt == VT_I2 || leftvt == VT_I4 ||
5182 leftvt == VT_R4 || leftvt == VT_R8 ||
5183 leftvt == VT_CY || leftvt == VT_BOOL ||
5184 leftvt == VT_BSTR || leftvt == VT_I1 ||
5185 leftvt == VT_UI1 || leftvt == VT_UI2 ||
5186 leftvt == VT_UI4 || leftvt == VT_I8 ||
5187 leftvt == VT_UI8 || leftvt == VT_INT ||
5188 leftvt == VT_UINT || leftvt == VT_EMPTY ||
5189 leftvt == VT_NULL || leftvt == VT_DECIMAL ||
5192 (rightvt == VT_I2 || rightvt == VT_I4 ||
5193 rightvt == VT_R4 || rightvt == VT_R8 ||
5194 rightvt == VT_CY || rightvt == VT_BOOL ||
5195 rightvt == VT_BSTR || rightvt == VT_I1 ||
5196 rightvt == VT_UI1 || rightvt == VT_UI2 ||
5197 rightvt == VT_UI4 || rightvt == VT_I8 ||
5198 rightvt == VT_UI8 || rightvt == VT_INT ||
5199 rightvt == VT_UINT || rightvt == VT_EMPTY ||
5200 rightvt == VT_NULL || rightvt == VT_DECIMAL ||
5201 rightvt == VT_DATE))
5203 else if (rightvt == VT_ERROR && leftvt < VT_VOID)
5204 expected_error_num = DISP_E_TYPEMISMATCH;
5205 else if (leftvt == VT_ERROR && (rightvt == VT_DATE ||
5206 rightvt == VT_ERROR || rightvt == VT_DECIMAL))
5207 expected_error_num = DISP_E_TYPEMISMATCH;
5208 else if (rightvt == VT_DATE || rightvt == VT_ERROR ||
5209 rightvt == VT_DECIMAL)
5210 expected_error_num = DISP_E_BADVARTYPE;
5211 else if (leftvt == VT_ERROR || rightvt == VT_ERROR)
5212 expected_error_num = DISP_E_TYPEMISMATCH;
5213 else if (leftvt == VT_VARIANT)
5214 expected_error_num = DISP_E_TYPEMISMATCH;
5215 else if (rightvt == VT_VARIANT && (leftvt == VT_EMPTY ||
5216 leftvt == VT_NULL || leftvt == VT_I2 ||
5217 leftvt == VT_I4 || leftvt == VT_R4 ||
5218 leftvt == VT_R8 || leftvt == VT_CY ||
5219 leftvt == VT_DATE || leftvt == VT_BSTR ||
5220 leftvt == VT_BOOL || leftvt == VT_DECIMAL ||
5221 leftvt == VT_I1 || leftvt == VT_UI1 ||
5222 leftvt == VT_UI2 || leftvt == VT_UI4 ||
5223 leftvt == VT_I8 || leftvt == VT_UI8 ||
5224 leftvt == VT_INT || leftvt == VT_UINT
5226 expected_error_num = DISP_E_TYPEMISMATCH;
5228 expected_error_num = DISP_E_BADVARTYPE;
5230 V_VT(&left) = leftvt;
5231 V_VT(&right) = rightvt;
5233 if (leftvt == VT_BSTR)
5234 V_BSTR(&left) = SysAllocString(sz_empty);
5235 if (rightvt == VT_BSTR)
5236 V_BSTR(&right) = SysAllocString(sz_empty);
5237 if (leftvt == VT_DATE)
5238 V_DATE(&left) = 0.0;
5239 if (rightvt == VT_DATE)
5240 V_DATE(&right) = 0.0;
5241 if (leftvt == VT_DECIMAL)
5242 VarDecFromR8(0.0, &V_DECIMAL(&left));
5243 if (rightvt == VT_DECIMAL)
5244 VarDecFromR8(0.0, &V_DECIMAL(&right));
5246 hres = VarCat(&left, &right, &result);
5248 /* Determine the error code for the vt combination */
5249 ok(hres == expected_error_num,
5250 "VarCat: %d, %d returned error, 0x%X expected 0x%X.\n",
5251 leftvt, rightvt, expected_error_num, hres);
5253 /* Check types are correct */
5254 ok(V_VT(&result) == resultvt,
5255 "VarCat: %d, %d: expected vt %d, got vt %d\n",
5256 leftvt, rightvt, resultvt, V_VT(&result));
5258 VariantClear(&left);
5259 VariantClear(&right);
5260 VariantClear(&result);
5264 /* Runnning single comparison tests to compare outputs */
5266 /* Test concat strings */
5267 V_VT(&left) = VT_BSTR;
5268 V_VT(&right) = VT_BSTR;
5269 V_VT(&expected) = VT_BSTR;
5270 V_BSTR(&left) = SysAllocString(sz12);
5271 V_BSTR(&right) = SysAllocString(sz34);
5272 V_BSTR(&expected) = SysAllocString(sz1234);
5273 hres = VarCat(&left,&right,&result);
5274 ok(hres == S_OK, "VarCat failed with error 0x%08x\n", hres);
5275 ok(VarCmp(&result,&expected,lcid,0) == VARCMP_EQ,
5276 "VarCat: VT_BSTR concat with VT_BSTR failed to return correct result\n");
5278 VariantClear(&left);
5279 VariantClear(&right);
5280 VariantClear(&result);
5282 /* Test if expression is VT_ERROR */
5283 V_VT(&left) = VT_ERROR;
5284 V_VT(&right) = VT_BSTR;
5285 V_BSTR(&right) = SysAllocString(sz1234);
5286 hres = VarCat(&left,&right,&result);
5287 ok(hres == DISP_E_TYPEMISMATCH, "VarCat should have returned DISP_E_TYPEMISMATCH instead of 0x%08x\n", hres);
5288 ok(V_VT(&result) == VT_EMPTY,
5289 "VarCat: VT_ERROR concat with VT_BSTR should have returned VT_EMPTY\n");
5291 VariantClear(&left);
5292 VariantClear(&right);
5293 VariantClear(&result);
5295 V_VT(&left) = VT_BSTR;
5296 V_VT(&right) = VT_ERROR;
5297 V_BSTR(&left) = SysAllocString(sz1234);
5298 hres = VarCat(&left,&right,&result);
5299 ok(hres == DISP_E_TYPEMISMATCH, "VarCat should have returned DISP_E_TYPEMISMATCH instead of 0x%08x\n", hres);
5300 ok(V_VT(&result) == VT_EMPTY,
5301 "VarCat: VT_BSTR concat with VT_ERROR should have returned VT_EMPTY\n");
5303 VariantClear(&left);
5304 VariantClear(&right);
5305 VariantClear(&result);
5306 VariantClear(&expected);
5308 /* Test combining boolean with number */
5309 V_VT(&left) = VT_INT;
5310 V_VT(&right) = VT_BOOL;
5311 V_VT(&expected) = VT_BSTR;
5313 V_BOOL(&right) = TRUE;
5314 V_BSTR(&expected) = SysAllocString(sz12_true);
5315 hres = VarCat(&left,&right,&result);
5316 ok(hres == S_OK, "VarCat failed with error 0x%08x\n", hres);
5317 ok(VarCmp(&result,&expected,lcid,0) == VARCMP_EQ,
5318 "VarCat: VT_INT concat with VT_BOOL (TRUE) returned incorrect result\n");
5320 VariantClear(&left);
5321 VariantClear(&right);
5322 VariantClear(&result);
5323 VariantClear(&expected);
5325 V_VT(&left) = VT_INT;
5326 V_VT(&right) = VT_BOOL;
5327 V_VT(&expected) = VT_BSTR;
5329 V_BOOL(&right) = FALSE;
5330 V_BSTR(&expected) = SysAllocString(sz12_false);
5331 hres = VarCat(&left,&right,&result);
5332 ok(hres == S_OK, "VarCat failed with error 0x%08x\n", hres);
5333 ok(VarCmp(&result,&expected,lcid,0) == VARCMP_EQ,
5334 "VarCat: VT_INT concat with VT_BOOL (FALSE) returned inncorrect result\n");
5336 VariantClear(&left);
5337 VariantClear(&right);
5338 VariantClear(&result);
5339 VariantClear(&expected);
5341 /* Test when both expressions are numeric */
5342 V_VT(&left) = VT_INT;
5343 V_VT(&right) = VT_INT;
5344 V_VT(&expected) = VT_BSTR;
5347 V_BSTR(&expected) = SysAllocString(sz1234);
5348 hres = VarCat(&left,&right,&result);
5349 ok(hres == S_OK, "VarCat failed with error 0x%08x\n", hres);
5350 ok(VarCmp(&result,&expected,lcid,0) == VARCMP_EQ,
5351 "VarCat: NUMBER concat with NUMBER returned inncorrect result\n");
5353 VariantClear(&left);
5354 VariantClear(&right);
5355 VariantClear(&result);
5357 /* Test if one expression is numeric and the other is a string */
5358 V_VT(&left) = VT_INT;
5359 V_VT(&right) = VT_BSTR;
5361 V_BSTR(&right) = SysAllocString(sz34);
5362 hres = VarCat(&left,&right,&result);
5363 ok(hres == S_OK, "VarCat failed with error 0x%08x\n", hres);
5364 ok(VarCmp(&result,&expected,lcid,0) == VARCMP_EQ,
5365 "VarCat: NUMBER concat with VT_BSTR, inncorrect result\n");
5367 VariantClear(&left);
5368 VariantClear(&right);
5369 VariantClear(&result);
5371 V_VT(&left) = VT_BSTR;
5372 V_VT(&right) = VT_INT;
5373 V_BSTR(&left) = SysAllocString(sz12);
5375 hres = VarCat(&left,&right,&result);
5376 ok(hres == S_OK, "VarCat failed with error 0x%08x\n", hres);
5377 ok(VarCmp(&result,&expected,lcid,0) == VARCMP_EQ,
5378 "VarCat: VT_BSTR concat with NUMBER, inncorrect result\n");
5380 VariantClear(&left);
5381 VariantClear(&right);
5382 VariantClear(&result);
5384 /* Test concat dates with strings */
5385 V_VT(&left) = VT_BSTR;
5386 V_VT(&right) = VT_DATE;
5387 V_VT(&expected) = VT_BSTR;
5388 V_BSTR(&left) = SysAllocString(sz12);
5389 V_DATE(&right) = 29494.0;
5390 V_BSTR(&expected)= SysAllocString(sz12_date);
5391 hres = VarCat(&left,&right,&result);
5392 ok(hres == S_OK, "VarCat failed with error 0x%08x\n", hres);
5393 ok(VarCmp(&result,&expected,lcid,0) == VARCMP_EQ,
5394 "VarCat: VT_BSTR concat with VT_DATE returned inncorrect result\n");
5396 VariantClear(&left);
5397 VariantClear(&right);
5398 VariantClear(&result);
5399 VariantClear(&expected);
5401 V_VT(&left) = VT_DATE;
5402 V_VT(&right) = VT_BSTR;
5403 V_VT(&expected) = VT_BSTR;
5404 V_DATE(&left) = 29494.0;
5405 V_BSTR(&right) = SysAllocString(sz12);
5406 V_BSTR(&expected)= SysAllocString(date_sz12);
5407 hres = VarCat(&left,&right,&result);
5408 ok(hres == S_OK, "VarCat failed with error 0x%08x\n", hres);
5409 ok(VarCmp(&result,&expected,lcid,0) == VARCMP_EQ,
5410 "VarCat: VT_DATE concat with VT_BSTR returned inncorrect result\n");
5412 VariantClear(&left);
5413 VariantClear(&right);
5414 VariantClear(&result);
5415 VariantClear(&expected);
5417 /* Test of both expressions are empty */
5418 V_VT(&left) = VT_BSTR;
5419 V_VT(&right) = VT_BSTR;
5420 V_VT(&expected) = VT_BSTR;
5421 V_BSTR(&left) = SysAllocString(sz_empty);
5422 V_BSTR(&right) = SysAllocString(sz_empty);
5423 V_BSTR(&expected)= SysAllocString(sz_empty);
5424 hres = VarCat(&left,&right,&result);
5425 ok(hres == S_OK, "VarCat failed with error 0x%08x\n", hres);
5426 ok(VarCmp(&result,&left,lcid,0) == VARCMP_EQ,
5427 "VarCat: EMPTY concat with EMPTY did not return empty VT_BSTR\n");
5429 /* Restore original date format settings */
5430 SetLocaleInfo(lcid,LOCALE_SSHORTDATE,orig_date_format);
5432 VariantClear(&left);
5433 VariantClear(&right);
5434 VariantClear(&result);
5435 VariantClear(&expected);
5438 static HRESULT (WINAPI *pVarAnd)(LPVARIANT,LPVARIANT,LPVARIANT);
5440 #define VARAND(vt1,val1,vt2,val2,rvt,rval) \
5441 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
5442 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
5443 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
5444 test_var_call2( __LINE__, pVarAnd, &left, &right, &exp )
5446 #define VARANDCY(vt1,val1,val2,rvt,rval) \
5447 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
5448 V_VT(&right) = VT_CY; V_CY(&right).int64 = val2; \
5449 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
5450 test_var_call2( __LINE__, pVarAnd, &left, &right, &exp )
5452 /* Skip any type that is not defined or produces an error for every case */
5453 #define SKIPTESTAND(a) \
5454 if (a == VT_ERROR || a == VT_VARIANT || \
5455 a == VT_DISPATCH || a == VT_UNKNOWN || \
5456 a > VT_UINT || a == 15 /*not defined*/) \
5459 static void test_VarAnd(void)
5461 static const WCHAR szFalse[] = { '#','F','A','L','S','E','#','\0' };
5462 static const WCHAR szTrue[] = { '#','T','R','U','E','#','\0' };
5463 VARIANT left, right, exp, result;
5464 BSTR false_str, true_str;
5468 true_str = SysAllocString(szTrue);
5469 false_str = SysAllocString(szFalse);
5473 /* Test all possible flag/vt combinations & the resulting vt type */
5474 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
5476 VARTYPE leftvt, rightvt, resvt;
5478 for (leftvt = 0; leftvt <= VT_BSTR_BLOB; leftvt++)
5480 SKIPTESTAND(leftvt);
5482 /* Check if we need/have support for I8 and/or UI8 */
5483 if ((leftvt == VT_I8 || leftvt == VT_UI8) && !HAVE_OLEAUT32_I8)
5486 for (rightvt = 0; rightvt <= VT_BSTR_BLOB; rightvt++)
5489 SKIPTESTAND(rightvt);
5491 /* Check if we need/have support for I8 and/or UI8 */
5492 if ((rightvt == VT_I8 || rightvt == VT_UI8) && !HAVE_OLEAUT32_I8)
5495 memset(&left, 0, sizeof(left));
5496 memset(&right, 0, sizeof(right));
5497 V_VT(&left) = leftvt | ExtraFlags[i];
5498 V_VT(&right) = rightvt | ExtraFlags[i];
5499 V_VT(&result) = VT_EMPTY;
5501 if ((leftvt | ExtraFlags[i]) == VT_BSTR)
5502 V_BSTR(&left) = true_str;
5503 if ((rightvt | ExtraFlags[i]) == VT_BSTR)
5504 V_BSTR(&right) = true_str;
5506 /* Native VarAnd always returns an error when using extra
5507 * flags or if the variant combination is I8 and INT.
5509 if ((leftvt == VT_I8 && rightvt == VT_INT) ||
5510 (leftvt == VT_INT && rightvt == VT_I8) ||
5514 /* Determine return type */
5515 else if (leftvt == VT_I8 || rightvt == VT_I8)
5517 else if (leftvt == VT_I4 || rightvt == VT_I4 ||
5518 leftvt == VT_UINT || rightvt == VT_UINT ||
5519 leftvt == VT_INT || rightvt == VT_INT ||
5520 leftvt == VT_UINT || rightvt == VT_UINT ||
5521 leftvt == VT_R4 || rightvt == VT_R4 ||
5522 leftvt == VT_R8 || rightvt == VT_R8 ||
5523 leftvt == VT_CY || rightvt == VT_CY ||
5524 leftvt == VT_DATE || rightvt == VT_DATE ||
5525 leftvt == VT_I1 || rightvt == VT_I1 ||
5526 leftvt == VT_UI2 || rightvt == VT_UI2 ||
5527 leftvt == VT_UI4 || rightvt == VT_UI4 ||
5528 leftvt == VT_UI8 || rightvt == VT_UI8 ||
5529 leftvt == VT_DECIMAL || rightvt == VT_DECIMAL)
5531 else if (leftvt == VT_UI1 || rightvt == VT_UI1 ||
5532 leftvt == VT_I2 || rightvt == VT_I2 ||
5533 leftvt == VT_EMPTY || rightvt == VT_EMPTY)
5534 if ((leftvt == VT_NULL && rightvt == VT_UI1) ||
5535 (leftvt == VT_UI1 && rightvt == VT_NULL) ||
5536 (leftvt == VT_UI1 && rightvt == VT_UI1))
5540 else if (leftvt == VT_BOOL || rightvt == VT_BOOL ||
5541 (leftvt == VT_BSTR && rightvt == VT_BSTR))
5543 else if (leftvt == VT_NULL || rightvt == VT_NULL ||
5544 leftvt == VT_BSTR || rightvt == VT_BSTR)
5549 hres = pVarAnd(&left, &right, &result);
5551 /* Check expected HRESULT and if result variant type is correct */
5553 ok (hres == DISP_E_BADVARTYPE || hres == DISP_E_TYPEMISMATCH,
5554 "VarAnd: %s|0x%X, %s|0x%X: got vt %s hr 0x%X\n",
5555 vtstr(leftvt), ExtraFlags[i], vtstr(rightvt), ExtraFlags[i],
5556 vtstr(V_VT(&result)), hres);
5558 ok (hres == S_OK && resvt == V_VT(&result),
5559 "VarAnd: %s|0x%X, %s|0x%X: expected vt %s hr 0x%X, got vt %s hr 0x%X\n",
5560 vtstr(leftvt), ExtraFlags[i], vtstr(rightvt), ExtraFlags[i], vtstr(resvt),
5561 S_OK, vtstr(V_VT(&result)), hres);
5567 * Test returned values. Since we know the returned type is correct
5568 * and that we handle all combinations of invalid types, just check
5569 * that good type combinations produce the desired value.
5570 * FIXME: Test VT_DECIMAL
5572 VARAND(EMPTY,0,EMPTY,0,I2,0);
5573 VARAND(EMPTY,1,EMPTY,0,I2,0);
5574 VARAND(EMPTY,1,EMPTY,1,I2,0);
5575 VARAND(EMPTY,0,NULL,0,I2,0);
5576 VARAND(EMPTY,1,NULL,0,I2,0);
5577 VARAND(EMPTY,1,NULL,1,I2,0);
5578 VARAND(EMPTY,0,I1,0,I4,0);
5579 VARAND(EMPTY,0,I1,1,I4,0);
5580 VARAND(EMPTY,1,I1,1,I4,0);
5581 VARAND(EMPTY,0,UI1,0,I2,0);
5582 VARAND(EMPTY,0,UI1,1,I2,0);
5583 VARAND(EMPTY,1,UI1,1,I2,0);
5584 VARAND(EMPTY,0,I2,0,I2,0);
5585 VARAND(EMPTY,0,I2,1,I2,0);
5586 VARAND(EMPTY,1,I2,1,I2,0);
5587 VARAND(EMPTY,0,UI2,0,I4,0);
5588 VARAND(EMPTY,0,UI2,1,I4,0);
5589 VARAND(EMPTY,1,UI2,1,I4,0);
5590 VARAND(EMPTY,0,I4,0,I4,0);
5591 VARAND(EMPTY,0,I4,1,I4,0);
5592 VARAND(EMPTY,1,I4,1,I4,0);
5593 VARAND(EMPTY,0,UI4,0,I4,0);
5594 VARAND(EMPTY,0,UI4,1,I4,0);
5595 VARAND(EMPTY,1,UI4,1,I4,0);
5596 if (HAVE_OLEAUT32_I8)
5598 VARAND(EMPTY,0,I8,0,I8,0);
5599 VARAND(EMPTY,0,I8,1,I8,0);
5600 VARAND(EMPTY,1,I8,1,I8,0);
5601 VARAND(EMPTY,0,UI8,0,I4,0);
5602 VARAND(EMPTY,0,UI8,1,I4,0);
5603 VARAND(EMPTY,1,UI8,1,I4,0);
5605 VARAND(EMPTY,0,INT,0,I4,0);
5606 VARAND(EMPTY,0,INT,1,I4,0);
5607 VARAND(EMPTY,1,INT,1,I4,0);
5608 VARAND(EMPTY,0,UINT,0,I4,0);
5609 VARAND(EMPTY,0,UINT,1,I4,0);
5610 VARAND(EMPTY,1,UINT,1,I4,0);
5611 VARAND(EMPTY,0,BOOL,0,I2,0);
5612 VARAND(EMPTY,0,BOOL,1,I2,0);
5613 VARAND(EMPTY,1,BOOL,1,I2,0);
5614 VARAND(EMPTY,0,R4,0,I4,0);
5615 VARAND(EMPTY,0,R4,1,I4,0);
5616 VARAND(EMPTY,1,R4,1,I4,0);
5617 VARAND(EMPTY,0,R8,0,I4,0);
5618 VARAND(EMPTY,0,R8,1,I4,0);
5619 VARAND(EMPTY,1,R8,1,I4,0);
5620 VARAND(EMPTY,0,BSTR,false_str,I2,0);
5621 VARAND(EMPTY,0,BSTR,true_str,I2,0);
5622 VARANDCY(EMPTY,0,10000,I4,0);
5624 /* NULL OR 0 = NULL. NULL OR n = n */
5625 VARAND(NULL,0,NULL,0,NULL,0);
5626 VARAND(NULL,1,NULL,0,NULL,0);
5627 VARAND(NULL,0,I1,0,I4,0);
5628 VARAND(NULL,0,I1,1,NULL,0);
5629 VARAND(NULL,0,UI1,0,UI1,0);
5630 VARAND(NULL,0,UI1,1,NULL,0);
5631 VARAND(NULL,0,I2,0,I2,0);
5632 VARAND(NULL,0,I2,1,NULL,0);
5633 VARAND(NULL,0,UI2,0,I4,0);
5634 VARAND(NULL,0,UI2,1,NULL,0);
5635 VARAND(NULL,0,I4,0,I4,0);
5636 VARAND(NULL,0,I4,1,NULL,0);
5637 VARAND(NULL,0,UI4,0,I4,0);
5638 VARAND(NULL,0,UI4,1,NULL,0);
5639 if (HAVE_OLEAUT32_I8)
5641 VARAND(NULL,0,I8,0,I8,0);
5642 VARAND(NULL,0,I8,1,NULL,0);
5643 VARAND(NULL,0,UI8,0,I4,0);
5644 VARAND(NULL,0,UI8,1,NULL,0);
5646 VARAND(NULL,0,INT,0,I4,0);
5647 VARAND(NULL,0,INT,1,NULL,0);
5648 VARAND(NULL,0,UINT,0,I4,0);
5649 VARAND(NULL,0,UINT,1,NULL,0);
5650 VARAND(NULL,0,BOOL,0,BOOL,0);
5651 VARAND(NULL,0,BOOL,1,NULL,0);
5652 VARAND(NULL,0,R4,0,I4,0);
5653 VARAND(NULL,0,R4,1,NULL,0);
5654 VARAND(NULL,0,R8,0,I4,0);
5655 VARAND(NULL,0,R8,1,NULL,0);
5656 VARAND(NULL,0,BSTR,false_str,BOOL,0);
5657 VARAND(NULL,0,BSTR,true_str,NULL,VARIANT_FALSE);
5658 VARANDCY(NULL,0,10000,NULL,0);
5659 VARANDCY(NULL,0,0,I4,0);
5660 VARAND(BOOL,VARIANT_TRUE,BOOL,VARIANT_TRUE,BOOL,VARIANT_TRUE);
5661 VARAND(BOOL,VARIANT_TRUE,BOOL,VARIANT_FALSE,BOOL,VARIANT_FALSE);
5662 VARAND(BOOL,VARIANT_FALSE,BOOL,VARIANT_TRUE,BOOL,VARIANT_FALSE);
5663 VARAND(BOOL,VARIANT_FALSE,BOOL,VARIANT_FALSE,BOOL,VARIANT_FALSE);
5665 /* Assume x,y & y,x are the same from now on to reduce the number of tests */
5666 VARAND(BOOL,VARIANT_TRUE,I1,-1,I4,-1);
5667 VARAND(BOOL,VARIANT_TRUE,I1,0,I4,0);
5668 VARAND(BOOL,VARIANT_FALSE,I1,0,I4,0);
5669 VARAND(BOOL,VARIANT_TRUE,UI1,255,I2,255);
5670 VARAND(BOOL,VARIANT_TRUE,UI1,0,I2,0);
5671 VARAND(BOOL,VARIANT_FALSE,UI1,0,I2,0);
5672 VARAND(BOOL,VARIANT_TRUE,I2,-1,I2,-1);
5673 VARAND(BOOL,VARIANT_TRUE,I2,0,I2,0);
5674 VARAND(BOOL,VARIANT_FALSE,I2,0,I2,0);
5675 VARAND(BOOL,VARIANT_TRUE,UI2,65535,I4,65535);
5676 VARAND(BOOL,VARIANT_TRUE,UI2,0,I4,0);
5677 VARAND(BOOL,VARIANT_FALSE,UI2,0,I4,0);
5678 VARAND(BOOL,VARIANT_TRUE,I4,-1,I4,-1);
5679 VARAND(BOOL,VARIANT_TRUE,I4,0,I4,0);
5680 VARAND(BOOL,VARIANT_FALSE,I4,0,I4,0);
5681 VARAND(BOOL,VARIANT_TRUE,UI4,0xffffffff,I4,-1);
5682 VARAND(BOOL,VARIANT_TRUE,UI4,0,I4,0);
5683 VARAND(BOOL,VARIANT_FALSE,UI4,0,I4,0);
5684 VARAND(BOOL,VARIANT_TRUE,R4,-1,I4,-1);
5685 VARAND(BOOL,VARIANT_TRUE,R4,0,I4,0);
5686 VARAND(BOOL,VARIANT_FALSE,R4,0,I4,0);
5687 VARAND(BOOL,VARIANT_TRUE,R8,-1,I4,-1);
5688 VARAND(BOOL,VARIANT_TRUE,R8,0,I4,0);
5689 VARAND(BOOL,VARIANT_FALSE,R8,0,I4,0);
5690 VARAND(BOOL,VARIANT_TRUE,DATE,-1,I4,-1);
5691 VARAND(BOOL,VARIANT_TRUE,DATE,0,I4,0);
5692 VARAND(BOOL,VARIANT_FALSE,DATE,0,I4,0);
5693 if (HAVE_OLEAUT32_I8)
5695 VARAND(BOOL,VARIANT_TRUE,I8,-1,I8,-1);
5696 VARAND(BOOL,VARIANT_TRUE,I8,0,I8,0);
5697 VARAND(BOOL,VARIANT_FALSE,I8,0,I8,0);
5698 VARAND(BOOL,VARIANT_TRUE,UI8,0,I4,0);
5699 VARAND(BOOL,VARIANT_FALSE,UI8,0,I4,0);
5701 VARAND(BOOL,VARIANT_TRUE,INT,-1,I4,-1);
5702 VARAND(BOOL,VARIANT_TRUE,INT,0,I4,0);
5703 VARAND(BOOL,VARIANT_FALSE,INT,0,I4,0);
5704 VARAND(BOOL,VARIANT_TRUE,UINT,0xffffffff,I4,-1);
5705 VARAND(BOOL,VARIANT_TRUE,UINT,0,I4,0);
5706 VARAND(BOOL,VARIANT_FALSE,UINT,0,I4,0);
5707 VARAND(BOOL,VARIANT_FALSE,BSTR,false_str,BOOL,VARIANT_FALSE);
5708 VARAND(BOOL,VARIANT_TRUE,BSTR,false_str,BOOL,VARIANT_FALSE);
5709 VARAND(BOOL,VARIANT_FALSE,BSTR,true_str,BOOL,VARIANT_FALSE);
5710 VARAND(BOOL,VARIANT_TRUE,BSTR,true_str,BOOL,VARIANT_TRUE);
5711 VARANDCY(BOOL,VARIANT_TRUE,10000,I4,1);
5712 VARANDCY(BOOL,VARIANT_TRUE,0,I4,0);
5713 VARANDCY(BOOL,VARIANT_FALSE,0,I4,0);
5714 VARAND(I1,-1,I1,-1,I4,-1);
5715 VARAND(I1,-1,I1,0,I4,0);
5716 VARAND(I1,0,I1,0,I4,0);
5717 VARAND(I1,-1,UI1,255,I4,255);
5718 VARAND(I1,-1,UI1,0,I4,0);
5719 VARAND(I1,0,UI1,0,I4,0);
5720 VARAND(I1,-1,I2,-1,I4,-1);
5721 VARAND(I1,-1,I2,0,I4,0);
5722 VARAND(I1,0,I2,0,I4,0);
5723 VARAND(I1,-1,UI2,65535,I4,65535);
5724 VARAND(I1,-1,UI2,0,I4,0);
5725 VARAND(I1,0,UI2,0,I4,0);
5726 VARAND(I1,-1,I4,-1,I4,-1);
5727 VARAND(I1,-1,I4,0,I4,0);
5728 VARAND(I1,0,I4,0,I4,0);
5729 VARAND(I1,-1,UI4,0xffffffff,I4,-1);
5730 VARAND(I1,-1,UI4,0,I4,0);
5731 VARAND(I1,0,UI4,0,I4,0);
5732 VARAND(I1,-1,R4,-1,I4,-1);
5733 VARAND(I1,-1,R4,0,I4,0);
5734 VARAND(I1,0,R4,0,I4,0);
5735 VARAND(I1,-1,R8,-1,I4,-1);
5736 VARAND(I1,-1,R8,0,I4,0);
5737 VARAND(I1,0,R8,0,I4,0);
5738 VARAND(I1,-1,DATE,-1,I4,-1);
5739 VARAND(I1,-1,DATE,0,I4,0);
5740 VARAND(I1,0,DATE,0,I4,0);
5741 if (HAVE_OLEAUT32_I8)
5743 VARAND(I1,-1,I8,-1,I8,-1);
5744 VARAND(I1,-1,I8,0,I8,0);
5745 VARAND(I1,0,I8,0,I8,0);
5746 VARAND(I1,-1,UI8,0,I4,0);
5747 VARAND(I1,0,UI8,0,I4,0);
5749 VARAND(I1,-1,INT,-1,I4,-1);
5750 VARAND(I1,-1,INT,0,I4,0);
5751 VARAND(I1,0,INT,0,I4,0);
5752 VARAND(I1,-1,UINT,0xffffffff,I4,-1);
5753 VARAND(I1,-1,UINT,0,I4,0);
5754 VARAND(I1,0,UINT,0,I4,0);
5755 VARAND(I1,0,BSTR,false_str,I4,0);
5756 VARAND(I1,-1,BSTR,false_str,I4,0);
5757 VARAND(I1,0,BSTR,true_str,I4,0);
5758 VARAND(I1,-1,BSTR,true_str,I4,-1);
5759 VARANDCY(I1,-1,10000,I4,1);
5760 VARANDCY(I1,-1,0,I4,0);
5761 VARANDCY(I1,0,0,I4,0);
5763 VARAND(UI1,255,UI1,255,UI1,255);
5764 VARAND(UI1,255,UI1,0,UI1,0);
5765 VARAND(UI1,0,UI1,0,UI1,0);
5766 VARAND(UI1,255,I2,-1,I2,255);
5767 VARAND(UI1,255,I2,0,I2,0);
5768 VARAND(UI1,0,I2,0,I2,0);
5769 VARAND(UI1,255,UI2,65535,I4,255);
5770 VARAND(UI1,255,UI2,0,I4,0);
5771 VARAND(UI1,0,UI2,0,I4,0);
5772 VARAND(UI1,255,I4,-1,I4,255);
5773 VARAND(UI1,255,I4,0,I4,0);
5774 VARAND(UI1,0,I4,0,I4,0);
5775 VARAND(UI1,255,UI4,0xffffffff,I4,255);
5776 VARAND(UI1,255,UI4,0,I4,0);
5777 VARAND(UI1,0,UI4,0,I4,0);
5778 VARAND(UI1,255,R4,-1,I4,255);
5779 VARAND(UI1,255,R4,0,I4,0);
5780 VARAND(UI1,0,R4,0,I4,0);
5781 VARAND(UI1,255,R8,-1,I4,255);
5782 VARAND(UI1,255,R8,0,I4,0);
5783 VARAND(UI1,0,R8,0,I4,0);
5784 VARAND(UI1,255,DATE,-1,I4,255);
5785 VARAND(UI1,255,DATE,0,I4,0);
5786 VARAND(UI1,0,DATE,0,I4,0);
5787 if (HAVE_OLEAUT32_I8)
5789 VARAND(UI1,255,I8,-1,I8,255);
5790 VARAND(UI1,255,I8,0,I8,0);
5791 VARAND(UI1,0,I8,0,I8,0);
5792 VARAND(UI1,255,UI8,0,I4,0);
5793 VARAND(UI1,0,UI8,0,I4,0);
5795 VARAND(UI1,255,INT,-1,I4,255);
5796 VARAND(UI1,255,INT,0,I4,0);
5797 VARAND(UI1,0,INT,0,I4,0);
5798 VARAND(UI1,255,UINT,0xffffffff,I4,255);
5799 VARAND(UI1,255,UINT,0,I4,0);
5800 VARAND(UI1,0,UINT,0,I4,0);
5801 VARAND(UI1,0,BSTR,false_str,I2,0);
5802 VARAND(UI1,255,BSTR,false_str,I2,0);
5803 VARAND(UI1,0,BSTR,true_str,I2,0);
5804 VARAND(UI1,255,BSTR,true_str,I2,255);
5805 VARANDCY(UI1,255,10000,I4,1);
5806 VARANDCY(UI1,255,0,I4,0);
5807 VARANDCY(UI1,0,0,I4,0);
5809 VARAND(I2,-1,I2,-1,I2,-1);
5810 VARAND(I2,-1,I2,0,I2,0);
5811 VARAND(I2,0,I2,0,I2,0);
5812 VARAND(I2,-1,UI2,65535,I4,65535);
5813 VARAND(I2,-1,UI2,0,I4,0);
5814 VARAND(I2,0,UI2,0,I4,0);
5815 VARAND(I2,-1,I4,-1,I4,-1);
5816 VARAND(I2,-1,I4,0,I4,0);
5817 VARAND(I2,0,I4,0,I4,0);
5818 VARAND(I2,-1,UI4,0xffffffff,I4,-1);
5819 VARAND(I2,-1,UI4,0,I4,0);
5820 VARAND(I2,0,UI4,0,I4,0);
5821 VARAND(I2,-1,R4,-1,I4,-1);
5822 VARAND(I2,-1,R4,0,I4,0);
5823 VARAND(I2,0,R4,0,I4,0);
5824 VARAND(I2,-1,R8,-1,I4,-1);
5825 VARAND(I2,-1,R8,0,I4,0);
5826 VARAND(I2,0,R8,0,I4,0);
5827 VARAND(I2,-1,DATE,-1,I4,-1);
5828 VARAND(I2,-1,DATE,0,I4,0);
5829 VARAND(I2,0,DATE,0,I4,0);
5830 if (HAVE_OLEAUT32_I8)
5832 VARAND(I2,-1,I8,-1,I8,-1);
5833 VARAND(I2,-1,I8,0,I8,0);
5834 VARAND(I2,0,I8,0,I8,0);
5835 VARAND(I2,-1,UI8,0,I4,0);
5836 VARAND(I2,0,UI8,0,I4,0);
5838 VARAND(I2,-1,INT,-1,I4,-1);
5839 VARAND(I2,-1,INT,0,I4,0);
5840 VARAND(I2,0,INT,0,I4,0);
5841 VARAND(I2,-1,UINT,0xffffffff,I4,-1);
5842 VARAND(I2,-1,UINT,0,I4,0);
5843 VARAND(I2,0,UINT,0,I4,0);
5844 VARAND(I2,0,BSTR,false_str,I2,0);
5845 VARAND(I2,-1,BSTR,false_str,I2,0);
5846 VARAND(I2,0,BSTR,true_str,I2,0);
5847 VARAND(I2,-1,BSTR,true_str,I2,-1);
5848 VARANDCY(I2,-1,10000,I4,1);
5849 VARANDCY(I2,-1,0,I4,0);
5850 VARANDCY(I2,0,0,I4,0);
5852 VARAND(UI2,65535,UI2,65535,I4,65535);
5853 VARAND(UI2,65535,UI2,0,I4,0);
5854 VARAND(UI2,0,UI2,0,I4,0);
5855 VARAND(UI2,65535,I4,-1,I4,65535);
5856 VARAND(UI2,65535,I4,0,I4,0);
5857 VARAND(UI2,0,I4,0,I4,0);
5858 VARAND(UI2,65535,UI4,0xffffffff,I4,65535);
5859 VARAND(UI2,65535,UI4,0,I4,0);
5860 VARAND(UI2,0,UI4,0,I4,0);
5861 VARAND(UI2,65535,R4,-1,I4,65535);
5862 VARAND(UI2,65535,R4,0,I4,0);
5863 VARAND(UI2,0,R4,0,I4,0);
5864 VARAND(UI2,65535,R8,-1,I4,65535);
5865 VARAND(UI2,65535,R8,0,I4,0);
5866 VARAND(UI2,0,R8,0,I4,0);
5867 VARAND(UI2,65535,DATE,-1,I4,65535);
5868 VARAND(UI2,65535,DATE,0,I4,0);
5869 VARAND(UI2,0,DATE,0,I4,0);
5870 if (HAVE_OLEAUT32_I8)
5872 VARAND(UI2,65535,I8,-1,I8,65535);
5873 VARAND(UI2,65535,I8,0,I8,0);
5874 VARAND(UI2,0,I8,0,I8,0);
5875 VARAND(UI2,65535,UI8,0,I4,0);
5876 VARAND(UI2,0,UI8,0,I4,0);
5878 VARAND(UI2,65535,INT,-1,I4,65535);
5879 VARAND(UI2,65535,INT,0,I4,0);
5880 VARAND(UI2,0,INT,0,I4,0);
5881 VARAND(UI2,65535,UINT,0xffffffff,I4,65535);
5882 VARAND(UI2,65535,UINT,0,I4,0);
5883 VARAND(UI2,0,UINT,0,I4,0);
5884 VARAND(UI2,0,BSTR,false_str,I4,0);
5885 VARAND(UI2,65535,BSTR,false_str,I4,0);
5886 VARAND(UI2,0,BSTR,true_str,I4,0);
5887 VARAND(UI2,65535,BSTR,true_str,I4,65535);
5888 VARANDCY(UI2,65535,10000,I4,1);
5889 VARANDCY(UI2,65535,0,I4,0);
5890 VARANDCY(UI2,0,0,I4,0);
5892 VARAND(I4,-1,I4,-1,I4,-1);
5893 VARAND(I4,-1,I4,0,I4,0);
5894 VARAND(I4,0,I4,0,I4,0);
5895 VARAND(I4,-1,UI4,0xffffffff,I4,-1);
5896 VARAND(I4,-1,UI4,0,I4,0);
5897 VARAND(I4,0,UI4,0,I4,0);
5898 VARAND(I4,-1,R4,-1,I4,-1);
5899 VARAND(I4,-1,R4,0,I4,0);
5900 VARAND(I4,0,R4,0,I4,0);
5901 VARAND(I4,-1,R8,-1,I4,-1);
5902 VARAND(I4,-1,R8,0,I4,0);
5903 VARAND(I4,0,R8,0,I4,0);
5904 VARAND(I4,-1,DATE,-1,I4,-1);
5905 VARAND(I4,-1,DATE,0,I4,0);
5906 VARAND(I4,0,DATE,0,I4,0);
5907 if (HAVE_OLEAUT32_I8)
5909 VARAND(I4,-1,I8,-1,I8,-1);
5910 VARAND(I4,-1,I8,0,I8,0);
5911 VARAND(I4,0,I8,0,I8,0);
5912 VARAND(I4,-1,UI8,0,I4,0);
5913 VARAND(I4,0,UI8,0,I4,0);
5915 VARAND(I4,-1,INT,-1,I4,-1);
5916 VARAND(I4,-1,INT,0,I4,0);
5917 VARAND(I4,0,INT,0,I4,0);
5918 VARAND(I4,-1,UINT,0xffffffff,I4,-1);
5919 VARAND(I4,-1,UINT,0,I4,0);
5920 VARAND(I4,0,UINT,0,I4,0);
5921 VARAND(I4,0,BSTR,false_str,I4,0);
5922 VARAND(I4,-1,BSTR,false_str,I4,0);
5923 VARAND(I4,0,BSTR,true_str,I4,0);
5924 VARAND(I4,-1,BSTR,true_str,I4,-1);
5925 VARANDCY(I4,-1,10000,I4,1);
5926 VARANDCY(I4,-1,0,I4,0);
5927 VARANDCY(I4,0,0,I4,0);
5929 VARAND(UI4,0xffffffff,UI4,0xffffffff,I4,-1);
5930 VARAND(UI4,0xffffffff,UI4,0,I4,0);
5931 VARAND(UI4,0,UI4,0,I4,0);
5932 VARAND(UI4,0xffffffff,R4,-1,I4,-1);
5933 VARAND(UI4,0xffffffff,R4,0,I4,0);
5934 VARAND(UI4,0,R4,0,I4,0);
5935 VARAND(UI4,0xffffffff,R8,-1,I4,-1);
5936 VARAND(UI4,0xffffffff,R8,0,I4,0);
5937 VARAND(UI4,0,R8,0,I4,0);
5938 VARAND(UI4,0xffffffff,DATE,-1,I4,-1);
5939 VARAND(UI4,0xffffffff,DATE,0,I4,0);
5940 VARAND(UI4,0,DATE,0,I4,0);
5941 if (HAVE_OLEAUT32_I8)
5943 VARAND(UI4,0xffffffff,I8,0,I8,0);
5944 VARAND(UI4,0,I8,0,I8,0);
5945 VARAND(UI4,0xffffffff,UI8,0,I4,0);
5946 VARAND(UI4,0,UI8,0,I4,0);
5948 VARAND(UI4,0xffffffff,INT,-1,I4,-1);
5949 VARAND(UI4,0xffffffff,INT,0,I4,0);
5950 VARAND(UI4,0,INT,0,I4,0);
5951 VARAND(UI4,0xffffffff,UINT,0xffffffff,I4,-1);
5952 VARAND(UI4,0xffffffff,UINT,0,I4,0);
5953 VARAND(UI4,0,UINT,0,I4,0);
5954 VARAND(UI4,0,BSTR,false_str,I4,0);
5955 VARAND(UI4,0xffffffff,BSTR,false_str,I4,0);
5956 VARAND(UI4,0,BSTR,true_str,I4,0);
5957 VARAND(UI4,0xffffffff,BSTR,true_str,I4,-1);
5958 VARANDCY(UI4,0xffffffff,10000,I4,1);
5959 VARANDCY(UI4,0xffffffff,0,I4,0);
5960 VARANDCY(UI4,0,0,I4,0);
5962 VARAND(R4,-1,R4,-1,I4,-1);
5963 VARAND(R4,-1,R4,0,I4,0);
5964 VARAND(R4,0,R4,0,I4,0);
5965 VARAND(R4,-1,R8,-1,I4,-1);
5966 VARAND(R4,-1,R8,0,I4,0);
5967 VARAND(R4,0,R8,0,I4,0);
5968 VARAND(R4,-1,DATE,-1,I4,-1);
5969 VARAND(R4,-1,DATE,0,I4,0);
5970 VARAND(R4,0,DATE,0,I4,0);
5971 if (HAVE_OLEAUT32_I8)
5973 VARAND(R4,-1,I8,-1,I8,-1);
5974 VARAND(R4,-1,I8,0,I8,0);
5975 VARAND(R4,0,I8,0,I8,0);
5976 VARAND(R4,-1,UI8,0,I4,0);
5977 VARAND(R4,0,UI8,0,I4,0);
5979 VARAND(R4,-1,INT,-1,I4,-1);
5980 VARAND(R4,-1,INT,0,I4,0);
5981 VARAND(R4,0,INT,0,I4,0);
5982 VARAND(R4,-1,UINT,0xffffffff,I4,-1);
5983 VARAND(R4,-1,UINT,0,I4,0);
5984 VARAND(R4,0,UINT,0,I4,0);
5985 VARAND(R4,0,BSTR,false_str,I4,0);
5986 VARAND(R4,-1,BSTR,false_str,I4,0);
5987 VARAND(R4,0,BSTR,true_str,I4,0);
5988 VARAND(R4,-1,BSTR,true_str,I4,-1);
5989 VARANDCY(R4,-1,10000,I4,1);
5990 VARANDCY(R4,-1,0,I4,0);
5991 VARANDCY(R4,0,0,I4,0);
5993 VARAND(R8,-1,R8,-1,I4,-1);
5994 VARAND(R8,-1,R8,0,I4,0);
5995 VARAND(R8,0,R8,0,I4,0);
5996 VARAND(R8,-1,DATE,-1,I4,-1);
5997 VARAND(R8,-1,DATE,0,I4,0);
5998 VARAND(R8,0,DATE,0,I4,0);
5999 if (HAVE_OLEAUT32_I8)
6001 VARAND(R8,-1,I8,-1,I8,-1);
6002 VARAND(R8,-1,I8,0,I8,0);
6003 VARAND(R8,0,I8,0,I8,0);
6004 VARAND(R8,-1,UI8,0,I4,0);
6005 VARAND(R8,0,UI8,0,I4,0);
6007 VARAND(R8,-1,INT,-1,I4,-1);
6008 VARAND(R8,-1,INT,0,I4,0);
6009 VARAND(R8,0,INT,0,I4,0);
6010 VARAND(R8,-1,UINT,0xffffffff,I4,-1);
6011 VARAND(R8,-1,UINT,0,I4,0);
6012 VARAND(R8,0,UINT,0,I4,0);
6013 VARAND(R8,0,BSTR,false_str,I4,0);
6014 VARAND(R8,-1,BSTR,false_str,I4,0);
6015 VARAND(R8,0,BSTR,true_str,I4,0);
6016 VARAND(R8,-1,BSTR,true_str,I4,-1);
6017 VARANDCY(R8,-1,10000,I4,1);
6018 VARANDCY(R8,-1,0,I4,0);
6019 VARANDCY(R8,0,0,I4,0);
6021 VARAND(DATE,-1,DATE,-1,I4,-1);
6022 VARAND(DATE,-1,DATE,0,I4,0);
6023 VARAND(DATE,0,DATE,0,I4,0);
6024 if (HAVE_OLEAUT32_I8)
6026 VARAND(DATE,-1,I8,-1,I8,-1);
6027 VARAND(DATE,-1,I8,0,I8,0);
6028 VARAND(DATE,0,I8,0,I8,0);
6029 VARAND(DATE,-1,UI8,0,I4,0);
6030 VARAND(DATE,0,UI8,0,I4,0);
6032 VARAND(DATE,-1,INT,-1,I4,-1);
6033 VARAND(DATE,-1,INT,0,I4,0);
6034 VARAND(DATE,0,INT,0,I4,0);
6035 VARAND(DATE,-1,UINT,0xffffffff,I4,-1);
6036 VARAND(DATE,-1,UINT,0,I4,0);
6037 VARAND(DATE,0,UINT,0,I4,0);
6038 VARAND(DATE,0,BSTR,false_str,I4,0);
6039 VARAND(DATE,-1,BSTR,false_str,I4,0);
6040 VARAND(DATE,0,BSTR,true_str,I4,0);
6041 VARAND(DATE,-1,BSTR,true_str,I4,-1);
6042 VARANDCY(DATE,-1,10000,I4,1);
6043 VARANDCY(DATE,-1,0,I4,0);
6044 VARANDCY(DATE,0,0,I4,0);
6046 if (HAVE_OLEAUT32_I8)
6048 VARAND(I8,-1,I8,-1,I8,-1);
6049 VARAND(I8,-1,I8,0,I8,0);
6050 VARAND(I8,0,I8,0,I8,0);
6051 VARAND(I8,-1,UI8,0,I8,0);
6052 VARAND(I8,0,UI8,0,I8,0);
6053 VARAND(I8,-1,UINT,0,I8,0);
6054 VARAND(I8,0,UINT,0,I8,0);
6055 VARAND(I8,0,BSTR,false_str,I8,0);
6056 VARAND(I8,-1,BSTR,false_str,I8,0);
6057 VARAND(I8,0,BSTR,true_str,I8,0);
6058 VARAND(I8,-1,BSTR,true_str,I8,-1);
6059 VARANDCY(I8,-1,10000,I8,1);
6060 VARANDCY(I8,-1,0,I8,0);
6061 VARANDCY(I8,0,0,I8,0);
6063 VARAND(UI8,0xffff,UI8,0xffff,I4,0xffff);
6064 VARAND(UI8,0xffff,UI8,0,I4,0);
6065 VARAND(UI8,0,UI8,0,I4,0);
6066 VARAND(UI8,0xffff,INT,-1,I4,65535);
6067 VARAND(UI8,0xffff,INT,0,I4,0);
6068 VARAND(UI8,0,INT,0,I4,0);
6069 VARAND(UI8,0xffff,UINT,0xffff,I4,0xffff);
6070 VARAND(UI8,0xffff,UINT,0,I4,0);
6071 VARAND(UI8,0,UINT,0,I4,0);
6072 VARAND(UI8,0,BSTR,false_str,I4,0);
6073 VARAND(UI8,0xffff,BSTR,false_str,I4,0);
6074 VARAND(UI8,0,BSTR,true_str,I4,0);
6075 VARAND(UI8,0xffff,BSTR,true_str,I4,65535);
6076 VARANDCY(UI8,0xffff,10000,I4,1);
6077 VARANDCY(UI8,0xffff,0,I4,0);
6078 VARANDCY(UI8,0,0,I4,0);
6081 VARAND(INT,-1,INT,-1,I4,-1);
6082 VARAND(INT,-1,INT,0,I4,0);
6083 VARAND(INT,0,INT,0,I4,0);
6084 VARAND(INT,-1,UINT,0xffff,I4,65535);
6085 VARAND(INT,-1,UINT,0,I4,0);
6086 VARAND(INT,0,UINT,0,I4,0);
6087 VARAND(INT,0,BSTR,false_str,I4,0);
6088 VARAND(INT,-1,BSTR,false_str,I4,0);
6089 VARAND(INT,0,BSTR,true_str,I4,0);
6090 VARAND(INT,-1,BSTR,true_str,I4,-1);
6091 VARANDCY(INT,-1,10000,I4,1);
6092 VARANDCY(INT,-1,0,I4,0);
6093 VARANDCY(INT,0,0,I4,0);
6095 VARAND(UINT,0xffff,UINT,0xffff,I4,0xffff);
6096 VARAND(UINT,0xffff,UINT,0,I4,0);
6097 VARAND(UINT,0,UINT,0,I4,0);
6098 VARAND(UINT,0,BSTR,false_str,I4,0);
6099 VARAND(UINT,0xffff,BSTR, false_str,I4,0);
6100 VARAND(UINT,0,BSTR,true_str,I4,0);
6101 VARAND(UINT,0xffff,BSTR,true_str,I4,65535);
6102 VARANDCY(UINT,0xffff,10000,I4,1);
6103 VARANDCY(UINT,0xffff,0,I4,0);
6104 VARANDCY(UINT,0,0,I4,0);
6106 VARAND(BSTR,false_str,BSTR,false_str,BOOL,0);
6107 VARAND(BSTR,true_str,BSTR,false_str,BOOL,VARIANT_FALSE);
6108 VARAND(BSTR,true_str,BSTR,true_str,BOOL,VARIANT_TRUE);
6109 VARANDCY(BSTR,true_str,10000,I4,1);
6110 VARANDCY(BSTR,false_str,10000,I4,0);
6112 SysFreeString(true_str);
6113 SysFreeString(false_str);
6116 static HRESULT (WINAPI *pVarCmp)(LPVARIANT,LPVARIANT,LCID,ULONG);
6118 static void test_cmp( int line, LCID lcid, UINT flags, VARIANT *left, VARIANT *right, HRESULT result )
6122 hres = pVarCmp(left,right,lcid,flags);
6123 ok_(__FILE__,line)(hres == result, "VarCmp(%s,%s): expected 0x%x, got hres=0x%x\n",
6124 variantstr(left), variantstr(right), result, hres );
6126 static void test_cmpex( int line, LCID lcid, VARIANT *left, VARIANT *right,
6127 HRESULT res1, HRESULT res2, HRESULT res3, HRESULT res4 )
6129 test_cmp( line, lcid, 0, left, right, res1 );
6130 V_VT(left) |= VT_RESERVED;
6131 test_cmp( line, lcid, 0, left, right, res2 );
6132 V_VT(left) &= ~VT_RESERVED;
6133 V_VT(right) |= VT_RESERVED;
6134 test_cmp( line, lcid, 0, left, right, res3 );
6135 V_VT(left) |= VT_RESERVED;
6136 test_cmp( line, lcid, 0, left, right, res4 );
6137 ok_(__FILE__,line)(V_VT(left) & V_VT(right) & VT_RESERVED, "VT_RESERVED filtered out\n");
6140 /* ERROR from wingdi.h is interfering here */
6142 #define _VARCMP(vt1,val1,vtfl1,vt2,val2,vtfl2,lcid,flags,result) \
6143 V_##vt1(&left) = val1; V_VT(&left) = VT_##vt1 | vtfl1; \
6144 V_##vt2(&right) = val2; V_VT(&right) = VT_##vt2 | vtfl2; \
6145 test_cmp( __LINE__, lcid, flags, &left, &right, result )
6146 #define VARCMPEX(vt1,val1,vt2,val2,res1,res2,res3,res4) \
6147 V_##vt1(&left) = val1; V_VT(&left) = VT_##vt1; \
6148 V_##vt2(&right) = val2; V_VT(&right) = VT_##vt2; \
6149 test_cmpex( __LINE__, lcid, &left, &right, res1, res2, res3, res4 )
6150 #define VARCMP(vt1,val1,vt2,val2,result) \
6151 VARCMPEX(vt1,val1,vt2,val2,result,result,result,result)
6152 /* The above macros do not work for VT_NULL as NULL gets expanded first */
6153 #define V_NULL_ V_NULL
6154 #define VT_NULL_ VT_NULL
6156 static void test_VarCmp(void)
6158 VARIANT left, right;
6163 static const WCHAR szhuh[] = {'h','u','h','?','\0'};
6164 static const WCHAR sz2cents[] = {'2','c','e','n','t','s','\0'};
6165 static const WCHAR szempty[] = {'\0'};
6166 static const WCHAR sz0[] = {'0','\0'};
6167 static const WCHAR sz1[] = {'1','\0'};
6168 static const WCHAR sz7[] = {'7','\0'};
6169 static const WCHAR sz42[] = {'4','2','\0'};
6170 static const WCHAR sz1neg[] = {'-','1','\0'};
6171 static const WCHAR sz666neg[] = {'-','6','6','6','\0'};
6172 static const WCHAR sz1few[] = {'1','.','0','0','0','0','0','0','0','1','\0'};
6173 BSTR bstrhuh, bstrempty, bstr0, bstr1, bstr7, bstr42, bstr1neg, bstr666neg;
6174 BSTR bstr2cents, bstr1few;
6178 lcid = MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT);
6179 bstrempty = SysAllocString(szempty);
6180 bstrhuh = SysAllocString(szhuh);
6181 bstr2cents = SysAllocString(sz2cents);
6182 bstr0 = SysAllocString(sz0);
6183 bstr1 = SysAllocString(sz1);
6184 bstr7 = SysAllocString(sz7);
6185 bstr42 = SysAllocString(sz42);
6186 bstr1neg = SysAllocString(sz1neg);
6187 bstr666neg = SysAllocString(sz666neg);
6188 bstr1few = SysAllocString(sz1few);
6190 /* Test all possible flag/vt combinations & the resulting vt type */
6191 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
6193 VARTYPE leftvt, rightvt;
6195 for (leftvt = 0; leftvt <= VT_BSTR_BLOB; leftvt++)
6200 for (rightvt = 0; rightvt <= VT_BSTR_BLOB; rightvt++)
6203 HRESULT expect = VARCMP_EQ;
6207 memset(&left, 0, sizeof(left));
6208 memset(&right, 0, sizeof(right));
6209 V_VT(&left) = leftvt | ExtraFlags[i];
6210 if (leftvt == VT_BSTR) {
6211 V_BSTR(&left) = bstr1neg;
6212 if (ExtraFlags[i] & VT_RESERVED)
6217 V_VT(&right) = rightvt | ExtraFlags[i];
6218 if (rightvt == VT_BSTR) {
6219 V_BSTR(&right) = bstr1neg;
6220 if (ExtraFlags[i] & VT_RESERVED)
6226 /* Don't ask me why but native VarCmp cannot handle:
6227 VT_I1, VT_UI2, VT_UI4, VT_UINT and VT_UI8.
6228 VT_INT is only supported as left variant. Go figure.
6229 Tested with DCOM98, Win2k, WinXP */
6230 if (ExtraFlags[i] & VT_ARRAY || ExtraFlags[i] & VT_BYREF ||
6231 !IsValidVariantClearVT(leftvt, ExtraFlags[i] & ~VT_RESERVED) ||
6232 !IsValidVariantClearVT(rightvt, ExtraFlags[i] & ~VT_RESERVED) ||
6233 leftvt == VT_CLSID || rightvt == VT_CLSID ||
6234 leftvt == VT_DISPATCH || rightvt == VT_DISPATCH ||
6235 leftvt == VT_ERROR || rightvt == VT_ERROR ||
6236 leftvt == VT_RECORD || rightvt == VT_RECORD ||
6237 leftvt == VT_UNKNOWN || rightvt == VT_UNKNOWN ||
6238 leftvt == VT_VARIANT || rightvt == VT_VARIANT ||
6239 leftvt == VT_I1 || rightvt == VT_I1 ||
6240 leftvt == VT_UI2 || rightvt == VT_UI2 ||
6241 leftvt == VT_UI4 || rightvt == VT_UI4 ||
6242 leftvt == VT_UI8 || rightvt == VT_UI8 ||
6243 rightvt == VT_INT ||
6244 leftvt == VT_UINT || rightvt == VT_UINT) {
6248 if (leftvt == VT_ERROR && rightvt == VT_ERROR &&
6249 !(ExtraFlags[i] & ~VT_RESERVED)) {
6252 } else if (leftvt == VT_NULL || rightvt == VT_NULL)
6253 expect = VARCMP_NULL;
6254 else if (leftvt == VT_BSTR && rightvt == VT_BSTR)
6256 else if (leftvt == VT_BSTR && rightvt == VT_EMPTY)
6258 else if (leftvt == VT_EMPTY && rightvt == VT_BSTR)
6261 hres = pVarCmp(&left, &right, LOCALE_USER_DEFAULT, 0);
6263 ok(hres == DISP_E_TYPEMISMATCH || hres == DISP_E_BADVARTYPE,
6264 "VarCmp: %d|0x%X, %d|0x%X: Expected failure, got 0x%X\n",
6265 leftvt, ExtraFlags[i], rightvt, ExtraFlags[i], hres);
6268 "VarCmp: %d|0x%X, %d|0x%X: Expected 0x%X, got 0x%X\n",
6269 leftvt, ExtraFlags[i], rightvt, ExtraFlags[i], expect,
6276 /* VARCMP{,EX} run each 4 tests with a permutation of all posible
6277 input variants with (1) and without (0) VT_RESERVED set. The order
6278 of the permutations is (0,0); (1,0); (0,1); (1,1) */
6279 VARCMP(INT,4711,I2,4711,VARCMP_EQ);
6280 VARCMP(INT,4711,I2,-4711,VARCMP_GT);
6281 VARCMP(ERROR,0,ERROR,0,VARCMP_EQ);
6282 VARCMP(ERROR,0,UI1,0,DISP_E_TYPEMISMATCH);
6283 VARCMP(EMPTY,0,EMPTY,0,VARCMP_EQ);
6284 VARCMP(I4,1,R8,1.0,VARCMP_EQ);
6285 VARCMP(EMPTY,19,I2,0,VARCMP_EQ);
6286 ok(V_EMPTY(&left) == 19, "VT_EMPTY modified!\n");
6287 VARCMP(I4,1,UI1,1,VARCMP_EQ);
6288 VARCMP(I2,2,I2,2,VARCMP_EQ);
6289 VARCMP(I2,1,I2,2,VARCMP_LT);
6290 VARCMP(I2,2,I2,1,VARCMP_GT);
6291 VARCMP(I2,2,EMPTY,1,VARCMP_GT);
6292 VARCMP(I2,2,NULL_,1,VARCMP_NULL);
6294 /* BSTR handling, especially in conjunction with VT_RESERVED */
6295 VARCMP(BSTR,bstr0,NULL_,0,VARCMP_NULL);
6296 VARCMP(BSTR,bstr0,BSTR,bstr0,VARCMP_EQ);
6297 VARCMP(BSTR,bstrempty,BSTR,bstr0,VARCMP_LT);
6298 VARCMP(BSTR,bstr7,BSTR,bstr0,VARCMP_GT);
6299 VARCMP(BSTR,bstr7,BSTR,bstr1neg,VARCMP_GT);
6300 VARCMP(BSTR,bstr0,BSTR,NULL,VARCMP_GT);
6301 VARCMP(BSTR,NULL,BSTR,NULL,VARCMP_EQ);
6302 VARCMP(BSTR,bstrempty,BSTR,NULL,VARCMP_EQ);
6303 VARCMP(BSTR,NULL,EMPTY,0,VARCMP_EQ);
6304 VARCMP(EMPTY,0,BSTR,NULL,VARCMP_EQ);
6305 VARCMP(EMPTY,0,BSTR,bstrempty,VARCMP_EQ);
6306 VARCMP(EMPTY,1,BSTR,bstrempty,VARCMP_EQ);
6307 VARCMP(BSTR,bstr0,EMPTY,0,VARCMP_GT);
6308 VARCMP(BSTR,bstr42,EMPTY,0,VARCMP_GT);
6309 VARCMPEX(BSTR,bstrempty,UI1,0,VARCMP_GT,VARCMP_LT,VARCMP_GT,VARCMP_GT);
6310 VARCMPEX(BSTR,bstrempty,I2,-1,VARCMP_GT,VARCMP_LT,VARCMP_GT,VARCMP_GT);
6311 VARCMPEX(I4,0,BSTR,bstrempty,VARCMP_LT,VARCMP_LT,VARCMP_GT,VARCMP_LT);
6312 VARCMPEX(BSTR,NULL,UI1,0,VARCMP_GT,VARCMP_LT,VARCMP_GT,VARCMP_GT);
6313 VARCMPEX(I4,7,BSTR,NULL,VARCMP_LT,VARCMP_LT,VARCMP_GT,VARCMP_LT);
6314 _VARCMP(BSTR,(BSTR)100,0,I2,100,0,lcid,0,VARCMP_GT);
6315 VARCMPEX(BSTR,bstr0,UI1,0,VARCMP_GT,VARCMP_EQ,VARCMP_EQ,VARCMP_GT);
6316 VARCMPEX(I2,0,BSTR,bstr0,VARCMP_LT,VARCMP_EQ,VARCMP_EQ,VARCMP_LT);
6317 VARCMP(BSTR,bstrhuh,I4,I4_MAX,VARCMP_GT);
6318 VARCMP(BSTR,bstr2cents,I4,2,VARCMP_GT);
6319 VARCMPEX(BSTR,bstr2cents,I4,42,VARCMP_GT,VARCMP_LT,VARCMP_GT,VARCMP_GT);
6320 VARCMP(BSTR,bstr2cents,I4,-1,VARCMP_GT);
6321 VARCMPEX(BSTR,bstr2cents,I4,-666,VARCMP_GT,VARCMP_LT,VARCMP_GT,VARCMP_GT);
6322 VARCMPEX(BSTR,bstr0,I2,0,VARCMP_GT,VARCMP_EQ,VARCMP_EQ,VARCMP_GT);
6323 VARCMPEX(BSTR,bstr0,I4,0,VARCMP_GT,VARCMP_EQ,VARCMP_EQ,VARCMP_GT);
6324 VARCMPEX(BSTR,bstr0,I4,-666,VARCMP_GT,VARCMP_LT,VARCMP_GT,VARCMP_GT);
6325 VARCMP(BSTR,bstr1,I4,0,VARCMP_GT);
6326 VARCMPEX(BSTR,bstr1,I4,1,VARCMP_GT,VARCMP_EQ,VARCMP_EQ,VARCMP_GT);
6327 VARCMPEX(BSTR,bstr1,I4,I4_MAX,VARCMP_GT,VARCMP_LT,VARCMP_LT,VARCMP_GT);
6328 VARCMPEX(BSTR,bstr1,I4,-1,VARCMP_GT,VARCMP_LT,VARCMP_GT,VARCMP_GT);
6329 VARCMP(BSTR,bstr7,I4,1,VARCMP_GT);
6330 VARCMPEX(BSTR,bstr7,I4,7,VARCMP_GT,VARCMP_EQ,VARCMP_EQ,VARCMP_GT);
6331 VARCMPEX(BSTR,bstr7,I4,42,VARCMP_GT,VARCMP_GT,VARCMP_LT,VARCMP_GT);
6332 VARCMPEX(BSTR,bstr42,I4,7,VARCMP_GT,VARCMP_LT,VARCMP_GT,VARCMP_GT);
6333 VARCMPEX(BSTR,bstr42,I4,42,VARCMP_GT,VARCMP_EQ,VARCMP_EQ,VARCMP_GT);
6334 VARCMPEX(BSTR,bstr42,I4,I4_MAX,VARCMP_GT,VARCMP_GT,VARCMP_LT,VARCMP_GT);
6335 VARCMPEX(BSTR,bstr1neg,I4,1,VARCMP_GT,VARCMP_GT,VARCMP_LT,VARCMP_LT);
6336 VARCMPEX(BSTR,bstr1neg,I4,42,VARCMP_GT,VARCMP_LT,VARCMP_LT,VARCMP_LT);
6337 VARCMPEX(BSTR,bstr1neg,I4,-1,VARCMP_GT,VARCMP_EQ,VARCMP_EQ,VARCMP_LT);
6338 VARCMPEX(BSTR,bstr1neg,I4,-666,VARCMP_GT,VARCMP_LT,VARCMP_GT,VARCMP_LT);
6339 VARCMPEX(BSTR,bstr666neg,I4,1,VARCMP_GT,VARCMP_GT,VARCMP_LT,VARCMP_LT);
6340 VARCMPEX(BSTR,bstr666neg,I4,7,VARCMP_GT,VARCMP_LT,VARCMP_LT,VARCMP_LT);
6341 VARCMPEX(BSTR,bstr666neg,I4,42,VARCMP_GT,VARCMP_GT,VARCMP_LT,VARCMP_LT);
6342 VARCMPEX(BSTR,bstr666neg,I4,I4_MAX,VARCMP_GT,VARCMP_GT,VARCMP_LT,VARCMP_LT);
6343 VARCMPEX(BSTR,bstr666neg,I4,-1,VARCMP_GT,VARCMP_GT,VARCMP_LT,VARCMP_LT);
6344 VARCMPEX(BSTR,bstr666neg,I4,-666,VARCMP_GT,VARCMP_EQ,VARCMP_EQ,VARCMP_LT);
6345 VARCMPEX(BSTR,bstr7,R8,7.0,VARCMP_GT,VARCMP_EQ,VARCMP_EQ,VARCMP_GT);
6346 VARCMPEX(R8,3.141592,BSTR,NULL,VARCMP_LT,VARCMP_LT,VARCMP_GT,VARCMP_LT);
6347 VARCMP(BSTR,bstr7,BSTR,bstr7,VARCMP_EQ);
6348 VARCMP(BSTR,bstr7,BSTR,bstr42,VARCMP_GT);
6349 VARCMP(BSTR,bstr42,BSTR,bstr7,VARCMP_LT);
6351 /* DECIMAL handling */
6352 setdec(&dec,0,0,0,0);
6353 VARCMPEX(DECIMAL,dec,BSTR,bstr0,VARCMP_LT,VARCMP_EQ,VARCMP_EQ,VARCMP_LT);
6354 setdec64(&dec,0,0,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF); /* max DECIMAL */
6355 VARCMP(DECIMAL,dec,R8,R8_MAX,VARCMP_LT); /* R8 has bigger range */
6356 VARCMP(DECIMAL,dec,DATE,R8_MAX,VARCMP_LT); /* DATE has bigger range */
6357 setdec64(&dec,0,0x80,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF);
6358 VARCMP(DECIMAL,dec,R8,-R8_MAX,VARCMP_GT);
6359 setdec64(&dec,20,0,0x5,0x6BC75E2D,0x63100001); /* 1+1e-20 */
6360 VARCMP(DECIMAL,dec,R8,1,VARCMP_GT); /* DECIMAL has higher precision */
6362 /* Show that DATE is handled just as a R8 */
6363 VARCMP(DATE,DATE_MAX,DATE,DATE_MAX+1,VARCMP_LT);
6364 VARCMP(DATE,DATE_MIN,DATE,DATE_MIN-1,VARCMP_GT);
6365 VARCMP(DATE,R8_MIN,R8,R8_MIN,VARCMP_EQ);
6366 VARCMP(DATE,1,DATE,1+1e-15,VARCMP_LT); /* 1e-15 == 8.64e-11 seconds */
6367 VARCMP(DATE,25570.0,DATE,25570.0,VARCMP_EQ);
6368 VARCMP(DATE,25570.0,DATE,25571.0,VARCMP_LT);
6369 VARCMP(DATE,25571.0,DATE,25570.0,VARCMP_GT);
6370 VARCMP(DATE,25570.0,EMPTY,0,VARCMP_GT);
6371 VARCMP(DATE,25570.0,NULL_,0,VARCMP_NULL);
6373 /* R4 precision handling */
6374 VARCMP(R4,1,R8,1+1e-8,VARCMP_EQ);
6375 VARCMP(R8,1+1e-8,R4,1,VARCMP_EQ);
6376 VARCMP(R8,1+1e-8,R8,1,VARCMP_GT);
6377 VARCMP(R8,R4_MAX*1.1,R4,R4_MAX,VARCMP_GT);
6378 VARCMP(R4,R4_MAX,R8,R8_MAX,VARCMP_LT);
6379 VARCMP(R4,1,DATE,1+1e-8,VARCMP_EQ);
6380 VARCMP(R4,1,BSTR,bstr1few,VARCMP_LT); /* bstr1few == 1+1e-8 */
6381 setdec(&dec,8,0,0,0x5F5E101); /* 1+1e-8 */
6382 VARCMP(R4,1,DECIMAL,dec,VARCMP_LT);
6384 SysFreeString(bstrhuh);
6385 SysFreeString(bstrempty);
6386 SysFreeString(bstr0);
6387 SysFreeString(bstr1);
6388 SysFreeString(bstr7);
6389 SysFreeString(bstr42);
6390 SysFreeString(bstr1neg);
6391 SysFreeString(bstr666neg);
6392 SysFreeString(bstr2cents);
6393 SysFreeString(bstr1few);
6396 static HRESULT (WINAPI *pVarPow)(LPVARIANT,LPVARIANT,LPVARIANT);
6398 #define VARPOW(vt1,val1,vt2,val2,rvt,rval) \
6399 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
6400 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
6401 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
6402 test_var_call2( __LINE__, pVarPow, &left, &right, &exp )
6404 /* Skip any type that is not defined or produces an error for every case */
6405 #define SKIPTESTPOW(a) \
6406 if (a == VT_ERROR || a == VT_VARIANT || \
6407 a == VT_DISPATCH || a == VT_UNKNOWN || \
6408 a == VT_RECORD || a > VT_UINT || \
6409 a == 15 /*not defined*/) \
6412 static void test_VarPow(void)
6414 static const WCHAR str2[] = { '2','\0' };
6415 static const WCHAR str3[] = { '3','\0' };
6416 VARIANT left, right, exp, result, cy, dec;
6417 BSTR num2_str, num3_str;
6423 num2_str = SysAllocString(str2);
6424 num3_str = SysAllocString(str3);
6426 /* Test all possible flag/vt combinations & the resulting vt type */
6427 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
6429 VARTYPE leftvt, rightvt, resvt;
6431 for (leftvt = 0; leftvt <= VT_BSTR_BLOB; leftvt++)
6433 SKIPTESTPOW(leftvt);
6435 for (rightvt = 0; rightvt <= VT_BSTR_BLOB; rightvt++)
6438 SKIPTESTPOW(rightvt);
6440 /* Native crashes with VT_BYREF */
6441 if (ExtraFlags[i] == VT_BYREF)
6444 memset(&left, 0, sizeof(left));
6445 memset(&right, 0, sizeof(right));
6446 V_VT(&left) = leftvt | ExtraFlags[i];
6447 V_VT(&right) = rightvt | ExtraFlags[i];
6448 V_VT(&result) = VT_EMPTY;
6451 if (leftvt == VT_BSTR)
6452 V_BSTR(&left) = num2_str;
6453 if (rightvt == VT_BSTR)
6454 V_BSTR(&right) = num2_str;
6456 /* Native VarPow always returns an error when using extra flags */
6457 if (ExtraFlags[i] != 0)
6460 /* Determine return type */
6461 else if ((leftvt == VT_NULL || rightvt == VT_NULL) &&
6462 ((leftvt != VT_I8 && leftvt != VT_UI8 &&
6463 rightvt != VT_I8 && rightvt != VT_UI8) || HAVE_OLEAUT32_I8))
6465 else if ((leftvt == VT_EMPTY || leftvt == VT_I2 ||
6466 leftvt == VT_I4 || leftvt == VT_R4 ||
6467 leftvt == VT_R8 || leftvt == VT_CY ||
6468 leftvt == VT_DATE || leftvt == VT_BSTR ||
6469 leftvt == VT_BOOL || leftvt == VT_DECIMAL ||
6470 (leftvt >= VT_I1 && leftvt <= VT_UI4) ||
6471 (HAVE_OLEAUT32_I8 && (leftvt == VT_I8 || leftvt == VT_UI8)) ||
6472 leftvt == VT_INT || leftvt == VT_UINT) &&
6473 (rightvt == VT_EMPTY || rightvt == VT_I2 ||
6474 rightvt == VT_I4 || rightvt == VT_R4 ||
6475 rightvt == VT_R8 || rightvt == VT_CY ||
6476 rightvt == VT_DATE || rightvt == VT_BSTR ||
6477 rightvt == VT_BOOL || rightvt == VT_DECIMAL ||
6478 (rightvt >= VT_I1 && rightvt <= VT_UI4) ||
6479 (HAVE_OLEAUT32_I8 && (rightvt == VT_I8 || rightvt == VT_UI8)) ||
6480 rightvt == VT_INT || rightvt == VT_UINT))
6485 hres = pVarPow(&left, &right, &result);
6487 /* Check expected HRESULT and if result variant type is correct */
6489 ok (hres == DISP_E_BADVARTYPE || hres == DISP_E_TYPEMISMATCH,
6490 "VarPow: %s|0x%X, %s|0x%X: got vt %s hr 0x%X\n",
6491 vtstr(leftvt), ExtraFlags[i], vtstr(rightvt), ExtraFlags[i],
6492 vtstr(V_VT(&result)), hres);
6494 ok (hres == S_OK && resvt == V_VT(&result),
6495 "VarPow: %s|0x%X, %s|0x%X: expected vt %s hr 0x%X, got vt %s hr 0x%X\n",
6496 vtstr(leftvt), ExtraFlags[i], vtstr(rightvt), ExtraFlags[i], vtstr(resvt),
6497 S_OK, vtstr(V_VT(&result)), hres);
6502 /* Check return values for valid variant type combinations */
6503 VARPOW(EMPTY,0,EMPTY,0,R8,1.0);
6504 VARPOW(EMPTY,0,NULL,0,NULL,0);
6505 VARPOW(EMPTY,0,I2,3,R8,0.0);
6506 VARPOW(EMPTY,0,I4,3,R8,0.0);
6507 VARPOW(EMPTY,0,R4,3.0f,R8,0.0);
6508 VARPOW(EMPTY,0,R8,3.0,R8,0.0);
6509 VARPOW(EMPTY,0,DATE,3,R8,0.0);
6510 VARPOW(EMPTY,0,BSTR,num3_str,R8,0.0);
6511 VARPOW(EMPTY,0,BOOL,VARIANT_FALSE,R8,1.0);
6512 VARPOW(EMPTY,0,I1,3,R8,0.0);
6513 VARPOW(EMPTY,0,UI1,3,R8,0.0);
6514 VARPOW(EMPTY,0,UI2,3,R8,0.0);
6515 VARPOW(EMPTY,0,UI4,3,R8,0.0);
6516 if (HAVE_OLEAUT32_I8)
6518 VARPOW(EMPTY,0,I8,3,R8,0.0);
6519 VARPOW(EMPTY,0,UI8,3,R8,0.0);
6521 VARPOW(EMPTY,0,INT,3,R8,0.0);
6522 VARPOW(EMPTY,0,UINT,3,R8,0.0);
6523 VARPOW(NULL,0,EMPTY,0,NULL,0);
6524 VARPOW(NULL,0,NULL,0,NULL,0);
6525 VARPOW(NULL,0,I2,3,NULL,0);
6526 VARPOW(NULL,0,I4,3,NULL,0);
6527 VARPOW(NULL,0,R4,3.0f,NULL,0);
6528 VARPOW(NULL,0,R8,3.0,NULL,0);
6529 VARPOW(NULL,0,DATE,3,NULL,0);
6530 VARPOW(NULL,0,BSTR,num3_str,NULL,0);
6531 VARPOW(NULL,0,BOOL,VARIANT_TRUE,NULL,0);
6532 VARPOW(NULL,0,I1,3,NULL,0);
6533 VARPOW(NULL,0,UI1,3,NULL,0);
6534 VARPOW(NULL,0,UI2,3,NULL,0);
6535 VARPOW(NULL,0,UI4,3,NULL,0);
6536 if (HAVE_OLEAUT32_I8)
6538 VARPOW(NULL,0,I8,3,NULL,0);
6539 VARPOW(NULL,0,UI8,3,NULL,0);
6541 VARPOW(NULL,0,INT,3,NULL,0);
6542 VARPOW(NULL,0,UINT,3,NULL,0);
6543 VARPOW(I2,2,EMPTY,0,R8,1.0);
6544 VARPOW(I2,2,NULL,0,NULL,0);
6545 VARPOW(I2,2,I2,3,R8,8.0);
6546 VARPOW(I2,2,I4,3,R8,8.0);
6547 VARPOW(I2,2,R4,3.0f,R8,8.0);
6548 VARPOW(I2,2,R8,3.0,R8,8.0);
6549 VARPOW(I2,2,DATE,3,R8,8.0);
6550 VARPOW(I2,2,BSTR,num3_str,R8,8.0);
6551 VARPOW(I2,2,BOOL,VARIANT_FALSE,R8,1.0);
6552 VARPOW(I2,2,I1,3,R8,8.0);
6553 VARPOW(I2,2,UI1,3,R8,8.0);
6554 VARPOW(I2,2,UI2,3,R8,8.0);
6555 VARPOW(I2,2,UI4,3,R8,8.0);
6556 if (HAVE_OLEAUT32_I8)
6558 VARPOW(I2,2,I8,3,R8,8.0);
6559 VARPOW(I2,2,UI8,3,R8,8.0);
6561 VARPOW(I2,2,INT,3,R8,8.0);
6562 VARPOW(I2,2,UINT,3,R8,8.0);
6563 VARPOW(I4,2,EMPTY,0,R8,1.0);
6564 VARPOW(I4,2,NULL,0,NULL,0);
6565 VARPOW(I4,2,I2,3,R8,8.0);
6566 VARPOW(I4,2,I4,3,R8,8.0);
6567 VARPOW(I4,2,R4,3.0f,R8,8.0);
6568 VARPOW(I4,2,R8,3.0,R8,8.0);
6569 VARPOW(I4,2,DATE,3,R8,8.0);
6570 VARPOW(I4,2,BSTR,num3_str,R8,8.0);
6571 VARPOW(I4,2,BOOL,VARIANT_FALSE,R8,1.0);
6572 VARPOW(I4,2,I1,3,R8,8.0);
6573 VARPOW(I4,2,UI1,3,R8,8.0);
6574 VARPOW(I4,2,UI2,3,R8,8.0);
6575 VARPOW(I4,2,UI4,3,R8,8.0);
6576 if (HAVE_OLEAUT32_I8)
6578 VARPOW(I4,2,I8,3,R8,8.0);
6579 VARPOW(I4,2,UI8,3,R8,8.0);
6581 VARPOW(I4,2,INT,3,R8,8.0);
6582 VARPOW(I4,2,UINT,3,R8,8.0);
6583 VARPOW(R4,2,EMPTY,0,R8,1.0);
6584 VARPOW(R4,2,NULL,0,NULL,0);
6585 VARPOW(R4,2,I2,3,R8,8.0);
6586 VARPOW(R4,2,I4,3,R8,8.0);
6587 VARPOW(R4,2,R4,3.0f,R8,8.0);
6588 VARPOW(R4,2,R8,3.0,R8,8.0);
6589 VARPOW(R4,2,DATE,3,R8,8.0);
6590 VARPOW(R4,2,BSTR,num3_str,R8,8.0);
6591 VARPOW(R4,2,BOOL,VARIANT_FALSE,R8,1.0);
6592 VARPOW(R4,2,I1,3,R8,8.0);
6593 VARPOW(R4,2,UI1,3,R8,8.0);
6594 VARPOW(R4,2,UI2,3,R8,8.0);
6595 VARPOW(R4,2,UI4,3,R8,8.0);
6596 if (HAVE_OLEAUT32_I8)
6598 VARPOW(R4,2,I8,3,R8,8.0);
6599 VARPOW(R4,2,UI8,3,R8,8.0);
6601 VARPOW(R4,2,INT,3,R8,8.0);
6602 VARPOW(R4,2,UINT,3,R8,8.0);
6603 VARPOW(R8,2,EMPTY,0,R8,1.0);
6604 VARPOW(R8,2,NULL,0,NULL,0);
6605 VARPOW(R8,2,I2,3,R8,8.0);
6606 VARPOW(R8,2,I4,3,R8,8.0);
6607 VARPOW(R8,2,R4,3.0f,R8,8.0);
6608 VARPOW(R8,2,R8,3.0,R8,8.0);
6609 VARPOW(R8,2,DATE,3,R8,8.0);
6610 VARPOW(R8,2,BSTR,num3_str,R8,8.0);
6611 VARPOW(R8,2,BOOL,VARIANT_FALSE,R8,1.0);
6612 VARPOW(R8,2,I1,3,R8,8.0);
6613 VARPOW(R8,2,UI1,3,R8,8.0);
6614 VARPOW(R8,2,UI2,3,R8,8.0);
6615 VARPOW(R8,2,UI4,3,R8,8.0);
6616 if (HAVE_OLEAUT32_I8)
6618 VARPOW(R8,2,I8,3,R8,8.0);
6619 VARPOW(R8,2,UI8,3,R8,8.0);
6621 VARPOW(R8,2,INT,3,R8,8.0);
6622 VARPOW(R8,2,UINT,3,R8,8.0);
6623 VARPOW(DATE,2,EMPTY,0,R8,1.0);
6624 VARPOW(DATE,2,NULL,0,NULL,0);
6625 VARPOW(DATE,2,I2,3,R8,8.0);
6626 VARPOW(DATE,2,I4,3,R8,8.0);
6627 VARPOW(DATE,2,R4,3.0f,R8,8.0);
6628 VARPOW(DATE,2,R8,3.0,R8,8.0);
6629 VARPOW(DATE,2,DATE,3,R8,8.0);
6630 VARPOW(DATE,2,BSTR,num3_str,R8,8.0);
6631 VARPOW(DATE,2,BOOL,VARIANT_FALSE,R8,1.0);
6632 VARPOW(DATE,2,I1,3,R8,8.0);
6633 VARPOW(DATE,2,UI1,3,R8,8.0);
6634 VARPOW(DATE,2,UI2,3,R8,8.0);
6635 VARPOW(DATE,2,UI4,3,R8,8.0);
6636 if (HAVE_OLEAUT32_I8)
6638 VARPOW(DATE,2,I8,3,R8,8.0);
6639 VARPOW(DATE,2,UI8,3,R8,8.0);
6641 VARPOW(DATE,2,INT,3,R8,8.0);
6642 VARPOW(DATE,2,UINT,3,R8,8.0);
6643 VARPOW(BSTR,num2_str,EMPTY,0,R8,1.0);
6644 VARPOW(BSTR,num2_str,NULL,0,NULL,0);
6645 VARPOW(BSTR,num2_str,I2,3,R8,8.0);
6646 VARPOW(BSTR,num2_str,I4,3,R8,8.0);
6647 VARPOW(BSTR,num2_str,R4,3.0f,R8,8.0);
6648 VARPOW(BSTR,num2_str,R8,3.0,R8,8.0);
6649 VARPOW(BSTR,num2_str,DATE,3,R8,8.0);
6650 VARPOW(BSTR,num2_str,BSTR,num3_str,R8,8.0);
6651 VARPOW(BSTR,num2_str,BOOL,VARIANT_FALSE,R8,1.0);
6652 VARPOW(BSTR,num2_str,I1,3,R8,8.0);
6653 VARPOW(BSTR,num2_str,UI1,3,R8,8.0);
6654 VARPOW(BSTR,num2_str,UI2,3,R8,8.0);
6655 VARPOW(BSTR,num2_str,UI4,3,R8,8.0);
6656 if (HAVE_OLEAUT32_I8)
6658 VARPOW(BSTR,num2_str,I8,3,R8,8.0);
6659 VARPOW(BSTR,num2_str,UI8,3,R8,8.0);
6661 VARPOW(BSTR,num2_str,INT,3,R8,8.0);
6662 VARPOW(BSTR,num2_str,UINT,3,R8,8.0);
6663 VARPOW(BOOL,VARIANT_TRUE,EMPTY,0,R8,1.0);
6664 VARPOW(BOOL,VARIANT_TRUE,NULL,0,NULL,0);
6665 VARPOW(BOOL,VARIANT_TRUE,I2,3,R8,-1.0);
6666 VARPOW(BOOL,VARIANT_TRUE,I4,3,R8,-1.0);
6667 VARPOW(BOOL,VARIANT_TRUE,R4,3.0f,R8,-1.0);
6668 VARPOW(BOOL,VARIANT_TRUE,R8,3.0,R8,-1.0);
6669 VARPOW(BOOL,VARIANT_TRUE,DATE,3,R8,-1.0);
6670 VARPOW(BOOL,VARIANT_TRUE,BSTR,num3_str,R8,-1.0);
6671 VARPOW(BOOL,VARIANT_TRUE,BOOL,VARIANT_TRUE,R8,-1.0);
6672 VARPOW(BOOL,VARIANT_TRUE,I1,3,R8,-1.0);
6673 VARPOW(BOOL,VARIANT_TRUE,UI1,3,R8,-1.0);
6674 VARPOW(BOOL,VARIANT_TRUE,UI2,3,R8,-1.0);
6675 VARPOW(BOOL,VARIANT_TRUE,UI4,3,R8,-1.0);
6676 if (HAVE_OLEAUT32_I8)
6678 VARPOW(BOOL,VARIANT_TRUE,I8,3,R8,-1.0);
6679 VARPOW(BOOL,VARIANT_TRUE,UI8,3,R8,-1.0);
6681 VARPOW(BOOL,VARIANT_TRUE,INT,3,R8,-1.0);
6682 VARPOW(BOOL,VARIANT_TRUE,UINT,3,R8,-1.0);
6683 VARPOW(I1,2,EMPTY,0,R8,1.0);
6684 VARPOW(I1,2,NULL,0,NULL,0);
6685 VARPOW(I1,2,I2,3,R8,8.0);
6686 VARPOW(I1,2,I4,3,R8,8.0);
6687 VARPOW(I1,2,R4,3.0f,R8,8.0);
6688 VARPOW(I1,2,R8,3.0,R8,8.0);
6689 VARPOW(I1,2,DATE,3,R8,8.0);
6690 VARPOW(I1,2,BSTR,num3_str,R8,8.0);
6691 VARPOW(I1,2,BOOL,VARIANT_FALSE,R8,1.0);
6692 VARPOW(I1,2,I1,3,R8,8.0);
6693 VARPOW(I1,2,UI1,3,R8,8.0);
6694 VARPOW(I1,2,UI2,3,R8,8.0);
6695 VARPOW(I1,2,UI4,3,R8,8.0);
6696 if (HAVE_OLEAUT32_I8)
6698 VARPOW(I1,2,I8,3,R8,8.0);
6699 VARPOW(I1,2,UI8,3,R8,8.0);
6701 VARPOW(I1,2,INT,3,R8,8.0);
6702 VARPOW(I1,2,UINT,3,R8,8.0);
6703 VARPOW(UI1,2,EMPTY,0,R8,1.0);
6704 VARPOW(UI1,2,NULL,0,NULL,0);
6705 VARPOW(UI1,2,I2,3,R8,8.0);
6706 VARPOW(UI1,2,I4,3,R8,8.0);
6707 VARPOW(UI1,2,R4,3.0f,R8,8.0);
6708 VARPOW(UI1,2,R8,3.0,R8,8.0);
6709 VARPOW(UI1,2,DATE,3,R8,8.0);
6710 VARPOW(UI1,2,BSTR,num3_str,R8,8.0);
6711 VARPOW(UI1,2,BOOL,VARIANT_FALSE,R8,1.0);
6712 VARPOW(UI1,2,I1,3,R8,8.0);
6713 VARPOW(UI1,2,UI1,3,R8,8.0);
6714 VARPOW(UI1,2,UI2,3,R8,8.0);
6715 VARPOW(UI1,2,UI4,3,R8,8.0);
6716 if (HAVE_OLEAUT32_I8)
6718 VARPOW(UI1,2,I8,3,R8,8.0);
6719 VARPOW(UI1,2,UI8,3,R8,8.0);
6721 VARPOW(UI1,2,INT,3,R8,8.0);
6722 VARPOW(UI1,2,UINT,3,R8,8.0);
6723 VARPOW(UI2,2,EMPTY,0,R8,1.0);
6724 VARPOW(UI2,2,NULL,0,NULL,0);
6725 VARPOW(UI2,2,I2,3,R8,8.0);
6726 VARPOW(UI2,2,I4,3,R8,8.0);
6727 VARPOW(UI2,2,R4,3.0f,R8,8.0);
6728 VARPOW(UI2,2,R8,3.0,R8,8.0);
6729 VARPOW(UI2,2,DATE,3,R8,8.0);
6730 VARPOW(UI2,2,BSTR,num3_str,R8,8.0);
6731 VARPOW(UI2,2,BOOL,VARIANT_FALSE,R8,1.0);
6732 VARPOW(UI2,2,I1,3,R8,8.0);
6733 VARPOW(UI2,2,UI1,3,R8,8.0);
6734 VARPOW(UI2,2,UI2,3,R8,8.0);
6735 VARPOW(UI2,2,UI4,3,R8,8.0);
6736 if (HAVE_OLEAUT32_I8)
6738 VARPOW(UI2,2,I8,3,R8,8.0);
6739 VARPOW(UI2,2,UI8,3,R8,8.0);
6741 VARPOW(UI2,2,INT,3,R8,8.0);
6742 VARPOW(UI2,2,UINT,3,R8,8.0);
6743 VARPOW(UI4,2,EMPTY,0,R8,1.0);
6744 VARPOW(UI4,2,NULL,0,NULL,0);
6745 VARPOW(UI4,2,I2,3,R8,8.0);
6746 VARPOW(UI4,2,I4,3,R8,8.0);
6747 VARPOW(UI4,2,R4,3.0f,R8,8.0);
6748 VARPOW(UI4,2,R8,3.0,R8,8.0);
6749 VARPOW(UI4,2,DATE,3,R8,8.0);
6750 VARPOW(UI4,2,BSTR,num3_str,R8,8.0);
6751 VARPOW(UI4,2,BOOL,VARIANT_FALSE,R8,1.0);
6752 VARPOW(UI4,2,I1,3,R8,8.0);
6753 VARPOW(UI4,2,UI1,3,R8,8.0);
6754 VARPOW(UI4,2,UI2,3,R8,8.0);
6755 VARPOW(UI4,2,UI4,3,R8,8.0);
6756 if (HAVE_OLEAUT32_I8)
6758 VARPOW(UI4,2,I8,3,R8,8.0);
6759 VARPOW(UI4,2,UI8,3,R8,8.0);
6761 VARPOW(UI4,2,INT,3,R8,8.0);
6762 VARPOW(UI4,2,UINT,3,R8,8.0);
6763 if (HAVE_OLEAUT32_I8)
6765 VARPOW(I8,2,EMPTY,0,R8,1.0);
6766 VARPOW(I8,2,NULL,0,NULL,0);
6767 VARPOW(I8,2,I2,3,R8,8.0);
6768 VARPOW(I8,2,I4,3,R8,8.0);
6769 VARPOW(I8,2,R4,3.0f,R8,8.0);
6770 VARPOW(I8,2,R8,3.0,R8,8.0);
6771 VARPOW(I8,2,DATE,3,R8,8.0);
6772 VARPOW(I8,2,BSTR,num3_str,R8,8.0);
6773 VARPOW(I8,2,BOOL,VARIANT_FALSE,R8,1.0);
6774 VARPOW(I8,2,I1,3,R8,8.0);
6775 VARPOW(I8,2,UI1,3,R8,8.0);
6776 VARPOW(I8,2,UI2,3,R8,8.0);
6777 VARPOW(I8,2,UI4,3,R8,8.0);
6778 VARPOW(I8,2,I8,3,R8,8.0);
6779 VARPOW(I8,2,UI8,3,R8,8.0);
6780 VARPOW(I8,2,INT,3,R8,8.0);
6781 VARPOW(I8,2,UINT,3,R8,8.0);
6782 VARPOW(UI8,2,EMPTY,0,R8,1.0);
6783 VARPOW(UI8,2,NULL,0,NULL,0);
6784 VARPOW(UI8,2,I2,3,R8,8.0);
6785 VARPOW(UI8,2,I4,3,R8,8.0);
6786 VARPOW(UI8,2,R4,3.0f,R8,8.0);
6787 VARPOW(UI8,2,R8,3.0,R8,8.0);
6788 VARPOW(UI8,2,DATE,3,R8,8.0);
6789 VARPOW(UI8,2,BSTR,num3_str,R8,8.0);
6790 VARPOW(UI8,2,I1,3,R8,8.0);
6791 VARPOW(UI8,2,UI1,3,R8,8.0);
6792 VARPOW(UI8,2,UI2,3,R8,8.0);
6793 VARPOW(UI8,2,UI4,3,R8,8.0);
6794 VARPOW(UI8,2,I8,3,R8,8.0);
6795 VARPOW(UI8,2,UI8,3,R8,8.0);
6796 VARPOW(UI8,2,INT,3,R8,8.0);
6797 VARPOW(UI8,2,UINT,3,R8,8.0);
6799 VARPOW(INT,2,EMPTY,0,R8,1.0);
6800 VARPOW(INT,2,NULL,0,NULL,0);
6801 VARPOW(INT,2,I2,3,R8,8.0);
6802 VARPOW(INT,2,I4,3,R8,8.0);
6803 VARPOW(INT,2,R4,3.0f,R8,8.0);
6804 VARPOW(INT,2,R8,3.0,R8,8.0);
6805 VARPOW(INT,2,DATE,3,R8,8.0);
6806 VARPOW(INT,2,BSTR,num3_str,R8,8.0);
6807 VARPOW(INT,2,BOOL,VARIANT_FALSE,R8,1.0);
6808 VARPOW(INT,2,I1,3,R8,8.0);
6809 VARPOW(INT,2,UI1,3,R8,8.0);
6810 VARPOW(INT,2,UI2,3,R8,8.0);
6811 VARPOW(INT,2,UI4,3,R8,8.0);
6812 if (HAVE_OLEAUT32_I8)
6814 VARPOW(INT,2,I8,3,R8,8.0);
6815 VARPOW(INT,2,UI8,3,R8,8.0);
6817 VARPOW(INT,2,INT,3,R8,8.0);
6818 VARPOW(INT,2,UINT,3,R8,8.0);
6819 VARPOW(UINT,2,EMPTY,0,R8,1.0);
6820 VARPOW(UINT,2,NULL,0,NULL,0);
6821 VARPOW(UINT,2,I2,3,R8,8.0);
6822 VARPOW(UINT,2,I4,3,R8,8.0);
6823 VARPOW(UINT,2,R4,3.0f,R8,8.0);
6824 VARPOW(UINT,2,R8,3.0,R8,8.0);
6825 VARPOW(UINT,2,DATE,3,R8,8.0);
6826 VARPOW(UINT,2,BSTR,num3_str,R8,8.0);
6827 VARPOW(UINT,2,BOOL,VARIANT_FALSE,R8,1.0);
6828 VARPOW(UINT,2,I1,3,R8,8.0);
6829 VARPOW(UINT,2,UI1,3,R8,8.0);
6830 VARPOW(UINT,2,UI2,3,R8,8.0);
6831 VARPOW(UINT,2,UI4,3,R8,8.0);
6832 if (HAVE_OLEAUT32_I8)
6834 VARPOW(UINT,2,I8,3,R8,8.0);
6835 VARPOW(UINT,2,UI8,3,R8,8.0);
6837 VARPOW(UINT,2,INT,3,R8,8.0);
6838 VARPOW(UINT,2,UINT,3,R8,8.0);
6840 /* Manually test some VT_CY, VT_DECIMAL variants */
6842 hres = VarCyFromI4(2, &V_CY(&cy));
6843 ok(hres == S_OK, "VarCyFromI4 failed!\n");
6844 V_VT(&dec) = VT_DECIMAL;
6845 hres = VarDecFromR8(2.0, &V_DECIMAL(&dec));
6846 ok(hres == S_OK, "VarDecFromR4 failed!\n");
6847 memset(&left, 0, sizeof(left));
6848 memset(&right, 0, sizeof(right));
6849 V_VT(&left) = VT_I4;
6851 V_VT(&right) = VT_I8;
6854 hres = pVarPow(&cy, &cy, &result);
6855 ok(hres == S_OK && V_VT(&result) == VT_R8,
6856 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
6857 S_OK, hres, vtstr(V_VT(&result)));
6858 ok(hres == S_OK && EQ_DOUBLE(V_R8(&result), 4.0),
6859 "VARPOW: CY value %f, expected %f\n", V_R8(&result), 4.0);
6861 hres = pVarPow(&cy, &right, &result);
6862 ok(hres == S_OK && V_VT(&result) == VT_R8,
6863 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
6864 S_OK, hres, vtstr(V_VT(&result)));
6865 ok(hres == S_OK && EQ_DOUBLE(V_R8(&result), 4.0),
6866 "VARPOW: CY value %f, expected %f\n", V_R8(&result), 4.0);
6868 hres = pVarPow(&left, &cy, &result);
6869 ok(hres == S_OK && V_VT(&result) == VT_R8,
6870 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
6871 S_OK, hres, vtstr(V_VT(&result)));
6872 ok(hres == S_OK && EQ_DOUBLE(V_R8(&result), 10000.0),
6873 "VARPOW: CY value %f, expected %f\n", V_R8(&result), 10000.0);
6875 hres = pVarPow(&left, &dec, &result);
6876 ok(hres == S_OK && V_VT(&result) == VT_R8,
6877 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
6878 S_OK, hres, vtstr(V_VT(&result)));
6879 ok(hres == S_OK && EQ_DOUBLE(V_R8(&result),10000.0),
6880 "VARPOW: DECIMAL value %f, expected %f\n", V_R8(&result), 10000.0);
6882 hres = pVarPow(&dec, &dec, &result);
6883 ok(hres == S_OK && V_VT(&result) == VT_R8,
6884 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
6885 S_OK, hres, vtstr(V_VT(&result)));
6886 ok(hres == S_OK && EQ_DOUBLE(V_R8(&result), 4.0),
6887 "VARPOW: DECIMAL value %f, expected %f\n", V_R8(&result), 4.0);
6889 hres = pVarPow(&dec, &right, &result);
6890 ok(hres == S_OK && V_VT(&result) == VT_R8,
6891 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
6892 S_OK, hres, vtstr(V_VT(&result)));
6893 ok(hres == S_OK && EQ_DOUBLE(V_R8(&result), 4.0),
6894 "VARPOW: DECIMAL value %f, expected %f\n", V_R8(&result), 4.0);
6896 SysFreeString(num2_str);
6897 SysFreeString(num3_str);
6900 static HRESULT (WINAPI *pVarDiv)(LPVARIANT,LPVARIANT,LPVARIANT);
6902 #define VARDIV(vt1,val1,vt2,val2,rvt,rval) \
6903 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
6904 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
6905 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
6906 test_var_call2( __LINE__, pVarDiv, &left, &right, &exp )
6908 /* Skip any type that is not defined or produces an error for every case */
6909 #define SKIPTESTDIV(a) \
6910 if (a == VT_ERROR || a == VT_VARIANT || \
6911 a == VT_DISPATCH || a == VT_UNKNOWN || \
6912 a == VT_RECORD || a > VT_UINT || \
6913 a == VT_I1 || a == VT_UI8 || \
6914 a == VT_INT || a == VT_UINT || \
6915 a == VT_UI2 || a == VT_UI4 || \
6916 a == 15 /*not defined*/) \
6919 static void test_VarDiv(void)
6921 static const WCHAR str1[] = { '1','\0' };
6922 static const WCHAR str2[] = { '2','\0' };
6923 VARIANT left, right, exp, result, cy, dec;
6924 BSTR num1_str, num2_str;
6926 HRESULT hres, expectedhres;
6929 num1_str = SysAllocString(str1);
6930 num2_str = SysAllocString(str2);
6934 /* Test all possible flag/vt combinations & the resulting vt type */
6935 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
6937 VARTYPE leftvt, rightvt, resvt;
6939 for (leftvt = 0; leftvt <= VT_BSTR_BLOB; leftvt++)
6941 SKIPTESTDIV(leftvt);
6943 /* Check if we need/have support for I8 */
6944 if (leftvt == VT_I8 && !HAVE_OLEAUT32_I8)
6947 for (rightvt = 0; rightvt <= VT_BSTR_BLOB; rightvt++)
6950 SKIPTESTDIV(rightvt);
6952 /* Check if we need/have support for I8 */
6953 if (rightvt == VT_I8 && !HAVE_OLEAUT32_I8)
6956 /* Native crashes with VT_BYREF */
6957 if (ExtraFlags[i] == VT_BYREF)
6960 memset(&left, 0, sizeof(left));
6961 memset(&right, 0, sizeof(right));
6962 V_VT(&left) = leftvt | ExtraFlags[i];
6963 V_VT(&right) = rightvt | ExtraFlags[i];
6964 V_VT(&result) = VT_EMPTY;
6966 expectedhres = S_OK;
6968 if (leftvt == VT_BSTR)
6969 V_BSTR(&left) = num2_str;
6970 else if (leftvt == VT_DECIMAL)
6972 VarDecFromR8(2.0, &V_DECIMAL(&left));
6973 V_VT(&left) = leftvt | ExtraFlags[i];
6976 /* Division by 0 is undefined */
6980 V_BSTR(&right) = num2_str;
6983 VarDecFromR8(2.0, &V_DECIMAL(&right));
6984 V_VT(&right) = rightvt | ExtraFlags[i];
6987 V_BOOL(&right) = VARIANT_TRUE;
6989 case VT_I2: V_I2(&right) = 2; break;
6990 case VT_I4: V_I4(&right) = 2; break;
6991 case VT_R4: V_R4(&right) = 2.0f; break;
6992 case VT_R8: V_R8(&right) = 2.0; break;
6993 case VT_CY: V_CY(&right).int64 = 2; break;
6994 case VT_DATE: V_DATE(&right) = 2; break;
6995 case VT_UI1: V_UI1(&right) = 2; break;
6996 case VT_I8: V_I8(&right) = 2; break;
7000 /* Determine return type */
7001 if (!(rightvt == VT_EMPTY))
7003 if (leftvt == VT_NULL || rightvt == VT_NULL)
7005 else if (leftvt == VT_DECIMAL || rightvt == VT_DECIMAL)
7007 else if (leftvt == VT_I8 || rightvt == VT_I8 ||
7008 leftvt == VT_CY || rightvt == VT_CY ||
7009 leftvt == VT_DATE || rightvt == VT_DATE ||
7010 leftvt == VT_I4 || rightvt == VT_I4 ||
7011 leftvt == VT_BSTR || rightvt == VT_BSTR ||
7012 leftvt == VT_I2 || rightvt == VT_I2 ||
7013 leftvt == VT_BOOL || rightvt == VT_BOOL ||
7014 leftvt == VT_R8 || rightvt == VT_R8 ||
7015 leftvt == VT_UI1 || rightvt == VT_UI1)
7017 if ((leftvt == VT_UI1 && rightvt == VT_R4) ||
7018 (leftvt == VT_R4 && rightvt == VT_UI1))
7020 else if ((leftvt == VT_R4 && (rightvt == VT_BOOL ||
7021 rightvt == VT_I2)) || (rightvt == VT_R4 &&
7022 (leftvt == VT_BOOL || leftvt == VT_I2)))
7027 else if (leftvt == VT_R4 || rightvt == VT_R4)
7030 else if (leftvt == VT_NULL && rightvt == VT_EMPTY)
7035 /* Native VarDiv always returns an error when using extra flags */
7036 if (ExtraFlags[i] != 0)
7039 hres = pVarDiv(&left, &right, &result);
7041 /* Check expected HRESULT and if result variant type is correct */
7043 ok (hres == DISP_E_BADVARTYPE || hres == DISP_E_TYPEMISMATCH ||
7044 hres == DISP_E_OVERFLOW || hres == DISP_E_DIVBYZERO,
7045 "VarDiv: %s|0x%X, %s|0x%X: got vt %s hr 0x%X\n",
7046 vtstr(leftvt), ExtraFlags[i], vtstr(rightvt), ExtraFlags[i],
7047 vtstr(V_VT(&result)), hres);
7049 ok (hres == S_OK && resvt == V_VT(&result),
7050 "VarDiv: %s|0x%X, %s|0x%X: expected vt %s hr 0x%X, got vt %s hr 0x%X\n",
7051 vtstr(leftvt), ExtraFlags[i], vtstr(rightvt), ExtraFlags[i], vtstr(resvt),
7052 S_OK, vtstr(V_VT(&result)), hres);
7057 /* Test return values for all the good cases */
7058 VARDIV(EMPTY,0,NULL,0,NULL,0);
7059 VARDIV(EMPTY,0,I2,2,R8,0.0);
7060 VARDIV(EMPTY,0,I4,2,R8,0.0);
7061 VARDIV(EMPTY,0,R4,2.0f,R4,0.0f);
7062 VARDIV(EMPTY,0,R8,2.0,R8,0.0);
7063 VARDIV(EMPTY,0,DATE,2.0,R8,0.0);
7064 VARDIV(EMPTY,0,BSTR,num2_str,R8,0.0);
7065 VARDIV(EMPTY,0,BOOL,VARIANT_TRUE,R8,0.0);
7066 VARDIV(EMPTY,0,UI1,2,R8,0.0);
7067 if (HAVE_OLEAUT32_I8)
7069 VARDIV(EMPTY,0,I8,2,R8,0.0);
7071 VARDIV(NULL,0,EMPTY,0,NULL,0);
7072 VARDIV(NULL,0,NULL,0,NULL,0);
7073 VARDIV(NULL,0,I2,2,NULL,0);
7074 VARDIV(NULL,0,I4,2,NULL,0);
7075 VARDIV(NULL,0,R4,2.0f,NULL,0);
7076 VARDIV(NULL,0,R8,2.0,NULL,0);
7077 VARDIV(NULL,0,DATE,2,NULL,0);
7078 VARDIV(NULL,0,BSTR,num2_str,NULL,0);
7079 VARDIV(NULL,0,BOOL,VARIANT_TRUE,NULL,0);
7080 VARDIV(NULL,0,UI1,2,NULL,0);
7081 if (HAVE_OLEAUT32_I8)
7083 VARDIV(NULL,0,I8,2,NULL,0);
7085 VARDIV(I2,2,NULL,0,NULL,0);
7086 VARDIV(I2,1,I2,2,R8,0.5);
7087 VARDIV(I2,1,I4,2,R8,0.5);
7088 VARDIV(I2,1,R4,2,R4,0.5f);
7089 VARDIV(I2,1,R8,2.0,R8,0.5);
7090 VARDIV(I2,1,DATE,2,R8,0.5);
7091 VARDIV(I2,1,BOOL,VARIANT_TRUE,R8,-1.0);
7092 VARDIV(I2,1,UI1,2,R8,0.5);
7093 if (HAVE_OLEAUT32_I8)
7095 VARDIV(I2,1,I8,2,R8,0.5);
7097 VARDIV(I4,1,NULL,0,NULL,0);
7098 VARDIV(I4,1,I2,2,R8,0.5);
7099 VARDIV(I4,1,I4,2,R8,0.5);
7100 VARDIV(I4,1,R4,2.0f,R8,0.5);
7101 VARDIV(I4,1,R8,2.0,R8,0.5);
7102 VARDIV(I4,1,DATE,2,R8,0.5);
7103 VARDIV(I4,1,BSTR,num2_str,R8,0.5);
7104 VARDIV(I4,1,BOOL,VARIANT_TRUE,R8,-1.0);
7105 VARDIV(I4,1,UI1,2,R8,0.5);
7106 if (HAVE_OLEAUT32_I8)
7108 VARDIV(I4,1,I8,2,R8,0.5);
7110 VARDIV(R4,1.0f,NULL,0,NULL,0);
7111 VARDIV(R4,1.0f,I2,2,R4,0.5f);
7112 VARDIV(R4,1.0f,I4,2,R8,0.5);
7113 VARDIV(R4,1.0f,R4,2.0f,R4,0.5f);
7114 VARDIV(R4,1.0f,R8,2.0,R8,0.5);
7115 VARDIV(R4,1.0f,DATE,2,R8,0.5);
7116 VARDIV(R4,1.0f,BSTR,num2_str,R8,0.5);
7117 VARDIV(R4,1.0f,BOOL,VARIANT_TRUE,R4,-1);
7118 VARDIV(R4,1.0f,UI1,2,R4,0.5f);
7119 if (HAVE_OLEAUT32_I8)
7121 VARDIV(R4,1.0f,I8,2,R8,0.5);
7123 VARDIV(R8,1.0,NULL,0,NULL,0);
7124 VARDIV(R8,1.0,I2,2,R8,0.5);
7125 VARDIV(R8,1.0,I4,2,R8,0.5);
7126 VARDIV(R8,1.0,R4,2.0f,R8,0.5);
7127 VARDIV(R8,1.0,R8,2.0,R8,0.5);
7128 VARDIV(R8,1.0,DATE,2,R8,0.5);
7129 VARDIV(R8,1.0,BSTR,num2_str,R8,0.5);
7130 VARDIV(R8,1.0,BOOL,VARIANT_TRUE,R8,-1.0);
7131 VARDIV(R8,1.0,UI1,2,R8,0.5);
7132 if (HAVE_OLEAUT32_I8)
7134 VARDIV(R8,1.0,I8,2,R8,0.5);
7136 VARDIV(DATE,1,NULL,0,NULL,0);
7137 VARDIV(DATE,1,I2,2,R8,0.5);
7138 VARDIV(DATE,1,I4,2,R8,0.5);
7139 VARDIV(DATE,1,R4,2.0f,R8,0.5);
7140 VARDIV(DATE,1,R8,2.0,R8,0.5);
7141 VARDIV(DATE,1,DATE,2,R8,0.5);
7142 VARDIV(DATE,1,BSTR,num2_str,R8,0.5);
7143 VARDIV(DATE,1,BOOL,VARIANT_TRUE,R8,-1.0);
7144 VARDIV(DATE,1,UI1,2,R8,0.5);
7145 if (HAVE_OLEAUT32_I8)
7147 VARDIV(DATE,1,I8,2,R8,0.5);
7149 VARDIV(BSTR,num1_str,NULL,0,NULL,0);
7150 VARDIV(BSTR,num1_str,I2,2,R8,0.5);
7151 VARDIV(BSTR,num1_str,I4,2,R8,0.5);
7152 VARDIV(BSTR,num1_str,R4,2.0f,R8,0.5);
7153 VARDIV(BSTR,num1_str,R8,2.0,R8,0.5);
7154 VARDIV(BSTR,num1_str,DATE,2,R8,0.5);
7155 VARDIV(BSTR,num1_str,BSTR,num2_str,R8,0.5);
7156 VARDIV(BSTR,num1_str,BOOL,VARIANT_TRUE,R8,-1);
7157 VARDIV(BSTR,num1_str,UI1,2,R8,0.5);
7158 if (HAVE_OLEAUT32_I8)
7160 VARDIV(BSTR,num1_str,I8,2,R8,0.5);
7162 VARDIV(BOOL,VARIANT_TRUE,NULL,0,NULL,0);
7163 VARDIV(BOOL,VARIANT_TRUE,I2,1,R8,-1.0);
7164 VARDIV(BOOL,VARIANT_FALSE,I2,1,R8,0.0);
7165 VARDIV(BOOL,VARIANT_TRUE,I4,1,R8,-1.0);
7166 VARDIV(BOOL,VARIANT_FALSE,I4,1,R8,0.0);
7167 VARDIV(BOOL,VARIANT_TRUE,R4,1,R4,-1.0f);
7168 VARDIV(BOOL,VARIANT_FALSE,R4,1,R4,0.0f);
7169 VARDIV(BOOL,VARIANT_TRUE,R8,1.0,R8,-1.0);
7170 VARDIV(BOOL,VARIANT_FALSE,R8,1.0,R8,0.0);
7171 VARDIV(BOOL,VARIANT_FALSE,DATE,2,R8,0.0);
7172 VARDIV(BOOL,VARIANT_FALSE,BSTR,num2_str,R8,0.0);
7173 VARDIV(BOOL,VARIANT_TRUE,BOOL,VARIANT_TRUE,R8,1.0);
7174 VARDIV(BOOL,VARIANT_FALSE,BOOL,VARIANT_TRUE,R8,0.0);
7175 VARDIV(BOOL,VARIANT_TRUE,UI1,1,R8,-1.0);
7176 if (HAVE_OLEAUT32_I8)
7178 VARDIV(BOOL,VARIANT_TRUE,I8,1,R8,-1.0);
7180 VARDIV(UI1,1,NULL,0,NULL,0);
7181 VARDIV(UI1,1,I2,2,R8,0.5);
7182 VARDIV(UI1,1,I4,2,R8,0.5);
7183 VARDIV(UI1,1,R4,2.0f,R4,0.5f);
7184 VARDIV(UI1,1,R8,2.0,R8,0.5);
7185 VARDIV(UI1,1,DATE,2,R8,0.5);
7186 VARDIV(UI1,1,BSTR,num2_str,R8,0.5);
7187 VARDIV(UI1,1,BOOL,VARIANT_TRUE,R8,-1);
7188 VARDIV(UI1,1,UI1,2,R8,0.5);
7189 if (HAVE_OLEAUT32_I8)
7191 VARDIV(UI1,1,I8,2,R8,0.5);
7192 VARDIV(I8,1,NULL,0,NULL,0);
7193 VARDIV(I8,1,I2,2,R8,0.5);
7194 VARDIV(I8,1,I4,2,R8,0.5);
7195 VARDIV(I8,1,R4,2.0f,R8,0.5);
7196 VARDIV(I8,1,R8,2.0,R8,0.5);
7197 VARDIV(I8,1,DATE,2,R8,0.5);
7198 VARDIV(I8,1,BSTR,num2_str,R8,0.5);
7199 VARDIV(I8,1,BOOL,VARIANT_TRUE,R8,-1);
7200 VARDIV(I8,1,UI1,2,R8,0.5);
7201 VARDIV(I8,1,I8,2,R8,0.5);
7204 /* Manually test some VT_CY, VT_DECIMAL variants */
7206 hres = VarCyFromI4(10000, &V_CY(&cy));
7207 ok(hres == S_OK, "VarCyFromI4 failed!\n");
7208 V_VT(&dec) = VT_DECIMAL;
7209 hres = VarDecFromR8(2.0, &V_DECIMAL(&dec));
7210 ok(hres == S_OK, "VarDecFromR4 failed!\n");
7211 memset(&left, 0, sizeof(left));
7212 memset(&right, 0, sizeof(right));
7213 V_VT(&left) = VT_I4;
7215 V_VT(&right) = VT_UI1;
7218 hres = pVarDiv(&cy, &cy, &result);
7219 ok(hres == S_OK && V_VT(&result) == VT_R8,
7220 "VARDIV: expected coerced type VT_R8, got %s!\n", vtstr(V_VT(&result)));
7221 ok(hres == S_OK && EQ_DOUBLE(V_R8(&result), 1.0),
7222 "VARDIV: CY value %f, expected %f\n", V_R8(&result), (double)1.0);
7224 hres = pVarDiv(&cy, &right, &result);
7225 ok(hres == S_OK && V_VT(&result) == VT_R8,
7226 "VARDIV: expected coerced type VT_R8, got %s!\n", vtstr(V_VT(&result)));
7227 ok(hres == S_OK && EQ_DOUBLE(V_R8(&result), 5000.0),
7228 "VARDIV: CY value %f, expected %f\n", V_R8(&result), (double)5000.0);
7230 hres = pVarDiv(&left, &cy, &result);
7231 ok(hres == S_OK && V_VT(&result) == VT_R8,
7232 "VARDIV: expected coerced type VT_R8, got %s!\n", vtstr(V_VT(&result)));
7233 ok(hres == S_OK && EQ_DOUBLE(V_R8(&result), 0.01),
7234 "VARDIV: CY value %f, expected %f\n", V_R8(&result), (double)0.01);
7236 hres = pVarDiv(&left, &dec, &result);
7237 ok(hres == S_OK && V_VT(&result) == VT_DECIMAL,
7238 "VARDIV: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result)));
7239 hres = VarR8FromDec(&V_DECIMAL(&result), &r);
7240 ok(hres == S_OK && EQ_DOUBLE(r, 50.0),
7241 "VARDIV: DECIMAL value %f, expected %f\n", r, (double)50.0);
7243 hres = pVarDiv(&dec, &dec, &result);
7244 ok(hres == S_OK && V_VT(&result) == VT_DECIMAL,
7245 "VARDIV: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result)));
7246 hres = VarR8FromDec(&V_DECIMAL(&result), &r);
7247 ok(hres == S_OK && EQ_DOUBLE(r, 1.0),
7248 "VARDIV: DECIMAL value %f, expected %f\n", r, (double)1.0);
7250 hres = pVarDiv(&dec, &right, &result);
7251 ok(hres == S_OK && V_VT(&result) == VT_DECIMAL,
7252 "VARDIV: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result)));
7253 hres = VarR8FromDec(&V_DECIMAL(&result), &r);
7254 ok(hres == S_OK && EQ_DOUBLE(r, 1.0),
7255 "VARDIV: DECIMAL value %f, expected %f\n", r, (double)1.0);
7257 /* Check for division by zero and overflow */
7258 V_VT(&left) = VT_R8;
7260 V_VT(&right) = VT_R8;
7262 hres = pVarDiv(&left, &right, &result);
7263 ok(hres == DISP_E_DIVBYZERO && V_VT(&result) == VT_EMPTY,
7264 "VARDIV: Division by (1.0/0.0) should result in DISP_E_DIVBYZERO but got 0x%X\n", hres);
7266 V_VT(&left) = VT_R8;
7268 V_VT(&right) = VT_R8;
7270 hres = pVarDiv(&left, &right, &result);
7271 ok(hres == DISP_E_OVERFLOW && V_VT(&result) == VT_EMPTY,
7272 "VARDIV: Division by (0.0/0.0) should result in DISP_E_OVERFLOW but got 0x%X\n", hres);
7274 SysFreeString(num1_str);
7275 SysFreeString(num2_str);
7278 static HRESULT (WINAPI *pVarIdiv)(LPVARIANT,LPVARIANT,LPVARIANT);
7280 #define VARIDIV(vt1,val1,vt2,val2,rvt,rval) \
7281 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
7282 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
7283 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
7284 test_var_call2( __LINE__, pVarIdiv, &left, &right, &exp )
7286 /* Skip any type that is not defined or produces an error for every case */
7287 #define SKIPTESTIDIV(a) \
7288 if (a == VT_ERROR || a == VT_VARIANT || \
7289 a == VT_DISPATCH || a == VT_UNKNOWN || \
7290 a == VT_RECORD || a > VT_UINT || \
7291 a == 15 /*not defined*/) \
7294 static void test_VarIdiv(void)
7296 static const WCHAR str1[] = { '1','\0' };
7297 static const WCHAR str2[] = { '2','\0' };
7298 VARIANT left, right, exp, result, cy, dec;
7299 BSTR num1_str, num2_str;
7305 num1_str = SysAllocString(str1);
7306 num2_str = SysAllocString(str2);
7308 /* Test all possible flag/vt combinations & the resulting vt type */
7309 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
7311 VARTYPE leftvt, rightvt, resvt;
7313 for (leftvt = 0; leftvt <= VT_BSTR_BLOB; leftvt++)
7315 SKIPTESTIDIV(leftvt);
7317 /* Check if we need/have support for I8 and/or UI8 */
7318 if ((leftvt == VT_I8 || leftvt == VT_UI8) && !HAVE_OLEAUT32_I8)
7321 for (rightvt = 0; rightvt <= VT_BSTR_BLOB; rightvt++)
7324 SKIPTESTIDIV(rightvt);
7326 /* Native crashes with extra flag VT_BYREF */
7327 if (ExtraFlags[i] == VT_BYREF)
7330 /* Check if we need/have support for I8 and/or UI8 */
7331 if ((rightvt == VT_I8 || rightvt == VT_UI8) && !HAVE_OLEAUT32_I8)
7334 memset(&left, 0, sizeof(left));
7335 memset(&right, 0, sizeof(right));
7336 V_VT(&left) = leftvt | ExtraFlags[i];
7337 V_VT(&right) = rightvt | ExtraFlags[i];
7338 V_VT(&result) = VT_EMPTY;
7341 if (leftvt == VT_BSTR)
7342 V_BSTR(&left) = num2_str;
7343 else if (leftvt == VT_DECIMAL)
7345 VarDecFromR8(2.0, &V_DECIMAL(&left));
7346 V_VT(&left) = leftvt | ExtraFlags[i];
7349 /* Division by 0 is undefined */
7353 V_BSTR(&right) = num2_str;
7356 VarDecFromR8(2.0, &V_DECIMAL(&right));
7357 V_VT(&right) = rightvt | ExtraFlags[i];
7360 V_BOOL(&right) = VARIANT_TRUE;
7363 VarCyFromI4(10000, &V_CY(&right));
7364 V_VT(&right) = rightvt | ExtraFlags[i];
7366 case VT_I2: V_I2(&right) = 2; break;
7367 case VT_I4: V_I4(&right) = 2; break;
7368 case VT_R4: V_R4(&right) = 2.0f; break;
7369 case VT_R8: V_R8(&right) = 2.0; break;
7370 case VT_DATE: V_DATE(&right) = 2; break;
7371 case VT_I1: V_I1(&right) = 2; break;
7372 case VT_UI1: V_UI1(&right) = 2; break;
7373 case VT_UI2: V_UI2(&right) = 2; break;
7374 case VT_UI4: V_UI4(&right) = 2; break;
7375 case VT_I8: V_I8(&right) = 2; break;
7376 case VT_UI8: V_UI8(&right) = 2; break;
7377 case VT_INT: V_INT(&right) = 2; break;
7378 case VT_UINT: V_UINT(&right) = 2; break;
7382 /* Native VarIdiv always returns an error when using extra
7383 * flags or if the variant combination is I8 and INT.
7385 if ((leftvt == VT_I8 && rightvt == VT_INT) ||
7386 (leftvt == VT_INT && rightvt == VT_I8) ||
7387 (rightvt == VT_EMPTY && leftvt != VT_NULL) ||
7391 /* Determine variant type */
7392 else if (leftvt == VT_NULL || rightvt == VT_NULL)
7394 else if (leftvt == VT_I8 || rightvt == VT_I8)
7396 else if (leftvt == VT_I4 || rightvt == VT_I4 ||
7397 leftvt == VT_INT || rightvt == VT_INT ||
7398 leftvt == VT_UINT || rightvt == VT_UINT ||
7399 leftvt == VT_UI8 || rightvt == VT_UI8 ||
7400 leftvt == VT_UI4 || rightvt == VT_UI4 ||
7401 leftvt == VT_UI2 || rightvt == VT_UI2 ||
7402 leftvt == VT_I1 || rightvt == VT_I1 ||
7403 leftvt == VT_BSTR || rightvt == VT_BSTR ||
7404 leftvt == VT_DATE || rightvt == VT_DATE ||
7405 leftvt == VT_CY || rightvt == VT_CY ||
7406 leftvt == VT_DECIMAL || rightvt == VT_DECIMAL ||
7407 leftvt == VT_R8 || rightvt == VT_R8 ||
7408 leftvt == VT_R4 || rightvt == VT_R4)
7410 else if (leftvt == VT_I2 || rightvt == VT_I2 ||
7411 leftvt == VT_BOOL || rightvt == VT_BOOL ||
7414 else if (leftvt == VT_UI1 || rightvt == VT_UI1)
7419 hres = pVarIdiv(&left, &right, &result);
7421 /* Check expected HRESULT and if result variant type is correct */
7423 ok (hres == DISP_E_BADVARTYPE || hres == DISP_E_TYPEMISMATCH ||
7424 hres == DISP_E_DIVBYZERO,
7425 "VarIdiv: %s|0x%X, %s|0x%X: got vt %s hr 0x%X\n",
7426 vtstr(leftvt), ExtraFlags[i], vtstr(rightvt), ExtraFlags[i],
7427 vtstr(V_VT(&result)), hres);
7429 ok (hres == S_OK && resvt == V_VT(&result),
7430 "VarIdiv: %s|0x%X, %s|0x%X: expected vt %s hr 0x%X, got vt %s hr 0x%X\n",
7431 vtstr(leftvt), ExtraFlags[i], vtstr(rightvt), ExtraFlags[i], vtstr(resvt),
7432 S_OK, vtstr(V_VT(&result)), hres);
7437 /* Test return values for all the good cases */
7438 VARIDIV(EMPTY,0,NULL,0,NULL,0);
7439 VARIDIV(EMPTY,0,I2,1,I2,0);
7440 VARIDIV(EMPTY,0,I4,1,I4,0);
7441 VARIDIV(EMPTY,0,R4,1.0f,I4,0);
7442 VARIDIV(EMPTY,0,R8,1.0,I4,0);
7443 VARIDIV(EMPTY,0,DATE,1.0,I4,0);
7444 VARIDIV(EMPTY,0,BSTR,num1_str,I4,0);
7445 VARIDIV(EMPTY,0,BOOL,VARIANT_TRUE,I2,0);
7446 VARIDIV(EMPTY,0,I1,1,I4,0);
7447 VARIDIV(EMPTY,0,UI1,1,I2,0);
7448 VARIDIV(EMPTY,0,UI2,1,I4,0);
7449 VARIDIV(EMPTY,0,UI4,1,I4,0);
7450 if (HAVE_OLEAUT32_I8)
7452 VARIDIV(EMPTY,0,I8,1,I8,0);
7453 VARIDIV(EMPTY,0,UI8,1,I4,0);
7455 VARIDIV(EMPTY,0,INT,1,I4,0);
7456 VARIDIV(EMPTY,0,UINT,1,I4,0);
7457 VARIDIV(NULL,0,EMPTY,0,NULL,0);
7458 VARIDIV(NULL,0,NULL,0,NULL,0);
7459 VARIDIV(NULL,0,I2,1,NULL,0);
7460 VARIDIV(NULL,0,I4,1,NULL,0);
7461 VARIDIV(NULL,0,R4,1,NULL,0);
7462 VARIDIV(NULL,0,R8,1,NULL,0);
7463 VARIDIV(NULL,0,DATE,1,NULL,0);
7464 VARIDIV(NULL,0,BSTR,num1_str,NULL,0);
7465 VARIDIV(NULL,0,BOOL,VARIANT_TRUE,NULL,0);
7466 VARIDIV(NULL,0,I1,1,NULL,0);
7467 VARIDIV(NULL,0,UI1,1,NULL,0);
7468 VARIDIV(NULL,0,UI2,1,NULL,0);
7469 VARIDIV(NULL,0,UI4,1,NULL,0);
7470 if (HAVE_OLEAUT32_I8)
7472 VARIDIV(NULL,0,I8,1,NULL,0);
7473 VARIDIV(NULL,0,UI8,1,NULL,0);
7475 VARIDIV(NULL,0,INT,1,NULL,0);
7476 VARIDIV(NULL,0,UINT,1,NULL,0);
7477 VARIDIV(I2,2,NULL,0,NULL,0);
7478 VARIDIV(I2,2,I2,1,I2,2);
7479 VARIDIV(I2,2,I4,1,I4,2);
7480 VARIDIV(I2,2,R4,1,I4,2);
7481 VARIDIV(I2,2,R8,1,I4,2);
7482 VARIDIV(I2,2,DATE,1,I4,2);
7483 VARIDIV(I2,2,BSTR,num1_str,I4,2);
7484 VARIDIV(I2,2,BOOL,VARIANT_TRUE,I2,-2);
7485 VARIDIV(I2,2,I1,1,I4,2);
7486 VARIDIV(I2,2,UI1,1,I2,2);
7487 VARIDIV(I2,2,UI2,1,I4,2);
7488 VARIDIV(I2,2,UI4,1,I4,2);
7489 if (HAVE_OLEAUT32_I8)
7491 VARIDIV(I2,2,I8,1,I8,2);
7492 VARIDIV(I2,2,UI8,1,I4,2);
7494 VARIDIV(I2,2,INT,1,I4,2);
7495 VARIDIV(I2,2,UINT,1,I4,2);
7496 VARIDIV(I4,2,NULL,0,NULL,0);
7497 VARIDIV(I4,2,I2,1,I4,2);
7498 VARIDIV(I4,2,I4,1,I4,2);
7499 VARIDIV(I4,2,R4,1,I4,2);
7500 VARIDIV(I4,2,R8,1,I4,2);
7501 VARIDIV(I4,2,DATE,1,I4,2);
7502 VARIDIV(I4,2,BSTR,num1_str,I4,2);
7503 VARIDIV(I4,2,BOOL,VARIANT_TRUE,I4,-2);
7504 VARIDIV(I4,2,I1,1,I4,2);
7505 VARIDIV(I4,2,UI1,1,I4,2);
7506 VARIDIV(I4,2,UI2,1,I4,2);
7507 VARIDIV(I4,2,UI4,1,I4,2);
7508 if (HAVE_OLEAUT32_I8)
7510 VARIDIV(I4,2,I8,1,I8,2);
7511 VARIDIV(I4,2,UI8,1,I4,2);
7513 VARIDIV(I4,2,INT,1,I4,2);
7514 VARIDIV(I4,2,UINT,1,I4,2);
7515 VARIDIV(R4,2.0f,NULL,0,NULL,0);
7516 VARIDIV(R4,2.0f,I2,1,I4,2);
7517 VARIDIV(R4,2.0f,I4,1,I4,2);
7518 VARIDIV(R4,2.0f,R4,1.0f,I4,2);
7519 VARIDIV(R4,2.0f,R8,1.0,I4,2);
7520 VARIDIV(R4,2.0f,DATE,1,I4,2);
7521 VARIDIV(R4,2.0f,BSTR,num1_str,I4,2);
7522 VARIDIV(R4,2.0f,BOOL,VARIANT_TRUE,I4,-2);
7523 VARIDIV(R4,2.0f,I1,1,I4,2);
7524 VARIDIV(R4,2.0f,UI1,1,I4,2);
7525 VARIDIV(R4,2.0f,UI2,1,I4,2);
7526 VARIDIV(R4,2.0f,UI4,1,I4,2);
7527 if (HAVE_OLEAUT32_I8)
7529 VARIDIV(R4,2.0f,I8,1,I8,2);
7530 VARIDIV(R4,2.0f,UI8,1,I4,2);
7532 VARIDIV(R4,2.0f,INT,1,I4,2);
7533 VARIDIV(R4,2.0f,UINT,1,I4,2);
7534 VARIDIV(R8,2.0,NULL,0,NULL,0);
7535 VARIDIV(R8,2.0,I2,1,I4,2);
7536 VARIDIV(R8,2.0,I4,1,I4,2);
7537 VARIDIV(R8,2.0,R4,1,I4,2);
7538 VARIDIV(R8,2.0,R8,1,I4,2);
7539 VARIDIV(R8,2.0,DATE,1,I4,2);
7540 VARIDIV(R8,2.0,BSTR,num1_str,I4,2);
7541 VARIDIV(R8,2.0,BOOL,VARIANT_TRUE,I4,-2);
7542 VARIDIV(R8,2.0,I1,1,I4,2);
7543 VARIDIV(R8,2.0,UI1,1,I4,2);
7544 VARIDIV(R8,2.0,UI2,1,I4,2);
7545 VARIDIV(R8,2.0,UI4,1,I4,2);
7546 if (HAVE_OLEAUT32_I8)
7548 VARIDIV(R8,2.0,I8,1,I8,2);
7549 VARIDIV(R8,2.0,UI8,1,I4,2);
7551 VARIDIV(R8,2.0,INT,1,I4,2);
7552 VARIDIV(R8,2.0,UINT,1,I4,2);
7553 VARIDIV(DATE,2,NULL,0,NULL,0);
7554 VARIDIV(DATE,2,I2,1,I4,2);
7555 VARIDIV(DATE,2,I4,1,I4,2);
7556 VARIDIV(DATE,2,R4,1,I4,2);
7557 VARIDIV(DATE,2,R8,1,I4,2);
7558 VARIDIV(DATE,2,DATE,1,I4,2);
7559 VARIDIV(DATE,2,BSTR,num1_str,I4,2);
7560 VARIDIV(DATE,2,BOOL,VARIANT_TRUE,I4,-2);
7561 VARIDIV(DATE,2,I1,1,I4,2);
7562 VARIDIV(DATE,2,UI1,1,I4,2);
7563 VARIDIV(DATE,2,UI2,1,I4,2);
7564 VARIDIV(DATE,2,UI4,1,I4,2);
7565 if (HAVE_OLEAUT32_I8)
7567 VARIDIV(DATE,2,I8,1,I8,2);
7568 VARIDIV(DATE,2,UI8,1,I4,2);
7570 VARIDIV(DATE,2,INT,1,I4,2);
7571 VARIDIV(DATE,2,UINT,1,I4,2);
7572 VARIDIV(BSTR,num2_str,NULL,0,NULL,0);
7573 VARIDIV(BSTR,num2_str,I2,1,I4,2);
7574 VARIDIV(BSTR,num2_str,I4,1,I4,2);
7575 VARIDIV(BSTR,num2_str,R4,1.0f,I4,2);
7576 VARIDIV(BSTR,num2_str,R8,1.0,I4,2);
7577 VARIDIV(BSTR,num2_str,DATE,1,I4,2);
7578 VARIDIV(BSTR,num2_str,BSTR,num1_str,I4,2);
7579 VARIDIV(BSTR,num2_str,BOOL,VARIANT_TRUE,I4,-2);
7580 VARIDIV(BSTR,num2_str,I1,1,I4,2);
7581 VARIDIV(BSTR,num2_str,UI1,1,I4,2);
7582 VARIDIV(BSTR,num2_str,UI2,1,I4,2);
7583 VARIDIV(BSTR,num2_str,UI4,1,I4,2);
7584 if (HAVE_OLEAUT32_I8)
7586 VARIDIV(BSTR,num2_str,I8,1,I8,2);
7587 VARIDIV(BSTR,num2_str,UI8,1,I4,2);
7589 VARIDIV(BSTR,num2_str,INT,1,I4,2);
7590 VARIDIV(BSTR,num2_str,UINT,1,I4,2);
7591 VARIDIV(BOOL,VARIANT_TRUE,NULL,0,NULL,0);
7592 VARIDIV(BOOL,VARIANT_TRUE,I2,1,I2,-1);
7593 VARIDIV(BOOL,VARIANT_TRUE,I4,1,I4,-1);
7594 VARIDIV(BOOL,VARIANT_TRUE,R4,1.0f,I4,-1);
7595 VARIDIV(BOOL,VARIANT_TRUE,R8,1.0,I4,-1);
7596 VARIDIV(BOOL,VARIANT_TRUE,DATE,1,I4,-1);
7597 VARIDIV(BOOL,VARIANT_TRUE,BSTR,num1_str,I4,-1);
7598 VARIDIV(BOOL,VARIANT_TRUE,BOOL,VARIANT_TRUE,I2,1);
7599 VARIDIV(BOOL,VARIANT_TRUE,I1,1,I4,-1);
7600 VARIDIV(BOOL,VARIANT_TRUE,UI1,1,I2,-1);
7601 VARIDIV(BOOL,VARIANT_TRUE,UI2,1,I4,-1);
7602 VARIDIV(BOOL,VARIANT_TRUE,UI4,1,I4,-1);
7603 if (HAVE_OLEAUT32_I8)
7605 VARIDIV(BOOL,VARIANT_TRUE,I8,1,I8,-1);
7606 VARIDIV(BOOL,VARIANT_TRUE,UI8,1,I4,-1);
7608 VARIDIV(BOOL,VARIANT_TRUE,INT,1,I4,-1);
7609 VARIDIV(BOOL,VARIANT_TRUE,UINT,1,I4,-1);
7610 VARIDIV(I1,2,NULL,0,NULL,0);
7611 VARIDIV(I1,2,I2,1,I4,2);
7612 VARIDIV(I1,2,I4,1,I4,2);
7613 VARIDIV(I1,2,R4,1.0f,I4,2);
7614 VARIDIV(I1,2,R8,1.0,I4,2);
7615 VARIDIV(I1,2,DATE,1,I4,2);
7616 VARIDIV(I1,2,BSTR,num1_str,I4,2);
7617 VARIDIV(I1,2,BOOL,VARIANT_TRUE,I4,-2);
7618 VARIDIV(I1,2,I1,1,I4,2);
7619 VARIDIV(I1,2,UI1,1,I4,2);
7620 VARIDIV(I1,2,UI2,1,I4,2);
7621 VARIDIV(I1,2,UI4,1,I4,2);
7622 if (HAVE_OLEAUT32_I8)
7624 VARIDIV(I1,2,I8,1,I8,2);
7625 VARIDIV(I1,2,UI8,1,I4,2);
7627 VARIDIV(I1,2,INT,1,I4,2);
7628 VARIDIV(I1,2,UINT,1,I4,2);
7629 VARIDIV(UI1,2,NULL,0,NULL,0);
7630 VARIDIV(UI1,2,I2,1,I2,2);
7631 VARIDIV(UI1,2,I4,1,I4,2);
7632 VARIDIV(UI1,2,R4,1.0f,I4,2);
7633 VARIDIV(UI1,2,R8,1.0,I4,2);
7634 VARIDIV(UI1,2,DATE,1,I4,2);
7635 VARIDIV(UI1,2,BSTR,num1_str,I4,2);
7636 VARIDIV(UI1,2,BOOL,VARIANT_TRUE,I2,-2);
7637 VARIDIV(UI1,2,I1,1,I4,2);
7638 VARIDIV(UI1,2,UI1,1,UI1,2);
7639 VARIDIV(UI1,2,UI2,1,I4,2);
7640 VARIDIV(UI1,2,UI4,1,I4,2);
7641 if (HAVE_OLEAUT32_I8)
7643 VARIDIV(UI1,2,I8,1,I8,2);
7644 VARIDIV(UI1,2,UI8,1,I4,2);
7646 VARIDIV(UI1,2,INT,1,I4,2);
7647 VARIDIV(UI1,2,UINT,1,I4,2);
7648 VARIDIV(UI2,2,NULL,0,NULL,0);
7649 VARIDIV(UI2,2,I2,1,I4,2);
7650 VARIDIV(UI2,2,I4,1,I4,2);
7651 VARIDIV(UI2,2,R4,1.0f,I4,2);
7652 VARIDIV(UI2,2,R8,1.0,I4,2);
7653 VARIDIV(UI2,2,DATE,1,I4,2);
7654 VARIDIV(UI2,2,BSTR,num1_str,I4,2);
7655 VARIDIV(UI2,2,BOOL,VARIANT_TRUE,I4,-2);
7656 VARIDIV(UI2,2,I1,1,I4,2);
7657 VARIDIV(UI2,2,UI1,1,I4,2);
7658 VARIDIV(UI2,2,UI2,1,I4,2);
7659 VARIDIV(UI2,2,UI4,1,I4,2);
7660 if (HAVE_OLEAUT32_I8)
7662 VARIDIV(UI2,2,I8,1,I8,2);
7663 VARIDIV(UI2,2,UI8,1,I4,2);
7665 VARIDIV(UI2,2,INT,1,I4,2);
7666 VARIDIV(UI2,2,UINT,1,I4,2);
7667 VARIDIV(UI4,2,NULL,0,NULL,0);
7668 VARIDIV(UI4,2,I2,1,I4,2);
7669 VARIDIV(UI4,2,I4,1,I4,2);
7670 VARIDIV(UI4,2,R4,1.0f,I4,2);
7671 VARIDIV(UI4,2,R8,1.0,I4,2);
7672 VARIDIV(UI4,2,DATE,1,I4,2);
7673 VARIDIV(UI4,2,BSTR,num1_str,I4,2);
7674 VARIDIV(UI4,2,BOOL,VARIANT_TRUE,I4,-2);
7675 VARIDIV(UI4,2,I1,1,I4,2);
7676 VARIDIV(UI4,2,UI1,1,I4,2);
7677 VARIDIV(UI4,2,UI2,1,I4,2);
7678 VARIDIV(UI4,2,UI4,1,I4,2);
7679 if (HAVE_OLEAUT32_I8)
7681 VARIDIV(UI4,2,I8,1,I8,2);
7682 VARIDIV(UI4,2,UI8,1,I4,2);
7684 VARIDIV(UI4,2,INT,1,I4,2);
7685 VARIDIV(UI4,2,UINT,1,I4,2);
7686 if (HAVE_OLEAUT32_I8)
7688 VARIDIV(I8,2,NULL,0,NULL,0);
7689 VARIDIV(I8,2,I2,1,I8,2);
7690 VARIDIV(I8,2,I4,1,I8,2);
7691 VARIDIV(I8,2,R4,1.0f,I8,2);
7692 VARIDIV(I8,2,R8,1.0,I8,2);
7693 VARIDIV(I8,2,DATE,1,I8,2);
7694 VARIDIV(I8,2,BSTR,num1_str,I8,2);
7695 VARIDIV(I8,2,BOOL,1,I8,2);
7696 VARIDIV(I8,2,I1,1,I8,2);
7697 VARIDIV(I8,2,UI1,1,I8,2);
7698 VARIDIV(I8,2,UI2,1,I8,2);
7699 VARIDIV(I8,2,UI4,1,I8,2);
7700 VARIDIV(I8,2,I8,1,I8,2);
7701 VARIDIV(I8,2,UI8,1,I8,2);
7702 VARIDIV(I8,2,UINT,1,I8,2);
7703 VARIDIV(UI8,2,NULL,0,NULL,0);
7704 VARIDIV(UI8,2,I2,1,I4,2);
7705 VARIDIV(UI8,2,I4,1,I4,2);
7706 VARIDIV(UI8,2,R4,1.0f,I4,2);
7707 VARIDIV(UI8,2,R8,1.0,I4,2);
7708 VARIDIV(UI8,2,DATE,1,I4,2);
7709 VARIDIV(UI8,2,BSTR,num1_str,I4,2);
7710 VARIDIV(UI8,2,BOOL,VARIANT_TRUE,I4,-2);
7711 VARIDIV(UI8,2,I1,1,I4,2);
7712 VARIDIV(UI8,2,UI1,1,I4,2);
7713 VARIDIV(UI8,2,UI2,1,I4,2);
7714 VARIDIV(UI8,2,UI4,1,I4,2);
7715 VARIDIV(UI8,2,I8,1,I8,2);
7716 VARIDIV(UI8,2,UI8,1,I4,2);
7717 VARIDIV(UI8,2,INT,1,I4,2);
7718 VARIDIV(UI8,2,UINT,1,I4,2);
7720 VARIDIV(INT,2,NULL,0,NULL,0);
7721 VARIDIV(INT,2,I2,1,I4,2);
7722 VARIDIV(INT,2,I4,1,I4,2);
7723 VARIDIV(INT,2,R4,1.0f,I4,2);
7724 VARIDIV(INT,2,R8,1.0,I4,2);
7725 VARIDIV(INT,2,DATE,1,I4,2);
7726 VARIDIV(INT,2,BSTR,num1_str,I4,2);
7727 VARIDIV(INT,2,BOOL,VARIANT_TRUE,I4,-2);
7728 VARIDIV(INT,2,I1,1,I4,2);
7729 VARIDIV(INT,2,UI1,1,I4,2);
7730 VARIDIV(INT,2,UI2,1,I4,2);
7731 VARIDIV(INT,2,UI4,1,I4,2);
7732 if (HAVE_OLEAUT32_I8)
7734 VARIDIV(INT,2,UI8,1,I4,2);
7736 VARIDIV(INT,2,INT,1,I4,2);
7737 VARIDIV(INT,2,UINT,1,I4,2);
7738 VARIDIV(UINT,2,NULL,0,NULL,0);
7739 VARIDIV(UINT,2,I2,1,I4,2);
7740 VARIDIV(UINT,2,I4,1,I4,2);
7741 VARIDIV(UINT,2,R4,1.0f,I4,2);
7742 VARIDIV(UINT,2,R8,1.0,I4,2);
7743 VARIDIV(UINT,2,DATE,1,I4,2);
7744 VARIDIV(UINT,2,BSTR,num1_str,I4,2);
7745 VARIDIV(UINT,2,BOOL,VARIANT_TRUE,I4,-2);
7746 VARIDIV(UINT,2,I1,1,I4,2);
7747 VARIDIV(UINT,2,UI1,1,I4,2);
7748 VARIDIV(UINT,2,UI2,1,I4,2);
7749 VARIDIV(UINT,2,UI4,1,I4,2);
7750 if (HAVE_OLEAUT32_I8)
7752 VARIDIV(UINT,2,I8,1,I8,2);
7753 VARIDIV(UINT,2,UI8,1,I4,2);
7755 VARIDIV(UINT,2,INT,1,I4,2);
7756 VARIDIV(UINT,2,UINT,1,I4,2);
7758 /* Manually test some VT_CY, VT_DECIMAL variants */
7760 hres = VarCyFromI4(10000, &V_CY(&cy));
7761 ok(hres == S_OK, "VarCyFromI4 failed!\n");
7762 V_VT(&dec) = VT_DECIMAL;
7763 hres = VarDecFromR8(2.0, &V_DECIMAL(&dec));
7764 ok(hres == S_OK, "VarDecFromR4 failed!\n");
7765 memset(&left, 0, sizeof(left));
7766 memset(&right, 0, sizeof(right));
7767 V_VT(&left) = VT_I4;
7769 V_VT(&right) = VT_I8;
7772 hres = VarIdiv(&cy, &cy, &result);
7773 ok(hres == S_OK && V_VT(&result) == VT_I4,
7774 "VARIDIV: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
7775 S_OK, hres, vtstr(V_VT(&result)));
7776 ok(hres == S_OK && V_I4(&result) == 1,
7777 "VARIDIV: CY value %d, expected %d\n", V_I4(&result), 1);
7779 if (HAVE_OLEAUT32_I8)
7781 hres = VarIdiv(&cy, &right, &result);
7782 ok(hres == S_OK && V_VT(&result) == VT_I8,
7783 "VARIDIV: expected coerced hres 0x%X type VT_I8, got hres 0x%X type %s!\n",
7784 S_OK, hres, vtstr(V_VT(&result)));
7785 ok(hres == S_OK && V_I8(&result) == 5000,
7786 "VARIDIV: CY value 0x%x%08x, expected 0x%x\n",
7787 (DWORD)(V_I8(&result) >>32), (DWORD)V_I8(&result), 5000);
7790 hres = VarIdiv(&left, &cy, &result);
7791 ok(hres == S_OK && V_VT(&result) == VT_I4,
7792 "VARIDIV: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
7793 S_OK, hres, vtstr(V_VT(&result)));
7794 ok(hres == S_OK && V_I4(&result) == 0,
7795 "VARIDIV: CY value %d, expected %d\n", V_I4(&result), 0);
7797 hres = VarIdiv(&left, &dec, &result);
7798 ok(hres == S_OK && V_VT(&result) == VT_I4,
7799 "VARIDIV: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
7800 S_OK, hres, vtstr(V_VT(&result)));
7801 ok(hres == S_OK && V_I4(&result) == 50,
7802 "VARIDIV: DECIMAL value %d, expected %d\n", V_I4(&result), 50);
7804 hres = VarIdiv(&dec, &dec, &result);
7805 ok(hres == S_OK && V_VT(&result) == VT_I4,
7806 "VARIDIV: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
7807 S_OK, hres, vtstr(V_VT(&result)));
7808 ok(hres == S_OK && V_I4(&result) == 1,
7809 "VARIDIV: DECIMAL value %d, expected %d\n", V_I4(&result), 1);
7811 if (HAVE_OLEAUT32_I8)
7813 hres = VarIdiv(&dec, &right, &result);
7814 ok(hres == S_OK && V_VT(&result) == VT_I8,
7815 "VARIDIV: expected coerced hres 0x%X type VT_I8, got hres 0x%X type %s!\n",
7816 S_OK, hres, vtstr(V_VT(&result)));
7817 ok(hres == S_OK && V_I8(&result) == 1,
7818 "VARIDIV: DECIMAL value 0x%x%08x, expected %d\n",
7819 (DWORD)(V_I8(&result) >> 32), (DWORD)V_I8(&result), 1);
7822 /* Check for division by zero */
7823 V_VT(&left) = VT_INT;
7825 V_VT(&right) = VT_INT;
7827 hres = pVarIdiv(&left, &right, &result);
7828 ok(hres == DISP_E_DIVBYZERO && V_VT(&result) == VT_EMPTY,
7829 "VARIDIV: Division by 0 should result in DISP_E_DIVBYZERO but got 0x%X\n", hres);
7831 V_VT(&left) = VT_INT;
7833 V_VT(&right) = VT_INT;
7835 hres = pVarIdiv(&left, &right, &result);
7836 ok(hres == DISP_E_DIVBYZERO && V_VT(&result) == VT_EMPTY,
7837 "VARIDIV: Division by 0 should result in DISP_E_DIVBYZERO but got 0x%X\n", hres);
7839 SysFreeString(num1_str);
7840 SysFreeString(num2_str);
7844 static HRESULT (WINAPI *pVarImp)(LPVARIANT,LPVARIANT,LPVARIANT);
7846 #define VARIMP(vt1,val1,vt2,val2,rvt,rval) \
7847 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
7848 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
7849 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
7850 test_var_call2( __LINE__, pVarImp, &left, &right, &exp )
7852 /* Skip any type that is not defined or produces an error for every case */
7853 #define SKIPTESTIMP(a) \
7854 if (a == VT_ERROR || a == VT_VARIANT || \
7855 a == VT_DISPATCH || a == VT_UNKNOWN || \
7856 a == VT_RECORD || a > VT_UINT || \
7857 a == 15 /*not defined*/) \
7860 static void test_VarImp(void)
7862 static const WCHAR szFalse[] = { '#','F','A','L','S','E','#','\0' };
7863 static const WCHAR szTrue[] = { '#','T','R','U','E','#','\0' };
7864 VARIANT left, right, exp, result, cy, dec;
7865 BSTR true_str, false_str;
7871 true_str = SysAllocString(szTrue);
7872 false_str = SysAllocString(szFalse);
7874 /* Test all possible flag/vt combinations & the resulting vt type */
7875 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
7877 VARTYPE leftvt, rightvt, resvt;
7879 for (leftvt = 0; leftvt <= VT_BSTR_BLOB; leftvt++)
7881 SKIPTESTIMP(leftvt);
7883 /* Check if we need/have support for I8 and/or UI8 */
7884 if ((leftvt == VT_I8 || leftvt == VT_UI8) && !HAVE_OLEAUT32_I8)
7887 for (rightvt = 0; rightvt <= VT_BSTR_BLOB; rightvt++)
7890 SKIPTESTIMP(rightvt);
7892 /* Native crashes when using the extra flag VT_BYREF
7893 * or with the following VT combinations
7895 if ((leftvt == VT_UI4 && rightvt == VT_BSTR) ||
7896 (leftvt == VT_UI8 && rightvt == VT_BSTR) ||
7897 ExtraFlags[i] == VT_BYREF)
7900 /* Check if we need/have support for I8 and/or UI8 */
7901 if ((rightvt == VT_I8 || rightvt == VT_UI8) && !HAVE_OLEAUT32_I8)
7904 memset(&left, 0, sizeof(left));
7905 memset(&right, 0, sizeof(right));
7906 V_VT(&left) = leftvt | ExtraFlags[i];
7907 V_VT(&right) = rightvt | ExtraFlags[i];
7908 V_VT(&result) = VT_EMPTY;
7911 if (leftvt == VT_BSTR)
7912 V_BSTR(&left) = true_str;
7914 /* This allows us to test return types that are not NULL
7915 * (NULL Imp value = n, NULL Imp 0 = NULL)
7920 V_BSTR(&right) = true_str;
7923 VarDecFromR8(2.0, &V_DECIMAL(&right));
7924 V_VT(&right) = rightvt | ExtraFlags[i];
7927 V_BOOL(&right) = VARIANT_TRUE;
7929 case VT_I1: V_I1(&right) = 2; break;
7930 case VT_I2: V_I2(&right) = 2; break;
7931 case VT_I4: V_I4(&right) = 2; break;
7932 case VT_R4: V_R4(&right) = 2.0f; break;
7933 case VT_R8: V_R8(&right) = 2.0; break;
7934 case VT_CY: V_CY(&right).int64 = 10000; break;
7935 case VT_DATE: V_DATE(&right) = 2; break;
7936 case VT_I8: V_I8(&right) = 2; break;
7937 case VT_INT: V_INT(&right) = 2; break;
7938 case VT_UINT: V_UINT(&right) = 2; break;
7939 case VT_UI1: V_UI1(&right) = 2; break;
7940 case VT_UI2: V_UI2(&right) = 2; break;
7941 case VT_UI4: V_UI4(&right) = 2; break;
7942 case VT_UI8: V_UI8(&right) = 2; break;
7946 /* Native VarImp always returns an error when using extra
7947 * flags or if the variants are I8 and INT.
7949 if ((leftvt == VT_I8 && rightvt == VT_INT) ||
7953 /* Determine result type */
7954 else if ((leftvt == VT_BSTR && rightvt == VT_NULL) ||
7955 (leftvt == VT_NULL && rightvt == VT_NULL) ||
7956 (leftvt == VT_NULL && rightvt == VT_EMPTY))
7958 else if (leftvt == VT_I8 || rightvt == VT_I8)
7960 else if (leftvt == VT_I4 || rightvt == VT_I4 ||
7961 leftvt == VT_INT || rightvt == VT_INT ||
7962 leftvt == VT_UINT || rightvt == VT_UINT ||
7963 leftvt == VT_UI4 || rightvt == VT_UI4 ||
7964 leftvt == VT_UI8 || rightvt == VT_UI8 ||
7965 leftvt == VT_UI2 || rightvt == VT_UI2 ||
7966 leftvt == VT_DECIMAL || rightvt == VT_DECIMAL ||
7967 leftvt == VT_DATE || rightvt == VT_DATE ||
7968 leftvt == VT_CY || rightvt == VT_CY ||
7969 leftvt == VT_R8 || rightvt == VT_R8 ||
7970 leftvt == VT_R4 || rightvt == VT_R4 ||
7971 leftvt == VT_I1 || rightvt == VT_I1)
7973 else if ((leftvt == VT_UI1 && rightvt == VT_UI1) ||
7974 (leftvt == VT_UI1 && rightvt == VT_NULL) ||
7975 (leftvt == VT_NULL && rightvt == VT_UI1))
7977 else if (leftvt == VT_EMPTY || rightvt == VT_EMPTY ||
7978 leftvt == VT_I2 || rightvt == VT_I2 ||
7979 leftvt == VT_UI1 || rightvt == VT_UI1)
7981 else if (leftvt == VT_BOOL || rightvt == VT_BOOL ||
7982 leftvt == VT_BSTR || rightvt == VT_BSTR)
7985 hres = pVarImp(&left, &right, &result);
7987 /* Check expected HRESULT and if result variant type is correct */
7989 ok (hres == DISP_E_BADVARTYPE || hres == DISP_E_TYPEMISMATCH,
7990 "VarImp: %s|0x%X, %s|0x%X: got vt %s hr 0x%X\n",
7991 vtstr(leftvt), ExtraFlags[i], vtstr(rightvt), ExtraFlags[i],
7992 vtstr(V_VT(&result)), hres);
7994 ok (hres == S_OK && resvt == V_VT(&result),
7995 "VarImp: %s|0x%X, %s|0x%X: expected vt %s hr 0x%X, got vt %s hr 0x%X\n",
7996 vtstr(leftvt), ExtraFlags[i], vtstr(rightvt), ExtraFlags[i], vtstr(resvt),
7997 S_OK, vtstr(V_VT(&result)), hres);
8002 VARIMP(EMPTY,0,EMPTY,0,I2,-1);
8003 VARIMP(EMPTY,0,NULL,0,I2,-1);
8004 VARIMP(EMPTY,0,I2,-1,I2,-1);
8005 VARIMP(EMPTY,0,I4,-1,I4,-1);
8006 VARIMP(EMPTY,0,R4,0.0f,I4,-1);
8007 VARIMP(EMPTY,0,R8,-1.0,I4,-1);
8008 VARIMP(EMPTY,0,DATE,0,I4,-1);
8009 VARIMP(EMPTY,0,BSTR,true_str,I2,-1);
8010 VARIMP(EMPTY,0,BOOL,VARIANT_FALSE,I2,-1);
8011 VARIMP(EMPTY,0,I1,0,I4,-1);
8012 VARIMP(EMPTY,0,UI1,1,I2,-1);
8013 VARIMP(EMPTY,0,UI2,1,I4,-1);
8014 VARIMP(EMPTY,0,UI4,1,I4,-1);
8015 if (HAVE_OLEAUT32_I8)
8017 VARIMP(EMPTY,0,I8,1,I8,-1);
8018 VARIMP(EMPTY,0,UI8,1,I4,-1);
8020 VARIMP(EMPTY,0,INT,-1,I4,-1);
8021 VARIMP(EMPTY,0,UINT,1,I4,-1);
8022 VARIMP(NULL,0,EMPTY,0,NULL,0);
8023 VARIMP(NULL,0,NULL,0,NULL,0);
8024 VARIMP(NULL,0,I2,-1,I2,-1);
8025 VARIMP(NULL,0,I4,-1,I4,-1);
8026 VARIMP(NULL,0,R4,0.0f,NULL,0);
8027 VARIMP(NULL,0,R8,-1.0,I4,-1);
8028 VARIMP(NULL,0,DATE,0,NULL,0);
8029 VARIMP(NULL,0,BSTR,true_str,BOOL,-1);
8030 VARIMP(NULL,0,BOOL,VARIANT_FALSE,NULL,0);
8031 VARIMP(NULL,0,I1,0,NULL,0);
8032 VARIMP(NULL,0,UI1,1,UI1,1);
8033 VARIMP(NULL,0,UI2,1,I4,1);
8034 VARIMP(NULL,0,UI4,1,I4,1);
8035 if (HAVE_OLEAUT32_I8)
8037 VARIMP(NULL,0,I8,1,I8,1);
8038 VARIMP(NULL,0,UI8,1,I4,1);
8040 VARIMP(NULL,0,INT,-1,I4,-1);
8041 VARIMP(NULL,0,UINT,1,I4,1);
8042 VARIMP(I2,-1,EMPTY,0,I2,0);
8043 VARIMP(I2,-1,I2,-1,I2,-1);
8044 VARIMP(I2,-1,I4,-1,I4,-1);
8045 VARIMP(I2,-1,R4,0.0f,I4,0);
8046 VARIMP(I2,-1,R8,-1.0,I4,-1);
8047 VARIMP(I2,-1,DATE,0,I4,0);
8048 VARIMP(I2,-1,BSTR,true_str,I2,-1);
8049 VARIMP(I2,-1,BOOL,VARIANT_FALSE,I2,0);
8050 VARIMP(I2,-1,I1,0,I4,0);
8051 VARIMP(I2,-1,UI1,1,I2,1);
8052 VARIMP(I2,-1,UI2,1,I4,1);
8053 VARIMP(I2,-1,UI4,1,I4,1);
8054 if (HAVE_OLEAUT32_I8)
8056 VARIMP(I2,-1,I8,1,I8,1);
8057 VARIMP(I2,-1,UI8,1,I4,1);
8059 VARIMP(I2,-1,INT,-1,I4,-1);
8060 VARIMP(I2,-1,UINT,1,I4,1);
8061 VARIMP(I4,2,EMPTY,0,I4,-3);
8062 VARIMP(I4,2,NULL,0,I4,-3);
8063 VARIMP(I4,2,I2,-1,I4,-1);
8064 VARIMP(I4,2,I4,-1,I4,-1);
8065 VARIMP(I4,2,R4,0.0f,I4,-3);
8066 VARIMP(I4,2,R8,-1.0,I4,-1);
8067 VARIMP(I4,2,DATE,0,I4,-3);
8068 VARIMP(I4,2,BSTR,true_str,I4,-1);
8069 VARIMP(I4,2,BOOL,VARIANT_FALSE,I4,-3);
8070 VARIMP(I4,2,I1,0,I4,-3);
8071 VARIMP(I4,2,UI1,1,I4,-3);
8072 VARIMP(I4,2,UI2,1,I4,-3);
8073 VARIMP(I4,2,UI4,1,I4,-3);
8074 if (HAVE_OLEAUT32_I8)
8076 VARIMP(I4,2,I8,1,I8,-3);
8077 VARIMP(I4,2,UI8,1,I4,-3);
8079 VARIMP(I4,2,INT,-1,I4,-1);
8080 VARIMP(I4,2,UINT,1,I4,-3);
8081 VARIMP(R4,-1.0f,EMPTY,0,I4,0);
8082 VARIMP(R4,-1.0f,NULL,0,NULL,0);
8083 VARIMP(R4,-1.0f,I2,-1,I4,-1);
8084 VARIMP(R4,-1.0f,I4,-1,I4,-1);
8085 VARIMP(R4,-1.0f,R4,0.0f,I4,0);
8086 VARIMP(R4,-1.0f,R8,-1.0,I4,-1);
8087 VARIMP(R4,-1.0f,DATE,1,I4,1);
8088 VARIMP(R4,-1.0f,BSTR,true_str,I4,-1);
8089 VARIMP(R4,-1.0f,BOOL,VARIANT_FALSE,I4,0);
8090 VARIMP(R4,-1.0f,I1,0,I4,0);
8091 VARIMP(R4,-1.0f,UI1,1,I4,1);
8092 VARIMP(R4,-1.0f,UI2,1,I4,1);
8093 VARIMP(R4,-1.0f,UI4,1,I4,1);
8094 if (HAVE_OLEAUT32_I8)
8096 VARIMP(R4,-1.0f,I8,1,I8,1);
8097 VARIMP(R4,-1.0f,UI8,1,I4,1);
8099 VARIMP(R4,-1.0f,INT,-1,I4,-1);
8100 VARIMP(R4,-1.0f,UINT,1,I4,1);
8101 VARIMP(R8,1.0,EMPTY,0,I4,-2);
8102 VARIMP(R8,1.0,NULL,0,I4,-2);
8103 VARIMP(R8,1.0,I2,-1,I4,-1);
8104 VARIMP(R8,1.0,I4,-1,I4,-1);
8105 VARIMP(R8,1.0,R4,0.0f,I4,-2);
8106 VARIMP(R8,1.0,R8,-1.0,I4,-1);
8107 VARIMP(R8,1.0,DATE,0,I4,-2);
8108 VARIMP(R8,1.0,BSTR,true_str,I4,-1);
8109 VARIMP(R8,1.0,BOOL,VARIANT_FALSE,I4,-2);
8110 VARIMP(R8,1.0,I1,0,I4,-2);
8111 VARIMP(R8,1.0,UI1,1,I4,-1);
8112 VARIMP(R8,1.0,UI2,1,I4,-1);
8113 VARIMP(R8,1.0,UI4,1,I4,-1);
8114 if (HAVE_OLEAUT32_I8)
8116 VARIMP(R8,1.0,I8,1,I8,-1);
8117 VARIMP(R8,1.0,UI8,1,I4,-1);
8119 VARIMP(R8,1.0,INT,-1,I4,-1);
8120 VARIMP(R8,1.0,UINT,1,I4,-1);
8121 VARIMP(DATE,0,EMPTY,0,I4,-1);
8122 VARIMP(DATE,0,NULL,0,I4,-1);
8123 VARIMP(DATE,0,I2,-1,I4,-1);
8124 VARIMP(DATE,0,I4,-1,I4,-1);
8125 VARIMP(DATE,0,R4,0.0f,I4,-1);
8126 VARIMP(DATE,0,R8,-1.0,I4,-1);
8127 VARIMP(DATE,0,DATE,0,I4,-1);
8128 VARIMP(DATE,0,BSTR,true_str,I4,-1);
8129 VARIMP(DATE,0,BOOL,VARIANT_FALSE,I4,-1);
8130 VARIMP(DATE,0,I1,0,I4,-1);
8131 VARIMP(DATE,0,UI1,1,I4,-1);
8132 VARIMP(DATE,0,UI2,1,I4,-1);
8133 VARIMP(DATE,0,UI4,1,I4,-1);
8134 if (HAVE_OLEAUT32_I8)
8136 VARIMP(DATE,0,I8,1,I8,-1);
8137 VARIMP(DATE,0,UI8,1,I4,-1);
8139 VARIMP(DATE,0,INT,-1,I4,-1);
8140 VARIMP(DATE,0,UINT,1,I4,-1);
8141 VARIMP(BSTR,false_str,EMPTY,0,I2,-1);
8142 VARIMP(BSTR,false_str,NULL,0,BOOL,-1);
8143 VARIMP(BSTR,false_str,I2,-1,I2,-1);
8144 VARIMP(BSTR,false_str,I4,-1,I4,-1);
8145 VARIMP(BSTR,false_str,R4,0.0f,I4,-1);
8146 VARIMP(BSTR,false_str,R8,-1.0,I4,-1);
8147 VARIMP(BSTR,false_str,DATE,0,I4,-1);
8148 VARIMP(BSTR,false_str,BSTR,true_str,BOOL,-1);
8149 VARIMP(BSTR,false_str,BOOL,VARIANT_FALSE,BOOL,-1);
8150 VARIMP(BSTR,false_str,I1,0,I4,-1);
8151 VARIMP(BSTR,false_str,UI1,1,I2,-1);
8152 VARIMP(BSTR,false_str,UI2,1,I4,-1);
8153 VARIMP(BSTR,false_str,UI4,1,I4,-1);
8154 if (HAVE_OLEAUT32_I8)
8156 VARIMP(BSTR,false_str,I8,1,I8,-1);
8157 VARIMP(BSTR,false_str,UI8,1,I4,-1);
8159 VARIMP(BSTR,false_str,INT,-1,I4,-1);
8160 VARIMP(BSTR,false_str,UINT,1,I4,-1);
8161 VARIMP(BOOL,VARIANT_TRUE,EMPTY,0,I2,0);
8162 VARIMP(BOOL,VARIANT_TRUE,NULL,0,NULL,0);
8163 VARIMP(BOOL,VARIANT_TRUE,I2,-1,I2,-1);
8164 VARIMP(BOOL,VARIANT_TRUE,I4,-1,I4,-1);
8165 VARIMP(BOOL,VARIANT_TRUE,R4,0.0f,I4,0);
8166 VARIMP(BOOL,VARIANT_TRUE,R8,-1.0,I4,-1);
8167 VARIMP(BOOL,VARIANT_TRUE,DATE,0,I4,0);
8168 VARIMP(BOOL,VARIANT_TRUE,BSTR,true_str,BOOL,-1);
8169 VARIMP(BOOL,VARIANT_TRUE,BOOL,VARIANT_FALSE,BOOL,0);
8170 VARIMP(BOOL,VARIANT_TRUE,I1,0,I4,0);
8171 VARIMP(BOOL,VARIANT_TRUE,UI1,1,I2,1);
8172 VARIMP(BOOL,VARIANT_TRUE,UI2,1,I4,1);
8173 VARIMP(BOOL,VARIANT_TRUE,UI4,1,I4,1);
8174 if (HAVE_OLEAUT32_I8)
8176 VARIMP(BOOL,VARIANT_TRUE,I8,1,I8,1);
8177 VARIMP(BOOL,VARIANT_TRUE,UI8,1,I4,1);
8179 VARIMP(BOOL,VARIANT_TRUE,INT,-1,I4,-1);
8180 VARIMP(BOOL,VARIANT_TRUE,UINT,1,I4,1);
8181 VARIMP(I1,-1,EMPTY,0,I4,0);
8182 VARIMP(I1,-1,NULL,0,NULL,0);
8183 VARIMP(I1,-1,I2,-1,I4,-1);
8184 VARIMP(I1,-1,I4,-1,I4,-1);
8185 VARIMP(I1,-1,R4,0.0f,I4,0);
8186 VARIMP(I1,-1,R8,-1.0,I4,-1);
8187 VARIMP(I1,-1,DATE,0,I4,0);
8188 VARIMP(I1,-1,BSTR,true_str,I4,-1);
8189 VARIMP(I1,-1,BOOL,VARIANT_FALSE,I4,0);
8190 VARIMP(I1,-1,I1,0,I4,0);
8191 VARIMP(I1,-1,UI1,1,I4,1);
8192 VARIMP(I1,-1,UI2,1,I4,1);
8193 VARIMP(I1,-1,UI4,1,I4,1);
8194 if (HAVE_OLEAUT32_I8)
8196 VARIMP(I1,-1,I8,1,I8,1);
8197 VARIMP(I1,-1,UI8,1,I4,1);
8199 VARIMP(I1,-1,INT,-1,I4,-1);
8200 VARIMP(I1,-1,UINT,1,I4,1);
8201 VARIMP(UI1,0,EMPTY,0,I2,-1);
8202 VARIMP(UI1,0,NULL,0,UI1,255);
8203 VARIMP(UI1,0,I2,-1,I2,-1);
8204 VARIMP(UI1,0,I4,-1,I4,-1);
8205 VARIMP(UI1,0,R4,0.0f,I4,-1);
8206 VARIMP(UI1,0,R8,-1.0,I4,-1);
8207 VARIMP(UI1,0,DATE,0,I4,-1);
8208 VARIMP(UI1,0,BSTR,true_str,I2,-1);
8209 VARIMP(UI1,0,BOOL,VARIANT_FALSE,I2,-1);
8210 VARIMP(UI1,0,I1,0,I4,-1);
8211 VARIMP(UI1,0,UI1,1,UI1,255);
8212 VARIMP(UI1,0,UI2,1,I4,-1);
8213 VARIMP(UI1,0,UI4,1,I4,-1);
8214 if (HAVE_OLEAUT32_I8)
8216 VARIMP(UI1,0,I8,1,I8,-1);
8217 VARIMP(UI1,0,UI8,1,I4,-1);
8219 VARIMP(UI1,0,INT,-1,I4,-1);
8220 VARIMP(UI1,0,UINT,1,I4,-1);
8221 VARIMP(UI2,0,EMPTY,0,I4,-1);
8222 VARIMP(UI2,0,NULL,0,I4,-1);
8223 VARIMP(UI2,0,I2,-1,I4,-1);
8224 VARIMP(UI2,0,I4,-1,I4,-1);
8225 VARIMP(UI2,0,R4,0.0f,I4,-1);
8226 VARIMP(UI2,0,R8,-1.0,I4,-1);
8227 VARIMP(UI2,0,DATE,0,I4,-1);
8228 VARIMP(UI2,0,BSTR,true_str,I4,-1);
8229 VARIMP(UI2,0,BOOL,VARIANT_FALSE,I4,-1);
8230 VARIMP(UI2,0,I1,0,I4,-1);
8231 VARIMP(UI2,0,UI1,1,I4,-1);
8232 VARIMP(UI2,0,UI2,1,I4,-1);
8233 VARIMP(UI2,0,UI4,1,I4,-1);
8234 if (HAVE_OLEAUT32_I8)
8236 VARIMP(UI2,0,I8,1,I8,-1);
8237 VARIMP(UI2,0,UI8,1,I4,-1);
8239 VARIMP(UI2,0,INT,-1,I4,-1);
8240 VARIMP(UI2,0,UINT,1,I4,-1);
8241 VARIMP(UI4,0,EMPTY,0,I4,-1);
8242 VARIMP(UI4,0,NULL,0,I4,-1);
8243 VARIMP(UI4,0,I2,-1,I4,-1);
8244 VARIMP(UI4,0,I4,-1,I4,-1);
8245 VARIMP(UI4,0,R4,0.0f,I4,-1);
8246 VARIMP(UI4,0,R8,-1.0,I4,-1);
8247 VARIMP(UI4,0,DATE,0,I4,-1);
8248 VARIMP(UI4,0,BSTR,true_str,I4,-1);
8249 VARIMP(UI4,0,BOOL,VARIANT_FALSE,I4,-1);
8250 VARIMP(UI4,0,I1,0,I4,-1);
8251 VARIMP(UI4,0,UI1,1,I4,-1);
8252 VARIMP(UI4,0,UI2,1,I4,-1);
8253 VARIMP(UI4,0,UI4,1,I4,-1);
8254 if (HAVE_OLEAUT32_I8)
8256 VARIMP(UI4,0,I8,1,I8,-1);
8257 VARIMP(UI4,0,UI8,1,I4,-1);
8259 VARIMP(UI4,0,INT,-1,I4,-1);
8260 VARIMP(UI4,0,UINT,1,I4,-1);
8261 if (HAVE_OLEAUT32_I8)
8263 VARIMP(I8,-1,EMPTY,0,I8,0);
8264 VARIMP(I8,-1,NULL,0,NULL,0);
8265 VARIMP(I8,-1,I2,-1,I8,-1);
8266 VARIMP(I8,-1,I4,-1,I8,-1);
8267 VARIMP(I8,-1,R4,0.0f,I8,0);
8268 VARIMP(I8,-1,R8,-1.0,I8,-1);
8269 VARIMP(I8,-1,DATE,0,I8,0);
8270 VARIMP(I8,-1,BSTR,true_str,I8,-1);
8271 VARIMP(I8,-1,BOOL,VARIANT_FALSE,I8,0);
8272 VARIMP(I8,-1,I1,0,I8,0);
8273 VARIMP(I8,-1,UI1,1,I8,1);
8274 VARIMP(I8,-1,UI2,1,I8,1);
8275 VARIMP(I8,-1,UI4,1,I8,1);
8276 VARIMP(I8,-1,I8,1,I8,1);
8277 VARIMP(I8,-1,UI8,1,I8,1);
8278 VARIMP(I8,-1,UINT,1,I8,1);
8279 VARIMP(UI8,0,EMPTY,0,I4,-1);
8280 VARIMP(UI8,0,NULL,0,I4,-1);
8281 VARIMP(UI8,0,I2,-1,I4,-1);
8282 VARIMP(UI8,0,I4,-1,I4,-1);
8283 VARIMP(UI8,0,R4,0.0f,I4,-1);
8284 VARIMP(UI8,0,R8,-1.0,I4,-1);
8285 VARIMP(UI8,0,DATE,0,I4,-1);
8286 VARIMP(UI8,0,BSTR,true_str,I4,-1);
8287 VARIMP(UI8,0,BOOL,VARIANT_FALSE,I4,-1);
8288 VARIMP(UI8,0,I1,0,I4,-1);
8289 VARIMP(UI8,0,UI1,1,I4,-1);
8290 VARIMP(UI8,0,UI2,1,I4,-1);
8291 VARIMP(UI8,0,UI4,1,I4,-1);
8292 VARIMP(UI8,0,I8,1,I8,-1);
8293 VARIMP(UI8,0,UI8,1,I4,-1);
8294 VARIMP(UI8,0,INT,-1,I4,-1);
8295 VARIMP(UI8,0,UINT,1,I4,-1);
8297 VARIMP(INT,-1,EMPTY,0,I4,0);
8298 VARIMP(INT,-1,NULL,0,NULL,0);
8299 VARIMP(INT,-1,I2,-1,I4,-1);
8300 VARIMP(INT,-1,I4,-1,I4,-1);
8301 VARIMP(INT,-1,R4,0.0f,I4,0);
8302 VARIMP(INT,-1,R8,-1.0,I4,-1);
8303 VARIMP(INT,-1,DATE,0,I4,0);
8304 VARIMP(INT,-1,BSTR,true_str,I4,-1);
8305 VARIMP(INT,-1,BOOL,VARIANT_FALSE,I4,0);
8306 VARIMP(INT,-1,I1,0,I4,0);
8307 VARIMP(INT,-1,UI1,1,I4,1);
8308 VARIMP(INT,-1,UI2,1,I4,1);
8309 VARIMP(INT,-1,UI4,1,I4,1);
8310 if (HAVE_OLEAUT32_I8)
8312 VARIMP(INT,-1,I8,1,I8,1);
8313 VARIMP(INT,-1,UI8,1,I4,1);
8315 VARIMP(INT,-1,INT,-1,I4,-1);
8316 VARIMP(INT,-1,UINT,1,I4,1);
8317 VARIMP(UINT,1,EMPTY,0,I4,-2);
8318 VARIMP(UINT,1,NULL,0,I4,-2);
8319 VARIMP(UINT,1,I2,-1,I4,-1);
8320 VARIMP(UINT,1,I4,-1,I4,-1);
8321 VARIMP(UINT,1,R4,0.0f,I4,-2);
8322 VARIMP(UINT,1,R8,-1.0,I4,-1);
8323 VARIMP(UINT,1,DATE,0,I4,-2);
8324 VARIMP(UINT,1,BSTR,true_str,I4,-1);
8325 VARIMP(UINT,1,BOOL,VARIANT_FALSE,I4,-2);
8326 VARIMP(UINT,1,I1,0,I4,-2);
8327 VARIMP(UINT,1,UI1,1,I4,-1);
8328 VARIMP(UINT,1,UI2,1,I4,-1);
8329 VARIMP(UINT,1,UI4,1,I4,-1);
8330 if (HAVE_OLEAUT32_I8)
8332 VARIMP(UINT,1,I8,1,I8,-1);
8333 VARIMP(UINT,1,UI8,1,I4,-1);
8335 VARIMP(UINT,1,INT,-1,I4,-1);
8336 VARIMP(UINT,1,UINT,1,I4,-1);
8338 /* Manually test some VT_CY, VT_DECIMAL variants */
8340 hres = VarCyFromI4(1, &V_CY(&cy));
8341 ok(hres == S_OK, "VarCyFromI4 failed!\n");
8342 V_VT(&dec) = VT_DECIMAL;
8343 hres = VarDecFromR8(2.0, &V_DECIMAL(&dec));
8344 ok(hres == S_OK, "VarDecFromR4 failed!\n");
8345 memset(&left, 0, sizeof(left));
8346 memset(&right, 0, sizeof(right));
8347 V_VT(&left) = VT_I4;
8349 V_VT(&right) = VT_I8;
8352 hres = pVarImp(&cy, &cy, &result);
8353 ok(hres == S_OK && V_VT(&result) == VT_I4,
8354 "VARIMP: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8355 S_OK, hres, vtstr(V_VT(&result)));
8356 ok(hres == S_OK && V_I4(&result) == -1,
8357 "VARIMP: CY value %d, expected %d\n", V_I4(&result), -1);
8359 if (HAVE_OLEAUT32_I8)
8361 hres = pVarImp(&cy, &right, &result);
8362 ok(hres == S_OK && V_VT(&result) == VT_I8,
8363 "VARIMP: expected coerced hres 0x%X type VT_I8, got hres 0x%X type %s!\n",
8364 S_OK, hres, vtstr(V_VT(&result)));
8365 ok(hres == S_OK && V_I8(&result) == -2,
8366 "VARIMP: CY value %x%08x, expected %d\n",
8367 (DWORD)((V_I8(&result)) >> 32), (DWORD)(V_I8(&result)), -2);
8370 hres = pVarImp(&left, &cy, &result);
8371 ok(hres == S_OK && V_VT(&result) == VT_I4,
8372 "VARIMP: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8373 S_OK, hres, vtstr(V_VT(&result)));
8374 ok(hres == S_OK && V_I4(&result) == -1,
8375 "VARIMP: CY value %d, expected %d\n", V_I4(&result), -1);
8377 hres = pVarImp(&left, &dec, &result);
8378 ok(hres == S_OK && V_VT(&result) == VT_I4,
8379 "VARIMP: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8380 S_OK, hres, vtstr(V_VT(&result)));
8381 ok(hres == S_OK && V_I4(&result) == -1,
8382 "VARIMP: DECIMAL value %d, expected %d\n", V_I4(&result), -1);
8384 hres = pVarImp(&dec, &dec, &result);
8385 ok(hres == S_OK && V_VT(&result) == VT_I4,
8386 "VARIMP: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8387 S_OK, hres, vtstr(V_VT(&result)));
8388 ok(hres == S_OK && V_I4(&result) == -1,
8389 "VARIMP: DECIMAL value %d, expected %d\n", V_I4(&result), -1);
8391 if (HAVE_OLEAUT32_I8)
8393 hres = pVarImp(&dec, &right, &result);
8394 ok(hres == S_OK && V_VT(&result) == VT_I8,
8395 "VARIMP: expected coerced hres 0x%X type VT_I8, got hres 0x%X type %s!\n",
8396 S_OK, hres, vtstr(V_VT(&result)));
8397 ok(hres == S_OK && V_I8(&result) == -3,
8398 "VARIMP: DECIMAL value 0x%x%08x, expected %d\n",
8399 (DWORD)(V_I8(&result) >>32), (DWORD)V_I8(&result), -3);
8402 SysFreeString(false_str);
8403 SysFreeString(true_str);
8411 test_VariantClear();
8413 test_VariantCopyInd();
8414 test_VarParseNumFromStr();
8415 test_VarNumFromParseNum();
8416 test_VarUdateFromDate();
8417 test_VarDateFromUdate();
8418 test_SystemTimeToVariantTime();
8419 test_VariantTimeToSystemTime();
8420 test_DosDateTimeToVariantTime();
8421 test_VariantTimeToDosDateTime();