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 /* Is a given function exported from oleaut32? */
55 #define HAVE_FUNC(func) ((void*)GetProcAddress(hOleaut32, #func) != NULL)
57 /* Have IRecordInfo data type? */
58 #define HAVE_OLEAUT32_RECORD HAVE_FUNC(SafeArraySetRecordInfo)
59 /* Have CY data type? */
60 #define HAVE_OLEAUT32_CY HAVE_FUNC(VarCyAdd)
61 /* Have I8/UI8 data type? */
62 #define HAVE_OLEAUT32_I8 HAVE_FUNC(VarI8FromI1)
63 /* Is this an ancient version with support for only I2/I4/R4/R8/DATE? */
64 #define IS_ANCIENT (!HAVE_FUNC(VarI1FromI2))
66 /* When comparing floating point values we cannot expect an exact match
67 * because the rounding errors depend on the exact algorithm.
69 #define EQ_DOUBLE(a,b) (fabs((a)-(b))<1e-14)
70 #define EQ_FLOAT(a,b) (fabs((a)-(b))<1e-7)
72 #define SKIPTESTS(a) if((a > VT_CLSID+10) && (a < VT_BSTR_BLOB-10)) continue;
74 /* Allow our test macros to work for VT_NULL and VT_EMPTY too */
75 #define V_EMPTY(v) V_I4(v)
76 #define V_NULL(v) V_I4(v)
78 /* Size constraints for overflow tests */
80 #define I1_MIN ((-I1_MAX)-1)
84 #define I2_MIN ((-I2_MAX)-1)
85 #define UI2_MAX 0xffff
87 #define I4_MAX 0x7fffffff
88 #define I4_MIN ((-I4_MAX)-1)
89 #define UI4_MAX 0xffffffff
91 #define I8_MAX (((LONGLONG)I4_MAX << 32) | UI4_MAX)
92 #define I8_MIN ((-I8_MAX)-1)
93 #define UI8_MAX (((ULONGLONG)UI4_MAX << 32) | UI4_MAX)
95 #define DATE_MAX 2958465
96 #define DATE_MIN -657434
97 #define R4_MAX FLT_MAX
98 #define R4_MIN FLT_MIN
99 #define R8_MAX DBL_MAX
100 #define R8_MIN DBL_MIN
102 /* Macros to set a DECIMAL */
103 #define SETDEC(dec, scl, sgn, hi, lo) S(U(dec)).scale = (BYTE)scl; \
104 S(U(dec)).sign = (BYTE)sgn; dec.Hi32 = (ULONG)hi; \
105 U1(dec).Lo64 = (ULONG64)lo
106 #define SETDEC64(dec, scl, sgn, hi, mid, lo) S(U(dec)).scale = (BYTE)scl; \
107 S(U(dec)).sign = (BYTE)sgn; dec.Hi32 = (ULONG)hi; \
108 S1(U1(dec)).Mid32 = mid; S1(U1(dec)).Lo32 = lo;
110 static inline int strcmpW( const WCHAR *str1, const WCHAR *str2 )
112 while (*str1 && (*str1 == *str2)) { str1++; str2++; }
113 return *str1 - *str2;
116 /* return the string text of a given variant type */
117 static const char *vtstr(int x)
139 return "VT_DISPATCH";
175 return "VT_SAFEARRAY";
179 return "VT_USERDEFINED";
187 return "VT_FILETIME";
195 return "VT_STREAMED_OBJECT";
197 return "VT_STORED_OBJECT";
199 return "VT_BLOB_OBJECT";
205 return "VT_BSTR_BLOB/VT_ILLEGALMASKED/VT_TYPEMASK";
213 return "VT_RESERVED";
222 static void test_VariantInit(void)
226 /* Test that VariantInit() only sets the type */
227 memset(&v1, -1, sizeof(v1));
229 V_VT(&v2) = VT_EMPTY;
231 ok(!memcmp(&v1, &v2, sizeof(v1)), "VariantInit() set extra fields\n");
234 /* All possible combinations of extra V_VT() flags */
235 static const VARTYPE ExtraFlags[16] =
244 VT_VECTOR|VT_RESERVED,
245 VT_VECTOR|VT_ARRAY|VT_BYREF,
246 VT_VECTOR|VT_ARRAY|VT_RESERVED,
247 VT_VECTOR|VT_BYREF|VT_RESERVED,
248 VT_VECTOR|VT_ARRAY|VT_BYREF|VT_RESERVED,
250 VT_ARRAY|VT_RESERVED,
251 VT_ARRAY|VT_BYREF|VT_RESERVED,
252 VT_BYREF|VT_RESERVED,
255 /* Determine if a vt is valid for VariantClear() */
256 static int IsValidVariantClearVT(VARTYPE vt, VARTYPE extraFlags)
260 /* Only the following flags/types are valid */
261 if ((vt <= VT_LPWSTR || vt == VT_RECORD || vt == VT_CLSID) &&
263 (vt < (VARTYPE)24 || vt > (VARTYPE)31) &&
264 (!(extraFlags & (VT_BYREF|VT_ARRAY)) || vt > VT_NULL) &&
265 (extraFlags == 0 || extraFlags == VT_BYREF || extraFlags == VT_ARRAY ||
266 extraFlags == (VT_ARRAY|VT_BYREF)))
269 if ((vt == VT_RECORD && !HAVE_OLEAUT32_RECORD) ||
270 ((vt == VT_I8 || vt == VT_UI8) && !HAVE_OLEAUT32_I8))
271 ret = 0; /* Old versions of oleaut32 */
277 const IUnknownVtbl *lpVtbl;
280 } test_VariantClearImpl;
282 static HRESULT WINAPI VC_QueryInterface(LPUNKNOWN iface,REFIID riid,LPVOID *ppobj)
284 test_VariantClearImpl *This = (test_VariantClearImpl *)iface;
286 return E_NOINTERFACE;
289 static ULONG WINAPI VC_AddRef(LPUNKNOWN iface) {
290 test_VariantClearImpl *This = (test_VariantClearImpl *)iface;
292 return InterlockedIncrement(&This->ref);
295 static ULONG WINAPI VC_Release(LPUNKNOWN iface) {
296 test_VariantClearImpl *This = (test_VariantClearImpl *)iface;
297 /* static class, won't be freed */
299 return InterlockedDecrement(&This->ref);
302 static const IUnknownVtbl test_VariantClear_vtbl = {
308 static test_VariantClearImpl test_myVariantClearImpl = {&test_VariantClear_vtbl, 1, 0};
310 static void test_VariantClear(void)
320 /* Crashes: Native does not test input for NULL, so neither does Wine */
321 hres = VariantClear(NULL);
324 /* Only the type field is set, to VT_EMPTY */
327 hres = VariantClear(&v);
328 ok((hres == S_OK && V_VT(&v) == VT_EMPTY) ||
329 (IS_ANCIENT && hres == DISP_E_BADVARTYPE && V_VT(&v) == VT_UI4),
330 "VariantClear: Type set to %d, res %08x\n", V_VT(&v), hres);
331 ok(V_UI4(&v) == ~0u, "VariantClear: Overwrote value\n");
333 /* Test all possible V_VT values.
334 * Also demonstrates that null pointers in 'v' are not dereferenced.
335 * Individual variant tests should test VariantClear() with non-NULL values.
337 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]) && !IS_ANCIENT; i++)
341 for (vt = 0; vt <= VT_BSTR_BLOB; vt++)
343 HRESULT hExpected = DISP_E_BADVARTYPE;
347 memset(&v, 0, sizeof(v));
348 V_VT(&v) = vt | ExtraFlags[i];
350 hres = VariantClear(&v);
352 if (IsValidVariantClearVT(vt, ExtraFlags[i]))
355 ok(hres == hExpected, "VariantClear: expected 0x%X, got 0x%X for vt %d | 0x%X\n",
356 hExpected, hres, vt, ExtraFlags[i]);
360 /* Some BYREF tests with non-NULL ptrs */
365 V_VT(&v) = VT_VARIANT | VT_BYREF;
366 V_VARIANTREF(&v) = &v2;
368 hres = VariantClear(&v);
369 ok(hres == S_OK, "ret %08x\n", hres);
370 ok(V_VT(&v) == 0, "vt %04x\n", V_VT(&v));
371 ok(V_VARIANTREF(&v) == &v2, "variant ref %p\n", V_VARIANTREF(&v2));
372 ok(V_VT(&v2) == VT_I4, "vt %04x\n", V_VT(&v2));
373 ok(V_I4(&v2) == 0x1234, "i4 %04x\n", V_I4(&v2));
377 V_VT(&v) = VT_I4 | VT_BYREF;
380 hres = VariantClear(&v);
381 ok(hres == S_OK, "ret %08x\n", hres);
382 ok(V_VT(&v) == 0, "vt %04x\n", V_VT(&v));
383 ok(V_I4REF(&v) == &i4, "i4 ref %p\n", V_I4REF(&v2));
384 ok(i4 == 0x4321, "i4 changed %08x\n", i4);
388 V_VT(&v) = VT_UNKNOWN;
389 V_UNKNOWN(&v) = (IUnknown*)&test_myVariantClearImpl;
390 test_myVariantClearImpl.events = 0;
391 hres = VariantClear(&v);
392 ok(hres == S_OK, "ret %08x\n", hres);
393 ok(V_VT(&v) == 0, "vt %04x\n", V_VT(&v));
394 ok(V_UNKNOWN(&v) == (IUnknown*)&test_myVariantClearImpl, "unknown %p\n", V_UNKNOWN(&v));
395 /* Check that Release got called, but nothing else */
396 ok(test_myVariantClearImpl.events == 0x4, "Unexpected call. events %08x\n", test_myVariantClearImpl.events);
399 punk = (IUnknown*)&test_myVariantClearImpl;
400 V_VT(&v) = VT_UNKNOWN | VT_BYREF;
401 V_UNKNOWNREF(&v) = &punk;
402 test_myVariantClearImpl.events = 0;
403 hres = VariantClear(&v);
404 ok(hres == S_OK, "ret %08x\n", hres);
405 ok(V_VT(&v) == 0, "vt %04x\n", V_VT(&v));
406 ok(V_UNKNOWNREF(&v) == &punk, "unknown ref %p\n", V_UNKNOWNREF(&v));
407 /* Check that nothing got called */
408 ok(test_myVariantClearImpl.events == 0, "Unexpected call. events %08x\n", test_myVariantClearImpl.events);
411 V_VT(&v) = VT_DISPATCH;
412 V_DISPATCH(&v) = (IDispatch*)&test_myVariantClearImpl;
413 test_myVariantClearImpl.events = 0;
414 hres = VariantClear(&v);
415 ok(hres == S_OK, "ret %08x\n", hres);
416 ok(V_VT(&v) == 0, "vt %04x\n", V_VT(&v));
417 ok(V_DISPATCH(&v) == (IDispatch*)&test_myVariantClearImpl, "dispatch %p\n", V_DISPATCH(&v));
418 /* Check that Release got called, but nothing else */
419 ok(test_myVariantClearImpl.events == 0x4, "Unexpected call. events %08x\n", test_myVariantClearImpl.events);
422 punk = (IUnknown*)&test_myVariantClearImpl;
423 V_VT(&v) = VT_DISPATCH | VT_BYREF;
424 V_DISPATCHREF(&v) = (IDispatch**)&punk;
425 test_myVariantClearImpl.events = 0;
426 hres = VariantClear(&v);
427 ok(hres == S_OK, "ret %08x\n", hres);
428 ok(V_VT(&v) == 0, "vt %04x\n", V_VT(&v));
429 ok(V_DISPATCHREF(&v) == (IDispatch**)&punk, "dispatch ref %p\n", V_DISPATCHREF(&v));
430 /* Check that nothing got called */
431 ok(test_myVariantClearImpl.events == 0, "Unexpected call. events %08x\n", test_myVariantClearImpl.events);
434 static void test_VariantCopy(void)
436 VARIANTARG vSrc, vDst;
439 HRESULT hres, hExpected;
441 /* Establish that the failure/other cases are dealt with. Individual tests
442 * for each type should verify that data is copied correctly, references
447 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]) && !IS_ANCIENT; i++)
449 for (vt = 0; vt <= VT_BSTR_BLOB; vt++)
453 memset(&vSrc, 0, sizeof(vSrc));
454 V_VT(&vSrc) = vt | ExtraFlags[i];
456 hExpected = DISP_E_BADVARTYPE;
457 /* src is allowed to be a VT_CLSID */
458 if (vt != VT_CLSID && IsValidVariantClearVT(vt, ExtraFlags[i]))
461 hres = VariantCopy(&vSrc, &vSrc);
463 ok(hres == hExpected,
464 "Copy(src==dst): expected 0x%X, got 0x%X for src==dest vt %d|0x%X\n",
465 hExpected, hres, vt, ExtraFlags[i]);
469 /* Test that if VariantClear() fails on dest, the function fails. This also
470 * shows that dest is in fact cleared and not just overwritten
472 memset(&vSrc, 0, sizeof(vSrc));
473 V_VT(&vSrc) = VT_UI1;
475 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]) && !IS_ANCIENT; i++)
477 for (vt = 0; vt <= VT_BSTR_BLOB; vt++)
481 hExpected = DISP_E_BADVARTYPE;
483 memset(&vDst, 0, sizeof(vDst));
484 V_VT(&vDst) = vt | ExtraFlags[i];
486 if (IsValidVariantClearVT(vt, ExtraFlags[i]))
489 hres = VariantCopy(&vDst, &vSrc);
491 ok(hres == hExpected,
492 "Copy(bad dst): expected 0x%X, got 0x%X for dest vt %d|0x%X\n",
493 hExpected, hres, vt, ExtraFlags[i]);
495 ok(V_VT(&vDst) == VT_UI1,
496 "Copy(bad dst): expected vt = VT_UI1, got %d\n", V_VT(&vDst));
500 /* Test that VariantClear() checks vSrc for validity before copying */
501 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]) && !IS_ANCIENT; i++)
503 for (vt = 0; vt <= VT_BSTR_BLOB; vt++)
507 hExpected = DISP_E_BADVARTYPE;
509 memset(&vDst, 0, sizeof(vDst));
510 V_VT(&vDst) = VT_EMPTY;
512 memset(&vSrc, 0, sizeof(vSrc));
513 V_VT(&vSrc) = vt | ExtraFlags[i];
515 /* src is allowed to be a VT_CLSID */
516 if (vt != VT_CLSID && IsValidVariantClearVT(vt, ExtraFlags[i]))
519 hres = VariantCopy(&vDst, &vSrc);
521 ok(hres == hExpected,
522 "Copy(bad src): expected 0x%X, got 0x%X for src vt %d|0x%X\n",
523 hExpected, hres, vt, ExtraFlags[i]);
525 ok(V_VT(&vDst) == (vt|ExtraFlags[i]),
526 "Copy(bad src): expected vt = %d, got %d\n",
527 vt | ExtraFlags[i], V_VT(&vDst));
531 /* Test that copying a NULL BSTR results in an empty BSTR */
532 memset(&vDst, 0, sizeof(vDst));
533 V_VT(&vDst) = VT_EMPTY;
534 memset(&vSrc, 0, sizeof(vSrc));
535 V_VT(&vSrc) = VT_BSTR;
536 hres = VariantCopy(&vDst, &vSrc);
537 ok(hres == S_OK, "Copy(NULL BSTR): Failed to copy a NULL BSTR\n");
540 ok((V_VT(&vDst) == VT_BSTR) && V_BSTR(&vDst),
541 "Copy(NULL BSTR): should have non-NULL result\n");
542 if ((V_VT(&vDst) == VT_BSTR) && V_BSTR(&vDst))
544 ok(*V_BSTR(&vDst) == 0, "Copy(NULL BSTR): result not empty\n");
549 /* Determine if a vt is valid for VariantCopyInd() */
550 static int IsValidVariantCopyIndVT(VARTYPE vt, VARTYPE extraFlags)
554 if ((extraFlags & VT_ARRAY) ||
555 (vt > VT_NULL && vt != (VARTYPE)15 && vt < VT_VOID &&
556 !(extraFlags & (VT_VECTOR|VT_RESERVED))))
563 static void test_VariantCopyInd(void)
565 VARIANTARG vSrc, vDst, vRef, vRef2;
569 HRESULT hres, hExpected;
571 memset(buffer, 0, sizeof(buffer));
574 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]) && !IS_ANCIENT; i++)
576 if (ExtraFlags[i] & VT_ARRAY)
577 continue; /* Native crashes on NULL safearray */
579 for (vt = 0; vt <= VT_BSTR_BLOB; vt++)
583 memset(&vSrc, 0, sizeof(vSrc));
584 V_VT(&vSrc) = vt | ExtraFlags[i];
586 hExpected = DISP_E_BADVARTYPE;
587 if (!(ExtraFlags[i] & VT_BYREF))
589 /* if src is not by-reference, acts as VariantCopy() */
590 if (vt != VT_CLSID && IsValidVariantClearVT(vt, ExtraFlags[i]))
595 if (vt == VT_SAFEARRAY || vt == VT_BSTR || vt == VT_UNKNOWN ||
596 vt == VT_DISPATCH || vt == VT_RECORD)
597 continue; /* Need valid ptrs for deep copies */
599 V_BYREF(&vSrc) = &buffer;
600 hExpected = E_INVALIDARG;
602 if ((vt == VT_I8 || vt == VT_UI8) &&
603 ExtraFlags[i] == VT_BYREF)
605 if (HAVE_OLEAUT32_I8)
606 hExpected = S_OK; /* Only valid if I8 is a known type */
608 else if (IsValidVariantCopyIndVT(vt, ExtraFlags[i]))
612 hres = VariantCopyInd(&vSrc, &vSrc);
614 ok(hres == hExpected,
615 "CopyInd(src==dst): expected 0x%X, got 0x%X for src==dst vt %d|0x%X\n",
616 hExpected, hres, vt, ExtraFlags[i]);
621 memset(&vSrc, 0, sizeof(vSrc));
622 V_VT(&vSrc) = VT_UI1|VT_BYREF;
623 V_BYREF(&vSrc) = &buffer;
625 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]) && !IS_ANCIENT; i++)
627 for (vt = 0; vt <= VT_BSTR_BLOB; vt++)
631 memset(&vDst, 0, sizeof(vDst));
632 V_VT(&vDst) = vt | ExtraFlags[i];
634 hExpected = DISP_E_BADVARTYPE;
636 if (IsValidVariantClearVT(vt, ExtraFlags[i]))
639 hres = VariantCopyInd(&vDst, &vSrc);
641 ok(hres == hExpected,
642 "CopyInd(bad dst): expected 0x%X, got 0x%X for dst vt %d|0x%X\n",
643 hExpected, hres, vt, ExtraFlags[i]);
645 ok(V_VT(&vDst) == VT_UI1,
646 "CopyInd(bad dst): expected vt = VT_UI1, got %d\n", V_VT(&vDst));
651 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]) && !IS_ANCIENT; i++)
653 if (ExtraFlags[i] & VT_ARRAY)
654 continue; /* Native crashes on NULL safearray */
656 for (vt = 0; vt <= VT_BSTR_BLOB; vt++)
660 memset(&vDst, 0, sizeof(vDst));
661 V_VT(&vDst) = VT_EMPTY;
663 memset(&vSrc, 0, sizeof(vSrc));
664 V_VT(&vSrc) = vt | ExtraFlags[i];
666 hExpected = DISP_E_BADVARTYPE;
667 if (!(ExtraFlags[i] & VT_BYREF))
669 /* if src is not by-reference, acts as VariantCopy() */
670 if (vt != VT_CLSID && IsValidVariantClearVT(vt, ExtraFlags[i]))
675 if (vt == VT_SAFEARRAY || vt == VT_BSTR || vt == VT_UNKNOWN ||
676 vt == VT_DISPATCH || vt == VT_RECORD)
677 continue; /* Need valid ptrs for deep copies, see vartype.c */
679 V_BYREF(&vSrc) = &buffer;
681 hExpected = E_INVALIDARG;
683 if ((vt == VT_I8 || vt == VT_UI8) &&
684 ExtraFlags[i] == VT_BYREF)
686 if (HAVE_OLEAUT32_I8)
687 hExpected = S_OK; /* Only valid if I8 is a known type */
689 else if (IsValidVariantCopyIndVT(vt, ExtraFlags[i]))
693 hres = VariantCopyInd(&vDst, &vSrc);
695 ok(hres == hExpected,
696 "CopyInd(bad src): expected 0x%X, got 0x%X for src vt %d|0x%X\n",
697 hExpected, hres, vt, ExtraFlags[i]);
700 if (vt == VT_VARIANT && ExtraFlags[i] == VT_BYREF)
702 /* Type of vDst should be the type of the referenced variant.
703 * Since we set the buffer to all zeros, its type should be
706 ok(V_VT(&vDst) == VT_EMPTY,
707 "CopyInd(bad src): expected dst vt = VT_EMPTY, got %d|0x%X\n",
708 V_VT(&vDst) & VT_TYPEMASK, V_VT(&vDst) & ~VT_TYPEMASK);
712 ok(V_VT(&vDst) == (vt|(ExtraFlags[i] & ~VT_BYREF)),
713 "CopyInd(bad src): expected dst vt = %d|0x%X, got %d|0x%X\n",
714 vt, ExtraFlags[i] & ~VT_BYREF,
715 V_VT(&vDst) & VT_TYPEMASK, V_VT(&vDst) & ~VT_TYPEMASK);
721 /* By-reference variants are dereferenced */
722 V_VT(&vRef) = VT_UI1;
724 V_VT(&vSrc) = VT_VARIANT|VT_BYREF;
725 V_VARIANTREF(&vSrc) = &vRef;
728 hres = VariantCopyInd(&vDst, &vSrc);
729 ok(V_VT(&vDst) == VT_UI1 && V_UI1(&vDst) == 0x77,
730 "CopyInd(deref): expected dst vt = VT_UI1, val 0x77, got %d|0x%X, 0x%2X\n",
731 V_VT(&vDst) & VT_TYPEMASK, V_VT(&vDst) & ~VT_TYPEMASK, V_UI1(&vDst));
733 /* By-reference variant to a by-reference type succeeds */
734 V_VT(&vRef) = VT_UI1|VT_BYREF;
735 V_UI1REF(&vRef) = buffer; buffer[0] = 0x88;
736 V_VT(&vSrc) = VT_VARIANT|VT_BYREF;
737 V_VARIANTREF(&vSrc) = &vRef;
740 hres = VariantCopyInd(&vDst, &vSrc);
741 ok(V_VT(&vDst) == VT_UI1 && V_UI1(&vDst) == 0x88,
742 "CopyInd(deref): expected dst vt = VT_UI1, val 0x77, got %d|0x%X, 0x%2X\n",
743 V_VT(&vDst) & VT_TYPEMASK, V_VT(&vDst) & ~VT_TYPEMASK, V_UI1(&vDst));
745 /* But a by-reference variant to a by-reference variant fails */
746 V_VT(&vRef2) = VT_UI1;
747 V_UI1(&vRef2) = 0x77;
748 V_VT(&vRef) = VT_VARIANT|VT_BYREF;
749 V_VARIANTREF(&vRef) = &vRef2;
750 V_VT(&vSrc) = VT_VARIANT|VT_BYREF;
751 V_VARIANTREF(&vSrc) = &vRef;
754 hres = VariantCopyInd(&vDst, &vSrc);
755 ok(hres == E_INVALIDARG,
756 "CopyInd(ref->ref): expected E_INVALIDARG, got 0x%08x\n", hres);
759 static HRESULT (WINAPI *pVarParseNumFromStr)(OLECHAR*,LCID,ULONG,NUMPARSE*,BYTE*);
761 /* Macros for converting and testing the result of VarParseNumFromStr */
763 #define CONVERTN(str,dig,flags) MultiByteToWideChar(CP_ACP,0,str,-1,buff,sizeof(buff)/sizeof(WCHAR)); \
764 memset(rgb, FAILDIG, sizeof(rgb)); memset(&np,-1,sizeof(np)); np.cDig = dig; np.dwInFlags = flags; \
765 hres = pVarParseNumFromStr(buff,lcid,LOCALE_NOUSEROVERRIDE,&np,rgb)
766 #define CONVERT(str,flags) CONVERTN(str,sizeof(rgb),flags)
767 #define EXPECT(a,b,c,d,e,f) ok(hres == (HRESULT)S_OK, "Call failed, hres = %08x\n", hres); \
768 if (hres == (HRESULT)S_OK) { \
769 ok(np.cDig == (a), "Expected cDig = %d, got %d\n", (a), np.cDig); \
770 ok(np.dwInFlags == (b), "Expected dwInFlags = 0x%x, got 0x%x\n", (ULONG)(b), np.dwInFlags); \
771 ok(np.dwOutFlags == (c), "Expected dwOutFlags = 0x%x, got 0x%x\n", (ULONG)(c), np.dwOutFlags); \
772 ok(np.cchUsed == (d), "Expected cchUsed = %d, got %d\n", (d), np.cchUsed); \
773 ok(np.nBaseShift == (e), "Expected nBaseShift = %d, got %d\n", (e), np.nBaseShift); \
774 ok(np.nPwr10 == (f), "Expected nPwr10 = %d, got %d\n", (f), np.nPwr10); \
776 #define EXPECTRGB(a,b) ok(rgb[a] == b, "Digit[%d], expected %d, got %d\n", a, b, rgb[a])
777 #define EXPECTFAIL ok(hres == (HRESULT)DISP_E_TYPEMISMATCH, "Call succeeded, hres = %08x\n", hres)
778 #define EXPECT2(a,b) EXPECTRGB(0,a); EXPECTRGB(1,b)
780 static void test_VarParseNumFromStr(void)
784 /* Ensure all tests are using the same locale characters for '$', ',' etc */
785 LCID lcid = MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT);
791 CHECKPTR(VarParseNumFromStr);
793 /* Consume a single digit */
798 /* cDig is not literal digits - zeros are suppressed and nPwr10 is increased */
801 /* Note: Win32 writes the trailing zeros if they are within cDig's limits,
802 * but then excludes them from the returned cDig count.
803 * In our implementation we don't bother writing them at all.
807 /* if cDig is too small and numbers follow, sets INEXACT */
809 EXPECT(1,0,NUMPRS_INEXACT,2,0,1);
812 /* Strips leading zeros */
817 /* Strips leading zeros */
823 /* Fails on non digits */
826 EXPECTRGB(0,FAILDIG);
828 /** NUMPRS_LEADING_WHITE/NUMPRS_TRAILING_WHITE **/
830 /* Without flag, fails on whitespace */
833 EXPECTRGB(0,FAILDIG);
836 /* With flag, consumes whitespace */
837 CONVERT(" 0", NUMPRS_LEADING_WHITE);
838 EXPECT(1,NUMPRS_LEADING_WHITE,NUMPRS_LEADING_WHITE,2,0,0);
841 /* Test TAB once, then assume it acts as space for all cases */
842 CONVERT("\t0", NUMPRS_LEADING_WHITE);
843 EXPECT(1,NUMPRS_LEADING_WHITE,NUMPRS_LEADING_WHITE,2,0,0);
847 /* Doesn't pick up trailing whitespace without flag */
852 /* With flag, consumes trailing whitespace */
853 CONVERT("0 ", NUMPRS_TRAILING_WHITE);
854 EXPECT(1,NUMPRS_TRAILING_WHITE,NUMPRS_TRAILING_WHITE,2,0,0);
857 /* Leading flag only consumes leading */
858 CONVERT(" 0 ", NUMPRS_LEADING_WHITE);
859 EXPECT(1,NUMPRS_LEADING_WHITE,NUMPRS_LEADING_WHITE,2,0,0);
862 /* Both flags consumes both */
863 CONVERT(" 0 ", NUMPRS_LEADING_WHITE|NUMPRS_TRAILING_WHITE);
864 EXPECT(1,NUMPRS_LEADING_WHITE|NUMPRS_TRAILING_WHITE,NUMPRS_LEADING_WHITE|NUMPRS_TRAILING_WHITE,3,0,0);
867 /** NUMPRS_LEADING_PLUS/NUMPRS_TRAILING_PLUS **/
869 /* Without flag, fails on + */
872 EXPECTRGB(0,FAILDIG);
874 /* With flag, consumes + */
875 CONVERT("+0", NUMPRS_LEADING_PLUS);
876 EXPECT(1,NUMPRS_LEADING_PLUS,NUMPRS_LEADING_PLUS,2,0,0);
879 /* Without flag, doesn't consume trailing + */
884 /* With flag, consumes trailing + */
885 CONVERT("0+", NUMPRS_TRAILING_PLUS);
886 EXPECT(1,NUMPRS_TRAILING_PLUS,NUMPRS_TRAILING_PLUS,2,0,0);
889 /* With leading flag, doesn't consume trailing + */
890 CONVERT("+0+", NUMPRS_LEADING_PLUS);
891 EXPECT(1,NUMPRS_LEADING_PLUS,NUMPRS_LEADING_PLUS,2,0,0);
894 /* Trailing + doesn't get consumed if we specify both (unlike whitespace) */
895 CONVERT("+0+", NUMPRS_LEADING_PLUS|NUMPRS_TRAILING_PLUS);
896 EXPECT(1,NUMPRS_LEADING_PLUS|NUMPRS_TRAILING_PLUS,NUMPRS_LEADING_PLUS,2,0,0);
899 /** NUMPRS_LEADING_MINUS/NUMPRS_TRAILING_MINUS **/
901 /* Without flag, fails on - */
904 EXPECTRGB(0,FAILDIG);
906 /* With flag, consumes - */
907 CONVERT("-0", NUMPRS_LEADING_MINUS);
908 EXPECT(1,NUMPRS_LEADING_MINUS,NUMPRS_NEG|NUMPRS_LEADING_MINUS,2,0,0);
911 /* Without flag, doesn't consume trailing - */
916 /* With flag, consumes trailing - */
917 CONVERT("0-", NUMPRS_TRAILING_MINUS);
918 EXPECT(1,NUMPRS_TRAILING_MINUS,NUMPRS_NEG|NUMPRS_TRAILING_MINUS,2,0,0);
921 /* With leading flag, doesn't consume trailing - */
922 CONVERT("-0-", NUMPRS_LEADING_MINUS);
923 EXPECT(1,NUMPRS_LEADING_MINUS,NUMPRS_NEG|NUMPRS_LEADING_MINUS,2,0,0);
926 /* Trailing - doesn't get consumed if we specify both (unlike whitespace) */
927 CONVERT("-0-", NUMPRS_LEADING_MINUS|NUMPRS_TRAILING_MINUS);
928 EXPECT(1,NUMPRS_LEADING_MINUS|NUMPRS_TRAILING_MINUS,NUMPRS_NEG|NUMPRS_LEADING_MINUS,2,0,0);
931 /** NUMPRS_HEX_OCT **/
933 /* Could be hex, octal or decimal - With flag reads as decimal */
934 CONVERT("0", NUMPRS_HEX_OCT);
935 EXPECT(1,NUMPRS_HEX_OCT,0,1,0,0);
938 /* Doesn't recognise hex in .asm sytax */
939 CONVERT("0h", NUMPRS_HEX_OCT);
940 EXPECT(1,NUMPRS_HEX_OCT,0,1,0,0);
943 /* Doesn't fail with valid leading string but no digits */
944 CONVERT("0x", NUMPRS_HEX_OCT);
945 EXPECT(1,NUMPRS_HEX_OCT,0,1,0,0);
948 /* Doesn't recognise hex format humbers at all! */
949 CONVERT("0x0", NUMPRS_HEX_OCT);
950 EXPECT(1,NUMPRS_HEX_OCT,0,1,0,0);
953 /* Doesn't recognise plain hex digits either */
954 CONVERT("FE", NUMPRS_HEX_OCT);
956 EXPECTRGB(0,FAILDIG);
959 CONVERT("0100", NUMPRS_HEX_OCT);
960 EXPECT(1,NUMPRS_HEX_OCT,0,4,0,2);
964 EXPECTRGB(3,FAILDIG);
967 CONVERT("&HF800", NUMPRS_HEX_OCT);
968 EXPECT(4,NUMPRS_HEX_OCT,0x40,6,4,0);
973 EXPECTRGB(4,FAILDIG);
975 /* VB hex lower case and leading zero */
976 CONVERT("&h0abcdef", NUMPRS_HEX_OCT);
977 EXPECT(6,NUMPRS_HEX_OCT,0x40,9,4,0);
984 EXPECTRGB(6,FAILDIG);
987 CONVERT("&O300", NUMPRS_HEX_OCT);
988 EXPECT(3,NUMPRS_HEX_OCT,0x40,5,3,0);
992 EXPECTRGB(3,FAILDIG);
994 /* VB oct lower case and leading zero */
995 CONVERT("&o0777", NUMPRS_HEX_OCT);
996 EXPECT(3,NUMPRS_HEX_OCT,0x40,6,3,0);
1000 EXPECTRGB(3,FAILDIG);
1002 /* VB oct char bigger than 7 */
1003 CONVERT("&o128", NUMPRS_HEX_OCT);
1005 Native versions 2.x of oleaut32 allow this to succeed: later versions and Wine don't
1007 EXPECTRGB(0,FAILDIG);
1009 /** NUMPRS_PARENS **/
1011 /* Empty parens = error */
1012 CONVERT("()", NUMPRS_PARENS);
1014 EXPECTRGB(0,FAILDIG);
1016 /* With flag, trailing parens not consumed */
1017 CONVERT("0()", NUMPRS_PARENS);
1018 EXPECT(1,NUMPRS_PARENS,0,1,0,0);
1021 /* With flag, Number in parens made negative and parens consumed */
1022 CONVERT("(0)", NUMPRS_PARENS);
1023 EXPECT(1,NUMPRS_PARENS,NUMPRS_NEG|NUMPRS_PARENS,3,0,0);
1026 /** NUMPRS_THOUSANDS **/
1028 /* With flag, thousands sep. not needed */
1029 CONVERT("0", NUMPRS_THOUSANDS);
1030 EXPECT(1,NUMPRS_THOUSANDS,0,1,0,0);
1033 /* With flag, thousands sep. and following digits consumed */
1034 CONVERT("1,000", NUMPRS_THOUSANDS);
1035 EXPECT(1,NUMPRS_THOUSANDS,NUMPRS_THOUSANDS,5,0,3);
1038 /* With flag and decimal point, thousands sep. but not decimals consumed */
1039 CONVERT("1,000.0", NUMPRS_THOUSANDS);
1040 EXPECT(1,NUMPRS_THOUSANDS,NUMPRS_THOUSANDS,5,0,3);
1043 /** NUMPRS_CURRENCY **/
1045 /* Without flag, chokes on currency sign */
1048 EXPECTRGB(0,FAILDIG);
1050 /* With flag, consumes currency sign */
1051 CONVERT("$11", NUMPRS_CURRENCY);
1052 EXPECT(2,NUMPRS_CURRENCY,NUMPRS_CURRENCY,3,0,0);
1054 EXPECTRGB(2,FAILDIG);
1056 /* With flag only, doesn't consume decimal point */
1057 CONVERT("$11.1", NUMPRS_CURRENCY);
1058 EXPECT(2,NUMPRS_CURRENCY,NUMPRS_CURRENCY,3,0,0);
1060 EXPECTRGB(2,FAILDIG);
1062 /* With flag and decimal flag, consumes decimal point and following digits */
1063 CONVERT("$11.1", NUMPRS_CURRENCY|NUMPRS_DECIMAL);
1064 EXPECT(3,NUMPRS_CURRENCY|NUMPRS_DECIMAL,NUMPRS_CURRENCY|NUMPRS_DECIMAL,5,0,-1);
1067 EXPECTRGB(3,FAILDIG);
1069 /* Thousands flag can only be used with currency */
1070 CONVERT("$1,234", NUMPRS_CURRENCY|NUMPRS_THOUSANDS);
1071 EXPECT(4,NUMPRS_CURRENCY|NUMPRS_THOUSANDS,NUMPRS_CURRENCY|NUMPRS_THOUSANDS,6,0,0);
1075 EXPECTRGB(4,FAILDIG);
1077 /** NUMPRS_DECIMAL **/
1079 /* With flag, consumes decimal point */
1080 CONVERT("1.1", NUMPRS_DECIMAL);
1081 EXPECT(2,NUMPRS_DECIMAL,NUMPRS_DECIMAL,3,0,-1);
1083 EXPECTRGB(2,FAILDIG);
1085 /* With flag, consumes decimal point. Skipping the decimal part is not an error */
1086 CONVERT("1.", NUMPRS_DECIMAL);
1087 EXPECT(1,NUMPRS_DECIMAL,NUMPRS_DECIMAL,2,0,0);
1090 /* Consumes only one decimal point */
1091 CONVERT("1.1.", NUMPRS_DECIMAL);
1092 EXPECT(2,NUMPRS_DECIMAL,NUMPRS_DECIMAL,3,0,-1);
1094 EXPECTRGB(2,FAILDIG);
1096 /** NUMPRS_EXPONENT **/
1098 /* Without flag, doesn't consume exponent */
1100 EXPECT(1,0,0,1,0,0);
1103 /* With flag, consumes exponent */
1104 CONVERT("1e1", NUMPRS_EXPONENT);
1105 EXPECT(1,NUMPRS_EXPONENT,NUMPRS_EXPONENT,3,0,1);
1108 /* Negative exponents are accepted without flags */
1109 CONVERT("1e-1", NUMPRS_EXPONENT);
1110 EXPECT(1,NUMPRS_EXPONENT,NUMPRS_EXPONENT,4,0,-1);
1113 /* As are positive exponents and leading exponent 0's */
1114 CONVERT("1e+01", NUMPRS_EXPONENT);
1115 EXPECT(1,NUMPRS_EXPONENT,NUMPRS_EXPONENT,5,0,1);
1118 /* The same for zero exponents */
1119 CONVERT("1e0", NUMPRS_EXPONENT);
1120 EXPECT(1,NUMPRS_EXPONENT,NUMPRS_EXPONENT,3,0,0);
1123 /* Sign on a zero exponent doesn't matter */
1124 CONVERT("1e+0", NUMPRS_EXPONENT);
1125 EXPECT(1,NUMPRS_EXPONENT,NUMPRS_EXPONENT,4,0,0);
1128 CONVERT("1e-0", NUMPRS_EXPONENT);
1129 EXPECT(1,NUMPRS_EXPONENT,NUMPRS_EXPONENT,4,0,0);
1132 /* Doesn't consume a real number exponent */
1133 CONVERT("1e1.", NUMPRS_EXPONENT);
1134 EXPECT(1,NUMPRS_EXPONENT,NUMPRS_EXPONENT,3,0,1);
1137 /* Powers of 10 are calculated from the position of any decimal point */
1138 CONVERT("1.5e20", NUMPRS_EXPONENT|NUMPRS_DECIMAL);
1139 EXPECT(2,NUMPRS_EXPONENT|NUMPRS_DECIMAL,NUMPRS_EXPONENT|NUMPRS_DECIMAL,6,0,19);
1142 CONVERT("1.5e-20", NUMPRS_EXPONENT|NUMPRS_DECIMAL);
1143 EXPECT(2,NUMPRS_EXPONENT|NUMPRS_DECIMAL,NUMPRS_EXPONENT|NUMPRS_DECIMAL,7,0,-21);
1146 /** NUMPRS_USE_ALL **/
1148 /* Flag expects all digits */
1149 CONVERT("0", NUMPRS_USE_ALL);
1150 EXPECT(1,NUMPRS_USE_ALL,0,1,0,0);
1153 /* Rejects anything trailing */
1154 CONVERT("0 ", NUMPRS_USE_ALL);
1158 /* Unless consumed by trailing flag */
1159 CONVERT("0 ", NUMPRS_USE_ALL|NUMPRS_TRAILING_WHITE);
1160 EXPECT(1,NUMPRS_USE_ALL|NUMPRS_TRAILING_WHITE,NUMPRS_TRAILING_WHITE,2,0,0);
1163 /** Combinations **/
1165 /* Leading whitepace and plus, doesn't consume trailing whitespace */
1166 CONVERT("+ 0 ", NUMPRS_LEADING_PLUS|NUMPRS_LEADING_WHITE);
1167 EXPECT(1,NUMPRS_LEADING_PLUS|NUMPRS_LEADING_WHITE,NUMPRS_LEADING_PLUS|NUMPRS_LEADING_WHITE,3,0,0);
1170 /* Order of whitepace and plus is unimportant */
1171 CONVERT(" +0", NUMPRS_LEADING_PLUS|NUMPRS_LEADING_WHITE);
1172 EXPECT(1,NUMPRS_LEADING_PLUS|NUMPRS_LEADING_WHITE,NUMPRS_LEADING_PLUS|NUMPRS_LEADING_WHITE,3,0,0);
1175 /* Leading whitespace can be repeated */
1176 CONVERT(" + 0", NUMPRS_LEADING_PLUS|NUMPRS_LEADING_WHITE);
1177 EXPECT(1,NUMPRS_LEADING_PLUS|NUMPRS_LEADING_WHITE,NUMPRS_LEADING_PLUS|NUMPRS_LEADING_WHITE,4,0,0);
1180 /* But plus/minus etc. cannot */
1181 CONVERT("+ +0", NUMPRS_LEADING_PLUS|NUMPRS_LEADING_WHITE);
1183 EXPECTRGB(0,FAILDIG);
1185 /* Inexact is not set if trailing zeros are removed */
1186 CONVERTN("10", 1, 0);
1187 EXPECT(1,0,0,2,0,1);
1190 /* Make sure a leading 0 is stripped but decimals after it get read */
1191 CONVERT("-0.51", NUMPRS_STD);
1192 EXPECT(2,NUMPRS_STD,NUMPRS_NEG|NUMPRS_DECIMAL|NUMPRS_LEADING_MINUS,5,0,-2);
1195 /* Keep trailing zeros on whole number part of a decimal */
1196 CONVERT("10.1", NUMPRS_STD);
1197 EXPECT(3,NUMPRS_STD,NUMPRS_DECIMAL,4,0,-1);
1201 /* Zeros after decimal sign */
1202 CONVERT("0.01", NUMPRS_STD);
1203 EXPECT(1,NUMPRS_STD,NUMPRS_DECIMAL,4,0,-2);
1206 /* Trailing zeros after decimal part */
1207 CONVERT("0.10", NUMPRS_STD);
1208 EXPECT(1,NUMPRS_STD,NUMPRS_DECIMAL,4,0,-1);
1212 static HRESULT (WINAPI *pVarNumFromParseNum)(NUMPARSE*,BYTE*,ULONG,VARIANT*);
1214 /* Macros for converting and testing the result of VarNumFromParseNum */
1215 #define SETRGB(indx,val) if (!indx) memset(rgb, FAILDIG, sizeof(rgb)); rgb[indx] = val
1217 #define CONVERT(a,b,c,d,e,f,bits) \
1218 np.cDig = (a); np.dwInFlags = (b); np.dwOutFlags = (c); np.cchUsed = (d); \
1219 np.nBaseShift = (e); np.nPwr10 = (f); hres = pVarNumFromParseNum(&np, rgb, bits, &vOut)
1220 static const char *szFailOverflow = "Expected overflow, hres = %08x\n";
1221 #define EXPECT_OVERFLOW ok(hres == (HRESULT)DISP_E_OVERFLOW, szFailOverflow, hres)
1222 static const char *szFailOk = "Call failed, hres = %08x\n";
1223 #define EXPECT_OK ok(hres == (HRESULT)S_OK, szFailOk, hres); \
1224 if (hres == (HRESULT)S_OK)
1225 #define EXPECT_TYPE(typ) ok(V_VT(&vOut) == typ,"Expected Type = " #typ ", got %d\n", V_VT(&vOut))
1226 #define EXPECT_I1(val) EXPECT_OK { EXPECT_TYPE(VT_I1); \
1227 ok(V_I1(&vOut) == val, "Expected i1 = %d, got %d\n", (signed char)val, V_I1(&vOut)); }
1228 #define EXPECT_UI1(val) EXPECT_OK { EXPECT_TYPE(VT_UI1); \
1229 ok(V_UI1(&vOut) == val, "Expected ui1 = %d, got %d\n", (BYTE)val, V_UI1(&vOut)); }
1230 #define EXPECT_I2(val) EXPECT_OK { EXPECT_TYPE(VT_I2); \
1231 ok(V_I2(&vOut) == val, "Expected i2 = %d, got %d\n", (SHORT)val, V_I2(&vOut)); }
1232 #define EXPECT_UI2(val) EXPECT_OK { EXPECT_TYPE(VT_UI2); \
1233 ok(V_UI2(&vOut) == val, "Expected ui2 = %d, got %d\n", (USHORT)val, V_UI2(&vOut)); }
1234 #define EXPECT_I4(val) EXPECT_OK { EXPECT_TYPE(VT_I4); \
1235 ok(V_I4(&vOut) == val, "Expected i4 = %d, got %d\n", (LONG)val, V_I4(&vOut)); }
1236 #define EXPECT_UI4(val) EXPECT_OK { EXPECT_TYPE(VT_UI4); \
1237 ok(V_UI4(&vOut) == val, "Expected ui4 = %d, got %d\n", (ULONG)val, V_UI4(&vOut)); }
1238 #define EXPECT_I8(high,low) EXPECT_OK { EXPECT_TYPE(VT_I8); \
1239 ok(V_I8(&vOut) == ((((LONG64)(high))<<32)|(low)), "Expected i8 = %x%08x, got %x%08x\n", \
1240 (LONG)(high), (LONG)(low), (LONG)(V_I8(&vOut)>>32), (LONG)V_I8(&vOut) ); }
1241 #define EXPECT_UI8(val) EXPECT_OK { EXPECT_TYPE(VT_UI8); \
1242 ok(V_UI8(&vOut) == val, "Expected ui8 = 0x%x%08x, got 0x%x%08x\n", \
1243 (DWORD)((ULONG64)val >> 32), (DWORD)(ULONG64)val, (DWORD)(V_UI8(&vOut) >> 32), (DWORD)V_UI8(&vOut)); }
1244 #define EXPECT_R4(val) EXPECT_OK { EXPECT_TYPE(VT_R4); \
1245 ok(V_R4(&vOut) == val, "Expected r4 = %f, got %f\n", val, V_R4(&vOut)); }
1246 #define EXPECT_R8(val) EXPECT_OK { EXPECT_TYPE(VT_R8); \
1247 ok(V_R8(&vOut) == val, "Expected r8 = %g, got %g\n", val, V_R8(&vOut)); }
1248 #define CY_MULTIPLIER 10000
1249 #define EXPECT_CY(val) EXPECT_OK { EXPECT_TYPE(VT_CY); \
1250 ok(V_CY(&vOut).int64 == (LONG64)(val * CY_MULTIPLIER), "Expected r8 = 0x%x%08x, got 0x%x%08x\n", \
1251 (DWORD)((LONG64)val >> 23), (DWORD)(LONG64)val, (DWORD)(V_CY(&vOut).int64 >>32), (DWORD)V_CY(&vOut).int64); }
1253 static void test_VarNumFromParseNum(void)
1260 CHECKPTR(VarNumFromParseNum);
1262 /* Convert the number 1 to different types */
1263 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_I1); EXPECT_I1(1);
1264 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_UI1); EXPECT_UI1(1);
1265 /* Prefers a signed type to unsigned of the same size */
1266 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_I1|VTBIT_UI1); EXPECT_I1(1);
1267 /* But takes the smaller size if possible */
1268 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_I2|VTBIT_UI1); EXPECT_UI1(1);
1270 /* Try different integer sizes */
1271 #define INTEGER_VTBITS (VTBIT_I1|VTBIT_UI1|VTBIT_I2|VTBIT_UI2|VTBIT_I4|VTBIT_UI4|VTBIT_I8|VTBIT_UI8)
1273 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, INTEGER_VTBITS); EXPECT_I1(1);
1275 SETRGB(0, 1); SETRGB(1, 2); SETRGB(2, 7);
1276 CONVERT(3,0,0,3,0,0, INTEGER_VTBITS); EXPECT_I1(127);
1278 SETRGB(0, 1); SETRGB(1, 2); SETRGB(2, 8);
1279 CONVERT(3,0,0,3,0,0, INTEGER_VTBITS); EXPECT_UI1(128);
1281 SETRGB(0, 2); SETRGB(1, 5); SETRGB(2, 5);
1282 CONVERT(3,0,0,3,0,0, INTEGER_VTBITS); EXPECT_UI1(255);
1284 SETRGB(0, 2); SETRGB(1, 5); SETRGB(2, 6);
1285 CONVERT(3,0,0,3,0,0, INTEGER_VTBITS); EXPECT_I2(256);
1287 SETRGB(0, 3); SETRGB(1, 2); SETRGB(2, 7); SETRGB(3, 6); SETRGB(4, 7);
1288 CONVERT(5,0,0,5,0,0, INTEGER_VTBITS); EXPECT_I2(32767);
1290 SETRGB(0, 3); SETRGB(1, 2); SETRGB(2, 7); SETRGB(3, 6); SETRGB(4, 8);
1291 CONVERT(5,0,0,5,0,0, INTEGER_VTBITS); EXPECT_UI2(32768);
1293 /* Assume the above pattern holds for remaining positive integers; test negative */
1296 SETRGB(0, 1); SETRGB(1, 2); SETRGB(2, 8);
1297 CONVERT(3,0,NUMPRS_NEG,3,0,0, INTEGER_VTBITS); EXPECT_I1(-128);
1299 SETRGB(0, 1); SETRGB(1, 2); SETRGB(2, 9);
1300 CONVERT(3,0,NUMPRS_NEG,3,0,0, INTEGER_VTBITS); EXPECT_I2(-129);
1302 SETRGB(0, 3); SETRGB(1, 2); SETRGB(2, 7); SETRGB(3, 6); SETRGB(4, 8);
1303 CONVERT(5,0,NUMPRS_NEG,5,0,0, INTEGER_VTBITS); EXPECT_I2(-32768);
1305 SETRGB(0, 3); SETRGB(1, 2); SETRGB(2, 7); SETRGB(3, 6); SETRGB(4, 9);
1306 CONVERT(5,0,NUMPRS_NEG,5,0,0, INTEGER_VTBITS); EXPECT_I4(-32769);
1308 /* Assume the above pattern holds for remaining negative integers */
1310 /* Test hexadecimal conversions */
1311 SETRGB(0, 1); CONVERT(1,0,0,1,4,0, INTEGER_VTBITS); EXPECT_I1(0x01);
1313 SETRGB(0, 7); SETRGB(1, 0xf);
1314 CONVERT(2,0,0,2,4,0, INTEGER_VTBITS); EXPECT_I1(0x7f);
1316 SETRGB(0, 7); SETRGB(1, 0xf); SETRGB(2, 0xf); SETRGB(3, 0xf);
1317 CONVERT(4,0,0,4,4,0, INTEGER_VTBITS); EXPECT_I2(0x7fff);
1319 SETRGB(0, 7); SETRGB(1, 0xf); SETRGB(2, 0xf); SETRGB(3, 0xf);
1320 SETRGB(4, 0xf); SETRGB(5, 0xf); SETRGB(6, 0xf); SETRGB(7, 0xf);
1321 CONVERT(8,0,0,8,4,0, INTEGER_VTBITS); EXPECT_I4(0x7fffffffL);
1322 /* 0x7fffffffffffffff (64 bits) */
1323 SETRGB(0, 7); SETRGB(1, 0xf); SETRGB(2, 0xf); SETRGB(3, 0xf);
1324 SETRGB(4, 0xf); SETRGB(5, 0xf); SETRGB(6, 0xf); SETRGB(7, 0xf);
1325 SETRGB(8, 0xf); SETRGB(9, 0xf); SETRGB(10, 0xf); SETRGB(11, 0xf);
1326 SETRGB(12, 0xf); SETRGB(13, 0xf); SETRGB(14, 0xf); SETRGB(15, 0xf);
1327 if (HAVE_OLEAUT32_I8)
1329 /* We cannot use INTEGER_VTBITS as WinXP and Win2003 are broken(?). They
1330 truncate the number to the smallest integer size requested:
1331 CONVERT(16,0,0,16,4,0, INTEGER_VTBITS); EXPECT_I1((signed char)0xff); */
1332 CONVERT(16,0,0,16,4,0, VTBIT_I8); EXPECT_I8(0x7fffffff,0xffffffff);
1335 /* Assume the above pattern holds for numbers without hi-bit set, test (preservation of) hi-bit */
1337 SETRGB(0, 8); SETRGB(1, 2);
1338 CONVERT(2,0,0,2,4,0, INTEGER_VTBITS);
1339 EXPECT_I1((signed char)0x82);
1341 SETRGB(0, 8); SETRGB(1, 0); SETRGB(2, 0); SETRGB(3, 2);
1342 CONVERT(4,0,0,4,4,0, INTEGER_VTBITS);
1343 EXPECT_I2((signed short)0x8002);
1345 SETRGB(0, 8); SETRGB(1, 0); SETRGB(2, 0); SETRGB(3, 0);
1346 SETRGB(4, 0); SETRGB(5, 0); SETRGB(6, 0); SETRGB(7, 2);
1347 CONVERT(8,0,0,8,4,0, INTEGER_VTBITS); EXPECT_I4(0x80000002);
1348 /* 0x8000000000000002 (64 bits) */
1349 SETRGB(0, 8); SETRGB(1, 0); SETRGB(2, 0); SETRGB(3, 0);
1350 SETRGB(4, 0); SETRGB(5, 0); SETRGB(6, 0); SETRGB(7, 0);
1351 SETRGB(8, 0); SETRGB(9, 0); SETRGB(10, 0); SETRGB(11, 0);
1352 SETRGB(12, 0); SETRGB(13, 0); SETRGB(14, 0); SETRGB(15, 2);
1353 if (HAVE_OLEAUT32_I8)
1355 /* We cannot use INTEGER_VTBITS as WinXP and Win2003 are broken(?). They
1356 truncate the number to the smallest integer size requested:
1357 CONVERT(16,0,0,16,4,0, INTEGER_VTBITS & ~VTBIT_I1);
1358 EXPECT_I2((signed short)0x0002); */
1359 CONVERT(16,0,0,16,4,0, VTBIT_I8); EXPECT_I8(0x80000000,0x00000002);
1362 /* Test (preservation of) hi-bit with STRICT type requesting */
1364 SETRGB(0, 8); SETRGB(1, 2);
1365 CONVERT(2,0,0,2,4,0, VTBIT_I1);
1366 EXPECT_I1((signed char)0x82);
1368 SETRGB(0, 8); SETRGB(1, 0); SETRGB(2, 0); SETRGB(3, 2);
1369 CONVERT(4,0,0,4,4,0, VTBIT_I2);
1370 EXPECT_I2((signed short)0x8002);
1372 SETRGB(0, 8); SETRGB(1, 0); SETRGB(2, 0); SETRGB(3, 0);
1373 SETRGB(4, 0); SETRGB(5, 0); SETRGB(6, 0); SETRGB(7, 2);
1374 CONVERT(8,0,0,8,4,0, VTBIT_I4); EXPECT_I4(0x80000002);
1375 /* 0x8000000000000002 (64 bits) */
1376 SETRGB(0, 8); SETRGB(1, 0); SETRGB(2, 0); SETRGB(3, 0);
1377 SETRGB(4, 0); SETRGB(5, 0); SETRGB(6, 0); SETRGB(7, 0);
1378 SETRGB(8, 0); SETRGB(9, 0); SETRGB(10, 0); SETRGB(11, 0);
1379 SETRGB(12, 0); SETRGB(13, 0); SETRGB(14, 0); SETRGB(15, 2);
1380 if (HAVE_OLEAUT32_I8)
1382 CONVERT(16,0,0,16,4,0, VTBIT_I8); EXPECT_I8(0x80000000,0x00000002);
1384 /* Assume the above pattern holds for numbers with hi-bit set */
1386 /* Negative numbers overflow if we have only unsigned outputs */
1388 SETRGB(0, 1); CONVERT(1,0,NUMPRS_NEG,1,0,0, VTBIT_UI1); EXPECT_OVERFLOW;
1390 SETRGB(0, 6); CONVERT(1,0,NUMPRS_NEG,1,0,~0u, VTBIT_UI1); EXPECT_OVERFLOW;
1392 /* Except that rounding is done first, so -0.5 to 0 are accepted as 0 */
1394 SETRGB(0, 5); CONVERT(1,0,NUMPRS_NEG,1,0,~0u, VTBIT_UI1); EXPECT_UI1(0);
1396 /* Floating point zero is OK */
1398 SETRGB(0, 0); CONVERT(1,0,NUMPRS_DECIMAL|NUMPRS_EXPONENT,12,0,-8, VTBIT_R8);
1401 /* Float is acceptable for an integer input value */
1402 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_R4); EXPECT_R4(1.0f);
1404 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_R8); EXPECT_R8(1.0);
1405 /* As is currency */
1406 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_CY); EXPECT_CY(1);
1408 /* Float is preferred over double */
1409 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_R4|VTBIT_R8); EXPECT_R4(1.0f);
1411 /* Double is preferred over currency */
1412 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_R8|VTBIT_CY); EXPECT_R8(1.0);
1414 /* Currency is preferred over decimal */
1415 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_CY|VTBIT_DECIMAL); EXPECT_CY(1);
1418 static const char* szUdateFromDateFail = "%.16g expected %x, %d,%d,%d,%d,%d,%d,%d %d %d"
1419 ", got %x, %d,%d,%d,%d,%d,%d,%d %d %d\n";
1420 #define DT2UD(dt,flags,r,d,m,y,h,mn,s,ms,dw,dy) \
1421 memset(&ud, 0, sizeof(ud)); \
1422 res = pVarUdateFromDate(dt, flags, &ud); \
1423 ok(r == res && (FAILED(r) || (ud.st.wYear == y && ud.st.wMonth == m && ud.st.wDay == d && \
1424 ud.st.wHour == h && ud.st.wMinute == mn && ud.st.wSecond == s && \
1425 ud.st.wMilliseconds == ms && ud.st.wDayOfWeek == dw && ud.wDayOfYear == dy)), \
1426 szUdateFromDateFail, dt, r, d, m, y, h, mn, s, ms, dw, dy, res, ud.st.wDay, ud.st.wMonth, \
1427 ud.st.wYear, ud.st.wHour, ud.st.wMinute, ud.st.wSecond, \
1428 ud.st.wMilliseconds, ud.st.wDayOfWeek, ud.wDayOfYear)
1430 static void test_VarUdateFromDate(void)
1435 CHECKPTR(VarUdateFromDate);
1436 DT2UD(29221.0,0,S_OK,1,1,1980,0,0,0,0,2,1); /* 1 Jan 1980 */
1437 DT2UD(29222.0,0,S_OK,2,1,1980,0,0,0,0,3,2); /* 2 Jan 1980 */
1438 DT2UD(33238.0,0,S_OK,31,12,1990,0,0,0,0,1,365); /* 31 Dec 1990 */
1439 DT2UD(0.0,0,S_OK,30,12,1899,0,0,0,0,6,364); /* 30 Dec 1899 - VT_DATE 0.0 */
1440 DT2UD(-657434.0,0,S_OK,1,1,100,0,0,0,0,5,1); /* 1 Jan 100 - Min */
1441 DT2UD(-657435.0,0,E_INVALIDARG,0,0,0,0,0,0,0,0,0); /* < 1 Jan 100 => err */
1442 DT2UD(2958465.0,0,S_OK,31,12,9999,0,0,0,0,5,365); /* 31 Dec 9999 - Max */
1443 DT2UD(2958466.0,0,E_INVALIDARG,0,0,0,0,0,0,0,0,0); /* > 31 Dec 9999 => err */
1445 /* VAR_VALIDDATE doesn't prevent upper and lower bounds being checked */
1446 DT2UD(-657435.0,VAR_VALIDDATE,E_INVALIDARG,0,0,0,0,0,0,0,0,0);
1447 DT2UD(2958466.0,VAR_VALIDDATE,E_INVALIDARG,0,0,0,0,0,0,0,0,0);
1450 DT2UD(29221.25,0,S_OK,1,1,1980,6,0,0,0,2,1); /* 6 AM */
1451 DT2UD(29221.33333333,0,S_OK,1,1,1980,8,0,0,0,2,1); /* 8 AM */
1452 DT2UD(29221.5,0,S_OK,1,1,1980,12,0,0,0,2,1); /* 12 AM */
1453 DT2UD(29221.9888884444,0,S_OK,1,1,1980,23,44,0,0,2,1); /* 11:44 PM */
1454 DT2UD(29221.7508765432,0,S_OK,1,1,1980,18,1,16,0,2,1); /* 6:18:02 PM */
1457 #define UD2T(d,m,y,h,mn,s,ms,dw,dy,flags,r,dt) \
1458 ud.st.wYear = (y); ud.st.wMonth = (m); ud.st.wDay = (d); ud.st.wHour = (h); \
1459 ud.st.wMinute = (mn); ud.st.wSecond = (s); ud.st.wMilliseconds = (ms); \
1460 ud.st.wDayOfWeek = (dw); ud.wDayOfYear = (dy); \
1461 res = pVarDateFromUdate(&ud, (flags), &out); \
1462 ok((r) == res && (FAILED(r) || fabs(out-(dt)) < 1.0e-11), \
1463 "expected %x, %.16g, got %x, %.16g\n", r, dt, res, out)
1465 static void test_VarDateFromUdate(void)
1471 CHECKPTR(VarDateFromUdate);
1472 UD2T(1,1,1980,0,0,0,0,2,1,0,S_OK,29221.0); /* 1 Jan 1980 */
1473 UD2T(2,1,1980,0,0,0,0,3,2,0,S_OK,29222.0); /* 2 Jan 1980 */
1474 UD2T(31,12,1990,0,0,0,0,0,0,0,S_OK,33238.0); /* 31 Dec 1990 */
1475 UD2T(31,12,90,0,0,0,0,0,0,0,S_OK,33238.0); /* year < 100 is 1900+year! */
1476 UD2T(30,12,1899,0,0,0,0,6,364,0,S_OK,0.0); /* 30 Dec 1899 - VT_DATE 0.0 */
1477 UD2T(1,1,100,0,0,0,0,0,0,0,S_OK,-657434.0); /* 1 Jan 100 - Min */
1478 UD2T(31,12,9999,0,0,0,0,0,0,0,S_OK,2958465.0); /* 31 Dec 9999 - Max */
1479 UD2T(1,1,10000,0,0,0,0,0,0,0,E_INVALIDARG,0.0); /* > 31 Dec 9999 => err */
1481 UD2T(1,1,1980,18,1,16,0,2,1,0,S_OK,29221.75087962963); /* 6:18:02 PM */
1483 UD2T(0,1,1980,0,0,0,0,2,1,0,S_OK,29220.0); /* Rolls back to 31 Dec 1899 */
1484 UD2T(1,13,1980,0,0,0,0,2,1,0,S_OK,29587.0); /* Rolls fwd to 1/1/1981 */
1487 #define ST2DT(d,m,y,h,mn,s,ms,r,dt) \
1488 st.wYear = y; st.wMonth = m; st.wDay = d; st.wHour = h; st.wMinute = mn; \
1489 st.wSecond = s; st.wMilliseconds = ms; st.wDayOfWeek = 0; \
1490 res = pSystemTimeToVariantTime(&st, &out); \
1491 ok(r == res && (!r || fabs(out-dt) < 1.0e-11), \
1492 "expected %d, %.16g, got %d, %.16g\n", r, dt, res, out)
1494 static void test_SystemTimeToVariantTime(void)
1500 CHECKPTR(SystemTimeToVariantTime);
1501 ST2DT(1,1,1980,0,0,0,0,TRUE,29221.0);
1502 ST2DT(2,1,1980,0,0,0,0,TRUE,29222.0);
1503 ST2DT(0,1,1980,0,0,0,0,TRUE,29220.0); /* Rolls back to 31 Dec 1899 */
1504 ST2DT(1,13,1980,0,0,0,0,FALSE,29587.0); /* Fails on invalid month */
1505 ST2DT(31,12,90,0,0,0,0,TRUE,33238.0); /* year < 100 is 1900+year! */
1508 #define DT2ST(dt,r,d,m,y,h,mn,s,ms) \
1509 memset(&st, 0, sizeof(st)); \
1510 res = pVariantTimeToSystemTime(dt, &st); \
1511 ok(r == res && (!r || (st.wYear == y && st.wMonth == m && st.wDay == d && \
1512 st.wHour == h && st.wMinute == mn && st.wSecond == s && \
1513 st.wMilliseconds == ms)), \
1514 "%.16g expected %d, %d,%d,%d,%d,%d,%d,%d, got %d, %d,%d,%d,%d,%d,%d,%d\n", \
1515 dt, r, d, m, y, h, mn, s, ms, res, st.wDay, st.wMonth, st.wYear, \
1516 st.wHour, st.wMinute, st.wSecond, st.wMilliseconds)
1518 static void test_VariantTimeToSystemTime(void)
1523 CHECKPTR(VariantTimeToSystemTime);
1524 DT2ST(29221.0,1,1,1,1980,0,0,0,0);
1525 DT2ST(29222.0,1,2,1,1980,0,0,0,0);
1528 #define MKDOSDATE(d,m,y) ((d & 0x1f) | ((m & 0xf) << 5) | (((y-1980) & 0x7f) << 9))
1529 #define MKDOSTIME(h,m,s) (((s>>1) & 0x1f) | ((m & 0x3f) << 5) | ((h & 0x1f) << 11))
1531 static const char *szDosDateToVarTimeFail = "expected %d, %.16g, got %d, %.16g\n";
1532 #define DOS2DT(d,m,y,h,mn,s,r,dt) out = 0.0; \
1533 dosDate = MKDOSDATE(d,m,y); \
1534 dosTime = MKDOSTIME(h,mn,s); \
1535 res = pDosDateTimeToVariantTime(dosDate, dosTime, &out); \
1536 ok(r == res && (!r || fabs(out-dt) < 1.0e-11), \
1537 szDosDateToVarTimeFail, r, dt, res, out)
1539 static void test_DosDateTimeToVariantTime(void)
1541 USHORT dosDate, dosTime;
1545 CHECKPTR(DosDateTimeToVariantTime);
1548 DOS2DT(1,1,1980,0,0,0,1,29221.0); /* 1/1/1980 */
1549 DOS2DT(31,12,2099,0,0,0,1,73050.0); /* 31/12/2099 */
1550 /* Dates are limited to the dos date max of 31/12/2099 */
1551 DOS2DT(31,12,2100,0,0,0,0,0.0); /* 31/12/2100 */
1552 /* Days and months of 0 cause date to roll back 1 day or month */
1553 DOS2DT(0,1,1980,0,0,0,1,29220.0); /* 0 Day => 31/12/1979 */
1554 DOS2DT(1,0,1980,0,0,0,1,29190.0); /* 0 Mth => 1/12/1979 */
1555 DOS2DT(0,0,1980,0,0,0,1,29189.0); /* 0 D/M => 30/11/1979 */
1556 /* Days > days in the month cause date to roll forward 1 month */
1557 DOS2DT(29,2,1981,0,0,0,1,29646.0); /* 29/2/1981 -> 3/1/1980 */
1558 DOS2DT(30,2,1981,0,0,0,1,29647.0); /* 30/2/1981 -> 4/1/1980 */
1559 /* Takes leap years into account when rolling forward */
1560 DOS2DT(29,2,1980,0,0,0,1,29280.0); /* 2/29/1980 */
1561 /* Months > 12 cause an error */
1562 DOS2DT(2,13,1980,0,0,0,0,0.0);
1565 DOS2DT(1,1,1980,0,0,29,1,29221.00032407407); /* 1/1/1980 12:00:28 AM */
1566 DOS2DT(1,1,1980,0,0,31,1,29221.00034722222); /* 1/1/1980 12:00:30 AM */
1567 DOS2DT(1,1,1980,0,59,0,1,29221.04097222222); /* 1/1/1980 12:59:00 AM */
1568 DOS2DT(1,1,1980,0,60,0,0,0.0); /* Invalid seconds */
1569 DOS2DT(1,1,1980,23,0,0,1,29221.95833333333); /* 1/1/1980 11:00:00 PM */
1570 DOS2DT(1,1,1980,24,0,0,0,0.0); /* Invalid hours */
1573 #define DT2DOS(dt,r,d,m,y,h,mn,s) dosTime = dosDate = 0; \
1574 expDosDate = MKDOSDATE(d,m,y); \
1575 expDosTime = MKDOSTIME(h,mn,s); \
1576 res = pVariantTimeToDosDateTime(dt, &dosDate, &dosTime); \
1577 ok(r == res && (!r || (dosTime == expDosTime && dosDate == expDosDate)), \
1578 "%g: expected %d,%d(%d/%d/%d),%d(%d:%d:%d) got %d,%d(%d/%d/%d),%d(%d:%d:%d)\n", \
1579 dt, r, expDosDate, expDosDate & 0x1f, (expDosDate >> 5) & 0xf, 1980 + (expDosDate >> 9), \
1580 expDosTime, expDosTime >> 11, (expDosTime >> 5) & 0x3f, (expDosTime & 0x1f), \
1581 res, dosDate, dosDate & 0x1f, (dosDate >> 5) & 0xf, 1980 + (dosDate >> 9), \
1582 dosTime, dosTime >> 11, (dosTime >> 5) & 0x3f, (dosTime & 0x1f))
1584 static void test_VariantTimeToDosDateTime(void)
1586 USHORT dosDate, dosTime, expDosDate, expDosTime;
1589 CHECKPTR(VariantTimeToDosDateTime);
1592 DT2DOS(29221.0,1,1,1,1980,0,0,0); /* 1/1/1980 */
1593 DT2DOS(73050.0,1,31,12,2099,0,0,0); /* 31/12/2099 */
1594 DT2DOS(29220.0,0,0,0,0,0,0,0); /* 31/12/1979 - out of range */
1595 DT2DOS(73415.0,0,0,0,0,0,0,0); /* 31/12/2100 - out of range */
1598 DT2DOS(29221.00032407407,1,1,1,1980,0,0,29); /* 1/1/1980 12:00:28 AM */
1599 DT2DOS(29221.00034722222,1,1,1,1980,0,0,31); /* 1/1/1980 12:00:30 AM */
1600 DT2DOS(29221.04097222222,1,1,1,1980,0,59,0); /* 1/1/1980 12:59:00 AM */
1601 DT2DOS(29221.95833333333,1,1,1,1980,23,0,0); /* 1/1/1980 11:00:00 PM */
1604 static HRESULT (WINAPI *pVarAbs)(LPVARIANT,LPVARIANT);
1606 static const char *szVarAbsFail = "VarAbs: expected 0x0,%d,%d, got 0x%X,%d,%d\n";
1607 #define VARABS(vt,val,rvt,rval) V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
1608 memset(&vDst,0,sizeof(vDst)); hres = pVarAbs(&v,&vDst); \
1609 ok(hres == S_OK && V_VT(&vDst) == VT_##rvt && V_##rvt(&vDst) == (rval), \
1610 szVarAbsFail, VT_##rvt, (int)(rval), \
1611 hres, V_VT(&vDst), (int)V_##rvt(&vDst))
1613 static void test_VarAbs(void)
1615 static const WCHAR szNum[] = {'-','1','.','1','\0' };
1623 /* Test all possible V_VT values.
1625 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
1629 for (vt = 0; vt <= VT_BSTR_BLOB; vt++)
1631 HRESULT hExpected = DISP_E_BADVARTYPE;
1635 memset(&v, 0, sizeof(v));
1636 V_VT(&v) = vt | ExtraFlags[i];
1637 V_VT(&vDst) = VT_EMPTY;
1639 hres = pVarAbs(&v,&vDst);
1640 if (ExtraFlags[i] & (VT_ARRAY|VT_ARRAY) ||
1641 (!ExtraFlags[i] && (vt == VT_UNKNOWN || vt == VT_BSTR ||
1642 vt == VT_DISPATCH || vt == VT_ERROR || vt == VT_RECORD)))
1644 hExpected = DISP_E_TYPEMISMATCH;
1646 else if (ExtraFlags[i] || vt >= VT_CLSID || vt == VT_VARIANT)
1648 hExpected = DISP_E_BADVARTYPE;
1650 else if (IsValidVariantClearVT(vt, ExtraFlags[i]))
1653 /* Native always fails on some vartypes that should be valid. don't
1654 * check that Wine does the same; these are bugs in native.
1656 if (vt == VT_I8 || vt == VT_UI8 || vt == VT_INT || vt == VT_UINT ||
1657 vt == VT_I1 || vt == VT_UI2 || vt == VT_UI4)
1659 ok(hres == hExpected, "VarAbs: expected 0x%X, got 0x%X for vt %d | 0x%X\n",
1660 hExpected, hres, vt, ExtraFlags[i]);
1664 /* BOOL->I2, BSTR->R8, all others remain the same */
1665 VARABS(BOOL,VARIANT_TRUE,I2,-VARIANT_TRUE);
1666 VARABS(BOOL,VARIANT_FALSE,I2,VARIANT_FALSE);
1667 VARABS(EMPTY,0,I2,0);
1668 VARABS(EMPTY,1,I2,0);
1669 VARABS(NULL,0,NULL,0);
1670 VARABS(NULL,1,NULL,0);
1675 VARABS(UI1,1,UI1,1);
1680 VARABS(DATE,1,DATE,1);
1681 VARABS(DATE,-1,DATE,1);
1683 V_CY(&v).int64 = -10000;
1684 memset(&vDst,0,sizeof(vDst));
1685 hres = pVarAbs(&v,&vDst);
1686 ok(hres == S_OK && V_VT(&vDst) == VT_CY && V_CY(&vDst).int64 == 10000,
1687 "VarAbs(CY): expected 0x0 got 0x%X\n", hres);
1688 GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, buff, sizeof(buff)/sizeof(char));
1689 if (buff[0] != '.' || buff[1])
1691 trace("Skipping VarAbs(BSTR) as decimal separator is '%s'\n", buff);
1695 V_BSTR(&v) = (BSTR)szNum;
1696 memset(&vDst,0,sizeof(vDst));
1697 hres = pVarAbs(&v,&vDst);
1698 ok(hres == S_OK && V_VT(&vDst) == VT_R8 && V_R8(&vDst) == 1.1,
1699 "VarAbs: expected 0x0,%d,%g, got 0x%X,%d,%g\n", VT_R8, 1.1, hres, V_VT(&vDst), V_R8(&vDst));
1702 static HRESULT (WINAPI *pVarNot)(LPVARIANT,LPVARIANT);
1704 static const char *szVarNotFail = "VarNot: expected 0x0,%d,%d, got 0x%X,%d,%d\n";
1705 #define VARNOT(vt,val,rvt,rval) V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
1706 memset(&vDst,0,sizeof(vDst)); hres = pVarNot(&v,&vDst); \
1707 ok(hres == S_OK && V_VT(&vDst) == VT_##rvt && V_##rvt(&vDst) == (rval), \
1708 szVarNotFail, VT_##rvt, (int)(rval), \
1709 hres, V_VT(&vDst), (int)V_##rvt(&vDst))
1711 static void test_VarNot(void)
1713 static const WCHAR szNum0[] = {'0','\0' };
1714 static const WCHAR szNum1[] = {'1','\0' };
1717 DECIMAL *pdec = &V_DECIMAL(&v);
1718 CY *pcy = &V_CY(&v);
1723 /* Test all possible V_VT values */
1724 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
1728 for (vt = 0; vt <= VT_BSTR_BLOB; vt++)
1730 HRESULT hExpected = DISP_E_BADVARTYPE;
1734 memset(&v, 0, sizeof(v));
1735 V_VT(&v) = vt | ExtraFlags[i];
1736 V_VT(&vDst) = VT_EMPTY;
1740 case VT_I1: case VT_UI1: case VT_I2: case VT_UI2:
1741 case VT_INT: case VT_UINT: case VT_I4: case VT_UI4:
1742 case VT_R4: case VT_R8:
1743 case VT_DECIMAL: case VT_BOOL: case VT_NULL: case VT_EMPTY:
1744 case VT_DATE: case VT_CY:
1747 case VT_I8: case VT_UI8:
1748 if (HAVE_OLEAUT32_I8)
1752 if (HAVE_OLEAUT32_RECORD)
1753 hExpected = DISP_E_TYPEMISMATCH;
1755 case VT_UNKNOWN: case VT_BSTR: case VT_DISPATCH: case VT_ERROR:
1756 hExpected = DISP_E_TYPEMISMATCH;
1759 if (IsValidVariantClearVT(vt, ExtraFlags[i]) && vt != VT_CLSID)
1760 hExpected = DISP_E_TYPEMISMATCH;
1764 hres = pVarNot(&v,&vDst);
1765 ok(hres == hExpected, "VarNot: expected 0x%X, got 0x%X vt %d|0x%X\n",
1766 hExpected, hres, vt, ExtraFlags[i]);
1769 /* Test the values returned by all cases that can succeed */
1770 VARNOT(EMPTY,0,I2,-1);
1771 VARNOT(EMPTY,1,I2,-1);
1772 VARNOT(NULL,0,NULL,0);
1773 VARNOT(NULL,1,NULL,0);
1774 VARNOT(BOOL,VARIANT_TRUE,BOOL,VARIANT_FALSE);
1775 VARNOT(BOOL,VARIANT_FALSE,BOOL,VARIANT_TRUE);
1783 VARNOT(UI1,1,UI1,254);
1784 VARNOT(UI1,0,UI1,255);
1785 VARNOT(UI2,0,I4,-1);
1786 VARNOT(UI2,1,I4,-2);
1787 VARNOT(UI4,0,I4,-1);
1788 VARNOT(UI4,1,I4,-2);
1789 VARNOT(INT,0,I4,-1);
1790 VARNOT(INT,1,I4,-2);
1791 VARNOT(UINT,0,I4,-1);
1792 VARNOT(UINT,1,I4,-2);
1793 if (HAVE_OLEAUT32_I8)
1797 VARNOT(UI8,0,I4,-1);
1798 VARNOT(UI8,1,I4,-2);
1804 VARNOT(DATE,1,I4,-2);
1805 VARNOT(DATE,0,I4,-1);
1806 VARNOT(BSTR,(BSTR)szNum0,I4,-1);
1807 ok(V_VT(&v) == VT_BSTR && V_BSTR(&v) == szNum0, "VarNot(0): changed input\n");
1808 VARNOT(BSTR,(BSTR)szNum1,I4,-2);
1809 ok(V_VT(&v) == VT_BSTR && V_BSTR(&v) == szNum1, "VarNot(1): changed input\n");
1811 V_VT(&v) = VT_DECIMAL;
1812 S(U(*pdec)).sign = DECIMAL_NEG;
1813 S(U(*pdec)).scale = 0;
1815 S1(U1(*pdec)).Mid32 = 0;
1816 S1(U1(*pdec)).Lo32 = 1;
1817 VARNOT(DECIMAL,*pdec,I4,0);
1820 VARNOT(CY,*pcy,I4,-2);
1823 VARNOT(CY,*pcy,I4,-1);
1826 VARNOT(CY,*pcy,I4,-1);
1829 static HRESULT (WINAPI *pVarSub)(LPVARIANT,LPVARIANT,LPVARIANT);
1831 static const char *szVarSubI4 = "VarSub(%d,%d): expected 0x0,%d,%d, got 0x%X,%d,%d\n";
1832 static const char *szVarSubR8 = "VarSub(%d,%d): expected 0x0,%d,%f, got 0x%X,%d,%f\n";
1834 #define VARSUB(vt1,val1,vt2,val2,rvt,rval) \
1835 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
1836 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
1837 memset(&result,0,sizeof(result)); hres = pVarSub(&left,&right,&result); \
1838 if (VT_##rvt == VT_R4 || VT_##rvt == VT_R8 || VT_##rvt == VT_DATE) { \
1839 ok(hres == S_OK && V_VT(&result) == VT_##rvt && \
1840 EQ_FLOAT(V_##rvt(&result), rval), \
1841 szVarSubR8, VT_##vt1, VT_##vt2, \
1842 VT_##rvt, (double)(rval), hres, V_VT(&result), (double)V_##rvt(&result)); \
1844 ok(hres == S_OK && V_VT(&result) == VT_##rvt && V_##rvt(&result) == (rval), \
1845 szVarSubI4, VT_##vt1, VT_##vt2, \
1846 VT_##rvt, (int)(rval), hres, V_VT(&result), (int)V_##rvt(&result)); }
1848 static void test_VarSub(void)
1850 static const WCHAR sz12[] = {'1','2','\0'};
1851 VARIANT left, right, result, cy, dec;
1854 HRESULT hres, expectedhres;
1859 lbstr = SysAllocString(sz12);
1860 rbstr = SysAllocString(sz12);
1863 VariantInit(&right);
1864 VariantInit(&result);
1866 /* Test all possible flag/vt combinations & the resulting vt type */
1867 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
1870 VARTYPE leftvt, rightvt, resvt;
1872 for (leftvt = 0; leftvt <= VT_BSTR_BLOB; leftvt++)
1877 for (rightvt = 0; rightvt <= VT_BSTR_BLOB; rightvt++)
1881 expectedhres = S_OK;
1883 memset(&left, 0, sizeof(left));
1884 memset(&right, 0, sizeof(right));
1885 V_VT(&left) = leftvt | ExtraFlags[i];
1886 if (leftvt == VT_BSTR)
1887 V_BSTR(&left) = lbstr;
1888 V_VT(&right) = rightvt | ExtraFlags[i];
1889 if (rightvt == VT_BSTR)
1890 V_BSTR(&right) = rbstr;
1891 V_VT(&result) = VT_EMPTY;
1894 /* All extra flags produce errors */
1895 if (ExtraFlags[i] == (VT_VECTOR|VT_BYREF|VT_RESERVED) ||
1896 ExtraFlags[i] == (VT_VECTOR|VT_RESERVED) ||
1897 ExtraFlags[i] == (VT_VECTOR|VT_BYREF) ||
1898 ExtraFlags[i] == (VT_BYREF|VT_RESERVED) ||
1899 ExtraFlags[i] == VT_VECTOR ||
1900 ExtraFlags[i] == VT_BYREF ||
1901 ExtraFlags[i] == VT_RESERVED)
1903 expectedhres = DISP_E_BADVARTYPE;
1906 else if (ExtraFlags[i] >= VT_ARRAY)
1908 expectedhres = DISP_E_TYPEMISMATCH;
1911 /* Native VarSub cannot handle: VT_I1, VT_UI2, VT_UI4,
1912 VT_INT, VT_UINT and VT_UI8. Tested with WinXP */
1913 else if (!IsValidVariantClearVT(leftvt, ExtraFlags[i]) ||
1914 !IsValidVariantClearVT(rightvt, ExtraFlags[i]) ||
1915 leftvt == VT_CLSID || rightvt == VT_CLSID ||
1916 leftvt == VT_VARIANT || rightvt == VT_VARIANT ||
1917 leftvt == VT_I1 || rightvt == VT_I1 ||
1918 leftvt == VT_UI2 || rightvt == VT_UI2 ||
1919 leftvt == VT_UI4 || rightvt == VT_UI4 ||
1920 leftvt == VT_UI8 || rightvt == VT_UI8 ||
1921 leftvt == VT_INT || rightvt == VT_INT ||
1922 leftvt == VT_UINT || rightvt == VT_UINT ||
1923 leftvt == VT_UNKNOWN || rightvt == VT_UNKNOWN ||
1924 leftvt == VT_RECORD || rightvt == VT_RECORD)
1926 if (leftvt == VT_RECORD && rightvt == VT_I8)
1927 expectedhres = DISP_E_TYPEMISMATCH;
1928 else if (leftvt < VT_UI1 && rightvt == VT_RECORD)
1929 expectedhres = DISP_E_TYPEMISMATCH;
1930 else if (leftvt >= VT_UI1 && rightvt == VT_RECORD)
1931 expectedhres = DISP_E_TYPEMISMATCH;
1932 else if (leftvt == VT_RECORD && rightvt <= VT_UI1)
1933 expectedhres = DISP_E_TYPEMISMATCH;
1934 else if (leftvt == VT_RECORD && rightvt > VT_UI1)
1935 expectedhres = DISP_E_BADVARTYPE;
1937 expectedhres = DISP_E_BADVARTYPE;
1940 else if ((leftvt == VT_NULL && rightvt == VT_DISPATCH) ||
1941 (leftvt == VT_DISPATCH && rightvt == VT_NULL))
1943 else if (leftvt == VT_DISPATCH || rightvt == VT_DISPATCH ||
1944 leftvt == VT_ERROR || rightvt == VT_ERROR)
1947 expectedhres = DISP_E_TYPEMISMATCH;
1949 else if (leftvt == VT_NULL || rightvt == VT_NULL)
1951 else if ((leftvt == VT_EMPTY && rightvt == VT_BSTR) ||
1952 (leftvt == VT_DATE && rightvt == VT_DATE) ||
1953 (leftvt == VT_BSTR && rightvt == VT_EMPTY) ||
1954 (leftvt == VT_BSTR && rightvt == VT_BSTR))
1956 else if (leftvt == VT_DECIMAL || rightvt == VT_DECIMAL)
1958 else if (leftvt == VT_DATE || rightvt == VT_DATE)
1960 else if (leftvt == VT_CY || rightvt == VT_CY)
1962 else if (leftvt == VT_R8 || rightvt == VT_R8)
1964 else if (leftvt == VT_BSTR || rightvt == VT_BSTR) {
1966 } else if (leftvt == VT_R4 || rightvt == VT_R4) {
1967 if (leftvt == VT_I4 || rightvt == VT_I4 ||
1968 leftvt == VT_I8 || rightvt == VT_I8)
1973 else if (leftvt == VT_I8 || rightvt == VT_I8)
1975 else if (leftvt == VT_I4 || rightvt == VT_I4)
1977 else if (leftvt == VT_I2 || rightvt == VT_I2 ||
1978 leftvt == VT_BOOL || rightvt == VT_BOOL ||
1979 (leftvt == VT_EMPTY && rightvt == VT_EMPTY))
1981 else if (leftvt == VT_UI1 || rightvt == VT_UI1)
1986 expectedhres = DISP_E_TYPEMISMATCH;
1989 hres = pVarSub(&left, &right, &result);
1991 ok(hres == expectedhres && V_VT(&result) == resvt,
1992 "VarSub: %d|0x%X, %d|0x%X: Expected failure 0x%X, "
1993 "got 0x%X, expected vt %d got vt %d\n",
1994 leftvt, ExtraFlags[i], rightvt, ExtraFlags[i],
1995 expectedhres, hres, resvt, V_VT(&result));
2000 /* Test returned values */
2001 VARSUB(I4,4,I4,2,I4,2);
2002 VARSUB(I2,4,I2,2,I2,2);
2003 VARSUB(I2,-13,I4,5,I4,-18);
2004 VARSUB(I4,-13,I4,5,I4,-18);
2005 VARSUB(I2,7,R4,0.5,R4,6.5);
2006 VARSUB(R4,0.5,I4,5,R8,-4.5);
2007 VARSUB(R8,7.1,BOOL,0,R8,7.1);
2008 VARSUB(BSTR,lbstr,I2,4,R8,8);
2009 VARSUB(BSTR,lbstr,BOOL,1,R8,11);
2010 VARSUB(BSTR,lbstr,R4,0.1,R8,11.9);
2011 VARSUB(R4,0.2,BSTR,rbstr,R8,-11.8);
2012 VARSUB(DATE,2.25,I4,7,DATE,-4.75);
2013 VARSUB(DATE,1.25,R4,-1.7,DATE,2.95);
2015 VARSUB(UI1, UI1_MAX, UI1, UI1_MAX, UI1, 0);
2016 VARSUB(I2, I2_MAX, I2, I2_MAX, I2, 0);
2017 VARSUB(I2, I2_MIN, I2, I2_MIN, I2, 0);
2018 VARSUB(I4, I4_MAX, I4, I4_MAX, I4, 0.0);
2019 VARSUB(I4, I4_MIN, I4, I4_MIN, I4, 0.0);
2020 VARSUB(R4, R4_MAX, R4, R4_MAX, R4, 0.0);
2021 VARSUB(R4, R4_MAX, R4, R4_MIN, R4, R4_MAX - R4_MIN);
2022 VARSUB(R4, R4_MIN, R4, R4_MIN, R4, 0.0);
2023 VARSUB(R8, R8_MAX, R8, R8_MIN, R8, R8_MAX - R8_MIN);
2024 VARSUB(R8, R8_MIN, R8, R8_MIN, R8, 0.0);
2026 /* Manually test BSTR + BSTR */
2027 V_VT(&left) = VT_BSTR;
2028 V_BSTR(&left) = lbstr;
2029 V_VT(&right) = VT_BSTR;
2030 V_BSTR(&right) = rbstr;
2031 hres = VarSub(&left, &right, &result);
2032 ok(hres == S_OK && V_VT(&result) == VT_R8,
2033 "VarSub: expected coerced type VT_R8, got %s!\n", vtstr(V_VT(&result)));
2034 ok(hres == S_OK && EQ_DOUBLE(V_R8(&result), 0),
2035 "VarSub: BSTR + BSTR, expected %f got %f\n", 0.0, V_R8(&result));
2037 /* Manually test some VT_CY and VT_DECIMAL variants */
2039 hres = VarCyFromI4(4711, &V_CY(&cy));
2040 ok(hres == S_OK, "VarCyFromI4 failed!\n");
2041 V_VT(&dec) = VT_DECIMAL;
2042 hres = VarDecFromR8(-4.2, &V_DECIMAL(&dec));
2043 ok(hres == S_OK, "VarDecFromR4 failed!\n");
2044 memset(&left, 0, sizeof(left));
2045 memset(&right, 0, sizeof(right));
2046 V_VT(&left) = VT_I4;
2048 V_VT(&right) = VT_UI1;
2051 hres = VarSub(&cy, &right, &result);
2052 ok(hres == S_OK && V_VT(&result) == VT_CY,
2053 "VarSub: expected coerced type VT_CY, got %s!\n", vtstr(V_VT(&result)));
2054 hres = VarR8FromCy(V_CY(&result), &r);
2055 ok(hres == S_OK && EQ_DOUBLE(r, 4702),
2056 "VarSub: CY value %f, expected %f\n", r, (double)4720);
2058 hres = VarSub(&left, &dec, &result);
2059 ok(hres == S_OK && V_VT(&result) == VT_DECIMAL,
2060 "VarSub: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result)));
2061 hres = VarR8FromDec(&V_DECIMAL(&result), &r);
2062 ok(hres == S_OK && EQ_DOUBLE(r, -6.8),
2063 "VarSub: DECIMAL value %f, expected %f\n", r, (double)-15.2);
2065 SysFreeString(lbstr);
2066 SysFreeString(rbstr);
2069 static const char *szVarModFail = "VarMod: expected 0x%x,%d(%s),%d, got 0x%X,%d(%s),%d\n";
2070 #define VARMOD(vt1,vt2,val1,val2,rvt,rval,hexpected) V_VT(&v1) = VT_##vt1; V_##vt1(&v1) = val1; \
2071 V_VT(&v2) = VT_##vt2; V_##vt2(&v2) = val2; \
2072 memset(&vDst,0,sizeof(vDst)); hres = pVarMod(&v1,&v2,&vDst); \
2073 ok(hres == hexpected && V_VT(&vDst) == VT_##rvt && V_##rvt(&vDst) == (rval), \
2074 szVarModFail, hexpected, VT_##rvt, vtstr(VT_##rvt), (int)(rval), \
2075 hres, V_VT(&vDst), vtstr(V_VT(&vDst)), (int)V_##rvt(&vDst))
2077 static const char *szVarMod2Fail = "VarMod: expected 0x%x,%d(%s),%d, got 0x%X,%d(%s),%d\n";
2078 #define VARMOD2(vt1,vt2,val1,val2,rvt,rval,hexpected) V_VT(&v1) = VT_##vt1; V_I4(&v1) = val1; \
2079 V_VT(&v2) = VT_##vt2; V_I4(&v2) = val2; \
2080 memset(&vDst,0,sizeof(vDst)); hres = pVarMod(&v1,&v2,&vDst); \
2081 ok(hres == hexpected && V_VT(&vDst) == VT_##rvt && V_I4(&vDst) == (rval), \
2082 szVarMod2Fail, hexpected, VT_##rvt, vtstr(VT_##rvt), (int)(rval), \
2083 hres, V_VT(&vDst), vtstr(V_VT(&vDst)), (int)V_I4(&vDst))
2085 static HRESULT (WINAPI *pVarMod)(LPVARIANT,LPVARIANT,LPVARIANT);
2087 static void test_VarMod(void)
2089 VARIANT v1, v2, vDst;
2091 HRESULT hexpected = 0;
2092 static const WCHAR szNum0[] = {'1','2','5','\0'};
2093 static const WCHAR szNum1[] = {'1','0','\0'};
2095 BOOL lFound, rFound;
2096 BOOL lValid, rValid;
2097 BSTR strNum0, strNum1;
2101 VARMOD(I1,BOOL,100,10,I4,0,S_OK);
2102 VARMOD(I1,I1,100,10,I4,0,S_OK);
2103 VARMOD(I1,UI1,100,10,I4,0,S_OK);
2104 VARMOD(I1,I2,100,10,I4,0,S_OK);
2105 VARMOD(I1,UI2,100,10,I4,0,S_OK);
2106 VARMOD(I1,I4,100,10,I4,0,S_OK);
2107 VARMOD(I1,UI4,100,10,I4,0,S_OK);
2108 VARMOD(I1,R4,100,10,I4,0,S_OK);
2109 VARMOD(I1,R8,100,10,I4,0,S_OK);
2111 VARMOD(UI1,BOOL,100,10,I2,0,S_OK);
2112 VARMOD(UI1,I1,100,10,I4,0,S_OK);
2113 VARMOD(UI1,UI1,100,10,UI1,0,S_OK);
2114 VARMOD(UI1,I2,100,10,I2,0,S_OK);
2115 VARMOD(UI1,UI2,100,10,I4,0,S_OK);
2116 VARMOD(UI1,I4,100,10,I4,0,S_OK);
2117 VARMOD(UI1,UI4,100,10,I4,0,S_OK);
2118 VARMOD(UI1,R4,100,10,I4,0,S_OK);
2119 VARMOD(UI1,R8,100,10,I4,0,S_OK);
2121 VARMOD(I2,BOOL,100,10,I2,0,S_OK);
2122 VARMOD(I2,I1,100,10,I4,0,S_OK);
2123 VARMOD(I2,UI1,100,10,I2,0,S_OK);
2124 VARMOD(I2,I2,100,10,I2,0,S_OK);
2125 VARMOD(I2,UI2,100,10,I4,0,S_OK);
2126 VARMOD(I2,I4,100,10,I4,0,S_OK);
2127 VARMOD(I2,UI4,100,10,I4,0,S_OK);
2128 VARMOD(I2,R4,100,10,I4,0,S_OK);
2129 VARMOD(I2,R8,100,10,I4,0,S_OK);
2131 VARMOD(I4,BOOL,100,10,I4,0,S_OK);
2132 VARMOD(I4,I1,100,10,I4,0,S_OK);
2133 VARMOD(I4,UI1,100,10,I4,0,S_OK);
2134 VARMOD(I4,I2,100,10,I4,0,S_OK);
2135 VARMOD(I4,UI2,100,10,I4,0,S_OK);
2136 VARMOD(I4,I4,100,10,I4,0,S_OK);
2137 VARMOD(I4,UI4,100,10,I4,0,S_OK);
2138 VARMOD(I4,R4,100,10,I4,0,S_OK);
2139 VARMOD(I4,R8,100,10,I4,0,S_OK);
2140 VARMOD(UI4,BOOL,100,10,I4,0,S_OK);
2141 VARMOD(UI4,I1,100,10,I4,0,S_OK);
2142 VARMOD(UI4,UI1,100,10,I4,0,S_OK);
2143 VARMOD(UI4,I2,100,10,I4,0,S_OK);
2144 VARMOD(UI4,UI2,100,10,I4,0,S_OK);
2145 VARMOD(UI4,I4,100,10,I4,0,S_OK);
2146 VARMOD(UI4,UI4,100,10,I4,0,S_OK);
2147 VARMOD(UI4,R4,100,10,I4,0,S_OK);
2148 VARMOD(UI4,R8,100,10,I4,0,S_OK);
2149 VARMOD(R4,BOOL,100,10,I4,0,S_OK);
2150 VARMOD(R4,I1,100,10,I4,0,S_OK);
2151 VARMOD(R4,UI1,100,10,I4,0,S_OK);
2152 VARMOD(R4,I2,100,10,I4,0,S_OK);
2153 VARMOD(R4,UI2,100,10,I4,0,S_OK);
2154 VARMOD(R4,I4,100,10,I4,0,S_OK);
2155 VARMOD(R4,UI4,100,10,I4,0,S_OK);
2156 VARMOD(R4,R4,100,10,I4,0,S_OK);
2157 VARMOD(R4,R8,100,10,I4,0,S_OK);
2158 VARMOD(R8,BOOL,100,10,I4,0,S_OK);
2159 VARMOD(R8,I1,100,10,I4,0,S_OK);
2160 VARMOD(R8,UI1,100,10,I4,0,S_OK);
2161 VARMOD(R8,I2,100,10,I4,0,S_OK);
2162 VARMOD(R8,UI2,100,10,I4,0,S_OK);
2163 VARMOD(R8,I4,100,10,I4,0,S_OK);
2164 VARMOD(R8,UI4,100,10,I4,0,S_OK);
2165 VARMOD(R8,R4,100,10,I4,0,S_OK);
2166 VARMOD(R8,R8,100,10,I4,0,S_OK);
2168 VARMOD(INT,INT,100,10,I4,0,S_OK);
2169 VARMOD(INT,UINT,100,10,I4,0,S_OK);
2171 VARMOD(BOOL,BOOL,100,10,I2,0,S_OK);
2172 VARMOD(BOOL,I1,100,10,I4,0,S_OK);
2173 VARMOD(BOOL,UI1,100,10,I2,0,S_OK);
2174 VARMOD(BOOL,I2,100,10,I2,0,S_OK);
2175 VARMOD(BOOL,UI2,100,10,I4,0,S_OK);
2176 VARMOD(BOOL,I4,100,10,I4,0,S_OK);
2177 VARMOD(BOOL,UI4,100,10,I4,0,S_OK);
2178 VARMOD(BOOL,R4,100,10,I4,0,S_OK);
2179 VARMOD(BOOL,R8,100,10,I4,0,S_OK);
2180 VARMOD(BOOL,DATE,100,10,I4,0,S_OK);
2182 VARMOD(DATE,BOOL,100,10,I4,0,S_OK);
2183 VARMOD(DATE,I1,100,10,I4,0,S_OK);
2184 VARMOD(DATE,UI1,100,10,I4,0,S_OK);
2185 VARMOD(DATE,I2,100,10,I4,0,S_OK);
2186 VARMOD(DATE,UI2,100,10,I4,0,S_OK);
2187 VARMOD(DATE,I4,100,10,I4,0,S_OK);
2188 VARMOD(DATE,UI4,100,10,I4,0,S_OK);
2189 VARMOD(DATE,R4,100,10,I4,0,S_OK);
2190 VARMOD(DATE,R8,100,10,I4,0,S_OK);
2191 VARMOD(DATE,DATE,100,10,I4,0,S_OK);
2193 strNum0 = SysAllocString(szNum0);
2194 strNum1 = SysAllocString(szNum1);
2195 VARMOD(BSTR,BSTR,strNum0,strNum1,I4,5,S_OK);
2196 VARMOD(BSTR,I1,strNum0,10,I4,5,S_OK);
2197 VARMOD(BSTR,I2,strNum0,10,I4,5,S_OK);
2198 VARMOD(BSTR,I4,strNum0,10,I4,5,S_OK);
2199 VARMOD(BSTR,R4,strNum0,10,I4,5,S_OK);
2200 VARMOD(BSTR,R8,strNum0,10,I4,5,S_OK);
2201 VARMOD(I4,BSTR,125,strNum1,I4,5,S_OK);
2203 if (HAVE_OLEAUT32_I8)
2205 VARMOD(BOOL,I8,100,10,I8,0,S_OK);
2206 VARMOD(I1,I8,100,10,I8,0,S_OK);
2207 VARMOD(UI1,I8,100,10,I8,0,S_OK);
2208 VARMOD(I2,I8,100,10,I8,0,S_OK);
2209 VARMOD(I4,I8,100,10,I8,0,S_OK);
2210 VARMOD(UI4,I8,100,10,I8,0,S_OK);
2211 VARMOD(R4,I8,100,10,I8,0,S_OK);
2212 VARMOD(R8,I8,100,10,I8,0,S_OK);
2213 VARMOD(DATE,I8,100,10,I8,0,S_OK);
2215 VARMOD(I8,BOOL,100,10,I8,0,S_OK);
2216 VARMOD(I8,I1,100,10,I8,0,S_OK);
2217 VARMOD(I8,UI1,100,10,I8,0,S_OK);
2218 VARMOD(I8,I2,100,10,I8,0,S_OK);
2219 VARMOD(I8,UI2,100,10,I8,0,S_OK);
2220 VARMOD(I8,I4,100,10,I8,0,S_OK);
2221 VARMOD(I8,UI4,100,10,I8,0,S_OK);
2222 VARMOD(I8,R4,100,10,I8,0,S_OK);
2223 VARMOD(I8,R8,100,10,I8,0,S_OK);
2224 VARMOD(I8,I8,100,10,I8,0,S_OK);
2226 VARMOD(BSTR,I8,strNum0,10,I8,5,S_OK);
2229 /* test all combinations of types */
2230 for(l = 0; l < VT_BSTR_BLOB; l++)
2234 for(r = 0; r < VT_BSTR_BLOB; r++)
2238 if(l == VT_BSTR) continue;
2239 if(l == VT_DISPATCH) continue;
2240 if(r == VT_BSTR) continue;
2241 if(r == VT_DISPATCH) continue;
2275 hexpected = DISP_E_BADVARTYPE;
2314 if(((l == VT_I8) && (r == VT_INT)) || ((l == VT_INT) && (r == VT_I8)))
2316 hexpected = DISP_E_TYPEMISMATCH;
2317 } else if((l == VT_EMPTY) && (r == VT_NULL))
2320 } else if((l == VT_NULL) && (r == VT_EMPTY))
2323 } else if((l == VT_EMPTY) && (r == VT_CY))
2326 } else if((l == VT_EMPTY) && (r == VT_RECORD))
2328 hexpected = DISP_E_TYPEMISMATCH;
2329 } else if((r == VT_EMPTY) && lFound && lValid)
2331 hexpected = DISP_E_DIVBYZERO;
2332 } else if((l == VT_ERROR) || ((r == VT_ERROR) && lFound && lValid))
2334 hexpected = DISP_E_TYPEMISMATCH;
2335 } else if((l == VT_NULL) && (r == VT_NULL))
2338 } else if((l == VT_VARIANT) || ((r == VT_VARIANT) && lFound && lValid))
2340 hexpected = DISP_E_TYPEMISMATCH;
2341 } else if((l == VT_NULL) && (r == VT_RECORD))
2343 hexpected = DISP_E_TYPEMISMATCH;
2344 } else if((l == VT_NULL) && (r == VT_DECIMAL))
2346 hexpected = E_INVALIDARG;
2347 } else if((l == VT_UNKNOWN) || ((r == VT_UNKNOWN) && lFound && lValid))
2349 hexpected = DISP_E_TYPEMISMATCH;
2350 } else if((l == VT_NULL) && rFound)
2353 } else if((l == VT_DECIMAL) || ((r == VT_DECIMAL) && lFound && lValid))
2355 hexpected = E_INVALIDARG;
2356 } else if(l == VT_RECORD)
2358 hexpected = DISP_E_TYPEMISMATCH;
2359 } else if((r == VT_RECORD) && lValid && lFound)
2361 hexpected = DISP_E_TYPEMISMATCH;
2362 } else if((l == VT_EMPTY) && (r == VT_EMPTY))
2364 hexpected = DISP_E_DIVBYZERO;
2365 } else if((l == VT_CY) && !rFound)
2367 hexpected = DISP_E_BADVARTYPE;
2368 } else if(lFound && !rFound)
2370 hexpected = DISP_E_BADVARTYPE;
2371 } else if(!lFound && rFound)
2373 hexpected = DISP_E_BADVARTYPE;
2374 } else if((r == VT_NULL) && lFound && lValid)
2377 } else if((l == VT_NULL) || (r == VT_NULL))
2379 hexpected = DISP_E_BADVARTYPE;
2380 } else if((l == VT_VARIANT) || (r == VT_VARIANT))
2382 hexpected = DISP_E_BADVARTYPE;
2383 } else if(lFound && !rFound)
2385 hexpected = DISP_E_BADVARTYPE;
2386 } else if(!lFound && !rFound)
2388 hexpected = DISP_E_BADVARTYPE;
2395 V_CY(&v1).int64 = 1000000;
2400 else if(l == VT_UI8)
2402 else if(l == VT_DATE)
2408 V_CY(&v2).int64 = 10000;
2413 else if(r == VT_UI8)
2415 else if(r == VT_DATE)
2420 if ((l != VT_I8 && l != VT_UI8 && r != VT_I8 && r != VT_UI8) || HAVE_OLEAUT32_I8)
2422 hres = pVarMod(&v1,&v2,&vDst);
2423 ok(hres == hexpected,
2424 "VarMod: expected 0x%x, got 0x%X for l type of %d, r type of %d,\n", hexpected, hres, l, r);
2430 /****************************/
2431 /* test some bad parameters */
2432 VARMOD(I4,I4,-1,-1,I4,0,S_OK);
2434 /* test modulus with zero */
2435 VARMOD2(I4,I4,100,0,EMPTY,0,DISP_E_DIVBYZERO);
2437 VARMOD(I4,I4,0,10,I4,0,S_OK); /* test 0 mod 10 */
2439 /* right parameter is type empty */
2440 VARMOD2(I4,EMPTY,100,10,EMPTY,0,DISP_E_DIVBYZERO);
2442 /* left parameter is type empty */
2443 VARMOD2(EMPTY,I4,100,10,I4,0,S_OK);
2445 /* mod with a null left value */
2446 VARMOD2(NULL,I4,125,10,NULL,0,S_OK);
2448 /* mod with a null right value */
2449 VARMOD2(I4,NULL,100,10,NULL,0,S_OK);
2451 /* void left value */
2452 VARMOD2(VOID,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2454 /* void right value */
2455 VARMOD2(I4,VOID,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2457 /* null left value, void right value */
2458 VARMOD2(NULL,VOID,100,10,EMPTY, 0, DISP_E_BADVARTYPE);
2460 /* void left value, null right value */
2461 VARMOD2(VOID,NULL,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2463 /* some currencies */
2466 V_CY(&v1).int64 = 100000;
2467 V_CY(&v2).int64 = 100000;
2468 hres = pVarMod(&v1,&v2,&vDst);
2469 ok(hres == S_OK && V_VT(&vDst) == VT_I4 && V_I4(&vDst) == 0,
2470 "VarMod: expected 0x%x,%d,%d, got 0x%X,%d,%d\n", S_OK, VT_I4, 0, hres, V_VT(&vDst), V_I4(&vDst));
2475 V_CY(&v2).int64 = 100000;
2476 hres = pVarMod(&v1,&v2,&vDst);
2477 ok(hres == S_OK && V_VT(&vDst) == VT_I4 && V_I4(&vDst) == 0,
2478 "VarMod: expected 0x%x,%d,%d, got 0x%X,%d,%d\n", S_OK, VT_I4, 0, hres, V_VT(&vDst), V_I4(&vDst));
2482 V_VT(&v1) = VT_DECIMAL;
2483 V_VT(&v2) = VT_DECIMAL;
2484 VarDecFromI4(100, &V_DECIMAL(&v1));
2485 VarDecFromI4(10, &V_DECIMAL(&v2));
2486 hres = pVarMod(&v1,&v2,&vDst);
2487 ok(hres == S_OK && V_VT(&vDst) == VT_I4 && V_I4(&vDst) == 0,
2488 "VarMod: expected 0x%x,%d,%d, got 0x%X,%d,%d\n", S_OK, VT_I4, 0, hres, V_VT(&vDst), V_I4(&vDst));
2491 V_VT(&v2) = VT_DECIMAL;
2493 VarDecFromI4(10, &V_DECIMAL(&v2));
2494 hres = pVarMod(&v1,&v2,&vDst);
2495 ok(hres == S_OK && V_VT(&vDst) == VT_I4 && V_I4(&vDst) == 0,
2496 "VarMod: expected 0x%x,%d,%d, got 0x%X,%d,%d\n", S_OK, VT_I4, 0, hres, V_VT(&vDst), V_I4(&vDst));
2499 VARMOD2(UINT,I4,100,10,I4,0,S_OK);
2501 /* test that an error results in the type of the result changing but not its value */
2502 V_VT(&v1) = VT_UNKNOWN;
2503 V_VT(&v2) = VT_EMPTY;
2505 V_CY(&v2).int64 = 100000;
2506 V_VT(&vDst) = VT_I4;
2508 hres = pVarMod(&v1,&v2,&vDst);
2509 ok(hres == DISP_E_TYPEMISMATCH && V_VT(&vDst) == VT_EMPTY && V_I4(&vDst) == 1231,
2510 "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));
2513 /* test some invalid types */
2514 /*TODO: not testing VT_DISPATCH */
2515 if (HAVE_OLEAUT32_I8)
2517 VARMOD2(I8,INT,100,10,EMPTY,0,DISP_E_TYPEMISMATCH);
2519 VARMOD2(ERROR,I4,100,10,EMPTY,0,DISP_E_TYPEMISMATCH);
2520 VARMOD2(VARIANT,I4,100,10,EMPTY,0,DISP_E_TYPEMISMATCH);
2521 VARMOD2(UNKNOWN,I4,100,10,EMPTY,0,DISP_E_TYPEMISMATCH);
2522 VARMOD2(VOID,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2523 VARMOD2(HRESULT,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2524 VARMOD2(PTR,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2525 VARMOD2(SAFEARRAY,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2526 VARMOD2(CARRAY,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2527 VARMOD2(USERDEFINED,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2528 VARMOD2(LPSTR,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2529 VARMOD2(LPWSTR,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2530 VARMOD2(RECORD,I4,100,10,EMPTY,0,DISP_E_TYPEMISMATCH);
2531 VARMOD2(FILETIME,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2532 VARMOD2(BLOB,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2533 VARMOD2(STREAM,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2534 VARMOD2(STORAGE,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2535 VARMOD2(STREAMED_OBJECT,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2536 VARMOD2(STORED_OBJECT,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2537 VARMOD2(BLOB_OBJECT,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2538 VARMOD2(CF,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2539 VARMOD2(CLSID,CLSID,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2540 VARMOD2(VECTOR,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2541 VARMOD2(ARRAY,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2542 VARMOD2(BYREF,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2544 /* test some more invalid types */
2549 hres = pVarMod(&v1,&v2,&vDst);
2550 ok(hres == DISP_E_BADVARTYPE && V_VT(&vDst) == VT_EMPTY && V_I4(&vDst) == 0,
2551 "VarMod: expected 0x%x,%d,%d, got 0x%X,%d,%d\n", DISP_E_BADVARTYPE, VT_EMPTY, 0, hres, V_VT(&vDst), V_I4(&vDst));
2554 static HRESULT (WINAPI *pVarFix)(LPVARIANT,LPVARIANT);
2556 static const char *szVarFixFail = "VarFix: expected 0x0,%d,%d, got 0x%X,%d,%d\n";
2557 #define VARFIX(vt,val,rvt,rval) V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
2558 memset(&vDst,0,sizeof(vDst)); hres = pVarFix(&v,&vDst); \
2559 ok(hres == S_OK && V_VT(&vDst) == VT_##rvt && V_##rvt(&vDst) == (rval), \
2560 szVarFixFail, VT_##rvt, (int)(rval), \
2561 hres, V_VT(&vDst), (int)V_##rvt(&vDst))
2563 static void test_VarFix(void)
2565 static const WCHAR szNumMinus1[] = {'-','1','\0' };
2568 DECIMAL *pdec = &V_DECIMAL(&v);
2569 CY *pcy = &V_CY(&v);
2574 /* Test all possible V_VT values */
2575 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
2579 for (vt = 0; vt <= VT_BSTR_BLOB; vt++)
2581 HRESULT bFail = TRUE;
2585 memset(&v, 0, sizeof(v));
2586 V_VT(&v) = vt | ExtraFlags[i];
2587 V_VT(&vDst) = VT_EMPTY;
2591 case VT_UI1: case VT_I2: case VT_I4: case VT_R4: case VT_R8:
2592 case VT_DECIMAL: case VT_BOOL: case VT_NULL: case VT_EMPTY:
2593 case VT_DATE: case VT_CY:
2597 if (HAVE_OLEAUT32_I8)
2602 hres = pVarFix(&v,&vDst);
2604 ok(hres == DISP_E_TYPEMISMATCH || hres == DISP_E_BADVARTYPE,
2605 "VarFix: expected failure, got 0x%X vt %d|0x%X\n",
2606 hres, vt, ExtraFlags[i]);
2608 ok(hres == S_OK, "VarFix: expected S_OK, got 0x%X vt %d|0x%X\n",
2609 hres, vt, ExtraFlags[i]);
2613 VARFIX(BOOL,VARIANT_TRUE,I2,VARIANT_TRUE);
2614 VARFIX(BOOL,VARIANT_FALSE,I2,0);
2615 VARFIX(BOOL,1,I2,1);
2616 VARFIX(UI1,1,UI1,1);
2617 VARFIX(I2,-1,I2,-1);
2618 VARFIX(I4,-1,I4,-1);
2619 if (HAVE_OLEAUT32_I8)
2621 VARFIX(I8,-1,I8,-1);
2623 VARFIX(R4,1.4,R4,1);
2624 VARFIX(R4,1.5,R4,1);
2625 VARFIX(R4,1.6,R4,1);
2626 VARFIX(R4,-1.4,R4,-1);
2627 VARFIX(R4,-1.5,R4,-1);
2628 VARFIX(R4,-1.6,R4,-1);
2629 /* DATE & R8 round as for R4 */
2630 VARFIX(DATE,-1,DATE,-1);
2631 VARFIX(R8,-1,R8,-1);
2632 VARFIX(BSTR,(BSTR)szNumMinus1,R8,-1);
2634 V_VT(&v) = VT_EMPTY;
2635 hres = pVarFix(&v,&vDst);
2636 ok(hres == S_OK && V_VT(&vDst) == VT_I2 && V_I2(&vDst) == 0,
2637 "VarFix: expected 0x0,%d,0 got 0x%X,%d,%d\n", VT_EMPTY,
2638 hres, V_VT(&vDst), V_I2(&vDst));
2641 hres = pVarFix(&v,&vDst);
2642 ok(hres == S_OK && V_VT(&vDst) == VT_NULL,
2643 "VarFix: expected 0x0,%d got 0x%X,%d\n", VT_NULL, hres, V_VT(&vDst));
2645 V_VT(&v) = VT_DECIMAL;
2646 S(U(*pdec)).sign = DECIMAL_NEG;
2647 S(U(*pdec)).scale = 0;
2649 S1(U1(*pdec)).Mid32 = 0;
2650 S1(U1(*pdec)).Lo32 = 1;
2651 hres = pVarFix(&v,&vDst);
2652 ok(hres == S_OK && V_VT(&vDst) == VT_DECIMAL && !memcmp(&v, &vDst, sizeof(v)),
2653 "VarFix: expected 0x0,%d,identical, got 0x%X,%d\n", VT_DECIMAL,
2656 /* FIXME: Test some fractional decimals when VarDecFix is implemented */
2659 pcy->int64 = -10000;
2660 hres = pVarFix(&v,&vDst);
2661 ok(hres == S_OK && V_VT(&vDst) == VT_CY && V_CY(&vDst).int64 == -10000,
2662 "VarFix: VT_CY wrong, hres=0x%X\n", hres);
2665 pcy->int64 = -16000;
2666 hres = pVarFix(&v,&vDst);
2667 ok(hres == S_OK && V_VT(&vDst) == VT_CY && V_CY(&vDst).int64 == -10000,
2668 "VarFix: VT_CY wrong, hres=0x%X\n", hres);
2671 static HRESULT (WINAPI *pVarInt)(LPVARIANT,LPVARIANT);
2673 static const char *szVarIntFail = "VarInt: expected 0x0,%d,%d, got 0x%X,%d,%d\n";
2674 #define VARINT(vt,val,rvt,rval) V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
2675 memset(&vDst,0,sizeof(vDst)); hres = pVarInt(&v,&vDst); \
2676 ok(hres == S_OK && V_VT(&vDst) == VT_##rvt && V_##rvt(&vDst) == (rval), \
2677 szVarIntFail, VT_##rvt, (int)(rval), \
2678 hres, V_VT(&vDst), (int)V_##rvt(&vDst))
2680 static void test_VarInt(void)
2682 static const WCHAR szNumMinus1[] = {'-','1','\0' };
2685 DECIMAL *pdec = &V_DECIMAL(&v);
2686 CY *pcy = &V_CY(&v);
2691 /* Test all possible V_VT values */
2692 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
2696 for (vt = 0; vt <= VT_BSTR_BLOB; vt++)
2698 HRESULT bFail = TRUE;
2702 memset(&v, 0, sizeof(v));
2703 V_VT(&v) = vt | ExtraFlags[i];
2704 V_VT(&vDst) = VT_EMPTY;
2708 case VT_UI1: case VT_I2: case VT_I4: case VT_R4: case VT_R8:
2709 case VT_DECIMAL: case VT_BOOL: case VT_NULL: case VT_EMPTY:
2710 case VT_DATE: case VT_CY:
2714 if (HAVE_OLEAUT32_I8)
2719 hres = pVarInt(&v,&vDst);
2721 ok(hres == DISP_E_TYPEMISMATCH || hres == DISP_E_BADVARTYPE,
2722 "VarInt: expected failure, got 0x%X vt %d|0x%X\n",
2723 hres, vt, ExtraFlags[i]);
2725 ok(hres == S_OK, "VarInt: expected S_OK, got 0x%X vt %d|0x%X\n",
2726 hres, vt, ExtraFlags[i]);
2730 VARINT(BOOL,VARIANT_TRUE,I2,VARIANT_TRUE);
2731 VARINT(BOOL,VARIANT_FALSE,I2,0);
2732 VARINT(BOOL,1,I2,1);
2733 VARINT(UI1,1,UI1,1);
2734 VARINT(I2,-1,I2,-1);
2735 VARINT(I4,-1,I4,-1);
2736 if (HAVE_OLEAUT32_I8)
2738 VARINT(I8,-1,I8,-1);
2740 VARINT(R4,1.4,R4,1);
2741 VARINT(R4,1.5,R4,1);
2742 VARINT(R4,1.6,R4,1);
2743 VARINT(R4,-1.4,R4,-2); /* Note these 3 are different from VarFix */
2744 VARINT(R4,-1.5,R4,-2);
2745 VARINT(R4,-1.6,R4,-2);
2746 /* DATE & R8 round as for R4 */
2747 VARINT(DATE,-1,DATE,-1);
2748 VARINT(R8,-1,R8,-1);
2749 VARINT(BSTR,(BSTR)szNumMinus1,R8,-1);
2751 V_VT(&v) = VT_EMPTY;
2752 hres = pVarInt(&v,&vDst);
2753 ok(hres == S_OK && V_VT(&vDst) == VT_I2 && V_I2(&vDst) == 0,
2754 "VarInt: expected 0x0,%d,0 got 0x%X,%d,%d\n", VT_EMPTY,
2755 hres, V_VT(&vDst), V_I2(&vDst));
2758 hres = pVarInt(&v,&vDst);
2759 ok(hres == S_OK && V_VT(&vDst) == VT_NULL,
2760 "VarInt: expected 0x0,%d got 0x%X,%d\n", VT_NULL, hres, V_VT(&vDst));
2762 V_VT(&v) = VT_DECIMAL;
2763 S(U(*pdec)).sign = DECIMAL_NEG;
2764 S(U(*pdec)).scale = 0;
2766 S1(U1(*pdec)).Mid32 = 0;
2767 S1(U1(*pdec)).Lo32 = 1;
2768 hres = pVarInt(&v,&vDst);
2769 ok(hres == S_OK && V_VT(&vDst) == VT_DECIMAL && !memcmp(&v, &vDst, sizeof(v)),
2770 "VarInt: expected 0x0,%d,identical, got 0x%X,%d\n", VT_DECIMAL,
2773 /* FIXME: Test some fractional decimals when VarDecInt is implemented */
2776 pcy->int64 = -10000;
2777 hres = pVarInt(&v,&vDst);
2778 ok(hres == S_OK && V_VT(&vDst) == VT_CY && V_CY(&vDst).int64 == -10000,
2779 "VarInt: VT_CY wrong, hres=0x%X\n", hres);
2782 pcy->int64 = -11000;
2783 hres = pVarInt(&v,&vDst);
2784 ok(hres == S_OK && V_VT(&vDst) == VT_CY && V_CY(&vDst).int64 == -20000,
2785 "VarInt: VT_CY wrong, hres=0x%X 0x%x%08x\n",
2786 hres, (DWORD)(V_CY(&vDst).int64 >> 32), (DWORD)V_CY(&vDst).int64);
2789 static HRESULT (WINAPI *pVarNeg)(LPVARIANT,LPVARIANT);
2791 static const char *szVarNegFail = "VarNeg: expected 0x0,%d,%d, got 0x%X,%d,%d\n";
2792 #define VARNEG(vt,val,rvt,rval) V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
2793 memset(&vDst,0,sizeof(vDst)); hres = pVarNeg(&v,&vDst); \
2794 ok(hres == S_OK && V_VT(&vDst) == VT_##rvt && V_##rvt(&vDst) == (rval), \
2795 szVarNegFail, VT_##rvt, (int)(rval), \
2796 hres, V_VT(&vDst), (int)V_##rvt(&vDst))
2798 static void test_VarNeg(void)
2800 static const WCHAR szNumMinus1[] = {'-','1','\0' };
2801 static const WCHAR szNum1[] = {'1','\0' };
2804 DECIMAL *pdec = &V_DECIMAL(&v);
2805 CY *pcy = &V_CY(&v);
2810 /* Test all possible V_VT values. But don't test the exact return values
2811 * except for success/failure, since M$ made a hash of them in the
2812 * native version. This at least ensures (as with all tests here) that
2813 * we will notice if/when new vtypes/flags are added in native.
2815 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
2819 for (vt = 0; vt <= VT_BSTR_BLOB; vt++)
2821 HRESULT bFail = TRUE;
2825 memset(&v, 0, sizeof(v));
2826 V_VT(&v) = vt | ExtraFlags[i];
2827 V_VT(&vDst) = VT_EMPTY;
2831 case VT_UI1: case VT_I2: case VT_I4:
2832 case VT_R4: case VT_R8:
2833 case VT_DECIMAL: case VT_BOOL: case VT_NULL: case VT_EMPTY:
2834 case VT_DATE: case VT_CY:
2838 if (HAVE_OLEAUT32_I8)
2842 hres = pVarNeg(&v,&vDst);
2844 ok(hres == DISP_E_TYPEMISMATCH || hres == DISP_E_BADVARTYPE,
2845 "VarNeg: expected failure, got 0x%X vt %d|0x%X\n",
2846 hres, vt, ExtraFlags[i]);
2848 ok(hres == S_OK, "VarNeg: expected S_OK, got 0x%X vt %d|0x%X\n",
2849 hres, vt, ExtraFlags[i]);
2853 VARNEG(BOOL,VARIANT_TRUE,I2,1);
2854 VARNEG(BOOL,VARIANT_FALSE,I2,0);
2855 VARNEG(BOOL,1,I2,-1);
2856 VARNEG(UI1,1,I2,-1);
2857 VARNEG(UI1,254,I2,-254);
2858 VARNEG(I2,-32768,I4,32768);
2861 VARNEG(I4,-((int)(~0u >> 1)) - 1,R8,-2147483648u);
2864 if (HAVE_OLEAUT32_I8)
2871 VARNEG(DATE,1,DATE,-1);
2872 VARNEG(DATE,-1,DATE,1);
2875 VARNEG(BSTR,(BSTR)szNumMinus1,R8,1);
2876 VARNEG(BSTR,(BSTR)szNum1,R8,-1);
2878 V_VT(&v) = VT_EMPTY;
2879 hres = pVarNeg(&v,&vDst);
2880 ok(hres == S_OK && V_VT(&vDst) == VT_I2 && V_I2(&vDst) == 0,
2881 "VarNeg: expected 0x0,%d,0 got 0x%X,%d,%d\n", VT_EMPTY,
2882 hres, V_VT(&vDst), V_I2(&vDst));
2885 hres = pVarNeg(&v,&vDst);
2886 ok(hres == S_OK && V_VT(&vDst) == VT_NULL,
2887 "VarNeg: expected 0x0,%d got 0x%X,%d\n", VT_NULL, hres, V_VT(&vDst));
2889 V_VT(&v) = VT_DECIMAL;
2890 S(U(*pdec)).sign = DECIMAL_NEG;
2891 S(U(*pdec)).scale = 0;
2893 S1(U1(*pdec)).Mid32 = 0;
2894 S1(U1(*pdec)).Lo32 = 1;
2895 hres = pVarNeg(&v,&vDst);
2896 ok(hres == S_OK && V_VT(&vDst) == VT_DECIMAL &&
2897 S(U(V_DECIMAL(&vDst))).sign == 0,
2898 "VarNeg: expected 0x0,%d,0x00, got 0x%X,%d,%02x\n", VT_DECIMAL,
2899 hres, V_VT(&vDst), S(U(V_DECIMAL(&vDst))).sign);
2901 S(U(*pdec)).sign = 0;
2902 hres = pVarNeg(&v,&vDst);
2903 ok(hres == S_OK && V_VT(&vDst) == VT_DECIMAL &&
2904 S(U(V_DECIMAL(&vDst))).sign == DECIMAL_NEG,
2905 "VarNeg: expected 0x0,%d,0x7f, got 0x%X,%d,%02x\n", VT_DECIMAL,
2906 hres, V_VT(&vDst), S(U(V_DECIMAL(&vDst))).sign);
2909 pcy->int64 = -10000;
2910 hres = pVarNeg(&v,&vDst);
2911 ok(hres == S_OK && V_VT(&vDst) == VT_CY && V_CY(&vDst).int64 == 10000,
2912 "VarNeg: VT_CY wrong, hres=0x%X\n", hres);
2915 static HRESULT (WINAPI *pVarRound)(LPVARIANT,int,LPVARIANT);
2917 #define VARROUND(vt,val,deci,rvt,rval) V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
2918 memset(&vDst,0,sizeof(vDst)); hres = pVarRound(&v,deci,&vDst); \
2919 ok(hres == S_OK && V_VT(&vDst) == VT_##rvt && V_##rvt(&vDst) == (rval), \
2920 "VarRound: expected 0x0,%d,%d, got 0x%X,%d,%d\n", VT_##rvt, (int)(rval), \
2921 hres, V_VT(&vDst), (int)V_##rvt(&vDst))
2923 #define VARROUNDF(vt,val,deci,rvt,rval) V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
2924 memset(&vDst,0,sizeof(vDst)); hres = pVarRound(&v,deci,&vDst); \
2925 ok(hres == S_OK && V_VT(&vDst) == VT_##rvt && V_##rvt(&vDst) == (rval), \
2926 "VarRound: expected 0x0,%d,%f, got 0x%X,%d,%f\n", VT_##rvt, rval, \
2927 hres, V_VT(&vDst), V_##rvt(&vDst))
2929 static void test_VarRound(void)
2931 /* static const WCHAR szNumMin[] = {'-','1','.','4','5','\0' };
2932 static const WCHAR szNum[] = {'1','.','4','5','\0' }; */
2935 CY *pcy = &V_CY(&v);
2939 /* first check valid integer types */
2940 VARROUND(BOOL,VARIANT_TRUE,0,I2,-1);
2941 VARROUND(BOOL,VARIANT_FALSE,0,I2,0);
2942 VARROUND(BOOL,1,0,I2,1);
2943 VARROUND(UI1,1,0,UI1,1);
2944 VARROUND(UI1,254,0,UI1,254);
2945 VARROUND(I2,-32768,0,I2,-32768);
2946 VARROUND(I2,-1,0,I2,-1);
2947 VARROUND(I2,1,0,I2,1);
2948 VARROUND(I4,-((int)(~0u >> 1)) - 1,0,I4,-((int)(~0u >> 1)) - 1);
2949 VARROUND(I4,-1,0,I4,-1);
2950 VARROUND(I4,1,0,I4,1);
2953 /* MSDN states that rounding of R4/R8 is dependent on the underlying
2954 * bit pattern of the number and so is architecture dependent. In this
2955 * case Wine returns .2 (which is more correct) and Native returns .3
2958 VARROUNDF(R4,1.0,0,R4,1.0);
2959 VARROUNDF(R4,-1.0,0,R4,-1.0);
2960 VARROUNDF(R8,1.0,0,R8,1.0);
2961 VARROUNDF(R8,-1.0,0,R8,-1.0);
2963 /* floating point numbers aren't exactly equal and we can't just
2964 * compare the first few digits.
2966 VARROUNDF(DATE,1.451,1,DATE,1.5);
2967 VARROUNDF(DATE,-1.45,1,DATE,-1.4);
2968 VARROUNDF(BSTR,(BSTR)szNumMin,1,R8,-1.40);
2969 VARROUNDF(BSTR,(BSTR)szNum,1,R8,1.50);
2971 VARROUNDF(R4,1.23456,0,R4,1.0);
2972 VARROUNDF(R4,1.23456,1,R4,1.2);
2973 VARROUNDF(R4,1.23456,2,R4,1.23);
2974 VARROUNDF(R4,1.23456,3,R4,1.235);
2975 VARROUNDF(R4,1.23456,4,R4,1.2346);
2976 VARROUNDF(R4,-1.23456,0,R4,-1.0);
2977 VARROUNDF(R4,-1.23456,1,R4,-1.2);
2978 VARROUNDF(R4,-1.23456,2,R4,-1.23);
2979 VARROUNDF(R4,-1.23456,3,R4,-1.235);
2980 VARROUNDF(R4,-1.23456,4,R4,-1.2346);
2982 VARROUNDF(R8,1.23456,0,R8,1.0);
2983 VARROUNDF(R8,1.23456,1,R8,1.2);
2984 VARROUNDF(R8,1.23456,2,R8,1.23);
2985 VARROUNDF(R8,1.23456,3,R8,1.235);
2986 VARROUNDF(R8,1.23456,4,R8,1.2346);
2987 VARROUNDF(R8,-1.23456,0,R8,-1.0);
2988 VARROUNDF(R8,-1.23456,1,R8,-1.2);
2989 VARROUNDF(R8,-1.23456,2,R8,-1.23);
2990 VARROUNDF(R8,-1.23456,3,R8,-1.235);
2991 VARROUNDF(R8,-1.23456,4,R8,-1.2346);
2995 V_VT(&v) = VT_EMPTY;
2996 hres = pVarRound(&v,0,&vDst);
2997 ok(hres == S_OK && V_VT(&vDst) == VT_I2 && V_I2(&vDst) == 0,
2998 "VarRound: expected 0x0,%d,0 got 0x%X,%d,%d\n", VT_EMPTY,
2999 hres, V_VT(&vDst), V_I2(&vDst));
3002 hres = pVarRound(&v,0,&vDst);
3003 ok(hres == S_OK && V_VT(&vDst) == VT_NULL,
3004 "VarRound: expected 0x0,%d got 0x%X,%d\n", VT_NULL, hres, V_VT(&vDst));
3006 /* not yet implemented so no use testing yet
3008 DECIMAL *pdec = &V_DECIMAL(&v);
3009 V_VT(&v) = VT_DECIMAL;
3010 S(U(*pdec)).sign = DECIMAL_NEG;
3011 S(U(*pdec)).scale = 0;
3013 S1(U1(*pdec)).Mid32 = 0;
3014 S1(U1(*pdec)).Lo32 = 1;
3015 hres = pVarRound(&v,0,&vDst);
3016 ok(hres == S_OK && V_VT(&vDst) == VT_DECIMAL &&
3017 S(U(V_DECIMAL(&vDst))).sign == 0,
3018 "VarRound: expected 0x0,%d,0x00, got 0x%X,%d,%02x\n", VT_DECIMAL,
3019 hres, V_VT(&vDst), S(U(V_DECIMAL(&vDst))).sign);
3021 S(U(*pdec)).sign = 0;
3022 hres = pVarRound(&v,0,&vDst);
3023 ok(hres == S_OK && V_VT(&vDst) == VT_DECIMAL &&
3024 S(U(V_DECIMAL(&vDst))).sign == DECIMAL_NEG,
3025 "VarRound: expected 0x0,%d,0x7f, got 0x%X,%d,%02x\n", VT_DECIMAL,
3026 hres, V_VT(&vDst), S(U(V_DECIMAL(&vDst))).sign);
3032 hres = pVarRound(&v,0,&vDst);
3033 ok(hres == S_OK && V_VT(&vDst) == VT_CY && V_CY(&vDst).int64 == 10000,
3034 "VarRound: VT_CY wrong, hres=0x%X\n", hres);
3038 static HRESULT (WINAPI *pVarXor)(LPVARIANT,LPVARIANT,LPVARIANT);
3040 static const char *szVarXorFail = "VarXor(%d,%d): expected 0x0,%d,%d, got 0x%X,%d,%d\n";
3041 #define VARXOR(vt1,val1,vt2,val2,rvt,rval) \
3042 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
3043 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
3044 memset(&result,0,sizeof(result)); hres = pVarXor(&left,&right,&result); \
3045 ok(hres == S_OK && V_VT(&result) == VT_##rvt && V_##rvt(&result) == (rval), \
3046 szVarXorFail, VT_##vt1, VT_##vt2, \
3047 VT_##rvt, (int)(rval), hres, V_VT(&result), (int)V_##rvt(&result)); \
3048 ok(V_VT(&left) == VT_##vt1 && V_##vt1(&left) == val1 && \
3049 V_VT(&right) == VT_##vt2 && V_##vt2(&right) == val2, \
3050 "VarXor(%d,%d): Modified input arguments\n",VT_##vt1,VT_##vt2)
3051 #define VARXORCY(vt1,val1,val2,rvt,rval) \
3052 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
3053 V_VT(&right) = VT_CY; V_CY(&right).int64 = val2; \
3054 memset(&result,0,sizeof(result)); hres = pVarXor(&left,&right,&result); \
3055 ok(hres == S_OK && V_VT(&result) == VT_##rvt && V_##rvt(&result) == (rval), \
3056 "VarXor(%d,%d): expected 0x0,%d,%d, got 0x%X,%d,%d\n", VT_##vt1, VT_CY, \
3057 VT_##rvt, (int)(rval), hres, V_VT(&result), (int)V_##rvt(&result)); \
3058 ok(V_VT(&left) == VT_##vt1 && V_##vt1(&left) == val1 && \
3059 V_VT(&right) == VT_CY && V_CY(&right).int64 == val2, \
3060 "VarXor(%d,%d): Modified input arguments\n",VT_##vt1,VT_CY)
3062 static void test_VarXor(void)
3064 static const WCHAR szFalse[] = { '#','F','A','L','S','E','#','\0' };
3065 static const WCHAR szTrue[] = { '#','T','R','U','E','#','\0' };
3066 VARIANT left, right, result;
3073 /* Test all possible flag/vt combinations & the resulting vt type */
3074 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
3076 VARTYPE leftvt, rightvt, resvt;
3078 for (leftvt = 0; leftvt <= VT_BSTR_BLOB; leftvt++)
3083 for (rightvt = 0; rightvt <= VT_BSTR_BLOB; rightvt++)
3089 if (leftvt == VT_BSTR || rightvt == VT_BSTR ||
3090 leftvt == VT_DISPATCH || rightvt == VT_DISPATCH ||
3091 leftvt == VT_UNKNOWN || rightvt == VT_UNKNOWN)
3094 memset(&left, 0, sizeof(left));
3095 memset(&right, 0, sizeof(right));
3096 V_VT(&left) = leftvt | ExtraFlags[i];
3097 V_VT(&right) = rightvt | ExtraFlags[i];
3098 V_VT(&result) = VT_EMPTY;
3101 if (ExtraFlags[i] & VT_ARRAY || ExtraFlags[i] & VT_BYREF ||
3102 !IsValidVariantClearVT(leftvt, ExtraFlags[i]) ||
3103 !IsValidVariantClearVT(rightvt, ExtraFlags[i]) ||
3104 leftvt == VT_CLSID || rightvt == VT_CLSID ||
3105 leftvt == VT_RECORD || rightvt == VT_RECORD ||
3106 leftvt == VT_VARIANT || rightvt == VT_VARIANT ||
3107 leftvt == VT_ERROR || rightvt == VT_ERROR)
3111 if (leftvt == VT_EMPTY || rightvt == VT_EMPTY)
3113 if (leftvt == rightvt ||
3114 leftvt == VT_I2 || rightvt == VT_I2 ||
3115 leftvt == VT_UI1 || rightvt == VT_UI1 ||
3116 leftvt == VT_BOOL || rightvt == VT_BOOL)
3118 else if (leftvt == VT_NULL || rightvt == VT_NULL)
3120 else if (leftvt == VT_I8 || rightvt == VT_I8)
3123 else if (leftvt == VT_NULL || rightvt == VT_NULL)
3127 else if (leftvt == VT_UI1 || rightvt == VT_UI1)
3129 if (leftvt == rightvt)
3131 else if (leftvt == rightvt ||
3132 leftvt == VT_I2 || rightvt == VT_I2 ||
3133 leftvt == VT_BOOL || rightvt == VT_BOOL)
3137 else if (leftvt == VT_I8 || rightvt == VT_I8)
3140 else if (leftvt == VT_I2 || rightvt == VT_I2)
3142 if (leftvt == rightvt ||
3143 leftvt == VT_BOOL || rightvt == VT_BOOL)
3145 else if (leftvt == VT_I8 || rightvt == VT_I8)
3148 else if (leftvt == VT_BOOL && rightvt == VT_BOOL)
3152 else if (leftvt == VT_I8 || rightvt == VT_I8)
3154 if (leftvt == VT_INT || rightvt == VT_INT)
3159 hres = pVarXor(&left, &right, &result);
3161 ok(hres == DISP_E_TYPEMISMATCH || hres == DISP_E_BADVARTYPE,
3162 "VarXor: %d|0x%X, %d|0x%X: Expected failure, got 0x%X vt %d\n",
3163 leftvt, ExtraFlags[i], rightvt, ExtraFlags[i], hres,
3166 ok(hres == S_OK && V_VT(&result) == resvt,
3167 "VarXor: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%X vt %d\n",
3168 leftvt, ExtraFlags[i], rightvt, ExtraFlags[i], resvt, hres,
3174 /* Test returned values
3175 * FIXME: Test VT_DECIMAL/VT_DISPATCH
3177 VARXOR(EMPTY,0,EMPTY,0,I2,0);
3178 VARXOR(EMPTY,1,EMPTY,0,I2,0);
3179 VARXOR(EMPTY,0,NULL,0,NULL,0);
3180 VARXOR(EMPTY,0,I1,0,I4,0);
3181 VARXOR(EMPTY,0,I1,1,I4,1);
3182 VARXOR(EMPTY,0,UI1,0,I2,0);
3183 VARXOR(EMPTY,0,UI1,1,I2,1);
3184 VARXOR(EMPTY,0,I2,0,I2,0);
3185 VARXOR(EMPTY,0,I2,1,I2,1);
3186 VARXOR(EMPTY,0,UI2,0,I4,0);
3187 VARXOR(EMPTY,0,UI2,1,I4,1);
3188 VARXOR(EMPTY,0,I4,0,I4,0);
3189 VARXOR(EMPTY,0,I4,1,I4,1);
3190 VARXOR(EMPTY,0,UI4,0,I4,0);
3191 VARXOR(EMPTY,0,UI4,1,I4,1);
3192 if (HAVE_OLEAUT32_I8)
3194 VARXOR(EMPTY,0,I8,0,I8,0);
3195 VARXOR(EMPTY,0,I8,1,I8,1);
3196 VARXOR(EMPTY,0,UI8,0,I4,0);
3197 VARXOR(EMPTY,0,UI8,1,I4,1);
3199 VARXOR(EMPTY,0,INT,0,I4,0);
3200 VARXOR(EMPTY,0,INT,1,I4,1);
3201 VARXOR(EMPTY,0,UINT,0,I4,0);
3202 VARXOR(EMPTY,0,UINT,1,I4,1);
3203 VARXOR(EMPTY,0,BOOL,0,I2,0);
3204 VARXOR(EMPTY,0,BOOL,1,I2,1);
3205 VARXOR(EMPTY,0,R4,0,I4,0);
3206 VARXOR(EMPTY,0,R4,1,I4,1);
3207 VARXOR(EMPTY,0,R8,0,I4,0);
3208 VARXOR(EMPTY,0,R8,1,I4,1);
3209 rbstr = SysAllocString(szFalse);
3210 VARXOR(EMPTY,0,BSTR,rbstr,I2,0);
3211 rbstr = SysAllocString(szTrue);
3212 VARXOR(EMPTY,0,BSTR,rbstr,I2,-1);
3213 VARXORCY(EMPTY,0,10000,I4,1);
3215 /* NULL OR 0 = NULL. NULL OR n = n */
3216 VARXOR(NULL,0,NULL,0,NULL,0);
3217 VARXOR(NULL,1,NULL,0,NULL,0);
3218 VARXOR(NULL,0,I1,0,NULL,0);
3219 VARXOR(NULL,0,I1,1,NULL,0);
3220 VARXOR(NULL,0,UI1,0,NULL,0);
3221 VARXOR(NULL,0,UI1,1,NULL,0);
3222 VARXOR(NULL,0,I2,0,NULL,0);
3223 VARXOR(NULL,0,I2,1,NULL,0);
3224 VARXOR(NULL,0,UI2,0,NULL,0);
3225 VARXOR(NULL,0,UI2,1,NULL,0);
3226 VARXOR(NULL,0,I4,0,NULL,0);
3227 VARXOR(NULL,0,I4,1,NULL,0);
3228 VARXOR(NULL,0,UI4,0,NULL,0);
3229 VARXOR(NULL,0,UI4,1,NULL,0);
3230 if (HAVE_OLEAUT32_I8)
3232 VARXOR(NULL,0,I8,0,NULL,0);
3233 VARXOR(NULL,0,I8,1,NULL,0);
3234 VARXOR(NULL,0,UI8,0,NULL,0);
3235 VARXOR(NULL,0,UI8,1,NULL,0);
3237 VARXOR(NULL,0,INT,0,NULL,0);
3238 VARXOR(NULL,0,INT,1,NULL,0);
3239 VARXOR(NULL,0,UINT,0,NULL,0);
3240 VARXOR(NULL,0,UINT,1,NULL,0);
3241 VARXOR(NULL,0,BOOL,0,NULL,0);
3242 VARXOR(NULL,0,BOOL,1,NULL,0);
3243 VARXOR(NULL,0,R4,0,NULL,0);
3244 VARXOR(NULL,0,R4,1,NULL,0);
3245 VARXOR(NULL,0,R8,0,NULL,0);
3246 VARXOR(NULL,0,R8,1,NULL,0);
3247 rbstr = SysAllocString(szFalse);
3248 VARXOR(NULL,0,BSTR,rbstr,NULL,0);
3249 rbstr = SysAllocString(szTrue);
3250 VARXOR(NULL,0,BSTR,rbstr,NULL,0);
3251 VARXORCY(NULL,0,10000,NULL,0);
3252 VARXORCY(NULL,0,0,NULL,0);
3254 VARXOR(BOOL,VARIANT_TRUE,BOOL,VARIANT_TRUE,BOOL,VARIANT_FALSE);
3255 VARXOR(BOOL,VARIANT_TRUE,BOOL,VARIANT_FALSE,BOOL,VARIANT_TRUE);
3256 VARXOR(BOOL,VARIANT_FALSE,BOOL,VARIANT_TRUE,BOOL,VARIANT_TRUE);
3257 VARXOR(BOOL,VARIANT_FALSE,BOOL,VARIANT_FALSE,BOOL,VARIANT_FALSE);
3258 /* Assume x,y & y,x are the same from now on to reduce the number of tests */
3259 VARXOR(BOOL,VARIANT_TRUE,I1,-1,I4,0);
3260 VARXOR(BOOL,VARIANT_TRUE,I1,0,I4,-1);
3261 VARXOR(BOOL,VARIANT_FALSE,I1,0,I4,0);
3262 VARXOR(BOOL,VARIANT_TRUE,UI1,255,I2,-256);
3263 VARXOR(BOOL,VARIANT_TRUE,UI1,0,I2,-1);
3264 VARXOR(BOOL,VARIANT_FALSE,UI1,0,I2,0);
3265 VARXOR(BOOL,VARIANT_TRUE,I2,-1,I2,0);
3266 VARXOR(BOOL,VARIANT_TRUE,I2,0,I2,-1);
3267 VARXOR(BOOL,VARIANT_FALSE,I2,0,I2,0);
3268 VARXOR(BOOL,VARIANT_TRUE,UI2,65535,I4,-65536);
3269 VARXOR(BOOL,VARIANT_TRUE,UI2,0,I4,-1);
3270 VARXOR(BOOL,VARIANT_FALSE,UI2,0,I4,0);
3271 VARXOR(BOOL,VARIANT_TRUE,I4,-1,I4,0);
3272 VARXOR(BOOL,VARIANT_TRUE,I4,0,I4,-1);
3273 VARXOR(BOOL,VARIANT_FALSE,I4,0,I4,0);
3274 VARXOR(BOOL,VARIANT_TRUE,UI4,0xffffffff,I4,0);
3275 VARXOR(BOOL,VARIANT_TRUE,UI4,0,I4,-1);
3276 VARXOR(BOOL,VARIANT_FALSE,UI4,0,I4,0);
3277 VARXOR(BOOL,VARIANT_TRUE,R4,-1,I4,0);
3278 VARXOR(BOOL,VARIANT_TRUE,R4,0,I4,-1);
3279 VARXOR(BOOL,VARIANT_FALSE,R4,0,I4,0);
3280 VARXOR(BOOL,VARIANT_TRUE,R8,-1,I4,0);
3281 VARXOR(BOOL,VARIANT_TRUE,R8,0,I4,-1);
3282 VARXOR(BOOL,VARIANT_FALSE,R8,0,I4,0);
3283 VARXOR(BOOL,VARIANT_TRUE,DATE,-1,I4,0);
3284 VARXOR(BOOL,VARIANT_TRUE,DATE,0,I4,-1);
3285 VARXOR(BOOL,VARIANT_FALSE,DATE,0,I4,0);
3286 if (HAVE_OLEAUT32_I8)
3288 VARXOR(BOOL,VARIANT_TRUE,I8,-1,I8,0);
3289 VARXOR(BOOL,VARIANT_TRUE,I8,0,I8,-1);
3290 VARXOR(BOOL,VARIANT_FALSE,I8,0,I8,0);
3291 /* This returns DISP_E_OVERFLOW which indicates that a conversion
3292 * to I4 is performed.
3294 /* VARXOR(BOOL,VARIANT_TRUE,UI8,-1,I4,-1); */
3295 VARXOR(BOOL,VARIANT_TRUE,UI8,0,I4,-1);
3296 VARXOR(BOOL,VARIANT_FALSE,UI8,0,I4,0);
3298 VARXOR(BOOL,VARIANT_TRUE,INT,-1,I4,0);
3299 VARXOR(BOOL,VARIANT_TRUE,INT,0,I4,-1);
3300 VARXOR(BOOL,VARIANT_FALSE,INT,0,I4,0);
3301 VARXOR(BOOL,VARIANT_TRUE,UINT,0xffffffff,I4,0);
3302 VARXOR(BOOL,VARIANT_TRUE,UINT,0,I4,-1);
3303 VARXOR(BOOL,VARIANT_FALSE,UINT,0,I4,0);
3304 rbstr = SysAllocString(szFalse);
3305 VARXOR(BOOL,VARIANT_FALSE,BSTR,rbstr,BOOL,VARIANT_FALSE);
3306 VARXOR(BOOL,VARIANT_TRUE,BSTR,rbstr,BOOL,VARIANT_TRUE);
3307 rbstr = SysAllocString(szTrue);
3308 VARXOR(BOOL,VARIANT_FALSE,BSTR,rbstr,BOOL,VARIANT_TRUE);
3309 VARXOR(BOOL,VARIANT_TRUE,BSTR,rbstr,BOOL,VARIANT_FALSE);
3310 VARXORCY(BOOL,VARIANT_TRUE,10000,I4,-2);
3311 VARXORCY(BOOL,VARIANT_TRUE,0,I4,-1);
3312 VARXORCY(BOOL,VARIANT_FALSE,0,I4,0);
3314 VARXOR(I1,-1,I1,-1,I4,0);
3315 VARXOR(I1,-1,I1,0,I4,-1);
3316 VARXOR(I1,0,I1,0,I4,0);
3317 VARXOR(I1,-1,UI1,255,I4,-256);
3318 VARXOR(I1,-1,UI1,0,I4,-1);
3319 VARXOR(I1,0,UI1,0,I4,0);
3320 VARXOR(I1,-1,I2,-1,I4,0);
3321 VARXOR(I1,-1,I2,0,I4,-1);
3322 VARXOR(I1,0,I2,0,I4,0);
3323 VARXOR(I1,-1,UI2,65535,I4,-65536);
3324 VARXOR(I1,-1,UI2,0,I4,-1);
3325 VARXOR(I1,0,UI2,0,I4,0);
3326 VARXOR(I1,-1,I4,-1,I4,0);
3327 VARXOR(I1,-1,I4,0,I4,-1);
3328 VARXOR(I1,0,I4,0,I4,0);
3329 VARXOR(I1,-1,UI4,0xffffffff,I4,0);
3330 VARXOR(I1,-1,UI4,0,I4,-1);
3331 VARXOR(I1,0,UI4,0,I4,0);
3332 VARXOR(I1,-1,R4,-1,I4,0);
3333 VARXOR(I1,-1,R4,0,I4,-1);
3334 VARXOR(I1,0,R4,0,I4,0);
3335 VARXOR(I1,-1,R8,-1,I4,0);
3336 VARXOR(I1,-1,R8,0,I4,-1);
3337 VARXOR(I1,0,R8,0,I4,0);
3338 VARXOR(I1,-1,DATE,-1,I4,0);
3339 VARXOR(I1,-1,DATE,0,I4,-1);
3340 VARXOR(I1,0,DATE,0,I4,0);
3341 if (HAVE_OLEAUT32_I8)
3343 VARXOR(I1,-1,I8,-1,I8,0);
3344 VARXOR(I1,-1,I8,0,I8,-1);
3345 VARXOR(I1,0,I8,0,I8,0);
3346 VARXOR(I1,-1,UI8,0,I4,-1);
3347 VARXOR(I1,0,UI8,0,I4,0);
3349 VARXOR(I1,-1,INT,-1,I4,0);
3350 VARXOR(I1,-1,INT,0,I4,-1);
3351 VARXOR(I1,0,INT,0,I4,0);
3352 VARXOR(I1,-1,UINT,0xffffffff,I4,0);
3353 VARXOR(I1,-1,UINT,0,I4,-1);
3354 VARXOR(I1,0,UINT,0,I4,0);
3355 rbstr = SysAllocString(szFalse);
3356 VARXOR(I1,0,BSTR,rbstr,I4,0);
3357 VARXOR(I1,-1,BSTR,rbstr,I4,-1);
3358 rbstr = SysAllocString(szTrue);
3359 VARXOR(I1,0,BSTR,rbstr,I4,-1);
3360 VARXOR(I1,-1,BSTR,rbstr,I4,0);
3361 VARXORCY(I1,-1,10000,I4,-2);
3362 VARXORCY(I1,-1,0,I4,-1);
3363 VARXORCY(I1,0,0,I4,0);
3365 VARXOR(UI1,255,UI1,255,UI1,0);
3366 VARXOR(UI1,255,UI1,0,UI1,255);
3367 VARXOR(UI1,0,UI1,0,UI1,0);
3368 VARXOR(UI1,255,I2,-1,I2,-256);
3369 VARXOR(UI1,255,I2,0,I2,255);
3370 VARXOR(UI1,0,I2,0,I2,0);
3371 VARXOR(UI1,255,UI2,65535,I4,65280);
3372 VARXOR(UI1,255,UI2,0,I4,255);
3373 VARXOR(UI1,0,UI2,0,I4,0);
3374 VARXOR(UI1,255,I4,-1,I4,-256);
3375 VARXOR(UI1,255,I4,0,I4,255);
3376 VARXOR(UI1,0,I4,0,I4,0);
3377 VARXOR(UI1,255,UI4,0xffffffff,I4,-256);
3378 VARXOR(UI1,255,UI4,0,I4,255);
3379 VARXOR(UI1,0,UI4,0,I4,0);
3380 VARXOR(UI1,255,R4,-1,I4,-256);
3381 VARXOR(UI1,255,R4,0,I4,255);
3382 VARXOR(UI1,0,R4,0,I4,0);
3383 VARXOR(UI1,255,R8,-1,I4,-256);
3384 VARXOR(UI1,255,R8,0,I4,255);
3385 VARXOR(UI1,0,R8,0,I4,0);
3386 VARXOR(UI1,255,DATE,-1,I4,-256);
3387 VARXOR(UI1,255,DATE,0,I4,255);
3388 VARXOR(UI1,0,DATE,0,I4,0);
3389 if (HAVE_OLEAUT32_I8)
3391 VARXOR(UI1,255,I8,-1,I8,-256);
3392 VARXOR(UI1,255,I8,0,I8,255);
3393 VARXOR(UI1,0,I8,0,I8,0);
3394 VARXOR(UI1,255,UI8,0,I4,255);
3395 VARXOR(UI1,0,UI8,0,I4,0);
3397 VARXOR(UI1,255,INT,-1,I4,-256);
3398 VARXOR(UI1,255,INT,0,I4,255);
3399 VARXOR(UI1,0,INT,0,I4,0);
3400 VARXOR(UI1,255,UINT,0xffffffff,I4,-256);
3401 VARXOR(UI1,255,UINT,0,I4,255);
3402 VARXOR(UI1,0,UINT,0,I4,0);
3403 rbstr = SysAllocString(szFalse);
3404 VARXOR(UI1,0,BSTR,rbstr,I2,0);
3405 VARXOR(UI1,255,BSTR,rbstr,I2,255);
3406 rbstr = SysAllocString(szTrue);
3407 VARXOR(UI1,0,BSTR,rbstr,I2,-1);
3408 VARXOR(UI1,255,BSTR,rbstr,I2,-256);
3409 VARXORCY(UI1,255,10000,I4,254);
3410 VARXORCY(UI1,255,0,I4,255);
3411 VARXORCY(UI1,0,0,I4,0);
3413 VARXOR(I2,-1,I2,-1,I2,0);
3414 VARXOR(I2,-1,I2,0,I2,-1);
3415 VARXOR(I2,0,I2,0,I2,0);
3416 VARXOR(I2,-1,UI2,65535,I4,-65536);
3417 VARXOR(I2,-1,UI2,0,I4,-1);
3418 VARXOR(I2,0,UI2,0,I4,0);
3419 VARXOR(I2,-1,I4,-1,I4,0);
3420 VARXOR(I2,-1,I4,0,I4,-1);
3421 VARXOR(I2,0,I4,0,I4,0);
3422 VARXOR(I2,-1,UI4,0xffffffff,I4,0);
3423 VARXOR(I2,-1,UI4,0,I4,-1);
3424 VARXOR(I2,0,UI4,0,I4,0);
3425 VARXOR(I2,-1,R4,-1,I4,0);
3426 VARXOR(I2,-1,R4,0,I4,-1);
3427 VARXOR(I2,0,R4,0,I4,0);
3428 VARXOR(I2,-1,R8,-1,I4,0);
3429 VARXOR(I2,-1,R8,0,I4,-1);
3430 VARXOR(I2,0,R8,0,I4,0);
3431 VARXOR(I2,-1,DATE,-1,I4,0);
3432 VARXOR(I2,-1,DATE,0,I4,-1);
3433 VARXOR(I2,0,DATE,0,I4,0);
3434 if (HAVE_OLEAUT32_I8)
3436 VARXOR(I2,-1,I8,-1,I8,0);
3437 VARXOR(I2,-1,I8,0,I8,-1);
3438 VARXOR(I2,0,I8,0,I8,0);
3439 VARXOR(I2,-1,UI8,0,I4,-1);
3440 VARXOR(I2,0,UI8,0,I4,0);
3442 VARXOR(I2,-1,INT,-1,I4,0);
3443 VARXOR(I2,-1,INT,0,I4,-1);
3444 VARXOR(I2,0,INT,0,I4,0);
3445 VARXOR(I2,-1,UINT,0xffffffff,I4,0);
3446 VARXOR(I2,-1,UINT,0,I4,-1);
3447 VARXOR(I2,0,UINT,0,I4,0);
3448 rbstr = SysAllocString(szFalse);
3449 VARXOR(I2,0,BSTR,rbstr,I2,0);
3450 VARXOR(I2,-1,BSTR,rbstr,I2,-1);
3451 rbstr = SysAllocString(szTrue);
3452 VARXOR(I2,0,BSTR,rbstr,I2,-1);
3453 VARXOR(I2,-1,BSTR,rbstr,I2,0);
3454 VARXORCY(I2,-1,10000,I4,-2);
3455 VARXORCY(I2,-1,0,I4,-1);
3456 VARXORCY(I2,0,0,I4,0);
3458 VARXOR(UI2,65535,UI2,65535,I4,0);
3459 VARXOR(UI2,65535,UI2,0,I4,65535);
3460 VARXOR(UI2,0,UI2,0,I4,0);
3461 VARXOR(UI2,65535,I4,-1,I4,-65536);
3462 VARXOR(UI2,65535,I4,0,I4,65535);
3463 VARXOR(UI2,0,I4,0,I4,0);
3464 VARXOR(UI2,65535,UI4,0xffffffff,I4,-65536);
3465 VARXOR(UI2,65535,UI4,0,I4,65535);
3466 VARXOR(UI2,0,UI4,0,I4,0);
3467 VARXOR(UI2,65535,R4,-1,I4,-65536);
3468 VARXOR(UI2,65535,R4,0,I4,65535);
3469 VARXOR(UI2,0,R4,0,I4,0);
3470 VARXOR(UI2,65535,R8,-1,I4,-65536);
3471 VARXOR(UI2,65535,R8,0,I4,65535);
3472 VARXOR(UI2,0,R8,0,I4,0);
3473 VARXOR(UI2,65535,DATE,-1,I4,-65536);
3474 VARXOR(UI2,65535,DATE,0,I4,65535);
3475 VARXOR(UI2,0,DATE,0,I4,0);
3476 if (HAVE_OLEAUT32_I8)
3478 VARXOR(UI2,65535,I8,-1,I8,-65536);
3479 VARXOR(UI2,65535,I8,0,I8,65535);
3480 VARXOR(UI2,0,I8,0,I8,0);
3481 VARXOR(UI2,65535,UI8,0,I4,65535);
3482 VARXOR(UI2,0,UI8,0,I4,0);
3484 VARXOR(UI2,65535,INT,-1,I4,-65536);
3485 VARXOR(UI2,65535,INT,0,I4,65535);
3486 VARXOR(UI2,0,INT,0,I4,0);
3487 VARXOR(UI2,65535,UINT,0xffffffff,I4,-65536);
3488 VARXOR(UI2,65535,UINT,0,I4,65535);
3489 VARXOR(UI2,0,UINT,0,I4,0);
3490 rbstr = SysAllocString(szFalse);
3491 VARXOR(UI2,0,BSTR,rbstr,I4,0);
3492 VARXOR(UI2,65535,BSTR,rbstr,I4,65535);
3493 rbstr = SysAllocString(szTrue);
3494 VARXOR(UI2,0,BSTR,rbstr,I4,-1);
3495 VARXOR(UI2,65535,BSTR,rbstr,I4,-65536);
3496 VARXORCY(UI2,65535,10000,I4,65534);
3497 VARXORCY(UI2,65535,0,I4,65535);
3498 VARXORCY(UI2,0,0,I4,0);
3500 VARXOR(I4,-1,I4,-1,I4,0);
3501 VARXOR(I4,-1,I4,0,I4,-1);
3502 VARXOR(I4,0,I4,0,I4,0);
3503 VARXOR(I4,-1,UI4,0xffffffff,I4,0);
3504 VARXOR(I4,-1,UI4,0,I4,-1);
3505 VARXOR(I4,0,UI4,0,I4,0);
3506 VARXOR(I4,-1,R4,-1,I4,0);
3507 VARXOR(I4,-1,R4,0,I4,-1);
3508 VARXOR(I4,0,R4,0,I4,0);
3509 VARXOR(I4,-1,R8,-1,I4,0);
3510 VARXOR(I4,-1,R8,0,I4,-1);
3511 VARXOR(I4,0,R8,0,I4,0);
3512 VARXOR(I4,-1,DATE,-1,I4,0);
3513 VARXOR(I4,-1,DATE,0,I4,-1);
3514 VARXOR(I4,0,DATE,0,I4,0);
3515 if (HAVE_OLEAUT32_I8)
3517 VARXOR(I4,-1,I8,-1,I8,0);
3518 VARXOR(I4,-1,I8,0,I8,-1);
3519 VARXOR(I4,0,I8,0,I8,0);
3520 VARXOR(I4,-1,UI8,0,I4,-1);
3521 VARXOR(I4,0,UI8,0,I4,0);
3523 VARXOR(I4,-1,INT,-1,I4,0);
3524 VARXOR(I4,-1,INT,0,I4,-1);
3525 VARXOR(I4,0,INT,0,I4,0);
3526 VARXOR(I4,-1,UINT,0xffffffff,I4,0);
3527 VARXOR(I4,-1,UINT,0,I4,-1);
3528 VARXOR(I4,0,UINT,0,I4,0);
3529 rbstr = SysAllocString(szFalse);
3530 VARXOR(I4,0,BSTR,rbstr,I4,0);
3531 VARXOR(I4,-1,BSTR,rbstr,I4,-1);
3532 rbstr = SysAllocString(szTrue);
3533 VARXOR(I4,0,BSTR,rbstr,I4,-1);
3534 VARXOR(I4,-1,BSTR,rbstr,I4,0);
3535 VARXORCY(I4,-1,10000,I4,-2);
3536 VARXORCY(I4,-1,0,I4,-1);
3537 VARXORCY(I4,0,0,I4,0);
3539 VARXOR(UI4,0xffffffff,UI4,0xffffffff,I4,0);
3540 VARXOR(UI4,0xffffffff,UI4,0,I4,-1);
3541 VARXOR(UI4,0,UI4,0,I4,0);
3542 VARXOR(UI4,0xffffffff,R4,-1,I4,0);
3543 VARXOR(UI4,0xffffffff,R4,0,I4,-1);
3544 VARXOR(UI4,0,R4,0,I4,0);
3545 VARXOR(UI4,0xffffffff,R8,-1,I4,0);
3546 VARXOR(UI4,0xffffffff,R8,0,I4,-1);
3547 VARXOR(UI4,0,R8,0,I4,0);
3548 VARXOR(UI4,0xffffffff,DATE,-1,I4,0);
3549 VARXOR(UI4,0xffffffff,DATE,0,I4,-1);
3550 VARXOR(UI4,0,DATE,0,I4,0);
3551 if (HAVE_OLEAUT32_I8)
3553 VARXOR(UI4,0xffffffff,I8,0,I8,0xffffffff);
3554 VARXOR(UI4,VARIANT_FALSE,I8,VARIANT_FALSE,I8,0);
3555 VARXOR(UI4,0,I8,0,I8,0);
3556 VARXOR(UI4,0xffffffff,UI8,0,I4,-1);
3557 VARXOR(UI4,0,UI8,0,I4,0);
3559 VARXOR(UI4,0xffffffff,INT,-1,I4,0);
3560 VARXOR(UI4,0xffffffff,INT,0,I4,-1);
3561 VARXOR(UI4,0,INT,0,I4,0);
3562 VARXOR(UI4,0xffffffff,UINT,0xffffffff,I4,0);
3563 VARXOR(UI4,0xffffffff,UINT,0,I4,-1);
3564 VARXOR(UI4,0,UINT,0,I4,0);
3565 rbstr = SysAllocString(szFalse);
3566 VARXOR(UI4,0,BSTR,rbstr,I4,0);
3567 VARXOR(UI4,0xffffffff,BSTR,rbstr,I4,-1);
3568 rbstr = SysAllocString(szTrue);
3569 VARXOR(UI4,0,BSTR,rbstr,I4,-1);
3570 VARXOR(UI4,0xffffffff,BSTR,rbstr,I4,0);
3571 VARXORCY(UI4,0xffffffff,10000,I4,-2);
3572 VARXORCY(UI4,0xffffffff,0,I4,-1);
3573 VARXORCY(UI4,0,0,I4,0);
3575 VARXOR(R4,-1,R4,-1,I4,0);
3576 VARXOR(R4,-1,R4,0,I4,-1);
3577 VARXOR(R4,0,R4,0,I4,0);
3578 VARXOR(R4,-1,R8,-1,I4,0);
3579 VARXOR(R4,-1,R8,0,I4,-1);
3580 VARXOR(R4,0,R8,0,I4,0);
3581 VARXOR(R4,-1,DATE,-1,I4,0);
3582 VARXOR(R4,-1,DATE,0,I4,-1);
3583 VARXOR(R4,0,DATE,0,I4,0);
3584 if (HAVE_OLEAUT32_I8)
3586 VARXOR(R4,-1,I8,-1,I8,0);
3587 VARXOR(R4,-1,I8,0,I8,-1);
3588 VARXOR(R4,0,I8,0,I8,0);
3589 VARXOR(R4,-1,UI8,0,I4,-1);
3590 VARXOR(R4,0,UI8,0,I4,0);
3592 VARXOR(R4,-1,INT,-1,I4,0);
3593 VARXOR(R4,-1,INT,0,I4,-1);
3594 VARXOR(R4,0,INT,0,I4,0);
3595 VARXOR(R4,-1,UINT,0xffffffff,I4,0);
3596 VARXOR(R4,-1,UINT,0,I4,-1);
3597 VARXOR(R4,0,UINT,0,I4,0);
3598 rbstr = SysAllocString(szFalse);
3599 VARXOR(R4,0,BSTR,rbstr,I4,0);
3600 VARXOR(R4,-1,BSTR,rbstr,I4,-1);
3601 rbstr = SysAllocString(szTrue);
3602 VARXOR(R4,0,BSTR,rbstr,I4,-1);
3603 VARXOR(R4,-1,BSTR,rbstr,I4,0);
3604 VARXORCY(R4,-1,10000,I4,-2);
3605 VARXORCY(R4,-1,0,I4,-1);
3606 VARXORCY(R4,0,0,I4,0);
3608 VARXOR(R8,-1,R8,-1,I4,0);
3609 VARXOR(R8,-1,R8,0,I4,-1);
3610 VARXOR(R8,0,R8,0,I4,0);
3611 VARXOR(R8,-1,DATE,-1,I4,0);
3612 VARXOR(R8,-1,DATE,0,I4,-1);
3613 VARXOR(R8,0,DATE,0,I4,0);
3614 if (HAVE_OLEAUT32_I8)
3616 VARXOR(R8,-1,I8,-1,I8,0);
3617 VARXOR(R8,-1,I8,0,I8,-1);
3618 VARXOR(R8,0,I8,0,I8,0);
3619 VARXOR(R8,-1,UI8,0,I4,-1);
3620 VARXOR(R8,0,UI8,0,I4,0);
3622 VARXOR(R8,-1,INT,-1,I4,0);
3623 VARXOR(R8,-1,INT,0,I4,-1);
3624 VARXOR(R8,0,INT,0,I4,0);
3625 VARXOR(R8,-1,UINT,0xffffffff,I4,0);
3626 VARXOR(R8,-1,UINT,0,I4,-1);
3627 VARXOR(R8,0,UINT,0,I4,0);
3628 rbstr = SysAllocString(szFalse);
3629 VARXOR(R8,0,BSTR,rbstr,I4,0);
3630 VARXOR(R8,-1,BSTR,rbstr,I4,-1);
3631 rbstr = SysAllocString(szTrue);
3632 VARXOR(R8,0,BSTR,rbstr,I4,-1);
3633 VARXOR(R8,-1,BSTR,rbstr,I4,0);
3634 VARXORCY(R8,-1,10000,I4,-2);
3635 VARXORCY(R8,-1,0,I4,-1);
3636 VARXORCY(R8,0,0,I4,0);
3638 VARXOR(DATE,-1,DATE,-1,I4,0);
3639 VARXOR(DATE,-1,DATE,0,I4,-1);
3640 VARXOR(DATE,0,DATE,0,I4,0);
3641 if (HAVE_OLEAUT32_I8)
3643 VARXOR(DATE,-1,I8,-1,I8,0);
3644 VARXOR(DATE,-1,I8,0,I8,-1);
3645 VARXOR(DATE,0,I8,0,I8,0);
3646 VARXOR(DATE,-1,UI8,0,I4,-1);
3647 VARXOR(DATE,0,UI8,0,I4,0);
3649 VARXOR(DATE,-1,INT,-1,I4,0);
3650 VARXOR(DATE,-1,INT,0,I4,-1);
3651 VARXOR(DATE,0,INT,0,I4,0);
3652 VARXOR(DATE,-1,UINT,0xffffffff,I4,0);
3653 VARXOR(DATE,-1,UINT,0,I4,-1);
3654 VARXOR(DATE,0,UINT,0,I4,0);
3655 rbstr = SysAllocString(szFalse);
3656 VARXOR(DATE,0,BSTR,rbstr,I4,0);
3657 VARXOR(DATE,-1,BSTR,rbstr,I4,-1);
3658 rbstr = SysAllocString(szTrue);
3659 VARXOR(DATE,0,BSTR,rbstr,I4,-1);
3660 VARXOR(DATE,-1,BSTR,rbstr,I4,0);
3661 VARXORCY(DATE,-1,10000,I4,-2);
3662 VARXORCY(DATE,-1,0,I4,-1);
3663 VARXORCY(DATE,0,0,I4,0);
3665 if (HAVE_OLEAUT32_I8)
3667 VARXOR(I8,-1,I8,-1,I8,0);
3668 VARXOR(I8,-1,I8,0,I8,-1);
3669 VARXOR(I8,0,I8,0,I8,0);
3670 VARXOR(I8,-1,UI8,0,I8,-1);
3671 VARXOR(I8,0,UI8,0,I8,0);
3672 VARXOR(I8,-1,UINT,0,I8,-1);
3673 VARXOR(I8,0,UINT,0,I8,0);
3674 rbstr = SysAllocString(szFalse);
3675 VARXOR(I8,0,BSTR,rbstr,I8,0);
3676 VARXOR(I8,-1,BSTR,rbstr,I8,-1);
3677 rbstr = SysAllocString(szTrue);
3678 VARXOR(I8,0,BSTR,rbstr,I8,-1);
3679 VARXOR(I8,-1,BSTR,rbstr,I8,0);
3680 VARXORCY(I8,-1,10000,I8,-2);
3681 VARXORCY(I8,-1,0,I8,-1);
3682 VARXORCY(I8,0,0,I8,0);
3684 VARXOR(UI8,0xffff,UI8,0xffff,I4,0);
3685 VARXOR(UI8,0xffff,UI8,0,I4,0xffff);
3686 VARXOR(UI8,0,UI8,0,I4,0);
3687 VARXOR(UI8,0xffff,INT,-1,I4,-65536);
3688 VARXOR(UI8,0xffff,INT,0,I4,0xffff);
3689 VARXOR(UI8,0,INT,0,I4,0);
3690 VARXOR(UI8,0xffff,UINT,0xffff,I4,0);
3691 VARXOR(UI8,0xffff,UINT,0,I4,0xffff);
3692 VARXOR(UI8,0,UINT,0,I4,0);
3693 rbstr = SysAllocString(szFalse);
3694 VARXOR(UI8,0,BSTR,rbstr,I4,0);
3695 VARXOR(UI8,0xffff,BSTR,rbstr,I4,0xffff);
3696 rbstr = SysAllocString(szTrue);
3697 VARXOR(UI8,0,BSTR,rbstr,I4,-1);
3698 VARXOR(UI8,0xffff,BSTR,rbstr,I4,-65536);
3699 VARXORCY(UI8,0xffff,10000,I4,65534);
3700 VARXORCY(UI8,0xffff,0,I4,0xffff);
3701 VARXORCY(UI8,0,0,I4,0);
3704 VARXOR(INT,-1,INT,-1,I4,0);
3705 VARXOR(INT,-1,INT,0,I4,-1);
3706 VARXOR(INT,0,INT,0,I4,0);
3707 VARXOR(INT,-1,UINT,0xffff,I4,-65536);
3708 VARXOR(INT,-1,UINT,0,I4,-1);
3709 VARXOR(INT,0,UINT,0,I4,0);
3710 rbstr = SysAllocString(szFalse);
3711 VARXOR(INT,0,BSTR,rbstr,I4,0);
3712 VARXOR(INT,-1,BSTR,rbstr,I4,-1);
3713 rbstr = SysAllocString(szTrue);
3714 VARXOR(INT,0,BSTR,rbstr,I4,-1);
3715 VARXOR(INT,-1,BSTR,rbstr,I4,0);
3716 VARXORCY(INT,-1,10000,I4,-2);
3717 VARXORCY(INT,-1,0,I4,-1);
3718 VARXORCY(INT,0,0,I4,0);
3720 VARXOR(UINT,0xffff,UINT,0xffff,I4,0);
3721 VARXOR(UINT,0xffff,UINT,0,I4,0xffff);
3722 VARXOR(UINT,0,UINT,0,I4,0);
3723 rbstr = SysAllocString(szFalse);
3724 VARXOR(UINT,0,BSTR,rbstr,I4,0);
3725 VARXOR(UINT,0xffff,BSTR,rbstr,I4,0xffff);
3726 rbstr = SysAllocString(szTrue);
3727 VARXOR(UINT,0,BSTR,rbstr,I4,-1);
3728 VARXOR(UINT,0xffff,BSTR,rbstr,I4,-65536);
3729 VARXORCY(UINT,0xffff,10000,I4,65534);
3730 VARXORCY(UINT,0xffff,0,I4,0xffff);
3731 VARXORCY(UINT,0,0,I4,0);
3733 lbstr = SysAllocString(szFalse);
3734 rbstr = SysAllocString(szFalse);
3735 VARXOR(BSTR,lbstr,BSTR,rbstr,BOOL,0);
3736 rbstr = SysAllocString(szTrue);
3737 VARXOR(BSTR,lbstr,BSTR,rbstr,BOOL,VARIANT_TRUE);
3738 lbstr = SysAllocString(szTrue);
3739 VARXOR(BSTR,lbstr,BSTR,rbstr,BOOL,VARIANT_FALSE);
3740 VARXORCY(BSTR,lbstr,10000,I4,-2);
3741 lbstr = SysAllocString(szFalse);
3742 VARXORCY(BSTR,lbstr,10000,I4,1);
3745 static HRESULT (WINAPI *pVarOr)(LPVARIANT,LPVARIANT,LPVARIANT);
3747 static const char *szVarOrFail = "VarOr(%d,%d): expected 0x0,%d,%d, got 0x%X,%d,%d\n";
3748 static const char *szVarOrChanged = "VarOr(%d,%d): Modified input arguments\n";
3749 #define VAROR(vt1,val1,vt2,val2,rvt,rval) \
3750 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
3751 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
3752 memset(&result,0,sizeof(result)); hres = pVarOr(&left,&right,&result); \
3753 ok(hres == S_OK && V_VT(&result) == VT_##rvt && V_##rvt(&result) == (rval), \
3754 szVarOrFail, VT_##vt1, VT_##vt2, \
3755 VT_##rvt, (int)(rval), hres, V_VT(&result), (int)V_##rvt(&result)); \
3756 ok(V_VT(&left) == VT_##vt1 && V_##vt1(&left) == val1 && \
3757 V_VT(&right) == VT_##vt2 && V_##vt2(&right) == val2, \
3758 szVarOrChanged,VT_##vt1,VT_##vt2)
3759 #define VARORCY(vt1,val1,val2,rvt,rval) \
3760 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
3761 V_VT(&right) = VT_CY; V_CY(&right).int64 = val2; \
3762 memset(&result,0,sizeof(result)); hres = pVarOr(&left,&right,&result); \
3763 ok(hres == S_OK && V_VT(&result) == VT_##rvt && V_##rvt(&result) == (rval), \
3764 "VarOr(%d,%d): expected 0x0,%d,%d, got 0x%X,%d,%d\n", VT_##vt1, VT_CY, \
3765 VT_##rvt, (int)(rval), hres, V_VT(&result), (int)V_##rvt(&result)); \
3766 ok(V_VT(&left) == VT_##vt1 && V_##vt1(&left) == val1 && \
3767 V_VT(&right) == VT_CY && V_CY(&right).int64 == val2, \
3768 "VarOr(%d,%d): Modified input arguments\n",VT_##vt1,VT_CY)
3770 static void test_VarOr(void)
3772 static const WCHAR szFalse[] = { '#','F','A','L','S','E','#','\0' };
3773 static const WCHAR szTrue[] = { '#','T','R','U','E','#','\0' };
3774 VARIANT left, right, result;
3781 /* Test all possible flag/vt combinations & the resulting vt type */
3782 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
3784 VARTYPE leftvt, rightvt, resvt;
3786 for (leftvt = 0; leftvt <= VT_BSTR_BLOB; leftvt++)
3791 for (rightvt = 0; rightvt <= VT_BSTR_BLOB; rightvt++)
3797 if (leftvt == VT_BSTR || rightvt == VT_BSTR ||
3798 leftvt == VT_DISPATCH || rightvt == VT_DISPATCH ||
3799 leftvt == VT_UNKNOWN || rightvt == VT_UNKNOWN)
3802 memset(&left, 0, sizeof(left));
3803 memset(&right, 0, sizeof(right));
3804 V_VT(&left) = leftvt | ExtraFlags[i];
3805 V_VT(&right) = rightvt | ExtraFlags[i];
3806 V_VT(&result) = VT_EMPTY;
3809 if (ExtraFlags[i] & VT_ARRAY || ExtraFlags[i] & VT_BYREF ||
3810 !IsValidVariantClearVT(leftvt, ExtraFlags[i]) ||
3811 !IsValidVariantClearVT(rightvt, ExtraFlags[i]) ||
3812 leftvt == VT_CLSID || rightvt == VT_CLSID ||
3813 leftvt == VT_RECORD || rightvt == VT_RECORD ||
3814 leftvt == VT_VARIANT || rightvt == VT_VARIANT ||
3815 leftvt == VT_ERROR || rightvt == VT_ERROR)
3819 if (leftvt == VT_EMPTY || rightvt == VT_EMPTY)
3821 if (leftvt == rightvt ||
3822 leftvt == VT_I2 || rightvt == VT_I2 ||
3823 leftvt == VT_UI1 || rightvt == VT_UI1 ||
3824 leftvt == VT_BOOL || rightvt == VT_BOOL)
3826 else if (leftvt == VT_NULL || rightvt == VT_NULL)
3828 else if (leftvt == VT_I8 || rightvt == VT_I8)
3831 else if (leftvt == VT_NULL || rightvt == VT_NULL)
3835 else if (leftvt == VT_UI1 || rightvt == VT_UI1)
3837 if (leftvt == rightvt)
3839 else if (leftvt == rightvt ||
3840 leftvt == VT_I2 || rightvt == VT_I2 ||
3841 leftvt == VT_BOOL || rightvt == VT_BOOL)
3845 else if (leftvt == VT_I8 || rightvt == VT_I8)
3848 else if (leftvt == VT_I2 || rightvt == VT_I2)
3850 if (leftvt == rightvt ||
3851 leftvt == VT_BOOL || rightvt == VT_BOOL)
3853 else if (leftvt == VT_I8 || rightvt == VT_I8)
3856 else if (leftvt == VT_BOOL && rightvt == VT_BOOL)
3860 else if (leftvt == VT_I8 || rightvt == VT_I8)
3862 if (leftvt == VT_INT || rightvt == VT_INT)
3867 hres = pVarOr(&left, &right, &result);
3869 ok(hres == DISP_E_TYPEMISMATCH || hres == DISP_E_BADVARTYPE,
3870 "VarOr: %d|0x%X, %d|0x%X: Expected failure, got 0x%X vt %d\n",
3871 leftvt, ExtraFlags[i], rightvt, ExtraFlags[i], hres,
3874 ok(hres == S_OK && V_VT(&result) == resvt,
3875 "VarOr: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%X vt %d\n",
3876 leftvt, ExtraFlags[i], rightvt, ExtraFlags[i], resvt, hres,
3882 /* Test returned values. Since we know the returned type is correct
3883 * and that we handle all combinations of invalid types, just check
3884 * that good type combinations produce the desired value.
3885 * FIXME: Test VT_DECIMAL/VT_DISPATCH
3887 VAROR(EMPTY,0,EMPTY,0,I2,0);
3888 VAROR(EMPTY,1,EMPTY,0,I2,0);
3889 VAROR(EMPTY,0,NULL,0,NULL,0);
3890 VAROR(EMPTY,0,I1,0,I4,0);
3891 VAROR(EMPTY,0,I1,1,I4,1);
3892 VAROR(EMPTY,0,UI1,0,I2,0);
3893 VAROR(EMPTY,0,UI1,1,I2,1);
3894 VAROR(EMPTY,0,I2,0,I2,0);
3895 VAROR(EMPTY,0,I2,1,I2,1);
3896 VAROR(EMPTY,0,UI2,0,I4,0);
3897 VAROR(EMPTY,0,UI2,1,I4,1);
3898 VAROR(EMPTY,0,I4,0,I4,0);
3899 VAROR(EMPTY,0,I4,1,I4,1);
3900 VAROR(EMPTY,0,UI4,0,I4,0);
3901 VAROR(EMPTY,0,UI4,1,I4,1);
3902 if (HAVE_OLEAUT32_I8)
3904 VAROR(EMPTY,0,I8,0,I8,0);
3905 VAROR(EMPTY,0,I8,1,I8,1);
3906 VAROR(EMPTY,0,UI8,0,I4,0);
3907 VAROR(EMPTY,0,UI8,1,I4,1);
3909 VAROR(EMPTY,0,INT,0,I4,0);
3910 VAROR(EMPTY,0,INT,1,I4,1);
3911 VAROR(EMPTY,0,UINT,0,I4,0);
3912 VAROR(EMPTY,0,UINT,1,I4,1);
3913 VAROR(EMPTY,0,BOOL,0,I2,0);
3914 VAROR(EMPTY,0,BOOL,1,I2,1);
3915 VAROR(EMPTY,0,R4,0,I4,0);
3916 VAROR(EMPTY,0,R4,1,I4,1);
3917 VAROR(EMPTY,0,R8,0,I4,0);
3918 VAROR(EMPTY,0,R8,1,I4,1);
3919 rbstr = SysAllocString(szFalse);
3920 VAROR(EMPTY,0,BSTR,rbstr,I2,0);
3921 rbstr = SysAllocString(szTrue);
3922 VAROR(EMPTY,0,BSTR,rbstr,I2,-1);
3923 VARORCY(EMPTY,0,10000,I4,1);
3925 /* NULL OR 0 = NULL. NULL OR n = n */
3926 VAROR(NULL,0,NULL,0,NULL,0);
3927 VAROR(NULL,1,NULL,0,NULL,0);
3928 VAROR(NULL,0,I1,0,NULL,0);
3929 VAROR(NULL,0,I1,1,I4,1);
3930 VAROR(NULL,0,UI1,0,NULL,0);
3931 VAROR(NULL,0,UI1,1,UI1,1);
3932 VAROR(NULL,0,I2,0,NULL,0);
3933 VAROR(NULL,0,I2,1,I2,1);
3934 VAROR(NULL,0,UI2,0,NULL,0);
3935 VAROR(NULL,0,UI2,1,I4,1);
3936 VAROR(NULL,0,I4,0,NULL,0);
3937 VAROR(NULL,0,I4,1,I4,1);
3938 VAROR(NULL,0,UI4,0,NULL,0);
3939 VAROR(NULL,0,UI4,1,I4,1);
3940 if (HAVE_OLEAUT32_I8)
3942 VAROR(NULL,0,I8,0,NULL,0);
3943 VAROR(NULL,0,I8,1,I8,1);
3944 VAROR(NULL,0,UI8,0,NULL,0);
3945 VAROR(NULL,0,UI8,1,I4,1);
3947 VAROR(NULL,0,INT,0,NULL,0);
3948 VAROR(NULL,0,INT,1,I4,1);
3949 VAROR(NULL,0,UINT,0,NULL,0);
3950 VAROR(NULL,0,UINT,1,I4,1);
3951 VAROR(NULL,0,BOOL,0,NULL,0);
3952 VAROR(NULL,0,BOOL,1,BOOL,1);
3953 VAROR(NULL,0,R4,0,NULL,0);
3954 VAROR(NULL,0,R4,1,I4,1);
3955 VAROR(NULL,0,R8,0,NULL,0);
3956 VAROR(NULL,0,R8,1,I4,1);
3957 rbstr = SysAllocString(szFalse);
3958 VAROR(NULL,0,BSTR,rbstr,NULL,0);
3959 rbstr = SysAllocString(szTrue);
3960 VAROR(NULL,0,BSTR,rbstr,BOOL,VARIANT_TRUE);
3961 VARORCY(NULL,0,10000,I4,1);
3962 VARORCY(NULL,0,0,NULL,0);
3964 VAROR(BOOL,VARIANT_TRUE,BOOL,VARIANT_TRUE,BOOL,VARIANT_TRUE);
3965 VAROR(BOOL,VARIANT_TRUE,BOOL,VARIANT_FALSE,BOOL,VARIANT_TRUE);
3966 VAROR(BOOL,VARIANT_FALSE,BOOL,VARIANT_TRUE,BOOL,VARIANT_TRUE);
3967 VAROR(BOOL,VARIANT_FALSE,BOOL,VARIANT_FALSE,BOOL,VARIANT_FALSE);
3968 /* Assume x,y & y,x are the same from now on to reduce the number of tests */
3969 VAROR(BOOL,VARIANT_TRUE,I1,-1,I4,-1);
3970 VAROR(BOOL,VARIANT_TRUE,I1,0,I4,-1);
3971 VAROR(BOOL,VARIANT_FALSE,I1,0,I4,0);
3972 VAROR(BOOL,VARIANT_TRUE,UI1,255,I2,-1);
3973 VAROR(BOOL,VARIANT_TRUE,UI1,0,I2,-1);
3974 VAROR(BOOL,VARIANT_FALSE,UI1,0,I2,0);
3975 VAROR(BOOL,VARIANT_TRUE,I2,-1,I2,-1);
3976 VAROR(BOOL,VARIANT_TRUE,I2,0,I2,-1);
3977 VAROR(BOOL,VARIANT_FALSE,I2,0,I2,0);
3978 VAROR(BOOL,VARIANT_TRUE,UI2,65535,I4,-1);
3979 VAROR(BOOL,VARIANT_TRUE,UI2,0,I4,-1);
3980 VAROR(BOOL,VARIANT_FALSE,UI2,0,I4,0);
3981 VAROR(BOOL,VARIANT_TRUE,I4,-1,I4,-1);
3982 VAROR(BOOL,VARIANT_TRUE,I4,0,I4,-1);
3983 VAROR(BOOL,VARIANT_FALSE,I4,0,I4,0);
3984 VAROR(BOOL,VARIANT_TRUE,UI4,0xffffffff,I4,-1);
3985 VAROR(BOOL,VARIANT_TRUE,UI4,0,I4,-1);
3986 VAROR(BOOL,VARIANT_FALSE,UI4,0,I4,0);
3987 VAROR(BOOL,VARIANT_TRUE,R4,-1,I4,-1);
3988 VAROR(BOOL,VARIANT_TRUE,R4,0,I4,-1);
3989 VAROR(BOOL,VARIANT_FALSE,R4,0,I4,0);
3990 VAROR(BOOL,VARIANT_TRUE,R8,-1,I4,-1);
3991 VAROR(BOOL,VARIANT_TRUE,R8,0,I4,-1);
3992 VAROR(BOOL,VARIANT_FALSE,R8,0,I4,0);
3993 VAROR(BOOL,VARIANT_TRUE,DATE,-1,I4,-1);
3994 VAROR(BOOL,VARIANT_TRUE,DATE,0,I4,-1);
3995 VAROR(BOOL,VARIANT_FALSE,DATE,0,I4,0);
3996 if (HAVE_OLEAUT32_I8)
3998 VAROR(BOOL,VARIANT_TRUE,I8,-1,I8,-1);
3999 VAROR(BOOL,VARIANT_TRUE,I8,0,I8,-1);
4000 VAROR(BOOL,VARIANT_FALSE,I8,0,I8,0);
4001 /* This returns DISP_E_OVERFLOW which indicates that a conversion
4002 * to I4 is performed.
4004 /* VAROR(BOOL,VARIANT_TRUE,UI8,-1,I4,-1); */
4005 VAROR(BOOL,VARIANT_TRUE,UI8,0,I4,-1);
4006 VAROR(BOOL,VARIANT_FALSE,UI8,0,I4,0);
4008 VAROR(BOOL,VARIANT_TRUE,INT,-1,I4,-1);
4009 VAROR(BOOL,VARIANT_TRUE,INT,0,I4,-1);
4010 VAROR(BOOL,VARIANT_FALSE,INT,0,I4,0);
4011 VAROR(BOOL,VARIANT_TRUE,UINT,0xffffffff,I4,-1);
4012 VAROR(BOOL,VARIANT_TRUE,UINT,0,I4,-1);
4013 VAROR(BOOL,VARIANT_FALSE,UINT,0,I4,0);
4014 rbstr = SysAllocString(szFalse);
4015 VAROR(BOOL,VARIANT_FALSE,BSTR,rbstr,BOOL,VARIANT_FALSE);
4016 VAROR(BOOL,VARIANT_TRUE,BSTR,rbstr,BOOL,VARIANT_TRUE);
4017 rbstr = SysAllocString(szTrue);
4018 VAROR(BOOL,VARIANT_FALSE,BSTR,rbstr,BOOL,VARIANT_TRUE);
4019 VAROR(BOOL,VARIANT_TRUE,BSTR,rbstr,BOOL,VARIANT_TRUE);
4020 VARORCY(BOOL,VARIANT_TRUE,10000,I4,-1);
4021 VARORCY(BOOL,VARIANT_TRUE,0,I4,-1);
4022 VARORCY(BOOL,VARIANT_FALSE,0,I4,0);
4024 VAROR(I1,-1,I1,-1,I4,-1);
4025 VAROR(I1,-1,I1,0,I4,-1);
4026 VAROR(I1,0,I1,0,I4,0);
4027 VAROR(I1,-1,UI1,255,I4,-1);
4028 VAROR(I1,-1,UI1,0,I4,-1);
4029 VAROR(I1,0,UI1,0,I4,0);
4030 VAROR(I1,-1,I2,-1,I4,-1);
4031 VAROR(I1,-1,I2,0,I4,-1);
4032 VAROR(I1,0,I2,0,I4,0);
4033 VAROR(I1,-1,UI2,65535,I4,-1);
4034 VAROR(I1,-1,UI2,0,I4,-1);
4035 VAROR(I1,0,UI2,0,I4,0);
4036 VAROR(I1,-1,I4,-1,I4,-1);
4037 VAROR(I1,-1,I4,0,I4,-1);
4038 VAROR(I1,0,I4,0,I4,0);
4039 VAROR(I1,-1,UI4,0xffffffff,I4,-1);
4040 VAROR(I1,-1,UI4,0,I4,-1);
4041 VAROR(I1,0,UI4,0,I4,0);
4042 VAROR(I1,-1,R4,-1,I4,-1);
4043 VAROR(I1,-1,R4,0,I4,-1);
4044 VAROR(I1,0,R4,0,I4,0);
4045 VAROR(I1,-1,R8,-1,I4,-1);
4046 VAROR(I1,-1,R8,0,I4,-1);
4047 VAROR(I1,0,R8,0,I4,0);
4048 VAROR(I1,-1,DATE,-1,I4,-1);
4049 VAROR(I1,-1,DATE,0,I4,-1);
4050 VAROR(I1,0,DATE,0,I4,0);
4051 if (HAVE_OLEAUT32_I8)
4053 VAROR(I1,-1,I8,-1,I8,-1);
4054 VAROR(I1,-1,I8,0,I8,-1);
4055 VAROR(I1,0,I8,0,I8,0);
4056 VAROR(I1,-1,UI8,0,I4,-1);
4057 VAROR(I1,0,UI8,0,I4,0);
4059 VAROR(I1,-1,INT,-1,I4,-1);
4060 VAROR(I1,-1,INT,0,I4,-1);
4061 VAROR(I1,0,INT,0,I4,0);
4062 VAROR(I1,-1,UINT,0xffffffff,I4,-1);
4063 VAROR(I1,-1,UINT,0,I4,-1);
4064 VAROR(I1,0,UINT,0,I4,0);
4065 rbstr = SysAllocString(szFalse);
4066 VAROR(I1,0,BSTR,rbstr,I4,0);
4067 VAROR(I1,-1,BSTR,rbstr,I4,-1);
4068 rbstr = SysAllocString(szTrue);
4069 VAROR(I1,0,BSTR,rbstr,I4,-1);
4070 VAROR(I1,-1,BSTR,rbstr,I4,-1);
4071 VARORCY(I1,-1,10000,I4,-1);
4072 VARORCY(I1,-1,0,I4,-1);
4073 VARORCY(I1,0,0,I4,0);
4075 VAROR(UI1,255,UI1,255,UI1,255);
4076 VAROR(UI1,255,UI1,0,UI1,255);
4077 VAROR(UI1,0,UI1,0,UI1,0);
4078 VAROR(UI1,255,I2,-1,I2,-1);
4079 VAROR(UI1,255,I2,0,I2,255);
4080 VAROR(UI1,0,I2,0,I2,0);
4081 VAROR(UI1,255,UI2,65535,I4,65535);
4082 VAROR(UI1,255,UI2,0,I4,255);
4083 VAROR(UI1,0,UI2,0,I4,0);
4084 VAROR(UI1,255,I4,-1,I4,-1);
4085 VAROR(UI1,255,I4,0,I4,255);
4086 VAROR(UI1,0,I4,0,I4,0);
4087 VAROR(UI1,255,UI4,0xffffffff,I4,-1);
4088 VAROR(UI1,255,UI4,0,I4,255);
4089 VAROR(UI1,0,UI4,0,I4,0);
4090 VAROR(UI1,255,R4,-1,I4,-1);
4091 VAROR(UI1,255,R4,0,I4,255);
4092 VAROR(UI1,0,R4,0,I4,0);
4093 VAROR(UI1,255,R8,-1,I4,-1);
4094 VAROR(UI1,255,R8,0,I4,255);
4095 VAROR(UI1,0,R8,0,I4,0);
4096 VAROR(UI1,255,DATE,-1,I4,-1);
4097 VAROR(UI1,255,DATE,0,I4,255);
4098 VAROR(UI1,0,DATE,0,I4,0);
4099 if (HAVE_OLEAUT32_I8)
4101 VAROR(UI1,255,I8,-1,I8,-1);
4102 VAROR(UI1,255,I8,0,I8,255);
4103 VAROR(UI1,0,I8,0,I8,0);
4104 VAROR(UI1,255,UI8,0,I4,255);
4105 VAROR(UI1,0,UI8,0,I4,0);
4107 VAROR(UI1,255,INT,-1,I4,-1);
4108 VAROR(UI1,255,INT,0,I4,255);
4109 VAROR(UI1,0,INT,0,I4,0);
4110 VAROR(UI1,255,UINT,0xffffffff,I4,-1);
4111 VAROR(UI1,255,UINT,0,I4,255);
4112 VAROR(UI1,0,UINT,0,I4,0);
4113 rbstr = SysAllocString(szFalse);
4114 VAROR(UI1,0,BSTR,rbstr,I2,0);
4115 VAROR(UI1,255,BSTR,rbstr,I2,255);
4116 rbstr = SysAllocString(szTrue);
4117 VAROR(UI1,0,BSTR,rbstr,I2,-1);
4118 VAROR(UI1,255,BSTR,rbstr,I2,-1);
4119 VARORCY(UI1,255,10000,I4,255);
4120 VARORCY(UI1,255,0,I4,255);
4121 VARORCY(UI1,0,0,I4,0);
4123 VAROR(I2,-1,I2,-1,I2,-1);
4124 VAROR(I2,-1,I2,0,I2,-1);
4125 VAROR(I2,0,I2,0,I2,0);
4126 VAROR(I2,-1,UI2,65535,I4,-1);
4127 VAROR(I2,-1,UI2,0,I4,-1);
4128 VAROR(I2,0,UI2,0,I4,0);
4129 VAROR(I2,-1,I4,-1,I4,-1);
4130 VAROR(I2,-1,I4,0,I4,-1);
4131 VAROR(I2,0,I4,0,I4,0);
4132 VAROR(I2,-1,UI4,0xffffffff,I4,-1);
4133 VAROR(I2,-1,UI4,0,I4,-1);
4134 VAROR(I2,0,UI4,0,I4,0);
4135 VAROR(I2,-1,R4,-1,I4,-1);
4136 VAROR(I2,-1,R4,0,I4,-1);
4137 VAROR(I2,0,R4,0,I4,0);
4138 VAROR(I2,-1,R8,-1,I4,-1);
4139 VAROR(I2,-1,R8,0,I4,-1);
4140 VAROR(I2,0,R8,0,I4,0);
4141 VAROR(I2,-1,DATE,-1,I4,-1);
4142 VAROR(I2,-1,DATE,0,I4,-1);
4143 VAROR(I2,0,DATE,0,I4,0);
4144 if (HAVE_OLEAUT32_I8)
4146 VAROR(I2,-1,I8,-1,I8,-1);
4147 VAROR(I2,-1,I8,0,I8,-1);
4148 VAROR(I2,0,I8,0,I8,0);
4149 VAROR(I2,-1,UI8,0,I4,-1);
4150 VAROR(I2,0,UI8,0,I4,0);
4152 VAROR(I2,-1,INT,-1,I4,-1);
4153 VAROR(I2,-1,INT,0,I4,-1);
4154 VAROR(I2,0,INT,0,I4,0);
4155 VAROR(I2,-1,UINT,0xffffffff,I4,-1);
4156 VAROR(I2,-1,UINT,0,I4,-1);
4157 VAROR(I2,0,UINT,0,I4,0);
4158 rbstr = SysAllocString(szFalse);
4159 VAROR(I2,0,BSTR,rbstr,I2,0);
4160 VAROR(I2,-1,BSTR,rbstr,I2,-1);
4161 rbstr = SysAllocString(szTrue);
4162 VAROR(I2,0,BSTR,rbstr,I2,-1);
4163 VAROR(I2,-1,BSTR,rbstr,I2,-1);
4164 VARORCY(I2,-1,10000,I4,-1);
4165 VARORCY(I2,-1,0,I4,-1);
4166 VARORCY(I2,0,0,I4,0);
4168 VAROR(UI2,65535,UI2,65535,I4,65535);
4169 VAROR(UI2,65535,UI2,0,I4,65535);
4170 VAROR(UI2,0,UI2,0,I4,0);
4171 VAROR(UI2,65535,I4,-1,I4,-1);
4172 VAROR(UI2,65535,I4,0,I4,65535);
4173 VAROR(UI2,0,I4,0,I4,0);
4174 VAROR(UI2,65535,UI4,0xffffffff,I4,-1);
4175 VAROR(UI2,65535,UI4,0,I4,65535);
4176 VAROR(UI2,0,UI4,0,I4,0);
4177 VAROR(UI2,65535,R4,-1,I4,-1);
4178 VAROR(UI2,65535,R4,0,I4,65535);
4179 VAROR(UI2,0,R4,0,I4,0);
4180 VAROR(UI2,65535,R8,-1,I4,-1);
4181 VAROR(UI2,65535,R8,0,I4,65535);
4182 VAROR(UI2,0,R8,0,I4,0);
4183 VAROR(UI2,65535,DATE,-1,I4,-1);
4184 VAROR(UI2,65535,DATE,0,I4,65535);
4185 VAROR(UI2,0,DATE,0,I4,0);
4186 if (HAVE_OLEAUT32_I8)
4188 VAROR(UI2,65535,I8,-1,I8,-1);
4189 VAROR(UI2,65535,I8,0,I8,65535);
4190 VAROR(UI2,0,I8,0,I8,0);
4191 VAROR(UI2,65535,UI8,0,I4,65535);
4192 VAROR(UI2,0,UI8,0,I4,0);
4194 VAROR(UI2,65535,INT,-1,I4,-1);
4195 VAROR(UI2,65535,INT,0,I4,65535);
4196 VAROR(UI2,0,INT,0,I4,0);
4197 VAROR(UI2,65535,UINT,0xffffffff,I4,-1);
4198 VAROR(UI2,65535,UINT,0,I4,65535);
4199 VAROR(UI2,0,UINT,0,I4,0);
4200 rbstr = SysAllocString(szFalse);
4201 VAROR(UI2,0,BSTR,rbstr,I4,0);
4202 VAROR(UI2,65535,BSTR,rbstr,I4,65535);
4203 rbstr = SysAllocString(szTrue);
4204 VAROR(UI2,0,BSTR,rbstr,I4,-1);
4205 VAROR(UI2,65535,BSTR,rbstr,I4,-1);
4206 VARORCY(UI2,65535,10000,I4,65535);
4207 VARORCY(UI2,65535,0,I4,65535);
4208 VARORCY(UI2,0,0,I4,0);
4210 VAROR(I4,-1,I4,-1,I4,-1);
4211 VAROR(I4,-1,I4,0,I4,-1);
4212 VAROR(I4,0,I4,0,I4,0);
4213 VAROR(I4,-1,UI4,0xffffffff,I4,-1);
4214 VAROR(I4,-1,UI4,0,I4,-1);
4215 VAROR(I4,0,UI4,0,I4,0);
4216 VAROR(I4,-1,R4,-1,I4,-1);
4217 VAROR(I4,-1,R4,0,I4,-1);
4218 VAROR(I4,0,R4,0,I4,0);
4219 VAROR(I4,-1,R8,-1,I4,-1);
4220 VAROR(I4,-1,R8,0,I4,-1);
4221 VAROR(I4,0,R8,0,I4,0);
4222 VAROR(I4,-1,DATE,-1,I4,-1);
4223 VAROR(I4,-1,DATE,0,I4,-1);
4224 VAROR(I4,0,DATE,0,I4,0);
4225 if (HAVE_OLEAUT32_I8)
4227 VAROR(I4,-1,I8,-1,I8,-1);
4228 VAROR(I4,-1,I8,0,I8,-1);
4229 VAROR(I4,0,I8,0,I8,0);
4230 VAROR(I4,-1,UI8,0,I4,-1);
4231 VAROR(I4,0,UI8,0,I4,0);
4233 VAROR(I4,-1,INT,-1,I4,-1);
4234 VAROR(I4,-1,INT,0,I4,-1);
4235 VAROR(I4,0,INT,0,I4,0);
4236 VAROR(I4,-1,UINT,0xffffffff,I4,-1);
4237 VAROR(I4,-1,UINT,0,I4,-1);
4238 VAROR(I4,0,UINT,0,I4,0);
4239 rbstr = SysAllocString(szFalse);
4240 VAROR(I4,0,BSTR,rbstr,I4,0);
4241 VAROR(I4,-1,BSTR,rbstr,I4,-1);
4242 rbstr = SysAllocString(szTrue);
4243 VAROR(I4,0,BSTR,rbstr,I4,-1);
4244 VAROR(I4,-1,BSTR,rbstr,I4,-1);
4245 VARORCY(I4,-1,10000,I4,-1);
4246 VARORCY(I4,-1,0,I4,-1);
4247 VARORCY(I4,0,0,I4,0);
4249 VAROR(UI4,0xffffffff,UI4,0xffffffff,I4,-1);
4250 VAROR(UI4,0xffffffff,UI4,0,I4,-1);
4251 VAROR(UI4,0,UI4,0,I4,0);
4252 VAROR(UI4,0xffffffff,R4,-1,I4,-1);
4253 VAROR(UI4,0xffffffff,R4,0,I4,-1);
4254 VAROR(UI4,0,R4,0,I4,0);
4255 VAROR(UI4,0xffffffff,R8,-1,I4,-1);
4256 VAROR(UI4,0xffffffff,R8,0,I4,-1);
4257 VAROR(UI4,0,R8,0,I4,0);
4258 VAROR(UI4,0xffffffff,DATE,-1,I4,-1);
4259 VAROR(UI4,0xffffffff,DATE,0,I4,-1);
4260 VAROR(UI4,0,DATE,0,I4,0);
4261 if (HAVE_OLEAUT32_I8)
4263 VAROR(UI4,0xffffffff,I8,-1,I8,-1);
4264 VAROR(UI4,0xffffffff,I8,0,I8,0xffffffff);
4265 VAROR(UI4,0,I8,0,I8,0);
4266 VAROR(UI4,0xffffffff,UI8,0,I4,-1);
4267 VAROR(UI4,0,UI8,0,I4,0);
4269 VAROR(UI4,0xffffffff,INT,-1,I4,-1);
4270 VAROR(UI4,0xffffffff,INT,0,I4,-1);
4271 VAROR(UI4,0,INT,0,I4,0);
4272 VAROR(UI4,0xffffffff,UINT,0xffffffff,I4,-1);
4273 VAROR(UI4,0xffffffff,UINT,0,I4,-1);
4274 VAROR(UI4,0,UINT,0,I4,0);
4275 rbstr = SysAllocString(szFalse);
4276 VAROR(UI4,0,BSTR,rbstr,I4,0);
4277 VAROR(UI4,0xffffffff,BSTR,rbstr,I4,-1);
4278 rbstr = SysAllocString(szTrue);
4279 VAROR(UI4,0,BSTR,rbstr,I4,-1);
4280 VAROR(UI4,0xffffffff,BSTR,rbstr,I4,-1);
4281 VARORCY(UI4,0xffffffff,10000,I4,-1);
4282 VARORCY(UI4,0xffffffff,0,I4,-1);
4283 VARORCY(UI4,0,0,I4,0);
4285 VAROR(R4,-1,R4,-1,I4,-1);
4286 VAROR(R4,-1,R4,0,I4,-1);
4287 VAROR(R4,0,R4,0,I4,0);
4288 VAROR(R4,-1,R8,-1,I4,-1);
4289 VAROR(R4,-1,R8,0,I4,-1);
4290 VAROR(R4,0,R8,0,I4,0);
4291 VAROR(R4,-1,DATE,-1,I4,-1);
4292 VAROR(R4,-1,DATE,0,I4,-1);
4293 VAROR(R4,0,DATE,0,I4,0);
4294 if (HAVE_OLEAUT32_I8)
4296 VAROR(R4,-1,I8,-1,I8,-1);
4297 VAROR(R4,-1,I8,0,I8,-1);
4298 VAROR(R4,0,I8,0,I8,0);
4299 VAROR(R4,-1,UI8,0,I4,-1);
4300 VAROR(R4,0,UI8,0,I4,0);
4302 VAROR(R4,-1,INT,-1,I4,-1);
4303 VAROR(R4,-1,INT,0,I4,-1);
4304 VAROR(R4,0,INT,0,I4,0);
4305 VAROR(R4,-1,UINT,0xffffffff,I4,-1);
4306 VAROR(R4,-1,UINT,0,I4,-1);
4307 VAROR(R4,0,UINT,0,I4,0);
4308 rbstr = SysAllocString(szFalse);
4309 VAROR(R4,0,BSTR,rbstr,I4,0);
4310 VAROR(R4,-1,BSTR,rbstr,I4,-1);
4311 rbstr = SysAllocString(szTrue);
4312 VAROR(R4,0,BSTR,rbstr,I4,-1);
4313 VAROR(R4,-1,BSTR,rbstr,I4,-1);
4314 VARORCY(R4,-1,10000,I4,-1);
4315 VARORCY(R4,-1,0,I4,-1);
4316 VARORCY(R4,0,0,I4,0);
4318 VAROR(R8,-1,R8,-1,I4,-1);
4319 VAROR(R8,-1,R8,0,I4,-1);
4320 VAROR(R8,0,R8,0,I4,0);
4321 VAROR(R8,-1,DATE,-1,I4,-1);
4322 VAROR(R8,-1,DATE,0,I4,-1);
4323 VAROR(R8,0,DATE,0,I4,0);
4324 if (HAVE_OLEAUT32_I8)
4326 VAROR(R8,-1,I8,-1,I8,-1);
4327 VAROR(R8,-1,I8,0,I8,-1);
4328 VAROR(R8,0,I8,0,I8,0);
4329 VAROR(R8,-1,UI8,0,I4,-1);
4330 VAROR(R8,0,UI8,0,I4,0);
4332 VAROR(R8,-1,INT,-1,I4,-1);
4333 VAROR(R8,-1,INT,0,I4,-1);
4334 VAROR(R8,0,INT,0,I4,0);
4335 VAROR(R8,-1,UINT,0xffffffff,I4,-1);
4336 VAROR(R8,-1,UINT,0,I4,-1);
4337 VAROR(R8,0,UINT,0,I4,0);
4338 rbstr = SysAllocString(szFalse);
4339 VAROR(R8,0,BSTR,rbstr,I4,0);
4340 VAROR(R8,-1,BSTR,rbstr,I4,-1);
4341 rbstr = SysAllocString(szTrue);
4342 VAROR(R8,0,BSTR,rbstr,I4,-1);
4343 VAROR(R8,-1,BSTR,rbstr,I4,-1);
4344 VARORCY(R8,-1,10000,I4,-1);
4345 VARORCY(R8,-1,0,I4,-1);
4346 VARORCY(R8,0,0,I4,0);
4348 VAROR(DATE,-1,DATE,-1,I4,-1);
4349 VAROR(DATE,-1,DATE,0,I4,-1);
4350 VAROR(DATE,0,DATE,0,I4,0);
4351 if (HAVE_OLEAUT32_I8)
4353 VAROR(DATE,-1,I8,-1,I8,-1);
4354 VAROR(DATE,-1,I8,0,I8,-1);
4355 VAROR(DATE,0,I8,0,I8,0);
4356 VAROR(DATE,-1,UI8,0,I4,-1);
4357 VAROR(DATE,0,UI8,0,I4,0);
4359 VAROR(DATE,-1,INT,-1,I4,-1);
4360 VAROR(DATE,-1,INT,0,I4,-1);
4361 VAROR(DATE,0,INT,0,I4,0);
4362 VAROR(DATE,-1,UINT,0xffffffff,I4,-1);
4363 VAROR(DATE,-1,UINT,0,I4,-1);
4364 VAROR(DATE,0,UINT,0,I4,0);
4365 rbstr = SysAllocString(szFalse);
4366 VAROR(DATE,0,BSTR,rbstr,I4,0);
4367 VAROR(DATE,-1,BSTR,rbstr,I4,-1);
4368 rbstr = SysAllocString(szTrue);
4369 VAROR(DATE,0,BSTR,rbstr,I4,-1);
4370 VAROR(DATE,-1,BSTR,rbstr,I4,-1);
4371 VARORCY(DATE,-1,10000,I4,-1);
4372 VARORCY(DATE,-1,0,I4,-1);
4373 VARORCY(DATE,0,0,I4,0);
4375 if (HAVE_OLEAUT32_I8)
4377 VAROR(I8,-1,I8,-1,I8,-1);
4378 VAROR(I8,-1,I8,0,I8,-1);
4379 VAROR(I8,0,I8,0,I8,0);
4380 VAROR(I8,-1,UI8,0,I8,-1);
4381 VAROR(I8,0,UI8,0,I8,0);
4382 /* These overflow under native and Wine
4383 VAROR(I8,-1,INT,-1,I4,-1);
4384 VAROR(I8,-1,INT,0,I4,-1);
4385 VAROR(I8,0,INT,0,I4,0); */
4386 VAROR(I8,-1,UINT,0xffffffff,I8,-1);
4387 VAROR(I8,-1,UINT,0,I8,-1);
4388 VAROR(I8,0,UINT,0,I8,0);
4389 rbstr = SysAllocString(szFalse);
4390 VAROR(I8,0,BSTR,rbstr,I8,0);
4391 VAROR(I8,-1,BSTR,rbstr,I8,-1);
4392 rbstr = SysAllocString(szTrue);
4393 VAROR(I8,0,BSTR,rbstr,I8,-1);
4394 VAROR(I8,-1,BSTR,rbstr,I8,-1);
4395 VARORCY(I8,-1,10000,I8,-1);
4396 VARORCY(I8,-1,0,I8,-1);
4397 VARORCY(I8,0,0,I8,0);
4399 VAROR(UI8,0xffff,UI8,0xffff,I4,0xffff);
4400 VAROR(UI8,0xffff,UI8,0,I4,0xffff);
4401 VAROR(UI8,0,UI8,0,I4,0);
4402 VAROR(UI8,0xffff,INT,-1,I4,-1);
4403 VAROR(UI8,0xffff,INT,0,I4,0xffff);
4404 VAROR(UI8,0,INT,0,I4,0);
4405 VAROR(UI8,0xffff,UINT,0xffff,I4,0xffff);
4406 VAROR(UI8,0xffff,UINT,0,I4,0xffff);
4407 VAROR(UI8,0,UINT,0,I4,0);
4408 rbstr = SysAllocString(szFalse);
4409 VAROR(UI8,0,BSTR,rbstr,I4,0);
4410 VAROR(UI8,0xffff,BSTR,rbstr,I4,0xffff);
4411 rbstr = SysAllocString(szTrue);
4412 VAROR(UI8,0,BSTR,rbstr,I4,-1);
4413 VAROR(UI8,0xffff,BSTR,rbstr,I4,-1);
4414 VARORCY(UI8,0xffff,10000,I4,0xffff);
4415 VARORCY(UI8,0xffff,0,I4,0xffff);
4416 VARORCY(UI8,0,0,I4,0);
4419 VAROR(INT,-1,INT,-1,I4,-1);
4420 VAROR(INT,-1,INT,0,I4,-1);
4421 VAROR(INT,0,INT,0,I4,0);
4422 VAROR(INT,-1,UINT,0xffff,I4,-1);
4423 VAROR(INT,-1,UINT,0,I4,-1);
4424 VAROR(INT,0,UINT,0,I4,0);
4425 rbstr = SysAllocString(szFalse);
4426 VAROR(INT,0,BSTR,rbstr,I4,0);
4427 VAROR(INT,-1,BSTR,rbstr,I4,-1);
4428 rbstr = SysAllocString(szTrue);
4429 VAROR(INT,0,BSTR,rbstr,I4,-1);
4430 VAROR(INT,-1,BSTR,rbstr,I4,-1);
4431 VARORCY(INT,-1,10000,I4,-1);
4432 VARORCY(INT,-1,0,I4,-1);
4433 VARORCY(INT,0,0,I4,0);
4435 VAROR(UINT,0xffff,UINT,0xffff,I4,0xffff);
4436 VAROR(UINT,0xffff,UINT,0,I4,0xffff);
4437 VAROR(UINT,0,UINT,0,I4,0);
4438 rbstr = SysAllocString(szFalse);
4439 VAROR(UINT,0,BSTR,rbstr,I4,0);
4440 VAROR(UINT,0xffff,BSTR,rbstr,I4,0xffff);
4441 rbstr = SysAllocString(szTrue);
4442 VAROR(UINT,0,BSTR,rbstr,I4,-1);
4443 VAROR(UINT,0xffff,BSTR,rbstr,I4,-1);
4444 VARORCY(UINT,0xffff,10000,I4,0xffff);
4445 VARORCY(UINT,0xffff,0,I4,0xffff);
4446 VARORCY(UINT,0,0,I4,0);
4448 lbstr = SysAllocString(szFalse);
4449 rbstr = SysAllocString(szFalse);
4450 VAROR(BSTR,lbstr,BSTR,rbstr,BOOL,0);
4451 rbstr = SysAllocString(szTrue);
4452 VAROR(BSTR,lbstr,BSTR,rbstr,BOOL,VARIANT_TRUE);
4453 lbstr = SysAllocString(szTrue);
4454 VAROR(BSTR,lbstr,BSTR,rbstr,BOOL,VARIANT_TRUE);
4455 VARORCY(BSTR,lbstr,10000,I4,-1);
4456 lbstr = SysAllocString(szFalse);
4457 VARORCY(BSTR,lbstr,10000,I4,1);
4460 static HRESULT (WINAPI *pVarEqv)(LPVARIANT,LPVARIANT,LPVARIANT);
4462 static const char *szVarEqvFail = "VarEqv(%d,%d): expected 0x0,%d,%d, got 0x%X,%d,%d\n";
4463 #define VAREQV(vt1,val1,vt2,val2,rvt,rval) \
4464 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
4465 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
4466 memset(&result,0,sizeof(result)); hres = pVarEqv(&left,&right,&result); \
4467 ok(hres == S_OK && V_VT(&result) == VT_##rvt && V_##rvt(&result) == (rval), \
4468 szVarEqvFail, VT_##vt1, VT_##vt2, \
4469 VT_##rvt, (int)(rval), hres, V_VT(&result), (int)V_##rvt(&result))
4471 static void test_VarEqv(void)
4473 VARIANT left, right, result;
4479 /* Test all possible flag/vt combinations & the resulting vt type */
4480 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
4482 VARTYPE leftvt, rightvt, resvt;
4484 for (leftvt = 0; leftvt <= VT_BSTR_BLOB; leftvt++)
4488 for (rightvt = 0; rightvt <= VT_BSTR_BLOB; rightvt++)
4494 if (leftvt == VT_BSTR || rightvt == VT_BSTR ||
4495 leftvt == VT_DISPATCH || rightvt == VT_DISPATCH ||
4496 leftvt == VT_UNKNOWN || rightvt == VT_UNKNOWN)
4499 memset(&left, 0, sizeof(left));
4500 memset(&right, 0, sizeof(right));
4501 V_VT(&left) = leftvt | ExtraFlags[i];
4502 V_VT(&right) = rightvt | ExtraFlags[i];
4503 V_VT(&result) = VT_EMPTY;
4506 if (ExtraFlags[i] & VT_ARRAY || ExtraFlags[i] & VT_BYREF ||
4507 !IsValidVariantClearVT(leftvt, ExtraFlags[i]) ||
4508 !IsValidVariantClearVT(rightvt, ExtraFlags[i]) ||
4509 leftvt == VT_CLSID || rightvt == VT_CLSID ||
4510 leftvt == VT_RECORD || rightvt == VT_RECORD ||
4511 leftvt == VT_VARIANT || rightvt == VT_VARIANT ||
4512 leftvt == VT_ERROR || rightvt == VT_ERROR)
4516 if (leftvt == VT_EMPTY || rightvt == VT_EMPTY)
4518 if (leftvt == rightvt ||
4519 leftvt == VT_I2 || rightvt == VT_I2 ||
4520 leftvt == VT_UI1 || rightvt == VT_UI1 ||
4521 leftvt == VT_BOOL || rightvt == VT_BOOL)
4523 else if (leftvt == VT_NULL || rightvt == VT_NULL)
4525 else if (leftvt == VT_I8 || rightvt == VT_I8)
4528 else if (leftvt == VT_NULL || rightvt == VT_NULL)
4532 else if (leftvt == VT_UI1 || rightvt == VT_UI1)
4534 if (leftvt == rightvt)
4536 else if (leftvt == rightvt ||
4537 leftvt == VT_I2 || rightvt == VT_I2 ||
4538 leftvt == VT_BOOL || rightvt == VT_BOOL)
4542 else if (leftvt == VT_I8 || rightvt == VT_I8)
4545 else if (leftvt == VT_I2 || rightvt == VT_I2)
4547 if (leftvt == rightvt ||
4548 leftvt == VT_BOOL || rightvt == VT_BOOL)
4550 else if (leftvt == VT_I8 || rightvt == VT_I8)
4553 else if (leftvt == VT_BOOL && rightvt == VT_BOOL)
4557 else if (leftvt == VT_I8 || rightvt == VT_I8)
4559 if (leftvt == VT_INT || rightvt == VT_INT)
4564 hres = pVarEqv(&left, &right, &result);
4566 ok(hres == DISP_E_TYPEMISMATCH || hres == DISP_E_BADVARTYPE,
4567 "VarEqv: %d|0x%X, %d|0x%X: Expected failure, got 0x%X vt %d\n",
4568 leftvt, ExtraFlags[i], rightvt, ExtraFlags[i], hres,
4571 ok(hres == S_OK && V_VT(&result) == resvt,
4572 "VarEqv: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%X vt %d\n",
4573 leftvt, ExtraFlags[i], rightvt, ExtraFlags[i], resvt, hres,
4579 /* Test returned values */
4580 VAREQV(BOOL,VARIANT_TRUE,BOOL,VARIANT_TRUE,BOOL,VARIANT_TRUE);
4581 VAREQV(BOOL,VARIANT_FALSE,BOOL,VARIANT_TRUE,BOOL,VARIANT_FALSE);
4582 VAREQV(BOOL,TRUE,BOOL,TRUE,BOOL,VARIANT_TRUE);
4583 VAREQV(BOOL,FALSE,BOOL,FALSE,BOOL,VARIANT_TRUE);
4584 VAREQV(BOOL,TRUE,BOOL,FALSE,BOOL,-2);
4585 VAREQV(BOOL,FALSE,BOOL,TRUE,BOOL,-2);
4586 VAREQV(BOOL,6,BOOL,7,BOOL,-2);
4587 VAREQV(BOOL,6,BOOL,6,BOOL,VARIANT_TRUE);
4588 VAREQV(BOOL,VARIANT_TRUE,I2,VARIANT_TRUE,I2,VARIANT_TRUE);
4589 VAREQV(BOOL,VARIANT_TRUE,I2,VARIANT_FALSE,I2,VARIANT_FALSE);
4590 VAREQV(BOOL,6,I2,7,I2,-2);
4591 VAREQV(UI1,1,UI1,1,UI1,255);
4592 VAREQV(UI1,1,UI1,0,UI1,254);
4593 VAREQV(UI1,0,UI1,1,UI1,254);
4594 if (HAVE_OLEAUT32_I8)
4596 VAREQV(UI4,VARIANT_FALSE,I8,VARIANT_FALSE,I8,-1);
4597 VAREQV(UI4,5,I8,19,I8,-23);
4598 VAREQV(UI4,VARIANT_FALSE,UI8,VARIANT_FALSE,I4,-1);
4602 static HRESULT (WINAPI *pVarMul)(LPVARIANT,LPVARIANT,LPVARIANT);
4604 static const char *szVarMulI4 = "VarMul(%d,%d): expected 0x0,%d,%d, got 0x%X,%d,%d\n";
4605 static const char *szVarMulR8 = "VarMul(%d,%d): expected 0x0,%d,%f, got 0x%X,%d,%f\n";
4607 #define VARMUL(vt1,val1,vt2,val2,rvt,rval) \
4608 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
4609 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
4610 memset(&result,0,sizeof(result)); hres = pVarMul(&left,&right,&result); \
4611 if (VT_##rvt == VT_R4 || VT_##rvt == VT_R8) { \
4612 ok(hres == S_OK && V_VT(&result) == VT_##rvt && \
4613 EQ_FLOAT(V_##rvt(&result), rval), \
4614 szVarMulR8, VT_##vt1, VT_##vt2, \
4615 VT_##rvt, (double)(rval), hres, V_VT(&result), (double)V_##rvt(&result)); \
4617 ok(hres == S_OK && V_VT(&result) == VT_##rvt && V_##rvt(&result) == (rval), \
4618 szVarMulI4, VT_##vt1, VT_##vt2, \
4619 VT_##rvt, (int)(rval), hres, V_VT(&result), (int)V_##rvt(&result)); }
4621 static void test_VarMul(void)
4623 static const WCHAR sz12[] = {'1','2','\0'};
4624 VARIANT left, right, result, cy, dec;
4632 lbstr = SysAllocString(sz12);
4633 rbstr = SysAllocString(sz12);
4635 /* Test all possible flag/vt combinations & the resulting vt type */
4636 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
4638 VARTYPE leftvt, rightvt, resvt;
4640 for (leftvt = 0; leftvt <= VT_BSTR_BLOB; leftvt++)
4645 for (rightvt = 0; rightvt <= VT_BSTR_BLOB; rightvt++)
4651 if (leftvt == VT_DISPATCH || rightvt == VT_DISPATCH ||
4652 leftvt == VT_UNKNOWN || rightvt == VT_UNKNOWN)
4655 memset(&left, 0, sizeof(left));
4656 memset(&right, 0, sizeof(right));
4657 V_VT(&left) = leftvt | ExtraFlags[i];
4658 if (leftvt == VT_BSTR)
4659 V_BSTR(&left) = lbstr;
4660 V_VT(&right) = rightvt | ExtraFlags[i];
4661 if (rightvt == VT_BSTR)
4662 V_BSTR(&right) = rbstr;
4663 V_VT(&result) = VT_EMPTY;
4666 /* Don't ask me why but native VarMul cannot handle:
4667 VT_I1, VT_UI2, VT_UI4, VT_INT, VT_UINT and VT_UI8.
4668 Tested with DCOM98, Win2k, WinXP */
4669 if (ExtraFlags[i] & VT_ARRAY || ExtraFlags[i] & VT_BYREF ||
4670 !IsValidVariantClearVT(leftvt, ExtraFlags[i]) ||
4671 !IsValidVariantClearVT(rightvt, ExtraFlags[i]) ||
4672 leftvt == VT_CLSID || rightvt == VT_CLSID ||
4673 leftvt == VT_RECORD || rightvt == VT_RECORD ||
4674 leftvt == VT_VARIANT || rightvt == VT_VARIANT ||
4675 leftvt == VT_ERROR || rightvt == VT_ERROR ||
4676 leftvt == VT_I1 || rightvt == VT_I1 ||
4677 leftvt == VT_UI2 || rightvt == VT_UI2 ||
4678 leftvt == VT_UI4 || rightvt == VT_UI4 ||
4679 leftvt == VT_UI8 || rightvt == VT_UI8 ||
4680 leftvt == VT_INT || rightvt == VT_INT ||
4681 leftvt == VT_UINT || rightvt == VT_UINT) {
4685 if (leftvt == VT_NULL || rightvt == VT_NULL)
4687 else if (leftvt == VT_DECIMAL || rightvt == VT_DECIMAL)
4689 else if (leftvt == VT_R8 || rightvt == VT_R8 ||
4690 leftvt == VT_BSTR || rightvt == VT_BSTR ||
4691 leftvt == VT_DATE || rightvt == VT_DATE)
4693 else if (leftvt == VT_R4 || rightvt == VT_R4) {
4694 if (leftvt == VT_I4 || rightvt == VT_I4 ||
4695 leftvt == VT_I8 || rightvt == VT_I8 ||
4696 leftvt == VT_CY || rightvt == VT_CY)
4700 } else if (leftvt == VT_CY || rightvt == VT_CY)
4702 else if (leftvt == VT_I8 || rightvt == VT_I8)
4704 else if (leftvt == VT_I4 || rightvt == VT_I4)
4706 else if (leftvt == VT_I2 || rightvt == VT_I2 ||
4707 leftvt == VT_BOOL || rightvt == VT_BOOL ||
4708 (leftvt == VT_EMPTY && rightvt == VT_EMPTY))
4710 else if (leftvt == VT_UI1 || rightvt == VT_UI1)
4713 hres = pVarMul(&left, &right, &result);
4715 ok(hres == DISP_E_TYPEMISMATCH || hres == DISP_E_BADVARTYPE,
4716 "VarMul: %d|0x%X, %d|0x%X: Expected failure, got 0x%X vt %d\n",
4717 leftvt, ExtraFlags[i], rightvt, ExtraFlags[i], hres,
4720 ok(hres == S_OK && V_VT(&result) == resvt,
4721 "VarMul: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%X vt %d\n",
4722 leftvt, ExtraFlags[i], rightvt, ExtraFlags[i], resvt, hres,
4729 /* Test returned values */
4730 VARMUL(I4,4,I4,2,I4,8);
4731 VARMUL(I2,4,I2,2,I2,8);
4732 VARMUL(I2,-13,I4,5,I4,-65);
4733 VARMUL(I4,-13,I4,5,I4,-65);
4734 VARMUL(I2,7,R4,0.5,R4,3.5);
4735 VARMUL(R4,0.5,I4,5,R8,2.5);
4736 VARMUL(R8,7.1,BOOL,0,R8,0);
4737 VARMUL(BSTR,lbstr,I2,4,R8,48);
4738 VARMUL(BSTR,lbstr,BOOL,1,R8,12);
4739 VARMUL(BSTR,lbstr,R4,0.1,R8,1.2);
4740 VARMUL(BSTR,lbstr,BSTR,rbstr,R8,144);
4741 VARMUL(R4,0.2,BSTR,rbstr,R8,2.4);
4742 VARMUL(DATE,2.25,I4,7,R8,15.75);
4744 VARMUL(UI1, UI1_MAX, UI1, UI1_MAX, I4, UI1_MAX * UI1_MAX);
4745 VARMUL(I2, I2_MAX, I2, I2_MAX, I4, I2_MAX * I2_MAX);
4746 VARMUL(I2, I2_MAX, I2, I2_MIN, I4, I2_MAX * I2_MIN);
4747 VARMUL(I2, I2_MIN, I2, I2_MIN, I4, I2_MIN * I2_MIN);
4748 VARMUL(I4, I4_MAX, I4, I4_MAX, R8, (double)I4_MAX * I4_MAX);
4749 VARMUL(I4, I4_MAX, I4, I4_MIN, R8, (double)I4_MAX * I4_MIN);
4750 VARMUL(I4, I4_MIN, I4, I4_MIN, R8, (double)I4_MIN * I4_MIN);
4751 VARMUL(R4, R4_MAX, R4, R4_MAX, R8, (double)R4_MAX * R4_MAX);
4752 VARMUL(R4, R4_MAX, R4, R4_MIN, R4, R4_MAX * R4_MIN);
4753 VARMUL(R4, R4_MIN, R4, R4_MIN, R4, R4_MIN * R4_MIN);
4754 VARMUL(R8, R8_MAX, R8, R8_MIN, R8, R8_MAX * R8_MIN);
4755 VARMUL(R8, R8_MIN, R8, R8_MIN, R8, R8_MIN * R8_MIN);
4757 /* Manuly test some VT_CY and VT_DECIMAL variants */
4759 hres = VarCyFromI4(4711, &V_CY(&cy));
4760 ok(hres == S_OK, "VarCyFromI4 failed!\n");
4761 V_VT(&dec) = VT_DECIMAL;
4762 hres = VarDecFromR8(-4.2, &V_DECIMAL(&dec));
4763 ok(hres == S_OK, "VarDecFromR4 failed!\n");
4764 memset(&left, 0, sizeof(left));
4765 memset(&right, 0, sizeof(right));
4766 V_VT(&left) = VT_I4;
4768 V_VT(&right) = VT_UI1;
4771 hres = VarMul(&cy, &right, &result);
4772 ok(hres == S_OK && V_VT(&result) == VT_CY, "VarMul: expected coerced type VT_CY, got %s!\n", vtstr(V_VT(&result)));
4773 hres = VarR8FromCy(V_CY(&result), &r);
4774 ok(hres == S_OK && EQ_DOUBLE(r, 42399), "VarMul: CY value %f, expected %f\n", r, (double)42399);
4776 hres = VarMul(&left, &dec, &result);
4777 ok(hres == S_OK && V_VT(&result) == VT_DECIMAL, "VarMul: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result)));
4778 hres = VarR8FromDec(&V_DECIMAL(&result), &r);
4779 ok(hres == S_OK && EQ_DOUBLE(r, 46.2), "VarMul: DECIMAL value %f, expected %f\n", r, (double)46.2);
4781 SysFreeString(lbstr);
4782 SysFreeString(rbstr);
4785 static HRESULT (WINAPI *pVarAdd)(LPVARIANT,LPVARIANT,LPVARIANT);
4787 static const char *szVarAddI4 = "VarAdd(%d,%d): expected 0x0,%d,%d, got 0x%X,%d,%d\n";
4788 static const char *szVarAddR8 = "VarAdd(%d,%d): expected 0x0,%d,%f, got 0x%X,%d,%f\n";
4790 #define VARADD(vt1,val1,vt2,val2,rvt,rval) \
4791 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
4792 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
4793 memset(&result,0,sizeof(result)); hres = pVarAdd(&left,&right,&result); \
4794 if (VT_##rvt == VT_R4 || VT_##rvt == VT_R8 || VT_##rvt == VT_DATE) { \
4795 ok(hres == S_OK && V_VT(&result) == VT_##rvt && \
4796 EQ_FLOAT(V_##rvt(&result), rval), \
4797 szVarAddR8, VT_##vt1, VT_##vt2, \
4798 VT_##rvt, (double)(rval), hres, V_VT(&result), (double)V_##rvt(&result)); \
4800 ok(hres == S_OK && V_VT(&result) == VT_##rvt && V_##rvt(&result) == (rval), \
4801 szVarAddI4, VT_##vt1, VT_##vt2, \
4802 VT_##rvt, (int)(rval), hres, V_VT(&result), (int)V_##rvt(&result)); }
4804 static void test_VarAdd(void)
4806 static const WCHAR sz12[] = {'1','2','\0'};
4807 VARIANT left, right, result, cy, dec;
4815 lbstr = SysAllocString(sz12);
4816 rbstr = SysAllocString(sz12);
4818 /* Test all possible flag/vt combinations & the resulting vt type */
4819 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
4821 VARTYPE leftvt, rightvt, resvt;
4823 for (leftvt = 0; leftvt <= VT_BSTR_BLOB; leftvt++)
4828 for (rightvt = 0; rightvt <= VT_BSTR_BLOB; rightvt++)
4834 if (leftvt == VT_UNKNOWN || rightvt == VT_UNKNOWN)
4837 memset(&left, 0, sizeof(left));
4838 memset(&right, 0, sizeof(right));
4839 V_VT(&left) = leftvt | ExtraFlags[i];
4840 if (leftvt == VT_BSTR)
4841 V_BSTR(&left) = lbstr;
4842 V_VT(&right) = rightvt | ExtraFlags[i];
4843 if (rightvt == VT_BSTR)
4844 V_BSTR(&right) = rbstr;
4845 V_VT(&result) = VT_EMPTY;
4848 /* Don't ask me why but native VarAdd cannot handle:
4849 VT_I1, VT_UI2, VT_UI4, VT_INT, VT_UINT and VT_UI8.
4850 Tested with DCOM98, Win2k, WinXP */
4851 if (ExtraFlags[i] & VT_ARRAY || ExtraFlags[i] & VT_BYREF ||
4852 !IsValidVariantClearVT(leftvt, ExtraFlags[i]) ||
4853 !IsValidVariantClearVT(rightvt, ExtraFlags[i]) ||
4854 leftvt == VT_CLSID || rightvt == VT_CLSID ||
4855 leftvt == VT_RECORD || rightvt == VT_RECORD ||
4856 leftvt == VT_VARIANT || rightvt == VT_VARIANT ||
4857 leftvt == VT_ERROR || rightvt == VT_ERROR ||
4858 leftvt == VT_I1 || rightvt == VT_I1 ||
4859 leftvt == VT_UI2 || rightvt == VT_UI2 ||
4860 leftvt == VT_UI4 || rightvt == VT_UI4 ||
4861 leftvt == VT_UI8 || rightvt == VT_UI8 ||
4862 leftvt == VT_INT || rightvt == VT_INT ||
4863 leftvt == VT_UINT || rightvt == VT_UINT) {
4867 if (leftvt == VT_NULL || rightvt == VT_NULL)
4869 else if (leftvt == VT_DISPATCH || rightvt == VT_DISPATCH)
4871 else if (leftvt == VT_DECIMAL || rightvt == VT_DECIMAL)
4873 else if (leftvt == VT_DATE || rightvt == VT_DATE)
4875 else if (leftvt == VT_CY || rightvt == VT_CY)
4877 else if (leftvt == VT_R8 || rightvt == VT_R8)
4879 else if (leftvt == VT_BSTR || rightvt == VT_BSTR) {
4880 if ((leftvt == VT_BSTR && rightvt == VT_BSTR) ||
4881 leftvt == VT_EMPTY || rightvt == VT_EMPTY)
4885 } else if (leftvt == VT_R4 || rightvt == VT_R4) {
4886 if (leftvt == VT_I4 || rightvt == VT_I4 ||
4887 leftvt == VT_I8 || rightvt == VT_I8)
4892 else if (leftvt == VT_I8 || rightvt == VT_I8)
4894 else if (leftvt == VT_I4 || rightvt == VT_I4)
4896 else if (leftvt == VT_I2 || rightvt == VT_I2 ||
4897 leftvt == VT_BOOL || rightvt == VT_BOOL ||
4898 (leftvt == VT_EMPTY && rightvt == VT_EMPTY))
4900 else if (leftvt == VT_UI1 || rightvt == VT_UI1)
4903 hres = pVarAdd(&left, &right, &result);
4905 ok(hres == DISP_E_TYPEMISMATCH || hres == DISP_E_BADVARTYPE,
4906 "VarAdd: %d|0x%X, %d|0x%X: Expected failure, got 0x%X vt %d\n",
4907 leftvt, ExtraFlags[i], rightvt, ExtraFlags[i], hres,
4910 ok(hres == S_OK && V_VT(&result) == resvt,
4911 "VarAdd: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%X vt %d\n",
4912 leftvt, ExtraFlags[i], rightvt, ExtraFlags[i], resvt, hres,
4919 /* Test returned values */
4920 VARADD(I4,4,I4,2,I4,6);
4921 VARADD(I2,4,I2,2,I2,6);
4922 VARADD(I2,-13,I4,5,I4,-8);
4923 VARADD(I4,-13,I4,5,I4,-8);
4924 VARADD(I2,7,R4,0.5,R4,7.5);
4925 VARADD(R4,0.5,I4,5,R8,5.5);
4926 VARADD(R8,7.1,BOOL,0,R8,7.1);
4927 VARADD(BSTR,lbstr,I2,4,R8,16);
4928 VARADD(BSTR,lbstr,BOOL,1,R8,13);
4929 VARADD(BSTR,lbstr,R4,0.1,R8,12.1);
4930 VARADD(R4,0.2,BSTR,rbstr,R8,12.2);
4931 VARADD(DATE,2.25,I4,7,DATE,9.25);
4932 VARADD(DATE,1.25,R4,-1.7,DATE,-0.45);
4934 VARADD(UI1, UI1_MAX, UI1, UI1_MAX, I2, UI1_MAX + UI1_MAX);
4935 VARADD(I2, I2_MAX, I2, I2_MAX, I4, I2_MAX + I2_MAX);
4936 VARADD(I2, I2_MAX, I2, I2_MIN, I2, I2_MAX + I2_MIN);
4937 VARADD(I2, I2_MIN, I2, I2_MIN, I4, I2_MIN + I2_MIN);
4938 VARADD(I4, I4_MAX, I4, I4_MIN, I4, I4_MAX + I4_MIN);
4939 VARADD(I4, I4_MAX, I4, I4_MAX, R8, (double)I4_MAX + I4_MAX);
4940 VARADD(I4, I4_MIN, I4, I4_MIN, R8, (double)I4_MIN + I4_MIN);
4941 VARADD(R4, R4_MAX, R4, R4_MAX, R8, (double)R4_MAX + R4_MAX);
4942 VARADD(R4, R4_MAX, R4, R4_MIN, R4, R4_MAX + R4_MIN);
4943 VARADD(R4, R4_MIN, R4, R4_MIN, R4, R4_MIN + R4_MIN);
4944 VARADD(R8, R8_MAX, R8, R8_MIN, R8, R8_MAX + R8_MIN);
4945 VARADD(R8, R8_MIN, R8, R8_MIN, R8, R8_MIN + R8_MIN);
4947 /* Manualy test BSTR + BSTR */
4948 V_VT(&left) = VT_BSTR;
4949 V_BSTR(&left) = lbstr;
4950 V_VT(&right) = VT_BSTR;
4951 V_BSTR(&right) = rbstr;
4952 hres = VarAdd(&left, &right, &result);
4953 ok(hres == S_OK && V_VT(&result) == VT_BSTR, "VarAdd: expected coerced type VT_BSTR, got %s!\n", vtstr(V_VT(&result)));
4954 hres = VarR8FromStr(V_BSTR(&result), 0, 0, &r);
4955 ok(hres == S_OK && EQ_DOUBLE(r, 1212), "VarAdd: BSTR value %f, expected %f\n", r, (double)1212);
4957 /* Manuly test some VT_CY and VT_DECIMAL variants */
4959 hres = VarCyFromI4(4711, &V_CY(&cy));
4960 ok(hres == S_OK, "VarCyFromI4 failed!\n");
4961 V_VT(&dec) = VT_DECIMAL;
4962 hres = VarDecFromR8(-4.2, &V_DECIMAL(&dec));
4963 ok(hres == S_OK, "VarDecFromR4 failed!\n");
4964 memset(&left, 0, sizeof(left));
4965 memset(&right, 0, sizeof(right));
4966 V_VT(&left) = VT_I4;
4968 V_VT(&right) = VT_UI1;
4971 hres = VarAdd(&cy, &right, &result);
4972 ok(hres == S_OK && V_VT(&result) == VT_CY, "VarAdd: expected coerced type VT_CY, got %s!\n", vtstr(V_VT(&result)));
4973 hres = VarR8FromCy(V_CY(&result), &r);
4974 ok(hres == S_OK && EQ_DOUBLE(r, 4720), "VarAdd: CY value %f, expected %f\n", r, (double)4720);
4976 hres = VarAdd(&left, &dec, &result);
4977 ok(hres == S_OK && V_VT(&result) == VT_DECIMAL, "VarAdd: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result)));
4978 hres = VarR8FromDec(&V_DECIMAL(&result), &r);
4979 ok(hres == S_OK && EQ_DOUBLE(r, -15.2), "VarAdd: DECIMAL value %f, expected %f\n", r, (double)-15.2);
4981 SysFreeString(lbstr);
4982 SysFreeString(rbstr);
4985 static void test_VarCat(void)
4988 VARIANT left, right, result, expected;
4989 static const WCHAR sz12[] = {'1','2','\0'};
4990 static const WCHAR sz34[] = {'3','4','\0'};
4991 static const WCHAR sz1234[] = {'1','2','3','4','\0'};
4992 static const WCHAR date_sz12[] = {'9','/','3','0','/','1','9','8','0','1','2','\0'};
4993 static const WCHAR sz12_date[] = {'1','2','9','/','3','0','/','1','9','8','0','\0'};
4994 static const WCHAR sz_empty[] = {'\0'};
4995 static const WCHAR sz12_true[] = {'1','2','T','r','u','e','\0'};
4996 static const WCHAR sz12_false[] = {'1','2','F','a','l','s','e','\0'};
4997 TCHAR orig_date_format[128];
4998 VARTYPE leftvt, rightvt, resultvt;
5000 HRESULT expected_error_num;
5002 /* Set date format for testing */
5003 lcid = LOCALE_USER_DEFAULT;
5004 GetLocaleInfo(lcid,LOCALE_SSHORTDATE,orig_date_format,128);
5005 SetLocaleInfo(lcid,LOCALE_SSHORTDATE,"M/d/yyyy");
5008 VariantInit(&right);
5009 VariantInit(&result);
5010 VariantInit(&expected);
5012 /* Check expected types for all combinations */
5013 for (leftvt = 0; leftvt <= VT_BSTR_BLOB; leftvt++)
5018 for (rightvt = 0; rightvt <= VT_BSTR_BLOB; rightvt++)
5022 expected_error_num = S_OK;
5023 resultvt = VT_EMPTY;
5025 if (leftvt == VT_DISPATCH || rightvt == VT_DISPATCH ||
5026 leftvt == VT_UNKNOWN || rightvt == VT_UNKNOWN ||
5027 leftvt == VT_RECORD || rightvt == VT_RECORD ||
5028 leftvt == 15 || rightvt == 15 /* Undefined type */)
5031 if (leftvt == VT_NULL && rightvt == VT_NULL)
5033 else if (leftvt == VT_VARIANT && (rightvt == VT_ERROR ||
5034 rightvt == VT_DATE || rightvt == VT_DECIMAL))
5035 expected_error_num = DISP_E_TYPEMISMATCH;
5036 else if ((leftvt == VT_I2 || leftvt == VT_I4 ||
5037 leftvt == VT_R4 || leftvt == VT_R8 ||
5038 leftvt == VT_CY || leftvt == VT_BOOL ||
5039 leftvt == VT_BSTR || leftvt == VT_I1 ||
5040 leftvt == VT_UI1 || leftvt == VT_UI2 ||
5041 leftvt == VT_UI4 || leftvt == VT_I8 ||
5042 leftvt == VT_UI8 || leftvt == VT_INT ||
5043 leftvt == VT_UINT || leftvt == VT_EMPTY ||
5044 leftvt == VT_NULL || leftvt == VT_DECIMAL ||
5047 (rightvt == VT_I2 || rightvt == VT_I4 ||
5048 rightvt == VT_R4 || rightvt == VT_R8 ||
5049 rightvt == VT_CY || rightvt == VT_BOOL ||
5050 rightvt == VT_BSTR || rightvt == VT_I1 ||
5051 rightvt == VT_UI1 || rightvt == VT_UI2 ||
5052 rightvt == VT_UI4 || rightvt == VT_I8 ||
5053 rightvt == VT_UI8 || rightvt == VT_INT ||
5054 rightvt == VT_UINT || rightvt == VT_EMPTY ||
5055 rightvt == VT_NULL || rightvt == VT_DECIMAL ||
5056 rightvt == VT_DATE))
5058 else if (rightvt == VT_ERROR && leftvt < VT_VOID)
5059 expected_error_num = DISP_E_TYPEMISMATCH;
5060 else if (leftvt == VT_ERROR && (rightvt == VT_DATE ||
5061 rightvt == VT_ERROR || rightvt == VT_DECIMAL))
5062 expected_error_num = DISP_E_TYPEMISMATCH;
5063 else if (rightvt == VT_DATE || rightvt == VT_ERROR ||
5064 rightvt == VT_DECIMAL)
5065 expected_error_num = DISP_E_BADVARTYPE;
5066 else if (leftvt == VT_ERROR || rightvt == VT_ERROR)
5067 expected_error_num = DISP_E_TYPEMISMATCH;
5068 else if (leftvt == VT_VARIANT)
5069 expected_error_num = DISP_E_TYPEMISMATCH;
5070 else if (rightvt == VT_VARIANT && (leftvt == VT_EMPTY ||
5071 leftvt == VT_NULL || leftvt == VT_I2 ||
5072 leftvt == VT_I4 || leftvt == VT_R4 ||
5073 leftvt == VT_R8 || leftvt == VT_CY ||
5074 leftvt == VT_DATE || leftvt == VT_BSTR ||
5075 leftvt == VT_BOOL || leftvt == VT_DECIMAL ||
5076 leftvt == VT_I1 || leftvt == VT_UI1 ||
5077 leftvt == VT_UI2 || leftvt == VT_UI4 ||
5078 leftvt == VT_I8 || leftvt == VT_UI8 ||
5079 leftvt == VT_INT || leftvt == VT_UINT
5081 expected_error_num = DISP_E_TYPEMISMATCH;
5083 expected_error_num = DISP_E_BADVARTYPE;
5085 V_VT(&left) = leftvt;
5086 V_VT(&right) = rightvt;
5088 if (leftvt == VT_BSTR)
5089 V_BSTR(&left) = SysAllocString(sz_empty);
5090 if (rightvt == VT_BSTR)
5091 V_BSTR(&right) = SysAllocString(sz_empty);
5092 if (leftvt == VT_DATE)
5093 V_DATE(&left) = 0.0;
5094 if (rightvt == VT_DATE)
5095 V_DATE(&right) = 0.0;
5096 if (leftvt == VT_DECIMAL)
5097 VarDecFromR8(0.0, &V_DECIMAL(&left));
5098 if (rightvt == VT_DECIMAL)
5099 VarDecFromR8(0.0, &V_DECIMAL(&right));
5101 hres = VarCat(&left, &right, &result);
5103 /* Determine the error code for the vt combination */
5104 ok(hres == expected_error_num,
5105 "VarCat: %d, %d returned error, 0x%X expected 0x%X.\n",
5106 leftvt, rightvt, expected_error_num, hres);
5108 /* Check types are correct */
5109 ok(V_VT(&result) == resultvt,
5110 "VarCat: %d, %d: expected vt %d, got vt %d\n",
5111 leftvt, rightvt, resultvt, V_VT(&result));
5113 VariantClear(&left);
5114 VariantClear(&right);
5115 VariantClear(&result);
5119 /* Runnning single comparison tests to compare outputs */
5121 /* Test concat strings */
5122 V_VT(&left) = VT_BSTR;
5123 V_VT(&right) = VT_BSTR;
5124 V_VT(&expected) = VT_BSTR;
5125 V_BSTR(&left) = SysAllocString(sz12);
5126 V_BSTR(&right) = SysAllocString(sz34);
5127 V_BSTR(&expected) = SysAllocString(sz1234);
5128 hres = VarCat(&left,&right,&result);
5129 ok(hres == S_OK, "VarCat failed with error 0x%08x\n", hres);
5130 ok(VarCmp(&result,&expected,lcid,0) == VARCMP_EQ,
5131 "VarCat: VT_BSTR concat with VT_BSTR failed to return correct result\n");
5133 VariantClear(&left);
5134 VariantClear(&right);
5135 VariantClear(&result);
5137 /* Test if expression is VT_ERROR */
5138 V_VT(&left) = VT_ERROR;
5139 V_VT(&right) = VT_BSTR;
5140 V_BSTR(&right) = SysAllocString(sz1234);
5141 hres = VarCat(&left,&right,&result);
5142 ok(hres == DISP_E_TYPEMISMATCH, "VarCat should have returned DISP_E_TYPEMISMATCH instead of 0x%08x\n", hres);
5143 ok(V_VT(&result) == VT_EMPTY,
5144 "VarCat: VT_ERROR concat with VT_BSTR should have returned VT_EMPTY\n");
5146 VariantClear(&left);
5147 VariantClear(&right);
5148 VariantClear(&result);
5150 V_VT(&left) = VT_BSTR;
5151 V_VT(&right) = VT_ERROR;
5152 V_BSTR(&left) = SysAllocString(sz1234);
5153 hres = VarCat(&left,&right,&result);
5154 ok(hres == DISP_E_TYPEMISMATCH, "VarCat should have returned DISP_E_TYPEMISMATCH instead of 0x%08x\n", hres);
5155 ok(V_VT(&result) == VT_EMPTY,
5156 "VarCat: VT_BSTR concat with VT_ERROR should have returned VT_EMPTY\n");
5158 VariantClear(&left);
5159 VariantClear(&right);
5160 VariantClear(&result);
5161 VariantClear(&expected);
5163 /* Test combining boolean with number */
5164 V_VT(&left) = VT_INT;
5165 V_VT(&right) = VT_BOOL;
5166 V_VT(&expected) = VT_BSTR;
5168 V_BOOL(&right) = TRUE;
5169 V_BSTR(&expected) = SysAllocString(sz12_true);
5170 hres = VarCat(&left,&right,&result);
5171 ok(hres == S_OK, "VarCat failed with error 0x%08x\n", hres);
5172 ok(VarCmp(&result,&expected,lcid,0) == VARCMP_EQ,
5173 "VarCat: VT_INT concat with VT_BOOL (TRUE) returned inncorrect result\n");
5175 VariantClear(&left);
5176 VariantClear(&right);
5177 VariantClear(&result);
5178 VariantClear(&expected);
5180 V_VT(&left) = VT_INT;
5181 V_VT(&right) = VT_BOOL;
5182 V_VT(&expected) = VT_BSTR;
5184 V_BOOL(&right) = FALSE;
5185 V_BSTR(&expected) = SysAllocString(sz12_false);
5186 hres = VarCat(&left,&right,&result);
5187 ok(hres == S_OK, "VarCat failed with error 0x%08x\n", hres);
5188 ok(VarCmp(&result,&expected,lcid,0) == VARCMP_EQ,
5189 "VarCat: VT_INT concat with VT_BOOL (FALSE) returned inncorrect result\n");
5191 VariantClear(&left);
5192 VariantClear(&right);
5193 VariantClear(&result);
5194 VariantClear(&expected);
5196 /* Test when both expressions are numeric */
5197 V_VT(&left) = VT_INT;
5198 V_VT(&right) = VT_INT;
5199 V_VT(&expected) = VT_BSTR;
5202 V_BSTR(&expected) = SysAllocString(sz1234);
5203 hres = VarCat(&left,&right,&result);
5204 ok(hres == S_OK, "VarCat failed with error 0x%08x\n", hres);
5205 ok(VarCmp(&result,&expected,lcid,0) == VARCMP_EQ,
5206 "VarCat: NUMBER concat with NUMBER returned inncorrect result\n");
5208 VariantClear(&left);
5209 VariantClear(&right);
5210 VariantClear(&result);
5212 /* Test if one expression is numeric and the other is a string */
5213 V_VT(&left) = VT_INT;
5214 V_VT(&right) = VT_BSTR;
5216 V_BSTR(&right) = SysAllocString(sz34);
5217 hres = VarCat(&left,&right,&result);
5218 ok(hres == S_OK, "VarCat failed with error 0x%08x\n", hres);
5219 ok(VarCmp(&result,&expected,lcid,0) == VARCMP_EQ,
5220 "VarCat: NUMBER concat with VT_BSTR, inncorrect result\n");
5222 VariantClear(&left);
5223 VariantClear(&right);
5224 VariantClear(&result);
5226 V_VT(&left) = VT_BSTR;
5227 V_VT(&right) = VT_INT;
5228 V_BSTR(&left) = SysAllocString(sz12);
5230 hres = VarCat(&left,&right,&result);
5231 ok(hres == S_OK, "VarCat failed with error 0x%08x\n", hres);
5232 ok(VarCmp(&result,&expected,lcid,0) == VARCMP_EQ,
5233 "VarCat: VT_BSTR concat with NUMBER, inncorrect result\n");
5235 VariantClear(&left);
5236 VariantClear(&right);
5237 VariantClear(&result);
5239 /* Test concat dates with strings */
5240 V_VT(&left) = VT_BSTR;
5241 V_VT(&right) = VT_DATE;
5242 V_VT(&expected) = VT_BSTR;
5243 V_BSTR(&left) = SysAllocString(sz12);
5244 V_DATE(&right) = 29494.0;
5245 V_BSTR(&expected)= SysAllocString(sz12_date);
5246 hres = VarCat(&left,&right,&result);
5247 ok(hres == S_OK, "VarCat failed with error 0x%08x\n", hres);
5248 ok(VarCmp(&result,&expected,lcid,0) == VARCMP_EQ,
5249 "VarCat: VT_BSTR concat with VT_DATE returned inncorrect result\n");
5251 VariantClear(&left);
5252 VariantClear(&right);
5253 VariantClear(&result);
5254 VariantClear(&expected);
5256 V_VT(&left) = VT_DATE;
5257 V_VT(&right) = VT_BSTR;
5258 V_VT(&expected) = VT_BSTR;
5259 V_DATE(&left) = 29494.0;
5260 V_BSTR(&right) = SysAllocString(sz12);
5261 V_BSTR(&expected)= SysAllocString(date_sz12);
5262 hres = VarCat(&left,&right,&result);
5263 ok(hres == S_OK, "VarCat failed with error 0x%08x\n", hres);
5264 ok(VarCmp(&result,&expected,lcid,0) == VARCMP_EQ,
5265 "VarCat: VT_DATE concat with VT_BSTR returned inncorrect result\n");
5267 VariantClear(&left);
5268 VariantClear(&right);
5269 VariantClear(&result);
5270 VariantClear(&expected);
5272 /* Test of both expressions are empty */
5273 V_VT(&left) = VT_BSTR;
5274 V_VT(&right) = VT_BSTR;
5275 V_VT(&expected) = VT_BSTR;
5276 V_BSTR(&left) = SysAllocString(sz_empty);
5277 V_BSTR(&right) = SysAllocString(sz_empty);
5278 V_BSTR(&expected)= SysAllocString(sz_empty);
5279 hres = VarCat(&left,&right,&result);
5280 ok(hres == S_OK, "VarCat failed with error 0x%08x\n", hres);
5281 ok(VarCmp(&result,&left,lcid,0) == VARCMP_EQ,
5282 "VarCat: EMPTY concat with EMPTY did not return empty VT_BSTR\n");
5284 /* Restore original date format settings */
5285 SetLocaleInfo(lcid,LOCALE_SSHORTDATE,orig_date_format);
5287 VariantClear(&left);
5288 VariantClear(&right);
5289 VariantClear(&result);
5290 VariantClear(&expected);
5293 static HRESULT (WINAPI *pVarAnd)(LPVARIANT,LPVARIANT,LPVARIANT);
5295 static const char *szVarAndFail = "VarAnd(%s,%s): expected 0x0,%s,%d, got 0x%X,%s,%d\n";
5297 #define VARAND(vt1,val1,vt2,val2,rvt,rval) \
5298 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
5299 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
5300 memset(&result,0,sizeof(result)); hres = pVarAnd(&left,&right,&result); \
5301 ok(hres == S_OK && V_VT(&result) == VT_##rvt && V_##rvt(&result) == (rval), \
5302 szVarAndFail, vtstr(VT_##vt1), vtstr(VT_##vt2), \
5303 vtstr(VT_##rvt), (int)(rval), hres, vtstr(V_VT(&result)), (int)V_##rvt(&result));
5304 #define VARANDCY(vt1,val1,val2,rvt,rval) \
5305 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
5306 V_VT(&right) = VT_CY; V_CY(&right).int64 = val2; \
5307 memset(&result,0,sizeof(result)); hres = pVarAnd(&left,&right,&result); \
5308 ok(hres == S_OK && V_VT(&result) == VT_##rvt && V_##rvt(&result) == (rval), \
5309 szVarAndFail, vtstr(VT_##vt1), vtstr(VT_CY), \
5310 vtstr(VT_##rvt), (int)(rval), hres, vtstr(V_VT(&result)), (int)V_##rvt(&result));
5312 /* Skip any type that is not defined or produces a error for every case */
5313 #define SKIPTESTAND(a) \
5314 if (a == VT_ERROR || a == VT_VARIANT || \
5315 a == VT_DISPATCH || a == VT_UNKNOWN || \
5316 a > VT_UINT || a == 15 /*not defined*/) \
5319 static void test_VarAnd(void)
5321 static const WCHAR szFalse[] = { '#','F','A','L','S','E','#','\0' };
5322 static const WCHAR szTrue[] = { '#','T','R','U','E','#','\0' };
5323 VARIANT left, right, result;
5324 BSTR false_str, true_str;
5328 true_str = SysAllocString(szTrue);
5329 false_str = SysAllocString(szFalse);
5333 /* Test all possible flag/vt combinations & the resulting vt type */
5334 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
5336 VARTYPE leftvt, rightvt, resvt;
5338 for (leftvt = 0; leftvt <= VT_BSTR_BLOB; leftvt++)
5340 SKIPTESTAND(leftvt);
5342 for (rightvt = 0; rightvt <= VT_BSTR_BLOB; rightvt++)
5345 SKIPTESTAND(rightvt);
5347 memset(&left, 0, sizeof(left));
5348 memset(&right, 0, sizeof(right));
5349 V_VT(&left) = leftvt | ExtraFlags[i];
5350 V_VT(&right) = rightvt | ExtraFlags[i];
5351 V_VT(&result) = VT_EMPTY;
5353 if (leftvt == VT_BSTR)
5354 V_BSTR(&left) = true_str;
5355 if (rightvt == VT_BSTR)
5356 V_BSTR(&right) = true_str;
5358 /* Native VarAnd always returns a error when using any extra
5359 * flags or if the variant combination is I8 and INT.
5361 if ((leftvt == VT_I8 && rightvt == VT_INT) ||
5362 (leftvt == VT_INT && rightvt == VT_I8) ||
5366 /* Determine return type */
5367 else if (leftvt == VT_I8 || rightvt == VT_I8)
5369 else if (leftvt == VT_I4 || rightvt == VT_I4 ||
5370 leftvt == VT_UINT || rightvt == VT_UINT ||
5371 leftvt == VT_INT || rightvt == VT_INT ||
5372 leftvt == VT_UINT || rightvt == VT_UINT ||
5373 leftvt == VT_R4 || rightvt == VT_R4 ||
5374 leftvt == VT_R8 || rightvt == VT_R8 ||
5375 leftvt == VT_CY || rightvt == VT_CY ||
5376 leftvt == VT_DATE || rightvt == VT_DATE ||
5377 leftvt == VT_I1 || rightvt == VT_I1 ||
5378 leftvt == VT_UI2 || rightvt == VT_UI2 ||
5379 leftvt == VT_UI4 || rightvt == VT_UI4 ||
5380 leftvt == VT_UI8 || rightvt == VT_UI8 ||
5381 leftvt == VT_DECIMAL || rightvt == VT_DECIMAL)
5383 else if (leftvt == VT_UI1 || rightvt == VT_UI1 ||
5384 leftvt == VT_I2 || rightvt == VT_I2 ||
5385 leftvt == VT_EMPTY || rightvt == VT_EMPTY)
5386 if ((leftvt == VT_NULL && rightvt == VT_UI1) ||
5387 (leftvt == VT_UI1 && rightvt == VT_NULL) ||
5388 (leftvt == VT_UI1 && rightvt == VT_UI1))
5392 else if (leftvt == VT_BOOL || rightvt == VT_BOOL ||
5393 (leftvt == VT_BSTR && rightvt == VT_BSTR))
5395 else if (leftvt == VT_NULL || rightvt == VT_NULL ||
5396 leftvt == VT_BSTR || rightvt == VT_BSTR)
5401 hres = pVarAnd(&left, &right, &result);
5403 /* Check expected HRESULT and if result variant type is correct */
5405 ok (hres == DISP_E_BADVARTYPE || hres == DISP_E_TYPEMISMATCH,
5406 "VarAnd: %s|0x%X, %s|0x%X: got vt %s hr 0x%X\n",
5407 vtstr(leftvt), ExtraFlags[i], vtstr(rightvt), ExtraFlags[i],
5408 vtstr(V_VT(&result)), hres);
5410 ok (hres == S_OK && resvt == V_VT(&result),
5411 "VarAnd: %s|0x%X, %s|0x%X: expected vt %s hr 0x%X, got vt %s hr 0x%X\n",
5412 vtstr(leftvt), ExtraFlags[i], vtstr(rightvt), ExtraFlags[i], vtstr(resvt),
5413 S_OK, vtstr(V_VT(&result)), hres);
5419 * Test returned values. Since we know the returned type is correct
5420 * and that we handle all combinations of invalid types, just check
5421 * that good type combinations produce the desired value.
5422 * FIXME: Test VT_DECIMAL
5424 VARAND(EMPTY,0,EMPTY,0,I2,0);
5425 VARAND(EMPTY,1,EMPTY,0,I2,0);
5426 VARAND(EMPTY,1,EMPTY,1,I2,0);
5427 VARAND(EMPTY,0,NULL,0,I2,0);
5428 VARAND(EMPTY,1,NULL,0,I2,0);
5429 VARAND(EMPTY,1,NULL,1,I2,0);
5430 VARAND(EMPTY,0,I1,0,I4,0);
5431 VARAND(EMPTY,0,I1,1,I4,0);
5432 VARAND(EMPTY,1,I1,1,I4,0);
5433 VARAND(EMPTY,0,UI1,0,I2,0);
5434 VARAND(EMPTY,0,UI1,1,I2,0);
5435 VARAND(EMPTY,1,UI1,1,I2,0);
5436 VARAND(EMPTY,0,I2,0,I2,0);
5437 VARAND(EMPTY,0,I2,1,I2,0);
5438 VARAND(EMPTY,1,I2,1,I2,0);
5439 VARAND(EMPTY,0,UI2,0,I4,0);
5440 VARAND(EMPTY,0,UI2,1,I4,0);
5441 VARAND(EMPTY,1,UI2,1,I4,0);
5442 VARAND(EMPTY,0,I4,0,I4,0);
5443 VARAND(EMPTY,0,I4,1,I4,0);
5444 VARAND(EMPTY,1,I4,1,I4,0);
5445 VARAND(EMPTY,0,UI4,0,I4,0);
5446 VARAND(EMPTY,0,UI4,1,I4,0);
5447 VARAND(EMPTY,1,UI4,1,I4,0);
5448 if (HAVE_OLEAUT32_I8)
5450 VARAND(EMPTY,0,I8,0,I8,0);
5451 VARAND(EMPTY,0,I8,1,I8,0);
5452 VARAND(EMPTY,1,I8,1,I8,0);
5453 VARAND(EMPTY,0,UI8,0,I4,0);
5454 VARAND(EMPTY,0,UI8,1,I4,0);
5455 VARAND(EMPTY,1,UI8,1,I4,0);
5457 VARAND(EMPTY,0,INT,0,I4,0);
5458 VARAND(EMPTY,0,INT,1,I4,0);
5459 VARAND(EMPTY,1,INT,1,I4,0);
5460 VARAND(EMPTY,0,UINT,0,I4,0);
5461 VARAND(EMPTY,0,UINT,1,I4,0);
5462 VARAND(EMPTY,1,UINT,1,I4,0);
5463 VARAND(EMPTY,0,BOOL,0,I2,0);
5464 VARAND(EMPTY,0,BOOL,1,I2,0);
5465 VARAND(EMPTY,1,BOOL,1,I2,0);
5466 VARAND(EMPTY,0,R4,0,I4,0);
5467 VARAND(EMPTY,0,R4,1,I4,0);
5468 VARAND(EMPTY,1,R4,1,I4,0);
5469 VARAND(EMPTY,0,R8,0,I4,0);
5470 VARAND(EMPTY,0,R8,1,I4,0);
5471 VARAND(EMPTY,1,R8,1,I4,0);
5472 VARAND(EMPTY,0,BSTR,false_str,I2,0);
5473 VARAND(EMPTY,0,BSTR,true_str,I2,0);
5474 VARANDCY(EMPTY,0,10000,I4,0);
5476 /* NULL OR 0 = NULL. NULL OR n = n */
5477 VARAND(NULL,0,NULL,0,NULL,0);
5478 VARAND(NULL,1,NULL,0,NULL,0);
5479 VARAND(NULL,0,I1,0,I4,0);
5480 VARAND(NULL,0,I1,1,NULL,0);
5481 VARAND(NULL,0,UI1,0,UI1,0);
5482 VARAND(NULL,0,UI1,1,NULL,0);
5483 VARAND(NULL,0,I2,0,I2,0);
5484 VARAND(NULL,0,I2,1,NULL,0);
5485 VARAND(NULL,0,UI2,0,I4,0);
5486 VARAND(NULL,0,UI2,1,NULL,0);
5487 VARAND(NULL,0,I4,0,I4,0);
5488 VARAND(NULL,0,I4,1,NULL,0);
5489 VARAND(NULL,0,UI4,0,I4,0);
5490 VARAND(NULL,0,UI4,1,NULL,0);
5491 if (HAVE_OLEAUT32_I8)
5493 VARAND(NULL,0,I8,0,I8,0);
5494 VARAND(NULL,0,I8,1,NULL,0);
5495 VARAND(NULL,0,UI8,0,I4,0);
5496 VARAND(NULL,0,UI8,1,NULL,0);
5498 VARAND(NULL,0,INT,0,I4,0);
5499 VARAND(NULL,0,INT,1,NULL,0);
5500 VARAND(NULL,0,UINT,0,I4,0);
5501 VARAND(NULL,0,UINT,1,NULL,0);
5502 VARAND(NULL,0,BOOL,0,BOOL,0);
5503 VARAND(NULL,0,BOOL,1,NULL,0);
5504 VARAND(NULL,0,R4,0,I4,0);
5505 VARAND(NULL,0,R4,1,NULL,0);
5506 VARAND(NULL,0,R8,0,I4,0);
5507 VARAND(NULL,0,R8,1,NULL,0);
5508 VARAND(NULL,0,BSTR,false_str,BOOL,0);
5509 VARAND(NULL,0,BSTR,true_str,NULL,VARIANT_FALSE);
5510 VARANDCY(NULL,0,10000,NULL,0);
5511 VARANDCY(NULL,0,0,I4,0);
5512 VARAND(BOOL,VARIANT_TRUE,BOOL,VARIANT_TRUE,BOOL,VARIANT_TRUE);
5513 VARAND(BOOL,VARIANT_TRUE,BOOL,VARIANT_FALSE,BOOL,VARIANT_FALSE);
5514 VARAND(BOOL,VARIANT_FALSE,BOOL,VARIANT_TRUE,BOOL,VARIANT_FALSE);
5515 VARAND(BOOL,VARIANT_FALSE,BOOL,VARIANT_FALSE,BOOL,VARIANT_FALSE);
5517 /* Assume x,y & y,x are the same from now on to reduce the number of tests */
5518 VARAND(BOOL,VARIANT_TRUE,I1,-1,I4,-1);
5519 VARAND(BOOL,VARIANT_TRUE,I1,0,I4,0);
5520 VARAND(BOOL,VARIANT_FALSE,I1,0,I4,0);
5521 VARAND(BOOL,VARIANT_TRUE,UI1,255,I2,255);
5522 VARAND(BOOL,VARIANT_TRUE,UI1,0,I2,0);
5523 VARAND(BOOL,VARIANT_FALSE,UI1,0,I2,0);
5524 VARAND(BOOL,VARIANT_TRUE,I2,-1,I2,-1);
5525 VARAND(BOOL,VARIANT_TRUE,I2,0,I2,0);
5526 VARAND(BOOL,VARIANT_FALSE,I2,0,I2,0);
5527 VARAND(BOOL,VARIANT_TRUE,UI2,65535,I4,65535);
5528 VARAND(BOOL,VARIANT_TRUE,UI2,0,I4,0);
5529 VARAND(BOOL,VARIANT_FALSE,UI2,0,I4,0);
5530 VARAND(BOOL,VARIANT_TRUE,I4,-1,I4,-1);
5531 VARAND(BOOL,VARIANT_TRUE,I4,0,I4,0);
5532 VARAND(BOOL,VARIANT_FALSE,I4,0,I4,0);
5533 VARAND(BOOL,VARIANT_TRUE,UI4,0xffffffff,I4,-1);
5534 VARAND(BOOL,VARIANT_TRUE,UI4,0,I4,0);
5535 VARAND(BOOL,VARIANT_FALSE,UI4,0,I4,0);
5536 VARAND(BOOL,VARIANT_TRUE,R4,-1,I4,-1);
5537 VARAND(BOOL,VARIANT_TRUE,R4,0,I4,0);
5538 VARAND(BOOL,VARIANT_FALSE,R4,0,I4,0);
5539 VARAND(BOOL,VARIANT_TRUE,R8,-1,I4,-1);
5540 VARAND(BOOL,VARIANT_TRUE,R8,0,I4,0);
5541 VARAND(BOOL,VARIANT_FALSE,R8,0,I4,0);
5542 VARAND(BOOL,VARIANT_TRUE,DATE,-1,I4,-1);
5543 VARAND(BOOL,VARIANT_TRUE,DATE,0,I4,0);
5544 VARAND(BOOL,VARIANT_FALSE,DATE,0,I4,0);
5545 if (HAVE_OLEAUT32_I8)
5547 VARAND(BOOL,VARIANT_TRUE,I8,-1,I8,-1);
5548 VARAND(BOOL,VARIANT_TRUE,I8,0,I8,0);
5549 VARAND(BOOL,VARIANT_FALSE,I8,0,I8,0);
5550 VARAND(BOOL,VARIANT_TRUE,UI8,0,I4,0);
5551 VARAND(BOOL,VARIANT_FALSE,UI8,0,I4,0);
5553 VARAND(BOOL,VARIANT_TRUE,INT,-1,I4,-1);
5554 VARAND(BOOL,VARIANT_TRUE,INT,0,I4,0);
5555 VARAND(BOOL,VARIANT_FALSE,INT,0,I4,0);
5556 VARAND(BOOL,VARIANT_TRUE,UINT,0xffffffff,I4,-1);
5557 VARAND(BOOL,VARIANT_TRUE,UINT,0,I4,0);
5558 VARAND(BOOL,VARIANT_FALSE,UINT,0,I4,0);
5559 VARAND(BOOL,VARIANT_FALSE,BSTR,false_str,BOOL,VARIANT_FALSE);
5560 VARAND(BOOL,VARIANT_TRUE,BSTR,false_str,BOOL,VARIANT_FALSE);
5561 VARAND(BOOL,VARIANT_FALSE,BSTR,true_str,BOOL,VARIANT_FALSE);
5562 VARAND(BOOL,VARIANT_TRUE,BSTR,true_str,BOOL,VARIANT_TRUE);
5563 VARANDCY(BOOL,VARIANT_TRUE,10000,I4,1);
5564 VARANDCY(BOOL,VARIANT_TRUE,0,I4,0);
5565 VARANDCY(BOOL,VARIANT_FALSE,0,I4,0);
5566 VARAND(I1,-1,I1,-1,I4,-1);
5567 VARAND(I1,-1,I1,0,I4,0);
5568 VARAND(I1,0,I1,0,I4,0);
5569 VARAND(I1,-1,UI1,255,I4,255);
5570 VARAND(I1,-1,UI1,0,I4,0);
5571 VARAND(I1,0,UI1,0,I4,0);
5572 VARAND(I1,-1,I2,-1,I4,-1);
5573 VARAND(I1,-1,I2,0,I4,0);
5574 VARAND(I1,0,I2,0,I4,0);
5575 VARAND(I1,-1,UI2,65535,I4,65535);
5576 VARAND(I1,-1,UI2,0,I4,0);
5577 VARAND(I1,0,UI2,0,I4,0);
5578 VARAND(I1,-1,I4,-1,I4,-1);
5579 VARAND(I1,-1,I4,0,I4,0);
5580 VARAND(I1,0,I4,0,I4,0);
5581 VARAND(I1,-1,UI4,0xffffffff,I4,-1);
5582 VARAND(I1,-1,UI4,0,I4,0);
5583 VARAND(I1,0,UI4,0,I4,0);
5584 VARAND(I1,-1,R4,-1,I4,-1);
5585 VARAND(I1,-1,R4,0,I4,0);
5586 VARAND(I1,0,R4,0,I4,0);
5587 VARAND(I1,-1,R8,-1,I4,-1);
5588 VARAND(I1,-1,R8,0,I4,0);
5589 VARAND(I1,0,R8,0,I4,0);
5590 VARAND(I1,-1,DATE,-1,I4,-1);
5591 VARAND(I1,-1,DATE,0,I4,0);
5592 VARAND(I1,0,DATE,0,I4,0);
5593 if (HAVE_OLEAUT32_I8)
5595 VARAND(I1,-1,I8,-1,I8,-1);
5596 VARAND(I1,-1,I8,0,I8,0);
5597 VARAND(I1,0,I8,0,I8,0);
5598 VARAND(I1,-1,UI8,0,I4,0);
5599 VARAND(I1,0,UI8,0,I4,0);
5601 VARAND(I1,-1,INT,-1,I4,-1);
5602 VARAND(I1,-1,INT,0,I4,0);
5603 VARAND(I1,0,INT,0,I4,0);
5604 VARAND(I1,-1,UINT,0xffffffff,I4,-1);
5605 VARAND(I1,-1,UINT,0,I4,0);
5606 VARAND(I1,0,UINT,0,I4,0);
5607 VARAND(I1,0,BSTR,false_str,I4,0);
5608 VARAND(I1,-1,BSTR,false_str,I4,0);
5609 VARAND(I1,0,BSTR,true_str,I4,0);
5610 VARAND(I1,-1,BSTR,true_str,I4,-1);
5611 VARANDCY(I1,-1,10000,I4,1);
5612 VARANDCY(I1,-1,0,I4,0);
5613 VARANDCY(I1,0,0,I4,0);
5615 VARAND(UI1,255,UI1,255,UI1,255);
5616 VARAND(UI1,255,UI1,0,UI1,0);
5617 VARAND(UI1,0,UI1,0,UI1,0);
5618 VARAND(UI1,255,I2,-1,I2,255);
5619 VARAND(UI1,255,I2,0,I2,0);
5620 VARAND(UI1,0,I2,0,I2,0);
5621 VARAND(UI1,255,UI2,65535,I4,255);
5622 VARAND(UI1,255,UI2,0,I4,0);
5623 VARAND(UI1,0,UI2,0,I4,0);
5624 VARAND(UI1,255,I4,-1,I4,255);
5625 VARAND(UI1,255,I4,0,I4,0);
5626 VARAND(UI1,0,I4,0,I4,0);
5627 VARAND(UI1,255,UI4,0xffffffff,I4,255);
5628 VARAND(UI1,255,UI4,0,I4,0);
5629 VARAND(UI1,0,UI4,0,I4,0);
5630 VARAND(UI1,255,R4,-1,I4,255);
5631 VARAND(UI1,255,R4,0,I4,0);
5632 VARAND(UI1,0,R4,0,I4,0);
5633 VARAND(UI1,255,R8,-1,I4,255);
5634 VARAND(UI1,255,R8,0,I4,0);
5635 VARAND(UI1,0,R8,0,I4,0);
5636 VARAND(UI1,255,DATE,-1,I4,255);
5637 VARAND(UI1,255,DATE,0,I4,0);
5638 VARAND(UI1,0,DATE,0,I4,0);
5639 if (HAVE_OLEAUT32_I8)
5641 VARAND(UI1,255,I8,-1,I8,255);
5642 VARAND(UI1,255,I8,0,I8,0);
5643 VARAND(UI1,0,I8,0,I8,0);
5644 VARAND(UI1,255,UI8,0,I4,0);
5645 VARAND(UI1,0,UI8,0,I4,0);
5647 VARAND(UI1,255,INT,-1,I4,255);
5648 VARAND(UI1,255,INT,0,I4,0);
5649 VARAND(UI1,0,INT,0,I4,0);
5650 VARAND(UI1,255,UINT,0xffffffff,I4,255);
5651 VARAND(UI1,255,UINT,0,I4,0);
5652 VARAND(UI1,0,UINT,0,I4,0);
5653 VARAND(UI1,0,BSTR,false_str,I2,0);
5654 VARAND(UI1,255,BSTR,false_str,I2,0);
5655 VARAND(UI1,0,BSTR,true_str,I2,0);
5656 VARAND(UI1,255,BSTR,true_str,I2,255);
5657 VARANDCY(UI1,255,10000,I4,1);
5658 VARANDCY(UI1,255,0,I4,0);
5659 VARANDCY(UI1,0,0,I4,0);
5661 VARAND(I2,-1,I2,-1,I2,-1);
5662 VARAND(I2,-1,I2,0,I2,0);
5663 VARAND(I2,0,I2,0,I2,0);
5664 VARAND(I2,-1,UI2,65535,I4,65535);
5665 VARAND(I2,-1,UI2,0,I4,0);
5666 VARAND(I2,0,UI2,0,I4,0);
5667 VARAND(I2,-1,I4,-1,I4,-1);
5668 VARAND(I2,-1,I4,0,I4,0);
5669 VARAND(I2,0,I4,0,I4,0);
5670 VARAND(I2,-1,UI4,0xffffffff,I4,-1);
5671 VARAND(I2,-1,UI4,0,I4,0);
5672 VARAND(I2,0,UI4,0,I4,0);
5673 VARAND(I2,-1,R4,-1,I4,-1);
5674 VARAND(I2,-1,R4,0,I4,0);
5675 VARAND(I2,0,R4,0,I4,0);
5676 VARAND(I2,-1,R8,-1,I4,-1);
5677 VARAND(I2,-1,R8,0,I4,0);
5678 VARAND(I2,0,R8,0,I4,0);
5679 VARAND(I2,-1,DATE,-1,I4,-1);
5680 VARAND(I2,-1,DATE,0,I4,0);
5681 VARAND(I2,0,DATE,0,I4,0);
5682 if (HAVE_OLEAUT32_I8)
5684 VARAND(I2,-1,I8,-1,I8,-1);
5685 VARAND(I2,-1,I8,0,I8,0);
5686 VARAND(I2,0,I8,0,I8,0);
5687 VARAND(I2,-1,UI8,0,I4,0);
5688 VARAND(I2,0,UI8,0,I4,0);
5690 VARAND(I2,-1,INT,-1,I4,-1);
5691 VARAND(I2,-1,INT,0,I4,0);
5692 VARAND(I2,0,INT,0,I4,0);
5693 VARAND(I2,-1,UINT,0xffffffff,I4,-1);
5694 VARAND(I2,-1,UINT,0,I4,0);
5695 VARAND(I2,0,UINT,0,I4,0);
5696 VARAND(I2,0,BSTR,false_str,I2,0);
5697 VARAND(I2,-1,BSTR,false_str,I2,0);
5698 VARAND(I2,0,BSTR,true_str,I2,0);
5699 VARAND(I2,-1,BSTR,true_str,I2,-1);
5700 VARANDCY(I2,-1,10000,I4,1);
5701 VARANDCY(I2,-1,0,I4,0);
5702 VARANDCY(I2,0,0,I4,0);
5704 VARAND(UI2,65535,UI2,65535,I4,65535);
5705 VARAND(UI2,65535,UI2,0,I4,0);
5706 VARAND(UI2,0,UI2,0,I4,0);
5707 VARAND(UI2,65535,I4,-1,I4,65535);
5708 VARAND(UI2,65535,I4,0,I4,0);
5709 VARAND(UI2,0,I4,0,I4,0);
5710 VARAND(UI2,65535,UI4,0xffffffff,I4,65535);
5711 VARAND(UI2,65535,UI4,0,I4,0);
5712 VARAND(UI2,0,UI4,0,I4,0);
5713 VARAND(UI2,65535,R4,-1,I4,65535);
5714 VARAND(UI2,65535,R4,0,I4,0);
5715 VARAND(UI2,0,R4,0,I4,0);
5716 VARAND(UI2,65535,R8,-1,I4,65535);
5717 VARAND(UI2,65535,R8,0,I4,0);
5718 VARAND(UI2,0,R8,0,I4,0);
5719 VARAND(UI2,65535,DATE,-1,I4,65535);
5720 VARAND(UI2,65535,DATE,0,I4,0);
5721 VARAND(UI2,0,DATE,0,I4,0);
5722 if (HAVE_OLEAUT32_I8)
5724 VARAND(UI2,65535,I8,-1,I8,65535);
5725 VARAND(UI2,65535,I8,0,I8,0);
5726 VARAND(UI2,0,I8,0,I8,0);
5727 VARAND(UI2,65535,UI8,0,I4,0);
5728 VARAND(UI2,0,UI8,0,I4,0);
5730 VARAND(UI2,65535,INT,-1,I4,65535);
5731 VARAND(UI2,65535,INT,0,I4,0);
5732 VARAND(UI2,0,INT,0,I4,0);
5733 VARAND(UI2,65535,UINT,0xffffffff,I4,65535);
5734 VARAND(UI2,65535,UINT,0,I4,0);
5735 VARAND(UI2,0,UINT,0,I4,0);
5736 VARAND(UI2,0,BSTR,false_str,I4,0);
5737 VARAND(UI2,65535,BSTR,false_str,I4,0);
5738 VARAND(UI2,0,BSTR,true_str,I4,0);
5739 VARAND(UI2,65535,BSTR,true_str,I4,65535);
5740 VARANDCY(UI2,65535,10000,I4,1);
5741 VARANDCY(UI2,65535,0,I4,0);
5742 VARANDCY(UI2,0,0,I4,0);
5744 VARAND(I4,-1,I4,-1,I4,-1);
5745 VARAND(I4,-1,I4,0,I4,0);
5746 VARAND(I4,0,I4,0,I4,0);
5747 VARAND(I4,-1,UI4,0xffffffff,I4,-1);
5748 VARAND(I4,-1,UI4,0,I4,0);
5749 VARAND(I4,0,UI4,0,I4,0);
5750 VARAND(I4,-1,R4,-1,I4,-1);
5751 VARAND(I4,-1,R4,0,I4,0);
5752 VARAND(I4,0,R4,0,I4,0);
5753 VARAND(I4,-1,R8,-1,I4,-1);
5754 VARAND(I4,-1,R8,0,I4,0);
5755 VARAND(I4,0,R8,0,I4,0);
5756 VARAND(I4,-1,DATE,-1,I4,-1);
5757 VARAND(I4,-1,DATE,0,I4,0);
5758 VARAND(I4,0,DATE,0,I4,0);
5759 if (HAVE_OLEAUT32_I8)
5761 VARAND(I4,-1,I8,-1,I8,-1);
5762 VARAND(I4,-1,I8,0,I8,0);
5763 VARAND(I4,0,I8,0,I8,0);
5764 VARAND(I4,-1,UI8,0,I4,0);
5765 VARAND(I4,0,UI8,0,I4,0);
5767 VARAND(I4,-1,INT,-1,I4,-1);
5768 VARAND(I4,-1,INT,0,I4,0);
5769 VARAND(I4,0,INT,0,I4,0);
5770 VARAND(I4,-1,UINT,0xffffffff,I4,-1);
5771 VARAND(I4,-1,UINT,0,I4,0);
5772 VARAND(I4,0,UINT,0,I4,0);
5773 VARAND(I4,0,BSTR,false_str,I4,0);
5774 VARAND(I4,-1,BSTR,false_str,I4,0);
5775 VARAND(I4,0,BSTR,true_str,I4,0);
5776 VARAND(I4,-1,BSTR,true_str,I4,-1);
5777 VARANDCY(I4,-1,10000,I4,1);
5778 VARANDCY(I4,-1,0,I4,0);
5779 VARANDCY(I4,0,0,I4,0);
5781 VARAND(UI4,0xffffffff,UI4,0xffffffff,I4,-1);
5782 VARAND(UI4,0xffffffff,UI4,0,I4,0);
5783 VARAND(UI4,0,UI4,0,I4,0);
5784 VARAND(UI4,0xffffffff,R4,-1,I4,-1);
5785 VARAND(UI4,0xffffffff,R4,0,I4,0);
5786 VARAND(UI4,0,R4,0,I4,0);
5787 VARAND(UI4,0xffffffff,R8,-1,I4,-1);
5788 VARAND(UI4,0xffffffff,R8,0,I4,0);
5789 VARAND(UI4,0,R8,0,I4,0);
5790 VARAND(UI4,0xffffffff,DATE,-1,I4,-1);
5791 VARAND(UI4,0xffffffff,DATE,0,I4,0);
5792 VARAND(UI4,0,DATE,0,I4,0);
5793 if (HAVE_OLEAUT32_I8)
5795 VARAND(UI4,0xffffffff,I8,0,I8,0);
5796 VARAND(UI4,0,I8,0,I8,0);
5797 VARAND(UI4,0xffffffff,UI8,0,I4,0);
5798 VARAND(UI4,0,UI8,0,I4,0);
5800 VARAND(UI4,0xffffffff,INT,-1,I4,-1);
5801 VARAND(UI4,0xffffffff,INT,0,I4,0);
5802 VARAND(UI4,0,INT,0,I4,0);
5803 VARAND(UI4,0xffffffff,UINT,0xffffffff,I4,-1);
5804 VARAND(UI4,0xffffffff,UINT,0,I4,0);
5805 VARAND(UI4,0,UINT,0,I4,0);
5806 VARAND(UI4,0,BSTR,false_str,I4,0);
5807 VARAND(UI4,0xffffffff,BSTR,false_str,I4,0);
5808 VARAND(UI4,0,BSTR,true_str,I4,0);
5809 VARAND(UI4,0xffffffff,BSTR,true_str,I4,-1);
5810 VARANDCY(UI4,0xffffffff,10000,I4,1);
5811 VARANDCY(UI4,0xffffffff,0,I4,0);
5812 VARANDCY(UI4,0,0,I4,0);
5814 VARAND(R4,-1,R4,-1,I4,-1);
5815 VARAND(R4,-1,R4,0,I4,0);
5816 VARAND(R4,0,R4,0,I4,0);
5817 VARAND(R4,-1,R8,-1,I4,-1);
5818 VARAND(R4,-1,R8,0,I4,0);
5819 VARAND(R4,0,R8,0,I4,0);
5820 VARAND(R4,-1,DATE,-1,I4,-1);
5821 VARAND(R4,-1,DATE,0,I4,0);
5822 VARAND(R4,0,DATE,0,I4,0);
5823 if (HAVE_OLEAUT32_I8)
5825 VARAND(R4,-1,I8,-1,I8,-1);
5826 VARAND(R4,-1,I8,0,I8,0);
5827 VARAND(R4,0,I8,0,I8,0);
5828 VARAND(R4,-1,UI8,0,I4,0);
5829 VARAND(R4,0,UI8,0,I4,0);
5831 VARAND(R4,-1,INT,-1,I4,-1);
5832 VARAND(R4,-1,INT,0,I4,0);
5833 VARAND(R4,0,INT,0,I4,0);
5834 VARAND(R4,-1,UINT,0xffffffff,I4,-1);
5835 VARAND(R4,-1,UINT,0,I4,0);
5836 VARAND(R4,0,UINT,0,I4,0);
5837 VARAND(R4,0,BSTR,false_str,I4,0);
5838 VARAND(R4,-1,BSTR,false_str,I4,0);
5839 VARAND(R4,0,BSTR,true_str,I4,0);
5840 VARAND(R4,-1,BSTR,true_str,I4,-1);
5841 VARANDCY(R4,-1,10000,I4,1);
5842 VARANDCY(R4,-1,0,I4,0);
5843 VARANDCY(R4,0,0,I4,0);
5845 VARAND(R8,-1,R8,-1,I4,-1);
5846 VARAND(R8,-1,R8,0,I4,0);
5847 VARAND(R8,0,R8,0,I4,0);
5848 VARAND(R8,-1,DATE,-1,I4,-1);
5849 VARAND(R8,-1,DATE,0,I4,0);
5850 VARAND(R8,0,DATE,0,I4,0);
5851 if (HAVE_OLEAUT32_I8)
5853 VARAND(R8,-1,I8,-1,I8,-1);
5854 VARAND(R8,-1,I8,0,I8,0);
5855 VARAND(R8,0,I8,0,I8,0);
5856 VARAND(R8,-1,UI8,0,I4,0);
5857 VARAND(R8,0,UI8,0,I4,0);
5859 VARAND(R8,-1,INT,-1,I4,-1);
5860 VARAND(R8,-1,INT,0,I4,0);
5861 VARAND(R8,0,INT,0,I4,0);
5862 VARAND(R8,-1,UINT,0xffffffff,I4,-1);
5863 VARAND(R8,-1,UINT,0,I4,0);
5864 VARAND(R8,0,UINT,0,I4,0);
5865 VARAND(R8,0,BSTR,false_str,I4,0);
5866 VARAND(R8,-1,BSTR,false_str,I4,0);
5867 VARAND(R8,0,BSTR,true_str,I4,0);
5868 VARAND(R8,-1,BSTR,true_str,I4,-1);
5869 VARANDCY(R8,-1,10000,I4,1);
5870 VARANDCY(R8,-1,0,I4,0);
5871 VARANDCY(R8,0,0,I4,0);
5873 VARAND(DATE,-1,DATE,-1,I4,-1);
5874 VARAND(DATE,-1,DATE,0,I4,0);
5875 VARAND(DATE,0,DATE,0,I4,0);
5876 if (HAVE_OLEAUT32_I8)
5878 VARAND(DATE,-1,I8,-1,I8,-1);
5879 VARAND(DATE,-1,I8,0,I8,0);
5880 VARAND(DATE,0,I8,0,I8,0);
5881 VARAND(DATE,-1,UI8,0,I4,0);
5882 VARAND(DATE,0,UI8,0,I4,0);
5884 VARAND(DATE,-1,INT,-1,I4,-1);
5885 VARAND(DATE,-1,INT,0,I4,0);
5886 VARAND(DATE,0,INT,0,I4,0);
5887 VARAND(DATE,-1,UINT,0xffffffff,I4,-1);
5888 VARAND(DATE,-1,UINT,0,I4,0);
5889 VARAND(DATE,0,UINT,0,I4,0);
5890 VARAND(DATE,0,BSTR,false_str,I4,0);
5891 VARAND(DATE,-1,BSTR,false_str,I4,0);
5892 VARAND(DATE,0,BSTR,true_str,I4,0);
5893 VARAND(DATE,-1,BSTR,true_str,I4,-1);
5894 VARANDCY(DATE,-1,10000,I4,1);
5895 VARANDCY(DATE,-1,0,I4,0);
5896 VARANDCY(DATE,0,0,I4,0);
5898 if (HAVE_OLEAUT32_I8)
5900 VARAND(I8,-1,I8,-1,I8,-1);
5901 VARAND(I8,-1,I8,0,I8,0);
5902 VARAND(I8,0,I8,0,I8,0);
5903 VARAND(I8,-1,UI8,0,I8,0);
5904 VARAND(I8,0,UI8,0,I8,0);
5905 VARAND(I8,-1,UINT,0,I8,0);
5906 VARAND(I8,0,UINT,0,I8,0);
5907 VARAND(I8,0,BSTR,false_str,I8,0);
5908 VARAND(I8,-1,BSTR,false_str,I8,0);
5909 VARAND(I8,0,BSTR,true_str,I8,0);
5910 VARAND(I8,-1,BSTR,true_str,I8,-1);
5911 VARANDCY(I8,-1,10000,I8,1);
5912 VARANDCY(I8,-1,0,I8,0);
5913 VARANDCY(I8,0,0,I8,0);
5915 VARAND(UI8,0xffff,UI8,0xffff,I4,0xffff);
5916 VARAND(UI8,0xffff,UI8,0,I4,0);
5917 VARAND(UI8,0,UI8,0,I4,0);
5918 VARAND(UI8,0xffff,INT,-1,I4,65535);
5919 VARAND(UI8,0xffff,INT,0,I4,0);
5920 VARAND(UI8,0,INT,0,I4,0);
5921 VARAND(UI8,0xffff,UINT,0xffff,I4,0xffff);
5922 VARAND(UI8,0xffff,UINT,0,I4,0);
5923 VARAND(UI8,0,UINT,0,I4,0);
5924 VARAND(UI8,0,BSTR,false_str,I4,0);
5925 VARAND(UI8,0xffff,BSTR,false_str,I4,0);
5926 VARAND(UI8,0,BSTR,true_str,I4,0);
5927 VARAND(UI8,0xffff,BSTR,true_str,I4,65535);
5928 VARANDCY(UI8,0xffff,10000,I4,1);
5929 VARANDCY(UI8,0xffff,0,I4,0);
5930 VARANDCY(UI8,0,0,I4,0);
5933 VARAND(INT,-1,INT,-1,I4,-1);
5934 VARAND(INT,-1,INT,0,I4,0);
5935 VARAND(INT,0,INT,0,I4,0);
5936 VARAND(INT,-1,UINT,0xffff,I4,65535);
5937 VARAND(INT,-1,UINT,0,I4,0);
5938 VARAND(INT,0,UINT,0,I4,0);
5939 VARAND(INT,0,BSTR,false_str,I4,0);
5940 VARAND(INT,-1,BSTR,false_str,I4,0);
5941 VARAND(INT,0,BSTR,true_str,I4,0);
5942 VARAND(INT,-1,BSTR,true_str,I4,-1);
5943 VARANDCY(INT,-1,10000,I4,1);
5944 VARANDCY(INT,-1,0,I4,0);
5945 VARANDCY(INT,0,0,I4,0);
5947 VARAND(UINT,0xffff,UINT,0xffff,I4,0xffff);
5948 VARAND(UINT,0xffff,UINT,0,I4,0);
5949 VARAND(UINT,0,UINT,0,I4,0);
5950 VARAND(UINT,0,BSTR,false_str,I4,0);
5951 VARAND(UINT,0xffff,BSTR, false_str,I4,0);
5952 VARAND(UINT,0,BSTR,true_str,I4,0);
5953 VARAND(UINT,0xffff,BSTR,true_str,I4,65535);
5954 VARANDCY(UINT,0xffff,10000,I4,1);
5955 VARANDCY(UINT,0xffff,0,I4,0);
5956 VARANDCY(UINT,0,0,I4,0);
5958 VARAND(BSTR,false_str,BSTR,false_str,BOOL,0);
5959 VARAND(BSTR,true_str,BSTR,false_str,BOOL,VARIANT_FALSE);
5960 VARAND(BSTR,true_str,BSTR,true_str,BOOL,VARIANT_TRUE);
5961 VARANDCY(BSTR,true_str,10000,I4,1);
5962 VARANDCY(BSTR,false_str,10000,I4,0);
5964 SysFreeString(true_str);
5965 SysFreeString(false_str);
5968 static HRESULT (WINAPI *pVarCmp)(LPVARIANT,LPVARIANT,LCID,ULONG);
5970 /* ERROR from wingdi.h is interfering here */
5972 #define _VARCMP(vt1,val1,vtfl1,vt2,val2,vtfl2,lcid,flags,result) \
5973 V_##vt1(&left) = val1; V_VT(&left) = VT_##vt1 | vtfl1; \
5974 V_##vt2(&right) = val2; V_VT(&right) = VT_##vt2 | vtfl2; \
5975 hres = pVarCmp(&left,&right,lcid,flags); \
5976 ok(hres == result, "VarCmp(VT_" #vt1 "|" #vtfl1 ",VT_" #vt2 "|" #vtfl2 "): expected " #result ", got hres=0x%x\n", hres)
5977 #define VARCMPEX(vt1,val1,vt2,val2,res1,res2,res3,res4) \
5978 _VARCMP(vt1,val1,0,vt2,val2,0,lcid,0,res1); \
5979 _VARCMP(vt1,val1,VT_RESERVED,vt2,val2,0,lcid,0,res2); \
5980 _VARCMP(vt1,val1,0,vt2,val2,VT_RESERVED,lcid,0,res3); \
5981 _VARCMP(vt1,val1,VT_RESERVED,vt2,val2,VT_RESERVED,lcid,0,res4)
5982 #define VARCMP(vt1,val1,vt2,val2,result) \
5983 VARCMPEX(vt1,val1,vt2,val2,result,result,result,result)
5984 /* The above macros do not work for VT_NULL as NULL gets expanded first */
5985 #define V_NULL_ V_NULL
5986 #define VT_NULL_ VT_NULL
5988 static void test_VarCmp(void)
5990 VARIANT left, right;
5995 static const WCHAR szhuh[] = {'h','u','h','?','\0'};
5996 static const WCHAR sz2cents[] = {'2','c','e','n','t','s','\0'};
5997 static const WCHAR szempty[] = {'\0'};
5998 static const WCHAR sz0[] = {'0','\0'};
5999 static const WCHAR sz1[] = {'1','\0'};
6000 static const WCHAR sz7[] = {'7','\0'};
6001 static const WCHAR sz42[] = {'4','2','\0'};
6002 static const WCHAR sz1neg[] = {'-','1','\0'};
6003 static const WCHAR sz666neg[] = {'-','6','6','6','\0'};
6004 static const WCHAR sz1few[] = {'1','.','0','0','0','0','0','0','0','1','\0'};
6005 BSTR bstrhuh, bstrempty, bstr0, bstr1, bstr7, bstr42, bstr1neg, bstr666neg;
6006 BSTR bstr2cents, bstr1few;
6010 lcid = MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT);
6011 bstrempty = SysAllocString(szempty);
6012 bstrhuh = SysAllocString(szhuh);
6013 bstr2cents = SysAllocString(sz2cents);
6014 bstr0 = SysAllocString(sz0);
6015 bstr1 = SysAllocString(sz1);
6016 bstr7 = SysAllocString(sz7);
6017 bstr42 = SysAllocString(sz42);
6018 bstr1neg = SysAllocString(sz1neg);
6019 bstr666neg = SysAllocString(sz666neg);
6020 bstr1few = SysAllocString(sz1few);
6022 /* Test all possible flag/vt combinations & the resulting vt type */
6023 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
6025 VARTYPE leftvt, rightvt;
6027 for (leftvt = 0; leftvt <= VT_BSTR_BLOB; leftvt++)
6032 for (rightvt = 0; rightvt <= VT_BSTR_BLOB; rightvt++)
6035 HRESULT expect = VARCMP_EQ;
6039 memset(&left, 0, sizeof(left));
6040 memset(&right, 0, sizeof(right));
6041 V_VT(&left) = leftvt | ExtraFlags[i];
6042 if (leftvt == VT_BSTR) {
6043 V_BSTR(&left) = bstr1neg;
6044 if (ExtraFlags[i] & VT_RESERVED)
6049 V_VT(&right) = rightvt | ExtraFlags[i];
6050 if (rightvt == VT_BSTR) {
6051 V_BSTR(&right) = bstr1neg;
6052 if (ExtraFlags[i] & VT_RESERVED)
6058 /* Don't ask me why but native VarCmp cannot handle:
6059 VT_I1, VT_UI2, VT_UI4, VT_UINT and VT_UI8.
6060 VT_INT is only supported as left variant. Go figure.
6061 Tested with DCOM98, Win2k, WinXP */
6062 if (ExtraFlags[i] & VT_ARRAY || ExtraFlags[i] & VT_BYREF ||
6063 !IsValidVariantClearVT(leftvt, ExtraFlags[i] & ~VT_RESERVED) ||
6064 !IsValidVariantClearVT(rightvt, ExtraFlags[i] & ~VT_RESERVED) ||
6065 leftvt == VT_CLSID || rightvt == VT_CLSID ||
6066 leftvt == VT_DISPATCH || rightvt == VT_DISPATCH ||
6067 leftvt == VT_ERROR || rightvt == VT_ERROR ||
6068 leftvt == VT_RECORD || rightvt == VT_RECORD ||
6069 leftvt == VT_UNKNOWN || rightvt == VT_UNKNOWN ||
6070 leftvt == VT_VARIANT || rightvt == VT_VARIANT ||
6071 leftvt == VT_I1 || rightvt == VT_I1 ||
6072 leftvt == VT_UI2 || rightvt == VT_UI2 ||
6073 leftvt == VT_UI4 || rightvt == VT_UI4 ||
6074 leftvt == VT_UI8 || rightvt == VT_UI8 ||
6075 rightvt == VT_INT ||
6076 leftvt == VT_UINT || rightvt == VT_UINT) {
6080 if (leftvt == VT_ERROR && rightvt == VT_ERROR &&
6081 !(ExtraFlags[i] & ~VT_RESERVED)) {
6084 } else if (leftvt == VT_NULL || rightvt == VT_NULL)
6085 expect = VARCMP_NULL;
6086 else if (leftvt == VT_BSTR && rightvt == VT_BSTR)
6088 else if (leftvt == VT_BSTR && rightvt == VT_EMPTY)
6090 else if (leftvt == VT_EMPTY && rightvt == VT_BSTR)
6093 hres = pVarCmp(&left, &right, LOCALE_USER_DEFAULT, 0);
6095 ok(hres == DISP_E_TYPEMISMATCH || hres == DISP_E_BADVARTYPE,
6096 "VarCmp: %d|0x%X, %d|0x%X: Expected failure, got 0x%X\n",
6097 leftvt, ExtraFlags[i], rightvt, ExtraFlags[i], hres);
6100 "VarCmp: %d|0x%X, %d|0x%X: Expected 0x%X, got 0x%X\n",
6101 leftvt, ExtraFlags[i], rightvt, ExtraFlags[i], expect,
6108 /* VARCMP{,EX} run each 4 tests with a permutation of all posible
6109 input variants with (1) and without (0) VT_RESERVED set. The order
6110 of the permutations is (0,0); (1,0); (0,1); (1,1) */
6111 VARCMP(INT,4711,I2,4711,VARCMP_EQ);
6112 ok(V_VT(&left) & V_VT(&right) & VT_RESERVED, "VT_RESERVED filtered out!\n");
6113 VARCMP(INT,4711,I2,-4711,VARCMP_GT);
6114 VARCMP(ERROR,0,ERROR,0,VARCMP_EQ);
6115 VARCMP(ERROR,0,UI1,0,DISP_E_TYPEMISMATCH);
6116 VARCMP(EMPTY,0,EMPTY,0,VARCMP_EQ);
6117 VARCMP(I4,1,R8,1.0,VARCMP_EQ);
6118 VARCMP(EMPTY,19,I2,0,VARCMP_EQ);
6119 ok(V_EMPTY(&left) == 19, "VT_EMPTY modified!\n");
6120 ok(V_VT(&left) & V_VT(&right) & VT_RESERVED, "VT_RESERVED filtered out!\n");
6121 VARCMP(I4,1,UI1,1,VARCMP_EQ);
6122 VARCMP(I2,2,I2,2,VARCMP_EQ);
6123 VARCMP(I2,1,I2,2,VARCMP_LT);
6124 VARCMP(I2,2,I2,1,VARCMP_GT);
6125 VARCMP(I2,2,EMPTY,1,VARCMP_GT);
6126 VARCMP(I2,2,NULL_,1,VARCMP_NULL);
6128 /* BSTR handling, especially in conjunction with VT_RESERVED */
6129 VARCMP(BSTR,bstr0,NULL_,0,VARCMP_NULL);
6130 VARCMP(BSTR,bstr0,BSTR,bstr0,VARCMP_EQ);
6131 VARCMP(BSTR,bstrempty,BSTR,bstr0,VARCMP_LT);
6132 VARCMP(BSTR,bstr7,BSTR,bstr0,VARCMP_GT);
6133 VARCMP(BSTR,bstr7,BSTR,bstr1neg,VARCMP_GT);
6134 VARCMP(BSTR,bstr0,BSTR,NULL,VARCMP_GT);
6135 VARCMP(BSTR,NULL,BSTR,NULL,VARCMP_EQ);
6136 VARCMP(BSTR,bstrempty,BSTR,NULL,VARCMP_EQ);
6137 VARCMP(BSTR,NULL,EMPTY,0,VARCMP_EQ);
6138 VARCMP(EMPTY,0,BSTR,NULL,VARCMP_EQ);
6139 VARCMP(EMPTY,0,BSTR,bstrempty,VARCMP_EQ);
6140 VARCMP(EMPTY,1,BSTR,bstrempty,VARCMP_EQ);
6141 VARCMP(BSTR,bstr0,EMPTY,0,VARCMP_GT);
6142 VARCMP(BSTR,bstr42,EMPTY,0,VARCMP_GT);
6143 VARCMPEX(BSTR,bstrempty,UI1,0,VARCMP_GT,VARCMP_LT,VARCMP_GT,VARCMP_GT);
6144 VARCMPEX(BSTR,bstrempty,I2,-1,VARCMP_GT,VARCMP_LT,VARCMP_GT,VARCMP_GT);
6145 VARCMPEX(I4,0,BSTR,bstrempty,VARCMP_LT,VARCMP_LT,VARCMP_GT,VARCMP_LT);
6146 VARCMPEX(BSTR,NULL,UI1,0,VARCMP_GT,VARCMP_LT,VARCMP_GT,VARCMP_GT);
6147 VARCMPEX(I4,7,BSTR,NULL,VARCMP_LT,VARCMP_LT,VARCMP_GT,VARCMP_LT);
6148 _VARCMP(BSTR,(BSTR)100,0,I2,100,0,lcid,0,VARCMP_GT);
6149 VARCMPEX(BSTR,bstr0,UI1,0,VARCMP_GT,VARCMP_EQ,VARCMP_EQ,VARCMP_GT);
6150 VARCMPEX(I2,0,BSTR,bstr0,VARCMP_LT,VARCMP_EQ,VARCMP_EQ,VARCMP_LT);
6151 ok(V_VT(&left) & V_VT(&right) & VT_RESERVED, "VT_RESERVED filtered out!\n");
6152 VARCMP(BSTR,bstrhuh,I4,I4_MAX,VARCMP_GT);
6153 VARCMP(BSTR,bstr2cents,I4,2,VARCMP_GT);
6154 VARCMPEX(BSTR,bstr2cents,I4,42,VARCMP_GT,VARCMP_LT,VARCMP_GT,VARCMP_GT);
6155 VARCMP(BSTR,bstr2cents,I4,-1,VARCMP_GT);
6156 VARCMPEX(BSTR,bstr2cents,I4,-666,VARCMP_GT,VARCMP_LT,VARCMP_GT,VARCMP_GT);
6157 VARCMPEX(BSTR,bstr0,I2,0,VARCMP_GT,VARCMP_EQ,VARCMP_EQ,VARCMP_GT);
6158 VARCMPEX(BSTR,bstr0,I4,0,VARCMP_GT,VARCMP_EQ,VARCMP_EQ,VARCMP_GT);
6159 VARCMPEX(BSTR,bstr0,I4,-666,VARCMP_GT,VARCMP_LT,VARCMP_GT,VARCMP_GT);
6160 VARCMP(BSTR,bstr1,I4,0,VARCMP_GT);
6161 VARCMPEX(BSTR,bstr1,I4,1,VARCMP_GT,VARCMP_EQ,VARCMP_EQ,VARCMP_GT);
6162 VARCMPEX(BSTR,bstr1,I4,I4_MAX,VARCMP_GT,VARCMP_LT,VARCMP_LT,VARCMP_GT);
6163 VARCMPEX(BSTR,bstr1,I4,-1,VARCMP_GT,VARCMP_LT,VARCMP_GT,VARCMP_GT);
6164 VARCMP(BSTR,bstr7,I4,1,VARCMP_GT);
6165 VARCMPEX(BSTR,bstr7,I4,7,VARCMP_GT,VARCMP_EQ,VARCMP_EQ,VARCMP_GT);
6166 VARCMPEX(BSTR,bstr7,I4,42,VARCMP_GT,VARCMP_GT,VARCMP_LT,VARCMP_GT);
6167 VARCMPEX(BSTR,bstr42,I4,7,VARCMP_GT,VARCMP_LT,VARCMP_GT,VARCMP_GT);
6168 VARCMPEX(BSTR,bstr42,I4,42,VARCMP_GT,VARCMP_EQ,VARCMP_EQ,VARCMP_GT);
6169 VARCMPEX(BSTR,bstr42,I4,I4_MAX,VARCMP_GT,VARCMP_GT,VARCMP_LT,VARCMP_GT);
6170 VARCMPEX(BSTR,bstr1neg,I4,1,VARCMP_GT,VARCMP_GT,VARCMP_LT,VARCMP_LT);
6171 VARCMPEX(BSTR,bstr1neg,I4,42,VARCMP_GT,VARCMP_LT,VARCMP_LT,VARCMP_LT);
6172 VARCMPEX(BSTR,bstr1neg,I4,-1,VARCMP_GT,VARCMP_EQ,VARCMP_EQ,VARCMP_LT);
6173 VARCMPEX(BSTR,bstr1neg,I4,-666,VARCMP_GT,VARCMP_LT,VARCMP_GT,VARCMP_LT);
6174 VARCMPEX(BSTR,bstr666neg,I4,1,VARCMP_GT,VARCMP_GT,VARCMP_LT,VARCMP_LT);
6175 VARCMPEX(BSTR,bstr666neg,I4,7,VARCMP_GT,VARCMP_LT,VARCMP_LT,VARCMP_LT);
6176 VARCMPEX(BSTR,bstr666neg,I4,42,VARCMP_GT,VARCMP_GT,VARCMP_LT,VARCMP_LT);
6177 VARCMPEX(BSTR,bstr666neg,I4,I4_MAX,VARCMP_GT,VARCMP_GT,VARCMP_LT,VARCMP_LT);
6178 VARCMPEX(BSTR,bstr666neg,I4,-1,VARCMP_GT,VARCMP_GT,VARCMP_LT,VARCMP_LT);
6179 VARCMPEX(BSTR,bstr666neg,I4,-666,VARCMP_GT,VARCMP_EQ,VARCMP_EQ,VARCMP_LT);
6180 VARCMPEX(BSTR,bstr7,R8,7.0,VARCMP_GT,VARCMP_EQ,VARCMP_EQ,VARCMP_GT);
6181 VARCMPEX(R8,3.141592,BSTR,NULL,VARCMP_LT,VARCMP_LT,VARCMP_GT,VARCMP_LT);
6182 VARCMP(BSTR,bstr7,BSTR,bstr7,VARCMP_EQ);
6183 VARCMP(BSTR,bstr7,BSTR,bstr42,VARCMP_GT);
6184 VARCMP(BSTR,bstr42,BSTR,bstr7,VARCMP_LT);
6186 /* DECIMAL handling */
6187 SETDEC(dec,0,0,0,0);
6188 VARCMPEX(DECIMAL,dec,BSTR,bstr0,VARCMP_LT,VARCMP_EQ,VARCMP_EQ,VARCMP_LT);
6189 SETDEC64(dec,0,0,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF); /* max DECIMAL */
6190 VARCMP(DECIMAL,dec,R8,R8_MAX,VARCMP_LT); /* R8 has bigger range */
6191 VARCMP(DECIMAL,dec,DATE,R8_MAX,VARCMP_LT); /* DATE has bigger range */
6192 SETDEC64(dec,0,0x80,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF);
6193 VARCMP(DECIMAL,dec,R8,-R8_MAX,VARCMP_GT);
6194 SETDEC64(dec,20,0,0x5,0x6BC75E2D,0x63100001); /* 1+1e-20 */
6195 VARCMP(DECIMAL,dec,R8,1,VARCMP_GT); /* DECIMAL has higher precission */
6197 /* Show that DATE is handled just as a R8 */
6198 VARCMP(DATE,DATE_MAX,DATE,DATE_MAX+1,VARCMP_LT);
6199 VARCMP(DATE,DATE_MIN,DATE,DATE_MIN-1,VARCMP_GT);
6200 VARCMP(DATE,R8_MIN,R8,R8_MIN,VARCMP_EQ);
6201 VARCMP(DATE,1,DATE,1+1e-15,VARCMP_LT); /* 1e-15 == 8.64e-11 seconds */
6202 VARCMP(DATE,25570.0,DATE,25570.0,VARCMP_EQ);
6203 VARCMP(DATE,25570.0,DATE,25571.0,VARCMP_LT);
6204 VARCMP(DATE,25571.0,DATE,25570.0,VARCMP_GT);
6205 VARCMP(DATE,25570.0,EMPTY,0,VARCMP_GT);
6206 VARCMP(DATE,25570.0,NULL_,0,VARCMP_NULL);
6208 /* R4 precission handling */
6209 VARCMP(R4,1,R8,1+1e-8,VARCMP_EQ);
6210 VARCMP(R8,1+1e-8,R4,1,VARCMP_EQ);
6211 VARCMP(R8,1+1e-8,R8,1,VARCMP_GT);
6212 VARCMP(R8,R4_MAX*1.1,R4,R4_MAX,VARCMP_GT);
6213 VARCMP(R4,R4_MAX,R8,R8_MAX,VARCMP_LT);
6214 VARCMP(R4,1,DATE,1+1e-8,VARCMP_EQ);
6215 VARCMP(R4,1,BSTR,bstr1few,VARCMP_LT); /* bstr1few == 1+1e-8 */
6216 SETDEC(dec,8,0,0,0x5F5E101); /* 1+1e-8 */
6217 VARCMP(R4,1,DECIMAL,dec,VARCMP_LT);
6219 SysFreeString(bstrhuh);
6220 SysFreeString(bstrempty);
6221 SysFreeString(bstr0);
6222 SysFreeString(bstr1);
6223 SysFreeString(bstr7);
6224 SysFreeString(bstr42);
6225 SysFreeString(bstr1neg);
6226 SysFreeString(bstr666neg);
6227 SysFreeString(bstr2cents);
6228 SysFreeString(bstr1few);
6231 static HRESULT (WINAPI *pVarPow)(LPVARIANT,LPVARIANT,LPVARIANT);
6233 static const char *szVarPowFail = "VarPow(%s,%s): expected 0x0,%s,%d, got 0x%X,%s,%d\n";
6235 #define VARPOW(vt1,val1,vt2,val2,rvt,rval) \
6236 V_VT(&left) = VT_##vt1; V_VT(&right) = VT_##vt2; \
6237 V_##vt1(&left) = val1; V_##vt2(&right) = val2; \
6238 memset(&result,0,sizeof(result)); \
6239 hres = pVarPow(&left,&right,&result); \
6240 ok(hres == S_OK && V_VT(&result) == VT_##rvt && \
6241 EQ_DOUBLE(V_##rvt(&result),(rval)), \
6242 szVarPowFail, vtstr(VT_##vt1), vtstr(VT_##vt2), \
6243 vtstr(VT_##rvt), (int)(rval), hres, vtstr(V_VT(&result)), \
6244 (int)V_##rvt(&result));
6246 /* Skip any type that is not defined or produces a error for every case */
6247 #define SKIPTESTPOW(a) \
6248 if (a == VT_ERROR || a == VT_VARIANT || \
6249 a == VT_DISPATCH || a == VT_UNKNOWN || \
6250 a == VT_RECORD || a > VT_UINT || \
6251 a == 15 /*not defined*/) \
6254 static void test_VarPow(void)
6256 static const WCHAR str2[] = { '2','\0' };
6257 static const WCHAR str3[] = { '3','\0' };
6258 VARIANT left, right, result, cy, dec;
6259 BSTR num2_str, num3_str;
6265 num2_str = SysAllocString(str2);
6266 num3_str = SysAllocString(str3);
6268 /* Test all possible flag/vt combinations & the resulting vt type */
6269 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
6271 VARTYPE leftvt, rightvt, resvt;
6273 for (leftvt = 0; leftvt <= VT_BSTR_BLOB; leftvt++)
6275 SKIPTESTPOW(leftvt);
6277 for (rightvt = 0; rightvt <= VT_BSTR_BLOB; rightvt++)
6280 SKIPTESTPOW(rightvt);
6282 /* Native crashes with VT_BYREF */
6283 if (ExtraFlags[i] == VT_BYREF)
6286 memset(&left, 0, sizeof(left));
6287 memset(&right, 0, sizeof(right));
6288 V_VT(&left) = leftvt | ExtraFlags[i];
6289 V_VT(&right) = rightvt | ExtraFlags[i];
6290 V_VT(&result) = VT_EMPTY;
6293 if (leftvt == VT_BSTR)
6294 V_BSTR(&left) = num2_str;
6295 if (rightvt == VT_BSTR)
6296 V_BSTR(&right) = num2_str;
6298 /* Native VarPow always returns a error when using any extra flags */
6299 if (ExtraFlags[i] != 0)
6302 /* Determine return type */
6303 else if (leftvt == VT_NULL || rightvt == VT_NULL)
6305 else if ((leftvt == VT_EMPTY || leftvt == VT_I2 ||
6306 leftvt == VT_I4 || leftvt == VT_R4 ||
6307 leftvt == VT_R8 || leftvt == VT_CY ||
6308 leftvt == VT_DATE || leftvt == VT_BSTR ||
6309 leftvt == VT_BOOL || leftvt == VT_DECIMAL ||
6310 (leftvt >= VT_I1 && leftvt <= VT_UINT)) &&
6311 (rightvt == VT_EMPTY || rightvt == VT_I2 ||
6312 rightvt == VT_I4 || rightvt == VT_R4 ||
6313 rightvt == VT_R8 || rightvt == VT_CY ||
6314 rightvt == VT_DATE || rightvt == VT_BSTR ||
6315 rightvt == VT_BOOL || rightvt == VT_DECIMAL ||
6316 (rightvt >= VT_I1 && rightvt <= VT_UINT)))
6321 hres = pVarPow(&left, &right, &result);
6323 /* Check expected HRESULT and if result variant type is correct */
6325 ok (hres == DISP_E_BADVARTYPE || hres == DISP_E_TYPEMISMATCH,
6326 "VarPow: %s|0x%X, %s|0x%X: got vt %s hr 0x%X\n",
6327 vtstr(leftvt), ExtraFlags[i], vtstr(rightvt), ExtraFlags[i],
6328 vtstr(V_VT(&result)), hres);
6330 ok (hres == S_OK && resvt == V_VT(&result),
6331 "VarPow: %s|0x%X, %s|0x%X: expected vt %s hr 0x%X, got vt %s hr 0x%X\n",
6332 vtstr(leftvt), ExtraFlags[i], vtstr(rightvt), ExtraFlags[i], vtstr(resvt),
6333 S_OK, vtstr(V_VT(&result)), hres);
6338 /* Check return values for valid variant type combinations */
6339 VARPOW(EMPTY,0,EMPTY,0,R8,1.0);
6340 VARPOW(EMPTY,0,NULL,0,NULL,0);
6341 VARPOW(EMPTY,0,I2,3,R8,0.0);
6342 VARPOW(EMPTY,0,I4,3,R8,0.0);
6343 VARPOW(EMPTY,0,R4,3.0,R8,0.0);
6344 VARPOW(EMPTY,0,R8,3.0,R8,0.0);
6345 VARPOW(EMPTY,0,DATE,3,R8,0.0);
6346 VARPOW(EMPTY,0,BSTR,num3_str,R8,0.0);
6347 VARPOW(EMPTY,0,BOOL,VARIANT_FALSE,R8,1.0);
6348 VARPOW(EMPTY,0,I1,3,R8,0.0);
6349 VARPOW(EMPTY,0,UI1,3,R8,0.0);
6350 VARPOW(EMPTY,0,UI2,3,R8,0.0);
6351 VARPOW(EMPTY,0,UI4,3,R8,0.0);
6352 VARPOW(EMPTY,0,I8,3,R8,0.0);
6353 VARPOW(EMPTY,0,UI8,3,R8,0.0);
6354 VARPOW(EMPTY,0,INT,3,R8,0.0);
6355 VARPOW(EMPTY,0,UINT,3,R8,0.0);
6356 VARPOW(NULL,0,EMPTY,0,NULL,0);
6357 VARPOW(NULL,0,NULL,0,NULL,0);
6358 VARPOW(NULL,0,I2,3,NULL,0);
6359 VARPOW(NULL,0,I4,3,NULL,0);
6360 VARPOW(NULL,0,R4,3.0,NULL,0);
6361 VARPOW(NULL,0,R8,3.0,NULL,0);
6362 VARPOW(NULL,0,DATE,3,NULL,0);
6363 VARPOW(NULL,0,BSTR,num3_str,NULL,0);
6364 VARPOW(NULL,0,BOOL,VARIANT_TRUE,NULL,0);
6365 VARPOW(NULL,0,I1,3,NULL,0);
6366 VARPOW(NULL,0,UI1,3,NULL,0);
6367 VARPOW(NULL,0,UI2,3,NULL,0);
6368 VARPOW(NULL,0,UI4,3,NULL,0);
6369 VARPOW(NULL,0,I8,3,NULL,0);
6370 VARPOW(NULL,0,UI8,3,NULL,0);
6371 VARPOW(NULL,0,INT,3,NULL,0);
6372 VARPOW(NULL,0,UINT,3,NULL,0);
6373 VARPOW(I2,2,EMPTY,0,R8,1.0);
6374 VARPOW(I2,2,NULL,0,NULL,0);
6375 VARPOW(I2,2,I2,3,R8,8.0);
6376 VARPOW(I2,2,I4,3,R8,8.0);
6377 VARPOW(I2,2,R4,3.0,R8,8.0);
6378 VARPOW(I2,2,R8,3.0,R8,8.0);
6379 VARPOW(I2,2,DATE,3,R8,8.0);
6380 VARPOW(I2,2,BSTR,num3_str,R8,8.0);
6381 VARPOW(I2,2,BOOL,VARIANT_FALSE,R8,1.0);
6382 VARPOW(I2,2,I1,3,R8,8.0);
6383 VARPOW(I2,2,UI1,3,R8,8.0);
6384 VARPOW(I2,2,UI2,3,R8,8.0);
6385 VARPOW(I2,2,UI4,3,R8,8.0);
6386 VARPOW(I2,2,I8,3,R8,8.0);
6387 VARPOW(I2,2,UI8,3,R8,8.0);
6388 VARPOW(I2,2,INT,3,R8,8.0);
6389 VARPOW(I2,2,UINT,3,R8,8.0);
6390 VARPOW(I4,2,EMPTY,0,R8,1.0);
6391 VARPOW(I4,2,NULL,0,NULL,0);
6392 VARPOW(I4,2,I2,3,R8,8.0);
6393 VARPOW(I4,2,I4,3,R8,8.0);
6394 VARPOW(I4,2,R4,3.0,R8,8.0);
6395 VARPOW(I4,2,R8,3.0,R8,8.0);
6396 VARPOW(I4,2,DATE,3,R8,8.0);
6397 VARPOW(I4,2,BSTR,num3_str,R8,8.0);
6398 VARPOW(I4,2,BOOL,VARIANT_FALSE,R8,1.0);
6399 VARPOW(I4,2,I1,3,R8,8.0);
6400 VARPOW(I4,2,UI1,3,R8,8.0);
6401 VARPOW(I4,2,UI2,3,R8,8.0);
6402 VARPOW(I4,2,UI4,3,R8,8.0);
6403 VARPOW(I4,2,I8,3,R8,8.0);
6404 VARPOW(I4,2,UI8,3,R8,8.0);
6405 VARPOW(I4,2,INT,3,R8,8.0);
6406 VARPOW(I4,2,UINT,3,R8,8.0);
6407 VARPOW(R4,2,EMPTY,0,R8,1.0);
6408 VARPOW(R4,2,NULL,0,NULL,0);
6409 VARPOW(R4,2,I2,3,R8,8.0);
6410 VARPOW(R4,2,I4,3,R8,8.0);
6411 VARPOW(R4,2,R4,3.0,R8,8.0);
6412 VARPOW(R4,2,R8,3.0,R8,8.0);
6413 VARPOW(R4,2,DATE,3,R8,8.0);
6414 VARPOW(R4,2,BSTR,num3_str,R8,8.0);
6415 VARPOW(R4,2,BOOL,VARIANT_FALSE,R8,1.0);
6416 VARPOW(R4,2,I1,3,R8,8.0);
6417 VARPOW(R4,2,UI1,3,R8,8.0);
6418 VARPOW(R4,2,UI2,3,R8,8.0);
6419 VARPOW(R4,2,UI4,3,R8,8.0);
6420 VARPOW(R4,2,I8,3,R8,8.0);
6421 VARPOW(R4,2,UI8,3,R8,8.0);
6422 VARPOW(R4,2,INT,3,R8,8.0);
6423 VARPOW(R4,2,UINT,3,R8,8.0);
6424 VARPOW(R8,2,EMPTY,0,R8,1.0);
6425 VARPOW(R8,2,NULL,0,NULL,0);
6426 VARPOW(R8,2,I2,3,R8,8.0);
6427 VARPOW(R8,2,I4,3,R8,8.0);
6428 VARPOW(R8,2,R4,3.0,R8,8.0);
6429 VARPOW(R8,2,R8,3.0,R8,8.0);
6430 VARPOW(R8,2,DATE,3,R8,8.0);
6431 VARPOW(R8,2,BSTR,num3_str,R8,8.0);
6432 VARPOW(R8,2,BOOL,VARIANT_FALSE,R8,1.0);
6433 VARPOW(R8,2,I1,3,R8,8.0);
6434 VARPOW(R8,2,UI1,3,R8,8.0);
6435 VARPOW(R8,2,UI2,3,R8,8.0);
6436 VARPOW(R8,2,UI4,3,R8,8.0);
6437 VARPOW(R8,2,I8,3,R8,8.0);
6438 VARPOW(R8,2,UI8,3,R8,8.0);
6439 VARPOW(R8,2,INT,3,R8,8.0);
6440 VARPOW(R8,2,UINT,3,R8,8.0);
6441 VARPOW(DATE,2,EMPTY,0,R8,1.0);
6442 VARPOW(DATE,2,NULL,0,NULL,0);
6443 VARPOW(DATE,2,I2,3,R8,8.0);
6444 VARPOW(DATE,2,I4,3,R8,8.0);
6445 VARPOW(DATE,2,R4,3.0,R8,8.0);
6446 VARPOW(DATE,2,R8,3.0,R8,8.0);
6447 VARPOW(DATE,2,DATE,3,R8,8.0);
6448 VARPOW(DATE,2,BSTR,num3_str,R8,8.0);
6449 VARPOW(DATE,2,BOOL,VARIANT_FALSE,R8,1.0);
6450 VARPOW(DATE,2,I1,3,R8,8.0);
6451 VARPOW(DATE,2,UI1,3,R8,8.0);
6452 VARPOW(DATE,2,UI2,3,R8,8.0);
6453 VARPOW(DATE,2,UI4,3,R8,8.0);
6454 VARPOW(DATE,2,I8,3,R8,8.0);
6455 VARPOW(DATE,2,UI8,3,R8,8.0);
6456 VARPOW(DATE,2,INT,3,R8,8.0);
6457 VARPOW(DATE,2,UINT,3,R8,8.0);
6458 VARPOW(BSTR,num2_str,EMPTY,0,R8,1.0);
6459 VARPOW(BSTR,num2_str,NULL,0,NULL,0);
6460 VARPOW(BSTR,num2_str,I2,3,R8,8.0);
6461 VARPOW(BSTR,num2_str,I4,3,R8,8.0);
6462 VARPOW(BSTR,num2_str,R4,3.0,R8,8.0);
6463 VARPOW(BSTR,num2_str,R8,3.0,R8,8.0);
6464 VARPOW(BSTR,num2_str,DATE,3,R8,8.0);
6465 VARPOW(BSTR,num2_str,BSTR,num3_str,R8,8.0);
6466 VARPOW(BSTR,num2_str,BOOL,VARIANT_FALSE,R8,1.0);
6467 VARPOW(BSTR,num2_str,I1,3,R8,8.0);
6468 VARPOW(BSTR,num2_str,UI1,3,R8,8.0);
6469 VARPOW(BSTR,num2_str,UI2,3,R8,8.0);
6470 VARPOW(BSTR,num2_str,UI4,3,R8,8.0);
6471 VARPOW(BSTR,num2_str,I8,3,R8,8.0);
6472 VARPOW(BSTR,num2_str,UI8,3,R8,8.0);
6473 VARPOW(BSTR,num2_str,INT,3,R8,8.0);
6474 VARPOW(BSTR,num2_str,UINT,3,R8,8.0);
6475 VARPOW(BOOL,VARIANT_TRUE,EMPTY,0,R8,1.0);
6476 VARPOW(BOOL,VARIANT_TRUE,NULL,0,NULL,0);
6477 VARPOW(BOOL,VARIANT_TRUE,I2,3,R8,-1.0);
6478 VARPOW(BOOL,VARIANT_TRUE,I4,3,R8,-1.0);
6479 VARPOW(BOOL,VARIANT_TRUE,R4,3.0,R8,-1.0);
6480 VARPOW(BOOL,VARIANT_TRUE,R8,3.0,R8,-1.0);
6481 VARPOW(BOOL,VARIANT_TRUE,DATE,3,R8,-1.0);
6482 VARPOW(BOOL,VARIANT_TRUE,BSTR,num3_str,R8,-1.0);
6483 VARPOW(BOOL,VARIANT_TRUE,BOOL,VARIANT_TRUE,R8,-1.0);
6484 VARPOW(BOOL,VARIANT_TRUE,I1,3,R8,-1.0);
6485 VARPOW(BOOL,VARIANT_TRUE,UI1,3,R8,-1.0);
6486 VARPOW(BOOL,VARIANT_TRUE,UI2,3,R8,-1.0);
6487 VARPOW(BOOL,VARIANT_TRUE,UI4,3,R8,-1.0);
6488 VARPOW(BOOL,VARIANT_TRUE,I8,3,R8,-1.0);
6489 VARPOW(BOOL,VARIANT_TRUE,UI8,3,R8,-1.0);
6490 VARPOW(BOOL,VARIANT_TRUE,INT,3,R8,-1.0);
6491 VARPOW(BOOL,VARIANT_TRUE,UINT,3,R8,-1.0);
6492 VARPOW(I1,2,EMPTY,0,R8,1.0);
6493 VARPOW(I1,2,NULL,0,NULL,0);
6494 VARPOW(I1,2,I2,3,R8,8.0);
6495 VARPOW(I1,2,I4,3,R8,8.0);
6496 VARPOW(I1,2,R4,3.0,R8,8.0);
6497 VARPOW(I1,2,R8,3.0,R8,8.0);
6498 VARPOW(I1,2,DATE,3,R8,8.0);
6499 VARPOW(I1,2,BSTR,num3_str,R8,8.0);
6500 VARPOW(I1,2,BOOL,VARIANT_FALSE,R8,1.0);
6501 VARPOW(I1,2,I1,3,R8,8.0);
6502 VARPOW(I1,2,UI1,3,R8,8.0);
6503 VARPOW(I1,2,UI2,3,R8,8.0);
6504 VARPOW(I1,2,UI4,3,R8,8.0);
6505 VARPOW(I1,2,I8,3,R8,8.0);
6506 VARPOW(I1,2,UI8,3,R8,8.0);
6507 VARPOW(I1,2,INT,3,R8,8.0);
6508 VARPOW(I1,2,UINT,3,R8,8.0);
6509 VARPOW(UI1,2,EMPTY,0,R8,1.0);
6510 VARPOW(UI1,2,NULL,0,NULL,0);
6511 VARPOW(UI1,2,I2,3,R8,8.0);
6512 VARPOW(UI1,2,I4,3,R8,8.0);
6513 VARPOW(UI1,2,R4,3.0,R8,8.0);
6514 VARPOW(UI1,2,R8,3.0,R8,8.0);
6515 VARPOW(UI1,2,DATE,3,R8,8.0);
6516 VARPOW(UI1,2,BSTR,num3_str,R8,8.0);
6517 VARPOW(UI1,2,BOOL,VARIANT_FALSE,R8,1.0);
6518 VARPOW(UI1,2,I1,3,R8,8.0);
6519 VARPOW(UI1,2,UI1,3,R8,8.0);
6520 VARPOW(UI1,2,UI2,3,R8,8.0);
6521 VARPOW(UI1,2,UI4,3,R8,8.0);
6522 VARPOW(UI1,2,I8,3,R8,8.0);
6523 VARPOW(UI1,2,UI8,3,R8,8.0);
6524 VARPOW(UI1,2,INT,3,R8,8.0);
6525 VARPOW(UI1,2,UINT,3,R8,8.0);
6526 VARPOW(UI2,2,EMPTY,0,R8,1.0);
6527 VARPOW(UI2,2,NULL,0,NULL,0);
6528 VARPOW(UI2,2,I2,3,R8,8.0);
6529 VARPOW(UI2,2,I4,3,R8,8.0);
6530 VARPOW(UI2,2,R4,3.0,R8,8.0);
6531 VARPOW(UI2,2,R8,3.0,R8,8.0);
6532 VARPOW(UI2,2,DATE,3,R8,8.0);
6533 VARPOW(UI2,2,BSTR,num3_str,R8,8.0);
6534 VARPOW(UI2,2,BOOL,VARIANT_FALSE,R8,1.0);
6535 VARPOW(UI2,2,I1,3,R8,8.0);
6536 VARPOW(UI2,2,UI1,3,R8,8.0);
6537 VARPOW(UI2,2,UI2,3,R8,8.0);
6538 VARPOW(UI2,2,UI4,3,R8,8.0);
6539 VARPOW(UI2,2,I8,3,R8,8.0);
6540 VARPOW(UI2,2,UI8,3,R8,8.0);
6541 VARPOW(UI2,2,INT,3,R8,8.0);
6542 VARPOW(UI2,2,UINT,3,R8,8.0);
6543 VARPOW(UI4,2,EMPTY,0,R8,1.0);
6544 VARPOW(UI4,2,NULL,0,NULL,0);
6545 VARPOW(UI4,2,I2,3,R8,8.0);
6546 VARPOW(UI4,2,I4,3,R8,8.0);
6547 VARPOW(UI4,2,R4,3.0,R8,8.0);
6548 VARPOW(UI4,2,R8,3.0,R8,8.0);
6549 VARPOW(UI4,2,DATE,3,R8,8.0);
6550 VARPOW(UI4,2,BSTR,num3_str,R8,8.0);
6551 VARPOW(UI4,2,BOOL,VARIANT_FALSE,R8,1.0);
6552 VARPOW(UI4,2,I1,3,R8,8.0);
6553 VARPOW(UI4,2,UI1,3,R8,8.0);
6554 VARPOW(UI4,2,UI2,3,R8,8.0);
6555 VARPOW(UI4,2,UI4,3,R8,8.0);
6556 VARPOW(UI4,2,I8,3,R8,8.0);
6557 VARPOW(UI4,2,UI8,3,R8,8.0);
6558 VARPOW(UI4,2,INT,3,R8,8.0);
6559 VARPOW(UI4,2,UINT,3,R8,8.0);
6560 VARPOW(I8,2,EMPTY,0,R8,1.0);
6561 VARPOW(I8,2,NULL,0,NULL,0);
6562 VARPOW(I8,2,I2,3,R8,8.0);
6563 VARPOW(I8,2,I4,3,R8,8.0);
6564 VARPOW(I8,2,R4,3.0,R8,8.0);
6565 VARPOW(I8,2,R8,3.0,R8,8.0);
6566 VARPOW(I8,2,DATE,3,R8,8.0);
6567 VARPOW(I8,2,BSTR,num3_str,R8,8.0);
6568 VARPOW(I8,2,BOOL,VARIANT_FALSE,R8,1.0);
6569 VARPOW(I8,2,I1,3,R8,8.0);
6570 VARPOW(I8,2,UI1,3,R8,8.0);
6571 VARPOW(I8,2,UI2,3,R8,8.0);
6572 VARPOW(I8,2,UI4,3,R8,8.0);
6573 VARPOW(I8,2,I8,3,R8,8.0);
6574 VARPOW(I8,2,UI8,3,R8,8.0);
6575 VARPOW(I8,2,INT,3,R8,8.0);
6576 VARPOW(I8,2,UINT,3,R8,8.0);
6577 VARPOW(UI8,2,EMPTY,0,R8,1.0);
6578 VARPOW(UI8,2,NULL,0,NULL,0);
6579 VARPOW(UI8,2,I2,3,R8,8.0);
6580 VARPOW(UI8,2,I4,3,R8,8.0);
6581 VARPOW(UI8,2,R4,3.0,R8,8.0);
6582 VARPOW(UI8,2,R8,3.0,R8,8.0);
6583 VARPOW(UI8,2,DATE,3,R8,8.0);
6584 VARPOW(UI8,2,BSTR,num3_str,R8,8.0);
6585 VARPOW(UI8,2,I1,3,R8,8.0);
6586 VARPOW(UI8,2,UI1,3,R8,8.0);
6587 VARPOW(UI8,2,UI2,3,R8,8.0);
6588 VARPOW(UI8,2,UI4,3,R8,8.0);
6589 VARPOW(UI8,2,I8,3,R8,8.0);
6590 VARPOW(UI8,2,UI8,3,R8,8.0);
6591 VARPOW(UI8,2,INT,3,R8,8.0);
6592 VARPOW(UI8,2,UINT,3,R8,8.0);
6593 VARPOW(INT,2,EMPTY,0,R8,1.0);
6594 VARPOW(INT,2,NULL,0,NULL,0);
6595 VARPOW(INT,2,I2,3,R8,8.0);
6596 VARPOW(INT,2,I4,3,R8,8.0);
6597 VARPOW(INT,2,R4,3.0,R8,8.0);
6598 VARPOW(INT,2,R8,3.0,R8,8.0);
6599 VARPOW(INT,2,DATE,3,R8,8.0);
6600 VARPOW(INT,2,BSTR,num3_str,R8,8.0);
6601 VARPOW(INT,2,BOOL,VARIANT_FALSE,R8,1.0);
6602 VARPOW(INT,2,I1,3,R8,8.0);
6603 VARPOW(INT,2,UI1,3,R8,8.0);
6604 VARPOW(INT,2,UI2,3,R8,8.0);
6605 VARPOW(INT,2,UI4,3,R8,8.0);
6606 VARPOW(INT,2,I8,3,R8,8.0);
6607 VARPOW(INT,2,UI8,3,R8,8.0);
6608 VARPOW(INT,2,INT,3,R8,8.0);
6609 VARPOW(INT,2,UINT,3,R8,8.0);
6610 VARPOW(UINT,2,EMPTY,0,R8,1.0);
6611 VARPOW(UINT,2,NULL,0,NULL,0);
6612 VARPOW(UINT,2,I2,3,R8,8.0);
6613 VARPOW(UINT,2,I4,3,R8,8.0);
6614 VARPOW(UINT,2,R4,3.0,R8,8.0);
6615 VARPOW(UINT,2,R8,3.0,R8,8.0);
6616 VARPOW(UINT,2,DATE,3,R8,8.0);
6617 VARPOW(UINT,2,BSTR,num3_str,R8,8.0);
6618 VARPOW(UINT,2,BOOL,VARIANT_FALSE,R8,1.0);
6619 VARPOW(UINT,2,I1,3,R8,8.0);
6620 VARPOW(UINT,2,UI1,3,R8,8.0);
6621 VARPOW(UINT,2,UI2,3,R8,8.0);
6622 VARPOW(UINT,2,UI4,3,R8,8.0);
6623 VARPOW(UINT,2,I8,3,R8,8.0);
6624 VARPOW(UINT,2,UI8,3,R8,8.0);
6625 VARPOW(UINT,2,INT,3,R8,8.0);
6626 VARPOW(UINT,2,UINT,3,R8,8.0);
6628 /* Manually test some VT_CY, VT_DECIMAL variants */
6630 hres = VarCyFromI4(2, &V_CY(&cy));
6631 ok(hres == S_OK, "VarCyFromI4 failed!\n");
6632 V_VT(&dec) = VT_DECIMAL;
6633 hres = VarDecFromR8(2.0, &V_DECIMAL(&dec));
6634 ok(hres == S_OK, "VarDecFromR4 failed!\n");
6635 memset(&left, 0, sizeof(left));
6636 memset(&right, 0, sizeof(right));
6637 V_VT(&left) = VT_I4;
6639 V_VT(&right) = VT_I8;
6642 hres = pVarPow(&cy, &cy, &result);
6643 ok(hres == S_OK && V_VT(&result) == VT_R8,
6644 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
6645 S_OK, hres, vtstr(V_VT(&result)));
6646 ok(hres == S_OK && EQ_DOUBLE(V_R8(&result), 4.0),
6647 "VARPOW: CY value %f, expected %f\n", V_R8(&result), 4.0);
6649 hres = pVarPow(&cy, &right, &result);
6650 ok(hres == S_OK && V_VT(&result) == VT_R8,
6651 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
6652 S_OK, hres, vtstr(V_VT(&result)));
6653 ok(hres == S_OK && EQ_DOUBLE(V_R8(&result), 4.0),
6654 "VARPOW: CY value %f, expected %f\n", V_R8(&result), 4.0);
6656 hres = pVarPow(&left, &cy, &result);
6657 ok(hres == S_OK && V_VT(&result) == VT_R8,
6658 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
6659 S_OK, hres, vtstr(V_VT(&result)));
6660 ok(hres == S_OK && EQ_DOUBLE(V_R8(&result), 10000.0),
6661 "VARPOW: CY value %f, expected %f\n", V_R8(&result), 10000.0);
6663 hres = pVarPow(&left, &dec, &result);
6664 ok(hres == S_OK && V_VT(&result) == VT_R8,
6665 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
6666 S_OK, hres, vtstr(V_VT(&result)));
6667 ok(hres == S_OK && EQ_DOUBLE(V_R8(&result),10000.0),
6668 "VARPOW: DECIMAL value %f, expected %f\n", V_R8(&result), 10000.0);
6670 hres = pVarPow(&dec, &dec, &result);
6671 ok(hres == S_OK && V_VT(&result) == VT_R8,
6672 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
6673 S_OK, hres, vtstr(V_VT(&result)));
6674 ok(hres == S_OK && EQ_DOUBLE(V_R8(&result), 4.0),
6675 "VARPOW: DECIMAL value %f, expected %f\n", V_R8(&result), 4.0);
6677 hres = pVarPow(&dec, &right, &result);
6678 ok(hres == S_OK && V_VT(&result) == VT_R8,
6679 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type%s!\n",
6680 S_OK, hres, vtstr(V_VT(&result)));
6681 ok(hres == S_OK && EQ_DOUBLE(V_R8(&result), 4.0),
6682 "VARPOW: DECIMAL value %f, expected %f\n", V_R8(&result), 4.0);
6684 SysFreeString(num2_str);
6685 SysFreeString(num3_str);
6688 static HRESULT (WINAPI *pVarDiv)(LPVARIANT,LPVARIANT,LPVARIANT);
6690 static const char *szVarDivFail = "VarDiv(%s,%s): expected 0x0,%s,%d, got 0x%X,%s,%d\n";
6692 #define VARDIV(vt1,val1,vt2,val2,rvt,rval) \
6693 V_VT(&left) = VT_##vt1; V_VT(&right) = VT_##vt2; \
6694 V_##vt1(&left) = val1; V_##vt2(&right) = val2; \
6695 memset(&result,0,sizeof(result)); \
6696 hres = pVarDiv(&left,&right,&result); \
6697 ok(hres == S_OK && V_VT(&result) == VT_##rvt && \
6698 EQ_DOUBLE(V_##rvt(&result),(rval)), \
6699 szVarDivFail, vtstr(VT_##vt1), vtstr(VT_##vt2), \
6700 vtstr(VT_##rvt), (int)(rval), hres, vtstr(V_VT(&result)), \
6701 (int)V_##rvt(&result));
6703 /* Skip any type that is not defined or produces a error for every case */
6704 #define SKIPTESTDIV(a) \
6705 if (a == VT_ERROR || a == VT_VARIANT || \
6706 a == VT_DISPATCH || a == VT_UNKNOWN || \
6707 a == VT_RECORD || a > VT_UINT || \
6708 a == VT_I1 || a == VT_UI8 || \
6709 a == VT_INT || a == VT_UINT || \
6710 a == VT_UI2 || a == VT_UI4 || \
6711 a == 15 /*not defined*/) \
6714 static void test_VarDiv(void)
6716 static const WCHAR str1[] = { '1','\0' };
6717 static const WCHAR str2[] = { '2','\0' };
6718 VARIANT left, right, result, cy, dec;
6719 BSTR num1_str, num2_str;
6721 HRESULT hres, expectedhres;
6724 num1_str = SysAllocString(str1);
6725 num2_str = SysAllocString(str2);
6729 /* Test all possible flag/vt combinations & the resulting vt type */
6730 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
6732 VARTYPE leftvt, rightvt, resvt;
6734 for (leftvt = 0; leftvt <= VT_BSTR_BLOB; leftvt++)
6736 SKIPTESTDIV(leftvt);
6738 for (rightvt = 0; rightvt <= VT_BSTR_BLOB; rightvt++)
6741 SKIPTESTDIV(rightvt);
6743 /* Native crashes with VT_BYREF */
6744 if (ExtraFlags[i] == VT_BYREF)
6747 memset(&left, 0, sizeof(left));
6748 memset(&right, 0, sizeof(right));
6749 V_VT(&left) = leftvt | ExtraFlags[i];
6750 V_VT(&right) = rightvt | ExtraFlags[i];
6751 V_VT(&result) = VT_EMPTY;
6753 expectedhres = S_OK;
6755 if (leftvt == VT_BSTR)
6756 V_BSTR(&left) = num2_str;
6757 else if (leftvt == VT_DECIMAL)
6759 VarDecFromR8(2.0, &V_DECIMAL(&left));
6760 V_VT(&left) = leftvt | ExtraFlags[i];
6763 /* Division by 0 is undefined */
6767 V_BSTR(&right) = num2_str;
6770 VarDecFromR8(2.0, &V_DECIMAL(&right));
6771 V_VT(&right) = rightvt | ExtraFlags[i];
6774 V_BOOL(&right) = VARIANT_TRUE;
6776 case VT_I2: V_I2(&right) = 2; break;
6777 case VT_I4: V_I4(&right) = 2; break;
6778 case VT_R4: V_R4(&right) = 2.0; break;
6779 case VT_R8: V_R8(&right) = 2.0; break;
6780 case VT_CY: V_CY(&right).int64 = 2; break;
6781 case VT_DATE: V_DATE(&right) = 2; break;
6782 case VT_UI1: V_UI1(&right) = 2; break;
6783 case VT_I8: V_I8(&right) = 2; break;
6787 /* Determine return type */
6788 if (!(rightvt == VT_EMPTY))
6790 if (leftvt == VT_NULL || rightvt == VT_NULL)
6792 else if (leftvt == VT_DECIMAL || rightvt == VT_DECIMAL)
6794 else if (leftvt == VT_I8 || rightvt == VT_I8 ||
6795 leftvt == VT_CY || rightvt == VT_CY ||
6796 leftvt == VT_DATE || rightvt == VT_DATE ||
6797 leftvt == VT_I4 || rightvt == VT_I4 ||
6798 leftvt == VT_BSTR || rightvt == VT_BSTR ||
6799 leftvt == VT_I2 || rightvt == VT_I2 ||
6800 leftvt == VT_BOOL || rightvt == VT_BOOL ||
6801 leftvt == VT_R8 || rightvt == VT_R8 ||
6802 leftvt == VT_UI1 || rightvt == VT_UI1)
6804 if ((leftvt == VT_UI1 && rightvt == VT_R4) ||
6805 (leftvt == VT_R4 && rightvt == VT_UI1))
6807 else if ((leftvt == VT_R4 && (rightvt == VT_BOOL ||
6808 rightvt == VT_I2)) || (rightvt == VT_R4 &&
6809 (leftvt == VT_BOOL || leftvt == VT_I2)))
6814 else if (leftvt == VT_R4 || rightvt == VT_R4)
6817 else if (leftvt == VT_NULL && rightvt == VT_EMPTY)
6822 /* Native VarDiv always returns a error when using any extra flags */
6823 if (ExtraFlags[i] != 0)
6826 hres = pVarDiv(&left, &right, &result);
6828 /* Check expected HRESULT and if result variant type is correct */
6830 ok (hres == DISP_E_BADVARTYPE || hres == DISP_E_TYPEMISMATCH ||
6831 hres == DISP_E_OVERFLOW || hres == DISP_E_DIVBYZERO,
6832 "VarDiv: %s|0x%X, %s|0x%X: got vt %s hr 0x%X\n",
6833 vtstr(leftvt), ExtraFlags[i], vtstr(rightvt), ExtraFlags[i],
6834 vtstr(V_VT(&result)), hres);
6836 ok (hres == S_OK && resvt == V_VT(&result),
6837 "VarDiv: %s|0x%X, %s|0x%X: expected vt %s hr 0x%X, got vt %s hr 0x%X\n",
6838 vtstr(leftvt), ExtraFlags[i], vtstr(rightvt), ExtraFlags[i], vtstr(resvt),
6839 S_OK, vtstr(V_VT(&result)), hres);
6844 /* Test return values for all the good cases */
6845 VARDIV(EMPTY,0,NULL,0,NULL,0);
6846 VARDIV(EMPTY,0,I2,2,R8,0.0);
6847 VARDIV(EMPTY,0,I4,2,R8,0.0);
6848 VARDIV(EMPTY,0,R4,2.0,R4,0.0);
6849 VARDIV(EMPTY,0,R8,2.0,R8,0.0);
6850 VARDIV(EMPTY,0,DATE,2.0,R8,0.0);
6851 VARDIV(EMPTY,0,BSTR,num2_str,R8,0.0);
6852 VARDIV(EMPTY,0,BOOL,VARIANT_TRUE,R8,0.0);
6853 VARDIV(EMPTY,0,UI1,2,R8,0.0);
6854 VARDIV(EMPTY,0,I8,2,R8,0.0);
6855 VARDIV(NULL,0,EMPTY,0,NULL,0);
6856 VARDIV(NULL,0,NULL,0,NULL,0);
6857 VARDIV(NULL,0,I2,2,NULL,0);
6858 VARDIV(NULL,0,I4,2,NULL,0);
6859 VARDIV(NULL,0,R4,2.0,NULL,0);
6860 VARDIV(NULL,0,R8,2.0,NULL,0);
6861 VARDIV(NULL,0,DATE,2,NULL,0);
6862 VARDIV(NULL,0,BSTR,num2_str,NULL,0);
6863 VARDIV(NULL,0,BOOL,VARIANT_TRUE,NULL,0);
6864 VARDIV(NULL,0,UI1,2,NULL,0);
6865 VARDIV(NULL,0,I8,2,NULL,0);
6866 VARDIV(I2,2,NULL,0,NULL,0);
6867 VARDIV(I2,1,I2,2,R8,0.5);
6868 VARDIV(I2,1,I4,2,R8,0.5);
6869 VARDIV(I2,1,R4,2,R4,0.5);
6870 VARDIV(I2,1,R8,2.0,R8,0.5);
6871 VARDIV(I2,1,DATE,2,R8,0.5);
6872 VARDIV(I2,1,BOOL,VARIANT_TRUE,R8,-1.0);
6873 VARDIV(I2,1,UI1,2,R8,0.5);
6874 VARDIV(I2,1,I8,2,R8,0.5);
6875 VARDIV(I4,1,NULL,0,NULL,0);
6876 VARDIV(I4,1,I2,2,R8,0.5);
6877 VARDIV(I4,1,I4,2,R8,0.5);
6878 VARDIV(I4,1,R4,2.0,R8,0.5);
6879 VARDIV(I4,1,R8,2.0,R8,0.5);
6880 VARDIV(I4,1,DATE,2,R8,0.5);
6881 VARDIV(I4,1,BSTR,num2_str,R8,0.5);
6882 VARDIV(I4,1,BOOL,VARIANT_TRUE,R8,-1.0);
6883 VARDIV(I4,1,UI1,2,R8,0.5);
6884 VARDIV(I4,1,I8,2.0,R8,0.5);
6885 VARDIV(R4,1.0,NULL,0,NULL,0);
6886 VARDIV(R4,1.0,I2,2,R4,0.5);
6887 VARDIV(R4,1.0,I4,2,R8,0.5);
6888 VARDIV(R4,1.0,R4,2.0,R4,0.5);
6889 VARDIV(R4,1.0,R8,2.0,R8,0.5);
6890 VARDIV(R4,1.0,DATE,2,R8,0.5);
6891 VARDIV(R4,1.0,BSTR,num2_str,R8,0.5);
6892 VARDIV(R4,1.0,BOOL,VARIANT_TRUE,R4,-1);
6893 VARDIV(R4,1.0,UI1,2,R4,0.5);
6894 VARDIV(R4,1.0,I8,2,R8,0.5);
6895 VARDIV(R8,1.0,NULL,0,NULL,0);
6896 VARDIV(R8,1.0,I2,2,R8,0.5);
6897 VARDIV(R8,1.0,I4,2,R8,0.5);
6898 VARDIV(R8,1.0,R4,2.0,R8,0.5);
6899 VARDIV(R8,1.0,R8,2.0,R8,0.5);
6900 VARDIV(R8,1.0,DATE,2,R8,0.5);
6901 VARDIV(R8,1.0,BSTR,num2_str,R8,0.5);
6902 VARDIV(R8,1.0,BOOL,VARIANT_TRUE,R8,-1.0);
6903 VARDIV(R8,1.0,UI1,2,R8,0.5);
6904 VARDIV(R8,1.0,I8,2,R8,0.5);
6905 VARDIV(DATE,1,NULL,0,NULL,0);
6906 VARDIV(DATE,1,I2,2,R8,0.5);
6907 VARDIV(DATE,1,I4,2,R8,0.5);
6908 VARDIV(DATE,1,R4,2.0,R8,0.5);
6909 VARDIV(DATE,1,R8,2.0,R8,0.5);
6910 VARDIV(DATE,1,DATE,2,R8,0.5);
6911 VARDIV(DATE,1,BSTR,num2_str,R8,0.5);
6912 VARDIV(DATE,1,BOOL,VARIANT_TRUE,R8,-1.0);
6913 VARDIV(DATE,1,UI1,2,R8,0.5);
6914 VARDIV(DATE,1,I8,2,R8,0.5);
6915 VARDIV(BSTR,num1_str,NULL,0,NULL,0);
6916 VARDIV(BSTR,num1_str,I2,2,R8,0.5);
6917 VARDIV(BSTR,num1_str,I4,2,R8,0.5);
6918 VARDIV(BSTR,num1_str,R4,2.0,R8,0.5);
6919 VARDIV(BSTR,num1_str,R8,2.0,R8,0.5);
6920 VARDIV(BSTR,num1_str,DATE,2,R8,0.5);
6921 VARDIV(BSTR,num1_str,BSTR,num2_str,R8,0.5);
6922 VARDIV(BSTR,num1_str,BOOL,VARIANT_TRUE,R8,-1);
6923 VARDIV(BSTR,num1_str,UI1,2,R8,0.5);
6924 VARDIV(BSTR,num1_str,I8,2.0,R8,0.5);
6925 VARDIV(BOOL,VARIANT_TRUE,NULL,0,NULL,0);
6926 VARDIV(BOOL,VARIANT_TRUE,I2,1,R8,-1.0);
6927 VARDIV(BOOL,VARIANT_FALSE,I2,1,R8,0.0);
6928 VARDIV(BOOL,VARIANT_TRUE,I4,1,R8,-1.0);
6929 VARDIV(BOOL,VARIANT_FALSE,I4,1,R8,0.0);
6930 VARDIV(BOOL,VARIANT_TRUE,R4,1,R4,-1.0);
6931 VARDIV(BOOL,VARIANT_FALSE,R4,1,R4,0.0);
6932 VARDIV(BOOL,VARIANT_TRUE,R8,1.0,R8,-1.0);
6933 VARDIV(BOOL,VARIANT_FALSE,R8,1.0,R8,0.0);
6934 VARDIV(BOOL,VARIANT_FALSE,DATE,2,R8,0.0);
6935 VARDIV(BOOL,VARIANT_FALSE,BSTR,num2_str,R8,0.0);
6936 VARDIV(BOOL,VARIANT_TRUE,BOOL,VARIANT_TRUE,R8,1.0);
6937 VARDIV(BOOL,VARIANT_FALSE,BOOL,VARIANT_TRUE,R8,0.0);
6938 VARDIV(BOOL,VARIANT_TRUE,UI1,1,R8,-1.0);
6939 VARDIV(BOOL,VARIANT_TRUE,I8,1,R8,-1.0);
6940 VARDIV(UI1,1,NULL,0,NULL,0);
6941 VARDIV(UI1,1,I2,2,R8,0.5);
6942 VARDIV(UI1,1,I4,2,R8,0.5);
6943 VARDIV(UI1,1,R4,2.0,R4,0.5);
6944 VARDIV(UI1,1,R8,2.0,R8,0.5);
6945 VARDIV(UI1,1,DATE,2,R8,0.5);
6946 VARDIV(UI1,1,BSTR,num2_str,R8,0.5);
6947 VARDIV(UI1,1,BOOL,VARIANT_TRUE,R8,-1);
6948 VARDIV(UI1,1,UI1,2,R8,0.5);
6949 VARDIV(UI1,1,I8,2,R8,0.5);
6950 VARDIV(I8,1,NULL,0,NULL,0);
6951 VARDIV(I8,1,I2,2,R8,0.5);
6952 VARDIV(I8,1,I4,2,R8,0.5);
6953 VARDIV(I8,1,R4,2.0,R8,0.5);
6954 VARDIV(I8,1,R8,2.0,R8,0.5);
6955 VARDIV(I8,1,DATE,2,R8,0.5);
6956 VARDIV(I8,1,BSTR,num2_str,R8,0.5);
6957 VARDIV(I8,1,BOOL,VARIANT_TRUE,R8,-1);
6958 VARDIV(I8,1,UI1,2,R8,0.5);
6959 VARDIV(I8,1,I8,2,R8,0.5);
6961 /* Manually test some VT_CY, VT_DECIMAL variants */
6963 hres = VarCyFromI4(10000, &V_CY(&cy));
6964 ok(hres == S_OK, "VarCyFromI4 failed!\n");
6965 V_VT(&dec) = VT_DECIMAL;
6966 hres = VarDecFromR8(2.0, &V_DECIMAL(&dec));
6967 ok(hres == S_OK, "VarDecFromR4 failed!\n");
6968 memset(&left, 0, sizeof(left));
6969 memset(&right, 0, sizeof(right));
6970 V_VT(&left) = VT_I4;
6972 V_VT(&right) = VT_UI1;
6975 hres = pVarDiv(&cy, &cy, &result);
6976 ok(hres == S_OK && V_VT(&result) == VT_R8,
6977 "VARDIV: expected coerced type VT_R8, got %s!\n", vtstr(V_VT(&result)));
6978 ok(hres == S_OK && EQ_DOUBLE(V_R8(&result), 1.0),
6979 "VARDIV: CY value %f, expected %f\n", V_R8(&result), (double)1.0);
6981 hres = pVarDiv(&cy, &right, &result);
6982 ok(hres == S_OK && V_VT(&result) == VT_R8,
6983 "VARDIV: expected coerced type VT_R8, got %s!\n", vtstr(V_VT(&result)));
6984 ok(hres == S_OK && EQ_DOUBLE(V_R8(&result), 5000.0),
6985 "VARDIV: CY value %f, expected %f\n", V_R8(&result), (double)5000.0);
6987 hres = pVarDiv(&left, &cy, &result);
6988 ok(hres == S_OK && V_VT(&result) == VT_R8,
6989 "VARDIV: expected coerced type VT_R8, got %s!\n", vtstr(V_VT(&result)));
6990 ok(hres == S_OK && EQ_DOUBLE(V_R8(&result), 0.01),
6991 "VARDIV: CY value %f, expected %f\n", V_R8(&result), (double)0.01);
6993 hres = pVarDiv(&left, &dec, &result);
6994 ok(hres == S_OK && V_VT(&result) == VT_DECIMAL,
6995 "VARDIV: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result)));
6996 hres = VarR8FromDec(&V_DECIMAL(&result), &r);
6997 ok(hres == S_OK && EQ_DOUBLE(r, 50.0),
6998 "VARDIV: DECIMAL value %f, expected %f\n", r, (double)50.0);
7000 hres = pVarDiv(&dec, &dec, &result);
7001 ok(hres == S_OK && V_VT(&result) == VT_DECIMAL,
7002 "VARDIV: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result)));
7003 hres = VarR8FromDec(&V_DECIMAL(&result), &r);
7004 ok(hres == S_OK && EQ_DOUBLE(r, 1.0),
7005 "VARDIV: DECIMAL value %f, expected %f\n", r, (double)1.0);
7007 hres = pVarDiv(&dec, &right, &result);
7008 ok(hres == S_OK && V_VT(&result) == VT_DECIMAL,
7009 "VARDIV: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result)));
7010 hres = VarR8FromDec(&V_DECIMAL(&result), &r);
7011 ok(hres == S_OK && EQ_DOUBLE(r, 1.0),
7012 "VARDIV: DECIMAL value %f, expected %f\n", r, (double)1.0);
7014 /* Check for division by zero and overflow */
7015 V_VT(&left) = VT_R8;
7017 V_VT(&right) = VT_R8;
7019 hres = pVarDiv(&left, &right, &result);
7020 ok(hres == DISP_E_DIVBYZERO && V_VT(&result) == VT_EMPTY,
7021 "VARDIV: Division by (1.0/0.0) should result in DISP_E_DIVBYZERO but got 0x%X\n", hres);
7023 V_VT(&left) = VT_R8;
7025 V_VT(&right) = VT_R8;
7027 hres = pVarDiv(&left, &right, &result);
7028 ok(hres == DISP_E_OVERFLOW && V_VT(&result) == VT_EMPTY,
7029 "VARDIV: Division by (0.0/0.0) should result in DISP_E_OVERFLOW but got 0x%X\n", hres);
7031 SysFreeString(num1_str);
7032 SysFreeString(num2_str);
7035 static HRESULT (WINAPI *pVarIdiv)(LPVARIANT,LPVARIANT,LPVARIANT);
7037 static const char *szVarIdivFail = "VarIdiv(%s,%s): expected 0x0,%s,%d, got 0x%X,%s,%d\n";
7039 #define VARIDIV(vt1,val1,vt2,val2,rvt,rval) \
7040 V_VT(&left) = VT_##vt1; V_VT(&right) = VT_##vt2; \
7041 V_##vt1(&left) = val1; V_##vt2(&right) = val2; \
7042 memset(&result,0,sizeof(result)); \
7043 hres = pVarIdiv(&left,&right,&result); \
7044 ok(hres == S_OK && V_VT(&result) == VT_##rvt && \
7045 V_##rvt(&result) == (rval), \
7046 szVarIdivFail, vtstr(VT_##vt1), vtstr(VT_##vt2), \
7047 vtstr(VT_##rvt), (int)(rval), hres, vtstr(V_VT(&result)), \
7048 (int)V_##rvt(&result));
7050 /* Skip any type that is not defined or produces a error for every case */
7051 #define SKIPTESTIDIV(a) \
7052 if (a == VT_ERROR || a == VT_VARIANT || \
7053 a == VT_DISPATCH || a == VT_UNKNOWN || \
7054 a == VT_RECORD || a > VT_UINT || \
7055 a == 15 /*not defined*/) \
7058 static void test_VarIdiv(void)
7060 static const WCHAR str1[] = { '1','\0' };
7061 static const WCHAR str2[] = { '2','\0' };
7062 VARIANT left, right, result, cy, dec;
7063 BSTR num1_str, num2_str;
7069 num1_str = SysAllocString(str1);
7070 num2_str = SysAllocString(str2);
7072 /* Test all possible flag/vt combinations & the resulting vt type */
7073 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
7075 VARTYPE leftvt, rightvt, resvt;
7077 for (leftvt = 0; leftvt <= VT_BSTR_BLOB; leftvt++)
7079 SKIPTESTIDIV(leftvt);
7081 for (rightvt = 0; rightvt <= VT_BSTR_BLOB; rightvt++)
7084 SKIPTESTIDIV(rightvt);
7086 /* Native crashes with extra flag VT_BYREF */
7087 if (ExtraFlags[i] == VT_BYREF)
7090 memset(&left, 0, sizeof(left));
7091 memset(&right, 0, sizeof(right));
7092 V_VT(&left) = leftvt | ExtraFlags[i];
7093 V_VT(&right) = rightvt | ExtraFlags[i];
7094 V_VT(&result) = VT_EMPTY;
7097 if (leftvt == VT_BSTR)
7098 V_BSTR(&left) = num2_str;
7099 else if (leftvt == VT_DECIMAL)
7101 VarDecFromR8(2.0, &V_DECIMAL(&left));
7102 V_VT(&left) = leftvt | ExtraFlags[i];
7105 /* Division by 0 is undefined */
7109 V_BSTR(&right) = num2_str;
7112 VarDecFromR8(2.0, &V_DECIMAL(&right));
7113 V_VT(&right) = rightvt | ExtraFlags[i];
7116 V_BOOL(&right) = VARIANT_TRUE;
7119 VarCyFromI4(10000, &V_CY(&right));
7120 V_VT(&right) = rightvt | ExtraFlags[i];
7122 case VT_I2: V_I2(&right) = 2; break;
7123 case VT_I4: V_I4(&right) = 2; break;
7124 case VT_R4: V_R4(&right) = 2.0; break;
7125 case VT_R8: V_R8(&right) = 2.0; break;
7126 case VT_DATE: V_DATE(&right) = 2; break;
7127 case VT_I1: V_I1(&right) = 2; break;
7128 case VT_UI1: V_UI1(&right) = 2; break;
7129 case VT_UI2: V_UI2(&right) = 2; break;
7130 case VT_UI4: V_UI4(&right) = 2; break;
7131 case VT_I8: V_I8(&right) = 2; break;
7132 case VT_UI8: V_UI8(&right) = 2; break;
7133 case VT_INT: V_INT(&right) = 2; break;
7134 case VT_UINT: V_UINT(&right) = 2; break;
7138 /* Native VarIdiv always returns a error when using any extra
7139 * flags or if the variant combination is I8 and INT.
7141 if ((leftvt == VT_I8 && rightvt == VT_INT) ||
7142 (leftvt == VT_INT && rightvt == VT_I8) ||
7143 (rightvt == VT_EMPTY && leftvt != VT_NULL) ||
7147 /* Determine variant type */
7148 else if (leftvt == VT_NULL || rightvt == VT_NULL)
7150 else if (leftvt == VT_I8 || rightvt == VT_I8)
7152 else if (leftvt == VT_I4 || rightvt == VT_I4 ||
7153 leftvt == VT_INT || rightvt == VT_INT ||
7154 leftvt == VT_UINT || rightvt == VT_UINT ||
7155 leftvt == VT_UI8 || rightvt == VT_UI8 ||
7156 leftvt == VT_UI4 || rightvt == VT_UI4 ||
7157 leftvt == VT_UI2 || rightvt == VT_UI2 ||
7158 leftvt == VT_I1 || rightvt == VT_I1 ||
7159 leftvt == VT_BSTR || rightvt == VT_BSTR ||
7160 leftvt == VT_DATE || rightvt == VT_DATE ||
7161 leftvt == VT_CY || rightvt == VT_CY ||
7162 leftvt == VT_DECIMAL || rightvt == VT_DECIMAL ||
7163 leftvt == VT_R8 || rightvt == VT_R8 ||
7164 leftvt == VT_R4 || rightvt == VT_R4)
7166 else if (leftvt == VT_I2 || rightvt == VT_I2 ||
7167 leftvt == VT_BOOL || rightvt == VT_BOOL ||
7170 else if (leftvt == VT_UI1 || rightvt == VT_UI1)
7175 hres = pVarIdiv(&left, &right, &result);
7177 /* Check expected HRESULT and if result variant type is correct */
7179 ok (hres == DISP_E_BADVARTYPE || hres == DISP_E_TYPEMISMATCH ||
7180 hres == DISP_E_DIVBYZERO,
7181 "VarIdiv: %s|0x%X, %s|0x%X: got vt %s hr 0x%X\n",
7182 vtstr(leftvt), ExtraFlags[i], vtstr(rightvt), ExtraFlags[i],
7183 vtstr(V_VT(&result)), hres);
7185 ok (hres == S_OK && resvt == V_VT(&result),
7186 "VarIdiv: %s|0x%X, %s|0x%X: expected vt %s hr 0x%X, got vt %s hr 0x%X\n",
7187 vtstr(leftvt), ExtraFlags[i], vtstr(rightvt), ExtraFlags[i], vtstr(resvt),
7188 S_OK, vtstr(V_VT(&result)), hres);
7193 /* Test return values for all the good cases */
7194 VARIDIV(EMPTY,0,NULL,0,NULL,0);
7195 VARIDIV(EMPTY,0,I2,1,I2,0);
7196 VARIDIV(EMPTY,0,I4,1,I4,0);
7197 VARIDIV(EMPTY,0,R4,1.0,I4,0);
7198 VARIDIV(EMPTY,0,R8,1.0,I4,0);
7199 VARIDIV(EMPTY,0,DATE,1.0,I4,0);
7200 VARIDIV(EMPTY,0,BSTR,num1_str,I4,0);
7201 VARIDIV(EMPTY,0,BOOL,VARIANT_TRUE,I2,0);
7202 VARIDIV(EMPTY,0,I1,1,I4,0);
7203 VARIDIV(EMPTY,0,UI1,1,I2,0);
7204 VARIDIV(EMPTY,0,UI2,1,I4,0);
7205 VARIDIV(EMPTY,0,UI4,1,I4,0);
7206 VARIDIV(EMPTY,0,I8,1,I8,0);
7207 VARIDIV(EMPTY,0,UI8,1,I4,0);
7208 VARIDIV(EMPTY,0,INT,1,I4,0);
7209 VARIDIV(EMPTY,0,UINT,1,I4,0);
7210 VARIDIV(NULL,0,EMPTY,0,NULL,0);
7211 VARIDIV(NULL,0,NULL,0,NULL,0);
7212 VARIDIV(NULL,0,I2,1,NULL,0);
7213 VARIDIV(NULL,0,I4,1,NULL,0);
7214 VARIDIV(NULL,0,R4,1,NULL,0);
7215 VARIDIV(NULL,0,R8,1,NULL,0);
7216 VARIDIV(NULL,0,DATE,1,NULL,0);
7217 VARIDIV(NULL,0,BSTR,num1_str,NULL,0);
7218 VARIDIV(NULL,0,BOOL,VARIANT_TRUE,NULL,0);
7219 VARIDIV(NULL,0,I1,1,NULL,0);
7220 VARIDIV(NULL,0,UI1,1,NULL,0);
7221 VARIDIV(NULL,0,UI2,1,NULL,0);
7222 VARIDIV(NULL,0,UI4,1,NULL,0);
7223 VARIDIV(NULL,0,I8,1,NULL,0);
7224 VARIDIV(NULL,0,UI8,1,NULL,0);
7225 VARIDIV(NULL,0,INT,1,NULL,0);
7226 VARIDIV(NULL,0,UINT,1,NULL,0);
7227 VARIDIV(I2,2,NULL,0,NULL,0);
7228 VARIDIV(I2,2,I2,1,I2,2);
7229 VARIDIV(I2,2,I4,1,I4,2);
7230 VARIDIV(I2,2,R4,1,I4,2);
7231 VARIDIV(I2,2,R8,1,I4,2);
7232 VARIDIV(I2,2,DATE,1,I4,2);
7233 VARIDIV(I2,2,BSTR,num1_str,I4,2);
7234 VARIDIV(I2,2,BOOL,VARIANT_TRUE,I2,-2);
7235 VARIDIV(I2,2,I1,1,I4,2);
7236 VARIDIV(I2,2,UI1,1,I2,2);
7237 VARIDIV(I2,2,UI2,1,I4,2);
7238 VARIDIV(I2,2,UI4,1,I4,2);
7239 VARIDIV(I2,2,I8,1,I8,2);
7240 VARIDIV(I2,2,UI8,1,I4,2);
7241 VARIDIV(I2,2,INT,1,I4,2);
7242 VARIDIV(I2,2,UINT,1,I4,2);
7243 VARIDIV(I4,2,NULL,0,NULL,0);
7244 VARIDIV(I4,2,I2,1,I4,2);
7245 VARIDIV(I4,2,I4,1,I4,2);
7246 VARIDIV(I4,2,R4,1,I4,2);
7247 VARIDIV(I4,2,R8,1,I4,2);
7248 VARIDIV(I4,2,DATE,1,I4,2);
7249 VARIDIV(I4,2,BSTR,num1_str,I4,2);
7250 VARIDIV(I4,2,BOOL,VARIANT_TRUE,I4,-2);
7251 VARIDIV(I4,2,I1,1,I4,2);
7252 VARIDIV(I4,2,UI1,1,I4,2);
7253 VARIDIV(I4,2,UI2,1,I4,2);
7254 VARIDIV(I4,2,UI4,1,I4,2);
7255 VARIDIV(I4,2,I8,1,I8,2);
7256 VARIDIV(I4,2,UI8,1,I4,2);
7257 VARIDIV(I4,2,INT,1,I4,2);
7258 VARIDIV(I4,2,UINT,1,I4,2);
7259 VARIDIV(R4,2.0,NULL,0,NULL,0);
7260 VARIDIV(R4,2.0,I2,1,I4,2);
7261 VARIDIV(R4,2.0,I4,1,I4,2);
7262 VARIDIV(R4,2.0,R4,1.0,I4,2);
7263 VARIDIV(R4,2.0,R8,1.0,I4,2);
7264 VARIDIV(R4,2.0,DATE,1,I4,2);
7265 VARIDIV(R4,2.0,BSTR,num1_str,I4,2);
7266 VARIDIV(R4,2.0,BOOL,VARIANT_TRUE,I4,-2);
7267 VARIDIV(R4,2.0,I1,1,I4,2);
7268 VARIDIV(R4,2.0,UI1,1,I4,2);
7269 VARIDIV(R4,2.0,UI2,1,I4,2);
7270 VARIDIV(R4,2.0,UI4,1,I4,2);
7271 VARIDIV(R4,2.0,I8,1,I8,2);
7272 VARIDIV(R4,2.0,UI8,1,I4,2);
7273 VARIDIV(R4,2.0,INT,1,I4,2);
7274 VARIDIV(R4,2.0,UINT,1,I4,2);
7275 VARIDIV(R8,2.0,NULL,0,NULL,0);
7276 VARIDIV(R8,2.0,I2,1,I4,2);
7277 VARIDIV(R8,2.0,I4,1,I4,2);
7278 VARIDIV(R8,2.0,R4,1,I4,2);
7279 VARIDIV(R8,2.0,R8,1,I4,2);
7280 VARIDIV(R8,2.0,DATE,1,I4,2);
7281 VARIDIV(R8,2.0,BSTR,num1_str,I4,2);
7282 VARIDIV(R8,2.0,BOOL,VARIANT_TRUE,I4,-2);
7283 VARIDIV(R8,2.0,I1,1,I4,2);
7284 VARIDIV(R8,2.0,UI1,1,I4,2);
7285 VARIDIV(R8,2.0,UI2,1,I4,2);
7286 VARIDIV(R8,2.0,UI4,1,I4,2);
7287 VARIDIV(R8,2.0,I8,1,I8,2);
7288 VARIDIV(R8,2.0,UI8,1,I4,2);
7289 VARIDIV(R8,2.0,INT,1,I4,2);
7290 VARIDIV(R8,2.0,UINT,1,I4,2);
7291 VARIDIV(DATE,2,NULL,0,NULL,0);
7292 VARIDIV(DATE,2,I2,1,I4,2);
7293 VARIDIV(DATE,2,I4,1,I4,2);
7294 VARIDIV(DATE,2,R4,1,I4,2);
7295 VARIDIV(DATE,2,R8,1,I4,2);
7296 VARIDIV(DATE,2,DATE,1,I4,2);
7297 VARIDIV(DATE,2,BSTR,num1_str,I4,2);
7298 VARIDIV(DATE,2,BOOL,VARIANT_TRUE,I4,-2);
7299 VARIDIV(DATE,2,I1,1,I4,2);
7300 VARIDIV(DATE,2,UI1,1,I4,2);
7301 VARIDIV(DATE,2,UI2,1,I4,2);
7302 VARIDIV(DATE,2,UI4,1,I4,2);
7303 VARIDIV(DATE,2,I8,1,I8,2);
7304 VARIDIV(DATE,2,UI8,1,I4,2);
7305 VARIDIV(DATE,2,INT,1,I4,2);
7306 VARIDIV(DATE,2,UINT,1,I4,2);
7307 VARIDIV(BSTR,num2_str,NULL,0,NULL,0);
7308 VARIDIV(BSTR,num2_str,I2,1,I4,2);
7309 VARIDIV(BSTR,num2_str,I4,1,I4,2);
7310 VARIDIV(BSTR,num2_str,R4,1.0,I4,2);
7311 VARIDIV(BSTR,num2_str,R8,1.0,I4,2);
7312 VARIDIV(BSTR,num2_str,DATE,1,I4,2);
7313 VARIDIV(BSTR,num2_str,BSTR,num1_str,I4,2);
7314 VARIDIV(BSTR,num2_str,BOOL,VARIANT_TRUE,I4,-2);
7315 VARIDIV(BSTR,num2_str,I1,1,I4,2);
7316 VARIDIV(BSTR,num2_str,UI1,1,I4,2);
7317 VARIDIV(BSTR,num2_str,UI2,1,I4,2);
7318 VARIDIV(BSTR,num2_str,UI4,1,I4,2);
7319 VARIDIV(BSTR,num2_str,I8,1,I8,2);
7320 VARIDIV(BSTR,num2_str,UI8,1,I4,2);
7321 VARIDIV(BSTR,num2_str,INT,1,I4,2);
7322 VARIDIV(BSTR,num2_str,UINT,1,I4,2);
7323 VARIDIV(BOOL,VARIANT_TRUE,NULL,0,NULL,0);
7324 VARIDIV(BOOL,VARIANT_TRUE,I2,1,I2,-1);
7325 VARIDIV(BOOL,VARIANT_TRUE,I4,1,I4,-1);
7326 VARIDIV(BOOL,VARIANT_TRUE,R4,1.0,I4,-1);
7327 VARIDIV(BOOL,VARIANT_TRUE,R8,1.0,I4,-1);
7328 VARIDIV(BOOL,VARIANT_TRUE,DATE,1,I4,-1);
7329 VARIDIV(BOOL,VARIANT_TRUE,BSTR,num1_str,I4,-1);
7330 VARIDIV(BOOL,VARIANT_TRUE,BOOL,VARIANT_TRUE,I2,1);
7331 VARIDIV(BOOL,VARIANT_TRUE,I1,1,I4,-1);
7332 VARIDIV(BOOL,VARIANT_TRUE,UI1,1,I2,-1);
7333 VARIDIV(BOOL,VARIANT_TRUE,UI2,1,I4,-1);
7334 VARIDIV(BOOL,VARIANT_TRUE,UI4,1,I4,-1);
7335 VARIDIV(BOOL,VARIANT_TRUE,I8,1,I8,-1);
7336 VARIDIV(BOOL,VARIANT_TRUE,UI8,1,I4,-1);
7337 VARIDIV(BOOL,VARIANT_TRUE,INT,1,I4,-1);
7338 VARIDIV(BOOL,VARIANT_TRUE,UINT,1,I4,-1);
7339 VARIDIV(I1,2,NULL,0,NULL,0);
7340 VARIDIV(I1,2,I2,1,I4,2);
7341 VARIDIV(I1,2,I4,1,I4,2);
7342 VARIDIV(I1,2,R4,1.0,I4,2);
7343 VARIDIV(I1,2,R8,1.0,I4,2);
7344 VARIDIV(I1,2,DATE,1,I4,2);
7345 VARIDIV(I1,2,BSTR,num1_str,I4,2);
7346 VARIDIV(I1,2,BOOL,VARIANT_TRUE,I4,-2);
7347 VARIDIV(I1,2,I1,1,I4,2);
7348 VARIDIV(I1,2,UI1,1,I4,2);
7349 VARIDIV(I1,2,UI2,1,I4,2);
7350 VARIDIV(I1,2,UI4,1,I4,2);
7351 VARIDIV(I1,2,I8,1,I8,2);
7352 VARIDIV(I1,2,UI8,1,I4,2);
7353 VARIDIV(I1,2,INT,1,I4,2);
7354 VARIDIV(I1,2,UINT,1,I4,2);
7355 VARIDIV(UI1,2,NULL,0,NULL,0);
7356 VARIDIV(UI1,2,I2,1,I2,2);
7357 VARIDIV(UI1,2,I4,1,I4,2);
7358 VARIDIV(UI1,2,R4,1.0,I4,2);
7359 VARIDIV(UI1,2,R8,1.0,I4,2);
7360 VARIDIV(UI1,2,DATE,1,I4,2);
7361 VARIDIV(UI1,2,BSTR,num1_str,I4,2);
7362 VARIDIV(UI1,2,BOOL,VARIANT_TRUE,I2,-2);
7363 VARIDIV(UI1,2,I1,1,I4,2);
7364 VARIDIV(UI1,2,UI1,1,UI1,2);
7365 VARIDIV(UI1,2,UI2,1,I4,2);
7366 VARIDIV(UI1,2,UI4,1,I4,2);
7367 VARIDIV(UI1,2,I8,1,I8,2);
7368 VARIDIV(UI1,2,UI8,1,I4,2);
7369 VARIDIV(UI1,2,INT,1,I4,2);
7370 VARIDIV(UI1,2,UINT,1,I4,2);
7371 VARIDIV(UI2,2,NULL,0,NULL,0);
7372 VARIDIV(UI2,2,I2,1,I4,2);
7373 VARIDIV(UI2,2,I4,1,I4,2);
7374 VARIDIV(UI2,2,R4,1.0,I4,2);
7375 VARIDIV(UI2,2,R8,1.0,I4,2);
7376 VARIDIV(UI2,2,DATE,1,I4,2);
7377 VARIDIV(UI2,2,BSTR,num1_str,I4,2);
7378 VARIDIV(UI2,2,BOOL,VARIANT_TRUE,I4,-2);
7379 VARIDIV(UI2,2,I1,1,I4,2);
7380 VARIDIV(UI2,2,UI1,1,I4,2);
7381 VARIDIV(UI2,2,UI2,1,I4,2);
7382 VARIDIV(UI2,2,UI4,1,I4,2);
7383 VARIDIV(UI2,2,I8,1,I8,2);
7384 VARIDIV(UI2,2,UI8,1,I4,2);
7385 VARIDIV(UI2,2,INT,1,I4,2);
7386 VARIDIV(UI2,2,UINT,1,I4,2);
7387 VARIDIV(UI4,2,NULL,0,NULL,0);
7388 VARIDIV(UI4,2,I2,1,I4,2);
7389 VARIDIV(UI4,2,I4,1,I4,2);
7390 VARIDIV(UI4,2,R4,1.0,I4,2);
7391 VARIDIV(UI4,2,R8,1.0,I4,2);
7392 VARIDIV(UI4,2,DATE,1,I4,2);
7393 VARIDIV(UI4,2,BSTR,num1_str,I4,2);
7394 VARIDIV(UI4,2,BOOL,VARIANT_TRUE,I4,-2);
7395 VARIDIV(UI4,2,I1,1,I4,2);
7396 VARIDIV(UI4,2,UI1,1,I4,2);
7397 VARIDIV(UI4,2,UI2,1,I4,2);
7398 VARIDIV(UI4,2,UI4,1,I4,2);
7399 VARIDIV(UI4,2,I8,1,I8,2);
7400 VARIDIV(UI4,2,UI8,1,I4,2);
7401 VARIDIV(UI4,2,INT,1,I4,2);
7402 VARIDIV(UI4,2,UINT,1,I4,2);
7403 VARIDIV(I8,2,NULL,0,NULL,0);
7404 VARIDIV(I8,2,I2,1,I8,2);
7405 VARIDIV(I8,2,I4,1,I8,2);
7406 VARIDIV(I8,2,R4,1.0,I8,2);
7407 VARIDIV(I8,2,R8,1.0,I8,2);
7408 VARIDIV(I8,2,DATE,1,I8,2);
7409 VARIDIV(I8,2,BSTR,num1_str,I8,2);
7410 VARIDIV(I8,2,BOOL,1,I8,2);
7411 VARIDIV(I8,2,I1,1,I8,2);
7412 VARIDIV(I8,2,UI1,1,I8,2);
7413 VARIDIV(I8,2,UI2,1,I8,2);
7414 VARIDIV(I8,2,UI4,1,I8,2);
7415 VARIDIV(I8,2,I8,1,I8,2);
7416 VARIDIV(I8,2,UI8,1,I8,2);
7417 VARIDIV(I8,2,UINT,1,I8,2);
7418 VARIDIV(UI8,2,NULL,0,NULL,0);
7419 VARIDIV(UI8,2,I2,1,I4,2);
7420 VARIDIV(UI8,2,I4,1,I4,2);
7421 VARIDIV(UI8,2,R4,1.0,I4,2);
7422 VARIDIV(UI8,2,R8,1.0,I4,2);
7423 VARIDIV(UI8,2,DATE,1,I4,2);
7424 VARIDIV(UI8,2,BSTR,num1_str,I4,2);
7425 VARIDIV(UI8,2,BOOL,VARIANT_TRUE,I4,-2);
7426 VARIDIV(UI8,2,I1,1,I4,2);
7427 VARIDIV(UI8,2,UI1,1,I4,2);
7428 VARIDIV(UI8,2,UI2,1,I4,2);
7429 VARIDIV(UI8,2,UI4,1,I4,2);
7430 VARIDIV(UI8,2,I8,1,I8,2);
7431 VARIDIV(UI8,2,UI8,1,I4,2);
7432 VARIDIV(UI8,2,INT,1,I4,2);
7433 VARIDIV(UI8,2,UINT,1,I4,2);
7434 VARIDIV(INT,2,NULL,0,NULL,0);
7435 VARIDIV(INT,2,I2,1,I4,2);
7436 VARIDIV(INT,2,I4,1,I4,2);
7437 VARIDIV(INT,2,R4,1.0,I4,2);
7438 VARIDIV(INT,2,R8,1.0,I4,2);
7439 VARIDIV(INT,2,DATE,1,I4,2);
7440 VARIDIV(INT,2,BSTR,num1_str,I4,2);
7441 VARIDIV(INT,2,BOOL,VARIANT_TRUE,I4,-2);
7442 VARIDIV(INT,2,I1,1,I4,2);
7443 VARIDIV(INT,2,UI1,1,I4,2);
7444 VARIDIV(INT,2,UI2,1,I4,2);
7445 VARIDIV(INT,2,UI4,1,I4,2);
7446 VARIDIV(INT,2,UI8,1,I4,2);
7447 VARIDIV(INT,2,INT,1,I4,2);
7448 VARIDIV(INT,2,UINT,1,I4,2);
7449 VARIDIV(UINT,2,NULL,0,NULL,0);
7450 VARIDIV(UINT,2,I2,1,I4,2);
7451 VARIDIV(UINT,2,I4,1,I4,2);
7452 VARIDIV(UINT,2,R4,1.0,I4,2);
7453 VARIDIV(UINT,2,R8,1.0,I4,2);
7454 VARIDIV(UINT,2,DATE,1,I4,2);
7455 VARIDIV(UINT,2,BSTR,num1_str,I4,2);
7456 VARIDIV(UINT,2,BOOL,VARIANT_TRUE,I4,-2);
7457 VARIDIV(UINT,2,I1,1,I4,2);
7458 VARIDIV(UINT,2,UI1,1,I4,2);
7459 VARIDIV(UINT,2,UI2,1,I4,2);
7460 VARIDIV(UINT,2,UI4,1,I4,2);
7461 VARIDIV(UINT,2,I8,1,I8,2);
7462 VARIDIV(UINT,2,UI8,1,I4,2);
7463 VARIDIV(UINT,2,INT,1,I4,2);
7464 VARIDIV(UINT,2,UINT,1,I4,2);
7466 /* Manually test some VT_CY, VT_DECIMAL variants */
7468 hres = VarCyFromI4(10000, &V_CY(&cy));
7469 ok(hres == S_OK, "VarCyFromI4 failed!\n");
7470 V_VT(&dec) = VT_DECIMAL;
7471 hres = VarDecFromR8(2.0, &V_DECIMAL(&dec));
7472 ok(hres == S_OK, "VarDecFromR4 failed!\n");
7473 memset(&left, 0, sizeof(left));
7474 memset(&right, 0, sizeof(right));
7475 V_VT(&left) = VT_I4;
7477 V_VT(&right) = VT_I8;
7480 hres = VarIdiv(&cy, &cy, &result);
7481 ok(hres == S_OK && V_VT(&result) == VT_I4,
7482 "VARIDIV: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
7483 S_OK, hres, vtstr(V_VT(&result)));
7484 ok(hres == S_OK && V_I4(&result) == 1,
7485 "VARIDIV: CY value %d, expected %d\n", V_I4(&result), 1);
7487 hres = VarIdiv(&cy, &right, &result);
7488 ok(hres == S_OK && V_VT(&result) == VT_I8,
7489 "VARIDIV: expected coerced hres 0x%X type VT_I8, got hres 0x%X type %s!\n",
7490 S_OK, hres, vtstr(V_VT(&result)));
7491 ok(hres == S_OK && V_I8(&result) == 5000,
7492 "VARIDIV: CY value 0x%x%08x, expected 0x%x\n",
7493 (DWORD)(V_I8(&result) >>32), (DWORD)V_I8(&result), 5000);
7495 hres = VarIdiv(&left, &cy, &result);
7496 ok(hres == S_OK && V_VT(&result) == VT_I4,
7497 "VARIDIV: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
7498 S_OK, hres, vtstr(V_VT(&result)));
7499 ok(hres == S_OK && V_I4(&result) == 0,
7500 "VARIDIV: CY value %d, expected %d\n", V_I4(&result), 0);
7502 hres = VarIdiv(&left, &dec, &result);
7503 ok(hres == S_OK && V_VT(&result) == VT_I4,
7504 "VARIDIV: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
7505 S_OK, hres, vtstr(V_VT(&result)));
7506 ok(hres == S_OK && V_I4(&result) == 50,
7507 "VARIDIV: DECIMAL value %d, expected %d\n", V_I4(&result), 50);
7509 hres = VarIdiv(&dec, &dec, &result);
7510 ok(hres == S_OK && V_VT(&result) == VT_I4,
7511 "VARIDIV: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
7512 S_OK, hres, vtstr(V_VT(&result)));
7513 ok(hres == S_OK && V_I4(&result) == 1,
7514 "VARIDIV: DECIMAL value %d, expected %d\n", V_I4(&result), 1);
7516 hres = VarIdiv(&dec, &right, &result);
7517 ok(hres == S_OK && V_VT(&result) == VT_I8,
7518 "VARIDIV: expected coerced hres 0x%X type VT_I8, got hres 0x%X type%s!\n",
7519 S_OK, hres, vtstr(V_VT(&result)));
7520 ok(hres == S_OK && V_I8(&result) == 1,
7521 "VARIDIV: DECIMAL value 0x%x%08x, expected %d\n",
7522 (DWORD)(V_I8(&result) >> 32), (DWORD)V_I8(&result), 1);
7524 /* Check for division by zero */
7525 V_VT(&left) = VT_INT;
7527 V_VT(&right) = VT_INT;
7529 hres = pVarIdiv(&left, &right, &result);
7530 ok(hres == DISP_E_DIVBYZERO && V_VT(&result) == VT_EMPTY,
7531 "VARIDIV: Division by 0 should result in DISP_E_DIVBYZERO but got 0x%X\n", hres);
7533 V_VT(&left) = VT_INT;
7535 V_VT(&right) = VT_INT;
7537 hres = pVarIdiv(&left, &right, &result);
7538 ok(hres == DISP_E_DIVBYZERO && V_VT(&result) == VT_EMPTY,
7539 "VARIDIV: Division by 0 should result in DISP_E_DIVBYZERO but got 0x%X\n", hres);
7541 SysFreeString(num1_str);
7542 SysFreeString(num2_str);
7546 static HRESULT (WINAPI *pVarImp)(LPVARIANT,LPVARIANT,LPVARIANT);
7548 static const char *szVarImpFail = "VarImp(%s,%s): expected 0x0,%s,%d, got 0x%X,%s,%d\n";
7550 #define VARIMP(vt1,val1,vt2,val2,rvt,rval) \
7551 V_VT(&left) = VT_##vt1; V_VT(&right) = VT_##vt2; \
7552 V_##vt1(&left) = val1; V_##vt2(&right) = val2; \
7553 memset(&result,0,sizeof(result)); \
7554 hres = pVarImp(&left,&right,&result); \
7555 ok(hres == S_OK && V_VT(&result) == VT_##rvt && \
7556 V_##rvt(&result) == (rval), \
7557 szVarImpFail, vtstr(VT_##vt1), vtstr(VT_##vt2), \
7558 vtstr(VT_##rvt), (int)(rval), hres, vtstr(V_VT(&result)), \
7559 (int)V_##rvt(&result));
7561 /* Skip any type that is not defined or produces a error for every case */
7562 #define SKIPTESTIMP(a) \
7563 if (a == VT_ERROR || a == VT_VARIANT || \
7564 a == VT_DISPATCH || a == VT_UNKNOWN || \
7565 a == VT_RECORD || a > VT_UINT || \
7566 a == 15 /*not defined*/) \
7569 static void test_VarImp(void)
7571 static const WCHAR szFalse[] = { '#','F','A','L','S','E','#','\0' };
7572 static const WCHAR szTrue[] = { '#','T','R','U','E','#','\0' };
7573 VARIANT left, right, result, cy, dec;
7574 BSTR true_str, false_str;
7580 true_str = SysAllocString(szTrue);
7581 false_str = SysAllocString(szFalse);
7583 /* Test all possible flag/vt combinations & the resulting vt type */
7584 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
7586 VARTYPE leftvt, rightvt, resvt;
7588 for (leftvt = 0; leftvt <= VT_BSTR_BLOB; leftvt++)
7590 SKIPTESTIMP(leftvt);
7592 for (rightvt = 0; rightvt <= VT_BSTR_BLOB; rightvt++)
7595 SKIPTESTIMP(rightvt);
7597 /* Native crashes using the the extra flag VT_BYREF
7598 * or with the following VT combinations
7600 if ((leftvt == VT_UI4 && rightvt == VT_BSTR) ||
7601 (leftvt == VT_UI8 && rightvt == VT_BSTR) ||
7602 ExtraFlags[i] == VT_BYREF)
7605 memset(&left, 0, sizeof(left));
7606 memset(&right, 0, sizeof(right));
7607 V_VT(&left) = leftvt | ExtraFlags[i];
7608 V_VT(&right) = rightvt | ExtraFlags[i];
7609 V_VT(&result) = VT_EMPTY;
7612 if (leftvt == VT_BSTR)
7613 V_BSTR(&left) = true_str;
7615 /* This allows us to test return types that are not NULL
7616 * (NULL Imp value = n, NULL Imp 0 = NULL)
7621 V_BSTR(&right) = true_str;
7624 VarDecFromR8(2.0, &V_DECIMAL(&right));
7625 V_VT(&right) = rightvt | ExtraFlags[i];
7628 V_BOOL(&right) = VARIANT_TRUE;
7630 case VT_I1: V_I1(&right) = 2; break;
7631 case VT_I2: V_I2(&right) = 2; break;
7632 case VT_I4: V_I4(&right) = 2; break;
7633 case VT_R4: V_R4(&right) = 2.0; break;
7634 case VT_R8: V_R8(&right) = 2.0; break;
7635 case VT_CY: V_CY(&right).int64 = 10000; break;
7636 case VT_DATE: V_DATE(&right) = 2; break;
7637 case VT_I8: V_I8(&right) = 2; break;
7638 case VT_INT: V_INT(&right) = 2; break;
7639 case VT_UINT: V_UINT(&right) = 2; break;
7640 case VT_UI1: V_UI1(&right) = 2; break;
7641 case VT_UI2: V_UI2(&right) = 2; break;
7642 case VT_UI4: V_UI4(&right) = 2; break;
7643 case VT_UI8: V_UI8(&right) = 2; break;
7647 /* Native VarImp always returns a error when using any extra
7648 * flags or if the variants are I8 and INT.
7650 if ((leftvt == VT_I8 && rightvt == VT_INT) ||
7654 /* Determine result type */
7655 else if ((leftvt == VT_BSTR && rightvt == VT_NULL) ||
7656 (leftvt == VT_NULL && rightvt == VT_NULL) ||
7657 (leftvt == VT_NULL && rightvt == VT_EMPTY))
7659 else if (leftvt == VT_I8 || rightvt == VT_I8)
7661 else if (leftvt == VT_I4 || rightvt == VT_I4 ||
7662 leftvt == VT_INT || rightvt == VT_INT ||
7663 leftvt == VT_UINT || rightvt == VT_UINT ||
7664 leftvt == VT_UI4 || rightvt == VT_UI4 ||
7665 leftvt == VT_UI8 || rightvt == VT_UI8 ||
7666 leftvt == VT_UI2 || rightvt == VT_UI2 ||
7667 leftvt == VT_DECIMAL || rightvt == VT_DECIMAL ||
7668 leftvt == VT_DATE || rightvt == VT_DATE ||
7669 leftvt == VT_CY || rightvt == VT_CY ||
7670 leftvt == VT_R8 || rightvt == VT_R8 ||
7671 leftvt == VT_R4 || rightvt == VT_R4 ||
7672 leftvt == VT_I1 || rightvt == VT_I1)
7674 else if ((leftvt == VT_UI1 && rightvt == VT_UI1) ||
7675 (leftvt == VT_UI1 && rightvt == VT_NULL) ||
7676 (leftvt == VT_NULL && rightvt == VT_UI1))
7678 else if (leftvt == VT_EMPTY || rightvt == VT_EMPTY ||
7679 leftvt == VT_I2 || rightvt == VT_I2 ||
7680 leftvt == VT_UI1 || rightvt == VT_UI1)
7682 else if (leftvt == VT_BOOL || rightvt == VT_BOOL ||
7683 leftvt == VT_BSTR || rightvt == VT_BSTR)
7686 hres = pVarImp(&left, &right, &result);
7688 /* Check expected HRESULT and if result variant type is correct */
7690 ok (hres == DISP_E_BADVARTYPE || hres == DISP_E_TYPEMISMATCH,
7691 "VarImp: %s|0x%X, %s|0x%X: got vt %s hr 0x%X\n",
7692 vtstr(leftvt), ExtraFlags[i], vtstr(rightvt), ExtraFlags[i],
7693 vtstr(V_VT(&result)), hres);
7695 ok (hres == S_OK && resvt == V_VT(&result),
7696 "VarImp: %s|0x%X, %s|0x%X: expected vt %s hr 0x%X, got vt %s hr 0x%X\n",
7697 vtstr(leftvt), ExtraFlags[i], vtstr(rightvt), ExtraFlags[i], vtstr(resvt),
7698 S_OK, vtstr(V_VT(&result)), hres);
7703 VARIMP(EMPTY,0,EMPTY,0,I2,-1);
7704 VARIMP(EMPTY,0,NULL,0,I2,-1);
7705 VARIMP(EMPTY,0,I2,-1,I2,-1);
7706 VARIMP(EMPTY,0,I4,-1,I4,-1);
7707 VARIMP(EMPTY,0,R4,0.0,I4,-1);
7708 VARIMP(EMPTY,0,R8,-1.0,I4,-1);
7709 VARIMP(EMPTY,0,DATE,0,I4,-1);
7710 VARIMP(EMPTY,0,BSTR,true_str,I2,-1);
7711 VARIMP(EMPTY,0,BOOL,VARIANT_FALSE,I2,-1);
7712 VARIMP(EMPTY,0,I1,0,I4,-1);
7713 VARIMP(EMPTY,0,UI1,1,I2,-1);
7714 VARIMP(EMPTY,0,UI2,1,I4,-1);
7715 VARIMP(EMPTY,0,UI4,1,I4,-1);
7716 VARIMP(EMPTY,0,I8,1,I8,-1);
7717 VARIMP(EMPTY,0,UI8,1,I4,-1);
7718 VARIMP(EMPTY,0,INT,-1,I4,-1);
7719 VARIMP(EMPTY,0,UINT,1,I4,-1);
7720 VARIMP(NULL,0,EMPTY,0,NULL,0);
7721 VARIMP(NULL,0,NULL,0,NULL,0);
7722 VARIMP(NULL,0,I2,-1,I2,-1);
7723 VARIMP(NULL,0,I4,-1,I4,-1);
7724 VARIMP(NULL,0,R4,0.0,NULL,0);
7725 VARIMP(NULL,0,R8,-1.0,I4,-1);
7726 VARIMP(NULL,0,DATE,0,NULL,0);
7727 VARIMP(NULL,0,BSTR,true_str,BOOL,-1);
7728 VARIMP(NULL,0,BOOL,VARIANT_FALSE,NULL,0);
7729 VARIMP(NULL,0,I1,0,NULL,0);
7730 VARIMP(NULL,0,UI1,1,UI1,1);
7731 VARIMP(NULL,0,UI2,1,I4,1);
7732 VARIMP(NULL,0,UI4,1,I4,1);
7733 VARIMP(NULL,0,I8,1,I8,1);
7734 VARIMP(NULL,0,UI8,1,I4,1);
7735 VARIMP(NULL,0,INT,-1,I4,-1);
7736 VARIMP(NULL,0,UINT,1,I4,1);
7737 VARIMP(I2,-1,EMPTY,0,I2,0);
7738 VARIMP(I2,-1,I2,-1,I2,-1);
7739 VARIMP(I2,-1,I4,-1,I4,-1);
7740 VARIMP(I2,-1,R4,0.0,I4,0);
7741 VARIMP(I2,-1,R8,-1.0,I4,-1);
7742 VARIMP(I2,-1,DATE,0,I4,0);
7743 VARIMP(I2,-1,BSTR,true_str,I2,-1);
7744 VARIMP(I2,-1,BOOL,VARIANT_FALSE,I2,0);
7745 VARIMP(I2,-1,I1,0,I4,0);
7746 VARIMP(I2,-1,UI1,1,I2,1);
7747 VARIMP(I2,-1,UI2,1,I4,1);
7748 VARIMP(I2,-1,UI4,1,I4,1);
7749 VARIMP(I2,-1,I8,1,I8,1);
7750 VARIMP(I2,-1,UI8,1,I4,1);
7751 VARIMP(I2,-1,INT,-1,I4,-1);
7752 VARIMP(I2,-1,UINT,1,I4,1);
7753 VARIMP(I4,2,EMPTY,0,I4,-3);
7754 VARIMP(I4,2,NULL,0,I4,-3);
7755 VARIMP(I4,2,I2,-1,I4,-1);
7756 VARIMP(I4,2,I4,-1,I4,-1);
7757 VARIMP(I4,2,R4,0.0,I4,-3);
7758 VARIMP(I4,2,R8,-1.0,I4,-1);
7759 VARIMP(I4,2,DATE,0,I4,-3);
7760 VARIMP(I4,2,BSTR,true_str,I4,-1);
7761 VARIMP(I4,2,BOOL,VARIANT_FALSE,I4,-3);
7762 VARIMP(I4,2,I1,0,I4,-3);
7763 VARIMP(I4,2,UI1,1,I4,-3);
7764 VARIMP(I4,2,UI2,1,I4,-3);
7765 VARIMP(I4,2,UI4,1,I4,-3);
7766 VARIMP(I4,2,I8,1,I8,-3);
7767 VARIMP(I4,2,UI8,1,I4,-3);
7768 VARIMP(I4,2,INT,-1,I4,-1);
7769 VARIMP(I4,2,UINT,1,I4,-3);
7770 VARIMP(R4,-1.0,EMPTY,0,I4,0);
7771 VARIMP(R4,-1.0,NULL,0,NULL,0);
7772 VARIMP(R4,-1.0,I2,-1,I4,-1);
7773 VARIMP(R4,-1.0,I4,-1,I4,-1);
7774 VARIMP(R4,-1.0,R4,0.0,I4,0);
7775 VARIMP(R4,-1.0,R8,-1.0,I4,-1);
7776 VARIMP(R4,-1.0,DATE,1,I4,1);
7777 VARIMP(R4,-1.0,BSTR,true_str,I4,-1);
7778 VARIMP(R4,-1.0,BOOL,VARIANT_FALSE,I4,0);
7779 VARIMP(R4,-1.0,I1,0,I4,0);
7780 VARIMP(R4,-1.0,UI1,1,I4,1);
7781 VARIMP(R4,-1.0,UI2,1,I4,1);
7782 VARIMP(R4,-1.0,UI4,1,I4,1);
7783 VARIMP(R4,-1.0,I8,1,I8,1);
7784 VARIMP(R4,-1.0,UI8,1,I4,1);
7785 VARIMP(R4,-1.0,INT,-1,I4,-1);
7786 VARIMP(R4,-1.0,UINT,1,I4,1);
7787 VARIMP(R8,1.0,EMPTY,0,I4,-2);
7788 VARIMP(R8,1.0,NULL,0,I4,-2);
7789 VARIMP(R8,1.0,I2,-1,I4,-1);
7790 VARIMP(R8,1.0,I4,-1,I4,-1);
7791 VARIMP(R8,1.0,R4,0.0,I4,-2);
7792 VARIMP(R8,1.0,R8,-1.0,I4,-1);
7793 VARIMP(R8,1.0,DATE,0,I4,-2);
7794 VARIMP(R8,1.0,BSTR,true_str,I4,-1);
7795 VARIMP(R8,1.0,BOOL,VARIANT_FALSE,I4,-2);
7796 VARIMP(R8,1.0,I1,0,I4,-2);
7797 VARIMP(R8,1.0,UI1,1,I4,-1);
7798 VARIMP(R8,1.0,UI2,1,I4,-1);
7799 VARIMP(R8,1.0,UI4,1,I4,-1);
7800 VARIMP(R8,1.0,I8,1,I8,-1);
7801 VARIMP(R8,1.0,UI8,1,I4,-1);
7802 VARIMP(R8,1.0,INT,-1,I4,-1);
7803 VARIMP(R8,1.0,UINT,1,I4,-1);
7804 VARIMP(DATE,0,EMPTY,0,I4,-1);
7805 VARIMP(DATE,0,NULL,0,I4,-1);
7806 VARIMP(DATE,0,I2,-1,I4,-1);
7807 VARIMP(DATE,0,I4,-1,I4,-1);
7808 VARIMP(DATE,0,R4,0.0,I4,-1);
7809 VARIMP(DATE,0,R8,-1.0,I4,-1);
7810 VARIMP(DATE,0,DATE,0,I4,-1);
7811 VARIMP(DATE,0,BSTR,true_str,I4,-1);
7812 VARIMP(DATE,0,BOOL,VARIANT_FALSE,I4,-1);
7813 VARIMP(DATE,0,I1,0,I4,-1);
7814 VARIMP(DATE,0,UI1,1,I4,-1);
7815 VARIMP(DATE,0,UI2,1,I4,-1);
7816 VARIMP(DATE,0,UI4,1,I4,-1);
7817 VARIMP(DATE,0,I8,1,I8,-1);
7818 VARIMP(DATE,0,UI8,1,I4,-1);
7819 VARIMP(DATE,0,INT,-1,I4,-1);
7820 VARIMP(DATE,0,UINT,1,I4,-1);
7821 VARIMP(BSTR,false_str,EMPTY,0,I2,-1);
7822 VARIMP(BSTR,false_str,NULL,0,BOOL,-1);
7823 VARIMP(BSTR,false_str,I2,-1,I2,-1);
7824 VARIMP(BSTR,false_str,I4,-1,I4,-1);
7825 VARIMP(BSTR,false_str,R4,0.0,I4,-1);
7826 VARIMP(BSTR,false_str,R8,-1.0,I4,-1);
7827 VARIMP(BSTR,false_str,DATE,0,I4,-1);
7828 VARIMP(BSTR,false_str,BSTR,true_str,BOOL,-1);
7829 VARIMP(BSTR,false_str,BOOL,VARIANT_FALSE,BOOL,-1);
7830 VARIMP(BSTR,false_str,I1,0,I4,-1);
7831 VARIMP(BSTR,false_str,UI1,1,I2,-1);
7832 VARIMP(BSTR,false_str,UI2,1,I4,-1);
7833 VARIMP(BSTR,false_str,UI4,1,I4,-1);
7834 VARIMP(BSTR,false_str,I8,1,I8,-1);
7835 VARIMP(BSTR,false_str,UI8,1,I4,-1);
7836 VARIMP(BSTR,false_str,INT,-1,I4,-1);
7837 VARIMP(BSTR,false_str,UINT,1,I4,-1);
7838 VARIMP(BOOL,VARIANT_TRUE,EMPTY,0,I2,0);
7839 VARIMP(BOOL,VARIANT_TRUE,NULL,0,NULL,0);
7840 VARIMP(BOOL,VARIANT_TRUE,I2,-1,I2,-1);
7841 VARIMP(BOOL,VARIANT_TRUE,I4,-1,I4,-1);
7842 VARIMP(BOOL,VARIANT_TRUE,R4,0.0,I4,0);
7843 VARIMP(BOOL,VARIANT_TRUE,R8,-1.0,I4,-1);
7844 VARIMP(BOOL,VARIANT_TRUE,DATE,0,I4,0);
7845 VARIMP(BOOL,VARIANT_TRUE,BSTR,true_str,BOOL,-1);
7846 VARIMP(BOOL,VARIANT_TRUE,BOOL,VARIANT_FALSE,BOOL,0);
7847 VARIMP(BOOL,VARIANT_TRUE,I1,0,I4,0);
7848 VARIMP(BOOL,VARIANT_TRUE,UI1,1,I2,1);
7849 VARIMP(BOOL,VARIANT_TRUE,UI2,1,I4,1);
7850 VARIMP(BOOL,VARIANT_TRUE,UI4,1,I4,1);
7851 VARIMP(BOOL,VARIANT_TRUE,I8,1,I8,1);
7852 VARIMP(BOOL,VARIANT_TRUE,UI8,1,I4,1);
7853 VARIMP(BOOL,VARIANT_TRUE,INT,-1,I4,-1);
7854 VARIMP(BOOL,VARIANT_TRUE,UINT,1,I4,1);
7855 VARIMP(I1,-1,EMPTY,0,I4,0);
7856 VARIMP(I1,-1,NULL,0,NULL,0);
7857 VARIMP(I1,-1,I2,-1,I4,-1);
7858 VARIMP(I1,-1,I4,-1,I4,-1);
7859 VARIMP(I1,-1,R4,0.0,I4,0);
7860 VARIMP(I1,-1,R8,-1.0,I4,-1);
7861 VARIMP(I1,-1,DATE,0,I4,0);
7862 VARIMP(I1,-1,BSTR,true_str,I4,-1);
7863 VARIMP(I1,-1,BOOL,VARIANT_FALSE,I4,0);
7864 VARIMP(I1,-1,I1,0,I4,0);
7865 VARIMP(I1,-1,UI1,1,I4,1);
7866 VARIMP(I1,-1,UI2,1,I4,1);
7867 VARIMP(I1,-1,UI4,1,I4,1);
7868 VARIMP(I1,-1,I8,1,I8,1);
7869 VARIMP(I1,-1,UI8,1,I4,1);
7870 VARIMP(I1,-1,INT,-1,I4,-1);
7871 VARIMP(I1,-1,UINT,1,I4,1);
7872 VARIMP(UI1,0,EMPTY,0,I2,-1);
7873 VARIMP(UI1,0,NULL,0,UI1,255);
7874 VARIMP(UI1,0,I2,-1,I2,-1);
7875 VARIMP(UI1,0,I4,-1,I4,-1);
7876 VARIMP(UI1,0,R4,0.0,I4,-1);
7877 VARIMP(UI1,0,R8,-1.0,I4,-1);
7878 VARIMP(UI1,0,DATE,0,I4,-1);
7879 VARIMP(UI1,0,BSTR,true_str,I2,-1);
7880 VARIMP(UI1,0,BOOL,VARIANT_FALSE,I2,-1);
7881 VARIMP(UI1,0,I1,0,I4,-1);
7882 VARIMP(UI1,0,UI1,1,UI1,255);
7883 VARIMP(UI1,0,UI2,1,I4,-1);
7884 VARIMP(UI1,0,UI4,1,I4,-1);
7885 VARIMP(UI1,0,I8,1,I8,-1);
7886 VARIMP(UI1,0,UI8,1,I4,-1);
7887 VARIMP(UI1,0,INT,-1,I4,-1);
7888 VARIMP(UI1,0,UINT,1,I4,-1);
7889 VARIMP(UI2,0,EMPTY,0,I4,-1);
7890 VARIMP(UI2,0,NULL,0,I4,-1);
7891 VARIMP(UI2,0,I2,-1,I4,-1);
7892 VARIMP(UI2,0,I4,-1,I4,-1);
7893 VARIMP(UI2,0,R4,0.0,I4,-1);
7894 VARIMP(UI2,0,R8,-1.0,I4,-1);
7895 VARIMP(UI2,0,DATE,0,I4,-1);
7896 VARIMP(UI2,0,BSTR,true_str,I4,-1);
7897 VARIMP(UI2,0,BOOL,VARIANT_FALSE,I4,-1);
7898 VARIMP(UI2,0,I1,0,I4,-1);
7899 VARIMP(UI2,0,UI1,1,I4,-1);
7900 VARIMP(UI2,0,UI2,1,I4,-1);
7901 VARIMP(UI2,0,UI4,1,I4,-1);
7902 VARIMP(UI2,0,I8,1,I8,-1);
7903 VARIMP(UI2,0,UI8,1,I4,-1);
7904 VARIMP(UI2,0,INT,-1,I4,-1);
7905 VARIMP(UI2,0,UINT,1,I4,-1);
7906 VARIMP(UI4,0,EMPTY,0,I4,-1);
7907 VARIMP(UI4,0,NULL,0,I4,-1);
7908 VARIMP(UI4,0,I2,-1,I4,-1);
7909 VARIMP(UI4,0,I4,-1,I4,-1);
7910 VARIMP(UI4,0,R4,0.0,I4,-1);
7911 VARIMP(UI4,0,R8,-1.0,I4,-1);
7912 VARIMP(UI4,0,DATE,0,I4,-1);
7913 VARIMP(UI4,0,BSTR,true_str,I4,-1);
7914 VARIMP(UI4,0,BOOL,VARIANT_FALSE,I4,-1);
7915 VARIMP(UI4,0,I1,0,I4,-1);
7916 VARIMP(UI4,0,UI1,1,I4,-1);
7917 VARIMP(UI4,0,UI2,1,I4,-1);
7918 VARIMP(UI4,0,UI4,1,I4,-1);
7919 VARIMP(UI4,0,I8,1,I8,-1);
7920 VARIMP(UI4,0,UI8,1,I4,-1);
7921 VARIMP(UI4,0,INT,-1,I4,-1);
7922 VARIMP(UI4,0,UINT,1,I4,-1);
7923 VARIMP(I8,-1,EMPTY,0,I8,0);
7924 VARIMP(I8,-1,NULL,0,NULL,0);
7925 VARIMP(I8,-1,I2,-1,I8,-1);
7926 VARIMP(I8,-1,I4,-1,I8,-1);
7927 VARIMP(I8,-1,R4,0.0,I8,0);
7928 VARIMP(I8,-1,R8,-1.0,I8,-1);
7929 VARIMP(I8,-1,DATE,0,I8,0);
7930 VARIMP(I8,-1,BSTR,true_str,I8,-1);
7931 VARIMP(I8,-1,BOOL,VARIANT_FALSE,I8,0);
7932 VARIMP(I8,-1,I1,0,I8,0);
7933 VARIMP(I8,-1,UI1,1,I8,1);
7934 VARIMP(I8,-1,UI2,1,I8,1);
7935 VARIMP(I8,-1,UI4,1,I8,1);
7936 VARIMP(I8,-1,I8,1,I8,1);
7937 VARIMP(I8,-1,UI8,1,I8,1);
7938 VARIMP(I8,-1,UINT,1,I8,1);
7939 VARIMP(UI8,0,EMPTY,0,I4,-1);
7940 VARIMP(UI8,0,NULL,0,I4,-1);
7941 VARIMP(UI8,0,I2,-1,I4,-1);
7942 VARIMP(UI8,0,I4,-1,I4,-1);
7943 VARIMP(UI8,0,R4,0.0,I4,-1);
7944 VARIMP(UI8,0,R8,-1.0,I4,-1);
7945 VARIMP(UI8,0,DATE,0,I4,-1);
7946 VARIMP(UI8,0,BSTR,true_str,I4,-1);
7947 VARIMP(UI8,0,BOOL,VARIANT_FALSE,I4,-1);
7948 VARIMP(UI8,0,I1,0,I4,-1);
7949 VARIMP(UI8,0,UI1,1,I4,-1);
7950 VARIMP(UI8,0,UI2,1,I4,-1);
7951 VARIMP(UI8,0,UI4,1,I4,-1);
7952 VARIMP(UI8,0,I8,1,I8,-1);
7953 VARIMP(UI8,0,UI8,1,I4,-1);
7954 VARIMP(UI8,0,INT,-1,I4,-1);
7955 VARIMP(UI8,0,UINT,1,I4,-1);
7956 VARIMP(INT,-1,EMPTY,0,I4,0);
7957 VARIMP(INT,-1,NULL,0,NULL,0);
7958 VARIMP(INT,-1,I2,-1,I4,-1);
7959 VARIMP(INT,-1,I4,-1,I4,-1);
7960 VARIMP(INT,-1,R4,0.0,I4,0);
7961 VARIMP(INT,-1,R8,-1.0,I4,-1);
7962 VARIMP(INT,-1,DATE,0,I4,0);
7963 VARIMP(INT,-1,BSTR,true_str,I4,-1);
7964 VARIMP(INT,-1,BOOL,VARIANT_FALSE,I4,0);
7965 VARIMP(INT,-1,I1,0,I4,0);
7966 VARIMP(INT,-1,UI1,1,I4,1);
7967 VARIMP(INT,-1,UI2,1,I4,1);
7968 VARIMP(INT,-1,UI4,1,I4,1);
7969 VARIMP(INT,-1,I8,1,I8,1);
7970 VARIMP(INT,-1,UI8,1,I4,1);
7971 VARIMP(INT,-1,INT,-1,I4,-1);
7972 VARIMP(INT,-1,UINT,1,I4,1);
7973 VARIMP(UINT,1,EMPTY,0,I4,-2);
7974 VARIMP(UINT,1,NULL,0,I4,-2);
7975 VARIMP(UINT,1,I2,-1,I4,-1);
7976 VARIMP(UINT,1,I4,-1,I4,-1);
7977 VARIMP(UINT,1,R4,0.0,I4,-2);
7978 VARIMP(UINT,1,R8,-1.0,I4,-1);
7979 VARIMP(UINT,1,DATE,0,I4,-2);
7980 VARIMP(UINT,1,BSTR,true_str,I4,-1);
7981 VARIMP(UINT,1,BOOL,VARIANT_FALSE,I4,-2);
7982 VARIMP(UINT,1,I1,0,I4,-2);
7983 VARIMP(UINT,1,UI1,1,I4,-1);
7984 VARIMP(UINT,1,UI2,1,I4,-1);
7985 VARIMP(UINT,1,UI4,1,I4,-1);
7986 VARIMP(UINT,1,I8,1,I8,-1);
7987 VARIMP(UINT,1,UI8,1,I4,-1);
7988 VARIMP(UINT,1,INT,-1,I4,-1);
7989 VARIMP(UINT,1,UINT,1,I4,-1);
7991 /* Manually test some VT_CY, VT_DECIMAL variants */
7993 hres = VarCyFromI4(1, &V_CY(&cy));
7994 ok(hres == S_OK, "VarCyFromI4 failed!\n");
7995 V_VT(&dec) = VT_DECIMAL;
7996 hres = VarDecFromR8(2.0, &V_DECIMAL(&dec));
7997 ok(hres == S_OK, "VarDecFromR4 failed!\n");
7998 memset(&left, 0, sizeof(left));
7999 memset(&right, 0, sizeof(right));
8000 V_VT(&left) = VT_I4;
8002 V_VT(&right) = VT_I8;
8005 hres = pVarImp(&cy, &cy, &result);
8006 ok(hres == S_OK && V_VT(&result) == VT_I4,
8007 "VARIMP: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8008 S_OK, hres, vtstr(V_VT(&result)));
8009 ok(hres == S_OK && V_I4(&result) == -1,
8010 "VARIMP: CY value %d, expected %d\n", V_I4(&result), -1);
8012 hres = pVarImp(&cy, &right, &result);
8013 ok(hres == S_OK && V_VT(&result) == VT_I8,
8014 "VARIMP: expected coerced hres 0x%X type VT_I8, got hres 0x%X type %s!\n",
8015 S_OK, hres, vtstr(V_VT(&result)));
8016 ok(hres == S_OK && V_I8(&result) == -2,
8017 "VARIMP: CY value %x%08x, expected %d\n",
8018 (DWORD)((V_I8(&result)) >> 32), (DWORD)(V_I8(&result)), -2);
8020 hres = pVarImp(&left, &cy, &result);
8021 ok(hres == S_OK && V_VT(&result) == VT_I4,
8022 "VARIMP: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8023 S_OK, hres, vtstr(V_VT(&result)));
8024 ok(hres == S_OK && V_I4(&result) == -1,
8025 "VARIMP: CY value %d, expected %d\n", V_I4(&result), -1);
8027 hres = pVarImp(&left, &dec, &result);
8028 ok(hres == S_OK && V_VT(&result) == VT_I4,
8029 "VARIMP: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8030 S_OK, hres, vtstr(V_VT(&result)));
8031 ok(hres == S_OK && V_I4(&result) == -1,
8032 "VARIMP: DECIMAL value %d, expected %d\n", V_I4(&result), -1);
8034 hres = pVarImp(&dec, &dec, &result);
8035 ok(hres == S_OK && V_VT(&result) == VT_I4,
8036 "VARIMP: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8037 S_OK, hres, vtstr(V_VT(&result)));
8038 ok(hres == S_OK && V_I4(&result) == -1,
8039 "VARIMP: DECIMAL value %d, expected %d\n", V_I4(&result), -1);
8041 hres = pVarImp(&dec, &right, &result);
8042 ok(hres == S_OK && V_VT(&result) == VT_I8,
8043 "VARIMP: expected coerced hres 0x%X type VT_I8, got hres 0x%X type%s!\n",
8044 S_OK, hres, vtstr(V_VT(&result)));
8045 ok(hres == S_OK && V_I8(&result) == -3,
8046 "VARIMP: DECIMAL value 0x%x%08x, expected %d\n",
8047 (DWORD)(V_I8(&result) >>32), (DWORD)V_I8(&result), -3);
8049 SysFreeString(false_str);
8050 SysFreeString(true_str);
8055 hOleaut32 = LoadLibraryA("oleaut32.dll");
8058 test_VariantClear();
8060 test_VariantCopyInd();
8061 test_VarParseNumFromStr();
8062 test_VarNumFromParseNum();
8063 test_VarUdateFromDate();
8064 test_VarDateFromUdate();
8065 test_SystemTimeToVariantTime();
8066 test_VariantTimeToSystemTime();
8067 test_DosDateTimeToVariantTime();
8068 test_VariantTimeToDosDateTime();