| OLD | NEW | 
|    1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |    1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 
|    2 // Use of this source code is governed by a BSD-style license that can be |    2 // Use of this source code is governed by a BSD-style license that can be | 
|    3 // found in the LICENSE file. |    3 // found in the LICENSE file. | 
|    4  |    4  | 
|    5 #include "net/base/host_cache.h" |    5 #include "net/base/host_cache.h" | 
|    6  |    6  | 
 |    7 #include "base/format_macros.h" | 
|    7 #include "base/stl_util-inl.h" |    8 #include "base/stl_util-inl.h" | 
|    8 #include "base/string_util.h" |    9 #include "base/string_util.h" | 
|    9 #include "net/base/net_errors.h" |   10 #include "net/base/net_errors.h" | 
|   10 #include "testing/gtest/include/gtest/gtest.h" |   11 #include "testing/gtest/include/gtest/gtest.h" | 
|   11  |   12  | 
|   12 namespace net { |   13 namespace net { | 
|   13  |   14  | 
|   14 namespace { |   15 namespace { | 
|   15 const int kMaxCacheEntries = 10; |   16 const int kMaxCacheEntries = 10; | 
|   16 const int kCacheDurationMs = 10000;  // 10 seconds. |   17 const int kCacheDurationMs = 10000;  // 10 seconds. | 
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  295       1 |  296       1 | 
|  296     }, |  297     }, | 
|  297     { |  298     { | 
|  298       HostCache::Key("host1", ADDRESS_FAMILY_UNSPECIFIED), |  299       HostCache::Key("host1", ADDRESS_FAMILY_UNSPECIFIED), | 
|  299       HostCache::Key("host2", ADDRESS_FAMILY_IPV4), |  300       HostCache::Key("host2", ADDRESS_FAMILY_IPV4), | 
|  300       -1 |  301       -1 | 
|  301     }, |  302     }, | 
|  302   }; |  303   }; | 
|  303  |  304  | 
|  304   for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { |  305   for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { | 
|  305     SCOPED_TRACE(StringPrintf("Test[%d]", i)); |  306     SCOPED_TRACE(StringPrintf("Test[%" PRIuS "]", i)); | 
|  306  |  307  | 
|  307     const HostCache::Key& key1 = tests[i].key1; |  308     const HostCache::Key& key1 = tests[i].key1; | 
|  308     const HostCache::Key& key2 = tests[i].key2; |  309     const HostCache::Key& key2 = tests[i].key2; | 
|  309  |  310  | 
|  310     switch (tests[i].expected_comparison) { |  311     switch (tests[i].expected_comparison) { | 
|  311       case -1: |  312       case -1: | 
|  312         EXPECT_TRUE(key1 < key2); |  313         EXPECT_TRUE(key1 < key2); | 
|  313         EXPECT_FALSE(key2 < key1); |  314         EXPECT_FALSE(key2 < key1); | 
|  314         EXPECT_FALSE(key2 == key1); |  315         EXPECT_FALSE(key2 == key1); | 
|  315         break; |  316         break; | 
|  316       case 0: |  317       case 0: | 
|  317         EXPECT_FALSE(key1 < key2); |  318         EXPECT_FALSE(key1 < key2); | 
|  318         EXPECT_FALSE(key2 < key1); |  319         EXPECT_FALSE(key2 < key1); | 
|  319         EXPECT_TRUE(key2 == key1); |  320         EXPECT_TRUE(key2 == key1); | 
|  320         break; |  321         break; | 
|  321       case 1: |  322       case 1: | 
|  322         EXPECT_FALSE(key1 < key2); |  323         EXPECT_FALSE(key1 < key2); | 
|  323         EXPECT_TRUE(key2 < key1); |  324         EXPECT_TRUE(key2 < key1); | 
|  324         EXPECT_FALSE(key2 == key1); |  325         EXPECT_FALSE(key2 == key1); | 
|  325         break; |  326         break; | 
|  326       default: |  327       default: | 
|  327         FAIL() << "Invalid expectation. Can be only -1, 0, 1"; |  328         FAIL() << "Invalid expectation. Can be only -1, 0, 1"; | 
|  328     } |  329     } | 
|  329   } |  330   } | 
|  330 } |  331 } | 
|  331  |  332  | 
|  332 }  // namespace net |  333 }  // namespace net | 
| OLD | NEW |