ReactOS 0.4.16-dev-1484-g212a1a5
RtlLocale.c File Reference
#include "precomp.h"
#include <winnls.h>
Include dependency graph for RtlLocale.c:

Go to the source code of this file.

Classes

struct  _LCID_TEST_ENTRY
 

Macros

#define FL_LOCALE   0x00000001
 
#define FL_CULTURE   0x00000002
 
#define FL_BOTH   0x00000003
 
#define FL_ALT_NAME   0x00000004
 
#define TEST(Lcid, CultureName, Flags)   { __LINE__, Lcid, CultureName, Flags }
 

Typedefs

typedef NTSTATUS NTAPI FN_RtlConvertLCIDToString(_In_ LCID LcidValue, _In_ ULONG Base, _In_ ULONG Padding, _Out_writes_(Size) PWSTR pResultBuf, _In_ ULONG Size)
 
typedef BOOLEAN NTAPI FN_RtlCultureNameToLCID(_In_ PUNICODE_STRING String, _Out_ PLCID Lcid)
 
typedef BOOLEAN NTAPI FN_RtlLCIDToCultureName(_In_ LCID Lcid, _Inout_ PUNICODE_STRING String)
 
typedef NTSTATUS NTAPI FN_RtlLcidToLocaleName(_In_ LCID Lcid, _Inout_ PUNICODE_STRING LocaleName, _In_ ULONG Flags, _In_ BOOLEAN AllocateDestinationString)
 
typedef NTSTATUS NTAPI FN_RtlLocaleNameToLcid(_In_ PWSTR LocaleName, _Out_ PLCID Lcid, _In_ ULONG Flags)
 
typedef struct _LCID_TEST_ENTRY LCID_TEST_ENTRY
 

Functions

static BOOLEAN Init (void)
 
static void Test_RtlCultureNameToLCID (void)
 
static void Test_RtlLCIDToCultureName (void)
 
static void Test_RtlLocaleNameToLcid (void)
 
static void Test_RtlLcidToLocaleName (void)
 
 START_TEST (RtlLocale)
 

Variables

FN_RtlConvertLCIDToStringpRtlConvertLCIDToString
 
FN_RtlCultureNameToLCIDpRtlCultureNameToLCID
 
FN_RtlLCIDToCultureNamepRtlLCIDToCultureName
 
FN_RtlLcidToLocaleNamepRtlLcidToLocaleName
 
FN_RtlLocaleNameToLcidpRtlLocaleNameToLcid
 
static LCID_TEST_ENTRY Tests []
 

Macro Definition Documentation

◆ FL_ALT_NAME

#define FL_ALT_NAME   0x00000004

Definition at line 61 of file RtlLocale.c.

◆ FL_BOTH

#define FL_BOTH   0x00000003

Definition at line 60 of file RtlLocale.c.

◆ FL_CULTURE

#define FL_CULTURE   0x00000002

Definition at line 59 of file RtlLocale.c.

◆ FL_LOCALE

#define FL_LOCALE   0x00000001

Definition at line 58 of file RtlLocale.c.

◆ TEST

#define TEST (   Lcid,
  CultureName,
  Flags 
)    { __LINE__, Lcid, CultureName, Flags }

Definition at line 71 of file RtlLocale.c.

Typedef Documentation

◆ FN_RtlConvertLCIDToString

typedef NTSTATUS NTAPI FN_RtlConvertLCIDToString(_In_ LCID LcidValue, _In_ ULONG Base, _In_ ULONG Padding, _Out_writes_(Size) PWSTR pResultBuf, _In_ ULONG Size)

Definition at line 14 of file RtlLocale.c.

◆ FN_RtlCultureNameToLCID

typedef BOOLEAN NTAPI FN_RtlCultureNameToLCID(_In_ PUNICODE_STRING String, _Out_ PLCID Lcid)

Definition at line 24 of file RtlLocale.c.

◆ FN_RtlLCIDToCultureName

typedef BOOLEAN NTAPI FN_RtlLCIDToCultureName(_In_ LCID Lcid, _Inout_ PUNICODE_STRING String)

Definition at line 31 of file RtlLocale.c.

◆ FN_RtlLcidToLocaleName

Definition at line 38 of file RtlLocale.c.

◆ FN_RtlLocaleNameToLcid

typedef NTSTATUS NTAPI FN_RtlLocaleNameToLcid(_In_ PWSTR LocaleName, _Out_ PLCID Lcid, _In_ ULONG Flags)

Definition at line 47 of file RtlLocale.c.

◆ LCID_TEST_ENTRY

Function Documentation

◆ Init()

static BOOLEAN Init ( void  )
static

Definition at line 586 of file RtlLocale.c.

587{
588 HMODULE hmod = GetModuleHandleA("ntdll.dll");
589
590 // Initialize function pointers
601 {
602 skip("Function not found\n");
603 return FALSE;
604 }
605
606 return TRUE;
607}
NTSTATUS NTAPI FN_RtlLocaleNameToLcid(_In_ PWSTR LocaleName, _Out_ PLCID Lcid, _In_ ULONG Flags)
Definition: RtlLocale.c:47
FN_RtlConvertLCIDToString * pRtlConvertLCIDToString
Definition: RtlLocale.c:52
BOOLEAN NTAPI FN_RtlCultureNameToLCID(_In_ PUNICODE_STRING String, _Out_ PLCID Lcid)
Definition: RtlLocale.c:24
NTSTATUS NTAPI FN_RtlConvertLCIDToString(_In_ LCID LcidValue, _In_ ULONG Base, _In_ ULONG Padding, _Out_writes_(Size) PWSTR pResultBuf, _In_ ULONG Size)
Definition: RtlLocale.c:14
BOOLEAN NTAPI FN_RtlLCIDToCultureName(_In_ LCID Lcid, _Inout_ PUNICODE_STRING String)
Definition: RtlLocale.c:31
FN_RtlLCIDToCultureName * pRtlLCIDToCultureName
Definition: RtlLocale.c:54
FN_RtlCultureNameToLCID * pRtlCultureNameToLCID
Definition: RtlLocale.c:53
NTSTATUS NTAPI FN_RtlLcidToLocaleName(_In_ LCID Lcid, _Inout_ PUNICODE_STRING LocaleName, _In_ ULONG Flags, _In_ BOOLEAN AllocateDestinationString)
Definition: RtlLocale.c:38
FN_RtlLocaleNameToLcid * pRtlLocaleNameToLcid
Definition: RtlLocale.c:56
FN_RtlLcidToLocaleName * pRtlLcidToLocaleName
Definition: RtlLocale.c:55
#define skip(...)
Definition: atltest.h:64
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define GetProcAddress(x, y)
Definition: compat.h:753
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
static PEXPLICIT_ACCESSW *static HMODULE hmod
Definition: security.c:143

Referenced by START_TEST().

◆ START_TEST()

START_TEST ( RtlLocale  )

Definition at line 1033 of file RtlLocale.c.

1034{
1035 if (!Init())
1036 {
1037 return;
1038 }
1039
1044}
static BOOLEAN Init(void)
Definition: RtlLocale.c:586
static void Test_RtlCultureNameToLCID(void)
Definition: RtlLocale.c:609
static void Test_RtlLocaleNameToLcid(void)
Definition: RtlLocale.c:753
static void Test_RtlLcidToLocaleName(void)
Definition: RtlLocale.c:872
static void Test_RtlLCIDToCultureName(void)
Definition: RtlLocale.c:693

◆ Test_RtlCultureNameToLCID()

static void Test_RtlCultureNameToLCID ( void  )
static

Definition at line 609 of file RtlLocale.c.

610{
611 UNICODE_STRING CultureName;
612 WCHAR Buffer[100];
613 BOOLEAN Result, ExpectedResult;;
614 LCID Lcid, ExpectedLcid;
615
616 // Test valid CultureName
617 Lcid = 0xDEADBEEF;
618 RtlInitUnicodeString(&CultureName, L"en-US");
619 Result = pRtlCultureNameToLCID(&CultureName, &Lcid);
621 ok_eq_hex(Lcid, 0x0409);
622
623 // Test wrongly capatalized CultureName
624 Lcid = 0xDEADBEEF;
625 RtlInitUnicodeString(&CultureName, L"eN-uS");
626 Result = pRtlCultureNameToLCID(&CultureName, &Lcid);
628 ok_eq_hex(Lcid, 0x0409);
629
630 // Test not nullterminated buffer
631 Lcid = 0xDEADBEEF;
632 wcscpy(Buffer, L"en-US");
633 RtlInitUnicodeString(&CultureName, Buffer);
634 Buffer[5] = L'X';
635 Result = pRtlCultureNameToLCID(&CultureName, &Lcid);
637 ok_eq_hex(Lcid, 0x0409);
638
639 // Test NULL Lcid
640 Lcid = 0xDEADBEEF;
641 RtlInitUnicodeString(&CultureName, L"en-US");
642 Result = pRtlCultureNameToLCID(&CultureName, NULL);
644 ok_eq_hex(Lcid, 0xDEADBEEF);
645
646 // Test NULL CultureName
647 Lcid = 0xDEADBEEF;
650 ok_eq_hex(Lcid, 0xDEADBEEF);
651
652 // Test NULL CultureName buffer
653 Lcid = 0xDEADBEEF;
654 RtlInitEmptyUnicodeString(&CultureName, NULL, 0);
655 Result = pRtlCultureNameToLCID(&CultureName, &Lcid);
657 ok_eq_hex(Lcid, 0xDEADBEEF);
658
659 // Test empty CultureName
660 Lcid = 0xDEADBEEF;
661 RtlInitUnicodeString(&CultureName, L"");
662 Result = pRtlCultureNameToLCID(&CultureName, &Lcid);
664 ok_eq_hex(Lcid, 0xDEADBEEF);
665
666 // Test invalid CultureName
667 Lcid = 0xDEADBEEF;
668 RtlInitUnicodeString(&CultureName, L"en-UX");
669 Result = pRtlCultureNameToLCID(&CultureName, &Lcid);
671 ok_eq_hex(Lcid, 0xDEADBEEF);
672
673 // Process the test entries
674 for (ULONG i = 0; i < ARRAYSIZE(Tests); i++)
675 {
676 ExpectedResult = (Tests[i].Flags & FL_CULTURE) ? TRUE : FALSE;
677 ExpectedLcid = (Tests[i].Flags & FL_CULTURE) ? Tests[i].Lcid : 0xDEADBEEF;
678
679 RtlInitUnicodeString(&CultureName, Tests[i].CultureName);
680 Lcid = 0xDEADBEEF;
681 Result = pRtlCultureNameToLCID(&CultureName, &Lcid);
682 ok(Result == ExpectedResult,
683 "Line %lu: Result = %u, expected %u failed\n",
684 Tests[i].Line,
685 Result,
686 ExpectedResult);
687 ok(Lcid == ExpectedLcid,
688 "Line %lu: Lcid = 0x%08lX, expected 0x%08lX\n",
689 Tests[i].Line, Lcid, Tests[i].Lcid);
690 }
691}
unsigned char BOOLEAN
static LCID_TEST_ENTRY Tests[]
Definition: RtlLocale.c:77
#define FL_CULTURE
Definition: RtlLocale.c:59
#define ok_eq_hex(value, expected)
Definition: apitest.h:62
#define ok_eq_bool(value, expected)
Definition: apitest.h:65
#define ok(value,...)
Definition: atltest.h:57
Definition: bufpool.h:45
wcscpy
#define NULL
Definition: types.h:112
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define L(x)
Definition: resources.c:13
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
DWORD LCID
Definition: nls.h:13
Definition: ncftp.h:79
ULONG Flags
Definition: RtlLocale.c:68
uint32_t ULONG
Definition: typedefs.h:59
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409
_In_ CONST DEVPROPKEY _In_ LCID Lcid
Definition: iofuncs.h:2415
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by START_TEST().

◆ Test_RtlLCIDToCultureName()

static void Test_RtlLCIDToCultureName ( void  )
static

Definition at line 693 of file RtlLocale.c.

694{
695 UNICODE_STRING CultureName, ExpectedCultureName;
696 WCHAR Buffer[100];
697 BOOLEAN Result, ExpectedResult, Equal;
698
699 // Test NULL CultureName
702
703 // Test NULL CultureName buffer
704 RtlInitEmptyUnicodeString(&CultureName, NULL, 0);
705 Result = pRtlLCIDToCultureName(0x0409, &CultureName);
707
708 // Test 0 sized CultureName buffer
709 RtlInitEmptyUnicodeString(&CultureName, Buffer, 0);
710 Result = pRtlLCIDToCultureName(0x0409, &CultureName);
712
713 // Test too small CultureName buffer
714 RtlInitEmptyUnicodeString(&CultureName, Buffer, 10);
715 Result = pRtlLCIDToCultureName(0x0409, &CultureName);
717
718 // Test valid CultureName buffer
719 RtlInitEmptyUnicodeString(&CultureName, Buffer, 12);
720 Result = pRtlLCIDToCultureName(0x0409, &CultureName);
722 ok_eq_wstr(CultureName.Buffer, L"en-US");
723
724 // Test invalid LCID
725 RtlInitEmptyUnicodeString(&CultureName, Buffer, 12);
726 Result = pRtlLCIDToCultureName(0x0469, &CultureName);
728
729 // Process the test entries
730 for (ULONG i = 0; i < ARRAYSIZE(Tests); i++)
731 {
732 if (Tests[i].Flags & FL_ALT_NAME)
733 {
734 continue;
735 }
736
737 ExpectedResult = (Tests[i].Flags & FL_CULTURE) ? TRUE : FALSE;
738 RtlInitEmptyUnicodeString(&CultureName, Buffer, sizeof(Buffer));
739 RtlInitUnicodeString(&ExpectedCultureName, Tests[i].CultureName);
740 Result = pRtlLCIDToCultureName(Tests[i].Lcid, &CultureName);
741 ok(Result == ExpectedResult,
742 "Line %lu, Lcid 0x%lx: Result == %u, expected %u\n",
743 Tests[i].Line, Tests[i].Lcid, Result, ExpectedResult);
744 if (Result)
745 {
746 Equal = RtlEqualUnicodeString(&CultureName, &ExpectedCultureName, FALSE);
747 ok(Equal, "Line %lu, Lcid 0x%lx: CultureName = '%wZ', expected '%wZ'\n",
748 Tests[i].Line, Tests[i].Lcid, &CultureName, &ExpectedCultureName);
749 }
750 }
751}
#define FL_ALT_NAME
Definition: RtlLocale.c:61
#define ok_eq_wstr(value, expected)
Definition: apitest.h:69
NTSYSAPI BOOLEAN NTAPI RtlEqualUnicodeString(PUNICODE_STRING String1, PUNICODE_STRING String2, BOOLEAN CaseInSensitive)
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170

Referenced by START_TEST().

◆ Test_RtlLcidToLocaleName()

static void Test_RtlLcidToLocaleName ( void  )
static

Definition at line 872 of file RtlLocale.c.

873{
874 UNICODE_STRING LocaleName, ExpectedLocaleName;
875 WCHAR Buffer[100];
876 NTSTATUS Status, ExpectedStatus;
877 BOOLEAN Equal;
878 LCID Lcid;
879
880 // Test valid parameters
881 RtlInitEmptyUnicodeString(&LocaleName, Buffer, sizeof(Buffer));
884 ok(memcmp(Buffer, L"en-US", 12) == 0, "Expected null-terminated 'en-US', got %wZ\n", &LocaleName);
885
886 // Test invalid LCIDs
891
892 // Test reserved LCID
895
896 // Test NULL LocaleName
897 Status = pRtlLcidToLocaleName(0x0409, NULL, 0, FALSE);
899
900 // Test NULL LocaleName buffer
901 RtlInitEmptyUnicodeString(&LocaleName, NULL, 0);
904
905 // Test invalid buffer size
906 RtlInitEmptyUnicodeString(&LocaleName, Buffer, sizeof(Buffer));
907 LocaleName.Length = sizeof(Buffer) + 8;
910
911 // Test flags
920 Status = pRtlLcidToLocaleName(0x0409, &LocaleName, 0x08000000, FALSE); // LOCALE_ALLOW_NEUTRAL_NAMES
922
923 // Test invalid LCID and NULL buffer
924 RtlInitEmptyUnicodeString(&LocaleName, NULL, 0);
927
928 // Test reserved LCID and NULL buffer
931
932 // Test reserved LCID and invalid flags
933 RtlInitEmptyUnicodeString(&LocaleName, Buffer, sizeof(Buffer));
936
937 // Test invalid flags and NULL buffer
938 RtlInitEmptyUnicodeString(&LocaleName, NULL, 0);
941
942 // Test 0 sized LocaleName buffer
943 RtlInitEmptyUnicodeString(&LocaleName, Buffer, 0);
946
947 // Test too small LocaleName buffer
948 RtlInitEmptyUnicodeString(&LocaleName, Buffer, 10);
949 Buffer[0] = L'@';
952 ok(Buffer[0] == L'@', "Buffer should not be modified\n");
953
954 // Test LOCALE_INVARIANT (0x007F)
955 RtlInitEmptyUnicodeString(&LocaleName, Buffer, sizeof(Buffer));
958 ok(Buffer[0] == L'\0', "Buffer should be empty\n");
959
960 // Test LOCALE_USER_DEFAULT (0x0400)
966
967 // Test LOCALE_SYSTEM_DEFAULT (0x0800)
973
974 // Test LOCALE_CUSTOM_DEFAULT (0x0C00)
977
978 // Test LOCALE_CUSTOM_UNSPECIFIED (0x1000)
983
984 // Test LOCALE_CUSTOM_UI_DEFAULT (0x1400)
989
990 // Test LOCALE_CUSTOM_UNSPECIFIED (0x1000)
993
994 // Process the test entries
995 for (ULONG i = 0; i < ARRAYSIZE(Tests); i++)
996 {
997 if (Tests[i].Flags & FL_ALT_NAME)
998 {
999 continue;
1000 }
1001
1002 RtlInitEmptyUnicodeString(&LocaleName, Buffer, sizeof(Buffer));
1003 RtlInitUnicodeString(&ExpectedLocaleName, Tests[i].CultureName);
1004
1005 /* First test with Flags == 0 */
1008 ok(Status == ExpectedStatus,
1009 "Line %lu, Lcid 0x%lx: Status == 0x%lx, expected 0x%lx\n",
1010 Tests[i].Line, Tests[i].Lcid, Status, ExpectedStatus);
1011 if (NT_SUCCESS(Status))
1012 {
1013 Equal = RtlEqualUnicodeString(&LocaleName, &ExpectedLocaleName, TRUE);
1014 ok(Equal, "Line %lu, Lcid 0x%lx: LocaleName == '%wZ', expected '%wZ'\n",
1015 Tests[i].Line, Tests[i].Lcid, &LocaleName, &ExpectedLocaleName);
1016 }
1017
1018 /* Test with Flags == 2 */
1021 ok(Status == ExpectedStatus,
1022 "Line %lu, Lcid 0x%lx: Status == 0x%lx, expected 0x%lx\n",
1023 Tests[i].Line, Tests[i].Lcid, Status, ExpectedStatus);
1024 if (NT_SUCCESS(Status))
1025 {
1026 Equal = RtlEqualUnicodeString(&LocaleName, &ExpectedLocaleName, FALSE);
1027 ok(Equal, "Line %lu, Lcid 0x%lx: LocaleName == '%wZ', expected '%wZ'\n",
1028 Tests[i].Line, Tests[i].Lcid, &LocaleName, &ExpectedLocaleName);
1029 }
1030 }
1031}
static _In_ LPCWSTR LocaleName
#define FL_BOTH
Definition: RtlLocale.c:60
#define FL_LOCALE
Definition: RtlLocale.c:58
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define ok_ntstatus(status, expected)
Definition: atltest.h:135
LONG NTSTATUS
Definition: precomp.h:26
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
LCID WINAPI GetUserDefaultLCID(void)
Definition: locale.c:1216
LCID WINAPI GetSystemDefaultLCID(void)
Definition: locale.c:1235
Status
Definition: gdiplustypes.h:25
#define LOCALE_CUSTOM_UNSPECIFIED
#define LOCALE_USER_DEFAULT
#define LOCALE_INVARIANT
#define LOCALE_CUSTOM_DEFAULT
#define LOCALE_SYSTEM_DEFAULT
#define LOCALE_CUSTOM_UI_DEFAULT
#define STATUS_INVALID_PARAMETER_2
Definition: ntstatus.h:476
#define STATUS_INVALID_PARAMETER_1
Definition: ntstatus.h:475
#define STATUS_INVALID_PARAMETER_3
Definition: ntstatus.h:477
#define STATUS_SUCCESS
Definition: shellext.h:65
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132

Referenced by START_TEST().

◆ Test_RtlLocaleNameToLcid()

static void Test_RtlLocaleNameToLcid ( void  )
static

Definition at line 753 of file RtlLocale.c.

754{
755 LCID Lcid;
756 NTSTATUS Status, ExpectedStatus;
757 LCID ExpectedLcid;
758
759 // Test valid LocaleName
760 Lcid = 0xDEADBEEF;
761 Status = pRtlLocaleNameToLcid(L"en-US", &Lcid, 0);
763 ok_eq_hex(Lcid, 0x0409);
764
765 // Test wrongly capatalized LocaleName
766 Lcid = 0xDEADBEEF;
767 Status = pRtlLocaleNameToLcid(L"eN-uS", &Lcid, 0);
769 ok_eq_hex(Lcid, 0x0409);
770
771 // Test extended unicode chars
772 Lcid = 0xDEADBEEF;
773 Status = pRtlLocaleNameToLcid(L"\x1165n-US", &Lcid, 0);
775 ok_eq_hex(Lcid, 0xDEADBEEF);
776
777 // Test NULL LocaleName (aka LOCALE_NAME_USER_DEFAULT)
778 Lcid = 0xDEADBEEF;
781 ok_eq_hex(Lcid, 0xDEADBEEF);
782
783 // Test empty LocaleName (aka LOCALE_NAME_INVARIANT)
784 Lcid = 0xDEADBEEF;
788
789 // Test LOCALE_NAME_SYSTEM_DEFAULT
790 Lcid = 0xDEADBEEF;
791 Status = pRtlLocaleNameToLcid(L"!sys-default-locale", &Lcid, 0);
793 ok_eq_hex(Lcid, 0xDEADBEEF);
794
795 // Test invalid LocaleName
796 Lcid = 0xDEADBEEF;
797 Status = pRtlLocaleNameToLcid(L"en-UX", &Lcid, 0);
799 ok_eq_hex(Lcid, 0xDEADBEEF);
800
801 // Test NULL Lcid
802 Lcid = 0xDEADBEEF;
803 Status = pRtlLocaleNameToLcid(L"en-US", NULL, 0);
805 ok_eq_hex(Lcid, 0xDEADBEEF);
806
807 // Test flags
808 Status = pRtlLocaleNameToLcid(L"en-US", &Lcid, 0x1);
810 Status = pRtlLocaleNameToLcid(L"en-US", &Lcid, 0x2);
812 Status = pRtlLocaleNameToLcid(L"en-US", &Lcid, 0x3);
814 Status = pRtlLocaleNameToLcid(L"en-US", &Lcid, 0x4);
816 Status = pRtlLocaleNameToLcid(L"en-US", &Lcid, 0x8);
818
819 // Test NULL LocaleName and NULL Lcid
820 Lcid = 0xDEADBEEF;
823 ok_eq_hex(Lcid, 0xDEADBEEF);
824
825 // Test invalid LocaleName and NULL Lcid
826 Lcid = 0xDEADBEEF;
827 Status = pRtlLocaleNameToLcid(L"en-UX", NULL, 0);
829 ok_eq_hex(Lcid, 0xDEADBEEF);
830
831 // Test NULL Lcid and invalid flags
832 Lcid = 0xDEADBEEF;
833 Status = pRtlLocaleNameToLcid(L"en-US", NULL, 0x8);
835 ok_eq_hex(Lcid, 0xDEADBEEF);
836
837 // Test empty LocaleName
838 Lcid = 0xDEADBEEF;
841 ok_eq_hex(Lcid, 0x7F);
842
843 // Process the test entries
844 for (ULONG i = 0; i < ARRAYSIZE(Tests); i++)
845 {
846 // No flags
848 ExpectedLcid = (Tests[i].Flags & FL_LOCALE) ? Tests[i].Lcid : 0xDEADBEEF;
849 Lcid = 0xDEADBEEF;
850 Status = pRtlLocaleNameToLcid((PWSTR)Tests[i].CultureName, &Lcid, 0);
851 ok(Status == ExpectedStatus,
852 "Line %lu: Status == 0x%lx, expected 0x%lx\n",
853 Tests[i].Line, Status, ExpectedStatus);
854 ok(Lcid == ExpectedLcid,
855 "Line %lu: Lcid == 0x%08X, expected 0x%08X\n",
856 Tests[i].Line, Lcid, ExpectedLcid);
857
858 // Flags = 0x2
860 ExpectedLcid = (Tests[i].Flags & FL_BOTH) ? Tests[i].Lcid : 0xDEADBEEF;
861 Lcid = 0xDEADBEEF;
862 Status = pRtlLocaleNameToLcid((PWSTR)Tests[i].CultureName, &Lcid, 0x2);
863 ok(Status == ExpectedStatus,
864 "Line %lu: Status == 0x%lx, expected 0x%lx\n",
865 Tests[i].Line, Status, ExpectedStatus);
866 ok(Lcid == ExpectedLcid,
867 "Line %lu: Lcid == 0x%08X, expected 0x%08X\n",
868 Tests[i].Line, Lcid, ExpectedLcid);
869 }
870}
uint16_t * PWSTR
Definition: typedefs.h:56

Referenced by START_TEST().

Variable Documentation

◆ pRtlConvertLCIDToString

FN_RtlConvertLCIDToString* pRtlConvertLCIDToString

Definition at line 52 of file RtlLocale.c.

Referenced by Init().

◆ pRtlCultureNameToLCID

FN_RtlCultureNameToLCID* pRtlCultureNameToLCID

Definition at line 53 of file RtlLocale.c.

Referenced by Init(), and Test_RtlCultureNameToLCID().

◆ pRtlLCIDToCultureName

FN_RtlLCIDToCultureName* pRtlLCIDToCultureName

Definition at line 54 of file RtlLocale.c.

Referenced by Init(), and Test_RtlLCIDToCultureName().

◆ pRtlLcidToLocaleName

FN_RtlLcidToLocaleName* pRtlLcidToLocaleName

Definition at line 55 of file RtlLocale.c.

Referenced by Init(), and Test_RtlLcidToLocaleName().

◆ pRtlLocaleNameToLcid

FN_RtlLocaleNameToLcid* pRtlLocaleNameToLcid

Definition at line 56 of file RtlLocale.c.

Referenced by Init(), Test_RtlLcidToLocaleName(), and Test_RtlLocaleNameToLcid().

◆ Tests