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

Unified Diff: third_party/sqlite/sqlite-src-3100200/ext/fts5/test/fts5rank.test

Issue 1610543003: [sql] Import reference version of SQLite 3.10.2. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months 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
Index: third_party/sqlite/sqlite-src-3100200/ext/fts5/test/fts5rank.test
diff --git a/third_party/sqlite/sqlite-src-3100200/ext/fts5/test/fts5rank.test b/third_party/sqlite/sqlite-src-3100200/ext/fts5/test/fts5rank.test
new file mode 100644
index 0000000000000000000000000000000000000000..4961b426058bae383dd071efe2539dadd5b9d4f8
--- /dev/null
+++ b/third_party/sqlite/sqlite-src-3100200/ext/fts5/test/fts5rank.test
@@ -0,0 +1,100 @@
+# 2014 Dec 20
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file focuses on testing queries that use the "rank" column.
+#
+
+source [file join [file dirname [info script]] fts5_common.tcl]
+set testprefix fts5rank
+
+# If SQLITE_ENABLE_FTS5 is defined, omit this file.
+ifcapable !fts5 {
+ finish_test
+ return
+}
+
+
+#-------------------------------------------------------------------------
+# "ORDER BY rank" + highlight() + large poslists.
+#
+do_execsql_test 1.0 {
+ CREATE VIRTUAL TABLE xyz USING fts5(z);
+}
+do_test 1.1 {
+ set doc [string trim [string repeat "x y " 500]]
+ execsql { INSERT INTO xyz VALUES($doc) }
+} {}
+do_execsql_test 1.2 {
+ SELECT highlight(xyz, 0, '[', ']') FROM xyz WHERE xyz MATCH 'x' ORDER BY rank
+} [list [string map {x [x]} $doc]]
+
+do_execsql_test 1.3 {
+ SELECT highlight(xyz, 0, '[', ']') FROM xyz
+ WHERE xyz MATCH 'x AND y' ORDER BY rank
+} [list [string map {x [x] y [y]} $doc]]
+
+#-------------------------------------------------------------------------
+# Check that the 'rank' option really is persistent.
+#
+do_execsql_test 2.0 {
+ CREATE VIRTUAL TABLE tt USING fts5(a);
+ INSERT INTO tt VALUES('a x x x x');
+ INSERT INTO tt VALUES('x x a a a');
+ INSERT INTO tt VALUES('x a a x x');
+}
+
+proc firstinst {cmd} {
+ foreach {p c o} [$cmd xInst 0] {}
+ return $o
+}
+sqlite3_fts5_create_function db firstinst firstinst
+
+do_execsql_test 2.1 {
+ SELECT rowid FROM tt('a') ORDER BY rank;
+} {2 3 1}
+
+do_execsql_test 2.2 {
+ SELECT rowid FROM tt('a', 'firstinst()') ORDER BY rank;
+} {1 3 2}
+
+do_execsql_test 2.3 {
+ INSERT INTO tt(tt, rank) VALUES('rank', 'firstinst()');
+ SELECT rowid FROM tt('a') ORDER BY rank;
+} {1 3 2}
+
+do_test 2.4 {
+ sqlite3 db2 test.db
+ catchsql { SELECT rowid FROM tt('a') ORDER BY rank; } db2
+} {1 {no such function: firstinst}}
+
+do_test 2.5 {
+ db2 close
+ sqlite3 db2 test.db
+ sqlite3_fts5_create_function db2 firstinst firstinst
+ execsql { SELECT rowid FROM tt('a') ORDER BY rank; } db2
+} {1 3 2}
+
+do_test 2.6 {
+ execsql { SELECT rowid FROM tt('a') ORDER BY rank; } db2
+} {1 3 2}
+
+do_test 2.7 {
+ execsql { SELECT rowid FROM tt('a') ORDER BY rank; } db
+} {1 3 2}
+
+
+
+
+
+
+
+finish_test
+

Powered by Google App Engine
This is Rietveld 408576698