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 defined(_MSC_VER) && (_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 defined(_MSC_VER) && (_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 ")\n", \
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 ")\n", \
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 ")\n", _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 ")\n", 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 ")\n", 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\n");
114 #define TEST_TYPE_UNSIGNED(type) \
115 ok((type) -1 > 0, "(" #type ") -1 > 0\n");
117 static void test_pack_ASSOCF(void)
120 TEST_TYPE(ASSOCF, 4, 4);
121 TEST_TYPE_UNSIGNED(ASSOCF);
124 static void test_pack_DLLGETVERSIONPROC(void)
126 /* DLLGETVERSIONPROC */
127 TEST_TYPE(DLLGETVERSIONPROC, 4, 4);
130 static void test_pack_DLLVERSIONINFO(void)
132 /* DLLVERSIONINFO (pack 8) */
133 TEST_TYPE(DLLVERSIONINFO, 20, 4);
134 TEST_FIELD(DLLVERSIONINFO, DWORD, cbSize, 0, 4, 4);
135 TEST_FIELD(DLLVERSIONINFO, DWORD, dwMajorVersion, 4, 4, 4);
136 TEST_FIELD(DLLVERSIONINFO, DWORD, dwMinorVersion, 8, 4, 4);
137 TEST_FIELD(DLLVERSIONINFO, DWORD, dwBuildNumber, 12, 4, 4);
138 TEST_FIELD(DLLVERSIONINFO, DWORD, dwPlatformID, 16, 4, 4);
141 static void test_pack_DLLVERSIONINFO2(void)
143 /* DLLVERSIONINFO2 (pack 8) */
144 TEST_TYPE(DLLVERSIONINFO2, 32, 8);
145 TEST_FIELD(DLLVERSIONINFO2, DLLVERSIONINFO, info1, 0, 20, 4);
146 TEST_FIELD(DLLVERSIONINFO2, DWORD, dwFlags, 20, 4, 4);
147 TEST_FIELD(DLLVERSIONINFO2, ULONGLONG, ullVersion, 24, 8, 8);
150 static void test_pack_HUSKEY(void)
153 TEST_TYPE(HUSKEY, 4, 4);
156 static void test_pack_IQueryAssociations(void)
158 /* IQueryAssociations */
161 static void test_pack_PHUSKEY(void)
164 TEST_TYPE(PHUSKEY, 4, 4);
165 TEST_TYPE_POINTER(PHUSKEY, 4, 4);
168 static void test_pack(void)
171 test_pack_DLLGETVERSIONPROC();
172 test_pack_DLLVERSIONINFO();
173 test_pack_DLLVERSIONINFO2();
175 test_pack_IQueryAssociations();
179 START_TEST(generated)