ReactOS 0.4.16-dev-2332-g4cba65d
GetCharWidth.c File Reference
#include "precomp.h"
Include dependency graph for GetCharWidth.c:

Go to the source code of this file.

Functions

static void Test_CharWidthA (HDC hDC)
 
static void Test_CharWidthW (HDC hDC)
 
static void Test_CharWidthI (HDC hDC)
 
static void Test_CharWidth32A (HDC hDC)
 
static void Test_CharWidth32W (HDC hDC)
 
static void Test_CharWidthFloatA (HDC hDC)
 
static void Test_CharWidthFloatW (HDC hDC)
 
 START_TEST (GetCharWidth)
 

Function Documentation

◆ START_TEST()

START_TEST ( GetCharWidth  )

Definition at line 349 of file GetCharWidth.c.

350{
359 DeleteDC(hDC);
360}
static HDC hDC
Definition: 3dtext.c:33
static void Test_CharWidthW(HDC hDC)
Definition: GetCharWidth.c:56
static void Test_CharWidthA(HDC hDC)
Definition: GetCharWidth.c:10
static void Test_CharWidthFloatA(HDC hDC)
Definition: GetCharWidth.c:257
static void Test_CharWidth32A(HDC hDC)
Definition: GetCharWidth.c:165
static void Test_CharWidthI(HDC hDC)
Definition: GetCharWidth.c:102
static void Test_CharWidth32W(HDC hDC)
Definition: GetCharWidth.c:211
static void Test_CharWidthFloatW(HDC hDC)
Definition: GetCharWidth.c:303
#define NULL
Definition: types.h:112
static HDC
Definition: imagelist.c:88
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
BOOL WINAPI DeleteDC(_In_ HDC)

◆ Test_CharWidth32A()

static void Test_CharWidth32A ( HDC  hDC)
static

Definition at line 165 of file GetCharWidth.c.

166{
167 BOOL ret;
168 INT anBuffer['Z' - 'A' + 1];
169
170 SetLastError(0xBEEFCAFE);
171 ret = GetCharWidth32A(NULL, 'A', 'Z', NULL);
172 ok_int(ret, FALSE);
174
175 SetLastError(0xBEEFCAFE);
176 ret = GetCharWidth32A(NULL, 'B', 'A', NULL);
177 ok_int(ret, FALSE);
179
180 SetLastError(0xBEEFCAFE);
181 ret = GetCharWidth32A(NULL, 'A', 'Z', anBuffer);
182 ok_int(ret, FALSE);
184
185 SetLastError(0xBEEFCAFE);
186 ret = GetCharWidth32A(NULL, 'B', 'A', anBuffer);
187 ok_int(ret, FALSE);
189
190 SetLastError(0xBEEFCAFE);
191 ret = GetCharWidth32A(hDC, 'A', 'Z', NULL);
192 ok_int(ret, FALSE);
194
195 SetLastError(0xBEEFCAFE);
196 ret = GetCharWidth32A(hDC, 'B', 'A', NULL);
197 ok_int(ret, FALSE);
199
200 SetLastError(0xBEEFCAFE);
201 ret = GetCharWidth32A(hDC, 'A', 'Z', anBuffer);
202 ok_int(ret, TRUE);
203 ok_err(0xBEEFCAFE);
204
205 SetLastError(0xBEEFCAFE);
206 ret = GetCharWidth32A(hDC, 'A', 'B', anBuffer);
207 ok_int(ret, TRUE);
208 ok_err(0xBEEFCAFE);
209}
#define ok_err(error)
Definition: atltest.h:124
#define ok_int(expression, result)
Definition: atltest.h:134
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define SetLastError(x)
Definition: compat.h:752
return ret
Definition: mutex.c:146
unsigned int BOOL
Definition: ntddk_ex.h:94
int32_t INT
Definition: typedefs.h:58
BOOL WINAPI GetCharWidth32A(_In_ HDC hdc, _In_ UINT iFirst, _In_ UINT iLast, _Out_writes_(iLast+1 - iFirst) LPINT lpBuffer)

Referenced by START_TEST().

◆ Test_CharWidth32W()

static void Test_CharWidth32W ( HDC  hDC)
static

Definition at line 211 of file GetCharWidth.c.

212{
213 BOOL ret;
214 INT anBuffer['Z' - 'A' + 1];
215
216 SetLastError(0xBEEFCAFE);
217 ret = GetCharWidth32W(NULL, 'A', 'Z', NULL);
218 ok_int(ret, FALSE);
220
221 SetLastError(0xBEEFCAFE);
222 ret = GetCharWidth32W(NULL, 'B', 'A', NULL);
223 ok_int(ret, FALSE);
225
226 SetLastError(0xBEEFCAFE);
227 ret = GetCharWidth32W(NULL, 'A', 'Z', anBuffer);
228 ok_int(ret, FALSE);
230
231 SetLastError(0xBEEFCAFE);
232 ret = GetCharWidth32W(NULL, 'B', 'A', anBuffer);
233 ok_int(ret, FALSE);
235
236 SetLastError(0xBEEFCAFE);
237 ret = GetCharWidth32W(hDC, 'A', 'Z', NULL);
238 ok_int(ret, FALSE);
240
241 SetLastError(0xBEEFCAFE);
242 ret = GetCharWidth32W(hDC, 'B', 'A', NULL);
243 ok_int(ret, FALSE);
245
246 SetLastError(0xBEEFCAFE);
247 ret = GetCharWidth32W(hDC, 'A', 'Z', anBuffer);
248 ok_int(ret, TRUE);
249 ok_err(0xBEEFCAFE);
250
251 SetLastError(0xBEEFCAFE);
252 ret = GetCharWidth32W(hDC, 'A', 'B', anBuffer);
253 ok_int(ret, TRUE);
254 ok_err(0xBEEFCAFE);
255}
BOOL WINAPI GetCharWidth32W(_In_ HDC hdc, _In_ UINT iFirst, _In_ UINT iLast, _Out_writes_(iLast+1 - iFirst) LPINT lpBuffer)

Referenced by START_TEST().

◆ Test_CharWidthA()

static void Test_CharWidthA ( HDC  hDC)
static

Definition at line 10 of file GetCharWidth.c.

11{
12 BOOL ret;
13 INT anBuffer['Z' - 'A' + 1];
14
15 SetLastError(0xBEEFCAFE);
16 ret = GetCharWidthA(NULL, 'A', 'Z', NULL);
19
20 SetLastError(0xBEEFCAFE);
21 ret = GetCharWidthA(NULL, 'B', 'A', NULL);
24
25 SetLastError(0xBEEFCAFE);
26 ret = GetCharWidthA(NULL, 'A', 'Z', anBuffer);
29
30 SetLastError(0xBEEFCAFE);
31 ret = GetCharWidthA(NULL, 'B', 'A', anBuffer);
34
35 SetLastError(0xBEEFCAFE);
36 ret = GetCharWidthA(hDC, 'A', 'Z', NULL);
39
40 SetLastError(0xBEEFCAFE);
41 ret = GetCharWidthA(hDC, 'B', 'A', NULL);
44
45 SetLastError(0xBEEFCAFE);
46 ret = GetCharWidthA(hDC, 'A', 'Z', anBuffer);
47 ok_int(ret, TRUE);
48 ok_err(0xBEEFCAFE);
49
50 SetLastError(0xBEEFCAFE);
51 ret = GetCharWidthA(hDC, 'A', 'B', anBuffer);
52 ok_int(ret, TRUE);
53 ok_err(0xBEEFCAFE);
54}
BOOL WINAPI GetCharWidthA(_In_ HDC hdc, _In_ UINT iFirst, _In_ UINT iLast, _Out_writes_(iLast+1 - iFirst) LPINT lpBuffer)

Referenced by START_TEST().

◆ Test_CharWidthFloatA()

static void Test_CharWidthFloatA ( HDC  hDC)
static

Definition at line 257 of file GetCharWidth.c.

258{
259 BOOL ret;
260 FLOAT aeBuffer['Z' - 'A' + 1];
261
262 SetLastError(0xBEEFCAFE);
263 ret = GetCharWidthFloatA(NULL, 'A', 'Z', NULL);
264 ok_int(ret, FALSE);
266
267 SetLastError(0xBEEFCAFE);
268 ret = GetCharWidthFloatA(NULL, 'B', 'A', NULL);
269 ok_int(ret, FALSE);
271
272 SetLastError(0xBEEFCAFE);
273 ret = GetCharWidthFloatA(NULL, 'A', 'Z', aeBuffer);
274 ok_int(ret, FALSE);
276
277 SetLastError(0xBEEFCAFE);
278 ret = GetCharWidthFloatA(NULL, 'B', 'A', aeBuffer);
279 ok_int(ret, FALSE);
281
282 SetLastError(0xBEEFCAFE);
283 ret = GetCharWidthFloatA(hDC, 'A', 'Z', NULL);
284 ok_int(ret, FALSE);
286
287 SetLastError(0xBEEFCAFE);
288 ret = GetCharWidthFloatA(hDC, 'B', 'A', NULL);
289 ok_int(ret, FALSE);
291
292 SetLastError(0xBEEFCAFE);
293 ret = GetCharWidthFloatA(hDC, 'A', 'Z', aeBuffer);
294 ok_int(ret, TRUE);
295 ok_err(0xBEEFCAFE);
296
297 SetLastError(0xBEEFCAFE);
298 ret = GetCharWidthFloatA(hDC, 'A', 'B', aeBuffer);
299 ok_int(ret, TRUE);
300 ok_err(0xBEEFCAFE);
301}
float FLOAT
Definition: typedefs.h:69
BOOL WINAPI GetCharWidthFloatA(_In_ HDC hdc, _In_ UINT iFirst, _In_ UINT iLast, _Out_writes_(iLast+1 - iFirst) PFLOAT lpBuffer)

Referenced by START_TEST().

◆ Test_CharWidthFloatW()

static void Test_CharWidthFloatW ( HDC  hDC)
static

Definition at line 303 of file GetCharWidth.c.

304{
305 BOOL ret;
306 FLOAT aeBuffer['Z' - 'A' + 1];
307
308 SetLastError(0xBEEFCAFE);
309 ret = GetCharWidthFloatW(NULL, 'A', 'Z', NULL);
310 ok_int(ret, FALSE);
312
313 SetLastError(0xBEEFCAFE);
314 ret = GetCharWidthFloatW(NULL, 'B', 'A', NULL);
315 ok_int(ret, FALSE);
317
318 SetLastError(0xBEEFCAFE);
319 ret = GetCharWidthFloatW(NULL, 'A', 'Z', aeBuffer);
320 ok_int(ret, FALSE);
322
323 SetLastError(0xBEEFCAFE);
324 ret = GetCharWidthFloatW(NULL, 'B', 'A', aeBuffer);
325 ok_int(ret, FALSE);
327
328 SetLastError(0xBEEFCAFE);
329 ret = GetCharWidthFloatW(hDC, 'A', 'Z', NULL);
330 ok_int(ret, FALSE);
332
333 SetLastError(0xBEEFCAFE);
334 ret = GetCharWidthFloatW(hDC, 'B', 'A', NULL);
335 ok_int(ret, FALSE);
337
338 SetLastError(0xBEEFCAFE);
339 ret = GetCharWidthFloatW(hDC, 'A', 'Z', aeBuffer);
340 ok_int(ret, TRUE);
341 ok_err(0xBEEFCAFE);
342
343 SetLastError(0xBEEFCAFE);
344 ret = GetCharWidthFloatW(hDC, 'A', 'B', aeBuffer);
345 ok_int(ret, TRUE);
346 ok_err(0xBEEFCAFE);
347}
BOOL WINAPI GetCharWidthFloatW(_In_ HDC hdc, _In_ UINT iFirst, _In_ UINT iLast, _Out_writes_(iLast+1 - iFirst) PFLOAT lpBuffer)

Referenced by START_TEST().

◆ Test_CharWidthI()

static void Test_CharWidthI ( HDC  hDC)
static

Definition at line 102 of file GetCharWidth.c.

103{
104 BOOL ret;
105 WORD awBuffer['Z' - 'A' + 1];
106 INT anWidths['Z' - 'A' + 1];
107
108 SetLastError(0xBEEFCAFE);
109 ret = GetCharWidthI(NULL, 0, 0, NULL, NULL);
110 ok_int(ret, FALSE);
112
113 SetLastError(0xBEEFCAFE);
114 ret = GetCharWidthI(hDC, 0, 0, NULL, NULL);
115 ok_int(ret, FALSE);
117
118 SetLastError(0xBEEFCAFE);
119 ret = GetCharWidthI(NULL, 0, 1, awBuffer, anWidths);
120 ok_int(ret, FALSE);
122
123 SetLastError(0xBEEFCAFE);
124 ret = GetCharWidthI(hDC, 0, 1, awBuffer, NULL);
125 ok_int(ret, FALSE);
127
128 SetLastError(0xBEEFCAFE);
129 ret = GetCharWidthI(hDC, 0, 1, awBuffer, anWidths);
130 ok_int(ret, TRUE);
131 ok_err(0xBEEFCAFE);
132
133 SetLastError(0xBEEFCAFE);
134 ret = GetCharWidthI(hDC, 0, _countof(awBuffer), awBuffer, anWidths);
135 ok_int(ret, TRUE);
136 ok_err(0xBEEFCAFE);
137
138#if 0 // These tests take time in ReactOS
139 INT count = 0x2710000 / sizeof(INT);
140 PINT pn = malloc((count + 1) * sizeof(INT));
141 PWORD pw = malloc((count + 1) * sizeof(WORD));
142
143 if (!pn || !pw)
144 {
145 skip("allocation failed\n");
146 }
147 else
148 {
149 SetLastError(0xBEEFCAFE);
150 ret = GetCharWidthI(hDC, 0, count, pw, pn);
151 ok_int(ret, TRUE);
152 ok_err(0xBEEFCAFE);
153
154 SetLastError(0xBEEFCAFE);
155 ret = GetCharWidthI(hDC, 0, count + 1, pw, pn);
156 ok_int(ret, FALSE);
157 ok_err(0xBEEFCAFE);
158 }
159
160 free(pn);
161 free(pw);
162#endif
163}
#define skip(...)
Definition: atltest.h:64
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
unsigned short WORD
Definition: ntddk_ex.h:93
GLuint GLuint GLsizei count
Definition: gl.h:1545
int * PINT
Definition: minwindef.h:150
static int pints_t pn[]
Definition: server.c:148
WORD * PWORD
Definition: pedump.c:67
#define INT
Definition: polytest.cpp:20
#define _countof(array)
Definition: sndvol32.h:70
BOOL WINAPI GetCharWidthI(_In_ HDC hdc, _In_ UINT giFirst, _In_ UINT cgi, _In_reads_opt_(cgi) LPWORD pgi, _Out_writes_(cgi) LPINT piWidths)

Referenced by START_TEST().

◆ Test_CharWidthW()

static void Test_CharWidthW ( HDC  hDC)
static

Definition at line 56 of file GetCharWidth.c.

57{
58 BOOL ret;
59 INT anBuffer['Z' - 'A' + 1];
60
61 SetLastError(0xBEEFCAFE);
62 ret = GetCharWidthW(NULL, 'A', 'Z', NULL);
65
66 SetLastError(0xBEEFCAFE);
67 ret = GetCharWidthW(NULL, 'B', 'A', NULL);
70
71 SetLastError(0xBEEFCAFE);
72 ret = GetCharWidthW(NULL, 'A', 'Z', anBuffer);
75
76 SetLastError(0xBEEFCAFE);
77 ret = GetCharWidthW(NULL, 'B', 'A', anBuffer);
80
81 SetLastError(0xBEEFCAFE);
82 ret = GetCharWidthW(hDC, 'A', 'Z', NULL);
85
86 SetLastError(0xBEEFCAFE);
87 ret = GetCharWidthW(hDC, 'B', 'A', NULL);
90
91 SetLastError(0xBEEFCAFE);
92 ret = GetCharWidthW(hDC, 'A', 'Z', anBuffer);
93 ok_int(ret, TRUE);
94 ok_err(0xBEEFCAFE);
95
96 SetLastError(0xBEEFCAFE);
97 ret = GetCharWidthW(hDC, 'A', 'B', anBuffer);
98 ok_int(ret, TRUE);
99 ok_err(0xBEEFCAFE);
100}
BOOL WINAPI GetCharWidthW(_In_ HDC hdc, _In_ UINT iFirst, _In_ UINT iLast, _Out_writes_(iLast+1 - iFirst) LPINT lpBuffer)

Referenced by START_TEST().