| 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" | |
| 10 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/strings/string_split.h" |
| 11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 13 |
| 14 namespace { | 14 namespace { |
| 15 | 15 |
| 16 // A sample document to compute snippets of. | 16 // A sample document to compute snippets of. |
| 17 // 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, |
| 18 // 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. |
| 19 const char* kSampleDocument = "Google\xe2\x84\xa2 Terms of Service " | 19 const char* kSampleDocument = "Google\xe2\x84\xa2 Terms of Service " |
| 20 "Welcome to Google! " | 20 "Welcome to Google! " |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(data); ++i) { | 243 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(data); ++i) { |
| 244 Snippet::MatchPositions matches; | 244 Snippet::MatchPositions matches; |
| 245 Snippet::ExtractMatchPositions(data[i].offsets_string, "0", &matches); | 245 Snippet::ExtractMatchPositions(data[i].offsets_string, "0", &matches); |
| 246 EXPECT_EQ(data[i].expected_match_count, matches.size()); | 246 EXPECT_EQ(data[i].expected_match_count, matches.size()); |
| 247 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) { |
| 248 EXPECT_EQ(data[i].expected_matches[2 * j], matches[j].first); | 248 EXPECT_EQ(data[i].expected_matches[2 * j], matches[j].first); |
| 249 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); |
| 250 } | 250 } |
| 251 } | 251 } |
| 252 } | 252 } |
| OLD | NEW |