ReactOS  0.4.14-dev-599-g2d4d3f5
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 }
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2343
#define TRUE
Definition: types.h:120
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
#define trace
Definition: atltest.h:70
unsigned char UCHAR
Definition: xmlstorage.h:181
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
ULONG_PTR SIZE_T
Definition: typedefs.h:78
unsigned int ULONG
Definition: retypes.h:1
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34

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 }
#define TRUE
Definition: types.h:120
void Fill(HDC hdc, LONG x, LONG y, COLORREF color)
Definition: drawing.cpp:109
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char CHAR
Definition: xmlstorage.h:175
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
#define trace
Definition: atltest.h:70
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
unsigned char UCHAR
Definition: xmlstorage.h:181
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
ULONG_PTR SIZE_T
Definition: typedefs.h:78
#define ok(value,...)
Definition: atltest.h:57
unsigned int ULONG
Definition: retypes.h:1
BOOLEAN Expected
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34

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 }
#define TRUE
Definition: types.h:120
void Fill(HDC hdc, LONG x, LONG y, COLORREF color)
Definition: drawing.cpp:109
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
#define trace
Definition: atltest.h:70
__wchar_t WCHAR
Definition: xmlstorage.h:180
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
unsigned char UCHAR
Definition: xmlstorage.h:181
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
ULONG_PTR SIZE_T
Definition: typedefs.h:78
#define ok(value,...)
Definition: atltest.h:57
unsigned int ULONG
Definition: retypes.h:1
BOOLEAN Expected
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

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 {
112  DWORD Length;
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 }
#define TRUE
Definition: types.h:120
static BOOLEAN CheckStringBufferA(const VOID *Buffer, SIZE_T Size, PCSTR Expected, UCHAR Fill)
char CHAR
Definition: xmlstorage.h:175
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
BOOL WINAPI SetCurrentDirectoryA(IN LPCSTR lpPathName)
Definition: path.c:2205
#define ok(value,...)
Definition: atltest.h:57
DWORD WINAPI GetCurrentDirectoryA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2145
static BOOLEAN CheckBuffer(const VOID *Buffer, SIZE_T Size, UCHAR Value)
#define RtlFillMemory(Dest, Length, Fill)
Definition: winternl.h:593

Referenced by START_TEST().

◆ TestGetCurrentDirectoryW()

static VOID TestGetCurrentDirectoryW ( VOID  )
static

Definition at line 161 of file GetCurrentDirectory.c.

162 {
164  DWORD Length;
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 }
#define TRUE
Definition: types.h:120
#define GetCurrentDirectoryW(x, y)
Definition: compat.h:421
static BOOLEAN CheckStringBufferW(const VOID *Buffer, SIZE_T Size, PCWSTR Expected, UCHAR Fill)
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
static const WCHAR L[]
Definition: oid.c:1250
BOOL WINAPI SetCurrentDirectoryW(IN LPCWSTR lpPathName)
Definition: path.c:2248
#define ok(value,...)
Definition: atltest.h:57
static BOOLEAN CheckBuffer(const VOID *Buffer, SIZE_T Size, UCHAR Value)
#define RtlFillMemory(Dest, Length, Fill)
Definition: winternl.h:593

Referenced by START_TEST().