Index: chrome/browser/google_apis/drive_api_util_unittest.cc |
diff --git a/chrome/browser/google_apis/drive_api_util_unittest.cc b/chrome/browser/google_apis/drive_api_util_unittest.cc |
index 0577c6c106496ebfc70c4e183895c41492be847b..b97f8a5f313cb1c955d3d23f74e539eabbde54f0 100644 |
--- a/chrome/browser/google_apis/drive_api_util_unittest.cc |
+++ b/chrome/browser/google_apis/drive_api_util_unittest.cc |
@@ -16,6 +16,25 @@ TEST(DriveApiUtilTest, EscapeQueryStringValue) { |
EXPECT_EQ("\\'abcde\\'", EscapeQueryStringValue("'abcde'")); |
} |
+TEST(DriveApiUtilTest, TranslateQuery) { |
+ EXPECT_EQ("", TranslateQuery("")); |
+ EXPECT_EQ("fullText contains 'dog'", TranslateQuery("dog")); |
+ EXPECT_EQ("fullText contains 'dog' and fullText contains 'cat'", |
+ TranslateQuery("dog cat")); |
+ EXPECT_EQ("not fullText contains 'cat'", TranslateQuery("-cat")); |
+ EXPECT_EQ("fullText contains 'dog cat'", TranslateQuery("\"dog cat\"")); |
+ |
+ // Should handles full-width white space correctly. |
+ // Note: \xE3\x80\x80 (\u3000) is Ideographic Space (a.k.a. Japanese |
+ // full-width whitespace). |
+ EXPECT_EQ("fullText contains 'dog' and fullText contains 'cat'", |
+ TranslateQuery("dog" "\xE3\x80\x80" "cat")); |
+ |
+ // If the quoted token is not closed (i.e. the last '"' is missing), |
+ // we handle the remaining string is one token, as a fallback. |
+ EXPECT_EQ("fullText contains 'dog cat'", TranslateQuery("\"dog cat")); |
hashimoto
2013/04/18 10:37:16
What are the desired output for the following case
hidehiko
2013/04/18 12:05:54
Good point. Handled quoted text with a leading hyp
|
+} |
+ |
} // namespace util |
} // namespace drive |
} // namespace google_apis |