James Hawkins : shlwapi: Add tests for PathAddBackslash.
Alexandre Julliard
julliard at wine.codeweavers.com
Tue Jun 27 04:53:27 CDT 2006
Module: wine
Branch: refs/heads/master
Commit: 251d76888d70133d3afa2cb8c43a45420175d8c2
URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=251d76888d70133d3afa2cb8c43a45420175d8c2
Author: James Hawkins <truiken at gmail.com>
Date: Mon Jun 26 14:41:22 2006 -0700
shlwapi: Add tests for PathAddBackslash.
---
dlls/shlwapi/tests/path.c | 63 +++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 63 insertions(+), 0 deletions(-)
diff --git a/dlls/shlwapi/tests/path.c b/dlls/shlwapi/tests/path.c
index 6c116c9..e931d81 100644
--- a/dlls/shlwapi/tests/path.c
+++ b/dlls/shlwapi/tests/path.c
@@ -1072,6 +1072,68 @@ static void test_PathCombineA(void)
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %ld\n", GetLastError());
}
+static void test_PathAddBackslash(void)
+{
+ LPSTR str;
+ char path[MAX_PATH];
+ char too_long[LONG_LEN];
+
+ /* try a NULL path */
+ SetLastError(0xdeadbeef);
+ str = PathAddBackslashA(NULL);
+ ok(str == NULL, "Expected str == NULL, got %p\n", str);
+ ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %ld\n", GetLastError());
+
+ /* try an empty path */
+ path[0] = '\0';
+ SetLastError(0xdeadbeef);
+ str = PathAddBackslashA(path);
+ ok(str == (path + lstrlenA(path)), "Expected str to point to end of path, got %p\n", str);
+ ok(lstrlenA(path) == 0, "Expected empty string, got %i\n", lstrlenA(path));
+ ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %ld\n", GetLastError());
+
+ /* try a relative path */
+ lstrcpyA(path, "one\\two");
+ SetLastError(0xdeadbeef);
+ str = PathAddBackslashA(path);
+ ok(str == (path + lstrlenA(path)), "Expected str to point to end of path, got %p\n", str);
+ ok(!lstrcmp(path, "one\\two\\"), "Expected one\\two\\, got %s\n", path);
+ ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %ld\n", GetLastError());
+
+ /* try periods */
+ lstrcpyA(path, "one\\..\\two");
+ SetLastError(0xdeadbeef);
+ str = PathAddBackslashA(path);
+ ok(str == (path + lstrlenA(path)), "Expected str to point to end of path, got %p\n", str);
+ ok(!lstrcmp(path, "one\\..\\two\\"), "Expected one\\..\\two\\, got %s\n", path);
+ ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %ld\n", GetLastError());
+
+ /* try just a space */
+ lstrcpyA(path, " ");
+ SetLastError(0xdeadbeef);
+ str = PathAddBackslashA(path);
+ ok(str == (path + lstrlenA(path)), "Expected str to point to end of path, got %p\n", str);
+ ok(!lstrcmp(path, " \\"), "Expected \\, got %s\n", path);
+ ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %ld\n", GetLastError());
+
+ /* path already has backslash */
+ lstrcpyA(path, "C:\\one\\");
+ SetLastError(0xdeadbeef);
+ str = PathAddBackslashA(path);
+ ok(str == (path + lstrlenA(path)), "Expected str to point to end of path, got %p\n", str);
+ ok(!lstrcmp(path, "C:\\one\\"), "Expected C:\\one\\, got %s\n", path);
+ ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %ld\n", GetLastError());
+
+ memset(too_long, 'a', LONG_LEN);
+ too_long[LONG_LEN - 1] = '\0';
+
+ /* path is longer than MAX_PATH */
+ SetLastError(0xdeadbeef);
+ str = PathAddBackslashA(too_long);
+ ok(str == NULL, "Expected str == NULL, got %p\n", str);
+ ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %ld\n", GetLastError());
+}
+
START_TEST(path)
{
hShlwapi = LoadLibraryA("shlwapi.dll");
@@ -1090,6 +1152,7 @@ START_TEST(path)
test_PathCreateFromUrl();
test_PathIsUrl();
+ test_PathAddBackslash();
test_PathMakePretty();
test_PathMatchSpec();
More information about the wine-cvs
mailing list