os/persistentdata/persistentstorage/sqlite3api/TEST/TclScript/fts2h.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/fts2h.test	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,76 @@
     1.4 +# 2006 October 31 (scaaarey)
     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 +# here is testing correct handling of excessively long terms.
    1.11 +#
    1.12 +# $Id: fts2h.test,v 1.1 2006/11/29 21:03:01 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 +# Generate a term of len copies of char.
    1.25 +proc bigterm {char len} {
    1.26 +  for {set term ""} {$len>0} {incr len -1} {
    1.27 +    append term $char
    1.28 +  }
    1.29 +  return $term
    1.30 +}
    1.31 +
    1.32 +# Generate a document of bigterms based on characters from the list
    1.33 +# chars.
    1.34 +proc bigtermdoc {chars len} {
    1.35 +  set doc ""
    1.36 +  foreach char $chars {
    1.37 +    append doc " " [bigterm $char $len]
    1.38 +  }
    1.39 +  return $doc
    1.40 +}
    1.41 +
    1.42 +set len 5000
    1.43 +set doc1 [bigtermdoc {a b c d} $len]
    1.44 +set doc2 [bigtermdoc {b d e f} $len]
    1.45 +set doc3 [bigtermdoc {a c e} $len]
    1.46 +
    1.47 +set aterm [bigterm a $len]
    1.48 +set bterm [bigterm b $len]
    1.49 +set xterm [bigterm x $len]
    1.50 +
    1.51 +db eval {
    1.52 +  CREATE VIRTUAL TABLE t1 USING fts2(content);
    1.53 +  INSERT INTO t1 (rowid, content) VALUES(1, $doc1);
    1.54 +  INSERT INTO t1 (rowid, content) VALUES(2, $doc2);
    1.55 +  INSERT INTO t1 (rowid, content) VALUES(3, $doc3);
    1.56 +}
    1.57 +
    1.58 +# No hits at all.  Returns empty doclists from termSelect().
    1.59 +do_test fts2h-1.1 {
    1.60 +  execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'something'}
    1.61 +} {}
    1.62 +
    1.63 +do_test fts2h-1.2 {
    1.64 +  execsql {SELECT rowid FROM t1 WHERE t1 MATCH $aterm}
    1.65 +} {1 3}
    1.66 +
    1.67 +do_test fts2h-1.2 {
    1.68 +  execsql {SELECT rowid FROM t1 WHERE t1 MATCH $xterm}
    1.69 +} {}
    1.70 +
    1.71 +do_test fts2h-1.3 {
    1.72 +  execsql "SELECT rowid FROM t1 WHERE t1 MATCH '$aterm -$xterm'"
    1.73 +} {1 3}
    1.74 +
    1.75 +do_test fts2h-1.4 {
    1.76 +  execsql "SELECT rowid FROM t1 WHERE t1 MATCH '\"$aterm $bterm\"'"
    1.77 +} {1}
    1.78 +
    1.79 +finish_test