generated.c 7.08 KB
Newer Older
1
/* File generated automatically from tools/winapi/tests.dat; do not edit! */
2 3 4 5 6 7 8 9 10 11 12 13
/* This file can be copied, modified and distributed without restriction. */

/*
 * Unit tests for data structure packing
 */

#define WINVER 0x0501
#define _WIN32_IE 0x0501
#define _WIN32_WINNT 0x0501

#define WINE_NOWINSOCK

14
#include <stdarg.h>
15
#include "windef.h"
16
#include "winbase.h"
17
#include "wtypes.h"
18
#include "winreg.h"
19 20 21 22 23
#include "shlwapi.h"

#include "wine/test.h"

/***********************************************************************
24
 * Compatibility macros
25 26 27 28 29 30 31 32 33 34
 */

#define DWORD_PTR UINT_PTR
#define LONG_PTR INT_PTR
#define ULONG_PTR UINT_PTR

/***********************************************************************
 * Windows API extension
 */

35
#if defined(_MSC_VER) && (_MSC_VER >= 1300) && defined(__cplusplus)
36 37 38 39 40
# define _TYPE_ALIGNMENT(type) __alignof(type)
#elif defined(__GNUC__)
# define _TYPE_ALIGNMENT(type) __alignof__(type)
#else
/*
41 42
 * FIXME: May not be possible without a compiler extension
 *        (if type is not just a name that is, otherwise the normal
43 44 45 46
 *         TYPE_ALIGNMENT can be used)
 */
#endif

47 48 49 50
#if defined(TYPE_ALIGNMENT) && defined(_MSC_VER) && _MSC_VER >= 800 && !defined(__cplusplus)
#pragma warning(disable:4116)
#endif

51 52 53 54 55 56 57 58
#if !defined(TYPE_ALIGNMENT) && defined(_TYPE_ALIGNMENT)
# define TYPE_ALIGNMENT _TYPE_ALIGNMENT
#endif

/***********************************************************************
 * Test helper macros
 */

59
#define TEST_TYPE_SIZE(type, size)             C_ASSERT(sizeof(type) == size);
60

61 62 63
#ifdef TYPE_ALIGNMENT
# define TEST_TYPE_ALIGN(type, align)          C_ASSERT(TYPE_ALIGNMENT(type) == align);
#else
64
# define TEST_TYPE_ALIGN(type, align)
65 66 67 68 69 70
#endif

#ifdef _TYPE_ALIGNMENT
# define TEST_TARGET_ALIGN(type, align)        C_ASSERT(_TYPE_ALIGNMENT(*(type)0) == align);
# define TEST_FIELD_ALIGN(type, field, align)  C_ASSERT(_TYPE_ALIGNMENT(((type*)0)->field) == align);
#else
71 72
# define TEST_TARGET_ALIGN(type, align)
# define TEST_FIELD_ALIGN(type, field, align)
73
#endif
74

75
#define TEST_FIELD_OFFSET(type, field, offset) C_ASSERT(FIELD_OFFSET(type, field) == offset);
76

77 78 79 80
#define TEST_TARGET_SIZE(type, size)            TEST_TYPE_SIZE(*(type)0, size)
#define TEST_FIELD_SIZE(type, field, size)      TEST_TYPE_SIZE((((type*)0)->field), size)
#define TEST_TYPE_SIGNED(type)                  C_ASSERT((type) -1 < 0);
#define TEST_TYPE_UNSIGNED(type)                C_ASSERT((type) -1 > 0);
81 82


83
#ifdef _WIN64
84

85 86 87 88 89 90 91
static void test_pack_ASSOCF(void)
{
    /* ASSOCF */
    TEST_TYPE_SIZE   (ASSOCF, 4)
    TEST_TYPE_ALIGN  (ASSOCF, 4)
    TEST_TYPE_UNSIGNED(ASSOCF)
}
92

93 94 95 96 97 98
static void test_pack_DLLGETVERSIONPROC(void)
{
    /* DLLGETVERSIONPROC */
    TEST_TYPE_SIZE   (DLLGETVERSIONPROC, 8)
    TEST_TYPE_ALIGN  (DLLGETVERSIONPROC, 8)
}
99

100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
static void test_pack_DLLVERSIONINFO(void)
{
    /* DLLVERSIONINFO (pack 8) */
    TEST_TYPE_SIZE   (DLLVERSIONINFO, 20)
    TEST_TYPE_ALIGN  (DLLVERSIONINFO, 4)
    TEST_FIELD_SIZE  (DLLVERSIONINFO, cbSize, 4)
    TEST_FIELD_ALIGN (DLLVERSIONINFO, cbSize, 4)
    TEST_FIELD_OFFSET(DLLVERSIONINFO, cbSize, 0)
    TEST_FIELD_SIZE  (DLLVERSIONINFO, dwMajorVersion, 4)
    TEST_FIELD_ALIGN (DLLVERSIONINFO, dwMajorVersion, 4)
    TEST_FIELD_OFFSET(DLLVERSIONINFO, dwMajorVersion, 4)
    TEST_FIELD_SIZE  (DLLVERSIONINFO, dwMinorVersion, 4)
    TEST_FIELD_ALIGN (DLLVERSIONINFO, dwMinorVersion, 4)
    TEST_FIELD_OFFSET(DLLVERSIONINFO, dwMinorVersion, 8)
    TEST_FIELD_SIZE  (DLLVERSIONINFO, dwBuildNumber, 4)
    TEST_FIELD_ALIGN (DLLVERSIONINFO, dwBuildNumber, 4)
    TEST_FIELD_OFFSET(DLLVERSIONINFO, dwBuildNumber, 12)
    TEST_FIELD_SIZE  (DLLVERSIONINFO, dwPlatformID, 4)
    TEST_FIELD_ALIGN (DLLVERSIONINFO, dwPlatformID, 4)
    TEST_FIELD_OFFSET(DLLVERSIONINFO, dwPlatformID, 16)
}
121

122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
static void test_pack_DLLVERSIONINFO2(void)
{
    /* DLLVERSIONINFO2 (pack 8) */
    TEST_TYPE_SIZE   (DLLVERSIONINFO2, 32)
    TEST_TYPE_ALIGN  (DLLVERSIONINFO2, 8)
    TEST_FIELD_SIZE  (DLLVERSIONINFO2, info1, 20)
    TEST_FIELD_ALIGN (DLLVERSIONINFO2, info1, 4)
    TEST_FIELD_OFFSET(DLLVERSIONINFO2, info1, 0)
    TEST_FIELD_SIZE  (DLLVERSIONINFO2, dwFlags, 4)
    TEST_FIELD_ALIGN (DLLVERSIONINFO2, dwFlags, 4)
    TEST_FIELD_OFFSET(DLLVERSIONINFO2, dwFlags, 20)
    TEST_FIELD_SIZE  (DLLVERSIONINFO2, ullVersion, 8)
    TEST_FIELD_ALIGN (DLLVERSIONINFO2, ullVersion, 8)
    TEST_FIELD_OFFSET(DLLVERSIONINFO2, ullVersion, 24)
}

static void test_pack_HUSKEY(void)
{
    /* HUSKEY */
    TEST_TYPE_SIZE   (HUSKEY, 8)
    TEST_TYPE_ALIGN  (HUSKEY, 8)
}

static void test_pack_PHUSKEY(void)
{
    /* PHUSKEY */
    TEST_TYPE_SIZE   (PHUSKEY, 8)
    TEST_TYPE_ALIGN  (PHUSKEY, 8)
    TEST_TARGET_SIZE (PHUSKEY, 8)
    TEST_TARGET_ALIGN(PHUSKEY, 8)
}

#else /* _WIN64 */
155

156 157 158
static void test_pack_ASSOCF(void)
{
    /* ASSOCF */
159 160 161
    TEST_TYPE_SIZE   (ASSOCF, 4)
    TEST_TYPE_ALIGN  (ASSOCF, 4)
    TEST_TYPE_UNSIGNED(ASSOCF)
162 163
}

164 165 166
static void test_pack_DLLGETVERSIONPROC(void)
{
    /* DLLGETVERSIONPROC */
167 168
    TEST_TYPE_SIZE   (DLLGETVERSIONPROC, 4)
    TEST_TYPE_ALIGN  (DLLGETVERSIONPROC, 4)
169 170 171 172
}

static void test_pack_DLLVERSIONINFO(void)
{
173
    /* DLLVERSIONINFO (pack 8) */
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190
    TEST_TYPE_SIZE   (DLLVERSIONINFO, 20)
    TEST_TYPE_ALIGN  (DLLVERSIONINFO, 4)
    TEST_FIELD_SIZE  (DLLVERSIONINFO, cbSize, 4)
    TEST_FIELD_ALIGN (DLLVERSIONINFO, cbSize, 4)
    TEST_FIELD_OFFSET(DLLVERSIONINFO, cbSize, 0)
    TEST_FIELD_SIZE  (DLLVERSIONINFO, dwMajorVersion, 4)
    TEST_FIELD_ALIGN (DLLVERSIONINFO, dwMajorVersion, 4)
    TEST_FIELD_OFFSET(DLLVERSIONINFO, dwMajorVersion, 4)
    TEST_FIELD_SIZE  (DLLVERSIONINFO, dwMinorVersion, 4)
    TEST_FIELD_ALIGN (DLLVERSIONINFO, dwMinorVersion, 4)
    TEST_FIELD_OFFSET(DLLVERSIONINFO, dwMinorVersion, 8)
    TEST_FIELD_SIZE  (DLLVERSIONINFO, dwBuildNumber, 4)
    TEST_FIELD_ALIGN (DLLVERSIONINFO, dwBuildNumber, 4)
    TEST_FIELD_OFFSET(DLLVERSIONINFO, dwBuildNumber, 12)
    TEST_FIELD_SIZE  (DLLVERSIONINFO, dwPlatformID, 4)
    TEST_FIELD_ALIGN (DLLVERSIONINFO, dwPlatformID, 4)
    TEST_FIELD_OFFSET(DLLVERSIONINFO, dwPlatformID, 16)
191 192
}

193 194
static void test_pack_DLLVERSIONINFO2(void)
{
195
    /* DLLVERSIONINFO2 (pack 8) */
196 197 198 199 200 201 202 203 204 205 206
    TEST_TYPE_SIZE   (DLLVERSIONINFO2, 32)
    TEST_TYPE_ALIGN  (DLLVERSIONINFO2, 8)
    TEST_FIELD_SIZE  (DLLVERSIONINFO2, info1, 20)
    TEST_FIELD_ALIGN (DLLVERSIONINFO2, info1, 4)
    TEST_FIELD_OFFSET(DLLVERSIONINFO2, info1, 0)
    TEST_FIELD_SIZE  (DLLVERSIONINFO2, dwFlags, 4)
    TEST_FIELD_ALIGN (DLLVERSIONINFO2, dwFlags, 4)
    TEST_FIELD_OFFSET(DLLVERSIONINFO2, dwFlags, 20)
    TEST_FIELD_SIZE  (DLLVERSIONINFO2, ullVersion, 8)
    TEST_FIELD_ALIGN (DLLVERSIONINFO2, ullVersion, 8)
    TEST_FIELD_OFFSET(DLLVERSIONINFO2, ullVersion, 24)
207 208
}

209 210 211
static void test_pack_HUSKEY(void)
{
    /* HUSKEY */
212 213
    TEST_TYPE_SIZE   (HUSKEY, 4)
    TEST_TYPE_ALIGN  (HUSKEY, 4)
214 215 216 217 218
}

static void test_pack_PHUSKEY(void)
{
    /* PHUSKEY */
219 220 221 222
    TEST_TYPE_SIZE   (PHUSKEY, 4)
    TEST_TYPE_ALIGN  (PHUSKEY, 4)
    TEST_TARGET_SIZE (PHUSKEY, 4)
    TEST_TARGET_ALIGN(PHUSKEY, 4)
223 224
}

225 226
#endif /* _WIN64 */

227 228
static void test_pack(void)
{
229
    test_pack_ASSOCF();
230 231
    test_pack_DLLGETVERSIONPROC();
    test_pack_DLLVERSIONINFO();
232
    test_pack_DLLVERSIONINFO2();
233 234 235 236 237 238 239 240
    test_pack_HUSKEY();
    test_pack_PHUSKEY();
}

START_TEST(generated)
{
    test_pack();
}