ReactOS 0.4.15-dev-7924-g5949c20
GetCurrentDirectory.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 GetCurrentDirectory
5 * PROGRAMMER: Thomas Faber <thomas.faber@reactos.org>
6 */
7
8#include "precomp.h"
9
10static
13 const VOID *Buffer,
16{
17 const UCHAR *Array = Buffer;
18 SIZE_T i;
19
20 for (i = 0; i < Size; i++)
21 if (Array[i] != Value)
22 {
23 trace("Expected %x, found %x at offset %lu\n", Value, Array[i], (ULONG)i);
24 return FALSE;
25 }
26 return TRUE;
27}
28
29static
32 const VOID *Buffer,
35 UCHAR Fill)
36{
37 const CHAR *Chars = Buffer;
38 const UCHAR *UChars = Buffer;
40 SIZE_T i;
41
42 if (Size < Length)
43 {
44 ok(0, "Size = %lu, Length = %lu\n", (ULONG)Size, (ULONG)Length);
45 return FALSE;
46 }
47
48 for (i = 0; i < Length; i++)
49 if (Chars[i] != Expected[i])
50 {
51 trace("Expected %x, found %x at offset %lu\n", Expected[i], Chars[i], (ULONG)i);
52 return FALSE;
53 }
54
55 ok(Chars[i] == 0, "Expected null terminator, found %x at offset %lu\n", Chars[i], (ULONG)i);
56 i++;
57
58 for (; i < Size; i++)
59 if (UChars[i] != Fill)
60 {
61 trace("Expected %x, found %x at offset %lu\n", Fill, UChars[i], (ULONG)i);
62 return FALSE;
63 }
64 return TRUE;
65}
66
67static
70 const VOID *Buffer,
73 UCHAR Fill)
74{
75 const WCHAR *Chars = Buffer;
76 const UCHAR *UChars = Buffer;
78 SIZE_T i;
79
80 if (Size < Length)
81 {
82 ok(0, "Size = %lu, Length = %lu\n", (ULONG)Size, (ULONG)Length);
83 return FALSE;
84 }
85
86 for (i = 0; i < Length; i++)
87 if (Chars[i] != Expected[i])
88 {
89 trace("Expected %x, found %x at offset %lu\n", Expected[i], Chars[i], (ULONG)i);
90 return FALSE;
91 }
92
93 ok(Chars[i] == 0, "Expected null terminator, found %x at offset %lu\n", Chars[i], (ULONG)i);
94 i++;
95
96 i *= sizeof(WCHAR);
97
98 for (; i < Size; i++)
99 if (UChars[i] != Fill)
100 {
101 trace("Expected %x, found %x at offset %lu\n", Fill, UChars[i], (ULONG)i);
102 return FALSE;
103 }
104 return TRUE;
105}
106
107static
108VOID
110{
113 BOOL Ret;
114 BOOLEAN Okay;
115
116 Ret = SetCurrentDirectoryA("C:\\");
117 ok(Ret == TRUE, "SetCurrentDirectory failed with %lu\n", GetLastError());
118
120 ok(Length == sizeof("C:\\"), "Length = %lu\n", Length);
121
122 RtlFillMemory(Buffer, sizeof(Buffer), 0x55);
124 ok(Length == sizeof("C:\\") - 1, "Length = %lu\n", Length);
125 Okay = CheckStringBufferA(Buffer, sizeof(Buffer), "C:\\", 0x55);
126 ok(Okay, "CheckStringBufferA failed\n");
127
128 RtlFillMemory(Buffer, sizeof(Buffer), 0x55);
130 ok(Length == sizeof("C:\\"), "Length = %lu\n", Length);
131 Okay = CheckBuffer(Buffer, sizeof(Buffer), 0x55);
132 ok(Okay, "CheckBuffer failed\n");
133
134 RtlFillMemory(Buffer, sizeof(Buffer), 0x55);
136 ok(Length == sizeof("C:\\"), "Length = %lu\n", Length);
137 Okay = CheckBuffer(Buffer, sizeof(Buffer), 0x55);
138 ok(Okay, "CheckBuffer failed\n");
139
140 RtlFillMemory(Buffer, sizeof(Buffer), 0x55);
142 ok(Length == sizeof("C:\\"), "Length = %lu\n", Length);
143 Okay = CheckBuffer(Buffer, sizeof(Buffer), 0x55);
144 ok(Okay, "CheckBuffer failed\n");
145
146 RtlFillMemory(Buffer, sizeof(Buffer), 0x55);
148 ok(Length == sizeof("C:\\"), "Length = %lu\n", Length);
149 Okay = CheckBuffer(Buffer, sizeof(Buffer), 0x55);
150 ok(Okay, "CheckBuffer failed\n");
151
152 RtlFillMemory(Buffer, sizeof(Buffer), 0x55);
154 ok(Length == sizeof("C:\\") - 1, "Length = %lu\n", Length);
155 Okay = CheckStringBufferA(Buffer, sizeof(Buffer), "C:\\", 0x55);
156 ok(Okay, "CheckStringBufferA failed\n");
157}
158
159static
160VOID
162{
165 BOOL Ret;
166 BOOLEAN Okay;
167
168 Ret = SetCurrentDirectoryW(L"C:\\");
169 ok(Ret == TRUE, "SetCurrentDirectory failed with %lu\n", GetLastError());
170
172 ok(Length == sizeof("C:\\"), "Length = %lu\n", Length);
173
174 RtlFillMemory(Buffer, sizeof(Buffer), 0x55);
175 Length = GetCurrentDirectoryW(sizeof(Buffer) / sizeof(WCHAR), Buffer);
176 ok(Length == sizeof("C:\\") - 1, "Length = %lu\n", Length);
177 Okay = CheckStringBufferW(Buffer, sizeof(Buffer), L"C:\\", 0x55);
178 ok(Okay, "CheckStringBufferW failed\n");
179
180 RtlFillMemory(Buffer, sizeof(Buffer), 0x55);
182 ok(Length == sizeof("C:\\"), "Length = %lu\n", Length);
183 Okay = CheckBuffer(Buffer, sizeof(Buffer), 0x55);
184 ok(Okay, "CheckBuffer failed\n");
185
186 RtlFillMemory(Buffer, sizeof(Buffer), 0x55);
188 ok(Length == sizeof("C:\\"), "Length = %lu\n", Length);
189 Okay = CheckBuffer(Buffer, sizeof(Buffer), 0x55);
190 ok(Okay, "CheckBuffer failed\n");
191
192 RtlFillMemory(Buffer, sizeof(Buffer), 0x55);
194 ok(Length == sizeof("C:\\"), "Length = %lu\n", Length);
195 Okay = CheckBuffer(Buffer, sizeof(Buffer), 0x55);
196 ok(Okay, "CheckBuffer failed\n");
197
198 RtlFillMemory(Buffer, sizeof(Buffer), 0x55);
200 ok(Length == sizeof("C:\\"), "Length = %lu\n", Length);
201 Okay = CheckBuffer(Buffer, sizeof(Buffer), 0x55);
202 ok(Okay, "CheckBuffer failed\n");
203
204 RtlFillMemory(Buffer, sizeof(Buffer), 0x55);
206 ok(Length == sizeof("C:\\") - 1, "Length = %lu\n", Length);
207 Okay = CheckStringBufferW(Buffer, sizeof(Buffer), L"C:\\", 0x55);
208 ok(Okay, "CheckStringBufferW failed\n");
209}
210
212{
215}
BOOLEAN Expected
static BOOLEAN CheckBuffer(const VOID *Buffer, SIZE_T Size, UCHAR Value)
static VOID TestGetCurrentDirectoryA(VOID)
static BOOLEAN CheckStringBufferA(const VOID *Buffer, SIZE_T Size, PCSTR Expected, UCHAR Fill)
static BOOLEAN CheckStringBufferW(const VOID *Buffer, SIZE_T Size, PCWSTR Expected, UCHAR Fill)
static VOID TestGetCurrentDirectoryW(VOID)
unsigned char BOOLEAN
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define trace
Definition: atltest.h:70
#define ok(value,...)
Definition: atltest.h:57
#define START_TEST(x)
Definition: atltest.h:75
Definition: bufpool.h:45
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define GetCurrentDirectoryW(x, y)
Definition: compat.h:756
#define MAX_PATH
Definition: compat.h:34
DWORD WINAPI GetCurrentDirectoryA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2146
BOOL WINAPI SetCurrentDirectoryW(IN LPCWSTR lpPathName)
Definition: path.c:2249
BOOL WINAPI SetCurrentDirectoryA(IN LPCSTR lpPathName)
Definition: path.c:2206
void Fill(HDC hdc, LONG x, LONG y, COLORREF color)
Definition: drawing.cpp:107
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
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
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define RtlFillMemory(Dest, Length, Fill)
Definition: winternl.h:599
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
#define L(x)
Definition: ntvdm.h:50
const uint16_t * PCWSTR
Definition: typedefs.h:57
ULONG_PTR SIZE_T
Definition: typedefs.h:80
const char * PCSTR
Definition: typedefs.h:52
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define GetCurrentDirectory
Definition: winbase.h:3805
unsigned char UCHAR
Definition: xmlstorage.h:181
__wchar_t WCHAR
Definition: xmlstorage.h:180
char CHAR
Definition: xmlstorage.h:175