Rebase webrtc/base with r6655 version of talk/base:

cls to port: r6633,r6639 (there is no cl in between that affects base and all other talk/base cls took care of webrtc/base as well (see r6569, r6624)):
svn diff -r 6632:6639 http://webrtc.googlecode.com/svn/trunk/talk/base > 6655.diff
sed -i.bak "s/talk_base/rtc/g" 6655.diff
patch -p0 -i 6555.diff

BUG=3379
TBR=tommi@webrtc.org,jiayl@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/21879004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@6656 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
henrike@webrtc.org
2014-07-10 22:47:02 +00:00
parent 72491b9a90
commit b614d0626f
3 changed files with 46 additions and 16 deletions

View File

@@ -113,9 +113,17 @@ inline bool Assert(bool result, const char* function, const char* file,
if (!result) {
LogAssert(function, file, line, expression);
Break();
return false;
}
return true;
return result;
}
// Same as Assert above, but does not call Break(). Used in assert macros
// that implement their own breaking.
inline bool AssertNoBreak(bool result, const char* function, const char* file,
int line, const char* expression) {
if (!result)
LogAssert(function, file, line, expression);
return result;
}
} // namespace rtc
@@ -125,13 +133,28 @@ inline bool Assert(bool result, const char* function, const char* file,
#endif
#ifndef ASSERT
#if defined(WIN32)
// Using debugbreak() inline on Windows directly in the ASSERT macro, has the
// benefit of breaking exactly where the failing expression is and not two
// calls up the stack.
#define ASSERT(x) \
(rtc::AssertNoBreak((x), __FUNCTION__, __FILE__, __LINE__, #x) ? \
(void)(1) : __debugbreak())
#else
#define ASSERT(x) \
(void)rtc::Assert((x), __FUNCTION__, __FILE__, __LINE__, #x)
#endif
#endif
#ifndef VERIFY
#if defined(WIN32)
#define VERIFY(x) \
(rtc::AssertNoBreak((x), __FUNCTION__, __FILE__, __LINE__, #x) ? \
true : (__debugbreak(), false))
#else
#define VERIFY(x) rtc::Assert((x), __FUNCTION__, __FILE__, __LINE__, #x)
#endif
#endif
#else // !ENABLE_DEBUG

View File

@@ -227,25 +227,20 @@ bool SocketAddress::operator==(const SocketAddress& addr) const {
}
bool SocketAddress::operator<(const SocketAddress& addr) const {
if (ip_ < addr.ip_)
return true;
else if (addr.ip_ < ip_)
return false;
if (ip_ != addr.ip_)
return ip_ < addr.ip_;
// We only check hostnames if both IPs are zero. This matches EqualIPs()
if (addr.IsAnyIP()) {
if (hostname_ < addr.hostname_)
return true;
else if (addr.hostname_ < hostname_)
return false;
}
// We only check hostnames if both IPs are ANY or unspecified. This matches
// EqualIPs().
if ((IPIsAny(ip_) || IPIsUnspec(ip_)) && hostname_ != addr.hostname_)
return hostname_ < addr.hostname_;
return port_ < addr.port_;
}
bool SocketAddress::EqualIPs(const SocketAddress& addr) const {
return (ip_ == addr.ip_) &&
((!IPIsAny(ip_)) || (hostname_ == addr.hostname_));
((!IPIsAny(ip_) && !IPIsUnspec(ip_)) || (hostname_ == addr.hostname_));
}
bool SocketAddress::EqualPorts(const SocketAddress& addr) const {

View File

@@ -273,10 +273,18 @@ TEST(SocketAddressTest, TestEqualityOperators) {
addr2 = SocketAddress("fe80::1", 5678);
EXPECT_PRED2(AreUnequal, addr1, addr2);
SocketAddress addr3("a.b.c.d", 1);
SocketAddress addr4("b.b.c.d", 1);
EXPECT_PRED2(AreUnequal, addr3, addr4);
EXPECT_PRED2(AreEqual, addr3, addr3);
addr3.SetIP(addr1.ip());
addr4.SetIP(addr1.ip());
EXPECT_PRED2(AreEqual,addr3, addr4);
}
bool IsLessThan(const SocketAddress& addr1,
const SocketAddress& addr2) {
bool IsLessThan(const SocketAddress& addr1, const SocketAddress& addr2) {
return addr1 < addr2 &&
!(addr2 < addr1) &&
!(addr1 == addr2);
@@ -307,6 +315,10 @@ TEST(SocketAddressTest, TestComparisonOperator) {
addr2 = SocketAddress("fe80::1", 5678);
EXPECT_FALSE(addr1 < addr2);
EXPECT_FALSE(addr2 < addr1);
SocketAddress addr3("a.b.c.d", 1);
SocketAddress addr4("b.b.c.d", 1);
EXPECT_PRED2(IsLessThan, addr3, addr4);
}
TEST(SocketAddressTest, TestToSensitiveString) {