mirror of
https://github.com/reactos/reactos.git
synced 2024-12-04 08:53:32 +08:00
[NTDLL_APITEST] Add a test for RtlValidateUnicodeString().
This commit is contained in:
parent
0d745e0698
commit
ae8c9a1fa2
@ -65,6 +65,7 @@ list(APPEND SOURCE
|
||||
RtlReAllocateHeap.c
|
||||
RtlUnicodeStringToAnsiString.c
|
||||
RtlUpcaseUnicodeStringToCountedOemString.c
|
||||
RtlValidateUnicodeString.c
|
||||
StackOverflow.c
|
||||
SystemInfo.c
|
||||
Timer.c
|
||||
|
105
modules/rostests/apitests/ntdll/RtlValidateUnicodeString.c
Normal file
105
modules/rostests/apitests/ntdll/RtlValidateUnicodeString.c
Normal file
@ -0,0 +1,105 @@
|
||||
/*
|
||||
* PROJECT: ReactOS API Tests
|
||||
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
|
||||
* PURPOSE: Test for RtlValidateUnicodeString
|
||||
* COPYRIGHT: Copyright 2020 Hermes Belusca-Maito
|
||||
*/
|
||||
|
||||
#include "precomp.h"
|
||||
|
||||
START_TEST(RtlValidateUnicodeString)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
UNICODE_STRING String;
|
||||
UNICODE_STRING ValidString = RTL_CONSTANT_STRING(L"My Wild String!");
|
||||
|
||||
/* Start with a valid Unicode string */
|
||||
String = ValidString;
|
||||
|
||||
/* Non-zero flags are unsupported! */
|
||||
Status = RtlValidateUnicodeString(0, &String);
|
||||
ok(Status == STATUS_SUCCESS, "Status = 0x%lx\n", Status);
|
||||
Status = RtlValidateUnicodeString(1, &String);
|
||||
ok(Status == STATUS_INVALID_PARAMETER, "Status = 0x%lx\n", Status);
|
||||
Status = RtlValidateUnicodeString(0xdeadbeef, &String);
|
||||
ok(Status == STATUS_INVALID_PARAMETER, "Status = 0x%lx\n", Status);
|
||||
|
||||
/* Empty string is allowed. Test also the flags. */
|
||||
RtlInitEmptyUnicodeString(&String, NULL, 0);
|
||||
Status = RtlValidateUnicodeString(0, &String);
|
||||
ok(Status == STATUS_SUCCESS, "Status = 0x%lx\n", Status);
|
||||
Status = RtlValidateUnicodeString(1, &String);
|
||||
ok(Status == STATUS_INVALID_PARAMETER, "Status = 0x%lx\n", Status);
|
||||
Status = RtlValidateUnicodeString(0xdeadbeef, &String);
|
||||
ok(Status == STATUS_INVALID_PARAMETER, "Status = 0x%lx\n", Status);
|
||||
|
||||
// With a non-NULL but empty buffer, and zero lengths.
|
||||
String.Buffer = L"";
|
||||
Status = RtlValidateUnicodeString(0, &String);
|
||||
ok(Status == STATUS_SUCCESS, "Status = 0x%lx\n", Status);
|
||||
Status = RtlValidateUnicodeString(1, &String);
|
||||
ok(Status == STATUS_INVALID_PARAMETER, "Status = 0x%lx\n", Status);
|
||||
Status = RtlValidateUnicodeString(0xdeadbeef, &String);
|
||||
ok(Status == STATUS_INVALID_PARAMETER, "Status = 0x%lx\n", Status);
|
||||
|
||||
// With a non-NULL but empty buffer, and zero Length, non-zero MaximumLength.
|
||||
String.Buffer = L"";
|
||||
String.Length = 0;
|
||||
Status = RtlValidateUnicodeString(0, &String);
|
||||
ok(Status == STATUS_SUCCESS, "Status = 0x%lx\n", Status);
|
||||
Status = RtlValidateUnicodeString(1, &String);
|
||||
ok(Status == STATUS_INVALID_PARAMETER, "Status = 0x%lx\n", Status);
|
||||
Status = RtlValidateUnicodeString(0xdeadbeef, &String);
|
||||
ok(Status == STATUS_INVALID_PARAMETER, "Status = 0x%lx\n", Status);
|
||||
|
||||
/* NULL pointer is also allowed! Test also the flags. */
|
||||
Status = RtlValidateUnicodeString(0, NULL);
|
||||
ok(Status == STATUS_SUCCESS, "Status = 0x%lx\n", Status);
|
||||
Status = RtlValidateUnicodeString(1, NULL);
|
||||
ok(Status == STATUS_INVALID_PARAMETER, "Status = 0x%lx\n", Status);
|
||||
Status = RtlValidateUnicodeString(0xdeadbeef, NULL);
|
||||
ok(Status == STATUS_INVALID_PARAMETER, "Status = 0x%lx\n", Status);
|
||||
|
||||
|
||||
/*
|
||||
* Now test invalid strings.
|
||||
*/
|
||||
|
||||
// NULL buffer but non-zero lengths.
|
||||
String = ValidString;
|
||||
String.Buffer = NULL;
|
||||
Status = RtlValidateUnicodeString(0, &String);
|
||||
ok(Status == STATUS_INVALID_PARAMETER, "Status = 0x%lx\n", Status);
|
||||
|
||||
// NULL buffer, zero Length, non-zero MaximumLength.
|
||||
String = ValidString;
|
||||
String.Buffer = NULL;
|
||||
String.Length = 0;
|
||||
Status = RtlValidateUnicodeString(0, &String);
|
||||
ok(Status == STATUS_INVALID_PARAMETER, "Status = 0x%lx\n", Status);
|
||||
|
||||
// NULL buffer, non-zero Length, zero MaximumLength.
|
||||
String = ValidString;
|
||||
String.Buffer = NULL;
|
||||
String.MaximumLength = 0;
|
||||
Status = RtlValidateUnicodeString(0, &String);
|
||||
ok(Status == STATUS_INVALID_PARAMETER, "Status = 0x%lx\n", Status);
|
||||
|
||||
// Non-NULL buffer, non-zero Length, zero MaximumLength.
|
||||
String = ValidString;
|
||||
String.MaximumLength = 0;
|
||||
Status = RtlValidateUnicodeString(0, &String);
|
||||
ok(Status == STATUS_INVALID_PARAMETER, "Status = 0x%lx\n", Status);
|
||||
|
||||
/* Non-NULL buffer, odd lengths */
|
||||
|
||||
String = ValidString;
|
||||
String.Length--; // Length was already >= 2 so it remains > 0.
|
||||
Status = RtlValidateUnicodeString(0, &String);
|
||||
ok(Status == STATUS_INVALID_PARAMETER, "Status = 0x%lx\n", Status);
|
||||
|
||||
String = ValidString;
|
||||
String.MaximumLength--; // MaximumLength was already >= 2 so it remains > 0.
|
||||
Status = RtlValidateUnicodeString(0, &String);
|
||||
ok(Status == STATUS_INVALID_PARAMETER, "Status = 0x%lx\n", Status);
|
||||
}
|
@ -64,6 +64,7 @@ extern void func_RtlQueryTimeZoneInformation(void);
|
||||
extern void func_RtlReAllocateHeap(void);
|
||||
extern void func_RtlUnicodeStringToAnsiString(void);
|
||||
extern void func_RtlUpcaseUnicodeStringToCountedOemString(void);
|
||||
extern void func_RtlValidateUnicodeString(void);
|
||||
extern void func_StackOverflow(void);
|
||||
extern void func_TimerResolution(void);
|
||||
|
||||
@ -130,6 +131,7 @@ const struct test winetest_testlist[] =
|
||||
{ "RtlReAllocateHeap", func_RtlReAllocateHeap },
|
||||
{ "RtlUnicodeStringToAnsiString", func_RtlUnicodeStringToAnsiString },
|
||||
{ "RtlUpcaseUnicodeStringToCountedOemString", func_RtlUpcaseUnicodeStringToCountedOemString },
|
||||
{ "RtlValidateUnicodeString", func_RtlValidateUnicodeString },
|
||||
{ "StackOverflow", func_StackOverflow },
|
||||
{ "TimerResolution", func_TimerResolution },
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user