0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-30 09:06:21 +01:00

!= operator for HostAndPort

This commit is contained in:
Eliot Horowitz 2010-12-18 23:34:26 -05:00
parent fba685096f
commit fadf89d824
2 changed files with 21 additions and 0 deletions

View File

@ -537,6 +537,21 @@ namespace BasicTests {
};
class HostAndPortTests {
public:
void run(){
HostAndPort a( "x1" , 1000 );
HostAndPort b( "x1" , 1000 );
HostAndPort c( "x1" , 1001 );
HostAndPort d( "x2" , 1000 );
ASSERT( a == b );
ASSERT( a != c );
ASSERT( a != d );
}
};
class All : public Suite {
public:
All() : Suite( "basic" ){
@ -568,6 +583,8 @@ namespace BasicTests {
add< QueueTest >();
add< StrTests >();
add< HostAndPortTests >();
}
} myall;

View File

@ -61,6 +61,10 @@ namespace mongo {
return _host == r._host && port() == r.port();
}
bool operator!=(const HostAndPort& r) const {
return _host != r._host || port() != r.port();
}
/* returns true if the host/port combo identifies this process instance. */
bool isSelf() const; // defined in message.cpp