ReactOS  0.4.15-dev-1207-g698a8e6
SetCurrentDirectory.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 SetCurrentDirectory
5  * PROGRAMMER: Thomas Faber <thomas.faber@reactos.org>
6  */
7 
8 #include "precomp.h"
9 
10 static
11 VOID
13 {
15  BOOL Ret;
16 
17  GetWindowsDirectoryW(Buffer, sizeof(Buffer) / sizeof(WCHAR));
19  ok(Ret == TRUE, "SetCurrentDirectoryW failed\n");
20 }
21 
22 static
23 VOID
25 {
26  BOOL Ret;
28  DWORD Length;
29 
31 
32  Ret = SetCurrentDirectoryA("C:\\");
33  ok(Ret == TRUE, "SetCurrentDirectoryA failed\n");
35  ok(Length == 3, "Length = %lu\n", Length);
36  ok(!strcmp(Buffer, "C:\\"), "Current directory is %s\n", Buffer);
37 
38  /* Same directory - succeeds */
39  Ret = SetCurrentDirectoryA("C:\\");
40  ok(Ret == TRUE, "SetCurrentDirectoryA failed\n");
42  ok(Length == 3, "Length = %lu\n", Length);
43  ok(!strcmp(Buffer, "C:\\"), "Current directory is %s\n", Buffer);
44 
45  /* Same directory, lowercase - succeeds and does not change case */
46  Ret = SetCurrentDirectoryA("c:\\");
47  ok(Ret == TRUE, "SetCurrentDirectoryA failed\n");
49  ok(Length == 3, "Length = %lu\n", Length);
50  ok(!strcmp(Buffer, "C:\\"), "Current directory is %s\n", Buffer);
51 
53 
54  /* Now this one does change case */
55  Ret = SetCurrentDirectoryA("c:\\");
56  ok(Ret == TRUE, "SetCurrentDirectoryA failed\n");
58  ok(Length == 3, "Length = %lu\n", Length);
59  ok(!strcmp(Buffer, "c:\\"), "Current directory is %s\n", Buffer);
60 }
61 
62 static
63 VOID
65 {
66  BOOL Ret;
68  DWORD Length;
69 
71 
72  Ret = SetCurrentDirectoryW(L"C:\\");
73  ok(Ret == TRUE, "SetCurrentDirectoryW failed\n");
74  Length = GetCurrentDirectoryW(sizeof(Buffer) / sizeof(WCHAR), Buffer);
75  ok(Length == 3, "Length = %lu\n", Length);
76  ok(!wcscmp(Buffer, L"C:\\"), "Current directory is %ls\n", Buffer);
77 
78  /* Same directory - succeeds */
79  Ret = SetCurrentDirectoryW(L"C:\\");
80  ok(Ret == TRUE, "SetCurrentDirectoryW failed\n");
81  Length = GetCurrentDirectoryW(sizeof(Buffer) / sizeof(WCHAR), Buffer);
82  ok(Length == 3, "Length = %lu\n", Length);
83  ok(!wcscmp(Buffer, L"C:\\"), "Current directory is %ls\n", Buffer);
84 
85  /* Same directory, lowercase - succeeds and does not change case */
86  Ret = SetCurrentDirectoryW(L"c:\\");
87  ok(Ret == TRUE, "SetCurrentDirectoryW failed\n");
88  Length = GetCurrentDirectoryW(sizeof(Buffer) / sizeof(WCHAR), Buffer);
89  ok(Length == 3, "Length = %lu\n", Length);
90  ok(!wcscmp(Buffer, L"C:\\"), "Current directory is %ls\n", Buffer);
91 
93 
94  /* Now this one does change case */
95  Ret = SetCurrentDirectoryW(L"c:\\");
96  ok(Ret == TRUE, "SetCurrentDirectoryW failed\n");
97  Length = GetCurrentDirectoryW(sizeof(Buffer) / sizeof(WCHAR), Buffer);
98  ok(Length == 3, "Length = %lu\n", Length);
99  ok(!wcscmp(Buffer, L"c:\\"), "Current directory is %ls\n", Buffer);
100 }
101 
103 {
106 }
START_TEST(SetCurrentDirectory)
#define TRUE
Definition: types.h:120
char CHAR
Definition: xmlstorage.h:175
#define GetCurrentDirectoryW(x, y)
Definition: compat.h:615
UINT WINAPI GetWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2351
unsigned int BOOL
Definition: ntddk_ex.h:94
Definition: bufpool.h:45
__wchar_t WCHAR
Definition: xmlstorage.h:180
static VOID TestSetCurrentDirectoryW(VOID)
#define MAX_PATH
Definition: compat.h:34
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 SetCurrentDirectoryA(IN LPCSTR lpPathName)
Definition: path.c:2205
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
static VOID TestSetCurrentDirectoryA(VOID)
BOOL WINAPI SetCurrentDirectoryW(IN LPCWSTR lpPathName)
Definition: path.c:2248
#define ok(value,...)
Definition: atltest.h:57
DWORD WINAPI GetCurrentDirectoryA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2145
static VOID SetUnrelatedDirectory(VOID)
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define SetCurrentDirectory
Definition: winbase.h:3743