OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/query_parser.h" | 5 #include "chrome/browser/history/query_parser.h" |
6 #include "base/logging.h" | 6 #include "base/logging.h" |
7 #include "chrome/common/scoped_vector.h" | 7 #include "chrome/common/scoped_vector.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 | 9 |
10 namespace { | 10 namespace { |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 EXPECT_EQ(data[i].expected_word_count, | 81 EXPECT_EQ(data[i].expected_word_count, |
82 query_parser_.ParseQuery(data[i].input, &query_string)); | 82 query_parser_.ParseQuery(data[i].input, &query_string)); |
83 } | 83 } |
84 } | 84 } |
85 | 85 |
86 TEST_F(QueryParserTest, ParseQueryNodesAndMatch) { | 86 TEST_F(QueryParserTest, ParseQueryNodesAndMatch) { |
87 struct TestData2 { | 87 struct TestData2 { |
88 const std::wstring query; | 88 const std::wstring query; |
89 const std::wstring text; | 89 const std::wstring text; |
90 const bool matches; | 90 const bool matches; |
91 const int m1_start; | 91 const size_t m1_start; |
92 const int m1_end; | 92 const size_t m1_end; |
93 const int m2_start; | 93 const size_t m2_start; |
94 const int m2_end; | 94 const size_t m2_end; |
95 } data[] = { | 95 } data[] = { |
96 { L"foo foo", L"foo", true, 0, 3, 0, 0 }, | 96 { L"foo foo", L"foo", true, 0, 3, 0, 0 }, |
97 { L"foo fooey", L"fooey", true, 0, 5, 0, 0 }, | 97 { L"foo fooey", L"fooey", true, 0, 5, 0, 0 }, |
98 { L"foo fooey bar", L"bar fooey", true, 0, 3, 4, 9 }, | 98 { L"foo fooey bar", L"bar fooey", true, 0, 3, 4, 9 }, |
99 { L"blah", L"blah", true, 0, 4, 0, 0 }, | 99 { L"blah", L"blah", true, 0, 4, 0, 0 }, |
100 { L"blah", L"foo", false, 0, 0, 0, 0 }, | 100 { L"blah", L"foo", false, 0, 0, 0, 0 }, |
101 { L"blah", L"blahblah", true, 0, 4, 0, 0 }, | 101 { L"blah", L"blahblah", true, 0, 4, 0, 0 }, |
102 { L"blah", L"foo blah", true, 4, 8, 0, 0 }, | 102 { L"blah", L"foo blah", true, 4, 8, 0, 0 }, |
103 { L"foo blah", L"blah", false, 0, 0, 0, 0 }, | 103 { L"foo blah", L"blah", false, 0, 0, 0, 0 }, |
104 { L"foo blah", L"blahx foobar", true, 0, 4, 6, 9 }, | 104 { L"foo blah", L"blahx foobar", true, 0, 4, 6, 9 }, |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 QueryParser parser; | 150 QueryParser parser; |
151 parser.ExtractQueryWords(data[i].text, &results); | 151 parser.ExtractQueryWords(data[i].text, &results); |
152 ASSERT_EQ(data[i].word_count, results.size()); | 152 ASSERT_EQ(data[i].word_count, results.size()); |
153 EXPECT_EQ(data[i].w1, results[0]); | 153 EXPECT_EQ(data[i].w1, results[0]); |
154 if (results.size() == 2) | 154 if (results.size() == 2) |
155 EXPECT_EQ(data[i].w2, results[1]); | 155 EXPECT_EQ(data[i].w2, results[1]); |
156 if (results.size() == 3) | 156 if (results.size() == 3) |
157 EXPECT_EQ(data[i].w3, results[2]); | 157 EXPECT_EQ(data[i].w3, results[2]); |
158 } | 158 } |
159 } | 159 } |
OLD | NEW |