1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-08 14:02:16 +03:00

Fix the FTS1 test cases and add new tests. Comments added to the FTS1 code. (CVS 3409)

FossilOrigin-Name: 528036c828c93c78ca879bf89a52131b72e24067
This commit is contained in:
drh
2006-09-13 12:36:08 +00:00
parent 4f1a424e72
commit a6be0dc938
5 changed files with 136 additions and 22 deletions

View File

@@ -11,7 +11,7 @@
# This file implements regression tests for SQLite library. The
# focus of this script is testing the FTS1 module.
#
# $Id: fts1a.test,v 1.1 2006/09/10 03:34:06 drh Exp $
# $Id: fts1a.test,v 1.2 2006/09/13 12:36:09 drh Exp $
#
set testdir [file dirname $argv0]
@@ -28,7 +28,7 @@ ifcapable !fts1 {
# rowid for each will be a bitmask for the elements it contains.
#
db eval {
CREATE VIRTUAL TABLE t1 USING fts1;
CREATE VIRTUAL TABLE t1 USING fts1(content);
INSERT INTO t1(content) VALUES('one');
INSERT INTO t1(content) VALUES('two');
INSERT INTO t1(content) VALUES('one two');

84
test/fts1b.test Normal file
View File

@@ -0,0 +1,84 @@
# 2006 September 13
#
# The author disclaims copyright to this source code. In place of
# a legal notice, here is a blessing:
#
# May you do good and not evil.
# May you find forgiveness for yourself and forgive others.
# May you share freely, never taking more than you give.
#
#*************************************************************************
# This file implements regression tests for SQLite library. The
# focus of this script is testing the FTS1 module.
#
# $Id: fts1b.test,v 1.1 2006/09/13 12:36:09 drh Exp $
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
# If SQLITE_ENABLE_FTS1 is defined, omit this file.
ifcapable !fts1 {
finish_test
return
}
# Fill the full-text index "t1" with phrases in english, spanish,
# and german. For the i-th row, fill in the names for the bits
# that are set in the value of i. The least significant bit is
# 1. For example, the value 5 is 101 in binary which will be
# converted to "one three" in english.
#
proc fill_multilanguage_fulltext_t1 {} {
set english {one two three four five}
set spanish {un dos tres cuatro cinco}
set german {eine zwei drei vier funf}
for {set i 1} {$i<=31} {incr i} {
set cmd "INSERT INTO t1 VALUES"
set vset {}
foreach lang {english spanish german} {
set words {}
for {set j 0; set k 1} {$j<5} {incr j; incr k $k} {
if {$k&$i} {lappend words [lindex [set $lang] $j]}
}
lappend vset "'$words'"
}
set sql "INSERT INTO t1(english,spanish,german) VALUES([join $vset ,])"
# puts $sql
db eval $sql
}
}
# Construct a full-text search table containing five keywords:
# one, two, three, four, and five, in various combinations. The
# rowid for each will be a bitmask for the elements it contains.
#
db eval {
CREATE VIRTUAL TABLE t1 USING fts1(english,spanish,german);
}
fill_multilanguage_fulltext_t1
do_test fts1b-1.1 {
execsql {SELECT rowid FROM t1 WHERE english MATCH 'one'}
} {1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31}
do_test fts1b-1.2 {
execsql {SELECT rowid FROM t1 WHERE spanish MATCH 'one'}
} {}
do_test fts1b-1.3 {
execsql {SELECT rowid FROM t1 WHERE german MATCH 'one'}
} {}
do_test fts1b-1.4 {
execsql {SELECT rowid FROM t1 WHERE _all MATCH 'one'}
} {1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31}
do_test fts1b-1.5 {
execsql {SELECT rowid FROM t1 WHERE _all MATCH 'one dos drei'}
} {7 15 23 31}
do_test fts1b-1.6 {
execsql {SELECT english, spanish, german FROM t1 WHERE rowid=1}
} {one un eine}
do_test fts1b-1.7 {
execsql {SELECT rowid FROM t1 WHERE _all MATCH '"one un"'}
} {}
finish_test