diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-29 18:13:07 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-29 18:13:07 +0000 |
commit | 9b6fee14acedde5c6b627d5f9b691776fc8d868c (patch) | |
tree | 8cd3438dc3b6504066f89096e37db4cff4b903ed /net | |
parent | b1ed7b9beaf3069b54084c453da6db6bed56607c (diff) | |
download | chromium_src-9b6fee14acedde5c6b627d5f9b691776fc8d868c.zip chromium_src-9b6fee14acedde5c6b627d5f9b691776fc8d868c.tar.gz chromium_src-9b6fee14acedde5c6b627d5f9b691776fc8d868c.tar.bz2 |
Avoid potential "NULL used as int" warnings by changing ASSERT_EQ(NULL, ...) to ASSERT_TRUE(... == NULL). Patch by Jacob Mandelson (see http://codereview.chromium.org/202057 ), r=me.
BUG=none
TEST=none
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27511 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/base/host_cache_unittest.cc | 34 | ||||
-rw-r--r-- | net/base/ssl_client_auth_cache_unittest.cc | 6 | ||||
-rw-r--r-- | net/ftp/ftp_auth_cache_unittest.cc | 12 | ||||
-rw-r--r-- | net/http/http_network_transaction_unittest.cc | 10 | ||||
-rw-r--r-- | net/proxy/single_threaded_proxy_resolver_unittest.cc | 4 | ||||
-rw-r--r-- | net/socket/client_socket_pool_base_unittest.cc | 9 |
6 files changed, 36 insertions, 39 deletions
diff --git a/net/base/host_cache_unittest.cc b/net/base/host_cache_unittest.cc index fe01e20..2259185 100644 --- a/net/base/host_cache_unittest.cc +++ b/net/base/host_cache_unittest.cc @@ -28,17 +28,17 @@ TEST(HostCacheTest, Basic) { EXPECT_EQ(0U, cache.size()); // Add an entry for "foobar.com" at t=0. - EXPECT_EQ(NULL, cache.Lookup("foobar.com", base::TimeTicks())); + EXPECT_TRUE(cache.Lookup("foobar.com", base::TimeTicks()) == NULL); cache.Set("foobar.com", OK, AddressList(), now); entry1 = cache.Lookup("foobar.com", base::TimeTicks()); - EXPECT_FALSE(NULL == entry1); + EXPECT_FALSE(entry1 == NULL); EXPECT_EQ(1U, cache.size()); // Advance to t=5. now += base::TimeDelta::FromSeconds(5); // Add an entry for "foobar2.com" at t=5. - EXPECT_EQ(NULL, cache.Lookup("foobar2.com", base::TimeTicks())); + EXPECT_TRUE(cache.Lookup("foobar2.com", base::TimeTicks()) == NULL); cache.Set("foobar2.com", OK, AddressList(), now); entry2 = cache.Lookup("foobar2.com", base::TimeTicks()); EXPECT_FALSE(NULL == entry1); @@ -54,7 +54,7 @@ TEST(HostCacheTest, Basic) { // Advance to t=10; entry1 is now expired. now += base::TimeDelta::FromSeconds(1); - EXPECT_EQ(NULL, cache.Lookup("foobar.com", now)); + EXPECT_TRUE(cache.Lookup("foobar.com", now) == NULL); EXPECT_EQ(entry2, cache.Lookup("foobar2.com", now)); // Update entry1, so it is no longer expired. @@ -70,8 +70,8 @@ TEST(HostCacheTest, Basic) { // Advance to t=20; both entries are now expired. now += base::TimeDelta::FromSeconds(10); - EXPECT_EQ(NULL, cache.Lookup("foobar.com", now)); - EXPECT_EQ(NULL, cache.Lookup("foobar2.com", now)); + EXPECT_TRUE(cache.Lookup("foobar.com", now) == NULL); + EXPECT_TRUE(cache.Lookup("foobar2.com", now) == NULL); } // Try caching entries for a failed resolve attempt. @@ -81,19 +81,19 @@ TEST(HostCacheTest, NegativeEntry) { // Set t=0. base::TimeTicks now; - EXPECT_EQ(NULL, cache.Lookup("foobar.com", base::TimeTicks())); + EXPECT_TRUE(cache.Lookup("foobar.com", base::TimeTicks()) == NULL); cache.Set("foobar.com", ERR_NAME_NOT_RESOLVED, AddressList(), now); EXPECT_EQ(1U, cache.size()); // We disallow use of negative entries. - EXPECT_EQ(NULL, cache.Lookup("foobar.com", now)); + EXPECT_TRUE(cache.Lookup("foobar.com", now) == NULL); // Now overwrite with a valid entry, and then overwrite with negative entry // again -- the valid entry should be kicked out. cache.Set("foobar.com", OK, AddressList(), now); - EXPECT_FALSE(NULL == cache.Lookup("foobar.com", now)); + EXPECT_FALSE(cache.Lookup("foobar.com", now) == NULL); cache.Set("foobar.com", ERR_NAME_NOT_RESOLVED, AddressList(), now); - EXPECT_EQ(NULL, cache.Lookup("foobar.com", now)); + EXPECT_TRUE(cache.Lookup("foobar.com", now) == NULL); } TEST(HostCacheTest, Compact) { @@ -185,10 +185,10 @@ TEST(HostCacheTest, SetWithCompact) { // Adding the fourth entry will cause "expired" to be evicted. cache.Set("host3", OK, AddressList(), now); EXPECT_EQ(3U, cache.size()); - EXPECT_EQ(NULL, cache.Lookup("expired", now)); - EXPECT_FALSE(NULL == cache.Lookup("host1", now)); - EXPECT_FALSE(NULL == cache.Lookup("host2", now)); - EXPECT_FALSE(NULL == cache.Lookup("host3", now)); + EXPECT_TRUE(cache.Lookup("expired", now) == NULL); + EXPECT_FALSE(cache.Lookup("host1", now) == NULL); + EXPECT_FALSE(cache.Lookup("host2", now) == NULL); + EXPECT_FALSE(cache.Lookup("host3", now) == NULL); // Add two more entries. Something should be evicted, however "host5" // should definitely be in there (since it was last inserted). @@ -196,7 +196,7 @@ TEST(HostCacheTest, SetWithCompact) { EXPECT_EQ(3U, cache.size()); cache.Set("host5", OK, AddressList(), now); EXPECT_EQ(3U, cache.size()); - EXPECT_FALSE(NULL == cache.Lookup("host5", now)); + EXPECT_FALSE(cache.Lookup("host5", now) == NULL); } TEST(HostCacheTest, NoCache) { @@ -208,9 +208,9 @@ TEST(HostCacheTest, NoCache) { base::TimeTicks now; // Lookup and Set should have no effect. - EXPECT_EQ(NULL, cache.Lookup("foobar.com", base::TimeTicks())); + EXPECT_TRUE(cache.Lookup("foobar.com", base::TimeTicks()) == NULL); cache.Set("foobar.com", OK, AddressList(), now); - EXPECT_EQ(NULL, cache.Lookup("foobar.com", base::TimeTicks())); + EXPECT_TRUE(cache.Lookup("foobar.com", base::TimeTicks()) == NULL); EXPECT_EQ(0U, cache.size()); } diff --git a/net/base/ssl_client_auth_cache_unittest.cc b/net/base/ssl_client_auth_cache_unittest.cc index 33eb25f..85b3d5e 100644 --- a/net/base/ssl_client_auth_cache_unittest.cc +++ b/net/base/ssl_client_auth_cache_unittest.cc @@ -28,7 +28,7 @@ TEST(SSLClientAuthCacheTest, LookupAddRemove) { new X509Certificate("foo3", "CA", start_date, expiration_date)); // Lookup non-existent client certificate. - EXPECT_EQ(NULL, cache.Lookup(server1)); + EXPECT_TRUE(cache.Lookup(server1) == NULL); // Add client certificate for server1. cache.Add(server1, cert1.get()); @@ -46,12 +46,12 @@ TEST(SSLClientAuthCacheTest, LookupAddRemove) { // Remove client certificate of server1. cache.Remove(server1); - EXPECT_EQ(NULL, cache.Lookup(server1)); + EXPECT_TRUE(cache.Lookup(server1) == NULL); EXPECT_EQ(cert2.get(), cache.Lookup(server2)); // Remove non-existent client certificate. cache.Remove(server1); - EXPECT_EQ(NULL, cache.Lookup(server1)); + EXPECT_TRUE(cache.Lookup(server1) == NULL); EXPECT_EQ(cert2.get(), cache.Lookup(server2)); } diff --git a/net/ftp/ftp_auth_cache_unittest.cc b/net/ftp/ftp_auth_cache_unittest.cc index 3f04d96..b23781e 100644 --- a/net/ftp/ftp_auth_cache_unittest.cc +++ b/net/ftp/ftp_auth_cache_unittest.cc @@ -17,7 +17,7 @@ TEST(FtpAuthCacheTest, LookupAddRemove) { GURL origin2("ftp://foo2"); // Lookup non-existent entry. - EXPECT_EQ(NULL, cache.Lookup(origin1)); + EXPECT_TRUE(cache.Lookup(origin1) == NULL); // Add entry for origin1. cache.Add(origin1, L"username1", L"password1"); @@ -48,11 +48,11 @@ TEST(FtpAuthCacheTest, LookupAddRemove) { // Remove entry of origin1. cache.Remove(origin1, L"username3", L"password3"); - EXPECT_EQ(NULL, cache.Lookup(origin1)); + EXPECT_TRUE(cache.Lookup(origin1) == NULL); // Remove non-existent entry. cache.Remove(origin1, L"username3", L"password3"); - EXPECT_EQ(NULL, cache.Lookup(origin1)); + EXPECT_TRUE(cache.Lookup(origin1) == NULL); } // Check that if the origin differs only by port number, it is considered @@ -95,7 +95,7 @@ TEST(FtpAuthCacheTest, NormalizedKey) { // Remove cache.Remove(GURL("ftp://HOsT"), L"othername", L"otherword"); - EXPECT_EQ(NULL, cache.Lookup(GURL("ftp://host"))); + EXPECT_TRUE(cache.Lookup(GURL("ftp://host")) == NULL); } TEST(FtpAuthCacheTest, OnlyRemoveMatching) { @@ -110,7 +110,7 @@ TEST(FtpAuthCacheTest, OnlyRemoveMatching) { // Auth data matches, should remove. cache.Remove(GURL("ftp://host"), L"username", L"password"); - EXPECT_EQ(NULL, cache.Lookup(GURL("ftp://host"))); + EXPECT_TRUE(cache.Lookup(GURL("ftp://host")) == NULL); } TEST(FtpAuthCacheTest, EvictOldEntries) { @@ -126,7 +126,7 @@ TEST(FtpAuthCacheTest, EvictOldEntries) { // Adding one entry should cause eviction of the first entry. cache.Add(GURL("ftp://last_host"), L"username", L"password"); - EXPECT_EQ(NULL, cache.Lookup(GURL("ftp://host0"))); + EXPECT_TRUE(cache.Lookup(GURL("ftp://host0")) == NULL); // Remaining entries should not get evicted. for (size_t i = 1; i < FtpAuthCache::kMaxEntries; i++) { diff --git a/net/http/http_network_transaction_unittest.cc b/net/http/http_network_transaction_unittest.cc index 0148a77..b80938e 100644 --- a/net/http/http_network_transaction_unittest.cc +++ b/net/http/http_network_transaction_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -2757,19 +2757,19 @@ TEST_F(HttpNetworkTransactionTest, ResetStateForRestart) { trans->ResetStateForRestart(); // Verify that the state that needed to be reset, has been reset. - EXPECT_EQ(NULL, trans->header_buf_->headers()); + EXPECT_TRUE(trans->header_buf_->headers() == NULL); EXPECT_EQ(0, trans->header_buf_capacity_); EXPECT_EQ(0, trans->header_buf_len_); EXPECT_EQ(-1, trans->header_buf_body_offset_); EXPECT_EQ(-1, trans->header_buf_http_offset_); EXPECT_EQ(-1, trans->response_body_length_); EXPECT_EQ(0, trans->response_body_read_); - EXPECT_EQ(NULL, trans->read_buf_.get()); + EXPECT_TRUE(trans->read_buf_.get() == NULL); EXPECT_EQ(0, trans->read_buf_len_); EXPECT_EQ("", trans->request_headers_->headers_); EXPECT_EQ(0U, trans->request_headers_bytes_sent_); - EXPECT_EQ(NULL, trans->response_.auth_challenge.get()); - EXPECT_EQ(NULL, trans->response_.headers.get()); + EXPECT_TRUE(trans->response_.auth_challenge.get() == NULL); + EXPECT_TRUE(trans->response_.headers.get() == NULL); EXPECT_EQ(false, trans->response_.was_cached); EXPECT_EQ(0, trans->response_.ssl_info.cert_status); EXPECT_FALSE(trans->response_.vary_data.is_valid()); diff --git a/net/proxy/single_threaded_proxy_resolver_unittest.cc b/net/proxy/single_threaded_proxy_resolver_unittest.cc index 7718602..7eee997 100644 --- a/net/proxy/single_threaded_proxy_resolver_unittest.cc +++ b/net/proxy/single_threaded_proxy_resolver_unittest.cc @@ -36,8 +36,8 @@ class MockProxyResolver : public ProxyResolver { CheckIsOnWorkerThread(); - EXPECT_EQ(NULL, callback); - EXPECT_EQ(NULL, request); + EXPECT_TRUE(callback == NULL); + EXPECT_TRUE(request == NULL); // Write something into |load_log| (doesn't really have any meaning.) LoadLog::BeginEvent(load_log, LoadLog::TYPE_PROXY_RESOLVER_V8_DNS_RESOLVE); diff --git a/net/socket/client_socket_pool_base_unittest.cc b/net/socket/client_socket_pool_base_unittest.cc index 249d7e3..5741b91 100644 --- a/net/socket/client_socket_pool_base_unittest.cc +++ b/net/socket/client_socket_pool_base_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -340,11 +340,8 @@ class TestConnectJobDelegate : public ConnectJob::Delegate { virtual void OnConnectJobComplete(int result, ConnectJob* job) { result_ = result; scoped_ptr<ClientSocket> socket(job->ReleaseSocket()); - if (result == OK) { - EXPECT_TRUE(socket.get() != NULL); - } else { - EXPECT_EQ(NULL, socket.get()); - } + // socket.get() should be NULL iff result != OK + EXPECT_EQ(socket.get() == NULL, result != OK); delete job; have_result_ = true; if (waiting_for_result_) |