1 /* File generated automatically from tools/winapi/tests.dat; do not edit! */ 2 /* This file can be copied, modified and distributed without restriction. */ 3 4 /* 5 * Unit tests for data structure packing 6 */ 7 8 #ifndef __REACTOS__ 9 #define WINVER 0x0501 10 #define _WIN32_IE 0x0501 11 #define _WIN32_WINNT 0x0501 12 #endif 13 14 #define WINE_NOWINSOCK 15 16 #include <stdarg.h> 17 #include "windef.h" 18 #include "winbase.h" 19 #include "wtypes.h" 20 #include "winreg.h" 21 #include "shlwapi.h" 22 23 #include "wine/test.h" 24 25 /*********************************************************************** 26 * Compatibility macros 27 */ 28 29 #define DWORD_PTR UINT_PTR 30 #define LONG_PTR INT_PTR 31 #define ULONG_PTR UINT_PTR 32 33 /*********************************************************************** 34 * Windows API extension 35 */ 36 37 #if defined(_MSC_VER) && (_MSC_VER >= 1300) && defined(__cplusplus) 38 # define _TYPE_ALIGNMENT(type) __alignof(type) 39 #elif defined(__GNUC__) 40 # define _TYPE_ALIGNMENT(type) __alignof__(type) 41 #else 42 /* 43 * FIXME: May not be possible without a compiler extension 44 * (if type is not just a name that is, otherwise the normal 45 * TYPE_ALIGNMENT can be used) 46 */ 47 #endif 48 49 #if defined(TYPE_ALIGNMENT) && defined(_MSC_VER) && _MSC_VER >= 800 && !defined(__cplusplus) 50 #pragma warning(disable:4116) 51 #endif 52 53 #if !defined(TYPE_ALIGNMENT) && defined(_TYPE_ALIGNMENT) 54 # define TYPE_ALIGNMENT _TYPE_ALIGNMENT 55 #endif 56 57 /*********************************************************************** 58 * Test helper macros 59 */ 60 61 #define TEST_TYPE_SIZE(type, size) C_ASSERT(sizeof(type) == size); 62 63 #ifdef TYPE_ALIGNMENT 64 # define TEST_TYPE_ALIGN(type, align) C_ASSERT(TYPE_ALIGNMENT(type) == align); 65 #else 66 # define TEST_TYPE_ALIGN(type, align) 67 #endif 68 69 #ifdef _TYPE_ALIGNMENT 70 # define TEST_TARGET_ALIGN(type, align) C_ASSERT(_TYPE_ALIGNMENT(*(type)0) == align); 71 # define TEST_FIELD_ALIGN(type, field, align) C_ASSERT(_TYPE_ALIGNMENT(((type*)0)->field) == align); 72 #else 73 # define TEST_TARGET_ALIGN(type, align) 74 # define TEST_FIELD_ALIGN(type, field, align) 75 #endif 76 77 #define TEST_FIELD_OFFSET(type, field, offset) C_ASSERT(FIELD_OFFSET(type, field) == offset); 78 79 #define TEST_TARGET_SIZE(type, size) TEST_TYPE_SIZE(*(type)0, size) 80 #define TEST_FIELD_SIZE(type, field, size) TEST_TYPE_SIZE((((type*)0)->field), size) 81 #define TEST_TYPE_SIGNED(type) C_ASSERT((type) -1 < 0); 82 #define TEST_TYPE_UNSIGNED(type) C_ASSERT((type) -1 > 0); 83 84 85 #ifdef _WIN64 86 87 static void test_pack_ASSOCF(void) 88 { 89 /* ASSOCF */ 90 TEST_TYPE_SIZE (ASSOCF, 4) 91 TEST_TYPE_ALIGN (ASSOCF, 4) 92 TEST_TYPE_UNSIGNED(ASSOCF) 93 } 94 95 static void test_pack_DLLGETVERSIONPROC(void) 96 { 97 /* DLLGETVERSIONPROC */ 98 TEST_TYPE_SIZE (DLLGETVERSIONPROC, 8) 99 TEST_TYPE_ALIGN (DLLGETVERSIONPROC, 8) 100 } 101 102 static void test_pack_DLLVERSIONINFO(void) 103 { 104 /* DLLVERSIONINFO (pack 8) */ 105 TEST_TYPE_SIZE (DLLVERSIONINFO, 20) 106 TEST_TYPE_ALIGN (DLLVERSIONINFO, 4) 107 TEST_FIELD_SIZE (DLLVERSIONINFO, cbSize, 4) 108 TEST_FIELD_ALIGN (DLLVERSIONINFO, cbSize, 4) 109 TEST_FIELD_OFFSET(DLLVERSIONINFO, cbSize, 0) 110 TEST_FIELD_SIZE (DLLVERSIONINFO, dwMajorVersion, 4) 111 TEST_FIELD_ALIGN (DLLVERSIONINFO, dwMajorVersion, 4) 112 TEST_FIELD_OFFSET(DLLVERSIONINFO, dwMajorVersion, 4) 113 TEST_FIELD_SIZE (DLLVERSIONINFO, dwMinorVersion, 4) 114 TEST_FIELD_ALIGN (DLLVERSIONINFO, dwMinorVersion, 4) 115 TEST_FIELD_OFFSET(DLLVERSIONINFO, dwMinorVersion, 8) 116 TEST_FIELD_SIZE (DLLVERSIONINFO, dwBuildNumber, 4) 117 TEST_FIELD_ALIGN (DLLVERSIONINFO, dwBuildNumber, 4) 118 TEST_FIELD_OFFSET(DLLVERSIONINFO, dwBuildNumber, 12) 119 TEST_FIELD_SIZE (DLLVERSIONINFO, dwPlatformID, 4) 120 TEST_FIELD_ALIGN (DLLVERSIONINFO, dwPlatformID, 4) 121 TEST_FIELD_OFFSET(DLLVERSIONINFO, dwPlatformID, 16) 122 } 123 124 static void test_pack_DLLVERSIONINFO2(void) 125 { 126 /* DLLVERSIONINFO2 (pack 8) */ 127 TEST_TYPE_SIZE (DLLVERSIONINFO2, 32) 128 TEST_TYPE_ALIGN (DLLVERSIONINFO2, 8) 129 TEST_FIELD_SIZE (DLLVERSIONINFO2, info1, 20) 130 TEST_FIELD_ALIGN (DLLVERSIONINFO2, info1, 4) 131 TEST_FIELD_OFFSET(DLLVERSIONINFO2, info1, 0) 132 TEST_FIELD_SIZE (DLLVERSIONINFO2, dwFlags, 4) 133 TEST_FIELD_ALIGN (DLLVERSIONINFO2, dwFlags, 4) 134 TEST_FIELD_OFFSET(DLLVERSIONINFO2, dwFlags, 20) 135 TEST_FIELD_SIZE (DLLVERSIONINFO2, ullVersion, 8) 136 TEST_FIELD_ALIGN (DLLVERSIONINFO2, ullVersion, 8) 137 TEST_FIELD_OFFSET(DLLVERSIONINFO2, ullVersion, 24) 138 } 139 140 static void test_pack_HUSKEY(void) 141 { 142 /* HUSKEY */ 143 TEST_TYPE_SIZE (HUSKEY, 8) 144 TEST_TYPE_ALIGN (HUSKEY, 8) 145 } 146 147 static void test_pack_PHUSKEY(void) 148 { 149 /* PHUSKEY */ 150 TEST_TYPE_SIZE (PHUSKEY, 8) 151 TEST_TYPE_ALIGN (PHUSKEY, 8) 152 TEST_TARGET_SIZE (PHUSKEY, 8) 153 TEST_TARGET_ALIGN(PHUSKEY, 8) 154 } 155 156 #else /* _WIN64 */ 157 158 static void test_pack_ASSOCF(void) 159 { 160 /* ASSOCF */ 161 TEST_TYPE_SIZE (ASSOCF, 4) 162 TEST_TYPE_ALIGN (ASSOCF, 4) 163 TEST_TYPE_UNSIGNED(ASSOCF) 164 } 165 166 static void test_pack_DLLGETVERSIONPROC(void) 167 { 168 /* DLLGETVERSIONPROC */ 169 TEST_TYPE_SIZE (DLLGETVERSIONPROC, 4) 170 TEST_TYPE_ALIGN (DLLGETVERSIONPROC, 4) 171 } 172 173 static void test_pack_DLLVERSIONINFO(void) 174 { 175 /* DLLVERSIONINFO (pack 8) */ 176 TEST_TYPE_SIZE (DLLVERSIONINFO, 20) 177 TEST_TYPE_ALIGN (DLLVERSIONINFO, 4) 178 TEST_FIELD_SIZE (DLLVERSIONINFO, cbSize, 4) 179 TEST_FIELD_ALIGN (DLLVERSIONINFO, cbSize, 4) 180 TEST_FIELD_OFFSET(DLLVERSIONINFO, cbSize, 0) 181 TEST_FIELD_SIZE (DLLVERSIONINFO, dwMajorVersion, 4) 182 TEST_FIELD_ALIGN (DLLVERSIONINFO, dwMajorVersion, 4) 183 TEST_FIELD_OFFSET(DLLVERSIONINFO, dwMajorVersion, 4) 184 TEST_FIELD_SIZE (DLLVERSIONINFO, dwMinorVersion, 4) 185 TEST_FIELD_ALIGN (DLLVERSIONINFO, dwMinorVersion, 4) 186 TEST_FIELD_OFFSET(DLLVERSIONINFO, dwMinorVersion, 8) 187 TEST_FIELD_SIZE (DLLVERSIONINFO, dwBuildNumber, 4) 188 TEST_FIELD_ALIGN (DLLVERSIONINFO, dwBuildNumber, 4) 189 TEST_FIELD_OFFSET(DLLVERSIONINFO, dwBuildNumber, 12) 190 TEST_FIELD_SIZE (DLLVERSIONINFO, dwPlatformID, 4) 191 TEST_FIELD_ALIGN (DLLVERSIONINFO, dwPlatformID, 4) 192 TEST_FIELD_OFFSET(DLLVERSIONINFO, dwPlatformID, 16) 193 } 194 195 static void test_pack_DLLVERSIONINFO2(void) 196 { 197 /* DLLVERSIONINFO2 (pack 8) */ 198 TEST_TYPE_SIZE (DLLVERSIONINFO2, 32) 199 TEST_TYPE_ALIGN (DLLVERSIONINFO2, 8) 200 TEST_FIELD_SIZE (DLLVERSIONINFO2, info1, 20) 201 TEST_FIELD_ALIGN (DLLVERSIONINFO2, info1, 4) 202 TEST_FIELD_OFFSET(DLLVERSIONINFO2, info1, 0) 203 TEST_FIELD_SIZE (DLLVERSIONINFO2, dwFlags, 4) 204 TEST_FIELD_ALIGN (DLLVERSIONINFO2, dwFlags, 4) 205 TEST_FIELD_OFFSET(DLLVERSIONINFO2, dwFlags, 20) 206 TEST_FIELD_SIZE (DLLVERSIONINFO2, ullVersion, 8) 207 TEST_FIELD_ALIGN (DLLVERSIONINFO2, ullVersion, 8) 208 TEST_FIELD_OFFSET(DLLVERSIONINFO2, ullVersion, 24) 209 } 210 211 static void test_pack_HUSKEY(void) 212 { 213 /* HUSKEY */ 214 TEST_TYPE_SIZE (HUSKEY, 4) 215 TEST_TYPE_ALIGN (HUSKEY, 4) 216 } 217 218 static void test_pack_PHUSKEY(void) 219 { 220 /* PHUSKEY */ 221 TEST_TYPE_SIZE (PHUSKEY, 4) 222 TEST_TYPE_ALIGN (PHUSKEY, 4) 223 TEST_TARGET_SIZE (PHUSKEY, 4) 224 TEST_TARGET_ALIGN(PHUSKEY, 4) 225 } 226 227 #endif /* _WIN64 */ 228 229 static void test_pack(void) 230 { 231 test_pack_ASSOCF(); 232 test_pack_DLLGETVERSIONPROC(); 233 test_pack_DLLVERSIONINFO(); 234 test_pack_DLLVERSIONINFO2(); 235 test_pack_HUSKEY(); 236 test_pack_PHUSKEY(); 237 } 238 239 START_TEST(generated) 240 { 241 test_pack(); 242 } 243