1 /* File generated automatically from tools/winapi/test.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
19 #include "wine/test.h"
21 /***********************************************************************
25 #define DWORD_PTR UINT_PTR
26 #define LONG_PTR INT_PTR
27 #define ULONG_PTR UINT_PTR
29 /***********************************************************************
30 * Windows API extension
33 #if defined(_MSC_VER) && (_MSC_VER >= 1300) && defined(__cplusplus)
34 # define FIELD_ALIGNMENT(type, field) __alignof(((type*)0)->field)
35 #elif defined(__GNUC__)
36 # define FIELD_ALIGNMENT(type, field) __alignof__(((type*)0)->field)
38 /* FIXME: Not sure if is possible to do without compiler extension */
41 #if defined(_MSC_VER) && (_MSC_VER >= 1300) && defined(__cplusplus)
42 # define _TYPE_ALIGNMENT(type) __alignof(type)
43 #elif defined(__GNUC__)
44 # define _TYPE_ALIGNMENT(type) __alignof__(type)
47 * FIXME: Not sure if is possible to do without compiler extension
48 * (if type is not just a name that is, if so the normal)
49 * TYPE_ALIGNMENT can be used)
53 #if !defined(TYPE_ALIGNMENT) && defined(_TYPE_ALIGNMENT)
54 # define TYPE_ALIGNMENT _TYPE_ALIGNMENT
57 /***********************************************************************
61 #ifdef FIELD_ALIGNMENT
62 # define TEST_FIELD_ALIGNMENT(type, field, align) \
63 ok(FIELD_ALIGNMENT(type, field) == align, \
64 "FIELD_ALIGNMENT(" #type ", " #field ") == %d (expected " #align ")\n", \
65 FIELD_ALIGNMENT(type, field))
67 # define TEST_FIELD_ALIGNMENT(type, field, align) do { } while (0)
70 #define TEST_FIELD_OFFSET(type, field, offset) \
71 ok(FIELD_OFFSET(type, field) == offset, \
72 "FIELD_OFFSET(" #type ", " #field ") == %ld (expected " #offset ")\n", \
73 FIELD_OFFSET(type, field))
75 #ifdef _TYPE_ALIGNMENT
76 #define TEST__TYPE_ALIGNMENT(type, align) \
77 ok(_TYPE_ALIGNMENT(type) == align, "TYPE_ALIGNMENT(" #type ") == %d (expected " #align ")\n", _TYPE_ALIGNMENT(type))
79 # define TEST__TYPE_ALIGNMENT(type, align) do { } while (0)
83 #define TEST_TYPE_ALIGNMENT(type, align) \
84 ok(TYPE_ALIGNMENT(type) == align, "TYPE_ALIGNMENT(" #type ") == %d (expected " #align ")\n", TYPE_ALIGNMENT(type))
86 # define TEST_TYPE_ALIGNMENT(type, align) do { } while (0)
89 #define TEST_TYPE_SIZE(type, size) \
90 ok(sizeof(type) == size, "sizeof(" #type ") == %d (expected " #size ")\n", sizeof(type))
92 /***********************************************************************
96 #define TEST_FIELD(type, field_type, field_name, field_offset, field_size, field_align) \
97 TEST_TYPE_SIZE(field_type, field_size); \
98 TEST_FIELD_ALIGNMENT(type, field_name, field_align); \
99 TEST_FIELD_OFFSET(type, field_name, field_offset); \
101 #define TEST_TYPE(type, size, align) \
102 TEST_TYPE_ALIGNMENT(type, align); \
103 TEST_TYPE_SIZE(type, size)
105 #define TEST_TYPE_POINTER(type, size, align) \
106 TEST__TYPE_ALIGNMENT(*(type)0, align); \
107 TEST_TYPE_SIZE(*(type)0, size)
109 #define TEST_TYPE_SIGNED(type) \
110 ok((type) -1 < 0, "(" #type ") -1 < 0\n");
112 #define TEST_TYPE_UNSIGNED(type) \
113 ok((type) -1 > 0, "(" #type ") -1 > 0\n");
115 static void test_pack_BINDINFO(void)
117 /* BINDINFO (pack 4) */
118 TEST_FIELD(BINDINFO, ULONG, cbSize, 0, 4, 4);
119 TEST_FIELD(BINDINFO, LPWSTR, szExtraInfo, 4, 4, 4);
122 static void test_pack_IBindHost(void)
127 static void test_pack_IBindHostVtbl(void)
132 static void test_pack_IBindStatusCallback(void)
134 /* IBindStatusCallback */
137 static void test_pack_IBindStatusCallbackVtbl(void)
139 /* IBindStatusCallbackVtbl */
142 static void test_pack_IBinding(void)
147 static void test_pack_IBindingVtbl(void)
152 static void test_pack_IInternetProtocolInfo(void)
154 /* IInternetProtocolInfo */
157 static void test_pack_IInternetProtocolInfoVtbl(void)
159 /* IInternetProtocolInfoVtbl */
162 static void test_pack_IPersistMoniker(void)
164 /* IPersistMoniker */
167 static void test_pack_IPersistMonikerVtbl(void)
169 /* IPersistMonikerVtbl */
172 static void test_pack_IWinInetHttpInfo(void)
174 /* IWinInetHttpInfo */
177 static void test_pack_IWinInetHttpInfoVtbl(void)
179 /* IWinInetHttpInfoVtbl */
182 static void test_pack_IWinInetInfo(void)
187 static void test_pack_IWinInetInfoVtbl(void)
189 /* IWinInetInfoVtbl */
192 static void test_pack_LPBINDHOST(void)
195 TEST_TYPE(LPBINDHOST, 4, 4);
198 static void test_pack_LPBINDING(void)
201 TEST_TYPE(LPBINDING, 4, 4);
204 static void test_pack_LPBINDSTATUSCALLBACK(void)
206 /* LPBINDSTATUSCALLBACK */
207 TEST_TYPE(LPBINDSTATUSCALLBACK, 4, 4);
210 static void test_pack_LPIINTERNETPROTOCOLINFO(void)
212 /* LPIINTERNETPROTOCOLINFO */
213 TEST_TYPE(LPIINTERNETPROTOCOLINFO, 4, 4);
216 static void test_pack_LPPERSISTMONIKER(void)
218 /* LPPERSISTMONIKER */
219 TEST_TYPE(LPPERSISTMONIKER, 4, 4);
222 static void test_pack_LPREMFORMATETC(void)
225 TEST_TYPE(LPREMFORMATETC, 4, 4);
226 TEST_TYPE_POINTER(LPREMFORMATETC, 20, 4);
229 static void test_pack_LPREMSECURITY_ATTRIBUTES(void)
231 /* LPREMSECURITY_ATTRIBUTES */
232 TEST_TYPE(LPREMSECURITY_ATTRIBUTES, 4, 4);
233 TEST_TYPE_POINTER(LPREMSECURITY_ATTRIBUTES, 12, 4);
236 static void test_pack_LPWININETHTTPINFO(void)
238 /* LPWININETHTTPINFO */
239 TEST_TYPE(LPWININETHTTPINFO, 4, 4);
242 static void test_pack_LPWININETINFO(void)
245 TEST_TYPE(LPWININETINFO, 4, 4);
248 static void test_pack_PREMSECURITY_ATTRIBUTES(void)
250 /* PREMSECURITY_ATTRIBUTES */
251 TEST_TYPE(PREMSECURITY_ATTRIBUTES, 4, 4);
252 TEST_TYPE_POINTER(PREMSECURITY_ATTRIBUTES, 12, 4);
255 static void test_pack_REMSECURITY_ATTRIBUTES(void)
257 /* REMSECURITY_ATTRIBUTES (pack 4) */
258 TEST_TYPE(REMSECURITY_ATTRIBUTES, 12, 4);
259 TEST_FIELD(REMSECURITY_ATTRIBUTES, DWORD, nLength, 0, 4, 4);
260 TEST_FIELD(REMSECURITY_ATTRIBUTES, DWORD, lpSecurityDescriptor, 4, 4, 4);
261 TEST_FIELD(REMSECURITY_ATTRIBUTES, BOOL, bInheritHandle, 8, 4, 4);
264 static void test_pack_RemBINDINFO(void)
266 /* RemBINDINFO (pack 4) */
267 TEST_TYPE(RemBINDINFO, 72, 4);
268 TEST_FIELD(RemBINDINFO, ULONG, cbSize, 0, 4, 4);
269 TEST_FIELD(RemBINDINFO, LPWSTR, szExtraInfo, 4, 4, 4);
270 TEST_FIELD(RemBINDINFO, DWORD, grfBindInfoF, 8, 4, 4);
271 TEST_FIELD(RemBINDINFO, DWORD, dwBindVerb, 12, 4, 4);
272 TEST_FIELD(RemBINDINFO, LPWSTR, szCustomVerb, 16, 4, 4);
273 TEST_FIELD(RemBINDINFO, DWORD, cbstgmedData, 20, 4, 4);
274 TEST_FIELD(RemBINDINFO, DWORD, dwOptions, 24, 4, 4);
275 TEST_FIELD(RemBINDINFO, DWORD, dwOptionsFlags, 28, 4, 4);
276 TEST_FIELD(RemBINDINFO, DWORD, dwCodePage, 32, 4, 4);
277 TEST_FIELD(RemBINDINFO, REMSECURITY_ATTRIBUTES, securityAttributes, 36, 12, 4);
278 TEST_FIELD(RemBINDINFO, IID, iid, 48, 16, 4);
279 TEST_FIELD(RemBINDINFO, IUnknown *, pUnk, 64, 4, 4);
280 TEST_FIELD(RemBINDINFO, DWORD, dwReserved, 68, 4, 4);
283 static void test_pack_RemFORMATETC(void)
285 /* RemFORMATETC (pack 4) */
286 TEST_TYPE(RemFORMATETC, 20, 4);
287 TEST_FIELD(RemFORMATETC, DWORD, cfFormat, 0, 4, 4);
288 TEST_FIELD(RemFORMATETC, DWORD, ptd, 4, 4, 4);
289 TEST_FIELD(RemFORMATETC, DWORD, dwAspect, 8, 4, 4);
290 TEST_FIELD(RemFORMATETC, LONG, lindex, 12, 4, 4);
291 TEST_FIELD(RemFORMATETC, DWORD, tymed, 16, 4, 4);
294 static void test_pack(void)
296 test_pack_BINDINFO();
297 test_pack_IBindHost();
298 test_pack_IBindHostVtbl();
299 test_pack_IBindStatusCallback();
300 test_pack_IBindStatusCallbackVtbl();
301 test_pack_IBinding();
302 test_pack_IBindingVtbl();
303 test_pack_IInternetProtocolInfo();
304 test_pack_IInternetProtocolInfoVtbl();
305 test_pack_IPersistMoniker();
306 test_pack_IPersistMonikerVtbl();
307 test_pack_IWinInetHttpInfo();
308 test_pack_IWinInetHttpInfoVtbl();
309 test_pack_IWinInetInfo();
310 test_pack_IWinInetInfoVtbl();
311 test_pack_LPBINDHOST();
312 test_pack_LPBINDING();
313 test_pack_LPBINDSTATUSCALLBACK();
314 test_pack_LPIINTERNETPROTOCOLINFO();
315 test_pack_LPPERSISTMONIKER();
316 test_pack_LPREMFORMATETC();
317 test_pack_LPREMSECURITY_ATTRIBUTES();
318 test_pack_LPWININETHTTPINFO();
319 test_pack_LPWININETINFO();
320 test_pack_PREMSECURITY_ATTRIBUTES();
321 test_pack_REMSECURITY_ATTRIBUTES();
322 test_pack_RemBINDINFO();
323 test_pack_RemFORMATETC();
326 START_TEST(generated)