Debian Codegraph @

ext/fts5/test/fts5expr.test

raw
1 # 2024 August 8
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 fts5expr
17
18 # If SQLITE_ENABLE_FTS5 is not defined, omit this file.
19 ifcapable !fts5 {
20 finish_test
21 return
22 }
23
24 do_execsql_test 1.0 {
25 CREATE VIRTUAL TABLE x1 USING fts5(a);
26 INSERT INTO x1(rowid, a) VALUES (113, 'fts5 expr test');
27 }
28
29 do_execsql_test 1.1 {
30 SELECT rowid FROM x1('expr');
31 } {113}
32
33 for {set ii 0} {$ii < 300} {incr ii} {
34 set expr "expr "
35 append expr [string repeat "NOT abcd " $ii]
36
37 if {$ii<257} {
38 set res {0 113}
39 } else {
40 set res {1 {fts5 expression tree is too large (maximum depth 256)}}
41 }
42 do_catchsql_test 1.1.$ii {
43 SELECT rowid FROM x1($expr)
44 } $res
45 }
46
47 do_execsql_test 1.2 {
48 SELECT rowid FROM x1 WHERE a MATCH '"..."'
49 } {}
50
51 finish_test
52