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
22 #include "wine/test.h"
24 /***********************************************************************
28 #define DWORD_PTR UINT_PTR
29 #define LONG_PTR INT_PTR
30 #define ULONG_PTR UINT_PTR
32 /***********************************************************************
33 * Windows API extension
36 #if (_MSC_VER >= 1300) && defined(__cplusplus)
37 # define FIELD_ALIGNMENT(type, field) __alignof(((type*)0)->field)
38 #elif defined(__GNUC__)
39 # define FIELD_ALIGNMENT(type, field) __alignof__(((type*)0)->field)
41 /* FIXME: Not sure if is possible to do without compiler extension */
44 #if (_MSC_VER >= 1300) && defined(__cplusplus)
45 # define _TYPE_ALIGNMENT(type) __alignof(type)
46 #elif defined(__GNUC__)
47 # define _TYPE_ALIGNMENT(type) __alignof__(type)
50 * FIXME: Not sure if is possible to do without compiler extension
51 * (if type is not just a name that is, if so the normal)
52 * TYPE_ALIGNMENT can be used)
56 #if !defined(TYPE_ALIGNMENT) && defined(_TYPE_ALIGNMENT)
57 # define TYPE_ALIGNMENT _TYPE_ALIGNMENT
60 /***********************************************************************
64 #ifdef FIELD_ALIGNMENT
65 # define TEST_FIELD_ALIGNMENT(type, field, align) \
66 ok(FIELD_ALIGNMENT(type, field) == align, \
67 "FIELD_ALIGNMENT(" #type ", " #field ") == %d (expected " #align ")", \
68 FIELD_ALIGNMENT(type, field))
70 # define TEST_FIELD_ALIGNMENT(type, field, align) do { } while (0)
73 #define TEST_FIELD_OFFSET(type, field, offset) \
74 ok(FIELD_OFFSET(type, field) == offset, \
75 "FIELD_OFFSET(" #type ", " #field ") == %ld (expected " #offset ")", \
76 FIELD_OFFSET(type, field))
78 #ifdef _TYPE_ALIGNMENT
79 #define TEST__TYPE_ALIGNMENT(type, align) \
80 ok(_TYPE_ALIGNMENT(type) == align, "TYPE_ALIGNMENT(" #type ") == %d (expected " #align ")", _TYPE_ALIGNMENT(type))
82 # define TEST__TYPE_ALIGNMENT(type, align) do { } while (0)
86 #define TEST_TYPE_ALIGNMENT(type, align) \
87 ok(TYPE_ALIGNMENT(type) == align, "TYPE_ALIGNMENT(" #type ") == %d (expected " #align ")", TYPE_ALIGNMENT(type))
89 # define TEST_TYPE_ALIGNMENT(type, align) do { } while (0)
92 #define TEST_TYPE_SIZE(type, size) \
93 ok(sizeof(type) == size, "sizeof(" #type ") == %d (expected " #size ")", sizeof(type))
95 /***********************************************************************
99 #define TEST_FIELD(type, field_type, field_name, field_offset, field_size, field_align) \
100 TEST_TYPE_SIZE(field_type, field_size); \
101 TEST_FIELD_ALIGNMENT(type, field_name, field_align); \
102 TEST_FIELD_OFFSET(type, field_name, field_offset); \
104 #define TEST_TYPE(type, size, align) \
105 TEST_TYPE_ALIGNMENT(type, align); \
106 TEST_TYPE_SIZE(type, size)
108 #define TEST_TYPE_POINTER(type, size, align) \
109 TEST__TYPE_ALIGNMENT(*(type)0, align); \
110 TEST_TYPE_SIZE(*(type)0, size)
112 #define TEST_TYPE_SIGNED(type) \
113 ok((type) -1 < 0, "(" #type ") -1 < 0");
115 #define TEST_TYPE_UNSIGNED(type) \
116 ok((type) -1 > 0, "(" #type ") -1 > 0");
118 static void test_pack_DLLGETVERSIONPROC(void)
120 /* DLLGETVERSIONPROC */
121 TEST_TYPE(DLLGETVERSIONPROC, 4, 4);
124 static void test_pack_DLLVERSIONINFO(void)
126 /* DLLVERSIONINFO (pack 1) */
127 TEST_TYPE(DLLVERSIONINFO, 20, 1);
128 TEST_FIELD(DLLVERSIONINFO, DWORD, cbSize, 0, 4, 1);
129 TEST_FIELD(DLLVERSIONINFO, DWORD, dwMajorVersion, 4, 4, 1);
130 TEST_FIELD(DLLVERSIONINFO, DWORD, dwMinorVersion, 8, 4, 1);
131 TEST_FIELD(DLLVERSIONINFO, DWORD, dwBuildNumber, 12, 4, 1);
132 TEST_FIELD(DLLVERSIONINFO, DWORD, dwPlatformID, 16, 4, 1);
135 static void test_pack_HUSKEY(void)
138 TEST_TYPE(HUSKEY, 4, 4);
141 static void test_pack_IQueryAssociations(void)
143 /* IQueryAssociations */
146 static void test_pack_PHUSKEY(void)
149 TEST_TYPE(PHUSKEY, 4, 4);
150 TEST_TYPE_POINTER(PHUSKEY, 4, 4);
153 static void test_pack(void)
155 test_pack_DLLGETVERSIONPROC();
156 test_pack_DLLVERSIONINFO();
158 test_pack_IQueryAssociations();
162 START_TEST(generated)