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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/history/query_parser.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/history/query_parser_unittest.cc
===================================================================
--- chrome/browser/history/query_parser_unittest.cc (revision 6595)
+++ chrome/browser/history/query_parser_unittest.cc (working copy)
@@ -131,3 +131,29 @@
}
}
}
+
+TEST_F(QueryParserTest, ExtractQueryWords) {
+ struct TestData2 {
+ const std::wstring text;
+ const std::wstring w1;
+ const std::wstring w2;
+ const std::wstring w3;
+ const size_t word_count;
+ } data[] = {
+ { L"foo", L"foo", L"", L"", 1 },
+ { L"foo bar", L"foo", L"bar", L"", 2 },
+ { L"\"foo bar\"", L"foo", L"bar", L"", 2 },
+ { L"\"foo bar\" a", L"foo", L"bar", L"a", 3 },
+ };
+ for (size_t i = 0; i < ARRAYSIZE_UNSAFE(data); ++i) {
+ std::vector<std::wstring> results;
+ QueryParser parser;
+ parser.ExtractQueryWords(data[i].text, &results);
+ ASSERT_EQ(data[i].word_count, results.size());
+ EXPECT_EQ(data[i].w1, results[0]);
+ if (results.size() == 2)
+ EXPECT_EQ(data[i].w2, results[1]);
+ if (results.size() == 3)
+ EXPECT_EQ(data[i].w3, results[2]);
+ }
+}
« 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