Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/sqlite/blob/master/test/fts3expr4.test # sqlite [Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `sqlite / test / fts3expr4.test` 91 lines ยท 2935 bytes Raw Blame History 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 15 set testdir [file dirname $argv0] 16 source $testdir/tester.tcl 17 set testprefix fts3expr4 18 19 # If SQLITE_ENABLE_FTS3 is defined, omit this file. 20 ifcapable !fts3||!icu { 21 finish_test 22 return 23 } 24 25 set sqlite_fts3_enable_parentheses 1 26 27 proc test_fts3expr {tokenizer expr} { 28 db one {SELECT fts3_exprtest($tokenizer, $expr, 'a', 'b', 'c')} 29 } 30 31 proc do_icu_expr_test {tn expr res} { 32 set res2 [list {*}$res] 33 uplevel [list do_test $tn [list test_fts3expr "icu en_US" $expr] $res2] 34 } 35 36 proc do_simple_expr_test {tn expr res} { 37 uplevel [list do_test $tn [list test_fts3expr simple $expr] [list {*}$res]] 38 } 39 40 #------------------------------------------------------------------------- 41 # 42 do_icu_expr_test 1.1 "abcd" {PHRASE 3 0 abcd} 43 do_icu_expr_test 1.2 " tag " {PHRASE 3 0 tag} 44 do_icu_expr_test 1.3 {"x y z"} {PHRASE 3 0 x y z} 45 do_icu_expr_test 1.4 {x OR y} {OR {PHRASE 3 0 x} {PHRASE 3 0 y}} 46 do_icu_expr_test 1.5 {(x OR y)} {OR {PHRASE 3 0 x} {PHRASE 3 0 y}} 47 do_icu_expr_test 1.6 { "(x OR y)" } {PHRASE 3 0 ( x or y )} 48 49 # In "col:word", if "col" is not the name of a column, the entire thing 50 # is passed to the tokenizer. 51 # 52 do_icu_expr_test 1.7 {a:word} {PHRASE 0 0 word} 53 # do_icu_expr_test 1.8 {d:word} {PHRASE 3 0 d:word} 54 do_test 1.8 { 55 set res [ 56 db one {SELECT fts3_exprtest('icu en_US', 'd:word', 'a', 'b', 'c')} 57 ] 58 expr { 59 $res=="PHRASE 3 0 d:word" || 60 $res=="AND {AND {PHRASE 3 0 d} {PHRASE 3 0 :}} {PHRASE 3 0 word}" 61 } 62 } 1 63 64 set sqlite_fts3_enable_parentheses 0 65 66 do_icu_expr_test 2.1 { 67 f (e NEAR/2 a) 68 } {AND {AND {AND {PHRASE 3 0 f} {PHRASE 3 0 (}} {NEAR/2 {PHRASE 3 0 e} {PHRASE 3 0 a}}} {PHRASE 3 0 )}} 69 70 #------------------------------------------------------------------------- 71 # 72 do_simple_expr_test 3.1 {*lOl* *h4h*} { 73 AND {PHRASE 3 0 lol+} {PHRASE 3 0 h4h+} 74 } 75 76 do_icu_expr_test 3.2 {*lOl* *h4h*} { 77 AND {AND {AND {PHRASE 3 0 *} {PHRASE 3 0 lol+}} {PHRASE 3 0 *}} {PHRASE 3 0 h4h+} 78 } 79 80 do_simple_expr_test 3.3 { * } {} 81 do_simple_expr_test 3.4 { *a } { PHRASE 3 0 a } 82 do_simple_expr_test 3.5 { a*b } { AND {PHRASE 3 0 a+} {PHRASE 3 0 b} } 83 do_simple_expr_test 3.6 { *a*b } { AND {PHRASE 3 0 a+} {PHRASE 3 0 b} } 84 do_simple_expr_test 3.7 { *"abc" } { PHRASE 3 0 abc } 85 do_simple_expr_test 3.8 { "abc"* } { PHRASE 3 0 abc } 86 do_simple_expr_test 3.8 { "ab*c" } { PHRASE 3 0 ab+ c } 87 88 do_icu_expr_test 3.9 { "ab*c" } { PHRASE 3 0 ab+ * c } 89 do_icu_expr_test 3.10 { ab*c } { AND {PHRASE 3 0 ab+} {PHRASE 3 0 c}} 90 91 finish_test