Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: chrome/browser/history/query_parser_unittest.cc

Issue 13296: Adds QueryParser::ExtractQueryWords. For consistent this should... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 12 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/history/query_parser.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 EXPECT_EQ(data[i].m1_end, match_positions[0].second); 124 EXPECT_EQ(data[i].m1_end, match_positions[0].second);
125 offset++; 125 offset++;
126 } 126 }
127 if (data[i].m2_start != 0 || data[i].m2_end != 0) { 127 if (data[i].m2_start != 0 || data[i].m2_end != 0) {
128 ASSERT_TRUE(match_positions.size() == 1 + offset); 128 ASSERT_TRUE(match_positions.size() == 1 + offset);
129 EXPECT_EQ(data[i].m2_start, match_positions[offset].first); 129 EXPECT_EQ(data[i].m2_start, match_positions[offset].first);
130 EXPECT_EQ(data[i].m2_end, match_positions[offset].second); 130 EXPECT_EQ(data[i].m2_end, match_positions[offset].second);
131 } 131 }
132 } 132 }
133 } 133 }
134
135 TEST_F(QueryParserTest, ExtractQueryWords) {
136 struct TestData2 {
137 const std::wstring text;
138 const std::wstring w1;
139 const std::wstring w2;
140 const std::wstring w3;
141 const size_t word_count;
142 } data[] = {
143 { L"foo", L"foo", L"", L"", 1 },
144 { L"foo bar", L"foo", L"bar", L"", 2 },
145 { L"\"foo bar\"", L"foo", L"bar", L"", 2 },
146 { L"\"foo bar\" a", L"foo", L"bar", L"a", 3 },
147 };
148 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(data); ++i) {
149 std::vector<std::wstring> results;
150 QueryParser parser;
151 parser.ExtractQueryWords(data[i].text, &results);
152 ASSERT_EQ(data[i].word_count, results.size());
153 EXPECT_EQ(data[i].w1, results[0]);
154 if (results.size() == 2)
155 EXPECT_EQ(data[i].w2, results[1]);
156 if (results.size() == 3)
157 EXPECT_EQ(data[i].w3, results[2]);
158 }
159 }
OLDNEW
« no previous file with comments | « chrome/browser/history/query_parser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698