[NTDLL_APITEST] Add tests for RtlxUnicodeStringToAnsiSize & RtlxUnicodeStringToOemSize

CORE-17571
This commit is contained in:
Jérôme Gardou 2021-05-18 23:00:58 +02:00 committed by Jérôme Gardou
parent 50e0b006e7
commit 0a8b51da80
4 changed files with 73 additions and 0 deletions

View file

@ -8,6 +8,7 @@ spec2def(ntdll_apitest.exe ntdll_apitest.spec)
list(APPEND SOURCE
LdrEnumResources.c
load_notifications.c
locale.c
NtAcceptConnectPort.c
NtAllocateVirtualMemory.c
NtApphelpCacheControl.c
@ -81,6 +82,8 @@ list(APPEND SOURCE
RtlUnicodeStringToAnsiString.c
RtlUpcaseUnicodeStringToCountedOemString.c
RtlValidateUnicodeString.c
RtlxUnicodeStringToAnsiSize.c
RtlxUnicodeStringToOemSize.c
StackOverflow.c
SystemInfo.c
Timer.c)

View file

@ -0,0 +1,33 @@
/*
* PROJECT: ReactOS API tests
* LICENSE: 0BSD (https://spdx.org/licenses/0BSD.html)
* PURPOSE: Test for RtlxUnicodeStringToAnsiSize
* COPYRIGHT: Copyright 2021 Jérôme Gardou <jerome.gardou@reactos.org>
*/
#include "precomp.h"
static const struct
{
ULONG AnsiCp;
ULONG OemCp;
PCWSTR Str;
ULONG OemLength;
} TestData[] =
{
{ 1252, 932, L"\u30c7\u30b9\u30af\u30c8\u30c3\u30d7", 7 }, /* "Desktop" in Japanese */
{ 932, 1252, L"\u30c7\u30b9\u30af\u30c8\u30c3\u30d7", 13 }, /* "Desktop" in Japanese */
};
START_TEST(RtlxUnicodeStringToAnsiSize)
{
for (int i = 0; i < _countof(TestData); i++)
{
SetupLocale(TestData[i].AnsiCp, TestData[i].OemCp, -1);
UNICODE_STRING Ustr;
RtlInitUnicodeString(&Ustr, TestData[i].Str);
ULONG Length = RtlxUnicodeStringToAnsiSize(&Ustr);
ok(Length == TestData[i].OemLength, "Wrong OEM length for test %u, expected %u, got %u\n",
i, (UINT)TestData[i].OemLength, (UINT)Length);
}
}

View file

@ -0,0 +1,33 @@
/*
* PROJECT: ReactOS API tests
* LICENSE: 0BSD (https://spdx.org/licenses/0BSD.html)
* PURPOSE: Test for RtlxUnicodeStringToOemSize
* COPYRIGHT: Copyright 2021 Jérôme Gardou <jerome.gardou@reactos.org>
*/
#include "precomp.h"
static const struct
{
ULONG AnsiCp;
ULONG OemCp;
PCWSTR Str;
ULONG OemLength;
} TestData[] =
{
{ 1252, 932, L"\u30c7\u30b9\u30af\u30c8\u30c3\u30d7", 7 }, /* "Desktop" in Japanese */
{ 932, 1252, L"\u30c7\u30b9\u30af\u30c8\u30c3\u30d7", 13 }, /* "Desktop" in Japanese */
};
START_TEST(RtlxUnicodeStringToOemSize)
{
for (int i = 0; i < _countof(TestData); i++)
{
SetupLocale(TestData[i].AnsiCp, TestData[i].OemCp, -1);
UNICODE_STRING Ustr;
RtlInitUnicodeString(&Ustr, TestData[i].Str);
ULONG Length = RtlxUnicodeStringToOemSize(&Ustr);
ok(Length == TestData[i].OemLength, "Wrong OEM length for test %u, expected %u, got %u\n",
i, (UINT)TestData[i].OemLength, (UINT)Length);
}
}

View file

@ -78,6 +78,8 @@ extern void func_RtlReAllocateHeap(void);
extern void func_RtlUnicodeStringToAnsiString(void);
extern void func_RtlUpcaseUnicodeStringToCountedOemString(void);
extern void func_RtlValidateUnicodeString(void);
extern void func_RtlxUnicodeStringToAnsiSize(void);
extern void func_RtlxUnicodeStringToOemSize(void);
extern void func_StackOverflow(void);
extern void func_TimerResolution(void);
@ -155,7 +157,9 @@ const struct test winetest_testlist[] =
{ "RtlpEnsureBufferSize", func_RtlpEnsureBufferSize },
{ "RtlQueryTimeZoneInformation", func_RtlQueryTimeZoneInformation },
{ "RtlReAllocateHeap", func_RtlReAllocateHeap },
{ "RtlUnicodeStringToAnsiSize", func_RtlxUnicodeStringToAnsiSize }, /* For some reason, starting test name with Rtlx hides it */
{ "RtlUnicodeStringToAnsiString", func_RtlUnicodeStringToAnsiString },
{ "RtlUnicodeStringToOemSize", func_RtlxUnicodeStringToOemSize },
{ "RtlUpcaseUnicodeStringToCountedOemString", func_RtlUpcaseUnicodeStringToCountedOemString },
{ "RtlValidateUnicodeString", func_RtlValidateUnicodeString },
{ "StackOverflow", func_StackOverflow },