OLD | NEW |
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 <stddef.h> |
| 8 |
7 #include <algorithm> | 9 #include <algorithm> |
8 | 10 |
| 11 #include "base/macros.h" |
9 #include "base/strings/string_split.h" | 12 #include "base/strings/string_split.h" |
10 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
11 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
13 | 16 |
14 namespace query_parser { | 17 namespace query_parser { |
15 namespace { | 18 namespace { |
16 | 19 |
17 // A sample document to compute snippets of. | 20 // A sample document to compute snippets of. |
18 // The \x bits after the first "Google" are UTF-8 of U+2122 TRADE MARK SIGN, | 21 // The \x bits after the first "Google" are UTF-8 of U+2122 TRADE MARK SIGN, |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 Snippet::ExtractMatchPositions(data[i].offsets_string, "0", &matches); | 245 Snippet::ExtractMatchPositions(data[i].offsets_string, "0", &matches); |
243 EXPECT_EQ(data[i].expected_match_count, matches.size()); | 246 EXPECT_EQ(data[i].expected_match_count, matches.size()); |
244 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) { |
245 EXPECT_EQ(data[i].expected_matches[2 * j], matches[j].first); | 248 EXPECT_EQ(data[i].expected_matches[2 * j], matches[j].first); |
246 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); |
247 } | 250 } |
248 } | 251 } |
249 } | 252 } |
250 | 253 |
251 } // namespace query_parser | 254 } // namespace query_parser |
OLD | NEW |