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(_MSC_VER) && _MSC_VER >= 800 && !defined(__cplusplus)
56 #pragma warning(disable:4116)
59 #if !defined(TYPE_ALIGNMENT) && defined(_TYPE_ALIGNMENT)
60 # define TYPE_ALIGNMENT _TYPE_ALIGNMENT
63 /***********************************************************************
67 #ifdef FIELD_ALIGNMENT
68 # define TEST_FIELD_ALIGNMENT(type, field, align) \
69 ok(FIELD_ALIGNMENT(type, field) == align, \
70 "FIELD_ALIGNMENT(" #type ", " #field ") == %d (expected " #align ")\n", \
71 FIELD_ALIGNMENT(type, field))
73 # define TEST_FIELD_ALIGNMENT(type, field, align) do { } while (0)
76 #define TEST_FIELD_OFFSET(type, field, offset) \
77 ok(FIELD_OFFSET(type, field) == offset, \
78 "FIELD_OFFSET(" #type ", " #field ") == %ld (expected " #offset ")\n", \
79 FIELD_OFFSET(type, field))
81 #ifdef _TYPE_ALIGNMENT
82 #define TEST__TYPE_ALIGNMENT(type, align) \
83 ok(_TYPE_ALIGNMENT(type) == align, "TYPE_ALIGNMENT(" #type ") == %d (expected " #align ")\n", _TYPE_ALIGNMENT(type))
85 # define TEST__TYPE_ALIGNMENT(type, align) do { } while (0)
89 #define TEST_TYPE_ALIGNMENT(type, align) \
90 ok(TYPE_ALIGNMENT(type) == align, "TYPE_ALIGNMENT(" #type ") == %d (expected " #align ")\n", TYPE_ALIGNMENT(type))
92 # define TEST_TYPE_ALIGNMENT(type, align) do { } while (0)
95 #define TEST_TYPE_SIZE(type, size) \
96 ok(sizeof(type) == size, "sizeof(" #type ") == %d (expected " #size ")\n", sizeof(type))
98 /***********************************************************************
102 #define TEST_FIELD(type, field_type, field_name, field_offset, field_size, field_align) \
103 TEST_TYPE_SIZE(field_type, field_size); \
104 TEST_FIELD_ALIGNMENT(type, field_name, field_align); \
105 TEST_FIELD_OFFSET(type, field_name, field_offset); \
107 #define TEST_TYPE(type, size, align) \
108 TEST_TYPE_ALIGNMENT(type, align); \
109 TEST_TYPE_SIZE(type, size)
111 #define TEST_TYPE_POINTER(type, size, align) \
112 TEST__TYPE_ALIGNMENT(*(type)0, align); \
113 TEST_TYPE_SIZE(*(type)0, size)
115 #define TEST_TYPE_SIGNED(type) \
116 ok((type) -1 < 0, "(" #type ") -1 < 0\n");
118 #define TEST_TYPE_UNSIGNED(type) \
119 ok((type) -1 > 0, "(" #type ") -1 > 0\n");
121 static void test_pack_ASSOCF(void)
124 TEST_TYPE(ASSOCF
, 4, 4);
125 TEST_TYPE_UNSIGNED(ASSOCF
);
128 static void test_pack_DLLGETVERSIONPROC(void)
130 /* DLLGETVERSIONPROC */
131 TEST_TYPE(DLLGETVERSIONPROC
, 4, 4);
134 static void test_pack_DLLVERSIONINFO(void)
136 /* DLLVERSIONINFO (pack 8) */
137 TEST_TYPE(DLLVERSIONINFO
, 20, 4);
138 TEST_FIELD(DLLVERSIONINFO
, DWORD
, cbSize
, 0, 4, 4);
139 TEST_FIELD(DLLVERSIONINFO
, DWORD
, dwMajorVersion
, 4, 4, 4);
140 TEST_FIELD(DLLVERSIONINFO
, DWORD
, dwMinorVersion
, 8, 4, 4);
141 TEST_FIELD(DLLVERSIONINFO
, DWORD
, dwBuildNumber
, 12, 4, 4);
142 TEST_FIELD(DLLVERSIONINFO
, DWORD
, dwPlatformID
, 16, 4, 4);
145 static void test_pack_DLLVERSIONINFO2(void)
147 /* DLLVERSIONINFO2 (pack 8) */
148 TEST_TYPE(DLLVERSIONINFO2
, 32, 8);
149 TEST_FIELD(DLLVERSIONINFO2
, DLLVERSIONINFO
, info1
, 0, 20, 4);
150 TEST_FIELD(DLLVERSIONINFO2
, DWORD
, dwFlags
, 20, 4, 4);
151 TEST_FIELD(DLLVERSIONINFO2
, ULONGLONG
, ullVersion
, 24, 8, 8);
154 static void test_pack_HUSKEY(void)
157 TEST_TYPE(HUSKEY
, 4, 4);
160 static void test_pack_IQueryAssociations(void)
162 /* IQueryAssociations */
165 static void test_pack_PHUSKEY(void)
168 TEST_TYPE(PHUSKEY
, 4, 4);
169 TEST_TYPE_POINTER(PHUSKEY
, 4, 4);
172 static void test_pack(void)
175 test_pack_DLLGETVERSIONPROC();
176 test_pack_DLLVERSIONINFO();
177 test_pack_DLLVERSIONINFO2();
179 test_pack_IQueryAssociations();
183 START_TEST(generated
)