When the Windows directory was something else than C:\WINDOWS

test_GetTempFileNameA() failed.
This commit is contained in:
Jakob Eriksson 2004-04-22 23:44:14 +00:00 committed by Alexandre Julliard
parent 1fb75dcac5
commit 960104b249
1 changed files with 31 additions and 11 deletions

View File

@ -628,23 +628,43 @@ static void test_CreateFileW(void)
"CreateFileW(\"\") returned ret=%p error=%ld\n",hFile,GetLastError()); "CreateFileW(\"\") returned ret=%p error=%ld\n",hFile,GetLastError());
} }
static void test_GetTempFileNameA()
static void test_GetTempFileNameA() { {
UINT result; UINT result;
char out[MAX_PATH]; char out[MAX_PATH];
char *expected = "c:\\windows\\abc2.tmp"; char expected[MAX_PATH + 10];
char windowsdir[MAX_PATH + 10];
char windowsdrive[3];
/* this test may depend on the config file settings */ result = GetWindowsDirectory(windowsdir, sizeof(windowsdir));
result = GetTempFileNameA("C:", "abc", 1, out); ok(result < sizeof(windowsdir), "windowsdir is abnormally long!\n");
ok( result != 0, "GetTempFileNameA: error %ld\n", GetLastError() ); ok(result != 0, "GetWindowsDirectory: error %ld\n", GetLastError());
ok( ((out[0] == 'C') && (out[1] == ':')) && (out[2] == '\\'), "GetTempFileNameA: first three characters should be C:\\, string was actually %s\n", out );
result = GetTempFileNameA("c:\\windows\\", "abc", 2, out); /* If the Windows directory is the root directory, it ends in backslash, not else. */
ok( result != 0, "GetTempFileNameA: error %ld\n", GetLastError() ); if (strlen(windowsdir) != 3) /* As in "C:\" or "F:\" */
ok( lstrcmpiA( out, expected ) == 0, "GetTempFileNameA: Unexpected output \"%s\" vs \"%s\"\n", out, expected ); {
strcat(windowsdir, "\\");
}
windowsdrive[0] = windowsdir[0];
windowsdrive[1] = windowsdir[1];
windowsdrive[2] = '\0';
result = GetTempFileNameA(windowsdrive, "abc", 1, out);
ok(result != 0, "GetTempFileNameA: error %ld\n", GetLastError());
ok(((out[0] == windowsdrive[0]) && (out[1] == ':')) && (out[2] == '\\'),
"GetTempFileNameA: first three characters should be %c:\\, string was actually %s\n",
windowsdrive[0], out);
result = GetTempFileNameA(windowsdir, "abc", 2, out);
ok(result != 0, "GetTempFileNameA: error %ld\n", GetLastError());
expected[0] = '\0';
strcat(expected, windowsdir);
strcat(expected, "abc2.tmp");
ok(lstrcmpiA(out, expected) == 0, "GetTempFileNameA: Unexpected output \"%s\" vs \"%s\"\n",
out, expected);
} }
static void test_DeleteFileA( void ) static void test_DeleteFileA( void )
{ {
BOOL ret; BOOL ret;