13c9a0737Sdan# 2006 September 9 23c9a0737Sdan# 33c9a0737Sdan# The author disclaims copyright to this source code. In place of 43c9a0737Sdan# a legal notice, here is a blessing: 53c9a0737Sdan# 63c9a0737Sdan# May you do good and not evil. 73c9a0737Sdan# May you find forgiveness for yourself and forgive others. 83c9a0737Sdan# May you share freely, never taking more than you give. 93c9a0737Sdan# 103c9a0737Sdan#************************************************************************* 113c9a0737Sdan# This file implements regression tests for SQLite library. The 123c9a0737Sdan# focus of this script is testing the FTS3 module. 133c9a0737Sdan# 143c9a0737Sdan 153c9a0737Sdanset testdir [file dirname $argv0] 163c9a0737Sdansource $testdir/tester.tcl 173c9a0737Sdanset testprefix fts3expr5 183c9a0737Sdan 193c9a0737Sdan# If SQLITE_ENABLE_FTS3 is defined, omit this file. 203c9a0737Sdanifcapable !fts3 { 213c9a0737Sdan finish_test 223c9a0737Sdan return 233c9a0737Sdan} 243c9a0737Sdan 25*68c1f9ceSdanproc test_fts3expr {expr} { 26*68c1f9ceSdan db one {SELECT fts3_exprtest('simple', $expr, 'a', 'b', 'c')} 27*68c1f9ceSdan} 28*68c1f9ceSdan 293c9a0737Sdan#------------------------------------------------------------------------- 303c9a0737Sdan# Various forms of empty phrase expressions. 313c9a0737Sdan# 323c9a0737Sdando_execsql_test 1.0 { 333c9a0737Sdan CREATE VIRTUAL TABLE t0 USING fts3(x); 343c9a0737Sdan SELECT rowid FROM t0 WHERE x MATCH ''; 353c9a0737Sdan} {} 363c9a0737Sdando_execsql_test 1.1 { 373c9a0737Sdan SELECT rowid FROM t0 WHERE x MATCH '""'; 383c9a0737Sdan} {} 393c9a0737Sdando_execsql_test 1.2 { 403c9a0737Sdan SELECT rowid FROM t0 WHERE x MATCH '"" ""'; 413c9a0737Sdan} {} 423c9a0737Sdando_execsql_test 1.3 { 433c9a0737Sdan SELECT rowid FROM t0 WHERE x MATCH '"" OR ""'; 443c9a0737Sdan} {} 453c9a0737Sdando_execsql_test 1.4 { 463c9a0737Sdan SELECT rowid FROM t0 WHERE x MATCH '"" NOT ""'; 473c9a0737Sdan} {} 483c9a0737Sdando_execsql_test 1.5 { 493c9a0737Sdan SELECT rowid FROM t0 WHERE x MATCH '""""'; 503c9a0737Sdan} {} 513c9a0737Sdan 52*68c1f9ceSdan#------------------------------------------------------------------------- 53*68c1f9ceSdan# Various forms of empty phrase expressions. 54*68c1f9ceSdan# 55*68c1f9ceSdanset sqlite_fts3_enable_parentheses 1 56*68c1f9ceSdando_test 2.0 { 57*68c1f9ceSdan test_fts3expr {(a:123)(b:234)()(c:456)} 58*68c1f9ceSdan} {AND {AND {PHRASE 0 0 123} {PHRASE 1 0 234}} {PHRASE 2 0 456}} 59*68c1f9ceSdando_test 2.1 { 60*68c1f9ceSdan test_fts3expr {(a:123)(b:234)(c:456)} 61*68c1f9ceSdan} {AND {AND {PHRASE 0 0 123} {PHRASE 1 0 234}} {PHRASE 2 0 456}} 62*68c1f9ceSdando_test 2.2 { 63*68c1f9ceSdan list [catch { test_fts3expr {"123" AND ( )} } msg] $msg 64*68c1f9ceSdan} {1 {Error parsing expression}} 65*68c1f9ceSdan 663c9a0737Sdanfinish_test 67