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
f05b840a
Commit
f05b840a
authored
Oct 12, 2007
by
Detlef Riekenberg
Committed by
Alexandre Julliard
Oct 16, 2007
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
shlwapi/test: Test dwSize for UrlCanonicalizeA/W.
parent
d9a33f3c
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
111 additions
and
0 deletions
+111
-0
url.c
dlls/shlwapi/tests/url.c
+111
-0
No files found.
dlls/shlwapi/tests/url.c
View file @
f05b840a
/* Unit test suite for Path functions
*
* Copyright 2002 Matthew Mastracci
* Copyright 2007 Detlef Riekenberg
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
...
...
@@ -28,10 +29,14 @@
#include "wininet.h"
/* ################ */
static
HMODULE
hShlwapi
;
static
HRESULT
(
WINAPI
*
pUrlCanonicalizeW
)(
LPCWSTR
,
LPWSTR
,
LPDWORD
,
DWORD
);
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"
;
const
WCHAR
winehqW
[]
=
{
'h'
,
't'
,
't'
,
'p'
,
':'
,
'/'
,
'/'
,
'w'
,
'w'
,
'w'
,
'.'
,
'w'
,
'i'
,
'n'
,
'e'
,
'h'
,
'q'
,
'.'
,
'o'
,
'r'
,
'g'
,
'/'
,
0
};
const
CHAR
winehqA
[]
=
{
'h'
,
't'
,
't'
,
'p'
,
':'
,
'/'
,
'/'
,
'w'
,
'w'
,
'w'
,
'.'
,
'w'
,
'i'
,
'n'
,
'e'
,
'h'
,
'q'
,
'.'
,
'o'
,
'r'
,
'g'
,
'/'
,
0
};
/* ################ */
...
...
@@ -469,8 +474,51 @@ static void test_UrlCanonicalizeA(void)
unsigned
int
i
;
CHAR
szReturnUrl
[
INTERNET_MAX_URL_LENGTH
];
DWORD
dwSize
;
DWORD
urllen
;
HRESULT
hr
;
urllen
=
lstrlenA
(
winehqA
);
/* buffer has no space for the result */
dwSize
=
urllen
-
1
;
memset
(
szReturnUrl
,
'#'
,
urllen
+
4
);
szReturnUrl
[
urllen
+
4
]
=
'\0'
;
SetLastError
(
0xdeadbeef
);
hr
=
UrlCanonicalizeA
(
winehqA
,
szReturnUrl
,
&
dwSize
,
URL_WININET_COMPATIBILITY
|
URL_ESCAPE_UNSAFE
);
ok
(
(
hr
==
E_POINTER
)
&&
(
dwSize
==
(
urllen
+
1
)),
"got 0x%x with %u and size %u for '%s' and %u (expected 'E_POINTER' and size %u)
\n
"
,
hr
,
GetLastError
(),
dwSize
,
szReturnUrl
,
lstrlenA
(
szReturnUrl
),
urllen
+
1
);
/* buffer has no space for the terminating '\0' */
dwSize
=
urllen
;
memset
(
szReturnUrl
,
'#'
,
urllen
+
4
);
szReturnUrl
[
urllen
+
4
]
=
'\0'
;
SetLastError
(
0xdeadbeef
);
hr
=
UrlCanonicalizeA
(
winehqA
,
szReturnUrl
,
&
dwSize
,
URL_WININET_COMPATIBILITY
|
URL_ESCAPE_UNSAFE
);
ok
(
(
hr
==
E_POINTER
)
&&
(
dwSize
==
(
urllen
+
1
)),
"got 0x%x with %u and size %u for '%s' and %u (expected 'E_POINTER' and size %u)
\n
"
,
hr
,
GetLastError
(),
dwSize
,
szReturnUrl
,
lstrlenA
(
szReturnUrl
),
urllen
+
1
);
/* buffer has the required size */
dwSize
=
urllen
+
1
;
memset
(
szReturnUrl
,
'#'
,
urllen
+
4
);
szReturnUrl
[
urllen
+
4
]
=
'\0'
;
SetLastError
(
0xdeadbeef
);
hr
=
UrlCanonicalizeA
(
winehqA
,
szReturnUrl
,
&
dwSize
,
URL_WININET_COMPATIBILITY
|
URL_ESCAPE_UNSAFE
);
ok
(
(
hr
==
S_OK
)
&&
(
dwSize
==
urllen
),
"got 0x%x with %u and size %u for '%s' and %u (expected 'S_OK' and size %u)
\n
"
,
hr
,
GetLastError
(),
dwSize
,
szReturnUrl
,
lstrlenA
(
szReturnUrl
),
urllen
);
/* buffer is larger as the required size */
dwSize
=
urllen
+
2
;
memset
(
szReturnUrl
,
'#'
,
urllen
+
4
);
szReturnUrl
[
urllen
+
4
]
=
'\0'
;
SetLastError
(
0xdeadbeef
);
hr
=
UrlCanonicalizeA
(
winehqA
,
szReturnUrl
,
&
dwSize
,
URL_WININET_COMPATIBILITY
|
URL_ESCAPE_UNSAFE
);
ok
(
(
hr
==
S_OK
)
&&
(
dwSize
==
urllen
),
"got 0x%x with %u and size %u for '%s' and %u (expected 'S_OK' and size %u)
\n
"
,
hr
,
GetLastError
(),
dwSize
,
szReturnUrl
,
lstrlenA
(
szReturnUrl
),
urllen
);
/* test url-modification */
for
(
i
=
0
;
i
<
sizeof
(
TEST_CANONICALIZE
)
/
sizeof
(
TEST_CANONICALIZE
[
0
]);
i
++
)
{
...
...
@@ -491,6 +539,65 @@ static void test_UrlCanonicalizeA(void)
/* ########################### */
static
void
test_UrlCanonicalizeW
(
void
)
{
WCHAR
szReturnUrl
[
INTERNET_MAX_URL_LENGTH
];
DWORD
dwSize
;
DWORD
urllen
;
HRESULT
hr
;
if
(
!
pUrlCanonicalizeW
)
{
skip
(
"UrlCanonicalizeW
\n
"
);
return
;
}
urllen
=
lstrlenW
(
winehqW
);
/* buffer has no space for the result */
dwSize
=
(
urllen
-
1
);
memset
(
szReturnUrl
,
'#'
,
(
urllen
+
4
)
*
sizeof
(
WCHAR
));
szReturnUrl
[
urllen
+
4
]
=
'\0'
;
SetLastError
(
0xdeadbeef
);
hr
=
pUrlCanonicalizeW
(
winehqW
,
szReturnUrl
,
&
dwSize
,
URL_WININET_COMPATIBILITY
|
URL_ESCAPE_UNSAFE
);
ok
(
(
hr
==
E_POINTER
)
&&
(
dwSize
==
(
urllen
+
1
)),
"got 0x%x with %u and size %u for %u (expected 'E_POINTER' and size %u)
\n
"
,
hr
,
GetLastError
(),
dwSize
,
lstrlenW
(
szReturnUrl
),
urllen
+
1
);
/* buffer has no space for the terminating '\0' */
dwSize
=
urllen
;
memset
(
szReturnUrl
,
'#'
,
(
urllen
+
4
)
*
sizeof
(
WCHAR
));
szReturnUrl
[
urllen
+
4
]
=
'\0'
;
SetLastError
(
0xdeadbeef
);
hr
=
pUrlCanonicalizeW
(
winehqW
,
szReturnUrl
,
&
dwSize
,
URL_WININET_COMPATIBILITY
|
URL_ESCAPE_UNSAFE
);
ok
(
(
hr
==
E_POINTER
)
&&
(
dwSize
==
(
urllen
+
1
)),
"got 0x%x with %u and size %u for %u (expected 'E_POINTER' and size %u)
\n
"
,
hr
,
GetLastError
(),
dwSize
,
lstrlenW
(
szReturnUrl
),
urllen
+
1
);
/* buffer has the required size */
dwSize
=
urllen
+
1
;
memset
(
szReturnUrl
,
'#'
,
(
urllen
+
4
)
*
sizeof
(
WCHAR
));
szReturnUrl
[
urllen
+
4
]
=
'\0'
;
SetLastError
(
0xdeadbeef
);
hr
=
pUrlCanonicalizeW
(
winehqW
,
szReturnUrl
,
&
dwSize
,
URL_WININET_COMPATIBILITY
|
URL_ESCAPE_UNSAFE
);
ok
(
(
hr
==
S_OK
)
&&
(
dwSize
==
urllen
),
"got 0x%x with %u and size %u for %u (expected 'S_OK' and size %u)
\n
"
,
hr
,
GetLastError
(),
dwSize
,
lstrlenW
(
szReturnUrl
),
urllen
);
/* buffer is larger as the required size */
dwSize
=
(
urllen
+
2
);
memset
(
szReturnUrl
,
'#'
,
(
urllen
+
4
)
*
sizeof
(
WCHAR
));
szReturnUrl
[
urllen
+
4
]
=
'\0'
;
SetLastError
(
0xdeadbeef
);
hr
=
pUrlCanonicalizeW
(
winehqW
,
szReturnUrl
,
&
dwSize
,
URL_WININET_COMPATIBILITY
|
URL_ESCAPE_UNSAFE
);
ok
(
(
hr
==
S_OK
)
&&
(
dwSize
==
urllen
),
"got 0x%x with %u and size %u for %u (expected 'S_OK' and size %u)
\n
"
,
hr
,
GetLastError
(),
dwSize
,
lstrlenW
(
szReturnUrl
),
urllen
);
}
/* ########################### */
static
void
test_url_combine
(
const
char
*
szUrl1
,
const
char
*
szUrl2
,
DWORD
dwFlags
,
HRESULT
dwExpectReturn
,
const
char
*
szExpectUrl
)
{
HRESULT
hr
;
...
...
@@ -674,9 +781,13 @@ static void test_UrlUnescape(void)
START_TEST
(
url
)
{
hShlwapi
=
GetModuleHandleA
(
"shlwapi.dll"
);
pUrlCanonicalizeW
=
(
void
*
)
GetProcAddress
(
hShlwapi
,
"UrlCanonicalizeW"
);
test_UrlHash
();
test_UrlGetPart
();
test_UrlCanonicalizeA
();
test_UrlCanonicalizeW
();
test_UrlEscape
();
test_UrlCombine
();
test_UrlCreateFromPath
();
...
...
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