summaryrefslogtreecommitdiffstats
path: root/sql/sqlite_features_unittest.cc
diff options
context:
space:
mode:
authorshess <shess@chromium.org>2015-01-09 16:42:29 -0800
committerCommit bot <commit-bot@chromium.org>2015-01-10 00:44:03 +0000
commit355d9a1e3cfc8e40eec3f3b0aae9e8baeb4ae14d (patch)
treeed9d453aa5aae4e140d84ec2105dfe4b3ea31d09 /sql/sqlite_features_unittest.cc
parent34d0e31a6543a429eb2364ea531591b8a99ded24 (diff)
downloadchromium_src-355d9a1e3cfc8e40eec3f3b0aae9e8baeb4ae14d.zip
chromium_src-355d9a1e3cfc8e40eec3f3b0aae9e8baeb4ae14d.tar.gz
chromium_src-355d9a1e3cfc8e40eec3f3b0aae9e8baeb4ae14d.tar.bz2
[sql] Test that a Chromium fts change is actually in place.
In working on a new import of SQLite, I found the patch resulting from: http://codereview.chromium.org/14176 This only touches fts2, not fts3. These tests verify that both versions work in the way the patch implies. BUG=340757 Review URL: https://codereview.chromium.org/844443002 Cr-Commit-Position: refs/heads/master@{#310922}
Diffstat (limited to 'sql/sqlite_features_unittest.cc')
-rw-r--r--sql/sqlite_features_unittest.cc34
1 files changed, 34 insertions, 0 deletions
diff --git a/sql/sqlite_features_unittest.cc b/sql/sqlite_features_unittest.cc
index d9bcb86..1aff80e 100644
--- a/sql/sqlite_features_unittest.cc
+++ b/sql/sqlite_features_unittest.cc
@@ -71,6 +71,24 @@ TEST_F(SQLiteFeaturesTest, NoFTS1) {
TEST_F(SQLiteFeaturesTest, FTS2) {
ASSERT_TRUE(db().Execute("CREATE VIRTUAL TABLE foo USING fts2(x)"));
}
+
+// A standard SQLite will not include our patch. This includes iOS.
+#if !defined(USE_SYSTEM_SQLITE)
+// Chromium fts2 was patched to treat "foo*" as a prefix search, though the icu
+// tokenizer will return it as two tokens {"foo", "*"}.
+TEST_F(SQLiteFeaturesTest, FTS2_Prefix) {
+ const char kCreateSql[] =
+ "CREATE VIRTUAL TABLE foo USING fts2(x, tokenize icu)";
+ ASSERT_TRUE(db().Execute(kCreateSql));
+
+ ASSERT_TRUE(db().Execute("INSERT INTO foo (x) VALUES ('test')"));
+
+ sql::Statement s(db().GetUniqueStatement(
+ "SELECT x FROM foo WHERE x MATCH 'te*'"));
+ ASSERT_TRUE(s.Step());
+ EXPECT_EQ("test", s.ColumnString(0));
+}
+#endif
#endif
// fts3 is used for current history files, and also for WebDatabase.
@@ -78,4 +96,20 @@ TEST_F(SQLiteFeaturesTest, FTS3) {
ASSERT_TRUE(db().Execute("CREATE VIRTUAL TABLE foo USING fts3(x)"));
}
+#if !defined(USE_SYSTEM_SQLITE)
+// Test that fts3 doesn't need fts2's patch (see above).
+TEST_F(SQLiteFeaturesTest, FTS3_Prefix) {
+ const char kCreateSql[] =
+ "CREATE VIRTUAL TABLE foo USING fts3(x, tokenize icu)";
+ ASSERT_TRUE(db().Execute(kCreateSql));
+
+ ASSERT_TRUE(db().Execute("INSERT INTO foo (x) VALUES ('test')"));
+
+ sql::Statement s(db().GetUniqueStatement(
+ "SELECT x FROM foo WHERE x MATCH 'te*'"));
+ ASSERT_TRUE(s.Step());
+ EXPECT_EQ("test", s.ColumnString(0));
+}
+#endif
+
} // namespace