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
17 #include "wine/test.h"
19 /***********************************************************************
20 * Compatibility macros
23 #define DWORD_PTR UINT_PTR
24 #define LONG_PTR INT_PTR
25 #define ULONG_PTR UINT_PTR
27 /***********************************************************************
28 * Windows API extension
31 #if defined(_MSC_VER) && (_MSC_VER >= 1300) && defined(__cplusplus)
32 # define _TYPE_ALIGNMENT(type) __alignof(type)
33 #elif defined(__GNUC__) || defined(__clang__)
34 # define _TYPE_ALIGNMENT(type) __alignof__(type)
37 * FIXME: May not be possible without a compiler extension
38 * (if type is not just a name that is, otherwise the normal
39 * TYPE_ALIGNMENT can be used)
43 #if defined(TYPE_ALIGNMENT) && defined(_MSC_VER) && _MSC_VER >= 800 && !defined(__cplusplus)
44 #pragma warning(disable:4116)
47 #if !defined(TYPE_ALIGNMENT) && defined(_TYPE_ALIGNMENT)
48 # define TYPE_ALIGNMENT _TYPE_ALIGNMENT
51 /***********************************************************************
55 #define TEST_TYPE_SIZE(type, size) C_ASSERT(sizeof(type) == size);
58 # define TEST_TYPE_ALIGN(type, align) C_ASSERT(TYPE_ALIGNMENT(type) == align);
60 # define TEST_TYPE_ALIGN(type, align)
63 #ifdef _TYPE_ALIGNMENT
64 # define TEST_TARGET_ALIGN(type, align) C_ASSERT(_TYPE_ALIGNMENT(*(type)0) == align);
65 # define TEST_FIELD_ALIGN(type, field, align) C_ASSERT(_TYPE_ALIGNMENT(((type*)0)->field) == align);
67 # define TEST_TARGET_ALIGN(type, align)
68 # define TEST_FIELD_ALIGN(type, field, align)
71 #define TEST_FIELD_OFFSET(type, field, offset) C_ASSERT(FIELD_OFFSET(type, field) == offset);
73 #define TEST_TARGET_SIZE(type, size) TEST_TYPE_SIZE(*(type)0, size)
74 #define TEST_FIELD_SIZE(type, field, size) TEST_TYPE_SIZE((((type*)0)->field), size)
75 #define TEST_TYPE_SIGNED(type) C_ASSERT((type) -1 < 0);
76 #define TEST_TYPE_UNSIGNED(type) C_ASSERT((type) -1 > 0);
81 static void test_pack_ASSOCF(void)
84 TEST_TYPE_SIZE (ASSOCF
, 4)
85 TEST_TYPE_ALIGN (ASSOCF
, 4)
86 TEST_TYPE_UNSIGNED(ASSOCF
)
89 static void test_pack_DLLGETVERSIONPROC(void)
91 /* DLLGETVERSIONPROC */
92 TEST_TYPE_SIZE (DLLGETVERSIONPROC
, 8)
93 TEST_TYPE_ALIGN (DLLGETVERSIONPROC
, 8)
96 static void test_pack_DLLVERSIONINFO(void)
98 /* DLLVERSIONINFO (pack 8) */
99 TEST_TYPE_SIZE (DLLVERSIONINFO
, 20)
100 TEST_TYPE_ALIGN (DLLVERSIONINFO
, 4)
101 TEST_FIELD_SIZE (DLLVERSIONINFO
, cbSize
, 4)
102 TEST_FIELD_ALIGN (DLLVERSIONINFO
, cbSize
, 4)
103 TEST_FIELD_OFFSET(DLLVERSIONINFO
, cbSize
, 0)
104 TEST_FIELD_SIZE (DLLVERSIONINFO
, dwMajorVersion
, 4)
105 TEST_FIELD_ALIGN (DLLVERSIONINFO
, dwMajorVersion
, 4)
106 TEST_FIELD_OFFSET(DLLVERSIONINFO
, dwMajorVersion
, 4)
107 TEST_FIELD_SIZE (DLLVERSIONINFO
, dwMinorVersion
, 4)
108 TEST_FIELD_ALIGN (DLLVERSIONINFO
, dwMinorVersion
, 4)
109 TEST_FIELD_OFFSET(DLLVERSIONINFO
, dwMinorVersion
, 8)
110 TEST_FIELD_SIZE (DLLVERSIONINFO
, dwBuildNumber
, 4)
111 TEST_FIELD_ALIGN (DLLVERSIONINFO
, dwBuildNumber
, 4)
112 TEST_FIELD_OFFSET(DLLVERSIONINFO
, dwBuildNumber
, 12)
113 TEST_FIELD_SIZE (DLLVERSIONINFO
, dwPlatformID
, 4)
114 TEST_FIELD_ALIGN (DLLVERSIONINFO
, dwPlatformID
, 4)
115 TEST_FIELD_OFFSET(DLLVERSIONINFO
, dwPlatformID
, 16)
118 static void test_pack_DLLVERSIONINFO2(void)
120 /* DLLVERSIONINFO2 (pack 8) */
121 TEST_TYPE_SIZE (DLLVERSIONINFO2
, 32)
122 TEST_TYPE_ALIGN (DLLVERSIONINFO2
, 8)
123 TEST_FIELD_SIZE (DLLVERSIONINFO2
, info1
, 20)
124 TEST_FIELD_ALIGN (DLLVERSIONINFO2
, info1
, 4)
125 TEST_FIELD_OFFSET(DLLVERSIONINFO2
, info1
, 0)
126 TEST_FIELD_SIZE (DLLVERSIONINFO2
, dwFlags
, 4)
127 TEST_FIELD_ALIGN (DLLVERSIONINFO2
, dwFlags
, 4)
128 TEST_FIELD_OFFSET(DLLVERSIONINFO2
, dwFlags
, 20)
129 TEST_FIELD_SIZE (DLLVERSIONINFO2
, ullVersion
, 8)
130 TEST_FIELD_ALIGN (DLLVERSIONINFO2
, ullVersion
, 8)
131 TEST_FIELD_OFFSET(DLLVERSIONINFO2
, ullVersion
, 24)
134 static void test_pack_HUSKEY(void)
137 TEST_TYPE_SIZE (HUSKEY
, 8)
138 TEST_TYPE_ALIGN (HUSKEY
, 8)
141 static void test_pack_PHUSKEY(void)
144 TEST_TYPE_SIZE (PHUSKEY
, 8)
145 TEST_TYPE_ALIGN (PHUSKEY
, 8)
146 TEST_TARGET_SIZE (PHUSKEY
, 8)
147 TEST_TARGET_ALIGN(PHUSKEY
, 8)
152 static void test_pack_ASSOCF(void)
155 TEST_TYPE_SIZE (ASSOCF
, 4)
156 TEST_TYPE_ALIGN (ASSOCF
, 4)
157 TEST_TYPE_UNSIGNED(ASSOCF
)
160 static void test_pack_DLLGETVERSIONPROC(void)
162 /* DLLGETVERSIONPROC */
163 TEST_TYPE_SIZE (DLLGETVERSIONPROC
, 4)
164 TEST_TYPE_ALIGN (DLLGETVERSIONPROC
, 4)
167 static void test_pack_DLLVERSIONINFO(void)
169 /* DLLVERSIONINFO (pack 8) */
170 TEST_TYPE_SIZE (DLLVERSIONINFO
, 20)
171 TEST_TYPE_ALIGN (DLLVERSIONINFO
, 4)
172 TEST_FIELD_SIZE (DLLVERSIONINFO
, cbSize
, 4)
173 TEST_FIELD_ALIGN (DLLVERSIONINFO
, cbSize
, 4)
174 TEST_FIELD_OFFSET(DLLVERSIONINFO
, cbSize
, 0)
175 TEST_FIELD_SIZE (DLLVERSIONINFO
, dwMajorVersion
, 4)
176 TEST_FIELD_ALIGN (DLLVERSIONINFO
, dwMajorVersion
, 4)
177 TEST_FIELD_OFFSET(DLLVERSIONINFO
, dwMajorVersion
, 4)
178 TEST_FIELD_SIZE (DLLVERSIONINFO
, dwMinorVersion
, 4)
179 TEST_FIELD_ALIGN (DLLVERSIONINFO
, dwMinorVersion
, 4)
180 TEST_FIELD_OFFSET(DLLVERSIONINFO
, dwMinorVersion
, 8)
181 TEST_FIELD_SIZE (DLLVERSIONINFO
, dwBuildNumber
, 4)
182 TEST_FIELD_ALIGN (DLLVERSIONINFO
, dwBuildNumber
, 4)
183 TEST_FIELD_OFFSET(DLLVERSIONINFO
, dwBuildNumber
, 12)
184 TEST_FIELD_SIZE (DLLVERSIONINFO
, dwPlatformID
, 4)
185 TEST_FIELD_ALIGN (DLLVERSIONINFO
, dwPlatformID
, 4)
186 TEST_FIELD_OFFSET(DLLVERSIONINFO
, dwPlatformID
, 16)
189 static void test_pack_DLLVERSIONINFO2(void)
191 /* DLLVERSIONINFO2 (pack 8) */
192 TEST_TYPE_SIZE (DLLVERSIONINFO2
, 32)
193 TEST_TYPE_ALIGN (DLLVERSIONINFO2
, 8)
194 TEST_FIELD_SIZE (DLLVERSIONINFO2
, info1
, 20)
195 TEST_FIELD_ALIGN (DLLVERSIONINFO2
, info1
, 4)
196 TEST_FIELD_OFFSET(DLLVERSIONINFO2
, info1
, 0)
197 TEST_FIELD_SIZE (DLLVERSIONINFO2
, dwFlags
, 4)
198 TEST_FIELD_ALIGN (DLLVERSIONINFO2
, dwFlags
, 4)
199 TEST_FIELD_OFFSET(DLLVERSIONINFO2
, dwFlags
, 20)
200 TEST_FIELD_SIZE (DLLVERSIONINFO2
, ullVersion
, 8)
201 TEST_FIELD_ALIGN (DLLVERSIONINFO2
, ullVersion
, 8)
202 TEST_FIELD_OFFSET(DLLVERSIONINFO2
, ullVersion
, 24)
205 static void test_pack_HUSKEY(void)
208 TEST_TYPE_SIZE (HUSKEY
, 4)
209 TEST_TYPE_ALIGN (HUSKEY
, 4)
212 static void test_pack_PHUSKEY(void)
215 TEST_TYPE_SIZE (PHUSKEY
, 4)
216 TEST_TYPE_ALIGN (PHUSKEY
, 4)
217 TEST_TARGET_SIZE (PHUSKEY
, 4)
218 TEST_TARGET_ALIGN(PHUSKEY
, 4)
223 static void test_pack(void)
226 test_pack_DLLGETVERSIONPROC();
227 test_pack_DLLVERSIONINFO();
228 test_pack_DLLVERSIONINFO2();
233 START_TEST(generated
)