Commit 81cf4abb authored by Sebastian Lackner's avatar Sebastian Lackner Committed by Vitaly Lipatov

shlwapi/tests: Add additional tests for UrlCombine and UrlCanonicalize

parent 8fdcd6d9
...@@ -183,6 +183,14 @@ static const TEST_URL_CANONICALIZE TEST_CANONICALIZE[] = { ...@@ -183,6 +183,14 @@ static const TEST_URL_CANONICALIZE TEST_CANONICALIZE[] = {
{"./A", URL_DONT_SIMPLIFY, "./A", FALSE}, {"./A", URL_DONT_SIMPLIFY, "./A", FALSE},
{"A/./B", 0, "A/B", TRUE}, {"A/./B", 0, "A/B", TRUE},
{"A/../B", 0, "B", TRUE}, {"A/../B", 0, "B", TRUE},
{"A/../B/./../C", 0, "C", TRUE},
{"A/../B/./../C", URL_DONT_SIMPLIFY, "A/../B/./../C", FALSE},
{".\\A", 0, ".\\A", FALSE},
{"A\\.\\B", 0, "A\\.\\B", FALSE},
{".", 0, "/", TRUE},
{"./A", 0, "A", TRUE},
{"A/./B", 0, "A/B", TRUE},
{"/:test\\", 0, "/:test\\", TRUE},
{"/uri-res/N2R?urn:sha1:B3K", URL_DONT_ESCAPE_EXTRA_INFO | URL_WININET_COMPATIBILITY /*0x82000000*/, "/uri-res/N2R?urn:sha1:B3K", FALSE} /*LimeWire online installer calls this*/, {"/uri-res/N2R?urn:sha1:B3K", URL_DONT_ESCAPE_EXTRA_INFO | URL_WININET_COMPATIBILITY /*0x82000000*/, "/uri-res/N2R?urn:sha1:B3K", FALSE} /*LimeWire online installer calls this*/,
{"http:www.winehq.org/dir/../index.html", 0, "http:www.winehq.org/index.html"}, {"http:www.winehq.org/dir/../index.html", 0, "http:www.winehq.org/index.html"},
{"http://localhost/test.html", URL_FILE_USE_PATHURL, "http://localhost/test.html"}, {"http://localhost/test.html", URL_FILE_USE_PATHURL, "http://localhost/test.html"},
...@@ -318,6 +326,7 @@ typedef struct _TEST_URL_COMBINE { ...@@ -318,6 +326,7 @@ typedef struct _TEST_URL_COMBINE {
const char *url2; const char *url2;
DWORD flags; DWORD flags;
const char *expecturl; const char *expecturl;
BOOL todo;
} TEST_URL_COMBINE; } TEST_URL_COMBINE;
static const TEST_URL_COMBINE TEST_COMBINE[] = { static const TEST_URL_COMBINE TEST_COMBINE[] = {
...@@ -1233,7 +1242,7 @@ static void test_UrlCanonicalizeW(void) ...@@ -1233,7 +1242,7 @@ static void test_UrlCanonicalizeW(void)
/* ########################### */ /* ########################### */
static void check_url_combine(const char *szUrl1, const char *szUrl2, DWORD dwFlags, const char *szExpectUrl) static void check_url_combine(const char *szUrl1, const char *szUrl2, DWORD dwFlags, const char *szExpectUrl, BOOL todo)
{ {
HRESULT hr; HRESULT hr;
CHAR szReturnUrl[INTERNET_MAX_URL_LENGTH]; CHAR szReturnUrl[INTERNET_MAX_URL_LENGTH];
...@@ -1253,17 +1262,28 @@ static void check_url_combine(const char *szUrl1, const char *szUrl2, DWORD dwFl ...@@ -1253,17 +1262,28 @@ static void check_url_combine(const char *szUrl1, const char *szUrl2, DWORD dwFl
dwSize = 0; dwSize = 0;
hr = UrlCombineA(szUrl1, szUrl2, NULL, &dwSize, dwFlags); 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(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); ok(todo || dwSize == dwExpectLen+1, "Got length %ld, expected %ld\n", dwSize, dwExpectLen+1);
dwSize--; dwSize--;
hr = UrlCombineA(szUrl1, szUrl2, szReturnUrl, &dwSize, dwFlags); hr = UrlCombineA(szUrl1, szUrl2, szReturnUrl, &dwSize, dwFlags);
ok(hr == E_POINTER, "UrlCombineA returned 0x%08lx, expected 0x%08lx\n", hr, E_POINTER); 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); ok(todo || dwSize == dwExpectLen+1, "Got length %ld, expected %ld\n", dwSize, dwExpectLen+1);
hr = UrlCombineA(szUrl1, szUrl2, szReturnUrl, &dwSize, dwFlags); hr = UrlCombineA(szUrl1, szUrl2, szReturnUrl, &dwSize, dwFlags);
ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
ok(dwSize == dwExpectLen, "Got length %ld, expected %ld\n", dwSize, dwExpectLen); ok(dwSize == dwExpectLen, "Got length %ld, expected %ld\n", dwSize, dwExpectLen);
ok(!strcmp(szReturnUrl, szExpectUrl), "Expected %s, got %s.\n", szExpectUrl, szReturnUrl);
if (todo)
{
todo_wine ok(dwSize == dwExpectLen && (FAILED(hr) || strcmp(szReturnUrl, szExpectUrl)==0),
"Expected %s (len=%ld), but got %s (len=%ld)\n", szExpectUrl, dwExpectLen, SUCCEEDED(hr) ? szReturnUrl : "(null)", dwSize);
}
else
{
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; dwSize = 0;
hr = UrlCombineW(wszUrl1, wszUrl2, NULL, &dwSize, dwFlags); hr = UrlCombineW(wszUrl1, wszUrl2, NULL, &dwSize, dwFlags);
...@@ -1294,7 +1314,7 @@ static void test_UrlCombine(void) ...@@ -1294,7 +1314,7 @@ static void test_UrlCombine(void)
{ {
unsigned int i; unsigned int i;
for (i = 0; i < ARRAY_SIZE(TEST_COMBINE); i++) { for (i = 0; i < ARRAY_SIZE(TEST_COMBINE); i++) {
check_url_combine(TEST_COMBINE[i].url1, TEST_COMBINE[i].url2, TEST_COMBINE[i].flags, TEST_COMBINE[i].expecturl); check_url_combine(TEST_COMBINE[i].url1, TEST_COMBINE[i].url2, TEST_COMBINE[i].flags, TEST_COMBINE[i].expecturl, TEST_COMBINE[i].todo);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment