https://git.reactos.org/?p=reactos.git;a=commitdiff;h=0a8b51da8044cd84a41a6…
commit 0a8b51da8044cd84a41a647407848d74690e9467
Author: Jérôme Gardou <jerome.gardou(a)reactos.org>
AuthorDate: Tue May 18 23:00:58 2021 +0200
Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com>
CommitDate: Wed May 19 22:50:29 2021 +0200
[NTDLL_APITEST] Add tests for RtlxUnicodeStringToAnsiSize &
RtlxUnicodeStringToOemSize
CORE-17571
---
modules/rostests/apitests/ntdll/CMakeLists.txt | 3 ++
.../apitests/ntdll/RtlxUnicodeStringToAnsiSize.c | 33 ++++++++++++++++++++++
.../apitests/ntdll/RtlxUnicodeStringToOemSize.c | 33 ++++++++++++++++++++++
modules/rostests/apitests/ntdll/testlist.c | 4 +++
4 files changed, 73 insertions(+)
diff --git a/modules/rostests/apitests/ntdll/CMakeLists.txt
b/modules/rostests/apitests/ntdll/CMakeLists.txt
index 85dba02c31d..d1e4499fb68 100644
--- a/modules/rostests/apitests/ntdll/CMakeLists.txt
+++ b/modules/rostests/apitests/ntdll/CMakeLists.txt
@@ -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)
diff --git a/modules/rostests/apitests/ntdll/RtlxUnicodeStringToAnsiSize.c
b/modules/rostests/apitests/ntdll/RtlxUnicodeStringToAnsiSize.c
new file mode 100644
index 00000000000..5caeea2346c
--- /dev/null
+++ b/modules/rostests/apitests/ntdll/RtlxUnicodeStringToAnsiSize.c
@@ -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(a)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);
+ }
+}
diff --git a/modules/rostests/apitests/ntdll/RtlxUnicodeStringToOemSize.c
b/modules/rostests/apitests/ntdll/RtlxUnicodeStringToOemSize.c
new file mode 100644
index 00000000000..354b64562fd
--- /dev/null
+++ b/modules/rostests/apitests/ntdll/RtlxUnicodeStringToOemSize.c
@@ -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(a)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);
+ }
+}
diff --git a/modules/rostests/apitests/ntdll/testlist.c
b/modules/rostests/apitests/ntdll/testlist.c
index 141a1305f61..78a8af20a05 100644
--- a/modules/rostests/apitests/ntdll/testlist.c
+++ b/modules/rostests/apitests/ntdll/testlist.c
@@ -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 },