sync oleaut32 winetest with wine 1.1.28
authorChristoph von Wittich <christoph_vw@reactos.org>
Sat, 22 Aug 2009 17:05:58 +0000 (17:05 +0000)
committerChristoph von Wittich <christoph_vw@reactos.org>
Sat, 22 Aug 2009 17:05:58 +0000 (17:05 +0000)
svn path=/trunk/; revision=42857

rostests/winetests/oleaut32/tmarshal.c
rostests/winetests/oleaut32/tmarshal.idl
rostests/winetests/oleaut32/tmarshal_dispids.h
rostests/winetests/oleaut32/typelib.c
rostests/winetests/oleaut32/usrmarshal.c
rostests/winetests/oleaut32/varformat.c
rostests/winetests/oleaut32/vartest.c
rostests/winetests/oleaut32/vartype.c

index a9392c5..f79fbc6 100644 (file)
@@ -44,82 +44,6 @@ const MYSTRUCT MYSTRUCT_ARRAY[5] = {
     {0x5a5b5c5d, ULL_CONST(0x5e5f5051, 0x52535455)},
 };
 
-/* Debugging functions from wine/libs/wine/debug.c */
-
-/* allocate some tmp string space */
-/* FIXME: this is not 100% thread-safe */
-static char *get_tmp_space( int size )
-{
-    static char *list[32];
-    static long pos;
-    char *ret;
-    int idx;
-
-    idx = ++pos % (sizeof(list)/sizeof(list[0]));
-    if ((ret = realloc( list[idx], size ))) list[idx] = ret;
-    return ret;
-}
-
-/* default implementation of wine_dbgstr_wn */
-static const char *default_dbgstr_wn( const WCHAR *str, int n )
-{
-    char *dst, *res;
-
-    if (!HIWORD(str))
-    {
-        if (!str) return "(null)";
-        res = get_tmp_space( 6 );
-        sprintf( res, "#%04x", LOWORD(str) );
-        return res;
-    }
-    if (n == -1) n = lstrlenW(str);
-    if (n < 0) n = 0;
-    else if (n > 200) n = 200;
-    dst = res = get_tmp_space( n * 5 + 7 );
-    *dst++ = 'L';
-    *dst++ = '"';
-    while (n-- > 0)
-    {
-        WCHAR c = *str++;
-        switch (c)
-        {
-        case '\n': *dst++ = '\\'; *dst++ = 'n'; break;
-        case '\r': *dst++ = '\\'; *dst++ = 'r'; break;
-        case '\t': *dst++ = '\\'; *dst++ = 't'; break;
-        case '"':  *dst++ = '\\'; *dst++ = '"'; break;
-        case '\\': *dst++ = '\\'; *dst++ = '\\'; break;
-        default:
-            if (c >= ' ' && c <= 126)
-                *dst++ = (char)c;
-            else
-            {
-                *dst++ = '\\';
-                sprintf(dst,"%04x",c);
-                dst+=4;
-            }
-        }
-    }
-    *dst++ = '"';
-    if (*str)
-    {
-        *dst++ = '.';
-        *dst++ = '.';
-        *dst++ = '.';
-    }
-    *dst = 0;
-    return res;
-}
-
-const char *wine_dbgstr_wn( const WCHAR *s, int n )
-{
-    return default_dbgstr_wn(s, n);
-}
-
-const char *wine_dbgstr_w( const WCHAR *s )
-{
-    return default_dbgstr_wn( s, -1 );
-}
-
 
 #define RELEASEMARSHALDATA WM_USER
 
@@ -620,6 +544,40 @@ static HRESULT WINAPI Widget_CloneInterface(
     return S_OK;
 }
 
+static HRESULT WINAPI Widget_put_prop_with_lcid(
+    IWidget* iface, LONG lcid, INT i)
+{
+    trace("put_prop_with_lcid(%08x, %x)\n", lcid, i);
+    ok(lcid == MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), "got lcid %08x\n", lcid);
+    ok(i == 0xcafe, "got %08x\n", i);
+    return S_OK;
+}
+
+static HRESULT WINAPI Widget_get_prop_with_lcid(
+    IWidget* iface, LONG lcid, INT *i)
+{
+    trace("get_prop_with_lcid(%08x, %p)\n", lcid, i);
+    ok(lcid == MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), "got lcid %08x\n", lcid);
+    *i = lcid;
+    return S_OK;
+}
+
+static HRESULT WINAPI Widget_get_prop_int(
+    IWidget* iface, INT *i)
+{
+    trace("get_prop_int(%p)\n", i);
+    *i = -13;
+    return S_OK;
+}
+
+static HRESULT WINAPI Widget_get_prop_uint(
+    IWidget* iface, UINT *i)
+{
+    trace("get_prop_uint(%p)\n", i);
+    *i = 42;
+    return S_OK;
+}
+
 static const struct IWidgetVtbl Widget_VTable =
 {
     Widget_QueryInterface,
@@ -647,7 +605,11 @@ static const struct IWidgetVtbl Widget_VTable =
     Widget_VarArg,
     Widget_StructArgs,
     Widget_Error,
-    Widget_CloneInterface
+    Widget_CloneInterface,
+    Widget_put_prop_with_lcid,
+    Widget_get_prop_with_lcid,
+    Widget_get_prop_int,
+    Widget_get_prop_uint
 };
 
 static HRESULT WINAPI StaticWidget_QueryInterface(IStaticWidget *iface, REFIID riid, void **ppvObject)
@@ -1324,6 +1286,59 @@ static void test_typelibmarshal(void)
     hr = IDispatch_Invoke(pDispatch, DISPID_TM_STATE, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_PROPERTYGET, &dispparams, &varresult, &excepinfo, NULL);
     ok(hr == DISP_E_NOTACOLLECTION, "IDispatch_Invoke should have returned DISP_E_NOTACOLLECTION instead of 0x%08x\n", hr);
 
+    /* test propput with lcid */
+
+    /* the lcid passed to the function is the first lcid in the typelib header.
+       Since we don't explicitly set an lcid in the idl, it'll default to US English. */
+    VariantInit(&vararg[0]);
+    V_VT(&vararg[0]) = VT_I4;
+    V_I4(&vararg[0]) = 0xcafe;
+    dispparams.cNamedArgs = 1;
+    dispparams.rgdispidNamedArgs = &dispidNamed;
+    dispparams.cArgs = 1;
+    dispparams.rgvarg = vararg;
+    VariantInit(&varresult);
+    hr = IDispatch_Invoke(pDispatch, DISPID_TM_PROP_WITH_LCID, &IID_NULL, 0x40c, DISPATCH_PROPERTYPUT, &dispparams, &varresult, &excepinfo, NULL);
+todo_wine
+    ok_ole_success(hr, ITypeInfo_Invoke);
+    VariantClear(&varresult);
+
+    /* test propget with lcid */
+    dispparams.cNamedArgs = 0;
+    dispparams.cArgs = 0;
+    dispparams.rgvarg = NULL;
+    dispparams.rgdispidNamedArgs = NULL;
+    hr = IDispatch_Invoke(pDispatch, DISPID_TM_PROP_WITH_LCID, &IID_NULL, 0x40c, DISPATCH_PROPERTYGET, &dispparams, &varresult, &excepinfo, NULL);
+todo_wine
+{
+    ok_ole_success(hr, ITypeInfo_Invoke);
+    ok(V_VT(&varresult) == VT_I4, "got %x\n", V_VT(&varresult));
+    ok(V_I4(&varresult) == 0x409, "got %x\n", V_I4(&varresult));
+}
+    VariantClear(&varresult);
+
+    /* test propget of INT value */
+    dispparams.cNamedArgs = 0;
+    dispparams.cArgs = 0;
+    dispparams.rgvarg = NULL;
+    dispparams.rgdispidNamedArgs = NULL;
+    hr = IDispatch_Invoke(pDispatch, DISPID_TM_PROP_INT, &IID_NULL, 0x40c, DISPATCH_PROPERTYGET, &dispparams, &varresult, &excepinfo, NULL);
+    ok_ole_success(hr, ITypeInfo_Invoke);
+    ok(V_VT(&varresult) == VT_I4, "got %x\n", V_VT(&varresult));
+    ok(V_I4(&varresult) == -13, "got %x\n", V_I4(&varresult));
+    VariantClear(&varresult);
+
+    /* test propget of INT value */
+    dispparams.cNamedArgs = 0;
+    dispparams.cArgs = 0;
+    dispparams.rgvarg = NULL;
+    dispparams.rgdispidNamedArgs = NULL;
+    hr = IDispatch_Invoke(pDispatch, DISPID_TM_PROP_UINT, &IID_NULL, 0x40c, DISPATCH_PROPERTYGET, &dispparams, &varresult, &excepinfo, NULL);
+    ok_ole_success(hr, ITypeInfo_Invoke);
+    ok(V_VT(&varresult) == VT_UI4, "got %x\n", V_VT(&varresult));
+    ok(V_UI4(&varresult) == 42, "got %x\n", V_UI4(&varresult));
+    VariantClear(&varresult);
+
     IDispatch_Release(pDispatch);
     IWidget_Release(pWidget);
 
@@ -1352,7 +1367,7 @@ static void test_DispCallFunc(void)
     V_VT(&varref) = VT_ERROR;
     V_ERROR(&varref) = DISP_E_PARAMNOTFOUND;
     VariantInit(&varresult);
-    hr = DispCallFunc(pWidget, 36, CC_STDCALL, VT_UI4, 4, rgvt, rgpvarg, &varresult);
+    hr = DispCallFunc(pWidget, 9*sizeof(void*), CC_STDCALL, VT_UI4, 4, rgvt, rgpvarg, &varresult);
     ok_ole_success(hr, DispCallFunc);
     VariantClear(&varresult);
     VariantClear(&vararg[1]);
@@ -1401,7 +1416,8 @@ START_TEST(tmarshal)
     test_DispCallFunc();
     test_StaticWidget();
 
-    hr = UnRegisterTypeLib(&LIBID_TestTypelib, 1, 0, LOCALE_NEUTRAL, 1);
+    hr = UnRegisterTypeLib(&LIBID_TestTypelib, 1, 0, LOCALE_NEUTRAL,
+                           sizeof(void*) == 8 ? SYS_WIN64 : SYS_WIN32);
     ok_ole_success(hr, UnRegisterTypeLib);
 
     CoUninitialize();
index 2b57ddd..f9b18b8 100644 (file)
@@ -125,6 +125,18 @@ library TestTypelib
 
         [propget, id(DISPID_TM_CLONEINTERFACE)]
         HRESULT CloneInterface([out, retval] ISomethingFromDispatch **ppVal);
+
+        [id(DISPID_TM_PROP_WITH_LCID), propput]
+        HRESULT prop_with_lcid([in,lcid] long lcid, [in] INT i);
+
+        [id(DISPID_TM_PROP_WITH_LCID), propget]
+        HRESULT prop_with_lcid([in,lcid] long lcid, [out,retval] INT *i);
+
+        [id(DISPID_TM_PROP_INT), propget]
+        HRESULT prop_int([out,retval] INT *i);
+
+        [id(DISPID_TM_PROP_UINT), propget]
+        HRESULT prop_uint([out,retval] UINT *i);
     }
 
     [
index 8fcf109..08d7736 100644 (file)
@@ -34,5 +34,8 @@
 #define DISPID_TM_CLONEINTERFACE 15
 #define DISPID_TM_TESTDUAL 16
 #define DISPID_TM_STRUCTARGS 17
+#define DISPID_TM_PROP_WITH_LCID 18
+#define DISPID_TM_PROP_INT 19
+#define DISPID_TM_PROP_UINT 20
 
 #define DISPID_NOA_BSTRRET 1
index 277e97d..2748ed0 100644 (file)
@@ -33,8 +33,8 @@
 #include "tmarshal.h"
 
 #define expect_eq(expr, value, type, format) { type _ret = (expr); ok((value) == _ret, #expr " expected " format " got " format "\n", value, _ret); }
-#define expect_int(expr, value) expect_eq(expr, (int)value, int, "%d")
-#define expect_hex(expr, value) expect_eq(expr, (int)value, int, "0x%x")
+#define expect_int(expr, value) expect_eq(expr, (int)(value), int, "%d")
+#define expect_hex(expr, value) expect_eq(expr, (int)(value), int, "0x%x")
 #define expect_null(expr) expect_eq(expr, NULL, const void *, "%p")
 
 #define expect_wstr_acpval(expr, value) \
@@ -1090,7 +1090,7 @@ typedef struct _function_info
     CALLCONV callconv;
     short cParams;
     short cParamsOpt;
-    short oVft;
+    short vtbl_index;
     short cScodes;
     WORD wFuncFlags;
     element_info ret_type;
@@ -1115,7 +1115,7 @@ static const interface_info info[] = {
 {
   "IDualIface",
   /*kind*/ TKIND_DISPATCH, /*flags*/ 0x1040, /*align*/ 4, /*size*/ 4,
-  /*#vtbl*/ 28, /*#func*/ 8,
+  /*#vtbl*/ 7, /*#func*/ 8,
   {
     {
       0x60000000, /*func*/ FUNC_DISPATCH, /*inv*/ INVOKE_FUNC, /*call*/ 0x4,
@@ -1135,7 +1135,7 @@ static const interface_info info[] = {
     },
     {
       0x60000001, /*func*/ FUNC_DISPATCH, /*inv*/ INVOKE_FUNC, /*call*/ 0x4,
-      /*#param*/ 0, /*#opt*/ 0, /*vtbl*/ 4, /*#scodes*/ 0, /*flags*/ 0x1,
+      /*#param*/ 0, /*#opt*/ 0, /*vtbl*/ 1, /*#scodes*/ 0, /*flags*/ 0x1,
       {19, 0}, /* ret */
       { /* params */
         {-1, -1}
@@ -1147,7 +1147,7 @@ static const interface_info info[] = {
     },
     {
       0x60000002, /*func*/ FUNC_DISPATCH, /*inv*/ INVOKE_FUNC, /*call*/ 0x4,
-      /*#param*/ 0, /*#opt*/ 0, /*vtbl*/ 8, /*#scodes*/ 0, /*flags*/ 0x1,
+      /*#param*/ 0, /*#opt*/ 0, /*vtbl*/ 2, /*#scodes*/ 0, /*flags*/ 0x1,
       {19, 0}, /* ret */
       { /* params */
         {-1, -1}
@@ -1159,7 +1159,7 @@ static const interface_info info[] = {
     },
     {
       0x60010000, /*func*/ FUNC_DISPATCH, /*inv*/ INVOKE_FUNC, /*call*/ 0x4,
-      /*#param*/ 1, /*#opt*/ 0, /*vtbl*/ 12, /*#scodes*/ 0, /*flags*/ 0x1,
+      /*#param*/ 1, /*#opt*/ 0, /*vtbl*/ 3, /*#scodes*/ 0, /*flags*/ 0x1,
       {24, 0}, /* ret */
       { /* params */
         {26, 2},
@@ -1173,7 +1173,7 @@ static const interface_info info[] = {
     },
     {
       0x60010001, /*func*/ FUNC_DISPATCH, /*inv*/ INVOKE_FUNC, /*call*/ 0x4,
-      /*#param*/ 3, /*#opt*/ 0, /*vtbl*/ 16, /*#scodes*/ 0, /*flags*/ 0x1,
+      /*#param*/ 3, /*#opt*/ 0, /*vtbl*/ 4, /*#scodes*/ 0, /*flags*/ 0x1,
       {24, 0}, /* ret */
       { /* params */
         {23, 1},
@@ -1191,7 +1191,7 @@ static const interface_info info[] = {
     },
     {
       0x60010002, /*func*/ FUNC_DISPATCH, /*inv*/ INVOKE_FUNC, /*call*/ 0x4,
-      /*#param*/ 5, /*#opt*/ 0, /*vtbl*/ 20, /*#scodes*/ 0, /*flags*/ 0x1,
+      /*#param*/ 5, /*#opt*/ 0, /*vtbl*/ 5, /*#scodes*/ 0, /*flags*/ 0x1,
       {24, 0}, /* ret */
       { /* params */
         {26, 1},
@@ -1213,7 +1213,7 @@ static const interface_info info[] = {
     },
     {
       0x60010003, /*func*/ FUNC_DISPATCH, /*inv*/ INVOKE_FUNC, /*call*/ 0x4,
-      /*#param*/ 8, /*#opt*/ 0, /*vtbl*/ 24, /*#scodes*/ 0, /*flags*/ 0x1,
+      /*#param*/ 8, /*#opt*/ 0, /*vtbl*/ 6, /*#scodes*/ 0, /*flags*/ 0x1,
       {24, 0}, /* ret */
       { /* params */
         {3, 1},
@@ -1241,7 +1241,7 @@ static const interface_info info[] = {
     },
     {
       0x60020000, /*func*/ FUNC_DISPATCH, /*inv*/ INVOKE_FUNC, /*call*/ 0x4,
-      /*#param*/ 0, /*#opt*/ 0, /*vtbl*/ 28, /*#scodes*/ 0, /*flags*/ 0x0,
+      /*#param*/ 0, /*#opt*/ 0, /*vtbl*/ 7, /*#scodes*/ 0, /*flags*/ 0x0,
       {24, 0}, /* ret */
       { /* params */
         {-1, -1}
@@ -1256,11 +1256,11 @@ static const interface_info info[] = {
 {
   "ISimpleIface",
   /*kind*/ TKIND_INTERFACE, /*flags*/ 0x1000, /*align*/ 4, /*size*/ 4,
-  /*#vtbl*/ 32, /*#func*/ 1,
+  /*#vtbl*/ 8, /*#func*/ 1,
   {
     {
       0x60020000, /*func*/ FUNC_PUREVIRTUAL, /*inv*/ INVOKE_FUNC, /*call*/ 0x4,
-      /*#param*/ 0, /*#opt*/ 0, /*vtbl*/ 28, /*#scodes*/ 0, /*flags*/ 0x0,
+      /*#param*/ 0, /*#opt*/ 0, /*vtbl*/ 7, /*#scodes*/ 0, /*flags*/ 0x0,
       {25, 0}, /* ret */
       { /* params */
         {-1, -1}
@@ -1307,7 +1307,7 @@ static void test_dump_typelib(const char *name)
         expect_hex(typeattr->wTypeFlags, if_info->wTypeFlags);
         expect_int(typeattr->cbAlignment, if_info->cbAlignment);
         expect_int(typeattr->cbSizeInstance, if_info->cbSizeInstance);
-        expect_int(typeattr->cbSizeVft, if_info->cbSizeVft);
+        expect_int(typeattr->cbSizeVft, if_info->cbSizeVft * sizeof(void*));
         expect_int(typeattr->cFuncs, if_info->cFuncs);
 
         for (func = 0; func < typeattr->cFuncs; func++)
@@ -1326,7 +1326,9 @@ static void test_dump_typelib(const char *name)
             expect_int(desc->callconv, fn_info->callconv);
             expect_int(desc->cParams, fn_info->cParams);
             expect_int(desc->cParamsOpt, fn_info->cParamsOpt);
-            expect_int(desc->oVft, fn_info->oVft);
+            ok( desc->oVft == fn_info->vtbl_index * sizeof(void*) ||
+                broken(desc->oVft == fn_info->vtbl_index * 4), /* xp64 */
+                "desc->oVft got %u\n", desc->oVft );
             expect_int(desc->cScodes, fn_info->cScodes);
             expect_int(desc->wFuncFlags, fn_info->wFuncFlags);
             ole_check(ITypeInfo_GetNames(typeinfo, desc->memid, namesTab, 256, &cNames));
@@ -1376,6 +1378,58 @@ static const char *create_test_typelib(void)
     return filename;
 }
 
+static void test_create_typelib_lcid(LCID lcid)
+{
+    char filename[MAX_PATH];
+    WCHAR name[MAX_PATH];
+    HRESULT hr;
+    ICreateTypeLib2 *tl;
+    HANDLE file;
+    DWORD msft_header[5]; /* five is enough for now */
+    DWORD read;
+
+    GetTempFileNameA( ".", "tlb", 0, filename );
+    MultiByteToWideChar(CP_ACP, 0, filename, -1, name, MAX_PATH);
+
+    hr = CreateTypeLib2(SYS_WIN32, name, &tl);
+    ok(hr == S_OK, "got %08x\n", hr);
+
+    hr = ICreateTypeLib2_SetLcid(tl, lcid);
+    ok(hr == S_OK, "got %08x\n", hr);
+
+    hr = ICreateTypeLib2_SaveAllChanges(tl);
+    ICreateTypeLib2_Release(tl);
+
+    file = CreateFileA( filename, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, 0 );
+    ok( file != INVALID_HANDLE_VALUE, "file creation failed\n" );
+
+    ReadFile( file, msft_header, sizeof(msft_header), &read, NULL );
+    ok(read == sizeof(msft_header), "read %d\n", read);
+    CloseHandle( file );
+
+    ok(msft_header[0] == 0x5446534d, "got %08x\n", msft_header[0]);
+    ok(msft_header[1] == 0x00010002, "got %08x\n", msft_header[1]);
+    ok(msft_header[2] == 0xffffffff, "got %08x\n", msft_header[2]);
+    ok(msft_header[3] == (lcid ? lcid : 0x409), "got %08x (lcid %08x)\n", msft_header[3], lcid);
+    ok(msft_header[4] == lcid, "got %08x (lcid %08x)\n", msft_header[4], lcid);
+
+    DeleteFileA(filename);
+}
+
+static void test_create_typelibs(void)
+{
+    test_create_typelib_lcid(LOCALE_SYSTEM_DEFAULT);
+    test_create_typelib_lcid(LOCALE_USER_DEFAULT);
+    test_create_typelib_lcid(LOCALE_NEUTRAL);
+
+    test_create_typelib_lcid(0x009);
+    test_create_typelib_lcid(0x409);
+    test_create_typelib_lcid(0x809);
+
+    test_create_typelib_lcid(0x007);
+    test_create_typelib_lcid(0x407);
+}
+
 START_TEST(typelib)
 {
     const char *filename;
@@ -1392,4 +1446,7 @@ START_TEST(typelib)
         test_dump_typelib( filename );
         DeleteFile( filename );
     }
+
+    test_create_typelibs();
+
 }
index 38827b1..d180946 100644 (file)
@@ -118,7 +118,7 @@ static void check_safearray(void *buffer, LPSAFEARRAY lpsa)
 
     if(!lpsa)
     {
-        ok(*(void **)wiresa == NULL, "wiresa + 0x0 should be NULL instead of 0x%08x\n", *(DWORD *)wiresa);
+        ok(*(DWORD *)wiresa == 0, "wiresa + 0x0 should be NULL instead of 0x%08x\n", *(DWORD *)wiresa);
         return;
     }
 
@@ -134,19 +134,19 @@ static void check_safearray(void *buffer, LPSAFEARRAY lpsa)
     wiresa += sizeof(DWORD);
     ok(*(WORD *)wiresa == lpsa->cDims, "wiresa + 0x8 should be lpsa->cDims instead of 0x%04x\n", *(WORD *)wiresa);
     wiresa += sizeof(WORD);
-    ok(*(WORD *)wiresa == lpsa->fFeatures, "wiresa + 0xc should be lpsa->fFeatures instead of 0x%08x\n", *(WORD *)wiresa);
+    ok(*(WORD *)wiresa == lpsa->fFeatures, "wiresa + 0xa should be lpsa->fFeatures instead of 0x%08x\n", *(WORD *)wiresa);
     wiresa += sizeof(WORD);
-    ok(*(DWORD *)wiresa == lpsa->cbElements, "wiresa + 0x10 should be lpsa->cbElements instead of 0x%08x\n", *(DWORD *)wiresa);
+    ok(*(DWORD *)wiresa == lpsa->cbElements, "wiresa + 0xc should be lpsa->cbElements instead of 0x%08x\n", *(DWORD *)wiresa);
     wiresa += sizeof(DWORD);
-    ok(*(WORD *)wiresa == lpsa->cLocks, "wiresa + 0x16 should be lpsa->cLocks instead of 0x%04x\n", *(WORD *)wiresa);
+    ok(*(WORD *)wiresa == lpsa->cLocks, "wiresa + 0x10 should be lpsa->cLocks instead of 0x%04x\n", *(WORD *)wiresa);
     wiresa += sizeof(WORD);
-    ok(*(WORD *)wiresa == vt, "wiresa + 0x14 should be %04x instead of 0x%04x\n", vt, *(WORD *)wiresa);
+    ok(*(WORD *)wiresa == vt, "wiresa + 0x12 should be %04x instead of 0x%04x\n", vt, *(WORD *)wiresa);
     wiresa += sizeof(WORD);
-    ok(*(DWORD *)wiresa == sftype, "wiresa + 0x18 should be %08x instead of 0x%08x\n", (DWORD)sftype, *(DWORD *)wiresa);
+    ok(*(DWORD *)wiresa == sftype, "wiresa + 0x14 should be %08x instead of 0x%08x\n", (DWORD)sftype, *(DWORD *)wiresa);
     wiresa += sizeof(DWORD);
-    ok(*(DWORD *)wiresa == cell_count, "wiresa + 0x1c should be %u instead of %u\n", cell_count, *(DWORD *)wiresa);
+    ok(*(DWORD *)wiresa == cell_count, "wiresa + 0x18 should be %u instead of %u\n", cell_count, *(DWORD *)wiresa);
     wiresa += sizeof(DWORD);
-    ok(*(DWORD *)wiresa, "wiresa + 0x20 should be non-zero instead of 0x%08x\n", *(DWORD *)wiresa);
+    ok(*(DWORD *)wiresa, "wiresa + 0x1c should be non-zero instead of 0x%08x\n", *(DWORD *)wiresa);
     wiresa += sizeof(DWORD);
     if(sftype == SF_HAVEIID)
     {
@@ -158,7 +158,7 @@ static void check_safearray(void *buffer, LPSAFEARRAY lpsa)
     ok(!memcmp(wiresa, lpsa->rgsabound, sizeof(lpsa->rgsabound[0]) * lpsa->cDims), "bounds mismatch\n");
     wiresa += sizeof(lpsa->rgsabound[0]) * lpsa->cDims;
 
-    ok(*(DWORD *)wiresa == cell_count, "wiresa + 0x2c should be %u instead of %u\n", cell_count, *(DWORD*)wiresa);
+    ok(*(DWORD *)wiresa == cell_count, "wiresa + 0x28 should be %u instead of %u\n", cell_count, *(DWORD*)wiresa);
     wiresa += sizeof(DWORD);
     /* elements are now pointed to by wiresa */
 }
@@ -198,7 +198,7 @@ static void init_user_marshal_cb(USER_MARSHAL_CB *umcb,
 static void test_marshal_LPSAFEARRAY(void)
 {
     unsigned char *buffer;
-    ULONG size;
+    ULONG size, expected;
     LPSAFEARRAY lpsa;
     LPSAFEARRAY lpsa2 = NULL;
     SAFEARRAYBOUND sab;
@@ -217,10 +217,15 @@ static void test_marshal_LPSAFEARRAY(void)
     lpsa->cLocks = 7;
     init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, NULL, 0, MSHCTX_DIFFERENTMACHINE);
     size = LPSAFEARRAY_UserSize(&umcb.Flags, 1, &lpsa);
-    ok(size == 68, "size should be 68 bytes, not %d\n", size);
+    expected = (44 + 1 + sizeof(ULONG) - 1) & ~(sizeof(ULONG) - 1);
+    expected += sab.cElements * sizeof(USHORT);
+    ok(size == expected || size == expected + 12, /* win64 */
+       "size should be %u bytes, not %u\n", expected, size);
     init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, NULL, 0, MSHCTX_DIFFERENTMACHINE);
     size = LPSAFEARRAY_UserSize(&umcb.Flags, 0, &lpsa);
-    ok(size == 64, "size should be 64 bytes, not %d\n", size);
+    expected = 44 + sab.cElements * sizeof(USHORT);
+    ok(size == expected || size == expected + 12, /* win64 */
+       "size should be %u bytes, not %u\n", expected, size);
     buffer = HeapAlloc(GetProcessHeap(), 0, size);
     init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, buffer, size, MSHCTX_DIFFERENTMACHINE);
     LPSAFEARRAY_UserMarshal(&umcb.Flags, buffer, &lpsa);
@@ -273,10 +278,16 @@ static void test_marshal_LPSAFEARRAY(void)
     lpsa->cLocks = 7;
     init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, NULL, 0, MSHCTX_DIFFERENTMACHINE);
     size = LPSAFEARRAY_UserSize(&umcb.Flags, 1, &lpsa);
-    ok(size == 128, "size should be 128 bytes, not %d\n", size);
+    expected = (44 + 1 + (sizeof(double) - 1)) & ~(sizeof(double) - 1);
+    expected += sab.cElements * sizeof(double);
+    ok(size == expected || size == expected + 16, /* win64 */
+       "size should be %u bytes, not %u\n", expected, size);
     init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, NULL, 0, MSHCTX_DIFFERENTMACHINE);
+    expected = (44 + (sizeof(double) - 1)) & ~(sizeof(double) - 1);
+    expected += sab.cElements * sizeof(double);
     size = LPSAFEARRAY_UserSize(&umcb.Flags, 0, &lpsa);
-    ok(size == 128, "size should be 128 bytes, not %d\n", size);
+    ok(size == expected || size == expected + 8, /* win64 */
+       "size should be %u bytes, not %u\n", expected, size);
     buffer = HeapAlloc(GetProcessHeap(), 0, size);
     init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, buffer, size, MSHCTX_DIFFERENTMACHINE);
     LPSAFEARRAY_UserMarshal(&umcb.Flags, buffer, &lpsa);
@@ -301,7 +312,10 @@ static void test_marshal_LPSAFEARRAY(void)
 
     init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, NULL, 0, MSHCTX_DIFFERENTMACHINE);
     size = LPSAFEARRAY_UserSize(&umcb.Flags, 0, &lpsa);
-    ok(size == 432, "size %d\n", size);
+    expected = (44 + lpsa->cbElements - 1) & ~(lpsa->cbElements - 1);
+    expected += lpsa->cbElements * lpsa->rgsabound[0].cElements;
+    ok(size == expected || size == expected + 8,  /* win64 */
+       "size should be %u bytes, not %u\n", expected, size);
     buffer = HeapAlloc(GetProcessHeap(), 0, size);
     init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, buffer, size, MSHCTX_DIFFERENTMACHINE);
     LPSAFEARRAY_UserMarshal(&umcb.Flags, buffer, &lpsa);
@@ -313,7 +327,7 @@ static void test_marshal_LPSAFEARRAY(void)
     /* VARTYPE-less arrays with FADF_VARIANT */
     hr = SafeArrayAllocDescriptor(1, &lpsa);
     ok(hr == S_OK, "saad failed %08x\n", hr);
-    lpsa->cbElements = 16;
+    lpsa->cbElements = sizeof(VARIANT);
     lpsa->fFeatures = FADF_VARIANT;
     lpsa->rgsabound[0].lLbound = 2;
     lpsa->rgsabound[0].cElements = 48;
@@ -325,11 +339,14 @@ static void test_marshal_LPSAFEARRAY(void)
 
     init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, NULL, 0, MSHCTX_DIFFERENTMACHINE);
     size = LPSAFEARRAY_UserSize(&umcb.Flags, 0, &lpsa);
+    expected = 44 + 28 * lpsa->rgsabound[0].cElements;
     todo_wine
-    ok(size == 1388, "size %d\n", size);
+    ok(size == expected || size == expected + 8,  /* win64 */
+       "size should be %u bytes, not %u\n", expected, size);
     buffer = HeapAlloc(GetProcessHeap(), 0, size);
     init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, buffer, size, MSHCTX_DIFFERENTMACHINE);
     LPSAFEARRAY_UserMarshal(&umcb.Flags, buffer, &lpsa);
+    lpsa->cbElements = 16;  /* VARIANT wire size */
     check_safearray(buffer, lpsa);
     HeapFree(GetProcessHeap(), 0, buffer);
     SafeArrayDestroyData(lpsa);
@@ -555,6 +572,15 @@ static void check_variant_header(DWORD *wirev, VARIANT *v, ULONG size)
     ok(*wirev == switch_is, "switch_is %08x expected %08x\n", *wirev, switch_is);
 }
 
+/* Win9x and WinME don't always align as needed. Variants have
+ * an alignment of 8.
+ */
+static void *alloc_aligned(SIZE_T size, void **buf)
+{
+    *buf = HeapAlloc(GetProcessHeap(), 0, size + 7);
+    return (void *)(((UINT_PTR)*buf + 7) & ~7);
+}
+
 static void test_marshal_VARIANT(void)
 {
     VARIANT v, v2;
@@ -562,6 +588,7 @@ static void test_marshal_VARIANT(void)
     RPC_MESSAGE rpcMsg = { 0 };
     USER_MARSHAL_CB umcb = { 0 };
     unsigned char *buffer, *next;
+    void *oldbuffer;
     ULONG ul;
     short s;
     double d;
@@ -572,6 +599,7 @@ static void test_marshal_VARIANT(void)
     LPSAFEARRAY lpsa;
     DECIMAL dec, dec2;
     HeapUnknown *heap_unknown;
+    DWORD expected;
 
     stubMsg.RpcMsg = &rpcMsg;
 
@@ -600,7 +628,7 @@ static void test_marshal_VARIANT(void)
     rpcMsg.BufferLength = stubMsg.BufferLength = VARIANT_UserSize(&umcb.Flags, 0, &v);
     ok(stubMsg.BufferLength == 21, "size %d\n", stubMsg.BufferLength);
 
-    buffer = rpcMsg.Buffer = stubMsg.Buffer = stubMsg.BufferStart = HeapAlloc(GetProcessHeap(), 0, stubMsg.BufferLength);
+    buffer = rpcMsg.Buffer = stubMsg.Buffer = stubMsg.BufferStart = alloc_aligned(stubMsg.BufferLength, &oldbuffer);
     stubMsg.BufferEnd = stubMsg.Buffer + stubMsg.BufferLength;
     next = VARIANT_UserMarshal(&umcb.Flags, buffer, &v);
     ok(next == buffer + stubMsg.BufferLength, "got %p expect %p\n", next, buffer + stubMsg.BufferLength);
@@ -620,7 +648,7 @@ static void test_marshal_VARIANT(void)
 
         VARIANT_UserFree(&umcb.Flags, &v2);
     }
-    HeapFree(GetProcessHeap(), 0, buffer);
+    HeapFree(GetProcessHeap(), 0, oldbuffer);
 
     /*** I2 ***/
     VariantInit(&v);
@@ -630,7 +658,7 @@ static void test_marshal_VARIANT(void)
     rpcMsg.BufferLength = stubMsg.BufferLength = VARIANT_UserSize(&umcb.Flags, 0, &v);
     ok(stubMsg.BufferLength == 22, "size %d\n", stubMsg.BufferLength);
 
-    buffer = rpcMsg.Buffer = stubMsg.Buffer = stubMsg.BufferStart = HeapAlloc(GetProcessHeap(), 0, stubMsg.BufferLength);
+    buffer = rpcMsg.Buffer = stubMsg.Buffer = stubMsg.BufferStart = alloc_aligned(stubMsg.BufferLength, &oldbuffer);
     stubMsg.BufferEnd = stubMsg.Buffer + stubMsg.BufferLength;
     next = VARIANT_UserMarshal(&umcb.Flags, buffer, &v);
     ok(next == buffer + stubMsg.BufferLength, "got %p expect %p\n", next, buffer + stubMsg.BufferLength);
@@ -650,7 +678,7 @@ static void test_marshal_VARIANT(void)
 
         VARIANT_UserFree(&umcb.Flags, &v2);
     }
-    HeapFree(GetProcessHeap(), 0, buffer);
+    HeapFree(GetProcessHeap(), 0, oldbuffer);
 
     /*** I2 BYREF ***/
     VariantInit(&v);
@@ -661,7 +689,7 @@ static void test_marshal_VARIANT(void)
     rpcMsg.BufferLength = stubMsg.BufferLength = VARIANT_UserSize(&umcb.Flags, 0, &v);
     ok(stubMsg.BufferLength == 26, "size %d\n", stubMsg.BufferLength);
 
-    buffer = rpcMsg.Buffer = stubMsg.Buffer = stubMsg.BufferStart = HeapAlloc(GetProcessHeap(), 0, stubMsg.BufferLength);
+    buffer = rpcMsg.Buffer = stubMsg.Buffer = stubMsg.BufferStart = alloc_aligned(stubMsg.BufferLength, &oldbuffer);
     stubMsg.BufferEnd = stubMsg.Buffer + stubMsg.BufferLength;
     next = VARIANT_UserMarshal(&umcb.Flags, buffer, &v);
     ok(next == buffer + stubMsg.BufferLength, "got %p expect %p\n", next, buffer + stubMsg.BufferLength);
@@ -687,7 +715,7 @@ static void test_marshal_VARIANT(void)
 
         VARIANT_UserFree(&umcb.Flags, &v2);
     }
-    HeapFree(GetProcessHeap(), 0, buffer);
+    HeapFree(GetProcessHeap(), 0, oldbuffer);
 
     /*** I4 ***/
     VariantInit(&v);
@@ -697,7 +725,7 @@ static void test_marshal_VARIANT(void)
     rpcMsg.BufferLength = stubMsg.BufferLength = VARIANT_UserSize(&umcb.Flags, 0, &v);
     ok(stubMsg.BufferLength == 24, "size %d\n", stubMsg.BufferLength);
 
-    buffer = rpcMsg.Buffer = stubMsg.Buffer = stubMsg.BufferStart = HeapAlloc(GetProcessHeap(), 0, stubMsg.BufferLength);
+    buffer = rpcMsg.Buffer = stubMsg.Buffer = stubMsg.BufferStart = alloc_aligned(stubMsg.BufferLength, &oldbuffer);
     stubMsg.BufferEnd = stubMsg.Buffer + stubMsg.BufferLength;
     next = VARIANT_UserMarshal(&umcb.Flags, buffer, &v);
     ok(next == buffer + stubMsg.BufferLength, "got %p expect %p\n", next, buffer + stubMsg.BufferLength);
@@ -718,8 +746,7 @@ static void test_marshal_VARIANT(void)
 
         VARIANT_UserFree(&umcb.Flags, &v2);
     }
-
-    HeapFree(GetProcessHeap(), 0, buffer);
+    HeapFree(GetProcessHeap(), 0, oldbuffer);
 
     /*** UI4 ***/
     VariantInit(&v);
@@ -729,7 +756,7 @@ static void test_marshal_VARIANT(void)
     rpcMsg.BufferLength = stubMsg.BufferLength = VARIANT_UserSize(&umcb.Flags, 0, &v);
     ok(stubMsg.BufferLength == 24, "size %d\n", stubMsg.BufferLength);
 
-    buffer = rpcMsg.Buffer = stubMsg.Buffer = stubMsg.BufferStart = HeapAlloc(GetProcessHeap(), 0, stubMsg.BufferLength);
+    buffer = rpcMsg.Buffer = stubMsg.Buffer = stubMsg.BufferStart = alloc_aligned(stubMsg.BufferLength, &oldbuffer);
     stubMsg.BufferEnd = stubMsg.Buffer + stubMsg.BufferLength;
     next = VARIANT_UserMarshal(&umcb.Flags, buffer, &v);
     ok(next == buffer + stubMsg.BufferLength, "got %p expect %p\n", next, buffer + stubMsg.BufferLength);
@@ -749,8 +776,7 @@ static void test_marshal_VARIANT(void)
 
         VARIANT_UserFree(&umcb.Flags, &v2);
     }
-
-    HeapFree(GetProcessHeap(), 0, buffer);
+    HeapFree(GetProcessHeap(), 0, oldbuffer);
 
     /*** UI4 BYREF ***/
     VariantInit(&v);
@@ -761,7 +787,7 @@ static void test_marshal_VARIANT(void)
     rpcMsg.BufferLength = stubMsg.BufferLength = VARIANT_UserSize(&umcb.Flags, 0, &v);
     ok(stubMsg.BufferLength == 28, "size %d\n", stubMsg.BufferLength);
 
-    buffer = rpcMsg.Buffer = stubMsg.Buffer = stubMsg.BufferStart = HeapAlloc(GetProcessHeap(), 0, stubMsg.BufferLength);
+    buffer = rpcMsg.Buffer = stubMsg.Buffer = stubMsg.BufferStart = alloc_aligned(stubMsg.BufferLength, &oldbuffer);
     stubMsg.BufferEnd = stubMsg.Buffer + stubMsg.BufferLength;
     next = VARIANT_UserMarshal(&umcb.Flags, buffer, &v);
     ok(next == buffer + stubMsg.BufferLength, "got %p expect %p\n", next, buffer + stubMsg.BufferLength);
@@ -784,7 +810,7 @@ static void test_marshal_VARIANT(void)
 
         VARIANT_UserFree(&umcb.Flags, &v2);
     }
-    HeapFree(GetProcessHeap(), 0, buffer);
+    HeapFree(GetProcessHeap(), 0, oldbuffer);
 
     /*** R4 ***/
     VariantInit(&v);
@@ -794,7 +820,7 @@ static void test_marshal_VARIANT(void)
     rpcMsg.BufferLength = stubMsg.BufferLength = VARIANT_UserSize(&umcb.Flags, 0, &v);
     ok(stubMsg.BufferLength == 24, "size %d\n", stubMsg.BufferLength);
 
-    buffer = rpcMsg.Buffer = stubMsg.Buffer = stubMsg.BufferStart = HeapAlloc(GetProcessHeap(), 0, stubMsg.BufferLength);
+    buffer = rpcMsg.Buffer = stubMsg.Buffer = stubMsg.BufferStart = alloc_aligned(stubMsg.BufferLength, &oldbuffer);
     stubMsg.BufferEnd = stubMsg.Buffer + stubMsg.BufferLength;
     next = VARIANT_UserMarshal(&umcb.Flags, buffer, &v);
     ok(next == buffer + stubMsg.BufferLength, "got %p expect %p\n", next, buffer + stubMsg.BufferLength);
@@ -814,7 +840,7 @@ static void test_marshal_VARIANT(void)
 
         VARIANT_UserFree(&umcb.Flags, &v2);
     }
-    HeapFree(GetProcessHeap(), 0, buffer);
+    HeapFree(GetProcessHeap(), 0, oldbuffer);
 
     /*** R8 ***/
     VariantInit(&v);
@@ -824,7 +850,7 @@ static void test_marshal_VARIANT(void)
     rpcMsg.BufferLength = stubMsg.BufferLength = VARIANT_UserSize(&umcb.Flags, 0, &v);
     ok(stubMsg.BufferLength == 32, "size %d\n", stubMsg.BufferLength);
 
-    buffer = rpcMsg.Buffer = stubMsg.Buffer = stubMsg.BufferStart = HeapAlloc(GetProcessHeap(), 0, stubMsg.BufferLength);
+    buffer = rpcMsg.Buffer = stubMsg.Buffer = stubMsg.BufferStart = alloc_aligned(stubMsg.BufferLength, &oldbuffer);
     stubMsg.BufferEnd = stubMsg.Buffer + stubMsg.BufferLength;
     memset(buffer, 0xcc, stubMsg.BufferLength);
     next = VARIANT_UserMarshal(&umcb.Flags, buffer, &v);
@@ -847,7 +873,7 @@ static void test_marshal_VARIANT(void)
 
         VARIANT_UserFree(&umcb.Flags, &v2);
     }
-    HeapFree(GetProcessHeap(), 0, buffer);
+    HeapFree(GetProcessHeap(), 0, oldbuffer);
 
     /*** R8 BYREF ***/
     VariantInit(&v);
@@ -858,7 +884,7 @@ static void test_marshal_VARIANT(void)
     rpcMsg.BufferLength = stubMsg.BufferLength = VARIANT_UserSize(&umcb.Flags, 0, &v);
     ok(stubMsg.BufferLength == 32, "size %d\n", stubMsg.BufferLength);
 
-    buffer = rpcMsg.Buffer = stubMsg.Buffer = stubMsg.BufferStart = HeapAlloc(GetProcessHeap(), 0, stubMsg.BufferLength);
+    buffer = rpcMsg.Buffer = stubMsg.Buffer = stubMsg.BufferStart = alloc_aligned(stubMsg.BufferLength, &oldbuffer);
     stubMsg.BufferEnd = stubMsg.Buffer + stubMsg.BufferLength;
     next = VARIANT_UserMarshal(&umcb.Flags, buffer, &v);
     ok(next == buffer + stubMsg.BufferLength, "got %p expect %p\n", next, buffer + stubMsg.BufferLength);
@@ -880,7 +906,7 @@ static void test_marshal_VARIANT(void)
 
         VARIANT_UserFree(&umcb.Flags, &v2);
     }
-    HeapFree(GetProcessHeap(), 0, buffer);
+    HeapFree(GetProcessHeap(), 0, oldbuffer);
 
     /*** VARIANT_BOOL ***/
     VariantInit(&v);
@@ -890,7 +916,7 @@ static void test_marshal_VARIANT(void)
     rpcMsg.BufferLength = stubMsg.BufferLength = VARIANT_UserSize(&umcb.Flags, 0, &v);
     ok(stubMsg.BufferLength == 22, "size %d\n", stubMsg.BufferLength);
 
-    buffer = rpcMsg.Buffer = stubMsg.Buffer = stubMsg.BufferStart = HeapAlloc(GetProcessHeap(), 0, stubMsg.BufferLength);
+    buffer = rpcMsg.Buffer = stubMsg.Buffer = stubMsg.BufferStart = alloc_aligned(stubMsg.BufferLength, &oldbuffer);
     stubMsg.BufferEnd = stubMsg.Buffer + stubMsg.BufferLength;
     next = VARIANT_UserMarshal(&umcb.Flags, buffer, &v);
     ok(next == buffer + stubMsg.BufferLength, "got %p expect %p\n", next, buffer + stubMsg.BufferLength);
@@ -910,7 +936,7 @@ static void test_marshal_VARIANT(void)
 
         VARIANT_UserFree(&umcb.Flags, &v2);
     }
-    HeapFree(GetProcessHeap(), 0, buffer);
+    HeapFree(GetProcessHeap(), 0, oldbuffer);
 
     /*** DECIMAL ***/
     VarDecFromI4(0x12345678, &dec);
@@ -922,7 +948,7 @@ static void test_marshal_VARIANT(void)
     rpcMsg.BufferLength = stubMsg.BufferLength = VARIANT_UserSize(&umcb.Flags, 0, &v);
     ok(stubMsg.BufferLength == 40, "size %d\n", stubMsg.BufferLength);
 
-    buffer = rpcMsg.Buffer = stubMsg.Buffer = stubMsg.BufferStart = HeapAlloc(GetProcessHeap(), 0, stubMsg.BufferLength);
+    buffer = rpcMsg.Buffer = stubMsg.Buffer = stubMsg.BufferStart = alloc_aligned(stubMsg.BufferLength, &oldbuffer);
     stubMsg.BufferEnd = stubMsg.Buffer + stubMsg.BufferLength;
     memset(buffer, 0xcc, stubMsg.BufferLength);
     next = VARIANT_UserMarshal(&umcb.Flags, buffer, &v);
@@ -948,7 +974,7 @@ static void test_marshal_VARIANT(void)
 
         VARIANT_UserFree(&umcb.Flags, &v2);
     }
-    HeapFree(GetProcessHeap(), 0, buffer);
+    HeapFree(GetProcessHeap(), 0, oldbuffer);
 
     /*** DECIMAL BYREF ***/
     VariantInit(&v);
@@ -958,7 +984,7 @@ static void test_marshal_VARIANT(void)
     rpcMsg.BufferLength = stubMsg.BufferLength = VARIANT_UserSize(&umcb.Flags, 0, &v);
     ok(stubMsg.BufferLength == 40, "size %d\n", stubMsg.BufferLength);
 
-    buffer = rpcMsg.Buffer = stubMsg.Buffer = stubMsg.BufferStart = HeapAlloc(GetProcessHeap(), 0, stubMsg.BufferLength);
+    buffer = rpcMsg.Buffer = stubMsg.Buffer = stubMsg.BufferStart = alloc_aligned(stubMsg.BufferLength, &oldbuffer);
     stubMsg.BufferEnd = stubMsg.Buffer + stubMsg.BufferLength;
     next = VARIANT_UserMarshal(&umcb.Flags, buffer, &v);
     ok(next == buffer + stubMsg.BufferLength, "got %p expect %p\n", next, buffer + stubMsg.BufferLength);
@@ -987,7 +1013,7 @@ static void test_marshal_VARIANT(void)
 
         VARIANT_UserFree(&umcb.Flags, &v2);
     }
-    HeapFree(GetProcessHeap(), 0, buffer);
+    HeapFree(GetProcessHeap(), 0, oldbuffer);
 
     /*** EMPTY ***/
     VariantInit(&v);
@@ -996,7 +1022,7 @@ static void test_marshal_VARIANT(void)
     rpcMsg.BufferLength = stubMsg.BufferLength = VARIANT_UserSize(&umcb.Flags, 0, &v);
     ok(stubMsg.BufferLength == 20, "size %d\n", stubMsg.BufferLength);
 
-    buffer = rpcMsg.Buffer = stubMsg.Buffer = stubMsg.BufferStart = HeapAlloc(GetProcessHeap(), 0, stubMsg.BufferLength);
+    buffer = rpcMsg.Buffer = stubMsg.Buffer = stubMsg.BufferStart = alloc_aligned(stubMsg.BufferLength, &oldbuffer);
     stubMsg.BufferEnd = stubMsg.Buffer + stubMsg.BufferLength;
     next = VARIANT_UserMarshal(&umcb.Flags, buffer, &v);
     ok(next == buffer + stubMsg.BufferLength, "got %p expect %p\n", next, buffer + stubMsg.BufferLength);
@@ -1013,7 +1039,7 @@ static void test_marshal_VARIANT(void)
 
         VARIANT_UserFree(&umcb.Flags, &v2);
     }
-    HeapFree(GetProcessHeap(), 0, buffer);
+    HeapFree(GetProcessHeap(), 0, oldbuffer);
 
     /*** NULL ***/
     VariantInit(&v);
@@ -1022,7 +1048,7 @@ static void test_marshal_VARIANT(void)
     rpcMsg.BufferLength = stubMsg.BufferLength = VARIANT_UserSize(&umcb.Flags, 0, &v);
     ok(stubMsg.BufferLength == 20, "size %d\n", stubMsg.BufferLength);
 
-    buffer = rpcMsg.Buffer = stubMsg.Buffer = stubMsg.BufferStart = HeapAlloc(GetProcessHeap(), 0, stubMsg.BufferLength);
+    buffer = rpcMsg.Buffer = stubMsg.Buffer = stubMsg.BufferStart = alloc_aligned(stubMsg.BufferLength, &oldbuffer);
     stubMsg.BufferEnd = stubMsg.Buffer + stubMsg.BufferLength;
     next = VARIANT_UserMarshal(&umcb.Flags, buffer, &v);
     ok(next == buffer + stubMsg.BufferLength, "got %p expect %p\n", next, buffer + stubMsg.BufferLength);
@@ -1039,7 +1065,7 @@ static void test_marshal_VARIANT(void)
 
         VARIANT_UserFree(&umcb.Flags, &v2);
     }
-    HeapFree(GetProcessHeap(), 0, buffer);
+    HeapFree(GetProcessHeap(), 0, oldbuffer);
 
     /*** BSTR ***/
     b = SysAllocString(str);
@@ -1049,7 +1075,7 @@ static void test_marshal_VARIANT(void)
 
     rpcMsg.BufferLength = stubMsg.BufferLength = VARIANT_UserSize(&umcb.Flags, 0, &v);
     ok(stubMsg.BufferLength == 60, "size %d\n", stubMsg.BufferLength);
-    buffer = rpcMsg.Buffer = stubMsg.Buffer = stubMsg.BufferStart = HeapAlloc(GetProcessHeap(), 0, stubMsg.BufferLength);
+    buffer = rpcMsg.Buffer = stubMsg.Buffer = stubMsg.BufferStart = alloc_aligned(stubMsg.BufferLength, &oldbuffer);
     stubMsg.BufferEnd = stubMsg.Buffer + stubMsg.BufferLength;
     next = VARIANT_UserMarshal(&umcb.Flags, buffer, &v);
     ok(next == buffer + stubMsg.BufferLength, "got %p expect %p\n", next, buffer + stubMsg.BufferLength);
@@ -1072,7 +1098,7 @@ static void test_marshal_VARIANT(void)
 
         VARIANT_UserFree(&umcb.Flags, &v2);
     }
-    HeapFree(GetProcessHeap(), 0, buffer);
+    HeapFree(GetProcessHeap(), 0, oldbuffer);
 
     /*** BSTR BYREF ***/
     VariantInit(&v);
@@ -1081,7 +1107,7 @@ static void test_marshal_VARIANT(void)
 
     rpcMsg.BufferLength = stubMsg.BufferLength = VARIANT_UserSize(&umcb.Flags, 0, &v);
     ok(stubMsg.BufferLength == 64, "size %d\n", stubMsg.BufferLength);
-    buffer = rpcMsg.Buffer = stubMsg.Buffer = stubMsg.BufferStart = HeapAlloc(GetProcessHeap(), 0, stubMsg.BufferLength);
+    buffer = rpcMsg.Buffer = stubMsg.Buffer = stubMsg.BufferStart = alloc_aligned(stubMsg.BufferLength, &oldbuffer);
     stubMsg.BufferEnd = stubMsg.Buffer + stubMsg.BufferLength;
     next = VARIANT_UserMarshal(&umcb.Flags, buffer, &v);
     ok(next == buffer + stubMsg.BufferLength, "got %p expect %p\n", next, buffer + stubMsg.BufferLength);
@@ -1106,7 +1132,7 @@ static void test_marshal_VARIANT(void)
 
         VARIANT_UserFree(&umcb.Flags, &v2);
     }
-    HeapFree(GetProcessHeap(), 0, buffer);
+    HeapFree(GetProcessHeap(), 0, oldbuffer);
     SysFreeString(b);
 
     /*** ARRAY ***/
@@ -1122,14 +1148,16 @@ static void test_marshal_VARIANT(void)
     V_ARRAY(&v) = lpsa;
 
     rpcMsg.BufferLength = stubMsg.BufferLength = VARIANT_UserSize(&umcb.Flags, 0, &v);
-    ok(stubMsg.BufferLength == 152, "size %d\n", stubMsg.BufferLength);
-    buffer = rpcMsg.Buffer = stubMsg.Buffer = stubMsg.BufferStart = HeapAlloc(GetProcessHeap(), 0, stubMsg.BufferLength);
+    expected = 152;
+    ok(stubMsg.BufferLength == expected || stubMsg.BufferLength == expected + 8, /* win64 */
+       "size %u instead of %u\n", stubMsg.BufferLength, expected);
+    buffer = rpcMsg.Buffer = stubMsg.Buffer = stubMsg.BufferStart = alloc_aligned(stubMsg.BufferLength, &oldbuffer);
     stubMsg.BufferEnd = stubMsg.Buffer + stubMsg.BufferLength;
     next = VARIANT_UserMarshal(&umcb.Flags, buffer, &v);
-    ok(next == buffer + stubMsg.BufferLength, "got %p expect %p\n", next, buffer + stubMsg.BufferLength);
+    ok(next == buffer + expected, "got %p expect %p\n", next, buffer + expected);
     wirev = (DWORD*)buffer;
     
-    check_variant_header(wirev, &v, stubMsg.BufferLength);
+    check_variant_header(wirev, &v, expected);
     wirev += 5;
     ok(*wirev, "wv[5] %08x\n", *wirev); /* win2k: this is lpsa. winxp: this is (char*)lpsa + 1 */
     wirev++;
@@ -1141,7 +1169,7 @@ static void test_marshal_VARIANT(void)
         VariantInit(&v2);
         stubMsg.Buffer = buffer;
         next = VARIANT_UserUnmarshal(&umcb.Flags, buffer, &v2);
-        ok(next == buffer + stubMsg.BufferLength, "got %p expect %p\n", next, buffer + stubMsg.BufferLength);
+        ok(next == buffer + expected, "got %p expect %p\n", next, buffer + expected);
         ok(V_VT(&v) == V_VT(&v2), "got vt %d expect %d\n", V_VT(&v), V_VT(&v2));
         ok(SafeArrayGetDim(V_ARRAY(&v)) == SafeArrayGetDim(V_ARRAY(&v)), "array dims differ\n");  
         SafeArrayGetLBound(V_ARRAY(&v), 1, &bound);
@@ -1155,7 +1183,7 @@ static void test_marshal_VARIANT(void)
         ok(vt == vt2, "array vts differ %x %x\n", vt, vt2);
         VARIANT_UserFree(&umcb.Flags, &v2);
     }
-    HeapFree(GetProcessHeap(), 0, buffer);
+    HeapFree(GetProcessHeap(), 0, oldbuffer);
 
     /*** ARRAY BYREF ***/
     VariantInit(&v);
@@ -1163,14 +1191,16 @@ static void test_marshal_VARIANT(void)
     V_ARRAYREF(&v) = &lpsa;
 
     rpcMsg.BufferLength = stubMsg.BufferLength = VARIANT_UserSize(&umcb.Flags, 0, &v);
-    ok(stubMsg.BufferLength == 152, "size %d\n", stubMsg.BufferLength);
-    buffer = rpcMsg.Buffer = stubMsg.Buffer = stubMsg.BufferStart = HeapAlloc(GetProcessHeap(), 0, stubMsg.BufferLength);
+    expected = 152;
+    ok(stubMsg.BufferLength == expected || stubMsg.BufferLength == expected + 16, /* win64 */
+       "size %u instead of %u\n", stubMsg.BufferLength, expected);
+    buffer = rpcMsg.Buffer = stubMsg.Buffer = stubMsg.BufferStart = alloc_aligned(stubMsg.BufferLength, &oldbuffer);
     stubMsg.BufferEnd = stubMsg.Buffer + stubMsg.BufferLength;
     next = VARIANT_UserMarshal(&umcb.Flags, buffer, &v);
-    ok(next == buffer + stubMsg.BufferLength, "got %p expect %p\n", next, buffer + stubMsg.BufferLength);
+    ok(next == buffer + expected, "got %p expect %p\n", next, buffer + expected);
     wirev = (DWORD*)buffer;
-    
-    check_variant_header(wirev, &v, stubMsg.BufferLength);
+
+    check_variant_header(wirev, &v, expected);
     wirev += 5;
     ok(*wirev == 4, "wv[5] %08x\n", *wirev);
     wirev++;
@@ -1184,7 +1214,7 @@ static void test_marshal_VARIANT(void)
         VariantInit(&v2);
         stubMsg.Buffer = buffer;
         next = VARIANT_UserUnmarshal(&umcb.Flags, buffer, &v2);
-        ok(next == buffer + stubMsg.BufferLength, "got %p expect %p\n", next, buffer + stubMsg.BufferLength);
+        ok(next == buffer + expected, "got %p expect %p\n", next, buffer + expected);
         ok(V_VT(&v) == V_VT(&v2), "got vt %d expect %d\n", V_VT(&v), V_VT(&v2));
         ok(SafeArrayGetDim(*V_ARRAYREF(&v)) == SafeArrayGetDim(*V_ARRAYREF(&v)), "array dims differ\n");  
         SafeArrayGetLBound(*V_ARRAYREF(&v), 1, &bound);
@@ -1198,7 +1228,7 @@ static void test_marshal_VARIANT(void)
         ok(vt == vt2, "array vts differ %x %x\n", vt, vt2);
         VARIANT_UserFree(&umcb.Flags, &v2);
     }
-    HeapFree(GetProcessHeap(), 0, buffer);
+    HeapFree(GetProcessHeap(), 0, oldbuffer);
     SafeArrayDestroy(lpsa);
 
     /*** VARIANT BYREF ***/
@@ -1211,7 +1241,7 @@ static void test_marshal_VARIANT(void)
 
     rpcMsg.BufferLength = stubMsg.BufferLength = VARIANT_UserSize(&umcb.Flags, 0, &v);
     ok(stubMsg.BufferLength == 64, "size %d\n", stubMsg.BufferLength);
-    buffer = rpcMsg.Buffer = stubMsg.Buffer = stubMsg.BufferStart = HeapAlloc(GetProcessHeap(), 0, stubMsg.BufferLength);
+    buffer = rpcMsg.Buffer = stubMsg.Buffer = stubMsg.BufferStart = alloc_aligned(stubMsg.BufferLength, &oldbuffer);
     stubMsg.BufferEnd = stubMsg.Buffer + stubMsg.BufferLength;
     memset(buffer, 0xcc, stubMsg.BufferLength);
     next = VARIANT_UserMarshal(&umcb.Flags, buffer, &v);
@@ -1220,7 +1250,7 @@ static void test_marshal_VARIANT(void)
     check_variant_header(wirev, &v, stubMsg.BufferLength);
     wirev += 5;
 
-    ok(*wirev == 16, "wv[5] %08x\n", *wirev);
+    ok(*wirev == sizeof(VARIANT), "wv[5] %08x\n", *wirev);
     wirev++;
     ok(*wirev == ('U' | 's' << 8 | 'e' << 16 | 'r' << 24), "wv[6] %08x\n", *wirev); /* 'User' */
     wirev++;
@@ -1244,7 +1274,7 @@ static void test_marshal_VARIANT(void)
         ok(V_R8(V_VARIANTREF(&v)) == V_R8(V_VARIANTREF(&v3)), "r8s differ\n"); 
         VARIANT_UserFree(&umcb.Flags, &v3);
     }
-    HeapFree(GetProcessHeap(), 0, buffer);
+    HeapFree(GetProcessHeap(), 0, oldbuffer);
 
     /*** UNKNOWN ***/
     heap_unknown = HeapAlloc(GetProcessHeap(), 0, sizeof(*heap_unknown));
@@ -1257,7 +1287,7 @@ static void test_marshal_VARIANT(void)
 
     rpcMsg.BufferLength = stubMsg.BufferLength = VARIANT_UserSize(&umcb.Flags, 0, &v);
     ok(stubMsg.BufferLength > 32, "size %d\n", stubMsg.BufferLength);
-    buffer = rpcMsg.Buffer = stubMsg.Buffer = stubMsg.BufferStart = HeapAlloc(GetProcessHeap(), 0, stubMsg.BufferLength);
+    buffer = rpcMsg.Buffer = stubMsg.Buffer = stubMsg.BufferStart = alloc_aligned(stubMsg.BufferLength, &oldbuffer);
     stubMsg.BufferEnd = stubMsg.Buffer + stubMsg.BufferLength;
     memset(buffer, 0xcc, stubMsg.BufferLength);
     next = VARIANT_UserMarshal(&umcb.Flags, buffer, &v);
@@ -1292,7 +1322,7 @@ static void test_marshal_VARIANT(void)
         ok(heap_unknown->refs == 1, "%d refcounts of IUnknown leaked\n", heap_unknown->refs - 1);
         IUnknown_Release((IUnknown *)heap_unknown);
     }
-    HeapFree(GetProcessHeap(), 0, buffer);
+    HeapFree(GetProcessHeap(), 0, oldbuffer);
 
     /*** UNKNOWN BYREF ***/
     heap_unknown = HeapAlloc(GetProcessHeap(), 0, sizeof(*heap_unknown));
@@ -1305,7 +1335,7 @@ static void test_marshal_VARIANT(void)
 
     rpcMsg.BufferLength = stubMsg.BufferLength = VARIANT_UserSize(&umcb.Flags, 0, &v);
     ok(stubMsg.BufferLength > 36, "size %d\n", stubMsg.BufferLength);
-    buffer = rpcMsg.Buffer = stubMsg.Buffer = stubMsg.BufferStart = HeapAlloc(GetProcessHeap(), 0, stubMsg.BufferLength);
+    buffer = rpcMsg.Buffer = stubMsg.Buffer = stubMsg.BufferStart = alloc_aligned(stubMsg.BufferLength, &oldbuffer);
     stubMsg.BufferEnd = stubMsg.Buffer + stubMsg.BufferLength;
     memset(buffer, 0xcc, stubMsg.BufferLength);
     next = VARIANT_UserMarshal(&umcb.Flags, buffer, &v);
@@ -1342,7 +1372,7 @@ static void test_marshal_VARIANT(void)
         ok(heap_unknown->refs == 1, "%d refcounts of IUnknown leaked\n", heap_unknown->refs - 1);
         IUnknown_Release((IUnknown *)heap_unknown);
     }
-    HeapFree(GetProcessHeap(), 0, buffer);
+    HeapFree(GetProcessHeap(), 0, oldbuffer);
 }
 
 
index b19efbd..6833a27 100644 (file)
@@ -379,6 +379,10 @@ static void test_VarFormat(void)
   VARFMT(VT_R8,V_R8,-1.57,"0.00",S_OK,"-1.57");
   VARFMT(VT_R8,V_R8,-1.57,"#.##",S_OK,"-1.57");
   VARFMT(VT_R8,V_R8,-0.1,".#",S_OK,"-.1");
+  VARFMT(VT_R8,V_R8,0.099,"#.#",S_OK,".1");
+  VARFMT(VT_R8,V_R8,0.0999,"#.##",S_OK,".1");
+  /* for large negative exponents, wine truncates instead of rounding */
+  todo_wine VARFMT(VT_R8,V_R8,0.099,"#.##",S_OK,".1");
 
 
   /* 'out' is not cleared */
index f0a6deb..53b0afc 100644 (file)
@@ -5234,11 +5234,13 @@ static void test_VarAdd(void)
 static void test_VarCat(void)
 {
     LCID lcid;
-    VARIANT left, right, result, expected;
+    VARIANT left, right, result, expected, expected_broken;
     static const WCHAR sz34[] = {'3','4','\0'};
     static const WCHAR sz1234[] = {'1','2','3','4','\0'};
     static const WCHAR date_sz12[] = {'9','/','3','0','/','1','9','8','0','1','2','\0'};
+    static const WCHAR date_sz12_broken[] = {'9','/','3','0','/','8','0','1','2','\0'};
     static const WCHAR sz12_date[] = {'1','2','9','/','3','0','/','1','9','8','0','\0'};
+    static const WCHAR sz12_date_broken[] = {'1','2','9','/','3','0','/','8','0','\0'};
     static const WCHAR sz_empty[] = {'\0'};
     TCHAR orig_date_format[128];
     VARTYPE leftvt, rightvt, resultvt;
@@ -5468,7 +5470,7 @@ static void test_VarCat(void)
     hres = VarCat(&left,&right,&result);
     ok(hres == S_OK, "VarCat failed with error 0x%08x\n", hres);
     ok(VarCmp(&result,&expected,lcid,0) == VARCMP_EQ,
-        "VarCat: NUMBER concat with NUMBER returned inncorrect result\n");
+        "VarCat: NUMBER concat with NUMBER returned incorrect result\n");
 
     VariantClear(&left);
     VariantClear(&right);
@@ -5482,7 +5484,7 @@ static void test_VarCat(void)
     hres = VarCat(&left,&right,&result);
     ok(hres == S_OK, "VarCat failed with error 0x%08x\n", hres);
     ok(VarCmp(&result,&expected,lcid,0) == VARCMP_EQ,
-        "VarCat: NUMBER concat with VT_BSTR, inncorrect result\n");
+        "VarCat: NUMBER concat with VT_BSTR, incorrect result\n");
 
     VariantClear(&left);
     VariantClear(&right);
@@ -5495,7 +5497,7 @@ static void test_VarCat(void)
     hres = VarCat(&left,&right,&result);
     ok(hres == S_OK, "VarCat failed with error 0x%08x\n", hres);
     ok(VarCmp(&result,&expected,lcid,0) == VARCMP_EQ,
-        "VarCat: VT_BSTR concat with NUMBER, inncorrect result\n");
+        "VarCat: VT_BSTR concat with NUMBER, incorrect result\n");
 
     VariantClear(&left);
     VariantClear(&right);
@@ -5506,34 +5508,42 @@ static void test_VarCat(void)
     V_VT(&left) = VT_BSTR;
     V_VT(&right) = VT_DATE;
     V_VT(&expected) = VT_BSTR;
+    V_VT(&expected_broken) = VT_BSTR;
     V_BSTR(&left) = SysAllocString(sz12);
     V_DATE(&right) = 29494.0;
     V_BSTR(&expected)= SysAllocString(sz12_date);
+    V_BSTR(&expected_broken)= SysAllocString(sz12_date_broken);
     hres = VarCat(&left,&right,&result);
     ok(hres == S_OK, "VarCat failed with error 0x%08x\n", hres);
-    ok(VarCmp(&result,&expected,lcid,0) == VARCMP_EQ,
-        "VarCat: VT_BSTR concat with VT_DATE returned inncorrect result\n");
+    ok(VarCmp(&result,&expected,lcid,0) == VARCMP_EQ ||
+        broken(VarCmp(&result,&expected_broken,lcid,0) == VARCMP_EQ), /* Some W98 and NT4 (intermittent) */
+        "VarCat: VT_BSTR concat with VT_DATE returned incorrect result\n");
 
     VariantClear(&left);
     VariantClear(&right);
     VariantClear(&result);
     VariantClear(&expected);
+    VariantClear(&expected_broken);
 
     V_VT(&left) = VT_DATE;
     V_VT(&right) = VT_BSTR;
     V_VT(&expected) = VT_BSTR;
+    V_VT(&expected_broken) = VT_BSTR;
     V_DATE(&left) = 29494.0;
     V_BSTR(&right) = SysAllocString(sz12);
     V_BSTR(&expected)= SysAllocString(date_sz12);
+    V_BSTR(&expected_broken)= SysAllocString(date_sz12_broken);
     hres = VarCat(&left,&right,&result);
     ok(hres == S_OK, "VarCat failed with error 0x%08x\n", hres);
-    ok(VarCmp(&result,&expected,lcid,0) == VARCMP_EQ,
-        "VarCat: VT_DATE concat with VT_BSTR returned inncorrect result\n");
+    ok(VarCmp(&result,&expected,lcid,0) == VARCMP_EQ ||
+        broken(VarCmp(&result,&expected_broken,lcid,0) == VARCMP_EQ), /* Some W98 and NT4 (intermittent) */
+        "VarCat: VT_DATE concat with VT_BSTR returned incorrect result\n");
 
     VariantClear(&left);
     VariantClear(&right);
     VariantClear(&result);
     VariantClear(&expected);
+    VariantClear(&expected_broken);
 
     /* Test of both expressions are empty */
     V_VT(&left) = VT_BSTR;
index 7600946..419e027 100644 (file)
@@ -3434,6 +3434,11 @@ static void test_VarDateFromStr(void)
   DFS("1/2/1970");        EXPECT_DBL(25570.0);
   DFS("1-2-1970");        EXPECT_DBL(25570.0);
   /* Native fails "1999 January 3, 9AM". I consider that a bug in native */
+
+  /* test a none english data string */
+  DFS("02.01.1970 00:00:00"); EXPECT_MISMATCH;
+  lcid = MAKELCID(MAKELANGID(LANG_GERMAN,SUBLANG_GERMAN),SORT_DEFAULT);
+  DFS("02.01.1970 00:00:00"); todo_wine EXPECT_DBL(25570.0);
 }
 
 static void test_VarDateCopy(void)
@@ -4408,9 +4413,104 @@ static void test_VarDecCmp(void)
   MATHVARS1;
 
   CHECKPTR(VarDecCmp);
+
   SETDEC(l,0,0,0,1); SETDEC(out,0,0,0,1); MATH1(VarDecCmp); EXPECT_EQ;
   SETDEC(l,0,0,0,1); SETDEC(out,0,0,0,0); MATH1(VarDecCmp); EXPECT_GT;
+  SETDEC(l,0,0,0,1); SETDEC(out,0,0,-1,-1); MATH1(VarDecCmp); EXPECT_LT;
+
+  SETDEC(l,0,0,0,1); SETDEC(out,0,DECIMAL_NEG,0,1); MATH1(VarDecCmp); EXPECT_GT;
+  SETDEC(l,0,0,0,1); SETDEC(out,0,DECIMAL_NEG,0,0); MATH1(VarDecCmp); EXPECT_GT;
+  SETDEC(l,0,0,0,1); SETDEC(out,0,DECIMAL_NEG,-1,-1); MATH1(VarDecCmp); EXPECT_GT;
+
+  SETDEC(l,0,DECIMAL_NEG,0,1); SETDEC(out,0,0,0,1); MATH1(VarDecCmp); EXPECT_LT;
+  SETDEC(l,0,DECIMAL_NEG,0,1); SETDEC(out,0,0,0,0); MATH1(VarDecCmp); EXPECT_LT;
+  SETDEC(l,0,DECIMAL_NEG,0,1); SETDEC(out,0,0,-1,-1); MATH1(VarDecCmp); EXPECT_LT;
+
+  SETDEC(l,0,DECIMAL_NEG,0,1); SETDEC(out,0,DECIMAL_NEG,0,1); MATH1(VarDecCmp); EXPECT_EQ;
+  SETDEC(l,0,DECIMAL_NEG,0,1); SETDEC(out,0,DECIMAL_NEG,0,0); MATH1(VarDecCmp); EXPECT_LT;
+  SETDEC(l,0,DECIMAL_NEG,0,1); SETDEC(out,0,DECIMAL_NEG,-1,-1); MATH1(VarDecCmp); EXPECT_GT;
+
   SETDEC(l,0,0,0,0); SETDEC(out,0,0,0,1); MATH1(VarDecCmp); EXPECT_LT;
+  SETDEC(l,0,0,0,0); SETDEC(out,0,0,0,0); MATH1(VarDecCmp); EXPECT_EQ;
+  SETDEC(l,0,0,0,0); SETDEC(out,0,0,-1,-1); MATH1(VarDecCmp); EXPECT_LT;
+
+  SETDEC(l,0,0,0,0); SETDEC(out,0,DECIMAL_NEG,0,1); MATH1(VarDecCmp); EXPECT_GT;
+  SETDEC(l,0,0,0,0); SETDEC(out,0,DECIMAL_NEG,0,0); MATH1(VarDecCmp); EXPECT_EQ;
+  SETDEC(l,0,0,0,0); SETDEC(out,0,DECIMAL_NEG,-1,-1); MATH1(VarDecCmp); EXPECT_GT;
+
+  SETDEC(l,0,DECIMAL_NEG,0,0); SETDEC(out,0,0,0,1); MATH1(VarDecCmp); EXPECT_LT;
+  SETDEC(l,0,DECIMAL_NEG,0,0); SETDEC(out,0,0,0,0); MATH1(VarDecCmp); EXPECT_EQ;
+  SETDEC(l,0,DECIMAL_NEG,0,0); SETDEC(out,0,0,-1,-1); MATH1(VarDecCmp); EXPECT_LT;
+
+  SETDEC(l,0,DECIMAL_NEG,0,0); SETDEC(out,0,DECIMAL_NEG,0,1); MATH1(VarDecCmp); EXPECT_GT;
+  SETDEC(l,0,DECIMAL_NEG,0,0); SETDEC(out,0,DECIMAL_NEG,0,0); MATH1(VarDecCmp); EXPECT_EQ;
+  SETDEC(l,0,DECIMAL_NEG,0,0); SETDEC(out,0,DECIMAL_NEG,-1,-1); MATH1(VarDecCmp); EXPECT_GT;
+
+  SETDEC(l,0,0,-1,-1); SETDEC(out,0,0,0,1); MATH1(VarDecCmp); EXPECT_GT;
+  SETDEC(l,0,0,-1,-1); SETDEC(out,0,0,0,0); MATH1(VarDecCmp); EXPECT_GT;
+  SETDEC(l,0,0,-1,-1); SETDEC(out,0,0,-1,-1); MATH1(VarDecCmp); EXPECT_EQ;
+
+  SETDEC(l,0,0,-1,-1); SETDEC(out,0,DECIMAL_NEG,0,1); MATH1(VarDecCmp); EXPECT_GT;
+  SETDEC(l,0,0,-1,-1); SETDEC(out,0,DECIMAL_NEG,0,0); MATH1(VarDecCmp); EXPECT_GT;
+  SETDEC(l,0,0,-1,-1); SETDEC(out,0,DECIMAL_NEG,-1,-1); MATH1(VarDecCmp); EXPECT_GT;
+
+  SETDEC(l,0,DECIMAL_NEG,-1,-1); SETDEC(out,0,0,0,1); MATH1(VarDecCmp); EXPECT_LT;
+  SETDEC(l,0,DECIMAL_NEG,-1,-1); SETDEC(out,0,0,0,0); MATH1(VarDecCmp); EXPECT_LT;
+  SETDEC(l,0,DECIMAL_NEG,-1,-1); SETDEC(out,0,0,-1,-1); MATH1(VarDecCmp); EXPECT_LT;
+
+  SETDEC(l,0,DECIMAL_NEG,-1,-1); SETDEC(out,0,DECIMAL_NEG,0,1); MATH1(VarDecCmp); EXPECT_LT;
+  SETDEC(l,0,DECIMAL_NEG,-1,-1); SETDEC(out,0,DECIMAL_NEG,0,0); MATH1(VarDecCmp); EXPECT_LT;
+  SETDEC(l,0,DECIMAL_NEG,-1,-1); SETDEC(out,0,DECIMAL_NEG,-1,-1); MATH1(VarDecCmp); EXPECT_EQ;
+
+
+  SETDEC(out,0,0,0,1); SETDEC(l,0,0,0,1); MATH1(VarDecCmp); EXPECT_EQ;
+  SETDEC(out,0,0,0,1); SETDEC(l,0,0,0,0); MATH1(VarDecCmp); EXPECT_LT;
+  SETDEC(out,0,0,0,1); SETDEC(l,0,0,-1,-1); MATH1(VarDecCmp); EXPECT_GT;
+
+  SETDEC(out,0,0,0,1); SETDEC(l,0,DECIMAL_NEG,0,1); MATH1(VarDecCmp); EXPECT_LT;
+  SETDEC(out,0,0,0,1); SETDEC(l,0,DECIMAL_NEG,0,0); MATH1(VarDecCmp); EXPECT_LT;
+  SETDEC(out,0,0,0,1); SETDEC(l,0,DECIMAL_NEG,-1,-1); MATH1(VarDecCmp); EXPECT_LT;
+
+  SETDEC(out,0,DECIMAL_NEG,0,1); SETDEC(l,0,0,0,1); MATH1(VarDecCmp); EXPECT_GT;
+  SETDEC(out,0,DECIMAL_NEG,0,1); SETDEC(l,0,0,0,0); MATH1(VarDecCmp); EXPECT_GT;
+  SETDEC(out,0,DECIMAL_NEG,0,1); SETDEC(l,0,0,-1,-1); MATH1(VarDecCmp); EXPECT_GT;
+
+  SETDEC(out,0,DECIMAL_NEG,0,1); SETDEC(l,0,DECIMAL_NEG,0,1); MATH1(VarDecCmp); EXPECT_EQ;
+  SETDEC(out,0,DECIMAL_NEG,0,1); SETDEC(l,0,DECIMAL_NEG,0,0); MATH1(VarDecCmp); EXPECT_GT;
+  SETDEC(out,0,DECIMAL_NEG,0,1); SETDEC(l,0,DECIMAL_NEG,-1,-1); MATH1(VarDecCmp); EXPECT_LT;
+
+  SETDEC(out,0,0,0,0); SETDEC(l,0,0,0,1); MATH1(VarDecCmp); EXPECT_GT;
+  SETDEC(out,0,0,0,0); SETDEC(l,0,0,0,0); MATH1(VarDecCmp); EXPECT_EQ;
+  SETDEC(out,0,0,0,0); SETDEC(l,0,0,-1,-1); MATH1(VarDecCmp); EXPECT_GT;
+
+  SETDEC(out,0,0,0,0); SETDEC(l,0,DECIMAL_NEG,0,1); MATH1(VarDecCmp); EXPECT_LT;
+  SETDEC(out,0,0,0,0); SETDEC(l,0,DECIMAL_NEG,0,0); MATH1(VarDecCmp); EXPECT_EQ;
+  SETDEC(out,0,0,0,0); SETDEC(l,0,DECIMAL_NEG,-1,-1); MATH1(VarDecCmp); EXPECT_LT;
+
+  SETDEC(out,0,DECIMAL_NEG,0,0); SETDEC(l,0,0,0,1); MATH1(VarDecCmp); EXPECT_GT;
+  SETDEC(out,0,DECIMAL_NEG,0,0); SETDEC(l,0,0,0,0); MATH1(VarDecCmp); EXPECT_EQ;
+  SETDEC(out,0,DECIMAL_NEG,0,0); SETDEC(l,0,0,-1,-1); MATH1(VarDecCmp); EXPECT_GT;
+
+  SETDEC(out,0,DECIMAL_NEG,0,0); SETDEC(l,0,DECIMAL_NEG,0,1); MATH1(VarDecCmp); EXPECT_LT;
+  SETDEC(out,0,DECIMAL_NEG,0,0); SETDEC(l,0,DECIMAL_NEG,0,0); MATH1(VarDecCmp); EXPECT_EQ;
+  SETDEC(out,0,DECIMAL_NEG,0,0); SETDEC(l,0,DECIMAL_NEG,-1,-1); MATH1(VarDecCmp); EXPECT_LT;
+
+  SETDEC(out,0,0,-1,-1); SETDEC(l,0,0,0,1); MATH1(VarDecCmp); EXPECT_LT;
+  SETDEC(out,0,0,-1,-1); SETDEC(l,0,0,0,0); MATH1(VarDecCmp); EXPECT_LT;
+  SETDEC(out,0,0,-1,-1); SETDEC(l,0,0,-1,-1); MATH1(VarDecCmp); EXPECT_EQ;
+
+  SETDEC(out,0,0,-1,-1); SETDEC(l,0,DECIMAL_NEG,0,1); MATH1(VarDecCmp); EXPECT_LT;
+  SETDEC(out,0,0,-1,-1); SETDEC(l,0,DECIMAL_NEG,0,0); MATH1(VarDecCmp); EXPECT_LT;
+  SETDEC(out,0,0,-1,-1); SETDEC(l,0,DECIMAL_NEG,-1,-1); MATH1(VarDecCmp); EXPECT_LT;
+
+  SETDEC(out,0,DECIMAL_NEG,-1,-1); SETDEC(l,0,0,0,1); MATH1(VarDecCmp); EXPECT_GT;
+  SETDEC(out,0,DECIMAL_NEG,-1,-1); SETDEC(l,0,0,0,0); MATH1(VarDecCmp); EXPECT_GT;
+  SETDEC(out,0,DECIMAL_NEG,-1,-1); SETDEC(l,0,0,-1,-1); MATH1(VarDecCmp); EXPECT_GT;
+
+  SETDEC(out,0,DECIMAL_NEG,-1,-1); SETDEC(l,0,DECIMAL_NEG,0,1); MATH1(VarDecCmp); EXPECT_GT;
+  SETDEC(out,0,DECIMAL_NEG,-1,-1); SETDEC(l,0,DECIMAL_NEG,0,0); MATH1(VarDecCmp); EXPECT_GT;
+  SETDEC(out,0,DECIMAL_NEG,-1,-1); SETDEC(l,0,DECIMAL_NEG,-1,-1); MATH1(VarDecCmp); EXPECT_EQ;
+
 }
 
 /*