Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(241)

Side by Side Diff: net/ftp/ftp_auth_cache_unittest.cc

Issue 3056029: Move the number conversions from string_util to a new file.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « jingle/notifier/listener/xml_element_util.cc ('k') | net/http/http_cache.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/ftp/ftp_auth_cache.h" 5 #include "net/ftp/ftp_auth_cache.h"
6 6
7 #include "base/string_number_conversions.h"
7 #include "base/string_util.h" 8 #include "base/string_util.h"
8 #include "googleurl/src/gurl.h" 9 #include "googleurl/src/gurl.h"
9 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
10 11
11 using net::FtpAuthCache; 12 using net::FtpAuthCache;
12 13
13 namespace { 14 namespace {
14 15
15 const string16 kBogus(ASCIIToUTF16("bogus")); 16 const string16 kBogus(ASCIIToUTF16("bogus"));
16 const string16 kOthername(ASCIIToUTF16("othername")); 17 const string16 kOthername(ASCIIToUTF16("othername"));
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 EXPECT_TRUE(cache.Lookup(GURL("ftp://host"))); 126 EXPECT_TRUE(cache.Lookup(GURL("ftp://host")));
126 127
127 // Auth data matches, should remove. 128 // Auth data matches, should remove.
128 cache.Remove(GURL("ftp://host"), kUsername, kPassword); 129 cache.Remove(GURL("ftp://host"), kUsername, kPassword);
129 EXPECT_TRUE(cache.Lookup(GURL("ftp://host")) == NULL); 130 EXPECT_TRUE(cache.Lookup(GURL("ftp://host")) == NULL);
130 } 131 }
131 132
132 TEST(FtpAuthCacheTest, EvictOldEntries) { 133 TEST(FtpAuthCacheTest, EvictOldEntries) {
133 FtpAuthCache cache; 134 FtpAuthCache cache;
134 135
135 for (size_t i = 0; i < FtpAuthCache::kMaxEntries; i++) 136 for (size_t i = 0; i < FtpAuthCache::kMaxEntries; i++) {
136 cache.Add(GURL("ftp://host" + IntToString(i)), kUsername, kPassword); 137 cache.Add(GURL("ftp://host" + base::IntToString(i)),
138 kUsername, kPassword);
139 }
137 140
138 // No entries should be evicted before reaching the limit. 141 // No entries should be evicted before reaching the limit.
139 for (size_t i = 0; i < FtpAuthCache::kMaxEntries; i++) { 142 for (size_t i = 0; i < FtpAuthCache::kMaxEntries; i++) {
140 EXPECT_TRUE(cache.Lookup(GURL("ftp://host" + IntToString(i)))); 143 EXPECT_TRUE(cache.Lookup(GURL("ftp://host" + base::IntToString(i))));
141 } 144 }
142 145
143 // Adding one entry should cause eviction of the first entry. 146 // Adding one entry should cause eviction of the first entry.
144 cache.Add(GURL("ftp://last_host"), kUsername, kPassword); 147 cache.Add(GURL("ftp://last_host"), kUsername, kPassword);
145 EXPECT_TRUE(cache.Lookup(GURL("ftp://host0")) == NULL); 148 EXPECT_TRUE(cache.Lookup(GURL("ftp://host0")) == NULL);
146 149
147 // Remaining entries should not get evicted. 150 // Remaining entries should not get evicted.
148 for (size_t i = 1; i < FtpAuthCache::kMaxEntries; i++) { 151 for (size_t i = 1; i < FtpAuthCache::kMaxEntries; i++) {
149 EXPECT_TRUE(cache.Lookup(GURL("ftp://host" + IntToString(i)))); 152 EXPECT_TRUE(cache.Lookup(GURL("ftp://host" + base::IntToString(i))));
150 } 153 }
151 EXPECT_TRUE(cache.Lookup(GURL("ftp://last_host"))); 154 EXPECT_TRUE(cache.Lookup(GURL("ftp://last_host")));
152 } 155 }
OLDNEW
« no previous file with comments | « jingle/notifier/listener/xml_element_util.cc ('k') | net/http/http_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698