Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
7412bddd
Commit
7412bddd
authored
Jun 26, 2006
by
James Hawkins
Committed by
Alexandre Julliard
Jun 27, 2006
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
shlwapi: Add tests for PathCombineA.
parent
e391387c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
201 additions
and
19 deletions
+201
-19
path.c
dlls/shlwapi/path.c
+1
-1
path.c
dlls/shlwapi/tests/path.c
+200
-18
No files found.
dlls/shlwapi/path.c
View file @
7412bddd
...
...
@@ -165,7 +165,7 @@ LPWSTR WINAPI PathCombineW(LPWSTR lpszDest, LPCWSTR lpszDir, LPCWSTR lpszFile)
if
(
!
lpszDest
||
(
!
lpszDir
&&
!
lpszFile
))
return
NULL
;
/* Invalid parameters */
if
(
!
lpszFile
||
!*
lpszFile
)
if
(
(
!
lpszFile
||
!*
lpszFile
)
&&
lpszDir
)
{
/* Use dir only */
lstrcpynW
(
szTemp
,
lpszDir
,
MAX_PATH
);
...
...
dlls/shlwapi/tests/path.c
View file @
7412bddd
...
...
@@ -861,36 +861,215 @@ static void test_PathMatchSpec(void)
ok
(
PathMatchSpecA
(
file
,
spec13
)
==
TRUE
,
"PathMatchSpec: Spec13 failed
\n
"
);
}
static
void
test_PathCombine
(
void
)
static
void
test_PathCombine
W
(
void
)
{
LPSTR
szString
,
szString2
;
LPWSTR
wszString
,
wszString2
;
szString2
=
HeapAlloc
(
GetProcessHeap
(),
0
,
MAX_PATH
*
sizeof
(
char
));
wszString2
=
HeapAlloc
(
GetProcessHeap
(),
0
,
MAX_PATH
*
sizeof
(
WCHAR
));
/* NULL test */
szString
=
PathCombineA
(
NULL
,
NULL
,
NULL
);
ok
(
szString
==
NULL
,
"Expected a NULL return
\n
"
);
wszString
=
pPathCombineW
(
NULL
,
NULL
,
NULL
);
ok
(
w
szString
==
NULL
,
"Expected a NULL return
\n
"
);
if
(
pPathCombineW
)
/* Some NULL */
wszString
=
pPathCombineW
(
wszString2
,
NULL
,
NULL
);
ok
(
wszString
==
NULL
,
"Expected a NULL return
\n
"
);
HeapFree
(
GetProcessHeap
(),
0
,
wszString2
);
}
#define LONG_LEN (MAX_PATH * 2)
#define HALF_LEN (MAX_PATH / 2 + 1)
static
void
test_PathCombineA
(
void
)
{
LPSTR
str
;
char
dest
[
MAX_PATH
];
char
too_long
[
LONG_LEN
];
char
one
[
HALF_LEN
],
two
[
HALF_LEN
];
/* try NULL dest */
SetLastError
(
0xdeadbeef
);
str
=
PathCombineA
(
NULL
,
"C:
\\
"
,
"one
\\
two
\\
three"
);
ok
(
str
==
NULL
,
"Expected NULL, got %p
\n
"
,
str
);
ok
(
GetLastError
()
==
0xdeadbeef
,
"Expected 0xdeadbeef, got %ld
\n
"
,
GetLastError
());
/* try NULL dest and NULL directory */
SetLastError
(
0xdeadbeef
);
str
=
PathCombineA
(
NULL
,
NULL
,
"one
\\
two
\\
three"
);
ok
(
str
==
NULL
,
"Expected NULL, got %p
\n
"
,
str
);
ok
(
GetLastError
()
==
0xdeadbeef
,
"Expected 0xdeadbeef, got %ld
\n
"
,
GetLastError
());
/* try all NULL*/
SetLastError
(
0xdeadbeef
);
str
=
PathCombineA
(
NULL
,
NULL
,
NULL
);
ok
(
str
==
NULL
,
"Expected NULL, got %p
\n
"
,
str
);
ok
(
GetLastError
()
==
0xdeadbeef
,
"Expected 0xdeadbeef, got %ld
\n
"
,
GetLastError
());
/* try NULL file part */
SetLastError
(
0xdeadbeef
);
lstrcpyA
(
dest
,
"control"
);
str
=
PathCombineA
(
dest
,
"C:
\\
"
,
NULL
);
ok
(
str
==
dest
,
"Expected str == dest, got %p
\n
"
,
str
);
ok
(
!
lstrcmp
(
str
,
"C:
\\
"
),
"Expected C:
\\
, got %s
\n
"
,
str
);
ok
(
GetLastError
()
==
0xdeadbeef
,
"Expected 0xdeadbeef, got %ld
\n
"
,
GetLastError
());
/* try empty file part */
SetLastError
(
0xdeadbeef
);
lstrcpyA
(
dest
,
"control"
);
str
=
PathCombineA
(
dest
,
"C:
\\
"
,
""
);
ok
(
str
==
dest
,
"Expected str == dest, got %p
\n
"
,
str
);
ok
(
!
lstrcmp
(
str
,
"C:
\\
"
),
"Expected C:
\\
, got %s
\n
"
,
str
);
ok
(
GetLastError
()
==
0xdeadbeef
,
"Expected 0xdeadbeef, got %ld
\n
"
,
GetLastError
());
/* try empty directory and file part */
SetLastError
(
0xdeadbeef
);
lstrcpyA
(
dest
,
"control"
);
str
=
PathCombineA
(
dest
,
""
,
""
);
ok
(
str
==
dest
,
"Expected str == dest, got %p
\n
"
,
str
);
ok
(
!
lstrcmp
(
str
,
"
\\
"
),
"Expected
\\
, got %s
\n
"
,
str
);
ok
(
GetLastError
()
==
0xdeadbeef
,
"Expected 0xdeadbeef, got %ld
\n
"
,
GetLastError
());
/* try NULL directory */
SetLastError
(
0xdeadbeef
);
lstrcpyA
(
dest
,
"control"
);
str
=
PathCombineA
(
dest
,
NULL
,
"one
\\
two
\\
three"
);
ok
(
str
==
dest
,
"Expected str == dest, got %p
\n
"
,
str
);
ok
(
!
lstrcmp
(
str
,
"one
\\
two
\\
three"
),
"Expected one
\\
two
\\
three, got %s
\n
"
,
str
);
ok
(
GetLastError
()
==
0xdeadbeef
,
"Expected 0xdeadbeef, got %ld
\n
"
,
GetLastError
());
/* try NULL directory and empty file part */
SetLastError
(
0xdeadbeef
);
lstrcpyA
(
dest
,
"control"
);
str
=
PathCombineA
(
dest
,
NULL
,
""
);
ok
(
str
==
dest
,
"Expected str == dest, got %p
\n
"
,
str
);
ok
(
!
lstrcmp
(
str
,
"
\\
"
),
"Expected
\\
, got %s
\n
"
,
str
);
ok
(
GetLastError
()
==
0xdeadbeef
,
"Expected 0xdeadbeef, got %ld
\n
"
,
GetLastError
());
/* try NULL directory and file part */
SetLastError
(
0xdeadbeef
);
lstrcpyA
(
dest
,
"control"
);
str
=
PathCombineA
(
dest
,
NULL
,
NULL
);
ok
(
str
==
NULL
,
"Expected str == NULL, got %p
\n
"
,
str
);
todo_wine
{
wszString
=
pPathCombineW
(
NULL
,
NULL
,
NULL
);
ok
(
wszString
==
NULL
,
"Expected a NULL return
\n
"
);
ok
(
lstrlenA
(
dest
)
==
0
,
"Expected 0 length, got %i
\n
"
,
lstrlenA
(
dest
));
}
ok
(
GetLastError
()
==
0xdeadbeef
,
"Expected 0xdeadbeef, got %ld
\n
"
,
GetLastError
());
/* try directory without backslash */
SetLastError
(
0xdeadbeef
);
lstrcpyA
(
dest
,
"control"
);
str
=
PathCombineA
(
dest
,
"C:"
,
"one
\\
two
\\
three"
);
ok
(
str
==
dest
,
"Expected str == dest, got %p
\n
"
,
str
);
ok
(
!
lstrcmp
(
str
,
"C:
\\
one
\\
two
\\
three"
),
"Expected C:
\\
one
\\
two
\\
three, got %s
\n
"
,
str
);
ok
(
GetLastError
()
==
0xdeadbeef
,
"Expected 0xdeadbeef, got %ld
\n
"
,
GetLastError
());
/* try directory with backslash */
SetLastError
(
0xdeadbeef
);
lstrcpyA
(
dest
,
"control"
);
str
=
PathCombineA
(
dest
,
"C:
\\
"
,
"one
\\
two
\\
three"
);
ok
(
str
==
dest
,
"Expected str == dest, got %p
\n
"
,
str
);
ok
(
!
lstrcmp
(
str
,
"C:
\\
one
\\
two
\\
three"
),
"Expected C:
\\
one
\\
two
\\
three, got %s
\n
"
,
str
);
ok
(
GetLastError
()
==
0xdeadbeef
,
"Expected 0xdeadbeef, got %ld
\n
"
,
GetLastError
());
/* try directory with backslash and file with prepended backslash */
SetLastError
(
0xdeadbeef
);
lstrcpyA
(
dest
,
"control"
);
str
=
PathCombineA
(
dest
,
"C:
\\
"
,
"
\\
one
\\
two
\\
three"
);
ok
(
str
==
dest
,
"Expected str == dest, got %p
\n
"
,
str
);
ok
(
!
lstrcmp
(
str
,
"C:
\\
one
\\
two
\\
three"
),
"Expected C:
\\
one
\\
two
\\
three, got %s
\n
"
,
str
);
ok
(
GetLastError
()
==
0xdeadbeef
,
"Expected 0xdeadbeef, got %ld
\n
"
,
GetLastError
());
/* try previous test, with backslash appended as well */
SetLastError
(
0xdeadbeef
);
lstrcpyA
(
dest
,
"control"
);
str
=
PathCombineA
(
dest
,
"C:
\\
"
,
"
\\
one
\\
two
\\
three
\\
"
);
ok
(
str
==
dest
,
"Expected str == dest, got %p
\n
"
,
str
);
ok
(
!
lstrcmp
(
str
,
"C:
\\
one
\\
two
\\
three
\\
"
),
"Expected C:
\\
one
\\
two
\\
three
\\
, got %s
\n
"
,
str
);
ok
(
GetLastError
()
==
0xdeadbeef
,
"Expected 0xdeadbeef, got %ld
\n
"
,
GetLastError
());
/* try a relative directory */
SetLastError
(
0xdeadbeef
);
lstrcpyA
(
dest
,
"control"
);
str
=
PathCombineA
(
dest
,
"relative
\\
dir"
,
"
\\
one
\\
two
\\
three
\\
"
);
ok
(
str
==
dest
,
"Expected str == dest, got %p
\n
"
,
str
);
ok
(
!
lstrcmp
(
str
,
"one
\\
two
\\
three
\\
"
),
"Expected one
\\
two
\\
three
\\
, got %s
\n
"
,
str
);
ok
(
GetLastError
()
==
0xdeadbeef
,
"Expected 0xdeadbeef, got %ld
\n
"
,
GetLastError
());
/* try forward slashes */
SetLastError
(
0xdeadbeef
);
lstrcpyA
(
dest
,
"control"
);
str
=
PathCombineA
(
dest
,
"C:
\\
"
,
"one/two/three
\\
"
);
ok
(
str
==
dest
,
"Expected str == dest, got %p
\n
"
,
str
);
ok
(
!
lstrcmp
(
str
,
"C:
\\
one/two/three
\\
"
),
"Expected one/two/three
\\
, got %s
\n
"
,
str
);
ok
(
GetLastError
()
==
0xdeadbeef
,
"Expected 0xdeadbeef, got %ld
\n
"
,
GetLastError
());
/* try a really weird directory */
SetLastError
(
0xdeadbeef
);
lstrcpyA
(
dest
,
"control"
);
str
=
PathCombineA
(
dest
,
"C:
\\
/
\\
/"
,
"
\\
one
\\
two
\\
three
\\
"
);
ok
(
str
==
dest
,
"Expected str == dest, got %p
\n
"
,
str
);
ok
(
!
lstrcmp
(
str
,
"C:
\\
one
\\
two
\\
three
\\
"
),
"Expected C:
\\
one
\\
two
\\
three
\\
, got %s
\n
"
,
str
);
ok
(
GetLastError
()
==
0xdeadbeef
,
"Expected 0xdeadbeef, got %ld
\n
"
,
GetLastError
());
/* try periods */
SetLastError
(
0xdeadbeef
);
lstrcpyA
(
dest
,
"control"
);
str
=
PathCombineA
(
dest
,
"C:
\\
"
,
"one
\\
..
\\
two
\\
.
\\
three"
);
ok
(
str
==
dest
,
"Expected str == dest, got %p
\n
"
,
str
);
ok
(
!
lstrcmp
(
str
,
"C:
\\
two
\\
three"
),
"Expected C:
\\
two
\\
three, got %s
\n
"
,
str
);
ok
(
GetLastError
()
==
0xdeadbeef
,
"Expected 0xdeadbeef, got %ld
\n
"
,
GetLastError
());
/* try .. as file */
/* try forward slashes */
SetLastError
(
0xdeadbeef
);
lstrcpyA
(
dest
,
"control"
);
str
=
PathCombineA
(
dest
,
"C:
\\
"
,
".."
);
ok
(
str
==
dest
,
"Expected str == dest, got %p
\n
"
,
str
);
ok
(
!
lstrcmp
(
str
,
"C:
\\
"
),
"Expected C:
\\
, got %s
\n
"
,
str
);
ok
(
GetLastError
()
==
0xdeadbeef
,
"Expected 0xdeadbeef, got %ld
\n
"
,
GetLastError
());
memset
(
too_long
,
'a'
,
LONG_LEN
);
too_long
[
LONG_LEN
-
1
]
=
'\0'
;
/* try a file longer than MAX_PATH */
SetLastError
(
0xdeadbeef
);
lstrcpyA
(
dest
,
"control"
);
str
=
PathCombineA
(
dest
,
"C:
\\
"
,
too_long
);
todo_wine
{
ok
(
str
==
NULL
,
"Expected str == NULL, got %p
\n
"
,
str
);
ok
(
lstrlenA
(
dest
)
==
0
,
"Expected 0 length, got %i
\n
"
,
lstrlenA
(
dest
));
ok
(
GetLastError
()
==
0xdeadbeef
,
"Expected 0xdeadbeef, got %ld
\n
"
,
GetLastError
());
}
/*
Some NULL
*/
szString
=
PathCombineA
(
szString2
,
NULL
,
NULL
);
ok
(
szString
==
NULL
,
"Expected a NULL return
\n
"
);
if
(
pPathCombineW
)
/*
try a directory longer than MAX_PATH
*/
SetLastError
(
0xdeadbeef
);
lstrcpyA
(
dest
,
"control
"
);
str
=
PathCombineA
(
dest
,
too_long
,
"one
\\
two
\\
three"
);
todo_wine
{
wszString
=
pPathCombineW
(
wszString2
,
NULL
,
NULL
);
ok
(
wszString
==
NULL
,
"Expected a NULL return
\n
"
);
ok
(
str
==
NULL
,
"Expected str == NULL, got %p
\n
"
,
str
);
ok
(
lstrlenA
(
dest
)
==
0
,
"Expected 0 length, got %i
\n
"
,
lstrlenA
(
dest
));
ok
(
GetLastError
()
==
0xdeadbeef
,
"Expected 0xdeadbeef, got %ld
\n
"
,
GetLastError
());
}
HeapFree
(
GetProcessHeap
(),
0
,
szString2
);
HeapFree
(
GetProcessHeap
(),
0
,
wszString2
);
memset
(
one
,
'b'
,
HALF_LEN
);
memset
(
two
,
'c'
,
HALF_LEN
);
one
[
HALF_LEN
-
1
]
=
'\0'
;
two
[
HALF_LEN
-
1
]
=
'\0'
;
/* destination string is longer than MAX_PATH, but not the constituent parts */
SetLastError
(
0xdeadbeef
);
lstrcpyA
(
dest
,
"control"
);
str
=
PathCombineA
(
dest
,
one
,
two
);
todo_wine
{
ok
(
str
==
NULL
,
"Expected str == NULL, got %p
\n
"
,
str
);
ok
(
lstrlenA
(
dest
)
==
0
,
"Expected 0 length, got %i
\n
"
,
lstrlenA
(
dest
));
}
ok
(
GetLastError
()
==
0xdeadbeef
,
"Expected 0xdeadbeef, got %ld
\n
"
,
GetLastError
());
}
START_TEST
(
path
)
...
...
@@ -927,5 +1106,8 @@ START_TEST(path)
}
pPathCombineW
=
(
void
*
)
GetProcAddress
(
hShlwapi
,
"PathCombineW"
);
test_PathCombine
();
if
(
pPathCombineW
)
test_PathCombineW
();
test_PathCombineA
();
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment