os/persistentdata/persistentstorage/sqlite3api/TEST/TclScript/fts2g.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/fts2g.test	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,93 @@
     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 focus
    1.10 +# of this script is testing handling of edge cases for various doclist
    1.11 +# merging functions in the FTS2 module query logic.
    1.12 +#
    1.13 +# $Id: fts2g.test,v 1.3 2007/11/16 00:23:08 shess Exp $
    1.14 +#
    1.15 +
    1.16 +set testdir [file dirname $argv0]
    1.17 +source $testdir/tester.tcl
    1.18 +
    1.19 +# If SQLITE_ENABLE_FTS2 is defined, omit this file.
    1.20 +ifcapable !fts2 {
    1.21 +  finish_test
    1.22 +  return
    1.23 +}
    1.24 +
    1.25 +db eval {
    1.26 +  CREATE VIRTUAL TABLE t1 USING fts2(content);
    1.27 +  INSERT INTO t1 (rowid, content) VALUES(1, 'this is a test');
    1.28 +  INSERT INTO t1 (rowid, content) VALUES(2, 'also a test');
    1.29 +}
    1.30 +
    1.31 +# No hits at all.  Returns empty doclists from termSelect().
    1.32 +do_test fts2g-1.1 {
    1.33 +  execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'something'}
    1.34 +} {}
    1.35 +
    1.36 +# Empty left in docListExceptMerge().
    1.37 +do_test fts2g-1.2 {
    1.38 +  execsql {SELECT rowid FROM t1 WHERE t1 MATCH '-this something'}
    1.39 +} {}
    1.40 +
    1.41 +# Empty right in docListExceptMerge().
    1.42 +do_test fts2g-1.3 {
    1.43 +  execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'this -something'}
    1.44 +} {1}
    1.45 +
    1.46 +# Empty left in docListPhraseMerge().
    1.47 +do_test fts2g-1.4 {
    1.48 +  execsql {SELECT rowid FROM t1 WHERE t1 MATCH '"this something"'}
    1.49 +} {}
    1.50 +
    1.51 +# Empty right in docListPhraseMerge().
    1.52 +do_test fts2g-1.5 {
    1.53 +  execsql {SELECT rowid FROM t1 WHERE t1 MATCH '"something is"'}
    1.54 +} {}
    1.55 +
    1.56 +# Empty left in docListOrMerge().
    1.57 +do_test fts2g-1.6 {
    1.58 +  execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'something OR this'}
    1.59 +} {1}
    1.60 +
    1.61 +# Empty right in docListOrMerge().
    1.62 +do_test fts2g-1.7 {
    1.63 +  execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'this OR something'}
    1.64 +} {1}
    1.65 +
    1.66 +# Empty left in docListAndMerge().
    1.67 +do_test fts2g-1.8 {
    1.68 +  execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'something this'}
    1.69 +} {}
    1.70 +
    1.71 +# Empty right in docListAndMerge().
    1.72 +do_test fts2g-1.9 {
    1.73 +  execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'this something'}
    1.74 +} {}
    1.75 +
    1.76 +# No support for all-except queries.
    1.77 +do_test fts2g-1.10 {
    1.78 +  catchsql {SELECT rowid FROM t1 WHERE t1 MATCH '-this -something'}
    1.79 +} {1 {SQL logic error or missing database}}
    1.80 +
    1.81 +# Test that docListOrMerge() correctly handles reaching the end of one
    1.82 +# doclist before it reaches the end of the other.
    1.83 +do_test fts2g-1.11 {
    1.84 +  execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'this OR also'}
    1.85 +} {1 2}
    1.86 +do_test fts2g-1.12 {
    1.87 +  execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'also OR this'}
    1.88 +} {1 2}
    1.89 +
    1.90 +# Empty left and right in docListOrMerge().  Each term matches neither
    1.91 +# row, and when combined there was an assertion failure.
    1.92 +do_test fts2g-1.13 {
    1.93 +  execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'something OR nothing'}
    1.94 +} {}
    1.95 +
    1.96 +finish_test