[PATCH] wininet: Conformance test for InternetCrackUrlA.txt

Nigel Liang ncliang at gmail.com
Tue Oct 16 23:49:34 CDT 2007


Hi,

Conformance tests for InternetCrackUrlA. Tested on Windows XP.

-Nigel

---
 dlls/wininet/tests/internet.c |   66 +++++++++++++++++++++++++++++++++++++++++
 1 files changed, 66 insertions(+), 0 deletions(-)

diff --git a/dlls/wininet/tests/internet.c b/dlls/wininet/tests/internet.c
old mode 100644
new mode 100755
index 9fac11e..5b55094
--- a/dlls/wininet/tests/internet.c
+++ b/dlls/wininet/tests/internet.c
@@ -311,6 +311,71 @@ static void test_null(void)
 
 }
 
+static void test_InternetCrackUrlA(void)
+{
+  static const char szUrl[] = "http://username:passwd@host:21/path?extra";
+  static const char sUrl[] = {'h','t','t','p',':','/','/','h','o','s','t'};
+  char szBuf[1024];
+  URL_COMPONENTSA urlCompa;
+  BOOL bRet;
+
+  ZeroMemory(&urlCompa, sizeof(urlCompa));
+  urlCompa.dwExtraInfoLength = urlCompa.dwHostNameLength =
+    urlCompa.dwUrlPathLength = urlCompa.dwSchemeLength =
+    urlCompa.dwUserNameLength = urlCompa.dwPasswordLength = 1;
+  urlCompa.dwStructSize = sizeof(urlCompa);
+  bRet = InternetCrackUrlA(szUrl, 0, 0, &urlCompa);
+  ok( bRet == TRUE, "return wrong\n");
+  ok( strncmp(szUrl, urlCompa.lpszScheme, urlCompa.dwSchemeLength) == 0,
+      "scheme wrong\n");
+  ok( strncmp("username", urlCompa.lpszUserName, urlCompa.dwUserNameLength) == 0,
+      "username wrong\n");
+  ok( strncmp("passwd", urlCompa.lpszPassword, urlCompa.dwPasswordLength) == 0,
+      "password wrong\n");
+  ok( strncmp("host", urlCompa.lpszHostName, urlCompa.dwHostNameLength) == 0,
+      "hostname wrong\n");
+  ok( urlCompa.nPort == 21, "port wrong\n");
+  ok( strncmp("/path", urlCompa.lpszUrlPath, urlCompa.dwUrlPathLength) == 0,
+      "path wrong\n");
+  ok( strncmp("?extra", urlCompa.lpszExtraInfo, urlCompa.dwExtraInfoLength) == 0,
+      "extra info wrong\n");
+
+  ZeroMemory(&urlCompa, sizeof(urlCompa));
+  urlCompa.dwExtraInfoLength = urlCompa.dwHostNameLength =
+    urlCompa.dwUrlPathLength = urlCompa.dwSchemeLength =
+    urlCompa.dwUserNameLength = urlCompa.dwPasswordLength = 1;
+  urlCompa.dwStructSize = sizeof(urlCompa);
+  bRet = InternetCrackUrlA(sUrl, 11, 0, &urlCompa);
+  ok( bRet == TRUE, "return wrong\n");
+  ok( strncmp("host", urlCompa.lpszHostName, urlCompa.dwHostNameLength) == 0,
+      "hostname wrong\n");
+  ok( !urlCompa.lpszExtraInfo, "should be no extra info\n");
+
+  ZeroMemory(&urlCompa, sizeof(urlCompa));
+  ZeroMemory(&szBuf, sizeof(char)*1024);
+  urlCompa.dwExtraInfoLength = urlCompa.dwHostNameLength =
+    urlCompa.dwUrlPathLength = urlCompa.dwSchemeLength =
+    urlCompa.dwPasswordLength = 1;
+  urlCompa.lpszUserName = szBuf;
+  urlCompa.dwUserNameLength = 1024;
+  urlCompa.dwStructSize = sizeof(urlCompa);
+  bRet = InternetCrackUrlA(szUrl, 0, 0, &urlCompa);
+  ok( bRet == TRUE, "return wrong\n");
+  ok( strncmp(szBuf, "username", urlCompa.dwUserNameLength) == 0,
+      "username not copied into buffer\n");
+
+  SetLastError(0xdeadbeef);
+  ZeroMemory(&urlCompa, sizeof(urlCompa));
+  urlCompa.dwExtraInfoLength = urlCompa.dwHostNameLength =
+    urlCompa.dwUrlPathLength = urlCompa.dwSchemeLength =
+    urlCompa.dwUserNameLength = urlCompa.dwPasswordLength = 1;
+  urlCompa.dwStructSize = sizeof(urlCompa);
+  bRet = InternetCrackUrlA(NULL, 0, 0, &urlCompa);
+  ok( bRet == FALSE, "return wrong\n");
+  ok( GetLastError() == ERROR_INVALID_PARAMETER, "Last error wrong: %p\n",
+      GetLastError());
+}
+
 /* ############################### */
 
 START_TEST(internet)
@@ -319,4 +384,5 @@ START_TEST(internet)
   test_InternetQueryOptionA();
   test_get_cookie();
   test_null();
+  test_InternetCrackUrlA();
 }
-- 
1.4.1




More information about the wine-patches mailing list