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