xref: /sqlite-3.40.0/test/fts3expr4.test (revision d2d8ca60)
1# 2014 May 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
15set testdir [file dirname $argv0]
16source $testdir/tester.tcl
17set testprefix fts3expr4
18
19# If SQLITE_ENABLE_FTS3 is defined, omit this file.
20ifcapable !fts3||!icu {
21  finish_test
22  return
23}
24
25set sqlite_fts3_enable_parentheses 1
26
27proc test_icu_fts3expr {expr} {
28  db one {SELECT fts3_exprtest('icu', $expr, 'a', 'b', 'c')}
29}
30
31proc do_icu_expr_test {tn expr res} {
32  uplevel [list do_test $tn [list test_icu_fts3expr $expr] $res]
33}
34
35#-------------------------------------------------------------------------
36#
37do_icu_expr_test 1.1 "abcd"    {PHRASE 3 0 abcd}
38do_icu_expr_test 1.2 " tag "   {PHRASE 3 0 tag}
39do_icu_expr_test 1.3 {"x y z"} {PHRASE 3 0 x y z}
40do_icu_expr_test 1.4 {x OR y}       {OR {PHRASE 3 0 x} {PHRASE 3 0 y}}
41do_icu_expr_test 1.5 {(x OR y)}     {OR {PHRASE 3 0 x} {PHRASE 3 0 y}}
42do_icu_expr_test 1.6 { "(x OR y)" } {PHRASE 3 0 ( x or y )}
43
44# In "col:word", if "col" is not the name of a column, the entire thing
45# is passed to the tokenizer.
46#
47do_icu_expr_test 1.7 {a:word} {PHRASE 0 0 word}
48do_icu_expr_test 1.8 {d:word} {PHRASE 3 0 d:word}
49
50set sqlite_fts3_enable_parentheses 0
51
52do_icu_expr_test 2.1 {
53  f (e NEAR/2 a)
54} {AND {AND {AND {PHRASE 3 0 f} {PHRASE 3 0 (}} {NEAR/2 {PHRASE 3 0 e} {PHRASE 3 0 a}}} {PHRASE 3 0 )}}
55
56finish_test
57
58