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

Unified Diff: third_party/sqlite/src/test/fts3matchinfo.test

Issue 1610963002: Import 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
« no previous file with comments | « third_party/sqlite/src/test/fts3fault2.test ('k') | third_party/sqlite/src/test/fts3offsets.test » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/sqlite/src/test/fts3matchinfo.test
diff --git a/third_party/sqlite/src/test/fts3matchinfo.test b/third_party/sqlite/src/test/fts3matchinfo.test
index 36c91211180e6f6b25078d0883fae0c2bc0fdb38..b17d7da0a59c8bfdddd5495d7f92d83c9715faef 100644
--- a/third_party/sqlite/src/test/fts3matchinfo.test
+++ b/third_party/sqlite/src/test/fts3matchinfo.test
@@ -449,5 +449,107 @@ do_execsql_test 10.1 {
ORDER BY 1;
} {1 1 one 2 2 two 3 3 three}
+#---------------------------------------------------------------------------
+# Test the 'y' matchinfo flag
+#
+set sqlite_fts3_enable_parentheses 1
+reset_db
+do_execsql_test 11.0 {
+ CREATE VIRTUAL TABLE tt USING fts3(x, y);
+ INSERT INTO tt VALUES('c d a c d d', 'e a g b d a'); -- 1
+ INSERT INTO tt VALUES('c c g a e b', 'c g d g e c'); -- 2
+ INSERT INTO tt VALUES('b e f d e g', 'b a c b c g'); -- 3
+ INSERT INTO tt VALUES('a c f f g d', 'd b f d e g'); -- 4
+ INSERT INTO tt VALUES('g a c f c f', 'd g g b c c'); -- 5
+ INSERT INTO tt VALUES('g a c e b b', 'd b f b g g'); -- 6
+ INSERT INTO tt VALUES('f d a a f c', 'e e a d c f'); -- 7
+ INSERT INTO tt VALUES('a c b b g f', 'a b a e d f'); -- 8
+ INSERT INTO tt VALUES('b a f e c c', 'f d b b a b'); -- 9
+ INSERT INTO tt VALUES('f d c e a c', 'f a f a a f'); -- 10
+}
+
+db func mit mit
+foreach {tn expr res} {
+ 1 "a" {
+ 1 {1 2} 2 {1 0} 3 {0 1} 4 {1 0} 5 {1 0}
+ 6 {1 0} 7 {2 1} 8 {1 2} 9 {1 1} 10 {1 3}
+ }
+
+ 2 "b" {
+ 1 {0 1} 2 {1 0} 3 {1 2} 4 {0 1} 5 {0 1}
+ 6 {2 2} 8 {2 1} 9 {1 3}
+ }
+
+ 3 "y:a" {
+ 1 {0 2} 3 {0 1}
+ 7 {0 1} 8 {0 2} 9 {0 1} 10 {0 3}
+ }
+
+ 4 "x:a" {
+ 1 {1 0} 2 {1 0} 4 {1 0} 5 {1 0}
+ 6 {1 0} 7 {2 0} 8 {1 0} 9 {1 0} 10 {1 0}
+ }
+
+ 5 "a OR b" {
+ 1 {1 2 0 1} 2 {1 0 1 0} 3 {0 1 1 2} 4 {1 0 0 1} 5 {1 0 0 1}
+ 6 {1 0 2 2} 7 {2 1 0 0} 8 {1 2 2 1} 9 {1 1 1 3} 10 {1 3 0 0}
+ }
+
+ 6 "a AND b" {
+ 1 {1 2 0 1} 2 {1 0 1 0} 3 {0 1 1 2} 4 {1 0 0 1} 5 {1 0 0 1}
+ 6 {1 0 2 2} 8 {1 2 2 1} 9 {1 1 1 3}
+ }
+
+ 7 "a OR (a AND b)" {
+ 1 {1 2 1 2 0 1} 2 {1 0 1 0 1 0} 3 {0 1 0 1 1 2} 4 {1 0 1 0 0 1}
+ 5 {1 0 1 0 0 1} 6 {1 0 1 0 2 2} 7 {2 1 0 0 0 0} 8 {1 2 1 2 2 1}
+ 9 {1 1 1 1 1 3} 10 {1 3 0 0 0 0}
+ }
+} {
+ do_execsql_test 11.1.$tn.1 {
+ SELECT rowid, mit(matchinfo(tt, 'y')) FROM tt WHERE tt MATCH $expr
+ } $res
+
+ set r2 [list]
+ foreach {rowid L} $res {
+ lappend r2 $rowid
+ set M [list]
+ foreach {a b} $L {
+ lappend M [expr ($a ? 1 : 0) + ($b ? 2 : 0)]
+ }
+ lappend r2 $M
+ }
+
+ do_execsql_test 11.1.$tn.2 {
+ SELECT rowid, mit(matchinfo(tt, 'b')) FROM tt WHERE tt MATCH $expr
+ } $r2
+ breakpoint
+
+ do_execsql_test 11.1.$tn.2 {
+ SELECT rowid, mit(matchinfo(tt, 'b')) FROM tt WHERE tt MATCH $expr
+ } $r2
+}
+set sqlite_fts3_enable_parentheses 0
+
+#---------------------------------------------------------------------------
+# Test the 'b' matchinfo flag
+#
+set sqlite_fts3_enable_parentheses 1
+reset_db
+db func mit mit
+
+do_test 12.0 {
+ set cols [list]
+ for {set i 0} {$i < 50} {incr i} { lappend cols "c$i" }
+ execsql "CREATE VIRTUAL TABLE tt USING fts3([join $cols ,])"
+} {}
+
+do_execsql_test 12.1 {
+ INSERT INTO tt (rowid, c4, c45) VALUES(1, 'abc', 'abc');
+ SELECT mit(matchinfo(tt, 'b')) FROM tt WHERE tt MATCH 'abc';
+} [list [list [expr 1<<4] [expr 1<<(45-32)]]]
+
+set sqlite_fts3_enable_parentheses 0
finish_test
+
« no previous file with comments | « third_party/sqlite/src/test/fts3fault2.test ('k') | third_party/sqlite/src/test/fts3offsets.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698