modernc.org/cc@v1.0.1/v2/testdata/_sqlite/ext/fts5/test/fts5determin.test (about) 1 # 2016 March 21 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 # Specifically, that the fts5 module is deterministic. At one point, when 15 # segment ids were allocated using sqlite3_randomness(), this was not the 16 # case. 17 # 18 19 source [file join [file dirname [info script]] fts5_common.tcl] 20 set testprefix fts5aa 21 return_if_no_fts5 22 23 proc do_determin_test {tn} { 24 uplevel [list 25 do_execsql_test $tn { 26 SELECT (SELECT md5sum(id, block) FROM t1_data)== 27 (SELECT md5sum(id, block) FROM t2_data), 28 (SELECT md5sum(id, block) FROM t1_data)== 29 (SELECT md5sum(id, block) FROM t3_data) 30 } {1 1} 31 ] 32 } 33 34 foreach_detail_mode $::testprefix { 35 do_execsql_test 1.0 { 36 CREATE VIRTUAL TABLE t1 USING fts5(a, b, prefix="1 2", detail=%DETAIL%); 37 CREATE VIRTUAL TABLE t2 USING fts5(a, b, prefix="1 2", detail=%DETAIL%); 38 CREATE VIRTUAL TABLE t3 USING fts5(a, b, prefix="1 2", detail=%DETAIL%); 39 } 40 41 do_test 1.1 { 42 foreach t {t1 t2 t3} { 43 execsql [string map [list TBL $t] { 44 INSERT INTO TBL VALUES('a b c', 'd e f'); 45 INSERT INTO TBL VALUES('c1 c2 c3', 'c1 c2 c3'); 46 INSERT INTO TBL VALUES('xyzxyzxyz', 'xyzxyzxyz'); 47 }] 48 } 49 } {} 50 51 do_determin_test 1.2 52 53 do_test 1.3 { 54 foreach t {t1 t2 t3} { 55 execsql [string map [list TBL $t] { 56 INSERT INTO TBL(TBL) VALUES('optimize'); 57 }] 58 } 59 } {} 60 61 do_determin_test 1.4 62 } 63 64 65 finish_test