winapi_test: The real tests are done at compile time so use C_ASSERT() instead of ok(). Do only one test per line so one can know exactly what went wrong.

This commit is contained in:
Francois Gouget 2009-01-08 00:26:10 +01:00 committed by Alexandre Julliard
parent 9f62c9b7a8
commit 411f5d22c0
10 changed files with 12466 additions and 5214 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -56,104 +56,109 @@
* Test helper macros
*/
#ifdef FIELD_ALIGNMENT
# define TEST_FIELD_ALIGNMENT(type, field, align) \
ok(_TYPE_ALIGNMENT(((type*)0)->field) == align, \
"FIELD_ALIGNMENT(" #type ", " #field ") == %d (expected " #align ")\n", \
(int)_TYPE_ALIGNMENT(((type*)0)->field))
#ifdef _WIN64
# define TEST_TYPE_SIZE(type, size)
# define TEST_TYPE_ALIGN(type, align)
# define TEST_TARGET_ALIGN(type, align)
# define TEST_FIELD_ALIGN(type, field, align)
# define TEST_FIELD_OFFSET(type, field, offset)
#else
# define TEST_FIELD_ALIGNMENT(type, field, align) do { } while (0)
# define TEST_TYPE_SIZE(type, size) C_ASSERT(sizeof(type) == size);
# ifdef TYPE_ALIGNMENT
# define TEST_TYPE_ALIGN(type, align) C_ASSERT(TYPE_ALIGNMENT(type) == align);
# else
# define TEST_TYPE_ALIGN(type, align)
# endif
# ifdef _TYPE_ALIGNMENT
# define TEST_TARGET_ALIGN(type, align) C_ASSERT(_TYPE_ALIGNMENT(*(type)0) == align);
# define TEST_FIELD_ALIGN(type, field, align) C_ASSERT(_TYPE_ALIGNMENT(((type*)0)->field) == align);
# else
# define TEST_TARGET_ALIGN(type, align)
# define TEST_FIELD_ALIGN(type, field, align)
# endif
# define TEST_FIELD_OFFSET(type, field, offset) C_ASSERT(FIELD_OFFSET(type, field) == offset);
#endif
#define TEST_FIELD_OFFSET(type, field, offset) \
ok(FIELD_OFFSET(type, field) == offset, \
"FIELD_OFFSET(" #type ", " #field ") == %ld (expected " #offset ")\n", \
(long int)FIELD_OFFSET(type, field))
#define TEST_TARGET_SIZE(type, size) TEST_TYPE_SIZE(*(type)0, size)
#define TEST_FIELD_SIZE(type, field, size) TEST_TYPE_SIZE((((type*)0)->field), size)
#define TEST_TYPE_SIGNED(type) C_ASSERT((type) -1 < 0);
#define TEST_TYPE_UNSIGNED(type) C_ASSERT((type) -1 > 0);
#ifdef _TYPE_ALIGNMENT
#define TEST__TYPE_ALIGNMENT(type, align) \
ok(_TYPE_ALIGNMENT(type) == align, "TYPE_ALIGNMENT(" #type ") == %d (expected " #align ")\n", (int)_TYPE_ALIGNMENT(type))
#else
# define TEST__TYPE_ALIGNMENT(type, align) do { } while (0)
#endif
#ifdef TYPE_ALIGNMENT
#define TEST_TYPE_ALIGNMENT(type, align) \
ok(TYPE_ALIGNMENT(type) == align, "TYPE_ALIGNMENT(" #type ") == %d (expected " #align ")\n", (int)TYPE_ALIGNMENT(type))
#else
# define TEST_TYPE_ALIGNMENT(type, align) do { } while (0)
#endif
#define TEST_TYPE_SIZE(type, size) \
ok(sizeof(type) == size, "sizeof(" #type ") == %d (expected " #size ")\n", ((int) sizeof(type)))
/***********************************************************************
* Test macros
*/
#define TEST_FIELD(type, field, field_offset, field_size, field_align) \
TEST_TYPE_SIZE((((type*)0)->field), field_size); \
TEST_FIELD_ALIGNMENT(type, field, field_align); \
TEST_FIELD_OFFSET(type, field, field_offset)
#define TEST_TYPE(type, size, align) \
TEST_TYPE_ALIGNMENT(type, align); \
TEST_TYPE_SIZE(type, size)
#define TEST_TYPE_POINTER(type, size, align) \
TEST__TYPE_ALIGNMENT(*(type)0, align); \
TEST_TYPE_SIZE(*(type)0, size)
#define TEST_TYPE_SIGNED(type) \
ok((type) -1 < 0, "(" #type ") -1 < 0\n");
#define TEST_TYPE_UNSIGNED(type) \
ok((type) -1 > 0, "(" #type ") -1 > 0\n");
static void test_pack_ASSOCF(void)
{
/* ASSOCF */
TEST_TYPE(ASSOCF, 4, 4);
TEST_TYPE_UNSIGNED(ASSOCF);
TEST_TYPE_SIZE (ASSOCF, 4)
TEST_TYPE_ALIGN (ASSOCF, 4)
TEST_TYPE_UNSIGNED(ASSOCF)
}
static void test_pack_DLLGETVERSIONPROC(void)
{
/* DLLGETVERSIONPROC */
TEST_TYPE(DLLGETVERSIONPROC, 4, 4);
TEST_TYPE_SIZE (DLLGETVERSIONPROC, 4)
TEST_TYPE_ALIGN (DLLGETVERSIONPROC, 4)
}
static void test_pack_DLLVERSIONINFO(void)
{
/* DLLVERSIONINFO (pack 8) */
TEST_TYPE(DLLVERSIONINFO, 20, 4);
TEST_FIELD(DLLVERSIONINFO, cbSize, 0, 4, 4);
TEST_FIELD(DLLVERSIONINFO, dwMajorVersion, 4, 4, 4);
TEST_FIELD(DLLVERSIONINFO, dwMinorVersion, 8, 4, 4);
TEST_FIELD(DLLVERSIONINFO, dwBuildNumber, 12, 4, 4);
TEST_FIELD(DLLVERSIONINFO, dwPlatformID, 16, 4, 4);
TEST_TYPE_SIZE (DLLVERSIONINFO, 20)
TEST_TYPE_ALIGN (DLLVERSIONINFO, 4)
TEST_FIELD_SIZE (DLLVERSIONINFO, cbSize, 4)
TEST_FIELD_ALIGN (DLLVERSIONINFO, cbSize, 4)
TEST_FIELD_OFFSET(DLLVERSIONINFO, cbSize, 0)
TEST_FIELD_SIZE (DLLVERSIONINFO, dwMajorVersion, 4)
TEST_FIELD_ALIGN (DLLVERSIONINFO, dwMajorVersion, 4)
TEST_FIELD_OFFSET(DLLVERSIONINFO, dwMajorVersion, 4)
TEST_FIELD_SIZE (DLLVERSIONINFO, dwMinorVersion, 4)
TEST_FIELD_ALIGN (DLLVERSIONINFO, dwMinorVersion, 4)
TEST_FIELD_OFFSET(DLLVERSIONINFO, dwMinorVersion, 8)
TEST_FIELD_SIZE (DLLVERSIONINFO, dwBuildNumber, 4)
TEST_FIELD_ALIGN (DLLVERSIONINFO, dwBuildNumber, 4)
TEST_FIELD_OFFSET(DLLVERSIONINFO, dwBuildNumber, 12)
TEST_FIELD_SIZE (DLLVERSIONINFO, dwPlatformID, 4)
TEST_FIELD_ALIGN (DLLVERSIONINFO, dwPlatformID, 4)
TEST_FIELD_OFFSET(DLLVERSIONINFO, dwPlatformID, 16)
}
static void test_pack_DLLVERSIONINFO2(void)
{
/* DLLVERSIONINFO2 (pack 8) */
TEST_TYPE(DLLVERSIONINFO2, 32, 8);
TEST_FIELD(DLLVERSIONINFO2, info1, 0, 20, 4);
TEST_FIELD(DLLVERSIONINFO2, dwFlags, 20, 4, 4);
TEST_FIELD(DLLVERSIONINFO2, ullVersion, 24, 8, 8);
TEST_TYPE_SIZE (DLLVERSIONINFO2, 32)
TEST_TYPE_ALIGN (DLLVERSIONINFO2, 8)
TEST_FIELD_SIZE (DLLVERSIONINFO2, info1, 20)
TEST_FIELD_ALIGN (DLLVERSIONINFO2, info1, 4)
TEST_FIELD_OFFSET(DLLVERSIONINFO2, info1, 0)
TEST_FIELD_SIZE (DLLVERSIONINFO2, dwFlags, 4)
TEST_FIELD_ALIGN (DLLVERSIONINFO2, dwFlags, 4)
TEST_FIELD_OFFSET(DLLVERSIONINFO2, dwFlags, 20)
TEST_FIELD_SIZE (DLLVERSIONINFO2, ullVersion, 8)
TEST_FIELD_ALIGN (DLLVERSIONINFO2, ullVersion, 8)
TEST_FIELD_OFFSET(DLLVERSIONINFO2, ullVersion, 24)
}
static void test_pack_HUSKEY(void)
{
/* HUSKEY */
TEST_TYPE(HUSKEY, 4, 4);
TEST_TYPE_SIZE (HUSKEY, 4)
TEST_TYPE_ALIGN (HUSKEY, 4)
}
static void test_pack_PHUSKEY(void)
{
/* PHUSKEY */
TEST_TYPE(PHUSKEY, 4, 4);
TEST_TYPE_POINTER(PHUSKEY, 4, 4);
TEST_TYPE_SIZE (PHUSKEY, 4)
TEST_TYPE_ALIGN (PHUSKEY, 4)
TEST_TARGET_SIZE (PHUSKEY, 4)
TEST_TARGET_ALIGN(PHUSKEY, 4)
}
static void test_pack(void)

View File

@ -54,65 +54,51 @@
* Test helper macros
*/
#ifdef FIELD_ALIGNMENT
# define TEST_FIELD_ALIGNMENT(type, field, align) \
ok(_TYPE_ALIGNMENT(((type*)0)->field) == align, \
"FIELD_ALIGNMENT(" #type ", " #field ") == %d (expected " #align ")\n", \
(int)_TYPE_ALIGNMENT(((type*)0)->field))
#ifdef _WIN64
# define TEST_TYPE_SIZE(type, size)
# define TEST_TYPE_ALIGN(type, align)
# define TEST_TARGET_ALIGN(type, align)
# define TEST_FIELD_ALIGN(type, field, align)
# define TEST_FIELD_OFFSET(type, field, offset)
#else
# define TEST_FIELD_ALIGNMENT(type, field, align) do { } while (0)
# define TEST_TYPE_SIZE(type, size) C_ASSERT(sizeof(type) == size);
# ifdef TYPE_ALIGNMENT
# define TEST_TYPE_ALIGN(type, align) C_ASSERT(TYPE_ALIGNMENT(type) == align);
# else
# define TEST_TYPE_ALIGN(type, align)
# endif
# ifdef _TYPE_ALIGNMENT
# define TEST_TARGET_ALIGN(type, align) C_ASSERT(_TYPE_ALIGNMENT(*(type)0) == align);
# define TEST_FIELD_ALIGN(type, field, align) C_ASSERT(_TYPE_ALIGNMENT(((type*)0)->field) == align);
# else
# define TEST_TARGET_ALIGN(type, align)
# define TEST_FIELD_ALIGN(type, field, align)
# endif
# define TEST_FIELD_OFFSET(type, field, offset) C_ASSERT(FIELD_OFFSET(type, field) == offset);
#endif
#define TEST_FIELD_OFFSET(type, field, offset) \
ok(FIELD_OFFSET(type, field) == offset, \
"FIELD_OFFSET(" #type ", " #field ") == %ld (expected " #offset ")\n", \
(long int)FIELD_OFFSET(type, field))
#define TEST_TARGET_SIZE(type, size) TEST_TYPE_SIZE(*(type)0, size)
#define TEST_FIELD_SIZE(type, field, size) TEST_TYPE_SIZE((((type*)0)->field), size)
#define TEST_TYPE_SIGNED(type) C_ASSERT((type) -1 < 0);
#define TEST_TYPE_UNSIGNED(type) C_ASSERT((type) -1 > 0);
#ifdef _TYPE_ALIGNMENT
#define TEST__TYPE_ALIGNMENT(type, align) \
ok(_TYPE_ALIGNMENT(type) == align, "TYPE_ALIGNMENT(" #type ") == %d (expected " #align ")\n", (int)_TYPE_ALIGNMENT(type))
#else
# define TEST__TYPE_ALIGNMENT(type, align) do { } while (0)
#endif
#ifdef TYPE_ALIGNMENT
#define TEST_TYPE_ALIGNMENT(type, align) \
ok(TYPE_ALIGNMENT(type) == align, "TYPE_ALIGNMENT(" #type ") == %d (expected " #align ")\n", (int)TYPE_ALIGNMENT(type))
#else
# define TEST_TYPE_ALIGNMENT(type, align) do { } while (0)
#endif
#define TEST_TYPE_SIZE(type, size) \
ok(sizeof(type) == size, "sizeof(" #type ") == %d (expected " #size ")\n", ((int) sizeof(type)))
/***********************************************************************
* Test macros
*/
#define TEST_FIELD(type, field, field_offset, field_size, field_align) \
TEST_TYPE_SIZE((((type*)0)->field), field_size); \
TEST_FIELD_ALIGNMENT(type, field, field_align); \
TEST_FIELD_OFFSET(type, field, field_offset)
#define TEST_TYPE(type, size, align) \
TEST_TYPE_ALIGNMENT(type, align); \
TEST_TYPE_SIZE(type, size)
#define TEST_TYPE_POINTER(type, size, align) \
TEST__TYPE_ALIGNMENT(*(type)0, align); \
TEST_TYPE_SIZE(*(type)0, size)
#define TEST_TYPE_SIGNED(type) \
ok((type) -1 < 0, "(" #type ") -1 < 0\n");
#define TEST_TYPE_UNSIGNED(type) \
ok((type) -1 > 0, "(" #type ") -1 > 0\n");
static void test_pack_BINDINFO(void)
{
/* BINDINFO (pack 4) */
TEST_FIELD(BINDINFO, cbSize, 0, 4, 4);
TEST_FIELD(BINDINFO, szExtraInfo, 4, 4, 4);
TEST_FIELD_SIZE (BINDINFO, cbSize, 4)
TEST_FIELD_ALIGN (BINDINFO, cbSize, 4)
TEST_FIELD_OFFSET(BINDINFO, cbSize, 0)
TEST_FIELD_SIZE (BINDINFO, szExtraInfo, 4)
TEST_FIELD_ALIGN (BINDINFO, szExtraInfo, 4)
TEST_FIELD_OFFSET(BINDINFO, szExtraInfo, 4)
}
static void test_pack_IBindHost(void)
@ -198,106 +184,162 @@ static void test_pack_IWinInetInfoVtbl(void)
static void test_pack_LPBINDHOST(void)
{
/* LPBINDHOST */
TEST_TYPE(LPBINDHOST, 4, 4);
TEST_TYPE_SIZE (LPBINDHOST, 4)
TEST_TYPE_ALIGN (LPBINDHOST, 4)
}
static void test_pack_LPBINDING(void)
{
/* LPBINDING */
TEST_TYPE(LPBINDING, 4, 4);
TEST_TYPE_SIZE (LPBINDING, 4)
TEST_TYPE_ALIGN (LPBINDING, 4)
}
static void test_pack_LPBINDSTATUSCALLBACK(void)
{
/* LPBINDSTATUSCALLBACK */
TEST_TYPE(LPBINDSTATUSCALLBACK, 4, 4);
TEST_TYPE_SIZE (LPBINDSTATUSCALLBACK, 4)
TEST_TYPE_ALIGN (LPBINDSTATUSCALLBACK, 4)
}
static void test_pack_LPIINTERNETPROTOCOLINFO(void)
{
/* LPIINTERNETPROTOCOLINFO */
TEST_TYPE(LPIINTERNETPROTOCOLINFO, 4, 4);
TEST_TYPE_SIZE (LPIINTERNETPROTOCOLINFO, 4)
TEST_TYPE_ALIGN (LPIINTERNETPROTOCOLINFO, 4)
}
static void test_pack_LPIINTERNETSESSION(void)
{
/* LPIINTERNETSESSION */
TEST_TYPE(LPIINTERNETSESSION, 4, 4);
TEST_TYPE_SIZE (LPIINTERNETSESSION, 4)
TEST_TYPE_ALIGN (LPIINTERNETSESSION, 4)
}
static void test_pack_LPPERSISTMONIKER(void)
{
/* LPPERSISTMONIKER */
TEST_TYPE(LPPERSISTMONIKER, 4, 4);
TEST_TYPE_SIZE (LPPERSISTMONIKER, 4)
TEST_TYPE_ALIGN (LPPERSISTMONIKER, 4)
}
static void test_pack_LPREMFORMATETC(void)
{
/* LPREMFORMATETC */
TEST_TYPE(LPREMFORMATETC, 4, 4);
TEST_TYPE_SIZE (LPREMFORMATETC, 4)
TEST_TYPE_ALIGN (LPREMFORMATETC, 4)
}
static void test_pack_LPREMSECURITY_ATTRIBUTES(void)
{
/* LPREMSECURITY_ATTRIBUTES */
TEST_TYPE(LPREMSECURITY_ATTRIBUTES, 4, 4);
TEST_TYPE_SIZE (LPREMSECURITY_ATTRIBUTES, 4)
TEST_TYPE_ALIGN (LPREMSECURITY_ATTRIBUTES, 4)
}
static void test_pack_LPWININETHTTPINFO(void)
{
/* LPWININETHTTPINFO */
TEST_TYPE(LPWININETHTTPINFO, 4, 4);
TEST_TYPE_SIZE (LPWININETHTTPINFO, 4)
TEST_TYPE_ALIGN (LPWININETHTTPINFO, 4)
}
static void test_pack_LPWININETINFO(void)
{
/* LPWININETINFO */
TEST_TYPE(LPWININETINFO, 4, 4);
TEST_TYPE_SIZE (LPWININETINFO, 4)
TEST_TYPE_ALIGN (LPWININETINFO, 4)
}
static void test_pack_PREMSECURITY_ATTRIBUTES(void)
{
/* PREMSECURITY_ATTRIBUTES */
TEST_TYPE(PREMSECURITY_ATTRIBUTES, 4, 4);
TEST_TYPE_SIZE (PREMSECURITY_ATTRIBUTES, 4)
TEST_TYPE_ALIGN (PREMSECURITY_ATTRIBUTES, 4)
}
static void test_pack_REMSECURITY_ATTRIBUTES(void)
{
/* REMSECURITY_ATTRIBUTES (pack 4) */
TEST_TYPE(REMSECURITY_ATTRIBUTES, 12, 4);
TEST_FIELD(REMSECURITY_ATTRIBUTES, nLength, 0, 4, 4);
TEST_FIELD(REMSECURITY_ATTRIBUTES, lpSecurityDescriptor, 4, 4, 4);
TEST_FIELD(REMSECURITY_ATTRIBUTES, bInheritHandle, 8, 4, 4);
TEST_TYPE_SIZE (REMSECURITY_ATTRIBUTES, 12)
TEST_TYPE_ALIGN (REMSECURITY_ATTRIBUTES, 4)
TEST_FIELD_SIZE (REMSECURITY_ATTRIBUTES, nLength, 4)
TEST_FIELD_ALIGN (REMSECURITY_ATTRIBUTES, nLength, 4)
TEST_FIELD_OFFSET(REMSECURITY_ATTRIBUTES, nLength, 0)
TEST_FIELD_SIZE (REMSECURITY_ATTRIBUTES, lpSecurityDescriptor, 4)
TEST_FIELD_ALIGN (REMSECURITY_ATTRIBUTES, lpSecurityDescriptor, 4)
TEST_FIELD_OFFSET(REMSECURITY_ATTRIBUTES, lpSecurityDescriptor, 4)
TEST_FIELD_SIZE (REMSECURITY_ATTRIBUTES, bInheritHandle, 4)
TEST_FIELD_ALIGN (REMSECURITY_ATTRIBUTES, bInheritHandle, 4)
TEST_FIELD_OFFSET(REMSECURITY_ATTRIBUTES, bInheritHandle, 8)
}
static void test_pack_RemBINDINFO(void)
{
/* RemBINDINFO (pack 4) */
TEST_TYPE(RemBINDINFO, 72, 4);
TEST_FIELD(RemBINDINFO, cbSize, 0, 4, 4);
TEST_FIELD(RemBINDINFO, szExtraInfo, 4, 4, 4);
TEST_FIELD(RemBINDINFO, grfBindInfoF, 8, 4, 4);
TEST_FIELD(RemBINDINFO, dwBindVerb, 12, 4, 4);
TEST_FIELD(RemBINDINFO, szCustomVerb, 16, 4, 4);
TEST_FIELD(RemBINDINFO, cbstgmedData, 20, 4, 4);
TEST_FIELD(RemBINDINFO, dwOptions, 24, 4, 4);
TEST_FIELD(RemBINDINFO, dwOptionsFlags, 28, 4, 4);
TEST_FIELD(RemBINDINFO, dwCodePage, 32, 4, 4);
TEST_FIELD(RemBINDINFO, securityAttributes, 36, 12, 4);
TEST_FIELD(RemBINDINFO, iid, 48, 16, 4);
TEST_FIELD(RemBINDINFO, pUnk, 64, 4, 4);
TEST_FIELD(RemBINDINFO, dwReserved, 68, 4, 4);
TEST_TYPE_SIZE (RemBINDINFO, 72)
TEST_TYPE_ALIGN (RemBINDINFO, 4)
TEST_FIELD_SIZE (RemBINDINFO, cbSize, 4)
TEST_FIELD_ALIGN (RemBINDINFO, cbSize, 4)
TEST_FIELD_OFFSET(RemBINDINFO, cbSize, 0)
TEST_FIELD_SIZE (RemBINDINFO, szExtraInfo, 4)
TEST_FIELD_ALIGN (RemBINDINFO, szExtraInfo, 4)
TEST_FIELD_OFFSET(RemBINDINFO, szExtraInfo, 4)
TEST_FIELD_SIZE (RemBINDINFO, grfBindInfoF, 4)
TEST_FIELD_ALIGN (RemBINDINFO, grfBindInfoF, 4)
TEST_FIELD_OFFSET(RemBINDINFO, grfBindInfoF, 8)
TEST_FIELD_SIZE (RemBINDINFO, dwBindVerb, 4)
TEST_FIELD_ALIGN (RemBINDINFO, dwBindVerb, 4)
TEST_FIELD_OFFSET(RemBINDINFO, dwBindVerb, 12)
TEST_FIELD_SIZE (RemBINDINFO, szCustomVerb, 4)
TEST_FIELD_ALIGN (RemBINDINFO, szCustomVerb, 4)
TEST_FIELD_OFFSET(RemBINDINFO, szCustomVerb, 16)
TEST_FIELD_SIZE (RemBINDINFO, cbstgmedData, 4)
TEST_FIELD_ALIGN (RemBINDINFO, cbstgmedData, 4)
TEST_FIELD_OFFSET(RemBINDINFO, cbstgmedData, 20)
TEST_FIELD_SIZE (RemBINDINFO, dwOptions, 4)
TEST_FIELD_ALIGN (RemBINDINFO, dwOptions, 4)
TEST_FIELD_OFFSET(RemBINDINFO, dwOptions, 24)
TEST_FIELD_SIZE (RemBINDINFO, dwOptionsFlags, 4)
TEST_FIELD_ALIGN (RemBINDINFO, dwOptionsFlags, 4)
TEST_FIELD_OFFSET(RemBINDINFO, dwOptionsFlags, 28)
TEST_FIELD_SIZE (RemBINDINFO, dwCodePage, 4)
TEST_FIELD_ALIGN (RemBINDINFO, dwCodePage, 4)
TEST_FIELD_OFFSET(RemBINDINFO, dwCodePage, 32)
TEST_FIELD_SIZE (RemBINDINFO, securityAttributes, 12)
TEST_FIELD_ALIGN (RemBINDINFO, securityAttributes, 4)
TEST_FIELD_OFFSET(RemBINDINFO, securityAttributes, 36)
TEST_FIELD_SIZE (RemBINDINFO, iid, 16)
TEST_FIELD_ALIGN (RemBINDINFO, iid, 4)
TEST_FIELD_OFFSET(RemBINDINFO, iid, 48)
TEST_FIELD_SIZE (RemBINDINFO, pUnk, 4)
TEST_FIELD_ALIGN (RemBINDINFO, pUnk, 4)
TEST_FIELD_OFFSET(RemBINDINFO, pUnk, 64)
TEST_FIELD_SIZE (RemBINDINFO, dwReserved, 4)
TEST_FIELD_ALIGN (RemBINDINFO, dwReserved, 4)
TEST_FIELD_OFFSET(RemBINDINFO, dwReserved, 68)
}
static void test_pack_RemFORMATETC(void)
{
/* RemFORMATETC (pack 4) */
TEST_TYPE(RemFORMATETC, 20, 4);
TEST_FIELD(RemFORMATETC, cfFormat, 0, 4, 4);
TEST_FIELD(RemFORMATETC, ptd, 4, 4, 4);
TEST_FIELD(RemFORMATETC, dwAspect, 8, 4, 4);
TEST_FIELD(RemFORMATETC, lindex, 12, 4, 4);
TEST_FIELD(RemFORMATETC, tymed, 16, 4, 4);
TEST_TYPE_SIZE (RemFORMATETC, 20)
TEST_TYPE_ALIGN (RemFORMATETC, 4)
TEST_FIELD_SIZE (RemFORMATETC, cfFormat, 4)
TEST_FIELD_ALIGN (RemFORMATETC, cfFormat, 4)
TEST_FIELD_OFFSET(RemFORMATETC, cfFormat, 0)
TEST_FIELD_SIZE (RemFORMATETC, ptd, 4)
TEST_FIELD_ALIGN (RemFORMATETC, ptd, 4)
TEST_FIELD_OFFSET(RemFORMATETC, ptd, 4)
TEST_FIELD_SIZE (RemFORMATETC, dwAspect, 4)
TEST_FIELD_ALIGN (RemFORMATETC, dwAspect, 4)
TEST_FIELD_OFFSET(RemFORMATETC, dwAspect, 8)
TEST_FIELD_SIZE (RemFORMATETC, lindex, 4)
TEST_FIELD_ALIGN (RemFORMATETC, lindex, 4)
TEST_FIELD_OFFSET(RemFORMATETC, lindex, 12)
TEST_FIELD_SIZE (RemFORMATETC, tymed, 4)
TEST_FIELD_ALIGN (RemFORMATETC, tymed, 4)
TEST_FIELD_OFFSET(RemFORMATETC, tymed, 16)
}
static void test_pack(void)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -536,59 +536,41 @@ sub output_header($$$) {
print OUT " * Test helper macros\n";
print OUT " */\n";
print OUT "\n";
print OUT "#ifdef FIELD_ALIGNMENT\n";
print OUT "# define TEST_FIELD_ALIGNMENT(type, field, align) \\\n";
print OUT " ok(_TYPE_ALIGNMENT(((type*)0)->field) == align, \\\n";
print OUT " \"FIELD_ALIGNMENT(\" #type \", \" #field \") == %d (expected \" #align \")\\n\", \\\n";
print OUT " (int)_TYPE_ALIGNMENT(((type*)0)->field))\n";
print OUT "#ifdef _WIN64\n";
print OUT "\n";
print OUT "# define TEST_TYPE_SIZE(type, size)\n";
print OUT "# define TEST_TYPE_ALIGN(type, align)\n";
print OUT "# define TEST_TARGET_ALIGN(type, align)\n";
print OUT "# define TEST_FIELD_ALIGN(type, field, align)\n";
print OUT "# define TEST_FIELD_OFFSET(type, field, offset)\n";
print OUT "\n";
print OUT "#else\n";
print OUT "# define TEST_FIELD_ALIGNMENT(type, field, align) do { } while (0)\n";
print OUT "\n";
print OUT "# define TEST_TYPE_SIZE(type, size) C_ASSERT(sizeof(type) == size);\n";
print OUT "\n";
print OUT "# ifdef TYPE_ALIGNMENT\n";
print OUT "# define TEST_TYPE_ALIGN(type, align) C_ASSERT(TYPE_ALIGNMENT(type) == align);\n";
print OUT "# else\n";
print OUT "# define TEST_TYPE_ALIGN(type, align)\n";
print OUT "# endif\n";
print OUT "\n";
print OUT "# ifdef _TYPE_ALIGNMENT\n";
print OUT "# define TEST_TARGET_ALIGN(type, align) C_ASSERT(_TYPE_ALIGNMENT(*(type)0) == align);\n";
print OUT "# define TEST_FIELD_ALIGN(type, field, align) C_ASSERT(_TYPE_ALIGNMENT(((type*)0)->field) == align);\n";
print OUT "# else\n";
print OUT "# define TEST_TARGET_ALIGN(type, align)\n";
print OUT "# define TEST_FIELD_ALIGN(type, field, align)\n";
print OUT "# endif\n";
print OUT "\n";
print OUT "# define TEST_FIELD_OFFSET(type, field, offset) C_ASSERT(FIELD_OFFSET(type, field) == offset);\n";
print OUT "\n";
print OUT "#endif\n";
print OUT "\n";
print OUT "#define TEST_FIELD_OFFSET(type, field, offset) \\\n";
print OUT " ok(FIELD_OFFSET(type, field) == offset, \\\n";
print OUT " \"FIELD_OFFSET(\" #type \", \" #field \") == %ld (expected \" #offset \")\\n\", \\\n";
print OUT " (long int)FIELD_OFFSET(type, field))\n";
print OUT "#define TEST_TARGET_SIZE(type, size) TEST_TYPE_SIZE(*(type)0, size)\n";
print OUT "#define TEST_FIELD_SIZE(type, field, size) TEST_TYPE_SIZE((((type*)0)->field), size)\n";
print OUT "#define TEST_TYPE_SIGNED(type) C_ASSERT((type) -1 < 0);\n";
print OUT "#define TEST_TYPE_UNSIGNED(type) C_ASSERT((type) -1 > 0);\n";
print OUT "\n";
print OUT "#ifdef _TYPE_ALIGNMENT\n";
print OUT "#define TEST__TYPE_ALIGNMENT(type, align) \\\n";
print OUT " ok(_TYPE_ALIGNMENT(type) == align, \"TYPE_ALIGNMENT(\" #type \") == %d (expected \" #align \")\\n\", (int)_TYPE_ALIGNMENT(type))\n";
print OUT "#else\n";
print OUT "# define TEST__TYPE_ALIGNMENT(type, align) do { } while (0)\n";
print OUT "#endif\n";
print OUT "\n";
print OUT "#ifdef TYPE_ALIGNMENT\n";
print OUT "#define TEST_TYPE_ALIGNMENT(type, align) \\\n";
print OUT " ok(TYPE_ALIGNMENT(type) == align, \"TYPE_ALIGNMENT(\" #type \") == %d (expected \" #align \")\\n\", (int)TYPE_ALIGNMENT(type))\n";
print OUT "#else\n";
print OUT "# define TEST_TYPE_ALIGNMENT(type, align) do { } while (0)\n";
print OUT "#endif\n";
print OUT "\n";
print OUT "#define TEST_TYPE_SIZE(type, size) \\\n";
print OUT " ok(sizeof(type) == size, \"sizeof(\" #type \") == %d (expected \" #size \")\\n\", ((int) sizeof(type)))\n";
print OUT "\n";
print OUT "/***********************************************************************\n";
print OUT " * Test macros\n";
print OUT " */\n";
print OUT "\n";
print OUT "#define TEST_FIELD(type, field, field_offset, field_size, field_align) \\\n";
print OUT " TEST_TYPE_SIZE((((type*)0)->field), field_size); \\\n";
print OUT " TEST_FIELD_ALIGNMENT(type, field, field_align); \\\n";
print OUT " TEST_FIELD_OFFSET(type, field, field_offset)\n";
print OUT "\n";
print OUT "#define TEST_TYPE(type, size, align) \\\n";
print OUT " TEST_TYPE_ALIGNMENT(type, align); \\\n";
print OUT " TEST_TYPE_SIZE(type, size)\n";
print OUT "\n";
print OUT "#define TEST_TYPE_POINTER(type, size, align) \\\n";
print OUT " TEST__TYPE_ALIGNMENT(*(type)0, align); \\\n";
print OUT " TEST_TYPE_SIZE(*(type)0, size)\n";
print OUT "\n";
print OUT "#define TEST_TYPE_SIGNED(type) \\\n";
print OUT " ok((type) -1 < 0, \"(\" #type \") -1 < 0\\n\");\n";
print OUT "\n";
print OUT "#define TEST_TYPE_UNSIGNED(type) \\\n";
print OUT " ok((type) -1 > 0, \"(\" #type \") -1 > 0\\n\");\n";
print OUT "\n";
}
@ -635,7 +617,8 @@ sub output_test_pack_type($$$$$$) {
}
if (!scalar(keys(%$optional_fields)) && defined($type_align) && defined($type_size)) {
print OUT " TEST_TYPE($type_name, $type_size, $type_align);\n";
print OUT " TEST_TYPE_SIZE ($type_name, $type_size)\n";
print OUT " TEST_TYPE_ALIGN ($type_name, $type_align)\n";
}
if ($type_kind eq "float") {
@ -684,15 +667,16 @@ sub output_test_pack_type($$$$$$) {
my $optional_fields2 = $$type_name2optional_fields{$type_name2};
if (!$optional && !scalar(keys(%$optional_fields2)) && defined($type_align2) && defined($type_size2)) {
print OUT " TEST_TYPE_POINTER($type_name, $type_size2, $type_align2);\n";
print OUT " TEST_TARGET_SIZE ($type_name, $type_size2)\n";
print OUT " TEST_TARGET_ALIGN($type_name, $type_align2)\n";
} else {
# $output->write("$type_name: warning: type size not found\n");
}
}
} elsif ($type_kind eq "signed") {
print OUT " TEST_TYPE_SIGNED($type_name);\n";
print OUT " TEST_TYPE_SIGNED($type_name)\n";
} elsif ($type_kind eq "unsigned") {
print OUT " TEST_TYPE_UNSIGNED($type_name);\n";
print OUT " TEST_TYPE_UNSIGNED($type_name)\n";
}
}
@ -727,15 +711,17 @@ sub output_test_pack_fields($$$$$$$) {
$field_offset += $offset;
if ($field_name eq "DUMMYSTRUCTNAME") {
print OUT "#ifdef NONAMELESSSTRUCT\n";
print OUT " TEST_FIELD($type_name, $field_name, ";
print OUT "$field_offset, $field_size, $field_align);\n";
print OUT " TEST_TYPE_SIZE ($type_name.$field_name, $field_size)\n";
print OUT " TEST_FIELD_ALIGN ($type_name, $field_name, $field_align)\n";
print OUT " TEST_FIELD_OFFSET($type_name, $field_name, $field_offset)\n";
print OUT "#else\n";
output_test_pack_fields(\*OUT, $type_name2type, $type_name2optional, $type_name2optional_fields,
$type_name, $$type_name2type{$field_type_name}, $field_offset);
print OUT "#endif\n";
} else {
print OUT " TEST_FIELD($type_name, $field_name, ";
print OUT "$field_offset, $field_size, $field_align);\n";
print OUT " TEST_FIELD_SIZE ($type_name, $field_name, $field_size)\n";
print OUT " TEST_FIELD_ALIGN ($type_name, $field_name, $field_align)\n";
print OUT " TEST_FIELD_OFFSET($type_name, $field_name, $field_offset)\n";
}
} else {
# $output->write("$type_name: $field_type_name: $field_name: test not generated (offset not defined)\n");