ReactOS  0.4.14-dev-317-g96040ec
FsRtlDissect.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS kernel-mode tests
3  * LICENSE: LGPLv2.1+ - See COPYING.LIB in the top level directory
4  * PURPOSE: Test for FsRtlDissectName/FsRtlDissectDbcs
5  * PROGRAMMER: Thomas Faber <thomas.faber@reactos.org>
6  */
7 
8 #include <kmt_test.h>
9 
10 static struct
11 {
17 } Tests[] =
18 {
19  { NULL, -1, -1 },
20  { "", -1, -1 },
21  { "a", 0, -1, 1, 1 },
22  { "a\\b", 0, 2, 1, 1 },
23  { "a\\", 0, 2, 1, 0 },
24  { "\\b", 1, -1, 1 },
25  { "\\", 1, -1, 0 },
26  { "a\\b\\c", 0, 2, 1, 3 },
27  { "\\a\\b\\c", 1, 3, 1, 3 },
28  /* Forward slashes are not separators */
29  { "/", 0, -1, 1 },
30  { "/a", 0, -1, 2 },
31  { "/a/b", 0, -1, 4 },
32  /* Normal parsing cycle */
33  { "Good Morning!\\Good Evening!\\Good Night", 0, 14, 13, 24 },
34  { "Good Evening!\\Good Night", 0, 14, 13, 10 },
35  { "Good Night", 0, -1, 10 },
36  /* Double backslashes */
37  { "\\\\", 1, 2, 0, 0 },
38  { "a\\\\", 0, 2, 1, 1 },
39  { "\\\\b", 1, 2, 0, 1 },
40  { "a\\\\b", 0, 2, 1, 2 },
41  /* Even more backslashes */
42  { "\\\\\\", 1, 2, 0, 1 },
43  { "a\\\\\\", 0, 2, 1, 2 },
44  { "\\\\\\b", 1, 2, 0, 2 },
45  { "a\\\\\\b", 0, 2, 1, 3 },
46  { "a\\\\\\\\b", 0, 2, 1, 4 },
47 };
48 
49 START_TEST(FsRtlDissect)
50 {
52  ANSI_STRING NameA;
53  ANSI_STRING FirstA;
54  ANSI_STRING RemainingA;
55  UNICODE_STRING NameU;
56  UNICODE_STRING FirstU;
57  UNICODE_STRING RemainingU;
58  ULONG i;
59 
60  for (i = 0; i < RTL_NUMBER_OF(Tests); i++)
61  {
62  RtlInitAnsiString(&NameA, Tests[i].Name);
63  RtlFillMemory(&FirstA, sizeof(FirstA), 0x55);
64  RtlFillMemory(&RemainingA, sizeof(RemainingA), 0x55);
65  FsRtlDissectDbcs(NameA, &FirstA, &RemainingA);
66  if (Tests[i].Offset1 == -1)
67  {
68  ok(FirstA.Buffer == NULL, "[%s] First=%p, expected NULL\n", Tests[i].Name, FirstA.Buffer);
69  ok(FirstA.Length == 0, "[%s] FirstLen=%u, expected 0\n", Tests[i].Name, FirstA.Length);
70  ok(FirstA.MaximumLength == 0, "[%s] FirstMaxLen=%u, expected 0\n", Tests[i].Name, FirstA.MaximumLength);
71  }
72  else
73  {
74  ok(FirstA.Buffer == NameA.Buffer + Tests[i].Offset1, "[%s] First=%p, expected %p\n", Tests[i].Name, FirstA.Buffer, NameA.Buffer + Tests[i].Offset1);
75  ok(FirstA.Length == Tests[i].Length1, "[%s] FirstLen=%u, expected %d\n", Tests[i].Name, FirstA.Length, Tests[i].Length1);
76  ok(FirstA.MaximumLength == Tests[i].Length1, "[%s] FirstMaxLen=%u, expected %d\n", Tests[i].Name, FirstA.MaximumLength, Tests[i].Length1);
77  }
78  if (Tests[i].Offset2 == -1)
79  {
80  ok(RemainingA.Buffer == NULL, "[%s] Remaining=%p, expected NULL\n", Tests[i].Name, RemainingA.Buffer);
81  ok(RemainingA.Length == 0, "[%s] RemainingLen=%u, expected 0\n", Tests[i].Name, RemainingA.Length);
82  ok(RemainingA.MaximumLength == 0, "[%s] RemainingMaxLen=%u, expected 0\n", Tests[i].Name, RemainingA.MaximumLength);
83  }
84  else
85  {
86  ok(RemainingA.Buffer == NameA.Buffer + Tests[i].Offset2, "[%s] Remaining=%p, expected %p\n", Tests[i].Name, RemainingA.Buffer, NameA.Buffer + Tests[i].Offset2);
87  ok(RemainingA.Length == Tests[i].Length2, "[%s] RemainingLen=%u, expected %d\n", Tests[i].Name, RemainingA.Length, Tests[i].Length2);
88  ok(RemainingA.MaximumLength == Tests[i].Length2, "[%s] RemainingMaxLen=%u, expected %d\n", Tests[i].Name, RemainingA.MaximumLength, Tests[i].Length2);
89  }
90 
91  Status = RtlAnsiStringToUnicodeString(&NameU, &NameA, TRUE);
92  if (skip(NT_SUCCESS(Status), "Conversion failed with %lx\n", Status))
93  continue;
94  RtlFillMemory(&FirstU, sizeof(FirstU), 0x55);
95  RtlFillMemory(&RemainingU, sizeof(RemainingU), 0x55);
96  FsRtlDissectName(NameU, &FirstU, &RemainingU);
97  if (Tests[i].Offset1 == -1)
98  {
99  ok(FirstU.Buffer == NULL, "[%s] First=%p, expected NULL\n", Tests[i].Name, FirstU.Buffer);
100  ok(FirstU.Length == 0, "[%s] FirstLen=%u, expected 0\n", Tests[i].Name, FirstU.Length);
101  ok(FirstU.MaximumLength == 0, "[%s] FirstMaxLen=%u, expected 0\n", Tests[i].Name, FirstU.MaximumLength);
102  }
103  else
104  {
105  ok(FirstU.Buffer == NameU.Buffer + Tests[i].Offset1, "[%s] First=%p, expected %p\n", Tests[i].Name, FirstU.Buffer, NameU.Buffer + Tests[i].Offset1);
106  ok(FirstU.Length == Tests[i].Length1 * sizeof(WCHAR), "[%s] FirstLen=%u, expected %d\n", Tests[i].Name, FirstU.Length, Tests[i].Length1 * sizeof(WCHAR));
107  ok(FirstU.MaximumLength == Tests[i].Length1 * sizeof(WCHAR), "[%s] FirstMaxLen=%u, expected %d\n", Tests[i].Name, FirstU.MaximumLength, Tests[i].Length1 * sizeof(WCHAR));
108  }
109  if (Tests[i].Offset2 == -1)
110  {
111  ok(RemainingU.Buffer == NULL, "[%s] Remaining=%p, expected NULL\n", Tests[i].Name, RemainingU.Buffer);
112  ok(RemainingU.Length == 0, "[%s] RemainingLen=%u, expected 0\n", Tests[i].Name, RemainingU.Length);
113  ok(RemainingU.MaximumLength == 0, "[%s] RemainingMaxLen=%u, expected 0\n", Tests[i].Name, RemainingU.MaximumLength);
114  }
115  else
116  {
117  ok(RemainingU.Buffer == NameU.Buffer + Tests[i].Offset2, "[%s] Remaining=%p, expected %p\n", Tests[i].Name, RemainingU.Buffer, NameU.Buffer + Tests[i].Offset2);
118  ok(RemainingU.Length == Tests[i].Length2 * sizeof(WCHAR), "[%s] RemainingLen=%u, expected %d\n", Tests[i].Name, RemainingU.Length, Tests[i].Length2 * sizeof(WCHAR));
119  ok(RemainingU.MaximumLength == Tests[i].Length2 * sizeof(WCHAR), "[%s] RemainingMaxLen=%u, expected %d\n", Tests[i].Name, RemainingU.MaximumLength, Tests[i].Length2 * sizeof(WCHAR));
120  }
121  RtlFreeUnicodeString(&NameU);
122  }
123 }
#define TRUE
Definition: types.h:120
PCSTR Name
Definition: FsRtlDissect.c:12
USHORT MaximumLength
Definition: env_spec_w32.h:370
LONG NTSTATUS
Definition: precomp.h:26
INT Length2
Definition: FsRtlDissect.c:16
int32_t INT
Definition: typedefs.h:56
NTSYSAPI VOID NTAPI RtlInitAnsiString(PANSI_STRING DestinationString, PCSZ SourceString)
INT Length1
Definition: FsRtlDissect.c:15
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
smooth NULL
Definition: ftsmooth.c:416
VOID NTAPI FsRtlDissectDbcs(IN ANSI_STRING Name, OUT PANSI_STRING FirstPart, OUT PANSI_STRING RemainingPart)
Definition: dbcsname.c:45
USHORT MaximumLength
Definition: env_spec_w32.h:377
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
VOID NTAPI FsRtlDissectName(IN UNICODE_STRING Name, OUT PUNICODE_STRING FirstPart, OUT PUNICODE_STRING RemainingPart)
Definition: name.c:398
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
static struct @1588 Tests[]
Status
Definition: gdiplustypes.h:24
#define RTL_NUMBER_OF(x)
Definition: RtlRegistry.c:12
NTSYSAPI NTSTATUS NTAPI RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString, PANSI_STRING SourceString, BOOLEAN AllocateDestinationString)
#define ok(value,...)
Definition: atltest.h:57
START_TEST(FsRtlDissect)
Definition: FsRtlDissect.c:49
INT Offset1
Definition: FsRtlDissect.c:13
#define skip(...)
Definition: atltest.h:64
unsigned int ULONG
Definition: retypes.h:1
const char * PCSTR
Definition: typedefs.h:51
INT Offset2
Definition: FsRtlDissect.c:14
#define RtlFillMemory(Dest, Length, Fill)
Definition: winternl.h:593