OLD | NEW |
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 "chrome/browser/history/snippet.h" | 5 #include "chrome/browser/history/snippet.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
| 9 #include "base/string_split.h" |
9 #include "base/string_util.h" | 10 #include "base/string_util.h" |
10 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
12 | 13 |
13 namespace { | 14 namespace { |
14 | 15 |
15 // A sample document to compute snippets of. | 16 // A sample document to compute snippets of. |
16 // The \x bits after the first "Google" are UTF-8 of U+2122 TRADE MARK SIGN, | 17 // The \x bits after the first "Google" are UTF-8 of U+2122 TRADE MARK SIGN, |
17 // and are useful for verifying we don't screw up in UTF-8/UTF-16 conversion. | 18 // and are useful for verifying we don't screw up in UTF-8/UTF-16 conversion. |
18 const char* kSampleDocument = "Google\xe2\x84\xa2 Terms of Service " | 19 const char* kSampleDocument = "Google\xe2\x84\xa2 Terms of Service " |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(data); ++i) { | 243 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(data); ++i) { |
243 Snippet::MatchPositions matches; | 244 Snippet::MatchPositions matches; |
244 Snippet::ExtractMatchPositions(data[i].offsets_string, "0", &matches); | 245 Snippet::ExtractMatchPositions(data[i].offsets_string, "0", &matches); |
245 EXPECT_EQ(data[i].expected_match_count, matches.size()); | 246 EXPECT_EQ(data[i].expected_match_count, matches.size()); |
246 for (size_t j = 0; j < data[i].expected_match_count; ++j) { | 247 for (size_t j = 0; j < data[i].expected_match_count; ++j) { |
247 EXPECT_EQ(data[i].expected_matches[2 * j], matches[j].first); | 248 EXPECT_EQ(data[i].expected_matches[2 * j], matches[j].first); |
248 EXPECT_EQ(data[i].expected_matches[2 * j + 1], matches[j].second); | 249 EXPECT_EQ(data[i].expected_matches[2 * j + 1], matches[j].second); |
249 } | 250 } |
250 } | 251 } |
251 } | 252 } |
OLD | NEW |