modernc.org/cc@v1.0.1/v2/testdata/_sqlite/ext/fts5/test/fts5colset.test (about) 1 # 2016 August 10 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 FTS5 module. 13 # 14 15 source [file join [file dirname [info script]] fts5_common.tcl] 16 set testprefix fts5colset 17 18 # If SQLITE_ENABLE_FTS5 is not defined, omit this file. 19 ifcapable !fts5 { 20 finish_test 21 return 22 } 23 24 foreach_detail_mode $::testprefix { 25 if {[detail_is_none]} continue 26 27 do_execsql_test 1.0 { 28 CREATE VIRTUAL TABLE t1 USING fts5(a, b, c, d, detail=%DETAIL%); 29 INSERT INTO t1 VALUES('a', 'b', 'c', 'd'); -- 1 30 INSERT INTO t1 VALUES('d', 'a', 'b', 'c'); -- 2 31 INSERT INTO t1 VALUES('c', 'd', 'a', 'b'); -- 3 32 INSERT INTO t1 VALUES('b', 'c', 'd', 'a'); -- 4 33 } 34 35 foreach {tn q res} { 36 1 "a" {1 2 3 4} 37 2 "{a} : a" {1} 38 3 "-{a} : a" {2 3 4} 39 4 "- {a c} : a" {2 4} 40 5 " - {d d c} : a" {1 2} 41 6 "- {d c b a} : a" {} 42 7 "-{\"a\"} : b" {1 2 3} 43 8 "- c : a" {1 2 4} 44 9 "-c : a" {1 2 4} 45 10 "-\"c\" : a" {1 2 4} 46 } { 47 do_execsql_test 1.$tn { 48 SELECT rowid FROM t1($q) 49 } $res 50 } 51 52 foreach {tn q res} { 53 0 {{a} : (a AND ":")} {} 54 1 "{a b c} : (a AND d)" {2 3} 55 2 "{a b c} : (a AND b:d)" {3} 56 3 "{a b c} : (a AND d:d)" {} 57 4 "{b} : ( {b a} : ( {c b a} : ( {d b c a} : ( d OR c ) ) ) )" {3 4} 58 5 "{a} : ( {b a} : ( {c b a} : ( {d b c a} : ( d OR c ) ) ) )" {2 3} 59 6 "{a} : ( {b a} : ( {c b} : ( {d b c a} : ( d OR c ) ) ) )" {} 60 7 "{a b c} : (b:a AND c:b)" {2} 61 } { 62 do_execsql_test 2.$tn { 63 SELECT rowid FROM t1($q) 64 } $res 65 } 66 67 foreach {tn w res} { 68 0 "a MATCH 'a'" {1} 69 1 "b MATCH 'a'" {2} 70 2 "b MATCH '{a b c} : a'" {2} 71 3 "b MATCH 'a OR b'" {1 2} 72 4 "b MATCH 'a OR a:b'" {2} 73 5 "b MATCH 'a OR b:b'" {1 2} 74 } { 75 do_execsql_test 3.$tn " 76 SELECT rowid FROM t1 WHERE $w 77 " $res 78 } 79 80 do_catchsql_test 4.1 { 81 SELECT * FROM t1 WHERE rowid MATCH 'a' 82 } {1 {unable to use function MATCH in the requested context}} 83 } 84 85 86 finish_test