4 * Copyright 1998 Jean-Claude Cote
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30 #include "wine/test.h"
40 static HMODULE hOleaut32;
42 static HRESULT (WINAPI *pVarUdateFromDate)(DATE,ULONG,UDATE*);
43 static HRESULT (WINAPI *pVarDateFromUdate)(UDATE*,ULONG,DATE*);
44 static INT (WINAPI *pSystemTimeToVariantTime)(LPSYSTEMTIME,double*);
45 static INT (WINAPI *pVariantTimeToSystemTime)(double,LPSYSTEMTIME);
46 static INT (WINAPI *pDosDateTimeToVariantTime)(USHORT,USHORT,double*);
47 static INT (WINAPI *pVariantTimeToDosDateTime)(double,USHORT*,USHORT *);
48 static HRESULT (WINAPI *pVarFormatNumber)(LPVARIANT,int,int,int,int,ULONG,BSTR*);
49 static HRESULT (WINAPI *pVarFormat)(LPVARIANT,LPOLESTR,int,int,ULONG,BSTR*);
51 /* Get a conversion function ptr, return if function not available */
52 #define CHECKPTR(func) p##func = (void*)GetProcAddress(hOleaut32, #func); \
53 if (!p##func) { trace("function " # func " not available, not testing it\n"); return; }
55 /* Is a given function exported from oleaut32? */
56 #define HAVE_FUNC(func) ((void*)GetProcAddress(hOleaut32, #func) != NULL)
58 /* Have IRecordInfo data type? */
59 #define HAVE_OLEAUT32_RECORD HAVE_FUNC(SafeArraySetRecordInfo)
60 /* Have CY data type? */
61 #define HAVE_OLEAUT32_CY HAVE_FUNC(VarCyAdd)
62 /* Have I8/UI8 data type? */
63 #define HAVE_OLEAUT32_I8 HAVE_FUNC(VarI8FromI1)
64 /* Is this an ancient version with support for only I2/I4/R4/R8/DATE? */
65 #define IS_ANCIENT (!HAVE_FUNC(VarI1FromI2))
67 /* When comparing floating point values we cannot expect an exact match
68 * because the rounding errors depend on the exact algorithm.
70 #define EQ_DOUBLE(a,b) (fabs((a)-(b))<1e-14)
71 #define EQ_FLOAT(a,b) (fabs((a)-(b))<1e-7)
73 #define SKIPTESTS(a) if((a > VT_CLSID+10) && (a < VT_BSTR_BLOB-10)) continue;
75 /* Allow our test macros to work for VT_NULL and VT_EMPTY too */
76 #define V_EMPTY(v) V_I4(v)
77 #define V_NULL(v) V_I4(v)
79 /* Size constraints for overflow tests */
81 #define I1_MIN ((-I1_MAX)-1)
85 #define I2_MIN ((-I2_MAX)-1)
86 #define UI2_MAX 0xffff
88 #define I4_MAX 0x7fffffff
89 #define I4_MIN ((-I4_MAX)-1)
90 #define UI4_MAX 0xffffffff
92 #define I8_MAX (((LONGLONG)I4_MAX << 32) | UI4_MAX)
93 #define I8_MIN ((-I8_MAX)-1)
94 #define UI8_MAX (((ULONGLONG)UI4_MAX << 32) | UI4_MAX)
96 #define DATE_MAX 2958465
97 #define DATE_MIN -657434
98 #define R4_MAX FLT_MAX
99 #define R4_MIN FLT_MIN
100 #define R8_MAX DBL_MAX
101 #define R8_MIN DBL_MIN
103 /* Macros to set a DECIMAL */
104 #define SETDEC(dec, scl, sgn, hi, lo) S(U(dec)).scale = (BYTE)scl; \
105 S(U(dec)).sign = (BYTE)sgn; dec.Hi32 = (ULONG)hi; \
106 U1(dec).Lo64 = (ULONG64)lo
107 #define SETDEC64(dec, scl, sgn, hi, mid, lo) S(U(dec)).scale = (BYTE)scl; \
108 S(U(dec)).sign = (BYTE)sgn; dec.Hi32 = (ULONG)hi; \
109 S1(U1(dec)).Mid32 = mid; S1(U1(dec)).Lo32 = lo;
111 static inline int strcmpW( const WCHAR *str1, const WCHAR *str2 )
113 while (*str1 && (*str1 == *str2)) { str1++; str2++; }
114 return *str1 - *str2;
117 /* return the string text of a given variant type */
118 static const char *vtstr(int x)
140 return "VT_DISPATCH";
176 return "VT_SAFEARRAY";
180 return "VT_USERDEFINED";
188 return "VT_FILETIME";
196 return "VT_STREAMED_OBJECT";
198 return "VT_STORED_OBJECT";
200 return "VT_BLOB_OBJECT";
206 return "VT_BSTR_BLOB/VT_ILLEGALMASKED/VT_TYPEMASK";
223 static void test_VariantInit(void)
227 /* Test that VariantInit() only sets the type */
228 memset(&v1, -1, sizeof(v1));
230 V_VT(&v2) = VT_EMPTY;
232 ok(!memcmp(&v1, &v2, sizeof(v1)), "VariantInit() set extra fields\n");
235 /* All possible combinations of extra V_VT() flags */
236 static const VARTYPE ExtraFlags[16] =
245 VT_VECTOR|VT_RESERVED,
246 VT_VECTOR|VT_ARRAY|VT_BYREF,
247 VT_VECTOR|VT_ARRAY|VT_RESERVED,
248 VT_VECTOR|VT_BYREF|VT_RESERVED,
249 VT_VECTOR|VT_ARRAY|VT_BYREF|VT_RESERVED,
251 VT_ARRAY|VT_RESERVED,
252 VT_ARRAY|VT_BYREF|VT_RESERVED,
253 VT_BYREF|VT_RESERVED,
256 /* Determine if a vt is valid for VariantClear() */
257 static int IsValidVariantClearVT(VARTYPE vt, VARTYPE extraFlags)
261 /* Only the following flags/types are valid */
262 if ((vt <= VT_LPWSTR || vt == VT_RECORD || vt == VT_CLSID) &&
264 (vt < (VARTYPE)24 || vt > (VARTYPE)31) &&
265 (!(extraFlags & (VT_BYREF|VT_ARRAY)) || vt > VT_NULL) &&
266 (extraFlags == 0 || extraFlags == VT_BYREF || extraFlags == VT_ARRAY ||
267 extraFlags == (VT_ARRAY|VT_BYREF)))
270 if ((vt == VT_RECORD && !HAVE_OLEAUT32_RECORD) ||
271 ((vt == VT_I8 || vt == VT_UI8) && !HAVE_OLEAUT32_I8))
272 ret = 0; /* Old versions of oleaut32 */
276 static void test_VariantClear(void)
283 /* Crashes: Native does not test input for NULL, so neither does Wine */
284 hres = VariantClear(NULL);
287 /* Only the type field is set, to VT_EMPTY */
290 hres = VariantClear(&v);
291 ok((hres == S_OK && V_VT(&v) == VT_EMPTY) ||
292 (IS_ANCIENT && hres == DISP_E_BADVARTYPE && V_VT(&v) == VT_UI4),
293 "VariantClear: Type set to %d, res %08lx\n", V_VT(&v), hres);
294 ok(V_UI4(&v) == ~0u, "VariantClear: Overwrote value\n");
296 /* Test all possible V_VT values.
297 * Also demonstrates that null pointers in 'v' are not dereferenced.
298 * Individual variant tests should test VariantClear() with non-NULL values.
300 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]) && !IS_ANCIENT; i++)
304 for (vt = 0; vt <= VT_BSTR_BLOB; vt++)
306 HRESULT hExpected = DISP_E_BADVARTYPE;
310 memset(&v, 0, sizeof(v));
311 V_VT(&v) = vt | ExtraFlags[i];
313 hres = VariantClear(&v);
315 if (IsValidVariantClearVT(vt, ExtraFlags[i]))
318 ok(hres == hExpected, "VariantClear: expected 0x%lX, got 0x%lX for vt %d | 0x%X\n",
319 hExpected, hres, vt, ExtraFlags[i]);
324 static void test_VariantCopy(void)
326 VARIANTARG vSrc, vDst;
329 HRESULT hres, hExpected;
331 /* Establish that the failure/other cases are dealt with. Individual tests
332 * for each type should verify that data is copied correctly, references
337 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]) && !IS_ANCIENT; i++)
339 for (vt = 0; vt <= VT_BSTR_BLOB; vt++)
343 memset(&vSrc, 0, sizeof(vSrc));
344 V_VT(&vSrc) = vt | ExtraFlags[i];
346 hExpected = DISP_E_BADVARTYPE;
347 /* src is allowed to be a VT_CLSID */
348 if (vt != VT_CLSID && IsValidVariantClearVT(vt, ExtraFlags[i]))
351 hres = VariantCopy(&vSrc, &vSrc);
353 ok(hres == hExpected,
354 "Copy(src==dst): expected 0x%lX, got 0x%lX for src==dest vt %d|0x%X\n",
355 hExpected, hres, vt, ExtraFlags[i]);
359 /* Test that if VariantClear() fails on dest, the function fails. This also
360 * shows that dest is in fact cleared and not just overwritten
362 memset(&vSrc, 0, sizeof(vSrc));
363 V_VT(&vSrc) = VT_UI1;
365 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]) && !IS_ANCIENT; i++)
367 for (vt = 0; vt <= VT_BSTR_BLOB; vt++)
371 hExpected = DISP_E_BADVARTYPE;
373 memset(&vDst, 0, sizeof(vDst));
374 V_VT(&vDst) = vt | ExtraFlags[i];
376 if (IsValidVariantClearVT(vt, ExtraFlags[i]))
379 hres = VariantCopy(&vDst, &vSrc);
381 ok(hres == hExpected,
382 "Copy(bad dst): expected 0x%lX, got 0x%lX for dest vt %d|0x%X\n",
383 hExpected, hres, vt, ExtraFlags[i]);
385 ok(V_VT(&vDst) == VT_UI1,
386 "Copy(bad dst): expected vt = VT_UI1, got %d\n", V_VT(&vDst));
390 /* Test that VariantClear() checks vSrc for validity before copying */
391 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]) && !IS_ANCIENT; i++)
393 for (vt = 0; vt <= VT_BSTR_BLOB; vt++)
397 hExpected = DISP_E_BADVARTYPE;
399 memset(&vDst, 0, sizeof(vDst));
400 V_VT(&vDst) = VT_EMPTY;
402 memset(&vSrc, 0, sizeof(vSrc));
403 V_VT(&vSrc) = vt | ExtraFlags[i];
405 /* src is allowed to be a VT_CLSID */
406 if (vt != VT_CLSID && IsValidVariantClearVT(vt, ExtraFlags[i]))
409 hres = VariantCopy(&vDst, &vSrc);
411 ok(hres == hExpected,
412 "Copy(bad src): expected 0x%lX, got 0x%lX for src vt %d|0x%X\n",
413 hExpected, hres, vt, ExtraFlags[i]);
415 ok(V_VT(&vDst) == (vt|ExtraFlags[i]),
416 "Copy(bad src): expected vt = %d, got %d\n",
417 vt | ExtraFlags[i], V_VT(&vDst));
422 /* Determine if a vt is valid for VariantCopyInd() */
423 static int IsValidVariantCopyIndVT(VARTYPE vt, VARTYPE extraFlags)
427 if ((extraFlags & VT_ARRAY) ||
428 (vt > VT_NULL && vt != (VARTYPE)15 && vt < VT_VOID &&
429 !(extraFlags & (VT_VECTOR|VT_RESERVED))))
436 static void test_VariantCopyInd(void)
438 VARIANTARG vSrc, vDst, vRef, vRef2;
442 HRESULT hres, hExpected;
444 memset(buffer, 0, sizeof(buffer));
447 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]) && !IS_ANCIENT; i++)
449 if (ExtraFlags[i] & VT_ARRAY)
450 continue; /* Native crashes on NULL safearray */
452 for (vt = 0; vt <= VT_BSTR_BLOB; vt++)
456 memset(&vSrc, 0, sizeof(vSrc));
457 V_VT(&vSrc) = vt | ExtraFlags[i];
459 hExpected = DISP_E_BADVARTYPE;
460 if (!(ExtraFlags[i] & VT_BYREF))
462 /* if src is not by-reference, acts as VariantCopy() */
463 if (vt != VT_CLSID && IsValidVariantClearVT(vt, ExtraFlags[i]))
468 if (vt == VT_SAFEARRAY || vt == VT_BSTR || vt == VT_UNKNOWN ||
469 vt == VT_DISPATCH || vt == VT_RECORD)
470 continue; /* Need valid ptrs for deep copies */
472 V_BYREF(&vSrc) = &buffer;
473 hExpected = E_INVALIDARG;
475 if ((vt == VT_I8 || vt == VT_UI8) &&
476 ExtraFlags[i] == VT_BYREF)
478 if (HAVE_OLEAUT32_I8)
479 hExpected = S_OK; /* Only valid if I8 is a known type */
481 else if (IsValidVariantCopyIndVT(vt, ExtraFlags[i]))
485 hres = VariantCopyInd(&vSrc, &vSrc);
487 ok(hres == hExpected,
488 "CopyInd(src==dst): expected 0x%lX, got 0x%lX for src==dst vt %d|0x%X\n",
489 hExpected, hres, vt, ExtraFlags[i]);
494 memset(&vSrc, 0, sizeof(vSrc));
495 V_VT(&vSrc) = VT_UI1|VT_BYREF;
496 V_BYREF(&vSrc) = &buffer;
498 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]) && !IS_ANCIENT; i++)
500 for (vt = 0; vt <= VT_BSTR_BLOB; vt++)
504 memset(&vDst, 0, sizeof(vDst));
505 V_VT(&vDst) = vt | ExtraFlags[i];
507 hExpected = DISP_E_BADVARTYPE;
509 if (IsValidVariantClearVT(vt, ExtraFlags[i]))
512 hres = VariantCopyInd(&vDst, &vSrc);
514 ok(hres == hExpected,
515 "CopyInd(bad dst): expected 0x%lX, got 0x%lX for dst vt %d|0x%X\n",
516 hExpected, hres, vt, ExtraFlags[i]);
518 ok(V_VT(&vDst) == VT_UI1,
519 "CopyInd(bad dst): expected vt = VT_UI1, got %d\n", V_VT(&vDst));
524 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]) && !IS_ANCIENT; i++)
526 if (ExtraFlags[i] & VT_ARRAY)
527 continue; /* Native crashes on NULL safearray */
529 for (vt = 0; vt <= VT_BSTR_BLOB; vt++)
533 memset(&vDst, 0, sizeof(vDst));
534 V_VT(&vDst) = VT_EMPTY;
536 memset(&vSrc, 0, sizeof(vSrc));
537 V_VT(&vSrc) = vt | ExtraFlags[i];
539 hExpected = DISP_E_BADVARTYPE;
540 if (!(ExtraFlags[i] & VT_BYREF))
542 /* if src is not by-reference, acts as VariantCopy() */
543 if (vt != VT_CLSID && IsValidVariantClearVT(vt, ExtraFlags[i]))
548 if (vt == VT_SAFEARRAY || vt == VT_BSTR || vt == VT_UNKNOWN ||
549 vt == VT_DISPATCH || vt == VT_RECORD)
550 continue; /* Need valid ptrs for deep copies, see vartype.c */
552 V_BYREF(&vSrc) = &buffer;
554 hExpected = E_INVALIDARG;
556 if ((vt == VT_I8 || vt == VT_UI8) &&
557 ExtraFlags[i] == VT_BYREF)
559 if (HAVE_OLEAUT32_I8)
560 hExpected = S_OK; /* Only valid if I8 is a known type */
562 else if (IsValidVariantCopyIndVT(vt, ExtraFlags[i]))
566 hres = VariantCopyInd(&vDst, &vSrc);
568 ok(hres == hExpected,
569 "CopyInd(bad src): expected 0x%lX, got 0x%lX for src vt %d|0x%X\n",
570 hExpected, hres, vt, ExtraFlags[i]);
573 if (vt == VT_VARIANT && ExtraFlags[i] == VT_BYREF)
575 /* Type of vDst should be the type of the referenced variant.
576 * Since we set the buffer to all zeros, its type should be
579 ok(V_VT(&vDst) == VT_EMPTY,
580 "CopyInd(bad src): expected dst vt = VT_EMPTY, got %d|0x%X\n",
581 V_VT(&vDst) & VT_TYPEMASK, V_VT(&vDst) & ~VT_TYPEMASK);
585 ok(V_VT(&vDst) == (vt|(ExtraFlags[i] & ~VT_BYREF)),
586 "CopyInd(bad src): expected dst vt = %d|0x%X, got %d|0x%X\n",
587 vt, ExtraFlags[i] & ~VT_BYREF,
588 V_VT(&vDst) & VT_TYPEMASK, V_VT(&vDst) & ~VT_TYPEMASK);
594 /* By-reference variants are dereferenced */
595 V_VT(&vRef) = VT_UI1;
597 V_VT(&vSrc) = VT_VARIANT|VT_BYREF;
598 V_VARIANTREF(&vSrc) = &vRef;
601 hres = VariantCopyInd(&vDst, &vSrc);
602 ok(V_VT(&vDst) == VT_UI1 && V_UI1(&vDst) == 0x77,
603 "CopyInd(deref): expected dst vt = VT_UI1, val 0x77, got %d|0x%X, 0x%2X\n",
604 V_VT(&vDst) & VT_TYPEMASK, V_VT(&vDst) & ~VT_TYPEMASK, V_UI1(&vDst));
606 /* By-reference variant to a by-reference type succeeds */
607 V_VT(&vRef) = VT_UI1|VT_BYREF;
608 V_UI1REF(&vRef) = buffer; buffer[0] = 0x88;
609 V_VT(&vSrc) = VT_VARIANT|VT_BYREF;
610 V_VARIANTREF(&vSrc) = &vRef;
613 hres = VariantCopyInd(&vDst, &vSrc);
614 ok(V_VT(&vDst) == VT_UI1 && V_UI1(&vDst) == 0x88,
615 "CopyInd(deref): expected dst vt = VT_UI1, val 0x77, got %d|0x%X, 0x%2X\n",
616 V_VT(&vDst) & VT_TYPEMASK, V_VT(&vDst) & ~VT_TYPEMASK, V_UI1(&vDst));
618 /* But a by-reference variant to a by-reference variant fails */
619 V_VT(&vRef2) = VT_UI1;
620 V_UI1(&vRef2) = 0x77;
621 V_VT(&vRef) = VT_VARIANT|VT_BYREF;
622 V_VARIANTREF(&vRef) = &vRef2;
623 V_VT(&vSrc) = VT_VARIANT|VT_BYREF;
624 V_VARIANTREF(&vSrc) = &vRef;
627 hres = VariantCopyInd(&vDst, &vSrc);
628 ok(hres == E_INVALIDARG,
629 "CopyInd(ref->ref): expected E_INVALIDARG, got 0x%08lx\n", hres);
632 static HRESULT (WINAPI *pVarParseNumFromStr)(OLECHAR*,LCID,ULONG,NUMPARSE*,BYTE*);
634 /* Macros for converting and testing the result of VarParseNumFromStr */
636 #define CONVERTN(str,dig,flags) MultiByteToWideChar(CP_ACP,0,str,-1,buff,sizeof(buff)/sizeof(WCHAR)); \
637 memset(rgb, FAILDIG, sizeof(rgb)); memset(&np,-1,sizeof(np)); np.cDig = dig; np.dwInFlags = flags; \
638 hres = pVarParseNumFromStr(buff,lcid,LOCALE_NOUSEROVERRIDE,&np,rgb)
639 #define CONVERT(str,flags) CONVERTN(str,sizeof(rgb),flags)
640 #define EXPECT(a,b,c,d,e,f) ok(hres == (HRESULT)S_OK, "Call failed, hres = %08lx\n", hres); \
641 if (hres == (HRESULT)S_OK) { \
642 ok(np.cDig == (a), "Expected cDig = %d, got %d\n", (a), np.cDig); \
643 ok(np.dwInFlags == (b), "Expected dwInFlags = 0x%lx, got 0x%lx\n", (ULONG)(b), np.dwInFlags); \
644 ok(np.dwOutFlags == (c), "Expected dwOutFlags = 0x%lx, got 0x%lx\n", (ULONG)(c), np.dwOutFlags); \
645 ok(np.cchUsed == (d), "Expected cchUsed = %d, got %d\n", (d), np.cchUsed); \
646 ok(np.nBaseShift == (e), "Expected nBaseShift = %d, got %d\n", (e), np.nBaseShift); \
647 ok(np.nPwr10 == (f), "Expected nPwr10 = %d, got %d\n", (f), np.nPwr10); \
649 #define EXPECTRGB(a,b) ok(rgb[a] == b, "Digit[%d], expected %d, got %d\n", a, b, rgb[a])
650 #define EXPECTFAIL ok(hres == (HRESULT)DISP_E_TYPEMISMATCH, "Call succeeded, hres = %08lx\n", hres)
651 #define EXPECT2(a,b) EXPECTRGB(0,a); EXPECTRGB(1,b)
653 static void test_VarParseNumFromStr(void)
657 /* Ensure all tests are using the same locale characters for '$', ',' etc */
658 LCID lcid = MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT);
664 CHECKPTR(VarParseNumFromStr);
666 /* Consume a single digit */
671 /* cDig is not literal digits - zeros are suppressed and nPwr10 is increased */
674 /* Note: Win32 writes the trailing zeros if they are within cDig's limits,
675 * but then excludes them from the returned cDig count.
676 * In our implementation we don't bother writing them at all.
680 /* if cDig is too small and numbers follow, sets INEXACT */
682 EXPECT(1,0,NUMPRS_INEXACT,2,0,1);
685 /* Strips leading zeros */
690 /* Strips leading zeros */
696 /* Fails on non digits */
699 EXPECTRGB(0,FAILDIG);
701 /** NUMPRS_LEADING_WHITE/NUMPRS_TRAILING_WHITE **/
703 /* Without flag, fails on whitespace */
706 EXPECTRGB(0,FAILDIG);
709 /* With flag, consumes whitespace */
710 CONVERT(" 0", NUMPRS_LEADING_WHITE);
711 EXPECT(1,NUMPRS_LEADING_WHITE,NUMPRS_LEADING_WHITE,2,0,0);
714 /* Test TAB once, then assume it acts as space for all cases */
715 CONVERT("\t0", NUMPRS_LEADING_WHITE);
716 EXPECT(1,NUMPRS_LEADING_WHITE,NUMPRS_LEADING_WHITE,2,0,0);
720 /* Doesn't pick up trailing whitespace without flag */
725 /* With flag, consumes trailing whitespace */
726 CONVERT("0 ", NUMPRS_TRAILING_WHITE);
727 EXPECT(1,NUMPRS_TRAILING_WHITE,NUMPRS_TRAILING_WHITE,2,0,0);
730 /* Leading flag only consumes leading */
731 CONVERT(" 0 ", NUMPRS_LEADING_WHITE);
732 EXPECT(1,NUMPRS_LEADING_WHITE,NUMPRS_LEADING_WHITE,2,0,0);
735 /* Both flags consumes both */
736 CONVERT(" 0 ", NUMPRS_LEADING_WHITE|NUMPRS_TRAILING_WHITE);
737 EXPECT(1,NUMPRS_LEADING_WHITE|NUMPRS_TRAILING_WHITE,NUMPRS_LEADING_WHITE|NUMPRS_TRAILING_WHITE,3,0,0);
740 /** NUMPRS_LEADING_PLUS/NUMPRS_TRAILING_PLUS **/
742 /* Without flag, fails on + */
745 EXPECTRGB(0,FAILDIG);
747 /* With flag, consumes + */
748 CONVERT("+0", NUMPRS_LEADING_PLUS);
749 EXPECT(1,NUMPRS_LEADING_PLUS,NUMPRS_LEADING_PLUS,2,0,0);
752 /* Without flag, doesn't consume trailing + */
757 /* With flag, consumes trailing + */
758 CONVERT("0+", NUMPRS_TRAILING_PLUS);
759 EXPECT(1,NUMPRS_TRAILING_PLUS,NUMPRS_TRAILING_PLUS,2,0,0);
762 /* With leading flag, doesn't consume trailing + */
763 CONVERT("+0+", NUMPRS_LEADING_PLUS);
764 EXPECT(1,NUMPRS_LEADING_PLUS,NUMPRS_LEADING_PLUS,2,0,0);
767 /* Trailing + doesn't get consumed if we specify both (unlike whitespace) */
768 CONVERT("+0+", NUMPRS_LEADING_PLUS|NUMPRS_TRAILING_PLUS);
769 EXPECT(1,NUMPRS_LEADING_PLUS|NUMPRS_TRAILING_PLUS,NUMPRS_LEADING_PLUS,2,0,0);
772 /** NUMPRS_LEADING_MINUS/NUMPRS_TRAILING_MINUS **/
774 /* Without flag, fails on - */
777 EXPECTRGB(0,FAILDIG);
779 /* With flag, consumes - */
780 CONVERT("-0", NUMPRS_LEADING_MINUS);
781 EXPECT(1,NUMPRS_LEADING_MINUS,NUMPRS_NEG|NUMPRS_LEADING_MINUS,2,0,0);
784 /* Without flag, doesn't consume trailing - */
789 /* With flag, consumes trailing - */
790 CONVERT("0-", NUMPRS_TRAILING_MINUS);
791 EXPECT(1,NUMPRS_TRAILING_MINUS,NUMPRS_NEG|NUMPRS_TRAILING_MINUS,2,0,0);
794 /* With leading flag, doesn't consume trailing - */
795 CONVERT("-0-", NUMPRS_LEADING_MINUS);
796 EXPECT(1,NUMPRS_LEADING_MINUS,NUMPRS_NEG|NUMPRS_LEADING_MINUS,2,0,0);
799 /* Trailing - doesn't get consumed if we specify both (unlike whitespace) */
800 CONVERT("-0-", NUMPRS_LEADING_MINUS|NUMPRS_TRAILING_MINUS);
801 EXPECT(1,NUMPRS_LEADING_MINUS|NUMPRS_TRAILING_MINUS,NUMPRS_NEG|NUMPRS_LEADING_MINUS,2,0,0);
804 /** NUMPRS_HEX_OCT **/
806 /* Could be hex, octal or decimal - With flag reads as decimal */
807 CONVERT("0", NUMPRS_HEX_OCT);
808 EXPECT(1,NUMPRS_HEX_OCT,0,1,0,0);
811 /* Doesn't recognise hex in .asm sytax */
812 CONVERT("0h", NUMPRS_HEX_OCT);
813 EXPECT(1,NUMPRS_HEX_OCT,0,1,0,0);
816 /* Doesn't fail with valid leading string but no digits */
817 CONVERT("0x", NUMPRS_HEX_OCT);
818 EXPECT(1,NUMPRS_HEX_OCT,0,1,0,0);
821 /* Doesn't recognise hex format humbers at all! */
822 CONVERT("0x0", NUMPRS_HEX_OCT);
823 EXPECT(1,NUMPRS_HEX_OCT,0,1,0,0);
826 /* Doesn't recognise plain hex digits either */
827 CONVERT("FE", NUMPRS_HEX_OCT);
829 EXPECTRGB(0,FAILDIG);
832 CONVERT("0100", NUMPRS_HEX_OCT);
833 EXPECT(1,NUMPRS_HEX_OCT,0,4,0,2);
837 EXPECTRGB(3,FAILDIG);
840 CONVERT("&HF800", NUMPRS_HEX_OCT);
841 EXPECT(4,NUMPRS_HEX_OCT,0x40,6,4,0);
846 EXPECTRGB(4,FAILDIG);
848 /* VB hex lower case and leading zero */
849 CONVERT("&h0abcd", NUMPRS_HEX_OCT);
850 EXPECT(4,NUMPRS_HEX_OCT,0x40,7,4,0);
855 EXPECTRGB(4,FAILDIG);
858 CONVERT("&O300", NUMPRS_HEX_OCT);
859 EXPECT(3,NUMPRS_HEX_OCT,0x40,5,3,0);
863 EXPECTRGB(3,FAILDIG);
865 /* VB oct lower case and leading zero */
866 CONVERT("&o0777", NUMPRS_HEX_OCT);
867 EXPECT(3,NUMPRS_HEX_OCT,0x40,6,3,0);
871 EXPECTRGB(3,FAILDIG);
873 /* VB oct char bigger than 7 */
874 CONVERT("&o128", NUMPRS_HEX_OCT);
876 Native versions 2.x of oleaut32 allow this to succeed: later versions and Wine don't
878 EXPECTRGB(0,FAILDIG);
880 /** NUMPRS_PARENS **/
882 /* Empty parens = error */
883 CONVERT("()", NUMPRS_PARENS);
885 EXPECTRGB(0,FAILDIG);
887 /* With flag, trailing parens not consumed */
888 CONVERT("0()", NUMPRS_PARENS);
889 EXPECT(1,NUMPRS_PARENS,0,1,0,0);
892 /* With flag, Number in parens made negative and parens consumed */
893 CONVERT("(0)", NUMPRS_PARENS);
894 EXPECT(1,NUMPRS_PARENS,NUMPRS_NEG|NUMPRS_PARENS,3,0,0);
897 /** NUMPRS_THOUSANDS **/
899 /* With flag, thousands sep. not needed */
900 CONVERT("0", NUMPRS_THOUSANDS);
901 EXPECT(1,NUMPRS_THOUSANDS,0,1,0,0);
904 /* With flag, thousands sep. and following digits consumed */
905 CONVERT("1,000", NUMPRS_THOUSANDS);
906 EXPECT(1,NUMPRS_THOUSANDS,NUMPRS_THOUSANDS,5,0,3);
909 /* With flag and decimal point, thousands sep. but not decimals consumed */
910 CONVERT("1,000.0", NUMPRS_THOUSANDS);
911 EXPECT(1,NUMPRS_THOUSANDS,NUMPRS_THOUSANDS,5,0,3);
914 /** NUMPRS_CURRENCY **/
916 /* Without flag, chokes on currency sign */
919 EXPECTRGB(0,FAILDIG);
921 /* With flag, consumes currency sign */
922 CONVERT("$11", NUMPRS_CURRENCY);
923 EXPECT(2,NUMPRS_CURRENCY,NUMPRS_CURRENCY,3,0,0);
925 EXPECTRGB(2,FAILDIG);
927 /* With flag only, doesn't consume decimal point */
928 CONVERT("$11.1", NUMPRS_CURRENCY);
929 EXPECT(2,NUMPRS_CURRENCY,NUMPRS_CURRENCY,3,0,0);
931 EXPECTRGB(2,FAILDIG);
933 /* With flag and decimal flag, consumes decimal point and following digits */
934 CONVERT("$11.1", NUMPRS_CURRENCY|NUMPRS_DECIMAL);
935 EXPECT(3,NUMPRS_CURRENCY|NUMPRS_DECIMAL,NUMPRS_CURRENCY|NUMPRS_DECIMAL,5,0,-1);
938 EXPECTRGB(3,FAILDIG);
940 /* Thousands flag can only be used with currency */
941 CONVERT("$1,234", NUMPRS_CURRENCY|NUMPRS_THOUSANDS);
942 EXPECT(4,NUMPRS_CURRENCY|NUMPRS_THOUSANDS,NUMPRS_CURRENCY|NUMPRS_THOUSANDS,6,0,0);
946 EXPECTRGB(4,FAILDIG);
948 /** NUMPRS_DECIMAL **/
950 /* With flag, consumes decimal point */
951 CONVERT("1.1", NUMPRS_DECIMAL);
952 EXPECT(2,NUMPRS_DECIMAL,NUMPRS_DECIMAL,3,0,-1);
954 EXPECTRGB(2,FAILDIG);
956 /* With flag, consumes decimal point. Skipping the decimal part is not an error */
957 CONVERT("1.", NUMPRS_DECIMAL);
958 EXPECT(1,NUMPRS_DECIMAL,NUMPRS_DECIMAL,2,0,0);
961 /* Consumes only one decimal point */
962 CONVERT("1.1.", NUMPRS_DECIMAL);
963 EXPECT(2,NUMPRS_DECIMAL,NUMPRS_DECIMAL,3,0,-1);
965 EXPECTRGB(2,FAILDIG);
967 /** NUMPRS_EXPONENT **/
969 /* Without flag, doesn't consume exponent */
974 /* With flag, consumes exponent */
975 CONVERT("1e1", NUMPRS_EXPONENT);
976 EXPECT(1,NUMPRS_EXPONENT,NUMPRS_EXPONENT,3,0,1);
979 /* Negative exponents are accepted without flags */
980 CONVERT("1e-1", NUMPRS_EXPONENT);
981 EXPECT(1,NUMPRS_EXPONENT,NUMPRS_EXPONENT,4,0,-1);
984 /* As are positive exponents and leading exponent 0's */
985 CONVERT("1e+01", NUMPRS_EXPONENT);
986 EXPECT(1,NUMPRS_EXPONENT,NUMPRS_EXPONENT,5,0,1);
989 /* The same for zero exponents */
990 CONVERT("1e0", NUMPRS_EXPONENT);
991 EXPECT(1,NUMPRS_EXPONENT,NUMPRS_EXPONENT,3,0,0);
994 /* Sign on a zero exponent doesn't matter */
995 CONVERT("1e+0", NUMPRS_EXPONENT);
996 EXPECT(1,NUMPRS_EXPONENT,NUMPRS_EXPONENT,4,0,0);
999 CONVERT("1e-0", NUMPRS_EXPONENT);
1000 EXPECT(1,NUMPRS_EXPONENT,NUMPRS_EXPONENT,4,0,0);
1003 /* Doesn't consume a real number exponent */
1004 CONVERT("1e1.", NUMPRS_EXPONENT);
1005 EXPECT(1,NUMPRS_EXPONENT,NUMPRS_EXPONENT,3,0,1);
1008 /* Powers of 10 are calculated from the position of any decimal point */
1009 CONVERT("1.5e20", NUMPRS_EXPONENT|NUMPRS_DECIMAL);
1010 EXPECT(2,NUMPRS_EXPONENT|NUMPRS_DECIMAL,NUMPRS_EXPONENT|NUMPRS_DECIMAL,6,0,19);
1013 CONVERT("1.5e-20", NUMPRS_EXPONENT|NUMPRS_DECIMAL);
1014 EXPECT(2,NUMPRS_EXPONENT|NUMPRS_DECIMAL,NUMPRS_EXPONENT|NUMPRS_DECIMAL,7,0,-21);
1017 /** NUMPRS_USE_ALL **/
1019 /* Flag expects all digits */
1020 CONVERT("0", NUMPRS_USE_ALL);
1021 EXPECT(1,NUMPRS_USE_ALL,0,1,0,0);
1024 /* Rejects anything trailing */
1025 CONVERT("0 ", NUMPRS_USE_ALL);
1029 /* Unless consumed by trailing flag */
1030 CONVERT("0 ", NUMPRS_USE_ALL|NUMPRS_TRAILING_WHITE);
1031 EXPECT(1,NUMPRS_USE_ALL|NUMPRS_TRAILING_WHITE,NUMPRS_TRAILING_WHITE,2,0,0);
1034 /** Combinations **/
1036 /* Leading whitepace and plus, doesn't consume trailing whitespace */
1037 CONVERT("+ 0 ", NUMPRS_LEADING_PLUS|NUMPRS_LEADING_WHITE);
1038 EXPECT(1,NUMPRS_LEADING_PLUS|NUMPRS_LEADING_WHITE,NUMPRS_LEADING_PLUS|NUMPRS_LEADING_WHITE,3,0,0);
1041 /* Order of whitepace and plus is unimportant */
1042 CONVERT(" +0", NUMPRS_LEADING_PLUS|NUMPRS_LEADING_WHITE);
1043 EXPECT(1,NUMPRS_LEADING_PLUS|NUMPRS_LEADING_WHITE,NUMPRS_LEADING_PLUS|NUMPRS_LEADING_WHITE,3,0,0);
1046 /* Leading whitespace can be repeated */
1047 CONVERT(" + 0", NUMPRS_LEADING_PLUS|NUMPRS_LEADING_WHITE);
1048 EXPECT(1,NUMPRS_LEADING_PLUS|NUMPRS_LEADING_WHITE,NUMPRS_LEADING_PLUS|NUMPRS_LEADING_WHITE,4,0,0);
1051 /* But plus/minus etc. cannot */
1052 CONVERT("+ +0", NUMPRS_LEADING_PLUS|NUMPRS_LEADING_WHITE);
1054 EXPECTRGB(0,FAILDIG);
1056 /* Inexact is not set if trailing zeros are removed */
1057 CONVERTN("10", 1, 0);
1058 EXPECT(1,0,0,2,0,1);
1061 /* Make sure a leading 0 is stripped but decimals after it get read */
1062 CONVERT("-0.51", NUMPRS_STD);
1063 EXPECT(2,NUMPRS_STD,NUMPRS_NEG|NUMPRS_DECIMAL|NUMPRS_LEADING_MINUS,5,0,-2);
1066 /* Keep trailing zeros on whole number part of a decimal */
1067 CONVERT("10.1", NUMPRS_STD);
1068 EXPECT(3,NUMPRS_STD,NUMPRS_DECIMAL,4,0,-1);
1072 /* Zeros after decimal sign */
1073 CONVERT("0.01", NUMPRS_STD);
1074 EXPECT(1,NUMPRS_STD,NUMPRS_DECIMAL,4,0,-2);
1077 /* Trailing zeros after decimal part */
1078 CONVERT("0.10", NUMPRS_STD);
1079 EXPECT(1,NUMPRS_STD,NUMPRS_DECIMAL,4,0,-1);
1083 static HRESULT (WINAPI *pVarNumFromParseNum)(NUMPARSE*,BYTE*,ULONG,VARIANT*);
1085 /* Macros for converting and testing the result of VarNumFromParseNum */
1086 #define SETRGB(indx,val) if (!indx) memset(rgb, FAILDIG, sizeof(rgb)); rgb[indx] = val
1088 #define CONVERT(a,b,c,d,e,f,bits) \
1089 np.cDig = (a); np.dwInFlags = (b); np.dwOutFlags = (c); np.cchUsed = (d); \
1090 np.nBaseShift = (e); np.nPwr10 = (f); hres = pVarNumFromParseNum(&np, rgb, bits, &vOut)
1091 static const char *szFailOverflow = "Expected overflow, hres = %08lx\n";
1092 #define EXPECT_OVERFLOW ok(hres == (HRESULT)DISP_E_OVERFLOW, szFailOverflow, hres)
1093 static const char *szFailOk = "Call failed, hres = %08lx\n";
1094 #define EXPECT_OK ok(hres == (HRESULT)S_OK, szFailOk, hres); \
1095 if (hres == (HRESULT)S_OK)
1096 #define EXPECT_TYPE(typ) ok(V_VT(&vOut) == typ,"Expected Type = " #typ ", got %d\n", V_VT(&vOut))
1097 #define EXPECT_I1(val) EXPECT_OK { EXPECT_TYPE(VT_I1); \
1098 ok(V_I1(&vOut) == val, "Expected i1 = %d, got %d\n", (signed char)val, V_I1(&vOut)); }
1099 #define EXPECT_UI1(val) EXPECT_OK { EXPECT_TYPE(VT_UI1); \
1100 ok(V_UI1(&vOut) == val, "Expected ui1 = %d, got %d\n", (BYTE)val, V_UI1(&vOut)); }
1101 #define EXPECT_I2(val) EXPECT_OK { EXPECT_TYPE(VT_I2); \
1102 ok(V_I2(&vOut) == val, "Expected i2 = %d, got %d\n", (SHORT)val, V_I2(&vOut)); }
1103 #define EXPECT_UI2(val) EXPECT_OK { EXPECT_TYPE(VT_UI2); \
1104 ok(V_UI2(&vOut) == val, "Expected ui2 = %d, got %d\n", (USHORT)val, V_UI2(&vOut)); }
1105 #define EXPECT_I4(val) EXPECT_OK { EXPECT_TYPE(VT_I4); \
1106 ok(V_I4(&vOut) == val, "Expected i4 = %ld, got %ld\n", (LONG)val, V_I4(&vOut)); }
1107 #define EXPECT_UI4(val) EXPECT_OK { EXPECT_TYPE(VT_UI4); \
1108 ok(V_UI4(&vOut) == val, "Expected ui4 = %ld, got %ld\n", (ULONG)val, V_UI4(&vOut)); }
1109 #define EXPECT_I8(high,low) EXPECT_OK { EXPECT_TYPE(VT_I8); \
1110 ok(V_I8(&vOut) == ((((LONG64)(high))<<32)|(low)), "Expected i8 = %lx%08lx, got %lx%08lx\n", \
1111 (LONG)(high), (LONG)(low), (LONG)(V_I8(&vOut)>>32), (LONG)V_I8(&vOut) ); }
1112 #define EXPECT_UI8(val) EXPECT_OK { EXPECT_TYPE(VT_UI8); \
1113 ok(V_UI8(&vOut) == val, "Expected ui8 = %lld, got %lld\n", (ULONG64)val, V_UI8(&vOut)); }
1114 #define EXPECT_R4(val) EXPECT_OK { EXPECT_TYPE(VT_R4); \
1115 ok(V_R4(&vOut) == val, "Expected r4 = %f, got %f\n", val, V_R4(&vOut)); }
1116 #define EXPECT_R8(val) EXPECT_OK { EXPECT_TYPE(VT_R8); \
1117 ok(V_R8(&vOut) == val, "Expected r8 = %g, got %g\n", val, V_R8(&vOut)); }
1118 #define CY_MULTIPLIER 10000
1119 #define EXPECT_CY(val) EXPECT_OK { EXPECT_TYPE(VT_CY); \
1120 ok(V_CY(&vOut).int64 == (LONG64)(val * CY_MULTIPLIER), "Expected r8 = %lld, got %lld\n", (LONG64)val, V_CY(&vOut).int64); }
1122 static void test_VarNumFromParseNum(void)
1129 CHECKPTR(VarNumFromParseNum);
1131 /* Convert the number 1 to different types */
1132 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_I1); EXPECT_I1(1);
1133 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_UI1); EXPECT_UI1(1);
1134 /* Prefers a signed type to unsigned of the same size */
1135 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_I1|VTBIT_UI1); EXPECT_I1(1);
1136 /* But takes the smaller size if possible */
1137 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_I2|VTBIT_UI1); EXPECT_UI1(1);
1139 /* Try different integer sizes */
1140 #define INTEGER_VTBITS (VTBIT_I1|VTBIT_UI1|VTBIT_I2|VTBIT_UI2|VTBIT_I4|VTBIT_UI4|VTBIT_I8|VTBIT_UI8)
1142 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, INTEGER_VTBITS); EXPECT_I1(1);
1144 SETRGB(0, 1); SETRGB(1, 2); SETRGB(2, 7);
1145 CONVERT(3,0,0,3,0,0, INTEGER_VTBITS); EXPECT_I1(127);
1147 SETRGB(0, 1); SETRGB(1, 2); SETRGB(2, 8);
1148 CONVERT(3,0,0,3,0,0, INTEGER_VTBITS); EXPECT_UI1(128);
1150 SETRGB(0, 2); SETRGB(1, 5); SETRGB(2, 5);
1151 CONVERT(3,0,0,3,0,0, INTEGER_VTBITS); EXPECT_UI1(255);
1153 SETRGB(0, 2); SETRGB(1, 5); SETRGB(2, 6);
1154 CONVERT(3,0,0,3,0,0, INTEGER_VTBITS); EXPECT_I2(256);
1156 SETRGB(0, 3); SETRGB(1, 2); SETRGB(2, 7); SETRGB(3, 6); SETRGB(4, 7);
1157 CONVERT(5,0,0,5,0,0, INTEGER_VTBITS); EXPECT_I2(32767);
1159 SETRGB(0, 3); SETRGB(1, 2); SETRGB(2, 7); SETRGB(3, 6); SETRGB(4, 8);
1160 CONVERT(5,0,0,5,0,0, INTEGER_VTBITS); EXPECT_UI2(32768);
1162 /* Assume the above pattern holds for remaining positive integers; test negative */
1165 SETRGB(0, 1); SETRGB(1, 2); SETRGB(2, 8);
1166 CONVERT(3,0,NUMPRS_NEG,3,0,0, INTEGER_VTBITS); EXPECT_I1(-128);
1168 SETRGB(0, 1); SETRGB(1, 2); SETRGB(2, 9);
1169 CONVERT(3,0,NUMPRS_NEG,3,0,0, INTEGER_VTBITS); EXPECT_I2(-129);
1171 SETRGB(0, 3); SETRGB(1, 2); SETRGB(2, 7); SETRGB(3, 6); SETRGB(4, 8);
1172 CONVERT(5,0,NUMPRS_NEG,5,0,0, INTEGER_VTBITS); EXPECT_I2(-32768);
1174 SETRGB(0, 3); SETRGB(1, 2); SETRGB(2, 7); SETRGB(3, 6); SETRGB(4, 9);
1175 CONVERT(5,0,NUMPRS_NEG,5,0,0, INTEGER_VTBITS); EXPECT_I4(-32769);
1177 /* Assume the above pattern holds for remaining negative integers */
1179 /* Test hexadecimal conversions */
1180 SETRGB(0, 1); CONVERT(1,0,0,1,4,0, INTEGER_VTBITS); EXPECT_I1(0x01);
1182 SETRGB(0, 7); SETRGB(1, 0xf);
1183 CONVERT(2,0,0,2,4,0, INTEGER_VTBITS); EXPECT_I1(0x7f);
1185 SETRGB(0, 7); SETRGB(1, 0xf); SETRGB(2, 0xf); SETRGB(3, 0xf);
1186 CONVERT(4,0,0,4,4,0, INTEGER_VTBITS); EXPECT_I2(0x7fff);
1188 SETRGB(0, 7); SETRGB(1, 0xf); SETRGB(2, 0xf); SETRGB(3, 0xf);
1189 SETRGB(4, 0xf); SETRGB(5, 0xf); SETRGB(6, 0xf); SETRGB(7, 0xf);
1190 CONVERT(8,0,0,8,4,0, INTEGER_VTBITS); EXPECT_I4(0x7fffffffL);
1191 /* 0x7fffffffffffffff (64 bits) */
1192 SETRGB(0, 7); SETRGB(1, 0xf); SETRGB(2, 0xf); SETRGB(3, 0xf);
1193 SETRGB(4, 0xf); SETRGB(5, 0xf); SETRGB(6, 0xf); SETRGB(7, 0xf);
1194 SETRGB(8, 0xf); SETRGB(9, 0xf); SETRGB(10, 0xf); SETRGB(11, 0xf);
1195 SETRGB(12, 0xf); SETRGB(13, 0xf); SETRGB(14, 0xf); SETRGB(15, 0xf);
1196 if (HAVE_OLEAUT32_I8)
1198 /* We cannot use INTEGER_VTBITS as WinXP and Win2003 are broken(?). They
1199 truncate the number to the smallest integer size requested:
1200 CONVERT(16,0,0,16,4,0, INTEGER_VTBITS); EXPECT_I1((signed char)0xff); */
1201 CONVERT(16,0,0,16,4,0, VTBIT_I8); EXPECT_I8(0x7fffffff,0xffffffff);
1204 /* Assume the above pattern holds for numbers without hi-bit set, test (preservation of) hi-bit */
1206 SETRGB(0, 8); SETRGB(1, 2);
1207 CONVERT(2,0,0,2,4,0, INTEGER_VTBITS);
1208 EXPECT_I1((signed char)0x82);
1210 SETRGB(0, 8); SETRGB(1, 0); SETRGB(2, 0); SETRGB(3, 2);
1211 CONVERT(4,0,0,4,4,0, INTEGER_VTBITS);
1212 EXPECT_I2((signed short)0x8002);
1214 SETRGB(0, 8); SETRGB(1, 0); SETRGB(2, 0); SETRGB(3, 0);
1215 SETRGB(4, 0); SETRGB(5, 0); SETRGB(6, 0); SETRGB(7, 2);
1216 CONVERT(8,0,0,8,4,0, INTEGER_VTBITS); EXPECT_I4(0x80000002);
1217 /* 0x8000000000000002 (64 bits) */
1218 SETRGB(0, 8); SETRGB(1, 0); SETRGB(2, 0); SETRGB(3, 0);
1219 SETRGB(4, 0); SETRGB(5, 0); SETRGB(6, 0); SETRGB(7, 0);
1220 SETRGB(8, 0); SETRGB(9, 0); SETRGB(10, 0); SETRGB(11, 0);
1221 SETRGB(12, 0); SETRGB(13, 0); SETRGB(14, 0); SETRGB(15, 2);
1222 if (HAVE_OLEAUT32_I8)
1224 /* We cannot use INTEGER_VTBITS as WinXP and Win2003 are broken(?). They
1225 truncate the number to the smallest integer size requested:
1226 CONVERT(16,0,0,16,4,0, INTEGER_VTBITS & ~VTBIT_I1);
1227 EXPECT_I2((signed short)0x0002); */
1228 CONVERT(16,0,0,16,4,0, VTBIT_I8); EXPECT_I8(0x80000000,0x00000002);
1231 /* Test (preservation of) hi-bit with STRICT type requesting */
1233 SETRGB(0, 8); SETRGB(1, 2);
1234 CONVERT(2,0,0,2,4,0, VTBIT_I1);
1235 EXPECT_I1((signed char)0x82);
1237 SETRGB(0, 8); SETRGB(1, 0); SETRGB(2, 0); SETRGB(3, 2);
1238 CONVERT(4,0,0,4,4,0, VTBIT_I2);
1239 EXPECT_I2((signed short)0x8002);
1241 SETRGB(0, 8); SETRGB(1, 0); SETRGB(2, 0); SETRGB(3, 0);
1242 SETRGB(4, 0); SETRGB(5, 0); SETRGB(6, 0); SETRGB(7, 2);
1243 CONVERT(8,0,0,8,4,0, VTBIT_I4); EXPECT_I4(0x80000002);
1244 /* 0x8000000000000002 (64 bits) */
1245 SETRGB(0, 8); SETRGB(1, 0); SETRGB(2, 0); SETRGB(3, 0);
1246 SETRGB(4, 0); SETRGB(5, 0); SETRGB(6, 0); SETRGB(7, 0);
1247 SETRGB(8, 0); SETRGB(9, 0); SETRGB(10, 0); SETRGB(11, 0);
1248 SETRGB(12, 0); SETRGB(13, 0); SETRGB(14, 0); SETRGB(15, 2);
1249 if (HAVE_OLEAUT32_I8)
1251 CONVERT(16,0,0,16,4,0, VTBIT_I8); EXPECT_I8(0x80000000,0x00000002);
1253 /* Assume the above pattern holds for numbers with hi-bit set */
1255 /* Negative numbers overflow if we have only unsigned outputs */
1257 SETRGB(0, 1); CONVERT(1,0,NUMPRS_NEG,1,0,0, VTBIT_UI1); EXPECT_OVERFLOW;
1259 SETRGB(0, 6); CONVERT(1,0,NUMPRS_NEG,1,0,~0u, VTBIT_UI1); EXPECT_OVERFLOW;
1261 /* Except that rounding is done first, so -0.5 to 0 are accepted as 0 */
1263 SETRGB(0, 5); CONVERT(1,0,NUMPRS_NEG,1,0,~0u, VTBIT_UI1); EXPECT_UI1(0);
1265 /* Floating point zero is OK */
1267 SETRGB(0, 0); CONVERT(1,0,NUMPRS_DECIMAL|NUMPRS_EXPONENT,12,0,-8, VTBIT_R8);
1270 /* Float is acceptable for an integer input value */
1271 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_R4); EXPECT_R4(1.0f);
1273 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_R8); EXPECT_R8(1.0);
1274 /* As is currency */
1275 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_CY); EXPECT_CY(1);
1277 /* Float is preferred over double */
1278 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_R4|VTBIT_R8); EXPECT_R4(1.0f);
1280 /* Double is preferred over currency */
1281 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_R8|VTBIT_CY); EXPECT_R8(1.0);
1283 /* Currency is preferred over decimal */
1284 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_CY|VTBIT_DECIMAL); EXPECT_CY(1);
1287 static const char* szUdateFromDateFail = "%.16g expected %lx, %d,%d,%d,%d,%d,%d,%d %d %d"
1288 ", got %lx, %d,%d,%d,%d,%d,%d,%d %d %d\n";
1289 #define DT2UD(dt,flags,r,d,m,y,h,mn,s,ms,dw,dy) \
1290 memset(&ud, 0, sizeof(ud)); \
1291 res = pVarUdateFromDate(dt, flags, &ud); \
1292 ok(r == res && (FAILED(r) || (ud.st.wYear == y && ud.st.wMonth == m && ud.st.wDay == d && \
1293 ud.st.wHour == h && ud.st.wMinute == mn && ud.st.wSecond == s && \
1294 ud.st.wMilliseconds == ms && ud.st.wDayOfWeek == dw && ud.wDayOfYear == dy)), \
1295 szUdateFromDateFail, dt, r, d, m, y, h, mn, s, ms, dw, dy, res, ud.st.wDay, ud.st.wMonth, \
1296 ud.st.wYear, ud.st.wHour, ud.st.wMinute, ud.st.wSecond, \
1297 ud.st.wMilliseconds, ud.st.wDayOfWeek, ud.wDayOfYear)
1299 static void test_VarUdateFromDate(void)
1304 CHECKPTR(VarUdateFromDate);
1305 DT2UD(29221.0,0,S_OK,1,1,1980,0,0,0,0,2,1); /* 1 Jan 1980 */
1306 DT2UD(29222.0,0,S_OK,2,1,1980,0,0,0,0,3,2); /* 2 Jan 1980 */
1307 DT2UD(33238.0,0,S_OK,31,12,1990,0,0,0,0,1,365); /* 31 Dec 1990 */
1308 DT2UD(0.0,0,S_OK,30,12,1899,0,0,0,0,6,364); /* 30 Dec 1899 - VT_DATE 0.0 */
1309 DT2UD(-657434.0,0,S_OK,1,1,100,0,0,0,0,5,1); /* 1 Jan 100 - Min */
1310 DT2UD(-657435.0,0,E_INVALIDARG,0,0,0,0,0,0,0,0,0); /* < 1 Jan 100 => err */
1311 DT2UD(2958465.0,0,S_OK,31,12,9999,0,0,0,0,5,365); /* 31 Dec 9999 - Max */
1312 DT2UD(2958466.0,0,E_INVALIDARG,0,0,0,0,0,0,0,0,0); /* > 31 Dec 9999 => err */
1314 /* VAR_VALIDDATE doesn't prevent upper and lower bounds being checked */
1315 DT2UD(-657435.0,VAR_VALIDDATE,E_INVALIDARG,0,0,0,0,0,0,0,0,0);
1316 DT2UD(2958466.0,VAR_VALIDDATE,E_INVALIDARG,0,0,0,0,0,0,0,0,0);
1319 DT2UD(29221.25,0,S_OK,1,1,1980,6,0,0,0,2,1); /* 6 AM */
1320 DT2UD(29221.33333333,0,S_OK,1,1,1980,8,0,0,0,2,1); /* 8 AM */
1321 DT2UD(29221.5,0,S_OK,1,1,1980,12,0,0,0,2,1); /* 12 AM */
1322 DT2UD(29221.9888884444,0,S_OK,1,1,1980,23,44,0,0,2,1); /* 11:44 PM */
1323 DT2UD(29221.7508765432,0,S_OK,1,1,1980,18,1,16,0,2,1); /* 6:18:02 PM */
1326 #define UD2T(d,m,y,h,mn,s,ms,dw,dy,flags,r,dt) \
1327 ud.st.wYear = (y); ud.st.wMonth = (m); ud.st.wDay = (d); ud.st.wHour = (h); \
1328 ud.st.wMinute = (mn); ud.st.wSecond = (s); ud.st.wMilliseconds = (ms); \
1329 ud.st.wDayOfWeek = (dw); ud.wDayOfYear = (dy); \
1330 res = pVarDateFromUdate(&ud, (flags), &out); \
1331 ok((r) == res && (FAILED(r) || fabs(out-(dt)) < 1.0e-11), \
1332 "expected %lx, %.16g, got %lx, %.16g\n", r, dt, res, out)
1334 static void test_VarDateFromUdate(void)
1340 CHECKPTR(VarDateFromUdate);
1341 UD2T(1,1,1980,0,0,0,0,2,1,0,S_OK,29221.0); /* 1 Jan 1980 */
1342 UD2T(2,1,1980,0,0,0,0,3,2,0,S_OK,29222.0); /* 2 Jan 1980 */
1343 UD2T(31,12,1990,0,0,0,0,0,0,0,S_OK,33238.0); /* 31 Dec 1990 */
1344 UD2T(31,12,90,0,0,0,0,0,0,0,S_OK,33238.0); /* year < 100 is 1900+year! */
1345 UD2T(30,12,1899,0,0,0,0,6,364,0,S_OK,0.0); /* 30 Dec 1899 - VT_DATE 0.0 */
1346 UD2T(1,1,100,0,0,0,0,0,0,0,S_OK,-657434.0); /* 1 Jan 100 - Min */
1347 UD2T(31,12,9999,0,0,0,0,0,0,0,S_OK,2958465.0); /* 31 Dec 9999 - Max */
1348 UD2T(1,1,10000,0,0,0,0,0,0,0,E_INVALIDARG,0.0); /* > 31 Dec 9999 => err */
1350 UD2T(1,1,1980,18,1,16,0,2,1,0,S_OK,29221.75087962963); /* 6:18:02 PM */
1352 UD2T(0,1,1980,0,0,0,0,2,1,0,S_OK,29220.0); /* Rolls back to 31 Dec 1899 */
1353 UD2T(1,13,1980,0,0,0,0,2,1,0,S_OK,29587.0); /* Rolls fwd to 1/1/1981 */
1356 #define ST2DT(d,m,y,h,mn,s,ms,r,dt) \
1357 st.wYear = y; st.wMonth = m; st.wDay = d; st.wHour = h; st.wMinute = mn; \
1358 st.wSecond = s; st.wMilliseconds = ms; st.wDayOfWeek = 0; \
1359 res = pSystemTimeToVariantTime(&st, &out); \
1360 ok(r == res && (!r || fabs(out-dt) < 1.0e-11), \
1361 "expected %d, %.16g, got %d, %.16g\n", r, dt, res, out)
1363 static void test_SystemTimeToVariantTime(void)
1369 CHECKPTR(SystemTimeToVariantTime);
1370 ST2DT(1,1,1980,0,0,0,0,TRUE,29221.0);
1371 ST2DT(2,1,1980,0,0,0,0,TRUE,29222.0);
1372 ST2DT(0,1,1980,0,0,0,0,TRUE,29220.0); /* Rolls back to 31 Dec 1899 */
1373 ST2DT(1,13,1980,0,0,0,0,FALSE,29587.0); /* Fails on invalid month */
1374 ST2DT(31,12,90,0,0,0,0,TRUE,33238.0); /* year < 100 is 1900+year! */
1377 #define DT2ST(dt,r,d,m,y,h,mn,s,ms) \
1378 memset(&st, 0, sizeof(st)); \
1379 res = pVariantTimeToSystemTime(dt, &st); \
1380 ok(r == res && (!r || (st.wYear == y && st.wMonth == m && st.wDay == d && \
1381 st.wHour == h && st.wMinute == mn && st.wSecond == s && \
1382 st.wMilliseconds == ms)), \
1383 "%.16g expected %d, %d,%d,%d,%d,%d,%d,%d, got %d, %d,%d,%d,%d,%d,%d,%d\n", \
1384 dt, r, d, m, y, h, mn, s, ms, res, st.wDay, st.wMonth, st.wYear, \
1385 st.wHour, st.wMinute, st.wSecond, st.wMilliseconds)
1387 static void test_VariantTimeToSystemTime(void)
1392 CHECKPTR(VariantTimeToSystemTime);
1393 DT2ST(29221.0,1,1,1,1980,0,0,0,0);
1394 DT2ST(29222.0,1,2,1,1980,0,0,0,0);
1397 #define MKDOSDATE(d,m,y) ((d & 0x1f) | ((m & 0xf) << 5) | (((y-1980) & 0x7f) << 9))
1398 #define MKDOSTIME(h,m,s) (((s>>1) & 0x1f) | ((m & 0x3f) << 5) | ((h & 0x1f) << 11))
1400 static const char *szDosDateToVarTimeFail = "expected %d, %.16g, got %d, %.16g\n";
1401 #define DOS2DT(d,m,y,h,mn,s,r,dt) out = 0.0; \
1402 dosDate = MKDOSDATE(d,m,y); \
1403 dosTime = MKDOSTIME(h,mn,s); \
1404 res = pDosDateTimeToVariantTime(dosDate, dosTime, &out); \
1405 ok(r == res && (!r || fabs(out-dt) < 1.0e-11), \
1406 szDosDateToVarTimeFail, r, dt, res, out)
1408 static void test_DosDateTimeToVariantTime(void)
1410 USHORT dosDate, dosTime;
1414 CHECKPTR(DosDateTimeToVariantTime);
1417 DOS2DT(1,1,1980,0,0,0,1,29221.0); /* 1/1/1980 */
1418 DOS2DT(31,12,2099,0,0,0,1,73050.0); /* 31/12/2099 */
1419 /* Dates are limited to the dos date max of 31/12/2099 */
1420 DOS2DT(31,12,2100,0,0,0,0,0.0); /* 31/12/2100 */
1421 /* Days and months of 0 cause date to roll back 1 day or month */
1422 DOS2DT(0,1,1980,0,0,0,1,29220.0); /* 0 Day => 31/12/1979 */
1423 DOS2DT(1,0,1980,0,0,0,1,29190.0); /* 0 Mth => 1/12/1979 */
1424 DOS2DT(0,0,1980,0,0,0,1,29189.0); /* 0 D/M => 30/11/1979 */
1425 /* Days > days in the month cause date to roll forward 1 month */
1426 DOS2DT(29,2,1981,0,0,0,1,29646.0); /* 29/2/1981 -> 3/1/1980 */
1427 DOS2DT(30,2,1981,0,0,0,1,29647.0); /* 30/2/1981 -> 4/1/1980 */
1428 /* Takes leap years into account when rolling forward */
1429 DOS2DT(29,2,1980,0,0,0,1,29280.0); /* 2/29/1980 */
1430 /* Months > 12 cause an error */
1431 DOS2DT(2,13,1980,0,0,0,0,0.0);
1434 DOS2DT(1,1,1980,0,0,29,1,29221.00032407407); /* 1/1/1980 12:00:28 AM */
1435 DOS2DT(1,1,1980,0,0,31,1,29221.00034722222); /* 1/1/1980 12:00:30 AM */
1436 DOS2DT(1,1,1980,0,59,0,1,29221.04097222222); /* 1/1/1980 12:59:00 AM */
1437 DOS2DT(1,1,1980,0,60,0,0,0.0); /* Invalid seconds */
1438 DOS2DT(1,1,1980,23,0,0,1,29221.95833333333); /* 1/1/1980 11:00:00 PM */
1439 DOS2DT(1,1,1980,24,0,0,0,0.0); /* Invalid hours */
1442 #define DT2DOS(dt,r,d,m,y,h,mn,s) dosTime = dosDate = 0; \
1443 expDosDate = MKDOSDATE(d,m,y); \
1444 expDosTime = MKDOSTIME(h,mn,s); \
1445 res = pVariantTimeToDosDateTime(dt, &dosDate, &dosTime); \
1446 ok(r == res && (!r || (dosTime == expDosTime && dosDate == expDosDate)), \
1447 "%g: expected %d,%d(%d/%d/%d),%d(%d:%d:%d) got %d,%d(%d/%d/%d),%d(%d:%d:%d)\n", \
1448 dt, r, expDosDate, expDosDate & 0x1f, (expDosDate >> 5) & 0xf, 1980 + (expDosDate >> 9), \
1449 expDosTime, expDosTime >> 11, (expDosTime >> 5) & 0x3f, (expDosTime & 0x1f), \
1450 res, dosDate, dosDate & 0x1f, (dosDate >> 5) & 0xf, 1980 + (dosDate >> 9), \
1451 dosTime, dosTime >> 11, (dosTime >> 5) & 0x3f, (dosTime & 0x1f))
1453 static void test_VariantTimeToDosDateTime(void)
1455 USHORT dosDate, dosTime, expDosDate, expDosTime;
1458 CHECKPTR(VariantTimeToDosDateTime);
1461 DT2DOS(29221.0,1,1,1,1980,0,0,0); /* 1/1/1980 */
1462 DT2DOS(73050.0,1,31,12,2099,0,0,0); /* 31/12/2099 */
1463 DT2DOS(29220.0,0,0,0,0,0,0,0); /* 31/12/1979 - out of range */
1464 DT2DOS(73415.0,0,0,0,0,0,0,0); /* 31/12/2100 - out of range */
1467 DT2DOS(29221.00032407407,1,1,1,1980,0,0,29); /* 1/1/1980 12:00:28 AM */
1468 DT2DOS(29221.00034722222,1,1,1,1980,0,0,31); /* 1/1/1980 12:00:30 AM */
1469 DT2DOS(29221.04097222222,1,1,1,1980,0,59,0); /* 1/1/1980 12:59:00 AM */
1470 DT2DOS(29221.95833333333,1,1,1,1980,23,0,0); /* 1/1/1980 11:00:00 PM */
1473 #define FMT_NUMBER(vt,val) \
1474 VariantInit(&v); V_VT(&v) = vt; val(&v) = 1; \
1475 hres = pVarFormatNumber(&v,2,0,0,0,0,&str); \
1476 ok(hres == S_OK, "VarFormatNumber (vt %d): returned %8lx\n", vt, hres); \
1478 ok(str && strcmpW(str,szResult1) == 0, \
1479 "VarFormatNumber (vt %d): string different\n", vt)
1481 static void test_VarFormatNumber(void)
1483 static const WCHAR szSrc1[] = { '1','\0' };
1484 static const WCHAR szResult1[] = { '1','.','0','0','\0' };
1485 static const WCHAR szSrc2[] = { '-','1','\0' };
1486 static const WCHAR szResult2[] = { '(','1','.','0','0',')','\0' };
1492 CHECKPTR(VarFormatNumber);
1494 GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, buff, sizeof(buff)/sizeof(char));
1495 if (buff[0] != '.' || buff[1])
1497 trace("Skipping VarFormatNumber tests as decimal separator is '%s'\n", buff);
1501 FMT_NUMBER(VT_I1, V_I1);
1502 FMT_NUMBER(VT_UI1, V_UI1);
1503 FMT_NUMBER(VT_I2, V_I2);
1504 FMT_NUMBER(VT_UI2, V_UI2);
1505 FMT_NUMBER(VT_I4, V_I4);
1506 FMT_NUMBER(VT_UI4, V_UI4);
1507 if (HAVE_OLEAUT32_I8)
1509 FMT_NUMBER(VT_I8, V_I8);
1510 FMT_NUMBER(VT_UI8, V_UI8);
1512 FMT_NUMBER(VT_R4, V_R4);
1513 FMT_NUMBER(VT_R8, V_R8);
1514 FMT_NUMBER(VT_BOOL, V_BOOL);
1517 V_BSTR(&v) = SysAllocString(szSrc1);
1519 hres = pVarFormatNumber(&v,2,0,0,0,0,&str);
1520 ok(hres == S_OK, "VarFormatNumber (bstr): returned %8lx\n", hres);
1522 ok(str && strcmpW(str, szResult1) == 0, "VarFormatNumber (bstr): string different\n");
1523 SysFreeString(V_BSTR(&v));
1526 V_BSTR(&v) = SysAllocString(szSrc2);
1527 hres = pVarFormatNumber(&v,2,0,-1,0,0,&str);
1528 ok(hres == S_OK, "VarFormatNumber (bstr): returned %8lx\n", hres);
1530 ok(str && strcmpW(str, szResult2) == 0, "VarFormatNumber (-bstr): string different\n");
1531 SysFreeString(V_BSTR(&v));
1535 #define SIGNED_VTBITS (VTBIT_I1|VTBIT_I2|VTBIT_I4|VTBIT_I8|VTBIT_R4|VTBIT_R8)
1537 static const char *szVarFmtFail = "VT %d|0x%04x Format %s: expected 0x%08lx, '%s', got 0x%08lx, '%s'\n";
1538 #define VARFMT(vt,v,val,fmt,ret,str) do { \
1539 if (out) SysFreeString(out); out = NULL; \
1540 V_VT(&in) = (vt); v(&in) = val; \
1541 if (fmt) MultiByteToWideChar(CP_ACP, 0, fmt, -1, buffW, sizeof(buffW)/sizeof(WCHAR)); \
1542 hres = pVarFormat(&in,fmt ? buffW : NULL,fd,fw,flags,&out); \
1543 if (SUCCEEDED(hres)) WideCharToMultiByte(CP_ACP, 0, out, -1, buff, sizeof(buff),0,0); \
1544 else buff[0] = '\0'; \
1545 ok(hres == ret && (FAILED(ret) || !strcmp(buff, str)), \
1547 (vt)&VT_TYPEMASK,(vt)&~VT_TYPEMASK,fmt?fmt:"<null>",ret,str,hres,buff); \
1550 typedef struct tagFMTRES
1557 static const FMTRES VarFormat_results[] =
1561 { "General Number", "1", "0" },
1562 { "Percent", "100.00%", "0.00%" },
1563 { "Standard", "1.00", "0.00" },
1564 { "Scientific","1.00E+00", "0.00E+00" },
1565 { "True/False", "True", "False" },
1566 { "On/Off", "On", "Off" },
1567 { "Yes/No", "Yes", "No" },
1570 { "#.#", "1.", "." },
1572 { "00", "01", "00" },
1573 { "0.0", "1.0", "0.0" },
1574 { "00\\c\\o\\p\\y", "01copy","00copy" },
1575 { "\"pos\";\"neg\"", "pos", "pos" },
1576 { "\"pos\";\"neg\";\"zero\"","pos", "zero" }
1579 typedef struct tagFMTDATERES
1586 static const FMTDATERES VarFormat_date_results[] =
1594 { 0.0, "w", "1" }, /* First 7 entries must remain in this order! */
1595 { 2.525, "am/pm", "pm" },
1596 { 2.525, "AM/PM", "PM" },
1597 { 2.525, "A/P", "P" },
1598 { 2.525, "a/p", "p" },
1599 { 2.525, "q", "1" },
1600 { 2.525, "d", "1" },
1601 { 2.525, "dd", "01" },
1602 { 2.525, "ddd", "Mon" },
1603 { 2.525, "dddd", "Monday" },
1604 { 2.525, "mmm", "Jan" },
1605 { 2.525, "mmmm", "January" },
1606 { 2.525, "y", "1" },
1607 { 2.525, "yy", "00" },
1608 { 2.525, "yyy", "001" },
1609 { 2.525, "yyyy", "1900" },
1610 { 2.525, "dd mm yyyy hh:mm:ss", "01 01 1900 12:36:00" },
1611 { 2.525, "dd mm yyyy mm", "01 01 1900 01" },
1612 { 2.525, "dd mm yyyy :mm", "01 01 1900 :01" },
1613 { 2.525, "dd mm yyyy hh:mm", "01 01 1900 12:36" },
1614 { 2.525, "mm mm", "01 01" },
1615 { 2.525, "mm :mm:ss", "01 :01:00" },
1616 { 2.525, "mm :ss:mm", "01 :00:01" },
1617 { 2.525, "hh:mm :ss:mm", "12:36 :00:01" },
1618 { 2.525, "hh:dd :mm:mm", "12:01 :01:01" },
1619 { 2.525, "dd:hh :mm:mm", "01:12 :36:01" },
1620 { 2.525, "hh :mm:mm", "12 :36:01" },
1621 { 2.525, "dd :mm:mm", "01 :01:01" },
1622 { 2.525, "dd :mm:nn", "01 :01:36" },
1623 { 2.725, "hh:nn:ss A/P", "05:24:00 P" }
1626 #define VNUMFMT(vt,v) \
1627 for (i = 0; i < sizeof(VarFormat_results)/sizeof(FMTRES); i++) \
1629 VARFMT(vt,v,1,VarFormat_results[i].fmt,S_OK,VarFormat_results[i].one_res); \
1630 VARFMT(vt,v,0,VarFormat_results[i].fmt,S_OK,VarFormat_results[i].zero_res); \
1632 if ((1 << vt) & SIGNED_VTBITS) \
1634 VARFMT(vt,v,-1,"\"pos\";\"neg\"",S_OK,"neg"); \
1635 VARFMT(vt,v,-1,"\"pos\";\"neg\";\"zero\"",S_OK,"neg"); \
1638 static void test_VarFormat(void)
1640 static const WCHAR szTesting[] = { 't','e','s','t','i','n','g','\0' };
1645 VARIANT_BOOL bTrue = VARIANT_TRUE, bFalse = VARIANT_FALSE;
1648 BSTR bstrin, out = NULL;
1651 CHECKPTR(VarFormat);
1653 if (PRIMARYLANGID(LANGIDFROMLCID(GetUserDefaultLCID())) != LANG_ENGLISH)
1655 trace("Skipping VarFormat tests for non english language\n");
1658 GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, buff, sizeof(buff)/sizeof(char));
1659 if (buff[0] != '.' || buff[1])
1661 trace("Skipping VarFormat tests as decimal separator is '%s'\n", buff);
1664 GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_IDIGITS, buff, sizeof(buff)/sizeof(char));
1665 if (buff[0] != '2' || buff[1])
1667 trace("Skipping VarFormat tests as decimal places is '%s'\n", buff);
1671 VARFMT(VT_BOOL,V_BOOL,VARIANT_TRUE,"True/False",S_OK,"True");
1672 VARFMT(VT_BOOL,V_BOOL,VARIANT_FALSE,"True/False",S_OK,"False");
1674 VNUMFMT(VT_I1,V_I1);
1675 VNUMFMT(VT_I2,V_I2);
1676 VNUMFMT(VT_I4,V_I4);
1677 if (HAVE_OLEAUT32_I8)
1679 VNUMFMT(VT_I8,V_I8);
1681 VNUMFMT(VT_INT,V_INT);
1682 VNUMFMT(VT_UI1,V_UI1);
1683 VNUMFMT(VT_UI2,V_UI2);
1684 VNUMFMT(VT_UI4,V_UI4);
1685 if (HAVE_OLEAUT32_I8)
1687 VNUMFMT(VT_UI8,V_UI8);
1689 VNUMFMT(VT_UINT,V_UINT);
1690 VNUMFMT(VT_R4,V_R4);
1691 VNUMFMT(VT_R8,V_R8);
1693 /* Reference types are dereferenced */
1694 VARFMT(VT_BOOL|VT_BYREF,V_BOOLREF,&bTrue,"True/False",S_OK,"True");
1695 VARFMT(VT_BOOL|VT_BYREF,V_BOOLREF,&bFalse,"True/False",S_OK,"False");
1698 for (i = 0; i < sizeof(VarFormat_date_results)/sizeof(FMTDATERES); i++)
1701 fd = i + 1; /* Test first day */
1704 VARFMT(VT_DATE,V_DATE,VarFormat_date_results[i].val,
1705 VarFormat_date_results[i].fmt,S_OK,
1706 VarFormat_date_results[i].res);
1710 bstrin = SysAllocString(szTesting);
1711 VARFMT(VT_BSTR,V_BSTR,bstrin,"",S_OK,"testing");
1712 VARFMT(VT_BSTR,V_BSTR,bstrin,"@",S_OK,"testing");
1713 VARFMT(VT_BSTR,V_BSTR,bstrin,"&",S_OK,"testing");
1714 VARFMT(VT_BSTR,V_BSTR,bstrin,"\\x@\\x@",S_OK,"xtxesting");
1715 VARFMT(VT_BSTR,V_BSTR,bstrin,"\\x&\\x&",S_OK,"xtxesting");
1716 VARFMT(VT_BSTR,V_BSTR,bstrin,"@\\x",S_OK,"txesting");
1717 VARFMT(VT_BSTR,V_BSTR,bstrin,"@@@@@@@@",S_OK," testing");
1718 VARFMT(VT_BSTR,V_BSTR,bstrin,"@\\x@@@@@@@",S_OK," xtesting");
1719 VARFMT(VT_BSTR,V_BSTR,bstrin,"&&&&&&&&",S_OK,"testing");
1720 VARFMT(VT_BSTR,V_BSTR,bstrin,"!&&&&&&&",S_OK,"testing");
1721 VARFMT(VT_BSTR,V_BSTR,bstrin,"&&&&&&&!",S_OK,"testing");
1722 VARFMT(VT_BSTR,V_BSTR,bstrin,">&&",S_OK,"TESTING");
1723 VARFMT(VT_BSTR,V_BSTR,bstrin,"<&&",S_OK,"testing");
1724 VARFMT(VT_BSTR,V_BSTR,bstrin,"<&>&",S_OK,"testing");
1725 SysFreeString(bstrin);
1726 /* Numeric values are converted to strings then output */
1727 VARFMT(VT_I1,V_I1,1,"<&>&",S_OK,"1");
1729 /* Number formats */
1730 VARFMT(VT_I4,V_I4,1,"#00000000",S_OK,"00000001");
1731 VARFMT(VT_I4,V_I4,1,"000###",S_OK,"000001");
1732 VARFMT(VT_I4,V_I4,1,"#00##00#0",S_OK,"00000001");
1733 VARFMT(VT_I4,V_I4,1,"1#####0000",S_OK,"10001");
1735 VARFMT(VT_I4,V_I4,100000,"#,###,###,###",S_OK,"100,000");
1737 VARFMT(VT_R8,V_R8,1.23456789,"0#.0#0#0#0#0",S_OK,"01.234567890");
1738 VARFMT(VT_R8,V_R8,1.2,"0#.0#0#0#0#0",S_OK,"01.200000000");
1739 VARFMT(VT_R8,V_R8,9.87654321,"#0.#0#0#0#0#",S_OK,"9.87654321");
1740 VARFMT(VT_R8,V_R8,9.8,"#0.#0#0#0#0#",S_OK,"9.80000000");
1741 VARFMT(VT_R8,V_R8,0.00000008,"#0.#0#0#0#0#0",S_OK,"0.0000000800");
1742 VARFMT(VT_R8,V_R8,0.00010705,"#0.##########",S_OK,"0.00010705");
1743 VARFMT(VT_I4,V_I4,17,"#0",S_OK,"17");
1744 VARFMT(VT_I4,V_I4,4711,"#0",S_OK,"4711");
1745 VARFMT(VT_I4,V_I4,17,"#00",S_OK,"17");
1746 VARFMT(VT_I4,V_I4,100,"0##",S_OK,"100");
1747 VARFMT(VT_I4,V_I4,17,"#000",S_OK,"017");
1748 VARFMT(VT_I4,V_I4,17,"#0.00",S_OK,"17.00");
1749 VARFMT(VT_I4,V_I4,17,"#0000.00",S_OK,"0017.00");
1750 VARFMT(VT_I4,V_I4,17,"#.00",S_OK,"17.00");
1751 VARFMT(VT_R8,V_R8,1.7,"#.00",S_OK,"1.70");
1752 VARFMT(VT_R8,V_R8,.17,"#.00",S_OK,".17");
1753 VARFMT(VT_I4,V_I4,17,"#3",S_OK,"173");
1754 VARFMT(VT_I4,V_I4,17,"#33",S_OK,"1733");
1755 VARFMT(VT_I4,V_I4,17,"#3.33",S_OK,"173.33");
1756 VARFMT(VT_I4,V_I4,17,"#3333.33",S_OK,"173333.33");
1757 VARFMT(VT_I4,V_I4,17,"#.33",S_OK,"17.33");
1758 VARFMT(VT_R8,V_R8,.17,"#.33",S_OK,".33");
1759 VARFMT(VT_R8,V_R8,1.7,"0.0000E-000",S_OK,"1.7000E000");
1760 VARFMT(VT_R8,V_R8,1.7,"0.0000e-1",S_OK,"1.7000e01");
1761 VARFMT(VT_R8,V_R8,86.936849,"#0.000000000000e-000",S_OK,"86.936849000000e000");
1762 VARFMT(VT_R8,V_R8,1.7,"#0",S_OK,"2");
1763 VARFMT(VT_R8,V_R8,1.7,"#.33",S_OK,"2.33");
1764 VARFMT(VT_R8,V_R8,1.7,"#3",S_OK,"23");
1765 VARFMT(VT_R8,V_R8,1.73245,"0.0000E+000",S_OK,"1.7325E+000");
1766 VARFMT(VT_R8,V_R8,9.9999999,"#0.000000",S_OK,"10.000000");
1767 VARFMT(VT_R8,V_R8,1.7,"0.0000e+0#",S_OK,"1.7000e+0");
1768 VARFMT(VT_R8,V_R8,100.0001e+0,"0.0000E+0",S_OK,"1.0000E+2");
1769 VARFMT(VT_R8,V_R8,1000001,"0.0000e+1",S_OK,"1.0000e+61");
1770 VARFMT(VT_R8,V_R8,100.0001e+25,"0.0000e+0",S_OK,"1.0000e+27");
1771 VARFMT(VT_R8,V_R8,450.0001e+43,"#000.0000e+0",S_OK,"4500.0010e+42");
1772 VARFMT(VT_R8,V_R8,0.0001e-11,"##00.0000e-0",S_OK,"1000.0000e-18");
1773 VARFMT(VT_R8,V_R8,0.0317e-11,"0000.0000e-0",S_OK,"3170.0000e-16");
1774 VARFMT(VT_R8,V_R8,0.0021e-11,"00##.0000e-0",S_OK,"2100.0000e-17");
1775 VARFMT(VT_R8,V_R8,1.0001e-27,"##00.0000e-0",S_OK,"1000.1000e-30");
1776 VARFMT(VT_R8,V_R8,47.11,".0000E+0",S_OK,".4711E+2");
1777 VARFMT(VT_R8,V_R8,3.0401e-13,"#####.####e-0%",S_OK,"30401.e-15%");
1780 /* 'out' is not cleared */
1782 pVarFormat(&in,NULL,fd,fw,flags,&out); /* Would crash if out is cleared */
1786 V_VT(&in) = VT_NULL;
1787 hres = pVarFormat(&in,NULL,fd,fw,0,&out);
1788 ok(hres == S_OK, "VarFormat failed with 0x%08lx\n", hres);
1789 ok(out == NULL, "expected NULL formatted string\n");
1792 hres = pVarFormat(&in,NULL,fd,fw,flags,NULL);
1793 ok(hres == E_INVALIDARG, "Null out: expected E_INVALIDARG, got 0x%08lx\n", hres);
1794 hres = pVarFormat(NULL,NULL,fd,fw,flags,&out);
1795 ok(hres == E_INVALIDARG, "Null in: expected E_INVALIDARG, got 0x%08lx\n", hres);
1797 VARFMT(VT_BOOL,V_BOOL,VARIANT_TRUE,"",E_INVALIDARG,"");
1799 VARFMT(VT_BOOL,V_BOOL,VARIANT_TRUE,"",E_INVALIDARG,"");
1801 VARFMT(VT_BOOL,V_BOOL,VARIANT_TRUE,"",E_INVALIDARG,"");
1803 VARFMT(VT_BOOL,V_BOOL,VARIANT_TRUE,"",E_INVALIDARG,"");
1806 static HRESULT (WINAPI *pVarAbs)(LPVARIANT,LPVARIANT);
1808 static const char *szVarAbsFail = "VarAbs: expected 0x0,%d,%d, got 0x%lX,%d,%d\n";
1809 #define VARABS(vt,val,rvt,rval) V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
1810 memset(&vDst,0,sizeof(vDst)); hres = pVarAbs(&v,&vDst); \
1811 ok(hres == S_OK && V_VT(&vDst) == VT_##rvt && V_##rvt(&vDst) == (rval), \
1812 szVarAbsFail, VT_##rvt, (int)(rval), \
1813 hres, V_VT(&vDst), (int)V_##rvt(&vDst))
1815 static void test_VarAbs(void)
1817 static const WCHAR szNum[] = {'-','1','.','1','\0' };
1825 /* Test all possible V_VT values.
1827 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
1831 for (vt = 0; vt <= VT_BSTR_BLOB; vt++)
1833 HRESULT hExpected = DISP_E_BADVARTYPE;
1837 memset(&v, 0, sizeof(v));
1838 V_VT(&v) = vt | ExtraFlags[i];
1839 V_VT(&vDst) = VT_EMPTY;
1841 hres = pVarAbs(&v,&vDst);
1842 if (ExtraFlags[i] & (VT_ARRAY|VT_ARRAY) ||
1843 (!ExtraFlags[i] && (vt == VT_UNKNOWN || vt == VT_BSTR ||
1844 vt == VT_DISPATCH || vt == VT_ERROR || vt == VT_RECORD)))
1846 hExpected = DISP_E_TYPEMISMATCH;
1848 else if (ExtraFlags[i] || vt >= VT_CLSID || vt == VT_VARIANT)
1850 hExpected = DISP_E_BADVARTYPE;
1852 else if (IsValidVariantClearVT(vt, ExtraFlags[i]))
1855 /* Native always fails on some vartypes that should be valid. don't
1856 * check that Wine does the same; these are bugs in native.
1858 if (vt == VT_I8 || vt == VT_UI8 || vt == VT_INT || vt == VT_UINT ||
1859 vt == VT_I1 || vt == VT_UI2 || vt == VT_UI4)
1861 ok(hres == hExpected, "VarAbs: expected 0x%lX, got 0x%lX for vt %d | 0x%X\n",
1862 hExpected, hres, vt, ExtraFlags[i]);
1866 /* BOOL->I2, BSTR->R8, all others remain the same */
1867 VARABS(BOOL,VARIANT_TRUE,I2,-VARIANT_TRUE);
1868 VARABS(BOOL,VARIANT_FALSE,I2,VARIANT_FALSE);
1869 VARABS(EMPTY,0,I2,0);
1870 VARABS(EMPTY,1,I2,0);
1871 VARABS(NULL,0,NULL,0);
1872 VARABS(NULL,1,NULL,0);
1877 VARABS(UI1,1,UI1,1);
1882 VARABS(DATE,1,DATE,1);
1883 VARABS(DATE,-1,DATE,1);
1885 V_CY(&v).int64 = -10000;
1886 memset(&vDst,0,sizeof(vDst));
1887 hres = pVarAbs(&v,&vDst);
1888 ok(hres == S_OK && V_VT(&vDst) == VT_CY && V_CY(&vDst).int64 == 10000,
1889 "VarAbs(CY): expected 0x0 got 0x%lX\n", hres);
1890 GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, buff, sizeof(buff)/sizeof(char));
1891 if (buff[0] != '.' || buff[1])
1893 trace("Skipping VarAbs(BSTR) as decimal separator is '%s'\n", buff);
1897 V_BSTR(&v) = (BSTR)szNum;
1898 memset(&vDst,0,sizeof(vDst));
1899 hres = pVarAbs(&v,&vDst);
1900 ok(hres == S_OK && V_VT(&vDst) == VT_R8 && V_R8(&vDst) == 1.1,
1901 "VarAbs: expected 0x0,%d,%g, got 0x%lX,%d,%g\n", VT_R8, 1.1, hres, V_VT(&vDst), V_R8(&vDst));
1904 static HRESULT (WINAPI *pVarNot)(LPVARIANT,LPVARIANT);
1906 static const char *szVarNotFail = "VarNot: expected 0x0,%d,%d, got 0x%lX,%d,%d\n";
1907 #define VARNOT(vt,val,rvt,rval) V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
1908 memset(&vDst,0,sizeof(vDst)); hres = pVarNot(&v,&vDst); \
1909 ok(hres == S_OK && V_VT(&vDst) == VT_##rvt && V_##rvt(&vDst) == (rval), \
1910 szVarNotFail, VT_##rvt, (int)(rval), \
1911 hres, V_VT(&vDst), (int)V_##rvt(&vDst))
1913 static void test_VarNot(void)
1915 static const WCHAR szNum0[] = {'0','\0' };
1916 static const WCHAR szNum1[] = {'1','\0' };
1919 DECIMAL *pdec = &V_DECIMAL(&v);
1920 CY *pcy = &V_CY(&v);
1925 /* Test all possible V_VT values */
1926 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
1930 for (vt = 0; vt <= VT_BSTR_BLOB; vt++)
1932 HRESULT hExpected = DISP_E_BADVARTYPE;
1936 memset(&v, 0, sizeof(v));
1937 V_VT(&v) = vt | ExtraFlags[i];
1938 V_VT(&vDst) = VT_EMPTY;
1942 case VT_I1: case VT_UI1: case VT_I2: case VT_UI2:
1943 case VT_INT: case VT_UINT: case VT_I4: case VT_UI4:
1944 case VT_R4: case VT_R8:
1945 case VT_DECIMAL: case VT_BOOL: case VT_NULL: case VT_EMPTY:
1946 case VT_DATE: case VT_CY:
1949 case VT_I8: case VT_UI8:
1950 if (HAVE_OLEAUT32_I8)
1954 if (HAVE_OLEAUT32_RECORD)
1955 hExpected = DISP_E_TYPEMISMATCH;
1957 case VT_UNKNOWN: case VT_BSTR: case VT_DISPATCH: case VT_ERROR:
1958 hExpected = DISP_E_TYPEMISMATCH;
1961 if (IsValidVariantClearVT(vt, ExtraFlags[i]) && vt != VT_CLSID)
1962 hExpected = DISP_E_TYPEMISMATCH;
1966 hres = pVarNot(&v,&vDst);
1967 ok(hres == hExpected, "VarNot: expected 0x%lX, got 0x%lX vt %d|0x%X\n",
1968 hExpected, hres, vt, ExtraFlags[i]);
1971 /* Test the values returned by all cases that can succeed */
1972 VARNOT(EMPTY,0,I2,-1);
1973 VARNOT(EMPTY,1,I2,-1);
1974 VARNOT(NULL,0,NULL,0);
1975 VARNOT(NULL,1,NULL,0);
1976 VARNOT(BOOL,VARIANT_TRUE,BOOL,VARIANT_FALSE);
1977 VARNOT(BOOL,VARIANT_FALSE,BOOL,VARIANT_TRUE);
1985 VARNOT(UI1,1,UI1,254);
1986 VARNOT(UI1,0,UI1,255);
1987 VARNOT(UI2,0,I4,-1);
1988 VARNOT(UI2,1,I4,-2);
1989 VARNOT(UI4,0,I4,-1);
1990 VARNOT(UI4,1,I4,-2);
1991 VARNOT(INT,0,I4,-1);
1992 VARNOT(INT,1,I4,-2);
1993 VARNOT(UINT,0,I4,-1);
1994 VARNOT(UINT,1,I4,-2);
1995 if (HAVE_OLEAUT32_I8)
1999 VARNOT(UI8,0,I4,-1);
2000 VARNOT(UI8,1,I4,-2);
2006 VARNOT(DATE,1,I4,-2);
2007 VARNOT(DATE,0,I4,-1);
2008 VARNOT(BSTR,(BSTR)szNum0,I4,-1);
2009 ok(V_VT(&v) == VT_BSTR && V_BSTR(&v) == szNum0, "VarNot(0): changed input\n");
2010 VARNOT(BSTR,(BSTR)szNum1,I4,-2);
2011 ok(V_VT(&v) == VT_BSTR && V_BSTR(&v) == szNum1, "VarNot(1): changed input\n");
2013 V_VT(&v) = VT_DECIMAL;
2014 S(U(*pdec)).sign = DECIMAL_NEG;
2015 S(U(*pdec)).scale = 0;
2017 S1(U1(*pdec)).Mid32 = 0;
2018 S1(U1(*pdec)).Lo32 = 1;
2019 VARNOT(DECIMAL,*pdec,I4,0);
2022 VARNOT(CY,*pcy,I4,-2);
2025 VARNOT(CY,*pcy,I4,-1);
2028 VARNOT(CY,*pcy,I4,-1);
2030 static HRESULT (WINAPI *pVarSub)(LPVARIANT,LPVARIANT,LPVARIANT);
2032 static void test_VarSub(void)
2039 V_VT(&va) = VT_DATE;
2040 V_DATE(&va) = 200000.0;
2041 V_VT(&vb) = VT_DATE;
2042 V_DATE(&vb) = 100000.0;
2044 hr = pVarSub(&va, &vb, &vc);
2045 ok(hr == S_OK,"VarSub of VT_DATE - VT_DATE failed with %lx\n", hr);
2046 ok(V_VT(&vc) == VT_R8,"VarSub of VT_DATE - VT_DATE returned vt 0x%x\n", V_VT(&vc));
2047 ok(((V_R8(&vc) > 99999.9) && (V_R8(&vc) < 100000.1)),"VarSub of VT_DATE - VT_DATE should return 100000.0, but returned %g\n", V_R8(&vc));
2048 /* fprintf(stderr,"VarSub of 10000-20000 returned: %g\n", V_R8(&vc)); */
2051 static const char *szVarModFail = "VarMod: expected 0x%lx,%d(%s),%d, got 0x%lX,%d(%s),%d\n";
2052 #define VARMOD(vt1,vt2,val1,val2,rvt,rval,hexpected) V_VT(&v1) = VT_##vt1; V_##vt1(&v1) = val1; \
2053 V_VT(&v2) = VT_##vt2; V_##vt2(&v2) = val2; \
2054 memset(&vDst,0,sizeof(vDst)); hres = pVarMod(&v1,&v2,&vDst); \
2055 ok(hres == hexpected && V_VT(&vDst) == VT_##rvt && V_##rvt(&vDst) == (rval), \
2056 szVarModFail, hexpected, VT_##rvt, vtstr(VT_##rvt), (int)(rval), \
2057 hres, V_VT(&vDst), vtstr(V_VT(&vDst)), (int)V_##rvt(&vDst))
2059 static const char *szVarMod2Fail = "VarMod: expected 0x%lx,%d(%s),%d, got 0x%lX,%d(%s),%d\n";
2060 #define VARMOD2(vt1,vt2,val1,val2,rvt,rval,hexpected) V_VT(&v1) = VT_##vt1; V_I4(&v1) = val1; \
2061 V_VT(&v2) = VT_##vt2; V_I4(&v2) = val2; \
2062 memset(&vDst,0,sizeof(vDst)); hres = pVarMod(&v1,&v2,&vDst); \
2063 ok(hres == hexpected && V_VT(&vDst) == VT_##rvt && V_I4(&vDst) == (rval), \
2064 szVarMod2Fail, hexpected, VT_##rvt, vtstr(VT_##rvt), (int)(rval), \
2065 hres, V_VT(&vDst), vtstr(V_VT(&vDst)), (int)V_I4(&vDst))
2067 static HRESULT (WINAPI *pVarMod)(LPVARIANT,LPVARIANT,LPVARIANT);
2069 static void test_VarMod(void)
2071 VARIANT v1, v2, vDst;
2073 HRESULT hexpected = 0;
2074 static const WCHAR szNum0[] = {'1','2','5','\0'};
2075 static const WCHAR szNum1[] = {'1','0','\0'};
2077 BOOL lFound, rFound;
2078 BOOL lValid, rValid;
2079 BSTR strNum0, strNum1;
2083 VARMOD(I1,BOOL,100,10,I4,0,S_OK);
2084 VARMOD(I1,I1,100,10,I4,0,S_OK);
2085 VARMOD(I1,UI1,100,10,I4,0,S_OK);
2086 VARMOD(I1,I2,100,10,I4,0,S_OK);
2087 VARMOD(I1,UI2,100,10,I4,0,S_OK);
2088 VARMOD(I1,I4,100,10,I4,0,S_OK);
2089 VARMOD(I1,UI4,100,10,I4,0,S_OK);
2090 VARMOD(I1,R4,100,10,I4,0,S_OK);
2091 VARMOD(I1,R8,100,10,I4,0,S_OK);
2093 VARMOD(UI1,BOOL,100,10,I2,0,S_OK);
2094 VARMOD(UI1,I1,100,10,I4,0,S_OK);
2095 VARMOD(UI1,UI1,100,10,UI1,0,S_OK);
2096 VARMOD(UI1,I2,100,10,I2,0,S_OK);
2097 VARMOD(UI1,UI2,100,10,I4,0,S_OK);
2098 VARMOD(UI1,I4,100,10,I4,0,S_OK);
2099 VARMOD(UI1,UI4,100,10,I4,0,S_OK);
2100 VARMOD(UI1,R4,100,10,I4,0,S_OK);
2101 VARMOD(UI1,R8,100,10,I4,0,S_OK);
2103 VARMOD(I2,BOOL,100,10,I2,0,S_OK);
2104 VARMOD(I2,I1,100,10,I4,0,S_OK);
2105 VARMOD(I2,UI1,100,10,I2,0,S_OK);
2106 VARMOD(I2,I2,100,10,I2,0,S_OK);
2107 VARMOD(I2,UI2,100,10,I4,0,S_OK);
2108 VARMOD(I2,I4,100,10,I4,0,S_OK);
2109 VARMOD(I2,UI4,100,10,I4,0,S_OK);
2110 VARMOD(I2,R4,100,10,I4,0,S_OK);
2111 VARMOD(I2,R8,100,10,I4,0,S_OK);
2113 VARMOD(I4,BOOL,100,10,I4,0,S_OK);
2114 VARMOD(I4,I1,100,10,I4,0,S_OK);
2115 VARMOD(I4,UI1,100,10,I4,0,S_OK);
2116 VARMOD(I4,I2,100,10,I4,0,S_OK);
2117 VARMOD(I4,UI2,100,10,I4,0,S_OK);
2118 VARMOD(I4,I4,100,10,I4,0,S_OK);
2119 VARMOD(I4,UI4,100,10,I4,0,S_OK);
2120 VARMOD(I4,R4,100,10,I4,0,S_OK);
2121 VARMOD(I4,R8,100,10,I4,0,S_OK);
2122 VARMOD(UI4,BOOL,100,10,I4,0,S_OK);
2123 VARMOD(UI4,I1,100,10,I4,0,S_OK);
2124 VARMOD(UI4,UI1,100,10,I4,0,S_OK);
2125 VARMOD(UI4,I2,100,10,I4,0,S_OK);
2126 VARMOD(UI4,UI2,100,10,I4,0,S_OK);
2127 VARMOD(UI4,I4,100,10,I4,0,S_OK);
2128 VARMOD(UI4,UI4,100,10,I4,0,S_OK);
2129 VARMOD(UI4,R4,100,10,I4,0,S_OK);
2130 VARMOD(UI4,R8,100,10,I4,0,S_OK);
2131 VARMOD(R4,BOOL,100,10,I4,0,S_OK);
2132 VARMOD(R4,I1,100,10,I4,0,S_OK);
2133 VARMOD(R4,UI1,100,10,I4,0,S_OK);
2134 VARMOD(R4,I2,100,10,I4,0,S_OK);
2135 VARMOD(R4,UI2,100,10,I4,0,S_OK);
2136 VARMOD(R4,I4,100,10,I4,0,S_OK);
2137 VARMOD(R4,UI4,100,10,I4,0,S_OK);
2138 VARMOD(R4,R4,100,10,I4,0,S_OK);
2139 VARMOD(R4,R8,100,10,I4,0,S_OK);
2140 VARMOD(R8,BOOL,100,10,I4,0,S_OK);
2141 VARMOD(R8,I1,100,10,I4,0,S_OK);
2142 VARMOD(R8,UI1,100,10,I4,0,S_OK);
2143 VARMOD(R8,I2,100,10,I4,0,S_OK);
2144 VARMOD(R8,UI2,100,10,I4,0,S_OK);
2145 VARMOD(R8,I4,100,10,I4,0,S_OK);
2146 VARMOD(R8,UI4,100,10,I4,0,S_OK);
2147 VARMOD(R8,R4,100,10,I4,0,S_OK);
2148 VARMOD(R8,R8,100,10,I4,0,S_OK);
2150 VARMOD(INT,INT,100,10,I4,0,S_OK);
2151 VARMOD(INT,UINT,100,10,I4,0,S_OK);
2153 VARMOD(BOOL,BOOL,100,10,I2,0,S_OK);
2154 VARMOD(BOOL,I1,100,10,I4,0,S_OK);
2155 VARMOD(BOOL,UI1,100,10,I2,0,S_OK);
2156 VARMOD(BOOL,I2,100,10,I2,0,S_OK);
2157 VARMOD(BOOL,UI2,100,10,I4,0,S_OK);
2158 VARMOD(BOOL,I4,100,10,I4,0,S_OK);
2159 VARMOD(BOOL,UI4,100,10,I4,0,S_OK);
2160 VARMOD(BOOL,R4,100,10,I4,0,S_OK);
2161 VARMOD(BOOL,R8,100,10,I4,0,S_OK);
2162 VARMOD(BOOL,DATE,100,10,I4,0,S_OK);
2164 VARMOD(DATE,BOOL,100,10,I4,0,S_OK);
2165 VARMOD(DATE,I1,100,10,I4,0,S_OK);
2166 VARMOD(DATE,UI1,100,10,I4,0,S_OK);
2167 VARMOD(DATE,I2,100,10,I4,0,S_OK);
2168 VARMOD(DATE,UI2,100,10,I4,0,S_OK);
2169 VARMOD(DATE,I4,100,10,I4,0,S_OK);
2170 VARMOD(DATE,UI4,100,10,I4,0,S_OK);
2171 VARMOD(DATE,R4,100,10,I4,0,S_OK);
2172 VARMOD(DATE,R8,100,10,I4,0,S_OK);
2173 VARMOD(DATE,DATE,100,10,I4,0,S_OK);
2175 strNum0 = SysAllocString(szNum0);
2176 strNum1 = SysAllocString(szNum1);
2177 VARMOD(BSTR,BSTR,strNum0,strNum1,I4,5,S_OK);
2178 VARMOD(BSTR,I1,strNum0,10,I4,5,S_OK);
2179 VARMOD(BSTR,I2,strNum0,10,I4,5,S_OK);
2180 VARMOD(BSTR,I4,strNum0,10,I4,5,S_OK);
2181 VARMOD(BSTR,R4,strNum0,10,I4,5,S_OK);
2182 VARMOD(BSTR,R8,strNum0,10,I4,5,S_OK);
2183 VARMOD(I4,BSTR,125,strNum1,I4,5,S_OK);
2185 if (HAVE_OLEAUT32_I8)
2187 VARMOD(BOOL,I8,100,10,I8,0,S_OK);
2188 VARMOD(I1,I8,100,10,I8,0,S_OK);
2189 VARMOD(UI1,I8,100,10,I8,0,S_OK);
2190 VARMOD(I2,I8,100,10,I8,0,S_OK);
2191 VARMOD(I4,I8,100,10,I8,0,S_OK);
2192 VARMOD(UI4,I8,100,10,I8,0,S_OK);
2193 VARMOD(R4,I8,100,10,I8,0,S_OK);
2194 VARMOD(R8,I8,100,10,I8,0,S_OK);
2195 VARMOD(DATE,I8,100,10,I8,0,S_OK);
2197 VARMOD(I8,BOOL,100,10,I8,0,S_OK);
2198 VARMOD(I8,I1,100,10,I8,0,S_OK);
2199 VARMOD(I8,UI1,100,10,I8,0,S_OK);
2200 VARMOD(I8,I2,100,10,I8,0,S_OK);
2201 VARMOD(I8,UI2,100,10,I8,0,S_OK);
2202 VARMOD(I8,I4,100,10,I8,0,S_OK);
2203 VARMOD(I8,UI4,100,10,I8,0,S_OK);
2204 VARMOD(I8,R4,100,10,I8,0,S_OK);
2205 VARMOD(I8,R8,100,10,I8,0,S_OK);
2206 VARMOD(I8,I8,100,10,I8,0,S_OK);
2208 VARMOD(BSTR,I8,strNum0,10,I8,5,S_OK);
2211 /* test all combinations of types */
2212 for(l = 0; l < VT_BSTR_BLOB; l++)
2216 for(r = 0; r < VT_BSTR_BLOB; r++)
2220 if(l == VT_BSTR) continue;
2221 if(l == VT_DISPATCH) continue;
2222 if(r == VT_BSTR) continue;
2223 if(r == VT_DISPATCH) continue;
2257 hexpected = DISP_E_BADVARTYPE;
2296 if(((l == VT_I8) && (r == VT_INT)) || ((l == VT_INT) && (r == VT_I8)))
2298 hexpected = DISP_E_TYPEMISMATCH;
2299 } else if((l == VT_EMPTY) && (r == VT_NULL))
2302 } else if((l == VT_NULL) && (r == VT_EMPTY))
2305 } else if((l == VT_EMPTY) && (r == VT_CY))
2308 } else if((l == VT_EMPTY) && (r == VT_RECORD))
2310 hexpected = DISP_E_TYPEMISMATCH;
2311 } else if((r == VT_EMPTY) && lFound && lValid)
2313 hexpected = DISP_E_DIVBYZERO;
2314 } else if((l == VT_ERROR) || ((r == VT_ERROR) && lFound && lValid))
2316 hexpected = DISP_E_TYPEMISMATCH;
2317 } else if((l == VT_NULL) && (r == VT_NULL))
2320 } else if((l == VT_VARIANT) || ((r == VT_VARIANT) && lFound && lValid))
2322 hexpected = DISP_E_TYPEMISMATCH;
2323 } else if((l == VT_NULL) && (r == VT_RECORD))
2325 hexpected = DISP_E_TYPEMISMATCH;
2326 } else if((l == VT_NULL) && (r == VT_DECIMAL))
2328 hexpected = DISP_E_OVERFLOW;
2329 } else if((l == VT_UNKNOWN) || ((r == VT_UNKNOWN) && lFound && lValid))
2331 hexpected = DISP_E_TYPEMISMATCH;
2332 } else if((l == VT_NULL) && rFound)
2335 } else if((l == VT_DECIMAL) || ((r == VT_DECIMAL) && lFound && lValid))
2337 hexpected = DISP_E_OVERFLOW;
2338 } else if(l == VT_RECORD)
2340 hexpected = DISP_E_TYPEMISMATCH;
2341 } else if((r == VT_RECORD) && lValid && lFound)
2343 hexpected = DISP_E_TYPEMISMATCH;
2344 } else if((l == VT_EMPTY) && (r == VT_EMPTY))
2346 hexpected = DISP_E_DIVBYZERO;
2347 } else if((l == VT_CY) && !rFound)
2349 hexpected = DISP_E_BADVARTYPE;
2350 } else if(lFound && !rFound)
2352 hexpected = DISP_E_BADVARTYPE;
2353 } else if(!lFound && rFound)
2355 hexpected = DISP_E_BADVARTYPE;
2356 } else if((r == VT_NULL) && lFound && lValid)
2359 } else if((l == VT_NULL) || (r == VT_NULL))
2361 hexpected = DISP_E_BADVARTYPE;
2362 } else if((l == VT_VARIANT) || (r == VT_VARIANT))
2364 hexpected = DISP_E_BADVARTYPE;
2365 } else if(lFound && !rFound)
2367 hexpected = DISP_E_BADVARTYPE;
2368 } else if(!lFound && !rFound)
2370 hexpected = DISP_E_BADVARTYPE;
2377 V_CY(&v1).int64 = 1000000;
2382 else if(l == VT_UI8)
2384 else if(l == VT_DATE)
2390 V_CY(&v2).int64 = 10000;
2395 else if(r == VT_UI8)
2397 else if(r == VT_DATE)
2402 if ((l != VT_I8 && l != VT_UI8 && r != VT_I8 && r != VT_UI8) || HAVE_OLEAUT32_I8)
2404 hres = pVarMod(&v1,&v2,&vDst);
2405 ok(hres == hexpected,
2406 "VarMod: expected 0x%lx, got 0x%lX for l type of %d, r type of %d,\n", hexpected, hres, l, r);
2412 /****************************/
2413 /* test some bad parameters */
2414 VARMOD(I4,I4,-1,-1,I4,0,S_OK);
2416 /* test modulus with zero */
2417 VARMOD2(I4,I4,100,0,EMPTY,0,DISP_E_DIVBYZERO);
2419 VARMOD(I4,I4,0,10,I4,0,S_OK); /* test 0 mod 10 */
2421 /* right parameter is type empty */
2422 VARMOD2(I4,EMPTY,100,10,EMPTY,0,DISP_E_DIVBYZERO);
2424 /* left parameter is type empty */
2425 VARMOD2(EMPTY,I4,100,10,I4,0,S_OK);
2427 /* mod with a null left value */
2428 VARMOD2(NULL,I4,125,10,NULL,0,S_OK);
2430 /* mod with a null right value */
2431 VARMOD2(I4,NULL,100,10,NULL,0,S_OK);
2433 /* void left value */
2434 VARMOD2(VOID,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2436 /* void right value */
2437 VARMOD2(I4,VOID,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2439 /* null left value, void right value */
2440 VARMOD2(NULL,VOID,100,10,EMPTY, 0, DISP_E_BADVARTYPE);
2442 /* void left value, null right value */
2443 VARMOD2(VOID,NULL,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2445 /* some currencies */
2448 V_CY(&v1).int64 = 100000;
2449 V_CY(&v2).int64 = 100000;
2450 hres = pVarMod(&v1,&v2,&vDst);
2451 ok(hres == S_OK && V_VT(&vDst) == VT_I4 && V_I4(&vDst) == 0,
2452 "VarMod: expected 0x%lx,%d,%d, got 0x%lX,%d,%ld\n", S_OK, VT_I4, 0, hres, V_VT(&vDst), V_I4(&vDst));
2457 V_CY(&v2).int64 = 100000;
2458 hres = pVarMod(&v1,&v2,&vDst);
2459 ok(hres == S_OK && V_VT(&vDst) == VT_I4 && V_I4(&vDst) == 0,
2460 "VarMod: expected 0x%lx,%d,%d, got 0x%lX,%d,%ld\n", S_OK, VT_I4, 0, hres, V_VT(&vDst), V_I4(&vDst));
2464 V_VT(&v1) = VT_DECIMAL;
2465 V_VT(&v2) = VT_DECIMAL;
2466 VarDecFromI4(100, &V_DECIMAL(&v1));
2467 VarDecFromI4(10, &V_DECIMAL(&v2));
2468 hres = pVarMod(&v1,&v2,&vDst);
2469 ok(hres == S_OK && V_VT(&vDst) == VT_I4 && V_I4(&vDst) == 0,
2470 "VarMod: expected 0x%lx,%d,%d, got 0x%lX,%d,%ld\n", S_OK, VT_I4, 0, hres, V_VT(&vDst), V_I4(&vDst));
2473 V_VT(&v2) = VT_DECIMAL;
2475 VarDecFromI4(10, &V_DECIMAL(&v2));
2476 hres = pVarMod(&v1,&v2,&vDst);
2477 ok(hres == S_OK && V_VT(&vDst) == VT_I4 && V_I4(&vDst) == 0,
2478 "VarMod: expected 0x%lx,%d,%d, got 0x%lX,%d,%ld\n", S_OK, VT_I4, 0, hres, V_VT(&vDst), V_I4(&vDst));
2481 VARMOD2(UINT,I4,100,10,I4,0,S_OK);
2483 /* test that an error results in the type of the result changing but not its value */
2484 V_VT(&v1) = VT_UNKNOWN;
2485 V_VT(&v2) = VT_EMPTY;
2487 V_CY(&v2).int64 = 100000;
2488 V_VT(&vDst) = VT_I4;
2490 hres = pVarMod(&v1,&v2,&vDst);
2491 ok(hres == DISP_E_TYPEMISMATCH && V_VT(&vDst) == VT_EMPTY && V_I4(&vDst) == 1231,
2492 "VarMod: expected 0x%lx,%d,%d, got 0x%lX,%d,%ld\n", DISP_E_TYPEMISMATCH, VT_EMPTY, 1231, hres, V_VT(&vDst), V_I4(&vDst));
2495 /* test some invalid types */
2496 /*TODO: not testing VT_DISPATCH */
2497 if (HAVE_OLEAUT32_I8)
2499 VARMOD2(I8,INT,100,10,EMPTY,0,DISP_E_TYPEMISMATCH);
2501 VARMOD2(ERROR,I4,100,10,EMPTY,0,DISP_E_TYPEMISMATCH);
2502 VARMOD2(VARIANT,I4,100,10,EMPTY,0,DISP_E_TYPEMISMATCH);
2503 VARMOD2(UNKNOWN,I4,100,10,EMPTY,0,DISP_E_TYPEMISMATCH);
2504 VARMOD2(VOID,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2505 VARMOD2(HRESULT,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2506 VARMOD2(PTR,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2507 VARMOD2(SAFEARRAY,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2508 VARMOD2(CARRAY,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2509 VARMOD2(USERDEFINED,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2510 VARMOD2(LPSTR,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2511 VARMOD2(LPWSTR,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2512 VARMOD2(RECORD,I4,100,10,EMPTY,0,DISP_E_TYPEMISMATCH);
2513 VARMOD2(FILETIME,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2514 VARMOD2(BLOB,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2515 VARMOD2(STREAM,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2516 VARMOD2(STORAGE,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2517 VARMOD2(STREAMED_OBJECT,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2518 VARMOD2(STORED_OBJECT,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2519 VARMOD2(BLOB_OBJECT,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2520 VARMOD2(CF,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2521 VARMOD2(CLSID,CLSID,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2522 VARMOD2(VECTOR,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2523 VARMOD2(ARRAY,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2524 VARMOD2(BYREF,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2526 /* test some more invalid types */
2531 hres = pVarMod(&v1,&v2,&vDst);
2532 ok(hres == DISP_E_BADVARTYPE && V_VT(&vDst) == VT_EMPTY && V_I4(&vDst) == 0,
2533 "VarMod: expected 0x%lx,%d,%d, got 0x%lX,%d,%ld\n", DISP_E_BADVARTYPE, VT_EMPTY, 0, hres, V_VT(&vDst), V_I4(&vDst));
2536 static HRESULT (WINAPI *pVarFix)(LPVARIANT,LPVARIANT);
2538 static const char *szVarFixFail = "VarFix: expected 0x0,%d,%d, got 0x%lX,%d,%d\n";
2539 #define VARFIX(vt,val,rvt,rval) V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
2540 memset(&vDst,0,sizeof(vDst)); hres = pVarFix(&v,&vDst); \
2541 ok(hres == S_OK && V_VT(&vDst) == VT_##rvt && V_##rvt(&vDst) == (rval), \
2542 szVarFixFail, VT_##rvt, (int)(rval), \
2543 hres, V_VT(&vDst), (int)V_##rvt(&vDst))
2545 static void test_VarFix(void)
2547 static const WCHAR szNumMinus1[] = {'-','1','\0' };
2550 DECIMAL *pdec = &V_DECIMAL(&v);
2551 CY *pcy = &V_CY(&v);
2556 /* Test all possible V_VT values */
2557 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
2561 for (vt = 0; vt <= VT_BSTR_BLOB; vt++)
2563 HRESULT bFail = TRUE;
2567 memset(&v, 0, sizeof(v));
2568 V_VT(&v) = vt | ExtraFlags[i];
2569 V_VT(&vDst) = VT_EMPTY;
2573 case VT_UI1: case VT_I2: case VT_I4: case VT_R4: case VT_R8:
2574 case VT_DECIMAL: case VT_BOOL: case VT_NULL: case VT_EMPTY:
2575 case VT_DATE: case VT_CY:
2579 if (HAVE_OLEAUT32_I8)
2584 hres = pVarFix(&v,&vDst);
2586 ok(hres == DISP_E_TYPEMISMATCH || hres == DISP_E_BADVARTYPE,
2587 "VarFix: expected failure, got 0x%lX vt %d|0x%X\n",
2588 hres, vt, ExtraFlags[i]);
2590 ok(hres == S_OK, "VarFix: expected S_OK, got 0x%lX vt %d|0x%X\n",
2591 hres, vt, ExtraFlags[i]);
2595 VARFIX(BOOL,VARIANT_TRUE,I2,VARIANT_TRUE);
2596 VARFIX(BOOL,VARIANT_FALSE,I2,0);
2597 VARFIX(BOOL,1,I2,1);
2598 VARFIX(UI1,1,UI1,1);
2599 VARFIX(I2,-1,I2,-1);
2600 VARFIX(I4,-1,I4,-1);
2601 if (HAVE_OLEAUT32_I8)
2603 VARFIX(I8,-1,I8,-1);
2605 VARFIX(R4,1.4,R4,1);
2606 VARFIX(R4,1.5,R4,1);
2607 VARFIX(R4,1.6,R4,1);
2608 VARFIX(R4,-1.4,R4,-1);
2609 VARFIX(R4,-1.5,R4,-1);
2610 VARFIX(R4,-1.6,R4,-1);
2611 /* DATE & R8 round as for R4 */
2612 VARFIX(DATE,-1,DATE,-1);
2613 VARFIX(R8,-1,R8,-1);
2614 VARFIX(BSTR,(BSTR)szNumMinus1,R8,-1);
2616 V_VT(&v) = VT_EMPTY;
2617 hres = pVarFix(&v,&vDst);
2618 ok(hres == S_OK && V_VT(&vDst) == VT_I2 && V_I2(&vDst) == 0,
2619 "VarFix: expected 0x0,%d,0 got 0x%lX,%d,%d\n", VT_EMPTY,
2620 hres, V_VT(&vDst), V_I2(&vDst));
2623 hres = pVarFix(&v,&vDst);
2624 ok(hres == S_OK && V_VT(&vDst) == VT_NULL,
2625 "VarFix: expected 0x0,%d got 0x%lX,%d\n", VT_NULL, hres, V_VT(&vDst));
2627 V_VT(&v) = VT_DECIMAL;
2628 S(U(*pdec)).sign = DECIMAL_NEG;
2629 S(U(*pdec)).scale = 0;
2631 S1(U1(*pdec)).Mid32 = 0;
2632 S1(U1(*pdec)).Lo32 = 1;
2633 hres = pVarFix(&v,&vDst);
2634 ok(hres == S_OK && V_VT(&vDst) == VT_DECIMAL && !memcmp(&v, &vDst, sizeof(v)),
2635 "VarFix: expected 0x0,%d,identical, got 0x%lX,%d\n", VT_DECIMAL,
2638 /* FIXME: Test some fractional decimals when VarDecFix is implemented */
2641 pcy->int64 = -10000;
2642 hres = pVarFix(&v,&vDst);
2643 ok(hres == S_OK && V_VT(&vDst) == VT_CY && V_CY(&vDst).int64 == -10000,
2644 "VarFix: VT_CY wrong, hres=0x%lX\n", hres);
2647 pcy->int64 = -16000;
2648 hres = pVarFix(&v,&vDst);
2649 ok(hres == S_OK && V_VT(&vDst) == VT_CY && V_CY(&vDst).int64 == -10000,
2650 "VarFix: VT_CY wrong, hres=0x%lX\n", hres);
2653 static HRESULT (WINAPI *pVarInt)(LPVARIANT,LPVARIANT);
2655 static const char *szVarIntFail = "VarInt: expected 0x0,%d,%d, got 0x%lX,%d,%d\n";
2656 #define VARINT(vt,val,rvt,rval) V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
2657 memset(&vDst,0,sizeof(vDst)); hres = pVarInt(&v,&vDst); \
2658 ok(hres == S_OK && V_VT(&vDst) == VT_##rvt && V_##rvt(&vDst) == (rval), \
2659 szVarIntFail, VT_##rvt, (int)(rval), \
2660 hres, V_VT(&vDst), (int)V_##rvt(&vDst))
2662 static void test_VarInt(void)
2664 static const WCHAR szNumMinus1[] = {'-','1','\0' };
2667 DECIMAL *pdec = &V_DECIMAL(&v);
2668 CY *pcy = &V_CY(&v);
2673 /* Test all possible V_VT values */
2674 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
2678 for (vt = 0; vt <= VT_BSTR_BLOB; vt++)
2680 HRESULT bFail = TRUE;
2684 memset(&v, 0, sizeof(v));
2685 V_VT(&v) = vt | ExtraFlags[i];
2686 V_VT(&vDst) = VT_EMPTY;
2690 case VT_UI1: case VT_I2: case VT_I4: case VT_R4: case VT_R8:
2691 case VT_DECIMAL: case VT_BOOL: case VT_NULL: case VT_EMPTY:
2692 case VT_DATE: case VT_CY:
2696 if (HAVE_OLEAUT32_I8)
2701 hres = pVarInt(&v,&vDst);
2703 ok(hres == DISP_E_TYPEMISMATCH || hres == DISP_E_BADVARTYPE,
2704 "VarInt: expected failure, got 0x%lX vt %d|0x%X\n",
2705 hres, vt, ExtraFlags[i]);
2707 ok(hres == S_OK, "VarInt: expected S_OK, got 0x%lX vt %d|0x%X\n",
2708 hres, vt, ExtraFlags[i]);
2712 VARINT(BOOL,VARIANT_TRUE,I2,VARIANT_TRUE);
2713 VARINT(BOOL,VARIANT_FALSE,I2,0);
2714 VARINT(BOOL,1,I2,1);
2715 VARINT(UI1,1,UI1,1);
2716 VARINT(I2,-1,I2,-1);
2717 VARINT(I4,-1,I4,-1);
2718 if (HAVE_OLEAUT32_I8)
2720 VARINT(I8,-1,I8,-1);
2722 VARINT(R4,1.4,R4,1);
2723 VARINT(R4,1.5,R4,1);
2724 VARINT(R4,1.6,R4,1);
2725 VARINT(R4,-1.4,R4,-2); /* Note these 3 are different from VarFix */
2726 VARINT(R4,-1.5,R4,-2);
2727 VARINT(R4,-1.6,R4,-2);
2728 /* DATE & R8 round as for R4 */
2729 VARINT(DATE,-1,DATE,-1);
2730 VARINT(R8,-1,R8,-1);
2731 VARINT(BSTR,(BSTR)szNumMinus1,R8,-1);
2733 V_VT(&v) = VT_EMPTY;
2734 hres = pVarInt(&v,&vDst);
2735 ok(hres == S_OK && V_VT(&vDst) == VT_I2 && V_I2(&vDst) == 0,
2736 "VarInt: expected 0x0,%d,0 got 0x%lX,%d,%d\n", VT_EMPTY,
2737 hres, V_VT(&vDst), V_I2(&vDst));
2740 hres = pVarInt(&v,&vDst);
2741 ok(hres == S_OK && V_VT(&vDst) == VT_NULL,
2742 "VarInt: expected 0x0,%d got 0x%lX,%d\n", VT_NULL, hres, V_VT(&vDst));
2744 V_VT(&v) = VT_DECIMAL;
2745 S(U(*pdec)).sign = DECIMAL_NEG;
2746 S(U(*pdec)).scale = 0;
2748 S1(U1(*pdec)).Mid32 = 0;
2749 S1(U1(*pdec)).Lo32 = 1;
2750 hres = pVarInt(&v,&vDst);
2751 ok(hres == S_OK && V_VT(&vDst) == VT_DECIMAL && !memcmp(&v, &vDst, sizeof(v)),
2752 "VarInt: expected 0x0,%d,identical, got 0x%lX,%d\n", VT_DECIMAL,
2755 /* FIXME: Test some fractional decimals when VarDecInt is implemented */
2758 pcy->int64 = -10000;
2759 hres = pVarInt(&v,&vDst);
2760 ok(hres == S_OK && V_VT(&vDst) == VT_CY && V_CY(&vDst).int64 == -10000,
2761 "VarInt: VT_CY wrong, hres=0x%lX\n", hres);
2764 pcy->int64 = -11000;
2765 hres = pVarInt(&v,&vDst);
2766 ok(hres == S_OK && V_VT(&vDst) == VT_CY && V_CY(&vDst).int64 == -20000,
2767 "VarInt: VT_CY wrong, hres=0x%lX %lld\n", hres,V_CY(&vDst).int64);
2770 static HRESULT (WINAPI *pVarNeg)(LPVARIANT,LPVARIANT);
2772 static const char *szVarNegFail = "VarNeg: expected 0x0,%d,%d, got 0x%lX,%d,%d\n";
2773 #define VARNEG(vt,val,rvt,rval) V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
2774 memset(&vDst,0,sizeof(vDst)); hres = pVarNeg(&v,&vDst); \
2775 ok(hres == S_OK && V_VT(&vDst) == VT_##rvt && V_##rvt(&vDst) == (rval), \
2776 szVarNegFail, VT_##rvt, (int)(rval), \
2777 hres, V_VT(&vDst), (int)V_##rvt(&vDst))
2779 static void test_VarNeg(void)
2781 static const WCHAR szNumMinus1[] = {'-','1','\0' };
2782 static const WCHAR szNum1[] = {'1','\0' };
2785 DECIMAL *pdec = &V_DECIMAL(&v);
2786 CY *pcy = &V_CY(&v);
2791 /* Test all possible V_VT values. But don't test the exact return values
2792 * except for success/failure, since M$ made a hash of them in the
2793 * native version. This at least ensures (as with all tests here) that
2794 * we will notice if/when new vtypes/flags are added in native.
2796 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
2800 for (vt = 0; vt <= VT_BSTR_BLOB; vt++)
2802 HRESULT bFail = TRUE;
2806 memset(&v, 0, sizeof(v));
2807 V_VT(&v) = vt | ExtraFlags[i];
2808 V_VT(&vDst) = VT_EMPTY;
2812 case VT_UI1: case VT_I2: case VT_I4:
2813 case VT_R4: case VT_R8:
2814 case VT_DECIMAL: case VT_BOOL: case VT_NULL: case VT_EMPTY:
2815 case VT_DATE: case VT_CY:
2819 if (HAVE_OLEAUT32_I8)
2823 hres = pVarNeg(&v,&vDst);
2825 ok(hres == DISP_E_TYPEMISMATCH || hres == DISP_E_BADVARTYPE,
2826 "VarNeg: expected failure, got 0x%lX vt %d|0x%X\n",
2827 hres, vt, ExtraFlags[i]);
2829 ok(hres == S_OK, "VarNeg: expected S_OK, got 0x%lX vt %d|0x%X\n",
2830 hres, vt, ExtraFlags[i]);
2834 VARNEG(BOOL,VARIANT_TRUE,I2,1);
2835 VARNEG(BOOL,VARIANT_FALSE,I2,0);
2836 VARNEG(BOOL,1,I2,-1);
2837 VARNEG(UI1,1,I2,-1);
2838 VARNEG(UI1,254,I2,-254);
2839 VARNEG(I2,-32768,I4,32768);
2842 VARNEG(I4,-((int)(~0u >> 1)) - 1,R8,-2147483648u);
2845 if (HAVE_OLEAUT32_I8)
2852 VARNEG(DATE,1,DATE,-1);
2853 VARNEG(DATE,-1,DATE,1);
2856 VARNEG(BSTR,(BSTR)szNumMinus1,R8,1);
2857 VARNEG(BSTR,(BSTR)szNum1,R8,-1);
2859 V_VT(&v) = VT_EMPTY;
2860 hres = pVarNeg(&v,&vDst);
2861 ok(hres == S_OK && V_VT(&vDst) == VT_I2 && V_I2(&vDst) == 0,
2862 "VarNeg: expected 0x0,%d,0 got 0x%lX,%d,%d\n", VT_EMPTY,
2863 hres, V_VT(&vDst), V_I2(&vDst));
2866 hres = pVarNeg(&v,&vDst);
2867 ok(hres == S_OK && V_VT(&vDst) == VT_NULL,
2868 "VarNeg: expected 0x0,%d got 0x%lX,%d\n", VT_NULL, hres, V_VT(&vDst));
2870 V_VT(&v) = VT_DECIMAL;
2871 S(U(*pdec)).sign = DECIMAL_NEG;
2872 S(U(*pdec)).scale = 0;
2874 S1(U1(*pdec)).Mid32 = 0;
2875 S1(U1(*pdec)).Lo32 = 1;
2876 hres = pVarNeg(&v,&vDst);
2877 ok(hres == S_OK && V_VT(&vDst) == VT_DECIMAL &&
2878 S(U(V_DECIMAL(&vDst))).sign == 0,
2879 "VarNeg: expected 0x0,%d,0x00, got 0x%lX,%d,%02x\n", VT_DECIMAL,
2880 hres, V_VT(&vDst), S(U(V_DECIMAL(&vDst))).sign);
2882 S(U(*pdec)).sign = 0;
2883 hres = pVarNeg(&v,&vDst);
2884 ok(hres == S_OK && V_VT(&vDst) == VT_DECIMAL &&
2885 S(U(V_DECIMAL(&vDst))).sign == DECIMAL_NEG,
2886 "VarNeg: expected 0x0,%d,0x7f, got 0x%lX,%d,%02x\n", VT_DECIMAL,
2887 hres, V_VT(&vDst), S(U(V_DECIMAL(&vDst))).sign);
2890 pcy->int64 = -10000;
2891 hres = pVarNeg(&v,&vDst);
2892 ok(hres == S_OK && V_VT(&vDst) == VT_CY && V_CY(&vDst).int64 == 10000,
2893 "VarNeg: VT_CY wrong, hres=0x%lX\n", hres);
2896 static HRESULT (WINAPI *pVarRound)(LPVARIANT,int,LPVARIANT);
2898 #define VARROUND(vt,val,deci,rvt,rval) V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
2899 memset(&vDst,0,sizeof(vDst)); hres = pVarRound(&v,deci,&vDst); \
2900 ok(hres == S_OK && V_VT(&vDst) == VT_##rvt && V_##rvt(&vDst) == (rval), \
2901 "VarRound: expected 0x0,%d,%d, got 0x%lX,%d,%d\n", VT_##rvt, (int)(rval), \
2902 hres, V_VT(&vDst), (int)V_##rvt(&vDst))
2904 #define VARROUNDF(vt,val,deci,rvt,rval) V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
2905 memset(&vDst,0,sizeof(vDst)); hres = pVarRound(&v,deci,&vDst); \
2906 ok(hres == S_OK && V_VT(&vDst) == VT_##rvt && V_##rvt(&vDst) == (rval), \
2907 "VarRound: expected 0x0,%d,%f, got 0x%lX,%d,%f\n", VT_##rvt, rval, \
2908 hres, V_VT(&vDst), V_##rvt(&vDst))
2910 static void test_VarRound(void)
2912 /* static const WCHAR szNumMin[] = {'-','1','.','4','5','\0' };
2913 static const WCHAR szNum[] = {'1','.','4','5','\0' }; */
2916 CY *pcy = &V_CY(&v);
2920 /* first check valid integer types */
2921 VARROUND(BOOL,VARIANT_TRUE,0,I2,-1);
2922 VARROUND(BOOL,VARIANT_FALSE,0,I2,0);
2923 VARROUND(BOOL,1,0,I2,1);
2924 VARROUND(UI1,1,0,UI1,1);
2925 VARROUND(UI1,254,0,UI1,254);
2926 VARROUND(I2,-32768,0,I2,-32768);
2927 VARROUND(I2,-1,0,I2,-1);
2928 VARROUND(I2,1,0,I2,1);
2929 VARROUND(I4,-((int)(~0u >> 1)) - 1,0,I4,-((int)(~0u >> 1)) - 1);
2930 VARROUND(I4,-1,0,I4,-1);
2931 VARROUND(I4,1,0,I4,1);
2934 /* MSDN states that rounding of R4/R8 is dependent on the underlying
2935 * bit pattern of the number and so is architecture dependent. In this
2936 * case Wine returns .2 (which is more correct) and Native returns .3
2939 VARROUNDF(R4,1.0,0,R4,1.0);
2940 VARROUNDF(R4,-1.0,0,R4,-1.0);
2941 VARROUNDF(R8,1.0,0,R8,1.0);
2942 VARROUNDF(R8,-1.0,0,R8,-1.0);
2944 /* floating point numbers aren't exactly equal and we can't just
2945 * compare the first few digits.
2947 VARROUNDF(DATE,1.451,1,DATE,1.5);
2948 VARROUNDF(DATE,-1.45,1,DATE,-1.4);
2949 VARROUNDF(BSTR,(BSTR)szNumMin,1,R8,-1.40);
2950 VARROUNDF(BSTR,(BSTR)szNum,1,R8,1.50);
2952 VARROUNDF(R4,1.23456,0,R4,1.0);
2953 VARROUNDF(R4,1.23456,1,R4,1.2);
2954 VARROUNDF(R4,1.23456,2,R4,1.23);
2955 VARROUNDF(R4,1.23456,3,R4,1.235);
2956 VARROUNDF(R4,1.23456,4,R4,1.2346);
2957 VARROUNDF(R4,-1.23456,0,R4,-1.0);
2958 VARROUNDF(R4,-1.23456,1,R4,-1.2);
2959 VARROUNDF(R4,-1.23456,2,R4,-1.23);
2960 VARROUNDF(R4,-1.23456,3,R4,-1.235);
2961 VARROUNDF(R4,-1.23456,4,R4,-1.2346);
2963 VARROUNDF(R8,1.23456,0,R8,1.0);
2964 VARROUNDF(R8,1.23456,1,R8,1.2);
2965 VARROUNDF(R8,1.23456,2,R8,1.23);
2966 VARROUNDF(R8,1.23456,3,R8,1.235);
2967 VARROUNDF(R8,1.23456,4,R8,1.2346);
2968 VARROUNDF(R8,-1.23456,0,R8,-1.0);
2969 VARROUNDF(R8,-1.23456,1,R8,-1.2);
2970 VARROUNDF(R8,-1.23456,2,R8,-1.23);
2971 VARROUNDF(R8,-1.23456,3,R8,-1.235);
2972 VARROUNDF(R8,-1.23456,4,R8,-1.2346);
2976 V_VT(&v) = VT_EMPTY;
2977 hres = pVarRound(&v,0,&vDst);
2978 ok(hres == S_OK && V_VT(&vDst) == VT_I2 && V_I2(&vDst) == 0,
2979 "VarRound: expected 0x0,%d,0 got 0x%lX,%d,%d\n", VT_EMPTY,
2980 hres, V_VT(&vDst), V_I2(&vDst));
2983 hres = pVarRound(&v,0,&vDst);
2984 ok(hres == S_OK && V_VT(&vDst) == VT_NULL,
2985 "VarRound: expected 0x0,%d got 0x%lX,%d\n", VT_NULL, hres, V_VT(&vDst));
2987 /* not yet implemented so no use testing yet
2989 DECIMAL *pdec = &V_DECIMAL(&v);
2990 V_VT(&v) = VT_DECIMAL;
2991 S(U(*pdec)).sign = DECIMAL_NEG;
2992 S(U(*pdec)).scale = 0;
2994 S1(U1(*pdec)).Mid32 = 0;
2995 S1(U1(*pdec)).Lo32 = 1;
2996 hres = pVarRound(&v,0,&vDst);
2997 ok(hres == S_OK && V_VT(&vDst) == VT_DECIMAL &&
2998 S(U(V_DECIMAL(&vDst))).sign == 0,
2999 "VarRound: expected 0x0,%d,0x00, got 0x%lX,%d,%02x\n", VT_DECIMAL,
3000 hres, V_VT(&vDst), S(U(V_DECIMAL(&vDst))).sign);
3002 S(U(*pdec)).sign = 0;
3003 hres = pVarRound(&v,0,&vDst);
3004 ok(hres == S_OK && V_VT(&vDst) == VT_DECIMAL &&
3005 S(U(V_DECIMAL(&vDst))).sign == DECIMAL_NEG,
3006 "VarRound: expected 0x0,%d,0x7f, got 0x%lX,%d,%02x\n", VT_DECIMAL,
3007 hres, V_VT(&vDst), S(U(V_DECIMAL(&vDst))).sign);
3013 hres = pVarRound(&v,0,&vDst);
3014 ok(hres == S_OK && V_VT(&vDst) == VT_CY && V_CY(&vDst).int64 == 10000,
3015 "VarRound: VT_CY wrong, hres=0x%lX\n", hres);
3019 static HRESULT (WINAPI *pVarXor)(LPVARIANT,LPVARIANT,LPVARIANT);
3021 static const char *szVarXorFail = "VarXor(%d,%d): expected 0x0,%d,%d, got 0x%lX,%d,%d\n";
3022 #define VARXOR(vt1,val1,vt2,val2,rvt,rval) \
3023 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
3024 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
3025 memset(&result,0,sizeof(result)); hres = pVarXor(&left,&right,&result); \
3026 ok(hres == S_OK && V_VT(&result) == VT_##rvt && V_##rvt(&result) == (rval), \
3027 szVarXorFail, VT_##vt1, VT_##vt2, \
3028 VT_##rvt, (int)(rval), hres, V_VT(&result), (int)V_##rvt(&result)); \
3029 ok(V_VT(&left) == VT_##vt1 && V_##vt1(&left) == val1 && \
3030 V_VT(&right) == VT_##vt2 && V_##vt2(&right) == val2, \
3031 "VarXor(%d,%d): Modified input arguments\n",VT_##vt1,VT_##vt2)
3032 #define VARXORCY(vt1,val1,val2,rvt,rval) \
3033 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
3034 V_VT(&right) = VT_CY; V_CY(&right).int64 = val2; \
3035 memset(&result,0,sizeof(result)); hres = pVarXor(&left,&right,&result); \
3036 ok(hres == S_OK && V_VT(&result) == VT_##rvt && V_##rvt(&result) == (rval), \
3037 "VarXor(%d,%d): expected 0x0,%d,%d, got 0x%lX,%d,%d\n", VT_##vt1, VT_CY, \
3038 VT_##rvt, (int)(rval), hres, V_VT(&result), (int)V_##rvt(&result)); \
3039 ok(V_VT(&left) == VT_##vt1 && V_##vt1(&left) == val1 && \
3040 V_VT(&right) == VT_CY && V_CY(&right).int64 == val2, \
3041 "VarXor(%d,%d): Modified input arguments\n",VT_##vt1,VT_CY)
3043 static void test_VarXor(void)
3045 static const WCHAR szFalse[] = { '#','F','A','L','S','E','#','\0' };
3046 static const WCHAR szTrue[] = { '#','T','R','U','E','#','\0' };
3047 VARIANT left, right, result;
3054 /* Test all possible flag/vt combinations & the resulting vt type */
3055 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
3057 VARTYPE leftvt, rightvt, resvt;
3059 for (leftvt = 0; leftvt <= VT_BSTR_BLOB; leftvt++)
3064 for (rightvt = 0; rightvt <= VT_BSTR_BLOB; rightvt++)
3070 if (leftvt == VT_BSTR || rightvt == VT_BSTR ||
3071 leftvt == VT_DISPATCH || rightvt == VT_DISPATCH ||
3072 leftvt == VT_UNKNOWN || rightvt == VT_UNKNOWN)
3075 memset(&left, 0, sizeof(left));
3076 memset(&right, 0, sizeof(right));
3077 V_VT(&left) = leftvt | ExtraFlags[i];
3078 V_VT(&right) = rightvt | ExtraFlags[i];
3079 V_VT(&result) = VT_EMPTY;
3082 if (ExtraFlags[i] & VT_ARRAY || ExtraFlags[i] & VT_BYREF ||
3083 !IsValidVariantClearVT(leftvt, ExtraFlags[i]) ||
3084 !IsValidVariantClearVT(rightvt, ExtraFlags[i]) ||
3085 leftvt == VT_CLSID || rightvt == VT_CLSID ||
3086 leftvt == VT_RECORD || rightvt == VT_RECORD ||
3087 leftvt == VT_VARIANT || rightvt == VT_VARIANT ||
3088 leftvt == VT_ERROR || rightvt == VT_ERROR)
3092 if (leftvt == VT_EMPTY || rightvt == VT_EMPTY)
3094 if (leftvt == rightvt ||
3095 leftvt == VT_I2 || rightvt == VT_I2 ||
3096 leftvt == VT_UI1 || rightvt == VT_UI1 ||
3097 leftvt == VT_BOOL || rightvt == VT_BOOL)
3099 else if (leftvt == VT_NULL || rightvt == VT_NULL)
3101 else if (leftvt == VT_I8 || rightvt == VT_I8)
3104 else if (leftvt == VT_NULL || rightvt == VT_NULL)
3108 else if (leftvt == VT_UI1 || rightvt == VT_UI1)
3110 if (leftvt == rightvt)
3112 else if (leftvt == rightvt ||
3113 leftvt == VT_I2 || rightvt == VT_I2 ||
3114 leftvt == VT_BOOL || rightvt == VT_BOOL)
3118 else if (leftvt == VT_I8 || rightvt == VT_I8)
3121 else if (leftvt == VT_I2 || rightvt == VT_I2)
3123 if (leftvt == rightvt ||
3124 leftvt == VT_BOOL || rightvt == VT_BOOL)
3126 else if (leftvt == VT_I8 || rightvt == VT_I8)
3129 else if (leftvt == VT_BOOL && rightvt == VT_BOOL)
3133 else if (leftvt == VT_I8 || rightvt == VT_I8)
3135 if (leftvt == VT_INT || rightvt == VT_INT)
3140 hres = pVarXor(&left, &right, &result);
3142 ok(hres == DISP_E_TYPEMISMATCH || hres == DISP_E_BADVARTYPE,
3143 "VarXor: %d|0x%X, %d|0x%X: Expected failure, got 0x%lX vt %d\n",
3144 leftvt, ExtraFlags[i], rightvt, ExtraFlags[i], hres,
3147 ok(hres == S_OK && V_VT(&result) == resvt,
3148 "VarXor: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%lX vt %d\n",
3149 leftvt, ExtraFlags[i], rightvt, ExtraFlags[i], resvt, hres,
3155 /* Test returned values
3156 * FIXME: Test VT_DECIMAL/VT_DISPATCH
3158 VARXOR(EMPTY,0,EMPTY,0,I2,0);
3159 VARXOR(EMPTY,1,EMPTY,0,I2,0);
3160 VARXOR(EMPTY,0,NULL,0,NULL,0);
3161 VARXOR(EMPTY,0,I1,0,I4,0);
3162 VARXOR(EMPTY,0,I1,1,I4,1);
3163 VARXOR(EMPTY,0,UI1,0,I2,0);
3164 VARXOR(EMPTY,0,UI1,1,I2,1);
3165 VARXOR(EMPTY,0,I2,0,I2,0);
3166 VARXOR(EMPTY,0,I2,1,I2,1);
3167 VARXOR(EMPTY,0,UI2,0,I4,0);
3168 VARXOR(EMPTY,0,UI2,1,I4,1);
3169 VARXOR(EMPTY,0,I4,0,I4,0);
3170 VARXOR(EMPTY,0,I4,1,I4,1);
3171 VARXOR(EMPTY,0,UI4,0,I4,0);
3172 VARXOR(EMPTY,0,UI4,1,I4,1);
3173 if (HAVE_OLEAUT32_I8)
3175 VARXOR(EMPTY,0,I8,0,I8,0);
3176 VARXOR(EMPTY,0,I8,1,I8,1);
3177 VARXOR(EMPTY,0,UI8,0,I4,0);
3178 VARXOR(EMPTY,0,UI8,1,I4,1);
3180 VARXOR(EMPTY,0,INT,0,I4,0);
3181 VARXOR(EMPTY,0,INT,1,I4,1);
3182 VARXOR(EMPTY,0,UINT,0,I4,0);
3183 VARXOR(EMPTY,0,UINT,1,I4,1);
3184 VARXOR(EMPTY,0,BOOL,0,I2,0);
3185 VARXOR(EMPTY,0,BOOL,1,I2,1);
3186 VARXOR(EMPTY,0,R4,0,I4,0);
3187 VARXOR(EMPTY,0,R4,1,I4,1);
3188 VARXOR(EMPTY,0,R8,0,I4,0);
3189 VARXOR(EMPTY,0,R8,1,I4,1);
3190 rbstr = SysAllocString(szFalse);
3191 VARXOR(EMPTY,0,BSTR,rbstr,I2,0);
3192 rbstr = SysAllocString(szTrue);
3193 VARXOR(EMPTY,0,BSTR,rbstr,I2,-1);
3194 VARXORCY(EMPTY,0,10000,I4,1);
3196 /* NULL OR 0 = NULL. NULL OR n = n */
3197 VARXOR(NULL,0,NULL,0,NULL,0);
3198 VARXOR(NULL,1,NULL,0,NULL,0);
3199 VARXOR(NULL,0,I1,0,NULL,0);
3200 VARXOR(NULL,0,I1,1,NULL,0);
3201 VARXOR(NULL,0,UI1,0,NULL,0);
3202 VARXOR(NULL,0,UI1,1,NULL,0);
3203 VARXOR(NULL,0,I2,0,NULL,0);
3204 VARXOR(NULL,0,I2,1,NULL,0);
3205 VARXOR(NULL,0,UI2,0,NULL,0);
3206 VARXOR(NULL,0,UI2,1,NULL,0);
3207 VARXOR(NULL,0,I4,0,NULL,0);
3208 VARXOR(NULL,0,I4,1,NULL,0);
3209 VARXOR(NULL,0,UI4,0,NULL,0);
3210 VARXOR(NULL,0,UI4,1,NULL,0);
3211 if (HAVE_OLEAUT32_I8)
3213 VARXOR(NULL,0,I8,0,NULL,0);
3214 VARXOR(NULL,0,I8,1,NULL,0);
3215 VARXOR(NULL,0,UI8,0,NULL,0);
3216 VARXOR(NULL,0,UI8,1,NULL,0);
3218 VARXOR(NULL,0,INT,0,NULL,0);
3219 VARXOR(NULL,0,INT,1,NULL,0);
3220 VARXOR(NULL,0,UINT,0,NULL,0);
3221 VARXOR(NULL,0,UINT,1,NULL,0);
3222 VARXOR(NULL,0,BOOL,0,NULL,0);
3223 VARXOR(NULL,0,BOOL,1,NULL,0);
3224 VARXOR(NULL,0,R4,0,NULL,0);
3225 VARXOR(NULL,0,R4,1,NULL,0);
3226 VARXOR(NULL,0,R8,0,NULL,0);
3227 VARXOR(NULL,0,R8,1,NULL,0);
3228 rbstr = SysAllocString(szFalse);
3229 VARXOR(NULL,0,BSTR,rbstr,NULL,0);
3230 rbstr = SysAllocString(szTrue);
3231 VARXOR(NULL,0,BSTR,rbstr,NULL,0);
3232 VARXORCY(NULL,0,10000,NULL,0);
3233 VARXORCY(NULL,0,0,NULL,0);
3235 VARXOR(BOOL,VARIANT_TRUE,BOOL,VARIANT_TRUE,BOOL,VARIANT_FALSE);
3236 VARXOR(BOOL,VARIANT_TRUE,BOOL,VARIANT_FALSE,BOOL,VARIANT_TRUE);
3237 VARXOR(BOOL,VARIANT_FALSE,BOOL,VARIANT_TRUE,BOOL,VARIANT_TRUE);
3238 VARXOR(BOOL,VARIANT_FALSE,BOOL,VARIANT_FALSE,BOOL,VARIANT_FALSE);
3239 /* Assume x,y & y,x are the same from now on to reduce the number of tests */
3240 VARXOR(BOOL,VARIANT_TRUE,I1,-1,I4,0);
3241 VARXOR(BOOL,VARIANT_TRUE,I1,0,I4,-1);
3242 VARXOR(BOOL,VARIANT_FALSE,I1,0,I4,0);
3243 VARXOR(BOOL,VARIANT_TRUE,UI1,255,I2,-256);
3244 VARXOR(BOOL,VARIANT_TRUE,UI1,0,I2,-1);
3245 VARXOR(BOOL,VARIANT_FALSE,UI1,0,I2,0);
3246 VARXOR(BOOL,VARIANT_TRUE,I2,-1,I2,0);
3247 VARXOR(BOOL,VARIANT_TRUE,I2,0,I2,-1);
3248 VARXOR(BOOL,VARIANT_FALSE,I2,0,I2,0);
3249 VARXOR(BOOL,VARIANT_TRUE,UI2,65535,I4,-65536);
3250 VARXOR(BOOL,VARIANT_TRUE,UI2,0,I4,-1);
3251 VARXOR(BOOL,VARIANT_FALSE,UI2,0,I4,0);
3252 VARXOR(BOOL,VARIANT_TRUE,I4,-1,I4,0);
3253 VARXOR(BOOL,VARIANT_TRUE,I4,0,I4,-1);
3254 VARXOR(BOOL,VARIANT_FALSE,I4,0,I4,0);
3255 VARXOR(BOOL,VARIANT_TRUE,UI4,0xffffffff,I4,0);
3256 VARXOR(BOOL,VARIANT_TRUE,UI4,0,I4,-1);
3257 VARXOR(BOOL,VARIANT_FALSE,UI4,0,I4,0);
3258 VARXOR(BOOL,VARIANT_TRUE,R4,-1,I4,0);
3259 VARXOR(BOOL,VARIANT_TRUE,R4,0,I4,-1);
3260 VARXOR(BOOL,VARIANT_FALSE,R4,0,I4,0);
3261 VARXOR(BOOL,VARIANT_TRUE,R8,-1,I4,0);
3262 VARXOR(BOOL,VARIANT_TRUE,R8,0,I4,-1);
3263 VARXOR(BOOL,VARIANT_FALSE,R8,0,I4,0);
3264 VARXOR(BOOL,VARIANT_TRUE,DATE,-1,I4,0);
3265 VARXOR(BOOL,VARIANT_TRUE,DATE,0,I4,-1);
3266 VARXOR(BOOL,VARIANT_FALSE,DATE,0,I4,0);
3267 if (HAVE_OLEAUT32_I8)
3269 VARXOR(BOOL,VARIANT_TRUE,I8,-1,I8,0);
3270 VARXOR(BOOL,VARIANT_TRUE,I8,0,I8,-1);
3271 VARXOR(BOOL,VARIANT_FALSE,I8,0,I8,0);
3272 /* This returns DISP_E_OVERFLOW which indicates that a conversion
3273 * to I4 is performed.
3275 /* VARXOR(BOOL,VARIANT_TRUE,UI8,-1,I4,-1); */
3276 VARXOR(BOOL,VARIANT_TRUE,UI8,0,I4,-1);
3277 VARXOR(BOOL,VARIANT_FALSE,UI8,0,I4,0);
3279 VARXOR(BOOL,VARIANT_TRUE,INT,-1,I4,0);
3280 VARXOR(BOOL,VARIANT_TRUE,INT,0,I4,-1);
3281 VARXOR(BOOL,VARIANT_FALSE,INT,0,I4,0);
3282 VARXOR(BOOL,VARIANT_TRUE,UINT,0xffffffff,I4,0);
3283 VARXOR(BOOL,VARIANT_TRUE,UINT,0,I4,-1);
3284 VARXOR(BOOL,VARIANT_FALSE,UINT,0,I4,0);
3285 rbstr = SysAllocString(szFalse);
3286 VARXOR(BOOL,VARIANT_FALSE,BSTR,rbstr,BOOL,VARIANT_FALSE);
3287 VARXOR(BOOL,VARIANT_TRUE,BSTR,rbstr,BOOL,VARIANT_TRUE);
3288 rbstr = SysAllocString(szTrue);
3289 VARXOR(BOOL,VARIANT_FALSE,BSTR,rbstr,BOOL,VARIANT_TRUE);
3290 VARXOR(BOOL,VARIANT_TRUE,BSTR,rbstr,BOOL,VARIANT_FALSE);
3291 VARXORCY(BOOL,VARIANT_TRUE,10000,I4,-2);
3292 VARXORCY(BOOL,VARIANT_TRUE,0,I4,-1);
3293 VARXORCY(BOOL,VARIANT_FALSE,0,I4,0);
3295 VARXOR(I1,-1,I1,-1,I4,0);
3296 VARXOR(I1,-1,I1,0,I4,-1);
3297 VARXOR(I1,0,I1,0,I4,0);
3298 VARXOR(I1,-1,UI1,255,I4,-256);
3299 VARXOR(I1,-1,UI1,0,I4,-1);
3300 VARXOR(I1,0,UI1,0,I4,0);
3301 VARXOR(I1,-1,I2,-1,I4,0);
3302 VARXOR(I1,-1,I2,0,I4,-1);
3303 VARXOR(I1,0,I2,0,I4,0);
3304 VARXOR(I1,-1,UI2,65535,I4,-65536);
3305 VARXOR(I1,-1,UI2,0,I4,-1);
3306 VARXOR(I1,0,UI2,0,I4,0);
3307 VARXOR(I1,-1,I4,-1,I4,0);
3308 VARXOR(I1,-1,I4,0,I4,-1);
3309 VARXOR(I1,0,I4,0,I4,0);
3310 VARXOR(I1,-1,UI4,0xffffffff,I4,0);
3311 VARXOR(I1,-1,UI4,0,I4,-1);
3312 VARXOR(I1,0,UI4,0,I4,0);
3313 VARXOR(I1,-1,R4,-1,I4,0);
3314 VARXOR(I1,-1,R4,0,I4,-1);
3315 VARXOR(I1,0,R4,0,I4,0);
3316 VARXOR(I1,-1,R8,-1,I4,0);
3317 VARXOR(I1,-1,R8,0,I4,-1);
3318 VARXOR(I1,0,R8,0,I4,0);
3319 VARXOR(I1,-1,DATE,-1,I4,0);
3320 VARXOR(I1,-1,DATE,0,I4,-1);
3321 VARXOR(I1,0,DATE,0,I4,0);
3322 if (HAVE_OLEAUT32_I8)
3324 VARXOR(I1,-1,I8,-1,I8,0);
3325 VARXOR(I1,-1,I8,0,I8,-1);
3326 VARXOR(I1,0,I8,0,I8,0);
3327 VARXOR(I1,-1,UI8,0,I4,-1);
3328 VARXOR(I1,0,UI8,0,I4,0);
3330 VARXOR(I1,-1,INT,-1,I4,0);
3331 VARXOR(I1,-1,INT,0,I4,-1);
3332 VARXOR(I1,0,INT,0,I4,0);
3333 VARXOR(I1,-1,UINT,0xffffffff,I4,0);
3334 VARXOR(I1,-1,UINT,0,I4,-1);
3335 VARXOR(I1,0,UINT,0,I4,0);
3336 rbstr = SysAllocString(szFalse);
3337 VARXOR(I1,0,BSTR,rbstr,I4,0);
3338 VARXOR(I1,-1,BSTR,rbstr,I4,-1);
3339 rbstr = SysAllocString(szTrue);
3340 VARXOR(I1,0,BSTR,rbstr,I4,-1);
3341 VARXOR(I1,-1,BSTR,rbstr,I4,0);
3342 VARXORCY(I1,-1,10000,I4,-2);
3343 VARXORCY(I1,-1,0,I4,-1);
3344 VARXORCY(I1,0,0,I4,0);
3346 VARXOR(UI1,255,UI1,255,UI1,0);
3347 VARXOR(UI1,255,UI1,0,UI1,255);
3348 VARXOR(UI1,0,UI1,0,UI1,0);
3349 VARXOR(UI1,255,I2,-1,I2,-256);
3350 VARXOR(UI1,255,I2,0,I2,255);
3351 VARXOR(UI1,0,I2,0,I2,0);
3352 VARXOR(UI1,255,UI2,65535,I4,65280);
3353 VARXOR(UI1,255,UI2,0,I4,255);
3354 VARXOR(UI1,0,UI2,0,I4,0);
3355 VARXOR(UI1,255,I4,-1,I4,-256);
3356 VARXOR(UI1,255,I4,0,I4,255);
3357 VARXOR(UI1,0,I4,0,I4,0);
3358 VARXOR(UI1,255,UI4,0xffffffff,I4,-256);
3359 VARXOR(UI1,255,UI4,0,I4,255);
3360 VARXOR(UI1,0,UI4,0,I4,0);
3361 VARXOR(UI1,255,R4,-1,I4,-256);
3362 VARXOR(UI1,255,R4,0,I4,255);
3363 VARXOR(UI1,0,R4,0,I4,0);
3364 VARXOR(UI1,255,R8,-1,I4,-256);
3365 VARXOR(UI1,255,R8,0,I4,255);
3366 VARXOR(UI1,0,R8,0,I4,0);
3367 VARXOR(UI1,255,DATE,-1,I4,-256);
3368 VARXOR(UI1,255,DATE,0,I4,255);
3369 VARXOR(UI1,0,DATE,0,I4,0);
3370 if (HAVE_OLEAUT32_I8)
3372 VARXOR(UI1,255,I8,-1,I8,-256);
3373 VARXOR(UI1,255,I8,0,I8,255);
3374 VARXOR(UI1,0,I8,0,I8,0);
3375 VARXOR(UI1,255,UI8,0,I4,255);
3376 VARXOR(UI1,0,UI8,0,I4,0);
3378 VARXOR(UI1,255,INT,-1,I4,-256);
3379 VARXOR(UI1,255,INT,0,I4,255);
3380 VARXOR(UI1,0,INT,0,I4,0);
3381 VARXOR(UI1,255,UINT,0xffffffff,I4,-256);
3382 VARXOR(UI1,255,UINT,0,I4,255);
3383 VARXOR(UI1,0,UINT,0,I4,0);
3384 rbstr = SysAllocString(szFalse);
3385 VARXOR(UI1,0,BSTR,rbstr,I2,0);
3386 VARXOR(UI1,255,BSTR,rbstr,I2,255);
3387 rbstr = SysAllocString(szTrue);
3388 VARXOR(UI1,0,BSTR,rbstr,I2,-1);
3389 VARXOR(UI1,255,BSTR,rbstr,I2,-256);
3390 VARXORCY(UI1,255,10000,I4,254);
3391 VARXORCY(UI1,255,0,I4,255);
3392 VARXORCY(UI1,0,0,I4,0);
3394 VARXOR(I2,-1,I2,-1,I2,0);
3395 VARXOR(I2,-1,I2,0,I2,-1);
3396 VARXOR(I2,0,I2,0,I2,0);
3397 VARXOR(I2,-1,UI2,65535,I4,-65536);
3398 VARXOR(I2,-1,UI2,0,I4,-1);
3399 VARXOR(I2,0,UI2,0,I4,0);
3400 VARXOR(I2,-1,I4,-1,I4,0);
3401 VARXOR(I2,-1,I4,0,I4,-1);
3402 VARXOR(I2,0,I4,0,I4,0);
3403 VARXOR(I2,-1,UI4,0xffffffff,I4,0);
3404 VARXOR(I2,-1,UI4,0,I4,-1);
3405 VARXOR(I2,0,UI4,0,I4,0);
3406 VARXOR(I2,-1,R4,-1,I4,0);
3407 VARXOR(I2,-1,R4,0,I4,-1);
3408 VARXOR(I2,0,R4,0,I4,0);
3409 VARXOR(I2,-1,R8,-1,I4,0);
3410 VARXOR(I2,-1,R8,0,I4,-1);
3411 VARXOR(I2,0,R8,0,I4,0);
3412 VARXOR(I2,-1,DATE,-1,I4,0);
3413 VARXOR(I2,-1,DATE,0,I4,-1);
3414 VARXOR(I2,0,DATE,0,I4,0);
3415 if (HAVE_OLEAUT32_I8)
3417 VARXOR(I2,-1,I8,-1,I8,0);
3418 VARXOR(I2,-1,I8,0,I8,-1);
3419 VARXOR(I2,0,I8,0,I8,0);
3420 VARXOR(I2,-1,UI8,0,I4,-1);
3421 VARXOR(I2,0,UI8,0,I4,0);
3423 VARXOR(I2,-1,INT,-1,I4,0);
3424 VARXOR(I2,-1,INT,0,I4,-1);
3425 VARXOR(I2,0,INT,0,I4,0);
3426 VARXOR(I2,-1,UINT,0xffffffff,I4,0);
3427 VARXOR(I2,-1,UINT,0,I4,-1);
3428 VARXOR(I2,0,UINT,0,I4,0);
3429 rbstr = SysAllocString(szFalse);
3430 VARXOR(I2,0,BSTR,rbstr,I2,0);
3431 VARXOR(I2,-1,BSTR,rbstr,I2,-1);
3432 rbstr = SysAllocString(szTrue);
3433 VARXOR(I2,0,BSTR,rbstr,I2,-1);
3434 VARXOR(I2,-1,BSTR,rbstr,I2,0);
3435 VARXORCY(I2,-1,10000,I4,-2);
3436 VARXORCY(I2,-1,0,I4,-1);
3437 VARXORCY(I2,0,0,I4,0);
3439 VARXOR(UI2,65535,UI2,65535,I4,0);
3440 VARXOR(UI2,65535,UI2,0,I4,65535);
3441 VARXOR(UI2,0,UI2,0,I4,0);
3442 VARXOR(UI2,65535,I4,-1,I4,-65536);
3443 VARXOR(UI2,65535,I4,0,I4,65535);
3444 VARXOR(UI2,0,I4,0,I4,0);
3445 VARXOR(UI2,65535,UI4,0xffffffff,I4,-65536);
3446 VARXOR(UI2,65535,UI4,0,I4,65535);
3447 VARXOR(UI2,0,UI4,0,I4,0);
3448 VARXOR(UI2,65535,R4,-1,I4,-65536);
3449 VARXOR(UI2,65535,R4,0,I4,65535);
3450 VARXOR(UI2,0,R4,0,I4,0);
3451 VARXOR(UI2,65535,R8,-1,I4,-65536);
3452 VARXOR(UI2,65535,R8,0,I4,65535);
3453 VARXOR(UI2,0,R8,0,I4,0);
3454 VARXOR(UI2,65535,DATE,-1,I4,-65536);
3455 VARXOR(UI2,65535,DATE,0,I4,65535);
3456 VARXOR(UI2,0,DATE,0,I4,0);
3457 if (HAVE_OLEAUT32_I8)
3459 VARXOR(UI2,65535,I8,-1,I8,-65536);
3460 VARXOR(UI2,65535,I8,0,I8,65535);
3461 VARXOR(UI2,0,I8,0,I8,0);
3462 VARXOR(UI2,65535,UI8,0,I4,65535);
3463 VARXOR(UI2,0,UI8,0,I4,0);
3465 VARXOR(UI2,65535,INT,-1,I4,-65536);
3466 VARXOR(UI2,65535,INT,0,I4,65535);
3467 VARXOR(UI2,0,INT,0,I4,0);
3468 VARXOR(UI2,65535,UINT,0xffffffff,I4,-65536);
3469 VARXOR(UI2,65535,UINT,0,I4,65535);
3470 VARXOR(UI2,0,UINT,0,I4,0);
3471 rbstr = SysAllocString(szFalse);
3472 VARXOR(UI2,0,BSTR,rbstr,I4,0);
3473 VARXOR(UI2,65535,BSTR,rbstr,I4,65535);
3474 rbstr = SysAllocString(szTrue);
3475 VARXOR(UI2,0,BSTR,rbstr,I4,-1);
3476 VARXOR(UI2,65535,BSTR,rbstr,I4,-65536);
3477 VARXORCY(UI2,65535,10000,I4,65534);
3478 VARXORCY(UI2,65535,0,I4,65535);
3479 VARXORCY(UI2,0,0,I4,0);
3481 VARXOR(I4,-1,I4,-1,I4,0);
3482 VARXOR(I4,-1,I4,0,I4,-1);
3483 VARXOR(I4,0,I4,0,I4,0);
3484 VARXOR(I4,-1,UI4,0xffffffff,I4,0);
3485 VARXOR(I4,-1,UI4,0,I4,-1);
3486 VARXOR(I4,0,UI4,0,I4,0);
3487 VARXOR(I4,-1,R4,-1,I4,0);
3488 VARXOR(I4,-1,R4,0,I4,-1);
3489 VARXOR(I4,0,R4,0,I4,0);
3490 VARXOR(I4,-1,R8,-1,I4,0);
3491 VARXOR(I4,-1,R8,0,I4,-1);
3492 VARXOR(I4,0,R8,0,I4,0);
3493 VARXOR(I4,-1,DATE,-1,I4,0);
3494 VARXOR(I4,-1,DATE,0,I4,-1);
3495 VARXOR(I4,0,DATE,0,I4,0);
3496 if (HAVE_OLEAUT32_I8)
3498 VARXOR(I4,-1,I8,-1,I8,0);
3499 VARXOR(I4,-1,I8,0,I8,-1);
3500 VARXOR(I4,0,I8,0,I8,0);
3501 VARXOR(I4,-1,UI8,0,I4,-1);
3502 VARXOR(I4,0,UI8,0,I4,0);
3504 VARXOR(I4,-1,INT,-1,I4,0);
3505 VARXOR(I4,-1,INT,0,I4,-1);
3506 VARXOR(I4,0,INT,0,I4,0);
3507 VARXOR(I4,-1,UINT,0xffffffff,I4,0);
3508 VARXOR(I4,-1,UINT,0,I4,-1);
3509 VARXOR(I4,0,UINT,0,I4,0);
3510 rbstr = SysAllocString(szFalse);
3511 VARXOR(I4,0,BSTR,rbstr,I4,0);
3512 VARXOR(I4,-1,BSTR,rbstr,I4,-1);
3513 rbstr = SysAllocString(szTrue);
3514 VARXOR(I4,0,BSTR,rbstr,I4,-1);
3515 VARXOR(I4,-1,BSTR,rbstr,I4,0);
3516 VARXORCY(I4,-1,10000,I4,-2);
3517 VARXORCY(I4,-1,0,I4,-1);
3518 VARXORCY(I4,0,0,I4,0);
3520 VARXOR(UI4,0xffffffff,UI4,0xffffffff,I4,0);
3521 VARXOR(UI4,0xffffffff,UI4,0,I4,-1);
3522 VARXOR(UI4,0,UI4,0,I4,0);
3523 VARXOR(UI4,0xffffffff,R4,-1,I4,0);
3524 VARXOR(UI4,0xffffffff,R4,0,I4,-1);
3525 VARXOR(UI4,0,R4,0,I4,0);
3526 VARXOR(UI4,0xffffffff,R8,-1,I4,0);
3527 VARXOR(UI4,0xffffffff,R8,0,I4,-1);
3528 VARXOR(UI4,0,R8,0,I4,0);
3529 VARXOR(UI4,0xffffffff,DATE,-1,I4,0);
3530 VARXOR(UI4,0xffffffff,DATE,0,I4,-1);
3531 VARXOR(UI4,0,DATE,0,I4,0);
3532 if (HAVE_OLEAUT32_I8)
3534 VARXOR(UI4,0xffffffff,I8,0,I8,0xffffffff);
3535 VARXOR(UI4,VARIANT_FALSE,I8,VARIANT_FALSE,I8,0);
3536 VARXOR(UI4,0,I8,0,I8,0);
3537 VARXOR(UI4,0xffffffff,UI8,0,I4,-1);
3538 VARXOR(UI4,0,UI8,0,I4,0);
3540 VARXOR(UI4,0xffffffff,INT,-1,I4,0);
3541 VARXOR(UI4,0xffffffff,INT,0,I4,-1);
3542 VARXOR(UI4,0,INT,0,I4,0);
3543 VARXOR(UI4,0xffffffff,UINT,0xffffffff,I4,0);
3544 VARXOR(UI4,0xffffffff,UINT,0,I4,-1);
3545 VARXOR(UI4,0,UINT,0,I4,0);
3546 rbstr = SysAllocString(szFalse);
3547 VARXOR(UI4,0,BSTR,rbstr,I4,0);
3548 VARXOR(UI4,0xffffffff,BSTR,rbstr,I4,-1);
3549 rbstr = SysAllocString(szTrue);
3550 VARXOR(UI4,0,BSTR,rbstr,I4,-1);
3551 VARXOR(UI4,0xffffffff,BSTR,rbstr,I4,0);
3552 VARXORCY(UI4,0xffffffff,10000,I4,-2);
3553 VARXORCY(UI4,0xffffffff,0,I4,-1);
3554 VARXORCY(UI4,0,0,I4,0);
3556 VARXOR(R4,-1,R4,-1,I4,0);
3557 VARXOR(R4,-1,R4,0,I4,-1);
3558 VARXOR(R4,0,R4,0,I4,0);
3559 VARXOR(R4,-1,R8,-1,I4,0);
3560 VARXOR(R4,-1,R8,0,I4,-1);
3561 VARXOR(R4,0,R8,0,I4,0);
3562 VARXOR(R4,-1,DATE,-1,I4,0);
3563 VARXOR(R4,-1,DATE,0,I4,-1);
3564 VARXOR(R4,0,DATE,0,I4,0);
3565 if (HAVE_OLEAUT32_I8)
3567 VARXOR(R4,-1,I8,-1,I8,0);
3568 VARXOR(R4,-1,I8,0,I8,-1);
3569 VARXOR(R4,0,I8,0,I8,0);
3570 VARXOR(R4,-1,UI8,0,I4,-1);
3571 VARXOR(R4,0,UI8,0,I4,0);
3573 VARXOR(R4,-1,INT,-1,I4,0);
3574 VARXOR(R4,-1,INT,0,I4,-1);
3575 VARXOR(R4,0,INT,0,I4,0);
3576 VARXOR(R4,-1,UINT,0xffffffff,I4,0);
3577 VARXOR(R4,-1,UINT,0,I4,-1);
3578 VARXOR(R4,0,UINT,0,I4,0);
3579 rbstr = SysAllocString(szFalse);
3580 VARXOR(R4,0,BSTR,rbstr,I4,0);
3581 VARXOR(R4,-1,BSTR,rbstr,I4,-1);
3582 rbstr = SysAllocString(szTrue);
3583 VARXOR(R4,0,BSTR,rbstr,I4,-1);
3584 VARXOR(R4,-1,BSTR,rbstr,I4,0);
3585 VARXORCY(R4,-1,10000,I4,-2);
3586 VARXORCY(R4,-1,0,I4,-1);
3587 VARXORCY(R4,0,0,I4,0);
3589 VARXOR(R8,-1,R8,-1,I4,0);
3590 VARXOR(R8,-1,R8,0,I4,-1);
3591 VARXOR(R8,0,R8,0,I4,0);
3592 VARXOR(R8,-1,DATE,-1,I4,0);
3593 VARXOR(R8,-1,DATE,0,I4,-1);
3594 VARXOR(R8,0,DATE,0,I4,0);
3595 if (HAVE_OLEAUT32_I8)
3597 VARXOR(R8,-1,I8,-1,I8,0);
3598 VARXOR(R8,-1,I8,0,I8,-1);
3599 VARXOR(R8,0,I8,0,I8,0);
3600 VARXOR(R8,-1,UI8,0,I4,-1);
3601 VARXOR(R8,0,UI8,0,I4,0);
3603 VARXOR(R8,-1,INT,-1,I4,0);
3604 VARXOR(R8,-1,INT,0,I4,-1);
3605 VARXOR(R8,0,INT,0,I4,0);
3606 VARXOR(R8,-1,UINT,0xffffffff,I4,0);
3607 VARXOR(R8,-1,UINT,0,I4,-1);
3608 VARXOR(R8,0,UINT,0,I4,0);
3609 rbstr = SysAllocString(szFalse);
3610 VARXOR(R8,0,BSTR,rbstr,I4,0);
3611 VARXOR(R8,-1,BSTR,rbstr,I4,-1);
3612 rbstr = SysAllocString(szTrue);
3613 VARXOR(R8,0,BSTR,rbstr,I4,-1);
3614 VARXOR(R8,-1,BSTR,rbstr,I4,0);
3615 VARXORCY(R8,-1,10000,I4,-2);
3616 VARXORCY(R8,-1,0,I4,-1);
3617 VARXORCY(R8,0,0,I4,0);
3619 VARXOR(DATE,-1,DATE,-1,I4,0);
3620 VARXOR(DATE,-1,DATE,0,I4,-1);
3621 VARXOR(DATE,0,DATE,0,I4,0);
3622 if (HAVE_OLEAUT32_I8)
3624 VARXOR(DATE,-1,I8,-1,I8,0);
3625 VARXOR(DATE,-1,I8,0,I8,-1);
3626 VARXOR(DATE,0,I8,0,I8,0);
3627 VARXOR(DATE,-1,UI8,0,I4,-1);
3628 VARXOR(DATE,0,UI8,0,I4,0);
3630 VARXOR(DATE,-1,INT,-1,I4,0);
3631 VARXOR(DATE,-1,INT,0,I4,-1);
3632 VARXOR(DATE,0,INT,0,I4,0);
3633 VARXOR(DATE,-1,UINT,0xffffffff,I4,0);
3634 VARXOR(DATE,-1,UINT,0,I4,-1);
3635 VARXOR(DATE,0,UINT,0,I4,0);
3636 rbstr = SysAllocString(szFalse);
3637 VARXOR(DATE,0,BSTR,rbstr,I4,0);
3638 VARXOR(DATE,-1,BSTR,rbstr,I4,-1);
3639 rbstr = SysAllocString(szTrue);
3640 VARXOR(DATE,0,BSTR,rbstr,I4,-1);
3641 VARXOR(DATE,-1,BSTR,rbstr,I4,0);
3642 VARXORCY(DATE,-1,10000,I4,-2);
3643 VARXORCY(DATE,-1,0,I4,-1);
3644 VARXORCY(DATE,0,0,I4,0);
3646 if (HAVE_OLEAUT32_I8)
3648 VARXOR(I8,-1,I8,-1,I8,0);
3649 VARXOR(I8,-1,I8,0,I8,-1);
3650 VARXOR(I8,0,I8,0,I8,0);
3651 VARXOR(I8,-1,UI8,0,I8,-1);
3652 VARXOR(I8,0,UI8,0,I8,0);
3653 VARXOR(I8,-1,UINT,0,I8,-1);
3654 VARXOR(I8,0,UINT,0,I8,0);
3655 rbstr = SysAllocString(szFalse);
3656 VARXOR(I8,0,BSTR,rbstr,I8,0);
3657 VARXOR(I8,-1,BSTR,rbstr,I8,-1);
3658 rbstr = SysAllocString(szTrue);
3659 VARXOR(I8,0,BSTR,rbstr,I8,-1);
3660 VARXOR(I8,-1,BSTR,rbstr,I8,0);
3661 VARXORCY(I8,-1,10000,I8,-2);
3662 VARXORCY(I8,-1,0,I8,-1);
3663 VARXORCY(I8,0,0,I8,0);
3665 VARXOR(UI8,0xffff,UI8,0xffff,I4,0);
3666 VARXOR(UI8,0xffff,UI8,0,I4,0xffff);
3667 VARXOR(UI8,0,UI8,0,I4,0);
3668 VARXOR(UI8,0xffff,INT,-1,I4,-65536);
3669 VARXOR(UI8,0xffff,INT,0,I4,0xffff);
3670 VARXOR(UI8,0,INT,0,I4,0);
3671 VARXOR(UI8,0xffff,UINT,0xffff,I4,0);
3672 VARXOR(UI8,0xffff,UINT,0,I4,0xffff);
3673 VARXOR(UI8,0,UINT,0,I4,0);
3674 rbstr = SysAllocString(szFalse);
3675 VARXOR(UI8,0,BSTR,rbstr,I4,0);
3676 VARXOR(UI8,0xffff,BSTR,rbstr,I4,0xffff);
3677 rbstr = SysAllocString(szTrue);
3678 VARXOR(UI8,0,BSTR,rbstr,I4,-1);
3679 VARXOR(UI8,0xffff,BSTR,rbstr,I4,-65536);
3680 VARXORCY(UI8,0xffff,10000,I4,65534);
3681 VARXORCY(UI8,0xffff,0,I4,0xffff);
3682 VARXORCY(UI8,0,0,I4,0);
3685 VARXOR(INT,-1,INT,-1,I4,0);
3686 VARXOR(INT,-1,INT,0,I4,-1);
3687 VARXOR(INT,0,INT,0,I4,0);
3688 VARXOR(INT,-1,UINT,0xffff,I4,-65536);
3689 VARXOR(INT,-1,UINT,0,I4,-1);
3690 VARXOR(INT,0,UINT,0,I4,0);
3691 rbstr = SysAllocString(szFalse);
3692 VARXOR(INT,0,BSTR,rbstr,I4,0);
3693 VARXOR(INT,-1,BSTR,rbstr,I4,-1);
3694 rbstr = SysAllocString(szTrue);
3695 VARXOR(INT,0,BSTR,rbstr,I4,-1);
3696 VARXOR(INT,-1,BSTR,rbstr,I4,0);
3697 VARXORCY(INT,-1,10000,I4,-2);
3698 VARXORCY(INT,-1,0,I4,-1);
3699 VARXORCY(INT,0,0,I4,0);
3701 VARXOR(UINT,0xffff,UINT,0xffff,I4,0);
3702 VARXOR(UINT,0xffff,UINT,0,I4,0xffff);
3703 VARXOR(UINT,0,UINT,0,I4,0);
3704 rbstr = SysAllocString(szFalse);
3705 VARXOR(UINT,0,BSTR,rbstr,I4,0);
3706 VARXOR(UINT,0xffff,BSTR,rbstr,I4,0xffff);
3707 rbstr = SysAllocString(szTrue);
3708 VARXOR(UINT,0,BSTR,rbstr,I4,-1);
3709 VARXOR(UINT,0xffff,BSTR,rbstr,I4,-65536);
3710 VARXORCY(UINT,0xffff,10000,I4,65534);
3711 VARXORCY(UINT,0xffff,0,I4,0xffff);
3712 VARXORCY(UINT,0,0,I4,0);
3714 lbstr = SysAllocString(szFalse);
3715 rbstr = SysAllocString(szFalse);
3716 VARXOR(BSTR,lbstr,BSTR,rbstr,BOOL,0);
3717 rbstr = SysAllocString(szTrue);
3718 VARXOR(BSTR,lbstr,BSTR,rbstr,BOOL,VARIANT_TRUE);
3719 lbstr = SysAllocString(szTrue);
3720 VARXOR(BSTR,lbstr,BSTR,rbstr,BOOL,VARIANT_FALSE);
3721 VARXORCY(BSTR,lbstr,10000,I4,-2);
3722 lbstr = SysAllocString(szFalse);
3723 VARXORCY(BSTR,lbstr,10000,I4,1);
3726 static HRESULT (WINAPI *pVarOr)(LPVARIANT,LPVARIANT,LPVARIANT);
3728 static const char *szVarOrFail = "VarOr(%d,%d): expected 0x0,%d,%d, got 0x%lX,%d,%d\n";
3729 static const char *szVarOrChanged = "VarOr(%d,%d): Modified input arguments\n";
3730 #define VAROR(vt1,val1,vt2,val2,rvt,rval) \
3731 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
3732 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
3733 memset(&result,0,sizeof(result)); hres = pVarOr(&left,&right,&result); \
3734 ok(hres == S_OK && V_VT(&result) == VT_##rvt && V_##rvt(&result) == (rval), \
3735 szVarOrFail, VT_##vt1, VT_##vt2, \
3736 VT_##rvt, (int)(rval), hres, V_VT(&result), (int)V_##rvt(&result)); \
3737 ok(V_VT(&left) == VT_##vt1 && V_##vt1(&left) == val1 && \
3738 V_VT(&right) == VT_##vt2 && V_##vt2(&right) == val2, \
3739 szVarOrChanged,VT_##vt1,VT_##vt2)
3740 #define VARORCY(vt1,val1,val2,rvt,rval) \
3741 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
3742 V_VT(&right) = VT_CY; V_CY(&right).int64 = val2; \
3743 memset(&result,0,sizeof(result)); hres = pVarOr(&left,&right,&result); \
3744 ok(hres == S_OK && V_VT(&result) == VT_##rvt && V_##rvt(&result) == (rval), \
3745 "VarOr(%d,%d): expected 0x0,%d,%d, got 0x%lX,%d,%d\n", VT_##vt1, VT_CY, \
3746 VT_##rvt, (int)(rval), hres, V_VT(&result), (int)V_##rvt(&result)); \
3747 ok(V_VT(&left) == VT_##vt1 && V_##vt1(&left) == val1 && \
3748 V_VT(&right) == VT_CY && V_CY(&right).int64 == val2, \
3749 "VarOr(%d,%d): Modified input arguments\n",VT_##vt1,VT_CY)
3751 static void test_VarOr(void)
3753 static const WCHAR szFalse[] = { '#','F','A','L','S','E','#','\0' };
3754 static const WCHAR szTrue[] = { '#','T','R','U','E','#','\0' };
3755 VARIANT left, right, result;
3762 /* Test all possible flag/vt combinations & the resulting vt type */
3763 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
3765 VARTYPE leftvt, rightvt, resvt;
3767 for (leftvt = 0; leftvt <= VT_BSTR_BLOB; leftvt++)
3772 for (rightvt = 0; rightvt <= VT_BSTR_BLOB; rightvt++)
3778 if (leftvt == VT_BSTR || rightvt == VT_BSTR ||
3779 leftvt == VT_DISPATCH || rightvt == VT_DISPATCH ||
3780 leftvt == VT_UNKNOWN || rightvt == VT_UNKNOWN)
3783 memset(&left, 0, sizeof(left));
3784 memset(&right, 0, sizeof(right));
3785 V_VT(&left) = leftvt | ExtraFlags[i];
3786 V_VT(&right) = rightvt | ExtraFlags[i];
3787 V_VT(&result) = VT_EMPTY;
3790 if (ExtraFlags[i] & VT_ARRAY || ExtraFlags[i] & VT_BYREF ||
3791 !IsValidVariantClearVT(leftvt, ExtraFlags[i]) ||
3792 !IsValidVariantClearVT(rightvt, ExtraFlags[i]) ||
3793 leftvt == VT_CLSID || rightvt == VT_CLSID ||
3794 leftvt == VT_RECORD || rightvt == VT_RECORD ||
3795 leftvt == VT_VARIANT || rightvt == VT_VARIANT ||
3796 leftvt == VT_ERROR || rightvt == VT_ERROR)
3800 if (leftvt == VT_EMPTY || rightvt == VT_EMPTY)
3802 if (leftvt == rightvt ||
3803 leftvt == VT_I2 || rightvt == VT_I2 ||
3804 leftvt == VT_UI1 || rightvt == VT_UI1 ||
3805 leftvt == VT_BOOL || rightvt == VT_BOOL)
3807 else if (leftvt == VT_NULL || rightvt == VT_NULL)
3809 else if (leftvt == VT_I8 || rightvt == VT_I8)
3812 else if (leftvt == VT_NULL || rightvt == VT_NULL)
3816 else if (leftvt == VT_UI1 || rightvt == VT_UI1)
3818 if (leftvt == rightvt)
3820 else if (leftvt == rightvt ||
3821 leftvt == VT_I2 || rightvt == VT_I2 ||
3822 leftvt == VT_BOOL || rightvt == VT_BOOL)
3826 else if (leftvt == VT_I8 || rightvt == VT_I8)
3829 else if (leftvt == VT_I2 || rightvt == VT_I2)
3831 if (leftvt == rightvt ||
3832 leftvt == VT_BOOL || rightvt == VT_BOOL)
3834 else if (leftvt == VT_I8 || rightvt == VT_I8)
3837 else if (leftvt == VT_BOOL && rightvt == VT_BOOL)
3841 else if (leftvt == VT_I8 || rightvt == VT_I8)
3843 if (leftvt == VT_INT || rightvt == VT_INT)
3848 hres = pVarOr(&left, &right, &result);
3850 ok(hres == DISP_E_TYPEMISMATCH || hres == DISP_E_BADVARTYPE,
3851 "VarOr: %d|0x%X, %d|0x%X: Expected failure, got 0x%lX vt %d\n",
3852 leftvt, ExtraFlags[i], rightvt, ExtraFlags[i], hres,
3855 ok(hres == S_OK && V_VT(&result) == resvt,
3856 "VarOr: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%lX vt %d\n",
3857 leftvt, ExtraFlags[i], rightvt, ExtraFlags[i], resvt, hres,
3863 /* Test returned values. Since we know the returned type is correct
3864 * and that we handle all combinations of invalid types, just check
3865 * that good type combinations produce the desired value.
3866 * FIXME: Test VT_DECIMAL/VT_DISPATCH
3868 VAROR(EMPTY,0,EMPTY,0,I2,0);
3869 VAROR(EMPTY,1,EMPTY,0,I2,0);
3870 VAROR(EMPTY,0,NULL,0,NULL,0);
3871 VAROR(EMPTY,0,I1,0,I4,0);
3872 VAROR(EMPTY,0,I1,1,I4,1);
3873 VAROR(EMPTY,0,UI1,0,I2,0);
3874 VAROR(EMPTY,0,UI1,1,I2,1);
3875 VAROR(EMPTY,0,I2,0,I2,0);
3876 VAROR(EMPTY,0,I2,1,I2,1);
3877 VAROR(EMPTY,0,UI2,0,I4,0);
3878 VAROR(EMPTY,0,UI2,1,I4,1);
3879 VAROR(EMPTY,0,I4,0,I4,0);
3880 VAROR(EMPTY,0,I4,1,I4,1);
3881 VAROR(EMPTY,0,UI4,0,I4,0);
3882 VAROR(EMPTY,0,UI4,1,I4,1);
3883 if (HAVE_OLEAUT32_I8)
3885 VAROR(EMPTY,0,I8,0,I8,0);
3886 VAROR(EMPTY,0,I8,1,I8,1);
3887 VAROR(EMPTY,0,UI8,0,I4,0);
3888 VAROR(EMPTY,0,UI8,1,I4,1);
3890 VAROR(EMPTY,0,INT,0,I4,0);
3891 VAROR(EMPTY,0,INT,1,I4,1);
3892 VAROR(EMPTY,0,UINT,0,I4,0);
3893 VAROR(EMPTY,0,UINT,1,I4,1);
3894 VAROR(EMPTY,0,BOOL,0,I2,0);
3895 VAROR(EMPTY,0,BOOL,1,I2,1);
3896 VAROR(EMPTY,0,R4,0,I4,0);
3897 VAROR(EMPTY,0,R4,1,I4,1);
3898 VAROR(EMPTY,0,R8,0,I4,0);
3899 VAROR(EMPTY,0,R8,1,I4,1);
3900 rbstr = SysAllocString(szFalse);
3901 VAROR(EMPTY,0,BSTR,rbstr,I2,0);
3902 rbstr = SysAllocString(szTrue);
3903 VAROR(EMPTY,0,BSTR,rbstr,I2,-1);
3904 VARORCY(EMPTY,0,10000,I4,1);
3906 /* NULL OR 0 = NULL. NULL OR n = n */
3907 VAROR(NULL,0,NULL,0,NULL,0);
3908 VAROR(NULL,1,NULL,0,NULL,0);
3909 VAROR(NULL,0,I1,0,NULL,0);
3910 VAROR(NULL,0,I1,1,I4,1);
3911 VAROR(NULL,0,UI1,0,NULL,0);
3912 VAROR(NULL,0,UI1,1,UI1,1);
3913 VAROR(NULL,0,I2,0,NULL,0);
3914 VAROR(NULL,0,I2,1,I2,1);
3915 VAROR(NULL,0,UI2,0,NULL,0);
3916 VAROR(NULL,0,UI2,1,I4,1);
3917 VAROR(NULL,0,I4,0,NULL,0);
3918 VAROR(NULL,0,I4,1,I4,1);
3919 VAROR(NULL,0,UI4,0,NULL,0);
3920 VAROR(NULL,0,UI4,1,I4,1);
3921 if (HAVE_OLEAUT32_I8)
3923 VAROR(NULL,0,I8,0,NULL,0);
3924 VAROR(NULL,0,I8,1,I8,1);
3925 VAROR(NULL,0,UI8,0,NULL,0);
3926 VAROR(NULL,0,UI8,1,I4,1);
3928 VAROR(NULL,0,INT,0,NULL,0);
3929 VAROR(NULL,0,INT,1,I4,1);
3930 VAROR(NULL,0,UINT,0,NULL,0);
3931 VAROR(NULL,0,UINT,1,I4,1);
3932 VAROR(NULL,0,BOOL,0,NULL,0);
3933 VAROR(NULL,0,BOOL,1,BOOL,1);
3934 VAROR(NULL,0,R4,0,NULL,0);
3935 VAROR(NULL,0,R4,1,I4,1);
3936 VAROR(NULL,0,R8,0,NULL,0);
3937 VAROR(NULL,0,R8,1,I4,1);
3938 rbstr = SysAllocString(szFalse);
3939 VAROR(NULL,0,BSTR,rbstr,NULL,0);
3940 rbstr = SysAllocString(szTrue);
3941 VAROR(NULL,0,BSTR,rbstr,BOOL,VARIANT_TRUE);
3942 VARORCY(NULL,0,10000,I4,1);
3943 VARORCY(NULL,0,0,NULL,0);
3945 VAROR(BOOL,VARIANT_TRUE,BOOL,VARIANT_TRUE,BOOL,VARIANT_TRUE);
3946 VAROR(BOOL,VARIANT_TRUE,BOOL,VARIANT_FALSE,BOOL,VARIANT_TRUE);
3947 VAROR(BOOL,VARIANT_FALSE,BOOL,VARIANT_TRUE,BOOL,VARIANT_TRUE);
3948 VAROR(BOOL,VARIANT_FALSE,BOOL,VARIANT_FALSE,BOOL,VARIANT_FALSE);
3949 /* Assume x,y & y,x are the same from now on to reduce the number of tests */
3950 VAROR(BOOL,VARIANT_TRUE,I1,-1,I4,-1);
3951 VAROR(BOOL,VARIANT_TRUE,I1,0,I4,-1);
3952 VAROR(BOOL,VARIANT_FALSE,I1,0,I4,0);
3953 VAROR(BOOL,VARIANT_TRUE,UI1,255,I2,-1);
3954 VAROR(BOOL,VARIANT_TRUE,UI1,0,I2,-1);
3955 VAROR(BOOL,VARIANT_FALSE,UI1,0,I2,0);
3956 VAROR(BOOL,VARIANT_TRUE,I2,-1,I2,-1);
3957 VAROR(BOOL,VARIANT_TRUE,I2,0,I2,-1);
3958 VAROR(BOOL,VARIANT_FALSE,I2,0,I2,0);
3959 VAROR(BOOL,VARIANT_TRUE,UI2,65535,I4,-1);
3960 VAROR(BOOL,VARIANT_TRUE,UI2,0,I4,-1);
3961 VAROR(BOOL,VARIANT_FALSE,UI2,0,I4,0);
3962 VAROR(BOOL,VARIANT_TRUE,I4,-1,I4,-1);
3963 VAROR(BOOL,VARIANT_TRUE,I4,0,I4,-1);
3964 VAROR(BOOL,VARIANT_FALSE,I4,0,I4,0);
3965 VAROR(BOOL,VARIANT_TRUE,UI4,0xffffffff,I4,-1);
3966 VAROR(BOOL,VARIANT_TRUE,UI4,0,I4,-1);
3967 VAROR(BOOL,VARIANT_FALSE,UI4,0,I4,0);
3968 VAROR(BOOL,VARIANT_TRUE,R4,-1,I4,-1);
3969 VAROR(BOOL,VARIANT_TRUE,R4,0,I4,-1);
3970 VAROR(BOOL,VARIANT_FALSE,R4,0,I4,0);
3971 VAROR(BOOL,VARIANT_TRUE,R8,-1,I4,-1);
3972 VAROR(BOOL,VARIANT_TRUE,R8,0,I4,-1);
3973 VAROR(BOOL,VARIANT_FALSE,R8,0,I4,0);
3974 VAROR(BOOL,VARIANT_TRUE,DATE,-1,I4,-1);
3975 VAROR(BOOL,VARIANT_TRUE,DATE,0,I4,-1);
3976 VAROR(BOOL,VARIANT_FALSE,DATE,0,I4,0);
3977 if (HAVE_OLEAUT32_I8)
3979 VAROR(BOOL,VARIANT_TRUE,I8,-1,I8,-1);
3980 VAROR(BOOL,VARIANT_TRUE,I8,0,I8,-1);
3981 VAROR(BOOL,VARIANT_FALSE,I8,0,I8,0);
3982 /* This returns DISP_E_OVERFLOW which indicates that a conversion
3983 * to I4 is performed.
3985 /* VAROR(BOOL,VARIANT_TRUE,UI8,-1,I4,-1); */
3986 VAROR(BOOL,VARIANT_TRUE,UI8,0,I4,-1);
3987 VAROR(BOOL,VARIANT_FALSE,UI8,0,I4,0);
3989 VAROR(BOOL,VARIANT_TRUE,INT,-1,I4,-1);
3990 VAROR(BOOL,VARIANT_TRUE,INT,0,I4,-1);
3991 VAROR(BOOL,VARIANT_FALSE,INT,0,I4,0);
3992 VAROR(BOOL,VARIANT_TRUE,UINT,0xffffffff,I4,-1);
3993 VAROR(BOOL,VARIANT_TRUE,UINT,0,I4,-1);
3994 VAROR(BOOL,VARIANT_FALSE,UINT,0,I4,0);
3995 rbstr = SysAllocString(szFalse);
3996 VAROR(BOOL,VARIANT_FALSE,BSTR,rbstr,BOOL,VARIANT_FALSE);
3997 VAROR(BOOL,VARIANT_TRUE,BSTR,rbstr,BOOL,VARIANT_TRUE);
3998 rbstr = SysAllocString(szTrue);
3999 VAROR(BOOL,VARIANT_FALSE,BSTR,rbstr,BOOL,VARIANT_TRUE);
4000 VAROR(BOOL,VARIANT_TRUE,BSTR,rbstr,BOOL,VARIANT_TRUE);
4001 VARORCY(BOOL,VARIANT_TRUE,10000,I4,-1);
4002 VARORCY(BOOL,VARIANT_TRUE,0,I4,-1);
4003 VARORCY(BOOL,VARIANT_FALSE,0,I4,0);
4005 VAROR(I1,-1,I1,-1,I4,-1);
4006 VAROR(I1,-1,I1,0,I4,-1);
4007 VAROR(I1,0,I1,0,I4,0);
4008 VAROR(I1,-1,UI1,255,I4,-1);
4009 VAROR(I1,-1,UI1,0,I4,-1);
4010 VAROR(I1,0,UI1,0,I4,0);
4011 VAROR(I1,-1,I2,-1,I4,-1);
4012 VAROR(I1,-1,I2,0,I4,-1);
4013 VAROR(I1,0,I2,0,I4,0);
4014 VAROR(I1,-1,UI2,65535,I4,-1);
4015 VAROR(I1,-1,UI2,0,I4,-1);
4016 VAROR(I1,0,UI2,0,I4,0);
4017 VAROR(I1,-1,I4,-1,I4,-1);
4018 VAROR(I1,-1,I4,0,I4,-1);
4019 VAROR(I1,0,I4,0,I4,0);
4020 VAROR(I1,-1,UI4,0xffffffff,I4,-1);
4021 VAROR(I1,-1,UI4,0,I4,-1);
4022 VAROR(I1,0,UI4,0,I4,0);
4023 VAROR(I1,-1,R4,-1,I4,-1);
4024 VAROR(I1,-1,R4,0,I4,-1);
4025 VAROR(I1,0,R4,0,I4,0);
4026 VAROR(I1,-1,R8,-1,I4,-1);
4027 VAROR(I1,-1,R8,0,I4,-1);
4028 VAROR(I1,0,R8,0,I4,0);
4029 VAROR(I1,-1,DATE,-1,I4,-1);
4030 VAROR(I1,-1,DATE,0,I4,-1);
4031 VAROR(I1,0,DATE,0,I4,0);
4032 if (HAVE_OLEAUT32_I8)
4034 VAROR(I1,-1,I8,-1,I8,-1);
4035 VAROR(I1,-1,I8,0,I8,-1);
4036 VAROR(I1,0,I8,0,I8,0);
4037 VAROR(I1,-1,UI8,0,I4,-1);
4038 VAROR(I1,0,UI8,0,I4,0);
4040 VAROR(I1,-1,INT,-1,I4,-1);
4041 VAROR(I1,-1,INT,0,I4,-1);
4042 VAROR(I1,0,INT,0,I4,0);
4043 VAROR(I1,-1,UINT,0xffffffff,I4,-1);
4044 VAROR(I1,-1,UINT,0,I4,-1);
4045 VAROR(I1,0,UINT,0,I4,0);
4046 rbstr = SysAllocString(szFalse);
4047 VAROR(I1,0,BSTR,rbstr,I4,0);
4048 VAROR(I1,-1,BSTR,rbstr,I4,-1);
4049 rbstr = SysAllocString(szTrue);
4050 VAROR(I1,0,BSTR,rbstr,I4,-1);
4051 VAROR(I1,-1,BSTR,rbstr,I4,-1);
4052 VARORCY(I1,-1,10000,I4,-1);
4053 VARORCY(I1,-1,0,I4,-1);
4054 VARORCY(I1,0,0,I4,0);
4056 VAROR(UI1,255,UI1,255,UI1,255);
4057 VAROR(UI1,255,UI1,0,UI1,255);
4058 VAROR(UI1,0,UI1,0,UI1,0);
4059 VAROR(UI1,255,I2,-1,I2,-1);
4060 VAROR(UI1,255,I2,0,I2,255);
4061 VAROR(UI1,0,I2,0,I2,0);
4062 VAROR(UI1,255,UI2,65535,I4,65535);
4063 VAROR(UI1,255,UI2,0,I4,255);
4064 VAROR(UI1,0,UI2,0,I4,0);
4065 VAROR(UI1,255,I4,-1,I4,-1);
4066 VAROR(UI1,255,I4,0,I4,255);
4067 VAROR(UI1,0,I4,0,I4,0);
4068 VAROR(UI1,255,UI4,0xffffffff,I4,-1);
4069 VAROR(UI1,255,UI4,0,I4,255);
4070 VAROR(UI1,0,UI4,0,I4,0);
4071 VAROR(UI1,255,R4,-1,I4,-1);
4072 VAROR(UI1,255,R4,0,I4,255);
4073 VAROR(UI1,0,R4,0,I4,0);
4074 VAROR(UI1,255,R8,-1,I4,-1);
4075 VAROR(UI1,255,R8,0,I4,255);
4076 VAROR(UI1,0,R8,0,I4,0);
4077 VAROR(UI1,255,DATE,-1,I4,-1);
4078 VAROR(UI1,255,DATE,0,I4,255);
4079 VAROR(UI1,0,DATE,0,I4,0);
4080 if (HAVE_OLEAUT32_I8)
4082 VAROR(UI1,255,I8,-1,I8,-1);
4083 VAROR(UI1,255,I8,0,I8,255);
4084 VAROR(UI1,0,I8,0,I8,0);
4085 VAROR(UI1,255,UI8,0,I4,255);
4086 VAROR(UI1,0,UI8,0,I4,0);
4088 VAROR(UI1,255,INT,-1,I4,-1);
4089 VAROR(UI1,255,INT,0,I4,255);
4090 VAROR(UI1,0,INT,0,I4,0);
4091 VAROR(UI1,255,UINT,0xffffffff,I4,-1);
4092 VAROR(UI1,255,UINT,0,I4,255);
4093 VAROR(UI1,0,UINT,0,I4,0);
4094 rbstr = SysAllocString(szFalse);
4095 VAROR(UI1,0,BSTR,rbstr,I2,0);
4096 VAROR(UI1,255,BSTR,rbstr,I2,255);
4097 rbstr = SysAllocString(szTrue);
4098 VAROR(UI1,0,BSTR,rbstr,I2,-1);
4099 VAROR(UI1,255,BSTR,rbstr,I2,-1);
4100 VARORCY(UI1,255,10000,I4,255);
4101 VARORCY(UI1,255,0,I4,255);
4102 VARORCY(UI1,0,0,I4,0);
4104 VAROR(I2,-1,I2,-1,I2,-1);
4105 VAROR(I2,-1,I2,0,I2,-1);
4106 VAROR(I2,0,I2,0,I2,0);
4107 VAROR(I2,-1,UI2,65535,I4,-1);
4108 VAROR(I2,-1,UI2,0,I4,-1);
4109 VAROR(I2,0,UI2,0,I4,0);
4110 VAROR(I2,-1,I4,-1,I4,-1);
4111 VAROR(I2,-1,I4,0,I4,-1);
4112 VAROR(I2,0,I4,0,I4,0);
4113 VAROR(I2,-1,UI4,0xffffffff,I4,-1);
4114 VAROR(I2,-1,UI4,0,I4,-1);
4115 VAROR(I2,0,UI4,0,I4,0);
4116 VAROR(I2,-1,R4,-1,I4,-1);
4117 VAROR(I2,-1,R4,0,I4,-1);
4118 VAROR(I2,0,R4,0,I4,0);
4119 VAROR(I2,-1,R8,-1,I4,-1);
4120 VAROR(I2,-1,R8,0,I4,-1);
4121 VAROR(I2,0,R8,0,I4,0);
4122 VAROR(I2,-1,DATE,-1,I4,-1);
4123 VAROR(I2,-1,DATE,0,I4,-1);
4124 VAROR(I2,0,DATE,0,I4,0);
4125 if (HAVE_OLEAUT32_I8)
4127 VAROR(I2,-1,I8,-1,I8,-1);
4128 VAROR(I2,-1,I8,0,I8,-1);
4129 VAROR(I2,0,I8,0,I8,0);
4130 VAROR(I2,-1,UI8,0,I4,-1);
4131 VAROR(I2,0,UI8,0,I4,0);
4133 VAROR(I2,-1,INT,-1,I4,-1);
4134 VAROR(I2,-1,INT,0,I4,-1);
4135 VAROR(I2,0,INT,0,I4,0);
4136 VAROR(I2,-1,UINT,0xffffffff,I4,-1);
4137 VAROR(I2,-1,UINT,0,I4,-1);
4138 VAROR(I2,0,UINT,0,I4,0);
4139 rbstr = SysAllocString(szFalse);
4140 VAROR(I2,0,BSTR,rbstr,I2,0);
4141 VAROR(I2,-1,BSTR,rbstr,I2,-1);
4142 rbstr = SysAllocString(szTrue);
4143 VAROR(I2,0,BSTR,rbstr,I2,-1);
4144 VAROR(I2,-1,BSTR,rbstr,I2,-1);
4145 VARORCY(I2,-1,10000,I4,-1);
4146 VARORCY(I2,-1,0,I4,-1);
4147 VARORCY(I2,0,0,I4,0);
4149 VAROR(UI2,65535,UI2,65535,I4,65535);
4150 VAROR(UI2,65535,UI2,0,I4,65535);
4151 VAROR(UI2,0,UI2,0,I4,0);
4152 VAROR(UI2,65535,I4,-1,I4,-1);
4153 VAROR(UI2,65535,I4,0,I4,65535);
4154 VAROR(UI2,0,I4,0,I4,0);
4155 VAROR(UI2,65535,UI4,0xffffffff,I4,-1);
4156 VAROR(UI2,65535,UI4,0,I4,65535);
4157 VAROR(UI2,0,UI4,0,I4,0);
4158 VAROR(UI2,65535,R4,-1,I4,-1);
4159 VAROR(UI2,65535,R4,0,I4,65535);
4160 VAROR(UI2,0,R4,0,I4,0);
4161 VAROR(UI2,65535,R8,-1,I4,-1);
4162 VAROR(UI2,65535,R8,0,I4,65535);
4163 VAROR(UI2,0,R8,0,I4,0);
4164 VAROR(UI2,65535,DATE,-1,I4,-1);
4165 VAROR(UI2,65535,DATE,0,I4,65535);
4166 VAROR(UI2,0,DATE,0,I4,0);
4167 if (HAVE_OLEAUT32_I8)
4169 VAROR(UI2,65535,I8,-1,I8,-1);
4170 VAROR(UI2,65535,I8,0,I8,65535);
4171 VAROR(UI2,0,I8,0,I8,0);
4172 VAROR(UI2,65535,UI8,0,I4,65535);
4173 VAROR(UI2,0,UI8,0,I4,0);
4175 VAROR(UI2,65535,INT,-1,I4,-1);
4176 VAROR(UI2,65535,INT,0,I4,65535);
4177 VAROR(UI2,0,INT,0,I4,0);
4178 VAROR(UI2,65535,UINT,0xffffffff,I4,-1);
4179 VAROR(UI2,65535,UINT,0,I4,65535);
4180 VAROR(UI2,0,UINT,0,I4,0);
4181 rbstr = SysAllocString(szFalse);
4182 VAROR(UI2,0,BSTR,rbstr,I4,0);
4183 VAROR(UI2,65535,BSTR,rbstr,I4,65535);
4184 rbstr = SysAllocString(szTrue);
4185 VAROR(UI2,0,BSTR,rbstr,I4,-1);
4186 VAROR(UI2,65535,BSTR,rbstr,I4,-1);
4187 VARORCY(UI2,65535,10000,I4,65535);
4188 VARORCY(UI2,65535,0,I4,65535);
4189 VARORCY(UI2,0,0,I4,0);
4191 VAROR(I4,-1,I4,-1,I4,-1);
4192 VAROR(I4,-1,I4,0,I4,-1);
4193 VAROR(I4,0,I4,0,I4,0);
4194 VAROR(I4,-1,UI4,0xffffffff,I4,-1);
4195 VAROR(I4,-1,UI4,0,I4,-1);
4196 VAROR(I4,0,UI4,0,I4,0);
4197 VAROR(I4,-1,R4,-1,I4,-1);
4198 VAROR(I4,-1,R4,0,I4,-1);
4199 VAROR(I4,0,R4,0,I4,0);
4200 VAROR(I4,-1,R8,-1,I4,-1);
4201 VAROR(I4,-1,R8,0,I4,-1);
4202 VAROR(I4,0,R8,0,I4,0);
4203 VAROR(I4,-1,DATE,-1,I4,-1);
4204 VAROR(I4,-1,DATE,0,I4,-1);
4205 VAROR(I4,0,DATE,0,I4,0);
4206 if (HAVE_OLEAUT32_I8)
4208 VAROR(I4,-1,I8,-1,I8,-1);
4209 VAROR(I4,-1,I8,0,I8,-1);
4210 VAROR(I4,0,I8,0,I8,0);
4211 VAROR(I4,-1,UI8,0,I4,-1);
4212 VAROR(I4,0,UI8,0,I4,0);
4214 VAROR(I4,-1,INT,-1,I4,-1);
4215 VAROR(I4,-1,INT,0,I4,-1);
4216 VAROR(I4,0,INT,0,I4,0);
4217 VAROR(I4,-1,UINT,0xffffffff,I4,-1);
4218 VAROR(I4,-1,UINT,0,I4,-1);
4219 VAROR(I4,0,UINT,0,I4,0);
4220 rbstr = SysAllocString(szFalse);
4221 VAROR(I4,0,BSTR,rbstr,I4,0);
4222 VAROR(I4,-1,BSTR,rbstr,I4,-1);
4223 rbstr = SysAllocString(szTrue);
4224 VAROR(I4,0,BSTR,rbstr,I4,-1);
4225 VAROR(I4,-1,BSTR,rbstr,I4,-1);
4226 VARORCY(I4,-1,10000,I4,-1);
4227 VARORCY(I4,-1,0,I4,-1);
4228 VARORCY(I4,0,0,I4,0);
4230 VAROR(UI4,0xffffffff,UI4,0xffffffff,I4,-1);
4231 VAROR(UI4,0xffffffff,UI4,0,I4,-1);
4232 VAROR(UI4,0,UI4,0,I4,0);
4233 VAROR(UI4,0xffffffff,R4,-1,I4,-1);
4234 VAROR(UI4,0xffffffff,R4,0,I4,-1);
4235 VAROR(UI4,0,R4,0,I4,0);
4236 VAROR(UI4,0xffffffff,R8,-1,I4,-1);
4237 VAROR(UI4,0xffffffff,R8,0,I4,-1);
4238 VAROR(UI4,0,R8,0,I4,0);
4239 VAROR(UI4,0xffffffff,DATE,-1,I4,-1);
4240 VAROR(UI4,0xffffffff,DATE,0,I4,-1);
4241 VAROR(UI4,0,DATE,0,I4,0);
4242 if (HAVE_OLEAUT32_I8)
4244 VAROR(UI4,0xffffffff,I8,-1,I8,-1);
4245 VAROR(UI4,0xffffffff,I8,0,I8,0xffffffff);
4246 VAROR(UI4,0,I8,0,I8,0);
4247 VAROR(UI4,0xffffffff,UI8,0,I4,-1);
4248 VAROR(UI4,0,UI8,0,I4,0);
4250 VAROR(UI4,0xffffffff,INT,-1,I4,-1);
4251 VAROR(UI4,0xffffffff,INT,0,I4,-1);
4252 VAROR(UI4,0,INT,0,I4,0);
4253 VAROR(UI4,0xffffffff,UINT,0xffffffff,I4,-1);
4254 VAROR(UI4,0xffffffff,UINT,0,I4,-1);
4255 VAROR(UI4,0,UINT,0,I4,0);
4256 rbstr = SysAllocString(szFalse);
4257 VAROR(UI4,0,BSTR,rbstr,I4,0);
4258 VAROR(UI4,0xffffffff,BSTR,rbstr,I4,-1);
4259 rbstr = SysAllocString(szTrue);
4260 VAROR(UI4,0,BSTR,rbstr,I4,-1);
4261 VAROR(UI4,0xffffffff,BSTR,rbstr,I4,-1);
4262 VARORCY(UI4,0xffffffff,10000,I4,-1);
4263 VARORCY(UI4,0xffffffff,0,I4,-1);
4264 VARORCY(UI4,0,0,I4,0);
4266 VAROR(R4,-1,R4,-1,I4,-1);
4267 VAROR(R4,-1,R4,0,I4,-1);
4268 VAROR(R4,0,R4,0,I4,0);
4269 VAROR(R4,-1,R8,-1,I4,-1);
4270 VAROR(R4,-1,R8,0,I4,-1);
4271 VAROR(R4,0,R8,0,I4,0);
4272 VAROR(R4,-1,DATE,-1,I4,-1);
4273 VAROR(R4,-1,DATE,0,I4,-1);
4274 VAROR(R4,0,DATE,0,I4,0);
4275 if (HAVE_OLEAUT32_I8)
4277 VAROR(R4,-1,I8,-1,I8,-1);
4278 VAROR(R4,-1,I8,0,I8,-1);
4279 VAROR(R4,0,I8,0,I8,0);
4280 VAROR(R4,-1,UI8,0,I4,-1);
4281 VAROR(R4,0,UI8,0,I4,0);
4283 VAROR(R4,-1,INT,-1,I4,-1);
4284 VAROR(R4,-1,INT,0,I4,-1);
4285 VAROR(R4,0,INT,0,I4,0);
4286 VAROR(R4,-1,UINT,0xffffffff,I4,-1);
4287 VAROR(R4,-1,UINT,0,I4,-1);
4288 VAROR(R4,0,UINT,0,I4,0);
4289 rbstr = SysAllocString(szFalse);
4290 VAROR(R4,0,BSTR,rbstr,I4,0);
4291 VAROR(R4,-1,BSTR,rbstr,I4,-1);
4292 rbstr = SysAllocString(szTrue);
4293 VAROR(R4,0,BSTR,rbstr,I4,-1);
4294 VAROR(R4,-1,BSTR,rbstr,I4,-1);
4295 VARORCY(R4,-1,10000,I4,-1);
4296 VARORCY(R4,-1,0,I4,-1);
4297 VARORCY(R4,0,0,I4,0);
4299 VAROR(R8,-1,R8,-1,I4,-1);
4300 VAROR(R8,-1,R8,0,I4,-1);
4301 VAROR(R8,0,R8,0,I4,0);
4302 VAROR(R8,-1,DATE,-1,I4,-1);
4303 VAROR(R8,-1,DATE,0,I4,-1);
4304 VAROR(R8,0,DATE,0,I4,0);
4305 if (HAVE_OLEAUT32_I8)
4307 VAROR(R8,-1,I8,-1,I8,-1);
4308 VAROR(R8,-1,I8,0,I8,-1);
4309 VAROR(R8,0,I8,0,I8,0);
4310 VAROR(R8,-1,UI8,0,I4,-1);
4311 VAROR(R8,0,UI8,0,I4,0);
4313 VAROR(R8,-1,INT,-1,I4,-1);
4314 VAROR(R8,-1,INT,0,I4,-1);
4315 VAROR(R8,0,INT,0,I4,0);
4316 VAROR(R8,-1,UINT,0xffffffff,I4,-1);
4317 VAROR(R8,-1,UINT,0,I4,-1);
4318 VAROR(R8,0,UINT,0,I4,0);
4319 rbstr = SysAllocString(szFalse);
4320 VAROR(R8,0,BSTR,rbstr,I4,0);
4321 VAROR(R8,-1,BSTR,rbstr,I4,-1);
4322 rbstr = SysAllocString(szTrue);
4323 VAROR(R8,0,BSTR,rbstr,I4,-1);
4324 VAROR(R8,-1,BSTR,rbstr,I4,-1);
4325 VARORCY(R8,-1,10000,I4,-1);
4326 VARORCY(R8,-1,0,I4,-1);
4327 VARORCY(R8,0,0,I4,0);
4329 VAROR(DATE,-1,DATE,-1,I4,-1);
4330 VAROR(DATE,-1,DATE,0,I4,-1);
4331 VAROR(DATE,0,DATE,0,I4,0);
4332 if (HAVE_OLEAUT32_I8)
4334 VAROR(DATE,-1,I8,-1,I8,-1);
4335 VAROR(DATE,-1,I8,0,I8,-1);
4336 VAROR(DATE,0,I8,0,I8,0);
4337 VAROR(DATE,-1,UI8,0,I4,-1);
4338 VAROR(DATE,0,UI8,0,I4,0);
4340 VAROR(DATE,-1,INT,-1,I4,-1);
4341 VAROR(DATE,-1,INT,0,I4,-1);
4342 VAROR(DATE,0,INT,0,I4,0);
4343 VAROR(DATE,-1,UINT,0xffffffff,I4,-1);
4344 VAROR(DATE,-1,UINT,0,I4,-1);
4345 VAROR(DATE,0,UINT,0,I4,0);
4346 rbstr = SysAllocString(szFalse);
4347 VAROR(DATE,0,BSTR,rbstr,I4,0);
4348 VAROR(DATE,-1,BSTR,rbstr,I4,-1);
4349 rbstr = SysAllocString(szTrue);
4350 VAROR(DATE,0,BSTR,rbstr,I4,-1);
4351 VAROR(DATE,-1,BSTR,rbstr,I4,-1);
4352 VARORCY(DATE,-1,10000,I4,-1);
4353 VARORCY(DATE,-1,0,I4,-1);
4354 VARORCY(DATE,0,0,I4,0);
4356 if (HAVE_OLEAUT32_I8)
4358 VAROR(I8,-1,I8,-1,I8,-1);
4359 VAROR(I8,-1,I8,0,I8,-1);
4360 VAROR(I8,0,I8,0,I8,0);
4361 VAROR(I8,-1,UI8,0,I8,-1);
4362 VAROR(I8,0,UI8,0,I8,0);
4363 /* These overflow under native and Wine
4364 VAROR(I8,-1,INT,-1,I4,-1);
4365 VAROR(I8,-1,INT,0,I4,-1);
4366 VAROR(I8,0,INT,0,I4,0); */
4367 VAROR(I8,-1,UINT,0xffffffff,I8,-1);
4368 VAROR(I8,-1,UINT,0,I8,-1);
4369 VAROR(I8,0,UINT,0,I8,0);
4370 rbstr = SysAllocString(szFalse);
4371 VAROR(I8,0,BSTR,rbstr,I8,0);
4372 VAROR(I8,-1,BSTR,rbstr,I8,-1);
4373 rbstr = SysAllocString(szTrue);
4374 VAROR(I8,0,BSTR,rbstr,I8,-1);
4375 VAROR(I8,-1,BSTR,rbstr,I8,-1);
4376 VARORCY(I8,-1,10000,I8,-1);
4377 VARORCY(I8,-1,0,I8,-1);
4378 VARORCY(I8,0,0,I8,0);
4380 VAROR(UI8,0xffff,UI8,0xffff,I4,0xffff);
4381 VAROR(UI8,0xffff,UI8,0,I4,0xffff);
4382 VAROR(UI8,0,UI8,0,I4,0);
4383 VAROR(UI8,0xffff,INT,-1,I4,-1);
4384 VAROR(UI8,0xffff,INT,0,I4,0xffff);
4385 VAROR(UI8,0,INT,0,I4,0);
4386 VAROR(UI8,0xffff,UINT,0xffff,I4,0xffff);
4387 VAROR(UI8,0xffff,UINT,0,I4,0xffff);
4388 VAROR(UI8,0,UINT,0,I4,0);
4389 rbstr = SysAllocString(szFalse);
4390 VAROR(UI8,0,BSTR,rbstr,I4,0);
4391 VAROR(UI8,0xffff,BSTR,rbstr,I4,0xffff);
4392 rbstr = SysAllocString(szTrue);
4393 VAROR(UI8,0,BSTR,rbstr,I4,-1);
4394 VAROR(UI8,0xffff,BSTR,rbstr,I4,-1);
4395 VARORCY(UI8,0xffff,10000,I4,0xffff);
4396 VARORCY(UI8,0xffff,0,I4,0xffff);
4397 VARORCY(UI8,0,0,I4,0);
4400 VAROR(INT,-1,INT,-1,I4,-1);
4401 VAROR(INT,-1,INT,0,I4,-1);
4402 VAROR(INT,0,INT,0,I4,0);
4403 VAROR(INT,-1,UINT,0xffff,I4,-1);
4404 VAROR(INT,-1,UINT,0,I4,-1);
4405 VAROR(INT,0,UINT,0,I4,0);
4406 rbstr = SysAllocString(szFalse);
4407 VAROR(INT,0,BSTR,rbstr,I4,0);
4408 VAROR(INT,-1,BSTR,rbstr,I4,-1);
4409 rbstr = SysAllocString(szTrue);
4410 VAROR(INT,0,BSTR,rbstr,I4,-1);
4411 VAROR(INT,-1,BSTR,rbstr,I4,-1);
4412 VARORCY(INT,-1,10000,I4,-1);
4413 VARORCY(INT,-1,0,I4,-1);
4414 VARORCY(INT,0,0,I4,0);
4416 VAROR(UINT,0xffff,UINT,0xffff,I4,0xffff);
4417 VAROR(UINT,0xffff,UINT,0,I4,0xffff);
4418 VAROR(UINT,0,UINT,0,I4,0);
4419 rbstr = SysAllocString(szFalse);
4420 VAROR(UINT,0,BSTR,rbstr,I4,0);
4421 VAROR(UINT,0xffff,BSTR,rbstr,I4,0xffff);
4422 rbstr = SysAllocString(szTrue);
4423 VAROR(UINT,0,BSTR,rbstr,I4,-1);
4424 VAROR(UINT,0xffff,BSTR,rbstr,I4,-1);
4425 VARORCY(UINT,0xffff,10000,I4,0xffff);
4426 VARORCY(UINT,0xffff,0,I4,0xffff);
4427 VARORCY(UINT,0,0,I4,0);
4429 lbstr = SysAllocString(szFalse);
4430 rbstr = SysAllocString(szFalse);
4431 VAROR(BSTR,lbstr,BSTR,rbstr,BOOL,0);
4432 rbstr = SysAllocString(szTrue);
4433 VAROR(BSTR,lbstr,BSTR,rbstr,BOOL,VARIANT_TRUE);
4434 lbstr = SysAllocString(szTrue);
4435 VAROR(BSTR,lbstr,BSTR,rbstr,BOOL,VARIANT_TRUE);
4436 VARORCY(BSTR,lbstr,10000,I4,-1);
4437 lbstr = SysAllocString(szFalse);
4438 VARORCY(BSTR,lbstr,10000,I4,1);
4441 static HRESULT (WINAPI *pVarEqv)(LPVARIANT,LPVARIANT,LPVARIANT);
4443 static const char *szVarEqvFail = "VarEqv(%d,%d): expected 0x0,%d,%d, got 0x%lX,%d,%d\n";
4444 #define VAREQV(vt1,val1,vt2,val2,rvt,rval) \
4445 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
4446 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
4447 memset(&result,0,sizeof(result)); hres = pVarEqv(&left,&right,&result); \
4448 ok(hres == S_OK && V_VT(&result) == VT_##rvt && V_##rvt(&result) == (rval), \
4449 szVarEqvFail, VT_##vt1, VT_##vt2, \
4450 VT_##rvt, (int)(rval), hres, V_VT(&result), (int)V_##rvt(&result))
4452 static void test_VarEqv(void)
4454 VARIANT left, right, result;
4460 /* Test all possible flag/vt combinations & the resulting vt type */
4461 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
4463 VARTYPE leftvt, rightvt, resvt;
4465 for (leftvt = 0; leftvt <= VT_BSTR_BLOB; leftvt++)
4469 for (rightvt = 0; rightvt <= VT_BSTR_BLOB; rightvt++)
4475 if (leftvt == VT_BSTR || rightvt == VT_BSTR ||
4476 leftvt == VT_DISPATCH || rightvt == VT_DISPATCH ||
4477 leftvt == VT_UNKNOWN || rightvt == VT_UNKNOWN)
4480 memset(&left, 0, sizeof(left));
4481 memset(&right, 0, sizeof(right));
4482 V_VT(&left) = leftvt | ExtraFlags[i];
4483 V_VT(&right) = rightvt | ExtraFlags[i];
4484 V_VT(&result) = VT_EMPTY;
4487 if (ExtraFlags[i] & VT_ARRAY || ExtraFlags[i] & VT_BYREF ||
4488 !IsValidVariantClearVT(leftvt, ExtraFlags[i]) ||
4489 !IsValidVariantClearVT(rightvt, ExtraFlags[i]) ||
4490 leftvt == VT_CLSID || rightvt == VT_CLSID ||
4491 leftvt == VT_RECORD || rightvt == VT_RECORD ||
4492 leftvt == VT_VARIANT || rightvt == VT_VARIANT ||
4493 leftvt == VT_ERROR || rightvt == VT_ERROR)
4497 if (leftvt == VT_EMPTY || rightvt == VT_EMPTY)
4499 if (leftvt == rightvt ||
4500 leftvt == VT_I2 || rightvt == VT_I2 ||
4501 leftvt == VT_UI1 || rightvt == VT_UI1 ||
4502 leftvt == VT_BOOL || rightvt == VT_BOOL)
4504 else if (leftvt == VT_NULL || rightvt == VT_NULL)
4506 else if (leftvt == VT_I8 || rightvt == VT_I8)
4509 else if (leftvt == VT_NULL || rightvt == VT_NULL)
4513 else if (leftvt == VT_UI1 || rightvt == VT_UI1)
4515 if (leftvt == rightvt)
4517 else if (leftvt == rightvt ||
4518 leftvt == VT_I2 || rightvt == VT_I2 ||
4519 leftvt == VT_BOOL || rightvt == VT_BOOL)
4523 else if (leftvt == VT_I8 || rightvt == VT_I8)
4526 else if (leftvt == VT_I2 || rightvt == VT_I2)
4528 if (leftvt == rightvt ||
4529 leftvt == VT_BOOL || rightvt == VT_BOOL)
4531 else if (leftvt == VT_I8 || rightvt == VT_I8)
4534 else if (leftvt == VT_BOOL && rightvt == VT_BOOL)
4538 else if (leftvt == VT_I8 || rightvt == VT_I8)
4540 if (leftvt == VT_INT || rightvt == VT_INT)
4545 hres = pVarEqv(&left, &right, &result);
4547 ok(hres == DISP_E_TYPEMISMATCH || hres == DISP_E_BADVARTYPE,
4548 "VarEqv: %d|0x%X, %d|0x%X: Expected failure, got 0x%lX vt %d\n",
4549 leftvt, ExtraFlags[i], rightvt, ExtraFlags[i], hres,
4552 ok(hres == S_OK && V_VT(&result) == resvt,
4553 "VarEqv: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%lX vt %d\n",
4554 leftvt, ExtraFlags[i], rightvt, ExtraFlags[i], resvt, hres,
4560 /* Test returned values */
4561 VAREQV(BOOL,VARIANT_TRUE,BOOL,VARIANT_TRUE,BOOL,VARIANT_TRUE);
4562 VAREQV(BOOL,VARIANT_FALSE,BOOL,VARIANT_TRUE,BOOL,VARIANT_FALSE);
4563 VAREQV(BOOL,TRUE,BOOL,TRUE,BOOL,VARIANT_TRUE);
4564 VAREQV(BOOL,FALSE,BOOL,FALSE,BOOL,VARIANT_TRUE);
4565 VAREQV(BOOL,TRUE,BOOL,FALSE,BOOL,-2);
4566 VAREQV(BOOL,FALSE,BOOL,TRUE,BOOL,-2);
4567 VAREQV(BOOL,6,BOOL,7,BOOL,-2);
4568 VAREQV(BOOL,6,BOOL,6,BOOL,VARIANT_TRUE);
4569 VAREQV(BOOL,VARIANT_TRUE,I2,VARIANT_TRUE,I2,VARIANT_TRUE);
4570 VAREQV(BOOL,VARIANT_TRUE,I2,VARIANT_FALSE,I2,VARIANT_FALSE);
4571 VAREQV(BOOL,6,I2,7,I2,-2);
4572 VAREQV(UI1,1,UI1,1,UI1,255);
4573 VAREQV(UI1,1,UI1,0,UI1,254);
4574 VAREQV(UI1,0,UI1,1,UI1,254);
4575 if (HAVE_OLEAUT32_I8)
4577 VAREQV(UI4,VARIANT_FALSE,I8,VARIANT_FALSE,I8,-1);
4578 VAREQV(UI4,5,I8,19,I8,-23);
4579 VAREQV(UI4,VARIANT_FALSE,UI8,VARIANT_FALSE,I4,-1);
4583 static HRESULT (WINAPI *pVarMul)(LPVARIANT,LPVARIANT,LPVARIANT);
4585 static const char *szVarMulI4 = "VarMul(%d,%d): expected 0x0,%d,%d, got 0x%lX,%d,%d\n";
4586 static const char *szVarMulR8 = "VarMul(%d,%d): expected 0x0,%d,%f, got 0x%lX,%d,%f\n";
4588 #define VARMUL(vt1,val1,vt2,val2,rvt,rval) \
4589 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
4590 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
4591 memset(&result,0,sizeof(result)); hres = pVarMul(&left,&right,&result); \
4592 if (VT_##rvt == VT_R4 || VT_##rvt == VT_R8) { \
4593 ok(hres == S_OK && V_VT(&result) == VT_##rvt && \
4594 EQ_FLOAT(V_##rvt(&result), rval), \
4595 szVarMulR8, VT_##vt1, VT_##vt2, \
4596 VT_##rvt, (double)(rval), hres, V_VT(&result), (double)V_##rvt(&result)); \
4598 ok(hres == S_OK && V_VT(&result) == VT_##rvt && V_##rvt(&result) == (rval), \
4599 szVarMulI4, VT_##vt1, VT_##vt2, \
4600 VT_##rvt, (int)(rval), hres, V_VT(&result), (int)V_##rvt(&result)); }
4602 static void test_VarMul(void)
4604 static const WCHAR sz12[] = {'1','2','\0'};
4605 VARIANT left, right, result, cy, dec;
4613 lbstr = SysAllocString(sz12);
4614 rbstr = SysAllocString(sz12);
4616 /* Test all possible flag/vt combinations & the resulting vt type */
4617 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
4619 VARTYPE leftvt, rightvt, resvt;
4621 for (leftvt = 0; leftvt <= VT_BSTR_BLOB; leftvt++)
4626 for (rightvt = 0; rightvt <= VT_BSTR_BLOB; rightvt++)
4632 if (leftvt == VT_DISPATCH || rightvt == VT_DISPATCH ||
4633 leftvt == VT_UNKNOWN || rightvt == VT_UNKNOWN)
4636 memset(&left, 0, sizeof(left));
4637 memset(&right, 0, sizeof(right));
4638 V_VT(&left) = leftvt | ExtraFlags[i];
4639 if (leftvt == VT_BSTR)
4640 V_BSTR(&left) = lbstr;
4641 V_VT(&right) = rightvt | ExtraFlags[i];
4642 if (rightvt == VT_BSTR)
4643 V_BSTR(&right) = rbstr;
4644 V_VT(&result) = VT_EMPTY;
4647 /* Don't ask me why but native VarMul cannot handle:
4648 VT_I1, VT_UI2, VT_UI4, VT_INT, VT_UINT and VT_UI8.
4649 Tested with DCOM98, Win2k, WinXP */
4650 if (ExtraFlags[i] & VT_ARRAY || ExtraFlags[i] & VT_BYREF ||
4651 !IsValidVariantClearVT(leftvt, ExtraFlags[i]) ||
4652 !IsValidVariantClearVT(rightvt, ExtraFlags[i]) ||
4653 leftvt == VT_CLSID || rightvt == VT_CLSID ||
4654 leftvt == VT_RECORD || rightvt == VT_RECORD ||
4655 leftvt == VT_VARIANT || rightvt == VT_VARIANT ||
4656 leftvt == VT_ERROR || rightvt == VT_ERROR ||
4657 leftvt == VT_I1 || rightvt == VT_I1 ||
4658 leftvt == VT_UI2 || rightvt == VT_UI2 ||
4659 leftvt == VT_UI4 || rightvt == VT_UI4 ||
4660 leftvt == VT_UI8 || rightvt == VT_UI8 ||
4661 leftvt == VT_INT || rightvt == VT_INT ||
4662 leftvt == VT_UINT || rightvt == VT_UINT) {
4666 if (leftvt == VT_NULL || rightvt == VT_NULL)
4668 else if (leftvt == VT_DECIMAL || rightvt == VT_DECIMAL)
4670 else if (leftvt == VT_R8 || rightvt == VT_R8 ||
4671 leftvt == VT_BSTR || rightvt == VT_BSTR ||
4672 leftvt == VT_DATE || rightvt == VT_DATE)
4674 else if (leftvt == VT_R4 || rightvt == VT_R4) {
4675 if (leftvt == VT_I4 || rightvt == VT_I4 ||
4676 leftvt == VT_I8 || rightvt == VT_I8 ||
4677 leftvt == VT_CY || rightvt == VT_CY)
4681 } else if (leftvt == VT_CY || rightvt == VT_CY)
4683 else if (leftvt == VT_I8 || rightvt == VT_I8)
4685 else if (leftvt == VT_I4 || rightvt == VT_I4)
4687 else if (leftvt == VT_I2 || rightvt == VT_I2 ||
4688 leftvt == VT_BOOL || rightvt == VT_BOOL ||
4689 (leftvt == VT_EMPTY && rightvt == VT_EMPTY))
4691 else if (leftvt == VT_UI1 || rightvt == VT_UI1)
4694 hres = pVarMul(&left, &right, &result);
4696 ok(hres == DISP_E_TYPEMISMATCH || hres == DISP_E_BADVARTYPE,
4697 "VarMul: %d|0x%X, %d|0x%X: Expected failure, got 0x%lX vt %d\n",
4698 leftvt, ExtraFlags[i], rightvt, ExtraFlags[i], hres,
4701 ok(hres == S_OK && V_VT(&result) == resvt,
4702 "VarMul: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%lX vt %d\n",
4703 leftvt, ExtraFlags[i], rightvt, ExtraFlags[i], resvt, hres,
4710 /* Test returned values */
4711 VARMUL(I4,4,I4,2,I4,8);
4712 VARMUL(I2,4,I2,2,I2,8);
4713 VARMUL(I2,-13,I4,5,I4,-65);
4714 VARMUL(I4,-13,I4,5,I4,-65);
4715 VARMUL(I2,7,R4,0.5,R4,3.5);
4716 VARMUL(R4,0.5,I4,5,R8,2.5);
4717 VARMUL(R8,7.1,BOOL,0,R8,0);
4718 VARMUL(BSTR,lbstr,I2,4,R8,48);
4719 VARMUL(BSTR,lbstr,BOOL,1,R8,12);
4720 VARMUL(BSTR,lbstr,R4,0.1,R8,1.2);
4721 VARMUL(BSTR,lbstr,BSTR,rbstr,R8,144);
4722 VARMUL(R4,0.2,BSTR,rbstr,R8,2.4);
4723 VARMUL(DATE,2.25,I4,7,R8,15.75);
4725 VARMUL(UI1, UI1_MAX, UI1, UI1_MAX, I4, UI1_MAX * UI1_MAX);
4726 VARMUL(I2, I2_MAX, I2, I2_MAX, I4, I2_MAX * I2_MAX);
4727 VARMUL(I2, I2_MAX, I2, I2_MIN, I4, I2_MAX * I2_MIN);
4728 VARMUL(I2, I2_MIN, I2, I2_MIN, I4, I2_MIN * I2_MIN);
4729 VARMUL(I4, I4_MAX, I4, I4_MAX, R8, (double)I4_MAX * I4_MAX);
4730 VARMUL(I4, I4_MAX, I4, I4_MIN, R8, (double)I4_MAX * I4_MIN);
4731 VARMUL(I4, I4_MIN, I4, I4_MIN, R8, (double)I4_MIN * I4_MIN);
4732 VARMUL(R4, R4_MAX, R4, R4_MAX, R8, (double)R4_MAX * R4_MAX);
4733 VARMUL(R4, R4_MAX, R4, R4_MIN, R4, R4_MAX * R4_MIN);
4734 VARMUL(R4, R4_MIN, R4, R4_MIN, R4, R4_MIN * R4_MIN);
4735 VARMUL(R8, R8_MAX, R8, R8_MIN, R8, R8_MAX * R8_MIN);
4736 VARMUL(R8, R8_MIN, R8, R8_MIN, R8, R8_MIN * R8_MIN);
4738 /* Manuly test some VT_CY and VT_DECIMAL variants */
4740 hres = VarCyFromI4(4711, &V_CY(&cy));
4741 ok(hres == S_OK, "VarCyFromI4 failed!\n");
4742 V_VT(&dec) = VT_DECIMAL;
4743 hres = VarDecFromR8(-4.2, &V_DECIMAL(&dec));
4744 ok(hres == S_OK, "VarDecFromR4 failed!\n");
4745 memset(&left, 0, sizeof(left));
4746 memset(&right, 0, sizeof(right));
4747 V_VT(&left) = VT_I4;
4749 V_VT(&right) = VT_UI1;
4752 hres = VarMul(&cy, &right, &result);
4753 ok(hres == S_OK && V_VT(&result) == VT_CY, "VarMul: expected coerced type VT_CY, got %s!\n", vtstr(V_VT(&result)));
4754 hres = VarR8FromCy(V_CY(&result), &r);
4755 ok(hres == S_OK && EQ_DOUBLE(r, 42399), "VarMul: CY value %f, expected %f\n", r, (double)42399);
4757 hres = VarMul(&left, &dec, &result);
4758 ok(hres == S_OK && V_VT(&result) == VT_DECIMAL, "VarMul: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result)));
4759 hres = VarR8FromDec(&V_DECIMAL(&result), &r);
4760 ok(hres == S_OK && EQ_DOUBLE(r, 46.2), "VarMul: DECIMAL value %f, expected %f\n", r, (double)46.2);
4762 SysFreeString(lbstr);
4763 SysFreeString(rbstr);
4766 static HRESULT (WINAPI *pVarAdd)(LPVARIANT,LPVARIANT,LPVARIANT);
4768 static const char *szVarAddI4 = "VarAdd(%d,%d): expected 0x0,%d,%d, got 0x%lX,%d,%d\n";
4769 static const char *szVarAddR8 = "VarAdd(%d,%d): expected 0x0,%d,%f, got 0x%lX,%d,%f\n";
4771 #define VARADD(vt1,val1,vt2,val2,rvt,rval) \
4772 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
4773 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
4774 memset(&result,0,sizeof(result)); hres = pVarAdd(&left,&right,&result); \
4775 if (VT_##rvt == VT_R4 || VT_##rvt == VT_R8 || VT_##rvt == VT_DATE) { \
4776 ok(hres == S_OK && V_VT(&result) == VT_##rvt && \
4777 EQ_FLOAT(V_##rvt(&result), rval), \
4778 szVarAddR8, VT_##vt1, VT_##vt2, \
4779 VT_##rvt, (double)(rval), hres, V_VT(&result), (double)V_##rvt(&result)); \
4781 ok(hres == S_OK && V_VT(&result) == VT_##rvt && V_##rvt(&result) == (rval), \
4782 szVarAddI4, VT_##vt1, VT_##vt2, \
4783 VT_##rvt, (int)(rval), hres, V_VT(&result), (int)V_##rvt(&result)); }
4785 static void test_VarAdd(void)
4787 static const WCHAR sz12[] = {'1','2','\0'};
4788 VARIANT left, right, result, cy, dec;
4796 lbstr = SysAllocString(sz12);
4797 rbstr = SysAllocString(sz12);
4799 /* Test all possible flag/vt combinations & the resulting vt type */
4800 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
4802 VARTYPE leftvt, rightvt, resvt;
4804 for (leftvt = 0; leftvt <= VT_BSTR_BLOB; leftvt++)
4809 for (rightvt = 0; rightvt <= VT_BSTR_BLOB; rightvt++)
4815 if (leftvt == VT_UNKNOWN || rightvt == VT_UNKNOWN)
4818 memset(&left, 0, sizeof(left));
4819 memset(&right, 0, sizeof(right));
4820 V_VT(&left) = leftvt | ExtraFlags[i];
4821 if (leftvt == VT_BSTR)
4822 V_BSTR(&left) = lbstr;
4823 V_VT(&right) = rightvt | ExtraFlags[i];
4824 if (rightvt == VT_BSTR)
4825 V_BSTR(&right) = rbstr;
4826 V_VT(&result) = VT_EMPTY;
4829 /* Don't ask me why but native VarAdd cannot handle:
4830 VT_I1, VT_UI2, VT_UI4, VT_INT, VT_UINT and VT_UI8.
4831 Tested with DCOM98, Win2k, WinXP */
4832 if (ExtraFlags[i] & VT_ARRAY || ExtraFlags[i] & VT_BYREF ||
4833 !IsValidVariantClearVT(leftvt, ExtraFlags[i]) ||
4834 !IsValidVariantClearVT(rightvt, ExtraFlags[i]) ||
4835 leftvt == VT_CLSID || rightvt == VT_CLSID ||
4836 leftvt == VT_RECORD || rightvt == VT_RECORD ||
4837 leftvt == VT_VARIANT || rightvt == VT_VARIANT ||
4838 leftvt == VT_ERROR || rightvt == VT_ERROR ||
4839 leftvt == VT_I1 || rightvt == VT_I1 ||
4840 leftvt == VT_UI2 || rightvt == VT_UI2 ||
4841 leftvt == VT_UI4 || rightvt == VT_UI4 ||
4842 leftvt == VT_UI8 || rightvt == VT_UI8 ||
4843 leftvt == VT_INT || rightvt == VT_INT ||
4844 leftvt == VT_UINT || rightvt == VT_UINT) {
4848 if (leftvt == VT_NULL || rightvt == VT_NULL)
4850 else if (leftvt == VT_DISPATCH || rightvt == VT_DISPATCH)
4852 else if (leftvt == VT_DECIMAL || rightvt == VT_DECIMAL)
4854 else if (leftvt == VT_DATE || rightvt == VT_DATE)
4856 else if (leftvt == VT_CY || rightvt == VT_CY)
4858 else if (leftvt == VT_R8 || rightvt == VT_R8)
4860 else if (leftvt == VT_BSTR || rightvt == VT_BSTR) {
4861 if ((leftvt == VT_BSTR && rightvt == VT_BSTR) ||
4862 leftvt == VT_EMPTY || rightvt == VT_EMPTY)
4866 } else if (leftvt == VT_R4 || rightvt == VT_R4) {
4867 if (leftvt == VT_I4 || rightvt == VT_I4 ||
4868 leftvt == VT_I8 || rightvt == VT_I8)
4873 else if (leftvt == VT_I8 || rightvt == VT_I8)
4875 else if (leftvt == VT_I4 || rightvt == VT_I4)
4877 else if (leftvt == VT_I2 || rightvt == VT_I2 ||
4878 leftvt == VT_BOOL || rightvt == VT_BOOL ||
4879 (leftvt == VT_EMPTY && rightvt == VT_EMPTY))
4881 else if (leftvt == VT_UI1 || rightvt == VT_UI1)
4884 hres = pVarAdd(&left, &right, &result);
4886 ok(hres == DISP_E_TYPEMISMATCH || hres == DISP_E_BADVARTYPE,
4887 "VarAdd: %d|0x%X, %d|0x%X: Expected failure, got 0x%lX vt %d\n",
4888 leftvt, ExtraFlags[i], rightvt, ExtraFlags[i], hres,
4891 ok(hres == S_OK && V_VT(&result) == resvt,
4892 "VarAdd: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%lX vt %d\n",
4893 leftvt, ExtraFlags[i], rightvt, ExtraFlags[i], resvt, hres,
4900 /* Test returned values */
4901 VARADD(I4,4,I4,2,I4,6);
4902 VARADD(I2,4,I2,2,I2,6);
4903 VARADD(I2,-13,I4,5,I4,-8);
4904 VARADD(I4,-13,I4,5,I4,-8);
4905 VARADD(I2,7,R4,0.5,R4,7.5);
4906 VARADD(R4,0.5,I4,5,R8,5.5);
4907 VARADD(R8,7.1,BOOL,0,R8,7.1);
4908 VARADD(BSTR,lbstr,I2,4,R8,16);
4909 VARADD(BSTR,lbstr,BOOL,1,R8,13);
4910 VARADD(BSTR,lbstr,R4,0.1,R8,12.1);
4911 VARADD(R4,0.2,BSTR,rbstr,R8,12.2);
4912 VARADD(DATE,2.25,I4,7,DATE,9.25);
4913 VARADD(DATE,1.25,R4,-1.7,DATE,-0.45);
4915 VARADD(UI1, UI1_MAX, UI1, UI1_MAX, I2, UI1_MAX + UI1_MAX);
4916 VARADD(I2, I2_MAX, I2, I2_MAX, I4, I2_MAX + I2_MAX);
4917 VARADD(I2, I2_MAX, I2, I2_MIN, I2, I2_MAX + I2_MIN);
4918 VARADD(I2, I2_MIN, I2, I2_MIN, I4, I2_MIN + I2_MIN);
4919 VARADD(I4, I4_MAX, I4, I4_MIN, I4, I4_MAX + I4_MIN);
4920 VARADD(I4, I4_MAX, I4, I4_MAX, R8, (double)I4_MAX + I4_MAX);
4921 VARADD(I4, I4_MIN, I4, I4_MIN, R8, (double)I4_MIN + I4_MIN);
4922 VARADD(R4, R4_MAX, R4, R4_MAX, R8, (double)R4_MAX + R4_MAX);
4923 VARADD(R4, R4_MAX, R4, R4_MIN, R4, R4_MAX + R4_MIN);
4924 VARADD(R4, R4_MIN, R4, R4_MIN, R4, R4_MIN + R4_MIN);
4925 VARADD(R8, R8_MAX, R8, R8_MIN, R8, R8_MAX + R8_MIN);
4926 VARADD(R8, R8_MIN, R8, R8_MIN, R8, R8_MIN + R8_MIN);
4928 /* Manualy test BSTR + BSTR */
4929 V_VT(&left) = VT_BSTR;
4930 V_BSTR(&left) = lbstr;
4931 V_VT(&right) = VT_BSTR;
4932 V_BSTR(&right) = rbstr;
4933 hres = VarAdd(&left, &right, &result);
4934 ok(hres == S_OK && V_VT(&result) == VT_BSTR, "VarAdd: expected coerced type VT_BSTR, got %s!\n", vtstr(V_VT(&result)));
4935 hres = VarR8FromStr(V_BSTR(&result), 0, 0, &r);
4936 ok(hres == S_OK && EQ_DOUBLE(r, 1212), "VarAdd: BSTR value %f, expected %f\n", r, (double)1212);
4938 /* Manuly test some VT_CY and VT_DECIMAL variants */
4940 hres = VarCyFromI4(4711, &V_CY(&cy));
4941 ok(hres == S_OK, "VarCyFromI4 failed!\n");
4942 V_VT(&dec) = VT_DECIMAL;
4943 hres = VarDecFromR8(-4.2, &V_DECIMAL(&dec));
4944 ok(hres == S_OK, "VarDecFromR4 failed!\n");
4945 memset(&left, 0, sizeof(left));
4946 memset(&right, 0, sizeof(right));
4947 V_VT(&left) = VT_I4;
4949 V_VT(&right) = VT_UI1;
4952 hres = VarAdd(&cy, &right, &result);
4953 ok(hres == S_OK && V_VT(&result) == VT_CY, "VarAdd: expected coerced type VT_CY, got %s!\n", vtstr(V_VT(&result)));
4954 hres = VarR8FromCy(V_CY(&result), &r);
4955 ok(hres == S_OK && EQ_DOUBLE(r, 4720), "VarAdd: CY value %f, expected %f\n", r, (double)4720);
4957 hres = VarAdd(&left, &dec, &result);
4958 ok(hres == S_OK && V_VT(&result) == VT_DECIMAL, "VarAdd: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result)));
4959 hres = VarR8FromDec(&V_DECIMAL(&result), &r);
4960 ok(hres == S_OK && EQ_DOUBLE(r, -15.2), "VarAdd: DECIMAL value %f, expected %f\n", r, (double)-15.2);
4962 SysFreeString(lbstr);
4963 SysFreeString(rbstr);
4966 static HRESULT (WINAPI *pVarCmp)(LPVARIANT,LPVARIANT,LCID,ULONG);
4968 /* ERROR from wingdi.h is interfering here */
4970 #define _VARCMP(vt1,val1,vtfl1,vt2,val2,vtfl2,lcid,flags,result) \
4971 V_##vt1(&left) = val1; V_VT(&left) = VT_##vt1 | vtfl1; \
4972 V_##vt2(&right) = val2; V_VT(&right) = VT_##vt2 | vtfl2; \
4973 hres = pVarCmp(&left,&right,lcid,flags); \
4974 ok(hres == result, "VarCmp(VT_" #vt1 "|" #vtfl1 ",VT_" #vt2 "|" #vtfl2 "): expected " #result ", got hres=0x%lx\n", hres)
4975 #define VARCMPEX(vt1,val1,vt2,val2,res1,res2,res3,res4) \
4976 _VARCMP(vt1,val1,0,vt2,val2,0,lcid,0,res1); \
4977 _VARCMP(vt1,val1,VT_RESERVED,vt2,val2,0,lcid,0,res2); \
4978 _VARCMP(vt1,val1,0,vt2,val2,VT_RESERVED,lcid,0,res3); \
4979 _VARCMP(vt1,val1,VT_RESERVED,vt2,val2,VT_RESERVED,lcid,0,res4)
4980 #define VARCMP(vt1,val1,vt2,val2,result) \
4981 VARCMPEX(vt1,val1,vt2,val2,result,result,result,result)
4982 /* The above macros do not work for VT_NULL as NULL gets expanded first */
4983 #define V_NULL_ V_NULL
4984 #define VT_NULL_ VT_NULL
4986 static void test_VarCmp(void)
4988 VARIANT left, right;
4993 static const WCHAR szhuh[] = {'h','u','h','?','\0'};
4994 static const WCHAR sz2cents[] = {'2','c','e','n','t','s','\0'};
4995 static const WCHAR szempty[] = {'\0'};
4996 static const WCHAR sz0[] = {'0','\0'};
4997 static const WCHAR sz1[] = {'1','\0'};
4998 static const WCHAR sz7[] = {'7','\0'};
4999 static const WCHAR sz42[] = {'4','2','\0'};
5000 static const WCHAR sz1neg[] = {'-','1','\0'};
5001 static const WCHAR sz666neg[] = {'-','6','6','6','\0'};
5002 static const WCHAR sz1few[] = {'1','.','0','0','0','0','0','0','0','1','\0'};
5003 BSTR bstrhuh, bstrempty, bstr0, bstr1, bstr7, bstr42, bstr1neg, bstr666neg;
5004 BSTR bstr2cents, bstr1few;
5008 lcid = MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT);
5009 bstrempty = SysAllocString(szempty);
5010 bstrhuh = SysAllocString(szhuh);
5011 bstr2cents = SysAllocString(sz2cents);
5012 bstr0 = SysAllocString(sz0);
5013 bstr1 = SysAllocString(sz1);
5014 bstr7 = SysAllocString(sz7);
5015 bstr42 = SysAllocString(sz42);
5016 bstr1neg = SysAllocString(sz1neg);
5017 bstr666neg = SysAllocString(sz666neg);
5018 bstr1few = SysAllocString(sz1few);
5020 /* Test all possible flag/vt combinations & the resulting vt type */
5021 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
5023 VARTYPE leftvt, rightvt;
5025 for (leftvt = 0; leftvt <= VT_BSTR_BLOB; leftvt++)
5030 for (rightvt = 0; rightvt <= VT_BSTR_BLOB; rightvt++)
5033 HRESULT expect = VARCMP_EQ;
5037 memset(&left, 0, sizeof(left));
5038 memset(&right, 0, sizeof(right));
5039 V_VT(&left) = leftvt | ExtraFlags[i];
5040 if (leftvt == VT_BSTR) {
5041 V_BSTR(&left) = bstr1neg;
5042 if (ExtraFlags[i] & VT_RESERVED)
5047 V_VT(&right) = rightvt | ExtraFlags[i];
5048 if (rightvt == VT_BSTR) {
5049 V_BSTR(&right) = bstr1neg;
5050 if (ExtraFlags[i] & VT_RESERVED)
5056 /* Don't ask me why but native VarCmp cannot handle:
5057 VT_I1, VT_UI2, VT_UI4, VT_UINT and VT_UI8.
5058 VT_INT is only supported as left variant. Go figure.
5059 Tested with DCOM98, Win2k, WinXP */
5060 if (ExtraFlags[i] & VT_ARRAY || ExtraFlags[i] & VT_BYREF ||
5061 !IsValidVariantClearVT(leftvt, ExtraFlags[i] & ~VT_RESERVED) ||
5062 !IsValidVariantClearVT(rightvt, ExtraFlags[i] & ~VT_RESERVED) ||
5063 leftvt == VT_CLSID || rightvt == VT_CLSID ||
5064 leftvt == VT_DISPATCH || rightvt == VT_DISPATCH ||
5065 leftvt == VT_ERROR || rightvt == VT_ERROR ||
5066 leftvt == VT_RECORD || rightvt == VT_RECORD ||
5067 leftvt == VT_UNKNOWN || rightvt == VT_UNKNOWN ||
5068 leftvt == VT_VARIANT || rightvt == VT_VARIANT ||
5069 leftvt == VT_I1 || rightvt == VT_I1 ||
5070 leftvt == VT_UI2 || rightvt == VT_UI2 ||
5071 leftvt == VT_UI4 || rightvt == VT_UI4 ||
5072 leftvt == VT_UI8 || rightvt == VT_UI8 ||
5073 rightvt == VT_INT ||
5074 leftvt == VT_UINT || rightvt == VT_UINT) {
5078 if (leftvt == VT_ERROR && rightvt == VT_ERROR &&
5079 !(ExtraFlags[i] & ~VT_RESERVED)) {
5082 } else if (leftvt == VT_NULL || rightvt == VT_NULL)
5083 expect = VARCMP_NULL;
5084 else if (leftvt == VT_BSTR && rightvt == VT_BSTR)
5086 else if (leftvt == VT_BSTR && rightvt == VT_EMPTY)
5088 else if (leftvt == VT_EMPTY && rightvt == VT_BSTR)
5091 hres = pVarCmp(&left, &right, LOCALE_USER_DEFAULT, 0);
5093 ok(hres == DISP_E_TYPEMISMATCH || hres == DISP_E_BADVARTYPE,
5094 "VarCmp: %d|0x%X, %d|0x%X: Expected failure, got 0x%lX\n",
5095 leftvt, ExtraFlags[i], rightvt, ExtraFlags[i], hres);
5098 "VarCmp: %d|0x%X, %d|0x%X: Expected 0x%lX, got 0x%lX\n",
5099 leftvt, ExtraFlags[i], rightvt, ExtraFlags[i], expect,
5106 /* VARCMP{,EX} run each 4 tests with a permutation of all posible
5107 input variants with (1) and without (0) VT_RESERVED set. The order
5108 of the permutations is (0,0); (1,0); (0,1); (1,1) */
5109 VARCMP(INT,4711,I2,4711,VARCMP_EQ);
5110 ok(V_VT(&left) & V_VT(&right) & VT_RESERVED, "VT_RESERVED filtered out!\n");
5111 VARCMP(INT,4711,I2,-4711,VARCMP_GT);
5112 VARCMP(ERROR,0,ERROR,0,VARCMP_EQ);
5113 VARCMP(ERROR,0,UI1,0,DISP_E_TYPEMISMATCH);
5114 VARCMP(EMPTY,0,EMPTY,0,VARCMP_EQ);
5115 VARCMP(I4,1,R8,1.0,VARCMP_EQ);
5116 VARCMP(EMPTY,19,I2,0,VARCMP_EQ);
5117 ok(V_EMPTY(&left) == 19, "VT_EMPTY modified!\n");
5118 ok(V_VT(&left) & V_VT(&right) & VT_RESERVED, "VT_RESERVED filtered out!\n");
5119 VARCMP(I4,1,UI1,1,VARCMP_EQ);
5120 VARCMP(I2,2,I2,2,VARCMP_EQ);
5121 VARCMP(I2,1,I2,2,VARCMP_LT);
5122 VARCMP(I2,2,I2,1,VARCMP_GT);
5123 VARCMP(I2,2,EMPTY,1,VARCMP_GT);
5124 VARCMP(I2,2,NULL_,1,VARCMP_NULL);
5126 /* BSTR handling, especialy in conjunction with VT_RESERVED */
5127 VARCMP(BSTR,bstr0,NULL_,0,VARCMP_NULL);
5128 VARCMP(BSTR,bstr0,BSTR,bstr0,VARCMP_EQ);
5129 VARCMP(BSTR,bstrempty,BSTR,bstr0,VARCMP_LT);
5130 VARCMP(BSTR,bstr7,BSTR,bstr0,VARCMP_GT);
5131 VARCMP(BSTR,bstr7,BSTR,bstr1neg,VARCMP_GT);
5132 VARCMP(BSTR,bstr0,BSTR,NULL,VARCMP_GT);
5133 VARCMP(BSTR,NULL,BSTR,NULL,VARCMP_EQ);
5134 VARCMP(BSTR,bstrempty,BSTR,NULL,VARCMP_EQ);
5135 VARCMP(BSTR,NULL,EMPTY,0,VARCMP_EQ);
5136 VARCMP(EMPTY,0,BSTR,NULL,VARCMP_EQ);
5137 VARCMP(EMPTY,0,BSTR,bstrempty,VARCMP_EQ);
5138 VARCMP(EMPTY,1,BSTR,bstrempty,VARCMP_EQ);
5139 VARCMP(BSTR,bstr0,EMPTY,0,VARCMP_GT);
5140 VARCMP(BSTR,bstr42,EMPTY,0,VARCMP_GT);
5141 VARCMPEX(BSTR,bstrempty,UI1,0,VARCMP_GT,VARCMP_LT,VARCMP_GT,VARCMP_GT);
5142 VARCMPEX(BSTR,bstrempty,I2,-1,VARCMP_GT,VARCMP_LT,VARCMP_GT,VARCMP_GT);
5143 VARCMPEX(I4,0,BSTR,bstrempty,VARCMP_LT,VARCMP_LT,VARCMP_GT,VARCMP_LT);
5144 VARCMPEX(BSTR,NULL,UI1,0,VARCMP_GT,VARCMP_LT,VARCMP_GT,VARCMP_GT);
5145 VARCMPEX(I4,7,BSTR,NULL,VARCMP_LT,VARCMP_LT,VARCMP_GT,VARCMP_LT);
5146 _VARCMP(BSTR,(BSTR)100,0,I2,100,0,lcid,0,VARCMP_GT);
5147 VARCMPEX(BSTR,bstr0,UI1,0,VARCMP_GT,VARCMP_EQ,VARCMP_EQ,VARCMP_GT);
5148 VARCMPEX(I2,0,BSTR,bstr0,VARCMP_LT,VARCMP_EQ,VARCMP_EQ,VARCMP_LT);
5149 ok(V_VT(&left) & V_VT(&right) & VT_RESERVED, "VT_RESERVED filtered out!\n");
5150 VARCMP(BSTR,bstrhuh,I4,I4_MAX,VARCMP_GT);
5151 VARCMP(BSTR,bstr2cents,I4,2,VARCMP_GT);
5152 VARCMPEX(BSTR,bstr2cents,I4,42,VARCMP_GT,VARCMP_LT,VARCMP_GT,VARCMP_GT);
5153 VARCMP(BSTR,bstr2cents,I4,-1,VARCMP_GT);
5154 VARCMPEX(BSTR,bstr2cents,I4,-666,VARCMP_GT,VARCMP_LT,VARCMP_GT,VARCMP_GT);
5155 VARCMPEX(BSTR,bstr0,I2,0,VARCMP_GT,VARCMP_EQ,VARCMP_EQ,VARCMP_GT);
5156 VARCMPEX(BSTR,bstr0,I4,0,VARCMP_GT,VARCMP_EQ,VARCMP_EQ,VARCMP_GT);
5157 VARCMPEX(BSTR,bstr0,I4,-666,VARCMP_GT,VARCMP_LT,VARCMP_GT,VARCMP_GT);
5158 VARCMP(BSTR,bstr1,I4,0,VARCMP_GT);
5159 VARCMPEX(BSTR,bstr1,I4,1,VARCMP_GT,VARCMP_EQ,VARCMP_EQ,VARCMP_GT);
5160 VARCMPEX(BSTR,bstr1,I4,I4_MAX,VARCMP_GT,VARCMP_LT,VARCMP_LT,VARCMP_GT);
5161 VARCMPEX(BSTR,bstr1,I4,-1,VARCMP_GT,VARCMP_LT,VARCMP_GT,VARCMP_GT);
5162 VARCMP(BSTR,bstr7,I4,1,VARCMP_GT);
5163 VARCMPEX(BSTR,bstr7,I4,7,VARCMP_GT,VARCMP_EQ,VARCMP_EQ,VARCMP_GT);
5164 VARCMPEX(BSTR,bstr7,I4,42,VARCMP_GT,VARCMP_GT,VARCMP_LT,VARCMP_GT);
5165 VARCMPEX(BSTR,bstr42,I4,7,VARCMP_GT,VARCMP_LT,VARCMP_GT,VARCMP_GT);
5166 VARCMPEX(BSTR,bstr42,I4,42,VARCMP_GT,VARCMP_EQ,VARCMP_EQ,VARCMP_GT);
5167 VARCMPEX(BSTR,bstr42,I4,I4_MAX,VARCMP_GT,VARCMP_GT,VARCMP_LT,VARCMP_GT);
5168 VARCMPEX(BSTR,bstr1neg,I4,1,VARCMP_GT,VARCMP_GT,VARCMP_LT,VARCMP_LT);
5169 VARCMPEX(BSTR,bstr1neg,I4,42,VARCMP_GT,VARCMP_LT,VARCMP_LT,VARCMP_LT);
5170 VARCMPEX(BSTR,bstr1neg,I4,-1,VARCMP_GT,VARCMP_EQ,VARCMP_EQ,VARCMP_LT);
5171 VARCMPEX(BSTR,bstr1neg,I4,-666,VARCMP_GT,VARCMP_LT,VARCMP_GT,VARCMP_LT);
5172 VARCMPEX(BSTR,bstr666neg,I4,1,VARCMP_GT,VARCMP_GT,VARCMP_LT,VARCMP_LT);
5173 VARCMPEX(BSTR,bstr666neg,I4,7,VARCMP_GT,VARCMP_LT,VARCMP_LT,VARCMP_LT);
5174 VARCMPEX(BSTR,bstr666neg,I4,42,VARCMP_GT,VARCMP_GT,VARCMP_LT,VARCMP_LT);
5175 VARCMPEX(BSTR,bstr666neg,I4,I4_MAX,VARCMP_GT,VARCMP_GT,VARCMP_LT,VARCMP_LT);
5176 VARCMPEX(BSTR,bstr666neg,I4,-1,VARCMP_GT,VARCMP_GT,VARCMP_LT,VARCMP_LT);
5177 VARCMPEX(BSTR,bstr666neg,I4,-666,VARCMP_GT,VARCMP_EQ,VARCMP_EQ,VARCMP_LT);
5178 VARCMPEX(BSTR,bstr7,R8,7.0,VARCMP_GT,VARCMP_EQ,VARCMP_EQ,VARCMP_GT);
5179 VARCMPEX(R8,3.141592,BSTR,NULL,VARCMP_LT,VARCMP_LT,VARCMP_GT,VARCMP_LT);
5180 VARCMP(BSTR,bstr7,BSTR,bstr7,VARCMP_EQ);
5181 VARCMP(BSTR,bstr7,BSTR,bstr42,VARCMP_GT);
5182 VARCMP(BSTR,bstr42,BSTR,bstr7,VARCMP_LT);
5184 /* DECIMAL handling */
5185 SETDEC(dec,0,0,0,0);
5186 VARCMPEX(DECIMAL,dec,BSTR,bstr0,VARCMP_LT,VARCMP_EQ,VARCMP_EQ,VARCMP_LT);
5187 SETDEC64(dec,0,0,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF); /* max DECIMAL */
5188 VARCMP(DECIMAL,dec,R8,R8_MAX,VARCMP_LT); /* R8 has bigger range */
5189 VARCMP(DECIMAL,dec,DATE,R8_MAX,VARCMP_LT); /* DATE has bigger range */
5190 SETDEC64(dec,0,0x80,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF);
5191 VARCMP(DECIMAL,dec,R8,-R8_MAX,VARCMP_GT);
5192 SETDEC64(dec,20,0,0x5,0x6BC75E2D,0x63100001); /* 1+1e-20 */
5193 VARCMP(DECIMAL,dec,R8,1,VARCMP_GT); /* DECIMAL has higher precission */
5195 /* Show that DATE is handled just as a R8 */
5196 VARCMP(DATE,DATE_MAX,DATE,DATE_MAX+1,VARCMP_LT);
5197 VARCMP(DATE,DATE_MIN,DATE,DATE_MIN-1,VARCMP_GT);
5198 VARCMP(DATE,R8_MIN,R8,R8_MIN,VARCMP_EQ);
5199 VARCMP(DATE,1,DATE,1+1e-15,VARCMP_LT); /* 1e-15 == 8.64e-11 seconds */
5200 VARCMP(DATE,25570.0,DATE,25570.0,VARCMP_EQ);
5201 VARCMP(DATE,25570.0,DATE,25571.0,VARCMP_LT);
5202 VARCMP(DATE,25571.0,DATE,25570.0,VARCMP_GT);
5203 VARCMP(DATE,25570.0,EMPTY,0,VARCMP_GT);
5204 VARCMP(DATE,25570.0,NULL_,0,VARCMP_NULL);
5206 /* R4 precission handling */
5207 VARCMP(R4,1,R8,1+1e-8,VARCMP_EQ);
5208 VARCMP(R8,1+1e-8,R4,1,VARCMP_EQ);
5209 VARCMP(R8,1+1e-8,R8,1,VARCMP_GT);
5210 VARCMP(R8,R4_MAX*1.1,R4,R4_MAX,VARCMP_GT);
5211 VARCMP(R4,R4_MAX,R8,R8_MAX,VARCMP_LT);
5212 VARCMP(R4,1,DATE,1+1e-8,VARCMP_EQ);
5213 VARCMP(R4,1,BSTR,bstr1few,VARCMP_LT); /* bstr1few == 1+1e-8 */
5214 SETDEC(dec,8,0,0,0x5F5E101); /* 1+1e-8 */
5215 VARCMP(R4,1,DECIMAL,dec,VARCMP_LT);
5217 SysFreeString(bstrhuh);
5218 SysFreeString(bstrempty);
5219 SysFreeString(bstr0);
5220 SysFreeString(bstr1);
5221 SysFreeString(bstr7);
5222 SysFreeString(bstr42);
5223 SysFreeString(bstr1neg);
5224 SysFreeString(bstr666neg);
5225 SysFreeString(bstr2cents);
5226 SysFreeString(bstr1few);
5231 hOleaut32 = LoadLibraryA("oleaut32.dll");
5234 test_VariantClear();
5236 test_VariantCopyInd();
5237 test_VarParseNumFromStr();
5238 test_VarNumFromParseNum();
5239 test_VarUdateFromDate();
5240 test_VarDateFromUdate();
5241 test_SystemTimeToVariantTime();
5242 test_VariantTimeToSystemTime();
5243 test_DosDateTimeToVariantTime();
5244 test_VariantTimeToDosDateTime();
5245 test_VarFormatNumber();