kernel32/tests: Add tests for NeedCurrentDirectoryForExePath
Kirill K. Smirnov
lich at math.spbu.ru
Wed Apr 25 02:41:11 CDT 2007
-------------- next part --------------
diff --git a/dlls/kernel32/tests/path.c b/dlls/kernel32/tests/path.c
index 9212165..44ece2b 100644
--- a/dlls/kernel32/tests/path.c
+++ b/dlls/kernel32/tests/path.c
@@ -53,6 +53,10 @@ static const CHAR is_char_ok[] ="1111111
static DWORD (WINAPI *pGetLongPathNameA)(LPCSTR,LPSTR,DWORD);
static DWORD (WINAPI *pGetLongPathNameW)(LPWSTR,LPWSTR,DWORD);
+/* Present in Win2003+ */
+static BOOL (WINAPI *pNeedCurrentDirectoryForExePathA)(LPCSTR);
+static BOOL (WINAPI *pNeedCurrentDirectoryForExePathW)(LPCWSTR);
+
/* a structure to deal with wine todos somewhat cleanly */
typedef struct {
DWORD shortlen;
@@ -1069,6 +1073,44 @@ static void test_GetWindowsDirectory(voi
res, GetLastError(), buffer, total);
}
+static void test_NeedCurrentDirectoryForExePathA(void)
+{
+ /* Crashes in Windows */
+ if (0)
+ ok(pNeedCurrentDirectoryForExePathA(NULL), "returned FALSE for NULL\n");
+
+ SetEnvironmentVariableA("NoDefaultCurrentDirectoryInExePath", NULL);
+ ok(pNeedCurrentDirectoryForExePathA("."), "returned FALSE for \".\"\n");
+ ok(pNeedCurrentDirectoryForExePathA("c:\\"), "returned FALSE for \"c:\\\"\n");
+ ok(pNeedCurrentDirectoryForExePathA("cmd.exe"), "returned FALSE for \"cmd.exe\"\n");
+
+ SetEnvironmentVariableA("NoDefaultCurrentDirectoryInExePath", "nya");
+ ok(!pNeedCurrentDirectoryForExePathA("."), "returned TRUE for \".\"\n");
+ ok(pNeedCurrentDirectoryForExePathA("c:\\"), "returned FALSE for \"c:\\\"\n");
+ ok(!pNeedCurrentDirectoryForExePathA("cmd.exe"), "returned TRUE for \"cmd.exe\"\n");
+}
+
+static void test_NeedCurrentDirectoryForExePathW(void)
+{
+ const WCHAR thispath[] = {'.', 0};
+ const WCHAR fullpath[] = {'c', ':', '\\', 0};
+ const WCHAR cmdname[] = {'c', 'm', 'd', '.', 'e', 'x', 'e', 0};
+
+ /* Crashes in Windows */
+ if (0)
+ ok(pNeedCurrentDirectoryForExePathW(NULL), "returned FALSE for NULL\n");
+
+ SetEnvironmentVariableA("NoDefaultCurrentDirectoryInExePath", NULL);
+ ok(pNeedCurrentDirectoryForExePathW(thispath), "returned FALSE for \".\"\n");
+ ok(pNeedCurrentDirectoryForExePathW(fullpath), "returned FALSE for \"c:\\\"\n");
+ ok(pNeedCurrentDirectoryForExePathW(cmdname), "returned FALSE for \"cmd.exe\"\n");
+
+ SetEnvironmentVariableA("NoDefaultCurrentDirectoryInExePath", "nya");
+ ok(!pNeedCurrentDirectoryForExePathW(thispath), "returned TRUE for \".\"\n");
+ ok(pNeedCurrentDirectoryForExePathW(fullpath), "returned FALSE for \"c:\\\"\n");
+ ok(!pNeedCurrentDirectoryForExePathW(cmdname), "returned TRUE for \"cmd.exe\"\n");
+}
+
START_TEST(path)
{
CHAR origdir[MAX_PATH],curdir[MAX_PATH], curDrive, otherDrive;
@@ -1076,6 +1118,13 @@ START_TEST(path)
"GetLongPathNameA" );
pGetLongPathNameW = (void*)GetProcAddress(GetModuleHandleA("kernel32.dll") ,
"GetLongPathNameW" );
+ pNeedCurrentDirectoryForExePathA =
+ (void*)GetProcAddress( GetModuleHandleA("kernel32.dll"),
+ "NeedCurrentDirectoryForExePathA" );
+ pNeedCurrentDirectoryForExePathW =
+ (void*)GetProcAddress( GetModuleHandleA("kernel32.dll"),
+ "NeedCurrentDirectoryForExePathW" );
+
test_InitPathA(curdir, &curDrive, &otherDrive);
test_CurrentDirectoryA(origdir,curdir);
test_PathNameA(curdir, curDrive, otherDrive);
@@ -1084,4 +1133,12 @@ START_TEST(path)
test_GetLongPathNameW();
test_GetSystemDirectory();
test_GetWindowsDirectory();
+ if (pNeedCurrentDirectoryForExePathA)
+ {
+ test_NeedCurrentDirectoryForExePathA();
+ }
+ if (pNeedCurrentDirectoryForExePathW)
+ {
+ test_NeedCurrentDirectoryForExePathW();
+ }
}
More information about the wine-patches
mailing list