| 1 |
# 2017 October 7 |
| 2 |
# |
| 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. |
| 9 |
# |
| 10 |
#************************************************************************* |
| 11 |
# This file implements regression tests for SQLite library. The |
| 12 |
# focus of this script is testing the FTS3 module. |
| 13 |
# |
| 14 |
|
| 15 |
set testdir [file dirname $argv0] |
| 16 |
source $testdir/tester.tcl |
| 17 |
set testprefix fts3rank |
| 18 |
|
| 19 |
# If SQLITE_ENABLE_FTS3 is defined, omit this file. |
| 20 |
ifcapable !fts3 { |
| 21 |
finish_test |
| 22 |
return |
| 23 |
} |
| 24 |
|
| 25 |
install_fts3_rank_function db |
| 26 |
do_execsql_test 1.0 { |
| 27 |
CREATE VIRTUAL TABLE t1 USING fts3(a, b); |
| 28 |
INSERT INTO t1 VALUES('one two', 'one'); |
| 29 |
INSERT INTO t1 VALUES('one two', 'three'); |
| 30 |
INSERT INTO t1 VALUES('one two', 'two'); |
| 31 |
} |
| 32 |
|
| 33 |
do_execsql_test 1.1 { |
| 34 |
SELECT * FROM t1 WHERE t1 MATCH 'one' |
| 35 |
ORDER BY rank(matchinfo(t1), 1.0, 1.0) DESC, rowid |
| 36 |
} { |
| 37 |
{one two} one |
| 38 |
{one two} three |
| 39 |
{one two} two |
| 40 |
} |
| 41 |
|
| 42 |
do_execsql_test 1.2 { |
| 43 |
SELECT * FROM t1 WHERE t1 MATCH 'two' |
| 44 |
ORDER BY rank(matchinfo(t1), 1.0, 1.0) DESC, rowid |
| 45 |
} { |
| 46 |
{one two} two |
| 47 |
{one two} one |
| 48 |
{one two} three |
| 49 |
} |
| 50 |
|
| 51 |
do_catchsql_test 1.3 { |
| 52 |
SELECT * FROM t1 ORDER BY rank(matchinfo(t1), 1.0, 1.0) DESC, rowid |
| 53 |
} {1 {invalid matchinfo blob passed to function rank()}} |
| 54 |
|
| 55 |
do_catchsql_test 1.4 { |
| 56 |
SELECT * FROM t1 ORDER BY rank(x'0000000000000000') DESC, rowid |
| 57 |
} {0 {{one two} one {one two} three {one two} two}} |
| 58 |
|
| 59 |
if {$tcl_platform(byteOrder)=="littleEndian"} { |
| 60 |
do_catchsql_test 1.5le { |
| 61 |
SELECT * FROM t1 ORDER BY rank(x'0100000001000000') DESC, rowid |
| 62 |
} {1 {invalid matchinfo blob passed to function rank()}} |
| 63 |
} else { |
| 64 |
do_catchsql_test 1.5be { |
| 65 |
SELECT * FROM t1 ORDER BY rank(x'0000000100000001') DESC, rowid |
| 66 |
} {1 {invalid matchinfo blob passed to function rank()}} |
| 67 |
} |
| 68 |
|
| 69 |
finish_test |