oleaut32/tests: Hide details about VARIANT wire header in header testing helper.

This commit is contained in:
Nikolay Sivov 2015-03-07 23:40:35 +03:00 committed by Alexandre Julliard
parent b9819b0b8e
commit 52d30cc301
1 changed files with 44 additions and 59 deletions

View File

@ -711,29 +711,35 @@ static const IUnknownVtbl HeapUnknown_Vtbl =
HeapUnknown_Release
};
static void check_variant_header(DWORD *wirev, VARIANT *v, ULONG size)
typedef struct
{
WORD *wp;
DWORD clSize;
DWORD rpcReserved;
USHORT vt;
USHORT wReserved1;
USHORT wReserved2;
USHORT wReserved3;
DWORD switch_is;
} variant_wire_t;
static DWORD *check_variant_header(DWORD *wirev, VARIANT *v, ULONG size)
{
const variant_wire_t *header = (const variant_wire_t*)wirev;
DWORD switch_is;
ok(*wirev == (size + 7) >> 3, "wv[0] %08x, expected %08x\n", *wirev, (size + 7) >> 3);
wirev++;
ok(*wirev == 0, "wv[1] %08x\n", *wirev);
wirev++;
wp = (WORD*)wirev;
ok(*wp == V_VT(v), "vt %04x expected %04x\n", *wp, V_VT(v));
wp++;
ok(*wp == V_U2(v).wReserved1, "res1 %04x expected %04x\n", *wp, V_U2(v).wReserved1);
wp++;
ok(*wp == V_U2(v).wReserved2, "res2 %04x expected %04x\n", *wp, V_U2(v).wReserved2);
wp++;
ok(*wp == V_U2(v).wReserved3, "res3 %04x expected %04x\n", *wp, V_U2(v).wReserved3);
wp++;
wirev = (DWORD*)wp;
ok(header->clSize == (size + 7) >> 3, "wv[0] %08x, expected %08x\n", header->clSize, (size + 7) >> 3);
ok(header->rpcReserved == 0, "wv[1] %08x\n", header->rpcReserved);
ok(header->vt == V_VT(v), "vt %04x expected %04x\n", header->vt, V_VT(v));
ok(header->wReserved1 == V_U2(v).wReserved1, "res1 %04x expected %04x\n", header->wReserved1, V_U2(v).wReserved1);
ok(header->wReserved2 == V_U2(v).wReserved2, "res2 %04x expected %04x\n", header->wReserved2, V_U2(v).wReserved2);
ok(header->wReserved3 == V_U2(v).wReserved3, "res3 %04x expected %04x\n", header->wReserved3, V_U2(v).wReserved3);
switch_is = V_VT(v);
if(switch_is & VT_ARRAY)
switch_is &= ~VT_TYPEMASK;
ok(*wirev == switch_is, "switch_is %08x expected %08x\n", *wirev, switch_is);
ok(header->switch_is == switch_is, "switch_is %08x expected %08x\n", header->switch_is, switch_is);
return (DWORD*)((unsigned char*)wirev + sizeof(variant_wire_t));
}
/* Win9x and WinME don't always align as needed. Variants have
@ -802,8 +808,7 @@ static void test_marshal_VARIANT(void)
ok(next == buffer + stubMsg.BufferLength, "got %p expect %p\n", next, buffer + stubMsg.BufferLength);
wirev = (DWORD*)buffer;
check_variant_header(wirev, &v, stubMsg.BufferLength);
wirev += 5;
wirev = check_variant_header(wirev, &v, stubMsg.BufferLength);
ok(*(char*)wirev == V_I1(&v), "wv[5] %08x\n", *wirev);
VariantInit(&v2);
stubMsg.Buffer = buffer;
@ -829,8 +834,7 @@ static void test_marshal_VARIANT(void)
ok(next == buffer + stubMsg.BufferLength, "got %p expect %p\n", next, buffer + stubMsg.BufferLength);
wirev = (DWORD*)buffer;
check_variant_header(wirev, &v, stubMsg.BufferLength);
wirev += 5;
wirev = check_variant_header(wirev, &v, stubMsg.BufferLength);
ok(*(short*)wirev == V_I2(&v), "wv[5] %08x\n", *wirev);
VariantInit(&v2);
stubMsg.Buffer = buffer;
@ -857,8 +861,7 @@ static void test_marshal_VARIANT(void)
ok(next == buffer + stubMsg.BufferLength, "got %p expect %p\n", next, buffer + stubMsg.BufferLength);
wirev = (DWORD*)buffer;
check_variant_header(wirev, &v, stubMsg.BufferLength);
wirev += 5;
wirev = check_variant_header(wirev, &v, stubMsg.BufferLength);
ok(*wirev == 0x4, "wv[5] %08x\n", *wirev);
wirev++;
ok(*(short*)wirev == s, "wv[6] %08x\n", *wirev);
@ -889,8 +892,7 @@ static void test_marshal_VARIANT(void)
ok(next == buffer + stubMsg.BufferLength, "got %p expect %p\n", next, buffer + stubMsg.BufferLength);
wirev = (DWORD*)buffer;
check_variant_header(wirev, &v, stubMsg.BufferLength);
wirev += 5;
wirev = check_variant_header(wirev, &v, stubMsg.BufferLength);
ok(*wirev == V_I4(&v), "wv[5] %08x\n", *wirev);
VariantInit(&v2);
@ -917,8 +919,7 @@ static void test_marshal_VARIANT(void)
ok(next == buffer + stubMsg.BufferLength, "got %p expect %p\n", next, buffer + stubMsg.BufferLength);
wirev = (DWORD*)buffer;
check_variant_header(wirev, &v, stubMsg.BufferLength);
wirev += 5;
wirev = check_variant_header(wirev, &v, stubMsg.BufferLength);
ok(*wirev == 0x1234, "wv[5] %08x\n", *wirev);
VariantInit(&v2);
stubMsg.Buffer = buffer;
@ -945,8 +946,7 @@ static void test_marshal_VARIANT(void)
ok(next == buffer + stubMsg.BufferLength, "got %p expect %p\n", next, buffer + stubMsg.BufferLength);
wirev = (DWORD*)buffer;
check_variant_header(wirev, &v, stubMsg.BufferLength);
wirev += 5;
wirev = check_variant_header(wirev, &v, stubMsg.BufferLength);
ok(*wirev == 0x4, "wv[5] %08x\n", *wirev);
wirev++;
ok(*wirev == ul, "wv[6] %08x\n", *wirev);
@ -975,8 +975,7 @@ static void test_marshal_VARIANT(void)
ok(next == buffer + stubMsg.BufferLength, "got %p expect %p\n", next, buffer + stubMsg.BufferLength);
wirev = (DWORD*)buffer;
check_variant_header(wirev, &v, stubMsg.BufferLength);
wirev += 5;
wirev = check_variant_header(wirev, &v, stubMsg.BufferLength);
ok(*(float*)wirev == V_R4(&v), "wv[5] %08x\n", *wirev);
VariantInit(&v2);
stubMsg.Buffer = buffer;
@ -1003,8 +1002,7 @@ static void test_marshal_VARIANT(void)
ok(next == buffer + stubMsg.BufferLength, "got %p expect %p\n", next, buffer + stubMsg.BufferLength);
wirev = (DWORD*)buffer;
check_variant_header(wirev, &v, stubMsg.BufferLength);
wirev += 5;
wirev = check_variant_header(wirev, &v, stubMsg.BufferLength);
ok(*wirev == 0xcccccccc, "wv[5] %08x\n", *wirev); /* pad */
wirev++;
ok(*(double*)wirev == V_R8(&v), "wv[6] %08x, wv[7] %08x\n", *wirev, *(wirev+1));
@ -1033,8 +1031,7 @@ static void test_marshal_VARIANT(void)
ok(next == buffer + stubMsg.BufferLength, "got %p expect %p\n", next, buffer + stubMsg.BufferLength);
wirev = (DWORD*)buffer;
check_variant_header(wirev, &v, stubMsg.BufferLength);
wirev += 5;
wirev = check_variant_header(wirev, &v, stubMsg.BufferLength);
ok(*wirev == 8, "wv[5] %08x\n", *wirev);
wirev++;
ok(*(double*)wirev == d, "wv[6] %08x wv[7] %08x\n", *wirev, *(wirev+1));
@ -1062,8 +1059,7 @@ static void test_marshal_VARIANT(void)
ok(next == buffer + stubMsg.BufferLength, "got %p expect %p\n", next, buffer + stubMsg.BufferLength);
wirev = (DWORD*)buffer;
check_variant_header(wirev, &v, stubMsg.BufferLength);
wirev += 5;
wirev = check_variant_header(wirev, &v, stubMsg.BufferLength);
ok(*(short*)wirev == V_BOOL(&v), "wv[5] %04x\n", *(WORD*)wirev);
VariantInit(&v2);
stubMsg.Buffer = buffer;
@ -1092,8 +1088,7 @@ static void test_marshal_VARIANT(void)
ok(next == buffer + stubMsg.BufferLength, "got %p expect %p\n", next, buffer + stubMsg.BufferLength);
wirev = (DWORD*)buffer;
check_variant_header(wirev, &v, stubMsg.BufferLength);
wirev += 5;
wirev = check_variant_header(wirev, &v, stubMsg.BufferLength);
ok(*wirev == 0xcccccccc, "wirev[5] %08x\n", *wirev); /* pad */
wirev++;
dec2 = dec;
@ -1124,8 +1119,7 @@ static void test_marshal_VARIANT(void)
ok(next == buffer + stubMsg.BufferLength, "got %p expect %p\n", next, buffer + stubMsg.BufferLength);
wirev = (DWORD*)buffer;
check_variant_header(wirev, &v, stubMsg.BufferLength);
wirev += 5;
wirev = check_variant_header(wirev, &v, stubMsg.BufferLength);
ok(*wirev == 16, "wv[5] %08x\n", *wirev);
wirev++;
ok(!memcmp(wirev, &dec, sizeof(dec)), "wirev[6] %08x wirev[7] %08x wirev[8] %08x wirev[9] %08x\n", *wirev, *(wirev + 1), *(wirev + 2), *(wirev + 3));
@ -1206,8 +1200,7 @@ static void test_marshal_VARIANT(void)
ok(next == buffer + stubMsg.BufferLength, "got %p expect %p\n", next, buffer + stubMsg.BufferLength);
wirev = (DWORD*)buffer;
check_variant_header(wirev, &v, stubMsg.BufferLength);
wirev += 5;
wirev = check_variant_header(wirev, &v, stubMsg.BufferLength);
ok(*wirev, "wv[5] %08x\n", *wirev); /* win2k: this is b. winxp: this is (char*)b + 1 */
wirev++;
check_bstr(wirev, V_BSTR(&v));
@ -1235,8 +1228,7 @@ static void test_marshal_VARIANT(void)
ok(next == buffer + stubMsg.BufferLength, "got %p expect %p\n", next, buffer + stubMsg.BufferLength);
wirev = (DWORD*)buffer;
check_variant_header(wirev, &v, stubMsg.BufferLength);
wirev += 5;
wirev = check_variant_header(wirev, &v, stubMsg.BufferLength);
ok(*wirev == 0x4, "wv[5] %08x\n", *wirev);
wirev++;
ok(*wirev, "wv[6] %08x\n", *wirev); /* win2k: this is b. winxp: this is (char*)b + 1 */
@ -1276,8 +1268,7 @@ static void test_marshal_VARIANT(void)
ok(next == buffer + expected, "got %p expect %p\n", next, buffer + expected);
wirev = (DWORD*)buffer;
check_variant_header(wirev, &v, expected);
wirev += 5;
wirev = check_variant_header(wirev, &v, expected);
ok(*wirev, "wv[5] %08x\n", *wirev); /* win2k: this is lpsa. winxp: this is (char*)lpsa + 1 */
wirev++;
check_safearray(wirev, lpsa);
@ -1317,8 +1308,7 @@ static void test_marshal_VARIANT(void)
ok(next == buffer + expected, "got %p expect %p\n", next, buffer + expected);
wirev = (DWORD*)buffer;
check_variant_header(wirev, &v, expected);
wirev += 5;
wirev = check_variant_header(wirev, &v, expected);
ok(*wirev == 4, "wv[5] %08x\n", *wirev);
wirev++;
ok(*wirev, "wv[6] %08x\n", *wirev); /* win2k: this is lpsa. winxp: this is (char*)lpsa + 1 */
@ -1363,8 +1353,7 @@ static void test_marshal_VARIANT(void)
next = VARIANT_UserMarshal(&umcb.Flags, buffer, &v);
ok(next == buffer + stubMsg.BufferLength, "got %p expect %p\n", next, buffer + stubMsg.BufferLength);
wirev = (DWORD*)buffer;
check_variant_header(wirev, &v, stubMsg.BufferLength);
wirev += 5;
wirev = check_variant_header(wirev, &v, stubMsg.BufferLength);
ok(*wirev == sizeof(VARIANT), "wv[5] %08x\n", *wirev);
wirev++;
@ -1372,8 +1361,7 @@ static void test_marshal_VARIANT(void)
wirev++;
ok(*wirev == 0xcccccccc, "wv[7] %08x\n", *wirev); /* pad */
wirev++;
check_variant_header(wirev, &v2, stubMsg.BufferLength - 32);
wirev += 5;
wirev = check_variant_header(wirev, &v2, stubMsg.BufferLength - 32);
ok(*wirev == 0xcccccccc, "wv[13] %08x\n", *wirev); /* pad for VT_R8 */
wirev++;
ok(*(double*)wirev == V_R8(&v2), "wv[6] %08x wv[7] %08x\n", *wirev, *(wirev+1));
@ -1404,8 +1392,7 @@ static void test_marshal_VARIANT(void)
memset(buffer, 0xcc, stubMsg.BufferLength);
next = VARIANT_UserMarshal(&umcb.Flags, buffer, &v);
wirev = (DWORD*)buffer;
check_variant_header(wirev, &v, next - buffer);
wirev += 5;
wirev = check_variant_header(wirev, &v, next - buffer);
todo_wine
ok(*wirev == (DWORD_PTR)V_UNKNOWN(&v) /* Win9x */ ||
@ -1444,8 +1431,7 @@ static void test_marshal_VARIANT(void)
memset(buffer, 0xcc, stubMsg.BufferLength);
next = VARIANT_UserMarshal(&umcb.Flags, buffer, &v);
wirev = (DWORD*)buffer;
check_variant_header(wirev, &v, next - buffer);
wirev += 5;
wirev = check_variant_header(wirev, &v, next - buffer);
ok(*wirev == 0, "wv[5] %08x\n", *wirev);
VariantInit(&v2);
@ -1472,8 +1458,7 @@ static void test_marshal_VARIANT(void)
memset(buffer, 0xcc, stubMsg.BufferLength);
next = VARIANT_UserMarshal(&umcb.Flags, buffer, &v);
wirev = (DWORD*)buffer;
check_variant_header(wirev, &v, next - buffer);
wirev += 5;
wirev = check_variant_header(wirev, &v, next - buffer);
ok(*wirev == 4, "wv[5] %08x\n", *wirev);
wirev++;