ReactOS  0.4.15-dev-3453-gff89651
AddFontResourceEx.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS api tests
3  * LICENSE: GPL - See COPYING in the top level directory
4  * PURPOSE: Test for AddFontResourceEx
5  * PROGRAMMERS: Timo Kreuzer
6  */
7 
8 #include "precomp.h"
9 
10 #include <pseh/pseh2.h>
11 
13 {
14  WCHAR szFileName[MAX_PATH];
15  int result;
16 
17  /* Test NULL filename */
19 
20  /* Windows crashes, need SEH here */
21  _SEH2_TRY
22  {
24  }
26  {
27  result = -1;
29  }
30  _SEH2_END
31  ok(result == -1, "AddFontResourceExW should throw an exception!, result == %d\n", result);
32  ok(GetLastError() == 0xc0000005, "GetLastError()==%lx\n", GetLastError());
33 
34  /* Test "" filename */
36  result = AddFontResourceExW(L"", 0, 0);
37  ok(result == 0, "AddFontResourceExW(L"", 0, 0) succeeded, result==%d\n", result);
38  ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError()==%ld\n", GetLastError());
39 
40  GetEnvironmentVariableW(L"systemroot", szFileName, MAX_PATH);
41  wcscat(szFileName, L"\\Fonts\\cour.ttf");
42 
43  /* Test flags = 0 */
45  result = AddFontResourceExW(szFileName, 0, 0);
46  ok(result == 1, "AddFontResourceExW(L"", 0, 0) failed, result==%d\n", result);
47  ok(GetLastError() == ERROR_SUCCESS, "GetLastError()==%ld\n", GetLastError());
48 
50  result = AddFontResourceExW(szFileName, 256, 0);
51  ok(result == 0, "AddFontResourceExW(L"", 0, 0) failed, result==%d\n", result);
52  ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError()==%ld\n", GetLastError());
53 
54  /* Test invalid pointer as last parameter */
55  result = AddFontResourceExW(szFileName, 0, (void*)-1);
56  ok(result != 0, "AddFontResourceExW(L"", 0, 0) failed, result==%d\n", result);
57  ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError()==%ld\n", GetLastError());
58 
59 }
60 
61 START_TEST(AddFontResourceEx)
62 {
64 }
65 
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define ERROR_SUCCESS
Definition: deptool.c:10
GLuint64EXT * result
Definition: glext.h:11304
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
_SEH2_TRY
Definition: create.c:4226
#define L(x)
Definition: ntvdm.h:50
void Test_AddFontResourceExW()
INT WINAPI AddFontResourceExW(_In_ LPCWSTR pszFilename, _In_ DWORD fl, _Reserved_ PVOID pvReserved)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define MAX_PATH
Definition: compat.h:34
#define SetLastError(x)
Definition: compat.h:611
_SEH2_END
Definition: create.c:4400
START_TEST(AddFontResourceEx)
#define ok(value,...)
Definition: atltest.h:57
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define NULL
Definition: types.h:112
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:40
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:165
#define GetEnvironmentVariableW(x, y, z)
Definition: compat.h:614