summaryrefslogtreecommitdiffstats
path: root/chrome/browser/history/query_parser_unittest.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/history/query_parser_unittest.cc')
-rw-r--r--chrome/browser/history/query_parser_unittest.cc42
1 files changed, 30 insertions, 12 deletions
diff --git a/chrome/browser/history/query_parser_unittest.cc b/chrome/browser/history/query_parser_unittest.cc
index d026df1..1e0b36d 100644
--- a/chrome/browser/history/query_parser_unittest.cc
+++ b/chrome/browser/history/query_parser_unittest.cc
@@ -88,25 +88,43 @@ TEST_F(QueryParserTest, ParseQueryNodesAndMatch) {
const std::wstring query;
const std::wstring text;
const bool matches;
+ const int m1_start;
+ const int m1_end;
+ const int m2_start;
+ const int m2_end;
} data[] = {
- { L"blah", L"blah", true },
- { L"blah", L"foo", false },
- { L"blah", L"blahblah", true },
- { L"blah", L"foo blah", true },
- { L"foo blah", L"blah", false },
- { L"foo blah", L"blahx foobar", true },
- { L"\"foo blah\"", L"foo blah", true },
- { L"\"foo blah\"", L"foox blahx", false },
- { L"\"foo blah\"", L"foo blah", true },
- { L"\"foo blah\"", L"\"foo blah\"", true },
- { L"foo blah", L"\"foo bar blah\"", true },
+ { L"blah", L"blah", true, 0, 4, 0, 0 },
+ { L"blah", L"foo", false, 0, 0, 0, 0 },
+ { L"blah", L"blahblah", true, 0, 4, 0, 0 },
+ { L"blah", L"foo blah", true, 4, 8, 0, 0 },
+ { L"foo blah", L"blah", false, 0, 0, 0, 0 },
+ { L"foo blah", L"blahx foobar", true, 6, 9, 0, 4 },
+ { L"\"foo blah\"", L"foo blah", true, 0, 8, 0, 0 },
+ { L"\"foo blah\"", L"foox blahx", false, 0, 0, 0, 0 },
+ { L"\"foo blah\"", L"foo blah", true, 0, 8, 0, 0 },
+ { L"\"foo blah\"", L"\"foo blah\"", true, 1, 9, 0, 0 },
+ { L"foo blah", L"\"foo bar blah\"", true, 1, 4, 9, 13 },
};
for (int i = 0; i < arraysize(data); ++i) {
std::vector<std::wstring> results;
QueryParser parser;
ScopedVector<QueryNode> query_nodes;
parser.ParseQuery(data[i].query, &query_nodes.get());
+ Snippet::MatchPositions match_positions;
ASSERT_EQ(data[i].matches,
- parser.DoesQueryMatch(data[i].text, query_nodes.get()));
+ parser.DoesQueryMatch(data[i].text, query_nodes.get(),
+ &match_positions));
+ size_t offset = 0;
+ if (data[i].m1_start != 0 || data[i].m1_end != 0) {
+ ASSERT_TRUE(match_positions.size() >= 1);
+ EXPECT_EQ(data[i].m1_start, match_positions[0].first);
+ EXPECT_EQ(data[i].m1_end, match_positions[0].second);
+ offset++;
+ }
+ if (data[i].m2_start != 0 || data[i].m2_end != 0) {
+ ASSERT_TRUE(match_positions.size() == 1 + offset);
+ EXPECT_EQ(data[i].m2_start, match_positions[offset].first);
+ EXPECT_EQ(data[i].m2_end, match_positions[offset].second);
+ }
}
}