ReactOS  0.4.15-dev-3173-g40ee59d
RtlGetLengthWithoutLastFullDosOrNtPathElement.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS API Tests
3  * LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
4  * PURPOSE: Test for RtlGetLengthWithoutLastFullDosOrNtPathElement
5  * COPYRIGHT: Copyright 2021 Mark Jansen <mark.jansen@reactos.org>
6  */
7 
8 #include "precomp.h"
9 
10 
12 NTAPI
14  IN ULONG Flags,
16  OUT PULONG LengthOut);
17 
18 
19 typedef struct _rtl_test_data
20 {
25 
26 // Based on http://undoc.airesoft.co.uk/ntdll.dll/RtlGetLengthWithoutLastFullDosOrNtPathElement.php
28  { L"", 0, STATUS_SUCCESS, },
29  { L"C", 0, STATUS_INVALID_PARAMETER, },
30  { L"C:", 0, STATUS_INVALID_PARAMETER, },
31  { L"C:\\", 0, STATUS_SUCCESS, },
32  { L"C:\\test", 3, STATUS_SUCCESS, },
33  { L"C:\\test\\", 3, STATUS_SUCCESS, },
34  { L"C:\\test\\a", 8, STATUS_SUCCESS, },
35  { L"C:\\test\\a\\", 8, STATUS_SUCCESS, },
36  { L"C://test", 3, STATUS_SUCCESS, },
37  { L"C://test\\", 3, STATUS_SUCCESS, },
38  { L"C://test\\\\", 3, STATUS_SUCCESS, },
39  { L"C://test/", 3, STATUS_SUCCESS, },
40  { L"C://test//", 3, STATUS_SUCCESS, },
41  { L"C://test\\a", 9, STATUS_SUCCESS, },
42  { L"C://test\\\\a", 9, STATUS_SUCCESS, },
43  { L"C://test/a", 9, STATUS_SUCCESS, },
44  { L"C://test//a", 9, STATUS_SUCCESS, },
45  { L"C://test\\a\\", 9, STATUS_SUCCESS, },
46  { L"C://test//a//", 9, STATUS_SUCCESS, },
47  { L"C://test//a/", 9, STATUS_SUCCESS, },
48  { L"X", 0, STATUS_INVALID_PARAMETER, },
49  { L"X:", 0, STATUS_INVALID_PARAMETER, },
50  { L"X:\\", 0, STATUS_SUCCESS, },
51  { L"D:\\Test\\hello.ext", 8, STATUS_SUCCESS, },
52  { L"\\\\?\\C", 0, STATUS_INVALID_PARAMETER, },
53  { L"\\\\?\\C:", 0, STATUS_INVALID_PARAMETER, },
54  { L"\\\\?\\CC", 0, STATUS_INVALID_PARAMETER, },
55  { L"\\\\?\\C:\\", 4, STATUS_SUCCESS, },
56  { L"\\\\?\\::\\", 4, STATUS_SUCCESS, },
57  { L"\\\\?\\CCC", 0, STATUS_INVALID_PARAMETER, },
58  { L"\\\\?\\CCC\\", 0, STATUS_INVALID_PARAMETER, },
59  { L"\\??\\UNC\\Mytest", 8, STATUS_SUCCESS, },
60  { L"\\SystemRoot", 0, STATUS_SUCCESS, },
61  { L"\\SystemRoot\\", 0, STATUS_SUCCESS, },
62  { L"\\SystemRoot\\ntdll.dll", 12, STATUS_SUCCESS, },
63  { L"\\Device\\HarddiskVolume9000", 8, STATUS_SUCCESS, },
64  { L"\\Stuff\\doesnt\\really\\matter", 21, STATUS_SUCCESS, },
65  { L"this\\doesnt\\really\\work", 0, STATUS_INVALID_PARAMETER, },
66  { L"multi(0)disk(0)rdisk(0)partition(1)", 0, STATUS_INVALID_PARAMETER, },
67  { L"multi(0)disk(0)rdisk(0)partition(1)\\test", 0, STATUS_INVALID_PARAMETER, },
68  { L"xyz", 0, STATUS_INVALID_PARAMETER, },
69  { L"CON", 0, STATUS_INVALID_PARAMETER, },
70  { L":", 0, STATUS_INVALID_PARAMETER, },
71  { L"\\\\", 0, STATUS_SUCCESS, },
72 };
73 
74 
76 {
77  UNICODE_STRING Dum;
79  ULONG Length;
80  RtlInitUnicodeString(&Dum, L"c:\\test\\");
81 
82  Length = 333;
84  ok_int(Length, 0);
86 
89 
90  for (ULONG n = 0; n < 32; ++n)
91  {
92  Length = 333;
94  ok_int(Length, 0);
96  }
97 
98  for (ULONG n = 0; n < ARRAYSIZE(tests); ++n)
99  {
101  Length = 333;
102 
104 
106  ok(Status == tests[n].Status, "Got Status=0x%lx, expected 0x%lx (%S)\n", Status, tests[n].Status, Str.Buffer);
107  ok(Length == tests[n].Length, "Got Length=0x%lx, expected 0x%lx (%S)\n", Length, tests[n].Length, Str.Buffer);
108  }
109 }
#define IN
Definition: typedefs.h:39
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
GLdouble n
Definition: glext.h:7729
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
struct _rtl_test_data rtl_test_data
#define ok_hex(expression, result)
Definition: atltest.h:94
START_TEST(RtlGetLengthWithoutLastFullDosOrNtPathElement)
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
#define ok_int(expression, result)
Definition: atltest.h:134
Status
Definition: gdiplustypes.h:24
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
static const WCHAR L[]
Definition: oid.c:1250
PRTL_UNICODE_STRING_BUFFER Path
#define ok(value,...)
Definition: atltest.h:57
unsigned int * PULONG
Definition: retypes.h:1
NTSTATUS NTAPI RtlGetLengthWithoutLastFullDosOrNtPathElement(IN ULONG Flags, IN PCUNICODE_STRING Path, OUT PULONG LengthOut)
Definition: path.c:496
#define NULL
Definition: types.h:112
#define OUT
Definition: typedefs.h:40
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define STATUS_SUCCESS
Definition: shellext.h:65