Exemplo n.º 1
0
void test_IPv4Address() {
	const char* ADDR = "192.0.2.10";

	sockaddr_u input = CreateSockaddr4(ADDR);
	struct addrinfo inputA = CreateAddrinfo(&input);

	TEST_ASSERT_EQUAL_STRING(ADDR, ss_to_str(&input));
	TEST_ASSERT_EQUAL_STRING(ADDR, addrinfo_to_str(&inputA));
}
Exemplo n.º 2
0
TEST(utilities, IPv4Address) {
	const char* ADDR = "192.0.2.10";

	sockaddr_u input = CreateSockaddr4(ADDR, 123);
	struct addrinfo inputA = CreateAddrinfo(&input);

	/* coverity[leaked_storage] */
	TEST_ASSERT_EQUAL_STRING(ADDR, ss_to_str(&input));
	/* coverity[leaked_storage] */
	TEST_ASSERT_EQUAL_STRING(ADDR, addrinfo_to_str(&inputA));
	/* coverity[leaked_storage] */
}
Exemplo n.º 3
0
void test_IPv6Address() {
	const struct in6_addr address = {
						0x20, 0x01, 0x0d, 0xb8,
						0x85, 0xa3, 0x08, 0xd3, 
						0x13, 0x19, 0x8a, 0x2e,
						0x03, 0x70, 0x73, 0x34
					};
	const char * expected = "2001:db8:85a3:8d3:1319:8a2e:370:7334";
	sockaddr_u	input;
	struct addrinfo	inputA;

	memset(&input, 0, sizeof(input));
	input.sa6.sin6_family = AF_INET6;
	input.sa6.sin6_addr = address;
	TEST_ASSERT_EQUAL_STRING(expected, ss_to_str(&input));

	inputA = CreateAddrinfo(&input);
	TEST_ASSERT_EQUAL_STRING(expected, addrinfo_to_str(&inputA));
}