Add tests for GetSystemDirectoryA/W and GetWindowsDirectoryA/W
Dmitry Timoshkov
dmitry at baikal.ru
Sun Mar 3 02:44:10 CST 2002
Hello.
Changelog:
Dmitry Timoshkov <dmitry at codeweavers.com>
Add tests for GetSystemDirectoryA/W and GetWindowsDirectoryA/W.
diff -u cvs/hq/wine/dlls/kernel/Makefile.in wine/dlls/kernel/Makefile.in
--- cvs/hq/wine/dlls/kernel/Makefile.in Thu Jan 24 20:32:58 2002
+++ wine/dlls/kernel/Makefile.in Sun Mar 3 16:05:32 2002
@@ -40,6 +40,10 @@
nls \
tests
+CTESTS = \
+ tests/GetSystemDirectory.c \
+ tests/GetWindowsDirectory.c
+
PLTESTS = \
tests/atom.pl
diff -u cvs/hq/wine/dlls/kernel/tests/.cvsignore wine/dlls/kernel/tests/.cvsignore
--- cvs/hq/wine/dlls/kernel/tests/.cvsignore Wed Jan 16 04:59:23 2002
+++ wine/dlls/kernel/tests/.cvsignore Sun Mar 3 16:01:45 2002
@@ -1 +1,5 @@
atom.ok
+GetSystemDirectory.ok
+GetWindowsDirectory.ok
+kernel32_test.spec.c
+testlist.c
diff -u cvs/hq/wine/dlls/kernel/tests/GetSystemDirectory.c wine/dlls/kernel/tests/GetSystemDirectory.c
--- cvs/hq/wine/dlls/kernel/tests/GetSystemDirectory.c Thu Jan 1 08:00:00 1970
+++ wine/dlls/kernel/tests/GetSystemDirectory.c Sun Mar 3 16:16:03 2002
@@ -0,0 +1,56 @@
+/* If you will change something in these tests, please do the same
+ * for GetWindowsDirectory tests.
+ */
+#include "winbase.h"
+#include "wine/test.h"
+
+void test_GetSystemDirectoryA(void)
+{
+ UINT len, len_with_null;
+ char buf[MAX_PATH];
+
+ lstrcpyA(buf, "foo");
+ len_with_null = GetSystemDirectoryA(buf, 1);
+ ok(lstrcmpA(buf, "foo") == 0, "should not touch the buffer");
+ ok(len_with_null <= MAX_PATH, "should fit into MAX_PATH");
+
+ lstrcpyA(buf, "foo");
+ len = GetSystemDirectoryA(buf, len_with_null - 1);
+ ok(lstrcmpA(buf, "foo") == 0, "should not touch the buffer");
+ ok(len == len_with_null, "should return length with terminating 0");
+
+ lstrcpyA(buf, "foo");
+ len = GetSystemDirectoryA(buf, len_with_null);
+ ok(lstrcmpA(buf, "foo") != 0, "should touch the buffer");
+ ok(len == lstrlenA(buf), "returned length should be equal to the length of string");
+ ok(len == (len_with_null - 1), "should return length without terminating 0");
+}
+
+void test_GetSystemDirectoryW(void)
+{
+ UINT len, len_with_null;
+ WCHAR buf[MAX_PATH];
+ static const WCHAR fooW[] = {'f','o','o',0};
+
+ lstrcpyW(buf, fooW);
+ len_with_null = GetSystemDirectoryW(buf, 1);
+ ok(lstrcmpW(buf, fooW) == 0, "should not touch the buffer");
+ ok(len_with_null <= MAX_PATH, "should fit into MAX_PATH");
+
+ lstrcpyW(buf, fooW);
+ len = GetSystemDirectoryW(buf, len_with_null - 1);
+ ok(lstrcmpW(buf, fooW) == 0, "should not touch the buffer");
+ ok(len == len_with_null, "should return length with terminating 0");
+
+ lstrcpyW(buf, fooW);
+ len = GetSystemDirectoryW(buf, len_with_null);
+ ok(lstrcmpW(buf, fooW) != 0, "should touch the buffer");
+ ok(len == lstrlenW(buf), "returned length should be equal to the length of string");
+ ok(len == (len_with_null - 1), "should return length without terminating 0");
+}
+
+START_TEST(GetSystemDirectory)
+{
+ test_GetSystemDirectoryA();
+ test_GetSystemDirectoryW();
+}
diff -u cvs/hq/wine/dlls/kernel/tests/GetWindowsDirectory.c wine/dlls/kernel/tests/GetWindowsDirectory.c
--- cvs/hq/wine/dlls/kernel/tests/GetWindowsDirectory.c Thu Jan 1 08:00:00 1970
+++ wine/dlls/kernel/tests/GetWindowsDirectory.c Sun Mar 3 16:24:58 2002
@@ -0,0 +1,56 @@
+/* If you will change something in these tests, please do the same
+ * for GetSystemDirectory tests.
+ */
+#include "winbase.h"
+#include "wine/test.h"
+
+void test_GetWindowsDirectoryA(void)
+{
+ UINT len, len_with_null;
+ char buf[MAX_PATH];
+
+ lstrcpyA(buf, "foo");
+ len_with_null = GetWindowsDirectoryA(buf, 1);
+ ok(lstrcmpA(buf, "foo") == 0, "should not touch the buffer");
+ ok(len_with_null <= MAX_PATH, "should fit into MAX_PATH");
+
+ lstrcpyA(buf, "foo");
+ len = GetWindowsDirectoryA(buf, len_with_null - 1);
+ ok(lstrcmpA(buf, "foo") == 0, "should not touch the buffer");
+ ok(len == len_with_null, "should return length with terminating 0");
+
+ lstrcpyA(buf, "foo");
+ len = GetWindowsDirectoryA(buf, len_with_null);
+ ok(lstrcmpA(buf, "foo") != 0, "should touch the buffer");
+ ok(len == lstrlenA(buf), "returned length should be equal to the length of string");
+ ok(len == (len_with_null - 1), "should return length without terminating 0");
+}
+
+void test_GetWindowsDirectoryW(void)
+{
+ UINT len, len_with_null;
+ WCHAR buf[MAX_PATH];
+ static const WCHAR fooW[] = {'f','o','o',0};
+
+ lstrcpyW(buf, fooW);
+ len_with_null = GetWindowsDirectoryW(buf, 1);
+ ok(lstrcmpW(buf, fooW) == 0, "should not touch the buffer");
+ ok(len_with_null <= MAX_PATH, "should fit into MAX_PATH");
+
+ lstrcpyW(buf, fooW);
+ len = GetWindowsDirectoryW(buf, len_with_null - 1);
+ ok(lstrcmpW(buf, fooW) == 0, "should not touch the buffer");
+ ok(len == len_with_null, "should return length with terminating 0");
+
+ lstrcpyW(buf, fooW);
+ len = GetWindowsDirectoryW(buf, len_with_null);
+ ok(lstrcmpW(buf, fooW) != 0, "should touch the buffer");
+ ok(len == lstrlenW(buf), "returned length should be equal to the length of string");
+ ok(len == (len_with_null - 1), "should return length without terminating 0");
+}
+
+START_TEST(GetWindowsDirectory)
+{
+ test_GetWindowsDirectoryA();
+ test_GetWindowsDirectoryW();
+}
diff -u cvs/hq/wine/dlls/kernel/tests/kernel32_test.spec wine/dlls/kernel/tests/kernel32_test.spec
--- cvs/hq/wine/dlls/kernel/tests/kernel32_test.spec Thu Jan 1 08:00:00 1970
+++ wine/dlls/kernel/tests/kernel32_test.spec Sun Mar 3 16:10:27 2002
@@ -0,0 +1,5 @@
+name kernel32_test
+type win32
+mode cuiexe
+
+import kernel32.dll
More information about the wine-patches
mailing list