ReactOS 0.4.15-dev-7834-g00c4b3d
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
16 OUT PULONG LengthOut);
17
18
19typedef 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{
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}
NTSTATUS NTAPI RtlGetLengthWithoutLastFullDosOrNtPathElement(IN ULONG Flags, IN PCUNICODE_STRING Path, OUT PULONG LengthOut)
Definition: path.c:496
struct _rtl_test_data rtl_test_data
PRTL_UNICODE_STRING_BUFFER Path
#define ok_hex(expression, result)
Definition: atltest.h:94
#define ok(value,...)
Definition: atltest.h:57
#define START_TEST(x)
Definition: atltest.h:75
#define ok_int(expression, result)
Definition: atltest.h:134
LONG NTSTATUS
Definition: precomp.h:26
#define NULL
Definition: types.h:112
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
Status
Definition: gdiplustypes.h:25
GLdouble n
Definition: glext.h:7729
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
#define L(x)
Definition: ntvdm.h:50
#define STATUS_SUCCESS
Definition: shellext.h:65
uint32_t * PULONG
Definition: typedefs.h:59
#define NTAPI
Definition: typedefs.h:36
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185