[NTOS:PO]
[reactos.git] / rostests / regtests / bugs / bug3481.c
1 /*
2 * PROJECT: ReactOS bug regression tests
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: rostests/regtests/bugs/bug3481.c
5 * PURPOSE: Test for bug 3481
6 * PROGRAMMERS: Timo Kreuzer
7 */
8
9 #include <stdio.h>
10 #include <wine/test.h>
11 #include <windows.h>
12
13 #define COUNT 26
14
15 void Test_bug3481()
16 {
17 const char text[COUNT] = "abcdefghijklmnopqrstuvmxyz";
18 WORD agi[COUNT];
19 INT i, aiWidth1[COUNT], aiWidth2[COUNT];
20 BOOL result;
21 HDC hdc;
22 SIZE size1, size2;
23
24 /* Create a DC */
25 hdc = CreateCompatibleDC(NULL);
26
27 SelectObject(hdc, GetStockObject(DEFAULT_GUI_FONT));
28
29 /* Convert the charcaters into glyph indices */
30 result = GetGlyphIndicesA(hdc, text, COUNT, agi, 0);
31 ok(result != 0, "result=%d, GetLastError()=%ld\n", result, GetLastError());
32
33 /* Get the size of the string */
34 result = GetTextExtentPoint32A(hdc, text, COUNT, &size1);
35 ok(result != 0, "result=%d, GetLastError()=%ld\n", result, GetLastError());
36
37 /* Get the size from glyph indices */
38 result = GetTextExtentPointI(hdc, agi, COUNT, &size2);
39 ok(result != 0, "result=%d, GetLastError()=%ld\n", result, GetLastError());
40
41 /* Compare sizes */
42 ok(size1.cx == size2.cx, "Sizes don't match. size1.cx=%ld, size2.cx=%ld\n", size1.cx, size2.cx);
43 ok(size1.cy == size2.cy, "Sizes don't match. size1.cy=%ld, size2.cy=%ld\n", size1.cy, size2.cy);
44
45 /* Get the size of the string */
46 result = GetTextExtentExPointA(hdc, text, COUNT, MAXLONG, NULL, aiWidth1, &size1);
47 ok(result != 0, "result=%d, GetLastError()=%ld\n", result, GetLastError());
48
49 /* Get the size from glyph indices */
50 result = GetTextExtentExPointI(hdc, agi, COUNT, MAXLONG, NULL, aiWidth2, &size2);
51 ok(result != 0, "result=%d, GetLastError()=%ld\n", result, GetLastError());
52
53 /* Compare sizes */
54 ok(size1.cx == size2.cx, "Sizes don't match. size1.cx=%ld, size2.cx=%ld\n", size1.cx, size2.cx);
55 ok(size1.cy == size2.cy, "Sizes don't match. size1.cy=%ld, size2.cy=%ld\n", size1.cy, size2.cy);
56
57 /* Loop all characters */
58 for (i = 0; i < COUNT; i++)
59 {
60 /* Check if we got identical spacing values */
61 ok(aiWidth1[i] == aiWidth2[i], "wrong spacing, i=%d, char:%d, index:%d\n", i, aiWidth1[i], aiWidth2[i]);
62 }
63
64 /* Cleanup */
65 DeleteDC(hdc);
66 }
67
68 START_TEST(bug3481)
69 {
70 Test_bug3481();
71 }
72