ReactOS 0.4.15-dev-7942-gd23573b
stringformat.c File Reference
#include "objbase.h"
#include "gdiplus.h"
#include "wine/test.h"
Include dependency graph for stringformat.c:

Go to the source code of this file.

Macros

#define expect(expected, got)   ok(got == expected, "Expected %.8x, got %.8x\n", expected, got)
 
#define expectf(expected, got)   ok(got == expected, "Expected %.2f, got %.2f\n", expected, got)
 

Functions

static void test_constructor (void)
 
static void test_characterrange (void)
 
static void test_digitsubstitution (void)
 
static void test_getgenerictypographic (void)
 
static void test_tabstops (void)
 
static void test_getgenericdefault (void)
 
static void test_stringformatflags (void)
 
 START_TEST (stringformat)
 

Variables

static REAL tabstops [] = {0.0, 10.0, 2.0}
 

Macro Definition Documentation

◆ expect

#define expect (   expected,
  got 
)    ok(got == expected, "Expected %.8x, got %.8x\n", expected, got)

Definition at line 25 of file stringformat.c.

◆ expectf

#define expectf (   expected,
  got 
)    ok(got == expected, "Expected %.2f, got %.2f\n", expected, got)

Definition at line 26 of file stringformat.c.

Function Documentation

◆ START_TEST()

START_TEST ( stringformat  )

Definition at line 437 of file stringformat.c.

438{
439 struct GdiplusStartupInput gdiplusStartupInput;
440 ULONG_PTR gdiplusToken;
441 HMODULE hmsvcrt;
442 int (CDECL * _controlfp_s)(unsigned int *cur, unsigned int newval, unsigned int mask);
443
444 /* Enable all FP exceptions except _EM_INEXACT, which gdi32 can trigger */
445 hmsvcrt = LoadLibraryA("msvcrt");
446 _controlfp_s = (void*)GetProcAddress(hmsvcrt, "_controlfp_s");
447 if (_controlfp_s) _controlfp_s(0, 0, 0x0008001e);
448
449 gdiplusStartupInput.GdiplusVersion = 1;
450 gdiplusStartupInput.DebugEventCallback = NULL;
451 gdiplusStartupInput.SuppressBackgroundThread = 0;
452 gdiplusStartupInput.SuppressExternalCodecs = 0;
453
454 GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
455
463
464 GdiplusShutdown(gdiplusToken);
465}
int CDECL _controlfp_s(unsigned int *cur, unsigned int newval, unsigned int mask)
Definition: _controlfp_s.c:19
#define NULL
Definition: types.h:112
#define CDECL
Definition: compat.h:29
#define GetProcAddress(x, y)
Definition: compat.h:753
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
FxCollectionEntry * cur
Status WINAPI GdiplusStartup(ULONG_PTR *token, const struct GdiplusStartupInput *input, struct GdiplusStartupOutput *output)
Definition: gdiplus.c:81
void WINAPI GdiplusShutdown(ULONG_PTR)
GLenum GLint GLuint mask
Definition: glext.h:6028
static void test_tabstops(void)
Definition: stringformat.c:207
static void test_getgenericdefault(void)
Definition: stringformat.c:311
static void test_stringformatflags(void)
Definition: stringformat.c:376
static void test_getgenerictypographic(void)
Definition: stringformat.c:141
static void test_digitsubstitution(void)
Definition: stringformat.c:86
static void test_constructor(void)
Definition: stringformat.c:28
static void test_characterrange(void)
Definition: stringformat.c:60
uint32_t ULONG_PTR
Definition: typedefs.h:65

◆ test_characterrange()

static void test_characterrange ( void  )
static

Definition at line 60 of file stringformat.c.

61{
62 CharacterRange ranges[3];
63 INT count;
66
68 expect(Ok, stat);
72 expect(Ok, stat);
75
77 expect(Ok, stat);
79 expect(Ok, stat);
80 if (stat == Ok) expect(3, count);
81
83 expect(Ok, stat);
84}
#define stat
Definition: acwin.h:99
GpStatus WINGDIPAPI GdipCreateStringFormat(INT attr, LANGID lang, GpStringFormat **format)
Definition: stringformat.c:76
GpStatus WINGDIPAPI GdipSetStringFormatMeasurableCharacterRanges(GpStringFormat *format, INT rangeCount, GDIPCONST CharacterRange *ranges)
Definition: stringformat.c:290
GpStatus WINGDIPAPI GdipGetStringFormatMeasurableCharacterRangeCount(GDIPCONST GpStringFormat *format, INT *count)
Definition: stringformat.c:186
GpStatus WINGDIPAPI GdipDeleteStringFormat(GpStringFormat *format)
Definition: stringformat.c:105
Status
Definition: gdiplustypes.h:25
@ Ok
Definition: gdiplustypes.h:26
@ InvalidParameter
Definition: gdiplustypes.h:28
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
#define expect(expected, got)
Definition: stringformat.c:25
#define LANG_NEUTRAL
Definition: nls.h:22
Definition: stat.h:55
int32_t INT
Definition: typedefs.h:58

Referenced by START_TEST().

◆ test_constructor()

static void test_constructor ( void  )
static

Definition at line 28 of file stringformat.c.

29{
32 INT n, count;
33 StringAlignment align, line_align;
34 StringTrimming trimming;
35 StringDigitSubstitute digitsub;
36 LANGID digitlang;
37
39 expect(Ok, stat);
40
45 GdipGetStringFormatDigitSubstitution(format, &digitlang, &digitsub);
47
50 expect(StringAlignmentNear, line_align);
53 expect(LANG_NEUTRAL, digitlang);
54 expect(0, count);
55
57 expect(Ok, stat);
58}
GpStatus WINGDIPAPI GdipGetStringFormatHotkeyPrefix(GDIPCONST GpStringFormat *format, INT *hkpx)
Definition: stringformat.c:164
GpStatus WINGDIPAPI GdipGetStringFormatDigitSubstitution(GDIPCONST GpStringFormat *format, LANGID *language, StringDigitSubstitute *substitute)
Definition: stringformat.c:141
GpStatus WINGDIPAPI GdipGetStringFormatAlign(GpStringFormat *format, StringAlignment *align)
Definition: stringformat.c:130
GpStatus WINGDIPAPI GdipGetStringFormatLineAlign(GpStringFormat *format, StringAlignment *align)
Definition: stringformat.c:175
GpStatus WINGDIPAPI GdipGetStringFormatTrimming(GpStringFormat *format, StringTrimming *trimming)
Definition: stringformat.c:225
int align(int length, int align)
Definition: dsound8.c:36
StringTrimming
Definition: gdiplusenums.h:292
@ StringTrimmingCharacter
Definition: gdiplusenums.h:294
StringAlignment
Definition: gdiplusenums.h:264
@ StringAlignmentNear
Definition: gdiplusenums.h:265
StringDigitSubstitute
Definition: gdiplusenums.h:271
@ StringDigitSubstituteUser
Definition: gdiplusenums.h:272
@ HotkeyPrefixNone
Definition: gdiplusenums.h:313
GLdouble n
Definition: glext.h:7729
USHORT LANGID
Definition: mui.h:9

Referenced by START_TEST().

◆ test_digitsubstitution()

static void test_digitsubstitution ( void  )
static

Definition at line 86 of file stringformat.c.

87{
90 StringDigitSubstitute digitsub;
91 LANGID digitlang;
92
94 expect(Ok, stat);
95
96 /* NULL arguments */
100 expect(Ok, stat);
105 stat = GdipGetStringFormatDigitSubstitution(NULL, &digitlang, &digitsub);
109
110 /* try to get both and one by one */
111 stat = GdipGetStringFormatDigitSubstitution(format, &digitlang, &digitsub);
112 expect(Ok, stat);
114 expect(LANG_NEUTRAL, digitlang);
115
116 digitsub = StringDigitSubstituteNone;
118 expect(Ok, stat);
120
121 digitlang = LANG_RUSSIAN;
123 expect(Ok, stat);
124 expect(LANG_NEUTRAL, digitlang);
125
126 /* set/get */
129 expect(Ok, stat);
130 digitsub = StringDigitSubstituteNone;
131 digitlang = LANG_RUSSIAN;
132 stat = GdipGetStringFormatDigitSubstitution(format, &digitlang, &digitsub);
133 expect(Ok, stat);
136
138 expect(Ok, stat);
139}
GpStatus WINGDIPAPI GdipSetStringFormatDigitSubstitution(GpStringFormat *format, LANGID language, StringDigitSubstitute substitute)
Definition: stringformat.c:250
@ StringDigitSubstituteNone
Definition: gdiplusenums.h:273
#define MAKELANGID(p, s)
Definition: nls.h:15
#define SUBLANG_CHINESE_TRADITIONAL
Definition: nls.h:208
#define LANG_RUSSIAN
Definition: nls.h:113
#define LANG_CHINESE
Definition: nls.h:42

Referenced by START_TEST().

◆ test_getgenericdefault()

static void test_getgenericdefault ( void  )
static

Definition at line 311 of file stringformat.c.

312{
313 GpStringFormat *format, *format2;
315
316 INT flags;
317 INT n;
318 StringAlignment align, line_align;
319 StringTrimming trimming;
320 StringDigitSubstitute digitsub;
321 LANGID digitlang;
322 INT tabcount;
323
324 /* NULL arg */
327
329 expect(Ok, stat);
330
332 expect(Ok, stat);
333 ok(format == format2, "expected same format object\n");
334 stat = GdipDeleteStringFormat(format2);
335 expect(Ok, stat);
336
342 GdipGetStringFormatDigitSubstitution(format, &digitlang, &digitsub);
344
345 expect(0, flags);
348 expect(StringAlignmentNear, line_align);
351 expect(LANG_NEUTRAL, digitlang);
352 expect(0, tabcount);
353
354 /* Change default format parameters, release, get format object again. */
356 expect(Ok, stat);
357
359 expect(Ok, stat);
361
363 expect(Ok, stat);
364
366 expect(Ok, stat);
367
369 expect(Ok, stat);
371
373 expect(Ok, stat);
374}
#define ok(value,...)
Definition: atltest.h:57
GpStatus WINGDIPAPI GdipStringFormatGetGenericDefault(GpStringFormat **format)
Definition: stringformat.c:120
GpStatus WINGDIPAPI GdipGetStringFormatTabStopCount(GDIPCONST GpStringFormat *format, INT *count)
Definition: stringformat.c:199
GpStatus WINGDIPAPI GdipGetStringFormatFlags(GDIPCONST GpStringFormat *format, INT *flags)
Definition: stringformat.c:153
GpStatus WINGDIPAPI GdipSetStringFormatFlags(GpStringFormat *format, INT flags)
Definition: stringformat.c:357
@ StringFormatFlagsNoWrap
Definition: gdiplusenums.h:286
GLbitfield flags
Definition: glext.h:7161

Referenced by START_TEST().

◆ test_getgenerictypographic()

static void test_getgenerictypographic ( void  )
static

Definition at line 141 of file stringformat.c.

142{
143 GpStringFormat *format, *format2;
145 INT flags;
146 INT n;
147 StringAlignment align, line_align;
148 StringTrimming trimming;
149 StringDigitSubstitute digitsub;
150 LANGID digitlang;
151 INT tabcount;
152
153 /* NULL arg */
156
158 expect(Ok, stat);
159
161 expect(Ok, stat);
162 ok(format == format2, "expected same format object\n");
163 stat = GdipDeleteStringFormat(format2);
164 expect(Ok, stat);
165
171 GdipGetStringFormatDigitSubstitution(format, &digitlang, &digitsub);
173
175 flags);
178 expect(StringAlignmentNear, line_align);
179 expect(StringTrimmingNone, trimming);
181 expect(LANG_NEUTRAL, digitlang);
182 expect(0, tabcount);
183
184 /* Change format parameters, release, get format object again. */
186 expect(Ok, stat);
187
189 expect(Ok, stat);
191
193 expect(Ok, stat);
194
196 expect(Ok, stat);
197
199 expect(Ok, stat);
201
203 expect(Ok, stat);
204}
GpStatus WINGDIPAPI GdipStringFormatGetGenericTypographic(GpStringFormat **format)
Definition: stringformat.c:408
@ StringTrimmingNone
Definition: gdiplusenums.h:293
@ StringFormatFlagsLineLimit
Definition: gdiplusenums.h:287
@ StringFormatFlagsNoClip
Definition: gdiplusenums.h:288
@ StringFormatFlagsNoFitBlackBox
Definition: gdiplusenums.h:282

Referenced by START_TEST().

◆ test_stringformatflags()

static void test_stringformatflags ( void  )
static

Definition at line 376 of file stringformat.c.

377{
380
381 INT flags;
382
384 expect(Ok, stat);
385
386 /* NULL args */
389
391 expect(Ok, stat);
393 expect(Ok, stat);
394 expect(0, flags);
395
396 /* Check some valid flags */
398 expect(Ok, stat);
400 expect(Ok, stat);
402
404 expect(Ok, stat);
406 expect(Ok, stat);
408
409 /* Check some flag combinations */
412 expect(Ok, stat);
414 expect(Ok, stat);
417
420 expect(Ok, stat);
422 expect(Ok, stat);
425
426 /* Check invalid flags */
427 stat = GdipSetStringFormatFlags(format, 0xdeadbeef);
428 expect(Ok, stat);
430 expect(Ok, stat);
431 expect(0xdeadbeef, flags);
432
434 expect(Ok, stat);
435}
@ StringFormatFlagsDirectionVertical
Definition: gdiplusenums.h:281
@ StringFormatFlagsDisplayFormatControl
Definition: gdiplusenums.h:283
@ StringFormatFlagsDirectionRightToLeft
Definition: gdiplusenums.h:280
@ StringFormatFlagsMeasureTrailingSpaces
Definition: gdiplusenums.h:285
@ StringFormatFlagsNoFontFallback
Definition: gdiplusenums.h:284

Referenced by START_TEST().

◆ test_tabstops()

static void test_tabstops ( void  )
static

Definition at line 207 of file stringformat.c.

208{
211 INT count;
212 REAL tabs[3];
213 REAL firsttab;
214
216 expect(Ok, stat);
217
218 /* NULL */
225
232
237 stat = GdipGetStringFormatTabStops(NULL, 0, &firsttab, NULL);
245
246 /* not NULL */
248 expect(Ok, stat);
249 expect(0, count);
250 /* negative tabcount */
252 expect(Ok, stat);
253 count = -1;
255 expect(Ok, stat);
256 expect(0, count);
257
259 expect(Ok, stat);
262
263 firsttab = -1.0;
264 tabs[0] = tabs[1] = tabs[2] = -1.0;
265 stat = GdipGetStringFormatTabStops(format, 0, &firsttab, tabs);
266 expect(Ok, stat);
267 expectf(-1.0, tabs[0]);
268 expectf(-1.0, tabs[1]);
269 expectf(-1.0, tabs[2]);
270 expectf(0.0, firsttab);
271
273 expect(Ok, stat);
274 count = 0;
276 expect(Ok, stat);
277 expect(3, count);
278
279 firsttab = -1.0;
280 tabs[0] = tabs[1] = tabs[2] = -1.0;
281 stat = GdipGetStringFormatTabStops(format, 3, &firsttab, tabs);
282 expect(Ok, stat);
283 expectf(0.0, tabs[0]);
284 expectf(10.0, tabs[1]);
285 expectf(2.0, tabs[2]);
286 expectf(0.0, firsttab);
287
289 expect(Ok, stat);
290 firsttab = -1.0;
291 tabs[0] = tabs[1] = tabs[2] = -1.0;
292 stat = GdipGetStringFormatTabStops(format, 0, &firsttab, tabs);
293 expect(Ok, stat);
294 expectf(-1.0, tabs[0]);
295 expectf(-1.0, tabs[1]);
296 expectf(-1.0, tabs[2]);
297 expectf(10.0, firsttab);
298
299 /* zero tabcount, after valid setting to 3 */
301 expect(Ok, stat);
302 count = 0;
304 expect(Ok, stat);
305 expect(3, count);
306
308 expect(Ok, stat);
309}
float REAL
Definition: types.h:41
GpStatus WINGDIPAPI GdipGetStringFormatTabStops(GDIPCONST GpStringFormat *format, INT count, REAL *firsttab, REAL *tabs)
Definition: stringformat.c:210
GpStatus WINGDIPAPI GdipSetStringFormatTabStops(GpStringFormat *format, REAL firsttab, INT count, GDIPCONST REAL *tabs)
Definition: stringformat.c:312
@ NotImplemented
Definition: gdiplustypes.h:32
static REAL tabstops[]
Definition: stringformat.c:206
#define expectf(expected, got)
Definition: stringformat.c:26

Referenced by START_TEST().

Variable Documentation

◆ tabstops

REAL tabstops[] = {0.0, 10.0, 2.0}
static

Definition at line 206 of file stringformat.c.

Referenced by test_tabstops().