github.com/jdgcs/sqlite3@v1.12.1-0.20210908114423-bc5f96e4dd51/testdata/tcl/fts3expr5.test (about)

     1  # 2006 September 9
     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 fts3expr5
    18  
    19  # If SQLITE_ENABLE_FTS3 is defined, omit this file.
    20  ifcapable !fts3 {
    21    finish_test
    22    return
    23  }
    24  
    25  proc test_fts3expr {expr} {
    26    db one {SELECT fts3_exprtest('simple', $expr, 'a', 'b', 'c')}
    27  }
    28  
    29  #-------------------------------------------------------------------------
    30  # Various forms of empty phrase expressions.
    31  #
    32  do_execsql_test 1.0 {
    33    CREATE VIRTUAL TABLE t0 USING fts3(x);
    34    SELECT rowid FROM t0 WHERE x MATCH '';
    35  } {}
    36  do_execsql_test 1.1 {
    37    SELECT rowid FROM t0 WHERE x MATCH '""';
    38  } {}
    39  do_execsql_test 1.2 {
    40    SELECT rowid FROM t0 WHERE x MATCH '"" ""';
    41  } {}
    42  do_execsql_test 1.3 {
    43    SELECT rowid FROM t0 WHERE x MATCH '"" OR ""';
    44  } {}
    45  do_execsql_test 1.4 {
    46    SELECT rowid FROM t0 WHERE x MATCH '"" NOT ""';
    47  } {}
    48  do_execsql_test 1.5 {
    49    SELECT rowid FROM t0 WHERE x MATCH '""""';
    50  } {}
    51  
    52  #-------------------------------------------------------------------------
    53  # Various forms of empty phrase expressions.
    54  #
    55  set sqlite_fts3_enable_parentheses 1
    56  do_test 2.0 {
    57    test_fts3expr {(a:123)(b:234)()(c:456)}
    58  } {AND {AND {PHRASE 0 0 123} {PHRASE 1 0 234}} {PHRASE 2 0 456}}
    59  do_test 2.1 {
    60    test_fts3expr {(a:123)(b:234)(c:456)}
    61  } {AND {AND {PHRASE 0 0 123} {PHRASE 1 0 234}} {PHRASE 2 0 456}}
    62  do_test 2.2 {
    63    list [catch { test_fts3expr {"123" AND ( )} } msg] $msg
    64  } {1 {Error parsing expression}}
    65  
    66  finish_test