modernc.org/cc@v1.0.1/v2/testdata/_sqlite/ext/fts5/test/fts5bigtok.test (about) 1 # 2016 Jan 19 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 15 source [file join [file dirname [info script]] fts5_common.tcl] 16 set testprefix fts5bigtok 17 return_if_no_fts5 18 19 proc rndterm {} { 20 set L [list a b c d e f g h i j k l m n o p q r s t u v w x y z] 21 set l [lindex $L [expr int(rand() * [llength $L])]] 22 string repeat $l [expr int(rand() * 5) + 60] 23 } 24 25 proc rnddoc {n} { 26 set res [list] 27 for {set i 0} {$i < $n} {incr i} { 28 lappend res [rndterm] 29 } 30 set res 31 } 32 33 foreach_detail_mode $::testprefix { 34 db func rnddoc rnddoc 35 do_execsql_test 1.0 { 36 CREATE VIRTUAL TABLE t1 USING fts5(x, detail=%DETAIL%); 37 INSERT INTO t1(t1, rank) VALUES('pgsz', 32); 38 CREATE VIRTUAL TABLE t1vocab USING fts5vocab(t1, row); 39 40 WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<10 ) 41 INSERT INTO t1 SELECT rnddoc(3) FROM s; 42 43 WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<10 ) 44 INSERT INTO t1 SELECT rnddoc(3) FROM s; 45 } 46 47 foreach v [db eval {SELECT term FROM t1vocab}] { 48 set res [db eval {SELECT rowid FROM t1($v)}] 49 do_execsql_test 1.[string range $v 0 0] { 50 SELECT rowid FROM t1($v) ORDER BY rowid DESC 51 } [lsort -integer -decr $res] 52 } 53 54 do_execsql_test 2.0 { 55 INSERT INTO t1(t1) VALUES('optimize'); 56 } 57 58 foreach v [db eval {SELECT term FROM t1vocab}] { 59 set res [db eval {SELECT rowid FROM t1($v)}] 60 do_execsql_test 2.[string range $v 0 0] { 61 SELECT rowid FROM t1($v) ORDER BY rowid DESC 62 } [lsort -integer -decr $res] 63 } 64 } 65 66 finish_test