skip uneccesary sqlcipher_free calls
[sqlcipher.git] / ext / fts5 / test / fts5trigram2.test
blobf5beae5b283a7fcb13aaff10819891b8211473f6
1 # 2023 October 24
3 # The author disclaims copyright to this source code.  In place of
4 # a legal notice, here is a blessing:
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.
10 #*************************************************************************
12 # Tests for the fts5 "trigram" tokenizer.
15 source [file join [file dirname [info script]] fts5_common.tcl]
16 ifcapable !fts5 { finish_test ; return }
17 set ::testprefix fts5trigram2
19 do_execsql_test 1.0 "
20   CREATE VIRTUAL TABLE t1 USING fts5(y, tokenize='trigram remove_diacritics 1');
21   INSERT INTO t1 VALUES('abc\u0303defghijklm');
22   INSERT INTO t1 VALUES('a\u0303b\u0303c\u0303defghijklm');
25 do_execsql_test 1.1 {
26   SELECT highlight(t1, 0, '(', ')') FROM t1('abc');
27 } [list \
28   "(abc\u0303)defghijklm"                          \
29   "(a\u0303b\u0303c\u0303)defghijklm"              \
32 do_execsql_test 1.2 {
33   SELECT highlight(t1, 0, '(', ')') FROM t1('bcde');
34 } [list \
35   "a(bc\u0303de)fghijklm"                          \
36   "a\u0303(b\u0303c\u0303de)fghijklm"              \
39 do_execsql_test 1.3 {
40   SELECT highlight(t1, 0, '(', ')') FROM t1('cdef');
41 } [list \
42   "ab(c\u0303def)ghijklm"                          \
43   "a\u0303b\u0303(c\u0303def)ghijklm"              \
46 do_execsql_test 1.4 {
47   SELECT highlight(t1, 0, '(', ')') FROM t1('def');
48 } [list \
49   "abc\u0303(def)ghijklm"                          \
50   "a\u0303b\u0303c\u0303(def)ghijklm"              \
54 #-------------------------------------------------------------------------
55 do_catchsql_test 2.0 {
56   CREATE VIRTUAL TABLE t2 USING fts5(
57       z, tokenize='trigram case_sensitive 1 remove_diacritics 1'
58   );
59 } {1 {error in tokenizer constructor}}
61 do_execsql_test 2.1 {
62   CREATE VIRTUAL TABLE t2 USING fts5(
63       z, tokenize='trigram case_sensitive 0 remove_diacritics 1'
64   );
66 do_execsql_test 2.2 "
67   INSERT INTO t2 VALUES('\u00E3bcdef');
68   INSERT INTO t2 VALUES('b\u00E3cdef');
69   INSERT INTO t2 VALUES('bc\u00E3def');
70   INSERT INTO t2 VALUES('bcd\u00E3ef');
73 do_execsql_test 2.3 {
74   SELECT highlight(t2, 0, '(', ')') FROM t2('abc');
75 } "(\u00E3bc)def"
76 do_execsql_test 2.4 {
77   SELECT highlight(t2, 0, '(', ')') FROM t2('bac');
78 } "(b\u00E3c)def"
79 do_execsql_test 2.5 {
80   SELECT highlight(t2, 0, '(', ')') FROM t2('bca');
81 } "(bc\u00E3)def"
82 do_execsql_test 2.6 "
83   SELECT highlight(t2, 0, '(', ')') FROM t2('\u00E3bc');
84 " "(\u00E3bc)def"
86 #-------------------------------------------------------------------------
87 do_execsql_test 3.0 {
88   CREATE VIRTUAL TABLE t3 USING fts5(
89       z, tokenize='trigram remove_diacritics 1'
90   );
91 } {}
92 do_execsql_test 3.1 "
93   INSERT INTO t3 VALUES ('\u0303abc\u0303');
95 do_execsql_test 3.2 {
96   SELECT highlight(t3, 0, '(', ')') FROM t3('abc');
97 } "\u0303(abc\u0303)"
99 #-------------------------------------------------------------------------
100 do_execsql_test 4.0 {
101   CREATE VIRTUAL TABLE t4 USING fts5(z, tokenize=trigram);
102 } {}
104 breakpoint
105 do_execsql_test 4.1 {
106   INSERT INTO t4 VALUES('ABCD');
107 } {}
109 finish_test