1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/persistentstorage/sqlite3api/TEST/TclScript/fts1f.test Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,90 @@
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 updates in the FTS1 module.
1.11 +#
1.12 +# $Id: fts1f.test,v 1.2 2007/02/23 00:14:06 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_FTS1 is defined, omit this file.
1.19 +ifcapable !fts1 {
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 31 INSERT,
1.27 +# UPDATE, and DELETE statements, so that we'll test both the
1.28 +# segmentMerge() merge (over the first 16) and the termSelect() merge
1.29 +# (over the level-1 segment and 15 level-0 segments).
1.30 +db eval {
1.31 + CREATE VIRTUAL TABLE t1 USING fts1(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 + INSERT INTO t1 (rowid, content) VALUES(5, 'one three');
1.37 + INSERT INTO t1 (rowid, content) VALUES(6, 'two three');
1.38 + INSERT INTO t1 (rowid, content) VALUES(7, 'one two three');
1.39 + DELETE FROM t1 WHERE rowid = 4;
1.40 + INSERT INTO t1 (rowid, content) VALUES(8, 'four');
1.41 + UPDATE t1 SET content = 'update one three' WHERE rowid = 1;
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 + UPDATE t1 SET content = 'update two five' WHERE rowid = 8;
1.52 + INSERT INTO t1 (rowid, content) VALUES(16, 'five');
1.53 + DELETE FROM t1 WHERE rowid = 13;
1.54 + INSERT INTO t1 (rowid, content) VALUES(17, 'one five');
1.55 + INSERT INTO t1 (rowid, content) VALUES(18, 'two five');
1.56 + INSERT INTO t1 (rowid, content) VALUES(19, 'one two five');
1.57 + DELETE FROM t1 WHERE rowid = 16;
1.58 + INSERT INTO t1 (rowid, content) VALUES(20, 'three five');
1.59 + INSERT INTO t1 (rowid, content) VALUES(21, 'one three five');
1.60 + INSERT INTO t1 (rowid, content) VALUES(22, 'two three five');
1.61 + DELETE FROM t1 WHERE rowid = 19;
1.62 + UPDATE t1 SET content = 'update' WHERE rowid = 15;
1.63 +}
1.64 +
1.65 +do_test fts1f-1.1 {
1.66 + execsql {SELECT COUNT(*) FROM t1}
1.67 +} {16}
1.68 +
1.69 +do_test fts1f-2.0 {
1.70 + execsql {SELECT rowid FROM t1 WHERE content MATCH 'update'}
1.71 +} {1 8 15}
1.72 +
1.73 +do_test fts1f-2.1 {
1.74 + execsql {SELECT rowid FROM t1 WHERE content MATCH 'one'}
1.75 +} {1 3 5 9 11 17 21}
1.76 +
1.77 +do_test fts1f-2.2 {
1.78 + execsql {SELECT rowid FROM t1 WHERE content MATCH 'two'}
1.79 +} {2 3 6 8 11 14 18 22}
1.80 +
1.81 +do_test fts1f-2.3 {
1.82 + execsql {SELECT rowid FROM t1 WHERE content MATCH 'three'}
1.83 +} {1 5 6 12 14 20 21 22}
1.84 +
1.85 +do_test fts1f-2.4 {
1.86 + execsql {SELECT rowid FROM t1 WHERE content MATCH 'four'}
1.87 +} {9 11 12 14}
1.88 +
1.89 +do_test fts1f-2.5 {
1.90 + execsql {SELECT rowid FROM t1 WHERE content MATCH 'five'}
1.91 +} {8 17 18 20 21 22}
1.92 +
1.93 +finish_test