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

Side by Side Diff: chrome/browser/bookmarks/bookmark_index_unittest.cc

Issue 3750001: base: Move SplitString functions into the base namespace and update the callers. (Closed) Base URL: git://git.chromium.org/chromium.git
Patch Set: brett review, reverted changes in o3d due to it's using an old base revision Created 10 years, 2 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
« no previous file with comments | « chrome/app/breakpad_win.cc ('k') | chrome/browser/browser_main.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 <string> 5 #include <string>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/string_number_conversions.h" 9 #include "base/string_number_conversions.h"
10 #include "base/string_split.h" 10 #include "base/string_split.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 break; 61 break;
62 } 62 }
63 } 63 }
64 ASSERT_TRUE(found); 64 ASSERT_TRUE(found);
65 } 65 }
66 } 66 }
67 67
68 void ExtractMatchPositions(const std::string& string, 68 void ExtractMatchPositions(const std::string& string,
69 Snippet::MatchPositions* matches) { 69 Snippet::MatchPositions* matches) {
70 std::vector<std::string> match_strings; 70 std::vector<std::string> match_strings;
71 SplitString(string, ':', &match_strings); 71 base::SplitString(string, ':', &match_strings);
72 for (size_t i = 0; i < match_strings.size(); ++i) { 72 for (size_t i = 0; i < match_strings.size(); ++i) {
73 std::vector<std::string> chunks; 73 std::vector<std::string> chunks;
74 SplitString(match_strings[i], ',', &chunks); 74 base::SplitString(match_strings[i], ',', &chunks);
75 ASSERT_EQ(2U, chunks.size()); 75 ASSERT_EQ(2U, chunks.size());
76 matches->push_back(Snippet::MatchPosition()); 76 matches->push_back(Snippet::MatchPosition());
77 int chunks0, chunks1; 77 int chunks0, chunks1;
78 base::StringToInt(chunks[0], &chunks0); 78 base::StringToInt(chunks[0], &chunks0);
79 base::StringToInt(chunks[1], &chunks1); 79 base::StringToInt(chunks[1], &chunks1);
80 matches->back().first = chunks0; 80 matches->back().first = chunks0;
81 matches->back().second = chunks1; 81 matches->back().second = chunks1;
82 } 82 }
83 } 83 }
84 84
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 "ab cdef ghij"}, 128 "ab cdef ghij"},
129 129
130 // Title with term multiple times. 130 // Title with term multiple times.
131 { "ab ab", "ab", "ab ab"}, 131 { "ab ab", "ab", "ab ab"},
132 132
133 // Make sure quotes don't do a prefix match. 133 // Make sure quotes don't do a prefix match.
134 { "think", "\"thi\"", ""}, 134 { "think", "\"thi\"", ""},
135 }; 135 };
136 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(data); ++i) { 136 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(data); ++i) {
137 std::vector<std::string> titles; 137 std::vector<std::string> titles;
138 SplitString(data[i].input, ';', &titles); 138 base::SplitString(data[i].input, ';', &titles);
139 AddBookmarksWithTitles(titles); 139 AddBookmarksWithTitles(titles);
140 140
141 std::vector<std::string> expected; 141 std::vector<std::string> expected;
142 if (!data[i].expected.empty()) 142 if (!data[i].expected.empty())
143 SplitString(data[i].expected, ';', &expected); 143 base::SplitString(data[i].expected, ';', &expected);
144 144
145 ExpectMatches(data[i].query, expected); 145 ExpectMatches(data[i].query, expected);
146 146
147 model_.reset(new BookmarkModel(NULL)); 147 model_.reset(new BookmarkModel(NULL));
148 } 148 }
149 } 149 }
150 150
151 // Makes sure match positions are updated appropriately. 151 // Makes sure match positions are updated appropriately.
152 TEST_F(BookmarkIndexTest, MatchPositions) { 152 TEST_F(BookmarkIndexTest, MatchPositions) {
153 struct TestData { 153 struct TestData {
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 294
295 matches.clear(); 295 matches.clear();
296 // Select top two matches. 296 // Select top two matches.
297 model->GetBookmarksWithTitlesMatching(ASCIIToUTF16("google"), 2, &matches); 297 model->GetBookmarksWithTitlesMatching(ASCIIToUTF16("google"), 2, &matches);
298 298
299 EXPECT_EQ(2, static_cast<int>(matches.size())); 299 EXPECT_EQ(2, static_cast<int>(matches.size()));
300 EXPECT_EQ(data[0].url, matches[0].node->GetURL()); 300 EXPECT_EQ(data[0].url, matches[0].node->GetURL());
301 EXPECT_EQ(data[3].url, matches[1].node->GetURL()); 301 EXPECT_EQ(data[3].url, matches[1].node->GetURL());
302 } 302 }
303 303
OLDNEW
« no previous file with comments | « chrome/app/breakpad_win.cc ('k') | chrome/browser/browser_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698