dan | 4f7c5e6 | 2010-10-19 14:07:59 +0000 | [diff] [blame] | 1 | # 2006 October 31 |
shess | db00b6a | 2007-08-20 17:38:42 +0000 | [diff] [blame] | 2 | # |
dan | 4f7c5e6 | 2010-10-19 14:07:59 +0000 | [diff] [blame] | 3 | # The author disclaims copyright to this source code. In place of |
| 4 | # a legal notice, here is a blessing: |
| 5 | # |
| 6 | # May you do good and not evil. |
| 7 | # May you find forgiveness for yourself and forgive others. |
| 8 | # May you share freely, never taking more than you give. |
shess | db00b6a | 2007-08-20 17:38:42 +0000 | [diff] [blame] | 9 | # |
| 10 | #************************************************************************* |
| 11 | # This file implements regression tests for SQLite library. The focus |
dan | 4f7c5e6 | 2010-10-19 14:07:59 +0000 | [diff] [blame] | 12 | # here is testing correct handling of very long terms. |
shess | db00b6a | 2007-08-20 17:38:42 +0000 | [diff] [blame] | 13 | # |
| 14 | |
| 15 | set testdir [file dirname $argv0] |
| 16 | source $testdir/tester.tcl |
| 17 | |
dan | 4f7c5e6 | 2010-10-19 14:07:59 +0000 | [diff] [blame] | 18 | # If SQLITE_ENABLE_FTS3 is not defined, omit this file. |
shess | db00b6a | 2007-08-20 17:38:42 +0000 | [diff] [blame] | 19 | ifcapable !fts3 { |
| 20 | finish_test |
| 21 | return |
| 22 | } |
| 23 | |
shess | db00b6a | 2007-08-20 17:38:42 +0000 | [diff] [blame] | 24 | # Generate a document of bigterms based on characters from the list |
| 25 | # chars. |
| 26 | proc bigtermdoc {chars len} { |
| 27 | set doc "" |
| 28 | foreach char $chars { |
dan | 4f7c5e6 | 2010-10-19 14:07:59 +0000 | [diff] [blame] | 29 | append doc " " [string repeat $char $len] |
shess | db00b6a | 2007-08-20 17:38:42 +0000 | [diff] [blame] | 30 | } |
| 31 | return $doc |
| 32 | } |
| 33 | |
| 34 | set len 5000 |
| 35 | set doc1 [bigtermdoc {a b c d} $len] |
| 36 | set doc2 [bigtermdoc {b d e f} $len] |
| 37 | set doc3 [bigtermdoc {a c e} $len] |
| 38 | |
dan | 4f7c5e6 | 2010-10-19 14:07:59 +0000 | [diff] [blame] | 39 | set aterm [string repeat a $len] |
| 40 | set bterm [string repeat b $len] |
| 41 | set xterm [string repeat x $len] |
shess | db00b6a | 2007-08-20 17:38:42 +0000 | [diff] [blame] | 42 | |
| 43 | db eval { |
| 44 | CREATE VIRTUAL TABLE t1 USING fts3(content); |
| 45 | INSERT INTO t1 (rowid, content) VALUES(1, $doc1); |
| 46 | INSERT INTO t1 (rowid, content) VALUES(2, $doc2); |
| 47 | INSERT INTO t1 (rowid, content) VALUES(3, $doc3); |
| 48 | } |
| 49 | |
| 50 | # No hits at all. Returns empty doclists from termSelect(). |
| 51 | do_test fts3ah-1.1 { |
| 52 | execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'something'} |
| 53 | } {} |
| 54 | |
| 55 | do_test fts3ah-1.2 { |
| 56 | execsql {SELECT rowid FROM t1 WHERE t1 MATCH $aterm} |
| 57 | } {1 3} |
| 58 | |
dan | 4e76cc3 | 2010-10-20 18:56:04 +0000 | [diff] [blame] | 59 | do_test fts3ah-1.3 { |
shess | db00b6a | 2007-08-20 17:38:42 +0000 | [diff] [blame] | 60 | execsql {SELECT rowid FROM t1 WHERE t1 MATCH $xterm} |
| 61 | } {} |
| 62 | |
dan | 4e76cc3 | 2010-10-20 18:56:04 +0000 | [diff] [blame] | 63 | do_test fts3ah-1.4 { |
shess | db00b6a | 2007-08-20 17:38:42 +0000 | [diff] [blame] | 64 | execsql "SELECT rowid FROM t1 WHERE t1 MATCH '$aterm -$xterm'" |
| 65 | } {1 3} |
| 66 | |
dan | 4e76cc3 | 2010-10-20 18:56:04 +0000 | [diff] [blame] | 67 | do_test fts3ah-1.5 { |
shess | db00b6a | 2007-08-20 17:38:42 +0000 | [diff] [blame] | 68 | execsql "SELECT rowid FROM t1 WHERE t1 MATCH '\"$aterm $bterm\"'" |
| 69 | } {1} |
| 70 | |
| 71 | finish_test |