Commit 4ed061f4 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

ws2_32/tests: Expand tests for WSAStringToAddress().

Adapted from RtlIpv4StringToAddress() tests. Signed-off-by: 's avatarZebediah Figura <zfigura@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent c70f64f8
......@@ -1093,14 +1093,91 @@ static void test_WSAStringToAddress(void)
}
ipv4_tests[] =
{
{ "0.0.0.0", 0 },
{ "127.127.127.127", 0x7f7f7f7f },
{ "255.255.255.255", 0xffffffff },
{ "127.127.127.127:65535", 0x7f7f7f7f, 65535 },
{ "255.255.255.255:65535", 0xffffffff, 65535 },
{ "2001::1", 0xd1070000, 0, WSAEINVAL },
{ "1.2.3.", 0, 0, WSAEINVAL },
{ "", 0, 0, WSAEINVAL },
{ "", 0, 0, WSAEINVAL },
{ " ", 0, 0, WSAEINVAL },
{ "1.1.1.1", 0x01010101 },
{ "0.0.0.0", 0 },
{ "127.127.127.127", 0x7f7f7f7f },
{ "127.127.127.127:", 0x7f7f7f7f, 0, WSAEINVAL },
{ "127.127.127.127:0", 0x7f7f7f7f, 0, WSAEINVAL },
{ "127.127.127.127:123", 0x7f7f7f7f, 123 },
{ "127.127.127.127:65535", 0x7f7f7f7f, 65535 },
{ "127.127.127.127:65537", 0x7f7f7f7f, 0, WSAEINVAL },
{ "127.127.127.127::1", 0x7f7f7f7f, 0, WSAEINVAL },
{ "127.127.127.127:0xAbCd", 0x7f7f7f7f, 43981 },
{ "127.127.127.127:0XaBcD", 0x7f7f7f7f, 43981 },
{ "127.127.127.127:0x", 0x7f7f7f7f, 0, WSAEINVAL },
{ "127.127.127.127:0x10000",0x7f7f7f7f, 0, WSAEINVAL },
{ "127.127.127.127:010", 0x7f7f7f7f, 8 },
{ "127.127.127.127:007", 0x7f7f7f7f, 7 },
{ "127.127.127.127:08", 0x7f7f7f7f, 0, WSAEINVAL },
{ "127.127.127.127:008", 0x7f7f7f7f, 0, WSAEINVAL },
{ "127.127.127.127:0a", 0x7f7f7f7f, 0, WSAEINVAL },
{ "127.127.127.127:0o10", 0x7f7f7f7f, 0, WSAEINVAL },
{ "127.127.127.127:0b10", 0x7f7f7f7f, 0, WSAEINVAL },
{ "255.255.255.255", 0xffffffff },
{ "255.255.255.255:123", 0xffffffff, 123 },
{ "255.255.255.255:65535", 0xffffffff, 65535 },
{ "255.255.255.256", 0, 0, WSAEINVAL },
{ "a", 0, 0, WSAEINVAL },
{ "1.1.1.0xaA", 0x010101aa },
{ "1.1.1.0XaA", 0x010101aa },
{ "1.1.1.0x", 0, 0, WSAEINVAL },
{ "1.1.1.0xff", 0x010101ff },
{ "1.1.1.0x100", 0, 0, WSAEINVAL },
{ "1.1.1.010", 0x01010108 },
{ "1.1.1.00", 0x01010100 },
{ "1.1.1.007", 0x01010107 },
{ "1.1.1.08", 0, 0, WSAEINVAL },
{ "1.1.1.008", 0x01010100, 0, WSAEINVAL },
{ "1.1.1.0a", 0x01010100, 0, WSAEINVAL },
{ "1.1.1.0o10", 0x01010100, 0, WSAEINVAL },
{ "1.1.1.0b10", 0x01010100, 0, WSAEINVAL },
{ "1.1.1.-2", 0, 0, WSAEINVAL },
{ "1", 0x00000001 },
{ "-1", 0, 0, WSAEINVAL },
{ "1:1", 0x00000001, 1 },
{ "1.2", 0x01000002 },
{ "1.2:1", 0x01000002, 1 },
{ "1000.2000", 0, 0, WSAEINVAL },
{ "1.2.", 0, 0, WSAEINVAL },
{ "1..2", 0, 0, WSAEINVAL },
{ "1...2", 0, 0, WSAEINVAL },
{ "1.2.3", 0x01020003 },
{ "1.2.3.", 0, 0, WSAEINVAL },
{ "1.2.3:1", 0x01020003, 1 },
{ "203569230", 0x0c22384e },
{ "203569230:123", 0x0c22384e, 123 },
{ "2001::1", 0x000007d1, 0, WSAEINVAL },
{ "1.223756", 0x01036a0c },
{ "3.4.756", 0x030402f4 },
{ "756.3.4", 0, 0, WSAEINVAL },
{ "3.756.4", 0, 0, WSAEINVAL },
{ "3.4.756.1", 0, 0, WSAEINVAL },
{ "3.4.65536", 0, 0, WSAEINVAL },
{ "3.4.5.6.7", 0, 0, WSAEINVAL },
{ "3.4.5.+6", 0, 0, WSAEINVAL },
{ " 3.4.5.6", 0, 0, WSAEINVAL },
{ "\t3.4.5.6", 0, 0, WSAEINVAL },
{ "3.4.5.6 ", 0x03040506, 0, WSAEINVAL },
{ "3.4.5.6:7 ", 0x03040506, 0, WSAEINVAL },
{ "3.4.5.6: 7", 0x03040506, 0, WSAEINVAL },
{ "3. 4.5.6", 0, 0, WSAEINVAL },
{ ".", 0, 0, WSAEINVAL },
{ "[0.1.2.3]", 0, 0, WSAEINVAL },
{ "0x00010203", 0x00010203 },
{ "0X00010203", 0x00010203 },
{ "0x00010203:10", 0x00010203, 10 },
{ "0x1234", 0x00001234 },
{ "0x123456789", 0x23456789 },
{ "0x00010Q03", 0x00000010, 0, WSAEINVAL },
{ "x00010203", 0, 0, WSAEINVAL },
{ "1234BEEF", 0x000004d2, 0, WSAEINVAL },
{ "017700000001", 0x7f000001 },
{ "0777", 0x000001ff },
{ "0777:10", 0x000001ff, 10 },
{ "::1", 0, 0, WSAEINVAL },
{ ":1", 0, 0, WSAEINVAL },
};
static struct
{
......@@ -1167,12 +1244,12 @@ static void test_WSAStringToAddress(void)
ok( sockaddr.sin_family == expected_family,
"WSAStringToAddress(%s) gave family %d, expected %d\n",
wine_dbgstr_a( ipv4_tests[j].input ), sockaddr.sin_family, expected_family );
ok( sockaddr.sin_addr.s_addr == ipv4_tests[j].address,
ok( sockaddr.sin_addr.s_addr == htonl( ipv4_tests[j].address ),
"WSAStringToAddress(%s) gave address %08x, expected %08x\n",
wine_dbgstr_a( ipv4_tests[j].input ), sockaddr.sin_addr.s_addr, ipv4_tests[j].address );
ok( sockaddr.sin_port == ipv4_tests[j].port,
wine_dbgstr_a( ipv4_tests[j].input ), sockaddr.sin_addr.s_addr, htonl( ipv4_tests[j].address) );
ok( sockaddr.sin_port == htons( ipv4_tests[j].port ),
"WSAStringToAddress(%s) gave port %04x, expected %04x\n",
wine_dbgstr_a( ipv4_tests[j].input ), sockaddr.sin_port, ipv4_tests[j].port );
wine_dbgstr_a( ipv4_tests[j].input ), sockaddr.sin_port, htons( ipv4_tests[j].port ) );
ok( len == expected_len,
"WSAStringToAddress(%s) gave length %d, expected %d\n",
wine_dbgstr_a( ipv4_tests[j].input ), len, expected_len );
......
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