kernel32/tests: [2/2] Add tests for GetWindowsDirectory (resend without changes)

Detlef Riekenberg wine.dev at web.de
Sun Dec 3 15:38:50 CST 2006


Subject: kernel32/tests: [2/2] Add Tests for GetWindowsDirectory
Date: Sun, 19 Nov 2006 16:53:42 +0100


Resend without changes (was dropped without comments)


Changelog:
- kernel32/tests: Add tests for GetWindowsDirectory


-- 
 
By by ... Detlef

-------------- next part --------------
>From 26846e65f3cc4f7e0ed8f3831fffc83f676a91e8 Mon Sep 17 00:00:00 2001
From: Detlef Riekenberg <wine.dev at web.de>
Date: Sun, 3 Dec 2006 22:32:25 +0100
Subject: [PATCH] kernel32/tests: Add test for GetWindowsDirectory
---
 dlls/kernel32/tests/path.c |   61 ++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 61 insertions(+), 0 deletions(-)

diff --git a/dlls/kernel32/tests/path.c b/dlls/kernel32/tests/path.c
index cb4b348..3df8915 100644
--- a/dlls/kernel32/tests/path.c
+++ b/dlls/kernel32/tests/path.c
@@ -1012,6 +1012,66 @@ #endif
         res, GetLastError(), buffer, total);
 }
 
+static void test_GetWindowsDirectory(void)
+{
+    CHAR    buffer[MAX_PATH + 4];
+    DWORD   res; 
+    DWORD   total; 
+
+    SetLastError(0xdeadbeef);
+    res = GetWindowsDirectory(NULL, 0);
+    /* res includes the terminating Zero */
+    ok(res > 0, "returned %d with 0x%x (expected '>0')\n", res, GetLastError());
+
+    total = res;
+#if 0
+    /* this test crash on XP */
+    res = GetWindowsDirectory(NULL, total);
+#endif
+
+    SetLastError(0xdeadbeef);
+    res = GetWindowsDirectory(NULL, total-1);
+    /* 95+NT: total (includes the terminating Zero)
+       98+ME: 0 with ERROR_INVALID_PARAMETER */
+    ok( (res == total) || (!res && (GetLastError() == ERROR_INVALID_PARAMETER)),
+        "returned %d with 0x%x (expected '%d' or: '0' with " \
+        "ERROR_INVALID_PARAMETER)\n", res, GetLastError(), total);
+
+    if (total > MAX_PATH) return;
+
+    buffer[0] = '\0';
+    SetLastError(0xdeadbeef);
+    res = GetWindowsDirectory(buffer, total);
+    /* res does not include the terminating Zero */
+    ok( (res == (total-1)) && (buffer[0]), 
+        "returned %d with 0x%x and '%s' (expected '%d' and a string)\n",
+        res, GetLastError(), buffer, total-1);
+
+    buffer[0] = '\0';
+    SetLastError(0xdeadbeef);
+    res = GetWindowsDirectory(buffer, total + 1);
+    /* res does not include the terminating Zero */
+    ok( (res == (total-1)) && (buffer[0]), 
+        "returned %d with 0x%x and '%s' (expected '%d' and a string)\n",
+        res, GetLastError(), buffer, total-1);
+
+    memset(buffer, '#', total + 1);    
+    buffer[total + 2] = '\0';
+    SetLastError(0xdeadbeef);
+    res = GetWindowsDirectory(buffer, total-1);
+    /* res includes the terminating Zero) */
+    ok( res == total, "returned %d with 0x%x and '%s' (expected '%d')\n",
+        res, GetLastError(), buffer, total);
+
+    memset(buffer, '#', total + 1);    
+    buffer[total + 2] = '\0';
+    SetLastError(0xdeadbeef);
+    res = GetWindowsDirectory(buffer, total-2);
+    /* res includes the terminating Zero) */
+    ok( res == total, "returned %d with 0x%x and '%s' (expected '%d')\n",
+        res, GetLastError(), buffer, total);
+}
+
 START_TEST(path)
 {
     CHAR origdir[MAX_PATH],curdir[MAX_PATH], curDrive, otherDrive;
@@ -1026,4 +1086,5 @@ START_TEST(path)
     test_GetTempPath();
     test_GetLongPathNameW();
     test_GetSystemDirectory();
+    test_GetWindowsDirectory();
 }
-- 
1.4.1



More information about the wine-patches mailing list