1# 2015 October 27 2# 3# The author disclaims copyright to this source code. In place of 4# a legal notice, here is a blessing: 5# 6# May you do good and not evil. 7# May you find forgiveness for yourself and forgive others. 8# May you share freely, never taking more than you give. 9# 10#************************************************************************* 11# This file implements regression tests for SQLite library. The 12# focus of this script is testing the FTS5 module. 13# 14 15source [file join [file dirname [info script]] fts5_common.tcl] 16set testprefix fts5query 17 18# If SQLITE_ENABLE_FTS5 is defined, omit this file. 19ifcapable !fts5 { 20 finish_test 21 return 22} 23 24for {set tn 1 ; set pgsz 64} {$tn<32} {incr tn; incr pgsz 16} { 25 reset_db 26 do_test 1.$tn.1 { 27 execsql { 28 CREATE VIRTUAL TABLE t1 USING fts5(x); 29 INSERT INTO t1(t1, rank) VALUES('pgsz', $pgsz); 30 BEGIN; 31 } 32 foreach x [list aaa bbb ccc ddd eee fff ggg hhh iii jjj] { 33 set doc [string repeat "$x " 30] 34 execsql { INSERT INTO t1 VALUES($doc) } 35 } 36 execsql COMMIT 37 } {} 38 39 do_execsql_test 1.$tn.2 { 40 INSERT INTO t1(t1) VALUES('integrity-check'); 41 } 42 43 set ret 1 44 foreach x [list a b c d e f g h i j] { 45 do_execsql_test 1.$tn.3.$ret { 46 SELECT rowid FROM t1 WHERE t1 MATCH $x || '*'; 47 } $ret 48 incr ret 49 } 50} 51 52for {set tn 1 ; set pgsz 64} {$tn<32} {incr tn; incr pgsz 16} { 53 reset_db 54 do_test 2.$tn.1 { 55 execsql { 56 CREATE VIRTUAL TABLE t1 USING fts5(x); 57 INSERT INTO t1(t1, rank) VALUES('pgsz', $pgsz); 58 BEGIN; 59 } 60 foreach x [list bbb ddd fff hhh jjj lll nnn ppp rrr ttt] { 61 set doc [string repeat "$x " 30] 62 execsql { INSERT INTO t1 VALUES($doc) } 63 } 64 execsql COMMIT 65 } {} 66 67 do_execsql_test 2.$tn.2 { 68 INSERT INTO t1(t1) VALUES('integrity-check'); 69 } 70 71 set ret 1 72 foreach x [list a c e g i k m o q s u] { 73 do_execsql_test 2.$tn.3.$ret { 74 SELECT rowid FROM t1 WHERE t1 MATCH $x || '*'; 75 } {} 76 incr ret 77 } 78} 79 80reset_db 81do_execsql_test 3.0 { 82 CREATE VIRTUAL TABLE x1 USING fts5(a); 83 INSERT INTO x1(rowid, a) VALUES(-1000000000000, 'toyota'); 84 INSERT INTO x1(rowid, a) VALUES(1, 'tarago'); 85} 86do_execsql_test 3.1 { 87 SELECT rowid FROM x1('t*'); 88} {-1000000000000 1} 89 90 91finish_test 92