xref: /sqlite-3.40.0/test/fts3expr4.test (revision 69e224f8)
1d2d8ca60Sdan# 2014 May 7
2d2d8ca60Sdan#
3d2d8ca60Sdan# The author disclaims copyright to this source code.  In place of
4d2d8ca60Sdan# a legal notice, here is a blessing:
5d2d8ca60Sdan#
6d2d8ca60Sdan#    May you do good and not evil.
7d2d8ca60Sdan#    May you find forgiveness for yourself and forgive others.
8d2d8ca60Sdan#    May you share freely, never taking more than you give.
9d2d8ca60Sdan#
10d2d8ca60Sdan#*************************************************************************
11d2d8ca60Sdan# This file implements regression tests for SQLite library.  The
12d2d8ca60Sdan# focus of this script is testing the FTS3 module.
13d2d8ca60Sdan#
14d2d8ca60Sdan
15d2d8ca60Sdanset testdir [file dirname $argv0]
16d2d8ca60Sdansource $testdir/tester.tcl
17d2d8ca60Sdanset testprefix fts3expr4
18d2d8ca60Sdan
19d2d8ca60Sdan# If SQLITE_ENABLE_FTS3 is defined, omit this file.
20d2d8ca60Sdanifcapable !fts3||!icu {
21d2d8ca60Sdan  finish_test
22d2d8ca60Sdan  return
23d2d8ca60Sdan}
24d2d8ca60Sdan
25d2d8ca60Sdanset sqlite_fts3_enable_parentheses 1
26d2d8ca60Sdan
276e1a0373Sdanproc test_fts3expr {tokenizer expr} {
286e1a0373Sdan  db one {SELECT fts3_exprtest($tokenizer, $expr, 'a', 'b', 'c')}
29d2d8ca60Sdan}
30d2d8ca60Sdan
31d2d8ca60Sdanproc do_icu_expr_test {tn expr res} {
32*03db962aSdan  set res2 [list {*}$res]
33*03db962aSdan  uplevel [list do_test $tn [list test_fts3expr "icu en_US" $expr] $res2]
346e1a0373Sdan}
356e1a0373Sdan
366e1a0373Sdanproc do_simple_expr_test {tn expr res} {
376e1a0373Sdan  uplevel [list do_test $tn [list test_fts3expr simple $expr] [list {*}$res]]
38d2d8ca60Sdan}
39d2d8ca60Sdan
40d2d8ca60Sdan#-------------------------------------------------------------------------
41d2d8ca60Sdan#
42d2d8ca60Sdando_icu_expr_test 1.1 "abcd"    {PHRASE 3 0 abcd}
43d2d8ca60Sdando_icu_expr_test 1.2 " tag "   {PHRASE 3 0 tag}
44d2d8ca60Sdando_icu_expr_test 1.3 {"x y z"} {PHRASE 3 0 x y z}
45d2d8ca60Sdando_icu_expr_test 1.4 {x OR y}       {OR {PHRASE 3 0 x} {PHRASE 3 0 y}}
46d2d8ca60Sdando_icu_expr_test 1.5 {(x OR y)}     {OR {PHRASE 3 0 x} {PHRASE 3 0 y}}
47d2d8ca60Sdando_icu_expr_test 1.6 { "(x OR y)" } {PHRASE 3 0 ( x or y )}
48d2d8ca60Sdan
49d2d8ca60Sdan# In "col:word", if "col" is not the name of a column, the entire thing
50d2d8ca60Sdan# is passed to the tokenizer.
51d2d8ca60Sdan#
52d2d8ca60Sdando_icu_expr_test 1.7 {a:word} {PHRASE 0 0 word}
53d2d8ca60Sdando_icu_expr_test 1.8 {d:word} {PHRASE 3 0 d:word}
54d2d8ca60Sdan
55d2d8ca60Sdanset sqlite_fts3_enable_parentheses 0
56d2d8ca60Sdan
57d2d8ca60Sdando_icu_expr_test 2.1 {
58d2d8ca60Sdan  f (e NEAR/2 a)
59d2d8ca60Sdan} {AND {AND {AND {PHRASE 3 0 f} {PHRASE 3 0 (}} {NEAR/2 {PHRASE 3 0 e} {PHRASE 3 0 a}}} {PHRASE 3 0 )}}
60d2d8ca60Sdan
616e1a0373Sdan#-------------------------------------------------------------------------
626e1a0373Sdan#
636e1a0373Sdando_simple_expr_test 3.1 {*lOl* *h4h*} {
646e1a0373Sdan  AND {PHRASE 3 0 lol+} {PHRASE 3 0 h4h+}
656e1a0373Sdan}
666e1a0373Sdan
676e1a0373Sdando_icu_expr_test 3.2 {*lOl* *h4h*} {
686e1a0373Sdan  AND {AND {AND {PHRASE 3 0 *} {PHRASE 3 0 lol+}} {PHRASE 3 0 *}} {PHRASE 3 0 h4h+}
696e1a0373Sdan}
706e1a0373Sdan
716e1a0373Sdando_simple_expr_test 3.3 { * }    {}
726e1a0373Sdando_simple_expr_test 3.4 { *a }   { PHRASE 3 0 a }
736e1a0373Sdando_simple_expr_test 3.5 { a*b }  { AND {PHRASE 3 0 a+} {PHRASE 3 0 b} }
746e1a0373Sdando_simple_expr_test 3.6 { *a*b } { AND {PHRASE 3 0 a+} {PHRASE 3 0 b} }
756e1a0373Sdando_simple_expr_test 3.7 { *"abc" } { PHRASE 3 0 abc }
766e1a0373Sdando_simple_expr_test 3.8 { "abc"* } { PHRASE 3 0 abc }
776e1a0373Sdando_simple_expr_test 3.8 { "ab*c" } { PHRASE 3 0 ab+ c }
786e1a0373Sdan
796e1a0373Sdando_icu_expr_test    3.9 { "ab*c" } { PHRASE 3 0 ab+ * c }
806e1a0373Sdando_icu_expr_test    3.10 { ab*c } { AND {PHRASE 3 0 ab+} {PHRASE 3 0 c}}
816e1a0373Sdan
82d2d8ca60Sdanfinish_test
83