os/persistentdata/persistentstorage/sqlite3api/TEST/TclScript/fts2e.test
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/persistentdata/persistentstorage/sqlite3api/TEST/TclScript/fts2e.test	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,85 @@
     1.4 +# 2006 October 19
     1.5 +#
     1.6 +# The author disclaims copyright to this source code.
     1.7 +#
     1.8 +#*************************************************************************
     1.9 +# This file implements regression tests for SQLite library.  The
    1.10 +# focus of this script is testing deletions in the FTS2 module.
    1.11 +#
    1.12 +# $Id: fts2e.test,v 1.1 2006/10/19 23:36:26 shess Exp $
    1.13 +#
    1.14 +
    1.15 +set testdir [file dirname $argv0]
    1.16 +source $testdir/tester.tcl
    1.17 +
    1.18 +# If SQLITE_ENABLE_FTS2 is defined, omit this file.
    1.19 +ifcapable !fts2 {
    1.20 +  finish_test
    1.21 +  return
    1.22 +}
    1.23 +
    1.24 +# Construct a full-text search table containing keywords which are the
    1.25 +# ordinal numbers of the bit positions set for a sequence of integers,
    1.26 +# which are used for the rowid.  There are a total of 30 INSERT and
    1.27 +# DELETE statements, so that we'll test both the segmentMerge() merge
    1.28 +# (over the first 16) and the termSelect() merge (over the level-1
    1.29 +# segment and 14 level-0 segments).
    1.30 +db eval {
    1.31 +  CREATE VIRTUAL TABLE t1 USING fts2(content);
    1.32 +  INSERT INTO t1 (rowid, content) VALUES(1, 'one');
    1.33 +  INSERT INTO t1 (rowid, content) VALUES(2, 'two');
    1.34 +  INSERT INTO t1 (rowid, content) VALUES(3, 'one two');
    1.35 +  INSERT INTO t1 (rowid, content) VALUES(4, 'three');
    1.36 +  DELETE FROM t1 WHERE rowid = 1;
    1.37 +  INSERT INTO t1 (rowid, content) VALUES(5, 'one three');
    1.38 +  INSERT INTO t1 (rowid, content) VALUES(6, 'two three');
    1.39 +  INSERT INTO t1 (rowid, content) VALUES(7, 'one two three');
    1.40 +  DELETE FROM t1 WHERE rowid = 4;
    1.41 +  INSERT INTO t1 (rowid, content) VALUES(8, 'four');
    1.42 +  INSERT INTO t1 (rowid, content) VALUES(9, 'one four');
    1.43 +  INSERT INTO t1 (rowid, content) VALUES(10, 'two four');
    1.44 +  DELETE FROM t1 WHERE rowid = 7;
    1.45 +  INSERT INTO t1 (rowid, content) VALUES(11, 'one two four');
    1.46 +  INSERT INTO t1 (rowid, content) VALUES(12, 'three four');
    1.47 +  INSERT INTO t1 (rowid, content) VALUES(13, 'one three four');
    1.48 +  DELETE FROM t1 WHERE rowid = 10;
    1.49 +  INSERT INTO t1 (rowid, content) VALUES(14, 'two three four');
    1.50 +  INSERT INTO t1 (rowid, content) VALUES(15, 'one two three four');
    1.51 +  INSERT INTO t1 (rowid, content) VALUES(16, 'five');
    1.52 +  DELETE FROM t1 WHERE rowid = 13;
    1.53 +  INSERT INTO t1 (rowid, content) VALUES(17, 'one five');
    1.54 +  INSERT INTO t1 (rowid, content) VALUES(18, 'two five');
    1.55 +  INSERT INTO t1 (rowid, content) VALUES(19, 'one two five');
    1.56 +  DELETE FROM t1 WHERE rowid = 16;
    1.57 +  INSERT INTO t1 (rowid, content) VALUES(20, 'three five');
    1.58 +  INSERT INTO t1 (rowid, content) VALUES(21, 'one three five');
    1.59 +  INSERT INTO t1 (rowid, content) VALUES(22, 'two three five');
    1.60 +  DELETE FROM t1 WHERE rowid = 19;
    1.61 +  DELETE FROM t1 WHERE rowid = 22;
    1.62 +}
    1.63 +
    1.64 +do_test fts2f-1.1 {
    1.65 +  execsql {SELECT COUNT(*) FROM t1}
    1.66 +} {14}
    1.67 +
    1.68 +do_test fts2e-2.1 {
    1.69 +  execsql {SELECT rowid FROM t1 WHERE content MATCH 'one'}
    1.70 +} {3 5 9 11 15 17 21}
    1.71 +
    1.72 +do_test fts2e-2.2 {
    1.73 +  execsql {SELECT rowid FROM t1 WHERE content MATCH 'two'}
    1.74 +} {2 3 6 11 14 15 18}
    1.75 +
    1.76 +do_test fts2e-2.3 {
    1.77 +  execsql {SELECT rowid FROM t1 WHERE content MATCH 'three'}
    1.78 +} {5 6 12 14 15 20 21}
    1.79 +
    1.80 +do_test fts2e-2.4 {
    1.81 +  execsql {SELECT rowid FROM t1 WHERE content MATCH 'four'}
    1.82 +} {8 9 11 12 14 15}
    1.83 +
    1.84 +do_test fts2e-2.5 {
    1.85 +  execsql {SELECT rowid FROM t1 WHERE content MATCH 'five'}
    1.86 +} {17 18 20 21}
    1.87 +
    1.88 +finish_test