ReactOS 0.4.16-dev-334-g4d9f67c
RtlGetLengthWithoutTrailingPathSeperators.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS api tests
3 * LICENSE: GPLv2+ - See COPYING in the top level directory
4 * PURPOSE: Test for RtlGetLengthWithoutTrailingPathSeperators
5 * PROGRAMMER: David Quintana <gigaherz@gmail.com>
6 */
7
8#include "precomp.h"
9
10#define MakeTestEntry_Success(str, expect) \
11 { str, expect, STATUS_SUCCESS, __LINE__ }
12
13struct test_data {
17 int line;
18} test_entries[] = {
19
20 /* NULL in UNICODE_STRING */
22
23 /* Length tests */
25 MakeTestEntry_Success( L"T", 1 ),
26 MakeTestEntry_Success( L"Te", 2 ),
27 MakeTestEntry_Success( L"Tes", 3 ),
28 MakeTestEntry_Success( L"Test", 4 ),
29
30 /* Separators tests */
31 MakeTestEntry_Success( L"\\.", 2 ),
32 MakeTestEntry_Success( L"\\.", 2 ),
33 MakeTestEntry_Success( L"\\.\\", 2 ),
34 MakeTestEntry_Success( L"\\.\\T", 4 ),
35 MakeTestEntry_Success( L"\\.\\Te", 5 ),
36 MakeTestEntry_Success( L"\\.\\Tes", 6 ),
37 MakeTestEntry_Success( L"\\.\\Test", 7 ),
38 MakeTestEntry_Success( L"\\.\\Test\\", 7 ),
39 MakeTestEntry_Success( L"\\.\\Test\\s", 9 ),
40 MakeTestEntry_Success( L"\\.\\T\\est", 8 ),
41 MakeTestEntry_Success( L"\\.\\T\\e\\st", 9 ),
42 MakeTestEntry_Success( L"\\.\\T\\e\\s\\t", 10 ),
43 MakeTestEntry_Success( L"\\.\\T\\e\\s\\t\\", 10 ),
44 MakeTestEntry_Success( L"\\Tests\\String\\", 13 ),
45 MakeTestEntry_Success( L"\\.\\Test\\String\\", 14 ),
46 MakeTestEntry_Success( L"\\.\\Tests\\String\\", 15 ),
47 MakeTestEntry_Success( L"\\.\\Tests\\String\\s", 17 ),
48 MakeTestEntry_Success( L"\\.\\Tests\\String\\as", 18 ),
49 MakeTestEntry_Success( L"\\.\\Tests\\String\\asd", 19 ),
50 MakeTestEntry_Success( L"\\.\\Tests\\String\\asdf", 20 ),
51 MakeTestEntry_Success( L"\\Tests\\String\\sdfsdf\\", 20 ),
52 MakeTestEntry_Success( L"C:\\Tests\\String\\sdfsdf\\", 22 ),
53
54 /* Separator-only tests */
55 MakeTestEntry_Success( L"\\", 0 ),
56 MakeTestEntry_Success( L"/", 0 ),
57
58 /* Mixed separators tests */
59 MakeTestEntry_Success( L"/Test/String", 12 ),
60 MakeTestEntry_Success( L"\\Test/String", 12 ),
61 MakeTestEntry_Success( L"/Test\\String", 12 ),
62 MakeTestEntry_Success( L"\\Test/String", 12 ),
63 MakeTestEntry_Success( L"/Test/String\\", 12 ),
64 MakeTestEntry_Success( L"\\Test/String\\", 12 ),
65 MakeTestEntry_Success( L"/Test\\String\\", 12 ),
66 MakeTestEntry_Success( L"\\Test/String\\", 12 ),
67 MakeTestEntry_Success( L"/Test/String/", 12 ),
68 MakeTestEntry_Success( L"\\Test/String/", 12 ),
69 MakeTestEntry_Success( L"/Test\\String/", 12 ),
70 MakeTestEntry_Success( L"\\Test/String/", 12 ),
71 MakeTestEntry_Success( L"\\Test/String/", 12 ),
72 MakeTestEntry_Success( L"\\Test\\\\String/", 13 ),
73
74 /* Common path formats tests */
75 MakeTestEntry_Success( L"Test\\String", 11 ),
76 MakeTestEntry_Success( L"\\Test\\String", 12 ),
77 MakeTestEntry_Success( L".\\Test\\String", 13 ),
78 MakeTestEntry_Success( L"\\.\\Test\\String", 14 ),
79 MakeTestEntry_Success( L"\\??\\Test\\String", 15 ),
80
81 /* Redundant trailing tests */
82 MakeTestEntry_Success( L"\\??\\Test\\String\\", 15 ),
83 MakeTestEntry_Success( L"\\??\\Test\\String\\\\", 15 ),
84 MakeTestEntry_Success( L"\\??\\Test\\String\\\\\\\\\\", 15 ),
85
86};
87
88int num_tests = sizeof(test_entries) / sizeof(struct test_data);
89
91{
92 ULONG len;
95 int i;
96
97 struct test_data * pentry = test_entries;
98
99 for(i = 0; i < num_tests; i++, pentry++)
100 {
102 &str, pentry->input);
103
104 len = 0xDEADBEEF;
105
106 StartSeh()
109
110 ok(res == pentry->expected_result,
111 "Unexpected result 0x%08lx (expected 0x%08lx) in [%d:%d]\n",
112 res, pentry->expected_result,
113 i, pentry->line);
114 ok(len == pentry->expected_output,
115 "Unexpected length %lu (expected %lu) in [%d:%d]\n",
116 len, pentry->expected_output,
117 i, pentry->line);
118 }
119
120 // Invalid parameters
121
122 len = 0xDEADBEEF;
123
124 StartSeh()
127
129 "Unexpected result 0x%08lx (expected STATUS_INVALID_PARAMETER)\n",
130 res);
131 ok(len == 0,
132 "Unexpected length %08lx (expected 0)\n",
133 len);
134
135 StartSeh()
138
140 "Unexpected result 0x%08lx (expected STATUS_INVALID_PARAMETER)\n",
141 res);
142
143 StartSeh()
146
148 "Unexpected result 0x%08lx (expected STATUS_INVALID_PARAMETER)\n",
149 res);
150
151 for(i = 0; i < 32; i++)
152 {
153 len = 0xDEADBEEF;
154
155 StartSeh()
158
160 "Unexpected result 0x%08lx (expected STATUS_INVALID_PARAMETER)\n",
161 res);
162
163 ok(len == 0,
164 "Unexpected length %08lx (expected 0)\n",
165 len);
166 }
167
168 len = 0xDEADBEEF;
169
170 StartSeh()
173
175 "Unexpected result 0x%08lx (expected STATUS_INVALID_PARAMETER)\n",
176 res);
177
178 ok(len == 0,
179 "Unexpected length %08lx (expected 0)\n",
180 len);
181}
struct test_data test_entries[]
#define MakeTestEntry_Success(str, expect)
#define StartSeh()
Definition: _sntprintf.h:16
#define EndSeh(ExpectedStatus)
Definition: _sntprintf.h:17
#define ok(value,...)
Definition: atltest.h:57
#define START_TEST(x)
Definition: atltest.h:75
LONG NTSTATUS
Definition: precomp.h:26
#define NULL
Definition: types.h:112
GLuint res
Definition: glext.h:9613
GLenum GLsizei len
Definition: glext.h:6722
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
NTSYSAPI NTSTATUS NTAPI RtlGetLengthWithoutTrailingPathSeperators(_Reserved_ ULONG Flags, _In_ PCUNICODE_STRING PathString, _Out_ PULONG Length)
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define L(x)
Definition: ntvdm.h:50
const WCHAR * str
#define STATUS_SUCCESS
Definition: shellext.h:65
uint16_t * PWSTR
Definition: typedefs.h:56
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135