FreeRDP
libwinpr/crt/test/TestTypes.c
1 
2 #include <stdio.h>
3 #include <winpr/crt.h>
4 #include <winpr/windows.h>
5 
6 #define EXPECTED_SIZEOF_BYTE 1
7 #define EXPECTED_SIZEOF_BOOLEAN 1
8 #define EXPECTED_SIZEOF_CHAR 1
9 #define EXPECTED_SIZEOF_UCHAR 1
10 #define EXPECTED_SIZEOF_INT8 1
11 #define EXPECTED_SIZEOF_UINT8 1
12 #define EXPECTED_SIZEOF_INT16 2
13 #define EXPECTED_SIZEOF_UINT16 2
14 #define EXPECTED_SIZEOF_WORD 2
15 #define EXPECTED_SIZEOF_WCHAR 2
16 #define EXPECTED_SIZEOF_SHORT 2
17 #define EXPECTED_SIZEOF_USHORT 2
18 #define EXPECTED_SIZEOF_BOOL 4
19 #define EXPECTED_SIZEOF_INT 4
20 #define EXPECTED_SIZEOF_UINT 4
21 #define EXPECTED_SIZEOF_INT32 4
22 #define EXPECTED_SIZEOF_UINT32 4
23 #define EXPECTED_SIZEOF_DWORD 4
24 #define EXPECTED_SIZEOF_DWORD32 4
25 #define EXPECTED_SIZEOF_LONG 4
26 #define EXPECTED_SIZEOF_LONG32 4
27 #define EXPECTED_SIZEOF_INT64 8
28 #define EXPECTED_SIZEOF_UINT64 8
29 #define EXPECTED_SIZEOF_DWORD64 8
30 #define EXPECTED_SIZEOF_DWORDLONG 8
31 #define EXPECTED_SIZEOF_LONG64 8
32 #define EXPECTED_SIZEOF_ULONGLONG 8
33 #define EXPECTED_SIZEOF_LUID 8
34 #define EXPECTED_SIZEOF_FILETIME 8
35 #define EXPECTED_SIZEOF_LARGE_INTEGER 8
36 #define EXPECTED_SIZEOF_ULARGE_INTEGER 8
37 #define EXPECTED_SIZEOF_GUID 16
38 #define EXPECTED_SIZEOF_SYSTEMTIME 16
39 #define EXPECTED_SIZEOF_size_t sizeof(void*)
40 #define EXPECTED_SIZEOF_INT_PTR sizeof(void*)
41 #define EXPECTED_SIZEOF_UINT_PTR sizeof(void*)
42 #define EXPECTED_SIZEOF_DWORD_PTR sizeof(void*)
43 #define EXPECTED_SIZEOF_LONG_PTR sizeof(void*)
44 #define EXPECTED_SIZEOF_ULONG_PTR sizeof(void*)
45 
46 #define TEST_SIZEOF_TYPE(_name) \
47  if (sizeof(_name) != EXPECTED_SIZEOF_##_name) \
48  { \
49  (void)fprintf(stderr, "sizeof(%s) mismatch: Actual: %" PRIuz ", Expected: %" PRIuz "\n", \
50  #_name, sizeof(_name), (size_t)EXPECTED_SIZEOF_##_name); \
51  status = -1; \
52  }
53 
54 int TestTypes(int argc, char* argv[])
55 {
56  int status = 0;
57 
58  WINPR_UNUSED(argc);
59  WINPR_UNUSED(argv);
60 
61  TEST_SIZEOF_TYPE(INT8)
62  TEST_SIZEOF_TYPE(UINT8)
63 
64  TEST_SIZEOF_TYPE(BYTE)
65  TEST_SIZEOF_TYPE(BOOLEAN)
66  TEST_SIZEOF_TYPE(CHAR)
67  TEST_SIZEOF_TYPE(UCHAR)
68 
69  TEST_SIZEOF_TYPE(INT16)
70  TEST_SIZEOF_TYPE(UINT16)
71 
72  TEST_SIZEOF_TYPE(WORD)
73  TEST_SIZEOF_TYPE(WCHAR)
74  TEST_SIZEOF_TYPE(SHORT)
75  TEST_SIZEOF_TYPE(USHORT)
76 
77  /* fails on OS X */
78  // TEST_SIZEOF_TYPE(BOOL)
79 
80  TEST_SIZEOF_TYPE(INT)
81  TEST_SIZEOF_TYPE(UINT)
82  TEST_SIZEOF_TYPE(DWORD)
83  TEST_SIZEOF_TYPE(DWORD32)
84  TEST_SIZEOF_TYPE(LONG)
85  TEST_SIZEOF_TYPE(LONG32)
86 
87  TEST_SIZEOF_TYPE(INT32)
88  TEST_SIZEOF_TYPE(UINT32)
89 
90  TEST_SIZEOF_TYPE(INT64)
91  TEST_SIZEOF_TYPE(UINT64)
92 
93  TEST_SIZEOF_TYPE(DWORD64)
94  TEST_SIZEOF_TYPE(DWORDLONG)
95 
96  TEST_SIZEOF_TYPE(LONG64)
97  TEST_SIZEOF_TYPE(ULONGLONG)
98 
99  TEST_SIZEOF_TYPE(LUID)
100  TEST_SIZEOF_TYPE(FILETIME)
101  TEST_SIZEOF_TYPE(LARGE_INTEGER)
102  TEST_SIZEOF_TYPE(ULARGE_INTEGER)
103 
104  TEST_SIZEOF_TYPE(GUID)
105  TEST_SIZEOF_TYPE(SYSTEMTIME)
106 
107  TEST_SIZEOF_TYPE(size_t)
108  TEST_SIZEOF_TYPE(INT_PTR)
109  TEST_SIZEOF_TYPE(UINT_PTR)
110  TEST_SIZEOF_TYPE(DWORD_PTR)
111  TEST_SIZEOF_TYPE(LONG_PTR)
112  TEST_SIZEOF_TYPE(ULONG_PTR)
113 
114  return status;
115 }