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
18 #include "wine/test.h"
20 /***********************************************************************
24 #define DWORD_PTR UINT_PTR
25 #define LONG_PTR INT_PTR
26 #define ULONG_PTR UINT_PTR
28 /***********************************************************************
29 * Windows API extension
32 #if (_MSC_VER >= 1300) && defined(__cplusplus)
33 # define FIELD_ALIGNMENT(type, field) __alignof(((type*)0)->field)
34 #elif defined(__GNUC__)
35 # define FIELD_ALIGNMENT(type, field) __alignof__(((type*)0)->field)
37 /* FIXME: Not sure if is possible to do without compiler extension */
40 #if (_MSC_VER >= 1300) && defined(__cplusplus)
41 # define _TYPE_ALIGNMENT(type) __alignof(type)
42 #elif defined(__GNUC__)
43 # define _TYPE_ALIGNMENT(type) __alignof__(type)
46 * FIXME: Not sure if is possible to do without compiler extension
47 * (if type is not just a name that is, if so the normal)
48 * TYPE_ALIGNMENT can be used)
52 #if !defined(TYPE_ALIGNMENT) && defined(_TYPE_ALIGNMENT)
53 # define TYPE_ALIGNMENT _TYPE_ALIGNMENT
56 /***********************************************************************
60 #ifdef FIELD_ALIGNMENT
61 # define TEST_FIELD_ALIGNMENT(type, field, align) \
62 ok(FIELD_ALIGNMENT(type, field) == align, \
63 "FIELD_ALIGNMENT(" #type ", " #field ") == %d (expected " #align ")", \
64 FIELD_ALIGNMENT(type, field))
66 # define TEST_FIELD_ALIGNMENT(type, field, align) do { } while (0)
69 #define TEST_FIELD_OFFSET(type, field, offset) \
70 ok(FIELD_OFFSET(type, field) == offset, \
71 "FIELD_OFFSET(" #type ", " #field ") == %ld (expected " #offset ")", \
72 FIELD_OFFSET(type, field))
74 #ifdef _TYPE_ALIGNMENT
75 #define TEST__TYPE_ALIGNMENT(type, align) \
76 ok(_TYPE_ALIGNMENT(type) == align, "TYPE_ALIGNMENT(" #type ") == %d (expected " #align ")", _TYPE_ALIGNMENT(type))
78 # define TEST__TYPE_ALIGNMENT(type, align) do { } while (0)
82 #define TEST_TYPE_ALIGNMENT(type, align) \
83 ok(TYPE_ALIGNMENT(type) == align, "TYPE_ALIGNMENT(" #type ") == %d (expected " #align ")", TYPE_ALIGNMENT(type))
85 # define TEST_TYPE_ALIGNMENT(type, align) do { } while (0)
88 #define TEST_TYPE_SIZE(type, size) \
89 ok(sizeof(type) == size, "sizeof(" #type ") == %d (expected " #size ")", sizeof(type))
91 /***********************************************************************
95 #define TEST_FIELD(type, field_type, field_name, field_offset, field_size, field_align) \
96 TEST_TYPE_SIZE(field_type, field_size); \
97 TEST_FIELD_ALIGNMENT(type, field_name, field_align); \
98 TEST_FIELD_OFFSET(type, field_name, field_offset); \
100 #define TEST_TYPE(type, size, align) \
101 TEST_TYPE_ALIGNMENT(type, align); \
102 TEST_TYPE_SIZE(type, size)
104 #define TEST_TYPE_POINTER(type, size, align) \
105 TEST__TYPE_ALIGNMENT(*(type)0, align); \
106 TEST_TYPE_SIZE(*(type)0, size)
108 #define TEST_TYPE_SIGNED(type) \
109 ok((type) -1 < 0, "(" #type ") -1 < 0");
111 #define TEST_TYPE_UNSIGNED(type) \
112 ok((type) -1 > 0, "(" #type ") -1 > 0");
114 static void test_pack_DLLGETVERSIONPROC(void)
116 /* DLLGETVERSIONPROC */
117 TEST_TYPE(DLLGETVERSIONPROC, 4, 4);
120 static void test_pack_DLLVERSIONINFO(void)
122 /* DLLVERSIONINFO (pack 1) */
123 TEST_TYPE(DLLVERSIONINFO, 20, 1);
124 TEST_FIELD(DLLVERSIONINFO, DWORD, cbSize, 0, 4, 1);
125 TEST_FIELD(DLLVERSIONINFO, DWORD, dwMajorVersion, 4, 4, 1);
126 TEST_FIELD(DLLVERSIONINFO, DWORD, dwMinorVersion, 8, 4, 1);
127 TEST_FIELD(DLLVERSIONINFO, DWORD, dwBuildNumber, 12, 4, 1);
128 TEST_FIELD(DLLVERSIONINFO, DWORD, dwPlatformID, 16, 4, 1);
131 static void test_pack_HUSKEY(void)
134 TEST_TYPE(HUSKEY, 4, 4);
137 static void test_pack_IQueryAssociations(void)
139 /* IQueryAssociations */
142 static void test_pack_PHUSKEY(void)
145 TEST_TYPE(PHUSKEY, 4, 4);
146 TEST_TYPE_POINTER(PHUSKEY, 4, 4);
149 static void test_pack(void)
151 test_pack_DLLGETVERSIONPROC();
152 test_pack_DLLVERSIONINFO();
154 test_pack_IQueryAssociations();
158 START_TEST(generated)