CoolFace
Modelpublic

AryaWu/sqlite

sourceHugging Faceupdated 9mo agoView on Hugging Face
0likes
fts4growth2.test93 linesDownload Raw Back to test
1# 2014 May 122#3# The author disclaims copyright to this source code.  In place of4# 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.  The12# focus of this script is testing the FTS4 module.13#14#15 16set testdir [file dirname $argv0]17source $testdir/tester.tcl18set testprefix fts4growth219 20# If SQLITE_ENABLE_FTS3 is defined, omit this file.21ifcapable !fts3 {22  finish_test23  return24}25 26source $testdir/genesis.tcl27 28do_execsql_test 1.0 { CREATE TABLE t1(docid, words); }29fts_kjv_genesis 30 31proc structure {} {32  puts [ db eval {SELECT level, count(*) FROM x1_segdir GROUP BY level} ]33}34 35proc tt {val} {36  execsql {37    DELETE FROM x1 38      WHERE docid IN (SELECT docid FROM t1 WHERE (rowid-1)%4==$val+0);39  }40  execsql {41    INSERT INTO x1(docid, content) 42      SELECT docid, words FROM t1 WHERE (rowid%4)==$val+0;43  }44}45 46do_execsql_test 1.1 {47  CREATE VIRTUAL TABLE x1 USING fts4;48  INSERT INTO x1(x1) VALUES('automerge=2');49}50 51do_test 1.2 {52  for {set i 0} {$i < 40} {incr i} {53    tt 0 ; tt 1 ; tt 2 ; tt 354  }55  execsql { 56    SELECT max(level) FROM x1_segdir; 57    SELECT count(*) FROM x1_segdir WHERE level=2;58  }59} {2 1}60 61do_test 1.3 {62  for {set i 0} {$i < 40} {incr i} {63    tt 0 ; tt 1 ; tt 2 ; tt 364  }65  execsql { 66    SELECT max(level) FROM x1_segdir; 67    SELECT count(*) FROM x1_segdir WHERE level=2;68  }69} {2 1}70 71#-------------------------------------------------------------------------72#73do_execsql_test 2.1 {74  DELETE FROM t1 WHERE rowid>16;75  DROP TABLE IF EXISTS x1;76  CREATE VIRTUAL TABLE x1 USING fts4;77}78 79db func second second80proc second {L} {lindex $L 1}81 82for {set tn 0} {$tn < 40} {incr tn} {83  do_test 2.2.$tn {84    for {set i 0} {$i < 100} {incr i} {85      tt 0 ; tt 1 ; tt 2 ; tt 386    }87    execsql { SELECT max(level) FROM x1_segdir }88  } {1}89}90 91 92finish_test93