ws2_32/tests: Add IDN resolution tests for GetAddrInfoW.

Signed-off-by: Bruno Jesus <00cpxxx@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Bruno Jesus 2016-11-29 15:23:14 -02:00 committed by Alexandre Julliard
parent d684831f4a
commit 590c908088
2 changed files with 79 additions and 0 deletions
dlls/ws2_32/tests
include

View File

@ -6811,6 +6811,11 @@ static void test_GetAddrInfoW(void)
ADDRINFOW *result, *result2, *p, hint;
WCHAR name[256];
DWORD size = sizeof(name)/sizeof(WCHAR);
/* te su to.winehq.org written in katakana */
static const WCHAR idn_domain[] =
{0x30C6,0x30B9,0x30C8,'.','w','i','n','e','h','q','.','o','r','g',0};
static const WCHAR idn_punycode[] =
{'x','n','-','-','z','c','k','z','a','h','.','w','i','n','e','h','q','.','o','r','g',0};
if (!pGetAddrInfoW || !pFreeAddrInfoW)
{
@ -6993,6 +6998,78 @@ static void test_GetAddrInfoW(void)
ok(0, "test %d: GetAddrInfoW failed with %d (err %d)\n", i, ret, err);
}
}
/* Test IDN resolution (Internationalized Domain Names) present since Windows 8 */
trace("Testing punycode IDN %s\n", wine_dbgstr_w(idn_punycode));
result = NULL;
ret = pGetAddrInfoW(idn_punycode, NULL, NULL, &result);
ok(!ret, "got %d expected success\n", ret);
ok(result != NULL, "got %p\n", result);
pFreeAddrInfoW(result);
hint.ai_family = AF_INET;
hint.ai_socktype = 0;
hint.ai_protocol = 0;
hint.ai_flags = 0;
result = NULL;
ret = pGetAddrInfoW(idn_punycode, NULL, &hint, &result);
ok(!ret, "got %d expected success\n", ret);
ok(result != NULL, "got %p\n", result);
trace("Testing unicode IDN %s\n", wine_dbgstr_w(idn_domain));
result2 = NULL;
ret = pGetAddrInfoW(idn_domain, NULL, NULL, &result2);
if (ret == WSAHOST_NOT_FOUND && broken(1))
{
pFreeAddrInfoW(result);
win_skip("IDN resolution not supported in Win <= 7\n");
return;
}
todo_wine {
ok(!ret, "got %d expected success\n", ret);
ok(result2 != NULL, "got %p\n", result2);
pFreeAddrInfoW(result2);
hint.ai_family = AF_INET;
hint.ai_socktype = 0;
hint.ai_protocol = 0;
hint.ai_flags = 0;
result2 = NULL;
ret = pGetAddrInfoW(idn_domain, NULL, &hint, &result2);
ok(!ret, "got %d expected success\n", ret);
ok(result2 != NULL, "got %p\n", result2);
/* ensure manually resolved punycode and unicode hosts result in same data */
compare_addrinfow(result, result2);
pFreeAddrInfoW(result);
pFreeAddrInfoW(result2);
hint.ai_family = AF_INET;
hint.ai_socktype = 0;
hint.ai_protocol = 0;
hint.ai_flags = 0;
result2 = NULL;
ret = pGetAddrInfoW(idn_domain, NULL, &hint, &result2);
ok(!ret, "got %d expected success\n", ret);
ok(result2 != NULL, "got %p\n", result2);
pFreeAddrInfoW(result2);
}
/* Disable IDN resolution and test again*/
hint.ai_family = AF_INET;
hint.ai_socktype = 0;
hint.ai_protocol = 0;
hint.ai_flags = AI_DISABLE_IDN_ENCODING;
SetLastError(0xdeadbeef);
result2 = NULL;
ret = pGetAddrInfoW(idn_domain, NULL, &hint, &result2);
ok(ret == WSAHOST_NOT_FOUND, "got %d expected WSAHOST_NOT_FOUND\n", ret);
ok(WSAGetLastError() == WSAHOST_NOT_FOUND, "expected 11001, got %d\n", WSAGetLastError());
ok(result2 == NULL, "got %p\n", result2);
}
static void test_getaddrinfo(void)

View File

@ -69,6 +69,7 @@ typedef ADDRINFOA ADDRINFO, *LPADDRINFO;
# define AI_NON_AUTHORITATIVE 0x00004000
# define AI_SECURE 0x00008000
# define AI_RETURN_PREFERRED_NAMES 0x00010000
# define AI_DISABLE_IDN_ENCODING 0x00080000
/* getaddrinfo error codes */
# define EAI_AGAIN WSATRY_AGAIN
# define EAI_BADFLAGS WSAEINVAL
@ -89,6 +90,7 @@ typedef ADDRINFOA ADDRINFO, *LPADDRINFO;
# define WS_AI_NON_AUTHORITATIVE 0x00004000
# define WS_AI_SECURE 0x00008000
# define WS_AI_RETURN_PREFERRED_NAMES 0x00010000
# define WS_AI_DISABLE_IDN_ENCODING 0x00080000
/* getaddrinfo error codes */
# define WS_EAI_AGAIN WSATRY_AGAIN
# define WS_EAI_BADFLAGS WSAEINVAL