Commit d4f13811 authored by Rolf Kalbermatter's avatar Rolf Kalbermatter Committed by Alexandre Julliard

Added a few todo_wine tests with filenames with wildcards.

parent 55bcaec4
......@@ -192,6 +192,22 @@ static void test_CreateDirectoryA(void)
ret = RemoveDirectoryA(tmpdir);
ok(ret == TRUE, "RemoveDirectoryA should always succeed");
todo_wine {
lstrcatA(tmpdir, "?");
ret = CreateDirectoryA(tmpdir, NULL);
ok(ret == FALSE && GetLastError() == ERROR_INVALID_NAME,
"CreateDirectoryA with ? wildcard name should fail, ret=%s error=%ld",
ret ? " True" : "False", GetLastError());
ret = RemoveDirectoryA(tmpdir);
tmpdir[lstrlenA(tmpdir) - 1] = '*';
ret = CreateDirectoryA(tmpdir, NULL);
ok(ret == FALSE && GetLastError() == ERROR_INVALID_NAME,
"CreateDirectoryA with * wildcard name should fail, ret=%s error=%ld",
ret ? " True" : "False", GetLastError());
ret = RemoveDirectoryA(tmpdir);
}
}
static void test_CreateDirectoryW(void)
......@@ -202,6 +218,7 @@ static void test_CreateDirectoryW(void)
static const WCHAR tmp_dir_name[] = {'P','l','e','a','s','e',' ','R','e','m','o','v','e',' ','M','e',0};
static const WCHAR dotW[] = {'.',0};
static const WCHAR dotdotW[] = {'.','.',0};
static const WCHAR questionW[] = {'?',0};
ret = CreateDirectoryW(NULL, NULL);
if (!ret && GetLastError()==ERROR_CALL_NOT_IMPLEMENTED)
......@@ -238,6 +255,81 @@ static void test_CreateDirectoryW(void)
ret = RemoveDirectoryW(tmpdir);
ok(ret == TRUE, "RemoveDirectoryW should always succeed");
todo_wine {
lstrcatW(tmpdir, questionW);
ret = CreateDirectoryW(tmpdir, NULL);
ok(ret == FALSE && GetLastError() == ERROR_INVALID_NAME,
"CreateDirectoryW with ? wildcard name should fail with error 183, ret=%s error=%ld",
ret ? " True" : "False", GetLastError());
ret = RemoveDirectoryW(tmpdir);
tmpdir[lstrlenW(tmpdir) - 1] = '*';
ret = CreateDirectoryW(tmpdir, NULL);
ok(ret == FALSE && GetLastError() == ERROR_INVALID_NAME,
"CreateDirectoryW with * wildcard name should fail with error 183, ret=%s error=%ld",
ret ? " True" : "False", GetLastError());
ret = RemoveDirectoryW(tmpdir);
}
}
static void test_RemoveDirectoryA(void)
{
char tmpdir[MAX_PATH];
BOOL ret;
GetTempPathA(MAX_PATH, tmpdir);
lstrcatA(tmpdir, "Please Remove Me");
ret = CreateDirectoryA(tmpdir, NULL);
ok(ret == TRUE, "CreateDirectoryA should always succeed");
ret = RemoveDirectoryA(tmpdir);
ok(ret == TRUE, "RemoveDirectoryA should always succeed");
todo_wine {
lstrcatA(tmpdir, "?");
ret = RemoveDirectoryA(tmpdir);
ok(ret == FALSE && GetLastError() == ERROR_INVALID_NAME,
"RemoveDirectoryA with ? wildcard name should fail with error 183, ret=%s error=%ld",
ret ? " True" : "False", GetLastError());
tmpdir[lstrlenA(tmpdir) - 1] = '*';
ret = RemoveDirectoryA(tmpdir);
ok(ret == FALSE && GetLastError() == ERROR_INVALID_NAME,
"RemoveDirectoryA with * wildcard name should fail with error 183, ret=%s error=%ld",
ret ? " True" : "False", GetLastError());
}
}
static void test_RemoveDirectoryW(void)
{
WCHAR tmpdir[MAX_PATH];
BOOL ret;
static const WCHAR tmp_dir_name[] = {'P','l','e','a','s','e',' ','R','e','m','o','v','e',' ','M','e',0};
static const WCHAR questionW[] = {'?',0};
GetTempPathW(MAX_PATH, tmpdir);
lstrcatW(tmpdir, tmp_dir_name);
ret = CreateDirectoryW(tmpdir, NULL);
ok(ret == TRUE, "CreateDirectoryW should always succeed");
ret = RemoveDirectoryW(tmpdir);
ok(ret == TRUE, "RemoveDirectoryW should always succeed");
todo_wine {
lstrcatW(tmpdir, questionW);
ret = RemoveDirectoryW(tmpdir);
ok(ret == FALSE && GetLastError() == ERROR_INVALID_NAME,
"RemoveDirectoryW with wildcard should fail with error 183, ret=%s error=%ld",
ret ? " True" : "False", GetLastError());
tmpdir[lstrlenW(tmpdir) - 1] = '*';
ret = RemoveDirectoryW(tmpdir);
ok(ret == FALSE && GetLastError() == ERROR_INVALID_NAME,
"RemoveDirectoryW with * wildcard name should fail with error 183, ret=%s error=%ld",
ret ? " True" : "False", GetLastError());
}
}
START_TEST(directory)
......@@ -250,4 +342,7 @@ START_TEST(directory)
test_CreateDirectoryA();
test_CreateDirectoryW();
test_RemoveDirectoryA();
test_RemoveDirectoryW();
}
......@@ -28,7 +28,6 @@
#include "winbase.h"
#include "winerror.h"
LPCSTR filename = "testfile.xxx";
LPCSTR sillytext =
"en larvig liten text dx \033 gx hej 84 hej 4484 ! \001\033 bla bl\na.. bla bla."
......@@ -263,10 +262,13 @@ static void test__lcreat( void )
ok( DeleteFileA( filename ) != 0, "DeleteFile failed (%ld)", GetLastError( ) );
filehandle=_lcreat (slashname, 0); /* illegal name */
if (HFILE_ERROR==filehandle)
ok (0, "couldn't create file \"%s\" (err=%ld)", slashname,
GetLastError ());
else {
if (HFILE_ERROR != filehandle || GetLastError() != ERROR_INVALID_NAME)
{
todo_wine {
ok (0, "creating file \"%s\" should fail with error 123, (err=%ld)", slashname, GetLastError ());
}
_lclose(filehandle);
find=FindFirstFileA (slashname, &search_results);
if (INVALID_HANDLE_VALUE==find)
......@@ -648,6 +650,109 @@ static void test_DeleteFileW( void )
"DeleteFileW(\"\") returned ret=%d error=%ld",ret,GetLastError());
}
#define IsDotDir(x) ((x[0] == '.') && ((x[1] == 0) || ((x[1] == '.') && (x[2] == 0))))
void test_MoveFileA(void)
{
char tempdir[MAX_PATH];
char source[MAX_PATH], dest[MAX_PATH];
static const char prefix[] = "pfx";
DWORD ret;
ret = GetTempPathA(MAX_PATH, tempdir);
ok(ret != 0, "GetTempPathA error %ld", GetLastError());
ok(ret < MAX_PATH, "temp path should fit into MAX_PATH");
ret = GetTempFileNameA(tempdir, prefix, 0, source);
ok(ret != 0, "GetTempFileNameA error %ld", GetLastError());
ret = GetTempFileNameA(tempdir, prefix, 0, dest);
ok(ret != 0, "GetTempFileNameA error %ld", GetLastError());
ret = MoveFileA(source, dest);
ok(!ret && GetLastError() == ERROR_FILE_EXISTS,
"MoveFileA: unexpected error %ld\n", GetLastError());
ret = DeleteFileA(dest);
ok(ret, "DeleteFileA: error %ld\n", GetLastError());
ret = MoveFileA(source, dest);
ok(ret, "MoveFileA: failed, error %ld\n", GetLastError());
lstrcatA(tempdir, "Remove Me");
ret = CreateDirectoryA(tempdir, NULL);
ok(ret == TRUE, "CreateDirectoryA failed");
lstrcpyA(source, dest);
lstrcpyA(dest, tempdir);
lstrcatA(dest, "\\wild?.*");
ret = MoveFileA(source, dest);
todo_wine {
ok(!ret, "MoveFileA: shouldn't move to wildcard file");
ok(GetLastError() == ERROR_INVALID_NAME,
"MoveFileA: with wildcards, unexpected error %ld\n", GetLastError());
if (ret || (GetLastError() != ERROR_INVALID_NAME))
{
WIN32_FIND_DATAA fd;
char temppath[MAX_PATH];
HANDLE hFind;
lstrcpyA(temppath, tempdir);
lstrcatA(temppath, "\\*.*");
hFind = FindFirstFileA(temppath, &fd);
if (INVALID_HANDLE_VALUE != hFind)
{
LPSTR lpName;
do
{
lpName = fd.cAlternateFileName;
if (!lpName[0])
lpName = fd.cFileName;
ok(!IsDotDir(lpName), "MoveFileA: wildcards file created!");
}
while (FindNextFileA(hFind, &fd));
FindClose(hFind);
}
}
}
ret = DeleteFileA(source);
ok(ret, "DeleteFileA: error %ld\n", GetLastError());
ret = DeleteFileA(dest);
ok(!ret, "DeleteFileA: error %ld\n", GetLastError());
ret = RemoveDirectoryA(tempdir);
ok(ret, "DeleteDirectoryA: error %ld\n", GetLastError());
}
void test_MoveFileW(void)
{
WCHAR temp_path[MAX_PATH];
WCHAR source[MAX_PATH], dest[MAX_PATH];
static const WCHAR prefix[] = {'p','f','x',0};
DWORD ret;
ret = GetTempPathW(MAX_PATH, temp_path);
if (ret==0 && GetLastError()==ERROR_CALL_NOT_IMPLEMENTED)
return;
ok(ret != 0, "GetTempPathW error %ld", GetLastError());
ok(ret < MAX_PATH, "temp path should fit into MAX_PATH");
ret = GetTempFileNameW(temp_path, prefix, 0, source);
ok(ret != 0, "GetTempFileNameW error %ld", GetLastError());
ret = GetTempFileNameW(temp_path, prefix, 0, dest);
ok(ret != 0, "GetTempFileNameW error %ld", GetLastError());
ret = MoveFileW(source, dest);
ok(!ret && GetLastError() == ERROR_FILE_EXISTS,
"CopyFileW: unexpected error %ld\n", GetLastError());
ret = DeleteFileW(source);
ok(ret, "DeleteFileW: error %ld\n", GetLastError());
ret = DeleteFileW(dest);
ok(ret, "DeleteFileW: error %ld\n", GetLastError());
}
#define PATTERN_OFFSET 0x10
void test_offset_in_overlapped_structure(void)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment