ReactOS  0.4.15-dev-2701-g34593d9
AddFontResourceEx.c File Reference
#include "precomp.h"
#include <pseh/pseh2.h>
Include dependency graph for AddFontResourceEx.c:

Go to the source code of this file.

Functions

void Test_AddFontResourceExW ()
 
 START_TEST (AddFontResourceEx)
 

Function Documentation

◆ START_TEST()

START_TEST ( AddFontResourceEx  )

Definition at line 61 of file AddFontResourceEx.c.

62 {
64 }
void Test_AddFontResourceExW()

◆ Test_AddFontResourceExW()

void Test_AddFontResourceExW ( )

Definition at line 12 of file AddFontResourceEx.c.

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 }
#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
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
static const WCHAR L[]
Definition: oid.c:1250
_SEH2_END
Definition: create.c:4400
#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

Referenced by START_TEST().