4 * Copyright 1998 Jean-Claude Cote
5 * Copyright 2006 Google (Benjamin Arai)
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
30 #include "wine/test.h"
40 static HMODULE hOleaut32;
42 static HRESULT (WINAPI *pVarUdateFromDate)(DATE,ULONG,UDATE*);
43 static HRESULT (WINAPI *pVarDateFromUdate)(UDATE*,ULONG,DATE*);
44 static INT (WINAPI *pSystemTimeToVariantTime)(LPSYSTEMTIME,double*);
45 static INT (WINAPI *pVariantTimeToSystemTime)(double,LPSYSTEMTIME);
46 static INT (WINAPI *pDosDateTimeToVariantTime)(USHORT,USHORT,double*);
47 static INT (WINAPI *pVariantTimeToDosDateTime)(double,USHORT*,USHORT *);
49 static const WCHAR sz12[] = {'1','2','\0'};
50 /* the strings are localized */
51 static WCHAR sz12_false[32];
52 static WCHAR sz12_true[32];
54 /* Get a conversion function ptr, return if function not available */
55 #define CHECKPTR(func) p##func = (void*)GetProcAddress(hOleaut32, #func); \
56 if (!p##func) { trace("function " # func " not available, not testing it\n"); return; }
58 /* Have IRecordInfo data type? */
59 static int HAVE_OLEAUT32_RECORD = 0;
60 /* Have I8/UI8 data type? */
61 static int HAVE_OLEAUT32_I8 = 0;
62 /* Is this an ancient version with support for only I2/I4/R4/R8/DATE? */
63 static int IS_ANCIENT = 0;
65 /* When comparing floating point values we cannot expect an exact match
66 * because the rounding errors depend on the exact algorithm.
68 #define EQ_DOUBLE(a,b) (fabs((a)-(b)) / (1.0+fabs(a)+fabs(b)) < 1e-14)
69 #define EQ_FLOAT(a,b) (fabs((a)-(b)) / (1.0+fabs(a)+fabs(b)) < 1e-7)
71 #define SKIPTESTS(a) if((a > VT_CLSID+10) && (a < VT_BSTR_BLOB-10)) continue
73 /* Allow our test macros to work for VT_NULL and VT_EMPTY too */
74 #define V_EMPTY(v) V_I4(v)
75 #define V_NULL(v) V_I4(v)
77 /* Size constraints for overflow tests */
79 #define I1_MIN ((-I1_MAX)-1)
83 #define I2_MIN ((-I2_MAX)-1)
84 #define UI2_MAX 0xffff
86 #define I4_MAX 0x7fffffff
87 #define I4_MIN ((-I4_MAX)-1)
88 #define UI4_MAX 0xffffffff
90 #define I8_MAX (((LONGLONG)I4_MAX << 32) | UI4_MAX)
91 #define I8_MIN ((-I8_MAX)-1)
92 #define UI8_MAX (((ULONGLONG)UI4_MAX << 32) | UI4_MAX)
94 #define DATE_MAX 2958465
95 #define DATE_MIN -657434
96 #define R4_MAX FLT_MAX
97 #define R4_MIN FLT_MIN
98 #define R8_MAX DBL_MAX
99 #define R8_MIN DBL_MIN
101 static void init(void)
106 res = VarBstrFromBool(VARIANT_TRUE, LANG_USER_DEFAULT, VAR_LOCALBOOL, &bstr);
107 ok(SUCCEEDED(res) && (lstrlenW(bstr) > 0),
108 "Expected localized string for 'True'\n");
109 /* lstrcpyW / lstrcatW do not work on win95 */
110 memcpy(sz12_true, sz12, sizeof(sz12));
111 if (bstr) memcpy(&sz12_true[2], bstr, SysStringByteLen(bstr) + sizeof(WCHAR));
114 res = VarBstrFromBool(VARIANT_FALSE, LANG_USER_DEFAULT, VAR_LOCALBOOL, &bstr);
115 ok(SUCCEEDED(res) && (lstrlenW(bstr) > 0),
116 "Expected localized string for 'False'\n");
117 memcpy(sz12_false, sz12, sizeof(sz12));
118 if (bstr) memcpy(&sz12_false[2], bstr, SysStringByteLen(bstr) + sizeof(WCHAR));
121 hOleaut32 = GetModuleHandle("oleaut32.dll");
123 /* Is a given function exported from oleaut32? */
124 #define HAVE_FUNC(func) ((void*)GetProcAddress(hOleaut32, #func) != NULL)
126 HAVE_OLEAUT32_I8 = HAVE_FUNC(VarI8FromI1);
127 if (!HAVE_OLEAUT32_I8)
128 skip("No support for I8 and UI8 data types\n");
130 HAVE_OLEAUT32_RECORD = HAVE_FUNC(SafeArraySetRecordInfo);
131 IS_ANCIENT = (!HAVE_FUNC(VarI1FromI2));
136 /* Functions to set a DECIMAL */
137 static void setdec(DECIMAL* dec, BYTE scl, BYTE sgn, ULONG hi32, ULONG64 lo64)
139 S(U(*dec)).scale = scl;
140 S(U(*dec)).sign = sgn;
142 U1(*dec).Lo64 = lo64;
145 static void setdec64(DECIMAL* dec, BYTE scl, BYTE sgn, ULONG hi32, ULONG mid32, ULONG lo32)
147 S(U(*dec)).scale = scl;
148 S(U(*dec)).sign = sgn;
150 S1(U1(*dec)).Mid32 = mid32;
151 S1(U1(*dec)).Lo32 = lo32;
154 static inline int strcmpW( const WCHAR *str1, const WCHAR *str2 )
156 while (*str1 && (*str1 == *str2)) { str1++; str2++; }
157 return *str1 - *str2;
160 /* return the string text of a given variant type */
161 static char vtstr_buffer[16][256];
162 static int vtstr_current=0;
163 static const char *vtstr(int x)
166 #define CASE(vt) case VT_##vt: return #vt
205 CASE(STREAMED_OBJECT);
210 CASE(VERSIONED_STREAM);
219 return "VT_BSTR_BLOB/VT_ILLEGALMASKED/VT_TYPEMASK";
222 vtstr_current %= sizeof(vtstr_buffer)/sizeof(*vtstr_buffer);
223 sprintf(vtstr_buffer[vtstr_current], "unknown variant type %d", x);
224 return vtstr_buffer[vtstr_current++];
228 static const char *variantstr( const VARIANT *var )
230 vtstr_current %= sizeof(vtstr_buffer)/sizeof(*vtstr_buffer);
234 sprintf( vtstr_buffer[vtstr_current], "VT_I1(%d)", V_I1(var) ); break;
236 sprintf( vtstr_buffer[vtstr_current], "VT_I2(%d)", V_I2(var) ); break;
238 sprintf( vtstr_buffer[vtstr_current], "VT_I4(%d)", V_I4(var) ); break;
240 sprintf( vtstr_buffer[vtstr_current], "VT_INT(%d)", V_INT(var) ); break;
242 sprintf( vtstr_buffer[vtstr_current], "VT_I8(%x%08x)", (UINT)(V_I8(var) >> 32), (UINT)V_I8(var) ); break;
244 sprintf( vtstr_buffer[vtstr_current], "VT_UI8(%x%08x)", (UINT)(V_UI8(var) >> 32), (UINT)V_UI8(var) ); break;
246 sprintf( vtstr_buffer[vtstr_current], "VT_R4(%g)", V_R4(var) ); break;
248 sprintf( vtstr_buffer[vtstr_current], "VT_R8(%g)", V_R8(var) ); break;
250 sprintf( vtstr_buffer[vtstr_current], "VT_UI1(%u)", V_UI1(var) ); break;
252 sprintf( vtstr_buffer[vtstr_current], "VT_UI2(%u)", V_UI2(var) ); break;
254 sprintf( vtstr_buffer[vtstr_current], "VT_UI4(%u)", V_UI4(var) ); break;
256 sprintf( vtstr_buffer[vtstr_current], "VT_UINT(%d)", V_UINT(var) ); break;
258 sprintf( vtstr_buffer[vtstr_current], "VT_CY(%x%08x)", S(V_CY(var)).Hi, S(V_CY(var)).Lo ); break;
260 sprintf( vtstr_buffer[vtstr_current], "VT_DATE(%g)", V_DATE(var) ); break;
262 return vtstr(V_VT(var));
264 return vtstr_buffer[vtstr_current++];
267 static BOOL is_expected_variant( const VARIANT *result, const VARIANT *expected )
269 if (V_VT(result) != V_VT(expected)) return FALSE;
270 switch(V_VT(expected))
276 #define CASE(vt) case VT_##vt: return (V_##vt(result) == V_##vt(expected))
291 return EQ_FLOAT(V_DATE(result), V_DATE(expected));
293 return EQ_FLOAT(V_R4(result), V_R4(expected));
295 return EQ_FLOAT(V_R8(result), V_R8(expected));
297 return (V_CY(result).int64 == V_CY(expected).int64);
299 return !lstrcmpW( V_BSTR(result), V_BSTR(expected) );
301 return !memcmp( &V_DECIMAL(result), &V_DECIMAL(expected), sizeof(DECIMAL) );
303 ok(0, "unhandled variant type %s\n",vtstr(V_VT(expected)));
308 static void test_var_call1( int line, HRESULT (WINAPI *func)(LPVARIANT,LPVARIANT),
309 VARIANT *arg, VARIANT *expected )
311 VARIANT old_arg = *arg;
315 memset( &result, 0, sizeof(result) );
316 hres = func( arg, &result );
317 ok_(__FILE__,line)( hres == S_OK, "wrong result %x\n", hres );
319 ok_(__FILE__,line)( is_expected_variant( &result, expected ),
320 "got %s expected %s\n", variantstr(&result), variantstr(expected) );
321 ok_(__FILE__,line)( is_expected_variant( arg, &old_arg ), "Modified argument %s / %s\n",
322 variantstr(&old_arg), variantstr(arg));
323 VariantClear( &result );
326 static void test_var_call2( int line, HRESULT (WINAPI *func)(LPVARIANT,LPVARIANT,LPVARIANT),
327 VARIANT *left, VARIANT *right, VARIANT *expected )
329 VARIANT old_left = *left, old_right = *right;
333 memset( &result, 0, sizeof(result) );
334 hres = func( left, right, &result );
335 ok_(__FILE__,line)( hres == S_OK, "wrong result %x\n", hres );
337 ok_(__FILE__,line)( is_expected_variant( &result, expected ),
338 "got %s expected %s\n", variantstr(&result), variantstr(expected) );
339 ok_(__FILE__,line)( is_expected_variant( left, &old_left ), "Modified left argument %s / %s\n",
340 variantstr(&old_left), variantstr(left));
341 ok_(__FILE__,line)( is_expected_variant( right, &old_right ), "Modified right argument %s / %s\n",
342 variantstr(&old_right), variantstr(right));
343 VariantClear( &result );
347 static void test_VariantInit(void)
351 /* Test that VariantInit() only sets the type */
352 memset(&v1, -1, sizeof(v1));
354 V_VT(&v2) = VT_EMPTY;
356 ok(!memcmp(&v1, &v2, sizeof(v1)), "VariantInit() set extra fields\n");
359 /* All possible combinations of extra V_VT() flags */
360 static const VARTYPE ExtraFlags[16] =
369 VT_VECTOR|VT_RESERVED,
370 VT_VECTOR|VT_ARRAY|VT_BYREF,
371 VT_VECTOR|VT_ARRAY|VT_RESERVED,
372 VT_VECTOR|VT_BYREF|VT_RESERVED,
373 VT_VECTOR|VT_ARRAY|VT_BYREF|VT_RESERVED,
375 VT_ARRAY|VT_RESERVED,
376 VT_ARRAY|VT_BYREF|VT_RESERVED,
377 VT_BYREF|VT_RESERVED,
380 /* Determine if a vt is valid for VariantClear() */
381 static int IsValidVariantClearVT(VARTYPE vt, VARTYPE extraFlags)
385 /* Only the following flags/types are valid */
386 if ((vt <= VT_LPWSTR || vt == VT_RECORD || vt == VT_CLSID) &&
388 (vt < (VARTYPE)24 || vt > (VARTYPE)31) &&
389 (!(extraFlags & (VT_BYREF|VT_ARRAY)) || vt > VT_NULL) &&
390 (extraFlags == 0 || extraFlags == VT_BYREF || extraFlags == VT_ARRAY ||
391 extraFlags == (VT_ARRAY|VT_BYREF)))
394 if ((vt == VT_RECORD && !HAVE_OLEAUT32_RECORD) ||
395 ((vt == VT_I8 || vt == VT_UI8) && !HAVE_OLEAUT32_I8))
396 ret = 0; /* Old versions of oleaut32 */
402 const IUnknownVtbl *lpVtbl;
405 } test_VariantClearImpl;
407 static HRESULT WINAPI VC_QueryInterface(LPUNKNOWN iface,REFIID riid,LPVOID *ppobj)
409 test_VariantClearImpl *This = (test_VariantClearImpl *)iface;
411 return E_NOINTERFACE;
414 static ULONG WINAPI VC_AddRef(LPUNKNOWN iface) {
415 test_VariantClearImpl *This = (test_VariantClearImpl *)iface;
417 return InterlockedIncrement(&This->ref);
420 static ULONG WINAPI VC_Release(LPUNKNOWN iface) {
421 test_VariantClearImpl *This = (test_VariantClearImpl *)iface;
422 /* static class, won't be freed */
424 return InterlockedDecrement(&This->ref);
427 static const IUnknownVtbl test_VariantClear_vtbl = {
433 static test_VariantClearImpl test_myVariantClearImpl = {&test_VariantClear_vtbl, 1, 0};
435 static void test_VariantClear(void)
444 /* Crashes: Native does not test input for NULL, so neither does Wine */
445 if (0) hres = VariantClear(NULL);
447 /* Only the type field is set, to VT_EMPTY */
450 hres = VariantClear(&v);
451 ok((hres == S_OK && V_VT(&v) == VT_EMPTY) ||
452 (IS_ANCIENT && hres == DISP_E_BADVARTYPE && V_VT(&v) == VT_UI4),
453 "VariantClear: Type set to %d, res %08x\n", V_VT(&v), hres);
454 ok(V_UI4(&v) == ~0u, "VariantClear: Overwrote value\n");
456 /* Test all possible V_VT values.
457 * Also demonstrates that null pointers in 'v' are not dereferenced.
458 * Individual variant tests should test VariantClear() with non-NULL values.
460 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]) && !IS_ANCIENT; i++)
464 for (vt = 0; vt <= VT_BSTR_BLOB; vt++)
466 HRESULT hExpected = DISP_E_BADVARTYPE;
470 memset(&v, 0, sizeof(v));
471 V_VT(&v) = vt | ExtraFlags[i];
473 hres = VariantClear(&v);
475 if (IsValidVariantClearVT(vt, ExtraFlags[i]))
478 ok(hres == hExpected, "VariantClear: expected 0x%X, got 0x%X for vt %d | 0x%X\n",
479 hExpected, hres, vt, ExtraFlags[i]);
483 /* Some BYREF tests with non-NULL ptrs */
488 V_VT(&v) = VT_VARIANT | VT_BYREF;
489 V_VARIANTREF(&v) = &v2;
491 hres = VariantClear(&v);
492 ok(hres == S_OK, "ret %08x\n", hres);
493 ok(V_VT(&v) == 0, "vt %04x\n", V_VT(&v));
494 ok(V_VARIANTREF(&v) == &v2, "variant ref %p\n", V_VARIANTREF(&v2));
495 ok(V_VT(&v2) == VT_I4, "vt %04x\n", V_VT(&v2));
496 ok(V_I4(&v2) == 0x1234, "i4 %04x\n", V_I4(&v2));
500 V_VT(&v) = VT_I4 | VT_BYREF;
503 hres = VariantClear(&v);
504 ok(hres == S_OK, "ret %08x\n", hres);
505 ok(V_VT(&v) == 0, "vt %04x\n", V_VT(&v));
506 ok(V_I4REF(&v) == &i4, "i4 ref %p\n", V_I4REF(&v2));
507 ok(i4 == 0x4321, "i4 changed %08x\n", i4);
511 V_VT(&v) = VT_UNKNOWN;
512 V_UNKNOWN(&v) = (IUnknown*)&test_myVariantClearImpl;
513 test_myVariantClearImpl.events = 0;
514 hres = VariantClear(&v);
515 ok(hres == S_OK, "ret %08x\n", hres);
516 ok(V_VT(&v) == 0, "vt %04x\n", V_VT(&v));
517 ok(V_UNKNOWN(&v) == (IUnknown*)&test_myVariantClearImpl, "unknown %p\n", V_UNKNOWN(&v));
518 /* Check that Release got called, but nothing else */
519 ok(test_myVariantClearImpl.events == 0x4, "Unexpected call. events %08x\n", test_myVariantClearImpl.events);
522 punk = (IUnknown*)&test_myVariantClearImpl;
523 V_VT(&v) = VT_UNKNOWN | VT_BYREF;
524 V_UNKNOWNREF(&v) = &punk;
525 test_myVariantClearImpl.events = 0;
526 hres = VariantClear(&v);
527 ok(hres == S_OK, "ret %08x\n", hres);
528 ok(V_VT(&v) == 0, "vt %04x\n", V_VT(&v));
529 ok(V_UNKNOWNREF(&v) == &punk, "unknown ref %p\n", V_UNKNOWNREF(&v));
530 /* Check that nothing got called */
531 ok(test_myVariantClearImpl.events == 0, "Unexpected call. events %08x\n", test_myVariantClearImpl.events);
534 V_VT(&v) = VT_DISPATCH;
535 V_DISPATCH(&v) = (IDispatch*)&test_myVariantClearImpl;
536 test_myVariantClearImpl.events = 0;
537 hres = VariantClear(&v);
538 ok(hres == S_OK, "ret %08x\n", hres);
539 ok(V_VT(&v) == 0, "vt %04x\n", V_VT(&v));
540 ok(V_DISPATCH(&v) == (IDispatch*)&test_myVariantClearImpl, "dispatch %p\n", V_DISPATCH(&v));
541 /* Check that Release got called, but nothing else */
542 ok(test_myVariantClearImpl.events == 0x4, "Unexpected call. events %08x\n", test_myVariantClearImpl.events);
545 punk = (IUnknown*)&test_myVariantClearImpl;
546 V_VT(&v) = VT_DISPATCH | VT_BYREF;
547 V_DISPATCHREF(&v) = (IDispatch**)&punk;
548 test_myVariantClearImpl.events = 0;
549 hres = VariantClear(&v);
550 ok(hres == S_OK, "ret %08x\n", hres);
551 ok(V_VT(&v) == 0, "vt %04x\n", V_VT(&v));
552 ok(V_DISPATCHREF(&v) == (IDispatch**)&punk, "dispatch ref %p\n", V_DISPATCHREF(&v));
553 /* Check that nothing got called */
554 ok(test_myVariantClearImpl.events == 0, "Unexpected call. events %08x\n", test_myVariantClearImpl.events);
557 static void test_VariantCopy(void)
559 VARIANTARG vSrc, vDst;
562 HRESULT hres, hExpected;
564 /* Establish that the failure/other cases are dealt with. Individual tests
565 * for each type should verify that data is copied correctly, references
570 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]) && !IS_ANCIENT; i++)
572 for (vt = 0; vt <= VT_BSTR_BLOB; vt++)
576 memset(&vSrc, 0, sizeof(vSrc));
577 V_VT(&vSrc) = vt | ExtraFlags[i];
579 hExpected = DISP_E_BADVARTYPE;
580 /* src is allowed to be a VT_CLSID */
581 if (vt != VT_CLSID && IsValidVariantClearVT(vt, ExtraFlags[i]))
584 hres = VariantCopy(&vSrc, &vSrc);
586 ok(hres == hExpected,
587 "Copy(src==dst): expected 0x%X, got 0x%X for src==dest vt %d|0x%X\n",
588 hExpected, hres, vt, ExtraFlags[i]);
592 /* Test that if VariantClear() fails on dest, the function fails. This also
593 * shows that dest is in fact cleared and not just overwritten
595 memset(&vSrc, 0, sizeof(vSrc));
596 V_VT(&vSrc) = VT_UI1;
598 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]) && !IS_ANCIENT; i++)
600 for (vt = 0; vt <= VT_BSTR_BLOB; vt++)
604 hExpected = DISP_E_BADVARTYPE;
606 memset(&vDst, 0, sizeof(vDst));
607 V_VT(&vDst) = vt | ExtraFlags[i];
609 if (IsValidVariantClearVT(vt, ExtraFlags[i]))
612 hres = VariantCopy(&vDst, &vSrc);
614 ok(hres == hExpected,
615 "Copy(bad dst): expected 0x%X, got 0x%X for dest vt %d|0x%X\n",
616 hExpected, hres, vt, ExtraFlags[i]);
618 ok(V_VT(&vDst) == VT_UI1,
619 "Copy(bad dst): expected vt = VT_UI1, got %d\n", V_VT(&vDst));
623 /* Test that VariantClear() checks vSrc for validity before copying */
624 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]) && !IS_ANCIENT; i++)
626 for (vt = 0; vt <= VT_BSTR_BLOB; vt++)
630 hExpected = DISP_E_BADVARTYPE;
632 memset(&vDst, 0, sizeof(vDst));
633 V_VT(&vDst) = VT_EMPTY;
635 memset(&vSrc, 0, sizeof(vSrc));
636 V_VT(&vSrc) = vt | ExtraFlags[i];
638 /* src is allowed to be a VT_CLSID */
639 if (vt != VT_CLSID && IsValidVariantClearVT(vt, ExtraFlags[i]))
642 hres = VariantCopy(&vDst, &vSrc);
644 ok(hres == hExpected,
645 "Copy(bad src): expected 0x%X, got 0x%X for src vt %d|0x%X\n",
646 hExpected, hres, vt, ExtraFlags[i]);
649 ok(V_VT(&vDst) == (vt|ExtraFlags[i]),
650 "Copy(bad src): expected vt = %d, got %d\n",
651 vt | ExtraFlags[i], V_VT(&vDst));
657 /* Test that copying a NULL BSTR results in an empty BSTR */
658 memset(&vDst, 0, sizeof(vDst));
659 V_VT(&vDst) = VT_EMPTY;
660 memset(&vSrc, 0, sizeof(vSrc));
661 V_VT(&vSrc) = VT_BSTR;
662 hres = VariantCopy(&vDst, &vSrc);
663 ok(hres == S_OK, "Copy(NULL BSTR): Failed to copy a NULL BSTR\n");
666 ok((V_VT(&vDst) == VT_BSTR) && V_BSTR(&vDst),
667 "Copy(NULL BSTR): should have non-NULL result\n");
668 if ((V_VT(&vDst) == VT_BSTR) && V_BSTR(&vDst))
670 ok(*V_BSTR(&vDst) == 0, "Copy(NULL BSTR): result not empty\n");
676 /* Determine if a vt is valid for VariantCopyInd() */
677 static int IsValidVariantCopyIndVT(VARTYPE vt, VARTYPE extraFlags)
681 if ((extraFlags & VT_ARRAY) ||
682 (vt > VT_NULL && vt != (VARTYPE)15 && vt < VT_VOID &&
683 !(extraFlags & (VT_VECTOR|VT_RESERVED))))
690 static void test_VariantCopyInd(void)
692 VARIANTARG vSrc, vDst, vRef, vRef2;
696 HRESULT hres, hExpected;
698 memset(buffer, 0, sizeof(buffer));
701 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]) && !IS_ANCIENT; i++)
703 if (ExtraFlags[i] & VT_ARRAY)
704 continue; /* Native crashes on NULL safearray */
706 for (vt = 0; vt <= VT_BSTR_BLOB; vt++)
710 memset(&vSrc, 0, sizeof(vSrc));
711 V_VT(&vSrc) = vt | ExtraFlags[i];
713 hExpected = DISP_E_BADVARTYPE;
714 if (!(ExtraFlags[i] & VT_BYREF))
716 /* if src is not by-reference, acts as VariantCopy() */
717 if (vt != VT_CLSID && IsValidVariantClearVT(vt, ExtraFlags[i]))
722 if (vt == VT_SAFEARRAY || vt == VT_BSTR || vt == VT_UNKNOWN ||
723 vt == VT_DISPATCH || vt == VT_RECORD)
724 continue; /* Need valid ptrs for deep copies */
726 V_BYREF(&vSrc) = &buffer;
727 hExpected = E_INVALIDARG;
729 if ((vt == VT_I8 || vt == VT_UI8) &&
730 ExtraFlags[i] == VT_BYREF)
732 if (HAVE_OLEAUT32_I8)
733 hExpected = S_OK; /* Only valid if I8 is a known type */
735 else if (IsValidVariantCopyIndVT(vt, ExtraFlags[i]))
739 hres = VariantCopyInd(&vSrc, &vSrc);
741 ok(hres == hExpected,
742 "CopyInd(src==dst): expected 0x%X, got 0x%X for src==dst vt %d|0x%X\n",
743 hExpected, hres, vt, ExtraFlags[i]);
748 memset(&vSrc, 0, sizeof(vSrc));
749 V_VT(&vSrc) = VT_UI1|VT_BYREF;
750 V_BYREF(&vSrc) = &buffer;
752 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]) && !IS_ANCIENT; i++)
754 for (vt = 0; vt <= VT_BSTR_BLOB; vt++)
758 memset(&vDst, 0, sizeof(vDst));
759 V_VT(&vDst) = vt | ExtraFlags[i];
761 hExpected = DISP_E_BADVARTYPE;
763 if (IsValidVariantClearVT(vt, ExtraFlags[i]))
766 hres = VariantCopyInd(&vDst, &vSrc);
768 ok(hres == hExpected,
769 "CopyInd(bad dst): expected 0x%X, got 0x%X for dst vt %d|0x%X\n",
770 hExpected, hres, vt, ExtraFlags[i]);
772 ok(V_VT(&vDst) == VT_UI1,
773 "CopyInd(bad dst): expected vt = VT_UI1, got %d\n", V_VT(&vDst));
778 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]) && !IS_ANCIENT; i++)
780 if (ExtraFlags[i] & VT_ARRAY)
781 continue; /* Native crashes on NULL safearray */
783 for (vt = 0; vt <= VT_BSTR_BLOB; vt++)
787 memset(&vDst, 0, sizeof(vDst));
788 V_VT(&vDst) = VT_EMPTY;
790 memset(&vSrc, 0, sizeof(vSrc));
791 V_VT(&vSrc) = vt | ExtraFlags[i];
793 hExpected = DISP_E_BADVARTYPE;
794 if (!(ExtraFlags[i] & VT_BYREF))
796 /* if src is not by-reference, acts as VariantCopy() */
797 if (vt != VT_CLSID && IsValidVariantClearVT(vt, ExtraFlags[i]))
802 if (vt == VT_SAFEARRAY || vt == VT_BSTR || vt == VT_UNKNOWN ||
803 vt == VT_DISPATCH || vt == VT_RECORD)
804 continue; /* Need valid ptrs for deep copies, see vartype.c */
806 V_BYREF(&vSrc) = &buffer;
808 hExpected = E_INVALIDARG;
810 if ((vt == VT_I8 || vt == VT_UI8) &&
811 ExtraFlags[i] == VT_BYREF)
813 if (HAVE_OLEAUT32_I8)
814 hExpected = S_OK; /* Only valid if I8 is a known type */
816 else if (IsValidVariantCopyIndVT(vt, ExtraFlags[i]))
820 hres = VariantCopyInd(&vDst, &vSrc);
822 ok(hres == hExpected,
823 "CopyInd(bad src): expected 0x%X, got 0x%X for src vt %d|0x%X\n",
824 hExpected, hres, vt, ExtraFlags[i]);
827 if (vt == VT_VARIANT && ExtraFlags[i] == VT_BYREF)
829 /* Type of vDst should be the type of the referenced variant.
830 * Since we set the buffer to all zeros, its type should be
833 ok(V_VT(&vDst) == VT_EMPTY,
834 "CopyInd(bad src): expected dst vt = VT_EMPTY, got %d|0x%X\n",
835 V_VT(&vDst) & VT_TYPEMASK, V_VT(&vDst) & ~VT_TYPEMASK);
839 ok(V_VT(&vDst) == (vt|(ExtraFlags[i] & ~VT_BYREF)),
840 "CopyInd(bad src): expected dst vt = %d|0x%X, got %d|0x%X\n",
841 vt, ExtraFlags[i] & ~VT_BYREF,
842 V_VT(&vDst) & VT_TYPEMASK, V_VT(&vDst) & ~VT_TYPEMASK);
849 /* By-reference variants are dereferenced */
850 V_VT(&vRef) = VT_UI1;
852 V_VT(&vSrc) = VT_VARIANT|VT_BYREF;
853 V_VARIANTREF(&vSrc) = &vRef;
856 hres = VariantCopyInd(&vDst, &vSrc);
857 ok(V_VT(&vDst) == VT_UI1 && V_UI1(&vDst) == 0x77,
858 "CopyInd(deref): expected dst vt = VT_UI1, val 0x77, got %d|0x%X, 0x%2X\n",
859 V_VT(&vDst) & VT_TYPEMASK, V_VT(&vDst) & ~VT_TYPEMASK, V_UI1(&vDst));
861 /* By-reference variant to a by-reference type succeeds */
862 V_VT(&vRef) = VT_UI1|VT_BYREF;
863 V_UI1REF(&vRef) = buffer; buffer[0] = 0x88;
864 V_VT(&vSrc) = VT_VARIANT|VT_BYREF;
865 V_VARIANTREF(&vSrc) = &vRef;
868 hres = VariantCopyInd(&vDst, &vSrc);
869 ok(V_VT(&vDst) == VT_UI1 && V_UI1(&vDst) == 0x88,
870 "CopyInd(deref): expected dst vt = VT_UI1, val 0x77, got %d|0x%X, 0x%2X\n",
871 V_VT(&vDst) & VT_TYPEMASK, V_VT(&vDst) & ~VT_TYPEMASK, V_UI1(&vDst));
873 /* But a by-reference variant to a by-reference variant fails */
874 V_VT(&vRef2) = VT_UI1;
875 V_UI1(&vRef2) = 0x77;
876 V_VT(&vRef) = VT_VARIANT|VT_BYREF;
877 V_VARIANTREF(&vRef) = &vRef2;
878 V_VT(&vSrc) = VT_VARIANT|VT_BYREF;
879 V_VARIANTREF(&vSrc) = &vRef;
882 hres = VariantCopyInd(&vDst, &vSrc);
883 ok(hres == E_INVALIDARG,
884 "CopyInd(ref->ref): expected E_INVALIDARG, got 0x%08x\n", hres);
887 static HRESULT (WINAPI *pVarParseNumFromStr)(OLECHAR*,LCID,ULONG,NUMPARSE*,BYTE*);
889 /* Macros for converting and testing the result of VarParseNumFromStr */
892 static HRESULT convert_str( const char *str, INT dig, ULONG flags,
893 NUMPARSE *np, BYTE rgb[128], LCID lcid )
896 MultiByteToWideChar( CP_ACP,0, str, -1, buff, sizeof(buff)/sizeof(WCHAR) );
897 memset( rgb, FAILDIG, 128 );
898 memset( np, 255, sizeof(*np) );
900 np->dwInFlags = flags;
901 return pVarParseNumFromStr( buff, lcid, LOCALE_NOUSEROVERRIDE, np, rgb);
904 static void expect_NumFromStr( int line, HRESULT hres, NUMPARSE *np, INT a, ULONG b, ULONG c,
905 INT d, INT e, INT f )
907 if (hres == (HRESULT)S_OK)
909 ok_(__FILE__,line)(np->cDig == a, "Expected cDig = %d, got %d\n", a, np->cDig);
910 ok_(__FILE__,line)(np->dwInFlags == b, "Expected dwInFlags = 0x%x, got 0x%x\n", b, np->dwInFlags);
911 ok_(__FILE__,line)(np->dwOutFlags == c, "Expected dwOutFlags = 0x%x, got 0x%x\n", c, np->dwOutFlags);
912 ok_(__FILE__,line)(np->cchUsed == d, "Expected cchUsed = %d, got %d\n", d, np->cchUsed);
913 ok_(__FILE__,line)(np->nBaseShift == e, "Expected nBaseShift = %d, got %d\n", e, np->nBaseShift);
914 ok_(__FILE__,line)(np->nPwr10 == f, "Expected nPwr10 = %d, got %d\n", f, np->nPwr10);
918 #define CONVERTN(str,dig,flags) hres = convert_str( str, dig, flags, &np, rgb, lcid )
919 #define CONVERT(str,flags) CONVERTN(str,sizeof(rgb),flags)
920 #define EXPECT(a,b,c,d,e,f) expect_NumFromStr( __LINE__, hres, &np, a, b, c, d, e, f )
921 #define EXPECTRGB(a,b) ok(rgb[a] == b, "Digit[%d], expected %d, got %d\n", a, b, rgb[a])
922 #define EXPECTFAIL ok(hres == (HRESULT)DISP_E_TYPEMISMATCH, "Call succeeded, hres = %08x\n", hres)
923 #define EXPECT2(a,b) EXPECTRGB(0,a); EXPECTRGB(1,b)
925 static void test_VarParseNumFromStr(void)
928 /* Ensure all tests are using the same locale characters for '$', ',' etc */
929 LCID lcid = MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT);
935 CHECKPTR(VarParseNumFromStr);
937 /* Consume a single digit */
942 /* cDig is not literal digits - zeros are suppressed and nPwr10 is increased */
945 /* Note: Win32 writes the trailing zeros if they are within cDig's limits,
946 * but then excludes them from the returned cDig count.
947 * In our implementation we don't bother writing them at all.
951 /* if cDig is too small and numbers follow, sets INEXACT */
953 EXPECT(1,0,NUMPRS_INEXACT,2,0,1);
956 /* Strips leading zeros */
961 /* Strips leading zeros */
967 /* Fails on non digits */
970 EXPECTRGB(0,FAILDIG);
972 /** NUMPRS_LEADING_WHITE/NUMPRS_TRAILING_WHITE **/
974 /* Without flag, fails on whitespace */
977 EXPECTRGB(0,FAILDIG);
980 /* With flag, consumes whitespace */
981 CONVERT(" 0", NUMPRS_LEADING_WHITE);
982 EXPECT(1,NUMPRS_LEADING_WHITE,NUMPRS_LEADING_WHITE,2,0,0);
985 /* Test TAB once, then assume it acts as space for all cases */
986 CONVERT("\t0", NUMPRS_LEADING_WHITE);
987 EXPECT(1,NUMPRS_LEADING_WHITE,NUMPRS_LEADING_WHITE,2,0,0);
991 /* Doesn't pick up trailing whitespace without flag */
996 /* With flag, consumes trailing whitespace */
997 CONVERT("0 ", NUMPRS_TRAILING_WHITE);
998 EXPECT(1,NUMPRS_TRAILING_WHITE,NUMPRS_TRAILING_WHITE,2,0,0);
1001 /* Leading flag only consumes leading */
1002 CONVERT(" 0 ", NUMPRS_LEADING_WHITE);
1003 EXPECT(1,NUMPRS_LEADING_WHITE,NUMPRS_LEADING_WHITE,2,0,0);
1006 /* Both flags consumes both */
1007 CONVERT(" 0 ", NUMPRS_LEADING_WHITE|NUMPRS_TRAILING_WHITE);
1008 EXPECT(1,NUMPRS_LEADING_WHITE|NUMPRS_TRAILING_WHITE,NUMPRS_LEADING_WHITE|NUMPRS_TRAILING_WHITE,3,0,0);
1011 /** NUMPRS_LEADING_PLUS/NUMPRS_TRAILING_PLUS **/
1013 /* Without flag, fails on + */
1016 EXPECTRGB(0,FAILDIG);
1018 /* With flag, consumes + */
1019 CONVERT("+0", NUMPRS_LEADING_PLUS);
1020 EXPECT(1,NUMPRS_LEADING_PLUS,NUMPRS_LEADING_PLUS,2,0,0);
1023 /* Without flag, doesn't consume trailing + */
1025 EXPECT(1,0,0,1,0,0);
1028 /* With flag, consumes trailing + */
1029 CONVERT("0+", NUMPRS_TRAILING_PLUS);
1030 EXPECT(1,NUMPRS_TRAILING_PLUS,NUMPRS_TRAILING_PLUS,2,0,0);
1033 /* With leading flag, doesn't consume trailing + */
1034 CONVERT("+0+", NUMPRS_LEADING_PLUS);
1035 EXPECT(1,NUMPRS_LEADING_PLUS,NUMPRS_LEADING_PLUS,2,0,0);
1038 /* Trailing + doesn't get consumed if we specify both (unlike whitespace) */
1039 CONVERT("+0+", NUMPRS_LEADING_PLUS|NUMPRS_TRAILING_PLUS);
1040 EXPECT(1,NUMPRS_LEADING_PLUS|NUMPRS_TRAILING_PLUS,NUMPRS_LEADING_PLUS,2,0,0);
1043 /** NUMPRS_LEADING_MINUS/NUMPRS_TRAILING_MINUS **/
1045 /* Without flag, fails on - */
1048 EXPECTRGB(0,FAILDIG);
1050 /* With flag, consumes - */
1051 CONVERT("-0", NUMPRS_LEADING_MINUS);
1052 EXPECT(1,NUMPRS_LEADING_MINUS,NUMPRS_NEG|NUMPRS_LEADING_MINUS,2,0,0);
1055 /* Without flag, doesn't consume trailing - */
1057 EXPECT(1,0,0,1,0,0);
1060 /* With flag, consumes trailing - */
1061 CONVERT("0-", NUMPRS_TRAILING_MINUS);
1062 EXPECT(1,NUMPRS_TRAILING_MINUS,NUMPRS_NEG|NUMPRS_TRAILING_MINUS,2,0,0);
1065 /* With leading flag, doesn't consume trailing - */
1066 CONVERT("-0-", NUMPRS_LEADING_MINUS);
1067 EXPECT(1,NUMPRS_LEADING_MINUS,NUMPRS_NEG|NUMPRS_LEADING_MINUS,2,0,0);
1070 /* Trailing - doesn't get consumed if we specify both (unlike whitespace) */
1071 CONVERT("-0-", NUMPRS_LEADING_MINUS|NUMPRS_TRAILING_MINUS);
1072 EXPECT(1,NUMPRS_LEADING_MINUS|NUMPRS_TRAILING_MINUS,NUMPRS_NEG|NUMPRS_LEADING_MINUS,2,0,0);
1075 /** NUMPRS_HEX_OCT **/
1077 /* Could be hex, octal or decimal - With flag reads as decimal */
1078 CONVERT("0", NUMPRS_HEX_OCT);
1079 EXPECT(1,NUMPRS_HEX_OCT,0,1,0,0);
1082 /* Doesn't recognise hex in .asm syntax */
1083 CONVERT("0h", NUMPRS_HEX_OCT);
1084 EXPECT(1,NUMPRS_HEX_OCT,0,1,0,0);
1087 /* Doesn't fail with valid leading string but no digits */
1088 CONVERT("0x", NUMPRS_HEX_OCT);
1089 EXPECT(1,NUMPRS_HEX_OCT,0,1,0,0);
1092 /* Doesn't recognise hex format numbers at all! */
1093 CONVERT("0x0", NUMPRS_HEX_OCT);
1094 EXPECT(1,NUMPRS_HEX_OCT,0,1,0,0);
1097 /* Doesn't recognise plain hex digits either */
1098 CONVERT("FE", NUMPRS_HEX_OCT);
1100 EXPECTRGB(0,FAILDIG);
1103 CONVERT("0100", NUMPRS_HEX_OCT);
1104 EXPECT(1,NUMPRS_HEX_OCT,0,4,0,2);
1108 EXPECTRGB(3,FAILDIG);
1111 CONVERT("&HF800", NUMPRS_HEX_OCT);
1112 EXPECT(4,NUMPRS_HEX_OCT,0x40,6,4,0);
1117 EXPECTRGB(4,FAILDIG);
1119 /* VB hex lower case and leading zero */
1120 CONVERT("&h0abcdef", NUMPRS_HEX_OCT);
1121 EXPECT(6,NUMPRS_HEX_OCT,0x40,9,4,0);
1128 EXPECTRGB(6,FAILDIG);
1131 CONVERT("&O300", NUMPRS_HEX_OCT);
1132 EXPECT(3,NUMPRS_HEX_OCT,0x40,5,3,0);
1136 EXPECTRGB(3,FAILDIG);
1138 /* VB oct lower case and leading zero */
1139 CONVERT("&o0777", NUMPRS_HEX_OCT);
1140 EXPECT(3,NUMPRS_HEX_OCT,0x40,6,3,0);
1144 EXPECTRGB(3,FAILDIG);
1146 /* VB oct char bigger than 7 */
1147 CONVERT("&o128", NUMPRS_HEX_OCT);
1149 Native versions 2.x of oleaut32 allow this to succeed: later versions and Wine don't
1151 EXPECTRGB(0,FAILDIG);
1153 /** NUMPRS_PARENS **/
1155 /* Empty parens = error */
1156 CONVERT("()", NUMPRS_PARENS);
1158 EXPECTRGB(0,FAILDIG);
1160 /* With flag, trailing parens not consumed */
1161 CONVERT("0()", NUMPRS_PARENS);
1162 EXPECT(1,NUMPRS_PARENS,0,1,0,0);
1165 /* With flag, Number in parens made negative and parens consumed */
1166 CONVERT("(0)", NUMPRS_PARENS);
1167 EXPECT(1,NUMPRS_PARENS,NUMPRS_NEG|NUMPRS_PARENS,3,0,0);
1170 /** NUMPRS_THOUSANDS **/
1172 /* With flag, thousands sep. not needed */
1173 CONVERT("0", NUMPRS_THOUSANDS);
1174 EXPECT(1,NUMPRS_THOUSANDS,0,1,0,0);
1177 /* With flag, thousands sep. and following digits consumed */
1178 CONVERT("1,000", NUMPRS_THOUSANDS);
1179 EXPECT(1,NUMPRS_THOUSANDS,NUMPRS_THOUSANDS,5,0,3);
1182 /* With flag and decimal point, thousands sep. but not decimals consumed */
1183 CONVERT("1,000.0", NUMPRS_THOUSANDS);
1184 EXPECT(1,NUMPRS_THOUSANDS,NUMPRS_THOUSANDS,5,0,3);
1187 /** NUMPRS_CURRENCY **/
1189 /* Without flag, chokes on currency sign */
1192 EXPECTRGB(0,FAILDIG);
1194 /* With flag, consumes currency sign */
1195 CONVERT("$11", NUMPRS_CURRENCY);
1196 EXPECT(2,NUMPRS_CURRENCY,NUMPRS_CURRENCY,3,0,0);
1198 EXPECTRGB(2,FAILDIG);
1200 /* With flag only, doesn't consume decimal point */
1201 CONVERT("$11.1", NUMPRS_CURRENCY);
1202 EXPECT(2,NUMPRS_CURRENCY,NUMPRS_CURRENCY,3,0,0);
1204 EXPECTRGB(2,FAILDIG);
1206 /* With flag and decimal flag, consumes decimal point and following digits */
1207 CONVERT("$11.1", NUMPRS_CURRENCY|NUMPRS_DECIMAL);
1208 EXPECT(3,NUMPRS_CURRENCY|NUMPRS_DECIMAL,NUMPRS_CURRENCY|NUMPRS_DECIMAL,5,0,-1);
1211 EXPECTRGB(3,FAILDIG);
1213 /* Thousands flag can only be used with currency */
1214 CONVERT("$1,234", NUMPRS_CURRENCY|NUMPRS_THOUSANDS);
1215 EXPECT(4,NUMPRS_CURRENCY|NUMPRS_THOUSANDS,NUMPRS_CURRENCY|NUMPRS_THOUSANDS,6,0,0);
1219 EXPECTRGB(4,FAILDIG);
1221 /** NUMPRS_DECIMAL **/
1223 /* With flag, consumes decimal point */
1224 CONVERT("1.1", NUMPRS_DECIMAL);
1225 EXPECT(2,NUMPRS_DECIMAL,NUMPRS_DECIMAL,3,0,-1);
1227 EXPECTRGB(2,FAILDIG);
1229 /* With flag, consumes decimal point. Skipping the decimal part is not an error */
1230 CONVERT("1.", NUMPRS_DECIMAL);
1231 EXPECT(1,NUMPRS_DECIMAL,NUMPRS_DECIMAL,2,0,0);
1234 /* Consumes only one decimal point */
1235 CONVERT("1.1.", NUMPRS_DECIMAL);
1236 EXPECT(2,NUMPRS_DECIMAL,NUMPRS_DECIMAL,3,0,-1);
1238 EXPECTRGB(2,FAILDIG);
1240 /** NUMPRS_EXPONENT **/
1242 /* Without flag, doesn't consume exponent */
1244 EXPECT(1,0,0,1,0,0);
1247 /* With flag, consumes exponent */
1248 CONVERT("1e1", NUMPRS_EXPONENT);
1249 EXPECT(1,NUMPRS_EXPONENT,NUMPRS_EXPONENT,3,0,1);
1252 /* Negative exponents are accepted without flags */
1253 CONVERT("1e-1", NUMPRS_EXPONENT);
1254 EXPECT(1,NUMPRS_EXPONENT,NUMPRS_EXPONENT,4,0,-1);
1257 /* As are positive exponents and leading exponent 0s */
1258 CONVERT("1e+01", NUMPRS_EXPONENT);
1259 EXPECT(1,NUMPRS_EXPONENT,NUMPRS_EXPONENT,5,0,1);
1262 /* The same for zero exponents */
1263 CONVERT("1e0", NUMPRS_EXPONENT);
1264 EXPECT(1,NUMPRS_EXPONENT,NUMPRS_EXPONENT,3,0,0);
1267 /* Sign on a zero exponent doesn't matter */
1268 CONVERT("1e+0", NUMPRS_EXPONENT);
1269 EXPECT(1,NUMPRS_EXPONENT,NUMPRS_EXPONENT,4,0,0);
1272 CONVERT("1e-0", NUMPRS_EXPONENT);
1273 EXPECT(1,NUMPRS_EXPONENT,NUMPRS_EXPONENT,4,0,0);
1276 /* Doesn't consume a real number exponent */
1277 CONVERT("1e1.", NUMPRS_EXPONENT);
1278 EXPECT(1,NUMPRS_EXPONENT,NUMPRS_EXPONENT,3,0,1);
1281 /* Powers of 10 are calculated from the position of any decimal point */
1282 CONVERT("1.5e20", NUMPRS_EXPONENT|NUMPRS_DECIMAL);
1283 EXPECT(2,NUMPRS_EXPONENT|NUMPRS_DECIMAL,NUMPRS_EXPONENT|NUMPRS_DECIMAL,6,0,19);
1286 CONVERT("1.5e-20", NUMPRS_EXPONENT|NUMPRS_DECIMAL);
1287 EXPECT(2,NUMPRS_EXPONENT|NUMPRS_DECIMAL,NUMPRS_EXPONENT|NUMPRS_DECIMAL,7,0,-21);
1290 /** NUMPRS_USE_ALL **/
1292 /* Flag expects all digits */
1293 CONVERT("0", NUMPRS_USE_ALL);
1294 EXPECT(1,NUMPRS_USE_ALL,0,1,0,0);
1297 /* Rejects anything trailing */
1298 CONVERT("0 ", NUMPRS_USE_ALL);
1302 /* Unless consumed by trailing flag */
1303 CONVERT("0 ", NUMPRS_USE_ALL|NUMPRS_TRAILING_WHITE);
1304 EXPECT(1,NUMPRS_USE_ALL|NUMPRS_TRAILING_WHITE,NUMPRS_TRAILING_WHITE,2,0,0);
1307 /** Combinations **/
1309 /* Leading whitespace and plus, doesn't consume trailing whitespace */
1310 CONVERT("+ 0 ", NUMPRS_LEADING_PLUS|NUMPRS_LEADING_WHITE);
1311 EXPECT(1,NUMPRS_LEADING_PLUS|NUMPRS_LEADING_WHITE,NUMPRS_LEADING_PLUS|NUMPRS_LEADING_WHITE,3,0,0);
1314 /* Order of whitespace and plus is unimportant */
1315 CONVERT(" +0", NUMPRS_LEADING_PLUS|NUMPRS_LEADING_WHITE);
1316 EXPECT(1,NUMPRS_LEADING_PLUS|NUMPRS_LEADING_WHITE,NUMPRS_LEADING_PLUS|NUMPRS_LEADING_WHITE,3,0,0);
1319 /* Leading whitespace can be repeated */
1320 CONVERT(" + 0", NUMPRS_LEADING_PLUS|NUMPRS_LEADING_WHITE);
1321 EXPECT(1,NUMPRS_LEADING_PLUS|NUMPRS_LEADING_WHITE,NUMPRS_LEADING_PLUS|NUMPRS_LEADING_WHITE,4,0,0);
1324 /* But plus/minus etc. cannot */
1325 CONVERT("+ +0", NUMPRS_LEADING_PLUS|NUMPRS_LEADING_WHITE);
1327 EXPECTRGB(0,FAILDIG);
1329 /* Inexact is not set if trailing zeros are removed */
1330 CONVERTN("10", 1, 0);
1331 EXPECT(1,0,0,2,0,1);
1334 /* Make sure a leading 0 is stripped but decimals after it get read */
1335 CONVERT("-0.51", NUMPRS_STD);
1336 EXPECT(2,NUMPRS_STD,NUMPRS_NEG|NUMPRS_DECIMAL|NUMPRS_LEADING_MINUS,5,0,-2);
1339 /* Keep trailing zeros on whole number part of a decimal */
1340 CONVERT("10.1", NUMPRS_STD);
1341 EXPECT(3,NUMPRS_STD,NUMPRS_DECIMAL,4,0,-1);
1345 /* Zeros after decimal sign */
1346 CONVERT("0.01", NUMPRS_STD);
1347 EXPECT(1,NUMPRS_STD,NUMPRS_DECIMAL,4,0,-2);
1350 /* Trailing zeros after decimal part */
1351 CONVERT("0.10", NUMPRS_STD);
1352 EXPECT(1,NUMPRS_STD,NUMPRS_DECIMAL,4,0,-1);
1356 static HRESULT (WINAPI *pVarNumFromParseNum)(NUMPARSE*,BYTE*,ULONG,VARIANT*);
1358 /* Macros for converting and testing the result of VarNumFromParseNum */
1359 #define SETRGB(indx,val) if (!indx) memset(rgb, FAILDIG, sizeof(rgb)); rgb[indx] = val
1361 #define CONVERT(a,b,c,d,e,f,bits) \
1362 np.cDig = (a); np.dwInFlags = (b); np.dwOutFlags = (c); np.cchUsed = (d); \
1363 np.nBaseShift = (e); np.nPwr10 = (f); hres = pVarNumFromParseNum(&np, rgb, bits, &vOut)
1364 static const char *szFailOverflow = "Expected overflow, hres = %08x\n";
1365 #define EXPECT_OVERFLOW ok(hres == (HRESULT)DISP_E_OVERFLOW, szFailOverflow, hres)
1366 static const char *szFailOk = "Call failed, hres = %08x\n";
1367 #define EXPECT_OK ok(hres == (HRESULT)S_OK, szFailOk, hres); \
1368 if (hres == (HRESULT)S_OK)
1369 #define EXPECT_TYPE(typ) ok(V_VT(&vOut) == typ,"Expected Type = " #typ ", got %d\n", V_VT(&vOut))
1370 #define EXPECT_I1(val) EXPECT_OK { EXPECT_TYPE(VT_I1); \
1371 ok(V_I1(&vOut) == val, "Expected i1 = %d, got %d\n", (signed char)val, V_I1(&vOut)); }
1372 #define EXPECT_UI1(val) EXPECT_OK { EXPECT_TYPE(VT_UI1); \
1373 ok(V_UI1(&vOut) == val, "Expected ui1 = %d, got %d\n", (BYTE)val, V_UI1(&vOut)); }
1374 #define EXPECT_I2(val) EXPECT_OK { EXPECT_TYPE(VT_I2); \
1375 ok(V_I2(&vOut) == val, "Expected i2 = %d, got %d\n", (SHORT)val, V_I2(&vOut)); }
1376 #define EXPECT_UI2(val) EXPECT_OK { EXPECT_TYPE(VT_UI2); \
1377 ok(V_UI2(&vOut) == val, "Expected ui2 = %d, got %d\n", (USHORT)val, V_UI2(&vOut)); }
1378 #define EXPECT_I4(val) EXPECT_OK { EXPECT_TYPE(VT_I4); \
1379 ok(V_I4(&vOut) == val, "Expected i4 = %d, got %d\n", (LONG)val, V_I4(&vOut)); }
1380 #define EXPECT_UI4(val) EXPECT_OK { EXPECT_TYPE(VT_UI4); \
1381 ok(V_UI4(&vOut) == val, "Expected ui4 = %d, got %d\n", (ULONG)val, V_UI4(&vOut)); }
1382 #define EXPECT_I8(high,low) EXPECT_OK { EXPECT_TYPE(VT_I8); \
1383 ok(V_I8(&vOut) == ((((LONG64)(high))<<32)|(low)), "Expected i8 = %x%08x, got %x%08x\n", \
1384 (LONG)(high), (LONG)(low), (LONG)(V_I8(&vOut)>>32), (LONG)V_I8(&vOut) ); }
1385 #define EXPECT_UI8(val) EXPECT_OK { EXPECT_TYPE(VT_UI8); \
1386 ok(V_UI8(&vOut) == val, "Expected ui8 = 0x%x%08x, got 0x%x%08x\n", \
1387 (DWORD)((ULONG64)val >> 32), (DWORD)(ULONG64)val, (DWORD)(V_UI8(&vOut) >> 32), (DWORD)V_UI8(&vOut)); }
1388 #define EXPECT_R4(val) EXPECT_OK { EXPECT_TYPE(VT_R4); \
1389 ok(V_R4(&vOut) == val, "Expected r4 = %f, got %f\n", val, V_R4(&vOut)); }
1390 #define EXPECT_R8(val) EXPECT_OK { EXPECT_TYPE(VT_R8); \
1391 ok(V_R8(&vOut) == val, "Expected r8 = %g, got %g\n", val, V_R8(&vOut)); }
1392 #define CY_MULTIPLIER 10000
1393 #define EXPECT_CY(val) EXPECT_OK { EXPECT_TYPE(VT_CY); \
1394 ok(V_CY(&vOut).int64 == (LONG64)(val * CY_MULTIPLIER), "Expected r8 = 0x%x%08x, got 0x%x%08x\n", \
1395 (DWORD)((LONG64)val >> 23), (DWORD)(LONG64)val, (DWORD)(V_CY(&vOut).int64 >>32), (DWORD)V_CY(&vOut).int64); }
1396 #define EXPECT_DECIMAL(valHi, valMid, valLo) EXPECT_OK { EXPECT_TYPE(VT_DECIMAL); \
1397 ok((V_DECIMAL(&vOut).Hi32 == valHi) && (S1(U1(V_DECIMAL(&vOut))).Mid32 == valMid) && \
1398 (S1(U1(V_DECIMAL(&vOut))).Lo32 == valLo), \
1399 "Expected decimal = %x/0x%x%08x, got %x/0x%x%08x\n", valHi, valMid, valLo, \
1400 V_DECIMAL(&vOut).Hi32, S1(U1(V_DECIMAL(&vOut))).Mid32, S1(U1(V_DECIMAL(&vOut))).Lo32); }
1402 static void test_VarNumFromParseNum(void)
1409 CHECKPTR(VarNumFromParseNum);
1411 /* Convert the number 1 to different types */
1412 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_I1); EXPECT_I1(1);
1413 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_UI1); EXPECT_UI1(1);
1414 /* Prefers a signed type to unsigned of the same size */
1415 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_I1|VTBIT_UI1); EXPECT_I1(1);
1416 /* But takes the smaller size if possible */
1417 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_I2|VTBIT_UI1); EXPECT_UI1(1);
1419 /* Try different integer sizes */
1420 #define INTEGER_VTBITS (VTBIT_I1|VTBIT_UI1|VTBIT_I2|VTBIT_UI2|VTBIT_I4|VTBIT_UI4|VTBIT_I8|VTBIT_UI8)
1422 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, INTEGER_VTBITS); EXPECT_I1(1);
1424 SETRGB(0, 1); SETRGB(1, 2); SETRGB(2, 7);
1425 CONVERT(3,0,0,3,0,0, INTEGER_VTBITS); EXPECT_I1(127);
1427 SETRGB(0, 1); SETRGB(1, 2); SETRGB(2, 8);
1428 CONVERT(3,0,0,3,0,0, INTEGER_VTBITS); EXPECT_UI1(128);
1430 SETRGB(0, 2); SETRGB(1, 5); SETRGB(2, 5);
1431 CONVERT(3,0,0,3,0,0, INTEGER_VTBITS); EXPECT_UI1(255);
1433 SETRGB(0, 2); SETRGB(1, 5); SETRGB(2, 6);
1434 CONVERT(3,0,0,3,0,0, INTEGER_VTBITS); EXPECT_I2(256);
1436 SETRGB(0, 3); SETRGB(1, 2); SETRGB(2, 7); SETRGB(3, 6); SETRGB(4, 7);
1437 CONVERT(5,0,0,5,0,0, INTEGER_VTBITS); EXPECT_I2(32767);
1439 SETRGB(0, 3); SETRGB(1, 2); SETRGB(2, 7); SETRGB(3, 6); SETRGB(4, 8);
1440 CONVERT(5,0,0,5,0,0, INTEGER_VTBITS); EXPECT_UI2(32768);
1442 /* Assume the above pattern holds for remaining positive integers; test negative */
1445 SETRGB(0, 1); SETRGB(1, 2); SETRGB(2, 8);
1446 CONVERT(3,0,NUMPRS_NEG,3,0,0, INTEGER_VTBITS); EXPECT_I1(-128);
1448 SETRGB(0, 1); SETRGB(1, 2); SETRGB(2, 9);
1449 CONVERT(3,0,NUMPRS_NEG,3,0,0, INTEGER_VTBITS); EXPECT_I2(-129);
1451 SETRGB(0, 3); SETRGB(1, 2); SETRGB(2, 7); SETRGB(3, 6); SETRGB(4, 8);
1452 CONVERT(5,0,NUMPRS_NEG,5,0,0, INTEGER_VTBITS); EXPECT_I2(-32768);
1454 SETRGB(0, 3); SETRGB(1, 2); SETRGB(2, 7); SETRGB(3, 6); SETRGB(4, 9);
1455 CONVERT(5,0,NUMPRS_NEG,5,0,0, INTEGER_VTBITS); EXPECT_I4(-32769);
1457 /* Assume the above pattern holds for remaining negative integers */
1459 /* Test hexadecimal conversions */
1460 SETRGB(0, 1); CONVERT(1,0,0,1,4,0, INTEGER_VTBITS); EXPECT_I1(0x01);
1462 SETRGB(0, 7); SETRGB(1, 0xf);
1463 CONVERT(2,0,0,2,4,0, INTEGER_VTBITS); EXPECT_I1(0x7f);
1464 SETRGB(0, 7); SETRGB(1, 0xf);
1465 CONVERT(2,0,0,2,4,0, VTBIT_DECIMAL); EXPECT_DECIMAL(0,0,0x7f);
1467 SETRGB(0, 7); SETRGB(1, 0xf); SETRGB(2, 0xf); SETRGB(3, 0xf);
1468 CONVERT(4,0,0,4,4,0, INTEGER_VTBITS); EXPECT_I2(0x7fff);
1470 SETRGB(0, 7); SETRGB(1, 0xf); SETRGB(2, 0xf); SETRGB(3, 0xf);
1471 SETRGB(4, 0xf); SETRGB(5, 0xf); SETRGB(6, 0xf); SETRGB(7, 0xf);
1472 CONVERT(8,0,0,8,4,0, INTEGER_VTBITS); EXPECT_I4(0x7fffffffL);
1473 /* 0x7fffffffffffffff (64 bits) */
1474 SETRGB(0, 7); SETRGB(1, 0xf); SETRGB(2, 0xf); SETRGB(3, 0xf);
1475 SETRGB(4, 0xf); SETRGB(5, 0xf); SETRGB(6, 0xf); SETRGB(7, 0xf);
1476 SETRGB(8, 0xf); SETRGB(9, 0xf); SETRGB(10, 0xf); SETRGB(11, 0xf);
1477 SETRGB(12, 0xf); SETRGB(13, 0xf); SETRGB(14, 0xf); SETRGB(15, 0xf);
1478 if (HAVE_OLEAUT32_I8)
1480 /* We cannot use INTEGER_VTBITS as WinXP and Win2003 are broken(?). They
1481 truncate the number to the smallest integer size requested:
1482 CONVERT(16,0,0,16,4,0, INTEGER_VTBITS); EXPECT_I1((signed char)0xff); */
1483 CONVERT(16,0,0,16,4,0, VTBIT_I8); EXPECT_I8(0x7fffffff,0xffffffff);
1486 /* Assume the above pattern holds for numbers without hi-bit set, test (preservation of) hi-bit */
1488 SETRGB(0, 8); SETRGB(1, 2);
1489 CONVERT(2,0,0,2,4,0, INTEGER_VTBITS);
1490 EXPECT_I1((signed char)0x82);
1492 SETRGB(0, 8); SETRGB(1, 0); SETRGB(2, 0); SETRGB(3, 2);
1493 CONVERT(4,0,0,4,4,0, INTEGER_VTBITS);
1494 EXPECT_I2((signed short)0x8002);
1496 SETRGB(0, 8); SETRGB(1, 0); SETRGB(2, 0); SETRGB(3, 0);
1497 SETRGB(4, 0); SETRGB(5, 0); SETRGB(6, 0); SETRGB(7, 2);
1498 CONVERT(8,0,0,8,4,0, INTEGER_VTBITS); EXPECT_I4(0x80000002);
1499 /* 0x8000000000000002 (64 bits) */
1500 SETRGB(0, 8); SETRGB(1, 0); SETRGB(2, 0); SETRGB(3, 0);
1501 SETRGB(4, 0); SETRGB(5, 0); SETRGB(6, 0); SETRGB(7, 0);
1502 SETRGB(8, 0); SETRGB(9, 0); SETRGB(10, 0); SETRGB(11, 0);
1503 SETRGB(12, 0); SETRGB(13, 0); SETRGB(14, 0); SETRGB(15, 2);
1504 if (HAVE_OLEAUT32_I8)
1506 /* We cannot use INTEGER_VTBITS as WinXP and Win2003 are broken(?). They
1507 truncate the number to the smallest integer size requested:
1508 CONVERT(16,0,0,16,4,0, INTEGER_VTBITS & ~VTBIT_I1);
1509 EXPECT_I2((signed short)0x0002); */
1510 CONVERT(16,0,0,16,4,0, VTBIT_I8); EXPECT_I8(0x80000000,0x00000002);
1513 /* Test (preservation of) hi-bit with STRICT type requesting */
1515 SETRGB(0, 8); SETRGB(1, 2);
1516 CONVERT(2,0,0,2,4,0, VTBIT_I1);
1517 EXPECT_I1((signed char)0x82);
1519 SETRGB(0, 8); SETRGB(1, 0); SETRGB(2, 0); SETRGB(3, 2);
1520 CONVERT(4,0,0,4,4,0, VTBIT_I2);
1521 EXPECT_I2((signed short)0x8002);
1523 SETRGB(0, 8); SETRGB(1, 0); SETRGB(2, 0); SETRGB(3, 0);
1524 SETRGB(4, 0); SETRGB(5, 0); SETRGB(6, 0); SETRGB(7, 2);
1525 CONVERT(8,0,0,8,4,0, VTBIT_I4); EXPECT_I4(0x80000002);
1526 /* 0x8000000000000002 (64 bits) */
1527 SETRGB(0, 8); SETRGB(1, 0); SETRGB(2, 0); SETRGB(3, 0);
1528 SETRGB(4, 0); SETRGB(5, 0); SETRGB(6, 0); SETRGB(7, 0);
1529 SETRGB(8, 0); SETRGB(9, 0); SETRGB(10, 0); SETRGB(11, 0);
1530 SETRGB(12, 0); SETRGB(13, 0); SETRGB(14, 0); SETRGB(15, 2);
1531 if (HAVE_OLEAUT32_I8)
1533 CONVERT(16,0,0,16,4,0, VTBIT_I8); EXPECT_I8(0x80000000,0x00000002);
1535 /* Assume the above pattern holds for numbers with hi-bit set */
1537 /* Negative numbers overflow if we have only unsigned outputs */
1539 SETRGB(0, 1); CONVERT(1,0,NUMPRS_NEG,1,0,0, VTBIT_UI1); EXPECT_OVERFLOW;
1541 SETRGB(0, 6); CONVERT(1,0,NUMPRS_NEG,1,0,~0u, VTBIT_UI1); EXPECT_OVERFLOW;
1543 /* Except that rounding is done first, so -0.5 to 0 are accepted as 0 */
1545 SETRGB(0, 5); CONVERT(1,0,NUMPRS_NEG,1,0,~0u, VTBIT_UI1); EXPECT_UI1(0);
1547 /* Floating point zero is OK */
1549 SETRGB(0, 0); CONVERT(1,0,NUMPRS_DECIMAL|NUMPRS_EXPONENT,12,0,-8, VTBIT_R8);
1552 /* Float is acceptable for an integer input value */
1553 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_R4); EXPECT_R4(1.0f);
1555 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_R8); EXPECT_R8(1.0);
1556 /* As is currency */
1557 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_CY); EXPECT_CY(1);
1559 /* Float is preferred over double */
1560 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_R4|VTBIT_R8); EXPECT_R4(1.0f);
1562 /* Double is preferred over currency */
1563 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_R8|VTBIT_CY); EXPECT_R8(1.0);
1565 /* Currency is preferred over decimal */
1566 SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_CY|VTBIT_DECIMAL); EXPECT_CY(1);
1570 static void test_UdateFromDate( int line, DATE dt, ULONG flags, HRESULT r, WORD d, WORD m, WORD y,
1571 WORD h, WORD mn, WORD s, WORD ms, WORD dw, WORD dy)
1576 memset(&ud, 0, sizeof(ud));
1577 res = pVarUdateFromDate(dt, flags, &ud);
1578 ok_(__FILE__,line)(r == res, "Wrong result %x/%x\n", r, res);
1580 ok_(__FILE__,line)(ud.st.wYear == y && ud.st.wMonth == m && ud.st.wDay == d &&
1581 ud.st.wHour == h && ud.st.wMinute == mn && ud.st.wSecond == s &&
1582 ud.st.wMilliseconds == ms && ud.st.wDayOfWeek == dw && ud.wDayOfYear == dy,
1583 "%.16g expected %d,%d,%d,%d,%d,%d,%d %d %d, got %d,%d,%d,%d,%d,%d,%d %d %d\n",
1584 dt, d, m, y, h, mn, s, ms, dw, dy,
1585 ud.st.wDay, ud.st.wMonth, ud.st.wYear, ud.st.wHour, ud.st.wMinute,
1586 ud.st.wSecond, ud.st.wMilliseconds, ud.st.wDayOfWeek, ud.wDayOfYear );
1588 #define DT2UD(dt,flags,r,d,m,y,h,mn,s,ms,dw,dy) test_UdateFromDate(__LINE__,dt,flags,r,d,m,y,h,mn,s,ms,dw,dy)
1590 static void test_VarUdateFromDate(void)
1592 CHECKPTR(VarUdateFromDate);
1593 DT2UD(29221.0,0,S_OK,1,1,1980,0,0,0,0,2,1); /* 1 Jan 1980 */
1594 DT2UD(29222.0,0,S_OK,2,1,1980,0,0,0,0,3,2); /* 2 Jan 1980 */
1595 DT2UD(33238.0,0,S_OK,31,12,1990,0,0,0,0,1,365); /* 31 Dec 1990 */
1596 DT2UD(0.0,0,S_OK,30,12,1899,0,0,0,0,6,364); /* 30 Dec 1899 - VT_DATE 0.0 */
1597 DT2UD(-657434.0,0,S_OK,1,1,100,0,0,0,0,5,1); /* 1 Jan 100 - Min */
1598 DT2UD(-657435.0,0,E_INVALIDARG,0,0,0,0,0,0,0,0,0); /* < 1 Jan 100 => err */
1599 DT2UD(2958465.0,0,S_OK,31,12,9999,0,0,0,0,5,365); /* 31 Dec 9999 - Max */
1600 DT2UD(2958466.0,0,E_INVALIDARG,0,0,0,0,0,0,0,0,0); /* > 31 Dec 9999 => err */
1602 /* VAR_VALIDDATE doesn't prevent upper and lower bounds being checked */
1603 DT2UD(-657435.0,VAR_VALIDDATE,E_INVALIDARG,0,0,0,0,0,0,0,0,0);
1604 DT2UD(2958466.0,VAR_VALIDDATE,E_INVALIDARG,0,0,0,0,0,0,0,0,0);
1607 DT2UD(29221.25,0,S_OK,1,1,1980,6,0,0,0,2,1); /* 6 AM */
1608 DT2UD(29221.33333333,0,S_OK,1,1,1980,8,0,0,0,2,1); /* 8 AM */
1609 DT2UD(29221.5,0,S_OK,1,1,1980,12,0,0,0,2,1); /* 12 AM */
1610 DT2UD(29221.9888884444,0,S_OK,1,1,1980,23,44,0,0,2,1); /* 11:44 PM */
1611 DT2UD(29221.7508765432,0,S_OK,1,1,1980,18,1,16,0,2,1); /* 6:18:02 PM */
1615 static void test_DateFromUDate( int line, WORD d, WORD m, WORD y, WORD h, WORD mn, WORD s, WORD ms,
1616 WORD dw, WORD dy, ULONG flags, HRESULT r, DATE dt )
1628 ud.st.wMilliseconds = ms;
1629 ud.st.wDayOfWeek = dw;
1631 res = pVarDateFromUdate(&ud, flags, &out);
1632 ok_(__FILE__,line)(r == res && (FAILED(r) || EQ_DOUBLE(out, dt)),
1633 "expected %x, %.16g, got %x, %.16g\n", r, dt, res, out);
1635 #define UD2T(d,m,y,h,mn,s,ms,dw,dy,flags,r,dt) test_DateFromUDate(__LINE__,d,m,y,h,mn,s,ms,dw,dy,flags,r,dt)
1637 static void test_VarDateFromUdate(void)
1639 CHECKPTR(VarDateFromUdate);
1640 UD2T(1,1,1980,0,0,0,0,2,1,0,S_OK,29221.0); /* 1 Jan 1980 */
1641 UD2T(2,1,1980,0,0,0,0,3,2,0,S_OK,29222.0); /* 2 Jan 1980 */
1642 UD2T(31,12,1990,0,0,0,0,0,0,0,S_OK,33238.0); /* 31 Dec 1990 */
1643 UD2T(31,12,90,0,0,0,0,0,0,0,S_OK,33238.0); /* year < 100 is 1900+year! */
1644 UD2T(30,12,1899,0,0,0,0,6,364,0,S_OK,0.0); /* 30 Dec 1899 - VT_DATE 0.0 */
1645 UD2T(1,1,100,0,0,0,0,0,0,0,S_OK,-657434.0); /* 1 Jan 100 - Min */
1646 UD2T(31,12,9999,0,0,0,0,0,0,0,S_OK,2958465.0); /* 31 Dec 9999 - Max */
1647 UD2T(1,1,10000,0,0,0,0,0,0,0,E_INVALIDARG,0.0); /* > 31 Dec 9999 => err */
1649 UD2T(30,12,1899,0,0,0,0,0,0,0,S_OK,0.0); /* 30 Dec 1899 0:00:00 */
1650 UD2T(30,12,1899,0,0,0,999,0,0,0,S_OK,0.0); /* Ignore milliseconds */
1652 UD2T(1,1,1980,18,1,16,0,2,1,0,S_OK,29221.75087962963); /* 6:18:02 PM */
1653 todo_wine UD2T(0,1,1980,42,1,16,0,2,1,0,S_OK,29221.75087962963); /* Test rolled hours */
1654 todo_wine UD2T(1,1,1980,17,61,16,0,2,1,0,S_OK,29221.75087962963); /* Test rolled minutes */
1655 todo_wine UD2T(1,1,1980,18,0,76,0,2,1,0,S_OK,29221.75087962963); /* Test rolled seconds */
1657 UD2T(0,1,1980,0,0,0,0,2,1,0,S_OK,29220.0); /* Rolls back to 31 Dec 1899 */
1658 UD2T(1,13,1980,0,0,0,0,2,1,0,S_OK,29587.0); /* Rolls fwd to 1/1/1981 */
1661 static void test_st2dt(int line, WORD d, WORD m, WORD y, WORD h, WORD mn,
1662 WORD s, WORD ms, INT r, double dt)
1674 st.wMilliseconds = ms;
1676 res = pSystemTimeToVariantTime(&st, &out);
1677 ok_(__FILE__,line)(r == res && (!r || EQ_DOUBLE(out, dt)),
1678 "expected %d, %.16g, got %d, %.16g\n", r, dt, res, out);
1680 #define ST2DT(d,m,y,h,mn,s,ms,r,dt) test_st2dt(__LINE__,d,m,y,h,mn,s,ms,r,dt)
1682 static void test_SystemTimeToVariantTime(void)
1684 CHECKPTR(SystemTimeToVariantTime);
1685 ST2DT(1,1,1980,0,0,0,0,TRUE,29221.0);
1686 ST2DT(2,1,1980,0,0,0,0,TRUE,29222.0);
1687 ST2DT(0,1,1980,0,0,0,0,TRUE,29220.0); /* Rolls back to 31 Dec 1899 */
1688 ST2DT(1,13,1980,0,0,0,0,FALSE,29587.0); /* Fails on invalid month */
1689 ST2DT(31,12,90,0,0,0,0,TRUE,33238.0); /* year < 100 is 1900+year! */
1692 static void test_dt2st(int line, double dt, INT r, WORD d, WORD m, WORD y,
1693 WORD h, WORD mn, WORD s, WORD ms)
1698 memset(&st, 0, sizeof(st));
1699 res = pVariantTimeToSystemTime(dt, &st);
1700 ok_(__FILE__,line)(r == res &&
1701 (!r || (st.wYear == y && st.wMonth == m && st.wDay == d &&
1702 st.wHour == h && st.wMinute == mn &&
1703 st.wSecond == s && st.wMilliseconds == ms)),
1704 "%.16g expected %d, %d,%d,%d,%d,%d,%d,%d, got %d, %d,%d,%d,%d,%d,%d,%d\n",
1705 dt, r, d, m, y, h, mn, s, ms, res, st.wDay, st.wMonth,
1706 st.wYear, st.wHour, st.wMinute, st.wSecond,
1709 #define DT2ST(dt,r,d,m,y,h,mn,s,ms) test_dt2st(__LINE__,dt,r,d,m,y,h,mn,s,ms)
1711 static void test_VariantTimeToSystemTime(void)
1713 CHECKPTR(VariantTimeToSystemTime);
1714 DT2ST(29221.0,1,1,1,1980,0,0,0,0);
1715 DT2ST(29222.0,1,2,1,1980,0,0,0,0);
1718 #define MKDOSDATE(d,m,y) ((d & 0x1f) | ((m & 0xf) << 5) | (((y-1980) & 0x7f) << 9))
1719 #define MKDOSTIME(h,m,s) (((s>>1) & 0x1f) | ((m & 0x3f) << 5) | ((h & 0x1f) << 11))
1721 static void test_dos2dt(int line, WORD d, WORD m, WORD y, WORD h, WORD mn,
1722 WORD s, INT r, double dt)
1724 unsigned short dosDate, dosTime;
1729 dosDate = MKDOSDATE(d, m, y);
1730 dosTime = MKDOSTIME(h, mn, s);
1731 res = pDosDateTimeToVariantTime(dosDate, dosTime, &out);
1732 ok_(__FILE__,line)(r == res && (!r || EQ_DOUBLE(out, dt)),
1733 "expected %d, %.16g, got %d, %.16g\n", r, dt, res, out);
1735 #define DOS2DT(d,m,y,h,mn,s,r,dt) test_dos2dt(__LINE__,d,m,y,h,mn,s,r,dt)
1737 static void test_DosDateTimeToVariantTime(void)
1739 CHECKPTR(DosDateTimeToVariantTime);
1742 DOS2DT(1,1,1980,0,0,0,1,29221.0); /* 1/1/1980 */
1743 DOS2DT(31,12,2099,0,0,0,1,73050.0); /* 31/12/2099 */
1744 /* Dates are limited to the dos date max of 31/12/2099 */
1745 DOS2DT(31,12,2100,0,0,0,0,0.0); /* 31/12/2100 */
1746 /* Days and months of 0 cause date to roll back 1 day or month */
1747 DOS2DT(0,1,1980,0,0,0,1,29220.0); /* 0 Day => 31/12/1979 */
1748 DOS2DT(1,0,1980,0,0,0,1,29190.0); /* 0 Mth => 1/12/1979 */
1749 DOS2DT(0,0,1980,0,0,0,1,29189.0); /* 0 D/M => 30/11/1979 */
1750 /* Days > days in the month cause date to roll forward 1 month */
1751 DOS2DT(29,2,1981,0,0,0,1,29646.0); /* 29/2/1981 -> 3/1/1980 */
1752 DOS2DT(30,2,1981,0,0,0,1,29647.0); /* 30/2/1981 -> 4/1/1980 */
1753 /* Takes leap years into account when rolling forward */
1754 DOS2DT(29,2,1980,0,0,0,1,29280.0); /* 2/29/1980 */
1755 /* Months > 12 cause an error */
1756 DOS2DT(2,13,1980,0,0,0,0,0.0);
1759 DOS2DT(1,1,1980,0,0,29,1,29221.00032407407); /* 1/1/1980 12:00:28 AM */
1760 DOS2DT(1,1,1980,0,0,31,1,29221.00034722222); /* 1/1/1980 12:00:30 AM */
1761 DOS2DT(1,1,1980,0,59,0,1,29221.04097222222); /* 1/1/1980 12:59:00 AM */
1762 DOS2DT(1,1,1980,0,60,0,0,0.0); /* Invalid seconds */
1763 DOS2DT(1,1,1980,23,0,0,1,29221.95833333333); /* 1/1/1980 11:00:00 PM */
1764 DOS2DT(1,1,1980,24,0,0,0,0.0); /* Invalid hours */
1767 static void test_dt2dos(int line, double dt, INT r, WORD d, WORD m, WORD y,
1768 WORD h, WORD mn, WORD s)
1770 unsigned short dosDate, dosTime, expDosDate, expDosTime;
1773 dosTime = dosDate = 0;
1774 expDosDate = MKDOSDATE(d,m,y);
1775 expDosTime = MKDOSTIME(h,mn,s);
1776 res = pVariantTimeToDosDateTime(dt, &dosDate, &dosTime);
1777 ok_(__FILE__,line)(r == res && (!r || (dosTime == expDosTime && dosDate == expDosDate)),
1778 "%g: expected %d,%d(%d/%d/%d),%d(%d:%d:%d) got %d,%d(%d/%d/%d),%d(%d:%d:%d)\n",
1779 dt, r, expDosDate, expDosDate & 0x1f,
1780 (expDosDate >> 5) & 0xf, 1980 + (expDosDate >> 9),
1781 expDosTime, expDosTime >> 11, (expDosTime >> 5) & 0x3f,
1782 (expDosTime & 0x1f),
1783 res, dosDate, dosDate & 0x1f, (dosDate >> 5) & 0xf,
1784 1980 + (dosDate >> 9), dosTime, dosTime >> 11,
1785 (dosTime >> 5) & 0x3f, (dosTime & 0x1f));
1787 #define DT2DOS(dt,r,d,m,y,h,mn,s) test_dt2dos(__LINE__,dt,r,d,m,y,h,mn,s)
1789 static void test_VariantTimeToDosDateTime(void)
1791 CHECKPTR(VariantTimeToDosDateTime);
1794 DT2DOS(29221.0,1,1,1,1980,0,0,0); /* 1/1/1980 */
1795 DT2DOS(73050.0,1,31,12,2099,0,0,0); /* 31/12/2099 */
1796 DT2DOS(29220.0,0,0,0,0,0,0,0); /* 31/12/1979 - out of range */
1797 DT2DOS(73415.0,0,0,0,0,0,0,0); /* 31/12/2100 - out of range */
1800 DT2DOS(29221.00032407407,1,1,1,1980,0,0,29); /* 1/1/1980 12:00:28 AM */
1801 DT2DOS(29221.00034722222,1,1,1,1980,0,0,31); /* 1/1/1980 12:00:30 AM */
1802 DT2DOS(29221.04097222222,1,1,1,1980,0,59,0); /* 1/1/1980 12:59:00 AM */
1803 DT2DOS(29221.95833333333,1,1,1,1980,23,0,0); /* 1/1/1980 11:00:00 PM */
1806 static HRESULT (WINAPI *pVarAbs)(LPVARIANT,LPVARIANT);
1808 #define VARABS(vt,val,rvt,rval) \
1809 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
1810 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
1811 test_var_call1( __LINE__, pVarAbs, &v, &exp )
1813 static void test_VarAbs(void)
1815 static WCHAR szNum[] = {'-','1','.','1','\0' };
1818 VARIANT v, vDst, exp;
1823 /* Test all possible V_VT values.
1825 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
1829 for (vt = 0; vt <= VT_BSTR_BLOB; vt++)
1831 HRESULT hExpected = DISP_E_BADVARTYPE;
1835 memset(&v, 0, sizeof(v));
1836 V_VT(&v) = vt | ExtraFlags[i];
1837 V_VT(&vDst) = VT_EMPTY;
1839 hres = pVarAbs(&v,&vDst);
1840 if (ExtraFlags[i] & (VT_ARRAY|VT_ARRAY) ||
1841 (!ExtraFlags[i] && (vt == VT_UNKNOWN || vt == VT_BSTR ||
1842 vt == VT_DISPATCH || vt == VT_ERROR || vt == VT_RECORD)))
1844 hExpected = DISP_E_TYPEMISMATCH;
1846 else if (ExtraFlags[i] || vt >= VT_CLSID || vt == VT_VARIANT)
1848 hExpected = DISP_E_BADVARTYPE;
1850 else if (IsValidVariantClearVT(vt, ExtraFlags[i]))
1853 /* Native always fails on some vartypes that should be valid. don't
1854 * check that Wine does the same; these are bugs in native.
1856 if (vt == VT_I8 || vt == VT_UI8 || vt == VT_INT || vt == VT_UINT ||
1857 vt == VT_I1 || vt == VT_UI2 || vt == VT_UI4)
1859 ok(hres == hExpected, "VarAbs: expected 0x%X, got 0x%X for vt %d | 0x%X\n",
1860 hExpected, hres, vt, ExtraFlags[i]);
1864 /* BOOL->I2, BSTR->R8, all others remain the same */
1865 VARABS(BOOL,VARIANT_TRUE,I2,-VARIANT_TRUE);
1866 VARABS(BOOL,VARIANT_FALSE,I2,VARIANT_FALSE);
1867 VARABS(EMPTY,0,I2,0);
1868 VARABS(EMPTY,1,I2,0);
1869 VARABS(NULL,0,NULL,0);
1870 VARABS(NULL,1,NULL,0);
1875 VARABS(UI1,1,UI1,1);
1880 VARABS(DATE,1,DATE,1);
1881 VARABS(DATE,-1,DATE,1);
1883 V_CY(&v).int64 = -10000;
1884 memset(&vDst,0,sizeof(vDst));
1885 hres = pVarAbs(&v,&vDst);
1886 ok(hres == S_OK && V_VT(&vDst) == VT_CY && V_CY(&vDst).int64 == 10000,
1887 "VarAbs(CY): expected 0x0 got 0x%X\n", hres);
1888 GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, buff, sizeof(buff)/sizeof(char));
1891 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%X,%d,%g\n", VT_R8, 1.1, hres, V_VT(&vDst), V_R8(&vDst));
1904 static HRESULT (WINAPI *pVarNot)(LPVARIANT,LPVARIANT);
1906 #define VARNOT(vt,val,rvt,rval) \
1907 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
1908 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
1909 test_var_call1( __LINE__, pVarNot, &v, &exp )
1911 static void test_VarNot(void)
1913 static const WCHAR szNum0[] = {'0','\0' };
1914 static const WCHAR szNum1[] = {'1','\0' };
1916 VARIANT v, exp, vDst;
1917 DECIMAL *pdec = &V_DECIMAL(&v);
1918 CY *pcy = &V_CY(&v);
1923 /* Test all possible V_VT values */
1924 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
1928 for (vt = 0; vt <= VT_BSTR_BLOB; vt++)
1930 HRESULT hExpected = DISP_E_BADVARTYPE;
1934 memset(&v, 0, sizeof(v));
1935 V_VT(&v) = vt | ExtraFlags[i];
1936 V_VT(&vDst) = VT_EMPTY;
1940 case VT_I1: case VT_UI1: case VT_I2: case VT_UI2:
1941 case VT_INT: case VT_UINT: case VT_I4: case VT_UI4:
1942 case VT_R4: case VT_R8:
1943 case VT_DECIMAL: case VT_BOOL: case VT_NULL: case VT_EMPTY:
1944 case VT_DATE: case VT_CY:
1947 case VT_I8: case VT_UI8:
1948 if (HAVE_OLEAUT32_I8)
1952 if (HAVE_OLEAUT32_RECORD)
1953 hExpected = DISP_E_TYPEMISMATCH;
1955 case VT_UNKNOWN: case VT_BSTR: case VT_DISPATCH: case VT_ERROR:
1956 hExpected = DISP_E_TYPEMISMATCH;
1959 if (IsValidVariantClearVT(vt, ExtraFlags[i]) && vt != VT_CLSID)
1960 hExpected = DISP_E_TYPEMISMATCH;
1964 hres = pVarNot(&v,&vDst);
1965 ok(hres == hExpected, "VarNot: expected 0x%X, got 0x%X vt %d|0x%X\n",
1966 hExpected, hres, vt, ExtraFlags[i]);
1969 /* Test the values returned by all cases that can succeed */
1970 VARNOT(EMPTY,0,I2,-1);
1971 VARNOT(EMPTY,1,I2,-1);
1972 VARNOT(NULL,0,NULL,0);
1973 VARNOT(NULL,1,NULL,0);
1974 VARNOT(BOOL,VARIANT_TRUE,BOOL,VARIANT_FALSE);
1975 VARNOT(BOOL,VARIANT_FALSE,BOOL,VARIANT_TRUE);
1983 VARNOT(UI1,1,UI1,254);
1984 VARNOT(UI1,0,UI1,255);
1985 VARNOT(UI2,0,I4,-1);
1986 VARNOT(UI2,1,I4,-2);
1987 VARNOT(UI4,0,I4,-1);
1988 VARNOT(UI4,1,I4,-2);
1989 VARNOT(INT,0,I4,-1);
1990 VARNOT(INT,1,I4,-2);
1991 VARNOT(UINT,0,I4,-1);
1992 VARNOT(UINT,1,I4,-2);
1993 if (HAVE_OLEAUT32_I8)
1997 VARNOT(UI8,0,I4,-1);
1998 VARNOT(UI8,1,I4,-2);
2004 VARNOT(DATE,1,I4,-2);
2005 VARNOT(DATE,0,I4,-1);
2006 VARNOT(BSTR,(BSTR)szNum0,I4,-1);
2007 ok(V_VT(&v) == VT_BSTR && V_BSTR(&v) == szNum0, "VarNot(0): changed input\n");
2008 VARNOT(BSTR,(BSTR)szNum1,I4,-2);
2009 ok(V_VT(&v) == VT_BSTR && V_BSTR(&v) == szNum1, "VarNot(1): changed input\n");
2011 V_VT(&v) = VT_DECIMAL;
2012 S(U(*pdec)).sign = DECIMAL_NEG;
2013 S(U(*pdec)).scale = 0;
2015 S1(U1(*pdec)).Mid32 = 0;
2016 S1(U1(*pdec)).Lo32 = 1;
2017 VARNOT(DECIMAL,*pdec,I4,0);
2020 VARNOT(CY,*pcy,I4,-2);
2023 VARNOT(CY,*pcy,I4,-1);
2026 VARNOT(CY,*pcy,I4,-1);
2029 static HRESULT (WINAPI *pVarSub)(LPVARIANT,LPVARIANT,LPVARIANT);
2031 #define VARSUB(vt1,val1,vt2,val2,rvt,rval) \
2032 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
2033 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
2034 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
2035 test_var_call2( __LINE__, pVarSub, &left, &right, &exp )
2037 static void test_VarSub(void)
2039 VARIANT left, right, exp, result, cy, dec;
2042 HRESULT hres, expectedhres;
2047 lbstr = SysAllocString(sz12);
2048 rbstr = SysAllocString(sz12);
2051 VariantInit(&right);
2052 VariantInit(&result);
2054 /* Test all possible flag/vt combinations & the resulting vt type */
2055 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
2058 VARTYPE leftvt, rightvt, resvt;
2060 for (leftvt = 0; leftvt <= VT_BSTR_BLOB; leftvt++)
2065 for (rightvt = 0; rightvt <= VT_BSTR_BLOB; rightvt++)
2069 expectedhres = S_OK;
2071 memset(&left, 0, sizeof(left));
2072 memset(&right, 0, sizeof(right));
2073 V_VT(&left) = leftvt | ExtraFlags[i];
2074 if (leftvt == VT_BSTR)
2075 V_BSTR(&left) = lbstr;
2076 V_VT(&right) = rightvt | ExtraFlags[i];
2077 if (rightvt == VT_BSTR)
2078 V_BSTR(&right) = rbstr;
2079 V_VT(&result) = VT_EMPTY;
2082 /* All extra flags produce errors */
2083 if (ExtraFlags[i] == (VT_VECTOR|VT_BYREF|VT_RESERVED) ||
2084 ExtraFlags[i] == (VT_VECTOR|VT_RESERVED) ||
2085 ExtraFlags[i] == (VT_VECTOR|VT_BYREF) ||
2086 ExtraFlags[i] == (VT_BYREF|VT_RESERVED) ||
2087 ExtraFlags[i] == VT_VECTOR ||
2088 ExtraFlags[i] == VT_BYREF ||
2089 ExtraFlags[i] == VT_RESERVED)
2091 expectedhres = DISP_E_BADVARTYPE;
2094 else if (ExtraFlags[i] >= VT_ARRAY)
2096 expectedhres = DISP_E_TYPEMISMATCH;
2099 /* Native VarSub cannot handle: VT_I1, VT_UI2, VT_UI4,
2100 VT_INT, VT_UINT and VT_UI8. Tested with WinXP */
2101 else if (!IsValidVariantClearVT(leftvt, ExtraFlags[i]) ||
2102 !IsValidVariantClearVT(rightvt, ExtraFlags[i]) ||
2103 leftvt == VT_CLSID || rightvt == VT_CLSID ||
2104 leftvt == VT_VARIANT || rightvt == VT_VARIANT ||
2105 leftvt == VT_I1 || rightvt == VT_I1 ||
2106 leftvt == VT_UI2 || rightvt == VT_UI2 ||
2107 leftvt == VT_UI4 || rightvt == VT_UI4 ||
2108 leftvt == VT_UI8 || rightvt == VT_UI8 ||
2109 leftvt == VT_INT || rightvt == VT_INT ||
2110 leftvt == VT_UINT || rightvt == VT_UINT ||
2111 leftvt == VT_UNKNOWN || rightvt == VT_UNKNOWN ||
2112 leftvt == VT_RECORD || rightvt == VT_RECORD)
2114 if (leftvt == VT_RECORD && rightvt == VT_I8)
2116 if (HAVE_OLEAUT32_I8)
2117 expectedhres = DISP_E_TYPEMISMATCH;
2119 expectedhres = DISP_E_BADVARTYPE;
2121 else if (leftvt < VT_UI1 && rightvt == VT_RECORD)
2122 expectedhres = DISP_E_TYPEMISMATCH;
2123 else if (leftvt >= VT_UI1 && rightvt == VT_RECORD)
2124 expectedhres = DISP_E_TYPEMISMATCH;
2125 else if (leftvt == VT_RECORD && rightvt <= VT_UI1)
2126 expectedhres = DISP_E_TYPEMISMATCH;
2127 else if (leftvt == VT_RECORD && rightvt > VT_UI1)
2128 expectedhres = DISP_E_BADVARTYPE;
2130 expectedhres = DISP_E_BADVARTYPE;
2133 else if ((leftvt == VT_NULL && rightvt == VT_DISPATCH) ||
2134 (leftvt == VT_DISPATCH && rightvt == VT_NULL))
2136 else if (leftvt == VT_DISPATCH || rightvt == VT_DISPATCH ||
2137 leftvt == VT_ERROR || rightvt == VT_ERROR)
2140 expectedhres = DISP_E_TYPEMISMATCH;
2142 else if (leftvt == VT_NULL || rightvt == VT_NULL)
2144 else if ((leftvt == VT_EMPTY && rightvt == VT_BSTR) ||
2145 (leftvt == VT_DATE && rightvt == VT_DATE) ||
2146 (leftvt == VT_BSTR && rightvt == VT_EMPTY) ||
2147 (leftvt == VT_BSTR && rightvt == VT_BSTR))
2149 else if (leftvt == VT_DECIMAL || rightvt == VT_DECIMAL)
2151 else if (leftvt == VT_DATE || rightvt == VT_DATE)
2153 else if (leftvt == VT_CY || rightvt == VT_CY)
2155 else if (leftvt == VT_R8 || rightvt == VT_R8)
2157 else if (leftvt == VT_BSTR || rightvt == VT_BSTR) {
2159 } else if (leftvt == VT_R4 || rightvt == VT_R4) {
2160 if (leftvt == VT_I4 || rightvt == VT_I4 ||
2161 leftvt == VT_I8 || rightvt == VT_I8)
2166 else if (leftvt == VT_I8 || rightvt == VT_I8)
2168 else if (leftvt == VT_I4 || rightvt == VT_I4)
2170 else if (leftvt == VT_I2 || rightvt == VT_I2 ||
2171 leftvt == VT_BOOL || rightvt == VT_BOOL ||
2172 (leftvt == VT_EMPTY && rightvt == VT_EMPTY))
2174 else if (leftvt == VT_UI1 || rightvt == VT_UI1)
2179 expectedhres = DISP_E_TYPEMISMATCH;
2182 hres = pVarSub(&left, &right, &result);
2184 ok(hres == expectedhres && V_VT(&result) == resvt,
2185 "VarSub: %d|0x%X, %d|0x%X: Expected failure 0x%X, "
2186 "got 0x%X, expected vt %d got vt %d\n",
2187 leftvt, ExtraFlags[i], rightvt, ExtraFlags[i],
2188 expectedhres, hres, resvt, V_VT(&result));
2193 /* Test returned values */
2194 VARSUB(I4,4,I4,2,I4,2);
2195 VARSUB(I2,4,I2,2,I2,2);
2196 VARSUB(I2,-13,I4,5,I4,-18);
2197 VARSUB(I4,-13,I4,5,I4,-18);
2198 VARSUB(I2,7,R4,0.5f,R4,6.5f);
2199 VARSUB(R4,0.5f,I4,5,R8,-4.5);
2200 VARSUB(R8,7.1,BOOL,0,R8,7.1);
2201 VARSUB(BSTR,lbstr,I2,4,R8,8);
2202 VARSUB(BSTR,lbstr,BOOL,1,R8,11);
2203 VARSUB(BSTR,lbstr,R4,0.1f,R8,11.9);
2204 VARSUB(R4,0.2f,BSTR,rbstr,R8,-11.8);
2205 VARSUB(DATE,2.25,I4,7,DATE,-4.75);
2206 VARSUB(DATE,1.25,R4,-1.7f,DATE,2.95);
2208 VARSUB(UI1, UI1_MAX, UI1, UI1_MAX, UI1, 0);
2209 VARSUB(I2, I2_MAX, I2, I2_MAX, I2, 0);
2210 VARSUB(I2, I2_MIN, I2, I2_MIN, I2, 0);
2211 VARSUB(I4, I4_MAX, I4, I4_MAX, I4, 0);
2212 VARSUB(I4, I4_MIN, I4, I4_MIN, I4, 0);
2213 VARSUB(R4, R4_MAX, R4, R4_MAX, R4, 0.0f);
2214 VARSUB(R4, R4_MAX, R4, R4_MIN, R4, R4_MAX - R4_MIN);
2215 VARSUB(R4, R4_MIN, R4, R4_MIN, R4, 0.0f);
2216 VARSUB(R8, R8_MAX, R8, R8_MIN, R8, R8_MAX - R8_MIN);
2217 VARSUB(R8, R8_MIN, R8, R8_MIN, R8, 0.0);
2219 /* Manually test BSTR + BSTR */
2220 V_VT(&left) = VT_BSTR;
2221 V_BSTR(&left) = lbstr;
2222 V_VT(&right) = VT_BSTR;
2223 V_BSTR(&right) = rbstr;
2224 hres = VarSub(&left, &right, &result);
2225 ok(hres == S_OK && V_VT(&result) == VT_R8,
2226 "VarSub: expected coerced type VT_R8, got %s!\n", vtstr(V_VT(&result)));
2227 ok(hres == S_OK && EQ_DOUBLE(V_R8(&result), 0),
2228 "VarSub: BSTR + BSTR, expected %f got %f\n", 0.0, V_R8(&result));
2230 /* Manually test some VT_CY and VT_DECIMAL variants */
2232 hres = VarCyFromI4(4711, &V_CY(&cy));
2233 ok(hres == S_OK, "VarCyFromI4 failed!\n");
2234 V_VT(&dec) = VT_DECIMAL;
2235 hres = VarDecFromR8(-4.2, &V_DECIMAL(&dec));
2236 ok(hres == S_OK, "VarDecFromR4 failed!\n");
2237 memset(&left, 0, sizeof(left));
2238 memset(&right, 0, sizeof(right));
2239 V_VT(&left) = VT_I4;
2241 V_VT(&right) = VT_UI1;
2244 hres = VarSub(&cy, &right, &result);
2245 ok(hres == S_OK && V_VT(&result) == VT_CY,
2246 "VarSub: expected coerced type VT_CY, got %s!\n", vtstr(V_VT(&result)));
2247 hres = VarR8FromCy(V_CY(&result), &r);
2248 ok(hres == S_OK && EQ_DOUBLE(r, 4702),
2249 "VarSub: CY value %f, expected %f\n", r, (double)4720);
2251 hres = VarSub(&left, &dec, &result);
2252 ok(hres == S_OK && V_VT(&result) == VT_DECIMAL,
2253 "VarSub: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result)));
2254 hres = VarR8FromDec(&V_DECIMAL(&result), &r);
2255 ok(hres == S_OK && EQ_DOUBLE(r, -6.8),
2256 "VarSub: DECIMAL value %f, expected %f\n", r, (double)-15.2);
2258 SysFreeString(lbstr);
2259 SysFreeString(rbstr);
2262 static HRESULT (WINAPI *pVarMod)(LPVARIANT,LPVARIANT,LPVARIANT);
2264 static void test_Mod( int line, VARIANT *left, VARIANT *right, VARIANT *expected, HRESULT expres )
2269 memset( &result, 0, sizeof(result) );
2270 hres = pVarMod( left, right, &result );
2271 ok_(__FILE__,line)( hres == expres, "wrong result %x/%x\n", hres, expres );
2273 ok_(__FILE__,line)( is_expected_variant( &result, expected ),
2274 "got %s expected %s\n", variantstr(&result), variantstr(expected) );
2277 #define VARMOD(vt1,vt2,val1,val2,rvt,rval) \
2278 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
2279 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
2280 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
2281 test_var_call2( __LINE__, pVarMod, &left, &right, &exp )
2283 #define VARMOD2(vt1,vt2,val1,val2,rvt,rval,hexpected) \
2284 V_VT(&left) = VT_##vt1; V_I4(&left) = val1; \
2285 V_VT(&right) = VT_##vt2; V_I4(&right) = val2; \
2286 V_VT(&exp) = VT_##rvt; V_I4(&exp) = rval; \
2287 test_Mod( __LINE__, &left, &right, &exp, hexpected )
2289 static void test_VarMod(void)
2291 VARIANT v1, v2, vDst, left, right, exp;
2293 HRESULT hexpected = 0;
2294 static const WCHAR szNum0[] = {'1','2','5','\0'};
2295 static const WCHAR szNum1[] = {'1','0','\0'};
2297 BOOL lFound, rFound;
2298 BOOL lValid, rValid;
2299 BSTR strNum0, strNum1;
2303 VARMOD(I1,BOOL,100,10,I4,0);
2304 VARMOD(I1,I1,100,10,I4,0);
2305 VARMOD(I1,UI1,100,10,I4,0);
2306 VARMOD(I1,I2,100,10,I4,0);
2307 VARMOD(I1,UI2,100,10,I4,0);
2308 VARMOD(I1,I4,100,10,I4,0);
2309 VARMOD(I1,UI4,100,10,I4,0);
2310 VARMOD(I1,R4,100,10,I4,0);
2311 VARMOD(I1,R8,100,10,I4,0);
2313 VARMOD(UI1,BOOL,100,10,I2,0);
2314 VARMOD(UI1,I1,100,10,I4,0);
2315 VARMOD(UI1,UI1,100,10,UI1,0);
2316 VARMOD(UI1,I2,100,10,I2,0);
2317 VARMOD(UI1,UI2,100,10,I4,0);
2318 VARMOD(UI1,I4,100,10,I4,0);
2319 VARMOD(UI1,UI4,100,10,I4,0);
2320 VARMOD(UI1,R4,100,10,I4,0);
2321 VARMOD(UI1,R8,100,10,I4,0);
2323 VARMOD(I2,BOOL,100,10,I2,0);
2324 VARMOD(I2,I1,100,10,I4,0);
2325 VARMOD(I2,UI1,100,10,I2,0);
2326 VARMOD(I2,I2,100,10,I2,0);
2327 VARMOD(I2,UI2,100,10,I4,0);
2328 VARMOD(I2,I4,100,10,I4,0);
2329 VARMOD(I2,UI4,100,10,I4,0);
2330 VARMOD(I2,R4,100,10,I4,0);
2331 VARMOD(I2,R8,100,10,I4,0);
2333 VARMOD(I4,BOOL,100,10,I4,0);
2334 VARMOD(I4,I1,100,10,I4,0);
2335 VARMOD(I4,UI1,100,10,I4,0);
2336 VARMOD(I4,I2,100,10,I4,0);
2337 VARMOD(I4,UI2,100,10,I4,0);
2338 VARMOD(I4,I4,100,10,I4,0);
2339 VARMOD(I4,UI4,100,10,I4,0);
2340 VARMOD(I4,R4,100,10,I4,0);
2341 VARMOD(I4,R8,100,10,I4,0);
2342 VARMOD(UI4,BOOL,100,10,I4,0);
2343 VARMOD(UI4,I1,100,10,I4,0);
2344 VARMOD(UI4,UI1,100,10,I4,0);
2345 VARMOD(UI4,I2,100,10,I4,0);
2346 VARMOD(UI4,UI2,100,10,I4,0);
2347 VARMOD(UI4,I4,100,10,I4,0);
2348 VARMOD(UI4,UI4,100,10,I4,0);
2349 VARMOD(UI4,R4,100,10,I4,0);
2350 VARMOD(UI4,R8,100,10,I4,0);
2351 VARMOD(R4,BOOL,100,10,I4,0);
2352 VARMOD(R4,I1,100,10,I4,0);
2353 VARMOD(R4,UI1,100,10,I4,0);
2354 VARMOD(R4,I2,100,10,I4,0);
2355 VARMOD(R4,UI2,100,10,I4,0);
2356 VARMOD(R4,I4,100,10,I4,0);
2357 VARMOD(R4,UI4,100,10,I4,0);
2358 VARMOD(R4,R4,100,10,I4,0);
2359 VARMOD(R4,R8,100,10,I4,0);
2360 VARMOD(R8,BOOL,100,10,I4,0);
2361 VARMOD(R8,I1,100,10,I4,0);
2362 VARMOD(R8,UI1,100,10,I4,0);
2363 VARMOD(R8,I2,100,10,I4,0);
2364 VARMOD(R8,UI2,100,10,I4,0);
2365 VARMOD(R8,I4,100,10,I4,0);
2366 VARMOD(R8,UI4,100,10,I4,0);
2367 VARMOD(R8,R4,100,10,I4,0);
2368 VARMOD(R8,R8,100,10,I4,0);
2370 VARMOD(INT,INT,100,10,I4,0);
2371 VARMOD(INT,UINT,100,10,I4,0);
2373 VARMOD(BOOL,BOOL,100,10,I2,0);
2374 VARMOD(BOOL,I1,100,10,I4,0);
2375 VARMOD(BOOL,UI1,100,10,I2,0);
2376 VARMOD(BOOL,I2,100,10,I2,0);
2377 VARMOD(BOOL,UI2,100,10,I4,0);
2378 VARMOD(BOOL,I4,100,10,I4,0);
2379 VARMOD(BOOL,UI4,100,10,I4,0);
2380 VARMOD(BOOL,R4,100,10,I4,0);
2381 VARMOD(BOOL,R8,100,10,I4,0);
2382 VARMOD(BOOL,DATE,100,10,I4,0);
2384 VARMOD(DATE,BOOL,100,10,I4,0);
2385 VARMOD(DATE,I1,100,10,I4,0);
2386 VARMOD(DATE,UI1,100,10,I4,0);
2387 VARMOD(DATE,I2,100,10,I4,0);
2388 VARMOD(DATE,UI2,100,10,I4,0);
2389 VARMOD(DATE,I4,100,10,I4,0);
2390 VARMOD(DATE,UI4,100,10,I4,0);
2391 VARMOD(DATE,R4,100,10,I4,0);
2392 VARMOD(DATE,R8,100,10,I4,0);
2393 VARMOD(DATE,DATE,100,10,I4,0);
2395 strNum0 = SysAllocString(szNum0);
2396 strNum1 = SysAllocString(szNum1);
2397 VARMOD(BSTR,BSTR,strNum0,strNum1,I4,5);
2398 VARMOD(BSTR,I1,strNum0,10,I4,5);
2399 VARMOD(BSTR,I2,strNum0,10,I4,5);
2400 VARMOD(BSTR,I4,strNum0,10,I4,5);
2401 VARMOD(BSTR,R4,strNum0,10,I4,5);
2402 VARMOD(BSTR,R8,strNum0,10,I4,5);
2403 VARMOD(I4,BSTR,125,strNum1,I4,5);
2405 if (HAVE_OLEAUT32_I8)
2407 VARMOD(BOOL,I8,100,10,I8,0);
2408 VARMOD(I1,I8,100,10,I8,0);
2409 VARMOD(UI1,I8,100,10,I8,0);
2410 VARMOD(I2,I8,100,10,I8,0);
2411 VARMOD(I4,I8,100,10,I8,0);
2412 VARMOD(UI4,I8,100,10,I8,0);
2413 VARMOD(R4,I8,100,10,I8,0);
2414 VARMOD(R8,I8,100,10,I8,0);
2415 VARMOD(DATE,I8,100,10,I8,0);
2417 VARMOD(I8,BOOL,100,10,I8,0);
2418 VARMOD(I8,I1,100,10,I8,0);
2419 VARMOD(I8,UI1,100,10,I8,0);
2420 VARMOD(I8,I2,100,10,I8,0);
2421 VARMOD(I8,UI2,100,10,I8,0);
2422 VARMOD(I8,I4,100,10,I8,0);
2423 VARMOD(I8,UI4,100,10,I8,0);
2424 VARMOD(I8,R4,100,10,I8,0);
2425 VARMOD(I8,R8,100,10,I8,0);
2426 VARMOD(I8,I8,100,10,I8,0);
2428 VARMOD(BSTR,I8,strNum0,10,I8,5);
2431 /* test all combinations of types */
2432 for(l = 0; l < VT_BSTR_BLOB; l++)
2436 for(r = 0; r < VT_BSTR_BLOB; r++)
2440 if(l == VT_BSTR) continue;
2441 if(l == VT_DISPATCH) continue;
2442 if(r == VT_BSTR) continue;
2443 if(r == VT_DISPATCH) continue;
2477 hexpected = DISP_E_BADVARTYPE;
2516 if(((l == VT_I8) && (r == VT_INT)) || ((l == VT_INT) && (r == VT_I8)))
2518 hexpected = DISP_E_TYPEMISMATCH;
2519 } else if((l == VT_EMPTY) && (r == VT_NULL))
2522 } else if((l == VT_NULL) && (r == VT_EMPTY))
2525 } else if((l == VT_EMPTY) && (r == VT_CY))
2528 } else if((l == VT_EMPTY) && (r == VT_RECORD))
2530 hexpected = DISP_E_TYPEMISMATCH;
2531 } else if((r == VT_EMPTY) && lFound && lValid)
2533 hexpected = DISP_E_DIVBYZERO;
2534 } else if((l == VT_ERROR) || ((r == VT_ERROR) && lFound && lValid))
2536 hexpected = DISP_E_TYPEMISMATCH;
2537 } else if((l == VT_NULL) && (r == VT_NULL))
2540 } else if((l == VT_VARIANT) || ((r == VT_VARIANT) && lFound && lValid))
2542 hexpected = DISP_E_TYPEMISMATCH;
2543 } else if((l == VT_NULL) && (r == VT_RECORD))
2545 hexpected = DISP_E_TYPEMISMATCH;
2546 } else if((l == VT_I8) && (r == VT_DECIMAL))
2549 } else if((l == VT_DECIMAL) && (r == VT_I8))
2552 } else if((l == VT_UNKNOWN) || ((r == VT_UNKNOWN) && lFound && lValid))
2554 hexpected = DISP_E_TYPEMISMATCH;
2555 } else if((l == VT_NULL) && rFound)
2558 } else if(l == VT_RECORD)
2560 hexpected = DISP_E_TYPEMISMATCH;
2561 } else if((r == VT_RECORD) && lValid && lFound)
2563 hexpected = DISP_E_TYPEMISMATCH;
2564 } else if((l == VT_EMPTY) && (r == VT_EMPTY))
2566 hexpected = DISP_E_DIVBYZERO;
2567 } else if((l == VT_CY) && !rFound)
2569 hexpected = DISP_E_BADVARTYPE;
2570 } else if(lFound && !rFound)
2572 hexpected = DISP_E_BADVARTYPE;
2573 } else if(!lFound && rFound)
2575 hexpected = DISP_E_BADVARTYPE;
2576 } else if((r == VT_NULL) && lFound && lValid)
2579 } else if((l == VT_NULL) || (r == VT_NULL))
2581 hexpected = DISP_E_BADVARTYPE;
2582 } else if((l == VT_VARIANT) || (r == VT_VARIANT))
2584 hexpected = DISP_E_BADVARTYPE;
2585 } else if(lFound && !rFound)
2587 hexpected = DISP_E_BADVARTYPE;
2588 } else if(!lFound && !rFound)
2590 hexpected = DISP_E_BADVARTYPE;
2597 V_CY(&v1).int64 = 1000000;
2602 else if(l == VT_UI8)
2606 else if(l == VT_DATE)
2608 else if (l == VT_DECIMAL)
2610 V_DECIMAL(&v1).Hi32 = 0;
2611 U1(V_DECIMAL(&v1)).Lo64 = 100;
2612 U(V_DECIMAL(&v1)).signscale = 0;
2618 V_CY(&v2).int64 = 10000;
2623 else if(r == VT_UI8)
2627 else if(r == VT_DATE)
2629 else if (r == VT_DECIMAL)
2631 V_DECIMAL(&v2).Hi32 = 0;
2632 U1(V_DECIMAL(&v2)).Lo64 = 100;
2633 U(V_DECIMAL(&v2)).signscale = 0;
2638 if ((l != VT_I8 && l != VT_UI8 && r != VT_I8 && r != VT_UI8) || HAVE_OLEAUT32_I8)
2640 hres = pVarMod(&v1,&v2,&vDst);
2641 ok(hres == hexpected,
2642 "VarMod: expected 0x%x, got 0x%X for l type of %d, r type of %d,\n", hexpected, hres, l, r);
2648 /****************************/
2649 /* test some bad parameters */
2650 VARMOD(I4,I4,-1,-1,I4,0);
2652 /* test modulus with zero */
2653 VARMOD2(I4,I4,100,0,EMPTY,0,DISP_E_DIVBYZERO);
2655 VARMOD(I4,I4,0,10,I4,0); /* test 0 mod 10 */
2657 /* right parameter is type empty */
2658 VARMOD2(I4,EMPTY,100,10,EMPTY,0,DISP_E_DIVBYZERO);
2660 /* left parameter is type empty */
2661 VARMOD2(EMPTY,I4,100,10,I4,0,S_OK);
2663 /* mod with a null left value */
2664 VARMOD2(NULL,I4,125,10,NULL,0,S_OK);
2666 /* mod with a null right value */
2667 VARMOD2(I4,NULL,100,10,NULL,0,S_OK);
2669 /* void left value */
2670 VARMOD2(VOID,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2672 /* void right value */
2673 VARMOD2(I4,VOID,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2675 /* null left value, void right value */
2676 VARMOD2(NULL,VOID,100,10,EMPTY, 0, DISP_E_BADVARTYPE);
2678 /* void left value, null right value */
2679 VARMOD2(VOID,NULL,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2681 /* some currencies */
2684 V_CY(&v1).int64 = 100000;
2685 V_CY(&v2).int64 = 100000;
2686 hres = pVarMod(&v1,&v2,&vDst);
2687 ok(hres == S_OK && V_VT(&vDst) == VT_I4 && V_I4(&vDst) == 0,
2688 "VarMod: expected 0x%x,%d,%d, got 0x%X,%d,%d\n", S_OK, VT_I4, 0, hres, V_VT(&vDst), V_I4(&vDst));
2693 V_CY(&v2).int64 = 100000;
2694 hres = pVarMod(&v1,&v2,&vDst);
2695 ok(hres == S_OK && V_VT(&vDst) == VT_I4 && V_I4(&vDst) == 0,
2696 "VarMod: expected 0x%x,%d,%d, got 0x%X,%d,%d\n", S_OK, VT_I4, 0, hres, V_VT(&vDst), V_I4(&vDst));
2699 V_VT(&v1) = VT_DECIMAL;
2700 V_VT(&v2) = VT_DECIMAL;
2701 VarDecFromI4(100, &V_DECIMAL(&v1));
2702 VarDecFromI4(10, &V_DECIMAL(&v2));
2703 hres = pVarMod(&v1,&v2,&vDst);
2704 ok(hres == S_OK && V_VT(&vDst) == VT_I4 && V_I4(&vDst) == 0,
2705 "VarMod: expected 0x%x,%d,%d, got 0x%X,%d,%d\n", S_OK, VT_I4, 0, hres, V_VT(&vDst), V_I4(&vDst));
2708 V_VT(&v2) = VT_DECIMAL;
2710 VarDecFromI4(10, &V_DECIMAL(&v2));
2711 hres = pVarMod(&v1,&v2,&vDst);
2712 ok(hres == S_OK && V_VT(&vDst) == VT_I4 && V_I4(&vDst) == 0,
2713 "VarMod: expected 0x%x,%d,%d, got 0x%X,%d,%d\n", S_OK, VT_I4, 0, hres, V_VT(&vDst), V_I4(&vDst));
2715 VARMOD2(UINT,I4,100,10,I4,0,S_OK);
2717 /* test that an error results in the type of the result changing but not its value */
2718 V_VT(&v1) = VT_UNKNOWN;
2719 V_VT(&v2) = VT_EMPTY;
2721 V_CY(&v2).int64 = 100000;
2722 V_VT(&vDst) = VT_I4;
2724 hres = pVarMod(&v1,&v2,&vDst);
2725 ok(hres == DISP_E_TYPEMISMATCH && V_VT(&vDst) == VT_EMPTY && V_I4(&vDst) == 1231,
2726 "VarMod: expected 0x%x,%d,%d, got 0x%X,%d,%d\n", DISP_E_TYPEMISMATCH, VT_EMPTY, 1231, hres, V_VT(&vDst), V_I4(&vDst));
2729 /* test some invalid types */
2730 /*TODO: not testing VT_DISPATCH */
2731 if (HAVE_OLEAUT32_I8)
2733 VARMOD2(I8,INT,100,10,EMPTY,0,DISP_E_TYPEMISMATCH);
2735 VARMOD2(ERROR,I4,100,10,EMPTY,0,DISP_E_TYPEMISMATCH);
2736 VARMOD2(VARIANT,I4,100,10,EMPTY,0,DISP_E_TYPEMISMATCH);
2737 VARMOD2(UNKNOWN,I4,100,10,EMPTY,0,DISP_E_TYPEMISMATCH);
2738 VARMOD2(VOID,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2739 VARMOD2(HRESULT,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2740 VARMOD2(PTR,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2741 VARMOD2(SAFEARRAY,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2742 VARMOD2(CARRAY,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2743 VARMOD2(USERDEFINED,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2744 VARMOD2(LPSTR,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2745 VARMOD2(LPWSTR,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2746 VARMOD2(RECORD,I4,100,10,EMPTY,0,DISP_E_TYPEMISMATCH);
2747 VARMOD2(FILETIME,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2748 VARMOD2(BLOB,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2749 VARMOD2(STREAM,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2750 VARMOD2(STORAGE,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2751 VARMOD2(STREAMED_OBJECT,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2752 VARMOD2(STORED_OBJECT,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2753 VARMOD2(BLOB_OBJECT,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2754 VARMOD2(CF,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2755 VARMOD2(CLSID,CLSID,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2756 VARMOD2(VECTOR,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2757 VARMOD2(ARRAY,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2758 VARMOD2(BYREF,I4,100,10,EMPTY,0,DISP_E_BADVARTYPE);
2760 /* test some more invalid types */
2765 hres = pVarMod(&v1,&v2,&vDst);
2766 ok(hres == DISP_E_BADVARTYPE && V_VT(&vDst) == VT_EMPTY,
2767 "VarMod: expected 0x%x,%d, got 0x%X,%d\n", DISP_E_BADVARTYPE, VT_EMPTY, hres, V_VT(&vDst));
2769 SysFreeString(strNum0);
2770 SysFreeString(strNum1);
2773 static HRESULT (WINAPI *pVarFix)(LPVARIANT,LPVARIANT);
2775 #define VARFIX(vt,val,rvt,rval) \
2776 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
2777 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
2778 test_var_call1( __LINE__, pVarFix, &v, &exp )
2780 static void test_VarFix(void)
2782 static const WCHAR szNumMinus1[] = {'-','1','\0' };
2784 VARIANT v, exp, vDst;
2785 DECIMAL *pdec = &V_DECIMAL(&v);
2786 CY *pcy = &V_CY(&v);
2791 /* Test all possible V_VT values */
2792 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
2796 for (vt = 0; vt <= VT_BSTR_BLOB; vt++)
2798 HRESULT bFail = TRUE;
2802 memset(&v, 0, sizeof(v));
2803 V_VT(&v) = vt | ExtraFlags[i];
2804 V_VT(&vDst) = VT_EMPTY;
2808 case VT_UI1: case VT_I2: case VT_I4: case VT_R4: case VT_R8:
2809 case VT_DECIMAL: case VT_BOOL: case VT_NULL: case VT_EMPTY:
2810 case VT_DATE: case VT_CY:
2814 if (HAVE_OLEAUT32_I8)
2819 hres = pVarFix(&v,&vDst);
2821 ok(hres == DISP_E_TYPEMISMATCH || hres == DISP_E_BADVARTYPE,
2822 "VarFix: expected failure, got 0x%X vt %d|0x%X\n",
2823 hres, vt, ExtraFlags[i]);
2825 ok(hres == S_OK, "VarFix: expected S_OK, got 0x%X vt %d|0x%X\n",
2826 hres, vt, ExtraFlags[i]);
2830 VARFIX(BOOL,VARIANT_TRUE,I2,VARIANT_TRUE);
2831 VARFIX(BOOL,VARIANT_FALSE,I2,0);
2832 VARFIX(BOOL,1,I2,1);
2833 VARFIX(UI1,1,UI1,1);
2834 VARFIX(I2,-1,I2,-1);
2835 VARFIX(I4,-1,I4,-1);
2836 if (HAVE_OLEAUT32_I8)
2838 VARFIX(I8,-1,I8,-1);
2840 VARFIX(R4,1.4f,R4,1);
2841 VARFIX(R4,1.5f,R4,1);
2842 VARFIX(R4,1.6f,R4,1);
2843 VARFIX(R4,-1.4f,R4,-1);
2844 VARFIX(R4,-1.5f,R4,-1);
2845 VARFIX(R4,-1.6f,R4,-1);
2846 /* DATE & R8 round as for R4 */
2847 VARFIX(DATE,-1,DATE,-1);
2848 VARFIX(R8,-1,R8,-1);
2849 VARFIX(BSTR,(BSTR)szNumMinus1,R8,-1);
2851 V_VT(&v) = VT_EMPTY;
2852 hres = pVarFix(&v,&vDst);
2853 ok(hres == S_OK && V_VT(&vDst) == VT_I2 && V_I2(&vDst) == 0,
2854 "VarFix: expected 0x0,%d,0 got 0x%X,%d,%d\n", VT_EMPTY,
2855 hres, V_VT(&vDst), V_I2(&vDst));
2858 hres = pVarFix(&v,&vDst);
2859 ok(hres == S_OK && V_VT(&vDst) == VT_NULL,
2860 "VarFix: expected 0x0,%d got 0x%X,%d\n", VT_NULL, hres, V_VT(&vDst));
2862 V_VT(&v) = VT_DECIMAL;
2863 S(U(*pdec)).sign = DECIMAL_NEG;
2864 S(U(*pdec)).scale = 0;
2866 S1(U1(*pdec)).Mid32 = 0;
2867 S1(U1(*pdec)).Lo32 = 1;
2868 hres = pVarFix(&v,&vDst);
2869 ok(hres == S_OK && V_VT(&vDst) == VT_DECIMAL && !memcmp(&V_DECIMAL(&v), &V_DECIMAL(&vDst), sizeof(DECIMAL)),
2870 "VarFix: expected 0x0,%d,identical, got 0x%X,%d\n", VT_DECIMAL,
2873 /* FIXME: Test some fractional decimals when VarDecFix is implemented */
2876 pcy->int64 = -10000;
2877 hres = pVarFix(&v,&vDst);
2878 ok(hres == S_OK && V_VT(&vDst) == VT_CY && V_CY(&vDst).int64 == -10000,
2879 "VarFix: VT_CY wrong, hres=0x%X\n", hres);
2882 pcy->int64 = -16000;
2883 hres = pVarFix(&v,&vDst);
2884 ok(hres == S_OK && V_VT(&vDst) == VT_CY && V_CY(&vDst).int64 == -10000,
2885 "VarFix: VT_CY wrong, hres=0x%X\n", hres);
2888 static HRESULT (WINAPI *pVarInt)(LPVARIANT,LPVARIANT);
2890 #define VARINT(vt,val,rvt,rval) \
2891 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
2892 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
2893 test_var_call1( __LINE__, pVarInt, &v, &exp )
2895 static void test_VarInt(void)
2897 static const WCHAR szNumMinus1[] = {'-','1','\0' };
2899 VARIANT v, exp, vDst;
2900 DECIMAL *pdec = &V_DECIMAL(&v);
2901 CY *pcy = &V_CY(&v);
2906 /* Test all possible V_VT values */
2907 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
2911 for (vt = 0; vt <= VT_BSTR_BLOB; vt++)
2913 HRESULT bFail = TRUE;
2917 memset(&v, 0, sizeof(v));
2918 V_VT(&v) = vt | ExtraFlags[i];
2919 V_VT(&vDst) = VT_EMPTY;
2923 case VT_UI1: case VT_I2: case VT_I4: case VT_R4: case VT_R8:
2924 case VT_DECIMAL: case VT_BOOL: case VT_NULL: case VT_EMPTY:
2925 case VT_DATE: case VT_CY:
2929 if (HAVE_OLEAUT32_I8)
2934 hres = pVarInt(&v,&vDst);
2936 ok(hres == DISP_E_TYPEMISMATCH || hres == DISP_E_BADVARTYPE,
2937 "VarInt: expected failure, got 0x%X vt %d|0x%X\n",
2938 hres, vt, ExtraFlags[i]);
2940 ok(hres == S_OK, "VarInt: expected S_OK, got 0x%X vt %d|0x%X\n",
2941 hres, vt, ExtraFlags[i]);
2945 VARINT(BOOL,VARIANT_TRUE,I2,VARIANT_TRUE);
2946 VARINT(BOOL,VARIANT_FALSE,I2,0);
2947 VARINT(BOOL,1,I2,1);
2948 VARINT(UI1,1,UI1,1);
2949 VARINT(I2,-1,I2,-1);
2950 VARINT(I4,-1,I4,-1);
2951 if (HAVE_OLEAUT32_I8)
2953 VARINT(I8,-1,I8,-1);
2955 VARINT(R4,1.4f,R4,1);
2956 VARINT(R4,1.5f,R4,1);
2957 VARINT(R4,1.6f,R4,1);
2958 VARINT(R4,-1.4f,R4,-2); /* Note these 3 are different from VarFix */
2959 VARINT(R4,-1.5f,R4,-2);
2960 VARINT(R4,-1.6f,R4,-2);
2961 /* DATE & R8 round as for R4 */
2962 VARINT(DATE,-1,DATE,-1);
2963 VARINT(R8,-1,R8,-1);
2964 VARINT(BSTR,(BSTR)szNumMinus1,R8,-1);
2966 V_VT(&v) = VT_EMPTY;
2967 hres = pVarInt(&v,&vDst);
2968 ok(hres == S_OK && V_VT(&vDst) == VT_I2 && V_I2(&vDst) == 0,
2969 "VarInt: expected 0x0,%d,0 got 0x%X,%d,%d\n", VT_EMPTY,
2970 hres, V_VT(&vDst), V_I2(&vDst));
2973 hres = pVarInt(&v,&vDst);
2974 ok(hres == S_OK && V_VT(&vDst) == VT_NULL,
2975 "VarInt: expected 0x0,%d got 0x%X,%d\n", VT_NULL, hres, V_VT(&vDst));
2977 V_VT(&v) = VT_DECIMAL;
2978 S(U(*pdec)).sign = DECIMAL_NEG;
2979 S(U(*pdec)).scale = 0;
2981 S1(U1(*pdec)).Mid32 = 0;
2982 S1(U1(*pdec)).Lo32 = 1;
2983 hres = pVarInt(&v,&vDst);
2984 ok(hres == S_OK && V_VT(&vDst) == VT_DECIMAL && !memcmp(&V_DECIMAL(&v), &V_DECIMAL(&vDst), sizeof(DECIMAL)),
2985 "VarInt: expected 0x0,%d,identical, got 0x%X,%d\n", VT_DECIMAL,
2988 /* FIXME: Test some fractional decimals when VarDecInt is implemented */
2991 pcy->int64 = -10000;
2992 hres = pVarInt(&v,&vDst);
2993 ok(hres == S_OK && V_VT(&vDst) == VT_CY && V_CY(&vDst).int64 == -10000,
2994 "VarInt: VT_CY wrong, hres=0x%X\n", hres);
2997 pcy->int64 = -11000;
2998 hres = pVarInt(&v,&vDst);
2999 ok(hres == S_OK && V_VT(&vDst) == VT_CY && V_CY(&vDst).int64 == -20000,
3000 "VarInt: VT_CY wrong, hres=0x%X 0x%x%08x\n",
3001 hres, (DWORD)(V_CY(&vDst).int64 >> 32), (DWORD)V_CY(&vDst).int64);
3004 static HRESULT (WINAPI *pVarNeg)(LPVARIANT,LPVARIANT);
3006 #define VARNEG(vt,val,rvt,rval) \
3007 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
3008 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
3009 test_var_call1( __LINE__, pVarNeg, &v, &exp )
3011 static void test_VarNeg(void)
3013 static const WCHAR szNumMinus1[] = {'-','1','\0' };
3014 static const WCHAR szNum1[] = {'1','\0' };
3016 VARIANT v, exp, vDst;
3017 DECIMAL *pdec = &V_DECIMAL(&v);
3018 CY *pcy = &V_CY(&v);
3023 /* Test all possible V_VT values. But don't test the exact return values
3024 * except for success/failure, since M$ made a hash of them in the
3025 * native version. This at least ensures (as with all tests here) that
3026 * we will notice if/when new vtypes/flags are added in native.
3028 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
3032 for (vt = 0; vt <= VT_BSTR_BLOB; vt++)
3034 HRESULT bFail = TRUE;
3038 memset(&v, 0, sizeof(v));
3039 V_VT(&v) = vt | ExtraFlags[i];
3040 V_VT(&vDst) = VT_EMPTY;
3044 case VT_UI1: case VT_I2: case VT_I4:
3045 case VT_R4: case VT_R8:
3046 case VT_DECIMAL: case VT_BOOL: case VT_NULL: case VT_EMPTY:
3047 case VT_DATE: case VT_CY:
3051 if (HAVE_OLEAUT32_I8)
3055 hres = pVarNeg(&v,&vDst);
3057 ok(hres == DISP_E_TYPEMISMATCH || hres == DISP_E_BADVARTYPE,
3058 "VarNeg: expected failure, got 0x%X vt %d|0x%X\n",
3059 hres, vt, ExtraFlags[i]);
3061 ok(hres == S_OK, "VarNeg: expected S_OK, got 0x%X vt %d|0x%X\n",
3062 hres, vt, ExtraFlags[i]);
3066 VARNEG(BOOL,VARIANT_TRUE,I2,1);
3067 VARNEG(BOOL,VARIANT_FALSE,I2,0);
3068 VARNEG(BOOL,1,I2,-1);
3069 VARNEG(UI1,1,I2,-1);
3070 VARNEG(UI1,254,I2,-254);
3071 VARNEG(I2,-32768,I4,32768);
3074 VARNEG(I4,-((int)(~0u >> 1)) - 1,R8,-2147483648u);
3077 if (HAVE_OLEAUT32_I8)
3084 VARNEG(DATE,1,DATE,-1);
3085 VARNEG(DATE,-1,DATE,1);
3088 VARNEG(BSTR,(BSTR)szNumMinus1,R8,1);
3089 VARNEG(BSTR,(BSTR)szNum1,R8,-1);
3091 V_VT(&v) = VT_EMPTY;
3092 hres = pVarNeg(&v,&vDst);
3093 ok(hres == S_OK && V_VT(&vDst) == VT_I2 && V_I2(&vDst) == 0,
3094 "VarNeg: expected 0x0,%d,0 got 0x%X,%d,%d\n", VT_EMPTY,
3095 hres, V_VT(&vDst), V_I2(&vDst));
3098 hres = pVarNeg(&v,&vDst);
3099 ok(hres == S_OK && V_VT(&vDst) == VT_NULL,
3100 "VarNeg: expected 0x0,%d got 0x%X,%d\n", VT_NULL, hres, V_VT(&vDst));
3102 V_VT(&v) = VT_DECIMAL;
3103 S(U(*pdec)).sign = DECIMAL_NEG;
3104 S(U(*pdec)).scale = 0;
3106 S1(U1(*pdec)).Mid32 = 0;
3107 S1(U1(*pdec)).Lo32 = 1;
3108 hres = pVarNeg(&v,&vDst);
3109 ok(hres == S_OK && V_VT(&vDst) == VT_DECIMAL &&
3110 S(U(V_DECIMAL(&vDst))).sign == 0,
3111 "VarNeg: expected 0x0,%d,0x00, got 0x%X,%d,%02x\n", VT_DECIMAL,
3112 hres, V_VT(&vDst), S(U(V_DECIMAL(&vDst))).sign);
3114 S(U(*pdec)).sign = 0;
3115 hres = pVarNeg(&v,&vDst);
3116 ok(hres == S_OK && V_VT(&vDst) == VT_DECIMAL &&
3117 S(U(V_DECIMAL(&vDst))).sign == DECIMAL_NEG,
3118 "VarNeg: expected 0x0,%d,0x7f, got 0x%X,%d,%02x\n", VT_DECIMAL,
3119 hres, V_VT(&vDst), S(U(V_DECIMAL(&vDst))).sign);
3122 pcy->int64 = -10000;
3123 hres = pVarNeg(&v,&vDst);
3124 ok(hres == S_OK && V_VT(&vDst) == VT_CY && V_CY(&vDst).int64 == 10000,
3125 "VarNeg: VT_CY wrong, hres=0x%X\n", hres);
3128 static HRESULT (WINAPI *pVarRound)(LPVARIANT,int,LPVARIANT);
3130 static void test_Round( int line, VARIANT *arg, int deci, VARIANT *expected )
3135 memset( &result, 0, sizeof(result) );
3136 hres = pVarRound( arg, deci, &result );
3137 ok_(__FILE__,line)( hres == S_OK, "wrong result %x\n", hres );
3139 ok_(__FILE__,line)( is_expected_variant( &result, expected ),
3140 "got %s expected %s\n", variantstr(&result), variantstr(expected) );
3142 #define VARROUND(vt,val,deci,rvt,rval) \
3143 V_VT(&v) = VT_##vt; V_##vt(&v) = val; \
3144 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
3145 test_Round( __LINE__, &v, deci, &exp )
3147 static void test_VarRound(void)
3149 static WCHAR szNumMin[] = {'-','1','.','4','4','9','\0' };
3150 static WCHAR szNum[] = {'1','.','4','5','1','\0' };
3152 VARIANT v, exp, vDst;
3153 CY *pcy = &V_CY(&v);
3158 /* first check valid integer types */
3159 VARROUND(BOOL,VARIANT_TRUE,0,I2,-1);
3160 VARROUND(BOOL,VARIANT_FALSE,0,I2,0);
3161 VARROUND(BOOL,1,0,I2,1);
3162 VARROUND(UI1,1,0,UI1,1);
3163 VARROUND(UI1,254,0,UI1,254);
3164 VARROUND(I2,-32768,0,I2,-32768);
3165 VARROUND(I2,-1,0,I2,-1);
3166 VARROUND(I2,1,0,I2,1);
3167 VARROUND(I4,-((int)(~0u >> 1)) - 1,0,I4,-((int)(~0u >> 1)) - 1);
3168 VARROUND(I4,-1,0,I4,-1);
3169 VARROUND(I4,1,0,I4,1);
3172 /* MSDN states that rounding of R4/R8 is dependent on the underlying
3173 * bit pattern of the number and so is architecture dependent. In this
3174 * case Wine returns .2 (which is more correct) and Native returns .3
3177 VARROUND(R4,1.0f,0,R4,1.0f);
3178 VARROUND(R4,-1.0f,0,R4,-1.0f);
3179 VARROUND(R8,1.0,0,R8,1.0);
3180 VARROUND(R8,-1.0,0,R8,-1.0);
3182 /* floating point numbers aren't exactly equal and we can't just
3183 * compare the first few digits. */
3184 VARROUND(DATE,1.451,1,DATE,1.5);
3185 VARROUND(DATE,-1.449,1,DATE,-1.4);
3187 /* replace the decimal separator */
3188 GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, buff, sizeof(buff)/sizeof(char));
3190 szNumMin[2] = buff[0];
3192 VARROUND(BSTR,(BSTR)szNumMin,1,R8,-1.40);
3193 VARROUND(BSTR,(BSTR)szNum,1,R8,1.50);
3195 skip("Skipping VarRound(BSTR) as decimal separator is '%s'\n", buff);
3198 VARROUND(R4,1.23456f,0,R4,1.0f);
3199 VARROUND(R4,1.23456f,1,R4,1.2f);
3200 VARROUND(R4,1.23456f,2,R4,1.23f);
3201 VARROUND(R4,1.23456f,3,R4,1.235f);
3202 VARROUND(R4,1.23456f,4,R4,1.2346f);
3203 VARROUND(R4,-1.23456f,0,R4,-1.0f);
3204 VARROUND(R4,-1.23456f,1,R4,-1.2f);
3205 VARROUND(R4,-1.23456f,2,R4,-1.23f);
3206 VARROUND(R4,-1.23456f,3,R4,-1.235f);
3207 VARROUND(R4,-1.23456f,4,R4,-1.2346f);
3209 VARROUND(R8,1.23456,0,R8,1.0);
3210 VARROUND(R8,1.23456,1,R8,1.2);
3211 VARROUND(R8,1.23456,2,R8,1.23);
3212 VARROUND(R8,1.23456,3,R8,1.235);
3213 VARROUND(R8,1.23456,4,R8,1.2346);
3214 VARROUND(R8,-1.23456,0,R8,-1.0);
3215 VARROUND(R8,-1.23456,1,R8,-1.2);
3216 VARROUND(R8,-1.23456,2,R8,-1.23);
3217 VARROUND(R8,-1.23456,3,R8,-1.235);
3218 VARROUND(R8,-1.23456,4,R8,-1.2346);
3220 V_VT(&v) = VT_EMPTY;
3221 hres = pVarRound(&v,0,&vDst);
3222 ok(hres == S_OK && V_VT(&vDst) == VT_I2 && V_I2(&vDst) == 0,
3223 "VarRound: expected 0x0,%d,0 got 0x%X,%d,%d\n", VT_EMPTY,
3224 hres, V_VT(&vDst), V_I2(&vDst));
3227 hres = pVarRound(&v,0,&vDst);
3228 ok(hres == S_OK && V_VT(&vDst) == VT_NULL,
3229 "VarRound: expected 0x0,%d got 0x%X,%d\n", VT_NULL, hres, V_VT(&vDst));
3231 /* not yet implemented so no use testing yet
3233 DECIMAL *pdec = &V_DECIMAL(&v);
3234 V_VT(&v) = VT_DECIMAL;
3235 S(U(*pdec)).sign = DECIMAL_NEG;
3236 S(U(*pdec)).scale = 0;
3238 S1(U1(*pdec)).Mid32 = 0;
3239 S1(U1(*pdec)).Lo32 = 1;
3240 hres = pVarRound(&v,0,&vDst);
3241 ok(hres == S_OK && V_VT(&vDst) == VT_DECIMAL &&
3242 S(U(V_DECIMAL(&vDst))).sign == 0,
3243 "VarRound: expected 0x0,%d,0x00, got 0x%X,%d,%02x\n", VT_DECIMAL,
3244 hres, V_VT(&vDst), S(U(V_DECIMAL(&vDst))).sign);
3246 S(U(*pdec)).sign = 0;
3247 hres = pVarRound(&v,0,&vDst);
3248 ok(hres == S_OK && V_VT(&vDst) == VT_DECIMAL &&
3249 S(U(V_DECIMAL(&vDst))).sign == DECIMAL_NEG,
3250 "VarRound: expected 0x0,%d,0x7f, got 0x%X,%d,%02x\n", VT_DECIMAL,
3251 hres, V_VT(&vDst), S(U(V_DECIMAL(&vDst))).sign);
3257 hres = pVarRound(&v,0,&vDst);
3258 ok(hres == S_OK && V_VT(&vDst) == VT_CY && V_CY(&vDst).int64 == 10000,
3259 "VarRound: VT_CY wrong, hres=0x%X\n", hres);
3263 static HRESULT (WINAPI *pVarXor)(LPVARIANT,LPVARIANT,LPVARIANT);
3265 #define VARXOR(vt1,val1,vt2,val2,rvt,rval) \
3266 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
3267 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
3268 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
3269 test_var_call2( __LINE__, pVarXor, &left, &right, &exp )
3271 #define VARXORCY(vt1,val1,val2,rvt,rval) \
3272 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
3273 V_VT(&right) = VT_CY; V_CY(&right).int64 = val2; \
3274 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
3275 test_var_call2( __LINE__, pVarXor, &left, &right, &exp )
3277 static void test_VarXor(void)
3279 static const WCHAR szFalse[] = { '#','F','A','L','S','E','#','\0' };
3280 static const WCHAR szTrue[] = { '#','T','R','U','E','#','\0' };
3281 VARIANT left, right, exp, result;
3288 /* Test all possible flag/vt combinations & the resulting vt type */
3289 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
3291 VARTYPE leftvt, rightvt, resvt;
3293 for (leftvt = 0; leftvt <= VT_BSTR_BLOB; leftvt++)
3298 for (rightvt = 0; rightvt <= VT_BSTR_BLOB; rightvt++)
3304 if (leftvt == VT_BSTR || rightvt == VT_BSTR ||
3305 leftvt == VT_DISPATCH || rightvt == VT_DISPATCH ||
3306 leftvt == VT_UNKNOWN || rightvt == VT_UNKNOWN)
3309 memset(&left, 0, sizeof(left));
3310 memset(&right, 0, sizeof(right));
3311 V_VT(&left) = leftvt | ExtraFlags[i];
3312 V_VT(&right) = rightvt | ExtraFlags[i];
3313 V_VT(&result) = VT_EMPTY;
3316 if (ExtraFlags[i] & VT_ARRAY || ExtraFlags[i] & VT_BYREF ||
3317 !IsValidVariantClearVT(leftvt, ExtraFlags[i]) ||
3318 !IsValidVariantClearVT(rightvt, ExtraFlags[i]) ||
3319 leftvt == VT_CLSID || rightvt == VT_CLSID ||
3320 leftvt == VT_RECORD || rightvt == VT_RECORD ||
3321 leftvt == VT_VARIANT || rightvt == VT_VARIANT ||
3322 leftvt == VT_ERROR || rightvt == VT_ERROR)
3326 if (leftvt == VT_EMPTY || rightvt == VT_EMPTY)
3328 if (leftvt == rightvt ||
3329 leftvt == VT_I2 || rightvt == VT_I2 ||
3330 leftvt == VT_UI1 || rightvt == VT_UI1 ||
3331 leftvt == VT_BOOL || rightvt == VT_BOOL)
3333 else if (leftvt == VT_NULL || rightvt == VT_NULL)
3335 else if (leftvt == VT_I8 || rightvt == VT_I8)
3338 else if (leftvt == VT_NULL || rightvt == VT_NULL)
3342 else if (leftvt == VT_UI1 || rightvt == VT_UI1)
3344 if (leftvt == rightvt)
3346 else if (leftvt == rightvt ||
3347 leftvt == VT_I2 || rightvt == VT_I2 ||
3348 leftvt == VT_BOOL || rightvt == VT_BOOL)
3352 else if (leftvt == VT_I8 || rightvt == VT_I8)
3355 else if (leftvt == VT_I2 || rightvt == VT_I2)
3357 if (leftvt == rightvt ||
3358 leftvt == VT_BOOL || rightvt == VT_BOOL)
3360 else if (leftvt == VT_I8 || rightvt == VT_I8)
3363 else if (leftvt == VT_BOOL && rightvt == VT_BOOL)
3367 else if (leftvt == VT_I8 || rightvt == VT_I8)
3369 if (leftvt == VT_INT || rightvt == VT_INT)
3374 hres = pVarXor(&left, &right, &result);
3376 ok(hres == DISP_E_TYPEMISMATCH || hres == DISP_E_BADVARTYPE,
3377 "VarXor: %d|0x%X, %d|0x%X: Expected failure, got 0x%X vt %d\n",
3378 leftvt, ExtraFlags[i], rightvt, ExtraFlags[i], hres,
3381 ok(hres == S_OK && V_VT(&result) == resvt,
3382 "VarXor: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%X vt %d\n",
3383 leftvt, ExtraFlags[i], rightvt, ExtraFlags[i], resvt, hres,
3389 /* Test returned values
3390 * FIXME: Test VT_DECIMAL/VT_DISPATCH
3392 VARXOR(EMPTY,0,EMPTY,0,I2,0);
3393 VARXOR(EMPTY,1,EMPTY,0,I2,0);
3394 VARXOR(EMPTY,0,NULL,0,NULL,0);
3395 VARXOR(EMPTY,0,I1,0,I4,0);
3396 VARXOR(EMPTY,0,I1,1,I4,1);
3397 VARXOR(EMPTY,0,UI1,0,I2,0);
3398 VARXOR(EMPTY,0,UI1,1,I2,1);
3399 VARXOR(EMPTY,0,I2,0,I2,0);
3400 VARXOR(EMPTY,0,I2,1,I2,1);
3401 VARXOR(EMPTY,0,UI2,0,I4,0);
3402 VARXOR(EMPTY,0,UI2,1,I4,1);
3403 VARXOR(EMPTY,0,I4,0,I4,0);
3404 VARXOR(EMPTY,0,I4,1,I4,1);
3405 VARXOR(EMPTY,0,UI4,0,I4,0);
3406 VARXOR(EMPTY,0,UI4,1,I4,1);
3407 if (HAVE_OLEAUT32_I8)
3409 VARXOR(EMPTY,0,I8,0,I8,0);
3410 VARXOR(EMPTY,0,I8,1,I8,1);
3411 VARXOR(EMPTY,0,UI8,0,I4,0);
3412 VARXOR(EMPTY,0,UI8,1,I4,1);
3414 VARXOR(EMPTY,0,INT,0,I4,0);
3415 VARXOR(EMPTY,0,INT,1,I4,1);
3416 VARXOR(EMPTY,0,UINT,0,I4,0);
3417 VARXOR(EMPTY,0,UINT,1,I4,1);
3418 VARXOR(EMPTY,0,BOOL,0,I2,0);
3419 VARXOR(EMPTY,0,BOOL,1,I2,1);
3420 VARXOR(EMPTY,0,R4,0,I4,0);
3421 VARXOR(EMPTY,0,R4,1,I4,1);
3422 VARXOR(EMPTY,0,R8,0,I4,0);
3423 VARXOR(EMPTY,0,R8,1,I4,1);
3424 rbstr = SysAllocString(szFalse);
3425 VARXOR(EMPTY,0,BSTR,rbstr,I2,0);
3426 SysFreeString(rbstr);
3427 rbstr = SysAllocString(szTrue);
3428 VARXOR(EMPTY,0,BSTR,rbstr,I2,-1);
3429 VARXORCY(EMPTY,0,10000,I4,1);
3430 SysFreeString(rbstr);
3432 /* NULL OR 0 = NULL. NULL OR n = n */
3433 VARXOR(NULL,0,NULL,0,NULL,0);
3434 VARXOR(NULL,1,NULL,0,NULL,0);
3435 VARXOR(NULL,0,I1,0,NULL,0);
3436 VARXOR(NULL,0,I1,1,NULL,0);
3437 VARXOR(NULL,0,UI1,0,NULL,0);
3438 VARXOR(NULL,0,UI1,1,NULL,0);
3439 VARXOR(NULL,0,I2,0,NULL,0);
3440 VARXOR(NULL,0,I2,1,NULL,0);
3441 VARXOR(NULL,0,UI2,0,NULL,0);
3442 VARXOR(NULL,0,UI2,1,NULL,0);
3443 VARXOR(NULL,0,I4,0,NULL,0);
3444 VARXOR(NULL,0,I4,1,NULL,0);
3445 VARXOR(NULL,0,UI4,0,NULL,0);
3446 VARXOR(NULL,0,UI4,1,NULL,0);
3447 if (HAVE_OLEAUT32_I8)
3449 VARXOR(NULL,0,I8,0,NULL,0);
3450 VARXOR(NULL,0,I8,1,NULL,0);
3451 VARXOR(NULL,0,UI8,0,NULL,0);
3452 VARXOR(NULL,0,UI8,1,NULL,0);
3454 VARXOR(NULL,0,INT,0,NULL,0);
3455 VARXOR(NULL,0,INT,1,NULL,0);
3456 VARXOR(NULL,0,UINT,0,NULL,0);
3457 VARXOR(NULL,0,UINT,1,NULL,0);
3458 VARXOR(NULL,0,BOOL,0,NULL,0);
3459 VARXOR(NULL,0,BOOL,1,NULL,0);
3460 VARXOR(NULL,0,R4,0,NULL,0);
3461 VARXOR(NULL,0,R4,1,NULL,0);
3462 VARXOR(NULL,0,R8,0,NULL,0);
3463 VARXOR(NULL,0,R8,1,NULL,0);
3464 rbstr = SysAllocString(szFalse);
3465 VARXOR(NULL,0,BSTR,rbstr,NULL,0);
3466 SysFreeString(rbstr);
3467 rbstr = SysAllocString(szTrue);
3468 VARXOR(NULL,0,BSTR,rbstr,NULL,0);
3469 SysFreeString(rbstr);
3470 VARXORCY(NULL,0,10000,NULL,0);
3471 VARXORCY(NULL,0,0,NULL,0);
3473 VARXOR(BOOL,VARIANT_TRUE,BOOL,VARIANT_TRUE,BOOL,VARIANT_FALSE);
3474 VARXOR(BOOL,VARIANT_TRUE,BOOL,VARIANT_FALSE,BOOL,VARIANT_TRUE);
3475 VARXOR(BOOL,VARIANT_FALSE,BOOL,VARIANT_TRUE,BOOL,VARIANT_TRUE);
3476 VARXOR(BOOL,VARIANT_FALSE,BOOL,VARIANT_FALSE,BOOL,VARIANT_FALSE);
3477 /* Assume x,y & y,x are the same from now on to reduce the number of tests */
3478 VARXOR(BOOL,VARIANT_TRUE,I1,-1,I4,0);
3479 VARXOR(BOOL,VARIANT_TRUE,I1,0,I4,-1);
3480 VARXOR(BOOL,VARIANT_FALSE,I1,0,I4,0);
3481 VARXOR(BOOL,VARIANT_TRUE,UI1,255,I2,-256);
3482 VARXOR(BOOL,VARIANT_TRUE,UI1,0,I2,-1);
3483 VARXOR(BOOL,VARIANT_FALSE,UI1,0,I2,0);
3484 VARXOR(BOOL,VARIANT_TRUE,I2,-1,I2,0);
3485 VARXOR(BOOL,VARIANT_TRUE,I2,0,I2,-1);
3486 VARXOR(BOOL,VARIANT_FALSE,I2,0,I2,0);
3487 VARXOR(BOOL,VARIANT_TRUE,UI2,65535,I4,-65536);
3488 VARXOR(BOOL,VARIANT_TRUE,UI2,0,I4,-1);
3489 VARXOR(BOOL,VARIANT_FALSE,UI2,0,I4,0);
3490 VARXOR(BOOL,VARIANT_TRUE,I4,-1,I4,0);
3491 VARXOR(BOOL,VARIANT_TRUE,I4,0,I4,-1);
3492 VARXOR(BOOL,VARIANT_FALSE,I4,0,I4,0);
3493 VARXOR(BOOL,VARIANT_TRUE,UI4,0xffffffff,I4,0);
3494 VARXOR(BOOL,VARIANT_TRUE,UI4,0,I4,-1);
3495 VARXOR(BOOL,VARIANT_FALSE,UI4,0,I4,0);
3496 VARXOR(BOOL,VARIANT_TRUE,R4,-1,I4,0);
3497 VARXOR(BOOL,VARIANT_TRUE,R4,0,I4,-1);
3498 VARXOR(BOOL,VARIANT_FALSE,R4,0,I4,0);
3499 VARXOR(BOOL,VARIANT_TRUE,R8,-1,I4,0);
3500 VARXOR(BOOL,VARIANT_TRUE,R8,0,I4,-1);
3501 VARXOR(BOOL,VARIANT_FALSE,R8,0,I4,0);
3502 VARXOR(BOOL,VARIANT_TRUE,DATE,-1,I4,0);
3503 VARXOR(BOOL,VARIANT_TRUE,DATE,0,I4,-1);
3504 VARXOR(BOOL,VARIANT_FALSE,DATE,0,I4,0);
3505 if (HAVE_OLEAUT32_I8)
3507 VARXOR(BOOL,VARIANT_TRUE,I8,-1,I8,0);
3508 VARXOR(BOOL,VARIANT_TRUE,I8,0,I8,-1);
3509 VARXOR(BOOL,VARIANT_FALSE,I8,0,I8,0);
3510 /* This returns DISP_E_OVERFLOW which indicates that a conversion
3511 * to I4 is performed.
3513 /* VARXOR(BOOL,VARIANT_TRUE,UI8,-1,I4,-1); */
3514 VARXOR(BOOL,VARIANT_TRUE,UI8,0,I4,-1);
3515 VARXOR(BOOL,VARIANT_FALSE,UI8,0,I4,0);
3517 VARXOR(BOOL,VARIANT_TRUE,INT,-1,I4,0);
3518 VARXOR(BOOL,VARIANT_TRUE,INT,0,I4,-1);
3519 VARXOR(BOOL,VARIANT_FALSE,INT,0,I4,0);
3520 VARXOR(BOOL,VARIANT_TRUE,UINT,0xffffffff,I4,0);
3521 VARXOR(BOOL,VARIANT_TRUE,UINT,0,I4,-1);
3522 VARXOR(BOOL,VARIANT_FALSE,UINT,0,I4,0);
3523 rbstr = SysAllocString(szFalse);
3524 VARXOR(BOOL,VARIANT_FALSE,BSTR,rbstr,BOOL,VARIANT_FALSE);
3525 VARXOR(BOOL,VARIANT_TRUE,BSTR,rbstr,BOOL,VARIANT_TRUE);
3526 SysFreeString(rbstr);
3527 rbstr = SysAllocString(szTrue);
3528 VARXOR(BOOL,VARIANT_FALSE,BSTR,rbstr,BOOL,VARIANT_TRUE);
3529 VARXOR(BOOL,VARIANT_TRUE,BSTR,rbstr,BOOL,VARIANT_FALSE);
3530 SysFreeString(rbstr);
3531 VARXORCY(BOOL,VARIANT_TRUE,10000,I4,-2);
3532 VARXORCY(BOOL,VARIANT_TRUE,0,I4,-1);
3533 VARXORCY(BOOL,VARIANT_FALSE,0,I4,0);
3535 VARXOR(I1,-1,I1,-1,I4,0);
3536 VARXOR(I1,-1,I1,0,I4,-1);
3537 VARXOR(I1,0,I1,0,I4,0);
3538 VARXOR(I1,-1,UI1,255,I4,-256);
3539 VARXOR(I1,-1,UI1,0,I4,-1);
3540 VARXOR(I1,0,UI1,0,I4,0);
3541 VARXOR(I1,-1,I2,-1,I4,0);
3542 VARXOR(I1,-1,I2,0,I4,-1);
3543 VARXOR(I1,0,I2,0,I4,0);
3544 VARXOR(I1,-1,UI2,65535,I4,-65536);
3545 VARXOR(I1,-1,UI2,0,I4,-1);
3546 VARXOR(I1,0,UI2,0,I4,0);
3547 VARXOR(I1,-1,I4,-1,I4,0);
3548 VARXOR(I1,-1,I4,0,I4,-1);
3549 VARXOR(I1,0,I4,0,I4,0);
3550 VARXOR(I1,-1,UI4,0xffffffff,I4,0);
3551 VARXOR(I1,-1,UI4,0,I4,-1);
3552 VARXOR(I1,0,UI4,0,I4,0);
3553 VARXOR(I1,-1,R4,-1,I4,0);
3554 VARXOR(I1,-1,R4,0,I4,-1);
3555 VARXOR(I1,0,R4,0,I4,0);
3556 VARXOR(I1,-1,R8,-1,I4,0);
3557 VARXOR(I1,-1,R8,0,I4,-1);
3558 VARXOR(I1,0,R8,0,I4,0);
3559 VARXOR(I1,-1,DATE,-1,I4,0);
3560 VARXOR(I1,-1,DATE,0,I4,-1);
3561 VARXOR(I1,0,DATE,0,I4,0);
3562 if (HAVE_OLEAUT32_I8)
3564 VARXOR(I1,-1,I8,-1,I8,0);
3565 VARXOR(I1,-1,I8,0,I8,-1);
3566 VARXOR(I1,0,I8,0,I8,0);
3567 VARXOR(I1,-1,UI8,0,I4,-1);
3568 VARXOR(I1,0,UI8,0,I4,0);
3570 VARXOR(I1,-1,INT,-1,I4,0);
3571 VARXOR(I1,-1,INT,0,I4,-1);
3572 VARXOR(I1,0,INT,0,I4,0);
3573 VARXOR(I1,-1,UINT,0xffffffff,I4,0);
3574 VARXOR(I1,-1,UINT,0,I4,-1);
3575 VARXOR(I1,0,UINT,0,I4,0);
3576 rbstr = SysAllocString(szFalse);
3577 VARXOR(I1,0,BSTR,rbstr,I4,0);
3578 VARXOR(I1,-1,BSTR,rbstr,I4,-1);
3579 SysFreeString(rbstr);
3580 rbstr = SysAllocString(szTrue);
3581 VARXOR(I1,0,BSTR,rbstr,I4,-1);
3582 VARXOR(I1,-1,BSTR,rbstr,I4,0);
3583 SysFreeString(rbstr);
3584 VARXORCY(I1,-1,10000,I4,-2);
3585 VARXORCY(I1,-1,0,I4,-1);
3586 VARXORCY(I1,0,0,I4,0);
3588 VARXOR(UI1,255,UI1,255,UI1,0);
3589 VARXOR(UI1,255,UI1,0,UI1,255);
3590 VARXOR(UI1,0,UI1,0,UI1,0);
3591 VARXOR(UI1,255,I2,-1,I2,-256);
3592 VARXOR(UI1,255,I2,0,I2,255);
3593 VARXOR(UI1,0,I2,0,I2,0);
3594 VARXOR(UI1,255,UI2,65535,I4,65280);
3595 VARXOR(UI1,255,UI2,0,I4,255);
3596 VARXOR(UI1,0,UI2,0,I4,0);
3597 VARXOR(UI1,255,I4,-1,I4,-256);
3598 VARXOR(UI1,255,I4,0,I4,255);
3599 VARXOR(UI1,0,I4,0,I4,0);
3600 VARXOR(UI1,255,UI4,0xffffffff,I4,-256);
3601 VARXOR(UI1,255,UI4,0,I4,255);
3602 VARXOR(UI1,0,UI4,0,I4,0);
3603 VARXOR(UI1,255,R4,-1,I4,-256);
3604 VARXOR(UI1,255,R4,0,I4,255);
3605 VARXOR(UI1,0,R4,0,I4,0);
3606 VARXOR(UI1,255,R8,-1,I4,-256);
3607 VARXOR(UI1,255,R8,0,I4,255);
3608 VARXOR(UI1,0,R8,0,I4,0);
3609 VARXOR(UI1,255,DATE,-1,I4,-256);
3610 VARXOR(UI1,255,DATE,0,I4,255);
3611 VARXOR(UI1,0,DATE,0,I4,0);
3612 if (HAVE_OLEAUT32_I8)
3614 VARXOR(UI1,255,I8,-1,I8,-256);
3615 VARXOR(UI1,255,I8,0,I8,255);
3616 VARXOR(UI1,0,I8,0,I8,0);
3617 VARXOR(UI1,255,UI8,0,I4,255);
3618 VARXOR(UI1,0,UI8,0,I4,0);
3620 VARXOR(UI1,255,INT,-1,I4,-256);
3621 VARXOR(UI1,255,INT,0,I4,255);
3622 VARXOR(UI1,0,INT,0,I4,0);
3623 VARXOR(UI1,255,UINT,0xffffffff,I4,-256);
3624 VARXOR(UI1,255,UINT,0,I4,255);
3625 VARXOR(UI1,0,UINT,0,I4,0);
3626 rbstr = SysAllocString(szFalse);
3627 VARXOR(UI1,0,BSTR,rbstr,I2,0);
3628 VARXOR(UI1,255,BSTR,rbstr,I2,255);
3629 SysFreeString(rbstr);
3630 rbstr = SysAllocString(szTrue);
3631 VARXOR(UI1,0,BSTR,rbstr,I2,-1);
3632 VARXOR(UI1,255,BSTR,rbstr,I2,-256);
3633 SysFreeString(rbstr);
3634 VARXORCY(UI1,255,10000,I4,254);
3635 VARXORCY(UI1,255,0,I4,255);
3636 VARXORCY(UI1,0,0,I4,0);
3638 VARXOR(I2,-1,I2,-1,I2,0);
3639 VARXOR(I2,-1,I2,0,I2,-1);
3640 VARXOR(I2,0,I2,0,I2,0);
3641 VARXOR(I2,-1,UI2,65535,I4,-65536);
3642 VARXOR(I2,-1,UI2,0,I4,-1);
3643 VARXOR(I2,0,UI2,0,I4,0);
3644 VARXOR(I2,-1,I4,-1,I4,0);
3645 VARXOR(I2,-1,I4,0,I4,-1);
3646 VARXOR(I2,0,I4,0,I4,0);
3647 VARXOR(I2,-1,UI4,0xffffffff,I4,0);
3648 VARXOR(I2,-1,UI4,0,I4,-1);
3649 VARXOR(I2,0,UI4,0,I4,0);
3650 VARXOR(I2,-1,R4,-1,I4,0);
3651 VARXOR(I2,-1,R4,0,I4,-1);
3652 VARXOR(I2,0,R4,0,I4,0);
3653 VARXOR(I2,-1,R8,-1,I4,0);
3654 VARXOR(I2,-1,R8,0,I4,-1);
3655 VARXOR(I2,0,R8,0,I4,0);
3656 VARXOR(I2,-1,DATE,-1,I4,0);
3657 VARXOR(I2,-1,DATE,0,I4,-1);
3658 VARXOR(I2,0,DATE,0,I4,0);
3659 if (HAVE_OLEAUT32_I8)
3661 VARXOR(I2,-1,I8,-1,I8,0);
3662 VARXOR(I2,-1,I8,0,I8,-1);
3663 VARXOR(I2,0,I8,0,I8,0);
3664 VARXOR(I2,-1,UI8,0,I4,-1);
3665 VARXOR(I2,0,UI8,0,I4,0);
3667 VARXOR(I2,-1,INT,-1,I4,0);
3668 VARXOR(I2,-1,INT,0,I4,-1);
3669 VARXOR(I2,0,INT,0,I4,0);
3670 VARXOR(I2,-1,UINT,0xffffffff,I4,0);
3671 VARXOR(I2,-1,UINT,0,I4,-1);
3672 VARXOR(I2,0,UINT,0,I4,0);
3673 rbstr = SysAllocString(szFalse);
3674 VARXOR(I2,0,BSTR,rbstr,I2,0);
3675 VARXOR(I2,-1,BSTR,rbstr,I2,-1);
3676 SysFreeString(rbstr);
3677 rbstr = SysAllocString(szTrue);
3678 VARXOR(I2,0,BSTR,rbstr,I2,-1);
3679 VARXOR(I2,-1,BSTR,rbstr,I2,0);
3680 SysFreeString(rbstr);
3681 VARXORCY(I2,-1,10000,I4,-2);
3682 VARXORCY(I2,-1,0,I4,-1);
3683 VARXORCY(I2,0,0,I4,0);
3685 VARXOR(UI2,65535,UI2,65535,I4,0);
3686 VARXOR(UI2,65535,UI2,0,I4,65535);
3687 VARXOR(UI2,0,UI2,0,I4,0);
3688 VARXOR(UI2,65535,I4,-1,I4,-65536);
3689 VARXOR(UI2,65535,I4,0,I4,65535);
3690 VARXOR(UI2,0,I4,0,I4,0);
3691 VARXOR(UI2,65535,UI4,0xffffffff,I4,-65536);
3692 VARXOR(UI2,65535,UI4,0,I4,65535);
3693 VARXOR(UI2,0,UI4,0,I4,0);
3694 VARXOR(UI2,65535,R4,-1,I4,-65536);
3695 VARXOR(UI2,65535,R4,0,I4,65535);
3696 VARXOR(UI2,0,R4,0,I4,0);
3697 VARXOR(UI2,65535,R8,-1,I4,-65536);
3698 VARXOR(UI2,65535,R8,0,I4,65535);
3699 VARXOR(UI2,0,R8,0,I4,0);
3700 VARXOR(UI2,65535,DATE,-1,I4,-65536);
3701 VARXOR(UI2,65535,DATE,0,I4,65535);
3702 VARXOR(UI2,0,DATE,0,I4,0);
3703 if (HAVE_OLEAUT32_I8)
3705 VARXOR(UI2,65535,I8,-1,I8,-65536);
3706 VARXOR(UI2,65535,I8,0,I8,65535);
3707 VARXOR(UI2,0,I8,0,I8,0);
3708 VARXOR(UI2,65535,UI8,0,I4,65535);
3709 VARXOR(UI2,0,UI8,0,I4,0);
3711 VARXOR(UI2,65535,INT,-1,I4,-65536);
3712 VARXOR(UI2,65535,INT,0,I4,65535);
3713 VARXOR(UI2,0,INT,0,I4,0);
3714 VARXOR(UI2,65535,UINT,0xffffffff,I4,-65536);
3715 VARXOR(UI2,65535,UINT,0,I4,65535);
3716 VARXOR(UI2,0,UINT,0,I4,0);
3717 rbstr = SysAllocString(szFalse);
3718 VARXOR(UI2,0,BSTR,rbstr,I4,0);
3719 VARXOR(UI2,65535,BSTR,rbstr,I4,65535);
3720 SysFreeString(rbstr);
3721 rbstr = SysAllocString(szTrue);
3722 VARXOR(UI2,0,BSTR,rbstr,I4,-1);
3723 VARXOR(UI2,65535,BSTR,rbstr,I4,-65536);
3724 SysFreeString(rbstr);
3725 VARXORCY(UI2,65535,10000,I4,65534);
3726 VARXORCY(UI2,65535,0,I4,65535);
3727 VARXORCY(UI2,0,0,I4,0);
3729 VARXOR(I4,-1,I4,-1,I4,0);
3730 VARXOR(I4,-1,I4,0,I4,-1);
3731 VARXOR(I4,0,I4,0,I4,0);
3732 VARXOR(I4,-1,UI4,0xffffffff,I4,0);
3733 VARXOR(I4,-1,UI4,0,I4,-1);
3734 VARXOR(I4,0,UI4,0,I4,0);
3735 VARXOR(I4,-1,R4,-1,I4,0);
3736 VARXOR(I4,-1,R4,0,I4,-1);
3737 VARXOR(I4,0,R4,0,I4,0);
3738 VARXOR(I4,-1,R8,-1,I4,0);
3739 VARXOR(I4,-1,R8,0,I4,-1);
3740 VARXOR(I4,0,R8,0,I4,0);
3741 VARXOR(I4,-1,DATE,-1,I4,0);
3742 VARXOR(I4,-1,DATE,0,I4,-1);
3743 VARXOR(I4,0,DATE,0,I4,0);
3744 if (HAVE_OLEAUT32_I8)
3746 VARXOR(I4,-1,I8,-1,I8,0);
3747 VARXOR(I4,-1,I8,0,I8,-1);
3748 VARXOR(I4,0,I8,0,I8,0);
3749 VARXOR(I4,-1,UI8,0,I4,-1);
3750 VARXOR(I4,0,UI8,0,I4,0);
3752 VARXOR(I4,-1,INT,-1,I4,0);
3753 VARXOR(I4,-1,INT,0,I4,-1);
3754 VARXOR(I4,0,INT,0,I4,0);
3755 VARXOR(I4,-1,UINT,0xffffffff,I4,0);
3756 VARXOR(I4,-1,UINT,0,I4,-1);
3757 VARXOR(I4,0,UINT,0,I4,0);
3758 rbstr = SysAllocString(szFalse);
3759 VARXOR(I4,0,BSTR,rbstr,I4,0);
3760 VARXOR(I4,-1,BSTR,rbstr,I4,-1);
3761 SysFreeString(rbstr);
3762 rbstr = SysAllocString(szTrue);
3763 VARXOR(I4,0,BSTR,rbstr,I4,-1);
3764 VARXOR(I4,-1,BSTR,rbstr,I4,0);
3765 SysFreeString(rbstr);
3766 VARXORCY(I4,-1,10000,I4,-2);
3767 VARXORCY(I4,-1,0,I4,-1);
3768 VARXORCY(I4,0,0,I4,0);
3770 VARXOR(UI4,0xffffffff,UI4,0xffffffff,I4,0);
3771 VARXOR(UI4,0xffffffff,UI4,0,I4,-1);
3772 VARXOR(UI4,0,UI4,0,I4,0);
3773 VARXOR(UI4,0xffffffff,R4,-1,I4,0);
3774 VARXOR(UI4,0xffffffff,R4,0,I4,-1);
3775 VARXOR(UI4,0,R4,0,I4,0);
3776 VARXOR(UI4,0xffffffff,R8,-1,I4,0);
3777 VARXOR(UI4,0xffffffff,R8,0,I4,-1);
3778 VARXOR(UI4,0,R8,0,I4,0);
3779 VARXOR(UI4,0xffffffff,DATE,-1,I4,0);
3780 VARXOR(UI4,0xffffffff,DATE,0,I4,-1);
3781 VARXOR(UI4,0,DATE,0,I4,0);
3782 if (HAVE_OLEAUT32_I8)
3784 VARXOR(UI4,0xffffffff,I8,0,I8,0xffffffff);
3785 VARXOR(UI4,VARIANT_FALSE,I8,VARIANT_FALSE,I8,0);
3786 VARXOR(UI4,0,I8,0,I8,0);
3787 VARXOR(UI4,0xffffffff,UI8,0,I4,-1);
3788 VARXOR(UI4,0,UI8,0,I4,0);
3790 VARXOR(UI4,0xffffffff,INT,-1,I4,0);
3791 VARXOR(UI4,0xffffffff,INT,0,I4,-1);
3792 VARXOR(UI4,0,INT,0,I4,0);
3793 VARXOR(UI4,0xffffffff,UINT,0xffffffff,I4,0);
3794 VARXOR(UI4,0xffffffff,UINT,0,I4,-1);
3795 VARXOR(UI4,0,UINT,0,I4,0);
3796 rbstr = SysAllocString(szFalse);
3797 VARXOR(UI4,0,BSTR,rbstr,I4,0);
3798 VARXOR(UI4,0xffffffff,BSTR,rbstr,I4,-1);
3799 SysFreeString(rbstr);
3800 rbstr = SysAllocString(szTrue);
3801 VARXOR(UI4,0,BSTR,rbstr,I4,-1);
3802 VARXOR(UI4,0xffffffff,BSTR,rbstr,I4,0);
3803 SysFreeString(rbstr);
3804 VARXORCY(UI4,0xffffffff,10000,I4,-2);
3805 VARXORCY(UI4,0xffffffff,0,I4,-1);
3806 VARXORCY(UI4,0,0,I4,0);
3808 VARXOR(R4,-1,R4,-1,I4,0);
3809 VARXOR(R4,-1,R4,0,I4,-1);
3810 VARXOR(R4,0,R4,0,I4,0);
3811 VARXOR(R4,-1,R8,-1,I4,0);
3812 VARXOR(R4,-1,R8,0,I4,-1);
3813 VARXOR(R4,0,R8,0,I4,0);
3814 VARXOR(R4,-1,DATE,-1,I4,0);
3815 VARXOR(R4,-1,DATE,0,I4,-1);
3816 VARXOR(R4,0,DATE,0,I4,0);
3817 if (HAVE_OLEAUT32_I8)
3819 VARXOR(R4,-1,I8,-1,I8,0);
3820 VARXOR(R4,-1,I8,0,I8,-1);
3821 VARXOR(R4,0,I8,0,I8,0);
3822 VARXOR(R4,-1,UI8,0,I4,-1);
3823 VARXOR(R4,0,UI8,0,I4,0);
3825 VARXOR(R4,-1,INT,-1,I4,0);
3826 VARXOR(R4,-1,INT,0,I4,-1);
3827 VARXOR(R4,0,INT,0,I4,0);
3828 VARXOR(R4,-1,UINT,0xffffffff,I4,0);
3829 VARXOR(R4,-1,UINT,0,I4,-1);
3830 VARXOR(R4,0,UINT,0,I4,0);
3831 rbstr = SysAllocString(szFalse);
3832 VARXOR(R4,0,BSTR,rbstr,I4,0);
3833 VARXOR(R4,-1,BSTR,rbstr,I4,-1);
3834 SysFreeString(rbstr);
3835 rbstr = SysAllocString(szTrue);
3836 VARXOR(R4,0,BSTR,rbstr,I4,-1);
3837 VARXOR(R4,-1,BSTR,rbstr,I4,0);
3838 SysFreeString(rbstr);
3839 VARXORCY(R4,-1,10000,I4,-2);
3840 VARXORCY(R4,-1,0,I4,-1);
3841 VARXORCY(R4,0,0,I4,0);
3843 VARXOR(R8,-1,R8,-1,I4,0);
3844 VARXOR(R8,-1,R8,0,I4,-1);
3845 VARXOR(R8,0,R8,0,I4,0);
3846 VARXOR(R8,-1,DATE,-1,I4,0);
3847 VARXOR(R8,-1,DATE,0,I4,-1);
3848 VARXOR(R8,0,DATE,0,I4,0);
3849 if (HAVE_OLEAUT32_I8)
3851 VARXOR(R8,-1,I8,-1,I8,0);
3852 VARXOR(R8,-1,I8,0,I8,-1);
3853 VARXOR(R8,0,I8,0,I8,0);
3854 VARXOR(R8,-1,UI8,0,I4,-1);
3855 VARXOR(R8,0,UI8,0,I4,0);
3857 VARXOR(R8,-1,INT,-1,I4,0);
3858 VARXOR(R8,-1,INT,0,I4,-1);
3859 VARXOR(R8,0,INT,0,I4,0);
3860 VARXOR(R8,-1,UINT,0xffffffff,I4,0);
3861 VARXOR(R8,-1,UINT,0,I4,-1);
3862 VARXOR(R8,0,UINT,0,I4,0);
3863 rbstr = SysAllocString(szFalse);
3864 VARXOR(R8,0,BSTR,rbstr,I4,0);
3865 VARXOR(R8,-1,BSTR,rbstr,I4,-1);
3866 SysFreeString(rbstr);
3867 rbstr = SysAllocString(szTrue);
3868 VARXOR(R8,0,BSTR,rbstr,I4,-1);
3869 VARXOR(R8,-1,BSTR,rbstr,I4,0);
3870 SysFreeString(rbstr);
3871 VARXORCY(R8,-1,10000,I4,-2);
3872 VARXORCY(R8,-1,0,I4,-1);
3873 VARXORCY(R8,0,0,I4,0);
3875 VARXOR(DATE,-1,DATE,-1,I4,0);
3876 VARXOR(DATE,-1,DATE,0,I4,-1);
3877 VARXOR(DATE,0,DATE,0,I4,0);
3878 if (HAVE_OLEAUT32_I8)
3880 VARXOR(DATE,-1,I8,-1,I8,0);
3881 VARXOR(DATE,-1,I8,0,I8,-1);
3882 VARXOR(DATE,0,I8,0,I8,0);
3883 VARXOR(DATE,-1,UI8,0,I4,-1);
3884 VARXOR(DATE,0,UI8,0,I4,0);
3886 VARXOR(DATE,-1,INT,-1,I4,0);
3887 VARXOR(DATE,-1,INT,0,I4,-1);
3888 VARXOR(DATE,0,INT,0,I4,0);
3889 VARXOR(DATE,-1,UINT,0xffffffff,I4,0);
3890 VARXOR(DATE,-1,UINT,0,I4,-1);
3891 VARXOR(DATE,0,UINT,0,I4,0);
3892 rbstr = SysAllocString(szFalse);
3893 VARXOR(DATE,0,BSTR,rbstr,I4,0);
3894 VARXOR(DATE,-1,BSTR,rbstr,I4,-1);
3895 SysFreeString(rbstr);
3896 rbstr = SysAllocString(szTrue);
3897 VARXOR(DATE,0,BSTR,rbstr,I4,-1);
3898 VARXOR(DATE,-1,BSTR,rbstr,I4,0);
3899 SysFreeString(rbstr);
3900 VARXORCY(DATE,-1,10000,I4,-2);
3901 VARXORCY(DATE,-1,0,I4,-1);
3902 VARXORCY(DATE,0,0,I4,0);
3904 if (HAVE_OLEAUT32_I8)
3906 VARXOR(I8,-1,I8,-1,I8,0);
3907 VARXOR(I8,-1,I8,0,I8,-1);
3908 VARXOR(I8,0,I8,0,I8,0);
3909 VARXOR(I8,-1,UI8,0,I8,-1);
3910 VARXOR(I8,0,UI8,0,I8,0);
3911 VARXOR(I8,-1,UINT,0,I8,-1);
3912 VARXOR(I8,0,UINT,0,I8,0);
3913 rbstr = SysAllocString(szFalse);
3914 VARXOR(I8,0,BSTR,rbstr,I8,0);
3915 VARXOR(I8,-1,BSTR,rbstr,I8,-1);
3916 SysFreeString(rbstr);
3917 rbstr = SysAllocString(szTrue);
3918 VARXOR(I8,0,BSTR,rbstr,I8,-1);
3919 VARXOR(I8,-1,BSTR,rbstr,I8,0);
3920 SysFreeString(rbstr);
3921 VARXORCY(I8,-1,10000,I8,-2);
3922 VARXORCY(I8,-1,0,I8,-1);
3923 VARXORCY(I8,0,0,I8,0);
3925 VARXOR(UI8,0xffff,UI8,0xffff,I4,0);
3926 VARXOR(UI8,0xffff,UI8,0,I4,0xffff);
3927 VARXOR(UI8,0,UI8,0,I4,0);
3928 VARXOR(UI8,0xffff,INT,-1,I4,-65536);
3929 VARXOR(UI8,0xffff,INT,0,I4,0xffff);
3930 VARXOR(UI8,0,INT,0,I4,0);
3931 VARXOR(UI8,0xffff,UINT,0xffff,I4,0);
3932 VARXOR(UI8,0xffff,UINT,0,I4,0xffff);
3933 VARXOR(UI8,0,UINT,0,I4,0);
3934 rbstr = SysAllocString(szFalse);
3935 VARXOR(UI8,0,BSTR,rbstr,I4,0);
3936 VARXOR(UI8,0xffff,BSTR,rbstr,I4,0xffff);
3937 SysFreeString(rbstr);
3938 rbstr = SysAllocString(szTrue);
3939 VARXOR(UI8,0,BSTR,rbstr,I4,-1);
3940 VARXOR(UI8,0xffff,BSTR,rbstr,I4,-65536);
3941 SysFreeString(rbstr);
3942 VARXORCY(UI8,0xffff,10000,I4,65534);
3943 VARXORCY(UI8,0xffff,0,I4,0xffff);
3944 VARXORCY(UI8,0,0,I4,0);
3947 VARXOR(INT,-1,INT,-1,I4,0);
3948 VARXOR(INT,-1,INT,0,I4,-1);
3949 VARXOR(INT,0,INT,0,I4,0);
3950 VARXOR(INT,-1,UINT,0xffff,I4,-65536);
3951 VARXOR(INT,-1,UINT,0,I4,-1);
3952 VARXOR(INT,0,UINT,0,I4,0);
3953 rbstr = SysAllocString(szFalse);
3954 VARXOR(INT,0,BSTR,rbstr,I4,0);
3955 VARXOR(INT,-1,BSTR,rbstr,I4,-1);
3956 SysFreeString(rbstr);
3957 rbstr = SysAllocString(szTrue);
3958 VARXOR(INT,0,BSTR,rbstr,I4,-1);
3959 VARXOR(INT,-1,BSTR,rbstr,I4,0);
3960 SysFreeString(rbstr);
3961 VARXORCY(INT,-1,10000,I4,-2);
3962 VARXORCY(INT,-1,0,I4,-1);
3963 VARXORCY(INT,0,0,I4,0);
3965 VARXOR(UINT,0xffff,UINT,0xffff,I4,0);
3966 VARXOR(UINT,0xffff,UINT,0,I4,0xffff);
3967 VARXOR(UINT,0,UINT,0,I4,0);
3968 rbstr = SysAllocString(szFalse);
3969 VARXOR(UINT,0,BSTR,rbstr,I4,0);
3970 VARXOR(UINT,0xffff,BSTR,rbstr,I4,0xffff);
3971 SysFreeString(rbstr);
3972 rbstr = SysAllocString(szTrue);
3973 VARXOR(UINT,0,BSTR,rbstr,I4,-1);
3974 VARXOR(UINT,0xffff,BSTR,rbstr,I4,-65536);
3975 SysFreeString(rbstr);
3976 VARXORCY(UINT,0xffff,10000,I4,65534);
3977 VARXORCY(UINT,0xffff,0,I4,0xffff);
3978 VARXORCY(UINT,0,0,I4,0);
3980 lbstr = SysAllocString(szFalse);
3981 rbstr = SysAllocString(szFalse);
3982 VARXOR(BSTR,lbstr,BSTR,rbstr,BOOL,0);
3983 SysFreeString(rbstr);
3984 rbstr = SysAllocString(szTrue);
3985 VARXOR(BSTR,lbstr,BSTR,rbstr,BOOL,VARIANT_TRUE);
3986 SysFreeString(lbstr);
3987 lbstr = SysAllocString(szTrue);
3988 VARXOR(BSTR,lbstr,BSTR,rbstr,BOOL,VARIANT_FALSE);
3989 VARXORCY(BSTR,lbstr,10000,I4,-2);
3990 SysFreeString(lbstr);
3991 lbstr = SysAllocString(szFalse);
3992 VARXORCY(BSTR,lbstr,10000,I4,1);
3993 SysFreeString(lbstr);
3994 SysFreeString(rbstr);
3997 static HRESULT (WINAPI *pVarOr)(LPVARIANT,LPVARIANT,LPVARIANT);
3999 #define VAROR(vt1,val1,vt2,val2,rvt,rval) \
4000 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
4001 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
4002 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
4003 test_var_call2( __LINE__, pVarOr, &left, &right, &exp )
4005 #define VARORCY(vt1,val1,val2,rvt,rval) \
4006 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
4007 V_VT(&right) = VT_CY; V_CY(&right).int64 = val2; \
4008 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
4009 test_var_call2( __LINE__, pVarOr, &left, &right, &exp )
4011 static void test_VarOr(void)
4013 static const WCHAR szFalse[] = { '#','F','A','L','S','E','#','\0' };
4014 static const WCHAR szTrue[] = { '#','T','R','U','E','#','\0' };
4015 VARIANT left, right, exp, result;
4022 /* Test all possible flag/vt combinations & the resulting vt type */
4023 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
4025 VARTYPE leftvt, rightvt, resvt;
4027 for (leftvt = 0; leftvt <= VT_BSTR_BLOB; leftvt++)
4032 for (rightvt = 0; rightvt <= VT_BSTR_BLOB; rightvt++)
4038 if (leftvt == VT_BSTR || rightvt == VT_BSTR ||
4039 leftvt == VT_DISPATCH || rightvt == VT_DISPATCH ||
4040 leftvt == VT_UNKNOWN || rightvt == VT_UNKNOWN)
4043 memset(&left, 0, sizeof(left));
4044 memset(&right, 0, sizeof(right));
4045 V_VT(&left) = leftvt | ExtraFlags[i];
4046 V_VT(&right) = rightvt | ExtraFlags[i];
4047 V_VT(&result) = VT_EMPTY;
4050 if (ExtraFlags[i] & VT_ARRAY || ExtraFlags[i] & VT_BYREF ||
4051 !IsValidVariantClearVT(leftvt, ExtraFlags[i]) ||
4052 !IsValidVariantClearVT(rightvt, ExtraFlags[i]) ||
4053 leftvt == VT_CLSID || rightvt == VT_CLSID ||
4054 leftvt == VT_RECORD || rightvt == VT_RECORD ||
4055 leftvt == VT_VARIANT || rightvt == VT_VARIANT ||
4056 leftvt == VT_ERROR || rightvt == VT_ERROR)
4060 if (leftvt == VT_EMPTY || rightvt == VT_EMPTY)
4062 if (leftvt == rightvt ||
4063 leftvt == VT_I2 || rightvt == VT_I2 ||
4064 leftvt == VT_UI1 || rightvt == VT_UI1 ||
4065 leftvt == VT_BOOL || rightvt == VT_BOOL)
4067 else if (leftvt == VT_NULL || rightvt == VT_NULL)
4069 else if (leftvt == VT_I8 || rightvt == VT_I8)
4072 else if (leftvt == VT_NULL || rightvt == VT_NULL)
4076 else if (leftvt == VT_UI1 || rightvt == VT_UI1)
4078 if (leftvt == rightvt)
4080 else if (leftvt == rightvt ||
4081 leftvt == VT_I2 || rightvt == VT_I2 ||
4082 leftvt == VT_BOOL || rightvt == VT_BOOL)
4086 else if (leftvt == VT_I8 || rightvt == VT_I8)
4089 else if (leftvt == VT_I2 || rightvt == VT_I2)
4091 if (leftvt == rightvt ||
4092 leftvt == VT_BOOL || rightvt == VT_BOOL)
4094 else if (leftvt == VT_I8 || rightvt == VT_I8)
4097 else if (leftvt == VT_BOOL && rightvt == VT_BOOL)
4101 else if (leftvt == VT_I8 || rightvt == VT_I8)
4103 if (leftvt == VT_INT || rightvt == VT_INT)
4108 hres = pVarOr(&left, &right, &result);
4110 ok(hres == DISP_E_TYPEMISMATCH || hres == DISP_E_BADVARTYPE,
4111 "VarOr: %d|0x%X, %d|0x%X: Expected failure, got 0x%X vt %d\n",
4112 leftvt, ExtraFlags[i], rightvt, ExtraFlags[i], hres,
4115 ok(hres == S_OK && V_VT(&result) == resvt,
4116 "VarOr: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%X vt %d\n",
4117 leftvt, ExtraFlags[i], rightvt, ExtraFlags[i], resvt, hres,
4123 /* Test returned values. Since we know the returned type is correct
4124 * and that we handle all combinations of invalid types, just check
4125 * that good type combinations produce the desired value.
4126 * FIXME: Test VT_DECIMAL/VT_DISPATCH
4128 VAROR(EMPTY,0,EMPTY,0,I2,0);
4129 VAROR(EMPTY,1,EMPTY,0,I2,0);
4130 VAROR(EMPTY,0,NULL,0,NULL,0);
4131 VAROR(EMPTY,0,I1,0,I4,0);
4132 VAROR(EMPTY,0,I1,1,I4,1);
4133 VAROR(EMPTY,0,UI1,0,I2,0);
4134 VAROR(EMPTY,0,UI1,1,I2,1);
4135 VAROR(EMPTY,0,I2,0,I2,0);
4136 VAROR(EMPTY,0,I2,1,I2,1);
4137 VAROR(EMPTY,0,UI2,0,I4,0);
4138 VAROR(EMPTY,0,UI2,1,I4,1);
4139 VAROR(EMPTY,0,I4,0,I4,0);
4140 VAROR(EMPTY,0,I4,1,I4,1);
4141 VAROR(EMPTY,0,UI4,0,I4,0);
4142 VAROR(EMPTY,0,UI4,1,I4,1);
4143 if (HAVE_OLEAUT32_I8)
4145 VAROR(EMPTY,0,I8,0,I8,0);
4146 VAROR(EMPTY,0,I8,1,I8,1);
4147 VAROR(EMPTY,0,UI8,0,I4,0);
4148 VAROR(EMPTY,0,UI8,1,I4,1);
4150 VAROR(EMPTY,0,INT,0,I4,0);
4151 VAROR(EMPTY,0,INT,1,I4,1);
4152 VAROR(EMPTY,0,UINT,0,I4,0);
4153 VAROR(EMPTY,0,UINT,1,I4,1);
4154 VAROR(EMPTY,0,BOOL,0,I2,0);
4155 VAROR(EMPTY,0,BOOL,1,I2,1);
4156 VAROR(EMPTY,0,R4,0,I4,0);
4157 VAROR(EMPTY,0,R4,1,I4,1);
4158 VAROR(EMPTY,0,R8,0,I4,0);
4159 VAROR(EMPTY,0,R8,1,I4,1);
4160 rbstr = SysAllocString(szFalse);
4161 VAROR(EMPTY,0,BSTR,rbstr,I2,0);
4162 SysFreeString(rbstr);
4163 rbstr = SysAllocString(szTrue);
4164 VAROR(EMPTY,0,BSTR,rbstr,I2,-1);
4165 SysFreeString(rbstr);
4166 VARORCY(EMPTY,0,10000,I4,1);
4168 /* NULL OR 0 = NULL. NULL OR n = n */
4169 VAROR(NULL,0,NULL,0,NULL,0);
4170 VAROR(NULL,1,NULL,0,NULL,0);
4171 VAROR(NULL,0,I1,0,NULL,0);
4172 VAROR(NULL,0,I1,1,I4,1);
4173 VAROR(NULL,0,UI1,0,NULL,0);
4174 VAROR(NULL,0,UI1,1,UI1,1);
4175 VAROR(NULL,0,I2,0,NULL,0);
4176 VAROR(NULL,0,I2,1,I2,1);
4177 VAROR(NULL,0,UI2,0,NULL,0);
4178 VAROR(NULL,0,UI2,1,I4,1);
4179 VAROR(NULL,0,I4,0,NULL,0);
4180 VAROR(NULL,0,I4,1,I4,1);
4181 VAROR(NULL,0,UI4,0,NULL,0);
4182 VAROR(NULL,0,UI4,1,I4,1);
4183 if (HAVE_OLEAUT32_I8)
4185 VAROR(NULL,0,I8,0,NULL,0);
4186 VAROR(NULL,0,I8,1,I8,1);
4187 VAROR(NULL,0,UI8,0,NULL,0);
4188 VAROR(NULL,0,UI8,1,I4,1);
4190 VAROR(NULL,0,INT,0,NULL,0);
4191 VAROR(NULL,0,INT,1,I4,1);
4192 VAROR(NULL,0,UINT,0,NULL,0);
4193 VAROR(NULL,0,UINT,1,I4,1);
4194 VAROR(NULL,0,BOOL,0,NULL,0);
4195 VAROR(NULL,0,BOOL,1,BOOL,1);
4196 VAROR(NULL,0,R4,0,NULL,0);
4197 VAROR(NULL,0,R4,1,I4,1);
4198 VAROR(NULL,0,R8,0,NULL,0);
4199 VAROR(NULL,0,R8,1,I4,1);
4200 rbstr = SysAllocString(szFalse);
4201 VAROR(NULL,0,BSTR,rbstr,NULL,0);
4202 SysFreeString(rbstr);
4203 rbstr = SysAllocString(szTrue);
4204 VAROR(NULL,0,BSTR,rbstr,BOOL,VARIANT_TRUE);
4205 SysFreeString(rbstr);
4206 VARORCY(NULL,0,10000,I4,1);
4207 VARORCY(NULL,0,0,NULL,0);
4209 VAROR(BOOL,VARIANT_TRUE,BOOL,VARIANT_TRUE,BOOL,VARIANT_TRUE);
4210 VAROR(BOOL,VARIANT_TRUE,BOOL,VARIANT_FALSE,BOOL,VARIANT_TRUE);
4211 VAROR(BOOL,VARIANT_FALSE,BOOL,VARIANT_TRUE,BOOL,VARIANT_TRUE);
4212 VAROR(BOOL,VARIANT_FALSE,BOOL,VARIANT_FALSE,BOOL,VARIANT_FALSE);
4213 /* Assume x,y & y,x are the same from now on to reduce the number of tests */
4214 VAROR(BOOL,VARIANT_TRUE,I1,-1,I4,-1);
4215 VAROR(BOOL,VARIANT_TRUE,I1,0,I4,-1);
4216 VAROR(BOOL,VARIANT_FALSE,I1,0,I4,0);
4217 VAROR(BOOL,VARIANT_TRUE,UI1,255,I2,-1);
4218 VAROR(BOOL,VARIANT_TRUE,UI1,0,I2,-1);
4219 VAROR(BOOL,VARIANT_FALSE,UI1,0,I2,0);
4220 VAROR(BOOL,VARIANT_TRUE,I2,-1,I2,-1);
4221 VAROR(BOOL,VARIANT_TRUE,I2,0,I2,-1);
4222 VAROR(BOOL,VARIANT_FALSE,I2,0,I2,0);
4223 VAROR(BOOL,VARIANT_TRUE,UI2,65535,I4,-1);
4224 VAROR(BOOL,VARIANT_TRUE,UI2,0,I4,-1);
4225 VAROR(BOOL,VARIANT_FALSE,UI2,0,I4,0);
4226 VAROR(BOOL,VARIANT_TRUE,I4,-1,I4,-1);
4227 VAROR(BOOL,VARIANT_TRUE,I4,0,I4,-1);
4228 VAROR(BOOL,VARIANT_FALSE,I4,0,I4,0);
4229 VAROR(BOOL,VARIANT_TRUE,UI4,0xffffffff,I4,-1);
4230 VAROR(BOOL,VARIANT_TRUE,UI4,0,I4,-1);
4231 VAROR(BOOL,VARIANT_FALSE,UI4,0,I4,0);
4232 VAROR(BOOL,VARIANT_TRUE,R4,-1,I4,-1);
4233 VAROR(BOOL,VARIANT_TRUE,R4,0,I4,-1);
4234 VAROR(BOOL,VARIANT_FALSE,R4,0,I4,0);
4235 VAROR(BOOL,VARIANT_TRUE,R8,-1,I4,-1);
4236 VAROR(BOOL,VARIANT_TRUE,R8,0,I4,-1);
4237 VAROR(BOOL,VARIANT_FALSE,R8,0,I4,0);
4238 VAROR(BOOL,VARIANT_TRUE,DATE,-1,I4,-1);
4239 VAROR(BOOL,VARIANT_TRUE,DATE,0,I4,-1);
4240 VAROR(BOOL,VARIANT_FALSE,DATE,0,I4,0);
4241 if (HAVE_OLEAUT32_I8)
4243 VAROR(BOOL,VARIANT_TRUE,I8,-1,I8,-1);
4244 VAROR(BOOL,VARIANT_TRUE,I8,0,I8,-1);
4245 VAROR(BOOL,VARIANT_FALSE,I8,0,I8,0);
4246 /* This returns DISP_E_OVERFLOW which indicates that a conversion
4247 * to I4 is performed.
4249 /* VAROR(BOOL,VARIANT_TRUE,UI8,-1,I4,-1); */
4250 VAROR(BOOL,VARIANT_TRUE,UI8,0,I4,-1);
4251 VAROR(BOOL,VARIANT_FALSE,UI8,0,I4,0);
4253 VAROR(BOOL,VARIANT_TRUE,INT,-1,I4,-1);
4254 VAROR(BOOL,VARIANT_TRUE,INT,0,I4,-1);
4255 VAROR(BOOL,VARIANT_FALSE,INT,0,I4,0);
4256 VAROR(BOOL,VARIANT_TRUE,UINT,0xffffffff,I4,-1);
4257 VAROR(BOOL,VARIANT_TRUE,UINT,0,I4,-1);
4258 VAROR(BOOL,VARIANT_FALSE,UINT,0,I4,0);
4259 rbstr = SysAllocString(szFalse);
4260 VAROR(BOOL,VARIANT_FALSE,BSTR,rbstr,BOOL,VARIANT_FALSE);
4261 VAROR(BOOL,VARIANT_TRUE,BSTR,rbstr,BOOL,VARIANT_TRUE);
4262 SysFreeString(rbstr);
4263 rbstr = SysAllocString(szTrue);
4264 VAROR(BOOL,VARIANT_FALSE,BSTR,rbstr,BOOL,VARIANT_TRUE);
4265 VAROR(BOOL,VARIANT_TRUE,BSTR,rbstr,BOOL,VARIANT_TRUE);
4266 SysFreeString(rbstr);
4267 VARORCY(BOOL,VARIANT_TRUE,10000,I4,-1);
4268 VARORCY(BOOL,VARIANT_TRUE,0,I4,-1);
4269 VARORCY(BOOL,VARIANT_FALSE,0,I4,0);
4271 VAROR(I1,-1,I1,-1,I4,-1);
4272 VAROR(I1,-1,I1,0,I4,-1);
4273 VAROR(I1,0,I1,0,I4,0);
4274 VAROR(I1,-1,UI1,255,I4,-1);
4275 VAROR(I1,-1,UI1,0,I4,-1);
4276 VAROR(I1,0,UI1,0,I4,0);
4277 VAROR(I1,-1,I2,-1,I4,-1);
4278 VAROR(I1,-1,I2,0,I4,-1);
4279 VAROR(I1,0,I2,0,I4,0);
4280 VAROR(I1,-1,UI2,65535,I4,-1);
4281 VAROR(I1,-1,UI2,0,I4,-1);
4282 VAROR(I1,0,UI2,0,I4,0);
4283 VAROR(I1,-1,I4,-1,I4,-1);
4284 VAROR(I1,-1,I4,0,I4,-1);
4285 VAROR(I1,0,I4,0,I4,0);
4286 VAROR(I1,-1,UI4,0xffffffff,I4,-1);
4287 VAROR(I1,-1,UI4,0,I4,-1);
4288 VAROR(I1,0,UI4,0,I4,0);
4289 VAROR(I1,-1,R4,-1,I4,-1);
4290 VAROR(I1,-1,R4,0,I4,-1);
4291 VAROR(I1,0,R4,0,I4,0);
4292 VAROR(I1,-1,R8,-1,I4,-1);
4293 VAROR(I1,-1,R8,0,I4,-1);
4294 VAROR(I1,0,R8,0,I4,0);
4295 VAROR(I1,-1,DATE,-1,I4,-1);
4296 VAROR(I1,-1,DATE,0,I4,-1);
4297 VAROR(I1,0,DATE,0,I4,0);
4298 if (HAVE_OLEAUT32_I8)
4300 VAROR(I1,-1,I8,-1,I8,-1);
4301 VAROR(I1,-1,I8,0,I8,-1);
4302 VAROR(I1,0,I8,0,I8,0);
4303 VAROR(I1,-1,UI8,0,I4,-1);
4304 VAROR(I1,0,UI8,0,I4,0);
4306 VAROR(I1,-1,INT,-1,I4,-1);
4307 VAROR(I1,-1,INT,0,I4,-1);
4308 VAROR(I1,0,INT,0,I4,0);
4309 VAROR(I1,-1,UINT,0xffffffff,I4,-1);
4310 VAROR(I1,-1,UINT,0,I4,-1);
4311 VAROR(I1,0,UINT,0,I4,0);
4312 rbstr = SysAllocString(szFalse);
4313 VAROR(I1,0,BSTR,rbstr,I4,0);
4314 VAROR(I1,-1,BSTR,rbstr,I4,-1);
4315 SysFreeString(rbstr);
4316 rbstr = SysAllocString(szTrue);
4317 VAROR(I1,0,BSTR,rbstr,I4,-1);
4318 VAROR(I1,-1,BSTR,rbstr,I4,-1);
4319 SysFreeString(rbstr);
4320 VARORCY(I1,-1,10000,I4,-1);
4321 VARORCY(I1,-1,0,I4,-1);
4322 VARORCY(I1,0,0,I4,0);
4324 VAROR(UI1,255,UI1,255,UI1,255);
4325 VAROR(UI1,255,UI1,0,UI1,255);
4326 VAROR(UI1,0,UI1,0,UI1,0);
4327 VAROR(UI1,255,I2,-1,I2,-1);
4328 VAROR(UI1,255,I2,0,I2,255);
4329 VAROR(UI1,0,I2,0,I2,0);
4330 VAROR(UI1,255,UI2,65535,I4,65535);
4331 VAROR(UI1,255,UI2,0,I4,255);
4332 VAROR(UI1,0,UI2,0,I4,0);
4333 VAROR(UI1,255,I4,-1,I4,-1);
4334 VAROR(UI1,255,I4,0,I4,255);
4335 VAROR(UI1,0,I4,0,I4,0);
4336 VAROR(UI1,255,UI4,0xffffffff,I4,-1);
4337 VAROR(UI1,255,UI4,0,I4,255);
4338 VAROR(UI1,0,UI4,0,I4,0);
4339 VAROR(UI1,255,R4,-1,I4,-1);
4340 VAROR(UI1,255,R4,0,I4,255);
4341 VAROR(UI1,0,R4,0,I4,0);
4342 VAROR(UI1,255,R8,-1,I4,-1);
4343 VAROR(UI1,255,R8,0,I4,255);
4344 VAROR(UI1,0,R8,0,I4,0);
4345 VAROR(UI1,255,DATE,-1,I4,-1);
4346 VAROR(UI1,255,DATE,0,I4,255);
4347 VAROR(UI1,0,DATE,0,I4,0);
4348 if (HAVE_OLEAUT32_I8)
4350 VAROR(UI1,255,I8,-1,I8,-1);
4351 VAROR(UI1,255,I8,0,I8,255);
4352 VAROR(UI1,0,I8,0,I8,0);
4353 VAROR(UI1,255,UI8,0,I4,255);
4354 VAROR(UI1,0,UI8,0,I4,0);
4356 VAROR(UI1,255,INT,-1,I4,-1);
4357 VAROR(UI1,255,INT,0,I4,255);
4358 VAROR(UI1,0,INT,0,I4,0);
4359 VAROR(UI1,255,UINT,0xffffffff,I4,-1);
4360 VAROR(UI1,255,UINT,0,I4,255);
4361 VAROR(UI1,0,UINT,0,I4,0);
4362 rbstr = SysAllocString(szFalse);
4363 VAROR(UI1,0,BSTR,rbstr,I2,0);
4364 VAROR(UI1,255,BSTR,rbstr,I2,255);
4365 SysFreeString(rbstr);
4366 rbstr = SysAllocString(szTrue);
4367 VAROR(UI1,0,BSTR,rbstr,I2,-1);
4368 VAROR(UI1,255,BSTR,rbstr,I2,-1);
4369 SysFreeString(rbstr);
4370 VARORCY(UI1,255,10000,I4,255);
4371 VARORCY(UI1,255,0,I4,255);
4372 VARORCY(UI1,0,0,I4,0);
4374 VAROR(I2,-1,I2,-1,I2,-1);
4375 VAROR(I2,-1,I2,0,I2,-1);
4376 VAROR(I2,0,I2,0,I2,0);
4377 VAROR(I2,-1,UI2,65535,I4,-1);
4378 VAROR(I2,-1,UI2,0,I4,-1);
4379 VAROR(I2,0,UI2,0,I4,0);
4380 VAROR(I2,-1,I4,-1,I4,-1);
4381 VAROR(I2,-1,I4,0,I4,-1);
4382 VAROR(I2,0,I4,0,I4,0);
4383 VAROR(I2,-1,UI4,0xffffffff,I4,-1);
4384 VAROR(I2,-1,UI4,0,I4,-1);
4385 VAROR(I2,0,UI4,0,I4,0);
4386 VAROR(I2,-1,R4,-1,I4,-1);
4387 VAROR(I2,-1,R4,0,I4,-1);
4388 VAROR(I2,0,R4,0,I4,0);
4389 VAROR(I2,-1,R8,-1,I4,-1);
4390 VAROR(I2,-1,R8,0,I4,-1);
4391 VAROR(I2,0,R8,0,I4,0);
4392 VAROR(I2,-1,DATE,-1,I4,-1);
4393 VAROR(I2,-1,DATE,0,I4,-1);
4394 VAROR(I2,0,DATE,0,I4,0);
4395 if (HAVE_OLEAUT32_I8)
4397 VAROR(I2,-1,I8,-1,I8,-1);
4398 VAROR(I2,-1,I8,0,I8,-1);
4399 VAROR(I2,0,I8,0,I8,0);
4400 VAROR(I2,-1,UI8,0,I4,-1);
4401 VAROR(I2,0,UI8,0,I4,0);
4403 VAROR(I2,-1,INT,-1,I4,-1);
4404 VAROR(I2,-1,INT,0,I4,-1);
4405 VAROR(I2,0,INT,0,I4,0);
4406 VAROR(I2,-1,UINT,0xffffffff,I4,-1);
4407 VAROR(I2,-1,UINT,0,I4,-1);
4408 VAROR(I2,0,UINT,0,I4,0);
4409 rbstr = SysAllocString(szFalse);
4410 VAROR(I2,0,BSTR,rbstr,I2,0);
4411 VAROR(I2,-1,BSTR,rbstr,I2,-1);
4412 SysFreeString(rbstr);
4413 rbstr = SysAllocString(szTrue);
4414 VAROR(I2,0,BSTR,rbstr,I2,-1);
4415 VAROR(I2,-1,BSTR,rbstr,I2,-1);
4416 SysFreeString(rbstr);
4417 VARORCY(I2,-1,10000,I4,-1);
4418 VARORCY(I2,-1,0,I4,-1);
4419 VARORCY(I2,0,0,I4,0);
4421 VAROR(UI2,65535,UI2,65535,I4,65535);
4422 VAROR(UI2,65535,UI2,0,I4,65535);
4423 VAROR(UI2,0,UI2,0,I4,0);
4424 VAROR(UI2,65535,I4,-1,I4,-1);
4425 VAROR(UI2,65535,I4,0,I4,65535);
4426 VAROR(UI2,0,I4,0,I4,0);
4427 VAROR(UI2,65535,UI4,0xffffffff,I4,-1);
4428 VAROR(UI2,65535,UI4,0,I4,65535);
4429 VAROR(UI2,0,UI4,0,I4,0);
4430 VAROR(UI2,65535,R4,-1,I4,-1);
4431 VAROR(UI2,65535,R4,0,I4,65535);
4432 VAROR(UI2,0,R4,0,I4,0);
4433 VAROR(UI2,65535,R8,-1,I4,-1);
4434 VAROR(UI2,65535,R8,0,I4,65535);
4435 VAROR(UI2,0,R8,0,I4,0);
4436 VAROR(UI2,65535,DATE,-1,I4,-1);
4437 VAROR(UI2,65535,DATE,0,I4,65535);
4438 VAROR(UI2,0,DATE,0,I4,0);
4439 if (HAVE_OLEAUT32_I8)
4441 VAROR(UI2,65535,I8,-1,I8,-1);
4442 VAROR(UI2,65535,I8,0,I8,65535);
4443 VAROR(UI2,0,I8,0,I8,0);
4444 VAROR(UI2,65535,UI8,0,I4,65535);
4445 VAROR(UI2,0,UI8,0,I4,0);
4447 VAROR(UI2,65535,INT,-1,I4,-1);
4448 VAROR(UI2,65535,INT,0,I4,65535);
4449 VAROR(UI2,0,INT,0,I4,0);
4450 VAROR(UI2,65535,UINT,0xffffffff,I4,-1);
4451 VAROR(UI2,65535,UINT,0,I4,65535);
4452 VAROR(UI2,0,UINT,0,I4,0);
4453 rbstr = SysAllocString(szFalse);
4454 VAROR(UI2,0,BSTR,rbstr,I4,0);
4455 VAROR(UI2,65535,BSTR,rbstr,I4,65535);
4456 SysFreeString(rbstr);
4457 rbstr = SysAllocString(szTrue);
4458 VAROR(UI2,0,BSTR,rbstr,I4,-1);
4459 VAROR(UI2,65535,BSTR,rbstr,I4,-1);
4460 SysFreeString(rbstr);
4461 VARORCY(UI2,65535,10000,I4,65535);
4462 VARORCY(UI2,65535,0,I4,65535);
4463 VARORCY(UI2,0,0,I4,0);
4465 VAROR(I4,-1,I4,-1,I4,-1);
4466 VAROR(I4,-1,I4,0,I4,-1);
4467 VAROR(I4,0,I4,0,I4,0);
4468 VAROR(I4,-1,UI4,0xffffffff,I4,-1);
4469 VAROR(I4,-1,UI4,0,I4,-1);
4470 VAROR(I4,0,UI4,0,I4,0);
4471 VAROR(I4,-1,R4,-1,I4,-1);
4472 VAROR(I4,-1,R4,0,I4,-1);
4473 VAROR(I4,0,R4,0,I4,0);
4474 VAROR(I4,-1,R8,-1,I4,-1);
4475 VAROR(I4,-1,R8,0,I4,-1);
4476 VAROR(I4,0,R8,0,I4,0);
4477 VAROR(I4,-1,DATE,-1,I4,-1);
4478 VAROR(I4,-1,DATE,0,I4,-1);
4479 VAROR(I4,0,DATE,0,I4,0);
4480 if (HAVE_OLEAUT32_I8)
4482 VAROR(I4,-1,I8,-1,I8,-1);
4483 VAROR(I4,-1,I8,0,I8,-1);
4484 VAROR(I4,0,I8,0,I8,0);
4485 VAROR(I4,-1,UI8,0,I4,-1);
4486 VAROR(I4,0,UI8,0,I4,0);
4488 VAROR(I4,-1,INT,-1,I4,-1);
4489 VAROR(I4,-1,INT,0,I4,-1);
4490 VAROR(I4,0,INT,0,I4,0);
4491 VAROR(I4,-1,UINT,0xffffffff,I4,-1);
4492 VAROR(I4,-1,UINT,0,I4,-1);
4493 VAROR(I4,0,UINT,0,I4,0);
4494 rbstr = SysAllocString(szFalse);
4495 VAROR(I4,0,BSTR,rbstr,I4,0);
4496 VAROR(I4,-1,BSTR,rbstr,I4,-1);
4497 SysFreeString(rbstr);
4498 rbstr = SysAllocString(szTrue);
4499 VAROR(I4,0,BSTR,rbstr,I4,-1);
4500 VAROR(I4,-1,BSTR,rbstr,I4,-1);
4501 SysFreeString(rbstr);
4502 VARORCY(I4,-1,10000,I4,-1);
4503 VARORCY(I4,-1,0,I4,-1);
4504 VARORCY(I4,0,0,I4,0);
4506 VAROR(UI4,0xffffffff,UI4,0xffffffff,I4,-1);
4507 VAROR(UI4,0xffffffff,UI4,0,I4,-1);
4508 VAROR(UI4,0,UI4,0,I4,0);
4509 VAROR(UI4,0xffffffff,R4,-1,I4,-1);
4510 VAROR(UI4,0xffffffff,R4,0,I4,-1);
4511 VAROR(UI4,0,R4,0,I4,0);
4512 VAROR(UI4,0xffffffff,R8,-1,I4,-1);
4513 VAROR(UI4,0xffffffff,R8,0,I4,-1);
4514 VAROR(UI4,0,R8,0,I4,0);
4515 VAROR(UI4,0xffffffff,DATE,-1,I4,-1);
4516 VAROR(UI4,0xffffffff,DATE,0,I4,-1);
4517 VAROR(UI4,0,DATE,0,I4,0);
4518 if (HAVE_OLEAUT32_I8)
4520 VAROR(UI4,0xffffffff,I8,-1,I8,-1);
4521 VAROR(UI4,0xffffffff,I8,0,I8,0xffffffff);
4522 VAROR(UI4,0,I8,0,I8,0);
4523 VAROR(UI4,0xffffffff,UI8,0,I4,-1);
4524 VAROR(UI4,0,UI8,0,I4,0);
4526 VAROR(UI4,0xffffffff,INT,-1,I4,-1);
4527 VAROR(UI4,0xffffffff,INT,0,I4,-1);
4528 VAROR(UI4,0,INT,0,I4,0);
4529 VAROR(UI4,0xffffffff,UINT,0xffffffff,I4,-1);
4530 VAROR(UI4,0xffffffff,UINT,0,I4,-1);
4531 VAROR(UI4,0,UINT,0,I4,0);
4532 rbstr = SysAllocString(szFalse);
4533 VAROR(UI4,0,BSTR,rbstr,I4,0);
4534 VAROR(UI4,0xffffffff,BSTR,rbstr,I4,-1);
4535 SysFreeString(rbstr);
4536 rbstr = SysAllocString(szTrue);
4537 VAROR(UI4,0,BSTR,rbstr,I4,-1);
4538 VAROR(UI4,0xffffffff,BSTR,rbstr,I4,-1);
4539 SysFreeString(rbstr);
4540 VARORCY(UI4,0xffffffff,10000,I4,-1);
4541 VARORCY(UI4,0xffffffff,0,I4,-1);
4542 VARORCY(UI4,0,0,I4,0);
4544 VAROR(R4,-1,R4,-1,I4,-1);
4545 VAROR(R4,-1,R4,0,I4,-1);
4546 VAROR(R4,0,R4,0,I4,0);
4547 VAROR(R4,-1,R8,-1,I4,-1);
4548 VAROR(R4,-1,R8,0,I4,-1);
4549 VAROR(R4,0,R8,0,I4,0);
4550 VAROR(R4,-1,DATE,-1,I4,-1);
4551 VAROR(R4,-1,DATE,0,I4,-1);
4552 VAROR(R4,0,DATE,0,I4,0);
4553 if (HAVE_OLEAUT32_I8)
4555 VAROR(R4,-1,I8,-1,I8,-1);
4556 VAROR(R4,-1,I8,0,I8,-1);
4557 VAROR(R4,0,I8,0,I8,0);
4558 VAROR(R4,-1,UI8,0,I4,-1);
4559 VAROR(R4,0,UI8,0,I4,0);
4561 VAROR(R4,-1,INT,-1,I4,-1);
4562 VAROR(R4,-1,INT,0,I4,-1);
4563 VAROR(R4,0,INT,0,I4,0);
4564 VAROR(R4,-1,UINT,0xffffffff,I4,-1);
4565 VAROR(R4,-1,UINT,0,I4,-1);
4566 VAROR(R4,0,UINT,0,I4,0);
4567 rbstr = SysAllocString(szFalse);
4568 VAROR(R4,0,BSTR,rbstr,I4,0);
4569 VAROR(R4,-1,BSTR,rbstr,I4,-1);
4570 SysFreeString(rbstr);
4571 rbstr = SysAllocString(szTrue);
4572 VAROR(R4,0,BSTR,rbstr,I4,-1);
4573 VAROR(R4,-1,BSTR,rbstr,I4,-1);
4574 SysFreeString(rbstr);
4575 VARORCY(R4,-1,10000,I4,-1);
4576 VARORCY(R4,-1,0,I4,-1);
4577 VARORCY(R4,0,0,I4,0);
4579 VAROR(R8,-1,R8,-1,I4,-1);
4580 VAROR(R8,-1,R8,0,I4,-1);
4581 VAROR(R8,0,R8,0,I4,0);
4582 VAROR(R8,-1,DATE,-1,I4,-1);
4583 VAROR(R8,-1,DATE,0,I4,-1);
4584 VAROR(R8,0,DATE,0,I4,0);
4585 if (HAVE_OLEAUT32_I8)
4587 VAROR(R8,-1,I8,-1,I8,-1);
4588 VAROR(R8,-1,I8,0,I8,-1);
4589 VAROR(R8,0,I8,0,I8,0);
4590 VAROR(R8,-1,UI8,0,I4,-1);
4591 VAROR(R8,0,UI8,0,I4,0);
4593 VAROR(R8,-1,INT,-1,I4,-1);
4594 VAROR(R8,-1,INT,0,I4,-1);
4595 VAROR(R8,0,INT,0,I4,0);
4596 VAROR(R8,-1,UINT,0xffffffff,I4,-1);
4597 VAROR(R8,-1,UINT,0,I4,-1);
4598 VAROR(R8,0,UINT,0,I4,0);
4599 rbstr = SysAllocString(szFalse);
4600 VAROR(R8,0,BSTR,rbstr,I4,0);
4601 VAROR(R8,-1,BSTR,rbstr,I4,-1);
4602 SysFreeString(rbstr);
4603 rbstr = SysAllocString(szTrue);
4604 VAROR(R8,0,BSTR,rbstr,I4,-1);
4605 VAROR(R8,-1,BSTR,rbstr,I4,-1);
4606 SysFreeString(rbstr);
4607 VARORCY(R8,-1,10000,I4,-1);
4608 VARORCY(R8,-1,0,I4,-1);
4609 VARORCY(R8,0,0,I4,0);
4611 VAROR(DATE,-1,DATE,-1,I4,-1);
4612 VAROR(DATE,-1,DATE,0,I4,-1);
4613 VAROR(DATE,0,DATE,0,I4,0);
4614 if (HAVE_OLEAUT32_I8)
4616 VAROR(DATE,-1,I8,-1,I8,-1);
4617 VAROR(DATE,-1,I8,0,I8,-1);
4618 VAROR(DATE,0,I8,0,I8,0);
4619 VAROR(DATE,-1,UI8,0,I4,-1);
4620 VAROR(DATE,0,UI8,0,I4,0);
4622 VAROR(DATE,-1,INT,-1,I4,-1);
4623 VAROR(DATE,-1,INT,0,I4,-1);
4624 VAROR(DATE,0,INT,0,I4,0);
4625 VAROR(DATE,-1,UINT,0xffffffff,I4,-1);
4626 VAROR(DATE,-1,UINT,0,I4,-1);
4627 VAROR(DATE,0,UINT,0,I4,0);
4628 rbstr = SysAllocString(szFalse);
4629 VAROR(DATE,0,BSTR,rbstr,I4,0);
4630 VAROR(DATE,-1,BSTR,rbstr,I4,-1);
4631 SysFreeString(rbstr);
4632 rbstr = SysAllocString(szTrue);
4633 VAROR(DATE,0,BSTR,rbstr,I4,-1);
4634 VAROR(DATE,-1,BSTR,rbstr,I4,-1);
4635 SysFreeString(rbstr);
4636 VARORCY(DATE,-1,10000,I4,-1);
4637 VARORCY(DATE,-1,0,I4,-1);
4638 VARORCY(DATE,0,0,I4,0);
4640 if (HAVE_OLEAUT32_I8)
4642 VAROR(I8,-1,I8,-1,I8,-1);
4643 VAROR(I8,-1,I8,0,I8,-1);
4644 VAROR(I8,0,I8,0,I8,0);
4645 VAROR(I8,-1,UI8,0,I8,-1);
4646 VAROR(I8,0,UI8,0,I8,0);
4647 /* These overflow under native and Wine
4648 VAROR(I8,-1,INT,-1,I4,-1);
4649 VAROR(I8,-1,INT,0,I4,-1);
4650 VAROR(I8,0,INT,0,I4,0); */
4651 VAROR(I8,-1,UINT,0xffffffff,I8,-1);
4652 VAROR(I8,-1,UINT,0,I8,-1);
4653 VAROR(I8,0,UINT,0,I8,0);
4654 rbstr = SysAllocString(szFalse);
4655 VAROR(I8,0,BSTR,rbstr,I8,0);
4656 VAROR(I8,-1,BSTR,rbstr,I8,-1);
4657 SysFreeString(rbstr);
4658 rbstr = SysAllocString(szTrue);
4659 VAROR(I8,0,BSTR,rbstr,I8,-1);
4660 VAROR(I8,-1,BSTR,rbstr,I8,-1);
4661 SysFreeString(rbstr);
4662 VARORCY(I8,-1,10000,I8,-1);
4663 VARORCY(I8,-1,0,I8,-1);
4664 VARORCY(I8,0,0,I8,0);
4666 VAROR(UI8,0xffff,UI8,0xffff,I4,0xffff);
4667 VAROR(UI8,0xffff,UI8,0,I4,0xffff);
4668 VAROR(UI8,0,UI8,0,I4,0);
4669 VAROR(UI8,0xffff,INT,-1,I4,-1);
4670 VAROR(UI8,0xffff,INT,0,I4,0xffff);
4671 VAROR(UI8,0,INT,0,I4,0);
4672 VAROR(UI8,0xffff,UINT,0xffff,I4,0xffff);
4673 VAROR(UI8,0xffff,UINT,0,I4,0xffff);
4674 VAROR(UI8,0,UINT,0,I4,0);
4675 rbstr = SysAllocString(szFalse);
4676 VAROR(UI8,0,BSTR,rbstr,I4,0);
4677 VAROR(UI8,0xffff,BSTR,rbstr,I4,0xffff);
4678 SysFreeString(rbstr);
4679 rbstr = SysAllocString(szTrue);
4680 VAROR(UI8,0,BSTR,rbstr,I4,-1);
4681 VAROR(UI8,0xffff,BSTR,rbstr,I4,-1);
4682 SysFreeString(rbstr);
4683 VARORCY(UI8,0xffff,10000,I4,0xffff);
4684 VARORCY(UI8,0xffff,0,I4,0xffff);
4685 VARORCY(UI8,0,0,I4,0);
4688 VAROR(INT,-1,INT,-1,I4,-1);
4689 VAROR(INT,-1,INT,0,I4,-1);
4690 VAROR(INT,0,INT,0,I4,0);
4691 VAROR(INT,-1,UINT,0xffff,I4,-1);
4692 VAROR(INT,-1,UINT,0,I4,-1);
4693 VAROR(INT,0,UINT,0,I4,0);
4694 rbstr = SysAllocString(szFalse);
4695 VAROR(INT,0,BSTR,rbstr,I4,0);
4696 VAROR(INT,-1,BSTR,rbstr,I4,-1);
4697 SysFreeString(rbstr);
4698 rbstr = SysAllocString(szTrue);
4699 VAROR(INT,0,BSTR,rbstr,I4,-1);
4700 VAROR(INT,-1,BSTR,rbstr,I4,-1);
4701 SysFreeString(rbstr);
4702 VARORCY(INT,-1,10000,I4,-1);
4703 VARORCY(INT,-1,0,I4,-1);
4704 VARORCY(INT,0,0,I4,0);
4706 VAROR(UINT,0xffff,UINT,0xffff,I4,0xffff);
4707 VAROR(UINT,0xffff,UINT,0,I4,0xffff);
4708 VAROR(UINT,0,UINT,0,I4,0);
4709 rbstr = SysAllocString(szFalse);
4710 VAROR(UINT,0,BSTR,rbstr,I4,0);
4711 VAROR(UINT,0xffff,BSTR,rbstr,I4,0xffff);
4712 SysFreeString(rbstr);
4713 rbstr = SysAllocString(szTrue);
4714 VAROR(UINT,0,BSTR,rbstr,I4,-1);
4715 VAROR(UINT,0xffff,BSTR,rbstr,I4,-1);
4716 SysFreeString(rbstr);
4717 VARORCY(UINT,0xffff,10000,I4,0xffff);
4718 VARORCY(UINT,0xffff,0,I4,0xffff);
4719 VARORCY(UINT,0,0,I4,0);
4721 lbstr = SysAllocString(szFalse);
4722 rbstr = SysAllocString(szFalse);
4723 VAROR(BSTR,lbstr,BSTR,rbstr,BOOL,0);
4724 SysFreeString(rbstr);
4725 rbstr = SysAllocString(szTrue);
4726 VAROR(BSTR,lbstr,BSTR,rbstr,BOOL,VARIANT_TRUE);
4727 SysFreeString(lbstr);
4728 lbstr = SysAllocString(szTrue);
4729 VAROR(BSTR,lbstr,BSTR,rbstr,BOOL,VARIANT_TRUE);
4730 VARORCY(BSTR,lbstr,10000,I4,-1);
4731 SysFreeString(lbstr);
4732 lbstr = SysAllocString(szFalse);
4733 VARORCY(BSTR,lbstr,10000,I4,1);
4734 SysFreeString(lbstr);
4735 SysFreeString(rbstr);
4738 static HRESULT (WINAPI *pVarEqv)(LPVARIANT,LPVARIANT,LPVARIANT);
4740 #define VAREQV(vt1,val1,vt2,val2,rvt,rval) \
4741 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
4742 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
4743 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
4744 test_var_call2( __LINE__, pVarEqv, &left, &right, &exp )
4746 static void test_VarEqv(void)
4748 VARIANT left, right, exp, result;
4754 /* Test all possible flag/vt combinations & the resulting vt type */
4755 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
4757 VARTYPE leftvt, rightvt, resvt;
4759 for (leftvt = 0; leftvt <= VT_BSTR_BLOB; leftvt++)
4763 for (rightvt = 0; rightvt <= VT_BSTR_BLOB; rightvt++)
4769 if (leftvt == VT_BSTR || rightvt == VT_BSTR ||
4770 leftvt == VT_DISPATCH || rightvt == VT_DISPATCH ||
4771 leftvt == VT_UNKNOWN || rightvt == VT_UNKNOWN)
4774 memset(&left, 0, sizeof(left));
4775 memset(&right, 0, sizeof(right));
4776 V_VT(&left) = leftvt | ExtraFlags[i];
4777 V_VT(&right) = rightvt | ExtraFlags[i];
4778 V_VT(&result) = VT_EMPTY;
4781 if (ExtraFlags[i] & VT_ARRAY || ExtraFlags[i] & VT_BYREF ||
4782 !IsValidVariantClearVT(leftvt, ExtraFlags[i]) ||
4783 !IsValidVariantClearVT(rightvt, ExtraFlags[i]) ||
4784 leftvt == VT_CLSID || rightvt == VT_CLSID ||
4785 leftvt == VT_RECORD || rightvt == VT_RECORD ||
4786 leftvt == VT_VARIANT || rightvt == VT_VARIANT ||
4787 leftvt == VT_ERROR || rightvt == VT_ERROR)
4791 if (leftvt == VT_EMPTY || rightvt == VT_EMPTY)
4793 if (leftvt == rightvt ||
4794 leftvt == VT_I2 || rightvt == VT_I2 ||
4795 leftvt == VT_UI1 || rightvt == VT_UI1 ||
4796 leftvt == VT_BOOL || rightvt == VT_BOOL)
4798 else if (leftvt == VT_NULL || rightvt == VT_NULL)
4800 else if (leftvt == VT_I8 || rightvt == VT_I8)
4803 else if (leftvt == VT_NULL || rightvt == VT_NULL)
4807 else if (leftvt == VT_UI1 || rightvt == VT_UI1)
4809 if (leftvt == rightvt)
4811 else if (leftvt == rightvt ||
4812 leftvt == VT_I2 || rightvt == VT_I2 ||
4813 leftvt == VT_BOOL || rightvt == VT_BOOL)
4817 else if (leftvt == VT_I8 || rightvt == VT_I8)
4820 else if (leftvt == VT_I2 || rightvt == VT_I2)
4822 if (leftvt == rightvt ||
4823 leftvt == VT_BOOL || rightvt == VT_BOOL)
4825 else if (leftvt == VT_I8 || rightvt == VT_I8)
4828 else if (leftvt == VT_BOOL && rightvt == VT_BOOL)
4832 else if (leftvt == VT_I8 || rightvt == VT_I8)
4834 if (leftvt == VT_INT || rightvt == VT_INT)
4839 hres = pVarEqv(&left, &right, &result);
4841 ok(hres == DISP_E_TYPEMISMATCH || hres == DISP_E_BADVARTYPE,
4842 "VarEqv: %d|0x%X, %d|0x%X: Expected failure, got 0x%X vt %d\n",
4843 leftvt, ExtraFlags[i], rightvt, ExtraFlags[i], hres,
4846 ok(hres == S_OK && V_VT(&result) == resvt,
4847 "VarEqv: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%X vt %d\n",
4848 leftvt, ExtraFlags[i], rightvt, ExtraFlags[i], resvt, hres,
4854 /* Test returned values */
4855 VAREQV(BOOL,VARIANT_TRUE,BOOL,VARIANT_TRUE,BOOL,VARIANT_TRUE);
4856 VAREQV(BOOL,VARIANT_FALSE,BOOL,VARIANT_TRUE,BOOL,VARIANT_FALSE);
4857 VAREQV(BOOL,TRUE,BOOL,TRUE,BOOL,VARIANT_TRUE);
4858 VAREQV(BOOL,FALSE,BOOL,FALSE,BOOL,VARIANT_TRUE);
4859 VAREQV(BOOL,TRUE,BOOL,FALSE,BOOL,-2);
4860 VAREQV(BOOL,FALSE,BOOL,TRUE,BOOL,-2);
4861 VAREQV(BOOL,6,BOOL,7,BOOL,-2);
4862 VAREQV(BOOL,6,BOOL,6,BOOL,VARIANT_TRUE);
4863 VAREQV(BOOL,VARIANT_TRUE,I2,VARIANT_TRUE,I2,VARIANT_TRUE);
4864 VAREQV(BOOL,VARIANT_TRUE,I2,VARIANT_FALSE,I2,VARIANT_FALSE);
4865 VAREQV(BOOL,6,I2,7,I2,-2);
4866 VAREQV(UI1,1,UI1,1,UI1,255);
4867 VAREQV(UI1,1,UI1,0,UI1,254);
4868 VAREQV(UI1,0,UI1,1,UI1,254);
4869 if (HAVE_OLEAUT32_I8)
4871 VAREQV(UI4,VARIANT_FALSE,I8,VARIANT_FALSE,I8,-1);
4872 VAREQV(UI4,5,I8,19,I8,-23);
4873 VAREQV(UI4,VARIANT_FALSE,UI8,VARIANT_FALSE,I4,-1);
4877 static HRESULT (WINAPI *pVarMul)(LPVARIANT,LPVARIANT,LPVARIANT);
4879 #define VARMUL(vt1,val1,vt2,val2,rvt,rval) \
4880 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
4881 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
4882 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
4883 test_var_call2( __LINE__, pVarMul, &left, &right, &exp )
4885 static void test_VarMul(void)
4887 VARIANT left, right, exp, result, cy, dec;
4895 lbstr = SysAllocString(sz12);
4896 rbstr = SysAllocString(sz12);
4898 /* Test all possible flag/vt combinations & the resulting vt type */
4899 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
4901 VARTYPE leftvt, rightvt, resvt;
4903 for (leftvt = 0; leftvt <= VT_BSTR_BLOB; leftvt++)
4908 for (rightvt = 0; rightvt <= VT_BSTR_BLOB; rightvt++)
4914 if (leftvt == VT_DISPATCH || rightvt == VT_DISPATCH ||
4915 leftvt == VT_UNKNOWN || rightvt == VT_UNKNOWN)
4918 memset(&left, 0, sizeof(left));
4919 memset(&right, 0, sizeof(right));
4920 V_VT(&left) = leftvt | ExtraFlags[i];
4921 if (leftvt == VT_BSTR)
4922 V_BSTR(&left) = lbstr;
4923 V_VT(&right) = rightvt | ExtraFlags[i];
4924 if (rightvt == VT_BSTR)
4925 V_BSTR(&right) = rbstr;
4926 V_VT(&result) = VT_EMPTY;
4929 /* Don't ask me why but native VarMul cannot handle:
4930 VT_I1, VT_UI2, VT_UI4, VT_INT, VT_UINT and VT_UI8.
4931 Tested with DCOM98, Win2k, WinXP */
4932 if (ExtraFlags[i] & VT_ARRAY || ExtraFlags[i] & VT_BYREF ||
4933 !IsValidVariantClearVT(leftvt, ExtraFlags[i]) ||
4934 !IsValidVariantClearVT(rightvt, ExtraFlags[i]) ||
4935 leftvt == VT_CLSID || rightvt == VT_CLSID ||
4936 leftvt == VT_RECORD || rightvt == VT_RECORD ||
4937 leftvt == VT_VARIANT || rightvt == VT_VARIANT ||
4938 leftvt == VT_ERROR || rightvt == VT_ERROR ||
4939 leftvt == VT_I1 || rightvt == VT_I1 ||
4940 leftvt == VT_UI2 || rightvt == VT_UI2 ||
4941 leftvt == VT_UI4 || rightvt == VT_UI4 ||
4942 leftvt == VT_UI8 || rightvt == VT_UI8 ||
4943 leftvt == VT_INT || rightvt == VT_INT ||
4944 leftvt == VT_UINT || rightvt == VT_UINT) {
4948 if (leftvt == VT_NULL || rightvt == VT_NULL)
4950 else if (leftvt == VT_DECIMAL || rightvt == VT_DECIMAL)
4952 else if (leftvt == VT_R8 || rightvt == VT_R8 ||
4953 leftvt == VT_BSTR || rightvt == VT_BSTR ||
4954 leftvt == VT_DATE || rightvt == VT_DATE)
4956 else if (leftvt == VT_R4 || rightvt == VT_R4) {
4957 if (leftvt == VT_I4 || rightvt == VT_I4 ||
4958 leftvt == VT_I8 || rightvt == VT_I8 ||
4959 leftvt == VT_CY || rightvt == VT_CY)
4963 } else if (leftvt == VT_CY || rightvt == VT_CY)
4965 else if (leftvt == VT_I8 || rightvt == VT_I8)
4967 else if (leftvt == VT_I4 || rightvt == VT_I4)
4969 else if (leftvt == VT_I2 || rightvt == VT_I2 ||
4970 leftvt == VT_BOOL || rightvt == VT_BOOL ||
4971 (leftvt == VT_EMPTY && rightvt == VT_EMPTY))
4973 else if (leftvt == VT_UI1 || rightvt == VT_UI1)
4976 hres = pVarMul(&left, &right, &result);
4978 ok(hres == DISP_E_TYPEMISMATCH || hres == DISP_E_BADVARTYPE,
4979 "VarMul: %d|0x%X, %d|0x%X: Expected failure, got 0x%X vt %d\n",
4980 leftvt, ExtraFlags[i], rightvt, ExtraFlags[i], hres,
4983 ok(hres == S_OK && V_VT(&result) == resvt,
4984 "VarMul: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%X vt %d\n",
4985 leftvt, ExtraFlags[i], rightvt, ExtraFlags[i], resvt, hres,
4992 /* Test returned values */
4993 VARMUL(I4,4,I4,2,I4,8);
4994 VARMUL(I2,4,I2,2,I2,8);
4995 VARMUL(I2,-13,I4,5,I4,-65);
4996 VARMUL(I4,-13,I4,5,I4,-65);
4997 VARMUL(I2,7,R4,0.5f,R4,3.5f);
4998 VARMUL(R4,0.5f,I4,5,R8,2.5);
4999 VARMUL(R8,7.1,BOOL,0,R8,0);
5000 VARMUL(BSTR,lbstr,I2,4,R8,48);
5001 VARMUL(BSTR,lbstr,BOOL,1,R8,12);
5002 VARMUL(BSTR,lbstr,R4,0.1f,R8,1.2);
5003 VARMUL(BSTR,lbstr,BSTR,rbstr,R8,144);
5004 VARMUL(R4,0.2f,BSTR,rbstr,R8,2.4);
5005 VARMUL(DATE,2.25,I4,7,R8,15.75);
5007 VARMUL(UI1, UI1_MAX, UI1, UI1_MAX, I4, UI1_MAX * UI1_MAX);
5008 VARMUL(I2, I2_MAX, I2, I2_MAX, I4, I2_MAX * I2_MAX);
5009 VARMUL(I2, I2_MAX, I2, I2_MIN, I4, I2_MAX * I2_MIN);
5010 VARMUL(I2, I2_MIN, I2, I2_MIN, I4, I2_MIN * I2_MIN);
5011 VARMUL(I4, I4_MAX, I4, I4_MAX, R8, (double)I4_MAX * I4_MAX);
5012 VARMUL(I4, I4_MAX, I4, I4_MIN, R8, (double)I4_MAX * I4_MIN);
5013 VARMUL(I4, I4_MIN, I4, I4_MIN, R8, (double)I4_MIN * I4_MIN);
5014 VARMUL(R4, R4_MAX, R4, R4_MAX, R8, (double)R4_MAX * R4_MAX);
5015 VARMUL(R4, R4_MAX, R4, R4_MIN, R4, R4_MAX * R4_MIN);
5016 VARMUL(R4, R4_MIN, R4, R4_MIN, R4, R4_MIN * R4_MIN);
5017 VARMUL(R8, R8_MAX, R8, R8_MIN, R8, R8_MAX * R8_MIN);
5018 VARMUL(R8, R8_MIN, R8, R8_MIN, R8, R8_MIN * R8_MIN);
5020 /* Manuly test some VT_CY and VT_DECIMAL variants */
5022 hres = VarCyFromI4(4711, &V_CY(&cy));
5023 ok(hres == S_OK, "VarCyFromI4 failed!\n");
5024 V_VT(&dec) = VT_DECIMAL;
5025 hres = VarDecFromR8(-4.2, &V_DECIMAL(&dec));
5026 ok(hres == S_OK, "VarDecFromR4 failed!\n");
5027 memset(&left, 0, sizeof(left));
5028 memset(&right, 0, sizeof(right));
5029 V_VT(&left) = VT_I4;
5031 V_VT(&right) = VT_UI1;
5034 hres = VarMul(&cy, &right, &result);
5035 ok(hres == S_OK && V_VT(&result) == VT_CY, "VarMul: expected coerced type VT_CY, got %s!\n", vtstr(V_VT(&result)));
5036 hres = VarR8FromCy(V_CY(&result), &r);
5037 ok(hres == S_OK && EQ_DOUBLE(r, 42399), "VarMul: CY value %f, expected %f\n", r, (double)42399);
5039 hres = VarMul(&left, &dec, &result);
5040 ok(hres == S_OK && V_VT(&result) == VT_DECIMAL, "VarMul: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result)));
5041 hres = VarR8FromDec(&V_DECIMAL(&result), &r);
5042 ok(hres == S_OK && EQ_DOUBLE(r, 46.2), "VarMul: DECIMAL value %f, expected %f\n", r, (double)46.2);
5044 SysFreeString(lbstr);
5045 SysFreeString(rbstr);
5048 static HRESULT (WINAPI *pVarAdd)(LPVARIANT,LPVARIANT,LPVARIANT);
5050 #define VARADD(vt1,val1,vt2,val2,rvt,rval) \
5051 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
5052 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
5053 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
5054 test_var_call2( __LINE__, pVarAdd, &left, &right, &exp )
5056 static void test_VarAdd(void)
5058 VARIANT left, right, exp, result, cy, dec;
5066 lbstr = SysAllocString(sz12);
5067 rbstr = SysAllocString(sz12);
5069 /* Test all possible flag/vt combinations & the resulting vt type */
5070 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
5072 VARTYPE leftvt, rightvt, resvt;
5074 for (leftvt = 0; leftvt <= VT_BSTR_BLOB; leftvt++)
5079 for (rightvt = 0; rightvt <= VT_BSTR_BLOB; rightvt++)
5085 if (leftvt == VT_UNKNOWN || rightvt == VT_UNKNOWN)
5088 memset(&left, 0, sizeof(left));
5089 memset(&right, 0, sizeof(right));
5090 V_VT(&left) = leftvt | ExtraFlags[i];
5091 if (leftvt == VT_BSTR)
5092 V_BSTR(&left) = lbstr;
5093 V_VT(&right) = rightvt | ExtraFlags[i];
5094 if (rightvt == VT_BSTR)
5095 V_BSTR(&right) = rbstr;
5096 V_VT(&result) = VT_EMPTY;
5099 /* Don't ask me why but native VarAdd cannot handle:
5100 VT_I1, VT_UI2, VT_UI4, VT_INT, VT_UINT and VT_UI8.
5101 Tested with DCOM98, Win2k, WinXP */
5102 if (ExtraFlags[i] & VT_ARRAY || ExtraFlags[i] & VT_BYREF ||
5103 !IsValidVariantClearVT(leftvt, ExtraFlags[i]) ||
5104 !IsValidVariantClearVT(rightvt, ExtraFlags[i]) ||
5105 leftvt == VT_CLSID || rightvt == VT_CLSID ||
5106 leftvt == VT_RECORD || rightvt == VT_RECORD ||
5107 leftvt == VT_VARIANT || rightvt == VT_VARIANT ||
5108 leftvt == VT_ERROR || rightvt == VT_ERROR ||
5109 leftvt == VT_I1 || rightvt == VT_I1 ||
5110 leftvt == VT_UI2 || rightvt == VT_UI2 ||
5111 leftvt == VT_UI4 || rightvt == VT_UI4 ||
5112 leftvt == VT_UI8 || rightvt == VT_UI8 ||
5113 leftvt == VT_INT || rightvt == VT_INT ||
5114 leftvt == VT_UINT || rightvt == VT_UINT) {
5118 if (leftvt == VT_NULL || rightvt == VT_NULL)
5120 else if (leftvt == VT_DISPATCH || rightvt == VT_DISPATCH)
5122 else if (leftvt == VT_DECIMAL || rightvt == VT_DECIMAL)
5124 else if (leftvt == VT_DATE || rightvt == VT_DATE)
5126 else if (leftvt == VT_CY || rightvt == VT_CY)
5128 else if (leftvt == VT_R8 || rightvt == VT_R8)
5130 else if (leftvt == VT_BSTR || rightvt == VT_BSTR) {
5131 if ((leftvt == VT_BSTR && rightvt == VT_BSTR) ||
5132 leftvt == VT_EMPTY || rightvt == VT_EMPTY)
5136 } else if (leftvt == VT_R4 || rightvt == VT_R4) {
5137 if (leftvt == VT_I4 || rightvt == VT_I4 ||
5138 leftvt == VT_I8 || rightvt == VT_I8)
5143 else if (leftvt == VT_I8 || rightvt == VT_I8)
5145 else if (leftvt == VT_I4 || rightvt == VT_I4)
5147 else if (leftvt == VT_I2 || rightvt == VT_I2 ||
5148 leftvt == VT_BOOL || rightvt == VT_BOOL ||
5149 (leftvt == VT_EMPTY && rightvt == VT_EMPTY))
5151 else if (leftvt == VT_UI1 || rightvt == VT_UI1)
5154 hres = pVarAdd(&left, &right, &result);
5156 ok(hres == DISP_E_TYPEMISMATCH || hres == DISP_E_BADVARTYPE,
5157 "VarAdd: %d|0x%X, %d|0x%X: Expected failure, got 0x%X vt %d\n",
5158 leftvt, ExtraFlags[i], rightvt, ExtraFlags[i], hres,
5161 ok(hres == S_OK && V_VT(&result) == resvt,
5162 "VarAdd: %d|0x%X, %d|0x%X: expected S_OK, vt %d, got 0x%X vt %d\n",
5163 leftvt, ExtraFlags[i], rightvt, ExtraFlags[i], resvt, hres,
5166 /* Note, we don't clear left/right deliberately here */
5167 VariantClear(&result);
5172 /* Test returned values */
5173 VARADD(I4,4,I4,2,I4,6);
5174 VARADD(I2,4,I2,2,I2,6);
5175 VARADD(I2,-13,I4,5,I4,-8);
5176 VARADD(I4,-13,I4,5,I4,-8);
5177 VARADD(I2,7,R4,0.5f,R4,7.5f);
5178 VARADD(R4,0.5f,I4,5,R8,5.5);
5179 VARADD(R8,7.1,BOOL,0,R8,7.1);
5180 VARADD(BSTR,lbstr,I2,4,R8,16);
5181 VARADD(BSTR,lbstr,BOOL,1,R8,13);
5182 VARADD(BSTR,lbstr,R4,0.1f,R8,12.1);
5183 VARADD(R4,0.2f,BSTR,rbstr,R8,12.2);
5184 VARADD(DATE,2.25,I4,7,DATE,9.25);
5185 VARADD(DATE,1.25,R4,-1.7f,DATE,-0.45);
5187 VARADD(UI1, UI1_MAX, UI1, UI1_MAX, I2, UI1_MAX + UI1_MAX);
5188 VARADD(I2, I2_MAX, I2, I2_MAX, I4, I2_MAX + I2_MAX);
5189 VARADD(I2, I2_MAX, I2, I2_MIN, I2, I2_MAX + I2_MIN);
5190 VARADD(I2, I2_MIN, I2, I2_MIN, I4, I2_MIN + I2_MIN);
5191 VARADD(I4, I4_MAX, I4, I4_MIN, I4, I4_MAX + I4_MIN);
5192 VARADD(I4, I4_MAX, I4, I4_MAX, R8, (double)I4_MAX + I4_MAX);
5193 VARADD(I4, I4_MIN, I4, I4_MIN, R8, (double)I4_MIN + I4_MIN);
5194 VARADD(R4, R4_MAX, R4, R4_MAX, R8, (double)R4_MAX + R4_MAX);
5195 VARADD(R4, R4_MAX, R4, R4_MIN, R4, R4_MAX + R4_MIN);
5196 VARADD(R4, R4_MIN, R4, R4_MIN, R4, R4_MIN + R4_MIN);
5197 VARADD(R8, R8_MAX, R8, R8_MIN, R8, R8_MAX + R8_MIN);
5198 VARADD(R8, R8_MIN, R8, R8_MIN, R8, R8_MIN + R8_MIN);
5200 /* Manually test BSTR + BSTR */
5201 V_VT(&left) = VT_BSTR;
5202 V_BSTR(&left) = lbstr;
5203 V_VT(&right) = VT_BSTR;
5204 V_BSTR(&right) = rbstr;
5205 hres = VarAdd(&left, &right, &result);
5206 ok(hres == S_OK && V_VT(&result) == VT_BSTR, "VarAdd: expected coerced type VT_BSTR, got %s!\n", vtstr(V_VT(&result)));
5207 hres = VarR8FromStr(V_BSTR(&result), 0, 0, &r);
5208 ok(hres == S_OK && EQ_DOUBLE(r, 1212), "VarAdd: BSTR value %f, expected %f\n", r, (double)1212);
5209 VariantClear(&result);
5211 /* Manuly test some VT_CY and VT_DECIMAL variants */
5213 hres = VarCyFromI4(4711, &V_CY(&cy));
5214 ok(hres == S_OK, "VarCyFromI4 failed!\n");
5215 V_VT(&dec) = VT_DECIMAL;
5216 hres = VarDecFromR8(-4.2, &V_DECIMAL(&dec));
5217 ok(hres == S_OK, "VarDecFromR4 failed!\n");
5218 memset(&left, 0, sizeof(left));
5219 memset(&right, 0, sizeof(right));
5220 V_VT(&left) = VT_I4;
5222 V_VT(&right) = VT_UI1;
5225 hres = VarAdd(&cy, &right, &result);
5226 ok(hres == S_OK && V_VT(&result) == VT_CY, "VarAdd: expected coerced type VT_CY, got %s!\n", vtstr(V_VT(&result)));
5227 hres = VarR8FromCy(V_CY(&result), &r);
5228 ok(hres == S_OK && EQ_DOUBLE(r, 4720), "VarAdd: CY value %f, expected %f\n", r, (double)4720);
5230 hres = VarAdd(&left, &dec, &result);
5231 ok(hres == S_OK && V_VT(&result) == VT_DECIMAL, "VarAdd: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result)));
5232 hres = VarR8FromDec(&V_DECIMAL(&result), &r);
5233 ok(hres == S_OK && EQ_DOUBLE(r, -15.2), "VarAdd: DECIMAL value %f, expected %f\n", r, (double)-15.2);
5234 VariantClear(&result);
5236 SysFreeString(lbstr);
5237 SysFreeString(rbstr);
5240 static void test_VarCat(void)
5243 VARIANT left, right, result, expected, expected_broken;
5244 static const WCHAR sz34[] = {'3','4','\0'};
5245 static const WCHAR sz1234[] = {'1','2','3','4','\0'};
5246 static const WCHAR date_sz12[] = {'9','/','3','0','/','1','9','8','0','1','2','\0'};
5247 static const WCHAR date_sz12_broken[] = {'9','/','3','0','/','8','0','1','2','\0'};
5248 static const WCHAR sz12_date[] = {'1','2','9','/','3','0','/','1','9','8','0','\0'};
5249 static const WCHAR sz12_date_broken[] = {'1','2','9','/','3','0','/','8','0','\0'};
5250 static const WCHAR sz_empty[] = {'\0'};
5251 TCHAR orig_date_format[128];
5252 VARTYPE leftvt, rightvt, resultvt;
5254 HRESULT expected_error_num;
5256 /* Set date format for testing */
5257 lcid = LOCALE_USER_DEFAULT;
5258 GetLocaleInfo(lcid,LOCALE_SSHORTDATE,orig_date_format,128);
5259 SetLocaleInfo(lcid,LOCALE_SSHORTDATE,"M/d/yyyy");
5262 VariantInit(&right);
5263 VariantInit(&result);
5264 VariantInit(&expected);
5266 /* Check expected types for all combinations */
5267 for (leftvt = 0; leftvt <= VT_BSTR_BLOB; leftvt++)
5272 /* Check if we need/have support for I8 and/or UI8 */
5273 if ((leftvt == VT_I8 || leftvt == VT_UI8) && !HAVE_OLEAUT32_I8)
5276 for (rightvt = 0; rightvt <= VT_BSTR_BLOB; rightvt++)
5280 expected_error_num = S_OK;
5281 resultvt = VT_EMPTY;
5283 if (leftvt == VT_DISPATCH || rightvt == VT_DISPATCH ||
5284 leftvt == VT_UNKNOWN || rightvt == VT_UNKNOWN ||
5285 leftvt == VT_RECORD || rightvt == VT_RECORD ||
5286 leftvt == 15 || rightvt == 15 /* Undefined type */)
5289 /* Check if we need/have support for I8 and/or UI8 */
5290 if ((rightvt == VT_I8 || rightvt == VT_UI8) && !HAVE_OLEAUT32_I8)
5293 if (leftvt == VT_NULL && rightvt == VT_NULL)
5295 else if (leftvt == VT_VARIANT && (rightvt == VT_ERROR ||
5296 rightvt == VT_DATE || rightvt == VT_DECIMAL))
5297 expected_error_num = DISP_E_TYPEMISMATCH;
5298 else if ((leftvt == VT_I2 || leftvt == VT_I4 ||
5299 leftvt == VT_R4 || leftvt == VT_R8 ||
5300 leftvt == VT_CY || leftvt == VT_BOOL ||
5301 leftvt == VT_BSTR || leftvt == VT_I1 ||
5302 leftvt == VT_UI1 || leftvt == VT_UI2 ||
5303 leftvt == VT_UI4 || leftvt == VT_I8 ||
5304 leftvt == VT_UI8 || leftvt == VT_INT ||
5305 leftvt == VT_UINT || leftvt == VT_EMPTY ||
5306 leftvt == VT_NULL || leftvt == VT_DECIMAL ||
5309 (rightvt == VT_I2 || rightvt == VT_I4 ||
5310 rightvt == VT_R4 || rightvt == VT_R8 ||
5311 rightvt == VT_CY || rightvt == VT_BOOL ||
5312 rightvt == VT_BSTR || rightvt == VT_I1 ||
5313 rightvt == VT_UI1 || rightvt == VT_UI2 ||
5314 rightvt == VT_UI4 || rightvt == VT_I8 ||
5315 rightvt == VT_UI8 || rightvt == VT_INT ||
5316 rightvt == VT_UINT || rightvt == VT_EMPTY ||
5317 rightvt == VT_NULL || rightvt == VT_DECIMAL ||
5318 rightvt == VT_DATE))
5320 else if (rightvt == VT_ERROR && leftvt < VT_VOID)
5321 expected_error_num = DISP_E_TYPEMISMATCH;
5322 else if (leftvt == VT_ERROR && (rightvt == VT_DATE ||
5323 rightvt == VT_ERROR || rightvt == VT_DECIMAL))
5324 expected_error_num = DISP_E_TYPEMISMATCH;
5325 else if (rightvt == VT_DATE || rightvt == VT_ERROR ||
5326 rightvt == VT_DECIMAL)
5327 expected_error_num = DISP_E_BADVARTYPE;
5328 else if (leftvt == VT_ERROR || rightvt == VT_ERROR)
5329 expected_error_num = DISP_E_TYPEMISMATCH;
5330 else if (leftvt == VT_VARIANT)
5331 expected_error_num = DISP_E_TYPEMISMATCH;
5332 else if (rightvt == VT_VARIANT && (leftvt == VT_EMPTY ||
5333 leftvt == VT_NULL || leftvt == VT_I2 ||
5334 leftvt == VT_I4 || leftvt == VT_R4 ||
5335 leftvt == VT_R8 || leftvt == VT_CY ||
5336 leftvt == VT_DATE || leftvt == VT_BSTR ||
5337 leftvt == VT_BOOL || leftvt == VT_DECIMAL ||
5338 leftvt == VT_I1 || leftvt == VT_UI1 ||
5339 leftvt == VT_UI2 || leftvt == VT_UI4 ||
5340 leftvt == VT_I8 || leftvt == VT_UI8 ||
5341 leftvt == VT_INT || leftvt == VT_UINT
5343 expected_error_num = DISP_E_TYPEMISMATCH;
5345 expected_error_num = DISP_E_BADVARTYPE;
5347 V_VT(&left) = leftvt;
5348 V_VT(&right) = rightvt;
5352 V_BSTR(&left) = SysAllocString(sz_empty); break;
5354 V_DATE(&left) = 0.0; break;
5356 VarDecFromR8(0.0, &V_DECIMAL(&left)); break;
5363 V_BSTR(&right) = SysAllocString(sz_empty); break;
5365 V_DATE(&right) = 0.0; break;
5367 VarDecFromR8(0.0, &V_DECIMAL(&right)); break;
5372 hres = VarCat(&left, &right, &result);
5374 /* Determine the error code for the vt combination */
5375 ok(hres == expected_error_num,
5376 "VarCat: %d, %d returned error, 0x%X expected 0x%X.\n",
5377 leftvt, rightvt, expected_error_num, hres);
5379 /* Check types are correct */
5380 ok(V_VT(&result) == resultvt,
5381 "VarCat: %d, %d: expected vt %d, got vt %d\n",
5382 leftvt, rightvt, resultvt, V_VT(&result));
5384 VariantClear(&left);
5385 VariantClear(&right);
5386 VariantClear(&result);
5390 /* Running single comparison tests to compare outputs */
5392 /* Test concat strings */
5393 V_VT(&left) = VT_BSTR;
5394 V_VT(&right) = VT_BSTR;
5395 V_VT(&expected) = VT_BSTR;
5396 V_BSTR(&left) = SysAllocString(sz12);
5397 V_BSTR(&right) = SysAllocString(sz34);
5398 V_BSTR(&expected) = SysAllocString(sz1234);
5399 hres = VarCat(&left,&right,&result);
5400 ok(hres == S_OK, "VarCat failed with error 0x%08x\n", hres);
5401 ok(VarCmp(&result,&expected,lcid,0) == VARCMP_EQ,
5402 "VarCat: VT_BSTR concat with VT_BSTR failed to return correct result\n");
5404 VariantClear(&left);
5405 VariantClear(&right);
5406 VariantClear(&result);
5408 /* Test if expression is VT_ERROR */
5409 V_VT(&left) = VT_ERROR;
5410 V_VT(&right) = VT_BSTR;
5411 V_BSTR(&right) = SysAllocString(sz1234);
5412 hres = VarCat(&left,&right,&result);
5413 ok(hres == DISP_E_TYPEMISMATCH, "VarCat should have returned DISP_E_TYPEMISMATCH instead of 0x%08x\n", hres);
5414 ok(V_VT(&result) == VT_EMPTY,
5415 "VarCat: VT_ERROR concat with VT_BSTR should have returned VT_EMPTY\n");
5417 VariantClear(&left);
5418 VariantClear(&right);
5419 VariantClear(&result);
5421 V_VT(&left) = VT_BSTR;
5422 V_VT(&right) = VT_ERROR;
5423 V_BSTR(&left) = SysAllocString(sz1234);
5424 hres = VarCat(&left,&right,&result);
5425 ok(hres == DISP_E_TYPEMISMATCH, "VarCat should have returned DISP_E_TYPEMISMATCH instead of 0x%08x\n", hres);
5426 ok(V_VT(&result) == VT_EMPTY,
5427 "VarCat: VT_BSTR concat with VT_ERROR should have returned VT_EMPTY\n");
5429 VariantClear(&left);
5430 VariantClear(&right);
5431 VariantClear(&result);
5432 VariantClear(&expected);
5434 /* Test combining boolean with number */
5435 V_VT(&left) = VT_INT;
5436 V_VT(&right) = VT_BOOL;
5437 V_VT(&expected) = VT_BSTR;
5439 V_BOOL(&right) = TRUE;
5440 V_BSTR(&expected) = SysAllocString(sz12_true);
5441 hres = VarCat(&left,&right,&result);
5442 ok(hres == S_OK, "VarCat failed with error 0x%08x\n", hres);
5443 hres = VarCmp(&result,&expected,lcid,0);
5444 ok(hres == VARCMP_EQ, "Expected VARCMP_EQ, got %08x for %s, %s\n",
5445 hres, variantstr(&result), variantstr(&expected));
5447 VariantClear(&left);
5448 VariantClear(&right);
5449 VariantClear(&result);
5450 VariantClear(&expected);
5452 V_VT(&left) = VT_INT;
5453 V_VT(&right) = VT_BOOL;
5454 V_VT(&expected) = VT_BSTR;
5456 V_BOOL(&right) = FALSE;
5457 V_BSTR(&expected) = SysAllocString(sz12_false);
5458 hres = VarCat(&left,&right,&result);
5459 ok(hres == S_OK, "VarCat failed with error 0x%08x\n", hres);
5460 hres = VarCmp(&result,&expected,lcid,0);
5461 ok(hres == VARCMP_EQ, "Expected VARCMP_EQ, got %08x for %s, %s\n",
5462 hres, variantstr(&result), variantstr(&expected));
5464 VariantClear(&left);
5465 VariantClear(&right);
5466 VariantClear(&result);
5467 VariantClear(&expected);
5469 /* Test when both expressions are numeric */
5470 V_VT(&left) = VT_INT;
5471 V_VT(&right) = VT_INT;
5472 V_VT(&expected) = VT_BSTR;
5475 V_BSTR(&expected) = SysAllocString(sz1234);
5476 hres = VarCat(&left,&right,&result);
5477 ok(hres == S_OK, "VarCat failed with error 0x%08x\n", hres);
5478 ok(VarCmp(&result,&expected,lcid,0) == VARCMP_EQ,
5479 "VarCat: NUMBER concat with NUMBER returned incorrect result\n");
5481 VariantClear(&left);
5482 VariantClear(&right);
5483 VariantClear(&result);
5485 /* Test if one expression is numeric and the other is a string */
5486 V_VT(&left) = VT_INT;
5487 V_VT(&right) = VT_BSTR;
5489 V_BSTR(&right) = SysAllocString(sz34);
5490 hres = VarCat(&left,&right,&result);
5491 ok(hres == S_OK, "VarCat failed with error 0x%08x\n", hres);
5492 ok(VarCmp(&result,&expected,lcid,0) == VARCMP_EQ,
5493 "VarCat: NUMBER concat with VT_BSTR, incorrect result\n");
5495 VariantClear(&left);
5496 VariantClear(&right);
5497 VariantClear(&result);
5499 V_VT(&left) = VT_BSTR;
5500 V_VT(&right) = VT_INT;
5501 V_BSTR(&left) = SysAllocString(sz12);
5503 hres = VarCat(&left,&right,&result);
5504 ok(hres == S_OK, "VarCat failed with error 0x%08x\n", hres);
5505 ok(VarCmp(&result,&expected,lcid,0) == VARCMP_EQ,
5506 "VarCat: VT_BSTR concat with NUMBER, incorrect result\n");
5508 VariantClear(&left);
5509 VariantClear(&right);
5510 VariantClear(&result);
5511 VariantClear(&expected);
5513 /* Test concat dates with strings */
5514 V_VT(&left) = VT_BSTR;
5515 V_VT(&right) = VT_DATE;
5516 V_VT(&expected) = VT_BSTR;
5517 V_VT(&expected_broken) = VT_BSTR;
5518 V_BSTR(&left) = SysAllocString(sz12);
5519 V_DATE(&right) = 29494.0;
5520 V_BSTR(&expected)= SysAllocString(sz12_date);
5521 V_BSTR(&expected_broken)= SysAllocString(sz12_date_broken);
5522 hres = VarCat(&left,&right,&result);
5523 ok(hres == S_OK, "VarCat failed with error 0x%08x\n", hres);
5524 ok(VarCmp(&result,&expected,lcid,0) == VARCMP_EQ ||
5525 broken(VarCmp(&result,&expected_broken,lcid,0) == VARCMP_EQ), /* Some W98 and NT4 (intermittent) */
5526 "VarCat: VT_BSTR concat with VT_DATE returned incorrect result\n");
5528 VariantClear(&left);
5529 VariantClear(&right);
5530 VariantClear(&result);
5531 VariantClear(&expected);
5532 VariantClear(&expected_broken);
5534 V_VT(&left) = VT_DATE;
5535 V_VT(&right) = VT_BSTR;
5536 V_VT(&expected) = VT_BSTR;
5537 V_VT(&expected_broken) = VT_BSTR;
5538 V_DATE(&left) = 29494.0;
5539 V_BSTR(&right) = SysAllocString(sz12);
5540 V_BSTR(&expected)= SysAllocString(date_sz12);
5541 V_BSTR(&expected_broken)= SysAllocString(date_sz12_broken);
5542 hres = VarCat(&left,&right,&result);
5543 ok(hres == S_OK, "VarCat failed with error 0x%08x\n", hres);
5544 ok(VarCmp(&result,&expected,lcid,0) == VARCMP_EQ ||
5545 broken(VarCmp(&result,&expected_broken,lcid,0) == VARCMP_EQ), /* Some W98 and NT4 (intermittent) */
5546 "VarCat: VT_DATE concat with VT_BSTR returned incorrect result\n");
5548 VariantClear(&left);
5549 VariantClear(&right);
5550 VariantClear(&result);
5551 VariantClear(&expected);
5552 VariantClear(&expected_broken);
5554 /* Test of both expressions are empty */
5555 V_VT(&left) = VT_BSTR;
5556 V_VT(&right) = VT_BSTR;
5557 V_VT(&expected) = VT_BSTR;
5558 V_BSTR(&left) = SysAllocString(sz_empty);
5559 V_BSTR(&right) = SysAllocString(sz_empty);
5560 V_BSTR(&expected)= SysAllocString(sz_empty);
5561 hres = VarCat(&left,&right,&result);
5562 ok(hres == S_OK, "VarCat failed with error 0x%08x\n", hres);
5563 ok(VarCmp(&result,&left,lcid,0) == VARCMP_EQ,
5564 "VarCat: EMPTY concat with EMPTY did not return empty VT_BSTR\n");
5566 /* Restore original date format settings */
5567 SetLocaleInfo(lcid,LOCALE_SSHORTDATE,orig_date_format);
5569 VariantClear(&left);
5570 VariantClear(&right);
5571 VariantClear(&result);
5572 VariantClear(&expected);
5575 static HRESULT (WINAPI *pVarAnd)(LPVARIANT,LPVARIANT,LPVARIANT);
5577 #define VARAND(vt1,val1,vt2,val2,rvt,rval) \
5578 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
5579 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
5580 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
5581 test_var_call2( __LINE__, pVarAnd, &left, &right, &exp )
5583 #define VARANDCY(vt1,val1,val2,rvt,rval) \
5584 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
5585 V_VT(&right) = VT_CY; V_CY(&right).int64 = val2; \
5586 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
5587 test_var_call2( __LINE__, pVarAnd, &left, &right, &exp )
5589 /* Skip any type that is not defined or produces an error for every case */
5590 #define SKIPTESTAND(a) \
5591 if (a == VT_ERROR || a == VT_VARIANT || \
5592 a == VT_DISPATCH || a == VT_UNKNOWN || \
5593 a > VT_UINT || a == 15 /*not defined*/) \
5596 static void test_VarAnd(void)
5598 static const WCHAR szFalse[] = { '#','F','A','L','S','E','#','\0' };
5599 static const WCHAR szTrue[] = { '#','T','R','U','E','#','\0' };
5600 VARIANT left, right, exp, result;
5601 BSTR false_str, true_str;
5605 true_str = SysAllocString(szTrue);
5606 false_str = SysAllocString(szFalse);
5610 /* Test all possible flag/vt combinations & the resulting vt type */
5611 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
5613 VARTYPE leftvt, rightvt, resvt;
5615 for (leftvt = 0; leftvt <= VT_BSTR_BLOB; leftvt++)
5617 SKIPTESTAND(leftvt);
5619 /* Check if we need/have support for I8 and/or UI8 */
5620 if ((leftvt == VT_I8 || leftvt == VT_UI8) && !HAVE_OLEAUT32_I8)
5623 for (rightvt = 0; rightvt <= VT_BSTR_BLOB; rightvt++)
5626 SKIPTESTAND(rightvt);
5628 /* Check if we need/have support for I8 and/or UI8 */
5629 if ((rightvt == VT_I8 || rightvt == VT_UI8) && !HAVE_OLEAUT32_I8)
5632 memset(&left, 0, sizeof(left));
5633 memset(&right, 0, sizeof(right));
5634 V_VT(&left) = leftvt | ExtraFlags[i];
5635 V_VT(&right) = rightvt | ExtraFlags[i];
5636 V_VT(&result) = VT_EMPTY;
5638 if ((leftvt | ExtraFlags[i]) == VT_BSTR)
5639 V_BSTR(&left) = true_str;
5640 if ((rightvt | ExtraFlags[i]) == VT_BSTR)
5641 V_BSTR(&right) = true_str;
5643 /* Native VarAnd always returns an error when using extra
5644 * flags or if the variant combination is I8 and INT.
5646 if ((leftvt == VT_I8 && rightvt == VT_INT) ||
5647 (leftvt == VT_INT && rightvt == VT_I8) ||
5651 /* Determine return type */
5652 else if (leftvt == VT_I8 || rightvt == VT_I8)
5654 else if (leftvt == VT_I4 || rightvt == VT_I4 ||
5655 leftvt == VT_UINT || rightvt == VT_UINT ||
5656 leftvt == VT_INT || rightvt == VT_INT ||
5657 leftvt == VT_UINT || rightvt == VT_UINT ||
5658 leftvt == VT_R4 || rightvt == VT_R4 ||
5659 leftvt == VT_R8 || rightvt == VT_R8 ||
5660 leftvt == VT_CY || rightvt == VT_CY ||
5661 leftvt == VT_DATE || rightvt == VT_DATE ||
5662 leftvt == VT_I1 || rightvt == VT_I1 ||
5663 leftvt == VT_UI2 || rightvt == VT_UI2 ||
5664 leftvt == VT_UI4 || rightvt == VT_UI4 ||
5665 leftvt == VT_UI8 || rightvt == VT_UI8 ||
5666 leftvt == VT_DECIMAL || rightvt == VT_DECIMAL)
5668 else if (leftvt == VT_UI1 || rightvt == VT_UI1 ||
5669 leftvt == VT_I2 || rightvt == VT_I2 ||
5670 leftvt == VT_EMPTY || rightvt == VT_EMPTY)
5671 if ((leftvt == VT_NULL && rightvt == VT_UI1) ||
5672 (leftvt == VT_UI1 && rightvt == VT_NULL) ||
5673 (leftvt == VT_UI1 && rightvt == VT_UI1))
5677 else if (leftvt == VT_BOOL || rightvt == VT_BOOL ||
5678 (leftvt == VT_BSTR && rightvt == VT_BSTR))
5680 else if (leftvt == VT_NULL || rightvt == VT_NULL ||
5681 leftvt == VT_BSTR || rightvt == VT_BSTR)
5686 hres = pVarAnd(&left, &right, &result);
5688 /* Check expected HRESULT and if result variant type is correct */
5690 ok (hres == DISP_E_BADVARTYPE || hres == DISP_E_TYPEMISMATCH,
5691 "VarAnd: %s|0x%X, %s|0x%X: got vt %s hr 0x%X\n",
5692 vtstr(leftvt), ExtraFlags[i], vtstr(rightvt), ExtraFlags[i],
5693 vtstr(V_VT(&result)), hres);
5695 ok (hres == S_OK && resvt == V_VT(&result),
5696 "VarAnd: %s|0x%X, %s|0x%X: expected vt %s hr 0x%X, got vt %s hr 0x%X\n",
5697 vtstr(leftvt), ExtraFlags[i], vtstr(rightvt), ExtraFlags[i], vtstr(resvt),
5698 S_OK, vtstr(V_VT(&result)), hres);
5704 * Test returned values. Since we know the returned type is correct
5705 * and that we handle all combinations of invalid types, just check
5706 * that good type combinations produce the desired value.
5707 * FIXME: Test VT_DECIMAL
5709 VARAND(EMPTY,0,EMPTY,0,I2,0);
5710 VARAND(EMPTY,1,EMPTY,0,I2,0);
5711 VARAND(EMPTY,1,EMPTY,1,I2,0);
5712 VARAND(EMPTY,0,NULL,0,I2,0);
5713 VARAND(EMPTY,1,NULL,0,I2,0);
5714 VARAND(EMPTY,1,NULL,1,I2,0);
5715 VARAND(EMPTY,0,I1,0,I4,0);
5716 VARAND(EMPTY,0,I1,1,I4,0);
5717 VARAND(EMPTY,1,I1,1,I4,0);
5718 VARAND(EMPTY,0,UI1,0,I2,0);
5719 VARAND(EMPTY,0,UI1,1,I2,0);
5720 VARAND(EMPTY,1,UI1,1,I2,0);
5721 VARAND(EMPTY,0,I2,0,I2,0);
5722 VARAND(EMPTY,0,I2,1,I2,0);
5723 VARAND(EMPTY,1,I2,1,I2,0);
5724 VARAND(EMPTY,0,UI2,0,I4,0);
5725 VARAND(EMPTY,0,UI2,1,I4,0);
5726 VARAND(EMPTY,1,UI2,1,I4,0);
5727 VARAND(EMPTY,0,I4,0,I4,0);
5728 VARAND(EMPTY,0,I4,1,I4,0);
5729 VARAND(EMPTY,1,I4,1,I4,0);
5730 VARAND(EMPTY,0,UI4,0,I4,0);
5731 VARAND(EMPTY,0,UI4,1,I4,0);
5732 VARAND(EMPTY,1,UI4,1,I4,0);
5733 if (HAVE_OLEAUT32_I8)
5735 VARAND(EMPTY,0,I8,0,I8,0);
5736 VARAND(EMPTY,0,I8,1,I8,0);
5737 VARAND(EMPTY,1,I8,1,I8,0);
5738 VARAND(EMPTY,0,UI8,0,I4,0);
5739 VARAND(EMPTY,0,UI8,1,I4,0);
5740 VARAND(EMPTY,1,UI8,1,I4,0);
5742 VARAND(EMPTY,0,INT,0,I4,0);
5743 VARAND(EMPTY,0,INT,1,I4,0);
5744 VARAND(EMPTY,1,INT,1,I4,0);
5745 VARAND(EMPTY,0,UINT,0,I4,0);
5746 VARAND(EMPTY,0,UINT,1,I4,0);
5747 VARAND(EMPTY,1,UINT,1,I4,0);
5748 VARAND(EMPTY,0,BOOL,0,I2,0);
5749 VARAND(EMPTY,0,BOOL,1,I2,0);
5750 VARAND(EMPTY,1,BOOL,1,I2,0);
5751 VARAND(EMPTY,0,R4,0,I4,0);
5752 VARAND(EMPTY,0,R4,1,I4,0);
5753 VARAND(EMPTY,1,R4,1,I4,0);
5754 VARAND(EMPTY,0,R8,0,I4,0);
5755 VARAND(EMPTY,0,R8,1,I4,0);
5756 VARAND(EMPTY,1,R8,1,I4,0);
5757 VARAND(EMPTY,0,BSTR,false_str,I2,0);
5758 VARAND(EMPTY,0,BSTR,true_str,I2,0);
5759 VARANDCY(EMPTY,0,10000,I4,0);
5761 /* NULL OR 0 = NULL. NULL OR n = n */
5762 VARAND(NULL,0,NULL,0,NULL,0);
5763 VARAND(NULL,1,NULL,0,NULL,0);
5764 VARAND(NULL,0,I1,0,I4,0);
5765 VARAND(NULL,0,I1,1,NULL,0);
5766 VARAND(NULL,0,UI1,0,UI1,0);
5767 VARAND(NULL,0,UI1,1,NULL,0);
5768 VARAND(NULL,0,I2,0,I2,0);
5769 VARAND(NULL,0,I2,1,NULL,0);
5770 VARAND(NULL,0,UI2,0,I4,0);
5771 VARAND(NULL,0,UI2,1,NULL,0);
5772 VARAND(NULL,0,I4,0,I4,0);
5773 VARAND(NULL,0,I4,1,NULL,0);
5774 VARAND(NULL,0,UI4,0,I4,0);
5775 VARAND(NULL,0,UI4,1,NULL,0);
5776 if (HAVE_OLEAUT32_I8)
5778 VARAND(NULL,0,I8,0,I8,0);
5779 VARAND(NULL,0,I8,1,NULL,0);
5780 VARAND(NULL,0,UI8,0,I4,0);
5781 VARAND(NULL,0,UI8,1,NULL,0);
5783 VARAND(NULL,0,INT,0,I4,0);
5784 VARAND(NULL,0,INT,1,NULL,0);
5785 VARAND(NULL,0,UINT,0,I4,0);
5786 VARAND(NULL,0,UINT,1,NULL,0);
5787 VARAND(NULL,0,BOOL,0,BOOL,0);
5788 VARAND(NULL,0,BOOL,1,NULL,0);
5789 VARAND(NULL,0,R4,0,I4,0);
5790 VARAND(NULL,0,R4,1,NULL,0);
5791 VARAND(NULL,0,R8,0,I4,0);
5792 VARAND(NULL,0,R8,1,NULL,0);
5793 VARAND(NULL,0,BSTR,false_str,BOOL,0);
5794 VARAND(NULL,0,BSTR,true_str,NULL,VARIANT_FALSE);
5795 VARANDCY(NULL,0,10000,NULL,0);
5796 VARANDCY(NULL,0,0,I4,0);
5797 VARAND(BOOL,VARIANT_TRUE,BOOL,VARIANT_TRUE,BOOL,VARIANT_TRUE);
5798 VARAND(BOOL,VARIANT_TRUE,BOOL,VARIANT_FALSE,BOOL,VARIANT_FALSE);
5799 VARAND(BOOL,VARIANT_FALSE,BOOL,VARIANT_TRUE,BOOL,VARIANT_FALSE);
5800 VARAND(BOOL,VARIANT_FALSE,BOOL,VARIANT_FALSE,BOOL,VARIANT_FALSE);
5802 /* Assume x,y & y,x are the same from now on to reduce the number of tests */
5803 VARAND(BOOL,VARIANT_TRUE,I1,-1,I4,-1);
5804 VARAND(BOOL,VARIANT_TRUE,I1,0,I4,0);
5805 VARAND(BOOL,VARIANT_FALSE,I1,0,I4,0);
5806 VARAND(BOOL,VARIANT_TRUE,UI1,255,I2,255);
5807 VARAND(BOOL,VARIANT_TRUE,UI1,0,I2,0);
5808 VARAND(BOOL,VARIANT_FALSE,UI1,0,I2,0);
5809 VARAND(BOOL,VARIANT_TRUE,I2,-1,I2,-1);
5810 VARAND(BOOL,VARIANT_TRUE,I2,0,I2,0);
5811 VARAND(BOOL,VARIANT_FALSE,I2,0,I2,0);
5812 VARAND(BOOL,VARIANT_TRUE,UI2,65535,I4,65535);
5813 VARAND(BOOL,VARIANT_TRUE,UI2,0,I4,0);
5814 VARAND(BOOL,VARIANT_FALSE,UI2,0,I4,0);
5815 VARAND(BOOL,VARIANT_TRUE,I4,-1,I4,-1);
5816 VARAND(BOOL,VARIANT_TRUE,I4,0,I4,0);
5817 VARAND(BOOL,VARIANT_FALSE,I4,0,I4,0);
5818 VARAND(BOOL,VARIANT_TRUE,UI4,0xffffffff,I4,-1);
5819 VARAND(BOOL,VARIANT_TRUE,UI4,0,I4,0);
5820 VARAND(BOOL,VARIANT_FALSE,UI4,0,I4,0);
5821 VARAND(BOOL,VARIANT_TRUE,R4,-1,I4,-1);
5822 VARAND(BOOL,VARIANT_TRUE,R4,0,I4,0);
5823 VARAND(BOOL,VARIANT_FALSE,R4,0,I4,0);
5824 VARAND(BOOL,VARIANT_TRUE,R8,-1,I4,-1);
5825 VARAND(BOOL,VARIANT_TRUE,R8,0,I4,0);
5826 VARAND(BOOL,VARIANT_FALSE,R8,0,I4,0);
5827 VARAND(BOOL,VARIANT_TRUE,DATE,-1,I4,-1);
5828 VARAND(BOOL,VARIANT_TRUE,DATE,0,I4,0);
5829 VARAND(BOOL,VARIANT_FALSE,DATE,0,I4,0);
5830 if (HAVE_OLEAUT32_I8)
5832 VARAND(BOOL,VARIANT_TRUE,I8,-1,I8,-1);
5833 VARAND(BOOL,VARIANT_TRUE,I8,0,I8,0);
5834 VARAND(BOOL,VARIANT_FALSE,I8,0,I8,0);
5835 VARAND(BOOL,VARIANT_TRUE,UI8,0,I4,0);
5836 VARAND(BOOL,VARIANT_FALSE,UI8,0,I4,0);
5838 VARAND(BOOL,VARIANT_TRUE,INT,-1,I4,-1);
5839 VARAND(BOOL,VARIANT_TRUE,INT,0,I4,0);
5840 VARAND(BOOL,VARIANT_FALSE,INT,0,I4,0);
5841 VARAND(BOOL,VARIANT_TRUE,UINT,0xffffffff,I4,-1);
5842 VARAND(BOOL,VARIANT_TRUE,UINT,0,I4,0);
5843 VARAND(BOOL,VARIANT_FALSE,UINT,0,I4,0);
5844 VARAND(BOOL,VARIANT_FALSE,BSTR,false_str,BOOL,VARIANT_FALSE);
5845 VARAND(BOOL,VARIANT_TRUE,BSTR,false_str,BOOL,VARIANT_FALSE);
5846 VARAND(BOOL,VARIANT_FALSE,BSTR,true_str,BOOL,VARIANT_FALSE);
5847 VARAND(BOOL,VARIANT_TRUE,BSTR,true_str,BOOL,VARIANT_TRUE);
5848 VARANDCY(BOOL,VARIANT_TRUE,10000,I4,1);
5849 VARANDCY(BOOL,VARIANT_TRUE,0,I4,0);
5850 VARANDCY(BOOL,VARIANT_FALSE,0,I4,0);
5851 VARAND(I1,-1,I1,-1,I4,-1);
5852 VARAND(I1,-1,I1,0,I4,0);
5853 VARAND(I1,0,I1,0,I4,0);
5854 VARAND(I1,-1,UI1,255,I4,255);
5855 VARAND(I1,-1,UI1,0,I4,0);
5856 VARAND(I1,0,UI1,0,I4,0);
5857 VARAND(I1,-1,I2,-1,I4,-1);
5858 VARAND(I1,-1,I2,0,I4,0);
5859 VARAND(I1,0,I2,0,I4,0);
5860 VARAND(I1,-1,UI2,65535,I4,65535);
5861 VARAND(I1,-1,UI2,0,I4,0);
5862 VARAND(I1,0,UI2,0,I4,0);
5863 VARAND(I1,-1,I4,-1,I4,-1);
5864 VARAND(I1,-1,I4,0,I4,0);
5865 VARAND(I1,0,I4,0,I4,0);
5866 VARAND(I1,-1,UI4,0xffffffff,I4,-1);
5867 VARAND(I1,-1,UI4,0,I4,0);
5868 VARAND(I1,0,UI4,0,I4,0);
5869 VARAND(I1,-1,R4,-1,I4,-1);
5870 VARAND(I1,-1,R4,0,I4,0);
5871 VARAND(I1,0,R4,0,I4,0);
5872 VARAND(I1,-1,R8,-1,I4,-1);
5873 VARAND(I1,-1,R8,0,I4,0);
5874 VARAND(I1,0,R8,0,I4,0);
5875 VARAND(I1,-1,DATE,-1,I4,-1);
5876 VARAND(I1,-1,DATE,0,I4,0);
5877 VARAND(I1,0,DATE,0,I4,0);
5878 if (HAVE_OLEAUT32_I8)
5880 VARAND(I1,-1,I8,-1,I8,-1);
5881 VARAND(I1,-1,I8,0,I8,0);
5882 VARAND(I1,0,I8,0,I8,0);
5883 VARAND(I1,-1,UI8,0,I4,0);
5884 VARAND(I1,0,UI8,0,I4,0);
5886 VARAND(I1,-1,INT,-1,I4,-1);
5887 VARAND(I1,-1,INT,0,I4,0);
5888 VARAND(I1,0,INT,0,I4,0);
5889 VARAND(I1,-1,UINT,0xffffffff,I4,-1);
5890 VARAND(I1,-1,UINT,0,I4,0);
5891 VARAND(I1,0,UINT,0,I4,0);
5892 VARAND(I1,0,BSTR,false_str,I4,0);
5893 VARAND(I1,-1,BSTR,false_str,I4,0);
5894 VARAND(I1,0,BSTR,true_str,I4,0);
5895 VARAND(I1,-1,BSTR,true_str,I4,-1);
5896 VARANDCY(I1,-1,10000,I4,1);
5897 VARANDCY(I1,-1,0,I4,0);
5898 VARANDCY(I1,0,0,I4,0);
5900 VARAND(UI1,255,UI1,255,UI1,255);
5901 VARAND(UI1,255,UI1,0,UI1,0);
5902 VARAND(UI1,0,UI1,0,UI1,0);
5903 VARAND(UI1,255,I2,-1,I2,255);
5904 VARAND(UI1,255,I2,0,I2,0);
5905 VARAND(UI1,0,I2,0,I2,0);
5906 VARAND(UI1,255,UI2,65535,I4,255);
5907 VARAND(UI1,255,UI2,0,I4,0);
5908 VARAND(UI1,0,UI2,0,I4,0);
5909 VARAND(UI1,255,I4,-1,I4,255);
5910 VARAND(UI1,255,I4,0,I4,0);
5911 VARAND(UI1,0,I4,0,I4,0);
5912 VARAND(UI1,255,UI4,0xffffffff,I4,255);
5913 VARAND(UI1,255,UI4,0,I4,0);
5914 VARAND(UI1,0,UI4,0,I4,0);
5915 VARAND(UI1,255,R4,-1,I4,255);
5916 VARAND(UI1,255,R4,0,I4,0);
5917 VARAND(UI1,0,R4,0,I4,0);
5918 VARAND(UI1,255,R8,-1,I4,255);
5919 VARAND(UI1,255,R8,0,I4,0);
5920 VARAND(UI1,0,R8,0,I4,0);
5921 VARAND(UI1,255,DATE,-1,I4,255);
5922 VARAND(UI1,255,DATE,0,I4,0);
5923 VARAND(UI1,0,DATE,0,I4,0);
5924 if (HAVE_OLEAUT32_I8)
5926 VARAND(UI1,255,I8,-1,I8,255);
5927 VARAND(UI1,255,I8,0,I8,0);
5928 VARAND(UI1,0,I8,0,I8,0);
5929 VARAND(UI1,255,UI8,0,I4,0);
5930 VARAND(UI1,0,UI8,0,I4,0);
5932 VARAND(UI1,255,INT,-1,I4,255);
5933 VARAND(UI1,255,INT,0,I4,0);
5934 VARAND(UI1,0,INT,0,I4,0);
5935 VARAND(UI1,255,UINT,0xffffffff,I4,255);
5936 VARAND(UI1,255,UINT,0,I4,0);
5937 VARAND(UI1,0,UINT,0,I4,0);
5938 VARAND(UI1,0,BSTR,false_str,I2,0);
5939 VARAND(UI1,255,BSTR,false_str,I2,0);
5940 VARAND(UI1,0,BSTR,true_str,I2,0);
5941 VARAND(UI1,255,BSTR,true_str,I2,255);
5942 VARANDCY(UI1,255,10000,I4,1);
5943 VARANDCY(UI1,255,0,I4,0);
5944 VARANDCY(UI1,0,0,I4,0);
5946 VARAND(I2,-1,I2,-1,I2,-1);
5947 VARAND(I2,-1,I2,0,I2,0);
5948 VARAND(I2,0,I2,0,I2,0);
5949 VARAND(I2,-1,UI2,65535,I4,65535);
5950 VARAND(I2,-1,UI2,0,I4,0);
5951 VARAND(I2,0,UI2,0,I4,0);
5952 VARAND(I2,-1,I4,-1,I4,-1);
5953 VARAND(I2,-1,I4,0,I4,0);
5954 VARAND(I2,0,I4,0,I4,0);
5955 VARAND(I2,-1,UI4,0xffffffff,I4,-1);
5956 VARAND(I2,-1,UI4,0,I4,0);
5957 VARAND(I2,0,UI4,0,I4,0);
5958 VARAND(I2,-1,R4,-1,I4,-1);
5959 VARAND(I2,-1,R4,0,I4,0);
5960 VARAND(I2,0,R4,0,I4,0);
5961 VARAND(I2,-1,R8,-1,I4,-1);
5962 VARAND(I2,-1,R8,0,I4,0);
5963 VARAND(I2,0,R8,0,I4,0);
5964 VARAND(I2,-1,DATE,-1,I4,-1);
5965 VARAND(I2,-1,DATE,0,I4,0);
5966 VARAND(I2,0,DATE,0,I4,0);
5967 if (HAVE_OLEAUT32_I8)
5969 VARAND(I2,-1,I8,-1,I8,-1);
5970 VARAND(I2,-1,I8,0,I8,0);
5971 VARAND(I2,0,I8,0,I8,0);
5972 VARAND(I2,-1,UI8,0,I4,0);
5973 VARAND(I2,0,UI8,0,I4,0);
5975 VARAND(I2,-1,INT,-1,I4,-1);
5976 VARAND(I2,-1,INT,0,I4,0);
5977 VARAND(I2,0,INT,0,I4,0);
5978 VARAND(I2,-1,UINT,0xffffffff,I4,-1);
5979 VARAND(I2,-1,UINT,0,I4,0);
5980 VARAND(I2,0,UINT,0,I4,0);
5981 VARAND(I2,0,BSTR,false_str,I2,0);
5982 VARAND(I2,-1,BSTR,false_str,I2,0);
5983 VARAND(I2,0,BSTR,true_str,I2,0);
5984 VARAND(I2,-1,BSTR,true_str,I2,-1);
5985 VARANDCY(I2,-1,10000,I4,1);
5986 VARANDCY(I2,-1,0,I4,0);
5987 VARANDCY(I2,0,0,I4,0);
5989 VARAND(UI2,65535,UI2,65535,I4,65535);
5990 VARAND(UI2,65535,UI2,0,I4,0);
5991 VARAND(UI2,0,UI2,0,I4,0);
5992 VARAND(UI2,65535,I4,-1,I4,65535);
5993 VARAND(UI2,65535,I4,0,I4,0);
5994 VARAND(UI2,0,I4,0,I4,0);
5995 VARAND(UI2,65535,UI4,0xffffffff,I4,65535);
5996 VARAND(UI2,65535,UI4,0,I4,0);
5997 VARAND(UI2,0,UI4,0,I4,0);
5998 VARAND(UI2,65535,R4,-1,I4,65535);
5999 VARAND(UI2,65535,R4,0,I4,0);
6000 VARAND(UI2,0,R4,0,I4,0);
6001 VARAND(UI2,65535,R8,-1,I4,65535);
6002 VARAND(UI2,65535,R8,0,I4,0);
6003 VARAND(UI2,0,R8,0,I4,0);
6004 VARAND(UI2,65535,DATE,-1,I4,65535);
6005 VARAND(UI2,65535,DATE,0,I4,0);
6006 VARAND(UI2,0,DATE,0,I4,0);
6007 if (HAVE_OLEAUT32_I8)
6009 VARAND(UI2,65535,I8,-1,I8,65535);
6010 VARAND(UI2,65535,I8,0,I8,0);
6011 VARAND(UI2,0,I8,0,I8,0);
6012 VARAND(UI2,65535,UI8,0,I4,0);
6013 VARAND(UI2,0,UI8,0,I4,0);
6015 VARAND(UI2,65535,INT,-1,I4,65535);
6016 VARAND(UI2,65535,INT,0,I4,0);
6017 VARAND(UI2,0,INT,0,I4,0);
6018 VARAND(UI2,65535,UINT,0xffffffff,I4,65535);
6019 VARAND(UI2,65535,UINT,0,I4,0);
6020 VARAND(UI2,0,UINT,0,I4,0);
6021 VARAND(UI2,0,BSTR,false_str,I4,0);
6022 VARAND(UI2,65535,BSTR,false_str,I4,0);
6023 VARAND(UI2,0,BSTR,true_str,I4,0);
6024 VARAND(UI2,65535,BSTR,true_str,I4,65535);
6025 VARANDCY(UI2,65535,10000,I4,1);
6026 VARANDCY(UI2,65535,0,I4,0);
6027 VARANDCY(UI2,0,0,I4,0);
6029 VARAND(I4,-1,I4,-1,I4,-1);
6030 VARAND(I4,-1,I4,0,I4,0);
6031 VARAND(I4,0,I4,0,I4,0);
6032 VARAND(I4,-1,UI4,0xffffffff,I4,-1);
6033 VARAND(I4,-1,UI4,0,I4,0);
6034 VARAND(I4,0,UI4,0,I4,0);
6035 VARAND(I4,-1,R4,-1,I4,-1);
6036 VARAND(I4,-1,R4,0,I4,0);
6037 VARAND(I4,0,R4,0,I4,0);
6038 VARAND(I4,-1,R8,-1,I4,-1);
6039 VARAND(I4,-1,R8,0,I4,0);
6040 VARAND(I4,0,R8,0,I4,0);
6041 VARAND(I4,-1,DATE,-1,I4,-1);
6042 VARAND(I4,-1,DATE,0,I4,0);
6043 VARAND(I4,0,DATE,0,I4,0);
6044 if (HAVE_OLEAUT32_I8)
6046 VARAND(I4,-1,I8,-1,I8,-1);
6047 VARAND(I4,-1,I8,0,I8,0);
6048 VARAND(I4,0,I8,0,I8,0);
6049 VARAND(I4,-1,UI8,0,I4,0);
6050 VARAND(I4,0,UI8,0,I4,0);
6052 VARAND(I4,-1,INT,-1,I4,-1);
6053 VARAND(I4,-1,INT,0,I4,0);
6054 VARAND(I4,0,INT,0,I4,0);
6055 VARAND(I4,-1,UINT,0xffffffff,I4,-1);
6056 VARAND(I4,-1,UINT,0,I4,0);
6057 VARAND(I4,0,UINT,0,I4,0);
6058 VARAND(I4,0,BSTR,false_str,I4,0);
6059 VARAND(I4,-1,BSTR,false_str,I4,0);
6060 VARAND(I4,0,BSTR,true_str,I4,0);
6061 VARAND(I4,-1,BSTR,true_str,I4,-1);
6062 VARANDCY(I4,-1,10000,I4,1);
6063 VARANDCY(I4,-1,0,I4,0);
6064 VARANDCY(I4,0,0,I4,0);
6066 VARAND(UI4,0xffffffff,UI4,0xffffffff,I4,-1);
6067 VARAND(UI4,0xffffffff,UI4,0,I4,0);
6068 VARAND(UI4,0,UI4,0,I4,0);
6069 VARAND(UI4,0xffffffff,R4,-1,I4,-1);
6070 VARAND(UI4,0xffffffff,R4,0,I4,0);
6071 VARAND(UI4,0,R4,0,I4,0);
6072 VARAND(UI4,0xffffffff,R8,-1,I4,-1);
6073 VARAND(UI4,0xffffffff,R8,0,I4,0);
6074 VARAND(UI4,0,R8,0,I4,0);
6075 VARAND(UI4,0xffffffff,DATE,-1,I4,-1);
6076 VARAND(UI4,0xffffffff,DATE,0,I4,0);
6077 VARAND(UI4,0,DATE,0,I4,0);
6078 if (HAVE_OLEAUT32_I8)
6080 VARAND(UI4,0xffffffff,I8,0,I8,0);
6081 VARAND(UI4,0,I8,0,I8,0);
6082 VARAND(UI4,0xffffffff,UI8,0,I4,0);
6083 VARAND(UI4,0,UI8,0,I4,0);
6085 VARAND(UI4,0xffffffff,INT,-1,I4,-1);
6086 VARAND(UI4,0xffffffff,INT,0,I4,0);
6087 VARAND(UI4,0,INT,0,I4,0);
6088 VARAND(UI4,0xffffffff,UINT,0xffffffff,I4,-1);
6089 VARAND(UI4,0xffffffff,UINT,0,I4,0);
6090 VARAND(UI4,0,UINT,0,I4,0);
6091 VARAND(UI4,0,BSTR,false_str,I4,0);
6092 VARAND(UI4,0xffffffff,BSTR,false_str,I4,0);
6093 VARAND(UI4,0,BSTR,true_str,I4,0);
6094 VARAND(UI4,0xffffffff,BSTR,true_str,I4,-1);
6095 VARANDCY(UI4,0xffffffff,10000,I4,1);
6096 VARANDCY(UI4,0xffffffff,0,I4,0);
6097 VARANDCY(UI4,0,0,I4,0);
6099 VARAND(R4,-1,R4,-1,I4,-1);
6100 VARAND(R4,-1,R4,0,I4,0);
6101 VARAND(R4,0,R4,0,I4,0);
6102 VARAND(R4,-1,R8,-1,I4,-1);
6103 VARAND(R4,-1,R8,0,I4,0);
6104 VARAND(R4,0,R8,0,I4,0);
6105 VARAND(R4,-1,DATE,-1,I4,-1);
6106 VARAND(R4,-1,DATE,0,I4,0);
6107 VARAND(R4,0,DATE,0,I4,0);
6108 if (HAVE_OLEAUT32_I8)
6110 VARAND(R4,-1,I8,-1,I8,-1);
6111 VARAND(R4,-1,I8,0,I8,0);
6112 VARAND(R4,0,I8,0,I8,0);
6113 VARAND(R4,-1,UI8,0,I4,0);
6114 VARAND(R4,0,UI8,0,I4,0);
6116 VARAND(R4,-1,INT,-1,I4,-1);
6117 VARAND(R4,-1,INT,0,I4,0);
6118 VARAND(R4,0,INT,0,I4,0);
6119 VARAND(R4,-1,UINT,0xffffffff,I4,-1);
6120 VARAND(R4,-1,UINT,0,I4,0);
6121 VARAND(R4,0,UINT,0,I4,0);
6122 VARAND(R4,0,BSTR,false_str,I4,0);
6123 VARAND(R4,-1,BSTR,false_str,I4,0);
6124 VARAND(R4,0,BSTR,true_str,I4,0);
6125 VARAND(R4,-1,BSTR,true_str,I4,-1);
6126 VARANDCY(R4,-1,10000,I4,1);
6127 VARANDCY(R4,-1,0,I4,0);
6128 VARANDCY(R4,0,0,I4,0);
6130 VARAND(R8,-1,R8,-1,I4,-1);
6131 VARAND(R8,-1,R8,0,I4,0);
6132 VARAND(R8,0,R8,0,I4,0);
6133 VARAND(R8,-1,DATE,-1,I4,-1);
6134 VARAND(R8,-1,DATE,0,I4,0);
6135 VARAND(R8,0,DATE,0,I4,0);
6136 if (HAVE_OLEAUT32_I8)
6138 VARAND(R8,-1,I8,-1,I8,-1);
6139 VARAND(R8,-1,I8,0,I8,0);
6140 VARAND(R8,0,I8,0,I8,0);
6141 VARAND(R8,-1,UI8,0,I4,0);
6142 VARAND(R8,0,UI8,0,I4,0);
6144 VARAND(R8,-1,INT,-1,I4,-1);
6145 VARAND(R8,-1,INT,0,I4,0);
6146 VARAND(R8,0,INT,0,I4,0);
6147 VARAND(R8,-1,UINT,0xffffffff,I4,-1);
6148 VARAND(R8,-1,UINT,0,I4,0);
6149 VARAND(R8,0,UINT,0,I4,0);
6150 VARAND(R8,0,BSTR,false_str,I4,0);
6151 VARAND(R8,-1,BSTR,false_str,I4,0);
6152 VARAND(R8,0,BSTR,true_str,I4,0);
6153 VARAND(R8,-1,BSTR,true_str,I4,-1);
6154 VARANDCY(R8,-1,10000,I4,1);
6155 VARANDCY(R8,-1,0,I4,0);
6156 VARANDCY(R8,0,0,I4,0);
6158 VARAND(DATE,-1,DATE,-1,I4,-1);
6159 VARAND(DATE,-1,DATE,0,I4,0);
6160 VARAND(DATE,0,DATE,0,I4,0);
6161 if (HAVE_OLEAUT32_I8)
6163 VARAND(DATE,-1,I8,-1,I8,-1);
6164 VARAND(DATE,-1,I8,0,I8,0);
6165 VARAND(DATE,0,I8,0,I8,0);
6166 VARAND(DATE,-1,UI8,0,I4,0);
6167 VARAND(DATE,0,UI8,0,I4,0);
6169 VARAND(DATE,-1,INT,-1,I4,-1);
6170 VARAND(DATE,-1,INT,0,I4,0);
6171 VARAND(DATE,0,INT,0,I4,0);
6172 VARAND(DATE,-1,UINT,0xffffffff,I4,-1);
6173 VARAND(DATE,-1,UINT,0,I4,0);
6174 VARAND(DATE,0,UINT,0,I4,0);
6175 VARAND(DATE,0,BSTR,false_str,I4,0);
6176 VARAND(DATE,-1,BSTR,false_str,I4,0);
6177 VARAND(DATE,0,BSTR,true_str,I4,0);
6178 VARAND(DATE,-1,BSTR,true_str,I4,-1);
6179 VARANDCY(DATE,-1,10000,I4,1);
6180 VARANDCY(DATE,-1,0,I4,0);
6181 VARANDCY(DATE,0,0,I4,0);
6183 if (HAVE_OLEAUT32_I8)
6185 VARAND(I8,-1,I8,-1,I8,-1);
6186 VARAND(I8,-1,I8,0,I8,0);
6187 VARAND(I8,0,I8,0,I8,0);
6188 VARAND(I8,-1,UI8,0,I8,0);
6189 VARAND(I8,0,UI8,0,I8,0);
6190 VARAND(I8,-1,UINT,0,I8,0);
6191 VARAND(I8,0,UINT,0,I8,0);
6192 VARAND(I8,0,BSTR,false_str,I8,0);
6193 VARAND(I8,-1,BSTR,false_str,I8,0);
6194 VARAND(I8,0,BSTR,true_str,I8,0);
6195 VARAND(I8,-1,BSTR,true_str,I8,-1);
6196 VARANDCY(I8,-1,10000,I8,1);
6197 VARANDCY(I8,-1,0,I8,0);
6198 VARANDCY(I8,0,0,I8,0);
6200 VARAND(UI8,0xffff,UI8,0xffff,I4,0xffff);
6201 VARAND(UI8,0xffff,UI8,0,I4,0);
6202 VARAND(UI8,0,UI8,0,I4,0);
6203 VARAND(UI8,0xffff,INT,-1,I4,65535);
6204 VARAND(UI8,0xffff,INT,0,I4,0);
6205 VARAND(UI8,0,INT,0,I4,0);
6206 VARAND(UI8,0xffff,UINT,0xffff,I4,0xffff);
6207 VARAND(UI8,0xffff,UINT,0,I4,0);
6208 VARAND(UI8,0,UINT,0,I4,0);
6209 VARAND(UI8,0,BSTR,false_str,I4,0);
6210 VARAND(UI8,0xffff,BSTR,false_str,I4,0);
6211 VARAND(UI8,0,BSTR,true_str,I4,0);
6212 VARAND(UI8,0xffff,BSTR,true_str,I4,65535);
6213 VARANDCY(UI8,0xffff,10000,I4,1);
6214 VARANDCY(UI8,0xffff,0,I4,0);
6215 VARANDCY(UI8,0,0,I4,0);
6218 VARAND(INT,-1,INT,-1,I4,-1);
6219 VARAND(INT,-1,INT,0,I4,0);
6220 VARAND(INT,0,INT,0,I4,0);
6221 VARAND(INT,-1,UINT,0xffff,I4,65535);
6222 VARAND(INT,-1,UINT,0,I4,0);
6223 VARAND(INT,0,UINT,0,I4,0);
6224 VARAND(INT,0,BSTR,false_str,I4,0);
6225 VARAND(INT,-1,BSTR,false_str,I4,0);
6226 VARAND(INT,0,BSTR,true_str,I4,0);
6227 VARAND(INT,-1,BSTR,true_str,I4,-1);
6228 VARANDCY(INT,-1,10000,I4,1);
6229 VARANDCY(INT,-1,0,I4,0);
6230 VARANDCY(INT,0,0,I4,0);
6232 VARAND(UINT,0xffff,UINT,0xffff,I4,0xffff);
6233 VARAND(UINT,0xffff,UINT,0,I4,0);
6234 VARAND(UINT,0,UINT,0,I4,0);
6235 VARAND(UINT,0,BSTR,false_str,I4,0);
6236 VARAND(UINT,0xffff,BSTR, false_str,I4,0);
6237 VARAND(UINT,0,BSTR,true_str,I4,0);
6238 VARAND(UINT,0xffff,BSTR,true_str,I4,65535);
6239 VARANDCY(UINT,0xffff,10000,I4,1);
6240 VARANDCY(UINT,0xffff,0,I4,0);
6241 VARANDCY(UINT,0,0,I4,0);
6243 VARAND(BSTR,false_str,BSTR,false_str,BOOL,0);
6244 VARAND(BSTR,true_str,BSTR,false_str,BOOL,VARIANT_FALSE);
6245 VARAND(BSTR,true_str,BSTR,true_str,BOOL,VARIANT_TRUE);
6246 VARANDCY(BSTR,true_str,10000,I4,1);
6247 VARANDCY(BSTR,false_str,10000,I4,0);
6249 SysFreeString(true_str);
6250 SysFreeString(false_str);
6253 static HRESULT (WINAPI *pVarCmp)(LPVARIANT,LPVARIANT,LCID,ULONG);
6255 static void test_cmp( int line, LCID lcid, UINT flags, VARIANT *left, VARIANT *right, HRESULT result )
6259 hres = pVarCmp(left,right,lcid,flags);
6260 ok_(__FILE__,line)(hres == result, "VarCmp(%s,%s): expected 0x%x, got hres=0x%x\n",
6261 variantstr(left), variantstr(right), result, hres );
6263 static void test_cmpex( int line, LCID lcid, VARIANT *left, VARIANT *right,
6264 HRESULT res1, HRESULT res2, HRESULT res3, HRESULT res4 )
6266 test_cmp( line, lcid, 0, left, right, res1 );
6267 V_VT(left) |= VT_RESERVED;
6268 test_cmp( line, lcid, 0, left, right, res2 );
6269 V_VT(left) &= ~VT_RESERVED;
6270 V_VT(right) |= VT_RESERVED;
6271 test_cmp( line, lcid, 0, left, right, res3 );
6272 V_VT(left) |= VT_RESERVED;
6273 test_cmp( line, lcid, 0, left, right, res4 );
6274 ok_(__FILE__,line)(V_VT(left) & V_VT(right) & VT_RESERVED, "VT_RESERVED filtered out\n");
6277 /* ERROR from wingdi.h is interfering here */
6279 #define _VARCMP(vt1,val1,vtfl1,vt2,val2,vtfl2,lcid,flags,result) \
6280 V_##vt1(&left) = val1; V_VT(&left) = VT_##vt1 | vtfl1; \
6281 V_##vt2(&right) = val2; V_VT(&right) = VT_##vt2 | vtfl2; \
6282 test_cmp( __LINE__, lcid, flags, &left, &right, result )
6283 #define VARCMPEX(vt1,val1,vt2,val2,res1,res2,res3,res4) \
6284 V_##vt1(&left) = val1; V_VT(&left) = VT_##vt1; \
6285 V_##vt2(&right) = val2; V_VT(&right) = VT_##vt2; \
6286 test_cmpex( __LINE__, lcid, &left, &right, res1, res2, res3, res4 )
6287 #define VARCMP(vt1,val1,vt2,val2,result) \
6288 VARCMPEX(vt1,val1,vt2,val2,result,result,result,result)
6289 /* The above macros do not work for VT_NULL as NULL gets expanded first */
6290 #define V_NULL_ V_NULL
6291 #define VT_NULL_ VT_NULL
6293 static void test_VarCmp(void)
6295 VARIANT left, right;
6300 static const WCHAR szhuh[] = {'h','u','h','?','\0'};
6301 static const WCHAR sz2cents[] = {'2','c','e','n','t','s','\0'};
6302 static const WCHAR szempty[] = {'\0'};
6303 static const WCHAR sz0[] = {'0','\0'};
6304 static const WCHAR sz1[] = {'1','\0'};
6305 static const WCHAR sz7[] = {'7','\0'};
6306 static const WCHAR sz42[] = {'4','2','\0'};
6307 static const WCHAR sz1neg[] = {'-','1','\0'};
6308 static const WCHAR sz666neg[] = {'-','6','6','6','\0'};
6309 static const WCHAR sz1few[] = {'1','.','0','0','0','0','0','0','0','1','\0'};
6310 BSTR bstrhuh, bstrempty, bstr0, bstr1, bstr7, bstr42, bstr1neg, bstr666neg;
6311 BSTR bstr2cents, bstr1few;
6315 lcid = MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT);
6316 bstrempty = SysAllocString(szempty);
6317 bstrhuh = SysAllocString(szhuh);
6318 bstr2cents = SysAllocString(sz2cents);
6319 bstr0 = SysAllocString(sz0);
6320 bstr1 = SysAllocString(sz1);
6321 bstr7 = SysAllocString(sz7);
6322 bstr42 = SysAllocString(sz42);
6323 bstr1neg = SysAllocString(sz1neg);
6324 bstr666neg = SysAllocString(sz666neg);
6325 bstr1few = SysAllocString(sz1few);
6327 /* Test all possible flag/vt combinations & the resulting vt type */
6328 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
6330 VARTYPE leftvt, rightvt;
6332 for (leftvt = 0; leftvt <= VT_BSTR_BLOB; leftvt++)
6337 for (rightvt = 0; rightvt <= VT_BSTR_BLOB; rightvt++)
6340 HRESULT expect = VARCMP_EQ;
6344 memset(&left, 0, sizeof(left));
6345 memset(&right, 0, sizeof(right));
6346 V_VT(&left) = leftvt | ExtraFlags[i];
6347 if (leftvt == VT_BSTR) {
6348 V_BSTR(&left) = bstr1neg;
6349 if (ExtraFlags[i] & VT_RESERVED)
6354 V_VT(&right) = rightvt | ExtraFlags[i];
6355 if (rightvt == VT_BSTR) {
6356 V_BSTR(&right) = bstr1neg;
6357 if (ExtraFlags[i] & VT_RESERVED)
6363 /* Don't ask me why but native VarCmp cannot handle:
6364 VT_I1, VT_UI2, VT_UI4, VT_UINT and VT_UI8.
6365 VT_INT is only supported as left variant. Go figure.
6366 Tested with DCOM98, Win2k, WinXP */
6367 if (ExtraFlags[i] & VT_ARRAY || ExtraFlags[i] & VT_BYREF ||
6368 !IsValidVariantClearVT(leftvt, ExtraFlags[i] & ~VT_RESERVED) ||
6369 !IsValidVariantClearVT(rightvt, ExtraFlags[i] & ~VT_RESERVED) ||
6370 leftvt == VT_CLSID || rightvt == VT_CLSID ||
6371 leftvt == VT_DISPATCH || rightvt == VT_DISPATCH ||
6372 leftvt == VT_ERROR || rightvt == VT_ERROR ||
6373 leftvt == VT_RECORD || rightvt == VT_RECORD ||
6374 leftvt == VT_UNKNOWN || rightvt == VT_UNKNOWN ||
6375 leftvt == VT_VARIANT || rightvt == VT_VARIANT ||
6376 leftvt == VT_I1 || rightvt == VT_I1 ||
6377 leftvt == VT_UI2 || rightvt == VT_UI2 ||
6378 leftvt == VT_UI4 || rightvt == VT_UI4 ||
6379 leftvt == VT_UI8 || rightvt == VT_UI8 ||
6380 rightvt == VT_INT ||
6381 leftvt == VT_UINT || rightvt == VT_UINT) {
6385 if (leftvt == VT_ERROR && rightvt == VT_ERROR &&
6386 !(ExtraFlags[i] & ~VT_RESERVED)) {
6389 } else if (leftvt == VT_NULL || rightvt == VT_NULL)
6390 expect = VARCMP_NULL;
6391 else if (leftvt == VT_BSTR && rightvt == VT_BSTR)
6393 else if (leftvt == VT_BSTR && rightvt == VT_EMPTY)
6395 else if (leftvt == VT_EMPTY && rightvt == VT_BSTR)
6398 hres = pVarCmp(&left, &right, LOCALE_USER_DEFAULT, 0);
6400 ok(hres == DISP_E_TYPEMISMATCH || hres == DISP_E_BADVARTYPE,
6401 "VarCmp: %d|0x%X, %d|0x%X: Expected failure, got 0x%X\n",
6402 leftvt, ExtraFlags[i], rightvt, ExtraFlags[i], hres);
6405 "VarCmp: %d|0x%X, %d|0x%X: Expected 0x%X, got 0x%X\n",
6406 leftvt, ExtraFlags[i], rightvt, ExtraFlags[i], expect,
6413 /* VARCMP{,EX} run each 4 tests with a permutation of all possible
6414 input variants with (1) and without (0) VT_RESERVED set. The order
6415 of the permutations is (0,0); (1,0); (0,1); (1,1) */
6416 VARCMP(INT,4711,I2,4711,VARCMP_EQ);
6417 VARCMP(INT,4711,I2,-4711,VARCMP_GT);
6418 VARCMP(ERROR,0,ERROR,0,VARCMP_EQ);
6419 VARCMP(ERROR,0,UI1,0,DISP_E_TYPEMISMATCH);
6420 VARCMP(EMPTY,0,EMPTY,0,VARCMP_EQ);
6421 VARCMP(I4,1,R8,1.0,VARCMP_EQ);
6422 VARCMP(EMPTY,19,I2,0,VARCMP_EQ);
6423 ok(V_EMPTY(&left) == 19, "VT_EMPTY modified!\n");
6424 VARCMP(I4,1,UI1,1,VARCMP_EQ);
6425 VARCMP(I2,2,I2,2,VARCMP_EQ);
6426 VARCMP(I2,1,I2,2,VARCMP_LT);
6427 VARCMP(I2,2,I2,1,VARCMP_GT);
6428 VARCMP(I2,2,EMPTY,1,VARCMP_GT);
6429 VARCMP(I2,2,NULL_,1,VARCMP_NULL);
6431 /* BSTR handling, especially in conjunction with VT_RESERVED */
6432 VARCMP(BSTR,bstr0,NULL_,0,VARCMP_NULL);
6433 VARCMP(BSTR,bstr0,BSTR,bstr0,VARCMP_EQ);
6434 VARCMP(BSTR,bstrempty,BSTR,bstr0,VARCMP_LT);
6435 VARCMP(BSTR,bstr7,BSTR,bstr0,VARCMP_GT);
6436 VARCMP(BSTR,bstr7,BSTR,bstr1neg,VARCMP_GT);
6437 VARCMP(BSTR,bstr0,BSTR,NULL,VARCMP_GT);
6438 VARCMP(BSTR,NULL,BSTR,NULL,VARCMP_EQ);
6439 VARCMP(BSTR,bstrempty,BSTR,NULL,VARCMP_EQ);
6440 VARCMP(BSTR,NULL,EMPTY,0,VARCMP_EQ);
6441 VARCMP(EMPTY,0,BSTR,NULL,VARCMP_EQ);
6442 VARCMP(EMPTY,0,BSTR,bstrempty,VARCMP_EQ);
6443 VARCMP(EMPTY,1,BSTR,bstrempty,VARCMP_EQ);
6444 VARCMP(BSTR,bstr0,EMPTY,0,VARCMP_GT);
6445 VARCMP(BSTR,bstr42,EMPTY,0,VARCMP_GT);
6446 VARCMPEX(BSTR,bstrempty,UI1,0,VARCMP_GT,VARCMP_LT,VARCMP_GT,VARCMP_GT);
6447 VARCMPEX(BSTR,bstrempty,I2,-1,VARCMP_GT,VARCMP_LT,VARCMP_GT,VARCMP_GT);
6448 VARCMPEX(I4,0,BSTR,bstrempty,VARCMP_LT,VARCMP_LT,VARCMP_GT,VARCMP_LT);
6449 VARCMPEX(BSTR,NULL,UI1,0,VARCMP_GT,VARCMP_LT,VARCMP_GT,VARCMP_GT);
6450 VARCMPEX(I4,7,BSTR,NULL,VARCMP_LT,VARCMP_LT,VARCMP_GT,VARCMP_LT);
6451 _VARCMP(BSTR,(BSTR)100,0,I2,100,0,lcid,0,VARCMP_GT);
6452 VARCMPEX(BSTR,bstr0,UI1,0,VARCMP_GT,VARCMP_EQ,VARCMP_EQ,VARCMP_GT);
6453 VARCMPEX(I2,0,BSTR,bstr0,VARCMP_LT,VARCMP_EQ,VARCMP_EQ,VARCMP_LT);
6454 VARCMP(BSTR,bstrhuh,I4,I4_MAX,VARCMP_GT);
6455 VARCMP(BSTR,bstr2cents,I4,2,VARCMP_GT);
6456 VARCMPEX(BSTR,bstr2cents,I4,42,VARCMP_GT,VARCMP_LT,VARCMP_GT,VARCMP_GT);
6457 VARCMP(BSTR,bstr2cents,I4,-1,VARCMP_GT);
6458 VARCMPEX(BSTR,bstr2cents,I4,-666,VARCMP_GT,VARCMP_LT,VARCMP_GT,VARCMP_GT);
6459 VARCMPEX(BSTR,bstr0,I2,0,VARCMP_GT,VARCMP_EQ,VARCMP_EQ,VARCMP_GT);
6460 VARCMPEX(BSTR,bstr0,I4,0,VARCMP_GT,VARCMP_EQ,VARCMP_EQ,VARCMP_GT);
6461 VARCMPEX(BSTR,bstr0,I4,-666,VARCMP_GT,VARCMP_LT,VARCMP_GT,VARCMP_GT);
6462 VARCMP(BSTR,bstr1,I4,0,VARCMP_GT);
6463 VARCMPEX(BSTR,bstr1,I4,1,VARCMP_GT,VARCMP_EQ,VARCMP_EQ,VARCMP_GT);
6464 VARCMPEX(BSTR,bstr1,I4,I4_MAX,VARCMP_GT,VARCMP_LT,VARCMP_LT,VARCMP_GT);
6465 VARCMPEX(BSTR,bstr1,I4,-1,VARCMP_GT,VARCMP_LT,VARCMP_GT,VARCMP_GT);
6466 VARCMP(BSTR,bstr7,I4,1,VARCMP_GT);
6467 VARCMPEX(BSTR,bstr7,I4,7,VARCMP_GT,VARCMP_EQ,VARCMP_EQ,VARCMP_GT);
6468 VARCMPEX(BSTR,bstr7,I4,42,VARCMP_GT,VARCMP_GT,VARCMP_LT,VARCMP_GT);
6469 VARCMPEX(BSTR,bstr42,I4,7,VARCMP_GT,VARCMP_LT,VARCMP_GT,VARCMP_GT);
6470 VARCMPEX(BSTR,bstr42,I4,42,VARCMP_GT,VARCMP_EQ,VARCMP_EQ,VARCMP_GT);
6471 VARCMPEX(BSTR,bstr42,I4,I4_MAX,VARCMP_GT,VARCMP_GT,VARCMP_LT,VARCMP_GT);
6472 VARCMPEX(BSTR,bstr1neg,I4,1,VARCMP_GT,VARCMP_GT,VARCMP_LT,VARCMP_LT);
6473 VARCMPEX(BSTR,bstr1neg,I4,42,VARCMP_GT,VARCMP_LT,VARCMP_LT,VARCMP_LT);
6474 VARCMPEX(BSTR,bstr1neg,I4,-1,VARCMP_GT,VARCMP_EQ,VARCMP_EQ,VARCMP_LT);
6475 VARCMPEX(BSTR,bstr1neg,I4,-666,VARCMP_GT,VARCMP_LT,VARCMP_GT,VARCMP_LT);
6476 VARCMPEX(BSTR,bstr666neg,I4,1,VARCMP_GT,VARCMP_GT,VARCMP_LT,VARCMP_LT);
6477 VARCMPEX(BSTR,bstr666neg,I4,7,VARCMP_GT,VARCMP_LT,VARCMP_LT,VARCMP_LT);
6478 VARCMPEX(BSTR,bstr666neg,I4,42,VARCMP_GT,VARCMP_GT,VARCMP_LT,VARCMP_LT);
6479 VARCMPEX(BSTR,bstr666neg,I4,I4_MAX,VARCMP_GT,VARCMP_GT,VARCMP_LT,VARCMP_LT);
6480 VARCMPEX(BSTR,bstr666neg,I4,-1,VARCMP_GT,VARCMP_GT,VARCMP_LT,VARCMP_LT);
6481 VARCMPEX(BSTR,bstr666neg,I4,-666,VARCMP_GT,VARCMP_EQ,VARCMP_EQ,VARCMP_LT);
6482 VARCMPEX(BSTR,bstr7,R8,7.0,VARCMP_GT,VARCMP_EQ,VARCMP_EQ,VARCMP_GT);
6483 VARCMPEX(R8,3.141592,BSTR,NULL,VARCMP_LT,VARCMP_LT,VARCMP_GT,VARCMP_LT);
6484 VARCMP(BSTR,bstr7,BSTR,bstr7,VARCMP_EQ);
6485 VARCMP(BSTR,bstr7,BSTR,bstr42,VARCMP_GT);
6486 VARCMP(BSTR,bstr42,BSTR,bstr7,VARCMP_LT);
6488 /* DECIMAL handling */
6489 setdec(&dec,0,0,0,0);
6490 VARCMPEX(DECIMAL,dec,BSTR,bstr0,VARCMP_LT,VARCMP_EQ,VARCMP_EQ,VARCMP_LT);
6491 setdec64(&dec,0,0,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF); /* max DECIMAL */
6492 VARCMP(DECIMAL,dec,R8,R8_MAX,VARCMP_LT); /* R8 has bigger range */
6493 VARCMP(DECIMAL,dec,DATE,R8_MAX,VARCMP_LT); /* DATE has bigger range */
6494 setdec64(&dec,0,0x80,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF);
6495 VARCMP(DECIMAL,dec,R8,-R8_MAX,VARCMP_GT);
6496 setdec64(&dec,20,0,0x5,0x6BC75E2D,0x63100001); /* 1+1e-20 */
6497 VARCMP(DECIMAL,dec,R8,1,VARCMP_GT); /* DECIMAL has higher precision */
6499 /* Show that DATE is handled just as a R8 */
6500 VARCMP(DATE,DATE_MAX,DATE,DATE_MAX+1,VARCMP_LT);
6501 VARCMP(DATE,DATE_MIN,DATE,DATE_MIN-1,VARCMP_GT);
6502 VARCMP(DATE,R8_MIN,R8,R8_MIN,VARCMP_EQ);
6503 VARCMP(DATE,1,DATE,1+1e-15,VARCMP_LT); /* 1e-15 == 8.64e-11 seconds */
6504 VARCMP(DATE,25570.0,DATE,25570.0,VARCMP_EQ);
6505 VARCMP(DATE,25570.0,DATE,25571.0,VARCMP_LT);
6506 VARCMP(DATE,25571.0,DATE,25570.0,VARCMP_GT);
6507 VARCMP(DATE,25570.0,EMPTY,0,VARCMP_GT);
6508 VARCMP(DATE,25570.0,NULL_,0,VARCMP_NULL);
6510 /* R4 precision handling */
6511 VARCMP(R4,1,R8,1+1e-8,VARCMP_EQ);
6512 VARCMP(R8,1+1e-8,R4,1,VARCMP_EQ);
6513 VARCMP(R8,1+1e-8,R8,1,VARCMP_GT);
6514 VARCMP(R8,R4_MAX*1.1,R4,R4_MAX,VARCMP_GT);
6515 VARCMP(R4,R4_MAX,R8,R8_MAX,VARCMP_LT);
6516 VARCMP(R4,1,DATE,1+1e-8,VARCMP_EQ);
6517 VARCMP(R4,1,BSTR,bstr1few,VARCMP_LT); /* bstr1few == 1+1e-8 */
6518 setdec(&dec,8,0,0,0x5F5E101); /* 1+1e-8 */
6519 VARCMP(R4,1,DECIMAL,dec,VARCMP_LT);
6521 SysFreeString(bstrhuh);
6522 SysFreeString(bstrempty);
6523 SysFreeString(bstr0);
6524 SysFreeString(bstr1);
6525 SysFreeString(bstr7);
6526 SysFreeString(bstr42);
6527 SysFreeString(bstr1neg);
6528 SysFreeString(bstr666neg);
6529 SysFreeString(bstr2cents);
6530 SysFreeString(bstr1few);
6533 static HRESULT (WINAPI *pVarPow)(LPVARIANT,LPVARIANT,LPVARIANT);
6535 #define VARPOW(vt1,val1,vt2,val2,rvt,rval) \
6536 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
6537 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
6538 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
6539 test_var_call2( __LINE__, pVarPow, &left, &right, &exp )
6541 /* Skip any type that is not defined or produces an error for every case */
6542 #define SKIPTESTPOW(a) \
6543 if (a == VT_ERROR || a == VT_VARIANT || \
6544 a == VT_DISPATCH || a == VT_UNKNOWN || \
6545 a == VT_RECORD || a > VT_UINT || \
6546 a == 15 /*not defined*/) \
6549 static void test_VarPow(void)
6551 static const WCHAR str2[] = { '2','\0' };
6552 static const WCHAR str3[] = { '3','\0' };
6553 VARIANT left, right, exp, result, cy, dec;
6554 BSTR num2_str, num3_str;
6560 num2_str = SysAllocString(str2);
6561 num3_str = SysAllocString(str3);
6563 /* Test all possible flag/vt combinations & the resulting vt type */
6564 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
6566 VARTYPE leftvt, rightvt, resvt;
6568 for (leftvt = 0; leftvt <= VT_BSTR_BLOB; leftvt++)
6570 SKIPTESTPOW(leftvt);
6572 for (rightvt = 0; rightvt <= VT_BSTR_BLOB; rightvt++)
6575 SKIPTESTPOW(rightvt);
6577 /* Native crashes with VT_BYREF */
6578 if (ExtraFlags[i] == VT_BYREF)
6581 memset(&left, 0, sizeof(left));
6582 memset(&right, 0, sizeof(right));
6583 V_VT(&left) = leftvt | ExtraFlags[i];
6584 V_VT(&right) = rightvt | ExtraFlags[i];
6585 V_VT(&result) = VT_EMPTY;
6588 if (leftvt == VT_BSTR)
6589 V_BSTR(&left) = num2_str;
6590 if (rightvt == VT_BSTR)
6591 V_BSTR(&right) = num2_str;
6593 /* Native VarPow always returns an error when using extra flags */
6594 if (ExtraFlags[i] != 0)
6597 /* Determine return type */
6598 else if ((leftvt == VT_NULL || rightvt == VT_NULL) &&
6599 ((leftvt != VT_I8 && leftvt != VT_UI8 &&
6600 rightvt != VT_I8 && rightvt != VT_UI8) || HAVE_OLEAUT32_I8))
6602 else if ((leftvt == VT_EMPTY || leftvt == VT_I2 ||
6603 leftvt == VT_I4 || leftvt == VT_R4 ||
6604 leftvt == VT_R8 || leftvt == VT_CY ||
6605 leftvt == VT_DATE || leftvt == VT_BSTR ||
6606 leftvt == VT_BOOL || leftvt == VT_DECIMAL ||
6607 (leftvt >= VT_I1 && leftvt <= VT_UI4) ||
6608 (HAVE_OLEAUT32_I8 && (leftvt == VT_I8 || leftvt == VT_UI8)) ||
6609 leftvt == VT_INT || leftvt == VT_UINT) &&
6610 (rightvt == VT_EMPTY || rightvt == VT_I2 ||
6611 rightvt == VT_I4 || rightvt == VT_R4 ||
6612 rightvt == VT_R8 || rightvt == VT_CY ||
6613 rightvt == VT_DATE || rightvt == VT_BSTR ||
6614 rightvt == VT_BOOL || rightvt == VT_DECIMAL ||
6615 (rightvt >= VT_I1 && rightvt <= VT_UI4) ||
6616 (HAVE_OLEAUT32_I8 && (rightvt == VT_I8 || rightvt == VT_UI8)) ||
6617 rightvt == VT_INT || rightvt == VT_UINT))
6622 hres = pVarPow(&left, &right, &result);
6624 /* Check expected HRESULT and if result variant type is correct */
6626 ok (hres == DISP_E_BADVARTYPE || hres == DISP_E_TYPEMISMATCH,
6627 "VarPow: %s|0x%X, %s|0x%X: got vt %s hr 0x%X\n",
6628 vtstr(leftvt), ExtraFlags[i], vtstr(rightvt), ExtraFlags[i],
6629 vtstr(V_VT(&result)), hres);
6631 ok (hres == S_OK && resvt == V_VT(&result),
6632 "VarPow: %s|0x%X, %s|0x%X: expected vt %s hr 0x%X, got vt %s hr 0x%X\n",
6633 vtstr(leftvt), ExtraFlags[i], vtstr(rightvt), ExtraFlags[i], vtstr(resvt),
6634 S_OK, vtstr(V_VT(&result)), hres);
6639 /* Check return values for valid variant type combinations */
6640 VARPOW(EMPTY,0,EMPTY,0,R8,1.0);
6641 VARPOW(EMPTY,0,NULL,0,NULL,0);
6642 VARPOW(EMPTY,0,I2,3,R8,0.0);
6643 VARPOW(EMPTY,0,I4,3,R8,0.0);
6644 VARPOW(EMPTY,0,R4,3.0f,R8,0.0);
6645 VARPOW(EMPTY,0,R8,3.0,R8,0.0);
6646 VARPOW(EMPTY,0,DATE,3,R8,0.0);
6647 VARPOW(EMPTY,0,BSTR,num3_str,R8,0.0);
6648 VARPOW(EMPTY,0,BOOL,VARIANT_FALSE,R8,1.0);
6649 VARPOW(EMPTY,0,I1,3,R8,0.0);
6650 VARPOW(EMPTY,0,UI1,3,R8,0.0);
6651 VARPOW(EMPTY,0,UI2,3,R8,0.0);
6652 VARPOW(EMPTY,0,UI4,3,R8,0.0);
6653 if (HAVE_OLEAUT32_I8)
6655 VARPOW(EMPTY,0,I8,3,R8,0.0);
6656 VARPOW(EMPTY,0,UI8,3,R8,0.0);
6658 VARPOW(EMPTY,0,INT,3,R8,0.0);
6659 VARPOW(EMPTY,0,UINT,3,R8,0.0);
6660 VARPOW(NULL,0,EMPTY,0,NULL,0);
6661 VARPOW(NULL,0,NULL,0,NULL,0);
6662 VARPOW(NULL,0,I2,3,NULL,0);
6663 VARPOW(NULL,0,I4,3,NULL,0);
6664 VARPOW(NULL,0,R4,3.0f,NULL,0);
6665 VARPOW(NULL,0,R8,3.0,NULL,0);
6666 VARPOW(NULL,0,DATE,3,NULL,0);
6667 VARPOW(NULL,0,BSTR,num3_str,NULL,0);
6668 VARPOW(NULL,0,BOOL,VARIANT_TRUE,NULL,0);
6669 VARPOW(NULL,0,I1,3,NULL,0);
6670 VARPOW(NULL,0,UI1,3,NULL,0);
6671 VARPOW(NULL,0,UI2,3,NULL,0);
6672 VARPOW(NULL,0,UI4,3,NULL,0);
6673 if (HAVE_OLEAUT32_I8)
6675 VARPOW(NULL,0,I8,3,NULL,0);
6676 VARPOW(NULL,0,UI8,3,NULL,0);
6678 VARPOW(NULL,0,INT,3,NULL,0);
6679 VARPOW(NULL,0,UINT,3,NULL,0);
6680 VARPOW(I2,2,EMPTY,0,R8,1.0);
6681 VARPOW(I2,2,NULL,0,NULL,0);
6682 VARPOW(I2,2,I2,3,R8,8.0);
6683 VARPOW(I2,2,I4,3,R8,8.0);
6684 VARPOW(I2,2,R4,3.0f,R8,8.0);
6685 VARPOW(I2,2,R8,3.0,R8,8.0);
6686 VARPOW(I2,2,DATE,3,R8,8.0);
6687 VARPOW(I2,2,BSTR,num3_str,R8,8.0);
6688 VARPOW(I2,2,BOOL,VARIANT_FALSE,R8,1.0);
6689 VARPOW(I2,2,I1,3,R8,8.0);
6690 VARPOW(I2,2,UI1,3,R8,8.0);
6691 VARPOW(I2,2,UI2,3,R8,8.0);
6692 VARPOW(I2,2,UI4,3,R8,8.0);
6693 if (HAVE_OLEAUT32_I8)
6695 VARPOW(I2,2,I8,3,R8,8.0);
6696 VARPOW(I2,2,UI8,3,R8,8.0);
6698 VARPOW(I2,2,INT,3,R8,8.0);
6699 VARPOW(I2,2,UINT,3,R8,8.0);
6700 VARPOW(I4,2,EMPTY,0,R8,1.0);
6701 VARPOW(I4,2,NULL,0,NULL,0);
6702 VARPOW(I4,2,I2,3,R8,8.0);
6703 VARPOW(I4,2,I4,3,R8,8.0);
6704 VARPOW(I4,2,R4,3.0f,R8,8.0);
6705 VARPOW(I4,2,R8,3.0,R8,8.0);
6706 VARPOW(I4,2,DATE,3,R8,8.0);
6707 VARPOW(I4,2,BSTR,num3_str,R8,8.0);
6708 VARPOW(I4,2,BOOL,VARIANT_FALSE,R8,1.0);
6709 VARPOW(I4,2,I1,3,R8,8.0);
6710 VARPOW(I4,2,UI1,3,R8,8.0);
6711 VARPOW(I4,2,UI2,3,R8,8.0);
6712 VARPOW(I4,2,UI4,3,R8,8.0);
6713 if (HAVE_OLEAUT32_I8)
6715 VARPOW(I4,2,I8,3,R8,8.0);
6716 VARPOW(I4,2,UI8,3,R8,8.0);
6718 VARPOW(I4,2,INT,3,R8,8.0);
6719 VARPOW(I4,2,UINT,3,R8,8.0);
6720 VARPOW(R4,2,EMPTY,0,R8,1.0);
6721 VARPOW(R4,2,NULL,0,NULL,0);
6722 VARPOW(R4,2,I2,3,R8,8.0);
6723 VARPOW(R4,2,I4,3,R8,8.0);
6724 VARPOW(R4,2,R4,3.0f,R8,8.0);
6725 VARPOW(R4,2,R8,3.0,R8,8.0);
6726 VARPOW(R4,2,DATE,3,R8,8.0);
6727 VARPOW(R4,2,BSTR,num3_str,R8,8.0);
6728 VARPOW(R4,2,BOOL,VARIANT_FALSE,R8,1.0);
6729 VARPOW(R4,2,I1,3,R8,8.0);
6730 VARPOW(R4,2,UI1,3,R8,8.0);
6731 VARPOW(R4,2,UI2,3,R8,8.0);
6732 VARPOW(R4,2,UI4,3,R8,8.0);
6733 if (HAVE_OLEAUT32_I8)
6735 VARPOW(R4,2,I8,3,R8,8.0);
6736 VARPOW(R4,2,UI8,3,R8,8.0);
6738 VARPOW(R4,2,INT,3,R8,8.0);
6739 VARPOW(R4,2,UINT,3,R8,8.0);
6740 VARPOW(R8,2,EMPTY,0,R8,1.0);
6741 VARPOW(R8,2,NULL,0,NULL,0);
6742 VARPOW(R8,2,I2,3,R8,8.0);
6743 VARPOW(R8,2,I4,3,R8,8.0);
6744 VARPOW(R8,2,R4,3.0f,R8,8.0);
6745 VARPOW(R8,2,R8,3.0,R8,8.0);
6746 VARPOW(R8,2,DATE,3,R8,8.0);
6747 VARPOW(R8,2,BSTR,num3_str,R8,8.0);
6748 VARPOW(R8,2,BOOL,VARIANT_FALSE,R8,1.0);
6749 VARPOW(R8,2,I1,3,R8,8.0);
6750 VARPOW(R8,2,UI1,3,R8,8.0);
6751 VARPOW(R8,2,UI2,3,R8,8.0);
6752 VARPOW(R8,2,UI4,3,R8,8.0);
6753 if (HAVE_OLEAUT32_I8)
6755 VARPOW(R8,2,I8,3,R8,8.0);
6756 VARPOW(R8,2,UI8,3,R8,8.0);
6758 VARPOW(R8,2,INT,3,R8,8.0);
6759 VARPOW(R8,2,UINT,3,R8,8.0);
6760 VARPOW(DATE,2,EMPTY,0,R8,1.0);
6761 VARPOW(DATE,2,NULL,0,NULL,0);
6762 VARPOW(DATE,2,I2,3,R8,8.0);
6763 VARPOW(DATE,2,I4,3,R8,8.0);
6764 VARPOW(DATE,2,R4,3.0f,R8,8.0);
6765 VARPOW(DATE,2,R8,3.0,R8,8.0);
6766 VARPOW(DATE,2,DATE,3,R8,8.0);
6767 VARPOW(DATE,2,BSTR,num3_str,R8,8.0);
6768 VARPOW(DATE,2,BOOL,VARIANT_FALSE,R8,1.0);
6769 VARPOW(DATE,2,I1,3,R8,8.0);
6770 VARPOW(DATE,2,UI1,3,R8,8.0);
6771 VARPOW(DATE,2,UI2,3,R8,8.0);
6772 VARPOW(DATE,2,UI4,3,R8,8.0);
6773 if (HAVE_OLEAUT32_I8)
6775 VARPOW(DATE,2,I8,3,R8,8.0);
6776 VARPOW(DATE,2,UI8,3,R8,8.0);
6778 VARPOW(DATE,2,INT,3,R8,8.0);
6779 VARPOW(DATE,2,UINT,3,R8,8.0);
6780 VARPOW(BSTR,num2_str,EMPTY,0,R8,1.0);
6781 VARPOW(BSTR,num2_str,NULL,0,NULL,0);
6782 VARPOW(BSTR,num2_str,I2,3,R8,8.0);
6783 VARPOW(BSTR,num2_str,I4,3,R8,8.0);
6784 VARPOW(BSTR,num2_str,R4,3.0f,R8,8.0);
6785 VARPOW(BSTR,num2_str,R8,3.0,R8,8.0);
6786 VARPOW(BSTR,num2_str,DATE,3,R8,8.0);
6787 VARPOW(BSTR,num2_str,BSTR,num3_str,R8,8.0);
6788 VARPOW(BSTR,num2_str,BOOL,VARIANT_FALSE,R8,1.0);
6789 VARPOW(BSTR,num2_str,I1,3,R8,8.0);
6790 VARPOW(BSTR,num2_str,UI1,3,R8,8.0);
6791 VARPOW(BSTR,num2_str,UI2,3,R8,8.0);
6792 VARPOW(BSTR,num2_str,UI4,3,R8,8.0);
6793 if (HAVE_OLEAUT32_I8)
6795 VARPOW(BSTR,num2_str,I8,3,R8,8.0);
6796 VARPOW(BSTR,num2_str,UI8,3,R8,8.0);
6798 VARPOW(BSTR,num2_str,INT,3,R8,8.0);
6799 VARPOW(BSTR,num2_str,UINT,3,R8,8.0);
6800 VARPOW(BOOL,VARIANT_TRUE,EMPTY,0,R8,1.0);
6801 VARPOW(BOOL,VARIANT_TRUE,NULL,0,NULL,0);
6802 VARPOW(BOOL,VARIANT_TRUE,I2,3,R8,-1.0);
6803 VARPOW(BOOL,VARIANT_TRUE,I4,3,R8,-1.0);
6804 VARPOW(BOOL,VARIANT_TRUE,R4,3.0f,R8,-1.0);
6805 VARPOW(BOOL,VARIANT_TRUE,R8,3.0,R8,-1.0);
6806 VARPOW(BOOL,VARIANT_TRUE,DATE,3,R8,-1.0);
6807 VARPOW(BOOL,VARIANT_TRUE,BSTR,num3_str,R8,-1.0);
6808 VARPOW(BOOL,VARIANT_TRUE,BOOL,VARIANT_TRUE,R8,-1.0);
6809 VARPOW(BOOL,VARIANT_TRUE,I1,3,R8,-1.0);
6810 VARPOW(BOOL,VARIANT_TRUE,UI1,3,R8,-1.0);
6811 VARPOW(BOOL,VARIANT_TRUE,UI2,3,R8,-1.0);
6812 VARPOW(BOOL,VARIANT_TRUE,UI4,3,R8,-1.0);
6813 if (HAVE_OLEAUT32_I8)
6815 VARPOW(BOOL,VARIANT_TRUE,I8,3,R8,-1.0);
6816 VARPOW(BOOL,VARIANT_TRUE,UI8,3,R8,-1.0);
6818 VARPOW(BOOL,VARIANT_TRUE,INT,3,R8,-1.0);
6819 VARPOW(BOOL,VARIANT_TRUE,UINT,3,R8,-1.0);
6820 VARPOW(I1,2,EMPTY,0,R8,1.0);
6821 VARPOW(I1,2,NULL,0,NULL,0);
6822 VARPOW(I1,2,I2,3,R8,8.0);
6823 VARPOW(I1,2,I4,3,R8,8.0);
6824 VARPOW(I1,2,R4,3.0f,R8,8.0);
6825 VARPOW(I1,2,R8,3.0,R8,8.0);
6826 VARPOW(I1,2,DATE,3,R8,8.0);
6827 VARPOW(I1,2,BSTR,num3_str,R8,8.0);
6828 VARPOW(I1,2,BOOL,VARIANT_FALSE,R8,1.0);
6829 VARPOW(I1,2,I1,3,R8,8.0);
6830 VARPOW(I1,2,UI1,3,R8,8.0);
6831 VARPOW(I1,2,UI2,3,R8,8.0);
6832 VARPOW(I1,2,UI4,3,R8,8.0);
6833 if (HAVE_OLEAUT32_I8)
6835 VARPOW(I1,2,I8,3,R8,8.0);
6836 VARPOW(I1,2,UI8,3,R8,8.0);
6838 VARPOW(I1,2,INT,3,R8,8.0);
6839 VARPOW(I1,2,UINT,3,R8,8.0);
6840 VARPOW(UI1,2,EMPTY,0,R8,1.0);
6841 VARPOW(UI1,2,NULL,0,NULL,0);
6842 VARPOW(UI1,2,I2,3,R8,8.0);
6843 VARPOW(UI1,2,I4,3,R8,8.0);
6844 VARPOW(UI1,2,R4,3.0f,R8,8.0);
6845 VARPOW(UI1,2,R8,3.0,R8,8.0);
6846 VARPOW(UI1,2,DATE,3,R8,8.0);
6847 VARPOW(UI1,2,BSTR,num3_str,R8,8.0);
6848 VARPOW(UI1,2,BOOL,VARIANT_FALSE,R8,1.0);
6849 VARPOW(UI1,2,I1,3,R8,8.0);
6850 VARPOW(UI1,2,UI1,3,R8,8.0);
6851 VARPOW(UI1,2,UI2,3,R8,8.0);
6852 VARPOW(UI1,2,UI4,3,R8,8.0);
6853 if (HAVE_OLEAUT32_I8)
6855 VARPOW(UI1,2,I8,3,R8,8.0);
6856 VARPOW(UI1,2,UI8,3,R8,8.0);
6858 VARPOW(UI1,2,INT,3,R8,8.0);
6859 VARPOW(UI1,2,UINT,3,R8,8.0);
6860 VARPOW(UI2,2,EMPTY,0,R8,1.0);
6861 VARPOW(UI2,2,NULL,0,NULL,0);
6862 VARPOW(UI2,2,I2,3,R8,8.0);
6863 VARPOW(UI2,2,I4,3,R8,8.0);
6864 VARPOW(UI2,2,R4,3.0f,R8,8.0);
6865 VARPOW(UI2,2,R8,3.0,R8,8.0);
6866 VARPOW(UI2,2,DATE,3,R8,8.0);
6867 VARPOW(UI2,2,BSTR,num3_str,R8,8.0);
6868 VARPOW(UI2,2,BOOL,VARIANT_FALSE,R8,1.0);
6869 VARPOW(UI2,2,I1,3,R8,8.0);
6870 VARPOW(UI2,2,UI1,3,R8,8.0);
6871 VARPOW(UI2,2,UI2,3,R8,8.0);
6872 VARPOW(UI2,2,UI4,3,R8,8.0);
6873 if (HAVE_OLEAUT32_I8)
6875 VARPOW(UI2,2,I8,3,R8,8.0);
6876 VARPOW(UI2,2,UI8,3,R8,8.0);
6878 VARPOW(UI2,2,INT,3,R8,8.0);
6879 VARPOW(UI2,2,UINT,3,R8,8.0);
6880 VARPOW(UI4,2,EMPTY,0,R8,1.0);
6881 VARPOW(UI4,2,NULL,0,NULL,0);
6882 VARPOW(UI4,2,I2,3,R8,8.0);
6883 VARPOW(UI4,2,I4,3,R8,8.0);
6884 VARPOW(UI4,2,R4,3.0f,R8,8.0);
6885 VARPOW(UI4,2,R8,3.0,R8,8.0);
6886 VARPOW(UI4,2,DATE,3,R8,8.0);
6887 VARPOW(UI4,2,BSTR,num3_str,R8,8.0);
6888 VARPOW(UI4,2,BOOL,VARIANT_FALSE,R8,1.0);
6889 VARPOW(UI4,2,I1,3,R8,8.0);
6890 VARPOW(UI4,2,UI1,3,R8,8.0);
6891 VARPOW(UI4,2,UI2,3,R8,8.0);
6892 VARPOW(UI4,2,UI4,3,R8,8.0);
6893 if (HAVE_OLEAUT32_I8)
6895 VARPOW(UI4,2,I8,3,R8,8.0);
6896 VARPOW(UI4,2,UI8,3,R8,8.0);
6898 VARPOW(UI4,2,INT,3,R8,8.0);
6899 VARPOW(UI4,2,UINT,3,R8,8.0);
6900 if (HAVE_OLEAUT32_I8)
6902 VARPOW(I8,2,EMPTY,0,R8,1.0);
6903 VARPOW(I8,2,NULL,0,NULL,0);
6904 VARPOW(I8,2,I2,3,R8,8.0);
6905 VARPOW(I8,2,I4,3,R8,8.0);
6906 VARPOW(I8,2,R4,3.0f,R8,8.0);
6907 VARPOW(I8,2,R8,3.0,R8,8.0);
6908 VARPOW(I8,2,DATE,3,R8,8.0);
6909 VARPOW(I8,2,BSTR,num3_str,R8,8.0);
6910 VARPOW(I8,2,BOOL,VARIANT_FALSE,R8,1.0);
6911 VARPOW(I8,2,I1,3,R8,8.0);
6912 VARPOW(I8,2,UI1,3,R8,8.0);
6913 VARPOW(I8,2,UI2,3,R8,8.0);
6914 VARPOW(I8,2,UI4,3,R8,8.0);
6915 VARPOW(I8,2,I8,3,R8,8.0);
6916 VARPOW(I8,2,UI8,3,R8,8.0);
6917 VARPOW(I8,2,INT,3,R8,8.0);
6918 VARPOW(I8,2,UINT,3,R8,8.0);
6919 VARPOW(UI8,2,EMPTY,0,R8,1.0);
6920 VARPOW(UI8,2,NULL,0,NULL,0);
6921 VARPOW(UI8,2,I2,3,R8,8.0);
6922 VARPOW(UI8,2,I4,3,R8,8.0);
6923 VARPOW(UI8,2,R4,3.0f,R8,8.0);
6924 VARPOW(UI8,2,R8,3.0,R8,8.0);
6925 VARPOW(UI8,2,DATE,3,R8,8.0);
6926 VARPOW(UI8,2,BSTR,num3_str,R8,8.0);
6927 VARPOW(UI8,2,I1,3,R8,8.0);
6928 VARPOW(UI8,2,UI1,3,R8,8.0);
6929 VARPOW(UI8,2,UI2,3,R8,8.0);
6930 VARPOW(UI8,2,UI4,3,R8,8.0);
6931 VARPOW(UI8,2,I8,3,R8,8.0);
6932 VARPOW(UI8,2,UI8,3,R8,8.0);
6933 VARPOW(UI8,2,INT,3,R8,8.0);
6934 VARPOW(UI8,2,UINT,3,R8,8.0);
6936 VARPOW(INT,2,EMPTY,0,R8,1.0);
6937 VARPOW(INT,2,NULL,0,NULL,0);
6938 VARPOW(INT,2,I2,3,R8,8.0);
6939 VARPOW(INT,2,I4,3,R8,8.0);
6940 VARPOW(INT,2,R4,3.0f,R8,8.0);
6941 VARPOW(INT,2,R8,3.0,R8,8.0);
6942 VARPOW(INT,2,DATE,3,R8,8.0);
6943 VARPOW(INT,2,BSTR,num3_str,R8,8.0);
6944 VARPOW(INT,2,BOOL,VARIANT_FALSE,R8,1.0);
6945 VARPOW(INT,2,I1,3,R8,8.0);
6946 VARPOW(INT,2,UI1,3,R8,8.0);
6947 VARPOW(INT,2,UI2,3,R8,8.0);
6948 VARPOW(INT,2,UI4,3,R8,8.0);
6949 if (HAVE_OLEAUT32_I8)
6951 VARPOW(INT,2,I8,3,R8,8.0);
6952 VARPOW(INT,2,UI8,3,R8,8.0);
6954 VARPOW(INT,2,INT,3,R8,8.0);
6955 VARPOW(INT,2,UINT,3,R8,8.0);
6956 VARPOW(UINT,2,EMPTY,0,R8,1.0);
6957 VARPOW(UINT,2,NULL,0,NULL,0);
6958 VARPOW(UINT,2,I2,3,R8,8.0);
6959 VARPOW(UINT,2,I4,3,R8,8.0);
6960 VARPOW(UINT,2,R4,3.0f,R8,8.0);
6961 VARPOW(UINT,2,R8,3.0,R8,8.0);
6962 VARPOW(UINT,2,DATE,3,R8,8.0);
6963 VARPOW(UINT,2,BSTR,num3_str,R8,8.0);
6964 VARPOW(UINT,2,BOOL,VARIANT_FALSE,R8,1.0);
6965 VARPOW(UINT,2,I1,3,R8,8.0);
6966 VARPOW(UINT,2,UI1,3,R8,8.0);
6967 VARPOW(UINT,2,UI2,3,R8,8.0);
6968 VARPOW(UINT,2,UI4,3,R8,8.0);
6969 if (HAVE_OLEAUT32_I8)
6971 VARPOW(UINT,2,I8,3,R8,8.0);
6972 VARPOW(UINT,2,UI8,3,R8,8.0);
6974 VARPOW(UINT,2,INT,3,R8,8.0);
6975 VARPOW(UINT,2,UINT,3,R8,8.0);
6977 /* Manually test some VT_CY, VT_DECIMAL variants */
6979 hres = VarCyFromI4(2, &V_CY(&cy));
6980 ok(hres == S_OK, "VarCyFromI4 failed!\n");
6981 V_VT(&dec) = VT_DECIMAL;
6982 hres = VarDecFromR8(2.0, &V_DECIMAL(&dec));
6983 ok(hres == S_OK, "VarDecFromR4 failed!\n");
6984 memset(&left, 0, sizeof(left));
6985 memset(&right, 0, sizeof(right));
6986 V_VT(&left) = VT_I4;
6988 V_VT(&right) = VT_I8;
6991 hres = pVarPow(&cy, &cy, &result);
6992 ok(hres == S_OK && V_VT(&result) == VT_R8,
6993 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
6994 S_OK, hres, vtstr(V_VT(&result)));
6995 ok(hres == S_OK && EQ_DOUBLE(V_R8(&result), 4.0),
6996 "VARPOW: CY value %f, expected %f\n", V_R8(&result), 4.0);
6998 hres = pVarPow(&cy, &right, &result);
7001 ok(hres == S_OK && V_VT(&result) == VT_R8,
7002 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
7003 S_OK, hres, vtstr(V_VT(&result)));
7004 ok(hres == S_OK && EQ_DOUBLE(V_R8(&result), 4.0),
7005 "VARPOW: CY value %f, expected %f\n", V_R8(&result), 4.0);
7009 ok(hres == DISP_E_BADVARTYPE && V_VT(&result) == VT_EMPTY,
7010 "VARPOW: expected coerced hres 0x%X type VT_EMPTY, got hres 0x%X type %s!\n",
7011 DISP_E_BADVARTYPE, hres, vtstr(V_VT(&result)));
7014 hres = pVarPow(&left, &cy, &result);
7015 ok(hres == S_OK && V_VT(&result) == VT_R8,
7016 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
7017 S_OK, hres, vtstr(V_VT(&result)));
7018 ok(hres == S_OK && EQ_DOUBLE(V_R8(&result), 10000.0),
7019 "VARPOW: CY value %f, expected %f\n", V_R8(&result), 10000.0);
7021 hres = pVarPow(&left, &dec, &result);
7022 ok(hres == S_OK && V_VT(&result) == VT_R8,
7023 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
7024 S_OK, hres, vtstr(V_VT(&result)));
7025 ok(hres == S_OK && EQ_DOUBLE(V_R8(&result),10000.0),
7026 "VARPOW: DECIMAL value %f, expected %f\n", V_R8(&result), 10000.0);
7028 hres = pVarPow(&dec, &dec, &result);
7029 ok(hres == S_OK && V_VT(&result) == VT_R8,
7030 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
7031 S_OK, hres, vtstr(V_VT(&result)));
7032 ok(hres == S_OK && EQ_DOUBLE(V_R8(&result), 4.0),
7033 "VARPOW: DECIMAL value %f, expected %f\n", V_R8(&result), 4.0);
7035 hres = pVarPow(&dec, &right, &result);
7038 ok(hres == S_OK && V_VT(&result) == VT_R8,
7039 "VARPOW: expected coerced hres 0x%X type VT_R8, got hres 0x%X type %s!\n",
7040 S_OK, hres, vtstr(V_VT(&result)));
7041 ok(hres == S_OK && EQ_DOUBLE(V_R8(&result), 4.0),
7042 "VARPOW: DECIMAL value %f, expected %f\n", V_R8(&result), 4.0);
7046 ok(hres == DISP_E_BADVARTYPE && V_VT(&result) == VT_EMPTY,
7047 "VARPOW: expected coerced hres 0x%X type VT_EMPTY, got hres 0x%X type %s!\n",
7048 DISP_E_BADVARTYPE, hres, vtstr(V_VT(&result)));
7051 SysFreeString(num2_str);
7052 SysFreeString(num3_str);
7055 static HRESULT (WINAPI *pVarDiv)(LPVARIANT,LPVARIANT,LPVARIANT);
7057 #define VARDIV(vt1,val1,vt2,val2,rvt,rval) \
7058 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
7059 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
7060 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
7061 test_var_call2( __LINE__, pVarDiv, &left, &right, &exp )
7063 /* Skip any type that is not defined or produces an error for every case */
7064 #define SKIPTESTDIV(a) \
7065 if (a == VT_ERROR || a == VT_VARIANT || \
7066 a == VT_DISPATCH || a == VT_UNKNOWN || \
7067 a == VT_RECORD || a > VT_UINT || \
7068 a == VT_I1 || a == VT_UI8 || \
7069 a == VT_INT || a == VT_UINT || \
7070 a == VT_UI2 || a == VT_UI4 || \
7071 a == 15 /*not defined*/) \
7074 static void test_VarDiv(void)
7076 static const WCHAR str1[] = { '1','\0' };
7077 static const WCHAR str2[] = { '2','\0' };
7078 VARIANT left, right, exp, result, cy, dec;
7079 BSTR num1_str, num2_str;
7081 HRESULT hres, expectedhres;
7084 num1_str = SysAllocString(str1);
7085 num2_str = SysAllocString(str2);
7089 /* Test all possible flag/vt combinations & the resulting vt type */
7090 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
7092 VARTYPE leftvt, rightvt, resvt;
7094 for (leftvt = 0; leftvt <= VT_BSTR_BLOB; leftvt++)
7096 SKIPTESTDIV(leftvt);
7098 /* Check if we need/have support for I8 */
7099 if (leftvt == VT_I8 && !HAVE_OLEAUT32_I8)
7102 for (rightvt = 0; rightvt <= VT_BSTR_BLOB; rightvt++)
7105 SKIPTESTDIV(rightvt);
7107 /* Check if we need/have support for I8 */
7108 if (rightvt == VT_I8 && !HAVE_OLEAUT32_I8)
7111 /* Native crashes with VT_BYREF */
7112 if (ExtraFlags[i] == VT_BYREF)
7115 memset(&left, 0, sizeof(left));
7116 memset(&right, 0, sizeof(right));
7117 V_VT(&left) = leftvt | ExtraFlags[i];
7118 V_VT(&right) = rightvt | ExtraFlags[i];
7119 V_VT(&result) = VT_EMPTY;
7121 expectedhres = S_OK;
7123 if (leftvt == VT_BSTR)
7124 V_BSTR(&left) = num2_str;
7125 else if (leftvt == VT_DECIMAL)
7127 VarDecFromR8(2.0, &V_DECIMAL(&left));
7128 V_VT(&left) = leftvt | ExtraFlags[i];
7131 /* Division by 0 is undefined */
7135 V_BSTR(&right) = num2_str;
7138 VarDecFromR8(2.0, &V_DECIMAL(&right));
7139 V_VT(&right) = rightvt | ExtraFlags[i];
7142 V_BOOL(&right) = VARIANT_TRUE;
7144 case VT_I2: V_I2(&right) = 2; break;
7145 case VT_I4: V_I4(&right) = 2; break;
7146 case VT_R4: V_R4(&right) = 2.0f; break;
7147 case VT_R8: V_R8(&right) = 2.0; break;
7148 case VT_CY: V_CY(&right).int64 = 2; break;
7149 case VT_DATE: V_DATE(&right) = 2; break;
7150 case VT_UI1: V_UI1(&right) = 2; break;
7151 case VT_I8: V_I8(&right) = 2; break;
7155 /* Determine return type */
7156 if (!(rightvt == VT_EMPTY))
7158 if (leftvt == VT_NULL || rightvt == VT_NULL)
7160 else if (leftvt == VT_DECIMAL || rightvt == VT_DECIMAL)
7162 else if (leftvt == VT_I8 || rightvt == VT_I8 ||
7163 leftvt == VT_CY || rightvt == VT_CY ||
7164 leftvt == VT_DATE || rightvt == VT_DATE ||
7165 leftvt == VT_I4 || rightvt == VT_I4 ||
7166 leftvt == VT_BSTR || rightvt == VT_BSTR ||
7167 leftvt == VT_I2 || rightvt == VT_I2 ||
7168 leftvt == VT_BOOL || rightvt == VT_BOOL ||
7169 leftvt == VT_R8 || rightvt == VT_R8 ||
7170 leftvt == VT_UI1 || rightvt == VT_UI1)
7172 if ((leftvt == VT_UI1 && rightvt == VT_R4) ||
7173 (leftvt == VT_R4 && rightvt == VT_UI1))
7175 else if ((leftvt == VT_R4 && (rightvt == VT_BOOL ||
7176 rightvt == VT_I2)) || (rightvt == VT_R4 &&
7177 (leftvt == VT_BOOL || leftvt == VT_I2)))
7182 else if (leftvt == VT_R4 || rightvt == VT_R4)
7185 else if (leftvt == VT_NULL && rightvt == VT_EMPTY)
7190 /* Native VarDiv always returns an error when using extra flags */
7191 if (ExtraFlags[i] != 0)
7194 hres = pVarDiv(&left, &right, &result);
7196 /* Check expected HRESULT and if result variant type is correct */
7198 ok (hres == DISP_E_BADVARTYPE || hres == DISP_E_TYPEMISMATCH ||
7199 hres == DISP_E_OVERFLOW || hres == DISP_E_DIVBYZERO,
7200 "VarDiv: %s|0x%X, %s|0x%X: got vt %s hr 0x%X\n",
7201 vtstr(leftvt), ExtraFlags[i], vtstr(rightvt), ExtraFlags[i],
7202 vtstr(V_VT(&result)), hres);
7204 ok (hres == S_OK && resvt == V_VT(&result),
7205 "VarDiv: %s|0x%X, %s|0x%X: expected vt %s hr 0x%X, got vt %s hr 0x%X\n",
7206 vtstr(leftvt), ExtraFlags[i], vtstr(rightvt), ExtraFlags[i], vtstr(resvt),
7207 S_OK, vtstr(V_VT(&result)), hres);
7212 /* Test return values for all the good cases */
7213 VARDIV(EMPTY,0,NULL,0,NULL,0);
7214 VARDIV(EMPTY,0,I2,2,R8,0.0);
7215 VARDIV(EMPTY,0,I4,2,R8,0.0);
7216 VARDIV(EMPTY,0,R4,2.0f,R4,0.0f);
7217 VARDIV(EMPTY,0,R8,2.0,R8,0.0);
7218 VARDIV(EMPTY,0,DATE,2.0,R8,0.0);
7219 VARDIV(EMPTY,0,BSTR,num2_str,R8,0.0);
7220 VARDIV(EMPTY,0,BOOL,VARIANT_TRUE,R8,0.0);
7221 VARDIV(EMPTY,0,UI1,2,R8,0.0);
7222 if (HAVE_OLEAUT32_I8)
7224 VARDIV(EMPTY,0,I8,2,R8,0.0);
7226 VARDIV(NULL,0,EMPTY,0,NULL,0);
7227 VARDIV(NULL,0,NULL,0,NULL,0);
7228 VARDIV(NULL,0,I2,2,NULL,0);
7229 VARDIV(NULL,0,I4,2,NULL,0);
7230 VARDIV(NULL,0,R4,2.0f,NULL,0);
7231 VARDIV(NULL,0,R8,2.0,NULL,0);
7232 VARDIV(NULL,0,DATE,2,NULL,0);
7233 VARDIV(NULL,0,BSTR,num2_str,NULL,0);
7234 VARDIV(NULL,0,BOOL,VARIANT_TRUE,NULL,0);
7235 VARDIV(NULL,0,UI1,2,NULL,0);
7236 if (HAVE_OLEAUT32_I8)
7238 VARDIV(NULL,0,I8,2,NULL,0);
7240 VARDIV(I2,2,NULL,0,NULL,0);
7241 VARDIV(I2,1,I2,2,R8,0.5);
7242 VARDIV(I2,1,I4,2,R8,0.5);
7243 VARDIV(I2,1,R4,2,R4,0.5f);
7244 VARDIV(I2,1,R8,2.0,R8,0.5);
7245 VARDIV(I2,1,DATE,2,R8,0.5);
7246 VARDIV(I2,1,BOOL,VARIANT_TRUE,R8,-1.0);
7247 VARDIV(I2,1,UI1,2,R8,0.5);
7248 if (HAVE_OLEAUT32_I8)
7250 VARDIV(I2,1,I8,2,R8,0.5);
7252 VARDIV(I4,1,NULL,0,NULL,0);
7253 VARDIV(I4,1,I2,2,R8,0.5);
7254 VARDIV(I4,1,I4,2,R8,0.5);
7255 VARDIV(I4,1,R4,2.0f,R8,0.5);
7256 VARDIV(I4,1,R8,2.0,R8,0.5);
7257 VARDIV(I4,1,DATE,2,R8,0.5);
7258 VARDIV(I4,1,BSTR,num2_str,R8,0.5);
7259 VARDIV(I4,1,BOOL,VARIANT_TRUE,R8,-1.0);
7260 VARDIV(I4,1,UI1,2,R8,0.5);
7261 if (HAVE_OLEAUT32_I8)
7263 VARDIV(I4,1,I8,2,R8,0.5);
7265 VARDIV(R4,1.0f,NULL,0,NULL,0);
7266 VARDIV(R4,1.0f,I2,2,R4,0.5f);
7267 VARDIV(R4,1.0f,I4,2,R8,0.5);
7268 VARDIV(R4,1.0f,R4,2.0f,R4,0.5f);
7269 VARDIV(R4,1.0f,R8,2.0,R8,0.5);
7270 VARDIV(R4,1.0f,DATE,2,R8,0.5);
7271 VARDIV(R4,1.0f,BSTR,num2_str,R8,0.5);
7272 VARDIV(R4,1.0f,BOOL,VARIANT_TRUE,R4,-1);
7273 VARDIV(R4,1.0f,UI1,2,R4,0.5f);
7274 if (HAVE_OLEAUT32_I8)
7276 VARDIV(R4,1.0f,I8,2,R8,0.5);
7278 VARDIV(R8,1.0,NULL,0,NULL,0);
7279 VARDIV(R8,1.0,I2,2,R8,0.5);
7280 VARDIV(R8,1.0,I4,2,R8,0.5);
7281 VARDIV(R8,1.0,R4,2.0f,R8,0.5);
7282 VARDIV(R8,1.0,R8,2.0,R8,0.5);
7283 VARDIV(R8,1.0,DATE,2,R8,0.5);
7284 VARDIV(R8,1.0,BSTR,num2_str,R8,0.5);
7285 VARDIV(R8,1.0,BOOL,VARIANT_TRUE,R8,-1.0);
7286 VARDIV(R8,1.0,UI1,2,R8,0.5);
7287 if (HAVE_OLEAUT32_I8)
7289 VARDIV(R8,1.0,I8,2,R8,0.5);
7291 VARDIV(DATE,1,NULL,0,NULL,0);
7292 VARDIV(DATE,1,I2,2,R8,0.5);
7293 VARDIV(DATE,1,I4,2,R8,0.5);
7294 VARDIV(DATE,1,R4,2.0f,R8,0.5);
7295 VARDIV(DATE,1,R8,2.0,R8,0.5);
7296 VARDIV(DATE,1,DATE,2,R8,0.5);
7297 VARDIV(DATE,1,BSTR,num2_str,R8,0.5);
7298 VARDIV(DATE,1,BOOL,VARIANT_TRUE,R8,-1.0);
7299 VARDIV(DATE,1,UI1,2,R8,0.5);
7300 if (HAVE_OLEAUT32_I8)
7302 VARDIV(DATE,1,I8,2,R8,0.5);
7304 VARDIV(BSTR,num1_str,NULL,0,NULL,0);
7305 VARDIV(BSTR,num1_str,I2,2,R8,0.5);
7306 VARDIV(BSTR,num1_str,I4,2,R8,0.5);
7307 VARDIV(BSTR,num1_str,R4,2.0f,R8,0.5);
7308 VARDIV(BSTR,num1_str,R8,2.0,R8,0.5);
7309 VARDIV(BSTR,num1_str,DATE,2,R8,0.5);
7310 VARDIV(BSTR,num1_str,BSTR,num2_str,R8,0.5);
7311 VARDIV(BSTR,num1_str,BOOL,VARIANT_TRUE,R8,-1);
7312 VARDIV(BSTR,num1_str,UI1,2,R8,0.5);
7313 if (HAVE_OLEAUT32_I8)
7315 VARDIV(BSTR,num1_str,I8,2,R8,0.5);
7317 VARDIV(BOOL,VARIANT_TRUE,NULL,0,NULL,0);
7318 VARDIV(BOOL,VARIANT_TRUE,I2,1,R8,-1.0);
7319 VARDIV(BOOL,VARIANT_FALSE,I2,1,R8,0.0);
7320 VARDIV(BOOL,VARIANT_TRUE,I4,1,R8,-1.0);
7321 VARDIV(BOOL,VARIANT_FALSE,I4,1,R8,0.0);
7322 VARDIV(BOOL,VARIANT_TRUE,R4,1,R4,-1.0f);
7323 VARDIV(BOOL,VARIANT_FALSE,R4,1,R4,0.0f);
7324 VARDIV(BOOL,VARIANT_TRUE,R8,1.0,R8,-1.0);
7325 VARDIV(BOOL,VARIANT_FALSE,R8,1.0,R8,0.0);
7326 VARDIV(BOOL,VARIANT_FALSE,DATE,2,R8,0.0);
7327 VARDIV(BOOL,VARIANT_FALSE,BSTR,num2_str,R8,0.0);
7328 VARDIV(BOOL,VARIANT_TRUE,BOOL,VARIANT_TRUE,R8,1.0);
7329 VARDIV(BOOL,VARIANT_FALSE,BOOL,VARIANT_TRUE,R8,0.0);
7330 VARDIV(BOOL,VARIANT_TRUE,UI1,1,R8,-1.0);
7331 if (HAVE_OLEAUT32_I8)
7333 VARDIV(BOOL,VARIANT_TRUE,I8,1,R8,-1.0);
7335 VARDIV(UI1,1,NULL,0,NULL,0);
7336 VARDIV(UI1,1,I2,2,R8,0.5);
7337 VARDIV(UI1,1,I4,2,R8,0.5);
7338 VARDIV(UI1,1,R4,2.0f,R4,0.5f);
7339 VARDIV(UI1,1,R8,2.0,R8,0.5);
7340 VARDIV(UI1,1,DATE,2,R8,0.5);
7341 VARDIV(UI1,1,BSTR,num2_str,R8,0.5);
7342 VARDIV(UI1,1,BOOL,VARIANT_TRUE,R8,-1);
7343 VARDIV(UI1,1,UI1,2,R8,0.5);
7344 if (HAVE_OLEAUT32_I8)
7346 VARDIV(UI1,1,I8,2,R8,0.5);
7347 VARDIV(I8,1,NULL,0,NULL,0);
7348 VARDIV(I8,1,I2,2,R8,0.5);
7349 VARDIV(I8,1,I4,2,R8,0.5);
7350 VARDIV(I8,1,R4,2.0f,R8,0.5);
7351 VARDIV(I8,1,R8,2.0,R8,0.5);
7352 VARDIV(I8,1,DATE,2,R8,0.5);
7353 VARDIV(I8,1,BSTR,num2_str,R8,0.5);
7354 VARDIV(I8,1,BOOL,VARIANT_TRUE,R8,-1);
7355 VARDIV(I8,1,UI1,2,R8,0.5);
7356 VARDIV(I8,1,I8,2,R8,0.5);
7359 /* Manually test some VT_CY, VT_DECIMAL variants */
7361 hres = VarCyFromI4(10000, &V_CY(&cy));
7362 ok(hres == S_OK, "VarCyFromI4 failed!\n");
7363 V_VT(&dec) = VT_DECIMAL;
7364 hres = VarDecFromR8(2.0, &V_DECIMAL(&dec));
7365 ok(hres == S_OK, "VarDecFromR4 failed!\n");
7366 memset(&left, 0, sizeof(left));
7367 memset(&right, 0, sizeof(right));
7368 V_VT(&left) = VT_I4;
7370 V_VT(&right) = VT_UI1;
7373 hres = pVarDiv(&cy, &cy, &result);
7374 ok(hres == S_OK && V_VT(&result) == VT_R8,
7375 "VARDIV: expected coerced type VT_R8, got %s!\n", vtstr(V_VT(&result)));
7376 ok(hres == S_OK && EQ_DOUBLE(V_R8(&result), 1.0),
7377 "VARDIV: CY value %f, expected %f\n", V_R8(&result), (double)1.0);
7379 hres = pVarDiv(&cy, &right, &result);
7380 ok(hres == S_OK && V_VT(&result) == VT_R8,
7381 "VARDIV: expected coerced type VT_R8, got %s!\n", vtstr(V_VT(&result)));
7382 ok(hres == S_OK && EQ_DOUBLE(V_R8(&result), 5000.0),
7383 "VARDIV: CY value %f, expected %f\n", V_R8(&result), (double)5000.0);
7385 hres = pVarDiv(&left, &cy, &result);
7386 ok(hres == S_OK && V_VT(&result) == VT_R8,
7387 "VARDIV: expected coerced type VT_R8, got %s!\n", vtstr(V_VT(&result)));
7388 ok(hres == S_OK && EQ_DOUBLE(V_R8(&result), 0.01),
7389 "VARDIV: CY value %f, expected %f\n", V_R8(&result), (double)0.01);
7391 hres = pVarDiv(&left, &dec, &result);
7392 ok(hres == S_OK && V_VT(&result) == VT_DECIMAL,
7393 "VARDIV: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result)));
7394 hres = VarR8FromDec(&V_DECIMAL(&result), &r);
7395 ok(hres == S_OK && EQ_DOUBLE(r, 50.0),
7396 "VARDIV: DECIMAL value %f, expected %f\n", r, (double)50.0);
7398 hres = pVarDiv(&dec, &dec, &result);
7399 ok(hres == S_OK && V_VT(&result) == VT_DECIMAL,
7400 "VARDIV: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result)));
7401 hres = VarR8FromDec(&V_DECIMAL(&result), &r);
7402 ok(hres == S_OK && EQ_DOUBLE(r, 1.0),
7403 "VARDIV: DECIMAL value %f, expected %f\n", r, (double)1.0);
7405 hres = pVarDiv(&dec, &right, &result);
7406 ok(hres == S_OK && V_VT(&result) == VT_DECIMAL,
7407 "VARDIV: expected coerced type VT_DECIMAL, got %s!\n", vtstr(V_VT(&result)));
7408 hres = VarR8FromDec(&V_DECIMAL(&result), &r);
7409 ok(hres == S_OK && EQ_DOUBLE(r, 1.0),
7410 "VARDIV: DECIMAL value %f, expected %f\n", r, (double)1.0);
7412 /* Check for division by zero and overflow */
7413 V_VT(&left) = VT_R8;
7415 V_VT(&right) = VT_R8;
7417 hres = pVarDiv(&left, &right, &result);
7418 ok(hres == DISP_E_DIVBYZERO && V_VT(&result) == VT_EMPTY,
7419 "VARDIV: Division by (1.0/0.0) should result in DISP_E_DIVBYZERO but got 0x%X\n", hres);
7421 V_VT(&left) = VT_R8;
7423 V_VT(&right) = VT_R8;
7425 hres = pVarDiv(&left, &right, &result);
7426 ok(hres == DISP_E_OVERFLOW && V_VT(&result) == VT_EMPTY,
7427 "VARDIV: Division by (0.0/0.0) should result in DISP_E_OVERFLOW but got 0x%X\n", hres);
7429 SysFreeString(num1_str);
7430 SysFreeString(num2_str);
7433 static HRESULT (WINAPI *pVarIdiv)(LPVARIANT,LPVARIANT,LPVARIANT);
7435 #define VARIDIV(vt1,val1,vt2,val2,rvt,rval) \
7436 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
7437 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
7438 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
7439 test_var_call2( __LINE__, pVarIdiv, &left, &right, &exp )
7441 /* Skip any type that is not defined or produces an error for every case */
7442 #define SKIPTESTIDIV(a) \
7443 if (a == VT_ERROR || a == VT_VARIANT || \
7444 a == VT_DISPATCH || a == VT_UNKNOWN || \
7445 a == VT_RECORD || a > VT_UINT || \
7446 a == 15 /*not defined*/) \
7449 static void test_VarIdiv(void)
7451 static const WCHAR str1[] = { '1','\0' };
7452 static const WCHAR str2[] = { '2','\0' };
7453 VARIANT left, right, exp, result, cy, dec;
7454 BSTR num1_str, num2_str;
7460 num1_str = SysAllocString(str1);
7461 num2_str = SysAllocString(str2);
7463 /* Test all possible flag/vt combinations & the resulting vt type */
7464 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
7466 VARTYPE leftvt, rightvt, resvt;
7468 for (leftvt = 0; leftvt <= VT_BSTR_BLOB; leftvt++)
7470 SKIPTESTIDIV(leftvt);
7472 /* Check if we need/have support for I8 and/or UI8 */
7473 if ((leftvt == VT_I8 || leftvt == VT_UI8) && !HAVE_OLEAUT32_I8)
7476 for (rightvt = 0; rightvt <= VT_BSTR_BLOB; rightvt++)
7479 SKIPTESTIDIV(rightvt);
7481 /* Native crashes with extra flag VT_BYREF */
7482 if (ExtraFlags[i] == VT_BYREF)
7485 /* Check if we need/have support for I8 and/or UI8 */
7486 if ((rightvt == VT_I8 || rightvt == VT_UI8) && !HAVE_OLEAUT32_I8)
7489 memset(&left, 0, sizeof(left));
7490 memset(&right, 0, sizeof(right));
7491 V_VT(&left) = leftvt | ExtraFlags[i];
7492 V_VT(&right) = rightvt | ExtraFlags[i];
7493 V_VT(&result) = VT_EMPTY;
7496 if (leftvt == VT_BSTR)
7497 V_BSTR(&left) = num2_str;
7498 else if (leftvt == VT_DECIMAL)
7500 VarDecFromR8(2.0, &V_DECIMAL(&left));
7501 V_VT(&left) = leftvt | ExtraFlags[i];
7504 /* Division by 0 is undefined */
7508 V_BSTR(&right) = num2_str;
7511 VarDecFromR8(2.0, &V_DECIMAL(&right));
7512 V_VT(&right) = rightvt | ExtraFlags[i];
7515 V_BOOL(&right) = VARIANT_TRUE;
7518 VarCyFromI4(10000, &V_CY(&right));
7519 V_VT(&right) = rightvt | ExtraFlags[i];
7521 case VT_I2: V_I2(&right) = 2; break;
7522 case VT_I4: V_I4(&right) = 2; break;
7523 case VT_R4: V_R4(&right) = 2.0f; break;
7524 case VT_R8: V_R8(&right) = 2.0; break;
7525 case VT_DATE: V_DATE(&right) = 2; break;
7526 case VT_I1: V_I1(&right) = 2; break;
7527 case VT_UI1: V_UI1(&right) = 2; break;
7528 case VT_UI2: V_UI2(&right) = 2; break;
7529 case VT_UI4: V_UI4(&right) = 2; break;
7530 case VT_I8: V_I8(&right) = 2; break;
7531 case VT_UI8: V_UI8(&right) = 2; break;
7532 case VT_INT: V_INT(&right) = 2; break;
7533 case VT_UINT: V_UINT(&right) = 2; break;
7537 /* Native VarIdiv always returns an error when using extra
7538 * flags or if the variant combination is I8 and INT.
7540 if ((leftvt == VT_I8 && rightvt == VT_INT) ||
7541 (leftvt == VT_INT && rightvt == VT_I8) ||
7542 (rightvt == VT_EMPTY && leftvt != VT_NULL) ||
7546 /* Determine variant type */
7547 else if (leftvt == VT_NULL || rightvt == VT_NULL)
7549 else if (leftvt == VT_I8 || rightvt == VT_I8)
7551 else if (leftvt == VT_I4 || rightvt == VT_I4 ||
7552 leftvt == VT_INT || rightvt == VT_INT ||
7553 leftvt == VT_UINT || rightvt == VT_UINT ||
7554 leftvt == VT_UI8 || rightvt == VT_UI8 ||
7555 leftvt == VT_UI4 || rightvt == VT_UI4 ||
7556 leftvt == VT_UI2 || rightvt == VT_UI2 ||
7557 leftvt == VT_I1 || rightvt == VT_I1 ||
7558 leftvt == VT_BSTR || rightvt == VT_BSTR ||
7559 leftvt == VT_DATE || rightvt == VT_DATE ||
7560 leftvt == VT_CY || rightvt == VT_CY ||
7561 leftvt == VT_DECIMAL || rightvt == VT_DECIMAL ||
7562 leftvt == VT_R8 || rightvt == VT_R8 ||
7563 leftvt == VT_R4 || rightvt == VT_R4)
7565 else if (leftvt == VT_I2 || rightvt == VT_I2 ||
7566 leftvt == VT_BOOL || rightvt == VT_BOOL ||
7569 else if (leftvt == VT_UI1 || rightvt == VT_UI1)
7574 hres = pVarIdiv(&left, &right, &result);
7576 /* Check expected HRESULT and if result variant type is correct */
7578 ok (hres == DISP_E_BADVARTYPE || hres == DISP_E_TYPEMISMATCH ||
7579 hres == DISP_E_DIVBYZERO,
7580 "VarIdiv: %s|0x%X, %s|0x%X: got vt %s hr 0x%X\n",
7581 vtstr(leftvt), ExtraFlags[i], vtstr(rightvt), ExtraFlags[i],
7582 vtstr(V_VT(&result)), hres);
7584 ok (hres == S_OK && resvt == V_VT(&result),
7585 "VarIdiv: %s|0x%X, %s|0x%X: expected vt %s hr 0x%X, got vt %s hr 0x%X\n",
7586 vtstr(leftvt), ExtraFlags[i], vtstr(rightvt), ExtraFlags[i], vtstr(resvt),
7587 S_OK, vtstr(V_VT(&result)), hres);
7592 /* Test return values for all the good cases */
7593 VARIDIV(EMPTY,0,NULL,0,NULL,0);
7594 VARIDIV(EMPTY,0,I2,1,I2,0);
7595 VARIDIV(EMPTY,0,I4,1,I4,0);
7596 VARIDIV(EMPTY,0,R4,1.0f,I4,0);
7597 VARIDIV(EMPTY,0,R8,1.0,I4,0);
7598 VARIDIV(EMPTY,0,DATE,1.0,I4,0);
7599 VARIDIV(EMPTY,0,BSTR,num1_str,I4,0);
7600 VARIDIV(EMPTY,0,BOOL,VARIANT_TRUE,I2,0);
7601 VARIDIV(EMPTY,0,I1,1,I4,0);
7602 VARIDIV(EMPTY,0,UI1,1,I2,0);
7603 VARIDIV(EMPTY,0,UI2,1,I4,0);
7604 VARIDIV(EMPTY,0,UI4,1,I4,0);
7605 if (HAVE_OLEAUT32_I8)
7607 VARIDIV(EMPTY,0,I8,1,I8,0);
7608 VARIDIV(EMPTY,0,UI8,1,I4,0);
7610 VARIDIV(EMPTY,0,INT,1,I4,0);
7611 VARIDIV(EMPTY,0,UINT,1,I4,0);
7612 VARIDIV(NULL,0,EMPTY,0,NULL,0);
7613 VARIDIV(NULL,0,NULL,0,NULL,0);
7614 VARIDIV(NULL,0,I2,1,NULL,0);
7615 VARIDIV(NULL,0,I4,1,NULL,0);
7616 VARIDIV(NULL,0,R4,1,NULL,0);
7617 VARIDIV(NULL,0,R8,1,NULL,0);
7618 VARIDIV(NULL,0,DATE,1,NULL,0);
7619 VARIDIV(NULL,0,BSTR,num1_str,NULL,0);
7620 VARIDIV(NULL,0,BOOL,VARIANT_TRUE,NULL,0);
7621 VARIDIV(NULL,0,I1,1,NULL,0);
7622 VARIDIV(NULL,0,UI1,1,NULL,0);
7623 VARIDIV(NULL,0,UI2,1,NULL,0);
7624 VARIDIV(NULL,0,UI4,1,NULL,0);
7625 if (HAVE_OLEAUT32_I8)
7627 VARIDIV(NULL,0,I8,1,NULL,0);
7628 VARIDIV(NULL,0,UI8,1,NULL,0);
7630 VARIDIV(NULL,0,INT,1,NULL,0);
7631 VARIDIV(NULL,0,UINT,1,NULL,0);
7632 VARIDIV(I2,2,NULL,0,NULL,0);
7633 VARIDIV(I2,2,I2,1,I2,2);
7634 VARIDIV(I2,2,I4,1,I4,2);
7635 VARIDIV(I2,2,R4,1,I4,2);
7636 VARIDIV(I2,2,R8,1,I4,2);
7637 VARIDIV(I2,2,DATE,1,I4,2);
7638 VARIDIV(I2,2,BSTR,num1_str,I4,2);
7639 VARIDIV(I2,2,BOOL,VARIANT_TRUE,I2,-2);
7640 VARIDIV(I2,2,I1,1,I4,2);
7641 VARIDIV(I2,2,UI1,1,I2,2);
7642 VARIDIV(I2,2,UI2,1,I4,2);
7643 VARIDIV(I2,2,UI4,1,I4,2);
7644 if (HAVE_OLEAUT32_I8)
7646 VARIDIV(I2,2,I8,1,I8,2);
7647 VARIDIV(I2,2,UI8,1,I4,2);
7649 VARIDIV(I2,2,INT,1,I4,2);
7650 VARIDIV(I2,2,UINT,1,I4,2);
7651 VARIDIV(I4,2,NULL,0,NULL,0);
7652 VARIDIV(I4,2,I2,1,I4,2);
7653 VARIDIV(I4,2,I4,1,I4,2);
7654 VARIDIV(I4,2,R4,1,I4,2);
7655 VARIDIV(I4,2,R8,1,I4,2);
7656 VARIDIV(I4,2,DATE,1,I4,2);
7657 VARIDIV(I4,2,BSTR,num1_str,I4,2);
7658 VARIDIV(I4,2,BOOL,VARIANT_TRUE,I4,-2);
7659 VARIDIV(I4,2,I1,1,I4,2);
7660 VARIDIV(I4,2,UI1,1,I4,2);
7661 VARIDIV(I4,2,UI2,1,I4,2);
7662 VARIDIV(I4,2,UI4,1,I4,2);
7663 if (HAVE_OLEAUT32_I8)
7665 VARIDIV(I4,2,I8,1,I8,2);
7666 VARIDIV(I4,2,UI8,1,I4,2);
7668 VARIDIV(I4,2,INT,1,I4,2);
7669 VARIDIV(I4,2,UINT,1,I4,2);
7670 VARIDIV(R4,2.0f,NULL,0,NULL,0);
7671 VARIDIV(R4,2.0f,I2,1,I4,2);
7672 VARIDIV(R4,2.0f,I4,1,I4,2);
7673 VARIDIV(R4,2.0f,R4,1.0f,I4,2);
7674 VARIDIV(R4,2.0f,R8,1.0,I4,2);
7675 VARIDIV(R4,2.0f,DATE,1,I4,2);
7676 VARIDIV(R4,2.0f,BSTR,num1_str,I4,2);
7677 VARIDIV(R4,2.0f,BOOL,VARIANT_TRUE,I4,-2);
7678 VARIDIV(R4,2.0f,I1,1,I4,2);
7679 VARIDIV(R4,2.0f,UI1,1,I4,2);
7680 VARIDIV(R4,2.0f,UI2,1,I4,2);
7681 VARIDIV(R4,2.0f,UI4,1,I4,2);
7682 if (HAVE_OLEAUT32_I8)
7684 VARIDIV(R4,2.0f,I8,1,I8,2);
7685 VARIDIV(R4,2.0f,UI8,1,I4,2);
7687 VARIDIV(R4,2.0f,INT,1,I4,2);
7688 VARIDIV(R4,2.0f,UINT,1,I4,2);
7689 VARIDIV(R8,2.0,NULL,0,NULL,0);
7690 VARIDIV(R8,2.0,I2,1,I4,2);
7691 VARIDIV(R8,2.0,I4,1,I4,2);
7692 VARIDIV(R8,2.0,R4,1,I4,2);
7693 VARIDIV(R8,2.0,R8,1,I4,2);
7694 VARIDIV(R8,2.0,DATE,1,I4,2);
7695 VARIDIV(R8,2.0,BSTR,num1_str,I4,2);
7696 VARIDIV(R8,2.0,BOOL,VARIANT_TRUE,I4,-2);
7697 VARIDIV(R8,2.0,I1,1,I4,2);
7698 VARIDIV(R8,2.0,UI1,1,I4,2);
7699 VARIDIV(R8,2.0,UI2,1,I4,2);
7700 VARIDIV(R8,2.0,UI4,1,I4,2);
7701 if (HAVE_OLEAUT32_I8)
7703 VARIDIV(R8,2.0,I8,1,I8,2);
7704 VARIDIV(R8,2.0,UI8,1,I4,2);
7706 VARIDIV(R8,2.0,INT,1,I4,2);
7707 VARIDIV(R8,2.0,UINT,1,I4,2);
7708 VARIDIV(DATE,2,NULL,0,NULL,0);
7709 VARIDIV(DATE,2,I2,1,I4,2);
7710 VARIDIV(DATE,2,I4,1,I4,2);
7711 VARIDIV(DATE,2,R4,1,I4,2);
7712 VARIDIV(DATE,2,R8,1,I4,2);
7713 VARIDIV(DATE,2,DATE,1,I4,2);
7714 VARIDIV(DATE,2,BSTR,num1_str,I4,2);
7715 VARIDIV(DATE,2,BOOL,VARIANT_TRUE,I4,-2);
7716 VARIDIV(DATE,2,I1,1,I4,2);
7717 VARIDIV(DATE,2,UI1,1,I4,2);
7718 VARIDIV(DATE,2,UI2,1,I4,2);
7719 VARIDIV(DATE,2,UI4,1,I4,2);
7720 if (HAVE_OLEAUT32_I8)
7722 VARIDIV(DATE,2,I8,1,I8,2);
7723 VARIDIV(DATE,2,UI8,1,I4,2);
7725 VARIDIV(DATE,2,INT,1,I4,2);
7726 VARIDIV(DATE,2,UINT,1,I4,2);
7727 VARIDIV(BSTR,num2_str,NULL,0,NULL,0);
7728 VARIDIV(BSTR,num2_str,I2,1,I4,2);
7729 VARIDIV(BSTR,num2_str,I4,1,I4,2);
7730 VARIDIV(BSTR,num2_str,R4,1.0f,I4,2);
7731 VARIDIV(BSTR,num2_str,R8,1.0,I4,2);
7732 VARIDIV(BSTR,num2_str,DATE,1,I4,2);
7733 VARIDIV(BSTR,num2_str,BSTR,num1_str,I4,2);
7734 VARIDIV(BSTR,num2_str,BOOL,VARIANT_TRUE,I4,-2);
7735 VARIDIV(BSTR,num2_str,I1,1,I4,2);
7736 VARIDIV(BSTR,num2_str,UI1,1,I4,2);
7737 VARIDIV(BSTR,num2_str,UI2,1,I4,2);
7738 VARIDIV(BSTR,num2_str,UI4,1,I4,2);
7739 if (HAVE_OLEAUT32_I8)
7741 VARIDIV(BSTR,num2_str,I8,1,I8,2);
7742 VARIDIV(BSTR,num2_str,UI8,1,I4,2);
7744 VARIDIV(BSTR,num2_str,INT,1,I4,2);
7745 VARIDIV(BSTR,num2_str,UINT,1,I4,2);
7746 VARIDIV(BOOL,VARIANT_TRUE,NULL,0,NULL,0);
7747 VARIDIV(BOOL,VARIANT_TRUE,I2,1,I2,-1);
7748 VARIDIV(BOOL,VARIANT_TRUE,I4,1,I4,-1);
7749 VARIDIV(BOOL,VARIANT_TRUE,R4,1.0f,I4,-1);
7750 VARIDIV(BOOL,VARIANT_TRUE,R8,1.0,I4,-1);
7751 VARIDIV(BOOL,VARIANT_TRUE,DATE,1,I4,-1);
7752 VARIDIV(BOOL,VARIANT_TRUE,BSTR,num1_str,I4,-1);
7753 VARIDIV(BOOL,VARIANT_TRUE,BOOL,VARIANT_TRUE,I2,1);
7754 VARIDIV(BOOL,VARIANT_TRUE,I1,1,I4,-1);
7755 VARIDIV(BOOL,VARIANT_TRUE,UI1,1,I2,-1);
7756 VARIDIV(BOOL,VARIANT_TRUE,UI2,1,I4,-1);
7757 VARIDIV(BOOL,VARIANT_TRUE,UI4,1,I4,-1);
7758 if (HAVE_OLEAUT32_I8)
7760 VARIDIV(BOOL,VARIANT_TRUE,I8,1,I8,-1);
7761 VARIDIV(BOOL,VARIANT_TRUE,UI8,1,I4,-1);
7763 VARIDIV(BOOL,VARIANT_TRUE,INT,1,I4,-1);
7764 VARIDIV(BOOL,VARIANT_TRUE,UINT,1,I4,-1);
7765 VARIDIV(I1,2,NULL,0,NULL,0);
7766 VARIDIV(I1,2,I2,1,I4,2);
7767 VARIDIV(I1,2,I4,1,I4,2);
7768 VARIDIV(I1,2,R4,1.0f,I4,2);
7769 VARIDIV(I1,2,R8,1.0,I4,2);
7770 VARIDIV(I1,2,DATE,1,I4,2);
7771 VARIDIV(I1,2,BSTR,num1_str,I4,2);
7772 VARIDIV(I1,2,BOOL,VARIANT_TRUE,I4,-2);
7773 VARIDIV(I1,2,I1,1,I4,2);
7774 VARIDIV(I1,2,UI1,1,I4,2);
7775 VARIDIV(I1,2,UI2,1,I4,2);
7776 VARIDIV(I1,2,UI4,1,I4,2);
7777 if (HAVE_OLEAUT32_I8)
7779 VARIDIV(I1,2,I8,1,I8,2);
7780 VARIDIV(I1,2,UI8,1,I4,2);
7782 VARIDIV(I1,2,INT,1,I4,2);
7783 VARIDIV(I1,2,UINT,1,I4,2);
7784 VARIDIV(UI1,2,NULL,0,NULL,0);
7785 VARIDIV(UI1,2,I2,1,I2,2);
7786 VARIDIV(UI1,2,I4,1,I4,2);
7787 VARIDIV(UI1,2,R4,1.0f,I4,2);
7788 VARIDIV(UI1,2,R8,1.0,I4,2);
7789 VARIDIV(UI1,2,DATE,1,I4,2);
7790 VARIDIV(UI1,2,BSTR,num1_str,I4,2);
7791 VARIDIV(UI1,2,BOOL,VARIANT_TRUE,I2,-2);
7792 VARIDIV(UI1,2,I1,1,I4,2);
7793 VARIDIV(UI1,2,UI1,1,UI1,2);
7794 VARIDIV(UI1,2,UI2,1,I4,2);
7795 VARIDIV(UI1,2,UI4,1,I4,2);
7796 if (HAVE_OLEAUT32_I8)
7798 VARIDIV(UI1,2,I8,1,I8,2);
7799 VARIDIV(UI1,2,UI8,1,I4,2);
7801 VARIDIV(UI1,2,INT,1,I4,2);
7802 VARIDIV(UI1,2,UINT,1,I4,2);
7803 VARIDIV(UI2,2,NULL,0,NULL,0);
7804 VARIDIV(UI2,2,I2,1,I4,2);
7805 VARIDIV(UI2,2,I4,1,I4,2);
7806 VARIDIV(UI2,2,R4,1.0f,I4,2);
7807 VARIDIV(UI2,2,R8,1.0,I4,2);
7808 VARIDIV(UI2,2,DATE,1,I4,2);
7809 VARIDIV(UI2,2,BSTR,num1_str,I4,2);
7810 VARIDIV(UI2,2,BOOL,VARIANT_TRUE,I4,-2);
7811 VARIDIV(UI2,2,I1,1,I4,2);
7812 VARIDIV(UI2,2,UI1,1,I4,2);
7813 VARIDIV(UI2,2,UI2,1,I4,2);
7814 VARIDIV(UI2,2,UI4,1,I4,2);
7815 if (HAVE_OLEAUT32_I8)
7817 VARIDIV(UI2,2,I8,1,I8,2);
7818 VARIDIV(UI2,2,UI8,1,I4,2);
7820 VARIDIV(UI2,2,INT,1,I4,2);
7821 VARIDIV(UI2,2,UINT,1,I4,2);
7822 VARIDIV(UI4,2,NULL,0,NULL,0);
7823 VARIDIV(UI4,2,I2,1,I4,2);
7824 VARIDIV(UI4,2,I4,1,I4,2);
7825 VARIDIV(UI4,2,R4,1.0f,I4,2);
7826 VARIDIV(UI4,2,R8,1.0,I4,2);
7827 VARIDIV(UI4,2,DATE,1,I4,2);
7828 VARIDIV(UI4,2,BSTR,num1_str,I4,2);
7829 VARIDIV(UI4,2,BOOL,VARIANT_TRUE,I4,-2);
7830 VARIDIV(UI4,2,I1,1,I4,2);
7831 VARIDIV(UI4,2,UI1,1,I4,2);
7832 VARIDIV(UI4,2,UI2,1,I4,2);
7833 VARIDIV(UI4,2,UI4,1,I4,2);
7834 if (HAVE_OLEAUT32_I8)
7836 VARIDIV(UI4,2,I8,1,I8,2);
7837 VARIDIV(UI4,2,UI8,1,I4,2);
7839 VARIDIV(UI4,2,INT,1,I4,2);
7840 VARIDIV(UI4,2,UINT,1,I4,2);
7841 if (HAVE_OLEAUT32_I8)
7843 VARIDIV(I8,2,NULL,0,NULL,0);
7844 VARIDIV(I8,2,I2,1,I8,2);
7845 VARIDIV(I8,2,I4,1,I8,2);
7846 VARIDIV(I8,2,R4,1.0f,I8,2);
7847 VARIDIV(I8,2,R8,1.0,I8,2);
7848 VARIDIV(I8,2,DATE,1,I8,2);
7849 VARIDIV(I8,2,BSTR,num1_str,I8,2);
7850 VARIDIV(I8,2,BOOL,1,I8,2);
7851 VARIDIV(I8,2,I1,1,I8,2);
7852 VARIDIV(I8,2,UI1,1,I8,2);
7853 VARIDIV(I8,2,UI2,1,I8,2);
7854 VARIDIV(I8,2,UI4,1,I8,2);
7855 VARIDIV(I8,2,I8,1,I8,2);
7856 VARIDIV(I8,2,UI8,1,I8,2);
7857 VARIDIV(I8,2,UINT,1,I8,2);
7858 VARIDIV(UI8,2,NULL,0,NULL,0);
7859 VARIDIV(UI8,2,I2,1,I4,2);
7860 VARIDIV(UI8,2,I4,1,I4,2);
7861 VARIDIV(UI8,2,R4,1.0f,I4,2);
7862 VARIDIV(UI8,2,R8,1.0,I4,2);
7863 VARIDIV(UI8,2,DATE,1,I4,2);
7864 VARIDIV(UI8,2,BSTR,num1_str,I4,2);
7865 VARIDIV(UI8,2,BOOL,VARIANT_TRUE,I4,-2);
7866 VARIDIV(UI8,2,I1,1,I4,2);
7867 VARIDIV(UI8,2,UI1,1,I4,2);
7868 VARIDIV(UI8,2,UI2,1,I4,2);
7869 VARIDIV(UI8,2,UI4,1,I4,2);
7870 VARIDIV(UI8,2,I8,1,I8,2);
7871 VARIDIV(UI8,2,UI8,1,I4,2);
7872 VARIDIV(UI8,2,INT,1,I4,2);
7873 VARIDIV(UI8,2,UINT,1,I4,2);
7875 VARIDIV(INT,2,NULL,0,NULL,0);
7876 VARIDIV(INT,2,I2,1,I4,2);
7877 VARIDIV(INT,2,I4,1,I4,2);
7878 VARIDIV(INT,2,R4,1.0f,I4,2);
7879 VARIDIV(INT,2,R8,1.0,I4,2);
7880 VARIDIV(INT,2,DATE,1,I4,2);
7881 VARIDIV(INT,2,BSTR,num1_str,I4,2);
7882 VARIDIV(INT,2,BOOL,VARIANT_TRUE,I4,-2);
7883 VARIDIV(INT,2,I1,1,I4,2);
7884 VARIDIV(INT,2,UI1,1,I4,2);
7885 VARIDIV(INT,2,UI2,1,I4,2);
7886 VARIDIV(INT,2,UI4,1,I4,2);
7887 if (HAVE_OLEAUT32_I8)
7889 VARIDIV(INT,2,UI8,1,I4,2);
7891 VARIDIV(INT,2,INT,1,I4,2);
7892 VARIDIV(INT,2,UINT,1,I4,2);
7893 VARIDIV(UINT,2,NULL,0,NULL,0);
7894 VARIDIV(UINT,2,I2,1,I4,2);
7895 VARIDIV(UINT,2,I4,1,I4,2);
7896 VARIDIV(UINT,2,R4,1.0f,I4,2);
7897 VARIDIV(UINT,2,R8,1.0,I4,2);
7898 VARIDIV(UINT,2,DATE,1,I4,2);
7899 VARIDIV(UINT,2,BSTR,num1_str,I4,2);
7900 VARIDIV(UINT,2,BOOL,VARIANT_TRUE,I4,-2);
7901 VARIDIV(UINT,2,I1,1,I4,2);
7902 VARIDIV(UINT,2,UI1,1,I4,2);
7903 VARIDIV(UINT,2,UI2,1,I4,2);
7904 VARIDIV(UINT,2,UI4,1,I4,2);
7905 if (HAVE_OLEAUT32_I8)
7907 VARIDIV(UINT,2,I8,1,I8,2);
7908 VARIDIV(UINT,2,UI8,1,I4,2);
7910 VARIDIV(UINT,2,INT,1,I4,2);
7911 VARIDIV(UINT,2,UINT,1,I4,2);
7913 /* Manually test some VT_CY, VT_DECIMAL variants */
7915 hres = VarCyFromI4(10000, &V_CY(&cy));
7916 ok(hres == S_OK, "VarCyFromI4 failed!\n");
7917 V_VT(&dec) = VT_DECIMAL;
7918 hres = VarDecFromR8(2.0, &V_DECIMAL(&dec));
7919 ok(hres == S_OK, "VarDecFromR4 failed!\n");
7920 memset(&left, 0, sizeof(left));
7921 memset(&right, 0, sizeof(right));
7922 V_VT(&left) = VT_I4;
7924 V_VT(&right) = VT_I8;
7927 hres = VarIdiv(&cy, &cy, &result);
7928 ok(hres == S_OK && V_VT(&result) == VT_I4,
7929 "VARIDIV: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
7930 S_OK, hres, vtstr(V_VT(&result)));
7931 ok(hres == S_OK && V_I4(&result) == 1,
7932 "VARIDIV: CY value %d, expected %d\n", V_I4(&result), 1);
7934 if (HAVE_OLEAUT32_I8)
7936 hres = VarIdiv(&cy, &right, &result);
7937 ok(hres == S_OK && V_VT(&result) == VT_I8,
7938 "VARIDIV: expected coerced hres 0x%X type VT_I8, got hres 0x%X type %s!\n",
7939 S_OK, hres, vtstr(V_VT(&result)));
7940 ok(hres == S_OK && V_I8(&result) == 5000,
7941 "VARIDIV: CY value 0x%x%08x, expected 0x%x\n",
7942 (DWORD)(V_I8(&result) >>32), (DWORD)V_I8(&result), 5000);
7945 hres = VarIdiv(&left, &cy, &result);
7946 ok(hres == S_OK && V_VT(&result) == VT_I4,
7947 "VARIDIV: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
7948 S_OK, hres, vtstr(V_VT(&result)));
7949 ok(hres == S_OK && V_I4(&result) == 0,
7950 "VARIDIV: CY value %d, expected %d\n", V_I4(&result), 0);
7952 hres = VarIdiv(&left, &dec, &result);
7953 ok(hres == S_OK && V_VT(&result) == VT_I4,
7954 "VARIDIV: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
7955 S_OK, hres, vtstr(V_VT(&result)));
7956 ok(hres == S_OK && V_I4(&result) == 50,
7957 "VARIDIV: DECIMAL value %d, expected %d\n", V_I4(&result), 50);
7959 hres = VarIdiv(&dec, &dec, &result);
7960 ok(hres == S_OK && V_VT(&result) == VT_I4,
7961 "VARIDIV: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
7962 S_OK, hres, vtstr(V_VT(&result)));
7963 ok(hres == S_OK && V_I4(&result) == 1,
7964 "VARIDIV: DECIMAL value %d, expected %d\n", V_I4(&result), 1);
7966 if (HAVE_OLEAUT32_I8)
7968 hres = VarIdiv(&dec, &right, &result);
7969 ok(hres == S_OK && V_VT(&result) == VT_I8,
7970 "VARIDIV: expected coerced hres 0x%X type VT_I8, got hres 0x%X type %s!\n",
7971 S_OK, hres, vtstr(V_VT(&result)));
7972 ok(hres == S_OK && V_I8(&result) == 1,
7973 "VARIDIV: DECIMAL value 0x%x%08x, expected %d\n",
7974 (DWORD)(V_I8(&result) >> 32), (DWORD)V_I8(&result), 1);
7977 /* Check for division by zero */
7978 V_VT(&left) = VT_INT;
7980 V_VT(&right) = VT_INT;
7982 hres = pVarIdiv(&left, &right, &result);
7983 ok(hres == DISP_E_DIVBYZERO && V_VT(&result) == VT_EMPTY,
7984 "VARIDIV: Division by 0 should result in DISP_E_DIVBYZERO but got 0x%X\n", hres);
7986 V_VT(&left) = VT_INT;
7988 V_VT(&right) = VT_INT;
7990 hres = pVarIdiv(&left, &right, &result);
7991 ok(hres == DISP_E_DIVBYZERO && V_VT(&result) == VT_EMPTY,
7992 "VARIDIV: Division by 0 should result in DISP_E_DIVBYZERO but got 0x%X\n", hres);
7994 SysFreeString(num1_str);
7995 SysFreeString(num2_str);
7999 static HRESULT (WINAPI *pVarImp)(LPVARIANT,LPVARIANT,LPVARIANT);
8001 #define VARIMP(vt1,val1,vt2,val2,rvt,rval) \
8002 V_VT(&left) = VT_##vt1; V_##vt1(&left) = val1; \
8003 V_VT(&right) = VT_##vt2; V_##vt2(&right) = val2; \
8004 V_VT(&exp) = VT_##rvt; V_##rvt(&exp) = rval; \
8005 test_var_call2( __LINE__, pVarImp, &left, &right, &exp )
8007 /* Skip any type that is not defined or produces an error for every case */
8008 #define SKIPTESTIMP(a) \
8009 if (a == VT_ERROR || a == VT_VARIANT || \
8010 a == VT_DISPATCH || a == VT_UNKNOWN || \
8011 a == VT_RECORD || a > VT_UINT || \
8012 a == 15 /*not defined*/) \
8015 static void test_VarImp(void)
8017 static const WCHAR szFalse[] = { '#','F','A','L','S','E','#','\0' };
8018 static const WCHAR szTrue[] = { '#','T','R','U','E','#','\0' };
8019 VARIANT left, right, exp, result, cy, dec;
8020 BSTR true_str, false_str;
8026 true_str = SysAllocString(szTrue);
8027 false_str = SysAllocString(szFalse);
8029 /* Test all possible flag/vt combinations & the resulting vt type */
8030 for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
8032 VARTYPE leftvt, rightvt, resvt;
8034 for (leftvt = 0; leftvt <= VT_BSTR_BLOB; leftvt++)
8036 SKIPTESTIMP(leftvt);
8038 /* Check if we need/have support for I8 and/or UI8 */
8039 if ((leftvt == VT_I8 || leftvt == VT_UI8) && !HAVE_OLEAUT32_I8)
8042 for (rightvt = 0; rightvt <= VT_BSTR_BLOB; rightvt++)
8045 SKIPTESTIMP(rightvt);
8047 /* Native crashes when using the extra flag VT_BYREF
8048 * or with the following VT combinations
8050 if ((leftvt == VT_UI4 && rightvt == VT_BSTR) ||
8051 (leftvt == VT_UI8 && rightvt == VT_BSTR) ||
8052 ExtraFlags[i] == VT_BYREF)
8055 /* Check if we need/have support for I8 and/or UI8 */
8056 if ((rightvt == VT_I8 || rightvt == VT_UI8) && !HAVE_OLEAUT32_I8)
8059 memset(&left, 0, sizeof(left));
8060 memset(&right, 0, sizeof(right));
8061 V_VT(&left) = leftvt | ExtraFlags[i];
8062 V_VT(&right) = rightvt | ExtraFlags[i];
8063 V_VT(&result) = VT_EMPTY;
8066 if (leftvt == VT_BSTR)
8067 V_BSTR(&left) = true_str;
8069 /* This allows us to test return types that are not NULL
8070 * (NULL Imp value = n, NULL Imp 0 = NULL)
8075 V_BSTR(&right) = true_str;
8078 VarDecFromR8(2.0, &V_DECIMAL(&right));
8079 V_VT(&right) = rightvt | ExtraFlags[i];
8082 V_BOOL(&right) = VARIANT_TRUE;
8084 case VT_I1: V_I1(&right) = 2; break;
8085 case VT_I2: V_I2(&right) = 2; break;
8086 case VT_I4: V_I4(&right) = 2; break;
8087 case VT_R4: V_R4(&right) = 2.0f; break;
8088 case VT_R8: V_R8(&right) = 2.0; break;
8089 case VT_CY: V_CY(&right).int64 = 10000; break;
8090 case VT_DATE: V_DATE(&right) = 2; break;
8091 case VT_I8: V_I8(&right) = 2; break;
8092 case VT_INT: V_INT(&right) = 2; break;
8093 case VT_UINT: V_UINT(&right) = 2; break;
8094 case VT_UI1: V_UI1(&right) = 2; break;
8095 case VT_UI2: V_UI2(&right) = 2; break;
8096 case VT_UI4: V_UI4(&right) = 2; break;
8097 case VT_UI8: V_UI8(&right) = 2; break;
8101 /* Native VarImp always returns an error when using extra
8102 * flags or if the variants are I8 and INT.
8104 if ((leftvt == VT_I8 && rightvt == VT_INT) ||
8108 /* Determine result type */
8109 else if ((leftvt == VT_BSTR && rightvt == VT_NULL) ||
8110 (leftvt == VT_NULL && rightvt == VT_NULL) ||
8111 (leftvt == VT_NULL && rightvt == VT_EMPTY))
8113 else if (leftvt == VT_I8 || rightvt == VT_I8)
8115 else if (leftvt == VT_I4 || rightvt == VT_I4 ||
8116 leftvt == VT_INT || rightvt == VT_INT ||
8117 leftvt == VT_UINT || rightvt == VT_UINT ||
8118 leftvt == VT_UI4 || rightvt == VT_UI4 ||
8119 leftvt == VT_UI8 || rightvt == VT_UI8 ||
8120 leftvt == VT_UI2 || rightvt == VT_UI2 ||
8121 leftvt == VT_DECIMAL || rightvt == VT_DECIMAL ||
8122 leftvt == VT_DATE || rightvt == VT_DATE ||
8123 leftvt == VT_CY || rightvt == VT_CY ||
8124 leftvt == VT_R8 || rightvt == VT_R8 ||
8125 leftvt == VT_R4 || rightvt == VT_R4 ||
8126 leftvt == VT_I1 || rightvt == VT_I1)
8128 else if ((leftvt == VT_UI1 && rightvt == VT_UI1) ||
8129 (leftvt == VT_UI1 && rightvt == VT_NULL) ||
8130 (leftvt == VT_NULL && rightvt == VT_UI1))
8132 else if (leftvt == VT_EMPTY || rightvt == VT_EMPTY ||
8133 leftvt == VT_I2 || rightvt == VT_I2 ||
8134 leftvt == VT_UI1 || rightvt == VT_UI1)
8136 else if (leftvt == VT_BOOL || rightvt == VT_BOOL ||
8137 leftvt == VT_BSTR || rightvt == VT_BSTR)
8140 hres = pVarImp(&left, &right, &result);
8142 /* Check expected HRESULT and if result variant type is correct */
8144 ok (hres == DISP_E_BADVARTYPE || hres == DISP_E_TYPEMISMATCH,
8145 "VarImp: %s|0x%X, %s|0x%X: got vt %s hr 0x%X\n",
8146 vtstr(leftvt), ExtraFlags[i], vtstr(rightvt), ExtraFlags[i],
8147 vtstr(V_VT(&result)), hres);
8149 ok (hres == S_OK && resvt == V_VT(&result),
8150 "VarImp: %s|0x%X, %s|0x%X: expected vt %s hr 0x%X, got vt %s hr 0x%X\n",
8151 vtstr(leftvt), ExtraFlags[i], vtstr(rightvt), ExtraFlags[i], vtstr(resvt),
8152 S_OK, vtstr(V_VT(&result)), hres);
8157 VARIMP(EMPTY,0,EMPTY,0,I2,-1);
8158 VARIMP(EMPTY,0,NULL,0,I2,-1);
8159 VARIMP(EMPTY,0,I2,-1,I2,-1);
8160 VARIMP(EMPTY,0,I4,-1,I4,-1);
8161 VARIMP(EMPTY,0,R4,0.0f,I4,-1);
8162 VARIMP(EMPTY,0,R8,-1.0,I4,-1);
8163 VARIMP(EMPTY,0,DATE,0,I4,-1);
8164 VARIMP(EMPTY,0,BSTR,true_str,I2,-1);
8165 VARIMP(EMPTY,0,BOOL,VARIANT_FALSE,I2,-1);
8166 VARIMP(EMPTY,0,I1,0,I4,-1);
8167 VARIMP(EMPTY,0,UI1,1,I2,-1);
8168 VARIMP(EMPTY,0,UI2,1,I4,-1);
8169 VARIMP(EMPTY,0,UI4,1,I4,-1);
8170 if (HAVE_OLEAUT32_I8)
8172 VARIMP(EMPTY,0,I8,1,I8,-1);
8173 VARIMP(EMPTY,0,UI8,1,I4,-1);
8175 VARIMP(EMPTY,0,INT,-1,I4,-1);
8176 VARIMP(EMPTY,0,UINT,1,I4,-1);
8177 VARIMP(NULL,0,EMPTY,0,NULL,0);
8178 VARIMP(NULL,0,NULL,0,NULL,0);
8179 VARIMP(NULL,0,I2,-1,I2,-1);
8180 VARIMP(NULL,0,I4,-1,I4,-1);
8181 VARIMP(NULL,0,R4,0.0f,NULL,0);
8182 VARIMP(NULL,0,R8,-1.0,I4,-1);
8183 VARIMP(NULL,0,DATE,0,NULL,0);
8184 VARIMP(NULL,0,BSTR,true_str,BOOL,-1);
8185 VARIMP(NULL,0,BOOL,VARIANT_FALSE,NULL,0);
8186 VARIMP(NULL,0,I1,0,NULL,0);
8187 VARIMP(NULL,0,UI1,1,UI1,1);
8188 VARIMP(NULL,0,UI2,1,I4,1);
8189 VARIMP(NULL,0,UI4,1,I4,1);
8190 if (HAVE_OLEAUT32_I8)
8192 VARIMP(NULL,0,I8,1,I8,1);
8193 VARIMP(NULL,0,UI8,1,I4,1);
8195 VARIMP(NULL,0,INT,-1,I4,-1);
8196 VARIMP(NULL,0,UINT,1,I4,1);
8197 VARIMP(I2,-1,EMPTY,0,I2,0);
8198 VARIMP(I2,-1,I2,-1,I2,-1);
8199 VARIMP(I2,-1,I4,-1,I4,-1);
8200 VARIMP(I2,-1,R4,0.0f,I4,0);
8201 VARIMP(I2,-1,R8,-1.0,I4,-1);
8202 VARIMP(I2,-1,DATE,0,I4,0);
8203 VARIMP(I2,-1,BSTR,true_str,I2,-1);
8204 VARIMP(I2,-1,BOOL,VARIANT_FALSE,I2,0);
8205 VARIMP(I2,-1,I1,0,I4,0);
8206 VARIMP(I2,-1,UI1,1,I2,1);
8207 VARIMP(I2,-1,UI2,1,I4,1);
8208 VARIMP(I2,-1,UI4,1,I4,1);
8209 if (HAVE_OLEAUT32_I8)
8211 VARIMP(I2,-1,I8,1,I8,1);
8212 VARIMP(I2,-1,UI8,1,I4,1);
8214 VARIMP(I2,-1,INT,-1,I4,-1);
8215 VARIMP(I2,-1,UINT,1,I4,1);
8216 VARIMP(I4,2,EMPTY,0,I4,-3);
8217 VARIMP(I4,2,NULL,0,I4,-3);
8218 VARIMP(I4,2,I2,-1,I4,-1);
8219 VARIMP(I4,2,I4,-1,I4,-1);
8220 VARIMP(I4,2,R4,0.0f,I4,-3);
8221 VARIMP(I4,2,R8,-1.0,I4,-1);
8222 VARIMP(I4,2,DATE,0,I4,-3);
8223 VARIMP(I4,2,BSTR,true_str,I4,-1);
8224 VARIMP(I4,2,BOOL,VARIANT_FALSE,I4,-3);
8225 VARIMP(I4,2,I1,0,I4,-3);
8226 VARIMP(I4,2,UI1,1,I4,-3);
8227 VARIMP(I4,2,UI2,1,I4,-3);
8228 VARIMP(I4,2,UI4,1,I4,-3);
8229 if (HAVE_OLEAUT32_I8)
8231 VARIMP(I4,2,I8,1,I8,-3);
8232 VARIMP(I4,2,UI8,1,I4,-3);
8234 VARIMP(I4,2,INT,-1,I4,-1);
8235 VARIMP(I4,2,UINT,1,I4,-3);
8236 VARIMP(R4,-1.0f,EMPTY,0,I4,0);
8237 VARIMP(R4,-1.0f,NULL,0,NULL,0);
8238 VARIMP(R4,-1.0f,I2,-1,I4,-1);
8239 VARIMP(R4,-1.0f,I4,-1,I4,-1);
8240 VARIMP(R4,-1.0f,R4,0.0f,I4,0);
8241 VARIMP(R4,-1.0f,R8,-1.0,I4,-1);
8242 VARIMP(R4,-1.0f,DATE,1,I4,1);
8243 VARIMP(R4,-1.0f,BSTR,true_str,I4,-1);
8244 VARIMP(R4,-1.0f,BOOL,VARIANT_FALSE,I4,0);
8245 VARIMP(R4,-1.0f,I1,0,I4,0);
8246 VARIMP(R4,-1.0f,UI1,1,I4,1);
8247 VARIMP(R4,-1.0f,UI2,1,I4,1);
8248 VARIMP(R4,-1.0f,UI4,1,I4,1);
8249 if (HAVE_OLEAUT32_I8)
8251 VARIMP(R4,-1.0f,I8,1,I8,1);
8252 VARIMP(R4,-1.0f,UI8,1,I4,1);
8254 VARIMP(R4,-1.0f,INT,-1,I4,-1);
8255 VARIMP(R4,-1.0f,UINT,1,I4,1);
8256 VARIMP(R8,1.0,EMPTY,0,I4,-2);
8257 VARIMP(R8,1.0,NULL,0,I4,-2);
8258 VARIMP(R8,1.0,I2,-1,I4,-1);
8259 VARIMP(R8,1.0,I4,-1,I4,-1);
8260 VARIMP(R8,1.0,R4,0.0f,I4,-2);
8261 VARIMP(R8,1.0,R8,-1.0,I4,-1);
8262 VARIMP(R8,1.0,DATE,0,I4,-2);
8263 VARIMP(R8,1.0,BSTR,true_str,I4,-1);
8264 VARIMP(R8,1.0,BOOL,VARIANT_FALSE,I4,-2);
8265 VARIMP(R8,1.0,I1,0,I4,-2);
8266 VARIMP(R8,1.0,UI1,1,I4,-1);
8267 VARIMP(R8,1.0,UI2,1,I4,-1);
8268 VARIMP(R8,1.0,UI4,1,I4,-1);
8269 if (HAVE_OLEAUT32_I8)
8271 VARIMP(R8,1.0,I8,1,I8,-1);
8272 VARIMP(R8,1.0,UI8,1,I4,-1);
8274 VARIMP(R8,1.0,INT,-1,I4,-1);
8275 VARIMP(R8,1.0,UINT,1,I4,-1);
8276 VARIMP(DATE,0,EMPTY,0,I4,-1);
8277 VARIMP(DATE,0,NULL,0,I4,-1);
8278 VARIMP(DATE,0,I2,-1,I4,-1);
8279 VARIMP(DATE,0,I4,-1,I4,-1);
8280 VARIMP(DATE,0,R4,0.0f,I4,-1);
8281 VARIMP(DATE,0,R8,-1.0,I4,-1);
8282 VARIMP(DATE,0,DATE,0,I4,-1);
8283 VARIMP(DATE,0,BSTR,true_str,I4,-1);
8284 VARIMP(DATE,0,BOOL,VARIANT_FALSE,I4,-1);
8285 VARIMP(DATE,0,I1,0,I4,-1);
8286 VARIMP(DATE,0,UI1,1,I4,-1);
8287 VARIMP(DATE,0,UI2,1,I4,-1);
8288 VARIMP(DATE,0,UI4,1,I4,-1);
8289 if (HAVE_OLEAUT32_I8)
8291 VARIMP(DATE,0,I8,1,I8,-1);
8292 VARIMP(DATE,0,UI8,1,I4,-1);
8294 VARIMP(DATE,0,INT,-1,I4,-1);
8295 VARIMP(DATE,0,UINT,1,I4,-1);
8296 VARIMP(BSTR,false_str,EMPTY,0,I2,-1);
8297 VARIMP(BSTR,false_str,NULL,0,BOOL,-1);
8298 VARIMP(BSTR,false_str,I2,-1,I2,-1);
8299 VARIMP(BSTR,false_str,I4,-1,I4,-1);
8300 VARIMP(BSTR,false_str,R4,0.0f,I4,-1);
8301 VARIMP(BSTR,false_str,R8,-1.0,I4,-1);
8302 VARIMP(BSTR,false_str,DATE,0,I4,-1);
8303 VARIMP(BSTR,false_str,BSTR,true_str,BOOL,-1);
8304 VARIMP(BSTR,false_str,BOOL,VARIANT_FALSE,BOOL,-1);
8305 VARIMP(BSTR,false_str,I1,0,I4,-1);
8306 VARIMP(BSTR,false_str,UI1,1,I2,-1);
8307 VARIMP(BSTR,false_str,UI2,1,I4,-1);
8308 VARIMP(BSTR,false_str,UI4,1,I4,-1);
8309 if (HAVE_OLEAUT32_I8)
8311 VARIMP(BSTR,false_str,I8,1,I8,-1);
8312 VARIMP(BSTR,false_str,UI8,1,I4,-1);
8314 VARIMP(BSTR,false_str,INT,-1,I4,-1);
8315 VARIMP(BSTR,false_str,UINT,1,I4,-1);
8316 VARIMP(BOOL,VARIANT_TRUE,EMPTY,0,I2,0);
8317 VARIMP(BOOL,VARIANT_TRUE,NULL,0,NULL,0);
8318 VARIMP(BOOL,VARIANT_TRUE,I2,-1,I2,-1);
8319 VARIMP(BOOL,VARIANT_TRUE,I4,-1,I4,-1);
8320 VARIMP(BOOL,VARIANT_TRUE,R4,0.0f,I4,0);
8321 VARIMP(BOOL,VARIANT_TRUE,R8,-1.0,I4,-1);
8322 VARIMP(BOOL,VARIANT_TRUE,DATE,0,I4,0);
8323 VARIMP(BOOL,VARIANT_TRUE,BSTR,true_str,BOOL,-1);
8324 VARIMP(BOOL,VARIANT_TRUE,BOOL,VARIANT_FALSE,BOOL,0);
8325 VARIMP(BOOL,VARIANT_TRUE,I1,0,I4,0);
8326 VARIMP(BOOL,VARIANT_TRUE,UI1,1,I2,1);
8327 VARIMP(BOOL,VARIANT_TRUE,UI2,1,I4,1);
8328 VARIMP(BOOL,VARIANT_TRUE,UI4,1,I4,1);
8329 if (HAVE_OLEAUT32_I8)
8331 VARIMP(BOOL,VARIANT_TRUE,I8,1,I8,1);
8332 VARIMP(BOOL,VARIANT_TRUE,UI8,1,I4,1);
8334 VARIMP(BOOL,VARIANT_TRUE,INT,-1,I4,-1);
8335 VARIMP(BOOL,VARIANT_TRUE,UINT,1,I4,1);
8336 VARIMP(I1,-1,EMPTY,0,I4,0);
8337 VARIMP(I1,-1,NULL,0,NULL,0);
8338 VARIMP(I1,-1,I2,-1,I4,-1);
8339 VARIMP(I1,-1,I4,-1,I4,-1);
8340 VARIMP(I1,-1,R4,0.0f,I4,0);
8341 VARIMP(I1,-1,R8,-1.0,I4,-1);
8342 VARIMP(I1,-1,DATE,0,I4,0);
8343 VARIMP(I1,-1,BSTR,true_str,I4,-1);
8344 VARIMP(I1,-1,BOOL,VARIANT_FALSE,I4,0);
8345 VARIMP(I1,-1,I1,0,I4,0);
8346 VARIMP(I1,-1,UI1,1,I4,1);
8347 VARIMP(I1,-1,UI2,1,I4,1);
8348 VARIMP(I1,-1,UI4,1,I4,1);
8349 if (HAVE_OLEAUT32_I8)
8351 VARIMP(I1,-1,I8,1,I8,1);
8352 VARIMP(I1,-1,UI8,1,I4,1);
8354 VARIMP(I1,-1,INT,-1,I4,-1);
8355 VARIMP(I1,-1,UINT,1,I4,1);
8356 VARIMP(UI1,0,EMPTY,0,I2,-1);
8357 VARIMP(UI1,0,NULL,0,UI1,255);
8358 VARIMP(UI1,0,I2,-1,I2,-1);
8359 VARIMP(UI1,0,I4,-1,I4,-1);
8360 VARIMP(UI1,0,R4,0.0f,I4,-1);
8361 VARIMP(UI1,0,R8,-1.0,I4,-1);
8362 VARIMP(UI1,0,DATE,0,I4,-1);
8363 VARIMP(UI1,0,BSTR,true_str,I2,-1);
8364 VARIMP(UI1,0,BOOL,VARIANT_FALSE,I2,-1);
8365 VARIMP(UI1,0,I1,0,I4,-1);
8366 VARIMP(UI1,0,UI1,1,UI1,255);
8367 VARIMP(UI1,0,UI2,1,I4,-1);
8368 VARIMP(UI1,0,UI4,1,I4,-1);
8369 if (HAVE_OLEAUT32_I8)
8371 VARIMP(UI1,0,I8,1,I8,-1);
8372 VARIMP(UI1,0,UI8,1,I4,-1);
8374 VARIMP(UI1,0,INT,-1,I4,-1);
8375 VARIMP(UI1,0,UINT,1,I4,-1);
8376 VARIMP(UI2,0,EMPTY,0,I4,-1);
8377 VARIMP(UI2,0,NULL,0,I4,-1);
8378 VARIMP(UI2,0,I2,-1,I4,-1);
8379 VARIMP(UI2,0,I4,-1,I4,-1);
8380 VARIMP(UI2,0,R4,0.0f,I4,-1);
8381 VARIMP(UI2,0,R8,-1.0,I4,-1);
8382 VARIMP(UI2,0,DATE,0,I4,-1);
8383 VARIMP(UI2,0,BSTR,true_str,I4,-1);
8384 VARIMP(UI2,0,BOOL,VARIANT_FALSE,I4,-1);
8385 VARIMP(UI2,0,I1,0,I4,-1);
8386 VARIMP(UI2,0,UI1,1,I4,-1);
8387 VARIMP(UI2,0,UI2,1,I4,-1);
8388 VARIMP(UI2,0,UI4,1,I4,-1);
8389 if (HAVE_OLEAUT32_I8)
8391 VARIMP(UI2,0,I8,1,I8,-1);
8392 VARIMP(UI2,0,UI8,1,I4,-1);
8394 VARIMP(UI2,0,INT,-1,I4,-1);
8395 VARIMP(UI2,0,UINT,1,I4,-1);
8396 VARIMP(UI4,0,EMPTY,0,I4,-1);
8397 VARIMP(UI4,0,NULL,0,I4,-1);
8398 VARIMP(UI4,0,I2,-1,I4,-1);
8399 VARIMP(UI4,0,I4,-1,I4,-1);
8400 VARIMP(UI4,0,R4,0.0f,I4,-1);
8401 VARIMP(UI4,0,R8,-1.0,I4,-1);
8402 VARIMP(UI4,0,DATE,0,I4,-1);
8403 VARIMP(UI4,0,BSTR,true_str,I4,-1);
8404 VARIMP(UI4,0,BOOL,VARIANT_FALSE,I4,-1);
8405 VARIMP(UI4,0,I1,0,I4,-1);
8406 VARIMP(UI4,0,UI1,1,I4,-1);
8407 VARIMP(UI4,0,UI2,1,I4,-1);
8408 VARIMP(UI4,0,UI4,1,I4,-1);
8409 if (HAVE_OLEAUT32_I8)
8411 VARIMP(UI4,0,I8,1,I8,-1);
8412 VARIMP(UI4,0,UI8,1,I4,-1);
8414 VARIMP(UI4,0,INT,-1,I4,-1);
8415 VARIMP(UI4,0,UINT,1,I4,-1);
8416 if (HAVE_OLEAUT32_I8)
8418 VARIMP(I8,-1,EMPTY,0,I8,0);
8419 VARIMP(I8,-1,NULL,0,NULL,0);
8420 VARIMP(I8,-1,I2,-1,I8,-1);
8421 VARIMP(I8,-1,I4,-1,I8,-1);
8422 VARIMP(I8,-1,R4,0.0f,I8,0);
8423 VARIMP(I8,-1,R8,-1.0,I8,-1);
8424 VARIMP(I8,-1,DATE,0,I8,0);
8425 VARIMP(I8,-1,BSTR,true_str,I8,-1);
8426 VARIMP(I8,-1,BOOL,VARIANT_FALSE,I8,0);
8427 VARIMP(I8,-1,I1,0,I8,0);
8428 VARIMP(I8,-1,UI1,1,I8,1);
8429 VARIMP(I8,-1,UI2,1,I8,1);
8430 VARIMP(I8,-1,UI4,1,I8,1);
8431 VARIMP(I8,-1,I8,1,I8,1);
8432 VARIMP(I8,-1,UI8,1,I8,1);
8433 VARIMP(I8,-1,UINT,1,I8,1);
8434 VARIMP(UI8,0,EMPTY,0,I4,-1);
8435 VARIMP(UI8,0,NULL,0,I4,-1);
8436 VARIMP(UI8,0,I2,-1,I4,-1);
8437 VARIMP(UI8,0,I4,-1,I4,-1);
8438 VARIMP(UI8,0,R4,0.0f,I4,-1);
8439 VARIMP(UI8,0,R8,-1.0,I4,-1);
8440 VARIMP(UI8,0,DATE,0,I4,-1);
8441 VARIMP(UI8,0,BSTR,true_str,I4,-1);
8442 VARIMP(UI8,0,BOOL,VARIANT_FALSE,I4,-1);
8443 VARIMP(UI8,0,I1,0,I4,-1);
8444 VARIMP(UI8,0,UI1,1,I4,-1);
8445 VARIMP(UI8,0,UI2,1,I4,-1);
8446 VARIMP(UI8,0,UI4,1,I4,-1);
8447 VARIMP(UI8,0,I8,1,I8,-1);
8448 VARIMP(UI8,0,UI8,1,I4,-1);
8449 VARIMP(UI8,0,INT,-1,I4,-1);
8450 VARIMP(UI8,0,UINT,1,I4,-1);
8452 VARIMP(INT,-1,EMPTY,0,I4,0);
8453 VARIMP(INT,-1,NULL,0,NULL,0);
8454 VARIMP(INT,-1,I2,-1,I4,-1);
8455 VARIMP(INT,-1,I4,-1,I4,-1);
8456 VARIMP(INT,-1,R4,0.0f,I4,0);
8457 VARIMP(INT,-1,R8,-1.0,I4,-1);
8458 VARIMP(INT,-1,DATE,0,I4,0);
8459 VARIMP(INT,-1,BSTR,true_str,I4,-1);
8460 VARIMP(INT,-1,BOOL,VARIANT_FALSE,I4,0);
8461 VARIMP(INT,-1,I1,0,I4,0);
8462 VARIMP(INT,-1,UI1,1,I4,1);
8463 VARIMP(INT,-1,UI2,1,I4,1);
8464 VARIMP(INT,-1,UI4,1,I4,1);
8465 if (HAVE_OLEAUT32_I8)
8467 VARIMP(INT,-1,I8,1,I8,1);
8468 VARIMP(INT,-1,UI8,1,I4,1);
8470 VARIMP(INT,-1,INT,-1,I4,-1);
8471 VARIMP(INT,-1,UINT,1,I4,1);
8472 VARIMP(UINT,1,EMPTY,0,I4,-2);
8473 VARIMP(UINT,1,NULL,0,I4,-2);
8474 VARIMP(UINT,1,I2,-1,I4,-1);
8475 VARIMP(UINT,1,I4,-1,I4,-1);
8476 VARIMP(UINT,1,R4,0.0f,I4,-2);
8477 VARIMP(UINT,1,R8,-1.0,I4,-1);
8478 VARIMP(UINT,1,DATE,0,I4,-2);
8479 VARIMP(UINT,1,BSTR,true_str,I4,-1);
8480 VARIMP(UINT,1,BOOL,VARIANT_FALSE,I4,-2);
8481 VARIMP(UINT,1,I1,0,I4,-2);
8482 VARIMP(UINT,1,UI1,1,I4,-1);
8483 VARIMP(UINT,1,UI2,1,I4,-1);
8484 VARIMP(UINT,1,UI4,1,I4,-1);
8485 if (HAVE_OLEAUT32_I8)
8487 VARIMP(UINT,1,I8,1,I8,-1);
8488 VARIMP(UINT,1,UI8,1,I4,-1);
8490 VARIMP(UINT,1,INT,-1,I4,-1);
8491 VARIMP(UINT,1,UINT,1,I4,-1);
8493 /* Manually test some VT_CY, VT_DECIMAL variants */
8495 hres = VarCyFromI4(1, &V_CY(&cy));
8496 ok(hres == S_OK, "VarCyFromI4 failed!\n");
8497 V_VT(&dec) = VT_DECIMAL;
8498 hres = VarDecFromR8(2.0, &V_DECIMAL(&dec));
8499 ok(hres == S_OK, "VarDecFromR4 failed!\n");
8500 memset(&left, 0, sizeof(left));
8501 memset(&right, 0, sizeof(right));
8502 V_VT(&left) = VT_I4;
8504 V_VT(&right) = VT_I8;
8507 hres = pVarImp(&cy, &cy, &result);
8508 ok(hres == S_OK && V_VT(&result) == VT_I4,
8509 "VARIMP: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8510 S_OK, hres, vtstr(V_VT(&result)));
8511 ok(hres == S_OK && V_I4(&result) == -1,
8512 "VARIMP: CY value %d, expected %d\n", V_I4(&result), -1);
8514 if (HAVE_OLEAUT32_I8)
8516 hres = pVarImp(&cy, &right, &result);
8517 ok(hres == S_OK && V_VT(&result) == VT_I8,
8518 "VARIMP: expected coerced hres 0x%X type VT_I8, got hres 0x%X type %s!\n",
8519 S_OK, hres, vtstr(V_VT(&result)));
8520 ok(hres == S_OK && V_I8(&result) == -2,
8521 "VARIMP: CY value %x%08x, expected %d\n",
8522 (DWORD)((V_I8(&result)) >> 32), (DWORD)(V_I8(&result)), -2);
8525 hres = pVarImp(&left, &cy, &result);
8526 ok(hres == S_OK && V_VT(&result) == VT_I4,
8527 "VARIMP: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8528 S_OK, hres, vtstr(V_VT(&result)));
8529 ok(hres == S_OK && V_I4(&result) == -1,
8530 "VARIMP: CY value %d, expected %d\n", V_I4(&result), -1);
8532 hres = pVarImp(&left, &dec, &result);
8533 ok(hres == S_OK && V_VT(&result) == VT_I4,
8534 "VARIMP: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8535 S_OK, hres, vtstr(V_VT(&result)));
8536 ok(hres == S_OK && V_I4(&result) == -1,
8537 "VARIMP: DECIMAL value %d, expected %d\n", V_I4(&result), -1);
8539 hres = pVarImp(&dec, &dec, &result);
8540 ok(hres == S_OK && V_VT(&result) == VT_I4,
8541 "VARIMP: expected coerced hres 0x%X type VT_I4, got hres 0x%X type %s!\n",
8542 S_OK, hres, vtstr(V_VT(&result)));
8543 ok(hres == S_OK && V_I4(&result) == -1,
8544 "VARIMP: DECIMAL value %d, expected %d\n", V_I4(&result), -1);
8546 if (HAVE_OLEAUT32_I8)
8548 hres = pVarImp(&dec, &right, &result);
8549 ok(hres == S_OK && V_VT(&result) == VT_I8,
8550 "VARIMP: expected coerced hres 0x%X type VT_I8, got hres 0x%X type %s!\n",
8551 S_OK, hres, vtstr(V_VT(&result)));
8552 ok(hres == S_OK && V_I8(&result) == -3,
8553 "VARIMP: DECIMAL value 0x%x%08x, expected %d\n",
8554 (DWORD)(V_I8(&result) >>32), (DWORD)V_I8(&result), -3);
8557 SysFreeString(false_str);
8558 SysFreeString(true_str);
8566 test_VariantClear();
8568 test_VariantCopyInd();
8569 test_VarParseNumFromStr();
8570 test_VarNumFromParseNum();
8571 test_VarUdateFromDate();
8572 test_VarDateFromUdate();
8573 test_SystemTimeToVariantTime();
8574 test_VariantTimeToSystemTime();
8575 test_DosDateTimeToVariantTime();
8576 test_VariantTimeToDosDateTime();