ReactOS  0.4.15-dev-1201-gb2cf5a4
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 
13 struct test_data {
17  int line;
18 } test_entries[] = {
19 
20  /* NULL in UNICODE_STRING */
22 
23  /* Length tests */
24  MakeTestEntry_Success( L"", 0 ),
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 
88 int num_tests = sizeof(test_entries) / sizeof(struct test_data);
89 
91 {
92  ULONG len;
94  NTSTATUS res;
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 }
#define MakeTestEntry_Success(str, expect)
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
uint16_t * PWSTR
Definition: typedefs.h:56
LONG NTSTATUS
Definition: precomp.h:26
#define StartSeh()
Definition: _sntprintf.h:16
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
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
static const WCHAR L[]
Definition: oid.c:1250
START_TEST(RtlGetLengthWithoutTrailingPathSeperators)
GLenum GLsizei len
Definition: glext.h:6722
#define ok(value,...)
Definition: atltest.h:57
GLuint res
Definition: glext.h:9613
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
return STATUS_SUCCESS
Definition: btrfs.c:3014
NTSYSAPI NTSTATUS NTAPI RtlGetLengthWithoutTrailingPathSeperators(_Reserved_ ULONG Flags, _In_ PCUNICODE_STRING PathString, _Out_ PULONG Length)
#define EndSeh(ExpectedStatus)
Definition: _sntprintf.h:17
struct test_data test_entries[]