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

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

Issue 336793004: Revert 277111 "Roll ICU to icu52" (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 6 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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 base::UTF16ToUTF8(BuildSnippet(kSampleDocument, "relationship"))); 164 base::UTF16ToUTF8(BuildSnippet(kSampleDocument, "relationship")));
165 } 165 }
166 166
167 TEST(Snippets, ThaiUTF8) { 167 TEST(Snippets, ThaiUTF8) {
168 // There are 3 instances of '\u0E43\u0E2B\u0E49' 168 // There are 3 instances of '\u0E43\u0E2B\u0E49'
169 // (\xE0\xB9\x83\xE0\xB8\xAB\xE0\xB9\x89) in kThaiSample. 169 // (\xE0\xB9\x83\xE0\xB8\xAB\xE0\xB9\x89) in kThaiSample.
170 // The 1st is more than |kSniipetContext| graphemes away from the 170 // The 1st is more than |kSniipetContext| graphemes away from the
171 // 2nd while the 2nd and 3rd are within that window. However, with 171 // 2nd while the 2nd and 3rd are within that window. However, with
172 // the 2nd match added, the snippet goes over the size limit so that 172 // the 2nd match added, the snippet goes over the size limit so that
173 // the snippet ends right before the 3rd match. 173 // the snippet ends right before the 3rd match.
174 ASSERT_EQ(" ... " 174 ASSERT_EQ(" ... "
175 "\xE0\xB8\x82\xE0\xB9\x89\xE0\xB8\xAD\xE0\xB8\xA1\xE0\xB8\xB9" 175 "\xE0\xB8\xA3\xE0\xB8\xA7\xE0\xB8\x9A\xE0\xB8\xA3\xE0\xB8\xA7"
176 "\xE0\xB8\xA5\xE0\xB8\xAA\xE0\xB9\x88\xE0\xB8\xA7\xE0\xB8\x99" 176 "\xE0\xB8\xA1 \xE0\xB8\x82\xE0\xB9\x89\xE0\xB8\xAD\xE0\xB8"
177 "\xE0\xB8\x9A\xE0\xB8\xB8\xE0\xB8\x84\xE0\xB8\x84\xE0\xB8\xA5 " 177 "\xA1\xE0\xB8\xB9\xE0\xB8\xA5\xE0\xB8\xAA\xE0\xB9\x88\xE0\xB8"
178 "\xE0\xB9\x80\xE0\xB8\xA1\xE0\xB8\xB7\xE0\xB9\x88\xE0\xB8\xAD" 178 "\xA7\xE0\xB8\x99\xE0\xB8\x9A\xE0\xB8\xB8\xE0\xB8\x84\xE0\xB8"
179 "\xE0\xB8\x84\xE0\xB8\xB8\xE0\xB8\x93\xE0\xB8\xA5\xE0\xB8\x87" 179 "\x84\xE0\xB8\xA5 \xE0\xB9\x80\xE0\xB8\xA1\xE0\xB8\xB7\xE0"
180 "\xE0\xB8\x97\xE0\xB8\xB0\xE0\xB9\x80\xE0\xB8\x9A\xE0\xB8\xB5" 180 "\xB9\x88\xE0\xB8\xAD\xE0\xB8\x84\xE0\xB8\xB8\xE0\xB8\x93\xE0"
181 "\xE0\xB8\xA2\xE0\xB8\x99\xE0\xB9\x80\xE0\xB8\x9E\xE0\xB8\xB7" 181 "\xB8\xA5\xE0\xB8\x87\xE0\xB8\x97\xE0\xB8\xB0\xE0\xB9\x80\xE0"
182 "\xE0\xB9\x88\xE0\xB8\xAD\xE0\xB9\x83\xE0\xB8\x8A\xE0\xB9\x89" 182 "\xB8\x9A\x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215 "\xB8\xB0\xE0\xB8\xAA\xE0\xB8\x9A\xE0\xB8\x81\xE0\xB8\xB2\xE0"
216 "\xE0\xB8\x82\xE0\xB8\xB6\xE0\xB9\x89\xE0\xB8\x99 \xE0\xB8\xA3" 216 "\xB8\xA3\xE0\xB8\x93\xE0\xB9\x8C\xE0\xB8\x97\xE0\xB8\xB5\xE0"
217 "\xE0\xB8\xA7\xE0\xB8\xA1\xE0\xB8\x97\xE0\xB8\xB1\xE0\xB9\x89" 217 "\xB9\x88\xE0\xB8\x94\xE0\xB8\xB5\xE0\xB8\x82\xE0\xB8\xB6\xE0"
218 "\xE0\xB8\x87\xE0\xB8\x9B\xE0\xB8\xA3\xE0\xB8\xB1\xE0\xB8\x9A" 218 "\xB9\x89\xE0\xB8\x99 \xE0\xB8\xA3\xE0\xB8\xA7\xE0\xB8\xA1"
219 "\xE0\xB9\x81\xE0\xB8\x95\xE0\xB9\x88\xE0\xB8\x87\xE0\xB9\x80" 219 "\xE0\xB8\x97\xE0\xB8\xB1\xE0\xB9\x89\xE0\xB8\x87\xE0\xB8\x9B"
220 "\xE0\xB8\x99\xE0\xB8\xB7\xE0\xB9\x89\xE0\xB8\xAD\xE0\xB8\xAB" 220 "\xE0\xB8\xA3\xE0\xB8\xB1\xE0\xB8\x9A\xE0\xB9\x81\xE0\xB8\x95"
221 "\xE0\xB8\xB2", 221 "\xE0\xB9\x88\xE0\xB8\x87\xE0\xB9\x80\xE0\xB8\x99\xE0\xB8\xB7"
222 "\xE0\xB9\x89\xE0\xB8\xAD\xE0\xB8\xAB\xE0\xB8\xB2",
222 base::UTF16ToUTF8(BuildSnippet(kThaiSample, 223 base::UTF16ToUTF8(BuildSnippet(kThaiSample,
223 "\xE0\xB9\x83\xE0\xB8\xAB\xE0\xB9\x89"))); 224 "\xE0\xB9\x83\xE0\xB8\xAB\xE0\xB9\x89")));
224 } 225 }
225 226
226 TEST(Snippets, ExtractMatchPositions) { 227 TEST(Snippets, ExtractMatchPositions) {
227 struct TestData { 228 struct TestData {
228 const std::string offsets_string; 229 const std::string offsets_string;
229 const size_t expected_match_count; 230 const size_t expected_match_count;
230 const size_t expected_matches[10]; 231 const size_t expected_matches[10];
231 } data[] = { 232 } data[] = {
(...skipping 13 matching lines...) Expand all
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 | « trunk/src/components/query_parser/snippet.h ('k') | trunk/src/tools/gn/secondary/third_party/icu/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698