mirror of
https://github.com/reactos/reactos.git
synced 2025-04-27 17:10:22 +00:00
[KERNEL32_APITEST] Add a test for FormatMessage backed with MC file.
This commit is contained in:
parent
e8b1752162
commit
72094e637d
5 changed files with 78 additions and 1 deletions
|
@ -1,6 +1,8 @@
|
||||||
|
|
||||||
add_subdirectory(redirptest)
|
add_subdirectory(redirptest)
|
||||||
|
|
||||||
|
add_message_headers(ANSI FormatMessage.mc)
|
||||||
|
|
||||||
list(APPEND SOURCE
|
list(APPEND SOURCE
|
||||||
Console.c
|
Console.c
|
||||||
CreateProcess.c
|
CreateProcess.c
|
||||||
|
@ -9,6 +11,7 @@ list(APPEND SOURCE
|
||||||
dosdev.c
|
dosdev.c
|
||||||
FindActCtxSectionStringW.c
|
FindActCtxSectionStringW.c
|
||||||
FindFiles.c
|
FindFiles.c
|
||||||
|
FormatMessage.c
|
||||||
GetComputerNameEx.c
|
GetComputerNameEx.c
|
||||||
GetCurrentDirectory.c
|
GetCurrentDirectory.c
|
||||||
GetDriveType.c
|
GetDriveType.c
|
||||||
|
@ -30,11 +33,12 @@ list(APPEND SOURCE
|
||||||
WideCharToMultiByte.c
|
WideCharToMultiByte.c
|
||||||
precomp.h)
|
precomp.h)
|
||||||
|
|
||||||
add_executable(kernel32_apitest ${SOURCE} testlist.c)
|
add_executable(kernel32_apitest ${SOURCE} testlist.c kernel32_apitest.rc)
|
||||||
target_link_libraries(kernel32_apitest wine ${PSEH_LIB})
|
target_link_libraries(kernel32_apitest wine ${PSEH_LIB})
|
||||||
set_module_type(kernel32_apitest win32cui)
|
set_module_type(kernel32_apitest win32cui)
|
||||||
add_delay_importlibs(kernel32_apitest advapi32 shlwapi)
|
add_delay_importlibs(kernel32_apitest advapi32 shlwapi)
|
||||||
add_importlibs(kernel32_apitest msvcrt kernel32 ntdll)
|
add_importlibs(kernel32_apitest msvcrt kernel32 ntdll)
|
||||||
|
add_dependencies(kernel32_apitest FormatMessage)
|
||||||
add_pch(kernel32_apitest precomp.h SOURCE)
|
add_pch(kernel32_apitest precomp.h SOURCE)
|
||||||
add_rostests_file(TARGET kernel32_apitest)
|
add_rostests_file(TARGET kernel32_apitest)
|
||||||
|
|
||||||
|
|
51
modules/rostests/apitests/kernel32/FormatMessage.c
Normal file
51
modules/rostests/apitests/kernel32/FormatMessage.c
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
/*
|
||||||
|
* PROJECT: ReactOS api tests
|
||||||
|
* LICENSE: GPLv2+ - See COPYING in the top level directory
|
||||||
|
* PURPOSE: Test for FormatMessage and resources
|
||||||
|
* PROGRAMMERS: Pierre Schweitzer
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <apitest.h>
|
||||||
|
#include <FormatMessage.h>
|
||||||
|
|
||||||
|
WCHAR First[] = L"This is a test message.\r\n";
|
||||||
|
WCHAR Second[] = L"This is a second test message.\r\n";
|
||||||
|
|
||||||
|
START_TEST(FormatMessage)
|
||||||
|
{
|
||||||
|
PWSTR Buffer;
|
||||||
|
DWORD Written;
|
||||||
|
|
||||||
|
Buffer = NULL;
|
||||||
|
Written = FormatMessageW(FORMAT_MESSAGE_FROM_HMODULE | FORMAT_MESSAGE_ALLOCATE_BUFFER,
|
||||||
|
NULL, MSG_FIRST_MESSAGE, 0, (LPWSTR)&Buffer, 0, NULL);
|
||||||
|
ok(Written != 0, "Unexpected error: %lx\n", GetLastError());
|
||||||
|
ok(Buffer != NULL, "No buffer allocated\n");
|
||||||
|
ok(Written == (sizeof(First) - sizeof(UNICODE_NULL)) / sizeof(WCHAR),
|
||||||
|
"Invalid size: %ld (expected: %d)\n",
|
||||||
|
Written, (sizeof(First) - sizeof(UNICODE_NULL)) / sizeof(WCHAR));
|
||||||
|
ok(RtlCompareMemory(Buffer, First, sizeof(First) - sizeof(UNICODE_NULL)) ==
|
||||||
|
sizeof(First) - sizeof(UNICODE_NULL),
|
||||||
|
"Mismatching string: %S (expected : %S)\n", Buffer, First);
|
||||||
|
LocalFree(Buffer);
|
||||||
|
|
||||||
|
Buffer = NULL;
|
||||||
|
Written = FormatMessageW(FORMAT_MESSAGE_FROM_HMODULE | FORMAT_MESSAGE_ALLOCATE_BUFFER,
|
||||||
|
NULL, MSG_SECOND_MESSAGE, 0, (LPWSTR)&Buffer, 0, NULL);
|
||||||
|
ok(Written != 0, "Unexpected error: %lx\n", GetLastError());
|
||||||
|
ok(Buffer != NULL, "No buffer allocated\n");
|
||||||
|
ok(Written == (sizeof(Second) - sizeof(UNICODE_NULL)) / sizeof(WCHAR),
|
||||||
|
"Invalid size: %ld (expected: %d)\n",
|
||||||
|
Written, (sizeof(Second) - sizeof(UNICODE_NULL)) / sizeof(WCHAR));
|
||||||
|
ok(RtlCompareMemory(Buffer, Second, sizeof(Second) - sizeof(UNICODE_NULL)) ==
|
||||||
|
sizeof(Second) - sizeof(UNICODE_NULL),
|
||||||
|
"Mismatching string: %S (expected: %S)\n", Buffer, Second);
|
||||||
|
LocalFree(Buffer);
|
||||||
|
|
||||||
|
Buffer = NULL;
|
||||||
|
Written = FormatMessageW(FORMAT_MESSAGE_FROM_HMODULE | FORMAT_MESSAGE_ALLOCATE_BUFFER,
|
||||||
|
NULL, MSG_SECOND_MESSAGE + 1, 0, (LPWSTR)&Buffer, 0, NULL);
|
||||||
|
ok(Written == 0, "Unexpected success: %ld\n", Written);
|
||||||
|
ok(Buffer == NULL, "Unexpected success: %p\n", Buffer);
|
||||||
|
ok(GetLastError() == 0x13d, "Unexpected error: %lx\n", GetLastError());
|
||||||
|
}
|
14
modules/rostests/apitests/kernel32/FormatMessage.mc
Normal file
14
modules/rostests/apitests/kernel32/FormatMessage.mc
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
MessageIdTypedef=DWORD
|
||||||
|
LanguageNames=(English=0x409:MSG0409)
|
||||||
|
|
||||||
|
MessageId=
|
||||||
|
SymbolicName=MSG_FIRST_MESSAGE
|
||||||
|
Language=English
|
||||||
|
This is a test message.
|
||||||
|
.
|
||||||
|
|
||||||
|
MessageId=
|
||||||
|
SymbolicName=MSG_SECOND_MESSAGE
|
||||||
|
Language=English
|
||||||
|
This is a second test message.
|
||||||
|
.
|
6
modules/rostests/apitests/kernel32/kernel32_apitest.rc
Normal file
6
modules/rostests/apitests/kernel32/kernel32_apitest.rc
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
#define REACTOS_STR_FILE_DESCRIPTION "Kernel32 Regtests"
|
||||||
|
#define REACTOS_STR_INTERNAL_NAME "kernel32_apitest"
|
||||||
|
#define REACTOS_STR_ORIGINAL_FILENAME "kernel32_apitest.exe"
|
||||||
|
#include <reactos/version.rc>
|
||||||
|
|
||||||
|
#include <FormatMessage.rc>
|
|
@ -10,6 +10,7 @@ extern void func_DeviceIoControl(void);
|
||||||
extern void func_dosdev(void);
|
extern void func_dosdev(void);
|
||||||
extern void func_FindActCtxSectionStringW(void);
|
extern void func_FindActCtxSectionStringW(void);
|
||||||
extern void func_FindFiles(void);
|
extern void func_FindFiles(void);
|
||||||
|
extern void func_FormatMessage(void);
|
||||||
extern void func_GetComputerNameEx(void);
|
extern void func_GetComputerNameEx(void);
|
||||||
extern void func_GetCurrentDirectory(void);
|
extern void func_GetCurrentDirectory(void);
|
||||||
extern void func_GetDriveType(void);
|
extern void func_GetDriveType(void);
|
||||||
|
@ -39,6 +40,7 @@ const struct test winetest_testlist[] =
|
||||||
{ "dosdev", func_dosdev },
|
{ "dosdev", func_dosdev },
|
||||||
{ "FindActCtxSectionStringW", func_FindActCtxSectionStringW },
|
{ "FindActCtxSectionStringW", func_FindActCtxSectionStringW },
|
||||||
{ "FindFiles", func_FindFiles },
|
{ "FindFiles", func_FindFiles },
|
||||||
|
{ "FormatMessage", func_FormatMessage },
|
||||||
{ "GetComputerNameEx", func_GetComputerNameEx },
|
{ "GetComputerNameEx", func_GetComputerNameEx },
|
||||||
{ "GetCurrentDirectory", func_GetCurrentDirectory },
|
{ "GetCurrentDirectory", func_GetCurrentDirectory },
|
||||||
{ "GetDriveType", func_GetDriveType },
|
{ "GetDriveType", func_GetDriveType },
|
||||||
|
|
Loading…
Reference in a new issue