OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/memory/scoped_vector.h" | 6 #include "base/memory/scoped_vector.h" |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "chrome/browser/history/query_parser.h" | 8 #include "chrome/browser/history/query_parser.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 TEST_F(QueryParserTest, ParseQueryNodesAndMatch) { | 90 TEST_F(QueryParserTest, ParseQueryNodesAndMatch) { |
91 struct TestData2 { | 91 struct TestData2 { |
92 const std::string query; | 92 const std::string query; |
93 const std::string text; | 93 const std::string text; |
94 const bool matches; | 94 const bool matches; |
95 const size_t m1_start; | 95 const size_t m1_start; |
96 const size_t m1_end; | 96 const size_t m1_end; |
97 const size_t m2_start; | 97 const size_t m2_start; |
98 const size_t m2_end; | 98 const size_t m2_end; |
99 } data[] = { | 99 } data[] = { |
| 100 { "foo", "fooey foo", true, 0, 3, 6, 9 }, |
100 { "foo foo", "foo", true, 0, 3, 0, 0 }, | 101 { "foo foo", "foo", true, 0, 3, 0, 0 }, |
101 { "foo fooey", "fooey", true, 0, 5, 0, 0 }, | 102 { "foo fooey", "fooey", true, 0, 5, 0, 0 }, |
| 103 { "fooey foo", "fooey", true, 0, 5, 0, 0 }, |
102 { "foo fooey bar", "bar fooey", true, 0, 3, 4, 9 }, | 104 { "foo fooey bar", "bar fooey", true, 0, 3, 4, 9 }, |
103 { "blah", "blah", true, 0, 4, 0, 0 }, | 105 { "blah", "blah", true, 0, 4, 0, 0 }, |
104 { "blah", "foo", false, 0, 0, 0, 0 }, | 106 { "blah", "foo", false, 0, 0, 0, 0 }, |
105 { "blah", "blahblah", true, 0, 4, 0, 0 }, | 107 { "blah", "blahblah", true, 0, 4, 0, 0 }, |
106 { "blah", "foo blah", true, 4, 8, 0, 0 }, | 108 { "blah", "foo blah", true, 4, 8, 0, 0 }, |
107 { "foo blah", "blah", false, 0, 0, 0, 0 }, | 109 { "foo blah", "blah", false, 0, 0, 0, 0 }, |
108 { "foo blah", "blahx foobar", true, 0, 4, 6, 9 }, | 110 { "foo blah", "blahx foobar", true, 0, 4, 6, 9 }, |
109 { "\"foo blah\"", "foo blah", true, 0, 8, 0, 0 }, | 111 { "\"foo blah\"", "foo blah", true, 0, 8, 0, 0 }, |
110 { "\"foo blah\"", "foox blahx", false, 0, 0, 0, 0 }, | 112 { "\"foo blah\"", "foox blahx", false, 0, 0, 0, 0 }, |
111 { "\"foo blah\"", "foo blah", true, 0, 8, 0, 0 }, | 113 { "\"foo blah\"", "foo blah", true, 0, 8, 0, 0 }, |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 QueryParser parser; | 156 QueryParser parser; |
155 parser.ParseQueryWords(UTF8ToUTF16(data[i].text), &results); | 157 parser.ParseQueryWords(UTF8ToUTF16(data[i].text), &results); |
156 ASSERT_EQ(data[i].word_count, results.size()); | 158 ASSERT_EQ(data[i].word_count, results.size()); |
157 EXPECT_EQ(data[i].w1, UTF16ToUTF8(results[0])); | 159 EXPECT_EQ(data[i].w1, UTF16ToUTF8(results[0])); |
158 if (results.size() == 2) | 160 if (results.size() == 2) |
159 EXPECT_EQ(data[i].w2, UTF16ToUTF8(results[1])); | 161 EXPECT_EQ(data[i].w2, UTF16ToUTF8(results[1])); |
160 if (results.size() == 3) | 162 if (results.size() == 3) |
161 EXPECT_EQ(data[i].w3, UTF16ToUTF8(results[2])); | 163 EXPECT_EQ(data[i].w3, UTF16ToUTF8(results[2])); |
162 } | 164 } |
163 } | 165 } |
OLD | NEW |