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_DLLGETVERSIONPROC(void)
119 /* DLLGETVERSIONPROC */
120 TEST_TYPE(DLLGETVERSIONPROC, 4, 4);
123 static void test_pack_DLLVERSIONINFO(void)
125 /* DLLVERSIONINFO (pack 1) */
126 TEST_TYPE(DLLVERSIONINFO, 20, 1);
127 TEST_FIELD(DLLVERSIONINFO, DWORD, cbSize, 0, 4, 1);
128 TEST_FIELD(DLLVERSIONINFO, DWORD, dwMajorVersion, 4, 4, 1);
129 TEST_FIELD(DLLVERSIONINFO, DWORD, dwMinorVersion, 8, 4, 1);
130 TEST_FIELD(DLLVERSIONINFO, DWORD, dwBuildNumber, 12, 4, 1);
131 TEST_FIELD(DLLVERSIONINFO, DWORD, dwPlatformID, 16, 4, 1);
134 static void test_pack_HUSKEY(void)
137 TEST_TYPE(HUSKEY, 4, 4);
140 static void test_pack_IQueryAssociations(void)
142 /* IQueryAssociations */
145 static void test_pack_PHUSKEY(void)
148 TEST_TYPE(PHUSKEY, 4, 4);
149 TEST_TYPE_POINTER(PHUSKEY, 4, 4);
152 static void test_pack(void)
154 test_pack_DLLGETVERSIONPROC();
155 test_pack_DLLVERSIONINFO();
157 test_pack_IQueryAssociations();
161 START_TEST(generated)