ReactOS 0.4.15-dev-8207-gd73a838
GetCurrentDirectory.c File Reference
#include "precomp.h"
Include dependency graph for GetCurrentDirectory.c:

Go to the source code of this file.

Functions

static BOOLEAN CheckBuffer (const VOID *Buffer, SIZE_T Size, UCHAR Value)
 
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 TestGetCurrentDirectoryA (VOID)
 
static VOID TestGetCurrentDirectoryW (VOID)
 
 START_TEST (GetCurrentDirectory)
 

Function Documentation

◆ CheckBuffer()

static BOOLEAN CheckBuffer ( const VOID Buffer,
SIZE_T  Size,
UCHAR  Value 
)
static

Definition at line 12 of file GetCurrentDirectory.c.

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}
#define trace
Definition: atltest.h:70
Definition: bufpool.h:45
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
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
ULONG_PTR SIZE_T
Definition: typedefs.h:80
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
unsigned char UCHAR
Definition: xmlstorage.h:181

Referenced by TestGetCurrentDirectoryA(), and TestGetCurrentDirectoryW().

◆ CheckStringBufferA()

static BOOLEAN CheckStringBufferA ( const VOID Buffer,
SIZE_T  Size,
PCSTR  Expected,
UCHAR  Fill 
)
static

Definition at line 31 of file GetCurrentDirectory.c.

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}
BOOLEAN Expected
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define ok(value,...)
Definition: atltest.h:57
void Fill(HDC hdc, LONG x, LONG y, COLORREF color)
Definition: drawing.cpp:107
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
char CHAR
Definition: xmlstorage.h:175

Referenced by TestGetCurrentDirectoryA().

◆ CheckStringBufferW()

static BOOLEAN CheckStringBufferW ( const VOID Buffer,
SIZE_T  Size,
PCWSTR  Expected,
UCHAR  Fill 
)
static

Definition at line 69 of file GetCurrentDirectory.c.

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}
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by TestGetCurrentDirectoryW().

◆ START_TEST()

START_TEST ( GetCurrentDirectory  )

Definition at line 211 of file GetCurrentDirectory.c.

212{
215}
static VOID TestGetCurrentDirectoryA(VOID)
static VOID TestGetCurrentDirectoryW(VOID)

◆ TestGetCurrentDirectoryA()

static VOID TestGetCurrentDirectoryA ( VOID  )
static

Definition at line 109 of file GetCurrentDirectory.c.

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}
static BOOLEAN CheckBuffer(const VOID *Buffer, SIZE_T Size, UCHAR Value)
static BOOLEAN CheckStringBufferA(const VOID *Buffer, SIZE_T Size, PCSTR Expected, UCHAR Fill)
unsigned char BOOLEAN
#define NULL
Definition: types.h:112
#define MAX_PATH
Definition: compat.h:34
DWORD WINAPI GetCurrentDirectoryA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2146
BOOL WINAPI SetCurrentDirectoryA(IN LPCSTR lpPathName)
Definition: path.c:2206
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
#define RtlFillMemory(Dest, Length, Fill)
Definition: winternl.h:599
DWORD WINAPI GetLastError(void)
Definition: except.c:1042

Referenced by START_TEST().

◆ TestGetCurrentDirectoryW()

static VOID TestGetCurrentDirectoryW ( VOID  )
static

Definition at line 161 of file GetCurrentDirectory.c.

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}
static BOOLEAN CheckStringBufferW(const VOID *Buffer, SIZE_T Size, PCWSTR Expected, UCHAR Fill)
#define GetCurrentDirectoryW(x, y)
Definition: compat.h:756
BOOL WINAPI SetCurrentDirectoryW(IN LPCWSTR lpPathName)
Definition: path.c:2249
#define L(x)
Definition: ntvdm.h:50

Referenced by START_TEST().