Git conversion: Make reactos the root directory, move rosapps, rostests, wallpapers...
[reactos.git] / modules / rostests / apitests / gdi32 / GetTextFace.c
1 /*
2 * PROJECT: ReactOS api tests
3 * LICENSE: GPL - See COPYING in the top level directory
4 * PURPOSE: Test for GetTextFace
5 * PROGRAMMERS: Timo Kreuzer
6 */
7
8 #include <apitest.h>
9
10 #include <wingdi.h>
11
12 #define TEST(x) ok(x, #x"\n")
13 #define RTEST(x) ok(x, #x"\n")
14
15 void Test_GetTextFace()
16 {
17 HDC hDC;
18 INT ret;
19 INT ret2;
20 WCHAR Buffer[20];
21
22 hDC = CreateCompatibleDC(NULL);
23 ok(hDC != 0, "CreateCompatibleDC failed, skipping tests.\n");
24 if (!hDC) return;
25
26 /* Whether asking for the string size (NULL buffer) ignores the size argument */
27 SetLastError(0xE000BEEF);
28 ret = GetTextFaceW(hDC, 0, NULL);
29 TEST(ret != 0);
30 ok(GetLastError() == 0xE000BEEF, "GetLastError() == %ld\n", GetLastError());
31 ret2 = ret;
32
33 SetLastError(0xE000BEEF);
34 ret = GetTextFaceW(hDC, -1, NULL);
35 TEST(ret != 0);
36 TEST(ret == ret2);
37 ok(GetLastError() == 0xE000BEEF, "GetLastError() == %ld\n", GetLastError());
38 ret2 = ret;
39
40 SetLastError(0xE000BEEF);
41 ret = GetTextFaceW(hDC, 10000, NULL);
42 TEST(ret != 0);
43 TEST(ret == ret2);
44 ok(GetLastError() == 0xE000BEEF, "GetLastError() == %ld\n", GetLastError());
45 ret2 = ret;
46
47 /* Whether the buffer is correctly filled */
48 SetLastError(0xE000BEEF);
49 ret = GetTextFaceW(hDC, 20, Buffer);
50 TEST(ret != 0);
51 TEST(ret <= 20);
52 TEST(Buffer[ret - 1] == 0);
53 ok(GetLastError() == 0xE000BEEF, "GetLastError() == %ld\n", GetLastError());
54
55 SetLastError(0xE000BEEF);
56 ret = GetTextFaceW(hDC, 1, Buffer);
57 TEST(ret == 1);
58 TEST(Buffer[ret - 1] == 0);
59 ok(GetLastError() == 0xE000BEEF, "GetLastError() == %ld\n", GetLastError());
60
61 SetLastError(0xE000BEEF);
62 ret = GetTextFaceW(hDC, 2, Buffer);
63 TEST(ret == 2);
64 TEST(Buffer[ret - 1] == 0);
65 ok(GetLastError() == 0xE000BEEF, "GetLastError() == %ld\n", GetLastError());
66
67 /* Whether invalid buffer sizes are correctly ignored */
68 SetLastError(0xE000BEEF);
69 ret = GetTextFaceW(hDC, 0, Buffer);
70 TEST(ret == 0);
71 ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError() == %ld\n", GetLastError());
72
73 SetLastError(0xE000BEEF);
74 ret = GetTextFaceW(hDC, -1, Buffer);
75 TEST(ret == 0);
76 ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError() == %ld\n", GetLastError());
77
78 DeleteDC(hDC);
79 }
80
81 START_TEST(GetTextFace)
82 {
83 Test_GetTextFace();
84 }
85