mirror of
https://github.com/zeromq/libzmq.git
synced 2025-10-20 05:49:07 +02:00
Problem: remaining basic assertions
Solution: use unity assertions instead
This commit is contained in:
@@ -27,22 +27,23 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
// On windows we can receive an IPv4 address even when an IPv6 is requested, if
|
||||
// we're in this situation then we compare to 'expected_addr_v4_failover_'
|
||||
// instead.
|
||||
void validate_address(int family, const zmq::ip_addr_t *addr_,
|
||||
const char *expected_addr_,
|
||||
uint16_t expected_port_ = 0,
|
||||
uint16_t expected_zone_ = 0,
|
||||
const char *expected_addr_v4_failover_ = NULL)
|
||||
void validate_address (int family,
|
||||
const zmq::ip_addr_t *addr_,
|
||||
const char *expected_addr_,
|
||||
uint16_t expected_port_ = 0,
|
||||
uint16_t expected_zone_ = 0,
|
||||
const char *expected_addr_v4_failover_ = NULL)
|
||||
{
|
||||
#if defined ZMQ_HAVE_WINDOWS
|
||||
if (family == AF_INET6 && expected_addr_v4_failover_ != NULL &&
|
||||
addr_->family () == AF_INET) {
|
||||
#if defined ZMQ_HAVE_WINDOWS
|
||||
if (family == AF_INET6 && expected_addr_v4_failover_ != NULL
|
||||
&& addr_->family () == AF_INET) {
|
||||
// We've requested an IPv6 but the system gave us an IPv4, use the
|
||||
// failover address
|
||||
family = AF_INET;
|
||||
expected_addr_ = expected_addr_v4_failover_;
|
||||
}
|
||||
#else
|
||||
(void)expected_addr_v4_failover_;
|
||||
(void) expected_addr_v4_failover_;
|
||||
#endif
|
||||
|
||||
TEST_ASSERT_EQUAL (family, addr_->family ());
|
||||
@@ -51,7 +52,8 @@ void validate_address(int family, const zmq::ip_addr_t *addr_,
|
||||
struct in6_addr expected_addr;
|
||||
const sockaddr_in6 *ip6_addr = &addr_->ipv6;
|
||||
|
||||
assert (test_inet_pton (AF_INET6, expected_addr_, &expected_addr) == 1);
|
||||
TEST_ASSERT_EQUAL (
|
||||
1, test_inet_pton (AF_INET6, expected_addr_, &expected_addr));
|
||||
|
||||
int neq = memcmp (&ip6_addr->sin6_addr, &expected_addr,
|
||||
sizeof (expected_addr_));
|
||||
@@ -63,7 +65,8 @@ void validate_address(int family, const zmq::ip_addr_t *addr_,
|
||||
struct in_addr expected_addr;
|
||||
const sockaddr_in *ip4_addr = &addr_->ipv4;
|
||||
|
||||
assert (test_inet_pton (AF_INET, expected_addr_, &expected_addr) == 1);
|
||||
TEST_ASSERT_EQUAL (
|
||||
1, test_inet_pton (AF_INET, expected_addr_, &expected_addr));
|
||||
|
||||
TEST_ASSERT_EQUAL (expected_addr.s_addr, ip4_addr->sin_addr.s_addr);
|
||||
TEST_ASSERT_EQUAL (htons (expected_port_), ip4_addr->sin_port);
|
||||
|
Reference in New Issue
Block a user