| 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 <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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 { "0 0 1 4 0 0 2 1", 1, { 1, 5 } }, | 234 { "0 0 1 4 0 0 2 1", 1, { 1, 5 } }, |
| 235 { "0 0 4 1 0 0 2 1", 2, { 2, 3, 4, 5 } }, | 235 { "0 0 4 1 0 0 2 1", 2, { 2, 3, 4, 5 } }, |
| 236 { "0 0 0 1", 1, { 0, 1 } }, | 236 { "0 0 0 1", 1, { 0, 1 } }, |
| 237 { "0 0 0 1 0 0 0 2", 1, { 0, 2 } }, | 237 { "0 0 0 1 0 0 0 2", 1, { 0, 2 } }, |
| 238 { "0 0 1 1 0 0 1 2", 1, { 1, 3 } }, | 238 { "0 0 1 1 0 0 1 2", 1, { 1, 3 } }, |
| 239 { "0 0 1 2 0 0 4 3 0 0 3 1", 1, { 1, 7 } }, | 239 { "0 0 1 2 0 0 4 3 0 0 3 1", 1, { 1, 7 } }, |
| 240 { "0 0 1 4 0 0 2 5", 1, { 1, 7 } }, | 240 { "0 0 1 4 0 0 2 5", 1, { 1, 7 } }, |
| 241 { "0 0 1 2 0 0 1 1", 1, { 1, 3 } }, | 241 { "0 0 1 2 0 0 1 1", 1, { 1, 3 } }, |
| 242 { "0 0 1 1 0 0 5 2 0 0 10 1 0 0 3 10", 2, { 1, 2, 3, 13 } }, | 242 { "0 0 1 1 0 0 5 2 0 0 10 1 0 0 3 10", 2, { 1, 2, 3, 13 } }, |
| 243 }; | 243 }; |
| 244 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(data); ++i) { | 244 for (size_t i = 0; i < arraysize(data); ++i) { |
| 245 Snippet::MatchPositions matches; | 245 Snippet::MatchPositions matches; |
| 246 Snippet::ExtractMatchPositions(data[i].offsets_string, "0", &matches); | 246 Snippet::ExtractMatchPositions(data[i].offsets_string, "0", &matches); |
| 247 EXPECT_EQ(data[i].expected_match_count, matches.size()); | 247 EXPECT_EQ(data[i].expected_match_count, matches.size()); |
| 248 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) { |
| 249 EXPECT_EQ(data[i].expected_matches[2 * j], matches[j].first); | 249 EXPECT_EQ(data[i].expected_matches[2 * j], matches[j].first); |
| 250 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); |
| 251 } | 251 } |
| 252 } | 252 } |
| 253 } | 253 } |
| 254 | 254 |
| 255 } // namespace query_parser | 255 } // namespace query_parser |
| OLD | NEW |