2009-01-08 00:18:27 +01:00
|
|
|
/* File generated automatically from tools/winapi/tests.dat; do not edit! */
|
2002-11-12 02:13:10 +01:00
|
|
|
/* This file can be copied, modified and distributed without restriction. */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Unit tests for data structure packing
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define WINVER 0x0501
|
|
|
|
#define _WIN32_IE 0x0501
|
|
|
|
#define _WIN32_WINNT 0x0501
|
|
|
|
|
|
|
|
#define WINE_NOWINSOCK
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2002-11-12 02:13:10 +01:00
|
|
|
#include "windef.h"
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "winbase.h"
|
2002-11-12 02:13:10 +01:00
|
|
|
#include "wtypes.h"
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "winreg.h"
|
2002-11-12 02:13:10 +01:00
|
|
|
#include "shlwapi.h"
|
|
|
|
|
|
|
|
#include "wine/test.h"
|
|
|
|
|
|
|
|
/***********************************************************************
|
2008-01-16 12:17:40 +01:00
|
|
|
* Compatibility macros
|
2002-11-12 02:13:10 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#define DWORD_PTR UINT_PTR
|
|
|
|
#define LONG_PTR INT_PTR
|
|
|
|
#define ULONG_PTR UINT_PTR
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* Windows API extension
|
|
|
|
*/
|
|
|
|
|
2003-10-24 06:45:35 +02:00
|
|
|
#if defined(_MSC_VER) && (_MSC_VER >= 1300) && defined(__cplusplus)
|
2002-11-12 02:13:10 +01:00
|
|
|
# define _TYPE_ALIGNMENT(type) __alignof(type)
|
|
|
|
#elif defined(__GNUC__)
|
|
|
|
# define _TYPE_ALIGNMENT(type) __alignof__(type)
|
|
|
|
#else
|
|
|
|
/*
|
2009-01-08 00:18:48 +01:00
|
|
|
* FIXME: May not be possible without a compiler extension
|
|
|
|
* (if type is not just a name that is, otherwise the normal
|
2002-11-12 02:13:10 +01:00
|
|
|
* TYPE_ALIGNMENT can be used)
|
|
|
|
*/
|
|
|
|
#endif
|
|
|
|
|
2004-09-06 22:29:53 +02:00
|
|
|
#if defined(TYPE_ALIGNMENT) && defined(_MSC_VER) && _MSC_VER >= 800 && !defined(__cplusplus)
|
|
|
|
#pragma warning(disable:4116)
|
|
|
|
#endif
|
|
|
|
|
2002-11-12 02:13:10 +01:00
|
|
|
#if !defined(TYPE_ALIGNMENT) && defined(_TYPE_ALIGNMENT)
|
|
|
|
# define TYPE_ALIGNMENT _TYPE_ALIGNMENT
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* Test helper macros
|
|
|
|
*/
|
|
|
|
|
2009-01-08 00:26:10 +01:00
|
|
|
#ifdef _WIN64
|
2002-11-12 02:13:10 +01:00
|
|
|
|
2009-01-08 00:26:10 +01:00
|
|
|
# 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)
|
2002-11-12 02:13:10 +01:00
|
|
|
|
|
|
|
#else
|
|
|
|
|
2009-01-08 00:26:10 +01:00
|
|
|
# define TEST_TYPE_SIZE(type, size) C_ASSERT(sizeof(type) == size);
|
2002-11-12 02:13:10 +01:00
|
|
|
|
2009-01-08 00:26:10 +01:00
|
|
|
# ifdef TYPE_ALIGNMENT
|
|
|
|
# define TEST_TYPE_ALIGN(type, align) C_ASSERT(TYPE_ALIGNMENT(type) == align);
|
|
|
|
# else
|
|
|
|
# define TEST_TYPE_ALIGN(type, align)
|
|
|
|
# endif
|
2002-11-12 02:13:10 +01:00
|
|
|
|
2009-01-08 00:26:10 +01:00
|
|
|
# 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
|
2002-11-12 02:13:10 +01:00
|
|
|
|
2009-01-08 00:26:10 +01:00
|
|
|
# define TEST_FIELD_OFFSET(type, field, offset) C_ASSERT(FIELD_OFFSET(type, field) == offset);
|
2002-11-12 02:13:10 +01:00
|
|
|
|
2009-01-08 00:26:10 +01:00
|
|
|
#endif
|
2002-11-12 02:13:10 +01:00
|
|
|
|
2009-01-08 00:26:10 +01:00
|
|
|
#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);
|
2002-11-12 02:13:10 +01:00
|
|
|
|
|
|
|
|
2004-05-04 02:41:11 +02:00
|
|
|
static void test_pack_ASSOCF(void)
|
|
|
|
{
|
|
|
|
/* ASSOCF */
|
2009-01-08 00:26:10 +01:00
|
|
|
TEST_TYPE_SIZE (ASSOCF, 4)
|
|
|
|
TEST_TYPE_ALIGN (ASSOCF, 4)
|
|
|
|
TEST_TYPE_UNSIGNED(ASSOCF)
|
2004-05-04 02:41:11 +02:00
|
|
|
}
|
|
|
|
|
2002-11-12 02:13:10 +01:00
|
|
|
static void test_pack_DLLGETVERSIONPROC(void)
|
|
|
|
{
|
|
|
|
/* DLLGETVERSIONPROC */
|
2009-01-08 00:26:10 +01:00
|
|
|
TEST_TYPE_SIZE (DLLGETVERSIONPROC, 4)
|
|
|
|
TEST_TYPE_ALIGN (DLLGETVERSIONPROC, 4)
|
2002-11-12 02:13:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void test_pack_DLLVERSIONINFO(void)
|
|
|
|
{
|
2004-08-19 21:59:41 +02:00
|
|
|
/* DLLVERSIONINFO (pack 8) */
|
2009-01-08 00:26:10 +01:00
|
|
|
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)
|
2002-11-12 02:13:10 +01:00
|
|
|
}
|
|
|
|
|
2004-05-04 02:41:11 +02:00
|
|
|
static void test_pack_DLLVERSIONINFO2(void)
|
|
|
|
{
|
2004-08-19 21:59:41 +02:00
|
|
|
/* DLLVERSIONINFO2 (pack 8) */
|
2009-01-08 00:26:10 +01:00
|
|
|
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)
|
2004-05-04 02:41:11 +02:00
|
|
|
}
|
|
|
|
|
2002-11-12 02:13:10 +01:00
|
|
|
static void test_pack_HUSKEY(void)
|
|
|
|
{
|
|
|
|
/* HUSKEY */
|
2009-01-08 00:26:10 +01:00
|
|
|
TEST_TYPE_SIZE (HUSKEY, 4)
|
|
|
|
TEST_TYPE_ALIGN (HUSKEY, 4)
|
2002-11-12 02:13:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void test_pack_PHUSKEY(void)
|
|
|
|
{
|
|
|
|
/* PHUSKEY */
|
2009-01-08 00:26:10 +01:00
|
|
|
TEST_TYPE_SIZE (PHUSKEY, 4)
|
|
|
|
TEST_TYPE_ALIGN (PHUSKEY, 4)
|
|
|
|
TEST_TARGET_SIZE (PHUSKEY, 4)
|
|
|
|
TEST_TARGET_ALIGN(PHUSKEY, 4)
|
2002-11-12 02:13:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void test_pack(void)
|
|
|
|
{
|
2004-05-04 02:41:11 +02:00
|
|
|
test_pack_ASSOCF();
|
2002-11-12 02:13:10 +01:00
|
|
|
test_pack_DLLGETVERSIONPROC();
|
|
|
|
test_pack_DLLVERSIONINFO();
|
2004-05-04 02:41:11 +02:00
|
|
|
test_pack_DLLVERSIONINFO2();
|
2002-11-12 02:13:10 +01:00
|
|
|
test_pack_HUSKEY();
|
|
|
|
test_pack_PHUSKEY();
|
|
|
|
}
|
|
|
|
|
|
|
|
START_TEST(generated)
|
|
|
|
{
|
2009-01-08 00:24:16 +01:00
|
|
|
#ifdef _WIN64
|
|
|
|
ok(0, "The type size / alignment tests don't support Win64 yet\n");
|
|
|
|
#else
|
2002-11-12 02:13:10 +01:00
|
|
|
test_pack();
|
2009-01-08 00:24:16 +01:00
|
|
|
#endif
|
2002-11-12 02:13:10 +01:00
|
|
|
}
|