From 07da96698f552090621960295ce15666b4af557e Mon Sep 17 00:00:00 2001 From: Marc Laukien Date: Sun, 9 Sep 2001 02:36:43 +0000 Subject: more tests, fixes to operator< and operator== --- cpp/src/Ice/Endpoint.cpp | 94 +++++++++++++++++------------------------------- 1 file changed, 32 insertions(+), 62 deletions(-) (limited to 'cpp/src/Ice/Endpoint.cpp') diff --git a/cpp/src/Ice/Endpoint.cpp b/cpp/src/Ice/Endpoint.cpp index 833af74472b..d8753565839 100644 --- a/cpp/src/Ice/Endpoint.cpp +++ b/cpp/src/Ice/Endpoint.cpp @@ -198,30 +198,24 @@ IceInternal::UnknownEndpoint::equivalent(const AcceptorPtr&) const bool IceInternal::UnknownEndpoint::operator==(const Endpoint& r) const -{ - return !operator!=(r); -} - -bool -IceInternal::UnknownEndpoint::operator!=(const Endpoint& r) const { const UnknownEndpoint* p = dynamic_cast(&r); if (!p) { - return true; + return false; } if (this == p) { - return false; + return true; } if (_rawBytes != p->_rawBytes) { - return true; + return false; } - return false; + return true; } bool @@ -465,45 +459,38 @@ IceInternal::TcpEndpoint::equivalent(const AcceptorPtr& acceptor) const bool IceInternal::TcpEndpoint::operator==(const Endpoint& r) const -{ - return !operator!=(r); -} - -bool -IceInternal::TcpEndpoint::operator!=(const Endpoint& r) const { const TcpEndpoint* p = dynamic_cast(&r); if (!p) { - return true; + return false; } if (this == p) { - return false; + return true; } if (_port != p->_port) { - return true; + return false; } - + + if(_timeout != p->_timeout) + { + return false; + } + struct sockaddr_in laddr; struct sockaddr_in raddr; getAddress(_host.c_str(), _port, laddr); getAddress(p->_host.c_str(), p->_port, raddr); - if (memcmp(&laddr, &raddr, sizeof(struct sockaddr_in)) != 0) { - return true; - } - - if (_timeout != p->_timeout) - { - return true; + return false; } - return false; + return true; } bool @@ -539,7 +526,6 @@ IceInternal::TcpEndpoint::operator<(const Endpoint& r) const struct sockaddr_in raddr; getAddress(_host.c_str(), _port, laddr); getAddress(p->_host.c_str(), p->_port, raddr); - if (laddr.sin_addr.s_addr < raddr.sin_addr.s_addr) { return true; @@ -785,45 +771,38 @@ IceInternal::SslEndpoint::equivalent(const AcceptorPtr& acceptor) const bool IceInternal::SslEndpoint::operator==(const Endpoint& r) const -{ - return !operator!=(r); -} - -bool -IceInternal::SslEndpoint::operator!=(const Endpoint& r) const { const SslEndpoint* p = dynamic_cast(&r); if (!p) { - return true; + return false; } if (this == p) { - return false; + return true; } if (_port != p->_port) { - return true; + return false; } - + + if(_timeout != p->_timeout) + { + return false; + } + struct sockaddr_in laddr; struct sockaddr_in raddr; getAddress(_host.c_str(), _port, laddr); getAddress(p->_host.c_str(), p->_port, raddr); - if (memcmp(&laddr, &raddr, sizeof(struct sockaddr_in)) != 0) { - return true; - } - - if (_timeout != p->_timeout) - { - return true; + return false; } - return false; + return true; } bool @@ -859,7 +838,6 @@ IceInternal::SslEndpoint::operator<(const Endpoint& r) const struct sockaddr_in raddr; getAddress(_host.c_str(), _port, laddr); getAddress(p->_host.c_str(), p->_port, raddr); - if (laddr.sin_addr.s_addr < raddr.sin_addr.s_addr) { return true; @@ -1083,40 +1061,33 @@ IceInternal::UdpEndpoint::equivalent(const AcceptorPtr&) const bool IceInternal::UdpEndpoint::operator==(const Endpoint& r) const -{ - return !operator!=(r); -} - -bool -IceInternal::UdpEndpoint::operator!=(const Endpoint& r) const { const UdpEndpoint* p = dynamic_cast(&r); if (!p) { - return true; + return false; } if (this == p) { - return false; + return true; } if (_port != p->_port) { - return true; + return false; } - + struct sockaddr_in laddr; struct sockaddr_in raddr; getAddress(_host.c_str(), _port, laddr); getAddress(p->_host.c_str(), p->_port, raddr); - if (memcmp(&laddr, &raddr, sizeof(struct sockaddr_in)) != 0) { - return true; + return false; } - return false; + return true; } bool @@ -1152,7 +1123,6 @@ IceInternal::UdpEndpoint::operator<(const Endpoint& r) const struct sockaddr_in raddr; getAddress(_host.c_str(), _port, laddr); getAddress(p->_host.c_str(), p->_port, raddr); - if (laddr.sin_addr.s_addr < raddr.sin_addr.s_addr) { return true; -- cgit v1.2.3