e304986d13fe4342ee0082f5c977d6b7c7905d20
[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 "precomp.h"
9
10 void Test_GetTextFace()
11 {
12 HDC hDC;
13 INT ret;
14 INT ret2;
15 WCHAR Buffer[20];
16
17 hDC = CreateCompatibleDC(NULL);
18 ok(hDC != 0, "CreateCompatibleDC failed, skipping tests.\n");
19 if (!hDC) return;
20
21 /* Whether asking for the string size (NULL buffer) ignores the size argument */
22 SetLastError(0xE000BEEF);
23 ret = GetTextFaceW(hDC, 0, NULL);
24 TEST(ret != 0);
25 ok(GetLastError() == 0xE000BEEF, "GetLastError() == %ld\n", GetLastError());
26 ret2 = ret;
27
28 SetLastError(0xE000BEEF);
29 ret = GetTextFaceW(hDC, -1, NULL);
30 TEST(ret != 0);
31 TEST(ret == ret2);
32 ok(GetLastError() == 0xE000BEEF, "GetLastError() == %ld\n", GetLastError());
33 ret2 = ret;
34
35 SetLastError(0xE000BEEF);
36 ret = GetTextFaceW(hDC, 10000, NULL);
37 TEST(ret != 0);
38 TEST(ret == ret2);
39 ok(GetLastError() == 0xE000BEEF, "GetLastError() == %ld\n", GetLastError());
40 ret2 = ret;
41
42 /* Whether the buffer is correctly filled */
43 SetLastError(0xE000BEEF);
44 ret = GetTextFaceW(hDC, 20, Buffer);
45 TEST(ret != 0);
46 TEST(ret <= 20);
47 TEST(Buffer[ret - 1] == 0);
48 ok(GetLastError() == 0xE000BEEF, "GetLastError() == %ld\n", GetLastError());
49
50 SetLastError(0xE000BEEF);
51 ret = GetTextFaceW(hDC, 1, Buffer);
52 TEST(ret == 1);
53 TEST(Buffer[ret - 1] == 0);
54 ok(GetLastError() == 0xE000BEEF, "GetLastError() == %ld\n", GetLastError());
55
56 SetLastError(0xE000BEEF);
57 ret = GetTextFaceW(hDC, 2, Buffer);
58 TEST(ret == 2);
59 TEST(Buffer[ret - 1] == 0);
60 ok(GetLastError() == 0xE000BEEF, "GetLastError() == %ld\n", GetLastError());
61
62 /* Whether invalid buffer sizes are correctly ignored */
63 SetLastError(0xE000BEEF);
64 ret = GetTextFaceW(hDC, 0, Buffer);
65 TEST(ret == 0);
66 ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError() == %ld\n", GetLastError());
67
68 SetLastError(0xE000BEEF);
69 ret = GetTextFaceW(hDC, -1, Buffer);
70 TEST(ret == 0);
71 ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError() == %ld\n", GetLastError());
72
73 DeleteDC(hDC);
74 }
75
76 START_TEST(GetTextFace)
77 {
78 Test_GetTextFace();
79 }
80