1 /* File generated automatically from tools/winapi/tests.dat; do not edit! */
2 /* This file can be copied, modified and distributed without restriction. */
5 * Unit tests for data structure packing
9 #define _WIN32_IE 0x0501
10 #define _WIN32_WINNT 0x0501
12 #define WINE_NOWINSOCK
21 #include "wine/test.h"
23 /***********************************************************************
24 * Compatibility macros
27 #define DWORD_PTR UINT_PTR
28 #define LONG_PTR INT_PTR
29 #define ULONG_PTR UINT_PTR
31 /***********************************************************************
32 * Windows API extension
35 #if defined(_MSC_VER) && (_MSC_VER >= 1300) && defined(__cplusplus)
36 # define _TYPE_ALIGNMENT(type) __alignof(type)
37 #elif defined(__GNUC__)
38 # define _TYPE_ALIGNMENT(type) __alignof__(type)
41 * FIXME: May not be possible without a compiler extension
42 * (if type is not just a name that is, otherwise the normal
43 * TYPE_ALIGNMENT can be used)
47 #if defined(TYPE_ALIGNMENT) && defined(_MSC_VER) && _MSC_VER >= 800 && !defined(__cplusplus)
48 #pragma warning(disable:4116)
51 #if !defined(TYPE_ALIGNMENT) && defined(_TYPE_ALIGNMENT)
52 # define TYPE_ALIGNMENT _TYPE_ALIGNMENT
55 /***********************************************************************
61 # define TEST_TYPE_SIZE(type, size)
62 # define TEST_TYPE_ALIGN(type, align)
63 # define TEST_TARGET_ALIGN(type, align)
64 # define TEST_FIELD_ALIGN(type, field, align)
65 # define TEST_FIELD_OFFSET(type, field, offset)
69 # define TEST_TYPE_SIZE(type, size) C_ASSERT(sizeof(type) == size);
71 # ifdef TYPE_ALIGNMENT
72 # define TEST_TYPE_ALIGN(type, align) C_ASSERT(TYPE_ALIGNMENT(type) == align);
74 # define TEST_TYPE_ALIGN(type, align)
77 # ifdef _TYPE_ALIGNMENT
78 # define TEST_TARGET_ALIGN(type, align) C_ASSERT(_TYPE_ALIGNMENT(*(type)0) == align);
79 # define TEST_FIELD_ALIGN(type, field, align) C_ASSERT(_TYPE_ALIGNMENT(((type*)0)->field) == align);
81 # define TEST_TARGET_ALIGN(type, align)
82 # define TEST_FIELD_ALIGN(type, field, align)
85 # define TEST_FIELD_OFFSET(type, field, offset) C_ASSERT(FIELD_OFFSET(type, field) == offset);
89 #define TEST_TARGET_SIZE(type, size) TEST_TYPE_SIZE(*(type)0, size)
90 #define TEST_FIELD_SIZE(type, field, size) TEST_TYPE_SIZE((((type*)0)->field), size)
91 #define TEST_TYPE_SIGNED(type) C_ASSERT((type) -1 < 0);
92 #define TEST_TYPE_UNSIGNED(type) C_ASSERT((type) -1 > 0);
95 static void test_pack_ASSOCF(void)
98 TEST_TYPE_SIZE (ASSOCF
, 4)
99 TEST_TYPE_ALIGN (ASSOCF
, 4)
100 TEST_TYPE_UNSIGNED(ASSOCF
)
103 static void test_pack_DLLGETVERSIONPROC(void)
105 /* DLLGETVERSIONPROC */
106 TEST_TYPE_SIZE (DLLGETVERSIONPROC
, 4)
107 TEST_TYPE_ALIGN (DLLGETVERSIONPROC
, 4)
110 static void test_pack_DLLVERSIONINFO(void)
112 /* DLLVERSIONINFO (pack 8) */
113 TEST_TYPE_SIZE (DLLVERSIONINFO
, 20)
114 TEST_TYPE_ALIGN (DLLVERSIONINFO
, 4)
115 TEST_FIELD_SIZE (DLLVERSIONINFO
, cbSize
, 4)
116 TEST_FIELD_ALIGN (DLLVERSIONINFO
, cbSize
, 4)
117 TEST_FIELD_OFFSET(DLLVERSIONINFO
, cbSize
, 0)
118 TEST_FIELD_SIZE (DLLVERSIONINFO
, dwMajorVersion
, 4)
119 TEST_FIELD_ALIGN (DLLVERSIONINFO
, dwMajorVersion
, 4)
120 TEST_FIELD_OFFSET(DLLVERSIONINFO
, dwMajorVersion
, 4)
121 TEST_FIELD_SIZE (DLLVERSIONINFO
, dwMinorVersion
, 4)
122 TEST_FIELD_ALIGN (DLLVERSIONINFO
, dwMinorVersion
, 4)
123 TEST_FIELD_OFFSET(DLLVERSIONINFO
, dwMinorVersion
, 8)
124 TEST_FIELD_SIZE (DLLVERSIONINFO
, dwBuildNumber
, 4)
125 TEST_FIELD_ALIGN (DLLVERSIONINFO
, dwBuildNumber
, 4)
126 TEST_FIELD_OFFSET(DLLVERSIONINFO
, dwBuildNumber
, 12)
127 TEST_FIELD_SIZE (DLLVERSIONINFO
, dwPlatformID
, 4)
128 TEST_FIELD_ALIGN (DLLVERSIONINFO
, dwPlatformID
, 4)
129 TEST_FIELD_OFFSET(DLLVERSIONINFO
, dwPlatformID
, 16)
132 static void test_pack_DLLVERSIONINFO2(void)
134 /* DLLVERSIONINFO2 (pack 8) */
135 TEST_TYPE_SIZE (DLLVERSIONINFO2
, 32)
136 TEST_TYPE_ALIGN (DLLVERSIONINFO2
, 8)
137 TEST_FIELD_SIZE (DLLVERSIONINFO2
, info1
, 20)
138 TEST_FIELD_ALIGN (DLLVERSIONINFO2
, info1
, 4)
139 TEST_FIELD_OFFSET(DLLVERSIONINFO2
, info1
, 0)
140 TEST_FIELD_SIZE (DLLVERSIONINFO2
, dwFlags
, 4)
141 TEST_FIELD_ALIGN (DLLVERSIONINFO2
, dwFlags
, 4)
142 TEST_FIELD_OFFSET(DLLVERSIONINFO2
, dwFlags
, 20)
143 TEST_FIELD_SIZE (DLLVERSIONINFO2
, ullVersion
, 8)
144 TEST_FIELD_ALIGN (DLLVERSIONINFO2
, ullVersion
, 8)
145 TEST_FIELD_OFFSET(DLLVERSIONINFO2
, ullVersion
, 24)
148 static void test_pack_HUSKEY(void)
151 TEST_TYPE_SIZE (HUSKEY
, 4)
152 TEST_TYPE_ALIGN (HUSKEY
, 4)
155 static void test_pack_PHUSKEY(void)
158 TEST_TYPE_SIZE (PHUSKEY
, 4)
159 TEST_TYPE_ALIGN (PHUSKEY
, 4)
160 TEST_TARGET_SIZE (PHUSKEY
, 4)
161 TEST_TARGET_ALIGN(PHUSKEY
, 4)
164 static void test_pack(void)
167 test_pack_DLLGETVERSIONPROC();
168 test_pack_DLLVERSIONINFO();
169 test_pack_DLLVERSIONINFO2();
174 START_TEST(generated
)
177 ok(0, "The type size / alignment tests don't support Win64 yet\n");