os/persistentdata/persistentstorage/sqlite3api/TEST/TclScript/fts3ah.test
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
# 2006 October 31 (scaaarey)
sl@0
     2
#
sl@0
     3
# The author disclaims copyright to this source code.
sl@0
     4
#
sl@0
     5
#*************************************************************************
sl@0
     6
# This file implements regression tests for SQLite library.  The focus
sl@0
     7
# here is testing correct handling of excessively long terms.
sl@0
     8
#
sl@0
     9
# $Id: fts3ah.test,v 1.1 2007/08/20 17:38:42 shess Exp $
sl@0
    10
#
sl@0
    11
sl@0
    12
set testdir [file dirname $argv0]
sl@0
    13
source $testdir/tester.tcl
sl@0
    14
sl@0
    15
# If SQLITE_ENABLE_FTS3 is defined, omit this file.
sl@0
    16
ifcapable !fts3 {
sl@0
    17
  finish_test
sl@0
    18
  return
sl@0
    19
}
sl@0
    20
sl@0
    21
# Generate a term of len copies of char.
sl@0
    22
proc bigterm {char len} {
sl@0
    23
  for {set term ""} {$len>0} {incr len -1} {
sl@0
    24
    append term $char
sl@0
    25
  }
sl@0
    26
  return $term
sl@0
    27
}
sl@0
    28
sl@0
    29
# Generate a document of bigterms based on characters from the list
sl@0
    30
# chars.
sl@0
    31
proc bigtermdoc {chars len} {
sl@0
    32
  set doc ""
sl@0
    33
  foreach char $chars {
sl@0
    34
    append doc " " [bigterm $char $len]
sl@0
    35
  }
sl@0
    36
  return $doc
sl@0
    37
}
sl@0
    38
sl@0
    39
set len 5000
sl@0
    40
set doc1 [bigtermdoc {a b c d} $len]
sl@0
    41
set doc2 [bigtermdoc {b d e f} $len]
sl@0
    42
set doc3 [bigtermdoc {a c e} $len]
sl@0
    43
sl@0
    44
set aterm [bigterm a $len]
sl@0
    45
set bterm [bigterm b $len]
sl@0
    46
set xterm [bigterm x $len]
sl@0
    47
sl@0
    48
db eval {
sl@0
    49
  CREATE VIRTUAL TABLE t1 USING fts3(content);
sl@0
    50
  INSERT INTO t1 (rowid, content) VALUES(1, $doc1);
sl@0
    51
  INSERT INTO t1 (rowid, content) VALUES(2, $doc2);
sl@0
    52
  INSERT INTO t1 (rowid, content) VALUES(3, $doc3);
sl@0
    53
}
sl@0
    54
sl@0
    55
# No hits at all.  Returns empty doclists from termSelect().
sl@0
    56
do_test fts3ah-1.1 {
sl@0
    57
  execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'something'}
sl@0
    58
} {}
sl@0
    59
sl@0
    60
do_test fts3ah-1.2 {
sl@0
    61
  execsql {SELECT rowid FROM t1 WHERE t1 MATCH $aterm}
sl@0
    62
} {1 3}
sl@0
    63
sl@0
    64
do_test fts3ah-1.2 {
sl@0
    65
  execsql {SELECT rowid FROM t1 WHERE t1 MATCH $xterm}
sl@0
    66
} {}
sl@0
    67
sl@0
    68
do_test fts3ah-1.3 {
sl@0
    69
  execsql "SELECT rowid FROM t1 WHERE t1 MATCH '$aterm -$xterm'"
sl@0
    70
} {1 3}
sl@0
    71
sl@0
    72
do_test fts3ah-1.4 {
sl@0
    73
  execsql "SELECT rowid FROM t1 WHERE t1 MATCH '\"$aterm $bterm\"'"
sl@0
    74
} {1}
sl@0
    75
sl@0
    76
finish_test