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
24 #include "wine/test.h"
26 /***********************************************************************
30 #define DWORD_PTR UINT_PTR
31 #define LONG_PTR INT_PTR
32 #define ULONG_PTR UINT_PTR
34 /***********************************************************************
35 * Windows API extension
38 #if defined(_MSC_VER) && (_MSC_VER >= 1300) && defined(__cplusplus)
39 # define FIELD_ALIGNMENT(type, field) __alignof(((type*)0)->field)
40 #elif defined(__GNUC__)
41 # define FIELD_ALIGNMENT(type, field) __alignof__(((type*)0)->field)
43 /* FIXME: Not sure if is possible to do without compiler extension */
46 #if defined(_MSC_VER) && (_MSC_VER >= 1300) && defined(__cplusplus)
47 # define _TYPE_ALIGNMENT(type) __alignof(type)
48 #elif defined(__GNUC__)
49 # define _TYPE_ALIGNMENT(type) __alignof__(type)
52 * FIXME: Not sure if is possible to do without compiler extension
53 * (if type is not just a name that is, if so the normal)
54 * TYPE_ALIGNMENT can be used)
58 #if !defined(TYPE_ALIGNMENT) && defined(_TYPE_ALIGNMENT)
59 # define TYPE_ALIGNMENT _TYPE_ALIGNMENT
62 /***********************************************************************
66 #ifdef FIELD_ALIGNMENT
67 # define TEST_FIELD_ALIGNMENT(type, field, align) \
68 ok(FIELD_ALIGNMENT(type, field) == align, \
69 "FIELD_ALIGNMENT(" #type ", " #field ") == %d (expected " #align ")\n", \
70 FIELD_ALIGNMENT(type, field))
72 # define TEST_FIELD_ALIGNMENT(type, field, align) do { } while (0)
75 #define TEST_FIELD_OFFSET(type, field, offset) \
76 ok(FIELD_OFFSET(type, field) == offset, \
77 "FIELD_OFFSET(" #type ", " #field ") == %ld (expected " #offset ")\n", \
78 FIELD_OFFSET(type, field))
80 #ifdef _TYPE_ALIGNMENT
81 #define TEST__TYPE_ALIGNMENT(type, align) \
82 ok(_TYPE_ALIGNMENT(type) == align, "TYPE_ALIGNMENT(" #type ") == %d (expected " #align ")\n", _TYPE_ALIGNMENT(type))
84 # define TEST__TYPE_ALIGNMENT(type, align) do { } while (0)
88 #define TEST_TYPE_ALIGNMENT(type, align) \
89 ok(TYPE_ALIGNMENT(type) == align, "TYPE_ALIGNMENT(" #type ") == %d (expected " #align ")\n", TYPE_ALIGNMENT(type))
91 # define TEST_TYPE_ALIGNMENT(type, align) do { } while (0)
94 #define TEST_TYPE_SIZE(type, size) \
95 ok(sizeof(type) == size, "sizeof(" #type ") == %d (expected " #size ")\n", sizeof(type))
97 /***********************************************************************
101 #define TEST_FIELD(type, field_type, field_name, field_offset, field_size, field_align) \
102 TEST_TYPE_SIZE(field_type, field_size); \
103 TEST_FIELD_ALIGNMENT(type, field_name, field_align); \
104 TEST_FIELD_OFFSET(type, field_name, field_offset); \
106 #define TEST_TYPE(type, size, align) \
107 TEST_TYPE_ALIGNMENT(type, align); \
108 TEST_TYPE_SIZE(type, size)
110 #define TEST_TYPE_POINTER(type, size, align) \
111 TEST__TYPE_ALIGNMENT(*(type)0, align); \
112 TEST_TYPE_SIZE(*(type)0, size)
114 #define TEST_TYPE_SIGNED(type) \
115 ok((type) -1 < 0, "(" #type ") -1 < 0\n");
117 #define TEST_TYPE_UNSIGNED(type) \
118 ok((type) -1 > 0, "(" #type ") -1 > 0\n");
120 static void test_pack_APPBARDATA(void)
122 /* APPBARDATA (pack 1) */
123 TEST_TYPE(APPBARDATA
, 36, 1);
124 TEST_FIELD(APPBARDATA
, DWORD
, cbSize
, 0, 4, 1);
125 TEST_FIELD(APPBARDATA
, HWND
, hWnd
, 4, 4, 1);
126 TEST_FIELD(APPBARDATA
, UINT
, uCallbackMessage
, 8, 4, 1);
127 TEST_FIELD(APPBARDATA
, UINT
, uEdge
, 12, 4, 1);
128 TEST_FIELD(APPBARDATA
, RECT
, rc
, 16, 16, 1);
129 TEST_FIELD(APPBARDATA
, LPARAM
, lParam
, 32, 4, 1);
132 static void test_pack_DRAGINFOA(void)
134 /* DRAGINFOA (pack 1) */
135 TEST_FIELD(DRAGINFOA
, UINT
, uSize
, 0, 4, 1);
136 TEST_FIELD(DRAGINFOA
, POINT
, pt
, 4, 8, 1);
137 TEST_FIELD(DRAGINFOA
, BOOL
, fNC
, 12, 4, 1);
140 static void test_pack_DRAGINFOW(void)
142 /* DRAGINFOW (pack 1) */
143 TEST_TYPE(DRAGINFOW
, 24, 1);
144 TEST_FIELD(DRAGINFOW
, UINT
, uSize
, 0, 4, 1);
145 TEST_FIELD(DRAGINFOW
, POINT
, pt
, 4, 8, 1);
146 TEST_FIELD(DRAGINFOW
, BOOL
, fNC
, 12, 4, 1);
147 TEST_FIELD(DRAGINFOW
, LPWSTR
, lpFileList
, 16, 4, 1);
148 TEST_FIELD(DRAGINFOW
, DWORD
, grfKeyState
, 20, 4, 1);
151 static void test_pack_FILEOP_FLAGS(void)
154 TEST_TYPE(FILEOP_FLAGS
, 2, 2);
157 static void test_pack_LPDRAGINFOA(void)
160 TEST_TYPE(LPDRAGINFOA
, 4, 4);
163 static void test_pack_LPDRAGINFOW(void)
166 TEST_TYPE(LPDRAGINFOW
, 4, 4);
167 TEST_TYPE_POINTER(LPDRAGINFOW
, 24, 1);
170 static void test_pack_LPSHFILEOPSTRUCTA(void)
172 /* LPSHFILEOPSTRUCTA */
173 TEST_TYPE(LPSHFILEOPSTRUCTA
, 4, 4);
174 TEST_TYPE_POINTER(LPSHFILEOPSTRUCTA
, 30, 1);
177 static void test_pack_LPSHFILEOPSTRUCTW(void)
179 /* LPSHFILEOPSTRUCTW */
180 TEST_TYPE(LPSHFILEOPSTRUCTW
, 4, 4);
181 TEST_TYPE_POINTER(LPSHFILEOPSTRUCTW
, 30, 1);
184 static void test_pack_NOTIFYICONDATAA(void)
186 /* NOTIFYICONDATAA (pack 1) */
187 TEST_TYPE(NOTIFYICONDATAA
, 88, 1);
188 TEST_FIELD(NOTIFYICONDATAA
, DWORD
, cbSize
, 0, 4, 1);
189 TEST_FIELD(NOTIFYICONDATAA
, HWND
, hWnd
, 4, 4, 1);
190 TEST_FIELD(NOTIFYICONDATAA
, UINT
, uID
, 8, 4, 1);
191 TEST_FIELD(NOTIFYICONDATAA
, UINT
, uFlags
, 12, 4, 1);
192 TEST_FIELD(NOTIFYICONDATAA
, UINT
, uCallbackMessage
, 16, 4, 1);
193 TEST_FIELD(NOTIFYICONDATAA
, HICON
, hIcon
, 20, 4, 1);
194 TEST_FIELD(NOTIFYICONDATAA
, CHAR
[64], szTip
, 24, 64, 1);
197 static void test_pack_NOTIFYICONDATAW(void)
199 /* NOTIFYICONDATAW (pack 1) */
200 TEST_TYPE(NOTIFYICONDATAW
, 152, 1);
201 TEST_FIELD(NOTIFYICONDATAW
, DWORD
, cbSize
, 0, 4, 1);
202 TEST_FIELD(NOTIFYICONDATAW
, HWND
, hWnd
, 4, 4, 1);
203 TEST_FIELD(NOTIFYICONDATAW
, UINT
, uID
, 8, 4, 1);
204 TEST_FIELD(NOTIFYICONDATAW
, UINT
, uFlags
, 12, 4, 1);
205 TEST_FIELD(NOTIFYICONDATAW
, UINT
, uCallbackMessage
, 16, 4, 1);
206 TEST_FIELD(NOTIFYICONDATAW
, HICON
, hIcon
, 20, 4, 1);
207 TEST_FIELD(NOTIFYICONDATAW
, WCHAR
[64], szTip
, 24, 128, 1);
210 static void test_pack_PAPPBARDATA(void)
213 TEST_TYPE(PAPPBARDATA
, 4, 4);
214 TEST_TYPE_POINTER(PAPPBARDATA
, 36, 1);
217 static void test_pack_PNOTIFYICONDATAA(void)
219 /* PNOTIFYICONDATAA */
220 TEST_TYPE(PNOTIFYICONDATAA
, 4, 4);
221 TEST_TYPE_POINTER(PNOTIFYICONDATAA
, 88, 1);
224 static void test_pack_PNOTIFYICONDATAW(void)
226 /* PNOTIFYICONDATAW */
227 TEST_TYPE(PNOTIFYICONDATAW
, 4, 4);
228 TEST_TYPE_POINTER(PNOTIFYICONDATAW
, 152, 1);
231 static void test_pack_PRINTEROP_FLAGS(void)
233 /* PRINTEROP_FLAGS */
234 TEST_TYPE(PRINTEROP_FLAGS
, 2, 2);
237 static void test_pack_SHFILEINFOA(void)
239 /* SHFILEINFOA (pack 1) */
240 TEST_TYPE(SHFILEINFOA
, 352, 1);
241 TEST_FIELD(SHFILEINFOA
, HICON
, hIcon
, 0, 4, 1);
242 TEST_FIELD(SHFILEINFOA
, int, iIcon
, 4, 4, 1);
243 TEST_FIELD(SHFILEINFOA
, DWORD
, dwAttributes
, 8, 4, 1);
244 TEST_FIELD(SHFILEINFOA
, CHAR
[MAX_PATH
], szDisplayName
, 12, 260, 1);
245 TEST_FIELD(SHFILEINFOA
, CHAR
[80], szTypeName
, 272, 80, 1);
248 static void test_pack_SHFILEINFOW(void)
250 /* SHFILEINFOW (pack 1) */
251 TEST_TYPE(SHFILEINFOW
, 692, 1);
252 TEST_FIELD(SHFILEINFOW
, HICON
, hIcon
, 0, 4, 1);
253 TEST_FIELD(SHFILEINFOW
, int, iIcon
, 4, 4, 1);
254 TEST_FIELD(SHFILEINFOW
, DWORD
, dwAttributes
, 8, 4, 1);
255 TEST_FIELD(SHFILEINFOW
, WCHAR
[MAX_PATH
], szDisplayName
, 12, 520, 1);
256 TEST_FIELD(SHFILEINFOW
, WCHAR
[80], szTypeName
, 532, 160, 1);
259 static void test_pack_SHFILEOPSTRUCTA(void)
261 /* SHFILEOPSTRUCTA (pack 1) */
262 TEST_TYPE(SHFILEOPSTRUCTA
, 30, 1);
263 TEST_FIELD(SHFILEOPSTRUCTA
, HWND
, hwnd
, 0, 4, 1);
264 TEST_FIELD(SHFILEOPSTRUCTA
, UINT
, wFunc
, 4, 4, 1);
265 TEST_FIELD(SHFILEOPSTRUCTA
, LPCSTR
, pFrom
, 8, 4, 1);
266 TEST_FIELD(SHFILEOPSTRUCTA
, LPCSTR
, pTo
, 12, 4, 1);
267 TEST_FIELD(SHFILEOPSTRUCTA
, FILEOP_FLAGS
, fFlags
, 16, 2, 1);
268 TEST_FIELD(SHFILEOPSTRUCTA
, BOOL
, fAnyOperationsAborted
, 18, 4, 1);
269 TEST_FIELD(SHFILEOPSTRUCTA
, LPVOID
, hNameMappings
, 22, 4, 1);
270 TEST_FIELD(SHFILEOPSTRUCTA
, LPCSTR
, lpszProgressTitle
, 26, 4, 1);
273 static void test_pack_SHFILEOPSTRUCTW(void)
275 /* SHFILEOPSTRUCTW (pack 1) */
276 TEST_TYPE(SHFILEOPSTRUCTW
, 30, 1);
277 TEST_FIELD(SHFILEOPSTRUCTW
, HWND
, hwnd
, 0, 4, 1);
278 TEST_FIELD(SHFILEOPSTRUCTW
, UINT
, wFunc
, 4, 4, 1);
279 TEST_FIELD(SHFILEOPSTRUCTW
, LPCWSTR
, pFrom
, 8, 4, 1);
280 TEST_FIELD(SHFILEOPSTRUCTW
, LPCWSTR
, pTo
, 12, 4, 1);
281 TEST_FIELD(SHFILEOPSTRUCTW
, FILEOP_FLAGS
, fFlags
, 16, 2, 1);
282 TEST_FIELD(SHFILEOPSTRUCTW
, BOOL
, fAnyOperationsAborted
, 18, 4, 1);
283 TEST_FIELD(SHFILEOPSTRUCTW
, LPVOID
, hNameMappings
, 22, 4, 1);
284 TEST_FIELD(SHFILEOPSTRUCTW
, LPCWSTR
, lpszProgressTitle
, 26, 4, 1);
287 static void test_pack_BFFCALLBACK(void)
290 TEST_TYPE(BFFCALLBACK
, 4, 4);
293 static void test_pack_BROWSEINFOA(void)
295 /* BROWSEINFOA (pack 1) */
296 TEST_FIELD(BROWSEINFOA
, HWND
, hwndOwner
, 0, 4, 1);
297 TEST_FIELD(BROWSEINFOA
, LPCITEMIDLIST
, pidlRoot
, 4, 4, 1);
300 static void test_pack_BROWSEINFOW(void)
302 /* BROWSEINFOW (pack 1) */
303 TEST_TYPE(BROWSEINFOW
, 32, 1);
304 TEST_FIELD(BROWSEINFOW
, HWND
, hwndOwner
, 0, 4, 1);
305 TEST_FIELD(BROWSEINFOW
, LPCITEMIDLIST
, pidlRoot
, 4, 4, 1);
306 TEST_FIELD(BROWSEINFOW
, LPWSTR
, pszDisplayName
, 8, 4, 1);
307 TEST_FIELD(BROWSEINFOW
, LPCWSTR
, lpszTitle
, 12, 4, 1);
308 TEST_FIELD(BROWSEINFOW
, UINT
, ulFlags
, 16, 4, 1);
309 TEST_FIELD(BROWSEINFOW
, BFFCALLBACK
, lpfn
, 20, 4, 1);
310 TEST_FIELD(BROWSEINFOW
, LPARAM
, lParam
, 24, 4, 1);
311 TEST_FIELD(BROWSEINFOW
, INT
, iImage
, 28, 4, 1);
314 static void test_pack_CIDA(void)
317 TEST_TYPE(CIDA
, 8, 1);
318 TEST_FIELD(CIDA
, UINT
, cidl
, 0, 4, 1);
319 TEST_FIELD(CIDA
, UINT
[1], aoffset
, 4, 4, 1);
322 static void test_pack_DROPFILES(void)
324 /* DROPFILES (pack 1) */
325 TEST_TYPE(DROPFILES
, 20, 1);
326 TEST_FIELD(DROPFILES
, DWORD
, pFiles
, 0, 4, 1);
327 TEST_FIELD(DROPFILES
, POINT
, pt
, 4, 8, 1);
328 TEST_FIELD(DROPFILES
, BOOL
, fNC
, 12, 4, 1);
329 TEST_FIELD(DROPFILES
, BOOL
, fWide
, 16, 4, 1);
332 static void test_pack_IShellIcon(void)
337 static void test_pack_ITEMIDLIST(void)
339 /* ITEMIDLIST (pack 1) */
340 TEST_TYPE(ITEMIDLIST
, 3, 1);
341 TEST_FIELD(ITEMIDLIST
, SHITEMID
, mkid
, 0, 3, 1);
344 static void test_pack_LPBROWSEINFOA(void)
347 TEST_TYPE(LPBROWSEINFOA
, 4, 4);
350 static void test_pack_LPBROWSEINFOW(void)
353 TEST_TYPE(LPBROWSEINFOW
, 4, 4);
354 TEST_TYPE_POINTER(LPBROWSEINFOW
, 32, 1);
357 static void test_pack_LPCITEMIDLIST(void)
360 TEST_TYPE(LPCITEMIDLIST
, 4, 4);
361 TEST_TYPE_POINTER(LPCITEMIDLIST
, 3, 1);
364 static void test_pack_LPIDA(void)
367 TEST_TYPE(LPIDA
, 4, 4);
368 TEST_TYPE_POINTER(LPIDA
, 8, 1);
371 static void test_pack_LPITEMIDLIST(void)
374 TEST_TYPE(LPITEMIDLIST
, 4, 4);
375 TEST_TYPE_POINTER(LPITEMIDLIST
, 3, 1);
378 static void test_pack_LPSHDESCRIPTIONID(void)
380 /* LPSHDESCRIPTIONID */
381 TEST_TYPE(LPSHDESCRIPTIONID
, 4, 4);
384 static void test_pack_LPSHELLEXECUTEINFOA(void)
386 /* LPSHELLEXECUTEINFOA */
387 TEST_TYPE(LPSHELLEXECUTEINFOA
, 4, 4);
390 static void test_pack_LPSHELLEXECUTEINFOW(void)
392 /* LPSHELLEXECUTEINFOW */
393 TEST_TYPE(LPSHELLEXECUTEINFOW
, 4, 4);
396 static void test_pack_LPSHITEMID(void)
399 TEST_TYPE(LPSHITEMID
, 4, 4);
400 TEST_TYPE_POINTER(LPSHITEMID
, 3, 1);
403 static void test_pack_PBROWSEINFOA(void)
406 TEST_TYPE(PBROWSEINFOA
, 4, 4);
409 static void test_pack_PBROWSEINFOW(void)
412 TEST_TYPE(PBROWSEINFOW
, 4, 4);
413 TEST_TYPE_POINTER(PBROWSEINFOW
, 32, 1);
416 static void test_pack_SHDESCRIPTIONID(void)
418 /* SHDESCRIPTIONID (pack 1) */
419 TEST_FIELD(SHDESCRIPTIONID
, DWORD
, dwDescriptionId
, 0, 4, 1);
422 static void test_pack_SHELLEXECUTEINFOA(void)
424 /* SHELLEXECUTEINFOA (pack 1) */
425 TEST_FIELD(SHELLEXECUTEINFOA
, DWORD
, cbSize
, 0, 4, 1);
426 TEST_FIELD(SHELLEXECUTEINFOA
, ULONG
, fMask
, 4, 4, 1);
427 TEST_FIELD(SHELLEXECUTEINFOA
, HWND
, hwnd
, 8, 4, 1);
428 TEST_FIELD(SHELLEXECUTEINFOA
, LPCSTR
, lpVerb
, 12, 4, 1);
429 TEST_FIELD(SHELLEXECUTEINFOA
, LPCSTR
, lpFile
, 16, 4, 1);
430 TEST_FIELD(SHELLEXECUTEINFOA
, LPCSTR
, lpParameters
, 20, 4, 1);
431 TEST_FIELD(SHELLEXECUTEINFOA
, LPCSTR
, lpDirectory
, 24, 4, 1);
432 TEST_FIELD(SHELLEXECUTEINFOA
, INT
, nShow
, 28, 4, 1);
433 TEST_FIELD(SHELLEXECUTEINFOA
, HINSTANCE
, hInstApp
, 32, 4, 1);
434 TEST_FIELD(SHELLEXECUTEINFOA
, LPVOID
, lpIDList
, 36, 4, 1);
435 TEST_FIELD(SHELLEXECUTEINFOA
, LPCSTR
, lpClass
, 40, 4, 1);
438 static void test_pack_SHELLEXECUTEINFOW(void)
440 /* SHELLEXECUTEINFOW (pack 1) */
441 TEST_FIELD(SHELLEXECUTEINFOW
, DWORD
, cbSize
, 0, 4, 1);
442 TEST_FIELD(SHELLEXECUTEINFOW
, ULONG
, fMask
, 4, 4, 1);
443 TEST_FIELD(SHELLEXECUTEINFOW
, HWND
, hwnd
, 8, 4, 1);
444 TEST_FIELD(SHELLEXECUTEINFOW
, LPCWSTR
, lpVerb
, 12, 4, 1);
445 TEST_FIELD(SHELLEXECUTEINFOW
, LPCWSTR
, lpFile
, 16, 4, 1);
446 TEST_FIELD(SHELLEXECUTEINFOW
, LPCWSTR
, lpParameters
, 20, 4, 1);
447 TEST_FIELD(SHELLEXECUTEINFOW
, LPCWSTR
, lpDirectory
, 24, 4, 1);
448 TEST_FIELD(SHELLEXECUTEINFOW
, INT
, nShow
, 28, 4, 1);
449 TEST_FIELD(SHELLEXECUTEINFOW
, HINSTANCE
, hInstApp
, 32, 4, 1);
450 TEST_FIELD(SHELLEXECUTEINFOW
, LPVOID
, lpIDList
, 36, 4, 1);
451 TEST_FIELD(SHELLEXECUTEINFOW
, LPCWSTR
, lpClass
, 40, 4, 1);
454 static void test_pack_SHELLVIEWID(void)
459 static void test_pack_SHITEMID(void)
461 /* SHITEMID (pack 1) */
462 TEST_TYPE(SHITEMID
, 3, 1);
463 TEST_FIELD(SHITEMID
, WORD
, cb
, 0, 2, 1);
464 TEST_FIELD(SHITEMID
, BYTE
[1], abID
, 2, 1, 1);
467 static void test_pack(void)
469 test_pack_APPBARDATA();
470 test_pack_BFFCALLBACK();
471 test_pack_BROWSEINFOA();
472 test_pack_BROWSEINFOW();
474 test_pack_DRAGINFOA();
475 test_pack_DRAGINFOW();
476 test_pack_DROPFILES();
477 test_pack_FILEOP_FLAGS();
478 test_pack_IShellIcon();
479 test_pack_ITEMIDLIST();
480 test_pack_LPBROWSEINFOA();
481 test_pack_LPBROWSEINFOW();
482 test_pack_LPCITEMIDLIST();
483 test_pack_LPDRAGINFOA();
484 test_pack_LPDRAGINFOW();
486 test_pack_LPITEMIDLIST();
487 test_pack_LPSHDESCRIPTIONID();
488 test_pack_LPSHELLEXECUTEINFOA();
489 test_pack_LPSHELLEXECUTEINFOW();
490 test_pack_LPSHFILEOPSTRUCTA();
491 test_pack_LPSHFILEOPSTRUCTW();
492 test_pack_LPSHITEMID();
493 test_pack_NOTIFYICONDATAA();
494 test_pack_NOTIFYICONDATAW();
495 test_pack_PAPPBARDATA();
496 test_pack_PBROWSEINFOA();
497 test_pack_PBROWSEINFOW();
498 test_pack_PNOTIFYICONDATAA();
499 test_pack_PNOTIFYICONDATAW();
500 test_pack_PRINTEROP_FLAGS();
501 test_pack_SHDESCRIPTIONID();
502 test_pack_SHELLEXECUTEINFOA();
503 test_pack_SHELLEXECUTEINFOW();
504 test_pack_SHELLVIEWID();
505 test_pack_SHFILEINFOA();
506 test_pack_SHFILEINFOW();
507 test_pack_SHFILEOPSTRUCTA();
508 test_pack_SHFILEOPSTRUCTW();
509 test_pack_SHITEMID();
512 START_TEST(generated
)