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

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

Issue 10828168: bookmarks: Fix mistakes found by cppcheck. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 | « no previous file | chrome/browser/bookmarks/bookmark_model_unittest.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 void ExpectMatches(const std::string& query, 44 void ExpectMatches(const std::string& query,
45 const char** expected_titles, 45 const char** expected_titles,
46 size_t expected_count) { 46 size_t expected_count) {
47 std::vector<std::string> title_vector; 47 std::vector<std::string> title_vector;
48 for (size_t i = 0; i < expected_count; ++i) 48 for (size_t i = 0; i < expected_count; ++i)
49 title_vector.push_back(expected_titles[i]); 49 title_vector.push_back(expected_titles[i]);
50 ExpectMatches(query, title_vector); 50 ExpectMatches(query, title_vector);
51 } 51 }
52 52
53 void ExpectMatches(const std::string& query, 53 void ExpectMatches(const std::string& query,
54 const std::vector<std::string> expected_titles) { 54 const std::vector<std::string>& expected_titles) {
55 std::vector<bookmark_utils::TitleMatch> matches; 55 std::vector<bookmark_utils::TitleMatch> matches;
56 model_->GetBookmarksWithTitlesMatching(ASCIIToUTF16(query), 1000, &matches); 56 model_->GetBookmarksWithTitlesMatching(ASCIIToUTF16(query), 1000, &matches);
57 ASSERT_EQ(expected_titles.size(), matches.size()); 57 ASSERT_EQ(expected_titles.size(), matches.size());
58 for (size_t i = 0; i < expected_titles.size(); ++i) { 58 for (size_t i = 0; i < expected_titles.size(); ++i) {
59 bool found = false; 59 bool found = false;
60 for (size_t j = 0; j < matches.size(); ++j) { 60 for (size_t j = 0; j < matches.size(); ++j) {
61 if (ASCIIToUTF16(expected_titles[i]) == matches[j].node->GetTitle()) { 61 if (ASCIIToUTF16(expected_titles[i]) == matches[j].node->GetTitle()) {
62 matches.erase(matches.begin() + j); 62 matches.erase(matches.begin() + j);
63 found = true; 63 found = true;
64 break; 64 break;
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 EXPECT_EQ(data[1].url, matches[3].node->url()); 296 EXPECT_EQ(data[1].url, matches[3].node->url());
297 297
298 matches.clear(); 298 matches.clear();
299 // Select top two matches. 299 // Select top two matches.
300 model->GetBookmarksWithTitlesMatching(ASCIIToUTF16("google"), 2, &matches); 300 model->GetBookmarksWithTitlesMatching(ASCIIToUTF16("google"), 2, &matches);
301 301
302 EXPECT_EQ(2, static_cast<int>(matches.size())); 302 EXPECT_EQ(2, static_cast<int>(matches.size()));
303 EXPECT_EQ(data[0].url, matches[0].node->url()); 303 EXPECT_EQ(data[0].url, matches[0].node->url());
304 EXPECT_EQ(data[3].url, matches[1].node->url()); 304 EXPECT_EQ(data[3].url, matches[1].node->url());
305 } 305 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/bookmarks/bookmark_model_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698