diff --git a/modules/rostests/apitests/kernel32/CMakeLists.txt b/modules/rostests/apitests/kernel32/CMakeLists.txt index 8ff3f8627be..36e806021fa 100644 --- a/modules/rostests/apitests/kernel32/CMakeLists.txt +++ b/modules/rostests/apitests/kernel32/CMakeLists.txt @@ -17,6 +17,7 @@ list(APPEND SOURCE GetCPInfo.c GetCurrentDirectory.c GetDriveType.c + GetLocaleInfo.c GetModuleFileName.c GetVolumeInformation.c InitOnce.c diff --git a/modules/rostests/apitests/kernel32/GetLocaleInfo.c b/modules/rostests/apitests/kernel32/GetLocaleInfo.c new file mode 100644 index 00000000000..29e0b375a93 --- /dev/null +++ b/modules/rostests/apitests/kernel32/GetLocaleInfo.c @@ -0,0 +1,90 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: GPLv2+ - See COPYING in the top level directory + * PURPOSE: Test for GetLocaleInfo(Ex) + * PROGRAMMER: Timo Kreuzer + */ + +#include "precomp.h" + +typedef +int +WINAPI +FN_GetLocaleInfoEx( + _In_opt_ LPCWSTR lpLocaleName, + _In_ LCTYPE LCType, + _Out_opt_ LPWSTR lpLCData, + _In_ int cchData); + +FN_GetLocaleInfoEx* pGetLocaleInfoEx = NULL; + +static void Test_GetLocaleInfoEx(void) +{ + HMODULE hmodKernel32; + int Ret; + ULONG CodePage; + + hmodKernel32 = GetModuleHandleW(L"kernel32.dll"); + pGetLocaleInfoEx = (FN_GetLocaleInfoEx*)GetProcAddress(hmodKernel32, "GetLocaleInfoEx"); + if (pGetLocaleInfoEx == NULL) + { + hmodKernel32 = LoadLibraryW(L"kernel32_vista.dll"); + pGetLocaleInfoEx = (FN_GetLocaleInfoEx*)GetProcAddress(hmodKernel32, "GetLocaleInfoEx"); + if (pGetLocaleInfoEx == NULL) + { + skip("GetLocaleInfoEx not found in kernel32.dll\n"); + return; + } + } + + // Test normal usage + Ret = pGetLocaleInfoEx(L"en-US", + LOCALE_IDEFAULTANSICODEPAGE | LOCALE_RETURN_NUMBER, + (WCHAR*)&CodePage, + sizeof(DWORD) / sizeof(WCHAR)); + ok_eq_int(Ret, 2); + ok_eq_long(CodePage, 1252ul); + + // Test with neutral locale + Ret = pGetLocaleInfoEx(L"en", + LOCALE_IDEFAULTANSICODEPAGE | LOCALE_RETURN_NUMBER, + NULL, + 0); + ok_eq_int(Ret, 2); + ok_eq_long(CodePage, 1252ul); + + // Test with NULL locale name + CodePage = 0xdeadbeef; + Ret = pGetLocaleInfoEx(NULL, + LOCALE_IDEFAULTANSICODEPAGE | LOCALE_RETURN_NUMBER, + (WCHAR *)&CodePage, + sizeof(DWORD) /sizeof(WCHAR)); + ok_eq_int(Ret, 2); + ok_eq_long(CodePage, 1252ul); + + // Test with empty locale name + CodePage = 0xdeadbeef; + Ret = pGetLocaleInfoEx(L"", + LOCALE_IDEFAULTANSICODEPAGE | LOCALE_RETURN_NUMBER, + (WCHAR *)&CodePage, + sizeof(DWORD) /sizeof(WCHAR)); + ok_eq_int(Ret, 2); + ok_eq_long(CodePage, 1252ul); + + // Test with invalid locale name + CodePage = 0xdeadbeef; + Ret = pGetLocaleInfoEx(L"invalid", + LOCALE_IDEFAULTANSICODEPAGE | LOCALE_RETURN_NUMBER, + (WCHAR *)&CodePage, + sizeof(DWORD) /sizeof(WCHAR)); + ok_eq_int(Ret, 0); + ok_eq_long(GetLastError(), (ULONG)ERROR_INVALID_PARAMETER); + ok(CodePage == 0xdeadbeef, "CodePage should not have been modified: %lx\n", CodePage); + +} + +#undef GetLocaleInfo +START_TEST(GetLocaleInfo) +{ + Test_GetLocaleInfoEx(); +} diff --git a/modules/rostests/apitests/kernel32/testlist.c b/modules/rostests/apitests/kernel32/testlist.c index e2e1735456f..c0cba1ba2f5 100644 --- a/modules/rostests/apitests/kernel32/testlist.c +++ b/modules/rostests/apitests/kernel32/testlist.c @@ -17,6 +17,7 @@ extern void func_GetComputerNameEx(void); extern void func_GetCPInfo(void); extern void func_GetCurrentDirectory(void); extern void func_GetDriveType(void); +extern void func_GetLocaleInfo(void); extern void func_GetModuleFileName(void); extern void func_GetVolumeInformation(void); extern void func_InitOnce(void); @@ -57,6 +58,7 @@ const struct test winetest_testlist[] = { "GetCPInfo", func_GetCPInfo }, { "GetCurrentDirectory", func_GetCurrentDirectory }, { "GetDriveType", func_GetDriveType }, + { "GetLocaleInfo", func_GetLocaleInfo }, { "GetModuleFileName", func_GetModuleFileName }, { "GetVolumeInformation", func_GetVolumeInformation }, { "InitOnce", func_InitOnce },