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
21 #include "wine/test.h"
23 /***********************************************************************
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 (_MSC_VER >= 1300) && defined(__cplusplus)
36 # define FIELD_ALIGNMENT(type, field) __alignof(((type*)0)->field)
37 #elif defined(__GNUC__)
38 # define FIELD_ALIGNMENT(type, field) __alignof__(((type*)0)->field)
40 /* FIXME: Not sure if is possible to do without compiler extension */
43 #if (_MSC_VER >= 1300) && defined(__cplusplus)
44 # define _TYPE_ALIGNMENT(type) __alignof(type)
45 #elif defined(__GNUC__)
46 # define _TYPE_ALIGNMENT(type) __alignof__(type)
49 * FIXME: Not sure if is possible to do without compiler extension
50 * (if type is not just a name that is, if so the normal)
51 * TYPE_ALIGNMENT can be used)
55 #if !defined(TYPE_ALIGNMENT) && defined(_TYPE_ALIGNMENT)
56 # define TYPE_ALIGNMENT _TYPE_ALIGNMENT
59 /***********************************************************************
63 #ifdef FIELD_ALIGNMENT
64 # define TEST_FIELD_ALIGNMENT(type, field, align) \
65 ok(FIELD_ALIGNMENT(type, field) == align, \
66 "FIELD_ALIGNMENT(" #type ", " #field ") == %d (expected " #align ")", \
67 FIELD_ALIGNMENT(type, field))
69 # define TEST_FIELD_ALIGNMENT(type, field, align) do { } while (0)
72 #define TEST_FIELD_OFFSET(type, field, offset) \
73 ok(FIELD_OFFSET(type, field) == offset, \
74 "FIELD_OFFSET(" #type ", " #field ") == %ld (expected " #offset ")", \
75 FIELD_OFFSET(type, field))
77 #ifdef _TYPE_ALIGNMENT
78 #define TEST__TYPE_ALIGNMENT(type, align) \
79 ok(_TYPE_ALIGNMENT(type) == align, "TYPE_ALIGNMENT(" #type ") == %d (expected " #align ")", _TYPE_ALIGNMENT(type))
81 # define TEST__TYPE_ALIGNMENT(type, align) do { } while (0)
85 #define TEST_TYPE_ALIGNMENT(type, align) \
86 ok(TYPE_ALIGNMENT(type) == align, "TYPE_ALIGNMENT(" #type ") == %d (expected " #align ")", TYPE_ALIGNMENT(type))
88 # define TEST_TYPE_ALIGNMENT(type, align) do { } while (0)
91 #define TEST_TYPE_SIZE(type, size) \
92 ok(sizeof(type) == size, "sizeof(" #type ") == %d (expected " #size ")", sizeof(type))
94 /***********************************************************************
98 #define TEST_FIELD(type, field_type, field_name, field_offset, field_size, field_align) \
99 TEST_TYPE_SIZE(field_type, field_size); \
100 TEST_FIELD_ALIGNMENT(type, field_name, field_align); \
101 TEST_FIELD_OFFSET(type, field_name, field_offset); \
103 #define TEST_TYPE(type, size, align) \
104 TEST_TYPE_ALIGNMENT(type, align); \
105 TEST_TYPE_SIZE(type, size)
107 #define TEST_TYPE_POINTER(type, size, align) \
108 TEST__TYPE_ALIGNMENT(*(type)0, align); \
109 TEST_TYPE_SIZE(*(type)0, size)
111 #define TEST_TYPE_SIGNED(type) \
112 ok((type) -1 < 0, "(" #type ") -1 < 0");
114 #define TEST_TYPE_UNSIGNED(type) \
115 ok((type) -1 > 0, "(" #type ") -1 > 0");
117 static void test_pack_APPBARDATA(void)
119 /* APPBARDATA (pack 1) */
120 TEST_TYPE(APPBARDATA
, 36, 1);
121 TEST_FIELD(APPBARDATA
, DWORD
, cbSize
, 0, 4, 1);
122 TEST_FIELD(APPBARDATA
, HWND
, hWnd
, 4, 4, 1);
123 TEST_FIELD(APPBARDATA
, UINT
, uCallbackMessage
, 8, 4, 1);
124 TEST_FIELD(APPBARDATA
, UINT
, uEdge
, 12, 4, 1);
125 TEST_FIELD(APPBARDATA
, RECT
, rc
, 16, 16, 1);
126 TEST_FIELD(APPBARDATA
, LPARAM
, lParam
, 32, 4, 1);
129 static void test_pack_DRAGINFOA(void)
131 /* DRAGINFOA (pack 1) */
132 TEST_FIELD(DRAGINFOA
, UINT
, uSize
, 0, 4, 1);
133 TEST_FIELD(DRAGINFOA
, POINT
, pt
, 4, 8, 1);
134 TEST_FIELD(DRAGINFOA
, BOOL
, fNC
, 12, 4, 1);
137 static void test_pack_DRAGINFOW(void)
139 /* DRAGINFOW (pack 1) */
140 TEST_TYPE(DRAGINFOW
, 24, 1);
141 TEST_FIELD(DRAGINFOW
, UINT
, uSize
, 0, 4, 1);
142 TEST_FIELD(DRAGINFOW
, POINT
, pt
, 4, 8, 1);
143 TEST_FIELD(DRAGINFOW
, BOOL
, fNC
, 12, 4, 1);
144 TEST_FIELD(DRAGINFOW
, LPWSTR
, lpFileList
, 16, 4, 1);
145 TEST_FIELD(DRAGINFOW
, DWORD
, grfKeyState
, 20, 4, 1);
148 static void test_pack_FILEOP_FLAGS(void)
151 TEST_TYPE(FILEOP_FLAGS
, 2, 2);
154 static void test_pack_LPDRAGINFOA(void)
157 TEST_TYPE(LPDRAGINFOA
, 4, 4);
160 static void test_pack_LPDRAGINFOW(void)
163 TEST_TYPE(LPDRAGINFOW
, 4, 4);
164 TEST_TYPE_POINTER(LPDRAGINFOW
, 24, 1);
167 static void test_pack_LPSHFILEOPSTRUCTA(void)
169 /* LPSHFILEOPSTRUCTA */
170 TEST_TYPE(LPSHFILEOPSTRUCTA
, 4, 4);
171 TEST_TYPE_POINTER(LPSHFILEOPSTRUCTA
, 30, 1);
174 static void test_pack_LPSHFILEOPSTRUCTW(void)
176 /* LPSHFILEOPSTRUCTW */
177 TEST_TYPE(LPSHFILEOPSTRUCTW
, 4, 4);
178 TEST_TYPE_POINTER(LPSHFILEOPSTRUCTW
, 30, 1);
181 static void test_pack_NOTIFYICONDATAA(void)
183 /* NOTIFYICONDATAA (pack 1) */
184 TEST_TYPE(NOTIFYICONDATAA
, 88, 1);
185 TEST_FIELD(NOTIFYICONDATAA
, DWORD
, cbSize
, 0, 4, 1);
186 TEST_FIELD(NOTIFYICONDATAA
, HWND
, hWnd
, 4, 4, 1);
187 TEST_FIELD(NOTIFYICONDATAA
, UINT
, uID
, 8, 4, 1);
188 TEST_FIELD(NOTIFYICONDATAA
, UINT
, uFlags
, 12, 4, 1);
189 TEST_FIELD(NOTIFYICONDATAA
, UINT
, uCallbackMessage
, 16, 4, 1);
190 TEST_FIELD(NOTIFYICONDATAA
, HICON
, hIcon
, 20, 4, 1);
191 TEST_FIELD(NOTIFYICONDATAA
, CHAR
[64], szTip
, 24, 64, 1);
194 static void test_pack_NOTIFYICONDATAW(void)
196 /* NOTIFYICONDATAW (pack 1) */
197 TEST_TYPE(NOTIFYICONDATAW
, 152, 1);
198 TEST_FIELD(NOTIFYICONDATAW
, DWORD
, cbSize
, 0, 4, 1);
199 TEST_FIELD(NOTIFYICONDATAW
, HWND
, hWnd
, 4, 4, 1);
200 TEST_FIELD(NOTIFYICONDATAW
, UINT
, uID
, 8, 4, 1);
201 TEST_FIELD(NOTIFYICONDATAW
, UINT
, uFlags
, 12, 4, 1);
202 TEST_FIELD(NOTIFYICONDATAW
, UINT
, uCallbackMessage
, 16, 4, 1);
203 TEST_FIELD(NOTIFYICONDATAW
, HICON
, hIcon
, 20, 4, 1);
204 TEST_FIELD(NOTIFYICONDATAW
, WCHAR
[64], szTip
, 24, 128, 1);
207 static void test_pack_PAPPBARDATA(void)
210 TEST_TYPE(PAPPBARDATA
, 4, 4);
211 TEST_TYPE_POINTER(PAPPBARDATA
, 36, 1);
214 static void test_pack_PNOTIFYICONDATAA(void)
216 /* PNOTIFYICONDATAA */
217 TEST_TYPE(PNOTIFYICONDATAA
, 4, 4);
218 TEST_TYPE_POINTER(PNOTIFYICONDATAA
, 88, 1);
221 static void test_pack_PNOTIFYICONDATAW(void)
223 /* PNOTIFYICONDATAW */
224 TEST_TYPE(PNOTIFYICONDATAW
, 4, 4);
225 TEST_TYPE_POINTER(PNOTIFYICONDATAW
, 152, 1);
228 static void test_pack_PRINTEROP_FLAGS(void)
230 /* PRINTEROP_FLAGS */
231 TEST_TYPE(PRINTEROP_FLAGS
, 2, 2);
234 static void test_pack_SHFILEINFOA(void)
236 /* SHFILEINFOA (pack 1) */
237 TEST_TYPE(SHFILEINFOA
, 352, 1);
238 TEST_FIELD(SHFILEINFOA
, HICON
, hIcon
, 0, 4, 1);
239 TEST_FIELD(SHFILEINFOA
, int, iIcon
, 4, 4, 1);
240 TEST_FIELD(SHFILEINFOA
, DWORD
, dwAttributes
, 8, 4, 1);
241 TEST_FIELD(SHFILEINFOA
, CHAR
[MAX_PATH
], szDisplayName
, 12, 260, 1);
242 TEST_FIELD(SHFILEINFOA
, CHAR
[80], szTypeName
, 272, 80, 1);
245 static void test_pack_SHFILEINFOW(void)
247 /* SHFILEINFOW (pack 1) */
248 TEST_TYPE(SHFILEINFOW
, 692, 1);
249 TEST_FIELD(SHFILEINFOW
, HICON
, hIcon
, 0, 4, 1);
250 TEST_FIELD(SHFILEINFOW
, int, iIcon
, 4, 4, 1);
251 TEST_FIELD(SHFILEINFOW
, DWORD
, dwAttributes
, 8, 4, 1);
252 TEST_FIELD(SHFILEINFOW
, WCHAR
[MAX_PATH
], szDisplayName
, 12, 520, 1);
253 TEST_FIELD(SHFILEINFOW
, WCHAR
[80], szTypeName
, 532, 160, 1);
256 static void test_pack_SHFILEOPSTRUCTA(void)
258 /* SHFILEOPSTRUCTA (pack 1) */
259 TEST_TYPE(SHFILEOPSTRUCTA
, 30, 1);
260 TEST_FIELD(SHFILEOPSTRUCTA
, HWND
, hwnd
, 0, 4, 1);
261 TEST_FIELD(SHFILEOPSTRUCTA
, UINT
, wFunc
, 4, 4, 1);
262 TEST_FIELD(SHFILEOPSTRUCTA
, LPCSTR
, pFrom
, 8, 4, 1);
263 TEST_FIELD(SHFILEOPSTRUCTA
, LPCSTR
, pTo
, 12, 4, 1);
264 TEST_FIELD(SHFILEOPSTRUCTA
, FILEOP_FLAGS
, fFlags
, 16, 2, 1);
265 TEST_FIELD(SHFILEOPSTRUCTA
, BOOL
, fAnyOperationsAborted
, 18, 4, 1);
266 TEST_FIELD(SHFILEOPSTRUCTA
, LPVOID
, hNameMappings
, 22, 4, 1);
267 TEST_FIELD(SHFILEOPSTRUCTA
, LPCSTR
, lpszProgressTitle
, 26, 4, 1);
270 static void test_pack_SHFILEOPSTRUCTW(void)
272 /* SHFILEOPSTRUCTW (pack 1) */
273 TEST_TYPE(SHFILEOPSTRUCTW
, 30, 1);
274 TEST_FIELD(SHFILEOPSTRUCTW
, HWND
, hwnd
, 0, 4, 1);
275 TEST_FIELD(SHFILEOPSTRUCTW
, UINT
, wFunc
, 4, 4, 1);
276 TEST_FIELD(SHFILEOPSTRUCTW
, LPCWSTR
, pFrom
, 8, 4, 1);
277 TEST_FIELD(SHFILEOPSTRUCTW
, LPCWSTR
, pTo
, 12, 4, 1);
278 TEST_FIELD(SHFILEOPSTRUCTW
, FILEOP_FLAGS
, fFlags
, 16, 2, 1);
279 TEST_FIELD(SHFILEOPSTRUCTW
, BOOL
, fAnyOperationsAborted
, 18, 4, 1);
280 TEST_FIELD(SHFILEOPSTRUCTW
, LPVOID
, hNameMappings
, 22, 4, 1);
281 TEST_FIELD(SHFILEOPSTRUCTW
, LPCWSTR
, lpszProgressTitle
, 26, 4, 1);
284 static void test_pack_BFFCALLBACK(void)
287 TEST_TYPE(BFFCALLBACK
, 4, 4);
290 static void test_pack_BROWSEINFOA(void)
292 /* BROWSEINFOA (pack 1) */
293 TEST_FIELD(BROWSEINFOA
, HWND
, hwndOwner
, 0, 4, 1);
294 TEST_FIELD(BROWSEINFOA
, LPCITEMIDLIST
, pidlRoot
, 4, 4, 1);
297 static void test_pack_BROWSEINFOW(void)
299 /* BROWSEINFOW (pack 1) */
300 TEST_TYPE(BROWSEINFOW
, 32, 1);
301 TEST_FIELD(BROWSEINFOW
, HWND
, hwndOwner
, 0, 4, 1);
302 TEST_FIELD(BROWSEINFOW
, LPCITEMIDLIST
, pidlRoot
, 4, 4, 1);
303 TEST_FIELD(BROWSEINFOW
, LPWSTR
, pszDisplayName
, 8, 4, 1);
304 TEST_FIELD(BROWSEINFOW
, LPCWSTR
, lpszTitle
, 12, 4, 1);
305 TEST_FIELD(BROWSEINFOW
, UINT
, ulFlags
, 16, 4, 1);
306 TEST_FIELD(BROWSEINFOW
, BFFCALLBACK
, lpfn
, 20, 4, 1);
307 TEST_FIELD(BROWSEINFOW
, LPARAM
, lParam
, 24, 4, 1);
308 TEST_FIELD(BROWSEINFOW
, INT
, iImage
, 28, 4, 1);
311 static void test_pack_CIDA(void)
314 TEST_TYPE(CIDA
, 8, 1);
315 TEST_FIELD(CIDA
, UINT
, cidl
, 0, 4, 1);
316 TEST_FIELD(CIDA
, UINT
[1], aoffset
, 4, 4, 1);
319 static void test_pack_DROPFILES(void)
321 /* DROPFILES (pack 1) */
322 TEST_TYPE(DROPFILES
, 20, 1);
323 TEST_FIELD(DROPFILES
, DWORD
, pFiles
, 0, 4, 1);
324 TEST_FIELD(DROPFILES
, POINT
, pt
, 4, 8, 1);
325 TEST_FIELD(DROPFILES
, BOOL
, fNC
, 12, 4, 1);
326 TEST_FIELD(DROPFILES
, BOOL
, fWide
, 16, 4, 1);
329 static void test_pack_IShellIcon(void)
334 static void test_pack_ITEMIDLIST(void)
336 /* ITEMIDLIST (pack 1) */
337 TEST_TYPE(ITEMIDLIST
, 3, 1);
338 TEST_FIELD(ITEMIDLIST
, SHITEMID
, mkid
, 0, 3, 1);
341 static void test_pack_LPBROWSEINFOA(void)
344 TEST_TYPE(LPBROWSEINFOA
, 4, 4);
347 static void test_pack_LPBROWSEINFOW(void)
350 TEST_TYPE(LPBROWSEINFOW
, 4, 4);
351 TEST_TYPE_POINTER(LPBROWSEINFOW
, 32, 1);
354 static void test_pack_LPCITEMIDLIST(void)
357 TEST_TYPE(LPCITEMIDLIST
, 4, 4);
358 TEST_TYPE_POINTER(LPCITEMIDLIST
, 3, 1);
361 static void test_pack_LPIDA(void)
364 TEST_TYPE(LPIDA
, 4, 4);
365 TEST_TYPE_POINTER(LPIDA
, 8, 1);
368 static void test_pack_LPITEMIDLIST(void)
371 TEST_TYPE(LPITEMIDLIST
, 4, 4);
372 TEST_TYPE_POINTER(LPITEMIDLIST
, 3, 1);
375 static void test_pack_LPSHDESCRIPTIONID(void)
377 /* LPSHDESCRIPTIONID */
378 TEST_TYPE(LPSHDESCRIPTIONID
, 4, 4);
381 static void test_pack_LPSHELLEXECUTEINFOA(void)
383 /* LPSHELLEXECUTEINFOA */
384 TEST_TYPE(LPSHELLEXECUTEINFOA
, 4, 4);
387 static void test_pack_LPSHELLEXECUTEINFOW(void)
389 /* LPSHELLEXECUTEINFOW */
390 TEST_TYPE(LPSHELLEXECUTEINFOW
, 4, 4);
393 static void test_pack_LPSHITEMID(void)
396 TEST_TYPE(LPSHITEMID
, 4, 4);
397 TEST_TYPE_POINTER(LPSHITEMID
, 3, 1);
400 static void test_pack_PBROWSEINFOA(void)
403 TEST_TYPE(PBROWSEINFOA
, 4, 4);
406 static void test_pack_PBROWSEINFOW(void)
409 TEST_TYPE(PBROWSEINFOW
, 4, 4);
410 TEST_TYPE_POINTER(PBROWSEINFOW
, 32, 1);
413 static void test_pack_SHDESCRIPTIONID(void)
415 /* SHDESCRIPTIONID (pack 1) */
416 TEST_FIELD(SHDESCRIPTIONID
, DWORD
, dwDescriptionId
, 0, 4, 1);
419 static void test_pack_SHELLEXECUTEINFOA(void)
421 /* SHELLEXECUTEINFOA (pack 1) */
422 TEST_FIELD(SHELLEXECUTEINFOA
, DWORD
, cbSize
, 0, 4, 1);
423 TEST_FIELD(SHELLEXECUTEINFOA
, ULONG
, fMask
, 4, 4, 1);
424 TEST_FIELD(SHELLEXECUTEINFOA
, HWND
, hwnd
, 8, 4, 1);
425 TEST_FIELD(SHELLEXECUTEINFOA
, LPCSTR
, lpVerb
, 12, 4, 1);
426 TEST_FIELD(SHELLEXECUTEINFOA
, LPCSTR
, lpFile
, 16, 4, 1);
427 TEST_FIELD(SHELLEXECUTEINFOA
, LPCSTR
, lpParameters
, 20, 4, 1);
428 TEST_FIELD(SHELLEXECUTEINFOA
, LPCSTR
, lpDirectory
, 24, 4, 1);
429 TEST_FIELD(SHELLEXECUTEINFOA
, INT
, nShow
, 28, 4, 1);
430 TEST_FIELD(SHELLEXECUTEINFOA
, HINSTANCE
, hInstApp
, 32, 4, 1);
431 TEST_FIELD(SHELLEXECUTEINFOA
, LPVOID
, lpIDList
, 36, 4, 1);
432 TEST_FIELD(SHELLEXECUTEINFOA
, LPCSTR
, lpClass
, 40, 4, 1);
435 static void test_pack_SHELLEXECUTEINFOW(void)
437 /* SHELLEXECUTEINFOW (pack 1) */
438 TEST_FIELD(SHELLEXECUTEINFOW
, DWORD
, cbSize
, 0, 4, 1);
439 TEST_FIELD(SHELLEXECUTEINFOW
, ULONG
, fMask
, 4, 4, 1);
440 TEST_FIELD(SHELLEXECUTEINFOW
, HWND
, hwnd
, 8, 4, 1);
441 TEST_FIELD(SHELLEXECUTEINFOW
, LPCWSTR
, lpVerb
, 12, 4, 1);
442 TEST_FIELD(SHELLEXECUTEINFOW
, LPCWSTR
, lpFile
, 16, 4, 1);
443 TEST_FIELD(SHELLEXECUTEINFOW
, LPCWSTR
, lpParameters
, 20, 4, 1);
444 TEST_FIELD(SHELLEXECUTEINFOW
, LPCWSTR
, lpDirectory
, 24, 4, 1);
445 TEST_FIELD(SHELLEXECUTEINFOW
, INT
, nShow
, 28, 4, 1);
446 TEST_FIELD(SHELLEXECUTEINFOW
, HINSTANCE
, hInstApp
, 32, 4, 1);
447 TEST_FIELD(SHELLEXECUTEINFOW
, LPVOID
, lpIDList
, 36, 4, 1);
448 TEST_FIELD(SHELLEXECUTEINFOW
, LPCWSTR
, lpClass
, 40, 4, 1);
451 static void test_pack_SHELLVIEWID(void)
456 static void test_pack_SHITEMID(void)
458 /* SHITEMID (pack 1) */
459 TEST_TYPE(SHITEMID
, 3, 1);
460 TEST_FIELD(SHITEMID
, WORD
, cb
, 0, 2, 1);
461 TEST_FIELD(SHITEMID
, BYTE
[1], abID
, 2, 1, 1);
464 static void test_pack(void)
466 test_pack_APPBARDATA();
467 test_pack_BFFCALLBACK();
468 test_pack_BROWSEINFOA();
469 test_pack_BROWSEINFOW();
471 test_pack_DRAGINFOA();
472 test_pack_DRAGINFOW();
473 test_pack_DROPFILES();
474 test_pack_FILEOP_FLAGS();
475 test_pack_IShellIcon();
476 test_pack_ITEMIDLIST();
477 test_pack_LPBROWSEINFOA();
478 test_pack_LPBROWSEINFOW();
479 test_pack_LPCITEMIDLIST();
480 test_pack_LPDRAGINFOA();
481 test_pack_LPDRAGINFOW();
483 test_pack_LPITEMIDLIST();
484 test_pack_LPSHDESCRIPTIONID();
485 test_pack_LPSHELLEXECUTEINFOA();
486 test_pack_LPSHELLEXECUTEINFOW();
487 test_pack_LPSHFILEOPSTRUCTA();
488 test_pack_LPSHFILEOPSTRUCTW();
489 test_pack_LPSHITEMID();
490 test_pack_NOTIFYICONDATAA();
491 test_pack_NOTIFYICONDATAW();
492 test_pack_PAPPBARDATA();
493 test_pack_PBROWSEINFOA();
494 test_pack_PBROWSEINFOW();
495 test_pack_PNOTIFYICONDATAA();
496 test_pack_PNOTIFYICONDATAW();
497 test_pack_PRINTEROP_FLAGS();
498 test_pack_SHDESCRIPTIONID();
499 test_pack_SHELLEXECUTEINFOA();
500 test_pack_SHELLEXECUTEINFOW();
501 test_pack_SHELLVIEWID();
502 test_pack_SHFILEINFOA();
503 test_pack_SHFILEINFOW();
504 test_pack_SHFILEOPSTRUCTA();
505 test_pack_SHFILEOPSTRUCTW();
506 test_pack_SHITEMID();
509 START_TEST(generated
)