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

Unified Diff: net/cookies/cookie_monster_unittest.cc

Issue 1215933004: New new versions of Starts/EndsWith and SplitString in net (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@starts_with
Patch Set: Created 5 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/cert/x509_certificate_unittest.cc ('k') | net/dns/dns_config_service_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/cookies/cookie_monster_unittest.cc
diff --git a/net/cookies/cookie_monster_unittest.cc b/net/cookies/cookie_monster_unittest.cc
index 5452f191992357caabc0a29361078011fc8bf2b9..6f3c0b616fb5703cd2e937dde5a3ce0cbd1382fe 100644
--- a/net/cookies/cookie_monster_unittest.cc
+++ b/net/cookies/cookie_monster_unittest.cc
@@ -436,20 +436,18 @@ class CookieMonsterTest : public CookieStoreTest<CookieMonsterTestTraits> {
std::vector<int> id_list[3]; // Indexed by CookiePriority.
// Parse |coded_priority_str| and add cookies.
- std::vector<std::string> priority_tok_list;
- base::SplitString(coded_priority_str, ' ', &priority_tok_list);
- for (std::vector<std::string>::iterator it = priority_tok_list.begin();
- it != priority_tok_list.end(); ++it) {
- size_t len = it->length();
- DCHECK_NE(len, 0U);
+ for (const std::string& token :
+ base::SplitString(coded_priority_str, " ", base::TRIM_WHITESPACE,
+ base::SPLIT_WANT_ALL)) {
+ DCHECK(!token.empty());
// Take last character as priority.
- CookiePriority priority = CharToPriority((*it)[len - 1]);
+ CookiePriority priority = CharToPriority(token[token.length() - 1]);
std::string priority_str = CookiePriorityToString(priority);
// The rest of the string (possibly empty) specifies repetition.
int rep = 1;
- if (!it->empty()) {
+ if (!token.empty()) {
bool result = base::StringToInt(
- base::StringPiece(it->begin(), it->end() - 1), &rep);
+ base::StringPiece(token.begin(), token.end() - 1), &rep);
DCHECK(result);
}
for (; rep > 0; --rep, ++next_cookie_id) {
@@ -466,14 +464,12 @@ class CookieMonsterTest : public CookieStoreTest<CookieMonsterTestTraits> {
// Parse the list of cookies
std::string cookie_str = this->GetCookies(cm, url_google_);
- std::vector<std::string> cookie_tok_list;
- base::SplitString(cookie_str, ';', &cookie_tok_list);
- for (std::vector<std::string>::iterator it = cookie_tok_list.begin();
- it != cookie_tok_list.end(); ++it) {
+ for (const std::string& token : base::SplitString(
+ cookie_str, ";", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) {
// Assuming *it is "a#=b", so extract and parse "#" portion.
int id = -1;
bool result = base::StringToInt(
- base::StringPiece(it->begin() + 1, it->end() - 2), &id);
+ base::StringPiece(token.begin() + 1, token.end() - 2), &id);
DCHECK(result);
DCHECK_GE(id, 0);
DCHECK_LT(id, num_cookies);
« no previous file with comments | « net/cert/x509_certificate_unittest.cc ('k') | net/dns/dns_config_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698