1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/persistentstorage/sqlite3api/TEST/TclScript/fts1a.test Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,186 @@
1.4 +# 2006 September 9
1.5 +#
1.6 +# The author disclaims copyright to this source code. In place of
1.7 +# a legal notice, here is a blessing:
1.8 +#
1.9 +# May you do good and not evil.
1.10 +# May you find forgiveness for yourself and forgive others.
1.11 +# May you share freely, never taking more than you give.
1.12 +#
1.13 +#*************************************************************************
1.14 +# This file implements regression tests for SQLite library. The
1.15 +# focus of this script is testing the FTS1 module.
1.16 +#
1.17 +# $Id: fts1a.test,v 1.4 2006/09/28 19:43:32 drh Exp $
1.18 +#
1.19 +
1.20 +set testdir [file dirname $argv0]
1.21 +source $testdir/tester.tcl
1.22 +
1.23 +# If SQLITE_ENABLE_FTS1 is defined, omit this file.
1.24 +ifcapable !fts1 {
1.25 + finish_test
1.26 + return
1.27 +}
1.28 +
1.29 +# Construct a full-text search table containing five keywords:
1.30 +# one, two, three, four, and five, in various combinations. The
1.31 +# rowid for each will be a bitmask for the elements it contains.
1.32 +#
1.33 +db eval {
1.34 + CREATE VIRTUAL TABLE t1 USING fts1(content);
1.35 + INSERT INTO t1(content) VALUES('one');
1.36 + INSERT INTO t1(content) VALUES('two');
1.37 + INSERT INTO t1(content) VALUES('one two');
1.38 + INSERT INTO t1(content) VALUES('three');
1.39 + INSERT INTO t1(content) VALUES('one three');
1.40 + INSERT INTO t1(content) VALUES('two three');
1.41 + INSERT INTO t1(content) VALUES('one two three');
1.42 + INSERT INTO t1(content) VALUES('four');
1.43 + INSERT INTO t1(content) VALUES('one four');
1.44 + INSERT INTO t1(content) VALUES('two four');
1.45 + INSERT INTO t1(content) VALUES('one two four');
1.46 + INSERT INTO t1(content) VALUES('three four');
1.47 + INSERT INTO t1(content) VALUES('one three four');
1.48 + INSERT INTO t1(content) VALUES('two three four');
1.49 + INSERT INTO t1(content) VALUES('one two three four');
1.50 + INSERT INTO t1(content) VALUES('five');
1.51 + INSERT INTO t1(content) VALUES('one five');
1.52 + INSERT INTO t1(content) VALUES('two five');
1.53 + INSERT INTO t1(content) VALUES('one two five');
1.54 + INSERT INTO t1(content) VALUES('three five');
1.55 + INSERT INTO t1(content) VALUES('one three five');
1.56 + INSERT INTO t1(content) VALUES('two three five');
1.57 + INSERT INTO t1(content) VALUES('one two three five');
1.58 + INSERT INTO t1(content) VALUES('four five');
1.59 + INSERT INTO t1(content) VALUES('one four five');
1.60 + INSERT INTO t1(content) VALUES('two four five');
1.61 + INSERT INTO t1(content) VALUES('one two four five');
1.62 + INSERT INTO t1(content) VALUES('three four five');
1.63 + INSERT INTO t1(content) VALUES('one three four five');
1.64 + INSERT INTO t1(content) VALUES('two three four five');
1.65 + INSERT INTO t1(content) VALUES('one two three four five');
1.66 +}
1.67 +
1.68 +do_test fts1a-1.1 {
1.69 + execsql {SELECT rowid FROM t1 WHERE content MATCH 'one'}
1.70 +} {1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31}
1.71 +do_test fts1a-1.2 {
1.72 + execsql {SELECT rowid FROM t1 WHERE content MATCH 'one two'}
1.73 +} {3 7 11 15 19 23 27 31}
1.74 +do_test fts1a-1.3 {
1.75 + execsql {SELECT rowid FROM t1 WHERE content MATCH 'two one'}
1.76 +} {3 7 11 15 19 23 27 31}
1.77 +do_test fts1a-1.4 {
1.78 + execsql {SELECT rowid FROM t1 WHERE content MATCH 'one two three'}
1.79 +} {7 15 23 31}
1.80 +do_test fts1a-1.5 {
1.81 + execsql {SELECT rowid FROM t1 WHERE content MATCH 'one three two'}
1.82 +} {7 15 23 31}
1.83 +do_test fts1a-1.6 {
1.84 + execsql {SELECT rowid FROM t1 WHERE content MATCH 'two three one'}
1.85 +} {7 15 23 31}
1.86 +do_test fts1a-1.7 {
1.87 + execsql {SELECT rowid FROM t1 WHERE content MATCH 'two one three'}
1.88 +} {7 15 23 31}
1.89 +do_test fts1a-1.8 {
1.90 + execsql {SELECT rowid FROM t1 WHERE content MATCH 'three one two'}
1.91 +} {7 15 23 31}
1.92 +do_test fts1a-1.9 {
1.93 + execsql {SELECT rowid FROM t1 WHERE content MATCH 'three two one'}
1.94 +} {7 15 23 31}
1.95 +do_test fts1a-1.10 {
1.96 + execsql {SELECT rowid FROM t1 WHERE content MATCH 'one two THREE'}
1.97 +} {7 15 23 31}
1.98 +do_test fts1a-1.11 {
1.99 + execsql {SELECT rowid FROM t1 WHERE content MATCH ' ONE Two three '}
1.100 +} {7 15 23 31}
1.101 +
1.102 +do_test fts1a-2.1 {
1.103 + execsql {SELECT rowid FROM t1 WHERE content MATCH '"one"'}
1.104 +} {1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31}
1.105 +do_test fts1a-2.2 {
1.106 + execsql {SELECT rowid FROM t1 WHERE content MATCH '"one two"'}
1.107 +} {3 7 11 15 19 23 27 31}
1.108 +do_test fts1a-2.3 {
1.109 + execsql {SELECT rowid FROM t1 WHERE content MATCH '"two one"'}
1.110 +} {}
1.111 +do_test fts1a-2.4 {
1.112 + execsql {SELECT rowid FROM t1 WHERE content MATCH '"one two three"'}
1.113 +} {7 15 23 31}
1.114 +do_test fts1a-2.5 {
1.115 + execsql {SELECT rowid FROM t1 WHERE content MATCH '"one three two"'}
1.116 +} {}
1.117 +do_test fts1a-2.6 {
1.118 + execsql {SELECT rowid FROM t1 WHERE content MATCH '"one two three four"'}
1.119 +} {15 31}
1.120 +do_test fts1a-2.7 {
1.121 + execsql {SELECT rowid FROM t1 WHERE content MATCH '"one three two four"'}
1.122 +} {}
1.123 +do_test fts1a-2.8 {
1.124 + execsql {SELECT rowid FROM t1 WHERE content MATCH '"one three five"'}
1.125 +} {21}
1.126 +do_test fts1a-2.9 {
1.127 + execsql {SELECT rowid FROM t1 WHERE content MATCH '"one three" five'}
1.128 +} {21 29}
1.129 +do_test fts1a-2.10 {
1.130 + execsql {SELECT rowid FROM t1 WHERE content MATCH 'five "one three"'}
1.131 +} {21 29}
1.132 +do_test fts1a-2.11 {
1.133 + execsql {SELECT rowid FROM t1 WHERE content MATCH 'five "one three" four'}
1.134 +} {29}
1.135 +do_test fts1a-2.12 {
1.136 + execsql {SELECT rowid FROM t1 WHERE content MATCH 'five four "one three"'}
1.137 +} {29}
1.138 +do_test fts1a-2.13 {
1.139 + execsql {SELECT rowid FROM t1 WHERE content MATCH '"one three" four five'}
1.140 +} {29}
1.141 +
1.142 +do_test fts1a-3.1 {
1.143 + execsql {SELECT rowid FROM t1 WHERE content MATCH 'one'}
1.144 +} {1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31}
1.145 +do_test fts1a-3.2 {
1.146 + execsql {SELECT rowid FROM t1 WHERE content MATCH 'one -two'}
1.147 +} {1 5 9 13 17 21 25 29}
1.148 +do_test fts1a-3.3 {
1.149 + execsql {SELECT rowid FROM t1 WHERE content MATCH '-two one'}
1.150 +} {1 5 9 13 17 21 25 29}
1.151 +
1.152 +do_test fts1a-4.1 {
1.153 + execsql {SELECT rowid FROM t1 WHERE content MATCH 'one OR two'}
1.154 +} {1 2 3 5 6 7 9 10 11 13 14 15 17 18 19 21 22 23 25 26 27 29 30 31}
1.155 +do_test fts1a-4.2 {
1.156 + execsql {SELECT rowid FROM t1 WHERE content MATCH '"one two" OR three'}
1.157 +} {3 4 5 6 7 11 12 13 14 15 19 20 21 22 23 27 28 29 30 31}
1.158 +do_test fts1a-4.3 {
1.159 + execsql {SELECT rowid FROM t1 WHERE content MATCH 'three OR "one two"'}
1.160 +} {3 4 5 6 7 11 12 13 14 15 19 20 21 22 23 27 28 29 30 31}
1.161 +do_test fts1a-4.4 {
1.162 + execsql {SELECT rowid FROM t1 WHERE content MATCH 'one two OR three'}
1.163 +} {3 5 7 11 13 15 19 21 23 27 29 31}
1.164 +do_test fts1a-4.5 {
1.165 + execsql {SELECT rowid FROM t1 WHERE content MATCH 'three OR two one'}
1.166 +} {3 5 7 11 13 15 19 21 23 27 29 31}
1.167 +do_test fts1a-4.6 {
1.168 + execsql {SELECT rowid FROM t1 WHERE content MATCH 'one two OR three OR four'}
1.169 +} {3 5 7 9 11 13 15 19 21 23 25 27 29 31}
1.170 +do_test fts1a-4.7 {
1.171 + execsql {SELECT rowid FROM t1 WHERE content MATCH 'two OR three OR four one'}
1.172 +} {3 5 7 9 11 13 15 19 21 23 25 27 29 31}
1.173 +
1.174 +# Test the ability to handle NULL content
1.175 +#
1.176 +do_test fts1a-5.1 {
1.177 + execsql {INSERT INTO t1(content) VALUES(NULL)}
1.178 +} {}
1.179 +do_test fts1a-5.2 {
1.180 + set rowid [db last_insert_rowid]
1.181 + execsql {SELECT content FROM t1 WHERE rowid=$rowid}
1.182 +} {{}}
1.183 +do_test fts1a-5.3 {
1.184 + execsql {SELECT rowid FROM t1 WHERE content MATCH NULL}
1.185 +} {}
1.186 +
1.187 +
1.188 +
1.189 +finish_test