ReactOS 0.4.16-dev-319-g6cf4263
FormatMessage.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS api tests
3 * LICENSE: GPLv2+ - See COPYING in the top level directory
4 * PURPOSE: Test for FormatMessage and resources
5 * PROGRAMMERS: Pierre Schweitzer
6 */
7
8#include <apitest.h>
9#include <FormatMessage.h>
10
11WCHAR First[] = L"This is a test message.\r\n";
12WCHAR Second[] = L"This is a second test message.\r\n";
13
15{
17 DWORD Written;
18
19 Buffer = NULL;
21 NULL, MSG_FIRST_MESSAGE, 0, (LPWSTR)&Buffer, 0, NULL);
22 ok(Written != 0, "Unexpected error: %lx\n", GetLastError());
23 ok(Buffer != NULL, "No buffer allocated\n");
24 ok(Written == (sizeof(First) - sizeof(UNICODE_NULL)) / sizeof(WCHAR),
25 "Invalid size: %ld (expected: %d)\n",
26 Written, (sizeof(First) - sizeof(UNICODE_NULL)) / sizeof(WCHAR));
27 ok(RtlCompareMemory(Buffer, First, sizeof(First) - sizeof(UNICODE_NULL)) ==
28 sizeof(First) - sizeof(UNICODE_NULL),
29 "Mismatching string: %S (expected : %S)\n", Buffer, First);
31
32 Buffer = NULL;
34 NULL, MSG_SECOND_MESSAGE, 0, (LPWSTR)&Buffer, 0, NULL);
35 ok(Written != 0, "Unexpected error: %lx\n", GetLastError());
36 ok(Buffer != NULL, "No buffer allocated\n");
37 ok(Written == (sizeof(Second) - sizeof(UNICODE_NULL)) / sizeof(WCHAR),
38 "Invalid size: %ld (expected: %d)\n",
39 Written, (sizeof(Second) - sizeof(UNICODE_NULL)) / sizeof(WCHAR));
40 ok(RtlCompareMemory(Buffer, Second, sizeof(Second) - sizeof(UNICODE_NULL)) ==
41 sizeof(Second) - sizeof(UNICODE_NULL),
42 "Mismatching string: %S (expected: %S)\n", Buffer, Second);
44
45 Buffer = NULL;
47 NULL, MSG_SECOND_MESSAGE + 1, 0, (LPWSTR)&Buffer, 0, NULL);
48 ok(Written == 0, "Unexpected success: %ld\n", Written);
49 ok(Buffer == NULL, "Unexpected success: %p\n", Buffer);
50 ok(GetLastError() == 0x13d, "Unexpected error: %lx\n", GetLastError());
51}
WCHAR Second[]
Definition: FormatMessage.c:12
WCHAR First[]
Definition: FormatMessage.c:11
#define ok(value,...)
Definition: atltest.h:57
#define START_TEST(x)
Definition: atltest.h:75
Definition: bufpool.h:45
#define NULL
Definition: types.h:112
DWORD WINAPI FormatMessageW(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, LPWSTR lpBuffer, DWORD nSize, __ms_va_list *args)
Definition: format_msg.c:583
#define RtlCompareMemory(s1, s2, l)
Definition: env_spec_w32.h:465
unsigned long DWORD
Definition: ntddk_ex.h:95
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
#define UNICODE_NULL
#define L(x)
Definition: ntvdm.h:50
uint16_t * PWSTR
Definition: typedefs.h:56
#define FormatMessage
Definition: winbase.h:3820
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define FORMAT_MESSAGE_ALLOCATE_BUFFER
Definition: winbase.h:445
#define FORMAT_MESSAGE_FROM_HMODULE
Definition: winbase.h:448
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184