2003-01-09 01:50:17 +01:00
/* Unit test suite for Path functions
*
* Copyright 2002 Matthew Mastracci
*
* This library is free software ; you can redistribute it and / or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation ; either
* version 2.1 of the License , or ( at your option ) any later version .
*
* This library is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the GNU
* Lesser General Public License for more details .
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library ; if not , write to the Free Software
2006-05-18 14:49:52 +02:00
* Foundation , Inc . , 51 Franklin St , Fifth Floor , Boston , MA 02110 - 1301 , USA
2003-01-09 01:50:17 +01:00
*/
# include <assert.h>
2003-09-06 01:08:26 +02:00
# include <stdarg.h>
2003-01-09 01:50:17 +01:00
# include <stdio.h>
# include "wine/test.h"
2003-09-06 01:08:26 +02:00
# include "windef.h"
2003-01-09 01:50:17 +01:00
# include "winbase.h"
2003-05-13 02:29:34 +02:00
# include "winreg.h"
2003-01-09 01:50:17 +01:00
# include "shlwapi.h"
# include "wininet.h"
2005-02-10 18:10:43 +01:00
static HMODULE hShlwapi ;
static HRESULT ( WINAPI * pPathIsValidCharA ) ( char , DWORD ) ;
static HRESULT ( WINAPI * pPathIsValidCharW ) ( WCHAR , DWORD ) ;
2006-06-23 15:21:02 +02:00
static LPWSTR ( WINAPI * pPathCombineW ) ( LPWSTR , LPCWSTR , LPCWSTR ) ;
2005-02-10 18:10:43 +01:00
2003-01-09 01:50:17 +01:00
const char * TEST_URL_1 = " http://www.winehq.org/tests?date=10/10/1923 " ;
const char * TEST_URL_2 = " http://localhost:8080/tests%2e.html?date=Mon%2010/10/1923 " ;
const char * TEST_URL_3 = " http://foo:bar@localhost:21/internal.php?query=x&return=y " ;
2004-03-03 21:11:46 +01:00
typedef struct _TEST_URL_CANONICALIZE {
2005-06-14 19:21:18 +02:00
const char * url ;
2004-03-03 21:11:46 +01:00
DWORD flags ;
HRESULT expectret ;
2005-06-14 19:21:18 +02:00
const char * expecturl ;
2004-03-03 21:11:46 +01:00
} TEST_URL_CANONICALIZE ;
const TEST_URL_CANONICALIZE TEST_CANONICALIZE [ ] = {
2004-04-28 01:29:01 +02:00
/*FIXME {"http://www.winehq.org/tests/../tests/../..", 0, S_OK, "http://www.winehq.org/"},*/
2004-03-03 21:11:46 +01:00
{ " http://www.winehq.org/tests/../tests " , 0 , S_OK , " http://www.winehq.org/tests " } ,
2004-03-16 02:07:28 +01:00
{ " http://www.winehq.org/tests \n " , URL_WININET_COMPATIBILITY | URL_ESCAPE_SPACES_ONLY | URL_ESCAPE_UNSAFE , S_OK , " http://www.winehq.org/tests " } ,
{ " http://www.winehq.org/tests \r " , URL_WININET_COMPATIBILITY | URL_ESCAPE_SPACES_ONLY | URL_ESCAPE_UNSAFE , S_OK , " http://www.winehq.org/tests " } ,
{ " http://www.winehq.org/tests \r " , 0 , S_OK , " http://www.winehq.org/tests " } ,
{ " http://www.winehq.org/tests \r " , URL_DONT_SIMPLIFY , S_OK , " http://www.winehq.org/tests " } ,
2004-03-03 21:11:46 +01:00
{ " http://www.winehq.org/tests/../tests/ " , 0 , S_OK , " http://www.winehq.org/tests/ " } ,
{ " http://www.winehq.org/tests/../tests/.. " , 0 , S_OK , " http://www.winehq.org/ " } ,
{ " http://www.winehq.org/tests/../tests/../ " , 0 , S_OK , " http://www.winehq.org/ " } ,
{ " http://www.winehq.org/tests/.. " , 0 , S_OK , " http://www.winehq.org/ " } ,
{ " http://www.winehq.org/tests/../ " , 0 , S_OK , " http://www.winehq.org/ " } ,
{ " http://www.winehq.org/tests/..?query=x&return=y " , 0 , S_OK , " http://www.winehq.org/?query=x&return=y " } ,
{ " http://www.winehq.org/tests/../?query=x&return=y " , 0 , S_OK , " http://www.winehq.org/?query=x&return=y " } ,
{ " http://www.winehq.org/tests/..#example " , 0 , S_OK , " http://www.winehq.org/#example " } ,
{ " http://www.winehq.org/tests/../#example " , 0 , S_OK , " http://www.winehq.org/#example " } ,
2005-12-26 12:58:28 +01:00
{ " http://www.winehq.org/tests \\ ../#example " , 0 , S_OK , " http://www.winehq.org/#example " } ,
{ " http://www.winehq.org/tests/.. \\ #example " , 0 , S_OK , " http://www.winehq.org/#example " } ,
{ " http://www.winehq.org \\ tests/../#example " , 0 , S_OK , " http://www.winehq.org/#example " } ,
2004-03-03 21:11:46 +01:00
{ " http://www.winehq.org/tests/../#example " , URL_DONT_SIMPLIFY , S_OK , " http://www.winehq.org/tests/../#example " } ,
2005-05-23 18:23:02 +02:00
{ " http://www.winehq.org/tests/foo bar " , URL_ESCAPE_SPACES_ONLY | URL_DONT_ESCAPE_EXTRA_INFO , S_OK , " http://www.winehq.org/tests/foo%20bar " } ,
{ " http://www.winehq.org/tests/foo%20bar " , URL_UNESCAPE , S_OK , " http://www.winehq.org/tests/foo bar " } ,
{ " file:///c:/tests/foo%20bar " , URL_UNESCAPE , S_OK , " file:///c:/tests/foo bar " } ,
2005-12-26 12:58:28 +01:00
{ " file:///c:/tests \\ foo%20bar " , URL_UNESCAPE , S_OK , " file:///c:/tests/foo bar " } ,
{ " file:///c:/tests/foo%20bar " , URL_FILE_USE_PATHURL , S_OK , " file://c: \\ tests \\ foo bar " } ,
{ " file://c:/tests/../tests/foo%20bar " , URL_FILE_USE_PATHURL , S_OK , " file://c: \\ tests \\ foo bar " } ,
{ " file://c:/tests \\ ../tests/foo%20bar " , URL_FILE_USE_PATHURL , S_OK , " file://c: \\ tests \\ foo bar " } ,
{ " file://c:/tests/foo%20bar " , URL_FILE_USE_PATHURL , S_OK , " file://c: \\ tests \\ foo bar " } ,
2006-01-11 21:15:31 +01:00
{ " file:///c://tests/foo%20bar " , URL_FILE_USE_PATHURL , S_OK , " file://c: \\ \\ tests \\ foo bar " } ,
{ " file:///c: \\ tests \\ foo bar " , 0 , S_OK , " file:///c:/tests/foo bar " } ,
{ " file:///c: \\ tests \\ foo bar " , URL_DONT_SIMPLIFY , S_OK , " file:///c:/tests/foo bar " } ,
2006-07-26 20:55:56 +02:00
{ " http://www.winehq.org/site/about " , URL_FILE_USE_PATHURL , S_OK , " http://www.winehq.org/site/about " } ,
{ " file_://www.winehq.org/site/about " , URL_FILE_USE_PATHURL , S_OK , " file_://www.winehq.org/site/about " } ,
2006-07-29 16:11:31 +02:00
{ " c: \\ dir \\ file " , 0 , S_OK , " file:///c:/dir/file " } ,
{ " file:///c: \\ dir \\ file " , 0 , S_OK , " file:///c:/dir/file " } ,
{ " c:dir \\ file " , 0 , S_OK , " file:///c:dir/file " } ,
{ " A " , 0 , S_OK , " A " } ,
{ " " , 0 , S_OK , " " }
2004-03-03 21:11:46 +01:00
} ;
2004-03-16 02:07:28 +01:00
typedef struct _TEST_URL_ESCAPE {
2005-06-14 19:21:18 +02:00
const char * url ;
2004-03-16 02:07:28 +01:00
DWORD flags ;
DWORD expectescaped ;
HRESULT expectret ;
2005-06-14 19:21:18 +02:00
const char * expecturl ;
2004-03-16 02:07:28 +01:00
} TEST_URL_ESCAPE ;
const TEST_URL_ESCAPE TEST_ESCAPE [ ] = {
{ " http://www.winehq.org/tests0 " , 0 , 0 , S_OK , " http://www.winehq.org/tests0 " } ,
{ " http://www.winehq.org/tests1 \n " , 0 , 0 , S_OK , " http://www.winehq.org/tests1%0A " } ,
{ " http://www.winehq.org/tests2 \r " , 0 , 0 , S_OK , " http://www.winehq.org/tests2%0D " } ,
{ " http://www.winehq.org/tests3 \r " , URL_ESCAPE_SPACES_ONLY | URL_ESCAPE_UNSAFE , 0 , S_OK , " http://www.winehq.org/tests3 \r " } ,
{ " http://www.winehq.org/tests4 \r " , URL_ESCAPE_SPACES_ONLY , 0 , S_OK , " http://www.winehq.org/tests4 \r " } ,
{ " http://www.winehq.org/tests5 \r " , URL_WININET_COMPATIBILITY | URL_ESCAPE_SPACES_ONLY , 0 , S_OK , " http://www.winehq.org/tests5 \r " } ,
{ " /direct/swhelp/series6/6.2i_latestservicepack.dat \r " , URL_ESCAPE_SPACES_ONLY , 0 , S_OK , " /direct/swhelp/series6/6.2i_latestservicepack.dat \r " } ,
2004-10-04 21:08:50 +02:00
{ " file://////foo/bar \\ baz " , 0 , 0 , S_OK , " file://foo/bar/baz " } ,
{ " file://///foo/bar \\ baz " , 0 , 0 , S_OK , " file://foo/bar/baz " } ,
{ " file:////foo/bar \\ baz " , 0 , 0 , S_OK , " file://foo/bar/baz " } ,
{ " file:///localhost/foo/bar \\ baz " , 0 , 0 , S_OK , " file:///localhost/foo/bar/baz " } ,
{ " file:///foo/bar \\ baz " , 0 , 0 , S_OK , " file:///foo/bar/baz " } ,
{ " file://loCalHost/foo/bar \\ baz " , 0 , 0 , S_OK , " file:///foo/bar/baz " } ,
{ " file://foo/bar \\ baz " , 0 , 0 , S_OK , " file://foo/bar/baz " } ,
{ " file:/localhost/foo/bar \\ baz " , 0 , 0 , S_OK , " file:///localhost/foo/bar/baz " } ,
{ " file:/foo/bar \\ baz " , 0 , 0 , S_OK , " file:///foo/bar/baz " } ,
{ " file:foo/bar \\ baz " , 0 , 0 , S_OK , " file:foo/bar/baz " } ,
{ " file: \\ foo/bar \\ baz " , 0 , 0 , S_OK , " file:///foo/bar/baz " } ,
{ " file: \\ \\ foo/bar \\ baz " , 0 , 0 , S_OK , " file://foo/bar/baz " } ,
{ " file: \\ \\ \\ foo/bar \\ baz " , 0 , 0 , S_OK , " file:///foo/bar/baz " } ,
{ " file: \\ \\ localhost \\ foo/bar \\ baz " , 0 , 0 , S_OK , " file:///foo/bar/baz " } ,
{ " file:///f oo/b?a r \\ baz " , 0 , 0 , S_OK , " file:///f%20oo/b?a r \\ baz " } ,
{ " file:///foo/b#a r \\ baz " , 0 , 0 , S_OK , " file:///foo/b%23a%20r/baz " } ,
{ " file:///f o^&`{}|][ \" <> \\ %o/b#a r \\ baz " , 0 , 0 , S_OK , " file:///f%20o%5E%26%60%7B%7D%7C%5D%5B%22%3C%3E/%o/b%23a%20r/baz " } ,
{ " file:///f o%o/b?a r \\ b%az " , URL_ESCAPE_PERCENT , 0 , S_OK , " file:///f%20o%25o/b?a r \\ b%az " } ,
{ " file:/foo/bar \\ baz " , URL_ESCAPE_SEGMENT_ONLY , 0 , S_OK , " file:%2Ffoo%2Fbar%5Cbaz " } ,
{ " foo/b%ar \\ ba?z \\ " , URL_ESCAPE_SEGMENT_ONLY , 0 , S_OK , " foo%2Fb%ar%5Cba%3Fz%5C " } ,
{ " foo/b%ar \\ ba?z \\ " , URL_ESCAPE_PERCENT | URL_ESCAPE_SEGMENT_ONLY , 0 , S_OK , " foo%2Fb%25ar%5Cba%3Fz%5C " } ,
{ " foo/bar \\ ba?z \\ " , 0 , 0 , S_OK , " foo/bar%5Cba?z \\ " } ,
{ " /foo/bar \\ ba?z \\ " , 0 , 0 , S_OK , " /foo/bar%5Cba?z \\ " } ,
{ " /foo/bar \\ ba#z \\ " , 0 , 0 , S_OK , " /foo/bar%5Cba#z \\ " } ,
{ " /foo/%5C " , 0 , 0 , S_OK , " /foo/%5C " } ,
{ " /foo/%5C " , URL_ESCAPE_PERCENT , 0 , S_OK , " /foo/%255C " } ,
{ " http://////foo/bar \\ baz " , 0 , 0 , S_OK , " http://////foo/bar/baz " } ,
{ " http://///foo/bar \\ baz " , 0 , 0 , S_OK , " http://///foo/bar/baz " } ,
{ " http:////foo/bar \\ baz " , 0 , 0 , S_OK , " http:////foo/bar/baz " } ,
{ " http:///foo/bar \\ baz " , 0 , 0 , S_OK , " http:///foo/bar/baz " } ,
{ " http://localhost/foo/bar \\ baz " , 0 , 0 , S_OK , " http://localhost/foo/bar/baz " } ,
{ " http://foo/bar \\ baz " , 0 , 0 , S_OK , " http://foo/bar/baz " } ,
{ " http:/foo/bar \\ baz " , 0 , 0 , S_OK , " http:/foo/bar/baz " } ,
{ " http:foo/bar \\ ba?z \\ " , 0 , 0 , S_OK , " http:foo%2Fbar%2Fba?z \\ " } ,
{ " http:foo/bar \\ ba#z \\ " , 0 , 0 , S_OK , " http:foo%2Fbar%2Fba#z \\ " } ,
{ " http: \\ foo/bar \\ baz " , 0 , 0 , S_OK , " http:/foo/bar/baz " } ,
{ " http: \\ \\ foo/bar \\ baz " , 0 , 0 , S_OK , " http://foo/bar/baz " } ,
{ " http: \\ \\ \\ foo/bar \\ baz " , 0 , 0 , S_OK , " http:///foo/bar/baz " } ,
{ " http: \\ \\ \\ \\ foo/bar \\ baz " , 0 , 0 , S_OK , " http:////foo/bar/baz " } ,
{ " http:/fo ?o/b ar \\ baz " , 0 , 0 , S_OK , " http:/fo%20?o/b ar \\ baz " } ,
{ " http:fo ?o/b ar \\ baz " , 0 , 0 , S_OK , " http:fo%20?o/b ar \\ baz " } ,
{ " http:/foo/bar \\ baz " , URL_ESCAPE_SEGMENT_ONLY , 0 , S_OK , " http:%2Ffoo%2Fbar%5Cbaz " } ,
{ " https://foo/bar \\ baz " , 0 , 0 , S_OK , " https://foo/bar/baz " } ,
{ " https:/foo/bar \\ baz " , 0 , 0 , S_OK , " https:/foo/bar/baz " } ,
{ " https: \\ foo/bar \\ baz " , 0 , 0 , S_OK , " https:/foo/bar/baz " } ,
{ " foo:////foo/bar \\ baz " , 0 , 0 , S_OK , " foo:////foo/bar%5Cbaz " } ,
{ " foo:///foo/bar \\ baz " , 0 , 0 , S_OK , " foo:///foo/bar%5Cbaz " } ,
{ " foo://localhost/foo/bar \\ baz " , 0 , 0 , S_OK , " foo://localhost/foo/bar%5Cbaz " } ,
{ " foo://foo/bar \\ baz " , 0 , 0 , S_OK , " foo://foo/bar%5Cbaz " } ,
{ " foo:/foo/bar \\ baz " , 0 , 0 , S_OK , " foo:/foo/bar%5Cbaz " } ,
{ " foo:foo/bar \\ baz " , 0 , 0 , S_OK , " foo:foo%2Fbar%5Cbaz " } ,
{ " foo: \\ foo/bar \\ baz " , 0 , 0 , S_OK , " foo:%5Cfoo%2Fbar%5Cbaz " } ,
{ " foo:/foo/bar \\ ba? \\ z " , 0 , 0 , S_OK , " foo:/foo/bar%5Cba? \\ z " } ,
{ " foo:/foo/bar \\ ba# \\ z " , 0 , 0 , S_OK , " foo:/foo/bar%5Cba# \\ z " } ,
{ " mailto:/fo/o@b \\ %a? \\ r.b# \\ az " , 0 , 0 , S_OK , " mailto:%2Ffo%2Fo@b%5C%a%3F%5Cr.b%23%5Caz " } ,
{ " mailto:fo/o@b \\ %a? \\ r.b# \\ az " , 0 , 0 , S_OK , " mailto:fo%2Fo@b%5C%a%3F%5Cr.b%23%5Caz " } ,
{ " mailto:fo/o@b \\ %a? \\ r.b# \\ az " , URL_ESCAPE_PERCENT , 0 , S_OK , " mailto:fo%2Fo@b%5C%25a%3F%5Cr.b%23%5Caz " } ,
{ " ftp:fo/o@bar.baz/foo/bar " , 0 , 0 , S_OK , " ftp:fo%2Fo@bar.baz%2Ffoo%2Fbar " } ,
{ " ftp:/fo/o@bar.baz/foo/bar " , 0 , 0 , S_OK , " ftp:/fo/o@bar.baz/foo/bar " } ,
{ " ftp://fo/o@bar.baz/fo?o \\ bar " , 0 , 0 , S_OK , " ftp://fo/o@bar.baz/fo?o \\ bar " } ,
{ " ftp://fo/o@bar.baz/fo#o \\ bar " , 0 , 0 , S_OK , " ftp://fo/o@bar.baz/fo#o \\ bar " } ,
{ " ftp://localhost/o@bar.baz/fo#o \\ bar " , 0 , 0 , S_OK , " ftp://localhost/o@bar.baz/fo#o \\ bar " } ,
{ " ftp:///fo/o@bar.baz/foo/bar " , 0 , 0 , S_OK , " ftp:///fo/o@bar.baz/foo/bar " } ,
{ " ftp:////fo/o@bar.baz/foo/bar " , 0 , 0 , S_OK , " ftp:////fo/o@bar.baz/foo/bar " }
2004-03-16 02:07:28 +01:00
} ;
2004-04-28 01:29:01 +02:00
typedef struct _TEST_URL_COMBINE {
2005-06-14 19:21:18 +02:00
const char * url1 ;
const char * url2 ;
2004-04-28 01:29:01 +02:00
DWORD flags ;
HRESULT expectret ;
2005-06-14 19:21:18 +02:00
const char * expecturl ;
2004-04-28 01:29:01 +02:00
} TEST_URL_COMBINE ;
const TEST_URL_COMBINE TEST_COMBINE [ ] = {
{ " http://www.winehq.org/tests " , " tests1 " , 0 , S_OK , " http://www.winehq.org/tests1 " } ,
2006-01-11 21:15:31 +01:00
{ " http://www.%77inehq.org/tests " , " tests1 " , 0 , S_OK , " http://www.%77inehq.org/tests1 " } ,
2004-04-28 01:29:01 +02:00
/*FIXME {"http://www.winehq.org/tests", "../tests2", 0, S_OK, "http://www.winehq.org/tests2"},*/
{ " http://www.winehq.org/tests/ " , " ../tests3 " , 0 , S_OK , " http://www.winehq.org/tests3 " } ,
2006-01-11 21:15:31 +01:00
{ " http://www.winehq.org/tests/test1 " , " test2 " , 0 , S_OK , " http://www.winehq.org/tests/test2 " } ,
2004-04-28 01:29:01 +02:00
{ " http://www.winehq.org/tests/../tests " , " tests4 " , 0 , S_OK , " http://www.winehq.org/tests4 " } ,
{ " http://www.winehq.org/tests/../tests/ " , " tests5 " , 0 , S_OK , " http://www.winehq.org/tests/tests5 " } ,
{ " http://www.winehq.org/tests/../tests/ " , " /tests6/.. " , 0 , S_OK , " http://www.winehq.org/ " } ,
{ " http://www.winehq.org/tests/../tests/.. " , " tests7/.. " , 0 , S_OK , " http://www.winehq.org/ " } ,
{ " http://www.winehq.org/tests/?query=x&return=y " , " tests8 " , 0 , S_OK , " http://www.winehq.org/tests/tests8 " } ,
{ " http://www.winehq.org/tests/#example " , " tests9 " , 0 , S_OK , " http://www.winehq.org/tests/tests9 " } ,
{ " http://www.winehq.org/tests/../tests/ " , " /tests10/.. " , URL_DONT_SIMPLIFY , S_OK , " http://www.winehq.org/tests10/.. " } ,
{ " http://www.winehq.org/tests/../ " , " tests11 " , URL_DONT_SIMPLIFY , S_OK , " http://www.winehq.org/tests/../tests11 " } ,
2006-01-11 21:15:31 +01:00
{ " file:///C: \\ dir \\ file.txt " , " test.txt " , 0 , S_OK , " file:///C:/dir/test.txt " }
2004-04-28 01:29:01 +02:00
} ;
2004-10-05 20:31:58 +02:00
struct {
2005-06-14 19:21:18 +02:00
const char * path ;
const char * url ;
2004-10-05 20:31:58 +02:00
DWORD ret ;
} TEST_URLFROMPATH [ ] = {
{ " foo " , " file:foo " , S_OK } ,
{ " foo \\ bar " , " file:foo/bar " , S_OK } ,
{ " \\ foo \\ bar " , " file:///foo/bar " , S_OK } ,
{ " c: \\ foo \\ bar " , " file:///c:/foo/bar " , S_OK } ,
{ " c:foo \\ bar " , " file:///c:foo/bar " , S_OK } ,
{ " c: \\ foo/b a%r " , " file:///c:/foo/b%20a%25r " , S_OK } ,
2005-05-23 18:23:02 +02:00
{ " c: \\ foo \\ foo bar " , " file:///c:/foo/foo%20bar " , S_OK } ,
2005-03-14 11:09:53 +01:00
#if 0
/* The following test fails on native shlwapi as distributed with Win95/98.
* Wine matches the behaviour of later versions .
*/
2004-10-05 20:31:58 +02:00
{ " xx:c: \\ foo \\ bar " , " xx:c: \\ foo \\ bar " , S_FALSE }
2005-03-14 11:09:53 +01:00
# endif
2004-10-05 20:31:58 +02:00
} ;
struct {
2005-06-14 19:21:18 +02:00
const char * url ;
const char * path ;
2004-10-05 20:31:58 +02:00
DWORD ret ;
} TEST_PATHFROMURL [ ] = {
{ " file:///c:/foo/ba%5Cr " , " c: \\ foo \\ ba \\ r " , S_OK } ,
{ " file:///c:/foo/../ba%5Cr " , " c: \\ foo \\ .. \\ ba \\ r " , S_OK } ,
{ " file:///host/c:/foo/bar " , " \\ host \\ c: \\ foo \\ bar " , S_OK } ,
{ " file://host/c:/foo/bar " , " \\ \\ hostc: \\ foo \\ bar " , S_OK } ,
{ " file://host/c:/foo/bar " , " \\ \\ hostc: \\ foo \\ bar " , S_OK } ,
{ " file: \\ \\ host \\ c: \\ foo \\ bar " , " \\ \\ hostc: \\ foo \\ bar " , S_OK } ,
{ " file: \\ \\ host \\ ca \\ foo \\ bar " , " \\ \\ host \\ ca \\ foo \\ bar " , S_OK } ,
{ " file: \\ \\ host \\ c| \\ foo \\ bar " , " \\ \\ hostc| \\ foo \\ bar " , S_OK } ,
{ " file: \\ %5Chost \\ c: \\ foo \\ bar " , " \\ \\ host \\ c: \\ foo \\ bar " , S_OK } ,
{ " file: \\ \\ host \\ cx: \\ foo \\ bar " , " \\ \\ host \\ cx: \\ foo \\ bar " , S_OK } ,
{ " file://c:/foo/bar " , " c: \\ foo \\ bar " , S_OK } ,
{ " file://c:/d:/foo/bar " , " c: \\ d: \\ foo \\ bar " , S_OK } ,
{ " file://c|/d|/foo/bar " , " c: \\ d| \\ foo \\ bar " , S_OK } ,
{ " file://host/foo/bar " , " \\ \\ host \\ foo \\ bar " , S_OK } ,
{ " file:/foo/bar " , " \\ foo \\ bar " , S_OK } ,
{ " file:/foo/bar/ " , " \\ foo \\ bar \\ " , S_OK } ,
{ " file:foo/bar " , " foo \\ bar " , S_OK } ,
{ " file:c:/foo/bar " , " c: \\ foo \\ bar " , S_OK } ,
{ " file:c|/foo/bar " , " c: \\ foo \\ bar " , S_OK } ,
{ " file:cx|/foo/bar " , " cx| \\ foo \\ bar " , S_OK } ,
{ " file:////c:/foo/bar " , " c: \\ foo \\ bar " , S_OK } ,
2005-05-23 18:23:02 +02:00
/* {"file:////c:/foo/foo%20bar", "c:\\foo\\foo%20bar", S_OK},*/
2004-10-05 20:31:58 +02:00
{ " c: \\ foo \\ bar " , NULL , E_INVALIDARG } ,
{ " foo/bar " , NULL , E_INVALIDARG } ,
{ " http://foo/bar " , NULL , E_INVALIDARG } ,
} ;
struct {
2005-06-14 19:21:18 +02:00
char url [ 30 ] ;
const char * expect ;
2004-10-05 20:31:58 +02:00
} TEST_URL_UNESCAPE [ ] = {
{ " file://foo/bar " , " file://foo/bar " } ,
{ " file://fo%20o%5Ca/bar " , " file://fo o \\ a/bar " }
} ;
struct {
2005-06-14 19:21:18 +02:00
const char * path ;
2004-10-05 20:31:58 +02:00
BOOL expect ;
} TEST_PATH_IS_URL [ ] = {
{ " http://foo/bar " , TRUE } ,
{ " c: \\ foo \\ bar " , FALSE } ,
{ " foo://foo/bar " , TRUE } ,
2005-01-03 18:08:40 +01:00
{ " foo \\ bar " , FALSE } ,
2005-03-21 11:54:35 +01:00
{ " foo.bar " , FALSE } ,
{ " bogusscheme: " , TRUE } ,
{ " http:partial " , TRUE }
2004-10-05 20:31:58 +02:00
} ;
2005-03-21 11:54:35 +01:00
struct {
2005-06-14 19:21:18 +02:00
const char * url ;
2005-03-21 11:54:35 +01:00
BOOL expectOpaque ;
BOOL expectFile ;
} TEST_URLIS_ATTRIBS [ ] = {
{ " ftp: " , FALSE , FALSE } ,
{ " http: " , FALSE , FALSE } ,
{ " gopher: " , FALSE , FALSE } ,
{ " mailto: " , TRUE , FALSE } ,
{ " news: " , FALSE , FALSE } ,
{ " nntp: " , FALSE , FALSE } ,
{ " telnet: " , FALSE , FALSE } ,
{ " wais: " , FALSE , FALSE } ,
{ " file: " , FALSE , TRUE } ,
{ " mk: " , FALSE , FALSE } ,
{ " https: " , FALSE , FALSE } ,
{ " shell: " , TRUE , FALSE } ,
{ " https: " , FALSE , FALSE } ,
{ " snews: " , FALSE , FALSE } ,
{ " local: " , FALSE , FALSE } ,
{ " javascript: " , TRUE , FALSE } ,
{ " vbscript: " , TRUE , FALSE } ,
{ " about: " , TRUE , FALSE } ,
{ " res: " , FALSE , FALSE } ,
{ " bogusscheme: " , FALSE , FALSE } ,
{ " file: \\ \\ e: \\ b \\ c " , FALSE , TRUE } ,
{ " file://e:/b/c " , FALSE , TRUE } ,
{ " http:partial " , FALSE , FALSE } ,
{ " mailto://www.winehq.org/test.html " , TRUE , FALSE } ,
{ " file:partial " , FALSE , TRUE }
} ;
2003-01-09 01:50:17 +01:00
static LPWSTR GetWideString ( const char * szString )
{
2005-03-22 19:26:06 +01:00
LPWSTR wszString = HeapAlloc ( GetProcessHeap ( ) , 0 , ( 2 * INTERNET_MAX_URL_LENGTH ) * sizeof ( WCHAR ) ) ;
2003-01-09 01:50:17 +01:00
MultiByteToWideChar ( 0 , 0 , szString , - 1 , wszString , INTERNET_MAX_URL_LENGTH ) ;
return wszString ;
}
static void FreeWideString ( LPWSTR wszString )
{
HeapFree ( GetProcessHeap ( ) , 0 , wszString ) ;
}
static void hash_url ( const char * szUrl )
{
LPCSTR szTestUrl = szUrl ;
LPWSTR wszTestUrl = GetWideString ( szTestUrl ) ;
DWORD cbSize = sizeof ( DWORD ) ;
DWORD dwHash1 , dwHash2 ;
2004-01-27 21:13:03 +01:00
ok ( UrlHashA ( szTestUrl , ( LPBYTE ) & dwHash1 , cbSize ) = = S_OK , " UrlHashA didn't return S_OK \n " ) ;
ok ( UrlHashW ( wszTestUrl , ( LPBYTE ) & dwHash2 , cbSize ) = = S_OK , " UrlHashW didn't return S_OK \n " ) ;
2003-01-09 01:50:17 +01:00
FreeWideString ( wszTestUrl ) ;
2004-01-27 21:13:03 +01:00
ok ( dwHash1 = = dwHash2 , " Hashes didn't compare \n " ) ;
2003-01-09 01:50:17 +01:00
}
static void test_UrlHash ( void )
{
hash_url ( TEST_URL_1 ) ;
hash_url ( TEST_URL_2 ) ;
hash_url ( TEST_URL_3 ) ;
}
2003-10-08 00:54:17 +02:00
static void test_url_part ( const char * szUrl , DWORD dwPart , DWORD dwFlags , const char * szExpected )
2003-01-09 01:50:17 +01:00
{
CHAR szPart [ INTERNET_MAX_URL_LENGTH ] ;
WCHAR wszPart [ INTERNET_MAX_URL_LENGTH ] ;
LPWSTR wszUrl = GetWideString ( szUrl ) ;
LPWSTR wszConvertedPart ;
DWORD dwSize ;
dwSize = INTERNET_MAX_URL_LENGTH ;
2004-03-16 02:07:28 +01:00
ok ( UrlGetPartA ( szUrl , szPart , & dwSize , dwPart , dwFlags ) = = S_OK , " UrlGetPartA for \" %s \" part 0x%08lx didn't return S_OK but \" %s \" \n " , szUrl , dwPart , szPart ) ;
2003-01-09 01:50:17 +01:00
dwSize = INTERNET_MAX_URL_LENGTH ;
2004-01-27 21:13:03 +01:00
ok ( UrlGetPartW ( wszUrl , wszPart , & dwSize , dwPart , dwFlags ) = = S_OK , " UrlGetPartW didn't return S_OK \n " ) ;
2003-01-09 01:50:17 +01:00
wszConvertedPart = GetWideString ( szPart ) ;
2006-05-24 18:05:09 +02:00
ok ( lstrcmpW ( wszPart , wszConvertedPart ) = = 0 , " Strings didn't match between ascii and unicode UrlGetPart! \n " ) ;
2003-01-09 01:50:17 +01:00
FreeWideString ( wszUrl ) ;
FreeWideString ( wszConvertedPart ) ;
2003-09-25 22:29:40 +02:00
/* Note that v6.0 and later don't return '?' with the query */
ok ( strcmp ( szPart , szExpected ) = = 0 | |
( * szExpected = = ' ? ' & & ! strcmp ( szPart , szExpected + 1 ) ) ,
2004-01-27 21:13:03 +01:00
" Expected %s, but got %s \n " , szExpected , szPart ) ;
2003-01-09 01:50:17 +01:00
}
static void test_UrlGetPart ( void )
{
2006-06-21 12:47:15 +02:00
CHAR szPart [ INTERNET_MAX_URL_LENGTH ] ;
DWORD dwSize ;
HRESULT res ;
dwSize = sizeof szPart ;
szPart [ 0 ] = ' x ' ; szPart [ 1 ] = 0 ;
res = UrlGetPartA ( " hi " , szPart , & dwSize , URL_PART_SCHEME , 0 ) ;
todo_wine {
ok ( res = = S_FALSE , " UrlGetPartA( \" hi \" ) returned %08lX \n " , res ) ;
ok ( szPart [ 0 ] = = 0 , " UrlGetPartA( \" hi \" ) return \" %s \" instead of \" \" \n " , szPart ) ;
}
dwSize = sizeof szPart ;
szPart [ 0 ] = ' x ' ; szPart [ 1 ] = 0 ;
res = UrlGetPartA ( " hi " , szPart , & dwSize , URL_PART_QUERY , 0 ) ;
todo_wine {
ok ( res = = S_FALSE , " UrlGetPartA( \" hi \" ) returned %08lX \n " , res ) ;
ok ( szPart [ 0 ] = = 0 , " UrlGetPartA( \" hi \" ) return \" %s \" instead of \" \" \n " , szPart ) ;
}
2003-01-09 01:50:17 +01:00
test_url_part ( TEST_URL_3 , URL_PART_HOSTNAME , 0 , " localhost " ) ;
test_url_part ( TEST_URL_3 , URL_PART_PORT , 0 , " 21 " ) ;
test_url_part ( TEST_URL_3 , URL_PART_USERNAME , 0 , " foo " ) ;
test_url_part ( TEST_URL_3 , URL_PART_PASSWORD , 0 , " bar " ) ;
test_url_part ( TEST_URL_3 , URL_PART_SCHEME , 0 , " http " ) ;
test_url_part ( TEST_URL_3 , URL_PART_QUERY , 0 , " ?query=x&return=y " ) ;
}
2004-03-16 02:07:28 +01:00
static void test_url_escape ( const char * szUrl , DWORD dwFlags , HRESULT dwExpectReturn , const char * szExpectUrl )
{
CHAR szReturnUrl [ INTERNET_MAX_URL_LENGTH ] ;
DWORD dwEscaped ;
2004-10-04 21:08:50 +02:00
WCHAR ret_urlW [ INTERNET_MAX_URL_LENGTH ] ;
WCHAR * urlW , * expected_urlW ;
2004-03-16 02:07:28 +01:00
dwEscaped = INTERNET_MAX_URL_LENGTH ;
2004-10-04 21:08:50 +02:00
ok ( UrlEscapeA ( szUrl , szReturnUrl , & dwEscaped , dwFlags ) = = dwExpectReturn , " UrlEscapeA didn't return 0x%08lx from \" %s \" \n " , dwExpectReturn , szUrl ) ;
ok ( strcmp ( szReturnUrl , szExpectUrl ) = = 0 , " Expected \" %s \" , but got \" %s \" from \" %s \" \n " , szExpectUrl , szReturnUrl , szUrl ) ;
dwEscaped = INTERNET_MAX_URL_LENGTH ;
urlW = GetWideString ( szUrl ) ;
expected_urlW = GetWideString ( szExpectUrl ) ;
ok ( UrlEscapeW ( urlW , ret_urlW , & dwEscaped , dwFlags ) = = dwExpectReturn , " UrlEscapeW didn't return 0x%08lx from \" %s \" \n " , dwExpectReturn , szUrl ) ;
WideCharToMultiByte ( CP_ACP , 0 , ret_urlW , - 1 , szReturnUrl , INTERNET_MAX_URL_LENGTH , 0 , 0 ) ;
2006-05-24 18:05:09 +02:00
ok ( lstrcmpW ( ret_urlW , expected_urlW ) = = 0 , " Expected \" %s \" , but got \" %s \" from \" %s \" flags %08lx \n " , szExpectUrl , szReturnUrl , szUrl , dwFlags ) ;
2004-10-04 21:08:50 +02:00
FreeWideString ( urlW ) ;
FreeWideString ( expected_urlW ) ;
2004-03-16 02:07:28 +01:00
}
2004-10-05 20:31:58 +02:00
2004-03-03 21:11:46 +01:00
static void test_url_canonicalize ( const char * szUrl , DWORD dwFlags , HRESULT dwExpectReturn , const char * szExpectUrl )
{
CHAR szReturnUrl [ INTERNET_MAX_URL_LENGTH ] ;
WCHAR wszReturnUrl [ INTERNET_MAX_URL_LENGTH ] ;
LPWSTR wszUrl = GetWideString ( szUrl ) ;
LPWSTR wszExpectUrl = GetWideString ( szExpectUrl ) ;
LPWSTR wszConvertedUrl ;
DWORD dwSize ;
dwSize = INTERNET_MAX_URL_LENGTH ;
2005-05-23 18:23:02 +02:00
ok ( UrlCanonicalizeA ( szUrl , NULL , & dwSize , dwFlags ) ! = dwExpectReturn , " Unexpected return for NULL buffer \n " ) ;
2004-03-03 21:11:46 +01:00
ok ( UrlCanonicalizeA ( szUrl , szReturnUrl , & dwSize , dwFlags ) = = dwExpectReturn , " UrlCanonicalizeA didn't return 0x%08lx \n " , dwExpectReturn ) ;
2006-07-29 16:11:31 +02:00
ok ( strcmp ( szReturnUrl , szExpectUrl ) = = 0 , " UrlCanonicalizeA dwFlags 0x%08lx Expected \" %s \" , but got \" %s \" \n " , dwFlags , szExpectUrl , szReturnUrl ) ;
2004-03-16 02:07:28 +01:00
2004-03-03 21:11:46 +01:00
dwSize = INTERNET_MAX_URL_LENGTH ;
2005-05-23 18:23:02 +02:00
ok ( UrlCanonicalizeW ( wszUrl , NULL , & dwSize , dwFlags ) ! = dwExpectReturn , " Unexpected return for NULL buffer \n " ) ;
2004-03-03 21:11:46 +01:00
ok ( UrlCanonicalizeW ( wszUrl , wszReturnUrl , & dwSize , dwFlags ) = = dwExpectReturn , " UrlCanonicalizeW didn't return 0x%08lx \n " , dwExpectReturn ) ;
wszConvertedUrl = GetWideString ( szReturnUrl ) ;
2006-05-24 18:05:09 +02:00
ok ( lstrcmpW ( wszReturnUrl , wszConvertedUrl ) = = 0 , " Strings didn't match between ascii and unicode UrlCanonicalize! \n " ) ;
2004-03-03 21:11:46 +01:00
FreeWideString ( wszConvertedUrl ) ;
FreeWideString ( wszUrl ) ;
FreeWideString ( wszExpectUrl ) ;
}
2004-03-16 02:07:28 +01:00
static void test_UrlEscape ( void )
{
2004-08-09 20:52:18 +02:00
unsigned int i ;
2004-03-16 02:07:28 +01:00
for ( i = 0 ; i < sizeof ( TEST_ESCAPE ) / sizeof ( TEST_ESCAPE [ 0 ] ) ; i + + ) {
test_url_escape ( TEST_ESCAPE [ i ] . url , TEST_ESCAPE [ i ] . flags ,
TEST_ESCAPE [ i ] . expectret , TEST_ESCAPE [ i ] . expecturl ) ;
}
}
2004-03-03 21:11:46 +01:00
static void test_UrlCanonicalize ( void )
{
2004-08-09 20:52:18 +02:00
unsigned int i ;
2006-06-21 12:47:15 +02:00
CHAR szReturnUrl [ INTERNET_MAX_URL_LENGTH ] ;
DWORD dwSize ;
2004-03-03 21:11:46 +01:00
for ( i = 0 ; i < sizeof ( TEST_CANONICALIZE ) / sizeof ( TEST_CANONICALIZE [ 0 ] ) ; i + + ) {
test_url_canonicalize ( TEST_CANONICALIZE [ i ] . url , TEST_CANONICALIZE [ i ] . flags ,
TEST_CANONICALIZE [ i ] . expectret , TEST_CANONICALIZE [ i ] . expecturl ) ;
}
2006-06-21 12:47:15 +02:00
/* move to TEST_CANONICALIZE when fixed */
dwSize = sizeof szReturnUrl ;
ok ( UrlCanonicalizeA ( " c: \\ tests \\ foo bar " , szReturnUrl , & dwSize , 0 ) = = S_OK , " UrlCanonicalizeA didn't return 0x%08lx \n " , S_OK ) ;
todo_wine {
ok ( strcmp ( szReturnUrl , " file:///c:/tests/foo%20bar " ) = = 0 , " UrlCanonicalizeA got %s \n " , szReturnUrl ) ;
}
2004-03-03 21:11:46 +01:00
}
2004-04-28 01:29:01 +02:00
static void test_url_combine ( const char * szUrl1 , const char * szUrl2 , DWORD dwFlags , HRESULT dwExpectReturn , const char * szExpectUrl )
{
HRESULT hr ;
CHAR szReturnUrl [ INTERNET_MAX_URL_LENGTH ] ;
WCHAR wszReturnUrl [ INTERNET_MAX_URL_LENGTH ] ;
LPWSTR wszUrl1 = GetWideString ( szUrl1 ) ;
LPWSTR wszUrl2 = GetWideString ( szUrl2 ) ;
LPWSTR wszExpectUrl = GetWideString ( szExpectUrl ) ;
LPWSTR wszConvertedUrl ;
DWORD dwSize ;
DWORD dwExpectLen = lstrlen ( szExpectUrl ) ;
hr = UrlCombineA ( szUrl1 , szUrl2 , NULL , NULL , dwFlags ) ;
ok ( hr = = E_INVALIDARG , " UrlCombineA returned 0x%08lx, expected 0x%08lx \n " , hr , E_INVALIDARG ) ;
dwSize = 0 ;
hr = UrlCombineA ( szUrl1 , szUrl2 , NULL , & dwSize , dwFlags ) ;
ok ( hr = = E_POINTER , " Checking length of string, return was 0x%08lx, expected 0x%08lx \n " , hr , E_POINTER ) ;
ok ( dwSize = = dwExpectLen + 1 , " Got length %ld, expected %ld \n " , dwSize , dwExpectLen + 1 ) ;
dwSize - - ;
hr = UrlCombineA ( szUrl1 , szUrl2 , szReturnUrl , & dwSize , dwFlags ) ;
ok ( hr = = E_POINTER , " UrlCombineA returned 0x%08lx, expected 0x%08lx \n " , hr , E_POINTER ) ;
ok ( dwSize = = dwExpectLen + 1 , " Got length %ld, expected %ld \n " , dwSize , dwExpectLen + 1 ) ;
hr = UrlCombineA ( szUrl1 , szUrl2 , szReturnUrl , & dwSize , dwFlags ) ;
ok ( hr = = dwExpectReturn , " UrlCombineA returned 0x%08lx, expected 0x%08lx \n " , hr , dwExpectReturn ) ;
ok ( dwSize = = dwExpectLen , " Got length %ld, expected %ld \n " , dwSize , dwExpectLen ) ;
if ( SUCCEEDED ( hr ) ) {
ok ( strcmp ( szReturnUrl , szExpectUrl ) = = 0 , " Expected %s, but got %s \n " , szExpectUrl , szReturnUrl ) ;
}
dwSize = 0 ;
hr = UrlCombineW ( wszUrl1 , wszUrl2 , NULL , & dwSize , dwFlags ) ;
ok ( hr = = E_POINTER , " Checking length of string, return was 0x%08lx, expected 0x%08lx \n " , hr , E_POINTER ) ;
ok ( dwSize = = dwExpectLen + 1 , " Got length %ld, expected %ld \n " , dwSize , dwExpectLen + 1 ) ;
dwSize - - ;
hr = UrlCombineW ( wszUrl1 , wszUrl2 , wszReturnUrl , & dwSize , dwFlags ) ;
ok ( hr = = E_POINTER , " UrlCombineA returned 0x%08lx, expected 0x%08lx \n " , hr , E_POINTER ) ;
ok ( dwSize = = dwExpectLen + 1 , " Got length %ld, expected %ld \n " , dwSize , dwExpectLen + 1 ) ;
hr = UrlCombineW ( wszUrl1 , wszUrl2 , wszReturnUrl , & dwSize , dwFlags ) ;
ok ( hr = = dwExpectReturn , " UrlCombineW returned 0x%08lx, expected 0x%08lx \n " , hr , dwExpectReturn ) ;
ok ( dwSize = = dwExpectLen , " Got length %ld, expected %ld \n " , dwSize , dwExpectLen ) ;
if ( SUCCEEDED ( hr ) ) {
wszConvertedUrl = GetWideString ( szReturnUrl ) ;
2006-05-24 18:05:09 +02:00
ok ( lstrcmpW ( wszReturnUrl , wszConvertedUrl ) = = 0 , " Strings didn't match between ascii and unicode UrlCombine! \n " ) ;
2004-04-28 01:29:01 +02:00
FreeWideString ( wszConvertedUrl ) ;
}
FreeWideString ( wszUrl1 ) ;
FreeWideString ( wszUrl2 ) ;
FreeWideString ( wszExpectUrl ) ;
}
static void test_UrlCombine ( void )
{
2004-08-09 20:52:18 +02:00
unsigned int i ;
2004-04-28 01:29:01 +02:00
for ( i = 0 ; i < sizeof ( TEST_COMBINE ) / sizeof ( TEST_COMBINE [ 0 ] ) ; i + + ) {
test_url_combine ( TEST_COMBINE [ i ] . url1 , TEST_COMBINE [ i ] . url2 , TEST_COMBINE [ i ] . flags ,
TEST_COMBINE [ i ] . expectret , TEST_COMBINE [ i ] . expecturl ) ;
}
}
2004-10-05 20:31:58 +02:00
static void test_UrlCreateFromPath ( void )
{
2005-03-14 11:09:53 +01:00
size_t i ;
2004-10-05 20:31:58 +02:00
char ret_url [ INTERNET_MAX_URL_LENGTH ] ;
DWORD len , ret ;
WCHAR ret_urlW [ INTERNET_MAX_URL_LENGTH ] ;
WCHAR * pathW , * urlW ;
for ( i = 0 ; i < sizeof ( TEST_URLFROMPATH ) / sizeof ( TEST_URLFROMPATH [ 0 ] ) ; i + + ) {
len = INTERNET_MAX_URL_LENGTH ;
ret = UrlCreateFromPathA ( TEST_URLFROMPATH [ i ] . path , ret_url , & len , 0 ) ;
ok ( ret = = TEST_URLFROMPATH [ i ] . ret , " ret %08lx from path %s \n " , ret , TEST_URLFROMPATH [ i ] . path ) ;
ok ( ! lstrcmpi ( ret_url , TEST_URLFROMPATH [ i ] . url ) , " url %s from path %s \n " , ret_url , TEST_URLFROMPATH [ i ] . path ) ;
ok ( len = = strlen ( ret_url ) , " ret len %ld from path %s \n " , len , TEST_URLFROMPATH [ i ] . path ) ;
len = INTERNET_MAX_URL_LENGTH ;
pathW = GetWideString ( TEST_URLFROMPATH [ i ] . path ) ;
urlW = GetWideString ( TEST_URLFROMPATH [ i ] . url ) ;
ret = UrlCreateFromPathW ( pathW , ret_urlW , & len , 0 ) ;
WideCharToMultiByte ( CP_ACP , 0 , ret_urlW , - 1 , ret_url , sizeof ( ret_url ) , 0 , 0 ) ;
2005-03-14 11:09:53 +01:00
ok ( ret = = TEST_URLFROMPATH [ i ] . ret , " ret %08lx from path L \" %s \" , expected %08lx \n " ,
ret , TEST_URLFROMPATH [ i ] . path , TEST_URLFROMPATH [ i ] . ret ) ;
2004-10-05 20:31:58 +02:00
ok ( ! lstrcmpiW ( ret_urlW , urlW ) , " got %s expected %s from path L \" %s \" \n " , ret_url , TEST_URLFROMPATH [ i ] . url , TEST_URLFROMPATH [ i ] . path ) ;
2006-05-24 18:05:09 +02:00
ok ( len = = lstrlenW ( ret_urlW ) , " ret len %ld from path L \" %s \" \n " , len , TEST_URLFROMPATH [ i ] . path ) ;
2004-10-05 20:31:58 +02:00
FreeWideString ( urlW ) ;
FreeWideString ( pathW ) ;
}
}
2005-01-03 18:08:40 +01:00
static void test_UrlIs ( void )
{
BOOL ret ;
2005-03-14 11:09:53 +01:00
size_t i ;
2005-03-21 11:54:35 +01:00
WCHAR wurl [ 80 ] ;
2005-01-03 18:08:40 +01:00
for ( i = 0 ; i < sizeof ( TEST_PATH_IS_URL ) / sizeof ( TEST_PATH_IS_URL [ 0 ] ) ; i + + ) {
2005-03-21 11:54:35 +01:00
MultiByteToWideChar ( CP_ACP , 0 , TEST_PATH_IS_URL [ i ] . path , - 1 , wurl , 80 ) ;
2005-01-03 18:08:40 +01:00
ret = UrlIsA ( TEST_PATH_IS_URL [ i ] . path , URLIS_URL ) ;
ok ( ret = = TEST_PATH_IS_URL [ i ] . expect ,
" returned %d from path %s, expected %d \n " , ret , TEST_PATH_IS_URL [ i ] . path ,
TEST_PATH_IS_URL [ i ] . expect ) ;
2005-03-21 11:54:35 +01:00
ret = UrlIsW ( wurl , URLIS_URL ) ;
ok ( ret = = TEST_PATH_IS_URL [ i ] . expect ,
" returned %d from path (UrlIsW) %s, expected %d \n " , ret , TEST_PATH_IS_URL [ i ] . path ,
TEST_PATH_IS_URL [ i ] . expect ) ;
}
for ( i = 0 ; i < sizeof ( TEST_URLIS_ATTRIBS ) / sizeof ( TEST_URLIS_ATTRIBS [ 0 ] ) ; i + + ) {
MultiByteToWideChar ( CP_ACP , 0 , TEST_URLIS_ATTRIBS [ i ] . url , - 1 , wurl , 80 ) ;
ret = UrlIsA ( TEST_URLIS_ATTRIBS [ i ] . url , URLIS_OPAQUE ) ;
ok ( ret = = TEST_URLIS_ATTRIBS [ i ] . expectOpaque ,
" returned %d for URLIS_OPAQUE, url \" %s \" , expected %d \n " , ret , TEST_URLIS_ATTRIBS [ i ] . url ,
TEST_URLIS_ATTRIBS [ i ] . expectOpaque ) ;
ret = UrlIsA ( TEST_URLIS_ATTRIBS [ i ] . url , URLIS_FILEURL ) ;
ok ( ret = = TEST_URLIS_ATTRIBS [ i ] . expectFile ,
" returned %d for URLIS_FILEURL, url \" %s \" , expected %d \n " , ret , TEST_URLIS_ATTRIBS [ i ] . url ,
TEST_URLIS_ATTRIBS [ i ] . expectFile ) ;
ret = UrlIsW ( wurl , URLIS_OPAQUE ) ;
ok ( ret = = TEST_URLIS_ATTRIBS [ i ] . expectOpaque ,
" returned %d for URLIS_OPAQUE (UrlIsW), url \" %s \" , expected %d \n " , ret , TEST_URLIS_ATTRIBS [ i ] . url ,
TEST_URLIS_ATTRIBS [ i ] . expectOpaque ) ;
ret = UrlIsW ( wurl , URLIS_FILEURL ) ;
ok ( ret = = TEST_URLIS_ATTRIBS [ i ] . expectFile ,
" returned %d for URLIS_FILEURL (UrlIsW), url \" %s \" , expected %d \n " , ret , TEST_URLIS_ATTRIBS [ i ] . url ,
TEST_URLIS_ATTRIBS [ i ] . expectFile ) ;
2005-01-03 18:08:40 +01:00
}
}
2004-10-05 20:31:58 +02:00
static void test_UrlUnescape ( void )
{
CHAR szReturnUrl [ INTERNET_MAX_URL_LENGTH ] ;
WCHAR ret_urlW [ INTERNET_MAX_URL_LENGTH ] ;
WCHAR * urlW , * expected_urlW ;
DWORD dwEscaped ;
2005-03-14 11:09:53 +01:00
size_t i ;
2006-02-16 12:08:48 +01:00
static char inplace [ ] = " file:///C:/Program%20Files " ;
static WCHAR inplaceW [ ] = { ' f ' , ' i ' , ' l ' , ' e ' , ' : ' , ' / ' , ' / ' , ' / ' , ' C ' , ' : ' , ' / ' ,
' P ' , ' r ' , ' o ' , ' g ' , ' r ' , ' a ' , ' m ' , ' % ' , ' 2 ' , ' 0 ' , ' F ' , ' i ' , ' l ' , ' e ' , ' s ' , 0 } ;
2004-10-05 20:31:58 +02:00
for ( i = 0 ; i < sizeof ( TEST_URL_UNESCAPE ) / sizeof ( TEST_URL_UNESCAPE [ 0 ] ) ; i + + ) {
dwEscaped = INTERNET_MAX_URL_LENGTH ;
ok ( UrlUnescapeA ( TEST_URL_UNESCAPE [ i ] . url , szReturnUrl , & dwEscaped , 0 ) = = S_OK , " UrlEscapeA didn't return 0x%08lx from \" %s \" \n " , S_OK , TEST_URL_UNESCAPE [ i ] . url ) ;
ok ( strcmp ( szReturnUrl , TEST_URL_UNESCAPE [ i ] . expect ) = = 0 , " Expected \" %s \" , but got \" %s \" from \" %s \" \n " , TEST_URL_UNESCAPE [ i ] . expect , szReturnUrl , TEST_URL_UNESCAPE [ i ] . url ) ;
dwEscaped = INTERNET_MAX_URL_LENGTH ;
urlW = GetWideString ( TEST_URL_UNESCAPE [ i ] . url ) ;
expected_urlW = GetWideString ( TEST_URL_UNESCAPE [ i ] . expect ) ;
ok ( UrlUnescapeW ( urlW , ret_urlW , & dwEscaped , 0 ) = = S_OK , " UrlEscapeW didn't return 0x%08lx from \" %s \" \n " , S_OK , TEST_URL_UNESCAPE [ i ] . url ) ;
WideCharToMultiByte ( CP_ACP , 0 , ret_urlW , - 1 , szReturnUrl , INTERNET_MAX_URL_LENGTH , 0 , 0 ) ;
2006-05-24 18:05:09 +02:00
ok ( lstrcmpW ( ret_urlW , expected_urlW ) = = 0 , " Expected \" %s \" , but got \" %s \" from \" %s \" flags %08lx \n " , TEST_URL_UNESCAPE [ i ] . expect , szReturnUrl , TEST_URL_UNESCAPE [ i ] . url , 0L ) ;
2004-10-05 20:31:58 +02:00
FreeWideString ( urlW ) ;
FreeWideString ( expected_urlW ) ;
}
2006-02-16 12:08:48 +01:00
dwEscaped = sizeof ( inplace ) ;
ok ( UrlUnescapeA ( inplace , NULL , & dwEscaped , URL_UNESCAPE_INPLACE ) = = S_OK , " UrlUnescapeA failed unexpectedly \n " ) ;
dwEscaped = sizeof ( inplaceW ) ;
ok ( UrlUnescapeW ( inplaceW , NULL , & dwEscaped , URL_UNESCAPE_INPLACE ) = = S_OK , " UrlUnescapeW failed unexpectedly \n " ) ;
2004-10-05 20:31:58 +02:00
}
2004-09-25 02:29:47 +02:00
static void test_PathSearchAndQualify ( void )
{
WCHAR path1 [ ] = { ' c ' , ' : ' , ' \\ ' , ' f ' , ' o ' , ' o ' , 0 } ;
WCHAR expect1 [ ] = { ' c ' , ' : ' , ' \\ ' , ' f ' , ' o ' , ' o ' , 0 } ;
WCHAR path2 [ ] = { ' c ' , ' : ' , ' f ' , ' o ' , ' o ' , 0 } ;
WCHAR c_drive [ ] = { ' c ' , ' : ' , 0 } ;
WCHAR foo [ ] = { ' f ' , ' o ' , ' o ' , 0 } ;
WCHAR path3 [ ] = { ' \\ ' , ' f ' , ' o ' , ' o ' , 0 } ;
WCHAR winini [ ] = { ' w ' , ' i ' , ' n ' , ' . ' , ' i ' , ' n ' , ' i ' , 0 } ;
WCHAR out [ MAX_PATH ] ;
WCHAR cur_dir [ MAX_PATH ] ;
WCHAR dot [ ] = { ' . ' , 0 } ;
/* c:\foo */
ok ( PathSearchAndQualifyW ( path1 , out , MAX_PATH ) ! = 0 ,
" PathSearchAndQualify rets 0 \n " ) ;
ok ( ! lstrcmpiW ( out , expect1 ) , " strings don't match \n " ) ;
/* c:foo */
ok ( PathSearchAndQualifyW ( path2 , out , MAX_PATH ) ! = 0 ,
" PathSearchAndQualify rets 0 \n " ) ;
GetFullPathNameW ( c_drive , MAX_PATH , cur_dir , NULL ) ;
PathAddBackslashW ( cur_dir ) ;
2006-05-24 18:05:09 +02:00
lstrcatW ( cur_dir , foo ) ;
2004-09-25 02:29:47 +02:00
ok ( ! lstrcmpiW ( out , cur_dir ) , " strings don't match \n " ) ;
/* foo */
ok ( PathSearchAndQualifyW ( foo , out , MAX_PATH ) ! = 0 ,
" PathSearchAndQualify rets 0 \n " ) ;
GetFullPathNameW ( dot , MAX_PATH , cur_dir , NULL ) ;
PathAddBackslashW ( cur_dir ) ;
2006-05-24 18:05:09 +02:00
lstrcatW ( cur_dir , foo ) ;
2004-09-25 02:29:47 +02:00
ok ( ! lstrcmpiW ( out , cur_dir ) , " strings don't match \n " ) ;
/* \foo */
ok ( PathSearchAndQualifyW ( path3 , out , MAX_PATH ) ! = 0 ,
" PathSearchAndQualify rets 0 \n " ) ;
GetFullPathNameW ( dot , MAX_PATH , cur_dir , NULL ) ;
2006-05-24 18:05:09 +02:00
lstrcpyW ( cur_dir + 2 , path3 ) ;
2004-09-25 02:29:47 +02:00
ok ( ! lstrcmpiW ( out , cur_dir ) , " strings don't match \n " ) ;
/* win.ini */
ok ( PathSearchAndQualifyW ( winini , out , MAX_PATH ) ! = 0 ,
" PathSearchAndQualify rets 0 \n " ) ;
if ( ! SearchPathW ( NULL , winini , NULL , MAX_PATH , cur_dir , NULL ) )
GetFullPathNameW ( winini , MAX_PATH , cur_dir , NULL ) ;
ok ( ! lstrcmpiW ( out , cur_dir ) , " strings don't match \n " ) ;
}
2004-10-05 20:31:58 +02:00
static void test_PathCreateFromUrl ( void )
{
2005-03-14 11:09:53 +01:00
size_t i ;
2004-10-05 20:31:58 +02:00
char ret_path [ INTERNET_MAX_URL_LENGTH ] ;
DWORD len , ret ;
WCHAR ret_pathW [ INTERNET_MAX_URL_LENGTH ] ;
WCHAR * pathW , * urlW ;
for ( i = 0 ; i < sizeof ( TEST_PATHFROMURL ) / sizeof ( TEST_PATHFROMURL [ 0 ] ) ; i + + ) {
len = INTERNET_MAX_URL_LENGTH ;
ret = PathCreateFromUrlA ( TEST_PATHFROMURL [ i ] . url , ret_path , & len , 0 ) ;
ok ( ret = = TEST_PATHFROMURL [ i ] . ret , " ret %08lx from url %s \n " , ret , TEST_PATHFROMURL [ i ] . url ) ;
if ( TEST_PATHFROMURL [ i ] . path ) {
ok ( ! lstrcmpi ( ret_path , TEST_PATHFROMURL [ i ] . path ) , " got %s expected %s from url %s \n " , ret_path , TEST_PATHFROMURL [ i ] . path , TEST_PATHFROMURL [ i ] . url ) ;
ok ( len = = strlen ( ret_path ) , " ret len %ld from url %s \n " , len , TEST_PATHFROMURL [ i ] . url ) ;
}
len = INTERNET_MAX_URL_LENGTH ;
pathW = GetWideString ( TEST_PATHFROMURL [ i ] . path ) ;
urlW = GetWideString ( TEST_PATHFROMURL [ i ] . url ) ;
ret = PathCreateFromUrlW ( urlW , ret_pathW , & len , 0 ) ;
WideCharToMultiByte ( CP_ACP , 0 , ret_pathW , - 1 , ret_path , sizeof ( ret_path ) , 0 , 0 ) ;
ok ( ret = = TEST_PATHFROMURL [ i ] . ret , " ret %08lx from url L \" %s \" \n " , ret , TEST_PATHFROMURL [ i ] . url ) ;
if ( TEST_PATHFROMURL [ i ] . path ) {
ok ( ! lstrcmpiW ( ret_pathW , pathW ) , " got %s expected %s from url L \" %s \" \n " , ret_path , TEST_PATHFROMURL [ i ] . path , TEST_PATHFROMURL [ i ] . url ) ;
2006-05-24 18:05:09 +02:00
ok ( len = = lstrlenW ( ret_pathW ) , " ret len %ld from url L \" %s \" \n " , len , TEST_PATHFROMURL [ i ] . url ) ;
2004-10-05 20:31:58 +02:00
}
FreeWideString ( urlW ) ;
FreeWideString ( pathW ) ;
}
}
static void test_PathIsUrl ( void )
{
2005-03-14 11:09:53 +01:00
size_t i ;
2004-10-05 20:31:58 +02:00
BOOL ret ;
for ( i = 0 ; i < sizeof ( TEST_PATH_IS_URL ) / sizeof ( TEST_PATH_IS_URL [ 0 ] ) ; i + + ) {
ret = PathIsURLA ( TEST_PATH_IS_URL [ i ] . path ) ;
ok ( ret = = TEST_PATH_IS_URL [ i ] . expect ,
" returned %d from path %s, expected %d \n " , ret , TEST_PATH_IS_URL [ i ] . path ,
TEST_PATH_IS_URL [ i ] . expect ) ;
}
}
2005-02-03 14:34:05 +01:00
static const DWORD SHELL_charclass [ ] =
{
0x00000000 , 0x00000000 , 0x00000000 , 0x00000000 ,
0x00000000 , 0x00000000 , 0x00000000 , 0x00000000 ,
0x00000000 , 0x00000000 , 0x00000000 , 0x00000000 ,
0x00000000 , 0x00000000 , 0x00000000 , 0x00000000 ,
0x00000000 , 0x00000000 , 0x00000000 , 0x00000000 ,
0x00000000 , 0x00000000 , 0x00000000 , 0x00000000 ,
0x00000000 , 0x00000000 , 0x00000000 , 0x00000000 ,
0x00000000 , 0x00000000 , 0x00000000 , 0x00000000 ,
0x00000080 , 0x00000100 , 0x00000200 , 0x00000100 ,
0x00000100 , 0x00000100 , 0x00000100 , 0x00000100 ,
0x00000100 , 0x00000100 , 0x00000002 , 0x00000100 ,
0x00000040 , 0x00000100 , 0x00000004 , 0x00000000 ,
0x00000100 , 0x00000100 , 0x00000100 , 0x00000100 ,
0x00000100 , 0x00000100 , 0x00000100 , 0x00000100 ,
0x00000100 , 0x00000100 , 0x00000010 , 0x00000020 ,
0x00000000 , 0x00000100 , 0x00000000 , 0x00000001 ,
0x00000100 , 0xffffffff , 0xffffffff , 0xffffffff ,
0xffffffff , 0xffffffff , 0xffffffff , 0xffffffff ,
0xffffffff , 0xffffffff , 0xffffffff , 0xffffffff ,
0xffffffff , 0xffffffff , 0xffffffff , 0xffffffff ,
0xffffffff , 0xffffffff , 0xffffffff , 0xffffffff ,
0xffffffff , 0xffffffff , 0xffffffff , 0xffffffff ,
0xffffffff , 0xffffffff , 0xffffffff , 0x00000100 ,
0x00000008 , 0x00000100 , 0x00000100 , 0x00000100 ,
0x00000100 , 0xffffffff , 0xffffffff , 0xffffffff ,
0xffffffff , 0xffffffff , 0xffffffff , 0xffffffff ,
0xffffffff , 0xffffffff , 0xffffffff , 0xffffffff ,
0xffffffff , 0xffffffff , 0xffffffff , 0xffffffff ,
0xffffffff , 0xffffffff , 0xffffffff , 0xffffffff ,
0xffffffff , 0xffffffff , 0xffffffff , 0xffffffff ,
0xffffffff , 0xffffffff , 0xffffffff , 0x00000100 ,
0x00000000 , 0x00000100 , 0x00000100
} ;
static void test_PathIsValidCharA ( void )
{
BOOL ret ;
unsigned int c ;
2005-02-10 18:10:43 +01:00
ret = pPathIsValidCharA ( 0x7f , 0 ) ;
2005-02-03 14:34:05 +01:00
ok ( ! ret , " PathIsValidCharA succeeded: 0x%08lx \n " , ( DWORD ) ret ) ;
2005-02-10 18:10:43 +01:00
ret = pPathIsValidCharA ( 0x7f , 1 ) ;
2005-02-03 14:34:05 +01:00
ok ( ! ret , " PathIsValidCharA succeeded: 0x%08lx \n " , ( DWORD ) ret ) ;
for ( c = 0 ; c < 0x7f ; c + + )
{
2005-02-10 18:10:43 +01:00
ret = pPathIsValidCharA ( c , ~ 0U ) ;
2005-02-03 14:34:05 +01:00
ok ( ret = = SHELL_charclass [ c ] | | ( ret = = 1 & & SHELL_charclass [ c ] = = 0xffffffff ) ,
" PathIsValidCharA failed: 0x%02x got 0x%08lx expected 0x%08lx \n " ,
c , ( DWORD ) ret , SHELL_charclass [ c ] ) ;
}
for ( c = 0x7f ; c < = 0xff ; c + + )
{
2005-02-10 18:10:43 +01:00
ret = pPathIsValidCharA ( c , ~ 0U ) ;
2005-02-03 14:34:05 +01:00
ok ( ret = = 0x00000100 ,
" PathIsValidCharA failed: 0x%02x got 0x%08lx expected 0x00000100 \n " ,
c , ( DWORD ) ret ) ;
}
}
static void test_PathIsValidCharW ( void )
{
BOOL ret ;
2005-10-31 11:02:24 +01:00
unsigned int c , err_count = 0 ;
2005-02-03 14:34:05 +01:00
2005-02-10 18:10:43 +01:00
ret = pPathIsValidCharW ( 0x7f , 0 ) ;
2005-02-03 14:34:05 +01:00
ok ( ! ret , " PathIsValidCharW succeeded: 0x%08lx \n " , ( DWORD ) ret ) ;
2005-02-10 18:10:43 +01:00
ret = pPathIsValidCharW ( 0x7f , 1 ) ;
2005-02-03 14:34:05 +01:00
ok ( ! ret , " PathIsValidCharW succeeded: 0x%08lx \n " , ( DWORD ) ret ) ;
for ( c = 0 ; c < 0x7f ; c + + )
{
2005-02-10 18:10:43 +01:00
ret = pPathIsValidCharW ( c , ~ 0U ) ;
2005-02-03 14:34:05 +01:00
ok ( ret = = SHELL_charclass [ c ] | | ( ret = = 1 & & SHELL_charclass [ c ] = = 0xffffffff ) ,
" PathIsValidCharW failed: 0x%02x got 0x%08lx expected 0x%08lx \n " ,
c , ( DWORD ) ret , SHELL_charclass [ c ] ) ;
}
for ( c = 0x007f ; c < = 0xffff ; c + + )
{
2005-02-10 18:10:43 +01:00
ret = pPathIsValidCharW ( c , ~ 0U ) ;
2005-02-03 14:34:05 +01:00
ok ( ret = = 0x00000100 ,
" PathIsValidCharW failed: 0x%02x got 0x%08lx expected 0x00000100 \n " ,
c , ( DWORD ) ret ) ;
2005-10-31 11:02:24 +01:00
if ( ret ! = 0x00000100 )
{
if ( + + err_count > 100 ) {
trace ( " skipping rest of PathIsValidCharW tests "
" because of the current number of errors \n " ) ;
break ;
}
}
2005-02-03 14:34:05 +01:00
}
}
2005-03-14 11:09:53 +01:00
static void test_PathMakePretty ( void )
{
char buff [ MAX_PATH ] ;
ok ( PathMakePrettyA ( NULL ) = = FALSE , " PathMakePretty: NULL path succeeded \n " ) ;
buff [ 0 ] = ' \0 ' ;
ok ( PathMakePrettyA ( buff ) = = TRUE , " PathMakePretty: Empty path failed \n " ) ;
strcpy ( buff , " C: \\ A LONG FILE NAME WITH \\ SPACES.TXT " ) ;
ok ( PathMakePrettyA ( buff ) = = TRUE , " PathMakePretty: Long UC name failed \n " ) ;
ok ( strcmp ( buff , " C: \\ a long file name with \\ spaces.txt " ) = = 0 ,
" PathMakePretty: Long UC name not changed \n " ) ;
strcpy ( buff , " C: \\ A LONG FILE NAME WITH \\ MixedCase.TXT " ) ;
ok ( PathMakePrettyA ( buff ) = = FALSE , " PathMakePretty: Long MC name succeeded \n " ) ;
ok ( strcmp ( buff , " C: \\ A LONG FILE NAME WITH \\ MixedCase.TXT " ) = = 0 ,
" PathMakePretty: Failed but modified path \n " ) ;
strcpy ( buff , " TEST " ) ;
ok ( PathMakePrettyA ( buff ) = = TRUE , " PathMakePretty: Short name failed \n " ) ;
ok ( strcmp ( buff , " Test " ) = = 0 , " PathMakePretty: 1st char lowercased %s \n " , buff ) ;
}
2006-04-11 20:55:25 +02:00
static void test_PathMatchSpec ( void )
{
static const char file [ ] = " c: \\ foo \\ bar \\ filename.ext " ;
static const char spec1 [ ] = " .ext " ;
static const char spec2 [ ] = " *.ext " ;
static const char spec3 [ ] = " *.ext " ;
static const char spec4 [ ] = " *.ext " ;
static const char spec5 [ ] = " * .ext " ;
static const char spec6 [ ] = " *. ext " ;
static const char spec7 [ ] = " * . ext " ;
static const char spec8 [ ] = " *.e?t " ;
static const char spec9 [ ] = " filename.ext " ;
static const char spec10 [ ] = " *bar \\ filename.ext " ;
static const char spec11 [ ] = " foo; *.ext " ;
static const char spec12 [ ] = " *.ext;*.bar " ;
static const char spec13 [ ] = " *bar* " ;
ok ( PathMatchSpecA ( file , spec1 ) = = FALSE , " PathMatchSpec: Spec1 failed \n " ) ;
ok ( PathMatchSpecA ( file , spec2 ) = = TRUE , " PathMatchSpec: Spec2 failed \n " ) ;
ok ( PathMatchSpecA ( file , spec3 ) = = FALSE , " PathMatchSpec: Spec3 failed \n " ) ;
2006-04-11 21:17:52 +02:00
ok ( PathMatchSpecA ( file , spec4 ) = = TRUE , " PathMatchSpec: Spec4 failed \n " ) ;
2006-04-11 20:55:25 +02:00
todo_wine ok ( PathMatchSpecA ( file , spec5 ) = = TRUE , " PathMatchSpec: Spec5 failed \n " ) ;
todo_wine ok ( PathMatchSpecA ( file , spec6 ) = = TRUE , " PathMatchSpec: Spec6 failed \n " ) ;
ok ( PathMatchSpecA ( file , spec7 ) = = FALSE , " PathMatchSpec: Spec7 failed \n " ) ;
ok ( PathMatchSpecA ( file , spec8 ) = = TRUE , " PathMatchSpec: Spec8 failed \n " ) ;
ok ( PathMatchSpecA ( file , spec9 ) = = FALSE , " PathMatchSpec: Spec9 failed \n " ) ;
ok ( PathMatchSpecA ( file , spec10 ) = = TRUE , " PathMatchSpec: Spec10 failed \n " ) ;
ok ( PathMatchSpecA ( file , spec11 ) = = TRUE , " PathMatchSpec: Spec11 failed \n " ) ;
ok ( PathMatchSpecA ( file , spec12 ) = = TRUE , " PathMatchSpec: Spec12 failed \n " ) ;
ok ( PathMatchSpecA ( file , spec13 ) = = TRUE , " PathMatchSpec: Spec13 failed \n " ) ;
}
2006-06-26 23:37:45 +02:00
static void test_PathCombineW ( void )
2006-06-23 15:21:02 +02:00
{
LPWSTR wszString , wszString2 ;
wszString2 = HeapAlloc ( GetProcessHeap ( ) , 0 , MAX_PATH * sizeof ( WCHAR ) ) ;
/* NULL test */
2006-06-26 23:37:45 +02:00
wszString = pPathCombineW ( NULL , NULL , NULL ) ;
ok ( wszString = = NULL , " Expected a NULL return \n " ) ;
2006-06-23 15:21:02 +02:00
2006-06-26 23:37:45 +02:00
/* 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
2006-06-23 15:21:02 +02:00
{
2006-06-26 23:37:45 +02:00
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 ( ) ) ;
2006-06-23 15:21:02 +02:00
}
2006-06-26 23:37:45 +02:00
/* try a directory longer than MAX_PATH */
SetLastError ( 0xdeadbeef ) ;
lstrcpyA ( dest , " control " ) ;
str = PathCombineA ( dest , too_long , " one \\ two \\ three " ) ;
todo_wine
2006-06-23 15:21:02 +02:00
{
2006-06-26 23:37:45 +02:00
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 ( ) ) ;
2006-06-23 15:21:02 +02:00
}
2006-06-26 23:37:45 +02:00
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 ( ) ) ;
2006-06-23 15:21:02 +02:00
}
2006-04-11 20:55:25 +02:00
2006-06-26 23:41:22 +02:00
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 ( ) ) ;
}
2006-06-27 22:05:30 +02:00
static void test_PathAppendA ( void )
{
char path [ MAX_PATH ] ;
char too_long [ LONG_LEN ] ;
char one [ HALF_LEN ] , two [ HALF_LEN ] ;
BOOL res ;
lstrcpy ( path , " C: \\ one " ) ;
/* try NULL pszMore */
SetLastError ( 0xdeadbeef ) ;
res = PathAppendA ( path , NULL ) ;
ok ( ! res , " Expected failure \n " ) ;
ok ( GetLastError ( ) = = 0xdeadbeef , " Expected 0xdeadbeef, got %ld \n " , GetLastError ( ) ) ;
ok ( ! lstrcmp ( path , " C: \\ one " ) , " Expected C: \\ one, got %s \n " , path ) ;
/* try empty pszMore */
SetLastError ( 0xdeadbeef ) ;
res = PathAppendA ( path , " " ) ;
ok ( res , " Expected success \n " ) ;
ok ( GetLastError ( ) = = 0xdeadbeef , " Expected 0xdeadbeef, got %ld \n " , GetLastError ( ) ) ;
ok ( ! lstrcmp ( path , " C: \\ one " ) , " Expected C: \\ one, got %s \n " , path ) ;
/* try NULL pszPath */
SetLastError ( 0xdeadbeef ) ;
res = PathAppendA ( NULL , " two \\ three " ) ;
ok ( ! res , " Expected failure \n " ) ;
ok ( GetLastError ( ) = = 0xdeadbeef , " Expected 0xdeadbeef, got %ld \n " , GetLastError ( ) ) ;
/* try empty pszPath */
path [ 0 ] = ' \0 ' ;
SetLastError ( 0xdeadbeef ) ;
res = PathAppendA ( path , " two \\ three " ) ;
ok ( res , " Expected success \n " ) ;
ok ( GetLastError ( ) = = 0xdeadbeef , " Expected 0xdeadbeef, got %ld \n " , GetLastError ( ) ) ;
ok ( ! lstrcmp ( path , " two \\ three " ) , " Expected \\ two \\ three, got %s \n " , path ) ;
/* try empty pszPath and empty pszMore */
path [ 0 ] = ' \0 ' ;
SetLastError ( 0xdeadbeef ) ;
res = PathAppendA ( path , " " ) ;
ok ( res , " Expected success \n " ) ;
ok ( GetLastError ( ) = = 0xdeadbeef , " Expected 0xdeadbeef, got %ld \n " , GetLastError ( ) ) ;
ok ( ! lstrcmp ( path , " \\ " ) , " Expected \\ , got %s \n " , path ) ;
/* try legit params */
lstrcpy ( path , " C: \\ one " ) ;
SetLastError ( 0xdeadbeef ) ;
res = PathAppendA ( path , " two \\ three " ) ;
ok ( res , " Expected success \n " ) ;
ok ( GetLastError ( ) = = 0xdeadbeef , " Expected 0xdeadbeef, got %ld \n " , GetLastError ( ) ) ;
ok ( ! lstrcmp ( path , " C: \\ one \\ two \\ three " ) , " Expected C: \\ one \\ two \\ three, got %s \n " , path ) ;
/* try pszPath with backslash after it */
lstrcpy ( path , " C: \\ one \\ " ) ;
SetLastError ( 0xdeadbeef ) ;
res = PathAppendA ( path , " two \\ three " ) ;
ok ( res , " Expected success \n " ) ;
ok ( GetLastError ( ) = = 0xdeadbeef , " Expected 0xdeadbeef, got %ld \n " , GetLastError ( ) ) ;
ok ( ! lstrcmp ( path , " C: \\ one \\ two \\ three " ) , " Expected C: \\ one \\ two \\ three, got %s \n " , path ) ;
/* try pszMore with backslash before it */
lstrcpy ( path , " C: \\ one " ) ;
SetLastError ( 0xdeadbeef ) ;
res = PathAppendA ( path , " \\ two \\ three " ) ;
ok ( res , " Expected success \n " ) ;
ok ( GetLastError ( ) = = 0xdeadbeef , " Expected 0xdeadbeef, got %ld \n " , GetLastError ( ) ) ;
ok ( ! lstrcmp ( path , " C: \\ one \\ two \\ three " ) , " Expected C: \\ one \\ two \\ three, got %s \n " , path ) ;
/* try pszMore with backslash after it */
lstrcpy ( path , " C: \\ one " ) ;
SetLastError ( 0xdeadbeef ) ;
res = PathAppendA ( path , " two \\ three \\ " ) ;
ok ( res , " Expected success \n " ) ;
ok ( GetLastError ( ) = = 0xdeadbeef , " Expected 0xdeadbeef, got %ld \n " , GetLastError ( ) ) ;
ok ( ! lstrcmp ( path , " C: \\ one \\ two \\ three \\ " ) , " Expected C: \\ one \\ two \\ three \\ , got %s \n " , path ) ;
/* try spaces in pszPath */
lstrcpy ( path , " C: \\ one " ) ;
SetLastError ( 0xdeadbeef ) ;
res = PathAppendA ( path , " two \\ three " ) ;
ok ( res , " Expected success \n " ) ;
ok ( GetLastError ( ) = = 0xdeadbeef , " Expected 0xdeadbeef, got %ld \n " , GetLastError ( ) ) ;
ok ( ! lstrcmp ( path , " C: \\ one \\ two \\ three " ) , " Expected C: \\ one \\ two \\ three, got %s \n " , path ) ;
/* try spaces in pszMore */
lstrcpy ( path , " C: \\ one " ) ;
SetLastError ( 0xdeadbeef ) ;
res = PathAppendA ( path , " two \\ three " ) ;
ok ( res , " Expected success \n " ) ;
ok ( GetLastError ( ) = = 0xdeadbeef , " Expected 0xdeadbeef, got %ld \n " , GetLastError ( ) ) ;
ok ( ! lstrcmp ( path , " C: \\ one \\ two \\ three " ) , " Expected 'C: \\ one \\ two \\ three ', got %s \n " , path ) ;
/* pszPath is too long */
memset ( too_long , ' a ' , LONG_LEN ) ;
too_long [ LONG_LEN - 1 ] = ' \0 ' ;
SetLastError ( 0xdeadbeef ) ;
res = PathAppendA ( too_long , " two \\ three " ) ;
todo_wine
{
ok ( ! res , " Expected failure \n " ) ;
ok ( GetLastError ( ) = = 0xdeadbeef , " Expected 0xdeadbeef, got %ld \n " , GetLastError ( ) ) ;
ok ( lstrlen ( too_long ) = = 0 , " Expected length of too_long to be zero, got %i \n " , lstrlen ( too_long ) ) ;
}
/* pszMore is too long */
lstrcpy ( path , " C: \\ one " ) ;
memset ( too_long , ' a ' , LONG_LEN ) ;
too_long [ LONG_LEN - 1 ] = ' \0 ' ;
SetLastError ( 0xdeadbeef ) ;
res = PathAppendA ( path , too_long ) ;
todo_wine
{
ok ( ! res , " Expected failure \n " ) ;
ok ( GetLastError ( ) = = 0xdeadbeef , " Expected 0xdeadbeef, got %ld \n " , GetLastError ( ) ) ;
ok ( lstrlen ( path ) = = 0 , " Expected length of path to be zero, got %i \n " , lstrlen ( path ) ) ;
}
/* both params combined are too long */
memset ( one , ' a ' , HALF_LEN ) ;
one [ HALF_LEN - 1 ] = ' \0 ' ;
memset ( two , ' b ' , HALF_LEN ) ;
two [ HALF_LEN - 1 ] = ' \0 ' ;
SetLastError ( 0xdeadbeef ) ;
res = PathAppendA ( one , two ) ;
todo_wine
{
ok ( ! res , " Expected failure \n " ) ;
ok ( lstrlen ( one ) = = 0 , " Expected length of one to be zero, got %i \n " , lstrlen ( one ) ) ;
}
ok ( GetLastError ( ) = = 0xdeadbeef , " Expected 0xdeadbeef, got %ld \n " , GetLastError ( ) ) ;
}
2006-06-29 22:33:05 +02:00
static void test_PathCanonicalizeA ( void )
{
char dest [ MAX_PATH ] ;
char too_long [ LONG_LEN ] ;
BOOL res ;
/* try a NULL source */
lstrcpy ( dest , " test " ) ;
SetLastError ( 0xdeadbeef ) ;
res = PathCanonicalizeA ( dest , NULL ) ;
ok ( ! res , " Expected failure \n " ) ;
ok ( GetLastError ( ) = = ERROR_INVALID_PARAMETER ,
" Expected ERROR_INVALID_PARAMETER, got %ld \n " , GetLastError ( ) ) ;
todo_wine
{
ok ( ! lstrcmp ( dest , " test " ) , " Expected test, got %s \n " , dest ) ;
}
/* try an empty source */
lstrcpy ( dest , " test " ) ;
SetLastError ( 0xdeadbeef ) ;
res = PathCanonicalizeA ( dest , " " ) ;
ok ( res , " Expected success \n " ) ;
ok ( GetLastError ( ) = = 0xdeadbeef , " Expected 0xdeadbeef, got %ld \n " , GetLastError ( ) ) ;
ok ( ! lstrcmp ( dest , " \\ " ) , " Expected \\ , got %s \n " , dest ) ;
/* try a NULL dest */
SetLastError ( 0xdeadbeef ) ;
res = PathCanonicalizeA ( NULL , " C: \\ " ) ;
ok ( ! res , " Expected failure \n " ) ;
ok ( GetLastError ( ) = = ERROR_INVALID_PARAMETER ,
" Expected ERROR_INVALID_PARAMETER, got %ld \n " , GetLastError ( ) ) ;
/* try empty dest */
dest [ 0 ] = ' \0 ' ;
SetLastError ( 0xdeadbeef ) ;
res = PathCanonicalizeA ( dest , " C: \\ " ) ;
ok ( res , " Expected success \n " ) ;
ok ( GetLastError ( ) = = 0xdeadbeef , " Expected 0xdeadbeef, got %ld \n " , GetLastError ( ) ) ;
ok ( ! lstrcmp ( dest , " C: \\ " ) , " Expected C: \\ , got %s \n " , dest ) ;
/* try non-empty dest */
lstrcpy ( dest , " test " ) ;
SetLastError ( 0xdeadbeef ) ;
res = PathCanonicalizeA ( dest , " C: \\ " ) ;
ok ( res , " Expected success \n " ) ;
ok ( GetLastError ( ) = = 0xdeadbeef , " Expected 0xdeadbeef, got %ld \n " , GetLastError ( ) ) ;
ok ( ! lstrcmp ( dest , " C: \\ " ) , " Expected C: \\ , got %s \n " , dest ) ;
/* try a space for source */
lstrcpy ( dest , " test " ) ;
SetLastError ( 0xdeadbeef ) ;
res = PathCanonicalizeA ( dest , " " ) ;
ok ( res , " Expected success \n " ) ;
ok ( GetLastError ( ) = = 0xdeadbeef , " Expected 0xdeadbeef, got %ld \n " , GetLastError ( ) ) ;
ok ( ! lstrcmp ( dest , " " ) , " Expected ' ', got %s \n " , dest ) ;
/* try a relative path */
lstrcpy ( dest , " test " ) ;
SetLastError ( 0xdeadbeef ) ;
res = PathCanonicalizeA ( dest , " one \\ two " ) ;
ok ( res , " Expected success \n " ) ;
ok ( GetLastError ( ) = = 0xdeadbeef , " Expected 0xdeadbeef, got %ld \n " , GetLastError ( ) ) ;
ok ( ! lstrcmp ( dest , " one \\ two " ) , " Expected one \\ two, got %s \n " , dest ) ;
/* try current dir and previous dir */
lstrcpy ( dest , " test " ) ;
SetLastError ( 0xdeadbeef ) ;
res = PathCanonicalizeA ( dest , " C: \\ one \\ . \\ .. \\ two \\ three \\ .. " ) ;
ok ( res , " Expected success \n " ) ;
ok ( GetLastError ( ) = = 0xdeadbeef , " Expected 0xdeadbeef, got %ld \n " , GetLastError ( ) ) ;
ok ( ! lstrcmp ( dest , " C: \\ two " ) , " Expected C: \\ two, got %s \n " , dest ) ;
/* try simple forward slashes */
lstrcpy ( dest , " test " ) ;
SetLastError ( 0xdeadbeef ) ;
res = PathCanonicalizeA ( dest , " C: \\ one/two/three \\ four/five \\ six " ) ;
ok ( res , " Expected success \n " ) ;
ok ( GetLastError ( ) = = 0xdeadbeef , " Expected 0xdeadbeef, got %ld \n " , GetLastError ( ) ) ;
ok ( ! lstrcmp ( dest , " C: \\ one/two/three \\ four/five \\ six " ) ,
" Expected C: \\ one/two/three \\ four/five \\ six, got %s \n " , dest ) ;
/* try simple forward slashes with same dir */
lstrcpy ( dest , " test " ) ;
SetLastError ( 0xdeadbeef ) ;
res = PathCanonicalizeA ( dest , " C: \\ one/. \\ two " ) ;
ok ( res , " Expected success \n " ) ;
ok ( GetLastError ( ) = = 0xdeadbeef , " Expected 0xdeadbeef, got %ld \n " , GetLastError ( ) ) ;
ok ( ! lstrcmp ( dest , " C: \\ one/. \\ two " ) , " Expected C: \\ one/. \\ two, got %s \n " , dest ) ;
/* try simple forward slashes with change dir */
lstrcpy ( dest , " test " ) ;
SetLastError ( 0xdeadbeef ) ;
res = PathCanonicalizeA ( dest , " C: \\ one/. \\ two \\ .. " ) ;
ok ( res , " Expected success \n " ) ;
ok ( GetLastError ( ) = = 0xdeadbeef , " Expected 0xdeadbeef, got %ld \n " , GetLastError ( ) ) ;
ok ( ! lstrcmp ( dest , " C: \\ one/. " ) , " Expected C: \\ one/., got %s \n " , dest ) ;
/* try forward slashes with change dirs
* NOTE : if there is a forward slash in between two backslashes ,
* everything in between the two backslashes is considered on dir
*/
lstrcpy ( dest , " test " ) ;
SetLastError ( 0xdeadbeef ) ;
res = PathCanonicalizeA ( dest , " C: \\ one/. \\ .. \\ two/three \\ .. \\ four/.five " ) ;
ok ( res , " Expected success \n " ) ;
ok ( GetLastError ( ) = = 0xdeadbeef , " Expected 0xdeadbeef, got %ld \n " , GetLastError ( ) ) ;
ok ( ! lstrcmp ( dest , " C: \\ four/.five " ) , " Expected C: \\ four/.five, got %s \n " , dest ) ;
/* try src is too long */
memset ( too_long , ' a ' , LONG_LEN ) ;
too_long [ LONG_LEN - 1 ] = ' \0 ' ;
lstrcpy ( dest , " test " ) ;
SetLastError ( 0xdeadbeef ) ;
res = PathCanonicalizeA ( dest , too_long ) ;
todo_wine
{
ok ( ! res , " Expected failure \n " ) ;
ok ( GetLastError ( ) = = 0xdeadbeef , " Expected 0xdeadbeef, got %ld \n " , GetLastError ( ) ) ;
}
ok ( lstrlen ( too_long ) = = LONG_LEN - 1 , " Expected length LONG_LEN - 1, got %i \n " , lstrlen ( too_long ) ) ;
}
2006-06-29 22:33:18 +02:00
static void test_PathFindExtensionA ( void )
{
LPSTR ext ;
char path [ MAX_PATH ] ;
char too_long [ LONG_LEN ] ;
/* try a NULL path */
SetLastError ( 0xdeadbeef ) ;
ext = PathFindExtensionA ( NULL ) ;
ok ( ext = = NULL , " Expected NULL, got %p \n " , ext ) ;
ok ( GetLastError ( ) = = 0xdeadbeef , " Expected 0xdeadbeef, got %ld \n " , GetLastError ( ) ) ;
/* try an empty path */
path [ 0 ] = ' \0 ' ;
SetLastError ( 0xdeadbeef ) ;
ext = PathFindExtensionA ( path ) ;
ok ( ext = = path , " Expected ext == path, got %p \n " , ext ) ;
ok ( lstrlen ( ext ) = = 0 , " Expected length 0, got %i \n " , lstrlen ( ext ) ) ;
ok ( GetLastError ( ) = = 0xdeadbeef , " Expected 0xdeadbeef, got %ld \n " , GetLastError ( ) ) ;
/* try a path without an extension */
lstrcpy ( path , " file " ) ;
SetLastError ( 0xdeadbeef ) ;
ext = PathFindExtensionA ( path ) ;
ok ( ext = = path + lstrlen ( path ) , " Expected ext == path, got %p \n " , ext ) ;
ok ( lstrlen ( ext ) = = 0 , " Expected length 0, got %i \n " , lstrlen ( ext ) ) ;
ok ( GetLastError ( ) = = 0xdeadbeef , " Expected 0xdeadbeef, got %ld \n " , GetLastError ( ) ) ;
/* try a path with an extension */
lstrcpy ( path , " file.txt " ) ;
SetLastError ( 0xdeadbeef ) ;
ext = PathFindExtensionA ( path ) ;
ok ( ext = = path + lstrlen ( " file " ) ,
" Expected ext == path + lstrlen( \" file \" ), got %p \n " , ext ) ;
ok ( ! lstrcmp ( ext , " .txt " ) , " Expected .txt, got %s \n " , ext ) ;
ok ( GetLastError ( ) = = 0xdeadbeef , " Expected 0xdeadbeef, got %ld \n " , GetLastError ( ) ) ;
/* try a path with two extensions */
lstrcpy ( path , " file.txt.doc " ) ;
SetLastError ( 0xdeadbeef ) ;
ext = PathFindExtensionA ( path ) ;
ok ( ext = = path + lstrlen ( " file.txt " ) ,
" Expected ext == path + lstrlen( \" file.txt \" ), got %p \n " , ext ) ;
ok ( ! lstrcmp ( ext , " .doc " ) , " Expected .txt, got %s \n " , ext ) ;
ok ( GetLastError ( ) = = 0xdeadbeef , " Expected 0xdeadbeef, got %ld \n " , GetLastError ( ) ) ;
/* try a path longer than MAX_PATH without an extension*/
memset ( too_long , ' a ' , LONG_LEN ) ;
too_long [ LONG_LEN - 1 ] = ' \0 ' ;
SetLastError ( 0xdeadbeef ) ;
ext = PathFindExtensionA ( too_long ) ;
ok ( ext = = too_long + LONG_LEN - 1 , " Expected ext == too_long + LONG_LEN - 1, got %p \n " , ext ) ;
ok ( GetLastError ( ) = = 0xdeadbeef , " Expected 0xdeadbeef, got %ld \n " , GetLastError ( ) ) ;
/* try a path longer than MAX_PATH with an extension*/
memset ( too_long , ' a ' , LONG_LEN ) ;
too_long [ LONG_LEN - 1 ] = ' \0 ' ;
lstrcpy ( too_long + 300 , " .abcde " ) ;
too_long [ lstrlen ( too_long ) ] = ' a ' ;
SetLastError ( 0xdeadbeef ) ;
ext = PathFindExtensionA ( too_long ) ;
ok ( ext = = too_long + 300 , " Expected ext == too_long + 300, got %p \n " , ext ) ;
ok ( lstrlen ( ext ) = = LONG_LEN - 301 , " Expected LONG_LEN - 301, got %i \n " , lstrlen ( ext ) ) ;
ok ( GetLastError ( ) = = 0xdeadbeef , " Expected 0xdeadbeef, got %ld \n " , GetLastError ( ) ) ;
}
2006-07-13 02:18:37 +02:00
static void test_PathBuildRootA ( void )
{
LPSTR root ;
char path [ 10 ] ;
char root_expected [ 26 ] [ 4 ] ;
char drive ;
int j ;
/* set up the expected paths */
for ( drive = ' A ' ; drive < = ' Z ' ; drive + + )
sprintf ( root_expected [ drive - ' A ' ] , " %c: \\ " , drive ) ;
/* test the expected values */
for ( j = 0 ; j < 26 ; j + + )
{
SetLastError ( 0xdeadbeef ) ;
lstrcpy ( path , " aaaaaaaaa " ) ;
root = PathBuildRootA ( path , j ) ;
ok ( root = = path , " Expected root == path, got %p \n " , root ) ;
ok ( ! lstrcmp ( root , root_expected [ j ] ) , " Expected %s, got %s \n " , root_expected [ j ] , root ) ;
ok ( GetLastError ( ) = = 0xdeadbeef , " Expected 0xdeadbeef, got %ld \n " , GetLastError ( ) ) ;
}
/* test a negative drive number */
SetLastError ( 0xdeadbeef ) ;
lstrcpy ( path , " aaaaaaaaa " ) ;
root = PathBuildRootA ( path , - 1 ) ;
ok ( root = = path , " Expected root == path, got %p \n " , root ) ;
ok ( ! lstrcmp ( path , " aaaaaaaaa " ) , " Expected aaaaaaaaa, got %s \n " , path ) ;
ok ( GetLastError ( ) = = 0xdeadbeef , " Expected 0xdeadbeef, got %ld \n " , GetLastError ( ) ) ;
/* test a drive number greater than 25 */
SetLastError ( 0xdeadbeef ) ;
lstrcpy ( path , " aaaaaaaaa " ) ;
root = PathBuildRootA ( path , 26 ) ;
ok ( root = = path , " Expected root == path, got %p \n " , root ) ;
ok ( ! lstrcmp ( path , " aaaaaaaaa " ) , " Expected aaaaaaaaa, got %s \n " , path ) ;
ok ( GetLastError ( ) = = 0xdeadbeef , " Expected 0xdeadbeef, got %ld \n " , GetLastError ( ) ) ;
/* length of path is less than 4 */
SetLastError ( 0xdeadbeef ) ;
lstrcpy ( path , " aa " ) ;
root = PathBuildRootA ( path , 0 ) ;
ok ( root = = path , " Expected root == path, got %p \n " , root ) ;
ok ( ! lstrcmp ( path , " A: \\ " ) , " Expected A: \\ , got %s \n " , path ) ;
ok ( GetLastError ( ) = = 0xdeadbeef , " Expected 0xdeadbeef, got %ld \n " , GetLastError ( ) ) ;
/* path is NULL */
SetLastError ( 0xdeadbeef ) ;
root = PathBuildRootA ( NULL , 0 ) ;
ok ( root = = NULL , " Expected root == NULL, got %p \n " , root ) ;
ok ( GetLastError ( ) = = 0xdeadbeef , " Expected 0xdeadbeef, got %ld \n " , GetLastError ( ) ) ;
}
2006-07-13 02:19:55 +02:00
static void test_PathCommonPrefixA ( void )
{
char path1 [ MAX_PATH ] , path2 [ MAX_PATH ] ;
char out [ MAX_PATH ] ;
int count ;
/* test NULL path1 */
SetLastError ( 0xdeadbeef ) ;
lstrcpy ( path2 , " C: \\ " ) ;
lstrcpy ( out , " aaa " ) ;
count = PathCommonPrefixA ( NULL , path2 , out ) ;
ok ( count = = 0 , " Expected 0, got %i \n " , count ) ;
todo_wine
{
ok ( ! lstrcmp ( out , " aaa " ) , " Expected aaa, got %s \n " , out ) ;
}
ok ( ! lstrcmp ( path2 , " C: \\ " ) , " Expected C: \\ , got %s \n " , path2 ) ;
ok ( GetLastError ( ) = = 0xdeadbeef , " Expected 0xdeadbeef, got %ld \n " , GetLastError ( ) ) ;
/* test NULL path2 */
SetLastError ( 0xdeadbeef ) ;
lstrcpy ( path1 , " C: \\ " ) ;
lstrcpy ( out , " aaa " ) ;
count = PathCommonPrefixA ( path1 , NULL , out ) ;
ok ( count = = 0 , " Expected 0, got %i \n " , count ) ;
todo_wine
{
ok ( ! lstrcmp ( out , " aaa " ) , " Expected aaa, got %s \n " , out ) ;
}
ok ( ! lstrcmp ( path1 , " C: \\ " ) , " Expected C: \\ , got %s \n " , path1 ) ;
ok ( GetLastError ( ) = = 0xdeadbeef , " Expected 0xdeadbeef, got %ld \n " , GetLastError ( ) ) ;
/* test empty path1 */
SetLastError ( 0xdeadbeef ) ;
path1 [ 0 ] = ' \0 ' ;
lstrcpy ( path2 , " C: \\ " ) ;
lstrcpy ( out , " aaa " ) ;
count = PathCommonPrefixA ( path1 , path2 , out ) ;
ok ( count = = 0 , " Expected 0, got %i \n " , count ) ;
ok ( lstrlen ( out ) = = 0 , " Expected 0 length out, got %i \n " , lstrlen ( out ) ) ;
ok ( lstrlen ( path1 ) = = 0 , " Expected 0 length path1, got %i \n " , lstrlen ( path1 ) ) ;
ok ( ! lstrcmp ( path2 , " C: \\ " ) , " Expected C: \\ , got %s \n " , path2 ) ;
ok ( GetLastError ( ) = = 0xdeadbeef , " Expected 0xdeadbeef, got %ld \n " , GetLastError ( ) ) ;
/* test empty path1 */
SetLastError ( 0xdeadbeef ) ;
path2 [ 0 ] = ' \0 ' ;
lstrcpy ( path1 , " C: \\ " ) ;
lstrcpy ( out , " aaa " ) ;
count = PathCommonPrefixA ( path1 , path2 , out ) ;
ok ( count = = 0 , " Expected 0, got %i \n " , count ) ;
ok ( lstrlen ( out ) = = 0 , " Expected 0 length out, got %i \n " , lstrlen ( out ) ) ;
ok ( lstrlen ( path2 ) = = 0 , " Expected 0 length path2, got %i \n " , lstrlen ( path2 ) ) ;
ok ( ! lstrcmp ( path1 , " C: \\ " ) , " Expected C: \\ , got %s \n " , path1 ) ;
ok ( GetLastError ( ) = = 0xdeadbeef , " Expected 0xdeadbeef, got %ld \n " , GetLastError ( ) ) ;
/* paths are legit, out is NULL */
SetLastError ( 0xdeadbeef ) ;
lstrcpy ( path1 , " C: \\ " ) ;
lstrcpy ( path2 , " C: \\ " ) ;
count = PathCommonPrefixA ( path1 , path2 , NULL ) ;
ok ( count = = 3 , " Expected 3, got %i \n " , count ) ;
ok ( ! lstrcmp ( path1 , " C: \\ " ) , " Expected C: \\ , got %s \n " , path1 ) ;
ok ( ! lstrcmp ( path2 , " C: \\ " ) , " Expected C: \\ , got %s \n " , path2 ) ;
ok ( GetLastError ( ) = = 0xdeadbeef , " Expected 0xdeadbeef, got %ld \n " , GetLastError ( ) ) ;
/* all parameters legit */
SetLastError ( 0xdeadbeef ) ;
lstrcpy ( path1 , " C: \\ " ) ;
lstrcpy ( path2 , " C: \\ " ) ;
lstrcpy ( out , " aaa " ) ;
count = PathCommonPrefixA ( path1 , path2 , out ) ;
ok ( count = = 3 , " Expected 3, got %i \n " , count ) ;
ok ( ! lstrcmp ( path1 , " C: \\ " ) , " Expected C: \\ , got %s \n " , path1 ) ;
ok ( ! lstrcmp ( path2 , " C: \\ " ) , " Expected C: \\ , got %s \n " , path2 ) ;
ok ( ! lstrcmp ( out , " C: \\ " ) , " Expected C: \\ , got %s \n " , out ) ;
ok ( GetLastError ( ) = = 0xdeadbeef , " Expected 0xdeadbeef, got %ld \n " , GetLastError ( ) ) ;
/* path1 and path2 not the same, but common prefix */
SetLastError ( 0xdeadbeef ) ;
lstrcpy ( path1 , " C: \\ one \\ two " ) ;
lstrcpy ( path2 , " C: \\ one \\ three " ) ;
lstrcpy ( out , " aaa " ) ;
count = PathCommonPrefixA ( path1 , path2 , out ) ;
ok ( count = = 6 , " Expected 6, got %i \n " , count ) ;
ok ( ! lstrcmp ( path1 , " C: \\ one \\ two " ) , " Expected C: \\ one \\ two, got %s \n " , path1 ) ;
ok ( ! lstrcmp ( path2 , " C: \\ one \\ three " ) , " Expected C: \\ one \\ three, got %s \n " , path2 ) ;
ok ( ! lstrcmp ( out , " C: \\ one " ) , " Expected C: \\ one, got %s \n " , out ) ;
ok ( GetLastError ( ) = = 0xdeadbeef , " Expected 0xdeadbeef, got %ld \n " , GetLastError ( ) ) ;
/* try . prefix */
SetLastError ( 0xdeadbeef ) ;
lstrcpy ( path1 , " one \\ .two " ) ;
lstrcpy ( path2 , " one \\ .three " ) ;
lstrcpy ( out , " aaa " ) ;
count = PathCommonPrefixA ( path1 , path2 , out ) ;
ok ( count = = 3 , " Expected 3, got %i \n " , count ) ;
ok ( ! lstrcmp ( path1 , " one \\ .two " ) , " Expected one \\ .two, got %s \n " , path1 ) ;
ok ( ! lstrcmp ( path2 , " one \\ .three " ) , " Expected one \\ .three, got %s \n " , path2 ) ;
ok ( ! lstrcmp ( out , " one " ) , " Expected one, got %s \n " , out ) ;
ok ( GetLastError ( ) = = 0xdeadbeef , " Expected 0xdeadbeef, got %ld \n " , GetLastError ( ) ) ;
/* try .. prefix */
SetLastError ( 0xdeadbeef ) ;
lstrcpy ( path1 , " one \\ ..two " ) ;
lstrcpy ( path2 , " one \\ ..three " ) ;
lstrcpy ( out , " aaa " ) ;
count = PathCommonPrefixA ( path1 , path2 , out ) ;
ok ( count = = 3 , " Expected 3, got %i \n " , count ) ;
ok ( ! lstrcmp ( path1 , " one \\ ..two " ) , " Expected one \\ ..two, got %s \n " , path1 ) ;
ok ( ! lstrcmp ( path2 , " one \\ ..three " ) , " Expected one \\ ..three, got %s \n " , path2 ) ;
ok ( ! lstrcmp ( out , " one " ) , " Expected one, got %s \n " , out ) ;
ok ( GetLastError ( ) = = 0xdeadbeef , " Expected 0xdeadbeef, got %ld \n " , GetLastError ( ) ) ;
/* try ... prefix */
SetLastError ( 0xdeadbeef ) ;
lstrcpy ( path1 , " one \\ ...two " ) ;
lstrcpy ( path2 , " one \\ ...three " ) ;
lstrcpy ( out , " aaa " ) ;
count = PathCommonPrefixA ( path1 , path2 , out ) ;
ok ( count = = 3 , " Expected 3, got %i \n " , count ) ;
ok ( ! lstrcmp ( path1 , " one \\ ...two " ) , " Expected one \\ ...two, got %s \n " , path1 ) ;
ok ( ! lstrcmp ( path2 , " one \\ ...three " ) , " Expected one \\ ...three, got %s \n " , path2 ) ;
ok ( ! lstrcmp ( out , " one " ) , " Expected one, got %s \n " , out ) ;
ok ( GetLastError ( ) = = 0xdeadbeef , " Expected 0xdeadbeef, got %ld \n " , GetLastError ( ) ) ;
/* try .\ prefix */
SetLastError ( 0xdeadbeef ) ;
lstrcpy ( path1 , " one \\ . \\ two " ) ;
lstrcpy ( path2 , " one \\ . \\ three " ) ;
lstrcpy ( out , " aaa " ) ;
count = PathCommonPrefixA ( path1 , path2 , out ) ;
ok ( count = = 5 , " Expected 5, got %i \n " , count ) ;
ok ( ! lstrcmp ( path1 , " one \\ . \\ two " ) , " Expected one \\ . \\ two, got %s \n " , path1 ) ;
ok ( ! lstrcmp ( path2 , " one \\ . \\ three " ) , " Expected one \\ . \\ three, got %s \n " , path2 ) ;
ok ( ! lstrcmp ( out , " one \\ . " ) , " Expected one \\ ., got %s \n " , out ) ;
ok ( GetLastError ( ) = = 0xdeadbeef , " Expected 0xdeadbeef, got %ld \n " , GetLastError ( ) ) ;
/* try ..\ prefix */
SetLastError ( 0xdeadbeef ) ;
lstrcpy ( path1 , " one \\ .. \\ two " ) ;
lstrcpy ( path2 , " one \\ .. \\ three " ) ;
lstrcpy ( out , " aaa " ) ;
count = PathCommonPrefixA ( path1 , path2 , out ) ;
ok ( count = = 6 , " Expected 6, got %i \n " , count ) ;
ok ( ! lstrcmp ( path1 , " one \\ .. \\ two " ) , " Expected one \\ .. \\ two, got %s \n " , path1 ) ;
ok ( ! lstrcmp ( path2 , " one \\ .. \\ three " ) , " Expected one \\ .. \\ three, got %s \n " , path2 ) ;
ok ( ! lstrcmp ( out , " one \\ .. " ) , " Expected one \\ .., got %s \n " , out ) ;
ok ( GetLastError ( ) = = 0xdeadbeef , " Expected 0xdeadbeef, got %ld \n " , GetLastError ( ) ) ;
/* try ...\\ prefix */
SetLastError ( 0xdeadbeef ) ;
lstrcpy ( path1 , " one \\ ... \\ two " ) ;
lstrcpy ( path2 , " one \\ ... \\ three " ) ;
lstrcpy ( out , " aaa " ) ;
count = PathCommonPrefixA ( path1 , path2 , out ) ;
ok ( count = = 7 , " Expected 7, got %i \n " , count ) ;
ok ( ! lstrcmp ( path1 , " one \\ ... \\ two " ) , " Expected one \\ ... \\ two, got %s \n " , path1 ) ;
ok ( ! lstrcmp ( path2 , " one \\ ... \\ three " ) , " Expected one \\ ... \\ three, got %s \n " , path2 ) ;
ok ( ! lstrcmp ( out , " one \\ ... " ) , " Expected one \\ ..., got %s \n " , out ) ;
ok ( GetLastError ( ) = = 0xdeadbeef , " Expected 0xdeadbeef, got %ld \n " , GetLastError ( ) ) ;
/* try prefix that is not an msdn labeled prefix type */
SetLastError ( 0xdeadbeef ) ;
lstrcpy ( path1 , " same " ) ;
lstrcpy ( path2 , " same " ) ;
lstrcpy ( out , " aaa " ) ;
count = PathCommonPrefixA ( path1 , path2 , out ) ;
ok ( count = = 4 , " Expected 4, got %i \n " , count ) ;
ok ( ! lstrcmp ( path1 , " same " ) , " Expected same, got %s \n " , path1 ) ;
ok ( ! lstrcmp ( path2 , " same " ) , " Expected same, got %s \n " , path2 ) ;
ok ( ! lstrcmp ( out , " same " ) , " Expected same, got %s \n " , out ) ;
ok ( GetLastError ( ) = = 0xdeadbeef , " Expected 0xdeadbeef, got %ld \n " , GetLastError ( ) ) ;
/* try . after directory */
SetLastError ( 0xdeadbeef ) ;
lstrcpy ( path1 , " one \\ mid. \\ two " ) ;
lstrcpy ( path2 , " one \\ mid. \\ three " ) ;
lstrcpy ( out , " aaa " ) ;
count = PathCommonPrefixA ( path1 , path2 , out ) ;
ok ( count = = 8 , " Expected 8, got %i \n " , count ) ;
ok ( ! lstrcmp ( path1 , " one \\ mid. \\ two " ) , " Expected one \\ mid. \\ two, got %s \n " , path1 ) ;
ok ( ! lstrcmp ( path2 , " one \\ mid. \\ three " ) , " Expected one \\ mid. \\ three, got %s \n " , path2 ) ;
ok ( ! lstrcmp ( out , " one \\ mid. " ) , " Expected one \\ mid., got %s \n " , out ) ;
ok ( GetLastError ( ) = = 0xdeadbeef , " Expected 0xdeadbeef, got %ld \n " , GetLastError ( ) ) ;
/* try . in the middle of a directory */
SetLastError ( 0xdeadbeef ) ;
lstrcpy ( path1 , " one \\ mid.end \\ two " ) ;
lstrcpy ( path2 , " one \\ mid.end \\ three " ) ;
lstrcpy ( out , " aaa " ) ;
count = PathCommonPrefixA ( path1 , path2 , out ) ;
ok ( count = = 11 , " Expected 11, got %i \n " , count ) ;
ok ( ! lstrcmp ( path1 , " one \\ mid.end \\ two " ) , " Expected one \\ mid.end \\ two, got %s \n " , path1 ) ;
ok ( ! lstrcmp ( path2 , " one \\ mid.end \\ three " ) , " Expected one \\ mid.end \\ three, got %s \n " , path2 ) ;
ok ( ! lstrcmp ( out , " one \\ mid.end " ) , " Expected one \\ mid.end, got %s \n " , out ) ;
ok ( GetLastError ( ) = = 0xdeadbeef , " Expected 0xdeadbeef, got %ld \n " , GetLastError ( ) ) ;
/* try comparing a .. with the expanded path */
SetLastError ( 0xdeadbeef ) ;
lstrcpy ( path1 , " one \\ .. \\ two " ) ;
lstrcpy ( path2 , " two " ) ;
lstrcpy ( out , " aaa " ) ;
count = PathCommonPrefixA ( path1 , path2 , out ) ;
ok ( count = = 0 , " Expected 0, got %i \n " , count ) ;
ok ( ! lstrcmp ( path1 , " one \\ .. \\ two " ) , " Expected one \\ .. \\ two, got %s \n " , path1 ) ;
ok ( ! lstrcmp ( path2 , " two " ) , " Expected two, got %s \n " , path2 ) ;
ok ( lstrlen ( out ) = = 0 , " Expected 0 length out, got %i \n " , lstrlen ( out ) ) ;
ok ( GetLastError ( ) = = 0xdeadbeef , " Expected 0xdeadbeef, got %ld \n " , GetLastError ( ) ) ;
}
2003-01-09 01:50:17 +01:00
START_TEST ( path )
{
2005-02-10 18:10:43 +01:00
hShlwapi = LoadLibraryA ( " shlwapi.dll " ) ;
if ( ! hShlwapi ) return ;
2003-01-09 01:50:17 +01:00
test_UrlHash ( ) ;
test_UrlGetPart ( ) ;
2004-03-03 21:11:46 +01:00
test_UrlCanonicalize ( ) ;
2004-03-16 02:07:28 +01:00
test_UrlEscape ( ) ;
2004-04-28 01:29:01 +02:00
test_UrlCombine ( ) ;
2004-10-05 20:31:58 +02:00
test_UrlCreateFromPath ( ) ;
2005-01-03 18:08:40 +01:00
test_UrlIs ( ) ;
2004-10-05 20:31:58 +02:00
test_UrlUnescape ( ) ;
2004-09-25 02:29:47 +02:00
test_PathSearchAndQualify ( ) ;
2004-10-05 20:31:58 +02:00
test_PathCreateFromUrl ( ) ;
test_PathIsUrl ( ) ;
2006-04-11 20:55:25 +02:00
2006-06-26 23:41:22 +02:00
test_PathAddBackslash ( ) ;
2005-03-14 11:09:53 +01:00
test_PathMakePretty ( ) ;
2006-04-11 20:55:25 +02:00
test_PathMatchSpec ( ) ;
2005-02-10 18:10:43 +01:00
2005-03-14 11:09:53 +01:00
/* For whatever reason, PathIsValidCharA and PathAppendA share the same
* ordinal number in some native versions . Check this to prevent a crash .
*/
2005-02-10 18:10:43 +01:00
pPathIsValidCharA = ( void * ) GetProcAddress ( hShlwapi , ( LPSTR ) 455 ) ;
2005-03-14 11:09:53 +01:00
if ( pPathIsValidCharA & & pPathIsValidCharA ! = ( void * ) GetProcAddress ( hShlwapi , " PathAppendA " ) )
{
test_PathIsValidCharA ( ) ;
2005-02-10 18:10:43 +01:00
2005-03-14 11:09:53 +01:00
pPathIsValidCharW = ( void * ) GetProcAddress ( hShlwapi , ( LPSTR ) 456 ) ;
if ( pPathIsValidCharW ) test_PathIsValidCharW ( ) ;
}
2006-06-23 15:21:02 +02:00
pPathCombineW = ( void * ) GetProcAddress ( hShlwapi , " PathCombineW " ) ;
2006-06-26 23:37:45 +02:00
if ( pPathCombineW )
test_PathCombineW ( ) ;
test_PathCombineA ( ) ;
2006-06-27 22:05:30 +02:00
test_PathAppendA ( ) ;
2006-06-29 22:33:05 +02:00
test_PathCanonicalizeA ( ) ;
2006-06-29 22:33:18 +02:00
test_PathFindExtensionA ( ) ;
2006-07-13 02:18:37 +02:00
test_PathBuildRootA ( ) ;
2006-07-13 02:19:55 +02:00
test_PathCommonPrefixA ( ) ;
2003-01-09 01:50:17 +01:00
}