ReactOS 0.4.16-dev-1561-gba36b90
GetLocaleInfo.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 GetLocaleInfo(Ex)
5 * PROGRAMMER: Timo Kreuzer <timo.kreuzer@reactos.org>
6 */
7
8#include "precomp.h"
9
10typedef
11int
14 _In_opt_ LPCWSTR lpLocaleName,
15 _In_ LCTYPE LCType,
16 _Out_opt_ LPWSTR lpLCData,
17 _In_ int cchData);
18
20
21static void Test_GetLocaleInfoEx(void)
22{
23 HMODULE hmodKernel32;
24 int Ret;
25 ULONG CodePage;
26
27 hmodKernel32 = GetModuleHandleW(L"kernel32.dll");
28 pGetLocaleInfoEx = (FN_GetLocaleInfoEx*)GetProcAddress(hmodKernel32, "GetLocaleInfoEx");
30 {
31 hmodKernel32 = LoadLibraryW(L"kernel32_vista.dll");
32 pGetLocaleInfoEx = (FN_GetLocaleInfoEx*)GetProcAddress(hmodKernel32, "GetLocaleInfoEx");
34 {
35 skip("GetLocaleInfoEx not found in kernel32.dll\n");
36 return;
37 }
38 }
39
40 // Test normal usage
41 Ret = pGetLocaleInfoEx(L"en-US",
42 LOCALE_IDEFAULTANSICODEPAGE | LOCALE_RETURN_NUMBER,
43 (WCHAR*)&CodePage,
44 sizeof(DWORD) / sizeof(WCHAR));
45 ok_eq_int(Ret, 2);
46 ok_eq_long(CodePage, 1252ul);
47
48 // Test with neutral locale
49 Ret = pGetLocaleInfoEx(L"en",
50 LOCALE_IDEFAULTANSICODEPAGE | LOCALE_RETURN_NUMBER,
51 NULL,
52 0);
53 ok_eq_int(Ret, 2);
54 ok_eq_long(CodePage, 1252ul);
55
56 // Test with NULL locale name
57 CodePage = 0xdeadbeef;
59 LOCALE_IDEFAULTANSICODEPAGE | LOCALE_RETURN_NUMBER,
60 (WCHAR *)&CodePage,
61 sizeof(DWORD) /sizeof(WCHAR));
62 ok_eq_int(Ret, 2);
63 ok_eq_long(CodePage, 1252ul);
64
65 // Test with empty locale name
66 CodePage = 0xdeadbeef;
67 Ret = pGetLocaleInfoEx(L"",
68 LOCALE_IDEFAULTANSICODEPAGE | LOCALE_RETURN_NUMBER,
69 (WCHAR *)&CodePage,
70 sizeof(DWORD) /sizeof(WCHAR));
71 ok_eq_int(Ret, 2);
72 ok_eq_long(CodePage, 1252ul);
73
74 // Test with invalid locale name
75 CodePage = 0xdeadbeef;
76 Ret = pGetLocaleInfoEx(L"invalid",
77 LOCALE_IDEFAULTANSICODEPAGE | LOCALE_RETURN_NUMBER,
78 (WCHAR *)&CodePage,
79 sizeof(DWORD) /sizeof(WCHAR));
80 ok_eq_int(Ret, 0);
82 ok(CodePage == 0xdeadbeef, "CodePage should not have been modified: %lx\n", CodePage);
83
84}
85
86#undef GetLocaleInfo
88{
90}
int WINAPI FN_GetLocaleInfoEx(_In_opt_ LPCWSTR lpLocaleName, _In_ LCTYPE LCType, _Out_opt_ LPWSTR lpLCData, _In_ int cchData)
Definition: GetLocaleInfo.c:13
FN_GetLocaleInfoEx * pGetLocaleInfoEx
Definition: GetLocaleInfo.c:19
static void Test_GetLocaleInfoEx(void)
Definition: GetLocaleInfo.c:21
#define ok_eq_long(value, expected)
Definition: apitest.h:47
#define ok_eq_int(value, expected)
Definition: apitest.h:45
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
#define START_TEST(x)
Definition: atltest.h:75
#define NULL
Definition: types.h:112
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define GetProcAddress(x, y)
Definition: compat.h:753
#define LoadLibraryW(x)
Definition: compat.h:747
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
#define L(x)
Definition: resources.c:13
unsigned long DWORD
Definition: ntddk_ex.h:95
#define _Out_opt_
Definition: no_sal2.h:214
#define _In_
Definition: no_sal2.h:158
#define _In_opt_
Definition: no_sal2.h:212
uint32_t ULONG
Definition: typedefs.h:59
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define WINAPI
Definition: msvc.h:6
#define GetLocaleInfo
Definition: winnls.h:1289
#define LOCALE_IDEFAULTANSICODEPAGE
Definition: winnls.h:45
DWORD LCTYPE
Definition: winnls.h:537
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185