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

Side by Side Diff: components/query_parser/snippet_unittest.cc

Issue 448853002: Move StringToLowerASCII to base namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/query_parser/snippet.h" 5 #include "components/query_parser/snippet.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/strings/string_split.h" 9 #include "base/strings/string_split.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 // sqlite's FTS matching. BuildSnippet returns the snippet for matching 89 // sqlite's FTS matching. BuildSnippet returns the snippet for matching
90 // |query| against |document|. Matches are surrounded by "**". 90 // |query| against |document|. Matches are surrounded by "**".
91 base::string16 BuildSnippet(const std::string& document, 91 base::string16 BuildSnippet(const std::string& document,
92 const std::string& query) { 92 const std::string& query) {
93 // This function assumes that |document| does not contain 93 // This function assumes that |document| does not contain
94 // any character for which lowercasing changes its length. Further, 94 // any character for which lowercasing changes its length. Further,
95 // it's assumed that lowercasing only the ASCII-portion works for 95 // it's assumed that lowercasing only the ASCII-portion works for
96 // |document|. We need to add more test cases and change this function 96 // |document|. We need to add more test cases and change this function
97 // to be more generic depending on how we deal with 'folding for match' 97 // to be more generic depending on how we deal with 'folding for match'
98 // in history. 98 // in history.
99 const std::string document_folded = StringToLowerASCII(std::string(document)); 99 const std::string document_folded =
100 base::StringToLowerASCII(std::string(document));
100 101
101 std::vector<std::string> query_words; 102 std::vector<std::string> query_words;
102 base::SplitString(query, ' ', &query_words); 103 base::SplitString(query, ' ', &query_words);
103 104
104 // Manually construct match_positions of the document. 105 // Manually construct match_positions of the document.
105 Snippet::MatchPositions match_positions; 106 Snippet::MatchPositions match_positions;
106 match_positions.clear(); 107 match_positions.clear();
107 for (std::vector<std::string>::iterator qw = query_words.begin(); 108 for (std::vector<std::string>::iterator qw = query_words.begin();
108 qw != query_words.end(); ++qw) { 109 qw != query_words.end(); ++qw) {
109 // Insert all instances of this word into match_pairs. 110 // Insert all instances of this word into match_pairs.
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 Snippet::ExtractMatchPositions(data[i].offsets_string, "0", &matches); 246 Snippet::ExtractMatchPositions(data[i].offsets_string, "0", &matches);
246 EXPECT_EQ(data[i].expected_match_count, matches.size()); 247 EXPECT_EQ(data[i].expected_match_count, matches.size());
247 for (size_t j = 0; j < data[i].expected_match_count; ++j) { 248 for (size_t j = 0; j < data[i].expected_match_count; ++j) {
248 EXPECT_EQ(data[i].expected_matches[2 * j], matches[j].first); 249 EXPECT_EQ(data[i].expected_matches[2 * j], matches[j].first);
249 EXPECT_EQ(data[i].expected_matches[2 * j + 1], matches[j].second); 250 EXPECT_EQ(data[i].expected_matches[2 * j + 1], matches[j].second);
250 } 251 }
251 } 252 }
252 } 253 }
253 254
254 } // namespace query_parser 255 } // namespace query_parser
OLDNEW
« no previous file with comments | « components/policy/core/common/preg_parser_win.cc ('k') | components/signin/core/browser/signin_internals_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698